PageSourceSearch

https://csvmeta.com/assets/index-DCl3feYb.js

js csvmeta.com collected 2026-10-02 14:44:08 UTC 2,750,277 bytes, 7,175 lines download raw bytes

vendor: 7,659 bytes, lines 1-17
1var kde=Object.defineProperty;var LB=t=>{throw TypeError(t)};var Ide=(t,e,n)=>e in t?kde(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var os=(t,e,n)=>Ide(t,typeof e!="symbol"?e+"":e,n),d4=(t,e,n)=>e.has(t)||LB("Cannot "+n);var _=(t,e,n)=>(d4(t,e,"read from private field"),n?n.call(t):e.get(t)),oe=(t,e,n)=>e.has(t)?LB("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),te=(t,e,n,s)=>(d4(t,e,"write to private field"),s?s.call(t,n):e.set(t,n),n),le=(t,e,n)=>(d4(t,e,"access private method"),n);var Vl=(t,e,n,s)=>({set _(r){te(t,e,r,n)},get _(){return _(t,e,s)}});function Nde(t,e){for(var n=0;n<e.length;n++){const s=e[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();var md=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function JR(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h4={exports:{}},R2={};/**
2 * @license React
3 * react-jsx-runtime.production.js
4 *
5 * Copyright (c) Meta Platforms, Inc. and affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */var jB;function Rde(){if(jB)return R2;jB=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(s,r,i){var a=null;if(i!==void 0&&(a=""+i),r.key!==void 0&&(a=""+r.key),"key"in r){i={};for(var o in r)o!=="key"&&(i[o]=r[o])}else i=r;return r=i.ref,{$$typeof:t,type:s,key:a,ref:r!==void 0?r:null,props:i}}return R2.Fragment=e,R2.jsx=n,R2.jsxs=n,R2}var BB;function Mde(){return BB||(BB=1,h4.exports=Rde()),h4.exports}var d=Mde(),f4={exports:{}},qs={};/**
10 * @license React
11 * react.production.js
12 *
13 * Copyright (c) Meta Platforms, Inc. and affiliates.
14 *
15 * This source code is licensed under the MIT license found in the
16 * LICENSE file in the root directory of this source tree.
17 */var UB;function Pde(){if(UB)return qs;UB=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;function m(ce){return ce===null||typeof ce!="object"?null:(ce=p&&ce[p]||ce["@@iterator"],typeof ce=="function"?ce:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function S(ce,ie,de){this.props=ce,this.context=ie,this.refs=b,this.updater=de||y}S.prototype.isReactComponent={},S.prototype.setState=function(ce,ie){if(typeof ce!="object"&&typeof ce!="function"&&ce!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,ce,ie,"setState")},S.prototype.forceUpdate=function(ce){this.updater.enqueueForceUpdate(this,ce,"forceUpdate")};function E(){}E.prototype=S.prototype;function I(ce,ie,de){this.props=ce,this.context=ie,this.refs=b,this.updater=de||y}var M=I.prototype=new E;M.constructor=I,v(M,S.prototype),M.isPureReactComponent=!0;var j=Array.isArray,L={H:null,A:null,T:null,S:null},K=Object.prototype.hasOwnProperty;function D(ce,ie,de,Re,Se,De){return de=De.ref,{$$typeof:t,type:ce,key:ie,ref:de!==void 0?de:null,props:De}}function R(ce,ie){return D(ce.type,ie,void 0,void 0,void 0,ce.props)}function B(ce){return typeof ce=="object"&&ce!==null&&ce.$$typeof===t}function G(ce){var ie={"=":"=0",":":"=2"};return"$"+ce.replace(/[=:]/g,function(de){return ie[de]})}var X=/\/+/g;function H(ce,ie){return typeof ce=="object"&&ce!==null&&ce.key!=null?G(""+ce.key):ie.toString(36)}function Y(){}function F(ce){switch(ce.status){case"fulfilled":return ce.value;case"rejected":throw ce.reason;default:switch(typeof ce.status=="string"?ce.then(Y,Y):(ce.status="pending",ce.then(function(ie){ce.status==="pending"&&(ce.status="fulfilled",ce.value=ie)},function(ie){ce.status==="pending"&&(ce.status="rejected",ce.reason=ie)})),ce.status){case"fulfilled":return ce.value;case"rejected":throw ce.reason}}throw ce}function we(ce,ie,de,Re,Se){var De=typeof ce;(De==="undefined"||De==="boolean")&&(ce=null);var gt=!1;if(ce===null)gt=!0;else switch(De){case"bigint":case"string":case"number":gt=!0;break;case"object":switch(ce.$$typeof){case t:case e:gt=!0;break;case h:return gt=ce._init,we(gt(ce._payload),ie,de,Re,Se)}}if(gt)return Se=Se(ce),gt=Re===""?"."+H(ce,0):Re,j(Se)?(de="",gt!=null&&(de=gt.replace(X,"$&/")+"/"),we(Se,ie,de,"",function(Nt){return Nt})):Se!=null&&(B(Se)&&(Se=R(Se,de+(Se.key==null||ce&&ce.key===Se.key?"":(""+Se.key).replace(X,"$&/")+"/")+gt)),ie.push(Se)),1;gt=0;var yt=Re===""?".":Re+":";if(j(ce))for(var xt=0;xt<ce.length;xt++)Re=ce[xt],De=yt+H(Re,xt),gt+=we(Re,ie,de,De,Se);else if(xt=m(ce),typeof xt=="function")for(ce=xt.call(ce),xt=0;!(Re=ce.next()).done;)Re=Re.value,De=yt+H(Re,xt++),gt+=we(Re,ie,de,De,Se);else if(De==="object"){if(typeof ce.then=="function")return we(F(ce),ie,de,Re,Se);throw ie=String(ce),Error("Objects are not valid as a React child (found: "+(ie==="[object Object]"?"object with keys {"+Object.keys(ce).join(", ")+"}":ie)+"). If you meant to render a collection of children, use an array instead.")}return gt}function me(ce,ie,de){if(ce==null)return ce;var Re=[],Se=0;return we(ce,Re,"","",function(De){return ie.call(de,De,Se++)}),Re}function xe(ce){if(ce._status===-1){var ie=ce._result;ie=ie(),ie.then(function(de){(ce._status===0||ce._status===-1)&&(ce._status=1,ce._result=de)},function(de){(ce._status===0||ce._status===-1)&&(ce._status=2,ce._result=de)}),ce._status===-1&&(ce._status=0,ce._result=ie)}if(ce._status===1)return ce._result.default;throw ce._result}var Le=typeof reportError=="function"?reportError:function(ce){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ie=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof ce=="object"&&ce!==null&&typeof ce.message=="string"?String(ce.message):String(ce),error:ce});if(!window.dispatchEvent(ie))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",ce);return}console.error(ce)};function ve(){}return qs.Children={map:me,forEach:function(ce,ie,de){me(ce,function(){ie.apply(this,arguments)},de)},count:function(ce){var ie=0;return me(ce,function(){ie++}),ie},toArray:function(ce){return me(ce,function(ie){return ie})||[]},only:function(ce){if(!B(ce))throw Error("React.Children.only expected to receive a single React element child.");return ce}}
vendor: 29,620 bytes, lines 17-48
17,qs.Component=S,qs.Fragment=n,qs.Profiler=r,qs.PureComponent=I,qs.StrictMode=s,qs.Suspense=l,qs.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,qs.act=function(){throw Error("act(...) is not supported in production builds of React.")},qs.cache=function(ce){return function(){return ce.apply(null,arguments)}},qs.cloneElement=function(ce,ie,de){if(ce==null)throw Error("The argument must be a React element, but you passed "+ce+".");var Re=v({},ce.props),Se=ce.key,De=void 0;if(ie!=null)for(gt in ie.ref!==void 0&&(De=void 0),ie.key!==void 0&&(Se=""+ie.key),ie)!K.call(ie,gt)||gt==="key"||gt==="__self"||gt==="__source"||gt==="ref"&&ie.ref===void 0||(Re[gt]=ie[gt]);var gt=arguments.length-2;if(gt===1)Re.children=de;else if(1<gt){for(var yt=Array(gt),xt=0;xt<gt;xt++)yt[xt]=arguments[xt+2];Re.children=yt}return D(ce.type,Se,void 0,void 0,De,Re)},qs.createContext=function(ce){return ce={$$typeof:a,_currentValue:ce,_currentValue2:ce,_threadCount:0,Provider:null,Consumer:null},ce.Provider=ce,ce.Consumer={$$typeof:i,_context:ce},ce},qs.createElement=function(ce,ie,de){var Re,Se={},De=null;if(ie!=null)for(Re in ie.key!==void 0&&(De=""+ie.key),ie)K.call(ie,Re)&&Re!=="key"&&Re!=="__self"&&Re!=="__source"&&(Se[Re]=ie[Re]);var gt=arguments.length-2;if(gt===1)Se.children=de;else if(1<gt){for(var yt=Array(gt),xt=0;xt<gt;xt++)yt[xt]=arguments[xt+2];Se.children=yt}if(ce&&ce.defaultProps)for(Re in gt=ce.defaultProps,gt)Se[Re]===void 0&&(Se[Re]=gt[Re]);return D(ce,De,void 0,void 0,null,Se)},qs.createRef=function(){return{current:null}},qs.forwardRef=function(ce){return{$$typeof:o,render:ce}},qs.isValidElement=B,qs.lazy=function(ce){return{$$typeof:h,_payload:{_status:-1,_result:ce},_init:xe}},qs.memo=function(ce,ie){return{$$typeof:c,type:ce,compare:ie===void 0?null:ie}},qs.startTransition=function(ce){var ie=L.T,de={};L.T=de;try{var Re=ce(),Se=L.S;Se!==null&&Se(de,Re),typeof Re=="object"&&Re!==null&&typeof Re.then=="function"&&Re.then(ve,Le)}catch(De){Le(De)}finally{L.T=ie}},qs.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},qs.use=function(ce){return L.H.use(ce)},qs.useActionState=function(ce,ie,de){return L.H.useActionState(ce,ie,de)},qs.useCallback=function(ce,ie){return L.H.useCallback(ce,ie)},qs.useContext=function(ce){return L.H.useContext(ce)},qs.useDebugValue=function(){},qs.useDeferredValue=function(ce,ie){return L.H.useDeferredValue(ce,ie)},qs.useEffect=function(ce,ie){return L.H.useEffect(ce,ie)},qs.useId=function(){return L.H.useId()},qs.useImperativeHandle=function(ce,ie,de){return L.H.useImperativeHandle(ce,ie,de)},qs.useInsertionEffect=function(ce,ie){return L.H.useInsertionEffect(ce,ie)},qs.useLayoutEffect=function(ce,ie){return L.H.useLayoutEffect(ce,ie)},qs.useMemo=function(ce,ie){return L.H.useMemo(ce,ie)},qs.useOptimistic=function(ce,ie){return L.H.useOptimistic(ce,ie)},qs.useReducer=function(ce,ie,de){return L.H.useReducer(ce,ie,de)},qs.useRef=function(ce){return L.H.useRef(ce)},qs.useState=function(ce){return L.H.useState(ce)},qs.useSyncExternalStore=function(ce,ie,de){return L.H.useSyncExternalStore(ce,ie,de)},qs.useTransition=function(){return L.H.useTransition()},qs.version="19.0.0",qs}var FB;function qO(){return FB||(FB=1,f4.exports=Pde()),f4.exports}var q=qO();const WO=JR(q),$de=Nde({__proto__:null,default:WO},[q]);var p4={exports:{}},M2={},m4={exports:{}},g4={};/**
18 * @license React
19 * scheduler.production.js
20 *
21 * Copyright (c) Meta Platforms, Inc. and affiliates.
22 *
23 * This source code is licensed under the MIT license found in the
24 * LICENSE file in the root directory of this source tree.
25 */var VB;function Dde(){return VB||(VB=1,(function(t){function e(me,xe){var Le=me.length;me.push(xe);e:for(;0<Le;){var ve=Le-1>>>1,ce=me[ve];if(0<r(ce,xe))me[ve]=xe,me[Le]=ce,Le=ve;else break e}}function n(me){return me.length===0?null:me[0]}function s(me){if(me.length===0)return null;var xe=me[0],Le=me.pop();if(Le!==xe){me[0]=Le;e:for(var ve=0,ce=me.length,ie=ce>>>1;ve<ie;){var de=2*(ve+1)-1,Re=me[de],Se=de+1,De=me[Se];if(0>r(Re,Le))Se<ce&&0>r(De,Re)?(me[ve]=De,me[Se]=Le,ve=Se):(me[ve]=Re,me[de]=Le,ve=de);else if(Se<ce&&0>r(De,Le))me[ve]=De,me[Se]=Le,ve=Se;else break e}}return xe}function r(me,xe){var Le=me.sortIndex-xe.sortIndex;return Le!==0?Le:me.id-xe.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var l=[],c=[],h=1,p=null,m=3,y=!1,v=!1,b=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function M(me){for(var xe=n(c);xe!==null;){if(xe.callback===null)s(c);else if(xe.startTime<=me)s(c),xe.sortIndex=xe.expirationTime,e(l,xe);else break;xe=n(c)}}function j(me){if(b=!1,M(me),!v)if(n(l)!==null)v=!0,F();else{var xe=n(c);xe!==null&&we(j,xe.startTime-me)}}var L=!1,K=-1,D=5,R=-1;function B(){return!(t.unstable_now()-R<D)}function G(){if(L){var me=t.unstable_now();R=me;var xe=!0;try{e:{v=!1,b&&(b=!1,E(K),K=-1),y=!0;var Le=m;try{t:{for(M(me),p=n(l);p!==null&&!(p.expirationTime>me&&B());){var ve=p.callback;if(typeof ve=="function"){p.callback=null,m=p.priorityLevel;var ce=ve(p.expirationTime<=me);if(me=t.unstable_now(),typeof ce=="function"){p.callback=ce,M(me),xe=!0;break t}p===n(l)&&s(l),M(me)}else s(l);p=n(l)}if(p!==null)xe=!0;else{var ie=n(c);ie!==null&&we(j,ie.startTime-me),xe=!1}}break e}finally{p=null,m=Le,y=!1}xe=void 0}}finally{xe?X():L=!1}}}var X;if(typeof I=="function")X=function(){I(G)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,Y=H.port2;H.port1.onmessage=G,X=function(){Y.postMessage(null)}}else X=function(){S(G,0)};function F(){L||(L=!0,X())}function we(me,xe){K=S(function(){me(t.unstable_now())},xe)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(me){me.callback=null},t.unstable_continueExecution=function(){v||y||(v=!0,F())},t.unstable_forceFrameRate=function(me){0>me||125<me?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<me?Math.floor(1e3/me):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_getFirstCallbackNode=function(){return n(l)},t.unstable_next=function(me){switch(m){case 1:case 2:case 3:var xe=3;break;default:xe=m}var Le=m;m=xe;try{return me()}finally{m=Le}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(me,xe){switch(me){case 1:case 2:case 3:case 4:case 5:break;default:me=3}var Le=m;m=me;try{return xe()}finally{m=Le}},t.unstable_scheduleCallback=function(me,xe,Le){var ve=t.unstable_now();switch(typeof Le=="object"&&Le!==null?(Le=Le.delay,Le=typeof Le=="number"&&0<Le?ve+Le:ve):Le=ve,me){case 1:var ce=-1;break;case 2:ce=250;break;case 5:ce=1073741823;break;case 4:ce=1e4;break;default:ce=5e3}return ce=Le+ce,me={id:h++,callback:xe,priorityLevel:me,startTime:Le,expirationTime:ce,sortIndex:-1},Le>ve?(me.sortIndex=Le,e(c,me),n(l)===null&&me===n(c)&&(b?(E(K),K=-1):b=!0,we(j,Le-ve))):(me.sortIndex=ce,e(l,me),v||y||(v=!0,F())),me},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(me){var xe=m;return function(){var Le=m;m=xe;try{return me.apply(this,arguments)}finally{m=Le}}}})(g4)),g4}var zB;function Ode(){return zB||(zB=1,m4.exports=Dde()),m4.exports}var y4={exports:{}},il={};/**
26 * @license React
27 * react-dom.production.js
28 *
29 * Copyright (c) Meta Platforms, Inc. and affiliates.
30 *
31 * This source code is licensed under the MIT license found in the
32 * LICENSE file in the root directory of this source tree.
33 */var GB;function Lde(){if(GB)return il;GB=1;var t=qO();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)c+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");function i(l,c,h){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:p==null?null:""+p,children:l,containerInfo:c,implementation:h}}var a=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(l,c){if(l==="font")return"";if(typeof c=="string")return c==="use-credentials"?c:""}return il.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,il.createPortal=function(l,c){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)throw Error(e(299));return i(l,c,null,h)},il.flushSync=function(l){var c=a.T,h=s.p;try{if(a.T=null,s.p=2,l)return l()}finally{a.T=c,s.p=h,s.d.f()}},il.preconnect=function(l,c){typeof l=="string"&&(c?(c=c.crossOrigin,c=typeof c=="string"?c==="use-credentials"?c:"":void 0):c=null,s.d.C(l,c))},il.prefetchDNS=function(l){typeof l=="string"&&s.d.D(l)},il.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var h=c.as,p=o(h,c.crossOrigin),m=typeof c.integrity=="string"?c.integrity:void 0,y=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;h==="style"?s.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:p,integrity:m,fetchPriority:y}):h==="script"&&s.d.X(l,{crossOrigin:p,integrity:m,fetchPriority:y,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},il.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var h=o(c.as,c.crossOrigin);s.d.M(l,{crossOrigin:h,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0})}}else c==null&&s.d.M(l)},il.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var h=c.as,p=o(h,c.crossOrigin);s.d.L(l,h,{crossOrigin:p,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0,type:typeof c.type=="string"?c.type:void 0,fetchPriority:typeof c.fetchPriority=="string"?c.fetchPriority:void 0,referrerPolicy:typeof c.referrerPolicy=="string"?c.referrerPolicy:void 0,imageSrcSet:typeof c.imageSrcSet=="string"?c.imageSrcSet:void 0,imageSizes:typeof c.imageSizes=="string"?c.imageSizes:void 0,media:typeof c.media=="string"?c.media:void 0})}},il.preloadModule=function(l,c){if(typeof l=="string")if(c){var h=o(c.as,c.crossOrigin);s.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:h,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else s.d.m(l)},il.requestFormReset=function(l){s.d.r(l)},il.unstable_batchedUpdates=function(l,c){return l(c)},il.useFormState=function(l,c,h){return a.H.useFormState(l,c,h)},il.useFormStatus=function(){return a.H.useHostTransitionStatus()},il.version="19.0.0",il}var HB;function iK(){if(HB)return y4.exports;HB=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),y4.exports=Lde(),y4.exports}/**
34 * @license React
35 * react-dom-client.production.js
36 *
37 * Copyright (c) Meta Platforms, Inc. and affiliates.
38 *
39 * This source code is licensed under the MIT license found in the
40 * LICENSE file in the root directory of this source tree.
41 */var qB;function jde(){if(qB)return M2;qB=1;var t=Ode(),e=qO(),n=iK();function s(u){var f="https://react.dev/errors/"+u;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)f+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+u+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}var i=Symbol.for("react.element"),a=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),p=Symbol.for("react.provider"),m=Symbol.for("react.consumer"),y=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),M=Symbol.for("react.offscreen"),j=Symbol.for("react.memo_cache_sentinel"),L=Symbol.iterator;function K(u){return u===null||typeof u!="object"?null:(u=L&&u[L]||u["@@iterator"],typeof u=="function"?u:null)}var D=Symbol.for("react.client.reference");function R(u){if(u==null)return null;if(typeof u=="function")return u.$$typeof===D?null:u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case l:return"Fragment";case o:return"Portal";case h:return"Profiler";case c:return"StrictMode";case b:return"Suspense";case S:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case y:return(u.displayName||"Context")+".Provider";case m:return(u._context.displayName||"Context")+".Consumer";case v:var f=u.render;return u=u.displayName,u||(u=f.displayName||f.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case E:return f=u.displayName||null,f!==null?f:R(u.type)||"Memo";case I:f=u._payload,u=u._init;try{return R(u(f))}catch{}}return null}var B=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=Object.assign,X,H;function Y(u){if(X===void 0)try{throw Error()}catch(g){var f=g.stack.trim().match(/\n( *(at )?)/);X=f&&f[1]||"",H=-1<g.stack.indexOf(`
42    at`)?" (<anonymous>)":-1<g.stack.indexOf("@")?"@unknown:0:0":""}return`
43`+X+u+H}var F=!1;function we(u,f){if(!u||F)return"";F=!0;var g=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var w={DetermineComponentFrameRoot:function(){try{if(f){var Pt=function(){throw Error()};if(Object.defineProperty(Pt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pt,[])}catch(Et){var it=Et}Reflect.construct(u,[],Pt)}else{try{Pt.call()}catch(Et){it=Et}u.call(Pt.prototype)}}else{try{throw Error()}catch(Et){it=Et}(Pt=u())&&typeof Pt.catch=="function"&&Pt.catch(function(){})}}catch(Et){if(Et&&it&&typeof Et.stack=="string")return[Et.stack,it.stack]}return[null,null]}};w.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var N=Object.getOwnPropertyDescriptor(w.DetermineComponentFrameRoot,"name");N&&N.configurable&&Object.defineProperty(w.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=w.DetermineComponentFrameRoot(),se=O[0],fe=O[1];if(se&&fe){var Ce=se.split(`
44`),Ge=fe.split(`
45`);for(N=w=0;w<Ce.length&&!Ce[w].includes("DetermineComponentFrameRoot");)w++;for(;N<Ge.length&&!Ge[N].includes("DetermineComponentFrameRoot");)N++;if(w===Ce.length||N===Ge.length)for(w=Ce.length-1,N=Ge.length-1;1<=w&&0<=N&&Ce[w]!==Ge[N];)N--;for(;1<=w&&0<=N;w--,N--)if(Ce[w]!==Ge[N]){if(w!==1||N!==1)do if(w--,N--,0>N||Ce[w]!==Ge[N]){var At=`
46`+Ce[w].replace(" at new "," at ");return u.displayName&&At.includes("<anonymous>")&&(At=At.replace("<anonymous>",u.displayName)),At}while(1<=w&&0<=N);break}}}finally{F=!1,Error.prepareStackTrace=g}return(g=u?u.displayName||u.name:"")?Y(g):""}function me(u){switch(u.tag){case 26:case 27:case 5:return Y(u.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 15:return u=we(u.type,!1),u;case 11:return u=we(u.type.render,!1),u;case 1:return u=we(u.type,!0),u;default:return""}}function xe(u){try{var f="";do f+=me(u),u=u.return;while(u);return f}catch(g){return`
47Error generating stack: `+g.message+`
48`+g.stack}}function Le(u){var f=u,g=u;if(u.alternate)for(;f.return;)f=f.return;else{u=f;do f=u,(f.flags&4098)!==0&&(g=f.return),u=f.return;while(u)}return f.tag===3?g:null}function ve(u){if(u.tag===13){var f=u.memoizedState;if(f===null&&(u=u.alternate,u!==null&&(f=u.memoizedState)),f!==null)return f.dehydrated}return null}function ce(u){if(Le(u)!==u)throw Error(s(188))}function ie(u){var f=u.alternate;if(!f){if(f=Le(u),f===null)throw Error(s(188));return f!==u?null:u}for(var g=u,w=f;;){var N=g.return;if(N===null)break;var O=N.alternate;if(O===null){if(w=N.return,w!==null){g=w;continue}break}if(N.child===O.child){for(O=N.child;O;){if(O===g)return ce(N),u;if(O===w)return ce(N),f;O=O.sibling}throw Error(s(188))}if(g.return!==w.return)g=N,w=O;else{for(var se=!1,fe=N.child;fe;){if(fe===g){se=!0,g=N,w=O;break}if(fe===w){se=!0,w=N,g=O;break}fe=fe.sibling}if(!se){for(fe=O.child;fe;){if(fe===g){se=!0,g=O,w=N;break}if(fe===w){se=!0,w=O,g=N;break}fe=fe.sibling}if(!se)throw Error(s(189))}}if(g.alternate!==w)throw Error(s(190))}if(g.tag!==3)throw Error(s(188));return g.stateNode.current===g?u:f}function de(u){var f=u.tag;if(f===5||f===26||f===27||f===6)return u;for(u=u.child;u!==null;){if(f=de(u),f!==null)return f;u=u.sibling}return null}var Re=Array.isArray,Se=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,De={pending:!1,data:null,method:null,action:null},gt=[],yt=-1;function xt(u){return{current:u}}function Nt(u){0>yt||(u.current=gt[yt],gt[yt]=null,yt--)}function wt(u,f){yt++,gt[yt]=u.current,u.current=f}var zt=xt(null),_n=xt(null),Zt=xt(null),J=xt(null);function We(u,f){switch(wt(Zt,f),wt(_n,u),wt(zt,null),u=f.nodeType,u){case 9:case 11:f=(f=f.documentElement)&&(f=f.namespaceURI)?i2(f):0;break;default:if(u=u===8?f.parentNode:f,f=u.tagName,u=u.namespaceURI)u=i2(u),f=ky(u,f);else switch(f){case"svg":f=1;break;case"math":f=2;break;default:f=0}}Nt(zt),wt(zt,f)}function Ie(){Nt(zt),Nt(_n),Nt(Zt)}function ge(u){u.memoizedState!==null&&wt(J,u);var f=zt.current,g=ky(f,u.type);f!==g&&(wt(_n,u),wt(zt,g))}function he(u){_n.current===u&&(Nt(zt),Nt(_n)),J.current===u&&(Nt(J),vg._currentValue=De)}var Ae=Object.prototype.hasOwnProperty,et=t.unstable_scheduleCallback,nt=t.unstable_cancelCallback,He=t.unstable_shouldYield,ft=t.unstable_requestPaint,Mt=t.unstable_now,pt=t.unstable_getCurrentPriorityLevel,Oe=t.unstable_ImmediatePriority,hn=t.unstable_UserBlockingPriority,Yt=t.unstable_NormalPriority,Qe=t.unstable_LowPriority,tn=t.unstable_IdlePriority,je=t.log,Ue=t.unstable_setDisableYieldValue,bt=null,ht=null;function Dt(u){if(ht&&typeof ht.onCommitFiberRoot=="function")try{ht.onCommitFiberRoot(bt,u,void 0,(u.current.flags&128)===128)}catch{}}function Ut(u){if(typeof je=="function"&&Ue(u),ht&&typeof ht.setStrictMode=="function")try{ht.setStrictMode(bt,u)}catch{}}var Lt=Math.clz32?Math.clz32:Jt,Wt=Math.log,fn=Math.LN2;function Jt(u){return u>>>=0,u===0?32:31-(Wt(u)/fn|0)|0}var Kn=128,nn=4194304;function Wn(u){var f=u&42;if(f!==0)return f;switch(u&-u){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:return 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 u&4194176;case 4194304:case 8388608:case 16777216:case 33554432:return u&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return u}}function ln(u,f){var g=u.pendingLanes;if(g===0)return 0;var w=0,N=u.suspendedLanes,O=u.pingedLanes,se=u.warmLanes;u=u.finishedLanes!==0;var fe=g&134217727;return fe!==0?(g=fe&~N,g!==0?w=Wn(g):(O&=fe,O!==0?w=Wn(O):u||(se=fe&~se,se!==0&&(w=Wn(se))))):(fe=g&~N,fe!==0?w=Wn(fe):O!==0?w=Wn(O):u||(se=g&~se,se!==0&&(w=Wn(se)))),w===0?0:f!==0&&f!==w&&(f&N)===0&&(N=w&-w,se=f&-f,N>=se||N===32&&(se&4194176)!==0)?f:w}function ns(u,f){return(u.pendingLanes&~(u.suspendedLanes&~u.pingedLanes)&f)===0}function Js(u,f){switch(u){case 1:case 2:case 4:case 8:return f+250;case 16:case 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 f+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ur(){var u=Kn;return Kn<<=1,(Kn&4194176)===0&&(Kn=128),u}function zs(){var u=nn;return nn<<=1,(nn&62914560)===0&&(nn=4194304),u}function fs(u){for(var f=[],g=0;31>g;g++)f.push(u);return f}function ps(u,f){u.pendingLanes|=f,f!==268435456&&(u.suspendedLanes=0,u.pingedLanes=0,u.warmLanes=0)}function ms(u,f,g,w,N,O){var se=u.pendingLanes;u.pendingLanes=g,u.suspendedLanes=0,u.pingedLanes=0,u.warmLanes=0,u.expiredLanes&=g,u.entangledLanes&=g,u.errorRecoveryDisabledLanes&=g,u.shellSuspendCounter=0;var fe=u.entanglements,Ce=u.expirationTimes,Ge=u.hiddenUpdates;for(g=se&~g;0<g;){var At=31-Lt(g),Pt=1<<At;fe[At]=0,Ce[At]=-1;var it=Ge[At];if(it!==null)for(Ge[At]=null,At=0;At<it.length;At++){var Et=it[At];Et!==null&&(Et.lane&=-536870913)}g&=~Pt}w!==0&&Me(u,w,0),O!==0&&N===0&&u.tag!==0&&(u.suspendedLanes|=O&~(se&~f))}function Me(u,f,g){u.pendingLanes|=f,u.suspendedLanes&=~f;var w=31-Lt(f);u.entangledLanes|=f,u.entanglements[w]=u.entanglements[w]|1073741824|g&4194218}function lt(u,f){var g=u.entangledLanes|=f;for(u=u.entanglements;g;){var w=31-Lt(g),N=1<<w;N&f|u[w]&f&&(u[w]|=f),g&=~N}}function jt(u){return u&=-u,2<u?8<u?(u&134217727)!==0?32:268435456:8:2}function Qt(){var u=Se.p;return u!==0?u:(u=window.event,u===void 0?32:Sg(u.type))}function Sn(u,f){var g=Se.p;try{return Se.p=u,f()}finally{Se.p=g}}var yn=Math.random().toString(36).slice(2),Ft="__reactFiber$"+yn,sn="__reactProps$"+yn,rn="__reactContainer$"+yn,bs="__reactEvents$"+yn,gs="__reactListeners$"+yn,us="__reactHandles$"+yn,Hn="__reactResources$"+yn,ls="__reactMarker$"+yn;function Ps(u){delete u[Ft],delete u[sn],delete u[bs],delete u[gs],delete u[us]}function rr(u){var f=u[Ft];if(f)return f;for(var g=u.parentNode;g;){if(f=g[rn]||g[Ft]){if(g=f.alternate,f.child!==null||g!==null&&g.child!==null)for(u=l2(u);u!==null;){if(g=u[Ft])return g;u=l2(u)}return f}u=g,g=u.parentNode}return null}function ws(u){if(u=u[Ft]||u[rn]){var f=u.tag;if(f===5||f===6||f===13||f===26||f===27||f===3)return u}return null}function $s(u){var f=u.tag;if(f===5||f===26||f===27||f===6)return u.stateNode;throw Error(s(33))}function ys(u){var f=u[Hn];return f||(f=u[Hn]={hoistableStyles:new Map,hoistableScripts:new Map}),f}function Pn(u){u[ls]=!0}var ir=new Set,ot={};function ar(u,f){$n(u,f),$n(u+"Capture",f)}function $n(u,f){for(ot[u]=f,u=0;u<f.length;u++)ir.add(f[u])}var kn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Nn=RegExp("^[: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]*$"),Bn={},er={};function oi(u){return Ae.call(er,u)?!0:Ae.call(Bn,u)?!1:Nn.test(u)?er[u]=!0:(Bn[u]=!0,!1)}function or(u,f,g){if(oi(f))if(g===null)u.removeAttribute(f);else{switch(typeof g){case"undefined":case"function":case"symbol":u.removeAttribute(f);return;case"boolean":var w=f.toLowerCase().slice(0,5);if(w!=="data-"&&w!=="aria-"){u.removeAttribute(f);return}}u.setAttribute(f,""+g)}}function ue(u,f,g){if(g===null)u.removeAttribute(f);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":u.removeAttribute(f);return}u.setAttribute(f,""+g)}}function ke(u,f,g,w){if(w===null)u.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":u.removeAttribute(g);return}u.setAttributeNS(f,g,""+w)}}function pe(u){switch(typeof u){case"bigint":case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function Pe(u){var f=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(f==="checkbox"||f==="radio")}function $e(u){var f=Pe(u)?"checked":"value",g=Object.getOwnPropertyDescriptor(u.constructor.prototype,f),w=""+u[f];if(!u.hasOwnProperty(f)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var N=g.get,O=g.set;return Object.defineProperty(u,f,{configurable:!0,get:function(){return N.call(this)},set:function(se){w=""+se,O.call(this,se)}}),Object.defineProperty(u,f,{enumerable:g.enumerable}),{getValue:function(){return w},setValue:function(se){w=""+se},stopTracking:function(){u._valueTracker=null,delete u[f]}}}}function Ne(u){u._valueTracker||(u._valueTracker=$e(u))}function tt(u){if(!u)return!1;var f=u._valueTracker;if(!f)return!0;var g=f.getValue(),w="";return u&&(w=Pe(u)?u.checked?"true":"false":u.value),u=w,u!==g?(f.setValue(u),!0):!1}function mt(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}var Ct=/[\n"\\]/g;function _t(u){return u.replace(Ct,function(f){return"\\"+f.charCodeAt(0).toString(16)+" "})}function kt(u,f,g,w,N,O,se,fe){u.name="",se!=null&&typeof se!="function"&&typeof se!="symbol"&&typeof se!="boolean"?u.type=se:u.removeAttribute("type"),f!=null?se==="number"?(f===0&&u.value===""||u.value!=f)&&(u.value=""+pe(f)):u.value!==""+pe(f)&&(u.value=""+pe(f)):se!=="submit"&&se!=="reset"||u.removeAttribute("value"),f!=null?qn(u,se,pe(f)):g!=null?qn(u,se,pe(g)):w!=null&&u.removeAttribute("value"),N==null&&O!=null&&(u.defaultChecked=!!O),N!=null&&(u.checked=N&&typeof N!="function"&&typeof N!="symbol"),fe!=null&&typeof fe!="function"&&typeof fe!="symbol"&&typeof fe!="boolean"?u.name=""+pe(fe):u.removeAttribute("name")}function Xt(u,f,g,w,N,O,se,fe){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(u.type=O),f!=null||g!=null){if(!(O!=="submit"&&O!=="reset"||f!=null))return;g=g!=null?""+pe(g):"",f=f!=null?""+pe(f):g,fe||f===u.value||(u.value=f),u.defaultValue=f}w=w??N,w=typeof w!="function"&&typeof w!="symbol"&&!!w,u.checked=fe?u.checked:!!w,u.defaultChecked=!!w,se!=null&&typeof se!="function"&&typeof se!="symbol"&&typeof se!="boolean"&&(u.name=se)}function qn(u,f,g){f==="number"&&mt(u.ownerDocument)===u||u.defaultValue===""+g||(u.defaultValue=""+g)}function Xn(u,f,g,w){if(u=u.options,f){f={};for(var N=0;N<g.length;N++)f["$"+g[N]]=!0;for(g=0;g<u.length;g++)N=f.hasOwnProperty("$"+u[g].value),u[g].selected!==N&&(u[g].selected=N),N&&w&&(u[g].defaultSelected=!0)}else{for(g=""+pe(g),f=null,N=0;N<u.length;N++){if(u[N].value===g){u[N].selected=!0,w&&(u[N].defaultSelected=!0);return}f!==null||u[N].disabled||(f=u[N])}f!==null&&(f.selected=!0)}}function an(u,f,g){if(f!=null&&(f=""+pe(f),f!==u.value&&(u.value=f),g==null)){u.defaultValue!==f&&(u.defaultValue=f);return}u.defaultValue=g!=null?""+pe(g):""}function Jn(u,f,g,w){if(f==null){if(w!=null){if(g!=null)throw Error(s(92));if(Re(w)){if(1<w.length)throw Error(s(93));w=w[0]}g=w}g==null&&(g=""),f=g}g=pe(f),u.defaultValue=g,w=u.textContent,w===g&&w!==""&&w!==null&&(u.value=w)}function Qn(u,f){if(f){var g=u.firstChild;if(g&&g===u.lastChild&&g.nodeType===3){g.nodeValue=f;return}}u.textContent=f}var Gs=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Cr(u,f,g){var w=f.indexOf("--")===0;g==null||typeof g=="boolean"||g===""?w?u.setProperty(f,""):f==="float"?u.cssFloat="":u[f]="":w?u.setProperty(f,g):typeof g!="number"||g===0||Gs.has(f)?f==="float"?u.cssFloat=g:u[f]=(""+g).trim():u[f]=g+"px"}function Qs(u,f,g){if(f!=null&&typeof f!="object")throw Error(s(62));if(u=u.style,g!=null){for(var w in g)!g.hasOwnProperty(w)||f!=null&&f.hasOwnProperty(w)||(w.indexOf("--")===0?u.setProperty(w,""):w==="float"?u.cssFloat="":u[w]="");for(var N in f)w=f[N],f.hasOwnProperty(N)&&g[N]!==w&&Cr(u,N,w)}else for(var O in f)f.hasOwnProperty(O)&&Cr(u,O,f[O])}function ti(u){if(u.indexOf("-")===-1)return!1;switch(u){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 gi=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRen
48dering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),yr=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function _a(u){return yr.test(""+u)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":u}var Va=null;function Ls(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var li=null,ni=null;function pn(u){var f=ws(u);if(f&&(u=f.stateNode)){var g=u[sn]||null;e:switch(u=f.stateNode,f.type){case"input":if(kt(u,g.value,g.defaultValue,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name),f=g.name,g.type==="radio"&&f!=null){for(g=u;g.parentNode;)g=g.parentNode;for(g=g.querySelectorAll('input[name="'+_t(""+f)+'"][type="radio"]'),f=0;f<g.length;f++){var w=g[f];if(w!==u&&w.form===u.form){var N=w[sn]||null;if(!N)throw Error(s(90));kt(w,N.value,N.defaultValue,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name)}}for(f=0;f<g.length;f++)w=g[f],w.form===u.form&&tt(w)}break e;case"textarea":an(u,g.value,g.defaultValue);break e;case"select":f=g.value,f!=null&&Xn(u,!!g.multiple,f,!1)}}}var ji=!1;function za(u,f,g){if(ji)return u(f,g);ji=!0;try{var w=u(f);return w}finally{if(ji=!1,(li!==null||ni!==null)&&(yb(),li&&(f=li,u=ni,ni=li=null,pn(f),u)))for(f=0;f<u.length;f++)pn(u[f])}}function Ai(u,f){var g=u.stateNode;if(g===null)return null;var w=g[sn]||null;if(w===null)return null;g=w[f];e:switch(f){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(u=u.type,w=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!w;break e;default:u=!1}if(u)return null;if(g&&typeof g!="function")throw Error(s(231,f,typeof g));return g}var Ye=!1;if(kn)try{var vt={};Object.defineProperty(vt,"passive",{get:function(){Ye=!0}}),window.addEventListener("test",vt,vt),window.removeEventListener("test",vt,vt)}catch{Ye=!1}var ct=null,Kt=null,ds=null;function Mr(){if(ds)return ds;var u,f=Kt,g=f.length,w,N="value"in ct?ct.value:ct.textContent,O=N.length;for(u=0;
vendor: 6,504 bytes, line 48
48u<g&&f[u]===N[u];u++);var se=g-u;for(w=1;w<=se&&f[g-w]===N[O-w];w++);return ds=N.slice(u,1<w?1-w:void 0)}function Ds(u){var f=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&f===13&&(u=13)):u=f,u===10&&(u=13),32<=u||u===13?u:0}function Hs(){return!0}function un(){return!1}function Yn(u){function f(g,w,N,O,se){this._reactName=g,this._targetInst=N,this.type=w,this.nativeEvent=O,this.target=se,this.currentTarget=null;for(var fe in u)u.hasOwnProperty(fe)&&(g=u[fe],this[fe]=g?g(O):O[fe]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Hs:un,this.isPropagationStopped=un,this}return G(f.prototype,{preventDefault:function(){this.defaultPrevented=!0;var g=this.nativeEvent;g&&(g.preventDefault?g.preventDefault():typeof g.returnValue!="unknown"&&(g.returnValue=!1),this.isDefaultPrevented=Hs)},stopPropagation:function(){var g=this.nativeEvent;g&&(g.stopPropagation?g.stopPropagation():typeof g.cancelBubble!="unknown"&&(g.cancelBubble=!0),this.isPropagationStopped=Hs)},persist:function(){},isPersistent:Hs}),f}var As={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pr=Yn(As),kr=G({},As,{view:0,detail:0}),Yi=Yn(kr),Ga,wl,sa,ra=G({},kr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Fc,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==sa&&(sa&&u.type==="mousemove"?(Ga=u.screenX-sa.screenX,wl=u.screenY-sa.screenY):wl=Ga=0,sa=u),Ga)},movementY:function(u){return"movementY"in u?u.movementY:wl}}),Bi=Yn(ra),_l=G({},ra,{dataTransfer:0}),Pu=Yn(_l),Uc=G({},kr,{relatedTarget:0}),ic=Yn(Uc),Cd=G({},As,{animationName:0,elapsedTime:0,pseudoElement:0}),ci=Yn(Cd),xr=G({},As,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),gn=Yn(xr),Sa=G({},As,{data:0}),yi=Yn(Sa),uo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Xo={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ha={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kd(u){var f=this.nativeEvent;return f.getModifierState?f.getModifierState(u):(u=Ha[u])?!!f[u]:!1}function Fc(){return kd}var Id=G({},kr,{key:function(u){if(u.key){var f=uo[u.key]||u.key;if(f!=="Unidentified")return f}return u.type==="keypress"?(u=Ds(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?Xo[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Fc,charCode:function(u){return u.type==="keypress"?Ds(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?Ds(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),ia=Yn(Id),qr=G({},ra,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ac=Yn(qr),Sl=G({},kr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Fc}),Io=Yn(Sl),C=G({},As,{propertyName:0,elapsedTime:0,pseudoElement:0}),W=Yn(C),ne=G({},ra,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),ye=Yn(ne),Xe=G({},As,{newState:0,oldState:0}),rt=Yn(Xe),Vt=[9,13,27,32],Zn=kn&&"CompositionEvent"in window,dr=null;kn&&"documentMode"in document&&(dr=document.documentMode);var lr=kn&&"TextEvent"in window&&!dr,wr=kn&&(!Zn||dr&&8<dr&&11>=dr),aa=" ",qa=!1;function No(u,f){switch(u){case"keyup":return Vt.indexOf(f.keyCode)!==-1;case"keydown":return f.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fa(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var pa=!1;function $u(u,f){switch(u){case"compositionend":return fa(f);case"keypress":return f.which!==32?null:(qa=!0,aa);case"textInput":return u=f.data,u===aa&&qa?null:u;default:return null}}function ef(u,f){if(pa)return u==="compositionend"||!Zn&&No(u,f)?(u=Mr(),ds=Kt=ct=null,pa=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(f.ctrlKey||f.altKey||f.metaKey)||f.ctrlKey&&f.altKey){if(f.char&&1<f.char.length)return f.char;if(f.which)return String.fromCharCode(f.which)}return null;case"compositionend":return wr&&f.locale!=="ko"?null:f.data;default:return null}}var oc={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Du(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f==="input"?!!oc[u.type]:f==="textarea"}function ho(u,f,g,w){li?ni?ni.push(w):ni=[w]:li=w,f=Sb(f,"onChange"),0<f.length&&(g=new Pr("onChange","change",null,g,w),u.push({event:g,listeners:f}))}var Vc=null,Ou=null;function Nd(u){hg(u,0)}function Rd(u){var f=$s(u);if(tt(f))return u}function js(u,f){if(u==="change")return f}var lc=!1;if(kn){var Md;if(kn){var El="oninput"in document;if(!El){var Lu=document.createElement("div");Lu.setAttribute("oninput","return;"),El=typeof Lu.oninput=="function"}Md=El}else Md=!1;lc=Md&&(!document.documentMode||9<document.documentMode)}function Ir(){Vc&&(Vc.detachEvent("onpropertychange",Wa),Ou=Vc=null)}function Wa(u){if(u.propertyName==="value"&&Rd(Ou)){var f=[];ho(f,Ou,u,Ls(u)),za(Nd,f)}}function Pd(u,f,g){u==="focusin"?(Ir(),Vc=f,Ou=g,Vc.attachEvent("onpropertychange",Wa)):u==="focusout"&&Ir()}function cc(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return Rd(Ou)}function fo(u,f){if(u==="click")return Rd(f)}function $d(u,f){if(u==="input"||u==="change")return Rd(f)}function vp(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var oa=typeof Object.is=="function"?Object.is:vp;function Wr(u,f){if(oa(u,f))return!0;
vendor: 22,135 bytes, line 48
48if(typeof u!="object"||u===null||typeof f!="object"||f===null)return!1;var g=Object.keys(u),w=Object.keys(f);if(g.length!==w.length)return!1;for(w=0;w<g.length;w++){var N=g[w];if(!Ae.call(f,N)||!oa(u[N],f[N]))return!1}return!0}function Tl(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function _s(u,f){var g=Tl(u);u=0;for(var w;g;){if(g.nodeType===3){if(w=u+g.textContent.length,u<=f&&w>=f)return{node:g,offset:f-u};u=w}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=Tl(g)}}function Ea(u,f){return u&&f?u===f?!0:u&&u.nodeType===3?!1:f&&f.nodeType===3?Ea(u,f.parentNode):"contains"in u?u.contains(f):u.compareDocumentPosition?!!(u.compareDocumentPosition(f)&16):!1:!1}function Jo(u){u=u!=null&&u.ownerDocument!=null&&u.ownerDocument.defaultView!=null?u.ownerDocument.defaultView:window;for(var f=mt(u.document);f instanceof u.HTMLIFrameElement;){try{var g=typeof f.contentWindow.location.href=="string"}catch{g=!1}if(g)u=f.contentWindow;else break;f=mt(u.document)}return f}function es(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f&&(f==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||f==="textarea"||u.contentEditable==="true")}function Ta(u,f){var g=Jo(f);f=u.focusedElem;var w=u.selectionRange;if(g!==f&&f&&f.ownerDocument&&Ea(f.ownerDocument.documentElement,f)){if(w!==null&&es(f)){if(u=w.start,g=w.end,g===void 0&&(g=u),"selectionStart"in f)f.selectionStart=u,f.selectionEnd=Math.min(g,f.value.length);else if(g=(u=f.ownerDocument||document)&&u.defaultView||window,g.getSelection){g=g.getSelection();var N=f.textContent.length,O=Math.min(w.start,N);w=w.end===void 0?O:Math.min(w.end,N),!g.extend&&O>w&&(N=w,w=O,O=N),N=_s(f,O);var se=_s(f,w);N&&se&&(g.rangeCount!==1||g.anchorNode!==N.node||g.anchorOffset!==N.offset||g.focusNode!==se.node||g.focusOffset!==se.offset)&&(u=u.createRange(),u.setStart(N.node,N.offset),g.removeAllRanges(),O>w?(g.addRange(u),g.extend(se.node,se.offset)):(u.setEnd(se.node,se.offset),g.addRange(u)))}}for(u=[],g=f;g=g.parentNode;)g.nodeType===1&&u.push({element:g,left:g.scrollLeft,top:g.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<u.length;f++)g=u[f],g.element.scrollLeft=g.left,g.element.scrollTop=g.top}}var hs=kn&&"documentMode"in document&&11>=document.documentMode,Ci=null,$r=null,Aa=null,uc=!1;function zc(u,f,g){var w=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;uc||Ci==null||Ci!==mt(w)||(w=Ci,"selectionStart"in w&&es(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Aa&&Wr(Aa,w)||(Aa=w,w=Sb($r,"onSelect"),0<w.length&&(f=new Pr("onSelect","select",null,f,g),u.push({event:f,listeners:w}),f.target=Ci)))}function Al(u,f){var g={};return g[u.toLowerCase()]=f.toLowerCase(),g["Webkit"+u]="webkit"+f,g["Moz"+u]="moz"+f,g}var Qo={animationend:Al("Animation","AnimationEnd"),animationiteration:Al("Animation","AnimationIteration"),animationstart:Al("Animation","AnimationStart"),transitionrun:Al("Transition","TransitionRun"),transitionstart:Al("Transition","TransitionStart"),transitioncancel:Al("Transition","TransitionCancel"),transitionend:Al("Transition","TransitionEnd")},dc={},Dd={};kn&&(Dd=document.createElement("div").style,"AnimationEvent"in window||(delete Qo.animationend.animation,delete Qo.animationiteration.animation,delete Qo.animationstart.animation),"TransitionEvent"in window||delete Qo.transitionend.transition);function la(u){if(dc[u])return dc[u];if(!Qo[u])return u;var f=Qo[u],g;for(g in f)if(f.hasOwnProperty(g)&&g in Dd)return dc[u]=f[g];return u}var Zo=la("animationend"),ju=la("animationiteration"),tf=la("animationstart"),nf=la("transitionrun"),Gc=la("transitionstart"),qm=la("transitioncancel"),sf=la("transitionend"),rf=new Map,xi="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll scrollEnd toggle touchMove waiting wheel".split(" ");function ma(u,f){rf.set(u,f),ar(f,[u])}var Ui=[],el=0,Bu=0;function Uu(){for(var u=el,f=Bu=el=0;f<u;){var g=Ui[f];Ui[f++]=null;var w=Ui[f];Ui[f++]=null;var N=Ui[f];Ui[f++]=null;var O=Ui[f];if(Ui[f++]=null,w!==null&&N!==null){var se=w.pending;se===null?N.next=N:(N.next=se.next,se.next=N),w.pending=N}O!==0&&Od(g,N,O)}}function tl(u,f,g,w){Ui[el++]=u,Ui[el++]=f,Ui[el++]=g,Ui[el++]=w,Bu|=w,u.lanes|=w,u=u.alternate,u!==null&&(u.lanes|=w)}function Hc(u,f,g,w){return tl(u,f,g,w),Ld(u)}function vi(u,f){return tl(u,null,null,f),Ld(u)}function Od(u,f,g){u.lanes|=g;var w=u.alternate;w!==null&&(w.lanes|=g);for(var N=!1,O=u.return;O!==null;)O.childLanes|=g,w=O.alternate,w!==null&&(w.childLanes|=g),O.tag===22&&(u=O.stateNode,u===null||u._visibility&1||(N=!0)),u=O,O=O.return;N&&f!==null&&u.tag===3&&(O=u.stateNode,N=31-Lt(g),O=O.hiddenUpdates,u=O[N],u===null?O[N]=[f]:u.push(f),f.lane=g|536870912)}function Ld(u){if(50<ig)throw ig=0,K_=null,Error(s(185));for(var f=u.return;f!==null;)u=f,f=u.return;return u.tag===3?u.stateNode:null}var hc={},af=new WeakMap;function Ka(u,f){if(typeof u=="object"&&u!==null){var g=af.get(u);return g!==void 0?g:(f={value:u,source:f,stack:xe(f)},af.set(u,f),f)}return{value:u,source:f,stack:xe(f)}}var Ya=[],fc=0,jd=null,Bd=0,ki=[],Xa=0,Cl=null,Xi=1,Ro="";function Fi(u,f){Ya[fc++]=Bd,Ya[fc++]=jd,jd=u,Bd=f}function of(u,f,g){ki[Xa++]=Xi,ki[Xa++]=Ro,ki[Xa++]=Cl,Cl=u;var w=Xi;u=Ro;var N=32-Lt(w)-1;w&=~(1<<N),g+=1;var O=32-Lt(f)+N;if(30<O){var se=N-N%5;O=(w&(1<<se)-1).toString(32),w>>=se,N-=se,Xi=1<<32-Lt(f)+N|g<<N|w,Ro=O+u}else Xi=1<<O|g<<N|w,Ro=u}function lf(u){u.return!==null&&(Fi(u,1),of(u,1,0))}function cf(u){for(;u===jd;)jd=Ya[--fc],Ya[fc]=null,Bd=Ya[--fc],Ya[fc]=null;for(;u===Cl;)Cl=ki[--Xa],ki[Xa]=null,Ro=ki[--Xa],ki[Xa]=null,Xi=ki[--Xa],ki[Xa]=null}var Fr=null,Kr=null,Bs=!1,Ca=null,nl=!1,Ud=Error(s(519));function qc(u){var f=Error(s(418,""));throw Vd(Ka(f,u)),Ud}function bp(u){var f=u.stateNode,g=u.type,w=u.memoizedProps;switch(f[Ft]=u,f[sn]=w,g){case"dialog":tr("cancel",f),tr("close",f);break;case"iframe":case"object":case"embed":tr("load",f);break;case"video":case"audio":for(g=0;g<dg.length;g++)tr(dg[g],f);break;case"source":tr("error",f);break;case"img":case"image":case"link":tr("error",f),tr("load",f);break;case"details":tr("toggle",f);break;case"input":tr("invalid",f),Xt(f,w.value,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name,!0),Ne(f);break;case"select":tr("invalid",f);break;case"textarea":tr("invalid",f),Jn(f,w.value,w.defaultValue,w.children),Ne(f)}g=w.children,typeof g!="string"&&typeof g!="number"&&typeof g!="bigint"||f.textContent===""+g||w.suppressHydrationWarning===!0||r2(f.textContent,g)?(w.popover!=null&&(tr("beforetoggle",f),tr("toggle",f)),w.onScroll!=null&&tr("scroll",f),w.onScrollEnd!=null&&tr("scrollend",f),w.onClick!=null&&(f.onclick=Cy),f=!0):f=!1,f||qc(u)}function uf(u){for(Fr=u.return;Fr;)switch(Fr.tag){case 3:case 27:nl=!0;return;case 5:case 13:nl=!1;return;default:Fr=Fr.return}}function Wc(u){if(u!==Fr)return!1;if(!Bs)return uf(u),Bs=!0,!1;var f=!1,g;if((g=u.tag!==3&&u.tag!==27)&&((g=u.tag===5)&&(g=u.type,g=!(g!=="form"&&g!=="button")||Tb(u.type,u.memoizedProps)),g=!g),g&&(f=!0),f&&Kr&&qc(u),uf(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));e:{for(u=u.nextSibling,f=0;u;){if(u.nodeType===8)if(g=u.data,g==="/$"){if(f===0){Kr=Fl(u.nextSibling);break e}f--}else g!=="$"&&g!=="$!"&&g!=="$?"||f++;u=u.nextSibling}Kr=null}}else Kr=Fr?Fl(u.stateNode.nextSibling):null;return!0}function Fd(){Kr=Fr=null,Bs=!1}function Vd(u){Ca===null?Ca=[u]:Ca.push(u)}var zd=Error(s(460)),wp=Error(s(474)),_p={then:function(){}};function po(u){return u=u.status,u==="fulfilled"||u==="rejected"}function ka(){}function Fu(u,f,g){switch(g=u[g],g===void 0?u.push(f):g!==f&&(f.then(ka,ka),f=g),f.status){case"fulfilled":return f.value;case"rejected":throw u=f.reason,u===zd?Error(s(483)):u;default:if(typeof f.status=="string")f.then(ka,ka);else{if(u=Jr,u!==null&&100<u.shellSuspendCounter)throw Error(s(482));u=f,u.status="pending",u.then(function(w){if(f.status==="pending"){var N=f;N.status="fulfilled",N.value=w}},function(w){if(f.status==="pending"){var N=f;N.status="rejected",N.reason=w}})}switch(f.status){case"fulfilled":return f.value;case"rejected":throw u=f.reason,u===zd?Error(s(483)):u}throw pc=f,zd}}var pc=null;function df(){if(pc===null)throw Error(s(459));var u=pc;return pc=null,u}var kl=null,mc=0;function hf(u){var f=mc;return mc+=1,kl===null&&(kl=[]),Fu(kl,u,f)}function Gd(u,f){f=f.props.ref,u.ref=f!==void 0?f:null}function Hd(u,f){throw f.$$typeof===i?Error(s(525)):(u=Object.prototype.toString.call(f),Error(s(31,u==="[object Object]"?"object with keys {"+Object.keys(f).join(", ")+"}":u)))}function Sp(u){var f=u._init;return f(u._payload)}function qd(u){function f(Je,Ve){if(u){var st=Je.deletions;st===null?(Je.deletions=[Ve],Je.flags|=16):st.push(Ve)}}function g(Je,Ve){if(!u)return null;for(;Ve!==null;)f(Je,Ve),Ve=Ve.sibling;return null}function w(Je){for(var Ve=new Map;Je!==null;)Je.key!==null?Ve.set(Je.key,Je):Ve.set(Je.index,Je),Je=Je.sibling;return Ve}function N(Je,Ve){return Je=_f(Je,Ve),Je.index=0,Je.sibling=null,Je}function O(Je,Ve,st){return Je.index=st,u?(st=Je.alternate,st!==null?(st=st.index,st<Ve?(Je.flags|=33554434,Ve):st):(Je.flags|=33554434,Ve)):(Je.flags|=1048576,Ve)}function se(Je){return u&&Je.alternate===null&&(Je.flags|=33554434),Je}function fe(Je,Ve,st,Rt){return Ve===null||Ve.tag!==6?(Ve=F_(st,Je.mode,Rt),Ve.return=Je,Ve):(Ve=N(Ve,st),Ve.return=Je,Ve)}function Ce(Je,Ve,st,Rt){var bn=st.type;return bn===l?At(Je,Ve,st.props.children,Rt,st.key):Ve!==null&&(Ve.elementType===bn||typeof bn=="object"&&bn!==null&&bn.$$typeof===I&&Sp(bn)===Ve.type)?(Ve=N(Ve,st.props),Gd(Ve,st),Ve.return=Je,Ve):(Ve=hb(st.type,st.key,st.props,null,Je.mode,Rt),Gd(Ve,st),Ve.return=Je,Ve)}function Ge(Je,Ve,st,Rt){return Ve===null||Ve.tag!==4||Ve.stateNode.containerInfo!==st.containerInfo||Ve.stateNode.implementation!==st.implementation?(Ve=V_(st,Je.mode,Rt),Ve.return=Je,Ve):(Ve=N(Ve,st.children||[]),Ve.return=Je,Ve)}function At(Je,Ve,st,Rt,bn){return Ve===null||Ve.tag!==7?(Ve=Sf(st,Je.mode,Rt,bn),Ve.return=Je,Ve):(Ve=N(Ve,st),Ve.return=Je,Ve)}function Pt(Je,Ve,st){if(typeof Ve=="string"&&Ve!==""||typeof Ve=="number"||typeof Ve=="bigint")return Ve=F_(""+Ve,Je.mode,st),Ve.return=Je,Ve;if(typeof Ve=="object"&&Ve!==null){switch(Ve.$$typeof){case a:return st=hb(Ve.type,Ve.key,Ve.props,null,Je.mode,st),Gd(st,Ve),st.return=Je,st;case o:return Ve=V_(Ve,Je.mode,st),Ve.return=Je,Ve;case I:var Rt=Ve._init;return Ve=Rt(Ve._payload),Pt(Je,Ve,st)}if(Re(Ve)||K(Ve))return Ve=Sf(Ve,Je.mode,st,null),Ve.return=Je,Ve;if(typeof Ve.then=="function")return Pt(Je,hf(Ve),st);if(Ve.$$typeof===y)return Pt(Je,ab(Je,Ve),st);Hd(Je,Ve)}return null}function it(Je,Ve,st,Rt){var bn=Ve!==null?Ve.key:null;if(typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint")return bn!==null?null:fe(Je,Ve,""+st,Rt);if(typeof st=="object"&&st!==null){switch(st.$$typeof){case a:return st.key===bn?Ce(Je,Ve,st,Rt):null;case o:return st.key===bn?Ge(Je,Ve,st,Rt):null;case I:return bn=st._init,st=bn(st._payload),it(Je,Ve,st,Rt)}if(Re(st)||K(st))return bn!==null?null:At(Je,Ve,st,Rt,null);if(typeof st.then=="function")return it(Je,Ve,hf(st),Rt);if(st.$$typeof===y)return it(Je,Ve,ab(Je,st),Rt);Hd(Je,st)}return null}function Et(Je,Ve,st,Rt,bn){if(typeof Rt=="string"&&Rt!==""||typeof Rt=="number"||typeof Rt=="bigint")return Je=Je.get(st)||null,fe(Ve,Je,""+Rt,bn);if(typeof Rt=="object"&&Rt!==null){switch(Rt.$$typeof){case a:return Je=Je.get(Rt.key===null?st:Rt.key)||null,Ce(Ve,Je,Rt,bn);case o:return Je=Je.get(Rt.key===null?st:Rt.key)||null,Ge(Ve,Je,Rt,bn);case I:var Ys=Rt._init;return Rt=Ys(Rt._payload),Et(Je,Ve,st,Rt,bn)}if(Re(Rt)||K(Rt))return Je=Je.get(st)||null,At(Ve,Je,Rt,bn,null);if(typeof Rt.then=="function")return Et(Je,Ve,st,hf(Rt),bn);if(Rt.$$typeof===y)return Et(Je,Ve,st,ab(Ve,Rt),bn);Hd(Ve,Rt)}return null}function jn(Je,Ve,st,Rt){for(var bn=null,Ys=null,Vn=Ve,as=Ve=0,ga=null;Vn!==null&&as<st.length;as++){Vn.index>as?(ga=Vn,Vn=null):ga=Vn.sibling;var Sr=it(Je,Vn,st[as],Rt);if(Sr===null){Vn===null&&(Vn=ga);break}u&&Vn&&Sr.alternate===null&&f(Je,Vn),Ve=O(Sr,Ve,as),Ys===null?bn=Sr:Ys.sibling=Sr,Ys=Sr,Vn=ga}if(as===st.length)return g(Je,Vn),Bs&&Fi(Je,as),bn;if(Vn===null){for(;as<st.length;as++)Vn=Pt(Je,st[as],Rt),Vn!==null&&(Ve=O(Vn,Ve,as),Ys===null?bn=Vn:Ys.sibling=Vn,Ys=Vn);return Bs&&Fi(Je,as),bn}for(Vn=w(Vn);as<st.length;as++)ga=Et(Vn,Je,as,st[as],Rt),ga!==null&&(u&&ga.alternate!==null&&Vn.delete(ga.key===null?as:ga.key),Ve=O(ga,Ve,as),Ys===null?bn=ga:Ys.sibling=ga,Ys=ga);return u&&Vn.forEach(function(Pf){return f(Je,Pf)}),Bs&&Fi(Je,as),bn}function Cs(Je,Ve,st,Rt){if(st==null)throw Error(s(151));for(var bn=null,Ys=null,Vn=Ve,as=Ve=0,ga=null,Sr=st.next();Vn!==null&&!Sr.done;as++,Sr=st.next()){Vn.index>as?(ga=Vn,Vn=null):ga=Vn.sibling;var Pf=it(Je,Vn,Sr.value,Rt);if(Pf===null){Vn===null&&(Vn=ga);break}u&&Vn&&Pf.alternate===null&&f(Je,Vn),Ve=O(Pf,Ve,as),Ys===null?bn=Pf:Ys.sibling=Pf,Ys=Pf,Vn=ga}if(Sr.done)return g(Je,Vn),Bs&&Fi(Je,as),bn;if(Vn===null){for(;!Sr.done;as++,Sr=st.next())Sr=Pt(Je,Sr.value,Rt),Sr!==null&&(Ve=O(Sr,Ve,as),Ys===null?bn=Sr:Ys.sibling=Sr,Ys=Sr);return Bs&&Fi(Je,as),bn}for(Vn=w(Vn);!Sr.done;as++,Sr=st.next())Sr=Et(Vn,Je,as,Sr.value,Rt),Sr!==null&&(u&&Sr.alternate!==null&&Vn.delete(Sr.key===null?as:Sr.key),Ve=O(Sr,Ve,as),Ys===null?bn=Sr:Ys.sibling=Sr,Ys=Sr);return u&&Vn.forEach(function(CP){return f(Je,CP)}),Bs&&Fi(Je,as),bn}function zi(Je,Ve,st,Rt){if(typeof st=="object"&&st!==null&&st.type===l&&st.key===null&&(st=st.props.children),typeof st=="object"&&st!==null){switch(st.$$typeof){case a:e:{for(var bn=st.key;Ve!==null;){if(Ve.key===bn){if(bn=st.type,bn===l){if(Ve.tag===7){g(Je,Ve.sibling),Rt=N(Ve,st.props.children),Rt.return=Je,Je=Rt;break e}}else if(Ve.elementType===bn||typeof bn=="object"&&bn!==null&&bn.$$typeof===I&&Sp(bn)===Ve.type){g(Je,Ve.sibling),Rt=N(Ve,st.props),Gd(Rt,st),Rt.return=Je,Je=Rt;break e}g(Je,Ve);break}else f(Je,Ve);Ve=Ve.sibling}st.type===l?(Rt=Sf(st.props.children,Je.mode,Rt,st.key),Rt.return=Je,Je=Rt):(Rt=hb(st.type,st.key,st.props,null,Je.mode,Rt),Gd(Rt,st),Rt.return=Je,Je=Rt)}return se(Je);case o:e:{for(bn=st.key;Ve!==null;){if(Ve.key===bn)if(Ve.tag===4&&Ve.stateNode.containerInfo===st.containerInfo&&Ve.stateNode.implementation===st.implementation){g(Je,Ve.sibling),Rt=N(Ve,st.children||[]),Rt.return=Je,Je=Rt;break e}else{g(Je,Ve);break}else f(Je,Ve);Ve=Ve.sibling}Rt=V_(st,Je.mode,Rt),Rt.return=Je,Je=Rt}return se(Je);case I:return bn=st._init,st=bn(st._payload),zi(Je,Ve,st,Rt)}if(Re(st))return jn(Je,Ve,st,Rt);if(K(st)){if(bn=K(st),typeof bn!="function")throw Error(s(150));return st=bn.call(st),Cs(Je,Ve,st,Rt)}if(typeof st.then=="function")return zi(Je,Ve,hf(st),Rt);if(st.$$typeof===y)return zi(Je,Ve,ab(Je,st),Rt);Hd(Je,st)}return typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint"?(st=""+st,Ve!==null&&Ve.tag===6?(g(Je,Ve.sibling),Rt=N(Ve,st),Rt.return=Je,Je=Rt):(g(Je,Ve),Rt=F_(st,Je.mode,Rt),Rt.return=Je,Je=Rt),se(Je)):g(Je,Ve)}return function(Je,Ve,st,Rt){try{mc=0;var bn=zi(Je,Ve,st,Rt);return kl=null,bn}catch(Vn){if(Vn===zd)throw Vn;var Ys=Ll(29,Vn,null,Je.mode);return Ys.lanes=Rt,Ys.return=Je,Ys}finally{}}}var gc=qd(!0),Wm=qd(!1),Mo=xt(null),Vu=xt(0);function ff(u,f){u=ih,wt(Vu,u),wt(Mo,f),ih=u|f.baseLanes}function Ep(){wt(Vu,ih),wt(Mo,Mo.current)}function Km(){ih=Vu.current,Nt(Mo),Nt(Vu)}var mo=xt(null),Ia=null;function yc(u){var f=u.alternate;wt(bi,bi.current&1),wt(mo,u),Ia===null&&(f===null||Mo.current!==null||f.memoizedState!==null)&&(Ia=u)}function Tp(u){if(u.tag===22){if(wt(bi,bi.current),wt(mo,u),Ia===null){var f=u.alternate;f!==null&&f.memoizedState!==null&&(Ia=u)}}else Il()}function Il(){wt(bi,bi.current),wt(mo,mo.current)}function Nl(u){Nt(mo),Ia===u&&(Ia=null),Nt(bi)}var bi=xt(0);function zu(u){for(var f=u;f!==null;){if(f.tag===13){var g=f.memoizedState;if(g!==null&&(g=g.dehydrated,g===null||g.data==="$?"||g.data==="$!"))return f}else if(f.tag===19&&f.memoizedProps.revealOrder!==void 0){if((f.flags&128)!==0)return f}else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return null;f=f.return}f.sibling.return=f.return,f=f.sibling}return null}var ui=typeof AbortController<"u"?AbortController:function(){var u=[],f=this.signal={aborted:!1,addEventListener:function(g,w){u.push(w)}};this.abort=function(){f.aborted=!0,u.forEach(function(g){return g()})}},Rl=t.unstable_scheduleCallback,Wd=t.unstable_NormalPriority,x={$$typeof:y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function A(){return{controller:new ui,data:new Map,refCount:0}}function $(u){u.refCount--,u.refCount===0&&Rl(Wd,function(){u.controller.abort()})}var P=null,z=0,Q=0,ee=null;function re(u,f){if(P===null){var g=P=[];z=0,Q=wb(),ee={status:"pending",value:void 0,then:function(w){g.push(w)}}}return z++,f.then(be,be),f}function be(){if(--z===0&&P!==null){ee!==null&&(ee.status="fulfilled");var u=P;P=null,Q=0,ee=null;for(var f=0;f<u.length;f++)(0,u[f])()}}function Ee(u,f){var g=[],w={status:"pending",value:null,reason:null,then:function(N){g.push(N)}};return u.then(function(){w.status="fulfilled",w.value=f;for(var N=0;N<g.length;N++)(0,g[N])(f)},function(N){for(w.status="rejected",w.reason=N,N=0;N<g.length;N++)(0,g[N])(void 0)}),w}var Te=B.S;B.S=function(u,f){typeof f=="object"&&f!==null&&typeof f.then=="function"&&re(u,f),Te!==null&&Te(u,f)};var Be=xt(null);function Ze(){var u=Be.current;return u!==null?u:Jr.pooledCache}function Fe(u,f){f===null?wt(Be,Be.current):wt(Be,f.pool)}function Gt(){var u=Ze();return u===null?null:{parent:x._currentValue,pool:u}}var Tt=0,Bt=null,en=null,Ln=null,Dn=!1,Os=!1,Rn=!1,On=0,Ss=0,Dr=null,Us=0;function is(){throw Error(s(321))}function Yr(u,f){if(f===null)return!1;for(var g=0;g<f.length&&g<u.length;g++)if(!oa(u[g],f[g]))return!1;return!0}function di(u,f,g,w,N,O){return Tt=O,Bt=f,f.memoizedState=null,f.updateQueue=null,f.lanes=0,B.H=u===null||u.memoizedState===null?Ip:xf,Rn=!1,O=g(w,N),Rn=!1,Os&&(O=Gu(f,g,w,N)),Kc(u),O}function Kc(u){B.H=Hu;var f=en!==null&&en.next!==null;if(Tt=0,Ln=en=Bt=null,Dn=!1,Ss=0,Dr=null,f)throw Error(s(300));u===null||Na||(u=u.dependencies,u!==null&&ib(u)&&(Na=!0))}function Gu(u,f,g,w){Bt=u;var N=0;do{if(Os&&(Dr=null),Ss=0,Os=!1,25<=N)throw Error(s(301));if(N+=1,Ln=en=null,u.updateQueue!=null){var O=u.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}B.H=Np,O=f(g,w)}while(Os);return O}function wi(){var u=B.H,f=u.useState()[0];return f=typeof f.then=="function"?Ap(f):f,u=u.useState()[0],(en!==null?en.memoizedState:null)!==u&&(Bt.flags|=1024),f}function sl(){var u=On!==0;return On=0,u}function Yc(u,f,g){f.updateQueue=u.updateQueue,f.flags&=-2053,u.lanes&=~g}function xc(u){if(Dn){for(u=u.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Dn=!1}Tt=0,Ln=en=Bt=null,Os=!1,Ss=On=0,Dr=null}function Xr(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ln===null?Bt.memoizedState=Ln=u:Ln=Ln.next=u,Ln}function Vr(){if(en===null){var u=Bt.alternate;u=u!==null?u.memoizedState:null}else u=en.next;var f=Ln===null?Bt.memoizedState:Ln.next;if(f!==null)Ln=f,en=u;else{if(u===null)throw Bt.alternate===null?Error(s(467)):Error(s(310));en=u,u={memoizedState:en.memoizedState,baseState:en.baseState,baseQueue:en.baseQueue,queue:en.queue,next:null},Ln===null?Bt.memoizedState=Ln=u:Ln=Ln.next=u}return Ln}var Ym;Ym=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}};function Ap(u){var f=Ss;return Ss+=1,Dr===null&&(Dr=[]),u=Fu(Dr,u,f),f=Bt,(Ln===null?f.memoizedState:Ln.next)===null&&(f=f.alternate,B.H=f===null||f.memoizedState===null?Ip:xf),u}function pf(u){if(u!==null&&typeof u=="object"){if(typeof u.then=="function")return Ap(u);if(u.$$typeof===y)return go(u)}throw Error(s(438,String(u)))}function Xm(u){var f=null,g=Bt.updateQueue;if(g!==null&&(f=g.memoCache),f==null){var w=Bt.alternate;w!==null&&(w=w.updateQueue,w!==null&&(w=w.memoCache,w!=null&&(f={data:w.data.map(function(N){return N.slice()}),index:0})))}if(f==null&&(f={data:[],index:0}),g===null&&(g=Ym(),Bt.updateQueue=g),g.memoCache=f,g=f.data[f.index],g===void 0)for(g=f.data[f.index]=Array(u),w=0;w<u;w++)g[w]=j;return f.index++,g}function Un(u,f){return typeof f=="function"?f(u):f}function _r(u){var f=Vr();return Fs(f,en,u)}function Fs(u,f,g){var w=u.queue;if(w===null)throw Error(s(311));w.lastRenderedReducer=g;var N=u.baseQueue,O=w.pending;if(O!==null){if(N!==null){var se=N.next;N.next=O.next,O.next=se}f.baseQueue=N=O,w.pending=null}if(O=u.baseState,N===null)u.memoizedState=O;else{f=N.next;var fe=se=null,Ce=null,Ge=f,At=!1;do{var Pt=Ge.lane&-536870913;if(Pt!==Ge.lane?(hr&Pt)===Pt:(Tt&Pt)===Pt){var it=Ge.revertLane;if(it===0)Ce!==null&&(Ce=Ce.next={lane:0,revertLane:0,action:Ge.action,hasEagerState:Ge.hasEagerState,eagerState:Ge.eagerState,next:null}),Pt===Q&&(At=!0);else if((Tt&it)===it){Ge=Ge.next,it===Q&&(At=!0);continue}else Pt={lane:0,revertLane:Ge.revertLane,action:Ge.action,hasEagerState:Ge.hasEagerState,eagerState:Ge.eagerState,next:null},Ce===null?(fe=Ce=Pt,se=O):Ce=Ce.next=Pt,Bt.lanes|=it,Ef|=it;Pt=Ge.action,Rn&&g(O,Pt),O=Ge.hasEagerState?Ge.eagerState:g(O,Pt)}else it={lane:Pt,revertLane:Ge.revertLane,action:Ge.action,hasEagerState:Ge.hasEagerState,eagerState:Ge.eagerState,next:null},Ce===null?(fe=Ce=it,se=O):Ce=Ce.next=it,Bt.lanes|=Pt,Ef|=Pt;Ge=Ge.next}
vendor: 4,134 bytes, line 48
48while(Ge!==null&&Ge!==f);if(Ce===null?se=O:Ce.next=fe,!oa(O,u.memoizedState)&&(Na=!0,At&&(g=ee,g!==null)))throw g;u.memoizedState=O,u.baseState=se,u.baseQueue=Ce,w.lastRenderedState=O}return N===null&&(w.lanes=0),[u.memoizedState,w.dispatch]}function vr(u){var f=Vr(),g=f.queue;if(g===null)throw Error(s(311));g.lastRenderedReducer=u;var w=g.dispatch,N=g.pending,O=f.memoizedState;if(N!==null){g.pending=null;var se=N=N.next;do O=u(O,se.action),se=se.next;while(se!==N);oa(O,f.memoizedState)||(Na=!0),f.memoizedState=O,f.baseQueue===null&&(f.baseState=O),g.lastRenderedState=O}return[O,w]}function Ii(u,f,g){var w=Bt,N=Vr(),O=Bs;if(O){if(g===void 0)throw Error(s(407));g=g()}else g=f();var se=!oa((en||N).memoizedState,g);if(se&&(N.memoizedState=g,Na=!0),N=N.queue,c_(vc.bind(null,w,N,u),[u]),N.getSnapshot!==f||se||Ln!==null&&Ln.memoizedState.tag&1){if(w.flags|=2048,Zm(9,Po.bind(null,w,N,g,f),{destroy:void 0},null),Jr===null)throw Error(s(349));O||(Tt&60)!==0||mf(w,f,g)}return g}function mf(u,f,g){u.flags|=16384,u={getSnapshot:f,value:g},f=Bt.updateQueue,f===null?(f=Ym(),Bt.updateQueue=f,f.stores=[u]):(g=f.stores,g===null?f.stores=[u]:g.push(u))}function Po(u,f,g,w){f.value=g,f.getSnapshot=w,Xc(f)&&bc(u)}function vc(u,f,g){return g(function(){Xc(f)&&bc(u)})}function Xc(u){var f=u.getSnapshot;u=u.value;try{var g=f();return!oa(u,g)}catch{return!0}}function bc(u){var f=vi(u,2);f!==null&&yo(f,u,2)}function Jc(u){var f=Xr();if(typeof u=="function"){var g=u;if(u=g(),Rn){Ut(!0);try{g()}finally{Ut(!1)}}}return f.memoizedState=f.baseState=u,f.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:u},f}function Kd(u,f,g,w){return u.baseState=g,Fs(u,en,typeof w=="function"?w:Un)}function Ml(u,f,g,w,N){if(Jv(u))throw Error(s(485));if(u=f.action,u!==null){var O={payload:N,action:u,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(se){O.listeners.push(se)}};B.T!==null?g(!0):O.isTransition=!1,w(O),g=f.pending,g===null?(O.next=f.pending=O,wc(f,O)):(O.next=g.next,f.pending=g.next=O)}}function wc(u,f){var g=f.action,w=f.payload,N=u.state;if(f.isTransition){var O=B.T,se={};B.T=se;try{var fe=g(N,w),Ce=B.S;Ce!==null&&Ce(se,fe),Qc(u,f,fe)}catch(Ge){gf(u,f,Ge)}finally{B.T=O}}else try{O=g(N,w),Qc(u,f,O)}catch(Ge){gf(u,f,Ge)}}function Qc(u,f,g){g!==null&&typeof g=="object"&&typeof g.then=="function"?g.then(function(w){Pl(u,f,w)},function(w){return gf(u,f,w)}):Pl(u,f,g)}function Pl(u,f,g){f.status="fulfilled",f.value=g,Jm(f),u.state=g,f=u.pending,f!==null&&(g=f.next,g===f?u.pending=null:(g=g.next,f.next=g,wc(u,g)))}function gf(u,f,g){var w=u.pending;if(u.pending=null,w!==null){w=w.next;do f.status="rejected",f.reason=g,Jm(f),f=f.next;while(f!==w)}u.action=null}function Jm(u){u=u.listeners;for(var f=0;f<u.length;f++)(0,u[f])()}function ry(u,f){return f}function Qm(u,f){if(Bs){var g=Jr.formState;if(g!==null){e:{var w=Bt;if(Bs){if(Kr){t:{for(var N=Kr,O=nl;N.nodeType!==8;){if(!O){N=null;break t}if(N=Fl(N.nextSibling),N===null){N=null;break t}}O=N.data,N=O==="F!"||O==="F"?N:null}if(N){Kr=Fl(N.nextSibling),w=N.data==="F!";break e}}qc(w)}w=!1}w&&(f=g[0])}}return g=Xr(),g.memoizedState=g.baseState=f,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ry,lastRenderedState:f},g.queue=w,g=KA.bind(null,Bt,w),w.dispatch=g,w=Jc(!1),O=p_.bind(null,Bt,!1,w.queue),w=Xr(),N={state:f,dispatch:null,action:u,pending:null},w.queue=N,g=Ml.bind(null,Bt,N,O,g),N.dispatch=g,w.memoizedState=u,[f,g,!1]}function iy(u){var f=Vr();return _c(f,en,u)}function _c(u,f,g){f=Fs(u,f,ry)[0],u=_r(Un)[0],f=typeof f=="object"&&f!==null&&typeof f.then=="function"?Ap(f):f;var w=Vr(),N=w.queue,O=N.dispatch;return g!==w.memoizedState&&(Bt.flags|=2048,Zm(9,Kv.bind(null,N,g),{destroy:void 0},null)),[f,O,u]}function Kv(u,f){u.action=f}function Cp(u){var f=Vr(),g=en;if(g!==null)return _c(f,g,u);Vr(),f=f.memoizedState,g=Vr();var w=g.queue.dispatch;return g.memoizedState=u,[f,w,!1]}function Zm(u,f,g,w){return u={tag:u,create:f,inst:g,deps:w,next:null},f=Bt.updateQueue,f===null&&(f=Ym(),Bt.updateQueue=f),g=f.lastEffect,g===null?f.lastEffect=u.next=u:(w=g.next,g.next=u,u.
vendor: 10,781 bytes, line 48
48next=w,f.lastEffect=u),u}function ay(){return Vr().memoizedState}function oy(u,f,g,w){var N=Xr();Bt.flags|=u,N.memoizedState=Zm(1|f,g,{destroy:void 0},w===void 0?null:w)}function Yv(u,f,g,w){var N=Vr();w=w===void 0?null:w;var O=N.memoizedState.inst;en!==null&&w!==null&&Yr(w,en.memoizedState.deps)?N.memoizedState=Zm(f,g,O,w):(Bt.flags|=u,N.memoizedState=Zm(1|f,g,O,w))}function LA(u,f){oy(8390656,8,u,f)}function c_(u,f){Yv(2048,8,u,f)}function u_(u,f){return Yv(4,2,u,f)}function jA(u,f){return Yv(4,4,u,f)}function BA(u,f){if(typeof f=="function"){u=u();var g=f(u);return function(){typeof g=="function"?g():f(null)}}if(f!=null)return u=u(),f.current=u,function(){f.current=null}}function UA(u,f,g){g=g!=null?g.concat([u]):null,Yv(4,4,BA.bind(null,f,u),g)}function d_(){}function FA(u,f){var g=Vr();f=f===void 0?null:f;var w=g.memoizedState;return f!==null&&Yr(f,w[1])?w[0]:(g.memoizedState=[u,f],u)}function VA(u,f){var g=Vr();f=f===void 0?null:f;var w=g.memoizedState;if(f!==null&&Yr(f,w[1]))return w[0];if(w=u(),Rn){Ut(!0);try{u()}finally{Ut(!1)}}return g.memoizedState=[w,f],w}function Xv(u,f,g){return g===void 0||(Tt&1073741824)!==0?u.memoizedState=f:(u.memoizedState=g,u=RC(),Bt.lanes|=u,Ef|=u,g)}function yf(u,f,g,w){return oa(g,f)?g:Mo.current!==null?(u=Xv(u,g,w),oa(u,f)||(Na=!0),u):(Tt&42)===0?(Na=!0,u.memoizedState=g):(u=RC(),Bt.lanes|=u,Ef|=u,f)}function Sc(u,f,g,w,N){var O=Se.p;Se.p=O!==0&&8>O?O:8;var se=B.T,fe={};B.T=fe,p_(u,!1,f,g);try{var Ce=N(),Ge=B.S;if(Ge!==null&&Ge(fe,Ce),Ce!==null&&typeof Ce=="object"&&typeof Ce.then=="function"){var At=Ee(Ce,w);ly(u,f,At,Bl(u))}else ly(u,f,w,Bl(u))}catch(Pt){ly(u,f,{then:function(){},status:"rejected",reason:Pt},Bl())}finally{Se.p=O,B.T=se}}function XM(){}function kp(u,f,g,w){if(u.tag!==5)throw Error(s(476));var N=zA(u).queue;Sc(u,N,f,De,g===null?XM:function(){return GA(u),g(w)})}function zA(u){var f=u.memoizedState;if(f!==null)return f;f={memoizedState:De,baseState:De,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:De},next:null};var g={};return f.next={memoizedState:g,baseState:g,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:g},next:null},u.memoizedState=f,u=u.alternate,u!==null&&(u.memoizedState=f),f}function GA(u){var f=zA(u).next.queue;ly(u,f,{},Bl())}function h_(){return go(vg)}function f_(){return Vr().memoizedState}function HA(){return Vr().memoizedState}function qA(u){for(var f=u.return;f!==null;){switch(f.tag){case 24:case 3:var g=Bl();u=Wu(g);var w=Zd(f,u,g);w!==null&&(yo(w,f,g),Zc(w,f,g)),f={cache:A()},u.payload=f;return}f=f.return}}function WA(u,f,g){var w=Bl();g={lane:w,revertLane:0,action:g,hasEagerState:!1,eagerState:null,next:null},Jv(u)?YA(f,g):(g=Hc(u,f,g,w),g!==null&&(yo(g,u,w),XA(g,f,w)))}function KA(u,f,g){var w=Bl();ly(u,f,g,w)}function ly(u,f,g,w){var N={lane:w,revertLane:0,action:g,hasEagerState:!1,eagerState:null,next:null};if(Jv(u))YA(f,N);else{var O=u.alternate;if(u.lanes===0&&(O===null||O.lanes===0)&&(O=f.lastRenderedReducer,O!==null))try{var se=f.lastRenderedState,fe=O(se,g);if(N.hasEagerState=!0,N.eagerState=fe,oa(fe,se))return tl(u,f,N,0),Jr===null&&Uu(),!1}catch{}finally{}if(g=Hc(u,f,N,w),g!==null)return yo(g,u,w),XA(g,f,w),!0}return!1}function p_(u,f,g,w){if(w={lane:2,revertLane:wb(),action:w,hasEagerState:!1,eagerState:null,next:null},Jv(u)){if(f)throw Error(s(479))}else f=Hc(u,g,w,2),f!==null&&yo(f,u,2)}function Jv(u){var f=u.alternate;return u===Bt||f!==null&&f===Bt}function YA(u,f){Os=Dn=!0;var g=u.pending;g===null?f.next=f:(f.next=g.next,g.next=f),u.pending=f}function XA(u,f,g){if((g&4194176)!==0){var w=f.lanes;w&=u.pendingLanes,g|=w,f.lanes=g,lt(u,g)}}var Hu={readContext:go,use:pf,useCallback:is,useContext:is,useEffect:is,useImperativeHandle:is,useLayoutEffect:is,useInsertionEffect:is,useMemo:is,useReducer:is,useRef:is,useState:is,useDebugValue:is,useDeferredValue:is,useTransition:is,useSyncExternalStore:is,useId:is};Hu.useCacheRefresh=is,Hu.useMemoCache=is,Hu.useHostTransitionStatus=is,Hu.useFormState=is,Hu.useActionState=is,Hu.useOptimistic=is;var Ip={readContext:go,use:pf,useCallback:function(u,f){return Xr().memoizedState=[u,f===void 0?null:f],u},useContext:go,useEffect:LA,useImperativeHandle:function(u,f,g){g=g!=null?g.concat([u]):null,oy(4194308,4,BA.bind(null,f,u),g)},useLayoutEffect:function(u,f){return oy(4194308,4,u,f)},useInsertionEffect:function(u,f){oy(4,2,u,f)},useMemo:function(u,f){var g=Xr();f=f===void 0?null:f;var w=u();if(Rn){Ut(!0);try{u()}finally{Ut(!1)}}return g.memoizedState=[w,f],w},useReducer:function(u,f,g){var w=Xr();if(g!==void 0){var N=g(f);if(Rn){Ut(!0);try{g(f)}finally{Ut(!1)}}}else N=f;return w.memoizedState=w.baseState=N,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:N},w.queue=u,u=u.dispatch=WA.bind(null,Bt,u),[w.memoizedState,u]},useRef:function(u){var f=Xr();return u={current:u},f.memoizedState=u},useState:function(u){u=Jc(u);var f=u.queue,g=KA.bind(null,Bt,f);return f.dispatch=g,[u.memoizedState,g]},useDebugValue:d_,useDeferredValue:function(u,f){var g=Xr();return Xv(g,u,f)},useTransition:function(){var u=Jc(!1);return u=Sc.bind(null,Bt,u.queue,!0,!1),Xr().memoizedState=u,[!1,u]},useSyncExternalStore:function(u,f,g){var w=Bt,N=Xr();if(Bs){if(g===void 0)throw Error(s(407));g=g()}else{if(g=f(),Jr===null)throw Error(s(349));(hr&60)!==0||mf(w,f,g)}N.memoizedState=g;var O={value:g,getSnapshot:f};return N.queue=O,LA(vc.bind(null,w,O,u),[u]),w.flags|=2048,Zm(9,Po.bind(null,w,O,g,f),{destroy:void 0},null),g},useId:function(){var u=Xr(),f=Jr.identifierPrefix;if(Bs){var g=Ro,w=Xi;g=(w&~(1<<32-Lt(w)-1)).toString(32)+g,f=":"+f+"R"+g,g=On++,0<g&&(f+="H"+g.toString(32)),f+=":"}else g=Us++,f=":"+f+"r"+g.toString(32)+":";return u.memoizedState=f},useCacheRefresh:function(){return Xr().memoizedState=qA.bind(null,Bt)}};Ip.useMemoCache=Xm,Ip.useHostTransitionStatus=h_,Ip.useFormState=Qm,Ip.useActionState=Qm,Ip.useOptimistic=function(u){var f=Xr();f.memoizedState=f.baseState=u;var g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return f.queue=g,f=p_.bind(null,Bt,!0,g),g.dispatch=f,[u,f]};var xf={readContext:go,use:pf,useCallback:FA,useContext:go,useEffect:c_,useImperativeHandle:UA,useInsertionEffect:u_,useLayoutEffect:jA,useMemo:VA,useReducer:_r,useRef:ay,useState:function(){return _r(Un)},useDebugValue:d_,useDeferredValue:function(u,f){var g=Vr();return yf(g,en.memoizedState,u,f)},useTransition:function(){var u=_r(Un)[0],f=Vr().memoizedState;return[typeof u=="boolean"?u:Ap(u),f]},useSyncExternalStore:Ii,useId:f_};xf.useCacheRefresh=HA,xf.useMemoCache=Xm,xf.useHostTransitionStatus=h_,xf.useFormState=iy,xf.useActionState=iy,xf.useOptimistic=function(u,f){var g=Vr();return Kd(g,en,u,f)};var Np={readContext:go,use:pf,useCallback:FA,useContext:go,useEffect:c_,useImperativeHandle:UA,useInsertionEffect:u_,useLayoutEffect:jA,useMemo:VA,useReducer:vr,useRef:ay,useState:function(){return vr(Un)},useDebugValue:d_,useDeferredValue:function(u,f){var g=Vr();return en===null?Xv(g,u,f):yf(g,en.memoizedState,u,f)},useTransition:function(){var u=vr(Un)[0],f=Vr().memoizedState;return[typeof u=="boolean"?u:Ap(u),f]},useSyncExternalStore:Ii,useId:f_};Np.useCacheRefresh=HA,Np.useMemoCache=Xm,Np.useHostTransitionStatus=h_,Np.useFormState=Cp,Np.useActionState=Cp,Np.useOptimistic=function(u,f){var g=Vr();return en!==null?Kd(g,en,u,f):(g.baseState=u,[u,g.queue.dispatch])};function m_(u,f,g,w){f=u.memoizedState,g=g(w,f),g=g==null?f:G({},f,g),u.memoizedState=g,u.lanes===0&&(u.updateQueue.baseState=g)}var g_={isMounted:function(u){return(u=u._reactInternals)?Le(u)===u:!1},enqueueSetState:function(u,f,g){u=u._reactInternals;var w=Bl(),N=Wu(w);N.payload=f,g!=null&&(N.callback=g),f=Zd(u,N,w),f!==null&&(yo(f,u,w),Zc(f,u,w))},enqueueReplaceState:function(u,f,g){u=u._reactInternals;var w=Bl(),N=Wu(w);N.tag=1,N.payload=f,g!=null&&(N.callback=g),f=Zd(u,N,w),f!==null&&(yo(f,u,w),Zc(f,u,w))},enqueueForceUpdate:function(u,f){u=u._reactInternals;var g=Bl(),w=Wu(g);w.tag=2,f!=null&&(w.callback=f),f=Zd(u,w,g),f!==null&&(yo(f,u,g),Zc(f,u,g))}};function JA(u,f,g,w,N,O,se){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(w,O,se):f.prototype&&f.prototype.isPureReactComponent?!Wr(g,w)||!Wr(N,O):!0}function y_(u,f,g,w){u=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(g,w),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(g,w),f.state!==u&&g_.enqueueReplaceState(f,f.state,null)}function Rp(u,f){var g=f;if("ref"in f){g={};for(var w in f)w!=="ref"&&(g[w]=f[w])}if(u=u.defaultProps){g===f&&(g=G({},g));for(var N in u)g[N]===void 0&&(g[N]=u[N])}return g}var Qv=typeof reportError=="function"?reportError:function(u){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var f=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof u=="object"&&u!==null&&typeof u.message=="string"?String(u.message):String(u),error:u});if(!window.dispatchEvent(f))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",u);return}console.error(u)};function QA(u){Qv(u)}function ZA(u){console.error(u)}function x_(u){Qv(u)}function cy(u,f){try{var g=u.onUncaughtError;g(f.value,{componentStack:f.stack})}catch(w){setTimeout(function(){throw w})}}function Zv(u,f,g){try{var w=u.onCaughtError;w(g.value,{componentStack:g.stack,errorBoundary:f.tag===1?f.stateNode:null})}catch(N){setTimeout(function(){throw N})}}function uy(u,f,g){return g=Wu(g),g.tag=3,g.payload={element:null},g.callback=function(){cy(u,f)},g}function v_(u){return u=Wu(u),u.tag=3,u}function eb(u,f,g,w){var N=g.type.getDerivedStateFromError;if(typeof N=="function"){var O=w.value;u.payload=function(){return N(O)},u.callback=function(){Zv(f,g,w)}}var se=g.stateNode;se!==null&&typeof se.componentDidCatch=="function"&&(u.callback=function(){Zv(f,g,w),typeof N!="function"&&(Tf===null?Tf=new Set([this]):Tf.add(this));var fe=w.stack;this.componentDidCatch(w.value,{componentStack:fe!==null?fe:""})})}function eC(u,f,g,w,N){if(g.flags|=32768,w!==null&&typeof w=="object"&&typeof w.then=="function"){if(f=g.alternate,f!==null&&$p(f,g,N,!0),g=mo.current,g!==null){switch(g.tag){case 13:return Ia===null?Q_():g.alternate===null&&_i===0&&(_i=3),g.flags&=-257,g.flags|=65536,g.lanes=N,w===_p?g.flags|=16384:(f=g.updateQueue,f===null?g.updateQueue=new Set([w]):f.add(w),Ty(u,w,N)),!1;case 22:return g.flags|=65536,w===_p?g.flags|=16384:(f=g.updateQueue,f===null?(f={transitions:null,markerInstances:null,retryQueue:new Set([w])},g.updateQueue=f):(g=f.retryQueue,g===null?f.retryQueue=new Set([w]):g.add(w)),Ty(u,w,N)),!1}throw Error(s(435,g.tag))}return Ty(u,w,N),Q_(),!1}
vendor: 1,763 bytes, line 48
48if(Bs)return f=mo.current,f!==null?((f.flags&65536)===0&&(f.flags|=256),f.flags|=65536,f.lanes=N,w!==Ud&&(u=Error(s(422),{cause:w}),Vd(Ka(u,g)))):(w!==Ud&&(f=Error(s(423),{cause:w}),Vd(Ka(f,g))),u=u.current.alternate,u.flags|=65536,N&=-N,u.lanes|=N,w=Ka(w,g),N=uy(u.stateNode,w,N),my(u,N),_i!==4&&(_i=2)),!1;var O=Error(s(520),{cause:w});if(O=Ka(O,g),Lp===null?Lp=[O]:Lp.push(O),_i!==4&&(_i=2),f===null)return!0;w=Ka(w,g),g=f;do{switch(g.tag){case 3:return g.flags|=65536,u=N&-N,g.lanes|=u,u=uy(g.stateNode,w,u),my(g,u),!1;case 1:if(f=g.type,O=g.stateNode,(g.flags&128)===0&&(typeof f.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Tf===null||!Tf.has(O))))return g.flags|=65536,N&=-N,g.lanes|=N,N=v_(N),eb(N,u,g,w),my(g,N),!1}g=g.return}while(g!==null);return!1}var b_=Error(s(461)),Na=!1;function ca(u,f,g,w){f.child=u===null?Wm(f,null,g,w):gc(f,u.child,g,w)}function dy(u,f,g,w,N){g=g.render;var O=f.ref;if("ref"in w){var se={};for(var fe in w)fe!=="ref"&&(se[fe]=w[fe])}else se=w;return qu(f),w=di(u,f,g,se,O,N),fe=sl(),u!==null&&!Na?(Yc(u,f,N),Yd(u,f,N)):(Bs&&fe&&lf(f),f.flags|=1,ca(u,f,w,N),f.child)}function hy(u,f,g,w,N){if(u===null){var O=g.type;return typeof O=="function"&&!U_(O)&&O.defaultProps===void 0&&g.compare===null?(f.tag=15,f.type=O,tC(u,f,O,w,N)):(u=hb(g.type,null,w,f,f.mode,N),u.ref=f.ref,u.return=f,f.child=u)}if(O=u.child,!C_(u,N)){var se=O.memoizedProps;if(g=g.compare,g=g!==null?g:Wr,g(se,w)&&u.ref===f.ref)return Yd(u,f,N)}return f.flags|=1,u=_f(O,w),u.ref=f.ref,u.return=f,f.child=u}function tC(u,f,g,w,N){if(u!==null){var O=u.memoizedProps;if(Wr(O,w)&&u.ref===f.ref)if(Na=!1,f.pendingProps=w=O,C_(u,N))(u.flags&131072)!==0&&(Na=!0);else return f.lanes=u.lanes,Yd(u,f,N)}return fy(u,f,g,w,N)}
vendor: 18,091 bytes, line 48
48function nC(u,f,g){var w=f.pendingProps,N=w.children,O=(f.stateNode._pendingVisibility&2)!==0,se=u!==null?u.memoizedState:null;if(Mp(u,f),w.mode==="hidden"||O){if((f.flags&128)!==0){if(w=se!==null?se.baseLanes|g:g,u!==null){for(N=f.child=u.child,O=0;N!==null;)O=O|N.lanes|N.childLanes,N=N.sibling;f.childLanes=O&~w}else f.childLanes=0,f.child=null;return sC(u,f,w,g)}if((g&536870912)!==0)f.memoizedState={baseLanes:0,cachePool:null},u!==null&&Fe(f,se!==null?se.cachePool:null),se!==null?ff(f,se):Ep(),Tp(f);else return f.lanes=f.childLanes=536870912,sC(u,f,se!==null?se.baseLanes|g:g,g)}else se!==null?(Fe(f,se.cachePool),ff(f,se),Il(),f.memoizedState=null):(u!==null&&Fe(f,null),Ep(),Il());return ca(u,f,N,g),f.child}function sC(u,f,g,w){var N=Ze();return N=N===null?null:{parent:x._currentValue,pool:N},f.memoizedState={baseLanes:g,cachePool:N},u!==null&&Fe(f,null),Ep(),Tp(f),u!==null&&$p(u,f,w,!0),null}function Mp(u,f){var g=f.ref;if(g===null)u!==null&&u.ref!==null&&(f.flags|=2097664);else{if(typeof g!="function"&&typeof g!="object")throw Error(s(284));(u===null||u.ref!==g)&&(f.flags|=2097664)}}function fy(u,f,g,w,N){return qu(f),g=di(u,f,g,w,void 0,N),w=sl(),u!==null&&!Na?(Yc(u,f,N),Yd(u,f,N)):(Bs&&w&&lf(f),f.flags|=1,ca(u,f,g,N),f.child)}function tb(u,f,g,w,N,O){return qu(f),f.updateQueue=null,g=Gu(f,w,g,N),Kc(u),w=sl(),u!==null&&!Na?(Yc(u,f,O),Yd(u,f,O)):(Bs&&w&&lf(f),f.flags|=1,ca(u,f,g,O),f.child)}function rC(u,f,g,w,N){if(qu(f),f.stateNode===null){var O=hc,se=g.contextType;typeof se=="object"&&se!==null&&(O=go(se)),O=new g(w,O),f.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=g_,f.stateNode=O,O._reactInternals=f,O=f.stateNode,O.props=w,O.state=f.memoizedState,O.refs={},N_(f),se=g.contextType,O.context=typeof se=="object"&&se!==null?go(se):hc,O.state=f.memoizedState,se=g.getDerivedStateFromProps,typeof se=="function"&&(m_(f,g,se,w),O.state=f.memoizedState),typeof g.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(se=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),se!==O.state&&g_.enqueueReplaceState(O,O.state,null),eg(f,w,O,N),yy(),O.state=f.memoizedState),typeof O.componentDidMount=="function"&&(f.flags|=4194308),w=!0}else if(u===null){O=f.stateNode;var fe=f.memoizedProps,Ce=Rp(g,fe);O.props=Ce;var Ge=O.context,At=g.contextType;se=hc,typeof At=="object"&&At!==null&&(se=go(At));var Pt=g.getDerivedStateFromProps;At=typeof Pt=="function"||typeof O.getSnapshotBeforeUpdate=="function",fe=f.pendingProps!==fe,At||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(fe||Ge!==se)&&y_(f,O,w,se),Qd=!1;var it=f.memoizedState;O.state=it,eg(f,w,O,N),yy(),Ge=f.memoizedState,fe||it!==Ge||Qd?(typeof Pt=="function"&&(m_(f,g,Pt,w),Ge=f.memoizedState),(Ce=Qd||JA(f,g,Ce,w,it,Ge,se))?(At||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"&&(f.flags|=4194308)):(typeof O.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=w,f.memoizedState=Ge),O.props=w,O.state=Ge,O.context=se,w=Ce):(typeof O.componentDidMount=="function"&&(f.flags|=4194308),w=!1)}else{O=f.stateNode,R_(u,f),se=f.memoizedProps,At=Rp(g,se),O.props=At,Pt=f.pendingProps,it=O.context,Ge=g.contextType,Ce=hc,typeof Ge=="object"&&Ge!==null&&(Ce=go(Ge)),fe=g.getDerivedStateFromProps,(Ge=typeof fe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(se!==Pt||it!==Ce)&&y_(f,O,w,Ce),Qd=!1,it=f.memoizedState,O.state=it,eg(f,w,O,N),yy();var Et=f.memoizedState;se!==Pt||it!==Et||Qd||u!==null&&u.dependencies!==null&&ib(u.dependencies)?(typeof fe=="function"&&(m_(f,g,fe,w),Et=f.memoizedState),(At=Qd||JA(f,g,At,w,it,Et,Ce)||u!==null&&u.dependencies!==null&&ib(u.dependencies))?(Ge||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(w,Et,Ce),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(w,Et,Ce)),typeof O.componentDidUpdate=="function"&&(f.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof O.componentDidUpdate!="function"||se===u.memoizedProps&&it===u.memoizedState||(f.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||se===u.memoizedProps&&it===u.memoizedState||(f.flags|=1024),f.memoizedProps=w,f.memoizedState=Et),O.props=w,O.state=Et,O.context=Ce,w=At):(typeof O.componentDidUpdate!="function"||se===u.memoizedProps&&it===u.memoizedState||(f.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||se===u.memoizedProps&&it===u.memoizedState||(f.flags|=1024),w=!1)}return O=w,Mp(u,f),w=(f.flags&128)!==0,O||w?(O=f.stateNode,g=w&&typeof g.getDerivedStateFromError!="function"?null:O.render(),f.flags|=1,u!==null&&w?(f.child=gc(f,u.child,null,N),f.child=gc(f,null,g,N)):ca(u,f,g,N),f.memoizedState=O.state,u=f.child):u=Yd(u,f,N),u}function iC(u,f,g,w){return Fd(),f.flags|=256,ca(u,f,g,w),f.child}var w_={dehydrated:null,treeContext:null,retryLane:0};function __(u){return{baseLanes:u,cachePool:Gt()}}function S_(u,f,g){return u=u!==null?u.childLanes&~g:0,f&&(u|=Cc),u}function aC(u,f,g){var w=f.pendingProps,N=!1,O=(f.flags&128)!==0,se;if((se=O)||(se=u!==null&&u.memoizedState===null?!1:(bi.current&2)!==0),se&&(N=!0,f.flags&=-129),se=(f.flags&32)!==0,f.flags&=-33,u===null){if(Bs){if(N?yc(f):Il(),Bs){var fe=Kr,Ce;if(Ce=fe){e:{for(Ce=fe,fe=nl;Ce.nodeType!==8;){if(!fe){fe=null;break e}if(Ce=Fl(Ce.nextSibling),Ce===null){fe=null;break e}}fe=Ce}fe!==null?(f.memoizedState={dehydrated:fe,treeContext:Cl!==null?{id:Xi,overflow:Ro}:null,retryLane:536870912},Ce=Ll(18,null,null,0),Ce.stateNode=fe,Ce.return=f,f.child=Ce,Fr=f,Kr=null,Ce=!0):Ce=!1}Ce||qc(f)}if(fe=f.memoizedState,fe!==null&&(fe=fe.dehydrated,fe!==null))return fe.data==="$!"?f.lanes=16:f.lanes=536870912,null;Nl(f)}return fe=w.children,w=w.fallback,N?(Il(),N=f.mode,fe=T_({mode:"hidden",children:fe},N),w=Sf(w,N,g,null),fe.return=f,w.return=f,fe.sibling=w,f.child=fe,N=f.child,N.memoizedState=__(g),N.childLanes=S_(u,se,g),f.memoizedState=w_,w):(yc(f),E_(f,fe))}if(Ce=u.memoizedState,Ce!==null&&(fe=Ce.dehydrated,fe!==null)){if(O)f.flags&256?(yc(f),f.flags&=-257,f=A_(u,f,g)):f.memoizedState!==null?(Il(),f.child=u.child,f.flags|=128,f=null):(Il(),N=w.fallback,fe=f.mode,w=T_({mode:"visible",children:w.children},fe),N=Sf(N,fe,g,null),N.flags|=2,w.return=f,N.return=f,w.sibling=N,f.child=w,gc(f,u.child,null,g),w=f.child,w.memoizedState=__(g),w.childLanes=S_(u,se,g),f.memoizedState=w_,f=N);else if(yc(f),fe.data==="$!"){if(se=fe.nextSibling&&fe.nextSibling.dataset,se)var Ge=se.dgst;se=Ge,w=Error(s(419)),w.stack="",w.digest=se,Vd({value:w,source:null,stack:null}),f=A_(u,f,g)}else if(Na||$p(u,f,g,!1),se=(g&u.childLanes)!==0,Na||se){if(se=Jr,se!==null){if(w=g&-g,(w&42)!==0)w=1;else switch(w){case 2:w=1;break;case 8:w=4;break;case 32:w=16;break;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:w=64;break;case 268435456:w=134217728;break;default:w=0}if(w=(w&(se.suspendedLanes|g))!==0?0:w,w!==0&&w!==Ce.retryLane)throw Ce.retryLane=w,vi(u,w),yo(se,u,w),b_}fe.data==="$?"||Q_(),f=A_(u,f,g)}else fe.data==="$?"?(f.flags|=128,f.child=u.child,f=aP.bind(null,u),fe._reactRetry=f,f=null):(u=Ce.treeContext,Kr=Fl(fe.nextSibling),Fr=f,Bs=!0,Ca=null,nl=!1,u!==null&&(ki[Xa++]=Xi,ki[Xa++]=Ro,ki[Xa++]=Cl,Xi=u.id,Ro=u.overflow,Cl=f),f=E_(f,w.children),f.flags|=4096);return f}return N?(Il(),N=w.fallback,fe=f.mode,Ce=u.child,Ge=Ce.sibling,w=_f(Ce,{mode:"hidden",children:w.children}),w.subtreeFlags=Ce.subtreeFlags&31457280,Ge!==null?N=_f(Ge,N):(N=Sf(N,fe,g,null),N.flags|=2),N.return=f,w.return=f,w.sibling=N,f.child=w,w=N,N=f.child,fe=u.child.memoizedState,fe===null?fe=__(g):(Ce=fe.cachePool,Ce!==null?(Ge=x._currentValue,Ce=Ce.parent!==Ge?{parent:Ge,pool:Ge}:Ce):Ce=Gt(),fe={baseLanes:fe.baseLanes|g,cachePool:Ce}),N.memoizedState=fe,N.childLanes=S_(u,se,g),f.memoizedState=w_,w):(yc(f),g=u.child,u=g.sibling,g=_f(g,{mode:"visible",children:w.children}),g.return=f,g.sibling=null,u!==null&&(se=f.deletions,se===null?(f.deletions=[u],f.flags|=16):se.push(u)),f.child=g,f.memoizedState=null,g)}function E_(u,f){return f=T_({mode:"visible",children:f},u.mode),f.return=u,u.child=f}function T_(u,f){return CC(u,f,0,null)}function A_(u,f,g){return gc(f,u.child,null,g),u=E_(f,f.pendingProps.children),u.flags|=2,f.memoizedState=null,u}function nb(u,f,g){u.lanes|=f;var w=u.alternate;w!==null&&(w.lanes|=f),I_(u.return,f,g)}function sb(u,f,g,w,N){var O=u.memoizedState;O===null?u.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:w,tail:g,tailMode:N}:(O.isBackwards=f,O.rendering=null,O.renderingStartTime=0,O.last=w,O.tail=g,O.tailMode=N)}function oC(u,f,g){var w=f.pendingProps,N=w.revealOrder,O=w.tail;if(ca(u,f,w.children,g),w=bi.current,(w&2)!==0)w=w&1|2,f.flags|=128;else{if(u!==null&&(u.flags&128)!==0)e:for(u=f.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&nb(u,g,f);else if(u.tag===19)nb(u,g,f);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===f)break e;for(;u.sibling===null;){if(u.return===null||u.return===f)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}w&=1}switch(wt(bi,w),N){case"forwards":for(g=f.child,N=null;g!==null;)u=g.alternate,u!==null&&zu(u)===null&&(N=g),g=g.sibling;g=N,g===null?(N=f.child,f.child=null):(N=g.sibling,g.sibling=null),sb(f,!1,N,g,O);break;case"backwards":for(g=null,N=f.child,f.child=null;N!==null;){if(u=N.alternate,u!==null&&zu(u)===null){f.child=N;break}u=N.sibling,N.sibling=g,g=N,N=u}sb(f,!0,g,null,O);break;case"together":sb(f,!1,null,null,void 0);break;default:f.memoizedState=null}return f.child}function Yd(u,f,g){if(u!==null&&(f.dependencies=u.dependencies),Ef|=f.lanes,(g&f.childLanes)===0)if(u!==null){if($p(u,f,g,!1),(g&f.childLanes)===0)return null}else return null;if(u!==null&&f.child!==u.child)throw Error(s(153));if(f.child!==null){for(u=f.child,g=_f(u,u.pendingProps),f.child=g,g.return=f;u.sibling!==null;)u=u.sibling,g=g.sibling=_f(u,u.pendingProps),g.return=f;g.sibling=null}return f.child}function C_(u,f){return(u.lanes&f)!==0?!0:(u=u.dependencies,!!(u!==null&&ib(u)))}function py(u,f,g){switch(f.tag){case 3:We(f,f.stateNode.containerInfo),vf(f,x,u.memoizedState.cache),Fd();break;case 27:case 5:ge(f);break;case 4:We(f,f.stateNode.containerInfo);break;case 10:vf(f,f.type,f.memoizedProps.value);break;case 13:var w=f.memoizedState;if(w!==null)return w.dehydrated!==null?(yc(f),f.flags|=128,null):(g&f.child.childLanes)!==0?aC(u,f,g):(yc(f),u=Yd(u,f,g),u!==null?u.sibling:null);yc(f);break;case 19:var N=(u.flags&128)!==0;if(w=(g&f.childLanes)!==0,w||($p(u,f,g,!1),w=(g&f.childLanes)!==0),N){if(w)return oC(u,f,g);f.flags|=128}if(N=f.memoizedState,N!==null&&(N.rendering=null,N.tail=null,N.lastEffect=null),wt(bi,bi.current),w)break;return null;case 22:case 23:return f.lanes=0,nC(u,f,g);case 24:vf(f,x,u.memoizedState.cache)}return Yd(u,f,g)}function lC(u,f,g){if(u!==null)if(u.memoizedProps!==f.pendingProps)Na=!0;else{if(!C_(u,g)&&(f.flags&128)===0)return Na=!1,py(u,f,g);Na=(u.flags&131072)!==0}else Na=!1,Bs&&(f.flags&1048576)!==0&&of(f,Bd,f.index);switch(f.lanes=0,f.tag){case 16:e:{u=f.pendingProps;var w=f.elementType,N=w._init;if(w=N(w._payload),f.type=w,typeof w=="function")U_(w)?(u=Rp(w,u),f.tag=1,f=rC(null,f,w,u,g)):(f.tag=0,f=fy(null,f,w,u,g));else{if(w!=null){if(N=w.$$typeof,N===v){f.tag=11,f=dy(null,f,w,u,g);break e}else if(N===E){f.tag=14,f=hy(null,f,w,u,g);break e}}throw f=R(w)||w,Error(s(306,f,""))}}return f;case 0:return fy(u,f,f.type,f.pendingProps,g);case 1:return w=f.type,N=Rp(w,f.pendingProps),rC(u,f,w,N,g);case 3:e:{if(We(f,f.stateNode.containerInfo),u===null)throw Error(s(387));var O=f.pendingProps;N=f.memoizedState,w=N.element,R_(u,f),eg(f,O,null,g);var se=f.memoizedState;if(O=se.cache,vf(f,x,O),O!==N.cache&&rb(f,[x],g,!0),yy(),O=se.element,N.isDehydrated)if(N={element:O,isDehydrated:!1,cache:se.cache},f.updateQueue.baseState=N,f.memoizedState=N,f.flags&256){f=iC(u,f,O,g);break e}else if(O!==w){w=Ka(Error(s(424)),f),Vd(w),f=iC(u,f,O,g);break e}else for(Kr=Fl(f.stateNode.containerInfo.firstChild),Fr=f,Bs=!0,Ca=null,nl=!0,g=Wm(f,null,O,g),f.child=g;g;)g.flags=g.flags&-3|4096,g=g.sibling;else{if(Fd(),O===w){f=Yd(u,f,g);break e}ca(u,f,O,g)}f=f.child}return f;case 26:return Mp(u,f),u===null?(g=u2(f.type,null,f.pendingProps,null))?f.memoizedState=g:Bs||(g=f.type,u=f.pendingProps,w=ru(Zt.current).createElement(g),w[Ft]=f,w[sn]=u,Ja(w,g,u),Pn(w),f.stateNode=w):f.memoizedState=u2(f.type,u.memoizedProps,f.pendingProps,u.memoizedState),null;case 27:return ge(f),u===null&&Bs&&(w=f.stateNode=QC(f.type,f.pendingProps,Zt.current),Fr=f,nl=!0,Kr=Fl(w.firstChild)),w=f.pendingProps.children,u!==null||Bs?ca(u,f,w,g):f.child=gc(f,null,w,g),Mp(u,f),f.child;case 5:return u===null&&Bs&&((N=w=Kr)&&(w=pP(w,f.type,f.pendingProps,nl),w!==null?(f.stateNode=w,Fr=f,Kr=Fl(w.firstChild),nl=!1,N=!0):N=!1),N||qc(f)),ge(f),N=f.type,O=f.pendingProps,se=u!==null?u.memoizedProps:null,w=O.children,Tb(N,O)?w=null:se!==null&&Tb(N,se)&&(f.flags|=32),f.memoizedState!==null&&(N=di(u,f,wi,null,null,g),vg._currentValue=N),Mp(u,f),ca(u,f,w,g),f.child;case 6:return u===null&&Bs&&((u=g=Kr)&&(g=mP(g,f.pendingProps,nl),g!==null?(f.stateNode=g,Fr=f,Kr=null,u=!0):u=!1),u||qc(f)),null;case 13:return aC(u,f,g);case 4:return We(f,f.stateNode.containerInfo),w=f.pendingProps,u===null?f.child=gc(f,null,w,g):ca(u,f,w,g),f.child;case 11:return dy(u,f,f.type,f.pendingProps,g);case 7:return ca(u,f,f.pendingProps,g),f.child;case 8:return ca(u,f,f.pendingProps.children,g),f.child;case 12:return ca(u,f,f.pendingProps.children,g),f.child;case 10:return w=f.pendingProps,vf(f,f.type,w.value),ca(u,f,w.children,g),f.child;case 9:return N=f.type._context,w=f.pendingProps.children,qu(f),N=go(N),w=w(N),f.flags|=1,ca(u,f,w,g),f.child;case 14:return hy(u,f,f.type,f.pendingProps,g);case 15:return tC(u,f,f.type,f.pendingProps,g);case 19:return oC(u,f,g);case 22:return nC(u,f,g);case 24:return qu(f),w=go(x),u===null?(N=Ze(),N===null&&(N=Jr,O=A(),N.pooledCache=O,O.refCount++,O!==null&&(N.pooledCacheLanes|=g),N=O),f.memoizedState={parent:w,cache:N},N_(f),vf(f,x,N)):((u.lanes&g)!==0&&(R_(u,f),eg(f,null,null,g),yy()),N=u.memoizedState,O=f.memoizedState,N.parent!==w?(N={parent:w,cache:w},f.memoizedState=N,f.lanes===0&&(f.memoizedState=f.updateQueue.baseState=N),vf(f,x,w)):(w=O.cache,vf(f,x,w),w!==N.cache&&rb(f,[x],g,!0))),ca(u,f,f.pendingProps.children,g),f.child;case 29:throw f.pendingProps}throw Error(s(156,f.tag))}var k_=xt(null),Pp=null,Xd=null;function vf(u,f,g){wt(k_,f._currentValue),f._currentValue=g}function Jd(u){u._currentValue=k_.current,Nt(k_)}function I_(u,f,g){for(;u!==null;){var w=u.alternate;if((u.childLanes&f)!==f?(u.childLanes|=f,w!==null&&(w.childLanes|=f)):w!==null&&(w.childLanes&f)!==f&&(w.childLanes|=f),u===g)break;u=u.return}}function rb(u,f,g,w){var N=u.child;for(N!==null&&(N.return=u);N!==null;){var O=N.dependencies;if(O!==null){var se=N.child;O=O.firstContext;e:for(;O!==null;){var fe=O;O=N;for(var Ce=0;Ce<f.length;Ce++)if(fe.context===f[Ce]){O.lanes|=g,fe=O.alternate,fe!==null&&(fe.lanes|=g),I_(O.return,g,u),w||(se=null);break e}O=fe.next}}else if(N.tag===18){if(se=N.return,se===null)throw Error(s(341));se.lanes|=g,O=se.alternate,O!==null&&(O.lanes|=g),I_(se,g,u),se=null}else se=N.child;if(se!==null)se.return=N;else for(se=N;se!==null;){if(se===u){se=null;break}if(N=se.sibling,N!==null){N.return=se.return,se=N;break}se=se.return}N=se}}function $p(u,f,g,w){u=null;for(var N=f,O=!1;N!==null;){if(!O){if((N.flags&524288)!==0)O=!0;else if((N.flags&262144)!==0)break}if(N.tag===10){var se=N.alternate;if(se===null)throw Error(s(387));if(se=se.memoizedProps,se!==null){var fe=N.type;oa(N.pendingProps.value,se.value)||(u!==null?u.push(fe):u=[fe])}}else if(N===J.current){if(se=N.alternate,se===null)throw Error(s(387));se.memoizedState.memoizedState!==N.memoizedState.memoizedState&&(u!==null?u.push(vg):u=[vg])}N=N.return}u!==null&&rb(f,u,g,w),f.flags|=262144}function ib(u){for(u=u.firstContext;u!==null;){if(!oa(u.context._currentValue,u.memoizedValue))return!0;u=u.next}return!1}function qu(u){Pp=u,Xd=null,u=u.dependencies,u!==null&&(u.firstContext=null)}function go(u){return cC(Pp,u)}function ab(u,f){return Pp===null&&qu(u),cC(u,f)}function cC(u,f){var g=f._currentValue;if(f={context:f,memoizedValue:g,next:null},Xd===null){if(u===null)throw Error(s(308));Xd=f,u.dependencies={lanes:0,firstContext:f},u.flags|=524288}else Xd=Xd.next=f;return g}var Qd=!1;function N_(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function R_(u,f){u=u.updateQueue,f.updateQueue===u&&(f.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,callbacks:null})}function Wu(u){return{lane:u,tag:0,payload:null,callback:null,next:null}}function Zd(u,f,g){var w=u.updateQueue;if(w===null)return null;if(w=w.shared,(Ri&2)!==0){var N=w.pending;return N===null?f.next=f:(f.next=N.next,N.next=f),w.pending=f,f=Ld(u),Od(u,null,g),f}return tl(u,w,f,g),Ld(u)}function Zc(u,f,g){if(f=f.updateQueue,f!==null&&(f=f.shared,(g&4194176)!==0)){var w=f.lanes;w&=u.pendingLanes,g|=w,f.lanes=g,lt(u,g)}}function my(u,f){var g=u.updateQueue,w=u.alternate;if(w!==null&&(w=w.updateQueue,g===w)){var N=null,O=null;if(g=g.firstBaseUpdate,g!==null){do{var se={lane:g.lane,tag:g.tag,payload:g.payload,callback:null,next:null};O===null?N=O=se:O=O.next=se,g=g.next}
vendor: 2,019 bytes, line 48
48while(g!==null);O===null?N=O=f:O=O.next=f}else N=O=f;g={baseState:w.baseState,firstBaseUpdate:N,lastBaseUpdate:O,shared:w.shared,callbacks:w.callbacks},u.updateQueue=g;return}u=g.lastBaseUpdate,u===null?g.firstBaseUpdate=f:u.next=f,g.lastBaseUpdate=f}var gy=!1;function yy(){if(gy){var u=ee;if(u!==null)throw u}}function eg(u,f,g,w){gy=!1;var N=u.updateQueue;Qd=!1;var O=N.firstBaseUpdate,se=N.lastBaseUpdate,fe=N.shared.pending;if(fe!==null){N.shared.pending=null;var Ce=fe,Ge=Ce.next;Ce.next=null,se===null?O=Ge:se.next=Ge,se=Ce;var At=u.alternate;At!==null&&(At=At.updateQueue,fe=At.lastBaseUpdate,fe!==se&&(fe===null?At.firstBaseUpdate=Ge:fe.next=Ge,At.lastBaseUpdate=Ce))}if(O!==null){var Pt=N.baseState;se=0,At=Ge=Ce=null,fe=O;do{var it=fe.lane&-536870913,Et=it!==fe.lane;if(Et?(hr&it)===it:(w&it)===it){it!==0&&it===Q&&(gy=!0),At!==null&&(At=At.next={lane:0,tag:fe.tag,payload:fe.payload,callback:null,next:null});e:{var jn=u,Cs=fe;it=f;var zi=g;switch(Cs.tag){case 1:if(jn=Cs.payload,typeof jn=="function"){Pt=jn.call(zi,Pt,it);break e}Pt=jn;break e;case 3:jn.flags=jn.flags&-65537|128;case 0:if(jn=Cs.payload,it=typeof jn=="function"?jn.call(zi,Pt,it):jn,it==null)break e;Pt=G({},Pt,it);break e;case 2:Qd=!0}}it=fe.callback,it!==null&&(u.flags|=64,Et&&(u.flags|=8192),Et=N.callbacks,Et===null?N.callbacks=[it]:Et.push(it))}else Et={lane:it,tag:fe.tag,payload:fe.payload,callback:fe.callback,next:null},At===null?(Ge=At=Et,Ce=Pt):At=At.next=Et,se|=it;if(fe=fe.next,fe===null){if(fe=N.shared.pending,fe===null)break;Et=fe,fe=Et.next,Et.next=null,N.lastBaseUpdate=Et,N.shared.pending=null}}while(!0);At===null&&(Ce=Pt),N.baseState=Ce,N.firstBaseUpdate=Ge,N.lastBaseUpdate=At,O===null&&(N.shared.lanes=0),Ef|=se,u.lanes=se,u.memoizedState=Pt}}function uC(u,f){if(typeof u!="function")throw Error(s(191,u));u.call(f)}function dC(u,f){var g=u.callbacks;if(g!==null)for(u.callbacks=null,u=0;u<g.length;u++)uC(g[u],f)}function xy(u,f){try{var g=f.updateQueue,w=g!==null?g.lastEffect:null;if(w!==null){var N=w.next;g=N;
vendor: 30,987 bytes, line 48
48do{if((g.tag&u)===u){w=void 0;var O=g.create,se=g.inst;w=O(),se.destroy=w}g=g.next}while(g!==N)}}catch(fe){zr(f,f.return,fe)}}function eh(u,f,g){try{var w=f.updateQueue,N=w!==null?w.lastEffect:null;if(N!==null){var O=N.next;w=O;do{if((w.tag&u)===u){var se=w.inst,fe=se.destroy;if(fe!==void 0){se.destroy=void 0,N=f;var Ce=g;try{fe()}catch(Ge){zr(N,Ce,Ge)}}}w=w.next}while(w!==O)}}catch(Ge){zr(f,f.return,Ge)}}function ob(u){var f=u.updateQueue;if(f!==null){var g=u.stateNode;try{dC(f,g)}catch(w){zr(u,u.return,w)}}}function hC(u,f,g){g.props=Rp(u.type,u.memoizedProps),g.state=u.memoizedState;try{g.componentWillUnmount()}catch(w){zr(u,f,w)}}function Dp(u,f){try{var g=u.ref;if(g!==null){var w=u.stateNode;switch(u.tag){case 26:case 27:case 5:var N=w;break;default:N=w}typeof g=="function"?u.refCleanup=g(N):g.current=N}}catch(O){zr(u,f,O)}}function $l(u,f){var g=u.ref,w=u.refCleanup;if(g!==null)if(typeof w=="function")try{w()}catch(N){zr(u,f,N)}finally{u.refCleanup=null,u=u.alternate,u!=null&&(u.refCleanup=null)}else if(typeof g=="function")try{g(null)}catch(N){zr(u,f,N)}else g.current=null}function fC(u){var f=u.type,g=u.memoizedProps,w=u.stateNode;try{e:switch(f){case"button":case"input":case"select":case"textarea":g.autoFocus&&w.focus();break e;case"img":g.src?w.src=g.src:g.srcSet&&(w.srcset=g.srcSet)}}catch(N){zr(u,u.return,N)}}function pC(u,f,g){try{var w=u.stateNode;dP(w,u.type,g,f),w[sn]=f}catch(N){zr(u,u.return,N)}}function mC(u){return u.tag===5||u.tag===3||u.tag===26||u.tag===27||u.tag===4}function M_(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||mC(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==27&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function P_(u,f,g){var w=u.tag;if(w===5||w===6)u=u.stateNode,f?g.nodeType===8?g.parentNode.insertBefore(u,f):g.insertBefore(u,f):(g.nodeType===8?(f=g.parentNode,f.insertBefore(u,g)):(f=g,f.appendChild(u)),g=g._reactRootContainer,g!=null||f.onclick!==null||(f.onclick=Cy));else if(w!==4&&w!==27&&(u=u.child,u!==null))for(P_(u,f,g),u=u.sibling;u!==null;)P_(u,f,g),u=u.sibling}function lb(u,f,g){var w=u.tag;if(w===5||w===6)u=u.stateNode,f?g.insertBefore(u,f):g.appendChild(u);else if(w!==4&&w!==27&&(u=u.child,u!==null))for(lb(u,f,g),u=u.sibling;u!==null;)lb(u,f,g),u=u.sibling}var th=!1,Vi=!1,$_=!1,gC=typeof WeakSet=="function"?WeakSet:Set,Ra=null,yC=!1;function JM(u,f){if(u=u.containerInfo,pg=wg,u=Jo(u),es(u)){if("selectionStart"in u)var g={start:u.selectionStart,end:u.selectionEnd};else e:{g=(g=u.ownerDocument)&&g.defaultView||window;var w=g.getSelection&&g.getSelection();if(w&&w.rangeCount!==0){g=w.anchorNode;var N=w.anchorOffset,O=w.focusNode;w=w.focusOffset;try{g.nodeType,O.nodeType}catch{g=null;break e}var se=0,fe=-1,Ce=-1,Ge=0,At=0,Pt=u,it=null;t:for(;;){for(var Et;Pt!==g||N!==0&&Pt.nodeType!==3||(fe=se+N),Pt!==O||w!==0&&Pt.nodeType!==3||(Ce=se+w),Pt.nodeType===3&&(se+=Pt.nodeValue.length),(Et=Pt.firstChild)!==null;)it=Pt,Pt=Et;for(;;){if(Pt===u)break t;if(it===g&&++Ge===N&&(fe=se),it===O&&++At===w&&(Ce=se),(Et=Pt.nextSibling)!==null)break;Pt=it,it=Pt.parentNode}Pt=Et}g=fe===-1||Ce===-1?null:{start:fe,end:Ce}}else g=null}g=g||{start:0,end:0}}else g=null;for(Ju={focusedElem:u,selectionRange:g},wg=!1,Ra=f;Ra!==null;)if(f=Ra,u=f.child,(f.subtreeFlags&1028)!==0&&u!==null)u.return=f,Ra=u;else for(;Ra!==null;){switch(f=Ra,O=f.alternate,u=f.flags,f.tag){case 0:break;case 11:case 15:break;case 1:if((u&1024)!==0&&O!==null){u=void 0,g=f,N=O.memoizedProps,O=O.memoizedState,w=g.stateNode;try{var jn=Rp(g.type,N,g.elementType===g.type);u=w.getSnapshotBeforeUpdate(jn,O),w.__reactInternalSnapshotBeforeUpdate=u}catch(Cs){zr(g,g.return,Cs)}}break;case 3:if((u&1024)!==0){if(u=f.stateNode.containerInfo,g=u.nodeType,g===9)o2(u);else if(g===1)switch(u.nodeName){case"HEAD":case"HTML":case"BODY":o2(u);break;default:u.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((u&1024)!==0)throw Error(s(163))}if(u=f.sibling,u!==null){u.return=f.return,Ra=u;break}Ra=f.return}return jn=yC,yC=!1,jn}function xC(u,f,g){var w=g.flags;switch(g.tag){case 0:case 11:case 15:eu(u,g),w&4&&xy(5,g);break;case 1:if(eu(u,g),w&4)if(u=g.stateNode,f===null)try{u.componentDidMount()}catch(fe){zr(g,g.return,fe)}else{var N=Rp(g.type,f.memoizedProps);f=f.memoizedState;try{u.componentDidUpdate(N,f,u.__reactInternalSnapshotBeforeUpdate)}catch(fe){zr(g,g.return,fe)}}w&64&&ob(g),w&512&&Dp(g,g.return);break;case 3:if(eu(u,g),w&64&&(w=g.updateQueue,w!==null)){if(u=null,g.child!==null)switch(g.child.tag){case 27:case 5:u=g.child.stateNode;break;case 1:u=g.child.stateNode}try{dC(w,u)}catch(fe){zr(g,g.return,fe)}}break;case 26:eu(u,g),w&512&&Dp(g,g.return);break;case 27:case 5:eu(u,g),f===null&&w&4&&fC(g),w&512&&Dp(g,g.return);break;case 12:eu(u,g);break;case 13:eu(u,g),w&4&&wC(u,g);break;case 22:if(N=g.memoizedState!==null||th,!N){f=f!==null&&f.memoizedState!==null||Vi;var O=th,se=Vi;th=N,(Vi=f)&&!se?bf(u,g,(g.subtreeFlags&8772)!==0):eu(u,g),th=O,Vi=se}w&512&&(g.memoizedProps.mode==="manual"?Dp(g,g.return):$l(g,g.return));break;default:eu(u,g)}}function vC(u){var f=u.alternate;f!==null&&(u.alternate=null,vC(f)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(f=u.stateNode,f!==null&&Ps(f)),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}var ua=null,Dl=!1;function Ol(u,f,g){for(g=g.child;g!==null;)bC(u,f,g),g=g.sibling}function bC(u,f,g){if(ht&&typeof ht.onCommitFiberUnmount=="function")try{ht.onCommitFiberUnmount(bt,g)}catch{}switch(g.tag){case 26:Vi||$l(g,f),Ol(u,f,g),g.memoizedState?g.memoizedState.count--:g.stateNode&&(g=g.stateNode,g.parentNode.removeChild(g));break;case 27:Vi||$l(g,f);var w=ua,N=Dl;for(ua=g.stateNode,Ol(u,f,g),g=g.stateNode,f=g.attributes;f.length;)g.removeAttributeNode(f[0]);Ps(g),ua=w,Dl=N;break;case 5:Vi||$l(g,f);case 6:N=ua;var O=Dl;if(ua=null,Ol(u,f,g),ua=N,Dl=O,ua!==null)if(Dl)try{u=ua,w=g.stateNode,u.nodeType===8?u.parentNode.removeChild(w):u.removeChild(w)}catch(se){zr(g,f,se)}else try{ua.removeChild(g.stateNode)}catch(se){zr(g,f,se)}break;case 18:ua!==null&&(Dl?(f=ua,g=g.stateNode,f.nodeType===8?a2(f.parentNode,g):f.nodeType===1&&a2(f,g),Ma(f)):a2(ua,g.stateNode));break;case 4:w=ua,N=Dl,ua=g.stateNode.containerInfo,Dl=!0,Ol(u,f,g),ua=w,Dl=N;break;case 0:case 11:case 14:case 15:Vi||eh(2,g,f),Vi||eh(4,g,f),Ol(u,f,g);break;case 1:Vi||($l(g,f),w=g.stateNode,typeof w.componentWillUnmount=="function"&&hC(g,f,w)),Ol(u,f,g);break;case 21:Ol(u,f,g);break;case 22:Vi||$l(g,f),Vi=(w=Vi)||g.memoizedState!==null,Ol(u,f,g),Vi=w;break;default:Ol(u,f,g)}}function wC(u,f){if(f.memoizedState===null&&(u=f.alternate,u!==null&&(u=u.memoizedState,u!==null&&(u=u.dehydrated,u!==null))))try{Ma(u)}catch(g){zr(f,f.return,g)}}function _C(u){switch(u.tag){case 13:case 19:var f=u.stateNode;return f===null&&(f=u.stateNode=new gC),f;case 22:return u=u.stateNode,f=u._retryCache,f===null&&(f=u._retryCache=new gC),f;default:throw Error(s(435,u.tag))}}function D_(u,f){var g=_C(u);f.forEach(function(w){var N=oP.bind(null,u,w);g.has(w)||(g.add(w),w.then(N,N))})}function Ec(u,f){var g=f.deletions;if(g!==null)for(var w=0;w<g.length;w++){var N=g[w],O=u,se=f,fe=se;e:for(;fe!==null;){switch(fe.tag){case 27:case 5:ua=fe.stateNode,Dl=!1;break e;case 3:ua=fe.stateNode.containerInfo,Dl=!0;break e;case 4:ua=fe.stateNode.containerInfo,Dl=!0;break e}fe=fe.return}if(ua===null)throw Error(s(160));bC(O,se,N),ua=null,Dl=!1,O=N.alternate,O!==null&&(O.return=null),N.return=null}if(f.subtreeFlags&13878)for(f=f.child;f!==null;)O_(f,u),f=f.sibling}var Tc=null;function O_(u,f){var g=u.alternate,w=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:Ec(f,u),Ac(u),w&4&&(eh(3,u,u.return),xy(3,u),eh(5,u,u.return));break;case 1:Ec(f,u),Ac(u),w&512&&(Vi||g===null||$l(g,g.return)),w&64&&th&&(u=u.updateQueue,u!==null&&(w=u.callbacks,w!==null&&(g=u.shared.hiddenCallbacks,u.shared.hiddenCallbacks=g===null?w:g.concat(w))));break;case 26:var N=Tc;if(Ec(f,u),Ac(u),w&512&&(Vi||g===null||$l(g,g.return)),w&4){var O=g!==null?g.memoizedState:null;if(w=u.memoizedState,g===null)if(w===null)if(u.stateNode===null){e:{w=u.type,g=u.memoizedProps,N=N.ownerDocument||N;t:switch(w){case"title":O=N.getElementsByTagName("title")[0],(!O||O[ls]||O[Ft]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=N.createElement(w),N.head.insertBefore(O,N.querySelector("head > title"))),Ja(O,w,g),O[Ft]=u,Pn(O),w=O;break e;case"link":var se=ak("link","href",N).get(w+(g.href||""));if(se){for(var fe=0;fe<se.length;fe++)if(O=se[fe],O.getAttribute("href")===(g.href==null?null:g.href)&&O.getAttribute("rel")===(g.rel==null?null:g.rel)&&O.getAttribute("title")===(g.title==null?null:g.title)&&O.getAttribute("crossorigin")===(g.crossOrigin==null?null:g.crossOrigin)){se.splice(fe,1);break t}}O=N.createElement(w),Ja(O,w,g),N.head.appendChild(O);break;case"meta":if(se=ak("meta","content",N).get(w+(g.content||""))){for(fe=0;fe<se.length;fe++)if(O=se[fe],O.getAttribute("content")===(g.content==null?null:""+g.content)&&O.getAttribute("name")===(g.name==null?null:g.name)&&O.getAttribute("property")===(g.property==null?null:g.property)&&O.getAttribute("http-equiv")===(g.httpEquiv==null?null:g.httpEquiv)&&O.getAttribute("charset")===(g.charSet==null?null:g.charSet)){se.splice(fe,1);break t}}O=N.createElement(w),Ja(O,w,g),N.head.appendChild(O);break;default:throw Error(s(468,w))}O[Ft]=u,Pn(O),w=O}u.stateNode=w}else ok(N,u.type,u.stateNode);else u.stateNode=ik(N,w,u.memoizedProps);else O!==w?(O===null?g.stateNode!==null&&(g=g.stateNode,g.parentNode.removeChild(g)):O.count--,w===null?ok(N,u.type,u.stateNode):ik(N,w,u.memoizedProps)):w===null&&u.stateNode!==null&&pC(u,u.memoizedProps,g.memoizedProps)}break;case 27:if(w&4&&u.alternate===null){N=u.stateNode,O=u.memoizedProps;try{for(var Ce=N.firstChild;Ce;){var Ge=Ce.nextSibling,At=Ce.nodeName;Ce[ls]||At==="HEAD"||At==="BODY"||At==="SCRIPT"||At==="STYLE"||At==="LINK"&&Ce.rel.toLowerCase()==="stylesheet"||N.removeChild(Ce),Ce=Ge}for(var Pt=u.type,it=N.attributes;it.length;)N.removeAttributeNode(it[0]);Ja(N,Pt,O),N[Ft]=u,N[sn]=O}catch(jn){zr(u,u.return,jn)}}case 5:if(Ec(f,u),Ac(u),w&512&&(Vi||g===null||$l(g,g.return)),u.flags&32){N=u.stateNode;try{Qn(N,"")}catch(jn){zr(u,u.return,jn)}}w&4&&u.stateNode!=null&&(N=u.memoizedProps,pC(u,N,g!==null?g.memoizedProps:N)),w&1024&&($_=!0);break;case 6:if(Ec(f,u),Ac(u),w&4){if(u.stateNode===null)throw Error(s(162));w=u.memoizedProps,g=u.stateNode;try{g.nodeValue=w}catch(jn){zr(u,u.return,jn)}}break;case 3:if(Ib=null,N=Tc,Tc=Ab(f.containerInfo),Ec(f,u),Tc=N,Ac(u),w&4&&g!==null&&g.memoizedState.isDehydrated)try{Ma(f.containerInfo)}catch(jn){zr(u,u.return,jn)}$_&&($_=!1,SC(u));break;case 4:w=Tc,Tc=Ab(u.stateNode.containerInfo),Ec(f,u),Ac(u),Tc=w;break;case 12:Ec(f,u),Ac(u);break;case 13:Ec(f,u),Ac(u),u.child.flags&8192&&u.memoizedState!==null!=(g!==null&&g.memoizedState!==null)&&(jp=Mt()),w&4&&(w=u.updateQueue,w!==null&&(u.updateQueue=null,D_(u,w)));break;case 22:if(w&512&&(Vi||g===null||$l(g,g.return)),Ce=u.memoizedState!==null,Ge=g!==null&&g.memoizedState!==null,At=th,Pt=Vi,th=At||Ce,Vi=Pt||Ge,Ec(f,u),Vi=Pt,th=At,Ac(u),f=u.stateNode,f._current=u,f._visibility&=-3,f._visibility|=f._pendingVisibility&2,w&8192&&(f._visibility=Ce?f._visibility&-2:f._visibility|1,Ce&&(f=th||Vi,g===null||Ge||f||tg(u)),u.memoizedProps===null||u.memoizedProps.mode!=="manual"))e:for(g=null,f=u;;){if(f.tag===5||f.tag===26||f.tag===27){if(g===null){Ge=g=f;try{if(N=Ge.stateNode,Ce)O=N.style,typeof O.setProperty=="function"?O.setProperty("display","none","important"):O.display="none";else{se=Ge.stateNode,fe=Ge.memoizedProps.style;var Et=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;se.style.display=Et==null||typeof Et=="boolean"?"":(""+Et).trim()}}catch(jn){zr(Ge,Ge.return,jn)}}}else if(f.tag===6){if(g===null){Ge=f;try{Ge.stateNode.nodeValue=Ce?"":Ge.memoizedProps}catch(jn){zr(Ge,Ge.return,jn)}}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===u)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===u)break e;for(;f.sibling===null;){if(f.return===null||f.return===u)break e;g===f&&(g=null),f=f.return}g===f&&(g=null),f.sibling.return=f.return,f=f.sibling}w&4&&(w=u.updateQueue,w!==null&&(g=w.retryQueue,g!==null&&(w.retryQueue=null,D_(u,g))));break;case 19:Ec(f,u),Ac(u),w&4&&(w=u.updateQueue,w!==null&&(u.updateQueue=null,D_(u,w)));break;case 21:break;default:Ec(f,u),Ac(u)}}function Ac(u){var f=u.flags;if(f&2){try{if(u.tag!==27){e:{for(var g=u.return;g!==null;){if(mC(g)){var w=g;break e}g=g.return}throw Error(s(160))}switch(w.tag){case 27:var N=w.stateNode,O=M_(u);lb(u,O,N);break;case 5:var se=w.stateNode;w.flags&32&&(Qn(se,""),w.flags&=-33);var fe=M_(u);lb(u,fe,se);break;case 3:case 4:var Ce=w.stateNode.containerInfo,Ge=M_(u);P_(u,Ge,Ce);break;default:throw Error(s(161))}}}catch(At){zr(u,u.return,At)}u.flags&=-3}f&4096&&(u.flags&=-4097)}function SC(u){if(u.subtreeFlags&1024)for(u=u.child;u!==null;){var f=u;SC(f),f.tag===5&&f.flags&1024&&f.stateNode.reset(),u=u.sibling}}function eu(u,f){if(f.subtreeFlags&8772)for(f=f.child;f!==null;)xC(u,f.alternate,f),f=f.sibling}function tg(u){for(u=u.child;u!==null;){var f=u;switch(f.tag){case 0:case 11:case 14:case 15:eh(4,f,f.return),tg(f);break;case 1:$l(f,f.return);var g=f.stateNode;typeof g.componentWillUnmount=="function"&&hC(f,f.return,g),tg(f);break;case 26:case 27:case 5:$l(f,f.return),tg(f);break;case 22:$l(f,f.return),f.memoizedState===null&&tg(f);break;default:tg(f)}u=u.sibling}}function bf(u,f,g){for(g=g&&(f.subtreeFlags&8772)!==0,f=f.child;f!==null;){var w=f.alternate,N=u,O=f,se=O.flags;switch(O.tag){case 0:case 11:case 15:bf(N,O,g),xy(4,O);break;case 1:if(bf(N,O,g),w=O,N=w.stateNode,typeof N.componentDidMount=="function")try{N.componentDidMount()}catch(Ge){zr(w,w.return,Ge)}if(w=O,N=w.updateQueue,N!==null){var fe=w.stateNode;try{var Ce=N.shared.hiddenCallbacks;if(Ce!==null)for(N.shared.hiddenCallbacks=null,N=0;N<Ce.length;N++)uC(Ce[N],fe)}catch(Ge){zr(w,w.return,Ge)}}g&&se&64&&ob(O),Dp(O,O.return);break;case 26:case 27:case 5:bf(N,O,g),g&&w===null&&se&4&&fC(O),Dp(O,O.return);break;case 12:bf(N,O,g);break;case 13:bf(N,O,g),g&&se&4&&wC(N,O);break;case 22:O.memoizedState===null&&bf(N,O,g),Dp(O,O.return);break;default:bf(N,O,g)}f=f.sibling}}function cb(u,f){var g=null;u!==null&&u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),u=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(u=f.memoizedState.cachePool.pool),u!==g&&(u!=null&&u.refCount++,g!=null&&$(g))}function L_(u,f){u=null,f.alternate!==null&&(u=f.alternate.memoizedState.cache),f=f.memoizedState.cache,f!==u&&(f.refCount++,u!=null&&$(u))}function wf(u,f,g,w){if(f.subtreeFlags&10256)for(f=f.child;f!==null;)j_(u,f,g,w),f=f.sibling}function j_(u,f,g,w){var N=f.flags;switch(f.tag){case 0:case 11:case 15:wf(u,f,g,w),N&2048&&xy(9,f);break;case 3:wf(u,f,g,w),N&2048&&(u=null,f.alternate!==null&&(u=f.alternate.memoizedState.cache),f=f.memoizedState.cache,f!==u&&(f.refCount++,u!=null&&$(u)));break;case 12:if(N&2048){wf(u,f,g,w),u=f.stateNode;try{var O=f.memoizedProps,se=O.id,fe=O.onPostCommit;typeof fe=="function"&&fe(se,f.alternate===null?"mount":"update",u.passiveEffectDuration,-0)}catch(Ce){zr(f,f.return,Ce)}}else wf(u,f,g,w);break;case 23:break;case 22:O=f.stateNode,f.memoizedState!==null?O._visibility&4?wf(u,f,g,w):sh(u,f):O._visibility&4?wf(u,f,g,w):(O._visibility|=4,nh(u,f,g,w,(f.subtreeFlags&10256)!==0)),N&2048&&cb(f.alternate,f);break;case 24:wf(u,f,g,w),N&2048&&L_(f.alternate,f);break;default:wf(u,f,g,w)}}function nh(u,f,g,w,N){for(N=N&&(f.subtreeFlags&10256)!==0,f=f.child;f!==null;){var O=u,se=f,fe=g,Ce=w,Ge=se.flags;switch(se.tag){case 0:case 11:case 15:nh(O,se,fe,Ce,N),xy(8,se);break;case 23:break;case 22:var At=se.stateNode;se.memoizedState!==null?At._visibility&4?nh(O,se,fe,Ce,N):sh(O,se):(At._visibility|=4,nh(O,se,fe,Ce,N)),N&&Ge&2048&&cb(se.alternate,se);break;case 24:nh(O,se,fe,Ce,N),N&&Ge&2048&&L_(se.alternate,se);break;default:nh(O,se,fe,Ce,N)}f=f.sibling}}function sh(u,f){if(f.subtreeFlags&10256)for(f=f.child;f!==null;){var g=u,w=f,N=w.flags;switch(w.tag){case 22:sh(g,w),N&2048&&cb(w.alternate,w);break;case 24:sh(g,w),N&2048&&L_(w.alternate,w);break;default:sh(g,w)}f=f.sibling}}var ng=8192;function Ku(u){if(u.subtreeFlags&ng)for(u=u.child;u!==null;)B_(u),u=u.sibling}function B_(u){switch(u.tag){case 26:Ku(u),u.flags&ng&&u.memoizedState!==null&&_P(Tc,u.memoizedState,u.memoizedProps);break;case 5:Ku(u);break;case 3:case 4:var f=Tc;Tc=Ab(u.stateNode.containerInfo),Ku(u),Tc=f;break;case 22:u.memoizedState===null&&(f=u.alternate,f!==null&&f.memoizedState!==null?(f=ng,ng=16777216,Ku(u),ng=f):Ku(u));break;default:Ku(u)}}function EC(u){var f=u.alternate;if(f!==null&&(u=f.child,u!==null)){f.child=null;do f=u.sibling,u.sibling=null,u=f;while(u!==null)}}function vy(u){var f=u.deletions;if((u.flags&16)!==0){if(f!==null)for(var g=0;g<f.length;g++){var w=f[g];Ra=w,db(w,u)}EC(u)}if(u.subtreeFlags&10256)for(u=u.child;u!==null;)TC(u),u=u.sibling}function TC(u){switch(u.tag){case 0:case 11:case 15:vy(u),u.flags&2048&&eh(9,u,u.return);break;case 3:vy(u);break;case 12:vy(u);break;case 22:var f=u.stateNode;u.memoizedState!==null&&f._visibility&4&&(u.return===null||u.return.tag!==13)?(f._visibility&=-5,ub(u)):vy(u);break;default:vy(u)}}function ub(u){var f=u.deletions;if((u.flags&16)!==0){if(f!==null)for(var g=0;g<f.length;g++){var w=f[g];Ra=w,db(w,u)}EC(u)}for(u=u.child;u!==null;){switch(f=u,f.tag){case 0:case 11:case 15:eh(8,f,f.return),ub(f);break;case 22:g=f.stateNode,g._visibility&4&&(g._visibility&=-5,ub(f));break;default:ub(f)}u=u.sibling}}function db(u,f){for(;Ra!==null;){var g=Ra;switch(g.tag){case 0:case 11:case 15:eh(8,g,f);break;case 23:case 22:if(g.memoizedState!==null&&g.memoizedState.cachePool!==null){var w=g.memoizedState.cachePool.pool;w!=null&&w.refCount++}break;case 24:$(g.memoizedState.cache)}if(w=g.child,w!==null)w.return=g,Ra=w;else e:for(g=u;Ra!==null;){w=Ra;var N=w.sibling,O=w.return;if(vC(w),w===g){Ra=null;break e}if(N!==null){N.return=O,Ra=N;break e}Ra=O}}}function AC(u,f,g,w){this.tag=u,this.key=g,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ll(u,f,g,w){return new AC(u,f,g,w)}function U_(u){return u=u.prototype,!(!u||!u.isReactComponent)}function _f(u,f){var g=u.alternate;return g===null?(g=Ll(u.tag,f,u.key,u.mode),g.elementType=u.elementType,g.type=u.type,g.stateNode=u.stateNode,g.alternate=u,u.alternate=g):(g.pendingProps=f,g.type=u.type,g.flags=0,g.subtreeFlags=0,g.deletions=null),g.flags=u.flags&31457280,g.childLanes=u.childLanes,g.lanes=u.lanes,g.child=u.child,g.memoizedProps=u.memoizedProps,g.memoizedState=u.memoizedState,g.updateQueue=u.updateQueue,f=u.dependencies,g.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},g.sibling=u.sibling,g.index=u.index,g.ref=u.ref,g.refCleanup=u.refCleanup,g}function by(u,f){u.flags&=31457282;var g=u.alternate;return g===null?(u.childLanes=0,u.lanes=f,u.child=null,u.subtreeFlags=0,u.memoizedProps=null,u.memoizedState=null,u.updateQueue=null,u.dependencies=null,u.stateNode=null):(u.childLanes=g.childLanes,u.lanes=g.lanes,u.child=g.child,u.subtreeFlags=0,u.deletions=null,u.memoizedProps=g.memoizedProps,u.memoizedState=g.memoizedState,u.updateQueue=g.updateQueue,u.type=g.type,f=g.dependencies,u.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext}),u}function hb(u,f,g,w,N,O){var se=0;if(w=u,typeof u=="function")U_(u)&&(se=1);else if(typeof u=="string")se=bP(u,g,zt.current)?26:u==="html"||u==="head"||u==="body"?27:5;else e:switch(u){case l:return Sf(g.children,N,O,f);case c:se=8,N|=24;break;case h:return u=Ll(12,g,f,N|2),u.elementType=h,u.lanes=O,u;case b:return u=Ll(13,g,f,N),u.elementType=b,u.lanes=O,u;case S:return u=Ll(19,g,f,N),u.elementType=S,u.lanes=O,u;case M:return CC(g,N,O,f);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case p:case y:se=10;break e;case m:se=9;break e;case v:se=11;break e;case E:se=14;break e;case I:se=16,w=null;break e}se=29,g=Error(s(130,u===null?"null":typeof u,"")),w=null}return f=Ll(se,g,f,N),f.elementType=u,f.type=w,f.lanes=O,f}function Sf(u,f,g,w){return u=Ll(7,u,w,f),u.lanes=g,u}function CC(u,f,g,w){u=Ll(22,u,w,f),u.elementType=M,u.lanes=g;var N={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var O=N._current;if(O===null)throw Error(s(456));if((N._pendingVisibility&2)===0){var se=vi(O,2);se!==null&&(N._pendingVisibility|=2,yo(se,O,2))}},attach:function(){var O=N._current;if(O===null)throw Error(s(456));if((N._pendingVisibility&2)!==0){var se=vi(O,2);se!==null&&(N._pendingVisibility&=-3,yo(se,O,2))}}};return u.stateNode=N,u}function F_(u,f,g){return u=Ll(6,u,null,f),u.lanes=g,u}function V_(u,f,g){return f=Ll(4,u.children!==null?u.children:[],u.key,f),f.lanes=g,f.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},f}function Yu(u){u.flags|=4}function kC(u,f){if(f.type!=="stylesheet"||(f.state.loading&4)!==0)u.flags&=-16777217;else if(u.flags|=16777216,!lk(f)){if(f=mo.current,f!==null&&((hr&4194176)===hr?Ia!==null:(hr&62914560)!==hr&&(hr&536870912)===0||f!==Ia))throw pc=_p,wp;u.flags|=8192}}function fb(u,f){f!==null&&(u.flags|=4),u.flags&16384&&(f=u.tag!==22?zs():536870912,u.lanes|=f,rg|=f)}function wy(u,f){if(!Bs)switch(u.tailMode){case"hidden":f=u.tail;for(var g=null;f!==null;)f.alternate!==null&&(g=f),f=f.sibling;g===null?u.tail=null:g.sibling=null;break;case"collapsed":g=u.tail;for(var w=null;g!==null;)g.alternate!==null&&(w=g),g=g.sibling;w===null?f||u.tail===null?u.tail=null:u.tail.sibling=null:w.sibling=null}}function Ni(u){var f=u.alternate!==null&&u.alternate.child===u.child,g=0,w=0;if(f)for(var N=u.child;N!==null;)g|=N.lanes|N.childLanes,w|=N.subtreeFlags&31457280,w|=N.flags&31457280,N.return=u,N=N.sibling;else for(N=u.child;N!==null;)g|=N.lanes|N.childLanes,w|=N.subtreeFlags,w|=N.flags,N.return=u,N=N.sibling;return u.subtreeFlags|=w,u.childLanes=g,f}function QM(u,f,g){var w=f.pendingProps;switch(cf(f),f.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ni(f),null;case 1:return Ni(f),null;case 3:return g=f.stateNode,w=null,u!==null&&(w=u.memoizedState.cache),f.memoizedState.cache!==w&&(f.flags|=2048),Jd(x),Ie(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(u===null||u.child===null)&&(Wc(f)?Yu(f):u===null||u.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,Ca!==null&&(X_(Ca),Ca=null))),Ni(f),null;case 26:return g=f.memoizedState,u===null?(Yu(f),g!==null?(Ni(f),kC(f,g)):(Ni(f),f.flags&=-16777217)):g?g!==u.memoizedState?(Yu(f),Ni(f),kC(f,g)):(Ni(f),f.flags&=-16777217):(u.memoizedProps!==w&&Yu(f),Ni(f),f.flags&=-16777217),null;case 27:he(f),g=Zt.current;var N=f.type;if(u!==null&&f.stateNode!=null)u.memoizedProps!==w&&Yu(f);else{if(!w){if(f.stateNode===null)throw Error(s(166));return Ni(f),null}u=zt.current,Wc(f)?bp(f):(u=QC(N,w,g),f.stateNode=u,Yu(f))}return Ni(f),null;case 5:if(he(f),g=f.type,u!==null&&f.stateNode!=null)u.memoizedProps!==w&&Yu(f);else{if(!w){if(f.stateNode===null)throw Error(s(166));return Ni(f),null}if(u=zt.current,Wc(f))bp(f);else{switch(N=ru(Zt.current),u){case 1:u=N.createElementNS("http://www.w3.org/2000/svg",g);break;case 2:u=N.createElementNS("http://www.w3.org/1998/Math/MathML",g);break;default:switch(g){case"svg":u=N.createElementNS("http://www.w3.org/2000/svg",g);break;case"math":u=N.createElementNS("http://www.w3.org/1998/Math/MathML",g);break;case"script":u=N.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof w.is=="string"?N.createElement("select",{is:w.is}):N.createElement("select"),w.multiple?u.multiple=!0:w.size&&(u.size=w.size);break;default:u=typeof w.is=="string"?N.createElement(g,{is:w.is}):N.createElement(g)}}u[Ft]=f,u[sn]=w;e:for(N=f.child;N!==null;){if(N.tag===5||N.tag===6)u.appendChild(N.stateNode);else if(N.tag!==4&&N.tag!==27&&N.child!==null){N.child.return=N,N=N.child;continue}if(N===f)break e;for(;N.sibling===null;){if(N.return===null||N.return===f)break e;N=N.return}N.sibling.return=N.return,N=N.sibling}f.stateNode=u;e:switch(Ja(u,g,w),g){case"button":case"input":case"select":case"textarea":u=!!w.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Yu(f)}}return Ni(f),f.flags&=-16777217,null;case 6:if(u&&f.stateNode!=null)u.memoizedProps!==w&&Yu(f);else{if(typeof w!="string"&&f.stateNode===null)throw Error(s(166));if(u=Zt.current,Wc(f)){if(u=f.stateNode,g=f.memoizedProps,w=null,N=Fr,N!==null)switch(N.tag){case 27:case 5:w=N.memoizedProps}u[Ft]=f,u=!!(u.nodeValue===g||w!==null&&w.suppressHydrationWarning===!0||r2(u.nodeValue,g)),u||qc(f)}else u=ru(u).createTextNode(w),u[Ft]=f,f.stateNode=u}return Ni(f),null;case 13:if(w=f.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(N=Wc(f),w!==null&&w.dehydrated!==null){if(u===null){if(!N)throw Error(s(318));if(N=f.memoizedState,N=N!==null?N.dehydrated:null,!N)throw Error(s(317));N[Ft]=f}else Fd(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;Ni(f),N=!1}else Ca!==null&&(X_(Ca),Ca=null),N=!0;if(!N)return f.flags&256?(Nl(f),f):(Nl(f),null)}if(Nl(f),(f.flags&128)!==0)return f.lanes=g,f;if(g=w!==null,u=u!==null&&u.memoizedState!==null,g){w=f.child,N=null,w.alternate!==null&&w.alternate.memoizedState!==null&&w.alternate.memoizedState.cachePool!==null&&(N=w.alternate.memoizedState.cachePool.pool);var O=null;w.memoizedState!==null&&w.memoizedState.cachePool!==null&&(O=w.memoizedState.cachePool.pool),O!==N&&(w.flags|=2048)}return g!==u&&g&&(f.child.flags|=8192),fb(f,f.updateQueue),Ni(f),null;case 4:return Ie(),u===null&&kf(f.stateNode.containerInfo),Ni(f),null;case 10:return Jd(f.type),Ni(f),null;case 19:if(Nt(bi),N=f.memoizedState,N===null)return Ni(f),null;if(w=(f.flags&128)!==0,O=N.rendering,O===null)if(w)wy(N,!1);else{if(_i!==0||u!==null&&(u.flags&128)!==0)for(u=f.child;u!==null;){if(O=zu(u),O!==null){for(f.flags|=128,wy(N,!1),u=O.updateQueue,f.updateQueue=u,fb(f,u),f.subtreeFlags=0,u=g,g=f.child;g!==null;)by(g,u),g=g.sibling;return wt(bi,bi.current&1|2),f.child}u=u.sibling}N.tail!==null&&Mt()>pb&&(f.flags|=128,w=!0,wy(N,!1),f.lanes=4194304)}else{if(!w)if(u=zu(O),u!==null){if(f.flags|=128,w=!0,u=u.updateQueue,f.updateQueue=u,fb(f,u),wy(N,!0),N.tail===null&&N.tailMode==="hidden"&&!O.alternate&&!Bs)return Ni(f),null}else 2*Mt()-N.renderingStartTime>pb&&g!==536870912&&(f.flags|=128,w=!0,wy(N,!1),f.lanes=4194304);N.isBackwards?(O.sibling=f.child,f.child=O):(u=N.last,u!==null?u.sibling=O:f.child=O,N.last=O)}return N.tail!==null?(f=N.tail,N.rendering=f,N.tail=f.sibling,N.renderingStartTime=Mt(),f.sibling=null,u=bi.current,wt(bi,w?u&1|2:u&1),f):(Ni(f),null);case 22:case 23:return Nl(f),Km(),w=f.memoizedState!==null,u!==null?u.memoizedState!==null!==w&&(f.flags|=8192):w&&(f.flags|=8192),w?(g&536870912)!==0&&(f.flags&128)===0&&(Ni(f),f.subtreeFlags&6&&(f.flags|=8192)):Ni(f),g=f.updateQueue,g!==null&&fb(f,g.retryQueue),g=null,u!==null&&u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),w=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(w=f.memoizedState.cachePool.pool),w!==g&&(f.flags|=2048),u!==null&&Nt(Be),null;case 24:return g=null,u!==null&&(g=u.memoizedState.cache),f.memoizedState.cache!==g&&(f.flags|=2048),Jd(x),Ni(f),null;case 25:return null}throw Error(s(156,f.tag))}function _y(u,f){switch(cf(f),f.tag){case 1:return u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 3:return Jd(x),Ie(),u=f.flags,(u&65536)!==0&&(u&128)===0?(f.flags=u&-65537|128,f):null;case 26:case 27:case 5:return he(f),null;case 13:if(Nl(f),u=f.memoizedState,u!==null&&u.dehydrated!==null){if(f.alternate===null)throw Error(s(340));Fd()}return u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 19:return Nt(bi),null;case 4:return Ie(),null;case 10:return Jd(f.type),null;case 22:case 23:return Nl(f),Km(),u!==null&&Nt(Be),u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 24:return Jd(x),null;case 25:return null;default:return null}}function IC(u,f){switch(cf(f),f.tag){case 3:Jd(x),Ie();break;case 26:case 27:case 5:he(f);break;case 4:Ie();break;case 13:Nl(f);break;case 19:Nt(bi);break;case 10:Jd(f.type);break;case 22:case 23:Nl(f),Km(),u!==null&&Nt(Be);break;case 24:Jd(x)}}var NC={getCacheForType:function(u){var f=go(x),g=f.data.get(u);return g===void 0&&(g=u(),f.data.set(u,g)),g}},ZM=typeof WeakMap=="function"?WeakMap:Map,Ri=0,Jr=null,Zs=null,hr=0,si=0,jl=null,rh=!1,sg=!1,z_=!1,ih=0,_i=0,Ef=0,Op=0,G_=0,Cc=0,rg=0,Lp=null,tu=null,H_=!1,jp=0,pb=1/0,mb=null,Tf=null,gb=!1,Af=null,Sy=0,q_=0,W_=null,ig=0,K_=null;function Bl(){if((Ri&2)!==0&&hr!==0)return hr&-hr;if(B.T!==null){var u=Q;return u!==0?u:wb()}return Qt()}function RC(){Cc===0&&(Cc=(hr&536870912)===0||Bs?ur():536870912);var u=mo.current;return u!==null&&(u.flags|=32),Cc}function yo(u,f,g){(u===Jr&&si===2||u.cancelPendingCommit!==null)&&(ag(u,0),ah(u,hr,Cc,!1)),ps(u,g),((Ri&2)===0||u!==Jr)&&(u===Jr&&((Ri&2)===0&&(Op|=g),_i===4&&ah(u,hr,Cc,!1)),nu(u))}function Y_(u,f,g){if((Ri&6)!==0)throw Error(s(327));var w=!g&&(f&60)===0&&(f&u.expiredLanes)===0||ns(u,f),N=w?nP(u,f):Z_(u,f,!0),O=w;do{if(N===0){sg&&!w&&ah(u,f,0,!1);break}else if(N===6)ah(u,f,0,!rh);else{if(g=u.current.alternate,O&&!eP(g)){N=Z_(u,f,!1),O=!1;continue}if(N===2){if(O=f,u.errorRecoveryDisabledLanes&O)var se=0;else se=u.pendingLanes&-536870913,se=se!==0?se:se&536870912?536870912:0;if(se!==0){f=se;e:{var fe=u;N=Lp;var Ce=fe.current.memoizedState.isDehydrated;if(Ce&&(ag(fe,se).flags|=256),se=Z_(fe,se,!1),se!==2){if(z_&&!Ce){fe.errorRecoveryDisabledLanes|=O,Op|=O,N=4;break e}O=tu,tu=N,O!==null&&X_(O)}N=se}if(O=!1,N!==2)continue}}if(N===1){ag(u,0),ah(u,f,0,!0);break}e:{switch(w=u,N){case 0:case 1:throw Error(s(345));case 4:if((f&4194176)===f){ah(w,f,Cc,!rh);break e}break;case 2:tu=null;break;case 3:case 5:break;default:throw Error(s(329))}if(w.finishedWork=g,w.finishedLanes=f,(f&62914560)===f&&(O=jp+300-Mt(),10<O)){if(ah(w,f,Cc,!rh),ln(w,0)!==0)break e;w.timeoutHandle=KC(MC.bind(null,w,g,tu,mb,H_,f,Cc,Op,rg,rh,2,-0,0),O);break e}MC(w,g,tu,mb,H_,f,Cc,Op,rg,rh,0,-0,0)}}break}while(!0);nu(u)}function X_(u){tu===null?tu=u:tu.push.apply(tu,u)}function MC(u,f,g,w,N,O,se,fe,Ce,Ge,At,Pt,it){var Et=f.subtreeFlags;if((Et&8192||(Et&16785408)===16785408)&&(Ny={stylesheets:null,count:0,unsuspend:wP},B_(f),f=p2(),f!==null)){u.cancelPendingCommit=f(LC.bind(null,u,g,w,N,se,fe,Ce,1,Pt,it)),ah(u,O,se,!Ge);return}LC(u,g,w,N,se,fe,Ce,At,Pt,it)}
vendor: 7,765 bytes, line 48
48function eP(u){for(var f=u;;){var g=f.tag;if((g===0||g===11||g===15)&&f.flags&16384&&(g=f.updateQueue,g!==null&&(g=g.stores,g!==null)))for(var w=0;w<g.length;w++){var N=g[w],O=N.getSnapshot;N=N.value;try{if(!oa(O(),N))return!1}catch{return!1}}if(g=f.child,f.subtreeFlags&16384&&g!==null)g.return=f,f=g;else{if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return!0;f=f.return}f.sibling.return=f.return,f=f.sibling}}return!0}function ah(u,f,g,w){f&=~G_,f&=~Op,u.suspendedLanes|=f,u.pingedLanes&=~f,w&&(u.warmLanes|=f),w=u.expirationTimes;for(var N=f;0<N;){var O=31-Lt(N),se=1<<O;w[O]=-1,N&=~se}g!==0&&Me(u,g,f)}function yb(){return(Ri&6)===0?(Ay(0),!1):!0}function J_(){if(Zs!==null){if(si===0)var u=Zs.return;else u=Zs,Xd=Pp=null,xc(u),kl=null,mc=0,u=Zs;for(;u!==null;)IC(u.alternate,u),u=u.return;Zs=null}}function ag(u,f){u.finishedWork=null,u.finishedLanes=0;var g=u.timeoutHandle;g!==-1&&(u.timeoutHandle=-1,fP(g)),g=u.cancelPendingCommit,g!==null&&(u.cancelPendingCommit=null,g()),J_(),Jr=u,Zs=g=_f(u.current,null),hr=f,si=0,jl=null,rh=!1,sg=ns(u,f),z_=!1,rg=Cc=G_=Op=Ef=_i=0,tu=Lp=null,H_=!1,(f&8)!==0&&(f|=f&32);var w=u.entangledLanes;if(w!==0)for(u=u.entanglements,w&=f;0<w;){var N=31-Lt(w),O=1<<N;f|=u[N],w&=~O}return ih=f,Uu(),g}function PC(u,f){Bt=null,B.H=Hu,f===zd?(f=df(),si=3):f===wp?(f=df(),si=4):si=f===b_?8:f!==null&&typeof f=="object"&&typeof f.then=="function"?6:1,jl=f,Zs===null&&(_i=1,cy(u,Ka(f,u.current)))}function $C(){var u=B.H;return B.H=Hu,u===null?Hu:u}function Xu(){var u=B.A;return B.A=NC,u}function Q_(){_i=4,rh||(hr&4194176)!==hr&&mo.current!==null||(sg=!0),(Ef&134217727)===0&&(Op&134217727)===0||Jr===null||ah(Jr,hr,Cc,!1)}function Z_(u,f,g){var w=Ri;Ri|=2;var N=$C(),O=Xu();(Jr!==u||hr!==f)&&(mb=null,ag(u,f)),f=!1;var se=_i;e:do try{if(si!==0&&Zs!==null){var fe=Zs,Ce=jl;switch(si){case 8:J_(),se=6;break e;case 3:case 2:case 6:mo.current===null&&(f=!0);var Ge=si;if(si=0,jl=null,Bp(u,fe,Ce,Ge),g&&sg){se=0;break e}break;default:Ge=si,si=0,jl=null,Bp(u,fe,Ce,Ge)}}tP(),se=_i;break}catch(At){PC(u,At)}while(!0);return f&&u.shellSuspendCounter++,Xd=Pp=null,Ri=w,B.H=N,B.A=O,Zs===null&&(Jr=null,hr=0,Uu()),se}function tP(){for(;Zs!==null;)DC(Zs)}function nP(u,f){var g=Ri;Ri|=2;var w=$C(),N=Xu();Jr!==u||hr!==f?(mb=null,pb=Mt()+500,ag(u,f)):sg=ns(u,f);e:do try{if(si!==0&&Zs!==null){f=Zs;var O=jl;t:switch(si){case 1:si=0,jl=null,Bp(u,f,O,1);break;case 2:if(po(O)){si=0,jl=null,OC(f);break}f=function(){si===2&&Jr===u&&(si=7),nu(u)},O.then(f,f);break e;case 3:si=7;break e;case 4:si=5;break e;case 7:po(O)?(si=0,jl=null,OC(f)):(si=0,jl=null,Bp(u,f,O,7));break;case 5:var se=null;switch(Zs.tag){case 26:se=Zs.memoizedState;case 5:case 27:var fe=Zs;if(!se||lk(se)){si=0,jl=null;var Ce=fe.sibling;if(Ce!==null)Zs=Ce;else{var Ge=fe.return;Ge!==null?(Zs=Ge,xb(Ge)):Zs=null}break t}}si=0,jl=null,Bp(u,f,O,5);break;case 6:si=0,jl=null,Bp(u,f,O,6);break;case 8:J_(),_i=6;break e;default:throw Error(s(462))}}sP();break}catch(At){PC(u,At)}while(!0);return Xd=Pp=null,B.H=w,B.A=N,Ri=g,Zs!==null?0:(Jr=null,hr=0,Uu(),_i)}function sP(){for(;Zs!==null&&!He();)DC(Zs)}function DC(u){var f=lC(u.alternate,u,ih);u.memoizedProps=u.pendingProps,f===null?xb(u):Zs=f}function OC(u){var f=u,g=f.alternate;switch(f.tag){case 15:case 0:f=tb(g,f,f.pendingProps,f.type,void 0,hr);break;case 11:f=tb(g,f,f.pendingProps,f.type.render,f.ref,hr);break;case 5:xc(f);default:IC(g,f),f=Zs=by(f,ih),f=lC(g,f,ih)}u.memoizedProps=u.pendingProps,f===null?xb(u):Zs=f}function Bp(u,f,g,w){Xd=Pp=null,xc(f),kl=null,mc=0;var N=f.return;try{if(eC(u,N,f,g,hr)){_i=1,cy(u,Ka(g,u.current)),Zs=null;return}}catch(O){if(N!==null)throw Zs=N,O;_i=1,cy(u,Ka(g,u.current)),Zs=null;return}f.flags&32768?(Bs||w===1?u=!0:sg||(hr&536870912)!==0?u=!1:(rh=u=!0,(w===2||w===3||w===6)&&(w=mo.current,w!==null&&w.tag===13&&(w.flags|=16384))),vb(f,u)):xb(f)}function xb(u){var f=u;do{if((f.flags&32768)!==0){vb(f,rh);return}u=f.return;var g=QM(f.alternate,f,ih);if(g!==null){Zs=g;return}if(f=f.sibling,f!==null){Zs=f;return}Zs=f=u}while(f!==null);_i===0&&(_i=5)}function vb(u,f){do{var g=_y(u.alternate,u);if(g!==null){g.flags&=32767,Zs=g;return}if(g=u.return,g!==null&&(g.flags|=32768,g.subtreeFlags=0,g.deletions=null),!f&&(u=u.sibling,u!==null)){Zs=u;return}Zs=u=g}while(u!==null);_i=6,Zs=null}function LC(u,f,g,w,N,O,se,fe,Ce,Ge){var At=B.T,Pt=Se.p;try{Se.p=2,B.T=null,rP(u,f,g,w,Pt,N,O,se,fe,Ce,Ge)}finally{B.T=At,Se.p=Pt}}function rP(u,f,g,w,N,O,se,fe){do Up();while(Af!==null);if((Ri&6)!==0)throw Error(s(327));var Ce=u.finishedWork;if(w=u.finishedLanes,Ce===null)return null;if(u.finishedWork=null,u.finishedLanes=0,Ce===u.current)throw Error(s(177));u.callbackNode=null,u.callbackPriority=0,u.cancelPendingCommit=null;var Ge=Ce.lanes|Ce.childLanes;if(Ge|=Bu,ms(u,w,Ge,O,se,fe),u===Jr&&(Zs=Jr=null,hr=0),(Ce.subtreeFlags&10256)===0&&(Ce.flags&10256)===0||gb||(gb=!0,q_=Ge,W_=g,jC(Yt,function(){return Up(),null})),g=(Ce.flags&15990)!==0,(Ce.subtreeFlags&15990)!==0||g?(g=B.T,B.T=null,O=Se.p,Se.p=2,se=Ri,Ri|=4,JM(u,Ce),O_(Ce,u),Ta(Ju,u.containerInfo),wg=!!pg,Ju=pg=null,u.current=Ce,xC(u,Ce.alternate,Ce),ft(),Ri=se,Se.p=O,B.T=g):u.current=Ce,gb?(gb=!1,Af=u,Sy=w):e2(u,Ge),Ge=u.pendingLanes,Ge===0&&(Tf=null),Dt(Ce.stateNode),nu(u),f!==null)for(N=u.onRecoverableError,Ce=0;Ce<f.length;Ce++)Ge=f[Ce],N(Ge.value,{componentStack:Ge.stack});return(Sy&3)!==0&&Up(),Ge=u.pendingLanes,(w&4194218)!==0&&(Ge&42)!==0?u===K_?ig++:(ig=0,K_=u):ig=0,Ay(0),null}function e2(u,f){(u.pooledCacheLanes&=f)===0&&(f=u.pooledCache,f!=null&&(u.pooledCache=null,$(f)))}function Up(){if(Af!==null){var u=Af,f=q_;q_=0;var g=jt(Sy),w=B.T,N=Se.p;try{if(Se.p=32>g?32:g,B.T=null,Af===null)var O=!1;else{g=W_,W_=null;var se=Af,fe=Sy;if(Af=null,Sy=0,(Ri&6)!==0)throw Error(s(331));var Ce=Ri;if(Ri|=4,TC(se.current),j_(se,se.current,fe,g),Ri=Ce,Ay(0,!1),ht&&typeof ht.onPostCommitFiberRoot=="function")try{ht.onPostCommitFiberRoot(bt,se)}catch{}O=!0}return O}finally{Se.p=N,B.T=w,e2(u,f)}}return!1}function Ey(u,f,g){f=Ka(g,f),f=uy(u.stateNode,f,2),u=Zd(u,f,2),u!==null&&(ps(u,2),nu(u))}function zr(u,f,g){if(u.tag===3)Ey(u,u,g);else for(;f!==null;){if(f.tag===3){Ey(f,u,g);break}else if(f.tag===1){var w=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(Tf===null||!Tf.has(w))){u=Ka(g,u),g=v_(2),w=Zd(f,g,2),w!==null&&(eb(g,w,f,u),ps(w,2),nu(w));break}}f=f.return}}function Ty(u,f,g){var w=u.pingCache;if(w===null){w=u.pingCache=new ZM;var N=new Set;w.set(f,N)}else N=w.get(f),N===void 0&&(N=new Set,w.set(f,N));N.has(g)||(z_=!0,N.add(g),u=iP.bind(null,u,f,g),f.then(u,u))}function iP(u,f,g){var w=u.pingCache;w!==null&&w.delete(f),u.pingedLanes|=u.suspendedLanes&g,u.warmLanes&=~g,Jr===u&&(hr&g)===g&&(_i===4||_i===3&&(hr&62914560)===hr&&300>Mt()-jp?(Ri&2)===0&&ag(u,0):G_|=g,rg===hr&&(rg=0)),nu(u)}function t2(u,f){f===0&&(f=zs()),u=vi(u,f),u!==null&&(ps(u,f),nu(u))}function aP(u){var f=u.memoizedState,g=0;f!==null&&(g=f.retryLane),t2(u,g)}function oP(u,f){var g=0;switch(u.tag){case 13:var w=u.stateNode,N=u.memoizedState;N!==null&&(g=N.retryLane);break;case 19:w=u.stateNode;break;case 22:w=u.stateNode._retryCache;break;default:throw Error(s(314))}w!==null&&w.delete(f),t2(u,g)}function jC(u,f){return et(u,f)}var og=null,oh=null,n2=!1,bb=!1,lg=!1,Fp=0;function nu(u){u!==oh&&u.next===null&&(oh===null?og=oh=u:oh=oh.next=u),bb=!0,n2||(n2=!0,lP(BC))}function Ay(u,f){if(!lg&&bb){lg=!0;do for(var g=!1,w=og;w!==null;){if(u!==0){var N=w.pendingLanes;if(N===0)var O=0;else{var se=w.suspendedLanes,fe=w.pingedLanes;O=(1<<31-Lt(42|u)+1)-1,O&=N&~(se&~fe),O=O&201326677?O&201326677|1:O?O|2:0}O!==0&&(g=!0,VC(w,O))}else O=hr,O=ln(w,w===Jr?O:0),(O&3)===0||ns(w,O)||(g=!0,VC(w,O));w=w.next}while(g);lg=!1}}function BC(){bb=n2=!1;var u=0;
vendor: 19,241 bytes, lines 48-49
48Fp!==0&&(hP()&&(u=Fp),Fp=0);for(var f=Mt(),g=null,w=og;w!==null;){var N=w.next,O=UC(w,f);O===0?(w.next=null,g===null?og=N:g.next=N,N===null&&(oh=g)):(g=w,(u!==0||(O&3)!==0)&&(bb=!0)),w=N}Ay(u)}function UC(u,f){for(var g=u.suspendedLanes,w=u.pingedLanes,N=u.expirationTimes,O=u.pendingLanes&-62914561;0<O;){var se=31-Lt(O),fe=1<<se,Ce=N[se];Ce===-1?((fe&g)===0||(fe&w)!==0)&&(N[se]=Js(fe,f)):Ce<=f&&(u.expiredLanes|=fe),O&=~fe}if(f=Jr,g=hr,g=ln(u,u===f?g:0),w=u.callbackNode,g===0||u===f&&si===2||u.cancelPendingCommit!==null)return w!==null&&w!==null&&nt(w),u.callbackNode=null,u.callbackPriority=0;if((g&3)===0||ns(u,g)){if(f=g&-g,f===u.callbackPriority)return f;switch(w!==null&&nt(w),jt(g)){case 2:case 8:g=hn;break;case 32:g=Yt;break;case 268435456:g=tn;break;default:g=Yt}return w=FC.bind(null,u),g=et(g,w),u.callbackPriority=f,u.callbackNode=g,f}return w!==null&&w!==null&&nt(w),u.callbackPriority=2,u.callbackNode=null,2}function FC(u,f){var g=u.callbackNode;if(Up()&&u.callbackNode!==g)return null;var w=hr;return w=ln(u,u===Jr?w:0),w===0?null:(Y_(u,w,f),UC(u,Mt()),u.callbackNode!=null&&u.callbackNode===g?FC.bind(null,u):null)}function VC(u,f){if(Up())return null;Y_(u,f,!0)}function lP(u){XC(function(){(Ri&6)!==0?et(Oe,u):u()})}function wb(){return Fp===0&&(Fp=ur()),Fp}function _b(u){return u==null||typeof u=="symbol"||typeof u=="boolean"?null:typeof u=="function"?u:_a(""+u)}function zC(u,f){var g=f.ownerDocument.createElement("input");return g.name=f.name,g.value=f.value,u.id&&g.setAttribute("form",u.id),f.parentNode.insertBefore(g,f),u=new FormData(u),g.parentNode.removeChild(g),u}function GC(u,f,g,w,N){if(f==="submit"&&g&&g.stateNode===N){var O=_b((N[sn]||null).action),se=w.submitter;se&&(f=(f=se[sn]||null)?_b(f.formAction):se.getAttribute("formAction"),f!==null&&(O=f,se=null));var fe=new Pr("action","action",null,w,N);u.push({event:fe,listeners:[{instance:null,listener:function(){if(w.defaultPrevented){if(Fp!==0){var Ce=se?zC(N,se):new FormData(N);kp(g,{pending:!0,data:Ce,method:N.method,action:O},null,Ce)}}else typeof O=="function"&&(fe.preventDefault(),Ce=se?zC(N,se):new FormData(N),kp(g,{pending:!0,data:Ce,method:N.method,action:O},O,Ce))},currentTarget:N}]})}}for(var Cf=0;Cf<xi.length;Cf++){var cg=xi[Cf],ug=cg.toLowerCase(),cP=cg[0].toUpperCase()+cg.slice(1);ma(ug,"on"+cP)}ma(Zo,"onAnimationEnd"),ma(ju,"onAnimationIteration"),ma(tf,"onAnimationStart"),ma("dblclick","onDoubleClick"),ma("focusin","onFocus"),ma("focusout","onBlur"),ma(nf,"onTransitionRun"),ma(Gc,"onTransitionStart"),ma(qm,"onTransitionCancel"),ma(sf,"onTransitionEnd"),$n("onMouseEnter",["mouseout","mouseover"]),$n("onMouseLeave",["mouseout","mouseover"]),$n("onPointerEnter",["pointerout","pointerover"]),$n("onPointerLeave",["pointerout","pointerover"]),ar("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ar("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ar("onBeforeInput",["compositionend","keypress","textInput","paste"]),ar("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ar("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ar("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var dg="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),HC=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(dg));function hg(u,f){f=(f&4)!==0;for(var g=0;g<u.length;g++){var w=u[g],N=w.event;w=w.listeners;e:{var O=void 0;if(f)for(var se=w.length-1;0<=se;se--){var fe=w[se],Ce=fe.instance,Ge=fe.currentTarget;if(fe=fe.listener,Ce!==O&&N.isPropagationStopped())break e;O=fe,N.currentTarget=Ge;try{O(N)}catch(At){Qv(At)}N.currentTarget=null,O=Ce}else for(se=0;se<w.length;se++){if(fe=w[se],Ce=fe.instance,Ge=fe.currentTarget,fe=fe.listener,Ce!==O&&N.isPropagationStopped())break e;O=fe,N.currentTarget=Ge;try{O(N)}catch(At){Qv(At)}N.currentTarget=null,O=Ce}}}}function tr(u,f){var g=f[bs];g===void 0&&(g=f[bs]=new Set);var w=u+"__bubble";g.has(w)||(su(f,u,2,!1),g.add(w))}function Ul(u,f,g){var w=0;f&&(w|=4),su(g,u,w,f)}var xo="_reactListening"+Math.random().toString(36).slice(2);function kf(u){if(!u[xo]){u[xo]=!0,ir.forEach(function(g){g!=="selectionchange"&&(HC.has(g)||Ul(g,!1,u),Ul(g,!0,u))});var f=u.nodeType===9?u:u.ownerDocument;f===null||f[xo]||(f[xo]=!0,Ul("selectionchange",!1,f))}}function su(u,f,g,w){switch(Sg(f)){case 2:var N=TP;break;case 8:N=AP;break;default:N=y2}g=N.bind(null,f,g,u),N=void 0,!Ye||f!=="touchstart"&&f!=="touchmove"&&f!=="wheel"||(N=!0),w?N!==void 0?u.addEventListener(f,g,{capture:!0,passive:N}):u.addEventListener(f,g,!0):N!==void 0?u.addEventListener(f,g,{passive:N}):u.addEventListener(f,g,!1)}function lh(u,f,g,w,N){var O=w;if((f&1)===0&&(f&2)===0&&w!==null)e:for(;;){if(w===null)return;var se=w.tag;if(se===3||se===4){var fe=w.stateNode.containerInfo;if(fe===N||fe.nodeType===8&&fe.parentNode===N)break;if(se===4)for(se=w.return;se!==null;){var Ce=se.tag;if((Ce===3||Ce===4)&&(Ce=se.stateNode.containerInfo,Ce===N||Ce.nodeType===8&&Ce.parentNode===N))return;se=se.return}for(;fe!==null;){if(se=rr(fe),se===null)return;if(Ce=se.tag,Ce===5||Ce===6||Ce===26||Ce===27){w=O=se;continue e}fe=fe.parentNode}}w=w.return}za(function(){var Ge=O,At=Ls(g),Pt=[];e:{var it=rf.get(u);if(it!==void 0){var Et=Pr,jn=u;switch(u){case"keypress":if(Ds(g)===0)break e;case"keydown":case"keyup":Et=ia;break;case"focusin":jn="focus",Et=ic;break;case"focusout":jn="blur",Et=ic;break;case"beforeblur":case"afterblur":Et=ic;break;case"click":if(g.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Et=Bi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Et=Pu;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Et=Io;break;case Zo:case ju:case tf:Et=ci;break;case sf:Et=W;break;case"scroll":case"scrollend":Et=Yi;break;case"wheel":Et=ye;break;case"copy":case"cut":case"paste":Et=gn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Et=ac;break;case"toggle":case"beforetoggle":Et=rt}var Cs=(f&4)!==0,zi=!Cs&&(u==="scroll"||u==="scrollend"),Je=Cs?it!==null?it+"Capture":null:it;Cs=[];for(var Ve=Ge,st;Ve!==null;){var Rt=Ve;if(st=Rt.stateNode,Rt=Rt.tag,Rt!==5&&Rt!==26&&Rt!==27||st===null||Je===null||(Rt=Ai(Ve,Je),Rt!=null&&Cs.push(fg(Ve,Rt,st))),zi)break;Ve=Ve.return}0<Cs.length&&(it=new Et(it,jn,null,g,At),Pt.push({event:it,listeners:Cs}))}}if((f&7)===0){e:{if(it=u==="mouseover"||u==="pointerover",Et=u==="mouseout"||u==="pointerout",it&&g!==Va&&(jn=g.relatedTarget||g.fromElement)&&(rr(jn)||jn[rn]))break e;if((Et||it)&&(it=At.window===At?At:(it=At.ownerDocument)?it.defaultView||it.parentWindow:window,Et?(jn=g.relatedTarget||g.toElement,Et=Ge,jn=jn?rr(jn):null,jn!==null&&(zi=Le(jn),Cs=jn.tag,jn!==zi||Cs!==5&&Cs!==27&&Cs!==6)&&(jn=null)):(Et=null,jn=Ge),Et!==jn)){if(Cs=Bi,Rt="onMouseLeave",Je="onMouseEnter",Ve="mouse",(u==="pointerout"||u==="pointerover")&&(Cs=ac,Rt="onPointerLeave",Je="onPointerEnter",Ve="pointer"),zi=Et==null?it:$s(Et),st=jn==null?it:$s(jn),it=new Cs(Rt,Ve+"leave",Et,g,At),it.target=zi,it.relatedTarget=st,Rt=null,rr(At)===Ge&&(Cs=new Cs(Je,Ve+"enter",jn,g,At),Cs.target=st,Cs.relatedTarget=zi,Rt=Cs),zi=Rt,Et&&jn)t:{for(Cs=Et,Je=jn,Ve=0,st=Cs;st;st=ch(st))Ve++;for(st=0,Rt=Je;Rt;Rt=ch(Rt))st++;for(;0<Ve-st;)Cs=ch(Cs),Ve--;for(;0<st-Ve;)Je=ch(Je),st--;for(;Ve--;){if(Cs===Je||Je!==null&&Cs===Je.alternate)break t;Cs=ch(Cs),Je=ch(Je)}Cs=null}else Cs=null;Et!==null&&qC(Pt,it,Et,Cs,!1),jn!==null&&zi!==null&&qC(Pt,zi,jn,Cs,!0)}}e:{if(it=Ge?$s(Ge):window,Et=it.nodeName&&it.nodeName.toLowerCase(),Et==="select"||Et==="input"&&it.type==="file")var bn=js;else if(Du(it))if(lc)bn=$d;else{bn=cc;var Ys=Pd}else Et=it.nodeName,!Et||Et.toLowerCase()!=="input"||it.type!=="checkbox"&&it.type!=="radio"?Ge&&ti(Ge.elementType)&&(bn=js):bn=fo;if(bn&&(bn=bn(u,Ge))){ho(Pt,bn,g,At);break e}Ys&&Ys(u,it,Ge),u==="focusout"&&Ge&&it.type==="number"&&Ge.memoizedProps.value!=null&&qn(it,"number",it.value)}switch(Ys=Ge?$s(Ge):window,u){case"focusin":(Du(Ys)||Ys.contentEditable==="true")&&(Ci=Ys,$r=Ge,Aa=null);break;case"focusout":Aa=$r=Ci=null;break;case"mousedown":uc=!0;break;case"contextmenu":case"mouseup":case"dragend":uc=!1,zc(Pt,g,At);break;case"selectionchange":if(hs)break;case"keydown":case"keyup":zc(Pt,g,At)}var Vn;if(Zn)e:{switch(u){case"compositionstart":var as="onCompositionStart";break e;case"compositionend":as="onCompositionEnd";break e;case"compositionupdate":as="onCompositionUpdate";break e}as=void 0}else pa?No(u,g)&&(as="onCompositionEnd"):u==="keydown"&&g.keyCode===229&&(as="onCompositionStart");as&&(wr&&g.locale!=="ko"&&(pa||as!=="onCompositionStart"?as==="onCompositionEnd"&&pa&&(Vn=Mr()):(ct=At,Kt="value"in ct?ct.value:ct.textContent,pa=!0)),Ys=Sb(Ge,as),0<Ys.length&&(as=new yi(as,u,null,g,At),Pt.push({event:as,listeners:Ys}),Vn?as.data=Vn:(Vn=fa(g),Vn!==null&&(as.data=Vn)))),(Vn=lr?$u(u,g):ef(u,g))&&(as=Sb(Ge,"onBeforeInput"),0<as.length&&(Ys=new yi("onBeforeInput","beforeinput",null,g,At),Pt.push({event:Ys,listeners:as}),Ys.data=Vn)),GC(Pt,u,Ge,g,At)}hg(Pt,f)})}function fg(u,f,g){return{instance:u,listener:f,currentTarget:g}}function Sb(u,f){for(var g=f+"Capture",w=[];u!==null;){var N=u,O=N.stateNode;N=N.tag,N!==5&&N!==26&&N!==27||O===null||(N=Ai(u,g),N!=null&&w.unshift(fg(u,N,O)),N=Ai(u,f),N!=null&&w.push(fg(u,N,O))),u=u.return}return w}function ch(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5&&u.tag!==27);return u||null}function qC(u,f,g,w,N){for(var O=f._reactName,se=[];g!==null&&g!==w;){var fe=g,Ce=fe.alternate,Ge=fe.stateNode;if(fe=fe.tag,Ce!==null&&Ce===w)break;fe!==5&&fe!==26&&fe!==27||Ge===null||(Ce=Ge,N?(Ge=Ai(g,O),Ge!=null&&se.unshift(fg(g,Ge,Ce))):N||(Ge=Ai(g,O),Ge!=null&&se.push(fg(g,Ge,Ce)))),g=g.return}se.length!==0&&u.push({event:f,listeners:se})}var uP=/\r\n?/g,WC=/\u0000|\uFFFD/g;function s2(u){return(typeof u=="string"?u:""+u).replace(uP,`
49`).replace(WC,"")}function r2(u,f){return f=s2(f),s2(u)===f}function Cy(){}function Gr(u,f,g,w,N,O){switch(g){case"children":typeof w=="string"?f==="body"||f==="textarea"&&w===""||Qn(u,w):(typeof w=="number"||typeof w=="bigint")&&f!=="body"&&Qn(u,""+w);break;case"className":ue(u,"class",w);break;case"tabIndex":ue(u,"tabindex",w);break;case"dir":case"role":case"viewBox":case"width":case"height":ue(u,g,w);break;case"style":Qs(u,w,O);break;case"data":if(f!=="object"){ue(u,"data",w);break}case"src":case"href":if(w===""&&(f!=="a"||g!=="href")){u.removeAttribute(g);break}if(w==null||typeof w=="function"||typeof w=="symbol"||typeof w=="boolean"){u.removeAttribute(g);break}w=_a(""+w),u.setAttribute(g,w);break;case"action":case"formAction":if(typeof w=="function"){u.setAttribute(g,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(g==="formAction"?(f!=="input"&&Gr(u,f,"name",N.name,N,null),Gr(u,f,"formEncType",N.formEncType,N,null),Gr(u,f,"formMethod",N.formMethod,N,null),Gr(u,f,"formTarget",N.formTarget,N,null)):(Gr(u,f,"encType",N.encType,N,null),Gr(u,f,"method",N.method,N,null),Gr(u,f,"target",N.target,N,null)));if(w==null||typeof w=="symbol"||typeof w=="boolean"){u.removeAttribute(g);break}w=_a(""+w),u.setAttribute(g,w);break;case"onClick":w!=null&&(u.onclick=Cy);break;case"onScroll":w!=null&&tr("scroll",u);break;case"onScrollEnd":w!=null&&tr("scrollend",u);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(s(61));if(g=w.__html,g!=null){if(N.children!=null)throw Error(s(60));u.innerHTML=g}}break;case"multiple":u.multiple=w&&typeof w!="function"&&typeof w!="symbol";break;case"muted":u.muted=w&&typeof w!="function"&&typeof w!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(w==null||typeof w=="function"||typeof w=="boolean"||typeof w=="symbol"){u.removeAttribute("xlink:href");break}g=_a(""+w),u.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",g);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":w!=null&&typeof w!="function"&&typeof w!="symbol"?u.setAttribute(g,""+w):u.removeAttribute(g);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":w&&typeof w!="function"&&typeof w!="symbol"?u.setAttribute(g,""):u.removeAttribute(g);break;case"capture":case"download":w===!0?u.setAttribute(g,""):w!==!1&&w!=null&&typeof w!="function"&&typeof w!="symbol"?u.setAttribute(g,w):u.removeAttribute(g);break;case"cols":case"rows":case"size":case"span":w!=null&&typeof w!="function"&&typeof w!="symbol"&&!isNaN(w)&&1<=w?u.setAttribute(g,w):u.removeAttribute(g);break;case"rowSpan":case"start":w==null||typeof w=="function"||typeof w=="symbol"||isNaN(w)?u.removeAttribute(g):u.setAttribute(g,w);break;case"popover":tr("beforetoggle",u),tr("toggle",u),or(u,"popover",w);break;case"xlinkActuate":ke(u,"http://www.w3.org/1999/xlink","xlink:actuate",w);break;case"xlinkArcrole":ke(u,"http://www.w3.org/1999/xlink","xlink:arcrole",w);break;case"xlinkRole":ke(u,"http://www.w3.org/1999/xlink","xlink:role",w);break;case"xlinkShow":ke(u,"http://www.w3.org/1999/xlink","xlink:show",w);break;case"xlinkTitle":ke(u,"http://www.w3.org/1999/xlink","xlink:title",w);break;case"xlinkType":ke(u,"http://www.w3.org/1999/xlink","xlink:type",w);break;case"xmlBase":ke(u,"http://www.w3.org/XML/1998/namespace","xml:base",w);break;case"xmlLang":ke(u,"http://www.w3.org/XML/1998/namespace","xml:lang",w);break;case"xmlSpace":ke(u,"http://www.w3.org/XML/1998/namespace","xml:space",w);break;case"is":or(u,"is",w);break;case"innerText":case"textContent":break;default:(!(2<g.length)||g[0]!=="o"&&g[0]!=="O"||g[1]!=="n"&&g[1]!=="N")&&(g=gi.get(g)||g,or(u,g,w))}}function Eb(u,f,g,w,N,O){switch(g){case"style":Qs(u,w,O);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(s(61));if(g=w.__html,g!=null){if(N.children!=null)throw Error(s(60));u.innerHTML=g}}break;case"children":typeof w=="string"?Qn(u,w):(typeof w=="number"||typeof w=="bigint")&&Qn(u,""+w);break;case"onScroll":w!=null&&tr("scroll",u);break;case"onScrollEnd":w!=null&&tr("scrollend",u);break;case"onClick":w!=null&&(u.onclick=Cy);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ot.hasOwnProperty(g))e:{if(g[0]==="o"&&g[1]==="n"&&(N=g.endsWith("Capture"),f=g.slice(2,N?g.length-7:void 0),O=u[sn]||null,O=O!=null?O[g]:null,typeof O=="function"&&u.removeEventListener(f,O,N),typeof w=="function")){typeof O!="function"&&O!==null&&(g in u?u[g]=null:u.hasAttribute(g)&&u.removeAttribute(g)),u.addEventListener(f,w,N);break e}g in u?u[g]=w:w===!0?u.setAttribute(g,""):or(u,g,w)}}}function Ja(u,f,g){switch(f){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":tr("error",u),tr("load",u);var w=!1,N=!1,O;for(O in g)if(g.hasOwnProperty(O)){var se=g[O];if(se!=null)switch(O){case"src":w=!0;break;case"srcSet":N=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,f));default:Gr(u,f,O,se,g,null)}}N&&Gr(u,f,"srcSet",g.srcSet,g,null),w&&Gr(u,f,"src",g.src,g,null);return;case"input":tr("invalid",u);var fe=O=se=N=null,Ce=null,Ge=null;for(w in g)if(g.hasOwnProperty(w)){var At=g[w];if(At!=null)switch(w){case"name":N=At;break;case"type":se=At;break;case"checked":Ce=At;break;case"defaultChecked":Ge=At;break;case"value":O=At;break;case"defaultValue":fe=At;break;case"children":case"dangerouslySetInnerHTML":if(At!=null)throw Error(s(137,f));break;default:Gr(u,f,w,At,g,null)}}Xt(u,O,fe,Ce,Ge,se,N,!1),Ne(u);return;case"select":tr("invalid",u),w=se=O=null;for(N in g)if(g.hasOwnProperty(N)&&(fe=g[N],fe!=null))switch(N){case"value":O=fe;break;case"defaultValue":se=fe;break;case"multiple":w=fe;default:Gr(u,f,N,fe,g,null)}f=O,g=se,u.multiple=!!w,f!=null?Xn(u,!!w,f,!1):g!=null&&Xn(u,!!w,g,!0);return;case"textarea":tr("invalid",u),O=N=w=null;for(se in g)if(g.hasOwnProperty(se)&&(fe=g[se],fe!=null))switch(se){case"value":w=fe;break;case"defaultValue":N=fe;break;case"children":O=fe;break;case"dangerouslySetInnerHTML":if(fe!=null)throw Error(s(91));break;default:Gr(u,f,se,fe,g,null)}Jn(u,w,N,O),Ne(u);return;case"option":for(Ce in g)if(g.hasOwnProperty(Ce)&&(w=g[Ce],w!=null))switch(Ce){case"selected":u.selected=w&&typeof w!="function"&&typeof w!="symbol";break;default:Gr(u,f,Ce,w,g,null)}return;case"dialog":tr("cancel",u),tr("close",u);break;case"iframe":case"object":tr("load",u);break;case"video":case"audio":for(w=0;w<dg.length;w++)tr(dg[w],u);break;case"image":tr("error",u),tr("load",u);break;case"details":tr("toggle",u);break;case"embed":case"source":case"link":tr("error",u),tr("load",u);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ge in g)if(g.hasOwnProperty(Ge)&&(w=g[Ge],w!=null))switch(Ge){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,f));default:Gr(u,f,Ge,w,g,null)}return;default:if(ti(f)){for(At in g)g.hasOwnProperty(At)&&(w=g[At],w!==void 0&&Eb(u,f,At,w,g,void 0));return}}for(fe in g)g.hasOwnProperty(fe)&&(w=g[fe],w!=null&&Gr(u,f,fe,w,g,null))}function dP(u,f,g,w){switch(f){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var N=null,O=null,se=null,fe=null,Ce=null,Ge=null,At=null;for(Et in g){var Pt=g[Et];if(g.hasOwnProperty(Et)&&Pt!=null)switch(Et){case"checked":break;case"value":break;case"defaultValue":Ce=Pt;default:w.hasOwnProperty(Et)||Gr(u,f,Et,null,w,Pt)}}for(var it in w){var Et=w[it];if(Pt=g[it],w.hasOwnProperty(it)&&(Et!=null||Pt!=null))switch(it){case"type":O=Et;break;case"name":N=Et;break;case"checked":Ge=Et;break;case"defaultChecked":At=Et;break;case"value":se=Et;break;case"defaultValue":fe=Et;break;case"children":case"dangerouslySetInnerHTML":if(Et!=null)throw Error(s(137,f));break;default:Et!==Pt&&Gr(u,f,it,Et,w,Pt)}}kt(u,se,fe,Ce,Ge,At,O,N);return;case"select":Et=se=fe=it=null;for(O in g)if(Ce=g[O],g.hasOwnProperty(O)&&Ce!=null)switch(O){case"value":break;case"multiple":Et=Ce;
vendor: 5,066 bytes, line 49
49default:w.hasOwnProperty(O)||Gr(u,f,O,null,w,Ce)}for(N in w)if(O=w[N],Ce=g[N],w.hasOwnProperty(N)&&(O!=null||Ce!=null))switch(N){case"value":it=O;break;case"defaultValue":fe=O;break;case"multiple":se=O;default:O!==Ce&&Gr(u,f,N,O,w,Ce)}f=fe,g=se,w=Et,it!=null?Xn(u,!!g,it,!1):!!w!=!!g&&(f!=null?Xn(u,!!g,f,!0):Xn(u,!!g,g?[]:"",!1));return;case"textarea":Et=it=null;for(fe in g)if(N=g[fe],g.hasOwnProperty(fe)&&N!=null&&!w.hasOwnProperty(fe))switch(fe){case"value":break;case"children":break;default:Gr(u,f,fe,null,w,N)}for(se in w)if(N=w[se],O=g[se],w.hasOwnProperty(se)&&(N!=null||O!=null))switch(se){case"value":it=N;break;case"defaultValue":Et=N;break;case"children":break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(s(91));break;default:N!==O&&Gr(u,f,se,N,w,O)}an(u,it,Et);return;case"option":for(var jn in g)if(it=g[jn],g.hasOwnProperty(jn)&&it!=null&&!w.hasOwnProperty(jn))switch(jn){case"selected":u.selected=!1;break;default:Gr(u,f,jn,null,w,it)}for(Ce in w)if(it=w[Ce],Et=g[Ce],w.hasOwnProperty(Ce)&&it!==Et&&(it!=null||Et!=null))switch(Ce){case"selected":u.selected=it&&typeof it!="function"&&typeof it!="symbol";break;default:Gr(u,f,Ce,it,w,Et)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Cs in g)it=g[Cs],g.hasOwnProperty(Cs)&&it!=null&&!w.hasOwnProperty(Cs)&&Gr(u,f,Cs,null,w,it);for(Ge in w)if(it=w[Ge],Et=g[Ge],w.hasOwnProperty(Ge)&&it!==Et&&(it!=null||Et!=null))switch(Ge){case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(s(137,f));break;default:Gr(u,f,Ge,it,w,Et)}return;default:if(ti(f)){for(var zi in g)it=g[zi],g.hasOwnProperty(zi)&&it!==void 0&&!w.hasOwnProperty(zi)&&Eb(u,f,zi,void 0,w,it);for(At in w)it=w[At],Et=g[At],!w.hasOwnProperty(At)||it===Et||it===void 0&&Et===void 0||Eb(u,f,At,it,w,Et);return}}for(var Je in g)it=g[Je],g.hasOwnProperty(Je)&&it!=null&&!w.hasOwnProperty(Je)&&Gr(u,f,Je,null,w,it);for(Pt in w)it=w[Pt],Et=g[Pt],!w.hasOwnProperty(Pt)||it===Et||it==null&&Et==null||Gr(u,f,Pt,it,w,Et)}var pg=null,Ju=null;function ru(u){return u.nodeType===9?u:u.ownerDocument}function i2(u){switch(u){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ky(u,f){if(u===0)switch(f){case"svg":return 1;case"math":return 2;default:return 0}return u===1&&f==="foreignObject"?0:u}function Tb(u,f){return u==="textarea"||u==="noscript"||typeof f.children=="string"||typeof f.children=="number"||typeof f.children=="bigint"||typeof f.dangerouslySetInnerHTML=="object"&&f.dangerouslySetInnerHTML!==null&&f.dangerouslySetInnerHTML.__html!=null}var mg=null;function hP(){var u=window.event;return u&&u.type==="popstate"?u===mg?!1:(mg=u,!0):(mg=null,!1)}var KC=typeof setTimeout=="function"?setTimeout:void 0,fP=typeof clearTimeout=="function"?clearTimeout:void 0,YC=typeof Promise=="function"?Promise:void 0,XC=typeof queueMicrotask=="function"?queueMicrotask:typeof YC<"u"?function(u){return YC.resolve(null).then(u).catch(JC)}:KC;function JC(u){setTimeout(function(){throw u})}function a2(u,f){var g=f,w=0;do{var N=g.nextSibling;if(u.removeChild(g),N&&N.nodeType===8)if(g=N.data,g==="/$"){if(w===0){u.removeChild(N),Ma(f);return}w--}else g!=="$"&&g!=="$?"&&g!=="$!"||w++;g=N}while(g);Ma(f)}function o2(u){var f=u.firstChild;for(f&&f.nodeType===10&&(f=f.nextSibling);f;){var g=f;switch(f=f.nextSibling,g.nodeName){case"HTML":case"HEAD":case"BODY":o2(g),Ps(g);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(g.rel.toLowerCase()==="stylesheet")continue}u.removeChild(g)}}function pP(u,f,g,w){for(;u.nodeType===1;){var N=g;if(u.nodeName.toLowerCase()!==f.toLowerCase()){if(!w&&(u.nodeName!=="INPUT"||u.type!=="hidden"))break}else if(w){if(!u[ls])switch(f){case"meta":if(!u.hasAttribute("itemprop"))break;return u;case"link":if(O=u.getAttribute("rel"),O==="stylesheet"&&u.hasAttribute("data-precedence"))break;if(O!==N.rel||u.getAttribute("href")!==(N.href==null?null:N.href)||u.getAttribute("crossorigin")!==(N.crossOrigin==null?null:N.crossOrigin)||u.getAttribute("title")!==(N.title==null?null:N.title))break;return u;case"style":if(u.hasAttribute("data-precedence"))break;return u;case"script":if(O=u.getAttribute("src"),(O!==(N.src==null?null:N.src)||u.getAttribute("type")!==(N.type==null?null:N.type)||u.getAttribute("crossorigin")!==(N.crossOrigin==null?null:N.crossOrigin))&&O&&u.hasAttribute("async")&&!u.hasAttribute("itemprop"))break;return u;default:return u}}else if(f==="input"&&u.type==="hidden"){var O=N.name==null?null:""+N.name;if(N.type==="hidden"&&u.getAttribute("name")===O)return u}else return u;if(u=Fl(u.nextSibling),u===null)break}return null}function mP(u,f,g){if(f==="")return null;for(;u.nodeType!==3;)if((u.nodeType!==1||u.nodeName!=="INPUT"||u.type!=="hidden")&&!g||(u=Fl(u.nextSibling),u===null))return null;return u}function Fl(u){for(;u!=null;u=u.nextSibling){var f=u.nodeType;if(f===1||f===3)break;if(f===8){if(f=u.data,f==="$"||f==="$!"||f==="$?"||f==="F!"||f==="F")break;
vendor: 16,745 bytes, line 49
49if(f==="/$")return null}}return u}function l2(u){u=u.previousSibling;for(var f=0;u;){if(u.nodeType===8){var g=u.data;if(g==="$"||g==="$!"||g==="$?"){if(f===0)return u;f--}else g==="/$"&&f++}u=u.previousSibling}return null}function QC(u,f,g){switch(f=ru(g),u){case"html":if(u=f.documentElement,!u)throw Error(s(452));return u;case"head":if(u=f.head,!u)throw Error(s(453));return u;case"body":if(u=f.body,!u)throw Error(s(454));return u;default:throw Error(s(451))}}var kc=new Map,ZC=new Set;function Ab(u){return typeof u.getRootNode=="function"?u.getRootNode():u.ownerDocument}var Qu=Se.d;Se.d={f:ek,r:gP,D:yP,C:nk,L:xP,m:c2,X:sk,S:vP,M:rk};function ek(){var u=Qu.f(),f=yb();return u||f}function gP(u){var f=ws(u);f!==null&&f.tag===5&&f.type==="form"?GA(f):Qu.r(u)}var gg=typeof document>"u"?null:document;function tk(u,f,g){var w=gg;if(w&&typeof f=="string"&&f){var N=_t(f);N='link[rel="'+u+'"][href="'+N+'"]',typeof g=="string"&&(N+='[crossorigin="'+g+'"]'),ZC.has(N)||(ZC.add(N),u={rel:u,crossOrigin:g,href:f},w.querySelector(N)===null&&(f=w.createElement("link"),Ja(f,"link",u),Pn(f),w.head.appendChild(f)))}}function yP(u){Qu.D(u),tk("dns-prefetch",u,null)}function nk(u,f){Qu.C(u,f),tk("preconnect",u,f)}function xP(u,f,g){Qu.L(u,f,g);var w=gg;if(w&&u&&f){var N='link[rel="preload"][as="'+_t(f)+'"]';f==="image"&&g&&g.imageSrcSet?(N+='[imagesrcset="'+_t(g.imageSrcSet)+'"]',typeof g.imageSizes=="string"&&(N+='[imagesizes="'+_t(g.imageSizes)+'"]')):N+='[href="'+_t(u)+'"]';var O=N;switch(f){case"style":O=yg(u);break;case"script":O=Vp(u)}kc.has(O)||(u=G({rel:"preload",href:f==="image"&&g&&g.imageSrcSet?void 0:u,as:f},g),kc.set(O,u),w.querySelector(N)!==null||f==="style"&&w.querySelector(Iy(O))||f==="script"&&w.querySelector(xg(O))||(f=w.createElement("link"),Ja(f,"link",u),Pn(f),w.head.appendChild(f)))}}function c2(u,f){Qu.m(u,f);var g=gg;if(g&&u){var w=f&&typeof f.as=="string"?f.as:"script",N='link[rel="modulepreload"][as="'+_t(w)+'"][href="'+_t(u)+'"]',O=N;switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=Vp(u)}if(!kc.has(O)&&(u=G({rel:"modulepreload",href:u},f),kc.set(O,u),g.querySelector(N)===null)){switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(g.querySelector(xg(O)))return}w=g.createElement("link"),Ja(w,"link",u),Pn(w),g.head.appendChild(w)}}}function vP(u,f,g){Qu.S(u,f,g);var w=gg;if(w&&u){var N=ys(w).hoistableStyles,O=yg(u);f=f||"default";var se=N.get(O);if(!se){var fe={loading:0,preload:null};if(se=w.querySelector(Iy(O)))fe.loading=5;else{u=G({rel:"stylesheet",href:u,"data-precedence":f},g),(g=kc.get(O))&&h2(u,g);var Ce=se=w.createElement("link");Pn(Ce),Ja(Ce,"link",u),Ce._p=new Promise(function(Ge,At){Ce.onload=Ge,Ce.onerror=At}),Ce.addEventListener("load",function(){fe.loading|=1}),Ce.addEventListener("error",function(){fe.loading|=2}),fe.loading|=4,kb(se,f,w)}se={type:"stylesheet",instance:se,count:1,state:fe},N.set(O,se)}}}function sk(u,f){Qu.X(u,f);var g=gg;if(g&&u){var w=ys(g).hoistableScripts,N=Vp(u),O=w.get(N);O||(O=g.querySelector(xg(N)),O||(u=G({src:u,async:!0},f),(f=kc.get(N))&&f2(u,f),O=g.createElement("script"),Pn(O),Ja(O,"link",u),g.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(N,O))}}function rk(u,f){Qu.M(u,f);var g=gg;if(g&&u){var w=ys(g).hoistableScripts,N=Vp(u),O=w.get(N);O||(O=g.querySelector(xg(N)),O||(u=G({src:u,async:!0,type:"module"},f),(f=kc.get(N))&&f2(u,f),O=g.createElement("script"),Pn(O),Ja(O,"link",u),g.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(N,O))}}function u2(u,f,g,w){var N=(N=Zt.current)?Ab(N):null;if(!N)throw Error(s(446));switch(u){case"meta":case"title":return null;case"style":return typeof g.precedence=="string"&&typeof g.href=="string"?(f=yg(g.href),g=ys(N).hoistableStyles,w=g.get(f),w||(w={type:"style",instance:null,count:0,state:null},g.set(f,w)),w):{type:"void",instance:null,count:0,state:null};case"link":if(g.rel==="stylesheet"&&typeof g.href=="string"&&typeof g.precedence=="string"){u=yg(g.href);var O=ys(N).hoistableStyles,se=O.get(u);if(se||(N=N.ownerDocument||N,se={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(u,se),(O=N.querySelector(Iy(u)))&&!O._p&&(se.instance=O,se.state.loading=5),kc.has(u)||(g={rel:"preload",as:"style",href:g.href,crossOrigin:g.crossOrigin,integrity:g.integrity,media:g.media,hrefLang:g.hrefLang,referrerPolicy:g.referrerPolicy},kc.set(u,g),O||d2(N,u,g,se.state))),f&&w===null)throw Error(s(528,""));return se}if(f&&w!==null)throw Error(s(529,""));return null;case"script":return f=g.async,g=g.src,typeof g=="string"&&f&&typeof f!="function"&&typeof f!="symbol"?(f=Vp(g),g=ys(N).hoistableScripts,w=g.get(f),w||(w={type:"script",instance:null,count:0,state:null},g.set(f,w)),w):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,u))}}function yg(u){return'href="'+_t(u)+'"'}function Iy(u){return'link[rel="stylesheet"]['+u+"]"}function Cb(u){return G({},u,{"data-precedence":u.precedence,precedence:null})}function d2(u,f,g,w){u.querySelector('link[rel="preload"][as="style"]['+f+"]")?w.loading=1:(f=u.createElement("link"),w.preload=f,f.addEventListener("load",function(){return w.loading|=1}),f.addEventListener("error",function(){return w.loading|=2}),Ja(f,"link",g),Pn(f),u.head.appendChild(f))}function Vp(u){return'[src="'+_t(u)+'"]'}function xg(u){return"script[async]"+u}function ik(u,f,g){if(f.count++,f.instance===null)switch(f.type){case"style":var w=u.querySelector('style[data-href~="'+_t(g.href)+'"]');if(w)return f.instance=w,Pn(w),w;var N=G({},g,{"data-href":g.href,"data-precedence":g.precedence,href:null,precedence:null});return w=(u.ownerDocument||u).createElement("style"),Pn(w),Ja(w,"style",N),kb(w,g.precedence,u),f.instance=w;case"stylesheet":N=yg(g.href);var O=u.querySelector(Iy(N));if(O)return f.state.loading|=4,f.instance=O,Pn(O),O;w=Cb(g),(N=kc.get(N))&&h2(w,N),O=(u.ownerDocument||u).createElement("link"),Pn(O);var se=O;return se._p=new Promise(function(fe,Ce){se.onload=fe,se.onerror=Ce}),Ja(O,"link",w),f.state.loading|=4,kb(O,g.precedence,u),f.instance=O;case"script":return O=Vp(g.src),(N=u.querySelector(xg(O)))?(f.instance=N,Pn(N),N):(w=g,(N=kc.get(O))&&(w=G({},g),f2(w,N)),u=u.ownerDocument||u,N=u.createElement("script"),Pn(N),Ja(N,"link",w),u.head.appendChild(N),f.instance=N);case"void":return null;default:throw Error(s(443,f.type))}else f.type==="stylesheet"&&(f.state.loading&4)===0&&(w=f.instance,f.state.loading|=4,kb(w,g.precedence,u));return f.instance}function kb(u,f,g){for(var w=g.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),N=w.length?w[w.length-1]:null,O=N,se=0;se<w.length;se++){var fe=w[se];if(fe.dataset.precedence===f)O=fe;else if(O!==N)break}O?O.parentNode.insertBefore(u,O.nextSibling):(f=g.nodeType===9?g.head:g,f.insertBefore(u,f.firstChild))}function h2(u,f){u.crossOrigin==null&&(u.crossOrigin=f.crossOrigin),u.referrerPolicy==null&&(u.referrerPolicy=f.referrerPolicy),u.title==null&&(u.title=f.title)}function f2(u,f){u.crossOrigin==null&&(u.crossOrigin=f.crossOrigin),u.referrerPolicy==null&&(u.referrerPolicy=f.referrerPolicy),u.integrity==null&&(u.integrity=f.integrity)}var Ib=null;function ak(u,f,g){if(Ib===null){var w=new Map,N=Ib=new Map;N.set(g,w)}else N=Ib,w=N.get(g),w||(w=new Map,N.set(g,w));if(w.has(u))return w;for(w.set(u,null),g=g.getElementsByTagName(u),N=0;N<g.length;N++){var O=g[N];if(!(O[ls]||O[Ft]||u==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var se=O.getAttribute(f)||"";se=u+se;var fe=w.get(se);fe?fe.push(O):w.set(se,[O])}}return w}function ok(u,f,g){u=u.ownerDocument||u,u.head.insertBefore(g,f==="title"?u.querySelector("head > title"):null)}function bP(u,f,g){if(g===1||f.itemProp!=null)return!1;switch(u){case"meta":case"title":return!0;case"style":if(typeof f.precedence!="string"||typeof f.href!="string"||f.href==="")break;return!0;case"link":if(typeof f.rel!="string"||typeof f.href!="string"||f.href===""||f.onLoad||f.onError)break;switch(f.rel){case"stylesheet":return u=f.disabled,typeof f.precedence=="string"&&u==null;default:return!0}case"script":if(f.async&&typeof f.async!="function"&&typeof f.async!="symbol"&&!f.onLoad&&!f.onError&&f.src&&typeof f.src=="string")return!0}return!1}function lk(u){return!(u.type==="stylesheet"&&(u.state.loading&3)===0)}var Ny=null;function wP(){}function _P(u,f,g){if(Ny===null)throw Error(s(475));var w=Ny;if(f.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var N=yg(g.href),O=u.querySelector(Iy(N));if(O){u=O._p,u!==null&&typeof u=="object"&&typeof u.then=="function"&&(w.count++,w=Nb.bind(w),u.then(w,w)),f.state.loading|=4,f.instance=O,Pn(O);return}O=u.ownerDocument||u,g=Cb(g),(N=kc.get(N))&&h2(g,N),O=O.createElement("link"),Pn(O);var se=O;se._p=new Promise(function(fe,Ce){se.onload=fe,se.onerror=Ce}),Ja(O,"link",g),f.instance=O}w.stylesheets===null&&(w.stylesheets=new Map),w.stylesheets.set(f,u),(u=f.state.preload)&&(f.state.loading&3)===0&&(w.count++,f=Nb.bind(w),u.addEventListener("load",f),u.addEventListener("error",f))}}function p2(){if(Ny===null)throw Error(s(475));var u=Ny;return u.stylesheets&&u.count===0&&Rb(u,u.stylesheets),0<u.count?function(f){var g=setTimeout(function(){if(u.stylesheets&&Rb(u,u.stylesheets),u.unsuspend){var w=u.unsuspend;u.unsuspend=null,w()}},6e4);return u.unsuspend=f,function(){u.unsuspend=null,clearTimeout(g)}}:null}function Nb(){if(this.count--,this.count===0){if(this.stylesheets)Rb(this,this.stylesheets);else if(this.unsuspend){var u=this.unsuspend;this.unsuspend=null,u()}}}var Ry=null;function Rb(u,f){u.stylesheets=null,u.unsuspend!==null&&(u.count++,Ry=new Map,f.forEach(SP,u),Ry=null,Nb.call(u))}function SP(u,f){if(!(f.state.loading&4)){var g=Ry.get(u);if(g)var w=g.get(null);else{g=new Map,Ry.set(u,g);for(var N=u.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<N.length;O++){var se=N[O];(se.nodeName==="LINK"||se.getAttribute("media")!=="not all")&&(g.set(se.dataset.precedence,se),w=se)}w&&g.set(null,w)}N=f.instance,se=N.getAttribute("data-precedence"),O=g.get(se)||w,O===w&&g.set(null,N),g.set(se,N),this.count++,w=Nb.bind(this),N.addEventListener("load",w),N.addEventListener("error",w),O?O.parentNode.insertBefore(N,O.nextSibling):(u=u.nodeType===9?u.head:u,u.insertBefore(N,u.firstChild)),f.state.loading|=4}}var vg={$$typeof:y,Provider:null,Consumer:null,_currentValue:De,_currentValue2:De,_threadCount:0};function EP(u,f,g,w,N,O,se,fe){this.tag=1,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=fs(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fs(0),this.hiddenUpdates=fs(null),this.identifierPrefix=w,this.onUncaughtError=N,this.onCaughtError=O,this.onRecoverableError=se,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=fe,this.incompleteTransitions=new Map}function ck(u,f,g,w,N,O,se,fe,Ce,Ge,At,Pt){return u=new EP(u,f,g,se,fe,Ce,Ge,Pt),f=1,O===!0&&(f|=24),O=Ll(3,null,null,f),u.current=O,O.stateNode=u,f=A(),f.refCount++,u.pooledCache=f,f.refCount++,O.memoizedState={element:w,isDehydrated:g,cache:f},N_(O),u}function m2(u){return u?(u=hc,u):hc}function rl(u,f,g,w,N,O){N=m2(N),w.context===null?w.context=N:w.pendingContext=N,w=Wu(f),w.payload={element:g},O=O===void 0?null:O,O!==null&&(w.callback=O),g=Zd(u,w,f),g!==null&&(yo(g,u,f),Zc(g,u,f))}function g2(u,f){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var g=u.retryLane;u.retryLane=g!==0&&g<f?g:f}}function bg(u,f){g2(u,f),(u=u.alternate)&&g2(u,f)}function If(u){if(u.tag===13){var f=vi(u,67108864);f!==null&&yo(f,u,67108864),bg(u,67108864)}}var wg=!0;function TP(u,f,g,w){var N=B.T;B.T=null;var O=Se.p;try{Se.p=2,y2(u,f,g,w)}finally{Se.p=O,B.T=N}}function AP(u,f,g,w){var N=B.T;B.T=null;var O=Se.p;try{Se.p=8,y2(u,f,g,w)}finally{Se.p=O,B.T=N}}function y2(u,f,g,w){if(wg){var N=x2(w);if(N===null)lh(u,f,w,Mb,g),b2(u,w);else if(au(N,u,f,g,w))w.stopPropagation();else if(b2(u,w),f&4&&-1<uk.indexOf(u)){for(;N!==null;){var O=ws(N);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var se=Wn(O.pendingLanes);if(se!==0){var fe=O;for(fe.pendingLanes|=2,fe.entangledLanes|=2;se;){var Ce=1<<31-Lt(se);fe.entanglements[1]|=Ce,se&=~Ce}nu(O),(Ri&6)===0&&(pb=Mt()+500,Ay(0))}}break;case 13:fe=vi(O,2),fe!==null&&yo(fe,O,2),yb(),bg(O,2)}if(O=x2(w),O===null&&lh(u,f,w,Mb,g),O===N)break;N=O}N!==null&&w.stopPropagation()}else lh(u,f,w,null,g)}}function x2(u){return u=Ls(u),_g(u)}var Mb=null;function _g(u){if(Mb=null,u=rr(u),u!==null){var f=Le(u);if(f===null)u=null;else{var g=f.tag;if(g===13){if(u=ve(f),u!==null)return u;u=null}else if(g===3){if(f.stateNode.current.memoizedState.isDehydrated)return f.tag===3?f.stateNode.containerInfo:null;u=null}else f!==u&&(u=null)}}return Mb=u,null}function Sg(u){switch(u){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(pt()){case Oe:return 2;case hn:return 8;case Yt:case Qe:return 32;case tn:return 268435456;default:return 32}default:return 32}}var v2=!1,Nf=null,uh=null,dh=null,My=new Map,Rf=new Map,Zu=[],uk="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function b2(u,f){switch(u){case"focusin":case"focusout":Nf=null;break;case"dragenter":case"dragleave":uh=null;break;case"mouseover":case"mouseout":dh=null;break;case"pointerover":case"pointerout":My.delete(f.pointerId);break;case"gotpointercapture":case"lostpointercapture":Rf.delete(f.pointerId)}}function iu(u,f,g,w,N,O){return u===null||u.nativeEvent!==O?(u={blockedOn:f,domEventName:g,eventSystemFlags:w,nativeEvent:O,targetContainers:[N]},f!==null&&(f=ws(f),f!==null&&If(f)),u):(u.eventSystemFlags|=w,f=u.targetContainers,N!==null&&f.indexOf(N)===-1&&f.push(N),u)}function au(u,f,g,w,N){switch(f){case"focusin":return Nf=iu(Nf,u,f,g,w,N),!0;case"dragenter":return uh=iu(uh,u,f,g,w,N),!0;case"mouseover":return dh=iu(dh,u,f,g,w,N),!0;case"pointerover":var O=N.pointerId;return My.set(O,iu(My.get(O)||null,u,f,g,w,N)),!0;case"gotpointercapture":return O=N.pointerId,Rf.set(O,iu(Rf.get(O)||null,u,f,g,w,N)),!0}return!1}function dk(u){var f=rr(u.target);if(f!==null){var g=Le(f);if(g!==null){if(f=g.tag,f===13){if(f=ve(g),f!==null){u.blockedOn=f,Sn(u.priority,function(){if(g.tag===13){var w=Bl(),N=vi(g,w);N!==null&&yo(N,g,w),bg(g,w)}});return}}else if(f===3&&g.stateNode.current.memoizedState.isDehydrated){u.blockedOn=g.tag===3?g.stateNode.containerInfo:null;return}}}u.blockedOn=null}function Eg(u){if(u.blockedOn!==null)return!1;for(var f=u.targetContainers;0<f.length;){var g=x2(u.nativeEvent);if(g===null){g=u.nativeEvent;var w=new g.constructor(g.type,g);Va=w,g.target.dispatchEvent(w),Va=null}else return f=ws(g),f!==null&&If(f),u.blockedOn=g,!1;f.shift()}return!0}function w2(u,f,g){Eg(u)&&g.delete(f)}function _2(){v2=!1,Nf!==null&&Eg(Nf)&&(Nf=null),uh!==null&&Eg(uh)&&(uh=null),dh!==null&&Eg(dh)&&(dh=null),My.forEach(w2),Rf.forEach(w2)}function zp(u,f){u.blockedOn===f&&(u.blockedOn=null,v2||(v2=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,_2)))}var ou=null;
49function S2(u){ou!==u&&(ou=u,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ou===u&&(ou=null);for(var f=0;f<u.length;f+=3){var g=u[f],w=u[f+1],N=u[f+2];if(typeof w!="function"){if(_g(w||g)===null)continue;break}var O=ws(g);O!==null&&(u.splice(f,3),f-=3,kp(O,{pending:!0,data:N,method:g.method,action:w},w,N))}}))}function Ma(u){function f(Ce){return zp(Ce,u)}Nf!==null&&zp(Nf,u),uh!==null&&zp(uh,u),dh!==null&&zp(dh,u),My.forEach(f),Rf.forEach(f);for(var g=0;g<Zu.length;g++){var w=Zu[g];w.blockedOn===u&&(w.blockedOn=null)}for(;0<Zu.length&&(g=Zu[0],g.blockedOn===null);)dk(g),g.blockedOn===null&&Zu.shift();if(g=(u.ownerDocument||u).$$reactFormReplay,g!=null)for(w=0;w<g.length;w+=3){var N=g[w],O=g[w+1],se=N[sn]||null;if(typeof O=="function")se||S2(g);else if(se){var fe=null;if(O&&O.hasAttribute("formAction")){if(N=O,se=O[sn]||null)fe=se.formAction;else if(_g(N)!==null)continue}else fe=se.action;typeof fe=="function"?g[w+1]=fe:(g.splice(w,3),w-=3),S2(g)}}}function ed(u){this._internalRoot=u}hh.prototype.render=ed.prototype.render=function(u){var f=this._internalRoot;if(f===null)throw Error(s(409));var g=f.current,w=Bl();rl(g,w,u,f,null,null)},hh.prototype.unmount=ed.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var f=u.containerInfo;u.tag===0&&Up(),rl(u.current,2,null,u,null,null),yb(),f[rn]=null}};function hh(u){this._internalRoot=u}hh.prototype.unstable_scheduleHydration=function(u){if(u){var f=Qt();u={blockedOn:null,target:u,priority:f};for(var g=0;g<Zu.length&&f!==0&&f<Zu[g].priority;g++);Zu.splice(g,0,u),g===0&&dk(u)}};var Mf=e.version;if(Mf!=="19.0.0")throw Error(s(527,Mf,"19.0.0"));Se.findDOMNode=function(u){var f=u._reactInternals;if(f===void 0)throw typeof u.render=="function"?Error(s(188)):(u=Object.keys(u).join(","),Error(s(268,u)));return u=ie(f),u=u!==null?de(u):null,u=u===null?null:u.stateNode,u};var E2={bundleType:0,version:"19.0.0",rendererPackageName:"react-dom",currentDispatcherRef:B,findFiberByHostInstance:rr,reconcilerVersion:"19.0.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Pb=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Pb.isDisabled&&Pb.supportsFiber)try{bt=Pb.inject(E2),ht=Pb}catch{}}return M2.createRoot=function(u,f){if(!r(u))throw Error(s(299));var g=!1,w="",N=QA,O=ZA,se=x_,fe=null;return f!=null&&(f.unstable_strictMode===!0&&(g=!0),f.identifierPrefix!==void 0&&(w=f.identifierPrefix),f.onUncaughtError!==void 0&&(N=f.onUncaughtError),f.onCaughtError!==void 0&&(O=f.onCaughtError),f.onRecoverableError!==void 0&&(se=f.onRecoverableError),f.unstable_transitionCallbacks!==void 0&&(fe=f.unstable_transitionCallbacks)),f=ck(u,1,!1,null,null,g,w,N,O,se,fe,null),u[rn]=f.current,kf(u.nodeType===8?u.parentNode:u),new ed(f)},M2.hydrateRoot=function(u,f,g){if(!r(u))throw Error(s(299));var w=!1,N="",O=QA,se=ZA,fe=x_,Ce=null,Ge=null;return g!=null&&(g.unstable_strictMode===!0&&(w=!0),g.identifierPrefix!==void 0&&(N=g.identifierPrefix),g.onUncaughtError!==void 0&&(O=g.onUncaughtError),g.onCaughtError!==void 0&&(se=g.onCaughtError),g.onRecoverableError!==void 0&&(fe=g.onRecoverableError),g.unstable_transitionCallbacks!==void 0&&(Ce=g.unstable_transitionCallbacks),g.formState!==void 0&&(Ge=g.formState)),f=ck(u,1,!0,f,g??null,w,N,O,se,fe,Ce,Ge),f.context=m2(null),g=f.current,w=Bl(),N=Wu(w),N.callback=null,Zd(g,N,w),f.current.lanes=w,ps(f,w),nu(f),u[rn]=f.current,kf(u),new hh(f)},M2.version="19.0.0",M2}var WB;function Bde(){if(WB)return p4.exports;WB=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),p4.exports=jde(),p4.exports}var Ude=Bde();const Fde=JR(Ude);var Vde=iK();/**
50 * @remix-run/router v1.23.2
51 *
52 * Copyright (c) Remix Software Inc.
53 *
54 * This source code is licensed under the MIT license found in the
55 * LICENSE.md file in the root directory of this source tree.
56 *
57 * @license MIT
58 */function tE(){return tE=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},tE.apply(this,arguments)}var w0;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(w0||(w0={}));const KB="popstate";function zde(t){t===void 0&&(t={});function e(s,r){let{pathname:i,search:a,hash:o}=s.location;return k3("",{pathname:i,search:a,hash:o},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(s,r){return typeof r=="string"?r:bN(r)}return Hde(e,n,null,t)}function Ba(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function KO(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Gde(){return Math.random().toString(36).substr(2,8)}function YB(t,e){return{usr:t.state,key:t.key,idx:e}}function k3(t,e,n,s){return n===void 0&&(n=null),tE({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?K1(e):e,{state:n,key:e&&e.key||s||Gde()})}function bN(t){let{pathname:e="/",search:n="",hash:s=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(e+=s.charAt(0)==="#"?s:"#"+s),e}function K1(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substr(s),t=t.substr(0,s)),t&&(e.pathname=t)}return e}function Hde(t,e,n,s){s===void 0&&(s={});let{window:r=document.defaultView,v5Compat:i=!1}=s,a=r.history,o=w0.Pop,l=null,c=h();c==null&&(c=0,a.replaceState(tE({},a.state,{idx:c}),""));function h(){return(a.state||{idx:null}).idx}function p(){o=w0.Pop;let S=h(),E=S==null?null:S-c;c=S,l&&l({action:o,location:b.location,delta:E})}function m(S,E){o=w0.Push;let I=k3(b.location,S,E);c=h()+1;let M=YB(I,c),j=b.createHref(I);try{a.pushState(M,"",j)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;r.location.assign(j)}i&&l&&l({action:o,location:b.location,delta:1})}function y(S,E){o=w0.Replace;let I=k3(b.location,S,E);c=h();let M=YB(I,c),j=b.createHref(I);a.replaceState(M,"",j),i&&l&&l({action:o,location:b.location,delta:0})}function v(S){let E=r.location.origin!=="null"?r.location.origin:r.location.href,I=typeof S=="string"?S:bN(S);return I=I.replace(/ $/,"%20"),Ba(E,"No window.location.(origin|href) available to create URL for href: "+I),new URL(I,E)}let b={get action(){return o},get location(){return t(r,a)},listen(S){if(l)throw new Error("A history only accepts one active listener");return r.addEventListener(KB,p),l=S,()=>{r.removeEventListener(KB,p),l=null}},createHref(S){return e(r,S)},createURL:v,encodeLocation(S){let E=v(S);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:m,replace:y,go(S){return a.go(S)}};return b}var XB;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(XB||(XB={}));function qde(t,e,n){return n===void 0&&(n="/"),Wde(t,e,n)}function Wde(t,e,n,s){let r=typeof e=="string"?K1(e):e,i=YO(r.pathname||"/",n);if(i==null)return null;let a=aK(t);Kde(a);let o=null;for(let l=0;o==null&&l<a.length;++l){let c=ahe(i);o=she(a[l],c)}return o}function aK(t,e,n,s){e===void 0&&(e=[]),n===void 0&&(n=[]),s===void 0&&(s="");let r=(i,a,o)=>{let l={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:a,route:i};l.relativePath.startsWith("/")&&(Ba(l.relativePath.startsWith(s),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+s+'" is not val
58id. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(s.length));let c=C0([s,l.relativePath]),h=n.concat(l);i.children&&i.children.length>0&&(Ba(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),aK(i.children,e,h,c)),!(i.path==null&&!i.index)&&e.push({path:c,score:the(c,i.index),routesMeta:h})};return t.forEach((i,a)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))r(i,a);else for(let l of oK(i.path))r(i,a,l)}),e}function oK(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,r=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return r?[i,""]:[i];let a=oK(s.join("/")),o=[];return o.push(...a.map(l=>l===""?i:[i,l].join("/"))),r&&o.push(...a),o.map(l=>t.startsWith("/")&&l===""?"/":l)}function Kde(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:nhe(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const Yde=/^:[\w-]+$/,Xde=3,Jde=2,Qde=1,Zde=10,ehe=-2,JB=t=>t==="*";function the(t,e){let n=t.split("/"),s=n.length;return n.some(JB)&&(s+=ehe),e&&(s+=Jde),n.filter(r=>!JB(r)).reduce((r,i)=>r+(Yde.test(i)?Xde:i===""?Qde:Zde),s)}function nhe(t,e){return t.length===e.length&&t.slice(0,-1).every((s,r)=>s===e[r])?t[t.length-1]-e[e.length-1]:0}function she(t,e,n){let{routesMeta:s}=t,r={},i="/",a=[];for(let o=0;o<s.length;++o){let l=s[o],c=o===s.length-1,h=i==="/"?e:e.slice(i.length)||"/",p=rhe({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},h),m=l.route;if(!p)return null;
vendor: 5,158 bytes, lines 58-67
58Object.assign(r,p.params),a.push({params:r,pathname:C0([i,p.pathname]),pathnameBase:dhe(C0([i,p.pathnameBase])),route:m}),p.pathnameBase!=="/"&&(i=C0([i,p.pathnameBase]))}return a}function rhe(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,s]=ihe(t.path,t.caseSensitive,t.end),r=e.match(n);if(!r)return null;let i=r[0],a=i.replace(/(.)\/+$/,"$1"),o=r.slice(1);return{params:s.reduce((c,h,p)=>{let{paramName:m,isOptional:y}=h;if(m==="*"){let b=o[p]||"";a=i.slice(0,i.length-b.length).replace(/(.)\/+$/,"$1")}const v=o[p];return y&&!v?c[m]=void 0:c[m]=(v||"").replace(/%2F/g,"/"),c},{}),pathname:i,pathnameBase:a,pattern:t}}function ihe(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),KO(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let s=[],r="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,l)=>(s.push({paramName:o,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),r+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":t!==""&&t!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,e?void 0:"i"),s]}function ahe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return KO(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function YO(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}const ohe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,lhe=t=>ohe.test(t);function che(t,e){e===void 0&&(e="/");let{pathname:n,search:s="",hash:r=""}=typeof t=="string"?K1(t):t,i;if(n)if(lhe(n))i=n;else{if(n.includes("//")){let a=n;n=n.replace(/\/\/+/g,"/"),KO(!1,"Pathnames cannot have embedded double slashes - normalizing "+(a+" -> "+n))}n.startsWith("/")?i=QB(n.substring(1),"/"):i=QB(n,e)}else i=e;return{pathname:i,search:hhe(s),hash:fhe(r)}}function QB(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function x4(t,e,n,s){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(s)+"].  Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function uhe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function lK(t,e){let n=uhe(t);return e?n.map((s,r)=>r===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function cK(t,e,n,s){s===void 0&&(s=!1);let r;typeof t=="string"?r=K1(t):(r=tE({},t),Ba(!r.pathname||!r.pathname.includes("?"),x4("?","pathname","search",r)),Ba(!r.pathname||!r.pathname.includes("#"),x4("#","pathname","hash",r)),Ba(!r.search||!r.search.includes("#"),x4("#","search","hash",r)));let i=t===""||r.pathname==="",a=i?"/":r.pathname,o;if(a==null)o=n;else{let p=e.length-1;if(!s&&a.startsWith("..")){let m=a.split("/");for(;m[0]==="..";)m.shift(),p-=1;r.pathname=m.join("/")}o=p>=0?e[p]:"/"}let l=che(r,o),c=a&&a!=="/"&&a.endsWith("/"),h=(i||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(c||h)&&(l.pathname+="/"),l}const C0=t=>t.join("/").replace(/\/\/+/g,"/"),dhe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),hhe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,fhe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function phe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const uK=["post","put","patch","delete"];new Set(uK);const mhe=["get",...uK];new Set(mhe);/**
59 * React Router v6.30.3
60 *
61 * Copyright (c) Remix Software Inc.
62 *
63 * This source code is licensed under the MIT license found in the
64 * LICENSE.md file in the root directory of this source tree.
65 *
66 * @license MIT
67 */function nE(){return nE=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},nE.apply(this,arguments)}const XO=q.createContext(null),ghe=q.createContext(null),jv=q.createContext(null),QR=q.createContext(null),Bv=q.createContext({outlet:null,matches:[],isDataRoute:!1}),dK=q.createContext(null);function yhe(t,e){let{relative:n}=e===void 0?{}:e;oA()||Ba(!1);let{basename:s,navigator:r}=q.useContext(jv),{hash:i,pathname:a,search:o}=fK(t,{relative:n}),l=a;return s!=="/"&&(l=a==="/"?s:C0([s,a])),r.createHref({pathname:l,search:o,hash:i})}function oA(){return q.useContext(QR)!=null}function Qh(){return oA()||Ba(!1),q.useContext(QR).location}function hK(t){q.useContext(jv).static||q.useLayoutEffect(t)}function co(){let{isDataRoute:t}=q.useContext(Bv);return t?Nhe():xhe()}function xhe(){oA()||Ba(!1);
vendor: 4,338 bytes, line 67
67let t=q.useContext(XO),{basename:e,future:n,navigator:s}=q.useContext(jv),{matches:r}=q.useContext(Bv),{pathname:i}=Qh(),a=JSON.stringify(lK(r,n.v7_relativeSplatPath)),o=q.useRef(!1);return hK(()=>{o.current=!0}),q.useCallback(function(c,h){if(h===void 0&&(h={}),!o.current)return;if(typeof c=="number"){s.go(c);return}let p=cK(c,JSON.parse(a),i,h.relative==="path");t==null&&e!=="/"&&(p.pathname=p.pathname==="/"?e:C0([e,p.pathname])),(h.replace?s.replace:s.push)(p,h.state,h)},[e,s,a,i,t])}function fK(t,e){let{relative:n}=e===void 0?{}:e,{future:s}=q.useContext(jv),{matches:r}=q.useContext(Bv),{pathname:i}=Qh(),a=JSON.stringify(lK(r,s.v7_relativeSplatPath));return q.useMemo(()=>cK(t,JSON.parse(a),i,n==="path"),[t,a,i,n])}function vhe(t,e){return bhe(t,e)}function bhe(t,e,n,s){oA()||Ba(!1);let{navigator:r}=q.useContext(jv),{matches:i}=q.useContext(Bv),a=i[i.length-1],o=a?a.params:{};a&&a.pathname;let l=a?a.pathnameBase:"/";a&&a.route;let c=Qh(),h;if(e){var p;let S=typeof e=="string"?K1(e):e;l==="/"||(p=S.pathname)!=null&&p.startsWith(l)||Ba(!1),h=S}else h=c;let m=h.pathname||"/",y=m;if(l!=="/"){let S=l.replace(/^\//,"").split("/");y="/"+m.replace(/^\//,"").split("/").slice(S.length).join("/")}let v=qde(t,{pathname:y}),b=The(v&&v.map(S=>Object.assign({},S,{params:Object.assign({},o,S.params),pathname:C0([l,r.encodeLocation?r.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?l:C0([l,r.encodeLocation?r.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),i,n,s);return e&&b?q.createElement(QR.Provider,{value:{location:nE({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:w0.Pop}},b):b}function whe(){let t=Ihe(),e=phe(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return q.createElement(q.Fragment,null,q.createElement("h2",null,"Unexpected Application Error!"),q.createElement("h3",{style:{fontStyle:"italic"}},e),n?q.createElement("pre",{style:r},n):null,null)}const _he=q.createElement(whe,null);class She extends q.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?q.createElement(Bv.Provider,{value:this.props.routeContext},q.createElement(dK.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Ehe(t){let{routeContext:e,match:n,children:s}=t,r=q.useContext(XO);return r&&r.static&&r.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=n.route.id),q.createElement(Bv.Provider,{value:e},s)}function The(t,e,n,s){var r;if(e===void 0&&(e=[]),n===void 0&&(n=null),s===void 0&&(s=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=s)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,o=(r=n)==null?void 0:r.errors;if(o!=null){let h=a.findIndex(p=>p.route.id&&(o==null?void 0:o[p.route.id])!==void 0);h>=0||Ba(!1),a=a.slice(0,Math.min(a.length,h+1))}let l=!1,c=-1;if(n&&s&&s.v7_partialHydration)for(let h=0;h<a.length;h++){let p=a[h];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(c=h),p.route.id){let{loaderData:m,errors:y}=n,v=p.route.loader&&m[p.route.id]===void 0&&(!y||y[p.route.id]===void 0);if(p.route.lazy||v){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}return a.reduceRight((h,p,m)=>{let y,v=!1,b=null,S=null;n&&(y=o&&p.route.id?o[p.route.id]:void 0,b=p.route.errorElement||_he,l&&(c<0&&m===0?(Rhe("route-fallback"),v=!0,S=null):c===m&&(v=!0,S=p.route.hydrateFallbackElement||null)));let E=e.concat(a.slice(0,m+1)),I=()=>{let M;return y?M=b:v?M=S:p.route.Component?M=q.createElement(p.route.Component,null):p.route.element?M=p.route.element:M=h,q.createElement(Ehe,{match:p,routeC
67ontext:{outlet:h,matches:E,isDataRoute:n!=null},children:M})};return n&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?q.createElement(She,{location:n.location,revalidation:n.revalidation,component:b,error:y,children:I(),routeContext:{outlet:null,matches:E,isDataRoute:!0}}):I()},null)}var pK=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(pK||{}),mK=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(mK||{});function Ahe(t){let e=q.useContext(XO);return e||Ba(!1),e}function Che(t){let e=q.useContext(ghe);return e||Ba(!1),e}function khe(t){let e=q.useContext(Bv);return e||Ba(!1),e}function gK(t){let e=khe(),n=e.matches[e.matches.length-1];return n.route.id||Ba(!1),n.route.id}function Ihe(){var t;let e=q.useContext(dK),n=Che(),s=gK();return e!==void 0?e:(t=n.errors)==null?void 0:t[s]}function Nhe(){let{router:t}=Ahe(pK.UseNavigateStable),e=gK(mK.UseNavigateStable),n=q.useRef(!1);return hK(()=>{n.current=!0}),q.useCallback(function(r,i){i===void 0&&(i={}),n.current&&(typeof r=="number"?t.navigate(r):t.navigate(r,nE({fromRouteId:e},i)))},[t,e])}const ZB={};function Rhe(t,e,n){ZB[t]||(ZB[t]=!0)}function Mhe(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Gl(t){Ba(!1)}function Phe(t){let{basename:e="/",children:n=null,location:s,navigationType:r=w0.Pop,navigator:i,static:a=!1,future:o}=t;oA()&&Ba(!1);let l=e.replace(/^\/*/,"/"),c=q.useMemo(()=>({basename:l,navigator:i,static:a,future:nE({v7_relativeSplatPath:!1},o)}),[l,o,i,a]);typeof s=="string"&&(s=K1(s));let{pathname:h="/",search:p="",hash:m="",state:y=null,key:v="default"}=s,b=q.useMemo(()=>{let S=YO(h,l);return S==null?null:{location:{pathname:S,search:p,hash:m,state:y,key:v},navigationType:r}},[l,h,p,m,y,v,r]);return b==null?null:q.createElement(jv.Provider,{value:c},q.createElement(QR.Provider,{children:n,value:b}))}function $he(t){let{children:e,location:n}=t;return vhe(I3(e),n)}new Promise(()=>{});function I3(t,e){e===void 0&&(e=[]);let n=[];return q.Children.forEach(t,(s,r)=>{if(!q.isValidElement(s))return;let i=[...e,r];if(s.type===q.Fragment){n.push.apply(n,I3(s.props.children,i));return}s.type!==Gl&&Ba(!1),!s.props.index||!s.props.children||Ba(!1);let a={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(a.children=I3(s.props.children,i)),n.push(a)}),n}/**
68 * React Router DOM v6.30.3
69 *
70 * Copyright (c) Remix Software Inc.
71 *
72 * This source code is licensed under the MIT license found in the
73 * LICENSE.md file in the root directory of this source tree.
74 *
75 * @license MIT
76 */function N3(){return N3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},N3.apply(this,arguments)}function Dhe(t,e){if(t==null)return{};var n={},s=Object.keys(t),r,i;for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&(n[r]=t[r]);return n}function Ohe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Lhe(t,e){return t.button===0&&(!e||e==="_self")&&!Ohe(t)}function R3(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let s=t[n];return e.concat(Array.isArray(s)?s.map(r=>[n,r]):[[n,s]])},[]))}function jhe(t,e){let n=R3(t);return e&&e.forEach((s,r)=>{n.has(r)||e.getAll(r).forEach(i=>{n.append(r,i)})}),n}const Bhe=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Uhe="6";try{window.__reactRouterVersion=Uhe}catch{}const Fhe="startTransition",eU=$de[Fhe];function Vhe(t){let{basename:e,children:n,future:s,window:r}=t,i=q.useRef();i.current==null&&(i.current=zde({window:r,v5Compat:!0}));let a=i.current,[o,l]=q.useState({action:a.action,location:a.location}),{v7_startTransition:c}=s||{},h=q.useCallback(p=>{c&&eU?eU(()=>l(p)):l(p)},[l,c]);return q.useLayoutEffect(()=>a.listen(h),[a,h]),q.useEffect(()=>Mhe(s),[s]),q.createElement(Phe,{basename:e,children:n,location:o.location,navigationType:o.action,navigator:a,future:s})}const zhe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ghe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Is=q.forwardRef(function(e,n){let{onClick:s,relative:r,reloadDocument:i,replace:a,state:o,target:l,to:c,preventScrollReset:h,viewTransition:p}=e,m=Dhe(e,Bhe),{basename:y}=q.useContext(jv),v,b=!1;if(typeof c=="string"&&Ghe.test(c)&&(v=c,zhe))try{let M=new URL(window.location.href),j=c.startsWith("//")?new URL(M.protocol+c):new URL(c),L=YO(j.pathname,y);j.origin===M.origin&&L!=null?c=L+j.search+j.hash:b=!0}catch{}let S=yhe(c,{relative:r}),E=Hhe(c,{replace:a,state:o,target:l,preventScrollReset:h,relative:r,viewTransition:p});function I(M){s&&s(M),M.defaultPrevented||E(M)}return q.createElement("a",N3({},m,{href:v||S,onClick:b||i?s:I,ref:n,target:l}))});var tU;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(tU||(tU={}));var nU;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(nU||(nU={}));function Hhe(t,e){let{target:n,replace:s,state:r,preventScrollReset:i,relative:a,viewTransition:o}=e===void 0?{}:e,l=co(),c=Qh(),h=fK(t,{relative:a});return q.useCallback(p=>{if(Lhe(p,n)){p.preventDefault();let m=s!==void 0?s:bN(c)===bN(h);l(t,{replace:m,state:r,preventScrollReset:i,relative:a,viewTransition:o})}},[c,l,h,s,r,n,t,i,a,o])}function lA(t){let e=q.useRef(R3(t)),n=q.useRef(!1),s=Qh(),r=q.useMemo(()=>jhe(s.search,n.current?null:e.current),[s.search]),i=co(),a=q.useCallback((o,l)=>{const c=R3(typeof o=="function"?o(r):o);n.current=!0,i("?"+c,l)},[i,r]);return[r,a]}const qhe=()=>{};var sU={};/**
77 * @license
78 * Copyright 2017 Google LLC
79 *
80 * Licensed under the Apache License, Version 2.0 (the "License");
81 * you may not use this file except in compliance with the License.
82 * You may obtain a copy of the License at
83 *
84 *   http://www.apache.org/licenses/LICENSE-2.0
85 *
86 * Unless required by applicable law or agreed to in writing, software
87 * distributed under the License is distributed on an "AS IS" BASIS,
88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89 * See the License for the specific language governing permissions and
90 * limitations under the License.
91 */const yK=function(t){const e=[];let n=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);r<128?e[n++]=r:r<2048?(e[n++]=r>>6|192,e[n++]=r&63|128):(r&64512)===55296&&s+1<t.length&&(t.charCodeAt(s+1)&64512)===56320?(r=65536+((r&1023)<<10)+(t.charCodeAt(++s)&1023),e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=r&63|128):(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=r&63|128)}return e},Whe=function(t){const e=[];let n=0,s=0;for(;n<t.length;){const r=t[n++];if(r<128)e[s++]=String.fromCharCode(r);else if(r>191&&r<224){const i=t[n++];e[s++]=String.fromCharCode((r&31)<<6|i&63)}else if(r>239&&r<365){const i=t[n++],a=t[n++],o=t[n++],l=((r&7)<<18|(i&63)<<12|(a&63)<<6|o&63)-65536;e[s++]=String.fromCharCode(55296+(l>>10)),e[s++]=String.fromCharCode(56320+(l&1023))}else{const i=t[n++],a=t[n++];e[s++]=String.fromCharCode((r&15)<<12|(i&63)<<6|a&63)}}return e.join("")},xK={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let r=0;r<t.length;r+=3){const i=t[r],a=r+1<t.length,o=a?t[r+1]:0,l=r+2<t.length,c=l?t[r+2]:0,h=i>>2,p=(i&3)<<4|o>>4;let m=(o&15)<<2|c>>6,y=c&63;l||(y=64,a||(m=64)),s.push(n[h],n[p],n[m],n[y])}return s.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(yK(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):Whe(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let r=0;r<t.length;){const i=n[t.charAt(r++)],o=r<t.length?n[t.charAt(r)]:0;++r;const c=r<t.length?n[t.charAt(r)]:64;++r;const p=r<t.length?n[t.charAt(r)]:64;if(++r,i==null||o==null||c==null||p==null)throw new Khe;const m=i<<2|o>>4;if(s.push(m),c!==64){const y=o<<4&240|c>>2;if(s.push(y),p!==64){const v=c<<6&192|p;s.push(v)}}}return s},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};class Khe extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Yhe=function(t){const e=yK(t);return xK.encodeByteArray(e,!0)},vK=function(t){return Yhe(t).replace(/\./g,"")},bK=function(t){try{return xK.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
92 * @license
93 * Copyright 2022 Google LLC
94 *
95 * Licensed under the Apache License, Version 2.0 (the "License");
96 * you may not use this file except in compliance with the License.
97 * You may obtain a copy of the License at
98 *
99 *   http://www.apache.org/licenses/LICENSE-2.0
100 *
101 * Unless required by applicable law or agreed to in writing, software
102 * distributed under the License is distributed on an "AS IS" BASIS,
103 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104 * See the License for the specific language governing permissions and
105 * limitations under the License.
106 */function Xhe(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
107 * @license
108 * Copyright 2022 Google LLC
109 *
110 * Licensed under the Apache License, Version 2.0 (the "License");
111 * you may not use this file except in compliance with the License.
112 * You may obtain a copy of the License at
113 *
114 *   http://www.apache.org/licenses/LICENSE-2.0
115 *
116 * Unless required by applicable law or agreed to in writing, software
117 * distributed under the License is distributed on an "AS IS" BASIS,
118 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119 * See the License for the specific language governing permissions and
120 * limitations under the License.
121 */const Jhe=()=>Xhe().__FIREBASE_DEFAULTS__,Qhe=()=>{if(typeof process>"u"||typeof sU>"u")return;const t=sU.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},Zhe=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=t&&bK(t[1]);return e&&JSON.parse(e)},ZR=()=>{try{return qhe()||Jhe()||Qhe()||Zhe()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},efe=t=>{var e,n;return(n=(e=ZR())==null?void 0:e.emulatorHosts)==null?void 0:n[t]},wK=()=>{var t;return(t=ZR())==null?void 0:t.config},_K=t=>{var e;return(e=ZR())==null?void 0:e[`_${t}`]};/**
122 * @license
123 * Copyright 2017 Google LLC
124 *
125 * Licensed under the Apache License, Version 2.0 (the "License");
126 * you may not use this file except in compliance with the License.
127 * You may obtain a copy of the License at
128 *
129 *   http://www.apache.org/licenses/LICENSE-2.0
130 *
131 * Unless required by applicable law or agreed to in writing, software
132 * distributed under the License is distributed on an "AS IS" BASIS,
133 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134 * See the License for the specific language governing permissions and
135 * limitations under the License.
136 */class tfe{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}wrapCallback(e){return(n,s)=>{n?this.reject(n):this.resolve(s),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,s))}}}/**
137 * @license
138 * Copyright 2017 Google LLC
139 *
140 * Licensed under the Apache License, Version 2.0 (the "License");
141 * you may not use this file except in compliance with the License.
142 * You may obtain a copy of the License at
143 *
144 *   http://www.apache.org/licenses/LICENSE-2.0
145 *
146 * Unless required by applicable law or agreed to in writing, software
147 * distributed under the License is distributed on an "AS IS" BASIS,
148 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149 * See the License for the specific language governing permissions and
150 * limitations under the License.
151 */function bl(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function nfe(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(bl())}function sfe(){var e;const t=(e=ZR())==null?void 0:e.forceEnvironment;if(t==="node")return!0;if(t==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function rfe(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function ife(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function afe(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function ofe(){const t=bl();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function lfe(){return!sfe()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function cfe(){try{return typeof indexedDB=="object"}catch{return!1}}function ufe(){return new Promise((t,e)=>{try{let n=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(s),t(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var i;e(((i=r.error)==null?void 0:i.message)||"")}}catch(n){e(n)}})}/**
152 * @license
153 * Copyright 2017 Google LLC
154 *
155 * Licensed under the Apache License, Version 2.0 (the "License");
156 * you may not use this file except in compliance with the License.
157 * You may obtain a copy of the License at
158 *
159 *   http://www.apache.org/licenses/LICENSE-2.0
160 *
161 * Unless required by applicable law or agreed to in writing, software
162 * distributed under the License is distributed on an "AS IS" BASIS,
163 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
164 * See the License for the specific language governing permissions and
165 * limitations under the License.
166 */const dfe="FirebaseError";class Fm extends Error{constructor(e,n,s){super(n),this.code=e,this.customData=s,this.name=dfe,Object.setPrototypeOf(this,Fm.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,cA.prototype.create)}}class cA{constructor(e,n,s){this.service=e,this.serviceName=n,this.errors=s}create(e,...n){const s=n[0]||{},r=`${this.service}/${e}`,i=this.errors[e],a=i?hfe(i,s):"Error",o=`${this.serviceName}: ${a} (${r}).`;return new Fm(r,o,s)}}function hfe(t,e){return t.replace(ffe,(n,s)=>{const r=e[s];return r!=null?String(r):`<${s}?>`})}const ffe=/\{\$([^}]+)}/g;function pfe(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function vv(t,e){if(t===e)return!0;const n=Object.keys(t),s=Object.keys(e);for(const r of n){if(!s.includes(r))return!1;const i=t[r],a=e[r];if(rU(i)&&rU(a)){if(!vv(i,a))return!1}else if(i!==a)return!1}for(const r of s)if(!n.includes(r))return!1;return!0}function rU(t){return t!==null&&typeof t=="object"}/**
167 * @license
168 * Copyright 2017 Google LLC
169 *
170 * Licensed under the Apache License, Version 2.0 (the "License");
171 * you may not use this file except in compliance with the License.
172 * You may obtain a copy of the License at
173 *
174 *   http://www.apache.org/licenses/LICENSE-2.0
175 *
176 * Unless required by applicable law or agreed to in writing, software
177 * distributed under the License is distributed on an "AS IS" BASIS,
178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179 * See the License for the specific language governing permissions and
180 * limitations under the License.
181 */function uA(t){const e=[];for(const[n,s]of Object.entries(t))Array.isArray(s)?s.forEach(r=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(r))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}function mfe(t,e){const n=new gfe(t,e);return n.subscribe.bind(n)}class gfe{constructor(e,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{e(this)}).catch(s=>{this.error(s)})}next(e){this.forEachObserver(n=>{n.next(e)})}error(e){this.forEachObserver(n=>{n.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,n,s){let r;if(e===void 0&&n===void 0&&s===void 0)throw new Error("Missing Observer.");yfe(e,["next","error","complete"])?r=e:r={next:e,error:n,complete:s},r.next===void 0&&(r.next=v4),r.error===void 0&&(r.error=v4),r.complete===void 0&&(r.complete=v4);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch{}}),this.observers.push(r),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let n=0;n<this.observers.length;n++)this.sendOne(n,e)}sendOne(e,n){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{n(this.observers[e])}catch(s){typeof console<"u"&&console.error&&console.error(s)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function yfe(t,e){if(typeof t!="object"||t===null)return!1;for(const n of e)if(n in t&&typeof t[n]=="function")return!0;return!1}function v4(){}/**
182 * @license
183 * Copyright 2021 Google LLC
184 *
185 * Licensed under the Apache License, Version 2.0 (the "License");
186 * you may not use this file except in compliance with the License.
187 * You may obtain a copy of the License at
188 *
189 *   http://www.apache.org/licenses/LICENSE-2.0
190 *
191 * Unless required by applicable law or agreed to in writing, software
192 * distributed under the License is distributed on an "AS IS" BASIS,
193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194 * See the License for the specific language governing permissions and
195 * limitations under the License.
196 */function qo(t){return t&&t._delegate?t._delegate:t}/**
197 * @license
198 * Copyright 2025 Google LLC
199 *
200 * Licensed under the Apache License, Version 2.0 (the "License");
201 * you may not use this file except in compliance with the License.
202 * You may obtain a copy of the License at
203 *
204 *   http://www.apache.org/licenses/LICENSE-2.0
205 *
206 * Unless required by applicable law or agreed to in writing, software
207 * distributed under the License is distributed on an "AS IS" BASIS,
208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209 * See the License for the specific language governing permissions and
210 * limitations under the License.
211 */function dA(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function SK(t){return(await fetch(t,{credentials:"include"})).ok}class bv{constructor(e,n,s){this.name=e,this.instanceFactory=n,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
212 * @license
213 * Copyright 2019 Google LLC
214 *
215 * Licensed under the Apache License, Version 2.0 (the "License");
216 * you may not use this file except in compliance with the License.
217 * You may obtain a copy of the License at
218 *
219 *   http://www.apache.org/licenses/LICENSE-2.0
220 *
221 * Unless required by applicable law or agreed to in writing, software
222 * distributed under the License is distributed on an "AS IS" BASIS,
223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224 * See the License for the specific language governing permissions and
225 * limitations under the License.
226 */const Fy="[DEFAULT]";/**
227 * @license
228 * Copyright 2019 Google LLC
229 *
230 * Licensed under the Apache License, Version 2.0 (the "License");
231 * you may not use this file except in compliance with the License.
232 * You may obtain a copy of the License at
233 *
234 *   http://www.apache.org/licenses/LICENSE-2.0
235 *
236 * Unless required by applicable law or agreed to in writing, software
237 * distributed under the License is distributed on an "AS IS" BASIS,
238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239 * See the License for the specific language governing permissions and
240 * limitations under the License.
241 */class xfe{constructor(e,n){this.name=e,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){const s=new tfe;if(this.instancesDeferred.set(n,s),this.isInitialized(n)||this.shouldAutoInitialize())try{const r=this.getOrInitializeService({instanceIdentifier:n});r&&s.resolve(r)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){const n=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(e==null?void 0:e.optional)??!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(r){if(s)return null;throw r}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(bfe(e))try{this.getOrInitializeService({instanceIdentifier:Fy})}catch{}for(const[n,s]of this.instancesDeferred.entries()){const r=this.normalizeInstanceIdentifier(n);try{const i=this.getOrInitializeService({instanceIdentifier:r});s.resolve(i)}catch{}}}}clearInstance(e=Fy){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...e.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Fy){return this.instances.has(e)}getOptions(e=Fy){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:n={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:s,options:n});for(const[i,a]of this.instancesDeferred.entries()){const o=this.normalizeInstanceIdentifier(i);s===o&&a.resolve(r)}return r}onInit(e,n){const s=this.normalizeInstanceIdentifier(n),r=this.onInitCallbacks.get(s)??new Set;r.add(e),this.onInitCallbacks.set(s,r);const i=this.instances.get(s);return i&&e(i,s),()=>{r.delete(e)}}invokeOnInitCallbacks(e,n){const s=this.onInitCallbacks.get(n);if(s)for(const r of s)try{r(e,n)}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:vfe(e),options:n}),this.instances.set(e,s),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}return s||null}normalizeInstanceIdentifier(e=Fy){return this.component?this.component.multipleInstances?e:Fy:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function vfe(t){return t===Fy?void 0:t}function bfe(t){return t.instantiationMode==="EAGER"}/**
242 * @license
243 * Copyright 2019 Google LLC
244 *
245 * Licensed under the Apache License, Version 2.0 (the "License");
246 * you may not use this file except in compliance with the License.
247 * You may obtain a copy of the License at
248 *
249 *   http://www.apache.org/licenses/LICENSE-2.0
250 *
251 * Unless required by applicable law or agreed to in writing, software
252 * distributed under the License is distributed on an "AS IS" BASIS,
253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254 * See the License for the specific language governing permissions and
255 * limitations under the License.
256 */class wfe{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const n=this.getProvider(e.name);if(n.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);n.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const n=new xfe(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}}/**
257 * @license
258 * Copyright 2017 Google LLC
259 *
260 * Licensed under the Apache License, Version 2.0 (the "License");
261 * you may not use this file except in compliance with the License.
262 * You may obtain a copy of the License at
263 *
264 *   http://www.apache.org/licenses/LICENSE-2.0
265 *
266 * Unless required by applicable law or agreed to in writing, software
267 * distributed under the License is distributed on an "AS IS" BASIS,
268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
269 * See the License for the specific language governing permissions and
270 * limitations under the License.
271 */var pr;(function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"})(pr||(pr={}));const _fe={debug:pr.DEBUG,verbose:pr.VERBOSE,info:pr.INFO,warn:pr.WARN,error:pr.ERROR,silent:pr.SILENT},Sfe=pr.INFO,Efe={[pr.DEBUG]:"log",[pr.VERBOSE]:"log",[pr.INFO]:"info",[pr.WARN]:"warn",[pr.ERROR]:"error"},Tfe=(t,e,...n)=>{if(e<t.logLevel)return;const s=new Date().toISOString(),r=Efe[e];if(r)console[r](`[${s}]  ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class JO{constructor(e){this.name=e,this._logLevel=Sfe,this._logHandler=Tfe,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in pr))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?_fe[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,pr.DEBUG,...e),this._logHandler(this,pr.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,pr.VERBOSE,...e),this._logHandler(this,pr.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,pr.INFO,...e),this._logHandler(this,pr.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,pr.WARN,...e),this._logHandler(this,pr.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,pr.ERROR,...e),this._logHandler(this,pr.ERROR,...e)}}const Afe=(t,e)=>e.some(n=>t instanceof n);let iU,aU;function Cfe(){return iU||(iU=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kfe(){return aU||(aU=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const EK=new WeakMap,M3=new WeakMap,TK=new WeakMap,b4=new WeakMap,QO=new WeakMap;function Ife(t){const e=new Promise((n,s)=>{const r=()=>{t.removeEventListener("success",i),t.removeEventListener("error",a)},i=()=>{n(k0(t.result)),r()},a=()=>{s(t.error),r()};t.addEventListener("success",i),t.addEventListener("error",a)});return e.then(n=>{n instanceof IDBCursor&&EK.set(n,t)}).catch(()=>{}),QO.set(e,t),e}function Nfe(t){if(M3.has(t))return;const e=new Promise((n,s)=>{const r=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",a),t.removeEventListener("abort",a)},i=()=>{n(),r()},a=()=>{s(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",i),t.addEventListener("error",a),t.addEventListener("abort",a)});M3.set(t,e)}let P3={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return M3.get(t);if(e==="objectStoreNames")return t.objectStoreNames||TK.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return k0(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Rfe(t){P3=t(P3)}function Mfe(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const s=t.call(w4(this),e,...n);return TK.set(s,e.sort?e.sort():[e]),k0(s)}:kfe().includes(t)?function(...e){return t.apply(w4(this),e),k0(EK.get(this))}:function(...e){return k0(t.apply(w4(this),e))}}function Pfe(t){return typeof t=="function"?Mfe(t):(t instanceof IDBTransaction&&Nfe(t),Afe(t,Cfe())?new Proxy(t,P3):t)}function k0(t){if(t instanceof IDBRequest)return Ife(t);if(b4.has(t))return b4.get(t);const e=Pfe(t);return e!==t&&(b4.set(t,e),QO.set(e,t)),e}const w4=t=>QO.get(t);function $fe(t,e,{blocked:n,upgrade:s,blocking:r,terminated:i}={}){const a=indexedDB.open(t,e),o=k0(a);return s&&a.addEventListener("upgradeneeded",l=>{s(k0(a.result),l.oldVersion,l.newVersion,k0(a.transaction),l)}),n&&a.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),o.then(l=>{i&&l.addEventListener("close",()=>i()),r&&l.addEventListener("versionchange",c=>r(c.oldVersion,c.newVersion,c))}).catch(()=>{}),o}const Dfe=["get","getKey","getAll","getAllKeys","count"],Ofe=["put","add","delete","clear"],_4=new Map;function oU(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(_4.get(e))return _4.get(e);const n=e.replace(/FromIndex$/,""),s=e!==n,r=Ofe.includes(n);if(!(n in(s?IDBIndex:IDBObjectStore).prototype)||!(r||Dfe.includes(n)))return;const i=async function(a,...o){const l=this.transaction(a,r?"readwrite":"readonly");let c=l.store;
271return s&&(c=c.index(o.shift())),(await Promise.all([c[n](...o),r&&l.done]))[0]};return _4.set(e,i),i}Rfe(t=>({...t,get:(e,n,s)=>oU(e,n)||t.get(e,n,s),has:(e,n)=>!!oU(e,n)||t.has(e,n)}));/**
272 * @license
273 * Copyright 2019 Google LLC
274 *
275 * Licensed under the Apache License, Version 2.0 (the "License");
276 * you may not use this file except in compliance with the License.
277 * You may obtain a copy of the License at
278 *
279 *   http://www.apache.org/licenses/LICENSE-2.0
280 *
281 * Unless required by applicable law or agreed to in writing, software
282 * distributed under the License is distributed on an "AS IS" BASIS,
283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284 * See the License for the specific language governing permissions and
285 * limitations under the License.
286 */class Lfe{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(jfe(n)){const s=n.getImmediate();return`${s.library}/${s.version}`}else return null}).filter(n=>n).join(" ")}}function jfe(t){const e=t.getComponent();return(e==null?void 0:e.type)==="VERSION"}const $3="@firebase/app",lU="0.14.11";/**
287 * @license
288 * Copyright 2019 Google LLC
289 *
290 * Licensed under the Apache License, Version 2.0 (the "License");
291 * you may not use this file except in compliance with the License.
292 * You may obtain a copy of the License at
293 *
294 *   http://www.apache.org/licenses/LICENSE-2.0
295 *
296 * Unless required by applicable law or agreed to in writing, software
297 * distributed under the License is distributed on an "AS IS" BASIS,
298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299 * See the License for the specific language governing permissions and
300 * limitations under the License.
301 */const Mm=new JO("@firebase/app"),Bfe="@firebase/app-compat",Ufe="@firebase/analytics-compat",Ffe="@firebase/analytics",Vfe="@firebase/app-check-compat",zfe="@firebase/app-check",Gfe="@firebase/auth",Hfe="@firebase/auth-compat",qfe="@firebase/database",Wfe="@firebase/data-connect",Kfe="@firebase/database-compat",Yfe="@firebase/functions",Xfe="@firebase/functions-compat",Jfe="@firebase/installations",Qfe="@firebase/installations-compat",Zfe="@firebase/messaging",epe="@firebase/messaging-compat",tpe="@firebase/performance",npe="@firebase/performance-compat",spe="@firebase/remote-config",rpe="@firebase/remote-config-compat",ipe="@firebase/storage",ape="@firebase/storage-compat",ope="@firebase/firestore",lpe="@firebase/ai",cpe="@firebase/firestore-compat",upe="firebase",dpe="12.12.0";/**
302 * @license
303 * Copyright 2019 Google LLC
304 *
305 * Licensed under the Apache License, Version 2.0 (the "License");
306 * you may not use this file except in compliance with the License.
307 * You may obtain a copy of the License at
308 *
309 *   http://www.apache.org/licenses/LICENSE-2.0
310 *
311 * Unless required by applicable law or agreed to in writing, software
312 * distributed under the License is distributed on an "AS IS" BASIS,
313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
314 * See the License for the specific language governing permissions and
315 * limitations under the License.
316 */const D3="[DEFAULT]",hpe={[$3]:"fire-core",[Bfe]:"fire-core-compat",[Ffe]:"fire-analytics",[Ufe]:"fire-analytics-compat",[zfe]:"fire-app-check",[Vfe]:"fire-app-check-compat",[Gfe]:"fire-auth",[Hfe]:"fire-auth-compat",[qfe]:"fire-rtdb",[Wfe]:"fire-data-connect",[Kfe]:"fire-rtdb-compat",[Yfe]:"fire-fn",[Xfe]:"fire-fn-compat",[Jfe]:"fire-iid",[Qfe]:"fire-iid-compat",[Zfe]:"fire-fcm",[epe]:"fire-fcm-compat",[tpe]:"fire-perf",[npe]:"fire-perf-compat",[spe]:"fire-rc",[rpe]:"fire-rc-compat",[ipe]:"fire-gcs",[ape]:"fire-gcs-compat",[ope]:"fire-fst",[cpe]:"fire-fst-compat",[lpe]:"fire-vertex","fire-js":"fire-js",[upe]:"fire-js-all"};/**
317 * @license
318 * Copyright 2019 Google LLC
319 *
320 * Licensed under the Apache License, Version 2.0 (the "License");
321 * you may not use this file except in compliance with the License.
322 * You may obtain a copy of the License at
323 *
324 *   http://www.apache.org/licenses/LICENSE-2.0
325 *
326 * Unless required by applicable law or agreed to in writing, softw
326are
327 * distributed under the License is distributed on an "AS IS" BASIS,
328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329 * See the License for the specific language governing permissions and
330 * limitations under the License.
331 */const wN=new Map,fpe=new Map,O3=new Map;function cU(t,e){try{t.container.addComponent(e)}catch(n){Mm.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function N1(t){const e=t.name;if(O3.has(e))return Mm.debug(`There were multiple attempts to register component ${e}.`),!1;O3.set(e,t);for(const n of wN.values())cU(n,t);for(const n of fpe.values())cU(n,t);return!0}function ZO(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function Fh(t){return t==null?!1:t.settings!==void 0}/**
332 * @license
333 * Copyright 2019 Google LLC
334 *
335 * Licensed under the Apache License, Version 2.0 (the "License");
336 * you may not use this file except in compliance with the License.
337 * You may obtain a copy of the License at
338 *
339 *   http://www.apache.org/licenses/LICENSE-2.0
340 *
341 * Unless required by applicable law or agreed to in writing, software
342 * distributed under the License is distributed on an "AS IS" BASIS,
343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344 * See the License for the specific language governing permissions and
345 * limitations under the License.
346 */const ppe={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invali
346d-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},I0=new cA("app","Firebase",ppe);/**
347 * @license
348 * Copyright 2019 Google LLC
349 *
350 * Licensed under the Apache License, Version 2.0 (the "License");
351 * you may not use this file except in compliance with the License.
352 * You may obtain a copy of the License at
353 *
354 *   http://www.apache.org/licenses/LICENSE-2.0
355 *
356 * Unless required by applicable law or agreed to in writing, software
357 * distributed under the License is distributed on an "AS IS" BASIS,
358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359 * See the License for the specific language governing permissions and
360 * limitations under the License.
361 */class mpe{constructor(e,n,s){this._isDeleted=!1,this._options={...e},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new bv("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw I0.create("app-deleted",{appName:this._name})}}/**
362 * @license
363 * Copyright 2019 Google LLC
364 *
365 * Licensed under the Apache License, Version 2.0 (the "License");
366 * you may not use this file except in compliance with the License.
367 * You may obtain a copy of the License at
368 *
369 *   http://www.apache.org/licenses/LICENSE-2.0
370 *
371 * Unless required by applicable law or agreed to in writing, software
372 * distributed under the License is distributed on an "AS IS" BASIS,
373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374 * See the License for the specific language governing permissions and
375 * limitations under the License.
376 */const Y1=dpe;function AK(t,e={}){let n=t;typeof e!="object"&&(e={name:e});const s={name:D3,automaticDataCollectionEnabled:!0,...e},r=s.name;if(typeof r!="string"||!r)throw I0.create("bad-app-name",{appName:String(r)});if(n||(n=wK()),!n)throw I0.create("no-options");const i=wN.get(r);if(i){if(vv(n,i.options)&&vv(s,i.config))return i;throw I0.create("duplicate-app",{appName:r})}const a=new wfe(r);for(const l of O3.values())a.addComponent(l);const o=new mpe(n,s,a);return wN.set(r,o),o}function gpe(t=D3){const e=wN.get(t);if(!e&&t===D3&&wK())return AK();if(!e)throw I0.create("no-app",{appName:t});return e}function N0(t,e,n){let s=hpe[t]??t;n&&(s+=`-${n}`);const r=s.match(/\s|\//),i=e.match(/\s|\//);if(r||i){const a=[`Unable to register library "${s}" with version "${e}":`];r&&a.push(`library name "${s}" contains illegal characters (whitespace or "/")`),r&&i&&a.push("and"),i&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Mm.warn(a.join(" "));return}N1(new bv(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}/**
377 * @license
378 * Copyright 2021 Google LLC
379 *
380 * Licensed under the Apache License, Version 2.0 (the "License");
381 * you may not use this file except in compliance with the License.
382 * You may obtain a copy of the License at
383 *
384 *   http://www.apache.org/licenses/LICENSE-2.0
385 *
386 * Unless required by applicable law or agreed to in writing, softw
386are
387 * distributed under the License is distributed on an "AS IS" BASIS,
388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
389 * See the License for the specific language governing permissions and
390 * limitations under the License.
391 */const ype="firebase-heartbeat-database",xpe=1,sE="firebase-heartbeat-store";let S4=null;function CK(){return S4||(S4=$fe(ype,xpe,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(sE)}catch(n){console.warn(n)}}}}).catch(t=>{throw I0.create("idb-open",{originalErrorMessage:t.message})})),S4}async function vpe(t){try{const n=(await CK()).transaction(sE),s=await n.objectStore(sE).get(kK(t));return await n.done,s}catch(e){if(e instanceof Fm)Mm.warn(e.message);else{const n=I0.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});Mm.warn(n.message)}}}async function uU(t,e){try{const s=(await CK()).transaction(sE,"readwrite");await s.objectStore(sE).put(e,kK(t)),await s.done}catch(n){if(n instanceof Fm)Mm.warn(n.message);else{const s=I0.create("idb-set",{originalErrorMessage:n==null?void 0:n.message});Mm.warn(s.message)}}}function kK(t){return`${t.name}!${t.options.appId}`}/**
392 * @license
393 * Copyright 2021 Google LLC
394 *
395 * Licensed under the Apache License, Version 2.0 (the "License");
396 * you may not use this file except in compliance with the License.
397 * You may obtain a copy of the License at
398 *
399 *   http://www.apache.org/licenses/LICENSE-2.0
400 *
401 * Unless required by applicable law or agreed to in writing, software
402 * distributed under the License is distributed on an "AS IS" BASIS,
403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404 * See the License for the specific language governing permissions and
405 * limitations under the License.
406 */const bpe=1024,wpe=30;class _pe{constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new Epe(n),this._heartbeatsCachePromise=this._storage.read().then(s=>(this._heartbeatsCache=s,s))}async triggerHeartbeat(){var e,n;try{const r=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=dU();if(((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((n=this._heartbeatsCache)==null?void 0:n.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(a=>a.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:r}),this._heartbeatsCache.heartbeats.length>wpe){const a=Tpe(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(a,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(s){Mm.warn(s)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const n=dU(),{heartbeatsToSend:s,unsentEntries:r}=Spe(this._heartbeatsCache.heartbeats),i=vK(JSON.stringify({version:2,heartbeats:s}));return this._heartbeatsCache.lastSentHeartbeatDate=n,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(n){return Mm.warn(n),""}}}function dU(){return new Date().toISOString().substring(0,10)}function Spe(t,e=bpe){const n=[];let s=t.slice();for(const r of t){const i=n.find(a=>a.agent===r.agent);if(i){if(i.dates.push(r.date),hU(n)>e){i.dates.pop();break}}else if(n.push({agent:r.agent,dates:[r.date]}),hU(n)>e){n.pop();break}s=s.slice(1)}return{heartbeatsToSend:n,unsentEntries:s}}class Epe{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return cfe()?ufe().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await vpe(this.app);return n!=null&&n.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const s=await this.read();return uU(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const s=await this.read();return uU(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function hU(t){return vK(JSON.stringify({version:2,heartbeats:t})).length}function Tpe(t){if(t.length===0)return-1;let e=0,n=t[0].date;for(let s=1;s<t.length;s++)t[s].date<n&&(n=t[s].date,e=s);return e}/**
407 * @license
408 * Copyright 2019 Google LLC
409 *
410 * Licensed under the Apache License, Version 2.0 (the "License");
411 * you may not use this file except in compliance with the License.
412 * You may obtain a copy of the License at
413 *
414 *   http://www.apache.org/licenses/LICENSE-2.0
415 *
416 * Unless required by applicable law or agreed to in writing, software
417 * distributed under the License is distributed on an "AS IS" BASIS,
418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419 * See the License for the specific language governing permissions and
420 * limitations under the License.
421 */function Ape(t){N1(new bv("platform-logger",e=>new Lfe(e),"PRIVATE")),N1(new bv("heartbeat",e=>new _pe(e),"PRIVATE")),N0($3,lU,t),N0($3,lU,"esm2020"),N0("fire-js","")}Ape("");function IK(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const Cpe=IK,NK=new cA("auth","Firebase",IK());/**
422 * @license
423 * Copyright 2020 Google LLC
424 *
425 * Licensed under the Apache License, Version 2.0 (the "License");
426 * you may not use this file except in compliance with the License.
427 * You may obtain a copy of the License at
428 *
429 *   http://www.apache.org/licenses/LICENSE-2.0
430 *
431 * Unless required by applicable law or agreed to in writing, software
432 * distributed under the License is distributed on an "AS IS" BASIS,
433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
434 * See the License for the specific language governing permissions and
435 * limitations under the License.
436 */const _N=new JO("@firebase/auth");function kpe(t,...e){_N.logLevel<=pr.WARN&&_N.warn(`Auth (${Y1}): ${t}`,...e)}function dI(t,...e){_N.logLevel<=pr.ERROR&&_N.error(`Auth (${Y1}): ${t}`,...e)}/**
437 * @license
438 * Copyright 2020 Google LLC
439 *
440 * Licensed under the Apache License, Version 2.0 (the "License");
441 * you may not use this file except in compliance with the License.
442 * You may obtain a copy of the License at
443 *
444 *   http://www.apache.org/licenses/LICENSE-2.0
445 *
446 * Unless required by applicable law or agreed to in writing, software
447 * distributed under the License is distributed on an "AS IS" BASIS,
448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
449 * See the License for the specific language governing permissions and
450 * limitations under the License.
451 */function hp(t,...e){throw tL(t,...e)}function Hh(t,...e){return tL(t,...e)}function eL(t,e,n){const s={...Cpe(),[e]:n};return new cA("auth","Firebase",s).create(e,{appName:t.name})}function dv(t){return eL(t,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Ipe(t,e,n){const s=n;
451if(!(e instanceof s))throw s.name!==e.constructor.name&&hp(t,"argument-error"),eL(t,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function tL(t,...e){if(typeof t!="string"){const n=e[0],s=[...e.slice(1)];return s[0]&&(s[0].appName=t.name),t._errorFactory.create(n,...s)}return NK.create(t,...e)}function Es(t,e,...n){if(!t)throw tL(e,...n)}function Cm(t){const e="INTERNAL ASSERTION FAILED: "+t;throw dI(e),new Error(e)}function Pm(t,e){t||Cm(e)}/**
452 * @license
453 * Copyright 2020 Google LLC
454 *
455 * Licensed under the Apache License, Version 2.0 (the "License");
456 * you may not use this file except in compliance with the License.
457 * You may obtain a copy of the License at
458 *
459 *   http://www.apache.org/licenses/LICENSE-2.0
460 *
461 * Unless required by applicable law or agreed to in writing, software
462 * distributed under the License is distributed on an "AS IS" BASIS,
463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464 * See the License for the specific language governing permissions and
465 * limitations under the License.
466 */function L3(){var t;return typeof self<"u"&&((t=self.location)==null?void 0:t.href)||""}function Npe(){return fU()==="http:"||fU()==="https:"}function fU(){var t;return typeof self<"u"&&((t=self.location)==null?void 0:t.protocol)||null}/**
467 * @license
468 * Copyright 2020 Google LLC
469 *
470 * Licensed under the Apache License, Version 2.0 (the "License");
471 * you may not use this file except in compliance with the License.
472 * You may obtain a copy of the License at
473 *
474 *   http://www.apache.org/licenses/LICENSE-2.0
475 *
476 * Unless required by applicable law or agreed to in writing, software
477 * distributed under the License is distributed on an "AS IS" BASIS,
478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
479 * See the License for the specific language governing permissions and
480 * limitations under the License.
481 */function Rpe(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(Npe()||ife()||"connection"in navigator)?navigator.onLine:!0}function Mpe(){if(typeof navigator>"u")return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}/**
482 * @license
483 * Copyright 2020 Google LLC
484 *
485 * Licensed under the Apache License, Version 2.0 (the "License");
486 * you may not use this file except in compliance with the License.
487 * You may obtain a copy of the License at
488 *
489 *   http://www.apache.org/licenses/LICENSE-2.0
490 *
491 * Unless required by applicable law or agreed to in writing, software
492 * distributed under the License is distributed on an "AS IS" BASIS,
493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494 * See the License for the specific language governing permissions and
495 * limitations under the License.
496 */class hA{constructor(e,n){this.shortDelay=e,this.longDelay=n,Pm(n>e,"Short delay should be less than long delay!"),this.isMobile=nfe()||afe()}get(){return Rpe()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
497 * @license
498 * Copyright 2020 Google LLC
499 *
500 * Licensed under the Apache License, Version 2.0 (the "License");
501 * you may not use this file except in compliance with the License.
502 * You may obtain a copy of the License at
503 *
504 *   http://www.apache.org/licenses/LICENSE-2.0
505 *
506 * Unless required by applicable law or agreed to in writing, software
507 * distributed under the License is distributed on an "AS IS" BASIS,
508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509 * See the License for the specific language governing permissions and
510 * limitations under the License.
511 */function nL(t,e){Pm(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}/**
512 * @license
513 * Copyright 2020 Google LLC
514 *
515 * Licensed under the Apache License, Version 2.0 (the "License");
516 * you may not use this file except in compliance with the License.
517 * You may obtain a copy of the License at
518 *
519 *   http://www.apache.org/licenses/LICENSE-2.0
520 *
521 * Unless required by applicable law or agreed to in writing, softw
521are
522 * distributed under the License is distributed on an "AS IS" BASIS,
523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524 * See the License for the specific language governing permissions and
525 * limitations under the License.
526 */class RK{static initialize(e,n,s){this.fetchImpl=e,n&&(this.headersImpl=n),s&&(this.responseImpl=s)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;Cm("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;Cm("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;Cm("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
527 * @license
528 * Copyright 2020 Google LLC
529 *
530 * Licensed under the Apache License, Version 2.0 (the "License");
531 * you may not use this file except in compliance with the License.
532 * You may obtain a copy of the License at
533 *
534 *   http://www.apache.org/licenses/LICENSE-2.0
535 *
536 * Unless required by applicable law or agreed to in writing, software
537 * distributed under the License is distributed on an "AS IS" BASIS,
538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539 * See the License for the specific language governing permissions and
540 * limitations under the License.
541 */const Ppe={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-rec
541aptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/**
542 * @license
543 * Copyright 2020 Google LLC
544 *
545 * Licensed under the Apache License, Version 2.0 (the "License");
546 * you may not use this file except in compliance with the License.
547 * You may obtain a copy of the License at
548 *
549 *   http://www.apache.org/licenses/LICENSE-2.0
550 *
551 * Unless required by applicable law or agreed to in writing, software
552 * distributed under the License is distributed on an "AS IS" BASIS,
553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
554 * See the License for the specific language governing permissions and
555 * limitations under the License.
556 */const $pe=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Dpe=new hA(3e4,6e4);function sL(t,e){return t.tenantId&&!e.tenantId?{...e,tenantId:t.tenantId}:e}async function X1(t,e,n,s,r={}){return MK(t,r,async()=>{let i={},a={};s&&(e==="GET"?a=s:i={body:JSON.stringify(s)});const o=uA({key:t.config.apiKey,...a}).slice(1),l=await t._getAdditionalHeaders();l["Content-Type"]="application/json",t.languageCode&&(l["X-Firebase-Locale"]=t.languageCode);const c={method:e,headers:l,...i};return rfe()||(c.referrerPolicy="no-referrer"),t.emulatorConfig&&dA(t.emulatorConfig.host)&&(c.credentials="include"),RK.fetch()(await PK(t,t.config.apiHost,n,o),c)})}async function MK(t,e,n){t._canInitEmulator=!1;const s={...Ppe,...e};try{const r=new Lpe(t),i=await Promise.race([n(),r.promise]);r.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw Ak(t,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const o=i.ok?a.errorMessage:a.error.message,[l,c]=o.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw Ak(t,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw Ak(t,"email-already-in-use",a);if(l==="USER_DISABLED")throw Ak(t,"user-disabled",a);const h=s[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(c)throw eL(t,h,c);hp(t,h)}}catch(r){if(r instanceof Fm)throw r;hp(t,"network-request-failed",{message:String(r)})}}async function Ope(t,e,n,s,r={}){const i=await X1(t,e,n,s,r);return"mfaPendingCredential"in i&&hp(t,"multi-factor-auth-required",{_serverResponse:i}),i}async function PK(t,e,n,s){const r=`${e}${n}?${s}`,i=t,a=i.config.emulator?nL(t.config,r):`${t.config.apiScheme}://${r}`;return $pe.includes(n)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(a).toString():a}class Lpe{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((n,s)=>{this.timer=setTimeout(()=>s(Hh(this.auth,"network-request-failed")),Dpe.get())})}}function Ak(t,e,n){const s={appName:t.name};n.email&&(s.email=n.email),n.phoneNumber&&(s.phoneNumber=n.phoneNumber);const r=Hh(t,e,s);return r.customData._tokenResponse=n,r}/**
557 * @license
558 * Copyright 2020 Google LLC
559 *
560 * Licensed under the Apache License, Version 2.0 (the "License");
561 * you may not use this file except in compliance with the License.
562 * You may obtain a copy of the License at
563 *
564 *   http://www.apache.org/licenses/LICENSE-2.0
565 *
566 * Unless required by applicable law or agreed to in writing, software
567 * distributed under the License is distributed on an "AS IS" BASIS,
568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
569 * See the License for the specific language governing permissions and
570 * limitations under the License.
571 */async function jpe(t,e){return X1(t,"POST","/v1/accounts:delete",e)}async function SN(t,e){return X1(t,"POST","/v1/accounts:lookup",e)}/**
572 * @license
573 * Copyright 2020 Google LLC
574 *
575 * Licensed under the Apache License, Version 2.0 (the "License");
576 * you may not use this file except in compliance with the License.
577 * You may obtain a copy of the License at
578 *
579 *   http://www.apache.org/licenses/LICENSE-2.0
580 *
581 * Unless required by applicable law or agreed to in writing, softw
581are
582 * distributed under the License is distributed on an "AS IS" BASIS,
583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
584 * See the License for the specific language governing permissions and
585 * limitations under the License.
586 */function PS(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function Bpe(t,e=!1){const n=qo(t),s=await n.getIdToken(e),r=rL(s);Es(r&&r.exp&&r.auth_time&&r.iat,n.auth,"internal-error");const i=typeof r.firebase=="object"?r.firebase:void 0,a=i==null?void 0:i.sign_in_provider;return{claims:r,token:s,authTime:PS(E4(r.auth_time)),issuedAtTime:PS(E4(r.iat)),expirationTime:PS(E4(r.exp)),signInProvider:a||null,signInSecondFactor:(i==null?void 0:i.sign_in_second_factor)||null}}function E4(t){return Number(t)*1e3}function rL(t){const[e,n,s]=t.split(".");if(e===void 0||n===void 0||s===void 0)return dI("JWT malformed, contained fewer than 3 sections"),null;try{const r=bK(n);return r?JSON.parse(r):(dI("Failed to decode base64 JWT payload"),null)}catch(r){return dI("Caught error parsing JWT payload as JSON",r==null?void 0:r.toString()),null}}function pU(t){const e=rL(t);return Es(e,"internal-error"),Es(typeof e.exp<"u","internal-error"),Es(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
587 * @license
588 * Copyright 2020 Google LLC
589 *
590 * Licensed under the Apache License, Version 2.0 (the "License");
591 * you may not use this file except in compliance with the License.
592 * You may obtain a copy of the License at
593 *
594 *   http://www.apache.org/licenses/LICENSE-2.0
595 *
596 * Unless required by applicable law or agreed to in writing, software
597 * distributed under the License is distributed on an "AS IS" BASIS,
598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599 * See the License for the specific language governing permissions and
600 * limitations under the License.
601 */async function rE(t,e,n=!1){if(n)return e;try{return await e}catch(s){throw s instanceof Fm&&Upe(s)&&t.auth.currentUser===t&&await t.auth.signOut(),s}}function Upe({code:t}){return t==="auth/user-disabled"||t==="auth/user-token-expired"}/**
602 * @license
603 * Copyright 2020 Google LLC
604 *
605 * Licensed under the Apache License, Version 2.0 (the "License");
606 * you may not use this file except in compliance with the License.
607 * You may obtain a copy of the License at
608 *
609 *   http://www.apache.org/licenses/LICENSE-2.0
610 *
611 * Unless required by applicable law or agreed to in writing, software
612 * distributed under the License is distributed on an "AS IS" BASIS,
613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
614 * See the License for the specific language governing permissions and
615 * limitations under the License.
616 */class Fpe{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const n=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),n}else{this.errorBackoff=3e4;const s=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,s)}}schedule(e=!1){if(!this.isRunning)return;const n=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},n)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
617 * @license
618 * Copyright 2020 Google LLC
619 *
620 * Licensed under the Apache License, Version 2.0 (the "License");
621 * you may not use this file except in compliance with the License.
622 * You may obtain a copy of the License at
623 *
624 *   http://www.apache.org/licenses/LICENSE-2.0
625 *
626 * Unless required by applicable law or agreed to in writing, software
627 * distributed under the License is distributed on an "AS IS" BASIS,
628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629 * See the License for the specific language governing permissions and
630 * limitations under the License.
631 */class j3{constructor(e,n){this.createdAt=e,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=PS(this.lastLoginAt),this.creationTime=PS(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
632 * @license
633 * Copyright 2019 Google LLC
634 *
635 * Licensed under the Apache License, Version 2.0 (the "License");
636 * you may not use this file except in compliance with the License.
637 * You may obtain a copy of the License at
638 *
639 *   http://www.apache.org/licenses/LICENSE-2.0
640 *
641 * Unless required by applicable law or agreed to in writing, software
642 * distributed under the License is distributed on an "AS IS" BASIS,
643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
644 * See the License for the specific language governing permissions and
645 * limitations under the License.
646 */async function EN(t){var p;const e=t.auth,n=await t.getIdToken(),s=await rE(t,SN(e,{idToken:n}));Es(s==null?void 0:s.users.length,e,"internal-error");const r=s.users[0];t._notifyReloadListener(r);const i=(p=r.providerUserInfo)!=null&&p.length?$K(r.providerUserInfo):[],a=zpe(t.providerData,i),o=t.isAnonymous,l=!(t.email&&r.passwordHash)&&!(a!=null&&a.length),c=o?l:!1,h={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:a,metadata:new j3(r.createdAt,r.lastLoginAt),isAnonymous:c};Object.assign(t,h)}async function Vpe(t){const e=qo(t);await EN(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function zpe(t,e){return[...t.filter(s=>!e.some(r=>r.providerId===s.providerId)),...e]}function $K(t){return t.map(({providerId:e,...n})=>({providerId:e,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}))}/**
647 * @license
648 * Copyright 2020 Google LLC
649 *
650 * Licensed under the Apache License, Version 2.0 (the "License");
651 * you may not use this file except in compliance with the License.
652 * You may obtain a copy of the License at
653 *
654 *   http://www.apache.org/licenses/LICENSE-2.0
655 *
656 * Unless required by applicable law or agreed to in writing, software
657 * distributed under the License is distributed on an "AS IS" BASIS,
658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
659 * See the License for the specific language governing permissions and
660 * limitations under the License.
661 */async function Gpe(t,e){const n=await MK(t,{},async()=>{const s=uA({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:r,apiKey:i}=t.config,a=await PK(t,r,"/v1/token",`key=${i}`),o=await t._getAdditionalHeaders();o["Content-Type"]="application/x-www-form-urlencoded";const l={method:"POST",headers:o,body:s};return t.emulatorConfig&&dA(t.emulatorConfig.host)&&(l.credentials="include"),RK.fetch()(a,l)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function Hpe(t,e){return X1(t,"POST","/v2/accounts:revokeToken",sL(t,e))}/**
662 * @license
663 * Copyright 2020 Google LLC
664 *
665 * Licensed under the Apache License, Version 2.0 (the "License");
666 * you may not use this file except in compliance with the License.
667 * You may obtain a copy of the License at
668 *
669 *   http://www.apache.org/licenses/LICENSE-2.0
670 *
671 * Unless required by applicable law or agreed to in writing, software
672 * distributed under the License is distributed on an "AS IS" BASIS,
673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
674 * See the License for the specific language governing permissions and
675 * limitations under the License.
676 */class hw{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Es(e.idToken,"internal-error"),Es(typeof e.idToken<"u","internal-error"),Es(typeof e.refreshToken<"u","internal-error");const n="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):pU(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}updateFromIdToken(e){Es(e.length!==0,"internal-error");const n=pU(e);this.updateTokensAndExpiration(e,null,n)}async getToken(e,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(Es(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}
676async refresh(e,n){const{accessToken:s,refreshToken:r,expiresIn:i}=await Gpe(e,n);this.updateTokensAndExpiration(s,r,Number(i))}updateTokensAndExpiration(e,n,s){this.refreshToken=n||null,this.accessToken=e||null,this.expirationTime=Date.now()+s*1e3}static fromJSON(e,n){const{refreshToken:s,accessToken:r,expirationTime:i}=n,a=new hw;return s&&(Es(typeof s=="string","internal-error",{appName:e}),a.refreshToken=s),r&&(Es(typeof r=="string","internal-error",{appName:e}),a.accessToken=r),i&&(Es(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new hw,this.toJSON())}_performRefresh(){return Cm("not implemented")}}/**
677 * @license
678 * Copyright 2020 Google LLC
679 *
680 * Licensed under the Apache License, Version 2.0 (the "License");
681 * you may not use this file except in compliance with the License.
682 * You may obtain a copy of the License at
683 *
684 *   http://www.apache.org/licenses/LICENSE-2.0
685 *
686 * Unless required by applicable law or agreed to in writing, software
687 * distributed under the License is distributed on an "AS IS" BASIS,
688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
689 * See the License for the specific language governing permissions and
690 * limitations under the License.
691 */function Ig(t,e){Es(typeof t=="string"||typeof t>"u","internal-error",{appName:e})}class zh{constructor({uid:e,auth:n,stsTokenManager:s,...r}){this.providerId="firebase",this.proactiveRefresh=new Fpe(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=r.displayName||null,this.email=r.email||null,this.emailVerified=r.emailVerified||!1,this.phoneNumber=r.phoneNumber||null,this.photoURL=r.photoURL||null,this.isAnonymous=r.isAnonymous||!1,this.tenantId=r.tenantId||null,this.providerData=r.providerData?[...r.providerData]:[],this.metadata=new j3(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){const n=await rE(this,this.stsTokenManager.getToken(this.auth,e));return Es(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(e){return Bpe(this,e)}reload(){return Vpe(this)}_assign(e){this!==e&&(Es(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(n=>({...n})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const n=new zh({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(e){Es(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,n=!1){let s=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),s=!0),n&&await EN(this),await this.auth._persistUserIfCurrent(this),s&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Fh(this.auth.app))return Promise.reject(dv(this.auth));const e=await this.getIdToken();return await rE(this,jpe(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,n){const s=n.displayName??void 0,r=n.email??void 0,i=n.phoneNumber??void 0,a=n.photoURL??void 0,o=n.tenantId??void 0,l=n._redirectEventId??void 0,c=n.createdAt??void 0,h=n.lastLoginAt??void 0,{uid:p,emailVerified:m,isAnonymous:y,providerData:v,stsTokenManager:b}=n;Es(p&&b,e,"internal-error");const S=hw.fromJSON(this.name,b);Es(typeof p=="string",e,"internal-error"),Ig(s,e.name),Ig(r,e.name),Es(typeof m=="boolean",e,"internal-error"),Es(typeof y=="boolean",e,"internal-error"),Ig(i,e.name),Ig(a,e.name),Ig(o,e.name),Ig(l,e.name),Ig(c,e.name),Ig(h,e.name);const E=new zh({uid:p,auth:e,email:r,emailVerified:m,displayName:s,isAnonymous:y,photoURL:a,p
691honeNumber:i,tenantId:o,stsTokenManager:S,createdAt:c,lastLoginAt:h});return v&&Array.isArray(v)&&(E.providerData=v.map(I=>({...I}))),l&&(E._redirectEventId=l),E}static async _fromIdTokenResponse(e,n,s=!1){const r=new hw;r.updateFromServerResponse(n);const i=new zh({uid:n.localId,auth:e,stsTokenManager:r,isAnonymous:s});return await EN(i),i}static async _fromGetAccountInfoResponse(e,n,s){const r=n.users[0];Es(r.localId!==void 0,"internal-error");const i=r.providerUserInfo!==void 0?$K(r.providerUserInfo):[],a=!(r.email&&r.passwordHash)&&!(i!=null&&i.length),o=new hw;o.updateFromIdToken(s);const l=new zh({uid:r.localId,auth:e,stsTokenManager:o,isAnonymous:a}),c={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new j3(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash)&&!(i!=null&&i.length)};return Object.assign(l,c),l}}/**
692 * @license
693 * Copyright 2020 Google LLC
694 *
695 * Licensed under the Apache License, Version 2.0 (the "License");
696 * you may not use this file except in compliance with the License.
697 * You may obtain a copy of the License at
698 *
699 *   http://www.apache.org/licenses/LICENSE-2.0
700 *
701 * Unless required by applicable law or agreed to in writing, software
702 * distributed under the License is distributed on an "AS IS" BASIS,
703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
704 * See the License for the specific language governing permissions and
705 * limitations under the License.
706 */const mU=new Map;function km(t){Pm(t instanceof Function,"Expected a class definition");let e=mU.get(t);return e?(Pm(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,mU.set(t,e),e)}/**
707 * @license
708 * Copyright 2019 Google LLC
709 *
710 * Licensed under the Apache License, Version 2.0 (the "License");
711 * you may not use this file except in compliance with the License.
712 * You may obtain a copy of the License at
713 *
714 *   http://www.apache.org/licenses/LICENSE-2.0
715 *
716 * Unless required by applicable law or agreed to in writing, software
717 * distributed under the License is distributed on an "AS IS" BASIS,
718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
719 * See the License for the specific language governing permissions and
720 * limitations under the License.
721 */class DK{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,n){this.storage[e]=n}async _get(e){const n=this.storage[e];return n===void 0?null:n}async _remove(e){delete this.storage[e]}_addListener(e,n){}_removeListener(e,n){}}DK.type="NONE";const gU=DK;/**
722 * @license
723 * Copyright 2019 Google LLC
724 *
725 * Licensed under the Apache License, Version 2.0 (the "License");
726 * you may not use this file except in compliance with the License.
727 * You may obtain a copy of the License at
728 *
729 *   http://www.apache.org/licenses/LICENSE-2.0
730 *
731 * Unless required by applicable law or agreed to in writing, software
732 * distributed under the License is distributed on an "AS IS" BASIS,
733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
734 * See the License for the specific language governing permissions and
735 * limitations under the License.
736 */function hI(t,e,n){return`firebase:${t}:${e}:${n}`}class fw{constructor(e,n,s){this.persistence=e,this.auth=n,this.userKey=s;const{config:r,name:i}=this.auth;this.fullUserKey=hI(this.userKey,r.apiKey,i),this.fullPersistenceKey=hI("persistence",r.apiKey,i),this.boundEventHandler=n._onStorageEvent.bind(n),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const n=await SN(this.auth,{idToken:e}).catch(()=>{});return n?zh._fromGetAccountInfoResponse(this.auth,n,e):null}return zh._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const n=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,n)return this.setCurrentUser(n)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,n,s="authUser"){if(!n.length)return new fw(km(gU),e,s);const r=(await Promise.all(n.map(async c=>{if(await c._isAvailable())return c}))).filter(c=>c);let i=r[0]||km(gU);const a=hI(s,e.config.apiKey,e.name);let o=null;for(const c of n)try{const h=await c._get(a);if(h){let p;if(typeof h=="string"){const m=await SN(e,{idToken:h}).catch(()=>{});if(!m)break;p=await zh._fromGetAccountInfoResponse(e,m,h)}else p=zh._fromJSON(e,h);c!==i&&(o=p),i=c;break}}catch{}const l=r.filter(c=>c._shouldAllowMigration);return!i._shouldAllowMigration||!l.length?new fw(i,e,s):(i=l[0],o&&await i._set(a,o.toJSON()),await Promise.all(n.map(async c=>{if(c!==i)try{await c._remove(a)}catch{}})),new fw(i,e,s))}}/**
737 * @license
738 * Copyright 2020 Google LLC
739 *
740 * Licensed under the Apache License, Version 2.0 (the "License");
741 * you may not use this file except in compliance with the License.
742 * You may obtain a copy of the License at
743 *
744 *   http://www.apache.org/licenses/LICENSE-2.0
745 *
746 * Unless required by applicable law or agreed to in writing, software
747 * distributed under the License is distributed on an "AS IS" BASIS,
748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
749 * See the License for the specific language governing permissions and
750 * limitations under the License.
751 */function yU(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(BK(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(OK(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(FK(e))return"Blackberry";if(VK(e))return"Webos";if(LK(e))return"Safari";if((e.includes("chrome/")||jK(e))&&!e.includes("edge/"))return"Chrome";if(UK(e))return"Android";{const n=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,s=t.match(n);if((s==null?void 0:s.length)===2)return s[1]}return"Other"}function OK(t=bl()){return/firefox\//i.test(t)}function LK(t=bl()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function jK(t=bl()){return/crios\//i.test(t)}function BK(t=bl()){return/iemobile/i.test(t)}function UK(t=bl()){return/android/i.test(t)}function FK(t=bl()){return/blackberry/i.test(t)}function VK(t=bl()){return/webos/i.test(t)}function iL(t=bl()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function qpe(t=bl()){var e;return iL(t)&&!!((e=window.navigator)!=null&&e.standalone)}function Wpe(){return ofe()&&document.documentMode===10}function zK(t=bl()){return iL(t)||UK(t)||VK(t)||FK(t)||/windows phone/i.test(t)||BK(t)}/**
752 * @license
753 * Copyright 2020 Google LLC
754 *
755 * Licensed under the Apache License, Version 2.0 (the "License");
756 * you may not use this file except in compliance with the License.
757 * You may obtain a copy of the License at
758 *
759 *   http://www.apache.org/licenses/LICENSE-2.0
760 *
761 * Unless required by applicable law or agreed to in writing, software
762 * distributed under the License is distributed on an "AS IS" BASIS,
763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
764 * See the License for the specific language governing permissions and
765 * limitations under the License.
766 */function GK(t,e=[]){let n;switch(t){case"Browser":n=yU(bl());break;case"Worker":n=`${yU(bl())}-${t}`;break;default:n=t}const s=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${Y1}/${s}`}/**
767 * @license
768 * Copyright 2022 Google LLC
769 *
770 * Licensed under the Apache License, Version 2.0 (the "License");
771 * you may not use this file except in compliance with the License.
772 * You may obtain a copy of the License at
773 *
774 *   http://www.apache.org/licenses/LICENSE-2.0
775 *
776 * Unless required by applicable law or agreed to in writing, software
777 * distributed under the License is distributed on an "AS IS" BASIS,
778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
779 * See the License for the specific language governing permissions and
780 * limitations under the License.
781 */class Kpe{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,n){const s=i=>new Promise((a,o)=>{try{const l=e(i);a(l)}catch(l){o(l)}});s.onAbort=n,this.queue.push(s);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const n=[];try{for(const s of this.queue)await s(e),s.onAbort&&n.push(s.onAbort)}catch(s){n.reverse();for(const r of n)try{r()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:s==null?void 0:s.message})}}}/**
782 * @license
783 * Copyright 2023 Google LLC
784 *
785 * Licensed under the Apache License, Version 2.0 (the "License");
786 * you may not use this file except in compliance with the License.
787 * You may obtain a copy of the License at
788 *
789 *   http://www.apache.org/licenses/LICENSE-2.0
790 *
791 * Unless required by applicable law or agreed to in writing, softw
791are
792 * distributed under the License is distributed on an "AS IS" BASIS,
793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
794 * See the License for the specific language governing permissions and
795 * limitations under the License.
796 */async function Ype(t,e={}){return X1(t,"GET","/v2/passwordPolicy",sL(t,e))}/**
797 * @license
798 * Copyright 2023 Google LLC
799 *
800 * Licensed under the Apache License, Version 2.0 (the "License");
801 * you may not use this file except in compliance with the License.
802 * You may obtain a copy of the License at
803 *
804 *   http://www.apache.org/licenses/LICENSE-2.0
805 *
806 * Unless required by applicable law or agreed to in writing, software
807 * distributed under the License is distributed on an "AS IS" BASIS,
808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
809 * See the License for the specific language governing permissions and
810 * limitations under the License.
811 */const Xpe=6;class Jpe{constructor(e){var s;const n=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=n.minPasswordLength??Xpe,n.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=n.maxPasswordLength),n.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=n.containsLowercaseCharacter),n.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=n.containsUppercaseCharacter),n.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=n.containsNumericCharacter),n.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=n.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=((s=e.allowedNonAlphanumericCharacters)==null?void 0:s.join(""))??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const n={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,n),this.validatePasswordCharacterOptions(e,n),n.isValid&&(n.isValid=n.meetsMinPasswordLength??!0),n.isValid&&(n.isValid=n.meetsMaxPasswordLength??!0),n.isValid&&(n.isValid=n.containsLowercaseLetter??!0),n.isValid&&(n.isValid=n.containsUppercaseLetter??!0),n.isValid&&(n.isValid=n.containsNumericCharacter??!0),n.isValid&&(n.isValid=n.containsNonAlphanumericCharacter??!0),n}validatePasswordLengthOptions(e,n){const s=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;s&&(n.meetsMinPasswordLength=e.length>=s),r&&(n.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,n){this.updatePasswordCharacterOptionsStatuses(n,!1,
811!1,!1,!1);let s;for(let r=0;r<e.length;r++)s=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(n,s>="a"&&s<="z",s>="A"&&s<="Z",s>="0"&&s<="9",this.allowedNonAlphanumericCharacters.includes(s))}updatePasswordCharacterOptionsStatuses(e,n,s,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=s)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}/**
812 * @license
813 * Copyright 2020 Google LLC
814 *
815 * Licensed under the Apache License, Version 2.0 (the "License");
816 * you may not use this file except in compliance with the License.
817 * You may obtain a copy of the License at
818 *
819 *   http://www.apache.org/licenses/LICENSE-2.0
820 *
821 * Unless required by applicable law or agreed to in writing, software
822 * distributed under the License is distributed on an "AS IS" BASIS,
823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
824 * See the License for the specific language governing permissions and
825 * limitations under the License.
826 */class Qpe{constructor(e,n,s,r){this.app=e,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=s,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new xU(this),this.idTokenSubscription=new xU(this),this.beforeStateQueue=new Kpe(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=NK,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion,this._persistenceManagerAvailable=new Promise(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,n){return n&&(this._popupRedirectResolver=km(n)),this._initializationPromise=this.queue(async()=>{var s,r,i;if(!this._deleted&&(this.persistenceManager=await fw.create(this,e),(s=this._resolvePersistenceManagerAvailable)==null||s.call(this),!this._deleted)){if((r=this._popupRedirectResolver)!=null&&r._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(n),this.lastNotifiedUid=((i=this.currentUser)==null?void 0:i.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const n=await SN(this,{idToken:e}),s=await zh._fromGetAccountInfoResponse(this,n,e);await this.directlySetCurrentUser(s)}catch(n){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",n),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var i;if(Fh(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(o=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(o,o))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let s=n,r=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(i=this.redirectUser)==null?void 0:i._redirectEventId,o=s==null?void 0:s._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===o)&&(l!=null&&l.user)&&(s=l.user,r=!0)}if(!s)return this.directlySetCurrentUser(null);
826if(!s._redirectEventId){if(r)try{await this.beforeStateQueue.runMiddleware(s)}catch(a){s=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return Es(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}async tryRedirectSignIn(e){let n=null;try{n=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return n}async reloadAndSetCurrentUserOrClear(e){try{await EN(e)}catch(n){if((n==null?void 0:n.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=Mpe()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Fh(this.app))return Promise.reject(dv(this));const n=e?qo(e):null;return n&&Es(n.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(n&&n._clone(this))}async _updateCurrentUser(e,n=!1){if(!this._deleted)return e&&Es(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),n||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Fh(this.app)?Promise.reject(dv(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Fh(this.app)?Promise.reject(dv(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(km(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const n=this._getPasswordPolicyInternal();return n.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):n.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await Ype(this),n=new Jpe(e);this.tenantId===null?this._projectPasswordPolicy=n:this._tenantPasswordPolicies[this.tenantId]=n}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new cA("auth","Firebase",e())}onAuthStateChanged(e,n,s){return this.registerStateListener(this.authStateSubscription,e,n,s)}beforeAuthStateChanged(e,n){return this.beforeStateQueue.pushCallback(e,n)}onIdTokenChanged(e,n,s){return this.registerStateListener(this.idTokenSubscription,e,n,s)}authStateReady(){return new Promise((e,n)=>{if(this.currentUser)e();else{const s=this.onAuthStateChanged(()=>{s(),e()},n)}})}async revokeAccessToken(e){if(this.currentUser){const n=await this.currentUser.getIdToken(),s={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:n};this.tenantId!=null&&(s.tenantId=this.tenantId),await Hpe(this,s)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)==null?void 0:e.toJSON()}}async _setRedirectUser(e,n){const s=await this.getOrInitRedirectPersistenceManager(n);return e===null?s.removeCurrentUser():s.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const n=e&&km(e)||this._popupRedirectResolver;Es(n,this,"argument-error"),this.redirectPersistenceManager=await fw.create(this,[km(n._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var n,s;return this._isInitialized&&await this.queue(async()=>{}),((n=this._currentUser)==null?void 0:n._redirectEventId)===e?this._currentUser:((s=this.redirectUser)==null?void 0:s._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var n;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=((n=this.currentUser)==null?void 0:n.uid)??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,n,s,r){if(this._deleted)return()=>{};const i=typeof n=="function"?n:n.next.bind(n);let a=!1;const o=this._isInitialized?Promise.resolve():this._initializationPromise;if(Es(o,this,"internal-error"),o.then(()=>{a||i(this.currentUser)}),typeof n=="function"){const l=e.addObserver(n,s,r);return()=>{a=!0,l()}}else{const l=e.addObserver(n);return()=>{a=!0,l()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return Es(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=GK(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var r;const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const n=await((r=this.heartbeatServiceProvider.getImmediate({optional:!0}))==null?void 0:r.getHeartbeatsHeader());n&&(e["X-Firebase-Client"]=n);const s=await this._getAppCheckToken();return s&&(e["X-Firebase-AppCheck"]=s),e}async _getAppCheckToken(){var n;if(Fh(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await((n=this.appCheckServiceProvider.getImmediate({optional:!0}))==null?void 0:n.getToken());return e!=null&&e.error&&kpe(`Error while retrieving App Check token: ${e.error}`),e==null?void 0:e.token}}function eM(t){return qo(t)}class xU{constructor(e){this.auth=e,this.observer=null,this.addObserver=mfe(n=>this.observer=n)}get next(){return Es(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
827 * @license
828 * Copyright 2020 Google LLC
829 *
830 * Licensed under the Apache License, Version 2.0 (the "License");
831 * you may not use this file except in compliance with the License.
832 * You may obtain a copy of the License at
833 *
834 *   http://www.apache.org/licenses/LICENSE-2.0
835 *
836 * Unless required by applicable law or agreed to in writing, software
837 * distributed under the License is distributed on an "AS IS" BASIS,
838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
839 * See the License for the specific language governing permissions and
840 * limitations under the License.
841 */let aL={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Zpe(t){aL=t}function eme(t){return aL.loadJS(t)}function tme(){return aL.gapiScript}function nme(t){return`__${t}${Math.floor(Math.random()*1e6)}`}/**
842 * @license
843 * Copyright 2020 Google LLC
844 *
845 * Licensed under the Apache License, Version 2.0 (the "License");
846 * you may not use this file except in compliance with the License.
847 * You may obtain a copy of the License at
848 *
849 *   http://www.apache.org/licenses/LICENSE-2.0
850 *
851 * Unless required by applicable law or agreed to in writing, software
852 * distributed under the License is distributed on an "AS IS" BASIS,
853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
854 * See the License for the specific language governing permissions and
855 * limitations under the License.
856 */function sme(t,e){const n=ZO(t,"auth");if(n.isInitialized()){const r=n.getImmediate(),i=n.getOptions();if(vv(i,e??{}))return r;hp(r,"already-initialized")}return n.initialize({options:e})}function rme(t,e){const n=(e==null?void 0:e.persistence)||[],s=(Array.isArray(n)?n:[n]).map(km);e!=null&&e.errorMap&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(s,e==null?void 0:e.popupRedirectResolver)}function ime(t,e,n){const s=eM(t);Es(/^https?:\/\//.test(e),s,"invalid-emulator-scheme");const r=!1,i=HK(e),{host:a,port:o}=ame(e),l=o===null?"":`:${o}`,c={url:`${i}//${a}${l}/`},h=Object.freeze({host:a,port:o,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:r})});if(!s._canInitEmulator){Es(s.config.emulator&&s.emulatorConfig,s,"emulator-config-failed"),Es(vv(c,s.config.emulator)&&vv(h,s.emulatorConfig),s,"emulator-config-failed");return}s.config.emulator=c,s.emulatorConfig=h,s.settings.appVerificationDisabledForTesting=!0,dA(a)?SK(`${i}//${a}${l}`):ome()}function HK(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function ame(t){const e=HK(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const s=n[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(s);if(r){const i=r[1];return{host:i,port:vU(s.substr(i.length+1))}}else{const[i,a]=s.split(":");return{host:i,port:vU(a)}}}function vU(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}function ome(){function t(){const e=document.createElement("p"),n=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",n.position="fixed",n.width="100%",n.backgroundColor="#ffffff",n.border=".1em solid #000000",n.color="#b50000",n.bottom="0px",n.left="0px",n.margin="0px",n.zIndex="10000",n.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only.  Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",t):t())}/**
857 * @license
858 * Copyright 2020 Google LLC
859 *
860 * Licensed under the Apache License, Version 2.0 (the "License");
861 * you may not use this file except in compliance with the License.
862 * You may obtain a copy of the License at
863 *
864 *   http://www.apache.org/licenses/LICENSE-2.0
865 *
866 * Unless required by applicable law or agreed to in writing, software
867 * distributed under the License is distributed on an "AS IS" BASIS,
868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
869 * See the License for the specific language governing permissions and
870 * limitations under the License.
871 */class qK{constructor(e,n){this.providerId=e,this.signInMethod=n}toJSON(){return Cm("not implemented")}_getIdTokenResponse(e){return Cm("not implemented")}_linkToIdToken(e,n){return Cm("not implemented")}_getReauthenticationResolver(e){return Cm("not implemented")}}/**
872 * @license
873 * Copyright 2020 Google LLC
874 *
875 * Licensed under the Apache License, Version 2.0 (the "License");
876 * you may not use this file except in compliance with the License.
877 * You may obtain a copy of the License at
878 *
879 *   http://www.apache.org/licenses/LICENSE-2.0
880 *
881 * Unless required by applicable law or agreed to in writing, software
882 * distributed under the License is distributed on an "AS IS" BASIS,
883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
884 * See the License for the specific language governing permissions and
885 * limitations under the License.
886 */async function pw(t,e){return Ope(t,"POST","/v1/accounts:signInWithIdp",sL(t,e))}/**
887 * @license
888 * Copyright 2020 Google LLC
889 *
890 * Licensed under the Apache License, Version 2.0 (the "License");
891 * you may not use this file except in compliance with the License.
892 * You may obtain a copy of the License at
893 *
894 *   http://www.apache.org/licenses/LICENSE-2.0
895 *
896 * Unless required by applicable law or agreed to in writing, software
897 * distributed under the License is distributed on an "AS IS" BASIS,
898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
899 * See the License for the specific language governing permissions and
900 * limitations under the License.
901 */const lme="http://localhost";class wv extends qK{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const n=new wv(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(n.idToken=e.idToken),e.accessToken&&(n.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(n.nonce=e.nonce),e.pendingToken&&(n.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(n.accessToken=e.oauthToken,n.secret=e.oauthTokenSecret):hp("argument-error"),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
901once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const n=typeof e=="string"?JSON.parse(e):e,{providerId:s,signInMethod:r,...i}=n;if(!s||!r)return null;const a=new wv(s,r);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const n=this.buildRequest();return pw(e,n)}_linkToIdToken(e,n){const s=this.buildRequest();return s.idToken=n,pw(e,s)}_getReauthenticationResolver(e){const n=this.buildRequest();return n.autoCreate=!1,pw(e,n)}buildRequest(){const e={requestUri:lme,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const n={};this.idToken&&(n.id_token=this.idToken),this.accessToken&&(n.access_token=this.accessToken),this.secret&&(n.oauth_token_secret=this.secret),n.providerId=this.providerId,this.nonce&&!this.pendingToken&&(n.nonce=this.nonce),e.postBody=uA(n)}return e}}/**
902 * @license
903 * Copyright 2020 Google LLC
904 *
905 * Licensed under the Apache License, Version 2.0 (the "License");
906 * you may not use this file except in compliance with the License.
907 * You may obtain a copy of the License at
908 *
909 *   http://www.apache.org/licenses/LICENSE-2.0
910 *
911 * Unless required by applicable law or agreed to in writing, software
912 * distributed under the License is distributed on an "AS IS" BASIS,
913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
914 * See the License for the specific language governing permissions and
915 * limitations under the License.
916 */class oL{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/**
917 * @license
918 * Copyright 2019 Google LLC
919 *
920 * Licensed under the Apache License, Version 2.0 (the "License");
921 * you may not use this file except in compliance with the License.
922 * You may obtain a copy of the License at
923 *
924 *   http://www.apache.org/licenses/LICENSE-2.0
925 *
926 * Unless required by applicable law or agreed to in writing, software
927 * distributed under the License is distributed on an "AS IS" BASIS,
928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
929 * See the License for the specific language governing permissions and
930 * limitations under the License.
931 */class fA extends oL{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
932 * @license
933 * Copyright 2020 Google LLC
934 *
935 * Licensed under the Apache License, Version 2.0 (the "License");
936 * you may not use this file except in compliance with the License.
937 * You may obtain a copy of the License at
938 *
939 *   http://www.apache.org/licenses/LICENSE-2.0
940 *
941 * Unless required by applicable law or agreed to in writing, software
942 * distributed under the License is distributed on an "AS IS" BASIS,
943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
944 * See the License for the specific language governing permissions and
945 * limitations under the License.
946 */class Ug extends fA{constructor(){super("facebook.com")}static credential(e){return wv._fromParams({providerId:Ug.PROVIDER_ID,signInMethod:Ug.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Ug.credentialFromTaggedObject(e)}static credentialFromError(e){return Ug.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Ug.credential(e.oauthAccessToken)}catch{return null}}}Ug.FACEBOOK_SIGN_IN_METHOD="facebook.com";Ug.PROVIDER_ID="facebook.com";/**
947 * @license
948 * Copyright 2020 Google LLC
949 *
950 * Licensed under the Apache License, Version 2.0 (the "License");
951 * you may not use this file except in compliance with the License.
952 * You may obtain a copy of the License at
953 *
954 *   http://www.apache.org/licenses/LICENSE-2.0
955 *
956 * Unless required by applicable law or agreed to in writing, softw
956are
957 * distributed under the License is distributed on an "AS IS" BASIS,
958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
959 * See the License for the specific language governing permissions and
960 * limitations under the License.
961 */class Sm extends fA{constructor(){super("google.com"),this.addScope("profile")}static credential(e,n){return wv._fromParams({providerId:Sm.PROVIDER_ID,signInMethod:Sm.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}static credentialFromResult(e){return Sm.credentialFromTaggedObject(e)}static credentialFromError(e){return Sm.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:n,oauthAccessToken:s}=e;if(!n&&!s)return null;try{return Sm.credential(n,s)}catch{return null}}}Sm.GOOGLE_SIGN_IN_METHOD="google.com";Sm.PROVIDER_ID="google.com";/**
962 * @license
963 * Copyright 2020 Google LLC
964 *
965 * Licensed under the Apache License, Version 2.0 (the "License");
966 * you may not use this file except in compliance with the License.
967 * You may obtain a copy of the License at
968 *
969 *   http://www.apache.org/licenses/LICENSE-2.0
970 *
971 * Unless required by applicable law or agreed to in writing, software
972 * distributed under the License is distributed on an "AS IS" BASIS,
973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
974 * See the License for the specific language governing permissions and
975 * limitations under the License.
976 */class Fg extends fA{constructor(){super("github.com")}static credential(e){return wv._fromParams({providerId:Fg.PROVIDER_ID,signInMethod:Fg.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Fg.credentialFromTaggedObject(e)}static credentialFromError(e){return Fg.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Fg.credential(e.oauthAccessToken)}catch{return null}}}Fg.GITHUB_SIGN_IN_METHOD="github.com";
976Fg.PROVIDER_ID="github.com";/**
977 * @license
978 * Copyright 2020 Google LLC
979 *
980 * Licensed under the Apache License, Version 2.0 (the "License");
981 * you may not use this file except in compliance with the License.
982 * You may obtain a copy of the License at
983 *
984 *   http://www.apache.org/licenses/LICENSE-2.0
985 *
986 * Unless required by applicable law or agreed to in writing, software
987 * distributed under the License is distributed on an "AS IS" BASIS,
988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989 * See the License for the specific language governing permissions and
990 * limitations under the License.
991 */class Vg extends fA{constructor(){super("twitter.com")}static credential(e,n){return wv._fromParams({providerId:Vg.PROVIDER_ID,signInMethod:Vg.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}static credentialFromResult(e){return Vg.credentialFromTaggedObject(e)}static credentialFromError(e){return Vg.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:n,oauthTokenSecret:s}=e;if(!n||!s)return null;try{return Vg.credential(n,s)}catch{return null}}}Vg.TWITTER_SIGN_IN_METHOD="twitter.com";Vg.PROVIDER_ID="twitter.com";/**
992 * @license
993 * Copyright 2020 Google LLC
994 *
995 * Licensed under the Apache License, Version 2.0 (the "License");
996 * you may not use this file except in compliance with the License.
997 * You may obtain a copy of the License at
998 *
999 *   http://www.apache.org/licenses/LICENSE-2.0
1000 *
1001 * Unless required by applicable law or agreed to in writing, software
1002 * distributed under the License is distributed on an "AS IS" BASIS,
1003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1004 * See the License for the specific language governing permissions and
1005 * limitations under the License.
1006 */class R1{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,n,s,r=!1){const i=await zh._fromIdTokenResponse(e,s,r),a=bU(s);return new R1({user:i,providerId:a,_tokenResponse:s,operationType:n})}static async _forOperation(e,n,s){await e._updateTokensIfNecessary(s,!0);const r=bU(s);return new R1({user:e,providerId:r,_tokenResponse:s,operationType:n})}}function bU(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}/**
1007 * @license
1008 * Copyright 2020 Google LLC
1009 *
1010 * Licensed under the Apache License, Version 2.0 (the "License");
1011 * you may not use this file except in compliance with the License.
1012 * You may obtain a copy of the License at
1013 *
1014 *   http://www.apache.org/licenses/LICENSE-2.0
1015 *
1016 * Unless required by applicable law or agreed to in writing, software
1017 * distributed under the License is distributed on an "AS IS" BASIS,
1018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1019 * See the License for the specific language governing permissions and
1020 * limitations under the License.
1021 */class TN extends Fm{constructor(e,n,s,r){super(n.code,n.message),this.operationType=s,this.user=r,Object.setPrototypeOf(this,TN.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:s}}static _fromErrorAndOperation(e,n,s,r){return new TN(e,n,s,r)}}function WK(t,e,n,s){return(e==="reauthenticate"?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?TN._fromErrorAndOperation(t,i,e,s):i})}async function cme(t,e,n=!1){const s=await rE(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return R1._forOperation(t,"link",s)}/**
1022 * @license
1023 * Copyright 2019 Google LLC
1024 *
1025 * Licensed under the Apache License, Version 2.0 (the "License");
1026 * you may not use this file except in compliance with the License.
1027 * You may obtain a copy of the License at
1028 *
1029 *   http://www.apache.org/licenses/LICENSE-2.0
1030 *
1031 * Unless required by applicable law or agreed to in writing, software
1032 * distributed under the License is distributed on an "AS IS" BASIS,
1033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1034 * See the License for the specific language governing permissions and
1035 * limitations under the License.
1036 */async function ume(t,e,n=!1){const{auth:s}=t;if(Fh(s.app))return Promise.reject(dv(s));const r="reauthenticate";try{const i=await rE(t,WK(s,r,e,t),n);Es(i.idToken,s,"internal-error");const a=rL(i.idToken);Es(a,s,"internal-error");const{sub:o}=a;return Es(t.uid===o,s,"user-mismatch"),R1._forOperation(t,r,i)}catch(i){throw(i==null?void 0:i.code)==="auth/user-not-found"&&hp(s,"user-mismatch"),i}}/**
1037 * @license
1038 * Copyright 2020 Google LLC
1039 *
1040 * Licensed under the Apache License, Version 2.0 (the "License");
1041 * you may not use this file except in compliance with the License.
1042 * You may obtain a copy of the License at
1043 *
1044 *   http://www.apache.org/licenses/LICENSE-2.0
1045 *
1046 * Unless required by applicable law or agreed to in writing, software
1047 * distributed under the License is distributed on an "AS IS" BASIS,
1048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1049 * See the License for the specific language governing permissions and
1050 * limitations under the License.
1051 */async function dme(t,e,n=!1){if(Fh(t.app))return Promise.reject(dv(t));const s="signIn",r=await WK(t,s,e),i=await R1._fromIdTokenResponse(t,s,r);return n||await t._updateCurrentUser(i.user),i}function hme(t,e,n,s){return qo(t).onIdTokenChanged(e,n,s)}function fme(t,e,n){return qo(t).beforeAuthStateChanged(e,n)}function Vm(t,e,n,s){return qo(t).onAuthStateChanged(e,n,s)}function pme(t){return qo(t).signOut()}const AN="__sak";/**
1052 * @license
1053 * Copyright 2019 Google LLC
1054 *
1055 * Licensed under the Apache License, Version 2.0 (the "License");
1056 * you may not use this file except in compliance with the License.
1057 * You may obtain a copy of the License at
1058 *
1059 *   http://www.apache.org/licenses/LICENSE-2.0
1060 *
1061 * Unless required by applicable law or agreed to in writing, software
1062 * distributed under the License is distributed on an "AS IS" BASIS,
1063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1064 * See the License for the specific language governing permissions and
1065 * limitations under the License.
1066 */class KK{constructor(e,n){this.storageRetriever=e,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(AN,"1"),this.storage.removeItem(AN),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,n){return this.storage.setItem(e,JSON.stringify(n)),Promise.resolve()}_get(e){const n=this.storage.getItem(e);return Promise.resolve(n?JSON.parse(n):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
1067 * @license
1068 * Copyright 2020 Google LLC
1069 *
1070 * Licensed under the Apache License, Version 2.0 (the "License");
1071 * you may not use this file except in compliance with the License.
1072 * You may obtain a copy of the License at
1073 *
1074 *   http://www.apache.org/licenses/LICENSE-2.0
1075 *
1076 * Unless required by applicable law or agreed to in writing, software
1077 * distributed under the License is distributed on an "AS IS" BASIS,
1078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1079 * See the License for the specific language governing permissions and
1080 * limitations under the License.
1081 */const mme=1e3,gme=10;class YK extends KK{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,n)=>this.onStorageEvent(e,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=zK(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const n of Object.keys(this.listeners)){const s=this.storage.getItem(n),r=this.localCache[n];s!==r&&e(n,r,s)}}onStorageEvent(e,n=!1){if(!e.key){this.forAllChangedKeys((a,o,l)=>{this.notifyListeners(a,l)});return}const s=e.key;n?this.detachListener():this.stopPolling();const r=()=>{const a=this.storage.getItem(s);!n&&this.localCache[s]===a||this.notifyListeners(s,a)},i=this.storage.getItem(s);Wpe()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,gme):r()}notifyListeners(e,n){this.localCache[e]=n;const s=this.listeners[e];if(s)for(const r of Array.from(s))r(n&&JSON.parse(n))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,n,s)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:n,newValue:s}),!0)})},mme)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,n){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(n)}_removeListener(e,n){this.listeners[e]&&(this.listeners[e].delete(n),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1081ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,n){await super._set(e,n),this.localCache[e]=JSON.stringify(n)}async _get(e){const n=await super._get(e);return this.localCache[e]=JSON.stringify(n),n}async _remove(e){await super._remove(e),delete this.localCache[e]}}YK.type="LOCAL";const yme=YK;/**
1082 * @license
1083 * Copyright 2020 Google LLC
1084 *
1085 * Licensed under the Apache License, Version 2.0 (the "License");
1086 * you may not use this file except in compliance with the License.
1087 * You may obtain a copy of the License at
1088 *
1089 *   http://www.apache.org/licenses/LICENSE-2.0
1090 *
1091 * Unless required by applicable law or agreed to in writing, software
1092 * distributed under the License is distributed on an "AS IS" BASIS,
1093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1094 * See the License for the specific language governing permissions and
1095 * limitations under the License.
1096 */class XK extends KK{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,n){}_removeListener(e,n){}}XK.type="SESSION";const JK=XK;/**
1097 * @license
1098 * Copyright 2019 Google LLC
1099 *
1100 * Licensed under the Apache License, Version 2.0 (the "License");
1101 * you may not use this file except in compliance with the License.
1102 * You may obtain a copy of the License at
1103 *
1104 *   http://www.apache.org/licenses/LICENSE-2.0
1105 *
1106 * Unless required by applicable law or agreed to in writing, software
1107 * distributed under the License is distributed on an "AS IS" BASIS,
1108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1109 * See the License for the specific language governing permissions and
1110 * limitations under the License.
1111 */function xme(t){return Promise.all(t.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(n){return{fulfilled:!1,reason:n}}}))}/**
1112 * @license
1113 * Copyright 2019 Google LLC
1114 *
1115 * Licensed under the Apache License, Version 2.0 (the "License");
1116 * you may not use this file except in compliance with the License.
1117 * You may obtain a copy of the License at
1118 *
1119 *   http://www.apache.org/licenses/LICENSE-2.0
1120 *
1121 * Unless required by applicable law or agreed to in writing, software
1122 * distributed under the License is distributed on an "AS IS" BASIS,
1123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1124 * See the License for the specific language governing permissions and
1125 * limitations under the License.
1126 */class tM{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const n=this.receivers.find(r=>r.isListeningto(e));if(n)return n;const s=new tM(e);return this.receivers.push(s),s}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const n=e,{eventId:s,eventType:r,data:i}=n.data,a=this.handlersMap[r];if(!(a!=null&&a.size))return;n.ports[0].postMessage({status:"ack",eventId:s,eventType:r});const o=Array.from(a).map(async c=>c(n.origin,i)),l=await xme(o);n.ports[0].postMessage({status:"done",eventId:s,eventType:r,response:l})}_subscribe(e,n){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(n)}_unsubscribe(e,n){this.handlersMap[e]&&n&&this.handlersMap[e].delete(n),(!n||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}tM.receivers=[];/**
1127 * @license
1128 * Copyright 2020 Google LLC
1129 *
1130 * Licensed under the Apache License, Version 2.0 (the "License");
1131 * you may not use this file except in compliance with the License.
1132 * You may obtain a copy of the License at
1133 *
1134 *   http://www.apache.org/licenses/LICENSE-2.0
1135 *
1136 * Unless required by applicable law or agreed to in writing, software
1137 * distributed under the License is distributed on an "AS IS" BASIS,
1138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1139 * See the License for the specific language governing permissions and
1140 * limitations under the License.
1141 */function lL(t="",e=10){let n="";for(let s=0;s<e;s++)n+=Math.floor(Math.random()*10);return t+n}/**
1142 * @license
1143 * Copyright 2019 Google LLC
1144 *
1145 * Licensed under the Apache License, Version 2.0 (the "License");
1146 * you may not use this file except in compliance with the License.
1147 * You may obtain a copy of the License at
1148 *
1149 *   http://www.apache.org/licenses/LICENSE-2.0
1150 *
1151 * Unless required by applicable law or agreed to in writing, software
1152 * distributed under the License is distributed on an "AS IS" BASIS,
1153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1154 * See the License for the specific language governing permissions and
1155 * limitations under the License.
1156 */class vme{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,n,s=50){const r=typeof MessageChannel<"u"?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let i,a;return new Promise((o,l)=>{const c=lL("",20);r.port1.start();const h=setTimeout(()=>{l(new Error("unsupported_event"))},s);a={messageChannel:r,onMessage(p){const m=p;if(m.data.eventId===c)switch(m.data.status){case"ack":clearTimeout(h),i=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),o(m.data.response);break;default:clearTimeout(h),clearTimeout(i),l(new Error("invalid_response"));break}}},this.handlers.add(a),r.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:c,data:n},[r.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}/**
1157 * @license
1158 * Copyright 2020 Google LLC
1159 *
1160 * Licensed under the Apache License, Version 2.0 (the "License");
1161 * you may not use this file except in compliance with the License.
1162 * You may obtain a copy of the License at
1163 *
1164 *   http://www.apache.org/licenses/LICENSE-2.0
1165 *
1166 * Unless required by applicable law or agreed to in writing, software
1167 * distributed under the License is distributed on an "AS IS" BASIS,
1168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1169 * See the License for the specific language governing permissions and
1170 * limitations under the License.
1171 */function op(){return window}function bme(t){op().location.href=t}/**
1172 * @license
1173 * Copyright 2020 Google LLC.
1174 *
1175 * Licensed under the Apache License, Version 2.0 (the "License");
1176 * you may not use this file except in compliance with the License.
1177 * You may obtain a copy of the License at
1178 *
1179 *   http://www.apache.org/licenses/LICENSE-2.0
1180 *
1181 * Unless required by applicable law or agreed to in writing, software
1182 * distributed under the License is distributed on an "AS IS" BASIS,
1183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1184 * See the License for the specific language governing permissions and
1185 * limitations under the License.
1186 */function QK(){return typeof op().WorkerGlobalScope<"u"&&typeof op().importScripts=="function"}async function wme(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function _me(){var t;return((t=navigator==null?void 0:navigator.serviceWorker)==null?void 0:t.controller)||null}function Sme(){return QK()?self:null}/**
1187 * @license
1188 * Copyright 2019 Google LLC
1189 *
1190 * Licensed under the Apache License, Version 2.0 (the "License");
1191 * you may not use this file except in compliance with the License.
1192 * You may obtain a copy of the License at
1193 *
1194 *   http://www.apache.org/licenses/LICENSE-2.0
1195 *
1196 * Unless required by applicable law or agreed to in writing, software
1197 * distributed under the License is distributed on an "AS IS" BASIS,
1198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1199 * See the License for the specific language governing permissions and
1200 * limitations under the License.
1201 */const ZK="firebaseLocalStorageDb",Eme=1,CN="firebaseLocalStorage",eY="fbase_key";class pA{constructor(e){this.request=e}toPromise(){return new Promise((e,n)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{n(this.request.error)})})}}function nM(t,e){return t.transaction([CN],e?"readwrite":"readonly").objectStore(CN)}function Tme(){const t=indexedDB.deleteDatabase(ZK);
1201return new pA(t).toPromise()}function B3(){const t=indexedDB.open(ZK,Eme);return new Promise((e,n)=>{t.addEventListener("error",()=>{n(t.error)}),t.addEventListener("upgradeneeded",()=>{const s=t.result;try{s.createObjectStore(CN,{keyPath:eY})}catch(r){n(r)}}),t.addEventListener("success",async()=>{const s=t.result;s.objectStoreNames.contains(CN)?e(s):(s.close(),await Tme(),e(await B3()))})})}async function wU(t,e,n){const s=nM(t,!0).put({[eY]:e,value:n});return new pA(s).toPromise()}async function Ame(t,e){const n=nM(t,!1).get(e),s=await new pA(n).toPromise();return s===void 0?null:s.value}function _U(t,e){const n=nM(t,!0).delete(e);return new pA(n).toPromise()}const Cme=800,kme=3;class tY{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await B3(),this.db)}async _withRetries(e){let n=0;for(;;)try{const s=await this._openDb();return await e(s)}catch(s){if(n++>kme)throw s;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return QK()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=tM._getInstance(Sme()),this.receiver._subscribe("keyChanged",async(e,n)=>({keyProcessed:(await this._poll()).includes(n.key)}
1201)),this.receiver._subscribe("ping",async(e,n)=>["keyChanged"])}async initializeSender(){var n,s;if(this.activeServiceWorker=await wme(),!this.activeServiceWorker)return;this.sender=new vme(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&(n=e[0])!=null&&n.fulfilled&&(s=e[0])!=null&&s.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||_me()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await B3();return await wU(e,AN,"1"),await _U(e,AN),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,n){return this._withPendingWrite(async()=>(await this._withRetries(s=>wU(s,e,n)),this.localCache[e]=n,this.notifyServiceWorker(e)))}async _get(e){const n=await this._withRetries(s=>Ame(s,e));return this.localCache[e]=n,n}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(n=>_U(n,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(r=>{const i=nM(r,!1).getAll();return new pA(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const n=[],s=new Set;if(e.length!==0)for(const{fbase_key:r,value:i}of e)s.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),n.push(r));for(const r of Object.keys(this.localCache))this.localCache[r]&&!s.has(r)&&(this.notifyListeners(r,null),n.push(r));return n}notifyListeners(e,n){this.localCache[e]=n;const s=this.listeners[e];if(s)for(const r of Array.from(s))r(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Cme)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,n){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(n)}_removeListener(e,n){this.listeners[e]&&(this.listeners[e].delete(n),this.listeners[e].size===0&&delete this.listeners[e]),Ob
vendor: 4,328 bytes, lines 1201-1250
1201ject.keys(this.listeners).length===0&&this.stopPolling()}}tY.type="LOCAL";const Ime=tY;new hA(3e4,6e4);/**
1202 * @license
1203 * Copyright 2021 Google LLC
1204 *
1205 * Licensed under the Apache License, Version 2.0 (the "License");
1206 * you may not use this file except in compliance with the License.
1207 * You may obtain a copy of the License at
1208 *
1209 *   http://www.apache.org/licenses/LICENSE-2.0
1210 *
1211 * Unless required by applicable law or agreed to in writing, software
1212 * distributed under the License is distributed on an "AS IS" BASIS,
1213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214 * See the License for the specific language governing permissions and
1215 * limitations under the License.
1216 */function nY(t,e){return e?km(e):(Es(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}/**
1217 * @license
1218 * Copyright 2019 Google LLC
1219 *
1220 * Licensed under the Apache License, Version 2.0 (the "License");
1221 * you may not use this file except in compliance with the License.
1222 * You may obtain a copy of the License at
1223 *
1224 *   http://www.apache.org/licenses/LICENSE-2.0
1225 *
1226 * Unless required by applicable law or agreed to in writing, software
1227 * distributed under the License is distributed on an "AS IS" BASIS,
1228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1229 * See the License for the specific language governing permissions and
1230 * limitations under the License.
1231 */class cL extends qK{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return pw(e,this._buildIdpRequest())}_linkToIdToken(e,n){return pw(e,this._buildIdpRequest(n))}_getReauthenticationResolver(e){return pw(e,this._buildIdpRequest())}_buildIdpRequest(e){const n={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(n.idToken=e),n}}function Nme(t){return dme(t.auth,new cL(t),t.bypassAuthState)}function Rme(t){const{auth:e,user:n}=t;return Es(n,e,"internal-error"),ume(n,new cL(t),t.bypassAuthState)}async function Mme(t){const{auth:e,user:n}=t;return Es(n,e,"internal-error"),cme(n,new cL(t),t.bypassAuthState)}/**
1232 * @license
1233 * Copyright 2020 Google LLC
1234 *
1235 * Licensed under the Apache License, Version 2.0 (the "License");
1236 * you may not use this file except in compliance with the License.
1237 * You may obtain a copy of the License at
1238 *
1239 *   http://www.apache.org/licenses/LICENSE-2.0
1240 *
1241 * Unless required by applicable law or agreed to in writing, software
1242 * distributed under the License is distributed on an "AS IS" BASIS,
1243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1244 * See the License for the specific language governing permissions and
1245 * limitations under the License.
1246 */class sY{constructor(e,n,s,r,i=!1){this.auth=e,this.resolver=s,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(n)?n:[n]}execute(){return new Promise(async(e,n)=>{this.pendingPromise={resolve:e,reject:n};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(s){this.reject(s)}})}async onAuthEvent(e){const{urlResponse:n,sessionId:s,postBody:r,tenantId:i,error:a,type:o}=e;if(a){this.reject(a);return}const l={auth:this.auth,requestUri:n,sessionId:s,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(l))}catch(c){this.reject(c)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Nme;case"linkViaPopup":case"linkViaRedirect":return Mme;case"reauthViaPopup":case"reauthViaRedirect":return Rme;default:hp(this.auth,"internal-error")}}resolve(e){Pm(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Pm(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/**
1247 * @license
1248 * Copyright 2020 Google LLC
1249 *
1250 * Licensed under the Apache License, Version 2.0 (the "License");
1251 * you may not use this file except in compliance with the License.
1252 * You may obtain a copy of the License at
1253 *
1254 *   http://www.apache.org/licenses/LICENSE-2.0
1255 *
1256 * Unless required by applicable law or agreed to in writing, software
1257 * distributed under the License is distributed on an "AS IS" BASIS,
1258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1259 * See the License for the specific language governing permissions and
1260 * limitations under the License.
1261 */const Pme=new hA(2e3,1e4);async function $me(t,e,n){if(Fh(t.app))return Promise.reject(Hh(t,"operation-not-supported-in-this-environment"));const s=eM(t);Ipe(t,e,oL);const r=nY(s,n);return new ex(s,"signInViaPopup",e,r).executeNotNull()}class ex extends sY{constructor(e,n,s,r,i){super(e,n,r,i),this.provider=s,this.authWindow=null,this.pollId=null,ex.currentPopupAction&&ex.currentPopupAction.cancel(),ex.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return Es(e,this.auth,"internal-error"),e}async onExecution(){Pm(this.filter.length===1,"Popup operations only handle one event");const e=lL();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(n=>{this.reject(n)}),this.resolver._isIframeWebStorageSupported(this.auth,n=>{n||this.reject(Hh(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)==null?void 0:e.associatedEvent)||null}cancel(){this.reject(Hh(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,ex.currentPopupAction=null}pollUserCancellation(){const e=()=>{var n,s;if((s=(n=this.authWindow)==null?void 0:n.window)!=null&&s.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Hh(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,Pme.get())};e()}}ex.currentPopupAction=null;/**
1262 * @license
1263 * Copyright 2020 Google LLC
1264 *
1265 * Licensed under the Apache License, Version 2.0 (the "License");
1266 * you may not use this file except in compliance with the License.
1267 * You may obtain a copy of the License at
1268 *
1269 *   http://www.apache.org/licenses/LICENSE-2.0
1270 *
1271 * Unless required by applicable law or agreed to in writing, software
1272 * distributed under the License is distributed on an "AS IS" BASIS,
1273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1274 * See the License for the specific language governing permissions and
1275 * limitations under the License.
1276 */const Dme="pendingRedirect",fI=new Map;class Ome extends sY{constructor(e,n,s=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,s),this.eventId=null}async execute(){let e=fI.get(this.auth._key());if(!e){try{const s=await Lme(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(s)}catch(n){e=()=>Promise.reject(n)}fI.set(this.auth._key(),e)}return this.bypassAuthState||fI.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const n=await this.auth._redirectUserForId(e.eventId);if(n)return this.user=n,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function Lme(t,e){const n=Ume(e),s=Bme(t);if(!await s._isAvailable())return!1;const r=await s._get(n)==="true";return await s._remove(n),r}function jme(t,e){fI.set(t._key(),e)}function Bme(t){return km(t._redirectPersistence)}function Ume(t){return hI(Dme,t.config.apiKey,t.name)}async function Fme(t,e,n=!1){if(Fh(t.app))return Promise.reject(dv(t));const s=eM(t),r=nY(s,e),a=await new Ome(s,r,n).execute();return a&&!n&&(delete a.user._redirectEventId,await s._persistUserIfCurrent(a.user),await s._setRedirectUser(null,e)),a}/**
1277 * @license
1278 * Copyright 2020 Google LLC
1279 *
1280 * Licensed under the Apache License, Version 2.0 (the "License");
1281 * you may not use this file except in compliance with the License.
1282 * You may obtain a copy of the License at
1283 *
1284 *   http://www.apache.org/licenses/LICENSE-2.0
1285 *
1286 * Unless required by applicable law or agreed to in writing, software
1287 * distributed under the License is distributed on an "AS IS" BASIS,
1288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1289 * See the License for the specific language governing permissions and
1290 * limitations under the License.
1291 */const Vme=600*1e3;class zme{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let n=!1;return this.consumers.forEach(s=>{this.isEventForConsumer(e,s)&&(n=!0,this.sendToConsumer(e,s),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!Gme(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}sendToConsumer(e,n){var s;if(e.error&&!rY(e)){const r=((s=e.error.code)==null?void 0:s.split("auth/")[1])||"internal-error";n.onError(Hh(this.auth,r))}else n.onAuthEvent(e)}isEventForConsumer(e,n){const s=n.eventId===null||!!e.eventId&&e.eventId===n.eventId;return n.filter.includes(e.type)&&s}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=Vme&&this.cachedEventUids.clear(),this.cachedEventUids.has(SU(e))}saveEventToCache(e){this.cachedEventUids.add(SU(e)),this.lastProcessedEventTime=Date.now()}}function SU(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter(e=>e).join("-")}function rY({type:t,error:e}){return t==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function Gme(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return rY(t);default:return!1}}/**
1292 * @license
1293 * Copyright 2020 Google LLC
1294 *
1295 * Licensed under the Apache License, Version 2.0 (the "License");
1296 * you may not use this file except in compliance with the License.
1297 * You may obtain a copy of the License at
1298 *
1299 *   http://www.apache.org/licenses/LICENSE-2.0
1300 *
1301 * Unless required by applicable law or agreed to in writing, software
1302 * distributed under the License is distributed on an "AS IS" BASIS,
1303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304 * See the License for the specific language governing permissions and
1305 * limitations under the License.
1306 */async function Hme(t,e={}){return X1(t,"GET","/v1/projects",e)}/**
1307 * @license
1308 * Copyright 2020 Google LLC
1309 *
1310 * Licensed under the Apache License, Version 2.0 (the "License");
1311 * you may not use this file except in compliance with the License.
1312 * You may obtain a copy of the License at
1313 *
1314 *   http://www.apache.org/licenses/LICENSE-2.0
1315 *
1316 * Unless required by applicable law or agreed to in writing, software
1317 * distributed under the License is distributed on an "AS IS" BASIS,
1318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319 * See the License for the specific language governing permissions and
1320 * limitations under the License.
1321 */const qme=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Wme=/^https?/;async function Kme(t){if(t.config.emulator)return;const{authorizedDomains:e}=await Hme(t);for(const n of e)try{if(Yme(n))return}catch{}hp(t,"unauthorized-domain")}function Yme(t){const e=L3(),{protocol:n,hostname:s}=new URL(e);if(t.startsWith("chrome-extension://")){const a=new URL(t);return a.hostname===""&&s===""?n==="chrome-extension:"&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):n==="chrome-extension:"&&a.hostname===s}if(!Wme.test(n))return!1;if(qme.test(t))return s===t;const r=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+r+"|"+r+")$","i").test(s)}/**
1322 * @license
1323 * Copyright 2020 Google LLC.
1324 *
1325 * Licensed under the Apache License, Version 2.0 (the "License");
1326 * you may not use this file except in compliance with the License.
1327 * You may obtain a copy of the License at
1328 *
1329 *   http://www.apache.org/licenses/LICENSE-2.0
1330 *
1331 * Unless required by applicable law or agreed to in writing, software
1332 * distributed under the License is distributed on an "AS IS" BASIS,
1333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1334 * See the License for the specific language governing permissions and
1335 * limitations under the License.
1336 */const Xme=new hA(3e4,6e4);function EU(){const t=op().___jsl;if(t!=null&&t.H){for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let n=0;n<t.CP.length;n++)t.CP[n]=null}}function Jme(t){return new Promise((e,n)=>{var r,i,a;function s(){EU(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{EU(),n(Hh(t,"network-request-failed"))},timeout:Xme.get()})}if((i=(r=op().gapi)==null?void 0:r.iframes)!=null&&i.Iframe)e(gapi.iframes.getContext());else if((a=op().gapi)!=null&&a.load)s();else{const o=nme("iframefcb");return op()[o]=()=>{gapi.load?s():n(Hh(t,"network-request-failed"))},eme(`${tme()}?onload=${o}`).catch(l=>n(l))}}).catch(e=>{throw pI=null,e})}let pI=null;function Qme(t){return pI=pI||Jme(t),pI}/**
1337 * @license
1338 * Copyright 2020 Google LLC.
1339 *
1340 * Licensed under the Apache License, Version 2.0 (the "License");
1341 * you may not use this file except in compliance with the License.
1342 * You may obtain a copy of the License at
1343 *
1344 *   http://www.apache.org/licenses/LICENSE-2.0
1345 *
1346 * Unless required by applicable law or agreed to in writing, software
1347 * distributed under the License is distributed on an "AS IS" BASIS,
1348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1349 * See the License for the specific language governing permissions and
1350 * limitations under the License.
1351 */const Zme=new hA(5e3,15e3),ege="__/auth/iframe",tge="emulator/auth/iframe",nge={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},sge=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function rge(t){const e=t.config;Es(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?nL(e,tge):`https://${t.config.authDomain}/${ege}`,s={apiKey:e.apiKey,appName:t.name,v:Y1},r=sge.get(t.config.apiHost);r&&(s.eid=r);const i=t._getFrameworks();return i.length&&(s.fw=i.join(",")),`${n}?${uA(s).slice(1)}`}async function ige(t){const e=await Qme(t),n=op().gapi;return Es(n,t,"internal-error"),e.open({where:document.body,url:rge(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:nge,dontclear:!0},s=>new Promise(async(r,i)=>{await s.restyle({setHideOnLeave:!1});const a=Hh(t,"network-request-failed"),o=op().setTimeout(()=>{i(a)},Zme.get());function l(){op().clearTimeout(o),r(s)}s.ping(l).then(l,()=>{i(a)})}))}/**
1352 * @license
1353 * Copyright 2020 Google LLC.
1354 *
1355 * Licensed under the Apache License, Version 2.0 (the "License");
1356 * you may not use this file except in compliance with the License.
1357 * You may obtain a copy of the License at
1358 *
1359 *   http://www.apache.org/licenses/LICENSE-2.0
1360 *
1361 * Unless required by applicable law or agreed to in writing, software
1362 * distributed under the License is distributed on an "AS IS" BASIS,
1363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1364 * See the License for the specific language governing permissions and
1365 * limitations under the License.
1366 */const age={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},oge=500,lge=600,cge="_blank",uge="http://localhost";class TU{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function dge(t,e,n,s=oge,r=lge){const i=Math.max((window.screen.availHeight-r)/2,0).toString(),a=Math.max((window.screen.availWidth-s)/2,0).toString();let o="";const l={...age,width:s.toString(),height:r.toString(),top:i,left:a},c=bl().toLowerCase();n&&(o=jK(c)?cge:n),OK(c)&&(e=e||uge,l.scrollbars="yes");const h=Object.entries(l).reduce((m,[y,v])=>`${m}${y}=${v},`,"");if(qpe(c)&&o!=="_self")return hge(e||"",o),new TU(null);const p=window.open(e||"",o,h);Es(p,t,"popup-blocked");try{p.focus()}catch{}return new TU(p)}function hge(t,e){const n=document.createElement("a");n.href=t,n.target=e;const s=document.createEvent("MouseEvent");
1366s.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(s)}/**
1367 * @license
1368 * Copyright 2021 Google LLC
1369 *
1370 * Licensed under the Apache License, Version 2.0 (the "License");
1371 * you may not use this file except in compliance with the License.
1372 * You may obtain a copy of the License at
1373 *
1374 *   http://www.apache.org/licenses/LICENSE-2.0
1375 *
1376 * Unless required by applicable law or agreed to in writing, software
1377 * distributed under the License is distributed on an "AS IS" BASIS,
1378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1379 * See the License for the specific language governing permissions and
1380 * limitations under the License.
1381 */const fge="__/auth/handler",pge="emulator/auth/handler",mge=encodeURIComponent("fac");async function AU(t,e,n,s,r,i){Es(t.config.authDomain,t,"auth-domain-config-required"),Es(t.config.apiKey,t,"invalid-api-key");const a={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:s,v:Y1,eventId:r};if(e instanceof oL){e.setDefaultLanguage(t.languageCode),a.providerId=e.providerId||"",pfe(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[h,p]of Object.entries({}))a[h]=p}if(e instanceof fA){const h=e.getScopes().filter(p=>p!=="");h.length>0&&(a.scopes=h.join(","))}t.tenantId&&(a.tid=t.tenantId);const o=a;for(const h of Object.keys(o))o[h]===void 0&&delete o[h];const l=await t._getAppCheckToken(),c=l?`#${mge}=${encodeURIComponent(l)}`:"";return`${gge(t)}?${uA(o).slice(1)}${c}`}function gge({config:t}){return t.emulator?nL(t,pge):`https://${t.authDomain}/${fge}`}/**
1382 * @license
1383 * Copyright 2020 Google LLC
1384 *
1385 * Licensed under the Apache License, Version 2.0 (the "License");
1386 * you may not use this file except in compliance with the License.
1387 * You may obtain a copy of the License at
1388 *
1389 *   http://www.apache.org/licenses/LICENSE-2.0
1390 *
1391 * Unless required by applicable law or agreed to in writing, software
1392 * distributed under the License is distributed on an "AS IS" BASIS,
1393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1394 * See the License for the specific language governing permissions and
1395 * limitations under the License.
1396 */const T4="webStorageSupport";class yge{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=JK,this._completeRedirectFn=Fme,this._overrideRedirectResult=jme}async _openPopup(e,n,s,r){var a;Pm((a=this.eventManagers[e._key()])==null?void 0:a.manager,"_initialize() not called before _openPopup()");const i=await AU(e,n,s,L3(),r);return dge(e,i,lL())}async _openRedirect(e,n,s,r){await this._originValidation(e);const i=await AU(e,n,s,L3(),r);return bme(i),new Promise(()=>{})}_initialize(e){const n=e._key();if(this.eventManagers[n]){const{manager:r,promise:i}=this.eventManagers[n];return r?Promise.resolve(r):(Pm(i,"If manager is not set, promise should be"),i)}const s=this.initAndGetManager(e);return this.eventManagers[n]={promise:s},s.catch(()=>{delete this.eventManagers[n]}),s}async initAndGetManager(e){const n=await ige(e),s=new zme(e);return n.register("authEvent",r=>(Es(r==null?void 0:r.authEvent,e,"invalid-auth-event"),{status:s.onEvent(r.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:s},this.iframes[e._key()]=n,s}_isIframeWebStorageSupported(e,n){this.iframes[e._key()].send(T4,{type:T4},r=>{var a;const i=(a=r==null?void 0:r[0])==null?void 0:a[T4];i!==void 0&&n(!!i),hp(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const n=e._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=Kme(e)),this.originValidationPromises[n]}get _shouldInitProactively(){return zK()||LK()||iL()}}const xge=yge;var CU="@firebase/auth",kU="1.13.0";/**
1397 * @license
1398 * Copyright 2020 Google LLC
1399 *
1400 * Licensed under the Apache License, Version 2.0 (the "License");
1401 * you may not use this file except in compliance with the License.
1402 * You may obtain a copy of the License at
1403 *
1404 *   http://www.apache.org/licenses/LICENSE-2.0
1405 *
1406 * Unless required by applicable law or agreed to in writing, softw
1406are
1407 * distributed under the License is distributed on an "AS IS" BASIS,
1408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1409 * See the License for the specific language governing permissions and
1410 * limitations under the License.
1411 */class vge{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)==null?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const n=this.auth.onIdTokenChanged(s=>{e((s==null?void 0:s.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,n),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const n=this.internalListeners.get(e);n&&(this.internalListeners.delete(e),n(),this.updateProactiveRefresh())}assertAuthConfigured(){Es(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
1412 * @license
1413 * Copyright 2020 Google LLC
1414 *
1415 * Licensed under the Apache License, Version 2.0 (the "License");
1416 * you may not use this file except in compliance with the License.
1417 * You may obtain a copy of the License at
1418 *
1419 *   http://www.apache.org/licenses/LICENSE-2.0
1420 *
1421 * Unless required by applicable law or agreed to in writing, software
1422 * distributed under the License is distributed on an "AS IS" BASIS,
1423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1424 * See the License for the specific language governing permissions and
1425 * limitations under the License.
1426 */function bge(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function wge(t){N1(new bv("auth",(e,{options:n})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:o}=s.options;Es(a&&!a.includes(":"),"invalid-api-key",{appName:s.name});const l={apiKey:a,authDomain:o,clientPlatform:t,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:GK(t)},c=new Qpe(s,r,i,l);return rme(c,n),c},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,n,s)=>{e.getProvider("auth-internal").initialize()})),N1(new bv("auth-internal",e=>{const n=eM(e.getProvider("auth").getImmediate());return(s=>new vge(s))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),N0(CU,kU,bge(t)),N0(CU,kU,"esm2020")}/**
1427 * @license
1428 * Copyright 2021 Google LLC
1429 *
1430 * Licensed under the Apache License, Version 2.0 (the "License");
1431 * you may not use this file except in compliance with the License.
1432 * You may obtain a copy of the License at
1433 *
1434 *   http://www.apache.org/licenses/LICENSE-2.0
1435 *
1436 * Unless required by applicable law or agreed to in writing, software
1437 * distributed under the License is distributed on an "AS IS" BASIS,
1438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1439 * See the License for the specific language governing permissions and
1440 * limitations under the License.
1441 */const _ge=300,Sge=_K("authIdTokenMaxAge")||_ge;let IU=null;const Ege=t=>async e=>{const n=e&&await e.getIdTokenResult(),s=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(s&&s>Sge)return;const r=n==null?void 0:n.token;IU!==r&&(IU=r,await fetch(t,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))};
1441function Tge(t=gpe()){const e=ZO(t,"auth");if(e.isInitialized())return e.getImmediate();const n=sme(t,{popupRedirectResolver:xge,persistence:[Ime,yme,JK]}),s=_K("authTokenSyncURL");if(s&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(s,location.origin);if(location.origin===i.origin){const a=Ege(i.toString());fme(n,a,()=>a(n.currentUser)),hme(n,o=>a(o))}}const r=efe("auth");return r&&ime(n,`http://${r}`),n}function Age(){var t;return((t=document.getElementsByTagName("head"))==null?void 0:t[0])??document}Zpe({loadJS(t){return new Promise((e,n)=>{const s=document.createElement("script");s.setAttribute("src",t),s.onload=e,s.onerror=r=>{const i=Hh("internal-error");i.customData=r,n(i)},s.type="text/javascript",s.charset="UTF-8",Age().appendChild(s)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});wge("Browser");var Cge="firebase",kge="12.12.1";/**
1442 * @license
1443 * Copyright 2020 Google LLC
1444 *
1445 * Licensed under the Apache License, Version 2.0 (the "License");
1446 * you may not use this file except in compliance with the License.
1447 * You may obtain a copy of the License at
1448 *
1449 *   http://www.apache.org/licenses/LICENSE-2.0
1450 *
1451 * Unless required by applicable law or agreed to in writing, software
1452 * distributed under the License is distributed on an "AS IS" BASIS,
1453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1454 * See the License for the specific language governing permissions and
1455 * limitations under the License.
1456 */N0(Cge,kge,"app");var NU=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1457Copyright The Closure Library Authors.
1458SPDX-License-Identifier: Apache-2.0
1459*/var R0,iY;(function(){var t;/** @license
1460
1461 Copyright The Closure Library Authors.
1462 SPDX-License-Identifier: Apache-2.0
1463*/function e(D,R){function B(){}B.prototype=R.prototype,D.F=R.prototype,D.prototype=new B,D.prototype.constructor=D,D.D=function(G,X,H){for(var Y=Array(arguments.length-2),F=2;F<arguments.length;F++)Y[F-2]=arguments[F];return R.prototype[X].apply(G,Y)}}function n(){this.blockSize=-1}function s(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(s,n),s.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function r(D,R,B){B||(B=0);const G=Array(16);if(typeof R=="string")for(var X=0;X<16;++X)G[X]=R.charCodeAt(B++)|R.charCodeAt(B++)<<8|R.charCodeAt(B++)<<16|R.charCodeAt(B++)<<24;else for(X=0;X<16;++X)G[X]=R[B++]|R[B++]<<8|R[B++]<<16|R[B++]<<24;R=D.g[0],B=D.g[1],X=D.g[2];let H=D.g[3],Y;Y=R+(H^B&(X^H))+G[0]+3614090360&4294967295,R=B+(Y<<7&4294967295|Y>>>25),Y=H+(X^R&(B^X))+G[1]+3905402710&4294967295,H=R+(Y<<12&4294967295|Y>>>20),Y=X+(B^H&(R^B))+G[2]+606105819&4294967295,X=H+(Y<<17&4294967295|Y>>>15),Y=B+(R^X&(H^R))+G[3]+3250441966&4294967295,B=X+(Y<<22&4294967295|Y>>>10),Y=R+(H^B&(X^H))+G[4]+4118548399&4294967295,R=B+(Y<<7&4294967295|Y>>>25),Y=H+(X^R&(B^X))+G[5]+1200080426&4294967295,H=R+(Y<<12&4294967295|Y>>>20),Y=X+(B^H&(R^B))+G[6]+2821735955&4294967295,X=H+(Y<<17&4294967295|Y>>>15),Y=B+(R^X&(H^R))+G[7]+4249261313&4294967295,B=X+(Y<<22&4294967295|Y>>>10),Y=R+(H^B&(X^H))+G[8]+1770035416&4294967295,R=B+(Y<<7&4294967295|Y>>>25),Y=H+(X^R&(B^X))+G[9]+2336552879&4294967295,H=R+(Y<<12&4294967295|Y>>>20),Y=X+(B^H&(R^B))+G[10]+4294925233&4294967295,X=H+(Y<<17&4294967295|Y>>>15),Y=B+(R^X&(H^R))+G[11]+2304563134&4294967295,B=X+(Y<<22&4294967295|Y>>>10),Y=R+(H^B&(X^H))+G[12]+1804603682&4294967295,R=B+(Y<<7&4294967295|Y>>>25),Y=H+(X^R&(B^X))+G[13]+4254626195&4294967295,H=R+(Y<<12&4294967295|Y>>>20),Y=X+(B^H&(R^B))+G[14]+2792965006&4294967295,X=H+(Y<<17&4294967295|Y>>>15),Y=B+(R^X&(H^R))+G[15]+1236535329&4294967295,B=X+(Y<<22&4294967295|Y>>>10),Y=R+(X^H&(B^X))+G[1]+4129170786&4294967295,R=B+(Y<<5&4294967295|Y>>>27),Y=H+(B^X&(R^B))+G[6]+3225465664&4294967295,H=R+(Y<<9&4294967295|Y>>>23),Y=X+(R^B&(H^R))+G[11]+643717713&4294967295,X=H+(Y<<14&4294967295|Y>>>18),Y=B+(H^R&(X^H))+G[0]+3921069994&4294967295,B=X+(Y<<20&4294967295|Y>>>12),Y=R+(X^H&(B^X))+G[5]+3593408605&4294967295,R=B+(Y<<5&4294967295|Y>>>27),Y=H+(B^X&(R^B))+G[10]+38016083&4294967295,H=R+(Y<<9&4294967295|Y>>>23),Y=X+(R^B&(H^R))+G[15]+3634488961&4294967295,X=H+(Y<<14&4294967295|Y>>>18),Y=B+(H^R&(X^H))+G[4]+3889429448&4294967295,B=X+(Y<<20&4294967295|Y>>>12),Y=R+(X^H&(B^X))+G[9]+568446438&4294967295,R=B+(Y<<5&4294967295|Y>>>27),Y=H+(B^X&(R^B))+G[14]+3275163606&4294967295,H=R+(Y<<9&4294967295|Y>>>23),Y=X+(R^B&(H^R))+G[3]+4107603335&4294967295,X=H+(Y<<14&4294967295|Y>>>18),Y=B+(H^R&(X^H))+G[8]+1163531501&4294967295,B=X+(Y<<20&4294967295|Y>>>12),Y=R+(X^H&(B^X))+G[13]+2850285829&4294967295,R=B+(Y<<5&4294967295|Y>>>27),Y=H+(B^X&(R^B))+G[2]+4243563512&4294967295,H=R+(Y<<9&4294967295|Y>>>23),Y=X+(R^B&(H^R))+G[7]+1735328473&4294967295,X=H+(Y<<14&4294967295|Y>>>18),Y=B+(H^R&(X^H))+G[12]+2368359562&4294967295,B=X+(Y<<20&4294967295|Y>>>12),Y=R+(B^X^H)+G[5]+4294588738&4294967295,R=B+(Y<<4&4294967295|Y>>>28),Y=H+(R^B^X)+G[8]+2272392833&4294967295,H=R+(Y<<11&4294967295|Y>>>21),Y=X+(H^R^B)+G[11]+1839030562&4294967295,X=H+(Y<<16&4294967295|Y>>>16),Y=B+(X^H^R)+G[14]+4259657740&4294967295,B=X+(Y<<23&4294967295|Y>>>9),Y=R+(B^X^H)+G[1]+2763975236&4294967295,R=B+(Y<<4&4294967295|Y>>>28),Y=H+(R^B^X)+G[4]+1272893353&4294967295,H=R+(Y<<11&4294967295|Y>>>21),Y=X+(H^R^B)+G[7]+4139469664&4294967295,X=H+(Y<<16&4294967295|Y>>>16),Y=B+(X^H^R)+G[10]+3200236656&4294967295,B=X+(Y<<23&4294967295|Y>>>9),Y=R+(B^X^H)+G[13]+681279174&4294967295,R=B+(Y<<4&4294967295|Y>>>28),Y=H+(R^B^X)+G[0]+3936430074&4294967295,H=R+(Y<<11&4294967295|Y>>>21),Y=X+(H^R^B)+G[3]+3572445317&4294967295,X=H+(Y<<16&4294967295|Y>>>16),Y=B+(X^H^R)+G[6]+76029189&4294967295,B=X+(Y<<23&4294967295|Y>>>9),Y=R+(B^X^H)+G[9]+3654602809&4294967295,R=B+(Y<<4&4294967295|Y>>>28),Y=H+(R^B^X)+G[12]+3873151461&4294967295,H=R+(Y<<11&4294967295|Y>>>21),Y=X+(H^R^B)+G[15]+530742520&4294967295,X=H+(Y<<16&4294967295|Y>>>16),Y=B+(X^H^R)+G[2]+3299628645&4294967295,B=X+(Y<<23&4294967295|Y>>>9),Y=R+(X^(B|~H))+G[0]+4096336452&4294967295,R=B+(Y<<6&4294967295|Y>>>26),Y=H+(B^(R|~X))+G[7]+1126891415&4294967295,H=R+(Y<<10&4294967295|Y>>>22),Y=X+(R^(H|~B))+G[14]+2878612391&4294967295,X=H+(Y<<15&4294967295|Y>>>17),Y=B+(H^(X|~R))+G[5]+4237533241&4294967295,B=X+(Y<<21&4294967295|Y>>>11),Y=R+(X^(B|~H))+G[12]+1700485571&4294967295,R=B+(Y<<6&4294967295|Y>>>26),Y=H+(B^(R|~X))+G[3]+2399980690&4294967295,H=R+(Y<<10&4294967295|Y>>>22),Y=X+(R^(H|~B))+G[10]+4293915773&4294967295,X=H+(Y<<15&4294967295|Y>>>17),Y=B+(H^(X|~R))+G[1]+2240044497&4294967295,B=X+(Y<<21&4294967295|Y>>>11),Y=R+(X^(B|~H))+G[8]+1873313359&4294967295,R=B+(Y<<6&4294967295|Y>>>26),Y=H+(B^(R|~X))+G[15]+4264355552&4294967295,H=R+(Y<<10&4294967295|Y>>>22),Y=X+(R^(H|~B))+G[6]+2734768916&4294967295,X=H+(Y<<15&4294967295|Y>>>17),Y=B+(H^(X|~R))+G[13]+1309151649&4294967295,B=X+(Y<<21&4294967295|Y>>>11),Y=R+(X^(B|~H))+G[4]+4149444226&4294967295,R=B+(Y<<6&4294967295|Y>>>26),Y=H+(B^(R|~X))+G[11]+3174756917&4294967295,H=R+(Y<<10&4294967295|Y>>>22),Y=X+(R^(H|~B))+G[2]+718787259&4294967295,X=H+(Y<<15&4294967295|Y>>>17),Y=B+(H^(X|~R))+G[9]+3951481745&4294967295,D.g[0]=D.g[0]+R&4294967295,D.g[1]=D.g[1]+(X+(Y<<21&4294967295|Y>>>11))&4294967295,D.g[2]=D.g[2]+X&4294967295,D.g[3]=D.g[3]+H&4294967295}s.prototype.v=function(D,R){R===void 0&&(R=D.length);const B=R-this.blockSize,G=this.C;let X=this.h,H=0;for(;H<R;){if(X==0)for(;H<=B;
1463)r(this,D,H),H+=this.blockSize;if(typeof D=="string"){for(;H<R;)if(G[X++]=D.charCodeAt(H++),X==this.blockSize){r(this,G),X=0;break}}else for(;H<R;)if(G[X++]=D[H++],X==this.blockSize){r(this,G),X=0;break}}this.h=X,this.o+=R},s.prototype.A=function(){var D=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);D[0]=128;for(var R=1;R<D.length-8;++R)D[R]=0;R=this.o*8;for(var B=D.length-8;B<D.length;++B)D[B]=R&255,R/=256;for(this.v(D),D=Array(16),R=0,B=0;B<4;++B)for(let G=0;G<32;G+=8)D[R++]=this.g[B]>>>G&255;return D};function i(D,R){var B=o;return Object.prototype.hasOwnProperty.call(B,D)?B[D]:B[D]=R(D)}function a(D,R){this.h=R;const B=[];let G=!0;for(let X=D.length-1;X>=0;X--){const H=D[X]|0;G&&H==R||(B[X]=H,G=!1)}this.g=B}var o={};function l(D){return-128<=D&&D<128?i(D,function(R){return new a([R|0],R<0?-1:0)}):new a([D|0],D<0?-1:0)}function c(D){if(isNaN(D)||!isFinite(D))return p;if(D<0)return S(c(-D));const R=[];let B=1;for(let G=0;D>=B;G++)R[G]=D/B|0,B*=4294967296;return new a(R,0)}function h(D,R){if(D.length==0)throw Error("number format error: empty string");if(R=R||10,R<2||36<R)throw Error("radix out of range: "+R);if(D.charAt(0)=="-")return S(h(D.substring(1),R));if(D.indexOf("-")>=0)throw Error('number format error: interior "-" character');const B=c(Math.pow(R,8));let G=p;for(let H=0;H<D.length;H+=8){var X=Math.min(8,D.length-H);const Y=parseInt(D.substring(H,H+X),R);X<8?(X=c(Math.pow(R,X)),G=G.j(X).add(c(Y))):(G=G.j(B),G=G.add(c(Y)))}return G}var p=l(0),m=l(1),y=l(16777216);t=a.prototype,t.m=function(){if(b(this))return-S(this).m();let D=0,R=1;for(let B=0;B<this.g.length;B++){const G=this.i(B);D+=(G>=0?G:4294967296+G)*R,R*=4294967296}return D},t.toString=function(D){if(D=D||10,D<2||36<D)throw Error("radix out of range: "+D);if(v(this))return"0";if(b(this))return"-"+S(this).toString(D);const R=c(Math.pow(D,6));var B=this;let G="";for(;;){const X=j(B,R).g;B=E(B,X.j(R));let H=((B.g.length>0?B.g[0]:B.h)>>>0).toString(D);if(B=X,v(B))return H+G;for(;H.length<6;)H="0"+H;G=H+G}},t.i=function(D){return D<0?0:D<this.g.length?this.g[D]:this.h};function v(D){if(D.h!=0)return!1;for(let R=0;R<D.g.length;R++)if(D.g[R]!=0)return!1;return!0}function b(D){return D.h==-1}t.l=function(D){return D=E(this,D),b(D)?-1:v(D)?0:1};function S(D){const R=D.g.length,B=[];for(let G=0;G<R;G++)B[G]=~D.g[G];return new a(B,~D.h).add(m)}t.abs=function(){return b(this)?S(this):this},t.add=function(D){const R=Math.max(this.g.length,D.g.length),B=[];let G=0;for(let X=0;X<=R;X++){let H=G+(this.i(X)&65535)+(D.i(X)&65535),Y=(H>>>16)+(this.i(X)>>>16)+(D.i(X)>>>16);G=Y>>>16,H&=65535,Y&=65535,B[X]=Y<<16|H}return new a(B,B[B.length-1]&-2147483648?-1:0)};function E(D,R){return D.add(S(R))}t.j=function(D){if(v(this)||v(D))return p;if(b(this))return b(D)?S(this).j(S(D)):S(S(this).j(D));if(b(D))return S(this.j(S(D)));if(this.l(y)<0&&D.l(y)<0)return c(this.m()*D.m());const R=this.g.length+D.g.length,B=[];for(var G=0;G<2*R;G++)B[G]=0;for(G=0;G<this.g.length;G++)for(let X=0;X<D.g.length;X++){const H=this.i(G)>>>16,Y=this.i(G)&65535,F=D.i(X)>>>16,we=D.i(X)&65535;B[2*G+2*X]+=Y*we,I(B,2*G+2*X),B[2*G+2*X+1]+=H*we,I(B,2*G+2*X+1),B[2*G+2*X+1]+=Y*F,I(B,2*G+2*X+1),B[2*G+2*X+2]+=H*F,I(B,2*G+2*X+2)}for(D=0;D<R;D++)B[D]=B[2*D+1]<<16|B[2*D];for(D=R;D<2*R;D++)B[D]=0;return new a(B,0)};function I(D,R){for(;(D[R]&65535)!=D[R];)D[R+1]+=D[R]>>>16,D[R]&=65535,R++}function M(D,R){this.g=D,this.h=R}function j(D,R){if(v(R))throw Error("division by zero");if(v(D))return new M(p,p);if(b(D))return R=j(S(D),R),new M(S(R.g),S(R.h));if(b(R))return R=j(D,S(R)),new M(S(R.g),R.h);if(D.g.length>30){if(b(D)||b(R))throw Error("slowDivide_ only works with positive integers.");for(var B=m,G=R;G.l(D)<=0;)B=L(B),G=L(G);var X=K(B,1),H=K(G,1);for(G=K(G,2),B=K(B,2);!v(G);){var Y=H.add(G);Y.l(D)<=0&&(X=X.add(B),H=Y),G=K(G,1),B=K(B,1)}return R=E(D,X.j(R)),new M(X,R)}for(X=p;D.l(R)>=0;){for(B=Math.max(1,Math.floor(D.m()/R.m())),G=Math.ceil(Math.log(B)/Math.LN2),G=G<=48?1:Math.pow(2,G-48),H=c(B),Y=H.j(R);b(Y)||Y.l(D)>0;)B-=G,H=c(B),Y=H.j(R);v(H)&&(H=m),X=X.add(H),D=E(D,Y)}return new M(X,D)}t.B=function(D){return j(this,D).h},t.and=function(D){const R=Math.max(this.g.length,D.g.length),B=[];for(let G=0;G<R;G++)B[G]=this.i(G)&D.i(G);return new a(B,this.h&D.h)},t.or=function(D){const R=Math.max(this.g.length,D.g.length),B=[];for(let G=0;G<R;G++)B[G]=this.i(G)|D.i(G);return new a(B,this.h|D.h)},t.xor=function(D){const R=Math.max(this.g.length,D.g.length),B=[];for(let G=0;G<R;G++)B[G]=this.i(G)^D.i(G);return new a(B,this.h^D.h)};function L(D){const R=D.g.length+1,B=[];for(let G=0;G<R;G++)B[G]=D.i(G)<<1|D.i(G-1)>>>31;return new a(B,D.h)}function K(D,R){const B=R>>5;R%=32;const G=D.g.length-B,X=[];for(let H=0;H<G;H++)X[H]=R>0?D.i(H+B)>>>R|D.i(H+B+1)<<32-R:D.i(H+B);return new a(X,D.h)}s.prototype.digest=s.prototype.A,s.prototype.reset=s.prototype.u,s.prototype.update=s.prototype.v,iY=s,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=c,a.fromString=h,R0=a}).apply(typeof NU<"u"?NU:typeof self<"u"?self:typeof window<"u"?window:{});var Ck=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1464Copyright The Closure Library Authors.
1465SPDX-License-Identifier: Apache-2.0
1466*/var aY,rS,oY,mI,U3,lY,cY,uY;(function(){var t,e=Object.defineProperty;function n(C){C=[typeof globalThis=="object"&&globalThis,C,typeof window=="object"&&window,typeof self=="object"&&self,typeof Ck=="object"&&Ck];for(var W=0;W<C.length;++W){var ne=C[W];if(ne&&ne.Math==Math)return ne}throw Error("Cannot find global object")}var s=n(this);function r(C,W){if(W)e:{var ne=s;C=C.split(".");for(var ye=0;ye<C.length-1;ye++){var Xe=C[ye];if(!(Xe in ne))break e;ne=ne[Xe]}C=C[C.length-1],ye=ne[C],W=W(ye),W!=ye&&W!=null&&e(ne,C,{configurable:!0,writable:!0,value:W})}}r("Symbol.dispose",function(C){return C||Symbol("Symbol.dispose")}),r("Array.prototype.values",function(C){return C||function(){return this[Symbol.iterator]()}}),r("Object.entries",function(C){return C||function(W){var ne=[],ye;for(ye in W)Object.prototype.hasOwnProperty.call(W,ye)&&ne.push([ye,W[ye]]);return ne}});/** @license
1467
1468 Copyright The Closure Library Authors.
1469 SPDX-License-Identifier: Apache-2.0
1470*/var i=i||{},a=this||self;function o(C){var W=typeof C;return W=="object"&&C!=null||W=="function"}function l(C,W,ne){return C.call.apply(C.bind,arguments)}function c(C,W,ne){return c=l,c.apply(null,arguments)}
1470function h(C,W){var ne=Array.prototype.slice.call(arguments,1);return function(){var ye=ne.slice();return ye.push.apply(ye,arguments),C.apply(this,ye)}}function p(C,W){function ne(){}ne.prototype=W.prototype,C.Z=W.prototype,C.prototype=new ne,C.prototype.constructor=C,C.Ob=function(ye,Xe,rt){for(var Vt=Array(arguments.length-2),Zn=2;Zn<arguments.length;Zn++)Vt[Zn-2]=arguments[Zn];return W.prototype[Xe].apply(ye,Vt)}}var m=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?C=>C&&AsyncContext.Snapshot.wrap(C):C=>C;function y(C){const W=C.length;if(W>0){const ne=Array(W);for(let ye=0;ye<W;ye++)ne[ye]=C[ye];return ne}return[]}function v(C,W){for(let ye=1;ye<arguments.length;ye++){const Xe=arguments[ye];var ne=typeof Xe;if(ne=ne!="object"?ne:Xe?Array.isArray(Xe)?"array":ne:"null",ne=="array"||ne=="object"&&typeof Xe.length=="number"){ne=C.length||0;const rt=Xe.length||0;C.length=ne+rt;for(let Vt=0;Vt<rt;Vt++)C[ne+Vt]=Xe[Vt]}else C.push(Xe)}}class b{constructor(W,ne){this.i=W,this.j=ne,this.h=0,this.g=null}get(){let W;return this.h>0?(this.h--,W=this.g,this.g=W.next,W.next=null):W=this.i(),W}}function S(C){a.setTimeout(()=>{throw C},0)}function E(){var C=D;let W=null;return C.g&&(W=C.g,C.g=C.g.next,C.g||(C.h=null),W.next=null),W}class I{constructor(){this.h=this.g=null}add(W,ne){const ye=M.get();ye.set(W,ne),this.h?this.h.next=ye:this.g=ye,this.h=ye}}var M=new b(()=>new j,C=>C.reset());class j{constructor(){this.next=this.g=this.h=null}set(W,ne){this.h=W,this.g=ne,this.next=null}reset(){this.next=this.g=this.h=null}}let L,K=!1,D=new I,R=()=>{const C=Promise.resolve(void 0);L=()=>{C.then(B)}};function B(){for(var C;C=E();){try{C.h.call(C.g)}catch(ne){S(ne)}var W=M;W.j(C),W.h<100&&(W.h++,C.next=W.g,W.g=C)}K=!1}function G(){this.u=this.u,this.C=this.C}G.prototype.u=!1,G.prototype.dispose=function(){this.u||(this.u=!0,this.N())},G.prototype[Symbol.dispose]=function(){this.dispose()},G.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function X(C,W){this.type=C,this.g=this.target=W,this.defaultPrevented=!1}X.prototype.h=function(){this.defaultPrevented=!0};var H=(function(){if(!a.addEventListener||!Object.defineProperty)return!1;var C=!1,W=Object.defineProperty({},"passive",{get:function(){C=!0}});try{const ne=()=>{};a.addEventListener("test",ne,W),a.removeEventListener("test",ne,W)}catch{}return C})();function Y(C){return/^[\s\xa0]*$/.test(C)}function F(C,W){X.call(this,C?C.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,C&&this.init(C,W)}p(F,X),F.prototype.init=function(C,W){const ne=this.type=C.type,ye=C.changedTouches&&C.changedTouches.length?C.changedTouches[0]:null;this.target=C.target||C.srcElement,this.g=W,W=C.relatedTarget,W||(ne=="mouseover"?W=C.fromElement:ne=="mouseout"&&(W=C.toElement)),this.relatedTarget=W,ye?(this.clientX=ye.clientX!==void 0?ye.clientX:ye.pageX,this.clientY=ye.clientY!==void 0?ye.clientY:ye.pageY,this.screenX=ye.screenX||0,this.screenY=ye.screenY||0):(this.clientX=C.clientX!==void 0?C.clientX:C.pageX,this.clientY=C.clientY!==void 0?C.clientY:C.pageY,this.screenX=C.screenX||0,this.screenY=C.screenY||0),this.button=C.button,this.key=C.key||"",this.ctrlKey=C.ctrlKey,this.altKey=C.altKey,this.shiftKey=C.shiftKey,this.metaKey=C.metaKey,this.pointerId=C.pointerId||0,this.pointerType=C.pointerType,this.state=C.state,this.i=C,C.defaultPrevented&&F.Z.h.call(this)},F.prototype.h=function(){F.Z.h.call(this);const C=this.i;C.preventDefault?C.preventDefault():C.returnValue=!1};var we="closure_listenable_"+(Math.random()*1e6|0),me=0;function xe(C,W,ne,ye,Xe){this.listener=C,this.proxy=null,this.src=W,this.type=ne,this.capture=!!ye,this.ha=Xe,this.key=++me,this.da=this.fa=!1}function Le(C){C.da=!0,C.listener=null,C.proxy=null,C.src=null,C.ha=null}function ve(C,W,ne){for(const ye in C)W.call(ne,C[ye],ye,C)}function ce(C,W){for(const ne in C)W.call(void 0,C[ne],ne,C)}function ie(C){const W={};for(const ne in C)W[ne]=C[ne];return W}const de="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleStr
1470ing toString valueOf".split(" ");function Re(C,W){let ne,ye;for(let Xe=1;Xe<arguments.length;Xe++){ye=arguments[Xe];for(ne in ye)C[ne]=ye[ne];for(let rt=0;rt<de.length;rt++)ne=de[rt],Object.prototype.hasOwnProperty.call(ye,ne)&&(C[ne]=ye[ne])}}function Se(C){this.src=C,this.g={},this.h=0}Se.prototype.add=function(C,W,ne,ye,Xe){const rt=C.toString();C=this.g[rt],C||(C=this.g[rt]=[],this.h++);const Vt=gt(C,W,ye,Xe);return Vt>-1?(W=C[Vt],ne||(W.fa=!1)):(W=new xe(W,this.src,rt,!!ye,Xe),W.fa=ne,C.push(W)),W};function De(C,W){const ne=W.type;if(ne in C.g){var ye=C.g[ne],Xe=Array.prototype.indexOf.call(ye,W,void 0),rt;(rt=Xe>=0)&&Array.prototype.splice.call(ye,Xe,1),rt&&(Le(W),C.g[ne].length==0&&(delete C.g[ne],C.h--))}}function gt(C,W,ne,ye){for(let Xe=0;Xe<C.length;++Xe){const rt=C[Xe];if(!rt.da&&rt.listener==W&&rt.capture==!!ne&&rt.ha==ye)return Xe}return-1}var yt="closure_lm_"+(Math.random()*1e6|0),xt={};function Nt(C,W,ne,ye,Xe){if(Array.isArray(W)){for(let rt=0;rt<W.length;rt++)Nt(C,W[rt],ne,ye,Xe);return null}return ne=he(ne),C&&C[we]?C.J(W,ne,o(ye)?!!ye.capture:!1,Xe):wt(C,W,ne,!1,ye,Xe)}function wt(C,W,ne,ye,Xe,rt){if(!W)throw Error("Invalid event type");const Vt=o(Xe)?!!Xe.capture:!!Xe;let Zn=Ie(C);if(Zn||(C[yt]=Zn=new Se(C)),ne=Zn.add(W,ne,ye,Vt,rt),ne.proxy)return ne;if(ye=zt(),ne.proxy=ye,ye.src=C,ye.listener=ne,C.addEventListener)H||(Xe=Vt),Xe===void 0&&(Xe=!1),C.addEventListener(W.toString(),ye,Xe);else if(C.attachEvent)C.attachEvent(J(W.toString()),ye);else if(C.addListener&&C.removeListener)C.addListener(ye);else throw Error("addEventListener and attachEvent are unavailable.");return ne}function zt(){function C(ne){return W.call(C.src,C.listener,ne)}const W=We;return C}function _n(C,W,ne,ye,Xe){if(Array.isArray(W))for(var rt=0;rt<W.length;rt++)_n(C,W[rt],ne,ye,Xe);else ye=o(ye)?!!ye.capture:!!ye,ne=he(ne),C&&C[we]?(C=C.i,rt=String(W).toString(),rt in C.g&&(W=C.g[rt],ne=gt(W,ne,ye,Xe),ne>-1&&(Le(W[ne]),Array.prototype.splice.call(W,ne,1),W.length==0&&(delete C.g[rt],C.h--)))):C&&(C=Ie(C))&&(W=C.g[W.toString()],C=-1,W&&(C=gt(W,ne,ye,Xe)),(ne=C>-1?W[C]:null)&&Zt(ne))}function Zt(C){if(typeof C!="number"&&C&&!C.da){var W=C.src;if(W&&W[we])De(W.i,C);else{var ne=C.type,ye=C.proxy;W.removeEventListener?W.removeEventListener(ne,ye,C.capture):W.detachEvent?W.detachEvent(J(ne),ye):W.addListener&&W.removeListener&&W.removeListener(ye),(ne=Ie(W))?(De(ne,C),ne.h==0&&(ne.src=null,W[yt]=null)):Le(C)}}}function J(C){return C in xt?xt[C]:xt[C]="on"+C}function We(C,W){if(C.da)C=!0;else{W=new F(W,this);const ne=C.listener,ye=C.ha||C.src;C.fa&&Zt(C),C=ne.call(ye,W)}return C}function Ie(C){return C=C[yt],C instanceof Se?C:null}var ge="__closure_events_fn_"+(Math.random()*1e9>>>0);function he(C){return typeof C=="function"?C:(C[ge]||(C[ge]=function(W){return C.handleEvent(W)}),C[ge])}function Ae(){G.call(this),this.i=new Se(this),this.M=this,this.G=null}p(Ae,G),Ae.prototype[we]=!0,Ae.prototype.removeEventListener=function(C,W,ne,ye){_n(this,C,W,ne,ye)};function et(C,W){var ne,ye=C.G;if(ye)for(ne=[];ye;ye=ye.G)ne.push(ye);if(C=C.M,ye=W.type||W,typeof W=="string")W=new X(W,C);else if(W instanceof X)W.target=W.target||C;else{var Xe=W;W=new X(ye,C),Re(W,Xe)}Xe=!0;let rt,Vt;if(ne)for(Vt=ne.length-1;Vt>=0;Vt--)rt=W.g=ne[Vt],Xe=nt(rt,ye,!0,W)&&Xe;if(rt=W.g=C,Xe=nt(rt,ye,!0,W)&&Xe,Xe=nt(rt,ye,!1,W)&&Xe,ne)for(Vt=0;Vt<ne.length;Vt++)rt=W.g=ne[Vt],Xe=nt(rt,ye,!1,W)&&Xe}Ae.prototype.N=function(){if(Ae.Z.N.call(this),this.i){var C=this.i;for(const W in C.g){const ne=C.g[W];for(let ye=0;ye<ne.length;ye++)Le(ne[ye]);delete C.g[W],C.h--}}this.G=null},Ae.prototype.J=function(C,W,ne,ye){return this.i.add(String(C),W,!1,ne,ye)},Ae.prototype.K=function(C,W,ne,ye){return this.i.add(String(C),W,!0,ne,ye)};function nt(C,W,ne,ye){if(W=C.i.g[String(W)],!W)return!0;W=W.concat();let Xe=!0;for(let rt=0;rt<W.length;++rt){const Vt=W[rt];if(Vt&&!Vt.da&&Vt.capture==ne){const Zn=Vt.listener,dr=Vt.ha||Vt.src;Vt.fa&&De(C.i,Vt),Xe=Zn.call(dr,ye)!==!1&&Xe}}return Xe&&!ye.defaultPrevented}function He(C,W){if(typeof C!="function")if(C&&typeof C.handleEvent=="function")C=c(C.handleEvent,C);else throw Error("Invalid listener argument");return Number(W)>2147483647?-1:a.setTimeout(C,W||0)}function ft(C){C.g=He(()=>{C.g=null,C.i&&(C.i=!1,ft(C))},C.l);const W=C.h;C.h=null,C.m.apply(null,W)}class Mt extends G{constructor(W,ne){super(),this.m=W,this.l=ne,this.h=null,this.i=!1,this.g=null}j(W){this.h=arguments,this.g?this.i=!0:ft(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function pt(C){G.call(this),this.h=C,this.g={}}p(pt,G);var Oe=[];function hn(C){ve(C.g,function(W,ne){this.g.hasOwnProperty(ne)&&Zt(W)},C),C.g={}}pt.prototype.N=function(){pt.Z.N.call(this),hn(this)},pt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Yt=a.JSON.stringify,Qe=a.JSON.parse,tn=class{stringify(C){return a.JSON.stringify(C,void 0)}parse(C){return a.JSON.parse(C,void 0)}};function je(){}function Ue(){}var bt={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function ht(){X.call(this,"d")}p(ht,X);function Dt(){X.call(this,"c")}p(Dt,X);var Ut={},Lt=null;function Wt(){return Lt=Lt||new Ae}Ut.Ia="serverreachability";function fn(C){X.call(this,Ut.Ia,C)}p(fn,X);function Jt(C){const W=Wt();et(W,new fn(W))}Ut.STAT_EVENT="statevent";function Kn(C,W){X.call(this,Ut.STAT_EVENT,C),this.stat=W}p(Kn,X);function nn(C){const W=Wt();et(W,new Kn(W,C))}Ut.Ja="timingevent";function Wn(C,W){X.call(this,Ut.Ja,C),this.size=W}p(Wn,X);function ln(C,W){if(typeof C!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){C()},W)}function ns(){this.g=!0}ns.prototype.ua=function(){this.g=!1};function Js(C,W,ne,ye,Xe,rt){C.info(function(){if(C.g)if(rt){var Vt="",Zn=rt.split("&");for(let lr=0;lr<Zn.length;lr++){var dr=Zn[lr].split("=");if(dr.length>1){const wr=dr[0];dr=dr[1];const aa=wr.split("_");Vt=aa.length>=2&&aa[1]=="type"?Vt+(wr+"="+dr+"&"):Vt+(wr+"=redacted&")}}}else Vt=null;else Vt=rt;return"XMLHTTP REQ ("+ye+") [attempt "+Xe+"]: "+W+`
1471`+ne+`
1472`+Vt})}function ur(C,W,ne,ye,Xe,rt,Vt){C.info(function(){return"XMLHTTP RESP ("+ye+") [ attempt "+Xe+"]: "+W+`
1473`+ne+`
1474`+rt+" "+Vt})}function zs(C,W,ne,ye){C.info(function(){return"XMLHTTP TEXT ("+W+"): "+ps(C,ne)+(ye?" "+ye:"")})}function fs(C,W){C.info(function(){return"TIMEOUT: "+W})}ns.prototype.info=function(){};function ps(C,W){if(!C.g)return W;if(!W)return null;try{const rt=JSON.parse(W);if(rt){for(C=0;C<rt.length;C++)if(Array.isArray(rt[C])){var ne=rt[C];if(!(ne.length<2)){var ye=ne[1];if(Array.isArray(ye)&&!(ye.length<1)){var Xe=ye[0];if(Xe!="noop"&&Xe!="stop"&&Xe!="close")for(let Vt=1;Vt<ye.length;Vt++)ye[Vt]=""}}}}return Yt(rt)}catch{return W}}var ms={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},Me={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"},lt;function jt(){}p(jt,je),jt.prototype.g=function(){return new XMLHttpRequest},lt=new jt;function Qt(C){return encodeURIComponent(String(C))}function Sn(C){var W=1;C=C.split(":");const ne=[];for(;W>0&&C.length;)ne.push(C.shift()),W--;return C.length&&ne.push(C.join(":")),ne}function yn(C,W,ne,ye){this.j=C,this.i=W,this.l=ne,this.S=ye||1,this.V=new pt(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new Ft}function Ft(){this.i=null,this.g="",this.h=!1}var sn={},rn={};function bs(C,W,ne){C.M=1,C.A=tt(ke(W)),C.u=ne,C.R=!0,gs(C,null)}function gs(C,W){C.F=Date.now(),Ps(C),C.B=ke(C.A);var ne=C.B,ye=C.S;Array.isArray(ye)||(ye=[String(ye)]),ti(ne.i,"t",ye),C.C=0,ne=C.j.L,C.h=new Ft,C.g=Fc(C.j,ne?W:null,!C.u),C.P>0&&(C.O=new Mt(c(C.Y,C,C.g),C.P)),W=C.V,ne=C.g,ye=C.ba;var Xe="readystatechange";Array.isArray(Xe)||(Xe&&(Oe[0]=Xe.toString()),Xe=Oe);for(let rt=0;rt<Xe.length;rt++){const Vt=Nt(ne,Xe[rt],ye||W.handleEvent,!1,W.h||W);if(!Vt)break;W.g[Vt.key]=Vt}W=C.J?ie(C.J):{},C.u?(C.v||(C.v="POST"),W["Content-Type"]="application/x-www-form-urlencoded",C.g.ea(C.B,C.v,C.u,W)):(C.v="GET",C.g.ea(C.B,C.v,null,W)),Jt(),Js(C.i,C.v,C.B,C.l,C.S,C.u)}yn.prototype.ba=function(C){C=C.target;const W=this.O;W&&As(C)==3?W.j():this.Y(C)},yn.prototype.Y=function(C){try{if(C==this.g)e:{const Zn=As(this.g),dr=this.g.ya(),lr=this.g.ca();if(!(Zn<3)&&(Zn!=3||this.g&&(this.h.h||this.g.la()||Pr(this.g)))){this.K||Zn!=4||dr==7||(dr==8||lr<=0?Jt(3):Jt(2)),ws(this);var W=this.g.ca();this.X=W;var ne=us(this);if(this.o=W==200,ur(this.i,this.v,this.B,this.l,this.S,Zn,W),this.o){if(this.U&&!this.L){t:{if(this.g){var ye,Xe=this.g;if((ye=Xe.g?Xe.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!Y(ye)){var rt=ye;break t}}rt=null}if(C=rt)zs(this.i,this.l,C,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Pn(this,C);else{this.o=!1,this.m=3,nn(12),ys(this),$s(this);break e}}if(this.R){C=!0;let wr;for(;!this.K&&this.C<ne.length;)if(wr=ls(this,ne),wr==rn){Zn==4&&(this.m=4,nn(14),C=!1),zs(this.i,this.l,null,"[Incomplete Response]");break}else if(wr==sn){this.m=4,nn(15),zs(this.i,this.l,ne,"[Invalid Chunk]"),C=!1;break}else zs(this.i,this.l,wr,null),Pn(this,wr);if(Hn(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Zn!=4||ne.length!=0||this.h.h||(this.m=1,nn(16),C=!1),this.o=this.o&&C,!C)zs(this.i,this.l,ne,"[Invalid Chunked Response]"),ys(this),$s(this);else if(ne.length>0&&!this.W){this.W=!0;var Vt=this.j;Vt.g==this&&Vt.aa&&!Vt.P&&(Vt.j.info("Great, no buffering proxy detected. Bytes received: "+ne.length),xr(Vt),Vt.P=!0,nn(11))}}else zs(this.i,this.l,ne,null),Pn(this,ne);Zn==4&&ys(this),this.o&&!this.K&&(Zn==4?yi(this.j,this):(this.o=!1,Ps(this)))}else kr(this.g),W==400&&ne.indexOf("Unknown SID")>0?(this.m=3,nn(12)):(this.m=0,nn(13)),ys(this),$s(this)}}}catch{}finally{}};function us(C){if(!Hn(C))return C.g.la();const W=Pr(C.g);if(W==="")return"";let ne="";const ye=W.length,Xe=As(C.g)==4;if(!C.h.i){if(typeof TextDecoder>"u")return ys(C),$s(C),"";C.h.i=new a.TextDecoder}for(let rt=0;rt<ye;rt++)C.h.h=!0,ne+=C.h.i.decode(W[rt],{stream:!(Xe&&rt==ye-1)});
1474return W.length=0,C.h.g+=ne,C.C=0,C.h.g}function Hn(C){return C.g?C.v=="GET"&&C.M!=2&&C.j.Aa:!1}function ls(C,W){var ne=C.C,ye=W.indexOf(`
1475`,ne);return ye==-1?rn:(ne=Number(W.substring(ne,ye)),isNaN(ne)?sn:(ye+=1,ye+ne>W.length?rn:(W=W.slice(ye,ye+ne),C.C=ye+ne,W)))}yn.prototype.cancel=function(){this.K=!0,ys(this)};function Ps(C){C.T=Date.now()+C.H,rr(C,C.H)}function rr(C,W){if(C.D!=null)throw Error("WatchDog timer not null");C.D=ln(c(C.aa,C),W)}function ws(C){C.D&&(a.clearTimeout(C.D),C.D=null)}yn.prototype.aa=function(){this.D=null;const C=Date.now();C-this.T>=0?(fs(this.i,this.B),this.M!=2&&(Jt(),nn(17)),ys(this),this.m=2,$s(this)):rr(this,this.T-C)};function $s(C){C.j.I==0||C.K||yi(C.j,C)}function ys(C){ws(C);var W=C.O;W&&typeof W.dispose=="function"&&W.dispose(),C.O=null,hn(C.V),C.g&&(W=C.g,C.g=null,W.abort(),W.dispose())}function Pn(C,W){try{var ne=C.j;if(ne.I!=0&&(ne.g==C||kn(ne.h,C))){if(!C.L&&kn(ne.h,C)&&ne.I==3){try{var ye=ne.Ba.g.parse(W)}catch{ye=null}if(Array.isArray(ye)&&ye.length==3){var Xe=ye;if(Xe[0]==0){e:if(!ne.v){if(ne.g)if(ne.g.F+3e3<C.F)Sa(ne),sa(ne);else break e;ci(ne),nn(18)}}else ne.xa=Xe[1],0<ne.xa-ne.K&&Xe[2]<37500&&ne.F&&ne.A==0&&!ne.C&&(ne.C=ln(c(ne.Va,ne),6e3));$n(ne.h)<=1&&ne.ta&&(ne.ta=void 0)}else Xo(ne,11)}else if((C.L||ne.g==C)&&Sa(ne),!Y(W))for(Xe=ne.Ba.g.parse(W),W=0;W<Xe.length;W++){let lr=Xe[W];const wr=lr[0];if(!(wr<=ne.K))if(ne.K=wr,lr=lr[1],ne.I==2)if(lr[0]=="c"){ne.M=lr[1],ne.ba=lr[2];const aa=lr[3];aa!=null&&(ne.ka=aa,ne.j.info("VER="+ne.ka));const qa=lr[4];qa!=null&&(ne.za=qa,ne.j.info("SVER="+ne.za));const No=lr[5];No!=null&&typeof No=="number"&&No>0&&(ye=1.5*No,ne.O=ye,ne.j.info("backChannelRequestTimeoutMs_="+ye)),ye=ne;const fa=C.g;if(fa){const pa=fa.g?fa.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(pa){var rt=ye.h;rt.g||pa.indexOf("spdy")==-1&&pa.indexOf("quic")==-1&&pa.indexOf("h2")==-1||(rt.j=rt.l,rt.g=new Set,rt.h&&(Nn(rt,rt.h),rt.h=null))}if(ye.G){const $u=fa.g?fa.g.getResponseHeader("X-HTTP-Session-Id"):null;$u&&(ye.wa=$u,Ne(ye.J,ye.G,$u))}}ne.I=3,ne.l&&ne.l.ra(),ne.aa&&(ne.T=Date.now()-C.F,ne.j.info("Handshake RTT: "+ne.T+"ms")),ye=ne;var Vt=C;if(ye.na=kd(ye,ye.L?ye.ba:null,ye.W),Vt.L){Bn(ye.h,Vt);var Zn=Vt,dr=ye.O;dr&&(Zn.H=dr),Zn.D&&(ws(Zn),Ps(Zn)),ye.g=Vt}else Cd(ye);ne.i.length>0&&Bi(ne)}else lr[0]!="stop"&&lr[0]!="close"||Xo(ne,7);else ne.I==3&&(lr[0]=="stop"||lr[0]=="close"?lr[0]=="stop"?Xo(ne,7):wl(ne):lr[0]!="noop"&&ne.l&&ne.l.qa(lr),ne.A=0)}}Jt(4)}catch{}}var ir=class{constructor(C,W){this.g=C,this.map=W}};function ot(C){this.l=C||10,a.PerformanceNavigationTiming?(C=a.performance.getEntriesByType("navigation"),C=C.length>0&&(C[0].nextHopProtocol=="hq"||C[0].nextHopProtocol=="h2")):C=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=C?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function ar(C){return C.h?!0:C.g?C.g.size>=C.j:!1}function $n(C){return C.h?1:C.g?C.g.size:0}function kn(C,W){return C.h?C.h==W:C.g?C.g.has(W):!1}function Nn(C,W){C.g?C.g.add(W):C.h=W}function Bn(C,W){C.h&&C.h==W?C.h=null:C.g&&C.g.has(W)&&C.g.delete(W)}ot.prototype.cancel=function(){if(this.i=er(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const C of this.g.values())C.cancel();this.g.clear()}};function er(C){if(C.h!=null)return C.i.concat(C.h.G);if(C.g!=null&&C.g.size!==0){let W=C.i;for(const ne of C.g.values())W=W.concat(ne.G);return W}return y(C.i)}var oi=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function or(C,W){if(C){C=C.split("&");for(let ne=0;ne<C.length;ne++){const ye=C[ne].indexOf("=");let Xe,rt=null;ye>=0?(Xe=C[ne].substring(0,ye),rt=C[ne].substring(ye+1)):Xe=C[ne],W(Xe,rt?decodeURIComponent(rt.replace(/\+/g," ")):"")}}}function ue(C){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let W;C instanceof ue?(this.l=C.l,pe(this,C.j),this.o=C.o,this.g=C.g,Pe(this,C.u),this.h=C.h,$e(this,gi(C.i)),this.m=C.m):C&&(W=String(C).match(oi))?(this.l=!1,pe(this,W[1]||"",!0),this.o=mt(W[2]||""),this.g=mt(W[3]||"",!0),Pe(this,W[4]),this.h=mt(W[5]||"",!0),$e(this,W[6]||"",!0),this.m=mt(W[7]||"")):(this.l=!1,this.i=new Jn(null,this.l))}ue.prototype.toString=function(){const C=[];var W=this.j;W&&C.push(Ct(W,kt,!0),":");var ne=this.g;return(ne||W=="file")&&(C.push("//"),(W=this.o)&&C.push(Ct(W,kt,!0),"@"),C.push(Qt(ne).replace(/%25([0-9a-fA-F]{2}
1475)/g,"%$1")),ne=this.u,ne!=null&&C.push(":",String(ne))),(ne=this.h)&&(this.g&&ne.charAt(0)!="/"&&C.push("/"),C.push(Ct(ne,ne.charAt(0)=="/"?qn:Xt,!0))),(ne=this.i.toString())&&C.push("?",ne),(ne=this.m)&&C.push("#",Ct(ne,an)),C.join("")},ue.prototype.resolve=function(C){const W=ke(this);let ne=!!C.j;ne?pe(W,C.j):ne=!!C.o,ne?W.o=C.o:ne=!!C.g,ne?W.g=C.g:ne=C.u!=null;var ye=C.h;if(ne)Pe(W,C.u);else if(ne=!!C.h){if(ye.charAt(0)!="/")if(this.g&&!this.h)ye="/"+ye;else{var Xe=W.h.lastIndexOf("/");Xe!=-1&&(ye=W.h.slice(0,Xe+1)+ye)}if(Xe=ye,Xe==".."||Xe==".")ye="";else if(Xe.indexOf("./")!=-1||Xe.indexOf("/.")!=-1){ye=Xe.lastIndexOf("/",0)==0,Xe=Xe.split("/");const rt=[];for(let Vt=0;Vt<Xe.length;){const Zn=Xe[Vt++];Zn=="."?ye&&Vt==Xe.length&&rt.push(""):Zn==".."?((rt.length>1||rt.length==1&&rt[0]!="")&&rt.pop(),ye&&Vt==Xe.length&&rt.push("")):(rt.push(Zn),ye=!0)}ye=rt.join("/")}else ye=Xe}return ne?W.h=ye:ne=C.i.toString()!=="",ne?$e(W,gi(C.i)):ne=!!C.m,ne&&(W.m=C.m),W};function ke(C){return new ue(C)}function pe(C,W,ne){C.j=ne?mt(W,!0):W,C.j&&(C.j=C.j.replace(/:$/,""))}function Pe(C,W){if(W){if(W=Number(W),isNaN(W)||W<0)throw Error("Bad port number "+W);C.u=W}else C.u=null}function $e(C,W,ne){W instanceof Jn?(C.i=W,_a(C.i,C.l)):(ne||(W=Ct(W,Xn)),C.i=new Jn(W,C.l))}function Ne(C,W,ne){C.i.set(W,ne)}function tt(C){return Ne(C,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),C}function mt(C,W){return C?W?decodeURI(C.replace(/%25/g,"%2525")):decodeURIComponent(C):""}function Ct(C,W,ne){return typeof C=="string"?(C=encodeURI(C).replace(W,_t),ne&&(C=C.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),C):null}function _t(C){return C=C.charCodeAt(0),"%"+(C>>4&15).toString(16)+(C&15).toString(16)}var kt=/[#\/\?@]/g,Xt=/[#\?:]/g,qn=/[#\?]/g,Xn=/[#\?@]/g,an=/#/g;function Jn(C,W){this.h=this.g=null,this.i=C||null,this.j=!!W}function Qn(C){C.g||(C.g=new Map,C.h=0,C.i&&or(C.i,function(W,ne){C.add(decodeURIComponent(W.replace(/\+/g," ")),ne)}))}t=Jn.prototype,t.add=function(C,W){Qn(this),this.i=null,C=yr(this,C);let ne=this.g.get(C);return ne||this.g.set(C,ne=[]),ne.push(W),this.h+=1,this};function Gs(C,W){Qn(C),W=yr(C,W),C.g.has(W)&&(C.i=null,C.h-=C.g.get(W).length,C.g.delete(W))}function Cr(C,W){return Qn(C),W=yr(C,W),C.g.has(W)}t.forEach=function(C,W){Qn(this),this.g.forEach(function(ne,ye){ne.forEach(function(Xe){C.call(W,Xe,ye,this)},this)},this)};function Qs(C,W){Qn(C);let ne=[];if(typeof W=="string")Cr(C,W)&&(ne=ne.concat(C.g.get(yr(C,W))));else for(C=Array.from(C.g.values()),W=0;W<C.length;W++)ne=ne.concat(C[W]);return ne}t.set=function(C,W){return Qn(this),this.i=null,C=yr(this,C),Cr(this,C)&&(this.h-=this.g.get(C).length),this.g.set(C,[W]),this.h+=1,this},t.get=function(C,W){return C?(C=Qs(this,C),C.length>0?String(C[0]):W):W};function ti(C,W,ne){Gs(C,W),ne.length>0&&(C.i=null,C.g.set(yr(C,W),y(ne)),C.h+=ne.length)}t.toString=function(){if(this.i)return this.i;if(!this.g)return"";const C=[],W=Array.from(this.g.keys());for(let ye=0;ye<W.length;ye++){var ne=W[ye];const Xe=Qt(ne);ne=Qs(this,ne);for(let rt=0;rt<ne.length;rt++){let Vt=Xe;ne[rt]!==""&&(Vt+="="+Qt(ne[rt])),C.push(Vt)}}return this.i=C.join("&")};function gi(C){const W=new Jn;return W.i=C.i,C.g&&(W.g=new Map(C.g),W.h=C.h),W}function yr(C,W){return W=String(W),C.j&&(W=W.toLowerCase()),W}function _a(C,W){W&&!C.j&&(Qn(C),C.i=null,C.g.forEach(function(ne,ye){const Xe=ye.toLowerCase();ye!=Xe&&(Gs(this,ye),ti(this,Xe,ne))},C)),C.j=W}function Va(C,W){const ne=new ns;if(a.Image){const ye=new Image;ye.onload=h(li,ne,"TestLoadImage: loaded",!0,W,ye),ye.onerror=h(li,ne,"TestLoadImage: error",!1,W,ye),ye.onabort=h(li,ne,"TestLoadImage: abort",!1,W,ye),ye.ontimeout=h(li,ne,"TestLoadImage: timeout",!1,W,ye),a.setTimeout(function(){ye.ontimeout&&ye.ontimeout()},1e4),ye.src=C}else W(!1)}function Ls(C,W){const ne=new ns,ye=new AbortController,Xe=setTimeout(()=>{ye.abort(),li(ne,"TestPingServer: timeout",!1,W)},1e4);fetch(C,{signal:ye.signal}).then(rt=>{clearTimeout(Xe),rt.ok?li(ne,"TestPingServer: ok",!0,W):li(ne,"TestPingServer: server error",!1,W)}).catch(()=>{clearTimeout(Xe),li(ne,"TestPingServer: error",!1,W)})}function li(C,W,ne,ye,Xe){try{Xe&&(Xe.onload=null,Xe.onerror=null,Xe.onabort=null,Xe.ontimeout=null),ye(ne)}catch{}}function ni(){this.g=new tn}function pn(C){this.i=C.Sb||null,this.h=C.ab||!1}p(pn,je),pn.prototype.g=function(){return new ji(this.i,this.h)};function ji(C,W){Ae.call(this),this.H=C,this.o=W,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}p(ji,Ae),t=ji.prototype,t.open=function(C,W){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=C,this.D=W,this.readyState=1,Ye(this)},t.send=function(C){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");
vendor: 9,279 bytes, lines 1475-1478
1475if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const W={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};C&&(W.body=C),(this.H||a).fetch(new Request(this.D,W)).then(this.Pa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,Ai(this)),this.readyState=0},t.Pa=function(C){if(this.g&&(this.l=C,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=C.headers,this.readyState=2,Ye(this)),this.g&&(this.readyState=3,Ye(this),this.g)))if(this.responseType==="arraybuffer")C.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in C){if(this.j=C.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;za(this)}else C.text().then(this.Oa.bind(this),this.ga.bind(this))};function za(C){C.j.read().then(C.Ma.bind(C)).catch(C.ga.bind(C))}t.Ma=function(C){if(this.g){if(this.o&&C.value)this.response.push(C.value);else if(!this.o){var W=C.value?C.value:new Uint8Array(0);(W=this.B.decode(W,{stream:!C.done}))&&(this.response=this.responseText+=W)}C.done?Ai(this):Ye(this),this.readyState==3&&za(this)}},t.Oa=function(C){this.g&&(this.response=this.responseText=C,Ai(this))},t.Na=function(C){this.g&&(this.response=C,Ai(this))},t.ga=function(){this.g&&Ai(this)};function Ai(C){C.readyState=4,C.l=null,C.j=null,C.B=null,Ye(C)}t.setRequestHeader=function(C,W){this.A.append(C,W)},t.getResponseHeader=function(C){return this.h&&this.h.get(C.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";const C=[],W=this.h.entries();for(var ne=W.next();!ne.done;)ne=ne.value,C.push(ne[0]+": "+ne[1]),ne=W.next();return C.join(`\r
1476`)};function Ye(C){C.onreadystatechange&&C.onreadystatechange.call(C)}Object.defineProperty(ji.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(C){this.m=C?"include":"same-origin"}});function vt(C){let W="";return ve(C,function(ne,ye){W+=ye,W+=":",W+=ne,W+=`\r
1477`}),W}function ct(C,W,ne){e:{for(ye in ne){var ye=!1;break e}ye=!0}ye||(ne=vt(ne),typeof C=="string"?ne!=null&&Qt(ne):Ne(C,W,ne))}function Kt(C){Ae.call(this),this.headers=new Map,this.L=C||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}p(Kt,Ae);var ds=/^https?$/i,Mr=["POST","PUT"];t=Kt.prototype,t.Fa=function(C){this.H=C},t.ea=function(C,W,ne,ye){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+C);W=W?W.toUpperCase():"GET",this.D=C,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():lt.g(),this.g.onreadystatechange=m(c(this.Ca,this));try{this.B=!0,this.g.open(W,String(C),!0),this.B=!1}catch(rt){Ds(this,rt);return}if(C=ne||"",ne=new Map(this.headers),ye)if(Object.getPrototypeOf(ye)===Object.prototype)for(var Xe in ye)ne.set(Xe,ye[Xe]);else if(typeof ye.keys=="function"&&typeof ye.get=="function")for(const rt of ye.keys())ne.set(rt,ye.get(rt));else throw Error("Unknown input type for opt_headers: "+String(ye));ye=Array.from(ne.keys()).find(rt=>rt.toLowerCase()=="content-type"),Xe=a.FormData&&C instanceof a.FormData,!(Array.prototype.indexOf.call(Mr,W,void 0)>=0)||ye||Xe||ne.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[rt,Vt]of ne)this.g.setRequestHeader(rt,Vt);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(C),this.v=!1}catch(rt){Ds(this,rt)}};function Ds(C,W){C.h=!1,C.g&&(C.j=!0,C.g.abort(),C.j=!1),C.l=W,C.o=5,Hs(C),Yn(C)}function Hs(C){C.A||(C.A=!0,et(C,"complete"),et(C,"error"))}t.abort=function(C){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=C||7,et(this,"complete"),et(this,"abort"),Yn(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Yn(this,!0)),Kt.Z.N.call(this)},t.Ca=function(){this.u||(this.B||this.v||this.j?un(this):this.Xa())},t.Xa=function(){un(this)};function un(C){if(C.h&&typeof i<"u"){if(C.v&&As(C)==4)setTimeout(C.Ca.bind(C),0);else if(et(C,"readystatechange"),As(C)==4){C.h=!1;try{const rt=C.ca();e:switch(rt){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var W=!0;break e;default:W=!1}var ne;if(!(ne=W)){var ye;if(ye=rt===0){let Vt=String(C.D).match(oi)[1]||null;!Vt&&a.self&&a.self.location&&(Vt=a.self.location.protocol.slice(0,-1)),ye=!ds.test(Vt?Vt.toLowerCase():"")}ne=ye}if(ne)et(C,"complete"),et(C,"success");else{C.o=6;try{var Xe=As(C)>2?C.g.statusText:""}catch{Xe=""}C.l=Xe+" ["+C.ca()+"]",Hs(C)}}finally{Yn(C)}}}}function Yn(C,W){if(C.g){C.m&&(clearTimeout(C.m),C.m=null);const ne=C.g;C.g=null,W||et(C,"ready");try{ne.onreadystatechange=null}catch{}}}t.isActive=function(){return!!this.g};function As(C){return C.g?C.g.readyState:0}t.ca=function(){try{return As(this)>2?this.g.status:-1}catch{return-1}},t.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},t.La=function(C){if(this.g){var W=this.g.responseText;return C&&W.indexOf(C)==0&&(W=W.substring(C.length)),Qe(W)}};function Pr(C){try{if(!C.g)return null;if("response"in C.g)return C.g.response;switch(C.F){case"":case"text":return C.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in C.g)return C.g.mozResponseArrayBuffer}return null}catch{return null}}function kr(C){const W={};C=(C.g&&As(C)>=2&&C.g.getAllResponseHeaders()||"").split(`\r
1478`);for(let ye=0;ye<C.length;ye++){if(Y(C[ye]))continue;var ne=Sn(C[ye]);const Xe=ne[0];if(ne=ne[1],typeof ne!="string")continue;ne=ne.trim();const rt=W[Xe]||[];W[Xe]=rt,rt.push(ne)}ce(W,function(ye){return ye.join(", ")})}t.ya=function(){return this.o},t.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function Yi(C,W,ne){return ne&&ne.internalChannelParams&&ne.internalChannelParams[C]||W}function Ga(C){this.za=0,this.i=[],this.j=new ns,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=Yi("failFast",!1,C),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=Yi("baseRetryDelayMs",5e3,C),this.Za=Yi("retryDelaySeedMs",1e4,C),this.Ta=Yi("forwardChannelMaxRetries",2,C),this.va=Yi("forwardChannelRequestTimeoutMs",2e4,C),this.ma=C&&C.xmlHttpFactory||void 0,this.Ua=C&&C.Rb||void 0,this.Aa=C&&C.useFetchStreams||!1,this.O=void 0,this.L=C&&C.supportsCrossDomainXhr||!1,this.M="",this.h=new ot(C&&C.concurrentRequestLimit),this.Ba=new ni,this.S=C&&C.fastHandshake||!1,this.R=C&&C.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=C&&C.Pb||!1,C&&C.ua&&this.j.ua(),C&&C.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&C&&C.detectBufferingProxy||!1,this.ia=void 0,C&&C.longPollingTimeout&&C.longPollingTimeout>0&&(this.ia=C.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}t=Ga.prototype,t.ka=8,t.I=1,t.connect=function(C,W,ne,ye){nn(0),this.W=C,this.H=W||{},ne&&ye!==void 0&&(this.H.OSID=ne,this.H.OAID=ye),this.F=this.X,this.J=kd(this,null,this.W),Bi(this)};function wl(C){if(ra(C),C.I==3){var W=C.V++,ne=ke(C.J);if(Ne(ne,"SID",C.M),Ne(ne,"RID",W),Ne(ne,"TYPE","terminate"),Uc(C,ne),W=new yn(C,C.j,W),W.M=2,W.A=tt(ke(ne)),ne=!1,a.navigator&&a.navigator.sendBeacon)try{ne=a.navigator.sendBeacon(W.A.toString(),"")}catch{}!ne&&a.Image&&(new Image().src=W.A,ne=!0),ne||(W.g=Fc(W.j,null),W.g.ea(W.A)),W.F=Date.now(),Ps(W)}Ha(C)}function sa(C){C.g&&(xr(C),C.g.cancel(),C.g=null)}function ra(C){sa(C),C.v&&(a.clearTimeout(C.v),C.v=null),Sa(C),C.h.cancel(),C.m&&(typeof C.m=="number"&&a.clearTimeout(C.m),C.m=null)}function Bi(C){if(!ar(C.h)&&!C.m){C.m=!0;var W=C.Ea;L||R(),K||(L(),K=!0),D.add(W,C),C.D=0}}function _l(C,W){return $n(C.h)>=C.h.j-(C.m?1:0)?!1:C.m?(C.i=W.G.concat(C.i),!0):C.I==1||C.I==2||C.D>=(C.Sa?0:C.Ta)?!1:(C.m=ln(c(C.Ea,C,W),uo(C,C.D)),C.D++,!0)}t.Ea=function(C){if(this.m)if(this.m=null,this.I==1){if(!C){this.V=Math.floor(Math.random()*1e5),C=this.V++;const Xe=new yn(this,this.j,C);let rt=this.o;if(this.U&&(rt?(rt=ie(rt),Re(rt,this.U)):rt=this.U),this.u!==null||this.R||(Xe.J=rt,rt=null),this.S)e:{for(var W=0,ne=0;ne<this.i.length;ne++){t:{var ye=this.i[ne];if("__data__"in ye.map&&(ye=ye.map.__data__,typeof ye=="string")){ye=ye.length;break t}ye=void 0}if(ye===void 0)break;if(W+=ye,W>4096){W=ne;break e}if(W===4096||ne===this.i.length-1){W=ne+1;break e}}W=1e3}else W=1e3;W=ic(this,Xe,W),ne=ke(this.J),Ne(ne,"RID",C),Ne(ne,"CVER",22),this.G&&Ne(ne,"X-HTTP-Session-Id",this.G),Uc(this,ne),rt&&(this.R?W="headers="+Qt(vt(rt))+"&"+W:this.u&&ct(ne,this.u,rt)),Nn(this.h,Xe),this.Ra&&Ne(ne,"TYPE","init"),this.S?(Ne(ne,"$req",W),Ne(ne,"SID","null"),Xe.U=!0,bs(Xe,ne,null)):bs(Xe,ne,W),this.I=2}}else this.I==3&&(C?Pu(this,C):this.i.length==0||ar(this.h)||Pu(this))};function Pu(C,W){var ne;W?ne=W.l:ne=C.V++;const ye=ke(C.J);Ne(ye,"SID",C.M),Ne(ye,"RID",ne),Ne(ye,"AID",C.K),Uc(C,ye),C.u&&
vendor: 6,714 bytes, lines 1478-1482
1478C.o&&ct(ye,C.u,C.o),ne=new yn(C,C.j,ne,C.D+1),C.u===null&&(ne.J=C.o),W&&(C.i=W.G.concat(C.i)),W=ic(C,ne,1e3),ne.H=Math.round(C.va*.5)+Math.round(C.va*.5*Math.random()),Nn(C.h,ne),bs(ne,ye,W)}function Uc(C,W){C.H&&ve(C.H,function(ne,ye){Ne(W,ye,ne)}),C.l&&ve({},function(ne,ye){Ne(W,ye,ne)})}function ic(C,W,ne){ne=Math.min(C.i.length,ne);const ye=C.l?c(C.l.Ka,C.l,C):null;e:{var Xe=C.i;let Zn=-1;for(;;){const dr=["count="+ne];Zn==-1?ne>0?(Zn=Xe[0].g,dr.push("ofs="+Zn)):Zn=0:dr.push("ofs="+Zn);let lr=!0;for(let wr=0;wr<ne;wr++){var rt=Xe[wr].g;const aa=Xe[wr].map;if(rt-=Zn,rt<0)Zn=Math.max(0,Xe[wr].g-100),lr=!1;else try{rt="req"+rt+"_"||"";try{var Vt=aa instanceof Map?aa:Object.entries(aa);for(const[qa,No]of Vt){let fa=No;o(No)&&(fa=Yt(No)),dr.push(rt+qa+"="+encodeURIComponent(fa))}}catch(qa){throw dr.push(rt+"type="+encodeURIComponent("_badmap")),qa}}catch{ye&&ye(aa)}}if(lr){Vt=dr.join("&");break e}}Vt=void 0}return C=C.i.splice(0,ne),W.G=C,Vt}function Cd(C){if(!C.g&&!C.v){C.Y=1;var W=C.Da;L||R(),K||(L(),K=!0),D.add(W,C),C.A=0}}function ci(C){return C.g||C.v||C.A>=3?!1:(C.Y++,C.v=ln(c(C.Da,C),uo(C,C.A)),C.A++,!0)}t.Da=function(){if(this.v=null,gn(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var C=4*this.T;this.j.info("BP detection timer enabled: "+C),this.B=ln(c(this.Wa,this),C)}},t.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,nn(10),sa(this),gn(this))};function xr(C){C.B!=null&&(a.clearTimeout(C.B),C.B=null)}function gn(C){C.g=new yn(C,C.j,"rpc",C.Y),C.u===null&&(C.g.J=C.o),C.g.P=0;var W=ke(C.na);Ne(W,"RID","rpc"),Ne(W,"SID",C.M),Ne(W,"AID",C.K),Ne(W,"CI",C.F?"0":"1"),!C.F&&C.ia&&Ne(W,"TO",C.ia),Ne(W,"TYPE","xmlhttp"),Uc(C,W),C.u&&C.o&&ct(W,C.u,C.o),C.O&&(C.g.H=C.O);var ne=C.g;C=C.ba,ne.M=1,ne.A=tt(ke(W)),ne.u=null,ne.R=!0,gs(ne,C)}t.Va=function(){this.C!=null&&(this.C=null,sa(this),ci(this),nn(19))};function Sa(C){C.C!=null&&(a.clearTimeout(C.C),C.C=null)}function yi(C,W){var ne=null;if(C.g==W){Sa(C),xr(C),C.g=null;var ye=2}else if(kn(C.h,W))ne=W.G,Bn(C.h,W),ye=1;else return;if(C.I!=0){if(W.o)if(ye==1){ne=W.u?W.u.length:0,W=Date.now()-W.F;var Xe=C.D;ye=Wt(),et(ye,new Wn(ye,ne)),Bi(C)}else Cd(C);else if(Xe=W.m,Xe==3||Xe==0&&W.X>0||!(ye==1&&_l(C,W)||ye==2&&ci(C)))switch(ne&&ne.length>0&&(W=C.h,W.i=W.i.concat(ne)),Xe){case 1:Xo(C,5);break;case 4:Xo(C,10);break;case 3:Xo(C,6);break;default:Xo(C,2)}}}function uo(C,W){let ne=C.Qa+Math.floor(Math.random()*C.Za);return C.isActive()||(ne*=2),ne*W}function Xo(C,W){if(C.j.info("Error code "+W),W==2){var ne=c(C.bb,C),ye=C.Ua;const Xe=!ye;ye=new ue(ye||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||pe(ye,"https"),tt(ye),Xe?Va(ye.toString(),ne):Ls(ye.toString(),ne)}else nn(2);C.I=0,C.l&&C.l.pa(W),Ha(C),ra(C)}t.bb=function(C){C?(this.j.info("Successfully pinged google.com"),nn(2)):(this.j.info("Failed to ping google.com"),nn(1))};function Ha(C){if(C.I=0,C.ja=[],C.l){const W=er(C.h);(W.length!=0||C.i.length!=0)&&(v(C.ja,W),v(C.ja,C.i),C.h.i.length=0,y(C.i),C.i.length=0),C.l.oa()}}function kd(C,W,ne){var ye=ne instanceof ue?ke(ne):new ue(ne);if(ye.g!="")W&&(ye.g=W+"."+ye.g),Pe(ye,ye.u);else{var Xe=a.location;ye=Xe.protocol,W=W?W+"."+Xe.hostname:Xe.hostname,Xe=+Xe.port;const rt=new ue(null);ye&&pe(rt,ye),W&&(rt.g=W),Xe&&Pe(rt,Xe),ne&&(rt.h=ne),ye=rt}return ne=C.G,W=C.wa,ne&&W&&Ne(ye,ne,W),Ne(ye,"VER",C.ka),Uc(C,ye),ye}function Fc(C,W,ne){if(W&&!C.L)throw Error("Can't create secondary domain capable XhrIo object.");return W=C.Aa&&!C.ma?new Kt(new pn({ab:ne})):new Kt(C.ma),W.Fa(C.L),W}t.isActive=function(){return!!this.l&&this.l.isActive(this)};function Id(){}t=Id.prototype,t.ra=function(){},t.qa=function(){},t.pa=function(){},t.oa=function(){},t.isActive=function(){return!0},t.Ka=function(){};function ia(){}ia.prototype.g=function(C,W){return new qr(C,W)};function qr(C,W){Ae.call(this),this.g=new Ga(W),this.l=C,this.h=W&&W.messageUrlParams||null,C=W&&W.messageHeaders||null,W&&W.clientProtocolHeaderRequired&&(C?C["X-Client-Protocol"]="webchannel":C={"X-Client-Protocol":"webchannel"}),this.g.o=C,C=W&&W.initMessageHeaders||null,W&&W.messageContentType&&(C?C["X-WebChannel-Content-Type"]=W.messageContentType:C={"X-WebChannel-Content-Type":W.messageContentType}),W&&W.sa&&(C?C["X-WebChannel-Client-Profile"]=W.sa:C={"X-WebChannel-Client-Profile":W.sa}),this.g.U=C,(C=W&&W.Qb)&&!Y(C)&&(this.g.u=C),this.A=W&&W.supportsCrossDomainXhr||!1,this.v=W&&W.sendRawJson||!1,(W=W&&W.httpSessionIdParam)&&!Y(W)&&(this.g.G=W,C=this.h,C!==null&&W in C&&(C=this.h,W in C&&delete C[W])),this.j=new Io(this)}p(qr,Ae),qr.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},qr.prototype.close=function(){wl(this.g)},qr.prototype.o=function(C){var W=this.g;if(typeof C=="string"){var ne={};ne.__data__=C,C=ne}else this.v&&(ne={},ne.__data__=Yt(C),C=ne);W.i.push(new ir(W.Ya++,C)),W.I==3&&Bi(W)},qr.prototype.N=function(){this.g.l=null,delete this.j,wl(this.g),delete this.g,qr.Z.N.call(this)};function ac(C){ht.call(this),C.__headers__&&(this.headers=C.__headers__,this.statusCode=C.__status__,delete C.__headers__,delete C.__status__);var W=C.__sm__;if(W){e:{for(const ne in W){C=ne;break e}C=void 0}(this.i=C)&&(C=this.i,W=W!==null&&C in W?W[C]:void 0),this.data=W}else this.data=C}p(ac,ht);function Sl(){Dt.call(this),this.status=1}p(Sl,Dt);function Io(C){this.g=C}p(Io,Id),Io.prototype.ra=function(){et(this.g,"a")},Io.prototype.qa=function(C){et(this.g,new ac(C))},Io.prototype.pa=function(C){et(this.g,new Sl)},Io.prototype.oa=function(){et(this.g,"b")},ia.prototype.createWebChannel=ia.prototype.g,qr.prototype.send=qr.prototype.o,qr.prototype.open=qr.prototype.m,qr.prototype.close=qr.prototype.close,uY=function(){return new ia},cY=function(){return Wt()},lY=Ut,U3={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},ms.NO_ERROR=0,ms.TIMEOUT=8,ms.HTTP_ERROR=6,mI=ms,Me.COMPLETE="complete",oY=Me,Ue.EventType=bt,bt.OPEN="a",bt.CLOSE="b",bt.ERROR="c",bt.MESSAGE="d",Ae.prototype.listen=Ae.prototype.J,rS=Ue,Kt.prototype.listenOnce=Kt.prototype.K,Kt.prototype.getLastError=Kt.prototype.Ha,Kt.prototype.getLastErrorCode=Kt.prototype.ya,Kt.prototype.getStatus=Kt.prototype.ca,Kt.prototype.getResponseJson=Kt.prototype.La,Kt.prototype.getResponseText=Kt.prototype.la,Kt.prototype.send=Kt.prototype.ea,Kt.prototype.setWithCredentials=Kt.prototype.Fa,aY=Kt}).apply(typeof Ck<"u"?Ck:typeof self<"u"?self:typeof window<"u"?window:{});/**
1479 * @license
1480 * Copyright 2017 Google LLC
1481 *
1482 * Licensed under the Apache License, Version 2.0 (the "License");
1483 * you may not use this file except in compliance with the License.
1484 * You may obtain a copy of the License at
1485 *
1486 *   http://www.apache.org/licenses/LICENSE-2.0
1487 *
1488 * Unless required by applicable law or agreed to in writing, software
1489 * distributed under the License is distributed on an "AS IS" BASIS,
1490 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1491 * See the License for the specific language governing permissions and
1492 * limitations under the License.
1493 */class Lc{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Lc.UNAUTHENTICATED=new Lc(null),Lc.GOOGLE_CREDENTIALS=new Lc("google-credentials-uid"),Lc.FIRST_PARTY=new Lc("first-party-uid"),Lc.MOCK_USER=new Lc("mock-user");/**
1494 * @license
1495 * Copyright 2017 Google LLC
1496 *
1497 * Licensed under the Apache License, Version 2.0 (the "License");
1498 * you may not use this file except in compliance with the License.
1499 * You may obtain a copy of the License at
1500 *
1501 *   http://www.apache.org/licenses/LICENSE-2.0
1502 *
1503 * Unless required by applicable law or agreed to in writing, software
1504 * distributed under the License is distributed on an "AS IS" BASIS,
1505 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1506 * See the License for the specific language governing permissions and
1507 * limitations under the License.
1508 */let J1="12.12.0";function Ige(t){J1=t}/**
1509 * @license
1510 * Copyright 2020 Google LLC
1511 *
1512 * Licensed under the Apache License, Version 2.0 (the "License");
1513 * you may not use this file except in compliance with the License.
1514 * You may obtain a copy of the License at
1515 *
1516 *   http://www.apache.org/licenses/LICENSE-2.0
1517 *
1518 * Unless required by applicable law or agreed to in writing, software
1519 * distributed under the License is distributed on an "AS IS" BASIS,
1520 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1521 * See the License for the specific language governing permissions and
1522 * limitations under the License.
1523 *//**
1524 * @license
1525 * Copyright 2017 Google LLC
1526 *
1527 * Licensed under the Apache License, Version 2.0 (the "License");
1528 * you may not use this file except in compliance with the License.
1529 * You may obtain a copy of the License at
1530 *
1531 *   http://www.apache.org/licenses/LICENSE-2.0
1532 *
1533 * Unless required by applicable law or agreed to in writing, software
1534 * distributed under the License is distributed on an "AS IS" BASIS,
1535 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1536 * See the License for the specific language governing permissions and
1537 * limitations under the License.
1538 */const _v=new JO("@firebase/firestore");function Vb(){return _v.logLevel}function xn(t,...e){if(_v.logLevel<=pr.DEBUG){const n=e.map(uL);_v.debug(`Firestore (${J1}): ${t}`,...n)}}function $m(t,...e){if(_v.logLevel<=pr.ERROR){const n=e.map(uL);_v.error(`Firestore (${J1}): ${t}`,...n)}}function M1(t,...e){if(_v.logLevel<=pr.WARN){const n=e.map(uL);_v.warn(`Firestore (${J1}): ${t}`,...n)}}function uL(t){if(typeof t=="string")return t;try{return(function(n){return JSON.stringify(n)})(t)}catch{return t}}/**
1539 * @license
1540 * Copyright 2017 Google LLC
1541 *
1542 * Licensed under the Apache License, Version 2.0 (the "License");
1543 * you may not use this file except in compliance with the License.
1544 * You may obtain a copy of the License at
1545 *
1546 *   http://www.apache.org/licenses/LICENSE-2.0
1547 *
1548 * Unless required by applicable law or agreed to in writing, software
1549 * distributed under the License is distributed on an "AS IS" BASIS,
1550 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1551 * See the License for the specific language governing permissions and
1552 * limitations under the License.
1553 */function ss(t,e,n){let s="Unexpected state";typeof e=="string"?s=e:n=e,dY(t,s,n)}function dY(t,e,n){let s=`FIRESTORE (${J1}) INTERNAL ASSERTION FAILED: ${e} (ID: ${t.toString(16)})`;if(n!==void 0)try{s+=" CONTEXT: "+JSON.stringify(n)}catch{s+=" CONTEXT: "+n}throw $m(s),new Error(s)}function Ar(t,e,n,s){let r="Unexpected state";
vendor: 5,444 bytes, lines 1553-1598
1553typeof n=="string"?r=n:s=n,t||dY(e,r,s)}function Ns(t,e){return t}/**
1554 * @license
1555 * Copyright 2017 Google LLC
1556 *
1557 * Licensed under the Apache License, Version 2.0 (the "License");
1558 * you may not use this file except in compliance with the License.
1559 * You may obtain a copy of the License at
1560 *
1561 *   http://www.apache.org/licenses/LICENSE-2.0
1562 *
1563 * Unless required by applicable law or agreed to in writing, software
1564 * distributed under the License is distributed on an "AS IS" BASIS,
1565 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1566 * See the License for the specific language governing permissions and
1567 * limitations under the License.
1568 */const Ot={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Cn extends Fm{constructor(e,n){super(e,n),this.code=e,this.message=n,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
1569 * @license
1570 * Copyright 2017 Google LLC
1571 *
1572 * Licensed under the Apache License, Version 2.0 (the "License");
1573 * you may not use this file except in compliance with the License.
1574 * You may obtain a copy of the License at
1575 *
1576 *   http://www.apache.org/licenses/LICENSE-2.0
1577 *
1578 * Unless required by applicable law or agreed to in writing, software
1579 * distributed under the License is distributed on an "AS IS" BASIS,
1580 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1581 * See the License for the specific language governing permissions and
1582 * limitations under the License.
1583 */class Im{constructor(){this.promise=new Promise(((e,n)=>{this.resolve=e,this.reject=n}))}}/**
1584 * @license
1585 * Copyright 2017 Google LLC
1586 *
1587 * Licensed under the Apache License, Version 2.0 (the "License");
1588 * you may not use this file except in compliance with the License.
1589 * You may obtain a copy of the License at
1590 *
1591 *   http://www.apache.org/licenses/LICENSE-2.0
1592 *
1593 * Unless required by applicable law or agreed to in writing, software
1594 * distributed under the License is distributed on an "AS IS" BASIS,
1595 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1596 * See the License for the specific language governing permissions and
1597 * limitations under the License.
1598 */class Nge{constructor(e,n){this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Rge{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,n){e.enqueueRetryable((()=>n(Lc.UNAUTHENTICATED)))}shutdown(){}}class Mge{constructor(e){this.t=e,this.currentUser=Lc.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,n){Ar(this.o===void 0,42304);let s=this.i;const r=l=>this.i!==s?(s=this.i,n(l)):Promise.resolve();let i=new Im;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Im,e.enqueueRetryable((()=>r(this.currentUser)))};const a=()=>{const l=i;e.enqueueRetryable((async()=>{await l.promise,await r(this.currentUser)}))},o=l=>{xn("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((l=>o(l))),setTimeout((()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?o(l):(xn("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Im)}}),0),a()}getToken(){const e=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((s=>this.i!==e?(xn("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):s?(Ar(typeof s.accessToken=="string",31837,{l:s}),new Nge(s.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return Ar(e===null||typeof e=="string",2055,{h:e}),new Lc(e)}}class Pge{constructor(e,n,s){this.P=e,this.T=n,this.I=s,this.type="FirstParty",this.user=Lc.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class $ge{constructor(e,n,s){this.P=e,this.T=n,this.I=s}getToken(){return Promise.resolve(new Pge(this.P,this.T,this.I))}start(e,n){e.enqueueRetryable((()=>n(Lc.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class RU{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Dge{constructor(e,n){this.V=n,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Fh(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,n){Ar(this.o===void 0,3512);const s=i=>{i.error!=null&&xn("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.m;return this.m=i.token,xn("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?n(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable((()=>
1598s(i)))};const r=i=>{xn("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((i=>r(i))),setTimeout((()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?r(i):xn("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new RU(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((n=>n?(Ar(typeof n.token=="string",44558,{tokenResult:n}),this.m=n.token,new RU(n.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
1599 * @license
1600 * Copyright 2020 Google LLC
1601 *
1602 * Licensed under the Apache License, Version 2.0 (the "License");
1603 * you may not use this file except in compliance with the License.
1604 * You may obtain a copy of the License at
1605 *
1606 *   http://www.apache.org/licenses/LICENSE-2.0
1607 *
1608 * Unless required by applicable law or agreed to in writing, software
1609 * distributed under the License is distributed on an "AS IS" BASIS,
1610 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1611 * See the License for the specific language governing permissions and
1612 * limitations under the License.
1613 */function Oge(t){const e=typeof self<"u"&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(n);else for(let s=0;s<t;s++)n[s]=Math.floor(256*Math.random());return n}/**
1614 * @license
1615 * Copyright 2017 Google LLC
1616 *
1617 * Licensed under the Apache License, Version 2.0 (the "License");
1618 * you may not use this file except in compliance with the License.
1619 * You may obtain a copy of the License at
1620 *
1621 *   http://www.apache.org/licenses/LICENSE-2.0
1622 *
1623 * Unless required by applicable law or agreed to in writing, software
1624 * distributed under the License is distributed on an "AS IS" BASIS,
1625 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1626 * See the License for the specific language governing permissions and
1627 * limitations under the License.
1628 */class dL{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=62*Math.floor(4.129032258064516);let s="";for(;s.length<20;){const r=Oge(40);for(let i=0;i<r.length;++i)s.length<20&&r[i]<n&&(s+=e.charAt(r[i]%62))}return s}}function mr(t,e){return t<e?-1:t>e?1:0}function F3(t,e){const n=Math.min(t.length,e.length);for(let s=0;s<n;s++){const r=t.charAt(s),i=e.charAt(s);if(r!==i)return A4(r)===A4(i)?mr(r,i):A4(r)?1:-1}return mr(t.length,e.length)}const Lge=55296,jge=57343;function A4(t){const e=t.charCodeAt(0);return e>=Lge&&e<=jge}function P1(t,e,n){return t.length===e.length&&t.every(((s,r)=>n(s,e[r])))}/**
1629 * @license
1630 * Copyright 2017 Google LLC
1631 *
1632 * Licensed under the Apache License, Version 2.0 (the "License");
1633 * you may not use this file except in compliance with the License.
1634 * You may obtain a copy of the License at
1635 *
1636 *   http://www.apache.org/licenses/LICENSE-2.0
1637 *
1638 * Unless required by applicable law or agreed to in writing, software
1639 * distributed under the License is distributed on an "AS IS" BASIS,
1640 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1641 * See the License for the specific language governing permissions and
1642 * limitations under the License.
1643 */const MU="__name__";class Bf{constructor(e,n,s){n===void 0?n=0:n>e.length&&ss(637,{offset:n,range:e.length}),s===void 0?s=e.length-n:s>e.length-n&&ss(1746,{length:s,range:e.length-n}),this.segments=e,this.offset=n,this.len=s}get length(){return this.len}isEqual(e){return Bf.comparator(this,e)===0}child(e){const n=this.segments.slice(this.offset,this.limit());return e instanceof Bf?e.forEach((s=>{n.push(s)})):n.push(e),this.construct(n)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let n=0;n<this.length;n++)if(this.get(n)!==e.get(n))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let n=0;n<this.length;n++)if(this.get(n)!==e.get(n))return!1;return!0}forEach(e){for(let n=this.offset,s=this.limit();n<s;n++)e(this.segments[n])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,n){const s=Math.min(e.length,n.length);for(let r=0;r<s;r++){const i=Bf.compareSegments(e.get(r),n.get(r));if(i!==0)return i}return mr(e.length,n.length)}static compareSegments(e,n){const s=Bf.isNumericId(e),r=Bf.isNumericId(n);return s&&!r?-1:!s&&r?1:s&&r?Bf.extractNumericId(e).compare(Bf.extractNumericId(n)):F3(e,n)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return R0.fromString(e.substring(4,e.length-2))}}class Di extends Bf{construct(e,n,s){return new Di(e,n,s)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
1643toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const n=[];for(const s of e){if(s.indexOf("//")>=0)throw new Cn(Ot.INVALID_ARGUMENT,`Invalid segment (${s}). Paths must not contain // in them.`);n.push(...s.split("/").filter((r=>r.length>0)))}return new Di(n)}static emptyPath(){return new Di([])}}const Bge=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class zo extends Bf{construct(e,n,s){return new zo(e,n,s)}static isValidIdentifier(e){return Bge.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),zo.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===MU}static keyField(){return new zo([MU])}static fromServerFormat(e){const n=[];let s="",r=0;const i=()=>{if(s.length===0)throw new Cn(Ot.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(s),s=""};let a=!1;for(;r<e.length;){const o=e[r];if(o==="\\"){if(r+1===e.length)throw new Cn(Ot.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[r+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new Cn(Ot.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);s+=l,r+=2}else o==="`"?(a=!a,r++):o!=="."||a?(s+=o,r++):(i(),r++)}if(i(),a)throw new Cn(Ot.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new zo(n)}static emptyPath(){return new zo([])}}/**
1644 * @license
1645 * Copyright 2017 Google LLC
1646 *
1647 * Licensed under the Apache License, Version 2.0 (the "License");
1648 * you may not use this file except in compliance with the License.
1649 * You may obtain a copy of the License at
1650 *
1651 *   http://www.apache.org/licenses/LICENSE-2.0
1652 *
1653 * Unless required by applicable law or agreed to in writing, software
1654 * distributed under the License is distributed on an "AS IS" BASIS,
1655 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1656 * See the License for the specific language governing permissions and
1657 * limitations under the License.
1658 */class rs{constructor(e){this.path=e}static fromPath(e){return new rs(Di.fromString(e))}static fromName(e){return new rs(Di.fromString(e).popFirst(5))}static empty(){return new rs(Di.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Di.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,n){return Di.comparator(e.path,n.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new rs(new Di(e.slice()))}}/**
1659 * @license
1660 * Copyright 2017 Google LLC
1661 *
1662 * Licensed under the Apache License, Version 2.0 (the "License");
1663 * you may not use this file except in compliance with the License.
1664 * You may obtain a copy of the License at
1665 *
1666 *   http://www.apache.org/licenses/LICENSE-2.0
1667 *
1668 * Unless required by applicable law or agreed to in writing, software
1669 * distributed under the License is distributed on an "AS IS" BASIS,
1670 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1671 * See the License for the specific language governing permissions and
1672 * limitations under the License.
1673 */function Uge(t,e,n){if(!n)throw new Cn(Ot.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function Fge(t,e,n,s){if(e===!0&&s===!0)throw new Cn(Ot.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function PU(t){if(!rs.isDocumentKey(t))throw new Cn(Ot.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function hY(t){return typeof t=="object"&&t!==null&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null)}function hL(t){if(t===void 0)return"undefined";if(t===null)return"null";if(typeof t=="string")return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean")return""+t;if(typeof t=="object"){if(t instanceof Array)return"an array";{const e=(function(s){return s.constructor?s.constructor.name:null})(t);return e?`a custom ${e} object`:"an object"}}return typeof t=="function"?"a function":ss(12329,{type:typeof t})}function Sv(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Cn(Ot.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=hL(t);throw new Cn(Ot.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}/**
1674 * @license
1675 * Copyright 2025 Google LLC
1676 *
1677 * Licensed under the Apache License, Version 2.0 (the "License");
1678 * you may not use this file except in compliance with the License.
1679 * You may obtain a copy of the License at
1680 *
1681 *   http://www.apache.org/licenses/LICENSE-2.0
1682 *
1683 * Unless required by applicable law or agreed to in writing, software
1684 * distributed under the License is distributed on an "AS IS" BASIS,
1685 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1686 * See the License for the specific language governing permissions and
1687 * limitations under the License.
1688 */function La(t,e){const n={typeString:t};return e&&(n.value=e),n}function mA(t,e){if(!hY(t))throw new Cn(Ot.INVALID_ARGUMENT,"JSON must be an object");let n;for(const s in e)if(e[s]){const r=e[s].typeString,i="value"in e[s]?{value:e[s].value}:void 0;if(!(s in t)){n=`JSON missing required field: '${s}'`;break}const a=t[s];if(r&&typeof a!==r){n=`JSON field '${s}' must be a ${r}.`;break}if(i!==void 0&&a!==i.value){n=`Expected '${s}' field to equal '${i.value}'`;break}}if(n)throw new Cn(Ot.INVALID_ARGUMENT,n);return!0}/**
1689 * @license
1690 * Copyright 2017 Google LLC
1691 *
1692 * Licensed under the Apache License, Version 2.0 (the "License");
1693 * you may not use this file except in compliance with the License.
1694 * You may obtain a copy of the License at
1695 *
1696 *   http://www.apache.org/licenses/LICENSE-2.0
1697 *
1698 * Unless required by applicable law or agreed to in writing, software
1699 * distributed under the License is distributed on an "AS IS" BASIS,
1700 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1701 * See the License for the specific language governing permissions and
1702 * limitations under the License.
1703 */const $U=-62135596800,DU=1e6;class Oi{static now(){return Oi.fromMillis(Date.now())}static fromDate(e){return Oi.fromMillis(e.getTime())}static fromMillis(e){const n=Math.floor(e/1e3),s=Math.floor((e-1e3*n)*DU);return new Oi(n,s)}constructor(e,n){if(this.seconds=e,this.nanoseconds=n,n<0)throw new Cn(Ot.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new Cn(Ot.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(e<$U)throw new Cn(Ot.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new Cn(Ot.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/DU}_compareTo(e){return this.seconds===e.seconds?mr(this.nanoseconds,e.nanoseconds):mr(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:Oi._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(mA(e,Oi._jsonSchema))return new Oi(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-$U;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}Oi._jsonSchemaVersion="firestore/timestamp/1.0",Oi._jsonSchema={type:La("string",Oi._jsonSchemaVersion),seconds:La("number"),nanoseconds:La("number")};/**
1704 * @license
1705 * Copyright 2017 Google LLC
1706 *
1707 * Licensed under the Apache License, Version 2.0 (the "License");
1708 * you may not use this file except in compliance with the License.
1709 * You may obtain a copy of the License at
1710 *
1711 *   http://www.apache.org/licenses/LICENSE-2.0
1712 *
1713 * Unless required by applicable law or agreed to in writing, software
1714 * distributed under the License is distributed on an "AS IS" BASIS,
1715 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1716 * See the License for the specific language governing permissions and
1717 * limitations under the License.
1718 */class vs{static fromTimestamp(e){return new vs(e)}static min(){return new vs(new Oi(0,0))}static max(){return new vs(new Oi(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
1719 * @license
1720 * Copyright 2021 Google LLC
1721 *
1722 * Licensed under the Apache License, Version 2.0 (the "License");
1723 * you may not use this file except in compliance with the License.
1724 * You may obtain a copy of the License at
1725 *
1726 *   http://www.apache.org/licenses/LICENSE-2.0
1727 *
1728 * Unless required by applicable law or agreed to in writing, software
1729 * distributed under the License is distributed on an "AS IS" BASIS,
1730 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1731 * See the License for the specific language governing permissions and
1732 * limitations under the License.
1733 */const iE=-1;function Vge(t,e){const n=t.toTimestamp().seconds,s=t.toTimestamp().nanoseconds+1,r=vs.fromTimestamp(s===1e9?new Oi(n+1,0):new Oi(n,s));return new D0(r,rs.empty(),e)}function zge(t){return new D0(t.readTime,t.key,iE)}class D0{constructor(e,n,s){this.readTime=e,this.documentKey=n,this.largestBatchId=s}static min(){return new D0(vs.min(),rs.empty(),iE)}static max(){return new D0(vs.max(),rs.empty(),iE)}}function Gge(t,e){let n=t.readTime.compareTo(e.readTime);return n!==0?n:(n=rs.comparator(t.documentKey,e.documentKey),n!==0?n:mr(t.largestBatchId,e.largestBatchId))}/**
1734 * @license
1735 * Copyright 2020 Google LLC
1736 *
1737 * Licensed under the Apache License, Version 2.0 (the "License");
1738 * you may not use this file except in compliance with the License.
1739 * You may obtain a copy of the License at
1740 *
1741 *   http://www.apache.org/licenses/LICENSE-2.0
1742 *
1743 * Unless required by applicable law or agreed to in writing, software
1744 * distributed under the License is distributed on an "AS IS" BASIS,
1745 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1746 * See the License for the specific language governing permissions and
1747 * limitations under the License.
1748 */const Hge="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class qge{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}/**
1749 * @license
1750 * Copyright 2017 Google LLC
1751 *
1752 * Licensed under the Apache License, Version 2.0 (the "License");
1753 * you may not use this file except in compliance with the License.
1754 * You may obtain a copy of the License at
1755 *
1756 *   http://www.apache.org/licenses/LICENSE-2.0
1757 *
1758 * Unless required by applicable law or agreed to in writing, software
1759 * distributed under the License is distributed on an "AS IS" BASIS,
1760 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1761 * See the License for the specific language governing permissions and
1762 * limitations under the License.
1763 */async function Q1(t){if(t.code!==Ot.FAILED_PRECONDITION||t.message!==Hge)throw t;xn("LocalStore","Unexpectedly lost primary lease")}/**
1764 * @license
1765 * Copyright 2017 Google LLC
1766 *
1767 * Licensed under the Apache License, Version 2.0 (the "License");
1768 * you may not use this file except in compliance with the License.
1769 * You may obtain a copy of the License at
1770 *
1771 *   http://www.apache.org/licenses/LICENSE-2.0
1772 *
1773 * Unless required by applicable law or agreed to in writing, software
1774 * distributed under the License is distributed on an "AS IS" BASIS,
1775 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1776 * See the License for the specific language governing permissions and
1777 * limitations under the License.
1778 */class $t{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((n=>{this.isDone=!0,this.result=n,this.nextCallback&&this.nextCallback(n)}),(n=>{this.isDone=!0,this.error=n,this.catchCallback&&this.catchCallback(n)}))}catch(e){return this.next(void 0,e)}next(e,n){return this.callbackAttached&&ss(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new $t(((s,r)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(s,r)},this.catchCallback=i=>{this.wrapFailure(n,i).next(s,r)}}))}toPromise(){return new Promise(((e,n)=>{this.next(e,n)}))}wrapUserFunction(e){try{const n=e();return n instanceof $t?n:$t.resolve(n)}catch(n){return $t.reject(n)}}wrapSuccess(e,n){return e?this.wrapUserFunction((()=>e(n))):$t.resolve(n)}wrapFailure(e,n){return e?this.wrapUserFunction((()=>e(n))):$t.reject(n)}static resolve(e){return new $t(((n,s)=>{n(e)}))}static reject(e){return new $t(((n,s)=>{s(e)}))}static waitFor(e){return new $t(((n,s)=>{let r=0,i=0,a=!1;e.forEach((o=>{++r,o.next((()=>{++i,a&&i===r&&n()}),(l=>s(l)))})),a=!0,i===r&&n()}))}static or(e){let n=$t.resolve(!1);for(const s of e)n=n.next((r=>r?$t.resolve(r):s()));return n}static forEach(e,n){const s=[];return e.forEach(((r,i)=>{s.push(n.call(this,r,i))})),this.waitFor(s)}static mapArray(e,n){return new $t(((s,r)=>{const i=e.length,a=new Array(i);let o=0;for(let l=0;l<i;l++){const c=l;n(e[c]).next((h=>{a[c]=h,++o,o===i&&s(a)}),(h=>r(h)))}}))}static doWhile(e,n){return new $t(((s,r)=>{const i=()=>{e()===!0?n().next((()=>{i()}),r):s()};i()}))}}function Wge(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}function Z1(t){return t.name==="IndexedDbTransactionError"}/**
1779 * @license
1780 * Copyright 2018 Google LLC
1781 *
1782 * Licensed under the Apache License, Version 2.0 (the "License");
1783 * you may not use this file except in compliance with the License.
1784 * You may obtain a copy of the License at
1785 *
1786 *   http://www.apache.org/licenses/LICENSE-2.0
1787 *
1788 * Unless required by applicable law or agreed to in writing, software
1789 * distributed under the License is distributed on an "AS IS" BASIS,
1790 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1791 * See the License for the specific language governing permissions and
1792 * limitations under the License.
1793 */class sM{constructor(e,n){this.previousValue=e,n&&(n.sequenceNumberHandler=s=>this.ae(s),this.ue=s=>n.writeSequenceNumber(s))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}sM.ce=-1;/**
1794 * @license
1795 * Copyright 2017 Google LLC
1796 *
1797 * Licensed under the Apache License, Version 2.0 (the "License");
1798 * you may not use this file except in compliance with the License.
1799 * You may obtain a copy of the License at
1800 *
1801 *   http://www.apache.org/licenses/LICENSE-2.0
1802 *
1803 * Unless required by applicable law or agreed to in writing, software
1804 * distributed under the License is distributed on an "AS IS" BASIS,
1805 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1806 * See the License for the specific language governing permissions and
1807 * limitations under the License.
1808 */const fL=-1;function gA(t){return t==null}function kN(t){return t===0&&1/t==-1/0}function Kge(t){return typeof t=="number"&&Number.isInteger(t)&&!kN(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}/**
1809 * @license
1810 * Copyright 2017 Google LLC
1811 *
1812 * Licensed under the Apache License, Version 2.0 (the "License");
1813 * you may not use this file except in compliance with the License.
1814 * You may obtain a copy of the License at
1815 *
1816 *   http://www.apache.org/licenses/LICENSE-2.0
1817 *
1818 * Unless required by applicable law or agreed to in writing, software
1819 * distributed under the License is distributed on an "AS IS" BASIS,
1820 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1821 * See the License for the specific language governing permissions and
1822 * limitations under the License.
1823 */const fY="�";function Yge(t){let e="";for(let n=0;n<t.length;n++)e.length>0&&(e=OU(e)),e=Xge(t.get(n),e);return OU(e)}function Xge(t,e){let n=e;const s=t.length;for(let r=0;r<s;r++){const i=t.charAt(r);switch(i){case"\0":n+="��";break;case fY:n+="��";break;default:n+=i}}return n}function OU(t){return t+fY+"�"}/**
1824 * @license
1825 * Copyright 2017 Google LLC
1826 *
1827 * Licensed under the Apache License, Version 2.0 (the "License");
1828 * you may not use this file except in compliance with the License.
1829 * You may obtain a copy of the License at
1830 *
1831 *   http://www.apache.org/licenses/LICENSE-2.0
1832 *
1833 * Unless required by applicable law or agreed to in writing, software
1834 * distributed under the License is distributed on an "AS IS" BASIS,
1835 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1836 * See the License for the specific language governing permissions and
1837 * limitations under the License.
1838 */function LU(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function X0(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function pY(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}/**
1839 * @license
1840 * Copyright 2017 Google LLC
1841 *
1842 * Licensed under the Apache License, Version 2.0 (the "License");
1843 * you may not use this file except in compliance with the License.
1844 * You may obtain a copy of the License at
1845 *
1846 *   http://www.apache.org/licenses/LICENSE-2.0
1847 *
1848 * Unless required by applicable law or agreed to in writing, software
1849 * distributed under the License is distributed on an "AS IS" BASIS,
1850 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1851 * See the License for the specific language governing permissions and
1852 * limitations under the License.
1853 */class ta{constructor(e,n){this.comparator=e,this.root=n||Fo.EMPTY}insert(e,n){return new ta(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,Fo.BLACK,null,
vendor: 4,548 bytes, line 1853
1853null))}remove(e){return new ta(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Fo.BLACK,null,null))}get(e){let n=this.root;for(;!n.isEmpty();){const s=this.comparator(e,n.key);if(s===0)return n.value;s<0?n=n.left:s>0&&(n=n.right)}return null}indexOf(e){let n=0,s=this.root;for(;!s.isEmpty();){const r=this.comparator(e,s.key);if(r===0)return n+s.left.size;r<0?s=s.left:(n+=s.left.size+1,s=s.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((n,s)=>(e(n,s),!1)))}toString(){const e=[];return this.inorderTraversal(((n,s)=>(e.push(`${n}:${s}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new kk(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new kk(this.root,e,this.comparator,!1)}getReverseIterator(){return new kk(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new kk(this.root,e,this.comparator,!0)}}class kk{constructor(e,n,s,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=n?s(e.key,n):1,n&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const n={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return n}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class Fo{constructor(e,n,s,r,i){this.key=e,this.value=n,this.color=s??Fo.RED,this.left=r??Fo.EMPTY,this.right=i??Fo.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,n,s,r,i){return new Fo(e??this.key,n??this.value,s??this.color,r??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,n,s){let r=this;const i=s(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,n,s),null):i===0?r.copy(null,n,null,null,null):r.copy(null,null,null,null,r.right.insert(e,n,s)),r.fixUp()}removeMin(){if(this.left.isEmpty())return Fo.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,n){let s,r=this;if(n(e,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,n),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),n(e,r.key)===0){if(r.right.isEmpty())return Fo.EMPTY;s=r.right.min(),r=r.copy(s.key,s.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,n))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,Fo.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,Fo.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),n=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,n)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw ss(43730,{key:this.key,value:this.value});if(this.right.isRed())throw ss(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw ss(27949);return e+(this.isRed()?0:1)}}Fo.EMPTY=null,Fo.RED=!0,Fo.BLACK=!1;
vendor: 4,232 bytes, lines 1853-1897
1853Fo.EMPTY=new class{constructor(){this.size=0}get key(){throw ss(57766)}get value(){throw ss(16141)}get color(){throw ss(16727)}get left(){throw ss(29726)}get right(){throw ss(36894)}copy(e,n,s,r,i){return this}insert(e,n,s){return new Fo(e,n)}remove(e,n){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
1854 * @license
1855 * Copyright 2017 Google LLC
1856 *
1857 * Licensed under the Apache License, Version 2.0 (the "License");
1858 * you may not use this file except in compliance with the License.
1859 * You may obtain a copy of the License at
1860 *
1861 *   http://www.apache.org/licenses/LICENSE-2.0
1862 *
1863 * Unless required by applicable law or agreed to in writing, software
1864 * distributed under the License is distributed on an "AS IS" BASIS,
1865 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1866 * See the License for the specific language governing permissions and
1867 * limitations under the License.
1868 */class oo{constructor(e){this.comparator=e,this.data=new ta(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((n,s)=>(e(n),!1)))}forEachInRange(e,n){const s=this.data.getIteratorFrom(e[0]);for(;s.hasNext();){const r=s.getNext();if(this.comparator(r.key,e[1])>=0)return;n(r.key)}}forEachWhile(e,n){let s;for(s=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();s.hasNext();)if(!e(s.getNext().key))return}firstAfterOrEqual(e){const n=this.data.getIteratorFrom(e);return n.hasNext()?n.getNext().key:null}getIterator(){return new jU(this.data.getIterator())}getIteratorFrom(e){return new jU(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let n=this;return n.size<e.size&&(n=e,e=this),e.forEach((s=>{n=n.add(s)})),n}isEqual(e){if(!(e instanceof oo)||this.size!==e.size)return!1;const n=this.data.getIterator(),s=e.data.getIterator();for(;n.hasNext();){const r=n.getNext().key,i=s.getNext().key;if(this.comparator(r,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach((n=>{e.push(n)})),e}toString(){const e=[];return this.forEach((n=>e.push(n))),"SortedSet("+e.toString()+")"}copy(e){const n=new oo(this.comparator);return n.data=e,n}}class jU{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
1869 * @license
1870 * Copyright 2020 Google LLC
1871 *
1872 * Licensed under the Apache License, Version 2.0 (the "License");
1873 * you may not use this file except in compliance with the License.
1874 * You may obtain a copy of the License at
1875 *
1876 *   http://www.apache.org/licenses/LICENSE-2.0
1877 *
1878 * Unless required by applicable law or agreed to in writing, software
1879 * distributed under the License is distributed on an "AS IS" BASIS,
1880 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1881 * See the License for the specific language governing permissions and
1882 * limitations under the License.
1883 */class ku{constructor(e){this.fields=e,e.sort(zo.comparator)}static empty(){return new ku([])}unionWith(e){let n=new oo(zo.comparator);for(const s of this.fields)n=n.add(s);for(const s of e)n=n.add(s);return new ku(n.toArray())}covers(e){for(const n of this.fields)if(n.isPrefixOf(e))return!0;return!1}isEqual(e){return P1(this.fields,e.fields,((n,s)=>n.isEqual(s)))}}/**
1884 * @license
1885 * Copyright 2023 Google LLC
1886 *
1887 * Licensed under the Apache License, Version 2.0 (the "License");
1888 * you may not use this file except in compliance with the License.
1889 * You may obtain a copy of the License at
1890 *
1891 *   http://www.apache.org/licenses/LICENSE-2.0
1892 *
1893 * Unless required by applicable law or agreed to in writing, software
1894 * distributed under the License is distributed on an "AS IS" BASIS,
1895 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1896 * See the License for the specific language governing permissions and
1897 * limitations under the License.
1898 */class mY extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
1899 * @license
1900 * Copyright 2020 Google LLC
1901 *
1902 * Licensed under the Apache License, Version 2.0 (the "License");
1903 * you may not use this file except in compliance with the License.
1904 * You may obtain a copy of the License at
1905 *
1906 *   http://www.apache.org/licenses/LICENSE-2.0
1907 *
1908 * Unless required by applicable law or agreed to in writing, software
1909 * distributed under the License is distributed on an "AS IS" BASIS,
1910 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1911 * See the License for the specific language governing permissions and
1912 * limitations under the License.
1913 */class Wo{constructor(e){this.binaryString=e}static fromBase64String(e){const n=(function(r){try{return atob(r)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new mY("Invalid base64 string: "+i):i}})(e);return new Wo(n)}static fromUint8Array(e){const n=(function(r){let i="";for(let a=0;a<r.length;++a)i+=String.fromCharCode(r[a]);return i})(e);return new Wo(n)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return(function(n){return btoa(n)})(this.binaryString)}toUint8Array(){return(function(n){const s=new Uint8Array(n.length);for(let r=0;r<n.length;r++)s[r]=n.charCodeAt(r);return s})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return mr(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Wo.EMPTY_BYTE_STRING=new Wo("");const Jge=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function O0(t){if(Ar(!!t,39018),typeof t=="string"){let e=0;const n=Jge.exec(t);if(Ar(!!n,46558,{timestamp:t}),n[1]){let r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}const s=new Date(t);return{seconds:Math.floor(s.getTime()/1e3),nanos:e}}return{seconds:ba(t.seconds),nanos:ba(t.nanos)}}function ba(t){return typeof t=="number"?t:typeof t=="string"?Number(t):0}function L0(t){return typeof t=="string"?Wo.fromBase64String(t):Wo.fromUint8Array(t)}/**
1914 * @license
1915 * Copyright 2020 Google LLC
1916 *
1917 * Licensed under the Apache License, Version 2.0 (the "License");
1918 * you may not use this file except in compliance with the License.
1919 * You may obtain a copy of the License at
1920 *
1921 *   http://www.apache.org/licenses/LICENSE-2.0
1922 *
1923 * Unless required by applicable law or agreed to in writing, software
1924 * distributed under the License is distributed on an "AS IS" BASIS,
1925 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1926 * See the License for the specific language governing permissions and
1927 * limitations under the License.
1928 */const gY="server_timestamp",yY="__type__",xY="__previous_value__",vY="__local_write_time__";function pL(t){var n,s;return((s=(((n=t==null?void 0:t.mapValue)==null?void 0:n.fields)||{})[yY])==null?void 0:s.stringValue)===gY}function rM(t){const e=t.mapValue.fields[xY];return pL(e)?rM(e):e}function aE(t){const e=O0(t.mapValue.fields[vY].timestampValue);return new Oi(e.seconds,e.nanos)}/**
1929 * @license
1930 * Copyright 2017 Google LLC
1931 *
1932 * Licensed under the Apache License, Version 2.0 (the "License");
1933 * you may not use this file except in compliance with the License.
1934 * You may obtain a copy of the License at
1935 *
1936 *   http://www.apache.org/licenses/LICENSE-2.0
1937 *
1938 * Unless required by applicable law or agreed to in writing, software
1939 * distributed under the License is distributed on an "AS IS" BASIS,
1940 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1941 * See the License for the specific language governing permissions and
1942 * limitations under the License.
1943 */class Qge{constructor(e,n,s,r,i,a,o,l,c,h,p){this.databaseId=e,this.appId=n,this.persistenceKey=s,this.host=r,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=o,this.longPollingOptions=l,this.useFetchStreams=c,this.isUsingEmulator=h,this.apiKey=p}}const IN="(default)";class oE{constructor(e,n){this.projectId=e,this.database=n||IN}static empty(){return new oE("","")}get isDefaultDatabase(){return this.database===IN}isEqual(e){return e instanceof oE&&e.projectId===this.projectId&&e.database===this.database}}function Zge(t,e){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Cn(Ot.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');
vendor: 5,867 bytes, lines 1943-1958
1943return new oE(t.options.projectId,e)}/**
1944 * @license
1945 * Copyright 2020 Google LLC
1946 *
1947 * Licensed under the Apache License, Version 2.0 (the "License");
1948 * you may not use this file except in compliance with the License.
1949 * You may obtain a copy of the License at
1950 *
1951 *   http://www.apache.org/licenses/LICENSE-2.0
1952 *
1953 * Unless required by applicable law or agreed to in writing, software
1954 * distributed under the License is distributed on an "AS IS" BASIS,
1955 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1956 * See the License for the specific language governing permissions and
1957 * limitations under the License.
1958 */const bY="__type__",e0e="__max__",Ik={mapValue:{}},wY="__vector__",NN="value";function j0(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?pL(t)?4:n0e(t)?9007199254740991:t0e(t)?10:11:ss(28295,{value:t})}function fp(t,e){if(t===e)return!0;const n=j0(t);if(n!==j0(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return aE(t).isEqual(aE(e));case 3:return(function(r,i){if(typeof r.timestampValue=="string"&&typeof i.timestampValue=="string"&&r.timestampValue.length===i.timestampValue.length)return r.timestampValue===i.timestampValue;const a=O0(r.timestampValue),o=O0(i.timestampValue);return a.seconds===o.seconds&&a.nanos===o.nanos})(t,e);case 5:return t.stringValue===e.stringValue;case 6:return(function(r,i){return L0(r.bytesValue).isEqual(L0(i.bytesValue))})(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return(function(r,i){return ba(r.geoPointValue.latitude)===ba(i.geoPointValue.latitude)&&ba(r.geoPointValue.longitude)===ba(i.geoPointValue.longitude)})(t,e);case 2:return(function(r,i){if("integerValue"in r&&"integerValue"in i)return ba(r.integerValue)===ba(i.integerValue);if("doubleValue"in r&&"doubleValue"in i){const a=ba(r.doubleValue),o=ba(i.doubleValue);return a===o?kN(a)===kN(o):isNaN(a)&&isNaN(o)}return!1})(t,e);case 9:return P1(t.arrayValue.values||[],e.arrayValue.values||[],fp);case 10:case 11:return(function(r,i){const a=r.mapValue.fields||{},o=i.mapValue.fields||{};if(LU(a)!==LU(o))return!1;for(const l in a)if(a.hasOwnProperty(l)&&(o[l]===void 0||!fp(a[l],o[l])))return!1;return!0})(t,e);default:return ss(52216,{left:t})}}function lE(t,e){return(t.values||[]).find((n=>fp(n,e)))!==void 0}function $1(t,e){if(t===e)return 0;const n=j0(t),s=j0(e);if(n!==s)return mr(n,s);switch(n){case 0:case 9007199254740991:return 0;case 1:return mr(t.booleanValue,e.booleanValue);case 2:return(function(i,a){const o=ba(i.integerValue||i.doubleValue),l=ba(a.integerValue||a.doubleValue);return o<l?-1:o>l?1:o===l?0:isNaN(o)?isNaN(l)?0:-1:1})(t,e);case 3:return BU(t.timestampValue,e.timestampValue);case 4:return BU(aE(t),aE(e));case 5:return F3(t.stringValue,e.stringValue);case 6:return(function(i,a){const o=L0(i),l=L0(a);return o.compareTo(l)})(t.bytesValue,e.bytesValue);case 7:return(function(i,a){const o=i.split("/"),l=a.split("/");for(let c=0;c<o.length&&c<l.length;c++){const h=mr(o[c],l[c]);if(h!==0)return h}return mr(o.length,l.length)})(t.referenceValue,e.referenceValue);case 8:return(function(i,a){const o=mr(ba(i.latitude),ba(a.latitude));return o!==0?o:mr(ba(i.longitude),ba(a.longitude))})(t.geoPointValue,e.geoPointValue);case 9:return UU(t.arrayValue,e.arrayValue);case 10:return(function(i,a){var m,y,v,b;const o=i.fields||{},l=a.fields||{},c=(m=o[NN])==null?void 0:m.arrayValue,h=(y=l[NN])==null?void 0:y.arrayValue,p=mr(((v=c==null?void 0:c.values)==null?void 0:v.length)||0,((b=h==null?void 0:h.values)==null?void 0:b.length)||0);return p!==0?p:UU(c,h)})(t.mapValue,e.mapValue);case 11:return(function(i,a){if(i===Ik.mapValue&&a===Ik.mapValue)return 0;if(i===Ik.mapValue)return 1;if(a===Ik.mapValue)return-1;const o=i.fields||{},l=Object.keys(o),c=a.fields||{},h=Object.keys(c);l.sort(),h.sort();for(let p=0;p<l.length&&p<h.length;++p){const m=F3(l[p],h[p]);if(m!==0)return m;const y=$1(o[l[p]],c[h[p]]);if(y!==0)return y}return mr(l.length,h.length)})(t.mapValue,e.mapValue);default:throw ss(23264,{he:n})}}function BU(t,e){if(typeof t=="string"&&typeof e=="string"&&t.length===e.length)return mr(t,e);const n=O0(t),s=O0(e),r=mr(n.seconds,s.seconds);return r!==0?r:mr(n.nanos,s.nanos)}function UU(t,e){const n=t.values||[],s=e.values||[];for(let r=0;r<n.length&&r<s.length;++r){const i=$1(n[r],s[r]);if(i)return i}return mr(n.length,s.length)}function D1(t){return V3(t)}function V3(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?(function(n){const s=O0(n);return`time(${s.seconds},${s.nanos})`})(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?(function(n){return L0(n).toBase64()})(t.bytesValue):"referenceValue"in t?(function(n){return rs.fromName(n).toString()})(t.referenceValue):"geoPointValue"in t?(function(n){return`geo(${n.latitude},${n.longitude})`})(t.geoPointValue):"arrayValue"in t?(function(n){let s="[",r=!0;for(const i of n.values||[])r?r=!1:s+=",",s+=V3(i);return s+"]"})(t.arrayValue):"mapValue"in t?(function(n){const s=Object.keys(n.fields||{}).sort();let r="{",i=!0;for(const a of s)i?i=!1:r+=",",r+=`${a}:${V3(n.fields[a])}`;return r+"}"})(t.mapValue):ss(61005,{value:t})}function gI(t){switch(j0(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=rM(t);return e?16+gI(e):16;case 5:return 2*t.stringValue.length;case 6:return L0(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(function(s){return(s.values||[]).reduce(((r,i)=>r+gI(i)),0)})(t.arrayValue);case 10:case 11:return(function(s){let r=0;
vendor: 2,881 bytes, lines 1958-1973
1958return X0(s.fields,((i,a)=>{r+=i.length+gI(a)})),r})(t.mapValue);default:throw ss(13486,{value:t})}}function z3(t){return!!t&&"integerValue"in t}function mL(t){return!!t&&"arrayValue"in t}function FU(t){return!!t&&"nullValue"in t}function VU(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function yI(t){return!!t&&"mapValue"in t}function t0e(t){var n,s;return((s=(((n=t==null?void 0:t.mapValue)==null?void 0:n.fields)||{})[bY])==null?void 0:s.stringValue)===wY}function $S(t){if(t.geoPointValue)return{geoPointValue:{...t.geoPointValue}};if(t.timestampValue&&typeof t.timestampValue=="object")return{timestampValue:{...t.timestampValue}};if(t.mapValue){const e={mapValue:{fields:{}}};return X0(t.mapValue.fields,((n,s)=>e.mapValue.fields[n]=$S(s))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=$S(t.arrayValue.values[n]);return e}return{...t}}function n0e(t){return(((t.mapValue||{}).fields||{}).__type__||{}).stringValue===e0e}/**
1959 * @license
1960 * Copyright 2017 Google LLC
1961 *
1962 * Licensed under the Apache License, Version 2.0 (the "License");
1963 * you may not use this file except in compliance with the License.
1964 * You may obtain a copy of the License at
1965 *
1966 *   http://www.apache.org/licenses/LICENSE-2.0
1967 *
1968 * Unless required by applicable law or agreed to in writing, software
1969 * distributed under the License is distributed on an "AS IS" BASIS,
1970 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1971 * See the License for the specific language governing permissions and
1972 * limitations under the License.
1973 */class Jl{constructor(e){this.value=e}static empty(){return new Jl({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let n=this.value;for(let s=0;s<e.length-1;++s)if(n=(n.mapValue.fields||{})[e.get(s)],!yI(n))return null;return n=(n.mapValue.fields||{})[e.lastSegment()],n||null}}set(e,n){this.getFieldsMap(e.popLast())[e.lastSegment()]=$S(n)}setAll(e){let n=zo.emptyPath(),s={},r=[];e.forEach(((a,o)=>{if(!n.isImmediateParentOf(o)){const l=this.getFieldsMap(n);this.applyChanges(l,s,r),s={},r=[],n=o.popLast()}a?s[o.lastSegment()]=$S(a):r.push(o.lastSegment())}));const i=this.getFieldsMap(n);this.applyChanges(i,s,r)}delete(e){const n=this.field(e.popLast());yI(n)&&n.mapValue.fields&&delete n.mapValue.fields[e.lastSegment()]}isEqual(e){return fp(this.value,e.value)}getFieldsMap(e){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let s=0;s<e.length;++s){let r=n.mapValue.fields[e.get(s)];yI(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},n.mapValue.fields[e.get(s)]=r),n=r}return n.mapValue.fields}applyChanges(e,n,s){X0(n,((r,i)=>e[r]=i));for(const r of s)delete e[r]}clone(){return new Jl($S(this.value))}}function _Y(t){const e=[];return X0(t.fields,((n,s)=>{const r=new zo([n]);if(yI(s)){const i=_Y(s.mapValue).fields;
vendor: 4,181 bytes, lines 1973-2013
1973if(i.length===0)e.push(r);else for(const a of i)e.push(r.child(a))}else e.push(r)})),new ku(e)}/**
1974 * @license
1975 * Copyright 2017 Google LLC
1976 *
1977 * Licensed under the Apache License, Version 2.0 (the "License");
1978 * you may not use this file except in compliance with the License.
1979 * You may obtain a copy of the License at
1980 *
1981 *   http://www.apache.org/licenses/LICENSE-2.0
1982 *
1983 * Unless required by applicable law or agreed to in writing, software
1984 * distributed under the License is distributed on an "AS IS" BASIS,
1985 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1986 * See the License for the specific language governing permissions and
1987 * limitations under the License.
1988 */class ko{constructor(e,n,s,r,i,a,o){this.key=e,this.documentType=n,this.version=s,this.readTime=r,this.createTime=i,this.data=a,this.documentState=o}static newInvalidDocument(e){return new ko(e,0,vs.min(),vs.min(),vs.min(),Jl.empty(),0)}static newFoundDocument(e,n,s,r){return new ko(e,1,n,vs.min(),s,r,0)}static newNoDocument(e,n){return new ko(e,2,n,vs.min(),vs.min(),Jl.empty(),0)}static newUnknownDocument(e,n){return new ko(e,3,n,vs.min(),vs.min(),Jl.empty(),2)}convertToFoundDocument(e,n){return!this.createTime.isEqual(vs.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=n,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Jl.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Jl.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=vs.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof ko&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new ko(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/**
1989 * @license
1990 * Copyright 2022 Google LLC
1991 *
1992 * Licensed under the Apache License, Version 2.0 (the "License");
1993 * you may not use this file except in compliance with the License.
1994 * You may obtain a copy of the License at
1995 *
1996 *   http://www.apache.org/licenses/LICENSE-2.0
1997 *
1998 * Unless required by applicable law or agreed to in writing, software
1999 * distributed under the License is distributed on an "AS IS" BASIS,
2000 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2001 * See the License for the specific language governing permissions and
2002 * limitations under the License.
2003 */class RN{constructor(e,n){this.position=e,this.inclusive=n}}function zU(t,e,n){let s=0;for(let r=0;r<t.position.length;r++){const i=e[r],a=t.position[r];if(i.field.isKeyField()?s=rs.comparator(rs.fromName(a.referenceValue),n.key):s=$1(a,n.data.field(i.field)),i.dir==="desc"&&(s*=-1),s!==0)break}return s}function GU(t,e){if(t===null)return e===null;if(e===null||t.inclusive!==e.inclusive||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!fp(t.position[n],e.position[n]))return!1;return!0}/**
2004 * @license
2005 * Copyright 2022 Google LLC
2006 *
2007 * Licensed under the Apache License, Version 2.0 (the "License");
2008 * you may not use this file except in compliance with the License.
2009 * You may obtain a copy of the License at
2010 *
2011 *   http://www.apache.org/licenses/LICENSE-2.0
2012 *
2013 * Unless required by applicable law or agreed to in writing, softw
2013are
2014 * distributed under the License is distributed on an "AS IS" BASIS,
2015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2016 * See the License for the specific language governing permissions and
2017 * limitations under the License.
2018 */class MN{constructor(e,n="asc"){this.field=e,this.dir=n}}function s0e(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}/**
2019 * @license
2020 * Copyright 2022 Google LLC
2021 *
2022 * Licensed under the Apache License, Version 2.0 (the "License");
2023 * you may not use this file except in compliance with the License.
2024 * You may obtain a copy of the License at
2025 *
2026 *   http://www.apache.org/licenses/LICENSE-2.0
2027 *
2028 * Unless required by applicable law or agreed to in writing, software
2029 * distributed under the License is distributed on an "AS IS" BASIS,
2030 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2031 * See the License for the specific language governing permissions and
2032 * limitations under the License.
2033 */class SY{}class io extends SY{constructor(e,n,s){super(),this.field=e,this.op=n,this.value=s}static create(e,n,s){return e.isKeyField()?n==="in"||n==="not-in"?this.createKeyFieldInFilter(e,n,s):new i0e(e,n,s):n==="array-contains"?new l0e(e,s):n==="in"?new c0e(e,s):n==="not-in"?new u0e(e,s):n==="array-contains-any"?new d0e(e,s):new io(e,n,s)}static createKeyFieldInFilter(e,n,s){return n==="in"?new a0e(e,s):new o0e(e,s)}matches(e){const n=e.data.field(this.field);return this.op==="!="?n!==null&&n.nullValue===void 0&&this.matchesComparison($1(n,this.value)):n!==null&&j0(this.value)===j0(n)&&this.matchesComparison($1(n,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return ss(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class pp extends SY{constructor(e,n){super(),this.filters=e,this.op=n,this.Pe=null}static create(e,n){return new pp(e,n)}matches(e){return EY(this)?this.filters.find((n=>!n.matches(e)))===void 0:this.filters.find((n=>n.matches(e)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((e,n)=>e.concat(n.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function EY(t){return t.op==="and"}function TY(t){return r0e(t)&&EY(t)}function r0e(t){for(const e of t.filters)if(e instanceof pp)return!1;return!0}function G3(t){if(t instanceof io)return t.field.canonicalString()+t.op.toString()+D1(t.value);if(TY(t))return t.filters.map((e=>G3(e))).join(",");{const e=t.filters.map((n=>G3(n))).join(",");return`${t.op}(${e})`}}function AY(t,e){return t instanceof io?(function(s,r){return r instanceof io&&s.op===r.op&&s.field.isEqual(r.field)&&fp(s.value,r.value)})(t,e):t instanceof pp?(function(s,r){return r instanceof pp&&s.op===r.op&&s.filters.length===r.filters.length?s.filters.reduce(((i,a,o)=>i&&AY(a,r.filters[o])),!0):!1})(t,e):void ss(19439)}function CY(t){return t instanceof io?(function(n){return`${n.field.canonicalString()} ${n.op} ${D1(n.value)}`})(t):t instanceof pp?(function(n){return n.op.toString()+" {"+n.getFilters().map(CY).join(" ,")+"}"})(t):"Filter"}class i0e extends io{constructor(e,n,s){super(e,n,s),this.key=rs.fromName(s.referenceValue)}matches(e){const n=rs.comparator(e.key,this.key);return this.matchesComparison(n)}}class a0e extends io{constructor(e,n){super(e,"in",n),this.keys=kY("in",n)}matches(e){return this.keys.some((n=>n.isEqual(e.key)))}}class o0e extends io{constructor(e,n){super(e,"not-in",n),this.keys=kY("not-in",n)}matches(e){return!this.keys.some((n=>n.isEqual(e.key)))}}function kY(t,e){var n;return(((n=e.arrayValue)==null?void 0:n.values)||[]).map((s=>rs.fromName(s.referenceValue)))}class l0e extends io{constructor(e,n){super(e,"array-contains",n)}matches(e){const n=e.data.field(this.field);return mL(n)&&lE(n.arrayValue,this.value)}}class c0e extends io{constructor(e,n){super(e,"in",n)}matches(e){const n=e.data.field(this.field);return n!==null&&lE(this.value.arrayValue,n)}}class u0e extends io{constructor(e,n){super(e,"not-in",n)}matches(e){if(lE(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const n=e.data.field(this.field);return n!==null&&n.nullValue===void 0&&!lE(this.value.arrayValue,n)}}class d0e extends io{constructor(e,n){super(e,"array-contains-any",n)}matches(e){const n=e.data.field(this.field);return!(!mL(n)||!n.arrayValue.values)&&n.arrayValue.values.some((s=>lE(this.value.arrayValue,s)))}}/**
2034 * @license
2035 * Copyright 2019 Google LLC
2036 *
2037 * Licensed under the Apache License, Version 2.0 (the "License");
2038 * you may not use this file except in compliance with the License.
2039 * You may obtain a copy of the License at
2040 *
2041 *   http://www.apache.org/licenses/LICENSE-2.0
2042 *
2043 * Unless required by applicable law or agreed to in writing, software
2044 * distributed under the License is distributed on an "AS IS" BASIS,
2045 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2046 * See the License for the specific language governing permissions and
2047 * limitations under the License.
2048 */class h0e{constructor(e,n=null,s=[],r=[],i=null,a=null,o=null){this.path=e,this.collectionGroup=n,this.orderBy=s,this.filters=r,this.limit=i,this.startAt=a,this.endAt=o,this.Te=null}}function HU(t,e=null,n=[],s=[],r=null,i=null,a=null){return new h0e(t,e,n,s,r,i,a)}function gL(t){const e=Ns(t);if(e.Te===null){let n=e.path.canonicalString();e.collectionGroup!==null&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map((s=>G3(s))).join(","),n+="|ob:",n+=e.orderBy.map((s=>(function(i){return i.field.canonicalString()+i.dir})(s))).join(","),gA(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map((s=>D1(s))).join(",")),e.endAt&&(n+="|ub:",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map((s=>D1(s))).join(",")),e.Te=n}return e.Te}function yL(t,e){if(t.limit!==e.limit||t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!s0e(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let n=0;n<t.filters.length;n++)if(!AY(t.filters[n],e.filters[n]))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!GU(t.startAt,e.startAt)&&GU(t.endAt,e.endAt)}function H3(t){return rs.isDocumentKey(t.path)&&t.collectionGroup===null&&t.filters.length===0}/**
2049 * @license
2050 * Copyright 2017 Google LLC
2051 *
2052 * Licensed under the Apache License, Version 2.0 (the "License");
2053 * you may not use this file except in compliance with the License.
2054 * You may obtain a copy of the License at
2055 *
2056 *   http://www.apache.org/licenses/LICENSE-2.0
2057 *
2058 * Unless required by applicable law or agreed to in writing, software
2059 * distributed under the License is distributed on an "AS IS" BASIS,
2060 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2061 * See the License for the specific language governing permissions and
2062 * limitations under the License.
2063 */class iM{constructor(e,n=null,s=[],r=[],i=null,a="F",o=null,l=null){this.path=e,this.collectionGroup=n,this.explicitOrderBy=s,this.filters=r,this.limit=i,this.limitType=a,this.startAt=o,this.endAt=l,this.Ee=null,this.Ie=null,this.Re=null,this.startAt,this.endAt}}function f0e(t,e,n,s,r,i,a,o){return new iM(t,e,n,s,r,i,a,o)}function xL(t){return new iM(t)}function qU(t){return t.filters.length===0&&t.limit===null&&t.startAt==null&&t.endAt==null&&(t.explicitOrderBy.length===0||t.explicitOrderBy.length===1&&t.explicitOrderBy[0].field.isKeyField())}function p0e(t){return rs.isDocumentKey(t.path)&&t.collectionGroup===null&&t.filters.length===0}function m0e(t){return t.collectionGroup!==null}function DS(t){const e=Ns(t);if(e.Ee===null){e.Ee=[];const n=new Set;for(const i of e.explicitOrderBy)e.Ee.push(i),n.add(i.field.canonicalString());const s=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let o=new oo(zo.comparator);return a.filters.forEach((l=>{l.getFlattenedFilters().forEach((c=>{c.isInequality()&&(o=o.add(c.field))}))})),o})(e).forEach((i=>{n.has(i.canonicalString())||i.isKeyField()||e.Ee.push(new MN(i,s))})),n.has(zo.keyField().canonicalString())||e.Ee.push(new MN(zo.keyField(),s))}return e.Ee}function lp(t){const e=Ns(t);return e.Ie||(e.Ie=g0e(e,DS(t))),e.Ie}function g0e(t,e){if(t.limitType==="F")return HU(t.path,t.collectionGroup,e,t.filters,t.limit,t.startAt,t.endAt);{e=e.map((r=>{const i=r.dir==="desc"?"asc":"desc";return new MN(r.field,i)}));const n=t.endAt?new RN(t.endAt.position,t.endAt.inclusive):null,s=t.startAt?new RN(t.startAt.position,t.startAt.inclusive):null;return HU(t.path,t.collectionGroup,e,t.filters,t.limit,n,s)}}function q3(t,e,n){return new iM(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function aM(t,e){return yL(lp(t),lp(e))&&t.limitType===e.limitType}function IY(t){return`${gL(lp(t))}|lt:${t.limitType}`}function zb(t){return`Query(target=${(function(n){let s=n.path.canonicalString();return n.collectionGroup!==null&&(s+=" collectionGroup="+n.collectionGroup),n.filters.length>0&&(s+=`, filters: [${n.filters.map((r=>CY(r))).join(", ")}]`),gA(n.limit)||(s+=", limit: "+n.limit),n.orderBy.length>0&&(s+=`, orderBy: [${n.orderBy.map((r=>(function(a){return`${a.field.canonicalString()} (${a.dir})`})(r))).join(", ")}]`),n.startAt&&(s+=", startAt: ",s+=n.startAt.inclusive?"b:":"a:",s+=n.startAt.position.map((r=>D1(r))).join(",")),n.endAt&&(s+=", endAt: ",s+=n.endAt.inclusive?"a:":"b:",s+=n.endAt.position.map((r=>D1(r))).join(",")),`Target(${s})`})(lp(t))}; limitType=${t.limitType})`}
2063function oM(t,e){return e.isFoundDocument()&&(function(s,r){const i=r.key.path;return s.collectionGroup!==null?r.key.hasCollectionId(s.collectionGroup)&&s.path.isPrefixOf(i):rs.isDocumentKey(s.path)?s.path.isEqual(i):s.path.isImmediateParentOf(i)})(t,e)&&(function(s,r){for(const i of DS(s))if(!i.field.isKeyField()&&r.data.field(i.field)===null)return!1;return!0})(t,e)&&(function(s,r){for(const i of s.filters)if(!i.matches(r))return!1;return!0})(t,e)&&(function(s,r){return!(s.startAt&&!(function(a,o,l){const c=zU(a,o,l);return a.inclusive?c<=0:c<0})(s.startAt,DS(s),r)||s.endAt&&!(function(a,o,l){const c=zU(a,o,l);return a.inclusive?c>=0:c>0})(s.endAt,DS(s),r))})(t,e)}function y0e(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}function NY(t){return(e,n)=>{let s=!1;for(const r of DS(t)){const i=x0e(r,e,n);if(i!==0)return i;s=s||r.field.isKeyField()}return 0}}function x0e(t,e,n){const s=t.field.isKeyField()?rs.comparator(e.key,n.key):(function(i,a,o){const l=a.data.field(i),c=o.data.field(i);return l!==null&&c!==null?$1(l,c):ss(42886)})(t.field,e,n);switch(t.dir){case"asc":return s;case"desc":return-1*s;default:return ss(19790,{direction:t.dir})}}/**
2064 * @license
2065 * Copyright 2017 Google LLC
2066 *
2067 * Licensed under the Apache License, Version 2.0 (the "License");
2068 * you may not use this file except in compliance with the License.
2069 * You may obtain a copy of the License at
2070 *
2071 *   http://www.apache.org/licenses/LICENSE-2.0
2072 *
2073 * Unless required by applicable law or agreed to in writing, software
2074 * distributed under the License is distributed on an "AS IS" BASIS,
2075 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2076 * See the License for the specific language governing permissions and
2077 * limitations under the License.
2078 */class Uv{constructor(e,n){this.mapKeyFn=e,this.equalsFn=n,this.inner={},this.innerSize=0}get(e){const n=this.mapKeyFn(e),s=this.inner[n];if(s!==void 0){for(const[r,i]of s)if(this.equalsFn(r,e))return i}}has(e){return this.get(e)!==void 0}set(e,n){const s=this.mapKeyFn(e),r=this.inner[s];if(r===void 0)return this.inner[s]=[[e,n]],void this.innerSize++;for(let i=0;i<r.length;i++)if(this.equalsFn(r[i][0],e))return void(r[i]=[e,n]);r.push([e,n]),this.innerSize++}delete(e){const n=this.mapKeyFn(e),s=this.inner[n];if(s===void 0)return!1;for(let r=0;r<s.length;r++)if(this.equalsFn(s[r][0],e))return s.length===1?delete this.inner[n]:s.splice(r,1),this.innerSize--,!0;return!1}forEach(e){X0(this.inner,((n,s)=>{for(const[r,i]of s)e(r,i)}))}isEmpty(){return pY(this.inner)}size(){return this.innerSize}}/**
2079 * @license
2080 * Copyright 2017 Google LLC
2081 *
2082 * Licensed under the Apache License, Version 2.0 (the "License");
2083 * you may not use this file except in compliance with the License.
2084 * You may obtain a copy of the License at
2085 *
2086 *   http://www.apache.org/licenses/LICENSE-2.0
2087 *
2088 * Unless required by applicable law or agreed to in writing, software
2089 * distributed under the License is distributed on an "AS IS" BASIS,
2090 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2091 * See the License for the specific language governing permissions and
2092 * limitations under the License.
2093 */const v0e=new ta(rs.comparator);function Dm(){return v0e}const RY=new ta(rs.comparator);function iS(...t){let e=RY;for(const n of t)e=e.insert(n.key,n);return e}function MY(t){let e=RY;return t.forEach(((n,s)=>e=e.insert(n,s.overlayedDocument))),e}function tx(){return OS()}function PY(){return OS()}function OS(){return new Uv((t=>t.toString()),((t,e)=>t.isEqual(e)))}const b0e=new ta(rs.comparator),w0e=new oo(rs.comparator);function gr(...t){let e=w0e;for(const n of t)e=e.add(n);return e}const _0e=new oo(mr);function S0e(){return _0e}/**
2094 * @license
2095 * Copyright 2020 Google LLC
2096 *
2097 * Licensed under the Apache License, Version 2.0 (the "License");
2098 * you may not use this file except in compliance with the License.
2099 * You may obtain a copy of the License at
2100 *
2101 *   http://www.apache.org/licenses/LICENSE-2.0
2102 *
2103 * Unless required by applicable law or agreed to in writing, softw
2103are
2104 * distributed under the License is distributed on an "AS IS" BASIS,
2105 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2106 * See the License for the specific language governing permissions and
2107 * limitations under the License.
2108 */function vL(t,e){if(t.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:kN(e)?"-0":e}}function $Y(t){return{integerValue:""+t}}function E0e(t,e){return Kge(e)?$Y(e):vL(t,e)}/**
2109 * @license
2110 * Copyright 2018 Google LLC
2111 *
2112 * Licensed under the Apache License, Version 2.0 (the "License");
2113 * you may not use this file except in compliance with the License.
2114 * You may obtain a copy of the License at
2115 *
2116 *   http://www.apache.org/licenses/LICENSE-2.0
2117 *
2118 * Unless required by applicable law or agreed to in writing, software
2119 * distributed under the License is distributed on an "AS IS" BASIS,
2120 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2121 * See the License for the specific language governing permissions and
2122 * limitations under the License.
2123 */class lM{constructor(){this._=void 0}}function T0e(t,e,n){return t instanceof PN?(function(r,i){const a={fields:{[yY]:{stringValue:gY},[vY]:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}};return i&&pL(i)&&(i=rM(i)),i&&(a.fields[xY]=i),{mapValue:a}})(n,e):t instanceof cE?OY(t,e):t instanceof uE?LY(t,e):(function(r,i){const a=DY(r,i),o=WU(a)+WU(r.Ae);return z3(a)&&z3(r.Ae)?$Y(o):vL(r.serializer,o)})(t,e)}function A0e(t,e,n){return t instanceof cE?OY(t,e):t instanceof uE?LY(t,e):n}function DY(t,e){return t instanceof $N?(function(s){return z3(s)||(function(i){return!!i&&"doubleValue"in i})(s)})(e)?e:{integerValue:0}:null}class PN extends lM{}class cE extends lM{constructor(e){super(),this.elements=e}}function OY(t,e){const n=jY(e);for(const s of t.elements)n.some((r=>fp(r,s)))||n.push(s);return{arrayValue:{values:n}}}class uE extends lM{constructor(e){super(),this.elements=e}}function LY(t,e){let n=jY(e);for(const s of t.elements)n=n.filter((r=>!fp(r,s)));return{arrayValue:{values:n}}}class $N extends lM{constructor(e,n){super(),this.serializer=e,this.Ae=n}}function WU(t){return ba(t.integerValue||t.doubleValue)}function jY(t){return mL(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function C0e(t,e){return t.field.isEqual(e.field)&&(function(s,r){return s instanceof cE&&r instanceof cE||s instanceof uE&&r instanceof uE?P1(s.elements,r.elements,fp):s instanceof $N&&r instanceof $N?fp(s.Ae,r.Ae):s instanceof PN&&r instanceof PN})(t.transform,e.transform)}class k0e{constructor(e,n){this.version=e,this.transformResults=n}}class Ql{constructor(e,n){this.updateTime=e,this.exists=n}static none(){return new Ql}static exists(e){return new Ql(void 0,e)}static updateTime(e){return new Ql(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function xI(t,e){return t.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(t.updateTime):t.exists===void 0||t.exists===e.isFoundDocument()}class cM{}function BY(t,e){if(!t.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return t.isNoDocument()?new bL(t.key,Ql.none()):new yA(t.key,t.data,Ql.none());{const n=t.data,s=Jl.empty();let r=new oo(zo.comparator);for(let i of e.fields)if(!r.has(i)){let a=n.field(i);a===null&&i.length>1&&(i=i.popLast(),a=n.field(i)),a===null?s.delete(i):s.set(i,a),r=r.add(i)}return new J0(t.key,s,new ku(r.toArray()),Ql.none())}}function I0e(t,e,n){t instanceof yA?(function(r,i,a){const o=r.value.clone(),l=YU(r.fieldTransforms,i,a.transformResults);o.setAll(l),i.convertToFoundDocument(a.version,o).setHasCommittedMutations()})(t,e,n):t instanceof J0?(function(r,i,a){if(!xI(r.precondition,i))return void i.convertToUnknownDocument(a.version);const o=YU(r.fieldTransforms,i,a.transformResults),l=i.data;l.setAll(UY(r)),l.setAll(o),i.convertToFoundDocument(a.version,l).setHasCommittedMutations()})(t,e,n):(function(r,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()})(0,e,n)}function LS(t,e,n,s){return t instanceof yA?(function(i,a,o,l){if(!xI(i.prec
2123ondition,a))return o;const c=i.value.clone(),h=XU(i.fieldTransforms,l,a);return c.setAll(h),a.convertToFoundDocument(a.version,c).setHasLocalMutations(),null})(t,e,n,s):t instanceof J0?(function(i,a,o,l){if(!xI(i.precondition,a))return o;const c=XU(i.fieldTransforms,l,a),h=a.data;return h.setAll(UY(i)),h.setAll(c),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),o===null?null:o.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map((p=>p.field)))})(t,e,n,s):(function(i,a,o){return xI(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):o})(t,e,n)}function N0e(t,e){let n=null;for(const s of t.fieldTransforms){const r=e.data.field(s.field),i=DY(s.transform,r||null);i!=null&&(n===null&&(n=Jl.empty()),n.set(s.field,i))}return n||null}function KU(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!(function(s,r){return s===void 0&&r===void 0||!(!s||!r)&&P1(s,r,((i,a)=>C0e(i,a)))})(t.fieldTransforms,e.fieldTransforms)&&(t.type===0?t.value.isEqual(e.value):t.type!==1||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}class yA extends cM{constructor(e,n,s,r=[]){super(),this.key=e,this.value=n,this.precondition=s,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class J0 extends cM{constructor(e,n,s,r,i=[]){super(),this.key=e,this.data=n,this.fieldMask=s,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function UY(t){const e=new Map;return t.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const s=t.data.field(n);e.set(n,s)}})),e}function YU(t,e,n){const s=new Map;Ar(t.length===n.length,32656,{Ve:n.length,de:t.length});for(let r=0;r<n.length;r++){const i=t[r],a=i.transform,o=e.data.field(i.field);s.set(i.field,A0e(a,o,n[r]))}return s}function XU(t,e,n){const s=new Map;for(const r of t){const i=r.transform,a=n.data.field(r.field);s.set(r.field,T0e(i,a,e))}return s}class bL extends cM{constructor(e,n){super(),this.key=e,this.precondition=n,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class FY extends cM{constructor(e,n){super(),this.key=e,this.precondition=n,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
2124 * @license
2125 * Copyright 2017 Google LLC
2126 *
2127 * Licensed under the Apache License, Version 2.0 (the "License");
2128 * you may not use this file except in compliance with the License.
2129 * You may obtain a copy of the License at
2130 *
2131 *   http://www.apache.org/licenses/LICENSE-2.0
2132 *
2133 * Unless required by applicable law or agreed to in writing, software
2134 * distributed under the License is distributed on an "AS IS" BASIS,
2135 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2136 * See the License for the specific language governing permissions and
2137 * limitations under the License.
2138 */class R0e{constructor(e,n,s,r){this.batchId=e,this.localWriteTime=n,this.baseMutations=s,this.mutations=r}applyToRemoteDocument(e,n){const s=n.mutationResults;for(let r=0;r<this.mutations.length;r++){const i=this.mutations[r];i.key.isEqual(e.key)&&I0e(i,e,s[r])}}applyToLocalView(e,n){for(const s of this.baseMutations)s.key.isEqual(e.key)&&(n=LS(s,e,n,this.localWriteTime));for(const s of this.mutations)s.key.isEqual(e.key)&&(n=LS(s,e,n,this.localWriteTime));return n}applyToLocalDocumentSet(e,n){const s=PY();return this.mutations.forEach((r=>{const i=e.get(r.key),a=i.overlayedDocument;let o=this.applyToLocalView(a,i.mutatedFields);o=n.has(r.key)?null:o;const l=BY(a,o);l!==null&&s.set(r.key,l),a.isValidDocument()||a.convertToNoDocument(vs.min())})),s}keys(){return this.mutations.reduce(((e,n)=>e.add(n.key)),gr())}isEqual(e){return this.batchId===e.batchId&&P1(this.mutations,e.mutations,((n,s)=>KU(n,s)))&&P1(this.baseMutations,e.baseMutations,((n,s)=>KU(n,s)))}}class wL{constructor(e,n,s,r){this.batch=e,this.commitVersion=n,this.mutationResults=s,this.docVersions=r}static from(e,n,s){Ar(e.mutations.length===s.length,58842,{me:e.mutations.length,fe:s.length});let r=(function(){return b0e})();const i=e.mutations;for(let a=0;a<i.length;a++)r=r.insert(i[a].key,s[a].version);return new wL(e,n,s,r)}}/**
2139 * @license
2140 * Copyright 2022 Google LLC
2141 *
2142 * Licensed under the Apache License, Version 2.0 (the "License");
2143 * you may not use this file except in compliance with the License.
2144 * You may obtain a copy of the License at
2145 *
2146 *   http://www.apache.org/licenses/LICENSE-2.0
2147 *
2148 * Unless required by applicable law or agreed to in writing, software
2149 * distributed under the License is distributed on an "AS IS" BASIS,
2150 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2151 * See the License for the specific language governing permissions and
2152 * limitations under the License.
2153 */class M0e{constructor(e,n){this.largestBatchId=e,this.mutation=n}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
2154      largestBatchId: ${this.largestBatchId},
2155      mutation: ${this.mutation.toString()}
2156    }`}}/**
2157 * @license
2158 * Copyright 2017 Google LLC
2159 *
2160 * Licensed under the Apache License, Version 2.0 (the "License");
2161 * you may not use this file except in compliance with the License.
2162 * You may obtain a copy of the License at
2163 *
2164 *   http://www.apache.org/licenses/LICENSE-2.0
2165 *
2166 * Unless required by applicable law or agreed to in writing, software
2167 * distributed under the License is distributed on an "AS IS" BASIS,
2168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2169 * See the License for the specific language governing permissions and
2170 * limitations under the License.
2171 */class P0e{constructor(e,n){this.count=e,this.unchangedNames=n}}/**
2172 * @license
2173 * Copyright 2017 Google LLC
2174 *
2175 * Licensed under the Apache License, Version 2.0 (the "License");
2176 * you may not use this file except in compliance with the License.
2177 * You may obtain a copy of the License at
2178 *
2179 *   http://www.apache.org/licenses/LICENSE-2.0
2180 *
2181 * Unless required by applicable law or agreed to in writing, software
2182 * distributed under the License is distributed on an "AS IS" BASIS,
2183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2184 * See the License for the specific language governing permissions and
2185 * limitations under the License.
2186 */var $a,Er;function VY(t){switch(t){case Ot.OK:return ss(64938);case Ot.CANCELLED:case Ot.UNKNOWN:case Ot.DEADLINE_EXCEEDED:case Ot.RESOURCE_EXHAUSTED:case Ot.INTERNAL:case Ot.UNAVAILABLE:case Ot.UNAUTHENTICATED:return!1;case Ot.INVALID_ARGUMENT:case Ot.NOT_FOUND:case Ot.ALREADY_EXISTS:case Ot.PERMISSION_DENIED:case Ot.FAILED_PRECONDITION:case Ot.ABORTED:case Ot.OUT_OF_RANGE:case Ot.UNIMPLEMENTED:case Ot.DATA_LOSS:return!0;default:return ss(15467,{code:t})}}function zY(t){if(t===void 0)return $m("GRPC error has no .code"),Ot.UNKNOWN;switch(t){case $a.OK:return Ot.OK;case $a.CANCELLED:return Ot.CANCELLED;case $a.UNKNOWN:return Ot.UNKNOWN;case $a.DEADLINE_EXCEEDED:return Ot.DEADLINE_EXCEEDED;case $a.RESOURCE_EXHAUSTED:return Ot.RESOURCE_EXHAUSTED;case $a.INTERNAL:return Ot.INTERNAL;case $a.UNAVAILABLE:return Ot.UNAVAILABLE;case $a.UNAUTHENTICATED:return Ot.UNAUTHENTICATED;case $a.INVALID_ARGUMENT:return Ot.INVALID_ARGUMENT;case $a.NOT_FOUND:return Ot.NOT_FOUND;case $a.ALREADY_EXISTS:return Ot.ALREADY_EXISTS;case $a.PERMISSION_DENIED:return Ot.PERMISSION_DENIED;case $a.FAILED_PRECONDITION:return Ot.FAILED_PRECONDITION;case $a.ABORTED:return Ot.ABORTED;case $a.OUT_OF_RANGE:return Ot.OUT_OF_RANGE;case $a.UNIMPLEMENTED:return Ot.UNIMPLEMENTED;case $a.DATA_LOSS:return Ot.DATA_LOSS;default:return ss(39323,{code:t})}}(Er=$a||($a={}))[Er.OK=0]="OK",Er[Er.CANCELLED=1]="CANCELLED",Er[Er.UNKNOWN=2]="UNKNOWN",Er[Er.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Er[Er.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Er[Er.NOT_FOUND=5]="NOT_FOUND",Er[Er.ALREADY_EXISTS=6]="ALREADY_EXISTS",Er[Er.PERMISSION_DENIED=7]="PERMISSION_DENIED",Er[Er.UNAUTHENTICATED=16]="UNAUTHENTICATED",Er[Er.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Er[Er.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Er[Er.ABORTED=10]="ABORTED",Er[Er.OUT_OF_RANGE=11]="OUT_OF_RANGE",Er[Er.UNIMPLEMENTED=12]="UNIMPLEMENTED",Er[Er.INTERNAL=13]="INTERNAL",Er[Er.UNAVAILABLE=14]="UNAVAILABLE",Er[Er.DATA_LOSS=15]="DATA_LOSS";/**
2187 * @license
2188 * Copyright 2023 Google LLC
2189 *
2190 * Licensed under the Apache License, Version 2.0 (the "License");
2191 * you may not use this file except in compliance with the License.
2192 * You may obtain a copy of the License at
2193 *
2194 *   http://www.apache.org/licenses/LICENSE-2.0
2195 *
2196 * Unless required by applicable law or agreed to in writing, software
2197 * distributed under the License is distributed on an "AS IS" BASIS,
2198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2199 * See the License for the specific language governing permissions and
2200 * limitations under the License.
2201 */function $0e(){return new TextEncoder}/**
2202 * @license
2203 * Copyright 2022 Google LLC
2204 *
2205 * Licensed under the Apache License, Version 2.0 (the "License");
2206 * you may not use this file except in compliance with the License.
2207 * You may obtain a copy of the License at
2208 *
2209 *   http://www.apache.org/licenses/LICENSE-2.0
2210 *
2211 * Unless required by applicable law or agreed to in writing, software
2212 * distributed under the License is distributed on an "AS IS" BASIS,
2213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2214 * See the License for the specific language governing permissions and
2215 * limitations under the License.
2216 */const D0e=new R0([4294967295,4294967295],0);function JU(t){const e=$0e().encode(t),n=new iY;return n.update(e),new Uint8Array(n.digest())}function QU(t){const e=new DataView(t.buffer),n=e.getUint32(0,!0),s=e.getUint32(4,!0),r=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new R0([n,s],0),new R0([r,i],0)]}class _L{constructor(e,n,s){if(this.bitmap=e,this.padding=n,this.hashCount=s,n<0||n>=8)throw new aS(`Invalid padding: ${n}`);if(s<0)throw new aS(`Invalid hash count: ${s}`);if(e.length>0&&this.hashCount===0)throw new aS(`Invalid hash count: ${s}`);if(e.length===0&&n!==0)throw new aS(`Invalid padding when bitmap length is 0: ${n}`);this.ge=8*e.length-n,this.pe=R0.fromNumber(this.ge)}ye(e,n,s){let r=e.add(n.multiply(R0.fromNumber(s)));return r.compare(D0e)===1&&(r=new R0([r.getBits(0),r.getBits(1)],0)),r.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const n=JU(e),[s,r]=QU(n);for(let i=0;i<this.hashCount;i++){const a=this.ye(s,r,i);if(!this.we(a))return!1}return!0}static create(e,n,s){const r=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new _L(i,r,n);return s.forEach((o=>a.insert(o))),a}insert(e){if(this.ge===0)return;const n=JU(e),[s,r]=QU(n);for(let i=0;i<this.hashCount;i++){const a=this.ye(s,r,i);this.Se(a)}}Se(e){const n=Math.floor(e/8),s=e%8;this.bitmap[n]|=1<<s}}class aS extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
2217 * @license
2218 * Copyright 2017 Google LLC
2219 *
2220 * Licensed under the Apache License, Version 2.0 (the "License");
2221 * you may not use this file except in compliance with the License.
2222 * You may obtain a copy of the License at
2223 *
2224 *   http://www.apache.org/licenses/LICENSE-2.0
2225 *
2226 * Unless required by applicable law or agreed to in writing, software
2227 * distributed under the License is distributed on an "AS IS" BASIS,
2228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2229 * See the License for the specific language governing permissions and
2230 * limitations under the License.
2231 */class uM{constructor(e,n,s,r,i){this.snapshotVersion=e,this.targetChanges=n,this.targetMismatches=s,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,n,s){const r=new Map;return r.set(e,xA.createSynthesizedTargetChangeForCurrentChange(e,n,s)),new uM(vs.min(),r,new ta(mr),Dm(),gr())}}class xA{constructor(e,n,s,r,i){this.resumeToken=e,this.current=n,this.addedDocuments=s,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,n,s){return new xA(s,n,gr(),gr(),gr())}}/**
2232 * @license
2233 * Copyright 2017 Google LLC
2234 *
2235 * Licensed under the Apache License, Version 2.0 (the "License");
2236 * you may not use this file except in compliance with the License.
2237 * You may obtain a copy of the License at
2238 *
2239 *   http://www.apache.org/licenses/LICENSE-2.0
2240 *
2241 * Unless required by applicable law or agreed to in writing, softw
2241are
2242 * distributed under the License is distributed on an "AS IS" BASIS,
2243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2244 * See the License for the specific language governing permissions and
2245 * limitations under the License.
2246 */class vI{constructor(e,n,s,r){this.be=e,this.removedTargetIds=n,this.key=s,this.De=r}}class GY{constructor(e,n){this.targetId=e,this.Ce=n}}class HY{constructor(e,n,s=Wo.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=n,this.resumeToken=s,this.cause=r}}class ZU{constructor(){this.ve=0,this.Fe=eF(),this.Me=Wo.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=gr(),n=gr(),s=gr();return this.Fe.forEach(((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:n=n.add(r);break;case 1:s=s.add(r);break;default:ss(38017,{changeType:i})}})),new xA(this.Me,this.xe,e,n,s)}qe(){this.Oe=!1,this.Fe=eF()}Ke(e,n){this.Oe=!0,this.Fe=this.Fe.insert(e,n)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,Ar(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class O0e{constructor(e){this.Ge=e,this.ze=new Map,this.je=Dm(),this.Je=Nk(),this.He=Nk(),this.Ze=new ta(mr)}Xe(e){for(const n of e.be)e.De&&e.De.isFoundDocument()?this.Ye(n,e.De):this.et(n,e.key,e.De);for(const n of e.removedTargetIds)this.et(n,e.key,e.De)}tt(e){this.forEachTarget(e,(n=>{const s=this.nt(n);switch(e.state){case 0:this.rt(n)&&s.Le(e.resumeToken);break;case 1:s.We(),s.Ne||s.qe(),s.Le(e.resumeToken);break;case 2:s.We(),s.Ne||this.removeTarget(n);break;case 3:this.rt(n)&&(s.Qe(),s.Le(e.resumeToken));break;case 4:this.rt(n)&&(this.it(n),s.Le(e.resumeToken));break;default:ss(56790,{state:e.state})}}))}forEachTarget(e,n){e.targetIds.length>0?e.targetIds.forEach(n):this.ze.forEach(((s,r)=>{this.rt(r)&&n(r)}))}st(e){const n=e.targetId,s=e.Ce.count,r=this.ot(n);if(r){const i=r.target;if(H3(i))if(s===0){const a=new rs(i.path);this.et(n,a,ko.newNoDocument(a,vs.min()))}else Ar(s===1,20013,{expectedCount:s});else{const a=this._t(n);if(a!==s){const o=this.ut(e),l=o?this.ct(o,e,a):1;if(l!==0){this.it(n);const c=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(n,c)}}}}}ut(e){const n=e.Ce.unchangedNames;if(!n||!n.bits)return null;const{bits:{bitmap:s="",padding:r=0},hashCount:i=0}=n;let a,o;try{a=L0(s).toUint8Array()}catch(l){if(l instanceof mY)return M1("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{o=new _L(a,r,i)}catch(l){return M1(l instanceof aS?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return o.ge===0?null:o}ct(e,n,s){return n.Ce.count===s-this.Pt(e,n.targetId)?0:2}Pt(e,n){const s=this.Ge.getRemoteKeysForTarget(n);let r=0;return s.forEach((i=>{const a=this.Ge.ht(),o=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(o)||(this.et(n,i,null),r++)})),r}Tt(e){const n=new Map;this.ze.forEach(((i,a)=>{const o=this.ot(a);if(o){if(i.current&&H3(o.target)){const l=new rs(o.target.path);this.Et(l).has(a)||this.It(a,l)||this.et(a,l,ko.newNoDocument(l,e))}i.Be&&(n.set(a,i.ke()),i.qe())}}));let s=gr();this.He.forEach(((i,a)=>{let o=!0;a.forEachWhile((l=>{const c=this.ot(l);return!c||c.purpose==="TargetPurposeLimboResolution"||(o=!1,!1)})),o&&(s=s.add(i))})),this.je.forEach(((i,a)=>a.setReadTime(e)));const r=new uM(e,n,this.Ze,this.je,s);return this.je=Dm(),this.Je=Nk(),this.He=Nk(),this.Ze=new ta(mr),r}Ye(e,n){if(!this.rt(e))return;const s=this.It(e,n.key)?2:0;this.nt(e).Ke(n.key,s),this.je=this.je.insert(n.key,n),this.Je=this.Je.insert(n.key,this.Et(n.key).add(e)),this.He=this.He.insert(n.key,this.Rt(n.key).add(e))}et(e,n,s){if(!this.rt(e))return;const r=this.nt(e);this.It(e,n)?r.Ke(n,1):r.Ue(n),this.He=this.He.insert(n,this.Rt(n).delete(e)),this.He=this.He.insert(n,this.Rt(n).add(e)),s&&(this.je=this.je.insert(n,s))}removeTarget(e){this.ze.delete(e)}_t(e){const n=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+n.addedDocuments.size-n.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let n=this.ze.get(e);return n||(n=new ZU,this.ze.set(e,n)),n}Rt(e){let n=this.He.get(e);return n||(n=new oo(mr),this.He=this.He.insert(e,n)),n}Et(e){let n=this.Je.get(e);return n||(n=new oo(mr),this.Je=this.Je.insert(e,n)),n}rt(e){const n=this.ot(e)!==null;return n||xn("WatchChangeAggregator","Detected inactive target",e),n}ot(e){const n=this.ze.get(e);return n&&n.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new ZU),this.Ge.getRemoteKeysForTarget(e).forEach((n=>{this.et(e,n,null)}))}It(e,n){return this.Ge.getRemoteKeysForTarget(e).has(n)}}
vendor: 7,778 bytes, line 2246
2246function Nk(){return new ta(rs.comparator)}function eF(){return new ta(rs.comparator)}const L0e={asc:"ASCENDING",desc:"DESCENDING"},j0e={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},B0e={and:"AND",or:"OR"};class U0e{constructor(e,n){this.databaseId=e,this.useProto3Json=n}}function W3(t,e){return t.useProto3Json||gA(e)?e:{value:e}}function DN(t,e){return t.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function qY(t,e){return t.useProto3Json?e.toBase64():e.toUint8Array()}function F0e(t,e){return DN(t,e.toTimestamp())}function Iu(t){return Ar(!!t,49232),vs.fromTimestamp((function(n){const s=O0(n);return new Oi(s.seconds,s.nanos)})(t))}function SL(t,e){return K3(t,e).canonicalString()}function K3(t,e){const n=(function(r){return new Di(["projects",r.projectId,"databases",r.database])})(t).child("documents");return e===void 0?n:n.child(e)}function WY(t){const e=Di.fromString(t);return Ar(ZY(e),10190,{key:e.toString()}),e}function ON(t,e){return SL(t.databaseId,e.path)}function jS(t,e){const n=WY(e);if(n.get(1)!==t.databaseId.projectId)throw new Cn(Ot.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Cn(Ot.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new rs(YY(n))}function KY(t,e){return SL(t.databaseId,e)}function V0e(t){const e=WY(t);return e.length===4?Di.emptyPath():YY(e)}function Y3(t){return new Di(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function YY(t){return Ar(t.length>4&&t.get(4)==="documents",29091,{key:t.toString()}),t.popFirst(5)}function tF(t,e,n){return{name:ON(t,e),fields:n.value.mapValue.fields}}function z0e(t,e){return"found"in e?(function(s,r){Ar(!!r.found,43571),r.found.name,r.found.updateTime;const i=jS(s,r.found.name),a=Iu(r.found.updateTime),o=r.found.createTime?Iu(r.found.createTime):vs.min(),l=new Jl({mapValue:{fields:r.found.fields}});return ko.newFoundDocument(i,a,o,l)})(t,e):"missing"in e?(function(s,r){Ar(!!r.missing,3894),Ar(!!r.readTime,22933);const i=jS(s,r.missing),a=Iu(r.readTime);return ko.newNoDocument(i,a)})(t,e):ss(7234,{result:e})}function G0e(t,e){let n;if("targetChange"in e){e.targetChange;const s=(function(c){return c==="NO_CHANGE"?0:c==="ADD"?1:c==="REMOVE"?2:c==="CURRENT"?3:c==="RESET"?4:ss(39313,{state:c})})(e.targetChange.targetChangeType||"NO_CHANGE"),r=e.targetChange.targetIds||[],i=(function(c,h){return c.useProto3Json?(Ar(h===void 0||typeof h=="string",58123),Wo.fromBase64String(h||"")):(Ar(h===void 0||h instanceof Buffer||h instanceof Uint8Array,16193),Wo.fromUint8Array(h||new Uint8Array))})(t,e.targetChange.resumeToken),a=e.targetChange.cause,o=a&&(function(c){const h=c.code===void 0?Ot.UNKNOWN:zY(c.code);return new Cn(h,c.message||"")})(a);n=new HY(s,r,i,o||null)}else if("documentChange"in e){e.documentChange;const s=e.documentChange;s.document,s.document.name,s.document.updateTime;const r=jS(t,s.document.name),i=Iu(s.document.updateTime),a=s.document.createTime?Iu(s.document.createTime):vs.min(),o=new Jl({mapValue:{fields:s.document.fields}}),l=ko.newFoundDocument(r,i,a,o),c=s.targetIds||[],h=s.removedTargetIds||[];n=new vI(c,h,l.key,l)}else if("documentDelete"in e){e.documentDelete;const s=e.documentDelete;s.document;const r=jS(t,s.document),i=s.readTime?Iu(s.readTime):vs.min(),a=ko.newNoDocument(r,i),o=s.removedTargetIds||[];n=new vI([],o,a.key,a)}else if("documentRemove"in e){e.documentRemove;const s=e.documentRemove;s.document;const r=jS(t,s.document),i=s.removedTargetIds||[];n=new vI([],i,r,null)}else{if(!("filter"in e))return ss(11601,{Vt:e});{e.filter;const s=e.filter;s.targetId;const{count:r=0,unchangedNames:i}=s,a=new P0e(r,i),o=s.targetId;n=new GY(o,a)}}return n}function XY(t,e){let n;if(e instanceof yA)n={update:tF(t,e.key,e.value)};else if(e instanceof bL)n={delete:ON(t,e.key)};else if(e instanceof J0)n={update:tF(t,e.key,e.data),updateMask:Z0e(e.fieldMask)};else{if(!(e instanceof FY))return ss(16599,{dt:e.type});n={verify:ON(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((s=>(function(i,a){const o=a.transform;if(o instanceof PN)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(o instanceof cE)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:o.elements}};if(o instanceof uE)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:o.elements}};if(o instanceof $N)return{fieldPath:a.field.canonicalString(),increment:o.Ae};throw ss(20930,{transform:a.transform})})(0,s)))),e.precondition.isNone||(n.currentDocument=(function(r,i){return i.updateTime!==void 0?{updateTime:F0e(r,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:ss(27497)})(t,e.precondition)),n}function H0e(t,e){return t&&t.length>0?(Ar(e!==void 0,14353),t.map((n=>(function(r,i){let a=r.updateTime?Iu(r.updateTime):Iu(i);return a.isEqual(vs.min())&&(a=Iu(i)),new k0e(a,r.transformResults||[])})(n,e)))):[]}function q0e(t,e){return{documents:[KY(t,e.path)]}}function W0e(t,e){const n={structuredQuery:{}},s=e.path;let r;e.collectionGroup!==null?(r=s,n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(r=s.popLast(),n.structuredQuery.from=[{collectionId:s.lastSegment()}]),n.parent=KY(t,r);const i=(function(c){if(c.length!==0)return QY(pp.create(c,"and"))})(e.filters);i&&(n.structuredQuery.where=i);const a=(function(c){if(c.length!==0)return c.map((h=>(function(m){return{field:Gb(m.field),direction:X0e(m.dir)}})(h)))})(e.orderBy);a&&(n.structuredQuery.orderBy=a);const o=W3(t,e.limit);return o!==null&&(n.structuredQuery.limit=o),e.startAt&&(n.structuredQuery.startAt=(function(c){return{before:c.inclusive,values:c.position}})(e.startAt)),e.endAt&&(n.structuredQuery.endAt=(function(c){return{before:!c.inclusive,values:c.position}})(e.endAt)),{ft:n,parent:r}}function K0e(t){let e=V0e(t.parent);const n=t.structuredQuery,s=n.from?n.from.length:0;let r=null;if(s>0){Ar(s===1,65062);const h=n.from[0];h.allDescendants?r=h.collectionId:e=e.child(h.collectionId)}let i=[];n.where&&(i=(function(p){const m=JY(p);return m instanceof pp&&TY(m)?m.getFilters():[m]})(n.where));let a=[];n.orderBy&&(a=(function(p){return p.map((m=>(function(v){return new MN(Hb(v.field),(function(S){switch(S){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(v.direction))})(m)))})(n.orderBy));let o=null;n.limit&&(o=(function(p){let m;return m=typeof p=="object"?p.value:p,gA(m)?null:m})(n.limit));let l=null;n.startAt&&(l=(function(p){const m=!!p.before,y=p.values||[];return new RN(y,m)})(n.startAt));let c=null;return n.endAt&&(c=(function(p){const m=!p.before,y=p.values||[];return new RN(y,m)})(n.endAt)),f0e(e,r,a,i,o,"F",l,c)}function Y0e(t,e){const n=(function(r){switch(r){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return ss(28987,{purpose:r})}})(e.purpose);return n==null?null:{"goog-listen-tags":n}}function JY(t){return t.unaryFilter!==void 0?(function(n){switch(n.unaryFilter.op){case"IS_NAN":const s=Hb(n.unaryFilter.field);return io.create(s,"==",{doubleValue:NaN});case"IS_NULL":const r=Hb(n.unaryFilter.field);return io.create(r,"==",{nullValue:"NULL_VALUE"});
2246case"IS_NOT_NAN":const i=Hb(n.unaryFilter.field);return io.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=Hb(n.unaryFilter.field);return io.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return ss(61313);default:return ss(60726)}})(t):t.fieldFilter!==void 0?(function(n){return io.create(Hb(n.fieldFilter.field),(function(r){switch(r){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return ss(58110);default:return ss(50506)}})(n.fieldFilter.op),n.fieldFilter.value)})(t):t.compositeFilter!==void 0?(function(n){return pp.create(n.compositeFilter.filters.map((s=>JY(s))),(function(r){switch(r){case"AND":return"and";case"OR":return"or";default:return ss(1026)}})(n.compositeFilter.op))})(t):ss(30097,{filter:t})}function X0e(t){return L0e[t]}function J0e(t){return j0e[t]}function Q0e(t){return B0e[t]}function Gb(t){return{fieldPath:t.canonicalString()}}function Hb(t){return zo.fromServerFormat(t.fieldPath)}function QY(t){return t instanceof io?(function(n){if(n.op==="=="){if(VU(n.value))return{unaryFilter:{field:Gb(n.field),op:"IS_NAN"}};if(FU(n.value))return{unaryFilter:{field:Gb(n.field),op:"IS_NULL"}}}else if(n.op==="!="){if(VU(n.value))return{unaryFilter:{field:Gb(n.field),op:"IS_NOT_NAN"}};if(FU(n.value))return{unaryFilter:{field:Gb(n.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Gb(n.field),op:J0e(n.op),value:n.value}}})(t):t instanceof pp?(function(n){const s=n.getFilters().map((r=>QY(r)));return s.length===1?s[0]:{compositeFilter:{op:Q0e(n.op),filters:s}}})(t):ss(54877,{filter:t})}function Z0e(t){const e=[];return t.fields.forEach((n=>e.push(n.canonicalString()))),{fieldPaths:e}}function ZY(t){return t.length>=4&&t.get(0)==="projects"&&t.get(2)==="databases"}function eX(t){return!!t&&typeof t._toProto=="function"&&t._protoValueType==="ProtoValue"}/**
2247 * @license
2248 * Copyright 2017 Google LLC
2249 *
2250 * Licensed under the Apache License, Version 2.0 (the "License");
2251 * you may not use this file except in compliance with the License.
2252 * You may obtain a copy of the License at
2253 *
2254 *   http://www.apache.org/licenses/LICENSE-2.0
2255 *
2256 * Unless required by applicable law or agreed to in writing, software
2257 * distributed under the License is distributed on an "AS IS" BASIS,
2258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2259 * See the License for the specific language governing permissions and
2260 * limitations under the License.
2261 */class _0{constructor(e,n,s,r,i=vs.min(),a=vs.min(),o=Wo.EMPTY_BYTE_STRING,l=null){this.target=e,this.targetId=n,this.purpose=s,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=o,this.expectedCount=l}withSequenceNumber(e){return new _0(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,n){return new _0(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new _0(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new _0(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
2262 * @license
2263 * Copyright 2017 Google LLC
2264 *
2265 * Licensed under the Apache License, Version 2.0 (the "License");
2266 * you may not use this file except in compliance with the License.
2267 * You may obtain a copy of the License at
2268 *
2269 *   http://www.apache.org/licenses/LICENSE-2.0
2270 *
2271 * Unless required by applicable law or agreed to in writing, software
2272 * distributed under the License is distributed on an "AS IS" BASIS,
2273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2274 * See the License for the specific language governing permissions and
2275 * limitations under the License.
2276 */class eye{constructor(e){this.yt=e}}function tye(t){const e=K0e({parent:t.parent,structuredQuery:t.structuredQuery});return t.limitType==="LAST"?q3(e,e.limit,"L"):e}/**
2277 * @license
2278 * Copyright 2019 Google LLC
2279 *
2280 * Licensed under the Apache License, Version 2.0 (the "License");
2281 * you may not use this file except in compliance with the License.
2282 * You may obtain a copy of the License at
2283 *
2284 *   http://www.apache.org/licenses/LICENSE-2.0
2285 *
2286 * Unless required by applicable law or agreed to in writing, software
2287 * distributed under the License is distributed on an "AS IS" BASIS,
2288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2289 * See the License for the specific language governing permissions and
2290 * limitations under the License.
2291 */class nye{constructor(){this.bn=new sye}addToCollectionParentIndex(e,n){return this.bn.add(n),$t.resolve()}getCollectionParents(e,n){return $t.resolve(this.bn.getEntries(n))}addFieldIndex(e,n){return $t.resolve()}deleteFieldIndex(e,n){return $t.resolve()}deleteAllFieldIndexes(e){return $t.resolve()}createTargetIndexes(e,n){return $t.resolve()}getDocumentsMatchingTarget(e,n){return $t.resolve(null)}getIndexType(e,n){return $t.resolve(0)}getFieldIndexes(e,n){return $t.resolve([])}getNextCollectionGroupToUpdate(e){return $t.resolve(null)}getMinOffset(e,n){return $t.resolve(D0.min())}getMinOffsetFromCollectionGroup(e,n){return $t.resolve(D0.min())}updateCollectionGroup(e,n,s){return $t.resolve()}updateIndexEntries(e,n){return $t.resolve()}}class sye{constructor(){this.index={}}add(e){const n=e.lastSegment(),s=e.popLast(),r=this.index[n]||new oo(Di.comparator),i=!r.has(s);return this.index[n]=r.add(s),i}has(e){const n=e.lastSegment(),s=e.popLast(),r=this.index[n];return r&&r.has(s)}getEntries(e){return(this.index[e]||new oo(Di.comparator)).toArray()}}/**
2292 * @license
2293 * Copyright 2018 Google LLC
2294 *
2295 * Licensed under the Apache License, Version 2.0 (the "License");
2296 * you may not use this file except in compliance with the License.
2297 * You may obtain a copy of the License at
2298 *
2299 *   http://www.apache.org/licenses/LICENSE-2.0
2300 *
2301 * Unless required by applicable law or agreed to in writing, software
2302 * distributed under the License is distributed on an "AS IS" BASIS,
2303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2304 * See the License for the specific language governing permissions and
2305 * limitations under the License.
2306 */const nF={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},tX=41943040;class jc{static withCacheSize(e){return new jc(e,jc.DEFAULT_COLLECTION_PERCENTILE,jc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,n,s){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=n,this.maximumSequenceNumbersToCollect=s}}/**
2307 * @license
2308 * Copyright 2017 Google LLC
2309 *
2310 * Licensed under the Apache License, Version 2.0 (the "License");
2311 * you may not use this file except in compliance with the License.
2312 * You may obtain a copy of the License at
2313 *
2314 *   http://www.apache.org/licenses/LICENSE-2.0
2315 *
2316 * Unless required by applicable law or agreed to in writing, software
2317 * distributed under the License is distributed on an "AS IS" BASIS,
2318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2319 * See the License for the specific language governing permissions and
2320 * limitations under the License.
2321 */jc.DEFAULT_COLLECTION_PERCENTILE=10,jc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,jc.DEFAULT=new jc(tX,jc.DEFAULT_COLLECTION_PERCENTILE,jc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),jc.DISABLED=new jc(-1,0,0);/**
2322 * @license
2323 * Copyright 2017 Google LLC
2324 *
2325 * Licensed under the Apache License, Version 2.0 (the "License");
2326 * you may not use this file except in compliance with the License.
2327 * You may obtain a copy of the License at
2328 *
2329 *   http://www.apache.org/licenses/LICENSE-2.0
2330 *
2331 * Unless required by applicable law or agreed to in writing, software
2332 * distributed under the License is distributed on an "AS IS" BASIS,
2333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2334 * See the License for the specific language governing permissions and
2335 * limitations under the License.
2336 */class O1{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new O1(0)}static ar(){return new O1(-1)}}/**
2337 * @license
2338 * Copyright 2020 Google LLC
2339 *
2340 * Licensed under the Apache License, Version 2.0 (the "License");
2341 * you may not use this file except in compliance with the License.
2342 * You may obtain a copy of the License at
2343 *
2344 *   http://www.apache.org/licenses/LICENSE-2.0
2345 *
2346 * Unless required by applicable law or agreed to in writing, software
2347 * distributed under the License is distributed on an "AS IS" BASIS,
2348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2349 * See the License for the specific language governing permissions and
2350 * limitations under the License.
2351 */const sF="LruGarbageCollector",nX=1048576;function rF([t,e],[n,s]){const r=mr(t,n);return r===0?mr(e,s):r}class rye{constructor(e){this.Pr=e,this.buffer=new oo(rF),this.Tr=0}Er(){return++this.Tr}Ir(e){const n=[e,this.Er()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(n);else{const s=this.buffer.last();rF(n,s)<0&&(this.buffer=this.buffer.delete(s).add(n))}}get maxValue(){return this.buffer.last()[0]}}class iye{constructor(e,n,s){this.garbageCollector=e,this.asyncQueue=n,this.localStore=s,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Ar(e){xn(sF,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(n){Z1(n)?xn(sF,"Ignoring IndexedDB error during garbage collection: ",n):await Q1(n)}await this.Ar(3e5)}))}}class aye{constructor(e,n){this.Vr=e,this.params=n}calculateTargetCount(e,n){return this.Vr.dr(e).next((s=>Math.floor(n/100*s)))}nthSequenceNumber(e,n){if(n===0)return $t.resolve(sM.ce);const s=new rye(n);return this.Vr.forEachTarget(e,(r=>s.Ir(r.sequenceNumber))).next((()=>this.Vr.mr(e,(r=>s.Ir(r))))).next((()=>s.maxValue))}removeTargets(e,n,s){return this.Vr.removeTargets(e,n,s)}removeOrphanedDocuments(e,n){return this.Vr.removeOrphanedDocuments(e,n)}collect(e,n){return this.params.cacheSizeCollectionThreshold===-1?(xn("LruGarbageCollector","Garbage collection skipped; disabled"),$t.resolve(nF)):this.getCacheSize(e).next((s=>s<this.params.cacheSizeCollectionThreshold?(xn("LruGarbageCollector",`Garbage collection skipped; Cache size ${s} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),nF):this.gr(e,n)))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,n){let s,r,i,a,o,l,c;const h=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((p=>(p>this.params.maximumSequenceNumbersToCollect?(xn("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${p}`),r=this.params.maximumSequenceNumbersToCollect):r=p,a=Date.now(),this.nthSequenceNumber(e,r)))).next((p=>(s=p,o=Date.now(),this.removeTargets(e,s,n)))).next((p=>(i=p,l=Date.now(),this.removeOrphanedDocuments(e,s)))).next((p=>(c=Date.now(),Vb()<=pr.DEBUG&&xn("LruGarbageCollector",`LRU Garbage Collection
2352	Counted targets in ${a-h}ms
2353	Determined least recently used ${r} in `+(o-a)+`ms
2354	Removed ${i} targets in `+(l-o)+`ms
2355	Removed ${p} documents in `+(c-l)+`ms
2356Total Duration: ${c-h}ms`),$t.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:p}))))}}function oye(t,e){return new aye(t,e)}/**
2357 * @license
2358 * Copyright 2017 Google LLC
2359 *
2360 * Licensed under the Apache License, Version 2.0 (the "License");
2361 * you may not use this file except in compliance with the License.
2362 * You may obtain a copy of the License at
2363 *
2364 *   http://www.apache.org/licenses/LICENSE-2.0
2365 *
2366 * Unless required by applicable law or agreed to in writing, software
2367 * distributed under the License is distributed on an "AS IS" BASIS,
2368 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2369 * See the License for the specific language governing permissions and
2370 * limitations under the License.
2371 */class lye{constructor(){this.changes=new Uv((e=>e.toString()),((e,n)=>e.isEqual(n))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,n){this.assertNotApplied(),this.changes.set(e,ko.newInvalidDocument(e).setReadTime(n))}getEntry(e,n){this.assertNotApplied();const s=this.changes.get(n);return s!==void 0?$t.resolve(s):this.getFromCache(e,n)}getEntries(e,n){return this.getAllFromCache(e,n)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}
vendor: 4,984 bytes, lines 2371-2416
2371assertNotApplied(){}}/**
2372 * @license
2373 * Copyright 2017 Google LLC
2374 *
2375 * Licensed under the Apache License, Version 2.0 (the "License");
2376 * you may not use this file except in compliance with the License.
2377 * You may obtain a copy of the License at
2378 *
2379 *   http://www.apache.org/licenses/LICENSE-2.0
2380 *
2381 * Unless required by applicable law or agreed to in writing, software
2382 * distributed under the License is distributed on an "AS IS" BASIS,
2383 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2384 * See the License for the specific language governing permissions and
2385 * limitations under the License.
2386 *//**
2387 * @license
2388 * Copyright 2022 Google LLC
2389 *
2390 * Licensed under the Apache License, Version 2.0 (the "License");
2391 * you may not use this file except in compliance with the License.
2392 * You may obtain a copy of the License at
2393 *
2394 *   http://www.apache.org/licenses/LICENSE-2.0
2395 *
2396 * Unless required by applicable law or agreed to in writing, software
2397 * distributed under the License is distributed on an "AS IS" BASIS,
2398 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2399 * See the License for the specific language governing permissions and
2400 * limitations under the License.
2401 */class cye{constructor(e,n){this.overlayedDocument=e,this.mutatedFields=n}}/**
2402 * @license
2403 * Copyright 2017 Google LLC
2404 *
2405 * Licensed under the Apache License, Version 2.0 (the "License");
2406 * you may not use this file except in compliance with the License.
2407 * You may obtain a copy of the License at
2408 *
2409 *   http://www.apache.org/licenses/LICENSE-2.0
2410 *
2411 * Unless required by applicable law or agreed to in writing, software
2412 * distributed under the License is distributed on an "AS IS" BASIS,
2413 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2414 * See the License for the specific language governing permissions and
2415 * limitations under the License.
2416 */class uye{constructor(e,n,s,r){this.remoteDocumentCache=e,this.mutationQueue=n,this.documentOverlayCache=s,this.indexManager=r}getDocument(e,n){let s=null;return this.documentOverlayCache.getOverlay(e,n).next((r=>(s=r,this.remoteDocumentCache.getEntry(e,n)))).next((r=>(s!==null&&LS(s.mutation,r,ku.empty(),Oi.now()),r)))}getDocuments(e,n){return this.remoteDocumentCache.getEntries(e,n).next((s=>this.getLocalViewOfDocuments(e,s,gr()).next((()=>s))))}getLocalViewOfDocuments(e,n,s=gr()){const r=tx();return this.populateOverlays(e,r,n).next((()=>this.computeViews(e,n,r,s).next((i=>{let a=iS();return i.forEach(((o,l)=>{a=a.insert(o,l.overlayedDocument)})),a}))))}getOverlayedDocuments(e,n){const s=tx();return this.populateOverlays(e,s,n).next((()=>this.computeViews(e,n,s,gr())))}populateOverlays(e,n,s){const r=[];return s.forEach((i=>{n.has(i)||r.push(i)})),this.documentOverlayCache.getOverlays(e,r).next((i=>{i.forEach(((a,o)=>{n.set(a,o)}))}))}computeViews(e,n,s,r){let i=Dm();const a=OS(),o=(function(){return OS()})();return n.forEach(((l,c)=>{const h=s.get(c.key);r.has(c.key)&&(h===void 0||h.mutation instanceof J0)?i=i.insert(c.key,c):h!==void 0?(a.set(c.key,h.mutation.getFieldMask()),LS(h.mutation,c,h.mutation.getFieldMask(),Oi.now())):a.set(c.key,ku.empty())})),this.recalculateAndSaveOverlays(e,i).next((l=>(l.forEach(((c,h)=>a.set(c,h))),n.forEach(((c,h)=>o.set(c,new cye(h,a.get(c)??null)))),o)))}recalculateAndSaveOverlays(e,n){const s=OS();let r=new ta(((a,o)=>a-o)),i=gr();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,n).next((a=>{for(const o of a)o.keys().forEach((l=>{const c=n.get(l);if(c===null)return;let h=s.get(l)||ku.empty();h=o.applyToLocalView(c,h),s.set(l,h);const p=(r.get(o.batchId)||gr()).add(l);r=r.insert(o.batchId,p)}))})).next((()=>{const a=[],o=r.getReverseIterator();for(;o.hasNext();){const l=o.getNext(),c=l.key,h=l.value,p=PY();h.forEach((m=>{if(!i.has(m)){const y=BY(n.get(m),s.get(m));y!==null&&p.set(m,y),i=i.add(m)}})),a.push(this.documentOverlayCache.saveOverlays(e,c,p))}return $t.waitFor(a)})).next((()=>s))}recalculateAndSaveOverlaysForDocumentKeys(e,n){return this.remoteDocumentCache.getEntries(e,n).next((s=>this.recalculateAndSaveOverlays(e,s)))}getDocumentsMatchingQuery(e,n,s,r){return p0e(n)?this.getDocumentsMatchingDocumentQuery(e,n.path):m0e(n)?this.getDocumentsMatchingCollectionGroupQuery(e,n,s,r):this.getDocumentsMatchingCollectionQuery(e,n,s,r)}getNextDocuments(e,n,s,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,n,s,r).next((i=>{const a=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,n,s.largestBatchId,r-i.size):$t.resolve(tx());let o=iE,l=i;return a.next((c=>$t.forEach(c,((h,p)=>(o<p.largestBatchId&&(o=p.largestBatchId),i.get(h)?$t.resolve():this.remoteDocumentCache.getEntry(e,h).next((m=>{l=l.insert(h,m)}))))).next((()=>this.populateOverlays(e,c,i))).next((()=>this.computeViews(e,l,c,gr()))).next((h=>({batchId:o,changes:MY(h)})))))}))}getDocumentsMatchingDocumentQuery(e,n){return this.getDocument(e,new rs(n)).next((s=>{let r=iS();
2416return s.isFoundDocument()&&(r=r.insert(s.key,s)),r}))}getDocumentsMatchingCollectionGroupQuery(e,n,s,r){const i=n.collectionGroup;let a=iS();return this.indexManager.getCollectionParents(e,i).next((o=>$t.forEach(o,(l=>{const c=(function(p,m){return new iM(m,null,p.explicitOrderBy.slice(),p.filters.slice(),p.limit,p.limitType,p.startAt,p.endAt)})(n,l.child(i));return this.getDocumentsMatchingCollectionQuery(e,c,s,r).next((h=>{h.forEach(((p,m)=>{a=a.insert(p,m)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,n,s,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,n.path,s.largestBatchId).next((a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,n,s,i,r)))).next((a=>{i.forEach(((l,c)=>{const h=c.getKey();a.get(h)===null&&(a=a.insert(h,ko.newInvalidDocument(h)))}));let o=iS();return a.forEach(((l,c)=>{const h=i.get(l);h!==void 0&&LS(h.mutation,c,ku.empty(),Oi.now()),oM(n,c)&&(o=o.insert(l,c))})),o}))}}/**
2417 * @license
2418 * Copyright 2020 Google LLC
2419 *
2420 * Licensed under the Apache License, Version 2.0 (the "License");
2421 * you may not use this file except in compliance with the License.
2422 * You may obtain a copy of the License at
2423 *
2424 *   http://www.apache.org/licenses/LICENSE-2.0
2425 *
2426 * Unless required by applicable law or agreed to in writing, software
2427 * distributed under the License is distributed on an "AS IS" BASIS,
2428 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2429 * See the License for the specific language governing permissions and
2430 * limitations under the License.
2431 */class dye{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,n){return $t.resolve(this.Nr.get(n))}saveBundleMetadata(e,n){return this.Nr.set(n.id,(function(r){return{id:r.id,version:r.version,createTime:Iu(r.createTime)}})(n)),$t.resolve()}getNamedQuery(e,n){return $t.resolve(this.Br.get(n))}saveNamedQuery(e,n){return this.Br.set(n.name,(function(r){return{name:r.name,query:tye(r.bundledQuery),readTime:Iu(r.readTime)}})(n)),$t.resolve()}}/**
2432 * @license
2433 * Copyright 2022 Google LLC
2434 *
2435 * Licensed under the Apache License, Version 2.0 (the "License");
2436 * you may not use this file except in compliance with the License.
2437 * You may obtain a copy of the License at
2438 *
2439 *   http://www.apache.org/licenses/LICENSE-2.0
2440 *
2441 * Unless required by applicable law or agreed to in writing, software
2442 * distributed under the License is distributed on an "AS IS" BASIS,
2443 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2444 * See the License for the specific language governing permissions and
2445 * limitations under the License.
2446 */class hye{constructor(){this.overlays=new ta(rs.comparator),this.Lr=new Map}getOverlay(e,n){return $t.resolve(this.overlays.get(n))}getOverlays(e,n){const s=tx();return $t.forEach(n,(r=>this.getOverlay(e,r).next((i=>{i!==null&&s.set(r,i)})))).next((()=>s))}saveOverlays(e,n,s){return s.forEach(((r,i)=>{this.St(e,n,i)})),$t.resolve()}removeOverlaysForBatchId(e,n,s){const r=this.Lr.get(s);return r!==void 0&&(r.forEach((i=>this.overlays=this.overlays.remove(i))),this.Lr.delete(s)),$t.resolve()}getOverlaysForCollection(e,n,s){const r=tx(),i=n.length+1,a=new rs(n.child("")),o=this.overlays.getIteratorFrom(a);for(;o.hasNext();){const l=o.getNext().value,c=l.getKey();if(!n.isPrefixOf(c.path))break;c.path.length===i&&l.largestBatchId>s&&r.set(l.getKey(),l)}return $t.resolve(r)}getOverlaysForCollectionGroup(e,n,s,r){let i=new ta(((c,h)=>c-h));const a=this.overlays.getIterator();for(;a.hasNext();){const c=a.getNext().value;if(c.getKey().getCollectionGroup()===n&&c.largestBatchId>s){let h=i.get(c.largestBatchId);h===null&&(h=tx(),i=i.insert(c.largestBatchId,h)),h.set(c.getKey(),c)}}const o=tx(),l=i.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach(((c,h)=>o.set(c,h))),!(o.size()>=r)););return $t.resolve(o)}St(e,n,s){const r=this.overlays.get(s.key);if(r!==null){const a=this.Lr.get(r.largestBatchId).delete(s.key);this.Lr.set(r.largestBatchId,a)}this.overlays=this.overlays.insert(s.key,new M0e(n,s));let i=this.Lr.get(n);i===void 0&&(i=gr(),this.Lr.set(n,i)),this.Lr.set(n,i.add(s.key))}}/**
2447 * @license
2448 * Copyright 2024 Google LLC
2449 *
2450 * Licensed under the Apache License, Version 2.0 (the "License");
2451 * you may not use this file except in compliance with the License.
2452 * You may obtain a copy of the License at
2453 *
2454 *   http://www.apache.org/licenses/LICENSE-2.0
2455 *
2456 * Unless required by applicable law or agreed to in writing, software
2457 * distributed under the License is distributed on an "AS IS" BASIS,
2458 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2459 * See the License for the specific language governing permissions and
2460 * limitations under the License.
2461 */class fye{constructor(){this.sessionToken=Wo.EMPTY_BYTE_STRING}getSessionToken(e){return $t.resolve(this.sessionToken)}setSessionToken(e,n){return this.sessionToken=n,$t.resolve()}}/**
2462 * @license
2463 * Copyright 2017 Google LLC
2464 *
2465 * Licensed under the Apache License, Version 2.0 (the "License");
2466 * you may not use this file except in compliance with the License.
2467 * You may obtain a copy of the License at
2468 *
2469 *   http://www.apache.org/licenses/LICENSE-2.0
2470 *
2471 * Unless required by applicable law or agreed to in writing, software
2472 * distributed under the License is distributed on an "AS IS" BASIS,
2473 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2474 * See the License for the specific language governing permissions and
2475 * limitations under the License.
2476 */class EL{constructor(){this.kr=new oo(Co.qr),this.Kr=new oo(Co.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,n){const s=new Co(e,n);this.kr=this.kr.add(s),this.Kr=this.Kr.add(s)}$r(e,n){e.forEach((s=>this.addReference(s,n)))}removeReference(e,n){this.Wr(new Co(e,n))}Qr(e,n){e.forEach((s=>this.removeReference(s,n)))}Gr(e){const n=new rs(new Di([])),s=new Co(n,e),r=new Co(n,e+1),i=[];return this.Kr.forEachInRange([s,r],(a=>{this.Wr(a),i.push(a.key)})),i}zr(){this.kr.forEach((e=>this.Wr(e)))}Wr(e){this.kr=this.kr.delete(e),this.Kr=this.Kr.delete(e)}jr(e){const n=new rs(new Di([])),s=new Co(n,e),r=new Co(n,e+1);let i=gr();return this.Kr.forEachInRange([s,r],(a=>{i=i.add(a.key)})),i}containsKey(e){const n=new Co(e,0),s=this.kr.firstAfterOrEqual(n);return s!==null&&e.isEqual(s.key)}}class Co{constructor(e,n){this.key=e,this.Jr=n}static qr(e,n){return rs.comparator(e.key,n.key)||mr(e.Jr,n.Jr)}static Ur(e,n){return mr(e.Jr,n.Jr)||rs.comparator(e.key,n.key)}}/**
2477 * @license
2478 * Copyright 2017 Google LLC
2479 *
2480 * Licensed under the Apache License, Version 2.0 (the "License");
2481 * you may not use this file except in compliance with the License.
2482 * You may obtain a copy of the License at
2483 *
2484 *   http://www.apache.org/licenses/LICENSE-2.0
2485 *
2486 * Unless required by applicable law or agreed to in writing, software
2487 * distributed under the License is distributed on an "AS IS" BASIS,
2488 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2489 * See the License for the specific language governing permissions and
2490 * limitations under the License.
2491 */class pye{constructor(e,n){this.indexManager=e,this.referenceDelegate=n,this.mutationQueue=[],this.Yn=1,this.Hr=new oo(Co.qr)}checkEmpty(e){return $t.resolve(this.mutationQueue.length===0)}addMutationBatch(e,n,s,r){const i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new R0e(i,n,s,r);this.mutationQueue.push(a);for(const o of r)this.Hr=this.Hr.add(new Co(o.key,i)),this.indexManager.addToCollectionParentIndex(e,o.key.path.popLast());return $t.resolve(a)}lookupMutationBatch(e,n){return $t.resolve(this.Zr(n))}getNextMutationBatchAfterBatchId(e,n){const s=n+1,r=this.Xr(s),i=r<0?0:r;return $t.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return $t.resolve(this.mutationQueue.length===0?fL:this.Yn-1)}getAllMutationBatches(e){return $t.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,n){const s=new Co(n,0),r=new Co(n,Number.POSITIVE_INFINITY),i=[];return this.Hr.forEachInRange([s,r],(a=>{const o=this.Zr(a.Jr);i.push(o)})),$t.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,n){let s=new oo(mr);return n.forEach((r=>{const i=new Co(r,0),a=new Co(r,Number.POSITIVE_INFINITY);this.Hr.forEachInRange([i,a],(o=>{s=s.add(o.Jr)}))})),$t.resolve(this.Yr(s))}getAllMutationBatchesAffectingQuery(e,n){const s=n.path,r=s.length+1;let i=s;rs.isDocumentKey(i)||(i=i.child(""));const a=new Co(new rs(i),0);let o=new oo(mr);return this.Hr.forEachWhile((l=>{const c=l.key.path;return!!s.isPrefixOf(c)&&(c.length===r&&(o=o.add(l.Jr)),!0)}),a),$t.resolve(this.Yr(o))}Yr(e){const n=[];return e.forEach((s=>{const r=this.Zr(s);r!==null&&n.push(r)})),n}removeMutationBatch(e,n){Ar(this.ei(n.batchId,"removed")===0,55003),this.mutation
vendor: 14,100 bytes, lines 2491-2581
2491Queue.shift();let s=this.Hr;return $t.forEach(n.mutations,(r=>{const i=new Co(r.key,n.batchId);return s=s.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.Hr=s}))}nr(e){}containsKey(e,n){const s=new Co(n,0),r=this.Hr.firstAfterOrEqual(s);return $t.resolve(n.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,$t.resolve()}ei(e,n){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const n=this.Xr(e);return n<0||n>=this.mutationQueue.length?null:this.mutationQueue[n]}}/**
2492 * @license
2493 * Copyright 2017 Google LLC
2494 *
2495 * Licensed under the Apache License, Version 2.0 (the "License");
2496 * you may not use this file except in compliance with the License.
2497 * You may obtain a copy of the License at
2498 *
2499 *   http://www.apache.org/licenses/LICENSE-2.0
2500 *
2501 * Unless required by applicable law or agreed to in writing, software
2502 * distributed under the License is distributed on an "AS IS" BASIS,
2503 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2504 * See the License for the specific language governing permissions and
2505 * limitations under the License.
2506 */class mye{constructor(e){this.ti=e,this.docs=(function(){return new ta(rs.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,n){const s=n.key,r=this.docs.get(s),i=r?r.size:0,a=this.ti(n);return this.docs=this.docs.insert(s,{document:n.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,s.path.popLast())}removeEntry(e){const n=this.docs.get(e);n&&(this.docs=this.docs.remove(e),this.size-=n.size)}getEntry(e,n){const s=this.docs.get(n);return $t.resolve(s?s.document.mutableCopy():ko.newInvalidDocument(n))}getEntries(e,n){let s=Dm();return n.forEach((r=>{const i=this.docs.get(r);s=s.insert(r,i?i.document.mutableCopy():ko.newInvalidDocument(r))})),$t.resolve(s)}getDocumentsMatchingQuery(e,n,s,r){let i=Dm();const a=n.path,o=new rs(a.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(o);for(;l.hasNext();){const{key:c,value:{document:h}}=l.getNext();if(!a.isPrefixOf(c.path))break;c.path.length>a.length+1||Gge(zge(h),s)<=0||(r.has(h.key)||oM(n,h))&&(i=i.insert(h.key,h.mutableCopy()))}return $t.resolve(i)}getAllFromCollectionGroup(e,n,s,r){ss(9500)}ni(e,n){return $t.forEach(this.docs,(s=>n(s)))}newChangeBuffer(e){return new gye(this)}getSize(e){return $t.resolve(this.size)}}class gye extends lye{constructor(e){super(),this.Mr=e}applyChanges(e){const n=[];return this.changes.forEach(((s,r)=>{r.isValidDocument()?n.push(this.Mr.addEntry(e,r)):this.Mr.removeEntry(s)})),$t.waitFor(n)}getFromCache(e,n){return this.Mr.getEntry(e,n)}getAllFromCache(e,n){return this.Mr.getEntries(e,n)}}/**
2507 * @license
2508 * Copyright 2017 Google LLC
2509 *
2510 * Licensed under the Apache License, Version 2.0 (the "License");
2511 * you may not use this file except in compliance with the License.
2512 * You may obtain a copy of the License at
2513 *
2514 *   http://www.apache.org/licenses/LICENSE-2.0
2515 *
2516 * Unless required by applicable law or agreed to in writing, software
2517 * distributed under the License is distributed on an "AS IS" BASIS,
2518 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2519 * See the License for the specific language governing permissions and
2520 * limitations under the License.
2521 */class yye{constructor(e){this.persistence=e,this.ri=new Uv((n=>gL(n)),yL),this.lastRemoteSnapshotVersion=vs.min(),this.highestTargetId=0,this.ii=0,this.si=new EL,this.targetCount=0,this.oi=O1._r()}forEachTarget(e,n){return this.ri.forEach(((s,r)=>n(r))),$t.resolve()}getLastRemoteSnapshotVersion(e){return $t.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return $t.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),$t.resolve(this.highestTargetId)}setTargetsMetadata(e,n,s){return s&&(this.lastRemoteSnapshotVersion=s),n>this.ii&&(this.ii=n),$t.resolve()}lr(e){this.ri.set(e.target,e);const n=e.targetId;n>this.highestTargetId&&(this.oi=new O1(n),this.highestTargetId=n),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,n){return this.lr(n),this.targetCount+=1,$t.resolve()}updateTargetData(e,n){return this.lr(n),$t.resolve()}removeTargetData(e,n){return this.ri.delete(n.target),this.si.Gr(n.targetId),this.targetCount-=1,$t.resolve()}removeTargets(e,n,s){let r=0;const i=[];return this.ri.forEach(((a,o)=>{o.sequenceNumber<=n&&s.get(o.targetId)===null&&(this.ri.delete(a),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),$t.waitFor(i).next((()=>r))}getTargetCount(e){return $t.resolve(this.targetCount)}getTargetData(e,n){const s=this.ri.get(n)||null;return $t.resolve(s)}addMatchingKeys(e,n,s){return this.si.$r(n,s),$t.resolve()}removeMatchingKeys(e,n,s){this.si.Qr(n,s);const r=this.persistence.referenceDelegate,i=[];return r&&n.forEach((a=>{i.push(r.markPotentiallyOrphaned(e,a))})),$t.waitFor(i)}removeMatchingKeysForTargetId(e,n){return this.si.Gr(n),$t.resolve()}getMatchingKeysForTargetId(e,n){const s=this.si.jr(n);return $t.resolve(s)}containsKey(e,n){return $t.resolve(this.si.containsKey(n))}}/**
2522 * @license
2523 * Copyright 2017 Google LLC
2524 *
2525 * Licensed under the Apache License, Version 2.0 (the "License");
2526 * you may not use this file except in compliance with the License.
2527 * You may obtain a copy of the License at
2528 *
2529 *   http://www.apache.org/licenses/LICENSE-2.0
2530 *
2531 * Unless required by applicable law or agreed to in writing, software
2532 * distributed under the License is distributed on an "AS IS" BASIS,
2533 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2534 * See the License for the specific language governing permissions and
2535 * limitations under the License.
2536 */class sX{constructor(e,n){this._i={},this.overlays={},this.ai=new sM(0),this.ui=!1,this.ui=!0,this.ci=new fye,this.referenceDelegate=e(this),this.li=new yye(this),this.indexManager=new nye,this.remoteDocumentCache=(function(r){return new mye(r)})((s=>this.referenceDelegate.hi(s))),this.serializer=new eye(n),this.Pi=new dye(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let n=this.overlays[e.toKey()];return n||(n=new hye,this.overlays[e.toKey()]=n),n}getMutationQueue(e,n){let s=this._i[e.toKey()];return s||(s=new pye(n,this.referenceDelegate),this._i[e.toKey()]=s),s}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,n,s){xn("MemoryPersistence","Starting transaction:",e);const r=new xye(this.ai.next());return this.referenceDelegate.Ti(),s(r).next((i=>this.referenceDelegate.Ei(r).next((()=>i)))).toPromise().then((i=>(r.raiseOnCommittedEvent(),i)))}Ii(e,n){return $t.or(Object.values(this._i).map((s=>()=>s.containsKey(e,n))))}}class xye extends qge{constructor(e){super(),this.currentSequenceNumber=e}}class TL{constructor(e){this.persistence=e,this.Ri=new EL,this.Ai=null}static Vi(e){return new TL(e)}get di(){if(this.Ai)return this.Ai;throw ss(60996)}addReference(e,n,s){return this.Ri.addReference(s,n),this.di.delete(s.toString()),$t.resolve()}removeReference(e,n,s){return this.Ri.removeReference(s,n),this.di.add(s.toString()),$t.resolve()}markPotentiallyOrphaned(e,n){return this.di.add(n.toString()),$t.resolve()}removeTarget(e,n){this.Ri.Gr(n.targetId).forEach((r=>this.di.add(r.toString())));const s=this.persistence.getTargetCache();return s.getMatchingKeysForTargetId(e,n.targetId).next((r=>{r.forEach((i=>this.di.add(i.toString())))})).next((()=>s.removeTargetData(e,n)))}Ti(){this.Ai=new Set}Ei(e){const n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return $t.forEach(this.di,(s=>{const r=rs.fromPath(s);return this.mi(e,r).next((i=>{i||n.removeEntry(r,vs.min())}))})).next((()=>(this.Ai=null,n.apply(e))))}updateLimboDocument(e,n){return this.mi(e,n).next((s=>{s?this.di.delete(n.toString()):this.di.add(n.toString())}))}hi(e){return 0}mi(e,n){return $t.or([()=>$t.resolve(this.Ri.containsKey(n)),()=>this.persistence.getTargetCache().containsKey(e,n),()=>this.persistence.Ii(e,n)])}}class LN{constructor(e,n){this.persistence=e,this.fi=new Uv((s=>Yge(s.path)),((s,r)=>s.isEqual(r))),this.garbageCollector=oye(this,n)}static Vi(e,n){return new LN(e,n)}Ti(){}Ei(e){return $t.resolve()}forEachTarget(e,n){return this.persistence.getTargetCache().forEachTarget(e,n)}dr(e){const n=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next((s=>n.next((r=>s+r))))}pr(e){let n=0;return this.mr(e,(s=>{n++})).next((()=>n))}mr(e,n){return $t.forEach(this.fi,((s,r)=>this.wr(e,s,r).next((i=>i?$t.resolve():n(r)))))}removeTargets(e,n,s){return this.persistence.getTargetCache().removeTargets(e,n,s)}removeOrphanedDocuments(e,n){let s=0;const r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.ni(e,(a=>this.wr(e,a,n).next((o=>{o||(s++,i.removeEntry(a,vs.min()))})))).next((()=>i.apply(e))).next((()=>s))}markPotentiallyOrphaned(e,n){return this.fi.set(n,e.currentSequenceNumber),$t.resolve()}removeTarget(e,n){const s=n.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,s)}addReference(e,n,s){return this.fi.set(s,e.currentSequenceNumber),$t.resolve()}removeReference(e,n,s){return this.fi.set(s,e.currentSequenceNumber),$t.resolve()}updateLimboDocument(e,n){return this.fi.set(n,e.currentSequenceNumber),$t.resolve()}hi(e){let n=e.key.toString().length;return e.isFoundDocument()&&(n+=gI(e.data.value)),n}wr(e,n,s){return $t.or([()=>this.persistence.Ii(e,n),()=>this.persistence.getTargetCache().containsKey(e,n),()=>{const r=this.fi.get(n);return $t.resolve(r!==void 0&&r>s)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
2537 * @license
2538 * Copyright 2017 Google LLC
2539 *
2540 * Licensed under the Apache License, Version 2.0 (the "License");
2541 * you may not use this file except in compliance with the License.
2542 * You may obtain a copy of the License at
2543 *
2544 *   http://www.apache.org/licenses/LICENSE-2.0
2545 *
2546 * Unless required by applicable law or agreed to in writing, software
2547 * distributed under the License is distributed on an "AS IS" BASIS,
2548 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2549 * See the License for the specific language governing permissions and
2550 * limitations under the License.
2551 */class AL{constructor(e,n,s,r){this.targetId=e,this.fromCache=n,this.Ts=s,this.Es=r}static Is(e,n){let s=gr(),r=gr();for(const i of n.docChanges)switch(i.type){case 0:s=s.add(i.doc.key);break;case 1:r=r.add(i.doc.key)}return new AL(e,n.fromCache,s,r)}}/**
2552 * @license
2553 * Copyright 2023 Google LLC
2554 *
2555 * Licensed under the Apache License, Version 2.0 (the "License");
2556 * you may not use this file except in compliance with the License.
2557 * You may obtain a copy of the License at
2558 *
2559 *   http://www.apache.org/licenses/LICENSE-2.0
2560 *
2561 * Unless required by applicable law or agreed to in writing, software
2562 * distributed under the License is distributed on an "AS IS" BASIS,
2563 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2564 * See the License for the specific language governing permissions and
2565 * limitations under the License.
2566 */class vye{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
2567 * @license
2568 * Copyright 2019 Google LLC
2569 *
2570 * Licensed under the Apache License, Version 2.0 (the "License");
2571 * you may not use this file except in compliance with the License.
2572 * You may obtain a copy of the License at
2573 *
2574 *   http://www.apache.org/licenses/LICENSE-2.0
2575 *
2576 * Unless required by applicable law or agreed to in writing, software
2577 * distributed under the License is distributed on an "AS IS" BASIS,
2578 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2579 * See the License for the specific language governing permissions and
2580 * limitations under the License.
2581 */class bye{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(function(){return lfe()?8:Wge(bl())>0?6:4})()}initialize(e,n){this.fs=e,this.indexManager=n,this.Rs=!0}getDocumentsMatchingQuery(e,n,s,r){const i={result:null};return this.gs(e,n).next((a=>{i.result=a})).next((()=>{if(!i.result)return this.ps(e,n,r,s).next((a=>{i.result=a}))})).next((()=>{if(i.result)return;const a=new vye;return this.ys(e,n,a).next((o=>{if(i.result=o,this.As)return this.ws(e,n,a,o.size)}))})).next((()=>i.result))}ws(e,n,s,r){return s.documentReadCount<this.Vs?(Vb()<=pr.DEBUG&&xn("QueryEngine","SDK will not create cache indexes for query:",zb(n),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),$t.resolve()):(Vb()<=pr.DEBUG&&xn("QueryEngine","Query:",zb(n),"scans",s.documentReadCount,"local documents and returns",r,"documents as results."),s.documentReadCount>this.ds*r?(Vb()<=pr.DEBUG&&xn("QueryEngine","The SDK decides to create cache indexes for query:",zb(n),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,lp(n))):$t.resolve())}gs(e,n){if(qU(n))return $t.resolve(null);let s=lp(n);return this.indexManager.getIndexType(e,s).next((r=>r===0?null:(n.limit!==null&&r===1&&(n=q3(n,null,"F"),s=lp(n)),this.indexManager.getDocumentsMatchingTarget(e,s).next((i=>{const a=gr(...i);return this.fs.getDocuments(e,a).next((o=>this.indexManager.getMinOffset(e,s).next((l=>{const c=this.Ss(n,o);return this.bs(n,c,a,l.readTime)?this.gs(e,q3(n,null,"F")):this.Ds(e,c,n,l)}))))})))))}ps(e,n,s,r){return qU(n)||r.isEqual(vs.min())?$t.resolve(null):this.fs.getDocuments(e,s).next((i=>{const a=this.Ss(n,i);return this.bs(n,a,s,r)?$t.resolve(null):(Vb()<=pr.DEBUG&&xn("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),zb(n)),this.Ds(e,a,n,Vge(r,iE)).next((o=>o)))}))}Ss(e,n){let s=new oo(NY(e));
2581return n.forEach(((r,i)=>{oM(e,i)&&(s=s.add(i))})),s}bs(e,n,s,r){if(e.limit===null)return!1;if(s.size!==n.size)return!0;const i=e.limitType==="F"?n.last():n.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}ys(e,n,s){return Vb()<=pr.DEBUG&&xn("QueryEngine","Using full collection scan to execute query:",zb(n)),this.fs.getDocumentsMatchingQuery(e,n,D0.min(),s)}Ds(e,n,s,r){return this.fs.getDocumentsMatchingQuery(e,s,r).next((i=>(n.forEach((a=>{i=i.insert(a.key,a)})),i)))}}/**
2582 * @license
2583 * Copyright 2020 Google LLC
2584 *
2585 * Licensed under the Apache License, Version 2.0 (the "License");
2586 * you may not use this file except in compliance with the License.
2587 * You may obtain a copy of the License at
2588 *
2589 *   http://www.apache.org/licenses/LICENSE-2.0
2590 *
2591 * Unless required by applicable law or agreed to in writing, software
2592 * distributed under the License is distributed on an "AS IS" BASIS,
2593 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2594 * See the License for the specific language governing permissions and
2595 * limitations under the License.
2596 */const CL="LocalStore",wye=3e8;class _ye{constructor(e,n,s,r){this.persistence=e,this.Cs=n,this.serializer=r,this.vs=new ta(mr),this.Fs=new Uv((i=>gL(i)),yL),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(s)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new uye(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(n=>e.collect(n,this.vs)))}}function Sye(t,e,n,s){return new _ye(t,e,n,s)}async function rX(t,e){const n=Ns(t);return await n.persistence.runTransaction("Handle user change","readonly",(s=>{let r;
2596return n.mutationQueue.getAllMutationBatches(s).next((i=>(r=i,n.Os(e),n.mutationQueue.getAllMutationBatches(s)))).next((i=>{const a=[],o=[];let l=gr();for(const c of r){a.push(c.batchId);for(const h of c.mutations)l=l.add(h.key)}for(const c of i){o.push(c.batchId);for(const h of c.mutations)l=l.add(h.key)}return n.localDocuments.getDocuments(s,l).next((c=>({Ns:c,removedBatchIds:a,addedBatchIds:o})))}))}))}function Eye(t,e){const n=Ns(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(s=>{const r=e.batch.keys(),i=n.xs.newChangeBuffer({trackRemovals:!0});return(function(o,l,c,h){const p=c.batch,m=p.keys();let y=$t.resolve();return m.forEach((v=>{y=y.next((()=>h.getEntry(l,v))).next((b=>{const S=c.docVersions.get(v);Ar(S!==null,48541),b.version.compareTo(S)<0&&(p.applyToRemoteDocument(b,c),b.isValidDocument()&&(b.setReadTime(c.commitVersion),h.addEntry(b)))}))})),y.next((()=>o.mutationQueue.removeMutationBatch(l,p)))})(n,s,e,i).next((()=>i.apply(s))).next((()=>n.mutationQueue.performConsistencyCheck(s))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(s,r,e.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(s,(function(o){let l=gr();for(let c=0;c<o.mutationResults.length;++c)o.mutationResults[c].transformResults.length>0&&(l=l.add(o.batch.mutations[c].key));return l})(e)))).next((()=>n.localDocuments.getDocuments(s,r)))}))}function iX(t){const e=Ns(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(n=>e.li.getLastRemoteSnapshotVersion(n)))}function Tye(t,e){const n=Ns(t),s=e.snapshotVersion;let r=n.vs;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(i=>{const a=n.xs.newChangeBuffer({trackRemovals:!0});r=n.vs;const o=[];
2596e.targetChanges.forEach(((h,p)=>{const m=r.get(p);if(!m)return;o.push(n.li.removeMatchingKeys(i,h.removedDocuments,p).next((()=>n.li.addMatchingKeys(i,h.addedDocuments,p))));let y=m.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(p)!==null?y=y.withResumeToken(Wo.EMPTY_BYTE_STRING,vs.min()).withLastLimboFreeSnapshotVersion(vs.min()):h.resumeToken.approximateByteSize()>0&&(y=y.withResumeToken(h.resumeToken,s)),r=r.insert(p,y),(function(b,S,E){return b.resumeToken.approximateByteSize()===0||S.snapshotVersion.toMicroseconds()-b.snapshotVersion.toMicroseconds()>=wye?!0:E.addedDocuments.size+E.modifiedDocuments.size+E.removedDocuments.size>0})(m,y,h)&&o.push(n.li.updateTargetData(i,y))}));let l=Dm(),c=gr();if(e.documentUpdates.forEach((h=>{e.resolvedLimboDocuments.has(h)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(i,h))})),o.push(Aye(i,a,e.documentUpdates).next((h=>{l=h.Bs,c=h.Ls}))),!s.isEqual(vs.min())){const h=n.li.getLastRemoteSnapshotVersion(i).next((p=>n.li.setTargetsMetadata(i,i.currentSequenceNumber,s)));o.push(h)}return $t.waitFor(o).next((()=>a.apply(i))).next((()=>n.localDocuments.getLocalViewOfDocuments(i,l,c))).next((()=>l))})).then((i=>(n.vs=r,i)))}function Aye(t,e,n){let s=gr(),r=gr();return n.forEach((i=>s=s.add(i))),e.getEntries(t,s).next((i=>{let a=Dm();return n.forEach(((o,l)=>{const c=i.get(o);l.isFoundDocument()!==c.isFoundDocument()&&(r=r.add(o)),l.isNoDocument()&&l.version.isEqual(vs.min())?(e.removeEntry(o,l.readTime),a=a.insert(o,l)):!c.isValidDocument()||l.version.compareTo(c.version)>0||l.version.compareTo(c.version)===0&&c.hasPendingWrites?(e.addEntry(l),a=a.insert(o,l)):xn(CL,"Ignoring outdated watch update for ",o,". Current version:",c.version," Watch version:",l.version)})),{Bs:a,Ls:r}}))}function Cye(t,e){const n=Ns(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(s=>(e===void 0&&(e=fL),n.mutationQueue.getNextMutationBatchAfterBatchId(s,e))))}function kye(t,e){const n=Ns(t);return n.persistence.runTransaction("Allocate target","readwrite",(s=>{let r;return n.li.getTargetData(s,e).next((i=>i?(r=i,$t.resolve(r)):n.li.allocateTargetId(s).next((a=>(r=new _0(e,a,"TargetPurposeListen",s.currentSequenceNumber),n.li.addTargetData(s,r).next((()=>r)))))))})).then((s=>{const r=n.vs.get(s.targetId);return(r===null||s.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.vs=n.vs.insert(s.targetId,s),n.Fs.set(e,s.targetId)),s}))}async function X3(t,e,n){const s=Ns(t),r=s.vs.get(e),i=n?"readwrite":"readwrite-primary";try{n||await s.persistence.runTransaction("Release target",i,(a=>s.persistence.referenceDelegate.removeTarget(a,r)))}catch(a){if(!Z1(a))throw a;xn(CL,`Failed to update sequence numbers for target ${e}: ${a}`)}s.vs=s.vs.remove(e),s.Fs.delete(r.target)}function iF(t,e,n){const s=Ns(t);let r=vs.min(),i=gr();return s.persistence.runTransaction("Execute query","readwrite",(a=>(function(l,c,h){const p=Ns(l),m=p.Fs.get(h);return m!==void 0?$t.resolve(p.vs.get(m)):p.li.getTargetData(c,h)})(s,a,lp(e)).next((o=>{if(o)return r=o.lastLimboFreeSnapshotVersion,s.li.getMatchingKeysForTargetId(a,o.targetId).next((l=>{i=l}))})).next((()=>s.Cs.getDocumentsMatchingQuery(a,e,n?r:vs.min(),n?i:gr()))).next((o=>(Iye(s,y0e(e),o),{documents:o,ks:i})))))}function Iye(t,e,n){let s=t.Ms.get(e)||vs.min();n.forEach(((r,i)=>{i.readTime.compareTo(s)>0&&(s=i.readTime)})),t.Ms.set(e,s)}class aF{constructor(){this.activeTargetIds=S0e()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class Nye{constructor(){this.vo=new aF,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,n,s){}addLocalQueryTarget(e,n=!0){return n&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,n,s){this.Fo[e]=n}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new aF,Promise.resolve()}handleUserChange(e,n,s){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
2597 * @license
2598 * Copyright 2019 Google LLC
2599 *
2600 * Licensed under the Apache License, Version 2.0 (the "License");
2601 * you may not use this file except in compliance with the License.
2602 * You may obtain a copy of the License at
2603 *
2604 *   http://www.apache.org/licenses/LICENSE-2.0
2605 *
2606 * Unless required by applicable law or agreed to in writing, software
2607 * distributed under the License is distributed on an "AS IS" BASIS,
2608 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2609 * See the License for the specific language governing permissions and
2610 * limitations under the License.
2611 */class Rye{Mo(e){}shutdown(){}}/**
2612 * @license
2613 * Copyright 2019 Google LLC
2614 *
2615 * Licensed under the Apache License, Version 2.0 (the "License");
2616 * you may not use this file except in compliance with the License.
2617 * You may obtain a copy of the License at
2618 *
2619 *   http://www.apache.org/licenses/LICENSE-2.0
2620 *
2621 * Unless required by applicable law or agreed to in writing, software
2622 * distributed under the License is distributed on an "AS IS" BASIS,
2623 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2624 * See the License for the specific language governing permissions and
2625 * limitations under the License.
2626 */const oF="ConnectivityMonitor";class lF{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){xn(oF,"Network connectivity changed: AVAILABLE");for(const e of this.Lo)e(0)}Bo(){xn(oF,"Network connectivity changed: UNAVAILABLE");for(const e of this.Lo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
2627 * @license
2628 * Copyright 2023 Google LLC
2629 *
2630 * Licensed under the Apache License, Version 2.0 (the "License");
2631 * you may not use this file except in compliance with the License.
2632 * You may obtain a copy of the License at
2633 *
2634 *   http://www.apache.org/licenses/LICENSE-2.0
2635 *
2636 * Unless required by applicable law or agreed to in writing, software
2637 * distributed under the License is distributed on an "AS IS" BASIS,
2638 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2639 * See the License for the specific language governing permissions and
2640 * limitations under the License.
2641 */let Rk=null;function J3(){return Rk===null?Rk=(function(){return 268435456+Math.round(2147483648*Math.random())})():Rk++,"0x"+Rk.toString(16)}/**
2642 * @license
2643 * Copyright 2020 Google LLC
2644 *
2645 * Licensed under the Apache License, Version 2.0 (the "License");
2646 * you may not use this file except in compliance with the License.
2647 * You may obtain a copy of the License at
2648 *
2649 *   http://www.apache.org/licenses/LICENSE-2.0
2650 *
2651 * Unless required by applicable law or agreed to in writing, software
2652 * distributed under the License is distributed on an "AS IS" BASIS,
2653 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2654 * See the License for the specific language governing permissions and
2655 * limitations under the License.
2656 */const C4="RestConnection",Mye={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class Pye{get qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const n=e.ssl?"https":"http",s=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Ko=n+"://"+e.host,this.Uo=`projects/${s}/databases/${r}`,this.$o=this.databaseId.database===IN?`project_id=${s}`:`project_id=${s}&database_id=${r}`}Wo(e,n,s,r,i){const a=J3(),o=this.Qo(e,n.toUriEncodedString());xn(C4,`Sending RPC '${e}' ${a}:`,o,s);const l={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(l,r,i);const{host:c}=new URL(o),h=dA(c);return this.zo(e,o,l,s,h).then((p=>(xn(C4,`Received RPC '${e}' ${a}: `,p),p)),(p=>{throw M1(C4,`RPC '${e}' ${a} failed with error: `,p,"url: ",o,"request:",s),p}))}jo(e,n,s,r,i,a){return this.Wo(e,n,s,r,i)}Go(e,n,s){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+J1})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEac
vendor: 4,220 bytes, lines 2656-2686
2656h(((r,i)=>e[i]=r)),s&&s.headers.forEach(((r,i)=>e[i]=r))}Qo(e,n){const s=Mye[e];let r=`${this.Ko}/v1/${n}:${s}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}}/**
2657 * @license
2658 * Copyright 2017 Google LLC
2659 *
2660 * Licensed under the Apache License, Version 2.0 (the "License");
2661 * you may not use this file except in compliance with the License.
2662 * You may obtain a copy of the License at
2663 *
2664 *   http://www.apache.org/licenses/LICENSE-2.0
2665 *
2666 * Unless required by applicable law or agreed to in writing, software
2667 * distributed under the License is distributed on an "AS IS" BASIS,
2668 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2669 * See the License for the specific language governing permissions and
2670 * limitations under the License.
2671 */class $ye{constructor(e){this.Jo=e.Jo,this.Ho=e.Ho}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Ho()}send(e){this.Jo(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}/**
2672 * @license
2673 * Copyright 2017 Google LLC
2674 *
2675 * Licensed under the Apache License, Version 2.0 (the "License");
2676 * you may not use this file except in compliance with the License.
2677 * You may obtain a copy of the License at
2678 *
2679 *   http://www.apache.org/licenses/LICENSE-2.0
2680 *
2681 * Unless required by applicable law or agreed to in writing, software
2682 * distributed under the License is distributed on an "AS IS" BASIS,
2683 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2684 * See the License for the specific language governing permissions and
2685 * limitations under the License.
2686 */const al="WebChannelConnection",P2=(t,e,n)=>{t.listen(e,(s=>{try{n(s)}catch(r){setTimeout((()=>{throw r}),0)}}))};class mw extends Pye{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){if(!mw.c_){const e=cY();P2(e,lY.STAT_EVENT,(n=>{n.stat===U3.PROXY?xn(al,"STAT_EVENT: detected buffering proxy"):n.stat===U3.NOPROXY&&xn(al,"STAT_EVENT: detected no buffering proxy")})),mw.c_=!0}}zo(e,n,s,r,i){const a=J3();return new Promise(((o,l)=>{const c=new aY;c.setWithCredentials(!0),c.listenOnce(oY.COMPLETE,(()=>{try{switch(c.getLastErrorCode()){case mI.NO_ERROR:const p=c.getResponseJson();xn(al,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(p)),o(p);break;case mI.TIMEOUT:xn(al,`RPC '${e}' ${a} timed out`),l(new Cn(Ot.DEADLINE_EXCEEDED,"Request time out"));break;case mI.HTTP_ERROR:const m=c.getStatus();if(xn(al,`RPC '${e}' ${a} failed with status:`,m,"response text:",c.getResponseText()),m>0){let y=c.getResponseJson();Array.isArray(y)&&(y=y[0]);const v=y==null?void 0:y.error;if(v&&v.status&&v.message){const b=(function(E){const I=E.toLowerCase().replace(/_/g,"-");return Object.values(Ot).indexOf(I)>=0?I:Ot.UNKNOWN})(v.status);l(new Cn(b,v.message))}else l(new Cn(Ot.UNKNOWN,"Server responded with status "+c.getStatus()))}else l(new Cn(Ot.UNAVAILABLE,"Connection failed."));break;default:ss(9055,{l_:e,streamId:a,h_:c.getLastErrorCode(),P_:c.getLastError()})}}finally{xn(al,`RPC '${e}' ${a} completed.`)}}));const h=JSON.stringify(r);xn(al,`RPC '${e}' ${a} sending request:`,r),c.send(n,"POST",h,s,15)}))}T_(e,n,s){const r=J3(),i=[this.Ko,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},l=this.longPollingOptions.timeoutSeconds;l!==void 0&&(o.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(o.useFetchStreams=!0),this.Go(o.initMessageHeaders,n,s),o.encodeInitMessageHeaders=!0;const c=i.join("");xn(al,`Creating RPC '${e}' stream ${r}: ${c}`,o);const h=a.createWebChannel(c,o);this.E_(h);let p=!1,m=!1;const y=new $ye({Jo:v=>{m?xn(al,`Not sending because RPC '${e}' stream ${r}
2686 is closed:`,v):(p||(xn(al,`Opening RPC '${e}' stream ${r} transport.`),h.open(),p=!0),xn(al,`RPC '${e}' stream ${r} sending:`,v),h.send(v))},Ho:()=>h.close()});return P2(h,rS.EventType.OPEN,(()=>{m||(xn(al,`RPC '${e}' stream ${r} transport opened.`),y.i_())})),P2(h,rS.EventType.CLOSE,(()=>{m||(m=!0,xn(al,`RPC '${e}' stream ${r} transport closed`),y.o_(),this.I_(h))})),P2(h,rS.EventType.ERROR,(v=>{m||(m=!0,M1(al,`RPC '${e}' stream ${r} transport errored. Name:`,v.name,"Message:",v.message),y.o_(new Cn(Ot.UNAVAILABLE,"The operation could not be completed")))})),P2(h,rS.EventType.MESSAGE,(v=>{var b;if(!m){const S=v.data[0];Ar(!!S,16349);const E=S,I=(E==null?void 0:E.error)||((b=E[0])==null?void 0:b.error);if(I){xn(al,`RPC '${e}' stream ${r} received error:`,I);const M=I.status;let j=(function(D){const R=$a[D];if(R!==void 0)return zY(R)})(M),L=I.message;M==="NOT_FOUND"&&L.includes("database")&&L.includes("does not exist")&&L.includes(this.databaseId.database)&&M1(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),j===void 0&&(j=Ot.INTERNAL,L="Unknown error status: "+M+" with message "+I.message),m=!0,y.o_(new Cn(j,L)),h.close()}else xn(al,`RPC '${e}' stream ${r} received:`,S),y.__(S)}})),mw.u_(),setTimeout((()=>{y.s_()}),0),y}terminate(){this.a_.forEach((e=>e.close())),this.a_=[]}E_(e){this.a_.push(e)}I_(e){this.a_=this.a_.filter((n=>n===e))}Go(e,n,s){super.Go(e,n,s),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return uY()}}/**
2687 * @license
2688 * Copyright 2020 Google LLC
2689 *
2690 * Licensed under the Apache License, Version 2.0 (the "License");
2691 * you may not use this file except in compliance with the License.
2692 * You may obtain a copy of the License at
2693 *
2694 *   http://www.apache.org/licenses/LICENSE-2.0
2695 *
2696 * Unless required by applicable law or agreed to in writing, software
2697 * distributed under the License is distributed on an "AS IS" BASIS,
2698 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2699 * See the License for the specific language governing permissions and
2700 * limitations under the License.
2701 */function Dye(t){return new mw(t)}function k4(){return typeof document<"u"?document:null}/**
2702 * @license
2703 * Copyright 2020 Google LLC
2704 *
2705 * Licensed under the Apache License, Version 2.0 (the "License");
2706 * you may not use this file except in compliance with the License.
2707 * You may obtain a copy of the License at
2708 *
2709 *   http://www.apache.org/licenses/LICENSE-2.0
2710 *
2711 * Unless required by applicable law or agreed to in writing, software
2712 * distributed under the License is distributed on an "AS IS" BASIS,
2713 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2714 * See the License for the specific language governing permissions and
2715 * limitations under the License.
2716 */function dM(t){return new U0e(t,!0)}/**
2717 * @license
2718 * Copyright 2017 Google LLC
2719 *
2720 * Licensed under the Apache License, Version 2.0 (the "License");
2721 * you may not use this file except in compliance with the License.
2722 * You may obtain a copy of the License at
2723 *
2724 *   http://www.apache.org/licenses/LICENSE-2.0
2725 *
2726 * Unless required by applicable law or agreed to in writing, software
2727 * distributed under the License is distributed on an "AS IS" BASIS,
2728 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2729 * See the License for the specific language governing permissions and
2730 * limitations under the License.
2731 */mw.c_=!1;class kL{constructor(e,n,s=1e3,r=1.5,i=6e4){this.Ci=e,this.timerId=n,this.R_=s,this.A_=r,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();const n=Math.floor(this.d_+this.y_()),s=Math.max(0,Date.now()-this.f_),r=Math.max(0,n-s);r>0&&xn("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.d_} ms, delay with jitter: ${n} ms, last attempt: ${s} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,r,(()=>(this.f_=Date.now(),e()))),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}/**
2732 * @license
2733 * Copyright 2017 Google LLC
2734 *
2735 * Licensed under the Apache License, Version 2.0 (the "License");
2736 * you may not use this file except in compliance with the License.
2737 * You may obtain a copy of the License at
2738 *
2739 *   http://www.apache.org/licenses/LICENSE-2.0
2740 *
2741 * Unless required by applicable law or agreed to in writing, software
2742 * distributed under the License is distributed on an "AS IS" BASIS,
2743 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2744 * See the License for the specific language governing permissions and
2745 * limitations under the License.
2746 */const cF="PersistentStream";class aX{constructor(e,n,s,r,i,a,o,l){this.Ci=e,this.S_=s,this.b_=r,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=o,this.listener=l,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new kL(e,n)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.S_,6e4,(()=>this.k_())))}q_(e){this.K_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}K_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,n){this.K_(),this.U_(),this.M_.cancel(),this.D_++,e!==4?this.M_.reset():n&&n.code===Ot.RESOURCE_EXHAUSTED?($m(n.toString()),$m("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):n&&n.code===Ot.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(n)}W_(){}auth(){this.state=1;const e=this.Q_(this.D_),n=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([s,r])=>{this.D_===n&&this.G_(s,r)}),(s=>{e((()=>{const r=new Cn(Ot.UNKNOWN,"Fetching auth token failed: "+s.message);return this.z_(r)}))}))}G_(e,n){const s=this.Q_(this.D_);this.stream=this.j_(e,n),this.stream.Zo((()=>{s((()=>this.listener.Zo()))})),this.stream.Yo((()=>{s((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.b_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((r=>{s((()=>this.z_(r)))})),this.stream.onMessage((r=>{s((()=>++this.F_==1?this.J_(r):this.onNext(r)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(e){return xn(cF,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return n=>{this.Ci.enqueueAndForget((()=>this.D_===e?n():(xn(cF,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Oye extends aX{constructor(e,n,s,r,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,s,r,a),this.serializer=i}j_(e,n){return this.connection.T_("Listen",e,n)}J_(e){return this.onNext(e)}onNext(e){this.M_.reset();const n=G0e(this.serializer,e),s=(function(i){if(!("targetChange"in i))return vs.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?vs.min():a.readTime?Iu(a.readTime):vs.min()})(e);return this.listener.H_(n,s)}Z_(e){const n={};n.database=Y3(this.serializer),n.addTarget=(function(i,a){let o;const l=a.target;if(o=H3(l)?{documents:q0e(i,l)}:{query:W0e(i,l).ft},o.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){o.resumeToken=qY(i,a.resumeToken);const c=W3(i,a.expectedCount);c!==null&&(o.expectedCount=c)}else if(a.snapshotVersion.compareTo(vs.min())>0){o.readTime=DN(i,a.snapshotVersion.toTimestamp());const c=W3(i,a.expectedCount);c!==null&&(o.expectedCount=c)}return o})(this.serializer,e);const s=Y0e(this.serializer,e);s&&(n.labels=s),this.q_(n)}X_(e){const n={};n.database=Y3(this.serializer),n.removeTarget=e,this.q_(n)}}class Lye extends aX{constructor(e,n,s,r,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,s,r,a),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,n){return this.connection.T_("Write",e,n)}J_(e){return Ar(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,Ar(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){Ar(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const n=H0e(e.writeResults,e.commitTime),s=Iu(e.commitTime);
2746return this.listener.na(s,n)}ra(){const e={};e.database=Y3(this.serializer),this.q_(e)}ea(e){const n={streamToken:this.lastStreamToken,writes:e.map((s=>XY(this.serializer,s)))};this.q_(n)}}/**
2747 * @license
2748 * Copyright 2017 Google LLC
2749 *
2750 * Licensed under the Apache License, Version 2.0 (the "License");
2751 * you may not use this file except in compliance with the License.
2752 * You may obtain a copy of the License at
2753 *
2754 *   http://www.apache.org/licenses/LICENSE-2.0
2755 *
2756 * Unless required by applicable law or agreed to in writing, software
2757 * distributed under the License is distributed on an "AS IS" BASIS,
2758 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2759 * See the License for the specific language governing permissions and
2760 * limitations under the License.
2761 */class jye{}class Bye extends jye{constructor(e,n,s,r){super(),this.authCredentials=e,this.appCheckCredentials=n,this.connection=s,this.serializer=r,this.ia=!1}sa(){if(this.ia)throw new Cn(Ot.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,n,s,r){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Wo(e,K3(n,s),r,i,a))).catch((i=>{throw i.name==="FirebaseError"?(i.code===Ot.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new Cn(Ot.UNKNOWN,i.toString())}))}jo(e,n,s,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.jo(e,K3(n,s),r,a,o,i))).catch((a=>{throw a.name==="FirebaseError"?(a.code===Ot.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new Cn(Ot.UNKNOWN,a.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}}function Uye(t,e,n,s){return new Bye(t,e,n,s)}class Fye{constructor(e,n){this.asyncQueue=e,this.onlineStateHandler=n,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve()))))}ha(e){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,e==="Online"&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){const n=`Could not reach Cloud Firestore backend. ${e}
2762This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?($m(n),this.aa=!1):xn("OnlineStateTracker",n)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}/**
2763 * @license
2764 * Copyright 2017 Google LLC
2765 *
2766 * Licensed under the Apache License, Version 2.0 (the "License");
2767 * you may not use this file except in compliance with the License.
2768 * You may obtain a copy of the License at
2769 *
2770 *   http://www.apache.org/licenses/LICENSE-2.0
2771 *
2772 * Unless required by applicable law or agreed to in writing, software
2773 * distributed under the License is distributed on an "AS IS" BASIS,
2774 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2775 * See the License for the specific language governing permissions and
2776 * limitations under the License.
2777 */const Ev="RemoteStore";class Vye{constructor(e,n,s,r,i){this.localStore=e,this.datastore=n,this.asyncQueue=s,this.remoteSyncer={},this.Ta=[],this.Ea=new Map,this.Ia=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo((a=>{s.enqueueAndForget((async()=>{Fv(this)&&(xn(Ev,"Restarting streams for network reachability change."),await(async function(l){const c=Ns(l);c.Ia.add(4),await vA(c),c.Va.set("Unknown"),c.Ia.delete(4),await hM(c)})(this))}))})),this.Va=new Fye(s,r)}}async function hM(t){if(Fv(t))for(const e of t.Ra)await e(!0)}async function vA(t){for(const e of t.Ra)await e(!1)}function oX(t,e){const n=Ns(t);n.Ea.has(e.targetId)||(n.Ea.set(e.targetId,e),ML(n)?RL(n):e_(n).O_()&&NL(n,e))}function IL(t,e){const n=Ns(t),s=e_(n);n.Ea.delete(e),s.O_()&&lX(n,e),n.Ea.size===0&&(s.O_()?s.L_():Fv(n)&&n.Va.set("Unknown"))}function NL(t,e){if(t.da.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(vs.min())>0){const n=t.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(n)}e_(t).Z_(e)}function lX(t,e){t.da.$e(e),e_(t).X_(e)}function RL(t){t.da=new O0e({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),At:e=>t.Ea.get(e)||null,ht:()=>t.datastore.serializer.databaseId}),e_(t).start(),t.Va.ua()}function ML(t){return Fv(t)&&!e_(t).x_()&&t.Ea.size>0}function Fv(t){return Ns(t).Ia.size===0}function cX(t){t.da=void 0}async function zye(t){t.Va.set("Online")}
2777async function Gye(t){t.Ea.forEach(((e,n)=>{NL(t,e)}))}async function Hye(t,e){cX(t),ML(t)?(t.Va.ha(e),RL(t)):t.Va.set("Unknown")}async function qye(t,e,n){if(t.Va.set("Online"),e instanceof HY&&e.state===2&&e.cause)try{await(async function(r,i){const a=i.cause;for(const o of i.targetIds)r.Ea.has(o)&&(await r.remoteSyncer.rejectListen(o,a),r.Ea.delete(o),r.da.removeTarget(o))})(t,e)}catch(s){xn(Ev,"Failed to remove targets %s: %s ",e.targetIds.join(","),s),await jN(t,s)}else if(e instanceof vI?t.da.Xe(e):e instanceof GY?t.da.st(e):t.da.tt(e),!n.isEqual(vs.min()))try{const s=await iX(t.localStore);n.compareTo(s)>=0&&await(function(i,a){const o=i.da.Tt(a);return o.targetChanges.forEach(((l,c)=>{if(l.resumeToken.approximateByteSize()>0){const h=i.Ea.get(c);h&&i.Ea.set(c,h.withResumeToken(l.resumeToken,a))}})),o.targetMismatches.forEach(((l,c)=>{const h=i.Ea.get(l);if(!h)return;i.Ea.set(l,h.withResumeToken(Wo.EMPTY_BYTE_STRING,h.snapshotVersion)),lX(i,l);const p=new _0(h.target,l,c,h.sequenceNumber);NL(i,p)})),i.remoteSyncer.applyRemoteEvent(o)})(t,n)}catch(s){xn(Ev,"Failed to raise snapshot:",s),await jN(t,s)}}async function jN(t,e,n){if(!Z1(e))throw e;t.Ia.add(1),await vA(t),t.Va.set("Offline"),n||(n=()=>iX(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{xn(Ev,"Retrying IndexedDB access"),await n(),t.Ia.delete(1),await hM(t)}))}function uX(t,e){return e().catch((n=>jN(t,n,e)))}async function fM(t){const e=Ns(t),n=B0(e);let s=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:fL;for(;Wye(e);)try{const r=await Cye(e.localStore,s);if(r===null){e.Ta.length===0&&n.L_();break}s=r.batchId,Kye(e,r)}catch(r){await jN(e,r)}dX(e)&&hX(e)}function Wye(t){return Fv(t)&&t.Ta.length<10}function Kye(t,e){t.Ta.push(e);const n=B0(t);n.O_()&&n.Y_&&n.ea(e.mutations)}function dX(t){return Fv(t)&&!B0(t).x_()&&t.Ta.length>0}function hX(t){B0(t).start()}async function Yye(t){B0(t).ra()}async function Xye(t){const e=B0(t);for(const n of t.Ta)e.ea(n.mutations)}async function Jye(t,e,n){const s=t.Ta.shift(),r=wL.from(s,e,n);await uX(t,(()=>t.remoteSyncer.applySuccessfulWrite(r))),await fM(t)}async function Qye(t,e){e&&B0(t).Y_&&await(async function(s,r){if((function(a){return VY(a)&&a!==Ot.ABORTED})(r.code)){const i=s.Ta.shift();B0(s).B_(),await uX(s,(()=>s.remoteSyncer.rejectFailedWrite(i.batchId,r))),await fM(s)}})(t,e),dX(t)&&hX(t)}async function uF(t,e){const n=Ns(t);n.asyncQueue.verifyOperationInProgress(),xn(Ev,"RemoteStore received new credentials");const s=Fv(n);n.Ia.add(3),await vA(n),s&&n.Va.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n.Ia.delete(3),await hM(n)}async function Zye(t,e){const n=Ns(t);e?(n.Ia.delete(2),await hM(n)):e||(n.Ia.add(2),await vA(n),n.Va.set("Unknown"))}function e_(t){return t.ma||(t.ma=(function(n,s,r){const i=Ns(n);return i.sa(),new Oye(s,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,r)})(t.datastore,t.asyncQueue,{Zo:zye.bind(null,t),Yo:Gye.bind(null,t),t_:Hye.bind(null,t),H_:qye.bind(null,t)}),t.Ra.push((async e=>{e?(t.ma.B_(),ML(t)?RL(t):t.Va.set("Unknown")):(await t.ma.stop(),cX(t))}))),t.ma}function B0(t){return t.fa||(t.fa=(function(n,s,r){const i=Ns(n);return i.sa(),new Lye(s,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,r)})(t.datastore,t.asyncQueue,{Zo:()=>Promise.resolve(),Yo:Yye.bind(null,t),t_:Qye.bind(null,t),ta:Xye.bind(null,t),na:Jye.bind(null,t)}),t.Ra.push((async e=>{e?(t.fa.B_(),await fM(t)):(await t.fa.stop(),t.Ta.length>0&&(xn(Ev,`Stopping write stream with ${t.Ta.length} pending writes`),t.Ta=[]))}))),t.fa}/**
2778 * @license
2779 * Copyright 2017 Google LLC
2780 *
2781 * Licensed under the Apache License, Version 2.0 (the "License");
2782 * you may not use this file except in compliance with the License.
2783 * You may obtain a copy of the License at
2784 *
2785 *   http://www.apache.org/licenses/LICENSE-2.0
2786 *
2787 * Unless required by applicable law or agreed to in writing, software
2788 * distributed under the License is distributed on an "AS IS" BASIS,
2789 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2790 * See the License for the specific language governing permissions and
2791 * limitations under the License.
2792 */class PL{constructor(e,n,s,r,i){this.asyncQueue=e,this.timerId=n,this.targetTimeMs=s,this.op=r,this.removalCallback=i,this.deferred=new Im,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((a=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,n,s,r,i){const a=Date.now()+s,o=new PL(e,n,a,r,i);return o.start(s),o}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new Cn(Ot.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((e=>
2792this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function $L(t,e){if($m("AsyncQueue",`${e}: ${t}`),Z1(t))return new Cn(Ot.UNAVAILABLE,`${e}: ${t}`);throw t}/**
2793 * @license
2794 * Copyright 2017 Google LLC
2795 *
2796 * Licensed under the Apache License, Version 2.0 (the "License");
2797 * you may not use this file except in compliance with the License.
2798 * You may obtain a copy of the License at
2799 *
2800 *   http://www.apache.org/licenses/LICENSE-2.0
2801 *
2802 * Unless required by applicable law or agreed to in writing, software
2803 * distributed under the License is distributed on an "AS IS" BASIS,
2804 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2805 * See the License for the specific language governing permissions and
2806 * limitations under the License.
2807 */class gw{static emptySet(e){return new gw(e.comparator)}constructor(e){this.comparator=e?(n,s)=>e(n,s)||rs.comparator(n.key,s.key):(n,s)=>rs.comparator(n.key,s.key),this.keyedMap=iS(),this.sortedSet=new ta(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const n=this.keyedMap.get(e);return n?this.sortedSet.indexOf(n):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((n,s)=>(e(n),!1)))}add(e){const n=this.delete(e.key);return n.copy(n.keyedMap.insert(e.key,e),n.sortedSet.insert(e,null))}delete(e){const n=this.get(e);return n?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(n)):this}isEqual(e){if(!(e instanceof gw)||this.size!==e.size)return!1;const n=this.sortedSet.getIterator(),s=e.sortedSet.getIterator();for(;n.hasNext();){const r=n.getNext().key,i=s.getNext().key;if(!r.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach((n=>{e.push(n.toString())})),e.length===0?"DocumentSet ()":`DocumentSet (
2808  `+e.join(`  
2809`)+`
2810)`}copy(e,n){const s=new gw;return s.comparator=this.comparator,s.keyedMap=e,s.sortedSet=n,s}}/**
2811 * @license
2812 * Copyright 2017 Google LLC
2813 *
2814 * Licensed under the Apache License, Version 2.0 (the "License");
2815 * you may not use this file except in compliance with the License.
2816 * You may obtain a copy of the License at
2817 *
2818 *   http://www.apache.org/licenses/LICENSE-2.0
2819 *
2820 * Unless required by applicable law or agreed to in writing, software
2821 * distributed under the License is distributed on an "AS IS" BASIS,
2822 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2823 * See the License for the specific language governing permissions and
2824 * limitations under the License.
2825 */class dF{constructor(){this.ga=new ta(rs.comparator)}track(e){const n=e.doc.key,s=this.ga.get(n);s?e.type!==0&&s.type===3?this.ga=this.ga.insert(n,e):e.type===3&&s.type!==1?this.ga=this.ga.insert(n,{type:s.type,doc:e.doc}):e.type===2&&s.type===2?this.ga=this.ga.insert(n,{type:2,doc:e.doc}):e.type===2&&s.type===0?this.ga=this.ga.insert(n,{type:0,doc:e.doc}):e.type===1&&s.type===0?this.ga=this.ga.remove(n):e.type===1&&s.type===2?this.ga=this.ga.insert(n,{type:1,doc:s.doc}):e.type===0&&s.type===1?this.ga=this.ga.insert(n,{type:2,doc:e.doc}):ss(63341,{Vt:e,pa:s}):this.ga=this.ga.insert(n,e)}ya(){const e=[];return this.ga.inorderTraversal(((n,s)=>{e.push(s)})),e}}class L1{constructor(e,n,s,r,i,a,o,l,c){this.query=e,this.docs=n,this.oldDocs=s,this.docChanges=r,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=o,this.excludesMetadataChanges=l,this.hasCachedResults=c}static fromInitialDocuments(e,n,s,r,i){const a=[];return n.forEach((o=>{a.push({type:0,doc:o})})),new L1(e,n,gw.emptySet(n),a,s,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&aM(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const n=this.docChanges,s=e.docChanges;if(n.length!==s.length)return!1;for(let r=0;r<n.length;r++)if(n[r].type!==s[r].type||!n[r].doc.isEqual(s[r].doc))return!1;return!0}}/**
2826 * @license
2827 * Copyright 2017 Google LLC
2828 *
2829 * Licensed under the Apache License, Version 2.0 (the "License");
2830 * you may not use this file except in compliance with the License.
2831 * You may obtain a copy of the License at
2832 *
2833 *   http://www.apache.org/licenses/LICENSE-2.0
2834 *
2835 * Unless required by applicable law or agreed to in writing, software
2836 * distributed under the License is distributed on an "AS IS" BASIS,
2837 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2838 * See the License for the specific language governing permissions and
2839 * limitations under the License.
2840 */class exe{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some((e=>e.Da()))}}class txe{constructor(){this.queries=hF(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(n,s){const r=Ns(n),i=r.queries;r.queries=hF(),i.forEach(((a,o)=>{for(const l of o.Sa)l.onError(s)}))})(this,new Cn(Ot.ABORTED,"Firestore shutting down"))}}function hF(){return new Uv((t=>IY(t)),aM)}async function nxe(t,e){const n=Ns(t);let s=3;const r=e.query;let i=n.queries.get(r);i?!i.ba()&&e.Da()&&(s=2):(i=new exe,s=e.Da()?0:1);try{switch(s){case 0:i.wa=await n.onListen(r,!0);break;case 1:i.wa=await n.onListen(r,!1);break;case 2:await n.onFirstRemoteStoreListen(r)}}catch(a){const o=$L(a,`Initialization of query '${zb(e.query)}' failed`);return void e.onError(o)}n.queries.set(r,i),i.Sa.push(e),e.va(n.onlineState),i.wa&&e.Fa(i.wa)&&DL(n)}async function sxe(t,e){const n=Ns(t),s=e.query;let r=3;const i=n.queries.get(s);if(i){const a=i.Sa.indexOf(e);a>=0&&(i.Sa.splice(a,1),i.Sa.length===0?r=e.Da()?0:1:!i.ba()&&e.Da()&&(r=2))}switch(r){case 0:return n.queries.delete(s),n.onUnlisten(s,!0);case 1:return n.queries.delete(s),n.onUnlisten(s,!1);case 2:return n.onLastRemoteStoreUnlisten(s);default:return}}function rxe(t,e){const n=Ns(t);let s=!1;for(const r of e){const i=r.query,a=n.queries.get(i);if(a){for(const o of a.Sa)o.Fa(r)&&(s=!0);a.wa=r}}s&&DL(n)}function ixe(t,e,n){const s=Ns(t),r=s.queries.get(e);if(r)for(const i of r.Sa)i.onError(n);s.queries.delete(e)}function DL(t){t.Ca.forEach((e=>{e.next()}))}var Q3,fF;(fF=Q3||(Q3={})).Ma="default",fF.Cache="cache";class axe{constructor(e,n,s){this.query=e,this.xa=n,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=s||{}}Fa(e){if(!this.options.includeMetadataChanges){const s=[];for(const r of e.docChanges)r.type!==3&&s.push(r);e=new L1(e.query,e.docs,e.oldDocs,s,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let n=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),n=!0):this.La(e,this.onlineState)&&(this.ka(e),n=!0),this.Na=e,n}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let n=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),n=!0),n}La(e,n){if(!e.fromCache||!this.Da())return!0;const s=n!=="Offline";return(!this.options.qa||!s)&&(!e.docs.isEmpty()||e.hasCachedResults||n==="Offline")}Ba(e){if(e.docChanges.length>0)return!0;const n=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0}ka(e){e=L1.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==Q3.Cache}}/**
2841 * @license
2842 * Copyright 2017 Google LLC
2843 *
2844 * Licensed under the Apache License, Version 2.0 (the "License");
2845 * you may not use this file except in compliance with the License.
2846 * You may obtain a copy of the License at
2847 *
2848 *   http://www.apache.org/licenses/LICENSE-2.0
2849 *
2850 * Unless required by applicable law or agreed to in writing, software
2851 * distributed under the License is distributed on an "AS IS" BASIS,
2852 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2853 * See the License for the specific language governing permissions and
2854 * limitations under the License.
2855 */class fX{constructor(e){this.key=e}}class pX{constructor(e){this.key=e}}class oxe{constructor(e,n){this.query=e,this.Za=n,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=gr(),this.mutatedKeys=gr(),this.eu=NY(e),this.tu=new gw(this.eu)}get nu(){return this.Za}ru(e,n){const s=n?n.iu:new dF,r=n?n.tu:this.tu;let i=n?n.mutatedKeys:this.mutatedKeys,a=r,o=!1;const l=this.query.limitType==="F"&&r.size===this.query.limit?r.last():null,c=this.query.limitType==="L"&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((h,p)=>{const m=r.get(h),y=oM(this.query,p)?p:null,v=!!m&&this.mutatedKeys.has(m.ke
2855y),b=!!y&&(y.hasLocalMutations||this.mutatedKeys.has(y.key)&&y.hasCommittedMutations);let S=!1;m&&y?m.data.isEqual(y.data)?v!==b&&(s.track({type:3,doc:y}),S=!0):this.su(m,y)||(s.track({type:2,doc:y}),S=!0,(l&&this.eu(y,l)>0||c&&this.eu(y,c)<0)&&(o=!0)):!m&&y?(s.track({type:0,doc:y}),S=!0):m&&!y&&(s.track({type:1,doc:m}),S=!0,(l||c)&&(o=!0)),S&&(y?(a=a.add(y),i=b?i.add(h):i.delete(h)):(a=a.delete(h),i=i.delete(h)))})),this.query.limit!==null)for(;a.size>this.query.limit;){const h=this.query.limitType==="F"?a.last():a.first();a=a.delete(h.key),i=i.delete(h.key),s.track({type:1,doc:h})}return{tu:a,iu:s,bs:o,mutatedKeys:i}}su(e,n){return e.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations}applyChanges(e,n,s,r){const i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const a=e.iu.ya();a.sort(((h,p)=>(function(y,v){const b=S=>{switch(S){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ss(20277,{Vt:S})}};return b(y)-b(v)})(h.type,p.type)||this.eu(h.doc,p.doc))),this.ou(s),r=r??!1;const o=n&&!r?this._u():[],l=this.Ya.size===0&&this.current&&!r?1:0,c=l!==this.Xa;return this.Xa=l,a.length!==0||c?{snapshot:new L1(this.query,e.tu,i,a,e.mutatedKeys,l===0,c,!1,!!s&&s.resumeToken.approximateByteSize()>0),au:o}:{au:o}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new dF,mutatedKeys:this.mutatedKeys,bs:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((n=>this.Za=this.Za.add(n))),e.modifiedDocuments.forEach((n=>{})),e.removedDocuments.forEach((n=>this.Za=this.Za.delete(n))),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Ya;this.Ya=gr(),this.tu.forEach((s=>{this.uu(s.key)&&(this.Ya=this.Ya.add(s.key))}));const n=[];return e.forEach((s=>{this.Ya.has(s)||n.push(new pX(s))})),this.Ya.forEach((s=>{e.has(s)||n.push(new fX(s))})),n}cu(e){this.Za=e.ks,this.Ya=gr();const n=this.ru(e.documents);return this.applyChanges(n,!0)}lu(){return L1.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const OL="SyncEngine";class lxe{constructor(e,n,s){this.query=e,this.targetId=n,this.view=s}}class cxe{constructor(e){this.key=e,this.hu=!1}}class uxe{constructor(e,n,s,r,i,a){this.localStore=e,this.remoteStore=n,this.eventManager=s,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new Uv((o=>IY(o)),aM),this.Eu=new Map,this.Iu=new Set,this.Ru=new ta(rs.comparator),this.Au=new Map,this.Vu=new EL,this.du={},this.mu=new Map,this.fu=O1.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function dxe(t,e,n=!0){const s=bX(t);let r;const i=s.Tu.get(e);return i?(s.sharedClientState.addLocalQueryTarget(i.targetId),r=i.view.lu()):r=await mX(s,e,n,!0),r}async function hxe(t,e){const n=bX(t);await mX(n,e,!0,!1)}async function mX(t,e,n,s){const r=await kye(t.localStore,lp(e)),i=r.targetId,a=t.sharedClientState.addLocalQueryTarget(i,n);let o;return s&&(o=await fxe(t,e,i,a==="current",r.resumeToken)),t.isPrimaryClient&&n&&oX(t.remoteStore,r),o}async function fxe(t,e,n,s,r){t.pu=(p,m,y)=>(async function(b,S,E,I){let M=S.view.ru(E);M.bs&&(M=await iF(b.localStore,S.query,!1).then((({documents:D})=>S.view.ru(D,M))));const j=I&&I.targetChanges.get(S.targetId),L=I&&I.targetMismatches.get(S.targetId)!=null,K=S.view.applyChanges(M,b.isPrimaryClient,j,L);return mF(b,S.targetId,K.au),K.snapshot})(t,p,m,y);const i=await iF(t.localStore,e,!0),a=new oxe(e,i.ks),o=a.ru(i.documents),l=xA.createSynthesizedTargetChangeForCurrentChange(n,s&&t.onlineState!=="Offline",r),c=a.applyChanges(o,t.isPrimaryClient,l);mF(t,n,c.au);const h=new lxe(e,n,a);return t.Tu.set(e,h),t.Eu.has(n)?t.Eu.get(n).push(e):t.Eu.set(n,[e]),c.snapshot}async function pxe(t,e,n){const s=Ns(t),r=s.Tu.get(e),i=s.Eu.get(r.targetId);if(i.length>1)return s.Eu.set(r.targetId,i.filter((a=>!aM(a,e)))),void s.Tu.delete(e);s.isPrimaryClient?(s.sharedClientState.removeLocalQueryTarget(r.targetId),s.sharedClientState.isActiveQueryTarget(r.targetId)||await X3(s.localStore,r.targetId,!1).then((()=>
2855{s.sharedClientState.clearQueryState(r.targetId),n&&IL(s.remoteStore,r.targetId),Z3(s,r.targetId)})).catch(Q1)):(Z3(s,r.targetId),await X3(s.localStore,r.targetId,!0))}async function mxe(t,e){const n=Ns(t),s=n.Tu.get(e),r=n.Eu.get(s.targetId);n.isPrimaryClient&&r.length===1&&(n.sharedClientState.removeLocalQueryTarget(s.targetId),IL(n.remoteStore,s.targetId))}async function gxe(t,e,n){const s=Sxe(t);try{const r=await(function(a,o){const l=Ns(a),c=Oi.now(),h=o.reduce(((y,v)=>y.add(v.key)),gr());let p,m;return l.persistence.runTransaction("Locally write mutations","readwrite",(y=>{let v=Dm(),b=gr();return l.xs.getEntries(y,h).next((S=>{v=S,v.forEach(((E,I)=>{I.isValidDocument()||(b=b.add(E))}))})).next((()=>l.localDocuments.getOverlayedDocuments(y,v))).next((S=>{p=S;const E=[];for(const I of o){const M=N0e(I,p.get(I.key).overlayedDocument);M!=null&&E.push(new J0(I.key,M,_Y(M.value.mapValue),Ql.exists(!0)))}return l.mutationQueue.addMutationBatch(y,c,E,o)})).next((S=>{m=S;const E=S.applyToLocalDocumentSet(p,b);return l.documentOverlayCache.saveOverlays(y,S.batchId,E)}))})).then((()=>({batchId:m.batchId,changes:MY(p)})))})(s.localStore,e);s.sharedClientState.addPendingMutation(r.batchId),(function(a,o,l){let c=a.du[a.currentUser.toKey()];c||(c=new ta(mr)),c=c.insert(o,l),a.du[a.currentUser.toKey()]=c})(s,r.batchId,n),await bA(s,r.changes),await fM(s.remoteStore)}catch(r){const i=$L(r,"Failed to persist write");n.reject(i)}}async function gX(t,e){const n=Ns(t);try{const s=await Tye(n.localStore,e);
2855e.targetChanges.forEach(((r,i)=>{const a=n.Au.get(i);a&&(Ar(r.addedDocuments.size+r.modifiedDocuments.size+r.removedDocuments.size<=1,22616),r.addedDocuments.size>0?a.hu=!0:r.modifiedDocuments.size>0?Ar(a.hu,14607):r.removedDocuments.size>0&&(Ar(a.hu,42227),a.hu=!1))})),await bA(n,s,e)}catch(s){await Q1(s)}}function pF(t,e,n){const s=Ns(t);if(s.isPrimaryClient&&n===0||!s.isPrimaryClient&&n===1){const r=[];s.Tu.forEach(((i,a)=>{const o=a.view.va(e);o.snapshot&&r.push(o.snapshot)})),(function(a,o){const l=Ns(a);l.onlineState=o;let c=!1;l.queries.forEach(((h,p)=>{for(const m of p.Sa)m.va(o)&&(c=!0)})),c&&DL(l)})(s.eventManager,e),r.length&&s.Pu.H_(r),s.onlineState=e,s.isPrimaryClient&&s.sharedClientState.setOnlineState(e)}}async function yxe(t,e,n){const s=Ns(t);s.sharedClientState.updateQueryState(e,"rejected",n);const r=s.Au.get(e),i=r&&r.key;if(i){let a=new ta(rs.comparator);a=a.insert(i,ko.newNoDocument(i,vs.min()));const o=gr().add(i),l=new uM(vs.min(),new Map,new ta(mr),a,o);await gX(s,l),s.Ru=s.Ru.remove(i),s.Au.delete(e),LL(s)}else await X3(s.localStore,e,!1).then((()=>Z3(s,e,n))).catch(Q1)}async function xxe(t,e){const n=Ns(t),s=e.batch.batchId;try{const r=await Eye(n.localStore,e);xX(n,s,null),yX(n,s),n.sharedClientState.updateMutationState(s,"acknowledged"),await bA(n,r)}catch(r){await Q1(r)}}async function vxe(t,e,n){const s=Ns(t);try{const r=await(function(a,o){const l=Ns(a);return l.persistence.runTransaction("Reject batch","readwrite-primary",(c=>{let h;return l.mutationQueue.lookupMutationBatch(c,o).next((p=>(Ar(p!==null,37113),h=p.keys(),l.mutationQueue.removeMutationBatch(c,p)))).next((()=>l.mutationQueue.performConsistencyCheck(c))).next((()=>l.documentOverlayCache.removeOverlaysForBatchId(c,h,o))).next((()=>l.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(c,h))).next((()=>l.localDocuments.getDocuments(c,h)))}))})(s.localStore,e);xX(s,e,n),yX(s,e),s.sharedClientState.updateMutationState(e,"rejected",n),await bA(s,r)}catch(r){await Q1(r)}}function yX(t,e){(t.mu.get(e)||[]).forEach((n=>{n.resolve()})),t.mu.delete(e)}function xX(t,e,n){const s=Ns(t);let r=s.du[s.currentUser.toKey()];if(r){const i=r.get(e);i&&(n?i.reject(n):i.resolve(),r=r.remove(e)),s.du[s.currentUser.toKey()]=r}}
vendor: 4,327 bytes, line 2855
2855function Z3(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const s of t.Eu.get(e))t.Tu.delete(s),n&&t.Pu.yu(s,n);t.Eu.delete(e),t.isPrimaryClient&&t.Vu.Gr(e).forEach((s=>{t.Vu.containsKey(s)||vX(t,s)}))}function vX(t,e){t.Iu.delete(e.path.canonicalString());const n=t.Ru.get(e);n!==null&&(IL(t.remoteStore,n),t.Ru=t.Ru.remove(e),t.Au.delete(n),LL(t))}function mF(t,e,n){for(const s of n)s instanceof fX?(t.Vu.addReference(s.key,e),bxe(t,s)):s instanceof pX?(xn(OL,"Document no longer in limbo: "+s.key),t.Vu.removeReference(s.key,e),t.Vu.containsKey(s.key)||vX(t,s.key)):ss(19791,{wu:s})}function bxe(t,e){const n=e.key,s=n.path.canonicalString();t.Ru.get(n)||t.Iu.has(s)||(xn(OL,"New document in limbo: "+n),t.Iu.add(s),LL(t))}function LL(t){for(;t.Iu.size>0&&t.Ru.size<t.maxConcurrentLimboResolutions;){const e=t.Iu.values().next().value;t.Iu.delete(e);const n=new rs(Di.fromString(e)),s=t.fu.next();t.Au.set(s,new cxe(n)),t.Ru=t.Ru.insert(n,s),oX(t.remoteStore,new _0(lp(xL(n.path)),s,"TargetPurposeLimboResolution",sM.ce))}}async function bA(t,e,n){const s=Ns(t),r=[],i=[],a=[];s.Tu.isEmpty()||(s.Tu.forEach(((o,l)=>{a.push(s.pu(l,e,n).then((c=>{var h;if((c||n)&&s.isPrimaryClient){const p=c?!c.fromCache:(h=n==null?void 0:n.targetChanges.get(l.targetId))==null?void 0:h.current;s.sharedClientState.updateQueryState(l.targetId,p?"current":"not-current")}if(c){r.push(c);const p=AL.Is(l.targetId,c);i.push(p)}})))})),await Promise.all(a),s.Pu.H_(r),await(async function(l,c){const h=Ns(l);try{await h.persistence.runTransaction("notifyLocalViewChanges","readwrite",(p=>$t.forEach(c,(m=>$t.forEach(m.Ts,(y=>h.persistence.referenceDelegate.addReference(p,m.targetId,y))).next((()=>$t.forEach(m.Es,(y=>h.persistence.referenceDelegate.removeReference(p,m.targetId,y)))))))))}catch(p){if(!Z1(p))throw p;xn(CL,"Failed to update sequence numbers: "+p)}for(const p of c){const m=p.targetId;if(!p.fromCache){const y=h.vs.get(m),v=y.snapshotVersion,b=y.withLastLimboFreeSnapshotVersion(v);h.vs=h.vs.insert(m,b)}}})(s.localStore,i))}async function wxe(t,e){const n=Ns(t);if(!n.currentUser.isEqual(e)){xn(OL,"User change. New user:",e.toKey());const s=await rX(n.localStore,e);n.currentUser=e,(function(i,a){i.mu.forEach((o=>{o.forEach((l=>{l.reject(new Cn(Ot.CANCELLED,a))}))})),i.mu.clear()})(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(e,s.removedBatchIds,s.addedBatchIds),await bA(n,s.Ns)}}function _xe(t,e){const n=Ns(t),s=n.Au.get(e);if(s&&s.hu)return gr().add(s.key);{let r=gr();const i=n.Eu.get(e);if(!i)return r;for(const a of i){const o=n.Tu.get(a);r=r.unionWith(o.view.nu)}return r}}function bX(t){const e=Ns(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=gX.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=_xe.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=yxe.bind(null,e),e.Pu.H_=rxe.bind(null,e.eventManager),e.Pu.yu=ixe.bind(null,e.eventManager),e}function Sxe(t){const e=Ns(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=xxe.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=vxe.bind(null,e),e}class BN{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=dM(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,n){return null}Mu(e,n){return null}vu(e){return Sye(this.persistence,new bye,e.initialUser,this.serializer)}Cu(e){return new sX(TL.Vi,this.serializer)}Du(e){return new Nye}async terminate(){var e,n;(e=this.gcScheduler)==null||e.stop(),(n=this.indexBackfillerScheduler)==null||n.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}BN.provider={build:()=>new BN};class Exe extends BN{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,n){Ar(this.persistence.referenceDelegate instanceof LN,46915);const s=this.persistence.referenceDelegate.garbageCollector;return new iye(s,e.asyncQueue,n)}Cu(e){const n=this.cacheSizeBytes!==void 0?jc.withCacheSize(this.cacheSizeBytes):jc.DEFAULT;return new sX((s=>LN.Vi(s,n)),this.serializer)}}class eD{async initialize(e,n){this.localStore||(this.localStore=e.localStore,this.sharedCl
2855ientState=e.sharedClientState,this.datastore=this.createDatastore(n),this.remoteStore=this.createRemoteStore(n),this.eventManager=this.createEventManager(n),this.syncEngine=this.createSyncEngine(n,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=s=>pF(this.syncEngine,s,1),this.remoteStore.remoteSyncer.handleCredentialChange=wxe.bind(null,this.syncEngine),await Zye(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new txe})()}createDatastore(e){const n=dM(e.databaseInfo.databaseId),s=Dye(e.databaseInfo);return Uye(e.authCredentials,e.appCheckCredentials,s,n)}createRemoteStore(e){return(function(s,r,i,a,o){return new Vye(s,r,i,a,o)})(this.localStore,this.datastore,e.asyncQueue,(n=>pF(this.syncEngine,n,0)),(function(){return lF.v()?new lF:new Rye})())}createSyncEngine(e,n){return(function(r,i,a,o,l,c,h){const p=new uxe(r,i,a,o,l,c);return h&&(p.gu=!0),p})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,n)}async terminate(){var e,n;await(async function(r){const i=Ns(r);xn(Ev,"RemoteStore shutting down."),i.Ia.add(5),await vA(i),i.Aa.shutdown(),i.Va.set("Unknown")})(this.remoteStore),(e=this.datastore)==null||e.terminate(),(n=this.eventManager)==null||n.terminate()}}eD.provider={build:()=>new eD};/**
2856 * @license
2857 * Copyright 2020 Google LLC
2858 *
2859 * Licensed under the Apache License, Version 2.0 (the "License");
2860 * you may not use this file except in compliance with the License.
2861 * You may obtain a copy of the License at
2862 *
2863 *   http://www.apache.org/licenses/LICENSE-2.0
2864 *
2865 * Unless required by applicable law or agreed to in writing, software
2866 * distributed under the License is distributed on an "AS IS" BASIS,
2867 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2868 * See the License for the specific language governing permissions and
2869 * limitations under the License.
2870 *//**
2871 * @license
2872 * Copyright 2017 Google LLC
2873 *
2874 * Licensed under the Apache License, Version 2.0 (the "License");
2875 * you may not use this file except in compliance with the License.
2876 * You may obtain a copy of the License at
2877 *
2878 *   http://www.apache.org/licenses/LICENSE-2.0
2879 *
2880 * Unless required by applicable law or agreed to in writing, software
2881 * distributed under the License is distributed on an "AS IS" BASIS,
2882 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2883 * See the License for the specific language governing permissions and
2884 * limitations under the License.
2885 */class Txe{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):$m("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,n){setTimeout((()=>{this.muted||e(n)}),0)}}/**
2886 * @license
2887 * Copyright 2017 Google LLC
2888 *
2889 * Licensed under the Apache License, Version 2.0 (the "License");
2890 * you may not use this file except in compliance with the License.
2891 * You may obtain a copy of the License at
2892 *
2893 *   http://www.apache.org/licenses/LICENSE-2.0
2894 *
2895 * Unless required by applicable law or agreed to in writing, software
2896 * distributed under the License is distributed on an "AS IS" BASIS,
2897 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2898 * See the License for the specific language governing permissions and
2899 * limitations under the License.
2900 */let Axe=class{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new Cn(Ot.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const n=await(async function(r,i){const a=Ns(r),o={documents:i.map((p=>ON(a.serializer,p)))},l=await a.jo("BatchGetDocuments",a.serializer.databaseId,Di.emptyPath(),o,i.length),c=new Map;l.forEach((p=>{const m=z0e(a.serializer,p);c.set(m.key.toString(),m)}));const h=[];
vendor: 6,344 bytes, lines 2900-2930
2900return i.forEach((p=>{const m=c.get(p.toString());Ar(!!m,55234,{key:p}),h.push(m)})),h})(this.datastore,e);return n.forEach((s=>this.recordVersion(s))),n}set(e,n){this.write(n.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,n){try{this.write(n.toMutation(e,this.preconditionForUpdate(e)))}catch(s){this.lastTransactionError=s}this.writtenDocs.add(e.toString())}delete(e){this.write(new bL(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const e=this.readVersions;this.mutations.forEach((n=>{e.delete(n.key.toString())})),e.forEach(((n,s)=>{const r=rs.fromPath(s);this.mutations.push(new FY(r,this.precondition(r)))})),await(async function(s,r){const i=Ns(s),a={writes:r.map((o=>XY(i.serializer,o)))};await i.Wo("Commit",i.serializer.databaseId,Di.emptyPath(),a)})(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let n;if(e.isFoundDocument())n=e.version;else{if(!e.isNoDocument())throw ss(50498,{Gu:e.constructor.name});n=vs.min()}const s=this.readVersions.get(e.key.toString());if(s){if(!n.isEqual(s))throw new Cn(Ot.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),n)}precondition(e){const n=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&n?n.isEqual(vs.min())?Ql.exists(!1):Ql.updateTime(n):Ql.none()}preconditionForUpdate(e){const n=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&n){if(n.isEqual(vs.min()))throw new Cn(Ot.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ql.updateTime(n)}return Ql.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}};/**
2901 * @license
2902 * Copyright 2019 Google LLC
2903 *
2904 * Licensed under the Apache License, Version 2.0 (the "License");
2905 * you may not use this file except in compliance with the License.
2906 * You may obtain a copy of the License at
2907 *
2908 *   http://www.apache.org/licenses/LICENSE-2.0
2909 *
2910 * Unless required by applicable law or agreed to in writing, software
2911 * distributed under the License is distributed on an "AS IS" BASIS,
2912 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2913 * See the License for the specific language governing permissions and
2914 * limitations under the License.
2915 */class Cxe{constructor(e,n,s,r,i){this.asyncQueue=e,this.datastore=n,this.options=s,this.updateFunction=r,this.deferred=i,this.zu=s.maxAttempts,this.M_=new kL(this.asyncQueue,"transaction_retry")}ju(){this.zu-=1,this.Ju()}Ju(){this.M_.p_((async()=>{const e=new Axe(this.datastore),n=this.Hu(e);n&&n.then((s=>{this.asyncQueue.enqueueAndForget((()=>e.commit().then((()=>{this.deferred.resolve(s)})).catch((r=>{this.Zu(r)}))))})).catch((s=>{this.Zu(s)}))}))}Hu(e){try{const n=this.updateFunction(e);return!gA(n)&&n.catch&&n.then?n:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(n){return this.deferred.reject(n),null}}Zu(e){this.zu>0&&this.Xu(e)?(this.zu-=1,this.asyncQueue.enqueueAndForget((()=>(this.Ju(),Promise.resolve())))):this.deferred.reject(e)}Xu(e){if((e==null?void 0:e.name)==="FirebaseError"){const n=e.code;return n==="aborted"||n==="failed-precondition"||n==="already-exists"||!VY(n)}return!1}}/**
2916 * @license
2917 * Copyright 2017 Google LLC
2918 *
2919 * Licensed under the Apache License, Version 2.0 (the "License");
2920 * you may not use this file except in compliance with the License.
2921 * You may obtain a copy of the License at
2922 *
2923 *   http://www.apache.org/licenses/LICENSE-2.0
2924 *
2925 * Unless required by applicable law or agreed to in writing, software
2926 * distributed under the License is distributed on an "AS IS" BASIS,
2927 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2928 * See the License for the specific language governing permissions and
2929 * limitations under the License.
2930 */const U0="FirestoreClient";class kxe{constructor(e,n,s,r,i){this.authCredentials=e,this.appCheckCredentials=n,this.asyncQueue=s,this._databaseInfo=r,this.user=Lc.UNAUTHENTICATED,this.clientId=dL.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(s,(async a=>{xn(U0,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a})),this.appCheckCredentials.start(s,(a=>(xn(U0,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new Im;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(n){const s=$L(n,"Failed to shutdown persistence");e.reject(s)}})),e.promise}}async function I4(t,e){t.asyncQueue.verifyOperationInProgress(),xn(U0,"Initializing OfflineComponentProvider");const n=t.configuration;await e.initialize(n);let s=n.initialUser;t.setCredentialChangeListener((async r=>{s.isEqual(r)||(await rX(e.localStore,r),s=r)})),e.persistence.setDatabaseDeletedListener((()=>t.terminate())),t._offlineComponents=e}async function gF(t,e){t.asyncQueue.verifyOperationInProgress();const n=await Ixe(t);xn(U0,"Initializing OnlineComponentProvider"),await e.initialize(n,t.configuration),t.setCredentialChangeListener((s=>uF(e.remoteStore,s))),t.setAppCheckTokenChangeListener(((s,r)=>uF(e.remoteStore,r))),t._onlineComponents=e}async function Ixe(t){if(!t._offlineComponents)if(t._uninitializedComponentsProvider){xn(U0,"Using user provided OfflineComponentProvider");try{await I4(t,t._uninitializedComponentsProvider._offline)}catch(e){const n=e;if(!(function(r){return r.name==="FirebaseError"?r.code===Ot.FAILED_PRECONDITION||r.code===Ot.UNIMPLEMENT
2930ED:!(typeof DOMException<"u"&&r instanceof DOMException)||r.code===22||r.code===20||r.code===11})(n))throw n;M1("Error using user provided cache. Falling back to memory cache: "+n),await I4(t,new BN)}}else xn(U0,"Using default OfflineComponentProvider"),await I4(t,new Exe(void 0));return t._offlineComponents}async function jL(t){return t._onlineComponents||(t._uninitializedComponentsProvider?(xn(U0,"Using user provided OnlineComponentProvider"),await gF(t,t._uninitializedComponentsProvider._online)):(xn(U0,"Using default OnlineComponentProvider"),await gF(t,new eD))),t._onlineComponents}function Nxe(t){return jL(t).then((e=>e.syncEngine))}function Rxe(t){return jL(t).then((e=>e.datastore))}async function Mxe(t){const e=await jL(t),n=e.eventManager;return n.onListen=dxe.bind(null,e.syncEngine),n.onUnlisten=pxe.bind(null,e.syncEngine),n.onFirstRemoteStoreListen=hxe.bind(null,e.syncEngine),n.onLastRemoteStoreUnlisten=mxe.bind(null,e.syncEngine),n}function Pxe(t,e,n={}){const s=new Im;return t.asyncQueue.enqueueAndForget((async()=>(function(i,a,o,l,c){const h=new Txe({next:m=>{h.Nu(),a.enqueueAndForget((()=>sxe(i,p)));const y=m.docs.has(o);!y&&m.fromCache?c.reject(new Cn(Ot.UNAVAILABLE,"Failed to get document because the client is offline.")):y&&m.fromCache&&l&&l.source==="server"?c.reject(new Cn(Ot.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):c.resolve(m)},error:m=>c.reject(m)}),p=new axe(xL(o.path),h,{includeMetadataChanges:!0,qa:!0});return nxe(i,p)})(await Mxe(t),t.asyncQueue,e,n,s))),s.promise}function $xe(t,e){const n=new Im;return t.asyncQueue.enqueueAndForget((async()=>gxe(await Nxe(t),e,n))),n.promise}function Dxe(t,e,n){const s=new Im;return t.asyncQueue.enqueueAndForget((async()=>{const r=await Rxe(t);new Cxe(t.asyncQueue,r,n,e,s).ju()})),s.promise}/**
2931 * @license
2932 * Copyright 2023 Google LLC
2933 *
2934 * Licensed under the Apache License, Version 2.0 (the "License");
2935 * you may not use this file except in compliance with the License.
2936 * You may obtain a copy of the License at
2937 *
2938 *   http://www.apache.org/licenses/LICENSE-2.0
2939 *
2940 * Unless required by applicable law or agreed to in writing, software
2941 * distributed under the License is distributed on an "AS IS" BASIS,
2942 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2943 * See the License for the specific language governing permissions and
2944 * limitations under the License.
2945 */function wX(t){const e={};return t.timeoutSeconds!==void 0&&(e.timeoutSeconds=t.timeoutSeconds),e}/**
2946 * @license
2947 * Copyright 2020 Google LLC
2948 *
2949 * Licensed under the Apache License, Version 2.0 (the "License");
2950 * you may not use this file except in compliance with the License.
2951 * You may obtain a copy of the License at
2952 *
2953 *   http://www.apache.org/licenses/LICENSE-2.0
2954 *
2955 * Unless required by applicable law or agreed to in writing, software
2956 * distributed under the License is distributed on an "AS IS" BASIS,
2957 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2958 * See the License for the specific language governing permissions and
2959 * limitations under the License.
2960 */const Oxe="ComponentProvider",yF=new Map;function Lxe(t,e,n,s,r){return new Qge(t,e,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,wX(r.experimentalLongPollingOptions),r.useFetchStreams,r.isUsingEmulator,s)}/**
2961 * @license
2962 * Copyright 2020 Google LLC
2963 *
2964 * Licensed under the Apache License, Version 2.0 (the "License");
2965 * you may not use this file except in compliance with the License.
2966 * You may obtain a copy of the License at
2967 *
2968 *   http://www.apache.org/licenses/LICENSE-2.0
2969 *
2970 * Unless required by applicable law or agreed to in writing, software
2971 * distributed under the License is distributed on an "AS IS" BASIS,
2972 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2973 * See the License for the specific language governing permissions and
2974 * limitations under the License.
2975 */const jxe="firestore.googleapis.com",xF=!0;class vF{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new Cn(Ot.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=jxe,this.ssl=xF}else this.host=e.host,this.ssl=e.ssl??xF;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=tX;
vendor: 4,477 bytes, lines 2975-2990
2975else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<nX)throw new Cn(Ot.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}Fge("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=wX(e.experimentalLongPollingOptions??{}),(function(s){if(s.timeoutSeconds!==void 0){if(isNaN(s.timeoutSeconds))throw new Cn(Ot.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (must not be NaN)`);if(s.timeoutSeconds<5)throw new Cn(Ot.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (minimum allowed value is 5)`);if(s.timeoutSeconds>30)throw new Cn(Ot.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(function(s,r){return s.timeoutSeconds===r.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class _X{constructor(e,n,s,r){this._authCredentials=e,this._appCheckCredentials=n,this._databaseId=s,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new vF({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new Cn(Ot.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new Cn(Ot.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new vF(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(s){if(!s)return new Rge;switch(s.type){case"firstParty":return new $ge(s.sessionIndex||"0",s.iamToken||null,s.authTokenFactory||null);case"provider":return s.client;default:throw new Cn(Ot.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(n){const s=yF.get(n);s&&(xn(Oxe,"Removing Datastore"),yF.delete(n),s.terminate())})(this),Promise.resolve()}}/**
2976 * @license
2977 * Copyright 2020 Google LLC
2978 *
2979 * Licensed under the Apache License, Version 2.0 (the "License");
2980 * you may not use this file except in compliance with the License.
2981 * You may obtain a copy of the License at
2982 *
2983 *   http://www.apache.org/licenses/LICENSE-2.0
2984 *
2985 * Unless required by applicable law or agreed to in writing, software
2986 * distributed under the License is distributed on an "AS IS" BASIS,
2987 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2988 * See the License for the specific language governing permissions and
2989 * limitations under the License.
2990 */class BL{constructor(e,n,s){this.converter=n,this._query=s,this.type="query",this.firestore=e}withConverter(e){return new BL(this.firestore,e,this._query)}}class ja{constructor(e,n,s){this.converter=n,this._key=s,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}
vendor: 5,006 bytes, lines 2990-3006
2990get path(){return this._key.path.canonicalString()}get parent(){return new dE(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new ja(this.firestore,e,this._key)}toJSON(){return{type:ja._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,n,s){if(mA(n,ja._jsonSchema))return new ja(e,s||null,new rs(Di.fromString(n.referencePath)))}}ja._jsonSchemaVersion="firestore/documentReference/1.0",ja._jsonSchema={type:La("string",ja._jsonSchemaVersion),referencePath:La("string")};class dE extends BL{constructor(e,n,s){super(e,n,xL(s)),this._path=s,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new ja(this.firestore,null,new rs(e))}withConverter(e){return new dE(this.firestore,e,this._path)}}function Td(t,e,...n){if(t=qo(t),arguments.length===1&&(e=dL.newId()),Uge("doc","path",e),t instanceof _X){const s=Di.fromString(e,...n);return PU(s),new ja(t,null,new rs(s))}{if(!(t instanceof ja||t instanceof dE))throw new Cn(Ot.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=t._path.child(Di.fromString(e,...n));return PU(s),new ja(t.firestore,t instanceof dE?t.converter:null,new rs(s))}}/**
2991 * @license
2992 * Copyright 2020 Google LLC
2993 *
2994 * Licensed under the Apache License, Version 2.0 (the "License");
2995 * you may not use this file except in compliance with the License.
2996 * You may obtain a copy of the License at
2997 *
2998 *   http://www.apache.org/licenses/LICENSE-2.0
2999 *
3000 * Unless required by applicable law or agreed to in writing, software
3001 * distributed under the License is distributed on an "AS IS" BASIS,
3002 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3003 * See the License for the specific language governing permissions and
3004 * limitations under the License.
3005 */const bF="AsyncQueue";class wF{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new kL(this,"async_queue_retry"),this._c=()=>{const s=k4();s&&xn(bF,"Visibility state changed to "+s.visibilityState),this.M_.w_()},this.ac=e;const n=k4();n&&typeof n.addEventListener=="function"&&n.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;const n=k4();n&&typeof n.removeEventListener=="function"&&n.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));const n=new Im;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(e().then(n.resolve,n.reject),n.promise))).then((()=>n.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Yu.push(e),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!Z1(e))throw e;xn(bF,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){const n=this.ac.then((()=>(this.rc=!0,e().catch((s=>{throw this.nc=s,this.rc=!1,$m("INTERNAL UNHANDLED ERROR: ",_F(s)),s})).then((s=>(this.rc=!1,s))))));return this.ac=n,n}enqueueAfterDelay(e,n,s){this.uc(),this.oc.indexOf(e)>-1&&(n=0);const r=PL.createAndSchedule(this,e,n,s,(i=>this.hc(i)));return this.tc.push(r),r}uc(){this.nc&&ss(47125,{Pc:_F(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ec(e){for(const n of this.tc)if(n.timerId===e)return!0;return!1}Ic(e){return this.Tc().then((()=>{this.tc.sort(((n,s)=>n.targetTimeMs-s.targetTimeMs));for(const n of this.tc)if(n.skipDelay(),e!=="all"&&n.timerId===e)break;return this.Tc()}))}Rc(e){this.oc.push(e)}hc(e){const n=this.tc.indexOf(e);this.tc.splice(n,1)}}function _F(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+`
3006`+t.stack),e}class wA extends _X{constructor(e,n,s,r){super(e,n,s,r),this.type="firestore",this._queue=new wF,this._persistenceKey=(r==null?void 0:r.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new wF(e),this._firestoreClient=void 0,await e}}}function SF(t,e,n){n||(n=IN);const s=ZO(t,"firestore");if(s.isInitialized(n)){const r=s.getImmediate({identifier:n}),i=s.getOptions(n);if(vv(i,e))return r;throw new Cn(Ot.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(e.cacheSizeBytes!==void 0&&e.localCache!==void 0)throw new Cn(Ot.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");
3006if(e.cacheSizeBytes!==void 0&&e.cacheSizeBytes!==-1&&e.cacheSizeBytes<nX)throw new Cn(Ot.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return e.host&&dA(e.host)&&SK(e.host),s.initialize({options:e,instanceIdentifier:n})}function UL(t){if(t._terminated)throw new Cn(Ot.FAILED_PRECONDITION,"The client has already been terminated.");return t._firestoreClient||Bxe(t),t._firestoreClient}function Bxe(t){var s,r,i,a;const e=t._freezeSettings(),n=Lxe(t._databaseId,((s=t._app)==null?void 0:s.options.appId)||"",t._persistenceKey,(r=t._app)==null?void 0:r.options.apiKey,e);t._componentsProvider||(i=e.localCache)!=null&&i._offlineComponentProvider&&((a=e.localCache)!=null&&a._onlineComponentProvider)&&(t._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),t._firestoreClient=new kxe(t._authCredentials,t._appCheckCredentials,t._queue,n,t._componentsProvider&&(function(l){const c=l==null?void 0:l._online.build();return{_offline:l==null?void 0:l._offline.build(c),_online:c}})(t._componentsProvider))}/**
3007 * @license
3008 * Copyright 2020 Google LLC
3009 *
3010 * Licensed under the Apache License, Version 2.0 (the "License");
3011 * you may not use this file except in compliance with the License.
3012 * You may obtain a copy of the License at
3013 *
3014 *   http://www.apache.org/licenses/LICENSE-2.0
3015 *
3016 * Unless required by applicable law or agreed to in writing, software
3017 * distributed under the License is distributed on an "AS IS" BASIS,
3018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3019 * See the License for the specific language governing permissions and
3020 * limitations under the License.
3021 */class Au{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Au(Wo.fromBase64String(e))}catch(n){throw new Cn(Ot.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+n)}}static fromUint8Array(e){return new Au(Wo.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:Au._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(mA(e,Au._jsonSchema))return Au.fromBase64String(e.bytes)}}Au._jsonSchemaVersion="firestore/bytes/1.0",Au._jsonSchema={type:La("string",Au._jsonSchemaVersion),bytes:La("string")};/**
3022 * @license
3023 * Copyright 2020 Google LLC
3024 *
3025 * Licensed under the Apache License, Version 2.0 (the "License");
3026 * you may not use this file except in compliance with the License.
3027 * You may obtain a copy of the License at
3028 *
3029 *   http://www.apache.org/licenses/LICENSE-2.0
3030 *
3031 * Unless required by applicable law or agreed to in writing, software
3032 * distributed under the License is distributed on an "AS IS" BASIS,
3033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3034 * See the License for the specific language governing permissions and
3035 * limitations under the License.
3036 */class pM{constructor(...e){for(let n=0;n<e.length;++n)if(e[n].length===0)throw new Cn(Ot.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new zo(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
3037 * @license
3038 * Copyright 2020 Google LLC
3039 *
3040 * Licensed under the Apache License, Version 2.0 (the "License");
3041 * you may not use this file except in compliance with the License.
3042 * You may obtain a copy of the License at
3043 *
3044 *   http://www.apache.org/licenses/LICENSE-2.0
3045 *
3046 * Unless required by applicable law or agreed to in writing, software
3047 * distributed under the License is distributed on an "AS IS" BASIS,
3048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3049 * See the License for the specific language governing permissions and
3050 * limitations under the License.
3051 */class FL{constructor(e){this._methodName=e}}/**
3052 * @license
3053 * Copyright 2017 Google LLC
3054 *
3055 * Licensed under the Apache License, Version 2.0 (the "License");
3056 * you may not use this file except in compliance with the License.
3057 * You may obtain a copy of the License at
3058 *
3059 *   http://www.apache.org/licenses/LICENSE-2.0
3060 *
3061 * Unless required by applicable law or agreed to in writing, softw
3061are
3062 * distributed under the License is distributed on an "AS IS" BASIS,
3063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3064 * See the License for the specific language governing permissions and
3065 * limitations under the License.
3066 */class cp{constructor(e,n){if(!isFinite(e)||e<-90||e>90)throw new Cn(Ot.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(n)||n<-180||n>180)throw new Cn(Ot.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=e,this._long=n}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return mr(this._lat,e._lat)||mr(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:cp._jsonSchemaVersion}}static fromJSON(e){if(mA(e,cp._jsonSchema))return new cp(e.latitude,e.longitude)}}cp._jsonSchemaVersion="firestore/geoPoint/1.0",cp._jsonSchema={type:La("string",cp._jsonSchemaVersion),latitude:La("number"),longitude:La("number")};/**
3067 * @license
3068 * Copyright 2024 Google LLC
3069 *
3070 * Licensed under the Apache License, Version 2.0 (the "License");
3071 * you may not use this file except in compliance with the License.
3072 * You may obtain a copy of the License at
3073 *
3074 *   http://www.apache.org/licenses/LICENSE-2.0
3075 *
3076 * Unless required by applicable law or agreed to in writing, software
3077 * distributed under the License is distributed on an "AS IS" BASIS,
3078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3079 * See the License for the specific language governing permissions and
3080 * limitations under the License.
3081 */class qh{constructor(e){this._values=(e||[]).map((n=>n))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(s,r){if(s.length!==r.length)return!1;for(let i=0;i<s.length;++i)if(s[i]!==r[i])return!1;return!0})(this._values,e._values)}toJSON(){return{type:qh._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(mA(e,qh._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((n=>typeof n=="number")))return new qh(e.vectorValues);throw new Cn(Ot.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}qh._jsonSchemaVersion="firestore/vectorValue/1.0",qh._jsonSchema={type:La("string",qh._jsonSchemaVersion),vectorValues:La("object")};/**
3082 * @license
3083 * Copyright 2017 Google LLC
3084 *
3085 * Licensed under the Apache License, Version 2.0 (the "License");
3086 * you may not use this file except in compliance with the License.
3087 * You may obtain a copy of the License at
3088 *
3089 *   http://www.apache.org/licenses/LICENSE-2.0
3090 *
3091 * Unless required by applicable law or agreed to in writing, software
3092 * distributed under the License is distributed on an "AS IS" BASIS,
3093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3094 * See the License for the specific language governing permissions and
3095 * limitations under the License.
3096 */const Uxe=/^__.*__$/;class Fxe{constructor(e,n,s){this.data=e,this.fieldMask=n,this.fieldTransforms=s}toMutation(e,n){return this.fieldMask!==null?new J0(e,this.data,this.fieldMask,n,this.fieldTransforms):new yA(e,this.data,n,this.fieldTransforms)}}class SX{constructor(e,n,s){this.data=e,this.fieldMask=n,this.fieldTransforms=s}toMutation(e,n){return new J0(e,this.data,this.fieldMask,n,this.fieldTransforms)}}function EX(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ss(40011,{dataSource:t})}}class VL{constructor(e,n,s,r,i,a){this.settings=e,this.databaseId=n,this.serializer=s,this.ignoreUndefinedProperties=r,i===void 0&&this.Ac(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(e){return new VL({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}dc(e){var r;const n=(r=this.path)==null?void 0:r.child(e),s=this.i({path:n,arrayElement:!1});return s.mc(e),s}fc(e){var r;const n=(r=this.path)==null?void 0:r.child(e),s=this.i({path:n,arrayElement:!1});return s.Ac(),s}
3096gc(e){return this.i({path:void 0,arrayElement:!0})}yc(e){return UN(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((n=>e.isPrefixOf(n)))!==void 0||this.fieldTransforms.find((n=>e.isPrefixOf(n.field)))!==void 0}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.mc(this.path.get(e))}mc(e){if(e.length===0)throw this.yc("Document fields must not be empty");if(EX(this.dataSource)&&Uxe.test(e))throw this.yc('Document fields cannot begin and end with "__"')}}class Vxe{constructor(e,n,s){this.databaseId=e,this.ignoreUndefinedProperties=n,this.serializer=s||dM(e)}I(e,n,s,r=!1){return new VL({dataSource:e,methodName:n,targetDoc:s,path:zo.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function zL(t){const e=t._freezeSettings(),n=dM(t._databaseId);return new Vxe(t._databaseId,!!e.ignoreUndefinedProperties,n)}function TX(t,e,n,s,r,i={}){const a=t.I(i.merge||i.mergeFields?2:0,e,n,r);GL("Data must be an object, but it was:",a,s);const o=kX(s,a);let l,c;if(i.merge)l=new ku(a.fieldMask),c=a.fieldTransforms;else if(i.mergeFields){const h=[];for(const p of i.mergeFields){const m=hE(e,p,n);if(!a.contains(m))throw new Cn(Ot.INVALID_ARGUMENT,`Field '${m}' is specified in your field mask but missing from your input data.`);RX(h,m)||h.push(m)}l=new ku(h),c=a.fieldTransforms.filter((p=>l.covers(p.field)))}else l=null,c=a.fieldTransforms;return new Fxe(new Jl(o),l,c)}class _A extends FL{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.yc(`${this._methodName}() can only appear at the top level of your update data`):e.yc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof _A}}function AX(t,e,n,s){const r=t.I(1,e,n);GL("Data must be an object, but it was:",r,s);const i=[],a=Jl.empty();X0(s,((l,c)=>{const h=NX(e,l,n);c=qo(c);const p=r.fc(h);if(c instanceof _A)i.push(h);else{const m=mM(c,p);m!=null&&(i.push(h),a.set(h,m))}}));const o=new ku(i);return new SX(a,o,r.fieldTransforms)}function CX(t,e,n,s,r,i){const a=t.I(1,e,n),o=[hE(e,s,n)],l=[r];if(i.length%2!=0)throw new Cn(Ot.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let m=0;m<i.length;m+=2)o.push(hE(e,i[m])),l.push(i[m+1]);const c=[],h=Jl.empty();for(let m=o.length-1;m>=0;--m)if(!RX(c,o[m])){const y=o[m];let v=l[m];v=qo(v);const b=a.fc(y);if(v instanceof _A)c.push(y);else{const S=mM(v,b);S!=null&&(c.push(y),h.set(y,S))}}const p=new ku(c);return new SX(h,p,a.fieldTransforms)}function mM(t,e){if(IX(t=qo(t)))return GL("Unsupported field value:",e,t),kX(t,e);if(t instanceof FL)return(function(s,r){if(!EX(r.dataSource))throw r.yc(`${s._methodName}() can only be used with update() and set()`);if(!r.path)throw r.yc(`${s._methodName}() is not currently supported inside arrays`);const i=s._toFieldTransform(r);i&&r.fieldTransforms.push(i)})(t,e),null;if(t===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.arrayElement&&e.dataSource!==4)throw e.yc("Nested arrays are not supported");return(function(s,r){const i=[];let a=0;for(const o of s){let l=mM(o,r.gc(a));l==null&&(l={nullValue:"NULL_VALUE"}),i.push(l),a++}return{arrayValue:{values:i}}})(t,e)}return(function(s,r){if((s=qo(s))===null)return{nullValue:"NULL_VALUE"};if(typeof s=="number")return E0e(r.serializer,s);if(typeof s=="boolean")return{booleanValue:s};if(typeof s=="string")return{stringValue:s};if(s instanceof Date){const i=Oi.fromDate(s);return{timestampValue:DN(r.serializer,i)}}if(s instanceof Oi){const i=new Oi(s.seconds,1e3*Math.floor(s.nanoseconds/1e3));return{timestampValue:DN(r.serializer,i)}}if(s instanceof cp)return{geoPointValue:{latitude:s.latitude,longitude:s.longitude}};if(s instanceof Au)return{bytesValue:qY(r.serializer,s._byteString)};if(s instanceof ja){const i=r.databaseId,a=s.firestore._databaseId;if(!a.isEqual(i))throw r.yc(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:SL(s.firestore._databaseId||r.databaseId,s._key.path)}}if(s instanceof qh)return(function(a,o){const l=a instanceof qh?a.toArray():a;return{mapValue:{fields:{[bY]:{stringValue:wY},[NN]:{arrayValue:{values:l.map((h=>{if(typeof h!="number")throw o.yc("VectorValues must only contain numeric values.");return vL(o.serializer,h)}))}}}}}})(s,r);if(eX(s))return s._toProto(r.serializer);throw r.yc(`Unsupported field value: ${hL(s)}`)})(t,e)}function kX(t,e){const n={};return pY(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):X0(t,((s,r)=>{const i=mM(r,e.dc(s));i!=null&&(n[s]=i)})),{mapValue:{fields:n}}}function IX(t){return!(typeof t!="object"||t===null||t instanceof Array||t instanceof Date||t instanceof Oi||t instanceof cp||t instanceof Au||t instanceof ja||t instanceof FL||t instanceof qh||eX(t))}
vendor: 4,080 bytes, lines 3096-3126
3096function GL(t,e,n){if(!IX(n)||!hY(n)){const s=hL(n);throw s==="an object"?e.yc(t+" a custom object"):e.yc(t+" "+s)}}function hE(t,e,n){if((e=qo(e))instanceof pM)return e._internalPath;if(typeof e=="string")return NX(t,e);throw UN("Field path arguments must be of type string or ",t,!1,void 0,n)}const zxe=new RegExp("[~\\*/\\[\\]]");function NX(t,e,n){if(e.search(zxe)>=0)throw UN(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new pM(...e.split("."))._internalPath}catch{throw UN(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function UN(t,e,n,s,r){const i=s&&!s.isEmpty(),a=r!==void 0;let o=`Function ${e}() called with invalid data`;n&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(i||a)&&(l+=" (found",i&&(l+=` in field ${s}`),a&&(l+=` in document ${r}`),l+=")"),new Cn(Ot.INVALID_ARGUMENT,o+t+l)}function RX(t,e){return t.some((n=>n.isEqual(e)))}/**
3097 * @license
3098 * Copyright 2020 Google LLC
3099 *
3100 * Licensed under the Apache License, Version 2.0 (the "License");
3101 * you may not use this file except in compliance with the License.
3102 * You may obtain a copy of the License at
3103 *
3104 *   http://www.apache.org/licenses/LICENSE-2.0
3105 *
3106 * Unless required by applicable law or agreed to in writing, software
3107 * distributed under the License is distributed on an "AS IS" BASIS,
3108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3109 * See the License for the specific language governing permissions and
3110 * limitations under the License.
3111 */class MX{convertValue(e,n="none"){switch(j0(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ba(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,n);case 5:return e.stringValue;case 6:return this.convertBytes(L0(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,n);case 11:return this.convertObject(e.mapValue,n);case 10:return this.convertVectorValue(e.mapValue);default:throw ss(62114,{value:e})}}convertObject(e,n){return this.convertObjectMap(e.fields,n)}convertObjectMap(e,n="none"){const s={};return X0(e,((r,i)=>{s[r]=this.convertValue(i,n)})),s}convertVectorValue(e){var s,r,i;const n=(i=(r=(s=e.fields)==null?void 0:s[NN].arrayValue)==null?void 0:r.values)==null?void 0:i.map((a=>ba(a.doubleValue)));return new qh(n)}convertGeoPoint(e){return new cp(ba(e.latitude),ba(e.longitude))}convertArray(e,n){return(e.values||[]).map((s=>this.convertValue(s,n)))}convertServerTimestamp(e,n){switch(n){case"previous":const s=rM(e);return s==null?null:this.convertValue(s,n);case"estimate":return this.convertTimestamp(aE(e));default:return null}}convertTimestamp(e){const n=O0(e);return new Oi(n.seconds,n.nanos)}convertDocumentKey(e,n){const s=Di.fromString(e);Ar(ZY(s),9688,{name:e});const r=new oE(s.get(1),s.get(3)),i=new rs(s.popFirst(5));return r.isEqual(n)||$m(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),i}}/**
3112 * @license
3113 * Copyright 2024 Google LLC
3114 *
3115 * Licensed under the Apache License, Version 2.0 (the "License");
3116 * you may not use this file except in compliance with the License.
3117 * You may obtain a copy of the License at
3118 *
3119 *   http://www.apache.org/licenses/LICENSE-2.0
3120 *
3121 * Unless required by applicable law or agreed to in writing, software
3122 * distributed under the License is distributed on an "AS IS" BASIS,
3123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3124 * See the License for the specific language governing permissions and
3125 * limitations under the License.
3126 */class PX extends MX{constructor(e){super(),this.firestore=e}convertBytes(e){return new Au(e)}convertReference(e){const n=this.convertDocumentKey(e,this.firestore._databaseId);
3126return new ja(this.firestore,null,n)}}/**
3127 * @license
3128 * Copyright 2020 Google LLC
3129 *
3130 * Licensed under the Apache License, Version 2.0 (the "License");
3131 * you may not use this file except in compliance with the License.
3132 * You may obtain a copy of the License at
3133 *
3134 *   http://www.apache.org/licenses/LICENSE-2.0
3135 *
3136 * Unless required by applicable law or agreed to in writing, software
3137 * distributed under the License is distributed on an "AS IS" BASIS,
3138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3139 * See the License for the specific language governing permissions and
3140 * limitations under the License.
3141 */function jh(){return new _A("deleteField")}const EF="@firebase/firestore",TF="4.14.0";/**
3142 * @license
3143 * Copyright 2020 Google LLC
3144 *
3145 * Licensed under the Apache License, Version 2.0 (the "License");
3146 * you may not use this file except in compliance with the License.
3147 * You may obtain a copy of the License at
3148 *
3149 *   http://www.apache.org/licenses/LICENSE-2.0
3150 *
3151 * Unless required by applicable law or agreed to in writing, software
3152 * distributed under the License is distributed on an "AS IS" BASIS,
3153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3154 * See the License for the specific language governing permissions and
3155 * limitations under the License.
3156 */class FN{constructor(e,n,s,r,i){this._firestore=e,this._userDataWriter=n,this._key=s,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new ja(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new Gxe(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){var e;return((e=this._document)==null?void 0:e.data.clone().value.mapValue.fields)??void 0}get(e){if(this._document){const n=this._document.data.field(hE("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n)}}}class Gxe extends FN{data(){return super.data()}}function $X(t,e,n){let s;return s=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,s}class Hxe extends MX{constructor(e){super(),this.firestore=e}convertBytes(e){return new Au(e)}convertReference(e){const n=this.convertDocumentKey(e,this.firestore._databaseId);return new ja(this.firestore,null,n)}}class tw{constructor(e,n){this.hasPendingWrites=e,this.fromCache=n}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class M0 extends FN{constructor(e,n,s,r,i,a){super(e,n,s,r,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const n=new bI(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(n,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,n={}){if(this._document){const s=this._document.data.field(hE("DocumentSnapshot.get",e));if(s!==null)return this._userDataWriter.convertValue(s,n.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new Cn(Ot.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,n={};return n.type=M0._jsonSchemaVersion,n.bundle="",n.bundleSource="DocumentSnapshot",n.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),n.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),n)}}M0._jsonSchemaVersion="firestore/documentSnapshot/1.0",M0._jsonSchema={type:La("string",M0._jsonSchemaVersion),bundleSource:La("string","DocumentSnapshot"),bundleName:La("string"),bundle:La("string")};class bI extends M0{data(e={}){return super.data(e)}}class BS{constructor(e,n,s,r){this._firestore=e,this._userDataWriter=n,this._snapshot=r,this.metadata=new tw(r.hasPendingWrites,r.fromCache),this.query=s}get docs(){const e=[];return this.forEach((n=>e.push(n))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,n){this._snapshot.docs.forEach((s=>{e.call(n,new bI(this._firestore,this._userDataWriter,s.key,s,new tw(this._snapshot.mutatedKeys.has(s.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const n=!!e.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new Cn(Ot.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===n||(this._cachedChanges=(function(r,i){if(r._snapshot.oldDocs.isEmpty()){let a=0;return r._snapshot.docChanges.map((o=>{const l=new bI(r._firestore,r._userDataWriter,o.doc.key,o.doc,new tw(r._snapshot.mutatedKeys.has(o.doc.key),r._snapshot.fromCache),r.query.converter);return o.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}}))}{let a=r._snapshot.oldDocs;return r._snapshot.docChanges.filter((o=>i||o.type!==3)).map((o=>{const l=new bI(r._firestore,r._userDataWriter,o.doc.key,o.doc,new tw(r._snapshot.mutatedKeys.has(o.doc.key),r._snapshot.fromCache),r.query.converter);let c=-1,h=-1;return o.type!==0&&(c=a.indexOf(o.doc.key),a=a.delete(o.doc.key)),o.type!==1&&(a=a.add(o.doc),h=a.indexOf(o.doc.key)),{type:qxe(o.type),doc:l,oldIndex:c,newIndex:h}}))}})(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new Cn(Ot.FAILED_PRECONDITION,"QuerySnapsh
3156ot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=BS._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=dL.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const n=[],s=[],r=[];return this.docs.forEach((i=>{i._document!==null&&(n.push(i._document),s.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),r.push(i.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function qxe(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ss(61501,{type:t})}}/**
3157 * @license
3158 * Copyright 2022 Google LLC
3159 *
3160 * Licensed under the Apache License, Version 2.0 (the "License");
3161 * you may not use this file except in compliance with the License.
3162 * You may obtain a copy of the License at
3163 *
3164 *   http://www.apache.org/licenses/LICENSE-2.0
3165 *
3166 * Unless required by applicable law or agreed to in writing, software
3167 * distributed under the License is distributed on an "AS IS" BASIS,
3168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3169 * See the License for the specific language governing permissions and
3170 * limitations under the License.
3171 */BS._jsonSchemaVersion="firestore/querySnapshot/1.0",BS._jsonSchema={type:La("string",BS._jsonSchemaVersion),bundleSource:La("string","QuerySnapshot"),bundleName:La("string"),bundle:La("string")};const Wxe={maxAttempts:5};function oS(t,e){if((t=qo(t)).firestore!==e)throw new Cn(Ot.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}/**
3172 * @license
3173 * Copyright 2020 Google LLC
3174 *
3175 * Licensed under the Apache License, Version 2.0 (the "License");
3176 * you may not use this file except in compliance with the License.
3177 * You may obtain a copy of the License at
3178 *
3179 *   http://www.apache.org/licenses/LICENSE-2.0
3180 *
3181 * Unless required by applicable law or agreed to in writing, software
3182 * distributed under the License is distributed on an "AS IS" BASIS,
3183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3184 * See the License for the specific language governing permissions and
3185 * limitations under the License.
3186 */class Kxe{constructor(e,n){this._firestore=e,this._transaction=n,this._dataReader=zL(e)}get(e){const n=oS(e,this._firestore),s=new Hxe(this._firestore);return this._transaction.lookup([n._key]).then((r=>{if(!r||r.length!==1)return ss(24041);const i=r[0];if(i.isFoundDocument())return new FN(this._firestore,s,i.key,i,n.converter);if(i.isNoDocument())return new FN(this._firestore,s,n._key,null,n.converter);throw ss(18433,{doc:i})}))}set(e,n,s){const r=oS(e,this._firestore),i=$X(r.converter,n,s),a=TX(this._dataReader,"Transaction.set",r._key,i,r.converter!==null,s);return this._transaction.set(r._key,a),this}update(e,n,s,...r){const i=oS(e,this._firestore);let a;return a=typeof(n=qo(n))=="string"||n instanceof pM?CX(this._dataReader,"Transaction.update",i._key,n,s,r):AX(this._dataReader,"Transaction.update",i._key,n),this._transaction.update(i._key,a),this}delete(e){const n=oS(e,this._firestore);return this._transaction.delete(n._key),this}}/**
3187 * @license
3188 * Copyright 2020 Google LLC
3189 *
3190 * Licensed under the Apache License, Version 2.0 (the "License");
3191 * you may not use this file except in compliance with the License.
3192 * You may obtain a copy of the License at
3193 *
3194 *   http://www.apache.org/licenses/LICENSE-2.0
3195 *
3196 * Unless required by applicable law or agreed to in writing, software
3197 * distributed under the License is distributed on an "AS IS" BASIS,
3198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3199 * See the License for the specific language governing permissions and
3200 * limitations under the License.
3201 */class Yxe extends Kxe{constructor(e,n){super(e,n),this._firestore=e}get(e){const n=oS(e,this._firestore),s=new PX(this._firestore);return super.get(e).then((r=>new M0(this._firestore,s,n._key,r._document,new tw(!1,!1),n.converter)))}}function DX(t,e,n){t=Sv(t,wA);const s={...Wxe,...n};
3201(function(a){if(a.maxAttempts<1)throw new Cn(Ot.INVALID_ARGUMENT,"Max attempts must be at least 1")})(s);const r=UL(t);return Dxe(r,(i=>e(new Yxe(t,i))),s)}/**
3202 * @license
3203 * Copyright 2020 Google LLC
3204 *
3205 * Licensed under the Apache License, Version 2.0 (the "License");
3206 * you may not use this file except in compliance with the License.
3207 * You may obtain a copy of the License at
3208 *
3209 *   http://www.apache.org/licenses/LICENSE-2.0
3210 *
3211 * Unless required by applicable law or agreed to in writing, software
3212 * distributed under the License is distributed on an "AS IS" BASIS,
3213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3214 * See the License for the specific language governing permissions and
3215 * limitations under the License.
3216 */function Q0(t){t=Sv(t,ja);const e=Sv(t.firestore,wA),n=UL(e);return Pxe(n,t._key).then((s=>Jxe(e,t,s)))}function Xxe(t,e,n){t=Sv(t,ja);const s=Sv(t.firestore,wA),r=$X(t.converter,e,n),i=zL(s);return LX(s,[TX(i,"setDoc",t._key,r,t.converter!==null,n).toMutation(t._key,Ql.none())])}
3216function OX(t,e,n,...s){t=Sv(t,ja);const r=Sv(t.firestore,wA),i=zL(r);let a;return a=typeof(e=qo(e))=="string"||e instanceof pM?CX(i,"updateDoc",t._key,e,n,s):AX(i,"updateDoc",t._key,e),LX(r,[a.toMutation(t._key,Ql.exists(!0))])}function LX(t,e){const n=UL(t);return $xe(n,e)}function Jxe(t,e,n){const s=n.docs.get(e._key),r=new PX(t);return new M0(t,r,e._key,s,new tw(n.hasPendingWrites,n.fromCache),e.converter)}(function(e,n=!0){Ige(Y1),N1(new bv("firestore",((s,{instanceIdentifier:r,options:i})=>{const a=s.getProvider("app").getImmediate(),o=new wA(new Mge(s.getProvider("auth-internal")),new Dge(a,s.getProvider("app-check-internal")),Zge(a,r),a);return i={useFetchStreams:n,...i},o._setSettings(i),o}),"PUBLIC").setMultipleInstances(!0)),N0(EF,TF,e),N0(EF,TF,"esm2020")})();const Qxe="gen-lang-client-0084186361",Zxe="1:309502431110:web:46cb9705ec20417e4c2607",eve="AIzaSyBIksRI5Y_KDFoQjQyiqAOUeSsykHrFY3A",tve="auth.csvmeta.com",nve="ai-studio-422b575f-74d7-4c57-83cf-976bce303484",sve="gen-lang-client-0084186361.firebasestorage.app",rve="309502431110",ive="",jX={projectId:Qxe,appId:Zxe,apiKey:eve,authDomain:tve,firestoreDatabaseId:nve,storageBucket:sve,messagingSenderId:rve,measurementId:ive},tD=AK(jX),AF={experimentalForceLongPolling:!0};var sK;const nD=(sK=jX.firestoreDatabaseId)==null?void 0:sK.trim(),ave=!nD||nD==="(default)",Bc=ave?SF(tD,AF):SF(tD,AF,nD),Ko=Tge(tD),ove=new Sm,lve=async()=>{try{return(await $me(Ko,ove)).user}catch(t){throw console.error("Error signing in with Google",t),t}},BX=async()=>{try{await pme(Ko)}catch(t){throw console.error("Error logging out",t),t}},cve="/assets/csv%20lite-DcTMqtlL.svg",uve="/assets/csv%20plus-CpprnlzJ.svg",dve="/assets/csv%20max-aWGDbG_E.svg",sD=12,CF=[{id:"free",name:"Free",csvBucks:"30/day",batchLimit:"Max 30 files in single batch",features:["30 CSVBucks/day","Max 30 files in single batch","CSV and Embedding Support","Complementary Usage in BG Generator, Image Upscaler, Bento Generator and Vector Studio","Access to Color Extractor"],prices:{BDT:0,USD:0},annualPrices:{BDT:0,USD:0},ctaLabel:"Get Started Free"},{id:"lite",name:"CSV Lite",icon:cve,csvBucks:"3000",batchLimit:"Max 250 files in single batch",features:["3000 CSVBucks","Max 250 files in single batch","CSV and Embedding Support","Complementary Usage in BG Generator, Image Upscaler, Bento Generator and Vector Studio","Access to Color Extractor"],prices:{BDT:200,USD:2},annualPrices:{BDT:120,USD:1.99},ctaLabel:"Choose CSV Lite"},{id:"plus",name:"CSV Plus",icon:uve,csvBucks:"6000",batchLimit:"Max 500 files in single batch",features:["6000 CSVBucks","Max 500 files in single batch","CSV and Embedding support","Access to BG Generator, Image Upscaler, Bento Generator and Vector Studio","Access to Color Extractor"],prices:{BDT:500,USD:5},annualPrices:{BDT:450,USD:3.99},recommended:!0,ctaLabel:"Choose CSV Plus"},{id:"max",name:"CSV Max",icon:dve,csvBucks:"15000",batchLimit:"Unlimited files in single batch",features:["15000 CSVBucks","Unlimited files in single batch","CSV and Embedding support","Unlimited Access to BG Generator, Image Upscaler, Bento Generator and Vector Studio","Access to Color Extractor"],prices:{BDT:1e3,USD:10},annualPrices:{BDT:900,USD:7.99},ctaLabel:"Choose CSV Max"}],kF="csv_meta_pricing_currency";function SA(t){return t==="annual"?"annual":"monthly"}function UX(t){return t==="monthly"||t==="annual"?t:"both"}function FX(t,e){const n=UX(e);return n==="both"||n===t}function rD(t,e){const n=t*sD;return e==="USD"?Math.round(n*100)/100:Math.round(n)}function gM(t,e,n){return n==="annual"?t.annualPrices[e]:t.prices[e]}function IF(t,e,n="monthly"){return Uf(gM(t,e,n),e)}function Uf(t,e){return e==="BDT"?`à§³${Math.round(t)}`:`$${Number.isInteger(t)?String(t):t.toFixed(2)}`}const hve=[{label:"CSVBucks",free:"30/day",lite:"3,000",plus:"6,000",max:"15,000"},{label:"Batch size",free:"30 files",lite:"250 files",plus:"500 files",max:"Unlimited"},{label:"Creative tools",free:"Complementary",lite:"Complementary",plus:"Full access",max:"Unlimited"}],yM=-1,VX={free:{csvBucks:30,batchLimit:30,isDaily:!0},lite:{csvBucks:3e3,batchLimit:250,isDaily:!1},plus:{csvBucks:6e3,batchLimit:500,isDaily:!1},max:{csvBucks:15e3,batchLimit:yM,isDaily:!1}};function tc(t){return VX[t]}function wI(t){return{free:"Free",lite:"CSV Lite",plus:"CSV Plus",max:"CSV Max"}[t]}
3216function Om(t=Date.now()){const e=new Date(t);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function xM(t){return t==null?!0:t<Om()}function fve(t){return t==null||t===yM||!Number.isFinite(t)?"Unlimited":String(t)}function N4(t){return t==null||t===yM||!Number.isFinite(t)?Number.POSITIVE_INFINITY:t}const VN=720*60*60*1e3,zX=365*24*60*60*1e3;function GX(t,e=Date.now()){return t==null?!0:e>=t+VN}function pve(t){const e=tc(t),n=e.csvBucks.toLocaleString();return e.isDaily?`${n} CSVBucks daily`:`${n} CSVBucks monthly`}function mve(t){const n=(t.subscriptionStatus==="trial"&&(t.trialPlanId==="lite"||t.trialPlanId==="plus"||t.trialPlanId==="max")?t.trialPlanId:void 0)??t.plan??"free",s=tc(n),r=pve(n);if(s.isDaily){const p=Date.now(),m=Om(p)+1440*60*1e3,y=Math.max(1,Math.ceil((m-p)/(3600*1e3)));return y<24?`${r} (renew in ${y} hour${y===1?"":"s"})`:`${r} (renew in 1 day)`}const i=typeof t.trialEndsAt=="number"&&Number.isFinite(t.trialEndsAt)?t.trialEndsAt:void 0,a=SA(t.billingInterval),o=a==="annual"?zX:VN,l=t.subscriptionStatus==="trial"&&i!=null?i:typeof t.planExpiresAt=="number"?t.planExpiresAt:typeof t.lastCheckoutAt=="number"?t.lastCheckoutAt+o:Date.now()+o,c=Math.max(0,Math.ceil((l-Date.now())/(1440*60*1e3))),h=t.subscriptionStatus==="trial"?"trial ends":"expires";if(a==="annual"&&t.subscriptionStatus!=="trial"){const m=(typeof t.lastCsvBucksReset=="number"&&Number.isFinite(t.lastCsvBucksReset)?t.lastCsvBucksReset:typeof t.lastCheckoutAt=="number"?t.lastCheckoutAt:Date.now())+VN,y=Math.max(0,Math.ceil((m-Date.now())/(1440*60*1e3)));return`${r} (refill in ${y} day${y===1?"":"s"}, ${h} in ${c} day${c===1?"":"s"})`}return`${r} (${h} in ${c} day${c===1?"":"s"})`}const gve=new Set(["active","simulated"]),yve=["max","plus","lite"];function zN(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()){const e=Number(t);if(Number.isFinite(e))return e;const n=Date.parse(t);return Number.isNaN(n)?void 0:n}if(typeof t=="object"&&t!==null){if("toDate"in t&&typeof t.toDate=="function"){const n=t.toDate().getTime();return Number.isNaN(n)?void 0:n}if("seconds"in t){const e=Number(t.seconds);if(!Number.isFinite(e))return;const n=Number(t.nanoseconds??0);return e*1e3+Math.floor(n/1e6)}}}function NF(t){const e=typeof t=="string"?t.trim().toLowerCase():"";return e==="lite"||e==="plus"||e==="max"?e:null}function xve(t){if(!t)return null;const e=t.csvBucksBalance,n=t.batchLimit;for(const s of yve){const r=VX[s];if(typeof n=="number"&&n===r.batchLimit||typeof e=="number"&&e===r.csvBucks)return s}return null}function _I(t){return zN(t==null?void 0:t.trialEndsAt)}function HX(t){const e=zN(t==null?void 0:t.planExpiresAt);if(e!=null)return e;const n=zN(t==null?void 0:t.lastCheckoutAt);if(n!=null){const s=SA(t==null?void 0:t.billingInterval);return n+(s==="annual"?zX:VN)}}function qX(t){if((t==null?void 0:t.subscriptionStatus)!=="trial")return!1;const e=_I(t);return e!=null&&Date.now()>e}function vve(t){return(t==null?void 0:t.subscriptionStatus)!=="trial"||qX(t)?null:NF(t.trialPlanId)||NF(t.plan)||xve(t)}function WX(t){if(!t)return!1;const e=t.subscriptionStatus;if(typeof e!="string"||!gve.has(e))return!1;const n=t.plan;if(typeof n!="string"||n==="free")return!1;const s=HX(t);return s==null?!1:Date.now()>s}function RF(){const t=tc("free");return{plan:"free",subscriptionStatus:"inactive",csvBucksBalance:t.csvBucks,batchLimit:t.batchLimit,csvBucksUsedToday:0,lastCsvBucksReset:Om(),updatedAt:Date.now()}}function bve(t,e){if(e==="admin")return{plan:"max",csvBucksBalance:tc("max").csvBucks,batchLimit:tc("max").batchLimit};const n=(t==null?void 0:t.plan)??"free",s=tc(n);if(s.isDaily){const a=t==null?void 0:t.lastCsvBucksReset;if(xM(a))return{plan:n,csvBucksBalance:s.csvBucks,csvBucksUsedToday:0,lastCsvBucksReset:Om(),batchLimit:s.batchLimit};const o=typeof(t==null?void 0:t.csvBucksBalance)=="number"?Math.min(t.csvBucksBalance,s.csvBucks):s.csvBucks;return{plan:n,csvBucksBalance:o,csvBucksUsedToday:(t==null?void 0:t.csvBucksUsedToday)??0,lastCsvBucksReset:a??Om(),batchLimit:s.batchLimit}}if(SA(t==null?void 0:t.billingInterval)==="annual"&&!WX(t)){const a=typeof(t==null?void 0:t.lastCsvBucksReset)=="number"?t.lastCsvBucksReset:zN(t==null?void 0:t.lastCheckoutAt);if(GX(a))return{plan:n,csvBucksBalance:s.csvBucks,lastCsvBucksReset:Date.now(),batchLimit:s.batchLimit}}const i=typeof(t==null?void 0:t.csvBucksBalance)=="number"?t.csvBucksBalance:s.csvBucks;return{plan:n,csvBucksBalance:i,lastCsvBucksReset:typeof(t==null?void 0:t.lastCsvBucksReset)=="number"?t.lastCsvBucksReset:void 0,batchLimit:typeof(t==null?void 0:t.batchLimit)=="number"?t.batchLimit:s.batchLimit}}async function wve(t,e){const n=Td(Bc,"users",t);return DX(Bc,async s=>{const r=await s.get(n);if(!r.exists())throw new Error("User profile not found.");const i=r.data();if((i.role??"user")==="admin")return i.csvBucksBalance??tc("max").csvBucks;const o=i.plan??"free",l=tc(o);let c=typeof i.csvBucksBalance=="number"?i.csvBucksBalance:l.csvBucks;const h=SA(i.billingInterval);if(l.isDaily&&xM(i.lastCsvBucksReset))return c=l.csvBucks,s.update(n,{csvBucksBalance:c-e,csvBucksUsedToday:e,lastCsvBucksReset:Om()}),c-e;if(h==="annual"&&!l.isDaily&&GX(i.lastCsvBucksReset)){if(c=l.csvBucks,c<e)throw new Error("Insufficient CSVBucks.");return s.update(n,{csvBucksBalance:c-e,lastCsvBucksReset:Date.now()}),c-e}if(c<e)throw new Error("Insufficient CSVBucks.");const p={csvBucksBalance:c-e};return l.isDaily&&(p.csvBucksUsedToday=(i.csvBucksUsedToday??0)+e),s.update(n,p),c-e})}const R4="[email protected]";function vM(t){return{name:t.displayName||"",email:t.email||"",picture:t.photoURL||"",sub:t.uid}}async function Vv(t){const e=vM(t),n=Td(Bc,"users",t.uid);let s,r=!1;try{const c=await Q0(n);r=!0,c.exists()&&(s=c.data())}catch(c){console.warn("Could not read user profile from Firestore; will merge profile fields only.",c)}const i={lastLoginAt:Date.now()};
3216e.name?(i.name=e.name,i.displayName=e.name):typeof(s==null?void 0:s.name)=="string"&&s.name.trim()?(i.name=s.name,i.displayName=s.displayName??s.name):typeof(s==null?void 0:s.displayName)=="string"&&s.displayName.trim()&&(i.name=s.displayName,i.displayName=s.displayName),e.email?i.email=e.email:typeof(s==null?void 0:s.email)=="string"&&s.email.trim()&&(i.email=s.email),e.picture?i.picture=e.picture:typeof(s==null?void 0:s.picture)=="string"&&s.picture.trim()&&(i.picture=s.picture);let a="user";if(r&&!s)i.createdAt=t.metadata.creationTime?new Date(t.metadata.creationTime).getTime():Date.now(),a=e.email===R4?"admin":"user",i.role=a,a==="user"&&(i.plan="free");else if(s){if(qX(s))Object.assign(i,RF()),i.trialEndsAt=jh(),i.trialCouponCode=jh(),i.trialPlanId=jh(),i.planExpiresAt=jh(),i.billingInterval=jh(),s={...s,plan:"free",subscriptionStatus:"inactive",trialEndsAt:void 0,trialCouponCode:void 0,trialPlanId:void 0,planExpiresAt:void 0,billingInterval:void 0};else{const c=vve(s);if(c){const h=tc(c),p=s.plan!==c,m=s.plan==="free"||s.batchLimit!==h.batchLimit||typeof s.csvBucksBalance!="number"||typeof s.csvBucksBalance=="number"&&s.csvBucksBalance<=tc("free").csvBucks&&s.batchLimit!==h.batchLimit;i.plan=c,i.trialPlanId=c,i.subscriptionStatus="trial",(p||m)&&(i.csvBucksBalance=h.csvBucks,i.batchLimit=h.batchLimit,i.csvBucksUsedToday=0),s={...s,plan:c,trialPlanId:c,subscriptionStatus:"trial",...p||m?{csvBucksBalance:h.csvBucks,batchLimit:h.batchLimit,csvBucksUsedToday:0}:{}};const y=_I(s);y!=null&&(i.trialEndsAt=y,s={...s,trialEndsAt:y})}else if(WX(s))Object.assign(i,RF()),i.planExpiresAt=jh(),i.billingInterval=jh(),s={...s,plan:"free",subscriptionStatus:"inactive",planExpiresAt:void 0,billingInterval:void 0};else{const h=HX(s);h!=null&&s.planExpiresAt==null&&typeof s.plan=="string"&&s.plan!=="free"&&(s.subscriptionStatus==="active"||s.subscriptionStatus==="simulated")&&(i.planExpiresAt=h,s={...s,planExpiresAt:h})}}s.role?(a=s.role,i.role=a):(a=e.email===R4?"admin":"user",i.role=a),a==="user"&&!s.plan?i.plan="free":s.plan&&(i.plan=s.plan)}else a=e.email===R4?"admin":"user",i.role=a,a==="user"&&(i.plan="free");const o={...s,...i},l=bve(o,a);return i.plan=l.plan,i.csvBucksBalance=l.csvBucksBalance,i.batchLimit=l.batchLimit,l.csvBucksUsedToday!=null&&(i.csvBucksUsedToday=l.csvBucksUsedToday),l.lastCsvBucksReset!=null&&(i.lastCsvBucksReset=l.lastCsvBucksReset),s!=null&&s.subscriptionStatus&&(i.subscriptionStatus=s.subscriptionStatus),s!=null&&s.trialEndsAt&&(i.trialEndsAt=_I(s)??s.trialEndsAt),s!=null&&s.trialCouponCode&&(i.trialCouponCode=s.trialCouponCode),s!=null&&s.trialPlanId&&(i.trialPlanId=s.trialPlanId),s!=null&&s.lastCheckoutAt&&(i.lastCheckoutAt=s.lastCheckoutAt),s!=null&&s.planExpiresAt&&i.planExpiresAt===void 0&&(i.planExpiresAt=s.planExpiresAt),s!=null&&s.appliedCoupon&&(i.appliedCoupon=s.appliedCoupon),s!=null&&s.billingInterval&&(i.billingInterval=s.billingInterval),s!=null&&s.complementaryUsage&&(i.complementaryUsage=s.complementaryUsage),await Xxe(n,i,{merge:!0}),{...e,role:a,plan:l.plan,csvBucksBalance:l.csvBucksBalance,csvBucksUsedToday:l.csvBucksUsedToday,lastCsvBucksReset:l.lastCsvBucksReset,batchLimit:l.batchLimit,subscriptionStatus:s==null?void 0:s.subscriptionStatus,lastCheckoutAt:s==null?void 0:s.lastCheckoutAt,planExpiresAt:s==null?void 0:s.planExpiresAt,trialEndsAt:_I(s)??(s==null?void 0:s.trialEndsAt),trialCouponCode:s==null?void 0:s.trialCouponCode,trialPlanId:s==null?void 0:s.trialPlanId,appliedCoupon:s==null?void 0:s.appliedCoupon,billingInterval:s==null?void 0:s.billingInterval,complementaryUsage:s==null?void 0:s.complementaryUsage}}function MF(t){return t?t.role==="admin"?N4(yM):t.batchLimit!=null?N4(t.batchLimit):N4(tc(t.plan??"free").batchLimit):tc("free").batchLimit}function M4(t){return t?t.role==="admin"?t.csvBucksBalance??tc("max").csvBucks:t.csvBucksBalance??tc(t.plan??"free").csvBucks:0}/**
3217 * @license lucide-react v0.475.0 - ISC
3218 *
3219 * This source code is licensed under the ISC license.
3220 * See the LICENSE file in the root directory of this source tree.
3221 */const _ve=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),KX=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim();/**
3222 * @license lucide-react v0.475.0 - ISC
3223 *
3224 * This source code is licensed under the ISC license.
3225 * See the LICENSE file in the root directory of this source tree.
3226 */var Sve={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
3227 * @license lucide-react v0.475.0 - ISC
3228 *
3229 * This source code is licensed under the ISC license.
3230 * See the LICENSE file in the root directory of this source tree.
3231 */const Eve=q.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:r="",children:i,iconNode:a,...o},l)=>q.createElement("svg",{ref:l,...Sve,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:KX("lucide",r),...o},[...a.map(([c,h])=>q.createElement(c,h)),...Array.isArray(i)?i:[i]]));/**
3232 * @license lucide-react v0.475.0 - ISC
3233 *
3234 * This source code is licensed under the ISC license.
3235 * See the LICENSE file in the root directory of this source tree.
3236 */const It=(t,e)=>{const n=q.forwardRef(({className:s,...r},i)=>q.createElement(Eve,{ref:i,iconNode:e,className:KX(`lucide-${_ve(t)}`,s),...r}));return n.displayName=`${t}`,n};/**
3237 * @license lucide-react v0.475.0 - ISC
3238 *
3239 * This source code is licensed under the ISC license.
3240 * See the LICENSE file in the root directory of this source tree.
3241 */const Tve=[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]],PF=It("AlignCenterHorizontal",Tve);
3241/**
3242 * @license lucide-react v0.475.0 - ISC
3243 *
3244 * This source code is licensed under the ISC license.
3245 * See the LICENSE file in the root directory of this source tree.
3246 */const Ave=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]],$F=It("AlignCenterVertical",Ave);/**
3247 * @license lucide-react v0.475.0 - ISC
3248 *
3249 * This source code is licensed under the ISC license.
3250 * See the LICENSE file in the root directory of this source tree.
3251 */const Cve=[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],iD=It("AlignCenter",Cve);/**
3252 * @license lucide-react v0.475.0 - ISC
3253 *
3254 * This source code is licensed under the ISC license.
3255 * See the LICENSE file in the root directory of this source tree.
3256 */const kve=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],aD=It("AlignLeft",kve);/**
3257 * @license lucide-react v0.475.0 - ISC
3258 *
3259 * This source code is licensed under the ISC license.
3260 * See the LICENSE file in the root directory of this source tree.
3261 */const Ive=[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],oD=It("AlignRight",Ive);/**
3262 * @license lucide-react v0.475.0 - ISC
3263 *
3264 * This source code is licensed under the ISC license.
3265 * See the LICENSE file in the root directory of this source tree.
3266 */const Nve=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Rve=It("ArrowDown",Nve);/**
3267 * @license lucide-react v0.475.0 - ISC
3268 *
3269 * This source code is licensed under the ISC license.
3270 * See the LICENSE file in the root directory of this source tree.
3271 */const Mve=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],HL=It("ArrowLeft",Mve);/**
3272 * @license lucide-react v0.475.0 - ISC
3273 *
3274 * This source code is licensed under the ISC license.
3275 * See the LICENSE file in the root directory of this source tree.
3276 */const Pve=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],fE=It("ArrowRight",Pve);/**
3277 * @license lucide-react v0.475.0 - ISC
3278 *
3279 * This source code is licensed under the ISC license.
3280 * See the LICENSE file in the root directory of this source tree.
3281 */const $ve=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Dve=It("ArrowUp",$ve);/**
3282 * @license lucide-react v0.475.0 - ISC
3283 *
3284 * This source code is licensed under the ISC license.
3285 * See the LICENSE file in the root directory of this source tree.
3286 */const Ove=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],nw=It("Ban",Ove);/**
3287 * @license lucide-react v0.475.0 - ISC
3288 *
3289 * This source code is licensed under the ISC license.
3290 * See the LICENSE file in the root directory of this source tree.
3291 */const Lve=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],lD=It("Bold",Lve);/**
3292 * @license lucide-react v0.475.0 - ISC
3293 *
3294 * This source code is licensed under the ISC license.
3295 * See the LICENSE file in the root directory of this source tree.
3296 */const jve=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],GN=It("BookOpen",jve);/**
3297 * @license lucide-react v0.475.0 - ISC
3298 *
3299 * This source code is licensed under the ISC license.
3300 * See the LICENSE file in the root directory of this source tree.
3301 */const Bve=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],YX=It("ChartColumn",Bve);/**
3302 * @license lucide-react v0.475.0 - ISC
3303 *
3304 * This source code is licensed under the ISC license.
3305 * See the LICENSE file in the root directory of this source tree.
3306 */const Uve=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],yd=It("Check",Uve);/**
3307 * @license lucide-react v0.475.0 - ISC
3308 *
3309 * This source code is licensed under the ISC license.
3310 * See the LICENSE file in the root directory of this source tree.
3311 */const Fve=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],P0=It("ChevronDown",Fve);/**
3312 * @license lucide-react v0.475.0 - ISC
3313 *
3314 * This source code is licensed under the ISC license.
3315 * See the LICENSE file in the root directory of this source tree.
3316 */const Vve=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],qL=It("ChevronLeft",Vve);/**
3317 * @license lucide-react v0.475.0 - ISC
3318 *
3319 * This source code is licensed under the ISC license.
3320 * See the LICENSE file in the root directory of this source tree.
3321 */const zve=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],cD=It("ChevronRight",zve);/**
3322 * @license lucide-react v0.475.0 - ISC
3323 *
3324 * This source code is licensed under the ISC license.
3325 * See the LICENSE file in the root directory of this source tree.
3326 */const Gve=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],XX=It("ChevronUp",Gve);/**
3327 * @license lucide-react v0.475.0 - ISC
3328 *
3329 * This source code is licensed under the ISC license.
3330 * See the LICENSE file in the root directory of this source tree.
3331 */const Hve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],F0=It("CircleAlert",Hve);/**
3332 * @license lucide-react v0.475.0 - ISC
3333 *
3334 * This source code is licensed under the ISC license.
3335 * See the LICENSE file in the root directory of this source tree.
3336 */const qve=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],HN=It("CircleCheckBig",qve);/**
3337 * @license lucide-react v0.475.0 - ISC
3338 *
3339 * This source code is licensed under the ISC license.
3340 * See the LICENSE file in the root directory of this source tree.
3341 */const Wve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],uD=It("CircleCheck",Wve);/**
3342 * @license lucide-react v0.475.0 - ISC
3343 *
3344 * This source code is licensed under the ISC license.
3345 * See the LICENSE file in the root directory of this source tree.
3346 */const Kve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Yve=It("CircleDot",Kve);/**
3347 * @license lucide-react v0.475.0 - ISC
3348 *
3349 * This source code is licensed under the ISC license.
3350 * See the LICENSE file in the root directory of this source tree.
3351 */const Xve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Jve=It("CircleX",Xve);/**
3352 * @license lucide-react v0.475.0 - ISC
3353 *
3354 * This source code is licensed under the ISC license.
3355 * See the LICENSE file in the root directory of this source tree.
3356 */const Qve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],JX=It("Circle",Qve);/**
3357 * @license lucide-react v0.475.0 - ISC
3358 *
3359 * This source code is licensed under the ISC license.
3360 * See the LICENSE file in the root directory of this source tree.
3361 */const Zve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],EA=It("Clock",Zve);/**
3362 * @license lucide-react v0.475.0 - ISC
3363 *
3364 * This source code is licensed under the ISC license.
3365 * See the LICENSE file in the root directory of this source tree.
3366 */const ebe=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}
3366]],TA=It("CloudUpload",ebe);/**
3367 * @license lucide-react v0.475.0 - ISC
3368 *
3369 * This source code is licensed under the ISC license.
3370 * See the LICENSE file in the root directory of this source tree.
3371 */const tbe=[["path",{d:"M10 18H5a3 3 0 0 1-3-3v-1",key:"ru65g8"}],["path",{d:"M14 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"e30een"}],["path",{d:"M20 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"2ahx8o"}],["path",{d:"m7 21 3-3-3-3",key:"127cv2"}],["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}]],QX=It("Combine",tbe);/**
3372 * @license lucide-react v0.475.0 - ISC
3373 *
3374 * This source code is licensed under the ISC license.
3375 * See the LICENSE file in the root directory of this source tree.
3376 */const nbe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pE=It("Copy",nbe);/**
3377 * @license lucide-react v0.475.0 - ISC
3378 *
3379 * This source code is licensed under the ISC license.
3380 * See the LICENSE file in the root directory of this source tree.
3381 */const sbe=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}
3381],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],WL=It("Cpu",sbe);/**
3382 * @license lucide-react v0.475.0 - ISC
3383 *
3384 * This source code is licensed under the ISC license.
3385 * See the LICENSE file in the root directory of this source tree.
3386 */const rbe=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],DF=It("CreditCard",rbe);/**
3387 * @license lucide-react v0.475.0 - ISC
3388 *
3389 * This source code is licensed under the ISC license.
3390 * See the LICENSE file in the root directory of this source tree.
3391 */const ibe=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],abe=It("Diamond",ibe);/**
3392 * @license lucide-react v0.475.0 - ISC
3393 *
3394 * This source code is licensed under the ISC license.
3395 * See the LICENSE file in the root directory of this source tree.
3396 */const obe=[["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"}]],Ua=It("Download",obe);/**
3397 * @license lucide-react v0.475.0 - ISC
3398 *
3399 * This source code is licensed under the ISC license.
3400 * See the LICENSE file in the root directory of this source tree.
3401 */const lbe=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],cbe=It("Ellipsis",lbe);/**
3402 * @license lucide-react v0.475.0 - ISC
3403 *
3404 * This source code is licensed under the ISC license.
3405 * See the LICENSE file in the root directory of this source tree.
3406 */const ube=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],dbe=It("ExternalLink",ube);/**
3407 * @license lucide-react v0.475.0 - ISC
3408 *
3409 * This source code is licensed under the ISC license.
3410 * See the LICENSE file in the root directory of this source tree.
3411 */const hbe=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],dD=It("EyeOff",hbe);/**
3412 * @license lucide-react v0.475.0 - ISC
3413 *
3414 * This source code is licensed under the ISC license.
3415 * See the LICENSE file in the root directory of this source tree.
3416 */const fbe=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Yh=It("Eye",fbe);/**
3417 * @license lucide-react v0.475.0 - ISC
3418 *
3419 * This source code is licensed under the ISC license.
3420 * See the LICENSE file in the root directory of this source tree.
3421 */const pbe=[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]],KL=It("Facebook",pbe);
3421/**
3422 * @license lucide-react v0.475.0 - ISC
3423 *
3424 * This source code is licensed under the ISC license.
3425 * See the LICENSE file in the root directory of this source tree.
3426 */const mbe=[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]],ZX=It("FileStack",mbe);/**
3427 * @license lucide-react v0.475.0 - ISC
3428 *
3429 * This source code is licensed under the ISC license.
3430 * See the LICENSE file in the root directory of this source tree.
3431 */const gbe=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],mE=It("FileText",gbe);/**
3432 * @license lucide-react v0.475.0 - ISC
3433 *
3434 * This source code is licensed under the ISC license.
3435 * See the LICENSE file in the root directory of this source tree.
3436 */const ybe=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]],xbe=It("FileType",ybe);/**
3437 * @license lucide-react v0.475.0 - ISC
3438 *
3439 * This source code is licensed under the ISC license.
3440 * See the LICENSE file in the root directory of this source tree.
3441 */const vbe=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],bbe=It("File",vbe);/**
3442 * @license lucide-react v0.475.0 - ISC
3443 *
3444 * This source code is licensed under the ISC license.
3445 * See the LICENSE file in the root directory of this source tree.
3446 */const wbe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],YL=It("Globe",wbe);/**
3447 * @license lucide-react v0.475.0 - ISC
3448 *
3449 * This source code is licensed under the ISC license.
3450 * See the LICENSE file in the root directory of this source tree.
3451 */const _be=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Sbe=It("Grid3x3",_be);/**
3452 * @license lucide-react v0.475.0 - ISC
3453 *
3454 * This source code is licensed under the ISC license.
3455 * See the LICENSE file in the root directory of this source tree.
3456 */const Ebe=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],eJ=It("GripHorizontal",Ebe);/**
3457 * @license lucide-react v0.475.0 - ISC
3458 *
3459 * This source code is licensed under the ISC license.
3460 * See the LICENSE file in the root directory of this source tree.
3461 */const Tbe=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Abe=It("GripVertical",Tbe);/**
3462 * @license lucide-react v0.475.0 - ISC
3463 *
3464 * This source code is licensed under the ISC license.
3465 * See the LICENSE file in the root directory of this source tree.
3466 */const Cbe=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],tJ=It("Hand",Cbe);/**
3467 * @license lucide-react v0.475.0 - ISC
3468 *
3469 * This source code is licensed under the ISC license.
3470 * See the LICENSE file in the root directory of this source tree.
3471 */const kbe=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],Ibe=It("Hexagon",kbe);/**
3472 * @license lucide-react v0.475.0 - ISC
3473 *
3474 * This source code is licensed under the ISC license.
3475 * See the LICENSE file in the root directory of this source tree.
3476 */const Nbe=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],Rbe=It("House",Nbe);/**
3477 * @license lucide-react v0.475.0 - ISC
3478 *
3479 * This source code is licensed under the ISC license.
3480 * See the LICENSE file in the root directory of this source tree.
3481 */const Mbe=[["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"}]],bM=It("Image",Mbe);/**
3482 * @license lucide-react v0.475.0 - ISC
3483 *
3484 * This source code is licensed under the ISC license.
3485 * See the LICENSE file in the root directory of this source tree.
3486 */const Pbe=[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]],$be=It("Infinity",Pbe);/**
3487 * @license lucide-react v0.475.0 - ISC
3488 *
3489 * This source code is licensed under the ISC license.
3490 * See the LICENSE file in the root directory of this source tree.
3491 */const Dbe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Obe=It("Info",Dbe);/**
3492 * @license lucide-react v0.475.0 - ISC
3493 *
3494 * This source code is licensed under the ISC license.
3495 * See the LICENSE file in the root directory of this source tree.
3496 */const Lbe=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],hD=It("Italic",Lbe);/**
3497 * @license lucide-react v0.475.0 - ISC
3498 *
3499 * This source code is licensed under the ISC license.
3500 * See the LICENSE file in the root directory of this source tree.
3501 */const jbe=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],SI=It("Key",jbe);/**
3502 * @license lucide-react v0.475.0 - ISC
3503 *
3504 * This source code is licensed under the ISC license.
3505 * See the LICENSE file in the root directory of this source tree.
3506 */const Bbe=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Sd=It("Layers",Bbe);/**
3507 * @license lucide-react v0.475.0 - ISC
3508 *
3509 * This source code is licensed under the ISC license.
3510 * See the LICENSE file in the root directory of this source tree.
3511 */const Ube=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],wM=It("LayoutGrid",Ube);/**
3512 * @license lucide-react v0.475.0 - ISC
3513 *
3514 * This source code is licensed under the ISC license.
3515 * See the LICENSE file in the root directory of this source tree.
3516 */const Fbe=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],OF=It("Link2",Fbe);/**
3517 * @license lucide-react v0.475.0 - ISC
3518 *
3519 * This source code is licensed under the ISC license.
3520 * See the LICENSE file in the root directory of this source tree.
3521 */const Vbe=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],XL=It("Link",Vbe);/**
3522 * @license lucide-react v0.475.0 - ISC
3523 *
3524 * This source code is licensed under the ISC license.
3525 * See the LICENSE file in the root directory of this source tree.
3526 */const zbe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Go=It("LoaderCircle",zbe);/**
3527 * @license lucide-react v0.475.0 - ISC
3528 *
3529 * This source code is licensed under the ISC license.
3530 * See the LICENSE file in the root directory of this source tree.
3531 */const Gbe=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],LF=It("LockOpen",Gbe);/**
3532 * @license lucide-react v0.475.0 - ISC
3533 *
3534 * This source code is licensed under the ISC license.
3535 * See the LICENSE file in the root directory of this source tree.
3536 */const Hbe=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],j1=It("Lock",Hbe);/**
3537 * @license lucide-react v0.475.0 - ISC
3538 *
3539 * This source code is licensed under the ISC license.
3540 * See the LICENSE file in the root directory of this source tree.
3541 */const qbe=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],gE=It("LogIn",qbe);/**
3542 * @license lucide-react v0.475.0 - ISC
3543 *
3544 * This source code is licensed under the ISC license.
3545 * See the LICENSE file in the root directory of this source tree.
3546 */const Wbe=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],qN=It("LogOut",Wbe);/**
3547 * @license lucide-react v0.475.0 - ISC
3548 *
3549 * This source code is licensed under the ISC license.
3550 * See the LICENSE file in the root directory of this source tree.
3551 */const Kbe=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],B1=It("Mail",Kbe);/**
3552 * @license lucide-react v0.475.0 - ISC
3553 *
3554 * This source code is licensed under the ISC license.
3555 * See the LICENSE file in the root directory of this source tree.
3556 */const Ybe=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Xbe=It("MapPin",Ybe);/**
3557 * @license lucide-react v0.475.0 - ISC
3558 *
3559 * This source code is licensed under the ISC license.
3560 * See the LICENSE file in the root directory of this source tree.
3561 */const Jbe=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],AA=It("Maximize",Jbe);/**
3562 * @license lucide-react v0.475.0 - ISC
3563 *
3564 * This source code is licensed under the ISC license.
3565 * See the LICENSE file in the root directory of this source tree.
3566 */const Qbe=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],nJ=It("Menu",Qbe);/**
3567 * @license lucide-react v0.475.0 - ISC
3568 *
3569 * This source code is licensed under the ISC license.
3570 * See the LICENSE file in the root directory of this source tree.
3571 */const Zbe=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],sJ=It("MessageSquarePlus",Zbe);
3571/**
3572 * @license lucide-react v0.475.0 - ISC
3573 *
3574 * This source code is licensed under the ISC license.
3575 * See the LICENSE file in the root directory of this source tree.
3576 */const ewe=[["path",{d:"M5 12h14",key:"1ays0h"}]],twe=It("Minus",ewe);/**
3577 * @license lucide-react v0.475.0 - ISC
3578 *
3579 * This source code is licensed under the ISC license.
3580 * See the LICENSE file in the root directory of this source tree.
3581 */const nwe=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],fD=It("Monitor",nwe);/**
3582 * @license lucide-react v0.475.0 - ISC
3583 *
3584 * This source code is licensed under the ISC license.
3585 * See the LICENSE file in the root directory of this source tree.
3586 */const swe=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],pD=It("Moon",swe);/**
3587 * @license lucide-react v0.475.0 - ISC
3588 *
3589 * This source code is licensed under the ISC license.
3590 * See the LICENSE file in the root directory of this source tree.
3591 */const rwe=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],rJ=It("MousePointer2",rwe);/**
3592 * @license lucide-react v0.475.0 - ISC
3593 *
3594 * This source code is licensed under the ISC license.
3595 * See the LICENSE file in the root directory of this source tree.
3596 */const iwe=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],awe=It("Move",iwe);/**
3597 * @license lucide-react v0.475.0 - ISC
3598 *
3599 * This source code is licensed under the ISC license.
3600 * See the LICENSE file in the root directory of this source tree.
3601 */const owe=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],_M=It("Palette",owe);/**
3602 * @license lucide-react v0.475.0 - ISC
3603 *
3604 * This source code is licensed under the ISC license.
3605 * See the LICENSE file in the root directory of this source tree.
3606 */const lwe=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],jF=It("Pause",lwe);/**
3607 * @license lucide-react v0.475.0 - ISC
3608 *
3609 * This source code is licensed under the ISC license.
3610 * See the LICENSE file in the root directory of this source tree.
3611 */const cwe=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],mD=It("PenLine",cwe);/**
3612 * @license lucide-react v0.475.0 - ISC
3613 *
3614 * This source code is licensed under the ISC license.
3615 * See the LICENSE file in the root directory of this source tree.
3616 */const uwe=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]],JL=It("PenTool",uwe);/**
3617 * @license lucide-react v0.475.0 - ISC
3618 *
3619 * This source code is licensed under the ISC license.
3620 * See the LICENSE file in the root directory of this source tree.
3621 */const dwe=[["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"}]],QL=It("Pen",dwe);/**
3622 * @license lucide-react v0.475.0 - ISC
3623 *
3624 * This source code is licensed under the ISC license.
3625 * See the LICENSE file in the root directory of this source tree.
3626 */const hwe=[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]],fwe=It("Pentagon",hwe);/**
3627 * @license lucide-react v0.475.0 - ISC
3628 *
3629 * This source code is licensed under the ISC license.
3630 * See the LICENSE file in the root directory of this source tree.
3631 */const pwe=[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]],U1=It("Pipette",pwe);/**
3632 * @license lucide-react v0.475.0 - ISC
3633 *
3634 * This source code is licensed under the ISC license.
3635 * See the LICENSE file in the root directory of this source tree.
3636 */const mwe=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],F1=It("Play",mwe);/**
3637 * @license lucide-react v0.475.0 - ISC
3638 *
3639 * This source code is licensed under the ISC license.
3640 * See the LICENSE file in the root directory of this source tree.
3641 */const gwe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Tv=It("Plus",gwe);/**
3642 * @license lucide-react v0.475.0 - ISC
3643 *
3644 * This source code is licensed under the ISC license.
3645 * See the LICENSE file in the root directory of this source tree.
3646 */const ywe=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],BF=It("Redo2",ywe);/**
3647 * @license lucide-react v0.475.0 - ISC
3648 *
3649 * This source code is licensed under the ISC license.
3650 * See the LICENSE file in the root directory of this source tree.
3651 */const xwe=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Av=It("RefreshCw",xwe);/**
3652 * @license lucide-react v0.475.0 - ISC
3653 *
3654 * This source code is licensed under the ISC license.
3655 * See the LICENSE file in the root directory of this source tree.
3656 */const vwe=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Cv=It("RotateCw",vwe);/**
3657 * @license lucide-react v0.475.0 - ISC
3658 *
3659 * This source code is licensed under the ISC license.
3660 * See the LICENSE file in the root directory of this source tree.
3661 */const bwe=[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}
3661],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]],UF=It("Scale",bwe);/**
3662 * @license lucide-react v0.475.0 - ISC
3663 *
3664 * This source code is licensed under the ISC license.
3665 * See the LICENSE file in the root directory of this source tree.
3666 */const wwe=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],WN=It("Server",wwe);/**
3667 * @license lucide-react v0.475.0 - ISC
3668 *
3669 * This source code is licensed under the ISC license.
3670 * See the LICENSE file in the root directory of this source tree.
3671 */const _we=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],FF=It("Settings",_we);/**
3672 * @license lucide-react v0.475.0 - ISC
3673 *
3674 * This source code is licensed under the ISC license.
3675 * See the LICENSE file in the root directory of this source tree.
3676 */const Swe=[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]],VF=It("Shapes",Swe);/**
3677 * @license lucide-react v0.475.0 - ISC
3678 *
3679 * This source code is licensed under the ISC license.
3680 * See the LICENSE file in the root directory of this source tree.
3681 */const Ewe=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],gD=It("Share2",Ewe);/**
3682 * @license lucide-react v0.475.0 - ISC
3683 *
3684 * This source code is licensed under the ISC license.
3685 * See the LICENSE file in the root directory of this source tree.
3686 */const Twe=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],t_=It("ShieldCheck",Twe);/**
3687 * @license lucide-react v0.475.0 - ISC
3688 *
3689 * This source code is licensed under the ISC license.
3690 * See the LICENSE file in the root directory of this source tree.
3691 */const Awe=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],iJ=It("Shield",Awe);/**
3692 * @license lucide-react v0.475.0 - ISC
3693 *
3694 * This source code is licensed under the ISC license.
3695 * See the LICENSE file in the root directory of this source tree.
3696 */const Cwe=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],kwe=It("ShoppingCart",Cwe);/**
3697 * @license lucide-react v0.475.0 - ISC
3698 *
3699 * This source code is licensed under the ISC license.
3700 * See the LICENSE file in the root directory of this source tree.
3701 */const Iwe=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],Z0=It("SlidersHorizontal",Iwe);/**
3702 * @license lucide-react v0.475.0 - ISC
3703 *
3704 * This source code is licensed under the ISC license.
3705 * See the LICENSE file in the root directory of this source tree.
3706 */const Nwe=[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]],SM=It("SlidersVertical",Nwe);/**
3707 * @license lucide-react v0.475.0 - ISC
3708 *
3709 * This source code is licensed under the ISC license.
3710 * See the LICENSE file in the root directory of this source tree.
3711 */const Rwe=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],mp=It("Sparkles",Rwe);/**
3712 * @license lucide-react v0.475.0 - ISC
3713 *
3714 * This source code is licensed under the ISC license.
3715 * See the LICENSE file in the root directory of this source tree.
3716 */const Mwe=[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],xd=It("SquareCheckBig",Mwe);/**
3717 * @license lucide-react v0.475.0 - ISC
3718 *
3719 * This source code is licensed under the ISC license.
3720 * See the LICENSE file in the root directory of this source tree.
3721 */const Pwe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ZL=It("Square",Pwe);/**
3722 * @license lucide-react v0.475.0 - ISC
3723 *
3724 * This source code is licensed under the ISC license.
3725 * See the LICENSE file in the root directory of this source tree.
3726 */const $we=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],EM=It("Star",$we);/**
3727 * @license lucide-react v0.475.0 - ISC
3728 *
3729 * This source code is licensed under the ISC license.
3730 * See the LICENSE file in the root directory of this source tree.
3731 */const Dwe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],yD=It("Sun",Dwe);/**
3732 * @license lucide-react v0.475.0 - ISC
3733 *
3734 * This source code is licensed under the ISC license.
3735 * See the LICENSE file in the root directory of this source tree.
3736 */const Owe=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],e7=It("Tag",Owe);/**
3737 * @license lucide-react v0.475.0 - ISC
3738 *
3739 * This source code is licensed under the ISC license.
3740 * See the LICENSE file in the root directory of this source tree.
3741 */const Lwe=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]],$2=It("ToggleLeft",Lwe);/**
3742 * @license lucide-react v0.475.0 - ISC
3743 *
3744 * This source code is licensed under the ISC license.
3745 * See the LICENSE file in the root directory of this source tree.
3746 */const jwe=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]],D2=It("ToggleRight",jwe);/**
3747 * @license lucide-react v0.475.0 - ISC
3748 *
3749 * This source code is licensed under the ISC license.
3750 * See the LICENSE file in the root directory of this source tree.
3751 */const Bwe=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],xl=It("Trash2",Bwe);/**
3752 * @license lucide-react v0.475.0 - ISC
3753 *
3754 * This source code is licensed under the ISC license.
3755 * See the LICENSE file in the root directory of this source tree.
3756 */const Uwe=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],Fwe=It("TrendingUp",Uwe);/**
3757 * @license lucide-react v0.475.0 - ISC
3758 *
3759 * This source code is licensed under the ISC license.
3760 * See the LICENSE file in the root directory of this source tree.
3761 */const Vwe=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],S0=It("TriangleAlert",Vwe);/**
3762 * @license lucide-react v0.475.0 - ISC
3763 *
3764 * This source code is licensed under the ISC license.
3765 * See the LICENSE file in the root directory of this source tree.
3766 */const zwe=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],Gwe=It("Triangle",zwe);/**
3767 * @license lucide-react v0.475.0 - ISC
3768 *
3769 * This source code is licensed under the ISC license.
3770 * See the LICENSE file in the root directory of this source tree.
3771 */const Hwe=[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],TM=It("Type",Hwe);/**
3772 * @license lucide-react v0.475.0 - ISC
3773 *
3774 * This source code is licensed under the ISC license.
3775 * See the LICENSE file in the root directory of this source tree.
3776 */const qwe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],xD=It("Underline",qwe);/**
3777 * @license lucide-react v0.475.0 - ISC
3778 *
3779 * This source code is licensed under the ISC license.
3780 * See the LICENSE file in the root directory of this source tree.
3781 */const Wwe=[["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"}]],zF=It("Undo2",Wwe);/**
3782 * @license lucide-react v0.475.0 - ISC
3783 *
3784 * This source code is licensed under the ISC license.
3785 * See the LICENSE file in the root directory of this source tree.
3786 */const Kwe=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],yE=It("Upload",Kwe);/**
3787 * @license lucide-react v0.475.0 - ISC
3788 *
3789 * This source code is licensed under the ISC license.
3790 * See the LICENSE file in the root directory of this source tree.
3791 */const Ywe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}
3791],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]],GF=It("UserCheck",Ywe);/**
3792 * @license lucide-react v0.475.0 - ISC
3793 *
3794 * This source code is licensed under the ISC license.
3795 * See the LICENSE file in the root directory of this source tree.
3796 */const Xwe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Jwe=It("Users",Xwe);/**
3797 * @license lucide-react v0.475.0 - ISC
3798 *
3799 * This source code is licensed under the ISC license.
3800 * See the LICENSE file in the root directory of this source tree.
3801 */const Qwe=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],aJ=It("WandSparkles",Qwe);/**
3802 * @license lucide-react v0.475.0 - ISC
3803 *
3804 * This source code is licensed under the ISC license.
3805 * See the LICENSE file in the root directory of this source tree.
3806 */const Zwe=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],oJ=It("Wind",Zwe);/**
3807 * @license lucide-react v0.475.0 - ISC
3808 *
3809 * This source code is licensed under the ISC license.
3810 * See the LICENSE file in the root directory of this source tree.
3811 */const e1e=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ki=It("X",e1e);/**
3812 * @license lucide-react v0.475.0 - ISC
3813 *
3814 * This source code is licensed under the ISC license.
3815 * See the LICENSE file in the root directory of this source tree.
3816 */const t1e=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],vd=It("Zap",t1e);/**
3817 * @license lucide-react v0.475.0 - ISC
3818 *
3819 * This source code is licensed under the ISC license.
3820 * See the LICENSE file in the root directory of this source tree.
3821 */const n1e=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],s1e=It("ZoomIn",n1e),Ed=({className:t})=>d.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0 .68 0zm5.85 8.24l-2.22 10.53c-.16.7-.58.87-1.17.54l-3.24-2.39-1.56 1.5c-.17.17-.32.31-.65.31l.23-3.3 6-5.42c.26-.23-.06-.36-.41-.13l-7.42 4.67-3.2-1c-.7-.22-.71-.7.15-1.04l12.5-4.81c.57-.22 1.08.15.95.84z"})}),r1e=({className:t})=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":!0,children:[d.jsx("path",{d:"m10 16 4-4-4-4"}),d.jsx("path",{d:"M3 12h11"}),d.jsx("path",{d:"M3 8V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3"})]}),HF="csv_meta_theme_pref",P4=t=>t?"px-3 py-1.5 text-sm font-bold text-[#47ff72] transition-colors":"px-3 py-1.5 text-sm font-bold text-slate-600 dark:text-slate-300 hover:text-[#47ff72] transition-colors",$4=t=>t?"flex items-center justify-center gap-2 w-full p-3 border border-[#47ff72] text-[#47ff72] rounded-xl font-bold transition-colors":"flex items-center justify-center gap-2 w-full p-3 border border-slate-200 dark:border-slate-700 text-slate-800 dark:text-slate-200 hover:border-[#47ff72] hover:text-[#47ff72] rounded-xl font-bold transition-colors",V0=()=>{const[t,e]=q.useState(null),[n,s]=q.useState(!1),[r,i]=q.useState(!1),a=co(),o=Qh(),[l,c]=q.useState(()=>typeof window<"u"&&localStorage.getItem(HF)||"system"),[h,p]=q.useState(!1),m=o.pathname==="/pricing",y=o.pathname==="/tools",v=o.pathname==="/why-csv-meta";q.useEffect(()=>{const M=window.document.documentElement,j=()=>{let L=!1;l==="dark"?L=!0:l==="system"&&(L=window.matchMedia("(prefers-color-scheme: dark)").matches),L?M.classList.add("dark"):M.classList.remove("dark")};if(j(),localStorage.setItem(HF,l),l==="system"){const L=window.matchMedia("(prefers-color-scheme: dark)"),K=()=>j();return L.addEventListener("change",K),()=>L.removeEventListener("change",K)}},[l]),q.useEffect(()=>{const M=Vm(Ko,async j=>{if(j){const L=vM(j);e(L),localStorage.setItem("google_user_session",JSON.stringify(L));try{const K=await Vv(j);e(K),localStorage.setItem("google_user_session",JSON.stringify(K))}catch(K){console.error("Error saving user to Firestore",K)}}else e(null),localStorage.removeItem("google_user_session")});return()=>M()},[]);const b=async()=>{try{await BX()}catch(M){console.error("Logout failed",M)}s(!1),i(!1)},S=()=>{a("/auth")},E=()=>l==="light"?d.jsx(yD,{className:"w-5 h-5"}):l==="dark"?d.jsx(pD,{className:"w-5 h-5"}):d.jsx(fD,{className:"w-5 h-5"}),I=({isMobile:M=!1})=>d.jsxs("div",{className:"relative",children:[d.jsx("button",{onClick:()=>p(!h),className:`h-10 w-10 flex items-center justify-center rounded-lg transition-colors ${h?"text-[#47ff72]":"text-slate-500 hover:text-[#47ff72] dark:text-slate-400 dark:hover:text-[#47ff72]"}`,title:"Switch Theme",children:E()}),h&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>p(!1)}),d.jsx("div",{className:`absolute ${M?"left-0 top-full":"right-0 top-12"} mt-2 w-36 bg-white dark:bg-slate-900 rounded-xl shadow-xl border border-slate-200 dark:border-slate-700 z-50 overflow-hidden animate-in fade-in zoom-in-95 duration-200`,children:d.jsxs("div",{className:"p-1 space-y-1",children:[d.jsxs("button",{onClick:()=>{c("light"),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors ${l==="light"?"bg-[#47ff72]/10 text-[#47ff72]":"text-slate-700 dark:text-slate-300 hover:bg-slate-100 dar
3821k:hover:bg-slate-800"}`,children:[d.jsx(yD,{className:"w-4 h-4"})," Light"]}),d.jsxs("button",{onClick:()=>{c("dark"),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors ${l==="dark"?"bg-[#47ff72]/10 text-[#47ff72]":"text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800"}`,children:[d.jsx(pD,{className:"w-4 h-4"})," Dark"]}),d.jsxs("button",{onClick:()=>{c("system"),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors ${l==="system"?"bg-[#47ff72]/10 text-[#47ff72]":"text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800"}`,children:[d.jsx(fD,{className:"w-4 h-4"})," System"]})]})})]})]});return d.jsxs("header",{className:"bg-white dark:bg-green-950 border-b border-slate-200 dark:border-slate-800 sticky top-0 z-40 transition-colors duration-300",children:[d.jsxs("div",{className:"w-full px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between md:grid md:grid-cols-[1fr_auto_1fr] md:items-center",children:[d.jsx("div",{className:"flex items-center justify-start min-w-0",children:d.jsx(Is,{to:"/",className:"flex items-center",children:d.jsx("img",{src:"logo.png",alt:"CSV Meta",className:"h-10 md:h-12 w-auto object-contain"})})}),d.jsxs("nav",{className:"hidden md:flex items-center justify-center gap-1 lg:gap-3",children:[d.jsx(Is,{to:"/tools",className:P4(y),children:"Tools"}),d.jsx(Is,{to:"/why-csv-meta",className:P4(v),children:"Why CSV Meta"}),d.jsx(Is,{to:"/pricing",className:P4(m),children:"Pricing"})]}),d.jsxs("div",{className:"flex items-center justify-end gap-1 md:gap-3 shrink-0",children:[d.jsxs("div",{className:"hidden md:flex items-center gap-2 md:gap-3",children:[d.jsx(I,{}),!t&&d.jsxs("button",{onClick:S,className:"flex items-center justify-center gap-2 px-3 py-1.5 border border-[#47ff72] text-[#47ff72] rounded-lg font-bold transition-colors hover:bg-[#47ff72] hover:text-slate-900 text-sm h-[36px]",children:[d.jsx(gE,{className:"w-4 h-4"}),d.jsx("span",{children:"Sign In"})]}),d.jsx("div",{className:"w-px h-6 bg-slate-200 dark:bg-slate-700 mx-1"}),d.jsxs("a",{href:"https://t.me/csvmeta",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-2 border border-[#47ff72] text-[#47ff72] hover:bg-[#229ED9] hover:text-white rounded-lg transition-colors",children:[d.jsx(Ed,{className:"w-5 h-5"}),d.jsx("span",{className:"hidden lg:inline",children:"Find Us on Telegram"})]})]}),t&&d.jsxs("div",{className:"relative border-l border-slate-200 dark:border-slate-700 pl-3 ml-1 hidden md:block",children:[d.jsx("button",{onClick:()=>s(!n),className:"flex items-center gap-2 focus:outline-none",children:d.jsx("img",{src:t.picture,alt:"Profile",className:"w-8 h-8 rounded-full border-2 border-brand-500 shadow-sm hover:scale-105 transition-transform"})}),n&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>s(!1)}),d.jsxs("div",{className:"absolute right-0 top-12 mt-2 w-64 bg-white dark:bg-slate-900 rounded-xl shadow-xl border border-slate-200 dark:border-slate-700 z-50 overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:[d.jsxs("div",{className:"p-4 border-b border-slate-100 dark:border-slate-800 flex items-center gap-3",children:[d.jsx("img",{src:t.picture,alt:"Profile",className:"w-10 h-10 rounded-full border border-slate-200 dark:border-slate-700"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("h4",{className:"font-bold text-sm text-slate-800 dark:text-white truncate",children:t.name}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 truncate",children:t.email})]})]}),d.jsxs("div",{className:"p-2",children:[d.jsxs("button",{onClick:()=>{s(!1),a("/app")},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-lg transition-colors",children:[d.jsx(r1e,{className:"w-4 h-4"})," Go to App"]}),d.jsxs("button",{onClick:b,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors",children:[d.jsx(qN,{className:"w-4 h-4"}),"Sign Out"]})]})]})]})]}),d.jsxs("div",{className:"md:hidden flex items-center gap-1",children:[d.jsx(I,{isMobile:!0}),d.jsx("button",{onClick:()=>i(!r),className:"h-10 w-10 flex items-center justify-center rounded-lg text-slate-500 hover:text-[#47ff72] dark:text-slate-400 dark:hover:text-[#47ff72] transition-colors","aria-label":"Open menu",children:d.jsx(nJ,{className:"w-6 h-6"})})]})]})]}),r&&d.jsx("div",{className:"md:hidden absolute top-16 left-0 right-0 bg-white dark:bg-slate-900 border-b border-slate-200 dark:border-slate-800 shadow-xl z-50 animate-in slide-in-from-top duration-300",children:d.jsxs("div",{className:"p-4 space-y-4",children:[t?d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-xl",children:[d.jsx("img",{src:t.picture,alt:"Profile",className:"w-10 h-10 rounded-full border-2 border-brand-500"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("h4",{className:"font-bold text-sm text-slate-800 dark:text-white truncate",children:t.name}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 truncate",children:t.email})]}),d.jsx("button",{onClick:b,className:"p-2 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg",children:d.jsx(qN,{className:"w-5 h-5"})})]}),d.jsx("button",{onClick:()=>{i(!1),a("/app")}
3821,className:"flex items-center justify-center gap-2 w-full p-3 bg-[#47ff72] text-slate-900 rounded-xl font-bold transition-colors",children:"Go to Tool"})]}):d.jsxs("button",{onClick:S,className:"flex items-center justify-center gap-2 w-full p-3 border border-[#47ff72] text-[#47ff72] hover:bg-[#47ff72] hover:text-slate-900 rounded-xl font-bold transition-colors mb-2",children:[d.jsx(gE,{className:"w-5 h-5"}),d.jsx("span",{children:"Sign in with Google"})]}),d.jsx(Is,{to:"/tools",onClick:()=>i(!1),className:$4(y),children:"Tools"}),d.jsx(Is,{to:"/why-csv-meta",onClick:()=>i(!1),className:$4(v),children:"Why CSV Meta"}),d.jsx(Is,{to:"/pricing",onClick:()=>i(!1),className:$4(m),children:"Pricing"}),d.jsxs("a",{href:"https://t.me/csvmeta",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full p-3 bg-blue-500 text-white rounded-xl font-bold transition-colors",children:[d.jsx(Ed,{className:"w-5 h-5"})," Find Us on Telegram"]})]})})]})},AM=()=>d.jsx("footer",{className:"w-full py-6 mt-auto border-t border-slate-200 dark:border-slate-800 bg-white dark:bg-green-950/30 text-center transition-colors duration-300",children:d.jsxs("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:["Copyright ",new Date().getFullYear()," ",d.jsx("span",{className:"text-[#47ff72]",children:"CSV Meta"})," | All rights reserved |"," ",d.jsx(Is,{to:"/privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Privacy Policy"})," ","|"," ",d.jsx(Is,{to:"/terms-of-service",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Terms of Service"})," ","|"," ",d.jsx(Is,{to:"/promptgen-privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"PromptGen Privacy Policy"})]})}),lJ="csv_meta_header_banner_dismissed";function cJ(t){return`${t.id}:${t.activatedAt||t.updatedAt}`}function uJ(t){try{return localStorage.getItem(lJ)===cJ(t)}catch{return!1}}function i1e(t){try{localStorage.setItem(lJ,cJ(t))}catch{}}function qF(t){switch(t){case"left":return"justify-start text-left";case"right":return"justify-end text-right";default:return"justify-center text-center"}}function a1e(t){return t==="top"?"items-start":"items-center"}function o1e(t,e){return t==="both"||t===e}function l1e(t){return/^https?:\/\//i.test(t.trim())}const dJ=({banner:t,onDismiss:e})=>{const[n,s]=q.useState(()=>uJ(t)),{rectangle:r,textStyle:i,text:a,cta:o}=t,l=qF(i.align).split(" ").pop();if(n)return null;const c=()=>{i1e(t),s(!0),e==null||e()},h=o.enabled?l1e(o.url)?d.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center shrink-0 transition-opacity hover:opacity-90",style:{backgroundColor:o.backgroundColor,color:o.textColor,borderRadius:o.borderRadius,fontSize:o.fontSize,fontWeight:o.bold?700:500,paddingLeft:o.paddingX,paddingRight:o.paddingX,paddingTop:o.paddingY,paddingBottom:o.paddingY},children:o.text}):d.jsx(Is,{to:o.url||"/",className:"inline-flex items-center justify-center shrink-0 transition-opacity hover:opacity-90",style:{backgroundColor:o.backgroundColor,color:o.textColor,borderRadius:o.borderRadius,fontSize:o.fontSize,fontWeight:o.bold?700:500,paddingLeft:o.paddingX,paddingRight:o.paddingX,paddingTop:o.paddingY,paddingBottom:o.paddingY},children:o.text}):null;return d.jsxs("div",{className:"relative w-full pr-10",style:{backgroundColor:r.backgroundColor},children:[d.jsxs("div",{className:`mx-auto w-full flex gap-3 ${a1e(i.verticalAlign)} ${qF(i.align)}`,style:{maxWidth:r.maxWidth,minHeight:r.height>0?r.height:void 0,paddingLeft:r.paddingX,paddingRight:r.paddingX,paddingTop:r.paddingY,paddingBottom:r.paddingY,borderRadius:r.borderRadius},children:[d.jsx("p",{className:`leading-snug flex-1 min-w-0 ${l}`,style:{color:i.color,fontSize:i.fontSize,fontWeight:i.bold?700:500,fontStyle:i.italic?"italic":"normal",textDecoration:i.underline?"underline":"none"},children:a}),h]}),d.jsx("button",{type:"button","aria-label":"Close promo banner",onClick:c,className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 inline-flex items-center justify-center rounded-md p-1.5 transition-opacity hover:opacity-70",style:{color:i.color},children:d.jsx(Ki,{className:"w-4 h-4",strokeWidth:2.5})})]})},t7=q.createContext({});function n7(t){const e=q.useRef(null);return e.current===null&&(e.current=t()),e.current}
vendor: 29,863 bytes, line 3821
3821const c1e=typeof window<"u",hJ=c1e?q.useLayoutEffect:q.useEffect,CM=q.createContext(null);function s7(t,e){t.indexOf(e)===-1&&t.push(e)}function KN(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const gp=(t,e,n)=>n>e?e:n<t?t:n;let r7=()=>{};const z0={},fJ=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function pJ(t){return typeof t=="object"&&t!==null}const mJ=t=>/^0[^.\s]+$/u.test(t);function gJ(t){let e;return()=>(e===void 0&&(e=t()),e)}const bd=t=>t,u1e=(t,e)=>n=>e(t(n)),CA=(...t)=>t.reduce(u1e),xE=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class i7{constructor(){this.subscriptions=[]}add(e){return s7(this.subscriptions,e),()=>KN(this.subscriptions,e)}notify(e,n,s){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,n,s);else for(let i=0;i<r;i++){const a=this.subscriptions[i];a&&a(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Nu=t=>t*1e3,gd=t=>t/1e3;function yJ(t,e){return e?t*(1e3/e):0}const xJ=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,d1e=1e-7,h1e=12;function f1e(t,e,n,s,r){let i,a,o=0;do a=e+(n-e)/2,i=xJ(a,s,r)-t,i>0?n=a:e=a;while(Math.abs(i)>d1e&&++o<h1e);return a}function kA(t,e,n,s){if(t===e&&n===s)return bd;const r=i=>f1e(i,0,1,t,n);return i=>i===0||i===1?i:xJ(r(i),e,s)}const vJ=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,bJ=t=>e=>1-t(1-e),wJ=kA(.33,1.53,.69,.99),a7=bJ(wJ),_J=vJ(a7),SJ=t=>t>=1?1:(t*=2)<1?.5*a7(t):.5*(2-Math.pow(2,-10*(t-1))),o7=t=>1-Math.sin(Math.acos(t)),EJ=bJ(o7),TJ=vJ(o7),p1e=kA(.42,0,1,1),m1e=kA(0,0,.58,1),AJ=kA(.42,0,.58,1),g1e=t=>Array.isArray(t)&&typeof t[0]!="number",CJ=t=>Array.isArray(t)&&typeof t[0]=="number",y1e={linear:bd,easeIn:p1e,easeInOut:AJ,easeOut:m1e,circIn:o7,circInOut:TJ,circOut:EJ,backIn:a7,backInOut:_J,backOut:wJ,anticipate:SJ},x1e=t=>typeof t=="string",WF=t=>{if(CJ(t)){r7(t.length===4);const[e,n,s,r]=t;return kA(e,n,s,r)}else if(x1e(t))return y1e[t];return t},Mk=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function v1e(t,e){let n=new Set,s=new Set,r=!1,i=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(h){a.has(h)&&(c.schedule(h),t()),h(o)}const c={schedule:(h,p=!1,m=!1)=>{const v=m&&r?n:s;return p&&a.add(h),v.add(h),h},cancel:h=>{s.delete(h),a.delete(h)},process:h=>{if(o=h,r){i=!0;return}r=!0;const p=n;n=s,s=p,n.forEach(l),n.clear(),r=!1,i&&(i=!1,c.process(h))}};return c}const b1e=40;function kJ(t,e){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,a=Mk.reduce((M,j)=>(M[j]=v1e(i),M),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:h,update:p,preRender:m,render:y,postRender:v}=a,b=()=>{const M=z0.useManualTiming,j=M?r.timestamp:performance.now();n=!1,M||(r.delta=s?1e3/60:Math.max(Math.min(j-r.timestamp,b1e),1)),r.timestamp=j,r.isProcessing=!0,o.process(r),l.process(r),c.process(r),h.process(r),p.process(r),m.process(r),y.process(r),v.process(r),r.isProcessing=!1,n&&e&&(s=!1,t(b))},S=()=>{n=!0,s=!0,r.isProcessing||t(b)};return{schedule:Mk.reduce((M,j)=>{const L=a[j];return M[j]=(K,D=!1,R=!1)=>(n||S(),L.schedule(K,D,R)),M},{}),cancel:M=>{for(let j=0;j<Mk.length;j++)a[Mk[j]].cancel(M)},state:r,steps:a}}const{schedule:pi,cancel:G0,state:Uo,steps:D4}=kJ(typeof requestAnimationFrame<"u"?requestAnimationFrame:bd,!0);let EI;function w1e(){EI=void 0}const Zl={now:()=>(EI===void 0&&Zl.set(Uo.isProcessing||z0.useManualTiming?Uo.timestamp:performance.now()),EI),set:t=>{EI=t,queueMicrotask(w1e)}},IJ=t=>e=>typeof e=="string"&&e.startsWith(t),NJ=IJ("--"),_1e=IJ("var(--"),l7=t=>_1e(t)?S1e.test(t.split("/*")[0].trim()):!1,S1e=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function KF(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const n_={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},vE={...n_,transform:t=>gp(0,1,t)},Pk={...n_,default:1},US=t=>Math.round(t*1e5)/1e5,c7=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function E1e(t){return t==null}const T1e=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,u7=(t,e)=>n=>!!(typeof n=="string"&&T1e.test(n)&&n.startsWith(t)||e&&!E1e(n)&&Object.prototype.hasOwnProperty.call(n,e)),RJ=(t,e,n)=>s=>{if(typeof s!="string")return s;const[r,i,a,o]=s.match(c7);return{[t]:parseFloat(r),[e]:parseFloat(i),[n]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},A1e=t=>gp(0,255,t),O4={...n_,transform:t=>Math.round(A1e(t))},nx={test:u7("rgb","red"),parse:RJ("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+O4.transform(t)+", "+O4.transform(e)+", "+O4.transform(n)+", "+US(vE.transform(s))+")"};function C1e(t){let e="",n="",s="",r="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),r=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),r=t.substring(4,5),e+=e,n+=n,s+=s,r+=r),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}}const vD={test:u7("#"),parse:C1e,transform:nx.transform},IA=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Og=IA("deg"),up=IA("%"),In=IA("px"),k1e=IA("vh"),I1e=IA("vw"),YF={...up,parse:t=>up.parse(t)/100,transform:t=>up.transform(t*100)},sw={test:u7("hsl","hue"),parse:RJ("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+up.transform(US(e))+", "+up.transform(US(n))+", "+US(vE.transform(s))+")"},Da={test:t=>nx.test(t)||vD.test(t)||sw.test(t),parse:t=>nx.test(t)?nx.parse(t):sw.test(t)?sw.parse(t):vD.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?nx.transform(t):sw.transform(t),getAnimatableNone:t=>{const e=Da.parse(t);return e.alpha=0,Da.transform(e)}},N1e=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function R1e(t){var e,n;return isNaN(t)&&typeof t=="string"&&(((e=t.match(c7))==null?void 0:e.length)||0)+(((n=t.match(N1e))==null?void 0:n.length)||0)>0}const MJ="number",PJ="color",M1e="var",P1e="var(",XF="${}",$1e=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function V1(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},r=[];let i=0;const o=e.replace($1e,l=>(Da.test(l)?(s.color.push(i),r.push(PJ),n.push(Da.parse(l))):l.startsWith(P1e)?(s.var.push(i),r.push(M1e),n.push(l)):(s.number.push(i),r.push(MJ),n.push(parseFloat(l))),++i,XF)).split(XF);return{values:n,split:o,indexes:s,types:r}}function D1e(t){return V1(t).values}function $J({split:t,types:e}){const n=t.length;return s=>{let r="";for(let i=0;i<n;i++)if(r+=t[i],s[i]!==void 0){const a=e[i];a===MJ?r+=US(s[i]):a===PJ?r+=Da.transform(s[i]):r+=s[i]}return r}}function O1e(t){return $J(V1(t))}const L1e=t=>typeof t=="number"?0:Da.test(t)?Da.getAnimatableNone(t):t,j1e=(t,e)=>typeof t=="number"?e!=null&&e.trim().endsWith("/")?t:0:L1e(t);function B1e(t){const e=V1(t);return $J(e)(e.values.map((s,r)=>j1e(s,e.split[r])))}const Wh={test:R1e,parse:D1e,createTransformer:O1e,getAnimatableNone:B1e};function L4(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function U1e({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let r=0,i=0,a=0;if(!e)r=i=a=n;else{const o=n<.5?n*(1+e):n+e-n*e,l=2*n-o;r=L4(l,o,t+1/3),i=L4(l,o,t),a=L4(l,o,t-1/3)}return{red:Math.round(r*255),green:Math.round(i*255),blue:Math.round(a*255),alpha:s}}function YN(t,e){return n=>n>0?e:t}const Li=(t,e,n)=>t+(e-t)*n,j4=(t,e,n)=>{const s=t*t,r=n*(e*e-s)+s;return r<0?0:Math.sqrt(r)},F1e=[vD,nx,sw],V1e=t=>F1e.find(e=>e.test(t));function JF(t){const e=V1e(t);if(!e)return!1;let n=e.parse(t);return e===sw&&(n=U1e(n)),n}const QF=(t,e)=>{const n=JF(t),s=JF(e);if(!n||!s)return YN(t,e);const r={...n};return i=>(r.red=j4(n.red,s.red,i),r.green=j4(n.green,s.green,i),r.blue=j4(n.blue,s.blue,i),r.alpha=Li(n.alpha,s.alpha,i),nx.transform(r))},bD=new Set(["none","hidden"]);function z1e(t,e){return bD.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function G1e(t,e){return n=>Li(t,e,n)}function d7(t){return typeof t=="number"?G1e:typeof t=="string"?l7(t)?YN:Da.test(t)?QF:W1e:Array.isArray(t)?DJ:typeof t=="object"?Da.test(t)?QF:H1e:YN}function DJ(t,e){const n=[...t],s=n.length,r=t.map((i,a)=>d7(i)(i,e[a]));return i=>{for(let a=0;a<s;a++)n[a]=r[a](i);return n}}function H1e(t,e){const n={...t,...e},s={};for(const r in n)t[r]!==void 0&&e[r]!==void 0&&(s[r]=d7(t[r])(t[r],e[r]));return r=>{for(const i in s)n[i]=s[i](r);return n}}function q1e(t,e){const n=[],s={color:0,var:0,number:0};for(let r=0;r<e.values.length;r++){const i=e.types[r],a=t.indexes[i][s[i]],o=t.values[a]??0;n[r]=o,s[i]++}return n}const W1e=(t,e)=>{const n=Wh.createTransformer(e),s=V1(t),r=V1(e);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?bD.has(t)&&!r.values.length||bD.has(e)&&!s.values.length?z1e(t,e):CA(DJ(q1e(s,r),r.values),n):YN(t,e)};function OJ(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Li(t,e,n):d7(t)(t,e)}const K1e=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>pi.update(e,n),stop:()=>G0(e),now:()=>Uo.isProcessing?Uo.timestamp:Zl.now()}},LJ=(t,e,n=10)=>{let s="";const r=Math.max(Math.round(e/n),2);for(let i=0;i<r;i++)s+=Math.round(t(i/(r-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},XN=2e4;function h7(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<XN;)e+=n,s=t.next(e);return e>=XN?1/0:e}function Y1e(t,e=100,n){const s=n({...t,keyframes:[0,e]}),r=Math.min(h7(s),XN);return{type:"keyframes",ease:i=>s.next(r*i).value/e,duration:gd(r)}}const ha={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function wD(t,e){return t*Math.sqrt(1-e*e)}const X1e=12;function J1e(t,e,n){let s=n;for(let r=1;r<X1e;r++)s=s-t(s)/e(s);return s}const B4=.001;function Q1e({duration:t=ha.duration,bounce:e=ha.bounce,velocity:n=ha.velocity,mass:s=ha.mass}){let r,i,a=1-e;a=gp(ha.minDamping,ha.maxDamping,a),t=gp(ha.minDuration,ha.maxDuration,gd(t)),a<1?(r=c=>{const h=c*a,p=h*t,m=h-n,y=wD(c,a),v=Math.exp(-p);return B4-m/y*v},i=c=>{const p=c*a*t,m=p*n+n,y=Math.pow(a,2)*Math.pow(c,2)*t,v=Math.exp(-p),b=wD(Math.pow(c,2),a);return(-r(c)+B4>0?-1:1)*((m-y)*v)/b}):(r=c=>{const h=Math.exp(-c*t),p=(c-n)*t+1;return-B4+h*p},i=c=>{const h=Math.exp(-c*t),p=(n-c)*(t*t);return h*p});const o=5/t,l=J1e(r,i,o);if(t=Nu(t),isNaN(l))return{stiffness:ha.stiffness,damping:ha.damping,duration:t};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:a*2*Math.sqrt(s*c),duration:t}}}const Z1e=["duration","bounce"],e_e=["stiffness","damping","mass"];function ZF(t,e){return e.some(n=>t[n]!==void 0)}function t_e(t){let e={velocity:ha.velocity,stiffness:ha.stiffness,damping:ha.damping,mass:ha.mass,isResolvedFromDuration:!1,...t};if(!ZF(t,e_e)&&ZF(t,Z1e))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,i=2*gp(.05,1,1-(t.bounce||0))*Math.sqrt(r);e={...e,mass:ha.mass,stiffness:r,damping:i}}else{const n=Q1e({...t,velocity:0});e={...e,...n,mass:ha.mass},e.isResolvedFromDuration=!0}return e}function JN(t=ha.visualDuration,e=ha.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:r}=n;const i=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],o={done:!1,value:i},{stiffness:l,damping:c,mass:h,duration:p,velocity:m,isResolvedFromDuration:y}=t_e({...n,velocity:-gd(n.velocity||0)}),v=m||0,b=c/(2*Math.sqrt(l*h)),S=a-i,E=gd(Math.sqrt(l/h)),I=Math.abs(S)<5;s||(s=I?ha.restSpeed.granular:ha.restSpeed.default),r||(r=I?ha.restDelta.granular:ha.restDelta.default);let M,j,L,K,D,R;if(b<1)L=wD(E,b),K=(v+b*E*S)/L,M=G=>{const X=Math.exp(-b*E*G);return a-X*(K*Math.sin(L*G)+S*Math.cos(L*G))},D=b*E*K+S*L,R=b*E*S-K*L,j=G=>Math.exp(-b*E*G)*(D*Math.sin(L*G)+R*Math.cos(L*G));else if(b===1){M=X=>a-Math.exp(-E*X)*(S+(v+E*S)*X);const G=v+E*S;j=X=>Math.exp(-E*X)*(E*G*X-v)}else{const G=E*Math.sqrt(b*b-1);M=F=>{const we=Math.exp(-b*E*F),me=Math.min(G*F,300);return a-we*((v+b*E*S)*Math.sinh(me)+G*S*Math.cosh(me))/G};const X=(v+b*E*S)/G,H=b*E*X-S*G,Y=b*E*S-X*G;j=F=>{const we=Math.exp(-b*E*F),me=Math.min(G*F,300);return we*(H*Math.sinh(me)+Y*Math.cosh(me))}}const B={calculatedDuration:y&&p||null,velocity:G=>Nu(j(G)),next:G=>{if(!y&&b<1){const H=Math.exp(-b*E*G),Y=Math.sin(L*G),F=Math.cos(L*G),we=a-H*(K*Y+S*F),me=Nu(H*(D*Y+R*F));return o.done=Math.abs(me)<=s&&Math.abs(a-we)<=r,o.value=o.done?a:we,o}const X=M(G);if(y)o.done=G>=p;else{const H=Nu(j(G));o.done=Math.abs(H)<=s&&Math.abs(a-X)<=r}return o.value=o.done?a:X,o},toString:()=>{const G=Math.min(h7(B),XN),X=LJ(H=>B.next(G*H).value,G,30);return G+"ms "+X},toTransition:()=>{}};return B}JN.applyToOptions=t=>{const e=Y1e(t,100,JN);return t.ease=e.ease,t.duration=Nu(e.duration),t.type="keyframes",t};const n_e=5;function jJ(t,e,n){const s=Math.max(e-n_e,0);return yJ(n-t(s),e-s)}function _D({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:i=500,modifyTarget:a,min:o,max:l,restDelta:c=.5,restSpeed:h}){const p=t[0],m={done:!1,value:p},y=R=>o!==void 0&&R<o||l!==void 0&&R>l,v=R=>o===void 0?l:l===void 0||Math.abs(o-R)<Math.abs(l-R)?o:l;let b=n*e;const S=p+b,E=a===void 0?S:a(S);E!==S&&(b=E-p);const I=R=>-b*Math.exp(-R/s),M=R=>E+I(R),j=R=>{const B=I(R),G=M(R);m.done=Math.abs(B)<=c,m.value=m.done?E:G};let L,K;const D=R=>{y(m.value)&&(L=R,K=JN({keyframes:[m.value,v(m.value)],velocity:jJ(M,R,m.value),damping:r,stiffness:i,restDelta:c,restSpeed:h}))};return D(0),{calculatedDuration:null,next:R=>{let B=!1;return!K&&L===void 0&&(B=!0,j(R),D(R)),L!==void 0&&R>=L?K.next(R-L):(!B&&j(R),m)}}}function s_e(t,e,n){const s=[],r=n||z0.mix||OJ,i=t.length-1;for(let a=0;a<i;a++){let o=r(t[a],t[a+1]);if(e){const l=Array.isArray(e)?e[a]||bd:e;o=CA(l,o)}s.push(o)}return s}function r_e(t,e,{clamp:n=!0,ease:s,mixer:r}={}){const i=t.length;if(r7(i===e.length),i===1)return()=>e[0];if(i===2&&e[0]===e[1])return()=>e[1];const a=t[0]===t[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const o=s_e(e,s,r),l=o.length,c=h=>{if(a&&h<t[0])return e[0];let p=0;if(l>1)for(;p<t.length-2&&!(h<t[p+1]);p++);const m=xE(t[p],t[p+1],h);return o[p](m)};return n?h=>c(gp(t[0],t[i-1],h)):c}function i_e(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const r=xE(0,e,s);t.push(Li(n,1,r))}}function a_e(t){const e=[0];return i_e(e,t.length-1),e}function o_e(t,e){return t.map(n=>n*e)}function l_e(t,e){return t.map(()=>e||AJ).splice(0,t.length-1)}function FS({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const r=g1e(s)?s.map(WF):WF(s),i={done:!1,value:e[0]},a=o_e(n&&n.length===e.length?n:a_e(e),t),o=r_e(a,e,{ease:Array.isArray(r)?r:l_e(e,r)});return{calculatedDuration:t,next:l=>(i.value=o(l),i.done=l>=t,i)}}const c_e=t=>t!==null;function kM(t,{repeat:e,repeatType:n="loop"},s,r=1){const i=t.filter(c_e),o=r<0||e&&n!=="loop"&&e%2===1?0:i.length-1;return!o||s===void 0?i[o]:s}const u_e={decay:_D,inertia:_D,tween:FS,keyframes:FS,spring:JN};function BJ(t){typeof t.type=="string"&&(t.type=u_e[t.type])}class f7{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const d_e=t=>t/100;class QN extends f7{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var s,r;const{motionValue:n}=this.options;n&&n.updatedAt!==Zl.now()&&this.tick(Zl.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(r=(s=this.options).onStop)==null||r.call(s))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;BJ(e);const{type:n=FS,repeat:s=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e;let{keyframes:o}=e;const l=n||FS;l!==FS&&typeof o[0]!="number"&&(this.mixKeyframes=CA(d_e,OJ(o[0],o[1])),o=[0,100]);const c=l({...e,keyframes:o});i==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=h7(c));const{calculatedDuration:h}=c;this.calculatedDuration=h,this.resolvedDuration=h+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=c}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:c=0,keyframes:h,repeat:p,repeatType:m,repeatDelay:y,type:v,onUpdate:b,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const E=this.currentTime-c*(this.playbackSpeed>=0?1:-1),I=this.playbackSpeed>=0?E<0:E>r;this.currentTime=Math.max(E,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let M=this.currentTime,j=s;if(p){const R=Math.min(this.currentTime,r)/o;let B=Math.floor(R),G=R%1;!G&&R>=1&&(G=1),G===1&&B--,B=Math.min(B,p+1),!!(B%2)&&(m==="reverse"?(G=1-G,y&&(G-=y/o)):m==="mirror"&&(j=a)),M=gp(0,1,G)*o}let L;I?(this.delayState.value=h[0],L=this.delayState):L=j.next(M),i&&!I&&(L.value=i(L.value));let{done:K}=L;!I&&l!==null&&(K=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const D=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&K);return D&&v!==_D&&(L.value=kM(h,this.options,S,this.speed)),b&&b(L.value),D&&this.finish(),L}then(e,n){return this.finished.then(e,n)}get duration(){return gd(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+gd(e)}get time(){return gd(this.currentTime)}set time(e){e=Nu(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const n=this.generator.next(e).value;return jJ(s=>this.generator.next(s).value,e,n)}get speed(){return this.playbackSpeed}set speed(e){const n=this.playbackSpeed!==e;n&&this.driver&&this.updateTime(Zl.now()),this.playbackSpeed=e,n&&this.driver&&(this.time=gd(this.currentTime))}play(){var r,i;if(this.isStopped)return;const{driver:e=K1e,startTime:n}=this.options;this.driver||(this.driver=e(a=>this.tick(a))),(i=(r=this.options).onPlay)==null||i.call(r);const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Zl.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(e=this.options).onComplete)==null||n.call(e)}cancel(){var e,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(e=this.options).onCancel)==null||n.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),e.observe(this)}}function h_e(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const sx=t=>t*180/Math.PI,SD=t=>{const e=sx(Math.atan2(t[1],t[0]));return ED(e)},f_e={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:SD,rotateZ:SD,skewX:t=>sx(Math.atan(t[1])),skewY:t=>sx(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},ED=t=>(t=t%360,t<0&&(t+=360),t),eV=SD,tV=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),nV=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),p_e={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:tV,scaleY:nV,scale:t=>(tV(t)+nV(t))/2,rotateX:t=>ED(sx(Math.atan2(t[6],t[5]))),rotateY:t=>ED(sx(Math.atan2(-t[2],t[0]))),rotateZ:eV,rotate:eV,skewX:t=>sx(Math.atan(t[4])),skewY:t=>sx(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function TD(t){return t.includes("scale")?1:0}function AD(t,e){if(!t||t==="none")return TD(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=p_e,r=n;else{const o=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=f_e,r=o}if(!r)return TD(e);const i=s[e],a=r[1].split(",").map(g_e);return typeof i=="function"?i(a):a[i]}const m_e=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return AD(n,e)};function g_e(t){return parseFloat(t.trim())}const s_=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],r_=new Set(s_),sV=t=>t===n_||t===In,y_e=new Set(["x","y","z"]),x_e=s_.filter(t=>!y_e.has(t));function v_e(t){const e=[];return x_e.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const E0={width:({x:t},{paddingLeft:e="0",paddingRight:n="0",boxSizing:s})=>{const r=t.max-t.min;return s==="border-box"?r:r-parseFloat(e)-parseFloat(n)},height:({y:t},{paddingTop:e="0",paddingBottom:n="0",boxSizing:s})=>{const r=t.max-t.min;return s==="border-box"?r:r-parseFloat(e)-parseFloat(n)},top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>AD(e,"x"),y:(t,{transform:e})=>AD(e,"y")};E0.translateX=E0.x;E0.translateY=E0.y;const hv=new Set;let CD=!1,kD=!1,ID=!1;function UJ(){if(kD){const t=Array.from(hv).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const r=v_e(s);r.length&&(n.set(s,r),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const r=n.get(s);r&&r.forEach(([i,a])=>{var o;(o=s.getValue(i))==null||o.set(a)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}kD=!1,CD=!1,hv.forEach(t=>t.complete(ID)),hv.clear()}function FJ(){hv.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(kD=!0)})}function b_e(){ID=!0,FJ(),UJ(),ID=!1}class p7{constructor(e,n,s,r,i,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(hv.add(this),CD||(CD=!0,pi.read(FJ),pi.resolveKeyframes(UJ))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:r}=this;if(e[0]===null){const i=r==null?void 0:r.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(s&&n){const o=s.readValue(n,a);o!=null&&(e[0]=o)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}h_e(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),hv.delete(this)}cancel(){this.state==="scheduled"&&(hv.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const w_e=t=>t.startsWith("--");function VJ(t,e,n){w_e(e)?t.style.setProperty(e,n):t.style[e]=n}const __e={};function zJ(t,e){const n=gJ(t);return()=>__e[e]??n()}const S_e=zJ(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),GJ=zJ(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),lS=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,rV={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:lS([0,.65,.55,1]),circOut:lS([.55,0,1,.45]),backIn:lS([.31,.01,.66,-.59]),backOut:lS([.33,1.53,.69,.99])};function HJ(t,e){if(t)return typeof t=="function"?GJ()?LJ(t,e):"ease-out":CJ(t)?lS(t):Array.isArray(t)?t.map(n=>HJ(n,e)||rV.easeOut):rV[t]}function E_e(t,e,n,{delay:s=0,duration:r=300,repeat:i=0,repeatType:a="loop",ease:o="easeOut",times:l}={},c=void 0){const h={[e]:n};l&&(h.offset=l);const p=HJ(o,r);Array.isArray(p)&&(h.easing=p);const m={delay:s,duration:r,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:i+1,direction:a==="reverse"?"alternate":"normal"};return c&&(m.pseudoElement=c),t.animate(h,m)}function qJ(t){return typeof t=="function"&&"applyToOptions"in t}function T_e({type:t,...e}){return qJ(t)&&GJ()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class WJ extends f7{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:s,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:l}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,r7(typeof e.type!="string");const c=T_e(e);this.animation=E_e(n,s,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const h=kM(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(h),VJ(n,s,h),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,n;(n=(e=this.animation).finish)==null||n.call(e)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,s,r;const e=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(e!=null&&e.isConnected)&&((r=(s=this.animation).commitStyles)==null||r.call(s))}get duration(){var n,s;const e=((s=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:s.call(n).duration)||0;return gd(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+gd(e)}get time(){return gd(Number(this.animation.currentTime)||0)}set time(e){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Nu(e),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:n,rangeEnd:s,observe:r}){var i;return this.allowFlatten&&((i=this.animation.effect)==null||i.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&S_e()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),s&&(this.animation.rangeEnd=s),bd):r(this)}}const KJ={anticipate:SJ,backInOut:_J,circInOut:TJ};function A_e(t){return t in KJ}function C_e(t){typeof t.ease=="string"&&A_e(t.ease)&&(t.ease=KJ[t.ease])}const U4=10;class k_e extends WJ{constructor(e){C_e(e),BJ(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:r,element:i,...a}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const o=new QN({...a,autoplay:!1}),l=Math.max(U4,Zl.now()-this.startTime),c=gp(0,U4,l-U4),h=o.sample(l).value,{name:p}=this.options;i&&p&&VJ(i,p,h),n.setWithVelocity(o.sample(Math.max(0,l-c)).value,h,c),o.stop()}}const iV=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Wh.test(t)||t==="0")&&!t.startsWith("url("));function I_e(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function N_e(t,e,n,s){const r=t[0];if(r===null)return!1;if(e==="display"||e==="visibility")return!0;const i=t[t.length-1],a=iV(r,e),o=iV(i,e);return!a||!o?!1:I_e(t)||(n==="spring"||qJ(n))&&s}function ND(t){t.duration=0,t.type="keyframes"}const YJ=new Set(["opacity","clipPath","filter","transform"]),R_e=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function M_e(t){for(let e=0;e<t.length;e++)if(typeof t[e]=="string"&&R_e.test(t[e]))return!0;return!1}const P_e=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),$_e=gJ(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function D_e(t){var p;const{motionValue:e,name:n,repeatDelay:s,repeatType:r,damping:i,type:a,keyframes:o}=t;if(!(((p=e==null?void 0:e.owner)==null?void 0:p.current)instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:h}=e.owner.getProps();return $_e()&&n&&(YJ.has(n)||P_e.has(n)&&M_e(o))&&(n!=="transform"||!h)&&!c&&!s&&r!=="mirror"&&i!==0&&a!=="inertia"}const O_e=40;class L_e extends f7{constructor({autoplay:e=!0,delay:n=0,type:s="
3821keyframes",repeat:r=0,repeatDelay:i=0,repeatType:a="loop",keyframes:o,name:l,motionValue:c,element:h,...p}){var v;super(),this.stop=()=>{var b,S;this._animation&&(this._animation.stop(),(b=this.stopTimeline)==null||b.call(this)),(S=this.keyframeResolver)==null||S.cancel()},this.createdAt=Zl.now();const m={autoplay:e,delay:n,type:s,repeat:r,repeatDelay:i,repeatType:a,name:l,motionValue:c,element:h,...p},y=(h==null?void 0:h.KeyframeResolver)||p7;this.keyframeResolver=new y(o,(b,S,E)=>this.onKeyframesResolved(b,S,m,!E),l,c,h),(v=this.keyframeResolver)==null||v.scheduleResolve()}onKeyframesResolved(e,n,s,r){var E,I;this.keyframeResolver=void 0;const{name:i,type:a,velocity:o,delay:l,isHandoff:c,onUpdate:h}=s;this.resolvedAt=Zl.now();let p=!0;N_e(e,i,a,o)||(p=!1,(z0.instantAnimations||!l)&&(h==null||h(kM(e,s,n))),e[0]=e[e.length-1],ND(s),s.repeat=0);const y={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>O_e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},v=p&&!c&&D_e(y),b=(I=(E=y.motionValue)==null?void 0:E.owner)==null?void 0:I.current;let S;if(v)try{S=new k_e({...y,element:b})}catch{S=new QN(y)}else S=new QN(y);S.finished.then(()=>{this.notifyFinished()}).catch(bd),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),b_e()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}function XJ(t,e,n,s=0,r=1){const i=Array.from(t).sort((c,h)=>c.sortNodePosition(h)).indexOf(e),a=t.size,o=(a-1)*s;return typeof n=="function"?n(i,a):r===1?i*s:o-i*s}const j_e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function B_e(t){const e=j_e.exec(t);if(!e)return[,];const[,n,s,r]=e;return[`--${n??s}`,r]}function JJ(t,e,n=1){const[s,r]=B_e(t);if(!s)return;const i=window.getComputedStyle(e).getPropertyValue(s);if(i){const a=i.trim();return fJ(a)?parseFloat(a):a}return l7(r)?JJ(r,e,n+1):r}const U_e={type:"spring",stiffness:500,damping:25,restSpeed:10},F_e=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),V_e={type:"keyframes",duration:.8},z_e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},G_e=(t,{keyframes:e})=>e.length>2?V_e:r_.has(t)?t.startsWith("scale")?F_e(e[1]):U_e:z_e;function QJ(t,e){if(t!=null&&t.inherit&&e){const{inherit:n,...s}=t;return{...e,...s}}return t}function m7(t,e){const n=(t==null?void 0:t[e])??(t==null?void 0:t.default)??t;return n!==t?QJ(n,t):n}const H_e=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function q_e(t){for(const e in t)if(!H_e.has(e))return!0;return!1}const g7=(t,e,n,s={},r,i)=>a=>{const o=m7(s,t)||{},l=o.delay||s.delay||0;let{elapsed:c=0}=s;c=c-Nu(l);const h={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...o,delay:-c,onUpdate:m=>{e.set(m),o.onUpdate&&o.onUpdate(m)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:t,motionValue:e,element:i?void 0:r};q_e(o)||Object.assign(h,G_e(t,h)),h.duration&&(h.duration=Nu(h.duration)),h.repeatDelay&&(h.repeatDelay=Nu(h.repeatDelay)),h.from!==void 0&&(h.keyframes[0]=h.from);let p=!1;if((h.type===!1||h.duration===0&&!h.repeatDelay)&&(ND(h),h.delay===0&&(p=!0)),(z0.instantAnimations||z0.skipAnimations||r!=null&&r.shouldSkipAnimations)&&(p=!0,ND(h),h.delay=0),h.allowFlatten=!o.type&&!o.ease,p&&!i&&e.get()!==void 0){const m=kM(h.keyframes,o);if(m!==void 0){pi.update(()=>{h.onUpdate(m),h.onComplete()});return}}return o.isSync?new QN(h):new L_e(h)};function aV(t){const e=[{},{}];
vendor: 50,872 bytes, line 3821
3821return t==null||t.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function y7(t,e,n,s){if(typeof e=="function"){const[r,i]=aV(s);e=e(n!==void 0?n:t.custom,r,i)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[r,i]=aV(s);e=e(n!==void 0?n:t.custom,r,i)}return e}function fv(t,e,n){const s=t.getProps();return y7(s,e,n!==void 0?n:s.custom,t)}const ZJ=new Set(["width","height","top","left","right","bottom",...s_]),oV=30,W_e=t=>!isNaN(parseFloat(t));class K_e{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{var i;const r=Zl.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&((i=this.events.change)==null||i.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Zl.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=W_e(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new i7);const s=this.events[e].add(n);return e==="change"?()=>{s(),pi.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Zl.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>oV)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,oV);return yJ(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,n;(e=this.dependents)==null||e.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function z1(t,e){return new K_e(t,e)}const RD=t=>Array.isArray(t);function Y_e(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,z1(n))}function X_e(t){return RD(t)?t[t.length-1]||0:t}function J_e(t,e){const n=fv(t,e);let{transitionEnd:s={},transition:r={},...i}=n||{};i={...i,...s};for(const a in i){const o=X_e(i[a]);Y_e(t,a,o)}}const Ho=t=>!!(t&&t.getVelocity);function Q_e(t){return!!(Ho(t)&&t.add)}function MD(t,e){const n=t.getValue("willChange");if(Q_e(n))return n.add(e);if(!n&&z0.WillChange){const s=new z0.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function x7(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Z_e="framerAppearId",eQ="data-"+x7(Z_e);function tQ(t){return t.props[eQ]}function e2e({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function nQ(t,e,{delay:n=0,transitionOverride:s,type:r}={}){let{transition:i,transitionEnd:a,...o}=e;const l=t.getDefaultTransition();i=i?QJ(i,l):l;const c=i==null?void 0:i.reduceMotion;s&&(i=s);const h=[],p=r&&t.animationState&&t.animationState.getState()[r];for(const m in o){const y=t.getValue(m,t.latestValues[m]??null),v=o[m];if(v===void 0||p&&e2e(p,m))continue;const b={delay:n,...m7(i||{},m)},S=y.get();if(S!==void 0&&!y.isAnimating()&&!Array.isArray(v)&&v===S&&!b.velocity){pi.update(()=>y.set(v));continue}let E=!1;if(window.MotionHandoffAnimation){const j=tQ(t);if(j){const L=window.MotionHandoffAnimation(j,m,pi);L!==null&&(b.startTime=L,E=!0)}}MD(t,m);const I=c??t.shouldReduceMotion;y.start(g7(m,y,v,I&&ZJ.has(m)?{type:!1}:b,t,E));const M=y.animation;M&&h.push(M)}if(a){const m=()=>pi.update(()=>{a&&J_e(t,a)});h.length?Promise.all(h).then(m):m()}return h}function PD(t,e,n={}){var l;const s=fv(t,e,n.type==="exit"?(l=t.presenceContext)==null?void 0:l.custom:void 0);let{transition:r=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(r=n.transitionOverride);const i=s?()=>Promise.all(nQ(t,s,n)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:h=0,staggerChildren:p,staggerDirection:m}=r;return t2e(t,e,c,h,p,m,n)}:()=>Promise.resolve(),{when:o}=r;if(o){const[c,h]=o==="beforeChildren"?[i,a]:[a,i];return c().then(()=>h())}else return Promise.all([i(),a(n.delay)])}function t2e(t,e,n=0,s=0,r=0,i=1,a){const o=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),o.push(PD(l,e,{...a,delay:n+(typeof s=="function"?0:s)+XJ(t.variantChildren,l,s,r,i)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(o)}function n2e(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const r=e.map(i=>PD(t,i,n));s=Promise.all(r)}else if(typeof e=="string")s=PD(t,e,n);else{const r=typeof e=="function"?fv(t,e,n.custom):e;s=Promise.all(nQ(t,r,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}const s2e={test:t=>t==="auto",parse:t=>t},sQ=t=>e=>e.test(t),rQ=[n_,In,up,Og,I1e,k1e,s2e],lV=t=>rQ.find(sQ(t));function r2e(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||mJ(t):!0}const i2e=new Set(["brightness","contrast","saturate","opacity"]);function a2e(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(c7)||[];if(!s)return t;const r=n.replace(s,"");let i=i2e.has(e)?1:0;return s!==n&&(i*=100),e+"("+i+r+")"}const o2e=/\b([a-z-]*)\(.*?\)/gu,$D={...Wh,getAnimatableNone:t=>{const e=t.match(o2e);return e?e.map(a2e).join(" "):t}},DD={...Wh,getAnimatableNone:t=>{const e=Wh.parse(t);return Wh.createTransformer(t)(e.map(s=>typeof s=="number"?0:typeof s=="object"?{...s,alpha:1}:s))}},cV={...n_,transform:Math.round},l2e={rotate:Og,rotateX:Og,rotateY:Og,rotateZ:Og,scale:Pk,scaleX:Pk,scaleY:Pk,scaleZ:Pk,skew:Og,skewX:Og,skewY:Og,distance:In,translateX:In,translateY:In,translateZ:In,x:In,y:In,z:In,perspective:In,transformPerspective:In,opacity:vE,originX:YF,originY:YF,originZ:In},v7={borderWidth:In,borderTopWidth:In,borderRightWidth:In,borderBottomWidth:In,borderLeftWidth:In,borderRadius:In,borderTopLeftRadius:In,borderTopRightRadius:In,borderBottomRightRadius:In,borderBottomLeftRadius:In,width:In,maxWidth:In,height:In,maxHeight:In,top:In,right:In,bottom:In,left:In,inset:In,insetBlock:In,insetBlockStart:In,insetBlockEnd:In,insetInline:In,insetInlineStart:In,insetInlineEnd:In,padding:In,paddingTop:In,paddingRight:In,paddingBottom:In,paddingLeft:In,paddingBlock:In,paddingBlockStart:In,paddingBlockEnd:In,paddingInline:In,paddingInlineStart:In,paddingInlineEnd:In,margin:In,marginTop:In,marginRight:In,marginBottom:In,marginLeft:In,marginBlock:In,marginBlockStart:In,marginBlockEnd:In,marginInline:In,marginInlineStart:In,marginInlineEnd:In,fontSize:In,backgroundPositionX:In,backgroundPositionY:In,...l2e,zIndex:cV,fillOpacity:vE,strokeOpacity:vE,numOctaves:cV},c2e={...v7,color:Da,backgroundColor:Da,outlineColor:Da,fill:Da,stroke:Da,borderColor:Da,borderTopColor:Da,borderRightColor:Da,borderBottomColor:Da,borderLeftColor:Da,filter:$D,WebkitFilter:$D,mask:DD,WebkitMask:DD},iQ=t=>c2e[t],u2e=new Set([$D,DD]);function aQ(t,e){let n=iQ(t);return u2e.has(n)||(n=Wh),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const d2e=new Set(["auto","none","0"]);function h2e(t,e,n){let s=0,r;for(;s<t.length&&!r;){const i=t[s];typeof i=="string"&&!d2e.has(i)&&V1(i).values.length&&(r=t[s]),s++}if(r&&n)for(const i of e)t[i]=aQ(n,r)}class f2e extends p7{constructor(e,n,s,r,i){super(e,n,s,r,i,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let h=0;h<e.length;h++){let p=e[h];if(typeof p=="string"&&(p=p.trim(),l7(p))){const m=JJ(p,n.current);m!==void 0&&(e[h]=m),h===e.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!ZJ.has(s)||e.length!==2)return;const[r,i]=e,a=lV(r),o=lV(i),l=KF(r),c=KF(i);if(l!==c&&E0[s]){this.needsMeasurement=!0;return}if(a!==o)if(sV(a)&&sV(o))for(let h=0;h<e.length;h++){const p=e[h];typeof p=="string"&&(e[h]=parseFloat(p))}else E0[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let r=0;r<e.length;r++)(e[r]===null||r2e(e[r]))&&s.push(r);s.length&&h2e(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=E0[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&e.getValue(s,r).jump(r,!1)}measureEndState(){var o;const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const r=e.getValue(n);r&&r.jump(this.measuredOrigin,!1);const i=s.length-1,a=s[i];s[i]=E0[n](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(o=this.removedTransforms)!=null&&o.length&&this.removedTransforms.forEach(([l,c])=>{e.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function oQ(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const r=(n==null?void 0:n[t])??s.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t).filter(s=>s!=null)}const lQ=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function TI(t){return pJ(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:b7}=kJ(queueMicrotask,!1),bh={x:!1,y:!1};function cQ(){return bh.x||bh.y}function p2e(t){return t==="x"||t==="y"?bh[t]?null:(bh[t]=!0,()=>{bh[t]=!1}):bh.x||bh.y?null:(bh.x=bh.y=!0,()=>{bh.x=bh.y=!1})}function uQ(t,e){const n=oQ(t),s=new AbortController,r={passive:!0,...e,signal:s.signal};return[n,r,()=>s.abort()]}function m2e(t){return!(t.pointerType==="touch"||cQ())}function g2e(t,e,n={}){const[s,r,i]=uQ(t,n);return s.forEach(a=>{let o=!1,l=!1,c;const h=()=>{a.removeEventListener("pointerleave",v)},p=S=>{c&&(c(S),c=void 0),h()},m=S=>{o=!1,window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",m),l&&(l=!1,p(S))},y=()=>{o=!0,window.addEventListener("pointerup",m,r),window.addEventListener("pointercancel",m,r)},v=S=>{if(S.pointerType!=="touch"){if(o){l=!0;return}p(S)}},b=S=>{if(!m2e(S))return;l=!1;const E=e(a,S);typeof E=="function"&&(c=E,a.addEventListener("pointerleave",v,r))};a.addEventListener("pointerenter",b,r),a.addEventListener("pointerdown",y,r)}),i}const dQ=(t,e)=>e?t===e?!0:dQ(t,e.parentElement):!1,w7=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,y2e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function x2e(t){return y2e.has(t.tagName)||t.isContentEditable===!0}const v2e=new Set(["INPUT","SELECT","TEXTAREA"]);function b2e(t){return v2e.has(t.tagName)||t.isContentEditable===!0}const AI=new WeakSet;function uV(t){return e=>{e.key==="Enter"&&t(e)}}function F4(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const w2e=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=uV(()=>{if(AI.has(n))return;F4(n,"down");const r=uV(()=>{F4(n,"up")}),i=()=>F4(n,"cancel");n.addEventListener("keyup",r,e),n.addEventListener("blur",i,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function dV(t){return w7(t)&&!cQ()}const hV=new WeakSet;function _2e(t,e,n={}){const[s,r,i]=uQ(t,n),a=o=>{const l=o.currentTarget;if(!dV(o)||hV.has(o))return;AI.add(l),n.stopPropagation&&hV.add(o);const c=e(l,o),h=(y,v)=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",m),AI.has(l)&&AI.delete(l),dV(y)&&typeof c=="function"&&c(y,{success:v})},p=y=>{h(y,l===window||l===document||n.useGlobalTarget||dQ(l,y.target))},m=y=>{h(y,!1)};window.addEventListener("pointerup",p,r),window.addEventListener("pointercancel",m,r)};return s.forEach(o=>{(n.useGlobalTarget?window:o).addEventListener("pointerdown",a,r),TI(o)&&(o.addEventListener("focus",c=>w2e(c,r)),!x2e(o)&&!o.hasAttribute("tabindex")&&(o.tabIndex=0))}),i}function _7(t){return pJ(t)&&"ownerSVGElement"in t}const CI=new WeakMap;let Lg;const hQ=(t,e,n)=>(s,r)=>r&&r[0]?r[0][t+"Size"]:_7(s)&&"getBBox"in s?s.getBBox()[e]:s[n],S2e=hQ("inline","width","offsetWidth"),E2e=hQ("block","height","offsetHeight");function T2e({target:t,borderBoxSize:e}){var n;(n=CI.get(t))==null||n.forEach(s=>{s(t,{get width(){return S2e(t,e)},get height(){return E2e(t,e)}})})}function A2e(t){t.forEach(T2e)}function C2e(){typeof ResizeObserver>"u"||(Lg=new ResizeObserver(A2e))}function k2e(t,e){Lg||C2e();const n=oQ(t);return n.forEach(s=>{let r=CI.get(s);r||(r=new Set,CI.set(s,r)),r.add(e),Lg==null||Lg.observe(s)}),()=>{n.forEach(s=>{const r=CI.get(s);r==null||r.delete(e),r!=null&&r.size||Lg==null||Lg.unobserve(s)})}}const kI=new Set;let rw;function I2e(){rw=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};kI.forEach(e=>e(t))},window.addEventListener("resize",rw)}function N2e(t){return kI.add(t),rw||I2e(),()=>{kI.delete(t),!kI.size&&typeof rw=="function"&&(window.removeEventListener("resize",rw),rw=void 0)}}function fV(t,e){return typeof t=="function"?N2e(t):k2e(t,e)}function R2e(t){return _7(t)&&t.tagName==="svg"}const M2e=[...rQ,Da,Wh],P2e=t=>M2e.find(sQ(t)),pV=()=>({translate:0,scale:1,origin:0,originPoint:0}),iw=()=>({x:pV(),y:pV()}),mV=()=>({min:0,max:0}),so=()=>({x:mV(),y:mV()}),$2e=new WeakMap;function IM(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function bE(t){return typeof t=="string"||Array.isArray(t)}const S7=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],E7=["initial",...S7];function NM(t){return IM(t.animate)||E7.some(e=>bE(t[e]))}function fQ(t){return!!(NM(t)||t.variants)}function D2e(t,e,n){for(const s in e){const r=e[s],i=n[s];if(Ho(r))t.addValue(s,r);else if(Ho(i))t.addValue(s,z1(r,{owner:t}));else if(i!==r)if(t.hasValue(s)){const a=t.getValue(s);a.liveStyle===!0?a.jump(r):a.hasAnimated||a.set(r)}else{const a=t.getStaticValue(s);t.addValue(s,z1(a!==void 0?a:r,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const OD={current:null},pQ={current:!1},O2e=typeof window<"u";function L2e(){if(pQ.current=!0,!!O2e)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>OD.current=t.matches;t.addEventListener("change",e),e()}else OD.current=!1}const gV=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let ZN={};function mQ(t){ZN=t}function j2e(){return ZN}class B2e{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=p7,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const y=Zl.now();this.renderScheduledAt<y&&(this.renderScheduledAt=y,pi.render(this.render,!1,!0))};const{latestValues:c,renderState:h}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=h,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=l,this.blockInitialAnimation=!!a,this.isControllingVariants=NM(n),this.isVariantNode=fQ(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:p,...m}=this.scrapeMotionValuesFromProps(n,{},this);for(const y in m){const v=m[y];c[y]!==void 0&&Ho(v)&&v.set(c[y])}}mount(e){var n,s;if(this.hasBeenMounted)for(const r in this.initialValues)(n=this.values.get(r))==null||n.jump(this.initialValues[r]),this.latestValues[r]=this.initialValues[r];this.current=e,$2e.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((r,i)=>this.bindToMotionValue(i,r)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(pQ.current||L2e(),this.shouldReduceMotion=OD.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(s=this.parent)==null||s.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var e;this.projection&&this.projection.unmount(),G0(this.notifyUpdate),G0(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(e=this.parent)==null||e.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const s=this.features[n];s&&(s.unmount(),s.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),n.accelerate&&YJ.has(e)&&this.current instanceof HTMLElement){const{factory:a,keyframes:o,times:l,ease:c,duration:h}=n.accelerate,p=new WJ({element:this.current,name:e,keyframes:o,times:l,ease:c,duration:Nu(h)}),m=a(p);this.valueSubscriptions.set(e,()=>{m(),p.cancel()});return}const s=r_.has(e);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&pi.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in ZN){const n=ZN[e];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[e]&&r&&s(this.props)&&(this.features[e]=new r(this)),this.features[e]){const i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):so()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<gV.length;s++){const r=gV[s];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const i="on"+r,a=e[i];a&&(this.propEventSubscriptions[r]=this.on(r,a))}this.prevMotionValues=D2e(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=z1(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(fJ(s)||mJ(s))?s=parseFloat(s):!P2e(s)&&Wh.test(n)&&(s=aQ(e,n)),this.setBaseTarget(e,Ho(s)?s.get():s)),Ho(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){var i;const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const a=y7(this.props,n,(i=this.presenceContext)==null?void 0:i.custom);a&&(s=a[e])}if(n&&s!==void 0)return s;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!Ho(r)?r:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new i7),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){b7.render(this.render)}}class gQ extends B2e{constructor(){super(...arguments),this.KeyframeResolver=f2e}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const s=e.style;return s?s[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Ho(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class ey{constructor(e){this.isMounted=!1,this.node=e}update(){}}function yQ({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function U2e({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function F2e(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function V4(t){return t===void 0||t===1}function LD({scale:t,scaleX:e,scaleY:n}){return!V4(t)||!V4(e)||!V4(n)}function Vy(t){return LD(t)||xQ(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function xQ(t){return yV(t.x)||yV(t.y)}function yV(t){return t&&t!=="0%"}function eR(t,e,n){const s=t-n,r=e*s;return n+r}function xV(t,e,n,s,r){return r!==void 0&&(t=eR(t,r,s)),eR(t,n,s)+e}function jD(t,e=0,n=1,s,r){t.min=xV(t.min,e,n,s,r),t.max=xV(t.max,e,n,s,r)}function vQ(t,{x:e,y:n}){jD(t.x,e.translate,e.scale,e.originPoint),jD(t.y,n.translate,n.scale,n.originPoint)}const vV=.999999999999,bV=1.0000000000001;function V2e(t,e,n,s=!1){var o;const r=n.length;if(!r)return;e.x=e.y=1;let i,a;for(let l=0;l<r;l++){i=n[l],a=i.projectionDelta;const{visualElement:c}=i.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&i.options.layoutScroll&&i.scroll&&i!==i.root&&(ip(t.x,-i.scroll.offset.x),ip(t.y,-i.scroll.offset.y)),a&&(e.x*=a.x.scale,e.y*=a.y.scale,vQ(t,a)),s&&Vy(i.latestValues)&&II(t,i.latestValues,(o=i.layout)==null?void 0:o.layoutBox))}e.x<bV&&e.x>vV&&(e.x=1),e.y<bV&&e.y>vV&&(e.y=1)}function ip(t,e){t.min+=e,t.max+=e}function wV(t,e,n,s,r=.5){const i=Li(t.min,t.max,r);jD(t,e,n,i,s)}function _V(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function II(t,e,n){const s=n??t;wV(t.x,_V(e.x,s.x),e.scaleX,e.scale,e.originX),wV(t.y,_V(e.y,s.y),e.scaleY,e.scale,e.originY)}function bQ(t,e){return yQ(F2e(t.getBoundingClientRect(),e))}function z2e(t,e,n){const s=bQ(t,n),{scroll:r}=e;return r&&(ip(s.x,r.offset.x),ip(s.y,r.offset.y)),s}const G2e={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},H2e=s_.length;function q2e(t,e,n){let s="",r=!0;for(let i=0;i<H2e;i++){const a=s_[i],o=t[a];if(o===void 0)continue;let l=!0;if(typeof o=="number")l=o===(a.startsWith("scale")?1:0);else{const c=parseFloat(o);l=a.startsWith("scale")?c===1:c===0}if(!l||n){const c=lQ(o,v7[a]);if(!l){r=!1;const h=G2e[a]||a;s+=`${h}(${c}) `}n&&(e[a]=c)}}return s=s.trim(),n?s=n(e,r?"":s):r&&(s="none"),s}function T7(t,e,n){const{style:s,vars:r,transformOrigin:i}=t;let a=!1,o=!1;for(const l in e){const c=e[l];if(r_.has(l)){a=!0;continue}else if(NJ(l)){r[l]=c;continue}else{const h=lQ(c,v7[l]);l.startsWith("origin")?(o=!0,i[l]=h):s[l]=h}}if(e.transform||(a||n?s.transform=q2e(e,t.transform,n):s.transform&&(s.transform="none")),o){const{originX:l="50%",originY:c="50%",originZ:h=0}=i;s.transformOrigin=`${l} ${c} ${h}`}}function wQ(t,{style:e,vars:n},s,r){const i=t.style;let a;for(a in e)i[a]=e[a];r==null||r.applyProjectionStyles(i,s);for(a in n)i.setProperty(a,n[a])}function SV(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const O2={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(In.test(t))t=parseFloat(t);else return t;const n=SV(t,e.target.x),s=SV(t,e.target.y);return`${n}% ${s}%`}},W2e={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,r=Wh.parse(t);if(r.length>5)return s;const i=Wh.createTransformer(t),a=typeof r[0]!="number"?1:0,o=n.x.scale*e.x,l=n.y.scale*e.y;r[0+a]/=o,r[1+a]/=l;const c=Li(o,l,.5);return typeof r[2+a]=="number"&&(r[2+a]/=c),typeof r[3+a]=="number"&&(r[3+a]/=c),i(r)}},BD={borderRadius:{...O2,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:O2,borderTopRightRadius:O2,borderBottomLeftRadius:O2,borderBottomRightRadius:O2,boxShadow:W2e};function _Q(t,{layout:e,layoutId:n}){return r_.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!BD[t]||t==="opacity")}function A7(t,e,n){var a;const s=t.style,r=e==null?void 0:e.style,i={};if(!s)return i;for(const o in s)(Ho(s[o])||r&&Ho(r[o])||_Q(o,t)||((a=n==null?void 0:n.getValue(o))==null?void 0:a.liveStyle)!==void 0)&&(i[o]=s[o]);return i}function K2e(t){return window.getComputedStyle(t)}class Y2e extends gQ{constructor(){super(...arguments),this.type="html",this.renderInstance=wQ}readValueFromInstance(e,n){var s;if(r_.has(n))return(s=this.projection)!=null&&s.isProjecting?TD(n):m_e(e,n);{const r=K2e(e),i=(NJ(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return bQ(e,n)}build(e,n,s){T7(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return A7(e,n,s)}}const X2e={offset:"stroke-dashoffset",array:"stroke-dasharray"},J2e={offset:"strokeDashoffset",array:"strokeDasharray"};function Q2e(t,e,n=1,s=0,r=!0){t.pathLength=1;const i=r?X2e:J2e;t[i.offset]=`${-s}`,t[i.array]=`${e} ${n}`}const Z2e=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function SQ(t,{attrX:e,attrY:n,attrScale:s,pathLength:r,pathSpacing:i=1,pathOffset:a=0,...o},l,c,h){if(T7(t,o,c),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:p,style:m}=t;p.transform&&(m.transform=p.transform,delete p.transform),(m.transform||p.transformOrigin)&&(m.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),m.transform&&(m.transformBox=(h==null?void 0:h.transformBox)??"fill-box",delete p.transformBox);for(const y of Z2e)p[y]!==void 0&&(m[y]=p[y],delete p[y]);e!==void 0&&(p.x=e),n!==void 0&&(p.y=n),s!==void 0&&(p.scale=s),r!==void 0&&Q2e(p,r,i,a,!1)}const EQ=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),TQ=t=>typeof t=="string"&&t.toLowerCase()==="svg";function eSe(t,e,n,s){wQ(t,e,void 0,s);for(const r in e.attrs)t.setAttribute(EQ.has(r)?r:x7(r),e.attrs[r])}function AQ(t,e,n){const s=A7(t,e,n);for(const r in t)if(Ho(t[r])||Ho(e[r])){const i=s_.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[i]=t[r]}return s}class tSe extends gQ{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=so}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(r_.has(n)){const s=iQ(n);return s&&s.default||0}return n=EQ.has(n)?n:x7(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return AQ(e,n,s)}build(e,n,s){SQ(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,r){eSe(e,n,s,r)}mount(e){this.isSVGTag=TQ(e.tagName),super.mount(e)}}const nSe=E7.length;function CQ(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?CQ(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<nSe;n++){const s=E7[n],r=t.props[s];(bE(r)||r===!1)&&(e[s]=r)}return e}function kQ(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const sSe=[...S7].reverse(),rSe=S7.length;function iSe(t){return e=>Promise.all(e.map(({animation:n,options:s})=>n2e(t,n,s)))}function aSe(t){let e=iSe(t),n=EV(),s=!0,r=!1;const i=c=>(h,p)=>{var y;const m=fv(t,p,c==="exit"?(y=t.presenceContext)==null?void 0:y.custom:void 0);if(m){const{transition:v,transitionEnd:b,...S}=m;h={...h,...S,...b}}return h};function a(c){e=c(t)}function o(c){const{props:h}=t,p=CQ(t.parent)||{},m=[],y=new Set;let v={},b=1/0;for(let E=0;E<rSe;E++){const I=sSe[E],M=n[I],j=h[I]!==void 0?h[I]:p[I],L=bE(j),K=I===c?M.isActive:null;K===!1&&(b=E);let D=j===p[I]&&j!==h[I]&&L;if(D&&(s||r)&&t.manuallyAnimateOnMount&&(D=!1),M.protectedKeys={...v},!M.isActive&&K===null||!j&&!M.prevProp||IM(j)||typeof j=="boolean")continue;if(I==="exit"&&M.isActive&&K!==!0){M.prevResolvedValues&&(v={...v,...M.prevResolvedValues});continue}const R=oSe(M.prevProp,j);let B=R||I===c&&M.isActive&&!D&&L||E>b&&L,G=!1;const X=Array.isArray(j)?j:[j];let H=X.reduce(i(I),{});K===!1&&(H={});const{prevResolvedValues:Y={}}=M,F={...Y,...H},we=Le=>{B=!0,y.has(Le)&&(G=!0,y.delete(Le)),M.needsAnimating[Le]=!0;const ve=t.getValue(Le);ve&&(ve.liveStyle=!1)};for(const Le in F){const ve=H[Le],ce=Y[Le];if(v.hasOwnProperty(Le))continue;let ie=!1;RD(ve)&&RD(ce)?ie=!kQ(ve,ce):ie=ve!==ce,ie?ve!=null?we(Le):y.add(Le):ve!==void 0&&y.has(Le)?we(Le):M.protectedKeys[Le]=!0}M.prevProp=j,M.prevResolvedValues=H,M.isActive&&(v={...v,...H}),(s||r)&&t.blockInitialAnimation&&(B=!1);const me=D&&R;B&&(!me||G)&&m.push(...X.map(Le=>{const ve={type:I};if(typeof Le=="string"&&(s||r)&&!me&&t.manuallyAnimateOnMount&&t.parent){const{parent:ce}=t,ie=fv(ce,Le);if(ce.enteringChildren&&ie){const{delayChildren:de}=ie.transition||{};ve.delay=XJ(ce.enteringChildren,t,de)}}return{animation:Le,options:ve}}))}if(y.size){const E={};if(typeof h.initial!="boolean"){const I=fv(t,Array.isArray(h.initial)?h.initial[0]:h.initial);I&&I.transition&&(E.transition=I.transition)}y.forEach(I=>{const M=t.getBaseTarget(I),j=t.getValue(I);j&&(j.liveStyle=!0),E[I]=M??null}),m.push({animation:E})}let S=!!m.length;return s&&(h.initial===!1||h.initial===h.animate)&&!t.manuallyAnimateOnMount&&(S=!1),s=!1,r=!1,S?e(m):Promise.resolve()}function l(c,h){var m;if(n[c].isActive===h)return Promise.resolve();(m=t.variantChildren)==null||m.forEach(y=>{var v;return(v=y.animationState)==null?void 0:v.setActive(c,h)}),n[c].isActive=h;const p=o(c);for(const y in n)n[y].protectedKeys={};return p}return{animateChanges:o,setActive:l,setAnimateFunction:a,getState:()=>n,reset:()=>{n=EV(),r=!0}}}function oSe(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!kQ(e,t):!1}function Py(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function EV(){return{animate:Py(!0),whileInView:Py(),whileHover:Py(),whileTap:Py(),whileDrag:Py(),whileFocus:Py(),exit:Py()}}function UD(t,e){t.min=e.min,t.max=e.max}function fh(t,e){UD(t.x,e.x),UD(t.y,e.y)}function TV(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const IQ=1e-4,lSe=1-IQ,cSe=1+IQ,NQ=.01,uSe=0-NQ,dSe=0+NQ;function ec(t){return t.max-t.min}function hSe(t,e,n){return Math.abs(t-e)<=n}function AV(t,e,n,s=.5){t.origin=s,t.originPoint=Li(e.min,e.max,t.origin),t.scale=ec(n)/ec(e),t.translate=Li(n.min,n.max,t.origin)-t.originPoint,(t.scale>=lSe&&t.scale<=cSe||isNaN(t.scale))&&(t.scale=1),(t.translate>=uSe&&t.translate<=dSe||isNaN(t.translate))&&(t.translate=0)}function VS(t,e,n,s){AV(t.x,e.x,n.x,s?s.originX:void 0),AV(t.y,e.y,n.y,s?s.originY:void 0)}function CV(t,e,n,s=0){const r=s?Li(n.min,n.max,s):n.min;t.min=r+e.min,t.max=t.min+ec(e)}function fSe(t,e,n,s){CV(t.x,e.x,n.x,s==null?void 0:s.x),CV(t.y,e.y,n.y,s==null?void 0:s.y)}function kV(t,e,n,s=0){const r=s?Li(n.min,n.max,s):n.min;t.min=e.min-r,t.max=t.min+ec(e)}function tR(t,e,n,s){kV(t.x,e.x,n.x,s==null?void 0:s.x),kV(t.y,e.y,n.y,s==null?void 0:s.y)}function IV(t,e,n,s,r){return t-=e,t=eR(t,1/n,s),r!==void 0&&(t=eR(t,1/r,s)),t}function pSe(t,e=0,n=1,s=.5,r,i=t,a=t){if(up.test(e)&&(e=parseFloat(e),e=Li(a.min,a.max,e/100)-a.min),typeof e!="number")return;let o=Li(i.min,i.max,s);t===i&&(o-=e),t.min=IV(t.min,e,n,o,r),t.max=IV(t.max,e,n,o,r)}function NV(t,e,[n,s,r],i,a){pSe(t,e[n],e[s],e[r],e.scale,i,a)}const mSe=["x","scaleX","originX"],gSe=["y","scaleY","originY"];function RV(t,e,n,s){NV(t.x,e,mSe,n?n.x:void 0,s?s.x:void 0),NV(t.y,e,gSe,n?n.y:void 0,s?s.y:void 0)}function MV(t){return t.translate===0&&t.scale===1}function RQ(t){return MV(t.x)&&MV(t.y)}function PV(t,e){return t.min===e.min&&t.max===e.max}function ySe(t,e){return PV(t.x,e.x)&&PV(t.y,e.y)}function $V(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function MQ(t,e){return $V(t.x,e.x)&&$V(t.y,e.y)}function DV(t){return ec(t.x)/ec(t.y)}function OV(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function jf(t){return[t("x"),t("y")]}function xSe(t,e,n){let s="";const r=t.x.translate/e.x,i=t.y.translate/e.y,a=(n==null?void 0:n.z)||0;if((r||i||a)&&(s=`translate3d(${r}px, ${i}px, ${a}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:c,rotate:h,rotateX:p,rotateY:m,skewX:y,skewY:v}=n;c&&(s=`perspective(${c}px) ${s}`),h&&(s+=`rotate(${h}deg) `),p&&(s+=`rotateX(${p}deg) `),m&&(s+=`rotateY(${m}deg) `),y&&(s+=`skewX(${y}deg) `),v&&(s+=`skewY(${v}deg) `)}const o=t.x.scale*e.x,l=t.y.scale*e.y;return(o!==1||l!==1)&&(s+=`scale(${o}, ${l})`),s||"none"}const PQ=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],vSe=PQ.length,LV=t=>typeof t=="string"?parseFloat(t):t,jV=t=>typeof t=="number"||In.test(t);function bSe(t,e,n,s,r,i){r?(t.opacity=Li(0,n.opacity??1,wSe(s)),t.opacityExit=Li(e.opacity??1,0,_Se(s))):i&&(t.opacity=Li(e.opacity??1,n.opacity??1,s));for(let a=0;a<vSe;a++){const o=PQ[a];let l=BV(e,o),c=BV(n,o);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||jV(l)===jV(c)?(t[o]=Math.max(Li(LV(l),LV(c),s),0),(up.test(c)||up.test(l))&&(t[o]+="%")):t[o]=c}(e.rotate||n.rotate)&&(t.rotate=Li(e.rotate||0,n.rotate||0,s))}function BV(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const wSe=$Q(0,.5,EJ),_Se=$Q(.5,.95,bd);function $Q(t,e,n){return s=>s<t?0:s>e?1:n(xE(t,e,s))}function SSe(t,e,n){const s=Ho(t)?t:z1(t);return s.start(g7("",s,e,n)),s.animation}function wE(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}const ESe=(t,e)=>t.depth-e.depth;class TSe{constructor(){this.children=[],this.isDirty=!1}add(e){s7(this.children,e),this.isDirty=!0}remove(e){KN(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(ESe),this.isDirty=!1,this.children.forEach(e)}}function ASe(t,e){const n=Zl.now(),s=({timestamp:r})=>{const i=r-n;i>=e&&(G0(s),t(i-e))};return pi.setup(s,!0),()=>G0(s)}function NI(t){return Ho(t)?t.get():t}class CSe{constructor(){this.members=[]}add(e){s7(this.members,e);for(let n=this.members.length-1;n>=0;n--){const s=this.members[n];if(s===e||s===this.lead||s===this.prevLead)continue;const r=s.instance;(!r||r.isConnected===!1)&&!s.snapshot&&(KN(this.members,s),s.unmount())}e.scheduleRender()}remove(e){if(KN(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){var n;for(let s=this.members.indexOf(e)-1;s>=0;s--){const r=this.members[s];if(r.isPresent!==!1&&((n=r.instance)==null?void 0:n.isConnected)!==!1)return this.promote(r),!0}return!1}promote(e,n){var r;const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.updateSnapshot(),e.scheduleRender();const{layoutDependency:i}=s.options,{layoutDependency:a}=e.options;(i===void 0||i!==a)&&(e.resumeFrom=s,n&&(s.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),(r=e.root)!=null&&r.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{var n,s,r,i,a;(s=(n=e.options).onExitComplete)==null||s.call(n),(a=(r=e.resumingFrom)==null?void 0:(i=r.options).onExitComplete)==null||a.call(i)})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){var e;(e=this.lead)!=null&&e.snapshot&&(this.lead.snapshot=void 0)}}const RI={hasAnimatedSinceResize:!0,hasEverUpdated:!1},z4=["","X","Y","Z"],kSe=1e3;let ISe=0;function G4(t,e,n,s){const{latestValues:r}=e;r[t]&&(n[t]=r[t],e.setStaticValue(t,0),s&&(s[t]=0))}function DQ(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=tQ(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:i}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",pi,!(r||i))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&DQ(s)}function OQ({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(a={},o=e==null?void 0:e()){this.id=ISe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(MSe),this.nodes.forEach(jSe),this.nodes.forEach(BSe),this.nodes.forEach(PSe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new TSe)}addEventListener(a,o){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new i7),this.eventHandlers.get(a).add(o)}notifyListeners(a,...o){const l=this.eventHandlers.get(a);l&&l.notify(...o)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=_7(a)&&!R2e(a),this.instance=a;const{layoutId:o,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||o)&&(this.isLayoutDirty=!0),t){let h,p=0;const m=()=>this.root.updateBlockedByResize=!1;pi.read(()=>{p=window.innerWidth}),t(a,()=>{const y=window.innerWidth;y!==p&&(p=y,this.root.updateBlockedByResize=!0,h&&h(),h=ASe(m,250),RI.hasAnimatedSinceResize&&(RI.hasAnimatedSinceResize=!1,this.nodes.forEach(VV)))})}o&&this.root.registerSharedNode(o,this),this.options.animate!==!1&&c&&(o||l)&&this.addEventListener("didUpdate",({delta:h,hasLayoutChanged:p,hasRelativeLayoutChanged:m,layout:y})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const v=this.options.transition||c.getDefaultTransition()||GSe,{onLayoutAnimationStart:b,onLayoutAnimationComplete:S}=c.getProps(),E=!this.targetLayout||!MQ(this.targetLayout,y),I=!p&&m;if(this.options.layoutRoot||this.resumeFrom||I||p&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...m7(v,"layout"),onPlay:b,onComplete:S};(c.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(h,I)}else p||VV(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=y})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),G0(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(USe),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&DQ(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let h=0;h<this.path.length;h++){const p=this.path[h];p.shouldResetTransform=!0,(typeof p.latestValues.x=="string"||typeof p.latestValues.y=="string")&&(p.isLayoutDirty=!0),p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:o,layout:l}=this.options;if(o===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const l=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),l&&this.nodes.forEach(DSe),this.nodes.forEach(UV);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(FV);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(OSe),this.nodes.forEach(LSe),this.nodes.forEach(NSe),this.nodes.forEach(RSe)):this.nodes.forEach(FV),this.clearAllSnapshots();const o=Zl.now();Uo.delta=gp(0,1e3/60,o-Uo.timestamp),Uo.timestamp=o,Uo.isProcessing=!0,D4.update.process(Uo),D4.preRender.process(Uo),D4.render.process(Uo),Uo.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,b7.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach($Se),this.sharedNodes.forEach(FSe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,pi.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){pi.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ec(this.snapshot.measuredBox.x)&&!ec(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=so()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:o}=this.options;o&&o.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let o=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(o=!1),o&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,o=this.projectionDelta&&!RQ(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,h=c!==this.prevTransformTemplateValue;a&&this.instance&&(o||Vy(this.latestValues)||h)&&(r(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const o=this.measurePageBox();let l=this.removeElementScroll(o);return a&&(l=this.removeTransform(l)),HSe(l),{animationId:this.root.animationId,measuredBox:o,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var c;const{visualElement:a}=this.options;if(!a)return so();const o=a.measureViewportBox();if(!(((c=this.scroll)==null?void 0:c.wasRoot)||this.path.some(qSe))){const{scroll:h}=this.root;h&&(ip(o.x,h.offset.x),ip(o.y,h.offset.y))}return o}removeElementScroll(a){var l;const o=so();if(fh(o,a),(l=this.scroll)!=null&&l.wasRoot)return o;for(let c=0;c<this.path.length;c++){const h=this.path[c],{scroll:p,options:m}=h;h!==this.root&&p&&m.layoutScroll&&(p.wasRoot&&fh(o,a),ip(o.x,p.offset.x),ip(o.y,p.offset.y))}return o}applyTransform(a,o=!1,l){var h,p;const c=l||so();fh(c,a);for(let m=0;m<this.path.length;m++){const y=this.path[m];!o&&y.options.layoutScroll&&y.scroll&&y!==y.root&&(ip(c.x,-y.scroll.offset.x),ip(c.y,-y.scroll.offset.y)),Vy(y.latestValues)&&II(c,y.latestValues,(h=y.layout)==null?void 0:h.layoutBox)}return Vy(this.latestValues)&&II(c,this.latestValues,(p=this.layout)==null?void 0:p.layoutBox),c}removeTransform(a){var l;const o=so();fh(o,a);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!Vy(h.latestValues))continue;let p;h.instance&&(LD(h.latestValues)&&h.updateSnapshot(),p=so(),fh(p,h.measurePageBox())),RV(o,h.latestValues,(l=h.snapshot)==null?void 0:l.layoutBox,p)}return Vy(this.latestValues)&&RV(o,this.latestValues),o}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Uo.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var y;const o=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=o.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=o.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=o.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==o;if(!(a||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(y=this.parent)!=null&&y.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:h,layoutId:p}=this.options;if(!this.layout||!(h||p))return;this.resolvedRelativeTargetAt=Uo.timestamp;const m=this.getClosestProjectingParent();m&&this.linkedParentVersion!==m.layoutVersion&&!m.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&m&&m.layout?this.createRelativeTarget(m,this.layout.layoutBox,m.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=so(),this.targetWithTransforms=so()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),fSe(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):fh(this.target,this.layout.layoutBox),vQ(this.target,this.targetDelta)):fh(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?this.createRelativeTarget(m,this.target,m.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||LD(this.parent.latestValues)||xQ(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,o,l){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=so(),this.relativeTargetOrigin=so(),tR(this.relativeTargetOrigin,o,l,this.options.layoutAnchor||void 0),fh(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var v;const a=this.getLead(),o=!!this.resumingFrom||this!==a;let l=!0;if((this.isProjectionDirty||(v=this.parent)!=null&&v.isProjectionDirty)&&
vendor: 5,341 bytes, line 3821
3821(l=!1),o&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Uo.timestamp&&(l=!1),l)return;const{layout:c,layoutId:h}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||h))return;fh(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,m=this.treeScale.y;V2e(this.layoutCorrected,this.treeScale,this.path,o),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=so());const{target:y}=a;if(!y){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(TV(this.prevProjectionDelta.x,this.projectionDelta.x),TV(this.prevProjectionDelta.y,this.projectionDelta.y)),VS(this.projectionDelta,this.layoutCorrected,y,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==m||!OV(this.projectionDelta.x,this.prevProjectionDelta.x)||!OV(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",y))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){var o;if((o=this.options.visualElement)==null||o.scheduleRender(),a){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=iw(),this.projectionDelta=iw(),this.projectionDeltaWithTransform=iw()}setAnimationOrigin(a,o=!1){const l=this.snapshot,c=l?l.latestValues:{},h={...this.latestValues},p=iw();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!o;const m=so(),y=l?l.source:void 0,v=this.layout?this.layout.source:void 0,b=y!==v,S=this.getStack(),E=!S||S.members.length<=1,I=!!(b&&!E&&this.options.crossfade===!0&&!this.path.some(zSe));this.animationProgress=0;let M;this.mixTargetDelta=j=>{const L=j/1e3;zV(p.x,a.x,L),zV(p.y,a.y,L),this.setTargetDelta(p),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(tR(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),VSe(this.relativeTarget,this.relativeTargetOrigin,m,L),M&&ySe(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=so()),fh(M,this.relativeTarget)),b&&(this.animationValues=h,bSe(h,c,this.latestValues,L,I,E)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var o,l,c;this.notifyListeners("animationStart"),(o=this.currentAnimation)==null||o.stop(),(c=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||c.stop(),this.pendingAnimation&&(G0(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=pi.update(()=>{RI.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=z1(0)),this.motionValue.jump(0,!1),this.currentAnimation=SSe(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:h=>{this.mixTargetDelta(h),a.onUpdate&&a.onUpdate(h)},onStop:()=>{},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(kSe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:l,layout:c,latestValues:h}=a;if(!(!o||!l||!c)){if(this!==a&&this.layout&&c&&LQ(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||so();const p=ec(this.layout.layoutBox.x);l.x.min=a.target.x.min,l.x.max=l.x.min+p;const m=ec(this.layout.layoutBox.y);l.y.min=a.target.y.min,l.y.max=l.y.min+m}fh(o,l),II(o,h),VS(this.projectionDeltaWithTransform,this.layoutCorrected,o,h)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new CSe),this.sharedNodes.get(a).add(o);const c=o.options.initialPromotionConfig;o.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())==null?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())==null?void 0:o.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}
vendor: 4,515 bytes, line 3821
3821resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:l}=a;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(o=!0),!o)return;const c={};l.z&&G4("z",a,c,this.animationValues);for(let h=0;h<z4.length;h++)G4(`rotate${z4[h]}`,a,c,this.animationValues),G4(`skew${z4[h]}`,a,c,this.animationValues);a.render();for(const h in c)a.setStaticValue(h,c[h]),this.animationValues&&(this.animationValues[h]=c[h]);a.scheduleRender()}applyProjectionStyles(a,o){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=NI(o==null?void 0:o.pointerEvents)||"",a.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=NI(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Vy(this.latestValues)&&(a.transform=l?l({},""):"none",this.hasProjected=!1);return}a.visibility="";const h=c.animationValues||c.latestValues;this.applyTransformsToTarget();let p=xSe(this.projectionDeltaWithTransform,this.treeScale,h);l&&(p=l(h,p)),a.transform=p;const{x:m,y}=this.projectionDelta;a.transformOrigin=`${m.origin*100}% ${y.origin*100}% 0`,c.animationValues?a.opacity=c===this?h.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:h.opacityExit:a.opacity=c===this?h.opacity!==void 0?h.opacity:"":h.opacityExit!==void 0?h.opacityExit:0;for(const v in BD){if(h[v]===void 0)continue;const{correct:b,applyTo:S,isCSSVariable:E}=BD[v],I=p==="none"?h[v]:b(h[v],c);if(S){const M=S.length;for(let j=0;j<M;j++)a[S[j]]=I}else E?this.options.visualElement.renderState.vars[v]=I:a[v]=I}this.options.layoutId&&(a.pointerEvents=c===this?NI(o==null?void 0:o.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var o;return(o=a.currentAnimation)==null?void 0:o.stop()}),this.root.nodes.forEach(UV),this.root.sharedNodes.clear()}}}function NSe(t){t.updateLayout()}function RSe(t){var n;const e=((n=t.resumeFrom)==null?void 0:n.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:s,measuredBox:r}=t.layout,{animationType:i}=t.options,a=e.source!==t.layout.source;if(i==="size")jf(p=>{const m=a?e.measuredBox[p]:e.layoutBox[p],y=ec(m);m.min=s[p].min,m.max=m.min+y});else if(i==="x"||i==="y"){const p=i==="x"?"y":"x";UD(a?e.measuredBox[p]:e.layoutBox[p],s[p])}else LQ(i,e.layoutBox,s)&&jf(p=>{const m=a?e.measuredBox[p]:e.layoutBox[p],y=ec(s[p]);m.max=m.min+y,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[p].max=t.relativeTarget[p].min+y)});const o=iw();VS(o,s,e.layoutBox);const l=iw();a?VS(l,t.applyTransform(r,!0),e.measuredBox):VS(l,s,e.layoutBox);const c=!RQ(o);let h=!1;if(!t.resumeFrom){const p=t.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:m,layout:y}=p;if(m&&y){const v=t.options.layoutAnchor||void 0,b=so();tR(b,e.layoutBox,m.layoutBox,v);const S=so();tR(S,s,y.layoutBox,v),MQ(b,S)||(h=!0),p.options.layoutRoot&&(t.relativeTarget=S,t.relativeTargetOrigin=b,t.relativeParent=p)}}}t.notifyListeners("didUpdate",{layout:s,snapshot:e,delta:l,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:h})}else if(t.isLead()){const{onExitComplete:s}=t.options;s&&s()}t.options.transition=void 0}function MSe(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function PSe(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function $Se(t){t.clearSnapshot()}function UV(t){t.clearMeasurements()}function DSe(t){t.isLayoutDirty=!0,t.updateLayout()}function FV(t){t.isLayoutDirty=!1}function OSe(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function LSe(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function VV(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function jSe(t){t.resolveTargetDelta()}function BSe(t){t.calcProjection()}
3821function USe(t){t.resetSkewAndRotation()}function FSe(t){t.removeLeadSnapshot()}function zV(t,e,n){t.translate=Li(e.translate,0,n),t.scale=Li(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function GV(t,e,n,s){t.min=Li(e.min,n.min,s),t.max=Li(e.max,n.max,s)}function VSe(t,e,n,s){GV(t.x,e.x,n.x,s),GV(t.y,e.y,n.y,s)}function zSe(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const GSe={duration:.45,ease:[.4,0,.1,1]},HV=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),qV=HV("applewebkit/")&&!HV("chrome/")?Math.round:bd;function WV(t){t.min=qV(t.min),t.max=qV(t.max)}function HSe(t){WV(t.x),WV(t.y)}function LQ(t,e,n){return t==="position"||t==="preserve-aspect"&&!hSe(DV(e),DV(n),.2)}function qSe(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const WSe=OQ({attachResizeListener:(t,e)=>wE(t,"resize",e),measureScroll:()=>{var t,e;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((e=document.body)==null?void 0:e.scrollTop)||0}},checkIsScrollRoot:()=>!0}),H4={current:void 0},jQ=OQ({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!H4.current){const t=new WSe({});t.mount(window),t.setOptions({layoutScroll:!0}),H4.current=t}return H4.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),C7=q.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function KV(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function KSe(...t){return e=>{let n=!1;const s=t.map(r=>{const i=KV(r,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<s.length;r++){const i=s[r];typeof i=="function"?i():KV(t[r],null)}}}}function YSe(...t){return q.useCallback(KSe(...t),t)}class XSe extends q.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(TI(n)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,r=TI(s)&&s.offsetWidth||0,i=TI(s)&&s.offsetHeight||0,a=getComputedStyle(n),o=this.props.sizeRef.current;o.height=parseFloat(a.height),o.width=parseFloat(a.width),o.top=n.offsetTop,o.left=n.offsetLeft,o.right=r-o.width-o.left,o.bottom=i-o.height-o.top}return null}componentDidUpdate(){}render(){return this.props.children}}function JSe({children:t,isPresent:e,anchorX:n,anchorY:s,root:r,pop:i}){var m;const a=q.useId(),o=q.useRef(null),l=q.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:c}=q.useContext(C7),h=((m=t.props)==null?void 0:m.ref)??(t==null?void 0:t.ref),p=YSe(o,h);return q.useInsertionEffect(()=>{const{width:y,height:v,top:b,left:S,right:E,bottom:I}=l.current;if(e||i===!1||!o.current||!y||!v)return;const M=n==="left"?`left: ${S}`:`right: ${E}`,j=s==="bottom"?`bottom: ${I}`:`top: ${b}`;o.current.dataset.motionPopId=a;const L=document.createElement("style");c&&(L.nonce=c);const K=r??document.head;return K.appendChild(L),L.sheet&&L.sheet.insertRule(`
3822          [data-motion-pop-id="${a}"] {
3823            position: absolute !important;
3824            width: ${y}px !important;
3825            height: ${v}px !important;
3826            ${M}px !important;
3827            ${j}px !important;
3828          }
3829        `),()=>{var D;(D=o.current)==null||D.removeAttribute("data-motion-pop-id"),K.contains(L)&&K.removeChild(L)}},[e]),d.jsx(XSe,{isPresent:e,childRef:o,sizeRef:l,pop:i,children:i===!1?t:q.cloneElement(t,{ref:p})})}const QSe=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:i,mode:a,anchorX:o,anchorY:l,root:c})=>{const h=n7(ZSe),p=q.useId();let m=!0,y=q.useMemo(()=>(m=!1,{id:p,initial:e,isPresent:n,custom:r,onExitComplete:v=>{h.set(v,!0);for(const b of h.values())if(!b)return;s&&s()},register:v=>(h.set(v,!1),()=>h.delete(v))}),[n,h,s]);return i&&m&&(y={...y}),q.useMemo(()=>{h.forEach((v,b)=>h.set(b,!1))},[n]),q.useEffect(()=>{!n&&!h.size&&s&&s()},[n]),t=d.jsx(JSe,{pop:a==="popLayout",isPresent:n,anchorX:o,anchorY:l,root:c,children:t}),d.jsx(CM.Provider,{value:y,children:t})};function ZSe(){return new Map}function BQ(t=!0){const e=q.useContext(CM);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=e,i=q.useId();q.useEffect(()=>{if(t)return r(i)},[t]);const a=q.useCallback(()=>t&&s&&s(i),[i,s,t]);return!n&&s?[!1,a]:[!0]}const $k=t=>t.key||"";function YV(t){const e=[];
vendor: 4,959 bytes, line 3829
3829return q.Children.forEach(t,n=>{q.isValidElement(n)&&e.push(n)}),e}const kv=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:i="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:c})=>{const[h,p]=BQ(a),m=q.useMemo(()=>YV(t),[t]),y=a&&!h?[]:m.map($k),v=q.useRef(!0),b=q.useRef(m),S=n7(()=>new Map),E=q.useRef(new Set),[I,M]=q.useState(m),[j,L]=q.useState(m);hJ(()=>{v.current=!1,b.current=m;for(let R=0;R<j.length;R++){const B=$k(j[R]);y.includes(B)?(S.delete(B),E.current.delete(B)):S.get(B)!==!0&&S.set(B,!1)}},[j,y.length,y.join("-")]);const K=[];if(m!==I){let R=[...m];for(let B=0;B<j.length;B++){const G=j[B],X=$k(G);y.includes(X)||(R.splice(B,0,G),K.push(G))}return i==="wait"&&K.length&&(R=K),L(YV(R)),M(m),null}const{forceRender:D}=q.useContext(t7);return d.jsx(d.Fragment,{children:j.map(R=>{const B=$k(R),G=a&&!h?!1:m===j||y.includes(B),X=()=>{if(E.current.has(B))return;if(S.has(B))E.current.add(B),S.set(B,!0);else return;let H=!0;S.forEach(Y=>{Y||(H=!1)}),H&&(D==null||D(),L(b.current),a&&(p==null||p()),s&&s())};return d.jsx(QSe,{isPresent:G,initial:!v.current||n?void 0:!1,custom:e,presenceAffectsLayout:r,mode:i,root:c,onExitComplete:G?void 0:X,anchorX:o,anchorY:l,children:R},B)})})},UQ=q.createContext({strict:!1}),XV={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let JV=!1;function eEe(){if(JV)return;const t={};for(const e in XV)t[e]={isEnabled:n=>XV[e].some(s=>!!n[s])};mQ(t),JV=!0}function FQ(){return eEe(),j2e()}function tEe(t){const e=FQ();for(const n in t)e[n]={...e[n],...t[n]};mQ(e)}const nEe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function nR(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||nEe.has(t)}let VQ=t=>!nR(t);function sEe(t){typeof t=="function"&&(VQ=e=>e.startsWith("on")?!nR(e):t(e))}try{sEe(require("@emotion/is-prop-valid").default)}catch{}function rEe(t,e,n){const s={};for(const r in t)r==="values"&&typeof t.values=="object"||Ho(t[r])||(VQ(r)||n===!0&&nR(r)||!e&&!nR(r)||t.draggable&&r.startsWith("onDrag"))&&(s[r]=t[r]);return s}const RM=q.createContext({});function iEe(t,e){if(NM(t)){const{initial:n,animate:s}=t;return{initial:n===!1||bE(n)?n:void 0,animate:bE(s)?s:void 0}}return t.inherit!==!1?e:{}}function aEe(t){const{initial:e,animate:n}=iEe(t,q.useContext(RM));return q.useMemo(()=>({initial:e,animate:n}),[QV(e),QV(n)])}function QV(t){return Array.isArray(t)?t.join(" "):t}const k7=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function zQ(t,e,n){for(const s in e)!Ho(e[s])&&!_Q(s,n)&&(t[s]=e[s])}function oEe({transformTemplate:t},e){return q.useMemo(()=>{const n=k7();return T7(n,e,t),Object.assign({},n.vars,n.style)},[e])}function lEe(t,e){const n=t.style||{},s={};return zQ(s,n,t),Object.assign(s,oEe(t,e)),s}function cEe(t,e){const n={},s=lEe(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const GQ=()=>({...k7(),attrs:{}});function uEe(t,e,n,s){const r=q.useMemo(()=>{const i=GQ();return SQ(i,e,TQ(s),t.transformTemplate,t.style),{...i.attrs,style:{...i.style}}},[e]);if(t.style){const i={};zQ(i,t.style,t),r.style={...i,...r.style}}return r}const dEe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function I7(t){return typeof t!="string"||t.includes("-")?!1:!!(dEe.indexOf(t)>-1||/[A-Z]/u.test(t))}function hEe(t,e,n,{latestValues:s},r,i=!1,a){const l=(a??I7(t)?uEe:cEe)(e,s,r,t),c=rEe(e,typeof t=="string",i),h=t!==q.Fragment?{...c,...l,ref:n}:{},{children:p}=e,m=q.useMemo(()=>Ho(p)?p.get():p,[p]);return q.createElement(t,{...h,children:m})}function fEe({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,r){return{latestValues:pEe(n,s,r,t),renderState:e()}}function pEe(t,e,n,s){const r={},i=s(t,{});for(const m in i)r[m]=NI(i[m]);let{initial:a,animate:o}=t;
vendor: 22,979 bytes, line 3829
3829const l=NM(t),c=fQ(t);e&&c&&!l&&t.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let h=n?n.initial===!1:!1;h=h||a===!1;const p=h?o:a;if(p&&typeof p!="boolean"&&!IM(p)){const m=Array.isArray(p)?p:[p];for(let y=0;y<m.length;y++){const v=y7(t,m[y]);if(v){const{transitionEnd:b,transition:S,...E}=v;for(const I in E){let M=E[I];if(Array.isArray(M)){const j=h?M.length-1:0;M=M[j]}M!==null&&(r[I]=M)}for(const I in b)r[I]=b[I]}}}return r}const HQ=t=>(e,n)=>{const s=q.useContext(RM),r=q.useContext(CM),i=()=>fEe(t,e,s,r);return n?i():n7(i)},mEe=HQ({scrapeMotionValuesFromProps:A7,createRenderState:k7}),gEe=HQ({scrapeMotionValuesFromProps:AQ,createRenderState:GQ}),yEe=Symbol.for("motionComponentSymbol");function xEe(t,e,n){const s=q.useRef(n);q.useInsertionEffect(()=>{s.current=n});const r=q.useRef(null);return q.useCallback(i=>{var o;i&&((o=t.onMount)==null||o.call(t,i));const a=s.current;if(typeof a=="function")if(i){const l=a(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):a(i);else a&&(a.current=i);e&&(i?e.mount(i):e.unmount())},[e])}const qQ=q.createContext({});function qb(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function vEe(t,e,n,s,r,i){var M,j;const{visualElement:a}=q.useContext(RM),o=q.useContext(UQ),l=q.useContext(CM),c=q.useContext(C7),h=c.reducedMotion,p=c.skipAnimations,m=q.useRef(null),y=q.useRef(!1);s=s||o.renderer,!m.current&&s&&(m.current=s(t,{visualState:e,parent:a,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:h,skipAnimations:p,isSVG:i}),y.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const v=m.current,b=q.useContext(qQ);v&&!v.projection&&r&&(v.type==="html"||v.type==="svg")&&bEe(m.current,n,r,b);const S=q.useRef(!1);q.useInsertionEffect(()=>{v&&S.current&&v.update(n,l)});const E=n[eQ],I=q.useRef(!!E&&typeof window<"u"&&!((M=window.MotionHandoffIsComplete)!=null&&M.call(window,E))&&((j=window.MotionHasOptimisedAnimation)==null?void 0:j.call(window,E)));return hJ(()=>{y.current=!0,v&&(S.current=!0,window.MotionIsMounted=!0,v.updateFeatures(),v.scheduleRenderMicrotask(),I.current&&v.animationState&&v.animationState.animateChanges())}),q.useEffect(()=>{v&&(!I.current&&v.animationState&&v.animationState.animateChanges(),I.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,E)}),I.current=!1),v.enteringChildren=void 0)}),v}function bEe(t,e,n,s){const{layoutId:r,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutAnchor:h,layoutCrossfade:p}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:WQ(t.parent)),t.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!a||o&&qb(o),visualElement:t,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:p,layoutScroll:l,layoutRoot:c,layoutAnchor:h})}function WQ(t){if(t)return t.options.allowProjection!==!1?t.projection:WQ(t.parent)}function q4(t,{forwardMotionProps:e=!1,type:n}={},s,r){s&&tEe(s);const i=n?n==="svg":I7(t),a=i?gEe:mEe;function o(c,h){let p;const m={...q.useContext(C7),...c,layoutId:wEe(c)},{isStatic:y}=m,v=aEe(c),b=a(c,y);if(!y&&typeof window<"u"){_Ee();const S=SEe(m);p=S.MeasureLayout,v.visualElement=vEe(t,b,m,r,S.ProjectionNode,i)}return d.jsxs(RM.Provider,{value:v,children:[p&&v.visualElement?d.jsx(p,{visualElement:v.visualElement,...m}):null,hEe(t,c,xEe(b,v.visualElement,h),b,y,e,i)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const l=q.forwardRef(o);return l[yEe]=t,l}function wEe({layoutId:t}){const e=q.useContext(t7).id;return e&&t!==void 0?e+"-"+t:t}function _Ee(t,e){q.useContext(UQ).strict}function SEe(t){const e=FQ(),{drag:n,layout:s}=e;if(!n&&!s)return{};const r={...n,...s};return{MeasureLayout:n!=null&&n.isEnabled(t)||s!=null&&s.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function EEe(t,e){if(typeof Proxy>"u")return q4;const n=new Map,s=(i,a)=>q4(i,a,t,e),r=(i,a)=>s(i,a);return new Proxy(r,{get:(i,a)=>a==="create"?s:(n.has(a)||n.set(a,q4(a,void 0,t,e)),n.get(a))})}const TEe=(t,e)=>e.isSVG??I7(t)?new tSe(e):new Y2e(e,{allowProjection:t!==q.Fragment});class AEe extends ey{constructor(e){super(e),e.animationState||(e.animationState=aSe(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();IM(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let CEe=0;class kEe extends ey{constructor(){super(...arguments),this.id=CEe++,this.isExitComplete=!1}update(){var i;if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;if(e&&s===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=fv(this.node,a,o);if(l){const{transition:c,transitionEnd:h,...p}=l;for(const m in p)(i=this.node.getValue(m))==null||i.jump(p[m])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);n&&!e&&r.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const IEe={animation:{Feature:AEe},exit:{Feature:kEe}};function NA(t){return{point:{x:t.pageX,y:t.pageY}}}const NEe=t=>e=>w7(e)&&t(e,NA(e));function zS(t,e,n,s){return wE(t,e,NEe(n),s)}const KQ=({current:t})=>t?t.ownerDocument.defaultView:null,ZV=(t,e)=>Math.abs(t-e);function REe(t,e){const n=ZV(t.x,e.x),s=ZV(t.y,e.y);return Math.sqrt(n**2+s**2)}const ez=new Set(["auto","scroll"]);class YQ{constructor(e,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=y=>{this.handleScroll(y.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Dk(this.lastRawMoveEventInfo,this.transformPagePoint));const y=W4(this.lastMoveEventInfo,this.history),v=this.startEvent!==null,b=REe(y.offset,{x:0,y:0})>=this.distanceThreshold;if(!v&&!b)return;const{point:S}=y,{timestamp:E}=Uo;this.history.push({...S,timestamp:E});const{onStart:I,onMove:M}=this.handlers;v||(I&&I(this.lastMoveEvent,y),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,y)},this.handlePointerMove=(y,v)=>{this.lastMoveEvent=y,this.lastRawMoveEventInfo=v,this.lastMoveEventInfo=Dk(v,this.transformPagePoint),pi.update(this.updatePoint,!0)},this.handlePointerUp=(y,v)=>{this.end();const{onEnd:b,onSessionEnd:S,resumeAnimation:E}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&E&&E(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const I=W4(y.type==="pointercancel"?this.lastMoveEventInfo:Dk(v,this.transformPagePoint),this.history);this.startEvent&&b&&b(y,I),S&&S(y,I)},!w7(e))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const l=NA(e),c=Dk(l,this.transformPagePoint),{point:h}=c,{timestamp:p}=Uo;this.history=[{...h,timestamp:p}];const{onSessionStart:m}=n;m&&m(e,W4(c,this.history)),this.removeListeners=CA(zS(this.contextWindow,"pointermove",this.handlePointerMove),zS(this.contextWindow,"pointerup",this.handlePointerUp),zS(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let n=e.parentElement;for(;n;){const s=getComputedStyle(n);(ez.has(s.overflowX)||ez.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const s=e===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-n.x,y:r.y-n.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),pi.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),G0(this.updatePoint)}}function Dk(t,e){return e?{point:e(t.point)}:t}function tz(t,e){return{x:t.x-e.x,y:t.y-e.y}}function W4({point:t},e){return{point:t,delta:tz(t,XQ(e)),offset:tz(t,MEe(e)),velocity:PEe(e,.1)}}function MEe(t){return t[0]}function XQ(t){return t[t.length-1]}function PEe(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const r=XQ(t);for(;n>=0&&(s=t[n],!(r.timestamp-s.timestamp>Nu(e)));)n--;if(!s)return{x:0,y:0};s===t[0]&&t.length>2&&r.timestamp-s.timestamp>Nu(e)*2&&(s=t[1]);const i=gd(r.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const a={x:(r.x-s.x)/i,y:(r.y-s.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function $Ee(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?Li(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?Li(n,t,s.max):Math.min(t,n)),t}function nz(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function DEe(t,{top:e,left:n,bottom:s,right:r}){return{x:nz(t.x,n,r),y:nz(t.y,e,s)}}function sz(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function OEe(t,e){return{x:sz(t.x,e.x),y:sz(t.y,e.y)}}function LEe(t,e){let n=.5;const s=ec(t),r=ec(e);return r>s?n=xE(e.min,e.max-s,t.min):s>r&&(n=xE(t.min,t.max-r,e.min)),gp(0,1,n)}function jEe(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const FD=.35;function BEe(t=FD){return t===!1?t=0:t===!0&&(t=FD),{x:rz(t,"left","right"),y:rz(t,"top","bottom")}}function rz(t,e,n){return{min:iz(t,e),max:iz(t,n)}}function iz(t,e){return typeof t=="number"?t:t[e]||0}const UEe=new WeakMap;class FEe{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=so(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=p=>{n&&this.snapToCursor(NA(p).point),this.stopAnimation()},a=(p,m)=>{const{drag:y,dragPropagation:v,onDragStart:b}=this.getProps();if(y&&!v&&(this.openDragLock&&this.openDragLock(),this.openDragLock=p2e(y),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),jf(E=>{let I=this.getAxisMotionValue(E).get()||0;if(up.test(I)){const{projection:M}=this.visualElement;if(M&&M.layout){const j=M.layout.layoutBox[E];j&&(I=ec(j)*(parseFloat(I)/100))}}this.originPoint[E]=I}),b&&pi.update(()=>b(p,m),!1,!0),MD(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},o=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:y,dragDirectionLock:v,onDirectionLock:b,onDrag:S}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:E}=m;if(v&&this.currentDirection===null){this.currentDirection=zEe(E),this.currentDirection!==null&&b&&b(this.currentDirection);return}this.updateAxis("x",m.point,E),this.updateAxis("y",m.point,E),this.visualElement.render(),S&&pi.update(()=>S(p,m),!1,!0)},l=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new YQ(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:KQ(this.visualElement),element:this.visualElement.current})}stop(e,n){const s=e||this.latestPointerEvent,r=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!s)return;const{velocity:a}=r;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&pi.postRender(()=>o(s,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,s){const{drag:r}=this.getProps();if(!s||!Ok(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=$Ee(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){var i;const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,r=this.constraints;e&&qb(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=DEe(s.layoutBox,e):this.constraints=!1,this.elastic=BEe(n),r!==this.constraints&&!qb(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&jf(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=jEe(s.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!qb(e))return!1;const s=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const i=z2e(s,r.root,this.visualElement.getTransformPagePoint());let a=OEe(r.layout.layoutBox,i);if(n){const o=n(U2e(a));this.hasMutatedConstraints=!!o,o&&(a=yQ(o))}return a}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},c=jf(h=>{if(!Ok(h,n,this.currentDirection))return;let p=l&&l[h]||{};(a===!0||a===h)&&(p={min:0,max:0});const m=r?200:1e6,y=r?40:1e7,v={type:"inertia",velocity:s?e[h]:0,bounceStiffness:m,bounceDamping:y,timeConstant:750,restDelta:1,restSpeed:10,...i,...p};return this.startAxisValueAnimation(h,v)});return Promise.all(c).then(o)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return MD(this.visualElement,e),s.start(g7(e,s,0,n,this.visualElement,!1))}stopAnimation(){jf(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),r=s[n];return r||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){jf(n=>{const{drag:s}=this.getProps();if(!Ok(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[n],l=i.get()||0;i.set(e[n]-Li(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!qb(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};jf(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=LEe({min:l,max:l},this.constraints[a])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),jf(a=>{if(!Ok(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:c}=this.constraints[a];o.set(Li(l,c,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;UEe.set(this.visualElement,this);const e=this.visualElement.current,n=zS(e,"pointerdown",c=>{const{drag:h,dragListener:p=!0}=this.getProps(),m=c.target,y=m!==e&&b2e(m);h&&p&&!y&&this.start(c)});let s;const r=()=>{const{dragConstraints:c}=this.getProps();qb(c)&&c.current&&(this.constraints=this.resolveRefConstraints(),s||(s=VEe(e,c.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,a=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),pi.read(r);const o=wE(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:h})=>{this.isDragging&&h&&(jf(p=>{const m=this.getAxisMotionValue(p);m&&(this.originPoint[p]+=c[p].translate,m.set(m.get()+c[p].translate))}),this.visualElement.render())}));return()=>{o(),n(),a(),l&&l(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=FD,dragMomentum:o=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function az(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function VEe(t,e,n){const s=fV(t,az(n)),r=fV(e,az(n));return()=>{s(),r()}}function Ok(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function zEe(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class GEe extends ey{constructor(e){super(e),this.removeGroupControls=bd,this.removeListeners=bd,this.controls=new FEe(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||bd}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const K4=t=>(e,n)=>{t&&pi.update(()=>t(e,n),!1,!0)};class HEe extends ey{constructor(){super(...arguments),this.removePointerDownListener=bd}onPointerDown(e){this.session=new YQ(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:KQ(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:K4(e),onStart:K4(n),onMove:K4(s),onEnd:(i,a)=>{delete this.session,r&&pi.postRender(()=>r(i,a))}}}mount(){this.removePointerDownListener=zS(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Y4=!1;class qEe extends q.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:i}=e;i&&(n.group&&n.group.add(i),s&&s.register&&r&&s.register(i),Y4&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),RI.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:r,isPresent:i}=this.props,{projection:a}=s;return a&&(a.isPresent=i,e.layoutDependency!==n&&a.setOptions({...a.options,layoutDependency:n}),Y4=!0,r||e.layoutDependency!==n||n===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||pi.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:n}=this.props,{projection:s}=e;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),b7.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=e;Y4=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function JQ(t){const[e,n]=BQ(),s=q.useContext(t7);return d.jsx(qEe,{...t,layoutGroup:s,switchLayoutGroup:q.useContext(qQ),isPresent:e,safeToRemove:n})}const WEe={pan:{Feature:HEe},drag:{Feature:GEe,ProjectionNode:jQ,MeasureLayout:JQ}};function oz(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,i=s[r];i&&pi.postRender(()=>i(e,NA(e)))}class KEe extends ey{mount(){const{current:e}=this.node;e&&(this.unmount=g2e(e,(n,s)=>(oz(this.node,s,"Start"),r=>oz(this.node,r,"End"))))}unmount(){}}class YEe extends ey{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=CA(wE(this.node.current,"focus",()=>this.onFocus()),wE(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function lz(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),i=s[r];i&&pi.postRender(()=>i(e,NA(e)))}class XEe extends ey{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=_2e(e,(r,i)=>(lz(this.node,i,"Start"),(a,{success:o})=>lz(this.node,a,o?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const VD=new WeakMap,X4=new WeakMap,JEe=t=>{const e=VD.get(t.target);e&&e(t)},QEe=t=>{t.forEach(JEe)};function ZEe({root:t,...e}){const n=t||document;X4.has(n)||X4.set(n,{});const s=X4.get(n),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(QEe,{root:t,...e})),s[r]}function eTe(t,e,n){const s=ZEe(e);return VD.set(t,n),s.observe(t),()=>{VD.delete(t),s.unobserve(t)}}const tTe={some:0,all:1};
3829class nTe extends ey{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:i}=e,a={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:tTe[r]},o=c=>{const{isIntersecting:h}=c;if(this.isInView===h||(this.isInView=h,i&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:p,onViewportLeave:m}=this.node.getProps(),y=h?p:m;y&&y(c)};this.stopObserver=eTe(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(sTe(e,n))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function sTe({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const rTe={inView:{Feature:nTe},tap:{Feature:XEe},focus:{Feature:YEe},hover:{Feature:KEe}},iTe={layout:{ProjectionNode:jQ,MeasureLayout:JQ}},aTe={...IEe,...rTe,...WEe,...iTe},ks=EEe(aTe,TEe),N7=({onGoApp:t,compact:e=!1})=>d.jsxs(ks.div,{initial:{opacity:0,y:e?12:24},animate:{opacity:1,y:0},transition:{duration:.6},className:`text-center ${e?"max-w-md mx-auto":"max-w-lg mx-auto"} space-y-6 px-4`,children:[d.jsx("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-amber-500/10 flex items-center justify-center",children:d.jsx(EA,{className:"w-8 h-8 text-amber-400"})}),d.jsxs("div",{className:"space-y-3",children:[d.jsx("h1",{className:`font-extrabold text-white tracking-tight ${e?"text-2xl":"text-3xl sm:text-4xl"}`,children:"Your payment is still pending"}),d.jsx("p",{className:"text-slate-400 leading-relaxed",children:"We're still waiting for confirmation from your payment provider. This usually takes a few minutes — sometimes a bit longer during peak hours."}),d.jsx("p",{className:"text-slate-400 leading-relaxed",children:"You don't need to pay again. Once verified, your plan will activate automatically when you open the app, and you'll see your celebration screen."})]}),!e&&d.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3 pt-2",children:[t?d.jsx("button",{type:"button",onClick:t,className:"inline-flex items-center gap-2 px-6 py-3 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-xl font-bold transition-colors",children:"Go to app"}):d.jsx(Is,{to:"/app",className:"inline-flex items-center gap-2 px-6 py-3 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-xl font-bold transition-colors",children:"Go to app"}),d.jsxs(Is,{to:"/",className:"inline-flex items-center gap-2 px-6 py-3 border border-slate-700 hover:border-slate-500 text-white rounded-xl font-medium transition-colors",children:[d.jsx(HL,{className:"w-4 h-4"}),"Back to homepage"]})]})]}),cz=({isOpen:t,onClose:e})=>d.jsx(kv,{children:t&&d.jsx(ks.div,{initial:{opacity:0}
3829,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:e,children:d.jsxs(ks.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"bg-[#011f08] border border-slate-700 rounded-2xl shadow-2xl w-full max-w-md overflow-hidden",onClick:n=>n.stopPropagation(),children:[d.jsxs("div",{className:"flex items-start justify-between p-6 border-b border-slate-800",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-500/10 flex items-center justify-center",children:d.jsx(EA,{className:"w-5 h-5 text-amber-500"})}),d.jsx("h2",{className:"text-lg font-bold text-white",children:"Payment pending"})]}),d.jsx("button",{onClick:e,className:"text-slate-400 hover:text-white p-2 rounded-full hover:bg-slate-800 transition-colors","aria-label":"Close",children:d.jsx(Ki,{className:"w-5 h-5"})})]}),d.jsxs("div",{className:"p-6 space-y-4",children:[d.jsx(N7,{compact:!0}),d.jsx("button",{onClick:e,className:"w-full py-3 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-xl font-bold transition-colors",children:"Got it"})]})]})})}),QQ="csv_pending_notice_";function R7(t){return`${QQ}${t}`}function oTe(t){return localStorage.getItem(R7(t))==="1"}function M7(t){return!oTe(t)}function P7(t){localStorage.setItem(R7(t),"1")}function $7(t){if(t){localStorage.removeItem(R7(t));return}for(let e=localStorage.length-1;e>=0;e-=1){const n=localStorage.key(e);n!=null&&n.startsWith(QQ)&&localStorage.removeItem(n)}}const G1="csv_payment_invoice_id",H1="csv_awaiting_payment_return";function lTe(t){localStorage.setItem(G1,t),sessionStorage.setItem(G1,t)}function cTe(){localStorage.setItem(H1,"1"),sessionStorage.setItem(H1,"1")}function ZQ(){return localStorage.getItem(H1)==="1"||sessionStorage.getItem(H1)==="1"}function uz(){localStorage.removeItem(H1),sessionStorage.removeItem(H1)}function zv(){return localStorage.getItem(G1)??sessionStorage.getItem(G1)}function Wy(){localStorage.removeItem(G1),sessionStorage.removeItem(G1)}function eZ(t){return t.get("invoice_id")??t.get("invoiceId")??t.get("invoice")??t.get("payment_id")??t.get("paymentId")??t.get("trx_id")??t.get("transaction_id")??t.get("id")??zv()}function uTe(t){return["invoice_id","invoiceId","invoice","payment_id","paymentId","trx_id","transaction_id","status","payment_status","paymentStatus","result","cancelled","cancel","canceled"].some(n=>t.has(n))}function dTe(t){const e=t.get("status")??t.get("payment_status")??t.get("paymentStatus")??t.get("result");return e?RA(e):null}function RA(t){const e=String(t??"PENDING").trim().toUpperCase();return e==="CANCELED"||e==="CANCELLED"||e==="FALSE"||e==="FAIL"?"FAILED":e==="SUCCESS"?"COMPLETED":e==="COMPLETED"||e==="FAILED"||e==="PENDING"?e:"PENDING"}function J4(t){return RA(t)==="FAILED"}function Lk(t){return RA(t)==="PENDING"}function hTe(t){return RA(t)==="COMPLETED"}const fTe=["config","headerBanners"],Ng={text:"Learn more",url:"/pricing",backgroundColor:"#011f08",textColor:"#47ff72",borderRadius:8,fontSize:14,paddingX:14,paddingY:8};function pTe(t){return t==="home"||t==="app"||t==="both"?t:"both"}function mTe(t){const e=t&&typeof t=="object"?t:{};return{enabled:e.enabled===!0,text:typeof e.text=="string"?e.text:Ng.text,url:typeof e.url=="string"?e.url:Ng.url,backgroundColor:typeof e.backgroundColor=="string"?e.backgroundColor:Ng.backgroundColor,textColor:typeof e.textColor=="string"?e.textColor:Ng.textColor,borderRadius:Number(e.borderRadius??Ng.borderRadius)||8,fontSize:Number(e.fontSize??Ng.fontSize)||14,bold:e.bold!==!1,paddingX:Number(e.paddingX??Ng.paddingX)||14,paddingY:Number(e.paddingY??Ng.paddingY)||8}}function gTe(t){if(!t||typeof t!="object")return null;const e=t;if(typeof e.id!="string"||typeof e.text!="string")return null;const n=e.textStyle??{},s=e.rectangle??{};return{id:e.id,name:typeof e.name=="string"?e.name:"Header Banner",text:e.text,placement:pTe(e.placement),active:e.active===!0,createdAt:Number(e.createdAt??0),updatedAt:Number(e.updatedAt??0),activatedAt:Number(e.activatedAt??e.updatedAt??0),textStyle:{bold:n.bold===!0,italic:n.italic===!0,underline:n.underline===!0,align:n.align==="left"||n.align==="right"?n.align:"center",verticalAlign:n.verticalAlign==="top"?"top":"center",color:typeof n.color=="string"?n.color:"#011f08",fontSize:Number(n.fontSize??15)||15},rectangle:{paddingX:Number(s.paddingX??20)||20,paddingY:Number(s.paddingY??10)||10,height:Number(s.height??52)||0,backgroundColor:typeof s.backgroundColor=="string"?s.backgroundColor:"#47ff72",borderRadius:Number(s.borderRadius??0)||0,maxWidth:Number(s.maxWidth??1600)||1600},cta:mTe(e.cta)}}async function tZ(t){try{const e=await Q0(Td(Bc,...fTe));if(!e.exists())return null;const n=e.data().banners;return Array.isArray(n)?n.map(gTe).filter(r=>r!==null&&r.active&&o1e(r.placement,t)&&!uJ(r)).sort((r,i)=>i.updatedAt-r.updatedAt)[0]??null:null}catch(e){return console.warn("Could not load header banner",e),null}}
3829const nZ="/assets/csv-meta-hero-image-D3R9hG8_.webp",jk=({icon:t,title:e,desc:n})=>d.jsxs("div",{className:"p-6 bg-white dark:bg-white/5 border border-slate-200 dark:border-slate-800 rounded-2xl hover:border-brand-500/50 dark:hover:border-brand-500/50 transition-all duration-300 group shadow-sm dark:shadow-none",children:[d.jsx("div",{className:"w-12 h-12 bg-brand-500/10 rounded-xl flex items-center justify-center text-brand-500 mb-4 group-hover:scale-110 transition-transform",children:t}),d.jsx("h3",{className:"text-slate-900 dark:text-white font-bold mb-2",children:e}),d.jsx("p",{className:"text-slate-500 dark:text-slate-400 text-sm leading-relaxed",children:n})]}),L2=({question:t,answer:e})=>{const[n,s]=q.useState(!1);return d.jsxs("div",{className:"border-b border-slate-200 dark:border-slate-800 last:border-0",children:[d.jsxs("button",{onClick:()=>s(!n),className:"w-full flex items-center justify-between py-5 text-left hover:text-brand-500 dark:hover:text-brand-500 transition-colors",children:[d.jsx("span",{className:"text-slate-800 dark:text-white font-medium pr-8",children:t}),n?d.jsx(XX,{className:"w-5 h-5 text-brand-500"}):d.jsx(P0,{className:"w-5 h-5 text-slate-400 dark:text-slate-500"})]}),d.jsx("div",{className:`overflow-hidden transition-all duration-300 ${n?"max-h-96 pb-5 opacity-100":"max-h-0 opacity-0"}`,children:d.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-sm leading-relaxed",children:e})})]})},yTe=()=>{const[t,e]=q.useState(null),[n,s]=q.useState(!0),[r,i]=q.useState(null),[a,o]=q.useState(!1),[l,c]=q.useState(null),h=co(),[p]=lA();q.useEffect(()=>{let v=!1;return tZ("home").then(b=>{v||c(b)}),()=>{v=!0}},[]),q.useEffect(()=>{if(!(p.get("payment_pending")==="true"))return;const b=zv();b&&M7(b)&&(P7(b),o(!0));const S=new URLSearchParams(p);S.delete("payment_pending");const E=S.toString();window.history.replaceState({},"",E?`/?${E}`:"/")},[p]),q.useEffect(()=>{const v=Vm(Ko,async b=>{if(b){const S=vM(b);e(S),localStorage.setItem("google_user_session",JSON.stringify(S));try{const E=await Vv(b);e(E),localStorage.setItem("google_user_session",JSON.stringify(E))}catch(E){console.error("Error saving user to Firestore",E)}}else e(null),localStorage.removeItem("google_user_session");s(!1)});return()=>v()},[]);const m=()=>{h("/auth")},y=()=>{t?h("/app"):m()};return n?d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08]",children:d.jsxs("div",{className:"flex flex-col items-center gap-6",children:[d.jsxs("div",{className:"relative flex items-center justify-center",children:[d.jsx(Go,{className:"w-16 h-16 text-[#47ff72] animate-spin"}),d.jsx("img",{src:"/icon.png",alt:"CSV Meta Icon",className:"absolute w-8 h-8 object-contain"})]}),d.jsx("p",{className:"text-slate-300 font-medium tracking-wide text-sm uppercase",children:"Initializing CSV Meta..."})]})}),d.jsx(cz,{isOpen:a,onClose:()=>o(!1)})]}):d.jsxs("div",{className:"min-h-screen flex flex-col bg-[#011f08] text-slate-100 transition-colors duration-300 font-sans",children:[r&&d.jsxs("div",{className:"bg-red-500 text-white px-4 py-2 text-center text-sm font-medium relative flex items-center justify-center shadow-md z-50",children:[d.jsx(S0,{className:"w-4 h-4 mr-2"}),d.jsxs("span",{children:["Your account is blocked. To restore access, please contact ",d.jsx("a",{href:"mailto:[email protected]",className:"underline font-bold hover:text-red-100 transition-colors",children:"support"}),"."]}),d.jsx("button",{onClick:()=>i(null),className:"absolute right-4 top-1/2 -translate-y-1/2 hover:text-red-200 transition-colors",children:d.jsx(Ki,{className:"w-4 h-4"})})]}),d.jsx(V0,{}),l&&d.jsx(dJ,{banner:l,onDismiss:()=>c(null)}),d.jsx("main",{className:"flex-1 w-full",children:d.jsxs("div",{className:"w-full animate-in fade-in duration-700",children:[d.jsxs("section",{className:"relative pt-20 pb-16 md:pt-32 md:pb-24 overflow-hidden px-4 sm:px-6 lg:px-8",children:[d.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[#47ff72]/10 to-transparent dark:from-[#47ff72]/5 pointer-events-none"}),d.jsxs("div",{className:"relative z-10 text-center space-y-8 max-w-4xl mx-auto",children:[d.jsxs("h1",{className:"text-4xl md:text-6xl font-extrabold text-white tracking-tight",children:["The Ultimate ",d.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-[#47ff72] to-[#00d2ff]",children:"Microstock Metadata Generator"})]}),d.jsx("p",{className:"text-lg md:text-xl text-slate-300 max-w-2xl mx-auto leading-relaxed",children:"CSV Meta is your all-in-one CSV metadata generator and microstock SEO tool. Automate your workflow, generate perfect titles and ke
3829ywords, and dominate stock photigraphy SEO with AI-powered precision."}),d.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 pt-4",children:[d.jsx("button",{onClick:y,className:"relative group w-[245px] h-[48px] flex items-center justify-center cursor-pointer overflow-hidden rounded-xl border-none outline-none",children:d.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center gap-2 px-6 py-3 bg-[#47ff72] text-slate-900 rounded-xl font-bold transition-transform duration-200 group-hover:scale-105 pointer-events-none shadow-lg shadow-[#47ff72]/20",children:[d.jsx(vd,{className:"w-5 h-5"}),d.jsx("span",{children:t?"Start Generating":"Start Generating Free"})]})}),d.jsxs("a",{href:"https://chromewebstore.google.com/detail/foliaahbfnegnbmclfomfeamfkmnncjm",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 px-6 py-3 border-2 border-slate-700 hover:border-[#47ff72] text-white rounded-xl font-bold transition-all h-[48px] w-full sm:w-auto",children:[d.jsx(Ua,{className:"w-5 h-5"}),d.jsx("span",{children:"Download Chrome Extension"})]})]})]}),d.jsxs("div",{className:"relative z-10 mt-12 md:mt-16 mx-auto max-w-5xl",children:[d.jsx("div",{className:"absolute -inset-6 md:-inset-10 bg-[#47ff72]/8 blur-3xl rounded-full pointer-events-none"}),d.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-700/60 shadow-[0_20px_60px_rgba(0,0,0,0.45)] ring-1 ring-[#47ff72]/15",children:[d.jsx("img",{src:nZ,alt:"CSV Meta metadata generator interface",className:"w-full h-auto block",loading:"eager",decoding:"async"}),d.jsx("div",{className:"absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-[#011f08]/80 to-transparent pointer-events-none"})]})]})]}),d.jsxs("section",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16 space-y-10",children:[d.jsxs("div",{className:"text-center space-y-2",children:[d.jsx("h2",{className:"text-2xl font-bold text-white uppercase tracking-widest text-sm",children:"Key Features"}),d.jsx("p",{className:"text-slate-400",children:"Everything you need to scale your stock photography business."})]}),d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[d.jsx(jk,{icon:d.jsx(vd,{className:"w-6 h-6"}),title:"Instant Metadata",desc:"Generate titles, keywords, and categories for hundreds of files in minutes using world-class AI models."}),d.jsx(jk,{icon:d.jsx(YX,{className:"w-6 h-6"}),title:"Stock Optimized",desc:"SEO-friendly results tailored specifically for the requirements of Adobe Stock, Shutterstock and Freepik."}),d.jsx(jk,{icon:d.jsx(ZX,{className:"w-6 h-6"}),title:"Multi-Format",desc:"Seamlessly process Photos (JPG/PNG), Videos (MP4/MOV), and Vectors (SVG/AI/EPS)."}),d.jsx(jk,{icon:d.jsx(t_,{className:"w-6 h-6"}),title:"Privacy First",desc:"Your files are analyzed locally in your browser. We never store or save your creative assets on our servers."})]})]}),d.jsx("section",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:d.jsxs("div",{className:"bg-gradient-to-br from-white via-emerald-50/80 to-slate-50 dark:from-slate-900 dark:via-emerald-950/40 dark:to-slate-900 border border-[#47ff72]/30 rounded-3xl p-8 md:p-12 text-center relative overflow-hidden flex flex-col items-center shadow-[0_0_40px_rgba(71,255,114,0.1)]",children:[d.jsx("div",{className:"absolute -top-32 -left-32 w-64 h-64 bg-[#47ff72] rounded-full mix-blend-overlay filter blur-[100px] opacity-20 dark:opacity-40 animate-pulse"}),d.jsx("div",{className:"absolute -bottom-32 -right-32 w-64 h-64 bg-emerald-500 rounded-full mix-blend-overlay filter blur-[100px] opacity-20 dark:opacity-40"}),d.jsxs("h2",{className:"text-3xl md:text-4xl font-extrabold text-slate-900 dark:text-white mb-6 relative z-10 leading-tight",children:[d.jsx("span",{className:"text-[#47ff72]",children:"CSV Meta"})," is the first ever metadata generation tool offering ",d.jsx("span",{className:"bg-clip-text text-transparent bg-gradient-to-r from-emerald-600 to-slate-900 dark:from-emerald-200 dark:to-white",children:"EPS/SVG/MP4 metadata embedding"})," for free."]}
3829),d.jsx("p",{className:"text-lg text-slate-600 dark:text-emerald-100/80 max-w-2xl mb-8 relative z-10",children:"Stop wasting hours manually tagging vectors and videos. Join creators who are automating their workflow right now. Don't fall behind—experience the future of microstock!"}),d.jsx("div",{className:"relative z-10",children:d.jsxs("button",{onClick:y,className:"group relative inline-flex items-center justify-center px-8 py-4 font-bold text-slate-900 bg-[#47ff72] hover:bg-[#3ce565] transition-all rounded-xl overflow-hidden shadow-[0_0_20px_rgba(71,255,114,0.4)] hover:shadow-[0_0_30px_rgba(71,255,114,0.6)] transform hover:-translate-y-1",children:[d.jsx("span",{className:"mr-2 text-lg",children:t?"Open Tool":"Try now"}),d.jsx(vd,{className:"w-5 h-5 group-hover:scale-110 transition-transform animate-pulse"})]})})]})}),d.jsxs("section",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16 space-y-10",children:[d.jsxs("div",{className:"text-center space-y-2",children:[d.jsx("h2",{className:"text-2xl font-bold text-white uppercase tracking-widest text-sm",children:"Beautiful Words from our users"}),d.jsx("p",{className:"text-slate-400",children:"See what other creators are saying about CSV Meta."})]}),d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[d.jsxs("div",{className:"bg-white dark:bg-slate-800 p-6 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700",children:[d.jsx("div",{className:"flex text-yellow-400 mb-4",children:"★★★★★"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-300 mb-6",children:'"This tool has completely transformed my workflow. What used to take hours now takes minutes. The Adobe Stock metadata generator is spot on!"'}),d.jsx("div",{className:"font-bold text-slate-900 dark:text-white",children:"Siam"}),d.jsx("div",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Stock Photographer"})]}),d.jsxs("div",{className:"bg-white dark:bg-slate-800 p-6 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700",children:[d.jsx("div",{className:"flex text-yellow-400 mb-4",children:"★★★★★"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-300 mb-6",children:`"I've tried many Shutterstock metadata generators, but CSV Meta is by far the most accurate. My sales have increased since I started using it."`}),d.jsx("div",{className:"font-bold text-slate-900 dark:text-white",children:"Rabiul"}),d.jsx("div",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Vector Artist"})]}),d.jsxs("div",{className:"bg-white dark:bg-slate-800 p-6 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700",children:[d.jsx("div",{className:"flex text-yellow-400 mb-4",children:"★★★★★"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-300 mb-6",children:'"The Freepik SEO optimization is incredible. It finds keywords I would never have thought of. Highly recommended for any microstock contributor."'}),d.jsx("div",{className:"font-bold text-slate-900 dark:text-white",children:"Khalid"}),d.jsx("div",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Content Creator"})]})]})]}),d.jsxs("section",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-20 text-center space-y-8",children:[d.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-white",children:["Over ",d.jsx("span",{className:"text-[#47ff72]",children:"200+ Users"})," are currently using CSV Meta"]}),d.jsx("p",{className:"text-lg text-slate-300 max-w-2xl mx-auto",children:"Join to unlock the magic of perfect microstock metadata. Start optimizing your portfolio today."}),d.jsx("div",{className:"flex justify-center pt-4",children:d.jsx("button",{onClick:y,className:"relative group w-[240px] h-[48px] flex items-center justify-center cursor-pointer overflow-hidden rounded-xl border-none outline-none",children:d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center gap-2 px-6 py-3 bg-white text-slate-900 rounded-xl font-bold transition-transform duration-200 group-hover:scale-105 pointer-events-none shadow-lg",children:d.jsx("span",{children:t?"Go to Dashboard":"Get Started Now"})})})})]}),d.jsxs("section",{className:"max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 py-16 space-y-10",children:[d.jsxs("div",{className:"text-center space-y-2",children:[d.jsx("h2",{className:"text-2xl font-bold text-white uppercase tracking-widest text-sm",children:"Frequently Asked Questions"}),d.jsx("p",{className:"text-slate-400",children:"Answers to common questions about our platform."})]}),d.jsxs("div",{className:"bg-white dark:bg-slate-800/50 border border-slate-200 dark:border-slate-800 rounded-3xl p-8 shadow-xl",children:[d.jsx(L2,{question:"Does CSV Meta store my uploaded photos or videos?",answer:"Absolutely not. CSV Meta operates on a 'local-first' principle. Your files are only read by your browser to send visual data to the AI API for analysis. They are never uploaded to our servers, ensuring your intellectual property remains yours alone."}),d.jsx(L2,{question:"Is this tool free to use?",answer:"The tool itself is free to access. However, it requires a Gemini, Groq or Mistral AI API key to function. Google, Groq and Mistral offer a generous free tier for their keys which most contributors find sufficient for their monthly needs."}),d.jsx(L2,{question:"Which platforms are supported for CSV export?",answer:"Currently, we support specialized exports for Adobe Stock, Shutterstock and Freepik. The tool automatically handles category mapping and character limits specific to each platform's CSV upload requirements."}),d.jsx(L2,{question:"How accurate are the generated keywords?",answer:"By using advanced models like Gemini 2.5 Flash, the metadata is highly descriptive and context-aware. It captures colors, emotions, subjects, and lighting better than standard automated taggers. You can always review and edit results before exporting."}),d.jsx(L2,{question:"What is Image-to-Prompt mode?",answer:"Image-to-Prompt is a reverse-engineering tool. Upload an image, and the AI will generate a highly detailed prompt that you can use in tools like Midjourney, DALL-E, or Leonardo.ai to generate similar content."})]})]})]})}),d.jsx(AM,{}),d.jsx(cz,{isOpen:a,onClose:()=>o(!1)})]})},xTe=()=>{const t=co(),[e,n]=WO.useState(null);q.useEffect(()=>{const r=Vm(Ko,i=>{i&&t("/app")});return()=>r()},[t]);const s=async()=>{n(null);try{await lve(),t("/app")}catch(r){console.error("Sign in failed",r),((r==null?void 0:r.code)==="auth/user-disabled"||String(r).includes("user-disabled"))&&n("Your account is blocked. To restore access, please contact support.")}};return d.jsxs("div",{className:"min-h-screen flex flex-col md:flex-row bg-[#011f08] font-sans text-slate-100 overflow-hidden relative",children:[d.jsx(Is,{to:"/",className:"fixed top-6 left-6 md:top-8 md:left-10 z-50 transition-transform hover:scale-105 active:scale-95",children:d.jsx("img",{src:"/logo.png",alt:"CSV Meta",className:"h-10 md:h-12 w-auto object-contain"})}),e&&d.jsxs(ks.div,{initial:{y:-100},animate:{y:0},className:"fixed top-0 left-0 right-0 bg-red-500 text-white px-4 py-3 text-center text-sm font-medium flex items-center justify-center shadow-md z-[60]",children:[d.jsx(S0,{className:"w-5 h-5 mr-2"}),d.jsxs("span",{children:["Your account is blocked. To restore access, please contact ",d.jsx("a",{href:"mailto:[email protected]",className:"underline font-bold hover:text-red-100 transition-colors",children:"support"}),"."]}),d.jsx("button",{onClick:()=>n(null),className:"absolute right-4 top-1/2 -translate-y-1/2 hover:text-red-200 transition-colors",children:d.jsx(Ki,{className:"w-5 h-5"})})]}),d.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 md:p-12 relative z-10 w-full",children:d.jsxs(ks.div,{initial:{opacity:0,x:-20}
3829,animate:{opacity:1,x:0},transition:{duration:.5},className:"max-w-md w-full bg-slate-900/50 backdrop-blur-xl border border-slate-800/50 rounded-3xl p-8 md:p-10 shadow-2xl flex flex-col",children:[d.jsxs("div",{className:"mb-8",children:[d.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Welcome Back"}),d.jsx("p",{className:"text-slate-400",children:"Please sign in to access your tools and manage your assets."})]}),d.jsx("div",{className:"space-y-4",children:d.jsxs("button",{onClick:s,className:"flex items-center justify-center gap-3 w-full p-4 bg-[#47ff72] text-slate-900 hover:bg-[#3ce665] rounded-2xl font-bold transition-all shadow-[0_0_20px_rgba(71,255,114,0.2)] hover:shadow-[0_0_30px_rgba(71,255,114,0.4)] hover:scale-[1.02] active:scale-[0.98]",children:[d.jsx("img",{src:"https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg",alt:"Google",className:"w-6 h-6",referrerPolicy:"no-referrer"}),d.jsx("span",{className:"text-lg",children:"Sign in with Google"})]})}),d.jsx("div",{className:"mt-10 pt-10 border-t border-slate-800/50",children:d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400",children:[d.jsx(t_,{className:"w-4 h-4 text-[#47ff72]"}),d.jsx("span",{children:"Secure Access"})]}),d.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400",children:[d.jsx(vd,{className:"w-4 h-4 text-[#47ff72]"}),d.jsx("span",{children:"Instant Setup"})]})]})})]})}),d.jsxs("div",{className:"hidden md:flex flex-1 relative bg-gradient-to-br from-[#02350a] to-[#011f08] items-center justify-center p-12 overflow-hidden border-l border-slate-800/50",children:[d.jsx("div",{className:"absolute top-0 right-0 w-[500px] h-[500px] bg-[#47ff72]/5 rounded-full blur-[120px] -translate-y-1/2 translate-x-1/2"}),d.jsx("div",{className:"absolute bottom-0 left-0 w-[400px] h-[400px] bg-[#47ff72]/5 rounded-full blur-[100px] translate-y-1/2 -translate-x-1/2"}),d.jsxs(ks.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.5,delay:.2},className:"relative z-10 max-w-lg",children:[d.jsx("span",{className:"inline-block px-4 py-1.5 bg-[#47ff72]/10 text-[#47ff72] rounded-full text-xs font-bold tracking-wider mb-6 border border-[#47ff72]/20",children:"POWERED BY AI"}),d.jsxs("h2",{className:"text-4xl lg:text-5xl font-bold text-white mb-6 leading-tight",children:["Elevate your ",d.jsx("span",{className:"text-[#47ff72]",children:"Stock Asset"})," management workflow."]}),d.jsx("p",{className:"text-lg text-slate-300 mb-10 leading-relaxed",children:"Automatic keyword generation, smart titles, and batch background processing. Spend less time on metadata and more time on creating."}),d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"flex items-start gap-4",children:[d.jsx(uD,{className:"w-6 h-6 text-[#47ff72] mt-1 shrink-0"}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-white font-semibold",children:"Smart Batching"}),d.jsx("p",{className:"text-sm text-slate-400",children:"Process hundreds of assets simultaneously with high precision."})]})]}),d.jsxs("div",{className:"flex items-start gap-4",children:[d.jsx(uD,{className:"w-6 h-6 text-[#47ff72] mt-1 shrink-0"}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-white font-semibold",children:"SEO Optimized"}),d.jsx("p",{className:"text-sm text-slate-400",children:"Generated text is optimized for maximum visibility on all platforms."})]})]})]}),d.jsx("div",{className:"mt-16 pt-8 border-t border-white/5",children:d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"flex -space-x-3",children:[[1,2,3,4].map(r=>d.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-[#011f08] bg-slate-800 flex items-center justify-center text-[10px] font-bold text-white",children:String.fromCharCode(64+r)},r)),d.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-[#011f08] bg-[#47ff72] flex items-center justify-center text-[10px] font-black text-slate-900",children:"+"})]}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("div",{className:"flex items-center gap-0.5",children:[1,2,3,4,5].map(r=>d.jsx(EM,{className:"w-4 h-4 fill-[#47ff72] text-[#47ff72]"},r))}),d.jsx("span",{className:"text-sm font-medium text-slate-300",children:"Loved by 200+ creators"})]})]})})]})]})]})},$o=[];for(let t=0;t<256;++t)$o.push((t+256).toString(16).slice(1));function vTe(t,e=0){return($o[t[e+0]]+$o[t[e+1]]+$o[t[e+2]]+$o[t[e+3]]+"-"+$o[t[e+4]]+$o[t[e+5]]+"-"+$o[t[e+6]]+$o[t[e+7]]+"-"+$o[t[e+8]]+$o[t[e+9]]+"-"+$o[t[e+10]]+$o[t[e+11]]+$o[t[e+12]]+$o[t[e+13]]+$o[t[e+14]]+$o[t[e+15]]).toLowerCase()}let Q4;const bTe=new Uint8Array(16);function wTe(){if(!Q4){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Q4=crypto.getRandomValues.bind(crypto)}return Q4(bTe)}const _Te=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),dz={randomUUID:_Te};function j2(t,e,n){var r;if(dz.randomUUID&&!t)return dz.randomUUID();t=t||{};const s=t.random??((r=t.rng)==null?void 0:r.call(t))??wTe();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,vTe(s)}var hi=(t=>(t.PENDING="PENDING",t.PROCESSING="PROCESSING",t.COMPLETED="COMPLETED",t.ERROR="ERROR",t))(hi||{}),Ti=(t=>(t.METADATA="METADATA",t.PROMPT="PROMPT",t))(Ti||{}),_h=(t=>(t.CSV="CSV",t.EMBED="EMBED",t))(_h||{}),jr=(t=>(t.ADOBE_STOCK="ADOBE_STOCK",t.SHUTTERSTOCK="SHUTTERSTOCK",t.FREEPIK="FREEPIK",t))(jr||{});const sZ={Animals:1,"Buildings and Architecture":2,Business:3,Drinks:4,"The Environment":5,"States of Mind":6,Food:7,"Graphic Resources":8,"Hobbies and Leisure":9,Industry:10,Landscapes:11,Lifestyle:12,People:13,"Plants and Flowers":14,"Culture and Religion":15,Science:16,"Social Issues":17,Sports:18,Technology:19,Transport:20,Travel:21},_E=Object.keys(sZ),SE=["Abstract","Animals/Wildlife","Arts","Backgroun
3829ds/Textures","Beauty/Fashion","Buildings/Landmarks","Business/Finance","Celebrities","Education","Food and Drink","Healthcare/Medical","Holidays","Industrial","Interiors","Miscellaneous","Nature","Objects","Parks/Outdoor","People","Religion","Science","Signs/Symbols","Sports/Recreation","Technology","Transportation","Vintage"],hz=["Abstract","Beauty/Fashion","Celebrities","Interiors","Miscellaneous","Parks/Outdoor","Vintage"],STe=({onFilesDropped:t,generationMode:e,className:n=""})=>{const s=q.useCallback(c=>{c.preventDefault(),c.stopPropagation(),c.dataTransfer.files&&c.dataTransfer.files.length>0&&t(c.dataTransfer.files)},[t]),r=c=>{c.preventDefault(),c.stopPropagation()},i=c=>{c.target.files&&c.target.files.length>0&&(t(c.target.files),c.target.value="")},a=e===Ti.PROMPT,o=a?".jpg,.jpeg,.png,.mp4,.mov":".jpg,.jpeg,.png,.svg,.ai,.eps,.mp4,.mov",l=a?"JPG, PNG, MP4, MOV":"JPG, PNG, SVG, AI, EPS, MP4, MOV";return d.jsxs("div",{onDrop:s,onDragOver:r,className:`group relative border-2 border-dashed border-slate-300 dark:border-slate-600 rounded-2xl p-12 text-center hover:border-brand-500 dark:hover:border-brand-400 transition-colors bg-white dark:bg-slate-800/50 cursor-pointer flex flex-col items-center justify-center ${n}`,children:[d.jsx("input",{type:"file",multiple:!0,accept:o,onChange:i,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"}),d.jsxs("div",{className:"flex flex-col items-center justify-center gap-4",children:[d.jsx("div",{className:"p-4 bg-brand-50 dark:bg-brand-900/30 rounded-full group-hover:scale-110 transition-transform duration-300",children:d.jsx(TA,{className:"w-10 h-10 text-brand-600 dark:text-brand-400"})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-lg font-semibold text-slate-700 dark:text-slate-200",children:"Drag & Drop files here"}),d.jsx("p",{className:"text-slate-500 dark:text-slate-400 mt-1",children:"or click to browse"})]}),d.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 mt-2",children:[d.jsx(xbe,{className:"w-4 h-4"}),d.jsx("span",{children:l})]}),d.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2 px-4 py-2 bg-slate-50 dark:bg-slate-900/40 rounded-full border border-slate-100 dark:border-slate-700",children:[d.jsx(t_,{className:"w-3.5 h-3.5 text-green-500"}),d.jsx("p",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400",children:"Processed locally & securely. Your files never leave your browser."})]})]})]})},Z4=({text:t,label:e})=>{const[n,s]=q.useState(!1),r=async()=>{if(t)try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),2e3)}catch(i){console.error("Failed to copy:",i)}};return d.jsxs("button",{onClick:r,disabled:!t,className:`flex items-center gap-1.5 text-xs font-medium transition-colors mt-1.5 ${n?"text-green-600 dark:text-green-400":"text-[#47ff72] hover:text-[#32cc59] disabled:opacity-50 disabled:cursor-not-allowed"}`,children:[n?d.jsx(yd,{className:"w-3.5 h-3.5"}):d.jsx(pE,{className:"w-3.5 h-3.5"}),n?"Copied!":e]})},ETe=({keywords:t,onUpdate:e,disabled:n})=>{const[s,r]=q.useState(!1),i=q.useRef(null);q.useEffect(()=>{if(s&&i.current){i.current.focus();const l=i.current.value.length;i.current.setSelectionRange(l,l)}},[s]);const a=t?t.split(",").map(l=>l.trim()).filter(l=>l):[],o=l=>{const c=[...a];c.splice(l,1),e(c.join(", "))};return s?d.jsxs("div",{className:"relative group",children:[d.jsx("textarea",{ref:i,rows:5,value:t,onChange:l=>e(l.target.value),onBlur:()=>r(!1),className:"w-full px-3 py-2 text-sm border border-[#47ff72] rounded-lg bg-white dark:bg-slate-900 dark:text-white resize-none focus:outline-none shadow-sm font-medium h-28",disabled:n}),d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx("button",{onMouseDown:l=>l.preventDefault(),onClick:()=>r(!1),className:"px-2 py-1 bg-slate-100 dark:bg-slate-800 rounded-md text-[10px] font-bold text-slate-500 hover:text-slate-800 dark:hover:text-white border border-slate-200 dark:border-slate-700 uppercase tracking-wide",children:"Done"})})]}):d.jsxs("div",{className:"relative group",children:[d.jsx("div",{className:`w-full h-28 p-2 border border-slate-200 dark:border-slate-700 rounded-lg bg-white dark:bg-slate-900 overflow-y-auto flex flex-wrap gap-1.5 content-start transition-all ${n?"opacity-70 bg-slate-50 dark:bg-slate-900/50":"cursor-text hover:border-slate-300 dark:hover:border-slate-600"}`,onClick:()=>!n&&r(!0),children:a.length>0?a.map((l,c)=>d.jsxs("span",{className:"inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium bg-slate-100 dar
3829k:bg-slate-800 text-slate-700 dark:text-slate-300 border border-slate-200 dark:border-slate-700 shadow-sm transition-all hover:border-[#47ff72]/50 hover:bg-[#47ff72]/5 select-none",onClick:h=>h.stopPropagation(),children:[l,!n&&d.jsx("button",{onClick:h=>{h.stopPropagation(),o(c)},className:"ml-1.5 p-0.5 rounded-full hover:bg-red-500 hover:text-white text-slate-400 transition-colors",title:"Remove keyword",children:d.jsx(Ki,{className:"w-3 h-3"})})]},c)):d.jsx("div",{className:"w-full h-full flex items-center justify-center text-slate-400 text-xs italic pointer-events-none",children:n?d.jsx("span",{children:"Waiting for AI..."}):d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(Tv,{className:"w-4 h-4"})," Click to add keywords"]})})}),!n&&a.length>0&&d.jsx("div",{className:"absolute top-2 right-4 opacity-0 group-hover:opacity-100 transition-opacity",children:d.jsx("button",{onClick:l=>{l.stopPropagation(),r(!0)},className:"p-1.5 bg-slate-100 dark:bg-slate-800 text-slate-500 dark:text-slate-400 rounded-lg hover:text-[#47ff72] transition-colors border border-slate-200 dark:border-slate-700 shadow-sm",title:"Edit text",children:d.jsx(mD,{className:"w-3.5 h-3.5"})})})]})},TTe=({assets:t,onDelete:e,onRegenerate:n,onUpdateMetadata:s,isSelectionMode:r=!1,selectedIds:i=new Set,onToggleSelection:a,generationMode:o=Ti.METADATA,platform:l=jr.ADOBE_STOCK})=>{if(t.length===0)return null;const c=l===jr.SHUTTERSTOCK?SE:_E,h=l===jr.SHUTTERSTOCK?"Description":"Title",p=l===jr.FREEPIK,m=y=>y?y.split(",").filter(v=>v.trim().length>0).length:0;return d.jsx("div",{className:"space-y-6",children:t.map(y=>d.jsx("div",{className:`relative bg-white dark:bg-slate-800 rounded-xl shadow-sm border overflow-hidden transition-all duration-300 ${i.has(y.id)?"border-[#47ff72] ring-1 ring-[#47ff72]":"border-slate-200 dark:border-slate-700"}`,children:d.jsxs("div",{className:"flex flex-col md:flex-row",children:[d.jsxs("div",{className:`w-full md:w-48 h-48 md:h-auto flex-shrink-0 bg-slate-100 dark:bg-slate-900 flex items-center justify-center relative border-b md:border-b-0 md:border-r border-slate-200 dark:border-slate-700 ${r?"cursor-pointer":""}`,onClick:()=>r&&(a==null?void 0:a(y.id)),children:[y.previewUrl?y.type==="video"?d.jsxs("div",{className:"relative w-full h-full",children:[d.jsx("img",{src:y.previewUrl,alt:"Preview",className:"w-full h-full object-cover opacity-80"}),d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:d.jsx("div",{className:"bg-black/50 p-2 rounded-full",children:d.jsx("span",{className:"text-white text-xs font-bold",children:"VIDEO"})})})]}):d.jsx("img",{src:y.previewUrl,alt:"Preview",className:"w-full h-full object-contain p-2"}):d.jsxs("div",{className:"text-center p-4",children:[d.jsx(bbe,{className:"w-12 h-12 text-slate-400 mx-auto mb-2"}),d.jsx("span",{className:"text-xs text-slate-500 break-all",children:y.file.name})]}),r&&d.jsx("div",{className:"absolute top-2 left-2 z-20",children:d.jsx("div",{className:`w-6 h-6 rounded flex items-center justify-center border transition-colors ${i.has(y.id)?"bg-[#47ff72] border-[#47ff72] text-slate-900":"bg-white/50 border-slate-300"}`,children:i.has(y.id)?d.jsx(yd,{className:"w-4 h-4"}):null})}),d.jsxs("div",{className:`absolute top-2 ${r?"left-10":"left-2"}`,children:[y.status===hi.PENDING&&d.jsx("span",{className:"px-2 py-1 bg-slate-200 text-slate-600 text-xs rounded-full font-medium",children:"Pending"}),y.status===hi.PROCESSING&&d.jsxs("span",{className:"px-2 py-1 bg-blue-100 text-blue-600 text-xs rounded-full font-medium flex items-center gap-1",children:[d.jsx(Go,{className:"w-3 h-3 animate-spin"})," Processing"]}),y.status===hi.COMPLETED&&d.jsxs("span",{className:"px-2 py-1 bg-green-100 text-green-600 text-xs rounded-full font-medium flex items-center gap-1",children:[d.jsx(uD,{className:"w-3 h-3"})," Done"]}),y.status===hi.ERROR&&d.jsxs("span",{className:"px-2 py-1 bg-red-100 text-red-600 text-xs rounded-full font-medium flex items-center gap-1",children:[d.jsx(F0,{className:"w-3 h-3"})," Error"]})]})]}),d.jsxs("div",{className:"flex-1 p-6 space-y-4",children:[d.jsxs("div",{className:"flex justify-between items-start",children:[d.jsxs("div",{children:[d.jsx("h4",{className:"font-medium text-slate-900 dark:text-slate-100 text-sm mb-1",children:y.file.name}),d.jsxs("p",{className:"text-xs text-slate-500",children:[(y.file.size/1024/1024).toFixed(2)," MB • ",y.type.toUpperCase()]})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[y.status===hi.COMPLETED&&d.jsx("button",{onClick:()=>n(y.id),className:"p-2 text-slate-400 hover:text-[#47ff72] rounded-lg transition-colors",children:d.jsx(Cv,{className:"w-5 h-5"})}),d.jsx("button",{onClick:()=>e(y.id),className:"p-2 text-slate-400 hover:text-red-500 rounded-lg transition-colors",children:d.jsx(xl,{className:"w-5 h-5"})})]})]}),y.error&&d.jsx("div",{className:"p-3 bg-red-50 border border-red-100 text-red-600 text-sm rounded-lg",children:y.error}),d.jsx("div",{className:"grid grid-cols-1 gap-4",children:o===Ti.METADATA?d.jsxs(d.Fragment,{children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1 uppercase tracking-wider",children:h}),d.jsxs("div",{className:"relative",children:[d.jsx("textarea",{rows:2,value:y.metadata.title,onChange:v=>s(y.id,"title",v.target.value),placeholder:"Waiting for AI...",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 rounded-md dark:bg-slate-900 dark:text-white resize-none",disabled:y.status===hi.PROCESSING}),d.jsxs("span",{className:"absolute bottom-2 right-2 text-[10px] text-slate-400 bg-white/80 dark:bg-slate-900/80 px-1.5 rounded-full pointer-events-none border border-slate-100 dar
3829k:border-slate-800",children:[y.metadata.title.length," chars"]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(Z4,{text:y.metadata.title,label:`Copy ${h}`})})]}),d.jsxs("div",{className:`grid grid-cols-1 ${p?"":"md:grid-cols-2"} gap-4`,children:[!p&&d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1 uppercase tracking-wider",children:"Category"}),d.jsxs("select",{value:y.metadata.category,onChange:v=>s(y.id,"category",v.target.value),className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 rounded-md dark:bg-slate-900 dark:text-white",disabled:y.status===hi.PROCESSING,children:[d.jsx("option",{value:"",children:"Select Category..."}),c.map(v=>d.jsx("option",{value:v,children:v},v))]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1 uppercase tracking-wider",children:"Keywords"}),d.jsx(ETe,{keywords:y.metadata.keywords,onUpdate:v=>s(y.id,"keywords",v),disabled:y.status===hi.PROCESSING}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsxs("span",{className:"text-[10px] text-slate-400 mt-1.5 ml-1 font-medium",children:["Found ",m(y.metadata.keywords)," keywords"]}),d.jsx(Z4,{text:y.metadata.keywords,label:"Copy Keywords"})]})]})]})]}):d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1 uppercase tracking-wider",children:"Image Generation Prompt"}),d.jsx("textarea",{rows:4,value:y.metadata.prompt||"",onChange:v=>s(y.id,"prompt",v.target.value),placeholder:"Analyzing image to generate prompt...",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 rounded-md dark:bg-slate-900 dark:text-white resize-y",disabled:y.status===hi.PROCESSING}),d.jsx("div",{className:"flex justify-end",children:d.jsx(Z4,{text:y.metadata.prompt||"",label:"Copy Prompt"})})]})})]})]})},y.id))})},ATe=({isOpen:t,onClose:e,apiKeys:n,onAdd:s,onDelete:r,onToggle:i,onUpdateLabel:a})=>{const[o,l]=q.useState(()=>{try{const F=localStorage.getItem("last_active_provider_tab");return F==="gemini"||F==="groq"||F==="mistral"?F:"gemini"}catch{return"gemini"}}),[c,h]=q.useState(""),[p,m]=q.useState(""),[y,v]=q.useState(null),[b,S]=q.useState(null),[E,I]=q.useState(null),[M,j]=q.useState("");if(!t)return null;const L=F=>{l(F),localStorage.setItem("last_active_provider_tab",F)},K=()=>{c.trim().length>0&&(s(c.trim(),p.trim(),o),h(""),m(""))},D=F=>{I(F.id),j(F.label||"")},R=F=>{M.trim()&&a(F,M.trim()),I(null),j("")},B=()=>{I(null),j("")},G=F=>F==="gemini"?"Gemini":F==="groq"?"Groq":"Mistral",X=F=>F==="gemini"?"https://aistudio.google.com/app/apikey":F==="groq"?"https://console.groq.com/keys":"https://console.mistral.ai/api-keys",H=n.filter(F=>F.provider===o),Y=H.length>=5;return d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-2xl w-full max-w-lg overflow-hidden flex flex-col max-h-[90vh]",children:[d.jsxs("div",{className:"flex items-start justify-between p-6 pb-2 border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-3 text-brand-600 dark:text-brand-400",children:[d.jsx(SI,{className:"w-6 h-6"}),d.jsx("h2",{className:"text-xl font-bold",children:"Manage API Keys"}),n.length===0&&d.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 text-[10px] font-bold rounded-full border border-red-200 dark:border-red-900/50 animate-pulse ml-1",children:[d.jsx(F0,{className:"w-3 h-3"}),"NO API KEYS CONFIGURED"]})]}),d.jsx("p",{className:"text-slate-500 dark:text-slate-400 mt-2 text-sm",children:"Manage your AI provider keys securely."})]}),d.jsx("button",{onClick:e,className:"text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 p-2 rounded-full hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors -mr-2 -mt-2",title:"Close",children:d.jsx(Ki,{className:"w-5 h-5"})})]}),d.jsxs("div",{className:"flex border-b border-slate-200 dark:border-slate-700 px-6 bg-slate-50 dark:bg-slate-900/50 overflow-x-auto",children:[d.jsxs("button",{onClick:()=>L("gemini"),className:`pb-3 pt-4 px-4 text-sm font-bold flex items-center gap-2 border-b-2 transition-colors whitespace-nowrap ${o==="gemini"?"border-[#47ff72] text-slate-800 dark:text-white":"border-transparent text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:[d.jsx(WL,{className:"w-4 h-4"})," Gemini"]}),d.jsxs("button",{onClick:()=>L("groq"),className:`pb-3 pt-4 px-4 text-sm font-bold flex items-center gap-2 border-b-2 transition-colors whitespace-nowrap ${o==="groq"?"border-[#47ff72] text-slate-800 dark:text-white":"border-transparent text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:[d.jsx(vd,{className:"w-4 h-4"})," Groq"]}),d.jsxs("button",{onClick:()=>L("mistral"),className:`pb-3 pt-4 px-4 text-sm font-bold flex items-center gap-2 border-b-2 transition-colors whitespace-nowrap ${o==="mistral"?"border-[#47ff72] text-slate-800 dark:text-white":"border-transparent text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:[d.jsx(oJ,{className:"w-4 h-4"})," Mistral"]})]}),d.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto",children:[d.jsxs("div",{className:"space-y-3",children:[H.length===0&&d.jsxs("div",{className:"text-center py-8 text-slate-400 text-sm border-2 border-dashed border-slate-200 dark:border-slate-700 rounded-lg",children:["No ",G(o)," keys saved. Add one below."]}),H.map((F,we)=>d.jsxs("div",{className:"relative group bg-slate-50 dark:bg-slate-900/50 border border-slate-200 dark:border-slate-700 rounded-lg p-3 transition-colors hover:border-slate-300 dark:hover:border-slate-600",children:[b===F.id&&d.jsxs("div",{className:"absolute inset-0 bg-red-50 dark:bg-red-900/90 rounded-lg z-10 flex items-center justify-between px-4 animate-in fade-in duration-150",children:[d.jsxs("span",{className:"text-sm font-semibold text-red-600 dark:text-red-200 flex items-center gap-2",children:[d.jsx(F0,{className:"w-4 h-4"}),"Delete this key?"]}
3829),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{onClick:()=>S(null),className:"px-3 py-1 text-xs font-medium bg-white dark:bg-slate-800 text-slate-600 dark:text-slate-300 rounded shadow-sm",children:"Cancel"}),d.jsx("button",{onClick:()=>{r(F.id),S(null)},className:"px-3 py-1 text-xs font-medium bg-red-500 text-white rounded shadow-sm hover:bg-red-600",children:"Delete"})]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("button",{onClick:()=>i(F.id),className:`relative w-10 h-6 rounded-full transition-colors flex-shrink-0 ${F.isActive?"bg-[#47ff72]":"bg-slate-300 dark:bg-slate-600"}`,title:F.isActive?"Active Key":"Set as Active",children:d.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full shadow transition-transform ${F.isActive?"translate-x-4":"translate-x-0"}`})}),d.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden",children:[d.jsx("div",{className:"flex items-center gap-2 mb-0.5 min-h-[24px]",children:E===F.id?d.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[d.jsx("input",{type:"text",value:M,onChange:me=>j(me.target.value),className:"flex-1 min-w-0 px-2 py-0.5 text-sm rounded border border-brand-300 focus:outline-none focus:ring-1 focus:ring-brand-500 bg-white dark:bg-slate-800 text-slate-900 dark:text-white placeholder:text-slate-500 dark:placeholder:text-slate-400",autoFocus:!0,onKeyDown:me=>{me.key==="Enter"&&R(F.id),me.key==="Escape"&&B()}}),d.jsx("button",{onClick:()=>R(F.id),className:"p-1 text-green-600 hover:bg-green-100 dark:hover:bg-green-900/30 rounded",children:d.jsx(yd,{className:"w-3 h-3"})}),d.jsx("button",{onClick:B,className:"p-1 text-red-500 hover:bg-red-100 dark:hover:bg-red-900/30 rounded",children:d.jsx(Ki,{className:"w-3 h-3"})})]}):d.jsxs("div",{className:"flex items-center gap-2 group/label",children:[d.jsx("span",{className:"font-semibold text-sm text-slate-800 dark:text-slate-200 truncate",children:F.label||`${G(o)} Key ${we+1}`}),d.jsx("button",{onClick:()=>D(F),className:"opacity-0 group-hover/label:opacity-100 text-slate-400 hover:text-brand-500 transition-opacity p-0.5",title:"Rename",children:d.jsx(QL,{className:"w-3 h-3"})})]})}),d.jsxs("div",{className:"font-mono text-xs text-slate-500 dark:text-slate-400 flex items-center gap-1",children:[d.jsx(SI,{className:"w-3 h-3"}),y===F.id?d.jsx("span",{className:"break-all",children:F.key}):d.jsx("span",{className:"tracking-widest",children:"•••••••••••••••••••••••••"})]})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:()=>v(y===F.id?null:F.id),className:"p-2 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700",title:y===F.id?"Hide Key":"Show Key",children:y===F.id?d.jsx(dD,{className:"w-4 h-4"}):d.jsx(Yh,{className:"w-4 h-4"})}),d.jsx("button",{onClick:()=>S(F.id),className:"p-2 text-slate-400 hover:text-red-500 rounded-md hover:bg-red-50 dark:hover:bg-red-900/30 transition-colors",title:"Delete",children:d.jsx(xl,{className:"w-4 h-4"})})]})]}),F.isActive&&d.jsxs("div",{className:"absolute -top-2 -right-2 bg-[#47ff72] text-slate-900 text-[10px] font-bold px-2 py-0.5 rounded-full shadow-sm flex items-center gap-1",children:[d.jsx(t_,{className:"w-3 h-3"})," ACTIVE"]})]},F.id))]}),d.jsxs("div",{className:"mt-4 p-4 bg-slate-50 dark:bg-slate-900/30 rounded-xl border border-slate-200 dark:border-slate-700",children:[d.jsxs("h3",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300 mb-3 flex items-center gap-2",children:[d.jsx(Tv,{className:"w-4 h-4"})," Add New ",G(o)," Key"]}
3829),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:d.jsx(e7,{className:"w-4 h-4 text-slate-400"})}),d.jsx("input",{type:"text",value:p,onChange:F=>m(F.target.value),placeholder:"Label (Optional, e.g. 'Production')",disabled:Y,className:"w-full pl-10 pr-4 py-2 rounded-lg border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 focus:ring-2 focus:ring-brand-500 outline-none text-slate-900 dark:text-white placeholder:text-slate-500 dark:placeholder:text-slate-400 text-sm disabled:opacity-50 disabled:cursor-not-allowed"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("div",{className:"relative flex-1",children:[d.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:d.jsx(SI,{className:"w-4 h-4 text-slate-400"})}),d.jsx("input",{type:"text",value:c,onChange:F=>h(F.target.value),placeholder:Y?"Maximum 5 keys reached":`Enter ${G(o)} API Key`,disabled:Y,className:"w-full pl-10 pr-4 py-2 rounded-lg border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 focus:ring-2 focus:ring-brand-500 outline-none text-slate-900 dark:text-white placeholder:text-slate-500 dark:placeholder:text-slate-400 text-sm disabled:opacity-50 disabled:cursor-not-allowed"})]}),d.jsx("button",{onClick:K,disabled:Y||!c,className:"px-4 py-2 bg-brand-500 hover:bg-brand-600 disabled:bg-slate-300 dark:disabled:bg-slate-700 disabled:cursor-not-allowed text-slate-900 rounded-lg font-medium transition-colors flex items-center gap-2 text-sm whitespace-nowrap",children:"Add Key"})]})]}),d.jsx("div",{className:"mt-3 flex justify-start",children:d.jsxs("a",{href:X(o),target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-brand-600 hover:text-brand-500 dark:text-brand-400 dark:hover:text-brand-300 hover:underline flex items-center gap-1 transition-colors",children:["Get ",G(o)," API Key from here",d.jsx(dbe,{className:"w-3 h-3"})]})}),Y&&d.jsxs("p",{className:"text-xs text-amber-500 mt-2",children:["Limit reached for ",G(o),"."]})]})]}),d.jsx("div",{className:"p-6 border-t border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 flex justify-end",children:d.jsx("button",{onClick:e,className:"px-6 py-2 bg-slate-200 hover:bg-slate-300 dark:bg-slate-700 dark:hover:bg-slate-600 text-slate-700 dark:text-slate-200 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Done"})})]})})},CTe=({className:t})=>d.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),kTe=({className:t})=>d.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.008-.57-.008-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})}),Bk="https://csvmeta.azrafbarno.com",fz="Generate Adobe Stock metadata (titles & keywords) instantly with AI!",ITe=({isOpen:t,onClose:e,onExport:n,onRegenerateFailed:s,count:r,errorCount:i,mode:a,outputFormat:o})=>{const[l,c]=q.useState(!1);if(!t)return null;const h=()=>{navigator.clipboard.writeText(Bk).then(()=>{c(!0),setTimeout(()=>c(!1),2e3)})},p=a===Ti.METADATA,m=i>0,y=()=>{m?(s(),e()):n()};return d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl w-full max-w-md p-6 transform transition-all scale-100 max-h-[90vh] overflow-y-auto",children:[d.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[d.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center mb-2 ${m?"bg-amber-50 dark:bg-amber-900/30":"bg-brand-50 dark:bg-brand-900/30"}`,children:m?d.jsx(F0,{className:"w-8 h-8 text-amber-500"}):d.jsx(HN,{className:"w-8 h-8 text-[#47ff72]"})}),d.jsx("h2",{className:"text-2xl font-bold text-slate-800 dark:text-white",children:m?"Processing Finished":"Processing Complete!"}
3829),d.jsx("div",{className:"text-slate-600 dark:text-slate-300",children:m?d.jsxs("p",{children:["Processed ",d.jsx("span",{className:"font-bold text-slate-900 dark:text-white",children:r})," files successfully.",d.jsx("br",{}),d.jsxs("span",{className:"text-red-500 font-medium",children:["However, ",i," files failed."]})]}):d.jsxs("p",{children:[p?o===_h.EMBED?"Embedded Metadata":"CSV Metadata":"Prompts"," Generated Successfully for ",d.jsx("span",{className:"font-bold text-slate-900 dark:text-white",children:r})," files."]})}),d.jsxs("div",{className:"flex gap-3 w-full mt-6",children:[d.jsx("button",{onClick:e,className:"flex-1 px-4 py-3 text-slate-600 dark:text-slate-300 font-medium hover:bg-slate-100 dark:hover:bg-slate-700 rounded-xl transition-colors",children:"Cancel"}),d.jsx("button",{onClick:y,className:"flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 font-bold rounded-xl shadow-lg shadow-green-500/20 transition-transform active:scale-95",children:m?d.jsxs(d.Fragment,{children:[d.jsx(Cv,{className:"w-5 h-5"}),"Regenerate Failed"]}):d.jsxs(d.Fragment,{children:[p?d.jsx(Ua,{className:"w-5 h-5"}):d.jsx(mE,{className:"w-5 h-5"}),p?o===_h.EMBED?"Export Embedded files":"Export CSV":"Export Prompts"]})})]}),d.jsxs("a",{href:"https://t.me/csvmeta",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full mt-3 px-4 py-3 bg-transparent border border-[#47ff72] text-[#47ff72] hover:bg-[#229ED9] hover:text-white hover:border-[#229ED9] font-bold rounded-xl shadow-lg shadow-green-500/20 hover:shadow-blue-500/20 transition-transform active:scale-95",children:[d.jsx(Ed,{className:"w-5 h-5"}),"Join our Telegram Community"]}),d.jsxs("div",{className:"mt-8 pt-6 border-t border-slate-100 dark:border-slate-700 w-full",children:[d.jsx("p",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-4",children:"Share this tool"}),d.jsxs("div",{className:"flex items-center justify-center gap-4",children:[d.jsxs("button",{onClick:h,className:"group relative w-12 h-12 flex items-center justify-center rounded-full bg-slate-100 dark:bg-slate-700 hover:bg-slate-200 dark:hover:bg-slate-600 transition-all text-slate-600 dark:text-slate-200",title:"Copy Link",children:[l?d.jsx(yd,{className:"w-5 h-5 text-green-500"}):d.jsx(XL,{className:"w-5 h-5"}),l&&d.jsx("span",{className:"absolute -top-8 bg-slate-800 text-white text-xs px-2 py-1 rounded shadow-lg animate-in fade-in slide-in-from-bottom-2",children:"Copied!"})]}),d.jsx("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Bk)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-[#1877F2] hover:bg-[#166fe5] text-white transition-transform hover:scale-110 shadow-lg shadow-blue-500/20",title:"Share on Facebook",children:d.jsx(KL,{className:"w-5 h-5 fill-current"})}),d.jsx("a",{href:`https://twitter.com/intent/tweet?url=${encodeURIComponent(Bk)}&text=${encodeURIComponent(fz)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-black dark:bg-white hover:bg-slate-900 dark:hover:bg-slate-100 text-white dark:text-black transition-transform hover:scale-110 shadow-lg shadow-slate-500/20",title:"Share on X",children:d.jsx(CTe,{className:"w-5 h-5"})}),d.jsx("a",{href:`https://wa.me/?text=${encodeURIComponent(fz+" "+Bk)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-[#25D366] hover:bg-[#20bd5a] text-white transition-transform hover:scale-110 shadow-lg shadow-green-500/20",title:"Share on WhatsApp",children:d.jsx(kTe,{className:"w-5 h-5"})})]})]})]}),d.jsx("button",{onClick:e,className:"absolute top-4 right-4 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",children:d.jsx(Ki,{className:"w-5 h-5"})})]})})},mn="w-5 h-5 text-brand-500",NTe=[d.jsx(gE,{className:mn}),d.jsx(SI,{className:mn}),d.jsx(aJ,{className:mn}),d.jsx(Sd,{className:mn}),d.jsx(WL,{className:mn}),d.jsx(Z0,{className:mn}),d.jsx(Sd,{className:mn}
3829),d.jsx(mE,{className:mn}),d.jsx(sJ,{className:mn}),d.jsx(TA,{className:mn}),d.jsx(F1,{className:mn}),d.jsx(xd,{className:mn}),d.jsx(Cv,{className:mn}),d.jsx(QL,{className:mn}),d.jsx(Ua,{className:mn}),d.jsx(Ed,{className:mn})],RTe=[d.jsx(Z0,{className:mn}),d.jsx(Sd,{className:mn}),d.jsx(_M,{className:mn}),d.jsx(Yve,{className:mn}),d.jsx(eJ,{className:mn}),d.jsx(mp,{className:mn}),d.jsx(bM,{className:mn}),d.jsx(Yh,{className:mn}),d.jsx(Ua,{className:mn}),d.jsx(Ed,{className:mn})],MTe=[d.jsx(Ua,{className:mn}),d.jsx(AA,{className:mn}),d.jsx(SM,{className:mn}),d.jsx(TA,{className:mn}),d.jsx(F1,{className:mn}),d.jsx(EA,{className:mn}),d.jsx(Cv,{className:mn}),d.jsx(Yh,{className:mn}),d.jsx(Ua,{className:mn}),d.jsx(t_,{className:mn}),d.jsx(Ed,{className:mn})],PTe=[d.jsx(wM,{className:mn}),d.jsx(Z0,{className:mn}),d.jsx(Tv,{className:mn}),d.jsx(eJ,{className:mn}),d.jsx(_M,{className:mn}),d.jsx(xd,{className:mn}),d.jsx(bM,{className:mn}),d.jsx(TM,{className:mn}),d.jsx(Sd,{className:mn}),d.jsx(Ua,{className:mn}),d.jsx(Ed,{className:mn})],$Te=[d.jsx(AA,{className:mn}),d.jsx(rJ,{className:mn}),d.jsx(tJ,{className:mn}),d.jsx(Tv,{className:mn}),d.jsx(QL,{className:mn}),d.jsx(_M,{className:mn}),d.jsx(TM,{className:mn}),d.jsx(QX,{className:mn}),d.jsx(Sd,{className:mn}),d.jsx(TA,{className:mn}),d.jsx(Ed,{className:mn})],DTe=[d.jsx(TA,{className:mn}),d.jsx(mp,{className:mn}),d.jsx(SM,{className:mn}),d.jsx(_M,{className:mn}),d.jsx(pE,{className:mn}),d.jsx(U1,{className:mn}),d.jsx(Z0,{className:mn}),d.jsx(Cv,{className:mn}),d.jsx(Ua,{className:mn}),d.jsx(Ed,{className:mn})],pz={metadata:NTe,background:RTe,upscale:MTe,bento:PTe,vector:$Te,color:DTe},mz={metadata:{en:{title:"Metadata Generator User Guide",steps:[{title:"1. Sign in with Google",description:"To access all features and generation tools, first sign in with your Google account using the button on the home page. This ensures your session is secure."},{title:"2. Set API Key",description:"Click the Settings icon (gear) in the top right. Enter your Google Gemini, Groq or Mistral AI API Key. This is required for the AI to analyze your files. You can add up to five different API keys at your convenience for each provider."},{title:"3. Generation Mode",description:"Choose 'Stock Metadata' to generate titles/keywords for sales, or 'Image-to-Prompt' to reverse-engineer prompts for AI image generation (Midjourney/DALL-E)."},{title:"4. Platform Selection",description:"Under Settings, select 'Adobe Stock', 'Shutterstock' or 'Freepik'. The tool adapts title/description labels, character limits, and category lists to match the specific platform's requirements."},{title:"5. Select AI Model",description:"Choose between Gemini, Groq and Mistral API providers. For Gemini, use 'Gemini 2.5 Flash Lite' for maximum speed on large batches. Select 'Gemini 2.5 Flash' for higher quality descriptions, better reasoning on complex scenes, and richer vocabulary. For Groq, use 'Llama 4 Scout' for faster generations and 'Llama 4 Maverick' for best quality. For Mistral AI, Use 'Mistral Medium 3.1' for stable outputs and 'Mistral Large 3' for high quality output."},{title:"6. Configure Output",description:"Use the sliders to set your desired Title Length and Keywords Count. The AI will generate metadata that closely matches these limits."},{title:"7. Seamless Generation",description:"Enable the 'Seamless Generation' toggle to automatically fetch categories for both Adobe Stock and Shutterstock in a single pass. This allows you to switch between platforms and export perfectly formatted CSVs without needing to regenerate metadata."},{title:"8. Embed Metadata & Rename",description:"Select 'Embed Metadata' as the Output Format to embed generated titles and keywords directly into your files (supports JPG and PNG). Enable 'Rename Files' to automatically rename your files based on the generated title or description."},{title:"9. Refiner Prompt & AI Enhance",description:"Toggle 'Refiner Prompt' to guide the AI with custom rules (e.g., 'No brand names', 'Use British English'). Use the Sparkles icon to automatically expand your simple instruction into a professional system prompt using AI."},{title:"10. Upload Assets",description:"Drag & drop your files into the main area. Supports JPG, PNG, SVG, AI, EPS, MP4, and MOV formats."},{title:"11. Process Files",description:"Click the 'Process Files' button to start. The AI will analyze each file one by one. You can pause/stop at any time."},{title:"12. Selection Mode",description:"Use the 'Select Items' button to enable selection checkboxes. This allows you to pick specific assets for batch operations like group deletion or regeneration."},{title:"13. Smart Regeneration",description:"You can regenerate individual files, all failed one
3829s, or a custom selection. The 'Regenerate Selected' button activates once at least one selected item has completed metadata."},{title:"14. Review & Edit",description:"Review the generated titles, keywords, and categories. You can manually edit any field or copy them to your clipboard."},{title:"15. Export Result",description:"Click 'Export' to download. For Metadata mode, you get a CSV formatted for the selected platform. For Prompt mode, you get a text file with prompts."},{title:"16. Community Support",description:"Join our Telegram channel @csvmeta for direct support, feature requests, and community discussion."}],proTipTitle:"Pro Tip: PNG Handling",proTipDesc:'For .png files, the tool automatically adds "isolated on transparent background" to the title and keywords to meet Stock requirements.',button:"Got it, thanks!",videoUrl:"https://www.youtube.com/embed/MyaCgg80Vwk"},bn:{title:"মেটাডেটা জেনারেটর ব্যবহার নির্দেশিকা",steps:[{title:"১. Google দিয়ে সাইন-ইন করুন",description:"সব ফিচার এবং জেনারেশন টুল ব্যবহার করার জন্য প্রথমে হোম পেজে থাকা বাটনের মাধ্যমে আপনার Google অ্যাকাউন্ট দিয়ে সাইন-ইন করুন। এটি আপনার সেশন নিরাপদ রাখে।"},{title:"২. API কী সেট করুন",description:"উপরে ডানদিকে সেটিংস আইকনে (গিয়ার) ক্লিক করুন। আপনার Google Gemini, Groq অথবা Mistral AI API কী দিন। আপনার ফাইলগুলি বিশ্লেষণ করার জন্য AI-এর এই কী দরকার।"},{title:"৩. জেনারেশন মোড",description:"স্টক সাইটের জন্য টাইটেল/কীওয়ার্ড তৈরি করতে 'Stock Metadata' অথবা AI ইমেজ জেনারেশনের জন্য প্রম্পট পেতে 'Image-to-Prompt' নির্বাচন করুন।"},{title:"৪. প্ল্যাটফর্ম নির্বাচন",description:"সেটিংসের অধীনে 'Adobe Stock', 'Shutterstock' বা 'Freepik' বেছে নিন। টুলটি স্বয়ংক্রিয়ভাবে নির্দিষ্ট প্ল্যাটফর্মের নিয়ম অনুযায়ী ক্যাটাগরি, লিমিট এবং ফিল্ডের নাম ঠিক করে নেয়।"},{title:"৫. AI মডেল নির্বাচন করুন",description:"Gemini, Groq অথবা Mistral AI প্রোভাইডার বেছে নিন। Gemini এর ক্ষেত্রে বড় ব্যাচ বা দ্রুত প্রসেসিংয়ের জন্য 'Gemini 2.5 Flash Lite' সেরা। তবে জটিল ছবির বিস্তারিত বর্ণনা এবং উন্নত কীওয়ার্ডের জন্য 'Gemini 2.5 Flash' নির্বাচন করুন। Groq এর ক্ষেত্রে দ্রুত জেনেরেশনের জন্য 'Llama 4 Scout' এবং সর্বোচ্চ মানের জন্য 'Llama 4 Maverick' ব্যবহার করুন। Mistral AI এর ক্ষেত্রে স্থিতিশীল আউটপুটের জন্য 'Mistral Medium 3.1' ব্যবহার করুন এবং উচ্চমানের আউটপুট পেতে 'Mistral Large 3' ব্যবহার করুন।"},{title:"৬. আউটপুট কনফিগার করুন",description:"আপনার কাঙ্ক্ষিত শিরোনামের দৈর্ঘ্য এবং কীওয়ার্ড সংখ্যা সেট করতে স্লাইডারগুলি ব্যবহার করুন। AI এই সীমার সাথে মিল রেখে মেটাডেটা তৈরি করবে।"},{title:"৭. সিমলেস জেনারেশন (Seamless Generation)",description:"'Seamless Generation' চালু করলে টুলটি একই সাথে Adobe Stock এবং Shutterstock-এর জন্য ক্যাটাগরি তৈরি করে রাখবে। এর ফলে আপনি পুনরায় জেনারেট না করেই প্ল্যাটফর্ম পরিবর্তন করে সঠিক ফরম্যাটে CSV এক্সপোর্ট করতে পারবেন।"},{title:"৮. এম্বেড মেটাডেটা এবং রিনেম",description:"আউটপুট ফরম্যাট হিসেবে 'Embed Metadata' নির্বাচন করুন যাতে তৈরি করা টাইটেল এবং কীওয়ার্ড সরাসরি আপনার ফাইলে (JPG এবং PNG সাপোর্ট করে) এম্বেড করা যায়। 'Rename Files' চালু করলে আপনার ফাইলগুলো স্বয়ংক্রিয়ভাবে তৈরি করা টাইটেল বা ডেসক্রিপশনের ওপর ভিত্তি করে রিনেম হয়ে যাবে।"},{title:"৯. রিফাইনার প্রম্পট এবং AI এনহ্যান্স",description:"'Refiner Prompt' চালু করে AI-কে আপনার নিজস্ব নিয়ম (যেমন: 'কোনো ব্র্যান্ডের নাম নয়', 'ব্রিটিশ ইংরেজি ব্যবহার করুন') মেনে চলতে বলুন। Sparkles আই
3829কনে ক্লিক করলে AI স্বয়ংক্রিয়ভাবে আপনার সাধারণ নির্দেশটিকে একটি প্রফেশনাল প্রম্পটে রূপান্তর করে দেবে।"},{title:"১০. অ্যাসেট আপলোড করুন",description:"আপনার ফাইলগুলি মেইন এরিয়াতে ড্র্যাগ এবং ড্রপ করুন। এটি JPG, PNG, SVG, AI, EPS, MP4 এবং MOV ফরম্যাট সাপোর্ট করে।"},{title:"à§§à§§. ফাইল প্রসেস করুন",description:"শুরু করতে 'Process Files' বাটনে ক্লিক করুন। AI প্রতিটি ফাইল একে একে বিশ্লেষণ করবে। আপনি যে কোনো সময় এটি থামাতে পারেন।"},{title:"১২. সিলেকশন মোড",description:"আপনার অ্যাসেটগুলোতে চেকবক্স এক্টিভ করে সিলেক্ট করতে 'Select Items'-এ ক্লিক করুন। এটি নির্দিষ্ট ফাইলগুলো একসাথে ডিলিট বা পুনরায় জেনারেট করতে সাহায্য করে।"},{title:"à§§à§©. স্মার্ট রিজেনারেশন",description:"আপনি আলাদাভাবে কোনো ফাইল, সমস্ত ফেইল হওয়া ফাইল অথবা আপনার পছন্দমতà
3829§‹ সিলেক্ট করা ফাইলগুলো পুনরায় জেনারেট করতে পারেন।"},{title:"১৪. রিভিউ এবং এডিট করুন",description:"তৈরি করা টাইটেল, কীওয়ার্ড এবং ক্যাটাগরিগুলো রিভিউ করুন। আপনি যে কোনো ফিল্ড ম্যানুয়ালি এডিট করতে পারেন বা ক্লিপবোর্ডে কপি করতে পারেন।"},{title:"à§§à§«. রেজাল্ট এক্সপোর্ট করুন",description:"'Export'-এ ক্লিক করুন। মেটাডেটা মোডে আপনি নির্বাচিত প্ল্যাটফর্মের জন্য ফরম্যাট করা CSV পাবেন। প্রম্পট মোডে টেক্সট ফাইল পাবেন।"},{title:"১৬. কমিউনিটি সাপোর্ট",description:"সরাসরি সাপোর্ট এবং আপডেটের জন্য আমাদের টেলিগ্রাম চ্যানেল @csvmeta-এ জয়েন করুন।"}],proTipTitle:"প্রো টিপ: PNG হ্যান্ডলিং",proTipDesc:'.png ফাইলগুলির জন্য, Adobe Stock-এর প্রয়োজনীয়তা অনুযায়ী টুলটি স্বয়ংক্রিয়ভাবে শিরোনাম এবং কীওয়ার্ডগুলিতে "isolated on transparent background" যুক্ত করে।',button:"বুঝেছি, ধন্যবাদ!",videoUrl:"https://www.youtube.com/embed/MyaCgg80Vwk"}},background:{en:{title:"Background Generator User Guide",steps:[{title:"1. Choose a Background Type",description:"Under Base Settings, open the Type dropdown and pick one of four modes: Solid (flat color), Gradient (smooth color blend), Stripe (repeating bands), or Seamless (repeating vector pattern)."},{title:"2. Pick Linear or Radial Style",description:"Gradient and Stripe types show a Style toggle with Linear and Radial options. Linear flows in a direction you control; Radial spreads outward from the center. Solid and Seamless do not use this setting."},{title:"3. Solid Backgrounds",description:"Choose a single Background Color. In Adjustments, use the Noise / Grain slider to add subtle texture. Solid mode only supports color and noise — no angle or blur controls."}
3829,{title:"4. Gradient Backgrounds",description:"Build your gradient on the interactive color bar. Add up to four color stops by clicking the bar or using '+ Add Stop'. Drag stop handles to reposition them, and drag midpoints between stops to fine-tune color blending. Set Angle (Linear style only), Blur, and Noise under Adjustments."},{title:"5. Stripe Backgrounds",description:"Pick Start Color and End Color, then adjust Frequency (how many stripes), Width (how thick each stripe is, in %), Angle (Linear style only — hidden for Radial), plus Blur and Noise for a softer, textured look."},{title:"6. Seamless Pattern Backgrounds",description:"Set a solid base color, optionally upload a Custom Background SVG to fill the canvas, then upload an SVG Vector that tiles across the surface in an offset brick layout."},{title:"7. Seamless Vector Controls",description:"After uploading your pattern vector, tune Vector Size, Frequency (columns per row), Vector Rotation, and Variation (Seed). The seed adds natural randomness to each tile's size and rotation so the pattern feels organic."},{title:"8. Live Preview",description:"The canvas on the right updates in real time as you change settings. Hover over it to see the current dimensions. In Seamless mode, upload a vector first — the preview appears once your SVG is loaded."},{title:"9. Export Your Background",description:"Click Export, set your desired Width and Height, then download. Solid, Gradient, and Stripe backgrounds export as JPG only. Seamless mode offers both JPG and true vector SVG export."},{title:"10. Community Support",description:"Join our Telegram channel @csvmeta for direct support, feature requests, and community discussion."}],proTipTitle:"Pro Tip: Seamless SVG Export",proTipDesc:"In Seamless mode, export as SVG to get a true vector file — your pattern stays perfectly sharp at any size, ideal for stock backgrounds and scalable design assets.",button:"Got it, thanks!"},bn:{title:"ব্যাকগ্রাউন্ড জেনারেটর ব্যবহার নির্দেশিকা",steps:[{title:"১. ব্যাকগ্রাউন্ডের ধরন বেছে নিন",description:"Base Settings-এ Type ড্রপডাউন খুলে চারটি মোড থেকে একটি বেছে নিন: Solid (এক রঙ), Gradient (মসৃণ রঙের মিশ্রণ), Stripe (পুনরাবৃত্ত ডোরাকাটা বা স্ট্রাইপ), অথবা Seamless (পুনরাবৃত্ত ভেক্টর প্যাটার্ন)।"},{title:"২. Linear বা Radial স্টাইল নির্বাচন",description:"Gradient এবং Stripe টাইপে Linear ও Radial স্টাইল টগল দেখা যাবে। Linear আপনার নির্ধারিত দিকে রঙ ছড়ায়; Radial কেন্দ্র থেকে বাইরের দিকে ছড়িয়ে পড়ে। Solid ও Seamless-এ এই সেটিং থাকে না।"},{title:"৩. Solid ব্যাকগ্রাউন্ড",description:"একটি Background Color বেছে নিন। Adjustments-এ Noise / Grain স্লাইডার দিয়ে হালকা টেক্সচার যোগ করুন। Solid মোডে শুধু রঙ ও নয়েজ সামলানো যায় — Angle বা Blur নেই।"},{title:"৪. Gradient ব্যাকগ্রাউন্ড",description:"ইন্টারঅ্যাক্টিভ কালার বারে গ্রেডিয়েন্ট তৈরি করুন। বারে ক্লিক করে বা '+ Add Stop' দিয়ে সর্বোচ্চ চারটি কালার স্টপ যোগ করুন। স্টপ হ্যান্ডেল টেনে অবস্থান ঠিক করুন, আর স্টপের মাঝখানের midpoint টেনে রঙের মিশ্রণ নিয়ন্ত্রণ করুন। Adjustments-এ Angle (শুধু Linear), Blur ও Noise সেট করুন।"},{title:"৫. Stripe ব্যাকগ্রাউন্ড",de
3829scription:"Start Color ও End Color বেছে নিন, তারপর Frequency(কতগুলো বা স্ট্রাইপ), Width (প্রতিটি ডোরার পুরুত্ব, %), Angle (শুধু Linear — Radial-এ থাকে না), এবং Blur ও Noise দিয়ে নরম টেক্সচারযুক্ত লুক তৈরি করুন।"},{title:"৬. Seamless প্যাটার্ন ব্যাকগ্রাউন্ড",description:"একটি বেস রঙ সেট করুন, চাইলে নিজের Custom Background SVG আপলোড করে ক্যানভাস ভরুন, তারপর একটি SVG Vector আপলোড করুন যা অফসেট ব্রিক লেআউটে পুরো সারফেসে টাইলের মতো সাজানো থাকবে।"},{title:"৭. Seamless ভেক্টর নিয়ন্ত্রণ",description:"প্যাটার্ন ভেক্টর আপলোডের পর Vector Size, Frequency (প্রতি সারিতে কলাম), Vector Rotation, এবং Variation (Seed) ঠিক করুন। Seed প্রতিটি টাইলের সাইজ ও ঘূর্ণনে স্বাভাবিক এলোমেলো ভিন্নতা যোগ করে।"},{title:"৮. লাইভ প্রিভিউ",description:"ডান পাশের ক্যানভাসে সেটিংস বদলালেই রিয়েল টাইমে আপডেট দেখা যায়। হোভার করলে বর্তমান মাপ দেখা যাবে। Seamless মোডে আগে ভেক্টর আপলোড করুন — SVG লোড হলেই প্রিভিউ দেখা যাবে।"},{title:"৯. ব্যাকগ্রাউন্ড এক্সপোর্ট",description:"Export-এ ক্লিক করে Width ও Height সেট করুন, তারপর ডাউনলোড করুন। Solid, Gradient ও Stripe শুধু JPG-তে এক্সপোর্ট হয়। Seamless মোডে JPG এবং সত্যিকারের ভেক্টর SVG — দুটোই পাওয়া যায়।"},{title:"১০. কমিউনিটি সাপোর্ট",description:"সরাসরি সাপোর্ট এবং আপডেটের জন্য আমাদের টেলিগ্রাম চ্যানেল @csvmeta-এ জয়েন করুন।"}],proTipTitle:"প্রো টিপ: Seamless SVG এক্সপোর্ট",proTipDesc:"Seamless মোডে SVG হিসেবে এক্সপোর্ট করলে সত্যিকারের ভেক্টর ফাইল পাবেন — প্যাটার্ন যেকোনো সাইজে শার্প থাকবে, স্টক ব্যাকগ্রাউন্ড ও ডিজাইনের জন্য আদর্শ।",button:"বুঝেছি, ধন্যবাদ!"}},upscale:{en:{title:"Image Upscaler User Guide",steps:[{title:"1. Prepare the AI Model",description:"On your first visit, click 'Prepare AI Model (~16MB)' to download the Real-ESRGAN engine. It is saved in your browser, so you only need to do this once. When the green 'AI Ready' badge appears, you are set to go."},{title:"2. Choose Your Scale Factor",description:"Select 2x, 3x, or 4x from the pill buttons at the top. This controls how much larger your output will be compared to the original. Your choice is remembered automatically for future sessions."},{title:"3. Adjust JPG Quality",description:"Use the Quality slider (10–100%) to control JPEG compression when saving JPG files. PNG outputs are always lossless. The default is 85% — a good balance of file size and sharpness for stock uploads."},{title:"4. Upload Your Images",description:"Drag and drop JPG or PNG files into the upload area, or click to browse. You can add multiple images at once. Only JPEG/JPG and PNG formats are supported."},{title:"5. Start Batch Upscaling",description:"Click 'Upscale All' to process every pending image in the queue one by one. While running, the button switches to 'Pause Upscale' — click it anytime to stop after the current image finishes."},{title:"6. Monitor the Queue",description:"Each thumbnail shows its status: pending (clock), processing (spinner with % progress), done (green check), or error (red X). A completion popup appears when the batch finishes."},{title:"7. Upscale or Remove Individual Images",description:"Hover over a thumbnail to reveal controls: the play button upscales a single pending or failed image, and the trash icon removes it from the queue. Use 'Clear' to remove all items at once."},{title:"8. Compare Before & After",description:"On completed images, click 'Preview' to open the comparison view. Drag the slider left or right to see the original beside the upscaled result side by side."},{title:"9. Download Your Results",description:"Download a single upscaled image with the download icon on its thumbnail, or click 'Download All' to save everything. Multiple files are bundled into a ZIP archive automatically."},{title:"10. 100% Local & Private",description:"All upscaling runs entirely in your browser using AI on your device. Your images are never uploaded to any server — ideal for confidential client work and private assets."}
3829,{title:"11. Community Support",description:"Join our Telegram channel @csvmeta for direct support, feature requests, and community discussion."}],proTipTitle:"Pro Tip: PNG Transparency",proTipDesc:"PNG files keep their transparent background after upscaling — the AI enhances color detail while the alpha channel is preserved separately, perfect for isolated stock graphics.",button:"Got it, thanks!"},bn:{title:"ইমেজ আপস্কেলার ব্যবহার নির্দেশিকা",steps:[{title:"১. AI মডেল প্রস্তুত করুন",description:"প্রথমবার 'Prepare AI Model (~16MB)'-এ ক্লিক করে Real-ESRGAN ইঞ্জিন ডাউনলোড করুন। এটি ব্রাউজারে সংরক্ষিত থাকে, তাই একবারই করতে হয়। সবুজ 'AI Ready' ব্যাজ দেখা গেলে আপস্কেলিং শুরু করতে পারবেন।"},{title:"২. স্কেল ফ্যাক্টর বেছে নিন",description:"উপরের পিল বাটন থেকে 2x, 3x, অথবা 4x নির্বাচন করুন। এটি নির্ধারণ করে আউটপুট ইমেজ অরিজিনাল ছবির চেয়ে কতটা বড় হবে। আপনার পছন্দ স্বয়ংক্রিয়ভাবে মনে রাখা হয়।"},{title:"৩. JPG কোয়ালিটি ঠিক করুন",description:"Quality স্লাইডার (১০–১০০%) দিয়ে JPG ফাইলের কম্প্রেশন নিয়ন্ত্রণ করুন। PNG সবসময় lossless থাকে। ডিফল্ট ৮৫% — স্টক আপলোডের জন্য সাইজ ও sharpness-এর ভালো ব্যালান্স।"},{title:"৪. ইমেজ আপলোড করুন",description:"JPG বা PNG ফাইল ড্র্যাগ ও ড্রপ করুন, অথবা ক্লিক করে ব্রাউজ করুন। একসাথে একাধিক ইমেজ যোগ করা যায়। শুধু JPEG/JPG ও PNG ফরম্যাট সাপোর্ট করে।"},{title:"৫. ব্যাচ আপস্কেলিং শুরু করুন",description:"'Upscale All'-এ ক্লিক করলে কিউ-তে থাকা সব pending ইমেজ একে একে প্রসেস হবে। চলাকালীন বাটন 'Pause Upscale'-এ বদলে যায় — বর্তমান ইমেজ শেষ হলে যেকোনো সময় থামাতে পারবেন।"},{title:"৬. কিউ মনিটর করুন",description:"প্রতিটি থাম্বনেই স্ট্যাটাস দেখা যায়: pending (ঘড়ি আইকন), processing (স্পিনার ও % প্রগ্রেস), done (সবুজ টিক), অথবা error (লাল X)। ব্যাচ শেষ হলে completion পপআপ আসে।"},{title:"৭. আলাদা ইমেজ আপস্কেল বা সরান",description:"থাম্বনেইলে হোভার করলে কন্ট্রোল দেখা যায়: play বাটন দিয়ে একটি pending বা failed ইমেজ আপস্কেল করুন, trash আইকন দিয়ে কিউ থেকে সরান। 'Clear' বাটন দিয়ে সব একসাথে মুছুন।"},{title:"৮. আগে ও পরে তুলনা করুন",description:"সম্পন্ন ইমেজে 'Preview' ক্লিক করে comparison ভিউ খুলুন। স্লাইডার বাম-ডানে টেনে অরিজিনাল ও আপস্কেল করা ফলাফল পাশাপাশি দেখুন।"},{title:"৯. ফলাফল ডাউনলোড করুন",description:"থাম্বনেইলের download আই
3829কন দিয়ে একটি ইমেজ ডাউনলোড করুন, অথবা 'Download All' দিয়ে সব একসাথে নিন। একাধিক ফাইল স্বয়ংক্রিয়ভাবে ZIP-এ বান্ডেল হয়।"},{title:"১০. সম্পূর্ণ লোকাল ও প্রাইভেট",description:"সমস্ত আপস্কেলিং আপনার ব্রাউজারে, আপনার ডিভাইসে AI দিয়ে চলে। ইমেজ কোনো সার্ভারে আপলোড হয় না — গোপনীয় ক্লায়েন্ট কাজ ও ব্যক্তিগত অ্যাসেটের জন্য আদর্শ।"},{title:"১১. কমিউনিটি সাপোর্ট",description:"সরাসরি সাপোর্ট এবং আপডেটের জন্য আমাদের টেলিগ্রাম চ্যানেল @csvmeta-এ জয়েন করুন।"}],proTipTitle:"প্রো টিপ: PNG ট্রান্সপারেন্সি",proTipDesc:"PNG ফাইল আপস্কেলের পরও স্বচ্ছ ব্যাকগ্রাউন্ড ধরে রাখে — AI রঙের ডিটেল উন্নত করে, আর alpha চ্যানেল আলাদাভাবে সংরক্ষিত থাকে; isolated স্টক গ্রাফিক্সের জন্য দারুণ।",button:"বুঝেছি, ধন্যবাদ!"}},bento:{en:{title:"Bento Grid Generator User Guide",steps:[{title:"1. Start with a Layout Preset",description:"Under Canvas Settings, pick a Layout Preset to load a ready-made grid: Standard Bento, Hero Feature, Symmetric Cards, or Header Banner. You can customize everything after loading a preset."},{title:"2. Set Canvas Size & Color",description:"Adjust Canvas Width and Height (100–4000 px, default 1920×1080) and pick a Canvas Color for the background behind your grid. Click empty space on the canvas anytime to return to these global settings."},{title:"3. Add or Remove Grid Boxes",description:"Click 'Add Grid Box' to insert a new 1×1 cell at the first free spot in the 4-column grid. Hover a box and click the red trash icon to delete it, or use 'Delete Box' in the sidebar when a box is selected."},{title:"4. Move & Resize on the Canvas",description:"Drag any box to reposition it on the grid. When selected, drag the green corner handle to resize. Boxes cannot overlap or extend beyond 4 columns — an error message appears if a move is blocked."},{title:"5. Style All Boxes Globally",description:"In Canvas Settings, tune Grid Box Background Style (fill color & opacity, border color & opacity, border width, corner radius), Grid Box Shadows (horizontal, vertical, blur, color, opacity), plus Padding and Grid Gap."},{title:"6. Select a Box to Edit Content",description:"Click a grid box to open Box Settings in the sidebar. Use 'Back to Canvas' or click empty canvas space to switch back to global settings. The selected box is highlighted with a green border."},{title:"7. Add Images to Boxes",description:"In Box Settings, upload an image (PNG, JPG, JPEG, or WEBP). Choose Cover (fills the cell) or Contain (fits inside), and adjust Image Opacity. Images and text can be combined in the same box."},{title:"8. Add Text Overlays",description:"Each box supports up to two text blocks. Set alignment, Google Font, size, color, and bold/italic/underline styles. Pick an HTML tag (paragraph or h1–h6) — useful when exporting as HTML."},{title:"9. Fine-Tune Grid Placement",description:"Use the +/- controls under Grid Placement to adjust Column Start, Column Span, Row Start, and Row Span precisely. This is helpful when drag-and-drop cannot reach the exact size you need."},{title:"10. Export Your Bento Grid",description:"Click 'Export Bento' and choose PNG, JPG, or HTML (ZIP). PNG and JPG render a high-quality flat image. HTML (ZIP) packages a responsive web page with your layout, fonts, images, and text."}
3829,{title:"11. Community Support",description:"Join our Telegram channel @csvmeta for direct support, feature requests, and community discussion."}],proTipTitle:"Pro Tip: HTML (ZIP) Export",proTipDesc:"Export as HTML (ZIP) to get a ready-to-use responsive web layout with embedded images and Google Fonts — perfect for portfolio sections, landing pages, or client mockups without rebuilding in code.",button:"Got it, thanks!"},bn:{title:"বেন্টো গ্রিড জেনারেটর ব্যবহার নির্দেশিকা",steps:[{title:"১. লেআউট প্রিসেট দিয়ে শুরু করুন",description:"Canvas Settings-এ Layout Preset বেছে নিন: Standard Bento, Hero Feature, Symmetric Cards, অথবা Header Banner। প্রিসেট লোডের পর সবকিছু নিজ মতো কাস্টমাইজ করা যায়।"},{title:"২. ক্যানভাস সাইজ ও রঙ সেট করুন",description:"Canvas Width ও Height (১০০–৪০০০ px, ডিফল্ট ১৯২০×১০৮০) ঠিক করুন এবং গ্রিডের পেছনের Canvas Color বেছে নিন। যেকোনো সময় খালি জায়গায় ক্লিক করে global সেটিংসে ফিরে আসুন।"},{title:"৩. গ্রিড বক্স যোগ বা সরান",description:"'Add Grid Box'-এ ক্লিক করলে ৪-কলাম গ্রিডে প্রথম খালি জায়গায় নতুন ১×১ সেল যোগ হয়। বক্সে হোভার করে লাল trash আইকন দিয়ে মুছুন, অথবা বক্স সিলেক্ট করে sidebar-এ 'Delete Box' ব্যবহার করুন।"},{title:"৪. ক্যানভাসে সরান ও রিসাইজ করুন",description:"যেকোনো বক্স টেনে গ্রিডে সরান। সিলেক্ট করা থাকলে সবুজ corner handle টেনে সাইজ বদলান। বক্স overlap করতে বা ৪ কলামের বাইরে যেতে পারবে না — ব্লক হলে error মেসেজ দেখা যাবে।"},{title:"৫. সব বক্সের স্টাইল গ্লোবালি সেট করুন",description:"Canvas Settings-এ Grid Box Background Style (fill রঙ ও opacity, border রঙ ও opacity, border width, corner radius), Grid Box Shadows (horizontal, vertical, blur, রঙ, opacity), এবং Padding ও Grid Gap ঠিক করুন।"},{title:"৬. কন্টেন্ট এডিট করতে বক্স সিলেক্ট করুন",description:"গ্রিড বক্সে ক্লিক করলে sidebar-এ Box Settings খুলবে। 'Back to Canvas' বা খালি জায়গায় ক্লিক করে global সেটিংসে যান। সিলেক্ট করা বক্স সবুজ border-এ হাইলাইট হয়।"},{title:"৭. বক্সে ইমেজ যোগ করুন",description:"Box Settings-এ ইমেজ আপলোড করুন (PNG, JPG, JPEG, WEBP)। Cover (সেল ভরে) বা Contain (ভিতরে ফিট) বেছে নিন, Image Opacity ঠিক করুন। একই বক্সে ইমেজ ও টেক্সট একসাথে রাখা যায়।"},{title:"৮. টেক্সট ওভারলে যোগ করুন",description:"প্রতিটি বক্সে সর্বোচ্চ দুটি টেক্সট ব্লক। alignment, Google Font, size, রঙ, bold/italic/underline সেট করুন। HTML tag (paragraph বা h1–h6) বেছে নিন — HTML এক্সপোর্টের জন্য কাজে লাগে।"},{title:"৯. গ্রিড প্লেসমেন্ট fine-tune করুন",description:"Grid Placement-এ +/- দিয়ে Column Start, Column Span, Row Start, Row Span সুনির্দিষ্টভাবে ঠিক করুন। drag-and-drop দিয়ে ঠিক সাইজ না পেলে এটি সহায়ক।"},{title:"১০. বেন্টো গ্রিড এক্সপোর্ট করুন",description:"'Export Bento'-এ ক্লিক করে PNG, JPG, অথবা HTML (ZIP) বেছে নিন। PNG ও JPG high-quality flat ইমেজ দেয়। HTML (ZIP) responsive ওয়েব পেজ বান্ডেল করে — লেআউট, ফন্ট, ইমেজ ও টেক্সটসহ।"},{title:"১১. কমিউনিটি সাপোর্ট",description:"সরাসরি সাপোর্ট এবং আপডেটের জন্য আমাদের টেলিগ্রাম চ্যানেল @csvmeta-এ জয়েন করুন।"}],proTipTitle:"প্রো টিপ: HTML (ZIP) এক্সপোর্ট",proTipDesc:"HTML (ZIP) হিসেবে এক্সপোর্ট করলে embedded ইমেজ ও Google Fonts-সহ responsive ওয়েব লেআউট পাবেন — পোর্টফোলিও সেকশন, ল্যান্ডিং পেজ বা ক্লায়েন্ট mockup-এর জন্য কোডে আবার বানানোর দরকার নেই।",button:"বুঝেছি, ধন্যবাদ!"}},vector:{en:{title:"Vector Studio User Guide",steps:[{title:"1. Set Up Your Artboard",description:"Set Artboard Width and Height in the top toolbar (1–10,000 px, default 1920×1080). This is your working c
3829anvas — all shapes and exports use these dimensions."},{title:"2. Choose a Drawing Tool",description:"Use the left toolbar: Selection (V) to move and resize objects, Direct Selection (A) for path anchors, Pen (P) for custom paths, Hand (H) and Zoom (Z) to navigate, Shape Tool for rectangles, ellipses, lines, and more, Polygon Tool for custom-sided shapes, Type (T) for text, and Boolean Operations to combine shapes."},{title:"3. Navigate the Canvas",description:"Pan with the Hand tool or by holding Space while dragging. Zoom with the Zoom tool (click to zoom in) or the +/- controls in the top bar. Click Fit to reset the view to 100%."},{title:"4. Draw Shapes",description:"Select a shape tool and drag on the artboard to draw. Hold Shift (or enable Constrain Proportions) for perfect squares, circles, and uniform boxes. Open the Shape submenu for rectangle, rounded rectangle, ellipse, triangle, star, diamond, hexagon, and line."},{title:"5. Pen Tool & Path Editing",description:"With the Pen tool, click to place anchor points and build paths. Press Enter to finish an open path, or click the first point to close it. Use Direct Selection to move anchors and handles. Backspace removes the last pen point or a selected anchor."},{title:"6. Fill, Stroke & Gradients",description:"Click the fill or stroke swatches in the toolbar to open the paint panel. Choose solid colors or gradients (linear/radial with up to four stops). Set opacity, or toggle No Fill / No Stroke. Selected shapes update live."},{title:"7. Add & Format Text",description:"Select the Type tool and click the artboard to add text. Edit content, font, size, color, alignment, and bold/italic/underline in the properties panel. Text outline mode uses the toolbar stroke color as a glyph outline."},{title:"8. Boolean Shape Operations",description:"Select two or more filled shapes (rectangle, ellipse, polygon, or star), open Boolean Operations, and choose Unite, Subtract, Intersect, Exclude, or Divide. Subtract removes front shapes from the back — ideal for cutting holes and building logos."},{title:"9. Layers, Groups & Shortcuts",description:"Use the Layers panel to show/hide, lock, reorder, group, and ungroup objects. Right-click for align, arrange, flip, and rotate options. Ctrl+Z / Ctrl+Shift+Z undo and redo; Ctrl+C/V copy and paste; Ctrl+D duplicate; Delete removes selection."},{title:"10. Import & Export",description:"Upload an SVG or drag it onto the canvas to import editable vector paths. Export via the Export menu as SVG (true vector), PNG, or JPG. Enable Transparency for PNG exports with no background — great for isolated graphics."},{title:"11. Community Support",description:"Join our Telegram channel @csvmeta for direct support, feature requests, and community discussion."}],proTipTitle:"Pro Tip: SVG Export for Stock",proTipDesc:"Export as SVG to keep your artwork fully scalable with clean paths and gradients — ideal for microstock vector submissions or opening in Illustrator and other editors without quality loss.",button:"Got it, thanks!"},bn:{title:"ভেক্টর স্টুডিও ব্যবহার নির্দেশিকা",steps:[{title:"১. আর্টবোর্ড সেটআপ করুন",description:"top toolbar-এ Artboard Width ও Height সেট করুন (১–১০,০০০ px, ডিফল্ট ১৯২০×১০৮০)। এটি আপনার কাজের ক্যানভাস — সব shape ও export এই মাপ ব্যবহার করে।"},{title:"২. ড্রয়িং টুল বেছে নিন",description:"বাম toolbar ব্যবহার করুন: Selection (V) দিয়ে object সরান ও রিসাইজ করুন, Direct Selection (A) দিয়ে path anchor এডিট করুন, Pen (P) custom path আঁকতে, Hand (H) ও Zoom (Z) নেভিগেট এবং ছোট/বড় করতে, Shape Tool rectangle(আয়তক্ষেত্র), ellipse(উপবৃত্ত), line(সরল রেখা) ইত্যাদির জন্য, Polygon Tool বহুভুজের ক্ষেত্রে, Type (T) টেক্সটের জন্য, Boolean Operations shape মিলাতে।"},{title:"৩. ক্যানভাস navigate করুন",description:"Hand tool দিয়ে pan করুন, অথবা Space ধরে drag করুন। Zoom tool (ক্লিকে zoom in) বা top bar-এর +/- দিয়ে zoom করুন। Fit-এ ক্লিক করে view ১০০%-এ reset করুন।"},{title:"৪. shape আঁকুন",description:"shape tool বেছে artboard-এ drag করুন। Shift ধরুন (অথবা Constrain Proportions চালু করুন) নিখুঁত বর্গক্ষেত্র, বৃত্ত বা সুষম বক্সের জন্য। Shape submenu-তে rectangle(আয়তক্ষেত্র), roun
3829ded rectangle(গোলাকার আয়তক্ষেত্র), ellipse(উপবৃত্ত), triangle(ত্রিভুজ), star(তারকা), diamond(ডাইমন্ড), hexagon(ষড়ভুজ), line(সরল রেখা) পাবেন।"},{title:"৫. Pen Tool ও path editing",description:"Pen tool-এ ক্লিক করে anchor point বসান ও path তৈরি করুন। Enter চাপলে open path শেষ, প্রথম point-এ ক্লিক করলে close হয়। Direct Selection দিয়ে anchor ও handle সরান। Backspace শেষ pen point বা সিলেক্ট করা anchor মুছে।"},{title:"৬. Fill, Stroke ও Gradient",description:"toolbar-এ fill বা stroke swatch-এ ক্লিক করে paint panel খুলুন। solid রঙ বা gradient (linear/radial, সর্বোচ্চ চার stop) বেছে নিন। opacity সেট করুন, No Fill / No Stroke toggle করুন। সিলেক্ট করা shape সরাসরি আপডেট হয়।"},{title:"৭. টেক্সট যোগ ও ফরম্যাট",description:"Type tool বেছে artboard-এ ক্লিক করে টেক্সট যোগ করুন। properties panel-এ content, font, size, রঙ, alignment, bold/italic/underline এডিট করুন। Text outline mode toolbar stroke রঙ glyph outline হিসেবে ব্যবহার করে।"},{title:"৮. Boolean Shape Operations",description:"দুই বা ততোধিক filled shape (rectangle, ellipse, polygon, star) সিলেক্ট করে Boolean Operations খুলে Unite, Subtract, Intersect, Exclude, অথবা Divide বেছে নিন। Subtract সামনের shape পেছন থেকে কাটে — গর্ত ও লোগো তৈরিতে দারুণ।"},{title:"৯. Layers, Groups ও Shortcuts",description:"Layers panel-এ show/hide, lock, reorder, group, ungroup করুন। right-click-এ align, arrange, flip, rotate পাবেন। Ctrl+Z / Ctrl+Shift+Z undo/redo; Ctrl+C/V copy/paste; Ctrl+D duplicate; Delete selection সরায়।"},{title:"১০. Import ও Export",description:"SVG upload করুন বা canvas-এ drag করে editable vector path ইম্পোর্ট করুন। Export menu থেকে SVG (সত্যিকার ভেক্টর), PNG, অথবা JPG নিন। PNG-তে Transparency চালু করলে ব্যাকগ্রাউন্ড ছাড়া export — isolated graphic-এর জন্য ভালো।"},{title:"১১. কমিউনিটি সাপোর্ট",description:"সরাসরি সাপোর্ট এবং আপডেটের জন্য আমাদের টেলিগ্রাম চ্যানেল @csvmeta-এ জয়েন করুন।"}],proTipTitle:"প্রো টিপ: স্টকের জন্য SVG এক্সপোর্ট",proTipDesc:"SVG হিসেবে এক্সপোর্ট করলে artwork সম্পূর্ণ scalable থাকে — path ও gradient অক্ষত থাকে; microstock vector upload বা Illustrator-এ quality loss ছাড়া খোলার জন্য আদর্শ।",button:"বুঝেছি, ধন্যবাদ!"}},color:{en:{title:"Color Extractor User Guide",steps:[{title:"1. Upload an Image",description:"Click the upload area or drag and drop a JPG, PNG, or SVG file. The tool analyzes your image entirely in the browser — nothing is sent to a server."},{title:"2. Automatic Palette Extraction",description:"As soon as your image loads, the tool detects how many distinct colors it contains and builds an initial palette automatically. A gradient strip and individual swatches appear below the preview."},{title:"3. Adjust Number of Colors",description:"Use the Number of Colors slider (1–10) to control palette size. Lower values give a simpler, more unified scheme; higher values capture more nuance. The palette updates instantly as you slide."}
3829,{title:"4. View the Color Palette",description:"Each swatch shows a color preview plus HEX, RGB, HSL, and RGBA values. The strip at the top gives a quick visual overview of your full palette at a glance."},{title:"5. Copy Swatch Values",description:"Click any HEX, RGB, HSL, or RGBA row on a swatch to copy that value to your clipboard. A green check confirms the copy — paste directly into CSS, design tools, or metadata."},{title:"6. Use the Eyedropper on the Preview",description:"Move your cursor over the image preview to sample any pixel — a live color ring and value tooltip follow your mouse. Click once to copy that exact color to the clipboard."},{title:"7. Choose Picker Format",description:"Under Picker Format, select HEX, RGB, HSL, or RGBA. This controls which format the eyedropper copies when you click the preview, and what appears in the hover tooltip."},{title:"8. Replace or Delete the Image",description:"Click Replace Image to upload a different file without leaving the tool. Use Delete to clear the current image and palette and start fresh."},{title:"9. Export the Palette",description:"Click Export and choose PNG or SVG. Both formats produce a labeled swatch sheet with each color block and its HEX, HSL, RGB, and RGBA values — ready to share or attach to a brief."},{title:"10. Community Support",description:"Join our Telegram channel @csvmeta for direct support, feature requests, and community discussion."}],proTipTitle:"Pro Tip: Eyedropper Click-to-Copy",proTipDesc:"Need one exact shade from a reference photo? Hover the preview to preview any pixel, then click once — the color copies in your chosen format, perfect for matching stock backgrounds or brand colors.",button:"Got it, thanks!"},bn:{title:"কালার এক্সট্রাক্টর ব্যবহার নির্দেশিকা",steps:[{title:"১. ইমেজ আপলোড করুন",description:"upload area-তে ক্লিক করুন অথবা JPG, PNG, বা SVG ফাইল drag ও drop করুন। টুলটি সম্পূর্ণ ব্রাউজারে ইমেজ বিশ্লেষণ করে — কোনো সার্ভারে পাঠানো হয় না।"},{title:"২. স্বয়ংক্রিয় প্যালেট এক্সট্রাকশন",description:"ইমেজ লোড হওয়ার সাথে সাথে টুলটি কতগুলো আলাদা রঙ আছে তা detect করে initial palette তৈরি করে। gradient strip ও আলাদা আলাদা swatch নিচে দেখা যাবে।"},{title:"৩. রঙের সংখ্যা ঠিক করুন",description:"Number of Colors স্লাইডার (১–১০) দিয়ে palette size নিয়ন্ত্রণ করুন। কম মানে সহজ, একীভূত scheme; বেশি মানে বেশি nuance। স্লাইড করলেই palette তৎক্ষণাৎ আপডেট হয়।"},{title:"৪. কালার প্যালেট দেখুন",description:"প্রতিটি swatch-এ color preview এবং HEX, RGB, HSL, RGBA মান দেখা যায়। উপরের strip দিয়ে পুরো palette এক নজরে বোঝা যায়।"},{title:"৫. Swatch মান কপি করুন",description:"যেকোনো swatch-এ HEX, RGB, HSL, বা RGBA row-এ ক্লিক করলে clipboard-এ কপি হয়। সবুজ tick নিশ্চিত করে — সরাসরি CSS, design tool, বা metadata-তে paste করুন।"},{title:"৬. প্রিভিউতে Eyedropper ব্যবহার",description:"ইমেজ preview-এ cursor নিন — যেকোনো pixel স্যাম্পল হবে, live color ring ও value tooltip cursor অনুযায়ী চলে। একবার ক্লিক করলে সেই exact রঙ clipboard-এ কপি হয়।"},{title:"৭. Picker Format বেছে নিন",description:"Picker Format-এ HEX, RGB, HSL, বা RGBA সিলেক্ট করুন। preview-এ ক্লিক করলে eyedropper কোন format-এ কপি করবে এবং hover tooltip-এ কী দেখাবে তা নির্ধারণ করে।"},{title:"৮. ইমেজ Replace বা Delete করুন",description:"Replace Image-এ ক্লিক করে অন্য ফাইল আপলোড করুন। Delete দিয়ে বর্তমান ইমেজ ও palette মুছে নতুন করে শুরু করুন।"},{title:"৯. প্যালেট এক্সপোর্ট করুন",description:"Export-এ ক্লিক করে PNG বা SVG বেছে নিন। দুটো format-ই labeled swatch sheet দেয় — প্রতিটি color block ও HEX, HSL, RGB, RGBA মানসহ; share বা brief-এ attach করতে সুবিধাজনক।"},{title:"১০. কমিউনিটি সাপোর্ট",description:"সরাসরি সাপোর্ট এবং আপডেটের জন্য আমাদের টেলিগ্রাম চ্যানেল @csvmeta-এ জয়েন করুন।"}],proTipTitle:"প্রো টিপ: Eyedropper Click-to-Copy",proTipDesc:"reference photo থেকে একটি exact shade দরকার? preview-এ hover করে pixel দেখুন, তারপর একবার ক্লিক — আপনার বেছে নেওয়া format-এ রঙ কপি হয়; স্টক ব্যাকগ্রাউন্ড বা ব্র্যান্ড কালার মেলানোর জন্য দারুণ।",button:"বুঝেছি, ধন্যবাদ!"}}},OTe=(t,e)=>{var n;return((n=mz[t])==null?void 0:n[e])??mz.metadata[e]},LTe=({isOpen:t,onClose:e,tool:n="metadata"})=>{const[s,r]=q.useState("en");if(!t)return null;const i=OTe(n,s),a=pz[n]??pz.metadata??[];return d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",children:[d.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50",children:[d.jsx("h2",{className:"text-2xl font-bold text-slate-800 dark:text-white flex items-center gap-3",children:i.title}),d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsxs("div",{className:"flex bg-slate-200 dark:bg-slate-700 rounded-lg p-1",children:[d.jsx("button",{onClick:()=>r("en"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all ${s==="en"?"bg-white dark:bg-slate-600 shadow text-brand-600 dark:text-brand-400":"text-slate-500 dark:text-slate-400 hover:text-slate-700"}`,children:"English"}),d.jsx("button",{onClick:()=>r("bn"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all ${s==="bn"?"bg-white dark:bg-slate-600 shadow text-brand-600 dark:text-brand-400":"text-slate-500 dark:text-slate-400 hover:text-slate-700"}`,children:"বাংলা"})]}),d.jsx("button",{onClick:e,className:"p-2 text-slate-400 hover:text-slate-600 dar
3829k:hover:text-slate-200 rounded-full hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors",children:d.jsx(Ki,{className:"w-6 h-6"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:i.steps.map((o,l)=>d.jsxs("div",{className:"flex gap-4 p-4 rounded-xl border border-slate-100 dark:border-slate-700 bg-slate-50/50 dark:bg-slate-800/50 hover:border-brand-200 dark:hover:border-brand-900 transition-colors",children:[d.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-brand-50 dark:bg-brand-900/20 rounded-lg flex items-center justify-center border border-brand-100 dark:border-brand-900/50",children:a[l]||d.jsx(xd,{className:mn})}),d.jsxs("div",{children:[d.jsx("h3",{className:"font-bold text-slate-800 dark:text-slate-100 mb-1",children:o.title}),d.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400 leading-relaxed",children:o.description})]})]},l))}),d.jsxs("div",{className:"mt-8 p-4 bg-brand-50 dark:bg-brand-900/10 rounded-xl border border-brand-100 dark:border-brand-800/30",children:[d.jsx("h4",{className:"font-semibold text-brand-800 dark:text-brand-300 mb
3829-2",children:i.proTipTitle}),d.jsx("p",{className:"text-sm text-brand-700 dark:text-brand-200/80",children:i.proTipDesc})]}),i.videoUrl&&d.jsxs("div",{className:"mt-8",children:[d.jsxs("h3",{className:"text-xl font-bold text-slate-800 dark:text-white mb-4 flex items-center gap-2",children:[d.jsx(F1,{className:"w-6 h-6 text-brand-500"}),s==="en"?"Video Guide":"ভিডিও গাইড"]}),d.jsx("div",{className:"relative w-full overflow-hidden rounded-xl bg-slate-100 dark:bg-slate-800",style:{paddingTop:"56.25%"},children:d.jsx("iframe",{className:"absolute top-0 left-0 w-full h-full",src:i.videoUrl,title:"YouTube video player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0})})]})]}),d.jsx("div",{className:"p-6 border-t border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 flex justify-end",children:d.jsx("button",{onClick:e,className:"px-6 py-2.5 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 font-bold rounded-lg transition-colors",children:i.button})})]})})},jTe=({className:t})=>d.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),BTe=({className:t})=>d.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.008-.57-.008-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})}),Uk="https://csvmeta.com/",gz="Generate Stock Photo metadata (titles & keywords) instantly with AI!",UTe=({isOpen:t,onClose:e})=>{const[n,s]=q.useState(!1);if(!t)return null;const r=()=>{navigator.clipboard.writeText(Uk).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})};return d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl w-full max-w-sm p-6 transform transition-all scale-100",children:[d.jsxs("div",{className:"flex justify-between items-center mb-6",children:[d.jsxs("h2",{className:"text-xl font-bold text-slate-800 dark:text-white flex items-center gap-2",children:[d.jsx(gD,{className:"w-5 h-5 text-[#47ff72]"}),"Share this tool"]}),d.jsx("button",{onClick:e,className:"text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",children:d.jsx(Ki,{className:"w-5 h-5"})})]}),d.jsxs("div",{className:"flex items-center justify-center gap-4 py-2",children:[d.jsxs("button",{onClick:r,className:"group relative w-12 h-12 flex items-center justify-center rounded-full bg-slate-100 dark:bg-slate-700 hover:bg-slate-200 dark:hover:bg-slate-600 transition-all text-slate-600 dark:text-slate-200",title:"Copy Link",children:[n?d.jsx(yd,{className:"w-5 h-5 text-green-500"}):d.jsx(XL,{className:"w-5 h-5"}),n&&d.jsx("span",{className:"absolute -top-8 bg-slate-800 text-white text-xs px-2 py-1 rounded shadow-lg animate-in fade-in slide-in-from-bottom-2",children:"Copied!"})]}),d.jsx("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Uk)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-[#1877F2] hover:bg-[#166fe5] text-white transition-transform hover:scale-110 shadow-lg shadow-blue-500/20",title:"Share on Facebook",children:d.jsx(KL,{className:"w-5 h-5 fill-current"})}),d.jsx("a",{href:`https://twitter.com/intent/tweet?url=${encodeURIComponent(Uk)}&text=${encodeURIComponent(gz)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-black dark:bg-white hover:bg-slate-900 dark:hover:bg-slate-100 text-white dark:text-black transition-transform hover:scale-110 shadow-lg shadow-slate-500/20",title:"Share on X",children:d.jsx(jTe,{className:"w-5 h-5"})}),d.jsx("a",{href:`https://wa.me/?text=${encodeURIComponent(gz+" "+Uk)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-[#25D366] hover:bg-[#20bd5a] text-white transition-transform hover:scale-110 shadow-lg shadow-green-500/20",title:"Share on WhatsApp",children:d.jsx(BTe,{className:"w-5 h-5"})})]})]})})},FTe=({isOpen:t,setIsOpen:e,activeTool:n,setActiveTool:s})=>{Qh();const r=n==="metadata",i=n==="background",a=n==="upscale",o=n==="bento",l=n==="vector",c=n==="color",h=(p,m)=>{s&&(p.preventDefault(),s(m))};return d.jsxs("div",{className:`hidden md:flex ${t?"w-[280px]":"w-20"} bg-white dark:bg-slate-900 border-r border-slate-200 dark:border-slate-800 transition-all duration-300 flex-col z-30 flex-shrink-0 sticky top-[64px] h-[calc(100vh-64px)]`,children:[d.jsxs("div",{className:"py-6 px-4 flex-1 flex flex-col gap-6 overflow-y-auto",children:[t?d.jsxs("a",{href:"https://chromewebstore.google.com/detail/foliaahbfnegnbmclfomfeamfkmnncjm",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 bg-white dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700/50 hover:border-[#47ff72]/50 rounded-xl transition-colors group cursor-pointer shadow-sm dark:shadow-none",children:[d.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 dar
3829k:bg-slate-700 flex items-center justify-center flex-shrink-0",children:d.jsx("img",{src:"https://upload.wikimedia.org/wikipedia/commons/e/e1/Google_Chrome_icon_%28February_2022%29.svg",alt:"Chrome",className:"w-4 h-4"})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("h4",{className:"text-sm font-bold text-slate-800 dark:text-slate-200 group-hover:text-[#47ff72] transition-colors truncate",children:"Get Extension"}),d.jsx("p",{className:"text-xs text-slate-500 truncate",children:"Chrome Web Store"})]}),d.jsx(vd,{className:"w-4 h-4 text-slate-500 group-hover:text-[#47ff72]"})]}):d.jsx("a",{href:"https://chromewebstore.google.com/detail/foliaahbfnegnbmclfomfeamfkmnncjm",target:"_blank",rel:"noopener noreferrer",className:"w-10 h-10 mx-auto rounded-full bg-white dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700/50 flex items-center justify-center hover:border-[#47ff72]/50 transition-colors group shadow-sm dark:shadow-none",title:"Get Chrome Extension",children:d.jsx("img",{src:"https://upload.wikimedia.org/wikipedia/commons/e/e1/Google_Chrome_icon_%28February_2022%29.svg",alt:"Chrome",className:"w-5 h-5"})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[t&&d.jsx("span",{className:"text-[10px] uppercase font-bold tracking-widest text-slate-500 ml-2 mb-1",children:"Tools"}),d.jsxs(Is,{to:"/app",onClick:p=>h(p,"metadata"),title:"Metadata Generator",className:`flex items-center gap-3 px-3 py-3 rounded-xl transition-colors ${r?"bg-slate-100 dark:bg-slate-800 shadow-sm text-[#47ff72] font-bold":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300 font-medium"}`,children:[d.jsx(mp,{className:r?"text-[#47ff72]":"",size:20}),t&&d.jsx("span",{className:"truncate",children:"Metadata Generator"})]}),d.jsxs(Is,{to:"/app",onClick:p=>h(p,"background"),title:"Background Generator",className:`flex items-center gap-3 px-3 py-3 rounded-xl transition-colors ${i?"bg-slate-100 dark:bg-slate-800 shadow-sm text-[#47ff72] font-bold":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300 font-medium"}`,children:[d.jsx(Sd,{className:i?"text-[#47ff72]":"",size:20}
3829),t&&d.jsx("span",{className:"truncate",children:"Background Generator"})]}),d.jsxs(Is,{to:"/app",onClick:p=>h(p,"upscale"),title:"Image Upscaler",className:`flex items-center gap-3 px-3 py-3 rounded-xl transition-colors ${a?"bg-slate-100 dark:bg-slate-800 shadow-sm text-[#47ff72] font-bold":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300 font-medium"}`,children:[d.jsx(AA,{className:a?"text-[#47ff72]":"",size:20}),t&&d.jsx("span",{className:"truncate",children:"Image Upscaler"})]}),d.jsxs(Is,{to:"/app",onClick:p=>h(p,"bento"),title:"Bento Generator",className:`flex items-center gap-3 px-3 py-3 rounded-xl transition-colors ${o?"bg-slate-100 dark:bg-slate-800 shadow-sm text-[#47ff72] font-bold":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300 font-medium"}`,children:[d.jsx(wM,{className:o?"text-[#47ff72]":"",size:20}),t&&d.jsx("span",{className:"truncate",children:"Bento Generator"})]}),d.jsxs(Is,{to:"/app",onClick:p=>h(p,"vector"),title:"Vector Studio",className:`flex items-center gap-3 px-3 py-3 rounded-xl transition-colors ${l?"bg-slate-100 dark:bg-slate-800 shadow-sm text-[#47ff72] font-bold":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300 font-medium"}`,children:[d.jsx(JL,{className:l?"text-[#47ff72]":"",size:20}),t&&d.jsx("span",{className:"truncate",children:"Vector Studio"})]}),d.jsxs(Is,{to:"/app",onClick:p=>h(p,"color"),title:"Color Extractor",className:`flex items-center gap-3 px-3 py-3 rounded-xl transition-colors ${c?"bg-slate-100 dark:bg-slate-800 shadow-sm text-[#47ff72] font-bold":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300 font-medium"}`,children:[d.jsx(U1,{className:c?"text-[#47ff72]":"",size:20}),t&&d.jsx("span",{className:"truncate",children:"Color Extractor"})]})]})]}),d.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800 mt-auto",children:d.jsx("button",{onClick:()=>e(!t),className:`flex items-center ${t?"w-full justify-start gap-3 px-3 py-2":"justify-center mx-auto p-2"} rounded-xl text-slate-500 hover:text-[#47ff72] dark:hover:bg-slate-800/50 transition-colors`,title:"Toggle Sidebar",children:t?d.jsxs(d.Fragment,{children:[d.jsx(qL,{size:20}),d.jsx("span",{className:"font-medium text-sm",children:"Collapse Sidebar"})]}):d.jsx(cD,{size:20})})})]})},VTe={free:3,lite:5};function D7(t,e="user"){if(e==="admin")return{mode:"unlimited"};if(t==="max")return{mode:"unlimited"};if(t==="plus")return{mode:"csvBuck"};const n=VTe[t];return n!=null?{mode:"complementary",dailyLimit:n}:{mode:"complementary",dailyLimit:3}}function zTe(t){return!t||t.role==="admin"?!1:D7(t.plan??"free",t.role).mode==="complementary"}function MI(t){const e=t==null?void 0:t.complementaryUsage;return!e||typeof e!="object"?{}:e}function rZ(t,e,n){const s=t[e],r=s==null?void 0:s.lastReset;return xM(r)?{usedToday:0,lastReset:Om()}:{usedToday:(s==null?void 0:s.usedToday)??0,lastReset:r??Om()}}function GTe(t,e,n){if(!t)return null;const s=D7(t.plan??"free",t.role);if(s.mode!=="complementary"||s.dailyLimit==null)return null;const r=n??MI(t),i=rZ(r,e,s.dailyLimit);return Math.max(0,s.dailyLimit-i.usedToday)}function sR(t){return((t==null?void 0:t.plan)??"free")==="plus"?"Not enough CSVBucks for this export. Upgrade your plan on the pricing page.":"You have used all complementary exports for this tool today. Upgrade your plan on the pricing page."}async function HTe(t,e){const n=Td(Bc,"users",t);try{const s=await DX(Bc,async r=>{const i=await r.get(n);if(!i.exists())throw new Error("User profile not found.");const a=i.data(),o=a.role??"user",l=a.plan??"free",c=D7(l,o);if(c.mode==="unlimited")return{success:!0,remaining:null,csvBucksBalance:a.csvBucksBalance,complementaryUsage:MI(a)};if(c.mode==="csvBuck"){const b=tc(l);let S=typeof a.csvBucksBalance=="number"?a.csvBucksBalance:b.csvBucks;if(b.isDaily&&xM(a.lastCsvBucksReset)&&(S=b.csvBucks),S<1)return{success:!1,error:"insufficient_csvbucks"};const E={csvBucksBalance:S-1};return b.isDaily&&(E.csvBucksUsedToday=(a.csvBucksUsedToday??0)+1,E.lastCsvBucksReset=Om()),r.update(n,E),{success:!0,remaining:null,csvBucksBalance:S-1,complementaryUsage:MI(a)}}const h=c.dailyLimit??3,p=MI(a),m=rZ(p,e,h);if(m.usedToday>=h)return{success:!1,error:"complementary_exhausted"};const y={usedToday:m.usedToday+1,lastReset:m.lastReset},v={...p,[e]:y};return r.update(n,{complementaryUsage:v}),{success:!0,remaining:h-y.usedToday,csvBucksBalance:a.csvBucksBalance,complementaryUsage:v}});return s.success?s:{success:!1,error:s.error==="insufficient_csvbucks"?sR({plan:"plus"}):sR(null)}}catch(s){return console.error("consumeComplementaryExport failed",s),{success:!1,error:"Could not complete export. Please try again."}}}function qTe(t,e,n){return{...t,...n!=null?{csvBucksBalance:n}:{},...e?{complementaryUsage:e}:{}}}function MM(t){const[e,n]=q.useState(null),[s,r]=q.useState({}),[i,a]=q.useState(null),[o,l]=q.useState(!1),[c,h]=q.useState(!0),p=q.useCallback(y=>{const v=y.complementaryUsage??{};n(y),r(v),l(zTe(y)),a(GTe(y,t,v))},[t]);q.useEffect(()=>{const y=Vm(Ko,async v=>{if(!v){n(null),r({}),a(null),l(!1),h(!1);return}try{const b=await Vv(v);p(b)}catch(b){console.error("Failed to sync profile for complementary exports",b)}finally{h(!1)}});return()=>y()},[p]);const m=q.useCallback(async()=>
3829{if(!(e!=null&&e.sub))return{ok:!1,error:"Please sign in to export."};const y=await HTe(e.sub,t);if(!y.success)return{ok:!1,error:y.error??sR(e)};const v=qTe(e,y.complementaryUsage,y.csvBucksBalance);return p(v),{ok:!0}},[e,t,p]);return{user:e,remaining:i,showRemaining:o,isLoading:c,tryConsumeExport:m,upgradeMessage:sR(e)}}const EE=({showRemaining:t,remaining:e,className:n=""})=>!t||e==null?null:e===0?d.jsxs("p",{className:`text-xs text-amber-600 dark:text-amber-300 text-center leading-relaxed ${n}`,children:["You have used all complementary exports for this tool today."," ",d.jsx(Is,{to:"/pricing",className:"font-semibold text-[#47ff72] hover:underline",children:"Upgrade your plan"})," ","for more."]}):d.jsxs("p",{className:`text-xs text-slate-500 dark:text-slate-400 text-center ${n}`,children:[e," complementary export",e===1?"":"s"," remaining today"]}),WTe={batch_limit:{title:"Batch limit reached",subtitle:"Process more files at once",description:"Your current plan caps how many files you can add to a single batch. Upgrade to unlock larger batches and keep your metadata workflow running at full speed.",ctaLabel:"View plans & upgrade"},csvbucks:{title:"You're out of CSVBucks",subtitle:"Never pause mid-workflow again",description:"You have used all available CSVBucks for now. Paid plans include thousands of monthly credits so you can generate metadata and prompts without stopping.",ctaLabel:"Upgrade for more CSVBucks"}
3829,complementary_daily:{title:"Daily export limit reached",subtitle:"Unlock the full creative suite",description:"You have used all complimentary exports for this tool today. Upgrade to CSV Plus or CSV Max for expanded access and higher limits across every tool.",ctaLabel:"Upgrade your plan"},complementary_csvbucks:{title:"Not enough CSVBucks",subtitle:"Keep exporting without friction",description:"This export needs CSVBucks but your balance is too low. Upgrade for a larger monthly allowance and smoother access to Background, Upscaler, Bento, and Vector Studio.",ctaLabel:"Get more CSVBucks"}};function KTe(t){if(!t)return"complementary_daily";const e=t.toLowerCase();return e.includes("csvbuck")&&e.includes("not enough")?"complementary_csvbucks":e.includes("csvbuck")?"csvbucks":e.includes("batch")?"batch_limit":"complementary_daily"}function YTe(t){if(!t)return!1;const e=t.toLowerCase();return e.includes("sign in")||e.includes("could not complete")?!1:e.includes("upgrade")||e.includes("csvbuck")||e.includes("complementary")||e.includes("batch")}const XTe="/assets/pricinginsistmodalimage-CKHGSr6h.webp",MA=({isOpen:t,onClose:e,reason:n})=>{const s=WTe[n];return q.useEffect(()=>{if(!t)return;const r=i=>{i.key==="Escape"&&e()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,e]),d.jsx(kv,{children:t&&d.jsx(ks.div,{initial:{opacity:0}
3829,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/75 backdrop-blur-md p-4",onClick:e,children:d.jsxs(ks.div,{initial:{opacity:0,scale:.94,y:16},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.94,y:16},transition:{duration:.25,ease:[.22,1,.36,1]},className:"relative w-full max-w-3xl overflow-hidden rounded-2xl border border-[#47ff72]/30 bg-[#011f08] shadow-[0_0_60px_rgba(71,255,114,0.18)]",onClick:r=>r.stopPropagation(),children:[d.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#47ff72]/10 via-transparent to-emerald-950/40 pointer-events-none"}),d.jsx("div",{className:"absolute -top-24 -right-24 w-64 h-64 bg-[#47ff72]/10 rounded-full blur-[80px] pointer-events-none"}),d.jsx("button",{onClick:e,className:"absolute top-4 right-4 z-20 p-2 rounded-full text-slate-400 hover:text-white hover:bg-white/10 transition-colors","aria-label":"Close",children:d.jsx(Ki,{className:"w-5 h-5"})}),d.jsxs("div",{className:"relative flex flex-col md:flex-row min-h-[320px]",children:[d.jsxs("div",{className:"md:w-[42%] min-h-[180px] md:min-h-0 relative overflow-hidden",children:[d.jsx("img",{src:XTe,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),d.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-[#011f08]/20 to-[#011f08] md:bg-gradient-to-r md:from-transparent md:to-[#011f08]"})]}),d.jsxs("div",{className:"flex-1 flex flex-col justify-center px-6 py-8 md:px-8 md:py-10 md:min-w-[22rem]",children:[d.jsxs("div",{className:"inline-flex items-center gap-2 mb-4",children:[d.jsx(mp,{className:"w-4 h-4 text-[#47ff72]"}),d.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] text-[#47ff72]/80",children:"Upgrade recommended"})]}),d.jsx("h2",{className:"text-2xl md:text-3xl font-extrabold text-[#47ff72] leading-tight",children:s.title}),d.jsx("p",{className:"mt-2 text-base font-semibold text-white/90",children:s.subtitle}),d.jsx("p",{className:"mt-4 text-sm text-slate-400 leading-relaxed max-w-md",children:s.description}),d.jsxs("div",{className:"mt-8 flex flex-wrap items-center gap-3",children:[d.jsxs(Is,{to:"/pricing",onClick:e,className:"inline-flex items-center justify-center gap-2 px-6 py-3.5 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 text-sm font-bold rounded-xl shadow-[0_0_24px_rgba(71,255,114,0.4)] hover:shadow-[0_0_32px_rgba(71,255,114,0.55)] transition-all hover:-translate-y-0.5 whitespace-nowrap shrink-0",children:[s.ctaLabel,d.jsx(fE,{className:"w-4 h-4 shrink-0"})]}),d.jsx("button",{type:"button",onClick:e,className:"inline-flex items-center justify-center px-6 py-3.5 text-sm font-medium text-slate-400 hover:text-white border border-slate-700 hover:border-slate-500 rounded-xl transition-colors whitespace-nowrap shrink-0",children:"Maybe later"})]})]})]})]})})})};function PA(){const[t,e]=q.useState(!1),[n,s]=q.useState("csvbucks"),r=q.useCallback(o=>{s(o),e(!0)},[]),i=q.useCallback(()=>{e(!1)},[]),a=q.useCallback(o=>YTe(o)?(s(KTe(o)),e(!0),!0):!1,[]);return{isOpen:t,reason:n,openPricingInsist:r,closePricingInsist:i,openFromGateError:a}}const zD=(t,e)=>{const n=parseInt(t.slice(1,3),16)||0,s=parseInt(t.slice(3,5),16)||0,r=parseInt(t.slice(5,7),16)||0,i=parseInt(e.slice(1,3),16)||0,a=parseInt(e.slice(3,5),16)||0,o=parseInt(e.slice(5,7),16)||0,l=Math.round((n+i)/2),c=Math.round((s+a)/2),h=Math.round((r+o)/2);return`#${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}`},PI=(t,e)=>{let n=[];const s=[...t].sort((r,i)=>r.position-i.position);for(let r=0;r<s.length;r++)if(n.push({color:s[r].color,position:s[r].position}),r<s.length-1){const i=s[r].position,a=s[r+1].position,o=e[r]??50,l=i+(a-i)*(o/100);n.push({color:zD(s[r].color,s[r+1].color),position:l})}return n.sort((r,i)=>r.position-i.position)},JTe=(t,e)=>`linear-gradient(to right, ${PI(t,e).map(r=>`${r.color} ${r.position}%`).join(", ")})`,QTe=()=>{var hn,Yt,Qe,tn;const{remaining:t,showRemaining:e,tryConsumeExport:n}=MM("background"),{isOpen:s,reason:r,openFromGateError:i,closePricingInsist:a}=PA(),[o,l]=q.useState("linear"),[c,h]=q.useState([{id:"1",color:"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),position:0},{id:"2",color:"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),position:100}]),[p,m]=q.useState([50]),[y,v]=q.useState({type:"stop",index:0}),b=q.useRef(null),S=q.useRef(null),E=q.useRef(c),I=q.useRef(p);q.useEffect(()=>{E.current=c,I.current=p},[c,p]),q.useEffect(()=>{const je=Dt=>
3829{if(!S.current||!b.current)return;const Ut=b.current.getBoundingClientRect(),Lt=(Dt-Ut.left)/Ut.width*100,Wt=Math.max(0,Math.min(100,Math.round(Lt))),{type:fn,index:Jt}=S.current;if(fn==="stop"){const Kn=E.current,nn=Jt>0?Kn[Jt-1].position+1:0,Wn=Jt<Kn.length-1?Kn[Jt+1].position-1:100,ln=Math.max(nn,Math.min(Wn,Wt));h(ns=>{const Js=[...ns];return Js[Jt]={...Js[Jt],position:ln},Js})}else if(fn==="mid"){const Kn=E.current,nn=Kn[Jt].position,Wn=Kn[Jt+1].position;if(Wn>nn){const ln=Math.max(5,Math.min(95,Math.round((Wt-nn)/(Wn-nn)*100)));m(ns=>{const Js=[...ns];return Js[Jt]=ln,Js})}}},Ue=Dt=>je(Dt.clientX),bt=Dt=>{Dt.touches.length>0&&je(Dt.touches[0].clientX)},ht=()=>{S.current=null};return window.addEventListener("mousemove",Ue),window.addEventListener("mouseup",ht),window.addEventListener("touchmove",bt,{passive:!1}),window.addEventListener("touchend",ht),window.addEventListener("touchcancel",ht),()=>{window.removeEventListener("mousemove",Ue),window.removeEventListener("mouseup",ht),window.removeEventListener("touchmove",bt),window.removeEventListener("touchend",ht),window.removeEventListener("touchcancel",ht)}},[]);const[M,j]=q.useState(45),[L,K]=q.useState(10),[D,R]=q.useState(50),[B,G]=q.useState(100),[X,H]=q.useState(10),[Y,F]=q.useState(1),[we,me]=q.useState(0),[xe,Le]=q.useState(null),[ve,ce]=q.useState(null),[ie,de]=q.useState(null),[Re,Se]=q.useState(null),[De,gt]=q.useState(null),[yt,xt]=q.useState(null),[Nt,wt]=q.useState(0),[zt,_n]=q.useState(0),[Zt,J]=q.useState(1920),[We,Ie]=q.useState(1080),ge=q.useRef(null),[he,Ae]=q.useState(!1),[et,nt]=q.useState(!1),He=q.useRef(null);q.useEffect(()=>{if(xe){const je=new Image;je.onload=()=>de(je),je.src=xe}else de(null)},[xe]),q.useEffect(()=>{if(Re){const je=new Image;je.onload=()=>xt(je),je.src=Re}else xt(null)},[Re]),q.useEffect(()=>{const je=Ue=>{He.current&&!He.current.contains(Ue.target)&&nt(!1)};return document.addEventListener("mousedown",je),()=>document.removeEventListener("mousedown",je)},[]);const ft=q.useCallback(()=>{const je=ge.current;if(!je)return;const Ue=je.getContext("2d");if(!Ue)return;const bt=Math.max(1,Zt),ht=Math.max(1,We);je.width=bt,je.height=ht,Ue.clearRect(0,0,bt,ht),zt>0&&(Ue.filter=`blur(${zt}px)`);const Dt=zt*2;if(o==="solid")Ue.fillStyle=c[0].color,Ue.fillRect(-Dt,-Dt,bt+Dt*2,ht+Dt*2);else if(o==="seamless"){if(Ue.fillStyle=c[0].color,Ue.fillRect(-Dt,-Dt,bt+Dt*2,ht+Dt*2),yt&&(Ue.save(),Ue.drawImage(yt,0,0,bt,ht),Ue.restore()),ie){Ue.save();const Ut=X,Lt=bt/Ut,Wt=Lt,fn=Math.floor(ht/Wt),Jt=(ht-fn*Wt)/2,Kn=nn=>{const Wn=Math.sin(nn)*1e4;return Wn-Math.floor(Wn)};for(let nn=0;nn<=fn;nn++){const Wn=nn%2!==0,ln=Wn?Ut-1:Ut;for(let ns=0;ns<ln;ns++){const Js=Y+nn*Ut+ns;let ur=ns*Lt+Lt/2;Wn&&(ur+=Lt/2);let zs=nn*Wt+Wt/2+Jt;const fs=(Kn(Js+2)-.5)*(Y/1e3)*Math.PI,ps=we*Math.PI/180+fs,ms=1+(Kn(Js+3)-.5)*(Y/1e3),Me=B*ms,lt=Me/2;ur-lt>=0&&ur+lt<=bt&&zs-lt>=0&&zs+lt<=ht&&(Ue.save(),Ue.translate(ur,zs),Ue.rotate(ps),Ue.drawImage(ie,-Me/2,-Me/2,Me,Me),Ue.restore())}}Ue.restore()}}else{let Ut;if(o.includes("radial")){const Wt=bt/2,fn=ht/2,Jt=o==="stripe-radial"?Math.sqrt(Wt*Wt+fn*fn):Math.max(bt,ht)/2;Ut=Ue.createRadialGradient(Wt,fn,0,Wt,fn,Jt)}else{const Wt=M*Math.PI/180,fn=Math.abs(bt*Math.cos(Wt))+Math.abs(ht*Math.sin(Wt)),Jt=bt/2,Kn=ht/2,nn=Jt-Math.cos(Wt)*fn/2,Wn=Kn-Math.sin(Wt)*fn/2,ln=Jt+Math.cos(Wt)*fn/2,ns=Kn+Math.sin(Wt)*fn/2;Ut=Ue.createLinearGradient(nn,Wn,ln,ns)}if(o.startsWith("stripe"))for(let Wt=0;Wt<L;Wt++){const fn=Math.max(0,Math.min(1,Wt/L)),Jt=Math.max(0,Math.min(1,(Wt+1)/L)),Kn=Math.max(0,Math.min(1,fn+(Jt-fn)*(D/100)));Ut.addColorStop(fn,c[0].color),Ut.addColorStop(Kn,c[0].color),Ut.addColorStop(Kn,c[c.length-1].color),Ut.addColorStop(Jt,c[c.length-1].color)}
3829else PI(c,p).forEach(fn=>Ut.addColorStop(Math.min(1,Math.max(0,fn.position/100)),fn.color));Ue.fillStyle=Ut,Ue.fillRect(-Dt,-Dt,bt+Dt*2,ht+Dt*2)}if(Ue.filter="none",Nt>0){const Lt=document.createElement("canvas");Lt.width=256,Lt.height=256;const Wt=Lt.getContext("2d");if(Wt){const fn=Wt.createImageData(256,256),Jt=fn.data,Kn=Nt*2.55;for(let Wn=0;Wn<Jt.length;Wn+=4){const ln=(Math.random()-.5)*Kn;Jt[Wn]=ln>0?255:0,Jt[Wn+1]=ln>0?255:0,Jt[Wn+2]=ln>0?255:0,Jt[Wn+3]=Math.abs(ln)}Wt.putImageData(fn,0,0);const nn=Ue.createPattern(Lt,"repeat");nn&&(Ue.globalCompositeOperation="overlay",Ue.fillStyle=nn,Ue.fillRect(0,0,bt,ht),Ue.globalCompositeOperation="source-over")}}},[o,c,p,M,Nt,zt,Zt,We,L,D,B,X,Y,ie,we,yt]);q.useEffect(()=>{const je=setTimeout(()=>{requestAnimationFrame(ft)},10);return()=>clearTimeout(je)},[ft]);const Mt=(je="jpg")=>{const Ue=ge.current;if(!Ue)return;if(je==="svg"&&o==="seamless"&&xe){Oe();return}const bt=document.createElement("a");bt.download=`background-${Zt}x${We}.${je==="svg"?"svg":"jpg"}`,bt.href=Ue.toDataURL(je==="svg"?"image/svg+xml":"image/jpeg",.9),bt.click()},pt=async(je="jpg")=>{const Ue=await n();if(!Ue.ok){i(Ue.error)||alert(Ue.error);return}Mt(je)},Oe=()=>{if(!ve)return;const je=Zt||1920,Ue=We||1080,Dt=new DOMParser().parseFromString(ve,"image/svg+xml").documentElement;if(Dt.tagName==="html"||Dt.querySelector("parsererror")){console.error("Invalid SVG file");return}let Ut=0,Lt=0,Wt=100,fn=100;const Jt=Dt.getAttribute("viewBox");if(Jt){const Ft=Jt.trim().split(/[\s,]+/).map(Number);Ft.length>=4&&([Ut,Lt,Wt,fn]=Ft)}else Wt=parseFloat(Dt.getAttribute("width")||"100"),fn=parseFloat(Dt.getAttribute("height")||"100");let Kn=`width="${je}" height="${Ue}" viewBox="0 0 ${je} ${Ue}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"`;Array.from(Dt.attributes).forEach(Ft=>{Ft.name.startsWith("xmlns:")&&Ft.name!=="xmlns:xlink"&&(Kn+=` ${Ft.name}="${Ft.value}"`)});let nn=`<svg ${Kn}>
3830`;const Wn=Dt.querySelectorAll("defs");let ln="";Wn.forEach(Ft=>{Array.from(Ft.childNodes).forEach(sn=>{ln+=new XMLSerializer().serializeToString(sn)}),Ft.remove()}),Dt.querySelectorAll("title, desc").forEach(Ft=>Ft.remove()),Dt.querySelectorAll("rect").forEach(Ft=>{var bs,gs;const sn=Ft.getAttribute("fill")||((bs=Ft.style)==null?void 0:bs.fill),rn=Ft.getAttribute("stroke")||((gs=Ft.style)==null?void 0:gs.stroke);(sn==="none"||sn==="transparent")&&(!rn||rn==="none")&&Ft.remove()});let ns="";if(Array.from(Dt.childNodes).forEach(Ft=>{var sn;(Ft.nodeType===1||Ft.nodeType===3&&((sn=Ft.textContent)!=null&&sn.trim()))&&(ns+=new XMLSerializer().serializeToString(Ft))}),ln&&(nn+=`<defs>
3831${ln}
3832</defs>
3833`),nn+=`<rect width="${je}" height="${Ue}" fill="${c[0].color}"/>
3834`,De){const rn=new DOMParser().parseFromString(De,"image/svg+xml").documentElement;rn.tagName!=="html"&&!rn.querySelector("parsererror")&&(rn.setAttribute("width","100%"),rn.setAttribute("height","100%"),rn.setAttribute("x","0"),rn.setAttribute("y","0"),nn+=new XMLSerializer().serializeToString(rn)+`
3835`)}const Js=X,ur=je/Js,zs=ur,fs=Math.floor(Ue/zs),ps=(Ue-fs*zs)/2,ms=Ft=>{const sn=Math.sin(Ft)*1e4;return sn-Math.floor(sn)},Me=Ut+Wt/2,lt=Lt+fn/2,jt=Ft=>Number(Ft.toFixed(4));for(let Ft=0;Ft<=fs;Ft++){const sn=Ft%2!==0,rn=sn?Js-1:Js;for(let bs=0;bs<rn;bs++){const gs=Y+Ft*Js+bs;let us=bs*ur+ur/2;sn&&(us+=ur/2);let Hn=Ft*zs+zs/2+ps;const ls=(ms(gs+2)-.5)*(Y/1e3)*Math.PI,Ps=we*Math.PI/180+ls,rr=1+(ms(gs+3)-.5)*(Y/1e3),ws=B*rr,$s=ws/2;if(us-$s<0||us+$s>je||Hn-$s<0||Hn+$s>Ue)continue;const ys=ws/Wt,Pn=ws/fn,ir=Math.cos(Ps)*ys,ot=Math.sin(Ps)*ys,ar=-Math.sin(Ps)*Pn,$n=Math.cos(Ps)*Pn,kn=us-ir*Me-ar*lt,Nn=Hn-ot*Me-$n*lt;nn+=`<g transform="matrix(${jt(ir)} ${jt(ot)} ${jt(ar)} ${jt($n)} ${jt(kn)} ${jt(Nn)})">
3836`,nn+=ns,nn+=`</g>
3837`}}nn+="</svg>";const Qt=new Blob([nn],{type:"image/svg+xml"}),Sn=URL.createObjectURL(Qt),yn=document.createElement("a");yn.download=`background-pattern-${Date.now()}.svg`,yn.href=Sn,yn.click(),URL.revokeObjectURL(Sn)};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex-1 w-full max-w-[1600px] w-[96%] mx-auto px-4 sm:px-6 lg:px-8 py-4 sm:py-8 space-y-4 sm:sp
3837ace-y-8 animate-in fade-in zoom-in-95 duration-500",children:[d.jsxs("div",{className:"text-center space-y-4 mb-8",children:[d.jsx("h2",{className:"text-3xl font-bold text-[#47ff72]",children:"Background Generator"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-sm sm:text-base max-w-2xl mx-auto",children:"Generate high quality abstract and gradient backgrounds. Perfect for stock photography, social media, or app backgrounds."})]}),d.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-4 sm:gap-8",children:[d.jsxs("div",{className:"xl:col-span-1 bg-white dark:bg-slate-800/80 border border-slate-200 dark:border-slate-700/50 rounded-2xl p-4 sm:p-6 shadow-sm space-y-6 sm:space-y-8 xl:max-h-[calc(100vh-10rem)] xl:overflow-y-auto xl:sticky xl:top-8 scrollbar-thin scrollbar-thumb-slate-200 dark:scrollbar-thumb-slate-700",children:[d.jsxs("div",{className:"space-y-4",children:[d.jsxs("h3",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2 border-b border-slate-200 dark:border-slate-700 pb-2",children:[d.jsx(Z0,{className:"w-4 h-4 text-[#47ff72]"})," Base Settings"]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Type"}),d.jsxs("div",{className:"relative",children:[d.jsxs("select",{value:o==="solid"?"solid":o.startsWith("stripe")?"stripe":o==="seamless"?"seamless":"gradient",onChange:je=>{const Ue=je.target.value;Ue==="solid"?l("solid"):Ue==="gradient"?l("linear"):Ue==="stripe"?l("stripe-linear"):Ue==="seamless"&&l("seamless")},className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-xl px-4 py-2.5 text-slate-900 dark:text-white outline-none focus:border-[#47ff72] text-sm font-semibold appearance-none cursor-pointer",children:[d.jsx("option",{value:"solid",className:"dark:bg-slate-900",children:"Solid"}),d.jsx("option",{value:"gradient",className:"dark:bg-slate-900",children:"Gradient"}),d.jsx("option",{value:"stripe",className:"dark:bg-slate-900",children:"Stripe"}),d.jsx("option",{value:"seamless",className:"dark:bg-slate-900",children:"Seamless"})]}),d.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-500 pointer-events-none",children:d.jsx(P0,{className:"w-4 h-4"})})]})]}),o!=="solid"&&o!=="seamless"&&d.jsxs("div",{className:"space-y-1 animate-in slide-in-from-top-2 duration-300",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Style"}),d.jsx("div",{className:"flex bg-slate-100 dark:bg-slate-900 p-1 rounded-xl",children:["linear","radial"].map(je=>{const Ue=o.startsWith("stripe")?"stripe":"gradient",bt=o.includes(je),ht=Ue==="stripe"?`stripe-${je}`:je;return d.jsx("button",{onClick:()=>l(ht),className:`flex-1 py-1.5 rounded-lg text-sm font-semibold capitalize transition-all ${bt?"bg-white dark:bg-slate-700 text-[#47ff72] dark:text-[#47ff72] shadow-sm":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:je},je)})})]})]})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2 border-b border-slate-200 dark:border-slate-700 pb-2",children:o==="seamless"?"Background & Vector":"Colors"}),o!=="solid"&&o!=="seamless"&&!o.startsWith("stripe")?d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Gradient"}),d.jsxs("div",{ref:b,className:"relative w-full h-8 rounded-lg cursor-crosshair border border-slate-300 dark:border-slate-700 shadow-inner",style:{background:JTe(c,p)},onMouseDown:je=>{if(c.length>=4||!b.current)return;const Ue=b.current.getBoundingClientRect(),bt=Math.max(0,Math.min(100,Math.round((je.clientX-Ue.left)/Ue.width*100)));let ht=c.findIndex(Jt=>Jt.position>bt);ht===-1&&(ht=c.length),ht===0&&(ht=1);const Dt=PI(c,p);let Ut="#ffffff",Lt=Dt.findIndex(Jt=>Jt.position>=bt);Lt>0&&Lt<Dt.length&&(Ut=zD(Dt[Lt-1].color,Dt[Lt].color));const Wt=[...c];Wt.splice(ht,0,{id:Date.now().toString(),color:Ut,position:bt});const fn=[...p];fn.splice(ht>0?ht-1:0,0,50),h(Wt),m(fn),v({type:"stop",index:ht})},onTouchStart:je=>{if(c.length>=4||!b.current)return;const Ue=b.current.getBoundingClientRect(),bt=Math.max(0,Math.min(100,Math.round((je.touches[0].clientX-Ue.left)/Ue.width*100)));let ht=c.findIndex(Jt=>Jt.position>bt);ht===-1&&(ht=c.length),ht===0&&(ht=1);const Dt=PI(c,p);let Ut="#ffffff",Lt=Dt.findIndex(Jt=>Jt.position>=bt);Lt>0&&Lt<Dt.length&&(Ut=zD(Dt[Lt-1].color,Dt[Lt].color));const Wt=[...c];Wt.splice(ht,0,{id:Date.now().toString(),color:Ut,position:bt});const fn=[...p];fn.splice(ht>0?ht-1:0,0,50),h(Wt),m(fn),v({type:"stop",index:ht})},children:[c.map((je,Ue)=>d.jsx("div",{onMouseDown:bt=>{bt.stopPropagation(),S.current={type:"stop",index:Ue},v({type:"stop",index:Ue})},onTouchStart:bt=>{bt.stopPropagation(),S.current={type:"stop",index:Ue},v({type:"stop",index:Ue})},className:`absolute top-1/2 -translate-y-1/2 w-4 h-4 rounded-full border-2 cursor-grab drag-none ${(y==null?void 0:y.type)==="stop"&&y.index===Ue?"border-white z-20 scale-125":"border-slate-300 z-10"}`,style:{left:`calc(${je.position}% - 8px)`,backgroundColor:je.color}},je.id)),p.map((je,Ue)=>{const bt=c[Ue].position,ht=c[Ue+1].position,Dt=bt+(ht-bt)*(je/100);return d.jsx("div",{onMouseDown:Ut=>{Ut.stopPropagation(),S.current={type:"mid",index:Ue},v({type:"mid",index:Ue})},onTouchStart:Ut=>{Ut.stopPropagation(),S.current={type:"mid",index:Ue},v({type:"mid",index:Ue})},className:`absolute top-1/2 -translate-y-1/2 w-2 h-4 cursor-grab bg-slate-300 ${(y==null?void 0:y.type)==="mid"&&y.index===Ue?"bg-white z-20 scale-125 border border-slate-500":"z-10 bg-opacity-70"}`,style:{left:`calc(${Dt}% - 4px)`}},`mid-${Ue}`)})]})]}),d.jsx("div",{className:"grid grid-cols-2 gap-4 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-xl",children:(y==null?void 0:y.type)==="stop"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-bold uppercase",children:"Color"}),d.jsx("div",{className:"relative",children:d.jsx("input",{type:"color",value:((hn=c[y.index])==null?void 0:hn.color)||"#ffffff",onChange:je=>{const Ue=[...c];Ue[y.index].color=je.target.value,h(Ue)},className:"w-full h-8 rounded border-0 outline-none bg-transparent cursor-pointer"})})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-bold uppercase",children:"Position (%)"}),d.jsx("input",{type:"number",value:Math.round(((Yt=c[y.index])==null?void 0:Yt.position)||0),onChange:je=>{const Ue=parseInt(je.target.value)||0,bt=Math.max(0,Math.min(100,Ue)),ht=c,Dt=y.index,Ut=Dt>0?ht[Dt-1].position+1:0,Lt=Dt<ht.length-1?ht[Dt+1].position-1:100,Wt=M
3837ath.max(Ut,Math.min(Lt,bt)),fn=[...c];fn[Dt].position=Wt,h(fn)},className:"w-full h-8 bg-slate-200 dark:bg-slate-700/50 rounded p-1.5 text-sm text-center text-[#47ff72] font-mono outline-none"})]})]}):(y==null?void 0:y.type)==="mid"?d.jsxs("div",{className:"space-y-1 col-span-2",children:[d.jsx("label",{className:"text-xs text-slate-500 font-bold uppercase",children:"Midpoint (%)"}),d.jsx("input",{type:"number",value:p[y.index]??50,onChange:je=>{const Ue=Math.max(5,Math.min(95,parseInt(je.target.value)||50)),bt=[...p];bt[y.index]=Ue,m(bt)},className:"w-full h-8 bg-slate-200 dark:bg-slate-700/50 rounded p-1.5 text-sm text-center text-[#47ff72] font-mono outline-none"})]}):null}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{onClick:()=>{if(c.length>=4)return;let je=0,Ue=1;for(let Lt=0;Lt<c.length-1;Lt++){const Wt=c[Lt+1].position-c[Lt].position;Wt>je&&(je=Wt,Ue=Lt+1)}if(je<2)return;const bt=Math.round(c[Ue-1].position+je/2),ht={id:Date.now().toString(),color:"#ffffff",position:bt},Dt=[...c];Dt.splice(Ue,0,ht);const Ut=[...p];Ut.splice(Ue-1,0,50),h(Dt),m(Ut),v({type:"stop",index:Ue})},disabled:c.length>=4,className:"flex-1 py-1.5 bg-slate-100 dark:bg-slate-800 rounded-lg text-xs font-bold hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-50 transition-all font-mono",children:"+ Add Stop"}),d.jsx("button",{onClick:()=>{if(!(c.length>2&&(y==null?void 0:y.type)==="stop"))return;const Ue=y.index,bt=[...c];bt.splice(Ue,1);const ht=[...p];ht.splice(Math.max(0,Ue-1),1),h(bt),m(ht),v({type:"stop",index:Math.max(0,Ue-1)})},disabled:!(c.length>2&&(y==null?void 0:y.type)==="stop"),className:"flex-1 py-1.5 bg-slate-100 dark:bg-slate-800 text-red-500 rounded-lg text-xs font-bold hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-50 transition-all font-mono",children:"Delete"})]})]}):d.jsxs("div",{className:"flex gap-4",children:[d.jsxs("div",{className:"flex-1 space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:o==="solid"||o==="seamless"?"Background Color":"Start Color"}),d.jsxs("div",{className:"relative",children:[d.jsx("input",{type:"color",value:((Qe=c[0])==null?void 0:Qe.color)??"#000000",onChange:je=>{const Ue=[...c];Ue[0].color=je.target.value,h(Ue)},className:"w-full h-12 rounded-lg cursor-pointer border-0 p-0 overflow-hidden"}),d.jsx("div",{className:"absolute inset-0 border border-slate-200 dark:border-slate-700 rounded-lg pointer-events-none"})]})]}),o.startsWith("stripe")&&d.jsxs("div",{className:"flex-1 space-y-2 animate-in slide-in-from-right-4 duration-300",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:"End Color"}),d.jsxs("div",{className:"relative",children:[d.jsx("input",{type:"color",value:((tn=c[c.length-1])==null?void 0:tn.color)??"#000000",onChange:je=>{const Ue=[...c];Ue[c.length-1].color=je.target.value,h(Ue)},className:"w-full h-12 rounded-lg cursor-pointer border-0 p-0 overflow-hidden"}),d.jsx("div",{className:"absolute inset-0 border border-slate-200 dark:border-slate-700 rounded-lg pointer-events-none"})]})]})]}),o==="seamless"&&d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-top-4 duration-300",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase block",children:"Custom Background SVG (Optional)"}),Re?d.jsxs("div",{className:"flex items-center justify-between p-3 border border-slate-200 dark:border-slate-700 rounded-xl bg-slate-50 dark:bg-slate-800",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden bg-white flex items-center justify-center p-1",children:d.jsx("img",{src:Re,className:"w-full object-contain",alt:"Custom BG",referrerPolicy:"no-referrer"})}),d.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300",children:"Custom SVG"})]}),d.jsx("button",{onClick:()=>{Se(null),gt(null),xt(null)},className:"text-slate-400 hover:text-red-500 transition-colors",children:d.jsx(xl,{className:"w-4 h-4"})})]}):d.jsxs("label",{className:"flex flex-col items-center justify-center w-full h-24 border-2 border-dashed border-slate-200 dark:border-slate-700 rounded-xl cursor-pointer hover:bg-slate-50 dark:hover:bg-slate-800 transition-all",children:[d.jsx("span",{className:"text-sm text-slate-500 font-medium",children:"Upload BG SVG"}),d.jsx("input",{type:"file",accept:".svg",className:"hidden",onChange:je=>{var bt;const Ue=(bt=je.target.files)==null?void 0:bt[0];if(Ue){const ht=new FileReader;ht.onload=Ut=>{var Lt;return Se((Lt=Ut.target)==null?void 0:Lt.result)}
3837,ht.readAsDataURL(Ue);const Dt=new FileReader;Dt.onload=Ut=>{var Lt;return gt((Lt=Ut.target)==null?void 0:Lt.result)},Dt.readAsText(Ue)}}})]})]}),d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-top-4 duration-300",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase block",children:"SVG Vector"}),xe?d.jsxs("div",{className:"relative group",children:[d.jsx("div",{className:"flex flex-col items-center justify-center w-full h-32 border-2 border-solid border-slate-200 dark:border-slate-700 rounded-xl bg-slate-50/50 dark:bg-slate-900/50 p-4",children:d.jsx("img",{src:xe,alt:"Preview",className:"max-w-full max-h-full object-contain",referrerPolicy:"no-referrer"})}),d.jsx("button",{onClick:()=>{Le(null),ce(null),de(null)},className:"absolute -top-2 -right-2 w-8 h-8 bg-red-500 text-white rounded-full flex items-center justify-center shadow-lg hover:bg-red-600 transition-colors active:scale-95",title:"Remove Vector",children:d.jsx(xl,{className:"w-4 h-4"})}),d.jsx("p",{className:"text-[10px] text-[#47ff72] font-bold text-center mt-2 uppercase tracking-wider animate-pulse",children:"SVG Loaded Successfully!"})]}):d.jsxs("label",{className:"flex flex-col items-center justify-center w-full h-32 border-2 border-dashed border-slate-200 dark:border-slate-700 rounded-xl cursor-pointer hover:bg-slate-50 dark:hover:bg-slate-800 transition-all",children:[d.jsxs("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[d.jsx(bM,{className:"w-8 h-8 text-[#47ff72] mb-2"}),d.jsx("p",{className:"text-sm text-slate-500 font-medium",children:"Upload SVG"})]}),d.jsx("input",{type:"file",accept:".svg",className:"hidden",onChange:je=>{var bt;const Ue=(bt=je.target.files)==null?void 0:bt[0];if(Ue){const ht=new FileReader;ht.onload=Ut=>{var Lt;return Le((Lt=Ut.target)==null?void 0:Lt.result)},ht.readAsDataURL(Ue);const Dt=new FileReader;Dt.onload=Ut=>{var Lt;return ce((Lt=Ut.target)==null?void 0:Lt.result)},Dt.readAsText(Ue)}}})]})]})]})]}),d.jsxs("div",{className:"space-y-6",children:[d.jsxs("h3",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2 border-b border-slate-200 dark:border-slate-700 pb-2",children:[d.jsx(SM,{className:"w-4 h-4 text-[#47ff72]"})," Adjustments"]}),o.startsWith("stripe")&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Frequency"}),d.jsx("input",{type:"number",value:L,onChange:je=>K(parseInt(je.target.value,10)||1),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dark:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"})]}),d.jsx("input",{type:"range",min:"1",max:"100",value:L,onChange:je=>K(parseInt(je.target.value,10)),className:"w-full accent-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Width"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("input",{type:"number",value:D,onChange:je=>R(parseFloat(je.target.value)||0),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dark:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"}),d.jsx("span",{className:"text-[10px] text-slate-500 font-bold",children:"%"})]})]}),d.jsx("input",{type:"range",min:"0",max:"100",value:D,onChange:je=>R(parseFloat(je.target.value)),className:"w-full accent-[#47ff72]"})]})]}),o==="seamless"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Vector Size"}),d.jsx("input",{type:"number",value:B,onChange:je=>G(parseInt(je.target.value,10)||1),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dar
3837k:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"})]}),d.jsx("input",{type:"range",min:"10",max:"500",value:B,onChange:je=>G(parseInt(je.target.value,10)),className:"w-full accent-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Frequency"}),d.jsx("input",{type:"number",value:X,onChange:je=>H(parseInt(je.target.value,10)||1),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dark:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"})]}),d.jsx("input",{type:"range",min:"2",max:"50",value:X,onChange:je=>H(parseInt(je.target.value,10)),className:"w-full accent-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Vector Rotation"}),d.jsx("input",{type:"number",value:we,onChange:je=>me(parseInt(je.target.value,10)||0),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dark:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"})]}),d.jsx("input",{type:"range",min:"0",max:"360",value:we,onChange:je=>me(parseInt(je.target.value,10)),className:"w-full accent-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Variation (Seed)"}),d.jsx("input",{type:"number",value:Y,onChange:je=>F(parseInt(je.target.value,10)||1),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dark:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"})]}),d.jsx("input",{type:"range",min:"0",max:"1000",value:Y,onChange:je=>F(parseInt(je.target.value,10)),className:"w-full accent-[#47ff72]"})]})]}),o.includes("linear")&&d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Angle"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("input",{type:"number",value:M,onChange:je=>j(parseFloat(je.target.value)||0),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dark:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"}),d.jsx("span",{className:"text-[10px] text-slate-500 font-bold",children:"°"})]})]}),d.jsx("input",{type:"range",min:"0",max:"360",value:M,onChange:je=>j(parseFloat(je.target.value)),className:"w-full accent-[#47ff72]"})]}),o!=="seamless"&&d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Noise / Grain"}),d.jsx("input",{type:"number",value:Nt,onChange:je=>wt(parseFloat(je.target.value)||0),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dark:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"})]}),d.jsx("input",{type:"range",min:"0",max:"100",value:Nt,onChange:je=>wt(parseFloat(je.target.value)),className:"w-full accent-[#47ff72]"})]}),o!=="solid"&&o!=="seamless"&&d.jsxs("div",{className:"space-y-3 animate-in slide-in-from-bottom-4 duration-300",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase",children:"Blur"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("input",{type:"number",value:zt,onChange:je=>_n(parseFloat(je.target.value)||0),className:"w-12 text-xs font-mono text-center text-[#47ff72] bg-slate-100 dar
3837k:bg-slate-700 py-0.5 rounded outline-none focus:ring-1 focus:ring-[#47ff72]/50"}),d.jsx("span",{className:"text-[10px] text-slate-500 font-bold",children:"px"})]})]}),d.jsx("input",{type:"range",min:"0",max:"100",value:zt,onChange:je=>_n(parseFloat(je.target.value)),className:"w-full accent-[#47ff72]"})]})]})]}),d.jsxs("div",{className:"xl:col-span-2 relative flex flex-col items-center justify-center bg-slate-100 dark:bg-slate-900/50 rounded-2xl border border-slate-200 dark:border-slate-800 p-2 sm:p-4 xl:p-8 xl:pt-28 min-h-[300px] sm:min-h-[500px]",children:[d.jsxs("div",{className:"w-full relative group",children:[o==="seamless"&&!xe&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:d.jsxs(ks.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"bg-white/90 dark:bg-slate-800/90 backdrop-blur-md border border-slate-200 dark:border-slate-700 px-8 py-6 rounded-3xl shadow-2xl flex flex-col items-center gap-3",children:[d.jsx("div",{className:"w-12 h-12 bg-[#47ff72]/10 rounded-full flex items-center justify-center mb-1",children:d.jsx(mp,{className:"w-6 h-6 text-[#47ff72] animate-pulse"})}),d.jsx("p",{className:"text-slate-900 dark:text-white font-bold text-lg text-center",children:"Upload a vector to see the preview"}),d.jsx("p",{className:"text-sm text-slate-500 font-medium text-center",children:"Use the SVG Vector upload tool in the sidebar to get started"})]})}),d.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+CjxyZWN0IHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2ZmZmZmZiI+PC9yZWN0Pgo8cmVjdCB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIGZpbGw9IiNlNmU2ZTYiPjwvcmVjdD4KPHJlY3QgeD0iMTAiIHk9IjEwIiB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIGZpbGw9IiNlNmU2ZTYiPjwvcmVjdD4KPC9zdmc+')] rounded-xl shadow-2xl z-0 overflow-hidden",style:{aspectRatio:`${Zt}/${We}`,opacity:.1}}),d.jsx("canvas",{ref:ge,className:"w-full h-auto rounded-xl shadow-2xl relative z-10 border border-white/10",style:{aspectRatio:`${Zt}/${We}`,maxHeight:"70vh",objectFit:"contain"}}),d.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/60 backdrop-blur-md text-white text-xs font-mono px-3 py-1.5 rounded-full z-20 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity",children:["Preview (",Zt,"x",We,")"]})]}),d.jsx("div",{className:"xl:absolute xl:top-8 xl:right-8 mt-8 xl:mt-0 flex flex-col items-end z-30",ref:He,children:!(o==="seamless"&&!xe)&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:()=>nt(!et),className:`flex items-center gap-2 px-6 py-3 ${et?"bg-slate-900 text-white":"bg-[#47ff72] text-slate-900"} rounded-xl font-bold hover:bg-[#32cc59] hover:text-slate-900 transition-all active:scale-95 shadow-lg shadow-[#47ff72]/20`,children:[d.jsx(Ua,{className:"w-5 h-5"})," Export",et?d.jsx(XX,{className:"w-4 h-4 ml-1"}):d.jsx(P0,{className:"w-4 h-4 ml-1"})]}),d.jsx(kv,{children:et&&d.jsx(ks.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"mt-2 w-72 bg-white dark:bg-[#172032] text-black dark:text-white rounded-3xl p-6 shadow-2xl border border-white/10",children:d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"space-y-3",children:[d.jsx("h4",{className:"text-sm font-bold text-slate-400 uppercase tracking-widest",children:"Dimensions"}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("div",{className:"relative group",children:[d.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 font-bold text-sm",children:"W"}),d.jsx("input",{type:"number",value:Zt||"",onChange:je=>J(je.target.value?parseInt(je.target.value,10):0),className:"w-full bg-slate-900/50 border border-slate-800 rounded-xl pl-8 pr-3 py-3 text-[#47ff72] outline-none focus:border-[#47ff72]/50 focus:bg-slate-900 transition-all text-sm font-mono"})]}),d.jsxs("div",{className:"relative group",children:[d.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 font-bold text-sm",children:"H"}),d.jsx("input",{type:"number",value:We||"",onChange:je=>Ie(je.target.value?parseInt(je.target.value,10):0),className:"w-full bg-slate-900/50 border border-slate-800 rounded-xl pl-8 pr-3 py-3 text-[#47ff72] outline-none focus:border-[#47ff72]/50 focus:bg-slate-900 transition-all text-sm font-mono"})]})]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{onClick:()=>{pt("jpg"),nt(!1)},className:"flex-1 py-4 bg-[#47ff72] text-slate-900 rounded-2xl font-black text-lg hover:bg-[#32cc59] transition-all active:scale-[0.98] shadow-lg shadow-[#47ff72]/20",children:"JPG"}),o==="seamless"&&d.jsx("button",{onClick:()=>{pt("svg"),nt(!1)},className:"flex-1 py-4 bg-white text-slate-900 rounded-2xl font-black text-lg hover:bg-slate-100 transition-all active:scale-[0.98] shadow-lg",children:"SVG"})]}),d.jsx(EE,{showRemaining:e,remaining:t,className:"pt-2"})]})})})]})})]})]})]}),d.jsx(MA,{isOpen:s,onClose:a,reason:r})]})};/*!
3838 * ONNX Runtime Web v1.26.0
3839 * Copyright (c) Microsoft Corporation. All rights reserved.
3840 * Licensed under the MIT License.
3841 */var O7=Object.defineProperty,ZTe=Object.getOwnPropertyDescriptor,eAe=Object.getOwnPropertyNames,tAe=Object.prototype.hasOwnProperty,nAe=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),qt=(t,e)=>()=>(t&&(e=t(t=0)),e),i_=(t,e)=>{for(var n in e)O7(t,n,{get:e[n],enumerable:!0})},sAe=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of eAe(e))!tAe.call(t,r)&&r!==n&&O7(t,r,{get:()=>e[r],enumerable:!(s=ZTe(e,r))||s.enumerable});return t},TE=t=>
vendor: 16,852 bytes, line 3841
3841sAe(O7({},"__esModule",{value:!0}),t),B2,Rg,aw,yz,iZ,aZ=qt(()=>{B2=new Map,Rg=[],aw=(t,e,n)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let s=B2.get(t);if(s===void 0)B2.set(t,{backend:e,priority:n});else{if(s.priority>n)return;if(s.priority===n&&s.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){let r=Rg.indexOf(t);r!==-1&&Rg.splice(r,1);for(let i=0;i<Rg.length;i++)if(B2.get(Rg[i]).priority<=n){Rg.splice(i,0,t);return}Rg.push(t)}return}throw new TypeError("not a valid backend")},yz=async t=>{let e=B2.get(t);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let n=!!e.initPromise;try{return n||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(s){return n||(e.error=`${s}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},iZ=async t=>{let e=t.executionProviders||[],n=e.map(l=>typeof l=="string"?l:l.name),s=n.length===0?Rg:n,r,i=[],a=new Set;for(let l of s){let c=await yz(l);typeof c=="string"?i.push({name:l,err:c}):(r||(r=c),r===c&&a.add(l))}if(!r)throw new Error(`no available backend found. ERR: ${i.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(let{name:l,err:c}of i)n.includes(l)&&console.warn(`removing requested execution provider "${l}" from session options because it is not available: ${c}`);let o=e.filter(l=>a.has(typeof l=="string"?l:l.name));return[r,new Proxy(t,{get:(l,c)=>c==="executionProviders"?o:Reflect.get(l,c)})]}}),rAe=qt(()=>{aZ()}),oZ,iAe=qt(()=>{oZ="1.26.0"}),e$,vo,lZ=qt(()=>{iAe(),e$="warning",vo={wasm:{},webgl:{},webgpu:{},versions:{common:oZ},set logLevel(t){if(t!==void 0){if(typeof t!="string"||["verbose","info","warning","error","fatal"].indexOf(t)===-1)throw new Error(`Unsupported logging level: ${t}`);e$=t}},get logLevel(){return e$}},Object.defineProperty(vo,"logLevel",{enumerable:!0})}),fi,aAe=qt(()=>{lZ(),fi=vo}),cZ,uZ,oAe=qt(()=>{cZ=(t,e)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=t.dims[3],n.height=t.dims[2];let s=n.getContext("2d");if(s!=null){let r,i;(e==null?void 0:e.tensorLayout)!==void 0&&e.tensorLayout==="NHWC"?(r=t.dims[2],i=t.dims[3]):(r=t.dims[3],i=t.dims[2]);let a=(e==null?void 0:e.format)!==void 0?e.format:"RGB",o=e==null?void 0:e.norm,l,c;o===void 0||o.mean===void 0?l=[255,255,255,255]:typeof o.mean=="number"?l=[o.mean,o.mean,o.mean,o.mean]:(l=[o.mean[0],o.mean[1],o.mean[2],0],o.mean[3]!==void 0&&(l[3]=o.mean[3])),o===void 0||o.bias===void 0?c=[0,0,0,0]:typeof o.bias=="number"?c=[o.bias,o.bias,o.bias,o.bias]:(c=[o.bias[0],o.bias[1],o.bias[2],0],o.bias[3]!==void 0&&(c[3]=o.bias[3]));let h=i*r,p=0,m=h,y=h*2,v=-1;a==="RGBA"?(p=0,m=h,y=h*2,v=h*3):a==="RGB"?(p=0,m=h,y=h*2):a==="RBG"&&(p=0,y=h,m=h*2);for(let b=0;b<i;b++)for(let S=0;S<r;S++){let E=(t.data[p++]-c[0])*l[0],I=(t.data[m++]-c[1])*l[1],M=(t.data[y++]-c[2])*l[2],j=v===-1?255:(t.data[v++]-c[3])*l[3];s.fillStyle="rgba("+E+","+I+","+M+","+j+")",s.fillRect(S,b,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},uZ=(t,e)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),s;if(n!=null){let r,i,a;(e==null?void 0:e.tensorLayout)!==void 0&&e.tensorLayout==="NHWC"?(r=t.dims[2],i=t.dims[1],a=t.dims[3]):(r=t.dims[3],i=t.dims[2],a=t.dims[1]);let o=e!==void 0&&e.format!==void 0?e.format:"RGB",l=e==null?void 0:e.norm,c,h;l===void 0||l.mean===void 0?c=[255,255,255,255]:typeof l.mean=="number"?c=[l.mean,l.mean,l.mean,l.mean]:(c=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(c[3]=l.mean[3])),l===void 0||l.bias===void 0?h=[0,0,0,0]:typeof l.bias=="number"?h=[l.bias,l.bias,l.bias,l.bias]:(h=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(h[3]=l.bias[3]));let p=i*r;if(e!==void 0&&(e.format!==void 0&&a===4&&e.format!=="RGBA"||a===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let m=4,y=0,v=1,b=2,S=3,E=0,I=p,M=p*2,j=-1;o==="RGBA"?(E=0,I=p,M=p*2,j=p*3):o==="RGB"?(E=0,I=p,M=p*2):o==="RBG"&&(E=0,M=p,I=p*2),s=n.createImageData(r,i);for(let L=0;L<i*r;y+=m,v+=m,b+=m,S+=m,L++)s.data[y]=(t.data[E++]-h[0])*c[0],s.data[v]=(t.data[I++]-h[1])*c[1],s.data[b]=(t.data[M++]-h[2])*c[2],s.data[S]=j===-1?255:(t.data[j++]-h[3])*c[3]}else throw new Error("Can not access image data");return s}}),Fk,dZ,hZ,fZ,pZ,mZ,lAe=qt(()=>{L7(),Fk=(t,e)=>{if(t===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:n,width:s}=e,r=e.norm??{mean:255,bias:0},i,a;typeof r.mean=="number"?i=[r.mean,r.mean,r.mean,r.mean]:i=[r.mean[0],r.mean[1],r.mean[2],r.mean[3]??255],typeof r.bias=="number"?a=[r.bias,r.bias,r.bias,r.bias]:a=[r.bias[0],r.bias[1],r.bias[2],r.bias[3]??0];let o=e.format!==void 0?e.format:"RGBA",l=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",c=n*s,h=l==="RGBA"?new Float32Array(c*4):new Float32Array(c*3),p=4,m=0,y=1,v=2,b=3,S=0,E=c,I=c*2,M=-1;o==="RGB"&&(p=3,m=0,y=1,v=2,b=-1),l==="RGBA"?M=c*3:l==="RBG"?(S=0,I=c,E=c*2):l==="BGR"&&(I=0,E=c,S=c*2);for(let j=0;j<c;j++,m+=p,v+=p,y+=p,b+=p)h[S++]=(t[m]+a[0])/i[0],h[E++]=(t[y]+a[1])/i[1],h[I++]=(t[v]+a[2])/i[2],M!==-1&&b!==-1&&(h[M++]=(t[b]+a[3])/i[3]);return l==="RGBA"?new Eu("float32",h,[1,4,n,s]):new Eu("float32",h,[1,3,n,s])},dZ=async(t,e)=>{let n=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,s=typeof ImageData<"u"&&t instanceof ImageData,r=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,i=typeof t=="string",a,o=e??{},l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},c=h=>typeof HTMLCanvasElement<"u"&&h instanceof HTMLCanvasElement||h instanceof OffscreenCanvas?h.getContext("2d"):null;if(n){let h=l();h.width=t.width,h.height=t.height;let p=c(h);if(p!=null){let m=t.height,y=t.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(m=e.resizedHeight,y=e.resizedWidth),e!==void 0){if(o=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");o.tensorFormat="RGBA",o.height=m,o.width=y}else o.tensorFormat="RGBA",o.height=m,o.width=y;p.drawImage(t,0,0),a=p.getImageData(0,0,y,m).data}else throw new Error("Can not access image data")}else if(s){let h,p;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(h=e.resizedHeight,p=e.resizedWidth):(h=t.height,p=t.width),e!==void 0&&(o=e),o.format="RGBA",o.height=h,o.width=p,e!==void 0){let m=l();m.width=p,m.height=h;let y=c(m);if(y!=null)y.putImageData(t,0,0),a=y.getImageData(0,0,p,h).data;else throw new Error("Can not access image data")}else a=t.data}else if(r){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let h=l();h.width=t.width,h.height=t.height;let p=c(h);if(p!=null){let m=t.height,y=t.width;return p.drawImage(t,0,0,y,m),a=p.getImageData(0,0,y,m).data,o.height=m,o.width=y,Fk(a,o)}else throw new Error("Can not access image data")}else{if(i)return new Promise((h,p)=>{let m=l(),y=c(m);if(!t||!y)return p();let v=new Image;v.crossOrigin="Anonymous",v.src=t,v.onload=()=>{m.width=v.width,m.height=v.height,y.drawImage(v,0,0,m.width,m.height);let b=y.getImageData(0,0,m.width,m.height);o.height=m.height,o.width=m.width,h(Fk(b.data,o))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Fk(a,o);throw new Error("Input data provided is not supported - aborted tensor creation")},hZ=(t,e)=>{let{width:n,height:s,download:r,dispose:i}=e,a=[1,s,n,4];return new Eu({location:"texture",type:"float32",texture:t,dims:a,download:r,dispose:i})},fZ=(t,e)=>{let{dataType:n,dims:s,download:r,dispose:i}=e;return new Eu({location:"gpu-buffer",type:n??"float32",gpuBuffer:t,dims:s,download:r,dispose:i})},pZ=(t,e)=>{let{dataType:n,dims:s,download:r,dispose:i}=e;return new Eu({location:"ml-tensor",type:n??"float32",mlTensor:t,dims:s,download:r,dispose:i})},mZ=(t,e,n)=>new Eu({location:"cpu-pinned",type:t,data:e,dims:n??[e.length]})}),Ky,cS,t$,gZ,cAe=qt(()=>{Ky=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),cS=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),t$=!1,gZ=()=>{if(!t$){t$=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,n=globalThis.Float16Array,s=typeof n<"u"&&n.from;t&&(Ky.set("int64",BigInt64Array),cS.set(BigInt64Array,"int64")),e&&(Ky.set("uint64",BigUint64Array),cS.set(BigUint64Array,"uint64")),s?(Ky.set("float16",n),cS.set(n,"float16")):Ky.set("float16",Uint16Array)}}}),yZ,xZ,uAe=qt(()=>{L7(),yZ=t=>{let e=1;for(let n=0;n<t.length;n++){let s=t[n];if(typeof s!="number"||!Number.isSafeInteger(s))throw new TypeError(`dims[${n}] must be an integer, got: ${s}`);if(s<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${s}`);e*=s}return e},xZ=(t,e)=>{switch(t.location){case"cpu":return new Eu(t.type,t.data,e);case"cpu-pinned":return new Eu({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new Eu({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new Eu({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});case"ml-tensor":return new Eu({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),Eu,L7=qt(()=>{oAe(),lAe(),cAe(),uAe(),Eu=class{constructor(t,e,n){gZ();let s,r;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,s=t.type,r=t.dims,t.location){case"cpu-pinned":{let a=Ky.get(s);if(!a)throw new TypeError(`unsupported type "${s}" to create tensor from pinned buffer`);if(!(t.data instanceof a))throw new TypeError(`buffer should be of type ${a.name}`);this.cpuData=t.data;break}case"texture":{if(s!=="float32")throw new TypeError(`unsupported type "${s}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(s!=="float32"&&s!=="float16"&&s!=="int32"&&s!=="int64"&&s!=="uint32"&&s!=="uint8"&&s!=="bool"&&s!=="uint4"&&s!=="int4")throw new TypeError(`unsupported type "${s}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(s!=="float32"&&s!=="float16"&&s!=="int32"&&s!=="int64"&&s!=="uint32"&&s!=="uint64"&&s!=="int8"&&s!=="uint8"&&s!=="bool"&&s!=="uint4"&&s!=="int4")throw new TypeError(`unsupported type "${s}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof t=="string")if(s=t,o=n,t==="string"){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");a=e}else{let l=Ky.get(t);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e)){if(t==="float16"&&l===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${l.name} as data.`);t==="uint64"||t==="int64"?a=l.from(e,BigInt):a=l.from(e)}else if(e instanceof l)a=e;else if(e instanceof Uint8ClampedArray)if(t==="uint8")a=Uint8Array.from(e);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&e instanceof Uint16Array&&l!==Uint16Array)a=new globalThis.Float16Array(e.buffer,e.byteOffset,e.length);else throw new TypeError(`A ${s} tensor's data must be type of ${l}`)}else if(o=e,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof t[0];if(l==="string")s="string",a=t;else if(l==="boolean")s="bool",a=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(t instanceof Uint8ClampedArray)s="uint8",a=Uint8Array.from(t);else{let l=cS.get(t.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);s=l,a=t}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");r=o,this.cpuData=a,this.dataLocation="cpu"}let i=yZ(r);if(this.cpuData&&i!==this.cpuData.length&&!((s==="uint4"||s==="int4")&&Math.ceil(i/2)===this.cpuData.length))throw new Error(`Tensor's size(${i}) does not match data length(${this.cpuData.length}).`);this.type=s,this.dims=r,this.size=i}static async fromImage(t,e){return dZ(t,e)}static fromTexture(t,e){return hZ(t,e)}static fromGpuBuffer(t,e){return fZ(t,e)}static fromMLTensor(t,e){return pZ(t,e)}static fromPinnedBuffer(t,e,n){return mZ(t,e,n)}toDataURL(t){return cZ(this,t)}toImageData(t){return uZ(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,t&&this.disposer&&(this.disposer(),this.disposer=void 0),e}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return xZ(this,t)}}}),Vh,vZ=qt(()=>{L7(),Vh=Eu}),rR,n$,yp,Kh,pv,mv,bZ=qt(()=>{lZ(),rR=(t,e)=>{(typeof vo.trace>"u"?!vo.wasm.trace:!vo.trace)||console.timeStamp(`${t}::ORT::${e}`)},n$=(t,e)=>{var r;let n=((r=new Error().stack)==null?void 0:r.split(/\r\n|\r|\n/g))||[],s=!1;for(let i=0;i<n.length;i++){if(s&&!n[i].includes("TRACE_FUNC")){let a=`FUNC_${t}::${n[i].trim().split(" ")[1]}`;e&&(a+=`::${e}`),rR("CPU",a);return}n[i].includes("TRACE_FUNC")&&(s=!0)}},yp=t=>{(typeof vo.trace>"u"?!vo.wasm.trace:!vo.trace)||n$("BEGIN",t)},Kh=t=>{(typeof vo.trace>"u"?!vo.wasm.trace:!vo.trace)||n$("END",t)},pv=t=>{(typeof vo.trace>"u"?!vo.wasm.trace:!vo.trace)||console.time(`ORT::${t}`)},mv=t=>{(typeof vo.trace>"u"?!vo.wasm.trace:!vo.trace)||console.timeEnd(`ORT::${t}`)}}),wZ,dAe=qt(()=>{aZ(),vZ(),bZ(),wZ=class _Z{constructor(e){this.handler=e}async run(e,n,s){yp(),pv("InferenceSession.run");let r={},i={};if(typeof e!="object"||e===null||e instanceof Vh||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof Vh)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(n)){if(n.length===0)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let c of n){if(typeof c!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(c)===-1)throw new RangeError(`'fetches' contains invali
3841d output name: ${c}.`);r[c]=null}if(typeof s=="object"&&s!==null)i=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else{let c=!1,h=Object.getOwnPropertyNames(n);for(let p of this.outputNames)if(h.indexOf(p)!==-1){let m=n[p];(m===null||m instanceof Vh)&&(c=!0,a=!1,r[p]=m)}if(c){if(typeof s=="object"&&s!==null)i=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else i=n}}else if(typeof n<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let c of this.inputNames)if(typeof e[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(a)for(let c of this.outputNames)r[c]=null;let o=await this.handler.run(e,r,i),l={};for(let c in o)if(Object.hasOwnProperty.call(o,c)){let h=o[c];h instanceof Vh?l[c]=h:l[c]=new Vh(h.type,h.data,h.dims)}return mv("InferenceSession.run"),Kh(),l}async release(){return this.handler.dispose()}static async create(e,n,s,r){yp(),pv("InferenceSession.create");let i,a={};if(typeof e=="string"){if(i=e,typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(i=e,typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let h=e,p=0,m=e.byteLength;if(typeof n=="object"&&n!==null)a=n;else if(typeof n=="number"){if(p=n,!Number.isSafeInteger(p))throw new RangeError("'byteOffset' must be an integer.");if(p<0||p>=h.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${h.byteLength}).`);if(m=e.byteLength-p,typeof s=="number"){if(m=s,!Number.isSafeInteger(m))throw new RangeError("'byteLength' must be an integer.");if(m<=0||p+m>h.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${h.byteLength-p}].`);if(typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");i=new Uint8Array(h,p,m)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[o,l]=await iZ(a),c=await o.createInferenceSessionHandler(i,l);return mv("InferenceSession.create"),Kh(),new _Z(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),iR,hAe=qt(()=>{dAe(),iR=wZ}),fAe=qt(()=>{}),pAe=qt(()=>{}),mAe=qt(()=>{}),gAe=qt(()=>{}),yAe={};i_(yAe,{InferenceSession:()=>iR,TRACE:()=>rR,TRACE_EVENT_BEGIN:()=>pv,TRACE_EVENT_END:()=>mv,TRACE_FUNC_BEGIN:()=>yp,TRACE_FUNC_END:()=>Kh,Tensor:()=>Vh,env:()=>fi,registerBackend:()=>aw});var Ad=qt(()=>{rAe(),aAe(),hAe(),vZ(),fAe(),pAe(),bZ(),mAe(),gAe()}),j7=qt(()=>{}),SZ={};i_(SZ,{default:()=>EZ});var s$,r$,EZ,xAe=qt(()=>{var t;Ine(),Gv(),B7(),s$="ort-wasm-proxy-worker",r$=((t=globalThis.self)==null?void 0:t.name)===s$,r$&&(self.onmessage=e=>{let{type:n,in:s}=e.data;try{switch(n){case"init-wasm":U7(s.wasm).then(()=>{sj(s).then(()=>{postMessage({type:n})},r=>{postMessage({type:n,err:r})})},r=>{postMessage({type:n,err:r})});break;case"init-ep":{let{epName:r,env:i}=s;rj(i,r).then(()=>{postMessage({type:n})},a=>{postMessage({type:n,err:a})});break}case"copy-from":{let{buffer:r}=s,i=hR(r);postMessage({type:n,out:i});break}case"create":{let{model:r,options:i}=s;ij(r,i).then(a=>{postMessage({type:n,out:a})},a=>{postMessage({type:n,err:a})});break}case"release":aj(s),postMessage({type:n});break;case"run":{let{sessionId:r,inputIndices:i,inputs:a,outputIndices:o,options:l}=s;oj(r,i,a,o,new Array(o.length).fill(null),l).then(c=>{c.some(h=>h[3]!=="cpu")?postMessage({type:n,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:n,out:c},cj([...a,...c]))},c=>{postMessage({type:n,err:c})});break}case"end-profiling":lj(s),postMessage({type:n});break;default:}}catch(r){postMessage({type:n,err:r})}}),EZ=r$?null:e=>new Worker(e??lu,{type:"module",name:s$})}),TZ={};i_(TZ,{default:()=>AZ});async function xz(t={}){var Rl,Wd;var e=t,n=!!globalThis.window,s=!!globalThis.WorkerGlobalScope,r=s&&((Rl=self.name)==null?void 0:Rl.startsWith("em-pthread"));e.mountExternalData=(x,A)=>{x.startsWith("./")&&(x=x.substring(2)),(e.Xc||(e.Xc=new Map)).set(x,A)},e.unmountExternalData=()=>{delete e.Xc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let i=x=>async(...A)=>{var $;try{if(e.Yc)throw Error("Session already started");let P=e.Yc={Kd:A[0],errors:[]},z=await x(...A);if(e.Yc!==P)throw Error("Session mismatch");($=e.dd)==null||$.flush();let Q=P.errors;if(0<Q.length){let ee=await Promise.all(Q);if(ee=ee.filter(re=>re),0<ee.length)throw Error(ee.join(`
3842`))}return z}finally{e.Yc=null}};e.jsepInit=(x,A)=>{if(x==="webgpu"){[e.dd,e.Ad,e.Ed,e.ed,e.Dd,e.$b,e.Fd,e.Hd,e.Bd,e.Cd,e.Gd]=A;let $=e.dd;e.jsepRegisterBuffer=(P,z,Q,ee)=>$.registerBuffer(P,z,Q,ee),e.jsepGetBuffer=P=>$.getBuffer(P),e.jsepCreateDownloader=(P,z,Q)=>$.createDownloader(P,z,Q),e.jsepOnCreateSession=P=>{$.onCreateSession(P)},e.jsepOnReleaseSession=P=>{$.onReleaseSession(P)},e.jsepOnRunStart=P=>$.onRunStart(P),e.Id=(P,z)=>{$.upload(P,z)}}else if(x==="webnn"){let $=A[0];
vendor: 3,096 bytes, line 3842
3842[e.Wd,e.sd,e.webnnEnsureTensor,e.td,e.webnnDownloadTensor,e.Rd,e.webnnEnableTraceEvent]=A.slice(1),e.webnnReleaseTensorId=e.sd,e.webnnUploadTensor=e.td,e.webnnRegisterMLContext=e.Rd,e.webnnOnRunStart=P=>$.onRunStart(P),e.webnnOnRunEnd=$.onRunEnd.bind($),e.webnnOnReleaseSession=P=>{$.onReleaseSession(P)},e.webnnCreateMLTensorDownloader=(P,z)=>$.createMLTensorDownloader(P,z),e.webnnRegisterMLTensor=(P,z,Q,ee)=>$.registerMLTensor(P,z,Q,ee),e.webnnCreateMLContext=P=>$.createMLContext(P),e.webnnRegisterMLConstant=(P,z,Q,ee,re,be)=>$.registerMLConstant(P,z,Q,ee,re,e.Xc,be),e.webnnRegisterGraphInput=$.registerGraphInput.bind($),e.webnnIsGraphInput=$.isGraphInput.bind($),e.webnnRegisterGraphOutput=$.registerGraphOutput.bind($),e.webnnIsGraphOutput=$.isGraphOutput.bind($),e.webnnCreateTemporaryTensor=$.createTemporaryTensor.bind($),e.webnnIsGraphInputOutputTypeSupported=$.isGraphInputOutputTypeSupported.bind($)}};let a=()=>{let x=A=>(...$)=>{let P=pn;return $=A(...$),pn!=P?new Promise((z,Q)=>{Kt={resolve:z,reject:Q}}):$};(()=>{for(let A of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])e[A]=x(e[A])})(),i!==void 0&&(e._OrtRun=i(e._OrtRun),e._OrtRunWithBinding=i(e._OrtRunWithBinding)),a=void 0};e.asyncInit=()=>{a==null||a()};var o,l,c=(x,A)=>{throw A},h=import.meta.url,p="";if(n||s){try{p=new URL(".",h).href}catch{}s&&(l=x=>{var A=new XMLHttpRequest;return A.open("GET",x,!1),A.responseType="arraybuffer",A.send(null),new Uint8Array(A.response)}),o=async x=>{if(D(x))return new Promise(($,P)=>{var z=new XMLHttpRequest;z.open("GET",x,!0),z.responseType="arraybuffer",z.onload=()=>{z.status==200||z.status==0&&z.response?$(z.response):P(z.status)},z.onerror=P,z.send(null)});var A=await fetch(x,{credentials:"same-origin"});if(A.ok)return A.arrayBuffer();throw Error(A.status+" : "+A.url)}}var m,y,v,b,S,E,I=console.log.bind(console),M=console.error.bind(console),j=I,L=M,K=!1,D=x=>x.startsWith("file://");function R(){Oe.buffer!=G.buffer&&de()}if(r){let x=function(A){try{var $=A.data,P=$.Sc;if(P==="load"){let z=[];self.onmessage=Q=>z.push(Q),E=()=>{postMessage({Sc:"loaded"});for(let Q of z)x(Q);self.onmessage=x};for(let Q of $.xd)e[Q]&&!e[Q].proxy||(e[Q]=(...ee)=>{postMessage({Sc:"callHandler",wd:Q,args:ee})},Q=="print"&&(j=e[Q]),Q=="printErr"&&(L=e[Q]));Oe=$.Od,de(),y=$.Pd,gt(),ui()}else if(P==="run"){(function(z){var Q=(R(),we)[z+52>>>2>>>0];z=(R(),we)[z+56>>>2>>>0],Jo(Q,Q-z),es(Q)})($.Rc),cc($.Rc,0,0,1,0,0),ft(),Gs($.Rc),B||(Lu(),B=!0);try{hn($.Md,$.bd)}catch(z){if(z!="unwind")throw z}}else $.target!=="setimmediate"&&(P==="checkMailbox"?B&&Cr():P&&(L(`worker: received unknown command ${P}`),L($)))}catch(z){throw fo(),z}};var B=!1;self.onunhandledrejection=A=>{throw A.reason||A},self.onmessage=x}var G,X,H,Y,F,we,me,xe,Le,ve,ce,ie=!1;function de(){var x=Oe.buffer;e.HEAP8=G=new Int8Array(x),H=new Int16Array(x),e.HEAPU8=X=new Uint8Array(x),Y=new Uint16Array(x),e.HEAP32=F=new Int32Array(x),e.HEAPU32=we=new Uint32Array(x),me=new Float32Array(x),xe=new Float64Array(x),Le=new BigInt64Array(x),ve=new BigUint64Array(x)}
vendor: 4,136 bytes, line 3842
3842function Re(){ie=!0,r?E():Fr.sb()}function Se(x){throw L(x="Aborted("+x+")"),K=!0,x=new WebAssembly.RuntimeError(x+". Build with -sASSERTIONS for more info."),S==null||S(x),x}function De(){return{a:{ma:nl,gb:Ca,g:tn,J:Ue,f:Lt,o:Wt,h:fn,ha:Jt,b:Kn,T:nn,Ha:ln,n:ns,$:ps,Xa:ms,Da:Me,Fa:lt,Ya:jt,Va:Qt,Oa:Sn,Ua:yn,ka:Ft,Ea:sn,Ba:rn,Wa:bs,Ca:gs,bb:us,ea:ys,wa:Pn,ua:er,da:or,O:ue,H:ke,va:$e,_:qn,xa:Xn,Ra:an,za:Qs,Ia:gi,sa:yr,fa:_a,Qa:Gs,_a:Va,R:Ds,r:Yi,c:ar,hb:Ga,y:wl,M:sa,D:ra,l:Bi,s:_l,ib:Pu,I:Uc,S:ic,j:Cd,u:ci,q:xr,k:gn,La:Sa,Ma:Ha,Na:kd,Ja:Fc,Ka:Id,ta:ac,db:Sl,ab:C,v:ye,aa:Xe,ga:rt,$a:Io,W:Vt,Za:Zn,Aa:dr,F:qr,U:lr,la:fa,ya:pa,fb:No,eb:$u,Sa:ho,Ta:Vc,Ga:ge,V:Ou,ja:Nd,Pa:Rd,ia:lc,kb:bi,na:Ia,lb:Nl,oa:mo,G:Sp,d:uf,t:qc,w:Ud,A:pc,mb:ff,K:hf,x:Vd,pa:Ep,Y:yc,ba:Vu,nb:Mo,ob:Wm,P:df,qa:gc,pb:qd,N:Gd,Z:Km,e:bp,B:Fd,m:Wc,jb:zu,p:wp,z:_p,C:zd,E:po,L:kl,qb:Hd,Q:Tp,ca:mc,X:Il,rb:Fu,ra:ka,i:Md,a:Oe,cb:We}}}async function gt(){function x(P,z){var Q=Fr=P.exports;P={};for(let[ee,re]of Object.entries(Q))typeof re=="function"?(Q=li(re),P[ee]=Q):P[ee]=re;return Fr=P,Fr=(function(){var ee=Fr,re=Ee=>Te=>Ee(Te)>>>0,be=Ee=>()=>Ee()>>>0;return(ee=Object.assign({},ee)).tb=re(ee.tb),ee.Xb=be(ee.Xb),ee.Zb=re(ee.Zb),ee.lc=re(ee.lc),ee.mc=be(ee.mc),ee.qc=re(ee.qc),ee})(),et.push(Fr._b),El=(P=Fr).tb,Lu=P.ub,e._OrtInit=P.vb,e._OrtGetLastError=P.wb,e._OrtCreateSessionOptions=P.xb,e._OrtAppendExecutionProvider=P.yb,e._OrtAddFreeDimensionOverride=P.zb,e._OrtAddSessionConfigEntry=P.Ab,e._OrtReleaseSessionOptions=P.Bb,e._OrtCreateSession=P.Cb,e._OrtReleaseSession=P.Db,e._OrtGetInputOutputCount=P.Eb,e._OrtGetInputOutputMetadata=P.Fb,e._OrtFree=P.Gb,e._OrtCreateTensor=P.Hb,e._OrtGetTensorData=P.Ib,e._OrtReleaseTensor=P.Jb,e._OrtCreateRunOptions=P.Kb,e._OrtAddRunConfigEntry=P.Lb,e._OrtReleaseRunOptions=P.Mb,e._OrtCreateBinding=P.Nb,e._OrtBindInput=P.Ob,e._OrtBindOutput=P.Pb,e._OrtClearBoundOutputs=P.Qb,e._OrtReleaseBinding=P.Rb,e._OrtRunWithBinding=P.Sb,e._OrtRun=P.Tb,e._OrtEndProfiling=P.Ub,e._JsepOutput=P.Vb,e._JsepGetNodeName=P.Wb,Ir=P.Xb,Wa=e._free=P.Yb,Pd=e._malloc=P.Zb,cc=P.ac,fo=P.bc,$d=P.cc,vp=P.dc,oa=P.ec,Wr=P.fc,Tl=P.gc,_s=P.hc,Ea=P.ic,Jo=P.jc,es=P.kc,Ta=P.lc,hs=P.mc,Ci=P.nc,$r=P.oc,Aa=P.pc,uc=P.qc,zc=P.rc,Al=P.sc,Qo=P.tc,dc=P.uc,Dd=P.vc,la=P.wc,Zo=P.xc,ju=P.yc,tf=P.zc,nf=P.Ac,Gc=P.Bc,qm=P.Cc,sf=P.Dc,rf=P.Ec,xi=P.Fc,ma=P.Gc,Ui=P.Hc,el=P.Ic,Bu=P.Jc,Uu=P.Kc,tl=P.Lc,Hc=P.Mc,vi=P.Nc,Od=P.Pc,Ld=P.Qc,hc=P.$c,af=P.ad,Ka=P.fd,Ya=P.jd,fc=P.kd,jd=P.ld,Bd=P.md,ki=P.nd,Xa=P.od,Cl=P.pd,Xi=P.qd,Ro=P.vd,Fi=P.Sd,of=P.Td,lf=P.Ud,cf=P.Vd,y=z,Fr}var A,$=De();return e.instantiateWasm?new Promise(P=>{e.instantiateWasm($,(z,Q)=>{P(x(z,Q))})}):r?x(new WebAssembly.Instance(y,De()),y):(ce??(ce=e.locateFile?e.locateFile?e.locateFile("ort-wasm-simd-threaded.jsep.wasm",p):p+"ort-wasm-simd-threaded.jsep.wasm":new URL("/assets/ort-wasm-simd-threaded.jsep-CyqnNavA.wasm",import.meta.url).href),A=await(async function(P){var z=ce;if(!m&&!D(z))try{var Q=fetch(z,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(Q,P)}catch(ee){L(`wasm streaming compile failed: ${ee}`),L("falling back to ArrayBuffer instantiation")}return(async function(ee,re){try{var be=await(async function(Ee){if(!m)try{var Te=await o(Ee);return new Uint8Array(Te)}catch{}if(Ee==ce&&m)Ee=new Uint8Array(m);else{if(!l)throw"both async and sync fetching of the wasm failed";Ee=l(Ee)}return Ee})(ee);return await WebAssembly.instantiate(be,re)}catch(Ee){L(`failed to asynchronously prepare wasm: ${Ee}`),Se(Ee)}})(z,P)})($),x(A.instance,A.module))}class yt{constructor(A){os(this,"name","ExitStatus");this.message=`Program terminated with exit(${A})`,this.status=A}}var xt=x=>{x.terminate(),x.onmessage=()=>{}},Nt=[],wt=0,zt=null,_n=x=>{he.length==0&&(pt(),Mt(he[0]));var A=he.pop();if(!A)return 6;Ae.push(A),nt[x.Rc]=A,A.Rc=x.Rc;var $={Sc:"run",Md:x.Ld,bd:x.bd,Rc:x.Rc};return A.postMessage($,x.rd),0},Zt=0,J=(x,A,...$)=>{var P,z=16*$.length,Q=hs(),ee=Ta(z),re=ee>>>3;for(P of $)typeof P=="bigint"?((R(),Le)[re++>>>0]=1n,(R(),Le)[re++>>>0]=P):((R(),Le)[re++>>>0]=0n,(R(),xe)[re++>>>0]=P);return x=$d(x,0,z,ee,A),es(Q),x};function We(x){if(r)return J(0,1,x);
vendor: 36,347 bytes, lines 3842-3846
3842if(v=x,!(0<Zt)){for(var A of Ae)xt(A);for(A of he)xt(A);he=[],Ae=[],nt={},K=!0}c(0,new yt(x))}function Ie(x){if(r)return J(1,0,x);ge(x)}var ge=x=>{if(v=x,r)throw Ie(x),"unwind";We(x)},he=[],Ae=[],et=[],nt={},He=x=>{var A=x.Rc;delete nt[A],he.push(x),Ae.splice(Ae.indexOf(x),1),x.Rc=0,vp(A)};function ft(){et.forEach(x=>x())}var Mt=x=>new Promise(A=>{x.onmessage=z=>{var Q=z.data;if(z=Q.Sc,Q.Zc&&Q.Zc!=Ir()){var ee=nt[Q.Zc];ee?ee.postMessage(Q,Q.rd):L(`Internal error! Worker sent a message "${z}" to target pthread ${Q.Zc}, but that thread no longer exists!`)}else z==="checkMailbox"?Cr():z==="spawnThread"?_n(Q):z==="cleanupThread"?Jn(()=>{He(nt[Q.Nd])}):z==="loaded"?(x.loaded=!0,A(x)):Q.target==="setimmediate"?x.postMessage(Q):z==="uncaughtException"?x.onerror(Q.error):z==="callHandler"?e[Q.wd](...Q.args):z&&L(`worker sent an unknown command ${z}`)},x.onerror=z=>{throw L(`worker sent an error! ${z.filename}:${z.lineno}: ${z.message}`),z};var $,P=[];for($ of[])e.propertyIsEnumerable($)&&P.push($);x.postMessage({Sc:"load",xd:P,Od:Oe,Pd:y})});function pt(){var x=new Worker((()=>{let A=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new A("ort.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});he.push(x)}var Oe,hn=(x,A)=>{Zt=0,x=Al(x,A),0<Zt?v=x:oa(x)},Yt=[],Qe=0;function tn(x){var A=new Dt(x>>>=0);return(R(),G)[A.Tc+12>>>0]==0&&(bt(A,!0),Qe--),ht(A,!1),Yt.push(A),uc(x)}var je=0,Ue=()=>{_s(0,0);var x=Yt.pop();Ci(x.cd),je=0};function bt(x,A){A=A?1:0,(R(),G)[x.Tc+12>>>0]=A}function ht(x,A){A=A?1:0,(R(),G)[x.Tc+13>>>0]=A}class Dt{constructor(A){this.cd=A,this.Tc=A-24}}var Ut=x=>{var A=je;if(!A)return Ea(0),0;var $=new Dt(A);(R(),we)[$.Tc+16>>>2>>>0]=A;var P=(R(),we)[$.Tc+4>>>2>>>0];if(!P)return Ea(0),A;for(var z of x){if(z===0||z===P)break;if(Aa(z,P,$.Tc+16))return Ea(z),A}return Ea(P),A};function Lt(){return Ut([])}function Wt(x){return Ut([x>>>0])}function fn(x,A,$,P){return Ut([x>>>0,A>>>0,$>>>0,P>>>0])}var Jt=()=>{var x=Yt.pop();x||Se("no exception to throw");var A=x.cd;throw(R(),G)[x.Tc+13>>>0]==0&&(Yt.push(x),ht(x,!0),bt(x,!1),Qe++),$r(A),je=A};function Kn(x,A,$){var P=new Dt(x>>>=0);throw A>>>=0,$>>>=0,(R(),we)[P.Tc+16>>>2>>>0]=0,(R(),we)[P.Tc+4>>>2>>>0]=A,(R(),we)[P.Tc+8>>>2>>>0]=$,$r(x),Qe++,je=x}var nn=()=>Qe;function Wn(x,A,$,P){return r?J(2,1,x,A,$,P):ln(x,A,$,P)}function ln(x,A,$,P){if(x>>>=0,A>>>=0,$>>>=0,P>>>=0,!globalThis.SharedArrayBuffer)return 6;var z=[];return r&&z.length===0?Wn(x,A,$,P):(x={Ld:$,Rc:x,bd:P,rd:z},r?(x.Sc="spawnThread",postMessage(x,z),0):_n(x))}function ns(x){throw je||(je=x>>>0),je}var Js=globalThis.TextDecoder&&new TextDecoder,ur=(x,A,$,P)=>{if($=A+$,P)return $;for(;x[A]&&!(A>=$);)++A;return A},zs=(x,A=0,$,P)=>{if(16<($=ur(x,A>>>=0,$,P))-A&&x.buffer&&Js)return Js.decode(x.buffer instanceof ArrayBuffer?x.subarray(A,$):x.slice(A,$));for(P="";A<$;){var z=x[A++];if(128&z){var Q=63&x[A++];if((224&z)==192)P+=String.fromCharCode((31&z)<<6|Q);else{var ee=63&x[A++];65536>(z=(240&z)==224?(15&z)<<12|Q<<6|ee:(7&z)<<18|Q<<12|ee<<6|63&x[A++])?P+=String.fromCharCode(z):(z-=65536,P+=String.fromCharCode(55296|z>>10,56320|1023&z))}}else P+=String.fromCharCode(z)}return P},fs=(x,A,$)=>(x>>>=0)?zs((R(),X),x,A,$):"";function ps(x,A,$){return r?J(3,1,x,A,$):0}function ms(x,A){if(r)return J(4,1,x,A)}function Me(x,A){if(r)return J(5,1,x,A)}function lt(x,A,$){if(r)return J(6,1,x,A,$)}function jt(x,A,$){return r?J(7,1,x,A,$):0}function Qt(x,A){if(r)return J(8,1,x,A)}function Sn(x,A,$){if(r)return J(9,1,x,A,$)}function yn(x,A,$,P){if(r)return J(10,1,x,A,$,P)}function Ft(x,A,$,P){if(r)return J(11,1,x,A,$,P)}function sn(x,A,$,P){if(r)return J(12,1,x,A,$,P)}function rn(x){if(r)return J(13,1,x)}function bs(x,A){if(r)return J(14,1,x,A)}function gs(x,A,$){if(r)return J(15,1,x,A,$)}var us=()=>Se(""),Hn=x=>{x>>>=0;for(var A="";;){var $=(R(),X)[x++>>>0];if(!$)return A;A+=String.fromCharCode($)}},ls={},Ps={},rr=class extends Error{constructor(x){super(x),this.name="BindingError"}};function ws(x,A,$={}){return(function(P,z,Q={}){var ee=z.name;if(!P)throw new rr(`type "${ee}" must have a positive integer typeid pointer`);if(Ps.hasOwnProperty(P)){if(Q.yd)return;throw new rr(`Cannot register type '${ee}' twice`)}Ps[P]=z,ls.hasOwnProperty(P)&&(z=ls[P],delete ls[P],z.forEach(re=>re()))})(x,A,$)}var $s=(x,A,$)=>{switch(A){case 1:return $?P=>(R(),G)[P>>>0]:P=>(R(),X)[P>>>0];case 2:return $?P=>(R(),H)[P>>>1>>>0]:P=>(R(),Y)[P>>>1>>>0];case 4:return $?P=>(R(),F)[P>>>2>>>0]:P=>(R(),we)[P>>>2>>>0];case 8:return $?P=>(R(),Le)[P>>>3>>>0]:P=>(R(),ve)[P>>>3>>>0];default:throw new TypeError(`invalid integer width (${A}): ${x}`)}};function ys(x,A,$,P,z){x>>>=0,$>>>=0,A=Hn(A>>>0);let Q=ee=>ee;if(P=P===0n){let ee=8*$;Q=re=>BigInt.asUintN(ee,re),z=Q(z)}ws(x,{name:A,Oc:Q,Vc:(ee,re)=>(typeof re=="number"&&(re=BigInt(re)),re),Uc:$s(A,$,!P),Wc:null})}function Pn(x,A,$,P){ws(x>>>=0,{name:A=Hn(A>>>0),Oc:function(z){return!!z},Vc:function(z,Q){return Q?$:P},Uc:function(z){return this.Oc((R(),X)[z>>>0])},Wc:null})}var ir=[],ot=[0,1,,1,null,1,!0,1,!1,1];function ar(x){9<(x>>>=0)&&--ot[x+1]==0&&(ot[x]=void 0,ir.push(x))}var $n=x=>{if(!x)throw new rr(`Cannot use deleted val. handle = ${x}`);return ot[x]},kn=x=>{switch(x){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let A=ir.pop()||ot.length;return ot[A]=x,ot[A+1]=1,A}};function Nn(x){return this.Oc((R(),we)[x>>>2>>>0])}var Bn={name:"emscripten::val",Oc:x=>{var A=$n(x);return ar(x),A},Vc:(x,A)=>kn(A),Uc:Nn,Wc:null};function er(x){return ws(x>>>0,Bn)}var oi=(x,A)=>{switch(A){case 4:return function($){return this.Oc((R(),me)[$>>>2>>>0])};case 8:return function($){return this.Oc((R(),xe)[$>>>3>>>0])};default:throw new TypeError(`invalid float width (${A}): ${x}`)}};function or(x,A,$){$>>>=0,ws(x>>>=0,{name:A=Hn(A>>>0),Oc:P=>P,Vc:(P,z)=>z,Uc:oi(A,$),Wc:null})}function ue(x,A,$,P,z){x>>>=0,$>>>=0,A=Hn(A>>>0);let Q=re=>re;if(P===0){var ee=32-8*$;Q=re=>re<<ee>>>ee,z=Q(z)}ws(x,{name:A,Oc:Q,Vc:(re,be)=>be,Uc:$s(A,$,P!==0),Wc:null})}function ke(x,A,$){function P(Q){var ee=(R(),we)[Q>>>2>>>0];return Q=(R(),we)[Q+4>>>2>>>0],new z((R(),G).buffer,Q,ee)}var z=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][A];ws(x>>>=0,{name:$=Hn($>>>0),Oc:P,Uc:P},{yd:!0})}var pe=(x,A,$)=>{var P=(R(),X);if(A>>>=0,0<$){var z=A;$=A+$-1;for(var Q=0;Q<x.length;++Q){var ee=x.codePointAt(Q);if(127>=ee){if(A>=$)break;P[A++>>>0]=ee}else if(2047>=ee){if(A+1>=$)break;P[A++>>>0]=192|ee>>6,P[A++>>>0]=128|63&ee}else if(65535>=ee){if(A+2>=$)break;P[A++>>>0]=224|ee>>12,P[A++>>>0]=128|ee>>6&63,P[A++>>>0]=128|63&ee}else{if(A+3>=$)break;P[A++>>>0]=240|ee>>18,P[A++>>>0]=128|ee>>12&63,P[A++>>>0]=128|ee>>6&63,P[A++>>>0]=128|63&ee,Q++}}P[A>>>0]=0,x=A-z}else x=0;return x},Pe=x=>{for(var A=0,$=0;$<x.length;++$){var P=x.charCodeAt($);127>=P?A++:2047>=P?A+=2:55296<=P&&57343>=P?(A+=4,++$):A+=3}return A};function $e(x,A){ws(x>>>=0,{name:A=Hn(A>>>0),Oc($){var P=(R(),we)[$>>>2>>>0];return P=fs($+4,P,!0),Wa($),P},Vc($,P){P instanceof ArrayBuffer&&(P=new Uint8Array(P));var z=typeof P=="string";if(!(z||ArrayBuffer.isView(P)&&P.BYTES_PER_ELEMENT==1))throw new rr("Cannot pass non-string to std::string");var Q=z?Pe(P):P.length,ee=Pd(4+Q+1),re=ee+4;return(R(),we)[ee>>>2>>>0]=Q,z?pe(P,re,Q+1):(R(),X).set(P,re>>>0),$!==null&&$.push(Wa,ee),ee},Uc:Nn,Wc($){Wa($)}})}var Ne=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,tt=(x,A,$)=>{if(x>>>=1,16<(A=ur((R(),Y),x,A/2,$))-x&&Ne)return Ne.decode((R(),Y).slice(x,A));for($="";x<A;++x){var P=(R(),Y)[x>>>0];$+=String.fromCharCode(P)}return $},mt=(x,A,$)=>{if($??($=2147483647),2>$)return 0;var P=A;$=($-=2)<2*x.length?$/2:x.length;for(var z=0;z<$;++z){var Q=x.charCodeAt(z);(R(),H)[A>>>1>>>0]=Q,A+=2}return(R(),H)[A>>>1>>>0]=0,A-P},Ct=x=>2*x.length,_t=(x,A,$)=>{var P="";x>>>=2;for(var z=0;!(z>=A/4);z++){var Q=(R(),we)[x+z>>>0];if(!Q&&!$)break;P+=String.fromCodePoint(Q)}return P},kt=(x,A,$)=>{if(A>>>=0,$??($=2147483647),4>$)return 0;var P=A;$=P+$-4;for(var z=0;z<x.length;++z){var Q=x.codePointAt(z);if(65535<Q&&z++,(R(),F)[A>>>2>>>0]=Q,(A+=4)+4>$)break}return(R(),F)[A>>>2>>>0]=0,A-P},Xt=x=>{for(var A=0,$=0;$<x.length;++$)65535<x.codePointAt($)&&$++,A+=4;return A};function qn(x,A,$){if(x>>>=0,A>>>=0,$=Hn($>>>=0),A===2)var P=tt,z=mt,Q=Ct;else P=_t,z=kt,Q=Xt;ws(x,{name:$,Oc:ee=>{var re=(R(),we)[ee>>>2>>>0];return re=P(ee+4,re*A,!0),Wa(ee),re},Vc:(ee,re)=>{if(typeof re!="string")throw new rr(`Cannot pass non-string to C++ string type ${$}`);var be=Q(re),Ee=Pd(4+be+A);return(R(),we)[Ee>>>2>>>0]=be/A,z(re,Ee+4,be+A),ee!==null&&ee.push(Wa,Ee),Ee},Uc:Nn,Wc(ee){Wa(ee)}})}function Xn(x,A){ws(x>>>=0,{zd:!0,name:A=Hn(A>>>0),Oc:()=>{},Vc:()=>{}})}function an(x){cc(x>>>0,!s,1,!n,131072,!1),ft()}var Jn=x=>{if(!K)try{if(x(),!(0<Zt))try{r?Ir()&&oa(v):ge(v)}catch(A){A instanceof yt||A=="unwind"||c(0,A)}}catch(A){A instanceof yt||A=="unwind"||c(0,A)}},Qn=!Atomics.waitAsync||((Wd=globalThis.navigator)==null?void 0:Wd.userAgent)&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Gs(x){x>>>=0,Qn||(Atomics.waitAsync((R(),F),x>>>2,x).value.then(Cr),x+=128,Atomics.store((R(),F),x>>>2,1))}var Cr=()=>Jn(()=>{var x=Ir();x&&(Gs(x),Tl())});function Qs(x,A){(x>>>=0)==A>>>0?setTimeout(Cr):r?postMessage({Zc:x,Sc:"checkMailbox"}):(x=nt[x])&&x.postMessage({Sc:"checkMailbox"})}var ti=[];function gi(x,A,$,P,z){for(A>>>=0,z>>>=0,ti.length=0,$=z>>>3,P=z+P>>>3;$<P;){var Q;Q=(R(),Le)[$++>>>0]?(R(),Le)[$++>>>0]:(R(),xe)[$++>>>0],ti.push(Q)}return(A?Bs[A]:Kr[x])(...ti)}var yr=()=>{Zt=0};function _a(x){x>>>=0,r?postMessage({Sc:"cleanupThread",Nd:x}):He(nt[x])}function Va(x){}var Ls=x=>{try{x()}catch(A){Se(A)}};function li(x){var A=(...$)=>{za.push(x);try{return x(...$)}finally{K||(za.pop(),pn&&ni===1&&za.length===0&&(ni=0,Zt+=1,Ls(of),typeof Fibers<"u"&&Fibers.Zd()))}};return vt.set(x,A),A}var ni=0,pn=null,ji=0,za=[],Ai=new Map,Ye=new Map,vt=new Map,ct=0,Kt=null,ds=[],Mr=x=>(function(A){if(!K){if(ni===0){var $=!1,P=!1;A((z=0)=>{if(!K&&(ji=z,$=!0,P)){ni=2,Ls(()=>lf(pn)),typeof MainLoop<"u"&&MainLoop.ud&&MainLoop.resume(),z=!1;try{var Q=(function(){var be=(R(),F)[pn+8>>>2>>>0];return be=Ye.get(be),be=vt.get(be),--Zt,be()})()}catch(be){Q=be,z=!0}var ee=!1;if(!pn){var re=Kt;re&&(Kt=null,(z?re.reject:re.resolve)(Q),ee=!0)}if(z&&!ee)throw Q}}),P=!0,$||(ni=1,pn=(function(){var z=Pd(65548),Q=z+12;if((R(),we)[z>>>2>>>0]=Q,(R(),we)[z+4>>>2>>>0]=Q+65536,Q=za[0],!Ai.has(Q)){var ee=ct++;Ai.set(Q,ee),Ye.set(ee,Q)}return Q=Ai.get(Q),(R(),F)[z+8>>>2>>>0]=Q,z})(),typeof MainLoop<"u"&&MainLoop.ud&&MainLoop.pause(),Ls(()=>Fi(pn)))}else ni===2?(ni=0,Ls(cf),Wa(pn),pn=null,ds.forEach(Jn)):Se(`invalid state: ${ni}`);return ji}})(A=>{x().then(A)});function Ds(x){return x>>>=0,Mr(async()=>{var A=await $n(x);return kn(A)})}var Hs=[],un=x=>{var A=Hs.length;return Hs.push(x),A},Yn=(x,A)=>{for(var $=Array(x),P=0;P<x;++P){var z=P,Q=(R(),we)[A+4*P>>>2>>>0],ee=Ps[Q];if(ee===void 0)throw x=`parameter ${P}`,Q=El(Q),A=Hn(Q),Wa(Q),new rr(`${x} has unknown type ${A}`);$[z]=ee}return $},As=(x,A,$)=>{var P=[];return x=x(P,$),P.length&&((R(),we)[A>>>2>>>0]=kn(P)),x},Pr={},kr=x=>{var A=Pr[x];return A===void 0?Hn(x):A};function Yi(x,A,$){var[P,...z]=Yn(x,A>>>0);A=P.Vc.bind(P);var Q=z.map(be=>be.Uc.bind(be));x--;var ee={toValue:$n};switch(x=Q.map((be,Ee)=>{var Te=`argFromPtr${Ee}`;return ee[Te]=be,`${Te}(args${Ee?"+"+8*Ee:""})`}),$){case 0:var re="toValue(handle)";break;case 2:re="new (toValue(handle))";break;case 3:re="";break;case 1:ee.getStringOrSymbol=kr,re="toValue(handle)[getStringOrSymbol(methodName)]"}return re+=`(${x})`,P.zd||(ee.toReturnWire=A,ee.emval_returnValue=As,re=`return emval_returnValue(toReturnWire, destructorsRef, ${re})`),re=`return function (handle, methodName, destructorsRef, args) {
3843  ${re}
3844  }`,$=new Function(Object.keys(ee),re)(...Object.values(ee)),re=`methodCaller<(${z.map(be=>be.name)}) => ${P.name}>`,un(Object.defineProperty($,"name",{value:re}))}function Ga(x,A){return A>>>=0,(x=$n(x>>>0))==$n(A)}function wl(x){return(x>>>=0)?(x=kr(x),kn(globalThis[x])):kn(globalThis)}function sa(x){return x=kr(x>>>0),kn(e[x])}function ra(x,A){return A>>>=0,x=$n(x>>>0),A=$n(A),kn(x[A])}function Bi(x){9<(x>>>=0)&&(ot[x+1]+=1)}function _l(x,A,$,P,z){return Hs[x>>>0](A>>>0,$>>>0,P>>>0,z>>>0)}function Pu(x,A,$,P,z){return _l(x>>>0,A>>>0,$>>>0,P>>>0,z>>>0)}function Uc(){return kn([])}function ic(x){x=$n(x>>>0);for(var A=Array(x.length),$=0;$<x.length;$++)A[$]=x[$];return kn(A)}function Cd(x){return kn(kr(x>>>0))}function ci(){return kn({})}function xr(x){for(var A=$n(x>>>=0);A.length;){var $=A.pop();A.pop()($)}ar(x)}function gn(x,A,$){A>>>=0,$>>>=0,x=$n(x>>>0),A=$n(A),$=$n($),x[A]=$}function Sa(x,A){x=-9007199254740992>x||9007199254740992<x?NaN:Number(x),A>>>=0,x=new Date(1e3*x),(R(),F)[A>>>2>>>0]=x.getUTCSeconds(),(R(),F)[A+4>>>2>>>0]=x.getUTCMinutes(),(R(),F)[A+8>>>2>>>0]=x.getUTCHours(),(R(),F)[A+12>>>2>>>0]=x.getUTCDate(),(R(),F)[A+16>>>2>>>0]=x.getUTCMonth(),(R(),F)[A+20>>>2>>>0]=x.getUTCFullYear()-1900,(R(),F)[A+24>>>2>>>0]=x.getUTCDay(),x=(x.getTime()-Date.UTC(x.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(R(),F)[A+28>>>2>>>0]=x}var yi=x=>x%4==0&&(x%100!=0||x%400==0),uo=[0,31,60,91,121,152,182,213,244,274,305,335],Xo=[0,31,59,90,120,151,181,212,243,273,304,334];function Ha(x,A){x=-9007199254740992>x||9007199254740992<x?NaN:Number(x),A>>>=0,x=new Date(1e3*x),(R(),F)[A>>>2>>>0]=x.getSeconds(),(R(),F)[A+4>>>2>>>0]=x.getMinutes(),(R(),F)[A+8>>>2>>>0]=x.getHours(),(R(),F)[A+12>>>2>>>0]=x.getDate(),(R(),F)[A+16>>>2>>>0]=x.getMonth(),(R(),F)[A+20>>>2>>>0]=x.getFullYear()-1900,(R(),F)[A+24>>>2>>>0]=x.getDay();var $=(yi(x.getFullYear())?uo:Xo)[x.getMonth()]+x.getDate()-1|0;(R(),F)[A+28>>>2>>>0]=$,(R(),F)[A+36>>>2>>>0]=-60*x.getTimezoneOffset(),$=new Date(x.getFullYear(),6,1).getTimezoneOffset();var P=new Date(x.getFullYear(),0,1).getTimezoneOffset();x=0|($!=P&&x.getTimezoneOffset()==Math.min(P,$)),(R(),F)[A+32>>>2>>>0]=x}function kd(x){x>>>=0;var A=new Date((R(),F)[x+20>>>2>>>0]+1900,(R(),F)[x+16>>>2>>>0],(R(),F)[x+12>>>2>>>0],(R(),F)[x+8>>>2>>>0],(R(),F)[x+4>>>2>>>0],(R(),F)[x>>>2>>>0],0),$=(R(),F)[x+32>>>2>>>0],P=A.getTimezoneOffset(),z=new Date(A.getFullYear(),6,1).getTimezoneOffset(),Q=new Date(A.getFullYear(),0,1).getTimezoneOffset(),ee=Math.min(Q,z);return 0>$?(R(),F)[x+32>>>2>>>0]=+(z!=Q&&ee==P):0<$!=(ee==P)&&(z=Math.max(Q,z),A.setTime(A.getTime()+6e4*((0<$?ee:z)-P))),(R(),F)[x+24>>>2>>>0]=A.getDay(),$=(yi(A.getFullYear())?uo:Xo)[A.getMonth()]+A.getDate()-1|0,(R(),F)[x+28>>>2>>>0]=$,(R(),F)[x>>>2>>>0]=A.getSeconds(),(R(),F)[x+4>>>2>>>0]=A.getMinutes(),(R(),F)[x+8>>>2>>>0]=A.getHours(),(R(),F)[x+12>>>2>>>0]=A.getDate(),(R(),F)[x+16>>>2>>>0]=A.getMonth(),(R(),F)[x+20>>>2>>>0]=A.getYear(),x=A.getTime(),BigInt(isNaN(x)?-1:x/1e3)}function Fc(x,A,$,P,z,Q,ee){return r?J(16,1,x,A,$,P,z,Q,ee):-52}function Id(x,A,$,P,z,Q){if(r)return J(17,1,x,A,$,P,z,Q)}var ia={},qr=()=>performance.timeOrigin+performance.now();function ac(x,A){if(r)return J(18,1,x,A);if(ia[x]&&(clearTimeout(ia[x].id),delete ia[x]),!A)return 0;var $=setTimeout(()=>{delete ia[x],Jn(()=>Wr(x,performance.timeOrigin+performance.now()))},A);return ia[x]={id:$,Yd:A},0}function Sl(x,A,$,P){x>>>=0,A>>>=0,$>>>=0,P>>>=0;var z=new Date().getFullYear(),Q=new Date(z,0,1).getTimezoneOffset();z=new Date(z,6,1).getTimezoneOffset();var ee=Math.max(Q,z);(R(),we)[x>>>2>>>0]=60*ee,(R(),F)[A>>>2>>>0]=+(Q!=z),x=(A=re=>{var be=Math.abs(re);return`UTC${0<=re?"-":"+"}${String(Math.floor(be/60)).padStart(2,"0")}${String(be%60).padStart(2,"0")}`})(Q),A=A(z),z<Q?(pe(x,$,17),pe(A,P,17)):(pe(x,P,17),pe(A,$,17))}var Io=()=>Date.now();function C(x,A,$){return $>>>=0,0<=x&&3>=x?(x===0?x=Date.now():x=performance.timeOrigin+performance.now(),x=Math.round(1e6*x),(R(),Le)[$>>>3>>>0]=BigInt(x),0):28}var W=[],ne=(x,A)=>{W.length=0;for(var $;$=(R(),X)[x++>>>0];){var P=$!=105;A+=(P&=$!=112)&&A%8?4:0,W.push($==112?(R(),we)[A>>>2>>>0]:$==106?(R(),Le)[A>>>3>>>0]:$==105?(R(),F)[A>>>2>>>0]:(R(),xe)[A>>>3>>>0]),A+=P?8:4}return W};function ye(x,A,$){return x>>>=0,A=ne(A>>>0,$>>>0),Bs[x](...A)}function Xe(x,A,$){return x>>>=0,A=ne(A>>>0,$>>>0),Bs[x](...A)}var rt=()=>{};function Vt(x,A){return L(fs(x>>>0,A>>>0))}var Zn=()=>{throw Zt+=1,"unwind"};function dr(){return 4294901760}var lr=()=>navigator.hardwareConcurrency,wr={},aa=x=>{var A;return(A=/\bwasm-function\[\d+\]:(0x[0-9a-f]+)/.exec(x))?+A[1]:(A=/:(\d+):\d+(?:\)|$)/.exec(x))?2147483648|+A[1]:0},qa=x=>{for(var A of x)(x=aa(A))&&(wr[x]=A)};function No(){var x=Error().stack.toString().split(`
3845`);return x[0]=="Error"&&x.shift(),qa(x),wr.gd=aa(x[3]),wr.Jd=x,wr.gd}function fa(x){if(!(x=wr[x>>>0]))return 0;var A;if(A=/^\s+at .*\.wasm\.(.*) \(.*\)$/.exec(x))x=A[1];else if(A=/^\s+at (.*) \(.*\)$/.exec(x))x=A[1];else{if(!(A=/^(.+?)@/.exec(x)))return 0;x=A[1]}Wa(fa.hd??0),A=Pe(x)+1;var $=Pd(A);return $&&pe(x,$,A),fa.hd=$,fa.hd}function pa(x){x>>>=0;var A=(R(),X).length;if(x<=A||4294901760<x)return!1;for(var $=1;4>=$;$*=2){var P=A*(1+.2/$);P=Math.min(P,x+100663296);e:{P=(Math.min(4294901760,65536*Math.ceil(Math.max(x,P)/65536))-Oe.buffer.byteLength+65535)/65536|0;try{Oe.grow(P),de();var z=1;break e}catch{}z=void 0}if(z)return!0}return!1}function $u(x,A,$){if(x>>>=0,A>>>=0,wr.gd==x)var P=wr.Jd;else(P=Error().stack.toString().split(`
3846`))[0]=="Error"&&P.shift(),qa(P);for(var z=3;P[z]&&aa(P[z])!=x;)++z;for(x=0;x<$&&P[x+z];++x)(R(),F)[A+4*x>>>2>>>0]=aa(P[x+z]);return x}var ef,oc={},Du=()=>{var P;if(!ef){var x,A={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(((P=globalThis.navigator)==null?void 0:P.language)??"C").replace("-","_")+".UTF-8",_:"./this.program"};for(x in oc)oc[x]===void 0?delete A[x]:A[x]=oc[x];var $=[];for(x in A)$.push(`${x}=${A[x]}`);ef=$}return ef};function ho(x,A){if(r)return J(19,1,x,A);x>>>=0,A>>>=0;var $,P=0,z=0;for($ of Du()){var Q=A+P;(R(),we)[x+z>>>2>>>0]=Q,P+=pe($,Q,1/0)+1,z+=4}return 0}function Vc(x,A){if(r)return J(20,1,x,A);x>>>=0,A>>>=0;var $=Du();for(var P of((R(),we)[x>>>2>>>0]=$.length,x=0,$))x+=Pe(P)+1;return(R(),we)[A>>>2>>>0]=x,0}function Ou(x){return r?J(21,1,x):52}function Nd(x,A,$,P){return r?J(22,1,x,A,$,P):52}function Rd(x,A,$,P){return r?J(23,1,x,A,$,P):70}var js=[null,[],[]];function lc(x,A,$,P){if(r)return J(24,1,x,A,$,P);A>>>=0,$>>>=0,P>>>=0;for(var z=0,Q=0;Q<$;Q++){var ee=(R(),we)[A>>>2>>>0],re=(R(),we)[A+4>>>2>>>0];A+=8;for(var be=0;be<re;be++){var Ee=x,Te=(R(),X)[ee+be>>>0],Be=js[Ee];Te===0||Te===10?((Ee===1?j:L)(zs(Be)),Be.length=0):Be.push(Te)}z+=re}return(R(),we)[P>>>2>>>0]=z,0}function Md(x){return x>>>0}r||(function(){for(var x=e.numThreads-1;x--;)pt();Nt.push(async()=>{var A=(async function(){if(!r)return Promise.all(he.map(Mt))})();wt++,await A,--wt==0&&zt&&(A=zt,zt=null,A())})})(),r||(Oe=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),de()),e.wasmBinary&&(m=e.wasmBinary),e.stackSave=()=>hs(),e.stackRestore=x=>es(x),e.stackAlloc=x=>Ta(x),e.setValue=function(x,A,$="i8"){switch($.endsWith("*")&&($="*"),$){case"i1":case"i8":(R(),G)[x>>>0]=A;break;case"i16":(R(),H)[x>>>1>>>0]=A;break;case"i32":(R(),F)[x>>>2>>>0]=A;break;case"i64":(R(),Le)[x>>>3>>>0]=BigInt(A);break;case"float":(R(),me)[x>>>2>>>0]=A;break;case"double":(R(),xe)[x>>>3>>>0]=A;break;case"*":(R(),we)[x>>>2>>>0]=A;break;default:Se(`invalid type for setValue: ${$}`)}},e.getValue=function(x,A="i8"){switch(A.endsWith("*")&&(A="*"),A){case"i1":case"i8":return(R(),G)[x>>>0];case"i16":return(R(),H)[x>>>1>>>0];case"i32":return(R(),F)[x>>>2>>>0];case"i64":return(R(),Le)[x>>>3>>>0];case"float":return(R(),me)[x>>>2>>>0];case"double":return(R(),xe)[x>>>3>>>0];case"*":return(R(),we)[x>>>2>>>0];default:Se(`invalid type for getValue: ${A}`)}},e.UTF8ToString=fs,e.stringToUTF8=pe,e.lengthBytesUTF8=Pe;var El,Lu,Ir,Wa,Pd,cc,fo,$d,vp,oa,Wr,Tl,_s,Ea,Jo,es,Ta,hs,Ci,$r,Aa,uc,zc,Al,Qo,dc,Dd,la,Zo,ju,tf,nf,Gc,qm,sf,rf,xi,ma,Ui,el,Bu,Uu,tl,Hc,vi,Od,Ld,hc,af,Ka,Ya,fc,jd,Bd,ki,Xa,Cl,Xi,Ro,Fi,of,lf,cf,Fr,Kr=[We,Ie,Wn,ps,ms,Me,lt,jt,Qt,Sn,yn,Ft,sn,rn,bs,gs,Fc,Id,ac,ho,Vc,Ou,Nd,Rd,lc],Bs={973212:(x,A,$,P,z)=>{if(e===void 0||!e.Xc)return 1;if((x=fs(Number(x>>>0))).startsWith("./")&&(x=x.substring(2)),!(x=e.Xc.get(x)))return 2;if(A=Number(A>>>0),$=Number($>>>0),P=Number(P>>>0),A+$>x.byteLength)return 3;try{let Q=x.subarray(A,A+$);switch(z){case 0:(R(),X).set(Q,P>>>0);break;case 1:e.Qd?e.Qd(P,Q):e.Id(P,Q);break;default:return 4}return 0}catch{return 4}},974036:(x,A,$)=>{e.td(x,(R(),X).subarray(A>>>0,A+$>>>0))},974100:()=>e.Wd(),974142:x=>{e.sd(x)},974179:()=>{e.Bd()},974210:()=>{e.Cd()},974239:()=>{e.Gd()},974264:x=>e.Ad(x),974297:x=>e.Ed(x),974329:(x,A,$)=>{e.ed(Number(x),Number(A),Number($),!0)},974392:(x,A,$)=>{e.ed(Number(x),Number(A),Number($))},974449:()=>typeof wasmOffsetConverter<"u",974506:x=>{e.$b("Abs",x,void 0)},974557:x=>{e.$b("Neg",x,void 0)},974608:x=>{e.$b("Floor",x,void 0)},974661:x=>{e.$b("Ceil",x,void 0)},974713:x=>{e.$b("Reciprocal",x,void 0)},974771:x=>{e.$b("Sqrt",x,void 0)},974823:x=>{e.$b("Exp",x,void 0)},974874:x=>{e.$b("Erf",x,void 0)},974925:x=>{e.$b("Sigmoid",x,void 0)},974980:(x,A,$)=>{e.$b("HardSigmoid",x,{alpha:A,beta:$})},975059:x=>{e.$b("Log",x,void 0)},975110:x=>{e.$b("Sin",x,void 0)},975161:x=>{e.$b("Cos",x,void 0)},975212:x=>{e.$b("Tan",x,void 0)},975263:x=>{e.$b("Asin",x,void 0)},975315:x=>{e.$b("Acos",x,void 0)},975367:x=>{e.$b("Atan",x,void 0)},975419:x=>{e.$b("Sinh",x,void 0)},975471:x=>{e.$b("Cosh",x,void 0)},975523:x=>{e.$b("Asinh",x,void 0)},975576:x=>{e.$b("Acosh",x,void 0)},975629:x=>{e.$b("Atanh",x,void 0)},975682:x=>{e.$b("Tanh",x,void 0)},975734:x=>{e.$b("Not",x,void 0)},975785:(x,A,$)=>{e.$b("Clip",x,{min:A,max:$})},975854:x=>{e.$b("Clip",x,void 0)},975906:(x,A)=>{e.$b("Elu",x,{alpha:A})},975964:x=>{e.$b("Gelu",x,void 0)},976016:x=>{e.$b("Relu",x,void 0)},976068:(x,A)=>{e.$b("LeakyRelu",x,{alpha:A})},976132:(x,A)=>{e.$b("ThresholdedRelu",x,{alpha:A})},976202:(x,A)=>{e.$b("Cast",x,{to:A})},976260:x=>{e.$b("Add",x,void 0)},976311:x=>{e.$b("Sub",x,void 0)},976362:x=>{e.$b("Mul",x,void 0)},976413:x=>{e.$b("Div",x,void 0)},976464:x=>{e.$b("Pow",x,void 0)},976515:x=>{e.$b("Equal",x,void 0)},976568:x=>{e.$b("Greater",x,void 0)},976623:x=>{e.$b("GreaterOrEqual",x,void 0)},976685:x=>{e.$b("Less",x,void 0)},976737:x=>{e.$b("LessOrEqual",x,void 0)},976796:(x,A,$,P,z)=>{e.$b("ReduceMean",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},976971:(x,A,$,P,z)=>{e.$b("ReduceMax",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},977145:(x,A,$,P,z)=>{e.$b("ReduceMin",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},977319:(x,A,$,P,z)=>{e.$b("ReduceProd",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},977494:(x,A,$,P,z)=>{e.$b("ReduceSum",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},977668:(x,A,$,P,z)=>{e.$b("ReduceL1",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},977841:(x,A,$,P,z)=>{e.$b("ReduceL2",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},978014:(x,A,$,P,z)=>{e.$b("ReduceLogSum",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},978191:(x,A,$,P,z)=>{e.$b("ReduceSumSquare",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},978371:(x,A,$,P,z)=>{e.$b("ReduceLogSumExp",x,{keepDims:!!A,noopWithEmptyAxes:!!$,axes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},978551:x=>{e.$b("Where",x,void 0)},978604:(x,A,$)=>{e.$b("Transpose",x,{perm:A?Array.from((R(),F).subarray(Number(A)>>>0,Number($)>>>0)):[]})},978728:(x,A,$,P)=>{e.$b("DepthToSpace",x,{blocksize:A,mode:fs($),format:P?"NHWC":"NCHW"})},978861:(x,A,$,P)=>{e.$b("DepthToSpace",x,{blocksize:A,mode:fs($),format:P?"NHWC":"NCHW"})},978994:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe,Gt)=>{e.$b("ConvTranspose",x,{format:be?"NHWC":"NCHW",autoPad:A,dilations:[$],group:P,kernelShape:[z],pads:[Q,ee],strides:[re],wIsConst:()=>!!(R(),G)[Ee>>>0],outputPadding:Te?Array.from((R(),F).subarray(Number(Te)>>>0,Number(Be)>>>0)):[],outputShape:Ze?Array.from((R(),F).subarray(Number(Ze)>>>0,Number(Fe)>>>0)):[],activation:fs(Gt)})},979427:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe)=>{e.$b("ConvTranspose",x,{format:re?"NHWC":"NCHW",autoPad:A,dilations:Array.from((R(),F).subarray(Number($)>>>0,2+(Number($)>>>0)>>>0)),group:P,kernelShape:Array.from((R(),F).subarray(Number(z)>>>0,2+(Number(z)>>>0)>>>0)),pads:Array.from((R(),F).subarray(Number(Q)>>>0,4+(Number(Q)>>>0)>>>0)),strides:Array.from((R(),F).subarray(Number(ee)>>>0,2+(Number(ee)>>>0)>>>0)),wIsConst:()=>!!(R(),G)[be>>>0],outputPadding:Ee?Array.from((R(),F).subarray(Number(Ee)>>>0,Number(Te)>>>0)):[],outputShape:Be?Array.from((R(),F).subarray(Number(Be)>>>0,Number(Ze)>>>0)):[],activation:fs(Fe)})},980088:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe,Gt)=>{e.$b("ConvTranspose",x,{format:be?"NHWC":"NCHW",autoPad:A,dilations:[$],group:P,kernelShape:[z],pads:[Q,ee],strides:[re],wIsConst:()=>!!(R(),G)[Ee>>>0],outputPadding:Te?Array.from((R(),F).subarray(Number(Te)>>>0,Number(Be)>>>0)):[],outputShape:Ze?Array.from((R(),F).subarray(Number(Ze)>>>0,Number(Fe)>>>0)):[],activation:fs(Gt)})},980521:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe)=>{e.$b("ConvTranspose",x,{format:re?"NHWC":"NCHW",autoPad:A,dilations:Array.from((R(),F).subarray(Number($)>>>0,2+(Number($)>>>0)>>>0)),group:P,kernelShape:Array.from((R(),F).subarray(Number(z)>>>0,2+(Number(z)>>>0)>>>0)),pads:Array.from((R(),F).subarray(Number(Q)>>>0,4+(Number(Q)>>>0)>>>0)),strides:Array.from((R(),F).subarray(Number(ee)>>>0,2+(Number(ee)>>>0)>>>0)),wIsConst:()=>!!(R(),G)[be>>>0],outputPadding:Ee?Array.from((R(),F).subarray(Number(Ee)>>>0,Number(Te)>>>0)):[],outputShape:Be?Array.from((R(),F).subarray(Number(Be)>>>0,Number(Ze)>>>0)):[],activation:fs(Fe)})},981182:(x,A)=>{e.$b("GlobalAveragePool",x,{format:A?"NHWC":"NCHW"})},981273:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe)=>{e.$b("AveragePool",x,{format:Fe?"NHWC":"NCHW",auto_pad:A,ceil_mode:$,count_include_pad:P,storage_order:z,dilations:Q?Array.from((R(),F).subarray(Number(Q)>>>0,Number(ee)>>>0)):[],kernel_shape:re?Array.from((R(),F).subarray(Number(re)>>>0,Number(be)>>>0)):[],pads:Ee?Array.from((R(),F).subarray(Number(Ee)>>>0,Number(Te)>>>0)):[],strides:Be?Array.from((R(),F).subarray(Number(Be)>>>0,Number(Ze)>>>0)):[]})},981752:(x,A)=>{e.$b("GlobalAveragePool",x,{format:A?"NHWC":"NCHW"})},981843:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe)=>{e.$b("AveragePool",x,{format:Fe?"NHWC":"NCHW",auto_pad:A,ceil_mode:$,count_include_pad:P,storage_order:z,dilations:Q?Array.from((R(),F).subarray(Number(Q)>>>0,Number(ee)>>>0)):[],kernel_shape:re?Array.from((R(),F).subarray(Number(re)>>>0,Number(be)>>>0)):[],pads:Ee?Array.from((R(),F).subarray(Number(Ee)>>>0,Number(Te)>>>0)):[],strides:Be?Array.from((R(),F).subarray(Number(Be)>>>0,Number(Ze)>>>0)):[]})},982322:(x,A)=>{e.$b("GlobalMaxPool",x,{format:A?"NHWC":"NCHW"})},982409:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe)=>{e.$b("MaxPool",x,{format:Fe?"NHWC":"NCHW",auto_pad:A,ceil_mode:$,count_include_pad:P,storage_order:z,dilations:Q?Array.from((R(),F).subarray(Number(Q)>>>0,Number(ee)>>>0)):[],kernel_shape:re?Array.from((R(),F).subarray(Number(re)>>>0,Number(be)>>>0)):[],pads:Ee?Array.from((R(),F).subarray(Number(Ee)>>>0,Number(Te)>>>0)):[],strides:Be?Array.from((R(),F).subarray(Number(Be)>>>0,Number(Ze)>>>0)):[]})},982884:(x,A)=>{e.$b("GlobalMaxPool",x,{format:A?"NHWC":"NCHW"})},982971:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe)=>{e.$b("MaxPool",x,{format:Fe?"NHWC":"NCHW",auto_pad:A,ceil_mode:$,count_include_pad:P,storage_order:z,dilations:Q?Array.from((R(),F).subarray(Number(Q)>>>0,Number(ee)>>>0)):[],kernel_shape:re?Array.from((R(),F).subarray(Number(re)>>>0,Number(be)>>>0)):[],pads:Ee?Array.from((R(),F).subarray(Number(Ee)>>>0,Number(Te)>>>0)):[],strides:Be?Array.from((R(),F).subarray(Number(Be)>>>0,Number(Ze)>>>0)):[]})},983446:(x,A,$,P,z)=>{e.$b("Gemm",x,{alpha:A,beta:$,transA:P,transB:z})},983550:x=>{e.$b("MatMul",x,void 0)},983604:(x,A,$,P)=>{e.$b("ArgMax",x,{keepDims:!!A,selectLastIndex:!!$,axis:P})},983712:(x,A,$,P)=>{e.$b("ArgMin",x,{keepDims:!!A,selectLastIndex:!!$,axis:P})},983820:(x,A)=>{e.$b("Softmax",x,{axis:A})},983883:(x,A)=>{e.$b("Concat",x,{axis:A})},983943:(x,A,$,P,z)=>{e.$b("Split",x,{axis:A,numOutputs:$,splitSizes:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},984099:x=>{e.$b("Expand",x,void 0)},984153:(x,A)=>{e.$b("Gather",x,{axis:Number(A)})},984224:(x,A)=>{e.$b("GatherElements",x,{axis:Number(A)})},984303:(x,A)=>{e.$b("GatherND",x,{batch_dims:Number(A)})},984382:(x,A,$,P,z,Q,ee,re,be,Ee,Te)=>{e.$b("Resize",x,{antialias:A,axes:$?Array.from((R(),F).subarray(Number($)>>>0,Number(P)>>>0)):[],coordinateTransformMode:fs(z),cubicCoeffA:Q,excludeOutside:ee,extrapolationValue:re,keepAspectRatioPolicy:fs(be),mode:fs(Ee),nearestMode:fs(Te)})},984744:(x,A,$,P,z,Q,ee)=>{e.$b("Slice",x,{starts:A?Array.from((R(),F).subarray(Number(A)>>>0,Number($)>>>0)):[],ends:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[],axes:Q?Array.from((R(),F).subarray(Number(Q)>>>0,Number(ee)>>>0)):[]})},985008:x=>{e.$b("Tile",x,void 0)},985060:(x,A,$)=>{e.$b("InstanceNormalization",x,{epsilon:A,format:$?"NHWC":"NCHW"})},985174:(x,A,$)=>{e.$b("InstanceNormalization",x,{epsilon:A,format:$?"NHWC":"NCHW"})},985288:x=>{e.$b("Range",x,void 0)},985341:(x,A)=>{e.$b("Einsum",x,{equation:fs(A)})},985422:(x,A,$,P,z)=>{e.$b("Pad",x,{mode:A,value:$,pads:P?Array.from((R(),F).subarray(Number(P)>>>0,Number(z)>>>0)):[]})},985565:(x,A,$,P,z,Q)=>{e.$b("BatchNormalization",x,{epsilon:A,momentum:$,spatial:!!z,trainingMode:!!P,format:Q?"NHWC":"NCHW"})},985734:(x,A,$,P,z,Q)=>{e.$b("BatchNormalization",x,{epsilon:A,momentum:$,spatial:!!z,trainingMode:!!P,format:Q?"NHWC":"NCHW"})},985903:(x,A,$)=>{e.$b("CumSum",x,{exclusive:Number(A),reverse:Number($)})},986e3:(x,A,$)=>{e.$b("DequantizeLinear",x,{axis:A,blockSize:$})},986090:(x,A,$,P,z)=>{e.$b("GridSample",x,{align_corners:A,mode:fs($),padding_mode:fs(P),format:z?"NHWC":"NCHW"})},986260:(x,A,$,P,z)=>{e.$b("GridSample",x,{align_corners:A,mode:fs($),padding_mode:fs(P),format:z?"NHWC":"NCHW"})},986430:(x,A)=>{e.$b("ScatterND",x,{reduction:fs(A)})},986515:(x,A,$,P,z,Q,ee,re,be)=>{e.$b("Attention",x,{numHeads:A,isUnidirectional:$,maskFilterValue:P,scale:z,doRotary:Q,qkvHiddenSizes:ee?Array.from((R(),F).subarray(Number(re)>>>0,Number(re)+ee>>>0)):[],pastPresentShareBuffer:!!be})},986787:x=>{e.$b("BiasAdd",x,void 0)},986842:x=>{e.$b("BiasSplitGelu",x,void 0)},986903:x=>{e.$b("FastGelu",x,void 0)},986959:(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe,Gt,Tt)=>{e.$b("Conv",x,{format:Be?"NHWC":"NCHW",auto_pad:A,dilations:$?Array.from((R(),F).subarray(Number($)>>>0,Number(P)>>>0)):[],group:z,kernel_shape:Q?Array.from((R(),F).subarray(Number(Q)>>>0,Number(ee)>>>0)):[],pads:re?Array.from((R(),F).subarray(Number(re)>>>0,Number(be)>>>0)):[],strides:Ee?Array.from((R(),F).subarray(Number(Ee)>>>0,Number(Te)>>>0)):[],w_is_const:()=>!!(R(),G)[Number(Ze)>>>0],activation:fs(Fe),activation_params:Gt?Array.from((R(),me).subarray(Number(Gt)>>>0,Number(Tt)>>>0)):[]})},987543:x=>{e.$b("Gelu",x,void 0)},987595:(x,A,$,P,z,Q,ee,re,be)=>{e.$b("GroupQueryAttention",x,{numHeads:A,kvNumHeads:$,scale:P,softcap:z,doRotary:Q,rotaryInterleaved:ee,smoothSoftmax:re,localWindowSize:be})},987812:(x,A,$,P)=>{e.$b("LayerNormalization",x,{axis:A,epsilon:$,simplified:!!P})},987923:(x,A,$,P)=>{e.$b("LayerNormalization",x,{axis:A,epsilon:$,simplified:!!P})},988034:(x,A,$,P,z,Q)=>{e.$b("MatMulNBits",x,{k:A,n:$,accuracyLevel:P,bits:z,blockSize:Q})},988161:(x,A,$,P,z,Q)=>{e.$b("MultiHeadAttention",x,{numHeads:A,isUnidirectional:$,maskFilterValue:P,scale:z,doRotary:Q})},988320:(x,A)=>{e.$b("QuickGelu",x,{alpha:A})},988384:(x,A,$,P,z)=>{e.$b("RotaryEmbedding",x,{interleaved:!!A,numHeads:$,rotaryEmbeddingDim:P,scale:z})},988523:(x,A,$)=>{e.$b("SkipLayerNormalization",x,{epsilon:A,simplified:!!$})},988625:(x,A,$)=>{e.$b("SkipLayerNormalization",x,{epsilon:A,simplified:!!$})},988727:(x,A,$,P)=>{e.$b("GatherBlockQuantized",x,{gatherAxis:A,quantizeAxis:$,blockSize:P})},988848:x=>{e.Fd(x)},988882:(x,A)=>e.Hd(Number(x),Number(A),e.Yc.Kd,e.Yc.errors)};function Ca(x,A,$){return Mr(async()=>{await e.Dd(Number(x),Number(A),Number($))})}function nl(){return typeof wasmOffsetConverter<"u"}function Ud(x,A,$,P){var z=hs();try{return nf(x,A,$,P)}catch(Q){if(es(z),Q!==Q+0)throw Q;_s(1,0)}}function qc(x,A,$){var P=hs();try{return la(x,A,$)}catch(z){if(es(P),z!==z+0)throw z;_s(1,0)}}function bp(x){var A=hs();try{Qo(x)}catch($){if(es(A),$!==$+0)throw $;_s(1,0)}}function uf(x,A){var $=hs();try{return Al(x,A)}catch(P){if(es($),P!==P+0)throw P;_s(1,0)}}function Wc(x,A,$){var P=hs();try{zc(x,A,$)}catch(z){if(es(P),z!==z+0)throw z;_s(1,0)}}function Fd(x,A){var $=hs();try{Gc(x,A)}catch(P){if(es($),P!==P+0)throw P;_s(1,0)}}function Vd(x,A,$,P,z,Q,ee){var re=hs();try{return ju(x,A,$,P,z,Q,ee)}catch(be){if(es(re),be!==be+0)throw be;_s(1,0)}}function zd(x,A,$,P,z,Q){var ee=hs();try{dc(x,A,$,P,z,Q)}catch(re){if(es(ee),re!==re+0)throw re;_s(1,0)}}function wp(x,A,$,P){var z=hs();try{tf(x,A,$,P)}catch(Q){if(es(z),Q!==Q+0)throw Q;_s(1,0)}}function _p(x,A,$,P,z){var Q=hs();try{Dd(x,A,$,P,z)}catch(ee){if(es(Q),ee!==ee+0)throw ee;_s(1,0)}}function po(x,A,$,P,z,Q,ee){var re=hs();try{sf(x,A,$,P,z,Q,ee)}catch(be){if(es(re),be!==be+0)throw be;_s(1,0)}}function ka(x,A,$,P,z,Q,ee){var re=hs();try{rf(x,A,$,P,z,Q,ee)}catch(be){if(es(re),be!==be+0)throw be;_s(1,0)}}function Fu(x,A,$,P,z,Q,ee,re){var be=hs();try{el(x,A,$,P,z,Q,ee,re)}catch(Ee){if(es(be),Ee!==Ee+0)throw Ee;_s(1,0)}}function pc(x,A,$,P,z){var Q=hs();try{return qm(x,A,$,P,z)}catch(ee){if(es(Q),ee!==ee+0)throw ee;_s(1,0)}}function df(x,A,$){var P=hs();try{return Bu(x,A,$)}catch(z){if(es(P),z!==z+0)throw z;_s(1,0)}}function kl(x,A,$,P,z,Q,ee,re){var be=hs();try{Uu(x,A,$,P,z,Q,ee,re)}catch(Ee){if(es(be),Ee!==Ee+0)throw Ee;_s(1,0)}}function mc(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be){var Ze=hs();try{xi(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be)}catch(Fe){if(es(Ze),Fe!==Fe+0)throw Fe;_s(1,0)}}function hf(x,A,$,P,z,Q){var ee=hs();try{return ma(x,A,$,P,z,Q)}catch(re){if(es(ee),re!==re+0)throw re;_s(1,0)}}function Gd(x,A,$){var P=hs();try{return tl(x,A,$)}catch(z){if(es(P),z!==z+0)throw z;return _s(1,0),0n}}function Hd(x,A,$,P,z,Q,ee,re,be){var Ee=hs();try{Zo(x,A,$,P,z,Q,ee,re,be)}catch(Te){if(es(Ee),Te!==Te+0)throw Te;_s(1,0)}}function Sp(x){var A=hs();try{return Hc(x)}catch($){if(es(A),$!==$+0)throw $;_s(1,0)}}function qd(x,A){var $=hs();try{return Ro(x,A)}catch(P){if(es($),P!==P+0)throw P;return _s(1,0),0n}}function gc(x){var A=hs();try{return vi(x)}catch($){if(es(A),$!==$+0)throw $;return _s(1,0),0n}}function Wm(x,A,$,P){var z=hs();try{return Ya(x,A,$,P)}catch(Q){if(es(z),Q!==Q+0)throw Q;_s(1,0)}}function Mo(x,A,$,P,z){var Q=hs();try{return fc(x,A,$,P,z)}catch(ee){if(es(Q),ee!==ee+0)throw ee;_s(1,0)}}function Vu(x,A,$,P,z,Q){var ee=hs();try{return jd(x,A,$,P,z,Q)}catch(re){if(es(ee),re!==re+0)throw re;_s(1,0)}}function ff(x,A,$,P,z,Q){var ee=hs();try{return Bd(x,A,$,P,z,Q)}catch(re){if(es(ee),re!==re+0)throw re;_s(1,0)}}function Ep(x,A,$,P,z,Q,ee,re){var be=hs();try{return Ui(x,A,$,P,z,Q,ee,re)}catch(Ee){if(es(be),Ee!==Ee+0)throw Ee;_s(1,0)}}function Km(x,A,$,P,z){var Q=hs();try{return ki(x,A,$,P,z)}catch(ee){if(es(Q),ee!==ee+0)throw ee;return _s(1,0),0n}}function mo(x,A,$,P){var z=hs();try{return Xa(x,A,$,P)}catch(Q){if(es(z),Q!==Q+0)throw Q;_s(1,0)}}function Ia(x,A,$,P){var z=hs();try{return Cl(x,A,$,P)}catch(Q){if(es(z),Q!==Q+0)throw Q;_s(1,0)}}function yc(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be){var Ze=hs();try{return Xi(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be)}catch(Fe){if(es(Ze),Fe!==Fe+0)throw Fe;_s(1,0)}}function Tp(x,A,$,P,z,Q,ee,re,be,Ee,Te){var Be=hs();try{af(x,A,$,P,z,Q,ee,re,be,Ee,Te)}catch(Ze){if(es(Be),Ze!==Ze+0)throw Ze;_s(1,0)}}function Il(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe,Gt,Tt){var Bt=hs();try{Ka(x,A,$,P,z,Q,ee,re,be,Ee,Te,Be,Ze,Fe,Gt,Tt)}catch(en){if(es(Bt),en!==en+0)throw en;_s(1,0)}}function Nl(x,A,$){var P=hs();try{return Od(x,A,$)
vendor: 4,157 bytes, line 3846
3846}catch(z){if(es(P),z!==z+0)throw z;_s(1,0)}}function bi(x,A,$){var P=hs();try{return Ld(x,A,$)}catch(z){if(es(P),z!==z+0)throw z;_s(1,0)}}function zu(x,A,$,P){var z=hs();try{hc(x,A,$,P)}catch(Q){if(es(z),Q!==Q+0)throw Q;_s(1,0)}}function ui(){if(0<wt)zt=ui;else if(r)b==null||b(e),Re();else{for(var x=Nt;0<x.length;)x.shift()(e);0<wt?zt=ui:(e.calledRun=!0,K||(Re(),b==null||b(e)))}}return r||(Fr=await gt(),ui()),e.PTR_SIZE=4,ie?e:new Promise((x,A)=>{b=x,S=A})}var AZ,vz,vAe=qt(()=>{var t,e;AZ=xz,vz=(e=(t=globalThis.self)==null?void 0:t.name)==null?void 0:e.startsWith("em-pthread"),vz&&xz()}),i$,GD,bz,lu,CZ,Vk,wz,_z,a$,Sz,o$,kZ,l$,IZ,B7=qt(()=>{j7(),i$=typeof location>"u"?void 0:location.origin,GD=import.meta.url>"file:"&&import.meta.url<"file;",bz=()=>{{if(GD){let t=URL;return new URL(new t("ort.bundle.min.mjs",import.meta.url).href,i$).href}return import.meta.url}},lu=bz(),CZ=()=>{if(lu&&!lu.startsWith("blob:"))return lu.substring(0,lu.lastIndexOf("/")+1)},Vk=(t,e)=>{try{let n=e??lu;return(n?new URL(t,n):new URL(t)).origin===i$}catch{return!1}},wz=(t,e)=>{let n=e??lu;try{return(n?new URL(t,n):new URL(t)).href}catch{return}},_z=(t,e)=>`${e??"./"}${t}`,a$=async t=>{let e=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},Sz=async t=>(await import(t)).default,o$=(xAe(),TE(SZ)).default,kZ=async()=>{if(!lu)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Vk(lu))return[void 0,o$()];let t=await a$(lu);return[t,o$(t)]},l$=(vAe(),TE(TZ)).default,IZ=async(t,e,n,s)=>{let r=l$&&!(t||e);if(r)if(lu)r=Vk(lu)||s&&!n;else if(s&&!n)r=!0;else throw new Error("cannot determine the script source URL.");if(r)return[void 0,l$];{let i="ort-wasm-simd-threaded.jsep.mjs",a=t??wz(i,e),o=n&&a&&!Vk(a,e),l=o?await a$(a):a??_z(i,e);return[o?l:void 0,await Sz(l)]}}}),c$,zk,U2,u$,Ez,Tz,Az,U7,ri,Gv=qt(()=>{B7(),zk=!1,U2=!1,u$=!1,Ez=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Tz=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Az=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},U7=async t=>{if(zk)return Promise.resolve();if(U2)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(u$)throw new Error("previous call to 'initializeWebAssembly()' failed.");U2=!0;let e=t.initTimeout,n=t.numThreads;if(t.simd!==!1){if(t.simd==="relaxed"){if(!Az())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Tz())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let s=Ez();n>1&&!s&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+n+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),t.numThreads=n=1);let r=t.wasmPaths,i=typeof r=="string"?r:void 0,a=r==null?void 0:r.mjs,o=(a==null?void 0:a.href)??a,l=r==null?void 0:r.wasm,c=(l==null?void 0:l.href)??l,h=t.wasmBinary,[p,m]=await IZ(o,i,n>1,!!h||!!c),y=!1,v=[];if(e>0&&v.push(new Promise(b=>{setTimeout(()=>{y=!0,b()},e)})),v.push(new Promise((b,S)=>{let E={numThreads:n};if(h)E.wasmBinary=h,E.locateFile=I=>I;else if(c||i)E.locateFile=I=>c??i+I;else if(o&&o.indexOf("blob:")!==0)E.locateFile=I=>new URL(I,o).href;else if(p){let I=CZ();I&&(E.locateFile=M=>I+M)}m(E).then(I=>{U2=!1,zk=!0,c$=I,b(),p&&URL.revokeObjectURL(p)},I=>{U2=!1,u$=!0,S(I)})})),await Promise.race(v),y)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},ri=()=>
3846{if(zk&&c$)return c$;throw new Error("WebAssembly is not initialized yet.")}}),Uh,aR,Lr,F7=qt(()=>{Gv(),Uh=(t,e)=>{let n=ri(),s=n.lengthBytesUTF8(t)+1,r=n._malloc(s);return n.stringToUTF8(t,r,s),e.push(r),r},aR=(t,e,n,s)=>{if(typeof t=="object"&&t!==null){if(n.has(t))throw new Error("Circular reference in options");n.add(t)}Object.entries(t).forEach(([r,i])=>{let a=e?e+r:r;if(typeof i=="object")aR(i,a+".",n,s);else if(typeof i=="string"||typeof i=="number")s(a,i.toString());else if(typeof i=="boolean")s(a,i?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof i}`)})},Lr=t=>{let e=ri(),n=e.stackSave();try{let s=e.PTR_SIZE,r=e.stackAlloc(2*s);e._OrtGetLastError(r,r+s);let i=Number(e.getValue(r,s===4?"i32":"i64")),a=e.getValue(r+s,"*"),o=a?e.UTF8ToString(a):"";throw new Error(`${t} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{e.stackRestore(n)}}}),NZ,bAe=qt(()=>{Gv(),F7(),NZ=t=>{let e=ri(),n=0,s=[],r=t||{};try{if((t==null?void 0:t.logSeverityLevel)===void 0)r.logSeverityLevel=2;else if(typeof t.logSeverityLevel!="number"||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${t.logSeverityLevel}`);if((t==null?void 0:t.logVerbosityLevel)===void 0)r.logVerbosityLevel=0;else if(typeof t.logVerbosityLevel!="number"||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);(t==null?void 0:t.terminate)===void 0&&(r.terminate=!1);let i=0;return(t==null?void 0:t.tag)!==void 0&&(i=Uh(t.tag,s)),n=e._OrtCreateRunOptions(r.logSeverityLevel,r.logVerbosityLevel,!!r.terminate,i),n===0&&Lr("Can't create run options."),(t==null?void 0:t.extra)!==void 0&&aR(t.extra,"",new WeakSet,(a,o)=>{let l=Uh(a,s),c=Uh(o,s);e._OrtAddRunConfigEntry(n,l,c)!==0&&Lr(`Can't set a run config entry: ${a} - ${o}.`)}),[n,s]}
vendor: 13,298 bytes, line 3846
3846catch(i){throw n!==0&&e._OrtReleaseRunOptions(n),s.forEach(a=>e._free(a)),i}}}),Cz,kz,Iz,$y,Nz,RZ,wAe=qt(()=>{Gv(),F7(),Cz=t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}},kz=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},Iz=t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});let e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),t.executionProviders&&t.executionProviders.some(n=>(typeof n=="string"?n:n.name)==="webgpu")&&(t.enableMemPattern=!1)},$y=(t,e,n,s)=>{let r=Uh(e,s),i=Uh(n,s);ri()._OrtAddSessionConfigEntry(t,r,i)!==0&&Lr(`Can't set a session config entry: ${e} - ${n}.`)},Nz=async(t,e,n)=>{let s=e.executionProviders;for(let r of s){let i=typeof r=="string"?r:r.name,a=[];switch(i){case"webnn":if(i="WEBNN",$y(t,"session.disable_quant_qdq","1",n),$y(t,"session.disable_qdq_constant_folding","1",n),typeof r!="string"){let p=r==null?void 0:r.deviceType;p&&$y(t,"deviceType",p,n)}break;case"webgpu":if(i="JS",typeof r!="string"){let p=r;if(p!=null&&p.preferredLayout){if(p.preferredLayout!=="NCHW"&&p.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${p.preferredLayout}`);$y(t,"preferredLayout",p.preferredLayout,n)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${i}`)}let o=Uh(i,n),l=a.length,c=0,h=0;if(l>0){c=ri()._malloc(l*ri().PTR_SIZE),n.push(c),h=ri()._malloc(l*ri().PTR_SIZE),n.push(h);for(let p=0;p<l;p++)ri().setValue(c+p*ri().PTR_SIZE,a[p][0],"*"),ri().setValue(h+p*ri().PTR_SIZE,a[p][1],"*")}await ri()._OrtAppendExecutionProvider(t,o,c,h,l)!==0&&Lr(`Can't append execution provider: ${i}.`)}},RZ=async t=>{let e=ri(),n=0,s=[],r=t||{};Iz(r);try{let i=Cz(r.graphOptimizationLevel??"all"),a=kz(r.executionMode??"sequential"),o=typeof r.logId=="string"?Uh(r.logId,s):0,l=r.logSeverityLevel??2;if(!Number.isInteger(l)||l<0||l>4)throw new Error(`log severity level is not valid: ${l}`);let c=r.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw new Error(`log verbosity level is not valid: ${c}`);let h=typeof r.optimizedModelFilePath=="string"?Uh(r.optimizedModelFilePath,s):0;if(n=e._OrtCreateSessionOptions(i,!!r.enableCpuMemArena,!!r.enableMemPattern,a,!!r.enableProfiling,0,o,l,c,h),n===0&&Lr("Can't create session options."),r.executionProviders&&await Nz(n,r,s),r.enableGraphCapture!==void 0){if(typeof r.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${r.enableGraphCapture}`);$y(n,"enableGraphCapture",r.enableGraphCapture.toString(),s)}if(r.freeDimensionOverrides)for(let[p,m]of Object.entries(r.freeDimensionOverrides)){if(typeof p!="string")throw new Error(`free dimension override name must be a string: ${p}`);if(typeof m!="number"||!Number.isInteger(m)||m<0)throw new Error(`free dimension override value must be a non-negative integer: ${m}`);let y=Uh(p,s);e._OrtAddFreeDimensionOverride(n,y,m)!==0&&Lr(`Can't set a free dimension override: ${p} - ${m}.`)}return r.extra!==void 0&&aR(r.extra,"",new WeakSet,(p,m)=>{$y(n,p,m,s)}),[n,s]}catch(i){throw n!==0&&e._OrtReleaseSessionOptions(n)!==0&&Lr("Can't release session options."),s.forEach(a=>e._free(a)),i}}}),Yy,Em,Xy,PM,oR,V7,z7,HD,ts=qt(()=>{Yy=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${t}`)}},Em=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${t}`)}},Xy=(t,e)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][t],s=typeof e=="number"?e:e.reduce((r,i)=>r*i,1);return n>0?Math.ceil(s*n):void 0},PM=t=>{switch(t){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}},oR=t=>{switch(t){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${t}`)}},V7=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",z7=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",HD=t=>{switch(t){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${t}`)}}}),G7,MZ=qt(()=>{j7(),G7=async t=>{if(typeof t=="string"){let e=await fetch(t);if(!e.ok)throw new Error(`failed to load external data file: ${t}`);let n=e.headers.get("Content-Length"),s=n?parseInt(n,10):0;if(s<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let r=e.body.getReader(),i;try{i=new ArrayBuffer(s)}catch(o){if(o instanceof RangeError){let l=Math.ceil(s/65536);i=new WebAssembly.Memory({initial:l,maximum:l}).buffer}else throw o}let a=0;for(;;){let{done:o,value:l}=await r.read();if(o)break;let c=l.byteLength;new Uint8Array(i,a,c).set(l),a+=c}return new Uint8Array(i,0,s)}}else return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}}),Rz,Mz,Pz,$z,H7,Dz,cr,zm=qt(()=>{ts(),Rz=["V","I","W","E","F"],Mz=(t,e)=>{console.log(`[${Rz[t]},${new Date().toISOString()}]${e}`)},H7=(t,e)=>{Pz=t,$z=e},Dz=(t,e)=>{let n=oR(t),s=oR(Pz);n>=s&&Mz(n,typeof e=="function"?e():e)},cr=(...t)=>{$z&&Dz(...t)}}),Oz,q1,dt,lR,PZ,$Z,DZ,Ts=qt(()=>{Oz=class{static calcMatMulShape(t,e){return t[1]!==e[0]?void 0:[t[0],e[1]]}},q1=class{static calcShape(t,e,n=!1){let s=t.length,r=e.length;if(s===0)return e;if(r===0)return t;let i=Math.max(t.length,e.length),a=new Array(i);if(n){if(s<2||r<2)return;let o=Oz.calcMatMulShape([t[s-2],t[s-1]],[e[r-2],e[r-1]]);if(o===void 0)return;[a[i-2],a[i-1]]=o}for(let o=n?3:1;o<=i;o++){let l=s-o<0?1:t[s-o],c=r-o<0?1:e[r-o];if(l!==c&&l>1&&c>1)return;let h=Math.max(l,c);if(l&&c)a[i-o]=Math.max(l,c);else{if(h>1)return;a[i-o]=0}}return a}static isValidBroadcast(t,e){let n=t.length,s=e.length;if(n>s)return!1;for(let r=1;r<=n;r++)if(t[n-r]!==1&&t[n-r]!==e[s-r])return!1;return!0}},dt=class $I{static size(e){return $I.getSizeFromDimensionRange(e,0,e.length)}static convertShape(e,n=4){let s=e.length;if(s===0)return[];let r=new Array(s),i=s-1;for(;i>=0;){if(e[i]%n===0){r[i]=e[i]/n;break}if(n%e[i]!==0)throw new Error("cannot convert shape");r[i]=1,n/=e[i],i--}for(i--;i>=0;i--)r[i]=e[i];return r}static sizeFromDimension(e,n){if(n<0||n>e.length)throw new Error(`invalid dimension of ${n} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return $I.getSizeFromDimensionRange(e,n,e.length)}static sizeToDimension(e,n){if(n<0||n>e.length)throw new Error(`invalid dimension of ${n} for sizeToDimension as Tensor has ${e.length} dimensions.`);return $I.getSizeFromDimensionRange(e,0,n)}static getSizeFromDimensionRange(e,n,s){let r=1;for(let i=n;i<s;i++){if(e[i]<0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains negative values in them.");r*=Number(e[i])}return r}static computeStrides(e){let n=e.length;if(n===0)return[];if(n===1)return[1];let s=new Array(n);s[n-1]=1,s[n-2]=e[n-1];for(let r=n-3;r>=0;--r)s[r]=s[r+1]*e[r+1];return s}static normalizeAxis(e,n){if(e<-n&&e>=n)throw new Error("unsupported axis for this operation.");return e<0?e+n:e}static normalizeAxes(e,n){return e.map(s=>this.normalizeAxis(s,n??e.length))}static sortBasedOnPerm(e,n){return n?n.map(s=>e[s]):e.slice().reverse()}static padShape(e,n){let s=e.length;return e.map((r,i)=>r+n[i]+n[i+s])}static areEqual(e,n){return e.length!==n.length?!1:e.every((s,r)=>s===n[r])}},lR=class uS{static adjustPoolAttributes(e,n,s,r,i,a){if(!e&&s.length!==n.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let o=0;o<n.length-2;o++)o>=s.length?s.push(n[o+2]):s[o]=n[o+2];for(let o=0;o<s.length;o++)if(o<r.length){if(r[o]<0)throw new Error("strides should be greater than or equal to 1")}else r.push(1);for(let o=0;o<s.length;o++)if(o<i.length){if(i[o]<0)throw new Error("dilations should be greater than or equal to 1")}else i.push(1);for(let o=0;o<s.length*2;o++)if(o<a.length){if(a[o]<0)throw new Error("pad should be greater than or equal to 1")}else a.push(0);for(let o=0;o<s.length;o++){if(s[o]<=0)throw new Error("kernel shapes need to be greater than 0");if(a[o]>=s[o]||a[o+s.length]>=s[o])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,n,s,r,i,a,o){if(o){if(i.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(n.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(r.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let l=0;l<e.length-2;l++)uS.adjustPadAndReturnShape(e[l+(a?1:2)],n[l],s[l],r[l],i,l,l+e.length-2,o)}}static computePoolOutputShape(e,n,s,r,i,a,o){if(n.length<=0)throw new Error("input shape must be of size greater than 0");let l=[n[0],n[1]];return uS.computeShapeHelper(e,n,l,s,r,i,a,o),l}static computeConvOutputShape(e,n,s,r,i,a,o){if(e.length<=0||n.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let l=[e[0],n[0]];return uS.computeShapeHelper(!1,e,l,s,r,i,a,o),l}static computeShapeHelper(e,n,s,r,i,a,o,l){if(e)for(let c=0;c<n.length-2;c++)s.push(1);else for(let c=0;c<n.length-2;c++)s.push(uS.adjustPadAndReturnShape(n[c+2],r[c],i[c],a[c],o,c,c+n.length-2,l))}static adjustPadAndReturnShape(e,n,s,r,i,a,o,l){let c=s*(r-1)+1;if(l&&l!=="NOTSET")switch(l){case"VALID":return i[a]=0,i[o]=0,Math.floor((e-c)/n+1);case"SAME_LOWER":case"SAME_UPPER":if(s!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let h=((e+n-1)/n-1)*n+r-e;return i[a]=Math.floor(l==="SAME_LOWER"?(h+1)/2:h/2),i[o]=h-i[a],Math.floor((e+h-r)/n+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((e+i[a]+i[o]-c)/n+1)}},PZ=class{static getShapeOfGemmResult(t,e,n,s,r){if(t.length!==2||n.length!==2)throw new Error("shape need to be of size 2");let i,a,o;e?(i=t[1],a=t[0]):(i=t[0],a=t[1]);let l=-1;if(s?(o=n[0],l=1):(o=n[1],l=0),n[l]!==a)throw new Error("dimension mismatch");if(i<=0||o<=0||a<=0)throw new Error("invalid shape specified");if(r&&!q1.isValidBroadcast(r,[i,o]))throw new Error("gemm: invalid bias shape for broadcast");return[i,o,a]}},$Z=-34028234663852886e22,DZ=34028234663852886e22}),q7,OZ=qt(()=>{ts(),q7=(t,e)=>new(PM(e))(t)}),d$,qD,h$,Lz,f$,jz,p$,m$,g$,Bz,LZ,_Ae=qt(()=>{ts(),zm(),d$=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),qD=(t,e)=>{if(e==="int32")return t;let n=d$.get(e);if(!n)throw new Error(`WebNN backend does not support data type: ${e}`);let s=n/8;if(t.byteLength%s!==0)throw new Error(`Invalid Uint8Array length - must be a multiple of ${s}.`);let r=t.byteLength/s,i=new(PM(e))(t.buffer,t.byteOffset,r);switch(e){case"int64":case"uint64":{let a=new Int32Array(r);for(let o=0;o<r;o++){let l=i[o];if(l>2147483647n||l<-2147483648n)throw new Error("Can not convert int64 data to int32 - value out of range.");a[o]=Number(l)}return new Uint8Array(a.buffer)}case"int8":case"uint8":case"uint32":{if(e==="uint32"&&i.some(o=>o>2147483647))throw new Error("Can not convert uint32 data to int32 - value out of range.");let a=Int32Array.from(i,Number);return new Uint8Array(a.buffer)}default:throw new Error(`Unsupported data conversion from ${e} to 'int32'`)}},h$=(t,e)=>{if(e==="int32")return t;if(t.byteLength%4!==0)throw new Error("Invalid Uint8Array length - must be a multiple of 4 (int32).");let n=t.byteLength/4,s=new Int32Array(t.buffer,t.byteOffset,n);switch(e){case"int64":{let r=BigInt64Array.from(s,BigInt);return new Uint8Array(r.buffer)}case"uint64":{if(s.some(i=>i<0))throw new Error("Can not convert int32 data to uin64 - negative value found.");let r=BigUint64Array.from(s,BigInt);return new Uint8Array(r.buffer)}
vendor: 6,515 bytes, line 3846
3846case"int8":{if(s.some(i=>i<-128||i>127))throw new Error("Can not convert int32 data to int8 - value out of range.");let r=Int8Array.from(s,Number);return new Uint8Array(r.buffer)}case"uint8":{if(s.some(r=>r<0||r>255))throw new Error("Can not convert int32 data to uint8 - value out of range.");return Uint8Array.from(s,Number)}case"uint32":{if(s.some(i=>i<0))throw new Error("Can not convert int32 data to uint32 - negative value found.");let r=Uint32Array.from(s,Number);return new Uint8Array(r.buffer)}default:throw new Error(`Unsupported data conversion from 'int32' to ${e}`)}},Lz=1,f$=()=>Lz++,jz=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),p$=(t,e)=>{let n=d$.get(t);if(!n)throw new Error(`WebNN backend does not support data type: ${t}`);return e.length>0?Math.ceil(e.reduce((s,r)=>s*r)*n/8):0},m$=class{constructor(t){this.isDataConverted=!1;let{sessionId:e,context:n,tensor:s,dataType:r,shape:i,fallbackDataType:a}=t;this.sessionId=e,this.mlContext=n,this.mlTensor=s,this.dataType=r,this.tensorShape=i,this.fallbackDataType=a}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return p$(this.dataType,this.tensorShape)}destroy(){cr("verbose",()=>"[WebNN] TensorWrapper.destroy"),this.mlTensor.destroy()}write(t){this.mlContext.writeTensor(this.mlTensor,t)}async read(t){if(this.fallbackDataType){let e=await this.mlContext.readTensor(this.mlTensor),n=h$(new Uint8Array(e),this.dataType);if(t){(t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)).set(n);return}else return n.buffer}else return t?this.mlContext.readTensor(this.mlTensor,t):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(t,e,n){return this.mlContext===t&&this.dataType===e&&this.tensorShape.length===n.length&&this.tensorShape.every((s,r)=>s===n[r])}setIsDataConverted(t){this.isDataConverted=t}},g$=class{constructor(t,e){this.tensorManager=t,this.wrapper=e}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(t,e,n,s){let r=this.tensorManager.getMLContext(t),i=this.tensorManager.getMLOpSupportLimits(t),a;if(!(i!=null&&i.input.dataTypes.includes(e))){if(a=jz.get(e),!a||(i==null?void 0:i.input.dataTypes.includes(a)))throw new Error(`WebNN backend does not support data type: ${e}`);cr("verbose",()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${e} to ${a}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(r,e,n))return this.wrapper.tensor;if(s){if(this.wrapper.byteLength!==p$(e,n))throw new Error("Unable to copy data to tensor with different size.");this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let o=typeof MLTensorUsage>"u"?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(t,e,n,o,!0,!0,a),s&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(t){let e=t;if(this.wrapper){if(this.wrapper.fallbackType)if(this.wrapper.fallbackType==="int32")e=qD(t,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw new Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(t.byteLength===this.wrapper.byteLength){this.wrapper.write(e);return}else cr("verbose",()=>"Data size does not match tensor size. Releasing tensor."),this.releaseTensor()}this.activeUpload?this.activeUpload.set(e):this.activeUpload=new Uint8Array(e)}async download(t){var e,n;if(this.activeUpload){let s=(e=this.wrapper)!=null&&e.isDataConverted?h$(this.activeUpload,(n=this.wrapper)==null?void 0:n.type):this.activeUpload;if(t){t instanceof ArrayBuffer?new Uint8Array(t).set(s):new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(s);return}else return s.buffer}if(!this.wrapper)throw new Error("Tensor has not been created.");return t?this.wrapper.read(t):this.wrapper.read()}},Bz=class{constructor(t){this.backend=t,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(t){let e=this.backend.getMLContext(t);if(!e)throw new Error("MLContext not found for session.");return e}getMLOpSupportLimits(t){return this.backend.getMLOpSupportLimits(t)}reserveTensorId(){let t=f$();return this.tensorTrackersById.set(t,new g$(this)),t}releaseTensorId(t){let e=this.tensorTrackersById.get(t);e&&(this.tensorTrackersById.delete(t),e.tensorWrapper&&this.releaseTensor(e.tensorWrapper))}async ensureTensor(t,e,n,s,r){cr("verbose",()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${e}, dataType: ${n}, shape: ${s}, copyOld: ${r}}`);let i=this.tensorTrackersById.get(e);if(!i)throw new Error("Tensor not found.");return i.ensureTensor(t,n,s,r)}upload(t,e){let n=this.tensorTrackersById.get(t);if(!n)throw new Error("Tensor not found.");n.upload(e)}async download(t,e){cr("verbose",()=>`[WebNN] TensorManager.download {tensorId: ${t}, dstBuffer: ${e==null?void 0:e.byteLength}}`);let n=this.tensorTrackersById.get(t);if(!n)throw new Error("Tensor not found.");return n.download(e)}releaseTensorsForSession(t){for(let e of this.freeTensors)e.sessionId===t&&e.destroy();this.freeTensors=this.freeTensors.filter(e=>e.sessionId!==t)}registerTensor(t,e,n,s){let r=this.getMLContext(t),i=f$(),a=new m$({sessionId:t,context:r,tensor:e,dataType:n,shape:s});return this.tensorTrackersById.set(i,new g$(this,a)),this.externalTensors.add(a),i}async getCachedTensor(t,e,n,s,r,i,a){let o=this.getMLContext(t);for(let[c,h]of this.freeTensors.entries())if(h.canReuseTensor(o,e,n)){cr("verbose",()=>`[WebNN] Reusing tensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${n}`);let p=this.freeTensors.splice(c,1)[0];return p.sessionId=t,p}cr("verbose",()=>`[WebNN] MLContext.createTensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${n}}`);let l=await o.createTensor({dataType:a??e,shape:n,dimensions:n,usage:s,writable:r,readable:i});return new m$({sessionId:t,context:o,tensor:l,dataType:e,shape:n,fallbackDataType:a})}releaseTensor(t){this.externalTensors.has(t)&&this.externalTensors.delete(t),this.freeTensors.push(t)}},LZ=(...t)=>new Bz(...t)}),F2,Uz,jZ,SAe=qt(()=>{ts(),Gv(),OZ(),_Ae(),zm(),F2=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),Uz=(t,e)=>{if(t===e)return!0;
3846if(t===void 0||e===void 0)return!1;let n=Object.keys(t).sort(),s=Object.keys(e).sort();return n.length===s.length&&n.every((r,i)=>r===s[i]&&t[r]===e[r])},jZ=class{constructor(t){this.tensorManager=LZ(this),this.mlContextBySessionId=new Map,this.sessionIdsByMLContext=new Map,this.mlContextCache=[],this.sessionGraphInputs=new Map,this.sessionGraphOutputs=new Map,this.temporaryGraphInputs=[],this.temporaryGraphOutputs=[],this.temporarySessionTensorIds=new Map,this.mlOpSupportLimitsBySessionId=new Map,H7(t.logLevel,!!t.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(t){cr("verbose",()=>`[WebNN] onRunStart {sessionId: ${t}}`),this.activeSessionId=t}onRunEnd(t){cr("verbose",()=>`[WebNN] onRunEnd {sessionId: ${t}}`);let e=this.temporarySessionTensorIds.get(t);if(e){for(let n of e)cr("verbose",()=>`[WebNN] releasing temporary tensor {tensorId: ${n}}`),this.tensorManager.releaseTensorId(n);this.temporarySessionTensorIds.delete(t),this.activeSessionId=void 0}}async createMLContext(t){if(t instanceof GPUDevice){let n=this.mlContextCache.findIndex(s=>s.gpuDevice===t);if(n!==-1)return this.mlContextCache[n].mlContext;{let s=await navigator.ml.createContext(t);return this.mlContextCache.push({gpuDevice:t,mlContext:s}),s}}else if(t===void 0){let n=this.mlContextCache.findIndex(s=>s.options===void 0&&s.gpuDevice===void 0);if(n!==-1)return this.mlContextCache[n].mlContext;{let s=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:s}),s}}let e=this.mlContextCache.findIndex(n=>Uz(n.options,t));if(e!==-1)return this.mlContextCache[e].mlContext;{let n=await navigator.ml.createContext(t);return this.mlContextCache.push({options:t,mlContext:n}),n}}registerMLContext(t,e){this.mlContextBySessionId.set(t,e);let n=this.sessionIdsByMLContext.get(e);n||(n=new Set,this.sessionIdsByMLContext.set(e,n)),n.add(t),this.mlOpSupportLimitsBySessionId.has(t)||this.mlOpSupportLimitsBySessionId.set(t,e.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(t,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(t,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(t){this.sessionGraphInputs.delete(t),this.sessionGraphOutputs.delete(t);let e=this.mlContextBySessionId.get(t);if(!e)return;this.tensorManager.releaseTensorsForSession(t),this.mlContextBySessionId.delete(t),this.mlOpSupportLimitsBySessionId.delete(t);let n=this.sessionIdsByMLContext.get(e);if(n.delete(t),n.size===0){this.sessionIdsByMLContext.delete(e);let s=this.mlContextCache.findIndex(r=>r.mlContext===e);s!==-1&&this.mlContextCache.splice(s,1)}}getMLContext(t){return this.mlContextBySessionId.get(t)}getMLOpSupportLimits(t){return this.mlOpSupportLimitsBySessionId.get(t)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(t){cr("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${t}}`),this.tensorManager.releaseTensorId(t)}async ensureTensor(t,e,n,s,r){let i=F2.get(n);if(!i)throw new Error(`Unsupported ONNX data type: ${n}`);return this.tensorManager.ensureTensor(t??this.currentSessionId,e,i,s,r)}async createTemporaryTensor(t,e,n){cr("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${e}, shape: ${n}}`);let s=F2.get(e);if(!s)throw new Error(`Unsupported ONNX data type: ${e}`);let r=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(t,r,s,n,!1);let i=this.temporarySessionTensorIds.get(t);return i?i.push(r):this.temporarySessionTensorIds.set(t,[r]),r}uploadTensor(t,e){if(!ri().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");cr("verbose",()=>`[WebNN] uploadTensor {tensorId: ${t}, data: ${e.byteLength}}`),this.tensorManager.upload(t,e)}async downloadTensor(t,e){return this.tensorManager.download(t,e)}createMLTensorDownloader(t,e){return async()=>{let n=await this.tensorManager.download(t);return q7(n,e)}}registerMLTensor(t,e,n,s){let r=F2.get(n);if(!r)throw new Error(`Unsupported ONNX data type: ${n}`);let i=this.tensorManager.registerTensor(t,e,r,s);return cr("verbose",()=>`[WebNN] registerMLTensor {tensor: ${e}, dataType: ${r}, dimensions: ${s}} -> {tensorId: ${i}}`),i}registerMLConstant(t,e,n,s,r,i,a=!1){if(!i)throw new Error("External mounted files are not available.");let o=t;t.startsWith("./")&&(o=t.substring(2));let l=i.get(o);if(!l)throw new Error(`File with name ${o} not found in preloaded files.`);if(e+n>l.byteLength)throw new Error("Out of bounds: data offset and length exceed the external file data size.");let c=l.slice(e,e+n).buffer,h;switch(r.dataType){case"float32":h=new Float32Array(c);break;case"float16":h=typeof Float16Array<"u"&&Float16Array.from?new Float16Array(c):new Uint16Array(c);break;case"int32":h=new Int32Array(c);break;case"uint32":h=new Uint32Array(c);break;case"int64":if(a){let p=qD(new Uint8Array(c),"int64");h=new Int32Array(p.buffer),r.dataType="int32"}else h=new BigInt64Array(c);break;case"uint64":h=new BigUint64Array(c);break;case"int8":h=new Int8Array(c);break;case"int4":case"uint4":case"uint8":h=new Uint8Array(c);break;default:throw new Error(`Unsupported data type: ${r.dataType} in creating WebNN Constant from external data.`)}return cr("verbose",()=>`[WebNN] registerMLConstant {dataType: ${r.dataType}, shape: ${r.shape}}} ${a?"(Note: it was int64 data type and registered to int32 as workaround)":""}`),s.constant(r,h)}registerGraphInput(t){this.temporaryGraphInputs.push(t)}registerGraphOutput(t){this.temporaryGraphOutputs.push(t)}isGraphInput(t,e){let n=this.sessionGraphInputs.get(t);return n?n.includes(e):!1}isGraphOutput(t,e){let n=this.sessionGraphOutputs.get(t);return n?n.includes(e):!1}isGraphInputOutputTypeSupported(t,e,n=!0){let s=F2.get(Yy(e)),r=this.mlOpSupportLimitsBySessionId.get(t);return typeof s>"u"?!1:n?!!(r!=null&&r.input.dataTypes.includes(s)):!!(r!=null&&r.output.dataTypes.includes(s))}flush(){}}}),W7=qt(()=>{}),y$,Gk,Hk,Fz,Vz,x$,WD,zz,BZ,EAe=qt(()=>{zm(),W7(),y$=new Map([[64,250],[128,200],[256,200],[512,200],[2048,230],[4096,200
vendor: 23,591 bytes, lines 3846-3969
3846],[8192,50],[16384,50],[32768,50],[65536,50],[131072,50],[262144,50],[524288,50],[1048576,50],[2097152,30],[4194304,20],[8388608,10],[12582912,10],[16777216,10],[26214400,15],[33554432,22],[44236800,2],[58982400,6],[67108864,6],[134217728,6],[167772160,6]]),Gk=[],Hk=t=>Math.ceil(Number(t)/16)*16,Fz=t=>{for(let e=0;e<Gk.length;e++){let n=Gk[e];if(t<=n)return n}return Math.ceil(t/16)*16},Vz=1,x$=()=>Vz++,WD=async(t,e,n,s)=>{let r=Hk(n),i=t.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});try{let a=t.getCommandEncoder();t.endComputePass(),a.copyBufferToBuffer(e,0,i,0,r),t.flush(),await i.mapAsync(GPUMapMode.READ);let o=i.getMappedRange();if(s){let l=s();return l.set(new Uint8Array(o,0,n)),l}else return new Uint8Array(o.slice(0,n))}finally{i.destroy()}},zz=class{constructor(t){this.backend=t,this.storageCache=new Map,this.freeBuffers=new Map,this.freeUniformBuffers=new Map,this.buffersPending=[],this.capturedPendingBuffers=new Map;for(let[e]of y$)Gk.push(e),this.freeBuffers.set(e,[]),this.freeUniformBuffers.set(e,[]);this.sessionCount=0}upload(t,e){let n=e.buffer,s=e.byteOffset,r=e.byteLength,i=Hk(r),a=this.storageCache.get(t);if(!a)throw new Error("gpu data for uploading does not exist");if(Number(a.originalSize)!==r)throw new Error(`inconsistent data size. gpu data size=${a.originalSize}, data size=${r}`);let o=this.backend.device.createBuffer({mappedAtCreation:!0,size:i,usage:GPUBufferUsage.MAP_WRITE|GPUBufferUsage.COPY_SRC}),l=o.getMappedRange();new Uint8Array(l).set(new Uint8Array(n,s,r)),o.unmap();let c=this.backend.device.createCommandEncoder();c.copyBufferToBuffer(o,0,a.gpuData.buffer,0,i),this.backend.device.queue.submit([c.finish()]),o.destroy(),cr("verbose",()=>`[WebGPU] GpuDataManager.upload(id=${t})`)}memcpy(t,e){let n=this.storageCache.get(t);if(!n)throw new Error("source gpu data for memcpy does not exist");let s=this.storageCache.get(e);if(!s)throw new Error("destination gpu data for memcpy does not exist");if(n.originalSize!==s.originalSize)throw new Error("inconsistent source and destination gpu data size");let r=Hk(n.originalSize),i=this.backend.getCommandEncoder();this.backend.endComputePass(),i.copyBufferToBuffer(n.gpuData.buffer,0,s.gpuData.buffer,0,r)}registerExternalBuffer(t,e,n){let s;if(n){if(s=n[0],t===n[1])return cr("verbose",()=>`[WebGPU] GpuDataManager.registerExternalBuffer(size=${e}) => id=${s}, buffer is the same, skip.`),s;if(this.backend.capturedCommandList.has(this.backend.currentSessionId))throw new Error(`Registering a different external buffer under graph capture mode is not supported yet.
3847             Please use the previous external buffer!`)}else s=x$();return this.storageCache.set(s,{gpuData:{id:s,type:0,buffer:t},originalSize:e}),cr("verbose",()=>`[WebGPU] GpuDataManager.registerExternalBuffer(size=${e}) => id=${s}, registered.`),s}unregisterExternalBuffer(t){t!==void 0&&(this.storageCache.delete(t),cr("verbose",()=>`[WebGPU] GpuDataManager.unregisterExternalBuffer() => id=${t}`))}create(t,e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST){let n=Fz(t),s,r=(e&GPUBufferUsage.STORAGE)===GPUBufferUsage.STORAGE,i=(e&GPUBufferUsage.UNIFORM)===GPUBufferUsage.UNIFORM;if(r||i){let o=(r?this.freeBuffers:this.freeUniformBuffers).get(n);o?o.length>0?s=o.pop():s=this.backend.device.createBuffer({size:n,usage:e}):s=this.backend.device.createBuffer({size:n,usage:e})}else s=this.backend.device.createBuffer({size:n,usage:e});let a={id:x$(),type:0,buffer:s};return this.storageCache.set(a.id,{gpuData:a,originalSize:Number(t)}),cr("verbose",()=>`[WebGPU] GpuDataManager.create(size=${t}) => id=${a.id}`),a}get(t){var e;return(e=this.storageCache.get(t))==null?void 0:e.gpuData}release(t){let e=typeof t=="bigint"?Number(t):t,n=this.storageCache.get(e);if(!n){if(this.storageCache.size===0)return 0;throw new Error("releasing data does not exist")}return cr("verbose",()=>`[WebGPU] GpuDataManager.release(id=${e}), gpuDataId=${n.gpuData.id}`),this.storageCache.delete(e),this.buffersPending.push(n.gpuData.buffer),n.originalSize}async download(t,e){let n=this.storageCache.get(Number(t));if(!n)throw new Error("data does not exist");await WD(this.backend,n.gpuData.buffer,n.originalSize,e)}refreshPendingBuffers(){if(this.buffersPending.length!==0)if(this.backend.sessionStatus==="default"){for(let t of this.buffersPending){let e=y$.get(t.size);if((t.usage&GPUBufferUsage.STORAGE)===GPUBufferUsage.STORAGE){let n=this.freeBuffers.get(t.size)||[];e===void 0||n.length>=e?t.destroy():n.push(t)}else if((t.usage&GPUBufferUsage.UNIFORM)===GPUBufferUsage.UNIFORM){let n=this.freeUniformBuffers.get(t.size)||[];e===void 0||n.length>=e?t.destroy():n.push(t)}else t.destroy()}this.buffersPending=[]}else{let t=this.capturedPendingBuffers.get(this.backend.currentSessionId);t||(t=[],this.capturedPendingBuffers.set(this.backend.currentSessionId,t));for(let e of this.buffersPending)t.push(e);this.buffersPending=[]}}dispose(){this.freeBuffers.forEach(t=>{t.forEach(e=>{e.destroy()})}),this.freeUniformBuffers.forEach(t=>{t.forEach(e=>{e.destroy()})}),this.storageCache.forEach(t=>{t.gpuData.buffer.destroy()}),this.capturedPendingBuffers.forEach(t=>{t.forEach(e=>{e.destroy()})}),this.storageCache=new Map,this.freeBuffers=new Map,this.freeUniformBuffers=new Map,this.capturedPendingBuffers=new Map}onCreateSession(){this.sessionCount+=1}onReleaseSession(t){let e=this.capturedPendingBuffers.get(t);e&&(e.forEach(n=>{n.destroy()}),this.capturedPendingBuffers.delete(t)),this.sessionCount-=1,this.sessionCount===0&&(cr("warning",()=>"[WebGPU] Clearing webgpu buffer cache"),this.storageCache.forEach(n=>{n.gpuData.buffer.destroy()}),this.storageCache=new Map)}},BZ=(...t)=>new zz(...t)}),Gz,Rr,na=qt(()=>{Gz=class{constructor(t){Object.assign(this,t)}get cacheKey(){return this.key||(this.key=Object.getOwnPropertyNames(this).sort().map(t=>`${this[t]}`).join(";")),this.key}},Rr=t=>new Gz(t)}),W1,qk,lo,ml,Mn,Wi,KD,ow,H0,An,V2,St,wn,UZ,K7,Hz,FZ,Rs=qt(()=>{ts(),Ts(),W1=64,qk=(t,e)=>{if(e===3)throw new Error("vec3 has same alignment as vec4, use vec4 instead");switch(Number(t)){case 10:return e>1?`vec${e}<f16>`:"f16";case 1:return e>1?`vec${e}<f32>`:"f32";case 6:return e>1?`vec${e}<i32>`:"i32";case 12:return e>1?`vec${e}<u32>`:"u32";case 7:if(e>1)throw new Error("currently not supported vecX of uint64 yet");return["vec2<u32>","i32"];case 13:if(e>1)throw new Error("currently not supported vecX of uint64 yet");return["vec2<u32>","u32"];case 9:if(e!==4)throw new Error("bool must be vec4");return["u32","vec4<bool>"];case 22:return"i32";case 21:return"u32";default:throw new Error(`Unknown data type: ${t}`)}},lo=(t,e=1)=>{let n=qk(t,e);return typeof n=="string"?n:n[0]},ml=(t,e=1)=>{let n=qk(t,e);return typeof n=="string"?n:n[1]},Mn=(...t)=>{let e=[];return t.forEach(n=>{n.length!==0&&e.push({type:12,data:n},{type:12,data:dt.computeStrides(n)})}),e},Wi=t=>t%4===0?4:t%2===0?2:1,KD=(t="f32",e,n="0")=>!e||e===1?`${t}(${n})`:`vec${e}<${t}>(${n})`,ow=(t,e,n)=>t==="f32"?n:e===1?`f32(${n})`:`vec${e}<f32>(${n})`,H0=(t,e)=>e===4?`(${t}.x + ${t}.y + ${t}.z + ${t}.w)`:e===2?`(${t}.x + ${t}.y)`:e===3?`(${t}.x + ${t}.y + ${t}.z)`:t,An=(t,e,n,s)=>t.startsWith("uniforms.")&&n>4?typeof e=="string"?s==="f16"?`${t}[(${e}) / 8][(${e}) % 8 / 4][(${e}) % 8 % 4]`:`${t}[(${e}) / 4][(${e}) % 4]`:s==="f16"?`${t}[${Math.floor(e/8)}][${Math.floor(e%8/4)}][${e%8%4}]`:`${t}[${Math.floor(e/4)}][${e%4}]`:n>1?`${t}[${e}]`:t,V2=(t,e,n,s,r)=>{let i=typeof n=="number",a=i?n:n.length,o=[...new Array(a).keys()],l=a<2?"u32":a<=4?`vec${a}<u32>`:`array<u32, ${a}>`,c=qk(e,r),h=typeof c=="string"?c:c[1],p=typeof c=="string"?c:c[0],m={indices:l,value:h,storage:p,tensor:e},y=ie=>typeof ie=="string"?ie:`${ie}u`,v={offsetToIndices:!1,indicesToOffset:!1,broadcastedIndicesToOffset:!1,set:!1,setByIndices:!1,get:!1,getByIndices:!1},b=i?"uniforms.":"",S=`${b}${t}_shape`,E=`${b}${t}_strides`,I="";for(let ie=0;ie<a-1;ie++)I+=`
3848    let dim${ie} = current / ${An(E,ie,a)};
3849    let rest${ie} = current % ${An(E,ie,a)};
3850    indices[${ie}] = dim${ie};
3851    current = rest${ie};
3852    `;I+=`indices[${a-1}] = current;`;let M=a<2?"":`
3853  fn o2i_${t}(offset: u32) -> ${m.indices} {
3854    var indices: ${m.indices};
3855    var current = offset;
3856    ${I}
3857    return indices;
3858  }`,j=ie=>(v.offsetToIndices=!0,a<2?ie:`o2i_${t}(${ie})`),L=[];if(a>=2)for(let ie=a-1;ie>=0;ie--)L.push(`${An(E,ie,a)} * (indices[${ie}])`);let K=a<2?"":`
3859  fn i2o_${t}(indices: ${m.indices}) -> u32 {
3860    return ${L.join("+")};
3861  }`,D=ie=>(v.indicesToOffset=!0,a<2?ie:`i2o_${t}(${ie})`),R=(...ie)=>a===0?"0u":`${m.indices}(${ie.map(y).join(",")})`,B=(ie,de)=>a<2?`${ie}`:`${An(ie,de,a)}`,G=(ie,de,Re)=>a<2?`${ie}=${Re};`:`${An(ie,de,a)}=${Re};`,X={},H=(ie,de)=>{v.broadcastedIndicesToOffset=!0;let Re=`${de.name}broadcastedIndicesTo${t}Offset`;if(Re in X)return`${Re}(${ie})`;let Se=[];for(let De=a-1;De>=0;De--){let gt=de.indicesGet("outputIndices",De+de.rank-a);Se.push(`${B(E,De)} * (${gt} % ${B(S,De)})`)}return X[Re]=`fn ${Re}(outputIndices: ${de.type.indices}) -> u32 {
3862             return ${Se.length>0?Se.join("+"):"0u"};
3863           }`,`${Re}(${ie})`},Y=(ie,de)=>(()=>{if(m.storage===m.value)return`${t}[${ie}]=${de};`;if(m.storage==="vec2<u32>"&&m.value==="i32")return`${t}[${ie}]=vec2<u32>(u32(${de}), select(0u, 0xFFFFFFFFu, ${de} < 0));`;if(m.storage==="vec2<u32>"&&m.value==="u32")return`${t}[${ie}]=vec2<u32>(u32(${de}), 0u);`;if(m.storage==="u32"&&m.value==="vec4<bool>")return`${t}[${ie}]=dot(vec4<u32>(0x1, 0x100, 0x10000, 0x1000000), vec4<u32>(${de}));`;throw new Error(`not supported combination of storage type ${m.storage} and value type ${m.value} yet`)})(),F=ie=>(()=>{if(m.storage===m.value)return`${t}[${ie}]`;if(m.storage==="vec2<u32>"&&m.value==="i32")return`i32(${t}[${ie}].x)`;if(m.storage==="vec2<u32>"&&m.value==="u32")return`u32(${t}[${ie}].x)`;if(m.storage==="u32"&&m.value==="vec4<bool>")return`vec4<bool>(bool(${t}[${ie}] & 0xFFu), bool(${t}[${ie}] & 0xFF00u), bool(${t}[${ie}] & 0xFF0000u), bool(${t}[${ie}] & 0xFF000000u))`;throw new Error(`not supported combination of storage type ${m.storage} and value type ${m.value} yet`)})(),we=a<2?"":`
3864  fn get_${t}ByIndices(indices: ${m.indices}) -> ${h} {
3865    return ${F(`i2o_${t}(indices)`)};
3866  }`,me=a<2?"":(()=>{let ie=o.map(Re=>`d${Re}: u32`).join(", "),de=o.map(Re=>`d${Re}`).join(", ");return`
3867  fn get_${t}(${ie}) -> ${h} {
3868    return get_${t}ByIndices(${R(de)});
3869  }`})(),xe=(...ie)=>{if(ie.length!==a)throw new Error(`indices length must be ${a}`);let de=ie.map(y).join(",");return a===0?F("0u"):a===1?F(de[0]):(v.get=!0,v.getByIndices=!0,v.indicesToOffset=!0,`get_${t}(${de})`)},Le=ie=>a<2?F(ie):(v.getByIndices=!0,v.indicesToOffset=!0,`get_${t}ByIndices(${ie})`),ve=a<2?"":`
3870  fn set_${t}ByIndices(indices: ${m.indices}, value: ${h}) {
3871    ${Y(`i2o_${t}(indices)`,"value")}
3872  }`,ce=a<2?"":(()=>{let ie=o.map(Re=>`d${Re}: u32`).join(", "),de=o.map(Re=>`d${Re}`).join(", ");return`
3873  fn set_${t}(${ie}, value: ${h}) {
3874    set_${t}ByIndices(${R(de)}, value);
3875  }`})();return{impl:()=>{let ie=[],de=!1;return v.offsetToIndices&&(ie.push(M),de=!0),v.indicesToOffset&&(ie.push(K),de=!0),v.broadcastedIndicesToOffset&&(Object.values(X).forEach(Re=>ie.push(Re)),de=!0),v.set&&(ie.push(ce),de=!0),v.setByIndices&&(ie.push(ve),de=!0),v.get&&(ie.push(me),de=!0),v.getByIndices&&(ie.push(we),de=!0),!i&&de&&ie.unshift(`const ${S} = ${m.indices}(${n.join(",")});`,`const ${E} = ${m.indices}(${dt.computeStrides(n).join(",")});`),ie.join(`
3876`)},type:m,offsetToIndices:j,indicesToOffset:D,broadcastedIndicesToOffset:H,indices:R,indicesGet:B,indicesSet:G,set:(...ie)=>{if(ie.length!==a+1)throw new Error(`indices length must be ${a}`);let de=ie[a];if(typeof de!="string")throw new Error("value must be string");let Re=ie.slice(0,a).map(y).join(",");return a===0?Y("0u",de):a===1?Y(Re[0],de):(v.set=!0,v.setByIndices=!0,v.indicesToOffset=!0,`set_${t}(${Re}, ${de})`)},setByOffset:Y,setByIndices:(ie,de)=>a<2?Y(ie,de):(v.setByIndices=!0,v.indicesToOffset=!0,`set_${t}ByIndices(${ie}, ${de});`),get:xe,getByOffset:F,getByIndices:Le,usage:s,name:t,strides:E,shape:S,rank:a}},St=(t,e,n,s=1)=>V2(t,e,n,"input",s),wn=(t,e,n,s=1)=>V2(t,e,n,"output",s),UZ=(t,e,n)=>V2(t,e,n,"atomicOutput",1),K7=(t,e,n,s=1)=>V2(t,e,n,"internal",s),Hz=class{constructor(t,e){this.normalizedDispatchGroup=t,this.limits=e,this.internalVariables=[],this.variables=[],this.uniforms=[],this.variableIndex=0}guardAgainstOutOfBoundsWorkgroupSizes(t){return`if (global_idx >= ${typeof t=="number"?`${t}u`:t}) { return; }`}mainStart(t=W1){let e=typeof t=="number"?t:t[0],n=typeof t=="number"?1:t[1],s=typeof t=="number"?1:t[2];if(e>this.limits.maxComputeWorkgroupSizeX||n>this.limits.maxComputeWorkgroupSizeY||s>this.limits.maxComputeWorkgroupSizeZ)throw new Error(`workgroup size [${e}, ${n}, ${s}] exceeds the maximum workgroup size [${this.limits.maxComputeWorkgroupSizeX}, ${this.limits.maxComputeWorkgroupSizeY}, ${this.limits.maxComputeWorkgroupSizeZ}].`);if(e*n*s>this.limits.maxComputeInvocationsPerWorkgroup)throw new Error(`workgroup size [${e}, ${n}, ${s}] exceeds the maximum workgroup invocations ${this.limits.maxComputeInvocationsPerWorkgroup}.`);let r=this.normalizedDispatchGroup[1]===1&&this.normalizedDispatchGroup[2]===1,i=r?`@builtin(global_invocation_id) global_id : vec3<u32>,
3877    @builtin(workgroup_id) workgroup_id : vec3<u32>,
3878    @builtin(local_invocation_index) local_idx : u32,
3879    @builtin(local_invocation_id) local_id : vec3<u32>`:`@builtin(global_invocation_id) global_id : vec3<u32>,
3880                                             @builtin(local_invocation_id) local_id : vec3<u32>,
3881    @builtin(local_invocation_index) local_idx : u32,
3882    @builtin(workgroup_id) workgroup_id : vec3<u32>,
3883    @builtin(num_workgroups) num_workgroups : vec3<u32>`,a=r?`let global_idx = global_id.x;
3884         let workgroup_index = workgroup_id.x;`:`let workgroup_index = workgroup_id.z * num_workgroups[0] * num_workgroups[1] +
3885             workgroup_id.y * num_workgroups[0] + workgroup_id.x;
3886         let global_idx = workgroup_index * ${e*n*s}u + local_idx;`;return`@compute @workgroup_size(${e}, ${n}, ${s})
3887  fn main(${i}) {
3888    ${a}
3889  `}appendVariableUniforms(t){t.rank!==0&&(t.shape.startsWith("uniforms.")&&this.uniforms.push({name:t.shape.replace("uniforms.",""),type:"u32",length:t.rank}),t.strides.startsWith("uniforms.")&&this.uniforms.push({name:t.strides.replace("uniforms.",""),type:"u32",length:t.rank}))}declareVariable(t,e){if(t.usage==="internal")throw new Error("cannot use internal variable with declareVariable(). use registerInternalVariables() instead.");this.variables.push(t),this.appendVariableUniforms(t);let n=t.usage==="input"?"read":"read_write",s=t.usage==="atomicOutput"?"atomic<i32>":t.type.storage;return`@group(0) @binding(${e}) var<storage, ${n}> ${t.name}: array<${s}>;`}declareVariables(...t){return t.map(e=>this.declareVariable(e,this.variableIndex++)).join(`
3890`)}registerInternalVariable(t){if(t.usage!=="internal")throw new Error("cannot use input or output variable with registerInternalVariable(). use declareVariables() instead.");this.internalVariables.push(t),this.appendVariableUniforms(t)}registerInternalVariables(...t){return t.forEach(e=>this.registerInternalVariable(e)),this}registerUniform(t,e,n=1){return this.uniforms.push({name:t,type:e,length:n}),this}registerUniforms(t){return this.uniforms=this.uniforms.concat(t),this}uniformDeclaration(){if(this.uniforms.length===0)return"";let t=[];for(let{name:e,type:n,length:s}of this.uniforms)if(s&&s>4)n==="f16"?t.push(`@align(16) ${e}:array<mat2x4<${n}>, ${Math.ceil(s/8)}>`):t.push(`${e}:array<vec4<${n}>, ${Math.ceil(s/4)}>`);else{let r=s==null||s===1?n:`vec${s}<${n}>`;t.push(`${e}:${r}`)}return`
3891      struct Uniforms { ${t.join(", ")} };
3892      @group(0) @binding(${this.variableIndex}) var<uniform> uniforms: Uniforms;`}get additionalImplementations(){return this.uniformDeclaration()+this.variables.map(t=>t.impl()).join(`
3893`)+this.internalVariables.map(t=>t.impl()).join(`
3894`)}get variablesInfo(){if(this.uniforms.length===0)return;let t=e=>[12,10,1,6][["u32","f16","f32","i32"].indexOf(e)];return this.uniforms.map(e=>[t(e.type),e.length??1])}},FZ=(t,e)=>new Hz(t,e)}),qz,v$,Wz,Kz,Yz,Xz,Ru,VZ,zZ,ty=qt(()=>{ts(),Ts(),na(),Rs(),qz=(t,e)=>{if(!t||t.length!==1)throw new Error("Transpose requires 1 input.");if(e.length!==0&&e.length!==t[0].dims.length)throw new Error(`perm size ${e.length} does not match input rank ${t[0].dims.length}`)},v$=(t,e)=>e.length!==0?e:[...new Array(t).keys()].reverse(),Wz=(t,e)=>dt.sortBasedOnPerm(t,v$(t.length,e)),Kz=(t,e,n,s)=>{let r=`fn perm(i: ${s.type.indices}) -> ${n.type.indices} {
3895    var a: ${n.type.indices};`;for(let i=0;i<e;++i)r+=`a[${t[i]}]=i[${i}];`;return r+="return a;}"},Yz=(t,e)=>{let n=[],s=[];for(let r=0;r<t.length;++r)t[r]!==1&&n.push(t[r]),t[e[r]]!==1&&s.push(e[r]);return{newShape:n,newPerm:s}},Xz=(t,e)=>{let n=0;for(let s=0;s<t.length;++s)if(e[t[s]]!==1){if(t[s]<n)return!1;n=t[s]}return!0},Ru=(t,e)=>{let n=t.dataType,s=t.dims.length,r=v$(s,e),i=Wz(t.dims,r),a=t.dims,o=i,l=s<2||Xz(r,t.dims),c;if(l)return c=v=>{let b=St("input",n,a,4),S=wn("output",n,o,4);return`
3896  ${v.registerUniform("output_size","u32").declareVariables(b,S)}
3897  ${v.mainStart()}
3898    ${v.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
3899    output[global_idx] = input[global_idx];
3900  }`},{name:"TransposeCopy",shaderCache:{inputDependencies:["type"]},getRunData:()=>{let v=dt.size(i);return{outputs:[{dims:i,dataType:t.dataType}],dispatchGroup:{x:Math.ceil(v/64/4)},programUniforms:[{type:12,data:Math.ceil(v/4)}]}},getShaderSource:c};let{newShape:h,newPerm:p}=Yz(t.dims,r),m=dt.areEqual(p,[2,3,1]),y=dt.areEqual(p,[3,1,2]);if(h.length===2||m||y){a=m?[h[0],h[1]*h[2]]:y?[h[0]*h[1],h[2]]:h,o=[a[1],a[0]];let v=16;return c=b=>{let S=St("a",n,a.length),E=wn("output",n,o.length);return`
3901  ${b.registerUniform("output_size","u32").declareVariables(S,E)}
3902  var<workgroup> tile : array<array<${E.type.value}, ${v+1}>, ${v}>;
3903  ${b.mainStart([v,v,1])}
3904    let stride = (uniforms.output_shape[1] - 1) / ${v} + 1;
3905    let workgroup_id_x = workgroup_index % stride;
3906    let workgroup_id_y = workgroup_index / stride;
3907    let input_col = workgroup_id_y * ${v}u + local_id.x;
3908    let input_row = workgroup_id_x * ${v}u + local_id.y;
3909    if (input_row < uniforms.a_shape[0] && input_col < uniforms.a_shape[1]) {
3910      tile[local_id.y][local_id.x] = ${S.getByIndices(`${S.type.indices}(input_row, input_col)`)};
3911    }
3912    workgroupBarrier();
3913
3914    let output_col = workgroup_id_x * ${v}u + local_id.x;
3915    let output_row = workgroup_id_y * ${v}u + local_id.y;
3916    if (output_row < uniforms.output_shape[0] && output_col < uniforms.output_shape[1]) {
3917      ${E.setByIndices(`${E.type.indices}(output_row, output_col)`,"tile[local_id.x][local_id.y]")}
3918    }
3919  }`},{name:"TransposeShared",shaderCache:{inputDependencies:["type"]},getRunData:()=>{let b=dt.size(i);return{outputs:[{dims:i,dataType:t.dataType}],dispatchGroup:{x:Math.ceil(o[1]/v),y:Math.ceil(o[0]/v)},programUniforms:[{type:12,data:b},...Mn(a,o)]}},getShaderSource:c}}return c=v=>{let b=St("a",n,a.length),S=wn("output",n,o.length);return`
3920  ${v.registerUniform("output_size","u32").declareVariables(b,S)}
3921
3922  ${Kz(r,s,b,S)}
3923
3924  ${v.mainStart()}
3925    ${v.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
3926
3927    let indices = ${S.offsetToIndices("global_idx")};
3928    let aIndices = perm(indices);
3929
3930    ${S.setByOffset("global_idx",b.getByIndices("aIndices"))}
3931  }`},{name:"Transpose",shaderCache:{hint:`${e}`,inputDependencies:["rank"]},getRunData:()=>{let v=dt.size(i);return{outputs:[{dims:i,dataType:t.dataType}],dispatchGroup:{x:Math.ceil(v/64)},programUniforms:[{type:12,data:v},...Mn(a,o)]}},getShaderSource:c}},VZ=(t,e)=>{qz(t.inputs,e.perm),t.compute(Ru(t.inputs[0],e.perm))},zZ=t=>Rr({perm:t.perm})}),Jz,Qz,Zz,e8,t8,n8,s8,r8,i8,a8,ph,GZ,HZ,qZ,WZ,KZ,YZ,XZ,JZ,QZ,ZZ,TAe=qt(()=>{ts(),Ts(),Rs(),Y7(),ty(),Jz={max:"select(bestValue, candidate, candidate > bestValue)",min:"select(bestValue, candidate, candidate < bestValue)",mean:"bestValue + candidate",sum:"bestValue + candidate",prod:"bestValue * candidate",sumSquare:"bestValue + candidate * candidate",logSumExp:"bestValue + exp(candidate)",l1:"bestValue + abs(candidate)",l2:"bestValue + candidate * candidate",logSum:"bestValue + candidate"},Qz={max:"select(bestValue, candidate, candidate > bestValue)",min:"select(bestValue, candidate, candidate < bestValue)",mean:"bestValue + candidate",sum:"bestValue + candidate",prod:"bestValue * candidate",sumSquare:"bestValue + candidate",logSumExp:"bestValue + candidate",l1:"bestValue + candidate",l2:"bestValue + candidate",logSum:"bestValue + candidate"},Zz={max:"_A[offset]",min:"_A[offset]",mean:"0",sum:"0",prod:"1",sumSquare:"0",logSumExp:"0",l1:"0",l2:"0",logSum:"0"},e8={max:"bestValue",min:"bestValue",sum:"bestValue",prod:"bestValue",sumSquare:"bestValue",logSumExp:"log(bestValue)",l1:"bestValue",l2:"sqrt(bestValue)",logSum:"log(bestValue)"},t8=(t,e)=>{let n=[];for(let s=e-t;s<e;++s)n.push(s);return n},n8=(t,e)=>{let n=[],s=t.length;for(let i=0;i<s;i++)e.indexOf(i)===-1&&n.push(t[i]);let r=e.map(i=>t[i]);return[n,r]},s8=(t,e)=>{let n=t.length+e.length,s=[],r=0;for(let i=0;i<n;i++)e.indexOf(i)===-1?s.push(t[r++]):s.push(1);return s},r8=(t,e)=>{for(let n=0;n<t.length;++n)if(t[t.length-n-1]!==e-1-n)return!1;return!0},i8=(t,e)=>{let n=[];if(!r8(t,e)){for(let s=0;s<e;++s)t.indexOf(s)===-1&&n.push(s);t.forEach(s=>n.push(s))}return n},a8=(t,e,n,s,r,i,a)=>{let o=n[0].dims,l=dt.size(i),c=dt.size(a),h=St("_A",n[0].dataType,o),p=wn("output",r,i),m=64;l===1&&(m=256);let y=`
3932          var<workgroup> aBestValues : array<f32, ${m}>;
3933       `,v=b=>`
3934        ${b.registerUniform("reduceSize","u32").declareVariables(h,p)}
3935        ${y}
3936        fn DIV_CEIL(a : u32, b : u32) -> u32 {
3937          return ((a - 1u) / b + 1u);
3938         }
3939         ${b.mainStart(m)}
3940
3941          let outputIndex = global_idx / ${m};
3942          let offset = outputIndex * uniforms.reduceSize;
3943
3944          var bestValue = f32(${Zz[s]});
3945          let Length = uniforms.reduceSize;
3946          for (var k = local_idx; k < Length; k = k + ${m}) {
3947           let candidate = f32(${h.getByOffset("offset + k")});
3948           bestValue = ${Jz[s]};
3949          }
3950          aBestValues[local_idx] = bestValue;
3951          workgroupBarrier();
3952
3953         var reduceSize = min(Length, ${m}u);
3954         for (var currentSize = reduceSize / 2u; reduceSize > 1u;
3955             currentSize = reduceSize / 2u) {
3956           let interval = DIV_CEIL(reduceSize, 2u);
3957           if (local_idx < currentSize) {
3958            let candidate = aBestValues[local_idx + interval];
3959            bestValue = ${Qz[s]};
3960            aBestValues[local_idx] = bestValue;
3961           }
3962           reduceSize = interval;
3963           workgroupBarrier();
3964         }
3965
3966         if (local_idx == 0u) {
3967          ${p.setByOffset("outputIndex",`${s==="mean"?`${p.type.storage}(bestValue / f32(uniforms.reduceSize))`:`${p.type.storage}(${e8[s]})`}`)};
3968         }
3969        }`;return{name:t,shaderCache:{hint:`${e};${m}`,inputDependencies:["type"]},getShaderSource:v,getRunData:()=>({outputs:[{dims:i,dataType:r}],dispatchGroup:{x:l},programUniforms:[{type:12,data:c}]})}},ph=(t,e,n,s)=>{let r=t.inputs.length===1?n:YD(t.inputs,n),i=r.axes;i.length===0&&!r.noopWithEmptyAxes&&(i=t.inputs[0].dims.map((y,v)=>v));let a=dt.normalizeAxes(i,t.inputs[0].dims.length),o=a,l=t.inputs[0],c=i8(o,t.inputs[0].dims.length);c.length>0&&(l=t.compute(Ru(t.inputs[0],c),{inputs:[0],outputs:[-1]})[0],o=t8(o.length,l.dims.length));let[h,p]=n8(l.dims,o),m=h;
3969r.keepDims&&(m=s8(h,a)),t.compute(a8(e,r.cacheKey,[l],s,t.inputs[0].dataType,m,p),{inputs:[l]})},GZ=(t,e)=>{ph(t,"ReduceMeanShared",e,"mean")},HZ=(t,e)=>{ph(t,"ReduceL1Shared",e,"l1")},qZ=(t,e)=>{ph(t,"ReduceL2Shared",e,"l2")},WZ=(t,e)=>{ph(t,"ReduceLogSumExpShared",e,"logSumExp")},KZ=(t,e)=>{ph(t,"ReduceMaxShared",e,"max")},YZ=(t,e)=>{ph(t,"ReduceMinShared",e,"min")},XZ=(t,e)=>{ph(t,"ReduceProdShared",e,"prod")},JZ=(t,e)=>{ph(t,"ReduceSumShared",e,"sum")},QZ=(t,e)=>{ph(t,"ReduceSumSquareShared",e,"sumSquare")},ZZ=(t,e)=>{ph(t,"ReduceLogSumShared",e,"logSum")}}),mh,o8,cR,YD,gh,l8,c8,u8,d8,h8,f8,p8,m8,g8,y8,yh,eee,tee,nee,see,ree,iee,aee,oee,lee,cee,Y7=qt(()=>{ts(),Ts(),na(),Rs(),TAe(),mh=t=>{if(!t||t.length===0||t.length>2)throw new Error("Reduce op requires 1 or 2 inputs.");if(t.length===2&&t[1].dims.length!==1)throw new Error("Invalid axes input dims.")},o8=t=>["","",`var value = ${t.getByIndices("input_indices")};`,""],cR=(t,e,n,s,r,i,a=!1,o=!1)=>{let l=[],c=n[0].dims,h=c.length,p=dt.normalizeAxes(r,h),m=!o&&p.length===0;
vendor: 10,118 bytes, lines 3969-4015
3969c.forEach((b,S)=>{m||p.indexOf(S)>=0?a&&l.push(1):l.push(b)});let y=l.length,v=dt.size(l);return{name:t,shaderCache:e,getShaderSource:b=>{let S=[],E=St("_A",n[0].dataType,h),I=wn("output",i,y),M=s(E,I,p),j=M[2];for(let L=0,K=0;L<h;L++)m||p.indexOf(L)>=0?(a&&K++,j=`for(var j${L}: u32 = 0; j${L} < ${c[L]}; j${L}++) {
3970                  ${M[2].includes("last_index")?`let last_index = j${L};`:""}
3971                  ${E.indicesSet("input_indices",L,`j${L}`)}
3972                  ${j}
3973                }`):(S.push(`${E.indicesSet("input_indices",L,I.indicesGet("output_indices",K))};`),K++);return`
3974
3975        ${b.registerUniform("output_size","u32").declareVariables(E,I)}
3976
3977        ${b.mainStart()}
3978          ${b.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
3979          var input_indices: ${E.type.indices};
3980          let output_indices = ${I.offsetToIndices("global_idx")};
3981
3982          ${S.join(`
3983`)}
3984          ${M[0]}       // init ops for reduce max/min
3985          ${M[1]}
3986          ${j}
3987          ${M[3]}
3988          ${M.length===4?I.setByOffset("global_idx","value"):M.slice(4).join(`
3989`)}
3990        }`},getRunData:()=>({outputs:[{dims:l,dataType:i}],dispatchGroup:{x:Math.ceil(v/64)},programUniforms:[{type:12,data:v},...Mn(c,l)]})}},YD=(t,e)=>{let n=[];return t[1].dims[0]>0&&t[1].getBigInt64Array().forEach(s=>n.push(Number(s))),Rr({axes:n,keepDims:e.keepDims,noopWithEmptyAxes:e.noopWithEmptyAxes})},gh=(t,e,n,s)=>{let r=t.inputs,i=r.length===1?n:YD(r,n);t.compute(cR(e,{hint:i.cacheKey,inputDependencies:["rank"]},[r[0]],i.noopWithEmptyAxes&&i.axes.length===0?o8:s,i.axes,r[0].dataType,i.keepDims,i.noopWithEmptyAxes),{inputs:[0]})},l8=(t,e)=>{mh(t.inputs),gh(t,"ReduceLogSum",e,(n,s)=>[`var value = ${s.type.storage}(0);`,"",`value += ${n.getByIndices("input_indices")};`,"value = log(value);"])},c8=(t,e)=>{mh(t.inputs),gh(t,"ReduceL1",e,(n,s)=>[`var value = ${s.type.storage}(0);`,"",`value += abs(${n.getByIndices("input_indices")});`,""])},u8=(t,e)=>{mh(t.inputs),gh(t,"ReduceL2",e,(n,s)=>[`var t = ${s.type.value}(0); var value = ${s.type.value}(0);`,"",`t = ${n.getByIndices("input_indices")}; value += (t * t);`,"value = sqrt(value);"])},d8=(t,e)=>{mh(t.inputs),gh(t,"ReduceLogSumExp",e,(n,s)=>[`var value = ${s.type.storage}(0);`,"",`value += exp(${n.getByIndices("input_indices")});`,"value = log(value);"])},h8=(t,e)=>{mh(t.inputs),gh(t,"ReduceMax",e,(n,s,r)=>{let i=[];for(let a=0;a<n.rank;a++)(r.indexOf(a)>=0||r.length===0)&&i.push(n.indicesSet("input_indices",a,0));return[`${i.join(`
3991`)}`,`var value = ${n.getByIndices("input_indices")};`,`value = max(value, ${n.getByIndices("input_indices")});`,""]})},f8=(t,e)=>{mh(t.inputs),gh(t,"ReduceMean",e,(n,s,r)=>{let i=1;for(let a=0;a<n.rank;a++)(r.indexOf(a)>=0||r.length===0)&&(i*=t.inputs[0].dims[a]);return["var sum = f32(0);","",`sum += f32(${n.getByIndices("input_indices")});`,`let value = ${s.type.value}(sum / ${i});`]})},p8=(t,e)=>{mh(t.inputs),gh(t,"ReduceMin",e,(n,s,r)=>{let i=[];for(let a=0;a<n.rank;a++)(r.indexOf(a)>=0||r.length===0)&&i.push(`input_indices[${a}] = 0;`);return[`${i.join(`
3992`)}`,`var value = ${n.getByIndices("input_indices")};`,`value = min(value, ${n.getByIndices("input_indices")});`,""]})},m8=(t,e)=>{mh(t.inputs),gh(t,"ReduceProd",e,(n,s)=>[`var value = ${s.type.storage}(1);`,"",`value *= ${n.getByIndices("input_indices")};`,""])},g8=(t,e)=>{mh(t.inputs),gh(t,"ReduceSum",e,(n,s)=>[`var value = ${s.type.storage}(0);`,"",`value += ${n.getByIndices("input_indices")};`,""])},y8=(t,e)=>{mh(t.inputs),gh(t,"ReduceSumSquare",e,(n,s)=>[`var t = ${s.type.value}(0); var value = ${s.type.value}(0);`,"",`t = ${n.getByIndices("input_indices")}; value += t * t;`,""])},yh=(t,e,n)=>{if(e.length===0)return n;let s=1,r=1;for(let i=0;i<e.length;i++)e.indexOf(i)===-1?s*=t[i]:r*=t[i];return r<32&&s>1024},eee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?f8(t,e):GZ(t,e)},tee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?c8(t,e):HZ(t,e)},nee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?u8(t,e):qZ(t,e)},see=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?d8(t,e):WZ(t,e)},ree=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?h8(t,e):KZ(t,e)},iee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?p8(t,e):YZ(t,e)},aee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?m8(t,e):XZ(t,e)},oee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?g8(t,e):JZ(t,e)},lee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?y8(t,e):QZ(t,e)},cee=(t,e)=>{yh(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?l8(t,e):ZZ(t,e)}}),b$,uee,dee,XD,AAe=qt(()=>{ts(),na(),Y7(),b$=t=>{if(!t||t.length===0||t.length>2)throw new Error("ArgMinMaxOp op requires 1 or 2 inputs.");if(t[0].dataType!==1)throw new Error("Invalid input type.")},uee=(t,e)=>{b$(t.inputs);let n=(s,r,i)=>{let a=[];for(let o=0;o<s.rank;o++)(i.indexOf(o)>=0||i.length===0)&&a.push(`input_indices[${o}] = 0;`);return[`${a.join(`
3993`)}`,`var value = ${s.getByIndices("input_indices")};
3994var best_index : i32 = 0;`,`if (${s.getByIndices("input_indices")} ${e.selectLastIndex>0?"<=":"<"} value) {
3995         value = ${s.getByIndices("input_indices")};
3996         best_index = i32(last_index);
3997       }`,"",r.setByOffset("global_idx","best_index")]};t.compute(cR("ArgMin",{hint:e.cacheKey,inputDependencies:["rank"]},[t.inputs[0]],n,[e.axis],7,e.keepDims),{inputs:[0]})},dee=(t,e)=>{b$(t.inputs);let n=(s,r,i)=>{let a=[];for(let o=0;o<s.rank;o++)(i.indexOf(o)>=0||i.length===0)&&a.push(`input_indices[${o}] = 0;`);return[`${a.join(`
3998`)}`,`var value = ${s.getByIndices("input_indices")};
3999var best_index : i32 = 0;`,`if (${s.getByIndices("input_indices")} ${e.selectLastIndex>0?">=":">"} value) {
4000         value = ${s.getByIndices("input_indices")};
4001         best_index = i32(last_index);
4002       }`,"",r.setByOffset("global_idx","best_index")]};t.compute(cR("argMax",{hint:e.cacheKey,inputDependencies:["rank"]},[t.inputs[0]],n,[e.axis],7,e.keepDims),{inputs:[0]})},XD=t=>Rr(t)}),x8,Wk,v8,b8,w8,AE,_8,hee,X7=qt(()=>{ts(),Ts(),W7(),Rs(),x8=(t,e)=>{let n=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5];if(a&&o)throw new Error("Attention cannot have both past and attention_bias");if(n.dims.length!==3)throw new Error('Input "input" must have 3 dimensions');let l=n.dims[0],c=n.dims[1],h=n.dims[2];if(r.dims.length!==1)throw new Error('Input "bias" is expected to have 1 dimensions');if(s.dims.length!==2)throw new Error('Input "weights" is expected to have 2 dimensions');if(s.dims[0]!==h)throw new Error("Input 1 dimension 0 should have same length as dimension 2 of input 0");if(r.dims[0]!==s.dims[1])throw new Error('Input "bias" dimension 0 should have same length as dimension 1 of input "weights"');let p=r.dims[0]/3,m=p,y=m;if(e.qkvHiddenSizes.length>0){if(e.qkvHiddenSizes.length!==3)throw new Error("qkv_hidden_sizes attribute should have 3 elements");for(let M of e.qkvHiddenSizes)if(M%e.numHeads!==0)throw new Error("qkv_hidden_sizes should be divisible by num_heads");p=e.qkvHiddenSizes[0],m=e.qkvHiddenSizes[1],y=e.qkvHiddenSizes[2]}let v=c;if(p!==m)throw new Error("qkv_hidden_sizes first element should be same as the second");if(r.dims[0]!==p+m+y)throw new Error('Input "bias" dimension 0 should have same length as sum of Q/K/V hidden sizes');let b=0;if(a){if(m!==y)throw new Error('Input "past" expect k_hidden_size == v_hidden_size');if(a.dims.length!==5)throw new Error('Input "past" must have 5 dimensions');if(a.dims[0]!==2)throw new Error('Input "past" first dimension must be 2');if(a.dims[1]!==l)throw new Error('Input "past" second dimension must be batch_size');if(a.dims[2]!==e.numHeads)throw new Error('Input "past" third dimension must be num_heads');if(a.dims[4]!==m/e.numHeads)throw new Error('Input "past" fifth dimension must be k_hidden_size / num_heads');e.pastPresentShareBuffer||(b=a.dims[3])}let S=v+b,E=-1,I=0;if(i)throw new Error("Mask not supported");if(a)throw new Error("past is not supported");if(o){if(o.dims.length!==4)throw new Error('Input "attention_bias" must have 4 dimensions');if(o.dims[0]!==l||o.dims[1]!==e.numHeads||o.dims[2]!==c||o.dims[3]!==S)throw new Error('Expect "attention_bias" shape (batch_size, num_heads, sequence_length, total_sequence_length)')}return{batchSize:l,sequenceLength:c,pastSequenceLength:b,kvSequenceLength:v,totalSequenceLength:S,maxSequenceLength:E,inputHiddenSize:h,hiddenSize:p,vHiddenSize:y,headSize:Math.floor(p/e.numHeads),vHeadSize:Math.floor(y/e.numHeads),numHeads:e.numHeads,isUnidirectional:!1,pastPresentShareBuffer:!1,maskFilterValue:e.maskFilterValue,maskType:I,scale:e.scale,broadcastResPosBias:!1,passPastInKv:!1,qkvFormat:1}},Wk=(t,e,n)=>e&&t?`
4003      let total_sequence_length_input = u32(${e.getByOffset("0")});
4004      let present_sequence_length = max(total_sequence_length_input, uniforms.past_sequence_length);
4005      let is_subsequent_prompt: bool = sequence_length > 1 && sequence_length != total_sequence_length_input;
4006      let is_first_prompt: bool = is_subsequent_prompt == false && sequence_length == total_sequence_length_input;
4007      total_sequence_length = u32(${t==null?void 0:t.getByOffset("batchIdx")}) + 1;
4008      var past_sequence_length: u32 = 0;
4009      if (is_first_prompt == false) {
4010        past_sequence_length = total_sequence_length - sequence_length;
4011      }
4012       `:`
4013    ${n?"let past_sequence_length = uniforms.past_sequence_length":""};
4014    let present_sequence_length = total_sequence_length;
4015    `,v8=(t,e,n,s,r,i,a,o)=>{let l=Wi(a?1:i),c=64,h=i/l;h<c&&(c=32);let p=Math.ceil(i/l/c),m=[{type:12,data:e},{type:12,data:n},{type:12,data:s},{type:12,data:r},{type:12,data:h},{type:12,data:p}],y=lo(t.dataType,l),v=ml(1,l),b=["type"];a&&b.push("type"),o&&b.push("type");let S=E=>{let I=wn("x",t.dataType,t.dims,l),M=[I],j=a?St("seq_lens",a.dataType,a.dims):void 0;j&&M.push(j);let L=o?St("total_sequence_length_input",o.dataType,o.dims):void 0;L&&M.push(L);let K=ml(t.dataType),D=[{name:"batch_size",type:"u32"},{name:"num_heads",type:"u32"},{name:"past_sequence_length",type:"u32"},{name:"sequence_length",type:"u32"},{name:"total_sequence_length",type:"u32"},{name:"elements_per_thread",type:"u32"}];return`
4016  var<workgroup> thread_max: array<f32, ${c}>;
4017  var<workgroup> thread_sum: array<f32, ${c}>;
4018  ${E.registerUniforms(D).declareVariables(...M)}
4019  ${E.mainStart([c,1,1])}
4020    let batchIdx = workgroup_id.z / uniforms.num_heads;
4021    let headIdx = workgroup_id.z % uniforms.num_heads;
4022    let sequence_length = uniforms.sequence_length;
4023    var total_sequence_length = uniforms.total_sequence_length;
4024    ${Wk(j,L,!1)}
4025    let local_offset = local_idx * uniforms.elements_per_thread;
4026    let offset = (global_idx / ${c}) * uniforms.total_sequence_length + local_offset;
4027    let seq_causal_length = ${a?"u32(past_sequence_length + workgroup_id.y + 1)":"total_sequence_length"};
4028    var thread_max_vector = ${v}(-3.4028234663852886e+38f);
4029    for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < seq_causal_length; i++) {
4030      thread_max_vector = max(${v}(x[offset + i]), thread_max_vector);
4031    }
4032    thread_max[local_idx] = ${(()=>{switch(l){case 1:return"thread_max_vector";case 2:return"max(thread_max_vector.x, thread_max_vector.y)";case 4:return"max(max(thread_max_vector.x, thread_max_vector.y), max(thread_max_vector.z, thread_max_vector.w))";default:throw new Error(`Unsupported components: ${l}`)}})()};
4033    workgroupBarrier();
4034
4035    var max_value =  f32(-3.4028234663852886e+38f);
4036    for (var i = 0u; i < ${c}; i++) {
4037      max_value = max(thread_max[i], max_value);
4038    }
4039
4040    var sum_vector = ${v}(0);
4041    for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < seq_causal_length; i++) {
4042      sum_vector += exp(${v}(x[offset + i]) - max_value);
4043    }
4044    thread_sum[local_idx] = ${(()=>{switch(l){case 1:return"sum_vector";case 2:return"sum_vector.x + sum_vector.y";case 4:return"sum_vector.x + sum_vector.y + sum_vector.z + sum_vector.w";default:throw new Error(`Unsupported components: ${l}`)}})()};
4045    workgroupBarrier();
4046
4047    var sum: f32 = 0;
4048    for (var i = 0u; i < ${c}; i++) {
4049      sum += thread_sum[i];
4050    }
4051
4052    if (sum == 0) {
4053      for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < seq_causal_length; i++) {
4054        x[offset + i] = ${I.type.value}(${K}(1.0) / ${K}(seq_causal_length));
4055      }
4056    } else {
4057      for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < seq_causal_length; i++) {
4058        var f32input = ${v}(x[offset + i]);
4059        x[offset + i] = ${I.type.value}(exp(f32input - max_value) / sum);
4060      }
4061    }
4062      ${a?`
4063        for (var total_seq_id: u32 = seq_causal_length; total_seq_id + local_offset < uniforms.total_sequence_length; total_seq_id++) {
4064          x[offset + total_seq_id] = ${I.type.value}(${K}(0));
4065        }`:""};
4066  }`};return{name:"AttentionProbsSoftmax",shaderCache:{hint:`${c};${y};${l}`,inputDependencies:b},getShaderSource:S,getRunData:()=>({outputs:[],dispatchGroup:{x:1,y:r,z:e*n},programUniforms:m})}},b8=(t,e,n,s,r,i,a,o,l)=>{let c=a+i.kvSequenceLength,h=[i.batchSize,i.numHeads,i.sequenceLength,c],p=t>1&&s,m=i.kvNumHeads?i.kvNumHeads:i.numHeads,y=p?[i.batchSize,m,c,i.headSize]:void 0,v=i.nReps?i.nReps:1,b=i.scale===0?1/Math.sqrt(i.headSize):i.scale,S=Wi(i.headSize),E=i.headSize/S,I=12,M={x:Math.ceil(c/I),y:Math.ceil(i.sequenceLength/I),z:i.batchSize*i.numHeads},j=[{type:12,data:i.sequenceLength},{type:12,data:E},{type:12,data:c},{type:12,data:i.numHeads},{type:12,data:i.headSize},{type:1,data:b},{type:12,data:a},{type:12,data:i.kvSequenceLength},{type:12,data:v}],L=p&&s&&dt.size(s.dims)>0,K=["type","type"];L&&K.push("type"),r&&K.push("type"),o&&K.push("type"),l&&K.push("type");let D=[{dims:h,dataType:e.dataType,gpuDataType:0}];p&&D.push({dims:y,dataType:e.dataType,gpuDataType:0});let R=B=>{let G=St("q",e.dataType,e.dims,S),X=St("key",n.dataType,n.dims,S),H=[G,X];if(L){let ve=St("past_key",s.dataType,s.dims,S);H.push(ve)}r&&H.push(St("attention_bias",r.dataType,r.dims));let Y=o?St("seq_lens",o.dataType,o.dims):void 0;Y&&H.push(Y);let F=l?St("total_sequence_length_input",l.dataType,l.dims):void 0;F&&H.push(F);let we=wn("output",e.dataType,h),me=[we];p&&me.push(wn("present_key",e.dataType,y,S));let xe=ml(1,S),Le=[{name:"M",type:"u32"},{name:"K",type:"u32"},{name:"N",type:"u32"},{name:"num_heads",type:"u32"},{name:"head_size",type:"u32"},{name:"alpha",type:"f32"},{name:"past_sequence_length",type:"u32"},{name:"kv_sequence_length",type:"u32"},{name:"n_reps",type:"u32"}];return`
4067  const TILE_SIZE = ${I}u;
4068
4069  var<workgroup> tileQ: array<${G.type.storage}, ${I*I}>;
4070  var<workgroup> tileK: array<${G.type.storage}, ${I*I}>;
4071  ${B.registerUniforms(Le).declareVariables(...H,...me)}
4072  ${B.mainStart([I,I,1])}
4073    // x holds the N and y holds the M
4074    let headIdx = workgroup_id.z % uniforms.num_heads;
4075    let kvHeadIdx = ${v===1?"headIdx":"headIdx / uniforms.n_reps"};
4076    let kv_num_heads = ${v===1?"uniforms.num_heads":"uniforms.num_heads / uniforms.n_reps"};
4077    let batchIdx = workgroup_id.z / uniforms.num_heads;
4078    let m = workgroup_id.y * TILE_SIZE;
4079    let n = workgroup_id.x * TILE_SIZE;
4080    let sequence_length = uniforms.M;
4081    var total_sequence_length = uniforms.N;
4082    ${Wk(Y,F,!0)}
4083    let absKvHeadIdx = batchIdx * kv_num_heads + kvHeadIdx;
4084    let qOffset = workgroup_id.z * uniforms.M * uniforms.K + m * uniforms.K;
4085    ${L&&p?"let pastKeyOffset = absKvHeadIdx * uniforms.past_sequence_length * uniforms.K;":""};
4086    let kOffset = absKvHeadIdx * uniforms.kv_sequence_length * uniforms.K;
4087    ${p?"let presentKeyOffset = absKvHeadIdx * uniforms.N * uniforms.K;":""}
4088    var value = ${xe}(0);
4089    for (var w: u32 = 0u; w < uniforms.K; w += TILE_SIZE) {
4090      if (global_id.y < uniforms.M && w + local_id.x < uniforms.K) {
4091        tileQ[TILE_SIZE * local_id.y + local_id.x] = q[qOffset + local_id.y * uniforms.K + w + local_id.x];
4092      }
4093      if (n + local_id.y < uniforms.N && w + local_id.x < uniforms.K) {
4094        var idx = TILE_SIZE * local_id.y + local_id.x;
4095      ${L&&p?`
4096              if (n + local_id.y < past_sequence_length) {
4097                tileK[idx] = past_key[pastKeyOffset + (n + local_id.y) * uniforms.K + w + local_id.x];
4098              } else if (n + local_id.y - past_sequence_length < uniforms.kv_sequence_length) {
4099                tileK[idx] = key[kOffset + (n + local_id.y - past_sequence_length) * uniforms.K + w + local_id.x];
4100              }`:`
4101          if (n + local_id.y < uniforms.kv_sequence_length) {
4102            tileK[idx] = key[kOffset + (n + local_id.y) * uniforms.K + w + local_id.x];
4103          }`}
4104      ${p?`if (n + local_id.y < present_sequence_length) {
4105        present_key[presentKeyOffset + (n + local_id.y) * uniforms.K + w + local_id.x] = tileK[idx];
4106      }`:""}
4107      }
4108      workgroupBarrier();
4109
4110      for (var k: u32 = 0u; k < TILE_SIZE && w+k < uniforms.K; k++) {
4111          value += ${xe}(tileQ[TILE_SIZE * local_id.y + k] * tileK[TILE_SIZE * local_id.x + k]);
4112      }
4113
4114      workgroupBarrier();
4115    }
4116
4117    if (global_id.y < uniforms.M && global_id.x < total_sequence_length) {
4118      let headOffset = workgroup_id.z * uniforms.M * uniforms.N;
4119      let outputIdx = headOffset + global_id.y * uniforms.N + global_id.x;
4120      var sum: f32 = ${(()=>{switch(S){case 1:return"value";case 2:return"value.x + value.y";case 4:return"value.x + value.y + value.z + value.w";default:throw new Error(`Unsupported components: ${S}`)}})()};
4121        output[outputIdx] = ${we.type.value} (sum * uniforms.alpha) + ${r?"attention_bias[outputIdx]":"0.0"};
4122    }
4123  }`};return{name:"AttentionProbs",shaderCache:{hint:`${S};${r!==void 0};${s!==void 0};${t}`,inputDependencies:K},getRunData:()=>({outputs:D,dispatchGroup:M,programUniforms:j}),getShaderSource:R}},w8=(t,e,n,s,r,i,a=void 0,o=void 0)=>{let l=i+r.kvSequenceLength,c=r.nReps?r.nReps:1,h=r.vHiddenSize*c,p=t>1&&s,m=r.kvNumHeads?r.kvNumHeads:r.numHeads,y=p?[r.batchSize,m,l,r.headSize]:void 0,v=[r.batchSize,r.sequenceLength,h],b=12,S={x:Math.ceil(r.vHeadSize/b),y:Math.ceil(r.sequenceLength/b),z:r.batchSize*r.numHeads},E=[{type:12,data:r.sequenceLength},{type:12,data:l},{type:12,data:r.vHeadSize},{type:12,data:r.numHeads},{type:12,data:r.headSize},{type:12,data:h},{type:12,data:i},{type:12,data:r.kvSequenceLength},{type:12,data:c}],I=p&&s&&dt.size(s.dims)>0,M=["type","type"];I&&M.push("type"),a&&M.push("type"),o&&M.push("type");let j=[{dims:v,dataType:e.dataType,gpuDataType:0}];p&&j.push({dims:y,dataType:e.dataType,gpuDataType:0});let L=K=>{let D=St("probs",e.dataType,e.dims),R=St("v",n.dataType,n.dims),B=[D,R];I&&B.push(St("past_value",s.dataType,s.dims));let G=a?St("seq_lens",a.dataType,a.dims):void 0;a&&B.push(G);let X=o?St("total_sequence_length_input",o.dataType,o.dims):void 0;o&&B.push(X);let H=[wn("output",e.dataType,v)];p&&H.push(wn("present_value",e.dataType,y));let Y=[{name:"M",type:"u32"},{name:"K",type:"u32"},{name:"N",type:"u32"},{name:"num_heads",type:"u32"},{name:"head_size",type:"u32"},{name:"v_hidden_size",type:"u32"},{name:"past_sequence_length",type:"u32"},{name:"kv_sequence_length",type:"u32"},{name:"n_reps",type:"u32"}];return`
4124  const TILE_SIZE = ${b}u;
4125  var<workgroup> tileQ: array<${D.type.value}, ${b*b}>;
4126  var<workgroup> tileV: array<${D.type.value}, ${b*b}>;
4127  ${K.registerUniforms(Y).declareVariables(...B,...H)}
4128  ${K.mainStart([b,b,1])}
4129   let headIdx = workgroup_id.z % uniforms.num_heads;
4130   let batchIdx = workgroup_id.z / uniforms.num_heads;
4131   let kvHeadIdx = ${c===1?"headIdx":"headIdx / uniforms.n_reps"};
4132   let kv_num_heads = ${c===1?"uniforms.num_heads":"uniforms.num_heads / uniforms.n_reps"};
4133   let m = global_id.y;
4134   let n = global_id.x;
4135   let sequence_length = uniforms.M;
4136   var total_sequence_length = uniforms.K;
4137   ${Wk(G,X,!0)}
4138   let offsetA = workgroup_id.z * uniforms.M * uniforms.K + m * uniforms.K;
4139   let absKvHeadIdx = batchIdx * kv_num_heads + kvHeadIdx; // kvHeadIdx is relative to the batch
4140   ${I&&p?"let pastValueOffset = absKvHeadIdx * uniforms.N * uniforms.past_sequence_length + n;":""};
4141   let vOffset = absKvHeadIdx * uniforms.N * uniforms.kv_sequence_length + n;
4142   ${p?"let presentValueOffset = absKvHeadIdx * uniforms.N * uniforms.K + n;":""}
4143   var value = ${D.type.storage}(0);
4144   for (var w: u32 = 0u; w < uniforms.K; w += TILE_SIZE) {
4145      if (m < uniforms.M && w + local_id.x < uniforms.K) {
4146        tileQ[TILE_SIZE * local_id.y + local_id.x] = probs[offsetA + w + local_id.x];
4147      }
4148      if (n < uniforms.N && w + local_id.y < uniforms.K) {
4149        var idx = TILE_SIZE * local_id.y + local_id.x;
4150        ${I&&p?`
4151        if (w + local_id.y < past_sequence_length) {
4152          tileV[idx] = past_value[pastValueOffset + (w + local_id.y) * uniforms.N];
4153        } else if (w + local_id.y - past_sequence_length < uniforms.kv_sequence_length) {
4154          tileV[idx] = v[vOffset + (w + local_id.y - past_sequence_length) * uniforms.N];
4155        }
4156      `:`
4157            if (w + local_id.y < uniforms.kv_sequence_length) {
4158              tileV[idx] = v[vOffset + (w + local_id.y) * uniforms.N];
4159            }`}
4160        ${p?`
4161            if (w + local_id.y < present_sequence_length) {
4162          present_value[presentValueOffset + (w + local_id.y) * uniforms.N] = tileV[idx];
4163        }`:""}
4164      }
4165     workgroupBarrier();
4166     for (var k: u32 = 0u; k < TILE_SIZE && w+k < total_sequence_length; k++) {
4167       value += tileQ[TILE_SIZE * local_id.y + k] * tileV[TILE_SIZE * k + local_id.x];
4168     }
4169     workgroupBarrier();
4170   }
4171
4172   // we need to transpose output from BNSH_v to BSND_v
4173   if (m < uniforms.M && n < uniforms.N) {
4174     let outputIdx = batchIdx * uniforms.M * uniforms.v_hidden_size + m * uniforms.v_hidden_size
4175       + headIdx * uniforms.N + n;
4176     output[outputIdx] = value;
4177   }
4178  }`};return{name:"AttentionScore",shaderCache:{hint:`${s!==void 0};${t}`,inputDependencies:M},getRunData:()=>({outputs:j,dispatchGroup:S,programUniforms:E}),getShaderSource:L}},AE=(t,e,n,s,r,i,a,o,l,c,h=void 0,p=void 0)=>{let m=Math.min(t.outputCount,1+(a?1:0)+(o?1:0)),y=m>1?a:void 0,v=m>1?o:void 0,b=m>1?c.pastSequenceLength:0,S=b+c.kvSequenceLength,E=l&&dt.size(l.dims)>0?l:void 0,I=[e,n];y&&dt.size(y.dims)>0&&I.push(y),E&&I.push(E),h&&I.push(h),p&&I.push(p);let M=t.compute(b8(m,e,n,y,E,c,b,h,p),{inputs:I,outputs:m>1?[-1,1]:[-1]})[0];t.compute(v8(M,c.batchSize,c.numHeads,b,c.sequenceLength,S,h,p),{inputs:h&&p?[M,h,p]:[M],outputs:[]});let j=[M,s];v&&dt.size(v.dims)>0&&j.push(v),h&&j.push(h),p&&j.push(p),t.compute(w8(m,M,s,v,c,b,h,p),{inputs:j,outputs:m>1?[0,2]:[0]})},_8=(t,e)=>{let n=[e.batchSize,e.numHeads,e.sequenceLength,e.headSize],s=e.sequenceLength,r=e.inputHiddenSize,i=e.headSize,a=12,o={x:Math.ceil(e.headSize/a),y:Math.ceil(e.sequenceLength/a),z:e.batchSize*e.numHeads},l=[t.inputs[0],t.inputs[1],t.inputs[2]],c=[{type:12,data:s},{type:12,data:r},{type:12,data:i},{type:12,data:e.numHeads},{type:12,data:e.headSize},{type:12,data:e.hiddenSize},{type:12,data:e.hiddenSize+e.hiddenSize+e.vHiddenSize}],h=p=>{let m=wn("output_q",l[0].dataType,n),y=wn("output_k",l[0].dataType,n),v=wn("output_v",l[0].dataType,n),b=St("input",l[0].dataType,l[0].dims),S=St("weight",l[1].dataType,l[1].dims),E=St("bias",l[2].dataType,l[2].dims),I=b.type.storage,M=[{name:"M",type:"u32"},{name:"K",type:"u32"},{name:"N",type:"u32"},{name:"num_heads",type:"u32"},{name:"head_size",type:"u32"},{name:"hidden_size",type:"u32"},{name:"ldb",type:"u32"}];return`
4179  const TILE_SIZE = ${a}u;
4180  var<workgroup> tileInput: array<${I}, ${a*a}>;
4181  var<workgroup> tileWeightQ: array<${I}, ${a*a}>;
4182  var<workgroup> tileWeightK: array<${I}, ${a*a}>;
4183  var<workgroup> tileWeightV: array<${I}, ${a*a}>;
4184  ${p.registerUniforms(M).declareVariables(b,S,E,m,y,v)}
4185  ${p.mainStart([a,a,1])}
4186    let batchIndex = workgroup_id.z / uniforms.num_heads;
4187    let headNumber = workgroup_id.z % uniforms.num_heads;
4188    let m = global_id.y;
4189    let n = global_id.x;
4190
4191    let inputOffset = batchIndex * (uniforms.M * uniforms.K) + m * uniforms.K;
4192    let biasOffsetQ = headNumber * uniforms.head_size;
4193    let biasOffsetK = uniforms.hidden_size + biasOffsetQ;
4194    let biasOffsetV = uniforms.hidden_size + biasOffsetK;
4195
4196    var valueQ = ${I}(0);
4197    var valueK = ${I}(0);
4198    var valueV = ${I}(0);
4199    for (var w: u32 = 0u; w < uniforms.K; w += TILE_SIZE) {
4200      if (m < uniforms.M && w + local_id.x < uniforms.K) {
4201        tileInput[TILE_SIZE * local_id.y + local_id.x] = input[inputOffset + w + local_id.x];
4202      }
4203      if (n < uniforms.N && w + local_id.y < uniforms.K) {
4204        let offset = n + (w + local_id.y) * uniforms.ldb;
4205        tileWeightQ[TILE_SIZE * local_id.y + local_id.x] = weight[biasOffsetQ + offset];
4206        tileWeightK[TILE_SIZE * local_id.y + local_id.x] = weight[biasOffsetK + offset];
4207        tileWeightV[TILE_SIZE * local_id.y + local_id.x] = weight[biasOffsetV + offset];
4208      }
4209      workgroupBarrier();
4210      for (var k: u32 = 0u; k<TILE_SIZE && w+k < uniforms.K; k++) {
4211        let inputTileOffset = TILE_SIZE * local_id.y + k;
4212        let weightTileOffset = TILE_SIZE * k + local_id.x;
4213        valueQ += tileInput[inputTileOffset] * tileWeightQ[weightTileOffset];
4214        valueK += tileInput[inputTileOffset] * tileWeightK[weightTileOffset];
4215        valueV += tileInput[inputTileOffset] * tileWeightV[weightTileOffset];
4216      }
4217
4218      workgroupBarrier();
4219    }
4220
4221    let headOffset = (m * uniforms.N + n) % uniforms.head_size;
4222    valueQ += bias[headOffset + biasOffsetQ];
4223    valueK += bias[headOffset + biasOffsetK];
4224    valueV += bias[headOffset + biasOffsetV];
4225
4226    let offset = workgroup_id.z * uniforms.M * uniforms.N;
4227    if (m < uniforms.M && n < uniforms.N) {
4228      let outputIdx = offset + m * uniforms.N + n;
4229      output_q[outputIdx] = valueQ;
4230      output_k[outputIdx] = valueK;
4231      output_v[outputIdx] = valueV;
4232    }
4233  }`};return t.compute({name:"AttentionPrepare",shaderCache:{inputDependencies:["type","type","type"]},getRunData:()=>({outputs:[{dims:n,dataType:t.inputs[0].dataType,gpuDataType:0},{dims:n,dataType:t.inputs[0].dataType,gpuDataType:0},{dims:n,dataType:t.inputs[0].dataType,gpuDataType:0}],dispatchGroup:o,programUniforms:c}),getShaderSource:h},{inputs:l,outputs:[-1,-1,-1]})},hee=(t,e)=>{let n=x8(t.inputs,e),[s,r,i]=_8(t,n);return AE(t,s,r,i,t.inputs[4],void 0,void 0,void 0,t.inputs[5],n)}}),S8,E8,T8,fee,CAe=qt(()=>{Ad(),ts(),Ts(),na(),Rs(),S8=(t,e)=>{if(!t||t.length!==5)throw new Error("BatchNormalization requires 5 inputs");let n=(s,r,i)=>{let a=r.length;if(a!==s.length)throw new Error(`${i}: num dimensions != ${a}`);r.forEach((o,l)=>{if(o!==s[l])throw new Error(`${i}: dim[${l}] do not match`)})};if(t[0].dims.length>1){let s=e.format==="NHWC"?e.spatial?t[0].dims.slice(-1):t[0].dims.slice(-1).concat(t[0].dims.slice(1,t[0].dims.length-1)):t[0].dims.slice(1,e.spatial?2:void 0);n(t[1].dims,s,"Invalid input scale"),n(t[2].dims,s,"Invalid input B"),n(t[3].dims,s,"Invalid input mean"),n(t[4].dims,s,"Invalid input var")}else n(t[1].dims,[1],"Invalid input scale"),n(t[2].dims,[1],"Invalid input B"),n(t[3].dims,[1],"Invalid input mean"),n(t[4].dims,[1],"Invalid input var")},E8=(t,e)=>{let{epsilon:n,spatial:s,format:r}=e,i=t[0].dims,a=s?Wi(i[i.length-1]):1,o=r==="NHWC"&&i.length>1?a:1,l=dt.size(i)/a,c=s,h=c?i.length:i,p=St("x",t[0].dataType,t[0].dims,a),m=St("scale",t[1].dataType,t[1].dims,o),y=St("bias",t[2].dataType,t[2].dims,o),v=St("inputMean",t[3].dataType,t[3].dims,o),b=St("inputVar",t[4].dataType,t[4].dims,o),S=wn("y",t[0].dataType,h,a),E=()=>{let M="";if(s)M=`let cOffset = ${i.length===1?"0u":r==="NHWC"?`outputIndices[${i.length-1}] / ${a}`:"outputIndices[1]"};`;else if(r==="NCHW")M=`
4234            ${S.indicesSet("outputIndices","0","0")}
4235            let cOffset = ${S.indicesToOffset("outputIndices")};`;else{M=`var cIndices = ${m.type.indices}(0);
4236                       cIndices[0] = outputIndices[${i.length-1}];`;for(let j=1;j<m.rank;j++)M+=`cIndices[${j}] = outputIndices[${j}];`;M+=`let cOffset = ${m.indicesToOffset("cIndices")};`}return M},I=M=>`
4237  const epsilon = ${n};
4238  ${M.registerUniform("outputSize","u32").declareVariables(p,m,y,v,b,S)}
4239  ${M.mainStart()}
4240  ${M.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
4241    var outputIndices = ${S.offsetToIndices(`global_idx * ${a}`)};
4242    ${E()}
4243    let scale = ${m.getByOffset("cOffset")};
4244    let bias = ${y.getByOffset("cOffset")};
4245    let inputMean = ${v.getByOffset("cOffset")};
4246    let inputVar = ${b.getByOffset("cOffset")};
4247    let x = ${p.getByOffset("global_idx")};
4248    let value = (x - inputMean) * inverseSqrt(inputVar + epsilon) * scale + bias;
4249    ${S.setByOffset("global_idx","value")}
4250  }`;return{name:"BatchNormalization",shaderCache:{hint:`${e.epsilon}_${e.format}_${s}_${a}`,inputDependencies:c?["rank","type","type","type","type"]:void 0},getShaderSource:I,getRunData:()=>({outputs:[{dims:t[0].dims,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:c?[{type:12,data:l},...Mn(i)]:[{type:12,data:l}]})}},T8=t=>Rr(t),fee=(t,e)=>{let{inputs:n,outputCount:s}=t,r=T8({...e,outputCount:s});if(fi.webgpu.validateInputContent&&S8(n,r),e.trainingMode)throw new Error("BatchNormalization trainingMode is not supported yet.");t.compute(E8(n,r))}}),A8,C8,pee,kAe=qt(()=>{Ts(),Rs(),A8=t=>{if(t[0].dims.length!==3)throw new Error("input should have 3 dimensions");if(![320,640,1280].includes(t[0].dims[2]))throw new Error("number of channels should be 320, 640 or 1280");if(t[1].dims.length!==1)throw new Error("bias is expected to have 1 dimensions");if(t[0].dims[2]!==t[1].dims[0])throw new Error("last dimension of input and bias are not the same")},C8=t=>{let e=t[0].dims,n=t[0].dims[2],s=dt.size(e)/4,r=t[0].dataType,i=St("input",r,e,4),a=St("bias",r,[n],4),o=St("residual",r,e,4),l=wn("output",r,e,4);return{name:"BiasAdd",getRunData:()=>({outputs:[{dims:e,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(s/64)}}),getShaderSource:c=>`
4251  const channels = ${n}u / 4;
4252  ${c.declareVariables(i,a,o,l)}
4253
4254  ${c.mainStart()}
4255    ${c.guardAgainstOutOfBoundsWorkgroupSizes(s)}
4256    let value = ${i.getByOffset("global_idx")}
4257      + ${a.getByOffset("global_idx % channels")} + ${o.getByOffset("global_idx")};
4258    ${l.setByOffset("global_idx","value")}
4259  }`}},pee=t=>{A8(t.inputs),t.compute(C8(t.inputs))}}),k8,Tr,mee,gee,yee,xee,vee,bee,wee,_ee,See,I8,Eee,Tee,Aee,Cee,dS,kee,DI,Iee,Nee,Ree,Mee,Pee,$ee,Dee,Oee,Lee,jee,Bee,Uee,Fee,Vee,zee,Gee,w$,Hee,JD,QD,qee,Wee,Kee,N8,R8,Yee,J7=qt(()=>{ts(),Ts(),na(),Rs(),k8=(t,e,n,s,r,i,a)=>{let o=Math.ceil(e/4),l="";typeof r=="string"?l=`${r}(a)`:l=r("a");let c=St("inputData",n,[o],4),h=wn("outputData",s,[o],4),p=[{name:"vec_size",type:"u32"}];return a&&p.push(...a),`
4260      ${t.registerUniforms(p).declareVariables(c,h)}
4261
4262  ${i??""}
4263
4264  ${t.mainStart()}
4265    ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}
4266
4267    let a = ${c.getByOffset("global_idx")};
4268    ${h.setByOffset("global_idx",l)}
4269  }`},Tr=(t,e,n,s,r,i=t.dataType,a,o)=>{let l=[{type:12,data:Math.ceil(dt.size(t.dims)/4)}];return a&&l.push(...a),{name:e,shaderCache:{hint:r,inputDependencies:["type"]},getShaderSource:c=>k8(c,dt.size(t.dims),t.dataType,i,n,s,o),getRunData:c=>({outputs:[{dims:t.dims,dataType:i}],dispatchGroup:{x:Math.ceil(dt.size(c[0].dims)/64/4)},programUniforms:l})}},mee=t=>{t.compute(Tr(t.inputs[0],"Abs","abs"))},gee=t=>{t.compute(Tr(t.inputs[0],"Acos","acos"))},yee=t=>{t.compute(Tr(t.inputs[0],"Acosh","acosh"))},xee=t=>{t.compute(Tr(t.inputs[0],"Asin","asin"))},vee=t=>{t.compute(Tr(t.inputs[0],"Asinh","asinh"))},bee=t=>{t.compute(Tr(t.inputs[0],"Atan","atan"))},wee=t=>{t.compute(Tr(t.inputs[0],"Atanh","atanh"))},_ee=t=>Rr(t),See=(t,e)=>{let n;switch(e.to){case 10:n="vec4<f16>";break;case 1:n="vec4<f32>";break;case 12:n="vec4<u32>";break;case 6:n="vec4<i32>";break;case 9:n="vec4<bool>";break;default:throw new RangeError(`not supported type (specified in attribute 'to' from 'Cast' operator): ${e.to}`)}t.compute(Tr(t.inputs[0],"Cast",n,void 0,e.cacheKey,e.to))},I8=t=>{let e,n,s=t.length>=2&&t[1].data!==0,r=t.length>=3&&t[2].data!==0;switch(t[0].dataType){case 1:e=s?t[1].getFloat32Array()[0]:-34028234663852886e22,n=r?t[2].getFloat32Array()[0]:34028234663852886e22;break;case 10:e=s?t[1].getUint16Array()[0]:64511,n=r?t[2].getUint16Array()[0]:31743;break;default:throw new Error("Unsupport data type")}return Rr({min:e,max:n})},Eee=(t,e)=>{let n=e||I8(t.inputs),s=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"Clip",r=>`clamp(${r}, vec4<${s}>(uniforms.min), vec4<${s}>(uniforms.max))`,void 0,n.cacheKey,void 0,[{type:t.inputs[0].dataType,data:n.min},{type:t.inputs[0].dataType,data:n.max}],[{name:"min",type:s},{name:"max",type:s}]),{inputs:[0]})},Tee=t=>{t.compute(Tr(t.inputs[0],"Ceil","ceil"))},Aee=t=>{t.compute(Tr(t.inputs[0],"Cos","cos"))},Cee=t=>{t.compute(Tr(t.inputs[0],"Cosh","cosh"))},dS=t=>Rr(t),kee=(t,e)=>{let n=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"Elu",s=>`elu_vf32(${s})`,`
4270  const elu_alpha_ = ${n}(${e.alpha});
4271
4272  fn elu_f32(a: ${n}) -> ${n} {
4273  return select((exp(a) - 1.0) * elu_alpha_, a, a >= 0.0);
4274  }
4275
4276  fn elu_vf32(v: vec4<${n}>) -> vec4<${n}> {
4277  return vec4(elu_f32(v.x), elu_f32(v.y), elu_f32(v.z), elu_f32(v.w));
4278  }`,e.cacheKey))},DI=(t="f32")=>`
4279const r0: ${t} = 0.3275911;
4280const r1: ${t} = 0.254829592;
4281const r2: ${t} = -0.284496736;
4282const r3: ${t} = 1.421413741;
4283const r4: ${t} = -1.453152027;
4284const r5: ${t} = 1.061405429;
4285
4286fn erf_vf32(v: vec4<${t}>) -> vec4<${t}> {
4287  let absv = abs(v);
4288  let x = 1.0 / (1.0 + r0 * absv);
4289  return sign(v) * (1.0 - ((((r5 * x + r4) * x + r3) * x + r2) * x + r1) * x * exp(-absv * absv));
4290}`,Iee=t=>{let e=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"Erf",n=>`erf_vf32(${n})`,DI(e)))},Nee=t=>{t.compute(Tr(t.inputs[0],"Exp","exp"))},Ree=t=>{t.compute(Tr(t.inputs[0],"Floor","floor"))},Mee=t=>{let e=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"Gelu",n=>`0.5 * ${n} * (1.0 + erf_vf32(${n} * 0.7071067811865475))`,DI(e)))},Pee=(t,e)=>{let n=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"LeakyRelu",s=>`select(leaky_relu_alpha_ * ${s}, ${s}, ${s} >= vec4<${n}>(0.0))`,`const leaky_relu_alpha_ = ${n}(${e.alpha});`,e.cacheKey))},$ee=t=>{t.compute(Tr(t.inputs[0],"Not",e=>`!${e}`))},Dee=t=>{t.compute(Tr(t.inputs[0],"Neg",e=>`-${e}`))},Oee=t=>{t.compute(Tr(t.inputs[0],"Reciprocal",e=>`1.0/${e}`))},Lee=t=>{let e=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"Relu",n=>`select(vec4<${e}>(0.0), ${n}, ${n} > vec4<${e}>(0.0))`))},jee=t=>{t.compute(Tr(t.inputs[0],"Sigmoid",e=>`(1.0 / (1.0 + exp(-${e})))`))},Bee=t=>Rr(t),Uee=(t,e)=>{let n=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"HardSigmoid",s=>`max(vec4<${n}>(0.0), min(vec4<${n}>(1.0), ${e.alpha} * ${s} + vec4<${n}>(${e.beta})))`,void 0,e.cacheKey))},Fee=t=>{t.compute(Tr(t.inputs[0],"Sin","sin"))},Vee=t=>{t.compute(Tr(t.inputs[0],"Sinh","sinh"))},zee=t=>{t.compute(Tr(t.inputs[0],"Sqrt","sqrt"))},Gee=t=>{t.compute(Tr(t.inputs[0],"Tan","tan"))},w$=t=>`sign(${t}) * (1 - exp(-2 * abs(${t}))) / (1 + exp(-2 * abs(${t})))`,Hee=t=>{t.compute(Tr(t.inputs[0],"Tanh",w$))},JD=(t="f32")=>`
4291const fast_gelu_a: ${t} = 0.5;
4292const fast_gelu_b: ${t} = 0.7978845608028654;
4293const fast_gelu_c: ${t} = 0.035677408136300125;
4294
4295fn tanh_v(v: vec4<${t}>) -> vec4<${t}> {
4296  return ${w$("v")};
4297}
4298`,QD=t=>`(fast_gelu_a + fast_gelu_a * tanh_v(${t} * (fast_gelu_c * ${t} * ${t} + fast_gelu_b))) * ${t}`,qee=t=>{let e=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"FastGelu",QD,JD(e),void 0,t.inputs[0].dataType))},Wee=(t,e)=>{let n=ml(t.inputs[0].dataType);return t.compute(Tr(t.inputs[0],"ThresholdedRelu",s=>`select(vec4<${n}>(0.0), ${s}, ${s} > thresholded_relu_alpha_)`,`const thresholded_relu_alpha_ = vec4<${n}>(${e.alpha});`,e.cacheKey)),0},Kee=t=>{t.compute(Tr(t.inputs[0],"Log","log"))},N8=(t,e)=>`
4299const alpha = vec4<${t}>(${e});
4300const one = ${t}(1.0);
4301const zero = ${t}(0.0);
4302
4303fn quick_gelu_impl(x: vec4<${t}>) -> vec4<${t}> {
4304  let v = x *alpha;
4305  var x1 : vec4<${t}>;
4306  for (var i = 0; i < 4; i = i + 1) {
4307    if (v[i] >= zero) {
4308      x1[i] = one / (one + exp(-v[i]));
4309    } else {
4310      x1[i] = one - one / (one + exp(v[i]));
4311    }
4312  }
4313  return x * x1;
4314}
4315`,R8=t=>`quick_gelu_impl(${t})`,Yee=(t,e)=>{let n=ml(t.inputs[0].dataType);t.compute(Tr(t.inputs[0],"QuickGelu",R8,N8(n,e.alpha),e.cacheKey,t.inputs[0].dataType))}}),M8,P8,Xee,IAe=qt(()=>{Ts(),Rs(),J7(),M8=t=>{if(t[0].dims.length!==3)throw new Error("input should have 3 dimensions");if(![2560,5120,10240].includes(t[0].dims[2]))throw new Error("hidden state should be 2560, 5120 or 10240");if(t[1].dims.length!==1)throw new Error("bias is expected to have 1 dimensions");if(t[0].dims[2]!==t[1].dims[0])throw new Error("last dimension of input and bias are not the same")},P8=t=>{let e=t[0].dims.slice();e[2]=e[2]/2;let n=St("input",t[0].dataType,t[0].dims,4),s=St("bias",t[0].dataType,[t[0].dims[2]],4),r=wn("output",t[0].dataType,e,4),i=dt.size(e)/4,a=lo(t[0].dataType);return{name:"BiasSplitGelu",getRunData:()=>({outputs:[{dims:e,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(i/64)}}),getShaderSource:o=>`
4316  const M_SQRT2 = sqrt(2.0);
4317  const halfChannels = ${t[0].dims[2]/4/2}u;
4318
4319  ${o.declareVariables(n,s,r)}
4320
4321  ${DI(a)}
4322
4323  ${o.mainStart()}
4324    ${o.guardAgainstOutOfBoundsWorkgroupSizes(i)}
4325    let biasIdx = global_idx % halfChannels;
4326    let batchIndex = global_idx / halfChannels;
4327    let inputOffset = biasIdx + batchIndex * halfChannels * 2;
4328    let valueLeft = input[inputOffset] + bias[biasIdx];
4329    let valueRight = input[inputOffset + halfChannels] + bias[biasIdx + halfChannels];
4330    let geluRight = valueRight * 0.5 * (erf_vf32(valueRight / M_SQRT2) + 1);
4331
4332    ${r.setByOffset("global_idx","valueLeft * geluRight")}
4333  }`}},Xee=t=>{M8(t.inputs),t.compute(P8(t.inputs))}}),$8,D8,xh,Jee,Qee,Zee,ete,tte,nte,ste,rte,ite,ate,NAe=qt(()=>{ts(),Ts(),Rs(),$8=(t,e,n,s,r,i,a,o,l,c,h,p)=>{let m,y;typeof o=="string"?m=y=(I,M)=>`${o}((${I}),(${M}))`:typeof o=="function"?m=y=o:(m=o.scalar,y=o.vector);let v=wn("outputData",h,s.length,4),b=St("aData",l,e.length,4),S=St("bData",c,n.length,4),E;if(r)if(i){let I=dt.size(e)===1,M=dt.size(n)===1,j=e.length>0&&e[e.length-1]%4===0,L=n.length>0&&n[n.length-1]%4===0;I||M?E=v.setByOffset("global_idx",y(I?`${b.type.value}(${b.getByOffset("0")}.x)`:b.getByOffset("global_idx"),M?`${S.type.value}(${S.getByOffset("0")}.x)`:S.getByOffset("global_idx"))):E=`
4334            let outputIndices = ${v.offsetToIndices("global_idx * 4u")};
4335            let offsetA = ${b.broadcastedIndicesToOffset("outputIndices",v)};
4336            let offsetB = ${S.broadcastedIndicesToOffset("outputIndices",v)};
4337            ${v.setByOffset("global_idx",y(a||j?b.getByOffset("offsetA / 4u"):`${b.type.value}(${b.getByOffset("offsetA / 4u")}[offsetA % 4u])`,a||L?S.getByOffset("offsetB / 4u"):`${S.type.value}(${S.getByOffset("offsetB / 4u")}[offsetB % 4u])`))}
4338          `}else E=v.setByOffset("global_idx",y(b.getByOffset("global_idx"),S.getByOffset("global_idx")));else{if(!i)throw new Error("no necessary to use scalar implementation for element-wise binary op implementation.");let I=(M,j,L="")=>{let K=`aData[indexA${j}][componentA${j}]`,D=`bData[indexB${j}][componentB${j}]`;return`
4339            let outputIndices${j} = ${v.offsetToIndices(`global_idx * 4u + ${j}u`)};
4340            let offsetA${j} = ${b.broadcastedIndicesToOffset(`outputIndices${j}`,v)};
4341            let offsetB${j} = ${S.broadcastedIndicesToOffset(`outputIndices${j}`,v)};
4342            let indexA${j} = offsetA${j} / 4u;
4343            let indexB${j} = offsetB${j} / 4u;
4344            let componentA${j} = offsetA${j} % 4u;
4345            let componentB${j} = offsetB${j} % 4u;
4346            ${M}[${j}] = ${L}(${m(K,D)});
4347          `};h===9?E=`
4348            var data = vec4<u32>(0);
4349            ${I("data",0,"u32")}
4350            ${I("data",1,"u32")}
4351            ${I("data",2,"u32")}
4352            ${I("data",3,"u32")}
4353            outputData[global_idx] = dot(vec4<u32>(0x1, 0x100, 0x10000, 0x1000000), vec4<u32>(data));`:E=`
4354            ${I("outputData[global_idx]",0)}
4355            ${I("outputData[global_idx]",1)}
4356            ${I("outputData[global_idx]",2)}
4357            ${I("outputData[global_idx]",3)}
4358          `}return`
4359        ${t.registerUniform("vec_size","u32").declareVariables(b,S,v)}
4360
4361        ${p??""}
4362
4363        ${t.mainStart()}
4364        ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}
4365        ${E}
4366      }`},D8=(t,e,n,s,r,i,a=n.dataType)=>{let o=n.dims.map(Number),l=s.dims.map(Number),c=!dt.areEqual(o,l),h=o,p=dt.size(o),m=!1,y=!1,v=[c];if(c){let b=q1.calcShape(o,l,!1);if(!b)throw new Error("Can't perform binary op on the given tensors");h=b.slice(),p=dt.size(h);let S=dt.size(o)===1,E=dt.size(l)===1,I=o.length>0&&o[o.length-1]%4===0,M=l.length>0&&l[l.length-1]%4===0;v.push(S),v.push(E),v.push(I),v.push(M);let j=1;for(let L=1;L<h.length;L++){let K=o[o.length-L],D=l[l.length-L];if(K===D)j*=K;else break}j%4===0?(y=!0,m=!0):(S||E||I||M)&&(m=!0)}else m=!0;return v.push(m),{name:t,shaderCache:{hint:e+v.map(b=>b.toString()).join("_"),inputDependencies:["rank","rank"]},getShaderSource:b=>$8(b,o,l,h,m,c,y,r,n.dataType,s.dataType,a,i),getRunData:()=>({outputs:[{dims:h,dataType:a}],dispatchGroup:{x:Math.ceil(p/64/4)},programUniforms:[{type:12,data:Math.ceil(dt.size(h)/4)},...Mn(o,l,h)]})}},xh=(t,e,n,s,r,i)=>{t.compute(D8(e,r??"",t.inputs[0],t.inputs[1],n,s,i))},Jee=t=>{xh(t,"Add",(e,n)=>`${e}+${n}`)},Qee=t=>{xh(t,"Div",(e,n)=>`${e}/${n}`)},Zee=t=>{xh(t,"Equal",{scalar:(e,n)=>`u32(${e}==${n})`,vector:(e,n)=>`vec4<u32>(${e}==${n})`},void 0,void 0,9)},ete=t=>{xh(t,"Mul",(e,n)=>`${e}*${n}`)},tte=t=>{let e=St("input",t.inputs[0].dataType,t.inputs[0].dims).type.value;xh(t,"Pow",{scalar:(n,s)=>`pow_custom(${n},${s})`,vector:(n,s)=>`pow_vector_custom(${n},${s})`},`
4367    fn pow_custom(a : ${e}, b : ${e}) -> ${e} {
4368      if (b == ${e}(0.0)) {
4369        return ${e}(1.0);
4370      } else if (a < ${e}(0.0) && f32(b) != floor(f32(b))) {
4371        return ${e}(pow(f32(a), f32(b))); // NaN
4372      }
4373      return select(sign(a), ${e}(1.0), round(f32(abs(b) % ${e}(2.0))) != 1.0) * ${e}(${e==="i32"?"round":""}(pow(f32(abs(a)), f32(b))));
4374    }
4375    fn pow_vector_custom(a : vec4<${e}>, b : vec4<${e}>) -> vec4<${e}> {
4376      // TODO: implement vectorized pow
4377      return vec4<${e}>(pow_custom(a.x, b.x), pow_custom(a.y, b.y), pow_custom(a.z, b.z), pow_custom(a.w, b.w));
4378    }
4379      `)},nte=t=>{xh(t,"Sub",(e,n)=>`${e}-${n}`)},ste=t=>{xh(t,"Greater",{scalar:(e,n)=>`u32(${e}>${n})`,vector:(e,n)=>`vec4<u32>(${e}>${n})`},void 0,void 0,9)},rte=t=>{xh(t,"Less",{scalar:(e,n)=>`u32(${e}<${n})`,vector:(e,n)=>`vec4<u32>(${e}<${n})`},void 0,void 0,9)},ite=t=>{xh(t,"GreaterOrEqual",{scalar:(e,n)=>`u32(${e}>=${n})`,vector:(e,n)=>`vec4<u32>(${e}>=${n})`},void 0,void 0,9)},ate=t=>{xh(t,"LessOrEqual",{scalar:(e,n)=>`u32(${e}<=${n})`,vector:(e,n)=>`vec4<u32>(${e}<=${n})`},void 0,void 0,9)}}),O8,L8,j8,B8,ote,lte,RAe=qt(()=>{ts(),Ts(),na(),Rs(),O8=(t,e)=>{if(!t||t.length<1)throw new Error("too few inputs");let n=0,s=t[n],r=s.dataType,i=s.dims.length;t.forEach((a,o)=>
vendor: 6,195 bytes, lines 4379-4433
4379{if(o!==n){if(a.dataType!==r)throw new Error("input tensors should be one type");if(a.dims.length!==i)throw new Error("input tensors should have the same shape");a.dims.forEach((l,c)=>{if(c!==e&&l!==s.dims[c])throw new Error("non concat dimensions must match")})}})},L8=(t,e)=>`
4380  fn calculateInputIndex(index: u32) -> u32 {
4381    let sizeInConcatAxis = array<u32, ${t}u>(${e});
4382    for (var i: u32 = 0u; i < ${t}; i += 1u ) {
4383      if (index < sizeInConcatAxis[i]) {
4384        return i;
4385      }
4386    }
4387    return ${t}u;
4388  }`,j8=(t,e)=>{let n=t.length,s=[];for(let r=0;r<n;++r){let i=e.setByOffset("global_idx",t[r].getByIndices("indices"));n===1?s.push(i):r===0?s.push(`if (inputIndex == ${r}u) { ${i} }`):r===n-1?s.push(`else { ${i} }`):s.push(`else if (inputIndex == ${r}) { ${i} }`)}return s.join(`
4389`)},B8=(t,e,n,s)=>{let r=dt.size(n),i=new Array(t.length),a=new Array(t.length),o=0,l=[],c=[],h=[{type:12,data:r}];for(let b=0;b<t.length;++b)o+=t[b].dims[e],i[b]=o,c.push(t[b].dims.length),a[b]=St(`input${b}`,s,c[b]),l.push("rank"),h.push({type:12,data:i[b]});for(let b=0;b<t.length;++b)h.push(...Mn(t[b].dims));h.push(...Mn(n));let p=wn("output",s,n.length),m=p.indicesGet("indices",e),y=Array.from(Array(i.length).keys()).map(b=>`uniforms.sizeInConcatAxis${b}`).join(","),v=b=>`
4390
4391  ${(()=>{b.registerUniform("outputSize","u32");for(let S=0;S<t.length;S++)b.registerUniform(`sizeInConcatAxis${S}`,"u32");return b.declareVariables(...a,p)})()}
4392
4393  ${L8(i.length,y)}
4394
4395  ${b.mainStart()}
4396    ${b.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
4397
4398    var indices = ${p.offsetToIndices("global_idx")};
4399
4400    let inputIndex = calculateInputIndex(${m});
4401    if (inputIndex != 0u) {
4402      let sizeInConcatAxis = array<u32, ${i.length}u>(${y});
4403      ${m} -= sizeInConcatAxis[inputIndex - 1u];
4404    }
4405
4406    ${j8(a,p)}
4407  }`;return{name:"Concat",shaderCache:{hint:`${e}`,inputDependencies:l},getRunData:()=>({outputs:[{dims:n,dataType:s}],dispatchGroup:{x:Math.ceil(r/64)},programUniforms:h}),getShaderSource:v}},ote=(t,e)=>{let n=t.inputs,s=n[0].dims,r=dt.normalizeAxis(e.axis,s.length);O8(n,r);let i=s.slice();i[r]=n.reduce((o,l)=>o+(l.dims.length>r?l.dims[r]:0),0);let a=n.filter(o=>dt.size(o.dims)>0);t.compute(B8(a,r,i,n[0].dataType),{inputs:a})},lte=t=>Rr({axis:t.axis})}),Iv,Nv,Rv,Q7,Hv=qt(()=>{ts(),Ts(),Iv=(t,e,n="f32")=>{switch(t.activation){case"Relu":return`value = max(value, ${e}(0.0));`;case"Sigmoid":return`value = (${e}(1.0) / (${e}(1.0) + exp(-value)));`;case"Clip":return`value = clamp(value, ${e}(${n}(uniforms.clip_min)), ${e}(${n}(uniforms.clip_max)));`;case"HardSigmoid":return`value = max(${e}(0.0), min(${e}(1.0), ${n}(uniforms.alpha) * value + ${n}(uniforms.beta)));`;case"LeakyRelu":return`value = select(${n}(uniforms.alpha) * value, value, value >= ${e}(0.0));`;case"Tanh":return`let e2x = exp(-2.0 * abs(value));
4408              value = sign(value) * (1.0 - e2x) / (1.0 + e2x);
4409        `;case"":return"";default:throw new Error(`Unsupported activation ${t.activation}`)}},Nv=(t,e)=>{t.activation==="Clip"?e.push({type:1,data:t.clipMax},{type:1,data:t.clipMin}):t.activation==="HardSigmoid"?e.push({type:1,data:t.alpha},{type:1,data:t.beta}):t.activation==="LeakyRelu"&&e.push({type:1,data:t.alpha})},Rv=(t,e)=>{t.activation==="Clip"?e.push({name:"clip_max",type:"f32"},{name:"clip_min",type:"f32"}):t.activation==="HardSigmoid"?e.push({name:"alpha",type:"f32"},{name:"beta",type:"f32"}):t.activation==="LeakyRelu"&&e.push({name:"alpha",type:"f32"})},Q7=t=>{let e=(t==null?void 0:t.activation)||"";if(e==="HardSigmoid"){let[n,s]=(t==null?void 0:t.activation_params)||[.2,.5];return{activation:e,alpha:n,beta:s}}else if(e==="Clip"){let[n,s]=(t==null?void 0:t.activation_params)||[$Z,DZ];return{activation:e,clipMax:s,clipMin:n}}else if(e==="LeakyRelu"){let[n]=(t==null?void 0:t.activation_params)||[.01];return{activation:e,alpha:n}}return{activation:e}}}),Ao,cte,Z7=qt(()=>{Ao=(t,e)=>{switch(t){case 1:return e;case 2:return`vec2<${e}>`;case 3:return`vec3<${e}>`;case 4:return`vec4<${e}>`;default:throw new Error(`${t}-component is not supported.`)}},cte=t=>`
4410      ${t?"value = value + getBiasByOutputCoords(coords);":""}
4411      `}),ute,MAe=qt(()=>{ute=t=>`
4412fn getIndexFromCoords4D(coords : vec4<i32>, shape : vec4<i32>) -> i32 {
4413  return dot(coords, vec4<i32>(
4414      shape.y * shape.z * shape.w, shape.z * shape.w, shape.w, 1));
4415}
4416fn getOutputIndexFromCoords(coords : vec4<i32>) -> i32 {
4417  return dot(coords, vec4<i32>(
4418    i32(${t}.x), i32(${t}.y), i32(${t}.z), 1));
4419}
4420`}),GS,ej,tj=qt(()=>{ts(),Ts(),Rs(),Hv(),GS=(t,e,n,s,r)=>{let i=s-n;return`
4421      ${Array.from({length:n}).map((a,o)=>`
4422      if (${An(e.shape,o,e.rank)} != 1) {
4423        ${e.indicesSet(t,o,An(r,o+i,s))}
4424      } else {
4425        ${e.indicesSet(t,o,0)}
4426      }`).join("")}
4427`},ej=(t,e,n,s,r=!1,i)=>{let a=t[0].dims,o=t[1].dims,l=a[a.length-2],c=o[o.length-1],h=a[a.length-1],p=Wi(c),m=Wi(h),y=Wi(l),v=dt.size(n)/p/y,b=t.length>2,S=s?s.slice(0,-2):n.slice(0,-2),E=[dt.size(S),l,c],I=[{type:12,data:v},{type:12,data:l},{type:12,data:c},{type:12,data:h}];Nv(e,I),I.push(...Mn(S,a,o)),b&&I.push(...Mn(t[2].dims)),I.push(...Mn(E));let M=j=>{let L=K7("batch_dims",t[0].dataType,S.length),K=St("a",t[0].dataType,a.length,m),D=St("b",t[1].dataType,o.length,p),R=wn("output",t[0].dataType,E.length,p),B=lo(R.type.tensor),G=Iv(e,R.type.value,B),X=[K,D],H="";if(b){let we=r?p:1;X.push(St("bias",t[2].dataType,t[2].dims.length,we)),H=`${r?`value += bias[col / ${we}];`:`value += ${R.type.value}(bias[row + i]);`}`}let Y=[{name:"output_size",type:"u32"},{name:"M",type:"u32"},{name:"N",type:"u32"},{name:"K",type:"u32"}];Rv(e,Y);let F=()=>{let we=`var a_data: ${K.type.value};`;for(let me=0;me<m;me++)we+=`
4428              let b_data${me} = b[(b_offset + (k + ${me}) * uniforms.N + col) / ${p}];`;for(let me=0;me<y;me++){we+=`a_data = a[(a_offset + (row + ${me}) * uniforms.K + k) / ${m}];`;for(let xe=0;xe<m;xe++)we+=`
4429            values[${me}] = fma(${D.type.value}(a_data${m===1?"":`[${xe}]`}), b_data${xe}, values[${me}]);
4430`}return we};return`
4431  ${j.registerUniforms(Y).registerInternalVariables(L).declareVariables(...X,R)}
4432  ${j.mainStart()}
4433    ${j.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
4434    let col = (global_idx % (uniforms.N / ${p})) * ${p};
4435    var index1 = global_idx / (uniforms.N / ${p});
4436    let stride1 = uniforms.M / ${y};
4437    let row = (index1 % stride1) * ${y};
4438    let batch = index1 / stride1;
4439
4440    ${n.length===2?"":`let batch_indices = ${L.offsetToIndices("batch")};`}
4441
4442    var a_indices: ${K.type.indices};
4443    ${GS("a_indices",K,K.rank-2,L.rank,"batch_indices")}
4444    ${K.indicesSet("a_indices",K.rank-2,0)}
4445    ${K.indicesSet("a_indices",K.rank-1,0)}
4446    let a_offset = ${K.indicesToOffset("a_indices")};
4447
4448    var b_indices: ${D.type.indices};
4449    ${GS("b_indices",D,D.rank-2,L.rank,"batch_indices")}
4450    ${D.indicesSet("b_indices",D.rank-2,0)}
4451    ${D.indicesSet("b_indices",D.rank-1,0)}
4452    let b_offset = ${D.indicesToOffset("b_indices")};
4453    var values: array<${R.type.value}, ${y}>;
4454    for (var k: u32 = 0u; k < uniforms.K; k = k + ${m}) {
4455      ${F()}
4456    }
4457    for (var i = 0u; i < ${y}u; i++) {
4458      var value = values[i];
4459      ${H}
4460      ${G}
4461      let cur_indices = ${R.type.indices}(batch, row + i, col);
4462      let offset = ${R.indicesToOffset("cur_indices")};
4463      ${R.setByOffset(`offset / ${p}`,"value")};
4464    }
4465  }
4466  `};return{name:"MatMulNaive",shaderCache:{hint:`${e.activation};${p};${m};${y};${r}`,inputDependencies:b?["rank","rank","rank"]:["rank","rank"]},getRunData:()=>({outputs:[{dims:i?i(n):n,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(v/64)},programUniforms:I}),getShaderSource:M}}}),U8,F8,ZD,_$,V8,e5,z8,uR,nj=qt(()=>{ts(),Ts(),Rs(),Hv(),tj(),Z7(),U8=(t,e)=>t?`
4467        mm_Asub[inputRow][inputCol] = mm_readA(batch,
4468          kStart + inputRow,
4469          globalRowStart / innerElementSize + inputCol${e?", batchIndices":""});
4470        `:`
4471        mm_Asub[inputRow][inputCol] = mm_readA(batch,
4472          globalRow + innerRow,
4473          kStart / innerElementSize + inputCol${e?", batchIndices":""});
4474        `,F8=(t,e)=>t?`
4475        let ACached0 = mm_Asub[k * innerElementSize][localRow];
4476        let ACached1 = mm_Asub[k * innerElementSize + 1][localRow];
4477        let ACached2 = mm_Asub[k * innerElementSize + 2][localRow];
4478        ${e===3?"":"let ACached3 = mm_Asub[k * innerElementSize + 3][localRow];"}
4479        for (var i = 0; i < rowPerThread; i = i + 1) {
4480          acc[i] = BCached0 * ACached0[i] + acc[i];
4481          acc[i] = BCached1 * ACached1[i] + acc[i];
4482          acc[i] = BCached2 * ACached2[i] + acc[i];
4483          ${e===3?"":"acc[i] = BCached3 * ACached3[i] + acc[i];"}
4484        }`:`
4485        for (var i = 0; i < rowPerThread; i = i + 1) {
4486          let ACached = mm_Asub[tileRow + i][k];
4487          acc[i] = BCached0 * ACached.x + acc[i];
4488          acc[i] = BCached1 * ACached.y + acc[i];
4489          acc[i] = BCached2 * ACached.z + acc[i];
4490          ${e===3?"":"acc[i] = BCached3 * ACached.w + acc[i];"}
4491        }`,ZD=(t,e,n="f32",s,r=!1,i=32,a=!1,o=32)=>{let l=e[1]*t[1],c=e[0]*t[0],h=r?l:i,p=r?i:l,m=h/e[0],y=i/e[1];if(!((r&&m===4&&t[1]===4||!r&&(m===3||m===4))&&h%e[0]===0&&i%e[1]===0&&t[0]===4))throw new Error(`If transposeA ${r} is true, innerElementSize ${m} and workPerThread[1] ${t[1]} must be 4.
4492      Otherwise, innerElementSize ${m} must be 3 or 4.
4493  tileAWidth ${h} must be divisible by workgroupSize[0]${e[0]}. tileInner ${i} must be divisible by workgroupSize[1] ${e[1]}. colPerThread ${t[0]} must be 4.`);return`
4494var<workgroup> mm_Asub: array<array<vec${m}<${n}>, ${h/m}>, ${p}>;
4495var<workgroup> mm_Bsub: array<array<vec4<${n}>, ${c/t[0]}>, ${i}>;
4496
4497const rowPerThread = ${t[1]};
4498const colPerThread = ${t[0]};
4499const innerElementSize = ${m};
4500const tileInner = ${i};
4501
4502@compute @workgroup_size(${e[0]}, ${e[1]}, ${e[2]})
4503fn main(@builtin(local_invocation_id) localId : vec3<u32>,
4504        @builtin(global_invocation_id) globalId : vec3<u32>,
4505        @builtin(workgroup_id) workgroupId : vec3<u32>) {
4506  let localRow = i32(localId.y);
4507  let tileRow = localRow * rowPerThread;
4508  let tileCol = i32(localId.x);
4509
4510  let globalRow =i32(globalId.y) * rowPerThread;
4511  let globalCol = i32(globalId.x);
4512  let batch = ${a?"0":"i32(globalId.z)"};
4513  ${s?`let batchIndices = ${s.offsetToIndices("u32(batch)")};`:""}
4514  let globalRowStart = i32(workgroupId.y) * ${l};
4515
4516  let num_tiles = ${a?`${Math.ceil(o/i)}`:"(uniforms.dim_inner - 1) / tileInner + 1"};
4517  var kStart = ${a?`i32(globalId.z) * ${o}`:"0"};
4518
4519  var acc: array<vec4<${n}>, rowPerThread>;
4520
4521  // Loop over shared dimension.
4522  let tileRowB = localRow * ${y};
4523  for (var t = 0; t < num_tiles; t = t + 1) {
4524      // Load one tile of A into local memory.
4525      for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
4526          let inputRow = tileRow + innerRow;
4527          let inputCol = tileCol;
4528          ${U8(r,s)}
4529      }
4530
4531      // Load one tile of B into local memory.
4532      for (var innerRow = 0; innerRow < ${y}; innerRow = innerRow + 1) {
4533          let inputRow = tileRowB + innerRow;
4534          let inputCol = tileCol;
4535          mm_Bsub[inputRow][inputCol] = mm_readB(batch, kStart + inputRow, globalCol${s?", batchIndices":""});
4536      }
4537      kStart = kStart + tileInner;
4538      workgroupBarrier();
4539
4540      // Compute acc values for a single thread.
4541      for (var k = 0; k < tileInner / innerElementSize; k = k + 1) {
4542          let BCached0 = mm_Bsub[k * innerElementSize][tileCol];
4543          let BCached1 = mm_Bsub[k * innerElementSize + 1][tileCol];
4544          let BCached2 = mm_Bsub[k * innerElementSize + 2][tileCol];
4545          ${m===3?"":"let BCached3 = mm_Bsub[k * innerElementSize + 3][tileCol];"}
4546
4547          ${F8(r,m)}
4548      }
4549
4550      workgroupBarrier();
4551  }
4552
4553  for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
4554      mm_write(batch, globalRow + innerRow, globalCol, acc[innerRow]);
4555  }
4556}`},_$=(t,e)=>t?`
4557            mm_Asub[inputRow][inputCol] = mm_readA(batch,
4558              kStart + inputRow,
4559              globalRowStart + inputCol${e?", batchIndices":""});
4560            `:`
4561            mm_Asub[inputRow][inputCol] = mm_readA(batch,
4562              globalRowStart + inputRow,
4563              kStart + inputCol${e?", batchIndices":""});
4564            `,V8=t=>t?"let ACached = mm_Asub[k][tileRow + innerRow];":"let ACached = mm_Asub[tileRow + innerRow][k];",e5=(t,e,n="f32",s,r=!1,i=32,a=!1,o=32,l=!1)=>{let c=t[1]*e[1],h=t[0]*e[0],p=r?c:i,m=r?i:c;if(!(m%e[1]===0&&p%e[0]===0&&i%e[1]===0))throw new Error(`tileAHight ${m} must be divisible by workgroupSize[1]${e[1]}, tileAWidth ${p} must be divisible by workgroupSize[0]${e[0]}, tileInner ${i} must be divisible by workgroupSize[1]${e[1]}`);let y=m/e[1],v=p/e[0],b=i/e[1],S=l?`
4565    let localRow = i32(localId.y);
4566    let localCol = i32(localId.x);
4567    let globalRowStart = i32(workgroupId.y) * ${c};
4568    let globalColStart = i32(workgroupId.x) * ${h};
4569
4570    // Loop over shared dimension.
4571    for (var t = 0; t < num_tiles; t = t + 1) {
4572      // Load one tile of A into local memory.
4573      for (var inputRow = localRow; inputRow < ${m}; inputRow = inputRow + ${e[1]}) {
4574        for (var inputCol = localCol; inputCol < ${p}; inputCol = inputCol + ${e[0]}) {
4575          ${_$(r,s)}
4576        }
4577      }
4578      // Load one tile of B into local memory.
4579      for (var inputRow = localRow; inputRow < ${i}; inputRow = inputRow + ${e[1]}) {
4580            for (var inputCol = localCol; inputCol < ${h}; inputCol = inputCol + ${e[0]}) {
4581          mm_Bsub[inputRow][inputCol] = mm_readB(batch,
4582            kStart + inputRow,
4583            globalColStart + inputCol${s?", batchIndices":""});
4584        }
4585      }
4586      kStart = kStart + tileInner;
4587      workgroupBarrier();
4588
4589      // Compute acc values for a single thread.
4590      var BCached : array<${n}, colPerThread>;
4591      for (var k = 0; k < tileInner; k = k + 1) {
4592        for (var inner = 0; inner < colPerThread; inner = inner + 1) {
4593          BCached[inner] = mm_Bsub[k][localCol + inner * ${e[0]}];
4594        }
4595        for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
4596          let ACached = ${r?`mm_Asub[k][localRow + innerRow * ${e[1]}];`:`mm_Asub[localRow + innerRow * ${e[1]}][k];`}
4597          for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
4598            acc[innerRow][innerCol] = acc[innerRow][innerCol] +
4599                ACached * BCached[innerCol];
4600          }
4601        }
4602      }
4603      workgroupBarrier();
4604    }
4605    for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
4606      let gRow = globalRowStart + localRow + innerRow * ${e[1]};
4607      for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
4608        let gCol = globalColStart + localCol + innerCol * ${e[0]};
4609        mm_write(batch, gRow, gCol, acc[innerRow][innerCol]);
4610      }
4611    }
4612    `:`
4613let tileRow = i32(localId.y) * rowPerThread;
4614let tileCol = i32(localId.x) * colPerThread;
4615
4616let globalRow = i32(globalId.y) * rowPerThread;
4617let globalCol = i32(globalId.x) * colPerThread;
4618let globalRowStart = i32(workgroupId.y) * ${c};
4619
4620let tileRowA = i32(localId.y) * ${y};
4621let tileColA = i32(localId.x) * ${v};
4622let tileRowB = i32(localId.y) * ${b};
4623// Loop over shared dimension.
4624for (var t = 0; t < num_tiles; t = t + 1) {
4625  // Load one tile of A into local memory.
4626  for (var innerRow = 0; innerRow < ${y}; innerRow = innerRow + 1) {
4627    for (var innerCol = 0; innerCol < ${v}; innerCol = innerCol + 1) {
4628      let inputRow = tileRowA + innerRow;
4629      let inputCol = tileColA + innerCol;
4630      ${_$(r,s)}
4631    }
4632  }
4633
4634  // Load one tile of B into local memory.
4635  for (var innerRow = 0; innerRow < ${b}; innerRow = innerRow + 1) {
4636    for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
4637      let inputRow = tileRowB + innerRow;
4638      let inputCol = tileCol + innerCol;
4639      mm_Bsub[inputRow][inputCol] = mm_readB(batch,
4640        kStart + inputRow,
4641        globalCol + innerCol${s?", batchIndices":""});
4642    }
4643  }
4644  kStart = kStart + tileInner;
4645  workgroupBarrier();
4646
4647  // Compute acc values for a single thread.
4648  var BCached : array<${n}, colPerThread>;
4649  for (var k = 0; k < tileInner; k = k + 1) {
4650    for (var inner = 0; inner < colPerThread; inner = inner + 1) {
4651      BCached[inner] = mm_Bsub[k][tileCol + inner];
4652    }
4653
4654    for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
4655      ${V8(r)}
4656      for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
4657        acc[innerRow][innerCol] = acc[innerRow][innerCol] + ACached * BCached[innerCol];
4658      }
4659    }
4660  }
4661
4662  workgroupBarrier();
4663}
4664
4665for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
4666  for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
4667    mm_write(batch, globalRow + innerRow, globalCol + innerCol,
4668        acc[innerRow][innerCol]);
4669  }
4670}
4671`;return`
4672  var<workgroup> mm_Asub : array<array<${n}, ${p}>, ${m}>;
4673  var<workgroup> mm_Bsub : array<array<${n}, ${h}>, ${i}>;
4674  const rowPerThread = ${t[1]};
4675  const colPerThread = ${t[0]};
4676  const tileInner = ${i};
4677
4678@compute @workgroup_size(${e[0]}, ${e[1]}, ${e[2]})
4679fn main(@builtin(local_invocation_id) localId : vec3<u32>,
4680        @builtin(global_invocation_id) globalId : vec3<u32>,
4681        @builtin(workgroup_id) workgroupId : vec3<u32>) {
4682    let batch = ${a?"0":"i32(globalId.z)"};
4683    ${s?`let batchIndices = ${s.offsetToIndices("u32(batch)")};`:""}
4684    let num_tiles = ${a?`${Math.ceil(o/i)}`:"(uniforms.dim_inner - 1) / tileInner + 1"};
4685    var kStart = ${a?`i32(globalId.z) * ${o}`:"0"};
4686
4687    var acc : array<array<${n}, colPerThread>, rowPerThread>;
4688    ${S}
4689  }
4690`},z8=(t,e,n,s,r=!1)=>{let[i,a,o,l]=s,c=lo(s[0].type.tensor);return`
4691    fn mm_readA(batch: i32, row: i32, colIn: i32, batchIndices: ${i.type.indices}) -> ${Ao(t,c)} {
4692      var value = ${Ao(t,c)}(0.0);
4693      let col = colIn * ${t};
4694      if(row < uniforms.dim_a_outer && col < uniforms.dim_inner)
4695      {
4696        var aIndices: ${a.type.indices};
4697        ${GS("aIndices",a,a.rank-2,i.rank,"batchIndices")}
4698        ${a.indicesSet("aIndices",a.rank-2,"u32(row)")}
4699        ${a.indicesSet("aIndices",a.rank-1,"u32(colIn)")}
4700        value = ${a.getByIndices("aIndices")};
4701      }
4702      return value;
4703    }
4704
4705    fn mm_readB(batch: i32, row: i32, colIn: i32, batchIndices: ${i.type.indices}) -> ${Ao(t,c)} {
4706      var value = ${Ao(t,c)}(0.0);
4707      let col = colIn * ${t};
4708      if(row < uniforms.dim_inner && col < uniforms.dim_b_outer)
4709      {
4710        var bIndices: ${o.type.indices};
4711        ${GS("bIndices",o,o.rank-2,i.rank,"batchIndices")}
4712        ${o.indicesSet("bIndices",o.rank-2,"u32(row)")}
4713        ${o.indicesSet("bIndices",o.rank-1,"u32(colIn)")}
4714        value = ${o.getByIndices("bIndices")};
4715      }
4716      return value;
4717    }
4718
4719    fn mm_write(batch: i32, row: i32, colIn: i32, valueIn: ${Ao(t,c)}) {
4720      let col = colIn * ${t};
4721      if (row < uniforms.dim_a_outer && col < uniforms.dim_b_outer) {
4722        var value = valueIn;
4723        let coords = vec3<i32>(batch, row, colIn);
4724        ${e?`value = value + ${r?"bias[colIn]":`${Ao(t,c)}(bias[row])`};`:""}
4725        ${n}
4726        ${l.setByIndices("vec3<u32>(coords)","value")}
4727      }
4728    }
4729    `},uR=(t,e,n,s,r=!1,i)=>{let a=t[0].dims,o=t[1].dims,l=a.slice(0,-2),c=o.slice(0,-2),h=s?s.slice(0,-2):n.slice(0,-2),p=dt.size(h),m=a[a.length-2],y=a[a.length-1],v=o[o.length-1],b=y%4===0&&v%4===0,S=m<=8?[4,1,1]:[4,4,1],E=[8,8,1],I=[Math.ceil(v/E[0]/S[0]),Math.ceil(m/E[1]/S[1]),Math.ceil(p/E[2]/S[2])],M=b?4:1,j=[...l,m,y/M],L=j.length,K=[...c,y,v/M],D=K.length,R=[p,m,v/M],B=[{type:6,data:m},{type:6,data:v},{type:6,data:y}];Nv(e,B),B.push(...Mn(h,j,K));let G=["rank","rank"],X=t.length>2;X&&(B.push(...Mn(t[2].dims)),G.push("rank")),B.push(...Mn(R));let H=Y=>{let F=h.length,we=K7("batchDims",t[0].dataType,F,1),me=lo(t[0].dataType),xe=St("a",t[0].dataType,L,M),Le=St("b",t[1].dataType,D,M),ve=wn("result",t[0].dataType,R.length,M),ce=[xe,Le];if(X){let De=r?M:1;ce.push(St("bias",t[2].dataType,t[2].dims.length,De))}let ie=[{name:"dim_a_outer",type:"i32"},{name:"dim_b_outer",type:"i32"},{name:"dim_inner",type:"i32"}];Rv(e,ie);let de=lo(ve.type.tensor),Re=Iv(e,ve.type.value,de),Se=z8(M,X,Re,[we,xe,Le,ve],r);return`
4730  ${Y.registerUniforms(ie).registerInternalVariables(we).declareVariables(...ce,ve)}
4731  ${Se}
4732  ${b?ZD(S,E,me,we):e5(S,E,me,we)}
4733                   `};return{name:"MatMul",shaderCache:{hint:`${S};${e.activation};${b};${r}`,inputDependencies:G},getRunData:()=>({outputs:[{dims:i?i(n):n,dataType:t[0].dataType}],dispatchGroup:{x:I[0],y:I[1],z:I[2]},programUniforms:B}),getShaderSource:H}}}),G8,dte,PAe=qt(()=>{ts(),zm(),Rs(),Hv(),Z7(),MAe(),nj(),G8=(t,e,n,s,r=!1,i,a=4,o=4,l=4,c="f32")=>{let h=B=>{switch(B){case 1:return"resData = x[xIndex];";case 3:return`resData = vec3<${c}>(x[xIndex], x[xIndex + 1], x[xIndex + 2]);`;case 4:return"resData = x[xIndex / 4];";default:throw new Error(`innerElementSize ${B} is not supported.`)}},p=B=>{switch(B){case 1:return"return w[row * i32(uniforms.w_shape[3]) + colIn];";case 4:return"return w[row * i32(uniforms.w_shape[3]) / 4 + colIn];";default:throw new Error(`innerElementSize ${B} is not supported.`)}},m=t?`
4734    let coord = vec4<i32>(batch, xRow, xCol, xCh);
4735    `:`
4736    let coord = vec4<i32>(batch, xCh, xRow, xCol);
4737    `,y=t?`
4738    let coords = vec4<i32>(
4739      batch,
4740      row / outWidth,
4741      row % outWidth,
4742      col);
4743    `:`
4744    let coords = vec4<i32>(
4745      batch,
4746      row,
4747      col / outWidth,
4748      col % outWidth);
4749    `,v=t?"i32(uniforms.x_shape[1])":"i32(uniforms.x_shape[2])",b=t?"i32(uniforms.x_shape[2])":"i32(uniforms.x_shape[3])",S=t?"row":"col",E=t?"col":"row",I=`
4750    let inChannels = i32(uniforms.w_shape[2]);
4751    let outWidth = ${t?"i32(uniforms.result_shape[2])":"i32(uniforms.result_shape[3])"};
4752    let outRow = ${S} / outWidth;
4753    let outCol = ${S} % outWidth;
4754
4755    let WRow = ${E} / (i32(uniforms.w_shape[1]) * inChannels);
4756    let WCol = ${E} / inChannels % i32(uniforms.w_shape[1]);
4757    let xRow = outRow * uniforms.stride[0] + uniforms.dilation[0] * WRow - uniforms.pad[0];
4758    let xCol = outCol * uniforms.stride[1] + uniforms.dilation[1] * WCol - uniforms.pad[1];
4759    let xCh = ${E} % inChannels;
4760    var resData = ${Ao(a,c)}(0.0);
4761    // The bounds checking is always needed since we use it to pad zero for
4762    // the 'same' padding type.
4763    if (xRow >= 0 && xRow < ${v} && xCol >= 0 && xCol < ${b}) {
4764      ${m}
4765      let xIndex = getIndexFromCoords4D(coord, vec4<i32>(uniforms.x_shape));
4766      ${h(a)}
4767    }
4768    return resData;`,M=t?e&&s?`
4769    let col = colIn * ${a};
4770    ${I}`:`
4771    let col = colIn * ${a};
4772    if (row < uniforms.dim_a_outer && col < uniforms.dim_inner) {
4773      ${I}
4774    }
4775    return ${Ao(a,c)}(0.0);`:s&&n?`
4776    let col = colIn * ${a};
4777    ${I}`:`
4778    let col = colIn * ${a};
4779    if (row < uniforms.dim_inner && col < uniforms.dim_b_outer) {
4780      ${I}
4781    }
4782    return ${Ao(a,c)}(0.0);`,j=t?s&&n?p(o):`
4783    let col = colIn * ${o};
4784    if (row < uniforms.dim_inner && col < uniforms.dim_b_outer) {
4785      ${p(o)}
4786    }
4787    return ${Ao(o,c)}(0.0);`:`
4788    let col = colIn * ${o};
4789    if (row < uniforms.dim_inner && col < uniforms.dim_a_outer) {
4790      ${p(o)}
4791    }
4792    return ${Ao(o,c)}(0.0);`,L=Ao(l,c),K=Ao(t?a:o,c),D=Ao(t?o:a,c),R=Iv(i,L,c);return`
4793    fn mm_readA(batch: i32, row : i32, colIn : i32) -> ${K} {
4794      ${t?M:j}
4795    }
4796
4797    fn mm_readB(batch: i32, row : i32, colIn : i32) -> ${D} {
4798      ${t?j:M}
4799    }
4800
4801    fn mm_write(batch: i32, row : i32, colIn : i32, valueIn : ${L}) {
4802      let col = colIn * ${l};
4803      if (row < uniforms.dim_a_outer && col < uniforms.dim_b_outer)
4804      {
4805      var value = valueIn;
4806      let outWidth = ${t?"i32(uniforms.result_shape[2])":"i32(uniforms.result_shape[3])"};
4807      ${y}
4808      ${cte(r)}
4809      ${R}
4810      setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value);
4811      }
4812    }`},dte=(t,e,n,s,r,i,a,o,l)=>{let c=e.format==="NHWC",h=c?t[0].dims[3]:t[0].dims[1],p=n[0],m=c?n[2]:n[3],y=c?n[1]:n[2],v=c?n[3]:n[1],b=c&&(h%4===0||h%3===0)&&v%4===0,S=c?v:m*y,E=c?m*y:v,I=[8,8,1],M=s<=8?[4,1,1]:[4,4,1],j=[Math.ceil(S/I[0]/M[0]),Math.ceil(E/I[1]/M[1]),Math.ceil(p/I[2]/M[2])];cr("verbose",()=>`[conv2d_mm_webgpu] dispatch = ${j}`);let L=b?c&&h%4!==0?3:4:1,K=I[1]*M[1],D=I[0]*M[0],R=Math.max(I[0]*L,I[1]),B=s%K===0,G=r%D===0,X=i%R===0,H=b?[L,4,4]:[1,1,1],Y=[{type:6,data:s},{type:6,data:r},{type:6,data:i},{type:6,data:[e.pads[0],e.pads[1]]},{type:6,data:e.strides},{type:6,data:e.dilations}];Nv(e,Y),Y.push(...Mn(t[0].dims,t[1].dims));let F=["rank","rank"];a&&(Y.push(...Mn(t[2].dims)),F.push("rank")),Y.push(...Mn(n));let we=me=>{let xe=[{name:"dim_a_outer",type:"i32"},{name:"dim_b_outer",type:"i32"},{name:"dim_inner",type:"i32"},{name:"pad",type:"i32",length:2},{name:"stride",type:"i32",length:2},{name:"dilation",type:"i32",length:2}];Rv(e,xe);let Le=b?4:1,ve=lo(t[0].dataType),ce=`
4813      fn setOutputAtIndex(flatIndex : i32, value : ${b?`vec4<${ve}>`:ve}) {
4814        result[flatIndex] = ${b?`vec4<${ve}>`:ve}(value);
4815      }
4816      fn setOutputAtCoords(d0 : i32, d1 : i32, d2 : i32, d3 : i32, value : ${b?`vec4<${ve}>`:ve}) {
4817        let flatIndex = getOutputIndexFromCoords(vec4<i32>(d0, d1, d2, d3));
4818        setOutputAtIndex(flatIndex ${b?"/ 4":""}, value);
4819      }`,ie=St("x",t[0].dataType,t[0].dims.length,L===3?1:L),de=St("w",t[1].dataType,t[1].dims.length,Le),Re=[ie,de],Se=wn("result",t[0].dataType,n.length,Le);if(a){let De=St("bias",t[2].dataType,t[2].dims.length,Le);Re.push(De),ce+=`
4820        fn getBiasByOutputCoords(coords : vec4<i32>) -> ${b?`vec4<${ve}>`:ve} {
4821          return bias[coords.${c?"w":"y"}${b?"/ 4":""}];
4822        }`}return`
4823        ${ute("uniforms.result_strides")}
4824        //struct Uniforms { xShape : vec4<i32>, wShape : vec4<i32>, outShape : vec4<i32>,
4825        //  outShapeStrides: vec3<i32>, filterDims : vec2<i32>, pad : vec2<i32>, stride : vec2<i32>,
4826        //  dilation : vec2<i32>, dimAOuter : i32, dimBOuter : i32, dimInner : i32 };
4827        ${me.registerUniforms(xe).declareVariables(...Re,Se)}
4828        ${ce}
4829        ${G8(c,B,G,X,a,e,H[0],H[1],H[2],ve)}
4830        ${b?ZD(M,I,ve,void 0,!c,R):e5(M,I,ve,void 0,!c,R,!1,void 0,o)}`};return{name:"Conv2DMatMul",shaderCache:{hint:`${e.cacheKey};${L};${b};${B};${G};${X};${K};${D};${R}`,inputDependencies:F},getRunData:()=>({outputs:[{dims:l?l(n):n,dataType:t[0].dataType}],dispatchGroup:{x:j[0],y:j[1],z:j[2]},programUniforms:Y}),getShaderSource:we}}}),H8,S$,z2,q8,E$,W8,hte,fte,$Ae=qt(()=>{ts(),zm(),Ts(),Rs(),Hv(),Z7(),H8=t=>{let e=1;for(let n=0;n<t.length;n++)e*=t[n];return e},S$=t=>typeof t=="number"?[t,t,t]:t,z2=(t,e)=>e<=1?t:t+(t-1)*(e-1),q8=(t,e,n,s=1)=>{let r=z2(e,s);return Math.floor((t[0]*(n-1)-n+r)/2)},E$=(t,e,n,s,r)=>{r==null&&(r=q8(t,e[0],s[0]));let i=[0,0,0,n];for(let a=0;a<3;a++)t[a]+2*r>=e[a]&&(i[a]=Math.trunc((t[a]-e[a]+2*r)/s[a]+1));return i},W8=(t,e,n,s,r,i,a,o,l,c)=>{let h,p,m,y;if(t==="VALID"&&(t=0),typeof t=="number"){h={top:t,bottom:t,left:t,right:t,front:t,back:t};let v=E$([e,n,s,1],[o,l,c],1,[r,i,a],t);p=v[0],m=v[1],y=v[2]}else if(Array.isArray(t)){if(!t.every((b,S,E)=>b===E[0]))throw Error(`Unsupported padding parameter: ${t}`);h={top:t[0],bottom:t[1],left:t[2],right:t[3],front:t[4],back:t[5]};let v=E$([e,n,s,1],[o,l,c],1,[r,i,a],t[0]);p=v[0],m=v[1],y=v[2]}else if(t==="SAME_UPPER"){p=Math.ceil(e/r),m=Math.ceil(n/i),y=Math.ceil(s/a);let v=(p-1)*r+o-e,b=(m-1)*i+l-n,S=(y-1)*a+c-s,E=Math.floor(v/2),I=v-E,M=Math.floor(b/2),j=b-M,L=Math.floor(S/2),K=S-L;h={top:M,bottom:j,left:L,right:K,front:E,back:I}}else throw Error(`Unknown padding parameter: ${t}`);return{padInfo:h,outDepth:p,outHeight:m,outWidth:y}},hte=(t,e,n,s,r,i=!1,a="channelsLast")=>{let o,l,c,h,p;if(a==="channelsLast")[o,l,c,h,p]=t;else if(a==="channelsFirst")[o,p,l,c,h]=t;else throw new Error(`Unknown dataFormat ${a}`);let[m,,y,v,b]=e,[S,E,I]=S$(n),[M,j,L]=S$(s),K=z2(y,M),D=z2(v,j),R=z2(b,L),{padInfo:B,outDepth:G,outHeight:X,outWidth:H}=W8(r,l,c,h,S,E,I,K,D,R),Y=i?m*p:m,F=[0,0,0,0,0];return a==="channelsFirst"?F=[o,Y,G,X,H]:a==="channelsLast"&&(F=[o,G,X,H,Y]),{batchSize:o,dataFormat:a,inDepth:l,inHeight:c,inWidth:h,inChannels:p,outDepth:G,outHeight:X,outWidth:H,outChannels:Y,padInfo:B,str
vendor: 5,047 bytes, lines 4830-4901
4830ideDepth:S,strideHeight:E,strideWidth:I,filterDepth:y,filterHeight:v,filterWidth:b,effectiveFilterDepth:K,effectiveFilterHeight:D,effectiveFilterWidth:R,dilationDepth:M,dilationHeight:j,dilationWidth:L,inShape:t,outShape:F,filterShape:e}},fte=(t,e,n,s,r,i)=>{let a=i==="channelsLast";a?t[0].dims[3]:t[0].dims[1];let o=[64,1,1],l={x:n.map((S,E)=>E)},c=[Math.ceil(H8(l.x.map(S=>n[S]))/o[0]),1,1];cr("verbose",()=>`[conv3d_naive_webgpu] dispatch = ${c}`);let h=1,p=dt.size(n),m=[{type:12,data:p},{type:12,data:s},{type:12,data:r},{type:12,data:e.strides},{type:12,data:e.dilations}];Nv(e,m),m.push(...Mn(t[0].dims,t[1].dims));let y=["rank","rank"],v=t.length===3;v&&(m.push(...Mn(t[2].dims)),y.push("rank")),m.push(...Mn(n));let b=S=>{let E=[{name:"output_size",type:"u32"},{name:"filter_dims",type:"u32",length:s.length},{name:"pads",type:"u32",length:r.length},{name:"strides",type:"u32",length:e.strides.length},{name:"dilations",type:"u32",length:e.dilations.length}];Rv(e,E);let I=1,M=lo(t[0].dataType),j=St("x",t[0].dataType,t[0].dims.length,h),L=St("W",t[1].dataType,t[1].dims.length,I),K=[j,L],D=wn("result",t[0].dataType,n.length,I),R="";if(v){let X=St("bias",t[2].dataType,t[2].dims.length,I);K.push(X),R+=`
4831        fn getBiasByOutputCoords(coords : array<u32, 5>) -> ${M} {
4832          return bias[${a?An("coords",4,5):An("coords",1,5)}];
4833        }`}let B=Ao(h,M),G=Iv(e,B,M);return`
4834            ${R}
4835            fn getX(d0 : u32, d1 : u32, d2 : u32, d3 : u32, d4 : u32) -> f32 {
4836              let aIndices = array<u32, 5>(d0, d1, d2, d3, d4);
4837              return ${j.getByIndices("aIndices")};
4838            }
4839            fn getW(d0 : u32, d1 : u32, d2 : u32, d3 : u32, d4 : u32) -> f32 {
4840              let aIndices = array<u32, 5>(d0, d1, d2, d3, d4);
4841              return ${L.getByIndices("aIndices")};
4842            }
4843          ${S.registerUniforms(E).declareVariables(...K,D)}
4844          ${S.mainStart()}
4845          ${S.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
4846              let coords = ${D.offsetToIndices("global_idx")};
4847              let batch = ${An("coords",0,j.rank)};
4848              let d2 = ${a?An("coords",j.rank-1,j.rank):An("coords",1,j.rank)};
4849              let xFRCCorner = vec3<u32>(${a?An("coords",1,j.rank):An("coords",2,j.rank)},
4850              ${a?An("coords",2,j.rank):An("coords",3,j.rank)},
4851              ${a?An("coords",3,j.rank):An("coords",4,j.rank)}) * uniforms.strides - uniforms.pads;
4852              let xFCorner = xFRCCorner.x;
4853              let xRCorner = xFRCCorner.y;
4854              let xCCorner = xFRCCorner.z;
4855              let xShapeY = ${a?An("uniforms.x_shape",1,j.rank):An("uniforms.x_shape",2,j.rank)};
4856              let xShapeZ = ${a?An("uniforms.x_shape",2,j.rank):An("uniforms.x_shape",3,j.rank)};
4857              let xShapeW = ${a?An("uniforms.x_shape",3,j.rank):An("uniforms.x_shape",4,j.rank)};
4858              let xShapeU = ${a?An("uniforms.x_shape",4,j.rank):An("uniforms.x_shape",1,j.rank)};
4859              let inputDepthNearestVec4 = (xShapeU / 4) * 4;
4860              let inputDepthVec4Remainder = xShapeU % 4;
4861
4862              var value = 0.0;
4863              for (var wF = 0u; wF < uniforms.filter_dims[0]; wF++) {
4864                let xF = xFCorner + wF * uniforms.dilations[0];
4865                if (xF < 0 || xF >= xShapeY) {
4866                  continue;
4867                }
4868
4869                for (var wR = 0u; wR < uniforms.filter_dims[1]; wR++) {
4870                  let xR = xRCorner + wR * uniforms.dilations[1];
4871                  if (xR < 0 || xR >= xShapeZ) {
4872                    continue;
4873                  }
4874
4875                  for (var wC = 0u; wC < uniforms.filter_dims[2]; wC++) {
4876                    let xC = xCCorner + wC * uniforms.dilations[2];
4877                    if (xC < 0 || xC >= xShapeW) {
4878                      continue;
4879                    }
4880
4881                    for (var d1 = 0u; d1 < inputDepthNearestVec4; d1 += 4) {
4882                      ${a?`let xValues = vec4<f32>(
4883                               getX(batch, xF, xR, xC, d1),
4884                               getX(batch, xF, xR, xC, d1 + 1),
4885                               getX(batch, xF, xR, xC, d1 + 2),
4886                               getX(batch, xF, xR, xC, d1 + 3));
4887                            `:`let xValues = vec4<f32>(
4888                               getX(batch, d1, xF, xR, xC),
4889                               getX(batch, d1 + 1, xF, xR, xC),
4890                               getX(batch, d1 + 2, xF, xR, xC),
4891                               getX(batch, d1 + 3, xF, xR, xC));
4892                            `}
4893                            let wValues = vec4<f32>(
4894                              getW(d2, d1, wF, wR, wC),
4895                              getW(d2, d1 + 1, wF, wR, wC),
4896                              getW(d2, d1 + 2, wF, wR, wC),
4897                              getW(d2, d1 + 3, wF, wR, wC));
4898                      value += dot(xValues, wValues);
4899                    }
4900                    if (inputDepthVec4Remainder == 1) {
4901                        ${a?`value += getX(batch, xF, xR, xC, inputDepthNearest
vendor: 5,411 bytes, lines 4901-4991
4901Vec4)
4902                          * getW(d2, inputDepthNearestVec4, wF, wR, wC);`:`value += getX(batch, inputDepthNearestVec4, xF, xR, xC)
4903                          * getW(d2, inputDepthNearestVec4, wF, wR, wC);`}
4904                    } else if (inputDepthVec4Remainder == 2) {
4905                      ${a?`let xValues = vec2<f32>(
4906                        getX(batch, xF, xR, xC, inputDepthNearestVec4),
4907                        getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1));
4908                      `:`let xValues = vec2<f32>(
4909                        getX(batch, inputDepthNearestVec4, xF, xR, xC),
4910                        getX(batch, inputDepthNearestVec4 + 1, xF, xR, xC));
4911                    `}
4912                    let wValues = vec2<f32>(
4913                      getW(d2, inputDepthNearestVec4, wF, wR, wC),
4914                      getW(d2, inputDepthNearestVec4 + 1, wF, wR, wC));
4915                      value += dot(xValues, wValues);
4916                    } else if (inputDepthVec4Remainder == 3) {
4917                      ${a?`let xValues = vec3<f32>(
4918                        getX(batch, xF, xR, xC, inputDepthNearestVec4),
4919                        getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1),
4920                        getX(batch, xF, xR, xC, inputDepthNearestVec4 + 2));
4921                      `:`let xValues = vec3<f32>(
4922                        getX(batch, inputDepthNearestVec4, xF, xR, xC),
4923                        getX(batch, inputDepthNearestVec4 + 1, xF, xR, xC),
4924                        getX(batch, inputDepthNearestVec4 + 2, xF, xR, xC));
4925                    `}
4926                    let wValues = vec3<f32>(
4927                      getW(d2, inputDepthNearestVec4, wF, wR, wC),
4928                      getW(d2, inputDepthNearestVec4 + 1, wF, wR, wC),
4929                      getW(d2, inputDepthNearestVec4 + 2, wF, wR, wC));
4930                      value += dot(xValues, wValues);
4931                    }
4932                  }
4933                }
4934              }
4935              ${v?"value = value + getBiasByOutputCoords(coords)":""};
4936              ${G}
4937              result[global_idx] = f32(value);
4938          }`};return{name:"Conv3DNaive",shaderCache:{hint:`${e.cacheKey};${a};${h};${v}`,inputDependencies:y},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:c[0],y:c[1],z:c[2]},programUniforms:m}),getShaderSource:b}}}),pte,mte,DAe=qt(()=>{ts(),Ts(),Rs(),Hv(),pte=(t,e,n,s)=>{let r=t.length>2,i=r?"value += b[output_channel];":"",a=t[0].dims,o=t[1].dims,l=e.format==="NHWC",c=l?n[3]:n[1],h=c/e.group,p=l&&h>=4?Wi(c):1,m=dt.size(n)/p,y=[{type:12,data:m},{type:12,data:e.dilations},{type:12,data:[e.strides[0],e.strides[1]]},{type:12,data:[e.pads[0],e.pads[1]]},{type:12,data:h}];Nv(e,y),y.push(...Mn(a,[o[0],o[1],o[2],o[3]/p]));let v=r?["rank","rank","rank"]:["rank","rank"];y.push(...Mn([n[0],n[1],n[2],n[3]/p]));let b=S=>{let E=wn("output",t[0].dataType,n.length,p),I=lo(E.type.tensor),M=Iv(e,E.type.value,I),j=St("x",t[0].dataType,a.length),L=St("w",t[1].dataType,o.length,p),K=[j,L];r&&K.push(St("b",t[2].dataType,t[2].dims,p));let D=[{name:"output_size",type:"u32"},{name:"dilations",type:"u32",length:e.dilations.length},{name:"strides",type:"u32",length:2},{name:"pads",type:"u32",length:2},{name:"output_channels_per_group",type:"u32"}];Rv(e,D);let R=l?`
4939      for (var wHeight: u32 = 0u; wHeight < uniforms.w_shape[0]; wHeight++) {
4940        let xHeight = xRCCorner.x + wHeight * uniforms.dilations[0];
4941
4942        if (xHeight < 0u || xHeight >= uniforms.x_shape[1]) {
4943          continue;
4944        }
4945
4946        for (var wWidth: u32 = 0u; wWidth < uniforms.w_shape[1]; wWidth++) {
4947          let xWidth = xRCCorner.y + wWidth * uniforms.dilations[1];
4948          if (xWidth < 0u || xWidth >= uniforms.x_shape[2]) {
4949            continue;
4950          }
4951
4952          for (var wInChannel: u32 = 0u; wInChannel < uniforms.w_shape[2]; wInChannel++) {
4953            let input_channel = in_channel_offset + wInChannel;
4954            let xVal = ${j.get("batch","xHeight","xWidth","input_channel")};
4955            let wVal = ${L.get("wHeight","wWidth","wInChannel","output_channel")};
4956            value += xVal * wVal;
4957          }
4958        }
4959      }
4960      `:`
4961      for (var wInChannel: u32 = 0u; wInChannel < uniforms.w_shape[1]; wInChannel++) {
4962        let input_channel = in_channel_offset + wInChannel;
4963        for (var wHeight: u32 = 0u; wHeight < uniforms.w_shape[2]; wHeight++) {
4964          let xHeight = xRCCorner.x + wHeight * uniforms.dilations[0];
4965
4966          if (xHeight < 0u || xHeight >= uniforms.x_shape[2]) {
4967            continue;
4968          }
4969
4970          for (var wWidth: u32 = 0u; wWidth < uniforms.w_shape[3]; wWidth++) {
4971            let xWidth = xRCCorner.y + wWidth * uniforms.dilations[1];
4972            if (xWidth < 0u || xWidth >= uniforms.x_shape[3]) {
4973              continue;
4974            }
4975
4976            let xVal = ${j.get("batch","input_channel","xHeight","xWidth")};
4977            let wVal = ${L.get("output_channel","wInChannel","wHeight","wWidth")};
4978            value += xVal * wVal;
4979          }
4980        }
4981      }
4982      `;return`
4983  ${S.registerUniforms(D).declareVariables(...K,E)}
4984
4985  ${S.mainStart()}
4986    ${S.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
4987
4988    let outputIndices = ${E.offsetToIndices("global_idx")};
4989    let batch: u32 = outputIndices[0];
4990    let output_channel: u32 = outputIndices[${l?3:1}];
4991    let xRCCorner: vec2<u32> = vec2<u32>(outputIndices[${l?1:2}
4991], outputIndices[${l?2:3}]) * uniforms.strides - uniforms.pads;
4992    let group_id: u32 = output_channel * ${p} / uniforms.output_channels_per_group;
4993    var in_channel_offset = group_id * uniforms.w_shape[${l?2:1}];
4994
4995    var value: ${E.type.value} = ${E.type.value}(0);
4996    ${R}
4997    ${i}
4998    ${M}
4999    ${E.setByOffset("global_idx","value")}
5000  }`};return{name:"GroupedConv",shaderCache:{hint:`${e.cacheKey}_${p}`,inputDependencies:v},getRunData:()=>({outputs:[{dims:s?s(n):n,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(m/64)},programUniforms:y}),getShaderSource:b}},mte=(t,e,n,s)=>{let r=t.length>2,i=Wi(n[3]),a=Wi(n[2]),o=dt.size(n)/i/a,l=[t[0].dims[0],t[0].dims[1],t[0].dims[2],t[0].dims[3]/i],c=[t[1].dims[0],t[1].dims[1],t[1].dims[2],t[1].dims[3]/i],h=[n[0],n[1],n[2],n[3]/i],p=[{type:12,data:o},{type:6,data:[e.strides[0],e.strides[1]]},{type:6,data:[e.pads[0],e.pads[1]]}];Nv(e,p),p.push(...Mn(l,c,h));let m=(a-1)*e.strides[1]+c[1],y=v=>{let b=wn("output",t[0].dataType,h.length,i),S=lo(b.type.tensor),E=Iv(e,b.type.value,S),I=St("x",t[0].dataType,l.length,i),M=St("w",t[1].dataType,c.length,i),j=[I,M];r&&j.push(St("b",t[2].dataType,t[2].dims,i));let L=r?"value += b[output_channel];":"",K=[{name:"output_size",type:"u32"},{name:"strides",type:"i32",length:2},{name:"pads",type:"i32",length:2}];return Rv(e,K),`
5001  ${v.registerUniforms(K).declareVariables(...j,b)}
5002  ${v.mainStart()}
5003    ${v.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5004    let width0 = uniforms.output_shape[3];
5005    let output_channel = global_idx % width0;
5006    var index1 = global_idx / width0;
5007    let width1 = uniforms.output_shape[2] / ${a}u;
5008    let col = (index1 % width1) * ${a}u;
5009    index1 = index1 / width1;
5010    let row = index1 % uniforms.output_shape[1];
5011    let batch = index1 / uniforms.output_shape[1];
5012
5013    let x_corner = vec2<i32>(i32(row), i32(col)) * uniforms.strides - uniforms.pads;
5014
5015    var x_vals: array<${I.type.value}, ${m}>;
5016    var values: array<${b.type.value}, ${a}>;
5017    let input_channel = output_channel;
5018    // Use constant instead of uniform can give better performance for w's height/width.
5019    for (var w_height: u32 = 0u; w_height < ${c[0]}; w_height++) {
5020      let x_height = x_corner.x + i32(w_height);
5021      if (x_height >= 0 && u32(x_height) < uniforms.x_shape[1]) {
5022        for (var i = 0; i < ${m}; i++) {
5023          let x_width = x_corner.y + i;
5024          if (x_width >= 0 && u32(x_width) < uniforms.x_shape[2]) {
5025            x_vals[i] = ${I.get("batch","u32(x_height)","u32(x_width)","input_channel")};
5026          } else {
5027            x_vals[i] = ${I.type.value}(0);
5028          }
5029        }
5030        for (var w_width: u32 = 0u; w_width < ${c[1]}; w_width++) {
5031          let w_val = ${M.get("w_height","w_width","0","output_channel")};
5032          for (var i = 0u; i < ${a}u; i++) {
5033            values[i] = fma(x_vals[i * u32(uniforms.strides[1]) + w_width], w_val, values[i]);
5034          }
5035        }
5036      }
5037    }
5038
5039    for (var i = 0u; i < ${a}u; i++) {
5040      var value = values[i];
5041      ${L}
5042      ${E}
5043      ${b.set("batch","row","col + i","output_channel","value")};
5044    }
5045  }`};return{name:"GroupedConv-Vectorize",shaderCache:{hint:`${e.cacheKey};${i};${a};${m};${c[0]};${c[1]}`,inputDependencies:r?["rank","rank","type"]:["rank","rank"]},getRunData:()=>({outputs:[{dims:s?s(n):n,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(o/64)},programUniforms:p}),getShaderSource:y}}}),K8,Kk,Y8,Yk,t5,T$,X8,J8,n5,OAe=qt(()=>{Ts(),PAe(),$Ae(),nj(),DAe(),Hv(),tj(),ty(),K8=(t,e,n,s,r,i)=>{let a=t[0],o=t.slice(i?1:2,i?3:4),l=o.length,c=e[0],h=e.slice(2).map((m,y)=>m+(m-1)*(n[y]-1)),p=o.map((m,y)=>m+s[y]+s[y+l]).map((m,y)=>Math.floor((m-h[y]+r[y])/r[y]));return p.splice(0,0,a),p.splice(i?3:1,0,c),p},Kk=[2,3,1,0],Y8=(t,e)=>{if(!t||t.length!==2&&t.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(t[0].dims.length>5)throw new Error("greater than 5D is not supported");if(t[0].dims.length!==t[1].dims.length)throw new Error("filter does not have same dimension as input");let n=t[0].dims[e.format==="NHWC"?t[0].dims.length-1:1],s=t[1].dims[1]*e.group;if(n!==s)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(t.length===3&&(t[2].dims.length!==1||t[1].dims[0]!==t[2].dims[
vendor: 25,870 bytes, lines 5045-5195
50450]))throw new Error("invalid bias");let r=t[0].dims.length-2;if(e.dilations.length!==r)throw new Error(`dilations should be ${r}D`);if(e.strides.length!==r)throw new Error(`strides should be ${r}D`);if(e.pads.length!==r*2)throw new Error(`pads should be ${r*2}D`);if(e.kernelShape.length!==0&&e.kernelShape.length!==t[1].dims.length-2)throw new Error("invalid kernel shape")},Yk=(t,e)=>{let n=t.kernelShape.slice();n.length<e[1].dims.length-2&&n.push(...Array(e[1].dims.length-2-n.length).fill(0));for(let i=2;i<e[1].dims.length;++i)n[i-2]===0&&(n[i-2]=e[1].dims[i]);let s=t.pads.slice();lR.adjustPadsBasedOnAutoPad(e[0].dims,t.strides,t.dilations,n,s,t.format==="NHWC",t.autoPad);let r=Object.assign({},t);return Object.assign(r,{kernelShape:n,pads:s}),r},t5=t=>{let e=Q7(t),n=t.format,s=["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][t.auto_pad],r=t.dilations,i=t.group,a=t.kernel_shape,o=t.pads,l=t.strides,c=t.w_is_const();return{autoPad:s,format:n,dilations:r,group:i,kernelShape:a,pads:o,strides:l,wIsConst:c,...e,cacheKey:`${t.format};${e.activation};`}},T$=(t,e,n,s)=>{let r=n.format==="NHWC",i=K8(e[0].dims,e[1].dims,n.dilations,n.pads,n.strides,r);if(n.group!==1){let K=[e[0]];if(r){let D=t.kernelCustomData.wT??t.compute(Ru(e[1],Kk),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=D),K.push(D)}else K.push(e[1]);e.length===3&&K.push(e[2]),!t.adapterInfo.isArchitecture("ampere")&&r&&e[1].dims[0]===n.group&&e[1].dims[1]===1&&n.dilations[0]===1&&n.dilations[1]===1?t.compute(mte(K,n,i,s),{inputs:K}):t.compute(pte(K,n,i,s),{inputs:K});return}let a=e.length===3,o=e[0].dims[r?1:2],l=e[0].dims[r?2:3],c=e[0].dims[r?3:1],h=e[1].dims[2],p=e[1].dims[3],m=i[r?1:2],y=i[r?2:3],v=i[r?3:1],b=r&&h===o&&p===l&&n.pads[0]===0&&n.pads[1]===0;if(b||h===1&&p===1&&n.dilations[0]===1&&n.dilations[1]===1&&n.strides[0]===1&&n.strides[1]===1&&n.pads[0]===0&&n.pads[1]===0){let K=i[0],D,R,B,G=[];if(r){let Y=t.kernelCustomData.wT??t.compute(Ru(e[1],Kk),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];if(n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=Y),b){let F=o*l*c;D=e[0].reshape([1,K,F]),R=Y.reshape([1,F,v]),B=[1,K,v]}else D=e[0].reshape([K,o*l,c]),R=Y.reshape([1,c,v]),B=[K,m*y,v];G.push(D),G.push(R)}else D=e[0].reshape([K,c,o*l]),R=e[1].reshape([1,v,c]),B=[K,v,m*y],G.push(R),G.push(D);a&&G.push(e[2]);let X=B[2],H=G[0].dims[G[0].dims.length-1];X<8&&H<8?t.compute(ej(G,n,i,B,r,s),{inputs:G}):t.compute(uR(G,n,i,B,r,s),{inputs:G});return}let S=!0,E=t.kernelCustomData.wT??t.compute(Ru(e[1],Kk),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=E);let I=[e[0],E];a&&I.push(e[2]);let M=r?m*y:v,j=r?v:m*y,L=h*p*c;t.compute(dte(I,n,i,M,j,L,a,S,s),{inputs:I})},X8=(t,e)=>{let n=e.format==="NHWC",s=[t.inputs[0].reshape(n?[t.inputs[0].dims[0],1,t.inputs[0].dims[1],t.inputs[0].dims[2]]:[t.inputs[0].dims[0],t.inputs[0].dims[1],1,t.inputs[0].dims[2]]),t.inputs[1].reshape([t.inputs[1].dims[0],t.inputs[1].dims[1],1,t.inputs[1].dims[2]])];t.inputs.length===3&&s.push(t.inputs[2]);let r=[0,e.pads[0],0,e.pads[1]],i=[1].concat(e.strides),a=[1].concat(e.dilations),o=[1].concat(e.kernelShape),l=Yk({...e,pads:r,strides:i,dilations:a,kernelShape:o},s);T$(t,s,l,c=>n?[c[0],c[2],c[3]]:[c[0],c[1],c[3]])},J8=(t,e,n)=>{let s=n.format==="NHWC"?"channelsLast":"channelsFirst",r=Yk(n,e),i=n.autoPad==="NOTSET"?n.pads:n.autoPad,a=hte(e[0].dims,e[1].dims,n.strides,n.dilations,i,!1,s);t.compute(fte(e,r,a.outShape,[a.filterDepth,a.filterHeight,a.filterWidth],[a.padInfo.front,a.padInfo.top,a.padInfo.left],s))},n5=(t,e)=>{if(Y8(t.inputs,e),t.inputs[0].dims.length===3)X8(t,e);else if(t.inputs[0].dims.length===5)J8(t,t.inputs,e);else{let n=Yk(e,t.inputs);T$(t,t.inputs,n)}}}),gte,LAe=qt(()=>{ts(),zm(),Ts(),Rs(),gte=(t,e,n)=>{let s=t.length>2,r=e.outputShape,i=e.format==="NHWC",a=e.group,o=t[1].dims,l=o[2]/a,c=o[3],h=i?Wi(l):1,p=i&&c===1&&l>=4,m=p?Math.floor(l/4)*4:Math.floor(l/h)*h,y=l-m,v=i?Wi(c):1,b=i?c===1?h:v:1,S=dt.size(r)/v,E=[Math.ceil(S/64),1,1];cr("verbose",()=>`[conv2d_backprop_webgpu] dispatch = ${E}`);let I=["rank","rank"],M=[e.strides[0],e.strides[1]],j=[e.kernelShape[i?1:2],e.kernelShape[i?2:3]],L=[e.dilations[0],e.dilations[1]],K=[j[0]+(e.dilations[0]<=1?0:(e.kernelShape[i?1:2]-1)*(e.dilations[0]-1)),j[1]+(e.dilations[1]<=1?0:(e.kernelShape[i?2:3]-1)*(e.dilations[1]-1))],D=[K[0]-1-Math.floor((e.pads[0]+e.pads[2])/2),K[1]-1-Math.floor((e.pads[1]+e.pads[3])/2)],R=[{type:12,data:S},{type:12,data:M},{type:12,data:j},{type:12,data:L},{type:12,data:K},{type:6,data:D},{type:12,data:m},{type:12,data:l},{type:12,data:c},...Mn(t[0].dims,t[1].dims)];s&&(R.push(...Mn(t[2].dims)),I.push("rank")),R.push(...Mn(r));let B=G=>{let X=[{name:"output_size",type:"u32"},{name:"strides",type:"u32",length:M.length},{name:"filter_dims",type:"u32",length:j.length},{name:"dilations",type:"u32",length:j.length},{name:"effective_filter_dims",type:"u32",length:K.length},{name:"pads",type:"i32",length:D.length},{name:"input_channels_per_group_int",type:"u32"},{name:"input_channels_per_group",type:"u32"},{name:"output_channels_per_group",type:"u32"}],H=lo(t[0].dataType),Y=i?1:2,F=i?2:3,we=i?3:1,me=St("W",t[1].dataType,t[1].dims.length,b),xe=St("Dy",t[0].dataType,t[0].dims.length,h),Le=[xe,me];s&&Le.push(St("bias",t[2].dataType,[r[we]].length,v));let ve=wn("result",t[0].dataType,r.length,v),ce=()=>{let Re="";if(p)h===4?Re+=`
5046        let xValue = ${xe.getByOffset("x_offset")};
5047        let wValue = ${me.getByOffset("w_offset")};
5048        dotProd = dotProd + dot(xValue, wValue);
5049        x_offset += 1u;
5050        w_offset += 1u;`:h===2?Re+=`
5051          dotProd = dotProd + dot(vec4<${H}>(${xe.getByOffset("x_offset")}, ${xe.getByOffset("x_offset + 1u")}), vec4<${H}>(${me.getByOffset("w_offset")}, ${me.getByOffset("w_offset + 1u")}));
5052          x_offset += 2u;
5053          w_offset += 2u;`:h===1&&(Re+=`
5054          dotProd = dotProd + dot(vec4<${H}>(${xe.getByOffset("x_offset")}, ${xe.getByOffset("x_offset + 1u")}, ${xe.getByOffset("x_offset + 2u")}, ${xe.getByOffset("x_offset + 3u")}), vec4<${H}>(${me.getByOffset("w_offset")}, ${me.getByOffset("w_offset + 1u")}, ${me.getByOffset("w_offset + 2u")}, ${me.getByOffset("w_offset + 3u")}));
5055          x_offset += 4u;
5056          w_offset += 4u;`);else if(Re+=`
5057                  let xValue = ${i?xe.getByOffset(`${xe.indicesToOffset(`${xe.type.indices}(batch, idyR, idyC, inputChannel)`)} / ${h}`):xe.get("batch","inputChannel","idyR","idyC")};
5058        `,h===1)Re+=`
5059          let w_offset = ${me.indicesToOffset(`${me.type.indices}(u32(wRPerm), u32(wCPerm), inputChannel, wOutChannel)`)};
5060          let wValue = ${me.getByOffset(`w_offset / ${b}`)};
5061          dotProd = dotProd + xValue * wValue;`;else for(let Se=0;Se<h;Se++)Re+=`
5062            let wValue${Se} = ${me.getByOffset(`${me.indicesToOffset(`${me.type.indices}(u32(wRPerm), u32(wCPerm), inputChannel + ${Se}, wOutChannel)`)} / ${b}`)};
5063            dotProd = dotProd + xValue[${Se}] * wValue${Se};`;return Re},ie=()=>{if(y===0)return"";if(!p)throw new Error(`packInputAs4 ${p} is not true.`);let Re="";if(h===1){Re+="dotProd = dotProd";for(let Se=0;Se<y;Se++)Re+=`
5064            + ${xe.getByOffset(`x_offset + ${Se}`)} * ${me.getByOffset(`w_offset + ${Se}`)}`;Re+=";"}else if(h===2){if(y!==2)throw new Error(`Invalid inputChannelsRemainder ${y}.`);Re+=`
5065          let xValue = ${xe.getByOffset("x_offset")};
5066          let wValue = ${me.getByOffset("w_offset")};
5067          dotProd = dotProd + dot(xValue, wValue);`}return Re},de=`
5068            let outputIndices = ${ve.offsetToIndices(`global_idx * ${v}`)};
5069            let batch = ${ve.indicesGet("outputIndices",0)};
5070            let d1 = ${ve.indicesGet("outputIndices",we)};
5071            let r = ${ve.indicesGet("outputIndices",Y)};
5072            let c = ${ve.indicesGet("outputIndices",F)};
5073            let dyCorner = vec2<i32>(i32(r), i32(c)) - uniforms.pads;
5074            let dyRCorner = dyCorner.x;
5075            let dyCCorner = dyCorner.y;
5076            let groupId = d1 / uniforms.output_channels_per_group;
5077            let wOutChannel = d1 - groupId * uniforms.output_channels_per_group;
5078            // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
5079            // ? = to be determined. : = across all values in that axis.
5080            var dotProd = ${ve.type.value}(0.0);
5081            var wR: u32 = 0;
5082            if (uniforms.dilations.x == 1) {
5083              // Minimum wR >= 0 that satisfies (dyRCorner + wR) % (uniforms.strides.x) == 0
5084              wR = u32(((dyRCorner + i32(uniforms.strides.x) - 1) / i32(uniforms.strides.x)) * i32(uniforms.strides.x) - dyRCorner);
5085            }
5086            for (; wR < uniforms.effective_filter_dims.x; wR = wR + 1) {
5087              if (wR % uniforms.dilations.x != 0) {
5088                continue;
5089              }
5090              let dyR = (${H}(dyRCorner) + ${H}(wR)) / ${H}(uniforms.strides[0]);
5091              let wRPerm = uniforms.filter_dims.x - 1 - wR / uniforms.dilations.x;
5092              if (dyR < 0.0 || dyR >= ${H}(uniforms.Dy_shape[${Y}]) || fract(dyR) > 0.0 ||
5093                  wRPerm < 0) {
5094                continue;
5095              }
5096              let idyR: u32 = u32(dyR);
5097              var wC: u32 = 0;
5098              if (uniforms.dilations.y == 1) {
5099                // Minimum wC >= 0 that satisfies (dyCCorner + wC) % (uniforms.strides.y) == 0
5100                wC = u32(((dyCCorner + i32(uniforms.strides.y) - 1) / i32(uniforms.strides.y)) * i32(uniforms.strides.y) - dyCCorner);
5101              }
5102              for (; wC < uniforms.effective_filter_dims.y; wC = wC + 1) {
5103                if (wC % uniforms.dilations.y != 0) {
5104                  continue;
5105                }
5106                let dyC = (${H}(dyCCorner) + ${H}(wC)) / ${H}(uniforms.strides.y);
5107                let wCPerm = uniforms.filter_dims.y - 1 - wC / uniforms.dilations.y;
5108                if (dyC < 0.0 || dyC >= ${H}(uniforms.Dy_shape[${F}]) ||
5109                    fract(dyC) > 0.0 || wCPerm < 0) {
5110                  continue;
5111                }
5112                let idyC: u32 = u32(dyC);
5113                var inputChannel = groupId * uniforms.input_channels_per_group;
5114                ${p?`
5115                var x_offset = ${xe.indicesToOffset(`${xe.type.indices}(batch, idyR, idyC, inputChannel)`)} / ${h};
5116                var w_offset = ${me.indicesToOffset(`${me.type.indices}(wRPerm, wCPerm, inputChannel, wOutChannel)`)} / ${b};
5117                  `:""}
5118                for (var d2: u32 = 0; d2 < uniforms.input_channels_per_group_int; d2 = d2 + ${p?4:h}) {
5119                  ${ce()}
5120                  inputChannel = inputChannel + ${p?4:h};
5121                }
5122                ${ie()}
5123                wC = wC + uniforms.strides.y - 1;
5124              }
5125              wR = wR + uniforms.strides[0] - 1;
5126            }
5127            let value = dotProd${s?` + bias[d1 / ${v}]`:""};
5128            ${ve.setByOffset("global_idx","value")};
5129          `;return`
5130    ${G.registerUniforms(X).declareVariables(...Le,ve)}
5131      ${G.mainStart()}
5132      ${G.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")};
5133    ${de}}`};return{name:"ConvTranspose2D",shaderCache:{hint:`${e.cacheKey};${h}${b}${v}${p}${y}`,inputDependencies:I},getRunData:()=>({dispatchGroup:{x:E[0],y:E[1],z:E[2]},outputs:[{dims:n?n(r):r,dataType:t[0].dataType}],programUniforms:R}),getShaderSource:B}}}),Q8,Z8,eG,A$,yte,tG,C$,nG,xte,jAe=qt(()=>{LAe(),Hv(),ty(),Q8=(t,e,n,s,r,i)=>(t-1)*e+n+(s-1)*r+1-i,Z8=(t,e,n,s,r)=>{let i=Math.floor(t/2);e==="SAME_UPPER"?(n[s]=i,n[r]=t-i):e==="SAME_LOWER"&&(n[s]=t-i,n[r]=i)},eG=(t,e,n,s,r,i,a,o,l,c)=>{let h=t.length-2,p=c.length===0;l.length<h&&l.push(...Array(h-l.length).fill(0));let m=t[0],y=e[o?3:1]*r;for(let v=0,b=t.length-h-(o?1:0);v<h;++v,++b){let S=t[b],E=p?S*a[v]:c[v],I=Q8(S,a[v],i[v],e[b],n[v],E);Z8(I,s,i,v,v+h),p&&c.push(a[v]*(S-1)+l[v]+(e[b]-1)*n[v]+1-i[v]-i[v+h])}c.splice(0,0,m),c.splice(o?3:1,0,y)},A$=(t,e)=>{let n=t.kernelShape.slice();if(t.kernelShape.length===0||t.kernelShape.reduce((p,m)=>p*m,1)===0){n.length=0;for(let p=2;p<e[1].dims.length;++p)n.push(e[1].dims[p])}let s=t.format==="NHWC";n.splice(0,0,e[1].dims[0]),n.splice(s?3:1,0,e[1].dims[1]);let r=t.pads.slice(),i=t.outputShape.slice(),a=t.outputPadding.slice(),o=e[0].dims,l=t.dilations.slice();if(l.reduce((p,m)=>p+m,0)===0){let p=e[0].dims.length-2;l=new Array(p).fill(1)}let c=t.strides.slice();if(c.reduce((p,m)=>p+m,0)===0){let p=e[0].dims.length-2;c=new Array(p).fill(1)}eG(o,n,l,t.autoPad,t.group,r,c,s,a,i);let h=Object.assign({},t);return Object.assign(h,{kernelShape:n,pads:r,outputPadding:a,outputShape:i,dilations:l,strides:c}),h},yte=t=>{let e=Q7(t),n=t.format,s=["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][typeof t.autoPad>"u"?0:t.autoPad],r=t.dilations,i=t.group??1,a=t.kernelShape,o=t.pads,l=t.strides,c=t.wIsConst(),h=t.outputPadding,p=t.outputShape;return{autoPad:s,format:n,dilations:r,group:i,kernelShape:a,outputPadding:h,outputShape:p,pads:o,strides:l,wIsConst:c,...e,cacheKey:`${t.format};${e.activation};`}},tG=(t,e)=>{if(!t||t.length!==2&&t.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(t[0].dims.length!==4&&t[0].dims.length!==3)throw new Error("currently only support 2-dimensional conv");if(t[0].dims.length!==t[1].dims.length)throw new Error("filter does not have same dimension as input");let n=t[0].dims[e.format==="NHWC"?t[0].dims.length-1:1],s=t[1].dims[0];if(n!==s)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let r=t[1].dims[1]*e.group;if(t.length===3&&(t[2].dims.length!==1||t[2].dims[0]!==r))throw new Error("invalid bias");let i=t[0].dims.length-2;if(e.dilations.reduce((a,o)=>a+o,0)>0&&e.dilations.length!==i)throw new Error(`dilations should be ${i}D`);if(e.strides.reduce((a,o)=>a+o,0)>0&&e.strides.length!==i)throw new Error(`strides should be ${i}D`);if(e.pads.reduce((a,o)=>a+o,0)>0&&e.pads.length!==i*2)throw new Error(`pads should be ${i*2}D`);if(e.outputPadding.length!==i&&e.outputPadding.length!==0)throw new Error(`output_padding should be ${i}D`);if(e.kernelShape.reduce((a,o)=>a+o,0)>0&&e.kernelShape.length!==0&&e.kernelShape.length!==t[1].dims.length-2)throw new Error("invalid kernel shape");if(e.outputShape.length!==0&&e.outputShape.length!==t[0].dims.length-2)throw new Error("invalid output shape")},C$=(t,e,n,s)=>{let r=t.kernelCustomData.wT??t.compute(Ru(e[1],[2,3,0,1]),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=r);let i=[e[0],r];e.length===3&&i.push(e[2]),t.compute(gte(i,n,s),{inputs:i})},nG=(t,e)=>{let n=e.format==="NHWC",s=[t.inputs[0].reshape(n?[t.inputs[0].dims[0],1,t.inputs[0].dims[1],t.inputs[0].dims[2]]:[t.inputs[0].dims[0],t.inputs[0].dims[1],1,t.inputs[0].dims[2]]),t.inputs[1].reshape([t.inputs[1].dims[0],t.inputs[1].dims[1],1,t.inputs[1].dims[2]])];t.inputs.length===3&&s.push(t.inputs[2]);let r=e.kernelShape;(r.length===0||r[0]===0)&&(r=[t.inputs[1].dims[2]]);let i=e.dilations;(i.length===0||i[0]===0)&&(i=[1]);let a=e.strides;(a.length===0||a[0]===0)&&(a=[1]);let o=e.pads;o.length===0&&(o=[0,0]),o=[0,o[0],0,o[1]],a=[1].concat(a),i=[1].concat(i),r=[1].concat(r);let l=e.outputPadding;l=[0].concat(l);let c=A$({...e,pads:o,strides:a,dilations:i,kernelShape:r,outputPadding:l},s);C$(t,s,c,h=>n?[h[0],h[2],h[3]]:[h[0],h[1],h[3]])},xte=(t,e)=>{if(tG(t.inputs,e),t.inputs[0].dims.length===3)nG(t,e);else{let n=A$(e,t.inputs);C$(t,t.inputs,n)}}}),sG,vte,bte,BAe=qt(()=>{ts(),Ts(),na(),Rs(),sG=(t,e,n,s)=>{let r=dt.size(e),i=e.length,a=St("input",t,i),o=wn("output",t,i),l=n.dataType===6?n.getInt32Array()[0]:Number(n.getBigInt64Array()[0]),c=dt.normalizeAxis(l,i),h=p=>{let m=` i32(${a.indicesGet("inputIndices","uniforms.axis")}) `,y=An("uniforms.input_shape","uniforms.axis",i),v=s.reverse?m+(s.exclusive?" + 1":""):"0",b=s.reverse?y:m+(s.exclusive?"":" + 1");return`
5134                ${p.registerUniform("outputSize","u32").registerUniform("axis","u32").declareVariables(a,o)}
5135                ${p.mainStart()}
5136                  ${p.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
5137                  var inputIndices = ${o.offsetToIndices("global_idx")};
5138                  var sum = ${o.type.value}(0);
5139                  let first : i32 = ${v};
5140                  let last : i32 = ${b};
5141                  for (var i : i32 = first; i < last; i++) {
5142                    ${a.indicesSet("inputIndices","uniforms.axis","u32(i)")};
5143                    sum = sum + ${a.getByIndices("inputIndices")};
5144                  }
5145                  ${o.setByOffset("global_idx","sum")};
5146                }`};return{name:"CumSum",shaderCache:{hint:s.cacheKey,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:e,dataType:t}],dispatchGroup:{x:Math.ceil(r/64)},programUniforms:[{type:12,data:r},{type:12,data:c},...Mn(e,e)]}),getShaderSource:h}},vte=(t,e)=>{let n=t.inputs[0].dims,s=t.inputs[0].dataType,r=t.inputs[1];t.compute(sG(s,n,r,e),{inputs:[0]})},bte=t=>{let e=t.exclusive===1,n=t.reverse===1;return Rr({exclusive:e,reverse:n})}}),rG,iG,aG,wte,_te,UAe=qt(()=>{ts(),Ts(),na(),Rs(),rG=t=>{if(!t||t.length!==1)throw new Error("DepthToSpace requires 1 input.");if(t[0].dims.length!==4)throw new Error("DepthToSpace requires 4D input.")},iG=(t,e,n,s)=>{let r=[];r.push(`fn perm(i: ${s.type.indices}) -> ${n.type.indices} {
5147    var a: ${n.type.indices};`);for(let i=0;i<e;++i)r.push(n.indicesSet("a",t[i],`i[${i}]`));return r.push("return a;}"),r.join(`
5148`)},aG=(t,e)=>{let n,s,r,i,a,o,l=e.format==="NHWC",c=e.blocksize,h=e.mode==="DCR";l?([n,s,r,i]=t.dims,a=h?[n,s,r,c,c,i/c**2]:[n,s,r,i/c**2,c,c],o=h?[0,1,3,2,4,5]:[0,1,4,2,5,3]):([n,s,r,i]=[t.dims[0],t.dims[2],t.dims[3],t.dims[1]],a=h?[n,c,c,i/c**2,s,r]:[n,i/c**2,c,c,s,r],o=h?[0,3,4,1,5,2]:[0,1,4,2,5,3]);let p=t.reshape(a),m=p.dims.length,y=t.dataType,v=St("a",y,m),b=wn("output",y,m),S=E=>`
5149  ${E.registerUniform("output_size","u32").declareVariables(v,b)}
5150
5151  ${iG(o,m,v,b)}
5152
5153  ${E.mainStart()}
5154    ${E.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5155
5156    let indices = ${b.offsetToIndices("global_idx")};
5157    let aIndices = perm(indices);
5158
5159    ${b.setByOffset("global_idx",v.getByIndices("aIndices"))}
5160  }`;return{name:"DepthToSpace",shaderCache:{hint:`${t.dims};${e.blocksize};${e.mode}`,inputDependencies:["rank"]},getRunData:E=>{let I=l?[n,s*c,r*c,i/c**2]:[n,i/c**2,s*c,r*c],M=dt.size(I),j=p.dims,L=dt.sortBasedOnPerm(j,o);return{outputs:[{dims:I,dataType:E[0].dataType}],dispatchGroup:{x:Math.ceil(M/64)},programUniforms:[{type:12,data:M},...Mn(j,L)]}},getShaderSource:S}},wte=(t,e)=>{rG(t.inputs),t.compute(aG(t.inputs[0],e))},_te=t=>Rr({blocksize:t.blocksize,mode:t.mode,format:t.format})}),Xk,G2,k$,oG,lG,cG,uG,I$,dG,Ste,Ete,FAe=qt(()=>{ts(),Ts(),na(),Rs(),Xk="[a-zA-Z]|\\.\\.\\.",G2="("+Xk+")+",k$="^"+G2+"$",oG="("+G2+",)*"+G2,lG="^"+oG+"$",cG=class{constructor(t=-1){this.symbolToIndices=new Map,this.inputIndex=t}addSymbol(t,e){let n=this.symbolToIndices.get(t);n===void 0?n=[e]:n.push(e),this.symbolToIndices.set(t,n)}},uG=class{constructor(t,e){var r;this.equation=e,this.hasEllipsis=!1,this.symbolToInfo=new Map,this.lhs=new Array,this.outputDims=[];let[n,s]=e.includes("->")?e.split("->",2):[e,""];if(!n.match(RegExp(lG)))throw new Error("Invalid LHS term");if(n.split(",").forEach((i,a)=>{let o=t[a].dims.slice();if(!i.match(RegExp(k$)))throw new Error("Invalid LHS term");let l=this.processTerm(i,!0,o,a);this.lhs.push(l)}),s==="")s+=[...this.symbolToInfo.entries()].filter(([i,a])=>a.count===1||i==="...").map(([i])=>i).join("");else if(!s.match(RegExp(G2)))throw new Error("Invalid RHS");(r=s.match(RegExp(Xk,"g")))==null||r.forEach(i=>{if(i==="...")this.outputDims=this.outputDims.concat(this.ellipsisDims);else{let a=this.symbolToInfo.get(i);if(a===void 0)throw new Error("Invalid RHS symbol");this.outputDims.push(a.dimValue)}}),this.rhs=this.processTerm(s,!1,this.outputDims)}addSymbol(t,e,n){let s=this.symbolToInfo.get(t);if(s!==void 0){if(s.dimValue!==e&&s.count!==1)throw new Error("Dimension mismatch");s.count++,s.inputIndices.push(n)}else s={count:1,dimValue:e,inputIndices:[n]};this.symbolToInfo.set(t,s)}processTerm(t,e,n,s=-1){let r=n.length,i=!1,a=[],o=0;if(!t.match(RegExp(k$))&&!e&&t!=="")throw new Error("Invalid LHS term");let l=t.match(RegExp(Xk,"g")),c=new cG(s);return l==null||l.forEach((h,p)=>{if(h==="..."){if(i)throw new Error("Only one ellipsis is allowed per input term");i=!0;let m=r-l.length+1;if(m<0)throw new Error("Ellipsis out of bounds");if(a=n.slice(o,o+m),this.hasEllipsis){if(this.ellipsisDims.length!==a.length||this.ellipsisDims.toString()!==a.toString())throw new Error("Ellipsis dimensions mismatch")}else if(e)this.hasEllipsis=!0,this.ellipsisDims=a;else throw new Error("Ellipsis must be specified in the LHS");for(let y=0;y<a.length;y++){let v=String.fromCharCode(48+y);c.addSymbol(v,p+y),this.addSymbol(v,n[o++],s)}}else c.addSymbol(h,p+(this.hasEllipsis?this.ellipsisDims.length-1:0)),this.addSymbol(h,n[o++],s)}),c}},I$=t=>t+"_max",dG=(t,e,n,s)=>{let r=t.map(c=>c.length).map((c,h)=>St(`input${h}`,e,c)),i=dt.size(s),a=wn("output",e,s.length),o=[...n.symbolToInfo.keys()].filter(c=>!n.rhs.symbolToIndices.has(c)),l=c=>{let h=[],p="var prod = 1.0;",m="var sum = 0.0;",y="sum += prod;",v=[],b=[],S=[],E=[],I=n.symbolToInfo.size===n.rhs.symbolToIndices.size;n.symbolToInfo.forEach((j,L)=>{var K;if(n.rhs.symbolToIndices.has(L)){let D=(K=n.rhs.symbolToIndices.get(L))==null?void 0:K[0];D!==void 0&&n.lhs.forEach((R,B)=>{if(j.inputIndices.includes(B)){let G=R.symbolToIndices.get(L);if(G===void 0)throw new Error("Invalid symbol error");G.forEach(X=>{h.push(`${r[B].indicesSet(`input${B}Indices`,X,a.indicesGet("outputIndices",D))}`)})}})}else n.lhs.forEach((D,R)=>{if(j.inputIndices.includes(R)){let B=D.symbolToIndices.get(L);if(B===void 0)throw new Error("Invalid symbol error");B.forEach(G=>{v.push(`${r[R].indicesSet(`input${R}Indices`,G,`${L}`)}`)}),E.push(`prod *= ${r[R].getByIndices(`input${R}Indices`)};`)}}),b.push(`for(var ${L}: u32 = 0; ${L} < uniforms.${I$(L)}; ${L}++) {`),S.push("}")});let M=I?[...h,`let sum = ${r.map((j,L)=>j.getByIndices(`input${L}Indices`)).join(" * ")};`]:[...h,m,...b,...v,p,...E,y,...S];return`
5161            ${c.registerUniforms(o.map(j=>({name:`${I$(j)}`,type:"u32"}))).registerUniform("outputSize","u32").declareVariables(...r,a)}
5162
5163            ${c.mainStart()}
5164            ${c.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
5165            var outputIndices = ${a.offsetToIndices("global_idx")};
5166            ${r.map((j,L)=>`var input${L}Indices: ${r[L].type.indices};`).join(`
5167`)}
5168            ${M.join(`
5169`)};
5170            ${a.setByOffset("global_idx","sum")};
5171          }`};return{name:"Einsum",shaderCache:{hint:n.equation,inputDependencies:t.map(()=>"rank")},getRunData:()=>{let c=o.filter(p=>n.symbolToInfo.has(p)).map(p=>{var m;return{type:12,data:((m=n.symbolToInfo.get(p))==null?void 0:m.dimValue)||0}});c.push({type:12,data:i});let h=t.map((p,m)=>[...Mn(p)]).reduce((p,m)=>p.concat(m),c);return h.push(...Mn(s)),{outputs:[{dims:s,dataType:e}],dispatchGroup:{x:Math.ceil(i/64)},programUniforms:h}},getShaderSource:l}},Ste=(t,e)=>{let n=new uG(t.inputs,e.equation),s=n.outputDims,r=t.inputs.map((i,a)=>i.dims);t.compute(dG(r,t.inputs[0].dataType,n,s))},Ete=t=>{let e=t.equation.replace(/\s+/g,"");return Rr({equation:e})}}),hG,N$,fG,pG,Tte,VAe=qt(()=>{ts(),Ts(),Rs(),hG=t=>{if(!t||t.length!==2)throw new Error("Expand requires 2 input.");let e=t[0].dims,n=Array.from(t[1].getBigInt64Array(),Number),s=n.length<e.length?0:n.length-e.length,r=e.length<n.length?0:e.length-n.length;for(;s<n.length&&r<e.length;++s,++r)if(n[s]!==e[r]&&n[s]!==1&&e[r]!==1)throw new Error("Expand requires shape to be broadcastable to input")},N$=(t,e)=>{let n=t.length-e.length,s=[];for(let r=0;r<n;++r)s.push(t[r]);for(let r=0;r<e.length;++r)s.push(e[r]===1?t[r+n]:e[r]);return s},fG=(t,e)=>t.length>e.length?N$(t,e):N$(e,t),pG=t=>{let e=t[0].dims,n=Array.from(t[1].getBigInt64Array(),Number),s=fG(e,n),r=t[0].dataType,i=r===9||dt.size(e)===1,a=r===9||e.length>0&&e[e.length-1]%4===0?4:1,o=i||s.length>0&&s[s.length-1]%4===0?4:1,l=Math.ceil(dt.size(s)/o),c=p=>{let m=St("input",r,e.length,a),y=wn("output",r,s.length,o),v;if(r===9){let b=(S,E,I="")=>`
5172          let outputIndices${E} = ${y.offsetToIndices(`outputOffset + ${E}u`)};
5173          let offset${E} = ${m.broadcastedIndicesToOffset(`outputIndices${E}`,y)};
5174          let index${E} = offset${E} / 4u;
5175          let component${E} = offset${E} % 4u;
5176          ${S}[${E}] = ${I}(${m.getByOffset(`index${E}`)}[component${E}]);
5177        `;v=`
5178        let outputOffset = global_idx * ${o};
5179        var data = vec4<u32>(0);
5180        ${b("data",0,"u32")}
5181        ${b("data",1,"u32")}
5182        ${b("data",2,"u32")}
5183        ${b("data",3,"u32")}
5184        ${y.setByOffset("global_idx","data")}
5185      }`}else v=`
5186        let outputIndices = ${y.offsetToIndices(`global_idx * ${o}`)};
5187        let inputOffset = ${m.broadcastedIndicesToOffset("outputIndices",y)};
5188        let data = ${y.type.value}(${m.getByOffset(`inputOffset / ${a}`)});
5189        ${y.setByOffset("global_idx","data")}
5190      }`;return`
5191    ${p.registerUniform("vec_size","u32").declareVariables(m,y)}
5192    ${p.mainStart()}
5193    ${p.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}
5194    ${v}`},h=[{type:12,data:l},...Mn(e,s)];return{name:"Expand",shaderCache:{hint:`${s.length};${a}${o}`,inputDependencies:["rank"]},getShaderSource:c,getRunData:()=>({outputs:[{dims:s,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:h})}},Tte=t=>{hG(t.inputs),t.compute(pG(t.inputs),{inputs:[0]})}}),mG,Ate,zAe=qt(()=>{ts(),Ts(),Rs(),J7(),mG=t=>{let e=t[0].dataType,n=dt.size(t[0].dims),s=dt.size(t[1].dims),r=s%4===0,i=a=>{let o=St("x",e,[1],4),l=St("bias",e,[1],4),c=wn("y",e,[1],4),h=[{name:"output_vec_size",type:"u32"},{name:"bias_size",type:"u32"}],p=y=>`
5195      let bias${y}_offset: u32 = (global_idx * 4 + ${y}
5195) % uniforms.bias_size;
5196      let bias${y} = ${l.getByOffset(`bias${y}_offset / 4`)}[bias${y}_offset % 4];`,m=r?`
5197      let bias = ${l.getByOffset("global_idx % (uniforms.bias_size / 4)")};`:`${p(0)}${p(1)}${p(2)}${p(3)}
5198      let bias = ${o.type.value}(bias0, bias1, bias2, bias3);`;return`${a.registerUniforms(h).declareVariables(o,l,c)}
5199
5200    ${JD(ml(e))}
5201
5202    ${a.mainStart(W1)}
5203      ${a.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_vec_size")}
5204
5205      let x = ${o.getByOffset("global_idx")};
5206      ${m}
5207      let x_in = x + bias;
5208      ${c.setByOffset("global_idx",QD("x_in"))}
5209    }`};return{name:"FastGeluWithBias",shaderCache:{hint:`${r}`,inputDependencies:["type","type"]},getShaderSource:i,getRunData:a=>({outputs:[{dims:a[0].dims,dataType:a[0].dataType}],programUniforms:[{type:12,data:Math.ceil(n/4)},{type:12,data:s}],dispatchGroup:{x:Math.ceil(n/W1/4)}})}},Ate=t=>{t.inputs.length<2||dt.size(t.inputs[1].dims)===0?qee(t):t.compute(mG(t.inputs))}}),gG,yG,Cte,kte,GAe=qt(()=>{ts(),Ts(),na(),Rs(),gG=t=>{if(!t||t.length!==2)throw new Error("Gather requires 2 inputs.")},yG=(t,e)=>{let n=t[0].dims,s=t[1].dims,r=n.length,i=dt.normalizeAxis(e.axis,r),a=n.slice(0);a.splice(i,1,...s);let o=n[i],l=t[0].dataType===9?4:1,c=Math.ceil(dt.size(a)/l),h=[{type:12,data:c},{type:6,data:o},{type:12,data:i},...Mn(t[0].dims,t[1].dims,a)],p=m=>{let y=St("data",t[0].dataType,t[0].dims.length,l),v=St("inputIndices",t[1].dataType,t[1].dims.length),b=wn("output",t[0].dataType,a.length,l),S=I=>{let M=s.length,j=`var indicesIndices${I}  = ${v.type.indices}(0);`;for(let L=0;L<M;L++)j+=`${M>1?`indicesIndices${I}[${L}]`:`indicesIndices${I}`} = ${a.length>1?`outputIndices${I}[uniforms.axis + ${L}]`:`outputIndices${I}`};`;j+=`
5210          var idx${I} = ${v.getByIndices(`indicesIndices${I}`)};
5211          if (idx${I} < 0) {
5212            idx${I} = idx${I} + uniforms.axisDimLimit;
5213          }
5214          var dataIndices${I} : ${y.type.indices};
5215        `;for(let L=0,K=0;L<r;L++)L===i?(j+=`${r>1?`dataIndices${I}[${L}]`:`dataIndices${I}`} = u32(idx${I});`,K+=M):(j+=`${r>1?`dataIndices${I}[${L}]`:`dataIndices${I}`} = ${a.length>1?`outputIndices${I}[${K}]`:`outputIndices${I}`};`,K++);return j},E;if(t[0].dataType===9){let I=(M,j,L="")=>`
5216          let outputIndices${j} = ${b.offsetToIndices(`outputOffset + ${j}u`)};
5217          ${S(j)};
5218          let offset${j} = ${y.indicesToOffset(`dataIndices${j}`)};
5219          let index${j} = offset${j} / 4u;
5220          let component${j} = offset${j} % 4u;
5221          ${M}[${j}] = ${L}(${y.getByOffset(`index${j}`)}[component${j}]);
5222        `;E=`
5223        let outputOffset = global_idx * ${l};
5224        var value = vec4<u32>(0);
5225        ${I("value",0,"u32")}
5226        ${I("value",1,"u32")}
5227        ${I("value",2,"u32")}
5228        ${I("value",3,"u32")}
5229        ${b.setByOffset("global_idx","value")}
5230      `}else E=`
5231      let outputIndices = ${b.offsetToIndices("global_idx")};
5232      ${S("")};
5233      let value = ${y.getByIndices("dataIndices")};
5234      ${b.setByOffset("global_idx","value")};
5235      `;return`
5236      ${m.registerUniform("outputSize","u32").registerUniform("axisDimLimit","i32").registerUniform("axis","u32").declareVariables(y,v,b)}
5237      ${m.mainStart()}
5238        ${m.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
5239        ${E}
5240      }`};return{name:"Gather",shaderCache:{hint:e.cacheKey,inputDependencies:["rank","rank"]},getRunData:()=>({outputs:[{dims:a,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(c/64)},programUniforms:h}),getShaderSource:p}},Cte=t=>Rr({axis:t.axis}),kte=(t,e)=>{let n=t.inputs;gG(n),t.compute(yG(t.inputs,e))}}),xG,Ite,Nte,HAe=qt(()=>{ts(),Ts(),Rs(),xG=(t,e,n,s,r,i,a,o,l)=>{let c=[{type:12,data:i},{type:12,data:s},{type:12,data:r},{type:12,data:n},{type:12,data:a},{type:12,data:o},{type:12,data:l}],h=[i];c.push(...Mn(e.dims,h));let p=m=>{let y=St("indices_data",e.dataType,e.dims.length),v=wn("input_slice_offsets_data",12,1,1),b=[y,v],S=[{name:"output_size",type:"u32"},{name:"batch_dims",type:"u32"},{name:"input_dims",type:"u32",length:r.length},{name:"sizes_from_slice_dims_data",type:"u32",length:n.length},{name:"num_slices_per_batch",type:"u32"},{name:"input_batch_stride",type:"u32"},{name:"num_slice_dims",type:"u32"}];return`
5241  ${m.registerUniforms(S).declareVariables(...b)}
5242  ${m.mainStart()}
5243    ${m.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5244    let batch_idx = global_idx / uniforms.num_slices_per_batch;
5245    let base_offset = batch_idx * uniforms.input_batch_stride;
5246
5247    let slice_indices_base_offset = global_idx * uniforms.num_slice_dims;
5248    var relative_slice_offset = 0;
5249    for (var dim_idx = 0u; dim_idx < uniforms.num_slice_dims; dim_idx ++) {
5250      var index = i32(indices_data[dim_idx + slice_indices_base_offset].x);
5251      let input_dim_idx = uniforms.batch_dims + dim_idx;
5252      if (index < 0) {
5253        ${r.length===1?"index += i32(uniforms.input_dims);":"index += i32(uniforms.input_dims[input_dim_idx]);"}
5254      }
5255      ${n.length===1?"relative_slice_offset += index * i32(uniforms.sizes_from_slice_dims_data);":"relative_slice_offset += index * i32(uniforms.sizes_from_slice_dims_data[dim_idx]);"}
5256    }
5257
5258    input_slice_offsets_data[global_idx] =  base_offset + u32(relative_slice_offset);
5259  }`};return t.compute({name:"computeSliceOffsets",shaderCache:{hint:`${r.length}_${n.length}`,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:h,dataType:t.inputs[1].dataType}],dispatchGroup:{x:Math.ceil(i/64)}
vendor: 7,611 bytes, lines 5259-5321
5259,programUniforms:c}),getShaderSource:p},{inputs:[e],outputs:[-1]})[0]},Ite=(t,e)=>{let n=t.inputs,s=n[0].dims,r=n[0].dataType,i=n[1].dims,a=i[i.length-1],o=dt.sizeToDimension(i,i.length-1),l=dt.sizeFromDimension(s,e.batchDims+a),c=dt.sizeToDimension(s,e.batchDims),h=dt.sizeFromDimension(s,e.batchDims),p=o/c,m=new Array(a),y=l;for(let j=0;j<a;++j)m[a-1-j]=y,y*=s[e.batchDims+a-1-j];let v=xG(t,n[1],m,e.batchDims,s,o,p,h,a),b=e.batchDims+a;if(b>s.length)throw new Error("last dimension of indices must not be larger than rank of input tensor");let S=i.slice(0,-1).concat(s.slice(b)),E=dt.size(S),I=[{type:12,data:E},{type:12,data:l},...Mn(n[0].dims,v.dims,S)],M=j=>{let L=St("data",n[0].dataType,n[0].dims.length),K=St("slice_offsets",12,v.dims.length),D=wn("output",n[0].dataType,S.length);return`
5260          ${j.registerUniform("output_size","u32").registerUniform("slice_size","u32").declareVariables(L,K,D)}
5261            ${j.mainStart()}
5262            ${j.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5263          let slice_offset = slice_offsets[global_idx / uniforms.slice_size];
5264          output[global_idx] = data[u32(slice_offset) + global_idx % uniforms.slice_size];
5265        }`};t.compute({name:"GatherND",shaderCache:{hint:e.cacheKey,inputDependencies:["rank","rank"]},getRunData:()=>({outputs:[{dims:S,dataType:r}],dispatchGroup:{x:Math.ceil(E/64)},programUniforms:I}),getShaderSource:M},{inputs:[n[0],v]})},Nte=t=>({batchDims:t.batch_dims,cacheKey:""})}),vG,bG,Rte,Mte,qAe=qt(()=>{ts(),Ts(),na(),Rs(),vG=(t,e)=>{if(t.length<3||t.length>4)throw new Error("GatherBlockQuantized requires 3 or 4 inputs.");let n=dt.normalizeAxis(e.quantizeAxis,t[0].dims.length),s=e.blockSize,r=t[0],i=t[2],a=t.length===4?t[3]:void 0;if(i.dims.length!==r.dims.length||!r.dims.map((o,l)=>l===n?Math.ceil(o/s)===i.dims[l]:o===i.dims[l]).reduce((o,l)=>o&&l,!0))throw new Error("Scales must have the same rank as the input tensor and the dims should match except on gatherAxis.");if(a){if(a.dataType!==r.dataType)throw new Error("Zero point must have the same data type as the input tensor.");if(a.dims.length!==i.dims.length||!a.dims.map((o,l)=>o===i.dims[l]).reduce((o,l)=>o&&l,!0))throw new Error("Zero point must have the same rank as the input tensor and the dims should match except on quantizeAxis.")}},bG=(t,e)=>{let n=t[0].dims,s=t[1].dims,r=n.length,i=dt.normalizeAxis(e.gatherAxis,r),a=dt.normalizeAxis(e.quantizeAxis,r),o=n.slice(0);o.splice(i,1,...s);let l=dt.size(o),c=t[2].dataType,h=t[0].dataType===22,p=[{type:12,data:l},{type:12,data:a},{type:12,data:i},{type:12,data:e.blockSize},...Mn(...t.map((y,v)=>y.dims),o)],m=y=>{let v=St("data",t[0].dataType,t[0].dims.length),b=St("inputIndices",t[1].dataType,t[1].dims.length),S=St("scales",t[2].dataType,t[2].dims.length),E=t.length>3?St("zeroPoint",t[3].dataType,t[3].dims.length):void 0,I=wn("output",c,o.length),M=[v,b,S];E&&M.push(E);let j=[{name:"output_size",type:"u32"},{name:"quantize_axis",type:"u32"},{name:"gather_axis",type:"u32"},{name:"block_size",type:"u32"}];return`
5266        ${y.registerUniforms(j).declareVariables(...M,I)}
5267        ${y.mainStart()}
5268        let output_indices = ${I.offsetToIndices("global_idx")};
5269        var indices_indices = ${b.type.indices}(0);
5270        ${s.length>1?`
5271          for (var i: u32 = 0; i < ${s.length}; i++) {
5272            let index = ${I.indicesGet("output_indices","uniforms.gather_axis + i")};
5273            ${b.indicesSet("indices_indices","i","index")};
5274          }`:`indices_indices = ${I.indicesGet("output_indices","uniforms.gather_axis")};`};
5275        var data_indices = ${v.type.indices}(0);
5276        for (var i: u32 = 0; i < uniforms.gather_axis; i++) {
5277          let index = ${I.indicesGet("output_indices","i")};
5278          ${v.indicesSet("data_indices","i","index")};
5279        }
5280        var index_from_indices = ${b.getByIndices("indices_indices")};
5281        if (index_from_indices < 0) {
5282          index_from_indices += ${n[i]};
5283        }
5284        ${v.indicesSet("data_indices","uniforms.gather_axis","u32(index_from_indices)")};
5285        for (var i = uniforms.gather_axis + 1; i < ${o.length}; i++) {
5286          let index = ${I.indicesGet("output_indices",`i + ${s.length} - 1`)};
5287          ${v.indicesSet("data_indices","i","index")};
5288        }
5289        let data_offset = ${v.indicesToOffset("data_indices")};
5290        let data_index = data_offset % 8;
5291        // Convert 4-bit packed data to 8-bit packed data.
5292        let packed_4bit_quantized_data = ${v.getByOffset("data_offset / 8")};
5293        let packed_8bit_quantized_data = (packed_4bit_quantized_data >> (4 * (data_index % 2))) & 0x0f0f0f0f;
5294        let quantized_data_vec = ${h?"unpack4xI8":"unpack4xU8"}(u32(packed_8bit_quantized_data));
5295        let quantized_data = quantized_data_vec[data_index / 2];
5296        var scale_indices = data_indices;
5297        let quantize_axis_index = ${S.indicesGet("data_indices","uniforms.quantize_axis")} / uniforms.block_size;
5298        ${S.indicesSet("scale_indices","uniforms.quantize_axis","quantize_axis_index")};
5299        var scale = ${S.getByIndices("scale_indices")};
5300        ${E?`
5301              let zero_point_indices = scale_indices;
5302              let zero_point_offset = ${E.indicesToOffset("zero_point_indices")};
5303              let zero_point_index = zero_point_offset % 8;
5304              let packed_4bit_zero_points = ${E.getByOffset("zero_point_offset / 8")};
5305              let packed_8bit_zero_points = (packed_4bit_zero_points >> (4 * (zero_point_index % 2))) & 0x0f0f0f0f;
5306              let zero_point_vec = ${h?"unpack4xI8":"unpack4xU8"}(u32(packed_8bit_zero_points));
5307              let zero_point = zero_point_vec[zero_point_index / 2];`:"var zero_point = 0"};
5308        let dequantized_data = ${ml(c)}(quantized_data - zero_point) * scale;
5309        ${I.setByOffset("global_idx","dequantized_data")};
5310    }`};return{name:"GatherBlockQuantized",shaderCache:{hint:`${e.cacheKey};${t.filter((y,v)=>v!==1).map(y=>y.dims.join("_")).join(";")}`,inputDependencies:Array.from({length:t.length},(y,v)=>"rank")},getRunData:()=>({outputs:[{dims:o,dataType:c}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:p}),getShaderSource:m}},Rte=(t,e)=>{let n=t.inputs;vG(n,e),t.compute(bG(t.inputs,e))},Mte=t=>Rr({blockSize:t.blockSize,gatherAxis:t.gatherAxis,quantizeAxis:t.quantizeAxis})}),wG,_G,Pte,$te,WAe=qt(()=>{ts(),Ts(),na(),Rs(),wG=t=>{if(!t||t.length!==2)throw new Error("GatherElements requires 2 inputs.");if(t[0].dims.length<1)throw new Error("GatherElements requires that the data input be rank >= 1.");if(t[0].dims.length!==t[1].dims.length)throw new Error(`GatherElements requires that the data input and
5311                     indices input tensors be of same rank.`)},_G=(t,e)=>{let n=t[0].dims,s=t[0].dataType,r=n.length,i=t[1].dims,a=t[1].dataType,o=dt.normalizeAxis(e.axis,r),l=n[o],c=i.slice(0),h=dt.size(c),p=St("input",s,r),m=St("indicesInput",a,i.length),y=wn("output",s,c.length),v=[{type:12,data:h},{type:6,data:l},{type:12,data:o}];return v.push(...Mn(n,i,c)),{name:"GatherElements",shaderCache:{inputDependencies:["rank","rank"]},getRunData:()=>({outputs:[{dims:c,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(h/64)},programUniforms:v}),getShaderSource:b=>`
5312      ${b.registerUniform("outputSize","u32").registerUniform("axisDimLimit","i32").registerUniform("axis","u32").declareVariables(p,m,y)}
5313      ${b.mainStart()}
5314      ${b.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
5315
5316      let outputIndices = ${y.offsetToIndices("global_idx")};
5317
5318      var idx = ${m.getByOffset("global_idx")};
5319      if (idx < 0) {
5320        idx = idx + uniforms.axisDimLimit;
5321      }
5322      var inputIndices = ${p.type.indices}(outputIndices);
5323      ${p.indicesSet("inputIndices","uniforms.axis","u32(idx)")};
5324      let value = ${p.getByIndices("inputIndices")};
5325
5326      ${y.setByOffset("global_idx","value")};
5327  }`}},Pte=t=>Rr({axis:t.axis}),$te=(t,e)=>{let n=t.inputs;wG(n),t.compute(_G(t.inputs,e))}}),SG,EG,Dte,Ote,KAe=qt(()=>{ts(),Ts(),Rs(),SG=t=>{if(!t)throw new Error("Input is missing");if(t.length<2||t.length>3)throw new Error("Invaid input number.");if(t.length===3&&t[2].dims.length>2)throw new Error("Invalid input shape of C");if(t[0].dataType!==t[1].dataType||t.length===3&&t[0].dataType!==t[2].dataType)throw new Error("Input types are mismatched")},EG=(t,e)=>{let n=t[0].dims.slice(),s=t[1].dims.slice(),[r,i,a]=PZ.getShapeOfGemmResult(n,e.transA,s,e.transB,t.length===3?t[2].dims:void 0),o=[r,i];if(!o)throw new Error("Can't use gemm on the given tensors");let l=16,c=Math.ceil(i/l),h=Math.ceil(r/l),p=!0,m=dt.size(o),y=[{type:12,data:p?c:m},{type:12,data:r},{type:12,data:i},{type:12,data:a},{type:1,data:e.alpha},{type:1,data:e.beta}],v=["type","type"];t.length===3&&(y.push(...Mn(t[2].dims)),v.push("rank")),y.push(...Mn(o));let b=E=>{let I="";e.transA&&e.transB?I="value += a[k * uniforms.M + m] * b[n * uniforms.K + k];":e.transA&&!e.transB?I="value += a[k * uniforms.M + m] * b[k * uniforms.N + n];":!e.transA&&e.transB?I="value += a[m * uniforms.K + k] * b[n * uniforms.K + k];":!e.transA&&!e.transB&&(I="value += a[m * uniforms.K + k] * b[k * uniforms.N + n];");let M=e.alpha===1?"":"value *= uniforms.alpha;",j=St("a",t[0].dataType,t[0].dims),L=St("b",t[1].dataType,t[1].dims),K=j.type.value,D=null,R=[j,L];t.length===3&&(D=St("c",t[2].dataType,t[2].dims.length),R.push(D));let B=wn("output",t[0].dataType,o.length);R.push(B);let G=[{name:"output_size",type:"u32"},{name:"M",type:"u32"},{name:"N",type:"u32"},{name:"K",type:"u32"},{name:"alpha",type:"f32"},{name:"beta",type:"f32"}];return`
5328  ${E.registerUniforms(G).declareVariables(...R)}
5329
5330  ${E.mainStart()}
5331    ${E.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5332
5333    let m = global_idx / uniforms.N;
5334    let n = global_idx % uniforms.N;
5335
5336    var value = ${K}(0);
5337    for (var k: u32 = 0u; k < uniforms.K; k++) {
5338      ${I}
5339    }
5340
5341    ${M}
5342    ${D!=null?`let cOffset = ${D.broadcastedIndicesToOffset("vec2(m, n)",B)}; value += ${K}(uniforms.beta) * ${D.getByOffset("cOffset")};`:""}
5343    output[global_idx] = value;
5344  }`},S=E=>{let I=St("a",t[0].dataType,t[0].dims),M=St("b",t[1].dataType,t[1].dims),j=null,L=[I,M];t.length===3&&(j=St("c",t[2].dataType,t[2].dims.length),L.push(j));let K=wn("output",t[0].dataType,o.length);L.push(K);let D=[{name:"num_tile_n",type:"u32"},{name:"M",type:"u32"},{name:"N",type:"u32"},{name:"K",type:"u32"},{name:"alpha",type:"f32"},{name:"beta",type:"f32"}],R="",B="";e.transA&&e.transB?(B=`
5345      var col = tile_row_start + local_id.x;
5346      var row = k_start + local_id.y;
5347      if (col < uniforms.M && row < uniforms.K) {
5348        tile_a[local_id.y][local_id.x] = a[row * uniforms.M + col];
5349      } else {
5350        tile_a[local_id.y][local_id.x] = ${I.type.value}(0);
5351      }
5352
5353      col = k_start + local_id.x;
5354      row = tile_col_start + local_id.y;
5355      if (col < uniforms.K && row < uniforms.N) {
5356        tile_b[local_id.y][local_id.x] = b[row * uniforms.K + col];
5357      } else {
5358        tile_b[local_id.y][local_id.x] = ${M.type.value}(0);
5359      }
5360      `,R="value += tile_a[k][local_id.y] * tile_b[local_id.x][k];"):e.transA&&!e.transB?(B=`
5361      var col = tile_row_start + local_id.x;
5362      var row = k_start + local_id.y;
5363      if (col < uniforms.M && row < uniforms.K) {
5364        tile_a[local_id.y][local_id.x] = a[row * uniforms.M + col];
5365      } else {
5366        tile_a[local_id.y][local_id.x] = ${I.type.value}(0);
5367      }
5368
5369      col = tile_col_start + local_id.x;
5370      row = k_start + local_id.y;
5371      if (col < uniforms.N && row < uniforms.K) {
5372        tile_b[local_id.y][local_id.x] = b[row * uniforms.N + col];
5373      } else {
5374        tile_b[local_id.y][local_id.x] = ${M.type.value}(0);
5375      }
5376      `,R="value += tile_a[k][local_id.y] * tile_b[k][local_id.x];"):!e.transA&&e.transB?(B=`
5377      var col = k_start + local_id.x;
5378      var row = tile_row_start + local_id.y;
5379      if (col < uniforms.K && row < uniforms.M) {
5380        tile_a[local_id.y][local_id.x] = a[row * uniforms.K + col];
5381      } else {
5382        tile_a[local_id.y][local_id.x] = ${I.type.value}(0);
5383      }
5384
5385      col = k_start + local_id.x;
5386      row = tile_col_start + local_id.y;
5387      if (col < uniforms.K && row < uniforms.N) {
5388        tile_b[local_id.y][local_id.x] = b[row * uniforms.K + col];
5389      } else {
5390        tile_b[local_id.y][local_id.x] = ${M.type.value}(0);
5391      }
5392      `,R="value += tile_a[local_id.y][k] * tile_b[local_id.x][k];"):!e.transA&&!e.transB&&(B=`
5393      var col = k_start + local_id.x;
5394      var row = tile_row_start + local_id.y;
5395      if (col < uniforms.K && row < uniforms.M) {
5396        tile_a[local_id.y][local_id.x] = a[row * uniforms.K + col];
5397      } else {
5398        tile_a[local_id.y][local_id.x] = ${I.type.value}(0);
5399      }
5400
5401      col = tile_col_start + local_id.x;
5402      row = k_start + local_id.y;
5403      if (col < uniforms.N && row < uniforms.K) {
5404        tile_b[local_id.y][local_id.x] = b[row * uniforms.N + col];
5405      } else {
5406        tile_b[local_id.y][local_id.x] = ${M.type.value}(0);
5407      }
5408      `,R="value += tile_a[local_id.y][k] * tile_b[k][local_id.x];");let G=e.alpha===1?"":"value *= uniforms.alpha;";return`
5409  ${E.registerUniforms(D).declareVariables(...L)}
5410  var<workgroup> tile_a: array<array<${I.type.storage}, ${l}>, ${l}>;
5411  var<workgroup> tile_b: array<array<${M.type.storage}, ${l}>, ${l}>;
5412  ${E.mainStart([l,l,1])}
5413    let tile_col_start = (workgroup_index % uniforms.num_tile_n) * ${l};
5414    let tile_row_start = (workgroup_index / uniforms.num_tile_n) * ${l};
5415    let num_tiles = (uniforms.K - 1) / ${l} + 1;
5416    var k_start = 0u;
5417    var value = ${K.type.value}(0);
5418    for (var t: u32 = 0u; t < num_tiles; t++) {
5419      ${B}
5420      k_start = k_start + ${l};
5421      workgroupBarrier();
5422
5423      for (var k: u32 = 0u; k < ${l}; k++) {
5424        ${R}
5425      }
5426      workgroupBarrier();
5427    }
5428
5429    ${G}
5430    let m = tile_row_start + local_id.y;
5431    let n = tile_col_start + local_id.x;
5432    ${j!=null?`let cOffset = ${j.broadcastedIndicesToOffset("vec2(m, n)",K)}; value += ${K.type.value}(uniforms.beta) * ${j.getByOffset("cOffset")};`:""}
5433    if (m < uniforms.M && n < uniforms.N) {
5434      output[m * uniforms.N + n] = value;
5435    }
5436  }`};return p?{name:"GemmShared",shaderCache:{hint:`${e.cacheKey}`,inputDependencies:v},getRunData:()=>({outputs:[{dims:o,dataType:t[0].dataType}],dispatchGroup:{x:c*h},programUniforms:y}),getShaderSource:S}:{name:"Gemm",shaderCache:{hint:`${e.cacheKey}`,inputDependencies:v},getRunData:()=>({outputs:[{dims:o,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(m/64)},programUniforms:y}),getShaderSource:b}},Dte=t=>{let e=t.transA,n=t.transB,s=t.alpha,r=t.beta;return{transA:e,transB:n,alpha:s,beta:r,cacheKey:`${t.transA};${t.transB};${t.alpha===1}`}},Ote=(t,e)=>{SG(t.inputs),t.compute(EG(t.inputs,e))}}),$f,Hp,Dy,Oy,TG,AG,CG,kG,IG,NG,RG,MG,Lte,jte,YAe=qt(()=>{ts(),Ts(),na(),Rs(),[$f,Hp,Dy,Oy]=[0,1,2,3],TG=t=>{if(t[0].dims.length!==4)throw new Error("only 4-D tensor is supported.");if(t[0].dims.length!==t[1].dims.length)throw new Error("input dimensions must be equal to grid dimensions");if(t[0].dims.length-2!==t[1].dims[t[1].dims.length-1])throw new Error(`last dimension of grid must be equal to ${t[0].dims.length-2}`);if(t[0].dims[0]!==t[1].dims[0])throw new Error("grid batch size must match input batch size")},AG=`
5437  fn gs_get_cubic_coeffs(x: f32) -> vec4<f32> {
5438    let cubic_alpha = -0.75f;
5439    let x_abs = abs(x);
5440    var coeffs: vec4<f32>;
5441    coeffs[0] = (((cubic_alpha * (x_abs + 1) - 5 * cubic_alpha) * (x_abs + 1) + 8 * cubic_alpha) * (x_abs + 1) - 4 * cubic_alpha);
5442    coeffs[1] = (((cubic_alpha + 2) * x_abs - (cubic_alpha + 3)) * x_abs * x_abs + 1);
5443    coeffs[2] = (((cubic_alpha + 2) * (1 - x_abs) - (cubic_alpha + 3)) * (1 - x_abs) * (1 - x_abs) + 1);
5444    coeffs[3] = (((cubic_alpha * (2 - x_abs) - 5 * cubic_alpha) * (2 - x_abs) + 8 * cubic_alpha) * (2 - x_abs) - 4 * cubic_alpha);
5445    return coeffs;
5446  }
5447`,CG=t=>`
5448  fn gs_bicubic_interpolate(p: mat4x4<${t}>, x: f32, y: f32) -> ${t} {
5449    var v: vec4<f32>;
5450    var coeffs = gs_get_cubic_coeffs(x);
5451    for (var i = 0; i < 4; i++) {
5452      v[i] = coeffs[0] * p[i][0] + coeffs[1] * p[i][1] + coeffs[2] * p[i][2] + coeffs[3] * p[i][3];
5453    }
5454    coeffs = gs_get_cubic_coeffs(y);
5455    let pixel = ${t}(coeffs[0] * v[0] + coeffs[1] * v[1] + coeffs[2] * v[2] + coeffs[3] * v[3]);
5456    return pixel;
5457  }
5458`,kG=t=>`
5459  fn gs_denormalize(n: f32, length: i32) -> f32 {
5460    ${t.alignCorners===0?`
5461    // alignCorners: false => [-1, 1] to [-0.5, length - 0.5]
5462    return ((n + 1.0) * f32(length) - 1.0) / 2.0;
5463    `:`
5464    // alignCorners: true => [-1, 1] to [0, length - 1]
5465    return (n + 1.0) / 2.0 * (f32(length - 1));
5466    `}
5467  }
5468`,IG=t=>`
5469  ${t.paddingMode==="reflection"?`
5470      fn gs_reflect(x: i32, x_min: f32, x_max: f32) -> u32 {
5471        var dx = 0.0;
5472        var fx = f32(x);
5473        let range = x_max - x_min;
5474        if (fx < x_min) {
5475          dx = x_min - fx;
5476          let n = u32(dx / range);
5477          let r = dx - f32(n) * range;
5478          if (n % 2 == 0) {
5479            fx = x_min + r;
5480          } else {
5481            fx = x_max - r;
5482          }
5483        } else if (fx > x_max) {
5484          dx = fx - x_max;
5485          let n = u32(dx / range);
5486          let r = dx - f32(n) * range;
5487          if (n % 2 == 0) {
5488            fx = x_max - r;
5489          } else {
5490            fx = x_min + r;
5491          }
5492        }
5493        return u32(fx);
5494      }`:""}
5495`,NG=(t,e,n)=>`
5496  fn pixel_at_grid(r: i32, c: i32, H: i32, W: i32, batch: u32, channel: u32, border: vec4<f32>) -> ${e} {
5497     var pixel = ${e}(0);
5498     var indices = vec4<u32>(0);
5499     indices[${$f}] = batch;
5500     indices[${Hp}] = channel;`+(()=>{switch(n.paddingMode){case"zeros":return`
5501          if (r >= 0 && r < H && c >=0 && c < W) {
5502            indices[${Dy}] = u32(r);
5503            indices[${Oy}] = u32(c);
5504          } else {
5505            return ${e}(0);
5506          }
5507        `;case"border":return`
5508          indices[${Dy}] = u32(clamp(r, 0, H - 1));
5509          indices[${Oy}] = u32(clamp(c, 0, W - 1));
5510        `;case"reflection":return`
5511          indices[${Dy}] = gs_reflect(r, border[1], border[3]);
5512          indices[${Oy}] = gs_reflect(c, border[0], border[2]);
5513        `;default:throw new Error(`padding mode ${n.paddingMode} is not supported`)}})()+`
5514    return ${t.getByIndices("indices")};
5515  }
5516`,RG=(t,e,n)=>(()=>{switch(n.mode){case"nearest":return`
5517          let result = pixel_at_grid(i32(round(y)), i32(round(x)), H_in, W_in, indices[${$f}], indices[${Hp}], border);
5518        `;case"bilinear":return`
5519          let x1 = i32(floor(x));
5520          let y1 = i32(floor(y));
5521          let x2 = x1 + 1;
5522          let y2 = y1 + 1;
5523
5524          let p11 = pixel_at_grid(y1, x1, H_in, W_in, indices[${$f}], indices[${Hp}], border);
5525          let p12 = pixel_at_grid(y1, x2, H_in, W_in, indices[${$f}], indices[${Hp}], border);
5526          let p21 = pixel_at_grid(y2, x1, H_in, W_in, indices[${$f}], indices[${Hp}], border);
5527          let p22 = pixel_at_grid(y2, x2, H_in, W_in, indices[${$f}], indices[${Hp}], border);
5528
5529          let dx2 = ${e}(f32(x2) - x);
5530          let dx1 = ${e}(x - f32(x1));
5531          let dy2 = ${e}(f32(y2) - y);
5532          let dy1 = ${e}(y - f32(y1));
5533          let result = dy2 * (dx2 * p11 + dx1 * p12) + dy1 * (dx2 * p21 + dx1 * p22);
5534        `;case"bicubic":return`
5535          let x0 = i32(floor(x)) - 1;
5536          let y0 = i32(floor(y)) - 1;
5537          var p: mat4x4<${e}>;
5538          for (var h = 0; h < 4; h++) {
5539            for (var w = 0; w < 4; w++) {
5540              p[h][w] = pixel_at_grid(h + y0, w + x0, H_in, W_in, indices[${$f}], indices[${Hp}], border);
5541            }
5542          }
5543
5544          let dx = x - f32(x0 + 1);
5545          let dy = y - f32(y0 + 1);
5546          let result = gs_bicubic_interpolate(p, dx, dy);
5547        `;default:throw new Error(`mode ${n.mode} is not supported`)}})()+`${t.setByOffset("global_idx","result")}`,MG=(t,e)=>{let n=St("x",t[0].dataType,t[0].dims.length),s=[t[1].dims[0],t[1].dims[1],t[1].dims[2]],r=St("grid",t[1].dataType,s.length,2),i=[t[0].dims[0],t[0].dims[1],t[1].dims[1],t[1].dims[2]];e.format==="NHWC"&&(i=[t[0].dims[0],t[1].dims[1],t[1].dims[2],t[0].dims[3]],[$f,Hp,Dy,Oy]=[0,3,1,2]);let a=wn("output",t[0].dataType,i.length),o=n.type.value,l=dt.size(i),c=[{type:12,data:l},...Mn(t[0].dims,s,i)],h=p=>`
5548  ${p.registerUniform("output_size","u32").declareVariables(n,r,a)}
5549  ${AG}
5550  ${CG(o)}
5551  ${kG(e)}
5552  ${IG(e)}
5553  ${NG(n,o,e)}
5554
5555  ${p.mainStart()}
5556    ${p.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5557      let H_in = i32(uniforms.x_shape[${Dy}]);
5558      let W_in = i32(uniforms.x_shape[${Oy}]);
5559
5560      ${e.alignCorners===0?`
5561      let x_min = -0.5;
5562      let x_max = f32(W_in) - 0.5;
5563      let y_min = -0.5;
5564      let y_max = f32(H_in) - 0.5;
5565      `:`
5566      let x_min = 0.0;
5567      let x_max = f32(W_in) - 1.0;
5568      let y_min = 0.0;
5569      let y_max = f32(H_in) - 1.0;
5570      `};
5571      let border = vec4<f32>(x_min, y_min, x_max, y_max);
5572
5573      let indices = ${a.offsetToIndices("global_idx")};
5574      var grid_indices = vec3<u32>(indices[${$f}], indices[${Dy}], indices[${Oy}]);
5575      let nxy = ${r.getByIndices("grid_indices")};
5576      var x = gs_denormalize(f32(nxy[0]), W_in);
5577      var y = gs_denormalize(f32(nxy[1]), H_in);
5578
5579      ${RG(a,o,e)}
5580  }`;return{name:"GridSample",shaderCache:{hint:`${e.cacheKey}`,inputDependencies:["type","type"]},getRunData:p=>{let m=dt.size(i);return{outputs:[{dims:i,dataType:p[0].dataType}],dispatchGroup:{x:Math.ceil(m/64)},programUniforms:c}},getShaderSource:h}},Lte=(t,e)=>{TG(t.inputs),t.compute(MG(t.inputs,e))},jte=t=>Rr({alignCorners:t.align_corners,mode:t.mode,paddingMode:t.padding_mode,format:t.format})}),zl,PG,Bte,R$,$G,hS,Ute,Fte=qt(()=>{ts(),Ts(),na(),W7(),X7(),Rs(),ty(),zl=(t,e)=>t.length>e&&t[e].dims.length>0?t[e]:void 0,PG=(t,e)=>{let n=t[0],s=zl(t,1),r=zl(t,2),i=zl(t,3),a=zl(t,4),o=zl(t,5),l=zl(t,6),c=zl(t,7);if(n.dims.length!==3&&n.dims.length!==5)throw new Error("Input query is expected to have 3 or 5 dimensions");let h=n.dims[0],p=n.dims[1],m=n.dims.length===3?n.dims[2]:e.numHeads*n.dims[4],y=p,v=0,b=0,S=Math.floor(m/e.numHeads);if(l&&c&&dt.size(l.dims)&&dt.size(c.dims)){if(l.dims.length!==4)throw new Error('Input "past_key" is expected to have 4 dimensions');if(l.dims[0]!==h||l.dims[1]!==e.numHeads||l.dims[3]!==S)throw new Error('Input "past_key" shape (batch_size, num_heads, past_sequence_length, head_size)');if(c.dims[0]!==h||c.dims[1]!==e.numHeads||c.dims[3]!==S)throw new Error('Input "past_value" shape (batch_size, num_heads, past_sequence_length, head_size)');if(l.dims[2]!==c.dims[2])throw new Error('Input "past_key" and "past_value" shall have same dim 2 (past_sequence_length)');if(c.dims.length!==4)throw new Error('Input "past_value" is expected to have 4 dimensions');v=l.dims[2],b=l.dims[2]}else if(l&&dt.size(l.dims)||c&&dt.size(c.dims))throw new Error('Input "past_key" and "past_value" shall be both present or both absent');let E;if(s&&dt.size(s.dims)>0){if(n.dims.length!==3)throw new Error('Input "query" is expected to have 3 dimensions when key is given');if(s.dims.length<3||s.dims.length>5)throw new Error('Input "key" is expected to have 3, 4, or 5 dimensions');if(n.dims[0]!==s.dims[0])throw new Error('Input "query" and "key" shall have same dim 0 (batch size)');if(s.dims.length===3){if(s.dims[2]!==n.dims[2])throw new Error('Input "query" and "key" shall have same dim 2 (hidden_size)');E=2,y=s.dims[1]}else if(s.dims.length===5){if(s.dims[2]!==e.numHeads||s.dims[3]!==2||s.dims[4]!==S)throw new Error('Expect "key" shape (batch_size, kv_sequence_length, num_heads, 2, head_size) for packed kv');if(r)throw new Error('Expect "value" be none when "key" has packed kv format.');E=5,y=s.dims[1]}else{if(s.dims[1]!==e.numHeads||s.dims[3]!==S)throw new Error('Expect "key" shape (batch_size, num_heads, kv_sequence_length, head_size) for past_key');E=0,y=s.dims[2]}}else{if(n.dims.length!==5)throw new Error('Input "query" is expected to have 5 dimensions when key is empty');if(n.dims[2]!==e.numHeads||n.dims[3]!==3)throw new Error('Expect "query" shape (batch_size, kv_sequence_length, num_heads, 3, head_size) for packed kv');E=3}if(i&&dt.size(i.dims)>0){if(i.dims.length!==1)throw new Error('Input "bias" is expected to have 1 dimension');
vendor: 5,392 bytes, lines 5580-5607
5580if(s&&s.dims.length===5&&s.dims[3]===2)throw new Error("bias is not allowed for packed kv.")}let I=v+y,M=0;if(a&&dt.size(a.dims)>0){M=8;let D=a.dims;throw D.length===1?D[0]===h?M=1:D[0]===3*h+2&&(M=3):D.length===2&&D[0]===h&&D[1]===I&&(M=5),M===8?new Error('Input "key_padding_mask" shape shall be (batch_size) or (batch_size, total_sequence_length)'):new Error("Mask not supported")}let j=!1,L=m;if(r&&dt.size(r.dims)>0){if(r.dims.length!==3&&r.dims.length!==4)throw new Error('Input "value" is expected to have 3 or 4 dimensions');if(n.dims[0]!==r.dims[0])throw new Error('Input "query" and "value" shall have same dim 0 (batch_size)');if(r.dims.length===3){if(y!==r.dims[1])throw new Error('Input "key" and "value" shall have the same dim 1 (kv_sequence_length)');L=r.dims[2]}else{if(y!==r.dims[2])throw new Error('Input "key" and "value" shall have the same dim 2 (kv_sequence_length)');L=r.dims[1]*r.dims[3],j=!0}}let K=!1;if(a&&dt.size(a.dims)>0)throw new Error("Key padding mask is not supported");if(o&&dt.size(o.dims)>0){if(o.dims.length!==4)throw new Error('Input "attention_bias" is expected to have 4 dimensions');if(o.dims[0]!==h||o.dims[1]!==e.numHeads||o.dims[2]!==p||o.dims[3]!==I)throw new Error('Expect "attention_bias" shape (batch_size, num_heads, sequence_length, total_sequence_length)')}return{batchSize:h,sequenceLength:p,pastSequenceLength:v,kvSequenceLength:y,totalSequenceLength:I,maxSequenceLength:b,inputHiddenSize:0,hiddenSize:m,vHiddenSize:L,headSize:S,vHeadSize:Math.floor(L/e.numHeads),numHeads:e.numHeads,isUnidirectional:!1,pastPresentShareBuffer:!1,maskFilterValue:e.maskFilterValue,maskType:M,scale:e.scale,broadcastResPosBias:K,passPastInKv:j,qkvFormat:E}},Bte=t=>Rr({...t}),R$=Rr({perm:[0,2,1,3]}),$G=(t,e,n,s,r,i,a)=>{let o=[s,r,i],l=dt.size(o),c=[{type:12,data:l},{type:12,data:a},{type:12,data:i}],h=p=>{let m=wn("qkv_with_bias",e.dataType,o),y=St("qkv",e.dataType,o),v=St("bias",n.dataType,o),b=[{name:"output_size",type:"u32"},{name:"bias_offset",type:"u32"},{name:"hidden_size",type:"u32"}];return`
5581  ${p.registerUniforms(b).declareVariables(y,v,m)}
5582  ${p.mainStart()}
5583    ${p.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5584    let bias_offset_idx = (global_idx % uniforms.hidden_size) + uniforms.bias_offset;
5585
5586    qkv_with_bias[global_idx] = qkv[global_idx] + bias[bias_offset_idx];
5587  }`};return t.compute({name:"MultiHeadAttentionAddBias",shaderCache:{inputDependencies:["type","type"]},getRunData:()=>({outputs:[{dims:o,dataType:e.dataType,gpuDataType:0}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:c}),getShaderSource:h},{inputs:[e,n],outputs:[-1]})[0]},hS=(t,e,n,s,r,i,a,o)=>{let l=i;if(a&&dt.size(a.dims)>0){if(s===1)throw new Error("AddBiasReshape is not implemented. Please export your model with packed QKV or KV");return l=$G(t,i,a,e,s,n*r,o),l=l.reshape([e,s,n,r]),n===1||s===1?l:t.compute(Ru(l,R$.perm),{inputs:[l],outputs:[-1]})[0]}else return i.dims.length===3&&(l=i.reshape([e,s,n,r])),n===1||s===1?l:t.compute(Ru(l,R$.perm),{inputs:[l],outputs:[-1]})[0]},Ute=(t,e)=>{let n=PG(t.inputs,e),s=t.inputs[0],r=zl(t.inputs,1),i=zl(t.inputs,2),a=zl(t.inputs,3),o=zl(t.inputs,4),l=zl(t.inputs,5),c=zl(t.inputs,6),h=zl(t.inputs,7);if(s.dims.length===5)throw new Error("Packed QKV is not implemented");if((r==null?void 0:r.dims.length)===5)throw new Error("Packed KV is not implemented");let p=r&&i&&r.dims.length===4&&i.dims.length===4,m=hS(t,n.batchSize,n.numHeads,n.sequenceLength,n.headSize,s,a,0);if(p)return AE(t,m,r,i,o,void 0,c,h,l,n);if(!r||!i)throw new Error("key and value must be provided");let y=hS(t,n.batchSize,n.numHeads,n.kvSequenceLength,n.headSize,r,a,n.hiddenSize),v=hS(t,n.batchSize,n.numHeads,n.kvSequenceLength,n.vHeadSize,i,a,2*n.hiddenSize);AE(t,m,y,v,o,void 0,c,h,l,n)}}),DG,OG,LG,jG,s5,Vte,zte,Gte=qt(()=>{ts(),Ts(),na(),Rs(),DG=t=>{if(!t||t.length<1)throw new Error("too few inputs")},OG=(t,e)=>{let n=[],s=e.numOutputs;return t[1].dims[0]>0&&(t[1].getBigInt64Array().forEach(r=>n.push(Number(r))),s=n.length),Rr({numOutputs:s,axis:e.axis,splitSizes:n})},LG=t=>`
5588fn calculateOutputIndex(index: u32) -> u32 {
5589    for (var i: u32 = 0u; i < ${t}u; i += 1u ) {
5590    if (index < ${An("uniforms.size_in_split_axis","i",t)}) {
5591        return i;
5592    }
5593    }
5594    return ${t}u;
5595}`,jG=t=>{let e=t.length,n=[];for(let s=0;s<e;++s){let r=t[s].setByIndices("indices","input[global_idx]");e===1?n.push(r):s===0?n.push(`if (output_number == ${s}u) { ${r} }`):s===e-1?n.push(`else { ${r} }`):n.push(`else if (output_number == ${s}) { ${r} }`)}return`
5596      fn writeBufferData(output_number: u32, indices: ${t[0].type.indices}, global_idx: u32) {
5597        ${n.join(`
5598`)}
5599      }`},s5=(t,e)=>{let n=t[0].dims,s=dt.size(n),r=t[0].dataType,i=dt.normalizeAxis(e.axis,n.length),a=new Array(e.numOutputs),o=St("input",r,n.length),l=new Array(e.numOutputs),c=[],h=[],p=0,m=[{type:12,data:s}];for(let v=0;v<e.numOutputs;v++){p+=e.splitSizes[v],l[v]=p;let b=n.slice();b[i]=e.splitSizes[v],h.push(b),a[v]=wn(`output${v}`,r,b.length),c.push({dims:h[v],dataType:t[0].dataType})}m.push({type:12,data:l},...Mn(n,...h));let y=v=>`
5600  ${v.registerUniform("input_size","u32").registerUniform("size_in_split_axis","u32",l.length).declareVariables(o,...a)}
5601  ${LG(l.length)}
5602  ${jG(a)}
5603
5604  ${v.mainStart()}
5605    ${v.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.input_size")}
5606
5607    var indices = ${o.offsetToIndices("global_idx")};
5608    var index = ${o.indicesGet("indices",i)};
5609    let output_number = calculateOutputIndex(index);
5610    if (output_number != 0) {
5611      index -= ${An("uniforms.size_in_split_axis","output_number - 1u",l.length)};
5612      ${o.indicesSet("indices",i,"index")};
5613    }
5614    writeBufferData(output_number, indices, global_idx);
5615  }`;return{name:"Split",shaderCache:{hint:e.cacheKey,inputDependencies:["rank"]},getShaderSource:y,getRunData:()=>({outputs:c,dispatchGroup:{x:Math.ceil(s/64)},programUniforms:m})}},Vte=(t,e)=>{DG(t.inputs);let n=t.inputs.length===1?e:OG(t.inputs,e);t.compute(s5(t.inputs,n),{inputs:[0]})},zte=t=>{let e=t.axis,n=t.splitSizes,s=t.numOutputs<0?n.length:t.numOutputs;if(s!==n.length)throw new Error("numOutputs and splitSizes length must be equal");return Rr({axis:e,numOutputs:s,splitSizes:n})}}),BG,dR,Hte,qte=qt(()=>{ts(),Ts(),na(),Rs(),BG=(t,e)=>{let[n,s,r,i]=t,{numHeads:a,rotaryEmbeddingDim:o}=e;if(n.dims.length!==3&&n.dims.length!==4)throw new Error(`Input 'x' is expected to have 3 or 4 dimensions, got ${n.dims.length}`);if(!dt.areEqual(s.dims,[])&&!dt.areEqual(s.dims,[1])&&s.dims.length!==2)throw new Error(`Input 'position_ids' is expected to have 0, 1, or 2 dimensions, got ${s.dims.length}`);if(r.dims.length!==2)throw new Error(`Input 'cos_cache' is expected to have 2 dimensions, got ${r.dims.length}`);if(i.dims.length!==2)throw new Error(`Input 'sin_cache' is expected to have 2 dimensions, got ${i.dims.length}`);if(!dt.areEqual(r.dims,i.dims))throw new Error("Inputs 'cos_cache' and 'sin_cache' are expected to have the same shape");if(o>0&&a===0)throw new Error("num_heads must be provided if rotary_embedding_dim is specified");let l=n.dims[0],c=n.dims[n.dims.length-2],h=r.dims[0],p=dt.sizeFromDimension(n.dims,1)/c,m=o===0?r.dims[1]*2:p/a;if(o>m)throw new Error("rotary_embedding_dim must be less than or equal to head_size");if(s.dims.length===2){if(l!==s.dims[0])throw new Error(`Input 'position_ids' dimension 0 should be of size batch_size, got ${s.dims[0]}`);if(c!==s.dims[1])throw new Error(`Input 'position_ids' dimension 1 should be of size sequence_length, got ${s.dims[1]}`)}if(c>h)throw new Error("Updating cos_cache and sin_cache in RotaryEmbedding is not currently supported");if(m/2!==r.dims[1]&&o/2!==r.dims[1])throw new Error(`Input 'cos_cache' dimension 1 should be same as head_size / 2 or rotary_embedding_dim / 2, got ${r.dims[1]}`)},dR=(t,e)=>{let{interleaved:n,numHeads:s,rotaryEmbeddingDim:r,scale:i}=e,a=t[0].dims[0],o=dt.sizeFromDimension(t[0].dims,1),l=t[0].dims[t[0].dims.length-2],c=o/l,h=t[2].dims[1],p=r===0?h*2:c/s,m=new Array(a,l,c/p,p-h),y=dt.computeStrides(m),v=[{type:1,data:i},{type:12,data:m},{type:12,data:y},...t[0].dims.length===3?new Array({type:12,data:[o,c,p,1]}):[],...t[0].dims.length===4?new Array({type:12,data:[o,p,l*p,1]}):[],...Mn(t[0].dims,t[1].dims,t[2].dims,t[3].dims,t[0].dims)],b=S=>{let E=St("input",t[0].dataType,t[0].dims.length),I=St("position_ids",t[1].dataType,t[1].dims.length),M=St("cos_cache",t[2].dataType,t[2].dims.length),j=St("sin_cache",t[3].dataType,t[3].dims.length),L=wn("output",t[0].dataType,t[0].dims.length);return S.registerUniforms([{name:"scale",type:"f32"},{name:"global_shape",type:"u32",length:m.length},{name:"global_strides",type:"u32",length:y.length},{name:"input_output_strides",type:"u32",length:y.length}]),`
5616        ${S.declareVariables(E,I,M,j,L)}
5617
5618        ${S.mainStart(W1)}
5619          let half_rotary_emb_dim = uniforms.${M.name}_shape[1];
5620          let bsnh = global_idx / uniforms.global_strides % uniforms.global_shape;
5621          let size = uniforms.global_shape[0] * uniforms.global_strides[0];
5622          ${S.guardAgainstOutOfBoundsWorkgroupSizes("size")}
5623
5624          if (bsnh[3] < half_rotary_emb_dim) {
5625            let position_ids_idx =
5626                ${I.broadcastedIndicesToOffset("bsnh.xy",wn("",I.type.tensor,2))};
5627            let position_id =
5628                u32(${I.getByOffset("position_ids_idx")}) + select(0, bsnh[1], position_ids_idx == 0);
5629            let i = dot(bsnh, uniforms.input_output_strides) + select(0, bsnh[3], ${n});
5630            let j = i + select(half_rotary_emb_dim, 1, ${n});
5631            let re = ${E.getByOffset("i")}
5631 * ${M.get("position_id","bsnh[3]")} -
5632                ${E.getByOffset("j")} * ${j.get("position_id","bsnh[3]")};
5633            ${L.setByOffset("i","re")}
5634            let im = ${E.getByOffset("i")} * ${j.get("position_id","bsnh[3]")} +
5635                ${E.getByOffset("j")} * ${M.get("position_id","bsnh[3]")};
5636            ${L.setByOffset("j","im")}
5637          } else {
5638            let k = dot(bsnh, uniforms.input_output_strides) + half_rotary_emb_dim;
5639            ${L.setByOffset("k",E.getByOffset("k"))}
5640          }
5641        }`};return{name:"RotaryEmbedding",shaderCache:{hint:Rr({interleaved:n}).cacheKey,inputDependencies:["rank","rank","rank","rank"]},getShaderSource:b,getRunData:()=>({outputs:[{dims:t[0].dims,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(dt.size(m)/W1)},programUniforms:v})}},Hte=(t,e)=>{BG(t.inputs,e),t.compute(dR(t.inputs,e))}}),UG,FG,M$,VG,Wte,XAe=qt(()=>{na(),ts(),X7(),Fte(),Gte(),ty(),qte(),Rs(),UG=(t,e)=>{if(e.doRotary&&t.length<=7)throw new Error("cos_cache and sin_cache inputs are required if do_rotary is specified");let n=t[0],s=t[1],r=t[2],i=t[3],a=t[4];if(e.doRotary!==0&&t.length<=7)throw new Error("cos_cast and sin_cache are expected if do_rotary attribute is non-zero");if(e.localWindowSize!==-1)throw new Error("Local attention is not supported");if(e.softcap!==0)throw new Error("Softcap is not supported");if(e.rotaryInterleaved!==0)throw new Error("Rotary interleaved is not supported");if(e.smoothSoftmax)throw new Error("Smooth softmax is not supported");if(n.dims.length!==3&&n.dims.length!==5)throw new Error("Input query is expected to have 3 or 5 dimensions");let o=!1,l=n.dims[0],c=n.dims[1],h=n.dims.length===3?o?n.dims[2]/3:n.dims[2]:e.numHeads*n.dims[4],p=c,m=0,y=!s||s.dims.length===0,v=Math.floor(y?h/(e.numHeads+2*e.kvNumHeads):h/e.numHeads);y&&(h=v*e.numHeads);let b=i&&i.dims.length!==0,S=a&&a.dims.length!==0;if(b&&i.dims.length===4&&i.dims[0]===l&&i.dims[1]!==e.kvNumHeads&&i.dims[2]===e.kvNumHeads&&i.dims[3]===v)throw new Error("BSNH pastKey/pastValue is not supported");if(b&&S){if(i.dims.length!==4)throw new Error('Input "past_key" is expected to have 4 dimensions');if(a.dims.length!==4)throw new Error('Input "past_value" is expected to have 4 dimensions');m=i.dims[2]}else if(b||S)throw new Error('Input "past_key" and "past_value" shall be both present or both absent');let E=1;if(s&&s.dims.length>0){if(n.dims.length!==3)throw new Error('Input "query" is expected to have 3 dimensions when key is given');if(s.dims.length<3||s.dims.length>5)throw new Error('Input "key" is expected to have 3, 4, or 5 dimensions');if(n.dims[0]!==s.dims[0])throw new Error('Input "query" and "key" shall have same dim 0 (batch size)');if(s.dims.length===3){if(n.dims[2]%s.dims[2]!==0)throw new Error('Dimension 2 of "query" should be a multiple of "key"');p=s.dims[1]}else if(s.dims.length===5){if(s.dims[2]!==e.numHeads||s.dims[3]!==2||s.dims[4]!==v)throw new Error('Expect "key" shape (batch_size, kv_sequence_length, num_heads, 2, head_size) for packed kv');if(r)throw new Error('Expect "value" be none when "key" has packed kv format.');p=s.dims[1]}else{if(s.dims[1]!==e.numHeads||s.dims[3]!==v)throw new Error('Expect "key" shape (batch_size, num_heads, kv_sequence_length, head_size) for past_key');p=s.dims[2]}}else{if(n.dims.length!==3&&n.dims.length!==5)throw new Error('Input "query" is expected to have 3 or 5 dimensions when key is empty');if(n.dims.length===5&&(n.dims[2]!==e.numHeads||n.dims[3]!==3))throw new Error('Expect "query" shape (batch_size, kv_sequence_length, num_heads, 3, head_size) for packed kv');E=3}let I=0,M=!1,j=e.kvNumHeads?v*e.kvNumHeads:h;if(r&&r.dims.length>0){if(r.dims.length!==3&&r.dims.length!==4)throw new Error('Input "value" is expected to have 3 or 4 dimensions');if(n.dims[0]!==r.dims[0])throw new Error('Input "query" and "value" shall have same dim 0 (batch_size)');if(r.dims.length===3){if(p!==r.dims[1])throw new Error('Input "key" and "value" shall have the same dim 1 (kv_sequence_length)');j=r.dims[2]}else{if(p!==r.dims[2])throw new Error('Input "past_key" and "past_value" shall have the same dim 2 (kv_sequence_length)');j=r.dims[1]*r.dims[3],M=!0}}let L=t.length>4?t[5]:void 0;if(L){if(L.dims.length===0)throw new Error("seqlens_k must be at least 1D, got scalar.");let K=L.dims.reduce((D,R)=>D*R,1);if(K!==l)throw new Error(`seqlens_k must have batch_size (${l}) elements, got ${K}.`);for(let D=0;D<L.dims.length;D++)if(L.dims[D]!==1&&L.dims[D]!==l)throw new Error(`seqlens_k has unexpected shape. Each dimension must be 1 or batch_size (${l}), got dims[${D}] = ${L.dims[D]}.`)}return{batchSize:l,sequenceLength:c,pastSequenceLength:m,kvSequenceLength:p,totalSequenceLength:-1,maxSequenceLength:-1,inputHiddenSize:0,hiddenSize:h,vHiddenSize:j,headSize:v,vHeadSize:Math.floor(j/e.kvNumHeads),numHeads:e.numHeads,kvNumHeads:e.kvNumHeads,nReps:e.numHeads/e.kvNumHeads,pastPresentShareBuffer:!1,maskType:I,scale:e.scale,broadcastResPosBias:!1,passPastInKv:M,qkvFormat:E}},FG=Rr({perm:[0,2,1,3]}),M$=(t,e,n)=>{let s=e,r=n.kvNumHeads;return e.dims.length===3&&n.kvSequenceLength!==0&&(s=e.reshape([n.batchSize,n.kvSequenceLength,r,n.headSize]),s=t.compute(Ru(s,FG.perm),{inputs:[s],outputs:[-1]})[0]),s},VG=(t,e,n,s)=>{let r=7,i=["type","type"],a=[t*e],o=t*e,l=[{type:12,data:o},{type:12,data:e},{type:12,data:t}],c=h=>{let p=St("seq_lens",n.dataType,n.dims),m=St("total_seq_lens",s.dataType,s.dims),y=wn("pos_ids",r,a),v=[{name:"output_size",type:"u32"},{name:"sequence_length",type:"u32"},{name:"batch_size",type:"u32"}];return`
5642  ${h.registerUniforms(v).declareVariables(p,m,y)}
5643  ${h.mainStart()}
5644    ${h.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5645    let total_sequence_length = u32(${m.getByOffset("0")});
5646    let is_subsequent_prompt = uniforms.sequence_length > 1 && uniforms.sequence_length != total_sequence_length;
5647    let is_first_prompt = !is_subsequent_prompt && uniforms.sequence_length == total_sequence_length;
5648    let batch_idx = global_idx / uniforms.sequence_length;
5649    let sequence_idx = i32(global_idx % uniforms.sequence_length);
5650    var pos_id: i32 = 0;
5651    let seqlen = ${p.getByOffset("batch_idx")};
5652    let total_seqlen = seqlen + 1;
5653    if (is_first_prompt) {
5654      if (sequence_idx < total_seqlen) {
5655        pos_id = sequence_idx;
5656      } else {
5657        pos_id = 1;
5658      }
5659      ${y.setByOffset("global_idx","pos_id")}
5660    } else if (is_subsequent_prompt) {
5661      let past_seqlen = total_seqlen - i32(uniforms.sequence_length);
5662      if (past_seqlen + sequence_idx < total_seqlen) {
5663        pos_id = past_seqlen + sequence_idx;
5664      } else {
5665        pos_id = 1;
5666      }
5667      ${y.setByOffset("global_idx","pos_id")}
5668    } else if (global_idx < uniforms.batch_size) {
5669      ${y.setByOffset("global_idx","seqlen")}
5670    };
5671  }
5672  `};return{name:"GeneratePositionIds",shaderCache:{hint:`${t};${e}`,inputDependencies:i},getRunData:()=>({outputs:[{dims:a,dataType:r}],dispatchGroup:{x:Math.ceil(o/64)},programUniforms:l}),getShaderSource:c}},Wte=(t,e)=>{var j;let n=UG(t.inputs,e);if(t.inputs[0].dims.length===5)throw new Error("Packed QKV is not implemented");if(((j=t.inputs[1])==null?void 0:j.dims.length)===5)throw new Error("Packed KV is not implemented");
vendor: 18,577 bytes, lines 5672-5856
5672let s=t.inputs[0],r=t.inputs[1]&&t.inputs[1].dims.length>0?t.inputs[1]:void 0,i=t.inputs[2]&&t.inputs[2].dims.length>0?t.inputs[2]:void 0,a=t.inputs[3]&&t.inputs[3].dims.length!==0?t.inputs[3]:void 0,o=t.inputs[4]&&t.inputs[4].dims.length!==0?t.inputs[4]:void 0,l=t.inputs.length>4?t.inputs[5]:void 0,c=t.inputs.length>5?t.inputs[6]:void 0,h=n.kvNumHeads?n.kvNumHeads:n.numHeads,p=Rr({axis:2,numOutputs:3,splitSizes:[n.numHeads*n.headSize,h*n.headSize,h*n.headSize]}),[m,y,v]=!r&&!i?t.compute(s5([s],p),{inputs:[s],outputs:[-1,-1,-1]}):[s,r,i],b,S;if(e.doRotary){let L=t.compute(VG(n.batchSize,n.sequenceLength,l,c),{inputs:[l,c],outputs:[-1]})[0],K=t.inputs[7],D=t.inputs[8],R=Rr({interleaved:e.rotaryInterleaved!==0,numHeads:n.numHeads,rotaryEmbeddingDim:0,scale:e.scale}),B=[m,L,K,D],G=[-1];b=t.compute(dR(B,R),{inputs:B,outputs:G})[0],B.splice(0,1,y);let X=Rr({interleaved:e.rotaryInterleaved!==0,numHeads:n.kvNumHeads,rotaryEmbeddingDim:0,scale:e.scale});S=t.compute(dR(B,X),{inputs:B,outputs:G})[0]}let E=hS(t,n.batchSize,n.numHeads,n.sequenceLength,n.headSize,e.doRotary?b:m,void 0,0),I=M$(t,e.doRotary?S:y,n),M=M$(t,v,n);AE(t,E,I,M,void 0,void 0,a,o,void 0,n,l,c)}}),P$,zG,GG,Kte,JAe=qt(()=>{ts(),Ts(),ty(),Rs(),P$=(t,e,n,s,r,i,a,o)=>{let l=Wi(i),c=l===1?"f32":`vec${l}f`,h=l===1?"vec2f":`mat2x${l}f`,p=r*a,m=64;p===1&&(m=256);let y=[r,a,i/l],v=[r,a,2],b=["rank","type","type"],S=[];S.push(...Mn(y,v));let E=I=>{let M=St("x",e.dataType,3,l),j=St("scale",n.dataType,n.dims),L=St("bias",s.dataType,s.dims),K=wn("output",1,3,2),D=[M,j,L,K];return`
5673  var<workgroup> workgroup_shared : array<${h}, ${m}>;
5674  const workgroup_size = ${m}u;
5675  ${I.declareVariables(...D)}
5676  ${I.mainStart(m)}
5677    let batch = workgroup_index / uniforms.x_shape[1];
5678    let channel = workgroup_index % uniforms.x_shape[1];
5679    let hight = uniforms.x_shape[2];
5680    // initialize workgroup memory
5681    var sum = ${c}(0);
5682    var squared_sum = ${c}(0);
5683    for (var h = local_idx; h < hight; h += workgroup_size) {
5684      let value = ${c}(${M.get("batch","channel","h")});
5685      sum += value;
5686      squared_sum += value * value;
5687    }
5688    workgroup_shared[local_idx] = ${h}(sum, squared_sum);
5689    workgroupBarrier();
5690
5691    for (var currSize = workgroup_size >> 1;  currSize > 0; currSize = currSize >> 1) {
5692      if (local_idx < currSize) {
5693        workgroup_shared[local_idx] = workgroup_shared[local_idx] + workgroup_shared[local_idx + currSize];
5694      }
5695      workgroupBarrier();
5696    }
5697    if (local_idx == 0) {
5698      let sum_final = ${H0("workgroup_shared[0][0]",l)} / f32(hight * ${l});
5699      let squared_sum_final = ${H0("workgroup_shared[0][1]",l)} / f32(hight * ${l});
5700
5701      let inv_std_dev = inverseSqrt(squared_sum_final - sum_final * sum_final + f32(${o}));
5702      let channel_scale = inv_std_dev * f32(scale[channel]);
5703      let channel_shift = f32(bias[channel]) - sum_final * channel_scale;
5704      output[workgroup_index] = vec2f(channel_scale, channel_shift);
5705    }
5706  }`};return t.compute({name:"InstanceNormComputeChannelScaleShift",shaderCache:{hint:`${l};${o};${m}`,inputDependencies:b},getRunData:()=>({outputs:[{dims:v,dataType:1}],dispatchGroup:{x:p},programUniforms:S}),getShaderSource:E},{inputs:[e,n,s],outputs:[-1]})[0]},zG=(t,e,n)=>{let s=e[0].dims,r=s,i=2,a=s[0],o=s[1],l=dt.sizeFromDimension(s,i),c=Wi(l),h=dt.size(r)/c,p=P$(t,e[0],e[1],e[2],a,l,o,n.epsilon),m=[a,o,l/c],y=[a,o],v=["type","none"],b=S=>{let E=St("x",e[0].dataType,m.length,c),I=St("scale_shift",1,y.length,2),M=wn("output",e[0].dataType,m.length,c),j=[E,I,M];return`
5707  ${S.registerUniform("output_size","u32").declareVariables(...j)}
5708  ${S.mainStart()}
5709  ${S.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5710      let outputIndices = ${M.offsetToIndices("global_idx")};
5711      let batch = outputIndices[0];
5712      let channel = outputIndices[1];
5713      let scale_shift = ${I.getByIndices("vec2<u32>(batch, channel)")};
5714      let value = ${E.getByOffset("global_idx")} * ${M.type.value}(scale_shift.x) + ${M.type.value}(scale_shift.y);
5715      ${M.setByOffset("global_idx","value")};
5716  }`};t.compute({name:"InstanceNormalization",shaderCache:{hint:`${c}`,inputDependencies:v},getRunData:()=>({outputs:[{dims:r,dataType:e[0].dataType}],dispatchGroup:{x:Math.ceil(h/64)},programUniforms:[{type:12,data:h},...Mn(m,y,m)]}),getShaderSource:b},{inputs:[e[0],p]})},GG=(t,e,n)=>{let s=e[0].dims,r=s,i=s[0],a=s[s.length-1],o=dt.sizeFromDimension(s,1)/a,l=Wi(a),c=dt.size(r)/l,h=[{type:12,data:o},{type:12,data:Math.floor(a/l)}],p=["type","type"],m=!1,y=[0,s.length-1];for(let E=0;E<s.length-2;E++)m=m||s[E+1]!==1,y.push(E+1);m=m&&s[s.length-1]!==1;let v=m?t.compute(Ru(t.inputs[0],y),{inputs:[t.inputs[0]],outputs:[-1]})[0]:t.inputs[0].reshape(Array.from({length:s.length},(E,I)=>s[y[I]])),b=P$(t,v,e[1],e[2],i,o,a,n.epsilon),S=E=>{let I=lo(e[0].dataType),M=l===1?"vec2f":`mat${l}x2f`,j=D=>{let R=D===0?"x":"y",B=l===1?"f32":`vec${l}f`;switch(l){case 1:return`${I}(${B}(scale.${R}))`;case 2:return`vec2<${I}>(${B}(scale[0].${R}, scale[1].${R}))`;case 4:return`vec4<${I}>(${B}(scale[0].${R}, scale[1].${R}, scale[2].${R}, scale[3].${R}))`;default:throw new Error(`Not supported compoents ${l}`)}},L=St("input",e[0].dataType,e[0].dims,l),K=wn("output",e[0].dataType,r,l);return`
5717  @group(0) @binding(0) var<storage, read> input : array<${L.type.storage}>;
5718  @group(0) @binding(1) var<storage, read> scale_input : array<${M}>;
5719  @group(0) @binding(2) var<storage, read_write> output : array<${K.type.storage}>;
5720  struct Uniforms {H: u32, C : u32};
5721  @group(0) @binding(3) var<uniform> uniforms: Uniforms;
5722
5723  ${E.mainStart()}
5724    let current_image_number = global_idx / (uniforms.C * uniforms.H);
5725    let current_channel_number = global_idx % uniforms.C;
5726
5727    let scale_offset = current_image_number * uniforms.C + current_channel_number;
5728    let scale = scale_input[scale_offset];
5729    output[global_idx] = fma(input[global_idx], ${j(0)}, ${j(1)});
5730  }`};t.compute({name:"InstanceNormalizationNHWC",shaderCache:{hint:`${l}`,inputDependencies:p},getRunData:()=>({outputs:[{dims:r,dataType:e[0].dataType}],dispatchGroup:{x:Math.ceil(c/64)},programUniforms:h}),getShaderSource:S},{inputs:[e[0],b]})},Kte=(t,e)=>{e.format==="NHWC"?GG(t,t.inputs,e):zG(t,t.inputs,e)}}),HG,qG,Yte,QAe=qt(()=>{ts(),Ts(),Rs(),HG=t=>{if(!t||t.length<2)throw new Error("layerNorm requires at least 2 inputs.")},qG=(t,e,n)=>{let s=e.simplified,r=t[0].dims,i=t[1],a=!s&&t[2],o=r,l=dt.normalizeAxis(e.axis,r.length),c=dt.sizeToDimension(r,l),h=dt.sizeFromDimension(r,l),p=dt.size(i.dims),m=a?dt.size(a.dims):0;if(p!==h||a&&m!==h)throw new Error(`Size of X.shape()[axis:] == ${h}.
5731       Size of scale and bias (if provided) must match this.
5732       Got scale size of ${p} and bias size of ${m}`);let y=[];for(let L=0;L<r.length;++L)L<l?y.push(r[L]):y.push(1);let v=Wi(h),b=["type","type"],S=[{type:12,data:c},{type:1,data:h},{type:12,data:Math.floor(h/v)},{type:1,data:e.epsilon}];a&&b.push("type");let E=n>1,I=n>2,M=L=>{let K=lo(t[0].dataType),D=[St("x",t[0].dataType,t[0].dims,v),St("scale",i.dataType,i.dims,v)];a&&D.push(St("bias",a.dataType,a.dims,v)),D.push(wn("output",t[0].dataType,o,v)),E&&D.push(wn("mean_data_output",1,y)),I&&D.push(wn("inv_std_output",1,y));let R=[{name:"norm_count",type:"u32"},{name:"norm_size",type:"f32"},{name:"norm_size_vectorized",type:"u32"},{name:"epsilon",type:"f32"}];return`
5733  ${L.registerUniforms(R).declareVariables(...D)}
5734  ${L.mainStart()}
5735    ${L.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.norm_count")}
5736    let offset = global_idx * uniforms.norm_size_vectorized;
5737    var mean_vector = ${KD("f32",v)};
5738    var mean_square_vector = ${KD("f32",v)};
5739
5740    for (var h: u32 = 0u; h < uniforms.norm_size_vectorized; h++) {
5741      let value = ${ow(K,v,"x[h + offset]")};
5742      mean_vector += value;
5743      mean_square_vector += value * value;
5744    }
5745    let mean = ${H0("mean_vector",v)} / uniforms.norm_size;
5746    let inv_std_dev = inverseSqrt(${H0("mean_square_vector",v)} / uniforms.norm_size ${s?"":"- mean * mean"} + uniforms.epsilon);
5747
5748    for (var j: u32 = 0; j < uniforms.norm_size_vectorized; j++) {
5749      let f32input = ${ow(K,v,"x[j + offset]")};
5750      let f32scale = ${ow(K,v,"scale[j]")};
5751      output[j + offset] = ${D[0].type.value}((f32input ${s?"":"- mean"}) * inv_std_dev * f32scale
5752        ${a?`+ ${ow(K,v,"bias[j]")}`:""}
5753      );
5754    }
5755
5756    ${E?"mean_data_output[global_idx] = mean":""};
5757    ${I?"inv_std_output[global_idx] = inv_std_dev":""};
5758  }`},j=[{dims:o,dataType:t[0].dataType}];return E&&j.push({dims:y,dataType:1}),I&&j.push({dims:y,dataType:1}),{name:"LayerNormalization",shaderCache:{hint:`${v};${n};${s}`,inputDependencies:b},getRunData:()=>({outputs:j,dispatchGroup:{x:Math.ceil(c/64)},programUniforms:S}),getShaderSource:M}},Yte=(t,e)=>{HG(t.inputs),t.compute(qG(t.inputs,e,t.outputCount))}}),WG,Xte,ZAe=qt(()=>{Ts(),tj(),nj(),WG=t=>{if(!t||t.length!==2)throw new Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw new Error("shared dimension does not match.")},Xte=t=>{WG(t.inputs);let e=q1.calcShape(t.inputs[0].dims,t.inputs[1].dims,!0);if(!e)throw new Error("Can't use matmul on the given tensors");let n=e[e.length-1],s=t.inputs[0].dims[t.inputs[0].dims.length-1];if(n<8&&s<8)t.compute(ej(t.inputs,{activation:""},e));else{let r=e[e.length-2],i=dt.size(t.inputs[0].dims.slice(0,-2)),a=dt.size(t.inputs[1].dims.slice(0,-2));if(i!==1&&r===1&&a===1){let o=t.inputs[0].reshape([1,i,s]),l=t.inputs[1].reshape([1,s,n]),c=[1,i,n],h=[o,l];t.compute(uR(h,{activation:""},e,c),{inputs:h})}else t.compute(uR(t.inputs,{activation:""},e))}}}),KG,YG,XG,Jte,Qte,eCe=qt(()=>{ts(),Ts(),na(),Rs(),KG=(t,e)=>{if(t.length<3||t.length>4)throw new Error("MatMulNBits requires 3 or 4 inputs");let n=t[0],s=n.dims.length;if(n.dims[s-1]!==e.k)throw new Error("The last dim of input shape does not match the k value");let r=Math.floor((e.k+e.blockSize-1)/e.blockSize),i=e.blockSize/8*e.bits,a=t[1];if(!dt.areEqual(a.dims,[e.n,r,i]))throw new Error("The second inputs must be 3D tensor with shape N X nBlocksPerCol X blobSize");let o=t[2].dims;if(dt.size(o)!==e.n*r)throw new Error("scales input size error.");if(t.length===4){let l=t[3].dims,c=e.n*(e.bits===8?r:Math.floor((r*e.bits+7)/8));if(dt.size(l)!==c)throw new Error("zeroPoints input size error.")}},YG=(t,e)=>{let n=t[0].dims,s=n.length,r=n[s-2],i=e.k,a=e.n,o=n.slice(0,s-2),l=dt.size(o),c=t[1].dims[2]/4,h=t[0].dataType,p=Wi(e.k),m=Wi(c),y=Wi(a),v=o.concat([r,a]),b=r>1&&a/y%2===0?2:1,S=dt.size(v)/y/b,E=64,I=[],M=[l,r,i/p],j=dt.convertShape(t[1].dims).slice();j.splice(-1,1,c/m),I.push(...Mn(M)),I.push(...Mn(j)),I.push(...Mn(t[2].dims)),t.length===4&&I.push(...Mn(dt.convertShape(t[3].dims)));let L=[l,r,a/y];I.push(...Mn(L));let K=D=>{let R=M.length,B=St("a",t[0].dataType,R,p),G=St("b",12,j.length,m),X=St("scales",t[2].dataType,t[2].dims.length),H=[B,G,X],Y=t.length===4?St("zero_points",12,t[3].dims.length):void 0;Y&&H.push(Y);let F=L.length,we=wn("output",t[0].dataType,F,y),me=lo(t[0].dataType),xe=(()=>{switch(p){case 1:return`array<${me}, 8>`;case 2:return`mat4x2<${me}>`;case 4:return`mat2x4<${me}>`;default:throw new Error(`${p}-component is not supported.`)}})(),Le=Math.floor(32/e.bits),ve=Math.floor(Le/8),ce=()=>{let Re="";for(let Se=0;Se<ve;Se++){let De=Se*e.bits*4,gt=De+e.bits;Re+=`
5759          // reuse a data (pass ${Se})
5760            var input_offset${Se>0?Se:""} = ${Se===0?B.indicesToOffset(`${B.type.indices}(batch, row, word_offset)`):"input_offset"};
5761            var a_data${Se>0?Se:""}: ${xe};
5762            for (var j${Se>0?Se:""}: u32 = 0; j${Se>0?Se:""} < ${8/p}; j${Se>0?Se:""}++) {
5763              a_data${Se>0?Se:""}[j${Se>0?Se:""}] = ${B.getByOffset(`input_offset${Se>0?Se:""}`)};
5764              input_offset${Se>0?Se:""}++;
5765            }
5766          `;for(let yt=0;yt<y*b;yt++)Re+=`
5767            b_value = ${m===1?`b${yt}_data`:`b${yt}_data[i]`};
5768            ${e.bits===2?`{
5769              let half_word = b_value >> ${Se*16}u;
5770              let byte_lo = half_word & 0xFFu;
5771              let byte_hi = (half_word >> 8u) & 0xFFu;
5772              let spread_word = (byte_lo & 0xFu) | ((byte_lo >> 4u) << 8u) | ((byte_hi & 0xFu) << 16u) | ((byte_hi >> 4u) << 24u);
5773              b_value_lower = unpack4xU8(spread_word & b_mask);
5774              b_value_upper = unpack4xU8((spread_word >> 2u) & b_mask);
5775            }`:`b_value_lower = unpack4xU8((b_value >> ${De}u) & b_mask);
5776            b_value_upper = unpack4xU8((b_value >> ${gt}u) & b_mask);`}
5777            b_quantized_values = ${xe}(${Array.from({length:4},(xt,Nt)=>`${me}(b_value_lower[${Nt}]), ${me}(b_value_upper[${Nt}])`).join(", ")});
5778            b_dequantized_values = ${p===1?`${xe}(${Array.from({length:8},(xt,Nt)=>`(b_quantized_values[${Nt}] - ${Y?`zero_point${yt}`:"zero_point"}) * scale${yt}`).join(", ")});`:`(b_quantized_values - ${xe}(${Array(8).fill(`${Y?`zero_point${yt}`:"zero_point"}`).join(",")})) * scale${yt};`};
5779            workgroup_shared[local_id.x * ${b} + ${Math.floor(yt/y)}]${y>1?`[${yt%y}]`:""} += ${Array.from({length:8/p},(xt,Nt)=>`${p===1?`a_data${Se>0?Se:""}[${Nt}] * b_dequantized_values[${Nt}]`:`dot(a_data${Se>0?Se:""}[${Nt}], b_dequantized_values[${Nt}])`}`).join(" + ")};
5780          `}return Re},ie=()=>{let Re=`
5781            var col_index = col * ${y};
5782            ${Y?`
5783            let zero_point_values_per_byte: u32 = ${Math.floor(8/e.bits)}u;
5784            let zero_point_bytes_per_col = (nBlocksPerCol + zero_point_values_per_byte - 1u) / zero_point_values_per_byte;
5785            var zero_point_byte_count: u32;
5786            var zero_point_word_index: u32;
5787            var zero_point_byte_offset: u32;
5788            let zero_point_sub_offset: u32 = block % zero_point_values_per_byte;
5789            var zero_point_bits_offset: u32;
5790            var zero_point_word: u32;`:`
5791            // The default zero point is ${Math.pow(2,e.bits-1)} for unsigned ${e.bits}-bit quantization.
5792            let zero_point = ${me}(${Math.pow(2,e.bits-1).toFixed(1)});`}
5793            `;for(let Se=0;Se<y*b;Se++)Re+=`
5794            let scale${Se} = ${X.getByOffset("col_index * nBlocksPerCol + block")};
5795            ${Y?`
5796            zero_point_byte_count = col_index * zero_point_bytes_per_col + (block / zero_point_values_per_byte);
5797            zero_point_word_index = zero_point_byte_count >> 0x2u;
5798            zero_point_byte_offset = zero_point_byte_count & 0x3u;
5799            zero_point_bits_offset = (zero_point_byte_offset << 3) + (zero_point_sub_offset * ${e.bits}u);
5800            zero_point_word = ${Y.getByOffset("zero_point_word_index")} >> zero_point_bits_offset;
5801            let zero_point${Se} = ${me}((zero_point_word) & ${e.bits===2?"0x3u":"0xFu"});`:""}
5802            col_index += 1;`;return Re},de=()=>{let Re=`col_index = col * ${y};`;for(let Se=0;Se<y*b;Se++)Re+=`
5803            let b${Se}_data = ${G.getByIndices(`${G.type.indices}(col_index, block, word)`)};
5804            col_index += 1;`;return Re+=`
5805            var b_value: u32;
5806            let b_mask: u32 = ${e.bits===2?"0x03030303u":"0x0F0F0F0Fu"};
5807            var b_value_lower: vec4<u32>;
5808            var b_value_upper: vec4<u32>;
5809            var b_quantized_values: ${xe};
5810            var b_dequantized_values: ${xe};`,Re};return`
5811        var<workgroup> workgroup_shared: array<${we.type.value}, ${b*E}>;
5812        ${D.declareVariables(...H,we)}
5813        ${D.mainStart([E,1,1])}
5814          let output_indices = ${we.offsetToIndices(`(global_idx / ${E}) * ${b}`)};
5815          let col = output_indices[2];
5816          let row = output_indices[1];
5817          let batch = output_indices[0];
5818          let nBlocksPerCol = uniforms.b_shape[1];
5819
5820          for (var block = local_id.x; block < nBlocksPerCol; block += ${E}) {
5821            //process one block
5822            var word_offset: u32 = block * ${e.blockSize/p};
5823            ${ie()}
5824            for (var word: u32 = 0; word < ${c}; word += ${m}) {
5825              ${de()}
5826              for (var i: u32 = 0; i < ${m}; i++) {
5827                ${ce()}
5828                word_offset += ${Le/p};
5829              }
5830            }
5831          }
5832          workgroupBarrier();
5833
5834          if (local_id.x < ${b}) {
5835            var output_value: ${we.type.value} = ${we.type.value}(0);
5836            var workgroup_shared_offset: u32 = local_id.x;
5837            for (var b: u32 = 0u; b < ${E}u; b++) {
5838              output_value += workgroup_shared[workgroup_shared_offset];
5839              workgroup_shared_offset += ${b};
5840            }
5841            ${we.setByIndices(`${we.type.indices}(batch, row, col + local_id.x)`,"output_value")};
5842          }
5843        }`};return{name:"MatMulNBits",shaderCache:{hint:`${e.blockSize};${e.bits};${p};${m};${y};${b};${E}`,inputDependencies:Array(t.length).fill("rank")},getRunData:()=>({outputs:[{dims:v,dataType:h}],dispatchGroup:{x:S},programUniforms:I}),getShaderSource:K}},XG=(t,e)=>{let n=t[0].dims,s=n.length,r=n[s-2],i=e.k,a=e.n,o=n.slice(0,s-2),l=dt.size(o),c=t[1].dims[2]/4,h=t[0].dataType,p=Wi(e.k),m=Wi(c),y=o.concat([r,a]),v=128,b=a%8===0?8:a%4===0?4:1,S=v/b,E=Math.floor(32/e.bits),I=S*m*E,M=I/p,j=I/e.blockSize,L=dt.size(y)/b,K=[],D=[l,r,i/p],R=dt.convertShape(t[1].dims).slice();R.splice(-1,1,c/m),K.push(...Mn(D)),K.push(...Mn(R)),K.push(...Mn(t[2].dims)),t.length===4&&K.push(...Mn(dt.convertShape(t[3].dims)));let B=[l,r,a];K.push(...Mn(B));let G=X=>{let H=D.length,Y=St("a",t[0].dataType,H,p),F=St("b",12,R.length,m),we=St("scales",t[2].dataType,t[2].dims.length),me=[Y,F,we],xe=t.length===4?St("zero_points",12,t[3].dims.length):void 0;xe&&me.push(xe);let Le=B.length,ve=wn("output",t[0].dataType,Le),ce=lo(t[0].dataType),ie=()=>{switch(p){case 1:return`
5844          let a_data0 = vec4<${ce}>(sub_a[word_offset], sub_a[word_offset + 1], sub_a[word_offset + 2], sub_a[word_offset + 3]);
5845          let a_data1 = vec4<${ce}>(sub_a[word_offset + 4], sub_a[word_offset + 5], sub_a[word_offset + 6], sub_a[word_offset + 7]);`;case 2:return`
5846          let a_data0 = vec4<${ce}>(sub_a[word_offset], sub_a[word_offset + 1]);
5847          let a_data1 = vec4<${ce}>(sub_a[word_offset + 2], sub_a[word_offset + 3]);`;case 4:return`
5848          let a_data0 = sub_a[word_offset];
5849          let a_data1 = sub_a[word_offset + 1];`;default:throw new Error(`${p}-component is not supported.`)}};return`
5850        var<workgroup> sub_a: array<${Y.type.value}, ${M}>;
5851        var<workgroup> inter_results: array<array<${ve.type.value}, ${S}>, ${b}>;
5852        ${X.declareVariables(...me,ve)}
5853        ${X.mainStart([S,b,1])}
5854          let output_indices = ${ve.offsetToIndices(`workgroup_index * ${b}`)};
5855          let col = output_indices[2];
5856          let row = output_indices[1];
5857          let batch = output_indices[0];
5858          let n_blocks_per_col = uniforms.b_shape[1];
5859          let num_tiles =  (n_blocks_per_col - 1) / ${j} + 1;
5860
5861          // Loop over shared dimension.
5862          for (var tile: u32 = 0; tile < num_tiles; tile += 1) {
5863            let a_col_start = tile * ${M};
5864            // load one tile A data into shared memory.
5865            for (var a_offset = local_idx; a_offset < ${M}; a_offset += ${v})
5866            {
5867              let a_col = a_col_start + a_offset;
5868              if (a_col < uniforms.a_shape[2])
5869              {
5870                sub_a[a_offset] = ${Y.getByIndices(`${Y.type.indices}(batch, row, a_col)`)};
5871              } else {
5872                sub_a[a_offset] = ${Y.type.value}(0);
5873              }
5874            }
5875            workgroupBarrier();
5876
5877            // each thread process one block
5878            let b_row = col + local_id.y;
5879            let block = tile * ${j} + local_id.x;
5880            ${xe?`
5881            let zero_point_values_per_byte: u32 = ${Math.floor(8/e.bits)}u;
5882            let zero_point_bytes_per_col = (n_blocks_per_col + zero_point_values_per_byte - 1u) / zero_point_values_per_byte;
5883            let zero_point_byte_count = b_row * zero_point_bytes_per_col + (block / zero_point_values_per_byte);
5884            let zero_point_word_index = zero_point_byte_count >> 0x2u;
5885            let zero_point_byte_offset = zero_point_byte_count & 0x3u;
5886            let zero_point_sub_offset: u32 = block % zero_point_values_per_byte;
5887            let zero_point_bits_offset = (zero_point_byte_offset << 3) + (zero_point_sub_offset * ${e.bits}u);
5888            let zero_point_word = ${xe.getByOffset("zero_point_word_index")} >> zero_point_bits_offset;
5889            let zero_point = ${ce}((zero_point_word) & ${e.bits===2?"0x3u":"0xFu"});`:`
5890            // The default zero point is ${Math.pow(2,e.bits-1)} for unsigned ${e.bits}-bit quantization.
5891            let zero_point = ${ce}(${Math.pow(2,e.bits-1).toFixed(1)});`}
5892            let scale = ${we.getByOffset("b_row * n_blocks_per_col + block")};
5893            let b_data = ${F.getByIndices(`${F.type.indices}(b_row, block, 0)`)};
5894            var word_offset = local_id.x * ${e.blockSize/p};
5895            for (var i: u32 = 0; i < ${m}; i++) {
5896              let b_value = ${m===1?"b_data":"b_data[i]"};
5897              ${(()=>{let de=Math.floor(E/8),Re="";for(let Se=0;Se<de;Se++){let De=Se*e.bits*4,gt=De+e.bits;Re+=`
5898              ${ie()}
5899              {${e.bits===2?`
5900                let half_word = b_value >> ${Se*16}u;
5901                let byte_lo = half_word & 0xFFu;
5902                let byte_hi = (half_word >> 8u) & 0xFFu;
5903                let spread_word = (byte_lo & 0xFu) | ((byte_lo >> 4u) << 8u) | ((byte_hi & 0xFu) << 16u) | ((byte_hi >> 4u) << 24u);
5904                let b_value_lower = unpack4xU8(spread_word & 0x03030303u);
5905                let b_value_upper = unpack4xU8((spread_word >> 2u) & 0x03030303u);`:`
5906                let b_value_lower = unpack4xU8((b_value >> ${De}u) & 0x0F0F0F0Fu);
5907                let b_value_upper = unpack4xU8((b_value >> ${gt}u) & 0x0F0F0F0Fu);`}
5908                let b_quantized_values = mat2x4<${ce}>(${Array.from({length:4},(yt,xt)=>`${ce}(b_value_lower[${xt}]), ${ce}(b_value_upper[${xt}])`).join(", ")});
5909                let b_dequantized_values = (b_quantized_values - mat2x4<${ce}>(${Array(8).fill("zero_point").join(",")})) * scale;
5910                inter_results[local_id.y][local_id.x] += ${Array.from({length:2},(yt,xt)=>`${`dot(a_data${xt}, b_dequantized_values[${xt}])`}`).join(" + ")};
5911              }
5912              word_offset += ${8/p};`}return Re})()}
5913            }
5914            workgroupBarrier();
5915          }
5916
5917          if (local_idx < ${b}) {
5918            var output_value: ${ve.type.value} = ${ve.type.value}(0);
5919            for (var b = 0u; b < ${S}; b++) {
5920              output_value += inter_results[local_idx][b];
5921            }
5922            if (col + local_idx < uniforms.output_shape[2])
5923            {
5924              ${ve.setByIndices(`${ve.type.indices}(batch, row, col + local_idx)`,"output_value")}
5925            }
5926          }
5927        }`};return{name:"BlockwiseMatMulNBits32",shaderCache:{hint:`${e.blockSize};${p};${m};${S};${b}`,inputDependencies:Array(t.length).fill("rank")},getRunData:()=>({outputs:[{dims:y,dataType:h}],dispatchGroup:{x:L},programUniforms:K}),getShaderSource:G}},Jte=(t,e)=>{KG(t.inputs,e),e.blockSize===32&&t.adapterInfo.isVendor("intel")&&t.adapterInfo.isArchitecture("gen-12lp")?t.compute(XG(t.inputs,e)):t.compute(YG(t.inputs,e))},Qte=t=>Rr(t)}),JG,QG,ZG,e9,t9,n9,s9,r9,Zte,tCe=qt(()=>{ts(),Ts(),Rs(),JG=t=>
vendor: 8,510 bytes, lines 5927-6036
5927{if(!t||t.length<1)throw new Error("Too few inputs");if(t[0].dataType!==1&&t[0].dataType!==10)throw new Error("Input type must be float or float16.");if(t.length>=2){let e=t[0].dims.length*2===t[1].dims[0];if(t.length===4&&(e=t[3].dims[0]*2===t[1].dims[0]),!e)throw new Error("The pads should be a 1D tensor of shape [2 * input_rank] or [2 * num_axes].")}},QG=(t,e,n)=>{let s="";for(let r=e-1;r>=0;--r)s+=`
5928            k = i32(${t.indicesGet("indices",r)}) - ${An("uniforms.pads",r,n)};
5929            if (k < 0) {
5930              break;
5931            }
5932            if (k >= i32(${An("uniforms.x_shape",r,e)})) {
5933              break;
5934            }
5935            offset += k * i32(${An("uniforms.x_strides",r,e)});
5936        `;return`
5937          value = ${t.type.value}(uniforms.constant_value);
5938          for (var i = 0; i < 1; i++) {
5939            var offset = 0;
5940            var k = 0;
5941            ${s}
5942            value = x[offset];
5943          }
5944      `},ZG=(t,e,n)=>{let s="";for(let r=e-1;r>=0;--r)s+=`
5945                k = i32(${t.indicesGet("indices",r)}) - ${An("uniforms.pads",r,n)};
5946                if (k < 0) {
5947                  k = -k;
5948                }
5949                {
5950                  let _2n_1 = 2 * (i32(${An("uniforms.x_shape",r,e)}) - 1);
5951                  k = k % _2n_1;
5952                  if(k >= i32(${An("uniforms.x_shape",r,e)})) {
5953                    k = _2n_1 - k;
5954                  }
5955                }
5956                offset += k * i32(${An("uniforms.x_strides",r,e)});
5957            `;return`
5958              var offset = 0;
5959              var k = 0;
5960              ${s}
5961              value = x[offset];
5962          `},e9=(t,e,n)=>{let s="";for(let r=e-1;r>=0;--r)s+=`
5963                k = i32(${t.indicesGet("indices",r)}) - ${An("uniforms.pads",r,n)};
5964                if (k < 0) {
5965                  k = 0;
5966                }
5967                if (k >= i32(${An("uniforms.x_shape",r,e)})) {
5968                  k = i32(${An("uniforms.x_shape",r,e)}) - 1;
5969                }
5970                offset += k * i32(${An("uniforms.x_strides",r,e)});
5971            `;return`
5972              var offset = 0;
5973              var k = 0;
5974              ${s}
5975              value = x[offset];
5976          `},t9=(t,e,n)=>{let s="";for(let r=e-1;r>=0;--r)s+=`
5977                k = i32(${t.indicesGet("indices",r)}) - ${An("uniforms.pads",r,n)};
5978                if (k < 0)  {
5979                  k += i32(${An("uniforms.x_shape",r,e)}]);
5980                }
5981                if (k >= i32(${An("uniforms.x_shape",r,e)})) {
5982                  k -= i32(${An("uniforms.x_shape",r,e)});
5983                }
5984                offset += k * i32(${An("uniforms.x_strides",r,e)});
5985            `;return`
5986              var offset = 0;
5987              var k = 0;
5988              ${s}
5989              value = x[offset];
5990          `},n9=(t,e,n)=>{switch(n.mode){case 0:return QG(t,e,n.pads.length);case 1:return ZG(t,e,n.pads.length);case 2:return e9(t,e,n.pads.length);case 3:return t9(t,e,n.pads.length);default:throw new Error("Invalid mode")}},s9=(t,e)=>{let n=dt.padShape(t[0].dims.slice(),e.pads),s=t[0].dims,r=dt.size(n),i=[{type:12,data:r},{type:6,data:e.pads}],a=t.length>=3&&t[2].data;e.mode===0&&i.push({type:a?t[2].dataType:1,data:e.value}),i.push(...Mn(t[0].dims,n));let o=["rank"],l=c=>{let h=wn("output",t[0].dataType,n.length),p=St("x",t[0].dataType,s.length),m=p.type.value,y=n9(h,s.length,e),v=[{name:"output_size",type:"u32"},{name:"pads",type:"i32",length:e.pads.length}];return e.mode===0&&v.push({name:"constant_value",type:a?m:"f32"}),`
5991            ${c.registerUniforms(v).declareVariables(p,h)}
5992            ${c.mainStart()}
5993            ${c.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
5994
5995            let indices = ${h.offsetToIndices("global_idx")};
5996
5997            var value = ${m}(0);
5998            ${y}
5999            output[global_idx] = value;
6000        }`};return{name:"Pad",shaderCache:{hint:`${e.mode}${a}`,inputDependencies:o},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(dt.size(n)/64)},programUniforms:i}),getShaderSource:l}},r9=(t,e)=>{if(t.length>1){let n=t[1].getBigInt64Array(),s=t.length>=3&&t[2].data?t[2].dataType===10?t[2].getUint16Array()[0]:t[2].getFloat32Array()[0]:0,r=t[0].dims.length,i=new Int32Array(2*r).fill(0);if(t.length>=4){let o=t[3].getBigInt64Array();for(let l=0;l<o.length;l++)i[Number(o[l])]=Number(n[l]),i[Number(o[l])+r]=Number(n[l+o.length])}else n.forEach((o,l)=>i[Number(l)]=Number(o));let a=[];return i.forEach(o=>a.push(o)),{mode:e.mode,value:s,pads:a}}else return e},Zte=(t,e)=>{JG(t.inputs);let n=r9(t.inputs,e);t.compute(s9(t.inputs,n),{inputs:[0]})}}),H2,$$,D$,O$,L$,i9,a9,j$,B$,ene,tne,U$,nne,sne,F$,rne,ine,ane,one,nCe=qt(()=>{Ad(),ts(),Ts(),Rs(),H2=t=>{if(fi.webgpu.validateInputContent&&(!t||t.length!==1))throw new Error("Pool ops requires 1 input.")},$$=(t,e,n)=>{let s=e.format==="NHWC",r=t.dims.slice();s&&r.splice(1,0,r.pop());let i=Object.hasOwnProperty.call(e,"dilations"),a=e.kernelShape.slice(),o=e.strides.slice(),l=i?e.dilations.slice():[],c=e.pads.slice();lR.adjustPoolAttributes(n,r,a,o,l,c);let h=lR.computePoolOutputShape(n,r,o,l,a,c,e.autoPad),p=Object.assign({},e);i?Object.assign(p,{kernelShape:a,strides:o,pads:c,dilations:l,cacheKey:e.cacheKey}):Object.assign(p,{kernelShape:a,strides:o,pads:c,cacheKey:e.cacheKey});let m=h.slice();return m.push(m.splice(1,1)[0]),[p,s?m:h]},D$=(t,e)=>{let n=e.format==="NHWC",s=dt.size(t),r=dt.size(e.kernelShape),i=[{type:12,data:s},{type:12,data:r}],a=[{name:"outputSize",type:"u32"},{name:"kernelSize",type:"u32"}];if(e.kernelShape.length<=2){let o=e.kernelShape[e.kernelShape.length-1],l=e.strides[e.strides.length-1],c=e.pads[e.pads.length/2-1],h=e.pads[e.pads.length-1],p=!!(c+h);i.push({type:12,data:o},{type:12,data:l},{type:12,data:c},{type:12,data:h}),a.push({name:"kw",type:"u32"},{name:"sw",type:"u32"},{name:"pwStart",type:"u32"},{name:"pwEnd",type:"u32"});let m=!1;if(e.kernelShape.length===2){let y=e.kernelShape[e.kernelShape.length-2],v=e.strides[e.strides.length-2],b=e.pads[e.pads.length/2-2],S=e.pads[e.pads.length-2];m=!!(b+S),i.push({type:12,data:y},{type:12,data:v},{type:12,data:b},{type:12,data:S}),a.push({name:"kh",type:"u32"},{name:"sh",type:"u32"},{name:"phStart",type:"u32"},{name:"phEnd",type:"u32"})}return[i,a,!0,p,m]}else{if(n)throw new Error("Pooling with kernelShape.length > 2 is not supported for NHWC format.");let o=dt.computeStrides(e.kernelShape);i.push({type:12,data:o},{type:12,data:e.pads},{type:12,data:e.strides}),a.push({name:"kernelStrides",type:"u32",length:o.length},{name:"pads",type:"u32",length:e.pads.length},{name:"strides",type:"u32",length:e.strides.length});let l=e.pads.reduce((c,h)=>c+h);return[i,a,!!l,!1,!1]}},O$=(t,e,n,s,r,i,a,o,l,c,h,p)=>{let m=r.format==="NHWC",y=e.type.value,v=wn("output",e.type.tensor,s);if(r.kernelShape.length<=2){let b="",S="",E="",I=n-(m?2:1);if(h?b=`
6001                for (var i: u32 = 0u; i < uniforms.kw; i++) {
6002                  xIndices[${I}] = indices[${I}] * uniforms.sw - uniforms.pwStart + i;
6003                  if (xIndices[${I}] < 0 || xIndices[${I}]
6004                      >= uniforms.x_shape[${I}]) {
6005                    pad++;
6006                    continue;
6007                  }
6008                  let x_val = x[${e.indicesToOffset("xIndices")}];
6009                  ${i}
6010                }`:b=`
6011                for (var i: u32 = 0u; i < uniforms.kw; i++) {
6012                  xIndices[${I}] = indices[${I}] * uniforms.sw - uniforms.pwStart + i;
6013                  let x_val = x[${e.indicesToOffset("xIndices")}];
6014                  ${i}
6015                }`,r.kernelShape.length===2){let M=n-(m?3:2);p?S=`
6016                for (var j: u32 = 0u; j < uniforms.kh; j++) {
6017                  xIndices[${M}] = indices[${M}] * uniforms.sh - uniforms.phStart + j;
6018                  if (xIndices[${M}] < 0 || xIndices[${M}] >= uniforms.x_shape[${M}]) {
6019                    pad += i32(uniforms.kw);
6020                    continue;
6021                  }
6022              `:S=`
6023                for (var j: u32 = 0u; j < uniforms.kh; j++) {
6024                  xIndices[${M}] = indices[${M}] * uniforms.sh - uniforms.phStart + j;
6025                `,E=`
6026              }
6027            `}return`
6028            ${t.registerUniforms(l).declareVariables(e,v)}
6029
6030            ${t.mainStart()}
6031              ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
6032
6033              let indices = ${v.offsetToIndices("global_idx")};
6034              var xIndices = ${v.offsetToIndices("global_idx")};
6035
6036              var value = ${y}(${o}
6036);
6037              var pad = 0;
6038              ${S}
6039              ${b}
6040              ${E}
6041              ${a}
6042
6043              output[global_idx] = value;
6044            }`}else{if(m)throw new Error("Pooling with kernelShape.length > 2 is not supported for NHWC format.");let b=r.kernelShape.length,S=r.pads.length,E="";return c?E=`
6045                if (xIndices[j] >= uniforms.x_shape[j]) {
6046                  pad++;
6047                  isPad = true;
6048                  break;
6049                }
6050              }
6051              if (!isPad) {
6052                let x_val = x[${e.indicesToOffset("xIndices")}];
6053                ${i}
6054              }`:E=`
6055              }
6056              let x_val = x[${e.indicesToOffset("xIndices")}];
6057              ${i}
6058            `,`
6059            ${t.registerUniforms(l).declareVariables(e,v)}
6060
6061            ${t.mainStart()}
6062              ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
6063              let indices = ${v.offsetToIndices("global_idx")};
6064              var xIndices = ${v.offsetToIndices("global_idx")};
6065
6066              var offsets: array<u32, ${b}>;
6067
6068              var value = ${y}(${o});
6069              var pad = 0;
6070              var isPad = false;
6071
6072              for (var i: u32 = 0u; i < uniforms.kernelSize; i++) {
6073                var offset = i;
6074                for (var j = 0u; j < ${b-1}u; j++) {
6075                  offsets[j] = offset / ${An("uniforms.kernelStrides","j",b)};
6076                  offset -= offsets[j] * ${An("uniforms.kernelStrides","j",b)};
6077                }
6078                offsets[${b-1}] = offset;
6079
6080                isPad = false;
6081                for (var j = ${n-b}u; j < ${n}u; j++) {
6082                  xIndices[j] = indices[j] * ${An("uniforms.strides",`j - ${n-b}u`,b)}
6083                    + offsets[j - ${n-b}u] - ${An("uniforms.pads","j - 2u",S)};
6084                  ${E}
6085              }
6086              ${a}
6087
6088              output[global_idx] = value;
6089            }`}},L$=t=>`${t.format};${t.ceilMode};${t.autoPad};${t.kernelShape.length}`,i9=t=>`${L$(t)};${t.countIncludePad}`,a9=t=>`${L$(t)};${t.storageOrder};${t.dilations}`,j$=t=>({format:t.format,autoPad:["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][t.auto_pad],ceilMode:t.ceil_mode,kernelShape:t.kernel_shape,strides:t.strides,pads:t.pads}),B$=(t,e,n,s)=>{let[r,i]=$$(e,s,n),a=St("x",e.dataType,e.dims.length),o=a.type.value,l="value += x_val;",c="";r.countIncludePad?c+=`value /= ${o}(uniforms.kernelSize);`:c+=`value /= ${o}(i32(uniforms.kernelSize) - pad);`;let[h,p,m,y,v]=D$(i,r);h.push(...Mn(e.dims,i));let b=["rank"];return{name:t,shaderCache:{hint:`${s.cacheKey};${m};${y};${v}`,inputDependencies:b},getRunData:()=>({outputs:[{dims:i,dataType:e.dataType}],dispatchGroup:{x:Math.ceil(dt.size(i)/64)},programUniforms:h}),getShaderSource:S=>O$(S,a,e.dims.length,i.length,r,l,c,0,p,m,y,v)}},ene=t=>{let e=t.count_include_pad!==0,n=j$(t);if(n.ceilMode!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");let s={countIncludePad:e,...n,cacheKey:""};return{...s,cacheKey:i9(s)}},tne=(t,e)=>{H2(t.inputs),t.compute(B$("AveragePool",t.inputs[0],!1,e))},U$={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[]},nne=t=>{let e=t.format;return{format:e,...U$,cacheKey:e}},sne=(t,e)=>{H2(t.inputs),t.compute(B$("GlobalAveragePool",t.inputs[0],!0,e))},F$=(t,e,n,s)=>{let[r,i]=$$(e,s,n),a=`
6090      value = max(x_val, value);
6091    `,o="",l=St("x",e.dataType,e.dims.length),c=["rank"],[h,p,m,y,v]=D$(i,r);return h.push(...Mn(e.dims,i)),{name:t,shaderCache:{hint:`${s.cacheKey};${m};${y};${v}`,inputDependencies:c},getRunData:()=>({outputs:[{dims:i,dataType:e.dataType}],dispatchGroup:{x:Math.ceil(dt.size(i)/64)},programUniforms:h}),getShaderSource:b=>O$(b,l,e.dims.length,i.length,r,a,o,e.dataType===10?-65504:-1e5,p,m,y,v)}},rne=(t,e)=>{H2(t.inputs),t.compute(F$("MaxPool",t.inputs[0],!1,e))},ine=t=>{let e=t.storage_order,n=t.dilations,s=j$(t);if(e!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(s.ceilMode!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");let r={storageOrder:e,dilations:n,...s,cacheKey:""};return{...r,cacheKey:a9(r)}},ane=t=>{let e=t.format;return{format:e,...U$,cacheKey:e}},one=(t,e)=>{H2(t.inputs),t.compute(F$("GlobalMaxPool",t.inputs[0],!0,e))}}),o9,l9,lne,cne,sCe=qt(()=>{ts(),Ts(),na(),Rs(),o9=(t,e)=>{if(t.length<2||t.length>3)throw new Error("DequantizeLinear requires 2 or 3 inputs.");if(t.length===3&&t[1].dims===t[2].dims)throw new Error("x-scale and x-zero-point must have the same shape.");if(t.length===3&&t[0].dataType!==t[2].dataType)throw new Error("x and x-zero-point must have the same data type.");if(t[1].dims.length!==0&&t[1].dims.length!==1&&t[1].dims.length!==t[0].dims.length)throw new Error("scale input must be a scalar, a 1D tensor, or have the same rank as the input tensor.");if(t.length>2){if(t[0].dataType!==t[2].dataType)throw new Error("x and x-zero-point must have the same data type.");if(t[1].dims.length!==t[2].dims.length)throw new Error("scale and zero-point inputs must have the same rank.");
vendor: 19,271 bytes, lines 6091-6288
6091if(!t[1].dims.map((n,s)=>n===t[2].dims[s]).reduce((n,s)=>n&&s,!0))throw new Error("scale and zero-point inputs must have the same shape.")}if(e.blockSize>0){if(t[1].dims.length===0||t[1].dims.length===1&&t[1].dims[0]===1)throw new Error("blockSize must be set only for block quantization.");if(!t[1].dims.map((r,i)=>i===e.axis||r===t[0].dims[i]).reduce((r,i)=>r&&i,!0))throw new Error("For block qunatization, scale input shape to match the input shape except for the axis");if(t[1].dims.length!==t[0].dims.length)throw new Error("For block qunatization the scale input rank must be the same as the x rank.");let n=t[0].dims[e.axis],s=t[1].dims[e.axis];if(e.blockSize<Math.ceil(n/s)||e.blockSize>Math.ceil(n/(s-1)-1))throw new Error("blockSize must be with in the range [ceil(dI / Si), ceil(dI / (Si - 1) - 1)].")}},l9=(t,e)=>{let n=dt.normalizeAxis(e.axis,t[0].dims.length),s=t[0].dataType,r=s===3,i=t[0].dims,a=t[1].dataType,o=dt.size(i),l=s===3||s===2,c=l?[Math.ceil(dt.size(t[0].dims)/4)]:t[0].dims,h=t[1].dims,p=t.length>2?t[2]:void 0,m=p?l?[Math.ceil(dt.size(p.dims)/4)]:p.dims:void 0,y=h.length===0||h.length===1&&h[0]===1,v=y===!1&&h.length===1,b=Wi(o),S=y&&(!l||b===4),E=S?b:1,I=S&&!l?b:1,M=St("input",l?12:s,c.length,I),j=St("scale",a,h.length),L=p?St("zero_point",l?12:s,m.length):void 0,K=wn("output",a,i.length,E),D=[M,j];L&&D.push(L);let R=[c,h];p&&R.push(m);let B=[{type:12,data:o/E},{type:12,data:n},{type:12,data:e.blockSize},...Mn(...R,i)],G=X=>{let H=[{name:"output_size",type:"u32"},{name:"axis",type:"u32"},{name:"block_size",type:"u32"}];return`
6092      ${X.registerUniforms(H).declareVariables(...D,K)}
6093      ${X.mainStart()}
6094          ${X.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
6095          let output_indices = ${K.offsetToIndices("global_idx")};
6096
6097          // Set input x
6098          ${l?`
6099            let input = ${M.getByOffset("global_idx / 4")};
6100            let x_vec = ${r?"unpack4xI8(input)":"unpack4xU8(input)"};
6101            let x_value = ${E===1?"x_vec[global_idx % 4]":"x_vec"};`:`let x_value = ${M.getByOffset("global_idx")};`};
6102
6103          // Set scale input
6104          ${y?`let scale_value= ${j.getByOffset("0")}`:v?`
6105            let scale_index = ${K.indicesGet("output_indices","uniforms.axis")};
6106            let scale_value= ${j.getByOffset("scale_index")};`:`
6107            var scale_indices: ${j.type.indices} = output_indices;
6108            let index = ${j.indicesGet("scale_indices","uniforms.axis")} / uniforms.block_size;
6109            ${j.indicesSet("scale_indices","uniforms.axis","index")};
6110            let scale_value= ${j.getByIndices("scale_indices")};`};
6111
6112          // Set zero-point input
6113          ${L?y?l?`
6114                let zero_point_input = ${L.getByOffset("0")};
6115                let zero_point_vec =  ${r?"unpack4xI8(zero_point_input)":"unpack4xU8(zero_point_input)"};
6116                let zero_point_value= zero_point_vec[0]`:`let zero_point_value = ${L.getByOffset("0")}`:v?l?`
6117                let zero_point_index = ${K.indicesGet("output_indices","uniforms.axis")};
6118                let zero_point_input = ${L.getByOffset("zero_point_index / 4")};
6119                let zero_point_vec =  ${r?"unpack4xI8(zero_point_input)":"unpack4xU8(zero_point_input)"};
6120                let zero_point_value = zero_point_vec[zero_point_index % 4]`:`
6121                let zero_point_index = ${K.indicesGet("output_indices","uniforms.axis")};
6122                let zero_point_value = ${L.getByOffset("zero_point_index")};`:l?`
6123                let zero_point_offset = ${j.indicesToOffset("scale_indices")};
6124                let zero_point_input = ${L.getByOffset("zero_point_offset / 4")};
6125                let zero_point_vec = ${r?"unpack4xI8(zero_point_input)":"unpack4xU8(zero_point_input)"};
6126                let zero_point_value = zero_point_vec[zero_point_offset % 4];`:`let zero_point_value = ${L.getByIndices("scale_indices")};`:`let zero_point_value = ${l?r?"i32":"u32":M.type.value}(0);`};
6127      // Compute and write output
6128      ${K.setByOffset("global_idx",`${K.type.value}(x_value - zero_point_value) * scale_value`)};
6129      }`};return{name:"DequantizeLinear",shaderCache:{hint:e.cacheKey,inputDependencies:L?["rank","rank","rank"]:["rank","rank"]},getShaderSource:G,getRunData:()=>({outputs:[{dims:i,dataType:a}],dispatchGroup:{x:Math.ceil(o/E/64),y:1,z:1},programUniforms:B})}},lne=(t,e)=>{o9(t.inputs,e),t.compute(l9(t.inputs,e))},cne=t=>Rr({axis:t.axis,blockSize:t.blockSize})}),c9,u9,une,rCe=qt(()=>{Ad(),ts(),Rs(),c9=(t,e,n)=>{let s=t===e,r=t<e&&n<0,i=t>e&&n>0;if(s||r||i)throw new Error("Range these inputs' contents are invalid.")},u9=(t,e,n,s)=>{let r=Math.abs(Math.ceil((e-t)/n)),i=[r],a=r,o=[{type:12,data:a},{type:s,data:t},{type:s,data:n},...Mn(i)],l=c=>{let h=wn("output",s,i.length),p=h.type.value,m=[{name:"outputSize",type:"u32"},{name:"start",type:p},{name:"delta",type:p}];return`
6130        ${c.registerUniforms(m).declareVariables(h)}
6131        ${c.mainStart()}
6132        ${c.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
6133        output[global_idx] = uniforms.start + ${p}(global_idx) * uniforms.delta;
6134      }`};return{name:"Range",shaderCache:{hint:`${s}`},getShaderSource:l,getRunData:()=>({outputs:[{dims:i,dataType:s}],dispatchGroup:{x:Math.ceil(a/64)},programUniforms:o})}},une=t=>{let e=0,n=0,s=0;t.inputs[0].dataType===6?(e=t.inputs[0].getInt32Array()[0],n=t.inputs[1].getInt32Array()[0],s=t.inputs[2].getInt32Array()[0]):t.inputs[0].dataType===1&&(e=t.inputs[0].getFloat32Array()[0],n=t.inputs[1].getFloat32Array()[0],s=t.inputs[2].getFloat32Array()[0]),fi.webgpu.validateInputContent&&c9(e,n,s),t.compute(u9(e,n,s,t.inputs[0].dataType),{inputs:[]})}}),d9,h9,dne,hne,iCe=qt(()=>{ts(),Ts(),na(),Rs(),d9=(t,e,n,s)=>{if(t!=="none"&&s!=="i32"&&s!=="u32"&&s!=="f32")throw new Error(`Input ${s} is not supported with reduction ${t}.`);let r=`{
6135                var oldValue = 0;
6136                loop {
6137                  let newValueF32 =`,i=`;
6138                  let newValue = bitcast<i32>(newValueF32);
6139                  let res = atomicCompareExchangeWeak(&${e}, oldValue, newValue);
6140                  if res.exchanged {
6141                    break;
6142                  }
6143                  oldValue = res.old_value;
6144                }
6145              }`;switch(t){case"none":return`${e}=${n};`;case"add":return s==="i32"||s==="u32"?`atomicAdd(&${e}, bitcast<${s}>(${n}));`:`
6146              ${r}bitcast<${s}>(oldValue) + (${n})${i}`;case"max":return s==="i32"||s==="u32"?`atomicMax(&${e}, bitcast<${s}>(${n}));`:`
6147                ${r}max(bitcast<f32>(oldValue), (${n}))${i}`;case"min":return s==="i32"||s==="u32"?`atomicMin(&${e}, bitcast<${s}>(${n}));`:`${r}min(bitcast<${s}>(oldValue), (${n}))${i}`;case"mul":return`${r}(bitcast<${s}>(oldValue) * (${n}))${i}`;default:throw new Error(`Reduction ${t} is not supported.`)}},h9=(t,e)=>{let n=t[0].dims,s=t[1].dims,r=n,i=1,a=Math.ceil(dt.sizeToDimension(s,s.length-1)/i),o=s[s.length-1],l=dt.sizeFromDimension(n,o),c=[{type:12,data:a},{type:12,data:o},{type:12,data:l},...Mn(t[1].dims,t[2].dims,r)],h=p=>{let m=St("indices",t[1].dataType,t[1].dims.length),y=St("updates",t[2].dataType,t[2].dims.length,i),v=e.reduction!=="none"&&e.reduction!==""?UZ("output",t[0].dataType,r.length):wn("output",t[0].dataType,r.length,i);return`
6148      ${p.registerUniform("output_size","u32").registerUniform("last_index_dimension","u32").registerUniform("num_updates_elements","u32").declareVariables(m,y,v)}
6149      ${p.mainStart()}
6150        ${p.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
6151  var data_offset = 0u;
6152  let indices_start = uniforms.last_index_dimension * global_idx;
6153  let indices_end = indices_start + uniforms.last_index_dimension;
6154  for (var i = indices_start; i < indices_end; i++) {
6155    var index = i32(indices[i].x);
6156    ${t[0].dims.length===1?`
6157    let element_count_dim = uniforms.output_strides;
6158    let dim_value = uniforms.output_shape;`:`
6159    let element_count_dim = uniforms.output_strides[i - indices_start];
6160    let dim_value = uniforms.output_shape[i - indices_start];`}
6161    if (index >= 0) {
6162      if (index >= i32(dim_value)) {
6163        index = i32(dim_value - 1);
6164      }
6165    } else {
6166      if (index < -i32(dim_value)) {
6167        index = 0;
6168      } else {
6169        index += i32(dim_value);
6170      }
6171    }
6172    data_offset += u32((u32(index) * element_count_dim));
6173  }
6174
6175  for (var i = 0u; i < uniforms.num_updates_elements; i++) {
6176    let value = updates[uniforms.num_updates_elements * global_idx + i];
6177    ${d9(e.reduction,"output[data_offset + i]","value",v.type.value)}
6178  }
6179
6180      }`};return{name:"ScatterND",shaderCache:{hint:`${e.cacheKey}_${e.reduction}`,inputDependencies:["rank","rank"]},getRunData:()=>({outputs:[{dims:r,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(a/64)},programUniforms:c}),getShaderSource:h}},dne=t=>Rr({reduction:t.reduction}),hne=(t,e)=>{t.compute(h9(t.inputs,e),{inputs:[t.inputs[1],t.inputs[2]],outputs:[]})}}),f9,p9,m9,V$,g9,y9,x9,v9,b9,w9,_9,S9,z$,E9,T9,A9,C9,k9,fne,pne,aCe=qt(()=>{ts(),Ts(),na(),Rs(),f9=(t,e)=>{if(t.every(n=>n>0||(()=>{throw new Error("Resize requires scales input values to be positive")})),t.length>0){if(e.mode==="linear"){if(!(t.length===2||t.length===3||t.length===4&&t[0]===1&&t[1]===1||t.length===4&&t[0]===1&&t[3]===1||t.length===5&&t[0]===1&&t[1]===1))throw new Error(`For linear mode, Resize requires scales to be 2D, 3D, 4D with either two outermost or one innermost and
6181            one outermost scale values equal to 1, or 5D with two outermost scale values equal to 1`)}else if(e.mode==="cubic"&&!(t.length===2||t.length===4&&t[0]===1&&t[1]===1||t.length===4&&t[0]===1&&t[3]===1))throw new Error("Resize requires scales input size to be 2 or 4 for cubic mode")}},p9=(t,e,n)=>{e.every(r=>r>=0&&r<n||(()=>{throw new Error("Resize requires axes input values to be positive and less than rank")}));let s=new Array(n).fill(1);return e.forEach((r,i)=>s[r]=t[i]),s},m9=(t,e,n,s,r,i)=>{let[a,o,l]=n>10?[1,2,3]:[-1,t.length>1?1:-1,-1],c=t[0].dims.length;if(a>0&&t.length>a&&t[a].dims.length>0)t[a].getFloat32Array().forEach(h=>i.push(h));else if(e.coordinateTransformMode==="tf_crop_and_resize")throw new Error("Resize requires RoI input to be specified when coordinateTransformMode is tfCropAndResize");if(o>0&&t.length>o&&t[o].dims.length===1&&t[o].dims[0]>0){if(t[o].getFloat32Array().forEach(h=>s.push(h)),s.length!==0&&s.length!==c&&n>=18&&s.length!==e.axes.length)throw new Error("Resize requires scales input size to be same as input rank or axes size for opset 18 and up");f9(s,e),e.axes.length>0&&p9(s,e.axes,c).forEach((h,p)=>s[p]=h)}if(l>0&&t.length>l&&t[l].dims.length===1&&t[l].dims[0]>0&&(t[l].getBigInt64Array().forEach(h=>r.push(Number(h))),r.length!==0&&r.length!==c&&n>=18&&r.length!==e.axes.length))throw new Error("Resize requires sizes input size to be same as input rank or axes size for opset 18 and up");if(e.axes.length>0){if(s.length!==0&&s.length!==e.axes.length)throw new Error('Resize requires "scales" input size to be of axes rank when axes attributes is specified');if(r.length!==0&&r.length!==e.axes.length)throw new Error('Resize requires "sizes" input size to be of rank axes rank when axes attributes is specified')}if(typeof s<"u"&&typeof r<"u"&&s.length>0&&r.length>c)throw new Error("Resize requires only of scales or sizes to be specified")},V$=(t,e,n,s)=>`
6182  // The whole part and the fractional part are calculated separately due to inaccuracy of floating
6183  // point division. As an example, f32(21) / f32(7) may evaluate to 2.99... instead of 3, causing an
6184  // offset-by-one error later in floor().
6185  let big = (${t}) * (${e});
6186  let whole = ${s}(big / (${n}));
6187  let fract = ${s}(big % (${n})) / ${s}(${n});
6188  return whole + fract;
6189`,g9=(t,e)=>`fn getOriginalCoordinateFromResizedCoordinate(xResized: u32, xScale: f32, lengthResized: u32,
6190     lengthOriginal: u32, roiStart: f32, roiEnd: f32) -> ${e} { `+(()=>{switch(t){case"asymmetric":return`
6191          if (xScale < 1.0 || floor(xScale) != xScale) {
6192            return ${e}(xResized) / ${e}(xScale);
6193          } else {
6194            ${V$("xResized","lengthOriginal","lengthResized",e)}
6195          }
6196        `;case"pytorch_half_pixel":return`if (lengthResized > 1) {
6197                    return (${e}(xResized) + 0.5) / ${e}(xScale) - 0.5;
6198                  } else {
6199                    return 0.0;
6200                  }`;case"tf_half_pixel_for_nn":return`return (${e}(xResized) + 0.5) / ${e}(xScale);`;case"align_corners":return`if (lengthResized == 1) {
6201                    return 0.0;
6202                  } else {
6203                    ${V$("xResized","lengthOriginal - 1","lengthResized - 1",e)}
6204                  }`;case"tf_crop_and_resize":return`if (lengthResized > 1) {
6205                    return ${e}(roiStart) * ${e}(lengthOriginal - 1) +
6206                        (${e}(xResized) * ${e}(roiEnd - roiStart) * ${e}(lengthOriginal - 1)) /
6207                        ${e}(lengthResized - 1);
6208                  } else {
6209                    return 0.5 * ${e}(roiStart + roiEnd) * ${e}(lengthOriginal - 1);
6210                  }`;case"half_pixel_symmetric":return`const outputWidth = ${e}xScale * ${e}(lengthResized);
6211                  const adjustment = ${e}(lengthResized) / outputWidth;
6212                  const center = ${e}(lengthOriginal) / 2;
6213                  const offset = center * (1 - adjustment);
6214                  return offset + ((${e}(xResized) + 0.5) / ${e}(xScale)) - 0.5;`;case"half_pixel":return`return ((${e}(xResized) + 0.5) / ${e}(xScale)) - 0.5;`;default:throw new Error(`Coordinate transform mode ${t} is not supported`)}})()+"}",y9=(t,e,n)=>`fn getNearestPixelFromOriginal(xOriginal: ${n}, isDownSample: bool) -> ${n} {`+(()=>{switch(t){case"round_prefer_ceil":return"if (fract(xOriginal) == 0.5) {             return ceil(xOriginal);           } else {             return round(xOriginal);           }";case"floor":return"return floor(xOriginal);";case"ceil":return"return ceil(xOriginal);";case"round_prefer_floor":return"if (fract(xOriginal) == 0.5) {                     return floor(xOriginal);                   } else {                     return round(xOriginal);                   }";case"simple":default:if(e<11)return"if (isDownSample)                     {                       return ceil(xOriginal);                     } else {                       return xOriginal;                     }";throw new Error(`Nearest mode ${t} is not supported`)}})()+"}",x9=(t,e,n)=>{let s=new Array(n).fill(0).concat(new Array(n).fill(1)),r=t.length===0?s:t.slice();return e.length>0?(e.forEach((i,a)=>{s[i]=r[a],s[a+n]=r[e.length+a]}),s):r},v9=(t,e,n,s)=>{let r=[];if(n.length>0)if(s.length>0){if(t.forEach(i=>r.push(i)),Math.max(...s)>t.length)throw new Error("axes is out of bound");s.forEach((i,a)=>r[i]=n[a])}else n.forEach(i=>r.push(i));else{if(e.length===0)throw new Error("Resize requires either scales or sizes.");r=t.map((i,a)=>Math.round(i*e[a]))}return r},b9=(t,e,n)=>{let s=(()=>{switch(n.keepAspectRatioPolicy){case"not_larger":return n.axes.length>0?Math.min(...n.axes.map(i=>e[i]),Number.MAX_VALUE):Math.min(...e,Number.MAX_VALUE);case"not_smaller":return n.axes.length>0?Math.max(...n.axes.map(i=>e[i]),Number.MIN_VALUE):Math.max(...e,Number.MIN_VALUE);default:throw new Error(`Keep aspect ratio policy ${n.keepAspectRatioPolicy} is not supported`)}})();e.fill(1,0,e.length);let r=t.slice();return n.axes.length>0?(n.axes.forEach(i=>e[i]=s),n.axes.forEach(i=>r[i]=Math.round(t[i]*e[i]))):(e.fill(s,0,e.length),r.forEach((i,a)=>r[a]=Math.round(i*e[a]))),r},w9=(t,e,n,s,r)=>`
6215    fn calculateOriginalIndicesFromOutputIndices(output_indices: ${t.type.indices}) -> array<${t.type.value}, ${n.length}> {
6216      var original_indices: array<${t.type.value}, ${n.length}>;
6217      for (var i:u32 = 0; i < ${n.length}; i++) {
6218        var output_index = ${t.indicesGet("output_indices","i")};
6219        var scale = ${An("uniforms.scales","i",s)};
6220        var roi_low = ${An("uniforms.roi","i",r)};
6221        var roi_hi = ${An("uniforms.roi",`i + ${e.length}`,r)};
6222        if (scale == 1.0) {
6223          original_indices[i] = ${t.type.value}(output_index);
6224        } else {
6225          var input_shape_i = ${An("uniforms.input_shape","i",e.length)};
6226          var output_shape_i = ${An("uniforms.output_shape","i",n.length)};
6227          original_indices[i] = getOriginalCoordinateFromResizedCoordinate(output_index, scale, output_shape_i,
6228                                                                           input_shape_i, roi_low, roi_hi);
6229        }
6230      }
6231      return original_indices;
6232    }`,_9=(t,e,n,s,r,i,a)=>`
6233    fn calculateInputIndicesFromOutputIndices(output_indices: ${e.type.indices}) -> ${t.type.indices} {
6234      var input_indices: ${t.type.indices};
6235      for (var i:u32 = 0; i < ${s.length}; i++) {
6236        var output_index = ${e.indicesGet("output_indices","i")};
6237        var input_index: u32;
6238        var scale = ${An("uniforms.scales","i",r)};
6239        if (scale == 1.0) {
6240          input_index = output_index;
6241        } else {
6242          var roi_low = ${An("uniforms.roi","i",i)};
6243          var roi_hi = ${An("uniforms.roi",`i + ${n.length}`,i)};
6244          var input_shape_i = ${An("uniforms.input_shape","i",n.length)};
6245          var output_shape_i = ${An("uniforms.output_shape","i",s.length)};
6246          var original_idx = getOriginalCoordinateFromResizedCoordinate(output_index, scale, output_shape_i,
6247                                                                        input_shape_i, roi_low, roi_hi);
6248          if (!${a} || (original_idx >= 0 && original_idx < ${e.type.value}(input_shape_i))) {
6249            if (original_idx < 0) {
6250              input_index = 0;
6251            } else if (original_idx > ${e.type.value}(input_shape_i - 1)) {
6252              input_index = input_shape_i - 1;
6253            } else {
6254              input_index = u32(getNearestPixelFromOriginal(original_idx, scale < 1));
6255            }
6256          } else {
6257            input_index = u32(original_idx);
6258          }
6259        }
6260        ${t.indicesSet("input_indices","i","input_index")}
6261      }
6262      return input_indices;
6263    }`,S9=(t,e)=>`
6264    fn checkInputIndices(input_indices: ${t.type.indices}) -> bool {
6265      for (var i:u32 = 0; i < ${e.length}; i++) {
6266        var input_index = ${t.indicesGet("input_indices","i")};
6267        if (input_index < 0 || input_index >= ${An("uniforms.input_shape","i",e.length)}) {
6268          return false;
6269        }
6270      }
6271      return true;
6272    }`,z$=(t,e,n,s)=>t.rank>s?`
6273    ${t.indicesSet("input_indices",e,"channel")};
6274    ${t.indicesSet("input_indices",n,"batch")};
6275`:"",E9=(t,e,n,s,r)=>{let[i,a,o,l]=n.length===2?[-1,0,1,-1]:[0,2,3,1],c=t.type.value;return`
6276    fn getInputValue(batch: u32, channel: u32, row: u32, col: u32) -> ${c} {
6277      var input_indices: ${t.type.indices};
6278      ${t.indicesSet("input_indices",a,`max(0, min(row, ${n[a]} - 1))`)};
6279      ${t.indicesSet("input_indices",o,`max(0, min(col, ${n[o]} - 1))`)};
6280      ${z$(t,l,i,2)}
6281      return ${t.getByIndices("input_indices")};
6282    }
6283
6284    fn bilinearInterpolation(output_indices: ${e.type.indices}) -> ${c} {
6285      var originalIndices = calculateOriginalIndicesFromOutputIndices(output_indices);
6286      var row:${c} = originalIndices[${a}];
6287      var col:${c} = originalIndices[${o}];
6288      ${s?`if (row < 0 || row > (${n[a]}
vendor: 6,877 bytes, lines 6288-6423
6288 - 1) || col < 0 || col > (${n[o]} - 1)) {
6289        return ${r};
6290      }`:""};
6291      row = max(0, min(row, ${n[a]} - 1));
6292      col = max(0, min(col, ${n[o]} - 1));
6293      var row1: u32 = u32(row);
6294      var col1: u32 = u32(col);
6295      var row2: u32 = u32(row + 1);
6296      var col2: u32 = u32(col + 1);
6297      var channel: u32 = ${n.length>2?`u32(originalIndices[${l}])`:"0"};
6298      var batch: u32 =  ${n.length>2?`u32(originalIndices[${i}])`:"0"};
6299      var x11: ${c} = getInputValue(batch, channel, row1, col1);
6300      var x12: ${c} = getInputValue(batch, channel, row1, col2);
6301      var x21: ${c} = getInputValue(batch, channel, row2, col1);
6302      var x22: ${c} = getInputValue(batch, channel, row2, col2);
6303      var dx1: ${c} = abs(row - ${c}(row1));
6304      var dx2: ${c} = abs(${c}(row2) - row);
6305      var dy1: ${c} = abs(col - ${c}(col1));
6306      var dy2: ${c} = abs(${c}(col2) - col);
6307      if (row1 == row2) {
6308        dx1 = 0.5;
6309        dx2 = 0.5;
6310      }
6311      if (col1 == col2) {
6312        dy1 = 0.5;
6313        dy2 = 0.5;
6314      }
6315      return (x11 * dx2 * dy2 + x12 * dx2 * dy1 + x21 * dx1 * dy2 + x22 * dx1 * dy1);
6316    }`},T9=(t,e,n,s,r,i,a,o,l,c)=>{let h=n.length===2,[p,m]=h?[0,1]:[2,3],y=t.type.value,v=b=>{let S=b===p?"row":"col";return`
6317      fn ${S}CubicInterpolation(input_indices: ${t.type.indices}, output_indices: ${e.type.indices}) -> ${y} {
6318        var output_index = ${e.indicesGet("output_indices",b)};
6319        var originalIdx: ${y} = getOriginalCoordinateFromResizedCoordinate(output_index, ${r[b]},
6320        ${s[b]}, ${n[b]}, ${i[b]}, ${i[b]} + ${n.length});
6321        var fractOriginalIdx: ${y} = originalIdx - floor(originalIdx);
6322        var coefs = getCubicInterpolationCoefs(fractOriginalIdx);
6323
6324        if (${o} && (originalIdx < 0 || originalIdx > (${n[b]} - 1))) {
6325          return ${l};
6326        }
6327        var data: array<${y}, 4> = array<${y}, 4>(0.0, 0.0, 0.0, 0.0);
6328        for (var i: i32 = -1; i < 3; i++) {
6329          var ${S}: ${y} = originalIdx + ${y}(i);
6330          if (${S} < 0 || ${S} >= ${n[b]}) {
6331            ${c?`coefs[i + 1] = 0.0;
6332                        continue;`:o?`return ${l};`:`${S} = max(0, min(${S}, ${n[b]} - 1));`};
6333          }
6334        var input_indices_copy: ${t.type.indices} = input_indices;
6335          ${t.indicesSet("input_indices_copy",b,`u32(${S})`)};
6336          data[i + 1] = ${b===p?t.getByIndices("input_indices_copy"):"rowCubicInterpolation(input_indices_copy, output_indices)"};
6337        }
6338        return cubicInterpolation1D(data, coefs);
6339      }`};return`
6340    ${v(p)};
6341    ${v(m)};
6342  fn getCubicInterpolationCoefs(s: ${y}) -> array<${y}, 4> {
6343    var absS = abs(s);
6344    var coeffs: array<${y}, 4> = array<${y}, 4>(0.0, 0.0, 0.0, 0.0);
6345    var oneMinusAbsS: ${y} = 1.0 - absS;
6346    var twoMinusAbsS: ${y} = 2.0 - absS;
6347    var onePlusAbsS: ${y} = 1.0 + absS;
6348    coeffs[0] = ((${a} * onePlusAbsS - 5 * ${a}) * onePlusAbsS + 8 * ${a}) * onePlusAbsS - 4 * ${a};
6349    coeffs[1] = ((${a} + 2) * absS - (${a} + 3)) * absS * absS + 1;
6350    coeffs[2] = ((${a} + 2) * oneMinusAbsS - (${a} + 3)) * oneMinusAbsS * oneMinusAbsS + 1;
6351    coeffs[3] = ((${a} * twoMinusAbsS - 5 * ${a}) * twoMinusAbsS + 8 * ${a}) * twoMinusAbsS - 4 * ${a};
6352    return coeffs;
6353  }
6354
6355  fn cubicInterpolation1D(x: array<${y}, 4>, coefs: array<${y}, 4>) -> ${y} {
6356    var coefsSum: ${y} = coefs[0] + coefs[1] + coefs[2] + coefs[3];
6357    return (x[0] * coefs[0] + x[1] * coefs[1]+ x[2] * coefs[2]+ x[3] * coefs[3]) / coefsSum;
6358  }
6359
6360  fn bicubicInterpolation(output_indices: ${e.type.indices}) -> ${y} {
6361    var input_indices: ${t.type.indices} = output_indices;
6362    return colCubicInterpolation(input_indices, output_indices);
6363  }
6364    `},A9=(t,e,n,s,r)=>{let[i,a,o,l,c]=n.length===3?[-1,0,1,2,-1]:[0,2,3,4,1],h=t.type.value;return`
6365    fn getInputValue(batch: u32, channel: u32, depth:u32, height: u32, width: u32) -> ${h} {
6366      var input_indices: ${t.type.indices};
6367      ${t.indicesSet("input_indices",a,`max(0, min(depth, ${n[a]} - 1))`)};
6368      ${t.indicesSet("input_indices",o,`max(0, min(height, ${n[o]} - 1))`)};
6369      ${t.indicesSet("input_indices",l,`max(0, min(width, ${n[l]} - 1))`)};
6370      ${z$(t,c,i,3)}
6371      return ${t.getByIndices("input_indices")};
6372    }
6373
6374    fn trilinearInterpolation(output_indices: ${e.type.indices}) -> ${h} {
6375      var originalIndices = calculateOriginalIndicesFromOutputIndices(output_indices);
6376      var depth:${h} = originalIndices[${a}];
6377      var height:${h} = originalIndices[${o}];
6378      var width:${h} = originalIndices[${l}];
6379      ${s?`if (depth < 0 || depth > (${n[a]} - 1) || height < 0 || height > (${n[o]} - 1) || width < 0 || (width > ${n[l]} - 1)) {
6380      return ${r};
6381        }`:""};
6382
6383    depth = max(0, min(depth, ${n[a]} - 1));
6384      height = max(0, min(height, ${n[o]} - 1));
6385      width = max(0, min(width, ${n[l]} - 1));
6386      var depth1: u32 = u32(depth);
6387      var height1: u32 = u32(height);
6388      var width1: u32 = u32(width);
6389      var depth2: u32 = u32(depth + 1);
6390      var height2: u32 = u32(height + 1);
6391      var width2: u32 = u32(width + 1);
6392      var channel: u32 = ${n.length>3?`u32(originalIndices[${c}])`:"0"};
6393      var batch: u32 =  ${n.length>3?`u32(originalIndices[${i}])`:"0"};
6394
6395      var x111: ${h} = getInputValue(batch, channel, depth1, height1, width1);
6396      var x112: ${h} = getInputValue(batch, channel, depth1, height1, width2);
6397      var x121: ${h} = getInputValue(batch, channel, depth1, height2, width1);
6398      var x122: ${h} = getInputValue(batch, channel, depth1, height2, width2);
6399      var x211: ${h} = getInputValue(batch, channel, depth2, height1, width1);
6400      var x212: ${h} = getInputValue(batch, channel, depth2, height1, width2);
6401      var x221: ${h} = getInputValue(batch, channel, depth2, height2, width1);
6402      var x222: ${h} = getInputValue(batch, channel, depth2, height2, width2);
6403      var dx1: ${h} = abs(depth - ${h}(depth1));
6404      var dx2: ${h} = abs(${h}(depth2) - depth);
6405      var dy1: ${h} = abs(height - ${h}(height1));
6406      var dy2: ${h} = abs(${h}(height2) - height);
6407      var dz1: ${h} = abs(width - ${h}(width1));
6408      var dz2: ${h} = abs(${h}(width2) - width);
6409      if (depth1 == depth2) {
6410        dx1 = 0.5;
6411        dx2 = 0.5;
6412      }
6413      if (height1 == height2) {
6414        dy1 = 0.5;
6415        dy2 = 0.5;
6416      }
6417      if (width1 == width2) {
6418        dz1 = 0.5;
6419        dz2 = 0.5;
6420      }
6421      return (x111 * dx2 * dy2 * dz2 + x112 * dx2 * dy2 * dz1 + x121 * dx2 * dy1 *dz2 + x122 * dx2 * dy1 * dz1 +
6422              x211 * dx1 * dy2 * dz2 + x212 * dx1 * dy2 * dz1 + x221 * dx1 * dy1 *dz2 + x222 * dx1 * dy1 * dz1);
6423    }`},C9=(t,e,n,s,r,i)=>{let a=t.dims,o=x9(i,e.axes,a.length),l=v9(a,s,r,e.axes),c=s.slice();s.length===0&&(c=a.map((I,M)=>I===0?1:l[M]/I),e.keepAspectRatioPolicy!=="stretch"&&(l=b9(a,c,e)));let h=wn("output",t.dataType,l.length),p=St("input",t.dataType,a.length),m=dt.size(l),y=a.length===l.length&&a.every((I,M)=>
vendor: 25,535 bytes, lines 6423-6647
6423I===l[M]),v=e.coordinateTransformMode==="tf_crop_and_resize",b=e.extrapolationValue,S=p.type.value,E=I=>`
6424      ${y?"":`
6425      ${g9(e.coordinateTransformMode,S)};
6426      ${(()=>{switch(e.mode){case"nearest":return`
6427              ${S9(p,a)};
6428              ${y9(e.nearestMode,n,S)};
6429              ${_9(p,h,a,l,c.length,o.length,v)};
6430              `;case"linear":return`
6431              ${w9(h,a,l,c.length,o.length)};
6432              ${(()=>{if(a.length===2||a.length===4)return`${E9(p,h,a,v,b)}`;if(a.length===3||a.length===5)return`${A9(p,h,a,v,b)}`;throw Error("Linear mode only supports input dims 2, 3, 4 and 5 are supported in linear mode.")})()};
6433            `;case"cubic":return`
6434            ${(()=>{if(a.length===2||a.length===4)return`${T9(p,h,a,l,c,o,e.cubicCoeffA,v,e.extrapolationValue,e.excludeOutside)}`;throw Error("Cubic mode only supports input dims 2 and 4 are supported in linear mode.")})()};
6435            `;default:throw Error("Invalid resize mode")}})()};
6436      `}
6437      ${I.registerUniform("output_size","u32").registerUniform("scales","f32",c.length).registerUniform("roi","f32",o.length).declareVariables(p,h)}
6438      ${I.mainStart()}
6439        ${I.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
6440        ${y?"output[global_idx] = input[global_idx];":`
6441        let output_indices = ${h.offsetToIndices("global_idx")};
6442        var input_indices: ${p.type.indices};
6443        ${(()=>{switch(e.mode){case"nearest":return`input_indices = calculateInputIndicesFromOutputIndices(output_indices);
6444                if (checkInputIndices(input_indices)) {
6445                  output[global_idx] = ${p.getByIndices("input_indices")};
6446                } else {
6447                  output[global_idx] = ${e.extrapolationValue};
6448                }`;case"linear":return`output[global_idx] = ${a.length===2||a.length===4?"bilinearInterpolation":"trilinearInterpolation"}(output_indices);`;case"cubic":return"output[global_idx] = bicubicInterpolation(output_indices);";default:throw Error(`Unsupported resize mode: ${e.mode}`)}})()};
6449`}
6450      }`;return{name:"Resize",shaderCache:{hint:`${e.cacheKey}|${n}|${c.length>0?e.mode==="cubic"?c:c.length:""}|${r.length>0?r:""}|${o.length>0?o:""}|${y}|${e.mode==="nearest"?a.length:a}`,inputDependencies:["rank"]},getShaderSource:E,getRunData:()=>({outputs:[{dims:l,dataType:t.dataType}],dispatchGroup:{x:Math.ceil(m/64)},programUniforms:[{type:12,data:m},{type:1,data:c},{type:1,data:o},...Mn(a,l)]})}},k9=t=>{let e=t.customDataBuffer;return new Uint32Array(e,e.byteOffset,1)[0]},fne=(t,e)=>{let n=[],s=[],r=[],i=k9(t);if(e.antialias!==0)throw Error("Only default value (0) for Antialias attribute is supported");m9(t.inputs,e,i,n,s,r),t.compute(C9(t.inputs[0],e,i,n,s,r),{inputs:[0]})},pne=t=>{let e=t.antialias,n=t.axes,s=t.coordinateTransformMode,r=t.cubicCoeffA,i=t.excludeOutside!==0,a=t.extrapolationValue,o=t.keepAspectRatioPolicy,l=t.mode,c=t.nearestMode===""?"simple":t.nearestMode;return Rr({antialias:e,axes:n,coordinateTransformMode:s,cubicCoeffA:r,excludeOutside:i,extrapolationValue:a,keepAspectRatioPolicy:o,mode:l,nearestMode:c})}}),I9,N9,mne,oCe=qt(()=>{ts(),Ts(),Rs(),I9=t=>{if(!t||t.length<3)throw new Error("layerNorm requires at least 3 inputs.");let e=t[0],n=t[1],s=t[2];if(e.dataType!==n.dataType||e.dataType!==s.dataType)throw new Error("All inputs must have the same data type");if(e.dims.length!==3&&e.dims.length!==2)throw new Error("Input must be 2D or 3D");if(n.dims.length!==3&&n.dims.length!==2)throw new Error("Skip must be 2D or 3D");let r=e.dims[e.dims.length-1],i=e.dims[e.dims.length-2];if(n.dims[n.dims.length-1]!==r)throw new Error("Skip must have the same hidden size as input");if(n.dims[n.dims.length-2]!==i)throw new Error("Skip must have the same sequence length as input");if(s.dims.length!==1)throw new Error("Gamma must be 1D");if(s.dims[s.dims.length-1]!==r)throw new Error("Gamma must have the same hidden size as input");if(t.length>3){let a=t[3];if(a.dims.length!==1)throw new Error("Beta must be 1D");if(a.dims[a.dims.length-1]!==r)throw new Error("Beta must have the same hidden size as input")}if(t.length>4){let a=t[4];if(a.dims.length!==1)throw new Error("Bias must be 1D");if(a.dims[a.dims.length-1]!==r)throw new Error("Bias must have the same hidden size as input")}},N9=(t,e,n,s)=>{let r=e.simplified,i=t[0].dims,a=dt.size(i),o=i,l=a,c=i.slice(-1)[0],h=s?i.slice(0,-1).concat(1):[],p=!r&&t.length>3,m=t.length>4,y=s&&n>1,v=s&&n>2,b=n>3,S=64,E=Wi(c),I=[{type:12,data:l},{type:12,data:E},{type:12,data:c},{type:1,data:e.epsilon}],M=L=>{let K=[{name:"output_size",type:"u32"},{name:"components",type:"u32"},{name:"hidden_size",type:"u32"},{name:"epsilon",type:"f32"}],D=[St("x",t[0].dataType,t[0].dims,E),St("skip",t[1].dataType,t[1].dims,E),St("gamma",t[2].dataType,t[2].dims,E)];p&&D.push(St("beta",t[3].dataType,t[3].dims,E)),m&&D.push(St("bias",t[4].dataType,t[4].dims,E)),D.push(wn("output",t[0].dataType,o,E)),y&&D.push(wn("mean_output",1,h)),v&&D.push(wn("inv_std_output",1,h)),b&&D.push(wn("input_skip_bias_sum",t[0].dataType,o,E));let R=lo(t[0].dataType),B=lo(1,E);return`
6451
6452      ${L.registerUniforms(K).declareVariables(...D)}
6453      var<workgroup> sum_shared : array<${B}, ${S}>;
6454      var<workgroup> sum_squared_shared : array<${B}, ${S}>;
6455
6456      ${L.mainStart([S,1,1])}
6457        let ix = local_id.x;
6458        let iy = global_id.x / ${S};
6459
6460        let hidden_size_vectorized: u32 = uniforms.hidden_size / uniforms.components;
6461        var stride = hidden_size_vectorized / ${S};
6462        let offset = ix * stride + iy * hidden_size_vectorized;
6463        let offset1d = stride * ix;
6464        if (ix == ${S-1}) {
6465          stride = hidden_size_vectorized - stride * ix;
6466        }
6467        for (var i: u32 = 0; i < stride; i++) {
6468          let skip_value = skip[offset + i];
6469          let bias_value = ${m?"bias[offset1d + i]":R+"(0.0)"};
6470          let input_value = x[offset + i];
6471          let value = input_value + skip_value + bias_value;
6472          ${b?"input_skip_bias_sum[offset + i] = value;":""}
6473          output[offset + i] = value;
6474          let f32_value = ${ow(R,E,"value")};
6475          sum_shared[ix] += f32_value;
6476          sum_squared_shared[ix] += f32_value * f32_value;
6477        }
6478        workgroupBarrier();
6479
6480        var reduce_size : u32 = ${S};
6481        for (var curr_size = reduce_size >> 1;  curr_size > 0; curr_size = reduce_size >> 1) {
6482          reduce_size = curr_size + (reduce_size & 1);
6483          if (ix < curr_size) {
6484            sum_shared[ix] += sum_shared[ix + reduce_size];
6485            sum_squared_shared[ix] += sum_squared_shared[ix + reduce_size];
6486          }
6487          workgroupBarrier();
6488        }
6489
6490        let sum = sum_shared[0];
6491        let square_sum = sum_squared_shared[0];
6492        let mean = ${H0("sum",E)} / f32(uniforms.hidden_size);
6493        let inv_std_dev = inverseSqrt(${H0("square_sum",E)} / f32(uniforms.hidden_size) ${r?"":"- mean * mean"} + uniforms.epsilon);
6494        ${y?"mean_output[global_idx] = mean;":""}
6495        ${v?"inv_std_output[global_idx] = inv_std_dev;":""}
6496
6497        for (var i: u32 = 0; i < stride; i++) {
6498          output[offset + i] = (output[offset + i] ${r?"":`- ${R}(mean)`}) *
6499            ${R}(inv_std_dev) * gamma[offset1d + i]
6500            ${p?"+ beta[offset1d + i]":""};
6501        }
6502      }`},j=[{dims:o,dataType:t[0].dataType}];return n>1&&j.push({dims:h,dataType:1}),n>2&&j.push({dims:h,dataType:1}),n>3&&j.push({dims:i,dataType:t[0].dataType}),{name:"SkipLayerNormalization",shaderCache:{hint:`${E};${y};${v};${b}`,inputDependencies:t.map((L,K)=>"type")},getShaderSource:M,getRunData:()=>({outputs:j,dispatchGroup:{x:Math.ceil(l/c)},programUniforms:I})}},mne=(t,e)=>{I9(t.inputs);let n=[0];t.outputCount>1&&n.push(-3),t.outputCount>2&&n.push(-3),t.outputCount>3&&n.push(3),t.compute(N9(t.inputs,e,t.outputCount,!1),{outputs:n})}}),R9,q2,M9,G$,P9,$9,gne,yne,lCe=qt(()=>{ts(),Ts(),na(),Rs(),R9=(t,e)=>{if(!t||t.length<1)throw new Error("too few inputs");if(e.axes.length!==0){if(e.axes.length!==e.starts.length||e.axes.length!==e.ends.length)throw new Error("axes, starts and ends must have the same length")}else if(e.starts.length!==e.ends.length)throw new Error("starts and ends must have the same length");t.slice(1).forEach((n,s)=>{if(t[s+1].dataType!==6&&t[s+1].dataType!==7)throw new Error(`Input ${s} must be an array of int32 or int64`)})},q2=(t,e)=>{let n=[];if(t.length>e)if(t[e].dataType===7)t[e].getBigInt64Array().forEach(s=>n.push(Number(s)));else if(t[e].dataType===6)t[e].getInt32Array().forEach(s=>n.push(Number(s)));else throw new Error(`Input ${e} must be an array of int32 or int64`);return n},M9=(t,e)=>{if(t.length>1){let n=q2(t,1),s=q2(t,2),r=q2(t,3);return r.length===0&&(r=[...Array(t[0].dims.length).keys()]),Rr({starts:n,ends:s,axes:r})}else return e},G$=(t,e,n,s,r)=>{let i=t;return t<0&&(i+=n[s[e]]),r[e]<0?Math.max(0,Math.min(i,n[s[e]]-1)):Math.max(0,Math.min(i,n[s[e]]))},P9=(t,e,n)=>`fn calculateInputIndices(output_indices: ${e.type.indices}) -> ${t.type.indices} {
6503          var input_indices: ${t.type.indices};
6504          var carry = 0u;
6505          for (var i = ${n.length-1}; i >= 0; i--) {
6506            let input_shape_i = ${An("uniforms.input_shape","i",n.length)};
6507            let steps_i = ${An("uniforms.steps","i",n.length)};
6508            let signs_i = ${An("uniforms.signs","i",n.length)};
6509            let starts_i = ${An("uniforms.starts","i",n.length)};
6510            var output_index = ${e.indicesGet("output_indices","i")};
6511            var input_index = output_index * steps_i + starts_i + carry;
6512            carry = input_index / input_shape_i;
6513            input_index = input_index % input_shape_i;
6514            if (signs_i < 0) {
6515              input_index = input_shape_i - input_index - 1u + starts_i;
6516            }
6517            ${t.indicesSet("input_indices","i","input_index")};
6518          }
6519          return input_indices;
6520      }`,$9=(t,e)=>{let n=t[0].dims,s=dt.size(n),r=e.axes.length>0?dt.normalizeAxes(e.axes,n.length):[...Array(n.length).keys()],i=q2(t,4);i.forEach(E=>E!==0||(()=>{throw new Error("step cannot be 0")})),i.length===0&&(i=Array(r.length).fill(1));let a=e.starts.map((E,I)=>G$(E,I,n,r,i)),o=e.ends.map((E,I)=>G$(E,I,n,r,i));if(r.length!==a.length||r.length!==o.length)throw new Error("start, ends and axes should have the same number of elements");if(r.length!==n.length)for(let E=0;E<n.length;++E)r.includes(E)||(a.splice(E,0,0),o.splice(E,0,n[E]),i.splice(E,0,1));let l=i.map(E=>Math.sign(E));i.forEach((E,I,M)=>{if(E<0){let j=(o[I]-a[I])/E,L=a[I],K=L+j*i[I];a[I]=K,o[I]=L,M[I]=-E}});let c=n.slice(0);r.forEach((E,I)=>{c[E]=Math.ceil((o[E]-a[E])/i[E])});let h={dims:c,dataType:t[0].dataType},p=wn("output",t[0].dataType,c.length),m=St("input",t[0].dataType,t[0].dims.length),y=dt.size(c),v=[{name:"outputSize",type:"u32"},{name:"starts",type:"u32",length:a.length},{name:"signs",type:"i32",length:l.length},{name:"steps",type:"u32",length:i.length}],b=[{type:12,data:y},{type:12,data:a},{type:6,data:l},{type:12,data:i},...Mn(t[0].dims,c)],S=E=>`
6521      ${E.registerUniforms(v).declareVariables(m,p)}
6522        ${P9(m,p,n)}
6523        ${E.mainStart()}
6524          ${E.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
6525          let output_indices = ${p.offsetToIndices("global_idx")};
6526          let input_indices = calculateInputIndices(output_indices);
6527          ${p.setByOffset("global_idx",m.getByIndices("input_indices"))}
6528      }`;return{name:"Slice",shaderCache:{hint:`${l.length}_${a.length}_${i.length}`,inputDependencies:["rank"]},getShaderSource:S,getRunData:()=>({outputs:[h],dispatchGroup:{x:Math.ceil(s/64)},programUniforms:b})}},gne=(t,e)=>{R9(t.inputs,e);let n=M9(t.inputs,e);t.compute($9(t.inputs,n),{inputs:[0]})},yne=t=>{let e=t.starts,n=t.ends,s=t.axes;return Rr({starts:e,ends:n,axes:s})}}),D9,O9,xne,vne,cCe=qt(()=>{ts(),Ts(),na(),ty(),Rs(),D9=t=>{if(!t||t.length!==1)throw new Error("Softmax op requires 1 input.")},O9=(t,e)=>{let n=t.inputs[0],s=n.dims,r=dt.size(s),i=s.length,a=dt.normalizeAxis(e.axis,i),o=a<s.length-1,l,c=[];o?(c=Array.from({length:i},(D,R)=>R),c[a]=i-1,c[i-1]=a,l=t.compute(Ru(n,c),{inputs:[n],outputs:[-1]})[0]):l=n;let h=l.dims,p=h[i-1],m=r/p,y=Wi(p),v=p/y,b=64;m===1&&(b=256);let S=(D,R)=>R===4?`max(max(${D}.x, ${D}.y), max(${D}.z, ${D}.w))`:R===2?`max(${D}.x, ${D}.y)`:R===3?`max(max(${D}.x, ${D}.y), ${D}.z)`:D,E=St("x",l.dataType,l.dims,y),I=wn("result",l.dataType,l.dims,y),M=E.type.value,j=lo(l.dataType)==="f32"?`var threadMax = ${M}(-3.4028234663852886e+38f);`:`var threadMax = ${M}(-65504.0h);`,L=D=>`
6529      var<workgroup> rowMaxShared : ${M};
6530      var<workgroup> rowSumShared : ${M};
6531      var<workgroup> threadShared : array<${M}, ${b}>;
6532
6533      fn getValue(row: i32, col: i32, row_stride: i32) -> ${M} {
6534        let index = row * row_stride + col;
6535        return x[index];
6536      }
6537
6538      fn setValue(row: i32, col: i32, row_stride: i32, value: ${M}) {
6539        let index = row * row_stride + col;
6540        result[index] = value;
6541      }
6542      ${D.registerUniform("packedCols","i32").declareVariables(E,I)}
6543      ${D.mainStart(b)}
6544        let gindex = i32(global_idx);
6545        let lindex = i32(local_idx);
6546        const wg = ${b};
6547        let row = gindex / wg;
6548        let cols = uniforms.packedCols;
6549        let row_stride : i32 = uniforms.packedCols;
6550
6551        // find the rows max
6552        ${j}
6553        for (var col = lindex; col < cols; col += wg) {
6554          let value = getValue(row, col, row_stride);
6555          threadMax = max(threadMax, value);
6556        }
6557        if (lindex < cols) {
6558          threadShared[lindex] = threadMax;
6559        }
6560        workgroupBarrier();
6561
6562        var reduceSize = min(cols, wg);
6563        for (var currSize = reduceSize >> 1;  currSize > 0; currSize = reduceSize >> 1) {
6564          reduceSize = currSize + (reduceSize & 1);
6565          if (lindex < currSize) {
6566            threadShared[lindex] = max(threadShared[lindex], threadShared[lindex + reduceSize]);
6567          }
6568          workgroupBarrier();
6569        }
6570        if (lindex == 0) {
6571          rowMaxShared = ${M}(${S("threadShared[0]",y)});
6572        }
6573        workgroupBarrier();
6574
6575        // find the rows sum
6576        var threadSum = ${M}(0.0);
6577        for (var col = lindex; col < cols; col += wg) {
6578          let subExp = exp(getValue(row, col, row_stride) - rowMaxShared);
6579          threadSum += subExp;
6580        }
6581        threadShared[lindex] = threadSum;
6582        workgroupBarrier();
6583
6584        for (var currSize = wg >> 1;  currSize > 0; currSize = currSize >> 1) {
6585          if (lindex < currSize) {
6586            threadShared[lindex] = threadShared[lindex] + threadShared[lindex + currSize];
6587          }
6588          workgroupBarrier();
6589        }
6590        if (lindex == 0) {
6591          rowSumShared = ${M}(${H0("threadShared[0]",y)});
6592        }
6593        workgroupBarrier();
6594
6595        // calculate final value for each element in the row
6596        for (var col = lindex; col < cols; col += wg) {
6597          var value = exp(getValue(row, col, row_stride) - rowMaxShared) / rowSumShared;
6598          // max operation protects against NaN since all values should be >=0
6599          value = max(value, ${M}(0.0));
6600          setValue(row, col, row_stride, value);
6601        }
6602      }`,K=t.compute({name:"Softmax",shaderCache:{hint:`${y};${b}`,inputDependencies:["type"]},getRunData:()=>({outputs:[{dims:h,dataType:l.dataType}],dispatchGroup:{x:m},programUniforms:[{type:6,data:v}]}),getShaderSource:L},{inputs:[l],outputs:[o?-1:0]})[0];o&&t.compute(Ru(K,c),{inputs:[K]})},xne=(t,e)=>{D9(t.inputs),O9(t,e)},vne=t=>Rr({axis:t.axis})}),H$,L9,j9,B9,bne,uCe=qt(()=>{ts(),Ts(),Rs(),H$=t=>Array.from(t.getBigInt64Array(),Number),L9=t=>{if(!t||t.length!==2)throw new Error("Tile requires 2 inputs.");if(t[0].dataType!==1&&t[0].dataType!==10&&t[0].dataType!==6&&t[0].dataType!==12)throw new Error("Tile only support float, float16, int32, and uint32 data types");if(t[1].dataType!==7)throw new Error("Tile `repeats` input should be of int64 data type");if(t[1].dims.length!==1)throw new Error("Tile `repeats` input should be 1-D");if(H$(t[1]).length!==t[0].dims.length)throw new Error("Tile `repeats` input should have same number of elements as rank of input data tensor")},j9=(t,e)=>{let n=[];for(let s=0;s<t.length;++s)n.push(t[s]*e[s]);return n},B9=(t,e)=>{let n=t[0].dims,s=e??H$(t[1]),r=j9(n,s),i=dt.size(r),a=t[0].dataType,o=St("input",a,n.length),l=wn("output",a,r.length),c=h=>`
6603      const inputShape = ${o.indices(...n)};
6604      ${h.registerUniform("output_size","u32").declareVariables(o,l)}
6605      ${h.mainStart()}
6606      ${h.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}
6607      let output_indices = ${l.offsetToIndices("global_idx")};
6608      var input_indices: ${o.type.indices};
6609      for (var i = 0; i < ${n.length}; i++) {
6610        let input_dim_i = ${o.indicesGet("uniforms.input_shape","i")};
6611        let input_dim_value = ${l.indicesGet("output_indices","i")}  % input_dim_i;
6612
6613        ${o.indicesSet("input_indices","i","input_dim_value")}
6614      }
6615      ${l.setByOffset("global_idx",o.getByIndices("input_indices"))}
6616    }`;return{name:"Tile",shaderCache:{hint:`${s}`,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:r,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(i/64)},programUniforms:[{type:12,data:i},...Mn(t[0].dims,r)]}),getShaderSource:c}},bne=t=>{L9(t.inputs),t.compute(B9(t.inputs),{inputs:[0]})}}),U9,F9,wne,dCe=qt(()=>{ts(),Ts(),Rs(),U9=(t,e,n,s,r)=>{let i=wn("output_data",r,n.length,4),a=St("a_data",e[1].dataType,e[1].dims.length,4),o=St("b_data",e[2].dataType,e[2].dims.length,4),l=St("c_data",e[0].dataType,e[0].dims.length,4),c,h=(p,m,y)=>`select(${m}, ${p}, ${y})`;if(!s)c=i.setByOffset("global_idx",h(a.getByOffset("global_idx"),o.getByOffset("global_idx"),l.getByOffset("global_idx")));else{let p=(m,y,v="")=>{let b=`a_data[index_a${y}][component_a${y}]`,S=`b_data[index_b${y}][component_b${y}]`,E=`bool(c_data[index_c${y}] & (0xffu << (component_c${y} * 8)))`;return`
6617            let output_indices${y} = ${i.offsetToIndices(`global_idx * 4u + ${y}u`)};
6618            let offset_a${y} = ${a.broadcastedIndicesToOffset(`output_indices${y}`,i)};
6619            let offset_b${y} = ${o.broadcastedIndicesToOffset(`output_indices${y}`,i)};
6620            let offset_c${y} = ${l.broadcastedIndicesToOffset(`output_indices${y}`,i)};
6621            let index_a${y} = offset_a${y} / 4u;
6622            let index_b${y} = offset_b${y} / 4u;
6623            let index_c${y} = offset_c${y} / 4u;
6624            let component_a${y} = offset_a${y} % 4u;
6625            let component_b${y} = offset_b${y} % 4u;
6626            let component_c${y} = offset_c${y} % 4u;
6627            ${m}[${y}] = ${v}(${h(b,S,E)});
6628          `};r===9?c=`
6629            var data = vec4<u32>(0);
6630            ${p("data",0,"u32")}
6631            ${p("data",1,"u32")}
6632            ${p("data",2,"u32")}
6633            ${p("data",3,"u32")}
6634            output_data[global_idx] = dot(vec4<u32>(0x1, 0x100, 0x10000, 0x1000000), vec4<u32>(data));`:c=`
6635            ${p("output_data[global_idx]",0)}
6636            ${p("output_data[global_idx]",1)}
6637            ${p("output_data[global_idx]",2)}
6638            ${p("output_data[global_idx]",3)}
6639          `}return`
6640        ${t.registerUniform("vec_size","u32").declareVariables(l,a,o,i)}
6641        ${t.mainStart()}
6642        ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}
6643        ${c}
6644      }`},F9=t=>{let e=t[1].dims,n=t[2].dims,s=t[0].dims,r=t[1].dataType,i=!(dt.areEqual(e,n)&&dt.areEqual(n,s)),a=e,o=dt.size(e);if(i){let c=q1.calcShape(q1.calcShape(e,n,!1),s,!1);if(!c)throw new Error("Can't perform where op on the given tensors");a=c,o=dt.size(a)}let l=Math.ceil(o/4);return{name:"Where",shaderCache:{inputDependencies:["rank","rank","rank"]},getShaderSource:c=>U9(c,t,a,i,r),getRunData:()=>({outputs:[{dims:a,dataType:r}],dispatchGroup:{x:Math.ceil(o/64/4)},programUniforms:[{type:12,data:l},...Mn(s,e,n,a)]})}},wne=t=>{t.compute(F9(t.inputs))}}),_ne,hCe=qt(()=>{AAe(),X7(),CAe(),kAe(),IAe(),NAe(),RAe(),OAe(),jAe(),BAe(),UAe(),FAe(),VAe(),zAe(),GAe(),HAe(),qAe(),WAe(),KAe(),YAe(),XAe(),JAe(),QAe(),ZAe(),eCe(),Fte(),tCe(),nCe(),sCe(),rCe(),iCe(),Y7(),aCe(),qte(),oCe(),lCe(),cCe(),Gte(),uCe(),ty(),J7(),dCe(),_ne=new Map([["Abs",[mee]],["Acos",[gee]],["Acosh",[yee]],["Add",[Jee]],["ArgMax",[dee,XD]],["ArgMin",[uee,XD]],["Asin",[xee]],["Asinh",[vee]],["Atan",[bee]],["Atanh",[wee]],["Attention",[hee]],["AveragePool",[tne,ene]],["BatchNormalization",[fee]],["BiasAdd",[pee]],["BiasSplitGelu",[Xee]],["Cast",[See,_ee]],["Ceil",[Tee]],["Clip",[Eee]],["Concat",[ote,lte]],["Conv",[n5,t5]],["ConvTranspose",[xte,yte]],["Cos",[Aee]],["Cosh",[Cee]],["CumSum",[vte,bte]],["DepthToSpace",[wte,_te]],["DequantizeLinear",[lne,cne]],["Div",[Qee]],["Einsum",[Ste,Ete]],["Elu",[kee,dS]],["Equal",[Zee]],["Erf",[Iee]],["Exp",[Nee]],["Expand",[Tte]],["FastGelu",[Ate]],["Floor",[Ree]],["FusedConv",[n5,t5]],["Gather",[kte,Cte]],["GatherElements",[$te,Pte]],["GatherBlockQuantized",[Rte,Mte]],["GatherND",[Ite,Nte]],["Gelu",[Mee]],["Gemm",[Ote,Dte]],["GlobalAveragePool",[sne,nne]],["GlobalMaxPool",[one,ane]],["Greater",[ste]],["GreaterOrEqual",[ite]],["GridSample",[Lte,jte]],["GroupQueryAttention",[Wte]],["HardSigmoid",[Uee,Bee]],["InstanceNormalization",[Kte]],["LayerNormalization",[Yte]],["LeakyRelu",[Pee,dS]],["Less",[rte]],["LessOrEqual",[ate]],["Log",[Kee]],["MatMul",[Xte]],["MatMulNBits",[Jte,Qte]],["MaxPool",[rne,ine]],["Mul",[ete]],["MultiHeadAttention",[Ute,Bte]],["Neg",[Dee]],["Not",[$ee]],["Pad",[Zte]],["Pow",[tte]],["QuickGelu",[Yee,dS]],["Range",[une]],["Reciprocal",[Oee]],["ReduceMin",[iee]],["ReduceMean",[eee]],["ReduceMax",[ree]],["ReduceSum",[oee]],["ReduceProd",[aee]],["ReduceL1",[tee]],["ReduceL2",[nee]],["ReduceLogSum",[cee]],["ReduceLogSumExp",[see]],["ReduceSumSquare",[lee]],["Relu",[Lee]],["Resize",[fne,pne]],["RotaryEmbedding",[Hte]],["ScatterND",[hne,dne]],["Sigmoid",[jee]],["Sin",[Fee]],["Sinh",[Vee]],["Slice",[gne,yne]],["SkipLayerNormalization",[mne]],["Split",[Vte,zte]],["Sqrt",[zee]],["Softmax",[xne,vne]],["Sub",[nte]],["Tan",[Gee]],["Tanh",[Hee]],["ThresholdedRelu",[Wee,dS]],["Tile",[bne]],["Transpose",[VZ,zZ]],["Where",[wne]]])}),Sne,fCe=qt(()=>{Ad(),zm(),Rs(),Sne=class{constructor(t){this.backend=t,this.repo=new Map,this.attributesBound=!1}getArtifact(t){return this.repo.get(t)}setArtifact(t,e){this.repo.set(t,e)}run(t,e,n,s,r){yp(t.programInfo.name);let i=this.backend.device,a=this.backend.getComputePassEncoder();this.backend.writeTimestamp(this.backend.pendingDispatchNumber*2);let o=[];for(let c of e)o.push({binding:o.length,resource:{buffer:c.buffer}});for(let c of n)o.push({binding:o.length,resource:{buffer:c.buffer}});r&&o.push({binding:o.length,resource:r});let l=i.createBindGroup({layout:t.computePipeline.getBindGroupLayout(0),entries:o,label:t.programInfo.name});if(this.backend.sessionStatus==="capturing"){let c={kernelId:this.backend.currentKernelId,computePipeline:t.computePipeline,bindGroup:l,dispatchGroup:s};this.backend.capturedCommandList.get(this.backend.currentSessionId).push(c)}a.setPipeline(t.computePipeline),a.setBindGroup(0,l),a.dispatchWorkgroups(...s),this.backend.writeTimestamp(this.backend.pendingDispatchNumber*2+1),this.backend.pendingDispatchNumber++,(this.backend.pendingDispatchNumber>=this.backend.maxDispatchNumber||this.backend.queryType==="at-passes")&&this.backend.endComputePass(),this.backend.pendingDispatchNumber>=this.backend.maxDispatchNumber&&this.backend.flush(),Kh(t.programInfo.name)}dispose(){}build(t,e){yp(t.name);let n=this.backend.device,s=[];[{feature:"shader-f16",extension:"f16"},{feature:"subgroups",extension:"subgroups"}].forEach(c=>{n.features.has(c.feature)&&s.push(`enable ${c.extension};`)});let r=FZ(e,this.backend.device.limits),i=t.getShaderSource(r),a=`${s.join(`
6645`)}
6646${r.additionalImplementations}
6647${i}`,o=n.createShaderModule({code:a,label:t.name});cr("verbose",()=>`[WebGPU] ${t.name} shader code: ${a}`);let l=n.createComputePipeline({compute:{module:o,entryPoint:"main"},layout:"auto",label:t.name});return Kh(t.name),{programInfo:t,computePipeline:l,uniformVariablesInfo:r.variablesInfo}}normalizeDispatchGroupSize(t){let e=typeof t=="number"?t:t.x,n=typeof t=="number"?1:t.y||1,s=typeof t=="number"?1:t.z||1,r=this.backend.device.limits.maxComputeWorkgroupsPerDimension;if(e<=r&&n<=r&&s<=r)return[e,n,s];let i=e*n*s,a=Math.ceil(Math.sqrt(i));if(a>r){if(a=Math.ceil(Math.cbrt(i)),a>r)throw new Error("Total dispatch size exceeds WebGPU maximum.");return[a,a,a]}else return[a,a,1]}}}),Ene={};i_(Ene,{WebGpuBackend:()=>Tne});var V9,z9,G9,Tne,pCe=qt(()=>{Ad(),ts(),zm(),OZ(),EAe(),hCe(),fCe(),V9=(t,e)=>{if(e.length!==t.length)throw new Error(`inputDependencies length ${e.length} is not equal to inputTensors length ${t.length}.`);let n=[];for(let s=0;s<t.length;++s){let r=t[s].dataType;switch(e[s]){case"none":{n.push("");break}case"type":{n.push(`${r}`);break}case"rank":{let i=t[s].dims.length;n.push(`${r};${i}`);break}case"dims":{let i=t[s].dims.join(",");n.push(`${r};${i}`);break}default:throw new Error(`unsupported input dependency: ${e[s]}`)}}return n.join("|")},z9=(t,e,n)=>{var r,i;let s=t.name;return(r=t.shaderCache)!=null&&r.hint&&(s+="["+t.shaderCache.hint+"]"),s+=":"+n+`:${V9(e,((i=t.shaderCache)==null?void 0:i.inputDependencies)??new Array(e.length).fill("dims"))}`,s},G9=class{constructor(t){t&&(this.architecture=t.architecture,this.vendor=t.vendor)}isArchitecture(t){return this.architecture===t}isVendor(t){return this.vendor===t}},Tne=class{constructor(){this.currentSessionId=null,this.currentKernelId=null,this.commandEncoder=null,this.computePassEncoder=null,this.maxDispat
vendor: 1,542 bytes, line 6647
6647chNumber=16,this.pendingDispatchNumber=0,this.pendingKernels=[],this.pendingQueries=new Map,this.sessionStatus="default",this.capturedCommandList=new Map,this.capturedPendingKernels=new Map,this.sessionExternalDataMapping=new Map}get currentKernelCustomData(){if(this.currentKernelId===null)throw new Error("currentKernelCustomData(): currentKernelId is null. (should not happen)");let t=this.kernelCustomData.get(this.currentKernelId);return t||(t={},this.kernelCustomData.set(this.currentKernelId,t)),t}async initialize(t,e){this.env=t;let n=[],s={requiredLimits:{maxComputeWorkgroupStorageSize:e.limits.maxComputeWorkgroupStorageSize,maxComputeWorkgroupsPerDimension:e.limits.maxComputeWorkgroupsPerDimension,maxStorageBufferBindingSize:e.limits.maxStorageBufferBindingSize,maxBufferSize:e.limits.maxBufferSize,maxComputeInvocationsPerWorkgroup:e.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupSizeX:e.limits.maxComputeWorkgroupSizeX,maxComputeWorkgroupSizeY:e.limits.maxComputeWorkgroupSizeY,maxComputeWorkgroupSizeZ:e.limits.maxComputeWorkgroupSizeZ},requiredFeatures:n},r=i=>e.features.has(i)&&n.push(i)&&!0;r("chromium-experimental-timestamp-query-inside-passes")||r("timestamp-query"),r("shader-f16"),r("subgroups"),this.device=await e.requestDevice(s),this.adapterInfo=new G9(e.info||await e.requestAdapterInfo()),this.gpuDataManager=BZ(this),this.programManager=new Sne(this),this.kernels=new Map,this.kernelPersistentData=new Map,this.kernelCustomData=new Map,H7(t.logLevel,!!t.debug),this.device.onuncapturederror=i=>
6647{i.error instanceof GPUValidationError&&console.error(`An uncaught WebGPU validation error was raised: ${i.error.message}`)},Object.defineProperty(this.env.webgpu,"device",{value:this.device,writable:!1,enumerable:!0,configurable:!0}),Object.defineProperty(this.env.webgpu,"adapter",{value:e,writable:!1,enumerable:!0,configurable:!1}),this.setQueryType()}dispose(){var t;typeof this.querySet<"u"&&this.querySet.destroy(),this.gpuDataManager.dispose(),this.device&&((t=this.env)!=null&&t.webgpu)&&this.device.lost.then(()=>{delete this.env.webgpu.device})}getCommandEncoder(){return this.commandEncoder||(this.commandEncoder=this.device.createCommandEncoder()),this.commandEncoder}getComputePassEncoder(){if(!this.computePassEncoder){let t=this.getCommandEncoder(),e={};this.queryType==="at-passes"&&(e.timestampWrites={querySet:this.querySet,beginningOfPassWriteIndex:this.pendingDispatchNumber*2,endOfPassWriteIndex:this.pendingDispatchNumber*2+1}),this.computePassEncoder=t.beginComputePass(e)}return this.computePassEncoder}endComputePass(){this.computePassEncoder&&(this.computePassEncoder.end(),this.computePassEncoder=null)}flush(){if(!this.commandEncoder)return;yp(),this.endComputePass();let t;this.queryType!=="none"&&(this.commandEncoder.resolveQuerySet(this.querySet,0,this.pendingDispatchNumber*2,this.queryResolveBuffer,0),t=this.device.createBuffer({size:this.pendingDispatchNumber*2*8,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),this.pendingQueries.set(t,this.pendingKernels),this.pendingKernels=[],this.commandEncoder.copyBufferToBuffer(this.queryResolveBuffer,0,t,0,this.pendingDispatchNumber*2*8)),this.device.queue.submit([this.commandEncoder.finish()]),this.gpuDataManager.refreshPendingBuffers(),this.commandEncoder=null,this.pendingDispatchNumber=0,this.queryType!=="none"&&t.mapAsync(GPUMapMode.READ).then(()=>{var s;let e=new BigUint64Array(t.getMappedRange()),n=this.pendingQueries.get(t);for(let r=0;r<e.length/2;r++){let i=n[r],a=i.kernelId,o=this.kernels.get(a),l=o.kernelType,c=o.kernelName,h=i.programName,p=i.inputTensorViews,m=i.outputTensorViews,y=e[r*2],v=e[r*2+1];typeof this.queryTimeBase>"u"&&(this.queryTimeBase=y);let b=Number(y-this.queryTimeBase),S=Number(v-this.queryTimeBase);if(!Number.isSafeInteger(b)||!Number.isSafeInteger(S))throw new RangeError("incorrect timestamp range");if((s=this.env.webgpu.profiling)!=null&&s.ondata)this.env.webgpu.profiling.ondata({version:1,inputsMetadata:p.map(E=>({dims:E.dims,dataType:Em(E.dataType)})),outputsMetadata:m.map(E=>
vendor: 20,942 bytes, line 6647
6647({dims:E.dims,dataType:Em(E.dataType)})),kernelId:a,kernelType:l,kernelName:c,programName:h,startTime:b,endTime:S});else{let E="";p.forEach((M,j)=>{E+=`input[${j}]: [${M.dims}] | ${Em(M.dataType)}, `});let I="";m.forEach((M,j)=>{I+=`output[${j}]: [${M.dims}] | ${Em(M.dataType)}, `}),console.log(`[profiling] kernel "${a}|${l}|${c}|${h}" ${E}${I}start time: ${b} ns, execution time: ${S-b} ns`)}rR("GPU",`${h}::${y}::${v}`)}t.unmap(),this.pendingQueries.delete(t)}),Kh()}run(t,e,n,s,r,i){yp(t.name);let a=[];for(let I=0;I<e.length;++I){let M=e[I].data;if(M===0)continue;let j=this.gpuDataManager.get(M);if(!j)throw new Error(`no GPU data for input: ${M}`);a.push(j)}let{outputs:o,dispatchGroup:l,programUniforms:c}=t.getRunData(e),h=n.length===0?o.map((I,M)=>M):n;if(h.length!==o.length)throw new Error(`Output size ${h.length} must be equal to ${o.length}.`);let p=[],m=[];for(let I=0;I<o.length;++I){if(!Number.isInteger(h[I])||h[I]<-3||h[I]>=i)throw new Error(`Invalid output index: ${h[I]}`);if(h[I]===-3)continue;let M=h[I]===-1,j=h[I]===-2,L=M||j?r(o[I].dataType,o[I].dims):s(h[I],o[I].dataType,o[I].dims);if(p.push(L),L.data===0)continue;let K=this.gpuDataManager.get(L.data);if(!K)throw new Error(`no GPU data for output: ${L.data}`);if(M&&this.temporaryData.push(K),j){let D=this.kernelPersistentData.get(this.currentKernelId);D||(D=[],this.kernelPersistentData.set(this.currentKernelId,D)),D.push(K)}m.push(K)}if(a.length!==e.length||m.length!==p.length){if(m.length===0)return Kh(t.name),p;throw new Error(`Program ${t.name} has zero-sized tensor(s) in inputs or outputs. This is not supported now.`)}let y;if(c){let I=0,M=[];c.forEach(D=>{let R=typeof D.data=="number"?[D.data]:D.data;if(R.length===0)return;let B=D.type===10?2:4,G,X;D.type===10?(X=R.length>4?16:R.length>2?8:R.length*B,G=R.length>4?16:B*R.length):(X=R.length<=2?R.length*B:16,G=16),I=Math.ceil(I/X)*X,M.push(I);let H=D.type===10?8:4;I+=R.length>4?Math.ceil(R.length/H)*G:R.length*B});let j=16;I=Math.ceil(I/j)*j;let L=new ArrayBuffer(I);c.forEach((D,R)=>{let B=M[R],G=typeof D.data=="number"?[D.data]:D.data;if(D.type===6)new Int32Array(L,B,G.length).set(G);else if(D.type===12)new Uint32Array(L,B,G.length).set(G);else if(D.type===10)new Uint16Array(L,B,G.length).set(G);else if(D.type===1)new Float32Array(L,B,G.length).set(G);else throw new Error(`Unsupported uniform type: ${Em(D.type)}`)});let K=this.gpuDataManager.create(I,GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM);this.device.queue.writeBuffer(K.buffer,0,L,0,I),this.gpuDataManager.release(K.id),y={offset:0,size:I,buffer:K.buffer}}let v=this.programManager.normalizeDispatchGroupSize(l),b=v[1]===1&&v[2]===1,S=z9(t,e,b),E=this.programManager.getArtifact(S);if(E||(E=this.programManager.build(t,v),this.programManager.setArtifact(S,E),cr("info",()=>`[artifact] key: ${S}, programName: ${t.name}`)),c&&E.uniformVariablesInfo){if(c.length!==E.uniformVariablesInfo.length)throw new Error(`Uniform variables count mismatch: expect ${E.uniformVariablesInfo.length}, got ${c.length} in program "${E.programInfo.name}".`);for(let I=0;I<c.length;I++){let M=c[I],j=M.type,L=typeof M.data=="number"?1:M.data.length,[K,D]=E.uniformVariablesInfo[I];if(j!==K||L!==D)throw new Error(`Uniform variable ${I} mismatch: expect type ${K} with size ${D}, got type ${j} with size ${L} in program "${E.programInfo.name}".`)}}if(cr("info",()=>`[ProgramManager] run "${t.name}" (key=${S}) with ${v[0]}x${v[1]}x${v[2]}`),this.queryType!=="none"||this.sessionStatus==="capturing"){let I={kernelId:this.currentKernelId,programName:E.programInfo.name,inputTensorViews:e,outputTensorViews:p};this.pendingKernels.push(I),this.sessionStatus==="capturing"&&this.capturedPendingKernels.get(this.currentSessionId).push(I)}return this.programManager.run(E,a,m,v,y),Kh(t.name),p}upload(t,e){this.gpuDataManager.upload(t,e)}memcpy(t,e){this.gpuDataManager.memcpy(t,e)}async download(t,e){await this.gpuDataManager.download(t,e)}alloc(t){return this.gpuDataManager.create(t).id}free(t){return this.gpuDataManager.release(t)}createKernel(t,e,n,s){let r=_ne.get(t);if(!r)throw new Error(`kernel not implemented: ${t}`);let i={kernelType:t,kernelName:s,kernelEntry:r[0],attributes:[r[1],n]};this.kernels.set(e,i)}releaseKernel(t){let e=this.kernelPersistentData.get(t);if(e){for(let n of e)this.gpuDataManager.release(n.id);this.kernelPersistentData.delete(t)}this.kernelCustomData.delete(t),this.kernels.delete(t)}computeKernel(t,e,n){let s=this.kernels.get(t);if(!s)throw new Error(`kernel not created: ${t}`);let r=s.kernelType,i=s.kernelName,a=s.kernelEntry,o=s.attributes;if(this.currentKernelId!==null)throw new Error(`kernel "[${r}] ${i}" is not allowed to be called recursively`);this.currentKernelId=t,o[0]&&(o[1]=o[0](o[1]),o[0]=void 0),cr("info",()=>`[WebGPU] Start to run kernel "[${r}] ${i}"...`);let l=this.env.debug;this.temporaryData=[];try{return l&&this.device.pushErrorScope("validation"),a(e,o[1]),0}catch(c){return n.push(Promise.resolve(`[WebGPU] Kernel "[${r}] ${i}" failed. ${c}`)),1}finally{l&&n.push(this.device.popErrorScope().then(c=>c?`GPU validation error for kernel "[${r}] ${i}": ${c.message}`:null));for(let c of this.temporaryData)this.gpuDataManager.release(c.id);this.temporaryData=[],this.currentKernelId=null}}registerBuffer(t,e,n,s){let r=this.sessionExternalDataMapping.get(t);r||(r=new Map,this.sessionExternalDataMapping.set(t,r));let i=r.get(e),a=this.gpuDataManager.registerExternalBuffer(n,s,i);return r.set(e,[a,n]),a}unregisterBuffers(t){let e=this.sessionExternalDataMapping.get(t);e&&(e.forEach(n=>this.gpuDataManager.unregisterExternalBuffer(n[0])),this.sessionExternalDataMapping.delete(t))}getBuffer(t){let e=this.gpuDataManager.get(t);if(!e)throw new Error(`no GPU data for buffer: ${t}`);return e.buffer}createDownloader(t,e,n){return async()=>{let s=await WD(this,t,e);return q7(s.buffer,n)}}writeTimestamp(t){this.queryType==="inside-passes"&&this.computePassEncoder.writeTimestamp(this.querySet,t)}setQueryType(){var t;this.queryType="none",(((t=this.env.webgpu.profiling)==null?void 0:t.mode)==="default"||(typeof this.env.trace>"u"?this.env.wasm.trace:this.env.trace))&&(this.device.features.has("chromium-experimental-timestamp-query-inside-passes")?this.queryType="inside-passes":this.device.features.has("timestamp-query")&&(this.queryType="at-passes"),this.queryType!=="none"&&typeof this.querySet>"u"&&(this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxDispatchNumber*2}),this.queryResolveBuffer=this.device.createBuffer({size:this.maxDispatchNumber*2*8,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.QUERY_RESOLVE})))}captureBegin(){cr("info","captureBegin"),this.capturedCommandList.get(this.currentSessionId)||this.capturedCommandList.set(this.currentSessionId,[]),this.capturedPendingKernels.get(this.currentSessionId)||this.capturedPendingKernels.set(this.currentSessionId,[]),this.flush(),this.sessionStatus="capturing"}captureEnd(){cr("info","captureEnd"),this.flush(),this.sessionStatus="default"}replay(){cr("info","replay"),this.sessionStatus="replaying";let t=this.capturedCommandList.get(this.currentSessionId),e=this.capturedPendingKernels.get(this.currentSessionId),n=t.length;this.pendingKernels=[];for(let s=0;s<n;s++){let r=this.getComputePassEncoder(),i=t[s];this.writeTimestamp(this.pendingDispatchNumber*2),r.setPipeline(i.computePipeline),r.setBindGroup(0,i.bindGroup),r.dispatchWorkgroups(...i.dispatchGroup),this.writeTimestamp(this.pendingDispatchNumber*2+1),this.pendingDispatchNumber++,this.queryType!=="none"&&this.pendingKernels.push(e[s]),(this.pendingDispatchNumber>=this.maxDispatchNumber||this.queryType==="at-passes")&&this.endComputePass(),this.pendingDispatchNumber>=this.maxDispatchNumber&&this.flush()}this.flush(),this.sessionStatus="default"}onCreateSession(){this.gpuDataManager.onCreateSession()}onReleaseSession(t){this.unregisterBuffers(t),this.capturedCommandList.has(t)&&this.capturedCommandList.delete(t),this.capturedPendingKernels.has(t)&&this.capturedPendingKernels.delete(t),this.gpuDataManager.onReleaseSession(t)}onRunStart(t){this.currentSessionId=t,this.setQueryType()}}}),Ane={};i_(Ane,{init:()=>Cne});var Jk,H9,Cne,mCe=qt(()=>{ts(),zm(),Ts(),SAe(),Jk=class kne{constructor(e,n,s,r){this.module=e,this.dataType=n,this.data=s,this.dims=r}getFloat32Array(){if(this.dataType!==1)throw new Error("Invalid data type");let e=dt.size(this.dims);return e===0?new Float32Array:new Float32Array(this.module.HEAP8.buffer,this.data,e)}getBigInt64Array(){if(this.dataType!==7)throw new Error("Invalid data type");let e=dt.size(this.dims);return e===0?new BigInt64Array:new BigInt64Array(this.module.HEAP8.buffer,this.data,e)}getInt32Array(){if(this.dataType!==6)throw new Error("Invalid data type");let e=dt.size(this.dims);return e===0?new Int32Array:new Int32Array(this.module.HEAP8.buffer,this.data,e)}getUint16Array(){if(this.dataType!==10&&this.dataType!==4)throw new Error("Invalid data type");let e=dt.size(this.dims);return e===0?new Uint16Array:new Uint16Array(this.module.HEAP8.buffer,this.data,e)}reshape(e){if(dt.size(e)!==dt.size(this.dims))throw new Error("Invalid new shape");return new kne(this.module,this.dataType,this.data,e)}},H9=class{constructor(t,e,n){this.module=t,this.backend=e,this.customDataOffset=0,this.customDataSize=0,this.adapterInfo=e.adapterInfo;let s=t.PTR_SIZE,r=n/t.PTR_SIZE,i=s===4?"i32":"i64";this.opKernelContext=Number(t.getValue(s*r++,i));let a=Number(t.getValue(s*r++,i));this.outputCount=Number(t.getValue(s*r++,i)),this.customDataOffset=Number(t.getValue(s*r++,"*")),this.customDataSize=Number(t.getValue(s*r++,i));let o=[];for(let l=0;l<a;l++){let c=Number(t.getValue(s*r++,i)),h=Number(t.getValue(s*r++,"*")),p=Number(t.getValue(s*r++,i)),m=[];for(let y=0;y<p;y++)m.push(Number(t.getValue(s*r++,i)));o.push(new Jk(t,c,h,m))}this.inputs=o}get kernelCustomData(){return this.backend.currentKernelCustomData}get customDataBuffer(){return this.module.HEAPU8.subarray(this.customDataOffset,this.customDataOffset+this.customDataSize)}compute(t,e){var a;let n=((a=e==null?void 0:e.inputs)==null?void 0:a.map(o=>typeof o=="number"?this.inputs[o]:o))??this.inputs,s=(e==null?void 0:e.outputs)??[],r=(o,l,c)=>new Jk(this.module,l,this.output(o,c),c),i=(o,l)=>{let c=Xy(o,l);if(!c)throw new Error(`Unsupported data type: ${o}`);let h=c>0?this.backend.gpuDataManager.create(c).id:0;return new Jk(this.module,o,h,l)};return this.backend.run(t,n,s,r,i,this.outputCount)}output(t,e){let n=this.module.stackSave();try{let s=this.module.PTR_SIZE,r=s===4?"i32":"i64",i=this.module.stackAlloc((1+e.length)*s);this.module.setValue(i,e.length,r);for(let a=0;a<e.length;a++)this.module.setValue(i+s*(a+1),e[a],r);return this.module._JsepOutput(this.opKernelContext,t,i)}catch(s){throw new Error(`Failed to generate kernel's output[${t}] with dims [${e}]. If you are running with pre-allocated output, please make sure the output type/dims are correct. Error: ${s}`)}finally{this.module.stackRestore(n)}}},Cne=async(t,e,n,s)=>{let r=e.jsepInit;if(!r)throw new Error("Failed to initialize JSEP. The WebAssembly module is not built with JSEP support.");if(t==="webgpu"){let i=(pCe(),TE(Ene)).WebGpuBackend,a=new i;await a.initialize(n,s),r("webgpu",[a,o=>a.alloc(Number(o)),o=>a.free(o),(o,l,c,h=!1)=>{if(h)cr("verbose",()=>`[WebGPU] jsepCopyGpuToGpu: src=${Number(o)}, dst=${Number(l)}, size=${Number(c)}`),a.memcpy(Number(o),Number(l));else{cr("verbose",()=>`[WebGPU] jsepCopyCpuToGpu: dataOffset=${Number(o)}, gpuDataId=${Number(l)}, size=${Number(c)}`);let p=e.HEAPU8.subarray(Number(o>>>0),Number(o>>>0)+Number(c));a.upload(Number(l),p)}},async(o,l,c)=>{cr("verbose",()=>`[WebGPU] jsepCopyGpuToCpu: gpuDataId=${o}, dataOffset=${l}, size=${c}`),await a.download(Number(o),()=>e.HEAPU8.subarray(Number(l)>>>0,Number(l+c)>>>0))},(o,l,c)=>a.createKernel(o,Number(l),c,e.UTF8ToString(e._JsepGetNodeName(Number(l)))),o=>a.releaseKernel(o),(o,l,c,h)=>{cr("verbose",()=>`[WebGPU] jsepRun: sessionHandle=${c}, kernel=${o}, contextDataOffset=${l}`);let p=new H9(e,a,Number(l));return a.computeKernel(Number(o),p,h)},()=>a.captureBegin(),()=>a.captureEnd(),()=>a.replay()])}else{let i=new jZ(n);r("webnn",[i,()=>i.reserveTensorId(),a=>i.releaseTensorId(a),async(a,o,l,c,h)=>i.ensureTensor(a,o,l,c,h),(a,o)=>{i.uploadTensor(a,o)},async(a,o)=>i.downloadTensor(a,o),(a,o)=>i.registerMLContext(a,o),!!n.trace])}}}),q9,sj,rj,Mg,W9,q$,hR,ij,aj,W$,oj,lj,cj,Ine=qt(()=>{Ad(),bAe(),wAe(),ts(),Gv(),F7(),MZ(),q9=(t,e)=>{ri()._OrtInit(t,e)!==0&&Lr("Can't initialize onnxruntime.")},sj=async t=>{q9(t.wasm.numThreads,oR(t.logLevel))},rj=async(t,e)=>{var s,r;(r=(s=ri()).asyncInit)==null||r.call(s);let n=t.webgpu.adapter;if(e==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(n){if(typeof n.limits!="object"||typeof n.features!="object"||typeof n.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let i=t.webgpu.powerPreference;if(i!==void 0&&i!=="low-power"&&i!=="high-performance")throw new Error(`Invalid powerPreference setting: "${i}"`);let a=t.webgpu.forceFallbackAdapter;if(a!==void 0&&typeof a!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${a}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:i,forceFallbackAdapter:a}),!n)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(e==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment");{let i=(mCe(),TE(Ane)).init;e==="webgpu"&&await i("webgpu",ri(),t,n),e==="webnn"&&await i("webnn",ri(),t)}},Mg=new Map,W9=t=>{let e=ri(),n=e.stackSave();try{let s=e.PTR_SIZE,r=e.stackAlloc(2*s);e._OrtGetInputOutputCount(t,r,r+s)!==0&&Lr("Can't get session input/output count.");let i=s===4?"i32":"i64";return[Number(e.getValue(r,i)),Number(e.getValue(r+s,i))]}finally{e.stackRestore(n)}},q$=(t,e)=>{let n=ri(),s=n.stackSave(),r=0;try{let i=n.PTR_SIZE,a=n.stackAlloc(2*i);n._OrtGetInputOutputMetadata(t,e,a,a+i)!==0&&Lr("Can't get session input/output metadata.");let o=Number(n.getValue(a,"*"));r=Number(n.getValue(a+i,"*"));let l=n.HEAP32[r/4];if(l===0)return[o,0];let c=n.HEAPU32[r/4+1],h=[];for(let p=0;p<c;p++){let m=Number(n.getValue(r+8+p*i,"*"));h.push(m!==0?n.UTF8ToString(m):Number(n.getValue(r+8+(p+c)*i,"*")))}return[o,l,h]}finally{n.stackRestore(s),r!==0&&n._OrtFree(r)}},hR=t=>{let e=ri(),n=e._malloc(t.byteLength);if(n===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return e.HEAPU8.set(t,n),[n,t.byteLength]},ij=async(t,e)=>{var p,m,y,v;let n,s,r=ri();Array.isArray(t)?[n,s]=t:t.buffer===r.HEAPU8.buffer?[n,s]=[t.byteOffset,t.byteLength]:[n,s]=hR(t);let i=0,a=0,o=0,l=[],c=[],h=[];try{if([a,l]=await RZ(e),(e==null?void 0:e.externalData)&&r.mountExternalData){let R=[];for(let B of e.externalData){let G=typeof B=="string"?B:B.path;R.push(G7(typeof B=="string"?B:B.data).then(X=>{r.mountExternalData(G,X)}))}await Promise.all(R)}for(let R of(e==null?void 0:e.executionProviders)??[])if((typeof R=="string"?R:R.name)==="webnn"){if(r.shouldTransferToMLTensor=!1,typeof R!="string"){let B=R,G=B==null?void 0:B.context,X=B==null?void 0:B.gpuDevice,H=B==null?void 0:B.deviceType,Y=B==null?void 0:B.powerPreference;G?r.currentContext=G:X?r.currentContext=await r.webnnCreateMLContext(X):r.currentContext=await r.webnnCreateMLContext({deviceType:H,powerPreference:Y})}else r.currentContext=await r.webnnCreateMLContext();break}i=await r._OrtCreateSession(n,s,a),(p=r.webgpuOnCreateSession)==null||p.call(r,i),i===0&&Lr("Can't create a session."),(m=r.jsepOnCreateSession)==null||m.call(r),r.currentContext&&(r.webnnRegisterMLContext(i,r.currentContext),r.currentContext=void 0,r.shouldTransferToMLTensor=!0);let[b,S]=W9(i),E=!!(e!=null&&e.enableGraphCapture),I=[],M=[],j=[],L=[],K=[];for(let R=0;R<b;R++){let[B,G,X]=q$(i,R);B===0&&Lr("Can't get an input name."),c.push(B);let H=r.UTF8ToString(B);I.push(H),j.push(G===0?{name:H,isTensor:!1}:{name:H,isTensor:!0,type:Em(G),shape:X})}for(let R=0;R<S;R++){let[B,G,X]=q$(i,R+b);B===0&&Lr("Can't get an output name."),h.push(B);let H=r.UTF8ToString(B);M.push(H),L.push(G===0?{name:H,isTensor:!1}:{name:H,isTensor:!0,type:Em(G),shape:X});{if(E&&(e==null?void 0:e.preferredOutputLocation)===void 0){K.push("gpu-buffer");continue}let Y=typeof(e==null?void 0:e.preferredOutputLocation)=="string"?e.preferredOutputLocation:((y=e==null?void 0:e.preferredOutputLocation)==null?void 0:y[H])??"cpu",F=r.webnnIsGraphOutput;if(Y==="cpu"&&F&&F(i,H)){K.push("ml-tensor-cpu-output");continue}if(Y!=="cpu"&&Y!=="cpu-pinned"&&Y!=="gpu-buffer"&&Y!=="ml-tensor")throw new Error(`Not supported preferred output location: ${Y}.`);if(E&&Y!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${Y}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);K.push(Y)}}let D=null;return K.some(R=>R==="gpu-buffer"||R==="ml-tensor"||R==="ml-tensor-cpu-output")&&(o=r._OrtCreateBinding(i),o===0&&Lr("Can't create IO binding."),D={handle:o,outputPreferredLocations:K,outputPreferredLocationsEncoded:K.map(R=>R==="ml-tensor-cpu-output"?"ml-tensor":R).map(R=>HD(R))}),Mg.set(i,[i,c,h,D,E,!1]),[i,I,M,j,L]}catch(b){throw c.forEach(S=>r._OrtFree(S)),h.forEach(S=>r._OrtFree(S)),o!==0&&r._OrtReleaseBinding(o)!==0&&Lr("Can't release IO binding."),i!==0&&r._OrtReleaseSession(i)!==0&&Lr("Can't release session."),b}finally{r._free(n),a!==0&&r._OrtReleaseSessionOptions(a)!==0&&Lr("Can't release session options."),l.forEach(b=>r._free(b)),(v=r.unmountExternalData)==null||v.call(r)}},aj=t=>{var l,c,h;let e=ri(),n=Mg.get(t);if(!n)throw new Error(`cannot release session. invalid session id: ${t}`);let[s,r,i,a,o]=n;a&&(o&&e._OrtClearBoundOutputs(a.handle)!==0&&Lr("Can't clear bound outputs."),e._OrtReleaseBinding(a.handle)!==0&&Lr("Can't release IO binding.")),(l=e.jsepOnReleaseSession)==null||l.call(e,t),(c=e.webnnOnReleaseSession)==null||c.call(e,t),(h=e.webgpuOnReleaseSession)==null||h.call(e,t),r.forEach(p=>e._OrtFree(p)),i.forEach(p=>e._OrtFree(p)),e._OrtReleaseSession(s)!==0&&Lr("Can't release session."),Mg.delete(t)},W$=async(t,e,n,s,r,i,a=!1)=>{if(!t){e.push(0);return}let o=ri(),l=o.PTR_SIZE,c=t[0],h=t[1],p=t[3],m=p,y,v;if(c==="string"&&(p==="gpu-buffer"||p==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(a&&p!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${i} when enableGraphCapture is true.`);if(p==="gpu-buffer"){let E=t[2].gpuBuffer;v=Xy(Yy(c),h);{let I=o.jsepRegisterBuffer;if(!I)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');y=I(s,i,E,v)}}else if(p==="ml-tensor"){let E=t[2].mlTensor;v=Xy(Yy(c),h);let I=o.webnnRegisterMLTensor;if(!I)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');y=I(s,E,Yy(c),h)}else{let E=t[2];if(Array.isArray(E)){v=l*E.length,y=o._malloc(v),n.push(y);for(let I=0;I<E.length;I++){if(typeof E[I]!="string")throw new TypeError(`tensor data at index ${I} is not a string`);o.setValue(y+I*l,Uh(E[I],n),"*")}}else{let I=o.webnnIsGraphInput,M=o.webnnIsGraphOutput;if(c!=="string"&&I&&M){let j=o.UTF8ToString(r);if(I(s,j)||M(s,j)){let L=Yy(c);v=Xy(L,h),m="ml-tensor";let K=o.webnnCreateTemporaryTensor,D=o.webnnUploadTensor;if(!K||!D)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let R=await K(s,L,h);D(R,new Uint8Array(E.buffer,E.byteOffset,E.byteLength)),y=R}else v=E.byteLength,y=o._malloc(v),n.push(y),o.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,v),y)}else v=E.byteLength,y=o._malloc(v),n.push(y),o.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,v),y)}}let b=o.stackSave(),S=o.stackAlloc(4*h.length);try{h.forEach((I,M)=>o.setValue(S+M*l,I,l===4?"i32":"i64"));let E=o._OrtCreateTensor(Yy(c),y,v,S,h.length,HD(m));E===0&&Lr(`Can't create tensor for input/output. session=${s}, index=${i}.`),e.push(E)}finally{o.stackRestore(b)}},oj=async(t,e,n,s,r,i)=>{var H,Y,F,we;let a=ri(),o=a.PTR_SIZE,l=Mg.get(t);if(!l)throw new Error(`cannot run inference. invalid session id: ${t}`);let c=l[0],h=l[1],p=l[2],m=l[3],y=l[4],v=l[5],b=e.length,S=s.length,E=0,I=[],M=[],j=[],L=[],K=[],D=a.stackSave(),R=a.stackAlloc(b*o),B=a.stackAlloc(b*o),G=a.stackAlloc(S*o),X=a.stackAlloc(S*o);try{[E,I]=NZ(i),pv("wasm prepareInputOutputTensor");for(let ve=0;ve<b;ve++)await W$(n[ve],M,L,t,h[e[ve]],e[ve],y);for(let ve=0;ve<S;ve++)await W$(r[ve],j,L,t,p[s[ve]],b+s[ve],y);mv("wasm prepareInputOutputTensor");for(let ve=0;ve<b;ve++)a.setValue(R+ve*o,M[ve],"*"),a.setValue(B+ve*o,h[e[ve]],"*");for(let ve=0;ve<S;ve++)a.setValue(G+ve*o,j[ve],"*"),a.setValue(X+ve*o,p[s[ve]],"*");if(m&&!v){let{handle:ve,outputPreferredLocations:ce,outputPreferredLocationsEncoded:ie}=m;if(h.length!==b)throw new Error(`input count from feeds (${b}
6647) is expected to be always equal to model's input count (${h.length}).`);pv("wasm bindInputsOutputs");for(let de=0;de<b;de++){let Re=e[de];await a._OrtBindInput(ve,h[Re],M[de])!==0&&Lr(`Can't bind input[${de}] for session=${t}.`)}for(let de=0;de<S;de++){let Re=s[de];(H=r[de])!=null&&H[3]?(K.push(j[de]),a._OrtBindOutput(ve,p[Re],j[de],0)!==0&&Lr(`Can't bind pre-allocated output[${de}] for session=${t}.`)):a._OrtBindOutput(ve,p[Re],0,ie[Re])!==0&&Lr(`Can't bind output[${de}] to ${ce[de]} for session=${t}.`)}mv("wasm bindInputsOutputs"),Mg.set(t,[c,h,p,m,y,!0])}(Y=a.jsepOnRunStart)==null||Y.call(a,c),(F=a.webnnOnRunStart)==null||F.call(a,c);let me;m?me=await a._OrtRunWithBinding(c,m.handle,S,G,E):me=await a._OrtRun(c,B,R,b,X,S,G,E),me!==0&&Lr("failed to call OrtRun().");let xe=[],Le=[];pv("wasm ProcessOutputTensor");for(let ve=0;ve<S;ve++){let ce=Number(a.getValue(G+ve*o,"*"));if(ce===j[ve]||K.includes(j[ve])){xe.push(r[ve]),ce!==j[ve]&&a._OrtReleaseTensor(ce)!==0&&Lr("Can't release tensor.");continue}let ie=a.stackSave(),de=a.stackAlloc(4*o),Re=!1,Se,De=0;try{a._OrtGetTensorData(ce,de,de+o,de+2*o,de+3*o)!==0&&Lr(`Can't access output tensor data on index ${ve}.`);let gt=o===4?"i32":"i64",yt=Number(a.getValue(de,gt));De=a.getValue(de+o,"*");let xt=a.getValue(de+o*2,"*"),Nt=Number(a.getValue(de+o*3,gt)),wt=[];for(let Zt=0;Zt<Nt;Zt++)wt.push(Number(a.getValue(xt+Zt*o,gt)));a._OrtFree(xt)!==0&&Lr("Can't free memory for tensor dims.");let zt=wt.reduce((Zt,J)=>Zt*J,1);Se=Em(yt);let _n=m==null?void 0:m.outputPreferredLocations[s[ve]];if(Se==="string"){if(_n==="gpu-buffer"||_n==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Zt=[];for(let J=0;J<zt;J++){let We=a.getValue(De+J*o,"*"),Ie=a.getValue(De+(J+1)*o,"*"),ge=J===zt-1?void 0:Ie-We;Zt.push(a.UTF8ToString(We,ge))}xe.push([Se,wt,Zt,"cpu"])}else if(_n==="gpu-buffer"&&zt>0){let Zt=a.jsepGetBuffer;if(!Zt)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let J=Zt(De),We=Xy(yt,zt);if(We===void 0||!V7(Se))throw new Error(`Unsupported data type: ${Se}`);Re=!0,xe.push([Se,wt,{gpuBuffer:J,download:a.jsepCreateDownloader(J,We,Se),dispose:()=>{a._OrtReleaseTensor(ce)!==0&&Lr("Can't release tensor.")}},"gpu-buffer"])}else if(_n==="ml-tensor"&&zt>0){let Zt=a.webnnEnsureTensor,J=a.webnnIsGraphInputOutputTypeSupported;if(!Zt||!J)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Xy(yt,zt)===void 0||!z7(Se))throw new Error(`Unsupported data type: ${Se}`);if(!J(t,Se,!1))throw new Error(`preferredLocation "ml-tensor" for ${Se} output is not supported by current WebNN Context.`);let We=await Zt(t,De,yt,wt,!1);Re=!0,xe.push([Se,wt,{mlTensor:We,download:a.webnnCreateMLTensorDownloader(De,Se),dispose:()=>{a.webnnReleaseTensorId(De),a._OrtReleaseTensor(ce)}},"ml-tensor"])}else if(_n==="ml-tensor-cpu-output"&&zt>0){let Zt=a.webnnCreateMLTensorDownloader(De,Se)(),J=xe.length;Re=!0,Le.push((async()=>{let We=[J,await Zt];return a.webnnReleaseTensorId(De),a._OrtReleaseTensor(ce),We})()),xe.push([Se,wt,[],"cpu"])}else{let Zt=PM(Se),J=new Zt(zt);new Uint8Array(J.buffer,J.byteOffset,J.byteLength).set(a.HEAPU8.subarray(De,De+J.byteLength)),xe.push([Se,wt,J,"cpu"])}}finally{a.stackRestore(ie),Se==="string"&&De&&a._free(De),Re||a._OrtReleaseTensor(ce)}}m&&!y&&(a._OrtClearBoundOutputs(m.handle)!==0&&Lr("Can't clear bound outputs."),Mg.set(t,[c,h,p,m,y,!1]));for(let[ve,ce]of await Promise.all(Le))xe[ve][2]=ce;return mv("wasm ProcessOutputTensor"),xe}finally{(we=a.webnnOnRunEnd)==null||we.call(a,c),a.stackRestore(D),M.forEach(me=>a._OrtReleaseTensor(me)),j.forEach(me=>a._OrtReleaseTensor(me)),L.forEach(me=>a._free(me)),E!==0&&a._OrtReleaseRunOptions(E),I.forEach(me=>a._free(me))}},lj=t=>{let e=ri(),n=Mg.get(t);if(!n)throw new Error("invalid session id");let s=n[0],r=e._OrtEndProfiling(s);r===0&&Lr("Can't get an profile file name."),e._OrtFree(r)},cj=t=>{let e=[];for(let n of t){let s=n[2];!Array.isArray(s)&&"buffer"in s&&e.push(s.buffer)}return e}}),Pg,Ic,Lb,W2,K2,Qk,K$,Zk,Ly,jy,K9,Nne,Rne,Mne,Pne,$ne,Dne,One,Lne=qt(()=>{Ad(),Ine(),Gv(),B7(),Pg=()=>!!fi.wasm.proxy&&typeof document<"u",Lb=!1,W2=!1,K2=!1,Zk=new Map,Ly=(t,e)=>{let n=Zk.get(t);n?n.push(e):Zk.set(t,[e])},jy=()=>
vendor: 5,589 bytes, lines 6647-6650
6647{if(Lb||!W2||K2||!Ic)throw new Error("worker not ready")},K9=t=>{switch(t.data.type){case"init-wasm":Lb=!1,t.data.err?(K2=!0,K$[1](t.data.err)):(W2=!0,K$[0]()),Qk&&(URL.revokeObjectURL(Qk),Qk=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=Zk.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out);break}}},Nne=async()=>{if(!W2){if(Lb)throw new Error("multiple calls to 'initWasm()' detected.");if(K2)throw new Error("previous call to 'initWasm()' failed.");if(Lb=!0,Pg())return new Promise((t,e)=>{Ic==null||Ic.terminate(),kZ().then(([n,s])=>{try{Ic=s,Ic.onerror=i=>e(i),Ic.onmessage=K9,K$=[t,e];let r={type:"init-wasm",in:fi};!r.in.wasm.wasmPaths&&(n||GD)&&(r.in.wasm.wasmPaths={wasm:new URL("/assets/ort-wasm-simd-threaded.jsep-CyqnNavA.wasm",import.meta.url).href}),Ic.postMessage(r),Qk=n}catch(r){e(r)}},e)});try{await U7(fi.wasm),await sj(fi),W2=!0}catch(t){throw K2=!0,t}finally{Lb=!1}}},Rne=async t=>{if(Pg())return jy(),new Promise((e,n)=>{Ly("init-ep",[e,n]);let s={type:"init-ep",in:{epName:t,env:fi}};Ic.postMessage(s)});await rj(fi,t)},Mne=async t=>Pg()?(jy(),new Promise((e,n)=>{Ly("copy-from",[e,n]);let s={type:"copy-from",in:{buffer:t}};Ic.postMessage(s,[t.buffer])})):hR(t),Pne=async(t,e)=>{if(Pg()){if(e!=null&&e.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return jy(),new Promise((n,s)=>{Ly("create",[n,s]);let r={type:"create",in:{model:t,options:{...e}}},i=[];t instanceof Uint8Array&&i.push(t.buffer),Ic.postMessage(r,i)})}else return ij(t,e)},$ne=async t=>{if(Pg())return jy(),new Promise((e,n)=>{Ly("release",[e,n]);let s={type:"release",in:t};Ic.postMessage(s)});aj(t)},Dne=async(t,e,n,s,r,i)=>{if(Pg()){if(n.some(a=>a[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(r.some(a=>a))throw new Error("pre-allocated output tensor is not supported for proxy.");return jy(),new Promise((a,o)=>{Ly("run",[a,o]);let l=n,c={type:"run",in:{sessionId:t,inputIndices:e,inputs:l,outputIndices:s,options:i}};Ic.postMessage(c,cj(l))})}else return oj(t,e,n,s,r,i)},One=async t=>{if(Pg())return jy(),new Promise((e,n)=>{Ly("end-profiling",[e,n]);let s={type:"end-profiling",in:t};Ic.postMessage(s)});lj(t)}}),Y$,Y9,jne,gCe=qt(()=>{Ad(),Lne(),ts(),j7(),MZ(),Y$=(t,e)=>{switch(t.location){case"cpu":return[t.type,t.dims,t.data,"cpu"];case"gpu-buffer":return[t.type,t.dims,{gpuBuffer:t.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[t.type,t.dims,{mlTensor:t.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${t.location} for ${e()}`)}},Y9=t=>{switch(t[3]){case"cpu":return new Vh(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!V7(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:n,download:s,dispose:r}=t[2];return Vh.fromGpuBuffer(n,{dataType:e,dims:t[1],download:s,dispose:r})}case"ml-tensor":{let e=t[0];if(!z7(e))throw new Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:n,download:s,dispose:r}=t[2];return Vh.fromMLTensor(n,{dataType:e,dims:t[1],download:s,dispose:r})}default:throw new Error(`invalid data location: ${t[3]}`)}},jne=class{async fetchModelAndCopyToWasmMemory(t){return Mne(await G7(t))}async loadModel(t,e){yp();let n;typeof t=="string"?n=await this.fetchModelAndCopyToWasmMemory(t):n=t,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Pne(n,e),Kh()}async dispose(){return $ne(this.sessionId)}async run(t,e,n){yp();let s=[],r=[];Object.entries(t).forEach(p=>{let m=p[0],y=p[1],v=this.inputNames.indexOf(m);if(v===-1)throw new Error(`invalid input '${m}'`);s.push(y),r.push(v)});let i=[],a=[];Object.entries(e).forEach(p=>{let m=p[0],y=p[1],v=this.outputNames.indexOf(m);if(v===-1)throw new Error(`invalid output '${m}'`);i.push(y),a.push(v)});let o=s.map((p,m)=>Y$(p,()=>`input "${this.inputNames[r[m]]}"`)),l=i.map((p,m)=>p?Y$(p,()=>`output "${this.outputNames[a[m]]}"`):null),c=await Dne(this.sessionId,r,o,a,l,n),h={};for(let p=0;p<c.length;p++)h[this.outputNames[a[p]]]=i[p]??Y9(c[p]);return Kh(),h}startProfiling(){}endProfiling(){One(this.sessionId)}}}),Bne={};i_(Bne,{OnnxruntimeWebAssemblyBackend:()=>i5,initializeFlags:()=>r5,wasmBackend:()=>Une});var r5,i5,Une,yCe=qt(()=>{Ad(),Lne(),gCe(),r5=()=>{(typeof fi.wasm.initTimeout!="number"||fi.wasm.initTimeout<0)&&(fi.wasm.initTimeout=0);let t=fi.wasm.simd;if(typeof t!="boolean"&&t!==void 0&&t!=="fixed"&&t!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${t}". Reset it to \`false\` and ignore SIMD feature checking.`),fi.wasm.simd=!1),typeof fi.wasm.proxy!="boolean"&&(fi.wasm.proxy=!1),typeof fi.wasm.trace!="boolean"&&(fi.wasm.trace=!1),typeof fi.wasm.numThreads!="number"||!Number.isInteger(fi.wasm.numThreads)||fi.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)fi.wasm.numThreads=1;else{let e=typeof navigator>"u"?nAe("node:os").cpus().length:navigator.hardwareConcurrency;fi.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},i5=class{async init(t){r5(),await Nne(),await Rne(t)}async createInferenceSessionHandler(t,e){let n=new jne;return await n.loadModel(t,e),n}},Une=new i5});Ad();Ad();Ad();var xCe="1.26.0";{let t=(yCe(),TE(Bne)).wasmBackend;aw("webgpu",t,5),aw("webnn",t,5),aw("cpu",t,10),aw("wasm",t,10)}Object.defineProperty(fi.versions,"web",{value:xCe,enumerable:!0});/**
6648* @license
6649* Copyright 2021 Google LLC. All Rights Reserved.
6650* Licensed under the Apache License, Version 2.0 (the "License");
6651* you may not use this file except in compliance with the License.
6652* You may obtain a copy of the License at
6653*
6654* http://www.apache.org/licenses/LICENSE-2.0
6655*
6656* Unless required by applicable law or agreed to in writing, software
6657* distributed under the License is distributed on an "AS IS" BASIS,
6658* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6659* See the License for the specific language governing permissions and
6660* limitations under the License.
6661* =============================================================================
6662*//**
6663 * @license
6664 * Copyright 2020 Google LLC. All Rights Reserved.
6665 * Licensed under the Apache License, Version 2.0 (the "License");
6666 * you may not use this file except in compliance with the License.
6667 * You may obtain a copy of the License at
6668 *
6669 * http://www.apache.org/licenses/LICENSE-2.0
6670 *
6671 * Unless required by applicable law or agreed to in writing, software
6672 * distributed under the License is distributed on an "AS IS" BASIS,
6673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6674 * See the License for the specific language governing permissions and
6675 * limitations under the License.
6676 * =============================================================================
6677 *//**
6678 * @license
6679 * Copyright 2019 Google LLC. All Rights Reserved.
6680 * Licensed under the Apache License, Version 2.0 (the "License");
6681 * you may not use this file except in compliance with the License.
6682 * You may obtain a copy of the License at
6683 *
6684 * http://www.apache.org/licenses/LICENSE-2.0
6685 *
6686 * Unless required by applicable law or agreed to in writing, software
6687 * distributed under the License is distributed on an "AS IS" BASIS,
6688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6689 * See the License for the specific language governing permissions and
6690 * limitations under the License.
6691 * =============================================================================
6692 */function T0(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var X$={exports:{}};/*!
6693
6694JSZip v3.10.1 - A JavaScript class for generating and reading zip files
6695<http://stuartk.com/jszip>
6696
6697(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
6698Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
6699
6700JSZip uses the library pako released under the MIT license :
6701https://github.com/nodeca/pako/blob/main/LICENSE
6702*/var X9;function vCe(){return X9||(X9=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(s,r,i){function a(c,h){if(!r[c]){if(!s[c]){var p=typeof T0=="function"&&T0;if(!h&&p)return p(c,!0);if(o)return o(c,!0);var m=new Error("Cannot find module '"+c+"'");throw m.code="MODULE_NOT_FOUND",m}var y=r[c]={exports:{}};s[c][0].call(y.exports,function(v){var b=s[c][1][v];return a(b||v)},y,y.exports,n,s,r,i)}return r[c].exports}for(var o=typeof T0=="function"&&T0,l=0;l<i.length;l++)a(i[l]);return a})({1:[function(n,s,r){var i=n("./utils"),a=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(l){for(var c,h,p,m,y,v,b,S=[],E=0,I=l.length,M=I,j=i.getTypeOf(l)!=="string";E<l.length;)M=I-E,p=j?(c=l[E++],h=E<I?l[E++]:0,E<I?l[E++]:0):(c=l.charCodeAt(E++),h=E<I?l.charCodeAt(E++):0,E<I?l.charCodeAt(E++):0),m=c>>2,y=(3&c)<<4|h>>4,v=1<M?(15&h)<<2|p>>6:64,b=2<M?63&p:64,S.push(o.charAt(m)+o.charAt(y)+o.charAt(v)+o.charAt(b));return S.join("")},r.decode=function(l){var c,h,p,m,y,v,b=0,S=0,E="data:";if(l.substr(0,E.length)===E)throw new Error("Invalid base64 input, it looks like a data url.");var I,M=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&M--,l.charAt(l.length-2)===o.charAt(64)&&M--,M%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=a.uint8array?new Uint8Array(0|M):new Array(0|M);b<l.length;)c=o.indexOf(l.charAt(b++))<<2|(m=o.indexOf(l.charAt(b++)))>>4,h=(15&m)<<4|(y=o.indexOf(l.charAt(b++)))>>2,p=(3&y)<<6|(v=o.indexOf(l.charAt(b++))),I[S++]=c,y!==64&&(I[S++]=h),v!==64&&(I[S++]=p);return I}},{"./support":30,"./utils":32}],2:[function(n,s,r){var i=n("./external"),a=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(h,p,m,y,v){this.compressedSize=h,this.uncompressedSize=p,this.crc32=m,this.compression=y,this.compressedContent=v}c.prototype={getContentWorker:function(){var h=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),p=this;return h.on("end",function(){if(this.streamInfo.data_length!==p.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,p,m){return h.pipe(new o).pipe(new l("uncompressedSize")).pipe(p.compressWorker(m)).pipe(new l("compressedSize")).withStreamInfo("compression",p)},s.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,s,r){var i=n("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,s,r){var i=n("./utils"),a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var h=0;h<8;h++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();s.exports=function(o,l){return o!==void 0&&o.length?i.getTypeOf(o
vendor: 7,993 bytes, lines 6702-6703
6702)!=="string"?(function(c,h,p,m){var y=a,v=m+p;c^=-1;for(var b=m;b<v;b++)c=c>>>8^y[255&(c^h[b])];return-1^c})(0|l,o,o.length,0):(function(c,h,p,m){var y=a,v=m+p;c^=-1;for(var b=m;b<v;b++)c=c>>>8^y[255&(c^h.charCodeAt(b))];return-1^c})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(n,s,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(n,s,r){var i=null;i=typeof Promise<"u"?Promise:n("lie"),s.exports={Promise:i}},{lie:37}],7:[function(n,s,r){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),o=n("./utils"),l=n("./stream/GenericWorker"),c=i?"uint8array":"array";function h(p,m){l.call(this,"FlateWorker/"+p),this._pako=null,this._pakoAction=p,this._pakoOptions=m,this.meta={}}r.magic="\b\0",o.inherits(h,l),h.prototype.processChunk=function(p){this.meta=p.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,p.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var p=this;this._pako.onData=function(m){p.push({data:m,meta:p.meta})}},r.compressWorker=function(p){return new h("Deflate",p)},r.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,s,r){function i(y,v){var b,S="";for(b=0;b<v;b++)S+=String.fromCharCode(255&y),y>>>=8;return S}function a(y,v,b,S,E,I){var M,j,L=y.file,K=y.compression,D=I!==c.utf8encode,R=o.transformTo("string",I(L.name)),B=o.transformTo("string",c.utf8encode(L.name)),G=L.comment,X=o.transformTo("string",I(G)),H=o.transformTo("string",c.utf8encode(G)),Y=B.length!==L.name.length,F=H.length!==G.length,we="",me="",xe="",Le=L.dir,ve=L.date,ce={crc32:0,compressedSize:0,uncompressedSize:0};v&&!b||(ce.crc32=y.crc32,ce.compressedSize=y.compressedSize,ce.uncompressedSize=y.uncompressedSize);var ie=0;v&&(ie|=8),D||!Y&&!F||(ie|=2048);var de=0,Re=0;Le&&(de|=16),E==="UNIX"?(Re=798,de|=(function(De,gt){var yt=De;return De||(yt=gt?16893:33204),(65535&yt)<<16})(L.unixPermissions,Le)):(Re=20,de|=(function(De){return 63&(De||0)})(L.dosPermissions)),M=ve.getUTCHours(),M<<=6,M|=ve.getUTCMinutes(),M<<=5,M|=ve.getUTCSeconds()/2,j=ve.getUTCFullYear()-1980,j<<=4,j|=ve.getUTCMonth()+1,j<<=5,j|=ve.getUTCDate(),Y&&(me=i(1,1)+i(h(R),4)+B,we+="up"+i(me.length,2)+me),F&&(xe=i(1,1)+i(h(X),4)+H,we+="uc"+i(xe.length,2)+xe);var Se="";return Se+=`
6703\0`,Se+=i(ie,2),Se+=K.magic,Se+=i(M,2),Se+=i(j,2),Se+=i(ce.crc32,4),Se+=i(ce.compressedSize,4),Se+=i(ce.uncompressedSize,4),Se+=i(R.length,2),Se+=i(we.length,2),{fileRecord:p.LOCAL_FILE_HEADER+Se+R+we,dirRecord:p.CENTRAL_FILE_HEADER+i(Re,2)+Se+i(X.length,2)+"\0\0\0\0"+i(de,4)+i(S,4)+R+we+X}}var o=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),h=n("../crc32"),p=n("../signature");function m(y,v,b,S){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=b,this.encodeFileName=S,this.streamFiles=y,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(m,l),m.prototype.push=function(y){var v=y.meta.percent||0,b=this.entriesCount,S=this._sources.length;this.accumulate?this.contentBuffer.push(y):(this.bytesWritten+=y.data.length,l.prototype.push.call(this,{data:y.data,meta:{currentFile:this.currentFile,percent:b?(v+100*(b-S-1))/b:100}}))},m.prototype.openedSource=function(y){this.currentSourceOffset=this.bytesWritten,this.currentFile=y.file.name;var v=this.streamFiles&&!y.file.dir;if(v){var b=a(y,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(y){this.accumulate=!1;var v=this.streamFiles&&!y.file.dir,b=a(y,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),v)this.push({data:(function(S){return p.DATA_DESCRIPTOR+i(S.crc32,4)+i(S.compressedSize,4)+i(S.uncompressedSize,4)})(y),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var y=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var b=this.bytesWritten-y,S=(function(E,I,M,j,L){var K=o.transformTo("string",L(j));return p.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(E,2)+i(E,2)+i(I,4)+i(M,4)+i(K.length,2)+K})(this.dirRecords.length,b,y,this.zipComment,this.encodeFileName);this.push({data:S,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(y){this._sources.push(y);var v=this;return y.on("data",function(b){v.processChunk(b)}),y.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),y.on("error",function(b){v.error(b)}),this},m.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(y){var v=this._sources;if(!l.prototype.error.call(this,y))return!1;for(var b=0;b<v.length;b++)try{v[b].error(y)}catch{}return!0},m.prototype.lock=function(){l.prototype.lock.call(this);for(var y=this._sources,v=0;v<y.length;v++)y[v].lock()},s.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,s,r){var i=n("../compressions"),a=n("./ZipFileWorker");r.generateWorker=function(o,l,c){var h=new a(l.streamFiles,c,l.platform,l.encodeFileName),p=0;try{o.forEach(function(m,y){p++;var v=(function(I,M){var j=I||M,L=i[j];if(!L)throw new Error(j+" is not a valid compression method !");return L})(y.options.compression,l.compression),b=y.options.compressionOptions||l.compressionOptions||{},S=y.dir,E=y.date;y._compressWorker(v,b).withStreamInfo("file",{name:m,dir:S,date:E,comment:y.comment||"",unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions}).pipe(h)}),h.entriesCount=p}catch(m){h.error(m)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,s,r){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new i;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(i.prototype=n("./object")).loadAsync=n("./load"),i.support=n("./support"),i.defaults=n("./defaults"),i.version="3.10.1",i.loadAsync=function(a,o){return new i().loadAsync(a,o)},i.external=n("./external"),s.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,s,r){var i=n("./utils"),a=n("./external"),o=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),h=n("./nodejsUtils");function p(m){return new a.Promise(function(y,v){var b=m.decompressed.getContentWorker().pipe(new c);b.on("error",function(S){v(S)}).on("end",function(){b.streamInfo.crc32!==m.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):y()}).resume()})}s.exports=function(m,y){var v=this;return y=i.extend(y||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),h.isNode&&h.isStream(m)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip f
6703ile",m,!0,y.optimizedBinaryString,y.base64).then(function(b){var S=new l(y);return S.load(b),S}).then(function(b){var S=[a.Promise.resolve(b)],E=b.files;if(y.checkCRC32)for(var I=0;I<E.length;I++)S.push(p(E[I]));return a.Promise.all(S)}).then(function(b){for(var S=b.shift(),E=S.files,I=0;I<E.length;I++){var M=E[I],j=M.fileNameStr,L=i.resolve(M.fileNameStr);v.file(L,M.decompressed,{binary:!0,optimizedBinaryString:!0,date:M.date,dir:M.dir,comment:M.fileCommentStr.length?M.fileCommentStr:null,unixPermissions:M.unixPermissions,dosPermissions:M.dosPermissions,createFolders:y.createFolders}),M.dir||(v.file(L).unsafeOriginalName=j)}return S.zipComment.length&&(v.comment=S.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,s,r){var i=n("../utils"),a=n("../stream/GenericWorker");function o(l,c){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}i.inherits(o,a),o.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},s.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,s,r){var i=n("readable-stream").Readable;function a(o,l,c){i.call(this,l),this._helper=o;var h=this;o.on("data",function(p,m){h.push(p)||h._helper.pause(),c&&c(m)}).on("error",function(p){h.emit("error",p)}).on("end",function(){h.push(null)})}n("../utils").inherits(a,i),a.prototype._read=function(){this._helper.resume()},s.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,s,r){s.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,a);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,a)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var a=new Buffer(i);return a.fill(0),a},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(n,s,r){function i(L,K,D){var R,B=o.getTypeOf(K),G=o.extend(D||{},h);G.date=G.date||new Date,G.compression!==null&&(G.compression=G.compression.toUpperCase()),typeof G.unixPermissions=="string"&&(G.unixPermissions=parseInt(G.unixPermissions,8)),G.unixPermissions&&16384&G.unixPermissions&&(G.dir=!0),G.dosPermissions&&16&G.dosPermissions&&(G.dir=!0),G.dir&&(L=E(L)),G.createFolders&&(R=S(L))&&I.call(this,R,!0);var X=B==="string"&&G.binary===!1&&G.base64===!1;D&&D.binary!==void 0||(G.binary=!X),(K instanceof p&&K.uncompressedSize===0||G.dir||!K||K.length===0)&&(G.base64=!1,G.binary=!0,K="",G.compression="STORE",B="string");var H=null;H=K instanceof p||K instanceof l?K:v.isNode&&v.isStream(K)?new b(L,K):o.prepareContent(L,K,G.binary,G.optimizedBinaryString,G.base64);var Y=new m(L,H,G);this.files[L]=Y}var a=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),h=n("./defaults"),p=n("./compressedObject"),m=n("./zipObject"),y=n("./generate"),v=n("./nodejsUtils"),b=n("./nodejs/NodejsStreamInputAdapter"),S=function(L){L.slice(-1)==="/"&&(L=L.substring(0,L.length-1));var K=L.lastIndexOf("/");return 0<K?L.substring(0,K):""},E=function(L){return L.slice(-1)!=="/"&&(L+="/"),L},I=function(L,K){return K=K!==void 0?K:h.createFolders,L=E(L),this.files[L]||i.call(this,L,null,{dir:!0,createFolders:K}),this.files[L]};function M(L){return Object.prototype.toString.call(L)==="[object RegExp]"}var j={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(L){var K,D,R;for(K in this.files)R=this.files[K],(D=K.slice(this.root.length,K.length))&&K.slice(0,this.root.length)===this.root&&L(D,R)},filter:function(L){var K=[];return this.forEach(function(D,R){L(D,R)&&K.push(R)}),K},file:function(L,K,D){if(arguments.length!==1)return L=this.root+L,i.call(this,L,K,D),this;if(M(L)){var R=L;return this.filter(function(G,X){return!X.dir&&R.test(G)})}var B=this.files[this.root+L];return B&&!B.dir?B:null},folder:function(L){if(!L)return this;if(M(L))return this.filter(function(B,G){return G.dir&&L.test(B)});var K=this.root+L,D=I.call(this,K),R=this.clone();return R.root=D.name,R},remove:function(L){L=this.root+L;var K=this.files[L];if(K||(L.slice(-1)!=="/"&&(L+="/"),K=this.files[L]),K&&!K.dir)delete this.files[L];else for(var D=this.filter(function(B,G){return G.name.slice(0,L.length)===L}),R=0;R<D.length;R++)delete this.files[D[R].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")}
vendor: 22,027 bytes, line 6703
6703,generateInternalStream:function(L){var K,D={};try{if((D=o.extend(L||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=D.type.toLowerCase(),D.compression=D.compression.toUpperCase(),D.type==="binarystring"&&(D.type="string"),!D.type)throw new Error("No output type specified.");o.checkSupport(D.type),D.platform!=="darwin"&&D.platform!=="freebsd"&&D.platform!=="linux"&&D.platform!=="sunos"||(D.platform="UNIX"),D.platform==="win32"&&(D.platform="DOS");var R=D.comment||this.comment||"";K=y.generateWorker(this,D,R)}catch(B){(K=new l("error")).error(B)}return new c(K,D.type||"string",D.mimeType)},generateAsync:function(L,K){return this.generateInternalStream(L).accumulate(K)},generateNodeStream:function(L,K){return(L=L||{}).type||(L.type="nodebuffer"),this.generateInternalStream(L).toNodejsStream(K)}};s.exports=j},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,s,r){s.exports=n("stream")},{stream:void 0}],17:[function(n,s,r){var i=n("./DataReader");function a(o){i.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),h=o.charCodeAt(2),p=o.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===l&&this.data[m+1]===c&&this.data[m+2]===h&&this.data[m+3]===p)return m-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),h=o.charCodeAt(2),p=o.charCodeAt(3),m=this.readData(4);return l===m[0]&&c===m[1]&&h===m[2]&&p===m[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,s,r){var i=n("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,c=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return i.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},s.exports=a},{"../utils":32}],19:[function(n,s,r){var i=n("./Uint8ArrayReader");function a(o){i.call(this,o)}n("../utils").inherits(a,i),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,s,r){var i=n("./DataReader");function a(o){i.call(this,o)}n("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,s,r){var i=n("./ArrayReader");function a(o){i.call(this,o)}n("../utils").inherits(a,i),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,s,r){var i=n("../utils"),a=n("../support"),o=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),h=n("./Uint8ArrayReader");s.exports=function(p){var m=i.getTypeOf(p);return i.checkSupport(m),m!=="string"||a.uint8array?m==="nodebuffer"?new c(p):a.uint8array?new h(i.transformTo("uint8array",p)):new o(i.transformTo("array",p)):new l(p)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,s,r){r.LOCAL_FILE_HEADER="PK��",r.CENTRAL_FILE_HEADER="PK��",r.CENTRAL_DIRECTORY_END="PK��",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK�\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK��",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,s,r){var i=n("./GenericWorker"),a=n("../utils");function o(l){i.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,i),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},s.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,s,r){var i=n("./GenericWorker"),a=n("../crc32");function o(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,i),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},s.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,s,r){var i=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},s.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,s,r){var i=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=i.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}i.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},s.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,s,r){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},s.exports=i},{}],29:[function(n,s,r){var i=n("../utils"),a=n("./ConvertWorker"),o=n("./GenericWorker"),l=n("../base64"),c=n("../support"),h=n("../external"),p=null;if(c.nodestream)try{p=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(v,b){return new h.Promise(function(S,E){var I=[],M=v._internalType,j=v._outputType,L=v._mimeType;v.on("data",function(K,D){I.push(K),b&&b(D)}).on("error",function(K){I=[],E(K)}).on("end",function(){try{var K=(function(D,R,B){switch(D){case"blob":return i.newBlob(i.transformTo("arraybuffer",R),B);case"base64":return l.encode(R);default:return i.transformTo(D,R)}})(j,(function(D,R){var B,G=0,X=null,H=0;for(B=0;B<R.length;B++)H+=R[B].length;switch(D){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(X=new Uint8Array(H),B=0;B<R.length;B++)X.set(R[B],G),G+=R[B].length;return X;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+D+"'")}})(M,I),L);S(K)}catch(D){E(D)}I=[]}).resume()})}function y(v,b,S){var E=b;switch(b){case"blob":case"arraybuffer":E="uint8array";break;case"base64":E="string"}try{this._internalType=E,this._outputType=b,this._mimeType=S,i.checkSupport(E),this._worker=v.pipe(new a(E)),v.lock()}catch(I){this._worker=new o("error"),this._worker.error(I)}}y.prototype={accumulate:function(v){return m(this,v)},on:function(v,b){var S=this;return v==="data"?this._worker.on(v,function(E){b.call(S,E.data,E.meta)}):this._worker.on(v,function(){i.delay(b,arguments,S)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new p(this,{objectMode:this._outputType!=="nodebuffer"},v)}},s.exports=y},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,s,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var i=new ArrayBuffer(0);try{r.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!n("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(n,s,r){for(var i=n("./utils"),a=n("./support"),o=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;c[254]=c[254]=1;function p(){l.call(this,"utf-8 decode"),this.leftOver=null}function m(){l.call(this,"utf-8 encode")}r.utf8encode=function(y){return a.nodebuffer?o.newBufferFrom(y,"utf-8"):(function(v){var b,S,E,I,M,j=v.length,L=0;for(I=0;I<j;I++)(64512&(S=v.charCodeAt(I)))==55296&&I+1<j&&(64512&(E=v.charCodeAt(I+1)))==56320&&(S=65536+(S-55296<<10)+(E-56320),I++),L+=S<128?1:S<2048?2:S<65536?3:4;for(b=a.uint8array?new Uint8Array(L):new Array(L),I=M=0;M<L;I++)(64512&(S=v.charCodeAt(I)))==55296&&I+1<j&&(64512&(E=v.charCodeAt(I+1)))==56320&&(S=65536+(S-55296<<10)+(E-56320),I++),S<128?b[M++]=S:(S<2048?b[M++]=192|S>>>6:(S<65536?b[M++]=224|S>>>12:(b[M++]=240|S>>>18,b[M++]=128|S>>>12&63),b[M++]=128|S>>>6&63),b[M++]=128|63&S);return b})(y)},r.utf8decode=function(y){return a.nodebuffer?i.transformTo("nodebuffer",y).toString("utf-8"):(function(v){var b,S,E,I,M=v.length,j=new Array(2*M);for(b=S=0;b<M;)if((E=v[b++])<128)j[S++]=E;else if(4<(I=c[E]))j[S++]=65533,b+=I-1;else{for(E&=I===2?31:I===3?15:7;1<I&&b<M;)E=E<<6|63&v[b++],I--;1<I?j[S++]=65533:E<65536?j[S++]=E:(E-=65536,j[S++]=55296|E>>10&1023,j[S++]=56320|1023&E)}return j.length!==S&&(j.subarray?j=j.subarray(0,S):j.length=S),i.applyFromCharCode(j)})(y=i.transformTo(a.uint8array?"uint8array":"array",y))},i.inherits(p,l),p.prototype.processChunk=function(y){var v=i.transformTo(a.uint8array?"uint8array":"array",y.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var b=v;(v=new Uint8Array(b.length+this.leftOver.length)).set(this.leftOver,0),v.set(b,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var S=(function(I,M){var j;for((M=M||I.length)>I.length&&(M=I.length),j=M-1;0<=j&&(192&I[j])==128;)j--;return j<0||j===0?M:j+c[I[j]]>M?j:M})(v),E=v;S!==v.length&&(a.uint8array?(E=v.subarray(0,S),this.leftOver=v.subarray(S,v.length)):(E=v.slice(0,S),this.leftOver=v.slice(S,v.length))),this.push({data:r.utf8decode(E),meta:y.meta})},p.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=p,i.inherits(m,l),m.prototype.processChunk=function(y){this.push({data:r.utf8encode(y.data),meta:y.meta})},r.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,s,r){var i=n("./support"),a=n("./base64"),o=n("./nodejsUtils"),l=n("./external");function c(b){return b}function h(b,S){for(var E=0;E<b.length;++E)S[E]=255&b.charCodeAt(E);return S}n("setimmediate"),r.newBlob=function(b,S){r.checkSupport("blob");try{return new Blob([b],{type:S})}catch{try{var E=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return E.append(b),E.getBlob(S)}catch{throw new Error("Bug : can't construct the Blob.")}}};var p={stringifyByChunk:function(b,S,E){var I=[],M=0,j=b.length;if(j<=E)return String.fromCharCode.apply(null,b);for(;M<j;)S==="array"||S==="nodebuffer"?I.push(String.fromCharCode.apply(null,b.slice(M,Math.min(M+E,j)))):I.push(String.fromCharCode.apply(null,b.subarray(M,Math.min(M+E,j)))),M+=E;return I.join("")},stringifyByChar:function(b){for(var S="",E=0;E<b.length;E++)S+=String.fromCharCode(b[E]);return S},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function m(b){var S=65536,E=r.getTypeOf(b),I=!0;if(E==="uint8array"?I=p.applyCanBeUsed.uint8array:E==="nodebuffer"&&(I=p.applyCanBeUsed.nodebuffer),I)for(;1<S;)try{return p.stringifyByChunk(b,E,S)}catch{S=Math.floor(S/2)}return p.stringifyByChar(b)}function y(b,S){for(var E=0;E<b.length;E++)S[E]=b[E];return S}r.applyFromCharCode=m;var v={};v.string={string:c,array:function(b){return h(b,new Array(b.length))},arraybuffer:function(b){return v.string.uint8array(b).buffer},uint8array:function(b){return h(b,new Uint8Array(b.length))},nodebuffer:function(b){return h(b,o.allocBuffer(b.length))}},v.array={string:m,array:c,arraybuffer:function(b){return new Uint8Array(b).buffer},uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return o.newBufferFrom(b)}},v.arraybuffer={string:function(b){return m(new Uint8Array(b))},array:function(b){return y(new Uint8Array(b),new Array(b.byteLength))},arraybuffer:c,uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return o.newBufferFrom(new Uint8Array(b))}},v.uint8array={string:m,array:function(b){return y(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:c,nodebuffer:function(b){return o.newBufferFrom(b)}},v.nodebuffer={string:m,array:function(b){return y(b,new Array(b.length))},arraybuffer:function(b){return v.nodebuffer.uint8array(b).buffer},uint8array:function(b){return y(b,new Uint8Array(b.length))},nodebuffer:c},r.transformTo=function(b,S){if(S=S||"",!b)return S;r.checkSupport(b);var E=r.getTypeOf(S);return v[E][b](S)},r.resolve=function(b){for(var S=b.split("/"),E=[],I=0;I<S.length;I++){var M=S[I];M==="."||M===""&&I!==0&&I!==S.length-1||(M===".."?E.pop():E.push(M))}return E.join("/")},r.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":i.nodebuffer&&o.isBuffer(b)?"nodebuffer":i.uint8array&&b instanceof Uint8Array?"uint8array":i.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(b){if(!i[b.toLowerCase()])throw new Error(b+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(b){var S,E,I="";for(E=0;E<(b||"").length;E++)I+="\\x"+((S=b.charCodeAt(E))<16?"0":"")+S.toString(16).toUpperCase();return I},r.delay=function(b,S,E){setImmediate(function(){b.apply(E||null,S||[])})},r.inherits=function(b,S){function E(){}E.prototype=S.prototype,b.prototype=new E},r.extend=function(){var b,S,E={};for(b=0;b<arguments.length;b++)for(S in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],S)&&E[S]===void 0&&(E[S]=arguments[b][S]);return E},r.prepareContent=function(b,S,E,I,M){return l.Promise.resolve(S).then(function(j){return i.blob&&(j instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(j))!==-1)&&typeof FileReader<"u"?new l.Promise(function(L,K){var D=new FileReader;D.onload=function(R){L(R.target.result)},D.onerror=function(R){K(R.target.error)},D.readAsArrayBuffer(j)}):j}).then(function(j){var L=r.getTypeOf(j);return L?(L==="arraybuffer"?j=r.transformTo("uint8array",j):L==="string"&&(M?j=a.decode(j):E&&I!==!0&&(j=(function(K){return h(K,i.uint8array?new Uint8Array(K.length):new Array(K.length))})(j))),j):l.Promise.reject(new Error("Can't read the data of '"+b+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,s,r){var i=n("./reader/readerFor"),a=n("./utils"),o=n("./signature"),l=n("./zipEntry"),c=n("./support");function h(p){this.files=[],this.loadOptions=p}h.prototype={checkSignature:function(p){if(!this.reader.readAndCheckSignature(p)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(m)+", expected "+a.pretty(p)+")")}},isSignature:function(p,m){var y=this.reader.index;this.reader.setIndex(p);var v=this.reader.readString(4)===m;return this.reader.setIndex(y),v},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var p=this.reader.readData(this.zipCommentLength),m=c.uint8array?"uint8array":"array",y=a.transformTo(m,p);this.zipComment=this.loadOptions.decodeFileName(y)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var p,m,y,v=this.zip64EndOfCentralSize-44;0<v;)p=this.reader.readInt(2),m=this.reader.readInt(4),y=this.reader.readData(m),this.zip64ExtensibleData[p]={id:p,length:m,value:y}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var p,m;for(p=0;p<this.files.length;p++)m=this.files[p],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var p;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(p=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(p);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var p=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(p<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip f
6703ile ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(p);var m=p;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(p=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(p),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var y=this.centralDirOffset+this.centralDirSize;this.zip64&&(y+=20,y+=12+this.zip64EndOfCentralSize);var v=m-y;if(0<v)this.isSignature(m,o.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(p){this.reader=i(p)},load:function(p){this.prepareReader(p),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},s.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,s,r){var i=n("./reader/readerFor"),a=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),h=n("./compressions"),p=n("./support");function m(y,v){this.options=y,this.loadOptions=v}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(y){var v,b;if(y.skip(22),this.fileNameLength=y.readInt(2),b=y.readInt(2),this.fileName=y.readData(this.fileNameLength),y.skip(b),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((v=(function(S){for(var E in h)if(Object.prototype.hasOwnProperty.call(h,E)&&h[E].magic===S)return h[E];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,v,y.readData(this.compressedSize))},readCentralPart:function(y){this.versionMadeBy=y.readInt(2),y.skip(2),this.bitFlag=y.readInt(2),this.compressionMethod=y.readString(2),this.date=y.readDate(),this.crc32=y.readInt(4),this.compressedSize=y.readInt(4),this.uncompressedSize=y.readInt(4);var v=y.readInt(2);if(this.extraFieldsLength=y.readInt(2),this.fileCommentLength=y.readInt(2),this.diskNumberStart=y.readInt(2),this.internalFileAttributes=y.readInt(2),this.externalFileAttributes=y.readInt(4),this.localHeaderOffset=y.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");y.skip(v),this.readExtraFields(y),this.parseZIP64ExtraField(y),this.fileComment=y.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var y=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),y==0&&(this.dosPermissions=63&this.externalFileAttributes),y==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var y=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=y.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=y.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&
vendor: 12,590 bytes, line 6703
6703(this.localHeaderOffset=y.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=y.readInt(4))}},readExtraFields:function(y){var v,b,S,E=y.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});y.index+4<E;)v=y.readInt(2),b=y.readInt(2),S=y.readData(b),this.extraFields[v]={id:v,length:b,value:S};y.setIndex(E)},handleUTF8:function(){var y=p.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var b=a.transformTo(y,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var S=this.findExtraFieldUnicodeComment();if(S!==null)this.fileCommentStr=S;else{var E=a.transformTo(y,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(E)}}},findExtraFieldUnicodePath:function(){var y=this.extraFields[28789];if(y){var v=i(y.value);return v.readInt(1)!==1||l(this.fileName)!==v.readInt(4)?null:c.utf8decode(v.readData(y.length-5))}return null},findExtraFieldUnicodeComment:function(){var y=this.extraFields[25461];if(y){var v=i(y.value);return v.readInt(1)!==1||l(this.fileComment)!==v.readInt(4)?null:c.utf8decode(v.readData(y.length-5))}return null}},s.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,s,r){function i(v,b,S){this.name=v,this.dir=S.dir,this.date=S.date,this.comment=S.comment,this.unixPermissions=S.unixPermissions,this.dosPermissions=S.dosPermissions,this._data=b,this._dataBinary=S.binary,this.options={compression:S.compression,compressionOptions:S.compressionOptions}}var a=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),h=n("./stream/GenericWorker");i.prototype={internalStream:function(v){var b=null,S="string";try{if(!v)throw new Error("No output type specified.");var E=(S=v.toLowerCase())==="string"||S==="text";S!=="binarystring"&&S!=="text"||(S="string"),b=this._decompressWorker();var I=!this._dataBinary;I&&!E&&(b=b.pipe(new l.Utf8EncodeWorker)),!I&&E&&(b=b.pipe(new l.Utf8DecodeWorker))}catch(M){(b=new h("error")).error(M)}return new a(b,S,"")},async:function(v,b){return this.internalStream(v).accumulate(b)},nodeStream:function(v,b){return this.internalStream(v||"nodebuffer").toNodejsStream(b)},_compressWorker:function(v,b){if(this._data instanceof c&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var S=this._decompressWorker();return this._dataBinary||(S=S.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(S,v,b)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new o(this._data)}};for(var p=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},y=0;y<p.length;y++)i.prototype[p[y]]=m;s.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,s,r){(function(i){var a,o,l=i.MutationObserver||i.WebKitMutationObserver;if(l){var c=0,h=new l(v),p=i.document.createTextNode("");h.observe(p,{characterData:!0}),a=function(){p.data=c=++c%2}}else if(i.setImmediate||i.MessageChannel===void 0)a="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var b=i.document.createElement("script");b.onreadystatechange=function(){v(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},i.document.documentElement.appendChild(b)}:function(){setTimeout(v,0)};else{var m=new i.MessageChannel;m.port1.onmessage=v,a=function(){m.port2.postMessage(0)}}var y=[];function v(){var b,S;o=!0;for(var E=y.length;E;){for(S=y,y=[],b=-1;++b<E;)S[b]();E=y.length}o=!1}s.exports=function(b){y.push(b)!==1||o||a()}}).call(this,typeof md<"u"?md:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,s,r){var i=n("immediate");function a(){}var o={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function p(E){if(typeof E!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,E!==a&&b(this,E)}function m(E,I,M){this.promise=E,typeof I=="function"&&(this.onFulfilled=I,this.callFulfilled=this.otherCallFulfilled),typeof M=="function"&&(this.onRejected=M,this.callRejected=this.otherCallRejected)}function y(E,I,M){i(function(){var j;try{j=I(M)}catch(L){return o.reject(E,L)}j===E?o.reject(E,new TypeError("Cannot resolve promise with itself")):o.resolve(E,j)})}function v(E){var I=E&&E.then;if(E&&(typeof E=="object"||typeof E=="function")&&typeof I=="function")return function(){I.apply(E,arguments)}}function b(E,I){var M=!1;function j(D){M||(M=!0,o.reject(E,D))}function L(D){M||(M=!0,o.resolve(E,D))}var K=S(function(){I(L,j)});K.status==="error"&&j(K.value)}function S(E,I){var M={};try{M.value=E(I),M.status="success"}catch(j){M.status="error",M.value=j}return M}(s.exports=p).prototype.finally=function(E){if(typeof E!="function")return this;var I=this.constructor;return this.then(function(M){return I.resolve(E()).then(function(){return M})},function(M){return I.resolve(E()).then(function(){throw M})})},p.prototype.catch=function(E){return this.then(null,E)},p.prototype.then=function(E,I){if(typeof E!="function"&&this.state===c||typeof I!="function"&&this.state===l)return this;var M=new this.constructor(a);return this.state!==h?y(M,this.state===c?E:I,this.outcome):this.queue.push(new m(M,E,I)),M},m.prototype.callFulfilled=function(E){o.resolve(this.promise,E)},m.prototype.otherCallFulfilled=function(E){y(this.promise,this.onFulfilled,E)},m.prototype.callRejected=function(E){o.reject(this.promise,E)},m.prototype.otherCallRejected=function(E){y(this.promise,this.onRejected,E)},o.resolve=function(E,I){var M=S(v,I);if(M.status==="error")return o.reject(E,M.value);var j=M.value;if(j)b(E,j);else{E.state=c,E.outcome=I;for(var L=-1,K=E.queue.length;++L<K;)E.queue[L].callFulfilled(I)}return E},o.reject=function(E,I){E.state=l,E.outcome=I;for(var M=-1,j=E.queue.length;++M<j;)E.queue[M].callRejected(I);return E},p.resolve=function(E){return E instanceof this?E:o.resolve(new this(a),E)},p.reject=function(E){var I=new this(a);return o.reject(I,E)},p.all=function(E){var I=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=E.length,j=!1;if(!M)return this.resolve([]);for(var L=new Array(M),K=0,D=-1,R=new this(a);++D<M;)B(E[D],D);return R;function B(G,X){I.resolve(G).then(function(H){L[X]=H,++K!==M||j||(j=!0,o.resolve(R,L))},function(H){j||(j=!0,o.reject(R,H))})}},p.race=function(E){var I=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=E.length,j=!1;if(!M)return this.resolve([]);for(var L=-1,K=new this(a);++L<M;)D=E[L],I.resolve(D).then(function(R){j||(j=!0,o.resolve(K,R))},function(R){j||(j=!0,o.reject(K,R))});var D;return K}},{immediate:36}],38:[function(n,s,r){var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),s.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,s,r){var i=n("./zlib/deflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),h=Object.prototype.toString,p=0,m=-1,y=0,v=8;function b(E){if(!(this instanceof b))return new b(E);this.options=a.assign({level:m,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:y,to:""},E||{});var I=this.options;I.raw&&0<I.windowBits?I.windowBits=-I.windowBits:I.gzip&&0<I.windowBits&&I.windowBits<16&&(I.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var M=i.deflateInit2(this.strm,I.level,I.method,I.windowBits,I.memLevel,I.strategy);if(M!==p)throw new Error(l[M]);if(I.header&&i.deflateSetHeader(this.strm,I.header),I.dictionary){var j;if(j=typeof I.dictionary=="string"?o.string2buf(I.dictionary):h.call(I.dictionary)==="[object ArrayBuffer]"?new Uint8Array(I.dictionary):I.dictionary,(M=i.deflateSetDictionary(this.strm,j))!==p)throw new Error(l[M]);this._dict_set=!0}}function S(E,I){var M=new b(I);if(M.push(E,!0),M.err)throw M.msg||l[M.err];return M.result}b.prototype.push=function(E,I){var M,j,L=this.strm,K=this.options.chunkSize;if(this.ended)return!1;j=I===~~I?I:I===!0?4:0,typeof E=="string"?L.input=o.string2buf(E):h.call(E)==="[object ArrayBuffer]"?L.input=new Uint8Array(E):L.input=E,L.next_in=0,L.avail_in=L.input.length;do{if(L.avail_out===0&&(L.output=new a.Buf8(K),L.next_out=0,L.avail_out=K),(M=i.deflate(L,j))!==1&&M!==p)return this.onEnd(M),!(this.ended=!0);L.avail_out!==0&&(L.avail_in!==0||j!==4&&j!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(L.output,L.next_out))):this.onData(a.shrinkBuf(L.output,L.next_out)))}while((0<L.avail_in||L.avail_out===0)&&M!==1);return j===4?(M=i.deflateEnd(this.strm),this.onEnd(M),this.ended=!0,M===p):j!==2||(this.onEnd(p),!(L.avail_out=0))},b.prototype.onData=function(E){this.chunks.push(E)},b.prototype.onEnd=function(E){E===p&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=E,this.msg=this.strm.msg},r.Deflate=b,r.deflate=S,r.deflateRaw=function(E,I){return(I=I||{}).raw=!0,S(E,I)},r.gzip=function(E,I){return(I=I||{}).gzip=!0,S(E,I)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,s,r){var i=n("./zlib/inflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),h=n("./zlib/zstream"),p=n("./zlib/gzheader"),m=Object.prototype.toString;function y(b){if(!(this instanceof y))return new y(b);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},b||{});var S=this.options;S.raw&&0<=S.windowBits&&S.windowBits<16&&(S.windowBits=-S.windowBits,S.windowBits===0&&(S.windowBits=-15)),!(0<=S.windowBits&&S.windowBits<16)||b&&b.windowBits||(S.windowBits+=32),15<S.windowBits&&S.windowBits<48&&(15&S.windowBits)==0&&(S.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var E=i.inflateInit2(this.strm,S.windowBits);if(E!==l.Z_OK)throw new Error(c[E]);this.header=new p,i.inflateGetHeader(this.strm,this.header)}function v(b,S){var E=new y(S);if(E.push(b,!0),E.err)throw E.msg||c[E.err];return E.result}y.prototype.push=function(b,S){var E,I,M,j,L,K,D=this.strm,R=this.options.chunkSize,B=this.options.dictionary,G=!1;if(this.ended)return!1;I=S===~~S?S:S===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof b=="string"?D.input=o.binstring2buf(b):m.call(b)==="[object ArrayBuffer]"?D.input=new Uint8Array(b):D.input=b,D.next_in=0,D.avail_in=D.input.length;do{if(D.avail_out===0&&(D.output=new a.Buf8(R),D.next_out=0,D.avail_out=R),(E=i.inflate(D,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&B&&(K=typeof B=="string"?o.string2buf(B):m.call(B)==="[object ArrayBuffer]"?new Uint8Array(B):B,E=i.inflateSetDictionary(this.strm,K)),E===l.Z_BUF_ERROR&&G===!0&&(E=l.Z_OK,G=!1),E!==l.Z_STREAM_END&&E!==l.Z_OK)return this.onEnd(E),!(this.ended=!0);D.next_out&&(D.avail_out!==0&&E!==l.Z_STREAM_END&&(D.avail_in!==0||I!==l.Z_FINISH&&I!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(M=o.utf8border(D.output,D.next_out),j=D.next_out-M,L=o.buf2string(D.output,M),D.next_out=j,D.avail_out=R-j,j&&a.arraySet(D.output,D.output,M,j,0),this.onData(L)):this.onData(a.shrinkBuf(D.output,D.next_out)))),D.avail_in===0&&D.avail_out===0&&(G=!0)}while((0<D.avail_in||D.avail_out===0)&&E!==l.Z_STREAM_END);return E===l.Z_STREAM_END&&(I=l.Z_FINISH),I===l.Z_FINISH?(E=i.inflateEnd(this.strm),this.onEnd(E),this.ended=!0,E===l.Z_OK):I!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(D.avail_out=0))},y.prototype.onData=function(b){this.chunks.push(b)},y.prototype.onEnd=function(b){b===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},r.Inflate=y,r.inflate=v,r.inflateRaw=function(b,S){return(S=S||{}).raw=!0,v(b,S)},r.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,s,r){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1
vendor: 4,101 bytes, line 6703
6703);c.length;){var h=c.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var p in h)h.hasOwnProperty(p)&&(l[p]=h[p])}}return l},r.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var a={arraySet:function(l,c,h,p,m){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+p),m);else for(var y=0;y<p;y++)l[m+y]=c[h+y]},flattenChunks:function(l){var c,h,p,m,y,v;for(c=p=0,h=l.length;c<h;c++)p+=l[c].length;for(v=new Uint8Array(p),c=m=0,h=l.length;c<h;c++)y=l[c],v.set(y,m),m+=y.length;return v}},o={arraySet:function(l,c,h,p,m){for(var y=0;y<p;y++)l[m+y]=c[h+y]},flattenChunks:function(l){return[].concat.apply([],l)}};r.setTyped=function(l){l?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,o))},r.setTyped(i)},{}],42:[function(n,s,r){var i=n("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new i.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(p,m){if(m<65537&&(p.subarray&&o||!p.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(p,m));for(var y="",v=0;v<m;v++)y+=String.fromCharCode(p[v]);return y}l[254]=l[254]=1,r.string2buf=function(p){var m,y,v,b,S,E=p.length,I=0;for(b=0;b<E;b++)(64512&(y=p.charCodeAt(b)))==55296&&b+1<E&&(64512&(v=p.charCodeAt(b+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),b++),I+=y<128?1:y<2048?2:y<65536?3:4;for(m=new i.Buf8(I),b=S=0;S<I;b++)(64512&(y=p.charCodeAt(b)))==55296&&b+1<E&&(64512&(v=p.charCodeAt(b+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),b++),y<128?m[S++]=y:(y<2048?m[S++]=192|y>>>6:(y<65536?m[S++]=224|y>>>12:(m[S++]=240|y>>>18,m[S++]=128|y>>>12&63),m[S++]=128|y>>>6&63),m[S++]=128|63&y);return m},r.buf2binstring=function(p){return h(p,p.length)},r.binstring2buf=function(p){for(var m=new i.Buf8(p.length),y=0,v=m.length;y<v;y++)m[y]=p.charCodeAt(y);return m},r.buf2string=function(p,m){var y,v,b,S,E=m||p.length,I=new Array(2*E);for(y=v=0;y<E;)if((b=p[y++])<128)I[v++]=b;else if(4<(S=l[b]))I[v++]=65533,y+=S-1;else{for(b&=S===2?31:S===3?15:7;1<S&&y<E;)b=b<<6|63&p[y++],S--;1<S?I[v++]=65533:b<65536?I[v++]=b:(b-=65536,I[v++]=55296|b>>10&1023,I[v++]=56320|1023&b)}return h(I,v)},r.utf8border=function(p,m){var y;for((m=m||p.length)>p.length&&(m=p.length),y=m-1;0<=y&&(192&p[y])==128;)y--;return y<0||y===0?m:y+l[p[y]]>m?y:m}},{"./common":41}],43:[function(n,s,r){s.exports=function(i,a,o,l){for(var c=65535&i|0,h=i>>>16&65535|0,p=0;o!==0;){for(o-=p=2e3<o?2e3:o;h=h+(c=c+a[l++]|0)|0,--p;);c%=65521,h%=65521}return c|h<<16|0}},{}],44:[function(n,s,r){s.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,s,r){var i=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();s.exports=function(a,o,l,c){var h=i,p=c+l;a^=-1;for(var m=c;m<p;m++)a=a>>>8^h[255&(a^o[m])];return-1^a}},{}],46:[function(n,s,r){var i,a=n("../utils/common"),o=n("./trees"),l=n("./adler32"),c=n("./crc32"),h=n("./messages"),p=0,m=4,y=0,v=-2,b=-1,S=4,E=2,I=8,M=9,j=286,L=30,K=19,D=2*j+1,R=15,B=3,G=258,X=G+B+1,H=42,Y=113,F=1,we=2,me=3,xe=4;function Le(J,We){return J.msg=h[We],We}function ve(J){return(J<<1)-(4<J?9:0)}function ce(J){for(var We=J.length;0<=--We;)J[We]=0}function ie(J){var We=J.state,Ie=We.pending;Ie>J.avail_out&&(Ie=J.avail_out),Ie!==0&&(a.arraySet(J.output,We.pending_buf,We.pending_out,Ie,J.next_out),J.next_out+=Ie,We.pending_out+=Ie,J.total_out+=Ie,J.avail_out-=Ie,We.pending-=Ie,We.pending===0&&(We.pending_out=0))}function de(J,We){o._tr_flush_block(J,0<=J.block_start?J.block_start:-1,J.strstart-J.block_start,We),J.block_start=J.strstart,ie(J.strm)}
vendor: 36,329 bytes, line 6703
6703function Re(J,We){J.pending_buf[J.pending++]=We}function Se(J,We){J.pending_buf[J.pending++]=We>>>8&255,J.pending_buf[J.pending++]=255&We}function De(J,We){var Ie,ge,he=J.max_chain_length,Ae=J.strstart,et=J.prev_length,nt=J.nice_match,He=J.strstart>J.w_size-X?J.strstart-(J.w_size-X):0,ft=J.window,Mt=J.w_mask,pt=J.prev,Oe=J.strstart+G,hn=ft[Ae+et-1],Yt=ft[Ae+et];J.prev_length>=J.good_match&&(he>>=2),nt>J.lookahead&&(nt=J.lookahead);do if(ft[(Ie=We)+et]===Yt&&ft[Ie+et-1]===hn&&ft[Ie]===ft[Ae]&&ft[++Ie]===ft[Ae+1]){Ae+=2,Ie++;do;while(ft[++Ae]===ft[++Ie]&&ft[++Ae]===ft[++Ie]&&ft[++Ae]===ft[++Ie]&&ft[++Ae]===ft[++Ie]&&ft[++Ae]===ft[++Ie]&&ft[++Ae]===ft[++Ie]&&ft[++Ae]===ft[++Ie]&&ft[++Ae]===ft[++Ie]&&Ae<Oe);if(ge=G-(Oe-Ae),Ae=Oe-G,et<ge){if(J.match_start=We,nt<=(et=ge))break;hn=ft[Ae+et-1],Yt=ft[Ae+et]}}while((We=pt[We&Mt])>He&&--he!=0);return et<=J.lookahead?et:J.lookahead}function gt(J){var We,Ie,ge,he,Ae,et,nt,He,ft,Mt,pt=J.w_size;do{if(he=J.window_size-J.lookahead-J.strstart,J.strstart>=pt+(pt-X)){for(a.arraySet(J.window,J.window,pt,pt,0),J.match_start-=pt,J.strstart-=pt,J.block_start-=pt,We=Ie=J.hash_size;ge=J.head[--We],J.head[We]=pt<=ge?ge-pt:0,--Ie;);for(We=Ie=pt;ge=J.prev[--We],J.prev[We]=pt<=ge?ge-pt:0,--Ie;);he+=pt}if(J.strm.avail_in===0)break;if(et=J.strm,nt=J.window,He=J.strstart+J.lookahead,ft=he,Mt=void 0,Mt=et.avail_in,ft<Mt&&(Mt=ft),Ie=Mt===0?0:(et.avail_in-=Mt,a.arraySet(nt,et.input,et.next_in,Mt,He),et.state.wrap===1?et.adler=l(et.adler,nt,Mt,He):et.state.wrap===2&&(et.adler=c(et.adler,nt,Mt,He)),et.next_in+=Mt,et.total_in+=Mt,Mt),J.lookahead+=Ie,J.lookahead+J.insert>=B)for(Ae=J.strstart-J.insert,J.ins_h=J.window[Ae],J.ins_h=(J.ins_h<<J.hash_shift^J.window[Ae+1])&J.hash_mask;J.insert&&(J.ins_h=(J.ins_h<<J.hash_shift^J.window[Ae+B-1])&J.hash_mask,J.prev[Ae&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=Ae,Ae++,J.insert--,!(J.lookahead+J.insert<B)););}while(J.lookahead<X&&J.strm.avail_in!==0)}function yt(J,We){for(var Ie,ge;;){if(J.lookahead<X){if(gt(J),J.lookahead<X&&We===p)return F;if(J.lookahead===0)break}if(Ie=0,J.lookahead>=B&&(J.ins_h=(J.ins_h<<J.hash_shift^J.window[J.strstart+B-1])&J.hash_mask,Ie=J.prev[J.strstart&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=J.strstart),Ie!==0&&J.strstart-Ie<=J.w_size-X&&(J.match_length=De(J,Ie)),J.match_length>=B)if(ge=o._tr_tally(J,J.strstart-J.match_start,J.match_length-B),J.lookahead-=J.match_length,J.match_length<=J.max_lazy_match&&J.lookahead>=B){for(J.match_length--;J.strstart++,J.ins_h=(J.ins_h<<J.hash_shift^J.window[J.strstart+B-1])&J.hash_mask,Ie=J.prev[J.strstart&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=J.strstart,--J.match_length!=0;);J.strstart++}else J.strstart+=J.match_length,J.match_length=0,J.ins_h=J.window[J.strstart],J.ins_h=(J.ins_h<<J.hash_shift^J.window[J.strstart+1])&J.hash_mask;else ge=o._tr_tally(J,0,J.window[J.strstart]),J.lookahead--,J.strstart++;if(ge&&(de(J,!1),J.strm.avail_out===0))return F}return J.insert=J.strstart<B-1?J.strstart:B-1,We===m?(de(J,!0),J.strm.avail_out===0?me:xe):J.last_lit&&(de(J,!1),J.strm.avail_out===0)?F:we}function xt(J,We){for(var Ie,ge,he;;){if(J.lookahead<X){if(gt(J),J.lookahead<X&&We===p)return F;if(J.lookahead===0)break}if(Ie=0,J.lookahead>=B&&(J.ins_h=(J.ins_h<<J.hash_shift^J.window[J.strstart+B-1])&J.hash_mask,Ie=J.prev[J.strstart&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=J.strstart),J.prev_length=J.match_length,J.prev_match=J.match_start,J.match_length=B-1,Ie!==0&&J.prev_length<J.max_lazy_match&&J.strstart-Ie<=J.w_size-X&&(J.match_length=De(J,Ie),J.match_length<=5&&(J.strategy===1||J.match_length===B&&4096<J.strstart-J.match_start)&&(J.match_length=B-1)),J.prev_length>=B&&J.match_length<=J.prev_length){for(he=J.strstart+J.lookahead-B,ge=o._tr_tally(J,J.strstart-1-J.prev_match,J.prev_length-B),J.lookahead-=J.prev_length-1,J.prev_length-=2;++J.strstart<=he&&(J.ins_h=(J.ins_h<<J.hash_shift^J.window[J.strstart+B-1])&J.hash_mask,Ie=J.prev[J.strstart&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=J.strstart),--J.prev_length!=0;);if(J.match_available=0,J.match_length=B-1,J.strstart++,ge&&(de(J,!1),J.strm.avail_out===0))return F}else if(J.match_available){if((ge=o._tr_tally(J,0,J.window[J.strstart-1]))&&de(J,!1),J.strstart++,J.lookahead--,J.strm.avail_out===0)return F}else J.match_available=1,J.strstart++,J.lookahead--}return J.match_available&&(ge=o._tr_tally(J,0,J.window[J.strstart-1]),J.match_available=0),J.insert=J.strstart<B-1?J.strstart:B-1,We===m?(de(J,!0),J.strm.avail_out===0?me:xe):J.last_lit&&(de(J,!1),J.strm.avail_out===0)?F:we}function Nt(J,We,Ie,ge,he){this.good_length=J,this.max_lazy=We,this.nice_length=Ie,this.max_chain=ge,this.func=he}function wt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=I,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*D),this.dyn_dtree=new a.Buf16(2*(2*L+1)),this.bl_tree=new a.Buf16(2*(2*K+1)),ce(this.dyn_ltree),ce(this.dyn_dtree),ce(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(R+1),this.heap=new a.Buf16(2*j+1),ce(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*j+1),ce(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function zt(J){var We;return J&&J.state?(J.total_in=J.total_out=0,J.data_type=E,(We=J.state).pending=0,We.pending_out=0,We.wrap<0&&(We.wrap=-We.wrap),We.status=We.wrap?H:Y,J.adler=We.wrap===2?0:1,We.last_flush=p,o._tr_init(We),y):Le(J,v)}function _n(J){var We=zt(J);return We===y&&(function(Ie){Ie.window_size=2*Ie.w_size,ce(Ie.head),Ie.max_lazy_match=i[Ie.level].max_lazy,Ie.good_match=i[Ie.level].good_length,Ie.nice_match=i[Ie.level].nice_length,Ie.max_chain_length=i[Ie.level].max_chain,Ie.strstart=0,Ie.block_start=0,Ie.lookahead=0,Ie.insert=0,Ie.match_length=Ie.prev_length=B-1,Ie.match_available=0,Ie.ins_h=0})(J.state),We}function Zt(J,We,Ie,ge,he,Ae){if(!J)return v;var et=1;if(We===b&&(We=6),ge<0?(et=0,ge=-ge):15<ge&&(et=2,ge-=16),he<1||M<he||Ie!==I||ge<8||15<ge||We<0||9<We||Ae<0||S<Ae)return Le(J,v);ge===8&&(ge=9);var nt=new wt;return(J.state=nt).strm=J,nt.wrap=et,nt.gzhead=null,nt.w_bits=ge,nt.w_size=1<<nt.w_bits,nt.w_mask=nt.w_size-1,nt.hash_bits=he+7,nt.hash_size=1<<nt.hash_bits,nt.hash_mask=nt.hash_size-1,nt.hash_shift=~~((nt.hash_bits+B-1)/B),nt.window=new a.Buf8(2*nt.w_size),nt.head=new a.Buf16(nt.hash_size),nt.prev=new a.Buf16(nt.w_size),nt.lit_bufsize=1<<he+6,nt.pending_buf_size=4*nt.lit_bufsize,nt.pending_buf=new a.Buf8(nt.pending_buf_size),nt.d_buf=1*nt.lit_bufsize,nt.l_buf=3*nt.lit_bufsize,nt.level=We,nt.strategy=Ae,nt.method=Ie,_n(J)}i=[new Nt(0,0,0,0,function(J,We){var Ie=65535;for(Ie>J.pending_buf_size-5&&(Ie=J.pending_buf_size-5);;){if(J.lookahead<=1){if(gt(J),J.lookahead===0&&We===p)return F;if(J.lookahead===0)break}J.strstart+=J.lookahead,J.lookahead=0;var ge=J.block_start+Ie;if((J.strstart===0||J.strstart>=ge)&&(J.lookahead=J.strstart-ge,J.strstart=ge,de(J,!1),J.strm.avail_out===0)||J.strstart-J.block_start>=J.w_size-X&&(de(J,!1),J.strm.avail_out===0))return F}return J.insert=0,We===m?(de(J,!0),J.strm.avail_out===0?me:xe):(J.strstart>J.block_start&&(de(J,!1),J.strm.avail_out),F)}),new Nt(4,4,8,4,yt),new Nt(4,5,16,8,yt),new Nt(4,6,32,32,yt),new Nt(4,4,16,16,xt),new Nt(8,16,32,32,xt),new Nt(8,16,128,128,xt),new Nt(8,32,128,256,xt),new Nt(32,128,258,1024,xt),new Nt(32,258,258,4096,xt)],r.deflateInit=function(J,We){return Zt(J,We,I,15,8,0)},r.deflateInit2=Zt,r.deflateReset=_n,r.deflateResetKeep=zt,r.deflateSetHeader=function(J,We){return J&&J.state?J.state.wrap!==2?v:(J.state.gzhead=We,y):v},r.deflate=function(J,We){var Ie,ge,he,Ae;if(!J||!J.state||5<We||We<0)return J?Le(J,v):v;if(ge=J.state,!J.output||!J.input&&J.avail_in!==0||ge.status===666&&We!==m)return Le(J,J.avail_out===0?-5:v);if(ge.strm=J,Ie=ge.last_flush,ge.last_flush=We,ge.status===H)if(ge.wrap===2)J.adler=0,Re(ge,31),Re(ge,139),Re(ge,8),ge.gzhead?(Re(ge,(ge.gzhead.text?1:0)+(ge.gzhead.hcrc?2:0)+(ge.gzhead.extra?4:0)+(ge.gzhead.name?8:0)+(ge.gzhead.comment?16:0)),Re(ge,255&ge.gzhead.time),Re(ge,ge.gzhead.time>>8&255),Re(ge,ge.gzhead.time>>16&255),Re(ge,ge.gzhead.time>>24&255),Re(ge,ge.level===9?2:2<=ge.strategy||ge.level<2?4:0),Re(ge,255&ge.gzhead.os),ge.gzhead.extra&&ge.gzhead.extra.length&&(Re(ge,255&ge.gzhead.extra.length),Re(ge,ge.gzhead.extra.length>>8&255)),ge.gzhead.hcrc&&(J.adler=c(J.adler,ge.pending_buf,ge.pending,0)),ge.gzindex=0,ge.status=69):(Re(ge,0),Re(ge,0),Re(ge,0),Re(ge,0),Re(ge,0),Re(ge,ge.level===9?2:2<=ge.strategy||ge.level<2?4:0),Re(ge,3),ge.status=Y);else{var et=I+(ge.w_bits-8<<4)<<8;et|=(2<=ge.strategy||ge.level<2?0:ge.level<6?1:ge.level===6?2:3)<<6,ge.strstart!==0&&(et|=32),et+=31-et%31,ge.status=Y,Se(ge,et),ge.strstart!==0&&(Se(ge,J.adler>>>16),Se(ge,65535&J.adler)),J.adler=1}if(ge.status===69)if(ge.gzhead.extra){for(he=ge.pending;ge.gzindex<(65535&ge.gzhead.extra.length)&&(ge.pending!==ge.pending_buf_size||(ge.gzhead.hcrc&&ge.pending>he&&(J.adler=c(J.adler,ge.pending_buf,ge.pending-he,he)),ie(J),he=ge.pending,ge.pending!==ge.pending_buf_size));)Re(ge,255&ge.gzhead.extra[ge.gzindex]),ge.gzindex++;ge.gzhead.hcrc&&ge.pending>he&&(J.adler=c(J.adler,ge.pending_buf,ge.pending-he,he)),ge.gzindex===ge.gzhead.extra.length&&(ge.gzindex=0,ge.status=73)}else ge.status=73;if(ge.status===73)if(ge.gzhead.name){he=ge.pending;do{if(ge.pending===ge.pending_buf_size&&(ge.gzhead.hcrc&&ge.pending>he&&(J.adler=c(J.adler,ge.pending_buf,ge.pending-he,he)),ie(J),he=ge.pending,ge.pending===ge.pending_buf_size)){Ae=1;break}Ae=ge.gzindex<ge.gzhead.name.length?255&ge.gzhead.name.charCodeAt(ge.gzindex++):0,Re(ge,Ae)}while(Ae!==0);ge.gzhead.hcrc&&ge.pending>he&&(J.adler=c(J.adler,ge.pending_buf,ge.pending-he,he)),Ae===0&&(ge.gzindex=0,ge.status=91)}else ge.status=91;if(ge.status===91)if(ge.gzhead.comment){he=ge.pending;do{if(ge.pending===ge.pending_buf_size&&(ge.gzhead.hcrc&&ge.pending>he&&(J.adler=c(J.adler,ge.pending_buf,ge.pending-he,he)),ie(J),he=ge.pending,ge.pending===ge.pending_buf_size)){Ae=1;break}Ae=ge.gzindex<ge.gzhead.comment.length?255&ge.gzhead.comment.charCodeAt(ge.gzindex++):0,Re(ge,Ae)}while(Ae!==0);ge.gzhead.hcrc&&ge.pending>he&&(J.adler=c(J.adler,ge.pending_buf,ge.pending-he,he)),Ae===0&&(ge.status=103)}else ge.status=103;if(ge.status===103&&(ge.gzhead.hcrc?(ge.pending+2>ge.pending_buf_size&&ie(J),ge.pending+2<=ge.pending_buf_size&&(Re(ge,255&J.adler),Re(ge,J.adler>>8&255),J.adler=0,ge.status=Y)):ge.status=Y),ge.pending!==0){if(ie(J),J.avail_out===0)return ge.last_flush=-1,y}else if(J.avail_in===0&&ve(We)<=ve(Ie)&&We!==m)return Le(J,-5);if(ge.status===666&&J.avail_in!==0)return Le(J,-5);if(J.avail_in!==0||ge.lookahead!==0||We!==p&&ge.status!==666){var nt=ge.strategy===2?(function(He,ft){for(var Mt;;){if(He.lookahead===0&&(gt(He),He.lookahead===0)){if(ft===p)return F;break}if(He.match_length=0,Mt=o._tr_tally(He,0,He.window[He.strstart]),He.lookahead--,He.strstart++,Mt&&(de(He,!1),He.strm.avail_out===0))return F}return He.insert=0,ft===m?(de(He,!0),He.strm.avail_out===0?me:xe):He.last_lit&&(de(He,!1),He.strm.avail_out===0)?F:we})(ge,We):ge.strategy===3?(function(He,ft){for(var Mt,pt,Oe,hn,Yt=He.window;;){if(He.lookahead<=G){if(gt(He),He.lookahead<=G&&ft===p)return F;if(He.lookahead===0)break}if(He.match_length=0,He.lookahead>=B&&0<He.strstart&&(pt=Yt[Oe=He.strstart-1])===Yt[++Oe]&&pt===Yt[++Oe]&&pt===Yt[++Oe]){hn=He.strstart+G;do;while(pt===Yt[++Oe]&&pt===Yt[++Oe]&&pt===Yt[++Oe]&&pt===Yt[++Oe]&&pt===Yt[++Oe]&&pt===Yt[++Oe]&&pt===Yt[++Oe]&&pt===Yt[++Oe]&&Oe<hn);He.match_length=G-(hn-Oe),He.match_length>He.lookahead&&(He.match_length=He.lookahead)}if(He.match_length>=B?(Mt=o._tr_tally(He,1,He.match_length-B),He.lookahead-=He.match_length,He.strstart+=He.match_length,He.match_length=0):(Mt=o._tr_tally(He,0,He.window[He.strstart]),He.lookahead--,He.strstart++),Mt&&(de(He,!1),He.strm.avail_out===0))return F}return He.insert=0,ft===m?(de(He,!0),He.strm.avail_out===0?me:xe):He.last_lit&&(de(He,!1),He.strm.avail_out===0)?F:we})(ge,We):i[ge.level].func(ge,We);if(nt!==me&&nt!==xe||(ge.status=666),nt===F||nt===me)return J.avail_out===0&&(ge.last_flush=-1),y;if(nt===we&&(We===1?o._tr_align(ge):We!==5&&(o._tr_stored_block(ge,0,0,!1),We===3&&(ce(ge.head),ge.lookahead===0&&(ge.strstart=0,ge.block_start=0,ge.insert=0))),ie(J),J.avail_out===0))return ge.last_flush=-1,y}return We!==m?y:ge.wrap<=0?1:(ge.wrap===2?(Re(ge,255&J.adler),Re(ge,J.adler>>8&255),Re(ge,J.adler>>16&255),Re(ge,J.adler>>24&255),Re(ge,255&J.total_in),Re(ge,J.total_in>>8&255),Re(ge,J.total_in>>16&255),Re(ge,J.total_in>>24&255)):(Se(ge,J.adler>>>16),Se(ge,65535&J.adler)),ie(J),0<ge.wrap&&(ge.wrap=-ge.wrap),ge.pending!==0?y:1)},r.deflateEnd=function(J){var We;return J&&J.state?(We=J.state.status)!==H&&We!==69&&We!==73&&We!==91&&We!==103&&We!==Y&&We!==666?Le(J,v):(J.state=null,We===Y?Le(J,-3):y):v},r.deflateSetDictionary=function(J,We){var Ie,ge,he,Ae,et,nt,He,ft,Mt=We.length;if(!J||!J.state||(Ae=(Ie=J.state).wrap)===2||Ae===1&&Ie.status!==H||Ie.lookahead)return v;for(Ae===1&&(J.adler=l(J.adler,We,Mt,0)),Ie.wrap=0,Mt>=Ie.w_size&&(Ae===0&&(ce(Ie.head),Ie.strstart=0,Ie.block_start=0,Ie.insert=0),ft=new a.Buf8(Ie.w_size),a.arraySet(ft,We,Mt-Ie.w_size,Ie.w_size,0),We=ft,Mt=Ie.w_size),et=J.avail_in,nt=J.next_in,He=J.input,J.avail_in=Mt,J.next_in=0,J.input=We,gt(Ie);Ie.lookahead>=B;){for(ge=Ie.strstart,he=Ie.lookahead-(B-1);Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[ge+B-1])&Ie.hash_mask,Ie.prev[ge&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=ge,ge++,--he;);Ie.strstart=ge,Ie.lookahead=B-1,gt(Ie)}return Ie.strstart+=Ie.lookahead,Ie.block_start=Ie.strstart,Ie.insert=Ie.lookahead,Ie.lookahead=0,Ie.match_length=Ie.prev_length=B-1,Ie.match_available=0,J.next_in=nt,J.input=He,J.avail_in=et,Ie.wrap=Ae,y},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,s,r){s.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,s,r){s.exports=function(i,a){var o,l,c,h,p,m,y,v,b,S,E,I,M,j,L,K,D,R,B,G,X,H,Y,F,we;o=i.state,l=i.next_in,F=i.input,c=l+(i.avail_in-5),h=i.next_out,we=i.output,p=h-(a-i.avail_out),m=h+(i.avail_out-257),y=o.dmax,v=o.wsize,b=o.whave,S=o.wnext,E=o.window,I=o.hold,M=o.bits,j=o.lencode,L=o.distcode,K=(1<<o.lenbits)-1,D=(1<<o.distbits)-1;e:do{M<15&&(I+=F[l++]<<M,M+=8,I+=F[l++]<<M,M+=8),R=j[I&K];t:for(;;){if(I>>>=B=R>>>24,M-=B,(B=R>>>16&255)===0)we[h++]=65535&R;else{if(!(16&B)){if((64&B)==0){R=j[(65535&R)+(I&(1<<B)-1)];continue t}if(32&B){o.mode=12;break e}i.msg="invalid literal/length code",o.mode=30;break e}G=65535&R,(B&=15)&&(M<B&&(I+=F[l++]<<M,M+=8),G+=I&(1<<B)-1,I>>>=B,M-=B),M<15&&(I+=F[l++]<<M,M+=8,I+=F[l++]<<M,M+=8),R=L[I&D];n:for(;;){if(I>>>=B=R>>>24,M-=B,!(16&(B=R>>>16&255))){if((64&B)==0){R=L[(65535&R)+(I&(1<<B)-1)];continue n}i.msg="invalid distance code",o.mode=30;break e}if(X=65535&R,M<(B&=15)&&(I+=F[l++]<<M,(M+=8)<B&&(I+=F[l++]<<M,M+=8)),y<(X+=I&(1<<B)-1)){i.msg="invalid distance too far back",o.mode=30;break e}if(I>>>=B,M-=B,(B=h-p)<X){if(b<(B=X-B)&&o.sane){i.msg="invalid distance too far back",o.mode=30;break e}if(Y=E,(H=0)===S){if(H+=v-B,B<G){for(G-=B;we[h++]=E[H++],--B;);H=h-X,Y=we}}else if(S<B){if(H+=v+S-B,(B-=S)<G){for(G-=B;we[h++]=E[H++],--B;);if(H=0,S<G){for(G-=B=S;we[h++]=E[H++],--B;);H=h-X,Y=we}}}else if(H+=S-B,B<G){for(G-=B;we[h++]=E[H++],--B;);H=h-X,Y=we}for(;2<G;)we[h++]=Y[H++],we[h++]=Y[H++],we[h++]=Y[H++],G-=3;G&&(we[h++]=Y[H++],1<G&&(we[h++]=Y[H++]))}else{for(H=h-X;we[h++]=we[H++],we[h++]=we[H++],we[h++]=we[H++],2<(G-=3););G&&(we[h++]=we[H++],1<G&&(we[h++]=we[H++]))}break}}break}}while(l<c&&h<m);l-=G=M>>3,I&=(1<<(M-=G<<3))-1,i.next_in=l,i.next_out=h,i.avail_in=l<c?c-l+5:5-(l-c),i.avail_out=h<m?m-h+257:257-(h-m),o.hold=I,o.bits=M}},{}],49:[function(n,s,r){var i=n("../utils/common"),a=n("./adler32"),o=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),h=1,p=2,m=0,y=-2,v=1,b=852,S=592;function E(H){return(H>>>24&255)+(H>>>8&65280)+((65280&H)<<8)+((255&H)<<24)}function I(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(H){var Y;return H&&H.state?(Y=H.state,H.total_in=H.total_out=Y.total=0,H.msg="",Y.wrap&&(H.adler=1&Y.wrap),Y.mode=v,Y.last=0,Y.havedict=0,Y.dmax=32768,Y.head=null,Y.hold=0,Y.bits=0,Y.lencode=Y.lendyn=new i.Buf32(b),Y.distcode=Y.distdyn=new i.Buf32(S),Y.sane=1,Y.back=-1,m):y}function j(H){var Y;return H&&H.state?((Y=H.state).wsize=0,Y.whave=0,Y.wnext=0,M(H)):y}function L(H,Y){var F,we;return H&&H.state?(we=H.state,Y<0?(F=0,Y=-Y):(F=1+(Y>>4),Y<48&&(Y&=15)),Y&&(Y<8||15<Y)?y:(we.window!==null&&we.wbits!==Y&&(we.window=null),we.wrap=F,we.wbits=Y,j(H))):y}function K(H,Y){var F,we;return H?(we=new I,(H.state=we).window=null,(F=L(H,Y))!==m&&(H.state=null),F):y}var D,R,B=!0;function G(H){if(B){var Y;for(D=new i.Buf32(512),R=new i.Buf32(32),Y=0;Y<144;)H.lens[Y++]=8;for(;Y<256;)H.lens[Y++]=9;for(;Y<280;)H.lens[Y++]=7;for(;Y<288;)H.lens[Y++]=8;for(c(h,H.lens,0,288,D,0,H.work,{bits:9}),Y=0;Y<32;)H.lens[Y++]=5;c(p,H.lens,0,32,R,0,H.work,{bits:5}),B=!1}H.lencode=D,H.lenbits=9,H.distcode=R,H.distbits=5}function X(H,Y,F,we){var me,xe=H.state;return xe.window===null&&(xe.wsize=1<<xe.wbits,xe.wnext=0,xe.whave=0,xe.window=new i.Buf8(xe.wsize)),we>=xe.wsize?(i.arraySet(xe.window,Y,F-xe.wsize,xe.wsize,0),xe.wnext=0,xe.whave=xe.wsize):(we<(me=xe.wsize-xe.wnext)&&(me=we),i.arraySet(xe.window,Y,F-we,me,xe.wnext),(we-=me)?(i.arraySet(xe.window,Y,F-we,we,0),xe.wnext=we,xe.whave=xe.wsize):(xe.wnext+=me,xe.wnext===xe.wsize&&(xe.wnext=0),xe.whave<xe.wsize&&(xe.whave+=me))),0}r.inflateReset=j,r.inflateReset2=L,r.inflateResetKeep=M,r.inflateInit=function(H){return K(H,15)},r.inflateInit2=K,r.inflate=function(H,Y){var F,we,me,xe,Le,ve,ce,ie,de,Re,Se,De,gt,yt,xt,Nt,wt,zt,_n,Zt,J,We,Ie,ge,he=0,Ae=new i.Buf8(4),et=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!H||!H.state||!H.output||!H.input&&H.avail_in!==0)return y;(F=H.state).mode===12&&(F.mode=13),Le=H.next_out,me=H.output,ce=H.avail_out,xe=H.next_in,we=H.input,ve=H.avail_in,ie=F.hold,de=F.bits,Re=ve,Se=ce,We=m;e:for(;;)switch(F.mode){case v:if(F.wrap===0){F.mode=13;break}for(;de<16;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(2&F.wrap&&ie===35615){Ae[F.check=0]=255&ie,Ae[1]=ie>>>8&255,F.check=o(F.check,Ae,2,0),de=ie=0,F.mode=2;break}if(F.flags=0,F.head&&(F.head.done=!1),!(1&F.wrap)||(((255&ie)<<8)+(ie>>8))%31){H.msg="incorrect header check",F.mode=30;break}if((15&ie)!=8){H.msg="unknown compression method",F.mode=30;break}if(de-=4,J=8+(15&(ie>>>=4)),F.wbits===0)F.wbits=J;else if(J>F.wbits){H.msg="invalid window size",F.mode=30;break}F.dmax=1<<J,H.adler=F.check=1,F.mode=512&ie?10:12,de=ie=0;break;case 2:for(;de<16;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(F.flags=ie,(255&F.flags)!=8){H.msg="unknown compression method",F.mode=30;break}if(57344&F.flags){H.msg="unknown header flags set",F.mode=30;break}F.head&&(F.head.text=ie>>8&1),512&F.flags&&(Ae[0]=255&ie,Ae[1]=ie>>>8&255,F.check=o(F.check,Ae,2,0)),de=ie=0,F.mode=3;case 3:for(;de<32;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}F.head&&(F.head.time=ie),512&F.flags&&(Ae[0]=255&ie,Ae[1]=ie>>>8&255,Ae[2]=ie>>>16&255,Ae[3]=ie>>>24&255,F.check=o(F.check,Ae,4,0)),de=ie=0,F.mode=4;case 4:for(;de<16;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}F.head&&(F.head.xflags=255&ie,F.head.os=ie>>8),512&F.flags&&(Ae[0]=255&ie,Ae[1]=ie>>>8&255,F.check=o(F.check,Ae,2,0)),de=ie=0,F.mode=5;case 5:if(1024&F.flags){for(;de<16;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}F.length=ie,F.head&&(F.head.extra_len=ie),512&F.flags&&(Ae[0]=255&ie,Ae[1]=ie>>>8&255,F.check=o(F.check,Ae,2,0)),de=ie=0}else F.head&&(F.head.extra=null);F.mode=6;case 6:if(1024&F.flags&&(ve<(De=F.length)&&(De=ve),De&&(F.head&&(J=F.head.extra_len-F.length,F.head.extra||(F.head.extra=new Array(F.head.extra_len)),i.arraySet(F.head.extra,we,xe,De,J)),512&F.flags&&(F.check=o(F.check,we,De,xe)),ve-=De,xe+=De,F.length-=De),F.length))break e;F.length=0,F.mode=7;case 7:if(2048&F.flags){if(ve===0)break e;for(De=0;J=we[xe+De++],F.head&&J&&F.length<65536&&(F.head.name+=String.fromCharCode(J)),J&&De<ve;);if(512&F.flags&&(F.check=o(F.check,we,De,xe)),ve-=De,xe+=De,J)break e}else F.head&&(F.head.name=null);F.length=0,F.mode=8;case 8:if(4096&F.flags){if(ve===0)break e;for(De=0;J=we[xe+De++],F.head&&J&&F.length<65536&&(F.head.comment+=String.fromCharCode(J)),J&&De<ve;);if(512&F.flags&&(F.check=o(F.check,we,De,xe)),ve-=De,xe+=De,J)break e}else F.head&&(F.head.comment=null);F.mode=9;case 9:if(512&F.flags){for(;de<16;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(ie!==(65535&F.check)){H.msg="header crc mismatch",F.mode=30;break}de=ie=0}F.head&&(F.head.hcrc=F.flags>>9&1,F.head.done=!0),H.adler=F.check=0,F.mode=12;break;case 10:for(;de<32;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}H.adler=F.check=E(ie),de=ie=0,F.mode=11;case 11:if(F.havedict===0)return H.next_out=Le,H.avail_out=ce,H.next_in=xe,H.avail_in=ve,F.hold=ie,F.bits=de,2;H.adler=F.check=1,F.mode=12;case 12:if(Y===5||Y===6)break e;case 13:if(F.last){ie>>>=7&de,de-=7&de,F.mode=27;break}for(;de<3;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}switch(F.last=1&ie,de-=1,3&(ie>>>=1)){case 0:F.mode=14;break;case 1:if(G(F),F.mode=20,Y!==6)break;ie>>>=2,de-=2;break e;case 2:F.mode=17;break;case 3:H.msg="invalid block type",F.mode=30}ie>>>=2,de-=2;break;case 14:for(ie>>>=7&de,de-=7&de;de<32;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if((65535&ie)!=(ie>>>16^65535)){H.msg="invalid stored block lengths",F.mode=30;break}if(F.length=65535&ie,de=ie=0,F.mode=15,Y===6)break e;case 15:F.mode=16;case 16:if(De=F.length){if(ve<De&&(De=ve),ce<De&&(De=ce),De===0)break e;i.arraySet(me,we,xe,De,Le),ve-=De,xe+=De,ce-=De,Le+=De,F.length-=De;break}F.mode=12;break;case 17:for(;de<14;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(F.nlen=257+(31&ie),ie>>>=5,de-=5,F.ndist=1+(31&ie),ie>>>=5,de-=5,F.ncode=4+(15&ie),ie>>>=4,de-=4,286<F.nlen||30<F.ndist){H.msg="too many length or distance symbols",F.mode=30;break}F.have=0,F.mode=18;case 18:for(;F.have<F.ncode;){for(;de<3;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}F.lens[et[F.have++]]=7&ie,ie>>>=3,de-=3}for(;F.have<19;)F.lens[et[F.have++]]=0;if(F.lencode=F.lendyn,F.lenbits=7,Ie={bits:F.lenbits},We=c(0,F.lens,0,19,F.lencode,0,F.work,Ie),F.lenbits=Ie.bits,We){H.msg="invalid code lengths set",F.mode=30;break}F.have=0,F.mode=19;case 19:for(;F.have<F.nlen+F.ndist;){for(;Nt=(he=F.lencode[ie&(1<<F.lenbits)-1])>>>16&255,wt=65535&he,!((xt=he>>>24)<=de);){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(wt<16)ie>>>=xt,de-=xt,F.lens[F.have++]=wt;else{if(wt===16){for(ge=xt+2;de<ge;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(ie>>>=xt,de-=xt,F.have===0){H.msg="invalid bit length repeat",F.mode=30;break}J=F.lens[F.have-1],De=3+(3&ie),ie>>>=2,de-=2}else if(wt===17){for(ge=xt+3;de<ge;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}de-=xt,J=0,De=3+(7&(ie>>>=xt)),ie>>>=3,de-=3}else{for(ge=xt+7;de<ge;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}de-=xt,J=0,De=11+(127&(ie>>>=xt)),ie>>>=7,de-=7}if(F.have+De>F.nlen+F.ndist){H.msg="invalid bit length repeat",F.mode=30;break}for(;De--;)F.lens[F.have++]=J}}if(F.mode===30)break;if(F.lens[256]===0){H.msg="invalid code -- missing end-of-block",F.mode=30;break}if(F.lenbits=9,Ie={bits:F.lenbits},We=c(h,F.lens,0,F.nlen,F.lencode,0,F.work,Ie),F.lenbits=Ie.bits,We){H.msg="invalid literal/lengths set",F.mode=30;break}if(F.distbits=6,F.distcode=F.distdyn,Ie={bits:F.distbits},We=c(p,F.lens,F.nlen,F.ndist,F.distcode,0,F.work,Ie),F.distbits=Ie.bits,We){H.msg="invalid distances set",F.mode=30;break}if(F.mode=20,Y===6)break e;case 20:F.mode=21;case 21:if(6<=ve&&258<=ce){H.next_out=Le,H.avail_out=ce,H.next_in=xe,H.avail_in=ve,F.hold=ie,F.bits=de,l(H,Se),Le=H.next_out,me=H.output,ce=H.avail_out,xe=H.next_in,we=H.input,ve=H.avail_in,ie=F.hold,de=F.bits,F.mode===12&&(F.back=-1);break}for(F.back=0;Nt=(he=F.lencode[ie&(1<<F.lenbits)-1])>>>16&255,wt=65535&he,!((xt=he>>>24)<=de);){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(Nt&&(240&Nt)==0){for(zt=xt,_n=Nt,Zt=wt;Nt=(he=F.lencode[Zt+((ie&(1<<zt+_n)-1)>>zt)])>>>16&255,wt=65535&he,!(zt+(xt=he>>>24)<=de);){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}ie>>>=zt,de-=zt,F.back+=zt}if(ie>>>=xt,de-=xt,F.back+=xt,F.length=wt,Nt===0){F.mode=26;break}if(32&Nt){F.back=-1,F.mode=12;break}if(64&Nt){H.msg="invalid literal/length code",F.mode=30;break}F.extra=15&Nt,F.mode=22;case 22:if(F.extra){for(ge=F.extra;de<ge;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}F.length+=ie&(1<<F.extra)-1,ie>>>=F.extra,de-=F.extra,F.back+=F.extra}F.was=F.length,F.mode=23;case 23:for(;Nt=(he=F.distcode[ie&(1<<F.distbits)-1])>>>16&255,wt=65535&he,!((xt=he>>>24)<=de);){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if((240&Nt)==0){for(zt=xt,_n=Nt,Zt=wt;Nt=(he=F.distcode[Zt+((ie&(1<<zt+_n)-1)>>zt)])>>>16&255,wt=65535&he,!(zt+(xt=he>>>24)<=de);){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}ie>>>=zt,de-=zt,F.back+=zt}if(ie>>>=xt,de-=xt,F.back+=xt,64&Nt){H.msg="invalid distance code",F.mode=30;break}F.offset=wt,F.extra=15&Nt,F.mode=24;case 24:if(F.extra){for(ge=F.extra;de<ge;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}F.offset+=ie&(1<<F.extra)-1,ie>>>=F.extra,de-=F.extra,F.back+=F.extra}if(F.offset>F.dmax){H.msg="invalid distance too far back",F.mode=30;break}F.mode=25;case 25:if(ce===0)break e;if(De=Se-ce,F.offset>De){if((De=F.offset-De)>F.whave&&F.sane){H.msg="invalid distance too far back",F.mode=30;break}gt=De>F.wnext?(De-=F.wnext,F.wsize-De):F.wnext-De,De>F.length&&(De=F.length),yt=F.window}else yt=me,gt=Le-F.offset,De=F.length;for(ce<De&&(De=ce),ce-=De,F.length-=De;me[Le++]=yt[gt++],--De;);F.length===0&&(F.mode=21);break;case 26:if(ce===0)break e;me[Le++]=F.length,ce--,F.mode=21;break;case 27:if(F.wrap){for(;de<32;){if(ve===0)break e;ve--,ie|=we[xe++]<<de,de+=8}if(Se-=ce,H.total_out+=Se,F.total+=Se,Se&&(H.adler=F.check=F.flags?o(F.check,me,Se,Le-Se):a(F.check,me,Se,Le-Se)),Se=ce,(F.flags?ie:E(ie))!==F.check){H.msg="incorrect data check",F.mode=30;break}de=ie=0}F.mode=28;case 28:if(F.wrap&&F.flags){for(;de<32;){if(ve===0)break e;ve--,ie+=we[xe++]<<de,de+=8}if(ie!==(4294967295&F.total)){H.msg="incorrect length check",F.mode=30;break}de=ie=0}F.mode=29;case 29:We=1;break e;case 30:We=-3;break e;case 31:return-4;case 32:default:return y}return H.next_out=Le,H.avail_out=ce,H.next_in=xe,H.avail_in=ve,F.hold=ie,F.bits=de,(F.wsize||Se!==H.avail_out&&F.mode<30&&(F.mode<27||Y!==4))&&X(H,H.output,H.next_out,Se-H.avail_out)?(F.mode=31,-4):(Re-=H.avail_in,Se-=H.avail_out,H.total_in+=Re,H.total_out+=Se,F.total+=Se,F.wrap&&Se&&(H.adler=F.check=F.flags?o(F.check,me,Se,H.next_out-Se):a(F.check,me,Se,H.next_out-Se)),H.data_type=F.bits+(F.last?64:0)+(F.mode===12?128:0)+(F.mode===20||F.mode===15?256:0),(Re==0&&Se===0||Y===4)&&We===m&&(We=-5),We)},r.inflateEnd=function(H){if(!H||!H.state)return y;var Y=H.state;return Y.window&&(Y.window=null),H.state=null,m},r.inflateGetHeader=function(H,Y){var F;return H&&H.state?(2&(F=H.state).wrap)==0?y:((F.head=Y).done=!1,m):y},r.inflateSetDictionary=function(H,Y){var F,we=Y.length;return H&&H.state?(F=H.state).wrap!==0&&F.mode!==11?y:F.mode===11&&a(1,Y,we,0)!==F.check?-3:X(H,Y,we,we)?(F.mode=31,-4):(F.havedict=1,m):y},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,s,r){var i=n("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];s.exports=function(h,p,m,y,v,b,S,E){var I,M,j,L,K,D,R,B,G,X=E.bits,H=0,Y=0,F=0,we=0,me=0,xe=0,Le=0,ve=0,ce=0,ie=0,de=null,Re=0,Se=new i.Buf16(16),De=new i.Buf16(16),gt=null,yt=0;for(H=0;H<=15;H++)Se[H]=0;for(Y=0;Y<y;Y++)Se[p[m+Y]]++;for(me=X,we=15;1<=we&&Se[we]===0;we--);if(we<me&&(me=we),we===0)return v[b++]=20971520,v[b++]=20971520,E.bits=1,0;for(F=1;F<we&&Se[F]===0;F++);for(me<F&&(me=F),H=ve=1;H<=15;H++)if(ve<<=1,(ve-=Se[H])<0)return-1;if(0<ve&&(h===0||we!==1))return-1;for(De[1]=0,H=1;H<15;H++)De[H+1]=De[H]+Se[H];for(Y=0;Y<y;Y++)p[m+Y]!==0&&(S[De[p[m+Y]]++]=Y);if(D=h===0?(de=gt=S,19):h===1?(de=a,Re-=257,gt=o,yt-=257,256):(de=l,gt=c,-1),H=F,K=b,Le=Y=ie=0,j=-1,L=(ce=1<<(xe=me))-1,h===1&&852<ce||h===2&&592<ce)return 1;for(;;){for(R=H-Le,G=S[Y]<D?(B=0,S[Y]):S[Y]>D?(B=gt[yt+S[Y]],de[Re+S[Y]]):(B=96,0),I=1<<H-Le,F=M=1<<xe;v[K+(ie>>Le)+(M-=I)]=R<<24|B<<16|G|0,M!==0;);for(I=1<<H-1;ie&I;)I>>=1;if(I!==0?(ie&=I-1,ie+=I):ie=0,Y++,--Se[H]==0){if(H===we)break;H=p[m+S[Y]]}if(me<H&&(ie&L)!==j){for(Le===0&&(Le=me),K+=F,ve=1<<(xe=H-Le);xe+Le<we&&!((ve-=Se[xe+Le])<=0);)xe++,ve<<=1;if(ce+=1<<xe,h===1&&852<ce||h===2&&592<ce)return 1;v[j=ie&L]=me<<24|xe<<16|K-b|0}}return ie!==0&&(v[K+ie]=H-Le<<24|64<<16|0),E.bits=me,0}},{"../utils/common":41}],51:[function(n,s,r){s.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,s,r){var i=n("../utils/common"),a=0,o=1;function l(he){for(var Ae=he.length;0<=--Ae;)he[Ae]=0}var c=0,h=29,p=256,m=p+1+h,y=30,v=19,b=2*m+1,S=15,E=16,I=7,M=256,j=16,L=17,K=18,D=[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],R=[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],B=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X=new Array(2*(m+2));l(X);var H=new Array(2*y);l(H);var Y=new Array(512);l(Y);var F=new Array(256);l(F);var we=new Array(h);l(we);var me,xe,Le,ve=new Array(y);function ce(he,Ae,et,nt,He){this.static_tree=he,this.extra_bits=Ae,this.extra_base=et,this.elems=nt,this.max_length=He,this.has_stree=he&&he.length}function ie(he,Ae){this.dyn_tree=he,this.max_code=0,this.stat_desc=Ae}function de(he){return he<256?Y[he]:Y[256+(he>>>7)]}function Re(he,Ae){he.pending_buf[he.pending++]=255&Ae,he.pending_buf[he.pending++]=Ae>>>8&255}function Se(he,Ae,et){he.bi_valid>E-et?(he.bi_buf|=Ae<<he.bi_valid&65535,Re(he,he.bi_buf),he.bi_buf=Ae>>E-he.bi_valid,he.bi_valid+=et-E):(he.bi_buf|=Ae<<he.bi_valid&65535,he.bi_valid+=et)}function De(he,Ae,et){Se(he,et[2*Ae],et[2*Ae+1])}function gt(he,Ae){for(var et=0;et|=1&he,he>>>=1,et<<=1,0<--Ae;);return et>>>1}function yt(he,Ae,et){var nt,He,ft=new Array(S+1),Mt=0;for(nt=1;nt<=S;nt++)ft[nt]=Mt=Mt+et[nt-1]<<1;for(He=0;He<=Ae;He++){var pt=he[2*He+1];pt!==0&&(he[2*He]=gt(ft[pt]++,pt))}}function xt(he){var Ae;for(Ae=0;Ae<m;Ae++)he.dyn_ltree[2*Ae]=0;for(Ae=0;Ae<y;Ae++)he.dyn_dtree[2*Ae]=0;for(Ae=0;Ae<v;Ae++)he.bl_tree[2*Ae]=0;he.dyn_ltree[2*M]=1,he.opt_len=he.static_len=0,he.last_lit=he.matches=0}function Nt(he){8<he.bi_valid?Re(he,he.bi_buf):0<he.bi_valid&&(he.pending_buf[he.pending++]=he.bi_buf),he.bi_buf=0,he.bi_valid=0}function wt(he,Ae,et,nt){var He=2*Ae,ft=2*et;return he[He]<he[ft]||he[He]===he[ft]&&nt[Ae]<=nt[et]}function zt(he,Ae,et){for(var nt=he.heap[et],He=et<<1;He<=he.heap_len&&(He<he.heap_len&&wt(Ae,he.heap[He+1],he.heap[He],he.depth)&&He++,!wt(Ae,nt,he.heap[He],he.depth));)he.heap[et]=he.heap[He],et=He,He<<=1;he.heap[et]=nt}function _n(he,Ae,et){var nt,He,ft,Mt,pt=0;if(he.last_lit!==0)for(;nt=he.pending_buf[he.d_buf+2*pt]<<8|he.pending_buf[he.d_buf+2*pt+1],He=he.pending_buf[he.l_buf+pt],pt++,nt===0?De(he,He,Ae):(De(he,(ft=F[He])+p+1,Ae),(Mt=D[ft])!==0&&Se(he,He-=we[ft],Mt),De(he,ft=de(--nt),et),(Mt=R[ft])!==0&&Se(he,nt-=ve[ft],Mt)),pt<he.last_lit;);De(he,M,Ae)}function Zt(he,Ae){var et,nt,He,ft=Ae.dyn_tree,Mt=Ae.stat_desc.static_tree,pt=Ae.stat_desc.has_stree,Oe=Ae.stat_desc.elems,hn=-1;for(he.heap_len=0,he.heap_max=b,et=0;et<Oe;et++)ft[2*et]!==0?(he.heap[++he.heap_len]=hn=et,he.depth[et]=0):ft[2*et+1]=0;for(;he.heap_len<2;)ft[2*(He=he.heap[++he.heap_len]=hn<2?++hn:0)]=1,he.depth[He]=0,he.opt_len--,pt&&(he.static_len-=Mt[2*He+1]);for(Ae.max_code=hn,et=he.heap_len>>1;1<=et;et--)zt(he,ft,et);for(He=Oe;et=he.heap[1],he.heap[1]=he.heap[he.heap_len--],zt(he,ft,1),nt=he.heap[1],he.heap[--he.heap_max]=et,he.heap[--he.heap_max]=nt,ft[2*He]=ft[2*et]+ft[2*nt],he.depth[He]=(he.depth[et]>=he.depth[nt]?he.depth[et]:he.depth[nt])+1,ft[2*et+1]=ft[2*nt+1]=He,he.heap[1]=He++,zt(he,ft,1),2<=he.heap_len;);he.heap[--he.heap_max]=he.heap[1],(function(Yt,Qe){var tn,je,Ue,bt,ht,Dt,Ut=Qe.dyn_tree,Lt=Qe.max_code,Wt=Qe.stat_desc.static_tree,fn=Qe.stat_desc.has_stree,Jt=Qe.stat_desc.extra_bits,Kn=Qe.stat_desc.extra_base,nn=Qe.stat_desc.max_length,Wn=0;for(bt=0;bt<=S;bt++)Yt.bl_count[bt]=0;for(Ut[2*Yt.heap[Yt.heap_max]+1]=0,tn=Yt.heap_max+1;tn<b;tn++)nn<(bt=Ut[2*Ut[2*(je=Yt.heap[tn])+1]+1]+1)&&(bt=nn,Wn++),Ut[2*je+1]=bt,Lt<je||(Yt.bl_count[bt]++,ht=0,Kn<=je&&(ht=Jt[je-Kn]),Dt=Ut[2*je],Yt.opt_len+=Dt*(bt+ht),fn&&(Yt.static_len+=Dt*(Wt[2*je+1]+ht)));if(Wn!==0){do{for(bt=nn-1;Yt.bl_count[bt]===0;)bt--;Yt.bl_count[bt]--,Yt.bl_count[bt+1]+=2,Yt.bl_count[nn]--,Wn-=2}while(0<Wn);for(bt=nn;bt!==0;bt--)for(je=Yt.bl_count[bt];je!==0;)Lt<(Ue=Yt.heap[--tn])||(Ut[2*Ue+1]!==bt&&(Yt.opt_len+=(bt-Ut[2*Ue+1])*Ut[2*Ue],Ut[2*Ue+1]=bt),je--)}})(he,Ae),yt(ft,hn,he.bl_count)}function J(he,Ae,et){var nt,He,ft=-1,Mt=Ae[1],pt=0,Oe=7,hn=4;for(Mt===0&&(Oe=138,hn=3),Ae[2*(et+1)+1]=65535,nt=0;nt<=et;nt++)He=Mt,Mt=Ae[2*(nt+1)+1],++pt<Oe&&He===Mt||(pt<hn?he.bl_tree[2*He]+=pt:He!==0?(He!==ft&&he.bl_tree[2*He]++,he.bl_tree[2*j]++):pt<=10?he.bl_tree[2*L]++:he.bl_tree[2*K]++,ft=He,hn=(pt=0)===Mt?(Oe=138,3):He===Mt?(Oe=6,3):(Oe=7,4))}function We(he,Ae,et){var nt,He,ft=-1,Mt=Ae[1],pt=0,Oe=7,hn=4;for(Mt===0&&(Oe=138,hn=3),nt=0;nt<=et;nt++)if(He=Mt,Mt=Ae[2*(nt+1)+1],!(++pt<Oe&&He===Mt)){if(pt<hn)for(;De(he,He,he.bl_tree),--pt!=0;);else He!==0?(He!==ft&&(De(he,He,he.bl_tree),pt--),De(he,j,he.bl_tree),Se(he,pt-3,2)):pt<=10?(De(he,L,he.bl_tree),Se(he,pt-3,3)):(De(he,K,he.bl_tree),Se(he,pt-11,7));ft=He,hn=(pt=0)===Mt?(Oe=138,3):He===Mt?(Oe=6,3):(Oe=7,4)}}l(ve);var Ie=!1;function ge(he,Ae,et,nt){Se(he,(c<<1)+(nt?1:0),3),(function(He,ft,Mt,pt){Nt(He),Re(He,Mt),Re(He,~Mt),i.arraySet(He.pending_buf,He.window,ft,Mt,He.pending),He.pending+=Mt})(he,Ae,et)}r._tr_init=function(he){Ie||((function(){var Ae,et,nt,He,ft,Mt=new Array(S+1);for(He=nt=0;He<h-1;He++)for(we[He]=nt,Ae=0;Ae<1<<D[He];Ae++)F[nt++]=He;for(F[nt-1]=He,He=ft=0;He<16;He++)for(ve[He]=ft,Ae=0;Ae<1<<R[He];Ae++)Y[ft++]=He;for(ft>>=7;He<y;He++)for(ve[He]=ft<<7,Ae=0;Ae<1<<R[He]-7;Ae++)Y[256+ft++]=He;for(et=0;et<=S;et++)Mt[et]=0;for(Ae=0;Ae<=143;)X[2*Ae+1]=8,Ae++,Mt[8]++;for(;Ae<=255;)X[2*Ae+1]=9,Ae++,Mt[9]++;for(;Ae<=279;)X[2*Ae+1]=7,Ae++,Mt[7]++;for(;Ae<=287;)X[2*Ae+1]=8,Ae++,Mt[8]++;for(yt(X,m+1,Mt),Ae=0;Ae<y;Ae++)H[2*Ae+1]=5,H[2*Ae]=gt(Ae,5);me=new ce(X,D,p+1,m,S),xe=new ce(H,R,0,y,S),Le=new ce(new Array(0),B,0,v,I)})(),Ie=!0),he.l_desc=new ie(he.dyn_ltree,me),he.d_desc=new ie(he.dyn_dtree,xe),he.bl_desc=new ie(he.bl_tree,Le),he.bi_buf=0,he.bi_valid=0,xt(he)},r._tr_stored_block=ge,r._tr_flush_block=function(he,Ae,et,nt){var He,ft,Mt=0;0<he.level?(he.strm.data_type===2&&(he.strm.data_type=(function(pt){var Oe,hn=4093624447;for(Oe=0;Oe<=31;Oe++,hn>>>=1)if(1&hn&&pt.dyn_ltree[2*Oe]!==0)return a;
vendor: 3,140 bytes, line 6703
6703if(pt.dyn_ltree[18]!==0||pt.dyn_ltree[20]!==0||pt.dyn_ltree[26]!==0)return o;for(Oe=32;Oe<p;Oe++)if(pt.dyn_ltree[2*Oe]!==0)return o;return a})(he)),Zt(he,he.l_desc),Zt(he,he.d_desc),Mt=(function(pt){var Oe;for(J(pt,pt.dyn_ltree,pt.l_desc.max_code),J(pt,pt.dyn_dtree,pt.d_desc.max_code),Zt(pt,pt.bl_desc),Oe=v-1;3<=Oe&&pt.bl_tree[2*G[Oe]+1]===0;Oe--);return pt.opt_len+=3*(Oe+1)+5+5+4,Oe})(he),He=he.opt_len+3+7>>>3,(ft=he.static_len+3+7>>>3)<=He&&(He=ft)):He=ft=et+5,et+4<=He&&Ae!==-1?ge(he,Ae,et,nt):he.strategy===4||ft===He?(Se(he,2+(nt?1:0),3),_n(he,X,H)):(Se(he,4+(nt?1:0),3),(function(pt,Oe,hn,Yt){var Qe;for(Se(pt,Oe-257,5),Se(pt,hn-1,5),Se(pt,Yt-4,4),Qe=0;Qe<Yt;Qe++)Se(pt,pt.bl_tree[2*G[Qe]+1],3);We(pt,pt.dyn_ltree,Oe-1),We(pt,pt.dyn_dtree,hn-1)})(he,he.l_desc.max_code+1,he.d_desc.max_code+1,Mt+1),_n(he,he.dyn_ltree,he.dyn_dtree)),xt(he),nt&&Nt(he)},r._tr_tally=function(he,Ae,et){return he.pending_buf[he.d_buf+2*he.last_lit]=Ae>>>8&255,he.pending_buf[he.d_buf+2*he.last_lit+1]=255&Ae,he.pending_buf[he.l_buf+he.last_lit]=255&et,he.last_lit++,Ae===0?he.dyn_ltree[2*et]++:(he.matches++,Ae--,he.dyn_ltree[2*(F[et]+p+1)]++,he.dyn_dtree[2*de(Ae)]++),he.last_lit===he.lit_bufsize-1},r._tr_align=function(he){Se(he,2,3),De(he,M,X),(function(Ae){Ae.bi_valid===16?(Re(Ae,Ae.bi_buf),Ae.bi_buf=0,Ae.bi_valid=0):8<=Ae.bi_valid&&(Ae.pending_buf[Ae.pending++]=255&Ae.bi_buf,Ae.bi_buf>>=8,Ae.bi_valid-=8)})(he)}},{"../utils/common":41}],53:[function(n,s,r){s.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,s,r){(function(i){(function(a,o){if(!a.setImmediate){var l,c,h,p,m=1,y={},v=!1,b=a.document,S=Object.getPrototypeOf&&Object.getPrototypeOf(a);S=S&&S.setTimeout?S:a,l={}.toString.call(a.process)==="[object process]"?function(j){process.nextTick(function(){I(j)})}:(function(){if(a.postMessage&&!a.importScripts){var j=!0,L=a.onmessage;return a.onmessage=function(){j=!1},a.postMessage("","*"),a.onmessage=L,j}})()?(p="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",M,!1):a.attachEvent("onmessage",M),function(j){a.postMessage(p+j,"*")}):a.MessageChannel?((h=new MessageChannel).port1.onmessage=function(j){I(j.data)},function(j){h.port2.postMessage(j)}):b&&"onreadystatechange"in b.createElement("script")?(c=b.documentElement,function(j){var L=b.createElement("script");L.onreadystatechange=function(){I(j),L.onreadystatechange=null,c.removeChild(L),L=null},c.appendChild(L)}):function(j){setTimeout(I,0,j)},S.setImmediate=function(j){typeof j!="function"&&(j=new Function(""+j));for(var L=new Array(arguments.length-1),K=0;K<L.length;K++)L[K]=arguments[K+1];var D={callback:j,args:L};return y[m]=D,l(m),m++},S.clearImmediate=E}function E(j){delete y[j]}function I(j){if(v)setTimeout(I,0,j);else{var L=y[j];if(L){v=!0;try{(function(K){var D=K.callback,R=K.args;switch(R.length){case 0:D();break;case 1:D(R[0]);break;case 2:D(R[0],R[1]);break;case 3:D(R[0],R[1],R[2]);break;default:D.apply(o,R)}})(L)}finally{E(j),v=!1}}}}
6703function M(j){j.source===a&&typeof j.data=="string"&&j.data.indexOf(p)===0&&I(+j.data.slice(p.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof md<"u"?md:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(X$)),X$.exports}var bCe=vCe();const uj=JR(bCe);var OI={exports:{}},wCe=OI.exports,J9;function _Ce(){return J9||(J9=1,(function(t,e){(function(n,s){s()})(wCe,function(){function n(c,h){return typeof h>"u"?h={autoBom:!1}:typeof h!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),h={autoBom:!h}),h.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob(["\uFEFF",c],{type:c.type}):c}function s(c,h,p){var m=new XMLHttpRequest;m.open("GET",c),m.responseType="blob",m.onload=function(){l(m.response,h,p)},m.onerror=function(){console.error("could not download file")},m.send()}function r(c){var h=new XMLHttpRequest;h.open("HEAD",c,!1);try{h.send()}catch{}return 200<=h.status&&299>=h.status}function i(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var h=document.createEvent("MouseEvents");
6703h.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(h)}}var a=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof md=="object"&&md.global===md?md:void 0,o=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=a.saveAs||(typeof window!="object"||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(c,h,p){var m=a.URL||a.webkitURL,y=document.createElement("a");h=h||c.name||"download",y.download=h,y.rel="noopener",typeof c=="string"?(y.href=c,y.origin===location.origin?i(y):r(y.href)?s(c,h,p):i(y,y.target="_blank")):(y.href=m.createObjectURL(c),setTimeout(function(){m.revokeObjectURL(y.href)},4e4),setTimeout(function(){i(y)},0))}:"msSaveOrOpenBlob"in navigator?function(c,h,p){if(h=h||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(n(c,p),h);else if(r(c))s(c,h,p);else{var m=document.createElement("a");m.href=c,m.target="_blank",setTimeout(function(){i(m)})}}:function(c,h,p,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof c=="string")return s(c,h,p);var y=c.type==="application/octet-stream",v=/constructor/i.test(a.HTMLElement)||a.safari,b=/CriOS\/[\d]+/.test(navigator.userAgent);if((b||y&&v||o)&&typeof FileReader<"u"){var S=new FileReader;S.onloadend=function(){var M=S.result;M=b?M:M.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=M:location=M,m=null},S.readAsDataURL(c)}else{var E=a.URL||a.webkitURL,I=E.createObjectURL(c);m?m.location=I:location.href=I,m=null,setTimeout(function(){E.revokeObjectURL(I)},4e4)}});a.saveAs=l.saveAs=l,t.exports=l})})(OI)),OI.exports}var HS=_Ce(),J$={exports:{}};/*!
6704    localForage -- Offline Storage, Improved
6705    Version 1.10.0
6706    https://localforage.github.io/localForage
6707    (c) 2013-2017 Mozilla, Apache License 2.0
6708*/var Q9;function SCe(){return Q9||(Q9=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(s,r,i){function a(c,h){if(!r[c]){if(!s[c]){var p=typeof T0=="function"&&T0;if(!h&&p)return p(c,!0);if(o)return o(c,!0);var m=new Error("Cannot find module '"+c+"'");throw m.code="MODULE_NOT_FOUND",m}var y=r[c]={exports:{}};s[c][0].call(y.exports,function(v){var b=s[c][1][v];return a(b||v)},y,y.exports,n,s,r,i)}return r[c].exports}for(var o=typeof T0=="function"&&T0,l=0;l<i.length;l++)a(i[l]);return a})({1:[function(n,s,r){(function(i){var a=i.MutationObserver||i.WebKitMutationObserver,o;if(a){var l=0,c=new a(v),h=i.document.createTextNode("");c.observe(h,{characterData:!0}),o=function(){h.data=l=++l%2}}else if(!i.setImmediate&&typeof i.MessageChannel<"u"){var p=new i.MessageChannel;p.port1.onmessage=v,o=function(){p.port2.postMessage(0)}}else"document"in i&&"onreadystatechange"in i.document.createElement("script")?o=function(){var S=i.document.createElement("script");S.onreadystatechange=function(){v(),S.onreadystatechange=null,S.parentNode.removeChild(S),S=null},i.document.documentElement.appendChild(S)}:o=function(){setTimeout(v,0)};var m,y=[];function v(){m=!0;for(var S,E,I=y.length;I;){for(E=y,y=[],S=-1;++S<I;)E[S]();I=y.length}m=!1}s.exports=b;function b(S){y.push(S)===1&&!m&&o()}}).call(this,typeof md<"u"?md:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,s,r){var i=n(1);function a(){}var o={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];s.exports=p;function p(L){if(typeof L!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,L!==a&&b(this,L)}p.prototype.catch=function(L){return this.then(null,L)},p.prototype.then=function(L,K){if(typeof L!="function"&&this.state===c||typeof K!="function"&&this.state===l)return this;var D=new this.constructor(a);if(this.state!==h){var R=this.state===c?L:K;y(D,R,this.outcome)}else this.queue.push(new m(D,L,K));return D};function m(L,K,D){this.promise=L,typeof K=="function"&&(this.onFulfilled=K,this.callFulfilled=this.otherCallFulfilled),typeof D=="function"&&(this.onRejected=D,this.callRejected=this.otherCallRejected)}m.prototype.callFulfilled=function(L){o.resolve(this.promise,L)},m.prototype.otherCallFulfilled=function(L){y(this.promise,this.onFulfilled,L)},m.prototype.callRejected=function(L){o.reject(this.promise,L)},m.prototype.otherCallRejected=function(L){y(this.promise,this.onRejected,L)};function y(L,K,D){i(function(){var R;try{R=K(D)}catch(B){return o.reject(L,B)}R===L?o.reject(L,new TypeError("Cannot resolve promise with itself")):o.resolve(L,R)})}o.resolve=function(L,K){var D=S(v,K);if(D.status==="error")return o.reject(L,D.value);var R=D.value;if(R)b(L,R);else{L.state=c,L.outcome=K;for(var B=-1,G=L.queue.length;++B<G;)L.queue[B].callFulfilled(K)}return L},o.reject=function(L,K){L.state=l,L.outcome=K;for(var D=-1,R=L.queue.length;++D<R;
vendor: 28,351 bytes, line 6708
6708)L.queue[D].callRejected(K);return L};function v(L){var K=L&&L.then;if(L&&(typeof L=="object"||typeof L=="function")&&typeof K=="function")return function(){K.apply(L,arguments)}}function b(L,K){var D=!1;function R(H){D||(D=!0,o.reject(L,H))}function B(H){D||(D=!0,o.resolve(L,H))}function G(){K(B,R)}var X=S(G);X.status==="error"&&R(X.value)}function S(L,K){var D={};try{D.value=L(K),D.status="success"}catch(R){D.status="error",D.value=R}return D}p.resolve=E;function E(L){return L instanceof this?L:o.resolve(new this(a),L)}p.reject=I;function I(L){var K=new this(a);return o.reject(K,L)}p.all=M;function M(L){var K=this;if(Object.prototype.toString.call(L)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=L.length,R=!1;if(!D)return this.resolve([]);for(var B=new Array(D),G=0,X=-1,H=new this(a);++X<D;)Y(L[X],X);return H;function Y(F,we){K.resolve(F).then(me,function(xe){R||(R=!0,o.reject(H,xe))});function me(xe){B[we]=xe,++G===D&&!R&&(R=!0,o.resolve(H,B))}}}p.race=j;function j(L){var K=this;if(Object.prototype.toString.call(L)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=L.length,R=!1;if(!D)return this.resolve([]);for(var B=-1,G=new this(a);++B<D;)X(L[B]);return G;function X(H){K.resolve(H).then(function(Y){R||(R=!0,o.resolve(G,Y))},function(Y){R||(R=!0,o.reject(G,Y))})}}},{1:1}],3:[function(n,s,r){(function(i){typeof i.Promise!="function"&&(i.Promise=n(2))}).call(this,typeof md<"u"?md:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,s,r){var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ue){return typeof ue}:function(ue){return ue&&typeof Symbol=="function"&&ue.constructor===Symbol&&ue!==Symbol.prototype?"symbol":typeof ue};function a(ue,ke){if(!(ue instanceof ke))throw new TypeError("Cannot call a class as a function")}function o(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var l=o();function c(){try{if(!l||!l.open)return!1;var ue=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),ke=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!ue||ke)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function h(ue,ke){ue=ue||[],ke=ke||{};try{return new Blob(ue,ke)}catch(Ne){if(Ne.name!=="TypeError")throw Ne;for(var pe=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,Pe=new pe,$e=0;$e<ue.length;$e+=1)Pe.append(ue[$e]);return Pe.getBlob(ke.type)}}typeof Promise>"u"&&n(3);var p=Promise;function m(ue,ke){ke&&ue.then(function(pe){ke(null,pe)},function(pe){ke(pe)})}function y(ue,ke,pe){typeof ke=="function"&&ue.then(ke),typeof pe=="function"&&ue.catch(pe)}function v(ue){return typeof ue!="string"&&(console.warn(ue+" used as a key, but it is not a string."),ue=String(ue)),ue}function b(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var S="local-forage-detect-blob-support",E=void 0,I={},M=Object.prototype.toString,j="readonly",L="readwrite";function K(ue){for(var ke=ue.length,pe=new ArrayBuffer(ke),Pe=new Uint8Array(pe),$e=0;$e<ke;$e++)Pe[$e]=ue.charCodeAt($e);return pe}function D(ue){return new p(function(ke){var pe=ue.transaction(S,L),Pe=h([""]);pe.objectStore(S).put(Pe,"key"),pe.onabort=function($e){$e.preventDefault(),$e.stopPropagation(),ke(!1)},pe.oncomplete=function(){var $e=navigator.userAgent.match(/Chrome\/(\d+)/),Ne=navigator.userAgent.match(/Edge\//);ke(Ne||!$e||parseInt($e[1],10)>=43)}}).catch(function(){return!1})}function R(ue){return typeof E=="boolean"?p.resolve(E):D(ue).then(function(ke){return E=ke,E})}function B(ue){var ke=I[ue.name],pe={};pe.promise=new p(function(Pe,$e){pe.resolve=Pe,pe.reject=$e}),ke.deferredOperations.push(pe),ke.dbReady?ke.dbReady=ke.dbReady.then(function(){return pe.promise}):ke.dbReady=pe.promise}function G(ue){var ke=I[ue.name],pe=ke.deferredOperations.pop();if(pe)return pe.resolve(),pe.promise}function X(ue,ke){var pe=I[ue.name],Pe=pe.deferredOperations.pop();if(Pe)return Pe.reject(ke),Pe.promise}function H(ue,ke){return new p(function(pe,Pe){if(I[ue.name]=I[ue.name]||de(),ue.db)if(ke)B(ue),ue.db.close();else return pe(ue.db);var $e=[ue.name];ke&&$e.push(ue.version);var Ne=l.open.apply(l,$e);ke&&(Ne.onupgradeneeded=function(tt){var mt=Ne.result;try{mt.createObjectStore(ue.storeName),tt.oldVersion<=1&&mt.createObjectStore(S)}catch(Ct){if(Ct.name==="ConstraintError")console.warn('The database "'+ue.name+'" has been upgraded from version '+tt.oldVersion+" to version "+tt.newVersion+', but the storage "'+ue.storeName+'" already exists.');else throw Ct}}),Ne.onerror=function(tt){tt.preventDefault(),Pe(Ne.error)},Ne.onsuccess=function(){var tt=Ne.result;tt.onversionchange=function(mt){mt.target.close()},pe(tt),G(ue)}})}function Y(ue){return H(ue,!1)}function F(ue){return H(ue,!0)}function we(ue,ke){if(!ue.db)return!0;var pe=!ue.db.objectStoreNames.contains(ue.storeName),Pe=ue.version<ue.db.version,$e=ue.version>ue.db.version;if(Pe&&(ue.version!==ke&&console.warn('The database "'+ue.name+`" can't be downgraded from version `+ue.db.version+" to version "+ue.version+"."),ue.version=ue.db.version),$e||pe){if(pe){var Ne=ue.db.version+1;Ne>ue.version&&(ue.version=Ne)}return!0}return!1}function me(ue){return new p(function(ke,pe){var Pe=new FileReader;Pe.onerror=pe,Pe.onloadend=function($e){var Ne=btoa($e.target.result||"");ke({__local_forage_encoded_blob:!0,data:Ne,type:ue.type})},Pe.readAsBinaryString(ue)})}function xe(ue){var ke=K(atob(ue.data));return h([ke],{type:ue.type})}function Le(ue){return ue&&ue.__local_forage_encoded_blob}function ve(ue){var ke=this,pe=ke._initReady().then(function(){var Pe=I[ke._dbInfo.name];if(Pe&&Pe.dbReady)return Pe.dbReady});return y(pe,ue,ue),pe}function ce(ue){B(ue);for(var ke=I[ue.name],pe=ke.forages,Pe=0;Pe<pe.length;Pe++){var $e=pe[Pe];$e._dbInfo.db&&($e._dbInfo.db.close(),$e._dbInfo.db=null)}return ue.db=null,Y(ue).then(function(Ne){return ue.db=Ne,we(ue)?F(ue):Ne}).then(function(Ne){ue.db=ke.db=Ne;for(var tt=0;tt<pe.length;tt++)pe[tt]._dbInfo.db=Ne}).catch(function(Ne){throw X(ue,Ne),Ne})}function ie(ue,ke,pe,Pe){Pe===void 0&&(Pe=1);try{var $e=ue.db.transaction(ue.storeName,ke);pe(null,$e)}catch(Ne){if(Pe>0&&(!ue.db||Ne.name==="InvalidStateError"||Ne.name==="NotFoundError"))return p.resolve().then(function(){if(!ue.db||Ne.name==="NotFoundError"&&!ue.db.objectStoreNames.contains(ue.storeName)&&ue.version<=ue.db.version)return ue.db&&(ue.version=ue.db.version+1),F(ue)}).then(function(){return ce(ue).then(function(){ie(ue,ke,pe,Pe-1)})}).catch(pe);pe(Ne)}}function de(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Re(ue){var ke=this,pe={db:null};if(ue)for(var Pe in ue)pe[Pe]=ue[Pe];var $e=I[pe.name];$e||($e=de(),I[pe.name]=$e),$e.forages.push(ke),ke._initReady||(ke._initReady=ke.ready,ke.ready=ve);var Ne=[];function tt(){return p.resolve()}for(var mt=0;mt<$e.forages.length;mt++){var Ct=$e.forages[mt];Ct!==ke&&Ne.push(Ct._initReady().catch(tt))}var _t=$e.forages.slice(0);return p.all(Ne).then(function(){return pe.db=$e.db,Y(pe)}).then(function(kt){return pe.db=kt,we(pe,ke._defaultConfig.version)?F(pe):kt}).then(function(kt){pe.db=$e.db=kt,ke._dbInfo=pe;for(var Xt=0;Xt<_t.length;Xt++){var qn=_t[Xt];qn!==ke&&(qn._dbInfo.db=pe.db,qn._dbInfo.version=pe.version)}})}function Se(ue,ke){var pe=this;ue=v(ue);var Pe=new p(function($e,Ne){pe.ready().then(function(){ie(pe._dbInfo,j,function(tt,mt){if(tt)return Ne(tt);try{var Ct=mt.objectStore(pe._dbInfo.storeName),_t=Ct.get(ue);_t.onsuccess=function(){var kt=_t.result;kt===void 0&&(kt=null),Le(kt)&&(kt=xe(kt)),$e(kt)},_t.onerror=function(){Ne(_t.error)}}catch(kt){Ne(kt)}})}).catch(Ne)});return m(Pe,ke),Pe}function De(ue,ke){var pe=this,Pe=new p(function($e,Ne){pe.ready().then(function(){ie(pe._dbInfo,j,function(tt,mt){if(tt)return Ne(tt);try{var Ct=mt.objectStore(pe._dbInfo.storeName),_t=Ct.openCursor(),kt=1;_t.onsuccess=function(){var Xt=_t.result;if(Xt){var qn=Xt.value;Le(qn)&&(qn=xe(qn));var Xn=ue(qn,Xt.key,kt++);Xn!==void 0?$e(Xn):Xt.continue()}else $e()},_t.onerror=function(){Ne(_t.error)}}catch(Xt){Ne(Xt)}})}).catch(Ne)});return m(Pe,ke),Pe}function gt(ue,ke,pe){var Pe=this;ue=v(ue);var $e=new p(function(Ne,tt){var mt;Pe.ready().then(function(){return mt=Pe._dbInfo,M.call(ke)==="[object Blob]"?R(mt.db).then(function(Ct){return Ct?ke:me(ke)}):ke}).then(function(Ct){ie(Pe._dbInfo,L,function(_t,kt){if(_t)return tt(_t);try{var Xt=kt.objectStore(Pe._dbInfo.storeName);Ct===null&&(Ct=void 0);var qn=Xt.put(Ct,ue);kt.oncomplete=function(){Ct===void 0&&(Ct=null),Ne(Ct)},kt.onabort=kt.onerror=function(){var Xn=qn.error?qn.error:qn.transaction.error;tt(Xn)}}catch(Xn){tt(Xn)}})}).catch(tt)});return m($e,pe),$e}function yt(ue,ke){var pe=this;ue=v(ue);var Pe=new p(function($e,Ne){pe.ready().then(function(){ie(pe._dbInfo,L,function(tt,mt){if(tt)return Ne(tt);try{var Ct=mt.objectStore(pe._dbInfo.storeName),_t=Ct.delete(ue);mt.oncomplete=function(){$e()},mt.onerror=function(){Ne(_t.error)},mt.onabort=function(){var kt=_t.error?_t.error:_t.transaction.error;Ne(kt)}}catch(kt){Ne(kt)}})}).catch(Ne)});return m(Pe,ke),Pe}function xt(ue){var ke=this,pe=new p(function(Pe,$e){ke.ready().then(function(){ie(ke._dbInfo,L,function(Ne,tt){if(Ne)return $e(Ne);try{var mt=tt.objectStore(ke._dbInfo.storeName),Ct=mt.clear();tt.oncomplete=function(){Pe()},tt.onabort=tt.onerror=function(){var _t=Ct.error?Ct.error:Ct.transaction.error;$e(_t)}}catch(_t){$e(_t)}})}).catch($e)});return m(pe,ue),pe}function Nt(ue){var ke=this,pe=new p(function(Pe,$e){ke.ready().then(function(){ie(ke._dbInfo,j,function(Ne,tt){if(Ne)return $e(Ne);try{var mt=tt.objectStore(ke._dbInfo.storeName),Ct=mt.count();Ct.onsuccess=function(){Pe(Ct.result)},Ct.onerror=function(){$e(Ct.error)}}catch(_t){$e(_t)}})}).catch($e)});return m(pe,ue),pe}function wt(ue,ke){var pe=this,Pe=new p(function($e,Ne){if(ue<0){$e(null);return}pe.ready().then(function(){ie(pe._dbInfo,j,function(tt,mt){if(tt)return Ne(tt);try{var Ct=mt.objectStore(pe._dbInfo.storeName),_t=!1,kt=Ct.openKeyCursor();kt.onsuccess=function(){var Xt=kt.result;if(!Xt){$e(null);return}ue===0||_t?$e(Xt.key):(_t=!0,Xt.advance(ue))},kt.onerror=function(){Ne(kt.error)}}catch(Xt){Ne(Xt)}})}).catch(Ne)});return m(Pe,ke),Pe}function zt(ue){var ke=this,pe=new p(function(Pe,$e){ke.ready().then(function(){ie(ke._dbInfo,j,function(Ne,tt){if(Ne)return $e(Ne);try{var mt=tt.objectStore(ke._dbInfo.storeName),Ct=mt.openKeyCursor(),_t=[];Ct.onsuccess=function(){var kt=Ct.result;if(!kt){Pe(_t);return}_t.push(kt.key),kt.continue()},Ct.onerror=function(){$e(Ct.error)}}catch(kt){$e(kt)}})}).catch($e)});return m(pe,ue),pe}function _n(ue,ke){ke=b.apply(this,arguments);var pe=this.config();ue=typeof ue!="function"&&ue||{},ue.name||(ue.name=ue.name||pe.name,ue.storeName=ue.storeName||pe.storeName);var Pe=this,$e;if(!ue.name)$e=p.reject("Invalid arguments");else{var Ne=ue.name===pe.name&&Pe._dbInfo.db,tt=Ne?p.resolve(Pe._dbInfo.db):Y(ue).then(function(mt){var Ct=I[ue.name],_t=Ct.forages;Ct.db=mt;for(var kt=0;kt<_t.length;kt++)_t[kt]._dbInfo.db=mt;return mt});ue.storeName?$e=tt.then(function(mt){if(mt.objectStoreNames.contains(ue.storeName)){var Ct=mt.version+1;B(ue);var _t=I[ue.name],kt=_t.forages;mt.close();for(var Xt=0;Xt<kt.length;Xt++){var qn=kt[Xt];qn._dbInfo.db=null,qn._dbInfo.version=Ct}var Xn=new p(function(an,Jn){var Qn=l.open(ue.name,Ct);Qn.onerror=function(Gs){var Cr=Qn.result;Cr.close(),Jn(Gs)},Qn.onupgradeneeded=function(){var Gs=Qn.result;Gs.deleteObjectStore(ue.storeName)},Qn.onsuccess=function(){var Gs=Qn.result;Gs.close(),an(Gs)}});return Xn.then(function(an){_t.db=an;for(var Jn=0;Jn<kt.length;Jn++){var Qn=kt[Jn];Qn._dbInfo.db=an,G(Qn._dbInfo)}}).catch(function(an){throw(X(ue,an)||p.resolve()).catch(function(){}),an})}}):$e=tt.then(function(mt){B(ue);var Ct=I[ue.name],_t=Ct.forages;mt.close();for(var kt=0;kt<_t.length;kt++){var Xt=_t[kt];Xt._dbInfo.db=null}var qn=new p(function(Xn,an){var Jn=l.deleteDatabase(ue.name);Jn.onerror=function(){var Qn=Jn.result;Qn&&Qn.close(),an(Jn.error)},Jn.onblocked=function(){console.warn('dropInstance blocked for database "'+ue.name+'" until all open connections are closed')},Jn.onsuccess=function(){var Qn=Jn.result;Qn&&Qn.close(),Xn(Qn)}});return qn.then(function(Xn){Ct.db=Xn;for(var an=0;an<_t.length;an++){var Jn=_t[an];G(Jn._dbInfo)}}).catch(function(Xn){throw(X(ue,Xn)||p.resolve()).catch(function(){}),Xn})})}return m($e,ke),$e}var Zt={_driver:"asyncStorage",_initStorage:Re,_support:c(),iterate:De,getItem:Se,setItem:gt,removeItem:yt,clear:xt,length:Nt,key:wt,keys:zt,dropInstance:_n};function J(){return typeof openDatabase=="function"}var We="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ie="~~local_forage_type~",ge=/^~~local_forage_type~([^~]+)~/,he="__lfsc__:",Ae=he.length,et="arbf",nt="blob",He="si08",ft="ui08",Mt="uic8",pt="si16",Oe="si32",hn="ur16",Yt="ui32",Qe="fl32",tn="fl64",je=Ae+et.length,Ue=Object.prototype.toString;function bt(ue){var ke=ue.length*.75,pe=ue.length,Pe,$e=0,Ne,tt,mt,Ct;ue[ue.length-1]==="="&&(ke--,ue[ue.length-2]==="="&&ke--);var _t=new ArrayBuffer(ke),kt=new Uint8Array(_t);for(Pe=0;Pe<pe;Pe+=4)Ne=We.indexOf(ue[Pe]),tt=We.indexOf(ue[Pe+1]),mt=We.indexOf(ue[Pe+2]),Ct=We.indexOf(ue[Pe+3]),kt[$e++]=Ne<<2|tt>>4,kt[$e++]=(tt&15)<<4|mt>>2,kt[$e++]=(mt&3)<<6|Ct&63;return _t}function ht(ue){var ke=new Uint8Array(ue),pe="",Pe;for(Pe=0;Pe<ke.length;Pe+=3)pe+=We[ke[Pe]>>2],pe+=We[(ke[Pe]&3)<<4|ke[Pe+1]>>4],pe+=We[(ke[Pe+1]&15)<<2|ke[Pe+2]>>6],pe+=We[ke[Pe+2]&63];return ke.length%3===2?pe=pe.substring(0,pe.length-1)+"=":ke.length%3===1&&(pe=pe.substring(0,pe.length-2)+"=="),pe}function Dt(ue,ke){var pe="";if(ue&&(pe=Ue.call(ue)),ue&&(pe==="[object ArrayBuffer]"||ue.buffer&&Ue.call(ue.buffer)==="[object ArrayBuffer]")){var Pe,$e=he;ue instanceof ArrayBuffer?(Pe=ue,$e+=et):(Pe=ue.buffer,pe==="[object Int8Array]"?$e+=He:pe==="[object Uint8Array]"?$e+=ft:pe==="[object Uint8ClampedArray]"?$e+=Mt:pe==="[object Int16Array]"?$e+=pt:pe==="[object Uint16Array]"?$e+=hn:pe==="[object Int32Array]"?$e+=Oe:pe==="[object Uint32Array]"?$e+=Yt:pe==="[object Float32Array]"?$e+=Qe:pe==="[object Float64Array]"?$e+=tn:ke(new Error("Failed to get type for BinaryArray"))),ke($e+ht(Pe))}else if(pe==="[object Blob]"){var Ne=new FileReader;Ne.onload=function(){var tt=Ie+ue.type+"~"+ht(this.result);ke(he+nt+tt)},Ne.readAsArrayBuffer(ue)}else try{ke(JSON.stringify(ue))}catch(tt){console.error("Couldn't convert value into a JSON string: ",ue),ke(null,tt)}}function Ut(ue){if(ue.substring(0,Ae)!==he)return JSON.parse(ue);var ke=ue.substring(je),pe=ue.substring(Ae,je),Pe;if(pe===nt&&ge.test(ke)){var $e=ke.match(ge);Pe=$e[1],ke=ke.substring($e[0].length)}var Ne=bt(ke);switch(pe){case et:return Ne;case nt:return h([Ne],{type:Pe});case He:return new Int8Array(Ne);case ft:return new Uint8Array(Ne);case Mt:return new Uint8ClampedArray(Ne);case pt:return new Int16Array(Ne);case hn:return new Uint16Array(Ne);case Oe:return new Int32Array(Ne);case Yt:return new Uint32Array(Ne);case Qe:return new Float32Array(Ne);case tn:return new Float64Array(Ne);default:throw new Error("Unkown type: "+pe)}}var Lt={serialize:Dt,deserialize:Ut,stringToBuffer:bt,bufferToString:ht};function Wt(ue,ke,pe,Pe){ue.executeSql("CREATE TABLE IF NOT EXISTS "+ke.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],pe,Pe)}function fn(ue){var ke=this,pe={db:null};if(ue)for(var Pe in ue)pe[Pe]=typeof ue[Pe]!="string"?ue[Pe].toString():ue[Pe];var $e=new p(function(Ne,tt){try{pe.db=openDatabase(pe.name,String(pe.version),pe.description,pe.size)}catch(mt){return tt(mt)}pe.db.transaction(function(mt){Wt(mt,pe,function(){ke._dbInfo=pe,Ne()},function(Ct,_t){tt(_t)})},tt)});return pe.serializer=Lt,$e}function Jt(ue,ke,pe,Pe,$e,Ne){ue.executeSql(pe,Pe,$e,function(tt,mt){mt.code===mt.SYNTAX_ERR?tt.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[ke.storeName],function(Ct,_t){_t.rows.length?Ne(Ct,mt):Wt(Ct,ke,function(){Ct.executeSql(pe,Pe,$e,Ne)},Ne)},Ne):Ne(tt,mt)},Ne)}function Kn(ue,ke){var pe=this;ue=v(ue);var Pe=new p(function($e,Ne){pe.ready().then(function(){var tt=pe._dbInfo;tt.db.transaction(function(mt){Jt(mt,tt,"SELECT * FROM "+tt.storeName+" WHERE key = ? LIMIT 1",[ue],function(Ct,_t){var kt=_t.rows.length?_t.rows.item(0).value:null;kt&&(kt=tt.serializer.deserialize(kt)),$e(kt)},function(Ct,_t){Ne(_t)})})}).catch(Ne)});return m(Pe,ke),Pe}function nn(ue,ke){var pe=this,Pe=new p(function($e,Ne){pe.ready().then(function(){var tt=pe._dbInfo;tt.db.transaction(function(mt){Jt(mt,tt,"SELECT * FROM "+tt.storeName,[],function(Ct,_t){for(var kt=_t.rows,Xt=kt.length,qn=0;qn<Xt;qn++){var Xn=kt.item(qn),an=Xn.value;if(an&&(an=tt.serializer.deserialize(an)),an=ue(an,Xn.key,qn+1),an!==void 0){$e(an);return}}$e()},function(Ct,_t){Ne(_t)})})}).catch(Ne)});return m(Pe,ke),Pe}function Wn(ue,ke,pe,Pe){var $e=this;ue=v(ue);var Ne=new p(function(tt,mt){$e.ready().then(function(){ke===void 0&&(ke=null);var Ct=ke,_t=$e._dbInfo;_t.serializer.serialize(ke,function(kt,Xt){Xt?mt(Xt):_t.db.transaction(function(qn){Jt(qn,_t,"INSERT OR REPLACE INTO "+_t.storeName+" (key, value) VALUES (?, ?)",[ue,kt],function(){tt(Ct)},function(Xn,an){mt(an)})},function(qn){if(qn.code===qn.QUOTA_ERR){if(Pe>0){tt(Wn.apply($e,[ue,Ct,pe,Pe-1]));return}mt(qn)}})})}).catch(mt)});return m(Ne,pe),Ne}function ln(ue,ke,pe){return Wn.apply(this,[ue,ke,pe,1])}function ns(ue,ke){var pe=this;ue=v(ue);var Pe=new p(function($e,Ne){pe.ready().then(function(){var tt=pe._dbInfo;tt.db.transaction(function(mt){Jt(mt,tt,"DELETE FROM "+tt.storeName+" WHERE key = ?",[ue],function(){$e()},function(Ct,_t){Ne(_t)})})}).catch(Ne)});return m(Pe,ke),Pe}function Js(ue){var ke=this,pe=new p(function(Pe,$e){ke.ready().then(function(){var Ne=ke._dbInfo;Ne.db.transaction(function(tt){Jt(tt,Ne,"DELETE FROM "+Ne.storeName,[],function(){Pe()},function(mt,Ct){$e(Ct)})})}).catch($e)});return m(pe,ue),pe}function ur(ue){var ke=this,pe=new p(function(Pe,$e){ke.ready().then(function(){var Ne=ke._dbInfo;Ne.db.transaction(function(tt){Jt(tt,Ne,"SELECT COUNT(key) as c FROM "+Ne.storeName,[],function(mt,Ct){var _t=Ct.rows.item(0).c;Pe(_t)},function(mt,Ct){$e(Ct)})})}).catch($e)});return m(pe,ue),pe}function zs(ue,ke){var pe=this,Pe=new p(function($e,Ne){pe.ready().then(function(){var tt=pe._dbInfo;tt.db.transaction(function(mt){Jt(mt,tt,"SELECT key FROM "+tt.storeName+" WHERE id = ? LIMIT 1",[ue+1],function(Ct,_t){var kt=_t.rows.length?_t.rows.item(0).key:null;$e(kt)},function(Ct,_t){Ne(_t)})})}).catch(Ne)});return m(Pe,ke),Pe}function fs(ue){var ke=this,pe=new p(function(Pe,$e){ke.ready().then(function(){var Ne=ke._dbInfo;Ne.db.transaction(function(tt){Jt(tt,Ne,"SELECT key FROM "+Ne.storeName,[],function(mt,Ct){for(var _t=[],kt=0;kt<Ct.rows.length;kt++)_t.push(Ct.rows.item(kt).key);Pe(_t)},function(mt,Ct){$e(Ct)})})}).catch($e)});return m(pe,ue),pe}function ps(ue){return new p(function(ke,pe){ue.transaction(function(Pe){Pe.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function($e,Ne){for(var tt=[],mt=0;mt<Ne.rows.length;mt++)tt.push(Ne.rows.item(mt).name);ke({db:ue,storeNames:tt})},function($e,Ne){pe(Ne)})},function(Pe){pe(Pe)})})}function ms(ue,ke){ke=b.apply(this,arguments);var pe=this.config();ue=typeof ue!="function"&&ue||{},ue.name||(ue.name=ue.name||pe.name,ue.storeName=ue.storeName||pe.storeName);var Pe=this,$e;return ue.name?$e=new p(function(Ne){var tt;ue.name===pe.name?tt=Pe._dbInfo.db:tt=openDatabase(ue.name,"","",0),ue.storeName?Ne({db:tt,storeNames:[ue.storeName]}):Ne(ps(tt))}).then(function(Ne){return new p(function(tt,mt){Ne.db.transaction(function(Ct){function _t(Xn){return new p(function(an,Jn){Ct.executeSql("DROP TABLE IF EXISTS "+Xn,[],function(){an()},function(Qn,Gs){Jn(Gs)})})}for(var kt=[],Xt=0,qn=Ne.storeNames.length;Xt<qn;Xt++)kt.push(_t(Ne.storeNames[Xt]));p.all(kt).then(function(){tt()}).catch(function(Xn){mt(Xn)})},function(Ct){mt(Ct)})})}):$e=p.reject("Invalid arguments"),m($e,ke),$e}var Me={_driver:"webSQLStorage",_initStorage:fn,_support:J(),iterate:nn,getItem:Kn,setItem:ln,removeItem:ns,clear:Js,length:ur,key:zs,keys:fs,dropInstance:ms};function lt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function jt(ue,ke){var pe=ue.name+"/";return ue.storeName!==ke.storeName&&(pe+=ue.storeName+"/"),pe}function Qt(){var ue="_localforage_support_test";try{return localStorage.setItem(ue,!0),localStorage.removeItem(ue),!1}catch{return!0}}function Sn(){return!Qt()||localStorage.length>0}function yn(ue){var ke=this,pe={};if(ue)for(var Pe in ue)pe[Pe]=ue[Pe];return pe.keyPrefix=jt(ue,ke._defaultConfig),Sn()?(ke._dbInfo=pe,pe.serializer=Lt,p.resolve()):p.reject()}function Ft(ue){var ke=this,pe=ke.ready().then(function(){for(var Pe=ke._dbInfo.keyPrefix,$e=localStorage.length-1;$e>=0;$e--){var Ne=localStorage.key($e);Ne.indexOf(Pe)===0&&localStorage.removeItem(Ne)}});return m(pe,ue),pe}function sn(ue,ke){var pe=this;ue=v(ue);var Pe=pe.ready().then(function(){var $e=pe._dbInfo,Ne=localStorage.getItem($e.keyPrefix+ue);return Ne&&(Ne=$e.serializer.deserialize(Ne)),Ne});return m(Pe,ke),Pe}function rn(ue,ke){var pe=this,Pe=pe.ready().then(function(){for(var $e=pe._dbInfo,Ne=$e.keyPrefix,tt=Ne.length,mt=localStorage.length,Ct=1,_t=0;_t<mt;_t++){var kt=localStorage.key(_t);if(kt.indexOf(Ne)===0){var Xt=localStorage.getItem(kt);if(Xt&&(Xt=$e.serializer.deserialize(Xt)),Xt=ue(Xt,kt.substring(tt),Ct++),Xt!==void 0)return Xt}}});return m(Pe,ke),Pe}function bs(ue,ke){var pe=this,Pe=pe.ready().then(function(){var $e=pe._dbInfo,Ne;try{Ne=localStorage.key(ue)}catch{Ne=null}return Ne&&(Ne=Ne.substring($e.keyPrefix.length)),Ne});return m(Pe,ke),Pe}function gs(ue){var ke=this,pe=ke.ready().then(function(){for(var Pe=ke._dbInfo,$e=localStorage.length,Ne=[],tt=0;tt<$e;tt++){var mt=localStorage.key(tt);mt.indexOf(Pe.keyPrefix)===0&&Ne.push(mt.substring(Pe.keyPrefix.length))}return Ne});return m(pe,ue),pe}function us(ue){var ke=this,pe=ke.keys().then(function(Pe){return Pe.length});return m(pe,ue),pe}function Hn(ue,ke){var pe=this;ue=v(ue);var Pe=pe.ready().then(function(){var $e=pe._dbInfo;localStorage.removeItem($e.keyPrefix+ue)});return m(Pe,ke),Pe}function ls(ue,ke,pe){var Pe=this;ue=v(ue);var $e=Pe.ready().then(function(){ke===void 0&&(ke=null);var Ne=ke;return new p(function(tt,mt){var Ct=Pe._dbInfo;Ct.serializer.serialize(ke,function(_t,kt){if(kt)mt(kt);else try{localStorage.setItem(Ct.keyPrefix+ue,_t),tt(Ne)}catch(Xt){(Xt.name==="QuotaExceededError"||Xt.name==="NS_ERROR_DOM_QUOTA_REACHED")&&mt(Xt),mt(Xt)}})})});return m($e,pe),$e}function Ps(ue,ke){if(ke=b.apply(this,arguments),ue=typeof ue!="function"&&ue||{},!ue.name){var pe=this.config();ue.name=ue.name||pe.name,ue.storeName=ue.storeName||pe.storeName}var Pe=this,$e;return ue.name?$e=new p(function(Ne){ue.storeName?Ne(jt(ue,Pe._defaultConfig)):Ne(ue.name+"/")}).then(function(Ne){for(var tt=localStorage.length-1;tt>=0;tt--){var mt=localStorage.key(tt);mt.indexOf(Ne)===0&&localStorage.removeItem(mt)}}):$e=p.reject("Invalid arguments"),m($e,ke),$e}var rr={_driver:"localStorageWrapper",_initStorage:yn,_support:lt(),iterate:rn,getItem:sn,setItem:ls,removeItem:Hn,clear:Ft,length:us,key:bs,keys:gs,dropInstance:Ps},ws=function(ke,pe){return ke===pe||typeof ke=="number"&&typeof pe=="number"&&isNaN(ke)&&isNaN(pe)},$s=function(ke,pe){for(var Pe=ke.length,$e=0;$e<Pe;){if(ws(ke[$e],pe))return!0;$e++}return!1},ys=Array.isArray||function(ue){return Object.prototype.toString.call(ue)==="[object Array]"},Pn={},ir={},ot={INDEXEDDB:Zt,WEBSQL:Me,LOCALSTORAGE:rr},ar=[ot.INDEXEDDB._driver,ot.WEBSQL._driver,ot.LOCALSTORAGE._driver],$n=["dropInstance"],kn=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat($n),Nn={description:"",driver:ar.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Bn(ue,ke){ue[ke]=function(){var pe=arguments;return ue.ready().then(function(){return ue[ke].apply(ue,pe)})}}function er(){for(var ue=1;ue<arguments.length;ue++){var ke=arguments[ue];if(ke)for(var pe in ke)ke.hasOwnProperty(pe)&&(ys(ke[pe])?arguments[0][pe]=ke[pe].slice():arguments[0][pe]=ke[pe])}return arguments[0]}var oi=(function(){function ue(ke){a(this,ue);for(var pe in ot)if(ot.hasOwnProperty(pe)){var Pe=ot[pe],$e=Pe._driver;this[pe]=$e,Pn[$e]||this.defineDriver(Pe)}this._defaultConfig=er({},Nn),this._config=er({},this._defaultConfig,ke),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return ue.prototype.config=function(pe){if((typeof pe>"u"?"undefined":i(pe))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var Pe in pe){if(Pe==="storeName"&&(pe[Pe]=pe[Pe].replace(/\W/g,"_")),Pe==="version"&&typeof pe[Pe]!="number")return new Error("Database version must be a number.");this._config[Pe]=pe[Pe]}return"driver"in pe&&pe.driver?this.setDriver(this._config.driver):!0}else return typeof pe=="string"?this._config[pe]:this._config},ue.prototype.defineDriver=function(pe,Pe,$e){var Ne=new p(function(tt,mt){try{var Ct=pe._driver,_t=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!pe._driver){mt(_t);return}for(var kt=kn.concat("_initStorage"),Xt=0,qn=kt.length;Xt<qn;Xt++){var Xn=kt[Xt],an=!$s($n,Xn);if((an||pe[Xn])&&typeof pe[Xn]!="function"){mt(_t);return}}var Jn=function(){for(var Cr=function(_a){return function(){var Va=new Error("Method "+_a+" is not implemented by the current driver"),Ls=p.reject(Va);return m(Ls,arguments[arguments.length-1]),Ls}},Qs=0,ti=$n.length;Qs<ti;Qs++){var gi=$n[Qs];pe[gi]||(pe[gi]=Cr(gi))}};Jn();var Qn=function(Cr){Pn[Ct]&&console.info("Redefining LocalForage driver: "+Ct),Pn[Ct]=pe,ir[Ct]=Cr,tt()};"_support"in pe?pe._support&&typeof pe._support=="function"?pe._support().then(Qn,mt):Qn(!!pe._support):Qn(!0)}catch(Gs){mt(Gs)}});return y(Ne,Pe,$e),Ne},ue.prototype.driver=function(){return this._driver||null},ue.prototype.getDriver=function(pe,Pe,$e){var Ne=Pn[pe]?p.resolve(Pn[pe]):p.reject(new Error("Driver not found."));return y(Ne,Pe,$e),Ne},ue.prototype.getSerializer=function(pe){var Pe=p.resolve(Lt);return y(Pe,pe),Pe},ue.prototype.ready=function(pe){var Pe=this,$e=Pe._driverSet.then(function(){return Pe._ready===null&&(Pe._ready=Pe._initDriver()),Pe._ready});return y($e,pe,pe),$e},ue.prototype.setDriver=function(pe,Pe,$e){var Ne=this;ys(pe)||(pe=[pe]);var tt=this._getSupportedDrivers(pe);function mt(){Ne._config.driver=Ne.driver()}function Ct(Xt){return Ne._extend(Xt),mt(),Ne._ready=Ne._initStorage(Ne._config),Ne._ready}function _t(Xt){return function(){var qn=0;function Xn(){for(;qn<Xt.length;){var an=Xt[qn];return qn++,Ne._dbInfo=null,Ne._ready=null,Ne.getDriver(an).then(Ct).catch(Xn)}mt();var Jn=new Error("No available storage method found.");return Ne._driverSet=p.reject(Jn),Ne._driverSet}return Xn()}}var kt=this._driverSet!==null?this._driverSet.catch(function(){return p.resolve()}):p.resolve();return this._driverSet=kt.then(function(){var Xt=tt[0];return Ne._dbInfo=null,Ne._ready=null,Ne.getDriver(Xt).then(function(qn){Ne._driver=qn._driver,mt(),Ne._wrapLibraryMethodsWithReady(),Ne._initDriver=_t(tt)})}).catch(function(){mt();var Xt=new Error("No available storage method found.");return Ne._driverSet=p.reject(Xt),Ne._driverSet}),y(this._driverSet,Pe,$e),this._driverSet},ue.prototype.supports=function(pe){return!!ir[pe]},ue.prototype._extend=function(pe){er(this,pe)},ue.prototype._getSupportedDrivers=function(pe){for(var Pe=[],$e=0,Ne=pe.length;$e<Ne;$e++){var tt=pe[$e];this.supports(tt)&&Pe.push(tt)}return Pe},ue.prototype._wrapLibraryMethodsWithReady=function(){for(var pe=0,Pe=kn.length;pe<Pe;pe++)Bn(this,kn[pe])},ue.prototype.createInstance=function(pe){return new ue(pe)},ue})(),or=new oi;s.exports=or},{3:3}]},{},[4])(4)}
6708)})(J$)),J$.exports}var ECe=SCe();const Z9=JR(ECe),TCe=({className:t})=>d.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),ACe=({className:t})=>d.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.008-.57-.008-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})}),eI="https://csvmeta.azrafbarno.com",eH="Upscale images with AI directly in your browser!",CCe=({isOpen:t,onClose:e,onDownloadAll:n,count:s})=>{const[r,i]=q.useState(!1);if(!t)return null;const a=()=>{navigator.clipboard.writeText(eI).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)})};return Vde.createPortal(d.jsx("div",{className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/75 backdrop-blur-md p-4 animate-in fade-in duration-200",children:d.jsxs("div",{className:"relative bg-white dark:bg-slate-800 rounded-2xl shadow-2xl w-full max-w-md p-6 transform transition-all scale-100 max-h-[90vh] overflow-y-auto",children:[d.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[d.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-2 bg-[#47ff72]/10",children:d.jsx(HN,{className:"w-8 h-8 text-[#47ff72]"})}),d.jsx("h2",{className:"text-2xl font-bold text-slate-800 dark:text-white",children:"Processing Complete!"}),d.jsx("div",{className:"text-slate-600 dark:text-slate-300",children:d.jsxs("p",{children:[d.jsx("span",{className:"font-bold text-slate-900 dark:text-white",children:s})," images upscaled successfully."]})}),d.jsxs("div",{className:"flex gap-3 w-full mt-6",children:[d.jsx("button",{onClick:e,className:"flex-1 px-4 py-3 text-slate-600 dark:text-slate-300 font-medium hover:bg-slate-100 dark:hover:bg-slate-700 rounded-xl transition-colors",children:"Cancel"}),d.jsxs("button",{onClick:()=>{n(),e()},className:"flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 font-bold rounded-xl shadow-lg shadow-green-500/20 transition-transform active:scale-95",children:[d.jsx(Ua,{className:"w-5 h-5"}),"Download All"]})]}),d.jsxs("a",{href:"https://t.me/csvmeta",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full mt-3 px-4 py-3 bg-transparent border border-[#47ff72] text-[#47ff72] hover:bg-[#229ED9] hover:text-white hover:border-[#229ED9] font-bold rounded-xl shadow-lg shadow-green-500/20 hover:shadow-blue-500/20 transition-transform active:scale-95",children:[d.jsx(Ed,{className:"w-5 h-5"}),"Join our Telegram Community"]}),d.jsxs("div",{className:"mt-8 pt-6 border-t border-slate-100 dark:border-slate-700 w-full",children:[d.jsx("p",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-4",children:"Share this tool"}),d.jsxs("div",{className:"flex items-center justify-center gap-4",children:[d.jsxs("button",{onClick:a,className:"group relative w-12 h-12 flex items-center justify-center rounded-full bg-slate-100 dar
6708k:bg-slate-700 hover:bg-slate-200 dark:hover:bg-slate-600 transition-all text-slate-600 dark:text-slate-200",title:"Copy Link",children:[r?d.jsx(yd,{className:"w-5 h-5 text-green-500"}):d.jsx(XL,{className:"w-5 h-5"}),r&&d.jsx("span",{className:"absolute -top-8 bg-slate-800 text-white text-xs px-2 py-1 rounded shadow-lg animate-in fade-in slide-in-from-bottom-2",children:"Copied!"})]}),d.jsx("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(eI)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-[#1877F2] hover:bg-[#166fe5] text-white transition-transform hover:scale-110 shadow-lg shadow-blue-500/20",title:"Share on Facebook",children:d.jsx(KL,{className:"w-5 h-5 fill-current"})}),d.jsx("a",{href:`https://twitter.com/intent/tweet?url=${encodeURIComponent(eI)}&text=${encodeURIComponent(eH)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-black dark:bg-white hover:bg-slate-900 dark:hover:bg-slate-100 text-white dark:text-black transition-transform hover:scale-110 shadow-lg shadow-slate-500/20",title:"Share on X",children:d.jsx(TCe,{className:"w-5 h-5"})}),d.jsx("a",{href:`https://wa.me/?text=${encodeURIComponent(eH+" "+eI)}`,target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex items-center justify-center rounded-full bg-[#25D366] hover:bg-[#20bd5a] text-white transition-transform hover:scale-110 shadow-lg shadow-green-500/20",title:"Share on WhatsApp",children:d.jsx(ACe,{className:"w-5 h-5"})})]})]})]}),d.jsx("button",{onClick:e,className:"absolute top-4 right-4 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",children:d.jsx(Ki,{className:"w-5 h-5"})})]})}),document.body)};fi.wasm.wasmPaths="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/";const kCe="https://huggingface.co/qualcomm/Real-ESRGAN-General-x4v3/resolve/3fd2853badb4d1c4661559674f54a7d574aadc9f/Real-ESRGAN-General-x4v3.onnx",tH="csv_meta_theme_pref",nH="csv_meta_upscale_factor",sH="csv_meta_upscale_quality",ICe=()=>{Qh(),co();const{remaining:t,showRemaining:e,tryConsumeExport:n}=MM("upscaler"),{isOpen:s,reason:r,openFromGateError:i,closePricingInsist:a}=PA(),[o,l]=q.useState(null),[c,h]=q.useState(!0),[p,m]=q.useState(!0),[y,v]=q.useState(!1),[b,S]=q.useState(!1),[E,I]=q.useState(!1),[M,j]=q.useState(!1),[L,K]=q.useState(!1),[D,R]=q.useState(()=>{const Qe=localStorage.getItem("csv_meta_api_keys");return Qe?JSON.parse(Qe):[]}),[B,G]=q.useState(()=>localStorage.getItem(tH)||"system"),[X,H]=q.useState(!1),[Y,F]=q.useState("checking"),[we,me]=q.useState(0),[xe,Le]=q.useState("wasm"),[ve,ce]=q.useState(null),[ie,de]=q.useState(()=>{const Qe=localStorage.getItem(nH);return Qe?parseInt(Qe,10):4}),[Re,Se]=q.useState(()=>{const Qe=localStorage.getItem(sH);return Qe?parseInt(Qe,10):85}),[De,gt]=q.useState([]),yt=q.useRef([]);q.useEffect(()=>{yt.current=De},[De]);const[xt,Nt]=q.useState(!1),wt=q.useRef(!1),[zt,_n]=q.useState(null),[Zt,J]=q.useState(!1),We=()=>{const Qe=yt.current.some(Ue=>Ue.status==="pending"),tn=yt.current.filter(Ue=>Ue.status==="done").length,je=yt.current.filter(Ue=>Ue.status==="error").length;!Qe&&(tn>0||je>0)&&J(!0)};q.useEffect(()=>{const Qe=window.document.documentElement;B==="dark"||B==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches?Qe.classList.add("dark"):Qe.classList.remove("dark"),localStorage.setItem(tH,B)},[B]),q.useEffect(()=>{const Qe=Vm(Ko,async tn=>{if(tn)try{const je=await Vv(tn);l(je)}catch{l({name:tn.displayName||"",email:tn.email||"",picture:tn.photoURL||"",sub:tn.uid})}else l(null);h(!1)});return et(),()=>Qe()},[]),q.useEffect(()=>{localStorage.setItem("csv_meta_api_keys",JSON.stringify(D))},[D]),q.useEffect(()=>{localStorage.setItem(nH,ie.toString())},[ie]),q.useEffect(()=>{localStorage.setItem(sH,Re.toString())},[Re]);const[Ie,ge]=q.useState(!1),he=Qe=>{gt(tn=>{const je=tn.find(Ue=>Ue.id===Qe);return je!=null&&je.blobUrl&&URL.revokeObjectURL(je.blobUrl),je!=null&&je.resultUrl&&URL.revokeObjectURL(je.resultUrl),tn.filter(Ue=>Ue.id!==Qe)}
6708)},Ae=()=>{De.length!==0&&(De.forEach(Qe=>{Qe.blobUrl&&URL.revokeObjectURL(Qe.blobUrl),Qe.resultUrl&&URL.revokeObjectURL(Qe.resultUrl)}),gt([]),ge(!1))},et=async()=>{try{const Qe=await Z9.getItem("real-esrgan-model");Qe?(F("downloading"),me(100),await ft(Qe)):F("not-ready")}catch(Qe){console.error(Qe),F("not-ready")}},nt=async()=>{try{if(navigator.gpu&&await navigator.gpu.requestAdapter())return"webgpu"}catch{}try{const Qe=document.createElement("canvas");if(Qe.getContext("webgl2")||Qe.getContext("webgl"))return"webgl"}catch{}return"wasm"},He=async()=>{var Qe;if(Y!=="downloading"){F("downloading"),me(0);try{const tn=await fetch(kCe),je=tn.headers.get("content-length"),Ue=parseInt(je||"0",10);let bt=0;const ht=(Qe=tn.body)==null?void 0:Qe.getReader();if(!ht)throw new Error("Failed to read stream");const Dt=[];for(;;){const{done:Wt,value:fn}=await ht.read();if(Wt)break;fn&&(Dt.push(fn),bt+=fn.length,Ue&&me(Math.round(bt/Ue*100)))}const Ut=new Uint8Array(bt);let Lt=0;for(const Wt of Dt)Ut.set(Wt,Lt),Lt+=Wt.length;await Z9.setItem("real-esrgan-model",Ut.buffer),await ft(Ut.buffer)}catch(tn){console.error("Failed to download or load model",tn),F("not-ready"),alert("Failed to download AI model. "+tn)}}},ft=async Qe=>{try{const tn=await nt();Le(tn);const je=await iR.create(Qe,{executionProviders:[tn]});ce(je),F("ready")}catch(tn){console.error("Inference session creation failed",tn);try{const je=await iR.create(Qe,{executionProviders:["wasm"]});Le("wasm"),ce(je),F("ready")}catch(je){F("not-ready"),alert("Failed to load AI model into runtime. "+je)}}},Mt=Qe=>{Qe.preventDefault();let tn=[];"dataTransfer"in Qe?tn=Array.from(Qe.dataTransfer.files):tn=Array.from(Qe.target.files||[]),tn=tn.filter(Ue=>Ue.type.startsWith("image/jpeg")||Ue.type.startsWith("image/png"));const je=tn.map(Ue=>({id:Math.random().toString(36).substring(7),file:Ue,status:"pending",blobUrl:URL.createObjectURL(Ue)}));gt(Ue=>[...Ue,...je])},pt=async(Qe,tn=!1)=>{if(ve){gt(je=>je.map(Ue=>Ue.id===Qe.id?{...Ue,status:"processing"}:Ue));try{const je=new Image;je.src=Qe.blobUrl,await new Promise((ps,ms)=>{je.onload=ps,je.onerror=ms});const Ue=document.createElement("canvas");Ue.width=je.width,Ue.height=je.height,Ue.getContext("2d",{willReadFrequently:!0}).drawImage(je,0,0);const ht=128,Dt=16,Ut=ht-2*Dt,Lt=4,Wt=document.createElement("canvas");Wt.width=Ue.width*Lt,Wt.height=Ue.height*Lt;const fn=Wt.getContext("2d");let Jt=null;Qe.file.type==="image/png"&&(Jt=document.createElement("canvas"),Jt.width=Ue.width*Lt,Jt.height=Ue.height*Lt,Jt.getContext("2d").drawImage(Ue,0,0,Ue.width,Ue.height,0,0,Jt.width,Jt.height));const Kn=Math.ceil(Ue.height/Ut)*Math.ceil(Ue.width/Ut);let nn=0;const Wn=document.createElement("canvas");Wn.width=ht,Wn.height=ht;const ln=Wn.getContext("2d");for(let ps=0;ps<Ue.height;ps+=Ut)for(let ms=0;ms<Ue.width;ms+=Ut){if(tn&&!wt.current)throw new Error("ABORTED");ln.clearRect(0,0,ht,ht);const Me=ms-Dt,lt=ps-Dt;ln.drawImage(Ue,Me,lt,ht,ht,0,0,ht,ht);const jt=ln.getImageData(0,0,ht,ht),Qt=new Float32Array(3*ht*ht);for(let ys=0;ys<ht;ys++)for(let Pn=0;Pn<ht;Pn++){const ir=(ys*ht+Pn)*4,ot=ys*ht+Pn;Qt[ot]=jt.data[ir]/255,Qt[ht*ht+ot]=jt.data[ir+1]/255,Qt[2*ht*ht+ot]=jt.data[ir+2]/255}const Sn=new Vh("float32",Qt,[1,3,ht,ht]),yn={};yn[ve.inputNames[0]]=Sn;const sn=(await ve.run(yn))[ve.outputNames[0]],rn=ht*Lt,bs=sn.data,gs=document.createElement("canvas");gs.width=rn,gs.height=rn;const us=gs.getContext("2d"),Hn=new ImageData(rn,rn);for(let ys=0;ys<rn;ys++)for(let Pn=0;Pn<rn;Pn++){const ir=ys*rn+Pn,ot=(ys*rn+Pn)*4;let ar=bs[ir]*255,$n=bs[rn*rn+ir]*255,kn=bs[2*rn*rn+ir]*255;Hn.data[ot]=Math.max(0,Math.min(255,ar)),Hn.data[ot+1]=Math.max(0,Math.min(255,$n)),Hn.data[ot+2]=Math.max(0,Math.min(255,kn)),Hn.data[ot+3]=255}us.putImageData(Hn,0,0);const ls=Dt*Lt,Ps=Ut*Lt,rr=Math.min(Ut,Ue.width-ms)*Lt,ws=Math.min(Ut,Ue.height-ps)*Lt;fn.drawImage(gs,ls,ls,rr,ws,ms*Lt,ps*Lt,rr,ws),nn++;const $s=Math.round(nn/Kn*100);gt(ys=>ys.map(Pn=>Pn.id===Qe.id?{...Pn,progress:$s}:Pn))}if(Jt){const ps=fn.getImageData(0,0,Wt.width,Wt.height),ms=Jt.getContext("2d").getImageData(0,0,Jt.width,Jt.height);for(let Me=0;Me<ps.data.length;Me+=4)ps.data[Me+3]=ms.data[Me+3];fn.putImageData(ps,0,0)}let ns=Wt;if(ie!==4){const ps=document.createElement("canvas");ps.width=Ue.width*ie,ps.height=Ue.height*ie,ps.getContext("2d").drawImage(Wt,0,0,Wt.width,Wt.height,0,0,ps.width,ps.height),ns=ps}const Js=Qe.file.type==="image/jpeg",ur=Js?"image/jpeg":"image/png",zs=Js?Re/100:void 0,fs=await new Promise(ps=>ns.toBlob(ms=>ps(ms),ur,zs));gt(ps=>ps.map(ms=>ms.id===Qe.id?{...ms,status:"done",progress:100,resultBlob:fs,resultUrl:URL.createObjectURL(fs)}:ms))}catch(je){if(je instanceof Error&&je.message==="ABORTED"){gt(Ue=>Ue.map(bt=>bt.id===Qe.id?{...bt,status:"pending",progress:0}:bt));return}console.error("Processing failed for item",Qe.id,je),gt(Ue=>Ue.map(bt=>bt.id===Qe.id?{...bt,status:"error"}:bt))}}},Oe=async()=>
6708{if(!ve)return;if(xt){Nt(!1),wt.current=!1;return}Nt(!0),wt.current=!0;const Qe=()=>yt.current.filter(tn=>tn.status==="pending"||tn.status==="error");for(;wt.current;){const tn=Qe()[0];if(!tn)break;await pt(tn,!0),await new Promise(je=>setTimeout(je,100))}Nt(!1),wt.current=!1,We()},hn=async()=>{const Qe=await n();if(!Qe.ok){i(Qe.error)||alert(Qe.error);return}const tn=De.filter(ht=>ht.status==="done"&&ht.resultBlob);if(tn.length===0)return;const je=new Date().toISOString().split("T")[0];if(tn.length===1){HS.saveAs(tn[0].resultBlob,tn[0].file.name);return}const Ue=new uj;tn.forEach(ht=>{Ue.file(ht.file.name,ht.resultBlob)});const bt=await Ue.generateAsync({type:"blob"});HS.saveAs(bt,`upscaled-images-${je}.zip`)},Yt=async Qe=>{if(!Qe.resultBlob)return;const tn=await n();if(!tn.ok){i(tn.error)||alert(tn.error);return}HS.saveAs(Qe.resultBlob,`upscaled_${Qe.file.name}`)};return c||!o?d.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:d.jsx(Go,{className:"w-10 h-10 text-[#47ff72] animate-spin"})}):d.jsxs("div",{className:"flex-1 w-full max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-4 sm:py-8 space-y-4 sm:space-y-8 animate-in fade-in zoom-in-95 duration-500",children:[d.jsxs("div",{className:"text-center space-y-4 mb-4",children:[d.jsx("h2",{className:"text-3xl font-bold text-[#47ff72]",children:"Image Upscaler"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-sm sm:text-base max-w-2xl mx-auto",children:"Enhance resolution of images entirely on your device for absolute privacy."})]}),d.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4 mb-4",children:[d.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#47ff72]/10 border border-[#47ff72]/20 rounded-full shadow-sm",children:[d.jsx("div",{className:`w-2 h-2 rounded-full ${Y==="ready"?"bg-[#47ff72] animate-pulse":"bg-slate-400"}`}),d.jsx("span",{className:"text-[10px] sm:text-xs font-bold text-[#47ff72] uppercase tracking-wider",children:"AI Ready"})]}),d.jsx("div",{className:"flex items-center gap-2 bg-white dark:bg-slate-800 p-1 rounded-full border border-slate-200 dark:border-slate-700 shadow-sm",children:[2,3,4].map(Qe=>d.jsxs("button",{onClick:()=>de(Qe),className:`px-4 py-1 rounded-full text-xs font-bold transition-all ${ie===Qe?"bg-[#47ff72] text-slate-900 shadow-md scale-105":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:[Qe,"x"]},Qe))}),d.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-slate-800 px-4 py-1.5 rounded-full border border-slate-200 dark:border-slate-700 shadow-sm group",children:[d.jsx(SM,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#47ff72] transition-colors"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Quality"}),d.jsx("input",{type:"range",min:"10",max:"100",value:Re,onChange:Qe=>Se(parseInt(Qe.target.value)),className:"w-20 sm:w-24 h-1.5 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"}),d.jsxs("span",{className:"text-[10px] font-mono font-bold text-[#47ff72] w-6",children:[Re,"%"]})]})]})]}),Y!=="ready"&&d.jsx("div",{className:"bg-white dark:bg-slate-800 rounded-xl p-4 sm:p-6 shadow-sm border border-slate-200 dark:border-slate-700 font-sans",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3 sm:gap-4",children:[Y==="checking"&&d.jsxs("div",{className:"flex items-center gap-3 text-brand-500 font-medium text-sm",children:[d.jsx(Go,{className:"w-5 h-5 animate-spin"}),"Checking AI Engine..."]}),Y==="not-ready"&&d.jsxs("button",{onClick:He,className:"bg-[#47ff72] text-slate-900 border border-[#47ff72]/20 font-bold px-4 sm:px-6 py-2 rounded-lg hover:opacity-90 transition-all flex items-center gap-2 text-sm sm:text-base shadow-lg shadow-[#47ff72]/10",children:[d.jsx(Ua,{className:"w-4 h-4"}),"Prepare AI Model (~16MB)"]}),Y==="downloading"&&d.jsxs("div",{className:"flex flex-col items-center gap-3 w-full max-w-xs",children:[d.jsxs("div",{className:"flex items-center gap-3 text-[#47ff72] font-bold text-sm",children:[d.jsx(Go,{className:"w-5 h-5 animate-spin"}),we===100?"Loading Model...":`Downloading Model: ${we}%`]}
6708),d.jsx("div",{className:"w-full bg-slate-100 dark:bg-slate-900 rounded-full h-1.5 overflow-hidden",children:d.jsx("div",{className:"bg-[#47ff72] h-full transition-all duration-300",style:{width:`${we}%`}})})]})]})}),Y==="ready"&&d.jsxs("div",{className:"relative",children:[d.jsx("input",{type:"file",id:"upscale-file",multiple:!0,accept:"image/png, image/jpeg",className:"hidden",onChange:Qe=>{Mt(Qe),Qe.target.value=""},title:""}),d.jsxs("div",{className:"group relative border-2 border-dashed border-slate-300 dark:border-slate-700 rounded-2xl bg-white dark:bg-slate-800/50 p-6 sm:p-10 flex flex-col items-center justify-center text-center cursor-pointer hover:border-[#47ff72] dark:hover:border-[#47ff72] transition-all duration-300 overflow-hidden",onDragOver:Qe=>{Qe.preventDefault(),Qe.stopPropagation()},onDrop:Mt,onClick:Qe=>{var tn;Qe.preventDefault(),Qe.stopPropagation(),(tn=document.getElementById("upscale-file"))==null||tn.click()},children:[d.jsxs("div",{className:"flex flex-col items-center gap-4 pointer-events-none",children:[d.jsx("div",{className:"p-4 bg-[#47ff72]/10 rounded-full group-hover:scale-110 group-hover:bg-[#47ff72]/20 transition-all duration-300 shadow-sm group-hover:shadow-[#47ff72]/20",children:d.jsx(yE,{className:"w-8 h-8 sm:w-10 h-10 text-[#47ff72]"})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-base sm:text-lg font-bold text-slate-700 dark:text-slate-200 group-hover:text-[#47ff72] transition-colors",children:"Drag & Drop Images"}),d.jsx("p",{className:"text-xs sm:text-sm text-slate-500 mt-1",children:"or click to browse JPG, PNG files"})]}),d.jsxs("div",{className:"mt-4 sm:mt-6 flex items-center gap-2 px-3 py-1.5 bg-slate-100 dark:bg-slate-900/50 rounded-full border border-slate-200 dark:border-slate-800 opacity-60",children:[d.jsx(HN,{className:"w-3 h-3 sm:w-3.5 h-3.5 text-green-500"}),d.jsx("span",{className:"text-[9px] sm:text-[10px] font-medium text-slate-600 dark:text-slate-400",children:"Processed locally. No upload."})]})]}),d.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#47ff72]/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none"})]}),d.jsx(EE,{showRemaining:e,remaining:t,className:"mt-3"})]}),De.length>0&&d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-xl p-4 sm:p-6 shadow-sm border border-slate-200 dark:border-slate-700 animate-in slide-in-from-bottom-4 duration-500",children:[d.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("h3",{className:"font-bold text-slate-800 dark:text-white uppercase tracking-wider text-sm",children:["Queue (",De.length,")"]}),d.jsxs("button",{onClick:Ae,className:"text-[10px] font-bold px-2 py-1 rounded transition-colors flex items-center gap-1.5 text-red-500 bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/40",children:[d.jsx(xl,{className:"w-3 h-3"})," Clear"]})]}),d.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[d.jsxs("button",{onClick:Oe,disabled:Y!=="ready"||De.filter(Qe=>Qe.status==="pending"||Qe.status==="error").length===0&&!xt,className:`flex-1 sm:flex-none justify-center px-4 py-2 rounded-lg font-bold text-xs sm:text-sm disabled:opacity-50 flex items-center gap-2 active:scale-95 transition-all shadow-sm
6709                                        ${xt?"bg-red-600 text-white hover:bg-red-700 ring-2 ring-red-500/20":"bg-[#47ff72] text-slate-900 hover:bg-[#3ce665]"}`,children:[xt?d.jsx(jF,{className:"w-4 h-4"}):d.jsx(F1,{className:"w-4 h-4"}),xt?"Pause Upscale":De.some(Qe=>Qe.status!=="pending")?"Resume Upscale":"Upscale All"]}),d.jsxs("button",{onClick:hn,disabled:xt||!De.some(Qe=>Qe.status==="done"),className:"flex-1 sm:flex-none justify-center bg-slate-200 dark:bg-slate-700 text-slate-800 dark:text-white px-4 py-2 rounded-lg font-bold text-xs sm:text-sm disabled:opacity-50 flex items-center gap-2 active:scale-95 transition-transform",children:[d.jsx(Ua,{className:"w-4 h-4"})," Download All"]})]})]}),d.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
6709p-3 sm:gap-4 overflow-hidden w-full",children:De.map(Qe=>d.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900 group",children:[d.jsx("img",{src:Qe.resultUrl||Qe.blobUrl,className:"w-full h-32 object-cover transition-transform group-hover:scale-105 duration-500"}),Qe.status==="processing"&&d.jsxs("div",{className:"absolute inset-0 bg-black/40 flex flex-col items-center justify-center p-3 backdrop-blur-[2px]",children:[d.jsx("div",{className:"w-full bg-white/20 h-1.5 rounded-full overflow-hidden",children:d.jsx("div",{className:"h-full bg-[#47ff72] transition-all duration-300",style:{width:`${Qe.progress||0}%`}})}),d.jsxs("span",{className:"text-[10px] font-bold text-white mt-1 shadow-sm",children:[Qe.progress||0,"%"]})]}),d.jsxs("div",{className:"absolute inset-x-0 bottom-0 p-2 bg-gradient-to-t from-black/90 to-transparent flex items-center justify-between",children:[d.jsx("span",{className:"text-[10px] text-white truncate max-w-[80%] font-medium",title:Qe.file.name,children:Qe.file.name}),Qe.status==="pending"&&d.jsx(EA,{className:"w-3.5 h-3.5 text-slate-300"}),Qe.status==="processing"&&d.jsx(Go,{className:"w-3.5 h-3.5 text-[#47ff72] animate-spin"}),Qe.status==="done"&&d.jsx(HN,{className:"w-3.5 h-3.5 text-[#47ff72]"}),Qe.status==="error"&&d.jsx(Jve,{className:"w-3.5 h-3.5 text-red-500"})]}),d.jsx("button",{onClick:()=>he(Qe.id),className:"absolute top-2 left-2 p-1.5 bg-black/50 hover:bg-red-500 text-white rounded opacity-0 group-hover:opacity-100 transition-all z-10",title:"Remove Image",children:d.jsx(xl,{className:"w-3 h-3"})}),(Qe.status==="pending"||Qe.status==="error")&&d.jsx("button",{onClick:()=>{Nt(!0),wt.current=!0,pt(Qe,!0).finally(()=>{Nt(!1),wt.current=!1,We()})},disabled:xt||Y!=="ready",className:"absolute top-2 right-2 p-1.5 bg-black/50 hover:bg-[#47ff72] hover:text-slate-900 text-white rounded opacity-0 group-hover:opacity-100 transition-all z-10 disabled:opacity-30",title:"Upscale This Image",children:d.jsx(F1,{className:"w-3 h-3"})}),Qe.status==="processing"&&d.jsx("button",{onClick:()=>{Nt(!1),wt.current=!1},className:"absolute top-2 right-2 p-1.5 bg-red-600 hover:bg-red-700 text-white rounded z-10",title:"Pause",children:d.jsx(jF,{className:"w-3 h-3"})}),Qe.status==="done"&&d.jsxs(d.Fragment,{children:[d.jsx("button",{onClick:()=>{Yt(Qe)},className:"absolute top-2 right-2 p-1.5 bg-black/50 hover:bg-[#47ff72] hover:text-slate-900 text-white rounded opacity-0 group-hover:opacity-100 transition-all z-10",title:"Download",children:d.jsx(Ua,{className:"w-3 h-3"})}),d.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/20 backdrop-blur-[1px] rounded-lg",children:d.jsxs("button",{onClick:()=>_n(Qe),className:"bg-[#47ff72] text-slate-900 px-3 py-1.5 rounded-full font-bold text-[10px] flex items-center gap-1.5 shadow-lg active:scale-95 transition-transform",children:[d.jsx(Yh,{className:"w-3 h-3"})," Preview"]})})]})]},Qe.id))})]}),zt&&d.jsx(NCe,{item:zt,onClose:()=>_n(null)}),d.jsx(CCe,{isOpen:Zt,onClose:()=>J(!1),onDownloadAll:hn,count:De.filter(Qe=>Qe.status==="done").length}),d.jsx(MA,{isOpen:s,onClose:a,reason:r})]})},NCe=({item:t,onClose:e})=>{const[n,s]=q.useState(50),r=q.useRef(null),i=a=>{if(!r.current)return;const o=r.current.getBoundingClientRect(),l="touches"in a?a.touches[0].clientX:a.clientX,c=Math.max(0,Math.min(100,(l-o.left)/o.width*100));s(c)};return d.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 sm:p-8 bg-black/80 backdrop-blur-md animate-in fade-in duration-300",children:d.jsxs("div",{className:"relative bg-slate-900 border border-slate-800 rounded-3xl overflow-hidden max-w-5xl w-full max-h-full flex flex-col shadow-2xl",children:[d.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/5 bg-white/5",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"bg-[#47ff72]/10 p-2 rounded-xl",children:d.jsx(Yh,{className:"w-5 h-5 text-[#47ff72]"})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-white font-bold text-sm sm:text-base leading-tight",children:"Comparison View"}),d.jsx("p",{className:"text-slate-400 text-[10px] sm:text-xs uppercase tracking-widest font-mono",children:"Drag slider to compare before & after"})]})]}),d.jsx("button",{onClick:e,className:"p-2 hover:bg-white/10 rounded-full text-slate-400 hover:text-white transition-colors",children:d.jsx(Ki,{className:"w-6 h-6"})})]}),d.jsx("div",{className:"flex-1 relative overflow-hidden bg-black flex items-center justify-center p-4",children:d.jsxs("div",{ref:r,className:"relative max-w-full max-h-full aspect-auto rounded-lg overflow-hidden cursor-col-resize select-none",onMouseMove:i,onTouchMove:i,children:[d.jsx("img",{src:t.blobUrl,alt:"Before",className:"max-h-[70vh] w-auto block select-none"}),d.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{clipPath:`inset(0 0 0 ${n}%)`},children:d.jsx("img",{src:t.resultUrl,alt:"After",className:"h-full w-full object-cover select-none"})}),d.jsxs("div",{className:"absolute top-0 bottom-0 z-30 pointer-events-none",style:{left:`${n}%`},children:[d.jsx("div",{className:"absolute inset-y-0 -left-[1px] w-[2px] bg-[#47ff72] 
6709shadow-[0_0_15px_rgba(71,255,114,0.5)]"}),d.jsx("div",{className:"absolute top-1/2 left-0 -translate-x-1/2 -translate-y-1/2 w-8 h-8 bg-[#47ff72] rounded-full flex items-center justify-center shadow-xl ring-4 ring-black/30",children:d.jsxs("div",{className:"flex gap-0.5",children:[d.jsx("div",{className:"w-0.5 h-3 bg-slate-900 rounded-full opacity-30"}),d.jsx("div",{className:"w-0.5 h-3 bg-slate-900 rounded-full"}),d.jsx("div",{className:"w-0.5 h-3 bg-slate-900 rounded-full opacity-30"})]})})]}),d.jsx("div",{className:"absolute bottom-4 left-4 z-40 bg-black/60 backdrop-blur-md text-white text-[10px] font-bold px-3 py-1 rounded-full uppercase tracking-wider border border-white/10",children:"Original"}),d.jsx("div",{className:"absolute bottom-4 right-4 z-40 bg-[#47ff72]/90 text-slate-900 text-[10px] font-bold px-3 py-1 rounded-full uppercase tracking-wider shadow-lg",children:"Upscaled"})]})})]})})},RCe=["p","h1","h2","h3","h4","h5","h6"],rH=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Q$=(t,e)=>{const n=t.replace("#","");if(n.length!==6)return t;const s=parseInt(n.substring(0,2),16),r=parseInt(n.substring(2,4),16),i=parseInt(n.substring(4,6),16);return`rgba(${s}, ${r}, ${i}, ${e/100})`},MCe=t=>{const e=t.split(",")[1],n=atob(e),s=new Uint8Array(n.length);for(let r=0;r<n.length;r++)s[r]=n.charCodeAt(r);return s},PCe=t=>{const e=t.match(/^data:image\/(\w+);/);return e?e[1]==="jpeg"?"jpg":e[1]:"png"},iH=t=>t.replace(/[^a-zA-Z0-9_-]/g,""),$Ce=t=>t===""?24:t,aH=t=>RCe.includes(t)?t:"p",vh=(t,e)=>`${t/e*100}cqw`,oH=(t,e)=>`${t/e*100}cqh`,lH=(t,e,n,s)=>{const r=$Ce(n.fontSize);return`
6710.${t} .bento-text-${e} {
6711  font-family: '${n.font}', sans-serif;
6712  font-size: ${vh(r,s)};
6713  color: ${n.color};
6714  font-weight: ${n.bold?"700":"400"};
6715  font-style: ${n.italic?"italic":"normal"};
6716  text-decoration: ${n.underline?"underline":"none"};
6717  text-align: ${n.alignment};
6718  width: 100%;
6719  margin: 0;
6720  white-space: pre-wrap;
6721  word-break: break-word;
6722  line-height: 1.2;
6723}`},DCe=async t=>{var xe,Le;const{canvasWidth:e,canvasHeight:n,canvasColor:s,canvasPadding:r,gridGap:i,gridBgColor:a,gridBgOpacity:o,gridBorderColor:l,gridBorderOpacity:c,borderWidth:h,borderRadius:p,boxShadowColor:m,boxShadowOpacity:y,boxShadowH:v,boxShadowV:b,boxShadowBlur:S,totalRows:E,boxes:I}=t,M=new uj,j=M.folder("assets"),L={};if(j)for(const ve of I){if(!ve.image)continue;const ce=PCe(ve.image),ie=`box-${iH(ve.id)}.${ce}`;L[ve.id]=`assets/${ie}`,j.file(ie,MCe(ve.image),{binary:!0})}const K=new Set;I.forEach(ve=>{var ce,ie;(ce=ve.textContent1)!=null&&ce.font&&K.add(ve.textContent1.font),(ie=ve.textContent2)!=null&&ie.font&&K.add(ve.textContent2.font)});const D=K.size>0?`<link rel="stylesheet" href="https://fonts.googleapis.com/css2?${Array.from(K).map(ve=>`family=${ve.replace(/ /g,"+")}`).join("&")}&display=swap">`:"",R=Q$(a,o),B=Q$(l,c),X=y>0&&(v!==0||b!==0||S>0)?`${vh(v,e)} ${vh(b,e)} ${vh(S,e)} ${Q$(m,y)}`:"none";let H="",Y="";for(const ve of I){const ce=`box-${iH(ve.id)}`;H+=`
6724.${ce} {
6725  grid-column: ${ve.colStart} / ${ve.colStart+ve.colSpan};
6726  grid-row: ${ve.rowStart} / ${ve.rowStart+ve.rowSpan};
6727}`,ve.textContent1&&(H+=lH(ce,"1",ve.textContent1,e)),ve.textContent2&&(H+=lH(ce,"2",ve.textContent2,e));const ie=ve.image?`<img class="bento-box-image" src="${L[ve.id]}" alt="" style="object-fit: ${ve.imageFit??"cover"}; opacity: ${(ve.imageOpacity??100)/100};" />`:"",de=[];if((xe=ve.textContent1)!=null&&xe.text){const Se=aH(ve.textContent1.htmlTag);de.push(`<${Se} class="bento-text-1">${rH(ve.textContent1.text)}</${Se}>`)}if((Le=ve.textContent2)!=null&&Le.text){const Se=aH(ve.textContent2.htmlTag);de.push(`<${Se} class="bento-text-2">${rH(ve.textContent2.text)}</${Se}>`)}const Re=de.length>0?`<div class="bento-box-text">${de.join(`
6728`)}</div>`:"";Y+=`
6729    <article class="bento-box ${ce}">
6730      <div class="bento-box-fill"></div>
6731      ${ie}
6732      ${Re}
6733    </article>`}const F=`/* Bento Grid — vanilla CSS export (responsive) */
6734*,
6735*::before,
6736*::after {
6737  box-sizing: border-box;
6738}
6739
6740:root {
6741  --design-width: ${e};
6742  --design-height: ${n};
6743}
6744
6745html {
6746  overflow-x: hidden;
6747  -webkit-text-size-adjust: 100%;
6748}
6749
6750body {
6751  margin: 0;
6752  min-height: 100vh;
6753  min-height: 100dvh;
6754  display: flex;
6755  align-items: center;
6756  justify-content: center;
6757  background: #0a0f0c;
6758  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
6759}
6760
6761.bento-viewport {
6762  width: 100%;
6763  max-width: ${e}px;
6764  margin: 0 auto;
6765}
6766
6767.bento-canvas {
6768  container-type: size;
6769  container-name: bento;
6770  width: 100%;
6771  aspect-ratio: ${e} / ${n};
6772  height: auto;
6773  background-color: ${s};
6774  padding: ${oH(r,n)} ${vh(r,e)};
6775  border-radius: ${vh(p,e)};
6776  overflow: hidden;
6777}
6778
6779.bento-grid {
6780  display: grid;
6781  grid-template-columns: repeat(4, minmax(0, 1fr));
6782  grid-template-rows: repeat(${E}, minmax(0, 1fr));
6783  gap: ${vh(i,e)};
6784  width: 100%;
6785  height: 100%;
6786}
6787
6788.bento-box {
6789  position: relative;
6790  overflow: hidden;
6791  border-radius: ${vh(p,e)};
6792  border: ${vh(h,e)} solid ${B};
6793  box-shadow: ${X};
6794}
6795
6796.bento-box-fill {
6797  position: absolute;
6798  inset: 0;
6799  background-color: ${R};
6800  z-index: 0;
6801}
6802
6803.bento-box-image {
6804  position: absolute;
6805  inset: 0;
6806  width: 100%;
6807  height: 100%;
6808  z-index: 1;
6809  display: block;
6810  object-fit: cover;
6811}
6812
6813.bento-box-text {
6814  position: absolute;
6815  inset: 0;
6816  z-index: 2;
6817  display: flex;
6818  flex-direction: column;
6819  align-items: stretch;
6820  justify-content: center;
6821  gap: ${vh(20,e)};
6822  padding: ${oH(24,n)} ${vh(24,e)};
6823  pointer-events: none;
6824}
6825
6826/* Small screens: tighter page padding, top-align if canvas is tall */
6827@media (max-width: 640px) {
6828  body {
6829    align-items: flex-start;
6830    padding-top: max(8px, env(safe-area-inset-top));
6831  }
6832}
6833
6834/* Large screens: cap width at design size (already via max-width on viewport) */
6835@media (min-width: ${e+48}px) {
6836  body {
6837    padding: 24px;
6838  }
6839}
6840${H}
6841`,we=`<!DOCTYPE html>
6842<html lang="en">
6843<head>
6844  <meta charset="UTF-8">
6845  <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
6846  <title>Bento Grid</title>
6847  ${D}
6848  <link rel="stylesheet" href="styles.css">
6849</head>
6850<body>
6851  <div class="bento-viewport">
6852    <main class="bento-canvas">
6853      <div class="bento-grid">
6854${Y}
6855      </div>
6856    </main>
6857  </div>
6858</body>
6859</html>
6860`;M.file("index.html",we),M.file("styles.css",F);const me=await M.generateAsync({type:"blob"});HS.saveAs(me,`bento-grid-${Date.now()}.zip`)},cH=[{value:"p",label:"<p> Paragraph"},{value:"h1",label:"<h1> Heading 1"},{value:"h2",label:"<h2> Heading 2"},{value:"h3",label:"<h3> Heading 3"},{value:"h4",label:"<h4> Heading 4"},{value:"h5",label:"<h5> Heading 5"},{value:"h6",label:"<h6> Heading 6"}],uH=({content:t,text:e})=>{const n=t.htmlTag??"p";return d.jsx(n,{style:{fontFamily:t.font,fontSize:`${t.fontSize||24}px`,color:t.color,fontWeight:t.bold?"bold":"normal",fontStyle:t.italic?"italic":"normal",textDecoration:t.underline?"underline":"none",textAlign:t.alignment,width:"100%",margin:0},className:"whitespace-pre-wrap break-words",children:e})},dH=["Inter","Roboto","Open Sans","Lato","Montserrat","Poppins","Raleway","Playfair Display","Merriweather","Oswald","Ubuntu","Nunito","PT Sans","Quicksand","Bebas Neue"],jb=4,Z$={default:{name:"Standard Bento",boxes:[{id:"1",colStart:1,colSpan:2,rowStart:1,rowSpan:2},{id:"2",colStart:3,colSpan:2,rowStart:1,rowSpan:1},{id:"3",colStart:3,colSpan:1,rowStart:2,rowSpan:1},{id:"4",colStart:4,colSpan:1,rowStart:2,rowSpan:2},{id:"5",colStart:1,colSpan:2,rowStart:3,rowSpan:1},{id:"6",colStart:3,colSpan:1,rowStart:3,rowSpan:1}]},feature:{name:"Hero Feature",boxes:[{id:"1",colStart:1,colSpan:2,rowStart:1,rowSpan:2},{id:"2",colStart:3,colSpan:1,rowStart:1,rowSpan:1},{id:"3",colStart:4,colSpan:1,rowStart:1,rowSpan:1},{id:"4",colStart:3,colSpan:2,rowStart:2,rowSpan:1},{id:"5",colStart:1,colSpan:1,rowStart:3,rowSpan:1},{id:"6",colStart:2,colSpan:2,rowStart:3,rowSpan:1},{id:"7",colStart:4,colSpan:1,rowStart:3,rowSpan:1}]},symmetric:{name:"Symmetric Cards",boxes:[{id:"1",colStart:1,colSpan:2,rowStart:1,rowSpan:1},{id:"2",colStart:3,colSpan:2,rowStart:1,rowSpan:1},{id:"3",colStart:1,colSpan:2,rowStart:2,rowSpan:1},{id:"4",colStart:3,colSpan:2,rowStart:2,rowSpan:1}]},showcase:{name:"Header Banner",boxes:[{id:"1",colStart:1,colSpan:4,rowStart:1,rowSpan:1},{id:"2",colStart:1,colSpan:1,rowStart:2,rowSpan:2},{id:"3",colStart:2,colSpan:2,rowStart:2,rowSpan:1},{id:"4",colStart:4,colSpan:1,rowStart:2,rowSpan:2},{id:"5",colStart:2,colSpan:1,rowStart:3,rowSpan:1},{id:"6",colStart:3,colSpan:1,rowStart:3,rowSpan:1}]}},OCe=()=>{var ms;const{remaining:t,showRemaining:e,tryConsumeExport:n}=MM("bento"),{isOpen:s,reason:r,openFromGateError:i,closePricingInsist:a}=PA(),[o,l]=q.useState(()=>JSON.parse(JSON.stringify(Z$.default.boxes))),[c,h]=q.useState("#011f08"),[p,m]=q.useState(24),[y,v]=q.useState(16),[b,S]=q.useState("#ffffff"),[E,I]=q.useState(8),[M,j]=q.useState("#ffffff"),[L,K]=q.useState(15),[D,R]=q.useState(1),[B,G]=q.useState(16),[X,H]=q.useState(1920),[Y,F]=q.useState(1080),we=q.useRef(null),[me,xe]=q.useState(1),Le=X===""?1920:X,ve=Y===""?1080:Y,[ce,ie]=q.useState("#000000"),[de,Re]=q.useState(50),[Se,De]=q.useState(0),[gt,yt]=q.useState(4),[xt,Nt]=q.useState(12),[wt,zt]=q.useState("canvas"),[_n,Zt]=q.useState(null),[J,We]=q.useState(!1),[Ie,ge]=q.useState(!1),[he,Ae]=q.useState("png"),et=q.useRef(null),nt=q.useRef(null),He=q.useRef(null),[ft,Mt]=q.useState(null),pt=q.useRef(!1),Oe=wt!=="canvas"?o.find(Me=>Me.id===wt):null;q.useEffect(()=>{if(_n){const Me=setTimeout(()=>Zt(null),3e3);return()=>clearTimeout(Me)}},[_n]),q.useEffect(()=>{if(!we.current)return;const Me=new ResizeObserver(lt=>{const{width:jt}=lt[0].contentRect,Qt=jt-48,Sn=Math.min(1,Qt/Le);xe(Sn)});return Me.observe(we.current),()=>Me.disconnect()},[Le]),q.useEffect(()=>{if(!Ie)return;const Me=lt=>{nt.current&&!nt.current.contains(lt.target)&&ge(!1)};return document.addEventListener("mousedown",Me),()=>document.removeEventListener("mousedown",Me)},[Ie]),q.useEffect(()=>{const Me=new Set;
6860if(o.forEach(lt=>{var jt,Qt;(jt=lt.textContent1)!=null&&jt.font&&Me.add(lt.textContent1.font),(Qt=lt.textContent2)!=null&&Qt.font&&Me.add(lt.textContent2.font)}),Me.size>0){const lt=document.createElement("link");return lt.rel="stylesheet",lt.href=`https://fonts.googleapis.com/css2?${Array.from(Me).map(jt=>`family=${jt.replace(/ /g,"+")}`).join("&")}&display=swap`,document.head.appendChild(lt),()=>{document.head.removeChild(lt)}}},[o]);const hn=(Me,lt,jt,Qt,Sn,yn)=>{const Ft=lt+jt,sn=Qt+Sn;if(lt<1||Ft-1>jb||Qt<1)return!0;for(const rn of yn){if(rn.id===Me)continue;const bs=rn.colStart+rn.colSpan,gs=rn.rowStart+rn.rowSpan,us=Math.max(0,Math.min(Ft,bs)-Math.max(lt,rn.colStart)),Hn=Math.max(0,Math.min(sn,gs)-Math.max(Qt,rn.rowStart));if(us>0&&Hn>0)return!0}return!1},Yt=Me=>{let lt=1;for(;;){for(let jt=1;jt<=4;jt++)if(!Me.some(Sn=>{const yn=Sn.colStart+Sn.colSpan,Ft=Sn.rowStart+Sn.rowSpan;return jt>=Sn.colStart&&jt<yn&&lt>=Sn.rowStart&&lt<Ft}))return{colStart:jt,rowStart:lt};lt++}},Qe=()=>{const Me=Yt(o),lt={id:Date.now().toString(),colStart:Me.colStart,colSpan:1,rowStart:Me.rowStart,rowSpan:1,imageFit:"cover",imageOpacity:100};l(jt=>[...jt,lt]),zt(lt.id)},tn=(Me,lt)=>{lt&&lt.stopPropagation(),l(jt=>jt.filter(Qt=>Qt.id!==Me)),wt===Me&&zt("canvas")},je=o.reduce((Me,lt)=>Math.max(Me,lt.rowStart+lt.rowSpan-1),0),Ue=Math.max(je,3),bt=(Me,lt,jt,Qt,Sn,yn)=>lt<1||Qt<1||jt<1||Sn<1||lt+jt-1>jb?!1:!hn(Me,lt,jt,Qt,Sn,yn),ht=(Me,lt,jt=!1)=>{l(Qt=>bt(Me,lt.colStart,lt.colSpan,lt.rowStart,lt.rowSpan,Qt)?Qt.map(Sn=>Sn.id===Me?{...Sn,...lt}:Sn):(jt&&(lt.colStart+lt.colSpan-1>jb?Zt("Grid cannot exceed 4 columns!"):Zt("Cannot move or resize here: would overlap with another grid item!")),Qt))},Dt=(Me,lt,jt)=>{const Qt=o.find(yn=>yn.id===Me);if(!Qt)return;const Sn={colStart:lt==="colStart"?jt:Qt.colStart,colSpan:lt==="colSpan"?jt:Qt.colSpan,rowStart:lt==="rowStart"?jt:Qt.rowStart,rowSpan:lt==="rowSpan"?jt:Qt.rowSpan};ht(Me,Sn,!0)},Ut=()=>{const Me=Le-p*2,lt=ve-p*2,jt=(Me-(jb-1)*y)/jb,Qt=(lt-(Ue-1)*y)/Ue;return{scaledCellW:jt*me,scaledCellH:Qt*me,scaledGap:y*me}},Lt=(Me,lt)=>{if(!He.current)return{col:1,row:1};const jt=He.current.getBoundingClientRect(),Qt=Me-jt.left,Sn=lt-jt.top,{scaledCellW:yn,scaledCellH:Ft,scaledGap:sn}=Ut(),rn=(bs,gs,us,Hn)=>{let ls=0;for(let Ps=1;Ps<=Hn;Ps++){if(bs<ls+gs)return Ps;ls+=gs+us}return Hn};return{col:rn(Qt,yn,sn,jb),row:rn(Sn,Ft,sn,Ue)}},Wt=(Me,lt,jt)=>{Me.stopPropagation(),Me.preventDefault();const{col:Qt,row:Sn}=Lt(Me.clientX,Me.clientY);zt(lt.id),pt.current=!1,Mt({mode:jt,boxId:lt.id,startClientX:Me.clientX,startClientY:Me.clientY,grabColOffset:Qt-lt.colStart,grabRowOffset:Sn-lt.rowStart,initial:{colStart:lt.colStart,colSpan:lt.colSpan,rowStart:lt.rowStart,rowSpan:lt.rowSpan}})};q.useEffect(()=>{if(!ft)return;document.body.style.userSelect="none",document.body.style.cursor=ft.mode==="move"?"grabbing":"nwse-resize";const Me=jt=>{if(!ft)return;(Math.abs(jt.clientX-ft.startClientX)>3||Math.abs(jt.clientY-ft.startClientY)>3)&&(pt.current=!0);const{col:Qt,row:Sn}=Lt(jt.clientX,jt.clientY),{initial:yn}=ft;ft.mode==="move"?ht(ft.boxId,{colStart:Qt-ft.grabColOffset,colSpan:yn.colSpan,rowStart:Sn-ft.grabRowOffset,rowSpan:yn.rowSpan}):ht(ft.boxId,{colStart:yn.colStart,colSpan:Qt-yn.colStart+1,rowStart:yn.rowStart,rowSpan:Sn-yn.rowStart+1})},lt=()=>{Mt(null)};return window.addEventListener("mousemove",Me),window.addEventListener("mouseup",lt),()=>{window.removeEventListener("mousemove",Me),window.removeEventListener("mouseup",lt),document.body.style.userSelect="",document.body.style.cursor=""}},[ft,me,y,Ue,Le,ve,p]);const fn=Me=>{const lt=Z$[Me];lt&&(l(JSON.parse(JSON.stringify(lt.boxes))),zt("canvas"))},Jt=()=>{et.current&&et.current.click()},Kn=Me=>{var Qt;const lt=(Qt=Me.target.files)==null?void 0:Qt[0];if(!lt||!Oe)return;const jt=new FileReader;jt.onload=Sn=>{var Ft;const yn=(Ft=Sn.target)==null?void 0:Ft.result;l(sn=>sn.map(rn=>rn.id===Oe.id?{...rn,image:yn}:rn))},jt.readAsDataURL(lt)},nn=Me=>{l(lt=>lt.map(jt=>jt.id===Me?{...jt,image:void 0}:jt))},Wn=()=>({text:"",alignment:"center",font:"Inter",fontSize:64,htmlTag:"p",bold:!1,italic:!1,underline:!1,color:"#ffffff"}),ln=(Me,lt,jt)=>{l(Qt=>Qt.map(Sn=>{if(Sn.id===Me){const yn=lt===1?"textContent1":"textContent2",Ft=Sn[yn]||Wn();return{...Sn,[yn]:{...Ft,...jt}}}return Sn}))},ns=(Me,lt)=>{l(jt=>jt.map(Qt=>Qt.id===Me?{...Qt,[lt===1?"textContent1":"textContent2"]:void 0}:Qt))},Js=()=>
6860{if(xt===0&&Se===0&&gt===0)return"none";const Me=Math.round(de*2.55).toString(16).padStart(2,"0");return`${Se}px ${gt}px ${xt}px ${ce}${Me}`},ur=Me=>new Promise((lt,jt)=>{const Qt=new Image;Qt.crossOrigin="anonymous",Qt.onload=()=>lt(Qt),Qt.onerror=()=>jt(new Error("Failed to load image: "+Me)),Qt.src=Me}),zs=async Me=>{if(!document.fonts.check(`16px "${Me}"`)){const lt=new FontFace(Me,`url(https://fonts.googleapis.com/css2?family=${Me.replace(/ /g,"+")}&display=swap)`);try{await lt.load(),document.fonts.add(lt)}catch(jt){console.warn(`Failed to load font: ${Me}`,jt)}}},fs=(Me,lt,jt)=>{const Qt=lt.split(`
6861`),Sn=[];for(const yn of Qt){const Ft=yn.split(" ");let sn=Ft[0]||"";for(let rn=1;rn<Ft.length;rn++){const bs=Ft[rn];Me.measureText(sn+" "+bs).width<jt?sn+=" "+bs:(Sn.push(sn),sn=bs)}Sn.push(sn)}return Sn},ps=async(Me="png")=>{var jt,Qt,Sn,yn,Ft,sn,rn,bs,gs,us;const lt=await n();if(!lt.ok){i(lt.error)||alert(lt.error);return}We(!0);try{if(Me==="html"){await DCe({canvasWidth:Math.min(4e3,Math.max(100,Le)),canvasHeight:Math.min(4e3,Math.max(100,ve)),canvasColor:c,canvasPadding:p,gridGap:y,gridBgColor:b,gridBgOpacity:E,gridBorderColor:M,gridBorderOpacity:L,borderWidth:D,borderRadius:B,boxShadowColor:ce,boxShadowOpacity:de,boxShadowH:Se,boxShadowV:gt,boxShadowBlur:xt,totalRows:je,boxes:o}),ge(!1);return}const Hn=4,ls=je,Ps=Math.min(4e3,Math.max(100,Le)),rr=Math.min(4e3,Math.max(100,ve)),$s=(Le-p*2-(Hn-1)*y)/Hn,Pn=(ve-p*2-(ls-1)*y)/ls,ir=document.createElement("canvas");ir.width=Ps,ir.height=rr;const ot=ir.getContext("2d");if(!ot)throw new Error("Could not get canvas context");ot.fillStyle=c,ot.fillRect(0,0,Ps,rr);const ar={},$n=new Set;for(const Bn of o){if(Bn.image)try{ar[Bn.id]=await ur(Bn.image)}catch(er){console.warn(`Failed to preload image for box ${Bn.id}`,er)}(jt=Bn.textContent1)!=null&&jt.font&&$n.add(Bn.textContent1.font),(Qt=Bn.textContent2)!=null&&Qt.font&&$n.add(Bn.textContent2.font)}if(await Promise.all(Array.from($n).map(Bn=>zs(Bn))),de>0&&(Se!==0||gt!==0||xt>0)){ot.save(),ot.shadowColor=`${ce}${Math.round(de*2.55).toString(16).padStart(2,"0")}`,ot.shadowBlur=xt,ot.shadowOffsetX=Se,ot.shadowOffsetY=gt;for(const Bn of o){const er=p+(Bn.colStart-1)*($s+y),oi=p+(Bn.rowStart-1)*(Pn+y),or=Bn.colSpan*$s+(Bn.colSpan-1)*y,ue=Bn.rowSpan*Pn+(Bn.rowSpan-1)*y;ot.beginPath(),ot.roundRect(er,oi,or,ue,B),ot.fillStyle=c,ot.fill()}ot.restore()}for(const Bn of o){const er=p+(Bn.colStart-1)*($s+y),oi=p+(Bn.rowStart-1)*(Pn+y),or=Bn.colSpan*$s+(Bn.colSpan-1)*y,ue=Bn.rowSpan*Pn+(Bn.rowSpan-1)*y;ot.save(),ot.beginPath(),ot.roundRect(er,oi,or,ue,B),ot.clip();const ke=Math.round(E*2.55).toString(16).padStart(2,"0");ot.fillStyle=`${b}${ke}`,ot.fillRect(er,oi,or,ue);const pe=ar[Bn.id];if(pe)if(ot.globalAlpha=(Bn.imageOpacity??100)/100,(Bn.imageFit??"cover")==="cover"){const $e=pe.width/pe.height,Ne=or/ue;let tt,mt,Ct,_t;$e>Ne?(mt=ue,tt=ue*$e,Ct=er+(or-tt)/2,_t=oi):(tt=or,mt=or/$e,Ct=er,_t=oi+(ue-mt)/2),ot.drawImage(pe,Ct,_t,tt,mt)}else{const $e=pe.width/pe.height,Ne=or/ue;let tt,mt,Ct,_t;$e>Ne?(tt=or,mt=or/$e,Ct=er,_t=oi+(ue-mt)/2):(mt=ue,tt=ue*$e,Ct=er+(or-tt)/2,_t=oi),ot.drawImage(pe,Ct,_t,tt,mt)}if(ot.restore(),(Sn=Bn.textContent1)!=null&&Sn.text||(yn=Bn.textContent2)!=null&&yn.text){ot.save();const Pe=24,$e=or-Pe*2;let Ne=[],tt=[];if((Ft=Bn.textContent1)!=null&&Ft.text){const an=Bn.textContent1,Jn=an.bold?"bold":"normal",Qn=an.italic?"italic":"normal";ot.font=`${Qn} ${Jn} ${an.fontSize||24}px "${an.font}", sans-serif`,Ne=fs(ot,an.text,$e)}if((sn=Bn.textContent2)!=null&&sn.text){const an=Bn.textContent2,Jn=an.bold?"bold":"normal",Qn=an.italic?"italic":"normal";ot.font=`${Qn} ${Jn} ${an.fontSize||24}px "${an.font}", sans-serif`,tt=fs(ot,an.text,$e)}const mt=((rn=Bn.textContent1)==null?void 0:rn.fontSize)||24,Ct=((bs=Bn.textContent2)==null?void 0:bs.fontSize)||24,_t=Ne.length>0?Ne.length*(mt*1.2):0,kt=tt.length>0?tt.length*(Ct*1.2):0,Xt=_t>0&&kt>0?20:0,qn=_t+kt+Xt;let Xn=oi+(ue-qn)/2;if((gs=Bn.textContent1)!=null&&gs.text){const an=Bn.textContent1,Jn=an.bold?"bold":"normal",Qn=an.italic?"italic":"normal";ot.font=`${Qn} ${Jn} ${mt}px "${an.font}", sans-serif`,ot.fillStyle=an.color,ot.textBaseline="top",Ne.forEach((Gs,Cr)=>{let Qs=er;if(an.alignment==="center"?(ot.textAlign="center",Qs=er+or/2):an.alignment==="right"?(ot.textAlign="right",Qs=er+or-Pe):(ot.textAlign="left",Qs=er+Pe),ot.fillText(Gs,Qs,Xn+Cr*mt*1.2),an.underline){const ti=ot.measureText(Gs),gi=Xn+Cr*mt*1.2+mt;let yr=Qs;an.alignment==="center"?yr=Qs-ti.width/2:an.alignment==="right"&&(yr=Qs-ti.width),ot.beginPath(),ot.moveTo(yr,gi),ot.lineTo(yr+ti.width,gi),ot.strokeStyle=an.color,ot.lineWidth=Math.max(1,mt/20),ot.stroke()}}),Xn+=_t+Xt}if((us=Bn.textContent2)!=null&&us.text){const an=Bn.textContent2,Jn=an.bold?"bold":"normal",Qn=an.italic?"italic":"normal";ot.font=`${Qn} ${Jn} ${Ct}px "${an.font}", sans-serif`,ot.fillStyle=an.color,ot.textBaseline="top",tt.forEach((Gs,Cr)=>{let Qs=er;if(an.alignment==="center"?(ot.textAlign="center",Qs=er+or/2):an.alignment==="right"?(ot.textAlign="right",Qs=er+or-Pe):(ot.textAlign="left",Qs=er+Pe),ot.fillText(Gs,Qs,Xn+Cr*Ct*1.2),an.underline){const ti=ot.measureText(Gs),gi=Xn+Cr*Ct*1.2+Ct;let yr=Qs;an.alignment==="center"?yr=Qs-ti.width/2:an.alignment==="right"&&(yr=Qs-ti.width),ot.beginPath(),ot.moveTo(yr,gi),ot.lineTo(yr+ti.width,gi),ot.strokeStyle=an.color,ot.lineWidth=Math.max(1,Ct/20),ot.stroke()}})}
6861ot.restore()}if(D>0){ot.save(),ot.beginPath(),ot.roundRect(er,oi,or,ue,B);const Pe=Math.round(L*2.55).toString(16).padStart(2,"0");ot.strokeStyle=`${M}${Pe}`,ot.lineWidth=D,ot.stroke(),ot.restore()}}const kn=document.createElement("a"),Nn=Date.now();Me==="jpg"?(kn.download=`bento-grid-${Nn}.jpg`,kn.href=ir.toDataURL("image/jpeg",.92)):(kn.download=`bento-grid-${Nn}.png`,kn.href=ir.toDataURL("image/png")),kn.click(),ge(!1)}catch(Hn){console.error(Hn),Zt(Me==="html"?"Failed to export HTML package. Make sure images loaded are valid.":"Failed to export bento image. Make sure images loaded are valid.")}finally{We(!1)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex-1 w-full max-w-[1600px] w-[96%] mx-auto px-4 sm:px-6 lg:px-8 py-4 sm:py-8 space-y-4 sm:space-y-8 animate-in fade-in zoom-in-95 duration-500",children:[d.jsxs("div",{className:"text-center space-y-4 mb-4",children:[d.jsx("h2",{className:"text-3xl font-bold text-[#47ff72] flex items-center justify-center gap-2",children:"Bento Grid Generator"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-sm sm:text-base max-w-2xl mx-auto",children:"Create, customize, and fill elegant Bento grid designs for your portfolio, presentations, or microstock assets."})]}),d.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-6 sm:gap-8 items-start",children:[d.jsxs("div",{className:"xl:col-span-1 bg-white dark:bg-slate-800/80 border border-slate-200 dark:border-slate-700/50 rounded-2xl p-4 sm:p-6 shadow-md space-y-6 xl:max-h-[calc(100vh-12rem)] xl:overflow-y-auto xl:sticky xl:top-24",children:[d.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 dark:border-slate-700 pb-3",children:[d.jsxs("h3",{className:"text-base font-bold text-slate-800 dark:text-white flex items-center gap-2",children:[d.jsx(Z0,{className:"w-5 h-5 text-[#47ff72]"}),wt==="canvas"?"Canvas Settings":"Box Settings"]}),wt!=="canvas"&&d.jsxs("button",{onClick:()=>zt("canvas"),className:"text-xs font-semibold text-[#47ff72] hover:text-[#3ce565] transition-colors flex items-center gap-1 bg-slate-100 dark:bg-slate-900 px-2 py-1 rounded",children:[d.jsx(qL,{className:"w-3.5 h-3.5"})," Back to Canvas"]})]}),d.jsx(kv,{children:_n&&d.jsx(ks.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"p-3 bg-red-500/10 border border-red-500/20 text-red-500 rounded-xl text-xs font-semibold",children:_n})}),wt==="canvas"?d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Canvas Width (px)"}),d.jsx("input",{type:"number",min:"100",max:"4000",value:X,onChange:Me=>{const lt=Me.target.value;if(lt==="")H("");else{const jt=parseInt(lt,10);Number.isNaN(jt)||H(jt)}},onBlur:()=>{X===""||typeof X=="number"&&X<100?H(1920):typeof X=="number"&&X>4e3&&H(4e3)},className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl px-4 py-2 text-sm outline-none focus:border-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Canvas Height (px)"}),d.jsx("input",{type:"number",min:"100",max:"4000",value:Y,onChange:Me=>{const lt=Me.target.value;if(lt==="")F("");else{const jt=parseInt(lt,10);Number.isNaN(jt)||F(jt)}},onBlur:()=>{Y===""||typeof Y=="number"&&Y<100?F(1080):typeof Y=="number"&&Y>4e3&&F(4e3)},className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl px-4 py-2 text-sm outline-none focus:border-[#47ff72]"})]})]}),d.jsxs("button",{onClick:Qe,className:"w-full flex items-center justify-center gap-2 py-3 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-xl font-bold transition-all shadow-md",children:[d.jsx(Tv,{className:"w-5 h-5"})," Add Grid Box"]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Layout Presets"}),d.jsx("div",{className:"grid grid-cols-2 gap-2",children:Object.entries(Z$).map(([Me,lt])=>d.jsx("button",{onClick:()=>fn(Me),className:"px-3 py-2 bg-slate-100 hover:bg-slate-200 dark:bg-slate-900 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded-xl text-xs font-bold transition-all truncate",children:lt.name},Me))})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Canvas Color"}),d.jsxs("div",{className:"flex gap-3 items-center",children:[d.jsx("div",{className:"relative w-12 h-10 rounded-lg overflow-hidden border border-slate-300 dark:border-slate-700 flex-shrink-0",children:d.jsx("input",{type:"color",value:c,onChange:Me=>h(Me.target.value),className:"absolute inset-0 w-full h-full p-0 border-0 cursor-pointer"})}),d.jsx("input",{type:"text",value:c,onChange:Me=>
6861h(Me.target.value),className:"flex-1 bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl px-4 py-2 text-sm text-[#47ff72] font-mono outline-none focus:border-[#47ff72]"})]})]}),d.jsxs("div",{className:"space-y-4 p-4 bg-slate-50 dark:bg-slate-900/50 rounded-xl border border-slate-200 dark:border-slate-700",children:[d.jsx("h4",{className:"text-xs font-bold text-slate-800 dark:text-slate-300 uppercase tracking-wider",children:"Grid Box Background Style"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex justify-between items-center text-xs",children:[d.jsx("span",{className:"text-slate-500 font-bold",children:"Fill Color"}),d.jsxs("span",{className:"text-[#47ff72]",children:[E,"%"]})]}),d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsx("input",{type:"color",value:b,onChange:Me=>S(Me.target.value),className:"w-8 h-8 rounded cursor-pointer border-0 p-0 overflow-hidden flex-shrink-0"}),d.jsx("input",{type:"range",min:"0",max:"100",value:E,onChange:Me=>I(parseInt(Me.target.value)),className:"flex-1 h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex justify-between items-center text-xs",children:[d.jsx("span",{className:"text-slate-500 font-bold",children:"Border Color"}),d.jsxs("span",{className:"text-[#47ff72]",children:[L,"%"]})]}),d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsx("input",{type:"color",value:M,onChange:Me=>j(Me.target.value),className:"w-8 h-8 rounded cursor-pointer border-0 p-0 overflow-hidden flex-shrink-0"}),d.jsx("input",{type:"range",min:"0",max:"100",value:L,onChange:Me=>K(parseInt(Me.target.value)),className:"flex-1 h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"})]})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500",children:"Border Width"}),d.jsx("input",{type:"number",min:"0",max:"10",value:D,onChange:Me=>R(Math.max(0,parseInt(Me.target.value)||0)),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500",children:"Corner Radius"}),d.jsx("input",{type:"number",min:"0",max:"60",value:B,onChange:Me=>G(Math.max(0,parseInt(Me.target.value)||0)),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]"})]})]})]}),d.jsxs("div",{className:"space-y-4 p-4 bg-slate-50 dark:bg-slate-900/50 rounded-xl border border-slate-200 dark:border-slate-700",children:[d.jsx("h4",{className:"text-xs font-bold text-slate-800 dark:text-slate-300 uppercase tracking-wider",children:"Grid Box Shadows"}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500",children:"Horizontal"}),d.jsx("input",{type:"number",value:Se,onChange:Me=>De(parseInt(Me.target.value)||0),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-2.5 py-1 text-xs outline-none"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500",children:"Vertical"}),d.jsx("input",{type:"number",value:gt,onChange:Me=>yt(parseInt(Me.target.value)||0),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-2.5 py-1 text-xs outline-none"})]})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500",children:"Blur Radius"}),d.jsx("input",{type:"number",min:"0",value:xt,onChange:Me=>Nt(Math.max(0,parseInt(Me.target.value)||0)),className:"w-full bg-slate-100 dar
6861k:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-2.5 py-1 text-xs outline-none"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500",children:"Color"}),d.jsx("input",{type:"color",value:ce,onChange:Me=>ie(Me.target.value),className:"w-full h-7 rounded border-0 cursor-pointer p-0 overflow-hidden"})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex justify-between items-center text-xs",children:[d.jsx("span",{className:"text-slate-500",children:"Shadow Opacity"}),d.jsxs("span",{className:"text-[#47ff72]",children:[de,"%"]})]}),d.jsx("input",{type:"range",min:"0",max:"100",value:de,onChange:Me=>Re(parseInt(Me.target.value)),className:"w-full h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"})]})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Padding (px)"}),d.jsx("input",{type:"number",min:"0",max:"100",value:p,onChange:Me=>m(Math.max(0,parseInt(Me.target.value)||0)),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl px-4 py-2 text-sm outline-none focus:border-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider block",children:"Grid Gap (px)"}),d.jsx("input",{type:"number",min:"0",max:"60",value:y,onChange:Me=>v(Math.max(0,parseInt(Me.target.value)||0)),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl px-4 py-2 text-sm outline-none focus:border-[#47ff72]"})]})]})]}):Oe&&d.jsxs("div",{className:"space-y-6 animate-in fade-in duration-300",children:[d.jsxs("div",{className:"space-y-4 p-4 bg-slate-50 dark:bg-slate-900/50 rounded-xl border border-slate-200 dark:border-slate-700",children:[d.jsx("h4",{className:"text-xs font-bold text-slate-800 dark:text-slate-300 uppercase tracking-wider",children:"Grid Placement"}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Column Start (1-4)"}),d.jsxs("div",{className:"flex gap-1",children:[d.jsx("button",{onClick:()=>Dt(Oe.id,"colStart",Math.max(1,Oe.colStart-1)),disabled:Oe.colStart<=1,className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 disabled:opacity-50 text-xs font-bold",children:"-"}),d.jsx("span",{className:"flex-1 text-center py-1 bg-slate-100 dark:bg-slate-900 text-sm font-bold font-mono",children:Oe.colStart}),d.jsx("button",{onClick:()=>Dt(Oe.id,"colStart",Math.min(4,Oe.colStart+1)),disabled:Oe.colStart>=4,className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 disabled:opacity-50 text-xs font-bold",children:"+"})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Column Span (1-4)"}),d.jsxs("div",{className:"flex gap-1",children:[d.jsx("button",{onClick:()=>Dt(Oe.id,"colSpan",Math.max(1,Oe.colSpan-1)),disabled:Oe.colSpan<=1,className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 disabled:opacity-50 text-xs font-bold",children:"-"}),d.jsx("span",{className:"flex-1 text-center py-1 bg-slate-100 dark:bg-slate-900 text-sm font-bold font-mono",children:Oe.colSpan}),d.jsx("button",{onClick:()=>Dt(Oe.id,"colSpan",Math.min(4,Oe.colSpan+1)),disabled:Oe.colStart+Oe.colSpan-1>=4,className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 disabled:opacity-50 text-xs font-bold",children:"+"})]})]})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Row Start (1+)"}),d.jsxs("div",{className:"flex gap-1",children:[d.jsx("button",{onClick:()=>Dt(Oe.id,"rowStart",Math.max(1,Oe.rowStart-1)),disabled:Oe.rowStart<=1,className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 disabled:opacity-50 text-xs font-bold",children:"-"}),d.jsx("span",{className:"flex-1 text-center py-1 bg-slate-100 dar
6861k:bg-slate-900 text-sm font-bold font-mono",children:Oe.rowStart}),d.jsx("button",{onClick:()=>Dt(Oe.id,"rowStart",Oe.rowStart+1),className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 text-xs font-bold",children:"+"})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Row Span (1+)"}),d.jsxs("div",{className:"flex gap-1",children:[d.jsx("button",{onClick:()=>Dt(Oe.id,"rowSpan",Math.max(1,Oe.rowSpan-1)),disabled:Oe.rowSpan<=1,className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 disabled:opacity-50 text-xs font-bold",children:"-"}),d.jsx("span",{className:"flex-1 text-center py-1 bg-slate-100 dark:bg-slate-900 text-sm font-bold font-mono",children:Oe.rowSpan}),d.jsx("button",{onClick:()=>Dt(Oe.id,"rowSpan",Oe.rowSpan+1),className:"px-2.5 py-1 bg-slate-200 dark:bg-slate-800 rounded hover:bg-slate-300 text-xs font-bold",children:"+"})]})]})]})]}),d.jsxs("div",{className:"space-y-4 p-4 bg-slate-50 dark:bg-slate-900/50 rounded-xl border border-slate-200 dark:border-slate-700",children:[d.jsxs("h4",{className:"text-xs font-bold text-slate-800 dark:text-slate-300 uppercase tracking-wider flex items-center gap-1.5",children:[d.jsx(bM,{className:"w-4 h-4 text-[#47ff72]"})," Image Content"]}),Oe.image?d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-slate-300 dark:border-slate-700 h-32 bg-slate-950 flex items-center justify-center",children:[d.jsx("img",{src:Oe.image,alt:"Box source",className:"w-full h-full object-cover"}),d.jsx("button",{onClick:()=>nn(Oe.id),className:"absolute top-2 right-2 p-1.5 bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors shadow",title:"Remove Image",children:d.jsx(Ki,{className:"w-4 h-4"})})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-xs font-semibold text-slate-500 block",children:"Image Fit"}),d.jsxs("div",{className:"flex bg-slate-100 dark:bg-slate-900 p-1 rounded-xl",children:[d.jsx("button",{onClick:()=>l(Me=>Me.map(lt=>lt.id===Oe.id?{...lt,imageFit:"cover"}:lt)),className:`flex-1 py-1 text-xs font-bold rounded-lg transition-all ${Oe.imageFit==="cover"?"bg-white dark:bg-slate-700 text-[#47ff72] shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:"Cover"}),d.jsx("button",{onClick:()=>l(Me=>Me.map(lt=>lt.id===Oe.id?{...lt,imageFit:"contain"}:lt)),className:`flex-1 py-1 text-xs font-bold rounded-lg transition-all ${Oe.imageFit==="contain"?"bg-white dark:bg-slate-700 text-[#47ff72] shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:"Contain"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center text-xs",children:[d.jsx("span",{className:"text-slate-500 font-semibold",children:"Image Opacity"}),d.jsxs("span",{className:"text-[#47ff72]",children:[Oe.imageOpacity??100,"%"]})]}),d.jsx("input",{type:"range",min:"0",max:"100",value:Oe.imageOpacity??100,onChange:Me=>l(lt=>lt.map(jt=>jt.id===Oe.id?{...jt,imageOpacity:parseInt(Me.target.value)}:jt)),className:"w-full h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"})]})]}):d.jsxs("div",{onClick:Jt,className:"border-2 border-dashed border-slate-300 dark:border-slate-700 rounded-xl p-6 text-center cursor-pointer hover:border-[#47ff72]/50 hover:bg-slate-100/30 dark:hover:bg-slate-900/30 transition-all group",children:[d.jsx(yE,{className:"w-8 h-8 text-slate-400 group-hover:text-[#47ff72] mx-auto mb-2 transition-colors"}),d.jsx("p",{className:"text-xs font-bold text-slate-600 dark:text-slate-400 mb-1",children:"Click to Upload Image"}),d.jsx("p",{className:"text-[10px] text-slate-400",children:"Supports PNG, JPG, JPEG, WEBP"}),d.jsx("input",{type:"file",ref:et,onChange:Kn,accept:"image/*",className:"hidden"})]})]}),d.jsxs("div",{className:"space-y-4 p-4 bg-slate-50 dark:bg-slate-900/50 rounded-xl border border-slate-200 dark:border-slate-700",children:[d.jsxs("h4",{className:"text-xs font-bold text-slate-800 dark:text-slate-300 uppercase tracking-wider flex items-center gap-1.5",children:[d.jsx(TM,{className:"w-4 h-4 text-[#47ff72]"})," Text Content"]}),d.jsxs("div",{className:"space-y-3 p-3 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-xs font-bold text-slate-700 dark:text-slate-300",children:"Text 1"}),Oe.textContent1&&d.jsx("button",{onClick:()=>ns(Oe.id,1),className:"text-xs text-red-500 hover:text-red-600 font-semibold",children:"Clear"})]}),d.jsx("textarea",{value:((ms=Oe.textContent1)==null?void 0:ms.text)||"",onChange:Me=>ln(Oe.id,1,{text:Me.target.value}),placeholder:"Enter text content...",rows:2,className:"w-full bg-slate-100 dar
6861k:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-2 text-sm outline-none focus:border-[#47ff72] resize-none"}),Oe.textContent1&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Alignment"}),d.jsxs("div",{className:"flex gap-1 bg-slate-100 dark:bg-slate-900 p-1 rounded-lg",children:[d.jsx("button",{onClick:()=>ln(Oe.id,1,{alignment:"left"}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent1.alignment==="left"?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(aD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,1,{alignment:"center"}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent1.alignment==="center"?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(iD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,1,{alignment:"right"}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent1.alignment==="right"?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(oD,{className:"w-4 h-4 mx-auto"})})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"HTML tag"}),d.jsx("select",{value:Oe.textContent1.htmlTag??"p",onChange:Me=>ln(Oe.id,1,{htmlTag:Me.target.value}),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]",children:cH.map(Me=>d.jsx("option",{value:Me.value,children:Me.label},Me.value))})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Font"}),d.jsx("select",{value:Oe.textContent1.font,onChange:Me=>ln(Oe.id,1,{font:Me.target.value}),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]",children:dH.map(Me=>d.jsx("option",{value:Me,children:Me},Me))})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Size (px)"}),d.jsx("input",{type:"number",min:"8",max:"300",value:Oe.textContent1.fontSize,onChange:Me=>ln(Oe.id,1,{fontSize:Me.target.value===""?"":parseInt(Me.target.value)}),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Color"}),d.jsx("input",{type:"color",value:Oe.textContent1.color,onChange:Me=>ln(Oe.id,1,{color:Me.target.value}),className:"w-full h-[34px] rounded-lg border-0 cursor-pointer p-0 overflow-hidden"})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Style"}),d.jsxs("div",{className:"flex gap-1 bg-slate-100 dark:bg-slate-900 p-1 rounded-lg",children:[d.jsx("button",{onClick:()=>ln(Oe.id,1,{bold:!Oe.textContent1.bold}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent1.bold?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(lD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,1,{italic:!Oe.textContent1.italic}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent1.italic?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(hD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,1,{underline:!Oe.textContent1.underline}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent1.underline?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(xD,{className:"w-4 h-4 mx-auto"})})]})]})]})]}),!Oe.textContent2&&d.jsxs("button",{onClick:()=>ln(Oe.id,2,{text:""}),className:"w-full flex items-center justify-center gap-1.5 py-2 border border-dashed border-[#47ff72]/40 hover:border-[#47ff72] bg-[#47ff72]/5 hover:bg-[#47ff72]/10 text-[#47ff72] rounded-lg text-xs font-bold transition-all shadow-sm",children:[d.jsx(Tv,{className:"w-4 h-4"})," Add Text"]}),Oe.textContent2&&d.jsxs("div",{className:"space-y-3 p-3 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-xs font-bold text-slate-700 dark:text-slate-300",children:"Text 2"}),d.jsx("button",{onClick:()=>ns(Oe.id,2),className:"text-xs text-red-500 hover:text-red-600 font-semibold",children:"Clear"})]}),d.jsx("textarea",{value:Oe.textContent2.text,onChange:Me=>ln(Oe.id,2,{text:Me.target.value}),placeholder:"Enter text content...",rows:2,className:"w-full bg-slate-100 dar
6861k:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-2 text-sm outline-none focus:border-[#47ff72] resize-none"}),Oe.textContent2&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Alignment"}),d.jsxs("div",{className:"flex gap-1 bg-slate-100 dark:bg-slate-900 p-1 rounded-lg",children:[d.jsx("button",{onClick:()=>ln(Oe.id,2,{alignment:"left"}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent2.alignment==="left"?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(aD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,2,{alignment:"center"}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent2.alignment==="center"?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(iD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,2,{alignment:"right"}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent2.alignment==="right"?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(oD,{className:"w-4 h-4 mx-auto"})})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"HTML tag"}),d.jsx("select",{value:Oe.textContent2.htmlTag??"p",onChange:Me=>ln(Oe.id,2,{htmlTag:Me.target.value}),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]",children:cH.map(Me=>d.jsx("option",{value:Me.value,children:Me.label},Me.value))})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Font"}),d.jsx("select",{value:Oe.textContent2.font,onChange:Me=>ln(Oe.id,2,{font:Me.target.value}),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]",children:dH.map(Me=>d.jsx("option",{value:Me,children:Me},Me))})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Size (px)"}),d.jsx("input",{type:"number",min:"8",max:"300",value:Oe.textContent2.fontSize,onChange:Me=>ln(Oe.id,2,{fontSize:Me.target.value===""?"":parseInt(Me.target.value)}),className:"w-full bg-slate-100 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-lg px-3 py-1.5 text-sm outline-none focus:border-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Color"}),d.jsx("input",{type:"color",value:Oe.textContent2.color,onChange:Me=>ln(Oe.id,2,{color:Me.target.value}),className:"w-full h-[34px] rounded-lg border-0 cursor-pointer p-0 overflow-hidden"})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-xs text-slate-500 font-semibold",children:"Style"}),d.jsxs("div",{className:"flex gap-1 bg-slate-100 dark:bg-slate-900 p-1 rounded-lg",children:[d.jsx("button",{onClick:()=>ln(Oe.id,2,{bold:!Oe.textContent2.bold}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent2.bold?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(lD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,2,{italic:!Oe.textContent2.italic}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent2.italic?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(hD,{className:"w-4 h-4 mx-auto"})}),d.jsx("button",{onClick:()=>ln(Oe.id,2,{underline:!Oe.textContent2.underline}),className:`flex-1 p-1.5 rounded transition-all ${Oe.textContent2.underline?"bg-[#47ff72] text-slate-900":"text-slate-500 hover:text-slate-700"}`,children:d.jsx(xD,{className:"w-4 h-4 mx-auto"})})]})]})]})]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("button",{onClick:Me=>tn(Oe.id,Me),className:"flex-1 flex items-center justify-center gap-2 py-2.5 border border-red-500/30 hover:border-red-500 bg-red-500/10 text-red-500 hover:bg-red-500 hover:text-white rounded-xl text-xs font-bold transition-all",children:[d.jsx(xl,{className:"w-4 h-4"})," Delete Box"]}),d.jsx("button",{onClick:()=>zt("canvas"),className:"flex-1 py-2.5 bg-slate-100 hover:bg-slate-200 dark:bg-slate-700 dark:hover:bg-slate-600 text-slate-800 dark:text-slate-200 rounded-xl text-xs font-bold transition-all text-center",children:"Deselect"})]})]})]}),d.jsxs("div",{className:"xl:col-span-2 space-y-4",children:[d.jsxs("div",{className:"flex justify-between items-center bg-white dark:bg-slate-800/50 border border-slate-200 dark:border-slate-800 px-4 py-3 rounded-2xl shadow-sm",children:[d.jsxs("span",{className:"text-xs text-slate-500 dark:text-slate-400 font-semibold flex items-center gap-1",children:[d.jsx(Obe,{className:"w-4 h-4 text-[#47ff72]"}),"Tip: Drag boxes to move, drag the corner handle to resize, or click empty space for canvas settings."]}),d.jsxs("div",{className:"relative",ref:nt,children:[d.jsxs("button",{type:"button",onClick:()=>ge(Me=>!Me),disabled:J,className:"flex items-center gap-2 px-5 py-2 bg-slate-900 dark:bg-slate-700 hover:bg-slate-800 text-[#47ff72] rounded-xl text-sm font-bold shadow-sm transition-all disabled:opacity-50",children:[J?d.jsx(Av,{className:"w-4 h-4 animate-spin"}):d.jsx(Ua,{className:"w-4 h-4"}),d.jsx("span",{children:J?"Exporting...":"Export Bento"}),d.jsx(P0,{className:`w-4 h-4 transition-transform ${Ie?"rotate-180":""}`})]}),d.jsx(kv,{children:Ie&&!J&&d.jsx(ks.div,{initial:{opacity:0,y:-8,scale:.98}
6861,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.98},transition:{duration:.15},className:"absolute right-0 top-full mt-2 w-56 bg-slate-900 border border-slate-700 rounded-2xl shadow-2xl z-50 overflow-hidden",children:d.jsxs("div",{className:"p-4 space-y-4",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-xs font-semibold text-slate-400 block",children:"Format"}),d.jsxs("select",{value:he,onChange:Me=>Ae(Me.target.value),className:"w-full bg-slate-800 border border-slate-600 text-white rounded-xl px-3 py-2.5 text-sm font-semibold outline-none focus:border-[#47ff72] appearance-none cursor-pointer",children:[d.jsx("option",{value:"png",children:"PNG"}),d.jsx("option",{value:"jpg",children:"JPG"}),d.jsx("option",{value:"html",children:"HTML (ZIP)"})]})]}),d.jsx("button",{type:"button",onClick:()=>ps(he),className:"w-full py-2.5 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-xl text-sm font-bold transition-all shadow-md",children:"Export"}),d.jsx(EE,{showRemaining:e,remaining:t,className:"pt-1"})]})})})]})]}),d.jsx("div",{ref:we,onClick:()=>zt("canvas"),className:"w-full rounded-3xl border border-slate-200 dark:border-slate-800 bg-[#001705] p-6 flex justify-center shadow-lg cursor-default overflow-hidden",children:d.jsx("div",{style:{width:Le*me,height:ve*me,position:"relative"},children:d.jsxs("div",{style:{width:`${Le}px`,height:`${ve}px`,transform:`scale(${me})`,transformOrigin:"top left",backgroundColor:c,padding:`${p}px`,borderRadius:`${B}px`,transition:"all 0.15s ease-out"},className:"relative shadow-2xl overflow-hidden select-none",children:[d.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gridTemplateRows:`repeat(${Ue}, minmax(0, 1fr))`,gap:`${y}px`,inset:`${p}px`},className:"absolute pointer-events-none",children:Array.from({length:Ue*4}).map((Me,lt)=>d.jsx("div",{className:"border border-dashed border-white/[0.03] rounded-md"},lt))}),d.jsx("div",{ref:He,style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gridTemplateRows:`repeat(${Ue}, minmax(0, 1fr))`,gap:`${y}px`,width:"100%",height:"100%",position:"relative",zIndex:10},children:o.map(Me=>{var yn,Ft,sn,rn,bs,gs;const lt=wt===Me.id,jt=(ft==null?void 0:ft.boxId)===Me.id,Qt=Math.round(E*2.55).toString(16).padStart(2,"0"),Sn=Math.round(L*2.55).toString(16).padStart(2,"0");return d.jsxs("div",{onMouseDown:us=>{us.button===0&&Wt(us,Me,"move")},onClick:us=>{us.stopPropagation(),!pt.current&&zt(Me.id)},style:{gridColumnStart:Me.colStart,gridColumnEnd:Me.colStart+Me.colSpan,gridRowStart:Me.rowStart,gridRowEnd:Me.rowStart+Me.rowSpan,backgroundColor:`${b}${Qt}`,borderColor:lt?"#47ff72":`${M}${Sn}`,borderWidth:lt?"2px":`${D}px`,borderRadius:`${B}px`,boxShadow:Js(),outline:lt?"1px solid #47ff72":"none",transition:jt?"none":"box-shadow 0.2s ease, border-color 0.2s ease, outline 0.2s ease",zIndex:jt?30:lt?20:10},className:`relative overflow-hidden group flex flex-col items-center justify-center backdrop-blur-sm ${jt?"cursor-grabbing":"cursor-grab"}`,children:[Me.image?d.jsx("div",{className:"absolute inset-0 w-full h-full",children:d.jsx("img",{src:Me.image,alt:"Bento cell content",style:{objectFit:Me.imageFit??"cover",opacity:(Me.imageOpacity??100)/100},className:"w-full h-full pointer-events-none select-none"})}):!((yn=Me.textContent1)!=null&&yn.text)&&!((Ft=Me.textContent2)!=null&&Ft.text)?d.jsxs("div",{className:"text-white/20 dark:text-white/10 flex flex-col items-center gap-1 pointer-events-none",children:[d.jsx(Sbe,{className:"w-5 h-5 text-white/30"}),d.jsxs("span",{className:"text-[10px] font-bold font-mono",children:[Me.colSpan,"x",Me.rowSpan]})]}):null,(((sn=Me.textContent1)==null?void 0:sn.text)||((rn=Me.textContent2)==null?void 0:rn.text))&&d.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 p-4 pointer-events-none",children:[((bs=Me.textContent1)==null?void 0:bs.text)&&d.jsx(uH,{content:Me.textContent1,text:Me.textContent1.text}),((gs=Me.textContent2)==null?void 0:gs.text)&&d.jsx(uH,{content:Me.textContent2,text:Me.textContent2.text})]}),lt&&d.jsx("div",{className:"absolute inset-0 bg-[#47ff72]/5 pointer-events-none"}),d.jsx("button",{onMouseDown:us=>us.stopPropagation(),onClick:us=>tn(Me.id,us),className:"absolute top-2 right-2 p-1.5 bg-red-500 hover:bg-red-600 text-white rounded-lg opacity-0 group-hover:opacity-100 hover:scale-105 active:scale-95 transition-all shadow-md z-20",title:"Delete Box",children:d.jsx(xl,{className:"w-3.5 h-3.5"})}),lt&&d.jsx("div",{onMouseDown:us=>Wt(us,Me,"resize"),className:"absolute bottom-1 right-1 w-4 h-4 bg-[#47ff72] rounded-sm border-2 border-slate-900 cursor-nwse-resize z-30 shadow-md hover:scale-110 transition-transform",title:"Resize box"})]},Me.id)})})]})})})]})]})]}),d.jsx(MA,{isOpen:s,onClose:a,reason:r})]})},LCe="modulepreload",jCe=function(t){return"/"+t}
6861,hH={},Fne=function(e,n,s){let r=Promise.resolve();if(n&&n.length>0){let a=function(c){return Promise.all(c.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));r=a(n.map(c=>{if(c=jCe(c),c in hH)return;hH[c]=!0;const h=c.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":LCe,h||(m.as="script"),m.crossOrigin="",m.href=c,l&&m.setAttribute("nonce",l),document.head.appendChild(m),h)return new Promise((y,v)=>{m.addEventListener("load",y),m.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return e().catch(i)})},jg=(t,e,n)=>Math.max(e,Math.min(n,t)),gv=t=>jg(Number.isFinite(t)?t:100,0,100),a5=t=>{const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{3}$/.test(e)?[parseInt(e[0]+e[0],16),parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16)]:/^[0-9a-fA-F]{6}$/.test(e)?[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]:[0,0,0]},Vne=(t,e)=>{const[n,s,r]=a5(t);return`rgba(${n}, ${s}, ${r}, ${gv(e)/100})`},zne=(t,e)=>{const[n,s,r]=a5(t),[i,a,o]=a5(e),l=c=>Math.round(c).toString(16).padStart(2,"0");return`#${l((n+i)/2)}${l((s+a)/2)}${l((r+o)/2)}`},Gne=(t,e)=>{const n=[];for(let s=0;s<t.length;s++)if(n.push({color:t[s].color,offset:t[s].offset,opacity:gv(t[s].opacity)}),s<t.length-1){const r=t[s].offset,i=t[s+1].offset,a=e[s]??50,o=r+(i-r)*(a/100);n.push({color:zne(t[s].color,t[s+1].color),offset:o,opacity:(gv(t[s].opacity)+gv(t[s+1].opacity))/2})}return n.sort((s,r)=>s.offset-r.offset)},BCe=(t,e)=>`linear-gradient(to right, ${Gne(t,e).map(r=>`${Vne(r.color,r.opacity)} ${r.offset}%`).join(", ")})`,UCe=({stops:t,midpoints:e,onChange:n,maxStops:s=4})=>{var I,M,j,L,K;const[r,i]=q.useState({type:"stop",index:0}),a=q.useRef(null),o=q.useRef(null),l=q.useRef(t),c=q.useRef(e);q.useEffect(()=>{l.current=t,c.current=e},[t,e]),q.useEffect(()=>{(r==null?void 0:r.type)==="stop"&&r.index>=t.length&&i({type:"stop",index:Math.max(0,t.length-1)}),(r==null?void 0:r.type)==="mid"&&r.index>=e.length&&i(e.length>0?{type:"mid",index:e.length-1}:{type:"stop",index:0})},[t.length,e.length,r]),q.useEffect(()=>{const D=X=>{if(!o.current||!a.current)return;const H=a.current.getBoundingClientRect(),Y=(X-H.left)/H.width*100,F=jg(Math.round(Y),0,100),{type:we,index:me}=o.current,xe=l.current,Le=c.current;if(we==="stop"){const ve=me>0?xe[me-1].offset+1:0,ce=me<xe.length-1?xe[me+1].offset-1:100,ie=jg(F,ve,ce),de=xe.map((Re,Se)=>Se===me?{...Re,offset:ie}:Re);n(de,Le)}else if(we==="mid"){const ve=xe[me].offset,ce=xe[me+1].offset;if(ce>ve){const ie=jg(Math.round((F-ve)/(ce-ve)*100),5,95),de=[...Le];de[me]=ie,n(xe,de)}}},R=X=>D(X.clientX),B=X=>{X.touches.length>0&&D(X.touches[0].clientX)},G=()=>{o.current=null};return window.addEventListener("mousemove",R),window.addEventListener("mouseup",G),window.addEventListener("touchmove",B,{passive:!1}),window.addEventListener("touchend",G),window.addEventListener("touchcancel",G),()=>{window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",G),window.removeEventListener("touchmove",B),window.removeEventListener("touchend",G),window.removeEventListener("touchcancel",G)}},[n]);const h=D=>{const R=Gne(t,e);let B="#ffffff",G=100;const X=R.findIndex(H=>H.offset>=D);return X>0&&X<R.length?(B=zne(R[X-1].color,R[X].color),G=(R[X-1].opacity+R[X].opacity)/2):X===0&&R.length>0&&(B=R[0].color,G=R[0].opacity),{color:B,opacity:G}},p=D=>{if(t.length>=s)return;let R=t.findIndex(Y=>Y.offset>D);R===-1&&(R=t.length),R===0&&(R=1);const{color:B,opacity:G}=h(D),X=[...t];X.splice(R,0,{id:`stop-${Date.now()}`,color:B,offset:D,opacity:G});const H=[...e];H.splice(R>0?R-1:0,0,50),n(X,H),i({type:"stop",index:R})},m=()=>{if(t.length>=s)return;let D=0,R=1;for(let F=0;F<t.length-1;F++){const we=t[F+1].offset-t[F].offset;we>D&&(D=we,R=F+1)}if(D<2)return;
6861const B=Math.round(t[R-1].offset+D/2),{color:G,opacity:X}=h(B),H=[...t];H.splice(R,0,{id:`stop-${Date.now()}`,color:G,offset:B,opacity:X});const Y=[...e];Y.splice(R-1,0,50),n(H,Y),i({type:"stop",index:R})},y=()=>{if(t.length<=2||(r==null?void 0:r.type)!=="stop")return;const D=r.index,R=t.filter((G,X)=>X!==D),B=[...e];B.splice(Math.max(0,D-1),1),n(R,B),i({type:"stop",index:Math.max(0,D-1)})},v=(D,R)=>{n(t.map((B,G)=>G===D?{...B,color:R}:B),e)},b=(D,R)=>{const B=gv(R);n(t.map((G,X)=>X===D?{...G,opacity:B}:G),e)},S=(D,R)=>{const B=D>0?t[D-1].offset+1:0,G=D<t.length-1?t[D+1].offset-1:100,X=jg(Math.round(R),B,G);n(t.map((H,Y)=>Y===D?{...H,offset:X}:H),e)},E=(D,R)=>{const B=[...e];B[D]=jg(Math.round(R),5,95),n(t,B)};return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{ref:a,className:"relative w-full h-8 rounded-lg cursor-crosshair border border-slate-300 dark:border-slate-700 shadow-inner select-none",style:{backgroundColor:"#e2e8f0",backgroundImage:BCe(t,e)},onMouseDown:D=>{if(D.target!==a.current||!a.current)return;const R=a.current.getBoundingClientRect(),B=jg(Math.round((D.clientX-R.left)/R.width*100),0,100);p(B)},onTouchStart:D=>{if(D.target!==a.current||!a.current)return;const R=a.current.getBoundingClientRect(),B=jg(Math.round((D.touches[0].clientX-R.left)/R.width*100),0,100);p(B)},children:[t.map((D,R)=>d.jsx("div",{onMouseDown:B=>{B.stopPropagation(),o.current={type:"stop",index:R},i({type:"stop",index:R})},onTouchStart:B=>{B.stopPropagation(),o.current={type:"stop",index:R},i({type:"stop",index:R})},className:`absolute top-1/2 -translate-y-1/2 w-4 h-4 rounded-full border-2 cursor-grab select-none ${(r==null?void 0:r.type)==="stop"&&r.index===R?"border-white z-20 scale-125":"border-slate-300 z-10"}`,style:{left:`calc(${D.offset}% - 8px)`,backgroundColor:Vne(D.color,D.opacity)}},D.id)),e.map((D,R)=>{const B=t[R].offset,G=t[R+1].offset,X=B+(G-B)*(D/100);return d.jsx("div",{onMouseDown:H=>{H.stopPropagation(),o.current={type:"mid",index:R},i({type:"mid",index:R})},onTouchStart:H=>{H.stopPropagation(),o.current={type:"mid",index:R},i({type:"mid",index:R})},className:`absolute top-1/2 -translate-y-1/2 w-2 h-4 rotate-45 cursor-grab select-none ${(r==null?void 0:r.type)==="mid"&&r.index===R?"bg-white z-20 scale-125 border border-slate-500":"z-10 bg-slate-300/80"}`,style:{left:`calc(${X}% - 4px)`}},`mid-${t[R].id}-${t[R+1].id}`)})]}),d.jsx("div",{className:"space-y-2.5 p-2.5 bg-slate-50 dark:bg-slate-800/50 rounded-lg overflow-hidden",children:(r==null?void 0:r.type)==="stop"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Color"}),d.jsx("input",{type:"color",value:((I=t[r.index])==null?void 0:I.color)||"#ffffff",onChange:D=>v(r.index,D.target.value),className:"w-full h-8 rounded border border-slate-200 dark:border-slate-700 cursor-pointer"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-400 font-bold uppercase",children:[d.jsx("span",{children:"Position"}),d.jsxs("span",{className:"font-mono text-slate-500 normal-case",children:[Math.round(((M=t[r.index])==null?void 0:M.offset)??0),"%"]})]}),d.jsx("div",{className:"px-1",children:d.jsx("input",{type:"range",min:r.index>0?t[r.index-1].offset+1:0,max:r.index<t.length-1?t[r.index+1].offset-1:100,value:((j=t[r.index])==null?void 0:j.offset)??0,onChange:D=>S(r.index,parseFloat(D.target.value)||0),className:"block w-full h-5 accent-[#47ff72]"})})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-400 font-bold uppercase",children:[d.jsx("span",{children:"Opacity"}),d.jsxs("span",{className:"font-mono text-slate-500 normal-case",children:[Math.round(gv((L=t[r.index])==null?void 0:L.opacity)),"%"]})]}),d.jsx("div",{className:"px-1 pb-0.5",children:d.jsx("input",{type:"range",min:0,max:100,value:gv((K=t[r.index])==null?void 0:K.opacity),onChange:D=>b(r.index,parseFloat(D.target.value)||0),className:"block w-full h-5 accent-[#47ff72]"})})]})]}):(r==null?void 0:r.type)==="mid"?d.jsxs("div",{className:"space-y-1",children:[d.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-400 font-bold uppercase",children:[d.jsxs("span",{children:["Midpoint (",r.index+1,"–",r.index+2,")"]}),d.jsxs("span",{className:"font-mono text-slate-500 normal-case",children:[Math.round(e[r.index]??50),"%"]})]}),d.jsx("div",{className:"px-1 pb-0.5",children:d.jsx("input",{type:"range",min:5,max:95,value:e[r.index]??50,onChange:D=>E(r.index,parseFloat(D.target.value)||50),className:"block w-full h-5 accent-[#47ff72]"})})]}):null}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",onClick:m,disabled:t.length>=s,className:"flex-1 h-7 rounded border border-slate-200 dark:border-slate-700 text-[10px] text-slate-600 dar
6861k:text-slate-300 disabled:opacity-40 hover:bg-slate-50 dark:hover:bg-slate-800",children:"+ Add Stop"}),d.jsx("button",{type:"button",onClick:y,disabled:!(t.length>2&&(r==null?void 0:r.type)==="stop"),className:"flex-1 h-7 rounded border border-slate-200 dark:border-slate-700 text-[10px] text-red-500 disabled:opacity-40 hover:bg-slate-50 dark:hover:bg-slate-800",children:"Delete"})]})]})};function FCe(t){const[e,n]=q.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return q.useEffect(()=>{const s=window.matchMedia(t),r=()=>n(s.matches);return r(),s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[t]),e}const o5="http://www.w3.org/2000/svg",VCe=new Set(["path","rect","circle","ellipse","line","polyline","polygon"]),Hne=new Set(["defs","clipPath","mask","pattern","metadata","title","desc"]),qne={fill:"#000000",fillMode:"solid",stroke:"none",strokeMode:"solid",strokeWidth:1,opacity:1},qS=(t,e,n)=>Math.max(e,Math.min(n,t)),Mv=t=>{if(!t)return;const e=parseFloat(t);if(Number.isFinite(e))return qS(e<=1?e*100:e,0,100)},zCe=t=>{if(!t)return{};const e={};for(const n of t.split(";")){const[s,r]=n.split(":");if(!s||!r)continue;const i=s.trim().toLowerCase(),a=r.trim();i==="fill"?e.fill=a:i==="stroke"?e.stroke=a:i==="stroke-width"?e.strokeWidth=parseFloat(a)||1:i==="opacity"?e.opacity=parseFloat(a)??1:i==="fill-opacity"?e.fillOpacity=Mv(a):i==="stroke-opacity"&&(e.strokeOpacity=Mv(a))}return e},Wne=t=>{const e=t.trim();if(!e||e==="none"||e==="transparent")return null;if(e.startsWith("#")){const i=e.replace(/^#/,"");return/^[0-9a-fA-F]{3}$/.test(i)?{hex:`#${i[0]}${i[0]}${i[1]}${i[1]}${i[2]}${i[2]}`}:/^[0-9a-fA-F]{6}$/.test(i)?{hex:`#${i}`}:null}const n=e.match(/^rgba?\(\s*([^)]+)\)$/i);if(n){const i=n[1].split(",").map(p=>p.trim());if(i.length<3)return null;const a=qS(Math.round(parseFloat(i[0])||0),0,255),o=qS(Math.round(parseFloat(i[1])||0),0,255),l=qS(Math.round(parseFloat(i[2])||0),0,255),c=p=>p.toString(16).padStart(2,"0"),h=i.length>=4?Mv(i[3]):void 0;return{hex:`#${c(a)}${c(o)}${c(l)}`,opacity:h}}const r=document.createElement("canvas").getContext("2d");if(!r)return null;try{r.fillStyle="#000000",r.fillStyle=e;const i=r.fillStyle;if(typeof i=="string"&&i.startsWith("#"))return{hex:i}}catch{return null}return null},tI=(t,e)=>{if(!t)return e;const n=t.trim();if(n.endsWith("%"))return parseFloat(n)||e;const s=parseFloat(n);return Number.isFinite(s)?s<=1?s*100:s:e},GCe=t=>{const e=t.trim().match(/^url\(\s*['"]?#([^)'"\s]+)['"]?\s*\)$/i);return e?e[1]:null},HCe=t=>{const e=new Map;return t.querySelectorAll("linearGradient, radialGradient").forEach(n=>{const s=n.getAttribute("id");s&&e.set(s,n)}),e},qCe=t=>{const e=t.getAttribute("href")||t.getAttribute("xlink:href");if(!e)return null;const n=e.trim();return n.startsWith("#")?n.slice(1):n},WCe=t=>{if(!t)return{};const e={};for(const n of t.split(";")){const[s,r]=n.split(":");if(!s||!r)continue;const i=s.trim().toLowerCase(),a=r.trim();i==="stop-color"||i==="fill"?e.color=a:i==="stop-opacity"&&(e.opacity=Mv(a))}return e},KCe=t=>{const e=Array.from(t.children).filter(s=>s.tagName.toLowerCase()==="stop");return e.map((s,r)=>{const i=WCe(s.getAttribute("style"));let a=r===0?0:100;const o=s.getAttribute("offset");o?o.trim().endsWith("%")?a=parseFloat(o)||a:a=(parseFloat(o)||0)*100:r===e.length-1&&(a=100);const l=s.getAttribute("stop-color")??i.color??"#000000",c=Wne(l);let h=Mv(s.getAttribute("stop-opacity"))??i.opacity;return(c==null?void 0:c.opacity)!==void 0&&(h=h!==void 0?h/100*c.opacity:c.opacity),{color:(c==null?void 0:c.hex)??"#000000",offset:qS(a,0,100),opacity:h??100}}).sort((s,r)=>s.offset-r.offset).filter((s,r,i)=>r===0||s.offset>=i[r-1].offset)},YCe=t=>
6861{if(t.length<=4)return t;const e=new Map;e.set(0,t[0]),e.set(100,t[t.length-1]);const n=2;for(let s=1;s<=n;s++){const i=s/(n+1)*100;let a=t[0],o=1/0;for(const l of t){const c=Math.abs(l.offset-i);c<o&&(o=c,a=l)}e.set(Math.round(a.offset),{...a})}return Array.from(e.values()).sort((s,r)=>s.offset-r.offset).slice(0,4)},fH=t=>Array.from({length:Math.max(0,t.length-1)},()=>50),Kne=(t,e,n)=>{const s=t.getAttribute("id");if(s){if(n.has(s))return null;n.add(s)}let r=KCe(t);const i=qCe(t);if(r.length<2&&i&&e.has(i)){const m=Kne(e.get(i),e,n);m&&(r=m.stops)}if(r=YCe(r),r.length<2)return null;if(t.tagName.toLowerCase()==="radialgradient")return{style:"radial",angle:0,stops:r,midpoints:fH(r)};const o=tI(t.getAttribute("x1"),0),l=tI(t.getAttribute("y1"),0),c=tI(t.getAttribute("x2"),100),h=tI(t.getAttribute("y2"),0),p=Math.atan2(h-l,c-o)*180/Math.PI;return{style:"linear",angle:Number.isFinite(p)?p:0,stops:r,midpoints:fH(r)}},XCe=(t,e)=>{const n=e.get(t);return n?Kne(n,e,new Set):null},pH=(t,e,n)=>{var i;if(!t||t==="inherit")return e;if(t==="none")return{color:"none",mode:"solid"};const s=GCe(t);if(s){const a=XCe(s,n);return a?{color:((i=a.stops[0])==null?void 0:i.color)??e.color,mode:"gradient",gradient:a,opacity:e.opacity}:e}const r=Wne(t);return r?{color:r.hex,mode:"solid",opacity:r.opacity??e.opacity}:{...e,color:t}},Yne=(t,e,n)=>{const s=zCe(t.getAttribute("style")),r=pH(t.getAttribute("fill")??s.fill,{color:e.fill,mode:e.fillMode,gradient:e.fillGradient,opacity:e.fillOpacity},n),i=pH(t.getAttribute("stroke")??s.stroke,{color:e.stroke,mode:e.strokeMode,gradient:e.strokeGradient,opacity:e.strokeOpacity},n),a=t.getAttribute("stroke-width")??(s.strokeWidth!==void 0?String(s.strokeWidth):""),o=a&&parseFloat(a)||e.strokeWidth,l=t.getAttribute("opacity")??(s.opacity!==void 0?String(s.opacity):""),c=l?parseFloat(l):1,h=e.opacity*(Number.isFinite(c)?Math.max(0,Math.min(1,c)):1),p=Mv(t.getAttribute("fill-opacity"))??s.fillOpacity??r.opacity??e.fillOpacity,m=Mv(t.getAttribute("stroke-opacity"))??s.strokeOpacity??i.opacity??e.strokeOpacity;return{fill:r.color,fillMode:r.mode,fillGradient:r.gradient,fillOpacity:p,stroke:i.color,strokeMode:i.mode,strokeGradient:i.gradient,strokeOpacity:m,strokeWidth:o,opacity:h}},JCe=(t,e)=>{const n=[];let s=t.parentElement;for(;s;){const r=s.tagName.toLowerCase();(r==="g"||r==="svg")&&n.unshift(s),s=s.parentElement}return n.reduce((r,i)=>Yne(i,r,e),qne)},QCe=t=>{let e=t.parentElement;for(;e;){const n=e.tagName.toLowerCase();if(Hne.has(n))return!0;e=e.parentElement}return!1},ZCe=t=>{const e=t.tagName.toLowerCase();if(e==="path"){const n=t.getAttribute("d");return n&&n.trim()?n.trim():null}if(e==="rect"){const n=parseFloat(t.getAttribute("x")||"0"),s=parseFloat(t.getAttribute("y")||"0"),r=parseFloat(t.getAttribute("width")||"0"),i=parseFloat(t.getAttribute("height")||"0");if(r<=0||i<=0)return null;const a=parseFloat(t.getAttribute("rx")||t.getAttribute("ry")||"0"),o=parseFloat(t.getAttribute("ry")||a||"0");if(a>0||o>0){const l=Math.min(a,r/2),c=Math.min(o,i/2);return[`M ${n+l} ${s}`,`H ${n+r-l}`,`Q ${n+r} ${s} ${n+r} ${s+c}`,`V ${s+i-c}`,`Q ${n+r} ${s+i} ${n+r-l} ${s+i}`,`H ${n+l}`,`Q ${n} ${s+i} ${n} ${s+i-c}`,`V ${s+c}`,`Q ${n} ${s} ${n+l} ${s}`,"Z"].join(" ")}return`M ${n} ${s} H ${n+r} V ${s+i} H ${n} Z`}if(e==="circle"){const n=parseFloat(t.getAttribute("cx")||"0"),s=parseFloat(t.getAttribute("cy")||"0"),r=parseFloat(t.getAttribute("r")||"0");return r<=0?null:`M ${n-r} ${s} A ${r} ${r} 0 1 0 ${n+r} ${s} A ${r} ${r} 0 1 0 ${n-r} ${s} Z`}if(e==="ellipse"){const n=parseFloat(t.getAttribute("cx")||"0"),s=parseFloat(t.getAttribute("cy")||"0"),r=parseFloat(t.getAttribute("rx")||"0"),i=parseFloat(t.getAttribute("ry")||"0");return r<=0||i<=0?null:`M ${n-r} ${s} A ${r} ${i} 0 1 0 ${n+r} ${s} A ${r} ${i} 0 1 0 ${n-r} ${s} Z`}if(e==="line"){const n=parseFloat(t.getAttribute("x1")||"0"),s=parseFloat(t.getAttribute("y1")||"0"),r=parseFloat(t.getAttribute("x2")||"0"),i=parseFloat(t.getAttribute("y2")||"0");return`M ${n} ${s} L ${r} ${i}`}if(e==="polyline"||e==="polygon"){const n=t.getAttribute("points");if(!(n!=null&&n.trim()))return null;const s=n.trim().split(/[\s,]+/).map(a=>parseFloat(a)).filter(a=>Number.isFinite(a));if(s.length<4)return null;const r=[];for(let a=0;a+1<s.length;a+=2)r.push(`${s[a]} ${s[a+1]}`);const i=e==="polygon";return`M ${r.join(" L ")}${i?" Z":""}`}return null},eke=t=>/[Zz]\s*$/i.test(t.trim())||/[Zz][\s,]*$/.test(t),tke=(t,e)=>{if(!e||t.length<2)return t;const n=t[0],s=t[t.length-1];return Math.hypot(n.x-s.x,n.y-s.y)<.75?t.slice(0,-1):t},nke=(t,e)=>{const n=tke(t,e);return n.length<2?[]:n.map((s,r)=>({x:s.x,y:s.y,handleIn:e||r>0?{x:s.x,y:s.y}:null,handleOut:e||r<n.length-1?{x:s.x,y:s.y}:null}))},ske=(t,e)=>{const n=new DOMPoint(t.x,t.y).matrixTransform(e);return{x:n.x,y:n.y}},rke=(t,e)=>{const n=document.createElementNS(o5,"path");n.setAttribute("d",t);const s=n.getTotalLength();if(!Number.isFinite(s)||s<.5)return null;const r=eke(t),i=Math.max(24,Math.min(160,Math.ceil(s/6))),a=[];for(let o=0;o<=i;o++){const l=n.getPointAtLength(s*o/i);a.push(ske({x:l.x,y:l.y},e))}return{points:a,closed:r}},ike=t=>{const e=t.match(/[a-zA-Z][^a-zA-Z]*/g);if(!e||e.length===0)return[t];const n=[];let s="";for(const r of e){const i=r[0];(i==="M"||i==="m")&&s.trim().length>0?(n.push(s.trim()),s=r):s+=(s?" ":"")+r}return s.trim().length>0&&n.push(s.trim()),n.length>0?n:[t]},ake=(t,e)=>ike(t).map(n=>rke(n,e)).filter(n=>!!(n&&n.points.length>=2)),oke=t=>{const e=document.createElementNS(o5,"svg");e.setAttribute("xmlns",o5);const n=t.getAttribute("viewBox");if(n)e.setAttribute("viewBox",n);else{const r=parseFloat(t.getAttribute("width")||"0"),i=parseFloat(t.getAttribute("height")||"0");r>0&&i>0&&e.setAttribute("viewBox",`0 0 ${r} ${i}`)}
6861e.style.position="fixed",e.style.left="-10000px",e.style.top="0",e.style.visibility="hidden",e.style.pointerEvents="none";const s=document.createDocumentFragment();return Array.from(t.childNodes).forEach(r=>{(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE)&&s.appendChild(r.cloneNode(!0))}),e.appendChild(s),document.body.appendChild(e),e},lke=t=>{const e=[],n=s=>{const r=s.tagName.toLowerCase();if(!Hne.has(r)){if(VCe.has(r)&&!QCe(s)){e.push(s);return}Array.from(s.children).forEach(i=>n(i))}};return n(t),e},cke=t=>(t.getAttribute("id")||t.getAttribute("label")||t.getAttribute("data-name")||t.getAttribute("aria-label")||t.getAttribute("inkscape:label")||"").trim(),uke=t=>t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"group",dke=t=>{if(t.length===0)return qne;const e=t.find(s=>s.fill!=="none")??t[0],n=t.find(s=>s.stroke!=="none")??t[0];return{fill:e.fill,fillMode:e.fillMode,fillGradient:e.fillGradient,fillOpacity:e.fillOpacity,stroke:n.stroke,strokeMode:n.strokeMode,strokeGradient:n.strokeGradient,strokeOpacity:n.strokeOpacity,strokeWidth:n.strokeWidth,opacity:t.reduce((s,r)=>Math.max(s,r.opacity),t[0].opacity)}},hke=t=>({fill:t.fill,fillMode:t.fillMode,fillGradient:t.fillGradient,fillOpacity:t.fillOpacity,stroke:t.stroke,strokeMode:t.strokeMode,strokeGradient:t.
6861strokeGradient,strokeOpacity:t.strokeOpacity,strokeWidth:t.strokeWidth,opacity:t.opacity}),fke=(t,e)=>{const n=[];let s=t.parentElement;for(;s;)s.tagName.toLowerCase()==="g"&&n.push(s),s=s.parentElement;return n.reverse(),n.map(e)},pke=t=>{const e=new DOMParser().parseFromString(t,"image/svg+xml");if(e.querySelector("parsererror"))return null;const s=e.documentElement;if(!s||s.tagName.toLowerCase()!=="svg")return null;const r=oke(s);try{const i=HCe(r),a=lke(r),o=[],l=new Map,c=new Map;let h=1;const p=v=>{const b=l.get(v);if(b)return b;const S=cke(v),E=S?uke(S):`group-${h++}`,I=c.get(E)??0;c.set(E,I+1);const M=I===0?E:`${E}-${I+1}`;return l.set(v,M),M};for(const v of a){const b=ZCe(v);if(!b)continue;const S=v.getCTM();if(!S)continue;const E=ake(b,S);if(E.length===0)continue;const I=E.map(K=>{const D=nke(K.points,K.closed);return D.length<2?null:{nodes:D,closed:K.closed}}).filter(K=>!!K);if(I.length===0)continue;const M=JCe(v,i),j=Yne(v,M,i),L=(v.getAttribute("id")||v.getAttribute("data-name")||"").trim()||void 0;o.push({contours:I,...hke(j),groupPath:fke(v,p),name:L})}if(o.length===0)return null;const m=dke(o.map(v=>({fill:v.fill,fillMode:v.fillMode??"solid",fillGradient:v.fillGradient,fillOpacity:v.fillOpacity,stroke:v.stroke,strokeMode:v.strokeMode??"solid",strokeGradient:v.strokeGradient,strokeOpacity:v.strokeOpacity,strokeWidth:v.strokeWidth,opacity:v.opacity})));return{shapes:o.map(v=>({...v,fill:v.fill||m.fill,fillMode:v.fillMode??m.fillMode,fillGradient:v.fillGradient??(v.fillMode==="gradient"?m.fillGradient:void 0),fillOpacity:v.fillOpacity??m.fillOpacity,stroke:v.stroke||m.stroke,strokeMode:v.strokeMode??m.strokeMode,strokeGradient:v.strokeGradient??(v.strokeMode==="gradient"?m.strokeGradient:void 0),strokeOpacity:v.strokeOpacity??m.strokeOpacity,strokeWidth:Number.isFinite(v.strokeWidth)?v.strokeWidth:m.strokeWidth,opacity:Number.isFinite(v.opacity)?v.opacity:m.opacity}))}}finally{r.remove()}},nI=t=>t.type==="image/svg+xml"||t.name.toLowerCase().endsWith(".svg"),Yo=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),dj=(t,e,n)=>{const s=n.x-e.x,r=n.y-e.y,i=s*s+r*r;if(i<1e-12)return Yo(t,e);const a=Math.max(0,Math.min(1,((t.x-e.x)*s+(t.y-e.y)*r)/i));return Yo(t,{x:e.x+a*s,y:e.y+a*r})},rx=(t,e)=>{const n=Math.hypot(t,e);return n<1e-9?{x:1,y:0}:{x:t/n,y:e/n}},mke=(t,e,n)=>{const s=t.x-e.x,r=t.y-e.y,i=n.x-e.x,a=n.y-e.y,o=Math.hypot(s,r),l=Math.hypot(i,a);if(o<1e-6||l<1e-6)return 180;const c=(s*i+r*a)/(o*l);return Math.acos(Math.max(-1,Math.min(1,c)))*180/Math.PI},gke=(t,e,n)=>180-mke(t,e,n),yke=(t,e,n,s,r)=>{const i=1-r;return{x:i*i*i*t.x+3*i*i*r*e.x+3*i*r*r*n.x+r*r*r*s.x,y:i*i*i*t.y+3*i*i*r*e.y+3*i*r*r*n.y+r*r*r*s.y}},Xne=(t,e,n)=>{const s=t.length;if(e===n)return[{...t[e]}];const r=[];let i=e;for(;r.push({...t[i]}),!(i===n||(i=(i+1)%s,r.length>s+1)););return r},l5=(t,e,n)=>(n-e+t)%t,Jne=(t,e,n,s,r)=>{const i=Yo(t,e),a=i/3,o=[];(!r.length||r[0].x!==t.x||r[0].y!==t.y)&&o.push(t);for(const M of r)o.push(M);if((!o.length||o[o.length-1].x!==e.x||o[o.length-1].y!==e.y)&&o.push(e),o.length<3)return{c1:{x:t.x+n.x*a,y:t.y+n.y*a},c2:{x:e.x+s.x*a,y:e.y+s.y*a}};const l=[0];for(let M=1;M<o.length;M++)l.push(l[M-1]+Yo(o[M],o[M-1]));const c=l[l.length-1]||1;for(let M=0;M<l.length;M++)l[M]/=c;let h=0,p=0,m=0,y=0,v=0;for(let M=0;M<o.length;M++){const j=l[M],L=1-j,K=3*L*L*j,D=3*L*j*j,R=L*L*(1+2*j)*t.x+j*j*(3-2*j)*e.x,B=L*L*(1+2*j)*t.y+j*j*(3-2*j)*e.y,G=o[M].x-R,X=o[M].y-B,H=K*n.x,Y=K*n.y,F=D*s.x,we=D*s.y;h+=H*H+Y*Y,p+=H*F+Y*we,m+=F*F+we*we,y+=H*G+Y*X,v+=F*G+we*X}const b=h*m-p*p;let S=a,E=a;Math.abs(b)>1e-12?(S=(m*y-p*v)/b,E=(h*v-p*y)/b):h>1e-12?S=y/h:m>1e-12&&(E=v/m);const I=Math.max(i,1)*1.5;if((!Number.isFinite(S)||S<0)&&(S=0),(!Number.isFinite(E)||E<0)&&(E=0),S>I&&(S=I),E>I&&(E=I),S<i*.02&&E<i*.02){let M=0;for(let j=1;j<o.length-1;j++){const L=dj(o[j],t,e);L>M&&(M=L)}M>i*.04&&(S=a,E=a)}return{c1:{x:t.x+n.x*S,y:t.y+n.y*S},c2:{x:e.x+s.x*E,y:e.y+s.y*E}}},yv=(t,e,n,s,r)=>{const i=t.length,a=t[e];let o=e,l=0;const c=Math.max(2,r);for(let h=0;h<i-1;h++){const p=(o+n+i)%i;if(p===s&&h>0||p===e||(l+=Yo(t[o],t[p]),o=p,l>=c))break}if(o===e){const h=(e+n+i)%i;return rx(t[h].x-a.x,t[h].y-a.y)}return rx(t[o].x-a.x,t[o].y-a.y)},xke=(t,e,n,s,r)=>{const i=yv(t,e,1,s,r),a=yv(t,e,-1,n,r),o=rx(i.x-a.x,i.y-a.y);return Math.hypot(i.x-a.x,i.y-a.y)<1e-8?i:o},sI=.552284749815,CE=t=>{const e=Math.abs(t.x),n=Math.abs(t.y);return e>=n*3.5?{x:t.x>=0?1:-1,y:0}:n>=e*3.5?{x:0,y:t.y>=0?1:-1}:t}
6861,Qne=(t,e,n,s,r,i)=>{if(n.length<4)return null;const a=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y);if(a<.001||o<.001)return null;const l=CE(s),c=CE(r),h=Math.abs(l.y)<1e-9,p=Math.abs(l.x)<1e-9,m=Math.abs(c.y)<1e-9,y=Math.abs(c.x)<1e-9;if(!(h&&y||p&&m))return null;const v=h?t.x:e.x,b=h?e.y:t.y,S=a,E=o;let I=0;for(const L of n){const K=(L.x-v)/S,D=(L.y-b)/E,R=Math.abs(K*K+D*D-1)*Math.min(S,E);if(R>I&&(I=R),I>i*1.8)return null}const M=h?sI*S:sI*E,j=m?sI*S:sI*E;return{c1:{x:t.x+l.x*M,y:t.y+l.y*M},c2:{x:e.x+c.x*j,y:e.y+c.y*j}}},Zne=(t,e,n,s,r,i)=>{if(n.length<4)return null;const{maxDev:a,idx:o}=hj(n),l=Yo(t,e);if(a<1e-6||l<1e-6)return null;const c=(a*a+l*.5*(l*.5))/(2*a);if(!Number.isFinite(c)||c<l*.5-1e-4)return null;const h={x:(t.x+e.x)/2,y:(t.y+e.y)/2},p=(e.y-t.y)/l,m=(t.x-e.x)/l,y=n[o],v=(y.x-h.x)*p+(y.y-h.y)*m>=0?1:-1,b={x:h.x+v*p*(c-a),y:h.y+v*m*(c-a)};let S=0;for(const D of n){const R=Math.abs(Yo(D,b)-c);if(R>S&&(S=R),S>i)return null}const E=t.x-b.x,I=t.y-b.y,M=e.x-b.x,j=e.y-b.y;let L=Math.atan2(E*j-I*M,E*M+I*j);if(n.length>2){const D=n[Math.floor(n.length/2)],R=D.x-b.x,B=D.y-b.y,G=Math.atan2(E*B-I*R,E*R+I*B),X=Math.atan2(R*j-B*M,R*M+B*j);L=G+X}if(!Number.isFinite(L)||Math.abs(L)<1e-4||Math.abs(L)>Math.PI*130/180)return null;const K=4/3*Math.tan(Math.abs(L)/4)*c;return!Number.isFinite(K)||K<=0?null:{c1:{x:t.x+s.x*K,y:t.y+s.y*K},c2:{x:e.x+r.x*K,y:e.y+r.y*K}}},vke=(t,e,n,s,r,i)=>Qne(t,e,n,s,r,i)??Zne(t,e,n,s,r,i)??Jne(t,e,s,r,n),bke=(t,e)=>{for(let n=0;n<t.length;n++){if(e[n])continue;const s=t[n],r=s.handleIn,i=s.handleOut;if(!r||!i)continue;const a=Yo(s,r),o=Yo(s,i);if(a<1e-6&&o<1e-6)continue;const l=a>=1e-6?rx(s.x-r.x,s.y-r.y):rx(i.x-s.x,i.y-s.y),c=o>=1e-6?rx(i.x-s.x,i.y-s.y):l;if(l.x*c.x+l.y*c.y<.15)continue;const h=rx(l.x+c.x,l.y+c.y);a>=1e-6&&(s.handleIn={x:s.x-h.x*a,y:s.y-h.y*a}),o>=1e-6&&(s.handleOut={x:s.x+h.x*o,y:s.y+h.y*o})}},hj=t=>{if(t.length<3)return{maxDev:0,idx:0};const e=t[0],n=t[t.length-1];let s=0,r=1;for(let i=1;i<t.length-1;i++){const a=dj(t[i],e,n);a>s&&(s=a,r=i)}return{maxDev:s,idx:r}},wke=(t,e,n,s,r)=>{if(r.length<3)return{err:0,idx:0};const i=[0];for(let c=1;c<r.length;c++)i.push(i[c-1]+Yo(r[c],r[c-1]));const a=i[i.length-1]||1;let o=0,l=1;for(let c=1;c<r.length-1;c++){const h=yke(t,e,n,s,i[c]/a),p=Yo(r[c],h);p>o&&(o=p,l=c)}return{err:o,idx:l}},_ke=24,Ske=(t,e)=>{const n=t.length;if(n<3)return[];const s=t.map((l,c)=>gke(t[(c-1+n)%n],t[c],t[(c+1)%n])),r=[];for(let l=0;l<n;l++)s[l]>=_ke&&r.push(l);const i=Math.max(2.5,e*.008),a=[],o=(l,c)=>s[l]>=s[c]?l:c;for(const l of r){const c=a[a.length-1];if(c===void 0){a.push(l);continue}Math.min(Math.abs(l-c),n-Math.abs(l-c))<=3&&Yo(t[l],t[c])<i?a[a.length-1]=o(c,l):a.push(l)}if(a.length>=2){const l=a[0],c=a[a.length-1];if(Math.min(Math.abs(l-c),n-Math.abs(l-c))<=3&&Yo(t[l],t[c])<i){const p=o(l,c);a.pop(),a[0]=p,p!==l&&(a.shift(),a.push(p),a.sort((m,y)=>m-y))}}return a},Eke=(t,e)=>{const n=t.length;if(n<4)return[];const s=Math.max(8,e*.025),r=Math.max(.4,e*.001),i=new Array(n).fill(!1),a=[];for(let o=0;o<n;o++){if(i[o])continue;let l=o,c=0;for(let h=1;h<n-1;h++){const p=(o+h)%n,m=t[o],y=t[p],v=Yo(m,y);if(v<1e-6)break;let b=0;for(let S=1;S<h&&(b=Math.max(b,dj(t[(o+S)%n],m,y)),!(b>r));S++);if(b>r||b/v>.006)break;l=p,c=v}if(c>=s&&l!==o){const p=l5(n,o,l)<=1?Math.max(16,e*.12):s;if(c<p)continue;a.push({start:o,end:l});let m=o;for(;m!==l;)i[m]=!0,m=(m+1)%n}}return a},Tke=t=>{let e=0,n=0,s=0,r=0;for(let h=1;h<t.length;h++)t[h].x<t[e].x&&(e=h),t[h].x>t[n].x&&(n=h),t[h].y<t[s].y&&(s=h),t[h].y>t[r].y&&(r=h);const i=[...new Set([e,n,s,r])].sort((h,p)=>h-p);if(i.length>=3)return i;const a=t.length,o=[0];for(let h=1;h<=a;h++)o.push(o[h-1]+Yo(t[h-1],t[h%a]));const l=o[a]||1,c=[];for(let h=0;h<4;h++){const p=l*h/4;let m=0,y=1/0;for(let v=0;v<a;v++){const b=Math.abs(o[v]-p);b<y&&(y=b,m=v)}c.includes(m)||c.push(m)}return c.sort((h,p)=>h-p)},c5=(t,e,n,s,r)=>{const i=t.length;if(s>=3||e===n)return[];const a=Xne(t,e,n);if(a.length<6)return[];const{maxDev:o,idx:l}=hj(a),c=Yo(a[0],a[a.length-1]);if(o<r||c<1e-6)return[];const h=Math.min(Math.max(4,c/8),24),p=CE(yv(t,e,1,n,h)),m=CE(yv(t,n,-1,e,h));if(Qne(a[0],a[a.length-1],a,p,m,Math.max(r,1.2)))return[];if(Zne(a[0],a[a.length-1],a,p,m,Math.max(r,1.2)))return[];const{c1:y,c2:v}=Jne(a[0],a[a.length-1],p,m,a),{err:b,idx:S}=wke(a[0],y,v,a[a.length-1],a);if(b<=Math.max(r,c*.02,2))return[];let E=b>o*.6?S:l;E=Math.max(2,Math.min(a.length-3,E));const I=(e+E)%i;return I===e||I===n?[]:l5(i,e,I)<3||l5(i,I,n)<3?[]:[...c5(t,e,I,s+1,r),I,...c5(t,I,n,s+1,r)]},Y2=(t,e)=>{const n=t.find(s=>
6861s.index===e.index);if(n){n.sharp=n.sharp||e.sharp;return}t.push(e)},ese=t=>{const e=t.filter((S,E,I)=>{if(E===0)return!0;const M=I[E-1];return Math.hypot(S.x-M.x,S.y-M.y)>1e-6});if(e.length>2){const S=e[0],E=e[e.length-1];Math.hypot(S.x-E.x,S.y-E.y)<1e-6&&e.pop()}if(e.length<3)return[];let n=1/0,s=1/0,r=-1/0,i=-1/0;for(const S of e)S.x<n&&(n=S.x),S.y<s&&(s=S.y),S.x>r&&(r=S.x),S.y>i&&(i=S.y);const a=Math.hypot(r-n,i-s)||1,o=Math.max(1.1,a*.006),l=Math.max(.45,a*.0012),c=Ske(e,a),h=[];if(c.length>=2)c.forEach(S=>Y2(h,{index:S,sharp:!0}));else{const S=Eke(e,a);S.length>=1&&S.forEach(E=>{Y2(h,{index:E.start,sharp:!1}),Y2(h,{index:E.end,sharp:!1})}),h.length<3&&Tke(e).forEach(E=>Y2(h,{index:E,sharp:!1}))}if(h.sort((S,E)=>S.index-E.index),h.length<2)return e.map(S=>({x:S.x,y:S.y,handleIn:{x:S.x,y:S.y},handleOut:{x:S.x,y:S.y}}));e.length;const p=[];for(let S=0;S<h.length;S++){const E=h[S].index,I=h[(S+1)%h.length].index;p.push(...c5(e,E,I,0,o))}p.forEach(S=>Y2(h,{index:S,sharp:!1})),h.sort((S,E)=>S.index-E.index);const m=h.length,y=h.map(S=>({x:e[S.index].x,y:e[S.index].y,handleIn:null,handleOut:null})),v=Math.min(Math.max(8,a*.045),48),b=h.map((S,E)=>{const I=h[(E-1+m)%m].index,M=h[(E+1)%m].index,j=S.sharp?yv(e,S.index,1,M,v):xke(e,S.index,I,M,v);return S.sharp?j:CE(j)});for(let S=0;S<m;S++){const E=(S+1)%m,I=h[S].index,M=h[E].index,j=e[I],L=e[M],K=Xne(e,I,M),{maxDev:D}=hj(K),R=Yo(j,L);if(D<l||R<1e-6||K.length<3){y[S].handleOut={x:j.x,y:j.y},y[E].handleIn={x:L.x,y:L.y};continue}const B=Math.min(Math.max(4,R/8),v),G=h[S].sharp?yv(e,I,1,M,B):b[S],X=h[E].sharp?yv(e,M,-1,I,B):{x:-b[E].x,y:-b[E].y},{c1:H,c2:Y}=vke(j,L,K,G,X,o);y[S].handleOut=H,y[E].handleIn=Y}for(const S of y)S.handleIn||(S.handleIn={x:S.x,y:S.y}),S.handleOut||(S.handleOut={x:S.x,y:S.y});return bke(y,h.map(S=>S.sharp)),y},_u=.552284749815,Ake=(t,e)=>Math.max(0,Math.min(t,e)/2),A0=(t,e,n)=>Math.max(0,Math.min(t,Ake(e,n))),Cke=(t,e,n)=>({tl:A0((t==null?void 0:t.tl)??0,e,n),tr:A0((t==null?void 0:t.tr)??0,e,n),br:A0((t==null?void 0:t.br)??0,e,n),bl:A0((t==null?void 0:t.bl)??0,e,n)}),q0=(t,e,n,s)=>{const r=A0(n??0,t,e);if(!s)return{tl:r,tr:r,br:r,bl:r};const i=Cke(s,t,e);return{tl:i.tl,tr:i.tr,br:i.br,bl:i.bl}},zg=(t,e=1e-6)=>Math.abs(t.tl-t.tr)<e&&Math.abs(t.tr-t.br)<e&&Math.abs(t.br-t.bl)<e,mH=(t,e)=>A0(Math.min(t,e)*.12,t,e),kke=(t,e,n,s,r,i,a=8)=>{const o=q0(n,s,r,i);if(o.tl<=0&&o.tr<=0&&o.br<=0&&o.bl<=0)return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+s},{x:t,y:e+s}];const l=[],c=[{cx:t+o.tl,cy:e+o.tl,start:Math.PI,end:Math.PI*1.5,r:o.tl},{cx:t+n-o.tr,cy:e+o.tr,start:Math.PI*1.5,end:Math.PI*2,r:o.tr},{cx:t+n-o.br,cy:e+s-o.br,start:0,end:Math.PI*.5,r:o.br},{cx:t+o.bl,cy:e+s-o.bl,start:Math.PI*.5,end:Math.PI,r:o.bl}];for(const h of c){if(h.r<=0){l.push({x:h.cx,y:h.cy});continue}for(let p=0;p<a;p++){const m=p/a,y=h.start+(h.end-h.start)*m;l.push({x:h.cx+h.r*Math.cos(y),y:h.cy+h.r*Math.sin(y)})}}return l},e3=(t,e,n,s,r,i)=>{const a=q0(n,s,r,i),o=m=>_u*m,l=a.tl,c=a.tr,h=a.br,p=a.bl;return[`M ${t+l} ${e}`,`L ${t+n-c} ${e}`,`C ${t+n-c+o(c)} ${e} ${t+n} ${e+c-o(c)} ${t+n} ${e+c}`,`L ${t+n} ${e+s-h}`,`C ${t+n} ${e+s-h+o(h)} ${t+n-h+o(h)} ${e+s} ${t+n-h} ${e+s}`,`L ${t+p} ${e+s}`,`C ${t+p-o(p)} ${e+s} ${t} ${e+s-p+o(p)} ${t} ${e+s-p}`,`L ${t} ${e+l}`,`C ${t} ${e+l-o(l)} ${t+l-o(l)} ${e} ${t+l} ${e}`,"Z"].join(" ")},Ike=(t,e,n,s,r,i)=>{const a=q0(n,s,r,i);if(a.tl<=0&&a.tr<=0&&a.br<=0&&a.bl<=0)return[{x:t,y:e,handleIn:{x:t,y:e},handleOut:{x:t,y:e}},{x:t+n,y:e,handleIn:{x:t+n,y:e},handleOut:{x:t+n,y:e}},{x:t+n,y:e+s,handleIn:{x:t+n,y:e+s},handleOut:{x:t+n,y:e+s}},{x:t,y:e+s,handleIn:{x:t,y:e+s},handleOut:{x:t,y:e+s}}];const o=_u*a.tl,l=_u*a.tr,c=_u*a.br,h=_u*a.bl,p={x:t+a.tl,y:e,handleIn:{x:t+a.tl-o,y:e},handleOut:{x:t+a.tl,y:e}},m={x:t+n-a.tr,y:e,handleIn:{x:t+n-a.tr,y:e},handleOut:{x:t+n-a.tr+l,y:e}},y={x:t+n,y:e+a.tr,handleIn:{x:t+n,y:e+a.tr-l},handleOut:{x:t+n,y:e+a.tr}},v={x:t+n,y:e+s-a.br,handleIn:{x:t+n,y:e+s-a.br},handleOut:{x:t+n,y:e+s-a.br+c}},b={x:t+n-a.br,y:e+s,handleIn:{x:t+n-a.br+c,y:e+s},handleOut:{x:t+n-a.br,y:e+s}},S={x:t+a.bl,y:e+s,handleIn:{x:t+a.bl,y:e+s},handleOut:{x:t+a.bl-h,y:e+s}},E={x:t,y:e+s-a.bl,handleIn:{x:t,y:e+s-a.bl+h},handleOut:{x:t,y:e+s-a.bl}},I={x:t,y:e+a.tl,handleIn:{x:t,y:e+a.tl},handleOut:{x:t,y:e+a.tl-o}};return[p,m,y,v,b,S,E,I]},$M=t=>["rect","ellipse","polygon","star","line","path"].includes(t),ro=t=>!!(t.pathNodes&&t.pathNodes.length>=2||t.pathContours&&t.pathContours.some(e=>e.length>=2)),fj=t=>{if(t.length===0)return{x:0,y:0,width:1,height:1};let e=t[0].x,n=t[0].x,s=t[0].y,r=t[0].y;for(let i=1;i<t.length;i++){const a=t[i];a.x<e?e=a.x:a.x>n&&(n=a.x),a.y<s?s=a.y:a.y>r&&(r=a.y)}return{x:e,y:s,width:Math.max(1,n-e),height:Math.max(1,r-s)}},Su=t=>fj(t),Lm=t=>t.map(e=>({x:e.x,y:e.y,handleIn:e.handleIn?{...e.handleIn}:null,handleOut:e.handleOut?{...e.handleOut}:null})),Pv=t=>t.map(e=>Lm(e)),Tm=t=>{const e=t.flat();return Su(e)},fS=(t,e,n,s)=>{if(!s)return t;const r=s*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=t.x-e,l=t.y-n;return{x:e+o*i-l*a,y:n+o*a+l*i}},gH=(t,e,n,s)=>t.map(r=>({x:fS({x:r.x,y:r.y},e,n,s).x,y:fS({x:r.x,y:r.y},e,n,s).y,handleIn:r.handleIn?fS(r.handleIn,e,n,s):null,handleOut:r.handleOut?fS(r.handleOut,e,n,s):null})),Sh=t=>{if(!Number.isFinite(t))return 0;const e=Math.round(t*1e6)/1e6;
6861if(Math.abs(e-360)<1e-6)return 360;let n=e%360;return n<0&&(n+=360),n},tse=t=>{if(!t)return 0;const e=Sh(t);return e===360?0:e},rI=(t,e,n,s)=>{if(!s)return t;const r=t.x+t.width/2,i=t.y+t.height/2,a=fS({x:r,y:i},e,n,s),o=a.x-r,l=a.y-i,c=Sh((t.rotation||0)+s);if(ro(t)&&t.pathNodes){const h=t.pathNodes.map(p=>({x:p.x+o,y:p.y+l,handleIn:p.handleIn?{x:p.handleIn.x+o,y:p.handleIn.y+l}:null,handleOut:p.handleOut?{x:p.handleOut.x+o,y:p.handleOut.y+l}:null}));return Pke({...t,rotation:c},h,t.pathClosed!==!1)}return{...t,x:t.x+o,y:t.y+l,rotation:c}},Nke=t=>{const e=t.x+t.width/2,n=t.y+t.height/2,s=t.width/2,r=t.height/2,i=t.sides||6;if(t.type==="star"){const o=Math.min(s,r),l=o*(t.starInnerRadius||.4),c=[];for(let h=0;h<i*2;h++){const p=h*Math.PI/i-Math.PI/2,m=h%2===0?o:l;c.push({x:e+m*Math.cos(p),y:n+m*Math.sin(p)})}return c}const a=[];for(let o=0;o<i;o++){const l=2*Math.PI*o/i-Math.PI/2;a.push({x:e+s*Math.cos(l),y:n+r*Math.sin(l)})}return a},Rke=t=>({x:t.x,y:t.y,handleIn:{x:t.x,y:t.y},handleOut:{x:t.x,y:t.y}}),Mke=(t,e,n)=>{const s=t.x-e.x,r=t.y-e.y,i=n.x-e.x,a=n.y-e.y,o=Math.hypot(s,r),l=Math.hypot(i,a);if(o<1e-6||l<1e-6)return 180;const c=(s*i+r*a)/(o*l);return Math.acos(Math.max(-1,Math.min(1,c)))*180/Math.PI},yH=(t,e,n)=>{if(Mke(t,e,n)<150)return Rke(e);const r=Math.hypot(t.x-e.x,t.y-e.y)/3,i=Math.hypot(n.x-e.x,n.y-e.y)/3,a=e.x-t.x,o=e.y-t.y,l=n.x-e.x,c=n.y-e.y,h=Math.hypot(a,o)||1,p=Math.hypot(l,c)||1;return{x:e.x,y:e.y,handleIn:{x:e.x-a/h*r,y:e.y-o/h*r},handleOut:{x:e.x+l/p*i,y:e.y+c/p*i}}},nse=t=>{const e=t.x+t.width/2,n=t.y+t.height/2,s=t.width/2,r=t.height/2;let i=[],a=!0;if(t.type==="ellipse")i=[{x:e,y:n-r,handleIn:{x:e-_u*s,y:n-r},handleOut:{x:e+_u*s,y:n-r}},{x:e+s,y:n,handleIn:{x:e+s,y:n-_u*r},handleOut:{x:e+s,y:n+_u*r}},{x:e,y:n+r,handleIn:{x:e+_u*s,y:n+r},handleOut:{x:e-_u*s,y:n+r}},{x:e-s,y:n,handleIn:{x:e-s,y:n+_u*r},handleOut:{x:e-s,y:n-_u*r}}];else if(t.type==="rect"){let o;if(t.points&&t.points.length===4)o=t.points.map(l=>({...l}));else{if(t.cornerRadius&&t.cornerRadius>0||t.cornerRadii)return i=Ike(t.x,t.y,t.width,t.height,t.cornerRadius??0,t.cornerRadii),a=!0,t.rotation&&(i=gH(i,e,n,t.rotation)),{nodes:i,closed:a};o=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}]}i=o.map((l,c)=>{const h=o.length;return yH(o[(c-1+h)%h],l,o[(c+1)%h])})}else if(t.type==="line"){const o=t.points&&t.points.length>=2?t.points.map(l=>({...l})):[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y+t.height}];i=o.map((l,c)=>({x:l.x,y:l.y,handleIn:c===0?null:{x:l.x,y:l.y},handleOut:c===o.length-1?null:{x:l.x,y:l.y}})),a=!1}else if(t.type==="polygon"||t.type==="star"){const o=t.points&&t.points.length>=3?t.points.map(l=>({...l})):Nke(t);if(o.length>8)i=ese(o);else{const l=o.length;i=o.map((c,h)=>yH(o[(h-1+l)%l],c,o[(h+1)%l]))}}else return t.type==="path"&&t.pathNodes&&t.pathNodes.length>=2?{nodes:t.pathNodes.map(o=>({x:o.x,y:o.y,handleIn:o.handleIn?{...o.handleIn}:null,handleOut:o.handleOut?{...o.handleOut}:null})),closed:t.pathClosed!==!1}:null;return t.rotation&&(i=gH(i,e,n,t.rotation)),{nodes:i,closed:a}},Eh=t=>{if(ro(t)||!$M(t.type))return t;const e=nse(t);if(!e)return t;const n=Su(e.nodes),s=t.type==="line"?"line":"path";return{...t,type:s,...n,pathNodes:e.nodes,pathClosed:e.closed,rotation:0,cornerRadius:void 0,cornerRadii:void 0,points:void 0,sides:void 0}},Pke=(t,e,n)=>{var a;const s=Lm(e),r=(a=t.pathContours)!=null&&a.length?[s,...t.pathContours.slice(1).map(o=>Lm(o))]:void 0,i=r?Tm(r):Su(s);return{...t,...i,pathNodes:s,pathContours:r,pathClosed:n??t.pathClosed!==!1,rotation:t.rotation??0}},lw=(t,e)=>e==="in"&&t.handleIn?t.handleIn:e==="out"&&t.handleOut?t.handleOut:{x:t.x,y:t.y},pS=(t,e)=>{if(t.length<2)return"";const n=[`M ${t[0].x} ${t[0].y}`];for(let s=0;s<t.length-1;s++){const r=t[s],i=t[s+1],a=lw(r,"out"),o=lw(i,"in");n.push(`C ${a.x} ${a.y} ${o.x} ${o.y} ${i.x} ${i.y}`)}if(e&&t.length>2){const s=t[t.length-1],r=t[0],i=lw(s,"out"),a=lw(r,"in");n.push(`C ${i.x} ${i.y} ${a.x} ${a.y} ${r.x} ${r.y} Z`)}return n.join(" ")},t3=(t,e=!0)=>t.map(n=>pS(n,e)).filter(Boolean).join(" "),kE=(t,e,n=12)=>{if(t.length<2)return[];const s=[],r=e?t.length:t.length-1,i=(a,o,l,c,h)=>{const p=1-h;return{x:p*p*p*a.x+3*p*p*h*o.x+3*p*h*h*l.x+h*h*h*c.x,y:p*p*p*a.y+3*p*p*h*o.y+3*p*h*h*l.y+h*h*h*c.y}};for(let a=0;a<r;a++){const o=t[a],l=t[(a+1)%t.length],c={x:o.x,y:o.y},h=lw(o,"out"),p=lw(l,"in"),m={x:l.x,y:l.y};for(let y=0;y<=n;y++)y===n&&a<r-1||s.push(i(c,h,p,m,y/n))}return s},xH=(t,e,n,s,r=0)=>{var h,p,m;const i=(h=t.pathContours)!=null&&h.length?Pv(t.pathContours):t.pathNodes?[Lm(t.pathNodes)]:[],a=i[r];if(!a||e<0||e>=a.length)return t;const o=a[e];if(n==="anchor"){const y=s.x-o.x,v=s.y-o.y;o.x=s.x,o.y=s.y,o.handleIn&&(o.handleIn={x:o.handleIn.x+y,y:o.handleIn.y+v}),o.handleOut&&(o.handleOut={x:o.handleOut.x+y,y:o.handleOut.y+v})}else n==="handleIn"?o.handleIn={x:s.x,y:s.y}:n==="handleOut"&&(o.handleOut={x:s.x,y:s.y});const l=i[0]||[],c=(p=t.pathContours)!=null&&p.length?Tm(i):Su(l);return{...t,...c,pathNodes:Lm(l),pathContours:(m=t.pathContours)!=null&&m.length?Pv(i):void 0,pathClosed:t.pathClosed!==!1,rotation:t.rotation??0}},sse=(t,e,n=0)=>{var p,m,y;const s=(p=t.pathContours)!=null&&p.length?Pv(t.pathContours):(m=t.pathNodes)!=null&&m.length?[Lm(t.pathNodes)]:null;if(!s)return null;const r=s[n];if(!r||e<0||e>=r.length)return null;let i=t.pathClosed!==!1;const a=2,o=3;if(!i&&r.length<=a)return s.length===1?{kind:"remove"}:null;if(i&&r.length<o)return s.length===1?{kind:"remove"}:null;if(r.splice(e,1),r.length===0){if(s.splice(n,1),s.length===0)return{kind:"remove"}}else if(i&&r.length===2)i=!1;
6861else if(!i&&r.length<a){if(s.length===1)return{kind:"remove"};if(s.splice(n,1),s.length===0)return{kind:"remove"}}const l=s[0];if(!(l!=null&&l.length))return{kind:"remove"};const c=s.length>1||(y=t.pathContours)!=null&&y.length?s:void 0,h=c?Tm(s):Su(l);return{kind:"updated",obj:{...t,type:t.type==="line"?"line":"path",...h,pathNodes:Lm(l),pathContours:c?Pv(c):void 0,pathClosed:i,rotation:t.rotation??0,points:void 0,cornerRadius:void 0,cornerRadii:void 0,sides:void 0}}},pj=(t,e,n,s,r,i)=>{var v;const a=e.pathNodes;if(!a.length||e.width<1e-6||e.height<1e-6)return{...t,x:n,y:s,width:r,height:i};const o=r/e.width,l=i/e.height,c=b=>({x:n+(b.x-e.x)*o,y:s+(b.y-e.y)*l}),h=b=>({x:c({x:b.x,y:b.y}).x,y:c({x:b.x,y:b.y}).y,handleIn:b.handleIn?c(b.handleIn):null,handleOut:b.handleOut?c(b.handleOut):null}),p=a.map(h),m=(v=e.pathContours)!=null&&v.length?e.pathContours:t.pathContours,y=m!=null&&m.length?m.map(b=>b.map(h)):void 0;return{...t,x:n,y:s,width:r,height:i,pathNodes:Lm(p),pathContours:y?Pv(y):void 0,pathClosed:t.pathClosed!==!1,rotation:t.rotation??0}},mj=t=>({x:t.x,y:t.y,width:t.width,height:t.height,pathNodes:t.pathNodes.map(e=>({x:e.x,y:e.y,handleIn:e.handleIn?{...e.handleIn}:null,handleOut:e.handleOut?{...e.handleOut}:null})),pathContours:t.pathContours?Pv(t.pathContours):void 0}),id=t=>{var e;return{...t,cornerRadii:t.cornerRadii?{...t.cornerRadii}:void 0,pathNodes:t.pathNodes?Lm(t.pathNodes):void 0,pathContours:t.pathContours?Pv(t.pathContours):void 0,points:(e=t.points)==null?void 0:e.map(n=>({...n}))}},$ke=(t,e,n)=>{if(e===0&&n===0)return t;const s={...t,x:t.x+e,y:t.y+n};return t.pathNodes&&(s.pathNodes=t.pathNodes.map(r=>({x:r.x+e,y:r.y+n,handleIn:r.handleIn?{x:r.handleIn.x+e,y:r.handleIn.y+n}:null,handleOut:r.handleOut?{x:r.handleOut.x+e,y:r.handleOut.y+n}:null}))),t.pathContours&&(s.pathContours=t.pathContours.map(r=>r.map(i=>({x:i.x+e,y:i.y+n,handleIn:i.handleIn?{x:i.handleIn.x+e,y:i.handleIn.y+n}:null,handleOut:i.handleOut?{x:i.handleOut.x+e,y:i.handleOut.y+n}:null})))),t.points&&(s.points=t.points.map(r=>({x:r.x+e,y:r.y+n}))),s},Dke=new Set(["rect","ellipse","polygon","star","path","line"]);let n3=null;const vH=()=>{if(typeof window<"u"){const t=window.polygonClipping;if(t)return Promise.resolve(t)}return n3||(n3=new Promise((t,e)=>{const n=document.createElement("script");n.src="/vendor/polygon-clipping.umd.min.js",n.async=!0,n.onload=()=>{const s=window.polygonClipping;s?t(s):e(new Error("polygon-clipping failed to load"))},n.onerror=()=>e(new Error("polygon-clipping script error")),document.head.appendChild(n)})),n3},rse=t=>Dke.has(t.type),LI=(t,e,n)=>{if(n.length===0)return null;let s=[n[0]];for(let r=1;r<n.length;r++)if(e==="union"?s=t.union(s,n[r]):e==="intersection"?s=t.intersection(s,n[r]):s=t.xor(s,n[r]),!s||s.length===0)return s;return s},ise=(t,e,n,s)=>{if(!s)return t;const r=s*Math.PI/180,i=Math.cos(r),a=Math.sin(r);return t.map(o=>{const l=o.x-e,c=o.y-n;return{x:e+l*i-c*a,y:n+l*a+c*i}})},Oke=t=>{const e=t.x+t.width/2,n=t.y+t.height/2,s=t.width/2,r=t.height/2,i=t.sides||6;if(t.type==="star"){const o=Math.min(s,r),l=o*(t.starInnerRadius||.4),c=[];for(let h=0;h<i*2;h++){const p=h*Math.PI/i-Math.PI/2,m=h%2===0?o:l;c.push({x:e+m*Math.cos(p),y:n+m*Math.sin(p)})}return c}const a=[];for(let o=0;o<i;o++){const l=2*Math.PI*o/i-Math.PI/2;a.push({x:e+s*Math.cos(l),y:n+r*Math.sin(l)})}return a},Lke=t=>{if(t.pathNodes&&t.pathNodes.length>=2)return t.type==="line"||t.pathClosed===!1?[]:kE(t.pathNodes,t.pathClosed!==!1,24);let e;if(t.type==="rect"&&t.points&&t.points.length===4)e=t.points.map(r=>({...r}));else if((t.type==="polygon"||t.type==="star")&&t.points&&t.points.length>=3)e=t.points.map(r=>({...r}));else if(t.type==="rect")t.cornerRadius&&t.cornerRadius>0||t.cornerRadii?e=kke(t.x,t.y,t.width,t.height,t.cornerRadius??0,t.cornerRadii):e=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];else if(t.type==="ellipse"){const r=t.x+t.width/2,i=t.y+t.height/2,a=t.width/2,o=t.height/2,l=96;e=[];for(let c=0;c<l;c++){const h=2*Math.PI*c/l-Math.PI/2;e.push({x:r+a*Math.cos(h),y:i+o*Math.sin(h)})}}else if(t.type==="polygon"||t.type==="star")e=Oke(t);else return t.type==="path"?[]:[];const n=t.x+t.width/2,s=t.y+t.height/2;return ise(e,n,s,t.rotation)},fR=t=>{if(t.length<3)return[];const e=t.map(r=>[r.x,r.y]),n=e[0],s=e[e.length-1];return(n[0]!==s[0]||n[1]!==s[1])&&e.push([n[0],n[1]]),e},bH=t=>{if(t.pathContours&&t.pathContours.length>0){const s=t.pathContours.map(r=>fR(kE(r,t.pathClosed!==!1,24))).filter(r=>r.length>=4);return s.length?s:null}const e=Lke(t);if(e.length<3)return null;const n=fR(e);return n.length<4?null:[n]},jke=t=>{const e=t.map(([n,s])=>({x:n,y:s}));if(e.length>1){const n=e[0],s=e[e.length-1];n.x===s.x&&n.y===s.y&&e.pop()}return e},Bke=t=>{const e=t.filter((n,s,r)=>
6861{if(s===0)return!0;const i=r[s-1];return Math.hypot(n.x-i.x,n.y-i.y)>1e-6});if(e.length>2){const n=e[0],s=e[e.length-1];Math.hypot(n.x-s.x,n.y-s.y)<1e-6&&e.pop()}return e.map(n=>({x:n.x,y:n.y,handleIn:{x:n.x,y:n.y},handleOut:{x:n.x,y:n.y}}))},gj=(t,e,n,s)=>{const r=t[0];if(!r||r.length<3)return null;const i=t.map(jke).filter(l=>l.length>=3).map(l=>{const c=ese(l);return c.length>=3?c:Bke(l)}).filter(l=>l.length>=2),a=i[0];if(!a)return null;const o=i.length>1?Tm(i):Su(a);return{...e,id:s,type:"path",...o,pathNodes:a,pathContours:i.length>1?i:void 0,pathClosed:!0,points:void 0,sides:void 0,cornerRadius:void 0,cornerRadii:void 0,rotation:0,name:n,visible:!0,locked:!1}},Uke=(t,e,n,s,r)=>{const i=[];return t.forEach((a,o)=>{const l=gj(a,e,`${n.charAt(0).toUpperCase()+n.slice(1)} ${s+o+1}`,r());l&&i.push(l)}),i},Fke=(t,e)=>{for(let n=e-1;n>=0;n--)if(t&1<<n)return n;return 0},Vke=(t,e,n,s,r)=>{const i=e.length;if(i>12)return null;const a=[],o=1<<i;for(let l=1;l<o;l++){const c=[],h=[];for(let y=0;y<i;y++)l&1<<y?c.push(e[y]):h.push(e[y]);let p;try{if(p=c.length===1?[c[0]]:t.intersection(c[0],...c.slice(1)),!p||p.length===0||h.length>0&&(p=t.difference(p,...h),!p||p.length===0))continue}catch{continue}const m=n[Fke(l,i)];p.forEach(y=>{const v=gj(y,m,`Divide ${s+a.length+1}`,r());v&&a.push(v)})}return a.length>0?a:null},zke=t=>{const e=[];for(const n of t){const s=e[e.length-1];(!s||Math.hypot(s.x-n.x,s.y-n.y)>1e-6)&&e.push(n)}if(e.length>1){const n=e[0],s=e[e.length-1];Math.hypot(n.x-s.x,n.y-s.y)<1e-6&&e.pop()}return e},Gke=t=>{let e=[];t.pathNodes&&t.pathNodes.length>=2&&t.pathClosed===!1?e=kE(t.pathNodes,!1,24):t.type==="line"&&t.points&&t.points.length>=2&&(e=[{...t.points[0]},{...t.points[t.points.length-1]}]);const n=zke(e);if(n.length<2)return null;const s=t.x+t.width/2,r=t.y+t.height/2;return{points:ise(n,s,r,t.rotation||0),radius:Math.max(.75,(t.strokeWidth||1)*.35)}},Hke=(t,e,n=16)=>{const s=[];for(let r=0;r<n;r++){const i=2*Math.PI*r/n;s.push({x:t.x+e*Math.cos(i),y:t.y+e*Math.sin(i)})}return[fR(s)]},qke=(t,e,n)=>{const s=e.x-t.x,r=e.y-t.y,i=Math.hypot(s,r);if(i<1e-6)return null;const a=-r/i,o=s/i,l=fR([{x:t.x+a*n,y:t.y+o*n},{x:e.x+a*n,y:e.y+o*n},{x:e.x-a*n,y:e.y-o*n},{x:t.x-a*n,y:t.y-o*n}]);return l.length>=4?[l]:null},Wke=(t,e)=>{const n=[];for(let s=0;s<e.points.length-1;s++){const r=qke(e.points[s],e.points[s+1],e.radius);r&&n.push(r)}if(e.points.forEach(s=>{const r=Hke(s,e.radius);r[0].length>=4&&n.push(r)}),n.length===0)return null;if(n.length===1)return[n[0]];try{const s=LI(t,"union",n);return s&&s.length>0?s:null}catch{return null}},Kke=(t,e,n,s,r,i)=>{const a=[];let o=!1;return e.forEach((l,c)=>{let h=[l];s.forEach(p=>{const m=Wke(t,p);if(!m||h.length===0)return;const y=[];h.forEach(v=>{try{const b=t.difference(v,m);if(!b||b.length===0)return;b.forEach(S=>y.push(S))}catch{y.push(v)}}),y.length>h.length&&(o=!0),h=y}),h.forEach(p=>{const m=gj(p,n[c],`Divide ${r+a.length+1}`,i());m&&a.push(m)})}),o&&a.length>0?a:null},Yke=async(t,e,n)=>{const s=e.filter(rse);if(s.length<2)return null;const r=t==="divide"?s.map(m=>Gke(m)).filter(m=>m!==null):[],i=s.map(m=>({shape:m,polygon:bH(m)})).filter(m=>m.polygon!==null),a=i.map(m=>m.polygon),o=i.map(m=>m.shape);if(t==="divide"&&r.length>0){if(a.length<1)return null;const m=await vH();return Kke(m,a,o,r,e.length,n)}const l=s.map(bH).filter(m=>m!==null);if(l.length<2)return null;const c=await vH(),h=t==="subtract"?o[0]:o[o.length-1];let p=null;try{switch(t){case"divide":return Vke(c,l,o,e.length,n);case"unite":p=LI(c,"union",l);break;case"intersect":p=LI(c,"intersection",l);break;case"subtract":{let m=[l[0]];for(let y=1;y<l.length&&(m=c.difference(m,l[y]),!(!m||m.length===0));y++);p=m;break}case"exclude":p=LI(c,"xor",l);break;default:return null}}catch{return null}return!p||p.length===0?null:Uke(p,h,t,e.length,n)},By=t=>!(t.type==="line"||t.type==="path"&&t.pathClosed===!1),$g=t=>t.type!=="text",Xke=["rect","roundedRect","ellipse","triangle","star","diamond","hexagon"],s3=["rect","roundedRect","ellipse","triangle","star","line","diamond","hexagon"],xv=t=>!!(t.points&&t.points.length===4),Jy=t=>t.type==="rect"&&!xv(t)?q0(t.width,t.height,t.cornerRadius??0,t.cornerRadii):{tl:0,tr:0,br:0,bl:0},u5=t=>t.type==="rect"&&!xv(t),d5=t=>{if(!u5(t))return!1;const e=Jy(t);return e.tl>0||e.tr>0||e.br>0||e.bl>0},yj=(t,e,n,s,r)=>{const i=Jy(t);return q0(e,n,A0((t.cornerRadius??0)*Math.min(s,r),e,n),{tl:i.tl*Math.min(s,r),tr:i.tr*Math.min(s,r),br:i.br*Math.min(s,r),bl:i.bl*Math.min(s,r)})},wH="flex-shrink-0 w-4 h-4 flex items-center justify-center [&>svg]:size-[15px]",Jke=()=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,
6861children:d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"5",ry:"5"})}),Qke=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("path",{d:"M12 19l7-7-4-4-7 7-2 6z"}),d.jsx("path",{d:"M14 6l4 4"})]}),_H=[{t:"rect",icon:d.jsx(ZL,{size:15}),label:"Rectangle (R)"},{t:"roundedRect",icon:d.jsx(Jke,{}),label:"Rounded Rectangle"},{t:"ellipse",icon:d.jsx(JX,{size:15}),label:"Ellipse (E)"},{t:"triangle",icon:d.jsx(Gwe,{size:15}),label:"Triangle"},{t:"star",icon:d.jsx(EM,{size:15}),label:"Star"},{t:"diamond",icon:d.jsx(abe,{size:15}),label:"Diamond"},{t:"hexagon",icon:d.jsx(Ibe,{size:15}),label:"Hexagon"},{t:"line",icon:d.jsx(twe,{size:15}),label:"Line"}],Zke=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"}),d.jsx("path",{d:"M10 7L4 12l6 5V7z"}),d.jsx("path",{d:"M14 7l6 5-6 5V7z"})]}),eIe=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),d.jsx("path",{d:"M7 10L12 4l5 6H7z"}),d.jsx("path",{d:"M7 14l5 6 5-6H7z"})]}),SH=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),d.jsx("rect",{x:"14",y:"4",width:"7",height:"7",rx:"1.5"}),d.jsx("rect",{x:"8.5",y:"13",width:"7",height:"7",rx:"1.5"}),d.jsx("path",{d:"M10 9h4M12 11v2"})]}),EH=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),d.jsx("rect",{x:"14",y:"4",width:"7",height:"7",rx:"1.5"}),d.jsx("rect",{x:"8.5",y:"13",width:"7",height:"7",rx:"1.5"}),d.jsx("path",{d:"M10 9h4"})]}),r3=(t,e,n)=>{const s=e.x-t.x,r=e.y-t.y;if(n==="line"){const l=Math.hypot(s,r);if(l<2)return e;const c=Math.atan2(r,s),h=Math.PI/4,p=Math.round(c/h)*h;return{x:t.x+l*Math.cos(p),y:t.y+l*Math.sin(p)}}if(!Xke.includes(n))return e;const i=Math.max(Math.abs(s),Math.abs(r));if(i<1e-9)return e;const a=s>=0?1:-1,o=r>=0?1:-1;return{x:t.x+a*i,y:t.y+o*i}},ase=(t,e,n,s)=>{const r=e.x,i=e.y,a=Math.max(e.width,1e-9),o=Math.max(e.height,1e-9),l=10,c=l/Math.min(a,o);if(t==="se"){const h=n-r,p=s-i,m=Math.max(c,Math.min(Math.abs(h)/a,Math.abs(p)/o)),y=a*m,v=o*m;return{x:r,y:i,width:Math.max(l,y),height:Math.max(l,v)}}if(t==="nw"){const h=r+a,p=i+o,m=h-n,y=p-s,v=Math.max(c,Math.min(Math.abs(m)/a,Math.abs(y)/o)),b=a*v,S=o*v;return{x:h-b,y:p-S,width:Math.max(l,b),height:Math.max(l,S)}}if(t==="ne"){const h=r,p=i+o,m=n-h,y=p-s,v=Math.max(c,Math.min(Math.abs(m)/a,Math.abs(y)/o)),b=a*v,S=o*v;return{x:h,y:p-S,width:Math.max(l,b),height:Math.max(l,S)}}if(t==="sw"){const h=r+a,p=i,m=h-n,y=s-p,v=Math.max(c,Math.min(Math.abs(m)/a,Math.abs(y)/o)),b=a*v,S=o*v;return{x:h-b,y:p,width:Math.max(l,b),height:Math.max(l,S)}}if(t==="e"){const p=Math.max(l,n-r)/a,m=Math.max(l,o*p),y=Math.max(l,a*p);return{x:r,y:i+(o-m)/2,width:y,height:m}}if(t==="w"){const h=r+a,m=Math.max(l,h-n)/a,y=Math.max(l,o*m),v=Math.max(l,a*m);return{x:h-v,y:i+(o-y)/2,width:v,height:y}}if(t==="s"){const p=Math.max(l,s-i)/o,m=Math.max(l,a*p),y=Math.max(l,o*p);return{x:r+(a-m)/2,y:i,width:m,height:y}}if(t==="n"){const h=i+o,m=Math.max(l,h-s)/o,y=Math.max(l,a*m),v=Math.max(l,o*m);return{x:r+(a-y)/2,y:h-v,width:y,height:v}}return{x:r,y:i,width:a,height:o}},TH=.004,tIe=(t,e)=>Math.abs(t-.5)>TH||Math.abs(e-.5)>TH,td=(t,e,n)=>Math.abs(e)<1e-9?n:t/e,nIe=(t,e,n,s,r,i,a)=>{const o=e.x,l=e.y,c=Math.max(e.width,1e-9),h=Math.max(e.height,1e-9),p=o+r*c,m=l+i*h,y=1-r,v=1-i;if(t==="se"){const b=Math.max(a,td(n-p,y,c)),S=Math.max(a,td(s-m,v,h));return{x:p-r*b,y:m-i*S,width:b,height:S}}if(t==="nw"){const b=Math.max(a,td(p-n,r,c)),S=Math.max(a,td(m-s,i,h));return{x:p-r*b,y:m-i*S,width:b,height:S}}if(t==="ne"){const b=Math.max(a,td(n-p,y,c)),S=Math.max(a,td(m-s,i,h));return{x:p-r*b,y:m-i*S,width:b,height:S}}if(t==="sw"){const b=Math.max(a,td(p-n,r,c)),S=Math.max(a,td(s-m,v,h));return{x:p-r*b,y:m-i*S,width:b,height:S}}if(t==="e"){const b=Math.max(a,td(n-p,y,c)),S=h;return{x:p-r*b,y:m-i*S,width:b,height:S}}if(t==="w"){const b=Math.max(a,td(p-n,r,c)),S=h;return{x:p-r*b,y:m-i*S,width:b,height:S}}if(t==="n"){const b=Math.max(a,td(m-s,i,h)),S=c;return{x:p-r*S,y:m-i*b,width:S,height:b}}if(t==="s"){const b=Math.max(a,td(s-m,v,h)),S=c;return{x:p-r*S,y:m-i*b,width:S,height:b}}return{x:o,y:l,width:c,height:h}},sIe=(t,e,n,s,r,i,a)=>{const o=e.x,l=e.y,c=Math.max(e.width,1e-9),h=Math.max(e.height,1e-9),p=o+r*c,m=l+i*h,y=a/Math.min(c,h);if(t==="se"){const v=(1-r)*c,b=(1-i)*h,S=Math.abs(v)<1e-9?0:(n-p)/v,E=Math.abs(b)<1e-9?0:(s-m)/b,I=Math.max(y,Math.min(S,E)),M=c*I,j=h*I;return{x:p-r*M,y:m-i*j,width:Math.max(a,M),height:Math.max(a,j)}}if(t==="nw"){const v=Math.abs(r)<1e-9?0:(p-n)/(r*c),b=Math.abs(i)<1e-9?0:(m-s)/(i*h),S=Math.max(y,Math.min(v,b)),E=c*S,I=h*S;return{x:p-r*E,y:m-i*I,width:Math.max(a,E),height:Math.max(a,I)}}if(t==="ne"){const v=(1-r)*c,b=-i*h,S=Math.abs(v)<1e-9?0:(n-p)/v,E=Math.abs(b)<1e-9?0:(s-m)/b,I=Math.max(y,Math.min(S,E)),M=c*I,j=h*I;return{x:p-r*M,y:m-i*j,width:Math.max(a,M),height:Math.max(a,j)}}if(t==="sw"){const v=Math.abs(r)<1e-9?0:(p-n)/(r*c),b=(1-i)*h,S=Math.abs(b)<1e-9?0:(s-m)/b,E=Math.max(y,Math.min(v,S)),I=c*E,M=h*E;return{x:p-r*I,y:m-i*M,width:Math.max(a,I),height:Math.max(a,M)}}if(t==="e"){const v=(1-r)*c,b=Math.abs(v)<1e-9?0:(n-p)/v,S=Math.max(y,b),E=c*S,I=h*S;return{x:p-r*E,y:m-i*I,width:Math.max(a,E),height:Math.max(a,I)}}if(t==="w"){const v=Math.abs(r)<1e-9?0:(p-n)/(r*c),b=Math.max(y,v),S=c*b,E=h*b;return{x:p-r*S,y:m-i*E,width:Math.max(a,S),height:Math.max(a,E)}}if(t==="s"){const v=(1-i)*h,b=Math.abs(v)<1e-9?0:(s-m)/v,S=Math.max(y,b),E=c*S,I=h*S;return{x:p-r*E,y:m-i*I,width:Math.max(a,E),height:Math.max(a,I)}}if(t==="n"){const v=Math.abs(i)<1e-9?0:(m-s)/(i*h),b=Math.max(y,v),S=c*b,E=h*b;return{x:p-r*S,y:m-i*E,width:Math.max(a,S),height:Math.max(a,E)}}return ase(t,e,n,s)},Xl=()=>Math.random().toString(36).substr(2,9),Bh=24,jI=1,rIe=4,h5=80,IE=36,iIe=200,aIe=56,AH=10,oIe=10,i3='url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2724%27 height=%2724%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23111827%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M12 20l8-8-4-4-8 8-2 6z%27/%3E%3Cpath d=%27M14 6l4 4%27/%3E%3C/svg%3E") 2 22, crosshair',lIe=["Inter","Roboto","Open Sans","Lato","Montserrat","Poppins","Raleway","Playfair Display","Merriweather","Oswald","Ubuntu","Nunito","PT Sans","Quicksand","Bebas Neue"],cIe="#ffffff",ose=t=>Math.max(0,Math.min(100,t)),lse=t=>Math.max(0,Math.min(100,t)),uIe=t=>Math.max(0,Math.min(100,t)),dp=t=>uIe(Number.isFinite(t)?t:100),NE=(t,e,n=100)=>({id:Xl(),color:t,offset:ose(e),opacity:dp(n)}),CH=t=>{if(t)return Ji({style:t.style,angle:t.angle,stops:t.stops.map(e=>NE(e.color,e.offset,e.opacity??100)),midpoints:t.midpoints})},kH=t=>({style:"linear",angle:0,stops:[NE(t,0),NE(cIe,100)],midpoints:[50]}),Qa=t=>t?{style:t.style,angle:t.angle,stops:t.stops.map(e=>({...e})),midpoints:[...t.midpoints]}:void 0,Ji=t=>{const e=t.stops.map(r=>({id:r.id||Xl(),color:r.color||"#000000",offset:ose(r.offset),opacity:dp(r.opacity)})).slice(0,4),n=e.length>=2?e:[NE("#000000",0),NE("#ffffff",100)],s=Array.from({length:Math.max(0,n.length-1)},(r,i)=>{var a;return lse(((a=t.midpoints)==null?void 0:a[i])??50)});return{style:t.style==="radial"?"radial":"linear",angle:Number.isFinite(t.angle)?t.angle:0,stops:n,midpoints:s}},BI=t=>{const e=Ji(t),n=e.stops.map((s,r)=>({stop:s,midpointAfter:r<e.stops.length-1?e.midpoints[r]:void 0}));return n.sort((s,r)=>s.stop.offset-r.stop.offset),{...e,stops:n.map(s=>
6861s.stop),midpoints:n.map(s=>s.midpointAfter).filter(s=>s!==void 0)}},f5=t=>{const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{3}$/.test(e)?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)}:/^[0-9a-fA-F]{6}$/.test(e)?{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}:null},a3=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0"),dIe=(t,e,n)=>{const s=f5(t),r=f5(e);if(!s||!r)return null;const i=Math.max(0,Math.min(1,n));return`#${a3(s.r+(r.r-s.r)*i)}${a3(s.g+(r.g-s.g)*i)}${a3(s.b+(r.b-s.b)*i)}`},RE=(t,e)=>{const n=f5(t);if(!n)return t;const s=dp(e)/100;return`rgba(${n.r}, ${n.g}, ${n.b}, ${s})`},Jp=(t,e)=>dp(e==="fill"?t.fillOpacity:t.strokeOpacity),X2=(t,e)=>{if(Ff(t,e)||pR(t,e)==="none")return"";const s=Jp(t,e)/100;return s>=.9999?"":e==="fill"?` fill-opacity="${s.toFixed(4)}"`:` stroke-opacity="${s.toFixed(4)}"`},p5=t=>{const e=BI(t),n=[];return e.stops.forEach((s,r)=>{if(n.push({color:s.color,offset:s.offset,opacity:dp(s.opacity)}),r>=e.stops.length-1)return;const i=e.stops[r+1],a=i.offset-s.offset;if(a<.01)return;const o=lse(e.midpoints[r]??50)/100,l=s.offset+a*o;n.push({color:dIe(s.color,i.color,.5)||s.color,offset:l,opacity:(dp(s.opacity)+dp(i.opacity))/2})}),n.sort((s,r)=>s.offset-r.offset)},cse=t=>{const e=Ji(t),n=p5(e).map(s=>`${RE(s.color,s.opacity)} ${s.offset}%`).join(", ");return e.style==="radial"?`radial-gradient(circle at 50% 50%, ${n})`:`linear-gradient(${e.angle}deg, ${n})`},o3=(t,e)=>`vs-grad-${t}-${e}`,ix=(t,e)=>e==="fill"?t.fillGradient:t.strokeGradient,hIe=(t,e)=>e==="fill"?t.fillMode||"solid":t.strokeMode||"solid",pR=(t,e)=>e==="fill"?t.fill:t.stroke,Ff=(t,e)=>{const n=pR(t,e),s=ix(t,e);return n!=="none"&&hIe(t,e)==="gradient"&&!!(s&&s.stops.length>=2)},J2=(t,e,n,s=100)=>t==="none"?{backgroundColor:"transparent",backgroundImage:"repeating-linear-gradient(45deg, #94a3b8 0, #94a3b8 2px, transparent 2px, transparent 5px)"}:e==="gradient"&&n?{backgroundImage:cse(n)}:{backgroundColor:RE(t,s)},DM=t=>{const e=t||"Inter";return`${e.includes(" ")?`'${e}'`:e}, sans-serif`},IH=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),l3=t=>{if(!t||!(t instanceof Element))return null;let e=t;for(;e;){const n=e.getAttribute("data-object-id");if(n)return n;e=e.parentElement??(e.parentNode instanceof Element?e.parentNode:null)}return null},m5=t=>t.type==="text"&&!!t.textOutline&&t.stroke!=="none",g5=t=>Math.max(0,t.textOutlineWidth??jI),fIe=t=>{var s;if(!Ff(t,"stroke"))return RE(t.stroke,Jp(t,"stroke"));const e=ix(t,"stroke"),n=(s=e==null?void 0:e.stops)==null?void 0:s[0];return n?RE(n.color,dp(n.opacity)):t.stroke},use=(t,e=1)=>{if(!m5(t))return{};const n=g5(t)*e,s=fIe(t);return{WebkitTextStroke:`${n}px ${s}`,paintOrder:"stroke fill"}},pIe=t=>{if(!Ff(t,"fill"))return{color:t.fill==="none"?"#000000":RE(t.fill,Jp(t,"fill"))};const e=ix(t,"fill");return e?{backgroundImage:cse(e),WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",WebkitTextFillColor:"transparent"}:{color:t.fill==="none"?"#000000":t.fill}},mIe=t=>({width:"100%",height:"100%",margin:0,padding:"2px 4px",boxSizing:"border-box",fontFamily:DM(t.fontFamily),fontSize:`${t.fontSize||Bh}px`,fontWeight:t.fontWeight==="bold"?"bold":"normal",fontStyle:t.fontStyle==="italic"?"italic":"normal",textDecoration:t.textDecoration==="underline"?"underline":"none",textAlign:t.textAlign||"left",lineHeight:1.25,whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"hidden",...pIe(t),...use(t)}),gIe=new Set(["text","fontSize","fontFamily","fontWeight","fontStyle","textDecoration","textAlign"]);let c3=null;const dse=()=>{if(typeof document>"u")return null;if(!c3){const t=document.createElement("div");t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"absolute",left:"-99999px",to
6861p:"-99999px",visibility:"hidden",pointerEvents:"none",margin:"0",padding:"2px 4px",boxSizing:"border-box",lineHeight:"1.25"}),document.body.appendChild(t),c3=t}return c3},yIe=t=>{const e=dse();if(!e)return{width:t.width,height:t.height};const n=t.fontSize||Bh,s=t.text??"";if(e.style.fontFamily=DM(t.fontFamily),e.style.fontSize=`${n}px`,e.style.fontWeight=t.fontWeight==="bold"?"bold":"normal",e.style.fontStyle=t.fontStyle==="italic"?"italic":"normal",e.style.textDecoration=t.textDecoration==="underline"?"underline":"none",e.style.textAlign=t.textAlign||"left",t.autoFit){e.style.whiteSpace="pre",e.style.wordBreak="normal",e.style.overflowWrap="normal",e.style.width="auto",e.style.height="auto",e.textContent=s.length===0?" ":`${s}​`;const a=e.getBoundingClientRect();return{width:Math.max(h5,Math.ceil(a.width)+1),height:Math.max(IE,Math.ceil(a.height))}}e.style.whiteSpace="pre-wrap",e.style.wordBreak="break-word",e.style.overflowWrap="anywhere",e.style.width=`${Math.max(1,t.width)}px`,e.style.height="auto",e.textContent=s.length===0?" ":s;const r=e.getBoundingClientRect(),i=Math.max(IE,Math.ceil(r.height));return{width:t.width,height:Math.max(t.height,i)}},NH=t=>{if(t.type!=="text"||t.autoFit&&!(t.text??"").length)return t;const{width:e,height:n}=yIe(t);return Math.abs(t.width-e)<=.5&&Math.abs(t.height-n)<=.5?t:{...t,width:e,height:n}},xIe=t=>{const e=t.flipX?-1:1,n=t.flipY?-1:1,s=tse(t.rotation||0),r=[];return s&&r.push(`rotate(${s}deg)`),(e!==1||n!==1)&&r.push(`scale(${e}, ${n})`),r.length===0?{}:{transform:r.join(" "),transformOrigin:"center center"}},hse=["se","nw","ne","sw"],vIe=["n","s","e","w"],RH=[...hse,...vIe],y5=new Set(hse),OM=(t,e)=>{const n=Math.sqrt(Math.abs(t*e));return Number.isFinite(n)&&n>0?n:1},mR=(t,e,n)=>{if(t.type!=="text")return t;const s=(t.fontSize||Bh)*OM(e,n);return{...t,fontSize:Math.max(rIe,Math.round(s*100)/100)}},bIe=t=>{const e=dse();if(!e)return t.height;const n=t.fontSize||Bh,s=t.text??"";e.style.fontFamily=DM(t.fontFamily),e.style.fontSize=`${n}px`,e.style.fontWeight=t.fontWeight==="bold"?"bold":"normal",e.style.fontStyle=t.fontStyle==="italic"?"italic":"normal",e.style.textDecoration=t.textDecoration==="underline"?"underline":"none",e.style.textAlign=t.textAlign||"left",e.style.whiteSpace="pre-wrap",e.style.wordBreak="break-word",e.style.overflowWrap="anywhere",e.style.width=`${Math.max(1,t.width)}px`,e.style.height="auto",e.textContent=s.length===0?" ":s;const r=e.getBoundingClientRect();return Math.max(IE,Math.ceil(r.height))},fse=t=>{if(t.type!=="text"||t.autoFit)return t;const e=bIe(t);return Math.abs(t.height-e)<=.5?t:{...t,height:e}},wIe=(t,e,n,s)=>{const r=OM(n,s),i=Math.max(1,t.width*r),a=Math.max(1,t.height*r),o=t.x+t.width,l=t.y+t.height;switch(e){case"se":return{x:t.x,y:t.y,width:i,height:a};case"nw":return{x:o-i,y:l-a,width:i,height:a};case"ne":return{x:t.x,y:l-a,width:i,height:a};case"sw":return{x:o-i,y:t.y,width:i,height:a};default:return{x:t.x,y:t.y,width:i,height:a}}},_Ie=(t,e,n,s)=>{const r=OM(n,s),i=wIe(t,e,n,s);return fse(mR({...t,...i,autoFit:!1},r,r))},SIe=(t,e,n)=>{const s=t.halfW>1e-9?e.halfW/t.halfW:1,r=t.halfH>1e-9?e.halfH/t.halfH:1,i=OM(s,r),a=Math.max(.5,t.halfW*i),o=Math.max(.5,t.halfH*i),{u:l,v:c}=t,h=LM(t);switch(n){case"se":return{cx:h.nw.x+a*l.x+o*c.x,cy:h.nw.y+a*l.y+o*c.y,halfW:a,halfH:o};case"nw":return{cx:h.se.x-a*l.x-o*c.x,cy:h.se.y-a*l.y-o*c.y,halfW:a,halfH:o};case"ne":return{cx:h.sw.x+a*l.x-o*c.x,cy:h.sw.y+a*l.y-o*c.y,halfW:a,halfH:o};case"sw":return{cx:h.ne.x-a*l.x+o*c.x,cy:h.ne.y-a*l.y+o*c.y,halfW:a,halfH:o};default:return{...e,halfW:a,halfH:o}}},MH=t=>Math.min(1e4,Math.max(1,Math.round(t))),ax=t=>fj(t),EIe=t=>{const e=t.x+t.width/2,n=t.y+t.height/2,s=t.width/2,r=t.height/2,i=t.sides||6;if(t.type==="star"){const o=Math.min(s,r),l=o*(t.starInnerRadius||.4),c=[];for(let h=0;h<i*2;h++){const p=h*Math.PI/i-Math.PI/2,m=h%2===0?o:l;c.push({x:e+m*Math.cos(p),y:n+m*Math.sin(p)})}return c}const a=[];for(let o=0;o<i;o++){const l=2*Math.PI*o/i-Math.PI/2;a.push({x:e+s*Math.cos(l),y:n+r*Math.sin(l)})}return a},xj=t=>{var e;if(t.type==="line"&&t.points&&t.points.length>=2)return t.points.map(n=>({...n}));if((t.type==="polygon"||t.type==="star")&&t.points&&t.points.length>=3)return t.points.map(n=>({...n}));if(t.type==="rect"&&t.points&&t.points.length===4)return t.points.map(n=>({...n}));
6861switch(t.type){case"rect":return[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];case"ellipse":{const n=t.x+t.width/2,s=t.y+t.height/2,r=t.width/2,i=t.height/2;return[{x:n,y:s-i},{x:n+r,y:s},{x:n,y:s+i},{x:n-r,y:s}]}case"line":return(e=t.points)!=null&&e.length?t.points.map(n=>({...n})):[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y+t.height}];case"polygon":case"star":return EIe(t);case"text":return[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];default:return[]}},WS=(t,e,n)=>{if(e===0&&n===0)return t;if(ro(t))return $ke(t,e,n);const s={...t,x:t.x+e,y:t.y+n};return t.points&&t.points.length>0&&(s.points=t.points.map(r=>({x:r.x+e,y:r.y+n}))),s},TIe=(t,e,n)=>{if(t.type==="text")return t;const r=xj(t).map((i,a)=>a===e?n:{...i});if(t.type==="rect"){const i=ax(r);return{...t,...i,points:r}}if(t.type==="ellipse"){let{x:i,y:a,width:o,height:l}=t;switch(e){case 0:{const p=a+l;a=n.y,l=Math.max(1,p-a);break}case 1:o=Math.max(1,n.x-i);break;case 2:l=Math.max(1,n.y-a);break;case 3:{const p=i+o;i=n.x,o=Math.max(1,p-i);break}}const{points:c,...h}=t;return{...h,x:i,y:a,width:o,height:l}}if(t.type==="line"){const i=ax(r);return{...t,...i,points:r}}if(t.type==="polygon"||t.type==="star"){const i=ax(r);return{...t,...i,points:r}}if(t.type==="text"){const i=ax(r);return{...t,...i}}return t},u3=(t,e)=>{if(t.type==="text")return null;const n=xj(t);if(e<0||e>=n.length)return null;const s=n.filter((r,i)=>i!==e);if(t.type==="line"){if(s.length<2)return"delete";const r=ax(s);return{...t,...r,points:s}}if(t.type==="rect"&&s.length>=3){const r=ax(s);return{...t,type:"polygon",...r,points:s,cornerRadius:void 0,cornerRadii:void 0,sides:s.length}}if((t.type==="polygon"||t.type==="star")&&s.length>=3){const r=ax(s);return{...t,...r,points:s,sides:t.type==="star"?Math.max(3,Math.ceil(s.length/2)):s.length}}if($M(t.type)){const r=Eh(t);if(ro(r)){const i=sse(r,e,0);return i?i.kind==="remove"?"delete":i.obj:null}}return s.length<2?"delete":null},AIe=(t,e,n)=>{if(t.locked)return null;let s=t;if(!ro(s))if(d5(s))s=Eh(s);else{if(s.type==="rect"||s.type==="line")return u3(s,e);if($M(s.type))s=Eh(s);else return u3(s,e)}if(ro(s)){const r=sse(s,e,n);return r?r.kind==="remove"?"delete":r.obj:null}return u3(s,e)},PH=t=>({x:t.x,y:t.y,handleIn:{x:t.x,y:t.y},handleOut:{x:t.x,y:t.y}}),$H=(t,e)=>{const n=e.x-t.x,s=e.y-t.y;return Math.hypot(n,s)<.25?{...t,handleIn:{x:t.x,y:t.y},handleOut:{x:t.x,y:t.y}}:{...t,handleIn:{x:t.x-n,y:t.y-s},handleOut:{x:t.x+n,y:t.y+s}}},DH=(t,e)=>{const n=t.rotation||0;if(!n)return e;const s=t.x+t.width/2,r=t.y+t.height/2;return vj(e,s,r,-n)},CIe=(t,e)=>{const n=t.rotation||0;if(!n)return e;const s=t.x+t.width/2,r=t.y+t.height/2;return vj(e,s,r,n)},Bb=(t,e,n)=>({x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}),pse=(t,e,n,s,r)=>{const i=1-r;return{x:i*i*i*t.x+3*i*i*r*e.x+3*i*r*r*n.x+r*r*r*s.x,y:i*i*i*t.y+3*i*i*r*e.y+3*i*r*r*n.y+r*r*r*s.y}},x5=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),kIe=(t,e,n,s,r)=>{let i=0,a=Number.POSITIVE_INFINITY;const o=(c,h,p)=>{for(let m=0;m<=p;m++){const y=c+(h-c)*m/p,v=pse(t,e,n,s,y),b=x5(v,r);b<a&&(a=b,i=y)}};o(0,1,24);let l=1/12;for(let c=0;c<3;c++){const h=Math.max(0,i-l),p=Math.min(1,i+l);o(h,p,12),l*=.5}return{t:i,distance:a}},IIe=(t,e,n)=>{let s=null;return t.forEach((r,i)=>{if(r.length<2)return;const a=e?r.length:r.length-1;for(let o=0;o<a;o++){const l=o,c=(o+1)%r.length,h=r[l],p=r[c],m={x:h.x,y:h.y},y=h.handleOut??m,v=p.handleIn??{x:p.x,y:p.y},b={x:p.x,y:p.y},S=kIe(m,y,v,b,n);(!s||S.distance<s.distance)&&(s={contourIndex:i,fromIndex:l,toIndex:c,t:S.t,distance:S.distance})}}),s},NIe=(t,e,n,s)=>{const r=Math.max(1e-4,Math.min(.9999,s)),i=t[e],a=t[n],o={x:i.x,y:i.y},l=i.handleOut??o,c=a.handleIn??{x:a.x,y:a.y},h={x:a.x,y:a.y},p=Bb(o,l,r),m=Bb(l,c,r),y=Bb(c,h,r),v=Bb(p,m,r),b=Bb(m,y,r),S=Bb(v,b,r),E=t.map(j=>({x:j.x,y:j.y,handleIn:j.handleIn?{...j.handleIn}:null,handleOut:j.handleOut?{...j.handleOut}:null}));E[e]={...E[e],handleOut:{...p}},E[n]={...E[n],handleIn:{...y}};const I={x:S.x,y:S.y,handleIn:{...v},handleOut:{...b}},M=n===0&&e===t.length-1?t.length:n;return E.splice(M,0,I),{contour:E,insertedIndex:M}},Ub=t=>{const e=t.flipX?-1:1,n=t.flipY?-1:1,s=e!==1||n!==1,r=tse(t.rotation||0);if(!r&&!s)return;const i=t.x+t.width/2,a=t.y+t.height/2,o=[];return r&&o.push(`rotate(${r} ${i} ${a})`),s&&o.push(`translate(${i} ${a}) scale(${e} ${n}) translate(${-i} ${-a})`),o.join(" ")},vj=(t,e,n,s)=>{if(!s)return t;const r=s*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=t.x-e,l=t.y-n;return{x:e+o*i-l*a,y:n+o*a+l*i}},RIe=.5,OH=(t,e)=>{const n=e.rotation||0;if(Math.abs(n)<1e-6)return t;const s=e.x+e.width/2,r=e.y+e.height/2;return t.map(i=>
6861vj(i,s,r,n))},MIe=t=>[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],PIe=16,mse=(t,e=!1)=>{var n;if(e&&ro(t)){const s=(n=t.pathContours)!=null&&n.length?t.pathContours.flatMap(r=>kE(r,t.pathClosed!==!1)):t.pathNodes?kE(t.pathNodes,t.pathClosed!==!1):[];if(s.length>0)return OH(s,t)}return OH(MIe(t),t)},d3=t=>gse(mse(t,!1)),gse=t=>{const e=fj(t);return{...e,cx:e.x+e.width/2,cy:e.y+e.height/2}},zy=t=>{const e=t.filter(K=>K.visible);if(e.length===0)return null;const n=e.length<=PIe,s=[];for(const K of e){const D=mse(K,n);for(let R=0;R<D.length;R++)s.push(D[R])}const r=gse(s),i=e[0].rotation||0,a=e.every(K=>Math.abs((K.rotation||0)-i)<RIe),o=a?i:0,l=o*Math.PI/180,c={x:Math.cos(l),y:Math.sin(l)},h={x:-Math.sin(l),y:Math.cos(l)},p={x:r.cx,y:r.cy};let m=1/0,y=-1/0,v=1/0,b=-1/0;for(const K of s){const D=K.x-p.x,R=K.y-p.y,B=D*c.x+R*c.y,G=D*h.x+R*h.y;m=Math.min(m,B),y=Math.max(y,B),v=Math.min(v,G),b=Math.max(b,G)}const S=Math.max(.5,(y-m)/2),E=Math.max(.5,(b-v)/2),I=(m+y)/2,M=(v+b)/2,j=p.x+I*c.x+M*h.x,L=p.y+I*c.y+M*h.y;return{u:c,v:h,cx:j,cy:L,halfW:S,halfH:E,rotationDeg:o,oriented:a,axisBounds:r}},LM=t=>{const{cx:e,cy:n,halfW:s,halfH:r,u:i,v:a}=t,o={x:e-s*i.x-r*a.x,y:n-s*i.y-r*a.y},l={x:e+s*i.x-r*a.x,y:n+s*i.y-r*a.y},c={x:e+s*i.x+r*a.x,y:n+s*i.y+r*a.y},h={x:e-s*i.x+r*a.x,y:n-s*i.y+r*a.y};return{nw:o,ne:l,se:c,sw:h}},$Ie=(t,e)=>{const n=t.halfW-e,s=t.halfH-e;return n<=0||s<=0?null:LM({...t,halfW:n,halfH:s})},Q2=(t,e,n)=>{const{cx:s,cy:r,halfW:i,halfH:a,u:o,v:l}=t,c=-i+e*(2*i),h=-a+n*(2*a);return{x:s+c*o.x+h*l.x,y:r+c*o.y+h*l.y}},DIe=(t,e,n)=>{const s=e.x-t.cx,r=e.y-t.cy,i=s*t.u.x+r*t.u.y,a=s*t.v.x+r*t.v.y;let o=(i+t.halfW)/(2*t.halfW),l=(a+t.halfH)/(2*t.halfH);return o=Math.max(0,Math.min(1,o)),l=Math.max(0,Math.min(1,l)),{u:o,v:l}},nd=(t,e)=>t.x*e.x+t.y*e.y,OIe=(t,e,n,s,r)=>{const i=LM(e),{u:a,v:o}=e;return(()=>{if(t==="se"){const c={x:n.x-i.nw.x,y:n.y-i.nw.y};let h=nd(c,a)/2,p=nd(c,o)/2;if(r){const v=e.halfW>1e-9?h/e.halfW:1,b=e.halfH>1e-9?p/e.halfH:1,S=Math.max(s/e.halfW,s/e.halfH,Math.min(v,b));h=e.halfW*S,p=e.halfH*S}h=Math.max(s,h),p=Math.max(s,p);const m=i.nw.x+h*a.x+p*o.x,y=i.nw.y+h*a.y+p*o.y;return{cx:m,cy:y,halfW:h,halfH:p}}if(t==="nw"){const c={x:i.se.x-n.x,y:i.se.y-n.y};let h=nd(c,a)/2,p=nd(c,o)/2;if(r){const v=e.halfW>1e-9?h/e.halfW:1,b=e.halfH>1e-9?p/e.halfH:1,S=Math.max(s/e.halfW,s/e.halfH,Math.min(v,b));h=e.halfW*S,p=e.halfH*S}h=Math.max(s,h),p=Math.max(s,p);const m=i.se.x-h*a.x-p*o.x,y=i.se.y-h*a.y-p*o.y;return{cx:m,cy:y,halfW:h,halfH:p}}if(t==="ne"){const c={x:n.x-i.sw.x,y:n.y-i.sw.y};let h=nd(c,a)/2,p=Math.max(s,-nd(c,o)/2);if(h=Math.max(s,h),r){const v=e.halfW>1e-9?h/e.halfW:1,b=e.halfH>1e-9?p/e.halfH:1,S=Math.max(s/e.halfW,s/e.halfH,Math.min(v,b));h=e.halfW*S,p=e.halfH*S}const m=i.sw.x+h*a.x-p*o.x,y=i.sw.y+h*a.y-p*o.y;return{cx:m,cy:y,halfW:h,halfH:p}}if(t==="sw"){const c={x:n.x-i.ne.x,y:n.y-i.ne.y};let h=Math.max(s,-nd(c,a)/2),p=nd(c,o)/2;if(p=Math.max(s,p),r){const v=e.halfW>1e-9?h/e.halfW:1,b=e.halfH>1e-9?p/e.halfH:1,S=Math.max(s/e.halfW,s/e.halfH,Math.min(v,b));h=e.halfW*S,p=e.halfH*S}const m=i.ne.x-h*a.x+p*o.x,y=i.ne.y-h*a.y+p*o.y;return{cx:m,cy:y,halfW:h,halfH:p}}if(t==="e"){const c={x:(i.nw.x+i.sw.x)/2,y:(i.nw.y+i.sw.y)/2},h={x:n.x-c.x,y:n.y-c.y};let p=Math.max(s,nd(h,a)/2),m=e.halfH;if(r){const y=Math.max(s/e.halfW,s/e.halfH,p/e.halfW);p=e.halfW*y,m=e.halfH*y}return{cx:c.x+p*a.x,cy:c.y+p*a.y,halfW:p,halfH:m}}if(t==="w"){const c={x:(i.ne.x+i.se.x)/2,y:(i.ne.y+i.se.y)/2},h={x:c.x-n.x,y:c.y-n.y};let p=Math.max(s,nd(h,a)/2),m=e.halfH;if(r){const y=Math.max(s/e.halfW,s/e.halfH,p/e.halfW);p=e.halfW*y,m=e.halfH*y}return{cx:c.x-p*a.x,cy:c.y-p*a.y,halfW:p,halfH:m}}if(t==="s"){const c={x:(i.nw.x+i.ne.x)/2,y:(i.nw.y+i.ne.y)/2},h={x:n.x-c.x,y:n.y-c.y};let p=Math.max(s,nd(h,o)/2),m=e.halfW;if(r){const y=Math.max(s/e.halfW,s/e.halfH,p/e.halfH);m=e.halfW*y,p=e.halfH*y}return{cx:c.x+p*o.x,cy:c.y+p*o.y,halfW:m,halfH:p}}if(t==="n"){const c={x:(i.sw.x+i.se.x)/2,y:(i.sw.y+i.se.y)/2},h={x:c.x-n.x,y:c.y-n.y};let p=Math.max(s,nd(h,o)/2),m=e.halfW;if(r){const y=Math.max(s/e.halfW,s/e.halfH,p/e.halfH);m=e.halfW*y,p=e.halfH*y}return{cx:c.x-p*o.x,cy:c.y-p*o.y,halfW:m,halfH:p}}return null})()},Wb=t=>{const e=zy(t);return e?e.axisBounds:null},LIe=(t,e,n,s)=>{var K,D;const{u:r,v:i}=e,a=t.type==="text"&&s&&y5.has(s)?SIe(e,n,s):n,o=t.x+t.width/2,l=t.y+t.height/2,c=o-e.cx,h=l-e.cy,p=c*r.x+h*r.y,m=c*i.x+h*i.y,y=e.halfW>1e-9?p/e.halfW:0,v=e.halfH>1e-9?m/e.halfH:0,b=a.cx+y*a.halfW*r.x+v*a.halfH*i.x,S=a.cy+y*a.halfW*r.y+v*a.halfH*i.y,E=b-t.width/2,I=S-t.height/2,M=e.halfW>1e-9?a.halfW/e.halfW:1,j=e.halfH>1e-9?a.halfH/e.halfH:1;let L={...t,x:E,y:I,width:Math.max(1,t.width*M),height:Math.max(1,t.height*j),...t.type==="text"?{autoFit:!1}:{}};return t.type==="text"&&s&&y5.has(s)?L=fse(mR(L,M,j)):t.type==="text"&&(L=mR(L,M,j)),ro(t)&&((K=t.pathNodes)!=null&&K.length)?L=pj(L,mj(t),E,I,L.width,L.height):(D=t.points)!=null&&D.length&&(L.points=t.points.map(R=>({x:E+(R.x-t.x)*M,y:I+(R.y-t.y)*j}))),L},jIe=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,Uy=4,BIe=12,UIe=700,FIe=3e3,VIe=6,gR=(t,e,n)=>({left:t.x+e,right:t.x+t.width+e,top:t.y+n,bottom:t.y+t.height+n,cx:t.cx+e,cy:t.cy+n}),LH=(t,e,n)=>{let s=1/0,r=0;for(const i of t)for(const a of e){const o=a-i,l=Math.abs(o);l>n||l<s-1e-9&&(s=l,r=o)}return r},zIe=(t,e)=>
6861[0,e,e/2,...t.flatMap(n=>[n.x,n.x+n.width,n.cx])],GIe=(t,e)=>[0,e,e/2,...t.flatMap(n=>[n.y,n.y+n.height,n.cy])],HIe=(t,e,n)=>{var l,c;let s=t;n.rotation!==void 0&&(s={...s,rotation:Sh(n.rotation)});const r=n.x!==void 0||n.y!==void 0,i=n.width!==void 0||n.height!==void 0;if(r||i){const h=n.x??(i?e.x:t.x),p=n.y??(i?e.y:t.y),m=Math.max(1,n.width??(i?e.width:t.width)),y=Math.max(1,n.height??(i?e.height:t.height));if(i&&e.type==="rect"&&!xv(e)){const v=e.width?m/e.width:1,b=e.height?y/e.height:1,S=yj(e,m,y,v,b);s={...s,cornerRadius:zg(S)?S.tl:0,cornerRadii:S}}if(ro(e)&&((l=e.pathNodes)!=null&&l.length)){const v=s.rotation??0;s=pj(t,mj(e),h,p,m,y),s={...s,rotation:v}}else if(r&&!i)s=WS(t,h-t.x,p-t.y);else{const v=e.width?m/e.width:1,b=e.height?y/e.height:1;s={...t,x:h,y:p,width:m,height:y},(c=e.points)!=null&&c.length&&(s.points=e.points.map(S=>({x:h+(S.x-e.x)*v,y:p+(S.y-e.y)*b})))}}if(n.cornerRadius!==void 0&&s.type==="rect"&&!xv(s)){const h=A0(n.cornerRadius,s.width,s.height),p=q0(s.width,s.height,h);s={...s,cornerRadius:h,cornerRadii:p}}if(n.cornerRadii!==void 0&&s.type==="rect"&&!xv(s)){const h=q0(s.width,s.height,0,n.cornerRadii);s={...s,cornerRadius:zg(h)?h.tl:0,cornerRadii:h}}const a=new Set(["rotation","x","y","width","height","cornerRadius","cornerRadii"]),o=Object.fromEntries(Object.entries(n).filter(([h])=>!a.has(h)));return{...s,...o}},qIe=(t,e)=>{var h,p;const n=Wb(t);if(!n)return new Map;const s=e.x??n.x,r=e.y??n.y,i=Math.max(1,e.width??n.width),a=Math.max(1,e.height??n.height),o=n.width?i/n.width:1,l=n.height?a/n.height:1,c=new Map;for(const m of t){const y=s+(m.x-n.x)*o,v=r+(m.y-n.y)*l,b=Math.max(1,m.width*o),S=Math.max(1,m.height*l);if(ro(m)&&((h=m.pathNodes)!=null&&h.length)){const E=pj(m,mj(m),y,v,b,S);c.set(m.id,{...E,rotation:m.rotation??0})}else{let E={...m,x:y,y:v,width:b,height:S};if((p=m.points)!=null&&p.length&&(E.points=m.points.map(I=>({x:y+(I.x-m.x)*o,y:v+(I.y-m.y)*l}))),m.type==="rect"&&!xv(m)){const I=yj(m,b,S,o,l);E.cornerRadii=I,E.cornerRadius=zg(I)?I.tl:0}c.set(m.id,E)}}return c},v5=t=>{const e=Math.round(t*10)/10;return Number.isInteger(e)?String(e):e.toFixed(1)},jH=t=>{const e=Math.max(0,t);return e<.05?"0":v5(e)},WIe=(t,e)=>{const n=Math.max(t.y,e.y),s=Math.min(t.y+t.height,e.y+e.height);return s>n?{y1:n,y2:s}:null},KIe=(t,e)=>{const n=Math.max(t.x,e.x),s=Math.min(t.x+t.width,e.x+e.width);return s>n?{x1:n,x2:s}:null},Fb=160,YIe=(t,e)=>({x1:Math.min(t.x,e.x),x2:Math.max(t.x+t.width,e.x+e.width)}),XIe=(t,e)=>({y1:Math.min(t.y,e.y),y2:Math.max(t.y+t.height,e.y+e.height)}),iI=(t,...e)=>`${t}:${e.map(n=>n.toFixed(2)).join(":")}`,JIe=(t,e,n,s,r,i)=>{const a={vertical:[],horizontal:[],spacingH:[],spacingV:[]},o=new Set,l=new Set,c=new Set,h=new Set,p=gR(t,0,0),m=gR(e,0,0),y=(D,R,B,G,X,H)=>{const Y=iI("v",D,R,B,G==="center"?1:0);o.has(Y)||B<=R||(o.add(Y),a.vertical.push({x:D,y1:R,y2:B,kind:G,labelValue:X,tickYs:H}))},v=(D,R,B,G,X,H)=>{const Y=iI("h",D,R,B,G==="center"?1:0);l.has(Y)||B<=R||(l.add(Y),a.horizontal.push({y:D,x1:R,x2:B,kind:G,labelValue:X,tickXs:H}))},b=(D,R)=>Math.abs(D-R)<=i,S=(D,R,B,G)=>{if(G>Fb)return;let X=Math.min(D,R),H=Math.max(D,R);H-X<1&&(X-=.5,H+=.5);const Y=iI("sh",X,H,B);c.has(Y)||(c.add(Y),a.spacingH.push({x1:X,x2:H,y:B,distance:G}))},E=(D,R,B,G)=>{if(G>Fb)return;let X=Math.min(D,R),H=Math.max(D,R);H-X<1&&(X-=.5,H+=.5);const Y=iI("sv",X,H,B);h.has(Y)||(h.add(Y),a.spacingV.push({y1:X,y2:H,x:B,distance:G}))},I=D=>{const R=WIe(t,D);if(R){const G=D.x+D.width,X=D.x,H=m.left-G,Y=X-m.right,F=R.y1+(R.y2-R.y1)*.2,we=R.y1+(R.y2-R.y1)*.8;H>=0&&(b(m.left,G)||b(p.left,G)||H<=Fb)&&(S(G,Math.max(G,m.left),F,H),S(G,Math.max(G,m.left),we,H)),Y>=0&&(b(m.right,X)||b(p.right,X)||Y<=Fb)&&(S(Math.min(m.right,X),X,F,Y),S(Math.min(m.right,X),X,we,Y))}const B=KIe(t,D);if(B){const G=D.y+D.height,X=D.y,H=m.top-G,Y=X-m.bottom,F=B.x1+(B.x2-B.x1)*.2,we=B.x1+(B.x2-B.x1)*.8;H>=0&&(b(m.top,G)||b(p.top,G)||H<=Fb)&&(E(G,Math.max(G,m.top),F,H),E(G,Math.max(G,m.top),we,H)),Y>=0&&(b(m.bottom,X)||b(p.bottom,X)||Y<=Fb)&&(E(Math.min(m.bottom,X),X,F,Y),E(Math.min(m.bottom,X),X,we,Y))}},M=[{val:p.left,rawVal:m.left,kind:"edge"},{val:p.right,rawVal:m.right,kind:"edge"},{val:p.cx,rawVal:m.cx,kind:"center"}],j=[{val:p.top,rawVal:m.top,kind:"edge"},{val:p.bottom,rawVal:m.bottom,kind:"edge"},{val:p.cy,rawVal:m.cy,kind:"center"}];for(const D of n){I(D);const R=[{val:D.x,kind:"edge"},{val:D.x+D.width,kind:"edge"},{val:D.cx,kind:"center"}],B=[{val:D.y,kind:"edge"},{val:D.y+D.height,kind:"edge"},{val:D.cy,kind:"center"}],G=YIe(t,D),X=XIe(t,D);for(const H of M)for(const Y of R){if(!b(H.rawVal,Y.val)&&!b(H.val,Y.val))continue;const F=H.kind==="center"&&Y.kind==="center"?"center":"edge";y(Y.val,X.y1,X.y2,F,F==="edge"?Y.val:void 0,F==="edge"?[D.y,D.y+D.height]:void 0)}for(const H of j)for(const Y of B){if(!b(H.rawVal,Y.val)&&!b(H.val,Y.val))continue;const F=H.kind==="center"&&Y.kind==="center"?"center":"edge";v(Y.val,G.x1,G.x2,F,F==="edge"?Y.val:void 0,F==="edge"?[D.x,D.x+D.width]:void 0)}}const L=[{val:0,kind:"edge"},{val:s/2,kind:"center"},{val:s,kind:"edge"}],K=[{val:0,kind:"edge"},{val:r/2,kind:"center"},{val:r,kind:"edge"}];for(const D of M)for(const R of L)!b(D.rawVal,R.val)&&!b(D.val,R.val)||y(R.val,0,r,R.kind,R.kind==="edge"?R.val:void 0);for(const D of j)for(const R of K)!b(D.rawVal,R.val)&&!b(D.val,R.val)||v(R.val,0,s,R.kind,R.kind==="edge"?R.val:void 0);return a},h3=5,aI=t=>t.map(e=>
6861id(e)),QIe=.1,ZIe=5,Dg=1.25,eNe=1.012,tNe=6,nNe=7,sNe=10,rNe=28,iNe=46,BH=1.5,f3=6,aNe=9,UH=7,oNe=11,FH=2,lNe=5,cNe=1.5,uNe=1.5,p3=6,dNe=5,VH=1.6,hNe=4,fNe=t=>Math.min(ZIe,Math.max(QIe,t)),m3=(t,e)=>{const n=e==="x"?t.deltaX!==0?t.deltaX:t.deltaY:t.deltaY!==0?t.deltaY:t.deltaX;return t.deltaMode===1?n*16:t.deltaMode===2?n*window.innerHeight:n},zH=t=>{if(t.length===0)return[];const e=[];let n=t[0].length;for(let s=1;s<t.length;s++)t[s].length<n&&(n=t[s].length);for(let s=0;s<n;s++){const r=t[0][s];if(t.every(i=>i[s]===r))e.push(r);else break}return e},pNe=t=>{const e=new Map;return t.forEach(n=>{(n.groupIds||[]).forEach(s=>{e.has(s)||e.set(s,Xl())})}),e},g3=(t,e=20,n=20)=>{const s=pNe(t);return t.map(r=>{var o;const i=id(r),a=(o=r.groupIds)==null?void 0:o.map(l=>s.get(l)||l);return WS({...i,id:Xl(),name:`${r.name} copy`,groupIds:a&&a.length>0?a:void 0},e,n)})},mNe=()=>{const{remaining:t,showRemaining:e,tryConsumeExport:n}=MM("vector"),{isOpen:s,reason:r,openFromGateError:i,closePricingInsist:a}=PA(),[o,l]=q.useState(1920),[c,h]=q.useState(1080),[p,m]=q.useState(null),[y,v]=q.useState(null),[b,S]=q.useState([]),[E,I]=q.useState([]),[M,j]=q.useState("select"),[L,K]=q.useState(!1),[D,R]=q.useState(!1),B=q.useRef([]),G=q.useRef([]),X=q.useRef(!1),H=q.useRef(b),Y=q.useRef(!1),F=q.useRef(new Map),we=q.useRef(null);q.useEffect(()=>{H.current=b},[b]);const[me,xe]=q.useState(!1),Le=q.useRef(!1),ve=q.useRef(null),ce=q.useRef(null),ie=q.useRef(null),de=q.useRef(()=>{}),Re=q.useRef(!1),Se=q.useRef(0),[De,gt]=q.useState(null),[yt,xt]=q.useState(null),[Nt,wt]=q.useState(null),[zt,_n]=q.useState(null),[Zt,J]=q.useState(null),[We,Ie]=q.useState("#4F46E5"),[ge,he]=q.useState(100),[Ae,et]=q.useState("#1E1B4B"),[nt,He]=q.useState(100),[ft,Mt]=q.useState(2),[pt,Oe]=q.useState(!1),[hn,Yt]=q.useState(!1),[Qe,tn]=q.useState("solid"),[je,Ue]=q.useState("solid"),[bt,ht]=q.useState(()=>kH("#4F46E5")),[Dt,Ut]=q.useState(()=>kH("#1E1B4B")),[Lt,Wt]=q.useState(null),[fn,Jt]=q.useState(!1),[Kn,nn]=q.useState(!1),[Wn,ln]=q.useState(!1),[ns,Js]=q.useState(6),[ur,zs]=q.useState(!1),[fs,ps]=q.useState(!1),[ms,Me]=q.useState(!1),[lt,jt]=q.useState("layers"),[Qt,Sn]=q.useState(null),[yn,Ft]=q.useState(!1),[sn,rn]=q.useState(null),[bs,gs]=q.useState(null),us=q.useRef(null),Hn=FCe("(max-width: 1023px)"),[ls,Ps]=q.useState(null),[rr,ws]=q.useState(!1),[$s,ys]=q.useState(!1),[Pn,ir]=q.useState({x:0,y:0}),[ot,ar]=q.useState(1),[$n,kn]=q.useState({x:0,y:0}),Nn=x=>x/Math.max(ot,1e-6),[Bn,er]=q.useState(!1),[oi,or]=q.useState({x:0,y:0}),[ue,ke]=q.useState(!1),[pe,Pe]=q.useState(""),[$e,Ne]=q.useState(null),[tt,mt]=q.useState(null),Ct=q.useRef(null),_t=q.useRef(null),[kt,Xt]=q.useState(null),qn=q.useRef(kt);q.useEffect(()=>{qn.current=kt},[kt]);const[Xn,an]=q.useState(!1),[Jn,Qn]=q.useState(null),[Gs,Cr]=q.useState(null),[Qs,ti]=q.useState(!1),[gi,yr]=q.useState(null),[_a,Va]=q.useState(null),Ls=q.useRef(null),li=q.useRef(null),ni=q.useRef([]),pn=q.useRef("none"),ji=q.useRef(null),[za,Ai]=q.useState(null),Ye=q.useRef(null),vt=q.useRef(null),ct=q.useRef(null),Kt=q.useRef(!1),ds=q.useRef(null),[Mr,Ds]=q.useState(null),[Hs,un]=q.useState(null),[Yn,As]=q.useState(()=>new Set),[Pr,kr]=q.useState(!1),Yi=q.useRef(!1),[Ga,wl]=q.useState(!1),sa=q.useRef(null),ra=q.useRef(null),Bi=q.useRef(null),_l=q.useRef(null),Pu=q.useRef(null),[Uc,ic]=q.useState(!1),Cd=q.useRef(null),ci=q.useRef(null),xr=b.filter(x=>E.includes(x.id)),gn=xr.length===1?xr[0]:null,Sa=q.useCallback((x=!1)=>ms||x,[ms]),yi=zy(xr),uo=(yi==null?void 0:yi.axisBounds)??null,Xo=tt??{u:.5,v:.5},Ha=(x,A)=>{if(x.length!==A.length)return!1;const $=new Set(x);return A.every(P=>$.has(P))},kd=x=>{var A;return((A=x.groupIds)==null?void 0:A[0])??null},Fc=x=>b.filter(A=>kd(A)===x).map(A=>A.id),Id=x=>b.filter(A=>(A.groupIds||[]).includes(x)).map(A=>A.id),ia=x=>{const A=new Set(x),$=new Set(x);return b.forEach(P=>{if(!A.has(P.id))return;const z=kd(P);z&&Fc(z).forEach(Q=>$.add(Q))}),Array.from($)},qr=(()=>{if(xr.length===0)return null;const x=xr.map(z=>z.groupIds||[]);if(!x.some(z=>z.length>0))return null;const A=zH(x);if(A.length===0)return null;const $=A[A.length-1],P=b.filter(z=>(z.groupIds||[]).includes($)).map(z=>z.id);return P.length===0?null:Ha(E,P)?$:null})(),ac=xr.filter(x=>!x.locked).length>=2&&!qr;q.useEffect(()=>{sa.current=Nt},[Nt]),q.useEffect(()=>{Ct.current=tt},[tt]),q.useEffect(()=>{mt(null)},[E.join("|")]);const Sl=b.filter(x=>E.includes(x.id)&&rse(x)),Io=q.useCallback(()=>{K(B.current.length>0),R(G.current.length>0)},[]),C=q.useCallback(()=>
6861{if(X.current)return;const x=aI(H.current);B.current=[...B.current,x].slice(-h3),G.current=[],Io()},[Io]),W=q.useCallback(x=>{X.current=!0,S(aI(x)),I(A=>A.filter($=>x.some(P=>P.id===$))),Ps(A=>A&&x.some($=>$.id===A)?A:null),X.current=!1,Io()},[Io]),ne=q.useCallback(()=>{if(B.current.length===0)return;G.current=[aI(H.current),...G.current].slice(0,h3);const x=B.current[B.current.length-1];B.current=B.current.slice(0,-1),W(x)},[W]),ye=q.useCallback(()=>{if(G.current.length===0)return;B.current=[...B.current,aI(H.current)].slice(-h3);const x=G.current[0];G.current=G.current.slice(1),W(x)},[W]),Xe=xr.filter(x=>!x.locked),rt=Xe.length>0,Vt=Xe.length>1,Zn=Xe.filter(x=>x.type==="text"&&(x.text??"").trim().length>0),dr=Zn.length>0,lr=q.useCallback(()=>{Y.current||(Y.current=!0,C());const x=H.current.filter(A=>E.includes(A.id)&&!A.locked);for(const A of x)F.current.has(A.id)||F.current.set(A.id,id(A));if(we.current===null&&x.length>0){const A=x.map(P=>Sh(P.rotation||0)),$=A.every(P=>Math.abs(P-A[0])<.01);we.current=$?A[0]:0}},[C,E]);q.useEffect(()=>{F.current=new Map,we.current=null},[E.join(",")]),q.useEffect(()=>{const x=()=>{Y.current=!1,F.current=new Map,we.current=null};return window.addEventListener("mouseup",x),()=>window.removeEventListener("mouseup",x)},[]),q.useEffect(()=>{gn&&(By(gn)&&(gn.fill==="none"?Oe(!0):(Ie(gn.fill),he(Jp(gn,"fill")),Oe(!1)),gn.fillMode==="gradient"&&gn.fillGradient?(tn("gradient"),ht(Qa(BI(gn.fillGradient)))):tn("solid")),$g(gn)?(gn.stroke==="none"?Yt(!0):(et(gn.stroke),He(Jp(gn,"stroke")),Yt(!1)),gn.strokeMode==="gradient"&&gn.strokeGradient?(Ue("gradient"),Ut(Qa(BI(gn.strokeGradient)))):Ue("solid")):gn.type==="text"&&gn.textOutline&&gn.stroke!=="none"&&(et(gn.stroke),He(Jp(gn,"stroke")),Yt(!1),gn.strokeMode==="gradient"&&gn.strokeGradient?(Ue("gradient"),Ut(Qa(BI(gn.strokeGradient)))):Ue("solid")))},[gn==null?void 0:gn.id]),q.useEffect(()=>{M!=="direct"||E.length===0||S(x=>{let A=!1;const $=x.map(P=>{if(!E.includes(P.id)||!$M(P.type)||P.type==="rect")return P;const z=Eh(P);return z!==P&&(A=!0),z});return A?$:x})},[M,E.join(",")]),q.useEffect(()=>{if(M!=="direct"){Xt(null);return}kt&&(E.includes(kt.objId)||Xt(null))},[M,E,kt]);const wr=x=>{Ie(x),Oe(!1);const A=Qe==="gradient"?Ji({...bt,stops:bt.stops.map(($,P)=>P===0?{...$,color:x}:$)}):null;if(Qe==="gradient"&&ht(A),E.length>0){const $=Qa(A??Ji(bt));C(),S(P=>P.map(z=>E.includes(z.id)&&!z.locked&&By(z)?{...z,fill:x,fillMode:Qe,fillGradient:Qe==="gradient"?$:void 0,fillOpacity:ge}:z))}},aa=x=>{const A=dp(x);he(A),E.length>0&&(C(),S($=>$.map(P=>E.includes(P.id)&&!P.locked&&By(P)?{...P,fillOpacity:A}:P)))},qa=x=>{et(x),Yt(!1);const A=je==="gradient"?Ji({...Dt,stops:Dt.stops.map(($,P)=>P===0?{...$,color:x}:$)}):null;if(je==="gradient"&&Ut(A),E.length>0){const $=Qa(A??Ji(Dt));C(),S(P=>P.map(z=>!E.includes(z.id)||z.locked?z:$g(z)||z.type==="text"?{...z,stroke:x,strokeMode:je,strokeGradient:je==="gradient"?$:void 0,strokeOpacity:nt}:z))}},No=x=>{const A=dp(x);He(A),E.length>0&&(C(),S($=>$.map(P=>!E.includes(P.id)||P.locked?P:$g(P)||P.type==="text"?{...P,strokeOpacity:A}:P)))},fa=()=>{Oe(!0),E.length>0&&(C(),S(x=>x.map(A=>E.includes(A.id)&&!A.locked&&By(A)?{...A,fill:"none",fillMode:"solid",fillGradient:void 0}:A)))},pa=()=>{Yt(!0),E.length>0&&(C(),S(x=>x.map(A=>!E.includes(A.id)||A.locked?A:A.type==="text"?{...A,textOutline:!1,stroke:"none",strokeMode:"solid",strokeGradient:void 0}:$g(A)?{...A,stroke:"none",strokeMode:"solid",strokeGradient:void 0}:A)))},$u=(x,A)=>{if(E.length===0)return;const $=Qa(Ji(A));C(),S(P=>P.map(z=>!E.includes(z.id)||z.locked?z:x==="fill"?By(z)?{...z,fillMode:"gradient",fill:z.fill==="none"?We:z.fill,fillGradient:$}:z:$g(z)||z.type==="text"?{...z,strokeMode:"gradient",stroke:z.stroke==="none"?Ae:z.stroke,strokeGradient:$}:z))},ef=(x,A)=>{if(x==="fill"){if(tn(A),A==="gradient"){if(Oe(!1),E.length>0){const $=Qa(Ji(bt));C(),S(P=>P.map(z=>!E.includes(z.id)||z.locked||!By(z)?z:{...z,fillMode:"gradient",fill:z.fill==="none"?We:z.fill,fillGradient:$}))}}else E.length>0&&(C(),S($=>$.map(P=>E.includes(P.id)&&!P.locked&&By(P)?{...P,fillMode:"solid",fillGradient:void 0}:P)));return}if(Ue(A),A==="gradient"){if(Yt(!1),E.length>0){const $=Qa(Ji(Dt));C(),S(P=>P.map(z=>!E.includes(z.id)||z.locked||!($g(z)||z.type==="text")?z:{...z,strokeMode:"gradient",stroke:z.stroke==="none"?Ae:z.stroke,strokeGradient:$}))}}else E.length>0&&(C(),S($=>$.map(P=>E.includes(P.id)&&!P.locked&&($g(P)||P.type==="text")?{...P,strokeMode:"solid",strokeGradient:void 0}:P)))},oc=x=>{const A=Ji(x(bt));ht(A),$u("fill",A)},Du=x=>{const A=Ji(x(Dt));
6861Ut(A),$u("stroke",A)},ho=q.useCallback((x=!0)=>{ls&&(S(A=>{const $=A.find(P=>P.id===ls);return x&&($==null?void 0:$.type)==="text"&&!($.text||"").trim()?A.filter(P=>P.id!==ls):A}),Ps(null))},[ls]),Vc=q.useCallback(()=>{Se.current=performance.now()+UIe,Re.current=!0},[]),Ou=q.useCallback(()=>{window.setTimeout(()=>{var x;if(performance.now()<Se.current){(x=ci.current)==null||x.focus();return}document.activeElement!==ci.current&&ho(!0)},0)},[ho]),Nd=x=>{C(),Vc(),Ps(x),I([x])},Rd=q.useCallback(x=>{if(ci.current=x,x&&Re.current){x.focus();const A=x.value.length;x.setSelectionRange(A,A),Re.current=!1}},[]);q.useLayoutEffect(()=>{if(!ls||!Re.current||!ci.current)return;ci.current.focus();const x=ci.current.value.length;ci.current.setSelectionRange(x,x),Re.current=!1},[ls]);const js=ls?b.find(x=>x.id===ls&&x.type==="text")??null:null;q.useLayoutEffect(()=>{if(!js)return;const x=NH(js);x.width===js.width&&x.height===js.height||S(A=>A.map($=>$.id===js.id&&$.type==="text"?x:$))},[js==null?void 0:js.id,js==null?void 0:js.autoFit,js==null?void 0:js.text,js==null?void 0:js.fontSize,js==null?void 0:js.fontFamily,js==null?void 0:js.fontWeight,js==null?void 0:js.fontStyle,js==null?void 0:js.textDecoration,js==null?void 0:js.textAlign,js==null?void 0:js.width]);const lc=q.useCallback(x=>{const A=sa.current;if(!A||A.nodes.length<2){wt(null),_n(null);return}const $=A.nodes.map(Q=>({x:Q.x,y:Q.y,handleIn:Q.handleIn?{...Q.handleIn}:null,handleOut:Q.handleOut?{...Q.handleOut}:null})),P=Su($),z={id:Xl(),type:"path",x:P.x,y:P.y,width:P.width,height:P.height,fill:pt?"none":We,fillMode:pt?"solid":Qe,fillGradient:!pt&&Qe==="gradient"?Qa(Ji(bt)):void 0,fillOpacity:pt?void 0:ge,stroke:hn?"none":Ae,strokeMode:hn?"solid":je,strokeGradient:!hn&&je==="gradient"?Qa(Ji(Dt)):void 0,strokeOpacity:hn?void 0:nt,strokeWidth:ft,opacity:1,rotation:0,name:`${x?"Shape":"Path"} ${H.current.length+1}`,visible:!0,locked:!1,pathNodes:$,pathClosed:x,autoFit:void 0};C(),S(Q=>[...Q,z]),I([z.id]),Xt(null),wt(null),_n(null),J(null),ra.current=null},[We,ge,pt,hn,Qe,bt,je,Dt,C,Ae,nt,ft]),Md=q.useCallback(()=>{wt(null),_n(null),J(null),ra.current=null,pn.current==="pen-anchor"&&(pn.current="none")},[]),El=q.useCallback((x,A)=>{var en,Ln;const $=H.current.find(Dn=>Dn.id===x);if(!$||$.locked||$.type==="text")return null;const P=ro($)?id($):Eh($);if(!((en=P.pathNodes)!=null&&en.length))return null;const z=(Ln=P.pathContours)!=null&&Ln.length?P.pathContours.map(Dn=>Dn.map(Os=>({x:Os.x,y:Os.y,handleIn:Os.handleIn?{...Os.handleIn}:null,handleOut:Os.handleOut?{...Os.handleOut}:null}))):[P.pathNodes.map(Dn=>({x:Dn.x,y:Dn.y,handleIn:Dn.handleIn?{...Dn.handleIn}:null,handleOut:Dn.handleOut?{...Dn.handleOut}:null}))],Q=DH(P,A),ee=IIe(z,P.pathClosed!==!1,Q),re=oIe/Math.max(ot,1e-6);if(!ee||ee.distance>re)return null;const be=z[ee.contourIndex],Ee=be[ee.fromIndex],Te=be[ee.toIndex],Be={x:Ee.x,y:Ee.
6861y},Ze=Ee.handleOut??Be,Fe=Te.handleIn??{x:Te.x,y:Te.y},Gt={x:Te.x,y:Te.y},Tt=pse(Be,Ze,Fe,Gt,ee.t),Bt=CIe(P,Tt);return{objId:x,contourIndex:ee.contourIndex,fromIndex:ee.fromIndex,toIndex:ee.toIndex,t:ee.t,point:Bt}},[ot]),Lu=q.useCallback((x,A)=>{var Ze,Fe,Gt;const $=H.current.find(Tt=>Tt.id===x);if(!$||$.locked||$.type==="text")return null;const P=ro($)?id($):Eh($);if(!((Ze=P.pathNodes)!=null&&Ze.length))return null;const z=El(x,A);if(!z)return null;const Q=(Fe=P.pathContours)!=null&&Fe.length?P.pathContours.map(Tt=>Tt.map(Bt=>({x:Bt.x,y:Bt.y,handleIn:Bt.handleIn?{...Bt.handleIn}:null,handleOut:Bt.handleOut?{...Bt.handleOut}:null}))):[P.pathNodes.map(Tt=>({x:Tt.x,y:Tt.y,handleIn:Tt.handleIn?{...Tt.handleIn}:null,handleOut:Tt.handleOut?{...Tt.handleOut}:null}))],ee=NIe(Q[z.contourIndex],z.fromIndex,z.toIndex,z.t),re=Q.map((Tt,Bt)=>Bt===z.contourIndex?ee.contour:Tt),be=re[0],Ee=(Gt=P.pathContours)!=null&&Gt.length?re:void 0,Te=Ee!=null&&Ee.length?Tm(Ee):Su(be),Be={...P,...Te,pathNodes:be,pathContours:Ee,pathClosed:P.pathClosed!==!1,rotation:P.rotation??0};return C(),S(Tt=>Tt.map(Bt=>Bt.id===x?Be:Bt)),I([x]),J(null),Xt({objId:x,nodeIndex:ee.insertedIndex,contourIndex:z.contourIndex}),{objId:x,nodeIndex:ee.insertedIndex,contourIndex:z.contourIndex}},[El,C]),Ir=q.useCallback(x=>{if(ls&&x!=="type"&&ho(!0),x!=="pen"){const A=sa.current;A&&(A.nodes.length>=2?lc(!1):wt(null)),_n(null),J(null),ra.current=null}j(x),Jt(!1),nn(!1),Wt(null),x!=="direct"&&Xt(null),x==="direct"&&I(A=>A.filter($=>{var P;return((P=b.find(z=>z.id===$))==null?void 0:P.type)!=="text"}))},[lc,ls,ho,b]),Wa=(x,A,$,P,z=!1)=>({id:Xl(),type:"text",x,y:A,width:$,height:P,fill:pt?"none":We,fillMode:pt?"solid":Qe,fillGradient:!pt&&Qe==="gradient"?Qa(Ji(bt)):void 0,fillOpacity:pt?void 0:ge,stroke:"none",strokeMode:"solid",strokeWidth:0,opacity:1,rotation:0,text:"",fontSize:Bh,fontFamily:"Inter",fontWeight:"normal",fontStyle:"normal",textDecoration:"none",textAlign:"left",name:`Text ${b.length+1}`,visible:!0,locked:!1,autoFit:z}),Pd=x=>({left:$n.x+x.x*ot,top:$n.y+x.y*ot}),cc=(x,A,$,P,z=0)=>{x.stopPropagation(),x.preventDefault();const Q=b.find(ee=>ee.id===A);!Q||Q.locked||(C(),I([A]),Xt({objId:A,nodeIndex:$,contourIndex:z}),S(ee=>ee.map(re=>re.id===A&&re.type!=="rect"?Eh(re):re)),_t.current={objId:A,nodeIndex:$,kind:P,contourIndex:z},pn.current="anchor",Wr(x))},fo=q.useCallback(x=>{const A=Bi.current;if(!A)return{x:0,y:0};const $=A.getBoundingClientRect();return{x:(x.clientX-$.left-$n.x)/ot,y:(x.clientY-$.top-$n.y)/ot}},[ot,$n]),$d=q.useCallback((x,A)=>{const $=Math.min(x.x,A.x),P=Math.min(x.y,A.y),z=Math.abs(A.x-x.x),Q=Math.abs(A.y-x.y);if(z<2&&Q<2)return null;const ee={id:Xl(),x:$,y:P,width:z,height:Q,fill:pt?"none":We,fillMode:pt?"solid":Qe,fillGradient:!pt&&Qe==="gradient"?Qa(Ji(bt)):void 0,fillOpacity:pt?void 0:ge,stroke:hn?"none":Ae,strokeMode:hn?"solid":je,strokeGradient:!hn&&je==="gradient"?Qa(Ji(Dt)):void 0,strokeOpacity:hn?void 0:nt,strokeWidth:ft,opacity:1,rotation:0,visible:!0,locked:!1};switch(M){case"rect":return{...ee,type:"rect",name:`Rectangle ${b.length+1}`};case"roundedRect":{const re=mH(z,Q),be=q0(z,Q,re);return{...ee,type:"rect",cornerRadius:re,cornerRadii:be,name:`Rounded Rectangle ${b.length+1}`}}case"ellipse":return{...ee,type:"ellipse",name:`Ellipse ${b.length+1}`};case"triangle":return{...ee,type:"polygon",sides:3,name:`Triangle ${b.length+1}`};case"star":return{...ee,type:"star",sides:5,starInnerRadius:.4,name:`Star ${b.length+1}`};case"diamond":return{...ee,type:"polygon",sides:4,name:`Diamond ${b.length+1}`};case"hexagon":return{...ee,type:"polygon",sides:6,name:`Hexagon ${b.length+1}`};case"line":return{...ee,type:"line",fill:"none",points:[x,A],name:`Line ${b.length+1}`};default:return null}},[M,We,ge,Ae,nt,ft,pt,hn,Qe,bt,je,Dt,b.length]),vp=()=>{const x=parseInt(p??"",10);l(MH(Number.isFinite(x)?x:o)),m(null)},oa=()=>{const x=parseInt(y??"",10);h(MH(Number.isFinite(x)?x:c)),v(null)},Wr=x=>{var A;try{(A=Bi.current)==null||A.setPointerCapture(x.pointerId)}catch{}},Tl=x=>{var A;if(x&&((A=Bi.current)!=null&&A.hasPointerCapture(x.pointerId)))try{Bi.current.releasePointerCapture(x.pointerId)}catch{}},_s=q.useCallback((x,A,$)=>{C(),ji.current=null,Ai(null);const P=b.filter(z=>$.includes(z.id)&&!z.locked).map(z=>id(z));Ls.current=P,li.current={x:A.x,y:A.y},pn.current="drag",ys(!0),ir({x:x.x-A.x,y:x.y-A.y})},[b,C]),Ea=q.useCallback((x,A,$)=>
6861{ji.current=null,Ai(null),Ye.current={point:x,anchorObj:A,ids:$},pn.current="pending-drag",ir({x:x.x-A.x,y:x.y-A.y})},[]),Jo=q.useCallback((x,A,$)=>{const P=$.filter(re=>!re.locked);if(P.length===0)return;C();const z=g3(P);S(re=>[...re,...z]);const Q=z.map(re=>re.id);I(Q);const ee=z[0];ee&&(Wr(x),Ea(A,ee,Q))},[Ea,C]),es=q.useCallback(x=>{pn.current="pan",Wr(x),er(!0),or({x:x.clientX-$n.x,y:x.clientY-$n.y})},[$n]),Ta=q.useCallback((x,A,$)=>{const P=Bi.current;if(!P||$===1)return;const z=P.getBoundingClientRect(),Q=x-z.left,ee=A-z.top;ar(re=>{const be=fNe(re*$);return kn(Ee=>{const Te=(Q-Ee.x)/re,Be=(ee-Ee.y)/re;return{x:Q-Te*be,y:ee-Be*be}}),be})},[]),hs=q.useCallback(()=>{rn(null),gs(null)},[]),Ci=q.useCallback((x,A)=>{gs(null),rn({x,y:A})},[]),$r=q.useCallback(()=>{const x=us.current;x!=null&&x.timer&&clearTimeout(x.timer),us.current=null},[]),Aa=q.useCallback((x,A,$,P,z)=>{$r(),us.current={startX:$,startY:P,clientX:x,clientY:A,pointerId:z,timer:setTimeout(()=>{var ee;const Q=us.current;if(us.current=null,Ye.current=null,pn.current="none",ys(!1),Q&&((ee=Bi.current)!=null&&ee.hasPointerCapture(Q.pointerId)))try{Bi.current.releasePointerCapture(Q.pointerId)}catch{}Ci(x,A)},FIe)}},[$r,Ci]),uc=q.useCallback(x=>{x.stopPropagation(),$r();const A=xr.filter(Q=>!Q.locked);if(A.length===0)return;const $=fo(x);if(x.altKey){Jo(x,$,A);return}const P=A.map(Q=>Q.id),z=A[0];Wr(x),Ea($,z,P),Hn&&Aa(x.clientX,x.clientY,$.x,$.y,x.pointerId)},[Jo,Ea,Wr,$r,fo,Hn,xr,Aa]),zc=q.useCallback(x=>{const A=pn.current;if(A!=="none"){if(A==="marquee"&&vt.current&&ct.current){const $=vt.current,P=ct.current,z=Math.min($.x,P.x),Q=Math.min($.y,P.y),ee=Math.abs(P.x-$.x),re=Math.abs(P.y-$.y);if(ee>Uy||re>Uy){const be={x:z,y:Q,width:ee,height:re},Ee=b.filter(Ze=>Ze.visible&&!Ze.locked&&jIe(d3(Ze),be)).map(Ze=>Ze.id),Te=ia(Ee),Be=(x==null?void 0:x.shiftKey)??Kt.current;I(Ze=>Be?[...new Set([...Ze,...Te])]:Te)}}pn.current="none",ji.current=null,Ai(null),Ye.current=null,$r(),vt.current=null,ct.current=null,Kt.current=!1,Ls.current=null,li.current=null,_t.current=null,ds.current=null,ra.current=null,an(!1),Qn(null),Cr(null),ys(!1),ti(!1),Va(null),yr(null),ke(!1),Ne(null),er(!1),J(null),Tl(x)}},[b,$r]);q.useEffect(()=>{const x=A=>{if(pn.current==="draw"){de.current(A);return}pn.current!=="none"&&zc()};return window.addEventListener("pointerup",x),window.addEventListener("mouseup",x),()=>{window.removeEventListener("pointerup",x),window.removeEventListener("mouseup",x)}},[zc]);const Al=q.useCallback(x=>{var z,Q,ee;if(performance.now()<Se.current){x.preventDefault(),x.stopPropagation();return}if((M!=="type"||ls)&&((z=_l.current)==null||z.focus()),x.button===1){es(x);return}if(x.button!==0)return;if(M==="hand"||Yi.current){es(x);return}if(M==="zoom"){x.preventDefault(),pn.current="zoom",ds.current={startClientY:x.clientY,lastClientY:x.clientY,screenX:x.clientX,screenY:x.clientY,altKey:x.altKey},Wr(x);return}const A=fo(x),$=x.target,P=l3(x.target);if(M==="pen"){const re=sa.current,be=AH/Math.max(ot,1e-6);if(re!=null&&re.nodes.length){const Te=re.nodes[0];if(re.nodes.length>=3&&x5(A,Te)<=be){J(null),lc(!0);return}const Be=PH(A),Ze=[...re.nodes,Be];wt({nodes:Ze,closed:!1}
6861),_n(A),J(null),ra.current={target:"draft",nodeIndex:Ze.length-1,contourIndex:0},pn.current="pen-anchor",Wr(x);return}if(P){const Te=Lu(P,A);if(Te){_n(A),J(null),ra.current={target:"object",objId:Te.objId,nodeIndex:Te.nodeIndex,contourIndex:Te.contourIndex},pn.current="pen-anchor",Wr(x);return}}const Ee=PH(A);wt({nodes:[Ee],closed:!1}),_n(A),J(null),ra.current={target:"draft",nodeIndex:0,contourIndex:0},pn.current="pen-anchor",Wr(x);return}if(M==="direct"){if(P){const re=b.find(be=>be.id===P);if((re==null?void 0:re.type)==="text"){$.getAttribute("data-resize-handle")||I(be=>be.filter(Ee=>{var Te;return((Te=b.find(Be=>Be.id===Ee))==null?void 0:Te.type)!=="text"})),Xt(null);return}re&&!re.locked&&(x.shiftKey?I(be=>be.includes(P)?be.filter(Ee=>Ee!==P):[...be,P]):I([P])),Xt(null);return}$.getAttribute("data-resize-handle")||I([]),Xt(null);return}if(M==="select"){if((Q=$.closest)!=null&&Q.call($,"[data-transform-origin]")){if(!yi||xr.length===0)return;x.stopPropagation(),$r(),pn.current="transform-origin",Wr(x);return}if($.getAttribute("data-rotate-handle")){if(!yi||xr.length===0)return;$r(),C();const re=tt??{u:.5,v:.5},be=Q2(yi,re.u,re.v),Ee=Math.atan2(A.y-be.y,A.x-be.x)*(180/Math.PI),Te=xr.filter(Ze=>!Ze.locked).map(Ze=>id(Ze)),Be=Te.length===1&&((ee=Te[0])==null?void 0:ee.rotation)||0;pn.current="rotate",Wr(x),ti(!0),yr(Be),Va({center:be,startAngle:Ee,snapshots:Te});return}if(P){const re=b.find(be=>be.id===P);if(re&&!re.locked){const be=ia([P]).filter(Be=>{const Ze=b.find(Fe=>Fe.id===Be);return!!(Ze&&!Ze.locked)});let Ee;if(x.shiftKey?Ee=be.every(Ze=>E.includes(Ze))?E.filter(Ze=>!be.includes(Ze)):[...new Set([...E,...be])]:be.every(Be=>E.includes(Be))?Ee=E:Ee=be,I(Ee),x.altKey){const Be=b.filter(Ze=>Ee.includes(Ze.id)&&!Ze.locked);Jo(x,A,Be);return}Wr(x);const Te=b.find(Be=>Be.id===Ee[0])||re;Ea(A,Te,Ee),Hn&&Aa(x.clientX,x.clientY,A.x,A.y,x.pointerId);return}if(!(re!=null&&re.locked))return}!$.getAttribute("data-resize-handle")&&!$.getAttribute("data-transform-origin")&&!$.getAttribute("data-selection-move")&&(pn.current="marquee",vt.current=A,ct.current=A,Kt.current=x.shiftKey,Wr(x),an(!0),Qn(A),Cr(A),x.shiftKey||I([]));return}if(M==="type"){if(P){const re=b.find(be=>be.id===P);if((re==null?void 0:re.type)==="text"&&!re.locked){Nd(P),x.pointerType==="touch"&&x.preventDefault();return}}pn.current="draw",Wr(x),ie.current={x:x.clientX,y:x.clientY},ve.current=A,ce.current=A,xe(!0),gt(A),xt(A);return}s3.includes(M)&&(pn.current="draw",Wr(x),ie.current={x:x.clientX,y:x.clientY},ve.current=A,ce.current=A,xe(!0),gt(A),xt(A))},[M,Jo,es,Ea,$r,lc,fo,Lu,Hn,b,$n,C,E,xr,yi,tt,Aa,ot]),Qo=q.useCallback(x=>{var z,Q;if(pn.current==="pan"&&Bn){kn({x:x.clientX-oi.x,y:x.clientY-oi.y});return}if(pn.current==="zoom"&&ds.current){const ee=ds.current,re=ee.lastClientY-x.clientY;if(ee.lastClientY=x.clientY,re!==0){let be=Math.pow(eNe,re);x.altKey&&(be=1/be),Ta(ee.screenX,ee.screenY,be)}return}const A=fo(x),$=us.current;if($&&Math.hypot(A.x-$.startX,A.y-$.startY)>=Uy&&$r(),M==="pen"){_n(A);const ee=sa.current,re=l3(x.target);if(!(ee!=null&&ee.nodes.length)&&re&&pn.current!=="pen-anchor"){const be=El(re,A);J(be?{objId:be.objId,point:be.point}:null)}else pn.current!=="pen-anchor"&&J(null)}if(pn.current==="pen-anchor"&&ra.current){const ee=ra.current;ee.target==="draft"?wt(re=>{if(!re||ee.nodeIndex<0||ee.nodeIndex>=re.nodes.length)return re;const be=re.nodes.map(Ee=>
6861({x:Ee.x,y:Ee.y,handleIn:Ee.handleIn?{...Ee.handleIn}:null,handleOut:Ee.handleOut?{...Ee.handleOut}:null}));return be[ee.nodeIndex]=$H(be[ee.nodeIndex],A),{...re,nodes:be}}):ee.objId&&S(re=>re.map(be=>{var Bt,en,Ln;if(be.id!==ee.objId)return be;const Ee=ro(be)?be:Eh(be);if(!((Bt=Ee.pathNodes)!=null&&Bt.length))return be;const Te=DH(Ee,A),Be=(en=Ee.pathContours)!=null&&en.length?Ee.pathContours.map(Dn=>Dn.map(Os=>({x:Os.x,y:Os.y,handleIn:Os.handleIn?{...Os.handleIn}:null,handleOut:Os.handleOut?{...Os.handleOut}:null}))):[Ee.pathNodes.map(Dn=>({x:Dn.x,y:Dn.y,handleIn:Dn.handleIn?{...Dn.handleIn}:null,handleOut:Dn.handleOut?{...Dn.handleOut}:null}))],Ze=Be[ee.contourIndex];if(!Ze||ee.nodeIndex<0||ee.nodeIndex>=Ze.length)return Ee;Ze[ee.nodeIndex]=$H(Ze[ee.nodeIndex],Te);const Fe=Be[0],Gt=(Ln=Ee.pathContours)!=null&&Ln.length?Be:void 0,Tt=Gt!=null&&Gt.length?Tm(Gt):Su(Fe);return{...Ee,...Tt,pathNodes:Fe,pathContours:Gt,pathClosed:Ee.pathClosed!==!1,rotation:Ee.rotation??0}})),J(null);return}const P=_t.current;if(pn.current==="anchor"&&P!==null){S(ee=>ee.map(re=>{if(re.id!==P.objId)return re;if(ro(re))return xH(re,P.nodeIndex,P.kind,A,P.contourIndex??0);if(d5(re)){const be=Eh(re);return xH(be,P.nodeIndex,P.kind,A,P.contourIndex??0)}return TIe(re,P.nodeIndex,A)}));return}if(pn.current==="pending-drag"&&Ye.current){const ee=Ye.current;Math.hypot(A.x-ee.point.x,A.y-ee.point.y)>=Uy&&(_s(ee.point,ee.anchorObj,ee.ids),Ye.current=null);return}if(pn.current==="marquee"&&vt.current){ct.current=A,Cr(A);return}if(pn.current==="rotate"&&Qs&&_a){const{center:ee,startAngle:re,snapshots:be}=_a;let Te=Math.atan2(A.y-ee.y,A.x-ee.x)*(180/Math.PI)-re;x.shiftKey&&(Te=Math.round(Te/45)*45);const Be=be[0],Ze=be.length>1&&(yi!=null&&yi.oriented)?yi.rotationDeg:0,Fe=be.length===1&&Be?Sh((Be.rotation||0)+Te):Sh(Ze+Te);if(yr(Fe),Math.abs(Te)<.01)return;S(Gt=>{const Tt=new Map(be.map(Bt=>[Bt.id,rI(Bt,ee.x,ee.y,Te)]));return Gt.map(Bt=>Tt.get(Bt.id)??Bt)});return}if(pn.current==="drag"&&$s&&M==="select"&&((z=Ls.current)!=null&&z.length)){const ee=li.current;if(!ee)return;const re=A.x-Pn.x,be=A.y-Pn.y,Ee=re-ee.x,Te=be-ee.y,Be=new Set(E),Fe=H.current.filter(is=>is.visible&&!is.locked&&!Be.has(is.id)).map(is=>d3(is)),Gt=Ls.current;if(!Gt)return;const Tt=Wb(Gt);if(!Tt)return;const Bt=VIe/ot,en=gR(Tt,Ee,Te),Ln=LH([en.left,en.right,en.cx],zIe(Fe,o),Bt),Dn=gR(Tt,Ee+Ln,Te),Os=LH([Dn.top,Dn.bottom,Dn.cy],GIe(Fe,c),Bt),Rn=Ee+Ln,On=Te+Os,Ss={x:Tt.x+Ee,y:Tt.y+Te,width:Tt.width,height:Tt.height,cx:Tt.cx+Ee,cy:Tt.cy+Te},Dr={x:Tt.x+Rn,y:Tt.y+On,width:Tt.width,height:Tt.height,cx:Tt.cx+Rn,cy:Tt.cy+On},Us=JIe(Dr,Ss,Fe,o,c,Bt);if(ji.current=Us,Ai(Us),Rn!==0||On!==0){const is=new Map(Gt.map(Yr=>[Yr.id,WS(Yr,Rn,On)]));S(Yr=>Yr.map(di=>is.get(di.id)??di))}return}if(pn.current==="transform-origin"&&yi){mt(DIe(yi,A));return}if(pn.current==="resize"&&ue&&$e){const ee=$e.snapshots??[];if($e.oriented&&$e.frame0&&(((Q=$e.snapshots)==null?void 0:Q.length)??0)===1&&RH.includes(pe)&&$e.frame0){const Rn=OIe(pe,$e.frame0,A,5,Sa(x.shiftKey));if(Rn){const On=$e.frame0;S(Ss=>Ss.map(Dr=>{const Us=ee.find(is=>is.id===Dr.id);return Us?LIe(Us,On,Rn,pe):Dr}))}return}const be=A.x-$e.x,Ee=A.y-$e.y,Te=$e.groupBounds??{x:$e.obj.x,y:$e.obj.y,width:$e.obj.width,height:$e.obj.height},Be=$e.pivotU??.5,Ze=$e.pivotV??.5,Fe=tIe(Be,Ze);let Gt=Te.x,Tt=Te.y,Bt=Te.width,en=Te.height;const Ln=10,Dn=A.x,Os=A.y;if(Sa(x.shiftKey))if(Fe){const Rn=sIe(pe,Te,Dn,Os,Be,Ze,Ln);Gt=Rn.x,Tt=Rn.y,Bt=Rn.width,en=Rn.height}else{const Rn=ase(pe,Te,Dn,Os);Gt=Rn.x,Tt=Rn.y,Bt=Rn.width,en=Rn.height}else if(Fe){const Rn=nIe(pe,Te,Dn,Os,Be,Ze,Ln);Gt=Rn.x,Tt=Rn.y,Bt=Rn.width,en=Rn.height}else pe.includes("e")&&(Bt=Math.max(Ln,Te.width+be)),pe.includes("w")&&(Gt=Te.x+be,Bt=Math.max(Ln,Te.width-be)),pe.includes("s")&&(en=Math.max(Ln,Te.height+Ee)),pe.includes("n")&&(Tt=Te.y+Ee,en=Math.max(Ln,Te.height-Ee));S(Rn=>Rn.map(On=>{var Kc,Gu;if(!E.includes(On.id)||On.locked)return On;const Ss=ee.find(wi=>wi.id===On.id);if(!Ss)return On;const Dr={x:Te.x,y:Te.y,width:Te.width,height:Te.height},Us=Dr.width?Bt/Dr.width:1,is=Dr.height?en/Dr.height:1,Yr=wi=>({x:Gt+(wi.x-Dr.x)*Us,y:Tt+(wi.y-Dr.y)*is});if(ro(Ss)&&((Kc=Ss.pathNodes)!=null&&Kc.length)){const wi=Ss.pathNodes.map(Xr=>({x:Yr(Xr).x,y:Yr(Xr).y,handleIn:Xr.handleIn?Yr(Xr.handleIn):null,handleOut:Xr.handleOut?Yr(Xr.handleOut):null})),sl=(Gu=Ss.pathContours)!=null&&Gu.length?Ss.pathContours.map(Xr=>Xr.map(Vr=>({x:Yr(Vr).x,y:Yr(Vr).y,handleIn:Vr.handleIn?Yr(Vr.handleIn):null,handleOut:Vr.handleOut?Yr(Vr.handleOut):null}))):void 0,Yc=sl!=null&&sl.length?Tm(sl):Su(wi),xc={...Ss,...Yc,pathNodes:wi,pathContours:sl,pathClosed:Ss.pathClosed!==!1,rotation:Ss.rotation??0,...Ss.type==="text"?{autoFit:!1}:{}};return["se","nw","ne","sw"].includes(pe)?mR(xc,Us,is):xc}if(Ss.type==="text"&&y5.has(pe))return _Ie(Ss,pe,Us,is);const di={...Ss,x:Gt+(Ss.x-Dr.x)*Us,y:Tt+(Ss.y-Dr.y)*is,width:Math.max(1,Ss.width*Us),height:Math.max(1,Ss.height*is),...Ss.type==="text"?{autoFit:!1}:{}};if(Ss.type==="rect"&&!xv(Ss)){const wi=yj(Ss,di.width,di.height,Us,is);di.cornerRadii=wi,di.cornerRadius=zg(wi)?wi.tl:0}return di}))}if(pn.current==="draw"&&me){Le.current=Sa(x.shiftKey);const ee=A,re=ve.current??De,be=Sa(x.shiftKey)&&M!=="type"&&re?r3(re,ee,M):ee;ce.current=be,xt(be)}},[Bn,oi,$s,M,E,b,o,c,Pn,fo,El,me,ue,pe,$e,Qs,_a,_s,Ta,yi,ot,$r,Sa]),dc=q.useCallback(x=>{if(_t.current!==null){_t.current=null,pn.current="none",Tl(x);return}if(pn.current==="pen-anchor"){ra.current=null,pn.current="none",J(null),Tl(x);return}if(pn.current==="zoom"&&x&&ds.current){const z=ds.current;if(Math.hypot(x.clientX-z.screenX,x.clientY-z.screenY)<Uy){const ee=
6861x.altKey?1/Dg:Dg;Ta(x.clientX,x.clientY,ee)}ds.current=null,pn.current="none",Tl(x);return}const A=ve.current??De,$=ce.current??yt;if(A&&$&&(pn.current==="draw"||me)&&pn.current==="draw"){if(pn.current="none",M==="type"){let z=Math.min(A.x,$.x),Q=Math.min(A.y,$.y),ee=Math.abs($.x-A.x),re=Math.abs($.y-A.y);const be=ie.current,Ee=be&&x?Math.hypot(x.clientX-be.x,x.clientY-be.y)<BIe:!1;if(Sa(x==null?void 0:x.shiftKey)&&ee>=4&&re>=4){const Ze=Math.max(ee,re),Fe=$.x>=A.x?1:-1,Gt=$.y>=A.y?1:-1,Tt=A.x+Fe*Ze,Bt=A.y+Gt*Ze;z=Math.min(A.x,Tt),Q=Math.min(A.y,Bt),ee=Ze,re=Ze}const Te=Ee||ee<Uy&&re<Uy;Te?(ee=iIe,re=aIe):(ee=Math.max(h5,ee),re=Math.max(IE,re));const Be=Wa(z,Q,ee,re,Te);C(),S(Ze=>[...Ze,Be]),Vc(),Ps(Be.id),I([Be.id]),(x==null?void 0:x.pointerType)==="touch"&&x.preventDefault()}else{const z=Sa(x==null?void 0:x.shiftKey)&&M!=="type"?r3(A,$,M):$,Q=$d(A,z);Q&&(C(),S(ee=>[...ee,Q]),I([Q.id]))}ve.current=null,ce.current=null,ie.current=null,xe(!1),gt(null),xt(null),Le.current=!1,Tl(x);return}zc(x)},[me,De,yt,$d,M,b.length,pt,We,zc,Ta,C,Sa,Wa]);q.useEffect(()=>{de.current=dc},[dc]);const Dd=q.useCallback((x,A)=>{if(x.stopPropagation(),$r(),E.length===0||!uo)return;C();const $=fo(x),P=xr.filter(re=>!re.locked).map(re=>id(re));E.length>1;const z={id:"_group_resize_",type:"rect",x:uo.x,y:uo.y,width:uo.width,height:uo.height,fill:"none",stroke:"none",strokeWidth:0,opacity:1,rotation:0,name:"",visible:!0,locked:!1};pn.current="resize",Wr(x),ke(!0),Pe(A);const Q=zy(xr),ee=Ct.current??{u:.5,v:.5};Ne({x:$.x,y:$.y,obj:gn?id(gn):z,groupBounds:(Q==null?void 0:Q.axisBounds)??uo??void 0,snapshots:P,pivotU:ee.u,pivotV:ee.v,oriented:!!(Q!=null&&Q.oriented),frame0:Q!=null&&Q.oriented?{...Q}:void 0,originRel:{...ee}})},[E,xr,gn,uo,fo,C,$r]);q.useEffect(()=>{const x=_l.current;if(!x)return;const A=$=>{if($.preventDefault(),$.stopPropagation(),$.altKey){const z=m3($,"y");if(z===0)return;const Q=z<0?Dg:1/Dg;Ta($.clientX,$.clientY,Q);return}if($.ctrlKey||$.metaKey){const z=m3($,"x");kn(Q=>({...Q,x:Q.x-z}));return}const P=m3($,"y");kn(z=>({...z,y:z.y-P}))};return x.addEventListener("wheel",A,{passive:!1}),()=>x.removeEventListener("wheel",A)},[Ta]);const la=q.useRef(null),Zo=q.useRef(null);q.useEffect(()=>{if(!Hn)return;const x=_l.current;if(!x)return;const A=()=>{const Q=pn.current;return Q!=="none"&&Q!=="pan"},$=Q=>{if(Q.touches.length===2){const[ee,re]=[Q.touches[0],Q.touches[1]];la.current={dist:Math.hypot(re.clientX-ee.clientX,re.clientY-ee.clientY)},Zo.current=null,Q.preventDefault()}else Q.touches.length===1&&(la.current=null,Zo.current=null)},P=Q=>{if(!A()&&Q.touches.length===2){Q.preventDefault();const[ee,re]=[Q.touches[0],Q.touches[1]],be=(ee.clientX+re.clientX)/2,Ee=(ee.clientY+re.clientY)/2,Te=Math.hypot(re.clientX-ee.clientX,re.clientY-ee.clientY);if(la.current&&la.current.dist>0){const Be=Te/la.current.dist;la.current.dist=Te,Math.abs(Be-1)>.002&&Ta(be,Ee,Be)}else la.current={dist:Te};Zo.current&&kn(Be=>({x:Be.x+be-Zo.current.lastX,y:Be.y+Ee-Zo.current.lastY})),Zo.current={lastX:be,lastY:Ee}}},z=()=>{la.current&&(la.current=null),Zo.current=null};return x.addEventListener("touchstart",$,{passive:!1}),x.addEventListener("touchmove",P,{passive:!1}),x.addEventListener("touchend",z),x.addEventListener("touchcancel",z),()=>{x.removeEventListener("touchstart",$),x.removeEventListener("touchmove",P),x.removeEventListener("touchend",z),x.removeEventListener("touchcancel",z)}},[Hn,Ta]);const ju=q.useCallback((x=20,A=20)=>{const $=xr.filter(z=>!z.locked);if($.length===0)return[];C();const P=g3($,x,A);return S(z=>[...z,...P]),I(P.map(z=>z.id)),P},[xr,C]),tf=q.useCallback(()=>{ni.current=xr.filter(x=>!x.locked).map(x=>id(x))},[xr]),nf=q.useCallback(()=>{if(ni.current.length===0)return;C();const x=g3(ni.current,20,20);S(A=>[...A,...x]),I(x.map(A=>A.id))},[C]),Gc=q.useCallback(()=>{const x=qn.current;if(!x)return!1;const A=H.current.find(P=>P.id===x.objId);if(!A||A.locked)return!1;const $=AIe(A,x.nodeIndex,x.contourIndex);return $===null?!1:(C(),$==="delete"?(S(P=>P.filter(z=>z.id!==x.objId||z.locked)),I([]),Xt(null),!0):(S(P=>P.map(z=>z.id===x.objId?$:z)),Xt(null),!0))},[C]);q.useEffect(()=>{const x=A=>{var $;if(!(A.target instanceof HTMLInputElement||A.target instanceof HTMLTextAreaElement)){if((A.ctrlKey||A.metaKey)&&A.key.toLowerCase()==="z"){A.preventDefault(),A.shiftKey?ye():ne();return}if(M==="pen"&&A.key==="Backspace"&&sa.current){A.preventDefault(),wt(P=>P&&(P.nodes.length<=1?(_n(null),null):{...P,nodes:P.nodes.slice(0,-1)}));return}if(A.key==="Delete"||A.key==="Backspace"){if(M==="direct"&&qn.current&&(A.preventDefault(),Gc()))return;E.some(P=>{const z=H.current.find(Q=>Q.id===P);return z&&!z.locked})&&(A.preventDefault(),C(),S(P=>P.filter(z=>!E.includes(z.id)||z.locked)),I([]),Xt(null))}!A.ctrlKey&&!A.metaKey&&(A.key==="v"&&Ir("select"),A.key==="a"&&Ir("direct"),A.key==="h"&&Ir("hand"),A.key==="z"&&Ir("zoom"),A.key==="r"&&Ir("rect"),A.key==="e"&&Ir("ellipse"),A.key==="t"&&Ir("type"),A.key==="p"&&Ir("pen")),A.key==="Escape"&&ls&&ho(!0),A.key==="Escape"&&M==="pen"&&Md(),A.key==="Enter"&&M==="pen"&&(($=sa.current)!=null&&$.nodes.length)&&!A.ctrlKey&&!A.metaKey&&(A.preventDefault(),lc(!1)),(A.ctrlKey||A.metaKey)&&A.key==="d"&&(A.preventDefault(),ju()),(A.ctrlKey||A.metaKey)&&A.key.toLowerCase()==="a"&&(A.preventDefault(),I(b.filter(P=>!P.locked).map(P=>P.id))),(A.ctrlKey||A.metaKey)&&A.key.toLowerCase()==="c"&&(A.preventDefault(),tf()),(A.ctrlKey||A.metaKey)&&A.key.toLowerCase()==="v"&&(A.preventDefault(),nf())}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)}
6861,[M,Md,lc,E,b,ls,ho,Ir,ju,tf,nf,ne,ye,C,Gc]),q.useEffect(()=>{const x=z=>z instanceof HTMLInputElement||z instanceof HTMLTextAreaElement||z instanceof HTMLElement&&z.isContentEditable,A=z=>{z.code!=="Space"&&z.key!==" "||x(z.target)||z.repeat||(z.preventDefault(),Yi.current=!0,kr(!0))},$=z=>{z.code!=="Space"&&z.key!==" "||(Yi.current=!1,kr(!1))},P=()=>{Yi.current=!1,kr(!1)};return window.addEventListener("keydown",A),window.addEventListener("keyup",$),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",A),window.removeEventListener("keyup",$),window.removeEventListener("blur",P)}},[]),q.useEffect(()=>{const x=z=>z instanceof HTMLInputElement||z instanceof HTMLTextAreaElement||z instanceof HTMLElement&&z.isContentEditable,A=z=>{z.key==="Shift"&&(x(z.target)||wl(!0))},$=z=>{z.key==="Shift"&&wl(z.shiftKey)},P=()=>wl(!1);return window.addEventListener("keydown",A),window.addEventListener("keyup",$),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",A),window.removeEventListener("keyup",$),window.removeEventListener("blur",P)}},[]);const qm=q.useCallback((x,A)=>{x!==A&&(C(),S($=>{const P=$.findIndex(re=>re.id===x),z=$.findIndex(re=>re.id===A);if(P===-1||z===-1)return $;const Q=[...$],[ee]=Q.splice(P,1);return Q.splice(z,0,ee),Q}))},[C]),sf=()=>{if(M==="direct"&&qn.current){Gc();return}E.some(x=>{const A=H.current.find($=>$.id===x);return A&&!A.locked})&&(C(),S(x=>x.filter(A=>!E.includes(A.id)||A.locked)),I([]),Xt(null))},rf=q.useCallback(x=>{if(x.length===0)return;C();const A=new Set(x);S($=>$.filter(P=>!A.has(P.id))),I($=>$.filter(P=>!A.has(P))),Xt($=>$&&A.has($.objId)?null:$),Ps($=>$&&A.has($)?null:$)},[C]),xi=E.some(x=>{const A=b.find($=>$.id===x);return A&&!A.locked}),ma=q.useCallback(x=>{const A=b.filter(be=>E.includes(be.id)&&!be.locked);if(A.length===0)return;const $=Wb(A);if(!$)return;const P=o/2,z=c/2,Q=x==="horizontal"?P-$.cx:0,ee=x==="vertical"?z-$.cy:0;if(Math.abs(Q)<.01&&Math.abs(ee)<.01)return;C();const re=new Set(A.map(be=>be.id));S(be=>be.map(Ee=>re.has(Ee.id)?WS(Ee,Q,ee):Ee))},[b,E,o,c,C]),Ui=q.useCallback(x=>{const A=b.filter(P=>E.includes(P.id)&&!P.locked);if(A.length===0)return;const $=new Set(A.map(P=>P.id));C(),S(P=>P.map(z=>$.has(z.id)?x==="horizontal"?{...z,flipX:!z.flipX}:{...z,flipY:!z.flipY}:z))},[b,E,C]),el=q.useCallback(()=>{const x=b.filter(z=>E.includes(z.id)&&!z.locked);if(x.length<2||qr)return;const A=new Set(x.map(z=>z.id)),$=zH(x.map(z=>z.groupIds||[])),P=Xl();C(),S(z=>z.map(Q=>{if(!A.has(Q.id))return Q;const re=(Q.groupIds||[]).slice($.length);return{...Q,groupIds:[...$,P,...re]}}))},[b,E,qr,C]),Bu=q.useCallback(()=>{qr&&(C(),S(x=>x.map(A=>{const $=A.groupIds||[],P=$.indexOf(qr);if(P===-1)return A;const z=[...$.slice(0,P),...$.slice(P+1)];return{...A,groupIds:z.length>0?z:void 0}})))},[qr,C]),Uu=q.useCallback(x=>{const A=b.filter(be=>E.includes(be.id)&&!be.locked);if(A.length===0)return;const $=A.map(be=>id(be)),P=Wb($);if(!P)return;const z=tt??{u:.5,v:.5},Q=zy($),ee=Q?Q2(Q,z.u,z.v):{x:P.cx,y:P.cy};C();const re=new Set(A.map(be=>be.id));S(be=>be.map(Ee=>re.has(Ee.id)?rI(Ee,ee.x,ee.y,x):Ee))},[b,E,tt,C]),tl=q.useCallback(x=>{const A=b.filter(z=>E.includes(z.id)&&!z.locked);if(A.length<2)return;const $=Wb(A);if(!$)return;C();const P=new Set(A.map(z=>z.id));S(z=>z.map(Q=>{if(!P.has(Q.id))return Q;const ee=d3(Q);let re=0,be=0;switch(x){case"left":re=$.x-ee.x;break;case"center":re=$.cx-ee.cx;break;case"right":re=$.x+$.width-(ee.x+ee.width);break;case"top":be=$.y-ee.y;break;case"middle":be=$.cy-ee.cy;break;case"bottom":be=$.y+$.height-(ee.y+ee.height);break}return Math.abs(re)<.01&&Math.abs(be)<.01?Q:WS(Q,re,be)}))},[b,E,C]),Hc=q.useCallback(x=>{const A=b.filter(P=>E.includes(P.id)&&!P.locked);if(A.length===0)return;const $=new Set(A.map(P=>P.id));C(),S(P=>{const z=P.filter(re=>$.has(re.id)),Q=P.filter(re=>!$.has(re.id));if(x==="front")return[...Q,...z];if(x==="back")return[...z,...Q];const ee=[...P];if(x==="forward")for(let re=ee.length-2;re>=0;re-=1)$.has(ee[re].id)&&!$.has(ee[re+1].id)&&([ee[re],ee[re+1]]=[ee[re+1],ee[re]]);else for(let re=1;re<ee.length;re+=1)$.has(ee[re].id)&&!$.has(ee[re-1].id)&&([ee[re],ee[re-1]]=[ee[re-1],ee[re]]);return ee})},[b,E,C]),vi=b.filter(x=>E.includes(x.id)&&!x.locked).length>=2,Od=q.useCallback(x=>{var $,P,z,Q;x.preventDefault(),x.stopPropagation();const A=x.target;if(!(($=A.getAttribute)!=null&&$.call(A,"data-resize-handle")||(P=A.getAttribute)!=null&&P.call(A,"data-rotate-handle")||(z=A.closest)!=null&&z.call(A,"[data-transform-origin]"))){if
6861((Q=_l.current)==null||Q.focus(),M==="select"){const ee=l3(x.target);if(ee){const re=b.find(be=>be.id===ee);if(re&&!re.locked){const be=ia([ee]).filter(Ee=>{const Te=b.find(Be=>Be.id===Ee);return!!(Te&&!Te.locked)});if(x.shiftKey){const Ee=be.every(Te=>E.includes(Te));I(Te=>Ee?Te.filter(Be=>!be.includes(Be)):[...new Set([...Te,...be])])}else be.every(Ee=>E.includes(Ee))||I(be)}}}Ci(x.clientX,x.clientY)}},[M,b,E,Ci]);q.useEffect(()=>{if(!sn)return;const x=A=>{A.key==="Escape"&&hs()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[sn,hs]),q.useEffect(()=>()=>$r(),[$r]);const Ld=(x,A,$)=>x.map(P=>({x:P.x+A,y:P.y+$,handleIn:P.handleIn?{x:P.handleIn.x+A,y:P.handleIn.y+$}:null,handleOut:P.handleOut?{x:P.handleOut.x+A,y:P.handleOut.y+$}:null})),hc=q.useCallback((x,A)=>{const $=pke(x);if(!$||$.shapes.length===0){alert("No editable vector shapes were found in this file. Try an SVG with paths or basic shapes.");return}const P=$.shapes.flatMap(Be=>Be.contours.flatMap(Ze=>Ze.nodes)),z=Su(P),Q=o/2-(z.x+z.width/2),ee=c/2-(z.y+z.height/2),re=new Map,be=Be=>(re.has(Be)||re.set(Be,Xl()),re.get(Be)),Ee=(A==null?void 0:A.replace(/\.svg$/i,"").trim())||"Imported vector",Te=$.shapes.map((Be,Ze)=>{const Fe=Be.contours.map(On=>({nodes:Ld(On.nodes,Q,ee),closed:On.closed})),Gt=Fe[0].nodes,Tt=Fe.length>1?Fe.map(On=>On.nodes):void 0,Bt=Tt?Tm(Tt):Su(Gt),en=Be.groupPath.map(be),Ln=Be.fillMode==="gradient"?Qa(CH(Be.fillGradient)):void 0,Dn=Be.strokeMode==="gradient"?Qa(CH(Be.strokeGradient)):void 0,Os=Ln?"gradient":"solid",Rn=Dn?"gradient":"solid";return{id:Xl(),type:"path",...Bt,fill:Be.fill==="none"&&Be.stroke!=="none"?"none":Be.fill,fillMode:Os,fillGradient:Ln,fillOpacity:Be.fillOpacity,stroke:Be.stroke,strokeMode:Rn,strokeGradient:Dn,strokeOpacity:Be.strokeOpacity,strokeWidth:Be.strokeWidth,opacity:Be.opacity,rotation:0,pathNodes:Gt,pathContours:Tt,pathClosed:Fe.every(On=>On.closed),groupIds:en.length>0?en:void 0,name:Be.name||`${Ee} ${Ze+1}`,visible:!0,locked:!1}});C(),S(Be=>[...Be,...Te]),I(Te.map(Be=>Be.id)),Ir("select")},[o,c,C,Ir]),af=q.useCallback(async x=>{if(!nI(x)){alert("Please upload an SVG vector file (.svg).");return}try{const A=await x.text();hc(A,x.name)}catch{alert("Could not read the vector file. Please try again.")}},[hc]),Ka=x=>{var $;const A=($=x.target.files)==null?void 0:$[0];A&&af(A),x.target.value=""},Ya=x=>x.files.length>0?Array.from(x.files).some(nI):Array.from(x.items).some(A=>{if(A.kind!=="file")return!1;const $=A.getAsFile();return $?nI($):A.type==="image/svg+xml"}),fc=x=>{Ya(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy",ic(!0))},jd=x=>{x.currentTarget.contains(x.relatedTarget)||ic(!1)},Bd=x=>{ic(!1);const A=Array.from(x.dataTransfer.files).find(nI);A&&(x.preventDefault(),x.stopPropagation(),af(A))},ki=(x,A)=>{C(),S($=>{const P=$.findIndex(ee=>ee.id===x);if(P===-1)return $;const z=[...$],Q=A==="up"?P+1:P-1;return Q<0||Q>=z.length?$:([z[P],z[Q]]=[z[Q],z[P]],z)})},Xa=()=>{const x=o/2,A=c/2,$=150,P={id:Xl(),type:"polygon",x:x-$/2,y:A-$/2,width:$,height:$,fill:pt?"none":We,fillMode:pt?"solid":Qe,fillGradient:!pt&&Qe==="gradient"?Qa(Ji(bt)):void 0,fillOpacity:pt?void 0:ge,stroke:hn?"none":Ae,strokeMode:hn?"solid":je,strokeGradient:!hn&&je==="gradient"?Qa(Ji(Dt)):void 0,strokeOpacity:hn?void 0:nt,strokeWidth:ft,opacity:1,rotation:0,sides:ns,name:`Polygon ${b.length+1}`,visible:!0,locked:!1},z=Eh(P);C(),S(Q=>[...Q,z]),I([z.id]),ln(!1),Ir("select")},Cl=async x=>{const A=b.filter(P=>E.includes(P.id)),$=await Yke(x,A,Xl);if(!$||$.length===0){nn(!1);return}C(),S(P=>[...P.filter(z=>!E.includes(z.id)),...$.map(z=>Eh({...z}))]),I($.map(P=>P.id)),nn(!1),Ir("select")},Xi=q.useCallback(async()=>{if(dr){ls&&Zn.some(x=>x.id===ls)&&ho(!1),ws(!0);try{const{textToLetterContours:x}=await Fne(async()=>{const{textToLetterContours:P}=await import("./textToPath-Bj4LEhVq.js");return{textToLetterContours:P}},[]),A=new Set,$=[];for(const P of Zn){const z=await x({text:P.text??"",x:P.x,y:P.y,width:P.width,fontSize:P.fontSize||Bh,fontFamily:P.fontFamily||"Inter",fontWeight:P.fontWeight,fontStyle:P.fontStyle,textAlign:P.textAlign,autoFit:P.autoFit});if(z.length===0)continue;const Q=z.length>1?Xl():null,ee=m5(P),re=P.groupIds||[];z.forEach((be,Ee)=>{const Te=be.contours,Be=Te[0],Ze=Te.length>1?Te:void 0,Fe=Ze?Tm(Te):Su(Be),Gt=be.char.trim()?be.char:`${P.name} ${Ee+1}`;$.push({id:Xl(),type:"path",...Fe,fill:P.fill,fillMode:P.fillMode,fillGradient:P.fillGradient?Qa(P.fillGradient):void 0,fillOpacity:P.fillOpacity,stroke:ee?P.stroke:"none",strokeMode:ee&&P.strokeMode||"solid",strokeGradient:ee&&P.strokeGradient?Qa(P.strokeGradient):void 0,strokeOpacity:ee?P.strokeOpacity:void 0,strokeWidth:ee?g5(P):0,opacity:P.opacity,rotation:P.rotation??0,flipX:P.flipX,flipY:P.flipY,pathNodes:Be,pathContours:Ze,pathClosed:!0,groupIds:Q?[...re,Q]:re.length>0?re:void 0,name:z.length>1?Gt:P.name,visible:P.visible,locked:P.locked})}),A.add(P.id)}if($.length===0){alert("Could not convert the selected text to shapes. Check that fonts are available.");return}C(),S(P=>[...P.filter(z=>!A.has(z.id)),...$]),I($.map(P=>P.id)),Ir("select")}catch(x){console.error("Convert text to shape failed:",x),alert("Could not convert text to shape. Please try again.")}finally{ws(!1)}}},[dr,Zn,ls,ho,C,Ir]),Ro=x=>x||"Inter",Fi=x=>{const A=(x.text||"").replace(/\r\n/g,`
6862`);if(A.length===0)return[""];const $=A.split(`
6863`);if(x.autoFit)return $;const P=Math.max(1,x.width-8),Q=document.createElement("canvas").getContext("2d");if(!Q)return $;
6863const ee=x.fontSize||Bh,re=x.fontWeight==="bold"?"700":"400",be=x.fontStyle==="italic"?"italic":"normal",Ee=Ro(x.fontFamily);Q.font=`${be} ${re} ${ee}px ${Ee}`;const Te=[];for(const Be of $){if(!Be){Te.push("");continue}const Ze=Be.split(" ");let Fe=Ze[0]||"";for(let Gt=1;Gt<Ze.length;Gt++){const Tt=`${Fe} ${Ze[Gt]}`;Q.measureText(Tt).width<=P?Fe=Tt:(Te.push(Fe),Fe=Ze[Gt])}Te.push(Fe)}return Te},of=(x=!1)=>{let A=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${c}" viewBox="0 0 ${o} ${c}">
6864`;x||(A+=`  <rect width="${o}" height="${c}" fill="white"/>
6865`);const $=new Map,P=(Q,ee)=>{const re=pR(Q,ee);if(re==="none")return"none";if(!Ff(Q,ee))return re;const be=ix(Q,ee);if(!be)return re;const Ee=o3(Q.id,ee);if(!$.has(Ee)){const Te=Ji(be),Be=p5(Te).map(Ze=>`      <stop offset="${Ze.offset}%" stop-color="${IH(Ze.color)}" stop-opacity="${(Ze.opacity/100).toFixed(4)}"/>
6866`).join("");if(Te.style==="radial")$.set(Ee,`    <radialGradient id="${Ee}" cx="50%" cy="50%" r="50%">
6867${Be}    </radialGradient>
6868`);else{const Ze=Te.angle*Math.PI/180,Fe=Math.cos(Ze)*.5,Gt=Math.sin(Ze)*.5;$.set(Ee,`    <linearGradient id="${Ee}" x1="${(.5-Fe)*100}%" y1="${(.5-Gt)*100}%" x2="${(.5+Fe)*100}%" y2="${(.5+Gt)*100}%">
6869${Be}    </linearGradient>
6870`)}}return`url(#${Ee})`};let z="";return b.filter(Q=>Q.visible).forEach(Q=>{var Be;const ee=Ub(Q),re=ee?` transform="${ee}"`:"",be=P(Q,"fill"),Ee=P(Q,"stroke"),Te=`fill="${be}"${X2(Q,"fill")} stroke="${Ee}"${X2(Q,"stroke")} stroke-width="${Q.strokeWidth}" opacity="${Q.opacity}"`;if(ro(Q)&&Q.pathNodes){const Ze=(Be=Q.pathContours)!=null&&Be.length?t3(Q.pathContours,Q.pathClosed!==!1):pS(Q.pathNodes,Q.pathClosed!==!1),Fe=Q.pathContours&&Q.pathContours.length>1?' fill-rule="evenodd" clip-rule="evenodd"':"",Gt=Q.pathClosed===!1?"none":be;z+=`  <path d="${Ze}" fill="${Gt}"${X2(Q,"fill")} stroke="${Ee}"${X2(Q,"stroke")} stroke-width="${Q.strokeWidth}" opacity="${Q.opacity}"${Fe}${re}/>
6871`;return}switch(Q.type){case"rect":if(Q.points&&Q.points.length===4){const Ze=Q.points.map(Fe=>`${Fe.x},${Fe.y}`).join(" ");z+=`  <polygon points="${Ze}" ${Te}${re}/>
6872`}else{const Ze=Jy(Q);if(zg(Ze)){const Fe=Ze.tl>0?` rx="${Ze.tl}" ry="${Ze.tl}"`:"";z+=`  <rect x="${Q.x}" y="${Q.y}" width="${Q.width}" height="${Q.height}"${Fe} ${Te}${re}/>
6873`}else{const Fe=e3(Q.x,Q.y,Q.width,Q.height,Q.cornerRadius??0,Q.cornerRadii);z+=`  <path d="${Fe}" ${Te}${re}/>
6874`}}break;case"ellipse":z+=`  <ellipse cx="${Q.x+Q.width/2}" cy="${Q.y+Q.height/2}" rx="${Q.width/2}" ry="${Q.height/2}" ${Te}${re}/>
6875`;break;case"polygon":case"star":{const Ze=Bs(Q);z+=`  <polygon points="${Ze}" ${Te}${re}/>
6876`;break}case"line":Q.points&&Q.points.length>=2&&(z+=`  <line x1="${Q.points[0].x}" y1="${Q.points[0].y}" x2="${Q.points[1].x}" y2="${Q.points[1].y}" stroke="${Ee}"${X2(Q,"stroke")} stroke-width="${Q.strokeWidth}" opacity="${Q.opacity}"${re}/>
6877`);break;case"text":{const Ze=Q.fontSize||Bh,Fe=P(Q,"fill"),Gt=Q.fontWeight==="bold"?"bold":"normal",Tt=Q.fontStyle==="italic"?"italic":"normal",Bt=Q.textDecoration==="underline"?"underline":"none",en=Q.textAlign||"left",Ln=Fi(Q),Dn=Ze*1.25,Os=en==="center"?Q.x+Q.width/2:en==="right"?Q.x+Q.width-4:Q.x+4,Rn=en==="center"?"middle":en==="right"?"end":"start",On=Q.y+2+Ze,Ss=Ro(Q.fontFamily),Dr=m5(Q),Us=g5(Q),is=P(Q,"stroke"),Yr=Dr?` stroke="${is}" stroke-width="${Us}" paint-order="stroke fill"`:"";z+=`  <text x="${Os}" y="${On}" fill="${Fe}" opacity="${Q.opacity}" font-family="${Ss}" font-size="${Ze}" font-weight="${Gt}" font-style="${Tt}" text-decoration="${Bt}" text-anchor="${Rn}"${Yr}${re}>
6878`,Ln.forEach((di,Kc)=>{z+=`    <tspan x="${Os}" dy="${Kc===0?0:Dn}">${IH(di)}</tspan>
6879`}),z+=`  </text>
6880`;break}}}),$.size>0&&(A+=`  <defs>
6881${Array.from($.values()).join("")}  </defs>
6882`),A+=z,A+="</svg>",A},lf=()=>{const x=of(fs),A=new Blob([x],{type:"image/svg+xml"}),$=URL.createObjectURL(A),P=document.createElement("a");P.href=$,P.download="vector-studio-export.svg",P.click(),URL.revokeObjectURL($),zs(!1)},cf=x=>{const $=of(fs&&x==="png"),P=document.createElement("canvas");P.width=o,P.height=c;const z=P.getContext("2d"),Q=new Image,ee=new Blob([$],{type:"image/svg+xml"}),re=URL.createObjectURL(ee);Q.onload=()=>{x==="jpg"&&(z.fillStyle="white",z.fillRect(0,0,o,c)),z.drawImage(Q,0,0);const be=P.toDataURL(x==="png"?"image/png":"image/jpeg",.95),Ee=document.createElement("a");Ee.href=be,Ee.download=`vector-studio-export.${x}`,Ee.click(),URL.revokeObjectURL(re)},Q.onerror=()=>{URL.revokeObjectURL(re),zs(!1),alert("Export failed to render. Please try again.")},Q.src=re,zs(!1)},Fr=async()=>{const x=await n();if(!x.ok){i(x.error)||alert(x.error);return}lf()},Kr=async x=>{const A=await n();if(!A.ok){i(A.error)||alert(A.error);return}cf(x)},Bs=x=>
6882{if(x.points&&x.points.length>=2&&(x.type==="polygon"||x.type==="star"))return x.points.map(re=>`${re.x},${re.y}`).join(" ");const A=x.x+x.width/2,$=x.y+x.height/2,P=x.width/2,z=x.height/2,Q=x.sides||6;if(x.type==="star"){const re=Math.min(P,z),be=re*(x.starInnerRadius||.4),Ee=[];for(let Te=0;Te<Q*2;Te++){const Be=Te*Math.PI/Q-Math.PI/2,Ze=Te%2===0?re:be;Ee.push(`${A+Ze*Math.cos(Be)},${$+Ze*Math.sin(Be)}`)}return Ee.join(" ")}const ee=[];for(let re=0;re<Q;re++){const be=2*Math.PI*re/Q-Math.PI/2;ee.push(`${A+P*Math.cos(be)},${$+z*Math.sin(be)}`)}return ee.join(" ")},Ca=(x,A)=>{var en,Ln,Dn;if(!((en=x.pathNodes)!=null&&en.length))return null;const $=(A==null?void 0:A.interactive)??!0,P=(A==null?void 0:A.showHandles)??$,z=((Ln=_t.current)==null?void 0:Ln.objId)===x.id?_t.current:null,Q=(kt==null?void 0:kt.objId)===x.id?kt:null,ee="#2563eb",re=Ub(x),be=(Dn=x.pathContours)!=null&&Dn.length?x.pathContours:[x.pathNodes],Ee=Nn(UH),Te=Ee+Nn(p3),Be=Nn(FH),Ze=Nn(oNe),Fe=Nn(lNe),Gt=Fe+Nn(p3),Tt=Nn(cNe),Bt=Nn(uNe);return d.jsx("g",{transform:re,children:be.map((Os,Rn)=>Os.map((On,Ss)=>{const Dr=(z==null?void 0:z.nodeIndex)===Ss&&(z.contourIndex??0)===Rn,Us=(Q==null?void 0:Q.nodeIndex)===Ss&&Q.contourIndex===Rn,is=P&&(Dr||Us),Yr=$&&(Us||Dr&&(z==null?void 0:z.kind)==="anchor");return d.jsxs("g",{children:[$&&is&&On.handleIn&&d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:On.x,y1:On.y,x2:On.handleIn.x,y2:On.handleIn.y,stroke:ee,strokeWidth:Bt,pointerEvents:"none"}),d.jsx("circle",{cx:On.handleIn.x,cy:On.handleIn.y,r:Gt,fill:"transparent",stroke:"none",style:{cursor:"pointer"},onPointerDown:di=>cc(di,x.id,Ss,"handleIn",Rn)}),d.jsx("circle",{cx:On.handleIn.x,cy:On.handleIn.y,r:Fe,fill:ee,stroke:"#ffffff",strokeWidth:Tt,pointerEvents:"none"})]}),$&&is&&On.handleOut&&d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:On.x,y1:On.y,x2:On.handleOut.x,y2:On.handleOut.y,stroke:ee,strokeWidth:Bt,pointerEvents:"none"}),d.jsx("circle",{cx:On.handleOut.x,cy:On.handleOut.y,r:Gt,fill:"transparent",stroke:"none",style:{cursor:"pointer"},onPointerDown:di=>cc(di,x.id,Ss,"handleOut",Rn)}),d.jsx("circle",{cx:On.handleOut.x,cy:On.handleOut.y,r:Fe,fill:ee,stroke:"#ffffff",strokeWidth:Tt,pointerEvents:"none"})]}),Yr&&d.jsx("circle",{cx:On.x,cy:On.y,r:Ze,fill:"none",stroke:"#ef4444",strokeWidth:Be,pointerEvents:"none"}),$&&d.jsx("circle",{cx:On.x,cy:On.y,r:Te,fill:"transparent",stroke:"none",style:{cursor:"pointer"},onPointerDown:di=>cc(di,x.id,Ss,"anchor",Rn)}),d.jsx("circle",{cx:On.x,cy:On.y,r:Ee,fill:"#ffffff",stroke:ee,strokeWidth:Be,style:{cursor:$?"pointer":"default"},pointerEvents:"none"})]},`${x.id}-contour-${Rn}-node-${Ss}`)}))},`direct-path-${x.id}`)},nl=()=>{if(!Xn||!Jn||!Gs)return null;const x=Math.min(Jn.x,Gs.x),A=Math.min(Jn.y,Gs.y),$=Math.abs(Gs.x-Jn.x),P=Math.abs(Gs.y-Jn.y);return d.jsx("rect",{x,y:A,width:$,height:P,fill:"rgba(71, 255, 114, 0.12)",stroke:"#47ff72",strokeWidth:1,strokeDasharray:"4 2",pointerEvents:"none"})},Ud=(x,A)=>{const $=Nn(aNe),P=Nn(5),z=Nn(BH),Q=Nn(2);return d.jsxs("g",{"data-transform-origin":"true",transform:`translate(${x} ${A})`,style:{cursor:"move"},onPointerDown:ee=>{ee.stopPropagation(),$r(),!(!yi||xr.length===0)&&(pn.current="transform-origin",Wr(ee))},children:[d.jsx("circle",{r:$,fill:"white",stroke:"#47ff72",strokeWidth:z}),d.jsx("line",{x1:-P,y1:0,x2:P,y2:0,stroke:"#47ff72",strokeWidth:z,pointerEvents:"none"}),d.jsx("line",{x1:0,y1:-P,x2:0,y2:P,stroke:"#47ff72",strokeWidth:z,pointerEvents:"none"}),d.jsx("circle",{r:Q,fill:"#47ff72",pointerEvents:"none"})]})},qc=()=>{const x=xr.filter(Un=>!Un.locked),A=zy(x),$=(A==null?void 0:A.axisBounds)??null;if(M!=="select"||!A||!$||x.length===0)return null;const P=A,z=Xo,Q=Q2(P,z.u,z.v),ee="#47ff72",re=Nn(tNe),be=re+Nn(f3),Ee=Nn(nNe),Te=Ee+Nn(f3),Be=Nn(BH),Ze=Nn(rNe),Fe=Nn(8),Gt=Nn(6),Tt=Nn(sNe/2),Bt=Tt+Nn(f3),en=Bt+Nn(2),Ln=$s?"grabbing":"move",Dn=P.rotationDeg,Os=Qs&&gi!==null?gi:Dn,Rn=Qs&&gi!==null?`${Math.round(gi)}°`:null,On=(Un,_r)=>{var Po;Un.stopPropagation(),$r(),C();const Fs=fo(Un),vr=Math.atan2(Fs.y-_r.y,Fs.x-_r.x)*(180/Math.PI),Ii=xr.filter(vc=>!vc.locked).map(vc=>id(vc)),mf=Ii.length===1?((Po=Ii[0])==null?void 0:Po.rotation)||0:P.oriented?P.rotationDeg:0;pn.current="rotate",Wr(Un),ti(!0),yr(mf),Va({center:_r,startAngle:vr,snapshots:Ii})};if(x.length===1&&x[0].type==="line"){const Un=x[0],_r=Un.points&&Un.points.length>=2?Un.points:[{x:Un.x,y:Un.y},{x:Un.x+Un.width,y:Un.y+Un.height}],[Fs,vr]=_r,Ii={x:(Fs.x+vr.x)/2,y:(Fs.y+vr.y)/2},mf=Ub(Un),Po=vr.x-Fs.x,vc=vr.y-Fs.y,Xc=Math.hypot(Po,vc)||1,bc=-vc/Xc,Jc=Po/Xc,Kd=Nn(iNe),Ml=Ii.x+bc*Kd,wc=Ii.y+Jc*Kd,Qc=Rn?{x:Ml,y:wc-Nn(18)}:null;return d.jsxs("g",{transform:mf,children:[d.jsx("line",{x1:Fs.x,y1:Fs.y,x2:vr.x,y2:vr.y,stroke:ee,strokeWidth:1.5,strokeDasharray:"4 2",pointerEvents:"none"}),d.jsx("line",{"data-selection-move":"true",x1:Fs.x,y1:Fs.y,x2:vr.x,y2:vr.y,stroke:"transparent",strokeWidth:Math.max(Nn(12),en*2),style:{cursor:Ln},onPointerDown:uc}),d.jsx("line",{x1:Ii.x+bc*Gt,y1:Ii.y+Jc*Gt,x2:Ml-bc*Fe,y2:wc-Jc*Fe,stroke:ee,strokeWidth:Be,pointerEvents:"none"}),Ud(Ii.x,Ii.y),d.jsx("circle",{"data-rotate-handle":"true",cx:Ml,cy:wc,r:Te,fill:"transparent",stroke:"none",style:{cursor:Qs?"grabbing":"grab"},onPointerDown:Pl=>On(Pl,Ii)}),d.jsx("circle",{cx:Ml,cy:wc,r:Ee,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"}),Rn&&Qc&&d.jsx("text",{x:Qc.x,y:Qc.y,textAnchor:"middle",dominantBaseline:"auto",fill:"#0f172a",stroke:"#ffffff",strokeWidth:Nn(3),paintOrder:"stroke",fontSize:Nn(12),fontFamily:"ui-monospace, monospace",fontWeight:600,pointerEvents:"none",children:Rn}),d.jsx("circle",{cx:Fs.x,cy:Fs.y,r:be,fill:"transparent",stroke:"none",style:{cursor:"pointer"},onPointerDown:Pl=>cc(Pl,Un.id,0,"anchor")}),d.jsx("circle",{cx:Fs.x,cy:Fs.y,r:re,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"}),d.jsx("circle",{cx:vr.x,cy:vr.y,r:be,fill:"transparent",stroke:"none",style:{cursor:"pointer"},onPointerDown:Pl=>cc(Pl,Un.id,1,"anchor")}),d.jsx("circle",{cx:vr.x,cy:vr.y,r:re,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"})]},"selection-overlay-line")}const Ss=(Un,_r,Fs)=>d.jsxs("g",{children:[d.jsx("circle",{"data-resize-handle":Un,cx:_r,cy:Fs,r:be,fill:"transparent",stroke:"none",style:{cursor:`${Un}-resize`},onPointerDown:vr=>Dd(vr,Un)}),d.jsx("circle",{cx:_r,cy:Fs,r:re,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"})]},Un),Dr=(Un,_r,Fs)=>d.jsxs("g",{children:[d.jsx("rect",{"data-resize-handle":Un,x:_r-Bt,y:Fs-Bt,width:Bt*2,height:Bt*2,fill:"transparent",stroke:"none",style:{cursor:`${Un}-resize`},onPointerDown:vr=>Dd(vr,Un)}),d.jsx("rect",{x:_r-Tt,y:Fs-Tt,width:Tt*2,height:Tt*2,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"})]},Un);if(P.oriented){const Un=zy(x)??P,{nw:_r,ne:Fs,se:vr,sw:Ii}=LM(Un),mf=`${_r.x}
6882,${_r.y} ${Fs.x},${Fs.y} ${vr.x},${vr.y} ${Ii.x},${Ii.y}`,Po={x:(_r.x+Fs.x)/2,y:(_r.y+Fs.y)/2},vc=Q2(Un,z.u,z.v),Xc=vc.x,bc=vc.y;let Jc=Po.x-Xc,Kd=Po.y-bc,Ml=Math.hypot(Jc,Kd);if(Ml<1e-6){const Cp=Os*Math.PI/180;Jc=-Math.sin(Cp),Kd=Math.cos(Cp),Ml=1}const wc=Jc/Ml,Qc=Kd/Ml,Pl=Xc+wc*(Ml+Ze),gf=bc+Qc*(Ml+Ze),Jm=Rn?{x:Pl,y:gf-Nn(18)}:null,ry={x:(Fs.x+vr.x)/2,y:(Fs.y+vr.y)/2},Qm={x:(_r.x+Ii.x)/2,y:(_r.y+Ii.y)/2},iy={x:(Ii.x+vr.x)/2,y:(Ii.y+vr.y)/2},_c=$Ie(Un,en),Kv=_c?`${_c.nw.x},${_c.nw.y} ${_c.ne.x},${_c.ne.y} ${_c.se.x},${_c.se.y} ${_c.sw.x},${_c.sw.y}`:null;return d.jsxs("g",{children:[d.jsx("polygon",{points:mf,fill:"none",stroke:ee,strokeWidth:Be,strokeDasharray:"4 2",pointerEvents:"none"}),Kv&&d.jsx("polygon",{"data-selection-move":"true",points:Kv,fill:"transparent",stroke:"none",style:{cursor:Ln},onPointerDown:uc}),d.jsx("line",{x1:Xc+wc*Gt,y1:bc+Qc*Gt,x2:Pl-wc*Fe,y2:gf-Qc*Fe,stroke:ee,strokeWidth:Be,pointerEvents:"none"}),Ud(Xc,bc),d.jsx("circle",{"data-rotate-handle":"true",cx:Pl,cy:gf,r:Te,fill:"transparent",stroke:"none",style:{cursor:Qs?"grabbing":"grab"},onPointerDown:Cp=>On(Cp,{x:Xc,y:bc})}),d.jsx("circle",{cx:Pl,cy:gf,r:Ee,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"}),Ss("nw",_r.x,_r.y),Ss("ne",Fs.x,Fs.y),Ss("se",vr.x,vr.y),Ss("sw",Ii.x,Ii.y),Dr("n",Po.x,Po.y),Dr("s",iy.x,iy.y),Dr("e",ry.x,ry.y),Dr("w",Qm.x,Qm.y),Rn&&Jm&&d.jsx("text",{x:Jm.x,y:Jm.y,textAnchor:"middle",dominantBaseline:"auto",fill:"#0f172a",stroke:"#ffffff",strokeWidth:Nn(3),paintOrder:"stroke",fontSize:Nn(12),fontFamily:"ui-monospace, monospace",fontWeight:600,pointerEvents:"none",children:Rn})]},"selection-overlay")}const Us=$,is=Q.x,Yr=Q.y,di={x:Us.cx,y:Us.y};let Kc=di.x-is,Gu=di.y-Yr,wi=Math.hypot(Kc,Gu);wi<1e-6&&(Kc=0,Gu=-1,wi=1);const sl=Kc/wi,Yc=Gu/wi,xc=is+sl*(wi+Ze),Xr=Yr+Yc*(wi+Ze),Vr=RH,Ym=Us.x+en,Ap=Us.y+en,pf=Us.width-en*2,Xm=Us.height-en*2;return d.jsxs("g",{children:[d.jsx("rect",{x:Us.x-1,y:Us.y-1,width:Us.width+2,height:Us.height+2,fill:"none",stroke:ee,strokeWidth:Be,strokeDasharray:"4 2",pointerEvents:"none"}),pf>0&&Xm>0&&d.jsx("rect",{"data-selection-move":"true",x:Ym,y:Ap,width:pf,height:Xm,fill:"transparent",stroke:"none",style:{cursor:Ln},onPointerDown:uc}),d.jsx("line",{x1:is+sl*Gt,y1:Yr+Yc*Gt,x2:xc-sl*Fe,y2:Xr-Yc*Fe,stroke:ee,strokeWidth:Be,pointerEvents:"none"}),Ud(is,Yr),d.jsx("circle",{"data-rotate-handle":"true",cx:xc,cy:Xr,r:Te,fill:"transparent",stroke:"none",style:{cursor:Qs?"grabbing":"grab"},onPointerDown:Un=>On(Un,{x:is,y:Yr})}),d.jsx("circle",{cx:xc,cy:Xr,r:Ee,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"}),Vr.map(Un=>{let _r=Us.x,Fs=Us.y;return Un.includes("e")&&(_r=Us.x+Us.width),Un.includes("w")&&(_r=Us.x),Un.includes("s")&&(Fs=Us.y+Us.height),Un.includes("n")&&(Fs=Us.y),(Un==="n"||Un==="s")&&(_r=Us.cx),(Un==="e"||Un==="w")&&(Fs=Us.cy),d.jsxs("g",{children:[d.jsx("rect",{"data-resize-handle":Un,x:_r-Bt,y:Fs-Bt,width:Bt*2,height:Bt*2,fill:"transparent",stroke:"none",style:{cursor:`${Un}-resize`},onPointerDown:vr=>Dd(vr,Un)}),d.jsx("rect",{x:_r-Tt,y:Fs-Tt,width:Tt*2,height:Tt*2,fill:"white",stroke:ee,strokeWidth:Be,pointerEvents:"none"})]},Un)}),Rn&&d.jsx("text",{x:xc,y:Xr-Nn(18),textAnchor:"middle",dominantBaseline:"auto",fill:"#0f172a",stroke:"#ffffff",strokeWidth:Nn(3),paintOrder:"stroke",fontSize:Nn(12),fontFamily:"ui-monospace, monospace",fontWeight:600,pointerEvents:"none",children:Rn})]},"selection-overlay")},bp=()=>{if(M!=="select"||!$s)return null;const x=za??ji.current;if(!x)return null;const{vertical:A,horizontal:$,spacingH:P=[],spacingV:z=[]}=x;if(A.length===0&&$.length===0&&P.length===0&&z.length===0)return null;const Q="#ef4444",ee="#eab308",re="#ef4444",be=Math.max(8,10/ot),Ee=4/ot,Te=3/ot,Be=(Fe,Gt,Tt,Bt)=>d.jsxs("g",{children:[d.jsx("line",{x1:Fe,y1:Tt,x2:Gt,y2:Tt,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Fe,y1:Tt,x2:Fe+Te,y2:Tt-Te,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Fe,y1:Tt,x2:Fe+Te,y2:Tt+Te,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Gt,y1:Tt,x2:Gt-Te,y2:Tt-Te,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Gt,y1:Tt,x2:Gt-Te,y2:Tt+Te,stroke:re,strokeWidth:1/ot})]},Bt),Ze=(Fe,Gt,Tt,Bt)=>d.jsxs("g",{children:[d.jsx("line",{x1:Tt,y1:Fe,x2:Tt,y2:Gt,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Tt,y1:Fe,x2:Tt-Te,y2:Fe+Te,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Tt,y1:Fe,x2:Tt+Te,y2:Fe+Te,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Tt,y1:Gt,x2:Tt-Te,y2:Gt-Te,stroke:re,strokeWidth:1/ot}),d.jsx("line",{x1:Tt,y1:Gt,x2:Tt+Te,y2:Gt-Te,stroke:re,strokeWidth:1/ot})]},Bt);return d.jsxs("g",{pointerEvents:"none",children:[A.map((Fe,Gt)=>{var Dn,Os;const Tt=Fe.kind==="center"?ee:Q,Bt=(Fe.y1+Fe.y2)/2,en=Fe.x+6/ot,Ln=Fe.labelValue!==void 0?v5(Fe.labelValue):null;return d.jsxs("g",{children:[d.jsx("line",{x1:Fe.x,y1:Fe.y1,x2:Fe.x,y2:Fe.y2,stroke:Tt,strokeWidth:1/ot}),(Dn=Fe.tickYs)==null?void 0:Dn.map((Rn,On)=>d.jsx("line",{x1:Fe.x-Ee,y1:Rn,x2:Fe.x+Ee,y2:Rn,stroke:Tt,strokeWidth:1/ot},`tick-v-${Gt}-${On}`)),Ln&&d.jsx("text",{x:en,y:Bt,fill:Tt,fontSize:be,fontFamily:"Inter, system-ui, sans-serif",dominantBaseline:"middle",children:Ln})]}
6882,`guide-v-${Gt}-${Fe.x.toFixed(2)}-${((Os=Fe.labelValue)==null?void 0:Os.toFixed(2))??"c"}`)}),$.map((Fe,Gt)=>{var Os;const Tt=Fe.kind==="center"?ee:Q,Bt=(Fe.x1+Fe.x2)/2,en=Fe.y-6/ot,Ln=Fe.labelValue!==void 0?v5(Fe.labelValue):null,Dn=Fe.kind==="edge"&&P.some(Rn=>Rn.x1>=Fe.x1-1&&Rn.x2<=Fe.x2+1);return d.jsxs("g",{children:[d.jsx("line",{x1:Fe.x1,y1:Fe.y,x2:Fe.x2,y2:Fe.y,stroke:Tt,strokeWidth:1/ot}),(Os=Fe.tickXs)==null?void 0:Os.map((Rn,On)=>d.jsx("line",{x1:Rn,y1:Fe.y-Ee,x2:Rn,y2:Fe.y+Ee,stroke:Tt,strokeWidth:1/ot},`tick-h-${Gt}-${On}`)),Ln&&!Dn&&d.jsx("text",{x:Bt,y:en,fill:Tt,fontSize:be,fontFamily:"Inter, system-ui, sans-serif",textAnchor:"middle",dominantBaseline:"auto",children:Ln})]},`guide-h-${Gt}-${Fe.y.toFixed(2)}`)}),P.map((Fe,Gt)=>d.jsxs("g",{children:[Be(Fe.x1,Fe.x2,Fe.y,`spacing-h-arrow-${Gt}`),d.jsx("text",{x:(Fe.x1+Fe.x2)/2,y:Fe.y-5/ot,fill:re,fontSize:be,fontFamily:"Inter, system-ui, sans-serif",textAnchor:"middle",dominantBaseline:"auto",children:jH(Fe.distance)})]},`spacing-h-${Gt}-${Fe.x1.toFixed(1)}-${Fe.y.toFixed(1)}-${Fe.distance.toFixed(2)}`)),z.map((Fe,Gt)=>d.jsxs("g",{children:[Ze(Fe.y1,Fe.y2,Fe.x,`spacing-v-arrow-${Gt}`),d.jsx("text",{x:Fe.x+5/ot,y:(Fe.y1+Fe.y2)/2,fill:re,fontSize:be,fontFamily:"Inter, system-ui, sans-serif",dominantBaseline:"middle",children:jH(Fe.distance)})]},`spacing-v-${Gt}-${Fe.y1.toFixed(1)}-${Fe.x.toFixed(1)}-${Fe.distance.toFixed(2)}`))]},"snapping-guides")},uf=(x,A)=>{const $=pR(x,A);return $==="none"?"none":Ff(x,A)?`url(#${o3(x.id,A)})`:$},Wc=()=>{const x=b.filter(A=>A.visible).flatMap(A=>["fill","stroke"].map($=>({obj:A,channel:$,gradient:ix(A,$)})).filter($=>Ff($.obj,$.channel)&&$.gradient));return x.length===0?null:d.jsx("defs",{children:x.map(({obj:A,channel:$,gradient:P})=>{const z=Ji(P),Q=o3(A.id,$),ee=p5(z);if(z.style==="radial")return d.jsx("radialGradient",{id:Q,cx:"50%",cy:"50%",r:"50%",children:ee.map((Te,Be)=>d.jsx("stop",{offset:`${Te.offset}%`,stopColor:Te.color,stopOpacity:Te.opacity/100},`${Q}-s-${Be}`))},Q);const re=z.angle*Math.PI/180,be=Math.cos(re)*.5,Ee=Math.sin(re)*.5;return d.jsx("linearGradient",{id:Q,x1:`${(.5-be)*100}%`,y1:`${(.5-Ee)*100}%`,x2:`${(.5+be)*100}%`,y2:`${(.5+Ee)*100}%`,children:ee.map((Te,Be)=>d.jsx("stop",{offset:`${Te.offset}%`,stopColor:Te.color,stopOpacity:Te.opacity/100},`${Q}-s-${Be}`))},Q)})})},Fd=x=>{if(!x.visible)return null;const A=Ub(x),$=uf(x,"fill"),P=uf(x,"stroke"),z=$!=="none"&&!Ff(x,"fill")?Jp(x,"fill")/100:void 0,Q=P!=="none"&&!Ff(x,"stroke")?Jp(x,"stroke")/100:void 0,ee={fillOpacity:z,strokeOpacity:Q},re={"data-object-id":x.id,pointerEvents:x.locked?"none":void 0,style:x.locked?void 0:{cursor:M==="select"?"move":M==="direct"?"default":M==="pen"?i3:"crosshair"},opacity:x.opacity,transform:A};let be=null;if(ro(x)&&x.pathNodes){const Ee=!!(x.pathContours&&x.pathContours.length>1),Te=x.pathClosed===!1?"none":$;be=d.jsx("path",{...re,d:Ee?t3(x.pathContours,x.pathClosed!==!1):pS(x.pathNodes,x.pathClosed!==!1),fill:Te,fillRule:Ee?"evenodd":void 0,clipRule:Ee?"evenodd":void 0,stroke:P,strokeWidth:x.strokeWidth,...ee})}else switch(x.type){case"rect":if(x.points&&x.points.length===4)be=d.jsx("polygon",{...re,points:x.points.map(Ee=>`${Ee.x},${Ee.y}`).join(" "),fill:$,stroke:P,strokeWidth:x.strokeWidth,...ee});else{const Ee=Jy(x);zg(Ee)?be=d.jsx("rect",{...re,x:x.x,y:x.y,width:x.width,height:x.height,rx:Ee.tl>0?Ee.tl:void 0,ry:Ee.tl>0?Ee.tl:void 0,fill:$,stroke:P,strokeWidth:x.strokeWidth,...ee}):be=d.jsx("path",{...re,d:e3(x.x,x.y,x.width,x.height,x.cornerRadius??0,x.cornerRadii),fill:$,stroke:P,strokeWidth:x.strokeWidth,...ee})}break;case"ellipse":be=d.jsx("ellipse",{...re,cx:x.x+x.width/2,cy:x.y+x.height/2,rx:x.width/2,ry:x.height/2,fill:$,stroke:P,strokeWidth:x.strokeWidth,...ee});break;case"polygon":case"star":be=d.jsx("polygon",{...re,points:Bs(x),fill:$,stroke:P,strokeWidth:x.strokeWidth,...ee});break;case"line":x.points&&x.points.length>=2&&(be=d.jsx("line",{...re,x1:x.points[0].x,y1:x.points[0].y,x2:x.points[1].x,y2:x.points[1].y,stroke:P,strokeWidth:x.strokeWidth,strokeOpacity:Q}));break;case"text":{const Ee=ls===x.id;be=d.jsxs(d.Fragment,{children:[!Ee&&d.jsx("foreignObject",{x:x.x,y:x.y,width:x.width,height:x.height,transform:A,style:{pointerEvents:"none"},children:d.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",style:mIe(x),children:x.text||""})}),Ee&&d.jsx("rect",{x:x.x,y:x.y,width:x.width,height:x.height,fill:"rgba(71, 255, 114, 0.06)",stroke:"#47ff72",strokeWidth:1.5,strokeDasharray:"4 2",pointerEvents:"none",transform:A}),d.jsx("rect",{"data-object-id":x.id,x:x.x,y:x.y,width:x.width,height:x.height,fill:"transparent",stroke:"none",pointerEvents:x.locked||M==="direct"?"none":"auto",style:x.locked?void 0:{cursor:M==="select"?"move":M==="type"?"text":M==="pen"?i3:"crosshair"},transform:A,onDoubleClick:Te=>{Te.stopPropagation(),!x.locked&&M!=="direct"&&Nd(x.id)}})]});break}}return d.jsx("g",{children:be},x.id)},Vd=x=>{var P;if(!x.visible||x.locked||M!=="select"||!E.includes(x.id))return null;const $={fill:"none",stroke:"#2563eb",strokeWidth:1.25,vectorEffect:"non-scaling-stroke",pointerEvents:"none",transform:Ub(x)};if(ro(x)&&x.pathNodes){const z=(P=x.pathContours)!=null&&P.length?t3(x.pathContours,x.pathClosed!==!1):pS(x.pathNodes,x.pathClosed!==!1);return d.jsx("path",{d:z,...$},`selected-outline-${x.id}`)}
6882switch(x.type){case"rect":if(x.points&&x.points.length===4)return d.jsx("polygon",{points:x.points.map(z=>`${z.x},${z.y}`).join(" "),...$},`selected-outline-${x.id}`);{const z=Jy(x);return zg(z)?d.jsx("rect",{x:x.x,y:x.y,width:x.width,height:x.height,rx:z.tl>0?z.tl:void 0,ry:z.tl>0?z.tl:void 0,...$},`selected-outline-${x.id}`):d.jsx("path",{d:e3(x.x,x.y,x.width,x.height,x.cornerRadius??0,x.cornerRadii),...$},`selected-outline-${x.id}`)}case"ellipse":return d.jsx("ellipse",{cx:x.x+x.width/2,cy:x.y+x.height/2,rx:x.width/2,ry:x.height/2,...$},`selected-outline-${x.id}`);case"polygon":case"star":return d.jsx("polygon",{points:Bs(x),...$},`selected-outline-${x.id}`);case"line":return!x.points||x.points.length<2?null:d.jsx("line",{x1:x.points[0].x,y1:x.points[0].y,x2:x.points[1].x,y2:x.points[1].y,...$},`selected-outline-${x.id}`);case"text":return d.jsx("rect",{x:x.x,y:x.y,width:x.width,height:x.height,...$},`selected-outline-${x.id}`);default:return null}},zd=()=>{if(!me||!De||!yt)return null;const x=(ms||Le.current)&&M!=="type"?r3(De,yt,M):yt,A=Math.min(De.x,x.x),$=Math.min(De.y,x.y),P=Math.abs(x.x-De.x),z=Math.abs(x.y-De.y),Q=pt?"none":We,ee=hn?"none":Ae;switch(M){case"rect":return d.jsx("rect",{x:A,y:$,width:P,height:z,fill:Q,stroke:ee,strokeWidth:ft,opacity:.7});case"roundedRect":{const re=mH(P,z);return d.jsx("rect",{x:A,y:$,width:P,height:z,rx:re,ry:re,fill:Q,stroke:ee,strokeWidth:ft,opacity:.7})}case"ellipse":return d.jsx("ellipse",{cx:A+P/2,cy:$+z/2,rx:P/2,ry:z/2,fill:Q,stroke:ee,strokeWidth:ft,opacity:.7});case"triangle":{const re=`${A+P/2},${$} ${A+P},${$+z} ${A},${$+z}`;return d.jsx("polygon",{points:re,fill:Q,stroke:ee,strokeWidth:ft,opacity:.7})}case"star":{const re=A+P/2,be=$+z/2,Ee=Math.min(P,z)/2,Te=Ee*.4,Be=[];for(let Ze=0;Ze<10;Ze++){const Fe=Ze*Math.PI/5-Math.PI/2,Gt=Ze%2===0?Ee:Te;Be.push(`${re+Gt*Math.cos(Fe)},${be+Gt*Math.sin(Fe)}`)}return d.jsx("polygon",{points:Be.join(" "),fill:Q,stroke:ee,strokeWidth:ft,opacity:.7})}case"diamond":{const re=`${A+P/2},${$} ${A+P},${$+z/2} ${A+P/2},${$+z} ${A},${$+z/2}`;return d.jsx("polygon",{points:re,fill:Q,stroke:ee,strokeWidth:ft,opacity:.7})}case"hexagon":{const re=A+P/2,be=$+z/2,Ee=[];for(let Te=0;Te<6;Te++){const Be=2*Math.PI*Te/6-Math.PI/2;Ee.push(`${re+P/2*Math.cos(Be)},${be+z/2*Math.sin(Be)}`)}return d.jsx("polygon",{points:Ee.join(" "),fill:Q,stroke:ee,strokeWidth:ft,opacity:.7})}case"line":return d.jsx("line",{x1:De.x,y1:De.y,x2:x.x,y2:x.y,stroke:ee,strokeWidth:ft,opacity:.7});default:if(M==="type"){let re=Math.min(De.x,x.x),be=Math.min(De.y,x.y),Ee=Math.abs(x.x-De.x),Te=Math.abs(x.y-De.y);return Ee<4&&Te<4?(Ee=200,Te=56):(Ee=Math.max(h5,Ee),Te=Math.max(IE,Te)),d.jsx("rect",{x:re,y:be,width:Ee,height:Te,fill:"rgba(71, 255, 114, 0.08)",stroke:"#47ff72",strokeWidth:1.5,strokeDasharray:"4 2",opacity:.9})}return null}},wp=()=>
6882{if(M!=="pen"||!Nt||Nt.nodes.length===0)return null;const x=AH/Math.max(ot,1e-6),A=Nt.nodes[0],$=!!(zt&&Nt.nodes.length>=3&&x5(zt,A)<=x),P=$?A:zt,z=hn?"#1e40af":Ae,Q=pt?"none":We,ee=pS(Nt.nodes,Nt.closed),re=Nt.nodes[Nt.nodes.length-1],be=Nn(dNe),Ee=Nn(VH),Te=Nn(1.1);return d.jsxs("g",{pointerEvents:"none",children:[ee&&d.jsx("path",{d:ee,fill:Nt.closed?Q:"none",stroke:z,strokeWidth:ft,opacity:.85}),P&&re&&d.jsx("line",{x1:re.x,y1:re.y,x2:P.x,y2:P.y,stroke:$?"#16a34a":"#2563eb",strokeWidth:Te,strokeDasharray:"4 3",opacity:.9}),Nt.nodes.map((Be,Ze)=>d.jsx("circle",{cx:Be.x,cy:Be.y,r:be,fill:Ze===0&&$?"#16a34a":"#ffffff",stroke:Ze===0?"#16a34a":"#2563eb",strokeWidth:Ee},`pen-node-${Ze}`))]},"pen-preview")},_p=()=>{if(M!=="pen"||Nt!=null&&Nt.nodes.length||!Zt)return null;const x=Nn(hNe),A=Nn(VH);return d.jsx("g",{pointerEvents:"none",children:d.jsx("circle",{cx:Zt.point.x,cy:Zt.point.y,r:x,fill:"white",stroke:"#2563eb",strokeWidth:A})},"pen-insert-hint")},po=x=>{gn&&ka(x)},ka=x=>{if(E.length===0)return;const A=new Set(["x","y","width","height"]),$=Object.keys(x).some(Q=>A.has(Q)),P=x.rotation!==void 0,z=x.opacity!==void 0;S(Q=>{var Ze;const ee=Q.filter(Fe=>E.includes(Fe.id)&&!Fe.locked);if(ee.length===0)return Q;const re=new Set(ee.map(Fe=>Fe.id)),be=ee.length>1,Ee=ee.map(Fe=>F.current.get(Fe.id)??Fe);let Te=null;be&&$&&(Te=qIe(Ee,x));const Be=Wb(Ee);if(P&&x.rotation!==void 0&&Be){const Fe=Sh(x.rotation),Gt=we.current??Sh(((Ze=Ee[0])==null?void 0:Ze.rotation)||0),Tt=Fe-Gt;if(we.current=Fe,Math.abs(Tt)>.001){const Bt=Ct.current??{u:.5,v:.5},en=zy(Ee),Ln=en?Q2(en,Bt.u,Bt.v):{x:Be.cx,y:Be.cy};return Q.map(Dn=>re.has(Dn.id)?Te!=null&&Te.has(Dn.id)?rI(Te.get(Dn.id),Ln.x,Ln.y,Tt):rI(Dn,Ln.x,Ln.y,Tt):Dn)}}return Q.map(Fe=>{if(!re.has(Fe.id))return Fe;if(Te!=null&&Te.has(Fe.id)){let en=Te.get(Fe.id);return z&&x.opacity!==void 0&&(en={...en,opacity:Math.min(1,Math.max(0,x.opacity))}),en}const Gt=F.current.get(Fe.id)??Fe;let Tt=HIe(Fe,Gt,x);return z&&x.opacity!==void 0&&(Tt={...Tt,opacity:Math.min(1,Math.max(0,x.opacity))}),Tt.type==="text"&&(Object.keys(x).some(en=>gIe.has(en))||x.width!==void 0&&!Tt.autoFit)&&(Tt=NH(Tt)),Tt})})},Fu=uo,pc=Xe.map(x=>x.rotation||0),df=Vt&&pc.some(x=>Math.abs(x-pc[0])>.01),kl=Xe.map(x=>x.opacity),mc=Vt&&kl.some(x=>Math.abs(x-kl[0])>.001),hf=df?"":String(Math.round(Sh(pc[0]??0))),Gd=mc?"":String(Math.round((kl[0]??1)*100)),Hd=Xe.filter(u5),Sp=Hd.length>0,qd=Hd.map(x=>{const A=Jy(x);return zg(A)?A.tl:Number.NaN}),gc=qd.some(x=>!Number.isFinite(x))||Vt&&qd.some(x=>Math.abs(x-qd[0])>.01),Wm=gc?"":String(Math.round(qd[0]??0)),Mo=!Vt&&gn&&u5(gn)?gn:null,Vu=Mo?Jy(Mo):null,ff=new Map;let Ep=1;b.forEach(x=>{(x.groupIds||[]).forEach(A=>{ff.has(A)||ff.set(A,`Group ${Ep++}`)})});const mo=(x=>{const A=[];for(const $ of x){let P=A;const z=$.groupIds||[];z.forEach((Q,ee)=>{let re=P.find(be=>be.kind==="group"&&be.groupId===Q);re||(re={kind:"group",groupId:Q,label:ff.get(Q)||`Group ${ee+1}`,depth:ee,children:[]},P.push(re)),P=re.children}),P.push({kind:"object",object:$,depth:z.length})}return A})(b),Ia=x=>[...x].reverse().map(A=>{var P,z,Q;if(A.kind==="group"){const ee=Id(A.groupId),re=ee.length>0&&ee.every(Ee=>E.includes(Ee)),be=!Yn.has(A.groupId);return d.jsxs("div",{className:"space-y-1",children:[d.jsxs("div",{onClick:Ee=>{if(Ee.shiftKey){const Te=ee.every(Be=>E.includes(Be));I(Be=>Te?Be.filter(Ze=>!ee.includes(Ze)):[...new Set([...Be,...ee])])}else I(ee)},className:`flex items-center gap-1.5 px-2 py-1.5 rounded-lg cursor-pointer transition-colors ${re?"bg-[#47ff72]/10 border border-[#47ff72]/30":"hover:bg-slate-50 dark:hover:bg-slate-800/50 border border-transparent"}`,style:{marginLeft:A.depth*12},children:[d.jsx("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),As(Te=>{const Be=new Set(Te);return Be.has(A.groupId)?Be.delete(A.groupId):Be.add(A.groupId),Be})},className:"p-0.5 -ml-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 flex-shrink-0",title:be?"Collapse group":"Expand group","aria-expanded":be,children:be?d.jsx(P0,{size:12}):d.jsx(cD,{size:12})}),d.jsx(Sd,{size:12,className:"text-slate-400 flex-shrink-0"}),d.jsx("span",{className:`flex-1 text-xs truncate ${re?"text-[#47ff72] font-semibold":"text-slate-600 dar
6882k:text-slate-300"}`,children:A.label}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx("button",{onClick:Ee=>{Ee.stopPropagation();const Te=!ee.every(Be=>{var Ze;return(Ze=b.find(Fe=>Fe.id===Be))==null?void 0:Ze.visible});S(Be=>Be.map(Ze=>(Ze.groupIds||[]).includes(A.groupId)?{...Ze,visible:Te}:Ze))},className:"p-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",title:"Toggle group visibility",children:ee.every(Ee=>{var Te;return(Te=b.find(Be=>Be.id===Ee))==null?void 0:Te.visible})?d.jsx(Yh,{size:11}):d.jsx(dD,{size:11})}),d.jsx("button",{onClick:Ee=>{Ee.stopPropagation();const Te=!ee.every(Be=>{var Ze;return(Ze=b.find(Fe=>Fe.id===Be))==null?void 0:Ze.locked});S(Be=>Be.map(Ze=>(Ze.groupIds||[]).includes(A.groupId)?{...Ze,locked:Te}:Ze)),Te&&I(Be=>Be.filter(Ze=>!ee.includes(Ze)))},className:"p-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",title:"Toggle group lock",children:ee.every(Ee=>{var Te;return(Te=b.find(Be=>Be.id===Ee))==null?void 0:Te.locked})?d.jsx(j1,{size:11}):d.jsx(LF,{size:11})}),d.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),rf(ee)},className:"p-0.5 text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Delete group",children:d.jsx(xl,{size:11})})]})]}),be&&A.children.length>0&&d.jsx("div",{className:"space-y-1",children:Ia(A.children)})]},`group-${A.groupId}`)}const $=A.object;return d.jsxs("div",{draggable:!0,onDragStart:ee=>{Ds($.id),ee.dataTransfer.effectAllowed="move"},onDragEnd:()=>{Ds(null),un(null)},onDragOver:ee=>{ee.preventDefault(),Mr&&Mr!==$.id&&un($.id)},onDragLeave:()=>un(ee=>ee===$.id?null:ee),onDrop:ee=>{ee.preventDefault(),Mr&&Mr!==$.id&&qm(Mr,$.id),Ds(null),un(null)},onClick:ee=>{const re=ia([$.id]);if(ee.shiftKey){const be=re.every(Ee=>E.includes(Ee));I(Ee=>be?Ee.filter(Te=>!re.includes(Te)):[...new Set([...Ee,...re])])}else I(re)},className:`flex items-center gap-1.5 px-2 py-1.5 rounded-lg cursor-pointer transition-colors ${Hs===$.id&&Mr!==$.id?"ring-2 ring-[#47ff72] ring-inset":E.includes($.id)?"bg-[#47ff72]/10 border border-[#47ff72]/30":"hover:bg-slate-50 dark:hover:bg-slate-800/50 border border-transparent"} ${Mr===$.id?"opacity-50":""}`,style:{marginLeft:A.depth*12},children:[d.jsx(Abe,{size:12,className:"text-slate-400 flex-shrink-0 cursor-grab"}),d.jsx("div",{className:"w-4 h-4 rounded flex-shrink-0",style:{...J2($.fill,$.fillMode||"solid",$.fillGradient,Jp($,"fill")),border:`1.5px solid ${$.stroke==="none"?"#cbd5e1":Ff($,"stroke")&&((Q=(z=(P=ix($,"stroke"))==null?void 0:P.stops)==null?void 0:z[0])==null?void 0:Q.color)||$.stroke}`}}),d.jsx("span",{className:`flex-1 text-xs truncate ${E.includes($.id)?"text-[#47ff72] font-semibold":"text-slate-600 dark:text-slate-300"}`,children:$.name}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx("button",{onClick:ee=>{ee.stopPropagation(),S(re=>re.map(be=>be.id===$.id?{...be,visible:!be.visible}:be))},className:"p-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",title:$.visible?"Hide":"Show",children:$.visible?d.jsx(Yh,{size:11}):d.jsx(dD,{size:11})}),d.jsx("button",{onClick:ee=>{ee.stopPropagation();const re=!$.locked;S(be=>be.map(Ee=>Ee.id===$.id?{...Ee,locked:re}:Ee)),re&&I(be=>be.filter(Ee=>Ee!==$.id))},className:"p-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",title:$.locked?"Unlock":"Lock",children:$.locked?d.jsx(j1,{size:11}):d.jsx(LF,{size:11})}),d.jsx("button",{onClick:ee=>{ee.stopPropagation(),ki($.id,"up")},className:"p-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",title:"Move up",children:d.jsx(Dve,{size:11})}),d.jsx("button",{onClick:ee=>{ee.stopPropagation(),ki($.id,"down")},className:"p-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",title:"Move down",children:d.jsx(Rve,{size:11})}),d.jsx("button",{onClick:ee=>{ee.stopPropagation(),rf([$.id])},className:"p-0.5 text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Delete",children:d.jsx(xl,{size:11})})]})]},$.id)}),yc=x=>{jt(x),Sn(x)},Tp=()=>{if(!Lt)return null;const x=Lt==="fill",A=x?Qe:je,$=Ji(x?bt:Dt),P=x?We:Ae,z=x?ge:nt,Q=re=>x?wr(re):qa(re),ee=re=>x?aa(re):No(re);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center justify-between mb-2",children:[d.jsxs("h4",{className:"text-xs font-bold text-slate-700 dark:text-slate-200 uppercase tracking-wide",children:[x?"Fill":"Stroke"," Paint"]}),d.jsx("button",{type:"button",onClick:()=>Wt(null),className:"text-[10px] text-slate-400 hover:text-slate-600 dar
6882k:hover:text-slate-200 lg:hidden p-1","aria-label":"Close paint panel",children:d.jsx(Ki,{size:16})}),d.jsx("button",{type:"button",onClick:()=>Wt(null),className:"text-[10px] text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 hidden lg:inline",children:"Close"})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-1 mb-3",children:[d.jsx("button",{type:"button",onClick:()=>ef(Lt,"solid"),className:`h-7 rounded-md text-xs border ${A==="solid"?"border-[#47ff72] bg-[#47ff72]/10 text-[#47ff72]":"border-slate-200 dark:border-slate-700 text-slate-500"}`,children:"Solid"}),d.jsx("button",{type:"button",onClick:()=>ef(Lt,"gradient"),className:`h-7 rounded-md text-xs border ${A==="gradient"?"border-[#47ff72] bg-[#47ff72]/10 text-[#47ff72]":"border-slate-200 dark:border-slate-700 text-slate-500"}`,children:"Gradient"})]}),A==="solid"?d.jsxs("div",{className:"space-y-2",children:[d.jsx("input",{type:"color",value:P,onChange:re=>Q(re.target.value),className:"w-full h-9 rounded border border-slate-200 dark:border-slate-700 cursor-pointer"}),d.jsx("input",{type:"text",value:P,onChange:re=>Q(re.target.value),className:"w-full h-8 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 font-mono text-slate-700 dark:text-slate-300"}),d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-400 font-bold uppercase",children:[d.jsx("span",{children:"Opacity"}),d.jsxs("span",{className:"font-mono text-slate-500 normal-case",children:[Math.round(z),"%"]})]}),d.jsx("div",{className:"px-1 mt-1 pb-0.5",children:d.jsx("input",{type:"range",min:0,max:100,value:z,onChange:re=>ee(parseFloat(re.target.value)||0),className:"block w-full h-5 accent-[#47ff72]"})})]})]}):d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Style"}),d.jsxs("select",{value:$.style,onChange:re=>(x?oc:Du)(be=>({...be,style:re.target.value==="radial"?"radial":"linear"})),className:"w-full h-8 mt-1 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300",children:[d.jsx("option",{value:"linear",children:"Linear"}),d.jsx("option",{value:"radial",children:"Radial"})]})]}),$.style==="linear"&&d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Angle"}),d.jsxs("div",{className:"flex items-center gap-2 mt-1 min-w-0",children:[d.jsx("div",{className:"flex-1 min-w-0 px-1",children:d.jsx("input",{type:"range",min:0,max:360,step:1,value:$.angle,onChange:re=>(x?oc:Du)(be=>({...be,angle:parseFloat(re.target.value)||0})),className:"block w-full h-5 accent-[#47ff72]"})}),d.jsx("input",{type:"number",min:0,max:360,value:Math.round($.angle),onChange:re=>(x?oc:Du)(be=>({...be,angle:parseFloat(re.target.value)||0})),className:"w-14 h-8 shrink-0 text-xs text-right bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-1 font-mono"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Gradient"}),d.jsx("div",{className:"mt-1",children:d.jsx(UCe,{stops:$.stops,midpoints:$.midpoints,onChange:(re,be)=>{const Ee=Te=>Ji({...Te,stops:re.map(Be=>({...Be,id:Be.id||Xl()})),midpoints:be});x?oc(Ee):Du(Ee)}})})]})]})]})},Il=()=>d.jsxs(d.Fragment,{children:[lt==="transform"&&d.jsx("div",{className:"space-y-4",onMouseDown:rt?lr:void 0,onFocusCapture:rt?lr:void 0,children:rt&&Fu?d.jsxs(d.Fragment,{children:[Vt&&d.jsxs("p",{className:"text-[10px] text-slate-500 dark:text-slate-400 -mb-2",children:[Xe.length," objects · group transform"]}),d.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"X"}),d.jsx("input",{type:"number",value:Math.round(Fu.x),onChange:x=>ka({x:parseFloat(x.target.value)||0}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Y"}),d.jsx("input",{type:"number",value:Math.round(Fu.y),onChange:x=>ka({y:parseFloat(x.target.value)||0}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"W"}),d.jsx("input",{type:"number",value:Math.round(Fu.width),onChange:x=>ka({width:Math.max(1,parseFloat(x.target.value)||1)}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"H"}),d.jsx("input",{type:"number",value:Math.round(Fu.height),onChange:x=>
6882ka({height:Math.max(1,parseFloat(x.target.value)||1)}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Rotation"}),d.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[d.jsx("input",{type:"range",min:0,max:360,value:df?0:Sh(pc[0]||0),onChange:x=>ka({rotation:parseFloat(x.target.value)}),className:"flex-1 h-1.5 accent-[#47ff72]"}),d.jsx("input",{type:"number",min:0,max:360,value:hf,placeholder:df?"—":void 0,onChange:x=>{const A=parseFloat(x.target.value);ka({rotation:Number.isFinite(A)?Sh(A):0})},className:"w-14 h-7 text-xs text-right bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-1.5 text-slate-700 dark:text-slate-300 font-mono"}),d.jsx("span",{className:"text-xs text-slate-400",children:"°"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Opacity"}),d.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[d.jsx("input",{type:"range",min:0,max:1,step:.05,value:mc?1:kl[0]??1,onChange:x=>ka({opacity:parseFloat(x.target.value)}),className:"flex-1 h-1.5 accent-[#47ff72]"}),d.jsx("input",{type:"number",min:0,max:100,value:Gd,placeholder:mc?"—":void 0,onChange:x=>ka({opacity:Math.min(1,Math.max(0,(parseFloat(x.target.value)||0)/100))}),className:"w-14 h-7 text-xs text-right bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-1.5 text-slate-700 dark:text-slate-300 font-mono"}),d.jsx("span",{className:"text-xs text-slate-400",children:"%"})]})]}),Sp&&d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Corner Radius"}),d.jsx("input",{type:"number",min:0,value:Wm,placeholder:gc?"—":void 0,onChange:x=>ka({cornerRadius:Math.max(0,parseFloat(x.target.value)||0)}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"}),Vu&&d.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[{key:"tl",label:"Top Left"},{key:"tr",label:"Top Right"},{key:"bl",label:"Bottom Left"},{key:"br",label:"Bottom Right"}].map(x=>d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400",children:x.label}),d.jsx("input",{type:"number",min:0,value:Math.round(Vu[x.key]),onChange:A=>ka({cornerRadii:{...Vu,[x.key]:Math.max(0,parseFloat(A.target.value)||0)}}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"})]},x.key))})]})]}):d.jsx("p",{className:"text-xs text-slate-400 text-center py-8 italic",children:"Select an object to view transform"})}),lt==="properties"&&d.jsx("div",{className:"space-y-4",onMouseDown:gn?lr:void 0,children:gn?d.jsxs(d.Fragment,{children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Name"}),d.jsx("input",{type:"text",value:gn.name,onChange:x=>po({name:x.target.value}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Type"}),d.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-300 mt-0.5 capitalize font-medium",children:gn.type})]}),$g(gn)&&d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Stroke Width"}),d.jsx("input",{type:"number",min:0,value:gn.strokeWidth,onChange:x=>po({strokeWidth:parseFloat(x.target.value)||0}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"})]}),gn.type==="text"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Text"}),d.jsx("textarea",{value:gn.text||"",onChange:x=>po({text:x.target.value}),rows:3,className:"w-full mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 py-1.5 text-slate-700 dark:text-slate-300 resize-y min-h-[56px]"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Font Size"}),d.jsx("input",{type:"number",min:8,value:gn.fontSize||Bh,onChange:x=>po({fontSize:parseInt(x.target.value)||Bh}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase",children:"Font Family"}),d.jsx("select",{value:gn.fontFamily||"Inter",onChange:x=>po({fontFamily:x.target.value}),className:"w-full h-7 mt-0.5 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300",children:lIe.map(x=>d.jsx("option",{value:x,children:x},x))})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase mb-1.5 block",children:"Alignment"}),d.jsx("div",{className:"flex gap-1",children:[{align:"left",icon:d.jsx(aD,{size:14})},{align:"center",icon:d.jsx(iD,{size:14})},{align:"right",icon:d.jsx(oD,{size:14})}].map(({align:x,icon:A})=>d.jsx("button",{type:"button",onClick:()=>po({textAlign:x}),className:`flex-1 h-8 flex items-center justify-center rounded-lg border transition-colors ${(gn.textAlign||"left")===x?"border-[#47ff72] bg-[#47ff72]/15 text-[#47ff72]":"border-slate-200 dark:border-slate-700 text-slate-500 hover:bg-slate-50 dark:hover:bg-slate-800"}`,title:`Align ${x}`,children:A},x))})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase mb-1.5 block",children:"Style"}),d.jsxs("div",{className:"flex gap-1",children:[d.jsx("button",{type:"button",onClick:()=>
6882po({fontWeight:gn.fontWeight==="bold"?"normal":"bold"}),className:`flex-1 h-8 flex items-center justify-center rounded-lg border transition-colors ${gn.fontWeight==="bold"?"border-[#47ff72] bg-[#47ff72]/15 text-[#47ff72]":"border-slate-200 dark:border-slate-700 text-slate-500 hover:bg-slate-50 dark:hover:bg-slate-800"}`,title:"Bold",children:d.jsx(lD,{size:14})}),d.jsx("button",{type:"button",onClick:()=>po({fontStyle:gn.fontStyle==="italic"?"normal":"italic"}),className:`flex-1 h-8 flex items-center justify-center rounded-lg border transition-colors ${gn.fontStyle==="italic"?"border-[#47ff72] bg-[#47ff72]/15 text-[#47ff72]":"border-slate-200 dark:border-slate-700 text-slate-500 hover:bg-slate-50 dark:hover:bg-slate-800"}`,title:"Italic",children:d.jsx(hD,{size:14})}),d.jsx("button",{type:"button",onClick:()=>po({textDecoration:gn.textDecoration==="underline"?"none":"underline"}),className:`flex-1 h-8 flex items-center justify-center rounded-lg border transition-colors ${gn.textDecoration==="underline"?"border-[#47ff72] bg-[#47ff72]/15 text-[#47ff72]":"border-slate-200 dark:border-slate-700 text-slate-500 hover:bg-slate-50 dark:hover:bg-slate-800"}`,title:"Underline",children:d.jsx(xD,{size:14})})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-[10px] text-slate-400 font-bold uppercase mb-1.5 block",children:"Outline"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("button",{type:"button",onClick:()=>{const x=!gn.textOutline;po(x?{textOutline:!0,stroke:gn.stroke==="none"?Ae:gn.stroke,textOutlineWidth:gn.textOutlineWidth??jI}:{textOutline:!1})},className:`h-8 px-3 flex items-center justify-center gap-1.5 rounded-lg border text-xs font-semibold transition-colors ${gn.textOutline?"border-[#47ff72] bg-[#47ff72]/15 text-[#47ff72]":"border-slate-200 dark:border-slate-700 text-slate-500 hover:bg-slate-50 dark:hover:bg-slate-800"}`,title:"Toggle text outline",children:[d.jsx(JX,{size:14}),gn.textOutline?"On":"Off"]}),gn.textOutline&&d.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[d.jsx("input",{type:"number",min:.5,step:.5,value:gn.textOutlineWidth??jI,onChange:x=>po({textOutlineWidth:Math.max(.5,parseFloat(x.target.value)||jI)}),className:"w-full h-8 text-xs bg-slate-50 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded px-2 text-slate-700 dark:text-slate-300 font-mono"}),d.jsx("span",{className:"text-[10px] text-slate-400 font-mono flex-shrink-0",children:"px"})]})]}),gn.textOutline&&d.jsx("p",{className:"text-[10px] text-slate-400 mt-1.5",children:"Outline color uses the toolbar stroke color."})]}),d.jsx("button",{type:"button",onClick:()=>Nd(gn.id),className:"w-full h-8 text-xs font-semibold rounded-lg border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:border-[#47ff72] hover:text-[#47ff72] transition-colors",children:"Edit on canvas"})]}),d.jsxs("div",{className:"flex gap-1 pt-2",children:[d.jsxs("button",{onClick:ju,className:"flex-1 h-7 flex items-center justify-center gap-1 text-[10px] font-bold bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 rounded hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors",title:"Duplicate",children:[d.jsx(pE,{size:12})," Duplicate"]}),d.jsxs("button",{onClick:sf,className:"flex-1 h-7 flex items-center justify-center gap-1 text-[10px] font-bold bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded hover:bg-red-100 dark:hover:bg-red-900/40 transition-colors",title:"Delete",children:[d.jsx(xl,{size:12})," Delete"]})]})]}):d.jsx("p",{className:"text-xs text-slate-400 text-center py-8 italic",children:"Select an object to view properties"})}),lt==="layers"&&d.jsx("div",{className:"space-y-1",children:b.length===0?d.jsxs("div",{className:"text-center py-8",children:[d.jsx(Sd,{size:24,className:"mx-auto text-slate-300 dark:text-slate-600 mb-2"}),d.jsx("p",{className:"text-xs text-slate-400 italic",children:"No objects yet"}),d.jsx("p",{className:"text-[10px] text-slate-400 mt-1",children:"Draw shapes on the artboard"})]}):Ia(mo)})]}),Nl=(x,A)=>
6882{x==="polygon"?(ln(!0),Ir("polygon")):x==="type"?Ir("type"):x==="boolean"?(nn(!Kn),Jt(!1)):A?(Jt(!fn),nn(!1)):Ir(x)},bi=[{tool:"select",icon:d.jsx(rJ,{size:18}),label:"Selection (V)"},{tool:"direct",icon:d.jsx(awe,{size:18}),label:"Direct Selection (A)"},{tool:"pen",icon:d.jsx(Qke,{}),label:"Pen Tool (P)"},{tool:"hand",icon:d.jsx(tJ,{size:18}),label:"Hand (H)"},{tool:"zoom",icon:d.jsx(s1e,{size:18}),label:"Zoom (Z)"},{tool:"polygon",icon:d.jsx(fwe,{size:18}),label:"Polygon Tool"},{tool:"rect",icon:d.jsx(ZL,{size:18}),label:"Shape Tool",hasSubmenu:!0},{tool:"type",icon:d.jsx(TM,{size:18}),label:"Type Tool (T)"},{tool:"boolean",icon:d.jsx(QX,{size:18}),label:"Boolean Operations",hasSubmenu:!0}],zu=ms||Ga,ui=zu?"bg-[#47ff72]/20 text-[#47ff72] ring-1 ring-[#47ff72]/40":"bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700",Rl="w-full px-3 py-2 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none flex items-center gap-2 transition-colors",Wd=()=>{if(!sn)return null;const $=Hn?Math.min(Math.max(8,sn.x),window.innerWidth-200-12-8):Math.min(sn.x,window.innerWidth-240),P=Math.min(sn.y,window.innerHeight-320),Q=!Hn&&sn.x>window.innerWidth-420?"absolute top-0 right-full mr-1 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-1 min-w-[188px] z-[62]":"absolute top-0 left-full ml-1 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-1 min-w-[188px] z-[62]",ee="absolute top-0 left-3 z-[62] w-[calc(100%+0.75rem)] min-w-[200px] max-h-[min(360px,calc(100vh-2rem))] overflow-y-auto bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-2xl py-1",re=Te=>{Te(),hs()},be={transform:[{label:"Flip Horizontal",disabled:!xi,onClick:()=>Ui("horizontal")},{label:"Flip Vertical",disabled:!xi,onClick:()=>Ui("vertical")},{label:"Rotate 90° CW",disabled:!xi,onClick:()=>Uu(90)},{label:"Rotate 180° CW",disabled:!xi,onClick:()=>Uu(180)}],arrange:[{label:"Bring to Front",disabled:!xi,onClick:()=>Hc("front")},{label:"Bring Forward",disabled:!xi,onClick:()=>Hc("forward")},{label:"Send Backward",disabled:!xi,onClick:()=>Hc("backward")},{label:"Send to Back",disabled:!xi,onClick:()=>Hc("back")}],align:[{label:"Left",disabled:!vi,onClick:()=>tl("left")},{label:"Center",disabled:!vi,onClick:()=>tl("center")},{label:"Right",disabled:!vi,onClick:()=>tl("right")},{label:"Top",disabled:!vi,onClick:()=>tl("top")},{label:"Middle",disabled:!vi,onClick:()=>tl("middle")},{label:"Bottom",disabled:!vi,onClick:()=>tl("bottom")}]},Ee=(Te,Be)=>d.jsxs("div",{className:Hn?void 0:"relative",onMouseEnter:Hn?void 0:()=>gs(Te),children:[d.jsxs("button",{type:"button",onClick:()=>gs(Ze=>Ze===Te?null:Te),className:`${Rl} justify-between`,children:[d.jsx("span",{children:Be}),d.jsx(cD,{size:14,className:"text-slate-400 flex-shrink-0"})]}),!Hn&&bs===Te&&d.jsx("div",{className:Q,children:be[Te].map(Ze=>d.jsx("button",{type:"button",disabled:Ze.disabled,onClick:()=>re(Ze.onClick),className:Rl,children:Ze.label},Ze.label))})]},Te);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"fixed inset-0 z-[60]",onClick:hs,onContextMenu:Te=>{Te.preventDefault(),hs()}}),d.jsx("div",{className:"fixed z-[61]",style:{left:$,top:P},children:d.jsxs("div",{className:"relative bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-1 min-w-[200px]",onContextMenu:Te=>Te.preventDefault(),children:[d.jsxs("button",{type:"button",disabled:!xi,onClick:()=>re(()=>{ju()}),className:Rl,children:[d.jsx(pE,{size:14}),"Duplicate"]}),d.jsxs("button",{type:"button",disabled:!xi,onClick:()=>re(sf),className:`${Rl} text-red-600 dark:text-red-400`,children:[d.jsx(xl,{size:14}),"Delete"]}),d.jsx("div",{className:"my-1 border-t border-slate-200 dark:border-slate-700"}),Ee("transform","Transform"),Ee("arrange","Arrange"),Ee("align","Align"),d.jsx("div",{className:"my-1 border-t border-slate-200 dark:border-slate-700"}),d.jsxs("button",{type:"button",disabled:!ac,onClick:()=>re(el),className:Rl,children:[d.jsx(SH,{}),"Group"]}),d.jsxs("button",{type:"button",disabled:!qr,onClick:()=>re(Bu),className:Rl,children:[d.jsx(EH,{}),"Ungroup"]}),Hn&&bs&&d.jsxs("div",{className:ee,children:[d.jsxs("button",{type:"button",onClick:()=>gs(null),className:`${Rl} font-semibold`,children:[d.jsx(qL,{size:14}),"Back"]}),d.jsx("div",{className:"my-1 border-t border-slate-200 dark:border-slate-700"}),be[bs].map(Te=>d.jsx("button",{type:"button",disabled:Te.disabled,onClick:()=>re(Te.onClick),className:Rl,children:Te.label},Te.label))]})]})})]})};return d.jsxs("div",{className:"flex flex-col flex-1 min-h-0 h-auto lg:h-[c
6882alc(100vh-4rem)] lg:min-h-[calc(100vh-4rem)] bg-slate-100 dark:bg-slate-950 overflow-hidden select-none",children:[d.jsx("input",{ref:Pu,type:"file",accept:".svg,image/svg+xml",className:"hidden",onChange:Ka}),d.jsxs("div",{className:"lg:hidden bg-white dark:bg-slate-900 border-b border-slate-200 dark:border-slate-800 flex-shrink-0 px-3 py-2 space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("button",{type:"button",onClick:()=>{var x;return(x=Pu.current)==null?void 0:x.click()},title:"Upload SVG vector",className:"h-11 px-3 flex items-center gap-1.5 rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-200 hover:bg-slate-200 dark:hover:bg-slate-700 text-xs font-semibold transition-colors",children:[d.jsx(yE,{size:14}),"Upload"]}),d.jsxs("div",{className:"relative",children:[d.jsxs("button",{onClick:()=>zs(!ur),className:"h-11 px-3 flex items-center gap-1.5 bg-[#47ff72] hover:bg-[#3de665] text-slate-900 rounded-lg font-bold text-xs transition-colors",children:[d.jsx(Ua,{size:14}),"Export",d.jsx(P0,{size:12})]}),ur&&d.jsxs("div",{className:"absolute top-12 right-0 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-1 min-w-[180px] z-50",children:[d.jsxs("label",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-slate-700 dark:text-slate-200 cursor-pointer border-b border-slate-200 dark:border-slate-700",onClick:x=>x.stopPropagation(),children:[d.jsx("input",{type:"checkbox",checked:fs,onChange:x=>ps(x.target.checked),className:"rounded border-slate-300 dark:border-slate-600 text-[#47ff72] focus:ring-[#47ff72]"}),"Transparency"]}),d.jsx("button",{onClick:()=>{Fr()},className:"w-full px-4 py-2 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 font-medium",children:"Export as SVG"}),d.jsx("button",{onClick:()=>{Kr("png")},className:"w-full px-4 py-2 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 font-medium",children:"Export as PNG"}),d.jsx("button",{onClick:()=>{Kr("jpg")},className:"w-full px-4 py-2 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 font-medium",children:"Export as JPG"}),d.jsx("div",{className:"px-4 py-2 border-t border-slate-200 dark:border-slate-700",children:d.jsx(EE,{showRemaining:e,remaining:t})})]})]})]}),d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsx("button",{type:"button",onClick:ne,disabled:!L,title:"Undo",className:"min-h-11 min-w-11 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 transition-colors",children:d.jsx(zF,{size:16})}),d.jsx("button",{type:"button",onClick:ye,disabled:!D,title:"Redo",className:"min-h-11 min-w-11 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 transition-colors",children:d.jsx(BF,{size:16})}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:()=>{var A;const x=(A=Bi.current)==null?void 0:A.getBoundingClientRect();x&&Ta(x.left+x.width/2,x.top+x.height/2,1/Dg)},className:"min-h-11 min-w-11 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 text-sm font-bold",children:"−"}),d.jsxs("span",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono min-w-[3rem] text-center",children:[Math.round(ot*100),"%"]}),d.jsx("button",{onClick:()=>{var A;const x=(A=Bi.current)==null?void 0:A.getBoundingClientRect();x&&Ta(x.left+x.width/2,x.top+x.height/2,Dg)},className:"min-h-11 min-w-11 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 text-sm font-bold",children:"+"}),d.jsx("button",{onClick:()=>{ar(1),kn({x:0,y:0})},className:"h-11 px-2 flex items-center justify-center rounded-lg bg-slate-100 dar
6882k:bg-slate-800 text-slate-600 dark:text-slate-300 text-[10px] font-bold uppercase",children:"Fit"})]}),d.jsx("button",{type:"button",onClick:()=>Me(x=>!x),title:"Constrain proportions — uniform draw and resize (same as Shift+drag)","aria-pressed":zu,className:`min-h-11 min-w-11 flex items-center justify-center rounded-lg transition-colors ${ui}`,children:d.jsx(OF,{size:16})}),d.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[d.jsx("input",{type:"text",inputMode:"numeric",value:p??String(o),onChange:x=>m(x.target.value.replace(/[^\d]/g,"")),onFocus:x=>{m(String(o)),x.target.select()},onBlur:vp,onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()},className:"w-14 h-9 text-xs text-center bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-md text-slate-700 dark:text-slate-300 font-mono"}),d.jsx("span",{className:"text-slate-400 text-xs",children:"×"}),d.jsx("input",{type:"text",inputMode:"numeric",value:y??String(c),onChange:x=>v(x.target.value.replace(/[^\d]/g,"")),onFocus:x=>{v(String(c)),x.target.select()},onBlur:oa,onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()},className:"w-14 h-9 text-xs text-center bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-md text-slate-700 dark:text-slate-300 font-mono"})]}),d.jsxs("div",{className:"relative",children:[d.jsx("button",{type:"button",onClick:()=>Ft(!yn),className:"min-h-11 min-w-11 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300",title:"More actions",children:d.jsx(cbe,{size:18})}),yn&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Ft(!1)}),d.jsxs("div",{className:"absolute right-0 top-12 z-50 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-2 min-w-[200px]",children:[d.jsxs("button",{type:"button",onClick:()=>{ma("horizontal"),Ft(!1)},disabled:!xi,className:"w-full px-4 py-2.5 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40 flex items-center gap-2",children:[d.jsx(PF,{size:16})," Align H Center"]}),d.jsxs("button",{type:"button",onClick:()=>{ma("vertical"),Ft(!1)},disabled:!xi,className:"w-full px-4 py-2.5 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40 flex items-center gap-2",children:[d.jsx($F,{size:16})," Align V Center"]}),d.jsx("button",{type:"button",onClick:()=>{Ui("horizontal"),Ft(!1)},disabled:!xi,className:"w-full px-4 py-2.5 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40",children:"Flip Horizontal"}),d.jsx("button",{type:"button",onClick:()=>{Ui("vertical"),Ft(!1)},disabled:!xi,className:"w-full px-4 py-2.5 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40",children:"Flip Vertical"}),d.jsx("button",{type:"button",onClick:()=>{el(),Ft(!1)},disabled:!ac,className:"w-full px-4 py-2.5 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40",children:"Group"}),d.jsx("button",{type:"button",onClick:()=>{Bu(),Ft(!1)},disabled:!qr,className:"w-full px-4 py-2.5 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40",children:"Ungroup"}),dr&&d.jsxs("button",{type:"button",onClick:()=>{Xi(),Ft(!1)},disabled:rr,className:"w-full px-4 py-2.5 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40 flex items-center gap-2",children:[d.jsx(VF,{size:16})," Convert to Shape"]})]})]})]})]})]}),d.jsxs("div",{className:"hidden lg:flex h-11 bg-white dark:bg-slate-900 border-b border-slate-200 dark:border-slate-800 items-center px-4 gap-4 flex-shrink-0",children:[d.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:d.jsxs("button",{type:"button",onClick:()=>{var x;return(x=Pu.current)==null?void 0:x.click()},title:"Upload SVG vector",className:"h-8 px-3 flex items-center gap-1.5 rounded-lg bg-slate-100 dar
6882k:bg-slate-800 text-slate-700 dark:text-slate-200 hover:bg-slate-200 dark:hover:bg-slate-700 text-xs font-semibold transition-colors",children:[d.jsx(yE,{size:14}),"Upload Vector"]})}),d.jsx("div",{className:"w-px h-6 bg-slate-200 dark:bg-slate-700 flex-shrink-0"}),d.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d.jsx("span",{className:"text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:"Artboard"}),d.jsx("input",{type:"text",inputMode:"numeric",value:p??String(o),onChange:x=>m(x.target.value.replace(/[^\d]/g,"")),onFocus:x=>{m(String(o)),x.target.select()},onBlur:vp,onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()},className:"w-16 h-7 text-xs text-center bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-md text-slate-700 dark:text-slate-300 font-mono"}),d.jsx("span",{className:"text-slate-400 text-xs",children:"×"}),d.jsx("input",{type:"text",inputMode:"numeric",value:y??String(c),onChange:x=>v(x.target.value.replace(/[^\d]/g,"")),onFocus:x=>{v(String(c)),x.target.select()},onBlur:oa,onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()},className:"w-16 h-7 text-xs text-center bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-md text-slate-700 dark:text-slate-300 font-mono"}),d.jsx("span",{className:"text-[10px] text-slate-400",children:"px"})]}),d.jsx("div",{className:"w-px h-6 bg-slate-200 dark:bg-slate-700"}),d.jsx("button",{type:"button",onClick:()=>Me(x=>!x),title:"Constrain proportions — uniform draw and resize (same as Shift+drag)","aria-pressed":zu,className:`w-8 h-8 flex items-center justify-center rounded-lg transition-colors ${ui}`,children:d.jsx(OF,{size:16})}),d.jsx("div",{className:"w-px h-6 bg-slate-200 dark:bg-slate-700"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{type:"button",onClick:()=>ma("horizontal"),disabled:!xi,title:"Align to horizontal center of artboard",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx(PF,{size:16})}),d.jsx("button",{type:"button",onClick:()=>ma("vertical"),disabled:!xi,title:"Align to vertical center of artboard",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx($F,{size:16})}),d.jsx("button",{type:"button",onClick:()=>Ui("horizontal"),disabled:!xi,title:"Flip horizontally",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx(Zke,{})}),d.jsx("button",{type:"button",onClick:()=>Ui("vertical"),disabled:!xi,title:"Flip vertically",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx(eIe,{})}),d.jsx("button",{type:"button",onClick:el,disabled:!ac,title:"Group selected objects",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx(SH,{})}),d.jsx("button",{type:"button",onClick:Bu,disabled:!qr,title:"Ungroup selected objects",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx(EH,{})}),dr&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"w-px h-6 bg-slate-200 dark:bg-slate-700"}),d.jsxs("button",{type:"button",onClick:()=>void Xi(),disabled:rr,title:"Convert text to shape",className:"h-8 px-3 flex items-center gap-1.5 rounded-lg bg-slate-100 dar
6882k:bg-slate-800 text-slate-700 dark:text-slate-200 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none text-xs font-semibold transition-colors",children:[d.jsx(VF,{size:16}),"Convert to Shape"]})]})]}),d.jsx("div",{className:"flex-1 min-w-0"}),d.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[d.jsx("button",{type:"button",onClick:ne,disabled:!L,title:"Undo (Ctrl+Z)",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx(zF,{size:16})}),d.jsx("button",{type:"button",onClick:ye,disabled:!D,title:"Redo (Ctrl+Shift+Z)",className:"w-8 h-8 flex items-center justify-center rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:pointer-events-none transition-colors",children:d.jsx(BF,{size:16})})]}),d.jsx("div",{className:"w-px h-6 bg-slate-200 dark:bg-slate-700"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:[Math.round(ot*100),"%"]}),d.jsx("button",{onClick:()=>{var A;const x=(A=Bi.current)==null?void 0:A.getBoundingClientRect();x&&Ta(x.left+x.width/2,x.top+x.height/2,Dg)},className:"w-7 h-7 flex items-center justify-center rounded bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 text-xs font-bold",children:"+"}),d.jsx("button",{onClick:()=>{var A;const x=(A=Bi.current)==null?void 0:A.getBoundingClientRect();x&&Ta(x.left+x.width/2,x.top+x.height/2,1/Dg)},className:"w-7 h-7 flex items-center justify-center rounded bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 text-xs font-bold",children:"−"}),d.jsx("button",{onClick:()=>{ar(1),kn({x:0,y:0})},className:"h-7 px-2 flex items-center justify-center rounded bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 text-[10px] font-bold uppercase tracking-wide",children:"Fit"})]}),d.jsx("div",{className:"w-px h-6 bg-slate-200 dark:bg-slate-700 flex-shrink-0"}),d.jsxs("div",{className:"relative flex-shrink-0",children:[d.jsxs("button",{onClick:()=>zs(!ur),className:"h-8 px-3 flex items-center gap-1.5 bg-[#47ff72] hover:bg-[#3de665] text-slate-900 rounded-lg font-bold text-xs transition-colors",children:[d.jsx(Ua,{size:14}),"Export",d.jsx(P0,{size:12})]}),ur&&d.jsxs("div",{className:"absolute top-10 right-0 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-1 min-w-[180px] z-50",children:[d.jsxs("label",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-slate-700 dark:text-slate-200 cursor-pointer border-b border-slate-200 dark:border-slate-700",onClick:x=>x.stopPropagation(),children:[d.jsx("input",{type:"checkbox",checked:fs,onChange:x=>ps(x.target.checked),className:"rounded border-slate-300 dark:border-slate-600 text-[#47ff72] focus:ring-[#47ff72]"}),"Transparency"]}),d.jsx("button",{onClick:()=>{Fr()},className:"w-full px-4 py-2 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 font-medium",children:"Export as SVG"}),d.jsx("button",{onClick:()=>{Kr("png")},className:"w-full px-4 py-2 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 font-medium",children:"Export as PNG"}),d.jsx("button",{onClick:()=>{Kr("jpg")},className:"w-full px-4 py-2 text-left text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 font-medium",children:"Export as JPG"}),d.jsx("div",{className:"px-4 py-2 border-t border-slate-200 dark:border-slate-700",children:d.jsx(EE,{showRemaining:e,remaining:t})})]})]})]})]}),d.jsxs("div",{className:"flex flex-1 overflow-hidden flex-col lg:flex-row min-h-0",children:[d.jsxs("div",{className:"relative hidden lg:flex w-12 bg-white dark:bg-slate-900 border-r border-slate-200 dark:border-slate-800 flex-col items-center py-3 gap-1 flex-shrink-0 overflow-visible",children:[bi.map(({tool:x,icon:A,label:$,hasSubmenu:P})=>d.jsxs("div",{className:"relative group",children:[d.jsx("button",{onClick:()=>
6882{x==="polygon"?(ln(!0),Ir("polygon")):x==="type"?Ir("type"):x==="boolean"?(nn(!Kn),Jt(!1)):P?(Jt(!fn),nn(!1)):Ir(x)},className:`w-9 h-9 flex items-center justify-center rounded-lg transition-all ${M===x||P&&x==="rect"&&s3.includes(M)?"bg-[#47ff72]/20 text-[#47ff72] shadow-sm":"text-slate-500 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800 hover:text-slate-700 dark:hover:text-slate-200"}`,title:$,children:A}),P&&x==="rect"&&fn&&d.jsx("div",{className:"hidden lg:block absolute left-11 top-0 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-2 min-w-[188px] z-50",children:_H.map(z=>d.jsxs("button",{onClick:()=>{Ir(z.t),Jt(!1)},className:`w-full px-3 py-1.5 flex items-center gap-2.5 text-sm hover:bg-slate-50 dark:hover:bg-slate-700 transition-colors ${M===z.t?"text-[#47ff72] font-semibold":"text-slate-600 dark:text-slate-300"}`,children:[d.jsx("span",{className:wH,children:z.icon}),d.jsx("span",{className:"whitespace-nowrap",children:z.label})]},z.t))}),P&&x==="boolean"&&Kn&&d.jsxs("div",{className:"hidden lg:block absolute left-11 top-0 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-xl py-2 min-w-[160px] z-50",children:[[{op:"unite",label:"Unite"},{op:"subtract",label:"Subtract"},{op:"intersect",label:"Intersect"},{op:"exclude",label:"Exclude"},{op:"divide",label:"Divide"}].map(z=>d.jsx("button",{onClick:()=>Cl(z.op),disabled:Sl.length<2,className:"w-full px-3 py-1.5 text-left text-sm text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:z.label},z.op)),Sl.length<2?d.jsx("p",{className:"px-3 py-1 text-[10px] text-slate-400 italic",children:"Select 2 filled shapes (rect, ellipse, polygon, star)"}):d.jsxs("p",{className:"px-3 py-1 text-[10px] text-slate-400 italic",children:[Sl.length," shapes · subtract removes front shapes"]})]})]},x)),d.jsx("div",{className:"w-8 h-px bg-slate-200 dark:bg-slate-700 my-2"}),d.jsxs("div",{className:"flex flex-col items-center gap-2.5 mt-1",children:[d.jsxs("div",{className:"flex flex-col items-center gap-1",children:[d.jsx("button",{type:"button",onClick:()=>Wt(x=>x==="fill"?null:"fill"),className:`w-7 h-7 rounded-md border-2 shadow-sm transition-colors ${Lt==="fill"?"border-[#47ff72] ring-1 ring-[#47ff72]/40":"border-slate-300 dark:border-slate-600 hover:border-slate-400"}`,style:J2(pt?"none":We,Qe,bt,ge),title:"Fill paint"}),d.jsx("button",{type:"button",onClick:fa,className:`w-7 h-7 rounded-md border flex items-center justify-center transition-colors ${pt?"border-[#47ff72] bg-[#47ff72]/10":"border-slate-300 dark:border-slate-600 hover:border-slate-400"}`,title:"No fill",children:d.jsx(nw,{size:14,className:"text-slate-500 dark:text-slate-400"})})]}),d.jsxs("div",{className:"flex flex-col items-center gap-1",children:[d.jsx("button",{type:"button",onClick:()=>Wt(x=>x==="stroke"?null:"stroke"),className:`w-7 h-7 rounded-md border-2 shadow-sm transition-colors ${Lt==="stroke"?"border-[#47ff72] ring-1 ring-[#47ff72]/40":"border-slate-300 dark:border-slate-600 hover:border-slate-400"}`,style:J2(hn?"none":Ae,je,Dt,nt),title:"Stroke paint"}),d.jsx("button",{type:"button",onClick:pa,className:`w-7 h-7 rounded-md border flex items-center justify-center transition-colors ${hn?"border-[#47ff72] bg-[#47ff72]/10":"border-slate-300 dark:border-slate-600 hover:border-slate-400"}`,title:"No stroke",children:d.jsx(nw,{size:14,className:"text-slate-500 dark:text-slate-400"})})]})]}),Lt&&d.jsx("div",{className:"hidden lg:block absolute left-full ml-3 bottom-20 w-72 max-h-[min(32rem,calc(100vh-10rem))] overflow-x-hidden overflow-y-auto rounded-xl border border-slate-200 dark:border-slate-700 bg-white/95 dark:bg-slate-900/95 backdrop-blur shadow-xl p-3 pb-4 z-30",children:Tp()})]}),d.jsxs("div",{className:"flex flex-col flex-1 min-h-0 min-w-0",children:[d.jsxs("div",{ref:_l,tabIndex:0,className:"flex-1 overflow-hidden overscroll-none touch-none bg-slate-200 dark:bg-slate-950 relative outline-none focus:ring-2 focus:ring-inset focus:ring-[#47ff72]/30 min-h-0",style:{cursor:Bn?"grabbing":M==="hand"||Pr?"grab":M==="zoom"?"zoom-in":M==="type"?"text":["select","direct"].includes(M)?"default":M==="pen"?i3:"crosshair"},onMouseDown:()=>{var x;return(x=_l.current)==null?void 0:x.focus()},onContextMenu:Od,onDragEnter:fc,onDragOver:fc,onDragLeave:jd,onDrop:Bd,children:[Uc&&d.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none flex items-center justify-center bg-[#47ff72]/10 ring-2 ring-inset ring-[#47ff72]/60","aria-hidden":!0,
6882children:d.jsx("span",{className:"px-4 py-2 rounded-lg bg-white/90 dark:bg-slate-900/90 text-sm font-semibold text-slate-700 dark:text-slate-200 shadow-lg",children:"Drop SVG to import"})}),d.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, rgba(100,116,139,0.15) 1px, transparent 0)",backgroundSize:`${20*ot}px ${20*ot}px`,backgroundPosition:`${$n.x}px ${$n.y}px`}}),d.jsxs("svg",{ref:Bi,className:"absolute inset-0 w-full h-full",onPointerDown:Al,onPointerMove:Qo,onPointerUp:dc,onLostPointerCapture:()=>{pn.current!=="draw"&&zc()},children:[Wc(),d.jsxs("g",{transform:`translate(${$n.x}, ${$n.y}) scale(${ot})`,children:[d.jsx("rect",{x:4,y:4,width:o,height:c,fill:"rgba(0,0,0,0.1)",rx:2}),d.jsx("rect",{ref:Cd,x:0,y:0,width:o,height:c,fill:"white",stroke:"#cbd5e1",strokeWidth:1,rx:1}),b.map(Fd),M==="select"&&E.length>1&&xr.map(Vd),zd(),wp(),_p(),bp(),(M==="direct"||M==="pen")&&(M==="pen"?b:xr).map(x=>{if(!x.visible||x.locked||x.type==="text")return null;const A=M==="direct";if(ro(x))return Ca(x,{interactive:A,showHandles:A});if(d5(x)){const ee=nse(x);if(ee)return Ca({...x,pathNodes:ee.nodes,pathClosed:ee.closed},{interactive:A,showHandles:A})}const $=Ub(x),P=Nn(UH),z=P+Nn(p3),Q=Nn(FH);return xj(x).map((ee,re)=>d.jsxs("g",{transform:$,children:[A&&d.jsx("circle",{cx:ee.x,cy:ee.y,r:z,fill:"transparent",stroke:"none",style:{cursor:"pointer"},onPointerDown:be=>cc(be,x.id,re,"anchor")}),d.jsx("circle",{cx:ee.x,cy:ee.y,r:P,fill:"white",stroke:"#2563eb",strokeWidth:Q,style:{cursor:A?"pointer":"default"},pointerEvents:"none"})]},`anchor-${x.id}-${re}`))}),nl(),qc()]})]}),ls&&(()=>{var re,be,Ee;const x=b.find(Te=>Te.id===ls);if(!x||x.type!=="text")return null;const A=Pd({x:x.x,y:x.y}),$=DM(x.fontFamily),P=x.fontSize||Bh,z=x.fontWeight==="bold"?"bold":"normal",Q=x.fontStyle==="italic"?"italic":"normal",ee=!x.autoFit;return d.jsx(d.Fragment,{children:d.jsx("textarea",{ref:Rd,value:x.text||"",onChange:Te=>{const Be=Te.target.value;S(Ze=>Ze.map(Fe=>Fe.id===ls&&Fe.type==="text"?{...Fe,text:Be}:Fe))},onBlur:Ou,onPointerDown:Te=>Te.stopPropagation(),onKeyDown:Te=>{Te.stopPropagation(),Te.key==="Escape"&&(Te.preventDefault(),ho(!0))},placeholder:"Type here…",className:"absolute resize-none overflow-hidden bg-white/95 dark:bg-slate-900/95 outline-none ring-2 ring-[#47ff72] rounded-sm text-slate-900 dark:text-slate-100",style:{left:A.left,top:A.top,width:x.width*ot,height:x.height*ot,padding:`${2*ot}px ${4*ot}px`,boxSizing:"border-box",fontFamily:$,fontSize:P*ot,fontWeight:z,fontStyle:Q,textDecoration:x.textDecoration==="underline"?"underline":"none",textAlign:x.textAlign||"left",color:Ff(x,"fill")?((Ee=(be=(re=ix(x,"fill"))==null?void 0:re.stops)==null?void 0:be[0])==null?void 0:Ee.color)||"#000000":x.fill==="none"?"#000000":x.fill,lineHeight:1.25,whiteSpace:ee?"pre-wrap":"pre",wordBreak:ee?"break-word":"normal",overflowWrap:ee?"anywhere":"normal",...xIe(x),...use(x,ot)}})})})(),d.jsxs("div",{className:"absolute bottom-0 left-0 right-0 h-6 bg-white/80 dark:bg-slate-900/80 backdrop-blur border-t border-slate-200 dark:border-slate-800 flex items-center px-3 text-[10px] text-slate-500 gap-4",children:[d.jsxs("span",{children:[b.length," object",b.length!==1?"s":""]}),E.length>0&&d.jsxs("span",{className:"text-[#47ff72] font-semibold",children:[E.length," selected"]}),d.jsx("span",{className:"text-slate-400 hidden lg:inline",children:"Ctrl+Z undo · Ctrl+Shift+Z redo · Scroll pan · Ctrl+scroll horizontal · Alt+scroll zoom · Z zoom · H hand · Right-click context menu"}),d.jsx("span",{className:"text-slate-400 lg:hidden",children:"Pinch zoom · Two-finger pan · Hand tool to drag · Hold object 3s for menu"}),d.jsxs("span",{className:"ml-auto font-mono",children:[o," × ",c]})]}),Wd()]}),d.jsx("div",{className:"lg:hidden flex gap-1 px-2 py-1.5 border-t border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 flex-shrink-0",children:["transform","properties","layers"].map(x=>d.jsx("button",{type:"button",onClick:()=>Qt===x?Sn(null):yc(x),className:`flex-1 min-h-11 py-2 text-[10px] font-bold uppercase tracking-wider rounded-lg transition-colors ${Qt===x?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-100 dar
6882k:bg-slate-800 text-slate-500 dark:text-slate-400"}`,children:x},x))}),d.jsx("div",{className:"lg:hidden flex-shrink-0 border-t border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 overflow-x-auto",children:d.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 min-w-max pb-[max(0.5rem,env(safe-area-inset-bottom))]",children:[bi.map(({tool:x,icon:A,label:$,hasSubmenu:P})=>d.jsx("button",{type:"button",onClick:()=>Nl(x,P),className:`min-h-11 min-w-11 flex items-center justify-center rounded-lg transition-all flex-shrink-0 ${M===x||P&&x==="rect"&&s3.includes(M)||P&&x==="boolean"&&Kn?"bg-[#47ff72]/20 text-[#47ff72] shadow-sm":"text-slate-500 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:$,children:A},x)),d.jsx("div",{className:"w-px h-8 bg-slate-200 dark:bg-slate-700 mx-1 flex-shrink-0"}),d.jsx("button",{type:"button",onClick:()=>Wt(x=>x==="fill"?null:"fill"),className:`min-h-11 min-w-11 rounded-md border-2 flex-shrink-0 ${Lt==="fill"?"border-[#47ff72] ring-1 ring-[#47ff72]/40":"border-slate-300 dark:border-slate-600"}`,style:J2(pt?"none":We,Qe,bt,ge),title:"Fill paint"}),d.jsx("button",{type:"button",onClick:fa,className:`min-h-11 min-w-11 rounded-md border flex items-center justify-center flex-shrink-0 ${pt?"border-[#47ff72] bg-[#47ff72]/10":"border-slate-300 dark:border-slate-600"}`,title:"No fill",children:d.jsx(nw,{size:14,className:"text-slate-500 dark:text-slate-400"})}),d.jsx("button",{type:"button",onClick:()=>Wt(x=>x==="stroke"?null:"stroke"),className:`min-h-11 min-w-11 rounded-md border-2 flex-shrink-0 ${Lt==="stroke"?"border-[#47ff72] ring-1 ring-[#47ff72]/40":"border-slate-300 dark:border-slate-600"}`,style:J2(hn?"none":Ae,je,Dt,nt),title:"Stroke paint"}),d.jsx("button",{type:"button",onClick:pa,className:`min-h-11 min-w-11 rounded-md border flex items-center justify-center flex-shrink-0 ${hn?"border-[#47ff72] bg-[#47ff72]/10":"border-slate-300 dark:border-slate-600"}`,title:"No stroke",children:d.jsx(nw,{size:14,className:"text-slate-500 dark:text-slate-400"})})]})})]}),d.jsxs("div",{className:"hidden lg:flex w-64 bg-white dark:bg-slate-900 border-l border-slate-200 dark:border-slate-800 flex-col flex-shrink-0 overflow-hidden",children:[d.jsx("div",{className:"flex border-b border-slate-200 dark:border-slate-800",children:["transform","properties","layers"].map(x=>d.jsx("button",{onClick:()=>jt(x),className:`flex-1 py-2.5 text-[10px] font-bold uppercase tracking-wider transition-colors ${lt===x?"text-[#47ff72] border-b-2 border-[#47ff72]":"text-slate-400 hover:text-slate-600 dark:hover:text-slate-300"}`,children:x},x))}),d.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:Il()})]})]}),Qt&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"lg:hidden fixed inset-0 z-40 bg-black/40",onClick:()=>Sn(null)}),d.jsxs("div",{className:"lg:hidden fixed inset-y-0 right-0 z-50 w-[min(100%,20rem)] bg-white dark:bg-slate-900 border-l border-slate-200 dark:border-slate-800 flex flex-col shadow-2xl",children:[d.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200 dark:border-slate-800",children:[d.jsx("div",{className:"flex gap-1 flex-1",children:["transform","properties","layers"].map(x=>d.jsx("button",{type:"button",onClick:()=>jt(x),className:`flex-1 min-h-11 py-2 text-[10px] font-bold uppercase tracking-wider rounded-lg transition-colors ${lt===x?"bg-[#47ff72]/20 text-[#47ff72]":"text-slate-400"}`,children:x},x))}),d.jsx("button",{type:"button",onClick:()=>Sn(null),className:"min-h-11 min-w-11 flex items-center justify-center text-slate-400 ml-2","aria-label":"Close panel",children:d.jsx(Ki,{size:18})})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:Il()})]})]}),fn&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"lg:hidden fixed inset-0 z-[55] bg-black/40",onClick:()=>Jt(!1)}),d.jsxs("div",{className:"lg:hidden fixed inset-x-0 bottom-0 z-[60] rounded-t-2xl max-h-[70dvh] overflow-y-auto bg-white dark:bg-slate-900 border-t border-slate-200 dark:border-slate-700 shadow-2xl p-4 pb-[max(1rem,env(safe-area-inset-bottom))]",children:[d.jsx("h4",{className:"text-xs font-bold text-slate-700 dark:text-slate-200 uppercase tracking-wide mb-3",children:"Shapes"}),_H.map(x=>d.jsxs("button",{onClick:()=>
6882{Ir(x.t),Jt(!1)},className:`w-full px-3 py-3 flex items-center gap-2.5 text-sm rounded-lg mb-1 hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors ${M===x.t?"text-[#47ff72] font-semibold":"text-slate-600 dark:text-slate-300"}`,children:[d.jsx("span",{className:wH,children:x.icon}),d.jsx("span",{children:x.label})]},x.t))]})]}),Kn&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"lg:hidden fixed inset-0 z-[55] bg-black/40",onClick:()=>nn(!1)}),d.jsxs("div",{className:"lg:hidden fixed inset-x-0 bottom-0 z-[60] rounded-t-2xl max-h-[70dvh] overflow-y-auto bg-white dark:bg-slate-900 border-t border-slate-200 dark:border-slate-700 shadow-2xl p-4 pb-[max(1rem,env(safe-area-inset-bottom))]",children:[d.jsx("h4",{className:"text-xs font-bold text-slate-700 dark:text-slate-200 uppercase tracking-wide mb-3",children:"Boolean Operations"}),[{op:"unite",label:"Unite"},{op:"subtract",label:"Subtract"},{op:"intersect",label:"Intersect"},{op:"exclude",label:"Exclude"},{op:"divide",label:"Divide"}].map(x=>d.jsx("button",{onClick:()=>{Cl(x.op),nn(!1)},disabled:Sl.length<2,className:"w-full px-3 py-3 text-left text-sm text-slate-600 dark:text-slate-300 rounded-lg mb-1 hover:bg-slate-50 dark:hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:x.label},x.op))]})]}),Lt&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"lg:hidden fixed inset-0 z-[55] bg-black/40",onClick:()=>Wt(null)}),d.jsx("div",{className:"lg:hidden fixed inset-x-0 bottom-0 z-[60] rounded-t-2xl max-h-[70dvh] overflow-y-auto bg-white dark:bg-slate-900 border-t border-slate-200 dark:border-slate-700 shadow-2xl p-4 pb-[max(1rem,env(safe-area-inset-bottom))]",children:Tp()})]}),Wn&&d.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:()=>ln(!1),children:d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl p-6 w-80 max-w-[calc(100%-2rem)] border border-slate-200 dark:border-slate-700",onClick:x=>x.stopPropagation(),children:[d.jsx("h3",{className:"text-lg font-bold text-slate-800 dark:text-white mb-4",children:"Create Polygon"}),d.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Number of Sides"}),d.jsx("input",{type:"number",min:3,max:50,value:ns,onChange:x=>Js(Math.max(3,Math.min(50,parseInt(x.target.value)||3))),className:"w-full h-10 mt-2 mb-4 text-sm bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-xl px-3 text-slate-700 dark:text-slate-300 font-mono",autoFocus:!0}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{onClick:()=>ln(!1),className:"flex-1 h-9 rounded-xl border border-slate-200 dark:border-slate-700 text-sm font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700 transition-colors",children:"Cancel"}),d.jsx("button",{onClick:Xa,className:"flex-1 h-9 rounded-xl bg-[#47ff72] text-slate-900 text-sm font-bold hover:bg-[#3de665] transition-colors",children:"Create"})]})]})}),d.jsx(MA,{isOpen:s,onClose:a,reason:r})]})},yw=800,KS=200,ap=8,yR=88,yse=t=>{const e=t<=3?10:t<=6?9:7;return{columnWidth:yw/t,fontSize:e,lineHeight:e+3,textStartY:ap+yR+10}},xse=t=>[`HEX ${t.hex}`,`HSL ${t.hsl}`,`RGB ${t.rgb}`,`RGBA ${t.rgba}`],vse=t=>(t||"color-palette").replace(/\.[^/.]+$/,"").replace(/[^\w\-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"color-palette",GH=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),gNe=(t,e,n)=>{if(t.measureText(e).width<=n)return e;let s=e;for(;s.length>0&&t.measureText(`${s}…`).width>n;)s=s.slice(0,-1);return`${s}…`},bse=(t,e)=>{const n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=e,s.click(),URL.revokeObjectURL(n)},yNe=t=>{if(t.length===0)return null;const e=document.createElement("canvas");e.width=yw,e.height=KS;const n=e.getContext("2d");if(!n)return null;const s=yse(t.length);return n.fillStyle="#ffffff",n.fillRect(0,0,yw,KS),n.font=`${s.fontSize}px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,n.textBaseline="top",t.forEach((r,i)=>{const a=i*s.columnWidth,o=a+ap/2,l=s.columnWidth-ap,c=a+ap/2;n.fillStyle=r.hex,n.fillRect(o,ap,l,yR),n.strokeStyle="#e2e8f0",n.lineWidth=1,n.strokeRect(o,ap,l,yR),n.fillStyle="#0f172a",xse(r).forEach((h,p)=>{n.fillText(gNe(n,h,l),c,s.textStartY+p*s.lineHeight)})}),e},xNe=t=>{if(t.length===0)return null;const e=yse(t.length),n=[`<svg xmlns="http://www.w3.org/2000/svg" width="${yw}" height="${KS}" viewBox="0 0 ${yw} ${KS}">`,`<rect width="${yw}" height="${KS}" fill="#ffffff"/>`];return t.forEach((s,r)=>{const i=r*e.columnWidth,a=i+ap/2,o=e.columnWidth-ap,l=i+ap/2;n.push(`<rect x="${a}" y="${ap}" width="${o}" height="${yR}" fill="${GH(s.hex)}" stroke="#e2e8f0" stroke-width="1"/>
6882`),xse(s).forEach((c,h)=>{const p=e.textStartY+h*e.lineHeight;n.push(`<text x="${l}" y="${p}" dominant-baseline="hanging" fill="#0f172a" font-family="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace" font-size="${e.fontSize}">${GH(c)}</text>`)})}),n.push("</svg>"),n.join("")},vNe=(t,e)=>new Promise((n,s)=>{const r=yNe(t);if(!r){s(new Error("Nothing to export."));return}r.toBlob(i=>{if(!i){s(new Error("Failed to create palette image."));return}bse(i,`${vse(e)}-palette.png`),n()},"image/png")}),bNe=(t,e)=>new Promise((n,s)=>{const r=xNe(t);if(!r){s(new Error("Nothing to export."));return}const i=new Blob([r],{type:"image/svg+xml;charset=utf-8"});bse(i,`${vse(e)}-palette.svg`),n()}),wNe=(t,e,n)=>e==="svg"?bNe(t,n):vNe(t,n),y3=t=>Math.round(Math.max(0,Math.min(255,t))).toString(16).padStart(2,"0"),xR=t=>`#${y3(t.r)}${y3(t.g)}${y3(t.b)}`,_Ne=t=>{const e=t.r/255,n=t.g/255,s=t.b/255,r=Math.max(e,n,s),i=Math.min(e,n,s);let a=0,o=0;const l=(r+i)/2;if(r!==i){const c=r-i;switch(o=l>.5?c/(2-r-i):c/(r+i),r){case e:a=((n-s)/c+(n<s?6:0))/6;break;case n:a=((s-e)/c+2)/6;break;default:a=((e-n)/c+4)/6;break}}return`hsl(${Math.round(a*360)}, ${Math.round(o*100)}%, ${Math.round(l*100)}%)`},SNe=t=>`rgb(${Math.round(t.r)}, ${Math.round(t.g)}, ${Math.round(t.b)})`,ENe=(t,e=1)=>`rgba(${Math.round(t.r)}, ${Math.round(t.g)}, ${Math.round(t.b)}, ${e})`,wse=t=>({channels:t,hex:xR(t),rgb:SNe(t),hsl:_Ne(t),rgba:ENe(t)}),TNe=(t,e,n)=>{const s=t.getContext("2d");if(!s)return null;const r=Math.max(0,Math.min(t.width-1,Math.floor(e))),i=Math.max(0,Math.min(t.height-1,Math.floor(n))),[a,o,l]=s.getImageData(r,i,1,1).data;return wse({r:a,g:o,b:l})},ANe=(t,e,n,s,r)=>{const{naturalWidth:i,naturalHeight:a}=t;if(!i||!a)return null;const o=Math.min(e.width/i,e.height/a),l=i*o,c=a*o,h=(e.width-l)/2,p=(e.height-c)/2,m=s-e.left-h,y=r-e.top-p;return m<0||y<0||m>=l||y>=c?null:{x:m/l*n.width,y:y/c*n.height}},CNe=1225,bj=(t,e)=>{const n=t.r-e.r,s=t.g-e.g,r=t.b-e.b;return n*n+s*s+r*r},xw=(t,e=24)=>Math.min(255,Math.round(t/e)*e),ME=(t,e)=>
6882!e.some(n=>bj(t,n)<CNe),wj=(t,e=24)=>{const n=new Map;for(const i of t){const a={r:xw(i.r,e),g:xw(i.g,e),b:xw(i.b,e)},o=xR(a),l=n.get(o);l?l.count+=1:n.set(o,{color:a,count:1})}const s=[],r=[...n.values()].sort((i,a)=>a.count-i.count);for(const i of r)ME(i.color,s)&&s.push(i.color);return s},kNe=(t,e)=>{const n=[];for(const s of t)if(ME(s,n)&&(n.push(s),n.length>=e))break;return n},HH=(t,e,n)=>{let s=kNe(t,e);if(s.length>=e)return s.slice(0,e);for(const r of[24,12,6]){const i=wj(n,r);for(const a of i){if(s.length>=e)break;ME(a,s)&&s.push(a)}if(s.length>=e)break}return s.slice(0,e)},INe=(t,e)=>{const n=wj(t),s=[];for(n.length>0&&s.push({...n[0]});s.length<e;){let r=null,i=-1;for(const o of t){const l=Math.min(...s.map(c=>bj(o,c)));l>i&&(i=l,r=o)}if(r&&i>0&&ME(r,s)){s.push({...r});continue}const a=n.find(o=>ME(o,s));if(!a)break;s.push({...a})}return s.slice(0,e)},NNe=t=>{const e=t.reduce((s,r)=>({r:s.r+r.r,g:s.g+r.g,b:s.b+r.b}),{r:0,g:0,b:0}),n=t.length||1;return{r:e.r/n,g:e.g/n,b:e.b/n}},RNe=(t,e,n=20)=>{if(t.length===0)return[];if(t.length<=e)return HH(t.map(o=>({...o})),e,t);const s=INe(t,e);if(s.length===0)return[];const r=new Array(t.length).fill(0);for(let o=0;o<n;o++){let l=!1;for(let h=0;h<t.length;h++){let p=0,m=1/0;for(let y=0;y<s.length;y++){const v=bj(t[h],s[y]);v<m&&(m=v,p=y)}r[h]!==p&&(r[h]=p,l=!0)}const c=Array.from({length:s.length},()=>[]);for(let h=0;h<t.length;h++)c[r[h]].push(t[h]);for(let h=0;h<s.length;h++)c[h].length>0&&(s[h]=NNe(c[h]));if(!l)break}const i=Array.from({length:s.length},()=>0);for(const o of r)i[o]++;const a=s.map((o,l)=>({centroid:o,size:i[l]})).filter(({size:o})=>o>0).sort((o,l)=>l.size-o.size).map(({centroid:o})=>o);return HH(a,e,t)},_se=(t,e=4)=>{const{data:n,width:s,height:r}=t,i=[];for(let a=0;a<r;a+=e)for(let o=0;o<s;o+=e){const l=(a*s+o)*4;n[l+3]<128||i.push({r:n[l],g:n[l+1],b:n[l+2]})}return i},MNe=t=>new Promise((e,n)=>{const s=URL.createObjectURL(t),r=new Image;r.onload=()=>{const a=Math.min(1,400/Math.max(r.width,r.height)),o=Math.max(1,Math.round(r.width*a)),l=Math.max(1,Math.round(r.height*a)),c=document.createElement("canvas");c.width=o,c.height=l;const h=c.getContext("2d");if(!h){URL.revokeObjectURL(s),n(new Error("Could not read image data."));return}h.clearRect(0,0,o,l),h.drawImage(r,0,0,o,l),URL.revokeObjectURL(s),e(c)},r.onerror=()=>{URL.revokeObjectURL(s),n(new Error("Failed to load image."))},r.src=s}),PNe=.02,$Ne=t=>{const e=t.getContext("2d");if(!e)return 5;const n=e.getImageData(0,0,t.width,t.height),s=_se(n);if(s.length===0)return 1;const r=new Map;for(const c of s){const h=xR({r:xw(c.r),g:xw(c.g),b:xw(c.b)});r.set(h,(r.get(h)??0)+1)}const i=wj(s),a=s.length;let o=0,l=0;for(const c of i){const p=(r.get(xR(c))??0)/a;if(p<PNe&&o>=1||(o+=1,l+=p,o>=10||l>=.9))break}return Math.max(1,Math.min(10,o))},qH=(t,e)=>{const n=t.getContext("2d");if(!n)return[];const s=n.getImageData(0,0,t.width,t.height),r=_se(s);return RNe(r,Math.max(1,Math.min(10,e))).map(a=>wse(a))},DNe=t=>{const e=t.type.toLowerCase(),n=t.name.toLowerCase();return e==="image/jpeg"||e==="image/png"||e==="image/svg+xml"||n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".png")||n.endsWith(".svg")},ONe=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2347ff72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 22 1-1h3l9-9-3-3-9 9v3Z'/%3E%3Cpath d='m14 6 3 3'/%3E%3C/svg%3E") 2 22, crosshair`,LNe=["rgb","rgba","hex","hsl"],jNe=()=>{var We;const t=q.useRef(null),[e,n]=q.useState(null),[s,r]=q.useState(null),[i,a]=q.useState([]),[o,l]=q.useState(1),[c,h]=q.useState(!1),[p,m]=q.useState(!1),[y,v]=q.useState(!1),b=q.useRef(null),[S,E]=q.useState(null),[I,M]=q.useState(!1),[j,L]=q.useState(null),[K,D]=q.useState(null),[R,B]=q.useState(null),[G,X]=q.useState(!1),[H,Y]=q.useState(null),[F,we]=q.useState("hex"),me=q.useRef(null),xe=q.useRef(null),Le=q.useRef(null),ve=q.useRef(null),ce=q.useCallback(async Ie=>{if(!DNe(Ie)){E("Please upload a JPG, PNG, or SVG image.");return}h(!0),E(null);try{const ge=await MNe(Ie);me.current=ge;const he=$Ne(ge),Ae=qH(ge,he);l(Ae.length);const et=URL.createObjectURL(Ie);n(nt=>(nt&&URL.revokeObjectURL(nt),et)),r(Ie.name),a(Ae)}catch{E("Could not extract colors from this image. Try another file."),a([])}finally{h(!1)}},[]),ie=q.useCallback(Ie=>{Ie&&ce(Ie)},[ce]),de=q.useCallback(Ie=>{var he;Ie.preventDefault(),Ie.stopPropagation(),M(!1);const ge=(he=Ie.dataTransfer.files)==null?void 0:he[0];ie(ge)},[ie]),Re=q.useCallback(Ie=>{if(!me.current)return;const ge=qH(me.current,Ie);a(ge),ge.length!==Ie&&l(ge.length)},[]),Se=q.useCallback(Ie=>{l(Ie),Re(Ie)},[Re]),De=()=>{e&&URL.revokeObjectURL(e),n(null),r(null),a([]),l(1),v(!1),me.current=null,D(null),B(null),X(!1),Y(null),ve.current&&clearTimeout(ve.current),E(null),t.current&&(t.current.value="")};q.useEffect(()=>{if(!y)return;const Ie=ge=>{b.current&&!b.current.contains(ge.target)&&v(!1)};return document.addEventListener("mousedown",Ie),()=>document.removeEventListener("mousedown",Ie)},[y]);const gt=async(Ie,ge)=>{if(Ie.stopPropagation(),!(i.length===0||p)){m(!0),v(!1);try{await wNe(i,ge,s)}catch{E("Could not export palette.")}finally{m(!1)}}},yt=Ie=>{ve.current&&clearTimeout(ve.current),Y(Ie),X(!0),ve.current=setTimeout(()=>{X(!1),Y(null)},2e3)},xt=q.useCallback((Ie,ge)=>{const he=me.current,Ae=Le.current,et=xe.current;if(!he||!Ae||!et)return null;const nt=ANe(Ae,et.getBoundingClientRect(),he,Ie,ge);return nt?TNe(he,nt.x,nt.y):null},[]),Nt=q.useCallback(Ie=>{const ge=xe.current;if(!ge)return;const he=xt(Ie.clientX,Ie.clientY);if(!he){D(null),B(null);return}const Ae=ge.getBoundingClientRect();D(he),B({x:Ie.clientX-Ae.left,y:Ie.clientY-Ae.top})},[xt]),wt=()=>{D(null),B(null)},zt=async Ie=>{const ge=xt(Ie.clientX,Ie.clientY);if(!ge)return;const he=ge[F];
6882try{await navigator.clipboard.writeText(he),D(ge),yt(he)}catch{E("Could not copy to clipboard.")}},_n=async(Ie,ge,he)=>{const Ae=ge[Ie],et=`${he}-${Ie}`;try{await navigator.clipboard.writeText(Ae),L(et),setTimeout(()=>L(nt=>nt===et?null:nt),1500)}catch{E("Could not copy to clipboard.")}},Zt={hex:"HEX",rgb:"RGB",hsl:"HSL",rgba:"RGBA"},J=i.length===0?void 0:i.length===1?i[0].hex:`linear-gradient(to right, ${i.map((Ie,ge)=>{const he=ge/i.length*100,Ae=(ge+1)/i.length*100;return`${Ie.hex} ${he}% ${Ae}%`}).join(", ")})`;return d.jsxs("div",{className:"flex-1 w-full max-w-[1600px] w-[96%] mx-auto px-4 sm:px-6 lg:px-8 py-4 sm:py-8 space-y-4 sm:space-y-8 animate-in fade-in zoom-in-95 duration-500",children:[d.jsx("input",{ref:t,type:"file",accept:"image/jpeg,image/png,image/svg+xml,.jpg,.jpeg,.png,.svg",className:"hidden",onChange:Ie=>{var ge;ie((ge=Ie.target.files)==null?void 0:ge[0]),Ie.target.value=""}}),d.jsxs("div",{className:"text-center space-y-4 mb-8",children:[d.jsx("h2",{className:"text-3xl font-bold text-[#47ff72]",children:"Color Extractor"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-sm sm:text-base max-w-2xl mx-auto",children:"Upload an image and extract a color palette. Copy hex, RGB, HSL, or RGBA values for every swatch."})]}),e?d.jsxs("div",{className:"max-w-3xl mx-auto space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[d.jsxs("div",{className:"bg-white dark:bg-slate-800/80 border border-slate-200 dark:border-slate-700/50 rounded-2xl p-4 sm:p-6 shadow-sm space-y-5",children:[d.jsxs("div",{ref:b,className:"relative z-10 flex justify-end",onMouseEnter:()=>{D(null),B(null),X(!1)},onMouseMove:Ie=>Ie.stopPropagation(),onMouseDown:Ie=>Ie.stopPropagation(),children:[d.jsxs("button",{type:"button",onClick:Ie=>{Ie.stopPropagation(),!(i.length===0||p)&&(D(null),B(null),v(ge=>!ge))},disabled:i.length===0||p,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg bg-[#47ff72] text-slate-900 text-xs font-bold shadow-md hover:bg-[#3ce665] disabled:opacity-50 disabled:cursor-not-allowed transition-colors cursor-pointer",children:[d.jsx(Ua,{className:"w-3.5 h-3.5"}),p?"Exporting…":"Export",d.jsx(P0,{className:`w-3.5 h-3.5 transition-transform ${y?"rotate-180":""}`})]}),y&&!p&&d.jsxs("div",{className:"absolute right-0 top-full mt-1.5 w-36 rounded-xl shadow-2xl overflow-hidden border border-slate-200 dark:border-slate-600 bg-white dark:bg-slate-950 cursor-pointer",children:[d.jsx("button",{type:"button",onClick:Ie=>gt(Ie,"png"),className:"w-full px-3 py-2.5 text-left text-xs font-bold text-slate-800 dark:text-slate-100 bg-white dark:bg-slate-950 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors cursor-pointer",children:"PNG"}),d.jsx("button",{type:"button",onClick:Ie=>gt(Ie,"svg"),className:"w-full px-3 py-2.5 text-left text-xs font-bold text-slate-800 dark:text-slate-100 bg-white dark:bg-slate-950 hover:bg-slate-100 dark:hover:bg-slate-800 border-t border-slate-200 dark:border-slate-600 transition-colors cursor-pointer",children:"SVG"})]})]}),d.jsxs("div",{ref:xe,className:"relative rounded-xl overflow-hidden border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 flex items-center justify-center min-h-[200px] max-h-[360px]",style:{cursor:ONe},onMouseMove:Nt,onMouseLeave:wt,onClick:zt,children:[d.jsx("img",{ref:Le,src:e,alt:"Uploaded preview",className:"max-w-full max-h-[360px] object-contain pointer-events-none select-none",draggable:!1}),K&&R&&!y&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"pointer-events-none absolute z-10 rounded-full border-2 border-white shadow-md",style:{left:R.x-10,top:R.y-10,width:20,height:20,backgroundColor:K.hex}}),d.jsx("div",{className:"pointer-events-none absolute z-10 -translate-y-full",style:{left:Math.min(R.x+14,(((We=xe.current)==null?void 0:We.clientWidth)??0)-(F==="rgba"||F==="hsl"?200:140)),top:R.y-10},children:d.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-slate-900/95 dark:bg-slate-950/95 text-white text-xs font-mono shadow-lg border border-white/10 whitespace-nowrap",children:[d.jsx("span",{className:"w-4 h-4 rounded-full border-2 border-white/40 flex-shrink-0 shadow-inner",style:{backgroundColor:K.hex}}),d.jsx("span",{className:"text-[#47ff72]",children:G?"Copied!":K[F]}),G&&d.jsx(yd,{className:"w-3.5 h-3.5 text-[#47ff72] flex-shrink-0"})]})})]})]}),s&&d.jsx("p",{className:"text-xs text-slate-500 truncate font-medium text-center",children:s}),d.jsxs("div",{className:"flex gap-3",children:[d.jsx("button",{onClick:()=>{var Ie;return(Ie=t.current)==null?void 0:Ie.click()},className:"flex-1 py-2.5 rounded-xl text-sm font-bold border border-slate-200 dark:border-slate-700 text-slate-600 dar
6882k:text-slate-300 hover:border-[#47ff72]/50 hover:text-[#47ff72] transition-colors",children:"Replace Image"}),d.jsxs("button",{onClick:De,className:"flex-1 py-2.5 rounded-xl text-sm font-bold border border-red-200 dark:border-red-900/50 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors flex items-center justify-center gap-2",children:[d.jsx(xl,{className:"w-4 h-4"}),"Delete"]})]}),S&&d.jsx("p",{className:"text-xs font-semibold text-red-500 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg",children:S}),d.jsxs("div",{className:"space-y-2 pt-2 border-t border-slate-200 dark:border-slate-700",children:[d.jsxs("div",{className:"flex justify-between items-center text-xs",children:[d.jsxs("span",{className:"text-slate-500 font-bold uppercase tracking-wider flex items-center gap-1.5",children:[d.jsx(Z0,{className:"w-3.5 h-3.5 text-[#47ff72]"}),"Number of Colors"]}),d.jsx("span",{className:"text-[#47ff72] font-bold",children:o})]}),d.jsx("input",{type:"range",min:1,max:10,value:o,onChange:Ie=>Se(parseInt(Ie.target.value,10)),className:"w-full h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"}),d.jsxs("div",{className:"flex justify-between text-[10px] text-slate-400 font-medium",children:[d.jsx("span",{children:"1"}),d.jsx("span",{children:"10"})]}),d.jsxs("div",{className:"space-y-2 pt-3",children:[d.jsxs("span",{className:"text-xs text-slate-500 font-bold uppercase tracking-wider flex items-center gap-1.5",children:[d.jsx(U1,{className:"w-3.5 h-3.5 text-[#47ff72]"}),"Picker Format"]}),d.jsx("div",{className:"grid grid-cols-4 gap-2",children:LNe.map(Ie=>d.jsx("button",{type:"button",onClick:()=>we(Ie),className:`py-2 rounded-lg text-xs font-bold transition-all ${F===Ie?"bg-[#47ff72] text-slate-900 shadow-sm":"bg-slate-100 dark:bg-slate-900 text-slate-600 dark:text-slate-400 hover:text-[#47ff72] border border-slate-200 dark:border-slate-700"}`,children:Zt[Ie]},Ie))})]})]})]}),d.jsxs("div",{className:"bg-white dark:bg-slate-800/80 border border-slate-200 dark:border-slate-700/50 rounded-2xl p-4 sm:p-6 shadow-sm",children:[d.jsxs("h3",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2 border-b border-slate-200 dark:border-slate-700 pb-3 mb-4",children:[d.jsx(U1,{className:"w-4 h-4 text-[#47ff72]"})," Color Palette",c&&d.jsx("span",{className:"text-xs font-medium text-slate-400 ml-auto",children:"Extracting…"})]}),i.length>0?d.jsxs("div",{className:"space-y-3",children:[d.jsx("div",{className:"rounded-xl overflow-hidden border border-slate-200 dark:border-slate-700 h-14",style:{background:J},title:i.map(Ie=>Ie.hex).join(", ")},o),d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:i.map((Ie,ge)=>d.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50",children:[d.jsx("div",{className:"w-12 h-12 rounded-lg border border-slate-200 dark:border-slate-600 flex-shrink-0 shadow-sm",style:{backgroundColor:Ie.hex}}),d.jsx("div",{className:"flex-1 min-w-0 space-y-1.5",children:["hex","rgb","hsl","rgba"].map(he=>{const Ae=`${ge}-${he}`,et=j===Ae;return d.jsxs("button",{onClick:()=>_n(he,Ie,ge),className:"w-full flex items-center gap-2 text-left group",title:`Copy ${Zt[he]}`,children:[d.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase w-10 flex-shrink-0",children:Zt[he]}),d.jsx("span",{className:"flex-1 text-xs font-mono text-slate-700 dark:text-slate-300 truncate group-hover:text-[#47ff72] transition-colors",children:Ie[he]}),et?d.jsx(yd,{className:"w-3.5 h-3.5 text-[#47ff72] flex-shrink-0"}):d.jsx(pE,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#47ff72] flex-shrink-0 opacity-0 group-hover:opacity-100 transition-all"})]},he)})})]},`${o}-${ge}-${Ie.hex}`))})]}):d.jsx("p",{className:"text-sm text-slate-500 text-center py-8",children:"No colors extracted yet."})]})]}):d.jsxs("div",{className:"max-w-3xl mx-auto w-full",children:[d.jsxs("div",{onClick:()=>{var Ie;return(Ie=t.current)==null?void 0:Ie.click()},onDragOver:Ie=>{Ie.preventDefault(),M(!0)},onDragLeave:()=>M(!1),onDrop:de,className:`group relative border-2 border-dashed rounded-2xl p-12 sm:p-16 flex flex-col items-center justify-center text-center cursor-pointer transition-all duration-300 overflow-hidden bg-white dark:bg-slate-900 ${I?"border-[#47ff72] bg-[#47ff72]/5 dark:bg-[#47ff72]/5":"border-slate-300 dark:border-slate-700 hover:border-[#47ff72] dark:hover:border-[#47ff72]"}`,children:[d.jsxs("div",{className:"flex flex-col items-center gap-4 pointer-events-none",children:[d.jsx("div",{className:"p-4 bg-[#47ff72]/10 rounded-full group-hover:scale-110 group-hover:bg-[#47ff72]/20 transition-all duration-300 shadow-sm group-hover:shadow-[#47ff72]/20",children:d.jsx(yE,{className:"w-10 h-10 sm:w-12 sm:h-12 text-[#47ff72]"})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-lg sm:text-xl font-bold text-slate-700 dark:text-slate-200 group-hover:text-[#47ff72] transition-colors",children:"Click or drag & drop"}),d.jsx("p",{className:"text-sm sm:text-base text-slate-500 mt-1",children:"JPG, PNG, SVG"})]})]}),d.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#47ff72]/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none"})]}),S&&d.jsx("p",{className:"mt-4 text-xs font-semibold text-red-500 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg text-center",children:S})]}),G&&H&&d.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 animate-in fade-in slide-in-from-bottom-4 duration-300",children:d.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 rounded-xl bg-slate-900 dark:bg-slate-800 text-white shadow-xl border border-slate-700/50",children:[d.jsx("div",{className:"w-8 h-8 rounded-full bg-[#47ff72]/20 flex items-center justify-center flex-shrink-0",children:d.jsx(yd,{className:"w-4 h-4 text-[#47ff72]"})}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-sm font-bold text-[#47ff72]",children:"Color copied"}),d.jsx("p",{className:"text-xs font-mono text-slate-300 truncate max-w-[240px] sm:max-w-xs",children:H})]})]})})]})};var YS={};YS.d=(t,e)=>{for(var n in e)YS.o(e,n)&&!YS.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})};YS.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ms=globalThis.pdfjsLib={};YS.d(Ms,{AbortException:()=>W0,AnnotationEditorLayer:()=>kO,AnnotationEditorParamsType:()=>br,AnnotationEditorType:()=>Ws,AnnotationEditorUIManager:()=>Dv,AnnotationLayer:()=>PMe,AnnotationMode:()=>Gg,ColorPicker:()=>ER,DOMSVGFactory:()=>Nj,DrawLayer:()=>RO,FeatureTest:()=>nc,GlobalWorkerOptions:()=>Am,ImageKind:()=>UI,InvalidPDFException:()=>w5,MissingPDFException:()=>PE,OPS:()=>Th,OutputScale:()=>S5,PDFDataRangeTransport:()=>Ere,PDFDateString:()=>Aj,PDFWorker:()=>bw,PasswordResponses:()=>VNe,PermissionFlag:()=>FNe,PixelsPerInch:()=>K0,RenderingCancelledException:()=>Ej,TextLayer:()=>$E,TouchManager:()=>_R,UnexpectedResponseException:()=>vR,Util:()=>Gn,VerbosityLevel:()=>jM,XfaLayer:()=>Are,build:()=>fMe,createValidAbsoluteUrl:()=>qNe,fetchData:()=>VM,getDocument:()=>rMe,getFilenameFromUrl:()=>tRe,getPdfFilenameFromUrl:()=>nRe,getXfaPageViewport:()=>sRe,isDataScheme:()=>zM,isPdfFile:()=>Tj,noContextMenu:()=>Xh,normalizeUnicode:()=>QNe,setLayerDimensions:()=>$v,shadow:()=>sr,stopEvent:()=>Cu,version:()=>hMe});const yl=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Sse=[1,0,0,1,0,0],b5=[.001,0,0,.001,0,0],BNe=1e7,x3=1.35,wu={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Gg={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},UNe="pdfjs_internal_editor_",Ws={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15}
6882,br={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,DRAW_STEP:41},FNe={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ll={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},UI={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Za={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},Z2={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},jM={ERRORS:0,WARNINGS:1,INFOS:5},Th={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},VNe={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let BM=jM.WARNINGS;function zNe(t){Number.isInteger(t)&&(BM=t)}function GNe(){return BM}function UM(t){BM>=jM.INFOS&&console.log(`Info: ${t}`)}function Ks(t){BM>=jM.WARNINGS&&console.log(`Warning: ${t}`)}function mi(t){throw new Error(t)}function Oa(t,e){t||mi(e)}function HNe(t){switch(t==null?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function qNe(t,e=null,n=null){if(!t)return null;try{if(n&&typeof t=="string"){if(n.addDefaultProtocol&&t.startsWith("www.")){const r=t.match(/\./g);(r==null?void 0:r.length)>=2&&(t=`http://${t}`)}if(n.tryConvertEncoding)try{t=JNe(t)}catch{}}const s=e?new URL(t,e):new URL(t);if(HNe(s))return s}catch{}return null}function sr(t,e,n,s=!1){return Object.defineProperty(t,e,{value:n,enumerable:!s,configurable:!0,writable:!1}),n}const ny=(function(){function e(n,s){this.message=n,this.name=s}return e.prototype=new Error,e.constructor=e,e})();class WH extends ny{constructor(e,n){super(e,"PasswordException"),this.code=n}}class v3 extends ny{constructor(e,n){super(e,"UnknownErrorException"),this.details=n}}class w5 extends ny{constructor(e){super(e,"InvalidPDFException")}}class PE extends ny{constructor(e){super(e,"MissingPDFException")}}class vR extends ny{constructor(e,n){super(e,"UnexpectedResponseException"),this.status=n}}class WNe extends ny{constructor(e){super(e,"FormatError")}}class W0 extends ny{constructor(e){super(e,"AbortException")}}function Ese(t){(typeof t!="object"||(t==null?void 0:t.length)===void 0)&&mi("Invalid argument for bytesToString");const e=t.length,n=8192;if(e<n)return String.fromCharCode.apply(null,t);const s=[];for(let r=0;r<e;r+=n){const i=Math.min(r+n,e),a=t.subarray(r,i);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function FM(t){typeof t!="string"&&mi("Invalid argument for stringToBytes");const e=t.length,n=new Uint8Array(e);for(let s=0;s<e;++s)n[s]=t.charCodeAt(s)&255;return n}function KNe(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}function _j(t){const e=Object.create(null);for(const[n,s]of t)e[n]=s;return e}function YNe(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}function XNe(){try{return new Function(""),!0}catch{return!1}}class nc{static get isLittleEndian(){return sr(this,"isLittleEndian",YNe())}static get isEvalSupported(){return sr(this,"isEvalSupported",XNe())}static get isOffscreenCanvasSupported(){return sr(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return sr(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="str
6882ing"?sr(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")}):sr(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var e,n;return sr(this,"isCSSRoundSupported",(n=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:n.call(e,"width: round(1.5px, 1px)"))}}const b3=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));var Nm,FI,_5;class Gn{static makeHexColor(e,n,s){return`#${b3[e]}${b3[n]}${b3[s]}`}static scaleMinMax(e,n){let s;e[0]?(e[0]<0&&(s=n[0],n[0]=n[2],n[2]=s),n[0]*=e[0],n[2]*=e[0],e[3]<0&&(s=n[1],n[1]=n[3],n[3]=s),n[1]*=e[3],n[3]*=e[3]):(s=n[0],n[0]=n[1],n[1]=s,s=n[2],n[2]=n[3],n[3]=s,e[1]<0&&(s=n[1],n[1]=n[3],n[3]=s),n[1]*=e[1],n[3]*=e[1],e[2]<0&&(s=n[0],n[0]=n[2],n[2]=s),n[0]*=e[2],n[2]*=e[2]),n[0]+=e[4],n[1]+=e[5],n[2]+=e[4],n[3]+=e[5]}static transform(e,n){return[e[0]*n[0]+e[2]*n[1],e[1]*n[0]+e[3]*n[1],e[0]*n[2]+e[2]*n[3],e[1]*n[2]+e[3]*n[3],e[0]*n[4]+e[2]*n[5]+e[4],e[1]*n[4]+e[3]*n[5]+e[5]]}static applyTransform(e,n){const s=e[0]*n[0]+e[1]*n[2]+n[4],r=e[0]*n[1]+e[1]*n[3]+n[5];return[s,r]}static applyInverseTransform(e,n){const s=n[0]*n[3]-n[1]*n[2],r=(e[0]*n[3]-e[1]*n[2]+n[2]*n[5]-n[4]*n[3])/s,i=(-e[0]*n[1]+e[1]*n[0]+n[4]*n[1]-n[5]*n[0])/s;return[r,i]}static getAxialAlignedBoundingBox(e,n){const s=this.applyTransform(e,n),r=this.applyTransform(e.slice(2,4),n),i=this.applyTransform([e[0],e[3]],n),a=this.applyTransform([e[2],e[1]],n);return[Math.min(s[0],r[0],i[0],a[0]),Math.min(s[1],r[1],i[1],a[1]),Math.max(s[0],r[0],i[0],a[0]),Math.max(s[1],r[1],i[1],a[1])]}static inverseTransform(e){const n=e[0]*e[3]-e[1]*e[2];return[e[3]/n,-e[1]/n,-e[2]/n,e[0]/n,(e[2]*e[5]-e[4]*e[3])/n,(e[4]*e[1]-e[5]*e[0])/n]}static singularValueDecompose2dScale(e){const n=[e[0],e[2],e[1],e[3]],s=e[0]*n[0]+e[1]*n[2],r=e[0]*n[1]+e[1]*n[3],i=e[2]*n[0]+e[3]*n[2],a=e[2]*n[1]+e[3]*n[3],o=(s+a)/2,l=Math.sqrt((s+a)**2-4*(s*a-i*r))/2,c=o+l||1,h=o-l||1;return[Math.sqrt(c),Math.sqrt(h)]}static normalizeRect(e){const n=e.slice(0);return e[0]>e[2]&&(n[0]=e[2],n[2]=e[0]),e[1]>e[3]&&(n[1]=e[3],n[3]=e[1]),n}static intersect(e,n){const s=Math.max(Math.min(e[0],e[2]),Math.min(n[0],n[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(n[0],n[2]));if(s>r)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(n[1],n[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(n[1],n[3]));return i>a?null:[s,i,r,a]}static bezierBoundingBox(e,n,s,r,i,a,o,l,c){return c?(c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],n,l),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],n,l)):c=[Math.min(e,o),Math.min(n,l),Math.max(e,o),Math.max(n,l)],le(this,Nm,_5).call(this,e,s,i,o,n,r,a,l,3*(-e+3*(s-i)+o),6*(e-2*s+i),3*(s-e),c),le(this,Nm,_5).call(this,e,s,i,o,n,r,a,l,3*(-n+3*(r-a)+l),6*(n-2*r+a),3*(r-n),c),c}}Nm=new WeakSet,FI=function(e,n,s,r,i,a,o,l,c,h){if(c<=0||c>=1)return;const p=1-c,m=c*c,y=m*c,v=p*(p*(p*e+3*c*n)+3*m*s)+y*r,b=p*(p*(p*i+3*c*a)+3*m*o)+y*l;h[0]=Math.min(h[0],v),h[1]=Math.min(h[1],b),h[2]=Math.max(h[2],v),h[3]=Math.max(h[3],b)},_5=function(e,n,s,r,i,a,o,l,c,h,p,m){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&le(this,Nm,FI).call(this,e,n,s,r,i,a,o,l,-p/h,m);return}const y=h**2-4*p*c;if(y<0)return;const v=Math.sqrt(y),b=2*c;le(this,Nm,FI).call(this,e,n,s,r,i,a,o,l,(-h+v)/b,m),le(this,Nm,FI).call(this,e,n,s,r,i,a,o,l,(-h-v)/b,m)},oe(Gn,Nm);function JNe(t){return decodeURIComponent(escape(t))}let w3=null,KH=null;function QNe(t){return w3||(w3=/([\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,KH=new Map([["ſt","ſt"]])),t.replaceAll(w3,(e,n,s)=>n?n.normalize("NFKC"):KH.get(s))}function ZNe(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),Ese(t)}const Sj="pdfjs_internal_id_";function eRe(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(Ese(t))}typeof Promise.try!="function"&&(Promise.try=function(t,...e){return new Promise(n=>{n(t(...e))})});const qp="http://www.w3.org/2000/svg",Qy=class Qy{};os(Qy,"CSS",96),os(Qy,"PDF",72),os(Qy,"PDF_TO_CSS_UNITS",Qy.CSS/Qy.PDF);let K0=Qy;
6882async function VM(t,e="text"){if(mS(t,document.baseURI)){const n=await fetch(t);if(!n.ok)throw new Error(n.statusText);switch(e){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,s)=>{const r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(r.status===200||r.status===0){switch(e){case"arraybuffer":case"blob":case"json":n(r.response);return}n(r.responseText);return}s(new Error(r.statusText))}},r.send(null)})}class $A{constructor({viewBox:e,userUnit:n,scale:s,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=n,this.scale=s,this.rotation=r,this.offsetX=i,this.offsetY=a,s*=n;const l=(e[2]+e[0])/2,c=(e[3]+e[1])/2;let h,p,m,y;switch(r%=360,r<0&&(r+=360),r){case 180:h=-1,p=0,m=0,y=1;break;case 90:h=0,p=1,m=1,y=0;break;case 270:h=0,p=-1,m=-1,y=0;break;case 0:h=1,p=0,m=0,y=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(m=-m,y=-y);let v,b,S,E;h===0?(v=Math.abs(c-e[1])*s+i,b=Math.abs(l-e[0])*s+a,S=(e[3]-e[1])*s,E=(e[2]-e[0])*s):(v=Math.abs(l-e[0])*s+i,b=Math.abs(c-e[1])*s+a,S=(e[2]-e[0])*s,E=(e[3]-e[1])*s),this.transform=[h*s,p*s,m*s,y*s,v-h*s*l-m*s*c,b-p*s*l-y*s*c],this.width=S,this.height=E}get rawDims(){const{userUnit:e,viewBox:n}=this,s=n.map(r=>r*e);return sr(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:e=this.scale,rotation:n=this.rotation,offsetX:s=this.offsetX,offsetY:r=this.offsetY,dontFlip:i=!1}={}){return new $A({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:n,offsetX:s,offsetY:r,dontFlip:i})}convertToViewportPoint(e,n){return Gn.applyTransform([e,n],this.transform)}convertToViewportRectangle(e){const n=Gn.applyTransform([e[0],e[1]],this.transform),s=Gn.applyTransform([e[2],e[3]],this.transform);return[n[0],n[1],s[0],s[1]]}convertToPdfPoint(e,n){return Gn.applyInverseTransform([e,n],this.transform)}}class Ej extends ny{constructor(e,n=0){super(e,"RenderingCancelledException"),this.extraDelay=n}}function zM(t){const e=t.length;let n=0;for(;n<e&&t[n].trim()==="";)n++;return t.substring(n,n+5).toLowerCase()==="data:"}function Tj(t){return typeof t=="string"&&/\.pdf$/i.test(t)}function tRe(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function nRe(t,e="document.pdf"){if(typeof t!="string")return e;if(zM(t))return Ks('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,r=n.exec(t);let i=s.exec(r[1])||s.exec(r[2])||s.exec(r[3]);if(i&&(i=i[0],i.includes("%")))try{i=s.exec(decodeURIComponent(i))[0]}catch{}return i||e}class YH{constructor(){os(this,"started",Object.create(null));os(this,"times",[])}time(e){e in this.started&&Ks(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Ks(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let n=0;for(const{name:s}of this.times)n=Math.max(s.length,n);for(const{name:s,start:r,end:i}of this.times)e.push(`${s.padEnd(n)} ${i-r}ms
6883`);return e.join("")}}function mS(t,e){try{const{protocol:n}=e?new URL(t,e):new URL(t);return n==="http:"||n==="https:"}catch{return!1}}function Xh(t){t.preventDefault()}function Cu(t){t.preventDefault(),t.stopPropagation()}var OE;class Aj{static toDateObject(e){if(!e||typeof e!="string")return null;_(this,OE)||te(this,OE,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const n=_(this,OE).exec(e);if(!n)return null;const s=parseInt(n[1],10);let r=parseInt(n[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(n[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(n[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(n[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(n[6],10);l=l>=0&&l<=59?l:0;const c=n[7]||"Z";let h=parseInt(n[8],10);h=h>=0&&h<=23?h:0;let p=parseInt(n[9],10)||0;return p=p>=0&&p<=59?p:0,c==="-"?(a+=h,o+=p):c==="+"&&(a-=h,o-=p),new Date(Date.UTC(s,r,i,a,o,l))}}OE=new WeakMap,oe(Aj,OE);function sRe(t,{scale:e=1,rotation:n=0}){const{width:s,height:r}=t.attributes.style,i=[0,0,parseInt(s),parseInt(r)];return new $A({viewBox:i,userUnit:1,scale:e,rotation:n})}function Cj(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(e=>parseInt(e)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(Ks(`Not a valid color format: "${t}"`),[0,0,0])}function rRe(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const n of t.keys()){e.style.color=n;const s=window.getComputedStyle(e).color;t.set(n,Cj(s))}e.remove()}function Hi(t){const{a:e,b:n,c:s,d:r,e:i,f:a}=t.getTransform();return[e,n,s,r,i,a]}function Df(t){const{a:e,b:n,c:s,d:r,e:i,f:a}=t.getTransform().invertSelf();return[e,n,s,r,i,a]}function $v(t,e,n=!1,s=!0){if(e instanceof $A){const{pageWidth:r,pageHeight:i}=e.rawDims,{style:a}=t,o=nc.isCSSRoundSupported,l=`var(--scale-factor) * ${r}px`,c=`var(--scale-factor) * ${i}px`,h=o?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,p=o?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!n||e.rotation%180===0?(a.width=h,a.height=p):(a.width=p,a.height=h)}s&&t.setAttribute("data-main-rotation",e.rotation)}class S5{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 Hg,ox,Ah,lx,LE,jE,MR,Tse,sc,Ase,Cse,VI,kse,T5;const Yp=class Yp{constructor(e){oe(this,sc);oe(this,Hg,null);oe(this,ox,null);oe(this,Ah);oe(this,lx,null);oe(this,LE,null);te(this,Ah,e),_(Yp,jE)||te(Yp,jE,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=te(this,Hg,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=_(this,Ah)._uiManager._signal;e.addEventListener("contextmenu",Xh,{signal:n}),e.addEventListener("pointerdown",le(Yp,MR,Tse),{signal:n});const s=te(this,lx,document.createElement("div"));s.className="buttons",e.append(s);const r=_(this,Ah).toolbarPosition;if(r){const{style:i}=e,a=_(this,Ah)._uiManager.direction==="ltr"?1-r[0]:r[0];i.insetInlineEnd=`${100*a}%`,i.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return le(this,sc,kse).call(this),e}get div(){return _(this,Hg)}hide(){var e;_(this,Hg).classList.add("hidden"),(e=_(this,ox))==null||e.hideDropdown()}show(){var e;_(this,Hg).classList.remove("hidden"),(e=_(this,LE))==null||e.shown()}async addAltText(e){const n=await e.render();le(this,sc,VI).call(this,n),_(this,lx).prepend(n,_(this,sc,T5)),te(this,LE,e)}addColorPicker(e){te(this,ox,e);const n=e.renderButton();le(this,sc,VI).call(this,n),_(this,lx).prepend(n,_(this,sc,T5))}remove(){var e;_(this,Hg).remove(),(e=_(this,ox))==null||e.destroy(),te(this,ox,null)}};Hg=new WeakMap,ox=new WeakMap,Ah=new WeakMap,lx=new WeakMap,LE=new WeakMap,jE=new WeakMap,MR=new WeakSet,Tse=function(e){e.stopPropagation()},sc=new WeakSet,Ase=function(e){_(this,Ah)._focusEventsAllowed=!1,Cu(e)},Cse=function(e){_(this,Ah)._focusEventsAllowed=!0,Cu(e)},VI=function(e){const n=_(this,Ah)._uiManager._signal;e.addEventListener("focusin",le(this,sc,Ase).bind(this),{capture:!0,signal:n}),e.addEventListener("focusout",le(this,sc,Cse).bind(this),{capture:!0,signal:n}),e.addEventListener("contextmenu",Xh,{signal:n})},kse=function(){const{editorType:e,_uiManager:n}=_(this,Ah),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",_(Yp,jE)[e]),le(this,sc,VI).call(this,s),s.addEventListener("click",r=>{n.delete()},{signal:n._signal}),_(this,lx).append(s)},T5=function(){const e=document.createElement("div");return e.className="divider",e},oe(Yp,MR),oe(Yp,jE,null);let E5=Yp;
6883var BE,cx,ux,Y0,Ise,Nse,Rse;class iRe{constructor(e){oe(this,Y0);oe(this,BE,null);oe(this,cx,null);oe(this,ux);te(this,ux,e)}show(e,n,s){const[r,i]=le(this,Y0,Nse).call(this,n,s),{style:a}=_(this,cx)||te(this,cx,le(this,Y0,Ise).call(this));e.append(_(this,cx)),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){_(this,cx).remove()}}BE=new WeakMap,cx=new WeakMap,ux=new WeakMap,Y0=new WeakSet,Ise=function(){const e=te(this,cx,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",Xh,{signal:_(this,ux)._signal});const n=te(this,BE,document.createElement("div"));return n.className="buttons",e.append(n),le(this,Y0,Rse).call(this),e},Nse=function(e,n){let s=0,r=0;for(const i of e){const a=i.y+i.height;if(a<s)continue;const o=i.x+(n?i.width:0);if(a>s){r=o,s=a;continue}n?o>r&&(r=o):o<r&&(r=o)}return[n?1-r:r,s]},Rse=function(){const e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const n=document.createElement("span");e.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=_(this,ux)._signal;e.addEventListener("contextmenu",Xh,{signal:s}),e.addEventListener("click",()=>{_(this,ux).highlightSelection("floating_button")},{signal:s}),_(this,BE).append(e)};function bR(t,e,n){for(const s of n)e.addEventListener(s,t[s].bind(t))}var PR;class aRe{constructor(){oe(this,PR,0)}get id(){return`${UNe}${Vl(this,PR)._++}`}}PR=new WeakMap;var Tw,UE,dl,Aw,zI;const Hj=class Hj{constructor(){oe(this,Aw);oe(this,Tw,ZNe());oe(this,UE,0);oe(this,dl,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),r=new Image;r.src=e;const i=r.decode().then(()=>(s.drawImage(r,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return sr(this,"_isSVGFittingCanvas",i)}async getFromFile(e){const{lastModified:n,name:s,size:r,type:i}=e;return le(this,Aw,zI).call(this,`${n}_${s}_${r}_${i}`,e)}async getFromUrl(e){return le(this,Aw,zI).call(this,e,e)}async getFromBlob(e,n){const s=await n;return le(this,Aw,zI).call(this,e,s)}async getFromId(e){_(this,dl)||te(this,dl,new Map);const n=_(this,dl).get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return this.getFromFile(n.file);if(n.blobPromise){const{blobPromise:s}=n;return delete n.blobPromise,this.getFromBlob(n.id,s)}return this.getFromUrl(n.url)}getFromCanvas(e,n){_(this,dl)||te(this,dl,new Map);let s=_(this,dl).get(e);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const r=new OffscreenCanvas(n.width,n.height);return r.getContext("2d").drawImage(n,0,0),s={bitmap:r.transferToImageBitmap(),id:`image_${_(this,Tw)}_${Vl(this,UE)._++}`,refCounter:1,isSvg:!1},_(this,dl).set(e,s),_(this,dl).set(s.id,s),s}getSvgUrl(e){const n=_(this,dl).get(e);return n!=null&&n.isSvg?n.svgUrl:null}deleteId(e){var r;_(this,dl)||te(this,dl,new Map);const n=_(this,dl).get(e);if(!n||(n.refCounter-=1,n.refCounter!==0))return;const{bitmap:s}=n;if(!n.url&&!n.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),n.blobPromise=i.convertToBlob()}(r=s.close)==null||r.call(s),n.bitmap=null}isValidId(e){return e.startsWith(`image_${_(this,Tw)}_`)}};Tw=new WeakMap,UE=new WeakMap,dl=new WeakMap,Aw=new WeakSet,zI=async function(e,n){_(this,dl)||te(this,dl,new Map);let s=_(this,dl).get(e);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${_(this,Tw)}_${Vl(this,UE)._++}`,refCounter:0,isSvg:!1});let r;if(typeof n=="string"?(s.url=n,r=await VM(n,"blob")):n instanceof File?r=s.file=n:n instanceof Blob&&(r=n),r.type==="image/svg+xml"){const i=Hj._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,h)=>{o.onload=()=>
6883{s.bitmap=o,s.isSvg=!0,c()},a.onload=async()=>{const p=s.svgUrl=a.result;o.src=await i?`${p}#svgView(preserveAspectRatio(none))`:p},o.onerror=a.onerror=h});a.readAsDataURL(r),await l}else s.bitmap=await createImageBitmap(r);s.refCounter=1}catch(r){Ks(r),s=null}return _(this,dl).set(e,s),s&&_(this,dl).set(s.id,s),s};let A5=Hj;var xa,qg,FE,Qi;class oRe{constructor(e=128){oe(this,xa,[]);oe(this,qg,!1);oe(this,FE);oe(this,Qi,-1);te(this,FE,e)}add({cmd:e,undo:n,post:s,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),_(this,qg))return;const l={cmd:e,undo:n,post:s,type:i};if(_(this,Qi)===-1){_(this,xa).length>0&&(_(this,xa).length=0),te(this,Qi,0),_(this,xa).push(l);return}if(a&&_(this,xa)[_(this,Qi)].type===i){o&&(l.undo=_(this,xa)[_(this,Qi)].undo),_(this,xa)[_(this,Qi)]=l;return}const c=_(this,Qi)+1;c===_(this,FE)?_(this,xa).splice(0,1):(te(this,Qi,c),c<_(this,xa).length&&_(this,xa).splice(c)),_(this,xa).push(l)}undo(){if(_(this,Qi)===-1)return;te(this,qg,!0);const{undo:e,post:n}=_(this,xa)[_(this,Qi)];e(),n==null||n(),te(this,qg,!1),te(this,Qi,_(this,Qi)-1)}redo(){if(_(this,Qi)<_(this,xa).length-1){te(this,Qi,_(this,Qi)+1),te(this,qg,!0);const{cmd:e,post:n}=_(this,xa)[_(this,Qi)];e(),n==null||n(),te(this,qg,!1)}}hasSomethingToUndo(){return _(this,Qi)!==-1}hasSomethingToRedo(){return _(this,Qi)<_(this,xa).length-1}cleanType(e){if(_(this,Qi)!==-1){for(let n=_(this,Qi);n>=0;n--)if(_(this,xa)[n].type!==e){_(this,xa).splice(n+1,_(this,Qi)-n),te(this,Qi,n);return}_(this,xa).length=0,te(this,Qi,-1)}}destroy(){te(this,xa,null)}}xa=new WeakMap,qg=new WeakMap,FE=new WeakMap,Qi=new WeakMap;var $R,Mse;class DA{constructor(e){oe(this,$R);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:n}=nc.platform;for(const[s,r,i={}]of e)for(const a of s){const o=a.startsWith("mac+");n&&o?(this.callbacks.set(a.slice(4),{callback:r,options:i}),this.allKeys.add(a.split("+").at(-1))):!n&&!o&&(this.callbacks.set(a,{callback:r,options:i}),this.allKeys.add(a.split("+").at(-1)))}}exec(e,n){if(!this.allKeys.has(n.key))return;const s=this.callbacks.get(le(this,$R,Mse).call(this,n));if(!s)return;const{callback:r,options:{bubbles:i=!1,args:a=[],checker:o=null}}=s;o&&!o(e,n)||(r.bind(e,...a,n)(),i||Cu(n))}}$R=new WeakSet,Mse=function(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const n=this.buffer.join("+");return this.buffer.length=0,n};const DR=class DR{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return rRe(e),sr(this,"_colors",e)}convert(e){const n=Cj(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[s,r]of this._colors)if(r.every((i,a)=>i===n[a]))return DR._colorsMapping.get(s);return n}getHexCode(e){const n=this._colors.get(e);return n?Gn.makeHexColor(...n):e}};os(DR,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let C5=DR;var Cw,cu,to,Do,kw,Qp,Iw,ad,Wg,dx,Nw,hx,Vf,Ch,fx,VE,zE,Rw,GE,zf,Kg,Mw,Yg,Gf,OR,Xg,HE,Jg,px,qE,WE,bo,Zr,Zp,mx,KE,YE,Qg,Hf,em,XE,od,on,GI,k5,Pse,$se,HI,Dse,Ose,Lse,I5,jse,N5,R5,Bse,Hl,Wp,Use,Fse,M5,Vse,gS,P5;const uw=class uw{constructor(e,n,s,r,i,a,o,l,c,h,p,m,y){oe(this,on);oe(this,Cw,new AbortController);oe(this,cu,null);oe(this,to,new Map);oe(this,Do,new Map);oe(this,kw,null);oe(this,Qp,null);oe(this,Iw,null);oe(this,ad,new oRe);oe(this,Wg,null);oe(this,dx,null);oe(this,Nw,0);oe(this,hx,new Set);oe(this,Vf,null);oe(this,Ch,null);oe(this,fx,new Set);os(this,"_editorUndoBar",null);oe(this,VE,!1);oe(this,zE,!1);oe(this,Rw,!1);oe(this,GE,null);oe(this,zf,null);oe(this,Kg,null);oe(this,Mw,null);oe(this,Yg,!1);oe(this,Gf,null);oe(this,OR,new aRe);oe(this,Xg,!1);oe(this,HE,!1);oe(this,Jg,null);oe(this,px,null);oe(this,qE,null);oe(this,WE,null);oe(this,bo,Ws.NONE);oe(this,Zr,new Set);oe(this,Zp,null);oe(this,mx,null);oe(this,KE,null);oe(this,YE,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});oe(this,Qg,[0,0]);oe(this,Hf,null);oe(this,em,null);oe(this,XE,null);oe(this,od,null);const v=this._signal=_(this,Cw).signal;te(this,em,e),te(this,XE,n),te(this,kw,s),this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:v}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:v}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:v}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:v}),r._on("setpreference",this.onSetPreference.bind(this),{signal:v}),r._on("switchannotationeditorparams",b=>this.updateParams(b.type,b.value),{signal:v}),le(this,on,Dse).call(this),le(this,on,Bse).call(this),le(this,on,I5).call(this),te(this,Qp,i.annotationStorage),te(this,GE,i.filterFactory),te(this,mx,a),te(this,Mw,o||null),te(this,VE,l),te(this,zE,c),te(this,Rw,h),te(this,WE,p||null),this.viewParameters={realScale:K0.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=m||null,this._supportsPinchToZoom=y!==!1}static get _keyboardManager(){const e=uw.prototype,n=a=>_(a,em).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},r=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return sr(this,"_keyboardManager",new DA([[["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}
6883],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&_(a,em).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&_(a,em).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}]]))}destroy(){var e,n,s,r,i;(e=_(this,od))==null||e.resolve(),te(this,od,null),(n=_(this,Cw))==null||n.abort(),te(this,Cw,null),this._signal=null;for(const a of _(this,Do).values())a.destroy();_(this,Do).clear(),_(this,to).clear(),_(this,fx).clear(),te(this,cu,null),_(this,Zr).clear(),_(this,ad).destroy(),(s=_(this,kw))==null||s.destroy(),(r=_(this,Gf))==null||r.hide(),te(this,Gf,null),_(this,zf)&&(clearTimeout(_(this,zf)),te(this,zf,null)),_(this,Hf)&&(clearTimeout(_(this,Hf)),te(this,Hf,null)),(i=this._editorUndoBar)==null||i.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return _(this,WE)}get useNewAltTextFlow(){return _(this,zE)}get useNewAltTextWhenAddingImage(){return _(this,Rw)}get hcmFilter(){return sr(this,"hcmFilter",_(this,mx)?_(this,GE).addHCMFilter(_(this,mx).foreground,_(this,mx).background):"none")}get direction(){return sr(this,"direction",getComputedStyle(_(this,em)).direction)}get highlightColors(){return sr(this,"highlightColors",_(this,Mw)?new Map(_(this,Mw).split(",").map(e=>e.split("=").map(n=>n.trim()))):null)}get highlightColorNames(){return sr(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),te(this,dx,e)}setMainHighlightColorPicker(e){te(this,qE,e)}editAltText(e,n=!1){var s;(s=_(this,kw))==null||s.editAltText(this,e,n)}switchToMode(e,n){this._eventBus.on("annotationeditormodechanged",n,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,n){this._eventBus.dispatch("setpreference",{source:this,name:e,value:n})}onSetPreference({name:e,value:n}){switch(e){case"enableNewAltTextWhenAddingImage":te(this,Rw,n);break}}onPageChanging({pageNumber:e}){te(this,Nw,e-1)}focusMainContainer(){_(this,em).focus()}findParent(e,n){for(const s of _(this,Do).values()){const{x:r,y:i,width:a,height:o}=s.div.getBoundingClientRect();if(e>=r&&e<=r+a&&n>=i&&n<=i+o)return s}return null}disableUserSelect(e=!1){_(this,XE).classList.toggle("noUserSelect",e)}addShouldRescale(e){_(this,fx).add(e)}removeShouldRescale(e){_(this,fx).delete(e)}onScaleChanging({scale:e}){var n;this.commitOrRemove(),this.viewParameters.realScale=e*K0.PDF_TO_CSS_UNITS;for(const s of _(this,fx))s.onScaleChanging();(n=_(this,dx))==null||n.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=""){const n=document.getSelection();if(!n||n.isCollapsed)return;const{anchorNode:s,anchorOffset:r,focusNode:i,focusOffset:a}=n,o=n.toString(),c=le(this,on,GI).call(this,n).closest(".textLayer"),h=this.getSelectionBoxes(c);if(!h)return;n.empty();
6883const p=le(this,on,k5).call(this,c),m=_(this,bo)===Ws.NONE,y=()=>{p==null||p.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:h,anchorNode:s,anchorOffset:r,focusNode:i,focusOffset:a,text:o}),m&&this.showAllEditors("highlight",!0,!0)};if(m){this.switchToMode(Ws.HIGHLIGHT,y);return}y()}addToAnnotationStorage(e){!e.isEmpty()&&_(this,Qp)&&!_(this,Qp).has(e.id)&&_(this,Qp).setValue(e.id,e)}blur(){if(this.isShiftKeyDown=!1,_(this,Yg)&&(te(this,Yg,!1),le(this,on,HI).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const n of _(this,Zr))if(n.div.contains(e)){te(this,px,[n,e]),n._focusEventsAllowed=!1;break}}focus(){if(!_(this,px))return;const[e,n]=_(this,px);te(this,px,null),n.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),n.focus()}addEditListeners(){le(this,on,I5).call(this),le(this,on,N5).call(this)}removeEditListeners(){le(this,on,jse).call(this),le(this,on,R5).call(this)}dragOver(e){for(const{type:n}of e.dataTransfer.items)for(const s of _(this,Ch))if(s.isHandlingMimeForPasting(n)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const n of e.dataTransfer.items)for(const s of _(this,Ch))if(s.isHandlingMimeForPasting(n.type)){s.paste(n,this.currentLayer),e.preventDefault();return}}copy(e){var s;if(e.preventDefault(),(s=_(this,cu))==null||s.commitOrRemove(),!this.hasSelection)return;const n=[];for(const r of _(this,Zr)){const i=r.serialize(!0);i&&n.push(i)}n.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:n}=e;for(const i of n.items)for(const a of _(this,Ch))if(a.isHandlingMimeForPasting(i.type)){a.paste(i,this.currentLayer);return}let s=n.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(i){Ks(`paste: "${i.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const r=this.currentLayer;try{const i=[];for(const l of s){const c=await r.deserialize(l);if(!c)return;i.push(c)}const a=()=>{for(const l of i)le(this,on,M5).call(this,l);le(this,on,P5).call(this,i)},o=()=>{for(const l of i)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(i){Ks(`paste: "${i.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),_(this,bo)!==Ws.NONE&&!this.isEditorHandlingKeyboard&&uw._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,_(this,Yg)&&(te(this,Yg,!1),le(this,on,HI).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?(le(this,on,Ose).call(this),le(this,on,N5).call(this),le(this,on,Hl).call(this,{isEditing:_(this,bo)!==Ws.NONE,isEmpty:le(this,on,gS).call(this),hasSomethingToUndo:_(this,ad).hasSomethingToUndo(),hasSomethingToRedo:_(this,ad).hasSomethingToRedo(),hasSelectedEditor:!1})):(le(this,on,Lse).call(this),le(this,on,R5).call(this),le(this,on,Hl).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!_(this,Ch)){te(this,Ch,e);for(const n of _(this,Ch))le(this,on,Wp).call(this,n.defaultPropertiesToUpdate)}}getId(){return _(this,OR).id}get currentLayer(){return _(this,Do).get(_(this,Nw))}getLayer(e){return _(this,Do).get(e)}get currentPageIndex(){return _(this,Nw)}addLayer(e){_(this,Do).set(e.pageIndex,e),_(this,Xg)?e.enable():e.disable()}removeLayer(e){_(this,Do).delete(e.pageIndex)}
6883async updateMode(e,n=null,s=!1){var r;if(_(this,bo)!==e&&!(_(this,od)&&(await _(this,od).promise,!_(this,od)))){if(te(this,od,Promise.withResolvers()),te(this,bo,e),e===Ws.NONE){this.setEditingState(!1),le(this,on,Fse).call(this),(r=this._editorUndoBar)==null||r.hide(),_(this,od).resolve();return}this.setEditingState(!0),await le(this,on,Use).call(this),this.unselectAll();for(const i of _(this,Do).values())i.updateMode(e);if(!n){s&&this.addNewEditorFromKeyboard(),_(this,od).resolve();return}for(const i of _(this,to).values())i.annotationElementId===n?(this.setSelected(i),i.enterInEditMode()):i.unselect();_(this,od).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==_(this,bo)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,n){var s;if(_(this,Ch)){switch(e){case br.CREATE:this.currentLayer.addNewEditor();return;case br.HIGHLIGHT_DEFAULT_COLOR:(s=_(this,qE))==null||s.updateColor(n);break;case br.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_(this,KE)||te(this,KE,new Map)).set(e,n),this.showAllEditors("highlight",n);break}for(const r of _(this,Zr))r.updateParams(e,n);for(const r of _(this,Ch))r.updateDefaultParams(e,n)}}showAllEditors(e,n,s=!1){var i;for(const a of _(this,to).values())a.editorType===e&&a.show(n);(((i=_(this,KE))==null?void 0:i.get(br.HIGHLIGHT_SHOW_ALL))??!0)!==n&&le(this,on,Wp).call(this,[[br.HIGHLIGHT_SHOW_ALL,n]])}enableWaiting(e=!1){if(_(this,HE)!==e){te(this,HE,e);for(const n of _(this,Do).values())e?n.disableClick():n.enableClick(),n.div.classList.toggle("waiting",e)}}getEditors(e){const n=[];for(const s of _(this,to).values())s.pageIndex===e&&n.push(s);return n}getEditor(e){return _(this,to).get(e)}addEditor(e){_(this,to).set(e.id,e)}removeEditor(e){var n;e.div.contains(document.activeElement)&&(_(this,zf)&&clearTimeout(_(this,zf)),te(this,zf,setTimeout(()=>{this.focusMainContainer(),te(this,zf,null)},0))),_(this,to).delete(e.id),this.unselect(e),(!e.annotationElementId||!_(this,hx).has(e.annotationElementId))&&((n=_(this,Qp))==null||n.remove(e.id))}addDeletedAnnotationElement(e){_(this,hx).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return _(this,hx).has(e)}removeDeletedAnnotationElement(e){_(this,hx).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){_(this,cu)!==e&&(te(this,cu,e),e&&le(this,on,Wp).call(this,e.propertiesToUpdate))}updateUI(e){_(this,on,Vse)===e&&le(this,on,Wp).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){le(this,on,Wp).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(_(this,Zr).has(e)){_(this,Zr).delete(e),e.unselect(),le(this,on,Hl).call(this,{hasSelectedEditor:this.hasSelection});return}_(this,Zr).add(e),e.select(),le(this,on,Wp).call(this,e.propertiesToUpdate),le(this,on,Hl).call(this,{hasSelectedEditor:!0})}setSelected(e){var n;(n=_(this,dx))==null||n.commitOrRemove();for(const s of _(this,Zr))s!==e&&s.unselect();_(this,Zr).clear(),_(this,Zr).add(e),e.select(),le(this,on,Wp).call(this,e.propertiesToUpdate),le(this,on,Hl).call(this,{hasSelectedEditor:!0})}isSelected(e){return _(this,Zr).has(e)}get firstSelectedEditor(){return _(this,Zr).values().next().value}unselect(e){e.unselect(),_(this,Zr).delete(e),le(this,on,Hl).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return _(this,Zr).size!==0}get isEnterHandled(){return _(this,Zr).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;_(this,ad).undo(),le(this,on,Hl).call(this,{hasSomethingToUndo:_(this,ad).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:le(this,on,gS).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){_(this,ad).redo(),le(this,on,Hl).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_(this,ad).hasSomethingToRedo(),isEmpty:le(this,on,gS).call(this)})}addCommands(e){_(this,ad).add(e),le(this,on,Hl).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:le(this,on,gS).call(this)})}cleanUndoStack(e){_(this,ad).cleanType(e)}delete(){var i;this.commitOrRemove();const e=(i=this.currentLayer)==null?void 0:i.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[..._(this,Zr)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(r,n.length===1?n[0].editorType:n.length);for(const o of n)o.remove()},r=()=>{for(const a of n)le(this,on,M5).call(this,a)};this.addCommands({cmd:s,undo:r,mustExec:!0})}commitOrRemove(){var e;(e=_(this,cu))==null||e.commitOrRemove()}hasSomethingToControl(){return _(this,cu)||this.hasSelection}selectAll(){for(const e of _(this,Zr))e.commit();le(this,on,P5).call(this,_(this,to).values())}unselectAll(){var e;if(!(_(this,cu)&&(_(this,cu).commitOrRemove(),_(this,bo)!==Ws.NONE))&&!((e=_(this,dx))!=null&&e.commitOrRemove())&&this.hasSelection){for(const n of _(this,Zr))n.unselect();_(this,Zr).clear(),le(this,on,Hl).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,n,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;_(this,Qg)[0]+=e,_(this,Qg)[1]+=n;const[r,i]=_(this,Qg),a=[..._(this,Zr)],o=1e3;_(this,Hf)&&clearTimeout(_(this,Hf)),te(this,Hf,setTimeout(()=>{te(this,Hf,null),_(this,Qg)[0]=_(this,Qg)[1]=0,this.addCommands({cmd:()=>{for(const l of a)_(this,to).has(l.id)&&l.translateInPage(r,i)},undo:()=>{for(const l of a)_(this,to).has(l.id)&&l.translateInPage(-r,-i)},mustExec:!1})},o));for(const l of a)l.translateInPage(e,n)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),te(this,Vf,new Map);for(const e of _(this,Zr))_(this,Vf).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!_(this,Vf))return!1;this.disableUserSelect(!1);const e=_(this,Vf);te(this,Vf,null);let n=!1;for(const[{x:r,y:i,pageIndex:a},o]of e)o.newX=r,o.newY=i,o.newPageIndex=a,n||(n=r!==o.savedX||i!==o.savedY||a!==o.savedPageIndex);if(!n)return!1;const s=(r,i,a,o)=>
6883{if(_(this,to).has(r.id)){const l=_(this,Do).get(o);l?r._setParentAndPosition(l,i,a):(r.pageIndex=o,r.x=i,r.y=a)}};return this.addCommands({cmd:()=>{for(const[r,{newX:i,newY:a,newPageIndex:o}]of e)s(r,i,a,o)},undo:()=>{for(const[r,{savedX:i,savedY:a,savedPageIndex:o}]of e)s(r,i,a,o)},mustExec:!0}),!0}dragSelectedEditors(e,n){if(_(this,Vf))for(const s of _(this,Vf).keys())s.drag(e,n)}rebuild(e){if(e.parent===null){const n=this.getLayer(e.pageIndex);n?(n.changeParent(e),n.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())||_(this,Zr).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return _(this,cu)===e}getActive(){return _(this,cu)}getMode(){return _(this,bo)}get imageManager(){return sr(this,"imageManager",new A5)}getSelectionBoxes(e){if(!e)return null;const n=document.getSelection();for(let c=0,h=n.rangeCount;c<h;c++)if(!e.contains(n.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:r,width:i,height:a}=e.getBoundingClientRect();let o;switch(e.getAttribute("data-main-rotation")){case"90":o=(c,h,p,m)=>({x:(h-r)/a,y:1-(c+p-s)/i,width:m/a,height:p/i});break;case"180":o=(c,h,p,m)=>({x:1-(c+p-s)/i,y:1-(h+m-r)/a,width:p/i,height:m/a});break;case"270":o=(c,h,p,m)=>({x:1-(h+m-r)/a,y:(c-s)/i,width:m/a,height:p/i});break;default:o=(c,h,p,m)=>({x:(c-s)/i,y:(h-r)/a,width:p/i,height:m/a});break}const l=[];for(let c=0,h=n.rangeCount;c<h;c++){const p=n.getRangeAt(c);if(!p.collapsed)for(const{x:m,y,width:v,height:b}of p.getClientRects())v===0||b===0||l.push(o(m,y,v,b))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:n}){(_(this,Iw)||te(this,Iw,new Map)).set(e,n)}removeChangedExistingAnnotation({annotationElementId:e}){var n;(n=_(this,Iw))==null||n.delete(e)}renderAnnotationElement(e){var r;const n=(r=_(this,Iw))==null?void 0:r.get(e.data.id);if(!n)return;const s=_(this,Qp).getRawValue(n);s&&(_(this,bo)===Ws.NONE&&!s.hasBeenModified||s.renderAnnotationElement(e))}};Cw=new WeakMap,cu=new WeakMap,to=new WeakMap,Do=new WeakMap,kw=new WeakMap,Qp=new WeakMap,Iw=new WeakMap,ad=new WeakMap,Wg=new WeakMap,dx=new WeakMap,Nw=new WeakMap,hx=new WeakMap,Vf=new WeakMap,Ch=new WeakMap,fx=new WeakMap,VE=new WeakMap,zE=new WeakMap,Rw=new WeakMap,GE=new WeakMap,zf=new WeakMap,Kg=new WeakMap,Mw=new WeakMap,Yg=new WeakMap,Gf=new WeakMap,OR=new WeakMap,Xg=new WeakMap,HE=new WeakMap,Jg=new WeakMap,px=new WeakMap,qE=new WeakMap,WE=new WeakMap,bo=new WeakMap,Zr=new WeakMap,Zp=new WeakMap,mx=new WeakMap,KE=new WeakMap,YE=new WeakMap,Qg=new WeakMap,Hf=new WeakMap,em=new WeakMap,XE=new WeakMap,od=new WeakMap,on=new WeakSet,GI=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},k5=function(e){const{currentLayer:n}=this;if(n.hasTextLayer(e))return n;for(const s of _(this,Do).values())if(s.hasTextLayer(e))return s;return null},Pse=function(){const e=document.getSelection();if(!e||e.isCollapsed)return;const s=le(this,on,GI).call(this,e).closest(".textLayer"),r=this.getSelectionBoxes(s);r&&(_(this,Gf)||te(this,Gf,new iRe(this)),_(this,Gf).show(s,r,this.direction==="ltr"))},$se=function(){var i,a,o;const e=document.getSelection();if(!e||e.isCollapsed){_(this,Zp)&&((i=_(this,Gf))==null||i.hide(),te(this,Zp,null),le(this,on,Hl).call(this,{hasSelectedText:!1}));return}const{anchorNode:n}=e;if(n===_(this,Zp))return;const r=le(this,on,GI).call(this,e).closest(".textLayer");if(!r){_(this,Zp)&&((a=_(this,Gf))==null||a.hide(),te(this,Zp,null),le(this,on,Hl).call(this,{hasSelectedText:!1}));return}if((o=_(this,Gf))==null||o.hide(),te(this,Zp,n),le(this,on,Hl).call(this,{hasSelectedText:!0}),!(_(this,bo)!==Ws.HIGHLIGHT&&_(this,bo)!==Ws.NONE)&&(_(this,bo)===Ws.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),te(this,Yg,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=_(this,bo)===Ws.HIGHLIGHT?le(this,on,k5).call(this,r):null;l==null||l.toggleDrawing();const c=new AbortController,h=this.combinedSignal(c),p=m=>{m.type==="pointerup"&&m.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),m.type==="pointerup"&&le(this,on,HI).call(this,"main_toolbar"))};window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("blur",p,{signal:h})}},HI=function(e=""){_(this,bo)===Ws.HIGHLIGHT?this.highlightSelection(e):_(this,VE)&&le(this,on,Pse).call(this)},Dse=function(){document.addEventListener("selectionchange",le(this,on,$se).bind(this),{signal:this._signal})},Ose=function(){if(_(this,Kg))return;te(this,Kg,new AbortController);const e=this.combinedSignal(_(this,Kg));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},Lse=function(){var e;(e=_(this,Kg))==null||e.abort(),te(this,Kg,null)},I5=function(){if(_(this,Jg))return;te(this,Jg,new AbortController);const e=this.combinedSignal(_(this,Jg));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},jse=function(){var e;(e=_(this,Jg))==null||e.abort(),te(this,Jg,null)},N5=function(){if(_(this,Wg))return;te(this,Wg,new AbortController);const e=this.combinedSignal(_(this,Wg));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})},R5=function(){var e;(e=_(this,Wg))==null||e.abort(),te(this,Wg,null)},Bse=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},Hl=function(e){Object.entries(e).some(([s,r])=>_(this,YE)[s]!==r)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_(this,YE),e)}),_(this,bo)===Ws.HIGHLIGHT&&e.hasSelectedEditor===!1&&le(this,on,Wp).call(this,[[br.HIGHLIGHT_FREE,!0]]))},Wp=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},Use=async function(){if(!_(this,Xg)){te(this,Xg,!0);const e=[];for(const n of _(this,Do).values())e.push(n.enable());await Promise.all(e);for(const n of _(this,to).values())n.enable()}},Fse=function(){if(this.unselectAll(),_(this,Xg)){te(this,Xg,!1);for(const e of _(this,Do).values())e.disable();for(const e of _(this,to).values())e.disable()}},M5=function(e){const n=_(this,Do).get(e.pageIndex);n?n.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Vse=function(){let e=null;for(e of _(this,Zr));return e},gS=function(){if(_(this,to).size===0)return!0;
6883if(_(this,to).size===1)for(const e of _(this,to).values())return e.isEmpty();return!1},P5=function(e){for(const n of _(this,Zr))n.unselect();_(this,Zr).clear();for(const n of e)n.isEmpty()||(_(this,Zr).add(n),n.select());le(this,on,Hl).call(this,{hasSelectedEditor:this.hasSelection})},os(uw,"TRANSLATE_SMALL",1),os(uw,"TRANSLATE_BIG",10);let Dv=uw;var wo,qf,kh,Pw,Wf,uu,$w,Kf,Pc,tm,gx,Yf,Zg,Gh,yS,qI;const ql=class ql{constructor(e){oe(this,Gh);oe(this,wo,null);oe(this,qf,!1);oe(this,kh,null);oe(this,Pw,null);oe(this,Wf,null);oe(this,uu,null);oe(this,$w,!1);oe(this,Kf,null);oe(this,Pc,null);oe(this,tm,null);oe(this,gx,null);oe(this,Yf,!1);te(this,Pc,e),te(this,Yf,e._uiManager.useNewAltTextFlow),_(ql,Zg)||te(ql,Zg,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){ql._l10n??(ql._l10n=e)}async render(){const e=te(this,kh,document.createElement("button"));e.className="altText",e.tabIndex="0";const n=te(this,Pw,document.createElement("span"));e.append(n),_(this,Yf)?(e.classList.add("new"),e.setAttribute("data-l10n-id",_(ql,Zg).missing),n.setAttribute("data-l10n-id",_(ql,Zg)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=_(this,Pc)._uiManager._signal;e.addEventListener("contextmenu",Xh,{signal:s}),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:s});const r=i=>{i.preventDefault(),_(this,Pc)._uiManager.editAltText(_(this,Pc)),_(this,Yf)&&_(this,Pc)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:_(this,Gh,yS)}})};return e.addEventListener("click",r,{capture:!0,signal:s}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(te(this,$w,!0),r(i))},{signal:s}),await le(this,Gh,qI).call(this),e}finish(){_(this,kh)&&(_(this,kh).focus({focusVisible:_(this,$w)}),te(this,$w,!1))}isEmpty(){return _(this,Yf)?_(this,wo)===null:!_(this,wo)&&!_(this,qf)}hasData(){return _(this,Yf)?_(this,wo)!==null||!!_(this,tm):this.isEmpty()}get guessedText(){return _(this,tm)}async setGuessedText(e){_(this,wo)===null&&(te(this,tm,e),te(this,gx,await ql._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),le(this,Gh,qI).call(this))}toggleAltTextBadge(e=!1){var n;if(!_(this,Yf)||_(this,wo)){(n=_(this,Kf))==null||n.remove(),te(this,Kf,null);return}if(!_(this,Kf)){const s=te(this,Kf,document.createElement("div"));s.className="noAltTextBadge",_(this,Pc).div.append(s)}_(this,Kf).classList.toggle("hidden",!e)}serialize(e){let n=_(this,wo);return!e&&_(this,tm)===n&&(n=_(this,gx)),{altText:n,decorative:_(this,qf),guessedText:_(this,tm),textWithDisclaimer:_(this,gx)}}get data(){return{altText:_(this,wo),decorative:_(this,qf)}}set data({altText:e,decorative:n,guessedText:s,textWithDisclaimer:r,cancel:i=!1}){s&&(te(this,tm,s),te(this,gx,r)),!(_(this,wo)===e&&_(this,qf)===n)&&(i||(te(this,wo,e),te(this,qf,n)),le(this,Gh,qI).call(this))}toggle(e=!1){_(this,kh)&&(!e&&_(this,uu)&&(clearTimeout(_(this,uu)),te(this,uu,null)),_(this,kh).disabled=!e)}shown(){_(this,Pc)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:_(this,Gh,yS)}})}destroy(){var e,n;(e=_(this,kh))==null||e.remove(),te(this,kh,null),te(this,Pw,null),te(this,Wf,null),(n=_(this,Kf))==null||n.remove(),te(this,Kf,null)}};wo=new WeakMap,qf=new WeakMap,kh=new WeakMap,Pw=new WeakMap,Wf=new WeakMap,uu=new WeakMap,$w=new WeakMap,Kf=new WeakMap,Pc=new WeakMap,tm=new WeakMap,gx=new WeakMap,Yf=new WeakMap,Zg=new WeakMap,Gh=new WeakSet,yS=function(){return _(this,wo)&&"added"||_(this,wo)===null&&this.guessedText&&"review"||"missing"},qI=async function(){var r,i,a;const e=_(this,kh);if(!e)return;if(_(this,Yf)){if(e.classList.toggle("done",!!_(this,wo)),e.setAttribute("data-l10n-id",_(ql,Zg)[_(this,Gh,yS)]),(r=_(this,Pw))==null||r.setAttribute("data-l10n-id",_(ql,Zg)[`${_(this,Gh,yS)}-label`]),!_(this,wo)){(i=_(this,Wf))==null||i.remove();return}}else{if(!_(this,wo)&&!_(this,qf)){e.classList.remove("done"),(a=_(this,Wf))==null||a.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=_(this,Wf);if(!n){te(this,Wf,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${_(this,Pc).id}`;const o=100,l=_(this,Pc)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(_(this,uu)),te(this,uu,null)},{once:!0}),e.addEventListener("mouseenter",()=>
6883{te(this,uu,setTimeout(()=>{te(this,uu,null),_(this,Wf).classList.add("show"),_(this,Pc)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),e.addEventListener("mouseleave",()=>{var c;_(this,uu)&&(clearTimeout(_(this,uu)),te(this,uu,null)),(c=_(this,Wf))==null||c.classList.remove("show")},{signal:l})}_(this,qf)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=_(this,wo)),n.parentNode||e.append(n);const s=_(this,Pc).getImageForAltText();s==null||s.setAttribute("aria-describedby",n.id)},oe(ql,Zg,null),os(ql,"_l10n",null);let wR=ql;var JE,yx,QE,ZE,eT,tT,nT,Dw,nm,xx,e0,Bm,zse,Gse,$5;const qj=class qj{constructor({container:e,isPinchingDisabled:n=null,isPinchingStopped:s=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){oe(this,Bm);oe(this,JE);oe(this,yx,!1);oe(this,QE,null);oe(this,ZE);oe(this,eT);oe(this,tT);oe(this,nT);oe(this,Dw);oe(this,nm,null);oe(this,xx);oe(this,e0,null);te(this,JE,e),te(this,QE,s),te(this,ZE,n),te(this,eT,r),te(this,tT,i),te(this,nT,a),te(this,xx,new AbortController),te(this,Dw,AbortSignal.any([o,_(this,xx).signal])),e.addEventListener("touchstart",le(this,Bm,zse).bind(this),{passive:!1,signal:_(this,Dw)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return sr(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var e;(e=_(this,xx))==null||e.abort(),te(this,xx,null)}};JE=new WeakMap,yx=new WeakMap,QE=new WeakMap,ZE=new WeakMap,eT=new WeakMap,tT=new WeakMap,nT=new WeakMap,Dw=new WeakMap,nm=new WeakMap,xx=new WeakMap,e0=new WeakMap,Bm=new WeakSet,zse=function(e){var r,i,a;if((r=_(this,ZE))!=null&&r.call(this)||e.touches.length<2)return;if(!_(this,e0)){te(this,e0,new AbortController);const o=AbortSignal.any([_(this,Dw),_(this,e0).signal]),l=_(this,JE),c={signal:o,passive:!1};l.addEventListener("touchmove",le(this,Bm,Gse).bind(this),c),l.addEventListener("touchend",le(this,Bm,$5).bind(this),c),l.addEventListener("touchcancel",le(this,Bm,$5).bind(this),c),(i=_(this,eT))==null||i.call(this)}if(Cu(e),e.touches.length!==2||(a=_(this,QE))!=null&&a.call(this)){te(this,nm,null);return}let[n,s]=e.touches;n.identifier>s.identifier&&([n,s]=[s,n]),te(this,nm,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:s.screenX,touch1Y:s.screenY})},Gse=function(e){var j;if(!_(this,nm)||e.touches.length!==2)return;let[n,s]=e.touches;n.identifier>s.identifier&&([n,s]=[s,n]);const{screenX:r,screenY:i}=n,{screenX:a,screenY:o}=s,l=_(this,nm),{touch0X:c,touch0Y:h,touch1X:p,touch1Y:m}=l,y=p-c,v=m-h,b=a-r,S=o-i,E=Math.hypot(b,S)||1,I=Math.hypot(y,v)||1;if(!_(this,yx)&&Math.abs(I-E)<=qj.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=r,l.touch0Y=i,l.touch1X=a,l.touch1Y=o,e.preventDefault(),!_(this,yx)){te(this,yx,!0);return}const M=[(r+a)/2,(i+o)/2];(j=_(this,tT))==null||j.call(this,M,I,E)},$5=function(e){var n;_(this,e0).abort(),te(this,e0,null),(n=_(this,nT))==null||n.call(this),_(this,nm)&&(e.preventDefault(),te(this,nm,null),te(this,yx,!1))};let _R=qj;var vx,Ih,Pi,Ow,t0,sT,bx,Oo,wx,sm,n0,rT,_x,du,iT,Sx,rm,Xf,Lw,jw,ld,Ex,aT,LR,cs,D5,oT,O5,WI,Hse,qse,L5,KI,j5,Wse,Kse,Yse,B5,Xse,U5,Jse,Qse,Zse,F5,xS;const Xs=class Xs{constructor(e){oe(this,cs);oe(this,vx,null);oe(this,Ih,null);oe(this,Pi,null);oe(this,Ow,!1);oe(this,t0,null);oe(this,sT,"");oe(this,bx,!1);oe(this,Oo,null);oe(this,wx,null);oe(this,sm,null);oe(this,n0,null);oe(this,rT,"");oe(this,_x,!1);oe(this,du,null);oe(this,iT,!1);oe(this,Sx,!1);oe(this,rm,!1);oe(this,Xf,null);oe(this,Lw,0);oe(this,jw,0);oe(this,ld,null);oe(this,Ex,null);os(this,"_editToolbar",null);os(this,"_initialOptions",Object.create(null));os(this,"_initialData",null);os(this,"_isVisible",!0);os(this,"_uiManager",null);os(this,"_focusEventsAllowed",!0);oe(this,aT,!1);oe(this,LR,Xs._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:n,rawDims:{pageWidth:s,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,r],this.pageTranslation=[i,a];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=Xs.prototype._resizeWithKeyboard,n=Dv.TRANSLATE_SMALL,s=Dv.TRANSLATE_BIG;return sr(this,"_resizerKeyboardManager",new DA([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],Xs.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return sr(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const n=new lRe({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});n.annotationElementId=e.annotationElementId,n.deleted=!0,n._uiManager.addToAnnotationStorage(n)}static initialize(e,n){if(Xs._l10n??(Xs._l10n=e),Xs._l10nResizer||(Xs._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"})),Xs._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);Xs._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,n){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,n){mi("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _(this,aT)}set _isDraggable(e){var n;te(this,aT,e),(n=this.div)==null||n.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,n]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*n/(e*2),this.y+=this.width*e/(n*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*n/(e*2),this.y-=this.width*e/(n*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}
6883setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_(this,LR)}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):le(this,cs,xS).call(this),this.parent=e}focusin(e){this._focusEventsAllowed&&(_(this,_x)?te(this,_x,!1):this.parent.setSelected(this))}focusout(e){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const n=e.relatedTarget;n!=null&&n.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,n,s,r){const[i,a]=this.parentDimensions;[s,r]=this.screenToPageTranslation(s,r),this.x=(e+s)/i,this.y=(n+r)/a,this.fixAndSetPosition()}translate(e,n){le(this,cs,D5).call(this,this.parentDimensions,e,n)}translateInPage(e,n){_(this,du)||te(this,du,[this.x,this.y,this.width,this.height]),le(this,cs,D5).call(this,this.pageDimensions,e,n),this.div.scrollIntoView({block:"nearest"})}drag(e,n){_(this,du)||te(this,du,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=n/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:p,y:m}=this.div.getBoundingClientRect();this.parent.findNewParent(this,p,m)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,c]=this.getBaseTranslation();a+=l,o+=c;const{style:h}=s;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(e,n){}_onTranslated(e,n){}get _hasBeenMoved(){return!!_(this,du)&&(_(this,du)[0]!==this.x||_(this,du)[1]!==this.y)}get _hasBeenResized(){return!!_(this,du)&&(_(this,du)[2]!==this.width||_(this,du)[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:s}=Xs,r=s/e,i=s/n;switch(this.rotation){case 90:return[-r,i];case 180:return[r,i];case 270:return[r,-i];default:return[-r,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:n},pageDimensions:[s,r]}=this;let{x:i,y:a,width:o,height:l}=this;if(o*=s,l*=r,i*=s,a*=r,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(s-o,i)),a=Math.max(0,Math.min(r-l,a));break;case 90:i=Math.max(0,Math.min(s-l,i)),a=Math.min(r,Math.max(o,a));break;case 180:i=Math.min(s,Math.max(o,i)),a=Math.min(r,Math.max(l,a));break;case 270:i=Math.min(s,Math.max(l,i)),a=Math.max(0,Math.min(r-o,a));break}this.x=i/=s,this.y=a/=r;const[c,h]=this.getBaseTranslation();i+=c,a+=h,n.left=`${(100*i).toFixed(2)}%`,n.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,n){var s;return le(s=Xs,oT,O5).call(s,e,n,this.parentRotation)}pageTranslationToScreen(e,n){var s;return le(s=Xs,oT,O5).call(s,e,n,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:[n,s]}=this;return[n*e,s*e]}setDims(e,n){const[s,r]=this.parentDimensions,{style:i}=this.div;i.width=`${(100*e/s).toFixed(2)}%`,_(this,bx)||(i.height=`${(100*n/r).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:n,width:s}=e,r=s.endsWith("%"),i=!_(this,bx)&&n.endsWith("%");if(r&&i)return;const[a,o]=this.parentDimensions;r||(e.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!_(this,bx)&&!i&&(e.height=`${(100*parseFloat(n)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=_(this,Pi))==null||e.finish()}async addEditToolbar(){return this._editToolbar||_(this,Sx)?this._editToolbar:(this._editToolbar=new E5(this),this.div.append(this._editToolbar.render()),_(this,Pi)&&await this._editToolbar.addAltText(_(this,Pi)),this._editToolbar)}removeEditToolbar(){var e;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(e=_(this,Pi))==null||e.destroy())}addContainer(e){var s;const n=(s=this._editToolbar)==null?void 0:s.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){_(this,Pi)||(wR.initialize(Xs._l10n),te(this,Pi,new wR(this)),_(this,vx)&&(_(this,Pi).data=_(this,vx),te(this,vx,null)),await this.addEditToolbar())}get altTextData(){var e;return(e=_(this,Pi))==null?void 0:e.data}set altTextData(e){_(this,Pi)&&(_(this,Pi).data=e)}get guessedAltText(){var e;return(e=_(this,Pi))==null?void 0:e.guessedText}async setGuessedAltText(e){var n;await((n=_(this,Pi))==null?void 0:n.setGuessedText(e))}serializeAltText(e){var n;return(n=_(this,Pi))==null?void 0:n.serialize(e)}hasAltText(){return!!_(this,Pi)&&!_(this,Pi).isEmpty()}hasAltTextData(){var e;return((e=_(this,Pi))==null?void 0:e.hasData())??!1}render(){var i;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=_(this,Ow)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),le(this,cs,U5).call(this);const[e,n]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*n/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/n).toFixed(2)}%`);const[s,r]=this.getInitialTranslation();return this.translate(s,r),bR(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_(this,Ex)||te(this,Ex,new _R({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:le(this,cs,Wse).bind(this),onPinching:le(this,cs,Kse).bind(this),onPinchEnd:le(this,cs,Yse).bind(this),signal:this._uiManager._signal}))),(i=this._uiManager._editorUndoBar)==null||i.hide(),this.div}pointerdown(e){const{isMac:n}=nc.platform;if(e.button!==0||e.ctrlKey&&n){e.preventDefault();return}if(te(this,_x,!0),this._isDraggable){le(this,cs,Xse).call(this,e);return}le(this,cs,B5).call(this,e)}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_(this,Xf)&&clearTimeout(_(this,Xf)),te(this,Xf,setTimeout(()=>{var e;te(this,Xf,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,n,s){e.changeParent(this),this.x=n,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(e,n,s=this.rotation){const r=this.parentScale,[i,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=e/r,h=n/r,p=this.x*i,m=this.y*a,y=this.width*i,v=this.height*a;switch(s){case 0:return[p+c+o,a-m-h-v+l,p+c+y+o,a-m-h+l];case 90:return[p+h+o,a-m+c+l,p+h+v+o,a-m+c+y+l];case 180:return[p-c-y+o,a-m+h+l,p-c+o,a-m+h+v+l];case 270:return[p-h-v+o,a-m-c-y+l,p-h+o,a-m-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,n){const[s,r,i,a]=e,o=i-s,l=a-r;switch(this.rotation){case 0:return[s,n-a,o,l];case 90:return[s,n-r,l,o];case 180:return[i,n-r,o,l];case 270:return[i,n-a,l,o];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){te(this,Sx,!0)}disableEditMode(){te(this,Sx,!1)}isInEditMode(){return _(this,Sx)}shouldGetKeyboardEvents(){return _(this,rm)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:n,bottom:s,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return n<a&&r>0&&e<i&&s>0}rebuild(){le(this,cs,U5).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,n=null){mi("An editor must be serializable")}static async deserialize(e,n,s){const r=new this.prototype.constructor({parent:n,id:n.getNextId(),uiManager:s});r.rotation=e.rotation,te(r,vx,e.accessibilityData);const[i,a]=r.pageDimensions,[o,l,c,h]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=l/a,r.width=c/i,r.height=h/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,n;if((e=_(this,n0))==null||e.abort(),te(this,n0,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_(this,Xf)&&(clearTimeout(_(this,Xf)),te(this,Xf,null)),le(this,cs,xS).call(this),this.removeEditToolbar(),_(this,ld)){for(const s of _(this,ld).values())clearTimeout(s);te(this,ld,null)}this.parent=null,(n=_(this,Ex))==null||n.destroy(),te(this,Ex,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(le(this,cs,Hse).call(this),_(this,Oo).classList.remove("hidden"),bR(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),te(this,sm,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=_(this,Oo).children;if(!_(this,Ih)){te(this,Ih,Array.from(n));const a=le(this,cs,Jse).bind(this),o=le(this,cs,Qse).bind(this),l=this._uiManager._signal;for(const c of _(this,Ih)){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",le(this,cs,Zse).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",Xs._l10nResizer[h])}}const s=_(this,Ih)[0];let r=0;for(const a of n){if(a===s)break;r++}const i=(360-this.rotation+this.parentRotation)%360/90*(_(this,Ih).length/4);if(i!==r){if(i<r)for(let o=0;o<r-i;o++)_(this,Oo).append(_(this,Oo).firstChild);else if(i>r)for(let o=0;o<i-r;o++)_(this,Oo).firstChild.before(_(this,Oo).lastChild);let a=0;for(const o of n){const c=_(this,Ih)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",Xs._l10nResizer[c])}}le(this,cs,F5).call(this,0),te(this,rm,!0),_(this,Oo).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,n){_(this,rm)&&le(this,cs,j5).call(this,_(this,rT),{deltaX:e,deltaY:n,fromKeyboard:!0})}_stopResizingWithKeyboard(){le(this,cs,xS).call(this),this.div.focus()}select(){var e,n,s;if(this.makeResizable(),(e=this.div)==null||e.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var r,i;(r=this.div)!=null&&r.classList.contains("selectedEditor")&&((i=this._editToolbar)==null||i.show())});return}(n=this._editToolbar)==null||n.show(),(s=_(this,Pi))==null||s.toggleAltTextBadge(!1)}unselect(){var e,n,s,r,i;(e=_(this,Oo))==null||e.classList.add("hidden"),(n=this.div)==null||n.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(r=this._editToolbar)==null||r.hide(),(i=_(this,Pi))==null||i.toggleAltTextBadge(!0)}updateParams(e,n){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return _(this,iT)}set isEditing(e){te(this,iT,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,n){te(this,bx,!0);const s=e/n,{style:r}=this.div;r.aspectRatio=s,r.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,n=!1){if(n){_(this,ld)||te(this,ld,new Map);const{action:s}=e;let r=_(this,ld).get(s);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(e),_(this,ld).delete(s),_(this,ld).size===0&&te(this,ld,null)},Xs._telemetryTimeout),_(this,ld).set(s,r);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),te(this,Ow,!1)}disable(){this.div&&(this.div.tabIndex=-1),te(this,Ow,!0)}renderAnnotationElement(e){let n=e.container.querySelector(".annotationContent");
vendor: 5,297 bytes, line 6883
6883if(!n)n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),e.container.prepend(n);else if(n.nodeName==="CANVAS"){const s=n;n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),s.before(n)}return n}resetAnnotationElement(e){const{firstChild:n}=e.container;(n==null?void 0:n.nodeName)==="DIV"&&n.classList.contains("annotationContent")&&n.remove()}};vx=new WeakMap,Ih=new WeakMap,Pi=new WeakMap,Ow=new WeakMap,t0=new WeakMap,sT=new WeakMap,bx=new WeakMap,Oo=new WeakMap,wx=new WeakMap,sm=new WeakMap,n0=new WeakMap,rT=new WeakMap,_x=new WeakMap,du=new WeakMap,iT=new WeakMap,Sx=new WeakMap,rm=new WeakMap,Xf=new WeakMap,Lw=new WeakMap,jw=new WeakMap,ld=new WeakMap,Ex=new WeakMap,aT=new WeakMap,LR=new WeakMap,cs=new WeakSet,D5=function([e,n],s,r){[s,r]=this.screenToPageTranslation(s,r),this.x+=s/e,this.y+=r/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},oT=new WeakSet,O5=function(e,n,s){switch(s){case 90:return[n,-e];case 180:return[-e,-n];case 270:return[-n,e];default:return[e,n]}},WI=function(e){switch(e){case 90:{const[n,s]=this.pageDimensions;return[0,-n/s,s/n,0]}case 180:return[-1,0,0,-1];case 270:{const[n,s]=this.pageDimensions;return[0,n/s,-s/n,0]}default:return[1,0,0,1]}},Hse=function(){if(_(this,Oo))return;te(this,Oo,document.createElement("div")),_(this,Oo).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],n=this._uiManager._signal;for(const s of e){const r=document.createElement("div");_(this,Oo).append(r),r.classList.add("resizer",s),r.setAttribute("data-resizer-name",s),r.addEventListener("pointerdown",le(this,cs,qse).bind(this,s),{signal:n}),r.addEventListener("contextmenu",Xh,{signal:n}),r.tabIndex=-1}this.div.prepend(_(this,Oo))},qse=function(e,n){var h;n.preventDefault();const{isMac:s}=nc.platform;if(n.button!==0||n.ctrlKey&&s)return;(h=_(this,Pi))==null||h.toggle(!1);const r=this._isDraggable;this._isDraggable=!1,te(this,wx,[n.screenX,n.screenY]);const i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",le(this,cs,j5).bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Cu,{passive:!1,signal:a}),window.addEventListener("contextmenu",Xh,{signal:a}),te(this,sm,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(n.target).cursor;const c=()=>{var p;i.abort(),this.parent.togglePointerEvents(!0),(p=_(this,Pi))==null||p.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=l,le(this,cs,KI).call(this)};window.addEventListener("pointerup",c,{signal:a}),window.addEventListener("blur",c,{signal:a})},L5=function(e,n,s,r){this.width=s,this.height=r,this.x=e,this.y=n;const[i,a]=this.parentDimensions;this.setDims(i*s,a*r),this.fixAndSetPosition(),this._onResized()},KI=function(){if(!_(this,sm))return;const{savedX:e,savedY:n,savedWidth:s,savedHeight:r}=_(this,sm);te(this,sm,null);const i=this.x,a=this.y,o=this.width,l=this.height;i===e&&a===n&&o===s&&l===r||this.addCommands({cmd:le(this,cs,L5).bind(this,i,a,o,l),undo:le(this,cs,L5).bind(this,e,n,s,r),mustExec:!0})},j5=function(e,n){const[s,r]=this.parentDimensions,i=this.x,a=this.y,o=this.width,l=this.height,c=Xs.MIN_SIZE/s,h=Xs.MIN_SIZE/r,p=le(this,cs,WI).call(this,this.rotation),m=(me,xe)=>[p[0]*me+p[2]*xe,p[1]*me+p[3]*xe],y=le(this,cs,WI).call(this,360-this.rotation),v=(me,xe)=>[y[0]*me+y[2]*xe,y[1]*me+y[3]*xe];let b,S,E=!1,I=!1;switch(e){case"topLeft":E=!0,b=(me,xe)=>[0,0],S=(me,xe)=>[me,xe];break;case"topMiddle":b=(me,xe)=>[me/2,0],S=(me,xe)=>[me/2,xe];break;case"topRight":E=!0,b=(me,xe)=>[me,0],S=(me,xe)=>[0,xe];break;case"middleRight":I=!0,b=(me,xe)=>[me,xe/2],S=(me,xe)=>[0,xe/2];break;case"bottomRight":E=!0,b=(me,xe)=>[me,xe],S=(me,xe)=>[0,0];break;case"bottomMiddle":b=(me,xe)=>[me/2,xe],S=(me,xe)=>[me/2,0];break;case"bottomLeft":E=!0,b=(me,xe)=>[0,xe],S=(me,xe)=>[me,0];break;case"middleLeft":I=!0,b=(me,xe)=>[0,xe/2],S=(me,xe)=>[me,xe/2];break}const M=b(o,l),j=S(o,l);let L=m(...j);const K=Xs._round(i+L[0]),D=Xs._round(a+L[1]);let R=1,B=1,G,X;if(n.fromKeyboard)({deltaX:G,deltaY:X}=n);else{const{screenX:me,screenY:xe}=n,[Le,ve]=_(this,wx);[G,X]=this.screenToPageTranslation(me-Le,xe-ve),_(this,wx)[0]=me,_(this,wx)[1]=xe}if([G,X]=v(G/s,X/r),E){const me=Math.hypot(o,l);R=B=Math.max(Math.min(Math.hypot(j[0]-M[0]-G,j[1]-M[1]-X)/me,1/o,1/l),c/o,h/l)}else I?R=Math.max(c,Math.min(1,Math.abs(j[0]-M[0]-G)))/o:B=Math.max(h,Math.min(1,Math.abs(j[1]-M[1]-X)))/l;const H=Xs._round(o*R),Y=Xs._round(l*B);L=m(...S(H,Y));const F=K-L[0],we=D-L[1];_(this,du)||te(this,du,[this.x,this.y,this.width,this.height]),this.width=H,this.height=Y,this.x=F,this.y=we,this.setDims(s*H,r*Y),this.fixAndSetPosition(),this._onResizing()},Wse=function(){var e;te(this,sm,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=_(this,Pi))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)},Kse=function(e,n,s){let i=.7*(s/n)+1-.7;
6883if(i===1)return;const a=le(this,cs,WI).call(this,this.rotation),o=(K,D)=>[a[0]*K+a[2]*D,a[1]*K+a[3]*D],[l,c]=this.parentDimensions,h=this.x,p=this.y,m=this.width,y=this.height,v=Xs.MIN_SIZE/l,b=Xs.MIN_SIZE/c;i=Math.max(Math.min(i,1/m,1/y),v/m,b/y);const S=Xs._round(m*i),E=Xs._round(y*i);if(S===m&&E===y)return;_(this,du)||te(this,du,[h,p,m,y]);const I=o(m/2,y/2),M=Xs._round(h+I[0]),j=Xs._round(p+I[1]),L=o(S/2,E/2);this.x=M-L[0],this.y=j-L[1],this.width=S,this.height=E,this.setDims(l*S,c*E),this.fixAndSetPosition(),this._onResizing()},Yse=function(){var e;(e=_(this,Pi))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),le(this,cs,KI).call(this)},B5=function(e){const{isMac:n}=nc.platform;e.ctrlKey&&!n||e.shiftKey||e.metaKey&&n?this.parent.toggleSelected(this):this.parent.setSelected(this)},Xse=function(e){const{isSelected:n}=this;this._uiManager.setUpDragSession();let s=!1;const r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=c=>{r.abort(),te(this,t0,null),te(this,_x,!1),this._uiManager.endDragSession()||le(this,cs,B5).call(this,c),s&&this._onStopDragging()};n&&(te(this,Lw,e.clientX),te(this,jw,e.clientY),te(this,t0,e.pointerId),te(this,sT,e.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._onStartDragging());const{clientX:h,clientY:p,pointerId:m}=c;if(m!==_(this,t0)){Cu(c);return}const[y,v]=this.screenToPageTranslation(h-_(this,Lw),p-_(this,jw));te(this,Lw,h),te(this,jw,p),this._uiManager.dragSelectedEditors(y,v)},a),window.addEventListener("touchmove",Cu,a),window.addEventListener("pointerdown",c=>{c.pointerType===_(this,sT)&&(_(this,Ex)||c.isPrimary)&&o(c),Cu(c)},a));const l=c=>{if(!_(this,t0)||_(this,t0)===c.pointerId){o(c);return}Cu(c)};window.addEventListener("pointerup",l,{signal:i}),window.addEventListener("blur",l,{signal:i})},U5=function(){if(_(this,n0)||!this.div)return;te(this,n0,new AbortController);const e=this._uiManager.combinedSignal(_(this,n0));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},Jse=function(e){Xs._resizerKeyboardManager.exec(this,e)},Qse=function(e){var n;_(this,rm)&&((n=e.relatedTarget)==null?void 0:n.parentNode)!==_(this,Oo)&&le(this,cs,xS).call(this)},Zse=function(e){te(this,rT,_(this,rm)?e:"")},F5=function(e){if(_(this,Ih))for(const n of _(this,Ih))n.tabIndex=e},xS=function(){te(this,rm,!1),le(this,cs,F5).call(this,-1),le(this,cs,KI).call(this)},oe(Xs,oT),os(Xs,"_l10n",null),os(Xs,"_l10nResizer",null),os(Xs,"_borderLineWidth",-1),os(Xs,"_colorManager",new C5),os(Xs,"_zIndex",1),os(Xs,"_telemetryTimeout",1e3);let ea=Xs;class lRe extends ea{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const XH=3285377520,sd=4294901760,Of=65535;class ere{constructor(e){this.h1=e?e&4294967295:XH,this.h2=e?e&4294967295:XH}update(e){let n,s;if(typeof e=="string"){n=new Uint8Array(e.length*2),s=0;for(let b=0,S=e.length;b<S;b++){const E=e.charCodeAt(b);E<=255?n[s++]=E:(n[s++]=E>>>8,n[s++]=E&255)}}else if(ArrayBuffer.isView(e))n=e.slice(),s=n.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const r=s>>2,i=s-r*4,a=new Uint32Array(n.buffer,0,r);let o=0,l=0,c=this.h1,h=this.h2;const p=3432918353,m=461845907,y=p&Of,v=m&Of;for(let b=0;b<r;b++)b&1?(o=a[b],o=o*p&sd|o*y&Of,o=o<<15|o>>>17,o=o*m&sd|o*v&Of,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[b],l=l*p&sd|l*y&Of,l=l<<15|l>>>17,l=l*m&sd|l*v&Of,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(o=0,i){case 3:o^=n[r*4+2]<<16;case 2:o^=n[r*4+1]<<8;case 1:o^=n[r*4],o=o*p&sd|o*y&Of,o=o<<15|o>>>17,o=o*m&sd|o*v&Of,r&1?c^=o:h^=o}this.h1=c,this.h2=h}hexdigest(){let e=this.h1,n=this.h2;return e^=n>>>1,e=e*3981806797&sd|e*36045&Of,n=n*4283543511&sd|((n<<16|e>>>16)*2950163797&sd)>>>16,e^=n>>>1,e=e*444984403&sd|e*60499&Of,n=n*3301882366&sd|((n<<16|e>>>16)*3120437893&sd)>>>16,e^=n>>>1,(e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}}const V5=Object.freeze({map:null,hash:"",transfer:void 0});var Tx,Ax,_o,jR,tre;class kj{constructor(){oe(this,jR);oe(this,Tx,!1);oe(this,Ax,null);oe(this,_o,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,n){const s=_(this,_o).get(e);return s===void 0?n:Object.assign(n,s)}getRawValue(e){return _(this,_o).get(e)}remove(e){if(_(this,_o).delete(e),_(this,_o).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const n of _(this,_o).values())if(n instanceof ea)return;this.onAnnotationEditor(null)}}setValue(e,n){const s=_(this,_o).get(e);let r=!1;if(s!==void 0)for(const[i,a]of Object.entries(n))s[i]!==a&&(r=!0,s[i]=a);else r=!0,_(this,_o).set(e,n);r&&le(this,jR,tre).call(this),n instanceof ea&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(n.constructor._type)}has(e){return _(this,_o).has(e)}getAll(){return _(this,_o).size>0?_j(_(this,_o)):null}setAll(e){for(const[n,s]of Object.entries(e))this.setValue(n,s)}get size(){return _(this,_o).size}resetModified(){_(this,Tx)&&(te(this,Tx,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new nre(this)}get serializable(){if(_(this,_o).size===0)return V5;const e=new Map,n=new ere,s=[],r=Object.create(null);let i=!1;
6883for(const[a,o]of _(this,_o)){const l=o instanceof ea?o.serialize(!1,r):o;l&&(e.set(a,l),n.update(`${a}:${JSON.stringify(l)}`),i||(i=!!l.bitmap))}if(i)for(const a of e.values())a.bitmap&&s.push(a.bitmap);return e.size>0?{map:e,hash:n.hexdigest(),transfer:s}:V5}get editorStats(){let e=null;const n=new Map;for(const s of _(this,_o).values()){if(!(s instanceof ea))continue;const r=s.telemetryFinalData;if(!r)continue;const{type:i}=r;n.has(i)||n.set(i,Object.getPrototypeOf(s).constructor),e||(e=Object.create(null));const a=e[i]||(e[i]=new Map);for(const[o,l]of Object.entries(r)){if(o==="type")continue;let c=a.get(o);c||(c=new Map,a.set(o,c));const h=c.get(l)??0;c.set(l,h+1)}}for(const[s,r]of n)e[s]=r.computeTelemetryFinalData(e[s]);return e}resetModifiedIds(){te(this,Ax,null)}get modifiedIds(){if(_(this,Ax))return _(this,Ax);const e=[];for(const n of _(this,_o).values())!(n instanceof ea)||!n.annotationElementId||!n.serialize()||e.push(n.annotationElementId);return te(this,Ax,{ids:new Set(e),hash:e.join(",")})}}Tx=new WeakMap,Ax=new WeakMap,_o=new WeakMap,jR=new WeakSet,tre=function(){_(this,Tx)||(te(this,Tx,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var lT;class nre extends kj{constructor(n){super();oe(this,lT);const{map:s,hash:r,transfer:i}=n.serializable,a=structuredClone(s,i?{transfer:i}:null);te(this,lT,{map:a,hash:r,transfer:i})}get print(){mi("Should not call PrintAnnotationStorage.print")}get serializable(){return _(this,lT)}get modifiedIds(){return sr(this,"modifiedIds",{ids:new Set,hash:""})}}lT=new WeakMap;var Bw;class cRe{constructor({ownerDocument:e=globalThis.document,styleElement:n=null}){oe(this,Bw,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 n=this.styleElement.sheet;n.insertRule(e,n.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),_(this,Bw).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:n}){if(!(!e||_(this,Bw).has(e.loadedName))){if(Oa(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:r,style:i}=e,a=new FontFace(s,r,i);this.addNativeFontFace(a);try{await a.load(),_(this,Bw).add(s),n==null||n(e)}catch{Ks(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}mi("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(r){throw Ks(`Failed to load font '${s.family}': '${r}'.`),e.disableFontFace=!0,r}}return}const n=e.createFontFaceRule();if(n){if(this.insertRule(n),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const r=this._queueLoadingCallback(s);this._prepareFontLoadEvent(e,r)})}}get isFontLoadingAPISupported(){var n;const e=!!((n=this._document)!=null&&n.fonts);return sr(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){let e=!1;return(yl||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),sr(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){function n(){for(Oa(!r.done,"completeRequest() cannot be called twice."),r.done=!0;s.length>0&&s[0].done;){const i=s.shift();setTimeout(i.callback,0)}}const{loadingRequests:s}=this,r={done:!1,complete:n,callback:e};return s.push(r),r}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return sr(this,"_loadTestFont",e)}
6883_prepareFontLoadEvent(e,n){function s(j,L){return j.charCodeAt(L)<<24|j.charCodeAt(L+1)<<16|j.charCodeAt(L+2)<<8|j.charCodeAt(L+3)&255}function r(j,L,K,D){const R=j.substring(0,L),B=j.substring(L+K);return R+D+B}let i,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let c=0;function h(j,L){if(++c>30){Ks("Load test font never loaded."),L();return}if(l.font="30px "+j,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){L();return}setTimeout(h.bind(null,j,L))}const p=`lt${Date.now()}${this.loadTestFontId++}`;let m=this._loadTestFont;m=r(m,976,p.length,p);const v=16,b=1482184792;let S=s(m,v);for(i=0,a=p.length-3;i<a;i+=4)S=S-b+s(p,i)|0;i<p.length&&(S=S-b+s(p+"XXX",i)|0),m=r(m,v,4,KNe(S));const E=`url(data:font/opentype;base64,${btoa(m)});`,I=`@font-face {font-family:"${p}";src:${E}}`;this.insertRule(I);const M=this._document.createElement("div");M.style.visibility="hidden",M.style.width=M.style.height="10px",M.style.position="absolute",M.style.top=M.style.left="0px";for(const j of[e.loadedName,p]){const L=this._document.createElement("span");L.textContent="Hi",L.style.fontFamily=j,M.append(L)}this._document.body.append(M),h(p,()=>{M.remove(),n.complete()})}}Bw=new WeakMap;class uRe{constructor(e,{disableFontFace:n=!1,fontExtraProperties:s=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(const i in e)this[i]=e[i];this.disableFontFace=n===!0,this.fontExtraProperties=s===!0,this._inspectFont=r}createNativeFontFace(){var n;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(n=this._inspectFont)==null||n.call(this,this),e}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${eRe(this.data)});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let r=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(r+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${r}src:${e}}`}return(s=this._inspectFont)==null||s.call(this,this,e),n}getPathGenerator(e,n){if(this.compiledGlyphs[n]!==void 0)return this.compiledGlyphs[n];const s=this.loadedName+"_path_"+n;let r;try{r=e.get(s)}catch(a){Ks(`getPathGenerator - ignoring character: "${a}".`)}const i=new Path2D(r||"");return this.fontExtraProperties||e.delete(s),this.compiledGlyphs[n]=i}}const oI={DATA:1,ERROR:2},Pa={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function JH(){}function Rc(t){if(t instanceof W0||t instanceof w5||t instanceof PE||t instanceof WH||t instanceof vR||t instanceof v3)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||mi('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new W0(t.message);case"InvalidPDFException":return new w5(t.message);case"MissingPDFException":return new PE(t.message);case"PasswordException":return new WH(t.message,t.code);case"UnexpectedResponseException":return new vR(t.message,t.status);case"UnknownErrorException":return new v3(t.message,t.details)}return new v3(t.message,t.toString())}var Uw,_d,sre,rre,ire,YI;class vS{constructor(e,n,s){oe(this,_d);oe(this,Uw,new AbortController);this.sourceName=e,this.targetName=n,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",le(this,_d,sre).bind(this),{signal:_(this,Uw).signal})}on(e,n){const s=this.actionHandler;if(s[e])throw new Error(`There is already an actionName called "${e}"`);s[e]=n}send(e,n,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:n},s)}
6883sendWithPromise(e,n,s){const r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:n},s)}catch(a){i.reject(a)}return i.promise}sendWithStream(e,n,s,r){const i=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[i]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:n,desiredSize:c.desiredSize},r),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[i].pullCall=h,l.postMessage({sourceName:a,targetName:o,stream:Pa.PULL,streamId:i,desiredSize:c.desiredSize}),h.promise},cancel:c=>{Oa(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[i].cancelCall=h,this.streamControllers[i].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Pa.CANCEL,streamId:i,reason:Rc(c)}),h.promise}},s)}destroy(){var e;(e=_(this,Uw))==null||e.abort(),te(this,Uw,null)}}Uw=new WeakMap,_d=new WeakSet,sre=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){le(this,_d,ire).call(this,e);return}if(e.callback){const s=e.callbackId,r=this.callbackCapabilities[s];if(!r)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],e.callback===oI.DATA)r.resolve(e.data);else if(e.callback===oI.ERROR)r.reject(Rc(e.reason));else throw new Error("Unexpected callback case");return}const n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const s=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(n,e.data).then(function(a){i.postMessage({sourceName:s,targetName:r,callback:oI.DATA,callbackId:e.callbackId,data:a})},function(a){i.postMessage({sourceName:s,targetName:r,callback:oI.ERROR,callbackId:e.callbackId,reason:Rc(a)})});return}if(e.streamId){le(this,_d,rre).call(this,e);return}n(e.data)},rre=function(e){const n=e.streamId,s=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],l={enqueue(c,h=1,p){if(this.isCancelled)return;const m=this.desiredSize;this.desiredSize-=h,m>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:s,targetName:r,stream:Pa.ENQUEUE,streamId:n,chunk:c},p)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:s,targetName:r,stream:Pa.CLOSE,streamId:n}),delete a.streamSinks[n])},error(c){Oa(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:s,targetName:r,stream:Pa.ERROR,streamId:n,reason:Rc(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[n]=l,Promise.try(o,e.data,l).then(function(){i.postMessage({sourceName:s,targetName:r,stream:Pa.START_COMPLETE,streamId:n,success:!0})},function(c){i.postMessage({sourceName:s,targetName:r,stream:Pa.START_COMPLETE,streamId:n,reason:Rc(c)})})},ire=function(e){const n=e.streamId,s=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[n],o=this.streamSinks[n];switch(e.stream){case Pa.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(Rc(e.reason));break;case Pa.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(Rc(e.reason));break;case Pa.PULL:if(!o){i.postMessage({sourceName:s,targetName:r,stream:Pa.PULL_COMPLETE,streamId:n,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||JH).then(function(){i.postMessage({sourceName:s,targetName:r,stream:Pa.PULL_COMPLETE,streamId:n,success:!0})},function(c){i.postMessage({sourceName:s,targetName:r,stream:Pa.PULL_COMPLETE,streamId:n,reason:Rc(c)})});break;case Pa.ENQUEUE:if(Oa(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(e.chunk);break;case Pa.CLOSE:if(Oa(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),le(this,_d,YI).call(this,a,n);break;case Pa.ERROR:Oa(a,"error should have stream controller"),a.controller.error(Rc(e.reason)),le(this,_d,YI).call(this,a,n);break;case Pa.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(Rc(e.reason)),le(this,_d,YI).call(this,a,n);break;case Pa.CANCEL:if(!o)break;const l=Rc(e.reason);Promise.try(o.onCancel||JH,l).then(function(){i.postMessage({sourceName:s,targetName:r,stream
6883:Pa.CANCEL_COMPLETE,streamId:n,success:!0})},function(c){i.postMessage({sourceName:s,targetName:r,stream:Pa.CANCEL_COMPLETE,streamId:n,reason:Rc(c)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}},YI=async function(e,n){var s,r,i;await Promise.allSettled([(s=e.startCall)==null?void 0:s.promise,(r=e.pullCall)==null?void 0:r.promise,(i=e.cancelCall)==null?void 0:i.promise]),delete this.streamControllers[n]};var cT;class are{constructor({enableHWA:e=!1}){oe(this,cT,!1);te(this,cT,e)}create(e,n){if(e<=0||n<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(e,n);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!_(this,cT)})}}reset(e,n,s){if(!e.canvas)throw new Error("Canvas is not specified");if(n<=0||s<=0)throw new Error("Invalid canvas size");e.canvas.width=n,e.canvas.height=s}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,n){mi("Abstract method `_createCanvas` called.")}}cT=new WeakMap;class dRe extends are{constructor({ownerDocument:e=globalThis.document,enableHWA:n=!1}){super({enableHWA:n}),this._document=e}_createCanvas(e,n){const s=this._document.createElement("canvas");return s.width=e,s.height=n,s}}class ore{constructor({baseUrl:e=null,isCompressed:n=!0}){this.baseUrl=e,this.isCompressed=n}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const n=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(n).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${n}`)})}async _fetch(e){mi("Abstract method `_fetch` called.")}}class lre extends ore{async _fetch(e){const n=await VM(e,this.isCompressed?"arraybuffer":"text");return n instanceof ArrayBuffer?new Uint8Array(n):FM(n)}}class cre{addFilter(e){return"none"}addHCMFilter(e,n){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,n,s,r,i){return"none"}destroy(e=!1){}}var Cx,Fw,im,am,hl,kx,Ix,vn,cl,bS,Kb,XI,Yb,ure,z5,Xb,wS,_S,G5,SS;class hRe extends cre{constructor({docId:n,ownerDocument:s=globalThis.document}){super();oe(this,vn);oe(this,Cx);oe(this,Fw);oe(this,im);oe(this,am);oe(this,hl);oe(this,kx);oe(this,Ix,0);te(this,am,n),te(this,hl,s)}addFilter(n){if(!n)return"none";let s=_(this,vn,cl).get(n);if(s)return s;const[r,i,a]=le(this,vn,XI).call(this,n),o=n.length===1?r:`${r}${i}${a}`;if(s=_(this,vn,cl).get(o),s)return _(this,vn,cl).set(n,s),s;const l=`g_${_(this,am)}_transfer_map_${Vl(this,Ix)._++}`,c=le(this,vn,Yb).call(this,l);_(this,vn,cl).set(n,c),_(this,vn,cl).set(o,c);const h=le(this,vn,Xb).call(this,l);return le(this,vn,_S).call(this,r,i,a,h),c}addHCMFilter(n,s){var v;const r=`${n}-${s}`,i="base";let a=_(this,vn,bS).get(i);if((a==null?void 0:a.key)===r||(a?((v=a.filter)==null||v.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},_(this,vn,bS).set(i,a)),!n||!s))return a.url;const o=le(this,vn,SS).call(this,n);n=Gn.makeHexColor(...o);const l=le(this,vn,SS).call(this,s);if(s=Gn.makeHexColor(...l),_(this,vn,Kb).style.color="",n==="#000000"&&s==="#ffffff"||n===s)return a.url;const c=new Array(256);for(let b=0;b<=255;b++){const S=b/255;c[b]=S<=.03928?S/12.92:((S+.055)/1.055)**2.4}const h=c.join(","),p=`g_${_(this,am)}_hcm_filter`,m=a.filter=le(this,vn,Xb).call(this,p);le(this,vn,_S).call(this,h,h,h,m),le(this,vn,z5).call(this,m);const y=(b,S)=>{const E=o[b]/255,I=l[b]/255,M=new Array(S+1);for(let j=0;j<=S;j++)M[j]=E+j/S*(I-E);return M.join(",")};return le(this,vn,_S).call(this,y(0,5),y(1,5),y(2,5),m),a.url=le(this,vn,Yb).call(this,p),a.url}addAlphaFilter(n){let s=_(this,vn,cl).get(n);if(s)return s;const[r]=le(this,vn,XI).call(this,[n]),i=`alpha_${r}`;if(s=_(this,vn,cl).get(i),s)return _(this,vn,cl).set(n,s),s;const a=`g_${_(this,am)}_alpha_map_${Vl(this,Ix)._++}`,o=le(this,vn,Yb).call(this,a);_(this,vn,cl).set(n,o),_(this,vn,cl).set(i,o);const l=le(this,vn,Xb).call(this,a);return le(this,vn,G5).call(this,r,l),o}addLuminosityFilter(n){let s=_(this,vn,cl).get(n||"luminosity");if(s)return s;let r,i;if(n?([r]=le(this,vn,XI).call(this,[n]),i=`luminosity_${r}`):i="luminosity",s=_(this,vn,cl).get(i),s)return _(this,vn,cl).set(n,s),s;const a=`g_${_(this,am)}_luminosity_map_${Vl(this,Ix)._++}`,o=le(this,vn,Yb).call(this,a);_(this,vn,cl).set(n,o),_(this,vn,cl).set(i,o);const l=le(this,vn,Xb).call(this,a);return le(this,vn,ure).call(this,l),n&&le(this,vn,G5).call(this,r,l),o}addHighlightHCMFilter(n,s,r,i,a){var I;const o=`${s}-${r}-${i}-${a}`;let l=_(this,vn,bS).get(n);if((l==null?void 0:l.key)===o||(l?((I=l.filter)==null||I.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},_(this,vn,bS).set(n,l)),!s||!r))return l.url;const[c,h]=[s,r].map(le(this,vn,SS).bind(this));let p=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),m=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[y,v]=[i,a].map(le(this,vn,SS).bind(this));m<p&&([p,m,y,v]=[m,p,v,y]),_(this,vn,Kb).style.color="";const b=(M,j,L)=>{const K=new Array(256),D=(m-p)/L,R=M/255,B=(j-M)/(255*L);let G=0;for(let X=0;X<=L;X++){const H=Math.round(p+X*D),Y=R+X*B;for(let F=G;F<=H;
6883F++)K[F]=Y;G=H+1}for(let X=G;X<256;X++)K[X]=K[G-1];return K.join(",")},S=`g_${_(this,am)}_hcm_${n}_filter`,E=l.filter=le(this,vn,Xb).call(this,S);return le(this,vn,z5).call(this,E),le(this,vn,_S).call(this,b(y[0],v[0],5),b(y[1],v[1],5),b(y[2],v[2],5),E),l.url=le(this,vn,Yb).call(this,S),l.url}destroy(n=!1){var s,r,i,a;n&&((s=_(this,kx))!=null&&s.size)||((r=_(this,im))==null||r.parentNode.parentNode.remove(),te(this,im,null),(i=_(this,Fw))==null||i.clear(),te(this,Fw,null),(a=_(this,kx))==null||a.clear(),te(this,kx,null),te(this,Ix,0))}}Cx=new WeakMap,Fw=new WeakMap,im=new WeakMap,am=new WeakMap,hl=new WeakMap,kx=new WeakMap,Ix=new WeakMap,vn=new WeakSet,cl=function(){return _(this,Fw)||te(this,Fw,new Map)},bS=function(){return _(this,kx)||te(this,kx,new Map)},Kb=function(){if(!_(this,im)){const n=_(this,hl).createElement("div"),{style:s}=n;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const r=_(this,hl).createElementNS(qp,"svg");r.setAttribute("width",0),r.setAttribute("height",0),te(this,im,_(this,hl).createElementNS(qp,"defs")),n.append(r),r.append(_(this,im)),_(this,hl).body.append(n)}return _(this,im)},XI=function(n){if(n.length===1){const c=n[0],h=new Array(256);for(let m=0;m<256;m++)h[m]=c[m]/255;const p=h.join(",");return[p,p,p]}const[s,r,i]=n,a=new Array(256),o=new Array(256),l=new Array(256);for(let c=0;c<256;c++)a[c]=s[c]/255,o[c]=r[c]/255,l[c]=i[c]/255;return[a.join(","),o.join(","),l.join(",")]},Yb=function(n){if(_(this,Cx)===void 0){te(this,Cx,"");const s=_(this,hl).URL;s!==_(this,hl).baseURI&&(zM(s)?Ks('#createUrl: ignore "data:"-URL for performance reasons.'):te(this,Cx,s.split("#",1)[0]))}return`url(${_(this,Cx)}#${n})`},ure=function(n){const s=_(this,hl).createElementNS(qp,"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"),n.append(s)},z5=function(n){const s=_(this,hl).createElementNS(qp,"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"),n.append(s)},Xb=function(n){const s=_(this,hl).createElementNS(qp,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",n),_(this,vn,Kb).append(s),s},wS=function(n,s,r){const i=_(this,hl).createElementNS(qp,s);i.setAttribute("type","discrete"),i.setAttribute("tableValues",r),n.append(i)},_S=function(n,s,r,i){const a=_(this,hl).createElementNS(qp,"feComponentTransfer");i.append(a),le(this,vn,wS).call(this,a,"feFuncR",n),le(this,vn,wS).call(this,a,"feFuncG",s),le(this,vn,wS).call(this,a,"feFuncB",r)},G5=function(n,s){const r=_(this,hl).createElementNS(qp,"feComponentTransfer");
6883s.append(r),le(this,vn,wS).call(this,r,"feFuncA",n)},SS=function(n){return _(this,vn,Kb).style.color=n,Cj(getComputedStyle(_(this,vn,Kb)).getPropertyValue("color"))};class dre{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 n=`${this.baseUrl}${e}`;return this._fetch(n).catch(s=>{throw new Error(`Unable to load font data at: ${n}`)})}async _fetch(e){mi("Abstract method `_fetch` called.")}}class hre extends dre{async _fetch(e){const n=await VM(e,"arraybuffer");return new Uint8Array(n)}}yl&&Ks("Please use the `legacy` build in Node.js environments.");async function fre(t){const n=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(n)}class fRe extends cre{}class pRe extends are{_createCanvas(e,n){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,n)}}class mRe extends ore{async _fetch(e){return fre(e)}}class gRe extends dre{async _fetch(e){return fre(e)}}const gl={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function H5(t,e){if(!e)return;const n=e[2]-e[0],s=e[3]-e[1],r=new Path2D;r.rect(e[0],e[1],n,s),t.clip(r)}class Ij{getPattern(){mi("Abstract method `getPattern` called.")}}class yRe extends Ij{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 n;this._type==="axial"?n=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(n=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)n.addColorStop(s[0],s[1]);return n}getPattern(e,n,s,r){let i;if(r===gl.STROKE||r===gl.FILL){const a=n.current.getClippedPathBoundingBox(r,Hi(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,c=n.cachedCanvases.getCanvas("pattern",o,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(-a[0],-a[1]),s=Gn.transform(s,[1,0,0,1,a[0],a[1]]),h.transform(...n.baseTransform),this.matrix&&h.transform(...this.matrix),H5(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),i=e.createPattern(c.canvas,"no-repeat");const p=new DOMMatrix(s);i.setTransform(p)}else H5(e,this._bbox),i=this._createGradient(e);return i}}function _3(t,e,n,s,r,i,a,o){const l=e.coords,c=e.colors,h=t.data,p=t.width*4;let m;l[n+1]>l[s+1]&&(m=n,n=s,s=m,m=i,i=a,a=m),l[s+1]>l[r+1]&&(m=s,s=r,r=m,m=a,a=o,o=m),l[n+1]>l[s+1]&&(m=n,n=s,s=m,m=i,i=a,a=m);const y=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY,b=(l[s]+e.offsetX)*e.scaleX,S=(l[s+1]+e.offsetY)*e.scaleY,E=(l[r]+e.offsetX)*e.scaleX,I=(l[r+1]+e.offsetY)*e.scaleY;if(v>=I)return;const M=c[i],j=c[i+1],L=c[i+2],K=c[a],D=c[a+1],R=c[a+2],B=c[o],G=c[o+1],X=c[o+2],H=Math.round(v),Y=Math.round(I);let F,we,me,xe,Le,ve,ce,ie;for(let de=H;de<=Y;de++){if(de<S){const yt=de<v?0:(v-de)/(v-S);F=y-(y-b)*yt,we=M-(M-K)*yt,me=j-(j-D)*yt,xe=L-(L-R)*yt}else{let yt;de>I?yt=1:S===I?yt=0:yt=(S-de)/(S-I),F=b-(b-E)*yt,we=K-(K-B)*yt,me=D-(D-G)*yt,xe=R-(R-X)*yt}let Re;de<v?Re=0:de>I?Re=1:Re=(v-de)/(v-I),Le=y-(y-E)*Re,ve=M-(M-B)*Re,ce=j-(j-G)*Re,ie=L-(L-X)*Re;
vendor: 9,756 bytes, line 6883
6883const Se=Math.round(Math.min(F,Le)),De=Math.round(Math.max(F,Le));let gt=p*de+Se*4;for(let yt=Se;yt<=De;yt++)Re=(F-yt)/(F-Le),Re<0?Re=0:Re>1&&(Re=1),h[gt++]=we-(we-ve)*Re|0,h[gt++]=me-(me-ce)*Re|0,h[gt++]=xe-(xe-ie)*Re|0,h[gt++]=255}}function xRe(t,e,n){const s=e.coords,r=e.colors;let i,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,c=o-1;for(i=0;i<l;i++){let h=i*o;for(let p=0;p<c;p++,h++)_3(t,n,s[h],s[h+1],s[h+o],r[h],r[h+1],r[h+o]),_3(t,n,s[h+o+1],s[h+1],s[h+o],r[h+o+1],r[h+1],r[h+o])}break;case"triangles":for(i=0,a=s.length;i<a;i+=3)_3(t,n,s[i],s[i+1],s[i+2],r[i],r[i+1],r[i+2]);break;default:throw new Error("illegal figure")}}class vRe extends Ij{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,n,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,h=Math.ceil(this._bounds[3])-l,p=Math.min(Math.ceil(Math.abs(c*e[0]*1.1)),3e3),m=Math.min(Math.ceil(Math.abs(h*e[1]*1.1)),3e3),y=c/p,v=h/m,b={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/y,scaleY:1/v},S=p+4,E=m+4,I=s.getCanvas("mesh",S,E),M=I.context,j=M.createImageData(p,m);if(n){const K=j.data;for(let D=0,R=K.length;D<R;D+=4)K[D]=n[0],K[D+1]=n[1],K[D+2]=n[2],K[D+3]=255}for(const K of this._figures)xRe(j,K,b);return M.putImageData(j,2,2),{canvas:I.canvas,offsetX:o-2*y,offsetY:l-2*v,scaleX:y,scaleY:v}}getPattern(e,n,s,r){H5(e,this._bbox);let i;if(r===gl.SHADING)i=Gn.singularValueDecompose2dScale(Hi(e));else if(i=Gn.singularValueDecompose2dScale(n.baseTransform),this.matrix){const o=Gn.singularValueDecompose2dScale(this.matrix);i=[i[0]*o[0],i[1]*o[1]]}const a=this._createMeshCanvas(i,r===gl.SHADING?null:this._background,n.cachedCanvases);return r!==gl.SHADING&&(e.setTransform(...n.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY),e.createPattern(a.canvas,"no-repeat")}}class bRe extends Ij{getPattern(){return"hotpink"}}function wRe(t){switch(t[0]){case"RadialAxial":return new yRe(t);case"Mesh":return new vRe(t);case"Dummy":return new bRe}throw new Error(`Unknown IR type: ${t[0]}`)}const QH={COLORED:1,UNCOLORED:2},BR=class BR{constructor(e,n,s,r,i){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=n,this.ctx=s,this.canvasGraphicsFactory=r,this.baseTransform=i}createPatternCanvas(e){const{bbox:n,operatorList:s,paintType:r,tilingType:i,color:a,canvasGraphicsFactory:o}=this;let{xstep:l,ystep:c}=this;l=Math.abs(l),c=Math.abs(c),UM("TilingType: "+i);const h=n[0],p=n[1],m=n[2],y=n[3],v=m-h,b=y-p,S=Gn.singularValueDecompose2dScale(this.matrix),E=Gn.singularValueDecompose2dScale(this.baseTransform),I=S[0]*E[0],M=S[1]*E[1];let j=v,L=b,K=!1,D=!1;const R=Math.ceil(l*I),B=Math.ceil(c*M),G=Math.ceil(v*I),X=Math.ceil(b*M);R>=G?j=l:K=!0,B>=X?L=c:D=!0;const H=this.getSizeAndScale(j,this.ctx.canvas.width,I),Y=this.getSizeAndScale(L,this.ctx.canvas.height,M),F=e.cachedCanvases.getCanvas("pattern",H.size,Y.size),we=F.context,me=o.createCanvasGraphics(we);if(me.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(me,r,a),we.translate(-H.scale*h,-Y.scale*p),me.transform(H.scale,0,0,Y.scale,0,0),we.save(),this.clipBbox(me,h,p,m,y),me.baseTransform=Hi(me.ctx),me.executeOperatorList(s),me.endDrawing(),we.restore(),K||D){const xe=F.canvas;K&&(j=l),D&&(L=c);const Le=this.getSizeAndScale(j,this.ctx.canvas.width,I),ve=this.getSizeAndScale(L,this.ctx.canvas.height,M),ce=Le.size,ie=ve.size,de=e.cachedCanvases.getCanvas("pattern-workaround",ce,ie),Re=de.context,Se=K?Math.floor(v/l):0,De=D?Math.floor(b/c):0;for(let gt=0;gt<=Se;gt++)for(let yt=0;yt<=De;yt++)Re.drawImage(xe,ce*gt,ie*yt,ce,ie,0,0,ce,ie);return{canvas:de.canvas,scaleX:Le.scale,scaleY:ve.scale,offsetX:h,offsetY:p}}return{canvas:F.canvas,scaleX:H.scale,scaleY:Y.scale,offsetX:h,offsetY:p}}getSizeAndScale(e,n,s){const r=Math.max(BR.MAX_PATTERN_SIZE,n);let i=Math.ceil(e*s);return i>=r?i=r:s=i/e,{scale:s,size:i}}clipBbox(e,n,s,r,i){const a=r-n,o=i-s;e.ctx.rect(n,s,a,o),e.current.updateRectMinMax(Hi(e.ctx),[n,s,r,i]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,n,s){const r=e.ctx,i=e.current;switch(n){case QH.COLORED:const a=this.ctx;r.fillStyle=a.fillStyle,r.strokeStyle=a.strokeStyle,i.fillColor=a.fillStyle,i.strokeColor=a.strokeStyle;break;case QH.UNCOLORED:const o=Gn.makeHexColor(s[0],s[1],s[2]);r.fillStyle=o,r.strokeStyle=o,i.fillColor=o,i.strokeColor=o;break;default:throw new WNe(`Unsupported paint type: ${n}`)}}getPattern(e,n,s,r){let i=s;r!==gl.SHADING&&(i=Gn.transform(i,n.baseTransform),this.matrix&&(i=Gn.transform(i,this.matrix)));const a=this.createPatternCanvas(n);let o=new DOMMatrix(i);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=e.createPattern(a.canvas,"repeat");return l.setTransform(o),l}};os(BR,"MAX_PATTERN_SIZE",3e3);let q5=BR;function _Re({src:t,srcPos:e=0,dest:n,width:s,height:r,nonBlackColor:i=4294967295,inverseDecode:a=!1}){const o=nc.isLittleEndian?4278190080:255,[l,c]=a?[i,o]:[o,i],h=s>>3,p=s&7,m=t.length;n=new Uint32Array(n.buffer);let y=0;for(let v=0;v<r;v++){for(const S=e+h;e<S;e++){const E=e<m?t[e]:255;n[y++]=E&128?c:l,n[y++]=E&64?c:l,n[y++]=E&32?c:l,n[y++]=E&16?c:l,n[y++]=E&8?c:l,n[y++]=E&4?c:l,n[y++]=E&2?c:l,n[y++]=E&1?c:l}if(p===0)continue;const b=e<m?t[e++]:255;for(let S=0;S<p;S++)n[y++]=b&1<<7-S?c:l}return{srcPos:e,destPos:y}}const ZH=16,eq=100,SRe=15,tq=10,nq=1e3,Oc=16;function ERe(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(s,r){e.translate(s,r),this.__originalTranslate(s,r)},t.scale=function(s,r){e.scale(s,r),this.__originalScale(s,r)},t.transform=function(s,r,i,a,o,l){e.transform(s,r,i,a,o,l),this.__originalTransform(s,r,i,a,o,l)},t.setTransform=function(s,r,i,a,o,l){e.setTransform(s,r,i,a,o,l),this.__originalSetTransform(s,r,i,a,o,l)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(s){e.rotate(s),this.__originalRotate(s)},t.clip=function(s){e.clip(s),this.__originalClip(s)},t.moveTo=function(n,s){e.moveTo(n,s),this.__originalMoveTo(n,s)},t.lineTo=function(n,s){e.lineTo(n,s),this.__originalLineTo(n,s)},t.bezierCurveTo=function(n,s,r,i,a,o){e.bezierCurveTo(n,s,r,i,a,o),this.__originalBezierCurveTo(n,s,r,i,a,o)},t.rect=function(n,s,r,i){e.rect(n,s,r,i),this.__originalRect(n,s,r,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class TRe{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,n,s){let r;return this.cache[e]!==void 0?(r=this.cache[e],this.canvasFactory.reset(r,n,s)):(r=this.canvasFactory.create(n,s),this.cache[e]=r),r}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const n=this.cache[e];this.canvasFactory.destroy(n),delete this.cache[e]}}}function lI(t,e,n,s,r,i,a,o,l,c){const[h,p,m,y,v,b]=Hi(t);if(p===0&&m===0){const I=a*h+v,M=Math.round(I),j=o*y+b,L=Math.round(j),K=(a+l)*h+v,D=Math.abs(Math.round(K)-M)||1,R=(o+c)*y+b,B=Math.abs(Math.round(R)-L)||1;return t.setTransform(Math.sign(h),0,0,Math.sign(y),M,L),t.drawImage(e,n,s,r,i,0,0,D,B),t.setTransform(h,p,m,y,v,b),[D,B]}if(h===0&&y===0){const I=o*m+v,M=Math.round(I),j=a*p+b,L=Math.round(j),K=(o+c)*m+v,D=Math.abs(Math.round(K)-M)||1,R=(a+l)*p+b,B=Math.abs(Math.round(R)-L)||1;return t.setTransform(0,Math.sign(p),Math.sign(m),0,M,L),t.drawImage(e,n,s,r,i,0,0,B,D),t.setTransform(h,p,m,y,v,b),[B,D]}t.drawImage(e,n,s,r,i,a,o,l,c);const S=Math.hypot(h,p),E=Math.hypot(m,y);return[S*l,E*c]}function ARe(t){const{width:e,height:n}=t;if(e>nq||n>nq)return null;const s=1e3,r=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),i=e+1;let a=new Uint8Array(i*(n+1)),o,l,c;const h=e+7&-8;let p=new Uint8Array(h*n),m=0;for(const E of t.data){let I=128;for(;I>0;)p[m++]=E&I?0:255,I>>=1}let y=0;for(m=0,p[m]!==0&&(a[0]=1,++y),l=1;l<e;l++)p[m]!==p[m+1]&&(a[l]=p[m]?2:1,++y),m++;for(p[m]!==0&&(a[l]=2,++y),o=1;o<n;o++){m=o*h,c=o*i,p[m-h]!==p[m]&&(a[c]=p[m]?1:8,++y);let E=(p[m]?4:0)+(p[m-h]?8:0);for(l=1;l<e;l++)E=(E>>2)+(p[m+1]?4:0)+(p[m-h+1]?8:0),r[E]&&(a[c+l]=r[E],++y),m++;if(p[m-h]!==p[m]&&(a[c+l]=p[m]?2:4,++y),y>s)return null}for(m=h*(n-1),c=o*i,p[m]!==0&&(a[c]=8,++y),l=1;l<e;l++)p[m]!==p[m+1]&&(a[c+l]=p[m]?4:8,++y),m++;if(p[m]!==0&&(a[c+l]=4,++y),y>s)return null;const v=new Int32Array([0,i,-1,0,-i,0,0,0,1]),b=new Path2D;for(o=0;y&&o<=n;o++){let E=o*i;const I=E+e;for(;E<I&&!a[E];)E++;
6883if(E===I)continue;b.moveTo(E%i,o);const M=E;let j=a[E];do{const L=v[j];do E+=L;while(!a[E]);const K=a[E];K!==5&&K!==10?(j=K,a[E]=0):(j=K&51*j>>4,a[E]&=j>>2|j<<2),b.lineTo(E%i,E/i|0),a[E]||--y}while(M!==E);--o}return p=null,a=null,function(E){E.save(),E.scale(1/e,-1/n),E.translate(0,-n),E.fill(b),E.beginPath(),E.restore()}}class sq{constructor(e,n){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Sse,this.textMatrixScale=1,this.fontMatrix=b5,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=ll.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,n])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,n){this.x=e,this.y=n}updatePathMinMax(e,n,s){[n,s]=Gn.applyTransform([n,s],e),this.minX=Math.min(this.minX,n),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,n),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(e,n){const s=Gn.applyTransform(n,e),r=Gn.applyTransform(n.slice(2),e),i=Gn.applyTransform([n[0],n[3]],e),a=Gn.applyTransform([n[2],n[1]],e);this.minX=Math.min(this.minX,s[0],r[0],i[0],a[0]),this.minY=Math.min(this.minY,s[1],r[1],i[1],a[1]),this.maxX=Math.max(this.maxX,s[0],r[0],i[0],a[0]),this.maxY=Math.max(this.maxY,s[1],r[1],i[1],a[1])}updateScalingPathMinMax(e,n){Gn.scaleMinMax(e,n),this.minX=Math.min(this.minX,n[0]),this.minY=Math.min(this.minY,n[1]),this.maxX=Math.max(this.maxX,n[2]),this.maxY=Math.max(this.maxY,n[3])}updateCurvePathMinMax(e,n,s,r,i,a,o,l,c,h){const p=Gn.bezierBoundingBox(n,s,r,i,a,o,l,c,h);h||this.updateRectMinMax(e,p)}getPathBoundingBox(e=gl.FILL,n=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(e===gl.STROKE){n||mi("Stroke bounding box must include transform.");const r=Gn.singularValueDecompose2dScale(n),i=r[0]*this.lineWidth/2,a=r[1]*this.lineWidth/2;s[0]-=i,s[1]-=a,s[2]+=i,s[3]+=a}return s}updateClipFromPath(){const e=Gn.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=gl.FILL,n=null){return Gn.intersect(this.clipBox,this.getPathBoundingBox(e,n))}}function rq(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const n=e.height,s=e.width,r=n%Oc,i=(n-r)/Oc,a=r===0?i:i+1,o=t.createImageData(s,Oc);let l=0,c;const h=e.data,p=o.data;let m,y,v,b;if(e.kind===UI.GRAYSCALE_1BPP){const S=h.byteLength,E=new Uint32Array(p.buffer,0,p.byteLength>>2),I=E.length,M=s+7>>3,j=4294967295,L=nc.isLittleEndian?4278190080:255;for(m=0;m<a;m++){for(v=m<i?Oc:r,c=0,y=0;y<v;y++){const K=S-l;let D=0;const R=K>M?s:K*8-7,B=R&-8;let G=0,X=0;for(;D<B;D+=8)X=h[l++],E[c++]=X&128?j:L,E[c++]=X&64?j:L,E[c++]=X&32?j:L,E[c++]=X&16?j:L,E[c++]=X&8?j:L,E[c++]=X&4?j:L,E[c++]=X&2?j:L,E[c++]=X&1?j:L;for(;D<R;D++)G===0&&(X=h[l++],G=128),E[c++]=X&G?j:L,G>>=1}for(;c<I;)E[c++]=0;t.putImageData(o,0,m*Oc)}}else if(e.kind===UI.RGBA_32BPP){for(y=0,b=s*Oc*4,m=0;m<i;m++)p.set(h.subarray(l,l+b)),l+=b,t.putImageData(o,0,y),y+=Oc;m<a&&(b=s*r*4,p.set(h.subarray(l,l+b)),t.putImageData(o,0,y))}else if(e.kind===UI.RGB_24BPP)for(v=Oc,b=s*v,m=0;m<a;m++){for(m>=i&&(v=r,b=s*v),c=0,y=b;y--;)p[c++]=h[l++],p[c++]=h[l++],p[c++]=h[l++],p[c++]=255;t.putImageData(o,0,m*Oc)}else throw new Error(`bad image kind: ${e.kind}`)}function iq(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const n=e.height,s=e.width,r=n%Oc,i=(n-r)/Oc,a=r===0?i:i+1,o=t.createImageData(s,Oc);let l=0;const c=e.data,h=o.data;for(let p=0;p<a;p++){const m=p<i?Oc:r;({srcPos:l}=_Re({src:c,srcPos:l,dest:h,width:s,height:m,nonBlackColor:0})),t.putImageData(o,0,p*Oc)}}function eS(t,e){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of n)t[s]!==void 0&&(e[s]=t[s]);t.setLineDash!==void 0&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function cI(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miter
vendor: 5,130 bytes, line 6883
6883Limit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0&&(t.setLineDash([]),t.lineDashOffset=0),!yl){const{filter:e}=t;e!=="none"&&e!==""&&(t.filter="none")}}function aq(t,e){if(e)return!0;const n=Gn.singularValueDecompose2dScale(t);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*K0.PDF_TO_CSS_UNITS);return n[0]<=s&&n[1]<=s}const CRe=["butt","round","square"],kRe=["miter","round","bevel"],IRe={},oq={};var Jh,W5,K5,Y5;const Wj=class Wj{constructor(e,n,s,r,i,{optionalContentConfig:a,markedContentStack:o=null},l,c){oe(this,Jh);this.ctx=e,this.current=new sq(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=n,this.objs=s,this.canvasFactory=r,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new TRe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,n=null){return typeof e=="string"?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):n}beginDrawing({transform:e,viewport:n,transparency:s=!1,background:r=null}){const i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",i,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Hi(this.compositeCtx))}this.ctx.save(),cI(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...n.transform),this.viewportScale=n.scale,this.baseTransform=Hi(this.ctx)}executeOperatorList(e,n,s,r){const i=e.argsArray,a=e.fnArray;let o=n||0;const l=i.length;if(l===o)return o;const c=l-o>tq&&typeof s=="function",h=c?Date.now()+SRe:0;let p=0;const m=this.commonObjs,y=this.objs;let v;for(;;){if(r!==void 0&&o===r.nextBreakPoint)return r.breakIt(o,s),o;if(v=a[o],v!==Th.dependency)this[v].apply(this,i[o]);else for(const b of i[o]){const S=b.startsWith("g_")?m:y;if(!S.has(b))return S.get(b,s),o}if(o++,o===l)return o;if(c&&++p>tq){if(Date.now()>h)return s(),o;p=0}}}endDrawing(){le(this,Jh,W5).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const n of e.values())typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&(n.width=n.height=0);e.clear()}this._cachedBitmapsMap.clear(),le(this,Jh,K5).call(this)}_scaleImage(e,n){const s=e.width??e.displayWidth,r=e.height??e.displayHeight;let i=Math.max(Math.hypot(n[0],n[1]),1),a=Math.max(Math.hypot(n[2],n[3]),1),o=s,l=r,c="prescale1",h,p;for(;i>2&&o>1||a>2&&l>1;){let m=o,y=l;i>2&&o>1&&(m=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),i/=o/m),a>2&&l>1&&(y=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/y),h=this.cachedCanvases.getCanvas(c,m,y),p=h.context,p.clearRect(0,0,m,y),p.drawImage(e,0,0,o,l,0,0,m,y),e=h.canvas,o=m,l=y,c=c==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:o,paintHeight:l}}_createMaskCanvas(e){const n=this.ctx,{width:s,height:r}=e,i=this.current.fillColor,a=this.current.patternFill,o=Hi(n);let l,c,h,p;if((e.bitmap||e.data)&&e.count>1){const R=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),i]),l=this._cachedBitmapsMap.get(R),l||(l=new Map,this._cachedBitmapsMap.set(R,l));const B=l.get(c);if(B&&!a){const G=Math.round(Math.min(o[0],o[2])+o[4]),X=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:B,offsetX:G,offsetY:X}}h=B}h||(p=this.cachedCanvases.getCanvas("maskCanvas",s,r),iq(p.context,e));let m=Gn.transform(o,[1/s,0,0,-1/r,0,0]);m=Gn.transform(m,[1,0,0,1,0,-r]);const[y,v,b,S]=Gn.getAxialAlignedBoundingBox([0,0,s,r],m),E=Math.round(b-y)||1,I=Math.round(S-v)||1,M=this.cachedCanvases.getCanvas("fillCanvas",E,I),j=M.context,L=y,K=v;j.translate(-L,-K),j.transform(...m),h||(h=this._scaleImage(p.canvas,Df(j)),h=h.img,l&&a&&l.set(c,h)),j.imageSmoothingEnabled=aq(Hi(j),e.interpolate),lI(j,h,0,0,h.width,h.height,0,0,s,r),j.globalCompositeOperation="source-in";const D=Gn.transform(Df(j),[1,0,0,1,-L,-K]);return j.fillStyle=a?i.getPattern(n,this,D,gl.FILL):i,j.fillRect(0,0,s,r),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,M.canvas)),{canvas:M.canvas,offsetX:Math.round(L),offsetY:Math.round(K)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=CRe[e]}setLineJoin(e){this.ctx.lineJoin=kRe[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,n){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(e),s.lineDashOffset=n)}
vendor: 5,266 bytes, line 6883
6883setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[n,s]of e)switch(n){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,n=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(s,e,n);this.suspendedCtx=this.ctx,this.ctx=r.context;const i=this.ctx;i.setTransform(...Hi(this.suspendedCtx)),eS(this.suspendedCtx,i),ERe(i,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(),eS(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 n=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,n,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,n,s,r){const i=r[0],a=r[1],o=r[2]-i,l=r[3]-a;o===0||l===0||(this.genericComposeSMask(n.context,s,o,l,n.subtype,n.backdrop,n.transferMap,i,a,n.offsetX,n.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,n,s,r,i,a,o,l,c,h,p){let m=e.canvas,y=l-h,v=c-p;if(a){const S=Gn.makeHexColor(...a);if(y<0||v<0||y+s>m.width||v+r>m.height){const E=this.cachedCanvases.getCanvas("maskExtension",s,r),I=E.context;I.drawImage(m,-y,-v),I.globalCompositeOperation="destination-atop",I.fillStyle=S,I.fillRect(0,0,s,r),I.globalCompositeOperation="source-over",m=E.canvas,y=v=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const E=new Path2D;E.rect(y,v,s,r),e.clip(E),e.globalCompositeOperation="destination-atop",e.fillStyle=S,e.fillRect(y,v,s,r),e.restore()}}n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0),i==="Alpha"&&o?n.filter=this.filterFactory.addAlphaFilter(o):i==="Luminosity"&&(n.filter=this.filterFactory.addLuminosityFilter(o));const b=new Path2D;b.rect(l,c,s,r),n.clip(b),n.globalCompositeOperation="destination-in",n.drawImage(m,y,v,s,r,l,c,s,r),n.restore()}save(){this.inSMaskMode?(eS(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(),eS(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,n,s,r,i,a){this.ctx.transform(e,n,s,r,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,n,s){const r=this.ctx,i=this.current;let a=i.x,o=i.y,l,c;const h=Hi(r),p=h[0]===0&&h[3]===0||h[1]===0&&h[2]===0,m=p?s.slice(0):null;for(let y=0,v=0,b=e.length;y<b;y++)switch(e[y]|0){case Th.rectangle:a=n[v++],o=n[v++];const S=n[v++],E=n[v++],I=a+S,M=o+E;r.moveTo(a,o),S===0||E===0?r.lineTo(I,M):(r.lineTo(I,o),r.lineTo(I,M),r.lineTo(a,M)),p||i.updateRectMinMax(h,[a,o,I,M]),r.closePath();break;case Th.moveTo:a=n[v++],o=n[v++],r.moveTo(a,o),p||i.updatePathMinMax(h,a,o);break;case Th.lineTo:a=n[v++],o=n[v++],r.lineTo(a,o),p||i.updatePathMinMax(h,a,o);break;case Th.curveTo:l=a,c=o,a=n[v+4],o=n[v+5],r.bezierCurveTo(n[v],n[v+1],n[v+2],n[v+3],a,o),i.updateCurvePathMinMax(h,l,c,n[v],n[v+1],n[v+2],n[v+3],a,o,m),v+=6;break;case Th.curveTo2:l=a,c=o,r.bezierCurveTo(a,o,n[v],n[v+1],n[v+2],n[v+3]),i.updateCurvePathMinMax(h,l,c,a,o,n[v],n[v+1],n[v+2],n[v+3],m),a=n[v+2],o=n[v+3],v+=4;break;case Th.curveTo3:l=a,c=o,a=n[v+2],o=n[v+3],r.bezierCurveTo(n[v],n[v+1],a,o,a,o),i.updateCurvePathMinMax(h,l,c,n[v],n[v+1],a,o,a,o,m),v+=4;break;case Th.closePath:r.closePath();break}p&&i.updateScalingPathMinMax(h,m),i.setCurrentPoint(a,o)}closePath(){this.ctx.closePath()}stroke(e=!0){const n=this.ctx,s=this.current.strokeColor;n.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&(s!=null&&s.getPattern)?(n.save(),n.strokeStyle=s.getPattern(n,this,Df(n),gl.STROKE),this.rescaleAndStroke(!1),n.restore(
6883)):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),n.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){const n=this.ctx,s=this.current.fillColor,r=this.current.patternFill;let i=!1;r&&(n.save(),n.fillStyle=s.getPattern(n,this,Df(n),gl.FILL),i=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(n.fill("evenodd"),this.pendingEOFill=!1):n.fill()),i&&n.restore(),e&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=IRe}eoClip(){this.pendingClip=oq}beginText(){this.current.textMatrix=Sse,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const e=this.pendingTextPaths,n=this.ctx;if(e===void 0){n.beginPath();return}const s=new Path2D,r=n.getTransform().invertSelf();for(const{transform:i,x:a,y:o,fontSize:l,path:c}of e)s.addPath(c,new DOMMatrix(i).preMultiplySelf(r).translate(a,o).scale(l,-l));n.clip(s),n.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,n){var h;const s=this.commonObjs.get(e),r=this.current;if(!s)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=s.fontMatrix||b5,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&Ks("Invalid font matrix for font "+e),n<0?(n=-n,r.fontDirection=-1):r.fontDirection=1,this.current.font=s,this.current.fontSize=n,s.isType3Font)return;const i=s.loadedName||"sans-serif",a=((h=s.systemFontInfo)==null?void 0:h.css)||`"${i}", ${s.fallbackName}`;let o="normal";s.black?o="900":s.bold&&(o="bold");const l=s.italic?"italic":"normal";let c=n;n<ZH?c=ZH:n>eq&&(c=eq),this.current.fontSizeScale=n/c,this.ctx.font=`${l} ${o} ${c}px ${a}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,n){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=n}setLeadingMoveText(e,n){this.setLeading(-n),this.moveText(e,n)}setTextMatrix(e,n,s,r,i,a){this.current.textMatrix=[e,n,s,r,i,a],this.current.textMatrixScale=Math.hypot(e,n),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,n,s,r,i){const a=this.ctx,o=this.current,l=o.font,c=o.textRenderingMode,h=o.fontSize/o.fontSizeScale,p=c&ll.FILL_STROKE_MASK,m=!!(c&ll.ADD_TO_PATH_FLAG),y=o.patternFill&&!l.missingFile,v=o.patternStroke&&!l.missingFile;let b;if((l.disableFontFace||m||y||v)&&(b=l.getPathGenerator(this.commonObjs,e)),l.disableFontFace||y||v){if(a.save(),a.translate(n,s),a.scale(h,-h),p===ll.FILL||p===ll.FILL_STROKE)if(r){const S=a.getTransform();a.setTransform(...r),a.fill(le(this,Jh,Y5).call(this,b,S,r))}else a.fill(b);if(p===ll.STROKE||p===ll.FILL_STROKE)if(i){const S=a.getTransform();a.setTransform(...i),a.stroke(le(this,Jh,Y5).call(this,b,S,i))}else a.lineWidth/=h,a.stroke(b);a.restore()}else(p===ll.FILL||p===ll.FILL_STROKE)&&a.fillText(e,n,s),(p===ll.STROKE||p===ll.FILL_STROKE)&&a.strokeText(e,n,s);m&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Hi(a),x:n,y:s,fontSize:h,path:b})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const n=e.getImageData(0,0,10,10).data;let s=!1;for(let r=3;r<n.length;r+=4)if(n[r]>0&&n[r]<255){s=!0;break}return sr(this,"isFontSubpixelAAEnabled",s)}showText(e){const n=this.current,s=n.font;if(s.isType3Font)return this.showType3Text(e);const r=n.fontSize;if(r===0)return;const i=this.ctx,a=n.fontSizeScale,o=n.charSpacing,l=n.wordSpacing,c=n.fontDirection,h=n.textHScale*c,p=e.length,m=s.vertical,y=m?1:-1,v=s.defaultVMetrics,b=r*n.fontMatrix[0],S=n.textRenderingMode===ll.FILL&&!s.disableFontFace&&!n.patternFill;i.save(),i.transform(...n.textMatrix),i.translate(n.x,n.y+n.textRise),c>0?i.scale(h,-1):i.scale(h,1);let E,I;if(n.patternFill){i.save();const D=n.fillColor.getPattern(i,this,Df(i),gl.FILL);
6883E=Hi(i),i.restore(),i.fillStyle=D}if(n.patternStroke){i.save();const D=n.strokeColor.getPattern(i,this,Df(i),gl.STROKE);I=Hi(i),i.restore(),i.strokeStyle=D}let M=n.lineWidth;const j=n.textMatrixScale;if(j===0||M===0){const D=n.textRenderingMode&ll.FILL_STROKE_MASK;(D===ll.STROKE||D===ll.FILL_STROKE)&&(M=this.getSinglePixelWidth())}else M/=j;if(a!==1&&(i.scale(a,a),M/=a),i.lineWidth=M,s.isInvalidPDFjsFont){const D=[];let R=0;for(const B of e)D.push(B.unicode),R+=B.width;i.fillText(D.join(""),0,0),n.x+=R*b*h,i.restore(),this.compose();return}let L=0,K;for(K=0;K<p;++K){const D=e[K];if(typeof D=="number"){L+=y*D*r/1e3;continue}let R=!1;const B=(D.isSpace?l:0)+o,G=D.fontChar,X=D.accent;let H,Y,F=D.width;if(m){const me=D.vmetric||v,xe=-(D.vmetric?me[1]:F*.5)*b,Le=me[2]*b;F=me?-me[0]:F,H=xe/a,Y=(L+Le)/a}else H=L/a,Y=0;if(s.remeasure&&F>0){const me=i.measureText(G).width*1e3/r*a;if(F<me&&this.isFontSubpixelAAEnabled){const xe=F/me;R=!0,i.save(),i.scale(xe,1),H/=xe}else F!==me&&(H+=(F-me)/2e3*r/a)}if(this.contentVisible&&(D.isInFont||s.missingFile)){if(S&&!X)i.fillText(G,H,Y);else if(this.paintChar(G,H,Y,E,I),X){const me=H+r*X.offset.x/a,xe=Y-r*X.offset.y/a;this.paintChar(X.fontChar,me,xe,E,I)}}const we=m?F*b-B*c:F*b+B*c;L+=we,R&&i.restore()}m?n.y-=L:n.x+=L*h,i.restore(),this.compose()}showType3Text(e){const n=this.ctx,s=this.current,r=s.font,i=s.fontSize,a=s.fontDirection,o=r.vertical?1:-1,l=s.charSpacing,c=s.wordSpacing,h=s.textHScale*a,p=s.fontMatrix||b5,m=e.length,y=s.textRenderingMode===ll.INVISIBLE;let v,b,S,E;if(!(y||i===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,n.save(),n.transform(...s.textMatrix),n.translate(s.x,s.y),n.scale(h,a),v=0;v<m;++v){if(b=e[v],typeof b=="number"){E=o*b*i/1e3,this.ctx.translate(E,0),s.x+=E*h;continue}const I=(b.isSpace?c:0)+l,M=r.charProcOperatorList[b.operatorListId];if(!M){Ks(`Type3 character "${b.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=b,this.save(),n.scale(i,i),n.transform(...p),this.executeOperatorList(M),this.restore()),S=Gn.applyTransform([b.width,0],p)[0]*i+I,n.translate(S,0),s.x+=S*h}n.restore(),this.processingType3=null}}setCharWidth(e,n){}setCharWidthAndBounds(e,n,s,r,i,a){this.ctx.rect(s,r,i-s,a-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let n;if(e[0]==="TilingPattern"){const s=e[1],r=this.baseTransform||Hi(this.ctx),i={createCanvasGraphics:a=>new Wj(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};n=new q5(e,s,this.ctx,i,r)}else n=this._getPattern(e[1],e[2]);return n}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,n,s){this.ctx.strokeStyle=this.current.strokeColor=Gn.makeHexColor(e,n,s),this.current.patternStroke=!1}
vendor: 9,317 bytes, line 6883
6883setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,n,s){this.ctx.fillStyle=this.current.fillColor=Gn.makeHexColor(e,n,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,n=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=wRe(this.getObject(e)),this.cachedPatterns.set(e,s)),n&&(s.matrix=n),s}shadingFill(e){if(!this.contentVisible)return;const n=this.ctx;this.save();const s=this._getPattern(e);n.fillStyle=s.getPattern(n,this,Df(n),gl.SHADING);const r=Df(n);if(r){const{width:i,height:a}=n.canvas,[o,l,c,h]=Gn.getAxialAlignedBoundingBox([0,0,i,a],r);this.ctx.fillRect(o,l,c-o,h-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){mi("Should not call beginInlineImage")}beginImageData(){mi("Should not call beginImageData")}paintFormXObjectBegin(e,n){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Hi(this.ctx),n)){const s=n[2]-n[0],r=n[3]-n[1];this.ctx.rect(n[0],n[1],s,r),this.current.updateRectMinMax(Hi(this.ctx),n),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 n=this.ctx;e.isolated||UM("TODO: Support non-isolated groups."),e.knockout&&Ks("Knockout groups not supported.");const s=Hi(n);if(e.matrix&&n.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=Gn.getAxialAlignedBoundingBox(e.bbox,Hi(n));const i=[0,0,n.canvas.width,n.canvas.height];r=Gn.intersect(r,i)||[0,0,0,0];const a=Math.floor(r[0]),o=Math.floor(r[1]),l=Math.max(Math.ceil(r[2])-a,1),c=Math.max(Math.ceil(r[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,c]);let h="groupAt"+this.groupLevel;e.smask&&(h+="_smask_"+this.smaskCounter++%2);const p=this.cachedCanvases.getCanvas(h,l,c),m=p.context;m.translate(-a,-o),m.transform(...s),e.smask?this.smaskStack.push({canvas:p.canvas,context:m,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(n.setTransform(1,0,0,1,0,0),n.translate(a,o),n.save()),eS(n,m),this.ctx=m,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(n),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const n=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 r=Hi(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);const i=Gn.getAxialAlignedBoundingBox([0,0,n.canvas.width,n.canvas.height],r);this.ctx.drawImage(n.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(e,n,s,r,i){if(le(this,Jh,W5).call(this),cI(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),n){const a=n[2]-n[0],o=n[3]-n[1];if(i&&this.annotationCanvasMap){s=s.slice(),s[4]-=n[0],s[5]-=n[1],n=n.slice(),n[0]=n[1]=0,n[2]=a,n[3]=o;const[l,c]=Gn.singularValueDecompose2dScale(Hi(this.ctx)),{viewportScale:h}=this,p=Math.ceil(a*this.outputScaleX*h),m=Math.ceil(o*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(p,m);const{canvas:y,context:v}=this.annotationCanvas;this.annotationCanvasMap.set(e,y),this.annotationCanvas.savedCtx=this.ctx,this.ctx=v,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,o*c),cI(this.ctx)}else cI(this.ctx),this.endPath(),this.ctx.rect(n[0],n[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new sq(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),le(this,Jh,K5).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const n=e.count;e=this.getObject(e.data,e),e.count=n;const s=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=ARe(e)),r.compiled)){r.compiled(s);return}const i=this._createMaskCanvas(e),a=i.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,i.offsetX,i.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(e,n,s=0,r=0,i,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);const o=this.ctx;o.save();const l=Hi(o);o.transform(n,s,r,i,0,0);const c=this._createMaskCanvas(e);o.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let h=0,p=a.length;h<p;h+=2){const m=Gn.transform(l,[n,s,r,i,a[h],a[h+1]]),[y,v]=Gn.applyTransform([0,0],m);o.drawImage(c.canvas,y,v)}o.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;const n=this.ctx,s=this.current.fillColor,r=this.current.patternFill;for(const i of e){const{data:a,width:o,height:l,transform:c}=i,h=this.cachedCanvases.getCanvas("maskCanvas",o,l),p=h.context;p.save();const m=this.getObject(a,i);iq(p,m),p.globalCompositeOperation="source-in",p.fillStyle=r?s.getPattern(p,this,Df(n),gl.FILL):s,p.fillRect(0,0,o,l),p.restore(),n.save(),n.transform(...c),n.scale(1,-1),lI(n,h.canvas,0,0,o,l,0,-1,1,1),n.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const n=this.getObject(e);if(!n){Ks("Dependent image isn't ready yet");return}this.paintInlineImageXObject(n)}paintImageXObjectRepeat(e,n,s,r){if(!this.contentVisible)return;const i=this.getObject(e);if(!i){Ks("Dependent image isn't ready yet");return}const a=i.width,o=i.height,l=[];for(let c=0,h=r.length;c<h;c+=2)l.push({transform:[n,0,0,s,r[c],r[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(i,l)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return e.bitmap;const{bitmap:n,width:s,height:r}=e,i=this.cachedCanvases.getCanvas("inlineImage",s,r),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(n,0,0),a.filter="none",i.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const n=e.width,s=e.height,r=this.ctx;if(this.save(),!yl){const{filter:o}=r;o!=="none"&&o!==""&&(r.filter="none")}r.scale(1/n,-1/s);let i;if(e.bitmap)i=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)i=e;else{const l=this.cachedCanvases.getCanvas("inlineImage",n,s).context;rq(l,e),i=this.applyTransferMapsToCanvas(l)}const a=this._scaleImage(i,Df(r));r.imageSmoothingEnabled=aq(Hi(r),e.interpolate),lI(r,a.img,0,0,a.paintWidth,a.paintHeight,0,-s,n,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,n){if(!this.contentVisible)return;const s=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const i=e.width,a=e.height,l=this.cachedCanvases.getCanvas("inlineImage",i,a).context;rq(l,e),r=this.applyTransferMapsToCanvas(l)}for(const i of n)s.save(),s.transform(...i.transform),s.scale(1,-1),lI(s,r,i.x,i.y,i.w,i.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,n){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,n){e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(n)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const s=this.ctx;this.pendingClip&&(n||(this.pendingClip===oq?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Hi(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const n=Math.abs(e[0]*e[3]-e[2]*e[1]),s=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(s,r)/n}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:e}=this.current,{a:n,b:s,c:r,d:i}=this.ctx.getTransform();let a,o;if(s===0&&r===0){const l=Math.abs(n),c=Math.abs(i);if(l===c)if(e===0)a=o=1/l;else{const h=l*e;a=o=h<1?1/h:1}else if(e===0)a=1/l,o=1/c;else{const h=l*e,p=c*e;a=h<1?1/h:1,o=p<1?1/p:1}}else{const l=Math.abs(n*i-s*r),c=Math.hypot(n,s),h=Math.hypot(r,i);if(e===0)a=h/l,o=c/l;else{const p=e*l;a=h>p?h/p:1,o=c>p?c/p:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:n}=this,{lineWidth:s}=this.current,[r,i]=this.getScaleForStroking();if(n.lineWidth=s||1,r===1&&i===1){n.stroke();return}const a=n.getLineDash();if(e&&n.save(),n.scale(r,i),a.length>
68830){const o=Math.max(r,i);n.setLineDash(a.map(l=>l/o)),n.lineDashOffset/=o}n.stroke(),e&&n.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};Jh=new WeakSet,W5=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)},K5=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const n=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=n}}},Y5=function(e,n,s){const r=new Path2D;return r.addPath(e,new DOMMatrix(s).invertSelf().multiplySelf(n)),r};let vw=Wj;for(const t in Th)vw.prototype[t]!==void 0&&(vw.prototype[Th[t]]=vw.prototype[t]);var uT,dT;class Am{static get workerPort(){return _(this,uT)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");te(this,uT,e)}static get workerSrc(){return _(this,dT)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");te(this,dT,e)}}uT=new WeakMap,dT=new WeakMap,oe(Am,uT,null),oe(Am,dT,"");var Nx,hT;class NRe{constructor({parsedData:e,rawData:n}){oe(this,Nx);oe(this,hT);te(this,Nx,e),te(this,hT,n)}getRaw(){return _(this,hT)}get(e){return _(this,Nx).get(e)??null}getAll(){return _j(_(this,Nx))}has(e){return _(this,Nx).has(e)}}Nx=new WeakMap,hT=new WeakMap;const Jb=Symbol("INTERNAL");var fT,pT,mT,Vw;class RRe{constructor(e,{name:n,intent:s,usage:r,rbGroups:i}){oe(this,fT,!1);oe(this,pT,!1);oe(this,mT,!1);oe(this,Vw,!0);te(this,fT,!!(e&wu.DISPLAY)),te(this,pT,!!(e&wu.PRINT)),this.name=n,this.intent=s,this.usage=r,this.rbGroups=i}get visible(){if(_(this,mT))return _(this,Vw);if(!_(this,Vw))return!1;const{print:e,view:n}=this.usage;return _(this,fT)?(n==null?void 0:n.viewState)!=="OFF":_(this,pT)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,n,s=!1){e!==Jb&&mi("Internal method `_setVisible` called."),te(this,mT,s),te(this,Vw,n)}}fT=new WeakMap,pT=new WeakMap,mT=new WeakMap,Vw=new WeakMap;var s0,ei,zw,Gw,gT,X5;class MRe{constructor(e,n=wu.DISPLAY){oe(this,gT);oe(this,s0,null);oe(this,ei,new Map);oe(this,zw,null);oe(this,Gw,null);if(this.renderingIntent=n,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,te(this,Gw,e.order);for(const s of e.groups)_(this,ei).set(s.id,new RRe(n,s));if(e.baseState==="OFF")for(const s of _(this,ei).values())s._setVisible(Jb,!1);for(const s of e.on)_(this,ei).get(s)._setVisible(Jb,!0);for(const s of e.off)_(this,ei).get(s)._setVisible(Jb,!1);te(this,zw,this.getHash())}}isVisible(e){if(_(this,ei).size===0)return!0;if(!e)return UM("Optional content group not defined."),!0;if(e.type==="OCG")return _(this,ei).has(e.id)?_(this,ei).get(e.id).visible:(Ks(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return le(this,gT,X5).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const n of e.ids){if(!_(this,ei).has(n))return Ks(`Optional content group not found: ${n}`),!0;if(_(this,ei).get(n).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const n of e.ids){if(!_(this,ei).has(n))return Ks(`Optional content group not found: ${n}`),!0;if(!_(this,ei).get(n).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const n of e.ids){if(!_(this,ei).has(n))return Ks(`Optional content group not found: ${n}`),!0;if(!_(this,ei).get(n).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const n of e.ids){if(!_(this,ei).has(n))return Ks(`Optional content group not found: ${n}`),!0;if(_(this,ei).get(n).visible)return!1}return!0}return Ks(`Unknown optional content policy ${e.policy}.`),!0}return Ks(`Unknown group type ${e.type}.`),!0}setVisibility(e,n=!0,s=!0){var i;const r=_(this,ei).get(e);if(!r){Ks(`Optional content group not found: ${e}`);return}if(s&&n&&r.rbGroups.length)for(const a of r.rbGroups)for(const o of a)o!==e&&((i=_(this,ei).get(o))==null||i._setVisible(Jb,!1,!0));r._setVisible(Jb,!!n,!0),te(this,s0,null)}setOCGState({state:e,preserveRB:n}){let s;for(const r of e){switch(r){case"ON":case"OFF":case"Toggle":s=r;continue}const i=_(this,ei).get(r);if(i)switch(s){case"ON":this.setVisibility(r,!0,n);break;case"OFF":this.setVisibility(r,!1,n);break;case"Toggle":this.setVisibility(r,!i.visible,n);break}}te(this,s0,null)}get hasInitialVisibility(){return _(this,zw)===null||this.getHash()===_(this,zw)}getOrder(){return _(this,ei).size?_(this,Gw)?_(this,Gw).slice():[..._(this,ei).keys()]:null}getGroups(){return _(this,ei).size>0?_j(_(this,ei)):null}getGroup(e){return _(this,ei).get(e)||null}getHash(){if(_(this,s0)!==null)return _(this,s0);const e=new ere;for(const[n,s]of _(this,ei))e.update(`${n}:${s.visible}`);return te(this,s0,e.hexdigest())}}s0=new WeakMap,ei=new WeakMap,zw=new WeakMap,Gw=new WeakMap,gT=new WeakSet,X5=function(e){const n=e.length;if(n<2)return!0;const s=e[0];for(let r=1;r<n;r++){const i=e[r];let a;
6883if(Array.isArray(i))a=le(this,gT,X5).call(this,i);else if(_(this,ei).has(i))a=_(this,ei).get(i).visible;else return Ks(`Optional content group not found: ${i}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};class PRe{constructor(e,{disableRange:n=!1,disableStream:s=!1}){Oa(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:i,progressiveDone:a,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(i==null?void 0:i.length)>0){const l=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!s,this._isRangeSupported=!n,this._contentLength=r,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:n}){const s=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const r=this._rangeReaders.some(function(i){return i._begin!==e?!1:(i._enqueue(s),!0)});Oa(r,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var n,s,r,i;e.total===void 0?(s=(n=this._rangeReaders[0])==null?void 0:n.onProgress)==null||s.call(n,{loaded:e.loaded}):(i=(r=this._fullRequestReader)==null?void 0:r.onProgress)==null||i.call(r,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const n=this._rangeReaders.indexOf(e);n>=0&&this._rangeReaders.splice(n,1)}getFullReader(){Oa(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new $Re(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const s=new DRe(this,e,n);return this._pdfDataRangeTransport.requestDataRange(e,n),this._rangeReaders.push(s),s}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const s of this._rangeReaders.slice(0))s.cancel(e);this._pdfDataRangeTransport.abort()}}class $Re{constructor(e,n,s=!1,r=null){this._stream=e,this._done=s||!1,this._filename=Tj(r)?r:null,this._queuedChunks=n||[],this._loaded=0;for(const i of this._queuedChunks)this._loaded+=i.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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class DRe{constructor(e,n,s){this._stream=e,this._begin=n,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 n=this._queuedChunk;return this._queuedChunk=null,{value:n,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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ORe(t){let e=!0,n=s("filename\\*","i").exec(t);if(n){n=n[1];let h=o(n);return h=unescape(h),h=l(h),h=c(h),i(h)}if(n=a(t),n){const h=c(n);return i(h)}
6883if(n=s("filename","i").exec(t),n){n=n[1];let h=o(n);return h=c(h),i(h)}function s(h,p){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',p)}function r(h,p){if(h){if(!/^[\x00-\xFF]+$/.test(p))return p;try{const m=new TextDecoder(h,{fatal:!0}),y=FM(p);p=m.decode(y),e=!1}catch{}}return p}function i(h){return e&&/[\x80-\xff]/.test(h)&&(h=r("utf-8",h),e&&(h=r("iso-8859-1",h))),h}function a(h){const p=[];let m;const y=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(m=y.exec(h))!==null;){let[,b,S,E]=m;if(b=parseInt(b,10),b in p){if(b===0)break;continue}p[b]=[S,E]}const v=[];for(let b=0;b<p.length&&b in p;++b){let[S,E]=p[b];E=o(E),S&&(E=unescape(E),b===0&&(E=l(E))),v.push(E)}return v.join("")}function o(h){if(h.startsWith('"')){const p=h.slice(1).split('\\"');for(let m=0;m<p.length;++m){const y=p[m].indexOf('"');y!==-1&&(p[m]=p[m].slice(0,y),p.length=m+1),p[m]=p[m].replaceAll(/\\(.)/g,"$1")}h=p.join('"')}return h}function l(h){const p=h.indexOf("'");if(p===-1)return h;const m=h.slice(0,p),v=h.slice(p+1).replace(/^[^']*'/,"");return r(m,v)}function c(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(p,m,y,v){if(y==="q"||y==="Q")return v=v.replaceAll("_"," "),v=v.replaceAll(/=([0-9a-fA-F]{2})/g,function(b,S){return String.fromCharCode(parseInt(S,16))}),r(m,v);try{v=atob(v)}catch{}return r(m,v)})}return""}function pre(t,e){const n=new Headers;if(!t||!e||typeof e!="object")return n;for(const s in e){const r=e[s];r!==void 0&&n.append(s,r)}return n}function GM(t){try{return new URL(t).origin}catch{}return null}function mre({responseHeaders:t,isHttp:e,rangeChunkSize:n,disableRange:s}){const r={allowRangeRequests:!1,suggestedLength:void 0},i=parseInt(t.get("Content-Length"),10);return!Number.isInteger(i)||(r.suggestedLength=i,i<=2*n)||s||!e||t.get("Accept-Ranges")!=="bytes"||(t.get("Content-Encoding")||"identity")!=="identity"||(r.allowRangeRequests=!0),r}function gre(t){const e=t.get("Content-Disposition");if(e){let n=ORe(e);if(n.includes("%"))try{n=decodeURIComponent(n)}catch{}if(Tj(n))return n}return null}function HM(t,e){return t===404||t===0&&e.startsWith("file:")?new PE('Missing PDF "'+e+'".'):new vR(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function yre(t){return t===200||t===206}function xre(t,e,n){return{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function vre(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Ks(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class lq{constructor(e){os(this,"_responseOrigin",null);this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=pre(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 Oa(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new LRe(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const s=new jRe(this,e,n);return this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class LRe{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const n=e.source;this._withCredentials=n.withCredentials||!1,this._contentLength=n.length,this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange;const s=new Headers(e.headers),r=n.url;fetch(r,xre(s,this._withCredentials,this._abortController)).then(i=>{if(e._responseOrigin=GM(i.url),!yre(i.status))throw HM(i.status,r);this._reader=i.body.getReader(),this._headersCapability.resolve();const a=i.headers,{allowRangeRequests:o,suggestedLength:l}=mre({responseHeaders:a,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=gre(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new W0("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:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:vre(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}class jRe{constructor(e,n,s){this._stream=e,this._reader=null,this._loaded=0;const r=e.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const i=new Headers(e.headers);i.append("Range",`bytes=${n}-${s-1}`);const a=r.url;fetch(a,xre(i,this._withCredentials,this._abortController)).then(o=>{const l=GM(o.url);if(l!==e._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${e._responseOrigin}".`);if(!yre(o.status))throw HM(o.status,a);this._readCapability.resolve(),this._reader=o.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:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:vre(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}const S3=200,E3=206;function BRe(t){const e=t.response;return typeof e!="string"?e:FM(e).buffer}class URe{constructor({url:e,httpHeaders:n,withCredentials:s}){os(this,"_responseOrigin",null);this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=pre(this.isHttp,n),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const n=new XMLHttpRequest,s=this.currXhrId++,r=this.pendingRequests[s]={xhr:n};n.open("GET",this.url),n.withCredentials=this.withCredentials;for(const[i,a]of this.headers)n.setRequestHeader(i,a);return this.isHttp&&"begin"in e&&"end"in e?(n.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),r.expectedStatus=E3):r.expectedStatus=S3,n.responseType="arraybuffer",Oa(e.onError,"Expected `onError` callback to be provided."),n.onerror=()=>{e.onError(n.status)},n.onreadystatechange=this.onStateChange.bind(this,s),n.onprogress=this.onProgress.bind(this,s),r.onHeadersReceived=e.onHeadersReceived,r.onDone=e.onDone,r.onError=e.onError,r.onProgress=e.onProgress,n.send(null),s}onProgress(e,n){var r;const s=this.pendingRequests[e];s&&((r=s.onProgress)==null||r.call(s,n))}onStateChange(e,n){const s=this.pendingRequests[e];if(!s)return;const r=s.xhr;if(r.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),r.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],r.status===0&&this.isHttp){s.onError(r.status);return}const i=r.status||S3;if(!(i===S3&&s.expectedStatus===E3)&&i!==s.expectedStatus){s.onError(r.status);return}const o=BRe(r);if(i===E3){const l=r.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);c?s.onDone({begin:parseInt(c[1],10),chunk:o}):(Ks('Missing or invalid "Content-Range" header.'),s.onError(0))}else o?s.onDone({begin:0,chunk:o}):s.onError(r.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}
6883abortRequest(e){const n=this.pendingRequests[e].xhr;delete this.pendingRequests[e],n.abort()}}class FRe{constructor(e){this._source=e,this._manager=new URe(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const n=this._rangeRequestReaders.indexOf(e);n>=0&&this._rangeRequestReaders.splice(n,1)}getFullReader(){return Oa(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new VRe(this._manager,this._source),this._fullRequestReader}getRangeReader(e,n){const s=new zRe(this._manager,e,n);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class VRe{constructor(e,n){this._manager=e,this._url=n.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._contentLength=n.length,this._rangeChunkSize=n.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,n=this._manager.getRequestXhr(e);this._manager._responseOrigin=GM(n.responseURL);const s=n.getAllResponseHeaders(),r=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...c]=o.split(": ");return[l,c.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:a}=mre({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=gre(r),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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=HM(e,this._url),this._headersCapability.reject(this._storedError);for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var n;(n=this.onProgress)==null||n.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(await this._headersCapability.promise,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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class zRe{constructor(e,n,s){this._manager=e,this._url=e.url,this._requestId=e.request({begin:n,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var n;const e=GM((n=this._manager.getRequestXhr(this._requestId))==null?void 0:n.responseURL);
6883e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const n=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:n,done:!1}):this._queuedChunk=n,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??(this._storedError=HM(e,this._url));for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var n;this.isStreamingSupported||(n=this.onProgress)==null||n.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const GRe=/^[a-z][a-z0-9\-+.]+:/i;function HRe(t){if(GRe.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}class qRe{constructor(e){this.source=e,this.url=HRe(e.url),Oa(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return Oa(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new WRe(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const s=new KRe(this,e,n);return this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class WRe{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const n=e.source;this._contentLength=n.length,this._loaded=0,this._filename=null,this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(r=>{this._contentLength=r.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},r=>{r.code==="ENOENT"&&(r=new PE(`Missing PDF "${this._url}".`)),this._storedError=r,this._headersCapability.reject(r)})}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",n=>{this._error(n)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new W0("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class KRe{constructor(e,n,s){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=e.source;this._isStreamingSupported=!r.disableStream;const i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:n,end:s-1}))}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",n=>{this._error(n)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const YRe=1e5,Nc=30,XRe=.8;var rK,r0,$c,yT,xT,Rx,om,vT,bT,Mx,Hw,qw,i0,Ww,wT,Kw,Px,_T,ST,$x,Dx,ET,a0,Yw,Um,bre,wre,J5,Mu,JI,Q5,_re,Sre;const eo=class eo{constructor({textContentSource:e,container:n,viewport:s}){oe(this,Um);oe(this,r0,Promise.withResolvers());oe(this,$c,null);oe(this,yT,!1);oe(this,xT,!!((rK=globalThis.FontInspector)!=null&&rK.enabled));oe(this,Rx,null);oe(this,om,null);oe(this,vT,0);oe(this,bT,0);oe(this,Mx,null);oe(this,Hw,null);oe(this,qw,0);oe(this,i0,0);oe(this,Ww,Object.create(null));oe(this,wT,[]);oe(this,Kw,null);oe(this,Px,[]);oe(this,_T,new WeakMap);oe(this,ST,null);var l;if(e instanceof ReadableStream)te(this,Kw,e);else if(typeof e=="object")te(this,Kw,new ReadableStream({start(c){c.enqueue(e),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');te(this,$c,te(this,Hw,n)),te(this,i0,s.scale*(globalThis.devicePixelRatio||1)),te(this,qw,s.rotation),te(this,om,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:i,pageX:a,pageY:o}=s.rawDims;te(this,ST,[1,0,0,-1,-a,o+i]),te(this,bT,r),te(this,vT,i),le(l=eo,Mu,_re).call(l),$v(n,s),_(this,r0).promise.finally(()=>{_(eo,Yw).delete(this),te(this,om,null),te(this,Ww,null)}
vendor: 5,882 bytes, line 6883
6883).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:n}=nc.platform;return sr(this,"fontFamilyMap",new Map([["sans-serif",`${e&&n?"Calibri, ":""}sans-serif`],["monospace",`${e&&n?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{_(this,Mx).read().then(({value:n,done:s})=>{if(s){_(this,r0).resolve();return}_(this,Rx)??te(this,Rx,n.lang),Object.assign(_(this,Ww),n.styles),le(this,Um,bre).call(this,n.items),e()},_(this,r0).reject)};return te(this,Mx,_(this,Kw).getReader()),_(eo,Yw).add(this),e(),_(this,r0).promise}update({viewport:e,onBefore:n=null}){var i;const s=e.scale*(globalThis.devicePixelRatio||1),r=e.rotation;if(r!==_(this,qw)&&(n==null||n(),te(this,qw,r),$v(_(this,Hw),{rotation:r})),s!==_(this,i0)){n==null||n(),te(this,i0,s);const a={div:null,properties:null,ctx:le(i=eo,Mu,JI).call(i,_(this,Rx))};for(const o of _(this,Px))a.properties=_(this,_T).get(o),a.div=o,le(this,Um,J5).call(this,a)}}cancel(){var n;const e=new W0("TextLayer task cancelled.");(n=_(this,Mx))==null||n.cancel(e).catch(()=>{}),te(this,Mx,null),_(this,r0).reject(e)}get textDivs(){return _(this,Px)}get textContentItemsStr(){return _(this,wT)}static cleanup(){if(!(_(this,Yw).size>0)){_(this,$x).clear();for(const{canvas:e}of _(this,Dx).values())e.remove();_(this,Dx).clear()}}};r0=new WeakMap,$c=new WeakMap,yT=new WeakMap,xT=new WeakMap,Rx=new WeakMap,om=new WeakMap,vT=new WeakMap,bT=new WeakMap,Mx=new WeakMap,Hw=new WeakMap,qw=new WeakMap,i0=new WeakMap,Ww=new WeakMap,wT=new WeakMap,Kw=new WeakMap,Px=new WeakMap,_T=new WeakMap,ST=new WeakMap,$x=new WeakMap,Dx=new WeakMap,ET=new WeakMap,a0=new WeakMap,Yw=new WeakMap,Um=new WeakSet,bre=function(e){var r,i;if(_(this,yT))return;(i=_(this,om)).ctx??(i.ctx=le(r=eo,Mu,JI).call(r,_(this,Rx)));const n=_(this,Px),s=_(this,wT);for(const a of e){if(n.length>YRe){Ks("Ignoring additional textDivs for performance reasons."),te(this,yT,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=_(this,$c);te(this,$c,document.createElement("span")),_(this,$c).classList.add("markedContent"),a.id!==null&&_(this,$c).setAttribute("id",`${a.id}`),o.append(_(this,$c))}else a.type==="endMarkedContent"&&te(this,$c,_(this,$c).parentNode);continue}s.push(a.str),le(this,Um,wre).call(this,a)}},wre=function(e){var b;const n=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};_(this,Px).push(n);const r=Gn.transform(_(this,ST),e.transform);let i=Math.atan2(r[1],r[0]);const a=_(this,Ww)[e.fontName];a.vertical&&(i+=Math.PI/2);let o=_(this,xT)&&a.fontSubstitution||a.fontFamily;o=eo.fontFamilyMap.get(o)||o;const l=Math.hypot(r[2],r[3]),c=l*le(b=eo,Mu,Sre).call(b,o,_(this,Rx));let h,p;i===0?(h=r[4],p=r[5]-c):(h=r[4]+c*Math.sin(i),p=r[5]-c*Math.cos(i));const m="calc(var(--scale-factor)*",y=n.style;_(this,$c)===_(this,Hw)?(y.left=`${(100*h/_(this,bT)).toFixed(2)}%`,y.top=`${(100*p/_(this,vT)).toFixed(2)}%`):(y.left=`${m}${h.toFixed(2)}px)`,y.top=`${m}${p.toFixed(2)}px)`),y.fontSize=`${m}${(_(eo,a0)*l).toFixed(2)}px)`,y.fontFamily=o,s.fontSize=l,n.setAttribute("role","presentation"),n.textContent=e.str,n.dir=e.dir,_(this,xT)&&(n.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),i!==0&&(s.angle=i*(180/Math.PI));let v=!1;if(e.str.length>1)v=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const S=Math.abs(e.transform[0]),E=Math.abs(e.transform[3]);S!==E&&Math.max(S,E)/Math.min(S,E)>1.5&&(v=!0)}if(v&&(s.canvasWidth=a.vertical?e.height:e.width),_(this,_T).set(n,s),_(this,om).div=n,_(this,om).properties=s,le(this,Um,J5).call(this,_(this,om)),s.hasText&&_(this,$c).append(n),s.hasEOL){const S=document.createElement("br");S.setAttribute("role","presentation"),_(this,$c).append(S)}},J5=function(e){var o;const{div:n,properties:s,ctx:r}=e,{style:i}=n;let a="";if(_(eo,a0)>1&&(a=`scale(${1/_(eo,a0)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=i,{canvasWidth:c,fontSize:h}=s;le(o=eo,Mu,Q5).call(o,r,h*_(this,i0),l);const{width:p}=r.measureText(n.textContent);p>0&&(a=`scaleX(${c*_(this,i0)/p}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(i.transform=a)},Mu=new WeakSet,JI=function(e=null){let n=_(this,Dx).get(e||(e=""));if(!n){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=e,document.body.append(s),n=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),_(this,Dx).set(e,n),_(this,ET).set(n,{size:0,family:""})}return n},Q5=function(e,n,s){const r=_(this,ET).get(e);n===r.size&&s===r.family||(e.font=`${n}px ${s}`,r.size=n,r.family=s)},_re=function(){if(_(this,a0)!==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),te(this,a0,e.getBoundingClientRect().height),e.remove()},Sre=function(e,n){const s=_(this,$x).get(e);if(s)return s;const r=le(this,Mu,JI).call(this,n);r.canvas.width=r.canvas.height=Nc,le(this,Mu,Q5).call(this,r,Nc,e);const i=r.measureText("");let a=i.fontBoundingBoxAscent,o=Math.abs(i.fontBoundingBoxDescent);if(a){const h=a/(a+o);return _(this,$x).set(e,h),r.canvas.width=r.canvas.height=0,h}r.strokeStyle="red",r.clearRect(0,0,Nc,Nc),r.strokeText("g",0,0);let l=r.getImageData(0,0,Nc,Nc).data;o=0;for(let h=l.length-1-3;h>=0;h-=4)if(l[h]>0){o=Math.ceil(h/4/Nc);break}r.clearRect(0,0,Nc,Nc),r.strokeText("A",0,Nc),l=r.getImageData(0,0,Nc,Nc).data,a=0;for(let h=0,p=l.length;h<p;h+=4)if(l[h]>0){a=Nc-Math.floor(h/4/Nc);break}r.canvas.width=r.canvas.height=0;const c=a?a/(a+o):XRe;return _(this,$x).set(e,c),c},oe(eo,Mu),oe(eo,$x,new Map),oe(eo,Dx,new Map),oe(eo,ET,new WeakMap),oe(eo,a0,null),oe(eo,Yw,new Set);let $E=eo;class DE{static textContent(e){const n=[],s={items:n,styles:Object.create(null)};function r(i){var l;if(!i)return;let a=null;const o=i.name;if(o==="#text")a=i.value;
6883else if(DE.shouldBuildText(o))(l=i==null?void 0:i.attributes)!=null&&l.textContent?a=i.attributes.textContent:i.value&&(a=i.value);else return;if(a!==null&&n.push({str:a}),!!i.children)for(const c of i.children)r(c)}return r(e),s}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}const JRe=65536,QRe=100,ZRe=5e3,eMe=yl?pRe:dRe,tMe=yl?mRe:lre,nMe=yl?fRe:hRe,sMe=yl?gRe:hre;function rMe(t={}){typeof t=="string"||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Z5,{docId:n}=e,s=t.url?iMe(t.url):null,r=t.data?aMe(t.data):null,i=t.httpHeaders||null,a=t.withCredentials===!0,o=t.password??null,l=t.range instanceof Ere?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:JRe;let h=t.worker instanceof bw?t.worker:null;const p=t.verbosity,m=typeof t.docBaseUrl=="string"&&!zM(t.docBaseUrl)?t.docBaseUrl:null,y=typeof t.cMapUrl=="string"?t.cMapUrl:null,v=t.cMapPacked!==!1,b=t.CMapReaderFactory||tMe,S=typeof t.standardFontDataUrl=="string"?t.standardFontDataUrl:null,E=t.StandardFontDataFactory||sMe,I=t.stopAtErrors!==!0,M=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,j=t.isEvalSupported!==!1,L=typeof t.isOffscreenCanvasSupported=="boolean"?t.isOffscreenCanvasSupported:!yl,K=typeof t.isImageDecoderSupported=="boolean"?t.isImageDecoderSupported:!yl&&(nc.platform.isFirefox||!globalThis.chrome),D=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,R=typeof t.disableFontFace=="boolean"?t.disableFontFace:yl,B=t.fontExtraProperties===!0,G=t.enableXfa===!0,X=t.ownerDocument||globalThis.document,H=t.disableRange===!0,Y=t.disableStream===!0,F=t.disableAutoFetch===!0,we=t.pdfBug===!0,me=t.CanvasFactory||eMe,xe=t.FilterFactory||nMe,Le=t.enableHWA===!0,ve=l?l.length:t.length??NaN,ce=typeof t.useSystemFonts=="boolean"?t.useSystemFonts:!yl&&!R,ie=typeof t.useWorkerFetch=="boolean"?t.useWorkerFetch:b===lre&&E===hre&&y&&S&&mS(y,document.baseURI)&&mS(S,document.baseURI),de=null;zNe(p);const Re={canvasFactory:new me({ownerDocument:X,enableHWA:Le}),filterFactory:new xe({docId:n,ownerDocument:X}),cMapReaderFactory:ie?null:new b({baseUrl:y,isCompressed:v}),standardFontDataFactory:ie?null:new E({baseUrl:S})};if(!h){const gt={verbosity:p,port:Am.workerPort};h=gt.port?bw.fromPort(gt):new bw(gt),e._worker=h}const Se={docId:n,apiVersion:"4.10.38",data:r,password:o,disableAutoFetch:F,rangeChunkSize:c,length:ve,docBaseUrl:m,enableXfa:G,evaluatorOptions:{maxImageSize:M,disableFontFace:R,ignoreErrors:I,isEvalSupported:j,isOffscreenCanvasSupported:L,isImageDecoderSupported:K,canvasMaxAreaInBytes:D,fontExtraProperties:B,useSystemFonts:ce,cMapUrl:ie?y:null,standardFontDataUrl:ie?S:null}},De={disableFontFace:R,fontExtraProperties:B,ownerDocument:X,pdfBug:we,styleElement:de,loadingParams:{disableAutoFetch:F,enableXfa:G}};return h.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const gt=h.messageHandler.sendWithPromise("GetDocRequest",Se,r?[r.buffer]:null);let yt;if(l)yt=new PRe(l,{disableRange:H,disableStream:Y});else if(!r){if(!s)throw new Error("getDocument - no `url` parameter provided.");let xt;if(yl)if(mS(s)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");xt=lq}else xt=qRe;else xt=mS(s)?lq:FRe;yt=new xt({url:s,length:ve,httpHeaders:i,withCredentials:a,rangeChunkSize:c,disableRange:H,disableStream:Y})}return gt.then(xt=>{if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const Nt=new vS(n,xt,h.port),wt=new uMe(Nt,e,yt,De,Re);e._transport=wt,Nt.send("Ready",null)})}).catch(e._capability.reject),e}function iMe(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(yl&&typeof t=="string")return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function aMe(t){if(yl&&typeof Buffer<"u"&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t=="string")return FM(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="object"&&!isNaN(t==null?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function cq(t){return typeof t=="object"&&Number.isInteger(t==null?void 0:t.num)&&t.num>=0&&Number.isInteger(t==null?void 0:t.gen)&&t.gen>=0}var UR;const FR=class FR{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Vl(FR,UR)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var e,n,s,r;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((n=this._transport)==null?void 0:n.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,(r=this._worker)==null||r.destroy(),this._worker=null}};UR=new WeakMap,oe(FR,UR,0);let Z5=FR;class Ere{constructor(e,n,s=!1,r=null){this.length=e,this.initialData=n,this.progressiveDone=s,this.contentDispositionFilename=r,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,n){for(const s of this._rangeListeners)s(e,n)}onDataProgress(e,n){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(e,n)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(const n of this._progressiveReadListeners)n(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,n){mi("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class oMe{constructor(e,n){this._pdfInfo=e,this._transport=n}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 sr(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)}
6883getDestinations(){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:n}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(n)}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 o0,lm,fd,Qb,QI;class lMe{constructor(e,n,s,r=!1){oe(this,fd);oe(this,o0,null);oe(this,lm,!1);this._pageIndex=e,this._pageInfo=n,this._transport=s,this._stats=r?new YH:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new Tre,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:n=this.rotate,offsetX:s=0,offsetY:r=0,dontFlip:i=!1}={}){return new $A({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:n,offsetX:s,offsetY:r,dontFlip:i})}getAnnotations({intent:e="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,n)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return sr(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:n,intent:s="display",annotationMode:r=Gg.ENABLE,transform:i=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:h=null,isEditing:p=!1}){var j,L;(j=this._stats)==null||j.time("Overall");const m=this._transport.getRenderingIntent(s,r,h,p),{renderingIntent:y,cacheKey:v}=m;te(this,lm,!1),le(this,fd,QI).call(this),o||(o=this._transport.getOptionalContentConfig(y));let b=this._intentStates.get(v);b||(b=Object.create(null),this._intentStates.set(v,b)),b.streamReaderCancelTimeout&&(clearTimeout(b.streamReaderCancelTimeout),b.streamReaderCancelTimeout=null);const S=!!(y&wu.PRINT);b.displayReadyCapability||(b.displayReadyCapability=Promise.withResolvers(),b.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(L=this._stats)==null||L.time("Page Request"),this._pumpOperatorList(m));const E=K=>{var D;b.renderTasks.delete(I),(this._maybeCleanupAfterRender||S)&&te(this,lm,!0),le(this,fd,Qb).call(this,!S),K?(I.capability.reject(K),this._abortOperatorList({intentState:b,reason:K instanceof Error?K:new Error(K)})):I.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(D=globalThis.Stats)!=null&&D.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},I=new tO({callback:E,params:{canvasContext:e,viewport:n,transform:i,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:b.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!S,pdfBug:this._pdfBug,page
6883Colors:c});(b.renderTasks||(b.renderTasks=new Set)).add(I);const M=I.task;return Promise.all([b.displayReadyCapability.promise,o]).then(([K,D])=>{var R;if(this.destroyed){E();return}if((R=this._stats)==null||R.time("Rendering"),!(D.renderingIntent&y))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:K,optionalContentConfig:D}),I.operatorListChanged()}).catch(E),M}getOperatorList({intent:e="display",annotationMode:n=Gg.ENABLE,printAnnotationStorage:s=null,isEditing:r=!1}={}){var c;function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(e,n,s,r,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:n=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:n===!0},{highWaterMark:100,size(r){return r.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>DE.textContent(s));const n=this.streamTextContent(e);return new Promise(function(s,r){function i(){a.read().then(function({value:l,done:c}){if(c){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),i()},r)}const a=n.getReader(),o={items:[],styles:Object.create(null),lang:null};i()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const n of this._intentStates.values())if(this._abortOperatorList({intentState:n,reason:new Error("Page was destroyed."),force:!0}),!n.opListReadCapability)for(const s of n.renderTasks)e.push(s.completed),s.cancel();return this.objs.clear(),te(this,lm,!1),le(this,fd,QI).call(this),Promise.all(e)}cleanup(e=!1){te(this,lm,!0);const n=le(this,fd,Qb).call(this,!1);return e&&n&&this._stats&&(this._stats=new YH),n}_startRenderPage(e,n){var r,i;const s=this._intentStates.get(n);s&&((r=this._stats)==null||r.timeEnd("Page Request"),(i=s.displayReadyCapability)==null||i.resolve(e))}_renderPageChunk(e,n){for(let s=0,r=e.length;s<r;s++)n.operatorList.fnArray.push(e.fnArray[s]),n.operatorList.argsArray.push(e.argsArray[s]);n.operatorList.lastChunk=e.lastChunk,n.operatorList.separateAnnots=e.separateAnnots;for(const s of n.renderTasks)s.operatorListChanged();e.lastChunk&&le(this,fd,Qb).call(this,!0)}_pumpOperatorList({renderingIntent:e,cacheKey:n,annotationStorageSerializable:s,modifiedIds:r}){const{map:i,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:n,annotationStorage:i,modifiedIds:r},a).getReader(),c=this._intentStates.get(n);c.streamReader=l;const h=()=>{l.read().then(({value:p,done:m})=>{if(m){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(p,c),h())},p=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const m of c.renderTasks)m.operatorListChanged();le(this,fd,Qb).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(p);else if(c.opListReadCapability)c.opListReadCapability.reject(p);else throw p}})};h()}_abortOperatorList({intentState:e,reason:n,force:s=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!s){if(e.renderTasks.size>0)return;if(n instanceof Ej){let r=QRe;n.extraDelay>0&&n.extraDelay<1e3&&(r+=n.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:n,force:!0})},r);return}}if(e.streamReader.cancel(new W0(n.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[r,i]of this._intentStates)if(i===e){this._intentStates.delete(r);break}this.cleanup()}}}get stats(){return this._stats}}o0=new WeakMap,lm=new WeakMap,fd=new WeakSet,Qb=function(e=!1){if(le(this,fd,QI).call(this),!_(this,lm)||this.destroyed)return!1;if(e)return te(this,o0,setTimeout(()=>{te(this,o0,null),le(this,fd,Qb).call(this,!1)},ZRe)),!1;for(const{renderTasks:n,operatorList:s}of this._intentStates.values())if(n.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),te(this,lm,!1),!0},QI=function(){_(this,o0)&&(clearTimeout(_(this,o0)),te(this,o0,null))};var cm,VR;class cMe{constructor(){oe(this,cm,new Map);oe(this,VR,Promise.resolve())}postMessage(e,n){const s={data:structuredClone(e,n?{transfer:n}:null)};_(this,VR).then(()=>{for(const[r]of _(this,cm))r.call(this,s)})}addEventListener(e,n,s=null){let r=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:i}=s;if(i.aborted){Ks("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(e,n);r=()=>i.removeEventListener("abort",a),i.addEventListener("abort",a)}_(this,cm).set(n,r)}removeEventListener(e,n){const s=_(this,cm).get(n);s==null||s(),_(this,cm).delete(n)}terminate(){for(const[,e]of _(this,cm))e==null||e();_(this,cm).clear()}}cm=new WeakMap,VR=new WeakMap;var zR,Ox,Lx,Xw,ZI,Jw,eN;const Gi=class Gi{constructor({name:e=null,port:n=null,verbosity:s=GNe()}={}){oe(this,Xw);var r;if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,n){if((r=_(Gi,Lx))!=null&&r.has(n))throw new Error("Cannot use more than one PDFWorker per port.");(_(Gi,Lx)||te(Gi,Lx,new WeakMap)).set(n,this),this._initializeFromPort(n);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new vS("main","worker",e),this._messageHandler.on("ready",function(){}),le(this,Xw,ZI).call(this)}_initialize(){if(_(Gi,Ox)||_(Gi,Jw,eN)){this._setupFakeWorker();return}let{workerSrc:e}=Gi;try{Gi._isSameOrigin(window.location.href,e)||(e=Gi._createCDNWrapper(new URL(e,window.location).href));const n=new Worker(e,{type:"module"}),s=new vS("main","worker",n),r=()=>{i.abort(),s.destroy(),n.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},i=new AbortController;n.addEventListener("error",()=>{this._webWorker||r()},{signal:i.signal}),s.on("test",o=>{if(i.abort(),this.destroyed||!o){r();return}this._messageHandler=s,this._port=n,this._webWorker=n,le(this,Xw,ZI).call(this)}),s.on("ready",o=>{if(i.abort(),this.destroyed){r();return}try{a()}catch{this._setupFakeWorker()}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{UM("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){_(Gi,Ox)||(Ks("Setting up fake worker."),te(Gi,Ox,!0)),Gi._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const n=new cMe;this._port=n;const s=`fake${Vl(Gi,zR)._++}`,r=new vS(s+"_worker",s,n);e.setup(r,n),this._messageHandler=new vS(s,s+"_worker",n),le(this,Xw,ZI).call(this)}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){var e,n,s;this.destroyed=!0,(e=this._webWorker)==null||e.terminate(),this._webWorker=null,(n=_(Gi,Lx))==null||n.delete(this._port),this._port=null,(s=this._messageHandler)==null||s.destroy(),this._messageHandler=null}static fromPort(e){var s;if(!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const n=(s=_(this,Lx))==null?void 0:s.get(e.port);
6883if(n){if(n._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new Gi(e)}static get workerSrc(){if(Am.workerSrc)return Am.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return sr(this,"_setupFakeWorkerGlobal",(async()=>_(this,Jw,eN)?_(this,Jw,eN):(await import(this.workerSrc)).WorkerMessageHandler)())}};zR=new WeakMap,Ox=new WeakMap,Lx=new WeakMap,Xw=new WeakSet,ZI=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Jw=new WeakSet,eN=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},oe(Gi,Jw),oe(Gi,zR,0),oe(Gi,Ox,!1),oe(Gi,Lx),yl&&(te(Gi,Ox,!0),Am.workerSrc||(Am.workerSrc="./pdf.worker.mjs")),Gi._isSameOrigin=(e,n)=>{let s;try{if(s=new URL(e),!s.origin||s.origin==="null")return!1}catch{return!1}const r=new URL(n,s);return s.origin===r.origin},Gi._createCDNWrapper=e=>{const n=`await import("${e}");`;return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))};let bw=Gi;var um,Jf,Qw,Zw,dm,jx,ES;class uMe{constructor(e,n,s,r,i){oe(this,jx);oe(this,um,new Map);oe(this,Jf,new Map);oe(this,Qw,new Map);oe(this,Zw,new Map);oe(this,dm,null);this.messageHandler=e,this.loadingTask=n,this.commonObjs=new Tre,this.fontLoader=new cRe({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.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 sr(this,"annotationStorage",new kj)}getRenderingIntent(e,n=Gg.ENABLE,s=null,r=!1,i=!1){let a=wu.DISPLAY,o=V5;switch(e){case"any":a=wu.ANY;break;case"display":break;case"print":a=wu.PRINT;break;default:Ks(`getRenderingIntent - invalid intent: ${e}`)}const l=a&wu.PRINT&&s instanceof nre?s:this.annotationStorage;switch(n){case Gg.DISABLE:a+=wu.ANNOTATIONS_DISABLE;break;case Gg.ENABLE:break;case Gg.ENABLE_FORMS:a+=wu.ANNOTATIONS_FORMS;break;case Gg.ENABLE_STORAGE:a+=wu.ANNOTATIONS_STORAGE,o=l.serializable;break;default:Ks(`getRenderingIntent - invalid annotationMode: ${n}`)}r&&(a+=wu.IS_EDITING),i&&(a+=wu.OPLIST);const{ids:c,hash:h}=l.modifiedIds,p=[a,o.hash,h];return{renderingIntent:a,cacheKey:p.join("_"),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=_(this,dm))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of _(this,Jf).values())e.push(r._destroy());_(this,Jf).clear(),_(this,Qw).clear(),_(this,Zw).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then(()=>{var r,i;this.commonObjs.clear(),this.fontLoader.clear(),_(this,um).clear(),this.filterFactory.destroy(),$E.cleanup(),(r=this._networkStream)==null||r.cancelAllRequests(new W0("Worker was terminated.")),(i=this.messageHandler)==null||i.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:n}=this;e.on("GetReader",(s,r)=>{Oa(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=i=>{this._lastProgress={loaded:i.loaded,total:i.total}},r.onPull=()=>{this._fullReader.read().then(function({value:i,done:a}){if(a){r.close();return}Oa(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(i),1,[i])}).catch(i=>{r.error(i)})},r.onCancel=i=>{this._fullReader.cancel(i),r.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:r,isRangeSupported:i,contentLength:a}=this._fullReader;return(!r||!i)&&(this._lastProgress&&((o=n.onProgress)==null||o.call(n,this._lastProgress)),this._fullReader.onProgress=l=>{var c;(c=n.onProgress)==null||c.call(n,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:r,isRangeSupported:i,contentLength:a}}),e.on("GetRangeReader",(s,r)=>{Oa(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(s.begin,s.end);if(!i){r.close();return}r.onPull=()=>{i.read().then(function({value:a,done:o}){if(o){r.close();return}Oa(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{r.error(a)})},r.onCancel=a=>{i.cancel(a),r.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,n._capability.resolve(new oMe(s,this))}),e.on("DocException",s=>{n._capability.reject(Rc(s))}),e.on("PasswordRequest",s=>{te(this,dm,Promise.withResolvers());try{if(!n.onPassword)throw Rc(s);const r=i=>{i instanceof Error?_(this,dm).reject(i):_(this,dm).resolve({password:i})};n.onPassword(r,s.code)}catch(r){_(this,dm).reject(r)}return _(this,dm).promise}),e.on("DataLoaded",s=>{var r;(r=n.onProgress)==null||r.call(n,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),e.on("StartRenderPage",s=>{if(this.destroyed)return;_(this,Jf).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),e.on("commonobj",([s,r,i])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(r){case"Font":const{disableFontFace:o,fontExtraProperties:l,pdfBug:c}=this._params;if("error"in i){const y=i.error;Ks(`Error during font loading: ${y}`),this.commonObjs.resolve(s,y);break}const h=c&&((a=globalThis.FontInspector)!=null&&a.enabled)?(y,v)=>globalThis.FontInspector.fontAdded(y,v):null,p=new uRe(i,{disableFontFace:o,fontExtraProperties:l,inspectFont:h});this.fontLoader.bind(p).catch(()=>
6883e.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&p.data&&(p.data=null),this.commonObjs.resolve(s,p)});break;case"CopyLocalImage":const{imageRef:m}=i;Oa(m,"The imageRef must be defined.");for(const y of _(this,Jf).values())for(const[,v]of y.objs)if((v==null?void 0:v.ref)===m)return v.dataLen?(this.commonObjs.resolve(s,structuredClone(v)),v.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,i);break;default:throw new Error(`Got unknown common object type ${r}`)}return null}),e.on("obj",([s,r,i,a])=>{var l;if(this.destroyed)return;const o=_(this,Jf).get(r);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(i){case"Image":o.objs.resolve(s,a),(a==null?void 0:a.dataLen)>BNe&&(o._maybeCleanupAfterRender=!0);break;case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${i}`)}}}),e.on("DocProgress",s=>{var r;this.destroyed||(r=n.onProgress)==null||r.call(n,{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&&Ks("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:n}=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},n).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const n=e-1,s=_(this,Qw).get(n);if(s)return s;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&_(this,Zw).set(i.refStr,e);const a=new lMe(n,i,this,this._params.pdfBug);return _(this,Jf).set(n,a),a});return _(this,Qw).set(n,r),r}getPageIndex(e){return cq(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,n){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:n})}getFieldObjects(){return le(this,jx,ES).call(this,"GetFieldObjects")}hasJSActions(){return le(this,jx,ES).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 le(this,jx,ES).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 le(this,jx,ES).call(this,"GetOptionalContentConfig").then(n=>new MRe(n,e))}
6883getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",n=_(this,um).get(e);if(n)return n;const s=this.messageHandler.sendWithPromise(e,null).then(r=>{var i,a;return{info:r[0],metadata:r[1]?new NRe(r[1]):null,contentDispositionFilename:((i=this._fullReader)==null?void 0:i.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return _(this,um).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 n of _(this,Jf).values())if(!n.cleanup())throw new Error(`startCleanup: Page ${n.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),_(this,um).clear(),this.filterFactory.destroy(!0),$E.cleanup()}}cachedPageNumber(e){if(!cq(e))return null;const n=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return _(this,Zw).get(n)??null}}um=new WeakMap,Jf=new WeakMap,Qw=new WeakMap,Zw=new WeakMap,dm=new WeakMap,jx=new WeakSet,ES=function(e,n=null){const s=_(this,um).get(e);if(s)return s;const r=this.messageHandler.sendWithPromise(e,n);return _(this,um).set(e,r),r};const tS=Symbol("INITIAL_DATA");var hu,TT,eO;class Tre{constructor(){oe(this,TT);oe(this,hu,Object.create(null))}get(e,n=null){if(n){const r=le(this,TT,eO).call(this,e);return r.promise.then(()=>n(r.data)),null}const s=_(this,hu)[e];if(!s||s.data===tS)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return s.data}has(e){const n=_(this,hu)[e];return!!n&&n.data!==tS}delete(e){const n=_(this,hu)[e];return!n||n.data===tS?!1:(delete _(this,hu)[e],!0)}resolve(e,n=null){const s=le(this,TT,eO).call(this,e);s.data=n,s.resolve()}clear(){var e;for(const n in _(this,hu)){const{data:s}=_(this,hu)[n];(e=s==null?void 0:s.bitmap)==null||e.close()}te(this,hu,Object.create(null))}*[Symbol.iterator](){for(const e in _(this,hu)){const{data:n}=_(this,hu)[e];n!==tS&&(yield[e,n])}}}hu=new WeakMap,TT=new WeakSet,eO=function(e){var n;return(n=_(this,hu))[e]||(n[e]={...Promise.withResolvers(),data:tS})};var l0;class dMe{constructor(e){oe(this,l0,null);te(this,l0,e),this.onContinue=null}get promise(){return _(this,l0).capability.promise}cancel(e=0){_(this,l0).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=_(this,l0).operatorList;if(!e)return!1;const{annotationCanvasMap:n}=_(this,l0);return e.form||e.canvas&&(n==null?void 0:n.size)>0}}l0=new WeakMap;var c0,Bx;const Zy=class Zy{constructor({callback:e,params:n,objs:s,commonObjs:r,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:p=!1,pageColors:m=null}){oe(this,c0,null);this.callback=e,this.params=n,this.objs=s,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=p,this.pageColors=m,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 dMe(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=n.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:n}){var o,l;if(this.cancelled)return;if(this._canvas){if(_(Zy,Bx).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.");_(Zy,Bx).add(this._canvas)}this._pdfBug&&((o=globalThis.StepperManager)!=null&&o.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:r,transform:i,background:a}=this.params;this.gfx=new vw(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:i,viewport:r,transparency:e,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(e=null,n=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),_(this,c0)&&(window.cancelAnimationFrame(_(this,c0)),te(this,c0,null)),_(Zy,Bx).delete(this._canvas),this.callback(e||new Ej(`Rendering cancelled, page ${this._pageIndex+1}`,n))}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?te(this,c0,window.requestAnimationFrame(()=>{te(this,c0,null),this._nextBound().catch(this._cancelBound)}
6883)):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(),_(Zy,Bx).delete(this._canvas),this.callback())))}};c0=new WeakMap,Bx=new WeakMap,oe(Zy,Bx,new WeakSet);let tO=Zy;const hMe="4.10.38",fMe="f9bea397f";function uq(t){return Math.floor(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,"0")}function nS(t){return Math.max(0,Math.min(255,255*t))}class dq{static CMYK_G([e,n,s,r]){return["G",1-Math.min(1,.3*e+.59*s+.11*n+r)]}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=nS(e),[e,e,e]}static G_HTML([e]){const n=uq(e);return`#${n}${n}${n}`}static RGB_G([e,n,s]){return["G",.3*e+.59*n+.11*s]}static RGB_rgb(e){return e.map(nS)}static RGB_HTML(e){return`#${e.map(uq).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,n,s,r]){return["RGB",1-Math.min(1,e+r),1-Math.min(1,s+r),1-Math.min(1,n+r)]}static CMYK_rgb([e,n,s,r]){return[nS(1-Math.min(1,e+r)),nS(1-Math.min(1,s+r)),nS(1-Math.min(1,n+r))]}static CMYK_HTML(e){const n=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(n)}static RGB_CMYK([e,n,s]){const r=1-e,i=1-n,a=1-s,o=Math.min(r,i,a);return["CMYK",r,i,a,o]}}class pMe{create(e,n,s=!1){if(e<=0||n<=0)throw new Error("Invalid SVG dimensions");const r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),s||(r.setAttribute("width",`${e}px`),r.setAttribute("height",`${n}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${e} ${n}`),r}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){mi("Abstract method `_createSVG` called.")}}class Nj extends pMe{_createSVG(e){return document.createElementNS(qp,e)}}class Are{static setupStorage(e,n,s,r,i){const a=r.getValue(n,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(e.textContent=a.value),i==="print")break;e.addEventListener("input",o=>{r.setValue(n,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?e.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&e.removeAttribute("checked"),i==="print")break;e.addEventListener("change",o=>{r.setValue(n,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&e.setAttribute("value",a.value),i==="print")break;e.addEventListener("input",o=>{r.setValue(n,{value:o.target.value})})}break;case"select":if(a.value!==null){e.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}e.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;r.setValue(n,{value:c})});break}}static setAttributes({html:e,element:n,storage:s=null,intent:r,linkService:i}){const{attributes:a}=n,o=e instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${r}`);for(const[l,c]of Object.entries(a))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:(!o||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,c)}o&&i.addLinkAttributes(e,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(e,a.dataId,n,s)}static render(e){var p,m;const n=e.annotationStorage,s=e.linkService,r=e.xfaHtml,i=e.intent||"display",a=document.createElement(r.name);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:s});const o=i!=="richText",l=e.div;if(l.append(a),e.viewport){const y=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=y}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(r.children.length===0){if(r.value){const y=document.createTextNode(r.value);a.append(y),o&&DE.shouldBuildText(r.name)&&c.push(y)}return{textDivs:c}}const h=[[r,-1,a]];for(;h.length>0;){const[y,v,b]=h.at(-1);
6883if(v+1===y.children.length){h.pop();continue}const S=y.children[++h.at(-1)[1]];if(S===null)continue;const{name:E}=S;if(E==="#text"){const M=document.createTextNode(S.value);c.push(M),b.append(M);continue}const I=(p=S==null?void 0:S.attributes)!=null&&p.xmlns?document.createElementNS(S.attributes.xmlns,E):document.createElement(E);if(b.append(I),S.attributes&&this.setAttributes({html:I,element:S,storage:n,intent:i,linkService:s}),((m=S.children)==null?void 0:m.length)>0)h.push([S,-1,I]);else if(S.value){const M=document.createTextNode(S.value);o&&DE.shouldBuildText(E)&&c.push(M),I.append(M)}}for(const y of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.setAttribute("readOnly",!0);return{textDivs:c}}static update(e){const n=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=n,e.div.hidden=!1}}const OA=1e3,mMe=9,Ov=new WeakSet;function $0(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class gMe{static create(e){switch(e.data.annotationType){case Za.LINK:return new Cre(e);case Za.TEXT:return new yMe(e);case Za.WIDGET:switch(e.data.fieldType){case"Tx":return new xMe(e);case"Btn":return e.data.radioButton?new Nre(e):e.data.checkBox?new bMe(e):new wMe(e);case"Ch":return new _Me(e);case"Sig":return new vMe(e)}return new qv(e);case Za.POPUP:return new sO(e);case Za.FREETEXT:return new Dre(e);case Za.LINE:return new EMe(e);case Za.SQUARE:return new TMe(e);case Za.CIRCLE:return new AMe(e);case Za.POLYLINE:return new Ore(e);case Za.CARET:return new kMe(e);case Za.INK:return new Rj(e);case Za.POLYGON:return new CMe(e);case Za.HIGHLIGHT:return new Lre(e);case Za.UNDERLINE:return new IMe(e);case Za.SQUIGGLY:return new NMe(e);case Za.STRIKEOUT:return new RMe(e);case Za.STAMP:return new jre(e);case Za.FILEATTACHMENT:return new MMe(e);default:return new wa(e)}}}var Ux,e1,t1,AT,nO;const Kj=class Kj{constructor(e,{isRenderable:n=!1,ignoreBorder:s=!1,createQuadrilaterals:r=!1}={}){oe(this,AT);oe(this,Ux,null);oe(this,e1,!1);oe(this,t1,null);this.isRenderable=n,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,n&&(this.container=this._createContainer(s)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:n,richText:s}){return!!(e!=null&&e.str||n!=null&&n.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Kj._hasPopupData(this.data)}updateEdited(e){var s;if(!this.container)return;_(this,Ux)||te(this,Ux,{rect:this.data.rect.slice(0)});const{rect:n}=e;n&&le(this,AT,nO).call(this,n),(s=_(this,t1))==null||s.popup.updateEdited(e)}resetEdited(){var e;_(this,Ux)&&(le(this,AT,nO).call(this,_(this,Ux).rect),(e=_(this,t1))==null||e.popup.resetEdited(),te(this,Ux,null))}_createContainer(e){const{data:n,parent:{page:s,viewport:r}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",n.id),this instanceof qv||(i.tabIndex=OA);const{style:a}=i;if(a.zIndex=this.parent.zIndex++,n.alternativeText&&(i.title=n.alternativeText),n.noRotate&&i.classList.add("norotate"),!n.rect||this instanceof sO){const{rotation:b}=n;return!n.hasOwnCanvas&&b!==0&&this.setRotation(b,i),i}const{width:o,height:l}=$0(n.rect);if(!e&&n.borderStyle.width>0){a.borderWidth=`${n.borderStyle.width}px`;const b=n.borderStyle.horizontalCornerRadius,S=n.borderStyle.verticalCornerRadius;if(b>0||S>0){const I=`calc(${b}px * var(--scale-factor)) / calc(${S}px * var(--scale-factor))`;a.borderRadius=I}else if(this instanceof Nre){const I=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=I}switch(n.borderStyle.style){case Z2.SOLID:a.borderStyle="solid";break;case Z2.DASHED:a.borderStyle="dashed";break;case Z2.BEVELED:Ks("Unimplemented border style: beveled");break;case Z2.INSET:Ks("Unimplemented border style: inset");break;case Z2.UNDERLINE:a.borderBottomStyle="solid";break}const E=n.borderColor||null;E?(te(this,e1,!0),a.borderColor=Gn.makeHexColor(E[0]|0,E[1]|0,E[2]|0)):a.borderWidth=0}const c=Gn.normalizeRect([n.rect[0],s.view[3]-n.rect[1]+s.view[1],n.rect[2],s.view[3]-n.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:p,pageX:m,pageY:y}=r.rawDims;a.left=`${100*(c[0]-m)/h}%`,a.top=`${100*(c[1]-y)/p}%`;const{rotation:v}=n;return n.hasOwnCanvas||v===0?(a.width=`${100*o/h}%`,a.height=`${100*l/p}%`):this.setRotation(v,i),i}setRotation(e,n=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=$0(this.data.rect);let o,l;e%180===0?(o=100*i/s,l=100*a/r):(o=100*a/s,l=100*i/r),n.style.width=`${o}%`,n.style.height=`${l}%`,n.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(n,s,r)=>
6883{const i=r.detail[n],a=i[0],o=i.slice(1);r.target.style[s]=dq[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:dq[`${a}_rgb`](o)})};return sr(this,"_commonActions",{display:n=>{const{display:s}=n.detail,r=s%2===1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:s===1||s===2})},print:n=>{this.annotationStorage.setValue(this.data.id,{noPrint:!n.detail.print})},hidden:n=>{const{hidden:s}=n.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:n=>{setTimeout(()=>n.target.focus({preventScroll:!1}),0)},userName:n=>{n.target.title=n.detail.userName},readonly:n=>{n.target.disabled=n.detail.readonly},required:n=>{this._setRequired(n.target,n.detail.required)},bgColor:n=>{e("bgColor","backgroundColor",n)},fillColor:n=>{e("fillColor","backgroundColor",n)},fgColor:n=>{e("fgColor","color",n)},textColor:n=>{e("textColor","color",n)},borderColor:n=>{e("borderColor","borderColor",n)},strokeColor:n=>{e("strokeColor","borderColor",n)},rotation:n=>{const s=n.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(e,n){const s=this._commonActions;for(const r of Object.keys(n.detail)){const i=e[r]||s[r];i==null||i(n)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const n=this.annotationStorage.getRawValue(this.data.id);if(!n)return;const s=this._commonActions;for(const[r,i]of Object.entries(n)){const a=s[r];if(a){const o={detail:{[r]:i},target:e};a(o),delete n[r]}}}
6883_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[n,s,r,i]=this.data.rect.map(b=>Math.fround(b));if(e.length===8){const[b,S,E,I]=e.subarray(2,6);if(r===b&&i===S&&n===E&&s===I)return}const{style:a}=this.container;let o;if(_(this,e1)){const{borderColor:b,borderWidth:S}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${b}" stroke-width="${S}">`],this.container.classList.add("hasBorder")}const l=r-n,c=i-s,{svgFactory:h}=this,p=h.createElement("svg");p.classList.add("quadrilateralsContainer"),p.setAttribute("width",0),p.setAttribute("height",0);const m=h.createElement("defs");p.append(m);const y=h.createElement("clipPath"),v=`clippath_${this.data.id}`;y.setAttribute("id",v),y.setAttribute("clipPathUnits","objectBoundingBox"),m.append(y);for(let b=2,S=e.length;b<S;b+=8){const E=e[b],I=e[b+1],M=e[b+2],j=e[b+3],L=h.createElement("rect"),K=(M-n)/l,D=(i-I)/c,R=(E-M)/l,B=(I-j)/c;L.setAttribute("x",K),L.setAttribute("y",D),L.setAttribute("width",R),L.setAttribute("height",B),y.append(L),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${K}" y="${D}" width="${R}" height="${B}"/>`)}_(this,e1)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(p),this.container.style.clipPath=`url(#${v})`}_createPopup(){const{data:e}=this,n=te(this,t1,new sO({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(n.render())}render(){mi("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,n=null){const s=[];if(this._fieldObjects){const r=this._fieldObjects[e];if(r)for(const{page:i,id:a,exportValues:o}of r){if(i===-1||a===n)continue;const l=typeof o=="string"?o:null,c=document.querySelector(`[data-element-id="${a}"]`);if(c&&!Ov.has(c)){Ks(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const r of document.getElementsByName(e)){const{exportValue:i}=r,a=r.getAttribute("data-element-id");a!==n&&Ov.has(r)&&s.push({id:a,exportValue:i,domElement:r})}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 n of e)n.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:n}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:e,editId:n})})}};Ux=new WeakMap,e1=new WeakMap,t1=new WeakMap,AT=new WeakSet,nO=function(e){const{container:{style:n},data:{rect:s,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...e);const{width:c,height:h}=$0(e);n.left=`${100*(e[0]-o)/i}%`,n.top=`${100*(a-e[3]+l)/a}%`,r===0?(n.width=`${100*c/i}%`,n.height=`${100*h/a}%`):this.setRotation(r)};let wa=Kj;var Tu,Gy,kre,Ire;class Cre extends wa{constructor(n,s=null){super(n,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});oe(this,Tu);this.isTooltipOnly=n.data.isTooltipOnly}render(){const{data:n,linkService:s}=this,r=document.createElement("a");r.setAttribute("data-element-id",n.id);let i=!1;return n.url?(s.addLinkAttributes(r,n.url,n.newWindow),i=!0):n.action?(this._bindNamedAction(r,n.action),i=!0):n.attachment?(le(this,Tu,kre).call(this,r,n.attachment,n.attachmentDest),i=!0):n.setOCGState?(le(this,Tu,Ire).call(this,r,n.setOCGState),i=!0):n.dest?(this._bindLink(r,n.dest),i=!0):(n.actions&&(n.actions.Action||n.actions["Mouse Up"]||n.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(r,n),i=!0),n.resetForm?(this._bindResetFormAction(r,n.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(r,""),i=!0)),this.container.classList.add("linkA
6883nnotation"),i&&this.container.append(r),this.container}_bindLink(n,s){n.href=this.linkService.getDestinationHash(s),n.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&le(this,Tu,Gy).call(this)}_bindNamedAction(n,s){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeNamedAction(s),!1),le(this,Tu,Gy).call(this)}_bindJSAction(n,s){n.href=this.linkService.getAnchorUrl("");const r=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(s.actions)){const a=r.get(i);a&&(n[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:i}}),!1})}n.onclick||(n.onclick=()=>!1),le(this,Tu,Gy).call(this)}_bindResetFormAction(n,s){const r=n.onclick;if(r||(n.href=this.linkService.getAnchorUrl("")),le(this,Tu,Gy).call(this),!this._fieldObjects){Ks('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),r||(n.onclick=()=>!1);return}n.onclick=()=>{var p;r==null||r();const{fields:i,refs:a,include:o}=s,l=[];if(i.length!==0||a.length!==0){const m=new Set(a);for(const y of i){const v=this._fieldObjects[y]||[];for(const{id:b}of v)m.add(b)}for(const y of Object.values(this._fieldObjects))for(const v of y)m.has(v.id)===o&&l.push(v)}else for(const m of Object.values(this._fieldObjects))l.push(...m);const c=this.annotationStorage,h=[];for(const m of l){const{id:y}=m;switch(h.push(y),m.type){case"text":{const b=m.defaultValue||"";c.setValue(y,{value:b});break}case"checkbox":case"radiobutton":{const b=m.defaultValue===m.exportValues;c.setValue(y,{value:b});break}case"combobox":case"listbox":{const b=m.defaultValue||"";c.setValue(y,{value:b});break}default:continue}const v=document.querySelector(`[data-element-id="${y}"]`);if(v){if(!Ov.has(v)){Ks(`_bindResetFormAction - element not allowed: ${y}`);continue}}else continue;v.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((p=this.linkService.eventBus)==null||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}Tu=new WeakSet,Gy=function(){this.container.setAttribute("data-internal-link","")},kre=function(n,s,r=null){n.href=this.linkService.getAnchorUrl(""),s.description&&(n.title=s.description),n.onclick=()=>{var i;return(i=this.downloadManager)==null||i.openOrDownloadData(s.content,s.filename,r),!1},le(this,Tu,Gy).call(this)},Ire=function(n,s){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeSetOCGState(s),!1),le(this,Tu,Gy).call(this)};class yMe extends wa{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 qv extends wa{render(){return this.container}showElementAndHideCanvas(e){var n;this.data.hasOwnCanvas&&(((n=e.previousSibling)==null?void 0:n.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return nc.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,n,s,r,i){s.includes("mouse")?e.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:i(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):e.addEventListener(s,a=>{var o;if(s==="blur"){if(!n.focused||!a.relatedTarget)return;n.focused=!1}else if(s==="focus"){if(n.focused)return;n.focused=!0}i&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:i(a)}}))})}_setEventListeners(e,n,s,r){var i,a,o;for(const[l,c]of s)(c==="Action"||(i=this.data.actions)!=null&&i[c])&&((c==="Focus"||c==="Blur")&&(n||(n={focused:!1})),this._setEventListener(e,n,l,c,r),c==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(e,n,"blur","Blur",null):c==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(e,n,"focus","Focus",null))}
6883_setBackgroundColor(e){const n=this.data.backgroundColor||null;e.style.backgroundColor=n===null?"transparent":Gn.makeHexColor(n[0],n[1],n[2])}_setTextStyle(e){const n=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||mMe,i=e.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),h=Math.round(c/(x3*r))||1,p=c/h;a=Math.min(r,l(p/x3))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(r,l(c/x3))}i.fontSize=`calc(${a}px * var(--scale-factor))`,i.color=Gn.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(i.textAlign=n[this.data.textAlignment])}_setRequired(e,n){n?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",n)}}class xMe extends qv{constructor(e){const n=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:n})}setPropertyOnSiblings(e,n,s,r){const i=this.annotationStorage;
6883for(const a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[n]=s),i.setValue(a.id,{[r]:s})}render(){var r,i;const e=this.annotationStorage,n=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=e.getValue(n,{value:this.data.fieldValue});let o=a.value||"";const l=e.getValue(n,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let c=a.formattedValue||((r=this.data.textContent)==null?void 0:r.join(`
6884`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const h={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Ov.add(s),s.setAttribute("data-element-id",n),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=OA,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",m=>{e.setValue(n,{value:m.target.value}),this.setPropertyOnSiblings(s,"value",m.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",m=>{const y=this.data.defaultFieldValue??"";s.value=h.userValue=y,h.formattedValue=null});let p=m=>{const{formattedValue:y}=h;y!=null&&(m.target.value=y),m.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",y=>{var b;if(h.focused)return;const{target:v}=y;h.userValue&&(v.value=h.userValue),h.lastCommittedValue=v.value,h.commitKey=1,(b=this.data.actions)!=null&&b.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",y=>{this.showElementAndHideCanvas(y.target);const v={value(b){h.userValue=b.detail.value??"",e.setValue(n,{value:h.userValue.toString()}),b.target.value=h.userValue},formattedValue(b){const{formattedValue:S}=b.detail;h.formattedValue=S,S!=null&&b.target!==document.activeElement&&(b.target.value=S),e.setValue(n,{formattedValue:S})},selRange(b){b.target.setSelectionRange(...b.detail.selRange)},charLimit:b=>{var M;const{charLimit:S}=b.detail,{target:E}=b;if(S===0){E.removeAttribute("maxLength");return}E.setAttribute("maxLength",S);let I=h.userValue;!I||I.length<=S||(I=I.slice(0,S),E.value=h.userValue=I,e.setValue(n,{value:I}),(M=this.linkService.eventBus)==null||M.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:I,willCommit:!0,commitKey:1,selStart:E.selectionStart,selEnd:E.selectionEnd}}))}};this._dispatchEventFromSandbox(v,y)}),s.addEventListener("keydown",y=>{var S;h.commitKey=1;let v=-1;if(y.key==="Escape"?v=0:y.key==="Enter"&&!this.data.multiLine?v=2:y.key==="Tab"&&(h.commitKey=3),v===-1)return;const{value:b}=y.target;h.lastCommittedValue!==b&&(h.lastCommittedValue=b,h.userValue=b,(S=this.linkService.eventBus)==null||S.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:b,willCommit:!0,commitKey:v,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}))});const m=p;p=null,s.addEventListener("blur",y=>{var b,S;if(!h.focused||!y.relatedTarget)return;(b=this.data.actions)!=null&&b.Blur||(h.focused=!1);const{value:v}=y.target;h.userValue=v,h.lastCommittedValue!==v&&((S=this.linkService.eventBus)==null||S.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:v,willCommit:!0,commitKey:h.commitKey,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}})),m(y)}),(i=this.data.actions)!=null&&i.Keystroke&&s.addEventListener("beforeinput",y=>{var L;h.lastCommittedValue=null;const{data:v,target:b}=y,{value:S,selectionStart:E,selectionEnd:I}=b;let M=E,j=I;switch(y.inputType){case"deleteWordBackward":{const K=S.substring(0,E).match(/\w*[^\w]*$/);K&&(M-=K[0].length);break}
vendor: 4,159 bytes, line 6884
6884case"deleteWordForward":{const K=S.substring(E).match(/^[^\w]*\w*/);K&&(j+=K[0].length);break}case"deleteContentBackward":E===I&&(M-=1);break;case"deleteContentForward":E===I&&(j+=1);break}y.preventDefault(),(L=this.linkService.eventBus)==null||L.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:S,change:v||"",willCommit:!1,selStart:M,selEnd:j}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],y=>y.target.value)}if(p&&s.addEventListener("blur",p),this.data.comb){const y=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${y}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 vMe extends qv{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class bMe extends qv{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,n=this.data,s=n.id;let r=e.getValue(s,{value:n.exportValue===n.fieldValue}).value;typeof r=="string"&&(r=r!=="Off",e.setValue(s,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return Ov.add(i),i.setAttribute("data-element-id",s),i.disabled=n.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=n.fieldName,r&&i.setAttribute("checked",!0),i.setAttribute("exportValue",n.exportValue),i.tabIndex=OA,i.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s)){const h=l&&c.exportValue===n.exportValue;c.domElement&&(c.domElement.checked=h),e.setValue(c.id,{value:h})}e.setValue(s,{value:l})}),i.addEventListener("resetform",a=>{const o=n.defaultFieldValue||"Off";a.target.checked=o===n.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(i,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)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Nre extends qv{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,n=this.data,s=n.id;let r=e.getValue(s,{value:n.fieldValue===n.buttonValue}).value;if(typeof r=="string"&&(r=r!==n.buttonValue,e.setValue(s,{value:r})),r)for(const a of this._getElementsByName(n.fieldName,s))e.setValue(a.id,{value:!1});const i=document.createElement("input");if(Ov.add(i),i.setAttribute("data-element-id",s),i.disabled=n.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=n.fieldName,r&&i.setAttribute("checked",!0),i.tabIndex=OA,i.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))e.setValue(c.id,{value:!1});e.setValue(s,{value:l})}),i.addEventListener("resetform",a=>{const o=n.defaultFieldValue;a.target.checked=o!=null&&o===n.buttonValue}),this.enableScripting&&this.hasJSActions){const a=n.buttonValue;i.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const h=a===c.detail.value;for(const p of this._getElementsByName(c.target.name)){const m=h&&p.id===s;p.domElement&&(p.domElement.checked=m),e.setValue(p.id,{value:m})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(i,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)}
6884return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class wMe extends Cre{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const n=e.lastChild;return this.enableScripting&&this.hasJSActions&&n&&(this._setDefaultPropertiesFromJS(n),n.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),e}}class _Me extends qv{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,n=this.data.id,s=e.getValue(n,{value:this.data.fieldValue}),r=document.createElement("select");Ov.add(r),r.setAttribute("data-element-id",n),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=OA;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",h=>{const p=this.data.defaultFieldValue;for(const m of r.options)m.selected=m.value===p});for(const h of this.data.options){const p=document.createElement("option");p.textContent=h.displayValue,p.value=h.exportValue,s.value.includes(h.exportValue)&&(p.setAttribute("selected",!0),i=!1),r.append(p)}let a=null;if(i){const h=document.createElement("option");h.value=" ",h.setAttribute("hidden",!0),h.setAttribute("selected",!0),r.prepend(h),a=()=>{h.remove(),r.removeEventListener("input",a),a=null},r.addEventListener("input",a)}const o=h=>{const p=h?"value":"textContent",{options:m,multiple:y}=r;return y?Array.prototype.filter.call(m,v=>v.selected).map(v=>v[p]):m.selectedIndex===-1?null:m[m.selectedIndex][p]};let l=o(!1);const c=h=>{const p=h.target.options;return Array.prototype.map.call(p,m=>({displayValue:m.textContent,exportValue:m.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",h=>{const p={value(m){a==null||a();const y=m.detail.value,v=new Set(Array.isArray(y)?y:[y]);for(const b of r.options)b.selected=v.has(b.value);e.setValue(n,{value:o(!0)}),l=o(!1)},multipleSelection(m){r.multiple=!0},remove(m){const y=r.options,v=m.detail.remove;y[v].selected=!1,r.remove(v),y.length>0&&Array.prototype.findIndex.call(y,S=>S.selected)===-1&&(y[0].selected=!0),e.setValue(n,{value:o(!0),items:c(m)}),l=o(!1)},clear(m){for(;r.length!==0;)r.remove(0);e.setValue(n,{value:null,items:[]}),l=o(!1)},insert(m){const{index:y,displayValue:v,exportValue:b}=m.detail.insert,S=r.children[y],E=document.createElement("option");E.textContent=v,E.value=b,S?S.before(E):r.append(E),e.setValue(n,{value:o(!0),items:c(m)}),l=o(!1)},items(m){const{items:y}=m.detail;for(;r.length!==0;)r.remove(0);for(const v of y){const{displayValue:b,exportValue:S}=v,E=document.createElement("option");E.textContent=b,E.value=S,r.append(E)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(n,{value:o(!0),items:c(m)}),l=o(!1)},indices(m){const y=new Set(m.detail.indices);for(const v of m.target.options)v.selected=y.has(v.index);e.setValue(n,{value:o(!0)}),l=o(!1)},editable(m){m.target.disabled=!m.detail.editable}};this._dispatchEventFromSandbox(p,h)}),r.addEventListener("input",h=>{var y;const p=o(!0),m=o(!1);e.setValue(n,{value:p}),h.preventDefault(),(y=this.linkService.eventBus)==null||y.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:l,change:m,changeEx:p,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,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)):r.addEventListener("input",function(h){e.setValue(n,{value:o(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class sO extends wa{constructor(e){const{data:n,elements:s}=e;super(e,{isRenderable:wa._hasPopupData(n)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new SMe({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}),n=[];for(const s of this.elements)s.popup=e,s.container.ariaHasPopup="dialog",n.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(s=>`${Sj}${s}`).join(",")),this.container}}
6884var n1,GR,HR,s1,Fx,da,hm,r1,CT,kT,i1,fm,Nh,pm,IT,mm,NT,Vx,zx,ai,tN,rO,Rre,Mre,Pre,$re,nN,sN,iO;class SMe{constructor({container:e,color:n,elements:s,titleObj:r,modificationDate:i,contentsObj:a,richText:o,parent:l,rect:c,parentRect:h,open:p}){oe(this,ai);oe(this,n1,le(this,ai,Pre).bind(this));oe(this,GR,le(this,ai,iO).bind(this));oe(this,HR,le(this,ai,sN).bind(this));oe(this,s1,le(this,ai,nN).bind(this));oe(this,Fx,null);oe(this,da,null);oe(this,hm,null);oe(this,r1,null);oe(this,CT,null);oe(this,kT,null);oe(this,i1,null);oe(this,fm,!1);oe(this,Nh,null);oe(this,pm,null);oe(this,IT,null);oe(this,mm,null);oe(this,NT,null);oe(this,Vx,null);oe(this,zx,!1);var m;te(this,da,e),te(this,NT,r),te(this,hm,a),te(this,mm,o),te(this,kT,l),te(this,Fx,n),te(this,IT,c),te(this,i1,h),te(this,CT,s),te(this,r1,Aj.toDateObject(i)),this.trigger=s.flatMap(y=>y.getElementsToTriggerPopup());for(const y of this.trigger)y.addEventListener("click",_(this,s1)),y.addEventListener("mouseenter",_(this,HR)),y.addEventListener("mouseleave",_(this,GR)),y.classList.add("popupTriggerArea");for(const y of s)(m=y.container)==null||m.addEventListener("keydown",_(this,n1));_(this,da).hidden=!0,p&&le(this,ai,nN).call(this)}render(){if(_(this,Nh))return;const e=te(this,Nh,document.createElement("div"));if(e.className="popup",_(this,Fx)){const i=e.style.outlineColor=Gn.makeHexColor(..._(this,Fx));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${i} 30%, white)`:e.style.backgroundColor=Gn.makeHexColor(..._(this,Fx).map(o=>Math.floor(.7*(255-o)+o)))}const n=document.createElement("span");n.className="header";const s=document.createElement("h1");if(n.append(s),{dir:s.dir,str:s.textContent}=_(this,NT),e.append(n),_(this,r1)){const i=document.createElement("span");i.classList.add("popupDate"),i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:_(this,r1).valueOf()})),n.append(i)}const r=_(this,ai,tN);if(r)Are.render({xfaHtml:r,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const i=this._formatContents(_(this,hm));e.append(i)}_(this,da).append(e)}_formatContents({str:e,dir:n}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=n;const r=e.split(/(?:\r\n?|\n)/);for(let i=0,a=r.length;i<a;++i){const o=r[i];s.append(document.createTextNode(o)),i<a-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:e,popupContent:n}){var s;_(this,Vx)||te(this,Vx,{contentsObj:_(this,hm),richText:_(this,mm)}),e&&te(this,pm,null),n&&(te(this,mm,le(this,ai,Mre).call(this,n)),te(this,hm,null)),(s=_(this,Nh))==null||s.remove(),te(this,Nh,null)}resetEdited(){var e;_(this,Vx)&&({contentsObj:Vl(this,hm)._,richText:Vl(this,mm)._}=_(this,Vx),te(this,Vx,null),(e=_(this,Nh))==null||e.remove(),te(this,Nh,null),te(this,pm,null))}forceHide(){te(this,zx,this.isVisible),_(this,zx)&&(_(this,da).hidden=!0)}maybeShow(){_(this,zx)&&(_(this,Nh)||le(this,ai,sN).call(this),te(this,zx,!1),_(this,da).hidden=!1)}get isVisible(){return _(this,da).hidden===!1}}n1=new WeakMap,GR=new WeakMap,HR=new WeakMap,s1=new WeakMap,Fx=new WeakMap,da=new WeakMap,hm=new WeakMap,r1=new WeakMap,CT=new WeakMap,kT=new WeakMap,i1=new WeakMap,fm=new WeakMap,Nh=new WeakMap,pm=new WeakMap,IT=new WeakMap,mm=new WeakMap,NT=new WeakMap,Vx=new WeakMap,zx=new WeakMap,ai=new WeakSet,tN=function(){const e=_(this,mm),n=_(this,hm);return e!=null&&e.str&&(!(n!=null&&n.str)||n.str===e.str)&&_(this,mm).html||null},rO=function(){var e,n,s;return((s=(n=(e=_(this,ai,tN))==null?void 0:e.attributes)==null?void 0:n.style)==null?void 0:s.fontSize)||0},Rre=function(){var e,n,s;return((s=(n=(e=_(this,ai,tN))==null?void 0:e.attributes)==null?void 0:n.style)==null?void 0:s.color)||null},Mre=function(e){const n=[],s={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:n}]}},r={style:{color:_(this,ai,Rre),fontSize:_(this,ai,rO)?`calc(${_(this,ai,rO)}px * var(--scale-factor))`:""}};for(const i of e.split(`
6885`))n.push({name:"span",value:i,attributes:r});return s},Pre=function(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&_(this,fm))&&le(this,ai,nN).call(this)},$re=function(){if(_(this,pm)!==null)return;const{page:{view:e},viewport:{rawDims:{pageWidth:n,pageHeight:s,pageX:r,pageY:i}}}=_(this,kT);let a=!!_(this,i1),o=a?_(this,i1):_(this,IT);for(const v of _(this,CT))if(!o||Gn.intersect(v.data.rect,o)!==null){o=v.data.rect,a=!0;break}const l=Gn.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),h=a?o[2]-o[0]+5:0,p=l[0]+h,m=l[1];te(this,pm,[100*(p-r)/n,100*(m-i)/s]);const{style:y}=_(this,da);y.left=`${_(this,pm)[0]}%`,y.top=`${_(this,pm)[1]}%`},nN=function(){te(this,fm,!_(this,fm)),_(this,fm)?(le(this,ai,sN).call(this),_(this,da).addEventListener("click",_(this,s1)),_(this,da).addEventListener("keydown",_(this,n1))):(le(this,ai,iO).call(this),_(this,da).removeEventListener("click",_(this,s1)),_(this,da).removeEventListener("keydown",_(this,n1)))},sN=function(){_(this,Nh)||this.render(),this.isVisible?_(this,fm)&&_(this,da).classList.add("focused"):(le(this,ai,$re).call(this),_(this,da).hidden=!1,_(this,da).style.zIndex=parseInt(_(this,da).style.zIndex)+1e3)},iO=function(){_(this,da).classList.remove("focused"),!(_(this,fm)||!this.isVisible)&&(_(this,da).hidden=!0,_(this,da).style.zIndex=parseInt(_(this,da).style.zIndex)-1e3)};class Dre extends wa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Ws.FREETEXT}
6885render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const n of this.textContent){const s=document.createElement("span");s.textContent=n,e.append(s)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var RT;class EMe extends wa{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});oe(this,RT,null)}render(){this.container.classList.add("lineAnnotation");const n=this.data,{width:s,height:r}=$0(n.rect),i=this.svgFactory.create(s,r,!0),a=te(this,RT,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",n.rect[2]-n.lineCoordinates[0]),a.setAttribute("y1",n.rect[3]-n.lineCoordinates[1]),a.setAttribute("x2",n.rect[2]-n.lineCoordinates[2]),a.setAttribute("y2",n.rect[3]-n.lineCoordinates[3]),a.setAttribute("stroke-width",n.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,RT)}addHighlightArea(){this.container.classList.add("highlightArea")}}RT=new WeakMap;var MT;class TMe extends wa{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});oe(this,MT,null)}render(){this.container.classList.add("squareAnnotation");const n=this.data,{width:s,height:r}=$0(n.rect),i=this.svgFactory.create(s,r,!0),a=n.borderStyle.width,o=te(this,MT,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",r-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,MT)}addHighlightArea(){this.container.classList.add("highlightArea")}}MT=new WeakMap;var PT;class AMe extends wa{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});oe(this,PT,null)}render(){this.container.classList.add("circleAnnotation");const n=this.data,{width:s,height:r}=$0(n.rect),i=this.svgFactory.create(s,r,!0),a=n.borderStyle.width,o=te(this,PT,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",r/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",r/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,PT)}addHighlightArea(){this.container.classList.add("highlightArea")}}PT=new WeakMap;var $T;class Ore extends wa{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});oe(this,$T,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:n,vertices:s,borderStyle:r,popupRef:i}}=this;if(!s)return this.container;const{width:a,height:o}=$0(n),l=this.svgFactory.create(a,o,!0);let c=[];for(let p=0,m=s.length;p<m;p+=2){const y=s[p]-n[0],v=n[3]-s[p+1];c.push(`${y},${v}`)}c=c.join(" ");const h=te(this,$T,this.svgFactory.createElement(this.svgElementName));return h.setAttribute("points",c),h.setAttribute("stroke-width",r.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),l.append(h),this.container.append(l),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,$T)}addHighlightArea(){this.container.classList.add("highlightArea")}}$T=new WeakMap;class CMe extends Ore{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class kMe extends wa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}
6885var DT,Gx,OT,aO;class Rj extends wa{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});oe(this,OT);oe(this,DT,null);oe(this,Gx,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Ws.HIGHLIGHT:Ws.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:n,rotation:s,inkLists:r,borderStyle:i,popupRef:a}}=this,{transform:o,width:l,height:c}=le(this,OT,aO).call(this,s,n),h=this.svgFactory.create(l,c,!0),p=te(this,DT,this.svgFactory.createElement("svg:g"));h.append(p),p.setAttribute("stroke-width",i.width||1),p.setAttribute("stroke-linecap","round"),p.setAttribute("stroke-linejoin","round"),p.setAttribute("stroke-miterlimit",10),p.setAttribute("stroke","transparent"),p.setAttribute("fill","transparent"),p.setAttribute("transform",o);for(let m=0,y=r.length;m<y;m++){const v=this.svgFactory.createElement(this.svgElementName);_(this,Gx).push(v),v.setAttribute("points",r[m].join(",")),p.append(v)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(n){super.updateEdited(n);const{thickness:s,points:r,rect:i}=n,a=_(this,DT);if(s>=0&&a.setAttribute("stroke-width",s||1),r)for(let o=0,l=_(this,Gx).length;o<l;o++)_(this,Gx)[o].setAttribute("points",r[o].join(","));if(i){const{transform:o,width:l,height:c}=le(this,OT,aO).call(this,this.data.rotation,i);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${c}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return _(this,Gx)}addHighlightArea(){this.container.classList.add("highlightArea")}}DT=new WeakMap,Gx=new WeakMap,OT=new WeakSet,aO=function(n,s){switch(n){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class Lre extends wa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Ws.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class IMe extends wa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class NMe extends wa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class RMe extends wa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class jre extends wa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Ws.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var LT,jT,oO;class MMe extends wa{constructor(n){var r;super(n,{isRenderable:!0});oe(this,jT);oe(this,LT,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(r=this.linkService.eventBus)==null||r.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:n,data:s}=this;let r;s.hasAppearance||s.fillAlpha===0?r=document.createElement("div"):(r=document.createElement("img"),r.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(r.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),r.addEventListener("dblclick",le(this,jT,oO).bind(this)),te(this,LT,r);const{isMac:i}=nc.platform;return n.addEventListener("keydown",a=>{a.key==="Enter"&&(i?a.metaKey:a.ctrlKey)&&le(this,jT,oO).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():r.classList.add("popupTriggerArea"),n.append(r),n}getElementsToTriggerPopup(){return _(this,LT)}addHighlightArea(){this.container.classList.add("highlightArea")}}LT=new WeakMap,jT=new WeakSet,oO=function(){var n;(n=this.downloadManager)==null||n.openOrDownloadData(this.content,this.filename)};var BT,Hx,qx,UT,Lv,Bre,lO;class PMe{constructor({div:e,accessibilityManager:n,annotationCanvasMap:s,annotationEditorUIManager:r,page:i,viewport:
6885a,structTreeLayer:o}){oe(this,Lv);oe(this,BT,null);oe(this,Hx,null);oe(this,qx,new Map);oe(this,UT,null);this.div=e,te(this,BT,n),te(this,Hx,s),te(this,UT,o||null),this.page=i,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return _(this,qx).size>0}async render(e){var a;const{annotations:n}=e,s=this.div;$v(s,this.viewport);const r=new Map,i={data:null,layer:s,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new Nj,annotationStorage:e.annotationStorage||new kj,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const o of n){if(o.noHTML)continue;const l=o.annotationType===Za.POPUP;if(l){const p=r.get(o.id);if(!p)continue;i.elements=p}else{const{width:p,height:m}=$0(o.rect);if(p<=0||m<=0)continue}i.data=o;const c=gMe.create(i);if(!c.isRenderable)continue;if(!l&&o.popupRef){const p=r.get(o.popupRef);p?p.push(c):r.set(o.popupRef,[c])}const h=c.render();o.hidden&&(h.style.visibility="hidden"),await le(this,Lv,Bre).call(this,h,o.id),c._isEditable&&(_(this,qx).set(c.data.id,c),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(c))}le(this,Lv,lO).call(this)}update({viewport:e}){const n=this.div;this.viewport=e,$v(n,{rotation:e.rotation}),le(this,Lv,lO).call(this),n.hidden=!1}getEditableAnnotations(){return Array.from(_(this,qx).values())}getEditableAnnotation(e){return _(this,qx).get(e)}}BT=new WeakMap,Hx=new WeakMap,qx=new WeakMap,UT=new WeakMap,Lv=new WeakSet,Bre=async function(e,n){var a,o;const s=e.firstChild||e,r=s.id=`${Sj}${n}`,i=await((a=_(this,UT))==null?void 0:a.getAriaAttributes(r));if(i)for(const[l,c]of i)s.setAttribute(l,c);this.div.append(e),(o=_(this,BT))==null||o.moveElementInDOM(this.div,e,s,!1)},lO=function(){if(!_(this,Hx))return;const e=this.div;for(const[n,s]of _(this,Hx)){const r=e.querySelector(`[data-annotation-id="${n}"]`);if(!r)continue;s.className="annotationContent";const{firstChild:i}=r;i?i.nodeName==="CANVAS"?i.replaceWith(s):i.classList.contains("annotationContent")?i.after(s):i.before(s):r.append(s)}_(this,Hx).clear()};const uI=/\r\n?|\n/g;var Rh,fu,FT,Wx,pu,Fa,Ure,Fre,Vre,rN,Rm,iN,aN,zre,uO,Gre;const Si=class Si extends ea{constructor(n){super({...n,name:"freeTextEditor"});oe(this,Fa);oe(this,Rh);oe(this,fu,"");oe(this,FT,`${this.id}-editor`);oe(this,Wx,null);oe(this,pu);te(this,Rh,n.color||Si._defaultColor||ea._defaultLineColor),te(this,pu,n.fontSize||Si._defaultFontSize)}static get _keyboardManager(){const n=Si.prototype,s=a=>a.isEmpty(),r=Dv.TRANSLATE_SMALL,i=Dv.TRANSLATE_BIG;return sr(this,"_keyboardManager",new DA([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],n.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],n.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],n._translateEmpty,{args:[-r,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],n._translateEmpty,{args:[-i,0],checker:s}],[["ArrowRight","mac+ArrowRight"],n._translateEmpty,{args:[r,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],n._translateEmpty,{args:[i,0],checker:s}],[["ArrowUp","mac+ArrowUp"],n._translateEmpty,{args:[0,-r],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],n._translateEmpty,{args:[0,-i],checker:s}],[["ArrowDown","mac+ArrowDown"],n._translateEmpty,{args:[0,r],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],n._translateEmpty,{args:[0,i],checker:s}]]))}static initialize(n,s){ea.initialize(n,s);const r=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(r.getPropertyValue("--freetext-padding"))}static updateDefaultParams(n,s){switch(n){case br.FREETEXT_SIZE:Si._defaultFontSize=s;break;case br.FREETEXT_COLOR:Si._defaultColor=s;break}}updateParams(n,s){switch(n){case br.FREETEXT_SIZE:le(this,Fa,Ure).call(this,s);break;case br.FREETEXT_COLOR:le(this,Fa,Fre).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[br.FREETEXT_SIZE,Si._defaultFontSize],[br.FREETEXT_COLOR,Si._defaultColor||ea._defaultLineColor]]}
6885get propertiesToUpdate(){return[[br.FREETEXT_SIZE,_(this,pu)],[br.FREETEXT_COLOR,_(this,Rh)]]}_translateEmpty(n,s){this._uiManager.translateSelectedEditors(n,s,!0)}getInitialTranslation(){const n=this.parentScale;return[-Si._internalPadding*n,-(Si._internalPadding+_(this,pu))*n]}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(Ws.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),te(this,Wx,new AbortController);const n=this._uiManager.combinedSignal(_(this,Wx));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:n}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:n}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:n}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:n}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:n})}disableEditMode(){var n;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",_(this,FT)),this._isDraggable=!0,(n=_(this,Wx))==null||n.abort(),te(this,Wx,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(n){this._focusEventsAllowed&&(super.focusin(n),n.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(n){var s;this.width||(this.enableEditMode(),n&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.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 n=_(this,fu),s=te(this,fu,le(this,Fa,Vre).call(this).trimEnd());if(n===s)return;const r=i=>{if(te(this,fu,i),!i){this.remove();return}le(this,Fa,aN).call(this),this._uiManager.rebuild(this),le(this,Fa,rN).call(this)};this.addCommands({cmd:()=>{r(s)},undo:()=>{r(n)},mustExec:!1}),le(this,Fa,rN).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(n){this.enterInEditMode()}keydown(n){n.target===this.div&&n.key==="Enter"&&(this.enterInEditMode(),n.preventDefault())}editorDivKeydown(n){Si._keyboardManager.exec(this,n)}editorDivFocus(n){this.isEditing=!0}editorDivBlur(n){this.isEditing=!1}editorDivInput(n){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 n,s;this.width&&(n=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",_(this,FT)),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:r}=this.editorDiv;if(r.fontSize=`calc(${_(this,pu)}px * var(--scale-factor))`,r.color=_(this,Rh),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),bR(this,this.div,["dblclick","keydown"]),this.width){const[i,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[h,p]=this.pageDimensions,[m,y]=this.pageTranslation;let v,b;switch(this.rotation){case 0:v=n+(o[0]-m)/h,b=s+this.height-(o[1]-y)/p;break;case 90:v=n+(o[0]-m)/h,b=s-(o[1]-y)/p,[l,c]=[c,-l];break;case 180:v=n-this.width+(o[0]-m)/h,b=s-(o[1]-y)/p,[l,c]=[-l,-c];break;case 270:v=n+(o[0]-m-this.height*p)/h,b=s+(o[1]-y-this.width*h)/p,[l,c]=[-c,l];break}this.setAt(v*i,b*a,l,c)}else this.setAt(n*i,s*a,this.width*i,this.height*a);le(this,Fa,aN).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(n){var v,b,S;const s=n.clipboardData||window.clipboardData,{types:r}=s;if(r.length===1&&r[0]==="text/plain")return;n.preventDefault();const i=le(v=Si,Rm,uO).call(v,s.getData("text")||"").replaceAll(uI,`
6886`);
vendor: 15,222 bytes, lines 6886-6893
6886if(!i)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!i.includes(`
6887`)){o.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:c}=o,h=[],p=[];if(l.nodeType===Node.TEXT_NODE){const E=l.parentElement;if(p.push(l.nodeValue.slice(c).replaceAll(uI,"")),E!==this.editorDiv){let I=h;for(const M of this.editorDiv.childNodes){if(M===E){I=p;continue}I.push(le(b=Si,Rm,iN).call(b,M))}}h.push(l.nodeValue.slice(0,c).replaceAll(uI,""))}else if(l===this.editorDiv){let E=h,I=0;for(const M of this.editorDiv.childNodes)I++===c&&(E=p),E.push(le(S=Si,Rm,iN).call(S,M))}te(this,fu,`${h.join(`
6888`)}${i}${p.join(`
6889`)}`),le(this,Fa,aN).call(this);const m=new Range;let y=h.reduce((E,I)=>E+I.length,0);for(const{firstChild:E}of this.editorDiv.childNodes)if(E.nodeType===Node.TEXT_NODE){const I=E.nodeValue.length;if(y<=I){m.setStart(E,y),m.setEnd(E,y);break}y-=I}a.removeAllRanges(),a.addRange(m)}get contentDiv(){return this.editorDiv}static async deserialize(n,s,r){var o;let i=null;if(n instanceof Dre){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:p,id:m,popupRef:y},textContent:v,textPosition:b,parent:{page:{pageNumber:S}}}=n;if(!v||v.length===0)return null;i=n={annotationType:Ws.FREETEXT,color:Array.from(c),fontSize:l,value:v.join(`
6890`),position:b,pageIndex:S-1,rect:h.slice(0),rotation:p,id:m,deleted:!1,popupRef:y}}const a=await super.deserialize(n,s,r);return te(a,pu,n.fontSize),te(a,Rh,Gn.makeHexColor(...n.color)),te(a,fu,le(o=Si,Rm,uO).call(o,n.value)),a.annotationElementId=n.id||null,a._initialData=i,a}serialize(n=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Si._internalPadding*this.parentScale,r=this.getRect(s,s),i=ea._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:_(this,Rh)),a={annotationType:Ws.FREETEXT,color:i,fontSize:_(this,pu),value:le(this,Fa,zre).call(this),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return n?a:this.annotationElementId&&!le(this,Fa,Gre).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(n){const s=super.renderAnnotationElement(n);if(this.deleted)return s;const{style:r}=s;r.fontSize=`calc(${_(this,pu)}px * var(--scale-factor))`,r.color=_(this,Rh),s.replaceChildren();for(const a of _(this,fu).split(`
6891`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const i=Si._internalPadding*this.parentScale;return n.updateEdited({rect:this.getRect(i,i),popupContent:_(this,fu)}),s}resetAnnotationElement(n){super.resetAnnotationElement(n),n.resetEdited()}};Rh=new WeakMap,fu=new WeakMap,FT=new WeakMap,Wx=new WeakMap,pu=new WeakMap,Fa=new WeakSet,Ure=function(n){const s=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--scale-factor))`,this.translate(0,-(i-_(this,pu))*this.parentScale),te(this,pu,i),le(this,Fa,rN).call(this)},r=_(this,pu);this.addCommands({cmd:s.bind(this,n),undo:s.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:br.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Fre=function(n){const s=i=>{te(this,Rh,this.editorDiv.style.color=i)},r=_(this,Rh);this.addCommands({cmd:s.bind(this,n),undo:s.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:br.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Vre=function(){var r;const n=[];this.editorDiv.normalize();let s=null;for(const i of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&i.nodeName==="BR"||(n.push(le(r=Si,Rm,iN).call(r,i)),s=i);return n.join(`
6892`)},rN=function(){const[n,s]=this.parentDimensions;let r;if(this.isAttachedToDOM)r=this.div.getBoundingClientRect();else{const{currentLayer:i,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",i.div.append(this.div),r=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=r.width/n,this.height=r.height/s):(this.width=r.height/n,this.height=r.width/s),this.fixAndSetPosition()},Rm=new WeakSet,iN=function(n){return(n.nodeType===Node.TEXT_NODE?n.nodeValue:n.innerText).replaceAll(uI,"")},aN=function(){if(this.editorDiv.replaceChildren(),!!_(this,fu))for(const n of _(this,fu).split(`
6893`)){const s=document.createElement("div");s.append(n?document.createTextNode(n):document.createElement("br")),this.editorDiv.append(s)}},zre=function(){return _(this,fu).replaceAll(" "," ")},uO=function(n){return n.replaceAll(" "," ")},Gre=function(n){const{value:s,fontSize:r,color:i,pageIndex:a}=this._initialData;return this._hasBeenMoved||n.value!==s||n.fontSize!==r||n.color.some((o,l)=>o!==i[l])||n.pageIndex!==a},oe(Si,Rm),os(Si,"_freeTextDefaultContent",""),os(Si,"_internalPadding",0),os(Si,"_defaultColor",null),os(Si,"_defaultFontSize",10),os(Si,"_type","freetext"),os(Si,"_editorType",Ws.FREETEXT);let cO=Si;class En{toSVGPath(){mi("Abstract method `toSVGPath` must be implemented.")}get box(){mi("Abstract getter `box` must be implemented.")}serialize(e,n){mi("Abstract method `serialize` must be implemented.")}static _rescale(e,n,s,r,i,a){a||(a=new Float32Array(e.length));for(let o=0,l=e.length;o<l;o+=2)a[o]=n+e[o]*r,a[o+1]=s+e[o+1]*i;return a}static _rescaleAndSwap(e,n,s,r,i,a){a||(a=new Float32Array(e.length));for(let o=0,l=e.length;o<l;o+=2)a[o]=n+e[o+1]*r,a[o+1]=s+e[o]*i;return a}static _translate(e,n,s,r){r||(r=new Float32Array(e.length));for(let i=0,a=e.length;i<a;i+=2)r[i]=n+e[i],r[i+1]=s+e[i+1];return r}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,n,s,r,i){switch(i){case 90:return[1-n/s,e/r];case 180:return[1-e/s,1-n/r];case 270:return[n/s,1-e/r];default:return[e/s,n/r]}}static _normalizePagePoint(e,n,s){switch(s){case 90:return[1-n,e];case 180:return[1-e,1-n];case 270:return[n,1-e];default:return[e,n]}}static createBezierPoints(e,n,s,r,i,a){return[(e+5*s)/6,(n+5*r)/6,(5*s+i)/6,(5*r+a)/6,(s+i)/2,(r+a)/2]}}os(En,"PRECISION",1e-4);var mu,Mh,a1,o1,Qf,nr,Kx,Yx,VT,zT,l1,c1,u0,GT,qR,WR,ao,TS,Hre,qre,Wre,Kre,Yre,Xre;const Xp=class Xp{constructor({x:e,y:n},s,r,i,a,o=0){oe(this,ao);oe(this,mu);oe(this,Mh,[]);oe(this,a1);oe(this,o1);oe(this,Qf,[]);oe(this,nr,new Float32Array(18));oe(this,Kx);oe(this,Yx);oe(this,VT);oe(this,zT);oe(this,l1);oe(this,c1);oe(this,u0,[]);te(this,mu,s),te(this,c1,i*r),te(this,o1,a),_(this,nr).set([NaN,NaN,NaN,NaN,e,n],6),te(this,a1,o),te(this,zT,_(Xp,GT)*r),te(this,VT,_(Xp,WR)*r),te(this,l1,r),_(this,u0).push(e,n)}isEmpty(){return isNaN(_(this,nr)[8])}add({x:e,y:n}){var B;te(this,Kx,e),te(this,Yx,n);const[s,r,i,a]=_(this,mu);let[o,l,c,h]=_(this,nr).subarray(8,12);const p=e-c,m=n-h,y=Math.hypot(p,m);if(y<_(this,VT))return!1;const v=y-_(this,zT),b=v/y,S=b*p,E=b*m;let I=o,M=l;o=c,l=h,c+=S,h+=E,(B=_(this,u0))==null||B.push(e,n);const j=-E/v,L=S/v,K=j*_(this,c1),D=L*_(this,c1);return _(this,nr).set(_(this,nr).subarray(2,8),0),_(this,nr).set([c+K,h+D],4),_(this,nr).set(_(this,nr).subarray(14,18),12),_(this,nr).set([c-K,h-D],16),isNaN(_(this,nr)[6])?(_(this,Qf).length===0&&(_(this,nr).set([o+K,l+D],2),_(this,Qf).push(NaN,NaN,NaN,NaN,(o+K-s)/i,(l+D-r)/a),_(this,nr).set([o-K,l-D],14),_(this,Mh).push(NaN,NaN,NaN,NaN,(o-K-s)/i,(l-D-r)/a)),_(this,nr).set([I,M,o,l,c,h],6),!this.isEmpty()):(_(this,nr).set([I,M,o,l,c,h],6),Math.abs(Math.atan2(M-l,I-o)-Math.atan2(E,S))<Math.PI/2?([o,l,c,h]=_(this,nr).subarray(2,6),_(this,Qf).push(NaN,NaN,NaN,NaN,((o+c)/2-s)/i,((l+h)/2-r)/a),[o,l,I,M]=_(this,nr).subarray(14,18),_(this,Mh).push(NaN,NaN,NaN,NaN,((I+o)/2-s)/i,((M+l)/2-r)/a),!0):([I,M,o,l,c,h]=_(this,nr).subarray(0,6),_(this,Qf).push(((I+5*o)/6-s)/i,((M+5*l)/6-r)/a,((5*o+c)/6-s)/i,((5*l+h)/6-r)/a,((o+c)/2-s)/i,((l+h)/2-r)/a),[c,h,o,l,I,M]=_(this,nr).subarray(12,18),_(this,Mh).push(((I+5*o)/6-s)/i,((M+5*l)/6-r)/a,((5*o+c)/6-s)/i,((5*l+h)/6-r)/a,((o+c)/2-s)/i,((l+h)/2-r)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const e=_(this,Qf),n=_(this,Mh);if(isNaN(_(this,nr)[6])&&!this.isEmpty())return le(this,ao,Hre).call(this);const s=[];s.push(`M${e[4]} ${e[5]}`);for(let r=6;r<e.length;r+=6)isNaN(e[r])?s.push(`L${e[r+4]} ${e[r+5]}`):s.push(`C${e[r]} ${e[r+1]} ${e[r+2]} ${e[r+3]} ${e[r+4]} ${e[r+5]}`);le(this,ao,Wre).call(this,s);for(let r=n.length-6;r>=6;r-=6)isNaN(n[r])?s.push(`L${n[r+4]} ${n[r+5]}`):s.push(`C${n[r]} ${n[r+1]} ${n[r+2]} ${n[r+3]} ${n[r+4]} ${n[r+5]}`);return le(this,ao,qre).call(this,s),s.join(" ")}newFreeDrawOutline(e,n,s,r,i,a){return new Jre(e,n,s,r,i,a)}getOutlines(){var p;const e=_(this,Qf),n=_(this,Mh),s=_(this,nr),[r,i,a,o]=_(this,mu),l=new Float32Array((((p=_(this,u0))==null?void 0:p.length)??0)+2);for(let m=0,y=l.length-2;m<y;m+=2)l[m]=(_(this,u0)[m]-r)/a,l[m+1]=(_(this,u0)[m+1]-i)/o;if(l[l.length-2]=(_(this,Kx)-r)/a,l[l.length-1]=(_(this,Yx)-i)/o,isNaN(s[6])&&!this.isEmpty())return le(this,ao,Kre).call(this,l);const c=new Float32Array(_(this,Qf).length+24+_(this,Mh).length);let h=e.length;for(let m=0;m<h;m+=2){if(isNaN(e[m])){c[m]=c[m+1]=NaN;continue}c[m]=e[m],c[m+1]=e[m+1]}h=le(this,ao,Xre).call(this,c,h);for(let m=n.length-6;m>=6;m-=6)for(let y=0;y<6;y+=2){if(isNaN(n[m+y])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=n[m+y],c[h+1]=n[m+y+1],h+=2}return le(this,ao,Yre).call(this,c,h),this.newFreeDrawOutline(c,l,_(this,mu),_(this,l1),_(this,a1),_(this,o1))}};mu=new WeakMap,Mh=new WeakMap,a1=new WeakMap,o1=new WeakMap,Qf=new WeakMap,nr=new WeakMap,Kx=new WeakMap,Yx=new WeakMap,VT=new WeakMap,zT=new WeakMap,l1=new WeakMap,c1=new WeakMap,u0=new WeakMap,GT=new WeakMap,qR=new WeakMap,WR=new WeakMap,ao=new WeakSet,TS=function(){const e=_(this,nr).subarray(4,6),n=_(this,nr).subarray(16,18),[s,r,i,a]=_(this,mu);return[(_(this,Kx)+(e[0]-n[0])/2-s)/i,(_(this,Yx)+(e[1]-n[1])/2-r)/a,(_(this,Kx)+(n[0]-e[0])/2-s)/i,(_(this,Yx)+(n[1]-e[1])/2-r)/a]},Hre=function(){const[e,n,s,r]=_(this,mu),[i,a,o,l]=le(this,ao,TS).call(this);return`M${(_(this,nr)[2]-e)/s} ${(_(this,nr)[3]-n)/r} L${(_(this,nr)[4]-e)/s} ${(_(this,nr)[5]-n)/r} L${i} ${a} L${o} ${l} L${(_(this,nr)[16]-e)/s} ${(_(this,nr)[17]-n)/r} L${(_(this,nr)[14]-e)/s} ${(_(this,nr)[15]-n)/r} Z`},qre=function(e){const n=_(this,Mh);e.push(`L${n[4]} ${n[5]} Z`)},Wre=function(e){const[n,s,r,i]=_(this,mu),a=_(this,nr).subarray(4,6),o=_(this,nr).subarray(16,18),[l,c,h,p]=le(this,ao,TS).call(this);e.push(`L${(a[0]-n)/r} ${(a[1]-s)/i} L${l} ${c} L${h} ${p} L${(o[0]-n)/r} ${(o[1]-s)/i}`)},Kre=function(e){const n=_(this,nr),[s,r,i,a]=_(this,mu),[o,l,c,h]=le(this,ao,TS).call(this),p=new Float32Array(36);return p.set([NaN,NaN,NaN,NaN,(n[2]-s)/i,(n[3]-r)/a,NaN,NaN,NaN,NaN,(n[4]-s)/i,(n[5]-r)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(n[16]-s)/i,(n[17]-r)/a,NaN,NaN,NaN,NaN,(n[14]-s)/i,(n[15]-r)/a],0),this.newFreeDrawOutline(p,e,_(this,mu),_(this,l1),_(this,a1),_(this,o1))},Yre=function(e,n){const s=_(this,Mh);return e.set([NaN,NaN,NaN,NaN,s[4],s[5]],n),n+=6},Xre=function(e,n){const s=_(this,nr).subarray(4,6),r=_(this,nr).subarray(16,18),[i,a,o,l]=_(this,mu),[c,h,p,m]=le(this,ao,TS).call(this);return e.set([NaN,NaN,NaN,NaN,(s[0]-i)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,p,m,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/l],n),n+=24},oe(Xp,GT,8),oe(Xp,qR,2),oe(Xp,WR,_(Xp,GT)+_(Xp,qR));let SR=Xp;var u1,Xx,gm,HT,gu,qT,va,KR,Qre;class Jre extends En{constructor(n,s,r,i,a,o){super();oe(this,KR);oe(this,u1);oe(this,Xx,new Float32Array(4));oe(this,gm);oe(this,HT);oe(this,gu);oe(this,qT);oe(this,va);te(this,va,n),te(this,gu,s),te(this,u1,r),te(this,qT,i),te(this,gm,a),te(this,HT,o),this.lastPoint=[NaN,NaN],le(this,KR,Qre).call(this,o);const[l,c,h,p]=_(this,Xx);for(let m=0,y=n.length;m<y;m+=2)n[m]=(n[m]-l)/h,n[m+1]=(n[m+1]-c)/p;for(let m=0,y=s.length;m<y;m+=2)s[m]=(s[m]-l)/h,s[m+1]=(s[m+1]-c)/p}toSVGPath(){const n=[`M${_(this,va)[4]} ${_(this,va)[5]}`];for(let s=6,r=_(this,va).length;s<r;s+=6){if(isNaN(_(this,va)[s])){n.push(`L${_(this,va)[s+4]} ${_(this,va)[s+5]}`);continue}n.push(`C${_(this,va)[s]} ${_(this,va)[s+1]} ${_(this,va)[s+2]} ${_(this,va)[s+3]} ${_(this,va)[s+4]} ${_(this,va)[s+5]}`)}return n.push("Z"),n.join(" ")}serialize([n,s,r,i],a){const o=r-n,l=i-s;let c,h;switch(a){case 0:c=En._rescale(_(this,va),n,i,o,-l),h=En._rescale(_(this,gu),n,i,o,-l);break;case 90:c=En._rescaleAndSwap(_(this,va),n,s,o,l),h=En._rescaleAndSwap(_(this,gu),n,s,o,l);break;case 180:c=En._rescale(_(this,va),r,s,-o,l),h=En._rescale(_(this,gu),r,s,-o,l);break;case 270:c=En._rescaleAndSwap(_(this,va),r,i,-o,-l),h=En._rescaleAndSwap(_(this,gu),r,i,-o,-l);break}return{outline:Array.from(c),points:[Array.from(h)]}}get box(){return _(this,Xx)}newOutliner(n,s,r,i,a,o=0){return new SR(n,s,r,i,a,o)}getNewOutline(n,s){const[r,i,a,o]=_(this,Xx),[l,c,h,p]=_(this,u1),m=a*h,y=o*p,v=r*h+l,b=i*p+c,S=this.newOutliner({x:_(this,gu)[0]*m+v,y:_(this,gu)[1]*y+b},_(this,u1),_(this,qT),n,_(this,HT),s??_(this,gm));for(let E=2;E<_(this,gu).length;E+=2)S.add({x:_(this,gu)[E]*m+v,y:_(this,gu)[E+1]*y+b});return S.getOutlines()}}u1=new WeakMap,Xx=new WeakMap,gm=new WeakMap,HT=new WeakMap,gu=new WeakMap,qT=new WeakMap,va=new WeakMap,KR=new WeakSet,Qre=function(n){const s=_(this,va);let r=s[4],i=s[5],a=r,o=i,l=r,c=i,h=r,p=i;const m=n?Math.max:Math.min;for(let v=6,b=s.length;v<b;v+=6){if(isNaN(s[v]))a=Math.min(a,s[v+4]),o=Math.min(o,s[v+5]),l=Math.max(l,s[v+4]),c=Math.max(c,s[v+5]),p<s[v+5]?(h=s[v+4],p=s[v+5]):p===s[v+5]&&(h=m(h,s[v+4]));else{const S=Gn.bezierBoundingBox(r,i,...s.slice(v,v+6));a=Math.min(a,S[0]),o=Math.min(o,S[1]),l=Math.max(l,S[2]),c=Math.max(c,S[3]),p<S[3]?(h=S[2],p=S[3]):p===S[3]&&(h=m(h,S[2]))}r=s[v+4],i=s[v+5]}const y=_(this,Xx);y[0]=a-_(this,gm),y[1]=o-_(this,gm),y[2]=l-a+2*_(this,gm),y[3]=c-o+2*_(this,gm),this.lastPoint=[h,p]};var WT,KT,d0,Ph,rc,Zre,oN,eie,tie,hO;class dO{constructor(e,n=0,s=0,r=!0){oe(this,rc);oe(this,WT);oe(this,KT);oe(this,d0,[]);oe(this,Ph,[]);let i=1/0,a=-1/0,o=1/0,l=-1/0;const c=10**-4;for(const{x:S,y:E,width:I,height:M}of e){const j=Math.floor((S-n)/c)*c,L=Math.ceil((S+I+n)/c)*c,K=Math.floor((E-n)/c)*c,D=Math.ceil((E+M+n)/c)*c,R=[j,K,D,!0],B=[L,K,D,!1];_(this,d0).push(R,B),i=Math.min(i,j),a=Math.max(a,L),o=Math.min(o,K),l=Math.max(l,D)}const h=a-i+2*s,p=l-o+2*s,m=i-s,y=o-s,v=_(this,d0).at(r?-1:-2),b=[v[0],v[2]];for(const S of _(this,d0)){const[E,I,M]=S;S[0]=(E-m)/h,S[1]=(I-y)/p,S[2]=(M-y)/p}te(this,WT,new Float32Array([m,y,h,p])),te(this,KT,b)}getOutlines(){_(this,d0).sort((n,s)=>n[0]-s[0]||n[1]-s[1]||n[2]-s[2]);const e=[];for(const n of _(this,d0))n[3]?(e.push(...le(this,rc,hO).call(this,n)),le(this,rc,eie).call(this,n)):(le(this,rc,tie).call(this,n),e.push(...le(this,rc,hO).call(this,n)));return le(this,rc,Zre).call(this,e)}}WT=new WeakMap,KT=new WeakMap,d0=new WeakMap,Ph=new WeakMap,rc=new WeakSet,Zre=function(e){const n=[],s=new Set;for(const a of e){const[o,l,c]=a;n.push([o,l,a],[o,c,a])}n.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=n.length;a<o;a+=2){const l=n[a][2],c=n[a+1][2];l.push(c),c.push(l),s.add(l),s.add(c)}const r=[];let i;for(;s.size>0;){const a=s.values().next().value;let[o,l,c,h,p]=a;s.delete(a);let m=o,y=l;
6893for(i=[o,c],r.push(i);;){let v;if(s.has(h))v=h;else if(s.has(p))v=p;else break;s.delete(v),[o,l,c,h,p]=v,m!==o&&(i.push(m,y,o,y===l?l:c),m=o),y=y===l?c:l}i.push(m,y)}return new $Me(r,_(this,WT),_(this,KT))},oN=function(e){const n=_(this,Ph);let s=0,r=n.length-1;for(;s<=r;){const i=s+r>>1,a=n[i][0];if(a===e)return i;a<e?s=i+1:r=i-1}return r+1},eie=function([,e,n]){const s=le(this,rc,oN).call(this,e);_(this,Ph).splice(s,0,[e,n])},tie=function([,e,n]){const s=le(this,rc,oN).call(this,e);for(let r=s;r<_(this,Ph).length;r++){const[i,a]=_(this,Ph)[r];if(i!==e)break;if(i===e&&a===n){_(this,Ph).splice(r,1);return}}for(let r=s-1;r>=0;r--){const[i,a]=_(this,Ph)[r];if(i!==e)break;if(i===e&&a===n){_(this,Ph).splice(r,1);return}}},hO=function(e){const[n,s,r]=e,i=[[n,s,r]],a=le(this,rc,oN).call(this,r);for(let o=0;o<a;o++){const[l,c]=_(this,Ph)[o];for(let h=0,p=i.length;h<p;h++){const[,m,y]=i[h];if(!(c<=m||y<=l)){if(m>=l){if(y>c)i[h][1]=c;else{if(p===1)return[];i.splice(h,1),h--,p--}continue}i[h][2]=l,y>c&&i.push([n,c,y])}}}return i};var YT,d1;class $Me extends En{constructor(n,s,r){super();oe(this,YT);oe(this,d1);te(this,d1,n),te(this,YT,s),this.lastPoint=r}toSVGPath(){const n=[];for(const s of _(this,d1)){let[r,i]=s;n.push(`M${r} ${i}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===r?(n.push(`V${l}`),i=l):l===i&&(n.push(`H${o}`),r=o)}n.push("Z")}return n.join(" ")}serialize([n,s,r,i],a){const o=[],l=r-n,c=i-s;for(const h of _(this,d1)){const p=new Array(h.length);for(let m=0;m<h.length;m+=2)p[m]=n+h[m]*l,p[m+1]=i-h[m+1]*c;o.push(p)}return o}get box(){return _(this,YT)}get classNamesForOutlining(){return["highlightOutline"]}}YT=new WeakMap,d1=new WeakMap;class fO extends SR{newFreeDrawOutline(e,n,s,r,i,a){return new DMe(e,n,s,r,i,a)}}class DMe extends Jre{newOutliner(e,n,s,r,i,a=0){return new fO(e,n,s,r,i,a)}}var $h,Jx,h1,no,XT,f1,JT,QT,h0,Dh,p1,ZT,ii,pO,mO,gO,Hy,nie,Bg;const Mc=class Mc{constructor({editor:e=null,uiManager:n=null}){oe(this,ii);oe(this,$h,null);oe(this,Jx,null);oe(this,h1);oe(this,no,null);oe(this,XT,!1);oe(this,f1,!1);oe(this,JT,null);oe(this,QT);oe(this,h0,null);oe(this,Dh,null);oe(this,p1);var s;e?(te(this,f1,!1),te(this,p1,br.HIGHLIGHT_COLOR),te(this,JT,e)):(te(this,f1,!0),te(this,p1,br.HIGHLIGHT_DEFAULT_COLOR)),te(this,Dh,(e==null?void 0:e._uiManager)||n),te(this,QT,_(this,Dh)._eventBus),te(this,h1,(e==null?void 0:e.color)||((s=_(this,Dh))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),_(Mc,ZT)||te(Mc,ZT,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return sr(this,"_keyboardManager",new DA([[["Escape","mac+Escape"],Mc.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Mc.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Mc.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Mc.prototype._moveToPrevious],[["Home","mac+Home"],Mc.prototype._moveToBeginning],[["End","mac+End"],Mc.prototype._moveToEnd]]))}renderButton(){const e=te(this,$h,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);const n=_(this,Dh)._signal;e.addEventListener("click",le(this,ii,Hy).bind(this),{signal:n}),e.addEventListener("keydown",le(this,ii,gO).bind(this),{signal:n});const s=te(this,Jx,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=_(this,h1),e.append(s),e}renderMainDropdown(){const e=te(this,no,le(this,ii,pO).call(this));return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}_colorSelectFromKeyboard(e){if(e.target===_(this,$h)){le(this,ii,Hy).call(this,e);return}const n=e.target.getAttribute("data-color");n&&le(this,ii,mO).call(this,n,e)}_moveToNext(e){var n,s;if(!_(this,ii,Bg)){le(this,ii,Hy).call(this,e);return}if(e.target===_(this,$h)){(n=_(this,no).firstChild)==null||n.focus();return}(s=e.target.nextSibling)==null||s.focus()}_moveToPrevious(e){var n,s;if(e.target===((n=_(this,no))==null?void 0:n.firstChild)||e.target===_(this,$h)){_(this,ii,Bg)&&this._hideDropdownFromKeyboard();return}_(this,ii,Bg)||le(this,ii,Hy).call(this,e),(s=e.target.previousSibling)==null||s.focus()}_moveToBeginning(e){var n;if(!_(this,ii,Bg)){le(this,ii,Hy).call(this,e);return}(n=_(this,no).firstChild)==null||n.focus()}_moveToEnd(e){var n;if(!_(this,ii,Bg)){le(this,ii,Hy).call(this,e);return}(n=_(this,no).lastChild)==null||n.focus()}hideDropdown(){var e,n;(e=_(this,no))==null||e.classList.add("hidden"),(n=_(this,h0))==null||n.abort(),te(this,h0,null)}_hideDropdownFromKeyboard(){var e;if(!_(this,f1)){if(!_(this,ii,Bg)){(e=_(this,JT))==null||e.unselect();return}this.hideDropdown(),_(this,$h).focus({preventScroll:!0,focusVisible:_(this,XT)})}}updateColor(e){if(_(this,Jx)&&(_(this,Jx).style.backgroundColor=e),!_(this,no))return;const n=_(this,Dh).highlightColors.values();for(const s of _(this,no).children)s.setAttribute("aria-selected",n.next().value===e)}destroy(){var e,n;(e=_(this,$h))==null||e.remove(),te(this,$h,null),te(this,Jx,null),(n=_(this,no))==null||n.remove(),te(this,no,null)}};$h=new WeakMap,Jx=new WeakMap,h1=new WeakMap,no=new WeakMap,XT=new WeakMap,f1=new WeakMap,JT=new WeakMap,QT=new WeakMap,h0=new WeakMap,Dh=new WeakMap,p1=new WeakMap,ZT=new WeakMap,ii=new WeakSet,pO=function(){const e=document.createElement("div"),n=_(this,Dh)._signal;e.addEventListener("contextmenu",Xh,{signal:n}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,r]of _(this,Dh).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",r),i.title=s,i.setAttribute("data-l10n-id",_(Mc,ZT)[s]);const a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=r,i.setAttribute("aria-selected",r===_(this,h1)),i.addEventListener("click",le(this,ii,mO).bind(this,r),{signal:n}),e.append(i)}return e.addEventListener("keydown",le(this,ii,gO).bind(this),{signal:n}),e}
6893,mO=function(e,n){n.stopPropagation(),_(this,QT).dispatch("switchannotationeditorparams",{source:this,type:_(this,p1),value:e})},gO=function(e){Mc._keyboardManager.exec(this,e)},Hy=function(e){if(_(this,ii,Bg)){this.hideDropdown();return}if(te(this,XT,e.detail===0),_(this,h0)||(te(this,h0,new AbortController),window.addEventListener("pointerdown",le(this,ii,nie).bind(this),{signal:_(this,Dh).combinedSignal(_(this,h0))})),_(this,no)){_(this,no).classList.remove("hidden");return}const n=te(this,no,le(this,ii,pO).call(this));_(this,$h).append(n)},nie=function(e){var n;(n=_(this,no))!=null&&n.contains(e.target)||this.hideDropdown()},Bg=function(){return _(this,no)&&!_(this,no).classList.contains("hidden")},oe(Mc,ZT,null);let ER=Mc;var m1,eA,ym,Qx,g1,Dc,tA,nA,Zx,cd,yu,Lo,y1,xm,fl,x1,ud,sA,Vs,yO,lN,sie,rie,iie,xO,qy,pd,Zb,aie,cN,AS,oie,lie,cie,uie,die;const Hr=class Hr extends ea{constructor(n){super({...n,name:"highlightEditor"});oe(this,Vs);oe(this,m1,null);oe(this,eA,0);oe(this,ym);oe(this,Qx,null);oe(this,g1,null);oe(this,Dc,null);oe(this,tA,null);oe(this,nA,0);oe(this,Zx,null);oe(this,cd,null);oe(this,yu,null);oe(this,Lo,!1);oe(this,y1,null);oe(this,xm);oe(this,fl,null);oe(this,x1,"");oe(this,ud);oe(this,sA,"");this.color=n.color||Hr._defaultColor,te(this,ud,n.thickness||Hr._defaultThickness),te(this,xm,n.opacity||Hr._defaultOpacity),te(this,ym,n.boxes||null),te(this,sA,n.methodOfCreation||""),te(this,x1,n.text||""),this._isDraggable=!1,n.highlightId>-1?(te(this,Lo,!0),le(this,Vs,lN).call(this,n),le(this,Vs,qy).call(this)):_(this,ym)&&(te(this,m1,n.anchorNode),te(this,eA,n.anchorOffset),te(this,tA,n.focusNode),te(this,nA,n.focusOffset),le(this,Vs,yO).call(this),le(this,Vs,qy).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const n=Hr.prototype;return sr(this,"_keyboardManager",new DA([[["ArrowLeft","mac+ArrowLeft"],n._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],n._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],n._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],n._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:_(this,Lo)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:_(this,ud),methodOfCreation:_(this,sA)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(n){return{numberOfColors:n.get("color").size}}static initialize(n,s){var r;ea.initialize(n,s),Hr._defaultColor||(Hr._defaultColor=((r=s.highlightColors)==null?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(n,s){switch(n){case br.HIGHLIGHT_DEFAULT_COLOR:Hr._defaultColor=s;break;case br.HIGHLIGHT_THICKNESS:Hr._defaultThickness=s;break}}translateInPage(n,s){}get toolbarPosition(){return _(this,y1)}updateParams(n,s){switch(n){case br.HIGHLIGHT_COLOR:le(this,Vs,sie).call(this,s);break;case br.HIGHLIGHT_THICKNESS:le(this,Vs,rie).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[br.HIGHLIGHT_DEFAULT_COLOR,Hr._defaultColor],[br.HIGHLIGHT_THICKNESS,Hr._defaultThickness]]}get propertiesToUpdate(){return[[br.HIGHLIGHT_COLOR,this.color||Hr._defaultColor],[br.HIGHLIGHT_THICKNESS,_(this,ud)||Hr._defaultThickness],[br.HIGHLIGHT_FREE,_(this,Lo)]]}async addEditToolbar(){const n=await super.addEditToolbar();return n?(this._uiManager.highlightColors&&(te(this,g1,new ER({editor:this})),n.addColorPicker(_(this,g1))),n):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(le(this,Vs,AS).call(this))}getBaseTranslation(){return[0,0]}getRect(n,s){return super.getRect(n,s,le(this,Vs,AS).call(this))}onceAdded(n){this.annotationElementId||this.parent.addUndoableEditor(this),n&&this.div.focus()}remove(){le(this,Vs,xO).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(le(this,Vs,qy).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(n){var r;let s=!1;this.parent&&!n?le(this,Vs,xO).call(this):n&&(le(this,Vs,qy).call(this,n),s=!this.parent&&((r=this.div)==null?void 0:r.classList.contains("selectedEditor"))),super.setParent(n),this.show(this._isVisible),s&&this.select()}rotate(n){var i,a,o;const{drawLayer:s}=this.parent;let r;
vendor: 10,735 bytes, line 6893
6893_(this,Lo)?(n=(n-this.rotation+360)%360,r=le(i=Hr,pd,Zb).call(i,_(this,cd).box,n)):r=le(a=Hr,pd,Zb).call(a,[this.x,this.y,this.width,this.height],n),s.updateProperties(_(this,yu),{bbox:r,root:{"data-main-rotation":n}}),s.updateProperties(_(this,fl),{bbox:le(o=Hr,pd,Zb).call(o,_(this,Dc).box,n),root:{"data-main-rotation":n}})}render(){if(this.div)return this.div;const n=super.render();_(this,x1)&&(n.setAttribute("aria-label",_(this,x1)),n.setAttribute("role","mark")),_(this,Lo)?n.classList.add("free"):this.div.addEventListener("keydown",le(this,Vs,aie).bind(this),{signal:this._uiManager._signal});const s=te(this,Zx,document.createElement("div"));n.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=_(this,Qx);const[r,i]=this.parentDimensions;return this.setDims(this.width*r,this.height*i),bR(this,_(this,Zx),["pointerover","pointerleave"]),this.enableEditing(),n}pointerover(){var n;this.isSelected||(n=this.parent)==null||n.drawLayer.updateProperties(_(this,fl),{rootClass:{hovered:!0}})}pointerleave(){var n;this.isSelected||(n=this.parent)==null||n.drawLayer.updateProperties(_(this,fl),{rootClass:{hovered:!1}})}_moveCaret(n){switch(this.parent.unselect(this),n){case 0:case 2:le(this,Vs,cN).call(this,!0);break;case 1:case 3:le(this,Vs,cN).call(this,!1);break}}select(){var n;super.select(),_(this,fl)&&((n=this.parent)==null||n.drawLayer.updateProperties(_(this,fl),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var n;super.unselect(),_(this,fl)&&((n=this.parent)==null||n.drawLayer.updateProperties(_(this,fl),{rootClass:{selected:!1}}),_(this,Lo)||le(this,Vs,cN).call(this,!1))}get _mustFixPosition(){return!_(this,Lo)}show(n=this._isVisible){super.show(n),this.parent&&(this.parent.drawLayer.updateProperties(_(this,yu),{rootClass:{hidden:!n}}),this.parent.drawLayer.updateProperties(_(this,fl),{rootClass:{hidden:!n}}))}static startHighlighting(n,s,{target:r,x:i,y:a}){const{x:o,y:l,width:c,height:h}=r.getBoundingClientRect(),p=new AbortController,m=n.combinedSignal(p),y=v=>{p.abort(),le(this,pd,uie).call(this,n,v)};window.addEventListener("blur",y,{signal:m}),window.addEventListener("pointerup",y,{signal:m}),window.addEventListener("pointerdown",Cu,{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",Xh,{signal:m}),r.addEventListener("pointermove",le(this,pd,cie).bind(this,n),{signal:m}),this._freeHighlight=new fO({x:i,y:a},[o,l,c,h],n.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=n.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(n,s,r){var b,S,E,I;let i=null;if(n instanceof Lre){const{data:{quadPoints:M,rect:j,rotation:L,id:K,color:D,opacity:R,popupRef:B},parent:{page:{pageNumber:G}}}=n;i=n={annotationType:Ws.HIGHLIGHT,color:Array.from(D),opacity:R,quadPoints:M,boxes:null,pageIndex:G-1,rect:j.slice(0),rotation:L,id:K,deleted:!1,popupRef:B}}else if(n instanceof Rj){const{data:{inkLists:M,rect:j,rotation:L,id:K,color:D,borderStyle:{rawWidth:R},popupRef:B},parent:{page:{pageNumber:G}}}=n;i=n={annotationType:Ws.HIGHLIGHT,color:Array.from(D),thickness:R,inkLists:M,boxes:null,pageIndex:G-1,rect:j.slice(0),rotation:L,id:K,deleted:!1,popupRef:B}}const{color:a,quadPoints:o,inkLists:l,opacity:c}=n,h=await super.deserialize(n,s,r);h.color=Gn.makeHexColor(...a),te(h,xm,c||1),l&&te(h,ud,n.thickness),h.annotationElementId=n.id||null,h._initialData=i;const[p,m]=h.pageDimensions,[y,v]=h.pageTranslation;if(o){const M=te(h,ym,[]);for(let j=0;j<o.length;j+=8)M.push({x:(o[j]-y)/p,y:1-(o[j+1]-v)/m,width:(o[j+2]-o[j])/p,height:(o[j+1]-o[j+5])/m});le(b=h,Vs,yO).call(b),le(S=h,Vs,qy).call(S),h.rotate(h.rotation)}else if(l){te(h,Lo,!0);const M=l[0],j={x:M[0]-y,y:m-(M[1]-v)},L=new fO(j,[0,0,p,m],1,_(h,ud)/2,!0,.001);for(let R=0,B=M.length;R<B;R+=2)j.x=M[R]-y,j.y=m-(M[R+1]-v),L.add(j);const{id:K,clipPathId:D}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:L.toSVGPath()}},!0,!0);le(E=h,Vs,lN).call(E,{highlightOutlines:L.getOutlines(),highlightId:K,clipPathId:D}),le(I=h,Vs,qy).call(I)}return h}serialize(n=!1){if(this.isEmpty()||n)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),r=ea._colorManager.convert(this.color),i={annotationType:Ws.HIGHLIGHT,color:r,opacity:_(this,xm),thickness:_(this,ud),quadPoints:le(this,Vs,oie).call(this),outlines:le(this,Vs,lie).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:le(this,Vs,AS).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!le(this,Vs,die).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(n){return n.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};m1=new WeakMap,eA=new WeakMap,ym=new WeakMap,Qx=new WeakMap,g1=new WeakMap,Dc=new WeakMap,tA=new WeakMap,nA=new WeakMap,Zx=new WeakMap,cd=new WeakMap,yu=new WeakMap,Lo=new WeakMap,y1=new WeakMap,xm=new WeakMap,fl=new WeakMap,x1=new WeakMap,ud=new WeakMap,sA=new WeakMap,Vs=new WeakSet,yO=function(){const n=new dO(_(this,ym),.001);te(this,cd,n.getOutlines()),[this.x,this.y,this.width,this.height]=_(this,cd).box;const s=new dO(_(this,ym),.0025,.001,this._uiManager.direction==="ltr");te(this,Dc,s.getOutlines());const{lastPoint:r}=_(this,Dc);te(this,y1,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},lN=function({highlightOutlines:n,highlightId:s,clipPathId:r}){var p,m;if(te(this,cd,n),te(this,Dc,n.getNewOutline(_(this,ud)/2+1.5,.0025)),s>=0)te(this,yu,s),te(this,Qx,r),this.parent.drawLayer.finalizeDraw(s,{bbox:n.box,path:{d:n.toSVGPath()}}),te(this,fl,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:_(this,Dc).box,path:{d:_(this,Dc).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(_(this,yu),{bbox:le(p=Hr,pd,Zb).call(p,_(this,cd).box,(y-this.rotation+360)%360),path:{d:n.toSVGPath()}}),this.parent.drawLayer.updateProperties(_(this,fl),{bbox:le(m=Hr,pd,Zb).call(m,_(this,Dc).box,y),path:{d:_(this,Dc).toSVGPath()}})}const[a,o,l,c]=n.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=c;break;case 90:{const[y,v]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*v/y,this.height=c*y/v;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[y,v]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*v/y,this.height=c*y/v;break}}const{lastPoint:h}=_(this,Dc);te(this,y1,[(h[0]-a)/l,(h[1]-o)/c])},sie=function(n){const s=(a,o)=>{var l,c;this.color=a,te(this,xm,o),(l=this.parent)==null||l.drawLayer.updateProperties(_(this,yu),{root:{fill:a,"fill-opacity":o}}),(c=_(this,g1))==null||c.updateColor(a)},r=this.color,i=_(this,xm);this.addCommands({cmd:s.bind(this,n,Hr._defaultOpacity),undo:s.bind(this,r,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:br.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(n)},!0)},rie=function(n){const s=_(this,ud),r=i=>{te(this,ud,i),le(this,Vs,iie).call(this,i)};this.addCommands({cmd:r.bind(this,n),undo:r.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:br.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:n},!0)},iie=function(n){if(!_(this,Lo))return;le(this,Vs,lN).call(this,{highlightOutlines:_(this,cd).getNewOutline(n/2)}),this.fixAndSetPosition();const[s,r]=this.parentDimensions;this.setDims(this.width*s,this.height*r)},xO=function(){_(this,yu)===null||!this.parent||(this.parent.drawLayer.remove(_(this,yu)),te(this,yu,null),this.parent.drawLayer.remove(_(this,fl)),te(this,fl,null))},qy=function(n=this.parent){_(this,yu)===null&&({id:Vl(this,yu)._,clipPathId:Vl(this,Qx)._}=n.drawLayer.draw({bbox:_(this,cd).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":_(this,xm)},rootClass:{highlight:!0,free:_(this,Lo)},path:{d:_(this,cd).toSVGPath()}},!1,!0),te(this,fl,n.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:_(this,Lo)},bbox:_(this,Dc).box,path:{d:_(this,Dc).toSVGPath()}},_(this,Lo))),_(this,Zx)&&(_(this,Zx).style.clipPath=_(this,Qx)))},pd=new WeakSet,Zb=function([n,s,r,i],a){switch(a){case 90:return[1-s-i,n,i,r];case 180:return[1-n-r,1-s-i,r,i];case 270:return[s,1-n-r,i,r]}return[n,s,r,i]},aie=function(n){Hr._keyboardManager.exec(this,n)},cN=function(n){if(!_(this,m1))return;const s=window.getSelection();n?s.setPosition(_(this,m1),_(this,eA)):s.setPosition(_(this,tA),_(this,nA))},AS=function(){return _(this,Lo)?this.rotation:0},oie=function(){if(_(this,Lo))return null;const[n,s]=this.pageDimensions,[r,i]=this.pageTranslation,a=_(this,ym),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:h,width:p,height:m}of a){const y=c*n+r,v=(1-h)*s+i;o[l]=o[l+4]=y,o[l+1]=o[l+3]=v,o[l+2]=o[l+6]=y+p*n,o[l+5]=o[l+7]=v-m*s,l+=8}return o},lie=function(n){return _(this,cd).serialize(n,le(this,Vs,AS).call(this))},cie=function(n,s){this._freeHighlight.add(s)&&n.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},uie=function(n,s){this._freeHighlight.isEmpty()?n.drawLayer.remove(this._freeHighlightId):n.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},die=function(n){const{color:s}=this._initialData;return n.color.some((r,i)=>r!==s[i])},oe(Hr,pd),os(Hr,"_defaultColor",null),os(Hr,"_defaultOpacity",1),os(Hr,"_defaultThickness",12),os(Hr,"_type","highlight"),os(Hr,"_editorType",Ws.HIGHLIGHT),os(Hr,"_freeHighlightId",-1),os(Hr,"_freeHighlight",null),os(Hr,"_freeHighlightClipId","");let TR=Hr;var ev;class OMe{constructor(){oe(this,ev,Object.create(null))}updateProperty(e,n){this[e]=n,this.updateSVGProperty(e,n)}updateProperties(e){if(e)for(const[n,s]of Object.entries(e))this.updateProperty(n,s)}updateSVGProperty(e,n){_(this,ev)[e]=n}toSVGProperties(){const e=_(this,ev);return te(this,ev,Object.create(null)),{root:e}}reset(){te(this,ev,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){mi("Not implemented")}}ev=new WeakMap;var xu,v1,So,tv,nv,f0,p0,m0,sv,Nr,bO,wO,_O,CS,hie,uN,kS,ew;const Tn=class Tn extends ea{constructor(n){super(n);oe(this,Nr);oe(this,xu,null);oe(this,v1);os(this,"_drawId",null);
6893te(this,v1,n.mustBeCommitted||!1),n.drawOutlines&&(le(this,Nr,bO).call(this,n),le(this,Nr,CS).call(this))}static _mergeSVGProperties(n,s){const r=new Set(Object.keys(n));for(const[i,a]of Object.entries(s))r.has(i)?Object.assign(n[i],a):n[i]=a;return n}static getDefaultDrawingOptions(n){mi("Not implemented")}static get typesMap(){mi("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(n,s){const r=this.typesMap.get(n);r&&this._defaultDrawingOptions.updateProperty(r,s),this._currentParent&&(_(Tn,So).updateProperty(r,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(n,s){const r=this.constructor.typesMap.get(n);r&&this._updateProperty(n,r,s)}static get defaultPropertiesToUpdate(){const n=[],s=this._defaultDrawingOptions;for(const[r,i]of this.typesMap)n.push([r,s[i]]);return n}get propertiesToUpdate(){const n=[],{_drawingOptions:s}=this;for(const[r,i]of this.constructor.typesMap)n.push([r,s[i]]);return n}_updateProperty(n,s,r){const i=this._drawingOptions,a=i[s],o=l=>{var h;i.updateProperty(s,l);const c=_(this,xu).updateProperty(s,l);c&&le(this,Nr,kS).call(this,c),(h=this.parent)==null||h.drawLayer.updateProperties(this._drawId,i.toSVGProperties())};this.addCommands({cmd:o.bind(this,r),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,Tn._mergeSVGProperties(_(this,xu).getPathResizingSVGProperties(le(this,Nr,uN).call(this)),{bbox:le(this,Nr,ew).call(this)}))}_onResized(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,Tn._mergeSVGProperties(_(this,xu).getPathResizedSVGProperties(le(this,Nr,uN).call(this)),{bbox:le(this,Nr,ew).call(this)}))}_onTranslating(n,s){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,{bbox:le(this,Nr,ew).call(this,n,s)})}_onTranslated(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,Tn._mergeSVGProperties(_(this,xu).getPathTranslatedSVGProperties(le(this,Nr,uN).call(this),this.parentDimensions),{bbox:le(this,Nr,ew).call(this)}))}_onStartDragging(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(n){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,_(this,v1)&&(te(this,v1,!1),this.commit(),this.parent.setSelected(this),n&&this.isOnScreen&&this.div.focus())}remove(){le(this,Nr,_O).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(le(this,Nr,CS).call(this),le(this,Nr,kS).call(this,_(this,xu).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(n){var r;let s=!1;this.parent&&!n?(this._uiManager.removeShouldRescale(this),le(this,Nr,_O).call(this)):n&&(this._uiManager.addShouldRescale(this),le(this,Nr,CS).call(this,n),s=!this.parent&&((r=this.div)==null?void 0:r.classList.contains("selectedEditor"))),super.setParent(n),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Tn._mergeSVGProperties({bbox:le(this,Nr,ew).call(this)},_(this,xu).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&le(this,Nr,kS).call(this,_(this,xu).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const n=super.render();n.classList.add("draw");const s=document.createElement("div");n.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[r,i]=this.parentDimensions;return this.setDims(this.width*r,this.height*i),this._uiManager.addShouldRescale(this),this.disableEditing(),n}static createDrawerInstance(n,s,r,i,a){mi("Not implemented")}static startDrawing(n,s,r,i){var S;const{target:a,offsetX:o,offsetY:l,pointerId:c,pointerType:h}=i;if(_(Tn,p0)&&_(Tn,p0)!==h)return;const{viewport:{rotation:p}}=n,{width:m,height:y}=a.getBoundingClientRect(),v=te(Tn,tv,new AbortController),b=n.combinedSignal(v);if(_(Tn,f0)||te(Tn,f0,c),_(Tn,p0)??te(Tn,p0,h),window.addEventListener("pointerup",E=>{var I;_(Tn,f0)===E.pointerId?this._endDraw(E):(I=_(Tn,m0))==null||I.delete(E.pointerId)},{signal:b}),window.addEventListener("pointercancel",E=>{var I;_(Tn,f0)===E.pointerId?this._currentParent.endDrawingSession():(I=_(Tn,m0))==null||I.delete(E.pointerId)},{signal:b}),window.addEventListener("pointerdown",E=>{_(Tn,p0)===E.pointerType&&((_(Tn,m0)||te(Tn,m0,new Set)).add(E.pointerId),_(Tn,So).isCancellable()&&(_(Tn,So).removeLastElement(),_(Tn,So).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",Xh,{signal:b}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:b}),a.addEventListener("touchmove",E=>{E.timeStamp===_(Tn,sv)&&Cu(E)},{signal:b}),n.toggleDrawing(),(S=s._editorUndoBar)==null||S.hide(),_(Tn,So)){n.drawLayer.updateProperties(this._currentDrawId,_(Tn,So).startNew(o,l,m,y,p));return}s.updateUIForDefaultProperties(this),te(Tn,So,this.createDrawerInstance(o,l,m,y,p)),te(Tn,nv,this.getDefaultDrawingOptions()),this._currentParent=n,{id:this._currentDrawId}=n.drawLayer.draw(this._mergeSVGProperties(_(Tn,nv).toSVGProperties(),_(Tn,So).defaultSVGProperties),!0,!1)}static _drawMove(n){var a;if(te(Tn,sv,-1),!_(Tn,So))return;const{offsetX:s,offsetY:r,pointerId:i}=n;if(_(Tn,f0)===i){if(((a=_(Tn,m0))==null?void 0:a.size)>=1){this._endDraw(n);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,_(Tn,So).add(s,r)),te(Tn,sv,n.timeStamp),Cu(n)}}static _cleanup(n){n&&(this._currentDrawId=-1,this._currentParent=null,te(Tn,So,null),te(Tn,nv,null),te(Tn,p0,null),te(Tn,sv,NaN)),_(Tn,tv)&&(_(Tn,tv).abort(),te(Tn,tv,null),te(Tn,f0,NaN),te(Tn,m0,null))}static _endDraw(n){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),n&&s.drawLayer.updateProperties(this._currentDrawId,_(Tn,So).end(n.offsetX,n.offsetY)),this.supportMultipleDrawings){const r=_(Tn,So),i=this._currentDrawId,a=r.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(i,r.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(i,r.removeLastElement())},mustExec:!1,type:br.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(n){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(br.DRAW_STEP),!_(Tn,So).isEmpty()){const{pageDimensions:[r,i],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:_(Tn,So).getOutlines(r*a,i*a,a,this._INNER_MARGIN),drawingOptions:_(Tn,nv),mustBeCommitted:!n}
6893);return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(n){}static deserializeDraw(n,s,r,i,a,o){mi("Not implemented")}static async deserialize(n,s,r){var p,m;const{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:l}}=s.viewport,c=this.deserializeDraw(o,l,i,a,this._INNER_MARGIN,n),h=await super.deserialize(n,s,r);return h.createDrawingOptions(n),le(p=h,Nr,bO).call(p,{drawOutlines:c}),le(m=h,Nr,CS).call(m),h.onScaleChanging(),h.rotate(),h}serializeDraw(n){const[s,r]=this.pageTranslation,[i,a]=this.pageDimensions;return _(this,xu).serialize([s,r,i,a],n)}renderAnnotationElement(n){return n.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};xu=new WeakMap,v1=new WeakMap,So=new WeakMap,tv=new WeakMap,nv=new WeakMap,f0=new WeakMap,p0=new WeakMap,m0=new WeakMap,sv=new WeakMap,Nr=new WeakSet,bO=function({drawOutlines:n,drawId:s,drawingOptions:r}){te(this,xu,n),this._drawingOptions||(this._drawingOptions=r),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,n.defaultProperties)):this._drawId=le(this,Nr,wO).call(this,n,this.parent),le(this,Nr,kS).call(this,n.box)},wO=function(n,s){const{id:r}=s.drawLayer.draw(Tn._mergeSVGProperties(this._drawingOptions.toSVGProperties(),n.defaultSVGProperties),!1,!1);return r},_O=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},CS=function(n=this.parent){if(!(this._drawId!==null&&this.parent===n)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,n.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=le(this,Nr,wO).call(this,_(this,xu),n)}},hie=function([n,s,r,i]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-n,r*(o/a),i*(a/o)];case 180:return[1-n,1-s,r,i];case 270:return[1-s,n,r*(o/a),i*(a/o)];default:return[n,s,r,i]}},uN=function(){const{x:n,y:s,width:r,height:i,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,n,r*(a/o),i*(o/a)];case 180:return[1-n,1-s,r,i];case 270:return[s,1-n,r*(a/o),i*(o/a)];default:return[n,s,r,i]}},kS=function(n){if([this.x,this.y,this.width,this.height]=le(this,Nr,hie).call(this,n),this.div){this.fixAndSetPosition();const[s,r]=this.parentDimensions;this.setDims(this.width*s,this.height*r)}this._onResized()},ew=function(){const{x:n,y:s,width:r,height:i,rotation:a,parentRotation:o,parentDimensions:[l,c]}=this;switch((a*4+o)/90){case 1:return[1-s-i,n,i,r];case 2:return[1-n-r,1-s-i,r,i];case 3:return[s,1-n-r,i,r];case 4:return[n,s-r*(l/c),i*(c/l),r*(l/c)];case 5:return[1-s,n,r*(l/c),i*(c/l)];case 6:return[1-n-i*(c/l),1-s,i*(c/l),r*(l/c)];case 7:return[s-r*(l/c),1-n-i*(c/l),r*(l/c),i*(c/l)];case 8:return[n-r,s-i,r,i];case 9:return[1-s,n-r,i,r];case 10:return[1-n,1-s,r,i];case 11:return[s-i,1-n,i,r];case 12:return[n-i*(c/l),s,i*(c/l),r*(l/c)];case 13:return[1-s-r*(l/c),n-i*(c/l),r*(l/c),i*(c/l)];case 14:return[1-n,1-s-r*(l/c),i*(c/l),r*(l/c)];case 15:return[s,1-n,r*(l/c),i*(c/l)];default:return[n,s,r,i]}},os(Tn,"_currentDrawId",-1),os(Tn,"_currentParent",null),oe(Tn,So,null),oe(Tn,tv,null),oe(Tn,nv,null),oe(Tn,f0,NaN),oe(Tn,p0,null),oe(Tn,m0,null),oe(Tn,sv,NaN),os(Tn,"_INNER_MARGIN",3);let vO=Tn;var Zf,Eo,To,rv,b1,Wl,jo,dd,iv,av,ov,w1,dN;class LMe{constructor(e,n,s,r,i,a){oe(this,w1);oe(this,Zf,new Float64Array(6));oe(this,Eo);oe(this,To);oe(this,rv);oe(this,b1);oe(this,Wl);oe(this,jo,"");oe(this,dd,0);oe(this,iv,new AR);oe(this,av);oe(this,ov);te(this,av,s),te(this,ov,r),te(this,rv,i),te(this,b1,a),[e,n]=le(this,w1,dN).call(this,e,n);const o=te(this,Eo,[NaN,NaN,NaN,NaN,e,n]);te(this,Wl,[e,n]),te(this,To,[{line:o,points:_(this,Wl)}]),_(this,Zf).set(o,0)}updateProperty(e,n){e==="stroke-width"&&te(this,b1,n)}isEmpty(){return!_(this,To)||_(this,To).length===0}isCancellable(){return _(this,Wl).length<=10}add(e,n){[e,n]=le(this,w1,dN).call(this,e,n);const[s,r,i,a]=_(this,Zf).subarray(2,6),o=e-i,l=n-a;return Math.hypot(_(this,av)*o,_(this,ov)*l)<=2?null:(_(this,Wl).push(e,n),isNaN(s)?(_(this,Zf).set([i,a,e,n],2),_(this,Eo).push(NaN,NaN,NaN,NaN,e,n),{path:{d:this.toSVGPath()}}):(isNaN(_(this,Zf)[0])&&_(this,Eo).splice(6,6),_(this,Zf).set([s,r,i,a,e,n],0),_(this,Eo).push(...En.createBezierPoints(s,r,i,a,e,n)),{path:{d:this.toSVGPath()}}))}end(e,n){const s=this.add(e,n);return s||(_(this,Wl).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,n,s,r,i){te(this,av,s),te(this,ov,r),te(this,rv,i),[e,n]=le(this,w1,dN).call(this,e,n);const a=te(this,Eo,[NaN,NaN,NaN,NaN,e,n]);te(this,Wl,[e,n]);const o=_(this,To).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),_(this,To).push({line:a,points:_(this,Wl)}),_(this,Zf).set(a,0),te(this,dd,0),this.toSVGPath(),null}getLastElement(){return _(this,To).at(-1)}setLastElement(e){return _(this,To)?(_(this,To).push(e),te(this,Eo,e.line),te(this,Wl,e.points),te(this,dd,0),{path:{d:this.toSVGPath()}}):_(this,iv).setLastElement(e)}removeLastElement(){if(!_(this,To))return _(this,iv).removeLastElement();_(this,To).pop(),te(this,jo,"");for(let e=0,n=_(this,To).length;e<n;e++){const{line:s,points:r}=_(this,To)[e];te(this,Eo,s),te(this,Wl,r),te(this,dd,0),this.toSVGPath()}return{path:{d:_(this,jo)}}}toSVGPath(){const e=En.svgRound(_(this,Eo)[4]),n=En.svgRound(_(this,Eo)[5]);if(_(this,Wl).length===2)return te(this,jo,`${_(this,jo)} M ${e} ${n} Z`),_(this,jo);if(_(this,Wl).length<=6){const r=_(this,jo).lastIndexOf("M");te(this,jo,`${_(this,jo).slice(0,r)} M ${e} ${n}`),te(this,dd,6)}if(_(this,Wl).length===4){const r=En.svgRound(_(this,Eo)[10]),i=En.svgRound(_(this,Eo)[11]);return te(this,jo,`${_(this,jo)} L ${r} ${i}`),te(this,dd,12),_(this,jo)}const s=[];_(this,dd)===0&&(s.push(`M ${e} ${n}`),te(this,dd,6));for(let r=_(this,dd),i=_(this,Eo).length;r<i;r+=6){const[a,o,l,c,h,p]=_(this,Eo).slice(r,r+6).map(En.svgRound);s.push(`C${a} ${o} ${l} ${c} ${h} ${p}`)}return te(this,jo,_(this,jo)+s.join(" ")),te(this,dd,_(this,Eo).length),_(this,jo)}getOutlines(e,n,s,r){const i=_(this,To).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),_(this,iv).build(_(this,To),e,n,s,_(this,rv),_(this,b1),r),te(this,Zf,null),te(this,Eo,null),te(this,To,null),te(this,jo,null),_(this,iv)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Zf=new WeakMap,Eo=new WeakMap,To=new WeakMap,rv=new WeakMap,b1=new WeakMap,Wl=new WeakMap,jo=new WeakMap,dd=new WeakMap,iv=new WeakMap,av=new WeakMap,ov=new WeakMap,w1=new WeakSet,dN=function(e,n){return En._normalizePoint(e,n,_(this,av),_(this,ov),_(this,rv))};var Kl,rA,iA,vu,ep,tp,_1,S1,E1,Vo,Kp,fie,pie,mie;
6893const Yj=class Yj extends En{constructor(){super(...arguments);oe(this,Vo);oe(this,Kl);oe(this,rA,0);oe(this,iA);oe(this,vu);oe(this,ep);oe(this,tp);oe(this,_1);oe(this,S1);oe(this,E1)}build(n,s,r,i,a,o,l){te(this,ep,s),te(this,tp,r),te(this,_1,i),te(this,S1,a),te(this,E1,o),te(this,iA,l??0),te(this,vu,n),le(this,Vo,pie).call(this)}setLastElement(n){return _(this,vu).push(n),{path:{d:this.toSVGPath()}}}removeLastElement(){return _(this,vu).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const n=[];for(const{line:s}of _(this,vu)){if(n.push(`M${En.svgRound(s[4])} ${En.svgRound(s[5])}`),s.length===6){n.push("Z");continue}if(s.length===12){n.push(`L${En.svgRound(s[10])} ${En.svgRound(s[11])}`);continue}for(let r=6,i=s.length;r<i;r+=6){const[a,o,l,c,h,p]=s.subarray(r,r+6).map(En.svgRound);n.push(`C${a} ${o} ${l} ${c} ${h} ${p}`)}}return n.join("")}serialize([n,s,r,i],a){const o=[],l=[],[c,h,p,m]=le(this,Vo,fie).call(this);let y,v,b,S,E,I,M,j,L;switch(_(this,S1)){case 0:L=En._rescale,y=n,v=s+i,b=r,S=-i,E=n+c*r,I=s+(1-h-m)*i,M=n+(c+p)*r,j=s+(1-h)*i;break;case 90:L=En._rescaleAndSwap,y=n,v=s,b=r,S=i,E=n+h*r,I=s+c*i,M=n+(h+m)*r,j=s+(c+p)*i;break;case 180:L=En._rescale,y=n+r,v=s,b=-r,S=i,E=n+(1-c-p)*r,I=s+h*i,M=n+(1-c)*r,j=s+(h+m)*i;break;case 270:L=En._rescaleAndSwap,y=n+r,v=s+i,b=-r,S=-i,E=n+(1-h-m)*r,I=s+(1-c-p)*i,M=n+(1-h)*r,j=s+(1-c)*i;break}for(const{line:K,points:D}of _(this,vu))o.push(L(K,y,v,b,S,a?new Array(K.length):null)),l.push(L(D,y,v,b,S,a?new Array(D.length):null));return{lines:o,points:l,rect:[E,I,M,j]}}static deserialize(n,s,r,i,a,{paths:{lines:o,points:l},rotation:c,thickness:h}){const p=[];let m,y,v,b,S;switch(c){case 0:S=En._rescale,m=-n/r,y=s/i+1,v=1/r,b=-1/i;break;case 90:S=En._rescaleAndSwap,m=-s/i,y=-n/r,v=1/i,b=1/r;break;case 180:S=En._rescale,m=n/r+1,y=-s/i,v=-1/r,b=1/i;break;case 270:S=En._rescaleAndSwap,m=s/i+1,y=n/r+1,v=-1/i,b=-1/r;break}if(!o){o=[];for(const I of l){const M=I.length;if(M===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,I[0],I[1]]));continue}if(M===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,I[0],I[1],NaN,NaN,NaN,NaN,I[2],I[3]]));continue}const j=new Float32Array(3*(M-2));o.push(j);let[L,K,D,R]=I.subarray(0,4);j.set([NaN,NaN,NaN,NaN,L,K],0);for(let B=4;B<M;B+=2){const G=I[B],X=I[B+1];j.set(En.createBezierPoints(L,K,D,R,G,X),(B-2)*3),[L,K,D,R]=[D,R,G,X]}}}for(let I=0,M=o.length;I<M;I++)p.push({line:S(o[I].map(j=>j??NaN),m,y,v,b),points:S(l[I].map(j=>j??NaN),m,y,v,b)});const E=new Yj;return E.build(p,r,i,1,c,h,a),E}get box(){return _(this,Kl)}updateProperty(n,s){return n==="stroke-width"?le(this,Vo,mie).call(this,s):null}updateParentDimensions([n,s],r){const[i,a]=le(this,Vo,Kp).call(this);te(this,ep,n),te(this,tp,s),te(this,_1,r);const[o,l]=le(this,Vo,Kp).call(this),c=o-i,h=l-a,p=_(this,Kl);return p[0]-=c,p[1]-=h,p[2]+=2*c,p[3]+=2*h,p}updateRotation(n){return te(this,rA,n),{path:{transform:this.rotationTransform}}}get viewBox(){return _(this,Kl).map(En.svgRound).join(" ")}get defaultProperties(){const[n,s]=_(this,Kl);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${En.svgRound(n)} ${En.svgRound(s)}`}}}get rotationTransform(){const[,,n,s]=_(this,Kl);let r=0,i=0,a=0,o=0,l=0,c=0;switch(_(this,rA)){case 90:i=s/n,a=-n/s,l=n;break;case 180:r=-1,o=-1,l=n,c=s;break;case 270:i=-s/n,a=n/s,c=s;break;default:return""}return`matrix(${r} ${i} ${a} ${o} ${En.svgRound(l)} ${En.svgRound(c)})`}getPathResizingSVGProperties([n,s,r,i]){const[a,o]=le(this,Vo,Kp).call(this),[l,c,h,p]=_(this,Kl);if(Math.abs(h-a)<=En.PRECISION||Math.abs(p-o)<=En.PRECISION){const S=n+r/2-(l+h/2),E=s+i/2-(c+p/2);return{path:{"transform-origin":`${En.svgRound(n)} ${En.svgRound(s)}`,transform:`${this.rotationTransform} translate(${S} ${E})`}}}const m=(r-2*a)/(h-2*a),y=(i-2*o)/(p-2*o),v=h/r,b=p/i;return{path:{"transform-origin":`${En.svgRound(l)} ${En.svgRound(c)}`,transform:`${this.rotationTransform} scale(${v} ${b}) translate(${En.svgRound(a)} ${En.svgRound(o)}) scale(${m} ${y}) translate(${En.svgRound(-a)} ${En.svgRound(-o)})`}}}getPathResizedSVGProperties([n,s,r,i]){const[a,o]=le(this,Vo,Kp).call(this),l=_(this,Kl),[c,h,p,m]=l;if(l[0]=n,l[1]=s,l[2]=r,l[3]=i,Math.abs(p-a)<=En.PRECISION||Math.abs(m-o)<=En.PRECISION){const E=n+r/2-(c+p/2),I=s+i/2-(h+m/2);for(const{line:M,points:j}of _(this,vu))En._translate(M,E,I,M),En._translate(j,E,I,j);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${En.svgRound(n)} ${En.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const y=(r-2*a)/(p-2*a),v=(i-2*o)/(m-2*o),b=-y*(c+a)+n+a,S=-v*(h+o)+s+o;if(y!==1||v!==1||b!==0||S!==0)for(const{line:E,points:I}of _(this,vu))En._rescale(E,b,S,y,v,E),En._rescale(I,b,S,y,v,I);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${En.svgRound(n)} ${En.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([n,s],r){const[i,a]=r,o=_(this,Kl),l=n-o[0],c=s-o[1];if(_(this,ep)===i&&_(this,tp)===a)for(const{line:h,points:p}of _(this,vu))En._translate(h,l,c,h),En._translate(p,l,c,p);else{const h=_(this,ep)/i,p=_(this,tp)/a;te(this,ep,i),te(this,tp,a);for(const{line:m,points:y}
6893of _(this,vu))En._rescale(m,l,c,h,p,m),En._rescale(y,l,c,h,p,y);o[2]*=h,o[3]*=p}return o[0]=n,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${En.svgRound(n)} ${En.svgRound(s)}`}}}get defaultSVGProperties(){const n=_(this,Kl);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${En.svgRound(n[0])} ${En.svgRound(n[1])}`,transform:this.rotationTransform||null},bbox:n}}};Kl=new WeakMap,rA=new WeakMap,iA=new WeakMap,vu=new WeakMap,ep=new WeakMap,tp=new WeakMap,_1=new WeakMap,S1=new WeakMap,E1=new WeakMap,Vo=new WeakSet,Kp=function(n=_(this,E1)){const s=_(this,iA)+n/2*_(this,_1);return _(this,S1)%180===0?[s/_(this,ep),s/_(this,tp)]:[s/_(this,tp),s/_(this,ep)]},fie=function(){const[n,s,r,i]=_(this,Kl),[a,o]=le(this,Vo,Kp).call(this,0);return[n+a,s+o,r-2*a,i-2*o]},pie=function(){const n=te(this,Kl,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of _(this,vu)){if(i.length<=12){for(let l=4,c=i.length;l<c;l+=6){const[h,p]=i.subarray(l,l+2);n[0]=Math.min(n[0],h),n[1]=Math.min(n[1],p),n[2]=Math.max(n[2],h),n[3]=Math.max(n[3],p)}continue}let a=i[4],o=i[5];for(let l=6,c=i.length;l<c;l+=6){const[h,p,m,y,v,b]=i.subarray(l,l+6);Gn.bezierBoundingBox(a,o,h,p,m,y,v,b,n),a=v,o=b}}const[s,r]=le(this,Vo,Kp).call(this);n[0]=Math.min(1,Math.max(0,n[0]-s)),n[1]=Math.min(1,Math.max(0,n[1]-r)),n[2]=Math.min(1,Math.max(0,n[2]+s)),n[3]=Math.min(1,Math.max(0,n[3]+r)),n[2]-=n[0],n[3]-=n[1]},mie=function(n){const[s,r]=le(this,Vo,Kp).call(this);te(this,E1,n);const[i,a]=le(this,Vo,Kp).call(this),[o,l]=[i-s,a-r],c=_(this,Kl);return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c};let AR=Yj;var T1;const Xj=class Xj extends OMe{constructor(n){super();oe(this,T1);te(this,T1,n),super.updateProperties({fill:"none",stroke:ea._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(n,s){n==="stroke-width"&&(s??(s=this["stroke-width"]),s*=_(this,T1).realScale),super.updateSVGProperty(n,s)}clone(){const n=new Xj(_(this,T1));return n.updateAll(this),n}};T1=new WeakMap;let SO=Xj;var YR,gie;const dw=class dw extends vO{constructor(n){super({...n,name:"inkEditor"});oe(this,YR);this._willKeepAspectRatio=!0}static initialize(n,s){ea.initialize(n,s),this._defaultDrawingOptions=new SO(s.viewParameters)}static getDefaultDrawingOptions(n){const s=this._defaultDrawingOptions.clone();return s.updateProperties(n),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return sr(this,"typesMap",new Map([[br.INK_THICKNESS,"stroke-width"],[br.INK_COLOR,"stroke"],[br.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(n,s,r,i,a){return new LMe(n,s,r,i,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(n,s,r,i,a,o){return AR.deserialize(n,s,r,i,a,o)}static async deserialize(n,s,r){let i=null;if(n instanceof Rj){const{data:{inkLists:o,rect:l,rotation:c,id:h,color:p,opacity:m,borderStyle:{rawWidth:y},popupRef:v},parent:{page:{pageNumber:b}}}=n;i=n={annotationType:Ws.INK,color:Array.from(p),thickness:y,opacity:m,paths:{points:o},boxes:null,pageIndex:b-1,rect:l.slice(0),rotation:c,id:h,deleted:!1,popupRef:v}}const a=await super.deserialize(n,s,r);return a.annotationElementId=n.id||null,a._initialData=i,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:n,_drawingOptions:s,parent:r}=this;s.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(n,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const n=this._currentParent;n&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:n,thickness:s,opacity:r}){this._drawingOptions=dw.getDefaultDrawingOptions({stroke:Gn.makeHexColor(...n),"stroke-width":s,"stroke-opacity":r})}serialize(n=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:r,rect:i}=this.serializeDraw(n),{_drawingOptions:{stroke:a,"stroke-opacity":o,"stroke-width":l}}=this,c={annotationType:Ws.INK,color:ea._colorManager.convert(a),opacity:o,thickness:l,paths:{lines:s,points:r},pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return n?c:this.annotationElementId&&!le(this,YR,gie).call(this,c)?null:(c.id=this.annotationElementId,c)}renderAnnotationElement(n){const{points:s,rect:r}=this.serializeDraw(!1);return n.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:s}),null}};YR=new WeakSet,gie=function(n){const{color:s,thickness:r,opacity:i,pageIndex:a}=this._initialData;
6893return this._hasBeenMoved||this._hasBeenResized||n.color.some((o,l)=>o!==s[l])||n.thickness!==r||n.opacity!==i||n.pageIndex!==a},os(dw,"_type","ink"),os(dw,"_editorType",Ws.INK),os(dw,"_defaultDrawingOptions",null);let EO=dw;var Zi,Bo,g0,vm,y0,A1,np,sp,bu,C1,Br,IS,NS,hN,AO,fN,CO,pN,yie;const eE=class eE extends ea{constructor(n){super({...n,name:"stampEditor"});oe(this,Br);oe(this,Zi,null);oe(this,Bo,null);oe(this,g0,null);oe(this,vm,null);oe(this,y0,null);oe(this,A1,"");oe(this,np,null);oe(this,sp,null);oe(this,bu,!1);oe(this,C1,!1);te(this,vm,n.bitmapUrl),te(this,y0,n.bitmapFile)}static initialize(n,s){ea.initialize(n,s)}static get supportedTypes(){return sr(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return sr(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(n){return this.supportedTypes.includes(n)}static paste(n,s){s.pasteEditor(Ws.STAMP,{bitmapFile:n.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var n;return{type:"stamp",hasAltText:!!((n=this.altTextData)!=null&&n.altText)}}static computeTelemetryFinalData(n){const s=n.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(n=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:r}=this._uiManager;if(!r)throw new Error("No ML.");if(!await r.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:a,height:o}=n||this.copyCanvas(null,null,!0).imageData,l=await r.guess({name:"altText",request:{data:i,width:a,height:o,channels:i.length/(a*o)}});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 n;_(this,Bo)&&(te(this,Zi,null),this._uiManager.imageManager.deleteId(_(this,Bo)),(n=_(this,np))==null||n.remove(),te(this,np,null),_(this,sp)&&(clearTimeout(_(this,sp)),te(this,sp,null))),super.remove()}rebuild(){if(!this.parent){_(this,Bo)&&le(this,Br,hN).call(this);return}super.rebuild(),this.div!==null&&(_(this,Bo)&&_(this,np)===null&&le(this,Br,hN).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(n){this._isDraggable=!0,n&&this.div.focus()}isEmpty(){return!(_(this,g0)||_(this,Zi)||_(this,vm)||_(this,y0)||_(this,Bo))}get isResizable(){return!0}render(){if(this.div)return this.div;let n,s;if(this.width&&(n=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),_(this,Zi)?le(this,Br,AO).call(this):le(this,Br,hN).call(this),this.width&&!this.annotationElementId){const[r,i]=this.parentDimensions;this.setAt(n*r,s*i,this.width*r,this.height*i)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;_(this,sp)!==null&&clearTimeout(_(this,sp)),te(this,sp,setTimeout(()=>{te(this,sp,null),le(this,Br,CO).call(this)},200))}copyCanvas(n,s,r=!1){var y;n||(n=224);const{width:i,height:a}=_(this,Zi),o=new S5;let l=_(this,Zi),c=i,h=a,p=null;if(s){if(i>s||a>s){const R=Math.min(s/i,s/a);c=Math.floor(i*R),h=Math.floor(a*R)}p=document.createElement("canvas");const v=p.width=Math.ceil(c*o.sx),b=p.height=Math.ceil(h*o.sy);_(this,bu)||(l=le(this,Br,fN).call(this,v,b));const S=p.getContext("2d");S.filter=this._uiManager.hcmFilter;let E="white",I="#cfcfd8";this._uiManager.hcmFilter!=="none"?I="black":(y=window.matchMedia)!=null&&y.call(window,"(prefers-color-scheme: dark)").matches&&(E="#8f8f9d",I="#42414d");const M=15,j=M*o.sx,L=M*o.sy,K=new OffscreenCanvas(j*2,L*2),D=K.getContext("2d");D.fillStyle=E,D.fillRect(0,0,j*2,L*2),D.fillStyle=I,D.fillRect(0,0,j,L),D.fillRect(j,L,j,L),S.fillStyle=S.createPattern(K,"repeat"),S.fillRect(0,0,v,b),S.drawImage(l,0,0,l.width,l.height,0,0,v,b)}let m=null;if(r){let v,b;if(o.symmetric&&l.width<n&&l.height<n)v=l.width,b=l.height;else if(l=_(this,Zi),i>n||a>
vendor: 6,964 bytes, line 6893
6893n){const I=Math.min(n/i,n/a);v=Math.floor(i*I),b=Math.floor(a*I),_(this,bu)||(l=le(this,Br,fN).call(this,v,b))}const E=new OffscreenCanvas(v,b).getContext("2d",{willReadFrequently:!0});E.drawImage(l,0,0,l.width,l.height,0,0,v,b),m={width:v,height:b,data:E.getImageData(0,0,v,b).data}}return{canvas:p,width:c,height:h,imageData:m}}getImageForAltText(){return _(this,np)}static async deserialize(n,s,r){var b;let i=null;if(n instanceof jre){const{data:{rect:S,rotation:E,id:I,structParent:M,popupRef:j},container:L,parent:{page:{pageNumber:K}}}=n,D=L.querySelector("canvas"),R=r.imageManager.getFromCanvas(L.id,D);D.remove();const B=((b=await s._structTree.getAriaAttributes(`${Sj}${I}`))==null?void 0:b.get("aria-label"))||"";i=n={annotationType:Ws.STAMP,bitmapId:R.id,bitmap:R.bitmap,pageIndex:K-1,rect:S.slice(0),rotation:E,id:I,deleted:!1,accessibilityData:{decorative:!1,altText:B},isSvg:!1,structParent:M,popupRef:j}}const a=await super.deserialize(n,s,r),{rect:o,bitmap:l,bitmapUrl:c,bitmapId:h,isSvg:p,accessibilityData:m}=n;h&&r.imageManager.isValidId(h)?(te(a,Bo,h),l&&te(a,Zi,l)):te(a,vm,c),te(a,bu,p);const[y,v]=a.pageDimensions;return a.width=(o[2]-o[0])/y,a.height=(o[3]-o[1])/v,a.annotationElementId=n.id||null,m&&(a.altTextData=m),a._initialData=i,te(a,C1,!!i),a}serialize(n=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const r={annotationType:Ws.STAMP,bitmapId:_(this,Bo),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:_(this,bu),structTreeParentId:this._structTreeParentId};if(n)return r.bitmapUrl=le(this,Br,pN).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r;const{decorative:i,altText:a}=this.serializeAltText(!1);if(!i&&a&&(r.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=le(this,Br,yie).call(this,r);if(l.isSame)return null;l.isSameAltText?delete r.accessibilityData:r.accessibilityData.structParent=this._initialData.structParent??-1}if(r.id=this.annotationElementId,s===null)return r;s.stamps||(s.stamps=new Map);const o=_(this,bu)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(!s.stamps.has(_(this,Bo)))s.stamps.set(_(this,Bo),{area:o,serialized:r}),r.bitmap=le(this,Br,pN).call(this,!1);else if(_(this,bu)){const l=s.stamps.get(_(this,Bo));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=le(this,Br,pN).call(this,!1))}return r}renderAnnotationElement(n){return n.updateEdited({rect:this.getRect(0,0)}),null}};Zi=new WeakMap,Bo=new WeakMap,g0=new WeakMap,vm=new WeakMap,y0=new WeakMap,A1=new WeakMap,np=new WeakMap,sp=new WeakMap,bu=new WeakMap,C1=new WeakMap,Br=new WeakSet,IS=function(n,s=!1){if(!n){this.remove();return}te(this,Zi,n.bitmap),s||(te(this,Bo,n.id),te(this,bu,n.isSvg)),n.file&&te(this,A1,n.file.name),le(this,Br,AO).call(this)},NS=function(){if(te(this,g0,null),this._uiManager.enableWaiting(!1),!!_(this,np)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(this,Zi)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(this,Zi)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},hN=function(){if(_(this,Bo)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(_(this,Bo)).then(r=>le(this,Br,IS).call(this,r,!0)).finally(()=>le(this,Br,NS).call(this));return}if(_(this,vm)){const r=_(this,vm);te(this,vm,null),this._uiManager.enableWaiting(!0),te(this,g0,this._uiManager.imageManager.getFromUrl(r).then(i=>le(this,Br,IS).call(this,i)).finally(()=>le(this,Br,NS).call(this)));return}if(_(this,y0)){const r=_(this,y0);te(this,y0,null),this._uiManager.enableWaiting(!0),te(this,g0,this._uiManager.imageManager.getFromFile(r).then(i=>le(this,Br,IS).call(this,i)).finally(()=>le(this,Br,NS).call(this)));return}const n=document.createElement("input");n.type="file",n.accept=eE.supportedTypesStr;const s=this._uiManager._signal;te(this,g0,new Promise(r=>{n.addEventListener("change",async()=>{if(!n.files||n.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(n.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),le(this,Br,IS).call(this,i)}r()},{signal:s}),n.addEventListener("cancel",()=>{this.remove(),r()},{signal:s})}).finally(()=>le(this,Br,NS).call(this))),n.click()},AO=function(){var p;const{div:n}=this;let{width:s,height:r}=_(this,Zi);const[i,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*i,r=this.height*a;else if(s>o*i||r>o*a){const m=Math.min(o*i/s,o*a/r);s*=m,r*=m}const[l,c]=this.parentDimensions;this.setDims(s*l/i,r*c/a),this._uiManager.enableWaiting(!1);const h=te(this,np,document.createElement("canvas"));h.setAttribute("role","img"),this.addContainer(h),this.width=s/i,this.height=r/a,(p=this._initialOptions)!=null&&p.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(n.hidden=!1),le(this,Br,CO).call(this),_(this,C1)||(this.parent.addUndoableEditor(this),te(this,C1,!0)),this._reportTelemetry({action:"inserted_image"}),_(this,A1)&&h.setAttribute("aria-label",_(this,A1))},fN=function(n,s){const{width:r,height:i}=_(this,Zi);let a=r,o=i,l=_(this,Zi);for(;a>2*n||o>2*s;){const c=a,h=o;a>2*n&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const p=new OffscreenCanvas(a,o);p.getContext("2d").drawImage(l,0,0,c,h,0,0,a,o),l=p.transferToImageBitmap()}return l},CO=function(){const[n,s]=this.parentDimensions,{width:r,height:i}=this,a=new S5,o=Math.ceil(r*n*a.sx),l=Math.ceil(i*s*a.sy),c=_(this,np);if(!c||c.width===o&&c.height===l)return;c.width=o,c.height=l;const h=_(this,bu)?_(this,Zi):le(this,Br,fN).call(this,o,l),p=c.getContext("2d");p.filter=this._uiManager.hcmFilter,p.drawImage(h,0,0,h.width,h.height,0,0,o,l)},pN=function(n){if(n){if(_(this,bu)){const i=this._uiManager.imageManager.getSvgUrl(_(this,Bo));if(i)return i}const s=document.createElement("canvas");return{width:s.width,height:s.height}=_(this,Zi),s.getContext("2d").drawImage(_(this,Zi),0,0),s.toDataURL()}if(_(this,bu)){const[s,r]=this.pageDimensions,i=Math.round(this.width*s*K0.PDF_TO_CSS_UNITS),a=Math.round(this.height*r*K0.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(i,a);return o.getContext("2d").drawImage(_(this,Zi),0,0,_(this,Zi).width,_(this,Zi).height,0,0,i,a),o.transferToImageBitmap()}return structuredClone(_(this,Zi))},yie=function(n){var o;const{pageIndex:s,accessibilityData:{altText:r}}=this._initialData,i=n.pageIndex===s,a=(((o=n.accessibilityData)==null?void 0:o.alt)||"")===r;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}}
6893,os(eE,"_type","stamp"),os(eE,"_editorType",Ws.STAMP);let TO=eE;var lv,k1,rp,x0,bm,hd,v0,I1,cv,Oh,wm,pl,_m,Fn,b0,qi,xie,Lf,IO,NO,mN;const wh=class wh{constructor({uiManager:e,pageIndex:n,div:s,structTreeLayer:r,accessibilityManager:i,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:h}){oe(this,qi);oe(this,lv);oe(this,k1,!1);oe(this,rp,null);oe(this,x0,null);oe(this,bm,null);oe(this,hd,new Map);oe(this,v0,!1);oe(this,I1,!1);oe(this,cv,!1);oe(this,Oh,null);oe(this,wm,null);oe(this,pl,null);oe(this,_m,null);oe(this,Fn);const p=[..._(wh,b0).values()];if(!wh._initialized){wh._initialized=!0;for(const m of p)m.initialize(h,e)}e.registerEditorTypes(p),te(this,Fn,e),this.pageIndex=n,this.div=s,te(this,lv,i),te(this,rp,a),this.viewport=c,te(this,pl,l),this.drawLayer=o,this._structTree=r,_(this,Fn).addLayer(this)}get isEmpty(){return _(this,hd).size===0}get isInvisible(){return this.isEmpty&&_(this,Fn).getMode()===Ws.NONE}updateToolbar(e){_(this,Fn).updateToolbar(e)}updateMode(e=_(this,Fn).getMode()){switch(le(this,qi,mN).call(this),e){case Ws.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Ws.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Ws.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:n}=this.div;for(const s of _(wh,b0).values())n.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(e){var n;return e===((n=_(this,pl))==null?void 0:n.div)}setEditingState(e){_(this,Fn).setEditingState(e)}addCommands(e){_(this,Fn).addCommands(e)}cleanUndoStack(e){_(this,Fn).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var n;(n=_(this,rp))==null||n.div.classList.toggle("disabled",!e)}async enable(){te(this,cv,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const s of _(this,hd).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(_(this,Fn).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));if(!_(this,rp)){te(this,cv,!1);return}const n=_(this,rp).getEditableAnnotations();for(const s of n){if(s.hide(),_(this,Fn).isDeletedAnnotationElement(s.data.id)||e.has(s.data.id))continue;const r=await this.deserialize(s);r&&(this.addOrRebuild(r),r.enableEditing())}te(this,cv,!1)}disable(){var r;te(this,I1,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,n=new Map;for(const i of _(this,hd).values())if(i.disableEditing(),!!i.annotationElementId){if(i.serialize()!==null){e.set(i.annotationElementId,i);continue}else n.set(i.annotationElementId,i);(r=this.getEditableAnnotation(i.annotationElementId))==null||r.show(),i.remove()}if(_(this,rp)){const i=_(this,rp).getEditableAnnotations();for(const a of i){const{id:o}=a.data;if(_(this,Fn).isDeletedAnnotationElement(o))continue;let l=n.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=e.get(o),l&&(_(this,Fn).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}le(this,qi,mN).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of _(wh,b0).values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),te(this,I1,!1)}getEditableAnnotation(e){var n;return((n=_(this,rp))==null?void 0:n.getEditableAnnotation(e))||null}setActiveEditor(e){_(this,Fn).getActive()!==e&&_(this,Fn).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=_(this,pl))!=null&&e.div&&!_(this,_m)){te(this,_m,new AbortController);const n=_(this,Fn).combinedSignal(_(this,_m));_(this,pl).div.addEventListener("pointerdown",le(this,qi,xie).bind(this),{signal:n}),_(this,pl).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=_(this,pl))!=null&&e.div&&_(this,_m)&&(_(this,_m).abort(),te(this,_m,null),_(this,pl).div.classList.remove("highlighting"))}enableClick(){if(_(this,x0))return;te(this,x0,new AbortController);const e=_(this,Fn).combinedSignal(_(this,x0));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const n=this.pointerup.bind(this);this.div.addEventListener("pointerup",n,{signal:e}),this.div.addEventListener("pointercancel",n,{signal:e})}disableClick(){var e;(e=_(this,x0))==null||e.abort(),te(this,x0,null)}attach(e){_(this,hd).set(e.id,e);const{annotationElementId:n}=e;n&&_(this,Fn).isDeletedAnnotationElement(n)&&_(this,Fn).removeDeletedAnnotationElement(e)}detach(e){var n;_(this,hd).delete(e.id),(n=_(this,lv))==null||n.removePointerInTextLayer(e.contentDiv),!_(this,I1)&&e.annotationElementId&&_(this,Fn).addDeletedAnnotationElement(e)}remove(e){this.detach(e),_(this,Fn).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var n;e.parent!==this&&(e.parent&&e.annotationElementId&&(_(this,Fn).addDeletedAnnotationElement(e.annotationElementId),ea.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(n=e.parent)==null||n.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}
6893add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),_(this,Fn).addEditor(e),this.attach(e),!e.isAttachedToDOM){const n=e.render();this.div.append(n),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!_(this,cv)),_(this,Fn).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var s;if(!e.isAttachedToDOM)return;const{activeElement:n}=document;e.div.contains(n)&&!_(this,bm)&&(e._focusEventsAllowed=!1,te(this,bm,setTimeout(()=>{te(this,bm,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:_(this,Fn)._signal}),n.focus())},0))),e._structTreeParentId=(s=_(this,lv))==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 n=()=>e._uiManager.rebuild(e),s=()=>{e.remove()};this.addCommands({cmd:n,undo:s,mustExec:!1})}getNextId(){return _(this,Fn).getId()}combinedSignal(e){return _(this,Fn).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=_(this,qi,Lf))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,n){_(this,Fn).updateToolbar(e),_(this,Fn).updateMode(e);const{offsetX:s,offsetY:r}=le(this,qi,NO).call(this),i=this.getNextId(),a=le(this,qi,IO).call(this,{parent:this,id:i,x:s,y:r,uiManager:_(this,Fn),isCentered:!0,...n});a&&this.add(a)}async deserialize(e){var n;return await((n=_(wh,b0).get(e.annotationType??e.annotationEditorType))==null?void 0:n.deserialize(e,this,_(this,Fn)))||null}createAndAddNewEditor(e,n,s={}){const r=this.getNextId(),i=le(this,qi,IO).call(this,{parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:_(this,Fn),isCentered:n,...s});return i&&this.add(i),i}addNewEditor(){this.createAndAddNewEditor(le(this,qi,NO).call(this),!0)}setSelected(e){_(this,Fn).setSelected(e)}toggleSelected(e){_(this,Fn).toggleSelected(e)}unselect(e){_(this,Fn).unselect(e)}pointerup(e){var s;const{isMac:n}=nc.platform;if(!(e.button!==0||e.ctrlKey&&n)&&e.target===this.div&&_(this,v0)&&(te(this,v0,!1),!((s=_(this,qi,Lf))!=null&&s.isDrawer&&_(this,qi,Lf).supportMultipleDrawings))){if(!_(this,k1)){te(this,k1,!0);return}if(_(this,Fn).getMode()===Ws.STAMP){_(this,Fn).unselectAll();return}this.createAndAddNewEditor(e,!1)}}pointerdown(e){var r;if(_(this,Fn).getMode()===Ws.HIGHLIGHT&&this.enableTextSelection(),_(this,v0)){te(this,v0,!1);return}const{isMac:n}=nc.platform;if(e.button!==0||e.ctrlKey&&n||e.target!==this.div)return;if(te(this,v0,!0),(r=_(this,qi,Lf))!=null&&r.isDrawer){this.startDrawingSession(e);return}const s=_(this,Fn).getActive();te(this,k1,!s||s.isEmpty())}startDrawingSession(e){if(this.div.focus(),_(this,Oh)){_(this,qi,Lf).startDrawing(this,_(this,Fn),!1,e);return}_(this,Fn).setCurrentDrawingSession(this),te(this,Oh,new AbortController);const n=_(this,Fn).combinedSignal(_(this,Oh));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(te(this,wm,null),this.commitOrRemove())},{signal:n}),_(this,qi,Lf).startDrawing(this,_(this,Fn),!1,e)}pause(e){if(e){const{activeElement:n}=document;this.div.contains(n)&&te(this,wm,n);return}_(this,wm)&&setTimeout(()=>{var n;(n=_(this,wm))==null||n.focus(),te(this,wm,null)},0)}endDrawingSession(e=!1){return _(this,Oh)?(_(this,Fn).setCurrentDrawingSession(null),_(this,Oh).abort(),te(this,Oh,null),te(this,wm,null),_(this,qi,Lf).endDrawing(e)):null}findNewParent(e,n,s){const r=_(this,Fn).findParent(n,s);return r===null||r===this?!1:(r.changeParent(e),!0)}commitOrRemove(){return _(this,Oh)?(this.endDrawingSession(),!0):!1}onScaleChanging(){_(this,Oh)&&_(this,qi,Lf).onScaleChangingWhenDrawing(this)}destroy(){var e,n;this.commitOrRemove(),((e=_(this,Fn).getActive())==null?void 0:e.parent)===this&&(_(this,Fn).commitOrRemove(),_(this,Fn).setActiveEditor(null)),_(this,bm)&&(clearTimeout(_(this,bm)),te(this,bm,null));for(const s of _(this,hd).values())(n=_(this,lv))==null||n.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,_(this,hd).clear(),_(this,Fn).removeLayer(this)}render({viewport:e}){this.viewport=e,$v(this.div,e);for(const n of _(this,Fn).getEditors(this.pageIndex))this.add(n),n.rebuild();this.updateMode()}update({viewport:e}){_(this,Fn).commitOrRemove(),le(this,qi,mN).call(this);const n=this.viewport.rotation,s=e.rotation;if(this.viewport=e,$v(this.div,{rotation:s}),n!==s)for(const r of _(this,hd).values())r.rotate(s)}get pageDimensions(){const{pageWidth:e,pageHeight:n}=this.viewport.rawDims;return[e,n]}get scale(){return _(this,Fn).viewParameters.realScale}};lv=new WeakMap,k1=new WeakMap,rp=new WeakMap,x0=new WeakMap,bm=new WeakMap,hd=new WeakMap,v0=new WeakMap,I1=new WeakMap,cv=new WeakMap,Oh=new WeakMap,wm=new WeakMap,pl=new WeakMap,_m=new WeakMap,Fn=new WeakMap,b0=new WeakMap,qi=new WeakSet,xie=function(e){_(this,Fn).unselectAll();const{target:n}=e;if(n===_(this,pl).div||(n.getAttribute("role")==="img"||n.classList.contains("endOfContent"))&&_(this,pl).div.contains(n)){const{isMac:s}=nc.platform;if(e.button!==0||e.ctrlKey&&s)return;_(this,Fn).showAllEditors("highlight",!0,!0),_(this,pl).div.classList.add("free"),this.toggleDrawing(),TR.startHighlighting(this,_(this,Fn).direction==="ltr",{target:_(this,pl).div,x:e.x,y:e.y}),_(this,pl).div.addEventListener("pointerup",()=>{_(this,pl).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:_(this,Fn)._signal}),e.preventDefault()}},Lf=function(){return _(wh,b0).get(_(this,Fn).getMode())},IO=function(e){const n=_(this,qi,Lf);return n?new n.prototype.constructor(e):null},NO=function(){const{x:e,y:n,width:s,height:r}=this.div.getBoundingClientRect(),i=Math.max(0,e),a=Math.max(0,n),o=Math.min(window.innerWidth,e+s),l=Math.min(window.innerHeight,n+r),c=(i+o)/2-e,h=(a+l)/2-n,[p,m]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:p,offsetY:m}}
6893,mN=function(){for(const e of _(this,hd).values())e.isEmpty()&&e.remove()},os(wh,"_initialized",!1),oe(wh,b0,new Map([cO,EO,TO,TR].map(e=>[e._editorType,e])));let kO=wh;var Lh,aA,Yl,uv,XR,vie,xp,MO,bie,PO;const ul=class ul{constructor({pageIndex:e}){oe(this,xp);oe(this,Lh,null);oe(this,aA,0);oe(this,Yl,new Map);oe(this,uv,new Map);this.pageIndex=e}setParent(e){if(!_(this,Lh)){te(this,Lh,e);return}if(_(this,Lh)!==e){if(_(this,Yl).size>0)for(const n of _(this,Yl).values())n.remove(),e.append(n);te(this,Lh,e)}}static get _svgFactory(){return sr(this,"_svgFactory",new Nj)}draw(e,n=!1,s=!1){const r=Vl(this,aA)._++,i=le(this,xp,MO).call(this),a=ul._svgFactory.createElement("defs");i.append(a);const o=ul._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${r}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),n&&_(this,uv).set(r,o);const c=s?le(this,xp,bie).call(this,a,l):null,h=ul._svgFactory.createElement("use");return i.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(i,e),_(this,Yl).set(r,i),{id:r,clipPathId:`url(#${c})`}}drawOutline(e,n){const s=Vl(this,aA)._++,r=le(this,xp,MO).call(this),i=ul._svgFactory.createElement("defs");r.append(i);const a=ul._svgFactory.createElement("path");i.append(a);const o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(n){const p=ul._svgFactory.createElement("mask");i.append(p),l=`mask_p${this.pageIndex}_${s}`,p.setAttribute("id",l),p.setAttribute("maskUnits","objectBoundingBox");const m=ul._svgFactory.createElement("rect");p.append(m),m.setAttribute("width","1"),m.setAttribute("height","1"),m.setAttribute("fill","white");const y=ul._svgFactory.createElement("use");p.append(y),y.setAttribute("href",`#${o}`),y.setAttribute("stroke","none"),y.setAttribute("fill","black"),y.setAttribute("fill-rule","nonzero"),y.classList.add("mask")}const c=ul._svgFactory.createElement("use");r.append(c),c.setAttribute("href",`#${o}`),l&&c.setAttribute("mask",`url(#${l})`);const h=c.cloneNode();return r.append(h),c.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(r,e),_(this,Yl).set(s,r),s}finalizeDraw(e,n){_(this,uv).delete(e),this.updateProperties(e,n)}updateProperties(e,n){var l;if(!n)return;const{root:s,bbox:r,rootClass:i,path:a}=n,o=typeof e=="number"?_(this,Yl).get(e):e;if(o){if(s&&le(this,xp,PO).call(this,o,s),r&&le(l=ul,XR,vie).call(l,o,r),i){const{classList:c}=o;for(const[h,p]of Object.entries(i))c.toggle(h,p)}if(a){const h=o.firstChild.firstChild;le(this,xp,PO).call(this,h,a)}}}updateParent(e,n){if(n===this)return;const s=_(this,Yl).get(e);s&&(_(n,Lh).append(s),_(this,Yl).delete(e),_(n,Yl).set(e,s))}remove(e){_(this,uv).delete(e),_(this,Lh)!==null&&(_(this,Yl).get(e).remove(),_(this,Yl).delete(e))}destroy(){te(this,Lh,null);for(const e of _(this,Yl).values())e.remove();_(this,Yl).clear(),_(this,uv).clear()}};Lh=new WeakMap,aA=new WeakMap,Yl=new WeakMap,uv=new WeakMap,XR=new WeakSet,vie=function(e,[n,s,r,i]){const{style:a}=e;a.top=`${100*s}%`,a.left=`${100*n}%`,a.width=`${100*r}%`,a.height=`${100*i}%`},xp=new WeakSet,MO=function(){const e=ul._svgFactory.create(1,1,!0);return _(this,Lh).append(e),e.setAttribute("aria-hidden",!0),e},bie=function(e,n){const s=ul._svgFactory.createElement("clipPath");e.append(s);const r=`clip_${n}`;s.setAttribute("id",r),s.setAttribute("clipPathUnits","objectBoundingBox");const i=ul._svgFactory.createElement("use");return s.append(i),i.setAttribute("href",`#${n}`),i.classList.add("clip"),r},PO=function(e,n){for(const[s,r]of Object.entries(n))r===null?e.removeAttribute(s):e.setAttribute(s,r)},oe(ul,XR);let RO=ul;globalThis.pdfjsTestingUtils={HighlightOutliner:dO};Ms.AbortException;Ms.AnnotationEditorLayer;Ms.AnnotationEditorParamsType;Ms.AnnotationEditorType;Ms.AnnotationEditorUIManager;Ms.AnnotationLayer;Ms.AnnotationMode;Ms.ColorPicker;Ms.DOMSVGFactory;Ms.DrawLayer;Ms.FeatureTest;var jMe=Ms.GlobalWorkerOptions;Ms.ImageKind;Ms.InvalidPDFException;Ms.MissingPDFException;Ms.OPS;Ms.OutputScale;Ms.PDFDataRangeTransport;Ms.PDFDateString;Ms.PDFWorker;Ms.PasswordResponses;Ms.PermissionFlag;Ms.PixelsPerInch;Ms.RenderingCancelledException;Ms.TextLayer;Ms.TouchManager;Ms.UnexpectedResponseException;Ms.Util;Ms.VerbosityLevel;Ms.XfaLayer;Ms.build;Ms.createValidAbsoluteUrl;Ms.fetchData;var BMe=Ms.getDocument;Ms.getFilenameFromUrl;Ms.getPdfFilenameFromUrl;Ms.getXfaPageViewport;Ms.isDataScheme;Ms.isPdfFile;Ms.noContextMenu;Ms.normalizeUnicode;Ms.setLayerDimensions;Ms.shadow;Ms.stopEvent;Ms.version;jMe.workerSrc="https://cdn.jsdelivr.net/npm/[email protected]/build/pdf.worker.min.mjs";const UMe=t=>{let e="";const n=t.byteLength;for(let s=0;s<n;s++)e+=String.fromCharCode(t[s]);return window.btoa(e)},FMe=(t,e)=>new Promise((n,s)=>{const r=new Image;r.onload=()=>{let i=r.width,a=r.height;if(i<=e&&a<=e){n(t);return}i>a?i>e&&(a=Math.round(a*e/i),i=e):a>e&&(i=Math.round(i*e/a),a=e);const o=document.createElement("canvas");o.width=i,o.height=a;const l=o.getContext("2d");if(!l){s(new Error("Canvas context missing"));return}l.fillStyle="#FFFFFF",l.fillRect(0,0,i,a),l.drawImage(r,0,0,i,a),n(o.toDataURL("image/jpeg",.85).split(",")[1])},r.onerror=i=>s(new Error("Failed to load image for resizing")),r.src=`data:image/jpeg;base64,${t}`}),hq=t=>
6893new Promise((e,n)=>{const s=new FileReader;s.readAsDataURL(t),s.onload=()=>{const i=s.result.split(",")[1];e(i)},s.onerror=r=>n(r)}),VMe=(t,e=300)=>new Promise((n,s)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=i=>{var o;const a=new Image;a.src=(o=i.target)==null?void 0:o.result,a.onload=()=>{let l=a.width,c=a.height;l>c?l>e&&(c=Math.round(c*e/l),l=e):c>e&&(l=Math.round(l*e/c),c=e);const h=document.createElement("canvas");h.width=l,h.height=c;const p=h.getContext("2d");if(!p){s(new Error("Canvas context missing"));return}p.fillStyle="#FFFFFF",p.fillRect(0,0,l,c),p.drawImage(a,0,0,l,c);const m=h.toDataURL("image/jpeg",.85);n(m.split(",")[1])},a.onerror=l=>s(l)},r.onerror=i=>s(i)});let ol=null,fq=!1;const pq=async(t,e=300)=>{if(fq)throw new Error("EPS renderer is unavailable (failed to load).");if(!ol)try{const o=await Fne(()=>import("./gs-C3r8Lwi2.js"),[]),l=o.default||o,c=["https://unpkg.com/@okathira/[email protected]/dist/gs.wasm","https://cdn.jsdelivr.net/npm/@okathira/[email protected]/dist/gs.wasm","https://cdn.jsdelivr.net/npm/@okathira/[email protected]/gs.wasm"];let h=null,p="";for(const m of c)try{const y=await fetch(m);if(y.ok){h=await y.arrayBuffer(),p=m;break}}catch(y){console.warn(`Attempt to fetch WASM from ${m} failed`,y)}if(!h)throw new Error("Failed to fetch WASM binary from all candidates (404/Network Error)");ol=await l({wasmBinary:h,locateFile:m=>m.endsWith(".wasm")?p:m,print:m=>console.log("[GhostPDL]",m),printErr:m=>console.warn("[GhostPDL Err]",m)})}catch(o){throw console.error("Failed to load ghostpdl-wasm",o),fq=!0,new Error("Could not load EPS renderer module")}const n=await t.arrayBuffer(),s=new Uint8Array(n),r=Math.random().toString(36).substr(2,9),i=`input_${r}.eps`,a=`output_${r}.jpg`;try{if(!ol.FS)throw new Error("GhostPDL FS not initialized");ol.FS.writeFile(i,s);const o=["-sDEVICE=jpeg","-o",a,"-dEPSCrop","-r72","-dTextAlphaBits=4","-dGraphicsAlphaBits=4","-dSAFER","-dBATCH","-dNOPAUSE",i];ol.callMain(o);let l;try{l=ol.FS.readFile(a)}catch{throw new Error("Failed to read output file from GhostPDL")}try{ol.FS.unlink(i)}catch{}try{ol.FS.unlink(a)}catch{}const c=UMe(l);return await FMe(c,e)}catch(o){try{ol!=null&&ol.FS&&ol.FS.unlink(i)}catch{}try{ol!=null&&ol.FS&&ol.FS.unlink(a)}catch{}throw console.warn("GhostPDL Rasterization error",o),o}},mq=async(t,e=300)=>{try{const n=await t.arrayBuffer(),i=await(await BMe({data:n,cMapUrl:"https://cdn.jsdelivr.net/npm/[email protected]/cmaps/",cMapPacked:!0}).promise).getPage(1),a=i.getViewport({scale:1}),o=Math.min(e/a.width,e/a.height,1.5),l=i.getViewport({scale:o<.1?.1:o}),c=document.createElement("canvas"),h=c.getContext("2d");if(!h)throw new Error("Canvas context unavailable");c.height=l.height,c.width=l.width,await i.render({canvasContext:h,viewport:l}).promise;const p=c.toDataURL("image/jpeg",.85);return c.remove(),p.split(",")[1]}catch(n){throw console.error("Error rasterizing AI file:",n),new Error("Failed to process .AI file. Please ensure it is saved with 'Create PDF Compatible File' enabled.")}},zMe=(t,e=300)=>new Promise((n,s)=>{const r=URL.createObjectURL(t),i=new Image;i.onload=()=>{const a=document.createElement("canvas");let o=i.width||e,l=i.height||e;o>l?o>e&&(l=l*(e/o),o=e):l>e&&(o=o*(e/l),l=e),a.width=o,a.height=l;const c=a.getContext("2d");if(!c){URL.revokeObjectURL(r),s(new Error("Canvas context failed"));return}c.fillStyle="#FFFFFF",c.fillRect(0,0,o,l);try{c.drawImage(i,0,0,o,l);const h=a.toDataURL("image/jpeg",.9);n(h.split(",")[1])}catch(h){s(h)}finally{URL.revokeObjectURL(r)}},i.onerror=a=>{URL.revokeObjectURL(r),s(new Error("Failed to load SVG for rasterization"))},i.src=r}),gq=async(t,e=3,n=300)=>{const s=document.createElement("video");s.preload="metadata",s.muted=!0,s.playsInline=!0;const r=URL.createObjectURL(t);return s.src=r,new Promise((i,a)=>{s.onloadedmetadata=async()=>{const o=s.duration,l=[],c=document.createElement("canvas"),h=c.getContext("2d");if(!h){URL.revokeObjectURL(r),a(new Error("Could not create canvas context"));return}let p=s.videoWidth,m=s.videoHeight;p>m?p>n&&(m*=n/p,p=n):m>n&&(p*=n/m,m=n),c.width=p,c.height=m;const y=[];if(o>0)if(e===1)y.push(Math.min(o,1));else{const v=1/(e+1);for(let b=1;b<=e;b++)y.push(o*(v*b))}else y.push(0);try{for(const v of y){s.currentTime=v,await new Promise(S=>{const E=()=>{s.removeEventListener("seeked",E),S()};s.addEventListener("seeked",E)}),h.drawImage(s,0,0,p,m);const b=c.toDataURL("image/jpeg",.8);l.push(b.split(",")[1])}URL.revokeObjectURL(r),i(l)}catch(v){URL.revokeObjectURL(r),a(v)}},s.onerror=()=>{URL.revokeObjectURL(r),a(new Error("Error loading video"))}})},GMe=t=>t.type.startsWith("video/")?"video":t.type==="image/svg+xml"||t.type.includes("postscript")||t.type.includes("illustrator")||t.name.toLowerCase().endsWith(".ai")||t.name.toLowerCase().endsWith(".eps")?"vector":"image";/**
6894 * @license
6895 * Copyright 2025 Google LLC
6896 * SPDX-License-Identifier: Apache-2.0
6897 */let HMe,qMe;function WMe(){return{geminiUrl:HMe,vertexUrl:qMe}}function KMe(t,e,n,s){var r,i;if(!(t!=null&&t.baseUrl)){const a=WMe();return e?(r=a.vertexUrl)!==null&&r!==void 0?r:n:(i=a.geminiUrl)!==null&&i!==void 0?i:s}return t.baseUrl}/**
6898 * @license
6899 * Copyright 2025 Google LLC
6900 * SPDX-License-Identifier: Apache-2.0
6901 */class Gm{}function cn(t,e){const n=/\{([^}]+)\}/g;return t.replace(n,(s,r)=>{if(Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];return i!=null?String(i):""}else throw new Error(`Key '${r}' not found in valueMap.`)})}function k(t,e,n){for(let i=0;i<e.length-1;i++){const a=e[i];if(a.endsWith("[]")){const o=a.slice(0,-2);if(!(o in t))if(Array.isArray(n))t[o]=Array.from({length:n.length},()=>({}));else throw new Error(`Value must be a list given an array path ${a}`);if(Array.isArray(t[o])){const l=t[o];if(Array.isArray(n))for(let c=0;c<l.length;c++){const h=l[c];k(h,e.slice(i+1),n[c])}else for(const c of l)k(c,e.slice(i+1),n)}return}else if(a.endsWith("[0]")){const o=a.slice(0,-3);o in t||(t[o]=[{}]);const l=t[o];k(l[0],e.slice(i+1),n);return}(!t[a]||typeof t[a]!="object")&&(t[a]={}),t=t[a]}const s=e[e.length-1],r=t[s];if(r!==void 0){if(!n||typeof n=="object"&&Object.keys(n).length===0||n===r)return;if(typeof r=="object"&&typeof n=="object"&&r!==null&&n!==null)Object.assign(r,n);else throw new Error(`Cannot set value for an existing key. Key: ${s}`)}else s==="_self"&&typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.assign(t,n):t[s]=n}function T(t,e,n=void 0){try{if(e.length===1&&e[0]==="_self")return t;for(let s=0;s<e.length;s++){if(typeof t!="object"||t===null)return n;const r=e[s];if(r.endsWith("[]")){const i=r.slice(0,-2);if(i in t){const a=t[i];return Array.isArray(a)?a.map(o=>T(o,e.slice(s+1),n)):n}else return n}else t=t[r]}return t}catch(s){if(s instanceof TypeError)return n;throw s}}function YMe(t,e){for(const[n,s]of Object.entries(e)){const r=n.split("."),i=s.split("."),a=new Set;let o=-1;for(let l=0;l<r.length;l++)if(r[l]==="*"){o=l;break}if(o!==-1&&i.length>o)for(let l=o;l<i.length;l++){const c=i[l];c!=="*"&&!c.endsWith("[]")&&!c.endsWith("[0]")&&a.add(c)}$O(t,r,i,0,a)}}function $O(t,e,n,s,r){if(s>=e.length||typeof t!="object"||t===null)return;const i=e[s];if(i.endsWith("[]")){const a=i.slice(0,-2),o=t;if(a in o&&Array.isArray(o[a]))for(const l of o[a])$O(l,e,n,s+1,r)}else if(i==="*"){if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const a=t,o=Object.keys(a).filter(c=>!c.startsWith("_")&&!r.has(c)),l={};for(const c of o)l[c]=a[c];for(const[c,h]of Object.entries(l)){const p=[];for(const m of n.slice(s))m==="*"?p.push(c):p.push(m);k(a,p,h)}for(const c of o)delete a[c]}}else{const a=t;i in a&&$O(a[i],e,n,s+1,r)}}/**
6902 * @license
6903 * Copyright 2025 Google LLC
6904 * SPDX-License-Identifier: Apache-2.0
6905 */function Mj(t){if(typeof t!="string")throw new Error("fromImageBytes must be a string");return t}/**
6906 * @license
6907 * Copyright 2025 Google LLC
6908 * SPDX-License-Identifier: Apache-2.0
6909 */function XMe(t){const e={},n=T(t,["operationName"]);n!=null&&k(e,["operationName"],n);const s=T(t,["resourceName"]);return s!=null&&k(e,["_url","resourceName"],s),e}function JMe(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata"]);s!=null&&k(e,["metadata"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["response","generateVideoResponse"]);return a!=null&&k(e,["response"],ZMe(a)),e}function QMe(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata"]);s!=null&&k(e,["metadata"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["response"]);return a!=null&&k(e,["response"],ePe(a)),e}function ZMe(t){const e={},n=T(t,["generatedSamples"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(a=>tPe(a))),k(e,["generatedVideos"],i)}const s=T(t,["raiMediaFilteredCount"]);s!=null&&k(e,["raiMediaFilteredCount"],s);const r=T(t,["raiMediaFilteredReasons"]);return r!=null&&k(e,["raiMediaFilteredReasons"],r),e}function ePe(t){const e={},n=T(t,["videos"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(a=>nPe(a))),k(e,["generatedVideos"],i)}const s=T(t,["raiMediaFilteredCount"]);s!=null&&k(e,["raiMediaFilteredCount"],s);const r=T(t,["raiMediaFilteredReasons"]);return r!=null&&k(e,["raiMediaFilteredReasons"],r),e}function tPe(t){const e={},n=T(t,["video"]);return n!=null&&k(e,["video"],lPe(n)),e}function nPe(t){const e={},n=T(t,["_self"]);return n!=null&&k(e,["video"],cPe(n)),e}function sPe(t){const e={},n=T(t,["operationName"]);return n!=null&&k(e,["_url","operationName"],n),e}
6909function rPe(t){const e={},n=T(t,["operationName"]);return n!=null&&k(e,["_url","operationName"],n),e}function iPe(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata"]);s!=null&&k(e,["metadata"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["response"]);return a!=null&&k(e,["response"],aPe(a)),e}function aPe(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["parent"]);s!=null&&k(e,["parent"],s);const r=T(t,["documentName"]);return r!=null&&k(e,["documentName"],r),e}function wie(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata"]);s!=null&&k(e,["metadata"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["response"]);return a!=null&&k(e,["response"],oPe(a)),e}function oPe(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["parent"]);s!=null&&k(e,["parent"],s);const r=T(t,["documentName"]);return r!=null&&k(e,["documentName"],r),e}function lPe(t){const e={},n=T(t,["uri"]);n!=null&&k(e,["uri"],n);const s=T(t,["encodedVideo"]);s!=null&&k(e,["videoBytes"],Mj(s));const r=T(t,["encoding"]);return r!=null&&k(e,["mimeType"],r),e}function cPe(t){const e={},n=T(t,["gcsUri"]);n!=null&&k(e,["uri"],n);const s=T(t,["bytesBase64Encoded"]);s!=null&&k(e,["videoBytes"],Mj(s));const r=T(t,["mimeType"]);return r!=null&&k(e,["mimeType"],r),e}/**
6910 * @license
6911 * Copyright 2025 Google LLC
6912 * SPDX-License-Identifier: Apache-2.0
6913 */var yq;(function(t){t.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",t.OUTCOME_OK="OUTCOME_OK",t.OUTCOME_FAILED="OUTCOME_FAILED",t.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(yq||(yq={}));var xq;(function(t){t.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",t.PYTHON="PYTHON"})(xq||(xq={}));var vq;(function(t){t.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",t.SILENT="SILENT",t.WHEN_IDLE="WHEN_IDLE",t.INTERRUPT="INTERRUPT"})(vq||(vq={}));var Ei;(function(t){t.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",t.STRING="STRING",t.NUMBER="NUMBER",t.INTEGER="INTEGER",t.BOOLEAN="BOOLEAN",t.ARRAY="ARRAY",t.OBJECT="OBJECT",t.NULL="NULL"})(Ei||(Ei={}));var bq;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(bq||(bq={}));var wq;(function(t){t.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",t.SIMPLE_SEARCH="SIMPLE_SEARCH",t.ELASTIC_SEARCH="ELASTIC_SEARCH"})(wq||(wq={}));var _q;(function(t){t.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",t.NO_AUTH="NO_AUTH",t.API_KEY_AUTH="API_KEY_AUTH",t.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",t.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",t.OAUTH="OAUTH",t.OIDC_AUTH="OIDC_AUTH"})(_q||(_q={}));var Sq;(function(t){t.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",t.HTTP_IN_QUERY="HTTP_IN_QUERY",t.HTTP_IN_HEADER="HTTP_IN_HEADER",t.HTTP_IN_PATH="HTTP_IN_PATH",t.HTTP_IN_BODY="HTTP_IN_BODY",t.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(Sq||(Sq={}));var Eq;(function(t){t.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",t.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",t.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",t.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(Eq||(Eq={}));var Tq;(function(t){t.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",t.LOW="LOW",t.HIGH="HIGH"})(Tq||(Tq={}));var Aq;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",t.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",t.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",t.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",t.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(Aq||(Aq={}));var Cq;(function(t){t.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",t.SEVERITY="SEVERITY",t.PROBABILITY="PROBABILITY"})(Cq||(Cq={}));var kq;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE",t.OFF="OFF"})(kq||(kq={}));var Iq;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.OTHER="OTHER",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.IMAGE_SAFETY="IMAGE_SAFETY",t.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",t.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",t.NO_IMAGE="NO_IMAGE"})(Iq||(Iq={}));var Nq;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(Nq||(Nq={}));var Rq;(function(t){t.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",t.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",t.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",t.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",t.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Rq||(Rq={}));var Mq;(function(t){t.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",t.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",t.U
6913RL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",t.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",t.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(Mq||(Mq={}));var Pq;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.IMAGE_SAFETY="IMAGE_SAFETY",t.MODEL_ARMOR="MODEL_ARMOR",t.JAILBREAK="JAILBREAK"})(Pq||(Pq={}));var $q;(function(t){t.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",t.ON_DEMAND="ON_DEMAND",t.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})($q||($q={}));var CR;(function(t){t.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",t.TEXT="TEXT",t.IMAGE="IMAGE",t.AUDIO="AUDIO"})(CR||(CR={}));var Dq;(function(t){t.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",t.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",t.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",t.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Dq||(Dq={}));var Oq;(function(t){t.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",t.TUNING_MODE_FULL="TUNING_MODE_FULL",t.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Oq||(Oq={}));var Lq;(function(t){t.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",t.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",t.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",t.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",t.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",t.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",t.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Lq||(Lq={}));var DO;(function(t){t.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",t.JOB_STATE_QUEUED="JOB_STATE_QUEUED",t.JOB_STATE_PENDING="JOB_STATE_PENDING",t.JOB_STATE_RUNNING="JOB_STATE_RUNNING",t.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",t.JOB_STATE_FAILED="JOB_STATE_FAILED",t.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",t.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",t.JOB_STATE_PAUSED="JOB_STATE_PAUSED",t.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",t.JOB_STATE_UPDATING="JOB_STATE_UPDATING",t.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(DO||(DO={}));var jq;(function(t){t.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",t.TUNING_TASK_I2V="TUNING_TASK_I2V",t.TUNING_TASK_T2V="TUNING_TASK_T2V",t.TUNING_TASK_R2V="TUNING_TASK_R2V"})(jq||(jq={}));var Bq;(function(t){t.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",t.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",t.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",t.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Bq||(Bq={}));var Uq;(function(t){t.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",t.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",t.BALANCED="BALANCED",t.PRIORITIZE_COST="PRIORITIZE_COST"})(Uq||(Uq={}));var Fq;(function(t){t.UNSPECIFIED="UNSPECIFIED",t.BLOCKING="BLOCKING",t.NON_BLOCKING="NON_BLOCKING"})(Fq||(Fq={}));var Vq;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(Vq||(Vq={}));var zq;(function(t){t.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",t.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(zq||(zq={}));var Gq;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE",t.VALIDATED="VALIDATED"})(Gq||(Gq={}));var Hq;(function(t){t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(Hq||(Hq={}));var qq;(function(t){t.DONT_ALLOW="DONT_ALLOW",t.ALLOW_ADULT="ALLOW_ADULT",t.ALLOW_ALL="ALLOW_ALL"})(qq||(qq={}));var Wq;(function(t){t.auto="auto",t.en="en",t.ja="ja",t.ko="ko",t.hi="hi",t.zh="zh",t.pt="pt",t.es="es"})(Wq||(Wq={}));var Kq;(function(t){t.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",t.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",t.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",t.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",t.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(Kq||(Kq={}));var Yq;(function(t){t.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",t.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",t.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",t.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Yq||(Yq={}));var Xq;(function(t){t.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",t.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",t.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",t.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Xq||(Xq={}));var Jq;(function(t){t.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",t.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",t.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",t.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",t.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",t.EDIT_MODE_STYLE="EDIT_MODE_STYLE",t.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",t.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(Jq||(Jq={}));var Qq;(function(t){t.FOREGROUND="FOREGROUND",t.BACKGROUND="BACKGROUND",t.PROMPT="PROMPT",t.
6913SEMANTIC="SEMANTIC",t.INTERACTIVE="INTERACTIVE"})(Qq||(Qq={}));var Zq;(function(t){t.ASSET="ASSET",t.STYLE="STYLE"})(Zq||(Zq={}));var eW;(function(t){t.INSERT="INSERT",t.REMOVE="REMOVE",t.REMOVE_STATIC="REMOVE_STATIC",t.OUTPAINT="OUTPAINT"})(eW||(eW={}));var tW;(function(t){t.OPTIMIZED="OPTIMIZED",t.LOSSLESS="LOSSLESS"})(tW||(tW={}));var nW;(function(t){t.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",t.PREFERENCE_TUNING="PREFERENCE_TUNING"})(nW||(nW={}));var sW;(function(t){t.STATE_UNSPECIFIED="STATE_UNSPECIFIED",t.STATE_PENDING="STATE_PENDING",t.STATE_ACTIVE="STATE_ACTIVE",t.STATE_FAILED="STATE_FAILED"})(sW||(sW={}));var rW;(function(t){t.STATE_UNSPECIFIED="STATE_UNSPECIFIED",t.PROCESSING="PROCESSING",t.ACTIVE="ACTIVE",t.FAILED="FAILED"})(rW||(rW={}));var iW;(function(t){t.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",t.UPLOADED="UPLOADED",t.GENERATED="GENERATED"})(iW||(iW={}));var aW;(function(t){t.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.RESPONSE_REJECTED="RESPONSE_REJECTED",t.NEED_MORE_INPUT="NEED_MORE_INPUT"})(aW||(aW={}));var oW;(function(t){t.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",t.TEXT="TEXT",t.IMAGE="IMAGE",t.VIDEO="VIDEO",t.AUDIO="AUDIO",t.DOCUMENT="DOCUMENT"})(oW||(oW={}));var lW;(function(t){t.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",t.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",t.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(lW||(lW={}));var cW;(function(t){t.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",t.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",t.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(cW||(cW={}));var uW;(function(t){t.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",t.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",t.NO_INTERRUPTION="NO_INTERRUPTION"})(uW||(uW={}));var dW;(function(t){t.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",t.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",t.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(dW||(dW={}));var hW;(function(t){t.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",t.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",t.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",t.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",t.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",t.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",t.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",t.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",t.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",t.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",t.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",t.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",t.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(hW||(hW={}));var fW;(function(t){t.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",t.QUALITY="QUALITY",t.DIVERSITY="DIVERSITY",t.VOCALIZATION="VOCALIZATION"})(fW||(fW={}));var cw;(function(t){t.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",t.PLAY="PLAY",t.PAUSE="PAUSE",t.STOP="STOP",t.RESET_CONTEXT="RESET_CONTEXT"})(cw||(cw={}));class OO{constructor(e){const n={};for(const s of e.headers.entries())n[s[0]]=s[1];this.headers=n,this.responseInternal=e}json(){return this.responseInternal.json()}}class sS{get text(){var e,n,s,r,i,a,o,l;if(((r=(s=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let c="",h=!1;const p=[];for(const m of(l=(o=(a=(i=this.candidates)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.content)===null||o===void 0?void 0:o.parts)!==null&&l!==void 0?l:[]){for(const[y,v]of Object.entries(m))y!=="text"&&y!=="thought"&&y!=="thoughtSignature"&&(v!==null||v!==void 0)&&p.push(y);if(typeof m.text=="string"){if(typeof m.thought=="boolean"&&m.thought)continue;h=!0,c+=m.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),h?c:void 0}get data(){var e,n,s,r,i,a,o,l;if(((r=(s=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let c="";const h=[];for(const p of(l=(o=(a=(i=this.candidates)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.content)===null||o===void 0?void 0:o.parts)!==null&&l!==void 0?l:[]){for(const[m,y]of Object.entries(p))m!=="inlineData"&&(y!==null||y!==void 0)&&h.push(m);
6913p.inlineData&&typeof p.inlineData.data=="string"&&(c+=atob(p.inlineData.data))}return h.length>0&&console.warn(`there are non-data parts ${h} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),c.length>0?btoa(c):void 0}get functionCalls(){var e,n,s,r,i,a,o,l;if(((r=(s=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const c=(l=(o=(a=(i=this.candidates)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.content)===null||o===void 0?void 0:o.parts)===null||l===void 0?void 0:l.filter(h=>h.functionCall).map(h=>h.functionCall).filter(h=>h!==void 0);if((c==null?void 0:c.length)!==0)return c}get executableCode(){var e,n,s,r,i,a,o,l,c;if(((r=(s=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const h=(l=(o=(a=(i=this.candidates)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.content)===null||o===void 0?void 0:o.parts)===null||l===void 0?void 0:l.filter(p=>p.executableCode).map(p=>p.executableCode).filter(p=>p!==void 0);if((h==null?void 0:h.length)!==0)return(c=h==null?void 0:h[0])===null||c===void 0?void 0:c.code}get codeExecutionResult(){var e,n,s,r,i,a,o,l,c;if(((r=(s=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const h=(l=(o=(a=(i=this.candidates)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.content)===null||o===void 0?void 0:o.parts)===null||l===void 0?void 0:l.filter(p=>p.codeExecutionResult).map(p=>p.codeExecutionResult).filter(p=>p!==void 0);if((h==null?void 0:h.length)!==0)return(c=h==null?void 0:h[0])===null||c===void 0?void 0:c.output}}class pW{}class mW{}class uPe{}class dPe{}class hPe{}class fPe{}class gW{}class yW{}class xW{}class pPe{}class kR{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const s=new kR;let r;const i=e;return n?r=QMe(i):r=JMe(i),Object.assign(s,r),s}}class vW{}class bW{}class wW{}class _W{}class mPe{}class gPe{}class yPe{}class Pj{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const s=new Pj,i=iPe(e);return Object.assign(s,i),s}}class xPe{}class vPe{}class bPe{}class SW{}class wPe{get text(){var e,n,s;let r="",i=!1;const a=[];for(const o of(s=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&s!==void 0?s:[]){for(const[l,c]of Object.entries(o))l!=="text"&&l!=="thought"&&c!==null&&a.push(l);if(typeof o.text=="string"){if(typeof o.thought=="boolean"&&o.thought)continue;i=!0,r+=o.text}}return a.length>0&&console.warn(`there are non-text parts ${a} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),i?r:void 0}get data(){var e,n,s;let r="";const i=[];for(const a of(s=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&s!==void 0?s:[]){for(const[o,l]of Object.entries(a))o!=="inlineData"&&l!==null&&i.push(o);a.inlineData&&typeof a.inlineData.data=="string"&&(r+=atob(a.inlineData.data))}return i.length>0&&console.warn(`there are non-data parts ${i} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),r.length>0?btoa(r):void 0}}class _Pe{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class $j{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const s=new $j,i=wie(e);return Object.assign(s,i),s}}/**
6914 * @license
6915 * Copyright 2025 Google LLC
6916 * SPDX-License-Identifier: Apache-2.0
6917 */function Ur(t,e){if(!e||typeof e!="string")throw new Error("model is required and must be a string");if(e.includes("..")||e.includes("?")||e.includes("&"))throw new Error("invalid model parameter");if(t.isVertexAI()){if(e.startsWith("publishers/")||e.startsWith("projects/")||e.startsWith("models/"))return e;if(e.indexOf("/")>=0){const n=e.split("/",2);return`publishers/${n[0]}/models/${n[1]}`}else return`publishers/google/models/${e}`}else return e.startsWith("models/")||e.startsWith("tunedModels/")?e:`models/${e}`}function _ie(t,e){const n=Ur(t,e);return n?n.startsWith("publishers/")&&t.isVertexAI()?`projects/${t.getProject()}/locations/${t.getLocation()}/${n}`:n.startsWith("models/")&&t.isVertexAI()?`projects/${t.getProject()}/locations/${t.getLocation()}/publishers/google/${n}`:n:""}function Sie(t){return Array.isArray(t)?t.map(e=>IR(e)):[IR(t)]}function IR(t){if(typeof t=="object"&&t!==null)return t;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof t}`)}function Eie(t){const e=IR(t);if(e.mimeType&&e.mimeType.startsWith("image/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function Tie(t){const e=IR(t);if(e.mimeType&&e.mimeType.startsWith("audio/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function EW(t){if(t==null)throw new Error("PartUnion is required");if(typeof t=="object")return t;if(typeof t=="string")return{text:t};throw new Error(`Unsupported part type: ${typeof t}`)}function Aie(t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("PartListUnion is required");return Array.isArray(t)?t.map(e=>EW(e)):[EW(t)]}function LO(t){return t!=null&&typeof t=="object"&&"parts"in t&&Array.isArray(t.parts)}function TW(t){return t!=null&&typeof t=="object"&&"functionCall"in t}function AW(t){return t!=null&&typeof t=="object"&&"functionResponse"in t}function vl(t){if(t==null)throw new Error("ContentUnion is required");return LO(t)?t:{role:"user",parts:Aie(t)}}function Dj(t,e){if(!e)return[];if(t.isVertexAI()&&Array.isArray(e))return e.flatMap(n=>{const s=vl(n);return s.parts&&s.parts.length>0&&s.parts[0].text!==void 0?[s.parts[0].text]:[]});if(t.isVertexAI()){const n=vl(e);return n.parts&&n.parts.length>0&&n.parts[0].text!==void 0?[n.parts[0].text]:[]}return Array.isArray(e)?e.map(n=>vl(n)):[vl(e)]}function wd(t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("contents are required");if(!Array.isArray(t)){if(TW(t)||AW(t))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[vl(t)]}const e=[],n=[],s=LO(t[0]);for(const r of t){const i=LO(r);if(i!=s)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(i)e.push(r);else{if(TW(r)||AW(r))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");n.push(r)}}return s||e.push({role:"user",parts:Aie(n)}),e}function SPe(t,e){t.includes("null")&&(e.nullable=!0);const n=t.filter(s=>s!=="null");if(n.length===1)e.type=Object.values(Ei).includes(n[0].toUpperCase())?n[0].toUpperCase():Ei.TYPE_UNSPECIFIED;else{e.anyOf=[];for(const s of n)e.anyOf.push({type:Object.values(Ei).includes(s.toUpperCase())?s.toUpperCase():Ei.TYPE_UNSPECIFIED})}}function ww(t){const e={},n=["items"],s=["anyOf"],r=["properties"];
6917if(t.type&&t.anyOf)throw new Error("type and anyOf cannot be both populated.");const i=t.anyOf;i!=null&&i.length==2&&(i[0].type==="null"?(e.nullable=!0,t=i[1]):i[1].type==="null"&&(e.nullable=!0,t=i[0])),t.type instanceof Array&&SPe(t.type,e);for(const[a,o]of Object.entries(t))if(o!=null)if(a=="type"){if(o==="null")throw new Error("type: null can not be the only possible type for the field.");if(o instanceof Array)continue;e.type=Object.values(Ei).includes(o.toUpperCase())?o.toUpperCase():Ei.TYPE_UNSPECIFIED}else if(n.includes(a))e[a]=ww(o);else if(s.includes(a)){const l=[];for(const c of o){if(c.type=="null"){e.nullable=!0;continue}l.push(ww(c))}e[a]=l}else if(r.includes(a)){const l={};for(const[c,h]of Object.entries(o))l[c]=ww(h);e[a]=l}else{if(a==="additionalProperties")continue;e[a]=o}return e}function Oj(t){return ww(t)}function Lj(t){if(typeof t=="object")return t;if(typeof t=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:t}}};throw new Error(`Unsupported speechConfig type: ${typeof t}`)}function jj(t){if("multiSpeakerVoiceConfig"in t)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return t}function a_(t){if(t.functionDeclarations)for(const e of t.functionDeclarations)e.parameters&&(Object.keys(e.parameters).includes("$schema")?e.parametersJsonSchema||(e.parametersJsonSchema=e.parameters,delete e.parameters):e.parameters=ww(e.parameters)),e.response&&(Object.keys(e.response).includes("$schema")?e.responseJsonSchema||(e.responseJsonSchema=e.response,delete e.response):e.response=ww(e.response));return t}function o_(t){if(t==null)throw new Error("tools is required");if(!Array.isArray(t))throw new Error("tools is required and must be an array of Tools");const e=[];for(const n of t)e.push(n);return e}function EPe(t,e,n,s=1){const r=!e.startsWith(`${n}/`)&&e.split("/").length===s;return t.isVertexAI()?e.startsWith("projects/")?e:e.startsWith("locations/")?`projects/${t.getProject()}/${e}`:e.startsWith(`${n}/`)?`projects/${t.getProject()}/locations/${t.getLocation()}/${e}`:r?`projects/${t.getProject()}/locations/${t.getLocation()}/${n}/${e}`:e:r?`${n}/${e}`:e}function Hm(t,e){if(typeof e!="string")throw new Error("name must be a string");return EPe(t,e,"cachedContents")}function Cie(t){switch(t){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return t}}function sy(t){return Mj(t)}function TPe(t){return t!=null&&typeof t=="object"&&"name"in t}function APe(t){return t!=null&&typeof t=="object"&&"video"in t}function CPe(t){return t!=null&&typeof t=="object"&&"uri"in t}function kie(t){var e;let n;if(TPe(t)&&(n=t.name),!(CPe(t)&&(n=t.uri,n===void 0))&&!(APe(t)&&(n=(e=t.video)===null||e===void 0?void 0:e.uri,n===void 0))){if(typeof t=="string"&&(n=t),n===void 0)throw new Error("Could not extract file name from the provided input.");if(n.startsWith("https://")){const r=n.split("files/")[1].match(/[a-z0-9]+/);if(r===null)throw new Error(`Could not extract file name from URI ${n}`);n=r[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}function Iie(t,e){let n;return t.isVertexAI()?n=e?"publishers/google/models":"models":n=e?"models":"tunedModels",n}function Nie(t){for(const e of["models","tunedModels","publisherModels"])if(kPe(t,e))return t[e];return[]}function kPe(t,e){return t!==null&&typeof t=="object"&&e in t}function IPe(t,e={}){const n=t,s={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(s.responseJsonSchema=n.outputSchema),e.behavior&&(s.behavior=e.behavior),{functionDeclarations:[s]}}function NPe(t,e={}){const n=[],s=new Set;for(const r of t){const i=r.name;if(s.has(i))throw new Error(`Duplicate function name ${i} found in MCP tools. Please ensure function names are unique.`);s.add(i);const a=IPe(r,e);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function Rie(t,e){let n;if(typeof e=="string")if(t.isVertexAI())if(e.startsWith("gs://"))n={format:"jsonl",gcsUri:[e]};else if(e.startsWith("bq://"))n={format:"bigquery",bigqueryUri:e};else throw new Error(`Unsupported string source for Vertex AI: ${e}`);else if(e.startsWith("files/"))n={fileName:e};else throw new Error(`Unsupported string source for Gemini API: ${e}`);else if(Array.isArray(e)){if(t.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");n={inlinedRequests:e}}else n=e;
6917const s=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,r=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(t.isVertexAI()){if(r>0||s!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(s>0||r!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function RPe(t){if(typeof t!="string")return t;const e=t;if(e.startsWith("gs://"))return{format:"jsonl",gcsUri:e};if(e.startsWith("bq://"))return{format:"bigquery",bigqueryUri:e};throw new Error(`Unsupported destination: ${e}`)}function Mie(t){if(typeof t!="object"||t===null)return{};const e=t,n=e.inlinedResponses;if(typeof n!="object"||n===null)return t;const r=n.inlinedResponses;if(!Array.isArray(r)||r.length===0)return t;let i=!1;for(const a of r){if(typeof a!="object"||a===null)continue;const l=a.response;if(typeof l!="object"||l===null)continue;if(l.embedding!==void 0){i=!0;break}}return i&&(e.inlinedEmbedContentResponses=e.inlinedResponses,delete e.inlinedResponses),t}function l_(t,e){const n=e;if(!t.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split("/").pop();throw new Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split("/").pop();if(/^\d+$/.test(n))return n;throw new Error(`Invalid batch job name: ${n}.`)}function Pie(t){const e=t;return e==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":e==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":e==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":e==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":e==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":e==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":e==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":e}/**
6918 * @license
6919 * Copyright 2025 Google LLC
6920 * SPDX-License-Identifier: Apache-2.0
6921 */function MPe(t){const e={},n=T(t,["responsesFile"]);n!=null&&k(e,["fileName"],n);const s=T(t,["inlinedResponses","inlinedResponses"]);if(s!=null){let i=s;Array.isArray(i)&&(i=i.map(a=>h4e(a))),k(e,["inlinedResponses"],i)}const r=T(t,["inlinedEmbedContentResponses","inlinedResponses"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["inlinedEmbedContentResponses"],i)}return e}function PPe(t){const e={},n=T(t,["predictionsFormat"]);n!=null&&k(e,["format"],n);const s=T(t,["gcsDestination","outputUriPrefix"]);s!=null&&k(e,["gcsUri"],s);const r=T(t,["bigqueryDestination","outputUri"]);return r!=null&&k(e,["bigqueryUri"],r),e}function $Pe(t){const e={},n=T(t,["format"]);n!=null&&k(e,["predictionsFormat"],n);const s=T(t,["gcsUri"]);s!=null&&k(e,["gcsDestination","outputUriPrefix"],s);const r=T(t,["bigqueryUri"]);if(r!=null&&k(e,["bigqueryDestination","outputUri"],r),T(t,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(T(t,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(T(t,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return e}function gN(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata","displayName"]);s!=null&&k(e,["displayName"],s);const r=T(t,["metadata","state"]);r!=null&&k(e,["state"],Pie(r));const i=T(t,["metadata","createTime"]);i!=null&&k(e,["createTime"],i);const a=T(t,["metadata","endTime"]);a!=null&&k(e,["endTime"],a);const o=T(t,["metadata","updateTime"]);o!=null&&k(e,["updateTime"],o);const l=T(t,["metadata","model"]);l!=null&&k(e,["model"],l);const c=T(t,["metadata","output"]);return c!=null&&k(e,["dest"],MPe(Mie(c))),e}function jO(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["displayName"]);s!=null&&k(e,["displayName"],s);const r=T(t,["state"]);r!=null&&k(e,["state"],Pie(r));const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["createTime"]);a!=null&&k(e,["createTime"],a);const o=T(t,["startTime"]);o!=null&&k(e,["startTime"],o);const l=T(t,["endTime"]);l!=null&&k(e,["endTime"],l);const c=T(t,["updateTime"]);c!=null&&k(e,["updateTime"],c);const h=T(t,["model"]);h!=null&&k(e,["model"],h);const p=T(t,["inputConfig"]);p!=null&&k(e,["src"],DPe(p));const m=T(t,["outputConfig"]);m!=null&&k(e,["dest"],PPe(Mie(m)));const y=T(t,["completionStats"]);return y!=null&&k(e,["completionStats"],y),e}function DPe(t){const e={},n=T(t,["instancesFormat"]);n!=null&&k(e,["format"],n);const s=T(t,["gcsSource","uris"]);s!=null&&k(e,["gcsUri"],s);const r=T(t,["bigquerySource","inputUri"]);return r!=null&&k(e,["bigqueryUri"],r),e}function OPe(t,e){const n={};if(T(e,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(T(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(T(e,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const s=T(e,["fileName"]);s!=null&&k(n,["fileName"],s);const r=T(e,["inlinedRequests"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>d4e(t,a))),k(n,["requests","requests"],i)}return n}function LPe(t){const e={},n=T(t,["format"]);n!=null&&k(e,["instancesFormat"],n);const s=T(t,["gcsUri"]);s!=null&&k(e,["gcsSource","uris"],s);const r=T(t,["bigqueryUri"]);if(r!=null&&k(e,["bigquerySource","inputUri"],r),T(t,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");
6921if(T(t,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return e}function jPe(t){const e={},n=T(t,["data"]);if(n!=null&&k(e,["data"],n),T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function BPe(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],l_(t,s)),n}function UPe(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],l_(t,s)),n}function FPe(t){const e={},n=T(t,["content"]);n!=null&&k(e,["content"],n);const s=T(t,["citationMetadata"]);s!=null&&k(e,["citationMetadata"],VPe(s));const r=T(t,["tokenCount"]);r!=null&&k(e,["tokenCount"],r);const i=T(t,["finishReason"]);i!=null&&k(e,["finishReason"],i);const a=T(t,["avgLogprobs"]);a!=null&&k(e,["avgLogprobs"],a);const o=T(t,["groundingMetadata"]);o!=null&&k(e,["groundingMetadata"],o);const l=T(t,["index"]);l!=null&&k(e,["index"],l);const c=T(t,["logprobsResult"]);c!=null&&k(e,["logprobsResult"],c);const h=T(t,["safetyRatings"]);if(h!=null){let m=h;Array.isArray(m)&&(m=m.map(y=>y)),k(e,["safetyRatings"],m)}const p=T(t,["urlContextMetadata"]);return p!=null&&k(e,["urlContextMetadata"],p),e}function VPe(t){const e={},n=T(t,["citationSources"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(r=>r)),k(e,["citations"],s)}return e}function $ie(t){const e={},n=T(t,["parts"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>v4e(i))),k(e,["parts"],r)}const s=T(t,["role"]);return s!=null&&k(e,["role"],s),e}function zPe(t,e){const n={},s=T(t,["displayName"]);if(e!==void 0&&s!=null&&k(e,["batch","displayName"],s),T(t,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return n}function GPe(t,e){const n={},s=T(t,["displayName"]);e!==void 0&&s!=null&&k(e,["displayName"],s);const r=T(t,["dest"]);return e!==void 0&&r!=null&&k(e,["outputConfig"],$Pe(RPe(r))),n}function CW(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["src"]);r!=null&&k(n,["batch","inputConfig"],OPe(t,Rie(t,r)));const i=T(e,["config"]);return i!=null&&zPe(i,n),n}function HPe(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["model"],Ur(t,s));const r=T(e,["src"]);r!=null&&k(n,["inputConfig"],LPe(Rie(t,r)));const i=T(e,["config"]);return i!=null&&GPe(i,n),n}function qPe(t,e){const n={},s=T(t,["displayName"]);return e!==void 0&&s!=null&&k(e,["batch","displayName"],s),n}function WPe(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["src"]);r!=null&&k(n,["batch","inputConfig"],e4e(t,r));const i=T(e,["config"]);return i!=null&&qPe(i,n),n}function KPe(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],l_(t,s)),n}function YPe(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],l_(t,s)),n}function XPe(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["name"]);s!=null&&k(e,["name"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);return i!=null&&k(e,["error"],i),e}function JPe(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["name"]);s!=null&&k(e,["name"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);return i!=null&&k(e,["error"],i),e}function QPe(t,e){const n={},s=T(e,["contents"]);if(s!=null){let i=Dj(t,s);Array.isArray(i)&&(i=i.map(a=>a)),k(n,["requests[]","request","content"],i)}const r=T(e,["config"]);return r!=null&&(k(n,["_self"],ZPe(r,n)),YMe(n,{"requests[].*":"requests[].request.*"})),n}function ZPe(t,e){const n={},s=T(t,["taskType"]);e!==void 0&&s!=null&&k(e,["requests[]","taskType"],s);const r=T(t,["title"]);e!==void 0&&r!=null&&k(e,["requests[]","title"],r);const i=T(t,["outputDimensionality"]);if(e!==void 0&&i!=null&&k(e,["requests[]","outputDimensionality"],i),T(t,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(T(t,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function e4e(t,e){const n={},s=T(e,["fileName"]);s!=null&&k(n,["file_name"],s);const r=T(e,["inlinedRequests"]);return r!=null&&k(n,["requests"],QPe(t,r)),n}function t4e(t){const e={};if(T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=T(t,["fileUri"]);n!=null&&k(e,["fileUri"],n);const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function n4e(t){const e={},n=T(t,["id"]);n!=null&&k(e,["id"],n);const s=T(t,["args"]);s!=null&&k(e,["args"],s);const r=T(t,["name"]);if(r!=null&&k(e,["name"],r),T(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");
6921if(T(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function s4e(t){const e={},n=T(t,["mode"]);n!=null&&k(e,["mode"],n);const s=T(t,["allowedFunctionNames"]);if(s!=null&&k(e,["allowedFunctionNames"],s),T(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function r4e(t,e,n){const s={},r=T(e,["systemInstruction"]);n!==void 0&&r!=null&&k(n,["systemInstruction"],$ie(vl(r)));const i=T(e,["temperature"]);i!=null&&k(s,["temperature"],i);const a=T(e,["topP"]);a!=null&&k(s,["topP"],a);const o=T(e,["topK"]);o!=null&&k(s,["topK"],o);const l=T(e,["candidateCount"]);l!=null&&k(s,["candidateCount"],l);const c=T(e,["maxOutputTokens"]);c!=null&&k(s,["maxOutputTokens"],c);const h=T(e,["stopSequences"]);h!=null&&k(s,["stopSequences"],h);const p=T(e,["responseLogprobs"]);p!=null&&k(s,["responseLogprobs"],p);const m=T(e,["logprobs"]);m!=null&&k(s,["logprobs"],m);const y=T(e,["presencePenalty"]);y!=null&&k(s,["presencePenalty"],y);const v=T(e,["frequencyPenalty"]);v!=null&&k(s,["frequencyPenalty"],v);const b=T(e,["seed"]);b!=null&&k(s,["seed"],b);const S=T(e,["responseMimeType"]);S!=null&&k(s,["responseMimeType"],S);const E=T(e,["responseSchema"]);E!=null&&k(s,["responseSchema"],Oj(E));const I=T(e,["responseJsonSchema"]);if(I!=null&&k(s,["responseJsonSchema"],I),T(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(T(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const M=T(e,["safetySettings"]);if(n!==void 0&&M!=null){let H=M;Array.isArray(H)&&(H=H.map(Y=>b4e(Y))),k(n,["safetySettings"],H)}const j=T(e,["tools"]);if(n!==void 0&&j!=null){let H=o_(j);Array.isArray(H)&&(H=H.map(Y=>_4e(a_(Y)))),k(n,["tools"],H)}const L=T(e,["toolConfig"]);if(n!==void 0&&L!=null&&k(n,["toolConfig"],w4e(L)),T(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const K=T(e,["cachedContent"]);n!==void 0&&K!=null&&k(n,["cachedContent"],Hm(t,K));const D=T(e,["responseModalities"]);D!=null&&k(s,["responseModalities"],D);const R=T(e,["mediaResolution"]);R!=null&&k(s,["mediaResolution"],R);const B=T(e,["speechConfig"]);if(B!=null&&k(s,["speechConfig"],Lj(B)),T(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const G=T(e,["thinkingConfig"]);G!=null&&k(s,["thinkingConfig"],G);const X=T(e,["imageConfig"]);return X!=null&&k(s,["imageConfig"],u4e(X)),s}function i4e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["candidates"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(c=>FPe(c))),k(e,["candidates"],l)}const r=T(t,["modelVersion"]);r!=null&&k(e,["modelVersion"],r);const i=T(t,["promptFeedback"]);i!=null&&k(e,["promptFeedback"],i);const a=T(t,["responseId"]);a!=null&&k(e,["responseId"],a);const o=T(t,["usageMetadata"]);return o!=null&&k(e,["usageMetadata"],o),e}function a4e(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],l_(t,s)),n}function o4e(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],l_(t,s)),n}function l4e(t){const e={};if(T(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=T(t,["enableWidget"]);return n!=null&&k(e,["enableWidget"],n),e}function c4e(t){const e={};if(T(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(T(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=T(t,["timeRangeFilter"]);return n!=null&&k(e,["timeRangeFilter"],n),e}function u4e(t){const e={},n=T(t,["aspectRatio"]);n!=null&&k(e,["aspectRatio"],n);const s=T(t,["imageSize"]);if(s!=null&&k(e,["imageSize"],s),T(t,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(T(t,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return e}function d4e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["request","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let o=wd(r);
6921Array.isArray(o)&&(o=o.map(l=>$ie(l))),k(n,["request","contents"],o)}const i=T(e,["metadata"]);i!=null&&k(n,["metadata"],i);const a=T(e,["config"]);return a!=null&&k(n,["request","generationConfig"],r4e(t,a,T(n,["request"],{}))),n}function h4e(t){const e={},n=T(t,["response"]);n!=null&&k(e,["response"],i4e(n));const s=T(t,["error"]);return s!=null&&k(e,["error"],s),e}function f4e(t,e){const n={},s=T(t,["pageSize"]);e!==void 0&&s!=null&&k(e,["_query","pageSize"],s);const r=T(t,["pageToken"]);if(e!==void 0&&r!=null&&k(e,["_query","pageToken"],r),T(t,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return n}function p4e(t,e){const n={},s=T(t,["pageSize"]);e!==void 0&&s!=null&&k(e,["_query","pageSize"],s);const r=T(t,["pageToken"]);e!==void 0&&r!=null&&k(e,["_query","pageToken"],r);const i=T(t,["filter"]);return e!==void 0&&i!=null&&k(e,["_query","filter"],i),n}function m4e(t){const e={},n=T(t,["config"]);return n!=null&&f4e(n,e),e}function g4e(t){const e={},n=T(t,["config"]);return n!=null&&p4e(n,e),e}function y4e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["operations"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>gN(a))),k(e,["batchJobs"],i)}return e}function x4e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["batchPredictionJobs"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>jO(a))),k(e,["batchJobs"],i)}return e}function v4e(t){const e={},n=T(t,["mediaResolution"]);n!=null&&k(e,["mediaResolution"],n);const s=T(t,["codeExecutionResult"]);s!=null&&k(e,["codeExecutionResult"],s);const r=T(t,["executableCode"]);r!=null&&k(e,["executableCode"],r);const i=T(t,["fileData"]);i!=null&&k(e,["fileData"],t4e(i));const a=T(t,["functionCall"]);a!=null&&k(e,["functionCall"],n4e(a));const o=T(t,["functionResponse"]);o!=null&&k(e,["functionResponse"],o);const l=T(t,["inlineData"]);l!=null&&k(e,["inlineData"],jPe(l));const c=T(t,["text"]);c!=null&&k(e,["text"],c);const h=T(t,["thought"]);h!=null&&k(e,["thought"],h);const p=T(t,["thoughtSignature"]);p!=null&&k(e,["thoughtSignature"],p);const m=T(t,["videoMetadata"]);return m!=null&&k(e,["videoMetadata"],m),e}function b4e(t){const e={},n=T(t,["category"]);if(n!=null&&k(e,["category"],n),T(t,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const s=T(t,["threshold"]);return s!=null&&k(e,["threshold"],s),e}function w4e(t){const e={},n=T(t,["functionCallingConfig"]);n!=null&&k(e,["functionCallingConfig"],s4e(n));const s=T(t,["retrievalConfig"]);return s!=null&&k(e,["retrievalConfig"],s),e}function _4e(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(p=>p)),k(e,["functionDeclarations"],h)}if(T(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=T(t,["googleSearchRetrieval"]);s!=null&&k(e,["googleSearchRetrieval"],s);const r=T(t,["computerUse"]);r!=null&&k(e,["computerUse"],r);const i=T(t,["fileSearch"]);i!=null&&k(e,["fileSearch"],i);const a=T(t,["codeExecution"]);if(a!=null&&k(e,["codeExecution"],a),T(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const o=T(t,["googleMaps"]);o!=null&&k(e,["googleMaps"],l4e(o));const l=T(t,["googleSearch"]);l!=null&&k(e,["googleSearch"],c4e(l));const c=T(t,["urlContext"]);return c!=null&&k(e,["urlContext"],c),e}/**
6922 * @license
6923 * Copyright 2025 Google LLC
6924 * SPDX-License-Identifier: Apache-2.0
6925 */var jm;(function(t){t.PAGED_ITEM_BATCH_JOBS="batchJobs",t.PAGED_ITEM_MODELS="models",t.PAGED_ITEM_TUNING_JOBS="tuningJobs",t.PAGED_ITEM_FILES="files",t.PAGED_ITEM_CACHED_CONTENTS="cachedContents",t.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",t.PAGED_ITEM_DOCUMENTS="documents"})(jm||(jm={}));class Wv{constructor(e,n,s,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=n,this.init(e,s,r)}init(e,n,s){var r,i;this.nameInternal=e,this.pageInternal=n[this.nameInternal]||[],this.sdkHttpResponseInternal=n==null?void 0:n.sdkHttpResponse,this.idxInternal=0;let a={config:{}};!s||Object.keys(s).length===0?a={config:{}}:typeof s=="object"?a=Object.assign({},s):a=s,a.config&&(a.config.pageToken=n.nextPageToken),this.paramsInternal=a,this.pageInternalSize=(i=(r=a.config)===null||r===void 0?void 0:r.pageSize)!==null&&i!==void 0?i:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>
6925{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return((e=this.params.config)===null||e===void 0?void 0:e.pageToken)!==void 0}}/**
6926 * @license
6927 * Copyright 2025 Google LLC
6928 * SPDX-License-Identifier: Apache-2.0
6929 */class S4e extends Gm{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new Wv(jm.PAGED_ITEM_BATCH_JOBS,s=>this.listInternal(s),await this.listInternal(n),n),this.create=async n=>(this.apiClient.isVertexAI()&&(n.config=this.formatDestination(n.src,n.config)),this.createInternal(n)),this.createEmbeddings=async n=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(n)}}createInlinedGenerateContentRequest(e){const n=CW(this.apiClient,e),s=n._url,r=cn("{model}:batchGenerateContent",s),o=n.batch.inputConfig.requests,l=o.requests,c=[];for(const h of l){const p=Object.assign({},h);if(p.systemInstruction){const m=p.systemInstruction;delete p.systemInstruction;const y=p.request;y.systemInstruction=m,p.request=y}c.push(p)}return o.requests=c,delete n.config,delete n._url,delete n._query,{path:r,body:n}}getGcsUri(e){if(typeof e=="string")return e.startsWith("gs://")?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e=="string")return e.startsWith("bq://")?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,n){const s=n?Object.assign({},n):{},r=Date.now().toString();if(s.displayName||(s.displayName=`genaiBatchJob_${r}`),s.dest===void 0){const i=this.getGcsUri(e),a=this.getBigqueryUri(e);if(i)i.endsWith(".jsonl")?s.dest=`${i.slice(0,-6)}/dest`:s.dest=`${i}_dest_${r}`;else if(a)s.dest=`${a}_dest_${r}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return s}async createInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=HPe(this.apiClient,e);return o=cn("batchPredictionJobs",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>jO(h))}else{const c=CW(this.apiClient,e);return o=cn("{model}:batchGenerateContent",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a.then(h=>gN(h))}}async createEmbeddingsInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=WPe(this.apiClient,e);return i=cn("{model}:asyncBatchEmbedContent",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>gN(l))}}async get(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=o4e(this.apiClient,e);return o=cn("batchPredictionJobs/{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>jO(h))}else{const c=a4e(this.apiClient,e);return o=cn("batches/{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abort
6929Signal}).then(h=>h.json()),a.then(h=>gN(h))}}async cancel(e){var n,s,r,i;let a="",o={};if(this.apiClient.isVertexAI()){const l=UPe(this.apiClient,e);a=cn("batchPredictionJobs/{name}:cancel",l._url),o=l._query,delete l._url,delete l._query,await this.apiClient.request({path:a,queryParams:o,body:JSON.stringify(l),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal})}else{const l=BPe(this.apiClient,e);a=cn("batches/{name}:cancel",l._url),o=l._query,delete l._url,delete l._query,await this.apiClient.request({path:a,queryParams:o,body:JSON.stringify(l),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal})}}async listInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=g4e(e);return o=cn("batchPredictionJobs",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=x4e(h),m=new SW;return Object.assign(m,p),m})}else{const c=m4e(e);return o=cn("batches",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=y4e(h),m=new SW;return Object.assign(m,p),m})}}async delete(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=YPe(this.apiClient,e);return o=cn("batchPredictionJobs/{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>JPe(h))}else{const c=KPe(this.apiClient,e);return o=cn("batches/{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>XPe(h))}}}/**
6930 * @license
6931 * Copyright 2025 Google LLC
6932 * SPDX-License-Identifier: Apache-2.0
6933 */function E4e(t){const e={},n=T(t,["data"]);if(n!=null&&k(e,["data"],n),T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function kW(t){const e={},n=T(t,["parts"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>W4e(i))),k(e,["parts"],r)}const s=T(t,["role"]);return s!=null&&k(e,["role"],s),e}function T4e(t,e){const n={},s=T(t,["ttl"]);e!==void 0&&s!=null&&k(e,["ttl"],s);const r=T(t,["expireTime"]);e!==void 0&&r!=null&&k(e,["expireTime"],r);const i=T(t,["displayName"]);e!==void 0&&i!=null&&k(e,["displayName"],i);const a=T(t,["contents"]);if(e!==void 0&&a!=null){let h=wd(a);Array.isArray(h)&&(h=h.map(p=>kW(p))),k(e,["contents"],h)}const o=T(t,["systemInstruction"]);e!==void 0&&o!=null&&k(e,["systemInstruction"],kW(vl(o)));const l=T(t,["tools"]);if(e!==void 0&&l!=null){let h=l;Array.isArray(h)&&(h=h.map(p=>Y4e(p))),k(e,["tools"],h)}const c=T(t,["toolConfig"]);if(e!==void 0&&c!=null&&k(e,["toolConfig"],K4e(c)),T(t,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return n}function A4e(t,e){const n={},s=T(t,["ttl"]);e!==void 0&&s!=null&&k(e,["ttl"],s);const r=T(t,["expireTime"]);e!==void 0&&r!=null&&k(e,["expireTime"],r);const i=T(t,["displayName"]);e!==void 0&&i!=null&&k(e,["displayName"],i);const a=T(t,["contents"]);if(e!==void 0&&a!=null){let p=wd(a);Array.isArray(p)&&(p=p.map(m=>m)),k(e,["contents"],p)}const o=T(t,["systemInstruction"]);e!==void 0&&o!=null&&k(e,["systemInstruction"],vl(o));const l=T(t,["tools"]);if(e!==void 0&&l!=null){let p=l;Array.isArray(p)&&(p=p.map(m=>X4e(m))),k(e,["tools"],p)}const c=T(t,["toolConfig"]);e!==void 0&&c!=null&&k(e,["toolConfig"],c);const h=T(t,["kmsKeyName"]);return e!==void 0&&h!=null&&k(e,["encryption_spec","kmsKeyName"],h),n}function C4e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["model"],_ie(t,s));const r=T(e,["config"]);return r!=null&&T4e(r,n),n}function k4e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["model"],_ie(t,s));const r=T(e,["config"]);return r!=null&&A4e(r,n),n}function I4e(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],Hm(t,s)),n}function N4e(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],Hm(t,s)),n}function R4e(t){const e={},n=T(t,["sdkHttpResponse"]);return n!=null&&k(e,["sdkHttpResponse"],n),e}function M4e(t){const e={},n=T(t,["sdkHttpResponse"]);return n!=null&&k(e,["sdkHttpResponse"],n),e}function P4e(t){const e={};if(T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=T(t,["fileUri"]);n!=null&&k(e,["fileUri"],n);const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function $4e(t){const e={},n=T(t,["id"]);n!=null&&k(e,["id"],n);const s=T(t,["args"]);s!=null&&k(e,["args"],s);const r=T(t,["name"]);if(r!=null&&k(e,["name"],r),T(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");
6933if(T(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function D4e(t){const e={},n=T(t,["mode"]);n!=null&&k(e,["mode"],n);const s=T(t,["allowedFunctionNames"]);if(s!=null&&k(e,["allowedFunctionNames"],s),T(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function O4e(t){const e={};if(T(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=T(t,["description"]);n!=null&&k(e,["description"],n);const s=T(t,["name"]);s!=null&&k(e,["name"],s);const r=T(t,["parameters"]);r!=null&&k(e,["parameters"],r);const i=T(t,["parametersJsonSchema"]);i!=null&&k(e,["parametersJsonSchema"],i);const a=T(t,["response"]);a!=null&&k(e,["response"],a);const o=T(t,["responseJsonSchema"]);return o!=null&&k(e,["responseJsonSchema"],o),e}function L4e(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],Hm(t,s)),n}function j4e(t,e){const n={},s=T(e,["name"]);return s!=null&&k(n,["_url","name"],Hm(t,s)),n}function B4e(t){const e={};if(T(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=T(t,["enableWidget"]);return n!=null&&k(e,["enableWidget"],n),e}function U4e(t){const e={};if(T(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(T(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=T(t,["timeRangeFilter"]);return n!=null&&k(e,["timeRangeFilter"],n),e}function F4e(t,e){const n={},s=T(t,["pageSize"]);e!==void 0&&s!=null&&k(e,["_query","pageSize"],s);const r=T(t,["pageToken"]);return e!==void 0&&r!=null&&k(e,["_query","pageToken"],r),n}function V4e(t,e){const n={},s=T(t,["pageSize"]);e!==void 0&&s!=null&&k(e,["_query","pageSize"],s);const r=T(t,["pageToken"]);return e!==void 0&&r!=null&&k(e,["_query","pageToken"],r),n}function z4e(t){const e={},n=T(t,["config"]);return n!=null&&F4e(n,e),e}function G4e(t){const e={},n=T(t,["config"]);return n!=null&&V4e(n,e),e}function H4e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["cachedContents"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["cachedContents"],i)}return e}function q4e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["cachedContents"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["cachedContents"],i)}return e}function W4e(t){const e={},n=T(t,["mediaResolution"]);n!=null&&k(e,["mediaResolution"],n);const s=T(t,["codeExecutionResult"]);s!=null&&k(e,["codeExecutionResult"],s);const r=T(t,["executableCode"]);r!=null&&k(e,["executableCode"],r);const i=T(t,["fileData"]);i!=null&&k(e,["fileData"],P4e(i));const a=T(t,["functionCall"]);a!=null&&k(e,["functionCall"],$4e(a));const o=T(t,["functionResponse"]);o!=null&&k(e,["functionResponse"],o);const l=T(t,["inlineData"]);l!=null&&k(e,["inlineData"],E4e(l));const c=T(t,["text"]);c!=null&&k(e,["text"],c);const h=T(t,["thought"]);h!=null&&k(e,["thought"],h);const p=T(t,["thoughtSignature"]);p!=null&&k(e,["thoughtSignature"],p);const m=T(t,["videoMetadata"]);return m!=null&&k(e,["videoMetadata"],m),e}function K4e(t){const e={},n=T(t,["functionCallingConfig"]);n!=null&&k(e,["functionCallingConfig"],D4e(n));const s=T(t,["retrievalConfig"]);return s!=null&&k(e,["retrievalConfig"],s),e}function Y4e(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(p=>p)),k(e,["functionDeclarations"],h)}if(T(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=T(t,["googleSearchRetrieval"]);s!=null&&k(e,["googleSearchRetrieval"],s);const r=T(t,["computerUse"]);r!=null&&k(e,["computerUse"],r);const i=T(t,["fileSearch"]);i!=null&&k(e,["fileSearch"],i);const a=T(t,["codeExecution"]);if(a!=null&&k(e,["codeExecution"],a),T(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const o=T(t,["googleMaps"]);o!=null&&k(e,["googleMaps"],B4e(o));const l=T(t,["googleSearch"]);l!=null&&k(e,["googleSearch"],U4e(l));const c=T(t,["urlContext"]);
6933return c!=null&&k(e,["urlContext"],c),e}function X4e(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(m=>O4e(m))),k(e,["functionDeclarations"],p)}const s=T(t,["retrieval"]);s!=null&&k(e,["retrieval"],s);const r=T(t,["googleSearchRetrieval"]);r!=null&&k(e,["googleSearchRetrieval"],r);const i=T(t,["computerUse"]);if(i!=null&&k(e,["computerUse"],i),T(t,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const a=T(t,["codeExecution"]);a!=null&&k(e,["codeExecution"],a);const o=T(t,["enterpriseWebSearch"]);o!=null&&k(e,["enterpriseWebSearch"],o);const l=T(t,["googleMaps"]);l!=null&&k(e,["googleMaps"],l);const c=T(t,["googleSearch"]);c!=null&&k(e,["googleSearch"],c);const h=T(t,["urlContext"]);return h!=null&&k(e,["urlContext"],h),e}function J4e(t,e){const n={},s=T(t,["ttl"]);e!==void 0&&s!=null&&k(e,["ttl"],s);const r=T(t,["expireTime"]);return e!==void 0&&r!=null&&k(e,["expireTime"],r),n}function Q4e(t,e){const n={},s=T(t,["ttl"]);e!==void 0&&s!=null&&k(e,["ttl"],s);const r=T(t,["expireTime"]);return e!==void 0&&r!=null&&k(e,["expireTime"],r),n}function Z4e(t,e){const n={},s=T(e,["name"]);s!=null&&k(n,["_url","name"],Hm(t,s));const r=T(e,["config"]);return r!=null&&J4e(r,n),n}function e$e(t,e){const n={},s=T(e,["name"]);s!=null&&k(n,["_url","name"],Hm(t,s));const r=T(e,["config"]);return r!=null&&Q4e(r,n),n}/**
6934 * @license
6935 * Copyright 2025 Google LLC
6936 * SPDX-License-Identifier: Apache-2.0
6937 */class t$e extends Gm{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new Wv(jm.PAGED_ITEM_CACHED_CONTENTS,s=>this.listInternal(s),await this.listInternal(n),n)}async create(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=k4e(this.apiClient,e);return o=cn("cachedContents",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>h)}else{const c=C4e(this.apiClient,e);return o=cn("cachedContents",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a.then(h=>h)}}async get(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=j4e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>h)}else{const c=L4e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a.then(h=>h)}}async delete(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=N4e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=M4e(h),m=new wW;return Object.assign(m,p),m})}else{const c=I4e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abort
6937Signal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=R4e(h),m=new wW;return Object.assign(m,p),m})}}async update(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=e$e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>h)}else{const c=Z4e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a.then(h=>h)}}async listInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=G4e(e);return o=cn("cachedContents",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=q4e(h),m=new _W;return Object.assign(m,p),m})}else{const c=z4e(e);return o=cn("cachedContents",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=H4e(h),m=new _W;return Object.assign(m,p),m})}}}function IW(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],s=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function $i(t){return this instanceof $i?(this.v=t,this):new $i(t)}function _w(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n.apply(t,e||[]),r,i=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),r[Symbol.asyncIterator]=function(){return this},r;function a(y){return function(v){return Promise.resolve(v).then(y,p)}}function o(y,v){s[y]&&(r[y]=function(b){return new Promise(function(S,E){i.push([y,b,S,E])>1||l(y,b)})},v&&(r[y]=v(r[y])))}function l(y,v){try{c(s[y](v))}catch(b){m(i[0][3],b)}}function c(y){y.value instanceof $i?Promise.resolve(y.value.v).then(h,p):m(i[0][2],y)}function h(y){l("next",y)}function p(y){l("throw",y)}function m(y,v){y(v),i.shift(),i.length&&l(i[0][0],i[0][1])}}function XS(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof IW=="function"?IW(t):t[Symbol.iterator](),n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n);function s(i){n[i]=t[i]&&function(a){return new Promise(function(o,l){a=t[i](a),r(o,l,a.done,a.value)})}}function r(i,a,o,l){Promise.resolve(l).then(function(c){i({value:c,done:o})},a)}}/**
6938 * @license
6939 * Copyright 2025 Google LLC
6940 * SPDX-License-Identifier: Apache-2.0
6941 */function n$e(t){var e;if(t.candidates==null||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;return n===void 0?!1:Die(n)}function Die(t){if(t.parts===void 0||t.parts.length===0)return!1;for(const e of t.parts)if(e===void 0||Object.keys(e).length===0)return!1;return!0}function s$e(t){if(t.length!==0){for(const e of t)if(e.role!=="user"&&e.role!=="model")throw new Error(`Role must be user or model, but got ${e.role}.`)}}function NW(t){if(t===void 0||t.length===0)return[];const e=[],n=t.length;let s=0;for(;s<n;)if(t[s].role==="user")e.push(t[s]),s++;else{const r=[];let i=!0;for(;s<n&&t[s].role==="model";)r.push(t[s]),i&&!Die(t[s])&&(i=!1),s++;i?e.push(...r):e.pop()}return e}class r$e{constructor(e,n){this.modelsModule=e,this.apiClient=n}create(e){return new i$e(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class i$e{constructor(e,n,s,r={},i=[]){this.apiClient=e,this.modelsModule=n,this.model=s,this.config=r,this.history=i,this.sendPromise=Promise.resolve(),s$e(i)}async sendMessage(e){var n;await this.sendPromise;const s=vl(e.message),r=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(s),config:(n=e.config)!==null&&n!==void 0?n:this.config});return this.sendPromise=(async()=>{var i,a,o;const l=await r,c=(a=(i=l.candidates)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.content,h=l.automaticFunctionCallingHistory,p=this.getHistory(!0).length;let m=[];h!=null&&(m=(o=h.slice(p))!==null&&o!==void 0?o:[]);const y=c?[c]:[];this.recordHistory(s,y,m)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),r}async sendMessageStream(e){var n;await this.sendPromise;const s=vl(e.message),r=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(s),config:(n=e.config)!==null&&n!==void 0?n:this.config});this.sendPromise=r.then(()=>{}).catch(()=>{});const i=await r;return this.processStreamResponse(i,s)}getHistory(e=!1){const n=e?NW(this.history):this.history;return structuredClone(n)}processStreamResponse(e,n){var s,r;return _w(this,arguments,function*(){var a,o,l,c;const h=[];try{for(var p=!0,m=XS(e),y;y=yield $i(m.next()),a=y.done,!a;p=!0){c=y.value,p=!1;const v=c;if(n$e(v)){const b=(r=(s=v.candidates)===null||s===void 0?void 0:s[0])===null||r===void 0?void 0:r.content;b!==void 0&&h.push(b)}yield yield $i(v)}}catch(v){o={error:v}}
6941finally{try{!p&&!a&&(l=m.return)&&(yield $i(l.call(m)))}finally{if(o)throw o.error}}this.recordHistory(n,h)})}recordHistory(e,n,s){let r=[];n.length>0&&n.every(i=>i.role!==void 0)?r=n:r.push({role:"model",parts:[]}),s&&s.length>0?this.history.push(...NW(s)):this.history.push(e),this.history.push(...r)}}/**
6942 * @license
6943 * Copyright 2025 Google LLC
6944 * SPDX-License-Identifier: Apache-2.0
6945 */class qM extends Error{constructor(e){super(e.message),this.name="ApiError",this.status=e.status,Object.setPrototypeOf(this,qM.prototype)}}/**
6946 * @license
6947 * Copyright 2025 Google LLC
6948 * SPDX-License-Identifier: Apache-2.0
6949 */function a$e(t){const e={},n=T(t,["file"]);return n!=null&&k(e,["file"],n),e}function o$e(t){const e={},n=T(t,["sdkHttpResponse"]);return n!=null&&k(e,["sdkHttpResponse"],n),e}function l$e(t){const e={},n=T(t,["name"]);return n!=null&&k(e,["_url","file"],kie(n)),e}function c$e(t){const e={},n=T(t,["sdkHttpResponse"]);return n!=null&&k(e,["sdkHttpResponse"],n),e}function u$e(t){const e={},n=T(t,["name"]);return n!=null&&k(e,["_url","file"],kie(n)),e}function d$e(t,e){const n={},s=T(t,["pageSize"]);e!==void 0&&s!=null&&k(e,["_query","pageSize"],s);const r=T(t,["pageToken"]);return e!==void 0&&r!=null&&k(e,["_query","pageToken"],r),n}function h$e(t){const e={},n=T(t,["config"]);return n!=null&&d$e(n,e),e}function f$e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["files"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["files"],i)}return e}/**
6950 * @license
6951 * Copyright 2025 Google LLC
6952 * SPDX-License-Identifier: Apache-2.0
6953 */class p$e extends Gm{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new Wv(jm.PAGED_ITEM_FILES,s=>this.listInternal(s),await this.listInternal(n),n)}async upload(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(e.file,e.config).then(n=>n)}async download(e){await this.apiClient.downloadFile(e)}async listInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=h$e(e);return i=cn("files",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json().then(c=>{const h=c;return h.sdkHttpResponse={headers:l.headers},h})),r.then(l=>{const c=f$e(l),h=new xPe;return Object.assign(h,c),h})}}async createInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=a$e(e);return i=cn("upload/v1beta/files",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>{const c=o$e(l),h=new vPe;return Object.assign(h,c),h})}}async get(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=u$e(e);return i=cn("files/{file}",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>l)}}async delete(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=l$e(e);return i=cn("files/{file}",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abort
6953Signal}).then(l=>l.json().then(c=>{const h=c;return h.sdkHttpResponse={headers:l.headers},h})),r.then(l=>{const c=c$e(l),h=new bPe;return Object.assign(h,c),h})}}}/**
6954 * @license
6955 * Copyright 2025 Google LLC
6956 * SPDX-License-Identifier: Apache-2.0
6957 */function yN(t){const e={},n=T(t,["data"]);if(n!=null&&k(e,["data"],n),T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function m$e(t){const e={},n=T(t,["parts"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>R$e(i))),k(e,["parts"],r)}const s=T(t,["role"]);return s!=null&&k(e,["role"],s),e}function g$e(t){const e={};if(T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=T(t,["fileUri"]);n!=null&&k(e,["fileUri"],n);const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function y$e(t){const e={},n=T(t,["id"]);n!=null&&k(e,["id"],n);const s=T(t,["args"]);s!=null&&k(e,["args"],s);const r=T(t,["name"]);if(r!=null&&k(e,["name"],r),T(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(T(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function x$e(t){const e={};if(T(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=T(t,["description"]);n!=null&&k(e,["description"],n);const s=T(t,["name"]);s!=null&&k(e,["name"],s);const r=T(t,["parameters"]);r!=null&&k(e,["parameters"],r);const i=T(t,["parametersJsonSchema"]);i!=null&&k(e,["parametersJsonSchema"],i);const a=T(t,["response"]);a!=null&&k(e,["response"],a);const o=T(t,["responseJsonSchema"]);return o!=null&&k(e,["responseJsonSchema"],o),e}function v$e(t){const e={},n=T(t,["modelSelectionConfig"]);n!=null&&k(e,["modelConfig"],n);const s=T(t,["responseJsonSchema"]);s!=null&&k(e,["responseJsonSchema"],s);const r=T(t,["audioTimestamp"]);r!=null&&k(e,["audioTimestamp"],r);const i=T(t,["candidateCount"]);i!=null&&k(e,["candidateCount"],i);const a=T(t,["enableAffectiveDialog"]);a!=null&&k(e,["enableAffectiveDialog"],a);const o=T(t,["frequencyPenalty"]);o!=null&&k(e,["frequencyPenalty"],o);const l=T(t,["logprobs"]);l!=null&&k(e,["logprobs"],l);const c=T(t,["maxOutputTokens"]);c!=null&&k(e,["maxOutputTokens"],c);const h=T(t,["mediaResolution"]);h!=null&&k(e,["mediaResolution"],h);const p=T(t,["presencePenalty"]);p!=null&&k(e,["presencePenalty"],p);const m=T(t,["responseLogprobs"]);m!=null&&k(e,["responseLogprobs"],m);const y=T(t,["responseMimeType"]);y!=null&&k(e,["responseMimeType"],y);const v=T(t,["responseModalities"]);v!=null&&k(e,["responseModalities"],v);const b=T(t,["responseSchema"]);b!=null&&k(e,["responseSchema"],b);const S=T(t,["routingConfig"]);S!=null&&k(e,["routingConfig"],S);const E=T(t,["seed"]);E!=null&&k(e,["seed"],E);const I=T(t,["speechConfig"]);I!=null&&k(e,["speechConfig"],Oie(I));const M=T(t,["stopSequences"]);M!=null&&k(e,["stopSequences"],M);const j=T(t,["temperature"]);j!=null&&k(e,["temperature"],j);const L=T(t,["thinkingConfig"]);L!=null&&k(e,["thinkingConfig"],L);const K=T(t,["topK"]);K!=null&&k(e,["topK"],K);const D=T(t,["topP"]);if(D!=null&&k(e,["topP"],D),T(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return e}function b$e(t){const e={};if(T(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=T(t,["enableWidget"]);return n!=null&&k(e,["enableWidget"],n),e}function w$e(t){const e={};if(T(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(T(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=T(t,["timeRangeFilter"]);return n!=null&&k(e,["timeRangeFilter"],n),e}function _$e(t,e){const n={},s=T(t,["generationConfig"]);e!==void 0&&s!=null&&k(e,["setup","generationConfig"],s);const r=T(t,["responseModalities"]);e!==void 0&&r!=null&&k(e,["setup","generationConfig","responseModalities"],r);const i=T(t,["temperature"]);e!==void 0&&i!=null&&k(e,["setup","generationConfig","temperature"],i);const a=T(t,["topP"]);e!==void 0&&a!=null&&k(e,["setup","generationConfig","topP"],a);const o=T(t,["topK"]);e!==void 0&&o!=null&&k(e,["setup","generationConfig","topK"],o);const l=T(t,["maxOutputTokens"]);e!==void 0&&l!=null&&k(e,["setup","generationConfig","maxOutputTokens"],l);const c=T(t,["mediaResolution"]);e!==void 0&&c!=null&&k(e,["setup","generationConfig","mediaResolution"],c);const h=T(t,["seed"]);e!==void 0&&h!=null&&k(e,["setup","generationConfig","seed"],h);const p=T(t,["speechConfig"]);e!==void 0&&p!=null&&k(e,["setup","generationConfig","speechConfig"],jj(p));const m=T(t,["thinkingConfig"]);e!==void 0&&m!=null&&k(e,["setup","generationConfig","thinkingConfig"],m);const y=T(t,["enableAffectiveDialog"]);e!==void 0&&y!=null&&k(e,["setup","generationConfig","enableAffectiveDialog"],y);const v=T(t,["systemInstruction"]);e!==void 0&&v!=null&&k(e,["setup","systemInstruction"],m$e(vl(v)));const b=T(t,["tools"]);if(e!==void 0&&b!=null){let K=o_(b);Array.isArray(K)&&(K=K.map(D=>P$e(a_(D)))),k(e,["setup","tools"],K)}const S=T(t,["sessionResumption"]);e!==void 0&&S!=null&&k(e,["setup","sessionResumption"],M$e(S));const E=T(t,["inputAudioTranscription"]);e!==void 0&&E!=null&&k(e,["setup","inputAudioTranscription"],E);const I=T(t,["outputAudioTranscription"]);e!==void 0&&I!=null&&k(e,["setup","outputAudioTranscription"],I);const M=T(t,["realtimeInputConfig"]);e!==void 0&&M!=null&&k(e,["setup","realtimeInputConfig"],M);const j=T(t,["contextWindowCompression"]);e!==void 0&&j!=null&&k(e,["setup","contextWindowCompression"],j);const L=T(t,["proactivity"]);return e!==void 0&&L!=null&&k(e,["setup","proactivity"],L),n}function S$e(t,e){const n={},s=T(t,["generationConfig"]);e!==void 0&&s!=null&&k(e,["setup","generationConfig"],v$e(s));const r=T(t,["responseModalities"]);e!==void 0&&r!=null&&k(e,["setup","generationConfig","responseModalities"],r);const i=T(t,["temperature"]);e!==void 0&&i!=null&&k(e,["setup","generationConfig","temperature"],i);const a=T(t,["topP"]);e!==void 0&&a!=null&&k(e,["setup","generationConfig","topP"],a);const o=T(t,["topK"]);e!==void 0&&o!=null&&k(e,["setup","generationConfig","topK"],o);const l=T(t,["maxOutputTokens"]);e!==void 0&&l!=null&&k(e,["setup","generationConfig","maxOutputTokens"],l);const c=T(t,["mediaResolution"]);e!==void 0&&c!=null&&k(e,["setup","generationConfig","mediaResolution"],c);const h=T(t,["seed"]);e!==void 0&&h!=null&&k(e,["setup","generationConfig","seed"],h);const p=T(t,["speechConfig"]);e!==void 0&&p!=null&&k(e,["setup","generationConfig","speechConfig"],Oie(jj(p)));const m=T(t,["thinkingConfig"]);e!==void 0&&m!=null&&k(e,["setup","generationConfig","thinkingConfig"],m);const y=T(t,["enableAffectiveDialog"]);e!==void 0&&y!=null&&k(e,["setup","generationConfig","enableAffectiveDialog"],y);const v=T(t,["systemInstruction"]);e!==void 0&&v!=null&&k(e,["setup","systemInstruction"],vl(v));const b=T(t,["tools"]);if(e!==void 0&&b!=null){let K=o_(b);Array.isArray(K)&&(K=K.map(D=>$$e(a_(D)))),k(e,["setup","tools"],K)}const S=T(t,["sessionResumption"]);e!==void 0&&S!=null&&k(e,["setup","sessionResumption"],S);const E=T(t,["inputAudioTranscription"]);e!==void 0&&E!=null&&k(e,["setup","inputAudioTranscription"],E);const I=T(t,["outputAudioTranscription"]);e!==void 0&&I!=null&&k(e,["setup","outputAudioTranscription"],I);const M=T(t,["realtimeInputConfig"]);e!==void 0&&M!=null&&k(e,["setup","realtimeInputConfig"],M);const j=T(t,["contextWindowCompression"]);e!==void 0&&j!=null&&k(e,["setup","contextWindowCompression"],j);const L=T(t,["proactivity"]);return e!==void 0&&L!=null&&k(e,["setup","proactivity"],L),n}function E$e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["setup","model"],Ur(t,s));const r=T(e,["config"]);return r!=null&&k(n,["config"],_$e(r,n)),n}function T$e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["setup","model"],Ur(t,s));const r=T(e,["config"]);return r!=null&&k(n,["config"],S$e(r,n)),n}function A$e(t){const e={},n=T(t,["musicGenerationConfig"]);return n!=null&&k(e,["musicGenerationConfig"],n),e}function C$e(t){const e={},n=T(t,["weightedPrompts"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(r=>r)),k(e,["weightedPrompts"],s)}return e}function k$e(t){const e={},n=T(t,["media"]);if(n!=null){let c=Sie(n);Array.isArray(c)&&(c=c.map(h=>yN(h))),k(e,["mediaChunks"],c)}const s=T(t,["audio"]);s!=null&&k(e,["audio"],yN(Tie(s)));const r=T(t,["audioStreamEnd"]);r!=null&&k(e,["audioStreamEnd"],r);const i=T(t,["video"]);i!=null&&k(e,["video"],yN(Eie(i)));const a=T(t,["text"]);a!=null&&k(e,["text"],a);const o=T(t,["activityStart"]);o!=null&&k(e,["activityStart"],o);const l=T(t,["activityEnd"]);return l!=null&&k(e,["activityEnd"],l),e}function I$e(t){const e={},n=T(t,["media"]);if(n!=null){let c=Sie(n);Array.isArray(c)&&(c=c.map(h=>h)),k(e,["mediaChunks"],c)}const s=T(t,["audio"]);s!=null&&k(e,["audio"],Tie(s));const r=T(t,["audioStreamEnd"]);r!=null&&k(e,["audioStreamEnd"],r);const i=T(t,["video"]);i!=null&&k(e,["video"],Eie(i));const a=T(t,["text"]);a!=null&&k(e,["text"],a);const o=T(t,["activityStart"]);o!=null&&k(e,["activityStart"],o);const l=T(t,["activityEnd"]);return l!=null&&k(e,["activityEnd"],l),e}function N$e(t){const e={},n=T(t,["setupComplete"]);n!=null&&k(e,["setupComplete"],n);const s=T(t,["serverContent"]);s!=null&&k(e,["serverContent"],s);const r=T(t,["toolCall"]);r!=null&&k(e,["toolCall"],r);const i=T(t,["toolCallCancellation"]);i!=null&&k(e,["toolCallCancellation"],i);const a=T(t,["usageMetadata"]);a!=null&&k(e,["usageMetadata"],D$e(a));const o=T(t,["goAway"]);o!=null&&k(e,["goAway"],o);const l=T(t,["sessionResumptionUpdate"]);return l!=null&&k(e,["sessionResumptionUpdate"],l),e}function R$e(t){const e={},n=T(t,["mediaResolution"]);n!=null&&k(e,["mediaResolution"],n);const s=T(t,["codeExecutionResult"]);s!=null&&k(e,["codeExecutionResult"],s);const r=T(t,["executableCode"]);r!=null&&k(e,["executableCode"],r);const i=T(t,["fileData"]);i!=null&&k(e,["fileData"],g$e(i));const a=T(t,["functionCall"]);a!=null&&k(e,["functionCall"],y$e(a));const o=T(t,["functionResponse"]);o!=null&&k(e,["functionResponse"],o);const l=T(t,["inlineData"]);l!=null&&k(e,["inlineData"],yN(l));const c=T(t,["text"]);c!=null&&k(e,["text"],c);const h=T(t,["thought"]);h!=null&&k(e,["thought"],h);const p=T(t,["thoughtSignature"]);p!=null&&k(e,["thoughtSignature"],p);const m=T(t,["videoMetadata"]);return m!=null&&k(e,["videoMetadata"],m),e}function M$e(t){const e={},n=T(t,["handle"]);if(n!=null&&k(e,["handle"],n),T(t,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return e}function Oie(t){const e={},n=T(t,["languageCode"]);n!=null&&k(e,["languageCode"],n);const s=T(t,["voiceConfig"]);if(s!=null&&k(e,["voiceConfig"],s),T(t,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return e}function P$e(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(p=>p)),k(e,["functionDeclarations"],h)}if(T(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=T(t,["googleSearchRetrieval"]);s!=null&&k(e,["googleSearchRetrieval"],s);const r=T(t,["computerUse"]);r!=null&&k(e,["computerUse"],r);const i=T(t,["fileSearch"]);i!=null&&k(e,["fileSearch"],i);const a=T(t,["codeExecution"]);if(a!=null&&k(e,["codeExecution"],a),T(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const o=T(t,["googleMaps"]);o!=null&&k(e,["googleMaps"],b$e(o));const l=T(t,["googleSearch"]);l!=null&&k(e,["googleSearch"],w$e(l));const c=T(t,["urlContext"]);
6957return c!=null&&k(e,["urlContext"],c),e}function $$e(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(m=>x$e(m))),k(e,["functionDeclarations"],p)}const s=T(t,["retrieval"]);s!=null&&k(e,["retrieval"],s);const r=T(t,["googleSearchRetrieval"]);r!=null&&k(e,["googleSearchRetrieval"],r);const i=T(t,["computerUse"]);if(i!=null&&k(e,["computerUse"],i),T(t,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const a=T(t,["codeExecution"]);a!=null&&k(e,["codeExecution"],a);const o=T(t,["enterpriseWebSearch"]);o!=null&&k(e,["enterpriseWebSearch"],o);const l=T(t,["googleMaps"]);l!=null&&k(e,["googleMaps"],l);const c=T(t,["googleSearch"]);c!=null&&k(e,["googleSearch"],c);const h=T(t,["urlContext"]);return h!=null&&k(e,["urlContext"],h),e}function D$e(t){const e={},n=T(t,["promptTokenCount"]);n!=null&&k(e,["promptTokenCount"],n);const s=T(t,["cachedContentTokenCount"]);s!=null&&k(e,["cachedContentTokenCount"],s);const r=T(t,["candidatesTokenCount"]);r!=null&&k(e,["responseTokenCount"],r);const i=T(t,["toolUsePromptTokenCount"]);i!=null&&k(e,["toolUsePromptTokenCount"],i);const a=T(t,["thoughtsTokenCount"]);a!=null&&k(e,["thoughtsTokenCount"],a);const o=T(t,["totalTokenCount"]);o!=null&&k(e,["totalTokenCount"],o);const l=T(t,["promptTokensDetails"]);if(l!=null){let y=l;Array.isArray(y)&&(y=y.map(v=>v)),k(e,["promptTokensDetails"],y)}const c=T(t,["cacheTokensDetails"]);if(c!=null){let y=c;Array.isArray(y)&&(y=y.map(v=>v)),k(e,["cacheTokensDetails"],y)}
6957const h=T(t,["candidatesTokensDetails"]);if(h!=null){let y=h;Array.isArray(y)&&(y=y.map(v=>v)),k(e,["responseTokensDetails"],y)}const p=T(t,["toolUsePromptTokensDetails"]);if(p!=null){let y=p;Array.isArray(y)&&(y=y.map(v=>v)),k(e,["toolUsePromptTokensDetails"],y)}const m=T(t,["trafficType"]);return m!=null&&k(e,["trafficType"],m),e}/**
6958 * @license
6959 * Copyright 2025 Google LLC
6960 * SPDX-License-Identifier: Apache-2.0
6961 */function O$e(t){const e={},n=T(t,["data"]);if(n!=null&&k(e,["data"],n),T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function L$e(t){const e={},n=T(t,["content"]);n!=null&&k(e,["content"],n);const s=T(t,["citationMetadata"]);s!=null&&k(e,["citationMetadata"],j$e(s));const r=T(t,["tokenCount"]);r!=null&&k(e,["tokenCount"],r);const i=T(t,["finishReason"]);i!=null&&k(e,["finishReason"],i);const a=T(t,["avgLogprobs"]);a!=null&&k(e,["avgLogprobs"],a);const o=T(t,["groundingMetadata"]);o!=null&&k(e,["groundingMetadata"],o);const l=T(t,["index"]);l!=null&&k(e,["index"],l);const c=T(t,["logprobsResult"]);c!=null&&k(e,["logprobsResult"],c);const h=T(t,["safetyRatings"]);if(h!=null){let m=h;Array.isArray(m)&&(m=m.map(y=>y)),k(e,["safetyRatings"],m)}const p=T(t,["urlContextMetadata"]);return p!=null&&k(e,["urlContextMetadata"],p),e}function j$e(t){const e={},n=T(t,["citationSources"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(r=>r)),k(e,["citations"],s)}return e}function B$e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let i=wd(r);Array.isArray(i)&&(i=i.map(a=>a)),k(n,["contents"],i)}return n}function U$e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["tokensInfo"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(i=>i)),k(e,["tokensInfo"],r)}return e}function F$e(t){const e={},n=T(t,["values"]);n!=null&&k(e,["values"],n);const s=T(t,["statistics"]);return s!=null&&k(e,["statistics"],V$e(s)),e}function V$e(t){const e={},n=T(t,["truncated"]);n!=null&&k(e,["truncated"],n);const s=T(t,["token_count"]);return s!=null&&k(e,["tokenCount"],s),e}function WM(t){const e={},n=T(t,["parts"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>J3e(i))),k(e,["parts"],r)}const s=T(t,["role"]);return s!=null&&k(e,["role"],s),e}function z$e(t){const e={},n=T(t,["controlType"]);n!=null&&k(e,["controlType"],n);const s=T(t,["enableControlImageComputation"]);return s!=null&&k(e,["computeControl"],s),e}function G$e(t){const e={};if(T(t,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(T(t,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(T(t,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return e}function H$e(t,e){const n={},s=T(t,["systemInstruction"]);e!==void 0&&s!=null&&k(e,["systemInstruction"],vl(s));const r=T(t,["tools"]);if(e!==void 0&&r!=null){let a=r;Array.isArray(a)&&(a=a.map(o=>Fie(o))),k(e,["tools"],a)}const i=T(t,["generationConfig"]);return e!==void 0&&i!=null&&k(e,["generationConfig"],O3e(i)),n}function q$e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let a=wd(r);Array.isArray(a)&&(a=a.map(o=>WM(o))),k(n,["contents"],a)}const i=T(e,["config"]);return i!=null&&G$e(i),n}function W$e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let a=wd(r);Array.isArray(a)&&(a=a.map(o=>o)),k(n,["contents"],a)}const i=T(e,["config"]);return i!=null&&H$e(i,n),n}function K$e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["totalTokens"]);s!=null&&k(e,["totalTokens"],s);const r=T(t,["cachedContentTokenCount"]);return r!=null&&k(e,["cachedContentTokenCount"],r),e}function Y$e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["totalTokens"]);return s!=null&&k(e,["totalTokens"],s),e}function X$e(t,e){const n={},s=T(e,["model"]);return s!=null&&k(n,["_url","name"],Ur(t,s)),n}function J$e(t,e){const n={},s=T(e,["model"]);return s!=null&&k(n,["_url","name"],Ur(t,s)),n}function Q$e(t){const e={},n=T(t,["sdkHttpResponse"]);return n!=null&&k(e,["sdkHttpResponse"],n),e}function Z$e(t){const e={},n=T(t,["sdkHttpResponse"]);return n!=null&&k(e,["sdkHttpResponse"],n),e}function e3e(t,e){const n={},s=T(t,["outputGcsUri"]);e!==void 0&&s!=null&&k(e,["parameters","storageUri"],s);const r=T(t,["negativePrompt"]);e!==void 0&&r!=null&&k(e,["parameters","negativePrompt"],r);const i=T(t,["numberOfImages"]);
6961e!==void 0&&i!=null&&k(e,["parameters","sampleCount"],i);const a=T(t,["aspectRatio"]);e!==void 0&&a!=null&&k(e,["parameters","aspectRatio"],a);const o=T(t,["guidanceScale"]);e!==void 0&&o!=null&&k(e,["parameters","guidanceScale"],o);const l=T(t,["seed"]);e!==void 0&&l!=null&&k(e,["parameters","seed"],l);const c=T(t,["safetyFilterLevel"]);e!==void 0&&c!=null&&k(e,["parameters","safetySetting"],c);const h=T(t,["personGeneration"]);e!==void 0&&h!=null&&k(e,["parameters","personGeneration"],h);const p=T(t,["includeSafetyAttributes"]);e!==void 0&&p!=null&&k(e,["parameters","includeSafetyAttributes"],p);const m=T(t,["includeRaiReason"]);e!==void 0&&m!=null&&k(e,["parameters","includeRaiReason"],m);const y=T(t,["language"]);e!==void 0&&y!=null&&k(e,["parameters","language"],y);const v=T(t,["outputMimeType"]);e!==void 0&&v!=null&&k(e,["parameters","outputOptions","mimeType"],v);const b=T(t,["outputCompressionQuality"]);e!==void 0&&b!=null&&k(e,["parameters","outputOptions","compressionQuality"],b);const S=T(t,["addWatermark"]);e!==void 0&&S!=null&&k(e,["parameters","addWatermark"],S);const E=T(t,["labels"]);e!==void 0&&E!=null&&k(e,["labels"],E);const I=T(t,["editMode"]);e!==void 0&&I!=null&&k(e,["parameters","editMode"],I);const M=T(t,["baseSteps"]);return e!==void 0&&M!=null&&k(e,["parameters","editConfig","baseSteps"],M),n}function t3e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["prompt"]);r!=null&&k(n,["instances[0]","prompt"],r);const i=T(e,["referenceImages"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(l=>sDe(l))),k(n,["instances[0]","referenceImages"],o)}const a=T(e,["config"]);return a!=null&&e3e(a,n),n}function n3e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(i=>KM(i))),k(e,["generatedImages"],r)}return e}function s3e(t,e){const n={},s=T(t,["taskType"]);e!==void 0&&s!=null&&k(e,["requests[]","taskType"],s);const r=T(t,["title"]);e!==void 0&&r!=null&&k(e,["requests[]","title"],r);const i=T(t,["outputDimensionality"]);if(e!==void 0&&i!=null&&k(e,["requests[]","outputDimensionality"],i),T(t,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(T(t,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function r3e(t,e){const n={},s=T(t,["taskType"]);e!==void 0&&s!=null&&k(e,["instances[]","task_type"],s);const r=T(t,["title"]);e!==void 0&&r!=null&&k(e,["instances[]","title"],r);const i=T(t,["outputDimensionality"]);e!==void 0&&i!=null&&k(e,["parameters","outputDimensionality"],i);const a=T(t,["mimeType"]);e!==void 0&&a!=null&&k(e,["instances[]","mimeType"],a);const o=T(t,["autoTruncate"]);return e!==void 0&&o!=null&&k(e,["parameters","autoTruncate"],o),n}function i3e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let o=Dj(t,r);Array.isArray(o)&&(o=o.map(l=>l)),k(n,["requests[]","content"],o)}const i=T(e,["config"]);i!=null&&s3e(i,n);const a=T(e,["model"]);return a!==void 0&&k(n,["requests[]","model"],Ur(t,a)),n}function a3e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let a=Dj(t,r);Array.isArray(a)&&(a=a.map(o=>o)),k(n,["instances[]","content"],a)}const i=T(e,["config"]);return i!=null&&r3e(i,n),n}function o3e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["embeddings"]);if(s!=null){let i=s;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["embeddings"],i)}const r=T(t,["metadata"]);return r!=null&&k(e,["metadata"],r),e}function l3e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["predictions[]","embeddings"]);if(s!=null){let i=s;Array.isArray(i)&&(i=i.map(a=>F$e(a))),k(e,["embeddings"],i)}const r=T(t,["metadata"]);return r!=null&&k(e,["metadata"],r),e}function c3e(t){const e={},n=T(t,["endpoint"]);n!=null&&k(e,["name"],n);const s=T(t,["deployedModelId"]);return s!=null&&k(e,["deployedModelId"],s),e}function u3e(t){const e={};if(T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=T(t,["fileUri"]);n!=null&&k(e,["fileUri"],n);const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function d3e(t){const e={},n=T(t,["id"]);n!=null&&k(e,["id"],n);const s=T(t,["args"]);s!=null&&k(e,["args"],s);const r=T(t,["name"]);if(r!=null&&k(e,["name"],r),T(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");
6961if(T(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function h3e(t){const e={},n=T(t,["mode"]);n!=null&&k(e,["mode"],n);const s=T(t,["allowedFunctionNames"]);if(s!=null&&k(e,["allowedFunctionNames"],s),T(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function f3e(t){const e={};if(T(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=T(t,["description"]);n!=null&&k(e,["description"],n);const s=T(t,["name"]);s!=null&&k(e,["name"],s);const r=T(t,["parameters"]);r!=null&&k(e,["parameters"],r);const i=T(t,["parametersJsonSchema"]);i!=null&&k(e,["parametersJsonSchema"],i);const a=T(t,["response"]);a!=null&&k(e,["response"],a);const o=T(t,["responseJsonSchema"]);return o!=null&&k(e,["responseJsonSchema"],o),e}function p3e(t,e,n){const s={},r=T(e,["systemInstruction"]);n!==void 0&&r!=null&&k(n,["systemInstruction"],WM(vl(r)));const i=T(e,["temperature"]);i!=null&&k(s,["temperature"],i);const a=T(e,["topP"]);a!=null&&k(s,["topP"],a);const o=T(e,["topK"]);o!=null&&k(s,["topK"],o);const l=T(e,["candidateCount"]);l!=null&&k(s,["candidateCount"],l);const c=T(e,["maxOutputTokens"]);c!=null&&k(s,["maxOutputTokens"],c);const h=T(e,["stopSequences"]);h!=null&&k(s,["stopSequences"],h);const p=T(e,["responseLogprobs"]);p!=null&&k(s,["responseLogprobs"],p);const m=T(e,["logprobs"]);m!=null&&k(s,["logprobs"],m);const y=T(e,["presencePenalty"]);y!=null&&k(s,["presencePenalty"],y);const v=T(e,["frequencyPenalty"]);v!=null&&k(s,["frequencyPenalty"],v);const b=T(e,["seed"]);b!=null&&k(s,["seed"],b);const S=T(e,["responseMimeType"]);S!=null&&k(s,["responseMimeType"],S);const E=T(e,["responseSchema"]);E!=null&&k(s,["responseSchema"],Oj(E));const I=T(e,["responseJsonSchema"]);if(I!=null&&k(s,["responseJsonSchema"],I),T(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(T(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const M=T(e,["safetySettings"]);if(n!==void 0&&M!=null){let H=M;Array.isArray(H)&&(H=H.map(Y=>rDe(Y))),k(n,["safetySettings"],H)}const j=T(e,["tools"]);if(n!==void 0&&j!=null){let H=o_(j);Array.isArray(H)&&(H=H.map(Y=>dDe(a_(Y)))),k(n,["tools"],H)}const L=T(e,["toolConfig"]);if(n!==void 0&&L!=null&&k(n,["toolConfig"],uDe(L)),T(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const K=T(e,["cachedContent"]);n!==void 0&&K!=null&&k(n,["cachedContent"],Hm(t,K));const D=T(e,["responseModalities"]);D!=null&&k(s,["responseModalities"],D);const R=T(e,["mediaResolution"]);R!=null&&k(s,["mediaResolution"],R);const B=T(e,["speechConfig"]);if(B!=null&&k(s,["speechConfig"],Lj(B)),T(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const G=T(e,["thinkingConfig"]);G!=null&&k(s,["thinkingConfig"],G);const X=T(e,["imageConfig"]);return X!=null&&k(s,["imageConfig"],F3e(X)),s}function m3e(t,e,n){const s={},r=T(e,["systemInstruction"]);n!==void 0&&r!=null&&k(n,["systemInstruction"],vl(r));const i=T(e,["temperature"]);i!=null&&k(s,["temperature"],i);const a=T(e,["topP"]);a!=null&&k(s,["topP"],a);const o=T(e,["topK"]);o!=null&&k(s,["topK"],o);const l=T(e,["candidateCount"]);l!=null&&k(s,["candidateCount"],l);const c=T(e,["maxOutputTokens"]);c!=null&&k(s,["maxOutputTokens"],c);const h=T(e,["stopSequences"]);h!=null&&k(s,["stopSequences"],h);const p=T(e,["responseLogprobs"]);p!=null&&k(s,["responseLogprobs"],p);const m=T(e,["logprobs"]);m!=null&&k(s,["logprobs"],m);const y=T(e,["presencePenalty"]);y!=null&&k(s,["presencePenalty"],y);const v=T(e,["frequencyPenalty"]);v!=null&&k(s,["frequencyPenalty"],v);const b=T(e,["seed"]);b!=null&&k(s,["seed"],b);const S=T(e,["responseMimeType"]);S!=null&&k(s,["responseMimeType"],S);const E=T(e,["responseSchema"]);E!=null&&k(s,["responseSchema"],Oj(E));const I=T(e,["responseJsonSchema"]);I!=null&&k(s,["responseJsonSchema"],I);const M=T(e,["routingConfig"]);
6961M!=null&&k(s,["routingConfig"],M);const j=T(e,["modelSelectionConfig"]);j!=null&&k(s,["modelConfig"],j);const L=T(e,["safetySettings"]);if(n!==void 0&&L!=null){let me=L;Array.isArray(me)&&(me=me.map(xe=>xe)),k(n,["safetySettings"],me)}const K=T(e,["tools"]);if(n!==void 0&&K!=null){let me=o_(K);Array.isArray(me)&&(me=me.map(xe=>Fie(a_(xe)))),k(n,["tools"],me)}const D=T(e,["toolConfig"]);n!==void 0&&D!=null&&k(n,["toolConfig"],D);const R=T(e,["labels"]);n!==void 0&&R!=null&&k(n,["labels"],R);const B=T(e,["cachedContent"]);n!==void 0&&B!=null&&k(n,["cachedContent"],Hm(t,B));const G=T(e,["responseModalities"]);G!=null&&k(s,["responseModalities"],G);const X=T(e,["mediaResolution"]);X!=null&&k(s,["mediaResolution"],X);const H=T(e,["speechConfig"]);H!=null&&k(s,["speechConfig"],Uie(Lj(H)));const Y=T(e,["audioTimestamp"]);Y!=null&&k(s,["audioTimestamp"],Y);const F=T(e,["thinkingConfig"]);F!=null&&k(s,["thinkingConfig"],F);const we=T(e,["imageConfig"]);return we!=null&&k(s,["imageConfig"],V3e(we)),s}function RW(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let a=wd(r);Array.isArray(a)&&(a=a.map(o=>WM(o))),k(n,["contents"],a)}const i=T(e,["config"]);return i!=null&&k(n,["generationConfig"],p3e(t,i,n)),n}function MW(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["contents"]);if(r!=null){let a=wd(r);Array.isArray(a)&&(a=a.map(o=>o)),k(n,["contents"],a)}const i=T(e,["config"]);return i!=null&&k(n,["generationConfig"],m3e(t,i,n)),n}function PW(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["candidates"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(c=>L$e(c))),k(e,["candidates"],l)}const r=T(t,["modelVersion"]);r!=null&&k(e,["modelVersion"],r);const i=T(t,["promptFeedback"]);i!=null&&k(e,["promptFeedback"],i);const a=T(t,["responseId"]);a!=null&&k(e,["responseId"],a);const o=T(t,["usageMetadata"]);return o!=null&&k(e,["usageMetadata"],o),e}function $W(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["candidates"]);if(s!=null){let c=s;Array.isArray(c)&&(c=c.map(h=>h)),k(e,["candidates"],c)}const r=T(t,["createTime"]);r!=null&&k(e,["createTime"],r);const i=T(t,["modelVersion"]);i!=null&&k(e,["modelVersion"],i);const a=T(t,["promptFeedback"]);a!=null&&k(e,["promptFeedback"],a);const o=T(t,["responseId"]);o!=null&&k(e,["responseId"],o);const l=T(t,["usageMetadata"]);return l!=null&&k(e,["usageMetadata"],l),e}function g3e(t,e){const n={};if(T(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(T(t,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const s=T(t,["numberOfImages"]);e!==void 0&&s!=null&&k(e,["parameters","sampleCount"],s);const r=T(t,["aspectRatio"]);e!==void 0&&r!=null&&k(e,["parameters","aspectRatio"],r);const i=T(t,["guidanceScale"]);if(e!==void 0&&i!=null&&k(e,["parameters","guidanceScale"],i),T(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const a=T(t,["safetyFilterLevel"]);e!==void 0&&a!=null&&k(e,["parameters","safetySetting"],a);const o=T(t,["personGeneration"]);e!==void 0&&o!=null&&k(e,["parameters","personGeneration"],o);const l=T(t,["includeSafetyAttributes"]);e!==void 0&&l!=null&&k(e,["parameters","includeSafetyAttributes"],l);const c=T(t,["includeRaiReason"]);e!==void 0&&c!=null&&k(e,["parameters","includeRaiReason"],c);const h=T(t,["language"]);e!==void 0&&h!=null&&k(e,["parameters","language"],h);const p=T(t,["outputMimeType"]);e!==void 0&&p!=null&&k(e,["parameters","outputOptions","mimeType"],p);const m=T(t,["outputCompressionQuality"]);if(e!==void 0&&m!=null&&k(e,["parameters","outputOptions","compressionQuality"],m),T(t,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(T(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const y=T(t,["imageSize"]);if(e!==void 0&&y!=null&&k(e,["parameters","sampleImageSize"],y),T(t,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return n}function y3e(t,e){const n={},s=T(t,["outputGcsUri"]);e!==void 0&&s!=null&&k(e,["parameters","storageUri"],s);const r=T(t,["negativePrompt"]);e!==void 0&&r!=null&&k(e,["parameters","negativePrompt"],r);const i=T(t,["numberOfImages"]);
6961e!==void 0&&i!=null&&k(e,["parameters","sampleCount"],i);const a=T(t,["aspectRatio"]);e!==void 0&&a!=null&&k(e,["parameters","aspectRatio"],a);const o=T(t,["guidanceScale"]);e!==void 0&&o!=null&&k(e,["parameters","guidanceScale"],o);const l=T(t,["seed"]);e!==void 0&&l!=null&&k(e,["parameters","seed"],l);const c=T(t,["safetyFilterLevel"]);e!==void 0&&c!=null&&k(e,["parameters","safetySetting"],c);const h=T(t,["personGeneration"]);e!==void 0&&h!=null&&k(e,["parameters","personGeneration"],h);const p=T(t,["includeSafetyAttributes"]);e!==void 0&&p!=null&&k(e,["parameters","includeSafetyAttributes"],p);const m=T(t,["includeRaiReason"]);e!==void 0&&m!=null&&k(e,["parameters","includeRaiReason"],m);const y=T(t,["language"]);e!==void 0&&y!=null&&k(e,["parameters","language"],y);const v=T(t,["outputMimeType"]);e!==void 0&&v!=null&&k(e,["parameters","outputOptions","mimeType"],v);const b=T(t,["outputCompressionQuality"]);e!==void 0&&b!=null&&k(e,["parameters","outputOptions","compressionQuality"],b);const S=T(t,["addWatermark"]);e!==void 0&&S!=null&&k(e,["parameters","addWatermark"],S);const E=T(t,["labels"]);e!==void 0&&E!=null&&k(e,["labels"],E);const I=T(t,["imageSize"]);e!==void 0&&I!=null&&k(e,["parameters","sampleImageSize"],I);const M=T(t,["enhancePrompt"]);return e!==void 0&&M!=null&&k(e,["parameters","enhancePrompt"],M),n}function x3e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["prompt"]);r!=null&&k(n,["instances[0]","prompt"],r);const i=T(e,["config"]);return i!=null&&g3e(i,n),n}function v3e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["prompt"]);r!=null&&k(n,["instances[0]","prompt"],r);const i=T(e,["config"]);return i!=null&&y3e(i,n),n}function b3e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["predictions"]);if(s!=null){let i=s;Array.isArray(i)&&(i=i.map(a=>M3e(a))),k(e,["generatedImages"],i)}const r=T(t,["positivePromptSafetyAttributes"]);return r!=null&&k(e,["positivePromptSafetyAttributes"],jie(r)),e}function w3e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["predictions"]);if(s!=null){let i=s;Array.isArray(i)&&(i=i.map(a=>KM(a))),k(e,["generatedImages"],i)}const r=T(t,["positivePromptSafetyAttributes"]);return r!=null&&k(e,["positivePromptSafetyAttributes"],Bie(r)),e}function _3e(t,e){const n={},s=T(t,["numberOfVideos"]);if(e!==void 0&&s!=null&&k(e,["parameters","sampleCount"],s),T(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(T(t,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const r=T(t,["durationSeconds"]);if(e!==void 0&&r!=null&&k(e,["parameters","durationSeconds"],r),T(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const i=T(t,["aspectRatio"]);e!==void 0&&i!=null&&k(e,["parameters","aspectRatio"],i);const a=T(t,["resolution"]);e!==void 0&&a!=null&&k(e,["parameters","resolution"],a);const o=T(t,["personGeneration"]);if(e!==void 0&&o!=null&&k(e,["parameters","personGeneration"],o),T(t,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const l=T(t,["negativePrompt"]);e!==void 0&&l!=null&&k(e,["parameters","negativePrompt"],l);const c=T(t,["enhancePrompt"]);if(e!==void 0&&c!=null&&k(e,["parameters","enhancePrompt"],c),T(t,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const h=T(t,["lastFrame"]);e!==void 0&&h!=null&&k(e,["instances[0]","lastFrame"],YM(h));const p=T(t,["referenceImages"]);if(e!==void 0&&p!=null){let m=p;Array.isArray(m)&&(m=m.map(y=>EDe(y))),k(e,["instances[0]","referenceImages"],m)}if(T(t,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(T(t,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return n}function S3e(t,e){const n={},s=T(t,["numberOfVideos"]);
6961e!==void 0&&s!=null&&k(e,["parameters","sampleCount"],s);const r=T(t,["outputGcsUri"]);e!==void 0&&r!=null&&k(e,["parameters","storageUri"],r);const i=T(t,["fps"]);e!==void 0&&i!=null&&k(e,["parameters","fps"],i);const a=T(t,["durationSeconds"]);e!==void 0&&a!=null&&k(e,["parameters","durationSeconds"],a);const o=T(t,["seed"]);e!==void 0&&o!=null&&k(e,["parameters","seed"],o);const l=T(t,["aspectRatio"]);e!==void 0&&l!=null&&k(e,["parameters","aspectRatio"],l);const c=T(t,["resolution"]);e!==void 0&&c!=null&&k(e,["parameters","resolution"],c);const h=T(t,["personGeneration"]);e!==void 0&&h!=null&&k(e,["parameters","personGeneration"],h);const p=T(t,["pubsubTopic"]);e!==void 0&&p!=null&&k(e,["parameters","pubsubTopic"],p);const m=T(t,["negativePrompt"]);e!==void 0&&m!=null&&k(e,["parameters","negativePrompt"],m);const y=T(t,["enhancePrompt"]);e!==void 0&&y!=null&&k(e,["parameters","enhancePrompt"],y);const v=T(t,["generateAudio"]);e!==void 0&&v!=null&&k(e,["parameters","generateAudio"],v);const b=T(t,["lastFrame"]);e!==void 0&&b!=null&&k(e,["instances[0]","lastFrame"],Zh(b));const S=T(t,["referenceImages"]);if(e!==void 0&&S!=null){let M=S;Array.isArray(M)&&(M=M.map(j=>TDe(j))),k(e,["instances[0]","referenceImages"],M)}const E=T(t,["mask"]);e!==void 0&&E!=null&&k(e,["instances[0]","mask"],SDe(E));const I=T(t,["compressionQuality"]);return e!==void 0&&I!=null&&k(e,["parameters","compressionQuality"],I),n}function E3e(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata"]);s!=null&&k(e,["metadata"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["response","generateVideoResponse"]);return a!=null&&k(e,["response"],k3e(a)),e}function T3e(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata"]);s!=null&&k(e,["metadata"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["response"]);return a!=null&&k(e,["response"],I3e(a)),e}function A3e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["prompt"]);r!=null&&k(n,["instances[0]","prompt"],r);const i=T(e,["image"]);i!=null&&k(n,["instances[0]","image"],YM(i));const a=T(e,["video"]);a!=null&&k(n,["instances[0]","video"],Vie(a));const o=T(e,["source"]);o!=null&&N3e(o,n);const l=T(e,["config"]);return l!=null&&_3e(l,n),n}function C3e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["prompt"]);r!=null&&k(n,["instances[0]","prompt"],r);const i=T(e,["image"]);i!=null&&k(n,["instances[0]","image"],Zh(i));const a=T(e,["video"]);a!=null&&k(n,["instances[0]","video"],zie(a));const o=T(e,["source"]);o!=null&&R3e(o,n);const l=T(e,["config"]);return l!=null&&S3e(l,n),n}function k3e(t){const e={},n=T(t,["generatedSamples"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(a=>$3e(a))),k(e,["generatedVideos"],i)}const s=T(t,["raiMediaFilteredCount"]);s!=null&&k(e,["raiMediaFilteredCount"],s);const r=T(t,["raiMediaFilteredReasons"]);return r!=null&&k(e,["raiMediaFilteredReasons"],r),e}function I3e(t){const e={},n=T(t,["videos"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(a=>D3e(a))),k(e,["generatedVideos"],i)}const s=T(t,["raiMediaFilteredCount"]);s!=null&&k(e,["raiMediaFilteredCount"],s);const r=T(t,["raiMediaFilteredReasons"]);return r!=null&&k(e,["raiMediaFilteredReasons"],r),e}function N3e(t,e){const n={},s=T(t,["prompt"]);e!==void 0&&s!=null&&k(e,["instances[0]","prompt"],s);const r=T(t,["image"]);e!==void 0&&r!=null&&k(e,["instances[0]","image"],YM(r));const i=T(t,["video"]);return e!==void 0&&i!=null&&k(e,["instances[0]","video"],Vie(i)),n}function R3e(t,e){const n={},s=T(t,["prompt"]);e!==void 0&&s!=null&&k(e,["instances[0]","prompt"],s);const r=T(t,["image"]);e!==void 0&&r!=null&&k(e,["instances[0]","image"],Zh(r));const i=T(t,["video"]);return e!==void 0&&i!=null&&k(e,["instances[0]","video"],zie(i)),n}function M3e(t){const e={},n=T(t,["_self"]);n!=null&&k(e,["image"],z3e(n));const s=T(t,["raiFilteredReason"]);s!=null&&k(e,["raiFilteredReason"],s);const r=T(t,["_self"]);return r!=null&&k(e,["safetyAttributes"],jie(r)),e}function KM(t){const e={},n=T(t,["_self"]);n!=null&&k(e,["image"],Lie(n));const s=T(t,["raiFilteredReason"]);s!=null&&k(e,["raiFilteredReason"],s);const r=T(t,["_self"]);r!=null&&k(e,["safetyAttributes"],Bie(r));const i=T(t,["prompt"]);return i!=null&&k(e,["enhancedPrompt"],i),e}function P3e(t){const e={},n=T(t,["_self"]);n!=null&&k(e,["mask"],Lie(n));const s=T(t,["labels"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(i=>i)),k(e,["labels"],r)}return e}function $3e(t){const e={},n=T(t,["video"]);return n!=null&&k(e,["video"],wDe(n)),e}function D3e(t){const e={},n=T(t,["_self"]);return n!=null&&k(e,["video"],_De(n)),e}function O3e(t){const e={},n=T(t,["modelSelectionConfig"]);n!=null&&k(e,["modelConfig"],n);const s=T(t,["responseJsonSchema"]);s!=null&&k(e,["responseJsonSchema"],s);const r=T(t,["audioTimestamp"]);r!=null&&k(e,["audioTimestamp"],r);const i=T(t,["candidateCount"]);i!=null&&k(e,["candidateCount"],i);const a=T(t,["enableAffectiveDialog"]);a!=null&&k(e,["enableAffectiveDialog"],a);const o=T(t,["frequencyPenalty"]);o!=null&&k(e,["frequencyPenalty"],o);const l=T(t,["logprobs"]);l!=null&&k(e,["logprobs"],l);const c=T(t,["maxOutputTokens"]);c!=null&&k(e,["maxOutputTokens"],c);const h=T(t,["mediaResolution"]);h!=null&&k(e,["mediaResolution"],h);const p=T(t,["presencePenalty"]);p!=null&&k(e,["presencePenalty"],p);const m=T(t,["responseLogprobs"]);m!=null&&k(e,["responseLogprobs"],m);const y=T(t,["responseMimeType"]);y!=null&&k(e,["responseMimeType"],y);const v=T(t,["responseModalities"]);v!=null&&k(e,["responseModalities"],v);const b=T(t,["responseSchema"]);b!=null&&k(e,["responseSchema"],b);const S=T(t,["routingConfig"]);S!=null&&k(e,["routingConfig"],S);const E=T(t,["seed"]);E!=null&&k(e,["seed"],E);const I=T(t,["speechConfig"]);I!=null&&k(e,["speechConfig"],Uie(I));const M=T(t,["stopSequences"]);M!=null&&k(e,["stopSequences"],M);const j=T(t,["temperature"]);j!=null&&k(e,["temperature"],j);const L=T(t,["thinkingConfig"]);L!=null&&k(e,["thinkingConfig"],L);const K=T(t,["topK"]);K!=null&&k(e,["topK"],K);const D=T(t,["topP"]);if(D!=null&&k(e,["topP"],D),T(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return e}function L3e(t,e){const n={},s=T(e,["model"]);return s!=null&&k(n,["_url","name"],Ur(t,s)),n}function j3e(t,e){const n={},s=T(e,["model"]);return s!=null&&k(n,["_url","name"],Ur(t,s)),n}function B3e(t){const e={};if(T(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=T(t,["enableWidget"]);return n!=null&&k(e,["enableWidget"],n),e}function U3e(t){const e={};if(T(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(T(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=T(t,["timeRangeFilter"]);return n!=null&&k(e,["timeRangeFilter"],n),e}function F3e(t){const e={},n=T(t,["aspectRatio"]);n!=null&&k(e,["aspectRatio"],n);const s=T(t,["imageSize"]);if(s!=null&&k(e,["imageSize"],s),T(t,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(T(t,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return e}function V3e(t){const e={},n=T(t,["aspectRatio"]);n!=null&&k(e,["aspectRatio"],n);const s=T(t,["imageSize"]);s!=null&&k(e,["imageSize"],s);const r=T(t,["outputMimeType"]);r!=null&&k(e,["imageOutputOptions","mimeType"],r);const i=T(t,["outputCompressionQuality"]);return i!=null&&k(e,["imageOutputOptions","compressionQuality"],i),e}function z3e(t){const e={}
6961,n=T(t,["bytesBase64Encoded"]);n!=null&&k(e,["imageBytes"],sy(n));const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function Lie(t){const e={},n=T(t,["gcsUri"]);n!=null&&k(e,["gcsUri"],n);const s=T(t,["bytesBase64Encoded"]);s!=null&&k(e,["imageBytes"],sy(s));const r=T(t,["mimeType"]);return r!=null&&k(e,["mimeType"],r),e}function YM(t){const e={};if(T(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=T(t,["imageBytes"]);n!=null&&k(e,["bytesBase64Encoded"],sy(n));const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function Zh(t){const e={},n=T(t,["gcsUri"]);n!=null&&k(e,["gcsUri"],n);const s=T(t,["imageBytes"]);s!=null&&k(e,["bytesBase64Encoded"],sy(s));const r=T(t,["mimeType"]);return r!=null&&k(e,["mimeType"],r),e}function G3e(t,e,n){const s={},r=T(e,["pageSize"]);n!==void 0&&r!=null&&k(n,["_query","pageSize"],r);const i=T(e,["pageToken"]);n!==void 0&&i!=null&&k(n,["_query","pageToken"],i);const a=T(e,["filter"]);n!==void 0&&a!=null&&k(n,["_query","filter"],a);const o=T(e,["queryBase"]);return n!==void 0&&o!=null&&k(n,["_url","models_url"],Iie(t,o)),s}function H3e(t,e,n){const s={},r=T(e,["pageSize"]);n!==void 0&&r!=null&&k(n,["_query","pageSize"],r);const i=T(e,["pageToken"]);n!==void 0&&i!=null&&k(n,["_query","pageToken"],i);const a=T(e,["filter"]);n!==void 0&&a!=null&&k(n,["_query","filter"],a);const o=T(e,["queryBase"]);return n!==void 0&&o!=null&&k(n,["_url","models_url"],Iie(t,o)),s}function q3e(t,e){const n={},s=T(e,["config"]);return s!=null&&G3e(t,s,n),n}function W3e(t,e){const n={},s=T(e,["config"]);return s!=null&&H3e(t,s,n),n}function K3e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["_self"]);if(r!=null){let i=Nie(r);Array.isArray(i)&&(i=i.map(a=>BO(a))),k(e,["models"],i)}return e}function Y3e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["_self"]);if(r!=null){let i=Nie(r);Array.isArray(i)&&(i=i.map(a=>UO(a))),k(e,["models"],i)}return e}function X3e(t){const e={},n=T(t,["maskMode"]);n!=null&&k(e,["maskMode"],n);const s=T(t,["segmentationClasses"]);s!=null&&k(e,["maskClasses"],s);const r=T(t,["maskDilation"]);return r!=null&&k(e,["dilation"],r),e}function BO(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["displayName"]);s!=null&&k(e,["displayName"],s);const r=T(t,["description"]);r!=null&&k(e,["description"],r);const i=T(t,["version"]);i!=null&&k(e,["version"],i);const a=T(t,["_self"]);a!=null&&k(e,["tunedModelInfo"],hDe(a));const o=T(t,["inputTokenLimit"]);o!=null&&k(e,["inputTokenLimit"],o);const l=T(t,["outputTokenLimit"]);l!=null&&k(e,["outputTokenLimit"],l);const c=T(t,["supportedGenerationMethods"]);c!=null&&k(e,["supportedActions"],c);const h=T(t,["temperature"]);h!=null&&k(e,["temperature"],h);const p=T(t,["maxTemperature"]);p!=null&&k(e,["maxTemperature"],p);const m=T(t,["topP"]);m!=null&&k(e,["topP"],m);const y=T(t,["topK"]);y!=null&&k(e,["topK"],y);const v=T(t,["thinking"]);return v!=null&&k(e,["thinking"],v),e}function UO(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["displayName"]);s!=null&&k(e,["displayName"],s);const r=T(t,["description"]);r!=null&&k(e,["description"],r);const i=T(t,["versionId"]);i!=null&&k(e,["version"],i);const a=T(t,["deployedModels"]);if(a!=null){let p=a;Array.isArray(p)&&(p=p.map(m=>c3e(m))),k(e,["endpoints"],p)}const o=T(t,["labels"]);o!=null&&k(e,["labels"],o);const l=T(t,["_self"]);l!=null&&k(e,["tunedModelInfo"],fDe(l));const c=T(t,["defaultCheckpointId"]);c!=null&&k(e,["defaultCheckpointId"],c);const h=T(t,["checkpoints"]);if(h!=null){let p=h;Array.isArray(p)&&(p=p.map(m=>m)),k(e,["checkpoints"],p)}return e}function J3e(t){const e={},n=T(t,["mediaResolution"]);n!=null&&k(e,["mediaResolution"],n);const s=T(t,["codeExecutionResult"]);s!=null&&k(e,["codeExecutionResult"],s);const r=T(t,["executableCode"]);r!=null&&k(e,["executableCode"],r);const i=T(t,["fileData"]);i!=null&&k(e,["fileData"],u3e(i));const a=T(t,["functionCall"]);a!=null&&k(e,["functionCall"],d3e(a));const o=T(t,["functionResponse"]);o!=null&&k(e,["functionResponse"],o);const l=T(t,["inlineData"]);l!=null&&k(e,["inlineData"],O$e(l));const c=T(t,["text"]);c!=null&&k(e,["text"],c);const h=T(t,["thought"]);h!=null&&k(e,["thought"],h);const p=T(t,["thoughtSignature"]);p!=null&&k(e,["thoughtSignature"],p);const m=T(t,["videoMetadata"]);return m!=null&&k(e,["videoMetadata"],m),e}function Q3e(t){const e={},n=T(t,["productImage"]);return n!=null&&k(e,["image"],Zh(n)),e}function Z3e(t,e){const n={},s=T(t,["numberOfImages"]);
6961e!==void 0&&s!=null&&k(e,["parameters","sampleCount"],s);const r=T(t,["baseSteps"]);e!==void 0&&r!=null&&k(e,["parameters","baseSteps"],r);const i=T(t,["outputGcsUri"]);e!==void 0&&i!=null&&k(e,["parameters","storageUri"],i);const a=T(t,["seed"]);e!==void 0&&a!=null&&k(e,["parameters","seed"],a);const o=T(t,["safetyFilterLevel"]);e!==void 0&&o!=null&&k(e,["parameters","safetySetting"],o);const l=T(t,["personGeneration"]);e!==void 0&&l!=null&&k(e,["parameters","personGeneration"],l);const c=T(t,["addWatermark"]);e!==void 0&&c!=null&&k(e,["parameters","addWatermark"],c);const h=T(t,["outputMimeType"]);e!==void 0&&h!=null&&k(e,["parameters","outputOptions","mimeType"],h);const p=T(t,["outputCompressionQuality"]);e!==void 0&&p!=null&&k(e,["parameters","outputOptions","compressionQuality"],p);const m=T(t,["enhancePrompt"]);e!==void 0&&m!=null&&k(e,["parameters","enhancePrompt"],m);const y=T(t,["labels"]);return e!==void 0&&y!=null&&k(e,["labels"],y),n}function eDe(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["source"]);r!=null&&nDe(r,n);const i=T(e,["config"]);return i!=null&&Z3e(i,n),n}function tDe(t){const e={},n=T(t,["predictions"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(r=>KM(r))),k(e,["generatedImages"],s)}return e}function nDe(t,e){const n={},s=T(t,["prompt"]);e!==void 0&&s!=null&&k(e,["instances[0]","prompt"],s);const r=T(t,["personImage"]);e!==void 0&&r!=null&&k(e,["instances[0]","personImage","image"],Zh(r));const i=T(t,["productImages"]);if(e!==void 0&&i!=null){let a=i;Array.isArray(a)&&(a=a.map(o=>Q3e(o))),k(e,["instances[0]","productImages"],a)}return n}function sDe(t){const e={},n=T(t,["referenceImage"]);n!=null&&k(e,["referenceImage"],Zh(n));const s=T(t,["referenceId"]);s!=null&&k(e,["referenceId"],s);const r=T(t,["referenceType"]);r!=null&&k(e,["referenceType"],r);const i=T(t,["maskImageConfig"]);i!=null&&k(e,["maskImageConfig"],X3e(i));const a=T(t,["controlImageConfig"]);a!=null&&k(e,["controlImageConfig"],z$e(a));const o=T(t,["styleImageConfig"]);o!=null&&k(e,["styleImageConfig"],o);const l=T(t,["subjectImageConfig"]);return l!=null&&k(e,["subjectImageConfig"],l),e}function jie(t){const e={},n=T(t,["safetyAttributes","categories"]);n!=null&&k(e,["categories"],n);const s=T(t,["safetyAttributes","scores"]);s!=null&&k(e,["scores"],s);const r=T(t,["contentType"]);return r!=null&&k(e,["contentType"],r),e}function Bie(t){const e={},n=T(t,["safetyAttributes","categories"]);n!=null&&k(e,["categories"],n);const s=T(t,["safetyAttributes","scores"]);s!=null&&k(e,["scores"],s);const r=T(t,["contentType"]);return r!=null&&k(e,["contentType"],r),e}function rDe(t){const e={},n=T(t,["category"]);if(n!=null&&k(e,["category"],n),T(t,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const s=T(t,["threshold"]);return s!=null&&k(e,["threshold"],s),e}function iDe(t){const e={},n=T(t,["image"]);return n!=null&&k(e,["image"],Zh(n)),e}function aDe(t,e){const n={},s=T(t,["mode"]);e!==void 0&&s!=null&&k(e,["parameters","mode"],s);const r=T(t,["maxPredictions"]);e!==void 0&&r!=null&&k(e,["parameters","maxPredictions"],r);const i=T(t,["confidenceThreshold"]);e!==void 0&&i!=null&&k(e,["parameters","confidenceThreshold"],i);const a=T(t,["maskDilation"]);e!==void 0&&a!=null&&k(e,["parameters","maskDilation"],a);const o=T(t,["binaryColorThreshold"]);e!==void 0&&o!=null&&k(e,["parameters","binaryColorThreshold"],o);const l=T(t,["labels"]);return e!==void 0&&l!=null&&k(e,["labels"],l),n}function oDe(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["source"]);r!=null&&cDe(r,n);const i=T(e,["config"]);return i!=null&&aDe(i,n),n}function lDe(t){const e={},n=T(t,["predictions"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(r=>P3e(r))),k(e,["generatedMasks"],s)}return e}function cDe(t,e){const n={},s=T(t,["prompt"]);e!==void 0&&s!=null&&k(e,["instances[0]","prompt"],s);const r=T(t,["image"]);e!==void 0&&r!=null&&k(e,["instances[0]","image"],Zh(r));const i=T(t,["scribbleImage"]);return e!==void 0&&i!=null&&k(e,["instances[0]","scribble"],iDe(i)),n}function Uie(t){const e={},n=T(t,["languageCode"]);n!=null&&k(e,["languageCode"],n);const s=T(t,["voiceConfig"]);if(s!=null&&k(e,["voiceConfig"],s),T(t,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return e}function uDe(t){const e={},n=T(t,["functionCallingConfig"]);n!=null&&k(e,["functionCallingConfig"],h3e(n));const s=T(t,["retrievalConfig"]);return s!=null&&k(e,["retrievalConfig"],s),e}function dDe(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(p=>p)),k(e,["functionDeclarations"],h)}if(T(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=T(t,["googleSearchRetrieval"]);s!=null&&k(e,["googleSearchRetrieval"],s);const r=T(t,["computerUse"]);r!=null&&k(e,["computerUse"],r);const i=T(t,["fileSearch"]);i!=null&&k(e,["fileSearch"],i);const a=T(t,["codeExecution"]);if(a!=null&&k(e,["codeExecution"],a),T(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const o=T(t,["googleMaps"]);o!=null&&k(e,["googleMaps"],B3e(o));const l=T(t,["googleSearch"]);l!=null&&k(e,["googleSearch"],U3e(l));const c=T(t,["urlContext"]);
6961return c!=null&&k(e,["urlContext"],c),e}function Fie(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(m=>f3e(m))),k(e,["functionDeclarations"],p)}const s=T(t,["retrieval"]);s!=null&&k(e,["retrieval"],s);const r=T(t,["googleSearchRetrieval"]);r!=null&&k(e,["googleSearchRetrieval"],r);const i=T(t,["computerUse"]);if(i!=null&&k(e,["computerUse"],i),T(t,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const a=T(t,["codeExecution"]);a!=null&&k(e,["codeExecution"],a);const o=T(t,["enterpriseWebSearch"]);o!=null&&k(e,["enterpriseWebSearch"],o);const l=T(t,["googleMaps"]);l!=null&&k(e,["googleMaps"],l);const c=T(t,["googleSearch"]);c!=null&&k(e,["googleSearch"],c);const h=T(t,["urlContext"]);return h!=null&&k(e,["urlContext"],h),e}function hDe(t){const e={},n=T(t,["baseModel"]);n!=null&&k(e,["baseModel"],n);const s=T(t,["createTime"]);s!=null&&k(e,["createTime"],s);const r=T(t,["updateTime"]);return r!=null&&k(e,["updateTime"],r),e}function fDe(t){const e={},n=T(t,["labels","google-vertex-llm-tuning-base-model-id"]);n!=null&&k(e,["baseModel"],n);const s=T(t,["createTime"]);s!=null&&k(e,["createTime"],s);const r=T(t,["updateTime"]);return r!=null&&k(e,["updateTime"],r),e}function pDe(t,e){const n={},s=T(t,["displayName"]);e!==void 0&&s!=null&&k(e,["displayName"],s);const r=T(t,["description"]);e!==void 0&&r!=null&&k(e,["description"],r);const i=T(t,["defaultCheckpointId"]);return e!==void 0&&i!=null&&k(e,["defaultCheckpointId"],i),n}function mDe(t,e){const n={},s=T(t,["displayName"]);e!==void 0&&s!=null&&k(e,["displayName"],s);const r=T(t,["description"]);e!==void 0&&r!=null&&k(e,["description"],r);const i=T(t,["defaultCheckpointId"]);return e!==void 0&&i!=null&&k(e,["defaultCheckpointId"],i),n}function gDe(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","name"],Ur(t,s));const r=T(e,["config"]);return r!=null&&pDe(r,n),n}function yDe(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["config"]);return r!=null&&mDe(r,n),n}function xDe(t,e){const n={},s=T(t,["outputGcsUri"]);e!==void 0&&s!=null&&k(e,["parameters","storageUri"],s);const r=T(t,["safetyFilterLevel"]);e!==void 0&&r!=null&&k(e,["parameters","safetySetting"],r);const i=T(t,["personGeneration"]);e!==void 0&&i!=null&&k(e,["parameters","personGeneration"],i);const a=T(t,["includeRaiReason"]);e!==void 0&&a!=null&&k(e,["parameters","includeRaiReason"],a);const o=T(t,["outputMimeType"]);e!==void 0&&o!=null&&k(e,["parameters","outputOptions","mimeType"],o);const l=T(t,["outputCompressionQuality"]);e!==void 0&&l!=null&&k(e,["parameters","outputOptions","compressionQuality"],l);const c=T(t,["enhanceInputImage"]);e!==void 0&&c!=null&&k(e,["parameters","upscaleConfig","enhanceInputImage"],c);const h=T(t,["imagePreservationFactor"]);e!==void 0&&h!=null&&k(e,["parameters","upscaleConfig","imagePreservationFactor"],h);const p=T(t,["labels"]);e!==void 0&&p!=null&&k(e,["labels"],p);const m=T(t,["numberOfImages"]);e!==void 0&&m!=null&&k(e,["parameters","sampleCount"],m);const y=T(t,["mode"]);return e!==void 0&&y!=null&&k(e,["parameters","mode"],y),n}function vDe(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["_url","model"],Ur(t,s));const r=T(e,["image"]);r!=null&&k(n,["instances[0]","image"],Zh(r));const i=T(e,["upscaleFactor"]);i!=null&&k(n,["parameters","upscaleConfig","upscaleFactor"],i);const a=T(e,["config"]);return a!=null&&xDe(a,n),n}function bDe(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(i=>KM(i))),k(e,["generatedImages"],r)}return e}function wDe(t){const e={},n=T(t,["uri"]);n!=null&&k(e,["uri"],n);const s=T(t,["encodedVideo"]);s!=null&&k(e,["videoBytes"],sy(s));const r=T(t,["encoding"]);return r!=null&&k(e,["mimeType"],r),e}function _De(t){const e={},n=T(t,["gcsUri"]);n!=null&&k(e,["uri"],n);const s=T(t,["bytesBase64Encoded"]);s!=null&&k(e,["videoBytes"],sy(s));const r=T(t,["mimeType"]);return r!=null&&k(e,["mimeType"],r),e}function SDe(t){const e={},n=T(t,["image"]);n!=null&&k(e,["_self"],Zh(n));const s=T(t,["maskMode"]);return s!=null&&k(e,["maskMode"],s),e}function EDe(t){const e={},n=T(t,["image"]);n!=null&&k(e,["image"],YM(n));const s=T(t,["referenceType"]);return s!=null&&k(e,["referenceType"],s),e}function TDe(t){const e={},n=T(t,["image"]);n!=null&&k(e,["image"],Zh(n));const s=T(t,["referenceType"]);return s!=null&&k(e,["referenceType"],s),e}function Vie(t){const e={},n=T(t,["uri"]);n!=null&&k(e,["uri"],n);const s=T(t,["videoBytes"]);s!=null&&k(e,["encodedVideo"],sy(s));const r=T(t,["mimeType"]);return r!=null&&k(e,["encoding"],r),e}function zie(t){const e={},n=T(t,["uri"]);n!=null&&k(e,["gcsUri"],n);const s=T(t,["videoBytes"]);
6961s!=null&&k(e,["bytesBase64Encoded"],sy(s));const r=T(t,["mimeType"]);return r!=null&&k(e,["mimeType"],r),e}/**
6962 * @license
6963 * Copyright 2025 Google LLC
6964 * SPDX-License-Identifier: Apache-2.0
6965 */function ADe(t,e){const n={},s=T(t,["displayName"]);return e!==void 0&&s!=null&&k(e,["displayName"],s),n}function CDe(t){const e={},n=T(t,["config"]);return n!=null&&ADe(n,e),e}function kDe(t,e){const n={},s=T(t,["force"]);return e!==void 0&&s!=null&&k(e,["_query","force"],s),n}function IDe(t){const e={},n=T(t,["name"]);n!=null&&k(e,["_url","name"],n);const s=T(t,["config"]);return s!=null&&kDe(s,e),e}function NDe(t){const e={},n=T(t,["name"]);return n!=null&&k(e,["_url","name"],n),e}function RDe(t,e){const n={},s=T(t,["customMetadata"]);if(e!==void 0&&s!=null){let i=s;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["customMetadata"],i)}const r=T(t,["chunkingConfig"]);return e!==void 0&&r!=null&&k(e,["chunkingConfig"],r),n}function MDe(t){const e={},n=T(t,["name"]);n!=null&&k(e,["name"],n);const s=T(t,["metadata"]);s!=null&&k(e,["metadata"],s);const r=T(t,["done"]);r!=null&&k(e,["done"],r);const i=T(t,["error"]);i!=null&&k(e,["error"],i);const a=T(t,["response"]);return a!=null&&k(e,["response"],$De(a)),e}function PDe(t){const e={},n=T(t,["fileSearchStoreName"]);n!=null&&k(e,["_url","file_search_store_name"],n);const s=T(t,["fileName"]);s!=null&&k(e,["fileName"],s);const r=T(t,["config"]);return r!=null&&RDe(r,e),e}function $De(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["parent"]);s!=null&&k(e,["parent"],s);const r=T(t,["documentName"]);return r!=null&&k(e,["documentName"],r),e}function DDe(t,e){const n={},s=T(t,["pageSize"]);e!==void 0&&s!=null&&k(e,["_query","pageSize"],s);const r=T(t,["pageToken"]);return e!==void 0&&r!=null&&k(e,["_query","pageToken"],r),n}function ODe(t){const e={},n=T(t,["config"]);return n!=null&&DDe(n,e),e}function LDe(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["fileSearchStores"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["fileSearchStores"],i)}return e}function Gie(t,e){const n={},s=T(t,["mimeType"]);e!==void 0&&s!=null&&k(e,["mimeType"],s);const r=T(t,["displayName"]);e!==void 0&&r!=null&&k(e,["displayName"],r);const i=T(t,["customMetadata"]);if(e!==void 0&&i!=null){let o=i;Array.isArray(o)&&(o=o.map(l=>l)),k(e,["customMetadata"],o)}const a=T(t,["chunkingConfig"]);return e!==void 0&&a!=null&&k(e,["chunkingConfig"],a),n}function jDe(t){const e={},n=T(t,["fileSearchStoreName"]);n!=null&&k(e,["_url","file_search_store_name"],n);const s=T(t,["config"]);return s!=null&&Gie(s,e),e}function BDe(t){const e={},n=T(t,["sdkHttpResponse"]);return n!=null&&k(e,["sdkHttpResponse"],n),e}/**
6966 * @license
6967 * Copyright 2025 Google LLC
6968 * SPDX-License-Identifier: Apache-2.0
6969 */const UDe="Content-Type",FDe="X-Server-Timeout",VDe="User-Agent",FO="x-goog-api-client",zDe="1.31.0",GDe=`google-genai-sdk/${zDe}`,HDe="v1beta1",qDe="v1beta",DW=/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class WDe{constructor(e){var n,s;this.clientOptions=Object.assign(Object.assign({},e),{project:e.project,location:e.location,apiKey:e.apiKey,vertexai:e.vertexai});const r={};this.clientOptions.vertexai?(r.apiVersion=(n=this.clientOptions.apiVersion)!==null&&n!==void 0?n:HDe,r.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(r.apiVersion=(s=this.clientOptions.apiVersion)!==null&&s!==void 0?s:qDe,r.baseUrl="https://generativelanguage.googleapis.com/"),r.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=r,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(r,e.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var e;return(e=this.clientOptions.vertexai)!==null&&e!==void 0?e:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const s=[e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==""&&s.push(e.apiVersion),s.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const e=this.getBaseUrl(),n=new URL(e);return n.protocol=n.protocol=="http:"?"ws":"wss",n.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw new Error("HTTP options are not correctly set.")}constructUrl(e,n,s){const r=[this.getRequestUrlInternal(n)];return s&&r.push(this.getBaseResourcePath()),e!==""&&r.push(e),new URL(`${r.join("/")}`)}shouldPrependVertexProjectPath(e){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith("projects/")||e.httpMethod==="GET"&&e.path.startsWith("publishers/google/models"))}async request(e){let n=this.clientOptions.httpOptions;e.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const s=this.shouldPrependVertexProjectPath(e),r=this.constructUrl(e.path,n,s);
6969if(e.queryParams)for(const[a,o]of Object.entries(e.queryParams))r.searchParams.append(a,String(o));let i={};if(e.httpMethod==="GET"){if(e.body&&e.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else i.body=e.body;return i=await this.includeExtraHttpOptionsToRequestInit(i,n,r.toString(),e.abortSignal),this.unaryApiCall(r,i,e.httpMethod)}patchHttpOptions(e,n){const s=JSON.parse(JSON.stringify(e));for(const[r,i]of Object.entries(n))typeof i=="object"?s[r]=Object.assign(Object.assign({},s[r]),i):i!==void 0&&(s[r]=i);return s}async requestStream(e){let n=this.clientOptions.httpOptions;e.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const s=this.shouldPrependVertexProjectPath(e),r=this.constructUrl(e.path,n,s);(!r.searchParams.has("alt")||r.searchParams.get("alt")!=="sse")&&r.searchParams.set("alt","sse");let i={};return i.body=e.body,i=await this.includeExtraHttpOptionsToRequestInit(i,n,r.toString(),e.abortSignal),this.streamApiCall(r,i,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,n,s,r){if(n&&n.timeout||r){const i=new AbortController,a=i.signal;if(n.timeout&&(n==null?void 0:n.timeout)>0){const o=setTimeout(()=>i.abort(),n.timeout);o&&typeof o.unref=="function"&&o.unref()}r&&r.addEventListener("abort",()=>{i.abort()}),e.signal=a}return n&&n.extraBody!==null&&KDe(e,n.extraBody),e.headers=await this.getHeadersInternal(n,s),e}async unaryApiCall(e,n,s){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:s})).then(async r=>(await OW(r),new OO(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}async streamApiCall(e,n,s){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:s})).then(async r=>(await OW(r),this.processStreamResponse(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}processStreamResponse(e){var n;return _w(this,arguments,function*(){const r=(n=e==null?void 0:e.body)===null||n===void 0?void 0:n.getReader(),i=new TextDecoder("utf-8");if(!r)throw new Error("Response body is empty");try{let a="";for(;;){const{done:o,value:l}=yield $i(r.read());if(o){if(a.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const c=i.decode(l,{stream:!0});try{const p=JSON.parse(c);if("error"in p){const m=JSON.parse(JSON.stringify(p.error)),y=m.status,v=m.code,b=`got status: ${y}. ${JSON.stringify(p)}`;if(v>=400&&v<600)throw new qM({message:b,status:v})}}catch(p){if(p.name==="ApiError")throw p}a+=c;let h=a.match(DW);for(;h;){const p=h[1];try{const m=new Response(p,{headers:e==null?void 0:e.headers,status:e==null?void 0:e.status,statusText:e==null?void 0:e.statusText});yield yield $i(new OO(m)),a=a.slice(h[0].length),h=a.match(DW)}catch(m){throw new Error(`exception parsing stream chunk ${p}. ${m}`)}}}}finally{r.releaseLock()}})}async apiCall(e,n){return fetch(e,n).catch(s=>{throw new Error(`exception ${s} sending request`)})}getDefaultHeaders(){const e={},n=GDe+" "+this.clientOptions.userAgentExtra;return e[VDe]=n,e[FO]=n,e[UDe]="application/json",e}async getHeadersInternal(e,n){const s=new Headers;if(e&&e.headers){for(const[r,i]of Object.entries(e.headers))s.append(r,i);e.timeout&&e.timeout>0&&s.append(FDe,String(Math.ceil(e.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(s,n),s}getFileName(e){var n;let s="";return typeof e=="string"&&(s=e.replace(/[/\\]+$/,""),s=(n=s.split(/[/\\]/).pop())!==null&&n!==void 0?n:""),s}async uploadFile(e,n){var s;const r={};n!=null&&(r.mimeType=n.mimeType,r.name=n.name,r.displayName=n.displayName),r.name&&!r.name.startsWith("files/")&&(r.name=`files/${r.name}`);const i=this.clientOptions.uploader,a=await i.stat(e);r.sizeBytes=String(a.size);const o=(s=n==null?void 0:n.mimeType)!==null&&s!==void 0?s:a.type;if(o===void 0||o==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");r.mimeType=o;const l={file:r},c=this.getFileName(e),h=cn("upload/v1beta/files",l._url),p=await this.fetchUploadUrl(h,r.sizeBytes,r.mimeType,c,l,n==null?void 0:n.httpOptions);return i.upload(e,p,this)}async uploadFileToFileSearchStore(e,n,s){var r;const i=this.clientOptions.uploader,a=await i.stat(n),o=String(a.size),l=(r=s==null?void 0:s.mimeType)!==null&&r!==void 0?r:a.type;if(l===void 0||l==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const c=`upload/v1beta/${e}:uploadToFileSearchStore`,h=this.getFileName(n),p={};s!=null&&Gie(s,p);const m=await this.fetchUploadUrl(c,o,l,h,p,s==null?void 0:s.httpOptions);return i.uploadToFileSearchStore(n,m,this)}async downloadFile(e){await this.clientOptions.downloader.download(e,this)}async fetchUploadUrl(e,n,s,r,i,a){var o;let l={};a?l=a:l={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${n}`,"X-Goog-Upload-Header-Content-Type":`${s}`},r?{"X-Goog-Upload-File-Name":r}:{})};const c=await this.request({path:e,body:JSON.stringify(i),httpMethod:"POST",httpOptions:l});if(!c||!(c!=null&&c.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const h=(o=c==null?void 0:c.headers)===null||o===void 0?void 0:o["x-goog-upload-url"];if(h===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return h}}async function OW(t){var e;if(t===void 0)throw new Error("response is undefined");if(!t.ok){const n=t.status;let s;!((e=t.headers.get("content-type"))===null||e===void 0)&&e.includes("application/json")?s=await t.json():s={error:{message:await t.text(),code:t.status,status:t.statusText}};const r=JSON.stringify(s);throw n>=400&&n<600?new qM({message:r,status:n}):new Error(r)}}function KDe(t,e){if(!e||Object.keys(e).length===0)return;if(t.body instanceof Blob){console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");return}let n={};
6969if(typeof t.body=="string"&&t.body.length>0)try{const i=JSON.parse(t.body);if(typeof i=="object"&&i!==null&&!Array.isArray(i))n=i;else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch{console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}function s(i,a){const o=Object.assign({},i);for(const l in a)if(Object.prototype.hasOwnProperty.call(a,l)){const c=a[l],h=o[l];c&&typeof c=="object"&&!Array.isArray(c)&&h&&typeof h=="object"&&!Array.isArray(h)?o[l]=s(h,c):(h&&c&&typeof h!=typeof c&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${l}". Original type: ${typeof h}, New type: ${typeof c}. Overwriting.`),o[l]=c)}return o}const r=s(n,e);t.body=JSON.stringify(r)}/**
6970 * @license
6971 * Copyright 2025 Google LLC
6972 * SPDX-License-Identifier: Apache-2.0
6973 */const YDe="mcp_used/unknown";let XDe=!1;function Hie(t){for(const e of t)if(JDe(e)||typeof e=="object"&&"inputSchema"in e)return!0;return XDe}function qie(t){var e;const n=(e=t[FO])!==null&&e!==void 0?e:"";t[FO]=(n+` ${YDe}`).trimStart()}function JDe(t){return t!==null&&typeof t=="object"&&t instanceof Bj}function QDe(t,e=100){return _w(this,arguments,function*(){let s,r=0;for(;r<e;){const i=yield $i(t.listTools({cursor:s}));for(const a of i.tools)yield yield $i(a),r++;if(!i.nextCursor)break;s=i.nextCursor}})}class Bj{constructor(e=[],n){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=n}static create(e,n){return new Bj(e,n)}async initialize(){var e,n,s,r;if(this.mcpTools.length>0)return;const i={},a=[];for(const h of this.mcpClients)try{for(var o=!0,l=(n=void 0,XS(QDe(h))),c;c=await l.next(),e=c.done,!e;o=!0){r=c.value,o=!1;const p=r;a.push(p);const m=p.name;if(i[m])throw new Error(`Duplicate function name ${m} found in MCP tools. Please ensure function names are unique.`);i[m]=h}}catch(p){n={error:p}}finally{try{!o&&!e&&(s=l.return)&&await s.call(l)}finally{if(n)throw n.error}}this.mcpTools=a,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),NPe(this.mcpTools,this.config)}async callTool(e){await this.initialize();const n=[];for(const s of e)if(s.name in this.functionNameToMcpClient){const r=this.functionNameToMcpClient[s.name];let i;this.config.timeout&&(i={timeout:this.config.timeout});const a=await r.callTool({name:s.name,arguments:s.args},void 0,i);n.push({functionResponse:{name:s.name,response:a.isError?{error:a}:a}})}return n}}/**
6974 * @license
6975 * Copyright 2025 Google LLC
6976 * SPDX-License-Identifier: Apache-2.0
6977 */async function ZDe(t,e,n){const s=new _Pe;let r;n.data instanceof Blob?r=JSON.parse(await n.data.text()):r=JSON.parse(n.data),Object.assign(s,r),e(s)}class e5e{constructor(e,n,s){this.apiClient=e,this.auth=n,this.webSocketFactory=s}async connect(e){var n,s;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const r=this.apiClient.getWebsocketBaseUrl(),i=this.apiClient.getApiVersion(),a=s5e(this.apiClient.getDefaultHeaders()),o=this.apiClient.getApiKey(),l=`${r}/ws/google.ai.generativelanguage.${i}.GenerativeService.BidiGenerateMusic?key=${o}`;let c=()=>{};const h=new Promise(M=>{c=M}),p=e.callbacks,m=function(){c({})},y=this.apiClient,v={onopen:m,onmessage:M=>{ZDe(y,p.onmessage,M)},onerror:(n=p==null?void 0:p.onerror)!==null&&n!==void 0?n:function(M){},onclose:(s=p==null?void 0:p.onclose)!==null&&s!==void 0?s:function(M){}},b=this.webSocketFactory.create(l,n5e(a),v);b.connect(),await h;const I={setup:{model:Ur(this.apiClient,e.model)}};return b.send(JSON.stringify(I)),new t5e(b,this.apiClient)}}class t5e{constructor(e,n){this.conn=e,this.apiClient=n}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const n=C$e(e);this.conn.send(JSON.stringify({clientContent:n}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||(e.musicGenerationConfig={});const n=A$e(e);this.conn.send(JSON.stringify(n))}sendPlaybackControl(e){const n={playbackControl:e};this.conn.send(JSON.stringify(n))}play(){this.sendPlaybackControl(cw.PLAY)}pause(){this.sendPlaybackControl(cw.PAUSE)}stop(){this.sendPlaybackControl(cw.STOP)}resetContext(){this.sendPlaybackControl(cw.RESET_CONTEXT)}
6977close(){this.conn.close()}}function n5e(t){const e={};return t.forEach((n,s)=>{e[s]=n}),e}function s5e(t){const e=new Headers;for(const[n,s]of Object.entries(t))e.append(n,s);return e}/**
6978 * @license
6979 * Copyright 2025 Google LLC
6980 * SPDX-License-Identifier: Apache-2.0
6981 */const r5e="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function i5e(t,e,n){const s=new wPe;let r;n.data instanceof Blob?r=await n.data.text():n.data instanceof ArrayBuffer?r=new TextDecoder().decode(n.data):r=n.data;const i=JSON.parse(r);if(t.isVertexAI()){const a=N$e(i);Object.assign(s,a)}else Object.assign(s,i);e(s)}class a5e{constructor(e,n,s){this.apiClient=e,this.auth=n,this.webSocketFactory=s,this.music=new e5e(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var n,s,r,i,a,o;if(e.config&&e.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const l=this.apiClient.getWebsocketBaseUrl(),c=this.apiClient.getApiVersion();let h;const p=this.apiClient.getHeaders();e.config&&e.config.tools&&Hie(e.config.tools)&&qie(p);const m=u5e(p);if(this.apiClient.isVertexAI())h=`${l}/ws/google.cloud.aiplatform.${c}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(m,h);else{const B=this.apiClient.getApiKey();let G="BidiGenerateContent",X="key";B!=null&&B.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),c!=="v1alpha"&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),G="BidiGenerateContentConstrained",X="access_token"),h=`${l}/ws/google.ai.generativelanguage.${c}.GenerativeService.${G}?${X}=${B}`}let y=()=>{};const v=new Promise(B=>{y=B}),b=e.callbacks,S=function(){var B;(B=b==null?void 0:b.onopen)===null||B===void 0||B.call(b),y({})},E=this.apiClient,I={onopen:S,onmessage:B=>{i5e(E,b.onmessage,B)},onerror:(n=b==null?void 0:b.onerror)!==null&&n!==void 0?n:function(B){},onclose:(s=b==null?void 0:b.onclose)!==null&&s!==void 0?s:function(B){}},M=this.webSocketFactory.create(h,c5e(m),I);M.connect(),await v;let j=Ur(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&j.startsWith("publishers/")){const B=this.apiClient.getProject(),G=this.apiClient.getLocation();j=`projects/${B}/locations/${G}/`+j}let L={};this.apiClient.isVertexAI()&&((r=e.config)===null||r===void 0?void 0:r.responseModalities)===void 0&&(e.config===void 0?e.config={responseModalities:[CR.AUDIO]}:e.config.responseModalities=[CR.AUDIO]),!((i=e.config)===null||i===void 0)&&i.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");const K=(o=(a=e.config)===null||a===void 0?void 0:a.tools)!==null&&o!==void 0?o:[],D=[];for(const B of K)if(this.isCallableTool(B)){const G=B;D.push(await G.tool())}else D.push(B);D.length>0&&(e.config.tools=D);const R={model:j,config:e.config,callbacks:e.callbacks};return this.apiClient.isVertexAI()?L=T$e(this.apiClient,R):L=E$e(this.apiClient,R),delete L.config,M.send(JSON.stringify(L)),new l5e(M,this.apiClient)}isCallableTool(e){return"callTool"in e&&typeof e.callTool=="function"}}const o5e={turnComplete:!0};class l5e{constructor(e,n){this.conn=e,this.apiClient=n}tLiveClientContent(e,n){if(n.turns!==null&&n.turns!==void 0){let s=[];try{s=wd(n.turns),e.isVertexAI()||(s=s.map(r=>WM(r)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof n.turns}'`)}return{clientContent:{turns:s,turnComplete:n.turnComplete}}}return{clientContent:{turnComplete:n.turnComplete}}}tLiveClienttToolResponse(e,n){let s=[];if(n.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(n.functionResponses)?s=n.functionResponses:s=[n.functionResponses],s.length===0)throw new Error("functionResponses is required.");for(const i of s){if(typeof i!="object"||i===null||!("name"in i)||!("response"in i))throw new Error(`Could not parse function response, type '${typeof i}'.`);if(!e.isVertexAI()&&!("id"in i))throw new Error(r5e)}return{toolResponse:{functionResponses:s}}}sendClientContent(e){e=Object.assign(Object.assign({},o5e),e);const n=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(n))}sendRealtimeInput(e){let n={};this.apiClient.isVertexAI()?n={realtimeInput:I$e(e)}:n={realtimeInput:k$e(e)},this.conn.send(JSON.stringify(n))}sendToolResponse(e){if(e.functionResponses==null)throw new Error("Tool response parameters are required.");const n=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(n))}
6981close(){this.conn.close()}}function c5e(t){const e={};return t.forEach((n,s)=>{e[s]=n}),e}function u5e(t){const e=new Headers;for(const[n,s]of Object.entries(t))e.append(n,s);return e}/**
6982 * @license
6983 * Copyright 2025 Google LLC
6984 * SPDX-License-Identifier: Apache-2.0
6985 */const LW=10;function jW(t){var e,n,s;if(!((e=t==null?void 0:t.automaticFunctionCalling)===null||e===void 0)&&e.disable)return!0;let r=!1;for(const a of(n=t==null?void 0:t.tools)!==null&&n!==void 0?n:[])if(Sw(a)){r=!0;break}if(!r)return!0;const i=(s=t==null?void 0:t.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls;return i&&(i<0||!Number.isInteger(i))||i==0?(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",i),!0):!1}function Sw(t){return"callTool"in t&&typeof t.callTool=="function"}function d5e(t){var e,n,s;return(s=(n=(e=t.config)===null||e===void 0?void 0:e.tools)===null||n===void 0?void 0:n.some(r=>Sw(r)))!==null&&s!==void 0?s:!1}function BW(t){var e;const n=[];return!((e=t==null?void 0:t.config)===null||e===void 0)&&e.tools&&t.config.tools.forEach((s,r)=>{if(Sw(s))return;const i=s;i.functionDeclarations&&i.functionDeclarations.length>0&&n.push(r)}),n}function UW(t){var e;return!(!((e=t==null?void 0:t.automaticFunctionCalling)===null||e===void 0)&&e.ignoreCallHistory)}/**
6986 * @license
6987 * Copyright 2025 Google LLC
6988 * SPDX-License-Identifier: Apache-2.0
6989 */class h5e extends Gm{constructor(e){super(),this.apiClient=e,this.generateContent=async n=>{var s,r,i,a,o;const l=await this.processParamsMaybeAddMcpUsage(n);if(this.maybeMoveToResponseJsonSchem(n),!d5e(n)||jW(n.config))return await this.generateContentInternal(l);const c=BW(n);if(c.length>0){const b=c.map(S=>`tools[${S}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${b}.`)}let h,p;const m=wd(l.contents),y=(i=(r=(s=l.config)===null||s===void 0?void 0:s.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&i!==void 0?i:LW;let v=0;for(;v<y&&(h=await this.generateContentInternal(l),!(!h.functionCalls||h.functionCalls.length===0));){const b=h.candidates[0].content,S=[];for(const E of(o=(a=n.config)===null||a===void 0?void 0:a.tools)!==null&&o!==void 0?o:[])if(Sw(E)){const M=await E.callTool(h.functionCalls);S.push(...M)}v++,p={role:"user",parts:S},l.contents=wd(l.contents),l.contents.push(b),l.contents.push(p),UW(l.config)&&(m.push(b),m.push(p))}return UW(l.config)&&(h.automaticFunctionCallingHistory=m),h},this.generateContentStream=async n=>{var s,r,i,a,o;if(this.maybeMoveToResponseJsonSchem(n),jW(n.config)){const p=await this.processParamsMaybeAddMcpUsage(n);return await this.generateContentStreamInternal(p)}const l=BW(n);if(l.length>0){const p=l.map(m=>`tools[${m}]`).join(", ");throw new Error(`Incompatible tools found at ${p}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const c=(i=(r=(s=n==null?void 0:n.config)===null||s===void 0?void 0:s.toolConfig)===null||r===void 0?void 0:r.functionCallingConfig)===null||i===void 0?void 0:i.streamFunctionCallArguments,h=(o=(a=n==null?void 0:n.config)===null||a===void 0?void 0:a.automaticFunctionCalling)===null||o===void 0?void 0:o.disable;if(c&&!h)throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(n)},this.generateImages=async n=>await this.generateImagesInternal(n).then(s=>{var r;let i;const a=[];if(s!=null&&s.generatedImages)for(const l of s.generatedImages)l&&(l!=null&&l.safetyAttributes)&&((r=l==null?void 0:l.safetyAttributes)===null||r===void 0?void 0:r.contentType)==="Positive Prompt"?i=l==null?void 0:l.safetyAttributes:a.push(l);let o;return i?o={generatedImages:a,positivePromptSafetyAttributes:i,sdkHttpResponse:s.sdkHttpResponse}:o={generatedImages:a,sdkHttpResponse:s.sdkHttpResponse},o}),this.list=async n=>{var s;const a={config:Object.assign(Object.assign({},{queryBase:!0}),n==null?void 0:n.config)};if(this.apiClient.isVertexAI()&&!a.config.queryBase){if(!((s=a.config)===null||s===void 0)&&s.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");a.config.filter="labels.tune-type:*"}return new Wv(jm.PAGED_ITEM_MODELS,o=>this.listInternal(o),await this.listInternal(a),a)},this.editImage=async n=>{const s={model:n.model,prompt:n.prompt,referenceImages:[],config:n.config};return n.referenceImages&&n.referenceImages&&(s.referenceImages=n.referenceImages.map(r=>r.toReferenceImageAPI())),await this.editImageInternal(s)},this.upscaleImage=async n=>{let s={numberOfImages:1,mode:"upscale"};n.config&&(s=Object.assign(Object.assign({},s),n.config));const r={model:n.model,image:n.image,upscaleFactor:n.upscaleFactor,config:s};return await this.upscaleImageInternal(r)},this.generateVideos=async n=>{var s,r,i,a,o,l;if((n.prompt||n.image||n.video)&&n.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((s=n.video)===null||s===void 0)&&s.uri&&(!((r=n.video)===null||r===void 0)&&r.videoBytes)?n.video={uri:n.video.uri,mimeType:n.video.mimeType}:!((a=(i=n.source)===null||i===void 0?void 0:i.video)===null||a===void 0)&&a.uri&&
6989(!((l=(o=n.source)===null||o===void 0?void 0:o.video)===null||l===void 0)&&l.videoBytes)&&(n.source.video={uri:n.source.video.uri,mimeType:n.source.video.mimeType})),await this.generateVideosInternal(n)}}maybeMoveToResponseJsonSchem(e){e.config&&e.config.responseSchema&&(e.config.responseJsonSchema||Object.keys(e.config.responseSchema).includes("$schema")&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema))}async processParamsMaybeAddMcpUsage(e){var n,s,r;const i=(n=e.config)===null||n===void 0?void 0:n.tools;if(!i)return e;const a=await Promise.all(i.map(async l=>Sw(l)?await l.tool():l)),o={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:a})};if(o.config.tools=a,e.config&&e.config.tools&&Hie(e.config.tools)){const l=(r=(s=e.config.httpOptions)===null||s===void 0?void 0:s.headers)!==null&&r!==void 0?r:{};let c=Object.assign({},l);Object.keys(c).length===0&&(c=this.apiClient.getDefaultHeaders()),qie(c),o.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:c})}return o}async initAfcToolsMap(e){var n,s,r;const i=new Map;for(const a of(s=(n=e.config)===null||n===void 0?void 0:n.tools)!==null&&s!==void 0?s:[])if(Sw(a)){const o=a,l=await o.tool();for(const c of(r=l.functionDeclarations)!==null&&r!==void 0?r:[]){if(!c.name)throw new Error("Function declaration name is required.");if(i.has(c.name))throw new Error(`Duplicate tool declaration name: ${c.name}`);i.set(c.name,o)}}return i}async processAfcStream(e){var n,s,r;const i=(r=(s=(n=e.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&r!==void 0?r:LW;let a=!1,o=0;const l=await this.initAfcToolsMap(e);return(function(c,h,p){var m,y;return _w(this,arguments,function*(){for(var v,b,S,E;o<i;){a&&(o++,a=!1);const L=yield $i(c.processParamsMaybeAddMcpUsage(p)),K=yield $i(c.generateContentStreamInternal(L)),D=[],R=[];try{for(var I=!0,M=(b=void 0,XS(K)),j;j=yield $i(M.next()),v=j.done,!v;I=!0){E=j.value,I=!1;const B=E;if(yield yield $i(B),B.candidates&&(!((m=B.candidates[0])===null||m===void 0)&&m.content)){R.push(B.candidates[0].content);for(const G of(y=B.candidates[0].content.parts)!==null&&y!==void 0?y:[])if(o<i&&G.functionCall){if(!G.functionCall.name)throw new Error("Function call name was not returned by the model.");if(h.has(G.functionCall.name)){const X=yield $i(h.get(G.functionCall.name).callTool([G.functionCall]));D.push(...X)}else throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${h.keys()}, mising tool: ${G.functionCall.name}`)}}}}catch(B){b={error:B}}finally{try{!I&&!v&&(S=M.return)&&(yield $i(S.call(M)))}finally{if(b)throw b.error}}if(D.length>0){a=!0;const B=new sS;B.candidates=[{content:{role:"user",parts:D}}],yield yield $i(B);const G=[];G.push(...R),G.push({role:"user",parts:D});const X=wd(p.contents).concat(G);p.contents=X}else break}})})(this,l,e)}async generateContentInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=MW(this.apiClient,e);return o=cn("{model}:generateContent",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=$W(h),m=new sS;return Object.assign(m,p),m})}else{const c=RW(this.apiClient,e);return o=cn("{model}:generateContent",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=PW(h),m=new sS;return Object.assign(m,p),m})}}async generateContentStreamInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=MW(this.apiClient,e);return o=cn("{model}:streamGenerateContent?alt=sse",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.requestStream({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abort
6989Signal}),a.then(function(p){return _w(this,arguments,function*(){var m,y,v,b;try{for(var S=!0,E=XS(p),I;I=yield $i(E.next()),m=I.done,!m;S=!0){b=I.value,S=!1;const M=b,j=$W(yield $i(M.json()));j.sdkHttpResponse={headers:M.headers};const L=new sS;Object.assign(L,j),yield yield $i(L)}}catch(M){y={error:M}}finally{try{!S&&!m&&(v=E.return)&&(yield $i(v.call(E)))}finally{if(y)throw y.error}}})})}else{const c=RW(this.apiClient,e);return o=cn("{model}:streamGenerateContent?alt=sse",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.requestStream({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}),a.then(function(p){return _w(this,arguments,function*(){var m,y,v,b;try{for(var S=!0,E=XS(p),I;I=yield $i(E.next()),m=I.done,!m;S=!0){b=I.value,S=!1;const M=b,j=PW(yield $i(M.json()));j.sdkHttpResponse={headers:M.headers};const L=new sS;Object.assign(L,j),yield yield $i(L)}}catch(M){y={error:M}}finally{try{!S&&!m&&(v=E.return)&&(yield $i(v.call(E)))}finally{if(y)throw y.error}}})})}}async embedContent(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=a3e(this.apiClient,e);return o=cn("{model}:predict",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=l3e(h),m=new pW;return Object.assign(m,p),m})}else{const c=i3e(this.apiClient,e);return o=cn("{model}:batchEmbedContents",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=o3e(h),m=new pW;return Object.assign(m,p),m})}}async generateImagesInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=v3e(this.apiClient,e);return o=cn("{model}:predict",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=w3e(h),m=new mW;return Object.assign(m,p),m})}else{const c=x3e(this.apiClient,e);return o=cn("{model}:predict",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=b3e(h),m=new mW;return Object.assign(m,p),m})}}async editImageInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI()){const o=t3e(this.apiClient,e);return i=cn("{model}:predict",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json().then(c=>{const h=c;return h.sdkHttpResponse={headers:l.headers},h})),r.then(l=>{const c=n3e(l),h=new uPe;return Object.assign(h,c),h})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI()){const o=vDe(this.apiClient,e);return i=cn("{model}:predict",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abort
6989Signal}).then(l=>l.json().then(c=>{const h=c;return h.sdkHttpResponse={headers:l.headers},h})),r.then(l=>{const c=bDe(l),h=new dPe;return Object.assign(h,c),h})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI()){const o=eDe(this.apiClient,e);return i=cn("{model}:predict",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>{const c=tDe(l),h=new hPe;return Object.assign(h,c),h})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI()){const o=oDe(this.apiClient,e);return i=cn("{model}:predict",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>{const c=lDe(l),h=new fPe;return Object.assign(h,c),h})}else throw new Error("This method is only supported by the Vertex AI.")}async get(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=j3e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>UO(h))}else{const c=L3e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a.then(h=>BO(h))}}async listInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=W3e(this.apiClient,e);return o=cn("{models_url}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=Y3e(h),m=new gW;return Object.assign(m,p),m})}else{const c=q3e(this.apiClient,e);return o=cn("{models_url}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=K3e(h),m=new gW;return Object.assign(m,p),m})}}async update(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=yDe(this.apiClient,e);return o=cn("{model}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>UO(h))}else{const c=gDe(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a.then(h=>BO(h))}}async delete(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=J$e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abort
6989Signal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=Z$e(h),m=new yW;return Object.assign(m,p),m})}else{const c=X$e(this.apiClient,e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=Q$e(h),m=new yW;return Object.assign(m,p),m})}}async countTokens(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=W$e(this.apiClient,e);return o=cn("{model}:countTokens",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=Y$e(h),m=new xW;return Object.assign(m,p),m})}else{const c=q$e(this.apiClient,e);return o=cn("{model}:countTokens",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=K$e(h),m=new xW;return Object.assign(m,p),m})}}async computeTokens(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI()){const o=B$e(this.apiClient,e);return i=cn("{model}:computeTokens",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json().then(c=>{const h=c;return h.sdkHttpResponse={headers:l.headers},h})),r.then(l=>{const c=U$e(l),h=new pPe;return Object.assign(h,c),h})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=C3e(this.apiClient,e);return o=cn("{model}:predictLongRunning",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a.then(h=>{const p=T3e(h),m=new kR;return Object.assign(m,p),m})}else{const c=A3e(this.apiClient,e);return o=cn("{model}:predictLongRunning",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a.then(h=>{const p=E3e(h),m=new kR;return Object.assign(m,p),m})}}}/**
6990 * @license
6991 * Copyright 2025 Google LLC
6992 * SPDX-License-Identifier: Apache-2.0
6993 */class f5e extends Gm{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){const n=e.operation,s=e.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=n.name.split("/operations/")[0];let i;s&&"httpOptions"in s&&(i=s.httpOptions);const a=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:r,config:{httpOptions:i}});return n._fromAPIResponse({apiResponse:a,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:n.name,config:s});return n._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async get(e){const n=e.operation,s=e.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");
6993if(this.apiClient.isVertexAI()){const r=n.name.split("/operations/")[0];let i;s&&"httpOptions"in s&&(i=s.httpOptions);const a=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:r,config:{httpOptions:i}});return n._fromAPIResponse({apiResponse:a,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:n.name,config:s});return n._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async getVideosOperationInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=rPe(e);return o=cn("{operationName}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),a}else{const c=sPe(e);return o=cn("{operationName}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json()),a}}async fetchPredictVideosOperationInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI()){const o=XMe(e);return i=cn("{resourceName}:fetchPredictOperation",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r}else throw new Error("This method is only supported by the Vertex AI.")}}/**
6994 * @license
6995 * Copyright 2025 Google LLC
6996 * SPDX-License-Identifier: Apache-2.0
6997 */function p5e(t){const e={},n=T(t,["data"]);if(n!=null&&k(e,["data"],n),T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function m5e(t){const e={},n=T(t,["parts"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>E5e(i))),k(e,["parts"],r)}const s=T(t,["role"]);return s!=null&&k(e,["role"],s),e}function g5e(t,e,n){const s={},r=T(e,["expireTime"]);n!==void 0&&r!=null&&k(n,["expireTime"],r);const i=T(e,["newSessionExpireTime"]);n!==void 0&&i!=null&&k(n,["newSessionExpireTime"],i);const a=T(e,["uses"]);n!==void 0&&a!=null&&k(n,["uses"],a);const o=T(e,["liveConnectConstraints"]);n!==void 0&&o!=null&&k(n,["bidiGenerateContentSetup"],S5e(t,o));const l=T(e,["lockAdditionalFields"]);return n!==void 0&&l!=null&&k(n,["fieldMask"],l),s}function y5e(t,e){const n={},s=T(e,["config"]);return s!=null&&k(n,["config"],g5e(t,s,n)),n}function x5e(t){const e={};if(T(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=T(t,["fileUri"]);n!=null&&k(e,["fileUri"],n);const s=T(t,["mimeType"]);return s!=null&&k(e,["mimeType"],s),e}function v5e(t){const e={},n=T(t,["id"]);n!=null&&k(e,["id"],n);const s=T(t,["args"]);s!=null&&k(e,["args"],s);const r=T(t,["name"]);if(r!=null&&k(e,["name"],r),T(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(T(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function b5e(t){const e={};if(T(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=T(t,["enableWidget"]);return n!=null&&k(e,["enableWidget"],n),e}function w5e(t){const e={};if(T(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(T(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=T(t,["timeRangeFilter"]);return n!=null&&k(e,["timeRangeFilter"],n),e}function _5e(t,e){const n={},s=T(t,["generationConfig"]);e!==void 0&&s!=null&&k(e,["setup","generationConfig"],s);const r=T(t,["responseModalities"]);e!==void 0&&r!=null&&k(e,["setup","generationConfig","responseModalities"],r);const i=T(t,["temperature"]);e!==void 0&&i!=null&&k(e,["setup","generationConfig","temperature"],i);const a=T(t,["topP"]);e!==void 0&&a!=null&&k(e,["setup","generationConfig","topP"],a);const o=T(t,["topK"]);e!==void 0&&o!=null&&k(e,["setup","generationConfig","topK"],o);const l=T(t,["maxOutputTokens"]);e!==void 0&&l!=null&&k(e,["setup","generationConfig","maxOutputTokens"],l);const c=T(t,["mediaResolution"]);e!==void 0&&c!=null&&k(e,["setup","generationConfig","mediaResolution"],c);const h=T(t,["seed"]);e!==void 0&&h!=null&&k(e,["setup","generationConfig","seed"],h);const p=T(t,["speechConfig"]);e!==void 0&&p!=null&&k(e,["setup","generationConfig","speechConfig"],jj(p));const m=T(t,["thinkingConfig"]);e!==void 0&&m!=null&&k(e,["setup","generationConfig","thinkingConfig"],m);const y=T(t,["enableAffectiveDialog"]);e!==void 0&&y!=null&&k(e,["setup","generationConfig","enableAffectiveDialog"],y);const v=T(t,["systemInstruction"]);e!==void 0&&v!=null&&k(e,["setup","systemInstruction"],m5e(vl(v)));const b=T(t,["tools"]);if(e!==void 0&&b!=null){let K=o_(b);Array.isArray(K)&&(K=K.map(D=>A5e(a_(D)))),k(e,["setup","tools"],K)}const S=T(t,["sessionResumption"]);e!==void 0&&S!=null&&k(e,["setup","sessionResumption"],T5e(S));const E=T(t,["inputAudioTranscription"]);e!==void 0&&E!=null&&k(e,["setup","inputAudioTranscription"],E);const I=T(t,["outputAudioTranscription"]);e!==void 0&&I!=null&&k(e,["setup","outputAudioTranscription"],I);const M=T(t,["realtimeInputConfig"]);e!==void 0&&M!=null&&k(e,["setup","realtimeInputConfig"],M);const j=T(t,["contextWindowCompression"]);e!==void 0&&j!=null&&k(e,["setup","contextWindowCompression"],j);const L=T(t,["proactivity"]);return e!==void 0&&L!=null&&k(e,["setup","proactivity"],L),n}function S5e(t,e){const n={},s=T(e,["model"]);s!=null&&k(n,["setup","model"],Ur(t,s));const r=T(e,["config"]);return r!=null&&k(n,["config"],_5e(r,n)),n}function E5e(t){const e={},n=T(t,["mediaResolution"]);n!=null&&k(e,["mediaResolution"],n);const s=T(t,["codeExecutionResult"]);s!=null&&k(e,["codeExecutionResult"],s);const r=T(t,["executableCode"]);r!=null&&k(e,["executableCode"],r);const i=T(t,["fileData"]);i!=null&&k(e,["fileData"],x5e(i));const a=T(t,["functionCall"]);a!=null&&k(e,["functionCall"],v5e(a));const o=T(t,["functionResponse"]);o!=null&&k(e,["functionResponse"],o);const l=T(t,["inlineData"]);l!=null&&k(e,["inlineData"],p5e(l));const c=T(t,["text"]);c!=null&&k(e,["text"],c);const h=T(t,["thought"]);h!=null&&k(e,["thought"],h);const p=T(t,["thoughtSignature"]);p!=null&&k(e,["thoughtSignature"],p);const m=T(t,["videoMetadata"]);return m!=null&&k(e,["videoMetadata"],m),e}function T5e(t){const e={},n=T(t,["handle"]);if(n!=null&&k(e,["handle"],n),T(t,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return e}function A5e(t){const e={},n=T(t,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(p=>p)),k(e,["functionDeclarations"],h)}if(T(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=T(t,["googleSearchRetrieval"]);s!=null&&k(e,["googleSearchRetrieval"],s);const r=T(t,["computerUse"]);r!=null&&k(e,["computerUse"],r);const i=T(t,["fileSearch"]);i!=null&&k(e,["fileSearch"],i);const a=T(t,["codeExecution"]);if(a!=null&&k(e,["codeExecution"],a),T(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const o=T(t,["googleMaps"]);o!=null&&k(e,["googleMaps"],b5e(o));const l=T(t,["googleSearch"]);l!=null&&k(e,["googleSearch"],w5e(l));const c=T(t,["urlContext"]);
6997return c!=null&&k(e,["urlContext"],c),e}/**
6998 * @license
6999 * Copyright 2025 Google LLC
7000 * SPDX-License-Identifier: Apache-2.0
7001 */function C5e(t){const e=[];for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];if(typeof s=="object"&&s!=null&&Object.keys(s).length>0){const r=Object.keys(s).map(i=>`${n}.${i}`);e.push(...r)}else e.push(n)}return e.join(",")}function k5e(t,e){let n=null;const s=t.bidiGenerateContentSetup;if(typeof s=="object"&&s!==null&&"setup"in s){const i=s.setup;typeof i=="object"&&i!==null?(t.bidiGenerateContentSetup=i,n=i):delete t.bidiGenerateContentSetup}else s!==void 0&&delete t.bidiGenerateContentSetup;const r=t.fieldMask;if(n){const i=C5e(n);if(Array.isArray(e==null?void 0:e.lockAdditionalFields)&&(e==null?void 0:e.lockAdditionalFields.length)===0)i?t.fieldMask=i:delete t.fieldMask;else if(e!=null&&e.lockAdditionalFields&&e.lockAdditionalFields.length>0&&r!==null&&Array.isArray(r)&&r.length>0){const a=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let o=[];r.length>0&&(o=r.map(c=>a.includes(c)?`generationConfig.${c}`:c));const l=[];i&&l.push(i),o.length>0&&l.push(...o),l.length>0?t.fieldMask=l.join(","):delete t.fieldMask}else delete t.fieldMask}else r!==null&&Array.isArray(r)&&r.length>0?t.fieldMask=r.join(","):delete t.fieldMask;return t}class I5e extends Gm{constructor(e){super(),this.apiClient=e}async create(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const o=y5e(this.apiClient,e);i=cn("auth_tokens",o._url),a=o._query,delete o.config,delete o._url,delete o._query;const l=k5e(o,e.config);return r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(l),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(c=>c.json()),r.then(c=>c)}}}/**
7002 * @license
7003 * Copyright 2025 Google LLC
7004 * SPDX-License-Identifier: Apache-2.0
7005 */function N5e(t,e){const n={},s=T(t,["force"]);return e!==void 0&&s!=null&&k(e,["_query","force"],s),n}function R5e(t){const e={},n=T(t,["name"]);n!=null&&k(e,["_url","name"],n);const s=T(t,["config"]);return s!=null&&N5e(s,e),e}function M5e(t){const e={},n=T(t,["name"]);return n!=null&&k(e,["_url","name"],n),e}function P5e(t,e){const n={},s=T(t,["pageSize"]);e!==void 0&&s!=null&&k(e,["_query","pageSize"],s);const r=T(t,["pageToken"]);return e!==void 0&&r!=null&&k(e,["_query","pageToken"],r),n}function $5e(t){const e={},n=T(t,["parent"]);n!=null&&k(e,["_url","parent"],n);const s=T(t,["config"]);return s!=null&&P5e(s,e),e}function D5e(t){const e={},n=T(t,["sdkHttpResponse"]);n!=null&&k(e,["sdkHttpResponse"],n);const s=T(t,["nextPageToken"]);s!=null&&k(e,["nextPageToken"],s);const r=T(t,["documents"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(a=>a)),k(e,["documents"],i)}return e}/**
7006 * @license
7007 * Copyright 2025 Google LLC
7008 * SPDX-License-Identifier: Apache-2.0
7009 */class O5e extends Gm{constructor(e){super(),this.apiClient=e,this.list=async n=>new Wv(jm.PAGED_ITEM_DOCUMENTS,s=>this.listInternal({parent:n.parent,config:s.config}),await this.listInternal(n),n)}async get(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=M5e(e);return i=cn("{name}",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>l)}}async delete(e){var n,s;let r="",i={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const a=R5e(e);r=cn("{name}",a._url),i=a._query,delete a._url,delete a._query,await this.apiClient.request({path:r,queryParams:i,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abort
7009Signal})}}async listInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=$5e(e);return i=cn("{parent}/documents",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>{const c=D5e(l),h=new mPe;return Object.assign(h,c),h})}}}/**
7010 * @license
7011 * Copyright 2025 Google LLC
7012 * SPDX-License-Identifier: Apache-2.0
7013 */class L5e extends Gm{constructor(e,n=new O5e(e)){super(),this.apiClient=e,this.documents=n,this.list=async(s={})=>new Wv(jm.PAGED_ITEM_FILE_SEARCH_STORES,r=>this.listInternal(r),await this.listInternal(s),s)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=CDe(e);return i=cn("fileSearchStores",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>l)}}async get(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=NDe(e);return i=cn("{name}",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>l)}}async delete(e){var n,s;let r="",i={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const a=IDe(e);r=cn("{name}",a._url),i=a._query,delete a._url,delete a._query,await this.apiClient.request({path:r,queryParams:i,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal})}}async listInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=ODe(e);return i=cn("fileSearchStores",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>{const c=LDe(l),h=new gPe;return Object.assign(h,c),h})}}async uploadToFileSearchStoreInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=jDe(e);return i=cn("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json()),r.then(l=>{const c=BDe(l),h=new yPe;return Object.assign(h,c),h})}}async importFile(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=PDe(e);return i=cn("{file_search_store_name}:importFile",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abort
7013Signal}).then(l=>l.json()),r.then(l=>{const c=MDe(l),h=new Pj;return Object.assign(h,c),h})}}}/**
7014 * @license
7015 * Copyright 2025 Google LLC
7016 * SPDX-License-Identifier: Apache-2.0
7017 */function j5e(t,e){const n={},s=T(t,["name"]);return s!=null&&k(n,["_url","name"],s),n}function B5e(t,e){const n={},s=T(t,["name"]);return s!=null&&k(n,["_url","name"],s),n}function U5e(t,e){const n={},s=T(t,["sdkHttpResponse"]);return s!=null&&k(n,["sdkHttpResponse"],s),n}function F5e(t,e){const n={},s=T(t,["sdkHttpResponse"]);return s!=null&&k(n,["sdkHttpResponse"],s),n}function V5e(t,e,n){const s={};if(T(t,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const r=T(t,["tunedModelDisplayName"]);if(e!==void 0&&r!=null&&k(e,["displayName"],r),T(t,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const i=T(t,["epochCount"]);e!==void 0&&i!=null&&k(e,["tuningTask","hyperparameters","epochCount"],i);const a=T(t,["learningRateMultiplier"]);if(a!=null&&k(s,["tuningTask","hyperparameters","learningRateMultiplier"],a),T(t,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(T(t,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(T(t,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const o=T(t,["batchSize"]);e!==void 0&&o!=null&&k(e,["tuningTask","hyperparameters","batchSize"],o);const l=T(t,["learningRate"]);if(e!==void 0&&l!=null&&k(e,["tuningTask","hyperparameters","learningRate"],l),T(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(T(t,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return s}function z5e(t,e,n){const s={};let r=T(n,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const y=T(t,["validationDataset"]);e!==void 0&&y!=null&&k(e,["supervisedTuningSpec"],FW(y))}else if(r==="PREFERENCE_TUNING"){const y=T(t,["validationDataset"]);e!==void 0&&y!=null&&k(e,["preferenceOptimizationSpec"],FW(y))}const i=T(t,["tunedModelDisplayName"]);e!==void 0&&i!=null&&k(e,["tunedModelDisplayName"],i);const a=T(t,["description"]);e!==void 0&&a!=null&&k(e,["description"],a);let o=T(n,["config","method"]);if(o===void 0&&(o="SUPERVISED_FINE_TUNING"),o==="SUPERVISED_FINE_TUNING"){const y=T(t,["epochCount"]);e!==void 0&&y!=null&&k(e,["supervisedTuningSpec","hyperParameters","epochCount"],y)}else if(o==="PREFERENCE_TUNING"){const y=T(t,["epochCount"]);e!==void 0&&y!=null&&k(e,["preferenceOptimizationSpec","hyperParameters","epochCount"],y)}let l=T(n,["config","method"]);if(l===void 0&&(l="SUPERVISED_FINE_TUNING"),l==="SUPERVISED_FINE_TUNING"){const y=T(t,["learningRateMultiplier"]);e!==void 0&&y!=null&&k(e,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],y)}else if(l==="PREFERENCE_TUNING"){const y=T(t,["learningRateMultiplier"]);e!==void 0&&y!=null&&k(e,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],y)}let c=T(n,["config","method"]);if(c===void 0&&(c="SUPERVISED_FINE_TUNING"),c==="SUPERVISED_FINE_TUNING"){const y=T(t,["exportLastCheckpointOnly"]);e!==void 0&&y!=null&&k(e,["supervisedTuningSpec","exportLastCheckpointOnly"],y)}else if(c==="PREFERENCE_TUNING"){const y=T(t,["exportLastCheckpointOnly"]);e!==void 0&&y!=null&&k(e,["preferenceOptimizationSpec","exportLastCheckpointOnly"],y)}let h=T(n,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const y=T(t,["adapterSize"]);e!==void 0&&y!=null&&k(e,["supervisedTuningSpec","hyperParameters","adapterSize"],y)}else if(h==="PREFERENCE_TUNING"){const y=T(t,["adapterSize"]);e!==void 0&&y!=null&&k(e,["preferenceOptimizationSpec","hyperParameters","adapterSize"],y)}if(T(t,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(T(t,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const p=T(t,["labels"]);e!==void 0&&p!=null&&k(e,["labels"],p);const m=T(t,["beta"]);return e!==void 0&&m!=null&&k(e,["preferenceOptimizationSpec","hyperParameters","beta"],m),s}function G5e(t,e){const n={},s=T(t,["baseModel"]);s!=null&&k(n,["baseModel"],s);const r=T(t,["preTunedModel"]);r!=null&&k(n,["preTunedModel"],r);const i=T(t,["trainingDataset"]);i!=null&&tOe(i);const a=T(t,["config"]);return a!=null&&V5e(a,n),n}function H5e(t,e){const n={},s=T(t,["baseModel"]);s!=null&&k(n,["baseModel"],s);const r=T(t,["preTunedModel"]);r!=null&&k(n,["preTunedModel"],r);const i=T(t,["trainingDataset"]);i!=null&&nOe(i,n,e);const a=T(t,["config"]);return a!=null&&z5e(a,n,e),n}function q5e(t,e){const n={},s=T(t,["name"]);return s!=null&&k(n,["_url","name"],s),n}function W5e(t,e){const n={},s=T(t,["name"]);return s!=null&&k(n,["_url","name"],s),n}function K5e(t,e,n){const s={},r=T(t,["pageSize"]);e!==void 0&&r!=null&&k(e,["_query","pageSize"],r);const i=T(t,["pageToken"]);e!==void 0&&i!=null&&k(e,["_query","pageToken"],i);const a=T(t,["filter"]);return e!==void 0&&a!=null&&k(e,["_query","filter"],a),s}function Y5e(t,e,n){const s={},r=T(t,["pageSize"]);e!==void 0&&r!=null&&k(e,["_query","pageSize"],r);const i=T(t,["pageToken"]);e!==void 0&&i!=null&&k(e,["_query","pageToken"],i);const a=T(t,["filter"]);return e!==void 0&&a!=null&&k(e,["_query","filter"],a),s}function X5e(t,e){const n={},s=T(t,["config"]);return s!=null&&K5e(s,n),n}function J5e(t,e){const n={},s=T(t,["config"]);return s!=null&&Y5e(s,n),n}function Q5e(t,e){const n={},s=T(t,["sdkHttpResponse"]);s!=null&&k(n,["sdkHttpResponse"],s);const r=T(t,["nextPageToken"]);r!=null&&k(n,["nextPageToken"],r);const i=T(t,["tunedModels"]);if(i!=null){let a=i;Array.isArray(a)&&(a=a.map(o=>Wie(o))),k(n,["tuningJobs"],a)}return n}function Z5e(t,e){const n={},s=T(t,["sdkHttpResponse"]);s!=null&&k(n,["sdkHttpResponse"],s);const r=T(t,["nextPageToken"]);r!=null&&k(n,["nextPageToken"],r);const i=T(t,["tuningJobs"]);if(i!=null){let a=i;Array.isArray(a)&&(a=a.map(o=>VO(o))),k(n,["tuningJobs"],a)}return n}function eOe(t,e){const n={},s=T(t,["name"]);s!=null&&k(n,["model"],s);const r=T(t,["name"]);return r!=null&&k(n,["endpoint"],r),n}function tOe(t,e){const n={};if(T(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(T(t,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const s=T(t,["examples"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(i=>i)),k(n,["examples","examples"],r)}return n}function nOe(t,e,n){const s={};let r=T(n,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const a=T(t,["gcsUri"]);e!==void 0&&a!=null&&k(e,["supervisedTuningSpec","trainingDatasetUri"],a)}else if(r==="PREFERENCE_TUNING"){const a=T(t,["gcsUri"]);e!==void 0&&a!=null&&k(e,["preferenceOptimizationSpec","trainingDatasetUri"],a)}let i=T(n,["config","method"]);if(i===void 0&&(i="SUPERVISED_FINE_TUNING"),i==="SUPERVISED_FINE_TUNING"){const a=T(t,["vertexDatasetResource"]);e!==void 0&&a!=null&&k(e,["supervisedTuningSpec","trainingDatasetUri"],a)}else if(i==="PREFERENCE_TUNING"){const a=T(t,["vertexDatasetResource"]);e!==void 0&&a!=null&&k(e,["preferenceOptimizationSpec","trainingDatasetUri"],a)}if(T(t,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return s}function Wie(t,e){const n={},s=T(t,["sdkHttpResponse"]);s!=null&&k(n,["sdkHttpResponse"],s);const r=T(t,["name"]);r!=null&&k(n,["name"],r);const i=T(t,["state"]);i!=null&&k(n,["state"],Cie(i));const a=T(t,["createTime"]);a!=null&&k(n,["createTime"],a);const o=T(t,["tuningTask","startTime"]);o!=null&&k(n,["startTime"],o);const l=T(t,["tuningTask","completeTime"]);l!=null&&k(n,["endTime"],l);const c=T(t,["updateTime"]);c!=null&&k(n,["updateTime"],c);
7017const h=T(t,["description"]);h!=null&&k(n,["description"],h);const p=T(t,["baseModel"]);p!=null&&k(n,["baseModel"],p);const m=T(t,["_self"]);return m!=null&&k(n,["tunedModel"],eOe(m)),n}function VO(t,e){const n={},s=T(t,["sdkHttpResponse"]);s!=null&&k(n,["sdkHttpResponse"],s);const r=T(t,["name"]);r!=null&&k(n,["name"],r);const i=T(t,["state"]);i!=null&&k(n,["state"],Cie(i));const a=T(t,["createTime"]);a!=null&&k(n,["createTime"],a);const o=T(t,["startTime"]);o!=null&&k(n,["startTime"],o);const l=T(t,["endTime"]);l!=null&&k(n,["endTime"],l);const c=T(t,["updateTime"]);c!=null&&k(n,["updateTime"],c);const h=T(t,["error"]);h!=null&&k(n,["error"],h);const p=T(t,["description"]);p!=null&&k(n,["description"],p);const m=T(t,["baseModel"]);m!=null&&k(n,["baseModel"],m);const y=T(t,["tunedModel"]);y!=null&&k(n,["tunedModel"],y);const v=T(t,["preTunedModel"]);v!=null&&k(n,["preTunedModel"],v);const b=T(t,["supervisedTuningSpec"]);b!=null&&k(n,["supervisedTuningSpec"],b);const S=T(t,["preferenceOptimizationSpec"]);S!=null&&k(n,["preferenceOptimizationSpec"],S);const E=T(t,["tuningDataStats"]);E!=null&&k(n,["tuningDataStats"],E);const I=T(t,["encryptionSpec"]);I!=null&&k(n,["encryptionSpec"],I);const M=T(t,["partnerModelTuningSpec"]);M!=null&&k(n,["partnerModelTuningSpec"],M);const j=T(t,["customBaseModel"]);j!=null&&k(n,["customBaseModel"],j);const L=T(t,["experiment"]);L!=null&&k(n,["experiment"],L);const K=T(t,["labels"]);K!=null&&k(n,["labels"],K);const D=T(t,["outputUri"]);D!=null&&k(n,["outputUri"],D);const R=T(t,["pipelineJob"]);R!=null&&k(n,["pipelineJob"],R);const B=T(t,["serviceAccount"]);B!=null&&k(n,["serviceAccount"],B);const G=T(t,["tunedModelDisplayName"]);G!=null&&k(n,["tunedModelDisplayName"],G);const X=T(t,["veoTuningSpec"]);return X!=null&&k(n,["veoTuningSpec"],X),n}function sOe(t,e){const n={},s=T(t,["sdkHttpResponse"]);s!=null&&k(n,["sdkHttpResponse"],s);const r=T(t,["name"]);r!=null&&k(n,["name"],r);const i=T(t,["metadata"]);i!=null&&k(n,["metadata"],i);const a=T(t,["done"]);a!=null&&k(n,["done"],a);const o=T(t,["error"]);return o!=null&&k(n,["error"],o),n}function FW(t,e){const n={},s=T(t,["gcsUri"]);s!=null&&k(n,["validationDatasetUri"],s);const r=T(t,["vertexDatasetResource"]);return r!=null&&k(n,["validationDatasetUri"],r),n}/**
7018 * @license
7019 * Copyright 2025 Google LLC
7020 * SPDX-License-Identifier: Apache-2.0
7021 */class rOe extends Gm{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new Wv(jm.PAGED_ITEM_TUNING_JOBS,s=>this.listInternal(s),await this.listInternal(n),n),this.get=async n=>await this.getInternal(n),this.tune=async n=>{var s;if(this.apiClient.isVertexAI())if(n.baseModel.startsWith("projects/")){const r={tunedModelName:n.baseModel};!((s=n.config)===null||s===void 0)&&s.preTunedModelCheckpointId&&(r.checkpointId=n.config.preTunedModelCheckpointId);const i=Object.assign(Object.assign({},n),{preTunedModel:r});return i.baseModel=void 0,await this.tuneInternal(i)}else{const r=Object.assign({},n);return await this.tuneInternal(r)}else{const r=Object.assign({},n),i=await this.tuneMldevInternal(r);let a="";return i.metadata!==void 0&&i.metadata.tunedModel!==void 0?a=i.metadata.tunedModel:i.name!==void 0&&i.name.includes("/operations/")&&(a=i.name.split("/operations/")[0]),{name:a,state:DO.JOB_STATE_QUEUED}}}}async getInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=W5e(e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>VO(h))}else{const c=q5e(e);return o=cn("{name}",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>Wie(h))}}async listInternal(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=J5e(e);return o=cn("tuningJobs",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abort
7021Signal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=Z5e(h),m=new vW;return Object.assign(m,p),m})}else{const c=X5e(e);return o=cn("tunedModels",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=Q5e(h),m=new vW;return Object.assign(m,p),m})}}async cancel(e){var n,s,r,i;let a,o="",l={};if(this.apiClient.isVertexAI()){const c=B5e(e);return o=cn("{name}:cancel",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=F5e(h),m=new bW;return Object.assign(m,p),m})}else{const c=j5e(e);return o=cn("{name}:cancel",c._url),l=c._query,delete c._url,delete c._query,a=this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(r=e.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(i=e.config)===null||i===void 0?void 0:i.abortSignal}).then(h=>h.json().then(p=>{const m=p;return m.sdkHttpResponse={headers:h.headers},m})),a.then(h=>{const p=U5e(h),m=new bW;return Object.assign(m,p),m})}}async tuneInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI()){const o=H5e(e,e);return i=cn("tuningJobs",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json().then(c=>{const h=c;return h.sdkHttpResponse={headers:l.headers},h})),r.then(l=>VO(l))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(e){var n,s;let r,i="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const o=G5e(e);return i=cn("tunedModels",o._url),a=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:i,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(l=>l.json().then(c=>{const h=c;return h.sdkHttpResponse={headers:l.headers},h})),r.then(l=>sOe(l))}}}/**
7022 * @license
7023 * Copyright 2025 Google LLC
7024 * SPDX-License-Identifier: Apache-2.0
7025 */class iOe{async download(e,n){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.")}}const aOe=1024*1024*8,oOe=3,lOe=1e3,cOe=2,NR="x-goog-upload-status";async function uOe(t,e,n){var s;const r=await Kie(t,e,n),i=await(r==null?void 0:r.json());if(((s=r==null?void 0:r.headers)===null||s===void 0?void 0:s[NR])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return i.file}async function dOe(t,e,n){var s;const r=await Kie(t,e,n),i=await(r==null?void 0:r.json());if(((s=r==null?void 0:r.headers)===null||s===void 0?void 0:s[NR])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const a=wie(i),o=new $j;return Object.assign(o,a),o}async function Kie(t,e,n){var s,r;let i=0,a=0,o=new OO(new Response),l="upload";for(i=t.size;a<i;){const c=Math.min(aOe,i-a),h=t.slice(a,a+c);a+c>=i&&(l+=", finalize");let p=0,m=lOe;for(;p<oOe&&(o=await n.request({path:"",body:h,httpMethod:"POST",httpOptions:{apiVersion:"",baseUrl:e,headers:{"X-Goog-Upload-Command":l,"X-Goog-Upload-Offset":String(a),"Content-Length":String(c)}}}),!(!((s=o==null?void 0:o.headers)===null||s===void 0)&&s[NR]));)p++,await fOe(m),m=m*cOe;if(a+=c,((r=o==null?void 0:o.headers)===null||r===void 0?void 0:r[NR])!=="active")break;if(i<=a)throw new Error("All content has been uploaded, but the upload status is not finalized.")}return o}async function hOe(t){return{size:t.size,type:t.type}}function fOe(t){return new Promise(e=>setTimeout(e,t))}class pOe{async upload(e,n,s){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await uOe(e,n,s)}async uploadToFileSearchStore(e,n,s){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await dOe(e,n,s)}async stat(e){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await hOe(e)}}/**
7026 * @license
7027 * Copyright 2025 Google LLC
7028 * SPDX-License-Identifier: Apache-2.0
7029 */class mOe{create(e,n,s){return new gOe(e,n,s)}}class gOe{constructor(e,n,s){this.url=e,this.headers=n,this.callbacks=s}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose
7029=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(e)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/**
7030 * @license
7031 * Copyright 2025 Google LLC
7032 * SPDX-License-Identifier: Apache-2.0
7033 */const VW="x-goog-api-key";class yOe{constructor(e){this.apiKey=e}async addAuthHeaders(e,n){if(e.get(VW)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");e.append(VW,this.apiKey)}}}/**
7034 * @license
7035 * Copyright 2025 Google LLC
7036 * SPDX-License-Identifier: Apache-2.0
7037 */const xOe="gl-node/";class Yie{constructor(e){var n;if(e.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(e.project||e.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(n=e.vertexai)!==null&&n!==void 0?n:!1,this.apiKey=e.apiKey;const s=KMe(e.httpOptions,e.vertexai,void 0,void 0);s&&(e.httpOptions?e.httpOptions.baseUrl=s:e.httpOptions={baseUrl:s}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const r=new yOe(this.apiKey);this.apiClient=new WDe({auth:r,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:xOe+"web",uploader:new pOe,downloader:new iOe}),this.models=new h5e(this.apiClient),this.live=new a5e(this.apiClient,r,new mOe),this.batches=new S4e(this.apiClient),this.chats=new r$e(this.models,this.apiClient),this.caches=new t$e(this.apiClient),this.files=new p$e(this.apiClient),this.operations=new f5e(this.apiClient),this.authTokens=new I5e(this.apiClient),this.tunings=new rOe(this.apiClient),this.fileSearchStores=new L5e(this.apiClient)}}const vOe={"llama-4-scout":"meta-llama/llama-4-scout-17b-16e-instruct"},RS=["gemini-3.6-flash","gemini-3.5-flash-lite","gemini-3.1-flash-lite","gemini-2.5-flash-lite","gemini-2.5-flash"];function bOe(t){const e=RS.indexOf(t);return e===-1?RS[0]:RS[(e+1)%RS.length]}const Xie=(t,e)=>{let n="";if(t.mode===Ti.PROMPT){let s="";t.isSilhouette&&(s+=`
7038- IMPORTANT: Understand the image as a vector silhouette design. Focus on clean outlines, solid fills (usually black on white), and minimalistic detail.`),t.isIcon&&(s+=`
7039- IMPORTANT: Understand the image as a vector icon design. Focus on symbolic representation, scalability, consistent stroke weights or flat styles, and clear legibility.`),n=`You are an AI prompt engineering expert. 
7040Your goal is to analyze the input asset and generate a detailed "image generation prompt".
7041The generated prompt should describe the subject, style, medium, lighting, composition, and mood so accurately that an AI (like Midjourney or DALL-E) could recreate an image identical or highly similar to the original.
7042${s}
7043
7044Return a JSON ARRAY containing exactly ${e} objects (or just 1 object if analyzing single file).
7045Each object must contain:
70461. prompt: A descriptive, highly detailed prompt.
7047   - Target range: ${Math.max(50,t.promptLength-50)} to ${t.promptLength} characters.
7048   - Do NOT exceed ${t.promptLength} characters.
7049   - Do not use generic phrases like "An image of" or "A photo of".
7050   - Focus on technical keywords: lighting (e.g., volumetric, cinematic), lens (e.g., 85mm, macro), style (e.g., photorealistic, digital art, oil painting).`}else{const s=t.platform===jr.SHUTTERSTOCK,r=t.platform===jr.FREEPIK,i=t.isSeamless,a=s?SE:_E,o=s?"Description":"Title";let l="";s?l=`
7051- Platform: Shutterstock.
7052- Video Files Restriction: For any video asset (MP4/MOV), you MUST NOT use the following categories: ${hz.join(", ")}. Select the best alternative from the remaining valid categories.
7053- For Images/Vectors: All categories are valid.`:r?l=`
7054- Platform: Freepik.
7055- Title Length: STRICTLY MAXIMUM 100 characters. Be concise but descriptive.
7056${i?"":"- Category: DO NOT GENERATE."}`:l=`
7057- Platform: Adobe Stock.`;const c=Math.max(20,t.titleMaxLength-25);n=`You are an elite stock photography contributor and SEO metadata specialist.
7058Your goal is to maximize sales potential by generating highly descriptive, search-engine-optimized metadata for the input asset.
7059
7060Return a JSON ARRAY containing exactly ${e} objects.
7061Each object must contain:
70621. title: A detailed, sentence-case ${o}.
7063   - CRITICAL: The length MUST be between ${c} and ${t.titleMaxLength} characters.
7064   - You MUST utilize the available character space to include detailed information about the subject, action, location, and mood.
7065   - Do NOT exceed ${t.titleMaxLength} characters.
70662. keywords: A comma-separated string of exactly ${t.keywordsCount} relevant keywords.
7067   - You MUST provide exactly this number of keywords. Use synonyms or related concepts if needed to reach the count.`,i?n+=`
70683. adobe_category: The most appropriate category for Adobe Stock.
70694. shutterstock_category: The most appropriate category for Shutterstock.
7070   - Note: For Shutterstock Video assets, exclude: ${hz.join(", ")}.`:r||(n+=`
70713. category: The most appropriate category from the approved list.`),n+=`
7072
7073Rules:
7074- ${o} must be English, sentence case.
7075- Keywords must be English.`,i?n+=`
7076- Adobe Categories: ${_E.join(", ")}.
7077- Shutterstock Categories: ${SE.join(", ")}.`:r||(n+=`
7078- List Categories: ${a.join(", ")}.`),n+=`
7079${l}`}return t.refinerInstruction&&t.refinerInstruction.trim().length>0&&(n+=`
7080
7081=== CUSTOM REFINER INSTRUCTIONS ===
7082Verified User Instruction: "${t.refinerInstruction}"
7083IMPORTANT: The above user instruction is used for refining the output. Like the system prompt, you must adhere to the above instruction strictly while generating the output. The instruction modifies the way the output is generated.`),n},wOe=t=>{if(t.mode===Ti.PROMPT)return{type:Ei.ARRAY,items:{type:Ei.OBJECT,properties:{prompt:{type:Ei.STRING}},required:["prompt"]}};const e=t.platform===jr.FREEPIK;if(t.isSeamless)return{type:Ei.ARRAY,items:{type:Ei.OBJECT,properties:{title:{type:Ei.STRING},keywords:{type:Ei.STRING},adobe_category:{type:Ei.STRING,enum:_E},shutterstock_category:{type:Ei.STRING,enum:SE}},required:["title","keywords","adobe_category","shutterstock_category"]}};if(e)return{type:Ei.ARRAY,items:{type:Ei.OBJECT,properties:{title:{type:Ei.STRING},keywords:{type:Ei.STRING}},required:["title","keywords"]}};const n=t.platform===jr.SHUTTERSTOCK?SE:_E;return{type:Ei.ARRAY,items:{type:Ei.OBJECT,properties:{title:{type:Ei.STRING},keywords:{type:Ei.STRING},category:{type:Ei.STRING,enum:n}},required:["title","keywords","category"]}}},T3=t=>new Promise(e=>setTimeout(e,t)),_Oe=async(t,e,n,s)=>(await new Yie({apiKey:t}).models.generateContent({model:n.modelId,contents:{role:"user",parts:s},config:{systemInstruction:Xie(n,e.length)+`
7084Maintain the exact order of the input files.`,responseMimeType:"application/json",responseSchema:wOe(n),temperature:n.mode===Ti.PROMPT?.7:.4}})).text,SOe=async(t,e,n,s)=>{var v,b,S;const r=n.provider==="groq"&&vOe[n.modelId]||n.modelId,a=[{role:"system",content:Xie(n,1)+`
7085
7086CRITICAL OUTPUT INSTRUCTION: You MUST return a valid JSON Object. Do NOT return a list directly. Wrap your result in a field named 'data'.
7087Example: { "data": [ { "title": "..." } ] }`}],o=[],l=n.platform===jr.SHUTTERSTOCK?"Shutterstock":n.platform===jr.FREEPIK?"Freepik":"Adobe Stock";
7087let c=n.mode===Ti.PROMPT?"Analyze this image and generate an image generation prompt.":`Analyze this asset and generate ${l} metadata.`;if(n.mode===Ti.METADATA){const E=n.platform===jr.SHUTTERSTOCK?"Description":"Title",I=Math.max(15,n.titleMaxLength-25);c+=`
7088
7089STRICT OUTPUT REQUIREMENTS:
70901. ${E}: MUST be between ${I} and ${n.titleMaxLength} characters long. Do not be short.
70912. Keywords: Provide EXACTLY ${n.keywordsCount} keywords.`}else c+=`
7092
7093STRICT OUTPUT REQUIREMENTS:
70941. Prompt: Max ${n.promptLength} characters.`;o.push({type:"text",text:c});const h=e.mediaParts.some(E=>E.inlineData.mimeType==="image/png")||e.filename.toLowerCase().endsWith(".png");n.mode===Ti.METADATA&&h&&o.push({type:"text",text:'IMPORTANT: This is a PNG. Naturally include "isolated on transparent background" in the title and keywords.'}),o.push({type:"text",text:`Filename: ${e.filename}`}),e.mediaParts.forEach(E=>{const I=E.inlineData.mimeType,M=E.inlineData.data;if(I.startsWith("image/"))o.push({type:"image_url",image_url:{url:`data:${I};base64,${M}`}});else if(I==="text/plain")try{const j=atob(M);o.push({type:"text",text:`
7095File Content (EPS/Vector Source):
7096${j.slice(0,15e3)}`})}catch(j){console.warn("Failed to decode text part",j)}}),a.push({role:"user",content:o});const p=await fetch(s,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({messages:a,model:r,temperature:n.mode===Ti.PROMPT?.7:.4,max_tokens:2048,response_format:{type:"json_object"}})});if(!p.ok){const E=await p.json().catch(()=>null),I=(E==null?void 0:E.message)||((v=E==null?void 0:E.error)==null?void 0:v.message)||(E==null?void 0:E.detail)||p.statusText||"Unknown Error";throw new Error(`${n.provider==="mistral"?"Mistral":"Groq"} API Error (${p.status}): ${I}`)}const y=(S=(b=(await p.json()).choices[0])==null?void 0:b.message)==null?void 0:S.content;if(!y)throw new Error(`Empty content from ${n.provider}`);try{let E=y;const I=y.match(/```(?:json)?\s*([\s\S]*?)\s*```/);if(I)E=I[1];else{const K=y.indexOf("{"),D=y.lastIndexOf("}");K!==-1&&D!==-1&&D>K&&(E=y.substring(K,D+1))}E=E.trim();const M=JSON.parse(E);let j=M;M.data?j=M.data:M.items?j=M.items:M.assets&&(j=M.assets);let L=Array.isArray(j)?j[0]:j;return L||(L=M),{title:L.title||L.description||"",keywords:Array.isArray(L.keywords)?L.keywords.join(", "):L.keywords||"",category:L.category||"",prompt:L.prompt||"",adobe_category:L.adobe_category,shutterstock_category:L.shutterstock_category}}catch{throw console.error(`${n.provider} JSON Parse Error. Content:`,y),new Error(`Failed to generate JSON from ${n.provider} response.`)}},EOe=async(t,e,n,s,r)=>{if(!t)throw new Error("API Key is missing");if(e.length===0)return[];const i=[];if(n.provider==="gemini"){const c=n.platform===jr.SHUTTERSTOCK?"Shutterstock":n.platform===jr.FREEPIK?"Freepik":"Adobe Stock";i.push({text:`Analyze these ${e.length} assets and generate ${n.mode===Ti.PROMPT?"image generation prompts":`${c} metadata`}. Return a JSON array corresponding to this order.`}),e.forEach((h,p)=>{const m=h.mediaParts.some(v=>v.inlineData.mimeType==="image/png")||h.filename.toLowerCase().endsWith(".png");let y=`
7097--- ASSET ${p+1} (Filename: ${h.filename}) [Type: ${h.type}] ---
7098`;n.mode===Ti.METADATA&&m&&(y+=' IMPORTANT: This is a PNG. Naturally include "isolated on transparent background" in the title and keywords.'),i.push({text:y}),h.mediaParts.forEach(v=>i.push(v))})}const a=n.provider==="gemini"?RS.length-1:2;let o=0,l=n.modelId;for(;o<=a;)try{let c={...n,modelId:l};if(n.provider==="groq"||n.provider==="mistral"){const h=n.provider==="groq"?"https://api.groq.com/openai/v1/chat/completions":"https://api.mistral.ai/v1/chat/completions",p=[];for(const m of e){let y=0,v=!1;for(;y<=3&&!v;)try{const b=await SOe(t,m,c,h);p.push(b),v=!0}catch(b){const S=b.message||"";if(S.includes("429")||S.includes("Rate limit")||S.toLowerCase().includes("too many requests")||S.includes("TPM")){if(y++,y>3)throw b;const I=S.match(/try again in (\d+(\.\d+)?)s/);let M=2e3*Math.pow(2,y);I?M=parseFloat(I[1])*1e3+1500:S.includes("TPM")&&(M=5e3*y),n.provider==="mistral"&&(M=Math.max(M,5e3*(y+1))),console.warn(`${n.provider} Rate limit hit for ${m.filename}. Waiting ${M}ms before retry...`),await T3(M)}else throw b}e.length>1&&await T3(n.provider==="groq"?300:n.provider==="mistral"?3e3:500)}return p}else{const h=await _Oe(t,e,c,i);if(!h)throw new Error("Empty response from AI");let p=h.replace(/```json\s*|\s*```/g,"").trim();const m=p.indexOf("["),y=p.lastIndexOf("]");m!==-1&&y!==-1&&y>m&&(p=p.substring(m,y+1));let v;try{v=JSON.parse(p)}catch(S){throw console.error("Gemini JSON Parse Error:",S.message),S.message.includes("Unterminated string")||S.message.includes("Unexpected end of JSON input")?new Error("AI output truncated. Please reduce batch size or retry."):new Error("AI response was malformed. Please retry.")}const b=Array.isArray(v)?v:v.items||v.assets||[v];if(!Array.isArray(b))throw new Error("Invalid format: Not an array");return b.map(S=>{let E=S.category||"";return n.isSeamless&&(n.platform===jr.ADOBE_STOCK?E=S.adobe_category:n.platform===jr.SHUTTERSTOCK&&(E=S.shutterstock_category)),{title:S.title||"",keywords:S.keywords||"",category:E||"",prompt:S.prompt||"",adobe_category:S.adobe_category,shutterstock_category:S.shutterstock_category}})}}catch(c){const h=c.message||"",p=c.status===429||c.code===429||h.includes("429")||h.toLowerCase().includes("rate limit")||h.includes("RESOURCE_EXHAUSTED"),m=c.status===503||c.code===503||h.includes("503")||h.includes("Service Unavailable");
7098if((p||m)&&o<a){if(n.provider==="gemini"){const y=bOe(l);if(y!==l){const v=p?"Rate limit Detected":"503 error detected";console.warn(`Gemini Error (${v}). Switching from ${l} to ${y}.`),s&&s(`${v}, switching to alternative model`),r&&r(y),l=y}}o++,await T3(2e3*Math.pow(2,o));continue}throw c}throw new Error("Generation failed after retries")},TOe=async(t,e,n)=>{var a,o,l;const s=`You are an elite Prompt Engineer specializing in AI system instructions for Stock Photography Metadata generation.
7099The user provides a raw, often simple instruction intended to guide the AI behavior.
7100Your task is to expand and refine this into a comprehensive, high-fidelity system prompt directive.
7101Do not be brief. Elaborate on the implications of the user's request to ensure the AI follows it strictly.
7102Explain the nuances of the request and add necessary constraints to ensure high-quality output.
7103Use professional, authoritative language suitable for a System Prompt.
7104
7105Example Input: "no brands"
7106Example Output: "Strictly exclude all brand names, trademarks, logotypes, or specific product model names from the generated titles and keywords. Focus solely on generic descriptors of the visual content. Ensure no intellectual property infringement in the textual data."
7107
7108Example Input: "give me short keywords"
7109Example Output: "Prioritize brevity in keyword generation. Ensure all generated keywords are concise, single-word tags or very short phrases. Avoid long-tail keywords or complex compound descriptions unless absolutely necessary for context. Maintain high relevance while minimizing token count per keyword."
7110
7111Return ONLY the refined instruction text. Do not add introductory text.`;if(n==="groq"||n==="mistral"){const c=n==="groq"?"https://api.groq.com/openai/v1/chat/completions":"https://api.mistral.ai/v1/chat/completions",h=n==="groq"?"llama-3.3-70b-versatile":"mistral-large-latest",p=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({messages:[{role:"system",content:s},{role:"user",content:e}],model:h,temperature:.7,max_tokens:1024})});if(!p.ok){const y=await p.json().catch(()=>null),v=(y==null?void 0:y.message)||((a=y==null?void 0:y.error)==null?void 0:a.message)||(y==null?void 0:y.detail)||p.statusText||"Unknown Error";throw new Error(`${n} API Error (${p.status}): ${v}`)}return((l=(o=(await p.json()).choices[0])==null?void 0:o.message)==null?void 0:l.content)||e}return(await new Yie({apiKey:t}).models.generateContent({model:"gemini-3-flash-preview",contents:e,config:{systemInstruction:s}})).text||e},AOe=(t,e=jr.ADOBE_STOCK)=>{const n=e===jr.SHUTTERSTOCK,s=e===jr.FREEPIK;let r=[];n?r=["Filename","Description","Keywords","Categories"]:s?r=["File name;Title;Keywords"]:r=["Filename","Title","Keywords","Category"];const i=t.map(p=>{const m=b=>`"${b.replace(/"/g,'""')}"`;if(s){const b=`${p.file.name};`,S=`${p.metadata.title};`,E=`${p.metadata.keywords};`;return[m(b),m(S),m(E)].join(",")}let y="";if(n)y=p.metadata.shutterstock_category||p.metadata.category;else{const b=p.metadata.adobe_category||p.metadata.category,S=sZ[b];y=S!==void 0?String(S):""}return[m(p.file.name),m(p.metadata.title),m(p.metadata.keywords),m(y)].join(",")}),a=[r.join(","),...i].join(`
7112`),o=new Blob([a],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),c=document.createElement("a");c.setAttribute("href",l);let h="adobe_stock";n&&(h="shutterstock"),s&&(h="freepik"),c.setAttribute("download",`${h}_metadata_${new Date().toISOString().slice(0,10)}.csv`),c.style.visibility="hidden",document.body.appendChild(c),c.click(),document.body.removeChild(c)},COe=t=>{const n=t.filter(a=>a.status==="COMPLETED").map(a=>`Filename: ${a.file.name}
7113
7114Prompt: ${a.metadata.prompt||""}
7115
7116`).join(`---
7117
7118`),s=new Blob([n],{type:"text/plain;charset=utf-8;"}),r=URL.createObjectURL(s),i=document.createElement("a");i.setAttribute("href",r),i.setAttribute("download",`image_prompts_${new Date().toISOString().slice(0,10)}.txt`),i.style.visibility="hidden",document.body.appendChild(i),i.click(),document.body.removeChild(i)};(function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self,t.MP4Tag=e())})(void 0,(function(){function t(U,V){(V==null||V>U.length)&&(V=U.length);for(var Z=0,ae=Array(V);Z<V;Z++)ae[Z]=U[Z];return ae}function e(U){if(Array.isArray(U))return t(U)}function n(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function s(U,V,Z){return V=l(V),v(U,p()?Reflect.construct(V,Z||[],l(U).constructor):V.apply(U,Z))}function r(U,V){if(!(U instanceof V))throw new TypeError("Cannot call a class as a function")}function i(U,V,Z){if(p())return Reflect.construct.apply(null,arguments);var ae=[null];ae.push.apply(ae,V);var _e=new(U.bind.apply(U,ae));return Z&&b(_e,Z.prototype),_e}function a(U,V){for(var Z=0;Z<V.length;Z++){var ae=V[Z];ae.enumerable=ae.enumerable||!1,ae.configurable=!0,"value"in ae&&(ae.writable=!0),Object.defineProperty(U,I(ae.key),ae)}}function o(U,V,Z){return V&&a(U.prototype,V),Z&&a(U,Z),Object.defineProperty(U,"prototype",{writable:!1}),U}function l(U){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(V){return V.__proto__||Object.getPrototypeOf(V)},l(U)}function c(U,V){if(typeof V!="function"&&V!==null)throw new TypeError("Super expression must either be null or a function");U.prototype=Object.create(V&&V.prototype,{constructor:{value:U,writable:!0,configurable:!0}}),Object.defineProperty(U,"prototype",{writable:!1}),V&&b(U,V)}function h(U){try{return Function.toString.call(U).indexOf("[native code]")!==-1}catch{return typeof U=="function"}}function p(){try{var U=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(p=function(){return!!U})()}function m(U){if(typeof Symbol<"u"&&U[Symbol.iterator]!=null||U["@@iterator"]!=null)return Array.from(U)}function y(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
7119In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v(U,V){if(V&&(typeof V=="object"||typeof V=="function"))return V;if(V!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return n(U)}function b(U,V){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Z,ae){return Z.__proto__=ae,Z},b(U,V)}function S(U){return e(U)||m(U)||j(U)||y()}function E(U,V){if(typeof U!="object"||!U)return U;var Z=U[Symbol.toPrimitive];if(Z!==void 0){var ae=Z.call(U,V);if(typeof ae!="object")return ae;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(U)}function I(U){var V=E(U,"string");return typeof V=="symbol"?V:V+""}function M(U){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(V){return typeof V}:function(V){return V&&typeof Symbol=="function"&&V.constructor===Symbol&&V!==Symbol.prototype?"symbol":typeof V},M(U)}function j(U,V){if(U){if(typeof U=="string")return t(U,V);var Z={}.toString.call(U).slice(8,-1);
vendor: 9,874 bytes, line 7119
7119return Z==="Object"&&U.constructor&&(Z=U.constructor.name),Z==="Map"||Z==="Set"?Array.from(U):Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z)?t(U,V):void 0}}function L(U){var V=typeof Map=="function"?new Map:void 0;return L=function(Z){if(Z===null||!h(Z))return Z;if(typeof Z!="function")throw new TypeError("Super expression must either be null or a function");if(V!==void 0){if(V.has(Z))return V.get(Z);V.set(Z,ae)}function ae(){return i(Z,arguments,l(this).constructor)}return ae.prototype=Object.create(Z.prototype,{constructor:{value:ae,enumerable:!1,writable:!0,configurable:!0}}),b(ae,Z)},L(U)}var K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},D=function(U){return U&&U.Math===Math&&U},R=D(typeof globalThis=="object"&&globalThis)||D(typeof window=="object"&&window)||D(typeof self=="object"&&self)||D(typeof K=="object"&&K)||D(typeof K=="object"&&K)||(function(){return this})()||Function("return this")(),B={},G=function(U){try{return!!U()}catch{return!0}},X=G,H=!X(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),Y=G,F=!Y(function(){var U=(function(){}).bind();return typeof U!="function"||U.hasOwnProperty("prototype")}),we=F,me=Function.prototype.call,xe=we?me.bind(me):function(){return me.apply(me,arguments)},Le={},ve={}.propertyIsEnumerable,ce=Object.getOwnPropertyDescriptor,ie=ce&&!ve.call({1:2},1);Le.f=ie?function(V){var Z=ce(this,V);return!!Z&&Z.enumerable}:ve;var de=function(U,V){return{enumerable:!(U&1),configurable:!(U&2),writable:!(U&4),value:V}},Re=F,Se=Function.prototype,De=Se.call,gt=Re&&Se.bind.bind(De,De),yt=Re?gt:function(U){return function(){return De.apply(U,arguments)}},xt=yt,Nt=xt({}.toString),wt=xt("".slice),zt=function(U){return wt(Nt(U),8,-1)},_n=yt,Zt=G,J=zt,We=Object,Ie=_n("".split),ge=Zt(function(){return!We("z").propertyIsEnumerable(0)})?function(U){return J(U)==="String"?Ie(U,""):We(U)}:We,he=function(U){return U==null},Ae=he,et=TypeError,nt=function(U){if(Ae(U))throw new et("Can't call method on "+U);return U},He=ge,ft=nt,Mt=function(U){return He(ft(U))},pt=typeof document=="object"&&document.all,Oe=typeof pt>"u"&&pt!==void 0?function(U){return typeof U=="function"||U===pt}:function(U){return typeof U=="function"},hn=Oe,Yt=function(U){return typeof U=="object"?U!==null:hn(U)},Qe=R,tn=Oe,je=function(U){return tn(U)?U:void 0},Ue=function(U,V){return arguments.length<2?je(Qe[U]):Qe[U]&&Qe[U][V]},bt=yt,ht=bt({}.isPrototypeOf),Dt=R,Ut=Dt.navigator,Lt=Ut&&Ut.userAgent,Wt=Lt?String(Lt):"",fn=R,Jt=Wt,Kn=fn.process,nn=fn.Deno,Wn=Kn&&Kn.versions||nn&&nn.version,ln=Wn&&Wn.v8,ns,Js;ln&&(ns=ln.split("."),Js=ns[0]>0&&ns[0]<4?1:+(ns[0]+ns[1])),!Js&&Jt&&(ns=Jt.match(/Edge\/(\d+)/),(!ns||ns[1]>=74)&&(ns=Jt.match(/Chrome\/(\d+)/),ns&&(Js=+ns[1])));var ur=Js,zs=ur,fs=G,ps=R,ms=ps.String,Me=!!Object.getOwnPropertySymbols&&!fs(function(){var U=Symbol("symbol detection");return!ms(U)||!(Object(U)instanceof Symbol)||!Symbol.sham&&zs&&zs<41}),lt=Me,jt=lt&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Qt=Ue,Sn=Oe,yn=ht,Ft=jt,sn=Object,rn=Ft?function(U){return typeof U=="symbol"}:function(U){var V=Qt("Symbol");return Sn(V)&&yn(V.prototype,sn(U))},bs=String,gs=function(U){try{return bs(U)}catch{return"Object"}},us=Oe,Hn=gs,ls=TypeError,Ps=function(U){if(us(U))return U;throw new ls(Hn(U)+" is not a function")},rr=Ps,ws=he,$s=function(U,V){var Z=U[V];return ws(Z)?void 0:rr(Z)},ys=xe,Pn=Oe,ir=Yt,ot=TypeError,ar=function(U,V){var Z,ae;if(V==="string"&&Pn(Z=U.toString)&&!ir(ae=ys(Z,U))||Pn(Z=U.valueOf)&&!ir(ae=ys(Z,U))||V!=="string"&&Pn(Z=U.toString)&&!ir(ae=ys(Z,U)))return ae;throw new ot("Can't convert object to primitive value")},$n={exports:{}},kn=R,Nn=Object.defineProperty,Bn=function(U,V){try{Nn(kn,U,{value:V,configurable:!0,writable:!0})}catch{kn[U]=V}return V},er=R,oi=Bn,or="__core-js_shared__",ue=$n.exports=er[or]||oi(or,{});(ue.versions||(ue.versions=[])).push({version:"3.38.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ke=$n.exports,pe=ke,Pe=function(U,V){return pe[U]||(pe[U]=V||{})},$e=nt,Ne=Object,tt=function(U){return Ne($e(U))},mt=yt,Ct=tt,_t=mt({}.hasOwnProperty),kt=Object.hasOwn||function(V,Z){return _t(Ct(V),Z)},Xt=yt,qn=0,Xn=Math.random(),an=Xt(1 .toString),Jn=function(U){return"Symbol("+(U===void 0?"":U)+")_"+an(++qn+Xn,36)},Qn=R,Gs=Pe,Cr=kt,Qs=Jn,ti=Me,gi=jt,yr=Qn.Symbol,_a=Gs("wks"),Va=gi?yr.for||yr:yr&&yr.withoutSetter||Qs,Ls=function(U){return Cr(_a,U)||(_a[U]=ti&&Cr(yr,U)?yr[U]:Va("Symbol."+U)),_a[U]},li=xe,ni=Yt,pn=rn,ji=$s,za=ar,Ai=Ls,Ye=TypeError,vt=Ai("toPrimitive"),ct=function(U,V){if(!ni(U)||pn(U))return U;var Z=ji(U,vt),ae;if(Z){if(V===void 0&&(V="default"),ae=li(Z,U,V),!ni(ae)||pn(ae))return ae;throw new Ye("Can't convert object to primitive value")}return V===void 0&&(V="number"),za(U,V)},Kt=ct,ds=rn,Mr=function(U){var V=Kt(U,"string");return ds(V)?V:V+""},Ds=R,Hs=Yt,un=Ds.document,Yn=Hs(un)&&Hs(un.createElement),As=function(U){return Yn?un.createElement(U):{}},Pr=H,kr=G,Yi=As,Ga=!Pr&&!kr(function(){return Object.defineProperty(Yi("div"),"a",{get:function(){return 7}}).a!==7}),wl=H,sa=xe,ra=Le,Bi=de,_l=Mt,Pu=Mr,Uc=kt,ic=Ga,Cd=Object.getOwnPropertyDescriptor;B.f=wl?Cd:function(V,Z){if(V=_l(V),Z=Pu(Z),ic)try{return Cd(V,Z)}catch{}if(Uc(V,Z))return Bi(!sa(ra.f,V,Z),V[Z])};var ci={},xr=H,gn=G,Sa=xr&&gn(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),yi=Yt,uo=String,Xo=TypeError,Ha=function(U){if(yi(U))return U;throw new Xo(uo(U)+" is not an object")},kd=H,Fc=Ga,Id=Sa,ia=Ha,qr=Mr,ac=TypeError,Sl=Object.defineProperty,Io=Object.getOwnPropertyDescriptor,C="enumerable",W="configurable",ne="writable";ci.f=kd?Id?function(V,Z,ae){if(ia(V),Z=qr(Z),ia(ae),typeof V=="function"&&Z==="prototype"&&"value"in ae&&ne in ae&&!ae[ne]){var _e=Io(V,Z);_e&&_e[ne]&&(V[Z]=ae.value,ae={configurable:W in ae?ae[W]:_e[W],enumerable:C in ae?ae[C]:_e[C],writable:!1})}return Sl(V,Z,ae)}:Sl:function(V,Z,ae){if(ia(V),Z=qr(Z),ia(ae),Fc)try{return Sl(V,Z,ae)}catch{}if("get"in ae||"set"in ae)throw new ac("Accessors not supported");return"value"in ae&&(V[Z]=ae.value),V};var ye=H,Xe=ci,rt=de,Vt=ye?function(U,V,Z){return Xe.f(U,V,rt(1,Z))}:function(U,V,Z){return U[V]=Z,U},Zn={exports:{}},dr=H,lr=kt,wr=Function.prototype,aa=dr&&Object.getOwnPropertyDescriptor,qa=lr(wr,"name"),No=qa&&(function(){}).name==="something",fa=qa&&(!dr||dr&&aa(wr,"name").configurable),pa={EXISTS:qa,PROPER:No,CONFIGURABLE:fa},$u=yt,ef=Oe,oc=ke,Du=$u(Function.toString);ef(oc.inspectSource)||(oc.inspectSource=function(U){return Du(U)});var ho=oc.inspectSource,Vc=R,Ou=Oe,Nd=Vc.WeakMap,Rd=Ou(Nd)&&/native code/.test(String(Nd)),js=Pe,lc=Jn,Md=js("keys"),El=function(U){return Md[U]||(Md[U]=lc(U))},Lu={},Ir=Rd,Wa=R,Pd=Yt,cc=Vt,fo=kt,$d=ke,vp=El,oa=Lu,Wr="Object already initialized",Tl=Wa.TypeError,_s=Wa.WeakMap,Ea,Jo,es,Ta=function(U){return es(U)?Jo(U):Ea(U,{})},hs=function(U){return function(V){var Z;if(!Pd(V)||(Z=Jo(V)).type!==U)throw new Tl("Incompatible receiver, "+U+" required");return Z}};if(Ir||$d.state){var Ci=$d.state||($d.state=new _s);Ci.get=Ci.get,Ci.has=Ci.has,Ci.set=Ci.set,Ea=function(U,V){if(Ci.has(U))throw new Tl(Wr);return V.facade=U,Ci.set(U,V),V},Jo=function(U){return Ci.get(U)||{}},es=function(U){return Ci.has(U)}}else{var $r=vp("state");oa[$r]=!0,Ea=function(U,V){if(fo(U,$r))throw new Tl(Wr);return V.facade=U,cc(U,$r,V),V},Jo=function(U){return fo(U,$r)?U[$r]:{}},es=function(U){return fo(U,$r)}}var Aa={set:Ea,get:Jo,has:es,enforce:Ta,getterFor:hs},uc=yt,zc=G,Al=Oe,Qo=kt,dc=H,Dd=pa.CONFIGURABLE,la=ho,Zo=Aa,ju=Zo.enforce,tf=Zo.get,nf=String,Gc=Object.defineProperty,qm=uc("".slice),sf=uc("".replace),rf=uc([].join),xi=dc&&!zc(function(){return Gc(function(){},"length",{value:8}).length!==8}),ma=String(String).split("String"),Ui=Zn.exports=function(U,V,Z){qm(nf(V),0,7)==="Symbol("&&(V="["+sf(nf(V),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),Z&&Z.getter&&(V="get "+V),Z&&Z.setter&&(V="set "+V),(!Qo(U,"name")||Dd&&U.name!==V)&&(dc?Gc(U,"name",{value:V,configurable:!0}):U.name=V),xi&&Z&&Qo(Z,"arity")&&U.length!==Z.arity&&Gc(U,"length",{value:Z.arity});try{Z&&Qo(Z,"constructor")&&Z.constructor?dc&&Gc(U,"prototype",{writable:!1}):U.prototype&&(U.prototype=void 0)}catch{}var ae=ju(U);return Qo(ae,"source")||(ae.source=rf(ma,typeof V=="string"?V:"")),U};Function.prototype.toString=Ui(function(){return Al(this)&&tf(this).source||la(this)},"toString");var el=Zn.exports,Bu=Oe,Uu=ci,tl=el,Hc=Bn,vi=function(U,V,Z,ae){ae||(ae={});var _e=ae.enumerable,qe=ae.name!==void 0?ae.name:V;if(Bu(Z)&&tl(Z,qe,ae),ae.global)_e?U[V]=Z:Hc(V,Z);else{try{ae.unsafe?U[V]&&(_e=!0):delete U[V]}catch{}_e?U[V]=Z:Uu.f(U,V,{value:Z,enumerable:!1,configurable:!ae.nonConfigurable,writable:!ae.nonWritable})}return U},Od={},Ld=Math.ceil,hc=Math.floor,af=Math.trunc||function(V){var Z=+V;return(Z>0?hc:Ld)(Z)},Ka=af,Ya=function(U){var V=+U;return V!==V||V===0?0:Ka(V)},fc=Ya,jd=Math.max,Bd=Math.min,ki=function(U,V){var Z=fc(U);return Z<0?jd(Z+V,0):Bd(Z,V)},Xa=Ya,Cl=Math.min,Xi=function(U){var V=Xa(U);return V>0?Cl(V,9007199254740991):0},Ro=Xi,Fi=function(U){return Ro(U.length)},of=Mt,lf=ki,cf=Fi,Fr=function(U){return function(V,Z,ae){var _e=of(V),qe=cf(_e);if(qe===0)return!U&&-1;var Ke=lf(ae,qe),ze;if(U&&Z!==Z){for(;qe>Ke;)if(ze=_e[Ke++],ze!==ze)return!0}else for(;qe>Ke;Ke++)if((U||Ke in _e)&&_e[Ke]===Z)return U||Ke||0;return!U&&-1}},Kr={includes:Fr(!0),indexOf:Fr(!1)},Bs=yt,Ca=kt,nl=Mt,Ud=Kr.indexOf,qc=Lu,bp=Bs([].push),uf=function(U,V){var Z=nl(U),ae=0,_e=[],qe;for(qe in Z)!Ca(qc,qe)&&Ca(Z,qe)&&bp(_e,qe);for(;V.length>ae;)Ca(Z,qe=V[ae++])&&(~Ud(_e,qe)||bp(_e,qe));return _e},Wc=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleStr
7119ing","toString","valueOf"],Fd=uf,Vd=Wc,zd=Vd.concat("length","prototype");Od.f=Object.getOwnPropertyNames||function(V){return Fd(V,zd)};var wp={};wp.f=Object.getOwnPropertySymbols;var _p=Ue,po=yt,ka=Od,Fu=wp,pc=Ha,df=po([].concat),kl=_p("Reflect","ownKeys")||function(V){var Z=ka.f(pc(V)),ae=Fu.f;return ae?df(Z,ae(V)):Z},mc=kt,hf=kl,Gd=B,Hd=ci,Sp=function(U,V,Z){for(var ae=hf(V),_e=Hd.f,qe=Gd.f,Ke=0;Ke<ae.length;Ke++){var ze=ae[Ke];!mc(U,ze)&&!(Z&&mc(Z,ze))&&_e(U,ze,qe(V,ze))}},qd=G,gc=Oe,Wm=/#|\.prototype\./,Mo=function(U,V){var Z=ff[Vu(U)];return Z===Km?!0:Z===Ep?!1:gc(V)?qd(V):!!V},Vu=Mo.normalize=function(U){return String(U).replace(Wm,".").toLowerCase()},ff=Mo.data={},Ep=Mo.NATIVE="N",Km=Mo.POLYFILL="P",mo=Mo,Ia=R,yc=B.f,Tp=Vt,Il=vi,Nl=Bn,bi=Sp,zu=mo,ui=function(U,V){var Z=U.target,ae=U.global,_e=U.stat,qe,Ke,ze,ut,at,Ht;if(ae?Ke=Ia:_e?Ke=Ia[Z]||Nl(Z,{}):Ke=Ia[Z]&&Ia[Z].prototype,Ke)for(ze in V){if(at=V[ze],U.dontCallGetSet?(Ht=yc(Ke,ze),ut=Ht&&Ht.value):ut=Ke[ze],qe=zu(ae?ze:Z+(_e?".":"#")+ze,U.forced),!qe&&ut!==void 0){if(typeof at==typeof ut)continue;bi(at,ut)}(U.sham||ut&&ut.sham)&&Tp(at,"sham",!0),Il(Ke,ze,at,U)}},Rl=zt,Wd=Array.isArray||function(V){return Rl(V)==="Array"},x=TypeError,A=9007199254740991,$=function(U){if(U>A)throw x("Maximum allowed index exceeded");return U},P=H,z=ci,Q=de,ee=function(U,V,Z){P?z.f(U,V,Q(0,Z)):U[V]=Z},re=Ls,be=re("toStringTag"),Ee={};Ee[be]="z";var Te=String(Ee)==="[object z]",Be=Te,Ze=Oe,Fe=zt,Gt=Ls,Tt=Gt("toStringTag"),Bt=Object,en=Fe((function(){return arguments})())==="Arguments",Ln=function(U,V){try{return U[V]}catch{}},Dn=Be?Fe:function(U){var V,Z,ae;return U===void 0?"Undefined":U===null?"Null":typeof(Z=Ln(V=Bt(U),Tt))=="string"?Z:en?Fe(V):(ae=Fe(V))==="Object"&&Ze(V.callee)?"Arguments":ae},Os=yt,Rn=G,On=Oe,Ss=Dn,Dr=Ue,Us=ho,is=function(){},Yr=Dr("Reflect","construct"),di=/^\s*(?:class|function)\b/,Kc=Os(di.exec),Gu=!di.test(is),wi=function(V){if(!On(V))return!1;try{return Yr(is,[],V),!0}catch{return!1}},sl=function(V){if(!On(V))return!1;switch(Ss(V)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Gu||!!Kc(di,Us(V))}catch{return!0}};sl.sham=!0;var Yc=!Yr||Rn(function(){var U;return wi(wi.call)||!wi(Object)||!wi(function(){U=!0})||U})?sl:wi,xc=Wd,Xr=Yc,Vr=Yt,Ym=Ls,Ap=Ym("species"),pf=Array,Xm=function(U){var V;return xc(U)&&(V=U.constructor,Xr(V)&&(V===pf||xc(V.prototype))?V=void 0:Vr(V)&&(V=V[Ap],V===null&&(V=void 0))),V===void 0?pf:V},Un=Xm,_r=function(U,V){return new(Un(U))(V===0?0:V)},Fs=G,vr=Ls,Ii=ur,mf=vr("species"),Po=function(U){return Ii>=51||!Fs(function(){var V=[],Z=V.constructor={};return Z[mf]=function(){return{foo:1}},V[U](Boolean).foo!==1})},vc=ui,Xc=G,bc=Wd,Jc=Yt,Kd=tt,Ml=Fi,wc=$,Qc=ee,Pl=_r,gf=Po,Jm=Ls,ry=ur,Qm=Jm("isConcatSpreadable"),iy=ry>=51||!Xc(function(){var U=[];return U[Qm]=!1,U.concat()[0]!==U}),_c=function(U){if(!Jc(U))return!1;var V=U[Qm];return V!==void 0?!!V:bc(U)},Kv=!iy||!gf("concat");vc({target:"Array",proto:!0,arity:1,forced:Kv},{concat:function(V){var Z=Kd(this),ae=Pl(Z,0),_e=0,qe,Ke,ze,ut,at;for(qe=-1,ze=arguments.length;qe<ze;qe++)if(at=qe===-1?Z:arguments[qe],_c(at))for(ut=Ml(at),wc(_e+ut),Ke=0;Ke<ut;Ke++,_e++)Ke in at&&Qc(ae,_e,at[Ke]);else wc(_e+1),Qc(ae,_e++,at);return ae.length=_e,ae}});var Cp=zt,Zm=yt,ay=function(U){if(Cp(U)==="Function")return Zm(U)},oy=ay,Yv=Ps,LA=F,c_=oy(oy.bind),u_=function(U,V){return Yv(U),V===void 0?U:LA?c_(U,V):function(){return U.apply(V,arguments)}},jA=u_,BA=yt,UA=ge,d_=tt,FA=Fi,VA=_r,Xv=BA([].push),yf=function(U){var V=U===1,Z=U===2,ae=U===3,_e=U===4,qe=U===6,Ke=U===7,ze=U===5||qe;return function(ut,at,Ht,dn){for(var zn=d_(ut),Mi=UA(zn),Qr=FA(Mi),fr=jA(at,Ht),xs=0,Or=dn||VA,ya=V?Or(ut,Qr):Z||Ke?Or(ut,0):void 0,Ag,Cg;Qr>xs;xs++)if((ze||xs in Mi)&&(Ag=Mi[xs],Cg=fr(Ag,xs,zn),U))if(V)ya[xs]=Cg;else if(Cg)switch(U){case 3:return!0;case 5:return Ag;case 6:return xs;case 2:Xv(ya,Ag)}else switch(U){case 4:return!1;case 7:Xv(ya,Ag)}return qe?-1:ae||_e?_e:ya}},Sc={forEach:yf(0),map:yf(1),filter:yf(2),some:yf(3),every:yf(4),find:yf(5),findIndex:yf(6)},XM=G,kp=function(U,V){var Z=[][U];return!!Z&&XM(function(){Z.call(null,V||function(){return 1},1)})},zA=Sc.forEach,GA=kp,h_=GA("forEach"),f_=h_?[].forEach:function(V){return zA(this,V,arguments.length>1?arguments[1]:void 0)},HA=ui,qA=f_;HA({target:"Array",proto:!0,forced:[].forEach!==qA},{forEach:qA});var WA={},KA=uf,ly=Wc,p_=Object.keys||function(V){return KA(V,ly)},Jv=H,YA=Sa,XA=ci,Hu=Ha,Ip=Mt,xf=p_;WA.f=Jv&&!YA?Object.defineProperties:function(V,Z){Hu(V);for(var ae=Ip(Z),_e=xf(Z),qe=_e.length,Ke=0,ze;qe>Ke;)XA.f(V,ze=_e[Ke++],ae[ze]);return V};var Np=Ue,m_=Np("document","documentElement"),g_=Ha,JA=WA,y_=Wc,Rp=Lu,Qv=m_,QA
vendor: 4,573 bytes, line 7119
7119=As,ZA=El,x_=">",cy="<",Zv="prototype",uy="script",v_=ZA("IE_PROTO"),eb=function(){},eC=function(U){return cy+uy+x_+U+cy+"/"+uy+x_},b_=function(U){U.write(eC("")),U.close();var V=U.parentWindow.Object;return U=null,V},Na=function(){var U=QA("iframe"),V="java"+uy+":",Z;return U.style.display="none",Qv.appendChild(U),U.src=String(V),Z=U.contentWindow.document,Z.open(),Z.write(eC("document.F=Object")),Z.close(),Z.F},ca,dy=function(){try{ca=new ActiveXObject("htmlfile")}catch{}dy=typeof document<"u"?document.domain&&ca?b_(ca):Na():b_(ca);for(var U=y_.length;U--;)delete dy[Zv][y_[U]];return dy()};Rp[v_]=!0;var hy=Object.create||function(V,Z){var ae;return V!==null?(eb[Zv]=g_(V),ae=new eb,eb[Zv]=null,ae[v_]=V):ae=dy(),Z===void 0?ae:JA.f(ae,Z)},tC=Ls,nC=hy,sC=ci.f,Mp=tC("unscopables"),fy=Array.prototype;fy[Mp]===void 0&&sC(fy,Mp,{configurable:!0,value:nC(null)});var tb=function(U){fy[Mp][U]=!0},rC=ui,iC=Kr.includes,w_=G,__=tb,S_=w_(function(){return!Array(1).includes()});rC({target:"Array",proto:!0,forced:S_},{includes:function(V){return iC(this,V,arguments.length>1?arguments[1]:void 0)}}),__("includes");var aC=ui,E_=ay,T_=Kr.indexOf,A_=kp,nb=E_([].indexOf),sb=!!nb&&1/nb([1],1,-0)<0,oC=sb||!A_("indexOf");aC({target:"Array",proto:!0,forced:oC},{indexOf:function(V){var Z=arguments.length>1?arguments[1]:void 0;return sb?nb(this,V,Z)||0:T_(this,V,Z)}});var Yd=ui,C_=Wd;Yd({target:"Array",stat:!0},{isArray:C_});var py={},lC=G,k_=!lC(function(){function U(){}return U.prototype.constructor=null,Object.getPrototypeOf(new U)!==U.prototype}),Pp=kt,Xd=Oe,vf=tt,Jd=El,I_=k_,rb=Jd("IE_PROTO"),$p=Object,ib=$p.prototype,qu=I_?$p.getPrototypeOf:function(U){var V=vf(U);if(Pp(V,rb))return V[rb];var Z=V.constructor;return Xd(Z)&&V instanceof Z?Z.prototype:V instanceof $p?ib:null},go=G,ab=Oe,cC=Yt,Qd=qu,N_=vi,R_=Ls,Wu=R_("iterator"),Zd=!1,Zc,my,gy;[].keys&&(gy=[].keys(),"next"in gy?(my=Qd(Qd(gy)),my!==Object.prototype&&(Zc=my)):Zd=!0);var yy=!cC(Zc)||go(function(){var U={};return Zc[Wu].call(U)!==U});yy&&(Zc={}),ab(Zc[Wu])||N_(Zc,Wu,function(){return this});var eg={IteratorPrototype:Zc,BUGGY_SAFARI_ITERATORS:Zd},uC=ci.f,dC=kt,xy=Ls,eh=xy("toStringTag"),ob=function(U,V,Z){U&&!Z&&(U=U.prototype),U&&!dC(U,eh)&&uC(U,eh,{configurable:!0,value:V})},hC=eg.IteratorPrototype,Dp=hy,$l=de,fC=ob,pC=py,mC=function(){return this},M_=function(U,V,Z,ae){var _e=V+" Iterator";return U.prototype=Dp(hC,{next:$l(+!ae,Z)}),fC(U,_e,!1),pC[_e]=mC,U},P_=yt,lb=Ps,th=function(U,V,Z){try{return P_(lb(Object.getOwnPropertyDescriptor(U,V)[Z]))}catch{}},Vi=Yt,$_=function(U){return Vi(U)||U===null},gC=$_,Ra=String,yC=TypeError,JM=function(U){if(gC(U))return U;throw new yC("Can't set "+Ra(U)+" as a prototype")},xC=th,vC=Yt,ua=nt,Dl=JM,Ol=Object.setPrototypeOf||("__proto__"in{}?(function(){var U=!1,V={},Z;try{Z=xC(Object.prototype,"__proto__","set"),Z(V,[]),U=V instanceof Array}catch{}return function(_e,qe){return ua(_e),Dl(qe),vC(_e)&&(U?Z(_e,qe):_e.__proto__=qe),_e}})():void 0),bC=ui,wC=xe,_C=pa,D_=Oe,Ec=M_,Tc=qu,O_=Ol,Ac=ob,SC=Vt,eu=vi,tg=Ls,bf=py,cb=eg,L_=_C.PROPER,wf=_C.CONFIGURABLE,j_=cb.IteratorPrototype,nh=cb.BUGGY_SAFARI_ITERATORS,sh=tg("iterator"),ng="keys",Ku="values",B_="entries",EC=function(){return this},vy=function(U,V,Z,ae,_e,qe,Ke){Ec(Z,V,ae);var ze=function(Or){if(Or===_e&&zn)return zn;if(!nh&&Or&&Or in Ht)return Ht[Or];switch(Or){case ng:return function(){return new Z(this,Or)};case Ku:return function(){return new Z(this,Or)};case B_:return function(){return new Z(this,Or)}}return function(){return new Z(this)}},ut=V+" Iterator",at=!1,Ht=U.prototype,dn=Ht[sh]||Ht["@@iterator"]||_e&&Ht[_e],zn=!nh&&dn||ze(_e),Mi=V==="Array"&&Ht.entries||dn,Qr,fr,xs;if(Mi&&(Qr=Tc(Mi.call(new U)),Qr!==Object.prototype&&Qr.next&&(Tc(Qr)!==j_&&(O_?O_(Qr,j_):D_(Qr[sh])||eu(Qr,sh,EC)),Ac(Qr,ut,!0))),L_&&_e===Ku&&dn&&dn.name!==Ku&&(wf?SC(Ht,"name",Ku):(at=!0,zn=function(){return wC(dn,this)})),_e)if(fr={values:ze(Ku),keys:qe?zn:ze(ng),entries:ze(B_)},Ke)for(xs in fr)(nh||at||!(xs in Ht))&&eu(Ht,xs,fr[xs]);else bC({target:V,proto:!0,forced:nh||at},fr);return Ht[sh]!==zn&&eu(Ht,sh,zn,{name:_e}),bf[V]=zn,fr},TC=function(U,V){return{value:U,done:V}},ub=Mt,db=tb,AC=py,Ll=Aa,U_=ci.f,_f=vy,by=TC,hb=H,Sf="Array Iterator",CC=Ll.set,F_=Ll.getterFor(Sf),V_=_f(Array,"Array",function(U,V){CC(this,{type:Sf,target:ub(U),index:0,kind:V})},function(){var U=F_(this),V=U.target,Z=U.index++;if(!V||Z>=V.length)return U.target=void 0,by(void 0,!0);switch(U.kind){case"keys":return by(Z,!1);case"values":return by(V[Z],!1)}return by([Z,V[Z]],!1)},"values"),Yu=AC.Arguments=AC.Array;
7119if(db("keys"),db("values"),db("entries"),hb&&Yu.name!=="values")try{U_(Yu,"name",{value:"values"})}catch{}var kC=ui,fb=Sc.map,wy=Po,Ni=wy("map");kC({target:"Array",proto:!0,forced:!Ni},{map:function(V){return fb(this,V,arguments.length>1?arguments[1]:void 0)}});var QM=yt,_y=QM([].slice),IC=ui,NC=Wd,ZM=Yc,Ri=Yt,Jr=ki,Zs=Fi,hr=Mt,si=ee,jl=Ls,rh=Po,sg=_y,z_=rh("slice"),ih=jl("species"),_i=Array,Ef=Math.max;IC({target:"Array",proto:!0,forced:!z_},{slice:function(V,Z){var ae=hr(this),_e=Zs(ae),qe=Jr(V,_e),Ke=Jr(Z===void 0?_e:Z,_e),ze,ut,at;if(NC(ae)&&(ze=ae.constructor,ZM(ze)&&(ze===_i||NC(ze.prototype))?ze=void 0:Ri(ze)&&(ze=ze[ih],ze===null&&(ze=void 0)),ze===_i||ze===void 0))return sg(ae,qe,Ke);for(ut=new(ze===void 0?_i:ze)(Ef(Ke-qe,0)),at=0;qe<Ke;qe++,at++)qe in ae&&si(ut,at,ae[qe]);return ut.length=at,ut}});var Op=ui,G_=Sc.some,Cc=kp,rg=Cc("some");Op({target:"Array",proto:!0,forced:!rg},{some:function(V){return G_(this,V,arguments.length>1?arguments[1]:void 0)}});var Lp=typeof ArrayBuffer<"u"&&typeof DataView<"u",tu=el,H_=ci,jp=function(U,V,Z){return Z.get&&tu(Z.get,V,{getter:!0}),Z.set&&tu(Z.set,V,{setter:!0}),H_.f(U,V,Z)},pb=vi,mb=function(U,V,Z){for(var ae in V)pb(U,ae,V[ae],Z);return U}
vendor: 5,713 bytes, line 7119
7119,Tf=ht,gb=TypeError,Af=function(U,V){if(Tf(V,U))return U;throw new gb("Incorrect invocation")},Sy=Ya,q_=Xi,W_=RangeError,ig=function(U){if(U===void 0)return 0;var V=Sy(U),Z=q_(V);if(V!==Z)throw new W_("Wrong length or index");return Z},K_=Math.sign||function(V){var Z=+V;return Z===0||Z!==Z?Z:Z<0?-1:1},Bl=K_,RC=Math.abs,yo=2220446049250313e-31,Y_=1/yo,X_=function(U){return U+Y_-Y_},MC=function(U,V,Z,ae){var _e=+U,qe=RC(_e),Ke=Bl(_e);if(qe<ae)return Ke*X_(qe/ae/V)*ae*V;var ze=(1+V/yo)*qe,ut=ze-(ze-qe);return ut>Z||ut!==ut?Ke*(1/0):Ke*ut},eP=MC,ah=11920928955078125e-23,yb=34028234663852886e22,J_=11754943508222875e-54,ag=Math.fround||function(V){return eP(V,ah,yb,J_)},PC=Array,$C=Math.abs,Xu=Math.pow,Q_=Math.floor,Z_=Math.log,tP=Math.LN2,nP=function(U,V,Z){var ae=PC(Z),_e=Z*8-V-1,qe=(1<<_e)-1,Ke=qe>>1,ze=V===23?Xu(2,-24)-Xu(2,-77):0,ut=U<0||U===0&&1/U<0?1:0,at=0,Ht,dn,zn;for(U=$C(U),U!==U||U===1/0?(dn=U!==U?1:0,Ht=qe):(Ht=Q_(Z_(U)/tP),zn=Xu(2,-Ht),U*zn<1&&(Ht--,zn*=2),Ht+Ke>=1?U+=ze/zn:U+=ze*Xu(2,1-Ke),U*zn>=2&&(Ht++,zn/=2),Ht+Ke>=qe?(dn=0,Ht=qe):Ht+Ke>=1?(dn=(U*zn-1)*Xu(2,V),Ht+=Ke):(dn=U*Xu(2,Ke-1)*Xu(2,V),Ht=0));V>=8;)ae[at++]=dn&255,dn/=256,V-=8;for(Ht=Ht<<V|dn,_e+=V;_e>0;)ae[at++]=Ht&255,Ht/=256,_e-=8;return ae[at-1]|=ut*128,ae},sP=function(U,V){var Z=U.length,ae=Z*8-V-1,_e=(1<<ae)-1,qe=_e>>1,Ke=ae-7,ze=Z-1,ut=U[ze--],at=ut&127,Ht;for(ut>>=7;Ke>0;)at=at*256+U[ze--],Ke-=8;for(Ht=at&(1<<-Ke)-1,at>>=-Ke,Ke+=V;Ke>0;)Ht=Ht*256+U[ze--],Ke-=8;if(at===0)at=1-qe;else{if(at===_e)return Ht?NaN:ut?-1/0:1/0;Ht+=Xu(2,V),at-=qe}return(ut?-1:1)*Ht*Xu(2,at-V)},DC={pack:nP,unpack:sP},OC=tt,Bp=ki,xb=Fi,vb=function(V){for(var Z=OC(this),ae=xb(Z),_e=arguments.length,qe=Bp(_e>1?arguments[1]:void 0,ae),Ke=_e>2?arguments[2]:void 0,ze=Ke===void 0?ae:Bp(Ke,ae);ze>qe;)Z[qe++]=V;return Z},LC=Oe,rP=Yt,e2=Ol,Up=function(U,V,Z){var ae,_e;return e2&&LC(ae=V.constructor)&&ae!==Z&&rP(_e=ae.prototype)&&_e!==Z.prototype&&e2(U,_e),U},Ey=R,zr=yt,Ty=H,iP=Lp,t2=pa,aP=Vt,oP=jp,jC=mb,og=G,oh=Af,n2=Ya,bb=Xi,lg=ig,Fp=ag,nu=DC,Ay=qu,BC=Ol,UC=vb,FC=_y,VC=Up,lP=Sp,wb=ob,_b=Aa,zC=t2.PROPER,GC=t2.CONFIGURABLE,Cf="ArrayBuffer",cg="DataView",ug="prototype",cP="Wrong length",dg="Wrong index",HC=_b.getterFor(Cf),hg=_b.getterFor(cg),tr=_b.set,Ul=Ey[Cf],xo=Ul,kf=xo&&xo[ug],su=Ey[cg],lh=su&&su[ug],fg=Object.prototype,Sb=Ey.Array,ch=Ey.RangeError,qC=zr(UC),uP=zr([].reverse),WC=nu.pack,s2=nu.unpack,r2=function(U){return[U&255]},Cy=function(U){return[U&255,U>>8&255]},Gr=function(U){return[U&255,U>>8&255,U>>16&255,U>>24&255]},Eb=function(U){return U[3]<<24|U[2]<<16|U[1]<<8|U[0]},Ja=function(U){return WC(Fp(U),23,4)},dP=function(U){return WC(U,52,8)},pg=function(U,V,Z){oP(U[ug],V,{configurable:!0,get:function(){return Z(this)[V]}})},Ju=function(U,V,Z,ae){var _e=hg(U),qe=lg(Z),Ke=!!ae;if(qe+V>_e.byteLength)throw new ch(dg);var ze=_e.bytes,ut=qe+_e.byteOffset,at=FC(ze,ut,ut+V);return Ke?at:uP(at)},ru=function(U,V,Z,ae,_e,qe){var Ke=hg(U),ze=lg(Z),ut=ae(+_e),at=!!qe;if(ze+V>Ke.byteLength)throw new ch(dg);for(var Ht=Ke.bytes,dn=ze+Ke.byteOffset,zn=0;zn<V;zn++)Ht[dn+zn]=ut[at?zn:V-zn-1]};if(!iP)xo=function(V){oh(this,kf);var Z=lg(V);tr(this,{type:Cf,bytes:qC(Sb(Z),0),byteLength:Z}),Ty||(this.byteLength=Z,this.detached=!1)},kf=xo[ug],su=function(V,Z,ae){oh(this,lh),oh(V,kf);var _e=HC(V),qe=_e.byteLength,Ke=n2(Z);if(Ke<0||Ke>qe)throw new ch("Wrong offset");if(ae=ae===void 0?qe-Ke:bb(ae),Ke+ae>qe)throw new ch(cP);tr(this,{type:cg,buffer:V,byteLength:ae,byteOffset:Ke,bytes:_e.bytes}),Ty||(this.buffer=V,this.byteLength=ae,this.byteOffset=Ke)},lh=su[ug],Ty&&(pg(xo,"byteLength",HC),pg(su,"buffer",hg),pg(su,"byteLength",hg),pg(su,"byteOffset",hg)),jC(lh,{getInt8:function(V){return Ju(this,1,V)[0]<<24>>24},getUint8:function(V){return Ju(this,1,V)[0]},getInt16:function(V){var Z=Ju(this,2,V,arguments.length>1?arguments[1]:!1);return(Z[1]<<8|Z[0])<<16>>16},getUint16:function(V){var Z=Ju(this,2,V,arguments.length>1?arguments[1]:!1);return Z[1]<<8|Z[0]},getInt32:function(V){return Eb(Ju(this,4,V,arguments.length>1?arguments[1]:!1))},getUint32:function(V){return Eb(Ju(this,4,V,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(V){return s2(Ju(this,4,V,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(V){return s2(Ju(this,8,V,arguments.length>1?arguments[1]:!1),52)},setInt8:function(V,Z){ru(this,1,V,r2,Z)},setUint8:function(V,Z){ru(this,1,V,r2,Z)},setInt16:function(V,Z){ru(this,2,V,Cy,Z,arguments.length>2?arguments[2]:!1)},setUint16:function(V,Z){ru(this,2,V,Cy,Z,arguments.length>2?arguments[2]:!1)},setInt32:function(V,Z){ru(this,4,V,Gr,Z,arguments.length>2?arguments[2]:!1)},setUint32:function(V,Z){ru(this,4,V,Gr,Z,arguments.length>2?arguments[2]:!1)},setFloat32:function(V,Z){ru(this,4,V,Ja,Z,arguments.length>2?arguments[2]:!1)},setFloat64:function(V,Z){ru(this,8,V,dP,Z,arguments.length>2?arguments[2]:!1)}});else{var i2=zC&&Ul.name!==Cf;!og(function(){Ul(1)})||!og(function(){new Ul(-1)})||og(function(){return new Ul,new Ul(1.5),new Ul(NaN),Ul.length!==1||i2&&!GC})?(xo=function(V){return oh(this,kf),VC(new Ul(lg(V)),this,xo)},xo[ug]=kf,kf.constructor=xo,lP(xo,Ul)):i2&&GC&&aP(Ul,"name",Cf),BC&&Ay(lh)!==fg&&BC(lh,fg);var ky=new su(new xo(2)),Tb=zr(lh.setInt8);ky.setInt8(0,2147483648),ky.setInt8(1,2147483649),(ky.getInt8(0)||!ky.getInt8(1))&&jC(lh,{setInt8:function(V,Z){Tb(this,V,Z<<24>>24)},setUint8:function(V,Z){Tb(this,V,Z<<24>>24)}},{unsafe:!0})}wb(xo,Cf),wb(su,cg);var mg={ArrayBuffer:xo,DataView:su},hP=Ue,KC=jp,fP=Ls,YC=H,XC=fP("species"),JC=function(U){var V=hP(U);YC&&V&&!V[XC]&&KC(V,XC,{configurable:!0,get:function(){return this}})},a2=ui,o2=R,pP=mg,mP=JC,Fl="ArrayBuffer",l2=pP[Fl],QC=o2[Fl];a2({global:!0,constructor:!0,forced:QC!==l2},{ArrayBuffer:l2}),mP(Fl);
vendor: 3,028 bytes, line 7119
7119var kc=Yc,ZC=gs,Ab=TypeError,Qu=function(U){if(kc(U))return U;throw new Ab(ZC(U)+" is not a constructor")},ek=Ha,gP=Qu,gg=he,tk=Ls,yP=tk("species"),nk=function(U,V){var Z=ek(U).constructor,ae;return Z===void 0||gg(ae=ek(Z)[yP])?V:gP(ae)},xP=ui,c2=ay,vP=G,sk=mg,rk=Ha,u2=ki,yg=Xi,Iy=nk,Cb=sk.ArrayBuffer,d2=sk.DataView,Vp=d2.prototype,xg=c2(Cb.prototype.slice),ik=c2(Vp.getUint8),kb=c2(Vp.setUint8),h2=vP(function(){return!new Cb(2).slice(1,void 0).byteLength});xP({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:h2},{slice:function(V,Z){if(xg&&Z===void 0)return xg(rk(this),V);for(var ae=rk(this).byteLength,_e=u2(V,ae),qe=u2(Z===void 0?ae:Z,ae),Ke=new(Iy(this,Cb))(yg(qe-_e)),ze=new d2(this),ut=new d2(Ke),at=0;_e<qe;)kb(ut,at++,ik(ze,_e++));return Ke}});var f2=ui,Ib=mg,ak=Lp;f2({global:!0,constructor:!0,forced:!ak},{DataView:Ib.DataView});var ok=Te,bP=Dn,lk=ok?{}.toString:function(){return"[object "+bP(this)+"]"},Ny=Te,wP=vi,_P=lk;Ny||wP(Object.prototype,"toString",_P,{unsafe:!0});var p2={exports:{}},Nb=Ls,Ry=Nb("iterator"),Rb=!1;try{var SP=0,vg={next:function(){return{done:!!SP++}},return:function(){Rb=!0}};vg[Ry]=function(){return this},Array.from(vg,function(){throw 2})}catch{}var EP=function(U,V){try{if(!V&&!Rb)return!1}catch{return!1}var Z=!1;try{var ae={};ae[Ry]=function(){return{next:function(){return{done:Z=!0}}}},U(ae)}catch{}return Z},ck=Lp,m2=H,rl=R,g2=Oe,bg=Yt,If=kt,wg=Dn,TP=gs,AP=Vt,y2=vi,x2=jp,Mb=ht,_g=qu,Sg=Ol,v2=Ls,Nf=Jn,uh=Aa,dh=uh.enforce,My=uh.get,Rf=rl.Int8Array,Zu=Rf&&Rf.prototype,uk=rl.Uint8ClampedArray,b2=uk&&uk.prototype,iu=Rf&&_g(Rf),au=Zu&&_g(Zu),dk=Object.prototype,Eg=rl.TypeError,w2=v2("toStringTag"),_2=Nf("TYPED_ARRAY_TAG"),zp="TypedArrayConstructor",ou=ck&&!!Sg&&wg(rl.opera)!=="Opera",S2=!1,Ma,ed,hh,Mf={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},E2={BigInt64Array:8,BigUint64Array:8},Pb=function(V){if(!bg(V))return!1;var Z=wg(V);return Z==="DataView"||If(Mf,Z)||If(E2,Z)},u=function(U){var V=_g(U);if(bg(V)){var Z=My(V);return Z&&If(Z,zp)?Z[zp]:u(V)}},f=function(U){if(!bg(U))return!1;var V=wg(U);return If(Mf,V)||If(E2,V)},g=function(U){if(f(U))return U;throw new Eg("Target is not a typed array")},w=function(U){if(g2(U)&&(!Sg||Mb(iu,U)))return U;throw new Eg(TP(U)+" is not a typed array constructor")},N=function(U,V,Z,ae){if(m2){if(Z)for(var _e in Mf){var qe=rl[_e];if(qe&&If(qe.prototype,U))try{delete qe.prototype[U]}catch{try{qe.prototype[U]=V}catch{}}}(!au[U]||Z)&&y2(au,U,Z?V:ou&&Zu[U]||V,ae)}};for(Ma in Mf)ed=rl[Ma],hh=ed&&ed.prototype,hh?dh(hh)[zp]=ed:ou=!1;for(Ma in E2)ed=rl[Ma],hh=ed&&ed.prototype,hh&&(dh(hh)[zp]=ed);if((!ou||!g2(iu)||iu===Function.prototype)&&(iu=function(){throw new Eg("Incorrect invocation")},ou))for(Ma in Mf)rl[Ma]&&Sg(rl[Ma],iu);if((!ou||!au||au===dk)&&(au=iu.prototype,ou))for(Ma in Mf)rl[Ma]&&Sg(rl[Ma].prototype,au);if(ou&&_g(b2)!==au&&Sg(b2,au),m2&&!If(au,w2)){S2=!0,x2(au,w2,{configurable:!0,get:function(){return bg(this)?this[_2]:void 0}});
vendor: 4,992 bytes, line 7119
7119for(Ma in Mf)rl[Ma]&&AP(rl[Ma],_2,Ma)}var O={NATIVE_ARRAY_BUFFER_VIEWS:ou,TYPED_ARRAY_TAG:S2&&_2,aTypedArray:g,aTypedArrayConstructor:w,exportTypedArrayMethod:N,getTypedArrayConstructor:u,isView:Pb,isTypedArray:f,TypedArray:iu,TypedArrayPrototype:au},se=R,fe=G,Ce=EP,Ge=O.NATIVE_ARRAY_BUFFER_VIEWS,At=se.ArrayBuffer,Pt=se.Int8Array,it=!Ge||!fe(function(){Pt(1)})||!fe(function(){new Pt(-1)})||!Ce(function(U){new Pt,new Pt(null),new Pt(1.5),new Pt(U)},!0)||fe(function(){return new Pt(new At(2),1,void 0).length!==1}),Et=Yt,jn=Math.floor,Cs=Number.isInteger||function(V){return!Et(V)&&isFinite(V)&&jn(V)===V},zi=Ya,Je=RangeError,Ve=function(U){var V=zi(U);if(V<0)throw new Je("The argument can't be less than 0");return V},st=Ve,Rt=RangeError,bn=function(U,V){var Z=st(U);if(Z%V)throw new Rt("Wrong offset");return Z},Ys=Math.round,Vn=function(U){var V=Ys(U);return V<0?0:V>255?255:V&255},as=Dn,ga=$s,Sr=he,Pf=py,CP=Ls,oae=CP("iterator"),Jj=function(U){if(!Sr(U))return ga(U,oae)||ga(U,"@@iterator")||Pf[as(U)]},lae=xe,cae=Ps,uae=Ha,dae=gs,hae=Jj,fae=TypeError,pae=function(U,V){var Z=arguments.length<2?hae(U):V;if(cae(Z))return uae(lae(Z,U));throw new fae(dae(U)+" is not iterable")},mae=Ls,gae=py,yae=mae("iterator"),xae=Array.prototype,vae=function(U){return U!==void 0&&(gae.Array===U||xae[yae]===U)},bae=Dn,wae=function(U){var V=bae(U);return V==="BigInt64Array"||V==="BigUint64Array"},_ae=ct,Sae=TypeError,Qj=function(U){var V=_ae(U,"number");if(typeof V=="number")throw new Sae("Can't convert number to bigint");return BigInt(V)},Eae=u_,Tae=xe,Aae=Qu,Cae=tt,kae=Fi,Iae=pae,Nae=Jj,Rae=vae,Mae=wae,Pae=O.aTypedArrayConstructor,$ae=Qj,Dae=function(V){var Z=Aae(this),ae=Cae(V),_e=arguments.length,qe=_e>1?arguments[1]:void 0,Ke=qe!==void 0,ze=Nae(ae),ut,at,Ht,dn,zn,Mi,Qr,fr;if(ze&&!Rae(ze))for(Qr=Iae(ae,ze),fr=Qr.next,ae=[];!(Mi=Tae(fr,Qr)).done;)ae.push(Mi.value);for(Ke&&_e>2&&(qe=Eae(qe,arguments[2])),at=kae(ae),Ht=new(Pae(Z))(at),dn=Mae(Ht),ut=0;at>ut;ut++)zn=Ke?qe(ae[ut],ut):ae[ut],Ht[ut]=dn?$ae(zn):+zn;return Ht},Oae=Fi,Zj=function(U,V,Z){for(var ae=0,_e=arguments.length>2?Z:Oae(V),qe=new U(_e);_e>ae;)qe[ae]=V[ae++];return qe},e6=ui,t6=R,n6=xe,Lae=H,jae=it,T2=O,s6=mg,r6=Af,Bae=de,A2=Vt,Uae=Cs,Fae=Xi,i6=ig,kP=bn,Vae=Vn,a6=Mr,C2=kt,zae=Dn,IP=Yt,Gae=rn,Hae=hy,qae=ht,hk=Ol,Wae=Od.f,o6=Dae,Kae=Sc.forEach,Yae=JC,Xae=jp,l6=ci,c6=B,u6=Zj,NP=Aa,Jae=Up,RP=NP.get,Qae=NP.set,Zae=NP.enforce,d6=l6.f,eoe=c6.f,MP=t6.RangeError,h6=s6.ArrayBuffer,toe=h6.prototype,noe=s6.DataView,fk=T2.NATIVE_ARRAY_BUFFER_VIEWS,f6=T2.TYPED_ARRAY_TAG,p6=T2.TypedArray,k2=T2.TypedArrayPrototype,PP=T2.isTypedArray,pk="BYTES_PER_ELEMENT",$P="Wrong length",mk=function(U,V){Xae(U,V,{configurable:!0,get:function(){return RP(this)[V]}})},m6=function(U){var V;return qae(toe,U)||(V=zae(U))==="ArrayBuffer"||V==="SharedArrayBuffer"},g6=function(U,V){return PP(U)&&!Gae(V)&&V in U&&Uae(+V)&&V>=0},y6=function(V,Z){return Z=a6(Z),g6(V,Z)?Bae(2,V[Z]):eoe(V,Z)},x6=function(V,Z,ae){return Z=a6(Z),g6(V,Z)&&IP(ae)&&C2(ae,"value")&&!C2(ae,"get")&&!C2(ae,"set")&&!ae.configurable&&(!C2(ae,"writable")||ae.writable)&&(!C2(ae,"enumerable")||ae.enumerable)?(V[Z]=ae.value,V):d6(V,Z,ae)};Lae?(fk||(c6.f=y6,l6.f=x6,mk(k2,"buffer"),mk(k2,"byteOffset"),mk(k2,"byteLength"),mk(k2,"length")),e6({target:"Object",stat:!0,forced:!fk},{getOwnPropertyDescriptor:y6,defineProperty:x6}),p2.exports=function(U,V,Z){var ae=U.match(/\d+/)[0]/8,_e=U+(Z?"Clamped":"")+"Array",qe="get"+U,Ke="set"+U,ze=t6[_e],ut=ze,at=ut&&ut.prototype,Ht={},dn=function(fr,xs){var Or=RP(fr);return Or.view[qe](xs*ae+Or.byteOffset,!0)},zn=function(fr,xs,Or){var ya=RP(fr);ya.view[Ke](xs*ae+ya.byteOffset,Z?Vae(Or):Or,!0)},Mi=function(fr,xs){d6(fr,xs,{get:function(){return dn(this,xs)},set:function(Or){return zn(this,xs,Or)},enumerable:!0})};fk?jae&&(ut=V(function(fr,xs,Or,ya){return r6(fr,at),Jae((function(){return IP(xs)?m6(xs)?ya!==void 0?new ze(xs,kP(Or,ae),ya):Or!==void 0?new ze(xs,kP(Or,ae)):new ze(xs):PP(xs)?u6(ut,xs):n6(o6,ut,xs):new ze(i6(xs))})(),fr,ut)}),hk&&hk(ut,p6),Kae(Wae(ze),function(fr){fr in ut||A2(ut,fr,ze[fr])}),ut.prototype=at):(ut=V(function(fr,xs,Or,ya){r6(fr,at);var Ag=0,Cg=0,Tk,kg,N2;if(!IP(xs))N2=i6(xs),kg=N2*ae,Tk=new h6(kg);else if(m6(xs)){Tk=xs,Cg=kP(Or,ae);var u4=xs.byteLength;if(ya===void 0){if(u4%ae)throw new MP($P);if(kg=u4-Cg,kg<0)throw new MP($P)}else if(kg=Fae(ya)*ae,kg+Cg>u4)throw new MP($P);N2=kg/ae}else return PP(xs)?u6(ut,xs):n6(o6,ut,xs);for(Qae(fr,{buffer:Tk,byteOffset:Cg,byteLength:kg,length:N2,view:new noe(Tk)});Ag<N2;)Mi(fr,Ag++)}),hk&&hk(ut,p6),at=ut.prototype=Hae(k2)),at.constructor!==ut&&A2(at,"constructor",ut),Zae(at).TypedArrayConstructor=ut,f6&&A2(at,f6,_e);var Qr=ut!==ze;Ht[_e]=ut,e6({global:!0,constructor:!0,forced:Qr,sham:!fk},Ht),pk in ut||A2(ut,pk,ae),pk in at||A2(at,pk,ae),Yae(_e)}):p2.exports=function(){};var soe=p2.exports,roe=soe;roe("Uint8",function(U){return function(Z,ae,_e){return U(this,Z,ae,_e)}});var v6=gs,ioe=TypeError,aoe=function(U,V){if(!delete U[V])throw new i
7119oe("Cannot delete property "+v6(V)+" of "+v6(U))},ooe=tt,DP=ki,loe=Fi,coe=aoe,uoe=Math.min,doe=[].copyWithin||function(V,Z){var ae=ooe(this),_e=loe(ae),qe=DP(V,_e),Ke=DP(Z,_e),ze=arguments.length>2?arguments[2]:void 0,ut=uoe((ze===void 0?_e:DP(ze,_e))-Ke,_e-qe),at=1;for(Ke<qe&&qe<Ke+ut&&(at=-1,Ke+=ut-1,qe+=ut-1);ut-- >0;)Ke in ae?ae[qe]=ae[Ke]:coe(ae,qe),qe+=at,Ke+=at;return ae},hoe=yt,b6=O,foe=doe,poe=hoe(foe),moe=b6.aTypedArray,goe=b6.exportTypedArrayMethod;goe("copyWithin",function(V,Z){return poe(moe(this),V,Z,arguments.length>2?arguments[2]:void 0)});var w6=O,yoe=Sc.every,xoe=w6.aTypedArray,voe=w6.exportTypedArrayMethod;voe("every",function(V){return yoe(xoe(this),V,arguments.length>1?arguments[1]:void 0)});var _6=O,boe=vb,woe=Qj,_oe=Dn,Soe=xe,Eoe=yt,Toe=G,Aoe=_6.aTypedArray,Coe=_6.exportTypedArrayMethod,koe=Eoe("".slice),Ioe=Toe(function(){var U=0;return new Int8Array(2).fill({valueOf:function(){return U++}}),U!==1});Coe("fill",function(V){var Z=arguments.length;Aoe(this);var ae=koe(_oe(this),0,3)==="Big"?woe(V):+V;return Soe(boe,this,ae,Z>1?arguments[1]:void 0,Z>2?arguments[2]:void 0)},Ioe);var S6=O,Noe=nk,Roe=S6.aTypedArrayConstructor,Moe=S6.getTypedArrayConstructor,gk=function(U){return Roe(Noe(U,Moe(U)))},Poe=Zj,$oe=gk,Doe=function(U,V){return Poe($oe(U),V)},E6=O,Ooe=Sc.filter,Loe=Doe,joe=E6.aTypedArray,Boe=E6.exportTypedArrayMethod;Boe("filter",function(V){var Z=Ooe(joe(this),V,arguments.length>1?arguments[1]:void 0);return Loe(this,Z)});var T6=O,Uoe=Sc.find,Foe=T6.aTypedArray,Voe=T6.exportTypedArrayMethod;Voe("find",function(V){return Uoe(Foe(this),V,arguments.length>1?arguments[1]:void 0)});var A6=O,zoe=Sc.findIndex,Goe=A6.aTypedArray,Hoe=A6.exportTypedArrayMethod;Hoe("findIndex",function(V){return zoe(Goe(this),V,arguments.length>1?arguments[1]:void 0)});var C6=O,qoe=Sc.forEach,Woe=C6.aTypedArray,Koe=C6.exportTypedArrayMethod;Koe("forEach",function(V){qoe(Woe(this),V,arguments.length>1?arguments[1]:void 0)});var k6=O,Yoe=Kr.includes,Xoe=k6.aTypedArray,Joe=k6.exportTypedArrayMethod;Joe("includes",function(V){return Yoe(Xoe(this),V,arguments.length>1?arguments[1]:void 0)});var I6=O,Qoe=Kr.indexOf,Zoe=I6.aTypedArray,ele=I6.exportTypedArrayMethod;ele("indexOf",function(V){return Qoe(Zoe(this),V,arguments.length>1?arguments[1]:void 0)});var tle=R,nle=G,OP=yt,N6=O,LP=V_,sle=Ls,jP=sle("iterator"),R6=tle.Uint8Array,rle=OP(LP.values),ile=OP(LP.keys),ale=OP(LP.entries),BP=N6.aTypedArray,yk=N6.exportTypedArrayMethod,$b=R6&&R6.prototype,xk=!nle(function(){$b[jP].call([1])}),M6=!!$b&&$b.values&&$b[jP]===$b.values&&$b.values.name==="values",P6=function(){return rle(BP(this))};yk("entries",function(){return ale(BP(this))},xk),yk("keys",function(){return ile(BP(this))},xk),yk("values",P6,xk||!M6,{name:"values"}),yk(jP,P6,xk||!M6,{name:"values"});var $6=O,ole=yt,lle=$6.aTypedArray,cle=$6.exportTypedArrayMethod,ule=ole([].join);cle("join",function(V){return ule(lle(this),V)});var dle=F,D6=Function.prototype,O6=D6.apply,L6=D6.call,UP=typeof Reflect=="object"&&Reflect.apply||(dle?L6.bind(O6):function(){return L6.apply(O6,arguments)}),hle=UP,fle=Mt,ple=Ya,mle=Fi,gle=kp,yle=Math.min,FP=[].lastIndexOf,j6=!!FP&&1/[1].lastIndexOf(1,-0)<0,xle=gle("lastIndexOf"),vle=j6||!xle,ble=vle?function(V){if(j6)return hle(FP,this,arguments)||0;var Z=fle(this),ae=mle(Z);if(ae===0)return-1;var _e=ae-1;for(arguments.length>1&&(_e=yle(_e,ple(arguments[1]))),_e<0&&(_e=ae+_e);_e>=0;_e--)if(_e in Z&&Z[_e]===V)return _e||0;return-1}:FP,B6=O,wle=UP,_le=ble,Sle=B6.aTypedArray,Ele=B6.exportTypedArrayMethod;Ele("lastIndexOf",function(V){var Z=arguments.length;return wle(_le,Sle(this),Z>1?[V,arguments[1]]:[V])});var U6=O,Tle=Sc.map,Ale=gk,Cle=U6.aTypedArray,kle=U6.exportTypedArrayMethod;kle("map",function(V){return Tle(Cle(this),V,arguments.length>1?arguments[1]:void 0,function(Z,ae){return new(Ale(Z))(ae)})});var Ile=Ps,Nle=tt,Rle=ge,Mle=Fi,F6=TypeError,V6="Reduce of empty array with no initial value",z6=function(U){return function(V,Z,ae,_e){var qe=Nle(V),Ke=Rle(qe),ze=Mle(qe);if(Ile(Z),ze===0&&ae<2)throw new F6(V6);var ut=U?ze-1:0,at=U?-1:1;if(ae<2)for(;;){if(ut in Ke){_e=Ke[ut],ut+=at;break}if(ut+=at,U?ut<0:ze<=ut)throw new F6(V6)}for(;U?ut>=0:ze>ut;ut+=at)ut in Ke&&(_e=Z(_e,Ke[ut],ut,qe));return _e}},G6={left:z6(!1),right:z6(!0)},H6=O,Ple=G6.left,$le=H6.aTypedArray,Dle=H6.exportTypedArrayMethod;
vendor: 4,353 bytes, line 7119
7119Dle("reduce",function(V){var Z=arguments.length;return Ple($le(this),V,Z,Z>1?arguments[1]:void 0)});var q6=O,Ole=G6.right,Lle=q6.aTypedArray,jle=q6.exportTypedArrayMethod;jle("reduceRight",function(V){var Z=arguments.length;return Ole(Lle(this),V,Z,Z>1?arguments[1]:void 0)});var W6=O,Ble=W6.aTypedArray,Ule=W6.exportTypedArrayMethod,Fle=Math.floor;Ule("reverse",function(){for(var V=this,Z=Ble(V).length,ae=Fle(Z/2),_e=0,qe;_e<ae;)qe=V[_e],V[_e++]=V[--Z],V[Z]=qe;return V});var K6=R,Y6=xe,VP=O,Vle=Fi,zle=bn,Gle=tt,X6=G,Hle=K6.RangeError,zP=K6.Int8Array,J6=zP&&zP.prototype,Q6=J6&&J6.set,qle=VP.aTypedArray,Wle=VP.exportTypedArrayMethod,GP=!X6(function(){var U=new Uint8ClampedArray(2);return Y6(Q6,U,{length:1,0:3},1),U[1]!==3}),Kle=GP&&VP.NATIVE_ARRAY_BUFFER_VIEWS&&X6(function(){var U=new zP(2);return U.set(1),U.set("2",1),U[0]!==0||U[1]!==2});Wle("set",function(V){qle(this);var Z=zle(arguments.length>1?arguments[1]:void 0,1),ae=Gle(V);if(GP)return Y6(Q6,this,ae,Z);var _e=this.length,qe=Vle(ae),Ke=0;if(qe+Z>_e)throw new Hle("Wrong length");for(;Ke<qe;)this[Z+Ke]=ae[Ke++]},!GP||Kle);var Z6=O,Yle=gk,Xle=G,Jle=_y,Qle=Z6.aTypedArray,Zle=Z6.exportTypedArrayMethod,ece=Xle(function(){new Int8Array(1).slice()});Zle("slice",function(V,Z){for(var ae=Jle(Qle(this),V,Z),_e=Yle(this),qe=0,Ke=ae.length,ze=new _e(Ke);Ke>qe;)ze[qe]=ae[qe++];return ze},ece);var eB=O,tce=Sc.some,nce=eB.aTypedArray,sce=eB.exportTypedArrayMethod;sce("some",function(V){return tce(nce(this),V,arguments.length>1?arguments[1]:void 0)});var tB=_y,rce=Math.floor,HP=function(U,V){var Z=U.length;if(Z<8)for(var ae=1,_e,qe;ae<Z;){for(qe=ae,_e=U[ae];qe&&V(U[qe-1],_e)>0;)U[qe]=U[--qe];qe!==ae++&&(U[qe]=_e)}else for(var Ke=rce(Z/2),ze=HP(tB(U,0,Ke),V),ut=HP(tB(U,Ke),V),at=ze.length,Ht=ut.length,dn=0,zn=0;dn<at||zn<Ht;)U[dn+zn]=dn<at&&zn<Ht?V(ze[dn],ut[zn])<=0?ze[dn++]:ut[zn++]:dn<at?ze[dn++]:ut[zn++];return U},ice=HP,ace=Wt,nB=ace.match(/firefox\/(\d+)/i),oce=!!nB&&+nB[1],lce=Wt,cce=/MSIE|Trident/.test(lce),uce=Wt,sB=uce.match(/AppleWebKit\/(\d+)\./),dce=!!sB&&+sB[1],hce=R,fce=ay,qP=G,pce=Ps,mce=ice,rB=O,iB=oce,gce=cce,aB=ur,oB=dce,yce=rB.aTypedArray,xce=rB.exportTypedArrayMethod,I2=hce.Uint16Array,Db=I2&&fce(I2.prototype.sort),vce=!!Db&&!(qP(function(){Db(new I2(2),null)})&&qP(function(){Db(new I2(2),{})})),lB=!!Db&&!qP(function(){if(aB)return aB<74;if(iB)return iB<67;if(gce)return!0;if(oB)return oB<602;var U=new I2(516),V=Array(516),Z,ae;for(Z=0;Z<516;Z++)ae=Z%4,U[Z]=515-Z,V[Z]=Z-2*ae+3;for(Db(U,function(_e,qe){return(_e/4|0)-(qe/4|0)}),Z=0;Z<516;Z++)if(U[Z]!==V[Z])return!0}),bce=function(U){return function(V,Z){return U!==void 0?+U(V,Z)||0:Z!==Z?-1:V!==V?1:V===0&&Z===0?1/V>0&&1/Z<0?1:-1:V>Z}};xce("sort",function(V){return V!==void 0&&pce(V),lB?Db(this,V):mce(yce(this),bce(V))},!lB||vce);var cB=O,wce=Xi,uB=ki,_ce=gk,Sce=cB.aTypedArray,Ece=cB.exportTypedArrayMethod;Ece("subarray",function(V,Z){var ae=Sce(this),_e=ae.length,qe=uB(V,_e),Ke=_ce(ae);return new Ke(ae.buffer,ae.byteOffset+qe*ae.BYTES_PER_ELEMENT,wce((Z===void 0?_e:uB(Z,_e))-qe))});var Tce=R,Ace=UP,dB=O,WP=G,hB=_y,vk=Tce.Int8Array,fB=dB.aTypedArray,Cce=dB.exportTypedArrayMethod,pB=[].toLocaleString,kce=!!vk&&WP(function(){pB.call(new vk(1))}),Ice=WP(function(){return[1,2].toLocaleString()!==new vk([1,2]).toLocaleString()})||!WP(function(){vk.prototype.toLocaleString.call([1,2])});Cce("toLocaleString",function(){return Ace(pB,kce?hB(fB(this)):fB(this),hB(arguments))},Ice);var Nce=O.exportTypedArrayMethod,Rce=G,Mce=R,Pce=yt,mB=Mce.Uint8Array,$ce=mB&&mB.prototype||{},bk=[].toString,Dce=Pce([].join);Rce(function(){bk.call({})})&&(bk=function(){return Dce(this)});var Oce=$ce.toString!==bk;Nce("toString",bk,Oce);var Lce={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},jce=As,KP=jce("span").classList,gB=KP&&KP.constructor&&KP.constructor.prototype,Bce=gB===Object.prototype?void 0:gB,yB=R,xB=Lce,Uce=Bce,YP=f_,Fce=Vt,vB=function(U){
vendor: 4,736 bytes, lines 7119-7121
7119if(U&&U.forEach!==YP)try{Fce(U,"forEach",YP)}catch{U.forEach=YP}};for(var XP in xB)xB[XP]&&vB(yB[XP]&&yB[XP].prototype);vB(Uce);var Vce=ui,zce=yt,Gce=ge,Hce=Mt,qce=kp,Wce=zce([].join),Kce=Gce!==Object,Yce=Kce||!qce("join",",");Vce({target:"Array",proto:!0,forced:Yce},{join:function(V){return Wce(Hce(this),V===void 0?",":V)}});var Xce=Dn,Jce=String,JP=function(U){if(Xce(U)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return Jce(U)},Qce=Ha,Zce=function(){var U=Qce(this),V="";return U.hasIndices&&(V+="d"),U.global&&(V+="g"),U.ignoreCase&&(V+="i"),U.multiline&&(V+="m"),U.dotAll&&(V+="s"),U.unicode&&(V+="u"),U.unicodeSets&&(V+="v"),U.sticky&&(V+="y"),V},QP=G,eue=R,ZP=eue.RegExp,bB=QP(function(){var U=ZP("a","y");return U.lastIndex=2,U.exec("abcd")!==null});bB||QP(function(){return!ZP("a","y").sticky});var tue=bB||QP(function(){var U=ZP("^r","gy");return U.lastIndex=2,U.exec("str")!==null}),nue={BROKEN_CARET:tue},sue=G,rue=R,iue=rue.RegExp,aue=sue(function(){var U=iue(".","s");return!(U.dotAll&&U.test(`
7120`)&&U.flags==="s")}),oue=G,lue=R,cue=lue.RegExp,uue=oue(function(){var U=cue("(?<a>b)","g");return U.exec("b").groups.a!=="b"||"b".replace(U,"$<a>c")!=="bc"}),Ob=xe,wk=yt,due=JP,hue=Zce,fue=nue,pue=Pe,mue=hy,gue=Aa.get,yue=aue,xue=uue,vue=pue("native-string-replace",String.prototype.replace),_k=RegExp.prototype.exec,e4=_k,bue=wk("".charAt),wue=wk("".indexOf),_ue=wk("".replace),t4=wk("".slice),n4=(function(){var U=/a/,V=/b*/g;return Ob(_k,U,"a"),Ob(_k,V,"a"),U.lastIndex!==0||V.lastIndex!==0})(),wB=fue.BROKEN_CARET,s4=/()??/.exec("")[1]!==void 0,Sue=n4||s4||wB||yue||xue;Sue&&(e4=function(V){var Z=this,ae=gue(Z),_e=due(V),qe=ae.raw,Ke,ze,ut,at,Ht,dn,zn;if(qe)return qe.lastIndex=Z.lastIndex,Ke=Ob(e4,qe,_e),Z.lastIndex=qe.lastIndex,Ke;var Mi=ae.groups,Qr=wB&&Z.sticky,fr=Ob(hue,Z),xs=Z.source,Or=0,ya=_e;if(Qr&&(fr=_ue(fr,"y",""),wue(fr,"g")===-1&&(fr+="g"),ya=t4(_e,Z.lastIndex),Z.lastIndex>0&&(!Z.multiline||Z.multiline&&bue(_e,Z.lastIndex-1)!==`
7121`)&&(xs="(?: "+xs+")",ya=" "+ya,Or++),ze=new RegExp("^(?:"+xs+")",fr)),s4&&(ze=new RegExp("^"+xs+"$(?!\\s)",fr)),n4&&(ut=Z.lastIndex),at=Ob(_k,Qr?ze:Z,ya),Qr?at?(at.input=t4(at.input,Or),at[0]=t4(at[0],Or),at.index=Z.lastIndex,Z.lastIndex+=at[0].length):Z.lastIndex=0:n4&&at&&(Z.lastIndex=Z.global?at.index+at[0].length:ut),s4&&at&&at.length>1&&Ob(vue,at[0],ze,function(){for(Ht=1;Ht<arguments.length-2;Ht++)arguments[Ht]===void 0&&(at[Ht]=void 0)}),at&&Mi)for(at.groups=dn=mue(null),Ht=0;Ht<Mi.length;Ht++)zn=Mi[Ht],dn[zn[0]]=at[zn[1]];return at});var r4=e4,Eue=ui,_B=r4;Eue({target:"RegExp",proto:!0,forced:/./.exec!==_B},{exec:_B});var SB=xe,EB=vi,Tue=r4,TB=G,AB=Ls,Aue=Vt,Cue=AB("species"),i4=RegExp.prototype,kue=function(U,V,Z,ae){var _e=AB(U),qe=!TB(function(){var at={};return at[_e]=function(){return 7},""[U](at)!==7}),Ke=qe&&!TB(function(){var at=!1,Ht=/a/;return U==="split"&&(Ht={},Ht.constructor={},Ht.constructor[Cue]=function(){return Ht},Ht.flags="",Ht[_e]=/./[_e]),Ht.exec=function(){return at=!0,null},Ht[_e](""),!at});if(!qe||!Ke||Z){var ze=/./[_e],ut=V(_e,""[U],function(at,Ht,dn,zn,Mi){var Qr=Ht.exec;return Qr===Tue||Qr===i4.exec?qe&&!Mi?{done:!0,value:SB(ze,Ht,dn,zn)}:{done:!0,value:SB(at,dn,Ht,zn)}:{done:!1}});EB(String.prototype,U,ut[0]),EB(i4,_e,ut[1])}ae&&Aue(i4[_e],"sham",!0)},a4=yt,Iue=Ya,Nue=JP,Rue=nt,Mue=a4("".charAt),CB=a4("".charCodeAt),Pue=a4("".slice),$ue=function(U){return function(V,Z){var ae=Nue(Rue(V)),_e=Iue(Z),qe=ae.length,Ke,ze;return _e<0||_e>=qe?U?"":void 0:(Ke=CB(ae,_e),Ke<55296||Ke>56319||_e+1===qe||(ze=CB(ae,_e+1))<56320||ze>57343?U?Mue(ae,_e):Ke:U?Pue(ae,_e,_e+2):(Ke-55296<<10)+(ze-56320)+65536)}},Due={charAt:$ue(!0)},Oue=Due.charAt,Lue=function(U,V,Z){return V+(Z?Oue(U,V).length:1)},kB=xe,jue=Ha,Bue=Oe,Uue=zt,Fue=r4,Vue=TypeError,zue=function(U,V){var Z=U.exec;if(Bue(Z)){var ae=kB(Z,U,V);return ae!==null&&jue(ae),ae}if(Uue(U)==="RegExp")return kB(Fue,U,V);throw new Vue("RegExp#exec called on incompatible receiver")},Gue=xe,Hue=kue,que=Ha,Wue=he,Kue=Xi,o4=JP,Yue=nt,Xue=$s,Jue=Lue,IB=zue;Hue("match",function(U,V,Z){return[function(_e){var qe=Yue(this),Ke=Wue(_e)?void 0:Xue(_e,U);return Ke?Gue(Ke,_e,qe):new RegExp(_e)[U](o4(qe))},function(ae){var _e=que(this),qe=o4(ae),Ke=Z(V,_e,qe);if(Ke.done)return Ke.value;if(!_e.global)return IB(_e,qe);var ze=_e.unicode;_e.lastIndex=0;for(var ut=[],at=0,Ht;(Ht=IB(_e,qe))!==null;){var dn=o4(Ht[0]);ut[at]=dn,dn===""&&(_e.lastIndex=Jue(qe,Kue(_e.lastIndex),ze)),at++}return at===0?null:ut}]});var Que=ui,NB=O,Zue=NB.NATIVE_ARRAY_BUFFER_VIEWS;Que({target:"ArrayBuffer",stat:!0,forced:!Zue},{isView:NB.isView});function ede(U){var V="",Z=0,ae=0,_e=0,qe=0;for(Z+=U[0]===239&&U[1]===187&&U[2]===191?3:0;Z<U.length;)switch(ae=U[Z++],ae>>
71214){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 10:V+=String.fromCharCode(ae);break;case 12:case 13:_e=U[Z++],V+=String.fromCharCode((ae&31)<<6|_e&63);break;case 14:_e=U[Z++],qe=U[Z++],V+=String.fromCharCode((ae&15)<<12|(_e&63)<<6|(qe&63)<<0);break;default:V+=""}return V}function tde(U){for(var V=[],Z=0;Z<U.length;Z++){var ae=U.charCodeAt(Z);ae<128?V.push(ae):ae<2048?V.push(192|ae>>6,128|ae&63):ae<55296||ae>=57344?V.push(224|ae>>12,128|ae>>6&63,128|ae&63):(Z++,ae=65536+((ae&1023)<<10|U.charCodeAt(Z)&1023),V.push(240|ae>>18,128|ae>>12&63,128|ae>>6&63,128|ae&63))}return V}function Sk(U){for(var V=[],Z=0;Z<U.length;Z++)V.push(U.charCodeAt(Z));return V}function l4(U){return U instanceof ArrayBuffer||typeof Buffer<"u"&&U instanceof Buffer}var Gp=(function(U){function V(){r(this,V);for(var Z=arguments.length,ae=new Array(Z),_e=0;_e<Z;_e++)ae[_e]=arguments[_e];if((typeof ae[0]=="number"||Array.isArray(ae[0]))&&(ae[0]=new Uint8Array(ae[0])),typeof Buffer<"u"&&ae[0]instanceof Buffer){for(var qe=new ArrayBuffer(ae[0].byteLength),Ke=new Uint8Array(qe),ze=0;ze<ae[0].byteLength;ze++)Ke[ze]=ae[0][ze];ae[0]=qe}return ArrayBuffer.isView(ae[0])&&(ae[0]=ae[0].buffer),s(this,V,[].concat(ae))}return c(V,U),o(V,[{key:"getString",value:function(ae,_e){var qe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"ascii",Ke=this.getUint8(ae,_e,!0),ze="";switch(qe){case"utf8":case"utf-8":ze=ede(Ke);break;case"ascii":default:ze=String.fromCharCode.apply(String,S(Ke))}return ze}},{key:"getUint8",value:function(ae){var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,qe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,Ke=ae+_e,ze=[];if(this.byteLength-Ke<0)return!1;for(var ut=ae;ut<Ke;ut++){var at=DataView.prototype.getUint8.call(this,ut);ze.push(at)}return ze.length===1&&!qe?ze[0]:ze}},{key:"getInt16",value:function(ae){for(var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,qe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;_e%2!==0;)_e-=1;var Ke=ae+_e,ze=[];if(this.byteLength-Ke<0)return!1;for(var ut=ae;ut<Ke;ut+=2){var at=DataView.prototype.getInt16.call(this,ut,qe);ze.push(at)}return ze.length===1?ze[0]:ze}},{key:"getInt32",value:function(ae){for(var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4,qe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;_e%4!==0;)_e-=1;var Ke=ae+_e,ze=[];if(this.byteLength-Ke<0)return!1;for(var ut=ae;ut<Ke;ut+=4){var at=DataView.prototype.getInt32.call(this,ut,qe);ze.push(at)}return ze.length===1?ze[0]:ze}},{key:"getUint32",value:function(ae){for(var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4,qe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;_e%4!==0;)_e-=1;var Ke=ae+_e,ze=[];if(this.byteLength-Ke<0)return!1;for(var ut=ae;ut<Ke;ut+=4){var at=DataView.prototype.getUint32.call(this,ut,qe);ze.push(at)}return ze.length===1?ze[0]:ze}},{key:"getUint64",value:function(ae){for(var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,qe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;_e%8!==0;)_e-=1;var Ke=ae+_e,ze=[];if(this.byteLength-Ke<0)return!1;for(var ut=ae;ut<Ke;ut+=8){var at=DataView.prototype.getBigUint64.call(this,ut,qe);ze.push(at)}return ze.length===1?ze[0]:ze}}],[{key:"isViewable",value:function(ae){return!!(l4(ae)||Array.isArray(ae)||ArrayBuffer.isView(ae))}}])})(L(DataView));function nde(U){var V=new Gp(U),Z=V.getString(8,V.byteLength-8),ae=typeof Z=="string"&&Z.length%4===0?Z.match(/.{4}/g):[];return{brand:V.getString(0,4),minor:V.getUint32(4),compatibleBrands:ae}}function sde(U){var V=U.brand,Z=U.minor,ae=U.compatibleBrands;if(typeof V!="string"||V.length!==4)throw new Error("`ftyp` brand is invali
7121d");if(typeof Z!="number"||Z<0||Z>4294967295)throw new Error("`ftyp` minor is invalid");if(!Array.isArray(ae)||ae.some(function(_e){return _e.length!==4}))throw new Error("`ftyp` compatibleBrands is invalid")}function rde(U){var V=U.brand,Z=U.minor,ae=U.compatibleBrands,_e=[],qe=Sk(V);_e.push.apply(_e,S(qe));var Ke=new Gp(4);Ke.setUint32(0,Z),_e.push.apply(_e,S(Ke.getUint8(0,4)));var ze=Sk(ae.join(""));return _e.push.apply(_e,S(ze)),_e}function ide(U){var V=new Gp(U),Z=V.getUint16(0),ae,_e,qe,Ke,ze=0;return Z===0?(ae=V.getUint32(4),_e=V.getUint32(8),qe=V.getUint32(12),Ke=V.getUint32(16),ze=20):Z===1&&(ae=V.getUint64(4),_e=V.getUint64(12),qe=V.getUint32(20),Ke=V.getUint64(24),ze=32),{creationTime:ae,modificationTime:_e,timescale:qe,duration:Ke,rate:V.getInt32(ze),volume:V.getInt16(ze+4),matrix:V.getInt32(ze+16,36),preDefined:V.getUint32(ze+52,24),nextTrackID:V.getUint32(ze+76)}}function ade(U){var V=U.creationTime,Z=U.modificationTime,ae=U.timescale,_e=U.duration,qe=U.rate,Ke=U.volume,ze=U.matrix,ut=U.preDefined,at=U.nextTrackID;if(typeof V!="number"||typeof Z!="number"||typeof ae!="number"||typeof _e!="number"||typeof qe!="number"||typeof Ke!="number"||typeof at!="number")throw new Error("`mvhd` Invalid value");if(!Array.isArray(ze)||ze.length!==9||ze.some(function(Ht){return Ht<0||Ht>4294967295}))throw new Error("`mvhd` matrix is invalid");if(!Array.isArray(ut)||ut.length!==6||ut.some(function(Ht){return Ht<0||Ht>4294967295}))throw new Error("`mvhd` preDefined is invalid")}function ode(U){var V=U.creationTime,Z=U.modificationTime,ae=U.timescale,_e=U.duration,qe=U.rate,Ke=U.volume,ze=U.matrix,ut=U.preDefined,at=U.nextTrackID,Ht=V>4294967295||Z>4294967295||_e>4294967295?1:0,dn=new Gp((Ht===1?32:20)+80);dn.setUint16(0,Ht),dn.setUint16(2,0);var zn=0;Ht===0?(dn.setUint32(4,V),dn.setUint32(8,Z),dn.setUint32(12,ae),dn.setUint32(16,_e),zn=20):(dn.setBigUint64(4,V),dn.setBigUint64(12,Z),dn.setUint32(20,ae),dn.setBigUint64(24,_e),zn=32),dn.setInt32(zn,qe),dn.setInt16(zn+4,Ke);for(var Mi=0;Mi<10;Mi++)dn.setUint8(zn+6+Mi,0);for(var Qr=0;Qr<9;Qr++){var fr=ze[Qr];dn.setInt32(zn+16+Qr*4,fr)}for(var xs=0;xs<6;xs++){var Or=ut[xs];dn.setUint32(zn+52+xs*4,Or)}return dn.setUint32(zn+76,at),dn.getUint8(0,dn.byteLength,!0)}var lde=ui,cde=vb,ude=tb;lde({target:"Array",proto:!0},{fill:cde}),ude("fill");var dde=H,hde=pa.EXISTS,RB=yt,fde=jp,MB=Function.prototype,pde=RB(MB.toString),PB=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,mde=RB(PB.exec),gde="name";dde&&!hde&&fde(MB,gde,{configurable:!0,get:function(){try{return mde(PB,pde(this))[1]}catch{return""}}});function yde(U){var V=new Gp(U);return{handlerType:V.getUint8(8,4),name:V.getString(24,V.byteLength-25,"utf8")}}function xde(U){var V=U.handlerType,Z=U.name;if(!Array.isArray(V)||V.length!==4||V.some(function(ae){return ae<0||ae>255}))throw new Error("`handlerType` is invalid");if(typeof Z!="string")throw new Error("`name` value is not a string")}function vde(U){var V=U.handlerType,Z=U.name,ae=new Array(8).fill(0);ae.push.apply(ae,S(V)),ae.push.apply(ae,S(new Array(12).fill(0)));var _e=tde(Z);return ae.push.apply(ae,S(_e).concat([0])),ae}function bde(U){var V=new Gp(U);return V.getString(8,V.byteLength-8,"utf8")}function wde(U){if(typeof U!="string")throw new Error("`data` value is not a string")}function _de(U){var V=[],Z=Sk(U),ae=new Gp(8);return ae.setUint32(0,1),ae.setUint32(4,0),V.push.apply(V,S(ae.getUint8(0,8)).concat(S(Z))),V}function Sde(U,V){var Z=U;for(var ae in V)U[ae]!==void 0&&U[ae]!==""&&(Z[ae]=U[ae]),V[ae]!==void 0&&V[ae]!==""&&(Z[ae]=V[ae]);return Z}function $B(U,V){var Z={};for(var ae in V){var _e=V[ae],qe=U[ae];if(typeof qe>"u"){Z[ae]=_e;continue}switch(M(_e)){case"object":Z[ae]=$B(qe,_e);break;default:Z[ae]=M(_e)===M(qe)?qe:_e}}return Z}var Tg={"©nam":"title","©day":"date","©cpy":"copyright","©ART":"artist",aART:"album_artist","©wrt":"composer",desc:"description","©cmt":"comment",ldes:"synopsis","©gen":"genre","©grp":"grouping","©key":"keywords",tvsh:"show",tven:"episode_id",tves:"episode_sort",tvsn:"season_number","©lyr":"lyrics",cpil:"compilation",tvnn:"network",stik:"media_type",hdvd:"hd_video",pgap:"gapless_playback","©too":"encoding_tool"},Ek=["meta","moov","udta","ilst"];function c4(U){for(var V=new Gp(U),Z=[],ae={},_e=0;_e<V.byteLength;
7121){var qe=V.getUint32(_e),Ke=V.getString(_e+4,4),ze=null;if(qe===1){var ut=V.getUint64(_e+8);ze=V.getUint8(_e+16,ut,!0),_e+=ut}else qe===0?(ze=V.getUint8(_e+8,V.byteLength-_e-8,!0),_e=V.byteLength):(ze=V.getUint8(_e+8,qe-8,!0),_e+=qe);var at=null;if(Ke==="ftyp"&&(at=nde(ze)),Ke==="mvhd"&&(at=ide(ze)),Ke==="data"&&(at=bde(ze)),Ke==="hdlr"&&(at=yde(ze)),Ek.includes(Ke)){var Ht=c4(Ke==="meta"?ze.slice(4):ze);at=Ht.boxes,ae=Sde(ae,Ht.metadata)}if(typeof Tg[Ke]<"u"){var dn=Tg[Ke],zn=c4(ze);at=zn.boxes,ae[dn]=zn.boxes[0].value}Z.push({type:Ke,raw:at===null?ze:null,value:at})}return{boxes:Z,metadata:ae}}function Ede(U,V,Z){for(var ae in U)if(typeof U[ae]!="string")throw new Error("Metadata value should be a string");var _e=function(Ke){var ze=Ke.type,ut=Ke.raw,at=Ke.value;if(at===null&&ut===null)throw new Error('Invalid value "'.concat(ze,'"'));if(typeof ze!="string"||ze.length!==4)throw new Error('Invalid header type "'.concat(ze,'"'));if(ut!==null&&(!Array.isArray(ut)||ut.some(function(Ht){return Ht>255||Ht<0})))throw new Error("Invalid byte in box raw ".concat(ze));ze==="ftyp"&&sde(at),ze==="mvhd"&&ade(at),ze==="data"&&wde(at),ze==="hdlr"&&xde(at),(Ek.includes(ze)||typeof Tg[ze]<"u")&&at.forEach(_e)};V.forEach(_e)}function Tde(U,V,Z){return V=DB(V),V=Ade(U,V),OB(V)}function DB(U){for(var V=[],Z=0;Z<U.length;Z++){var ae=U[Z];typeof Tg[ae.type]<"u"||(Ek.includes(ae.type)&&(ae.value=DB(ae.value)),V.push(ae))}return V}function Ade(U,V){var Z=V.map(function(at){return at.type}).indexOf("moov");Z<0&&(V.push({type:"moov",raw:null,value:[]}),Z=V.length-1);var ae=V[Z].value.map(function(at){return at.type}).indexOf("udta");ae<0&&(V[Z].value.push({type:"udta",raw:null,value:[]}),ae=V[Z].value.length-1);var _e=V[Z].value[ae].value.map(function(at){return at.type}).indexOf("meta");_e<0&&(V[Z].value[ae].value.push({type:"meta",raw:null,value:[]}),_e=V[Z].value[ae].value.length-1);var qe=V[Z].value[ae].value[_e].value.map(function(at){return at.type}).indexOf("hdlr");qe<0&&V[Z].value[ae].value[_e].value.unshift({type:"hdlr",raw:null,value:{handlerType:[109,100,105,114],name:""}});var Ke=V[Z].value[ae].value[_e].value.map(function(at){return at.type}).indexOf("ilst");Ke<0&&(V[Z].value[ae].value[_e].value.push({type:"ilst",raw:null,value:[]}),Ke=V[Z].value[ae].value[_e].value.length-1);for(var ze in U)if(Object.hasOwn(U,ze))for(var ut in Tg)Object.hasOwn(Tg,ut)&&ze===Tg[ut]&&V[Z].value[ae].value[_e].value[Ke].value.push({type:ut,raw:null,value:[{type:"data",raw:null,value:U[ze]}]});return V}function OB(U,V){for(var Z=[],ae=function(){var Ke=U[_e],ze=Ke.type,ut=Ke.raw,at=Ke.value,Ht=new Gp(4),dn=null;if(at===null&&(dn=ut),ze==="ftyp"&&(dn=rde(at)),ze==="mvhd"&&(dn=ode(at)),ze==="data"&&(dn=_de(at)),ze==="hdlr"&&(dn=vde(at)),Ek.includes(ze)||typeof Tg[ze]<"u"){if(at.length===0)return 1;dn=ze==="meta"?[0,0,0,0]:[],OB(at).forEach(function(Mi){return dn.push(Mi)})}if(dn===null)throw new Error('Unable to encode "'.concat(ze,'"'));Ht.setUint32(0,dn.length+8);var zn=Sk(ze);Z.push.apply(Z,S(Ht.getUint8(0,4)).concat(S(zn))),dn.forEach(function(Mi){return Z.push(Mi)})},_e=0;_e<U.length;_e++)ae();return new Uint8Array(Z)}var Cde=(function(){function U(V){var Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(r(this,U),!l4(V))throw new TypeError("buffer is not ArrayBuffer/Buffer");this.verbose=Z,this.buffer=V,this.metadata={},this.boxes=[],this.error=""}return o(U,[{key:"name",get:function(){return"MP4Tag"},set:function(Z){throw new Error("Unable to set this property")}},{key:"version",get:function(){return"0.1.0-beta"},set:function(Z){throw new Error("Unable to set this property")}},{key:"read",value:function(){var Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.metadata={},this.boxes=[],this.error="";try{var ae=U.decodeMetadata(this.buffer,Z,this.verbose);this.metadata=ae.metadata,this.boxes=ae.boxes}catch(_e){this.error=_e.message}return this.metadata}},{key:"save",value:function(){var Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.error="";try{this.buffer=U.encodeMetadata(this.metadata,this.boxes,Z,this.verbose)}catch(ae){this.error=ae.message}return this.buffer}}],[{key:"decodeMetadata",value:function(Z){var ae=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(!l4(Z))throw new TypeError("buffer is not ArrayBuffer/Buffer");ae&&console.log("Reading MP4 boxes...");var _e=c4(Z);return ae&&console.log("Finished reading MP4..."),_e}},{key:"encodeMetadata",value:function(Z,ae){var _e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},qe=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;_e=$B(_e,{strict:!1}),qe&&console.log("Validating metadata..."),Ede(Z,ae,_e.strict),qe&&console.log("Writing metadata...");var Ke=Tde(Z,ae);return typeof Buffer<"u"?Buffer.from(Ke):Ke.buffer}}])})();return Cde}));const kOe=MP4Tag,Uj=(t,e)=>{const n=e.map(r=>`<rdf:li>${r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</rdf:li>`).join("");return`<?xpacket begin="\uFEFF" id="W5M0MpCehiHzreSzNTczkc9d"?>
7122<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21        ">
7123 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
7124  <rdf:Description rdf:about=""
7125    xmlns:dc="http://purl.org/dc/elements/1.1/">
7126   <dc:title>
7127    <rdf:Alt>
7128     <rdf:li xml:lang="x-default">${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</rdf:li>
7129    </rdf:Alt>
7130   </dc:title>
7131   <dc:subject>
7132    <rdf:Bag>
7133     ${n}
7134    </rdf:Bag>
7135   </dc:subject>
7136  </rdf:Description>
7137 </rdf:RDF>
7138</x:xmpmeta>
7139<?xpacket end="w"?>`},Fj=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),IOe=t=>`<dc:title>
7140    <rdf:Alt>
7141     <rdf:li xml:lang="x-default">${Fj(t.replace(/(\r\n|\n|\r)/g," ").trim())}</rdf:li>
7142    </rdf:Alt>
7143   </dc:title>`,NOe=t=>`<dc:subject>
7144    <rdf:Bag>
7145     ${t.map(n=>`<rdf:li>${Fj(n.replace(/(\r\n|\n|\r)/g," ").trim())}</rdf:li>`).join(`
7146     `)}
7147    </rdf:Bag>
7148   </dc:subject>`,ROe=(t,e,n)=>{let s=t;const r=IOe(e),i=NOe(n);/<dc:title[\s\S]*?<\/dc:title>/i.test(s)?s=s.replace(/<dc:title[\s\S]*?<\/dc:title>/i,r):/<rdf:Description\b/i.test(s)&&(s=s.replace(/(<rdf:Description\b[^>]*>)/i,`$1
7149   ${r}`)),/<dc:subject[\s\S]*?<\/dc:subject>/i.test(s)?s=s.replace(/<dc:subject[\s\S]*?<\/dc:subject>/i,i):/<dc:title[\s\S]*?<\/dc:title>/i.test(s)?s=s.replace(/(<dc:title[\s\S]*?<\/dc:title>)/i,`$1
7150   ${i}`):/<rdf:Description\b/i.test(s)&&(s=s.replace(/(<rdf:Description\b[^>]*>)/i,`$1
7151   ${i}`));const a=Fj(e.replace(/(\r\n|\n|\r)/g," ").trim());return/<xmp:Title>[\s\S]*?<\/xmp:Title>/i.test(s)&&(s=s.replace(/<xmp:Title>[\s\S]*?<\/xmp:Title>/i,`<xmp:Title>${a}</xmp:Title>`)),/<photoshop:Headline>[\s\S]*?<\/photoshop:Headline>/i.test(s)&&(s=s.replace(/<photoshop:Headline>[\s\S]*?<\/photoshop:Headline>/i,`<photoshop:Headline>${a}</photoshop:Headline>`)),s},MOe=(t,e,n)=>{const s="<?xpacket begin",r="<?xpacket end";let i="",a=0;for(;a<t.length;){const o=t.indexOf(s,a);if(o===-1){i+=t.slice(a);break}i+=t.slice(a,o);const l=t.indexOf(r,o);if(l===-1){i+=t.slice(o);break}const c=t.indexOf("?>",l),h=c===-1?l+r.length:c+2,p=t.slice(o,h);i+=ROe(p,e,n),a=h}return i},zW=t=>{let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e},GW=t=>{const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n)&255;return e},POe=(t,e,n)=>{let s=`
7152`;t.includes(`\r
7153`)?s=`\r
7154`:t.includes("\r")&&!t.includes(`
7155`)&&(s="\r");const r=e.replace(/(\r\n|\n|\r)/g," ").trim(),i=n.join(", ").replace(/(\r\n|\n|\r)/g," ").trim(),a=`%%Title: ${r}${s}%%Keywords: ${i}${s}`;let o=t.replace(/^%%Title:.*(\r\n|\n|\r)/gm,"").replace(/^%%Keywords:.*(\r\n|\n|\r)/gm,"");const l=o.indexOf("%%EndComments");if(l!==-1)return o.slice(0,l)+a+o.slice(l);const c=o.search(/\r\n|\n|\r/);if(c!==-1){const h=o.startsWith(`\r
7156`,c)?2:1,p=c+h;return o.slice(0,p)+a+o.slice(p)}return a+o},HW=(t,e,n)=>{const s=POe(t,e,n);return MOe(s,e,n)},$Oe=(t,e)=>{let s=30;for(const v of e)s+=v.bytes.length;const r=new ArrayBuffer(s),i=new Uint8Array(r),a=new DataView(r);i.set(new Uint8Array(t,0,30),0);let o=30,l=0,c=0,h=0,p=0,m=0,y=0;for(const v of e)v.type==="ps"?(l=o,c=v.bytes.length):v.type==="meta"?(h=o,p=v.bytes.length):v.type==="tiff"&&(m=o,y=v.bytes.length),i.set(v.bytes,o),o+=v.bytes.length;return a.setUint32(4,l,!0),a.setUint32(8,c,!0),a.setUint32(12,h,!0),a.setUint32(16,p,!0),a.setUint32(20,m,!0),a.setUint32(24,y,!0),a.setUint16(28,65535,!0),r},DOe=async(t,e,n)=>{const s=await t.arrayBuffer(),r=new DataView(s),i=new Uint8Array(s);if(r.getUint16(0)!==65496)return t;const a=Uj(e,n),l=new TextEncoder().encode("http://ns.adobe.com/xap/1.0/\0"+a),c=l.length+2,h=new Uint8Array(c+2);h[0]=255,h[1]=225,h[2]=c>>8&255,h[3]=c&255,h.set(l,4);let p=2;if(r.getUint16(p)===65504){const y=r.getUint16(p+2);p+=2+y}const m=new Uint8Array(i.length+h.length);return m.set(i.subarray(0,p),0),m.set(h,p),m.set(i.subarray(p),p+h.length),new Blob([m],{type:"image/jpeg"})},Jie=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;Jie[t]=e}const OOe=t=>{let e=4294967295;for(let n=0;n<t.length;n++)e=Jie[(e^t[n])&255]^e>>>8;return(e^4294967295)>>>0},LOe=async(t,e,n)=>{const s=await t.arrayBuffer(),r=new Uint8Array(s),i=new DataView(s);if(i.getUint32(0)!==2303741511||i.getUint32(4)!==218765834)return t;const a=Uj(e,n),o="XML:com.adobe.xmp",l=new TextEncoder().encode(a),c=new TextEncoder().encode(o),h=new Uint8Array(c.length+5+l.length);h.set(c,0),h[c.length]=0,h[c.length+1]=0,h[c.length+2]=0,h[c.length+3]=0,h[c.length+4]=0,h.set(l,c.length+5);const p=new TextEncoder().encode("iTXt"),m=new Uint8Array(4+h.length);m.set(p,0),m.set(h,4);const y=OOe(m),v=new Uint8Array(12+h.length),b=new DataView(v.buffer);b.setUint32(0,h.length),v.set(p,4),v.set(h,8),b.setUint32(8+h.length,y);let S=33;const E=new Uint8Array(r.length+v.length);return E.set(r.subarray(0,S),0),E.set(v,S),E.set(r.subarray(S),S+v.length),new Blob([E],{type:"image/png"})},jOe=async(t,e,n)=>{const s=await t.arrayBuffer();let r=s;try{const i=new kOe(s);i.read(),i.metadata.title=e,i.metadata.keywords=n.join(", "),r=i.save()}catch(i){console.error("Error embedding iTunes metadata in MP4:",i)}try{const i=Uj(e,n),a=new TextEncoder().encode(i),o=new Uint8Array([190,122,207,203,151,169,66,232,156,113,153,148,145,227,175,172]),l=24+a.length,c=new Uint8Array(l);new DataView(c.buffer).setUint32(0,l),c.set(new TextEncoder().encode("uuid"),4),c.set(o,8),c.set(a,24);const p=new Uint8Array(r.byteLength+l);return p.set(new Uint8Array(r),0),p.set(c,r.byteLength),new Blob([p],{type:"video/mp4"})}catch(i){return console.error("Error embedding XMP in MP4:",i),new Blob([r],{type:"video/mp4"})}},BOe=async(t,e,n)=>{const s=await t.arrayBuffer(),r=new DataView(s);let i=!1,a=0,o=s.byteLength,l=0,c=0,h=0,p=0;s.byteLength>=30&&r.getUint32(0,!1)===3318797254&&(i=!0,a=r.getUint32(4,!0),o=r.getUint32(8,!0),l=r.getUint32(12,!0),c=r.getUint32(16,!0),h=r.getUint32(20,!0),p=r.getUint32(24,!0));const m=new Uint8Array(s,a,o);let y=HW(zW(m),e,n);const v=GW(y),b=[{type:"ps",bytes:v}];if(i&&c>0){const S=new Uint8Array(s,l,c),E=HW(zW(S),e,n);b.push({type:"meta",bytes:GW(E)})}return i&&p>0&&b.push({type:"tiff",bytes:new Uint8Array(s,h,p)}),i?new Blob([$Oe(s,b)],{type:t.type||"application/postscript"}):new Blob([v],{type:t.type||"application/postscript"})},UOe=async(t,e,n)=>{const s=await t.text(),r=n.map(c=>`<rdf:li>${c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</rdf:li>`).join(`
7157            `),a=`
7158  <metadata>
7159    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
7160      <rdf:Description rdf:about="">
7161        <dc:format>image/svg+xml</dc:format>
7162        <dc:title>
7163          <rdf:Alt>
7164            <rdf:li xml:lang="x-default">${e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</rdf:li>
7165          </rdf:Alt>
7166        </dc:title>
7167        <dc:subject>
7168          <rdf:Bag>
7169            ${r}
7170          </rdf:Bag>
7171        </dc:subject>
7172      </rdf:Description>
7173    </rdf:RDF>
7174  </metadata>`;let o=s.replace(/<metadata>[\s\S]*?<\/metadata>/ig,"");const l=o.match(/<svg[^>]*>/i);if(l){const c=l.index+l[0].length,h=o.slice(0,c)+a+o.slice(c);return new Blob([h],{type:"image/svg+xml"})}return t},FOe=async(t,e,n)=>t.type==="image/jpeg"||t.name.toLowerCase().endsWith(".jpg")||t.name.toLowerCase().endsWith(".jpeg")?DOe(t,e,n):t.type==="image/png"||t.name.toLowerCase().endsWith(".png")?LOe(t,e,n):t.type==="video/mp4"||t.name.toLowerCase().endsWith(".mp4")?jOe(t,e,n):t.name.toLowerCase().endsWith(".eps")?BOe(t,e,n):t.type==="image/svg+xml"||t.name.toLowerCase().endsWith(".svg")?UOe(t,e,n):t,VOe=async(t,e,n,s="_")=>{const r=new uj,i=t.filter(c=>c.status===hi.COMPLETED),a=new Set;for(const c of i){const h=c.metadata.keywords.split(",").map(I=>I.trim()).filter(I=>I);let p=c.metadata.title;const m=await FOe(c.file,p,h);let y=c.file.name;const v=y.substring(y.lastIndexOf("."));let b=y.substring(0,y.lastIndexOf("."));if(e){b=p.replace(/[^a-z0-9]/gi,s);const I=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");b=b.replace(new RegExp(`${I}+`,"g"),s).trim().substring(0,100)}let S=1,E=b;for(;a.has(`${E}${v}`);)E=`${b}${s}${S}`,S++;y=`${E}${v}`,a.add(y),r.file(y,m)}const o=await r.generateAsync({type:"blob"}),l=new Date().toISOString().split("T")[0];HS.saveAs(o,`embedded-metadata-files-[${l}].zip`)},JS="/assets/csvbuck-edited-DdN43Os1.svg",zOe="/assets/infinitymodalimage-D0JaJbh3.webp",GOe=({isOpen:t,onClose:e})=>(q.useEffect(()=>{if(!t)return;const n=s=>{s.key==="Escape"&&e()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,e]),d.jsx(kv,{children:t&&d.jsx(ks.div,{initial:{opacity:0}
7174,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/75 backdrop-blur-md p-4",onClick:e,children:d.jsxs(ks.div,{initial:{opacity:0,scale:.94,y:16},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.94,y:16},transition:{duration:.25,ease:[.22,1,.36,1]},className:"relative w-full max-w-3xl overflow-hidden rounded-2xl border border-[#47ff72]/30 bg-[#011f08] shadow-[0_0_60px_rgba(71,255,114,0.18)]",onClick:n=>n.stopPropagation(),children:[d.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#47ff72]/10 via-transparent to-emerald-950/40 pointer-events-none"}),d.jsx("div",{className:"absolute -top-24 -right-24 w-64 h-64 bg-[#47ff72]/10 rounded-full blur-[80px] pointer-events-none"}),d.jsx("button",{onClick:e,className:"absolute top-4 right-4 z-20 p-2 rounded-full text-slate-400 hover:text-white hover:bg-white/10 transition-colors","aria-label":"Close",children:d.jsx(Ki,{className:"w-5 h-5"})}),d.jsxs("div",{className:"relative flex flex-col md:flex-row min-h-[320px]",children:[d.jsxs("div",{className:"md:w-[42%] min-h-[180px] md:min-h-0 relative overflow-hidden",children:[d.jsx("img",{src:zOe,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),d.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-[#011f08]/20 to-[#011f08] md:bg-gradient-to-r md:from-transparent md:to-[#011f08]"})]}),d.jsxs("div",{className:"flex-1 flex flex-col justify-center px-6 py-8 md:px-8 md:py-10 md:min-w-[22rem]",children:[d.jsxs("div",{className:"inline-flex items-center gap-2 mb-4",children:[d.jsx(mp,{className:"w-4 h-4 text-[#47ff72]"}),d.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] text-[#47ff72]/80",children:"Plan unlocked"})]}),d.jsx("h2",{className:"text-2xl md:text-3xl font-extrabold text-[#47ff72] leading-tight",children:"Welcome to CSV Max"}),d.jsx("p",{className:"mt-2 text-base font-semibold text-white/90",children:"Unlimited batches. Maximum power."}),d.jsx("p",{className:"mt-4 text-sm text-slate-400 leading-relaxed max-w-md",children:"You now have 15,000 monthly CSVBucks, unlimited files in every batch, and unlimited access to Background Generator, Image Upscaler, Bento Generator, and Vector Studio. Drop in your whole library and keep going."}),d.jsxs("div",{className:"mt-6 flex items-center gap-2 text-xs font-medium text-[#47ff72]/80",children:[d.jsx($be,{className:"w-4 h-4 shrink-0"}),d.jsx("span",{children:"No batch cap — process as many files as you need at once"})]}),d.jsxs("div",{className:"mt-8 flex flex-wrap items-center gap-3",children:[d.jsx("button",{type:"button",onClick:e,className:"inline-flex items-center justify-center gap-2 px-6 py-3.5 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 text-sm font-bold rounded-xl shadow-[0_0_24px_rgba(71,255,114,0.4)] hover:shadow-[0_0_32px_rgba(71,255,114,0.55)] transition-all hover:-translate-y-0.5 whitespace-nowrap shrink-0",children:"Start creating"}),d.jsx("button",{type:"button",onClick:e,className:"inline-flex items-center justify-center px-6 py-3.5 text-sm font-medium text-slate-400 hover:text-white border border-slate-700 hover:border-slate-500 rounded-xl transition-colors whitespace-nowrap shrink-0",children:"Maybe later"})]})]})]})]})})})),zO="csv_max_welcome_pending";function HOe(t){if(!t)return!1;const e=t.trim().toLowerCase();return e==="max"||e==="csv max"||e.includes("csv max")}function qOe(t){HOe(t)&&sessionStorage.setItem(zO,"1")}function WOe(){const t=sessionStorage.getItem(zO)==="1";return t&&sessionStorage.removeItem(zO),t}function KOe(t=!0){const[e,n]=q.useState(!1);q.useEffect(()=>{t&&WOe()&&n(!0)},[t]);const s=q.useCallback(()=>{n(!1)},[]);return{isOpen:e,closeCsvMaxWelcome:s}}const qW="https://asia-south1-gen-lang-client-0084186361.cloudfunctions.net/api".replace(/\/$/,"");function Qie(t){return qW?`${qW}${t}`:`/api${t}`}async function YOe(){const t=Ko.currentUser;if(!t)throw new Error("You must be signed in to continue.");return t.getIdToken()}async function Vj(t,e={}){const n=await YOe(),s=await fetch(Qie(t),{...e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,...e.headers??{}}}),r=await s.json().catch(()=>({}));if(!s.ok)throw new Error(r.error??"Request failed.");return r}async function XOe(t,e,n,s="monthly"){return Vj("/payment/create",{method:"POST",body:JSON.stringify({planId:t,currency:e,couponCode:n,billingInterval:s})})}async function JOe(t,e){return Vj("/trial/redeem",{method:"POST",body:JSON.stringify({planId:t,couponCode:e})})}
7174async function QOe(){return Vj("/payment/check-pending",{method:"POST"})}async function ZOe(t){const e=await fetch(`${Qie("/payment/verify-return")}?invoice_id=${encodeURIComponent(t)}`),n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error??"Verification failed.");return n}const Zie="csv_last_celebration_at",eLe=6e4;function zj(){sessionStorage.setItem(Zie,String(Date.now()))}function tLe(){const t=Number(sessionStorage.getItem(Zie)??0);return Date.now()-t<eLe}function nLe(t=!0){const e=co();q.useEffect(()=>{if(!t)return;let n=!1;const s=async()=>{if(Ko.currentUser&&!tLe())try{const a=await QOe();if(n)return;a.status==="completed"&&a.planName&&(zj(),e("/checkout/success",{replace:!0,state:{planName:a.planName}}))}catch(a){console.warn("Pending payment check failed",a)}},r=Ko.onAuthStateChanged(i=>{i&&s()});return()=>{n=!0,r()}},[t,e])}const eae="csv_admin_celebration_processed_at";function sLe(t){if(!t||typeof t!="object")return null;const e=t;if(typeof e.planName=="string"&&e.planName.trim())return e.planName.trim();if(typeof e.planId=="string"){const n=e.planId.toLowerCase();if(n==="lite"||n==="plus"||n==="max")return wI(n)}return null}function rLe(){return Number(sessionStorage.getItem(eae)??0)}function iLe(t){sessionStorage.setItem(eae,String(t))}function aLe(t){const e=Number(t??0);return!Number.isFinite(e)||e<=0?!0:e>rLe()}function oLe(t){return`/checkout/success?planName=${encodeURIComponent(t)}`}const lLe=1e4;let GO=!1,RR=null,MS=null,QS=null,ZS=null,HO=null,Ew=!1,xN=!1;function cLe(){return window.location.pathname}function tae(){return cLe()==="/app"}async function uLe(t){await OX(Td(Bc,"users",t),{pendingPlanCelebration:jh(),pendingPlanCelebrationAt:jh()})}function Gj(){QS&&(clearInterval(QS),QS=null),ZS&&(document.removeEventListener("visibilitychange",ZS),ZS=null),HO=null}async function dLe(t,e,n){if(!(Ew||!RR)&&tae()){Ew=!0;try{iLe(n),zj();try{await uLe(t)}catch(s){console.warn("Could not clear pending plan celebration flag",s)}RR(oLe(e),{replace:!0,state:{planName:e}})}finally{Ew=!1}}}async function A3(t){if(!(xN||Ew)&&tae()){xN=!0;try{const e=await Q0(Td(Bc,"users",t));if(!e.exists())return;const n=e.data(),s=sLe(n.pendingPlanCelebration);if(!s)return;const r=Number(n.pendingPlanCelebrationAt??Date.now());if(!aLe(r))return;await dLe(t,s,r)}catch(e){console.warn("Could not check pending admin plan celebration",e)}finally{xN=!1}}}function hLe(t){HO===t&&QS||(Gj(),HO=t,A3(t),QS=setInterval(()=>{A3(t)},lLe),ZS=()=>{document.visibilityState==="visible"&&A3(t)},document.addEventListener("visibilitychange",ZS))}function fLe(t){RR=t,!GO&&(GO=!0,MS=Ko.onAuthStateChanged(e=>{if(!e){Gj(),Ew=!1;return}hLe(e.uid)}))}function pLe(){Gj(),MS==null||MS(),MS=null,GO=!1,RR=null,Ew=!1,xN=!1}function mLe(){const t=co();q.useEffect(()=>(fLe(t),()=>pLe()),[t])}const WW="csv_meta_settings_v2",KW="csv_meta_refiner_prompts",YW="csv_meta_theme_pref",gLe=()=>{const[t,e]=q.useState([]),[n,s]=q.useState(null),[r,i]=q.useState(!0),[a,o]=q.useState(!1),[l,c]=q.useState(null),[h,p]=q.useState(!1),[m,y]=q.useState(!1),[v,b]=q.useState(!0),S=co(),{isOpen:E,reason:I,openPricingInsist:M,closePricingInsist:j}=PA(),{isOpen:L,closeCsvMaxWelcome:K}=KOe(!r);nLe(!r),mLe();const[D,R]=q.useState(()=>typeof window<"u"&&localStorage.getItem(YW)||"system");q.useEffect(()=>{const Ye=window.document.documentElement,vt=()=>{let ct=!1;D==="dark"?ct=!0:D==="system"?ct=window.matchMedia("(prefers-color-scheme: dark)").matches:ct=!1,ct?Ye.classList.add("dark"):Ye.classList.remove("dark")};if(vt(),localStorage.setItem(YW,D),D==="system"){const ct=window.matchMedia("(prefers-color-scheme: dark)"),Kt=()=>vt();return ct.addEventListener("change",Kt),()=>ct.removeEventListener("change",Kt)}},[D]),q.useEffect(()=>{let Ye=!1;return tZ("app").then(vt=>{Ye||c(vt)}),()=>{Ye=!0}},[]);const B="gemini-3.6-flash",G="gemini-3.5-flash-lite",X="gemini-3.1-flash-lite",H="gemini-2.5-flash-lite",Y="gemini-2.5-flash",F=[B,G,X,H,Y],we="llama-4-scout",me="mistral-large-latest",xe="mistral-medium-latest",[Le,ve]=q.useState(()=>{try{const Ye=localStorage.getItem("gemini_api_keys_v1");if(Ye)return JSON.parse(Ye).map(Kt=>({...Kt,provider:Kt.provider||"gemini"}));const vt=localStorage.getItem("gemini_api_key");if(vt)return[{id:j2(),key:vt,label:"Default Key",provider:"gemini",isActive:!0,createdAt:Date.now()}]}catch(Ye){console.error("Error loading API keys:",Ye)}return[]}),[ce,ie]=q.useState("metadata"),[de,Re]=q.useState(Ti.METADATA),[Se,De]=q.useState(_h.CSV),[gt,yt]=q.useState(!1),[xt,Nt]=q.useState("_"),[wt,zt]=q.useState(jr.ADOBE_STOCK),[_n,Zt]=q.useState(100),[J,We]=q.useState(40),[Ie,ge]=q.useState(400),[he,Ae]=q.useState(X),[et,nt]=q.useState(!1),[He,ft]=q.useState(!1),[Mt,pt]=q.useState(!1),[Oe,hn]=q.useState(!1),[Yt,Qe]=q.useState([]),[tn,je]=q.useState(!1),[Ue,bt]=q.useState(null),[ht,Dt]=q.useState(""),[Ut,Lt]=q.useState(""),[Wt,fn]=q.useState(!1),[Jt,Kn]=q.useState(null),[nn,Wn]=q.useState(null),[ln,ns]=q.useState(""),[Js,ur]=q.useState(!1),[zs,fs]=q.useState(!1);q.useEffect(()=>{try{const Ye=localStorage.getItem(WW);
7174if(Ye){const ct=JSON.parse(Ye);ct.generationMode&&Re(ct.generationMode),ct.platform&&zt(ct.platform),ct.outputFormat&&De(ct.outputFormat),typeof ct.renameFiles=="boolean"&&yt(ct.renameFiles),ct.wordSeparator&&Nt(ct.wordSeparator),typeof ct.titleMaxLength=="number"&&Zt(ct.titleMaxLength),typeof ct.keywordsCount=="number"&&We(ct.keywordsCount),typeof ct.promptLength=="number"&&ge(ct.promptLength),ct.selectedModel&&Ae(ct.selectedModel),typeof ct.isSilhouette=="boolean"&&nt(ct.isSilhouette),typeof ct.isIcon=="boolean"&&ft(ct.isIcon),typeof ct.isSeamless=="boolean"&&pt(ct.isSeamless),typeof ct.isRefinerEnabled=="boolean"&&hn(ct.isRefinerEnabled)}const vt=localStorage.getItem(KW);Qe(vt?JSON.parse(vt):[{id:j2(),label:"My Style",content:"Use a professional, neutral tone. Avoid flowery adjectives.",isActive:!0,lastUpdated:Date.now()}])}catch(Ye){console.error("Error loading settings:",Ye)}finally{fs(!0)}},[]),q.useEffect(()=>{wt===jr.FREEPIK&&_n>100&&Zt(100)},[wt,_n]),q.useEffect(()=>{e(Ye=>Ye.map(vt=>{if(vt.metadata.adobe_category&&vt.metadata.shutterstock_category){let ct=vt.metadata.category;return wt===jr.ADOBE_STOCK?ct=vt.metadata.adobe_category:wt===jr.SHUTTERSTOCK&&(ct=vt.metadata.shutterstock_category),{...vt,metadata:{...vt.metadata,category:ct}}}return vt}))},[wt]),q.useEffect(()=>{if(!zs)return;const Ye={generationMode:de,platform:wt,outputFormat:Se,renameFiles:gt,wordSeparator:xt,titleMaxLength:_n,keywordsCount:J,promptLength:Ie,selectedModel:he,isSilhouette:et,isIcon:He,isSeamless:Mt,isRefinerEnabled:Oe};localStorage.setItem(WW,JSON.stringify(Ye))},[de,wt,Se,gt,xt,_n,J,Ie,he,et,He,Mt,Oe,zs]),q.useEffect(()=>{zs&&localStorage.setItem(KW,JSON.stringify(Yt))},[Yt,zs]);const[ps,ms]=q.useState(!1),[Me,lt]=q.useState(!1),[jt,Qt]=q.useState(!1),[Sn,yn]=q.useState(!1),[Ft,sn]=q.useState([]),[rn,bs]=q.useState(!1),[gs,us]=q.useState(!1),[Hn,ls]=q.useState(!1),[Ps,rr]=q.useState(!1),[ws,$s]=q.useState(new Set),ys=q.useRef(null),Pn=5;q.useEffect(()=>{const Ye=Vm(Ko,async vt=>{if(vt){const ct=vM(vt);s(ct),localStorage.setItem("google_user_session",JSON.stringify(ct));try{const Kt=await Vv(vt);s(Kt),localStorage.setItem("google_user_session",JSON.stringify(Kt))}catch(Kt){console.error("Error saving user to Firestore",Kt)}}else s(null),localStorage.removeItem("google_user_session"),S("/auth");i(!1)});return()=>Ye()},[S]);const ir=async()=>{try{await BX()}catch(Ye){console.error("Logout failed",Ye)}o(!1),y(!1)},ot=async()=>{S("/auth")};q.useEffect(()=>{localStorage.setItem("gemini_api_keys_v1",JSON.stringify(Le))},[Le]);const ar=Le.find(Ye=>Ye.isActive),$n=(ar==null?void 0:ar.key)||"",kn=(ar==null?void 0:ar.provider)||"gemini";q.useEffect(()=>{kn==="gemini"?F.includes(he)||Ae(X):kn==="groq"?he!==we&&Ae(we):kn==="mistral"&&he!==me&&he!==xe&&Ae(xe)},[kn,he]);const Nn=(Ye,vt,ct)=>{const Kt={id:j2(),key:Ye,label:vt||`Key ${Le.filter(ds=>ds.provider===ct).length+1}`,provider:ct,isActive:Le.length===0,createdAt:Date.now()};ve(ds=>[...ds,Kt])},Bn=Ye=>ve(vt=>vt.filter(ct=>ct.id!==Ye)),er=Ye=>ve(vt=>vt.map(ct=>({...ct,isActive:ct.id===Ye}))),oi=(Ye,vt)=>ve(ct=>ct.map(Kt=>Kt.id===Ye?{...Kt,label:vt}:Kt)),or=Ye=>{Qe(vt=>vt.map(ct=>({...ct,isActive:ct.id===Ye})))},ue=Ye=>{Qe(vt=>{var Kt;
7174const ct=vt.filter(ds=>ds.id!==Ye);return(Kt=vt.find(ds=>ds.id===Ye))!=null&&Kt.isActive&&ct.length>0&&(ct[0].isActive=!0),ct})},ke=()=>{Dt(""),Lt(""),bt(null),je(!0)},pe=Ye=>{Dt(Ye.label),Lt(Ye.content),bt(Ye.id),je(!0)},Pe=()=>{if(!(!ht.trim()||!Ut.trim())){if(Ue)Qe(Ye=>Ye.map(vt=>vt.id===Ue?{...vt,label:ht,content:Ut,lastUpdated:Date.now()}:vt));else{const Ye={id:j2(),label:ht,content:Ut,isActive:Yt.length===0,lastUpdated:Date.now()};Qe(vt=>[...vt,Ye])}je(!1)}},$e=async()=>{if(Ut.trim()){if(!$n){ms(!0);return}fn(!0);try{const Ye=await TOe($n,Ut,kn);Ye&&Lt(Ye.trim())}catch(Ye){console.error("Failed to enhance prompt",Ye),Kn("Failed to enhance prompt. Check your API key or connection.")}finally{fn(!1)}}},Ne=async()=>{if(!ln.trim()||!n)return;ur(!0),Kn(null);const Ye=ln.split(`
7175`).map(Kt=>Kt.trim()).filter(Kt=>Kt),vt=[],ct=[];for(const Kt of Ye)try{new URL(Kt);const ds=await fetch(Kt);if(!ds.ok)throw new Error(`HTTP error! status: ${ds.status}`);const Mr=await ds.blob();if(!Mr.type.startsWith("image/"))throw new Error("Not an image");const Ds=Kt.split("/");let Hs=Ds[Ds.length-1].split("?")[0];if(!Hs||!Hs.includes(".")){const Yn=Mr.type.split("/")[1]||"jpeg";Hs=`image-${Date.now()}.${Yn}`}const un=new File([Mr],Hs,{type:Mr.type});vt.push(un)}catch(ds){console.error(`Failed to fetch URL: ${Kt}`,ds),ct.push(Kt)}vt.length>0&&(tt(vt),ns("")),ct.length>0&&Kn(`Failed to fetch ${ct.length} image(s). Please check the URLs and ensure they point directly to image files.`),ur(!1)},tt=async Ye=>{if(!n)return;const vt=[],ct=[];for(let Ds=0;Ds<Ye.length;Ds++){const Hs=Ye[Ds],un=GMe(Hs);if(de===Ti.PROMPT&&un==="vector")continue;let Yn=null;(un==="image"||un==="vector")&&Hs.type.startsWith("image/")&&(Yn=URL.createObjectURL(Hs));const As=j2();un==="video"&&ct.push({id:As,file:Hs}),vt.push({id:As,file:Hs,previewUrl:Yn,status:hi.PENDING,type:un,metadata:{title:"",keywords:"",category:"",prompt:""}})}if(vt.length===0)return;const Kt=MF(n);if(Number.isFinite(Kt)&&t.length+vt.length>Kt){M("batch_limit");return}e(Ds=>[...Ds,...vt]),sn(Ds=>[...Ds,...vt.map(Hs=>Hs.id)]),ct.forEach(async({id:Ds,file:Hs})=>{try{const un=await gq(Hs,1,300);if(un.length>0){const Yn=`data:image/jpeg;base64,${un[0]}`;e(As=>As.map(Pr=>Pr.id===Ds?{...Pr,previewUrl:Yn}:Pr))}}catch(un){console.warn(`Failed thumbnail for video ${Ds}`,un)}});const ds=vt.filter(Ds=>Ds.type==="vector"&&!Ds.file.type.includes("svg")&&!Ds.file.name.toLowerCase().endsWith(".ai")),Mr=vt.filter(Ds=>Ds.file.name.toLowerCase().endsWith(".ai"));ds.forEach(async Ds=>{try{const un=`data:image/jpeg;base64,${await pq(Ds.file,300)}`;e(Yn=>Yn.map(As=>As.id===Ds.id?{...As,previewUrl:un}:As))}catch(Hs){console.warn("EPS Preview failed",Hs)}}),Mr.forEach(async Ds=>{try{const un=`data:image/jpeg;base64,${await mq(Ds.file,300)}`;e(Yn=>Yn.map(As=>As.id===Ds.id?{...As,previewUrl:un}:As))}catch(Hs){console.warn("AI Preview failed",Hs)}})},mt=q.useCallback(async()=>{if(Ft.length===0||!$n||!n)return;const Ye=Ft.slice(0,Pn);if(n.role!=="admin"&&M4(n)<Ye.length){M("csvbucks"),us(!1);return}bs(!0),e(vt=>vt.map(ct=>Ye.includes(ct.id)?{...ct,status:hi.PROCESSING,error:void 0}:ct));try{const vt=kn==="mistral"||kn==="groq"?300:512,ct=[],Kt=t.filter(un=>Ye.includes(un.id)),ds=Ye.map(un=>Kt.find(Yn=>Yn.id===un));for(const un of ds){let Yn=[],As=!1;if(un.type==="image")Yn=[{inlineData:{data:await VMe(un.file,vt),mimeType:"image/jpeg"}}];else if(un.type==="video"){const Pr=await gq(un.file,3,vt);Pr.length>0&&(Yn=Pr.map(kr=>({inlineData:{data:kr,mimeType:"image/jpeg"}})))}else if(un.type==="vector")if(un.file.type==="image/svg+xml")try{Yn=[{inlineData:{data:await zMe(un.file,vt),mimeType:"image/jpeg"}}]}catch{As=!0}else if(un.file.name.toLowerCase().endsWith(".ai"))try{let Pr="";Pr=await mq(un.file,vt),Yn=[{inlineData:{data:Pr,mimeType:"image/jpeg"}}]}catch{Yn=[{inlineData:{data:await hq(un.file),mimeType:"text/plain"}}],As=!0}else try{Yn=[{inlineData:{data:await pq(un.file,vt),mimeType:"image/jpeg"}}]}catch{Yn=[{inlineData:{data:await hq(un.file),mimeType:"text/plain"}}],As=!0}ct.push({id:un.id,filename:un.file.name,mediaParts:Yn,isFileOnly:As,type:un.type})}let Mr="";if(Oe){const un=Yt.find(Yn=>Yn.isActive);un&&(Mr=un.content)}const Hs=await EOe($n,ct,{titleMaxLength:_n,keywordsCount:J,promptLength:Ie,modelId:he,mode:de,platform:wt,provider:kn,isSilhouette:et,isIcon:He,refinerInstruction:Mr,isSeamless:Mt},un=>Kn(un),un=>Ae(un));Kn(null);for(let un=0;un<Hs.length;un++){const Yn=Ye[un];let As=Hs[un];const Pr=ds[un];if(de===Ti.METADATA&&(Pr.file.type==="image/png"||Pr.file.name.toLowerCase().endsWith(".png"))){let kr=As.keywords.split(",").map(Ga=>Ga.trim()).filter(Ga=>Ga);const Yi="isolated on transparent background";kr.some(Ga=>Ga.toLowerCase()===Yi)||(kr.length>=J&&(kr=kr.slice(0,J-1)),kr.push(Yi),As.keywords=kr.join(", "))}e(kr=>kr.map(Yi=>Yi.id===Yn?{...Yi,status:hi.COMPLETED,metadata:As}:Yi)),await new Promise(kr=>setTimeout(kr,200))}if(n.role!=="admin")try{const un=await wve(n.sub,Ye.length);s(Yn=>Yn&&{...Yn,csvBucksBalance:un})}catch(un){console.error("Failed to deduct CSVBucks",un)}}catch(vt){const ct=vt.status===429||vt.code===429;e(Kt=>Kt.map(ds=>Ye.includes(ds.id)?{...ds,status:hi.ERROR,error:ct?"Rate Limit hit":vt.message}:ds))}finally{bs(!1),sn(vt=>vt.slice(Ye.length)),setTimeout(()=>{if(ys.current&&Ye.length>0){const vt=Ye[Ye.length-1],ct=t.findIndex(Kt=>Kt.id===vt);if(ct!==-1&&ct+1<t.length){const Kt=ys.current,ds=Kt.firstElementChild;if(ds&&ds.children.length>ct+1){const Mr=ds.children[ct+1];if(Mr){const Ds=Kt.getBoundingClientRect(),un=Mr.getBoundingClientRect().top-Ds.top;Kt.scrollTo({top:Kt.scrollTop+un-24,behavior:"smooth"})}}}}},100)}},[$n,kn,t,Ft,_n,J,Ie,he,de,wt,et,He,n,Oe,Yt,Mt]);q.useEffect(()=>{if(gs&&Ft.length>0&&!rn&&$n&&n){const Ye=setTimeout(()=>mt(),100);return()=>clearTimeout(Ye)}else Ft.length===0&&gs&&!rn&&(us(!1),(t.some(Ye=>Ye.status===hi.COMPLETED)||t.some(Ye=>Ye.status===hi.ERROR))&&(lt(!0),ys.current&&ys.current.scrollTo({top:0,behavior:"smooth"}
7175)))},[gs,Ft,rn,$n,mt,t,n]);const Ct=Ye=>{e(vt=>vt.filter(ct=>ct.id!==Ye)),sn(vt=>vt.filter(ct=>ct!==Ye)),$s(vt=>{const ct=new Set(vt);return ct.delete(Ye),ct})},_t=Ye=>{e(vt=>vt.map(ct=>ct.id===Ye?{...ct,status:hi.PENDING,error:void 0}:ct)),sn(vt=>vt.includes(Ye)?vt:[...vt,Ye]),us(!0)},kt=()=>{t.length!==0&&(Hn?(us(!1),e([]),sn([]),ls(!1),$s(new Set),rr(!1)):(ls(!0),setTimeout(()=>ls(!1),3e3)))},Xt=(Ye,vt,ct)=>{e(Kt=>Kt.map(ds=>ds.id===Ye?{...ds,metadata:{...ds.metadata,[vt]:ct}}:ds))},qn=()=>{if(!n)return;if(!$n){ms(!0);return}const Ye=t.filter(vt=>vt.status===hi.PENDING||vt.status===hi.ERROR).map(vt=>vt.id);if(Ye.length!==0){if(n.role!=="admin"&&M4(n)<Ye.length){M("csvbucks");return}Ft.length===0&&sn(Ye),us(!0)}},Xn=()=>{const Ye=t.filter(vt=>vt.status===hi.ERROR).map(vt=>vt.id);e(vt=>vt.map(ct=>Ye.includes(ct.id)?{...ct,status:hi.PENDING,error:void 0}:ct)),sn(vt=>{const ct=[...vt];return Ye.forEach(Kt=>{ct.includes(Kt)||ct.push(Kt)}),ct}),us(!0)},an=Ye=>{$s(vt=>{const ct=new Set(vt);return ct.has(Ye)?ct.delete(Ye):ct.add(Ye),ct})},Jn=()=>{const Ye=Array.from(ws);e(vt=>vt.map(ct=>ws.has(ct.id)?{...ct,status:hi.PENDING,error:void 0}:ct)),sn(vt=>{const ct=[...vt];return Ye.forEach(Kt=>{ct.includes(Kt)||ct.push(Kt)}),ct}),$s(new Set),us(!0)},Qn=()=>{de===Ti.METADATA?Se===_h.EMBED?VOe(t,gt,wt,xt):AOe(t,wt):COe(t)},Gs=t.filter(Ye=>Ye.status===hi.COMPLETED).length,Cr=t.filter(Ye=>Ye.status===hi.ERROR).length,Qs=t.length-Gs,ti=Array.from(ws).some(Ye=>{var ct;const vt=(ct=t.find(Kt=>Kt.id===Ye))==null?void 0:ct.status;return vt===hi.COMPLETED||vt===hi.ERROR}),gi="flex items-center gap-2 px-3 py-1.5 bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 text-xs font-bold uppercase rounded-lg border border-slate-200 dark:border-slate-700 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors",yr=Ye=>Ye==="gemini"?d.jsx(WL,{className:"w-4 h-4 text-[#47ff72]"}):Ye==="groq"?d.jsx(vd,{className:"w-4 h-4 text-[#47ff72]"}):d.jsx(oJ,{className:"w-4 h-4 text-[#47ff72]"}),_a=Ye=>Ye==="gemini"?"Gemini":Ye==="groq"?"Groq":"Mistral",Va=({onSelect:Ye})=>d.jsxs("div",{className:"px-3 py-2 border-t border-slate-100 dark:border-slate-800",children:[d.jsx("p",{className:"text-[10px] font-bold text-slate-400 dark:text-slate-500 uppercase tracking-wider mb-2 px-1",children:"Theme"}),d.jsxs("div",{className:"flex gap-1",children:[d.jsxs("button",{onClick:()=>{R("light"),Ye==null||Ye()},className:`flex-1 flex items-center justify-center gap-1.5 px-2 py-2 text-xs rounded-lg transition-colors ${D==="light"?"bg-[#47ff72]/10 text-[#47ff72] border border-[#47ff72]/30":"text-slate-600 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:"Light mode",children:[d.jsx(yD,{className:"w-3.5 h-3.5"})," Light"]}),d.jsxs("button",{onClick:()=>{R("dark"),Ye==null||Ye()},className:`flex-1 flex items-center justify-center gap-1.5 px-2 py-2 text-xs rounded-lg transition-colors ${D==="dark"?"bg-[#47ff72]/10 text-[#47ff72] border border-[#47ff72]/30":"text-slate-600 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:"Dark mode",children:[d.jsx(pD,{className:"w-3.5 h-3.5"})," Dark"]}),d.jsxs("button",{onClick:()=>{R("system"),Ye==null||Ye()},className:`flex-1 flex items-center justify-center gap-1.5 px-2 py-2 text-xs rounded-lg transition-colors ${D==="system"?"bg-[#47ff72]/10 text-[#47ff72] border border-[#47ff72]/30":"text-slate-600 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:"System theme",children:[d.jsx(fD,{className:"w-3.5 h-3.5"})," Auto"]})]})]}),Ls=n?M4(n):0,li=((n==null?void 0:n.plan)??"free")==="free",ni=n&&!li&&(n.plan??"free")!=="max",pn=({onNavigate:Ye})=>d.jsxs("div",{className:"border-t border-slate-200 dark:border-slate-800 px-4 py-3 flex items-center justify-between gap-3 bg-slate-100 dark:bg-[#011f08]",children:[d.jsx("span",{className:"text-xs text-slate-700 dark:text-slate-200",children:"Need extra CSVBucks?"}),d.jsx(Is,{to:"/pricing",onClick:Ye,className:"px-3 py-1.5 text-xs font-bold bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-lg transition-colors whitespace-nowrap",children:"Upgrade"})]}),ji="h-9",za="border-2 border-[#47ff72] rounded-lg box-border",Ai=()=>
7175{if(!n)return null;const Ye=li||ni,vt="flex items-center gap-1.5 transition-colors cursor-pointer hover:bg-[#47ff72]/10 dark:hover:bg-[#47ff72]/15 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#47ff72]/50",ct=()=>d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>p(!1)}),d.jsxs("div",{className:"absolute right-0 top-full mt-2 w-72 bg-white dark:bg-slate-900 rounded-xl shadow-xl border border-slate-200 dark:border-slate-700 z-50 overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:[d.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 border-b border-slate-200 dark:border-slate-800",children:[d.jsx("img",{src:JS,alt:"",className:"w-5 h-5 object-contain"}),d.jsxs("span",{className:"text-sm font-semibold text-slate-900 dark:text-white tabular-nums",children:[Ls," CSVBucks"]})]}),d.jsxs("div",{className:"px-4 py-3 border-b border-slate-200 dark:border-slate-800",children:[d.jsx("p",{className:"text-sm font-bold text-slate-900 dark:text-white",children:wI(n.plan??"free")}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 leading-relaxed",children:mve(n)})]}),Ye&&d.jsxs("div",{className:"px-4 py-3 flex items-center justify-between gap-3 bg-slate-50 dark:bg-[#011f08]",children:[d.jsx("span",{className:"text-xs text-slate-700 dark:text-slate-200",children:"Need extra CSVBucks?"}),d.jsx(Is,{to:"/pricing",onClick:()=>p(!1),className:"px-3 py-1.5 text-xs font-bold bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-lg transition-colors whitespace-nowrap",children:"Upgrade"})]})]})]});return li?d.jsxs("div",{className:`relative flex items-stretch ${ji} ${za} overflow-visible shadow-[0_0_10px_rgba(71,255,114,0.35)]`,children:[d.jsxs("button",{type:"button",onClick:()=>p(Kt=>!Kt),className:`${vt} h-full px-2.5 bg-white dark:bg-[#011f08] rounded-l-[6px]`,"aria-expanded":h,"aria-haspopup":"dialog",children:[d.jsx("img",{src:JS,alt:"",className:"w-5 h-5 object-contain"}),d.jsx("span",{className:"text-sm font-bold text-[#47ff72] tabular-nums",children:Ls})]}),d.jsx(Is,{to:"/pricing",className:"flex items-center h-full px-3 text-xs font-bold bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 transition-colors rounded-r-[6px]",children:"Upgrade"}),h&&d.jsx(ct,{})]}):d.jsxs("div",{className:"relative",children:[d.jsxs("button",{type:"button",onClick:()=>p(Kt=>!Kt),className:`${vt} ${ji} ${za} gap-1.5 px-2.5 shadow-[0_0_10px_rgba(71,255,114,0.35)]`,"aria-expanded":h,"aria-haspopup":"dialog",children:[d.jsx("img",{src:JS,alt:"",className:"w-5 h-5 object-contain"}),d.jsx("span",{className:"text-sm font-bold text-[#47ff72] tabular-nums",children:Ls})]}),h&&d.jsx(ct,{})]})};return r?d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08]",children:d.jsxs("div",{className:"flex flex-col items-center gap-6",children:[d.jsxs("div",{className:"relative flex items-center justify-center",children:[d.jsx(Go,{className:"w-16 h-16 text-[#47ff72] animate-spin"}),d.jsx("img",{src:"/icon.png",alt:"CSV Meta Icon",className:"absolute w-8 h-8 object-contain"})]}),d.jsx("p",{className:"text-slate-300 font-medium tracking-wide text-sm uppercase",children:"Initializing CSV Meta..."})]})}):d.jsxs("div",{className:"min-h-screen flex flex-col bg-[#011f08] text-slate-100 transition-colors duration-300 font-sans",children:[nn&&d.jsxs("div",{className:"bg-red-500 text-white px-4 py-2 text-center text-sm font-medium relative flex items-center justify-center shadow-md z-50",children:[d.jsx(S0,{className:"w-4 h-4 mr-2"}),d.jsxs("span",{children:["Your account is blocked. To restore access, please contact ",d.jsx("a",{href:"mailto:[email protected]",className:"underline font-bold hover:text-red-100 transition-colors",children:"support"}),"."]}),d.jsx("button",{onClick:()=>Wn(null),className:"absolute right-4 top-1/2 -translate-y-1/2 hover:text-red-200 transition-colors",children:d.jsx(Ki,{className:"w-4 h-4"})})]}),d.jsx(ATe,{isOpen:ps,onClose:()=>ms(!1),apiKeys:Le,onAdd:Nn,onDelete:Bn,onToggle:er,onUpdateLabel:oi}),d.jsx(ITe,{isOpen:Me,onClose:()=>
7175lt(!1),onExport:Qn,count:Gs,mode:de,errorCount:Cr,onRegenerateFailed:Xn,outputFormat:Se}),d.jsx(LTe,{isOpen:jt,onClose:()=>Qt(!1),tool:ce}),d.jsx(UTe,{isOpen:Sn,onClose:()=>yn(!1)}),d.jsx(MA,{isOpen:E,onClose:j,reason:I}),d.jsx(GOe,{isOpen:L,onClose:K}),d.jsxs("header",{className:"bg-white dark:bg-green-950 border-b border-slate-200 dark:border-slate-800 sticky top-0 z-40 transition-colors duration-300",children:[d.jsxs("div",{className:"w-full px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between",children:[d.jsx("div",{className:"flex items-center",children:d.jsx(Is,{to:"/",className:"flex items-center",children:d.jsx("img",{src:"logo.png",alt:"CSV Meta",className:"h-12 w-auto object-contain"})})}),d.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[d.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[d.jsx("button",{onClick:()=>Qt(!0),className:"p-2 text-slate-500 hover:text-[#47ff72] dark:text-slate-400 dark:hover:text-[#47ff72] transition-colors",title:"User Guide",children:d.jsx(GN,{className:"w-5 h-5"})}),ce==="metadata"&&d.jsxs("button",{onClick:()=>n&&ms(!0),className:`p-2 transition-colors relative ${n?"text-slate-500 hover:text-[#47ff72] dark:text-slate-400 dark:hover:text-[#47ff72]":"text-slate-300 dark:text-slate-700 cursor-not-allowed"}`,disabled:!n,title:"Settings",children:[d.jsx(FF,{className:"w-5 h-5"}),n&&Le.length===0&&d.jsx("div",{className:"absolute -top-0.5 -right-0.5 bg-white dark:bg-slate-900 rounded-full p-0.5 shadow-sm",children:d.jsx(S0,{className:"w-3 h-3 text-red-500 fill-red-500/10"})})]}),!n&&d.jsxs("button",{onClick:ot,className:"flex items-center justify-center gap-2 px-3 py-1.5 ml-2 border border-[#47ff72] text-[#47ff72] rounded-lg font-bold transition-colors hover:bg-[#47ff72] hover:text-slate-900 text-sm h-[36px]",children:[d.jsx(gE,{className:"w-4 h-4"}),d.jsx("span",{children:"Sign In"})]}),d.jsx("div",{className:"w-px h-9 bg-slate-200 dark:bg-slate-700 mx-1"}),d.jsx("a",{href:"https://t.me/csvmeta",target:"_blank",rel:"noopener noreferrer",title:"Find Us on Telegram",className:`inline-flex items-center justify-center w-9 ${ji} ${za} text-[#47ff72] hover:bg-[#229ED9] hover:text-white hover:border-[#229ED9] transition-colors shrink-0`,children:d.jsx(Ed,{className:"w-5 h-5"})}),d.jsxs("button",{onClick:()=>yn(!0),className:`inline-flex items-center gap-2 px-3 ${ji} ${za} text-[#47ff72] hover:bg-[#47ff72] hover:text-slate-900 transition-colors shrink-0`,children:[d.jsx(gD,{className:"w-5 h-5"}),d.jsx("span",{className:"hidden sm:inline text-sm font-medium",children:"Share"})]}),n&&d.jsx(Ai,{})]}),n&&d.jsxs("div",{className:"relative border-l border-slate-200 dark:border-slate-700 pl-3 ml-1 hidden md:block",children:[d.jsx("button",{onClick:()=>{p(!1),o(!a)},className:"flex items-center gap-2 focus:outline-none",children:d.jsx("img",{src:n.picture,alt:"Profile",className:"w-9 h-9 rounded-full border-2 border-brand-500 shadow-sm hover:scale-105 transition-transform object-cover"})}),a&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1)}),d.jsxs("div",{className:"absolute right-0 top-12 mt-2 w-64 bg-white dark:bg-slate-900 rounded-xl shadow-xl border border-slate-200 dark:border-slate-700 z-50 overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:[d.jsxs("div",{className:"p-4 border-b border-slate-100 dark:border-slate-800 flex items-center gap-3",children:[d.jsx("img",{src:n.picture,alt:"Profile",className:"w-10 h-10 rounded-full border border-slate-200 dark:border-slate-700"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("h4",{className:"font-bold text-sm text-slate-800 dark:text-white truncate",children:n.name}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 truncate",children:n.email})]})]}),d.jsxs("div",{className:"px-3 py-2 mx-2 mt-2 rounded-lg bg-[#47ff72]/10 border border-[#47ff72]/20",children:[d.jsx("span",{className:"text-xs font-bold text-[#47ff72]",children:wI(n.plan??"free")}),d.jsxs("p",{className:"text-[10px] text-slate-500 dark:text-slate-400 mt-1",children:["Batch limit: ",fve(MF(n))," files"]})]}),ni&&d.jsx(pn,{onNavigate:()=>o(!1)}),d.jsx(Va,{onSelect:()=>o(!1)}),d.jsx("div",{className:"p-2",children:d.jsxs("button",{onClick:ir,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors",children:[d.jsx(qN,{className:"w-4 h-4"}),"Sign Out"]})})]})]})]}),d.jsxs("div",{className:"md:hidden flex items-center gap-2",children:[n&&d.jsx(Ai,{}),d.jsx("button",{onClick:()=>{p(!1),y(!m)},className:"p-2 text-slate-500 hover:text-[#47ff72] dark:text-slate-400 dark:hover:text-[#47ff72] transition-colors",children:d.jsx(nJ,{className:"w-6 h-6"})})]})]})]}),m&&d.jsx("div",{className:"md:hidden absolute top-16 left-0 right-0 bg-white dark:bg-slate-900 border-b border-slate-200 dark:border-slate-800 shadow-xl z-50 animate-in slide-in-from-top duration-300",children:d.jsxs("div",{className:"p-4 space-y-4",children:[n&&d.jsxs("div",{className:"p-3 bg-slate-50 dark:bg-slate-800/50 rounded-xl space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("img",{src:n.picture,alt:"Profile",className:"w-10 h-10 rounded-full border-2 border-brand-500"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("h4",{className:"font-bold text-sm text-slate-800 dark:text-white truncate",children:n.name}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 truncate",children:n.email})]}),d.jsx("button",{onClick:ir,className:"p-2 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg",children:d.jsx(qN,{className:"w-5 h-5"})})]}),d.jsx("div",{className:"px-1",children:d.jsx("span",{className:"text-xs font-bold text-[#47ff72]",children:wI(n.plan??"free")})}),ni&&d.jsx(pn,{onNavigate:()=>y(!1)}),d.jsx(Va,{onSelect:()=>y(!1)})]}),!n&&d.jsx(Va,{onSelect:()=>y(!1)}),d.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[d.jsx("button",{onClick:()=>{ie("metadata"),y(!1)},className:`flex items-center justify-center gap-2 p-2.5 rounded-xl font-medium text-xs ${ce==="metadata"?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-50 dark:bg-slate-800/50 text-slate-600 dar
7175k:text-slate-300"}`,children:"Metadata"}),d.jsx("button",{onClick:()=>{ie("background"),y(!1)},className:`flex items-center justify-center gap-2 p-2.5 rounded-xl font-medium text-xs ${ce==="background"?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-50 dark:bg-slate-800/50 text-slate-600 dark:text-slate-300"}`,children:"Background"}),d.jsx("button",{onClick:()=>{ie("upscale"),y(!1)},className:`flex items-center justify-center gap-2 p-2.5 rounded-xl font-medium text-xs ${ce==="upscale"?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-50 dark:bg-slate-800/50 text-slate-600 dark:text-slate-300"}`,children:"Upscaler"}),d.jsx("button",{onClick:()=>{ie("bento"),y(!1)},className:`flex items-center justify-center gap-2 p-2.5 rounded-xl font-medium text-xs ${ce==="bento"?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-50 dark:bg-slate-800/50 text-slate-600 dark:text-slate-300"}`,children:"Bento"}),d.jsx("button",{onClick:()=>{ie("vector"),y(!1)},className:`flex items-center justify-center gap-2 p-2.5 rounded-xl font-medium text-xs ${ce==="vector"?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-50 dark:bg-slate-800/50 text-slate-600 dark:text-slate-300"}`,children:"Vector"}),d.jsx("button",{onClick:()=>{ie("color"),y(!1)},className:`flex items-center justify-center gap-2 p-2.5 rounded-xl font-medium text-xs ${ce==="color"?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-50 dark:bg-slate-800/50 text-slate-600 dark:text-slate-300"}`,children:"Colors"})]}),d.jsxs("div",{className:`grid gap-2 ${ce==="metadata"?"grid-cols-2":"grid-cols-1"}`,children:[d.jsxs("button",{onClick:()=>{Qt(!0),y(!1)},className:"flex items-center justify-center gap-2 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-xl text-slate-600 dark:text-slate-300 font-medium",children:[d.jsx(GN,{className:"w-5 h-5"})," Guide"]}),ce==="metadata"&&d.jsxs("button",{onClick:()=>{n&&ms(!0),y(!1)},className:"flex items-center justify-center gap-2 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-xl text-slate-600 dark:text-slate-300 font-medium disabled:opacity-50 relative",disabled:!n,children:[d.jsx(FF,{className:"w-5 h-5"}),d.jsx("span",{children:"Settings"}),n&&Le.length===0&&d.jsx(S0,{className:"w-4 h-4 text-red-500 fill-red-500/10 animate-pulse"})]})]}),!n&&d.jsxs("button",{onClick:ot,className:"flex items-center justify-center gap-2 w-full p-3 border border-[#47ff72] text-[#47ff72] hover:bg-[#47ff72] hover:text-slate-900 rounded-xl font-bold transition-colors mb-2",children:[d.jsx(gE,{className:"w-5 h-5"}),d.jsx("span",{children:"Sign in with Google"})]}),d.jsxs("a",{href:"https://chromewebstore.google.com/detail/foliaahbfnegnbmclfomfeamfkmnncjm",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full p-3 bg-slate-100 dark:bg-slate-800/50 text-slate-800 dark:text-slate-200 border border-slate-200 dark:border-slate-700 hover:border-[#47ff72] rounded-xl font-bold transition-colors",children:[d.jsx("img",{src:"https://upload.wikimedia.org/wikipedia/commons/e/e1/Google_Chrome_icon_%28February_2022%29.svg",alt:"Chrome",className:"w-5 h-5"})," Get Chrome Extension"]}),d.jsxs("a",{href:"https://t.me/csvmeta",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full p-3 bg-blue-500 text-white rounded-xl font-bold transition-colors",children:[d.jsx(Ed,{className:"w-5 h-5"})," Find Us on Telegram"]}),d.jsxs("button",{onClick:()=>{yn(!0),y(!1)},className:"flex items-center justify-center gap-2 w-full p-3 border border-[#47ff72] text-[#47ff72] rounded-xl font-bold transition-colors",children:[d.jsx(gD,{className:"w-5 h-5"})," Share App"]})]})})]}),l&&d.jsx(dJ,{banner:l,onDismiss:()=>c(null)}),d.jsxs("div",{className:"flex w-full relative flex-1 min-h-0",children:[n&&d.jsx(FTe,{isOpen:v,setIsOpen:b,activeTool:ce,setActiveTool:ie}),d.jsxs("div",{className:"flex-1 flex flex-col transition-all duration-300 min-w-0",children:[d.jsx("div",{style:{display:ce==="metadata"||!n?"block":"none",flex:1},children:d.jsxs("main",{className:`flex-1 w-full ${n?"max-w-[1600px] w-[96%] mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-8":""}`,children:[n&&d.jsxs("div",{className:"text-center space-y-4 mb-8",children:[d.jsx("h2",{className:"text-3xl font-bold text-[#47ff72]",children:"Metadata and Prompt Generator"}
7175),d.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-sm sm:text-base max-w-2xl mx-auto",children:"Generate metadata or reverse-engineer image prompts with AI."})]}),n?d.jsxs("div",{className:"flex flex-col xl:flex-row gap-8 items-start",children:[d.jsxs("div",{className:"w-full xl:w-1/3 flex flex-col xl:sticky xl:top-32 xl:max-h-[calc(100vh-12rem)]",children:[d.jsx("h2",{className:"text-[#47ff72] font-bold text-sm tracking-widest uppercase mb-4 pl-1",children:"CONFIGURATION"}),d.jsxs("div",{className:"flex flex-col gap-6 overflow-y-auto custom-scrollbar pr-2 pb-4 h-full",children:[d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-xl p-6 shadow-sm border border-slate-200 dark:border-slate-700 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[d.jsxs("h3",{className:"text-lg font-semibold mb-4 text-slate-800 dark:text-white flex items-center gap-2",children:[d.jsx(aJ,{className:"w-5 h-5 text-[#47ff72]"})," Generation Mode"]}),d.jsxs("div",{className:"flex bg-slate-100 dark:bg-slate-900 p-1 rounded-xl",children:[d.jsx("button",{onClick:()=>Re(Ti.METADATA),className:`flex-1 py-3 rounded-lg text-base font-bold transition-all ${de===Ti.METADATA?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Stock Metadata"}),d.jsx("button",{onClick:()=>Re(Ti.PROMPT),className:`flex-1 py-3 rounded-lg text-base font-bold transition-all ${de===Ti.PROMPT?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Image-to-Prompt"})]})]}),d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-xl p-6 shadow-sm border border-slate-200 dark:border-slate-700 animate-in fade-in slide-in-from-bottom-6 duration-500",children:[d.jsxs("h3",{className:"text-lg font-semibold mb-6 text-slate-800 dark:text-white flex items-center gap-2",children:[d.jsx(Z0,{className:"w-5 h-5 text-[#47ff72]"})," Generation Settings"]}),d.jsxs("div",{className:"flex flex-col gap-6",children:[de===Ti.METADATA?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-3 pb-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-200",children:[d.jsx(Sd,{className:"w-4 h-4 text-[#47ff72]"})," ",d.jsx("label",{children:"Platform"})]}),d.jsxs("div",{className:"flex flex-col md:flex-row bg-slate-100 dark:bg-slate-900 p-1 rounded-xl gap-1 md:gap-0",children:[d.jsx("button",{onClick:()=>zt(jr.ADOBE_STOCK),className:`w-full md:flex-1 py-2.5 md:py-2 rounded-lg text-sm font-bold transition-all text-center ${wt===jr.ADOBE_STOCK?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Adobe Stock"}),d.jsx("button",{onClick:()=>zt(jr.SHUTTERSTOCK),className:`w-full md:flex-1 py-2.5 md:py-2 rounded-lg text-sm font-bold transition-all text-center ${wt===jr.SHUTTERSTOCK?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Shutterstock"}),d.jsx("button",{onClick:()=>zt(jr.FREEPIK),className:`w-full md:flex-1 py-2.5 md:py-2 rounded-lg text-sm font-bold transition-all text-center ${wt===jr.FREEPIK?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Magnific(formerly Freepik)"})]})]}),d.jsxs("div",{className:"space-y-3 pb-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-200",children:[d.jsx(mE,{className:"w-4 h-4 text-[#47ff72]"})," ",d.jsx("label",{children:"Output Format"})]}),d.jsxs("div",{className:"flex bg-slate-100 dark:bg-slate-900 p-1 rounded-xl",children:[d.jsx("button",{onClick:()=>De(_h.CSV),className:`flex-1 py-2 rounded-lg text-sm font-bold transition-all ${Se===_h.CSV?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Generate CSV"}),d.jsx("button",{onClick:()=>De(_h.EMBED),className:`flex-1 py-2 rounded-lg text-sm font-bold transition-all ${Se===_h.EMBED?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Embed Metadata"})]})]}),Se===_h.EMBED&&d.jsxs("div",{className:"space-y-3 pb-2",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700 rounded-xl",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:`p-2 rounded-lg ${gt?"bg-[#47ff72]/20 text-[#47ff72]":"bg-slate-200 dark:bg-slate-700 text-slate-500"}`,children:d.jsx(mD,{className:"w-5 h-5"})}),d.jsxs("div",{children:[d.jsx("h4",{className:"text-sm font-bold text-slate-800 dark:text-white",children:"Rename Files"}),d.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:["Rename files based on generated ",wt===jr.SHUTTERSTOCK?"de
7175scription":"title"]})]})]}),d.jsx("button",{onClick:()=>yt(!gt),className:`p-1 rounded-full transition-colors flex-shrink-0 ${gt?"text-[#47ff72]":"text-slate-400 dark:text-slate-600"}`,title:gt?"Disable Rename Files":"Enable Rename Files",children:gt?d.jsx(D2,{className:"w-9 h-9"}):d.jsx($2,{className:"w-9 h-9"})})]}),gt&&d.jsxs("div",{className:"space-y-3 mt-3",children:[d.jsx("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-200",children:d.jsx("label",{children:"Word Separator"})}),d.jsxs("div",{className:"flex bg-slate-100 dark:bg-slate-900 p-1 rounded-xl",children:[d.jsx("button",{onClick:()=>Nt(" "),className:`flex-1 py-2 rounded-lg text-sm font-bold transition-all ${xt===" "?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Space ( )"}),d.jsx("button",{onClick:()=>Nt("-"),className:`flex-1 py-2 rounded-lg text-sm font-bold transition-all ${xt==="-"?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Hyphen (-)"}),d.jsx("button",{onClick:()=>Nt("_"),className:`flex-1 py-2 rounded-lg text-sm font-bold transition-all ${xt==="_"?"bg-white dark:bg-slate-700 shadow-md text-[#47ff72]":"text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,children:"Underscore (_)"})]})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex justify-between items-center text-sm font-medium",children:[d.jsx("label",{className:"text-slate-700 dark:text-slate-200",children:wt===jr.SHUTTERSTOCK?"Description Length (Max)":"Title Length (Max)"}),d.jsxs("span",{className:"text-[#47ff72]",children:[_n," Characters"]})]}),d.jsx("input",{type:"range",min:"50",max:wt===jr.FREEPIK?100:200,step:"5",value:_n,onChange:Ye=>Zt(parseInt(Ye.target.value)),className:"w-full h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex justify-between items-center text-sm font-medium",children:[d.jsx("label",{className:"text-slate-700 dark:text-slate-200",children:"Keywords Count"}),d.jsxs("span",{className:"text-[#47ff72]",children:[J," Keywords"]})]}),d.jsx("input",{type:"range",min:"5",max:"50",step:"1",value:J,onChange:Ye=>We(parseInt(Ye.target.value)),className:"w-full h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"})]}),d.jsx("div",{className:"pt-2 pb-1 border-t border-dashed border-slate-200 dark:border-slate-700",children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-200",children:[d.jsx(Sd,{className:"w-4 h-4 text-[#47ff72]"}),d.jsx("label",{children:"Seamless Generation"})]}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 max-w-sm",children:"Auto-generate categories for both Adobe Stock & Shutterstock simultaneously. Switch platforms instantly without regenerating."})]}),d.jsx("button",{onClick:()=>pt(!Mt),className:`p-1 rounded-full transition-colors flex-shrink-0 ${Mt?"text-[#47ff72]":"text-slate-400 dark:text-slate-600"}`,title:Mt?"Disable Seamless Mode":"Enable Seamless Mode",children:Mt?d.jsx(D2,{className:"w-9 h-9"}):d.jsx($2,{className:"w-9 h-9"})})]})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex justify-between items-center text-sm font-medium",children:[d.jsx("label",{className:"text-slate-700 dark:text-slate-200",children:"Prompt Length (Max)"}),d.jsxs("span",{className:"text-[#47ff72]",children:[Ie," Characters"]})]}),d.jsx("input",{type:"range",min:"50",max:"600",step:"10",value:Ie,onChange:Ye=>ge(parseInt(Ye.target.value)),className:"w-full h-2 bg-slate-200 dark:bg-slate-700 rounded-lg appearance-none cursor-pointer accent-[#47ff72]"}),d.jsx("p",{className:"text-xs text-slate-500 mt-2",children:"Adjust the descriptive richness of the generated prompt (50 - 600 characters)."})]}),d.jsxs("div",{className:"space-y-3 pt-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-200",children:[d.jsx(mp,{className:"w-4 h-4 text-[#47ff72]"})," ",d.jsx("label",{children:"Style"})]}),d.jsxs("div",{className:"flex flex-wrap items-center gap-8 p-4 bg-slate-50 dark:bg-slate-900/50 rounded-xl border border-slate-100 dar
7175k:border-slate-700/50",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-200 cursor-pointer",onClick:()=>nt(!et),children:"Silhouette"}),d.jsx("button",{onClick:()=>nt(!et),className:`p-1 rounded-full transition-colors ${et?"text-[#47ff72]":"text-slate-400 dark:text-slate-600"}`,children:et?d.jsx(D2,{className:"w-9 h-9"}):d.jsx($2,{className:"w-9 h-9"})})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-200 cursor-pointer",onClick:()=>ft(!He),children:"Icon"}),d.jsx("button",{onClick:()=>ft(!He),className:`p-1 rounded-full transition-colors ${He?"text-[#47ff72]":"text-slate-400 dark:text-slate-600"}`,children:He?d.jsx(D2,{className:"w-9 h-9"}):d.jsx($2,{className:"w-9 h-9"})})]})]})]})]}),d.jsxs("div",{className:"space-y-3 pt-4 border-t border-slate-100 dark:border-slate-700",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-200",children:[d.jsx(sJ,{className:"w-4 h-4 text-[#47ff72]"}),d.jsx("label",{children:"Refiner Prompt"})]}),d.jsx("button",{onClick:()=>hn(!Oe),className:`p-1 rounded-full transition-colors ${Oe?"text-[#47ff72]":"text-slate-400 dark:text-slate-600"}`,children:Oe?d.jsx(D2,{className:"w-9 h-9"}):d.jsx($2,{className:"w-9 h-9"})})]}),Oe&&d.jsx("div",{className:"p-4 bg-slate-50 dark:bg-slate-900/50 rounded-xl border border-slate-100 dark:border-slate-700/50 space-y-4 animate-in fade-in slide-in-from-top-2",children:tn?d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"Label Name"}),d.jsx("input",{type:"text",value:ht,onChange:Ye=>Dt(Ye.target.value),placeholder:"e.g. My Cinematic Style",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-600 rounded-lg dark:bg-slate-800 dark:text-white outline-none focus:ring-1 focus:ring-brand-500",maxLength:30})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"Custom Instruction"}),d.jsxs("div",{className:"relative",children:[d.jsx("textarea",{rows:4,value:Ut,onChange:Ye=>Lt(Ye.target.value),placeholder:"Enter your specific instructions for the AI... (e.g. 'Use concise single words, avoid colors')",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-600 rounded-lg dark:bg-slate-800 dark:text-white outline-none focus:ring-1 focus:ring-brand-500 resize-y pr-10"}),Ut.trim().length>0&&d.jsx("button",{onClick:$e,disabled:Wt,className:"absolute bottom-2 right-2 p-2 bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 rounded-lg transition-all disabled:opacity-70 disabled:cursor-wait animate-in fade-in zoom-in duration-200",title:"Enhance with AI",children:Wt?d.jsx(Go,{className:"w-4 h-4 animate-spin"}):d.jsx(mp,{className:"w-4 h-4"})})]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{onClick:Pe,disabled:!ht||!Ut,className:"flex-1 py-2 bg-brand-500 hover:bg-brand-600 text-slate-900 rounded-lg text-sm font-bold disabled:opacity-50 transition-colors",children:"Save Prompt"}),d.jsx("button",{onClick:()=>je(!1),className:"px-4 py-2 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300 rounded-lg text-sm font-bold hover:bg-slate-300 dark:hover:bg-slate-600 transition-colors",children:"Cancel"})]})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[Yt.map(Ye=>d.jsxs("div",{className:"flex items-center gap-3 p-3 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700 hover:border-brand-300 dark:hover:border-brand-700 transition-colors",children:[d.jsx("button",{onClick:()=>or(Ye.id),className:`w-5 h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${Ye.isActive?"border-[#47ff72]":"border-slate-300 dark:border-slate-600"}`,children:Ye.isActive&&d.jsx("div",{className:"w-2.5 h-2.5 bg-[#47ff72] rounded-full"})}),d.jsxs("div",{className:"flex-1 min-w-0",onClick:()=>or(Ye.id),children:[d.jsx("h4",{className:"font-bold text-sm text-slate-800 dark:text-white truncate",children:Ye.label}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 truncate",children:Ye.content})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:()=>pe(Ye),className:"p-1.5 text-slate-400 hover:text-brand-500 rounded",children:d.jsx(mD,{className:"w-4 h-4"})}),d.jsx("button",{onClick:()=>ue(Ye.id),className:"p-1.5 text-slate-400 hover:text-red-500 rounded",children:d.jsx(xl,{className:"w-4 h-4"})})]})]},Ye.id)),Yt.length===0&&d.jsx("div",{className:"text-center p-4 text-sm text-slate-400",children:"No custom prompts saved. Add one below."})]}),Yt.length<5&&d.jsxs("button",{onClick:ke,className:"w-full py-2 flex items-center justify-center gap-2 border border-dashed border-slate-300 dark:border-slate-600 rounded-lg text-slate-500 hover:text-brand-500 hover:border-brand-300 hover:bg-slate-100 dar
7175k:hover:bg-slate-800 transition-all text-sm font-medium",children:[d.jsx(Tv,{className:"w-4 h-4"})," Add New Prompt"]})]})})]})]}),d.jsx("div",{className:"mt-8 pt-6 border-t border-slate-100 dark:border-slate-700",children:d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-200",children:[yr(kn),d.jsxs("label",{children:["AI Model (",_a(kn),")"]})]}),kn==="gemini"?d.jsxs("select",{value:he,onChange:Ye=>Ae(Ye.target.value),className:"w-full px-4 py-2.5 rounded-lg border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900 text-slate-800 dark:text-white focus:ring-2 focus:ring-[#47ff72] outline-none",children:[d.jsx("option",{value:B,children:"Gemini 3.6 Flash"}),d.jsx("option",{value:G,children:"Gemini 3.5 Flash Lite"}),d.jsx("option",{value:X,children:"Gemini 3.1 Flash Lite (Fast & Efficient)"}),d.jsx("option",{value:H,children:"Gemini 2.5 Flash Lite (Fallback)"}),d.jsx("option",{value:Y,children:"Gemini 2.5 Flash (Highest Quality)"})]}):kn==="groq"?d.jsx("select",{value:he,onChange:Ye=>Ae(Ye.target.value),className:"w-full px-4 py-2.5 rounded-lg border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900 text-slate-800 dark:text-white focus:ring-2 focus:ring-[#47ff72] outline-none",children:d.jsx("option",{value:we,children:"Llama 4 Scout (Fast)"})}):d.jsxs("select",{value:he,onChange:Ye=>Ae(Ye.target.value),className:"w-full px-4 py-2.5 rounded-lg border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900 text-slate-800 dark:text-white focus:ring-2 focus:ring-[#47ff72] outline-none",children:[d.jsx("option",{value:xe,children:"Mistral Medium 3.1 (Stable)"}),d.jsx("option",{value:me,children:"Mistral Large 3 (High Quality Text)"})]})]})})]})]})]}),d.jsxs("div",{className:"w-full xl:w-2/3 flex flex-col gap-6",children:[de===Ti.PROMPT&&d.jsxs("div",{className:"animate-in fade-in slide-in-from-bottom-8 duration-500 mb-6 bg-white dark:bg-slate-800 rounded-2xl p-6 shadow-sm border border-slate-200 dark:border-slate-700",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[d.jsx(YL,{className:"w-5 h-5 text-[#47ff72]"}),d.jsx("h3",{className:"text-lg font-bold text-slate-800 dark:text-white",children:"Input Image URL"})]}),d.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[d.jsx("textarea",{value:ln,onChange:Ye=>ns(Ye.target.value),placeholder:"Paste image URLs here (one per line)...",className:"flex-1 min-h-[80px] px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900 text-slate-800 dark:text-white focus:ring-2 focus:ring-[#47ff72] outline-none resize-y",disabled:Js}),d.jsxs("button",{onClick:Ne,disabled:Js||!ln.trim(),className:"sm:w-auto w-full flex items-center justify-center gap-2 px-6 py-3 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 rounded-xl font-bold transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[Js?d.jsx(Go,{className:"w-5 h-5 animate-spin"}):d.jsx(Ua,{className:"w-5 h-5"}),d.jsx("span",{children:"Enter"})]})]})]}),d.jsx("div",{className:"animate-in fade-in slide-in-from-bottom-8 duration-500 flex flex-col min-h-[200px]",children:d.jsx(STe,{onFilesDropped:tt,generationMode:de,className:"flex-1 py-8"})}),Jt&&d.jsxs("div",{className:"mt-2 mb-4 p-4 bg-amber-50 dark:bg-amber-900/30 border border-amber-200 dark:border-amber-700/50 rounded-xl flex items-center gap-3 text-amber-800 dark:text-amber-200 animate-in fade-in slide-in-from-top-2 shadow-sm",children:[d.jsx(S0,{className:"w-5 h-5 flex-shrink-0"}),d.jsx("p",{className:"text-sm font-medium",children:Jt}),d.jsx("button",{onClick:()=>Kn(null),className:"ml-auto hover:bg-amber-100 dark:hover:bg-amber-800/50 p-1 rounded-lg transition-colors",children:d.jsx(Ki,{className:"w-4 h-4"})})]}),t.length>0&&d.jsx("div",{className:"flex flex-col items-center justify-center space-y-2 py-4",children:d.jsx("div",{className:"flex gap-4",children:gs?d.jsxs("button",{onClick:()=>us(!1),className:"flex items-center gap-3 px-8 py-3 bg-red-500 hover:bg-red-600 text-white rounded-full font-semibold shadow-lg transition-all hover:scale-105 active:scale-95",children:[d.jsx(ZL,{className:"w-4 h-4 fill-current"}),d.jsx("span",{children:"Stop Processing"})]}):d.jsx(d.Fragment,{children:Ft.length>0?d.jsxs("button",{onClick:qn,className:"flex items-center gap-3 px-8 py-3 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 rounded-full font-bold shadow-lg transition-all hover:scale-105 active:scale-95",children:[d.jsx(F1,{className:"w-5 h-5 fill-current"}),d.jsxs("span",{children:["Process Files (",Ft.length,")"]})]}):Cr>0?d.jsxs("button",{onClick:Xn,className:"flex items-center gap-3 px-8 py-3 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 rounded-full font-bold shadow-lg transition-all hover:scale-105 active:scale-95",children:[d.jsx(Cv,{className:"w-5 h-5"}),d.jsxs("span",{children:["Regenerate Failed (",Cr,")"]})]}):null})})}),t.length>0&&d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[d.jsxs("div",{className:"flex items-center gap-4 text-sm text-slate-500 dark:text-slate-400",children:[d.jsxs("span",{children:["Total: ",t.length]}),d.jsxs("span",{className:"text-green-600 dark:text-[#47ff72]",children:["Completed: ",Gs]}),d.jsxs("span",{className:"text-slate-500 dark:text-slate-400",children:["Remaining: ",Qs]}),Ps&&d.jsxs("span",{className:"text-brand-500 font-bold",children:["Selected: ",ws.size]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[Ps?d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:()=>{rr(!1),$s(new Set)},className:gi,children:[d.jsx(Ki,{className:"w-4 h-4"}),"Cancel"]}),d.jsxs("button",{onClick:Jn,disabled:ws.size===0||!ti,className:"flex items-center gap-2 px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-slate-900 text-xs font-bold uppercase rounded-lg transition-colors disabled:opacity-50",children:[d.jsx(Cv,{className:"w-4 h-4"}),"Regenerate (",ws.size,")"]}),d.jsxs("button",{onClick:()=>{e(Ye=>
7175Ye.filter(vt=>!ws.has(vt.id))),$s(new Set),t.length===ws.size&&rr(!1)},disabled:ws.size===0,className:"flex items-center gap-2 px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white text-xs font-bold uppercase rounded-lg transition-colors disabled:opacity-50",children:[d.jsx(xl,{className:"w-4 h-4"}),"Delete (",ws.size,")"]})]}):d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:()=>rr(!0),className:gi,children:[d.jsx(xd,{className:"w-4 h-4"}),"Select Items"]}),d.jsxs("button",{onClick:kt,className:`flex items-center gap-2 px-3 py-1.5 text-xs font-bold uppercase rounded-lg transition-colors border ${Hn?"bg-red-500 text-white":"bg-red-500/10 text-red-500 border-red-500/20"}`,children:[d.jsx(xl,{className:"w-4 h-4"}),Hn?"Confirm Clear":"Clear All"]})]}),d.jsxs("button",{onClick:Qn,className:"flex items-center gap-2 px-3 py-1.5 bg-slate-900 dark:bg-slate-700 hover:bg-slate-800 text-white text-xs font-bold uppercase rounded-lg transition-colors disabled:opacity-50",disabled:Gs===0,children:[de===Ti.METADATA?d.jsx(Ua,{className:"w-4 h-4"}):d.jsx(mE,{className:"w-4 h-4"}),de===Ti.METADATA?Se===_h.EMBED?"Export Embedded files":"Export CSV":"Export Prompts"]})]})]}),d.jsx("div",{className:"w-full bg-slate-200 dark:bg-slate-700 rounded-full h-3 overflow-hidden shadow-inner",children:d.jsx("div",{className:"bg-[#47ff72] h-full rounded-full transition-all duration-500 ease-out",style:{width:`${Gs/t.length*100}%`}})})]}),t.length>0&&d.jsx("div",{ref:ys,className:"rounded-xl overflow-y-auto max-h-[600px] border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/30 p-4",children:d.jsx(TTe,{assets:t,onDelete:Ct,onRegenerate:_t,onUpdateMetadata:Xt,isSelectionMode:Ps,selectedIds:ws,onToggleSelection:an,generationMode:de,platform:wt})})]})]}):d.jsx("div",{className:"flex items-center justify-center h-[60vh]",children:d.jsx(Go,{className:"w-10 h-10 text-[#47ff72] animate-spin"})})]})}),n&&ce==="background"&&d.jsx("div",{className:"flex-1 min-w-0",children:d.jsx(QTe,{})}),n&&ce==="upscale"&&d.jsx("div",{className:"flex-1 min-w-0",children:d.jsx(ICe,{})}),n&&ce==="bento"&&d.jsx("div",{className:"flex-1 min-w-0",children:d.jsx(OCe,{})}
7175),n&&ce==="vector"&&d.jsx("div",{className:"flex-1 min-w-0 w-full flex flex-col min-h-0",children:d.jsx(mNe,{})}),n&&ce==="color"&&d.jsx("div",{className:"flex-1 min-w-0",children:d.jsx(jNe,{})})]})]}),d.jsx("footer",{className:"w-full py-6 mt-auto border-t border-slate-200 dark:border-slate-800 bg-white dark:bg-green-950/30 text-center transition-colors duration-300",children:d.jsxs("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:["Copyright ",new Date().getFullYear()," ",d.jsx("span",{className:"text-[#47ff72]",children:"CSV Meta"})," | All rights reserved | ",d.jsx(Is,{to:"/privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Privacy Policy"})," | ",d.jsx(Is,{to:"/terms-of-service",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Terms of Service"})," | ",d.jsx(Is,{to:"/promptgen-privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"PromptGen Privacy Policy"})]})})]})},yLe=()=>{const[t,e]=q.useState("introduction");q.useEffect(()=>{const r=()=>{const i=["introduction","information-we-use","third-party-services","data-collection","policy-changes","contact-us"],a=window.scrollY+100;for(const o of i){const l=document.getElementById(o);if(l&&l.offsetTop<=a&&l.offsetTop+l.offsetHeight>a){e(o);break}}};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=[{id:"introduction",label:"Introduction",icon:iJ},{id:"information-we-use",label:"Information We Use",icon:Yh},{id:"third-party-services",label:"Third-Party Services",icon:WN},{id:"data-collection",label:"Data Collection",icon:j1},{id:"policy-changes",label:"Policy Changes",icon:Av},{id:"contact-us",label:"Contact Us",icon:B1}],s=r=>{const i=document.getElementById(r);i&&(window.scrollTo({top:i.offsetTop-80,behavior:"smooth"}),window.history.pushState(null,"",`#${r}`),e(r))};return d.jsxs("div",{className:"min-h-screen bg-[#011f08] flex flex-col font-sans text-slate-300",children:[d.jsx(V0,{}),d.jsx("main",{className:"flex-1 max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:d.jsxs("div",{className:"flex flex-col md:flex-row gap-12",children:[d.jsx("aside",{className:"md:w-64 flex-shrink-0",children:d.jsxs("div",{className:"sticky top-24 space-y-1",children:[d.jsx("h2",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest px-4 mb-4",children:"Contents"}),n.map(r=>d.jsxs("button",{onClick:()=>s(r.id),className:`w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-xl transition-all ${t===r.id?"bg-[#47ff72]/10 text-[#47ff72] border-r-4 border-[#47ff72]":"text-slate-400 hover:bg-white/5 hover:text-slate-200"}`,children:[d.jsx(r.icon,{className:"w-4 h-4"}),r.label]},r.id))]})}),d.jsxs("div",{className:"flex-1 space-y-16",children:[d.jsxs("section",{id:"introduction",children:[d.jsx("h1",{className:"text-4xl font-extrabold text-white mb-6",children:"Privacy Policy"}),d.jsxs("div",{className:"prose prose-invert max-w-none space-y-4",children:[d.jsx("p",{className:"text-lg leading-relaxed",children:"Welcome to CSV Meta. Your privacy is paramount to us. This policy describes how our application collects, uses, and safeguards your information when you use our AI-powered metadata generation tools."}),d.jsx("p",{className:"leading-relaxed",children:"By accessing or using CSV Meta, you signify that you have read, understood, and agree to our collection, storage, use, and disclosure of your personal information as described in this Privacy Policy."})]})]}),d.jsxs("section",{id:"information-we-use",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(Yh,{className:"w-6 h-6"})," Information We Use"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"We only use the minimum amount of data required to provide our service:"}),d.jsxs("ul",{className:"list-disc pl-6 space-y-3",children:[d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Uploaded Assets:"})," Images, videos, and vector files you upload for analysis. These are processed locally in your browser to generate descriptions and are only sent to the AI API (Gemini or Groq) for high-level analysis. We do not store these files on our servers."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"API Keys:"})," If you provide your own API Keys, they are stored securely in your browser's local storage and are never transmitted to us."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"User Preferences:"})," Settings such as preferred AI model, platform choice (Adobe vs Shutterstock), and character limits are stored locally."]})]})]})]}),d.jsxs("section",{id:"third-party-services",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(WN,{className:"w-6 h-6"})," Third-Party Services"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"CSV Meta integrates with the following third-party services to function:"}),d.jsxs("ul",{className:"list-disc pl-6 space-y-3",children:[d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Google Gemini API:"})," Used for visual content analysis and metadata generation."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Groq API:"})," An alternative provider for inference processing by GroqCloud."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Mistral API:"})," An alternative provider for inference processing by Mistral AI."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Google Identity Services:"})," Used for secure authentication and login management."]})]}),d.jsx("p",{className:"text-sm text-slate-500",children:"Please note that these services have their own privacy policies governing how they handle data sent to their APIs."})]})]}),d.jsxs("section",{id:"data-collection",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(j1,{className:"w-6 h-6"})," Data Collection & Storage"]}),d.jsxs("div",{className:"bg-white/5 border border-slate-800 rounded-2xl p-6 space-y-4",children:[d.jsx("p",{className:"font-bold text-white uppercase tracking-wider text-xs",children:"Our C
7175ommitment"}),d.jsxs("p",{className:"text-lg",children:["CSV Meta follows a ",d.jsx("span",{className:"text-[#47ff72]",children:"Local-First"})," data philosophy."]}),d.jsxs("ul",{className:"space-y-4",children:[d.jsxs("li",{className:"flex gap-4",children:[d.jsx("div",{className:"bg-[#47ff72]/20 p-2 rounded-lg h-fit text-[#47ff72]",children:d.jsx(xd,{className:"w-4 h-4"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-white font-medium",children:"No Persistent Server Storage"}),d.jsx("p",{className:"text-sm",children:"We do not store your original images, videos, or the generated CSV results on our backend servers."})]})]}),d.jsxs("li",{className:"flex gap-4",children:[d.jsx("div",{className:"bg-[#47ff72]/20 p-2 rounded-lg h-fit text-[#47ff72]",children:d.jsx(xd,{className:"w-4 h-4"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-white font-medium",children:"Local Browser Storage"}),d.jsx("p",{className:"text-sm",children:"Metadata and settings exist only in your current browser session. Clearing your browser data will remove this information."})]})]})]})]})]}),d.jsxs("section",{id:"policy-changes",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(Av,{className:"w-6 h-6"})," Policy Changes"]}),d.jsx("div",{className:"prose prose-invert max-w-none",children:d.jsx("p",{children:"We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page. You are advised to review this Privacy Policy periodically for any changes."})})]}),d.jsxs("section",{id:"contact-us",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(B1,{className:"w-6 h-6"})," Contact Us"]}),d.jsxs("div",{className:"bg-green-950/30 border border-green-900/50 rounded-2xl p-8 text-center space-y-4",children:[d.jsx("p",{className:"text-slate-200",children:"Have questions about your privacy or the security of CSV Meta?"}),d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsx("p",{className:"text-xs uppercase font-bold text-slate-500 tracking-widest",children:"Support Email"}),d.jsx("a",{href:"mailto:[email protected]",className:"text-2xl font-bold text-[#47ff72] hover:underline",children:"[email protected]"})]})]})]})]})]})}),d.jsx("footer",{className:"w-full py-12 mt-auto border-t border-slate-200 dark:border-slate-800 bg-white dark:bg-green-950/30 text-center transition-colors duration-300",children:d.jsxs("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:["Copyright ",new Date().getFullYear()," ",d.jsx("span",{className:"text-[#47ff72]",children:"CSV Meta"})," | All rights reserved | ",d.jsx(Is,{to:"/privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Privacy Policy"})," | ",d.jsx(Is,{to:"/terms-of-service",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Terms of Service"})," | ",d.jsx(Is,{to:"/promptgen-privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"PromptGen Privacy Policy"})]})})]})},xLe=()=>{const[t,e]=q.useState("introduction");q.useEffect(()=>{const r=()=>{const i=["introduction","service-description","accounts","acceptable-use","subscriptions","disclaimers","changes","contact-us"],a=window.scrollY+100;for(const o of i){const l=document.getElementById(o);if(l&&l.offsetTop<=a&&l.offsetTop+l.offsetHeight>a){e(o);break}}};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=[{id:"introduction",label:"Introduction",icon:mE},{id:"service-description",label:"Our Services",icon:UF},{id:"accounts",label:"Accounts",icon:GF},{id:"acceptable-use",label:"Acceptable Use",icon:nw},{id:"subscriptions",label:"Subscriptions",icon:DF},{id:"disclaimers",label:"Disclaimers",icon:S0},{id:"changes",label:"Changes",icon:Av},{id:"contact-us",label:"Contact Us",icon:B1}],s=r=>{const i=document.getElementById(r);i&&(window.scrollTo({top:i.offsetTop-80,behavior:"smooth"}),window.history.pushState(null,"",`#${r}`),e(r))};return d.jsxs("div",{className:"min-h-screen bg-[#011f08] flex flex-col font-sans text-slate-300",children:[d.jsx(V0,{}),d.jsx("main",{className:"flex-1 max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:d.jsxs("div",{className:"flex flex-col md:flex-row gap-12",children:[d.jsx("aside",{className:"md:w-64 flex-shrink-0",children:d.jsxs("div",{className:"sticky top-24 space-y-1",children:[d.jsx("h2",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest px-4 mb-4",children:"Contents"}),n.map(r=>d.jsxs("button",{onClick:()=>s(r.id),className:`w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-xl transition-all ${t===r.id?"bg-[#47ff72]/10 text-[#47ff72] border-r-4 border-[#47ff72]":"text-slate-400 hover:bg-white/5 hover:text-slate-200"}`,children:[d.jsx(r.icon,{className:"w-4 h-4"}),r.label]},r.id))]})}),d.jsxs("div",{className:"flex-1 space-y-16",children:[d.jsxs("section",{id:"introduction",children:[d.jsx("h1",{className:"text-4xl font-extrabold text-white mb-6",children:"Terms of Service"}),d.jsxs("div",{className:"prose prose-invert max-w-none space-y-4",children:[d.jsx("p",{className:"text-lg leading-relaxed",children:"Welcome to CSV Meta. These Terms of Service govern your access to and use of our website, tools, and related services for microstock creators."}),d.jsx("p",{className:"leading-relaxed",children:"By accessing or using CSV Meta, you agree to be bound by these Terms. If you do not agree, please do not use the service."})]})]}),d.jsxs("section",{id:"service-description",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(UF,{className:"w-6 h-6"})," Our Services"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"CSV Meta provides AI-assisted tools for microstock workflows, including metadata generation, background generation, image upscaling, bento layouts, vector tools, and color extraction."}),d.jsxs("ul",{className:"list-disc pl-6 space-y-3",children:[d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Output responsibility:"})," You are responsible for reviewing AI-generated titles, keywords, prompts, and other outputs before uploading them to stock platforms."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Availability:"})," We strive for reliable uptime but do not guarantee uninterrupted access. Features may change as we improve the product."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Third-party AI:"})," Some processing depends on external AI providers. Their availability and policies may affect your experience."]})]})]})]}),d.jsxs("section",{id:"accounts",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(GF,{className:"w-6 h-6"})," Accounts"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"To access certain features, you may 
7175need to create an account or sign in with a supported identity provider."}),d.jsxs("ul",{className:"list-disc pl-6 space-y-3",children:[d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Accuracy:"})," You agree to provide accurate account information and keep it up to date."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Security:"})," You are responsible for safeguarding your account credentials and for activity that occurs under your account."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Eligibility:"})," You must be able to form a binding contract under applicable law to use paid plans."]})]})]})]}),d.jsxs("section",{id:"acceptable-use",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(nw,{className:"w-6 h-6"})," Acceptable Use"]}),d.jsxs("div",{className:"bg-white/5 border border-slate-800 rounded-2xl p-6 space-y-4",children:[d.jsx("p",{className:"font-bold text-white uppercase tracking-wider text-xs",children:"You agree not to"}),d.jsxs("ul",{className:"space-y-4",children:[d.jsxs("li",{className:"flex gap-4",children:[d.jsx("div",{className:"bg-[#47ff72]/20 p-2 rounded-lg h-fit text-[#47ff72]",children:d.jsx(xd,{className:"w-4 h-4"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-white font-medium",children:"Abuse the service"}),d.jsx("p",{className:"text-sm",children:"Attempt to disrupt, reverse engineer, or overload CSV Meta, or bypass plan limits and security controls."})]})]}),d.jsxs("li",{className:"flex gap-4",children:[d.jsx("div",{className:"bg-[#47ff72]/20 p-2 rounded-lg h-fit text-[#47ff72]",children:d.jsx(xd,{className:"w-4 h-4"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-white font-medium",children:"Upload unlawful content"}),d.jsx("p",{className:"text-sm",children:"Use the tools with content you do not have rights to process, or for illegal, harmful, or infringing purposes."})]})]}),d.jsxs("li",{className:"flex gap-4",children:[d.jsx("div",{className:"bg-[#47ff72]/20 p-2 rounded-lg h-fit text-[#47ff72]",children:d.jsx(xd,{className:"w-4 h-4"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-white font-medium",children:"Misrepresent outputs"}),d.jsx("p",{className:"text-sm",children:"Present AI-generated metadata or media as platform-approved without your own review and compliance checks."})]})]})]})]})]}),d.jsxs("section",{id:"subscriptions",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(DF,{className:"w-6 h-6"})," Subscriptions & Payments"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"Paid plans unlock higher usage limits and additional features. Pricing and plan details are shown on our Pricing page."}),d.jsxs("ul",{className:"list-disc pl-6 space-y-3",children:[d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Billing:"})," Fees are charged according to the plan you select and the payment method available at checkout."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Renewals:"})," Paid plans are prepaid for a single billing period (typically 30 days) and do not auto-renew. When the period ends, your account reverts to the Free plan unless you purchase again."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Refunds:"})," CSVBucks(credits) are non-refundable and cannot be transferred to other users."]})]})]})]}),d.jsxs("section",{id:"disclaimers",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(S0,{className:"w-6 h-6"})," Disclaimers"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"CSV Meta is provided on an “as is” and “as available” basis. AI outputs may be incomplete, inaccurate, or unsuitable for a given stock platform. We do not warrant that generated content will be accepted by Adobe Stock, Shutterstock, Freepik, or any other marketplace."}),d.jsx("p",{children:"To the fullest extent permitted by law, CSV Meta and its operators are not liable for indirect, incidental, special, consequential, or punitive damages, or for lost profits, data, or business opportunities arising from your use of the service."})]})]}),d.jsxs("section",{id:"changes",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(Av,{className:"w-6 h-6"})," Changes"]}),d.jsx("div",{className:"prose prose-invert max-w-none",children:d.jsx("p",{children:"We may update these Terms of Service from time to time. Changes take effect when posted on this page. C
7175ontinued use of CSV Meta after an update means you accept the revised Terms. Please review this page periodically."})})]}),d.jsxs("section",{id:"contact-us",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(B1,{className:"w-6 h-6"})," Contact Us"]}),d.jsxs("div",{className:"bg-green-950/30 border border-green-900/50 rounded-2xl p-8 text-center space-y-4",children:[d.jsx("p",{className:"text-slate-200",children:"Questions about these Terms of Service?"}),d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsx("p",{className:"text-xs uppercase font-bold text-slate-500 tracking-widest",children:"Support Email"}),d.jsx("a",{href:"mailto:[email protected]",className:"text-2xl font-bold text-[#47ff72] hover:underline",children:"[email protected]"})]})]})]})]})]})}),d.jsx("footer",{className:"w-full py-12 mt-auto border-t border-slate-200 dark:border-slate-800 bg-white dark:bg-green-950/30 text-center transition-colors duration-300",children:d.jsxs("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:["Copyright ",new Date().getFullYear()," ",d.jsx("span",{className:"text-[#47ff72]",children:"CSV Meta"})," | All rights reserved |"," ",d.jsx(Is,{to:"/privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Privacy Policy"})," ","|"," ",d.jsx(Is,{to:"/terms-of-service",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Terms of Service"})," ","|"," ",d.jsx(Is,{to:"/promptgen-privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"PromptGen Privacy Policy"})]})})]})},vLe=()=>{const[t,e]=q.useState("introduction");q.useEffect(()=>{const r=()=>{const i=["introduction","information-we-use","third-party-services","data-collection","policy-changes","contact-us"],a=window.scrollY+100;for(const o of i){const l=document.getElementById(o);if(l&&l.offsetTop<=a&&l.offsetTop+l.offsetHeight>a){e(o);break}}};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=[{id:"introduction",label:"Introduction",icon:iJ},{id:"information-we-use",label:"Information We Use",icon:Yh},{id:"third-party-services",label:"Third-Party Services",icon:WN},{id:"data-collection",label:"Data Collection",icon:j1},{id:"policy-changes",label:"Policy Changes",icon:Av},{id:"contact-us",label:"Contact Us",icon:B1}],s=r=>{const i=document.getElementById(r);i&&(window.scrollTo({top:i.offsetTop-80,behavior:"smooth"}),window.history.pushState(null,"",`#${r}`),e(r))};return d.jsxs("div",{className:"min-h-screen bg-[#011f08] flex flex-col font-sans text-slate-300",children:[d.jsx(V0,{}),d.jsx("main",{className:"flex-1 max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:d.jsxs("div",{className:"flex flex-col md:flex-row gap-12",children:[d.jsx("aside",{className:"md:w-64 flex-shrink-0",children:d.jsxs("div",{className:"sticky top-24 space-y-1",children:[d.jsx("h2",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest px-4 mb-4",children:"Contents"}),n.map(r=>d.jsxs("button",{onClick:()=>s(r.id),className:`w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-xl transition-all ${t===r.id?"bg-[#47ff72]/10 text-[#47ff72] border-r-4 border-[#47ff72]":"text-slate-400 hover:bg-white/5 hover:text-slate-200"}`,children:[d.jsx(r.icon,{className:"w-4 h-4"}),r.label]},r.id))]})}),d.jsxs("div",{className:"flex-1 space-y-16",children:[d.jsxs("section",{id:"introduction",children:[d.jsx("h1",{className:"text-4xl font-extrabold text-white mb-6",children:"PromptGen Privacy Policy"}),d.jsxs("div",{className:"prose prose-invert max-w-none space-y-4",children:[d.jsx("p",{className:"text-lg leading-relaxed",children:"Welcome to PromptGen, a Google Chrome Image-to-prompt extension by CSV Meta. Your privacy is paramount to us. This policy describes how our extension collects, uses, and safeguards your information when you use our AI-powered prompt generation tools."}),d.jsx("p",{className:"leading-relaxed",children:"By accessing or using PromptGen, you signify that you have read, understood, and agree to our collection, storage, use, and disclosure of your personal information as described 
7175in this Privacy Policy."})]})]}),d.jsxs("section",{id:"information-we-use",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(Yh,{className:"w-6 h-6"})," Information We Use"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"We only use the minimum amount of data required to provide our service:"}),d.jsxs("ul",{className:"list-disc pl-6 space-y-3",children:[d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"AI API Keys:"})," Used to analyze images and generate prompts. These are stored securely in your browser's local storage."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Image Data:"})," Sent to the AI API for inference to generate prompts."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"User Preferences:"})," Settings such as preferred AI model, prompt character length, or API provider (Gemini or Mistral) are stored locally."]})]})]})]}),d.jsxs("section",{id:"third-party-services",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(WN,{className:"w-6 h-6"})," Third-Party Services"]}),d.jsxs("div",{className:"space-y-4 leading-relaxed",children:[d.jsx("p",{children:"PromptGen integrates with the following third-party services to function:"}),d.jsxs("ul",{className:"list-disc pl-6 space-y-3",children:[d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Gemini API:"})," Used for visual content analysis and prompt generation."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Mistral AI API:"})," An alternative provider for visual content analysis and prompt generation."]}),d.jsxs("li",{children:[d.jsx("strong",{className:"text-white",children:"Google Analytics 4 (GA4):"})," Used to collect user count and user behavior to help us improve the extension."]})]}),d.jsx("p",{className:"text-sm text-slate-500",children:"Please note that these services have their own privacy policies governing how they handle data sent to their APIs."})]})]}),d.jsxs("section",{id:"data-collection",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(j1,{className:"w-6 h-6"})," Data Collection & Storage"]}),d.jsxs("div",{className:"bg-white/5 border border-slate-800 rounded-2xl p-6 space-y-4",children:[d.jsx("p",{className:"font-bold text-white uppercase tracking-wider text-xs",children:"Our Commitment"}),d.jsxs("p",{className:"text-lg",children:["PromptGen follows a ",d.jsx("span",{className:"text-[#47ff72]",children:"Local-First"})," data philosophy."]}),d.jsxs("ul",{className:"space-y-4",children:[d.jsxs("li",{className:"flex gap-4",children:[d.jsx("div",{className:"bg-[#47ff72]/20 p-2 rounded-lg h-fit text-[#47ff72]",children:d.jsx(xd,{className:"w-4 h-4"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-white font-medium",children:"No Personal Data Collection"}),d.jsx("p",{className:"text-sm",children:"We do not collect users' personal details, API keys, images, or the generated prompts. Everything happens locally on users' machines."})]})]}),d.jsxs("li",{className:"flex gap-4",children:[d.jsx("div",{className:"bg-[#47ff72]/20 p-2 rounded-lg h-fit text-[#47ff72]",children:d.jsx(xd,{className:"w-4 h-4"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-white font-medium",children:"Local Browser Storage"}),d.jsx("p",{className:"text-sm",children:"Preferences and API keys exist only in your current browser session/extension storage."})]})]})]})]})]}),d.jsxs("section",{id:"policy-changes",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(Av,{className:"w-6 h-6"})," Policy Changes"]}),d.jsx("div",{className:"prose prose-invert max-w-none",children:d.jsx("p",{children:"We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page. You are advised to review this Privacy Policy periodically for any changes."})})]}),d.jsxs("section",{id:"contact-us",children:[d.jsxs("h2",{className:"text-2xl font-bold text-[#47ff72] mb-6 flex items-center gap-3",children:[d.jsx(B1,{className:"w-6 h-6"})," Contact Us"]}),d.jsxs("div",{className:"bg-green-950/30 border border-green-900/50 rounded-2xl p-8 text-center space-y-4",children:[d.jsx("p",{className:"text-slate-200",children:"Have questions about your privacy or the security of PromptGen?"}),d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsx("p",{className:"text-xs uppercase font-bold text-slate-500 tracking-widest",children:"Support Email"}),d.jsx("a",{href:"mailto:[email protected]",className:"text-2xl font-bold text-[#47ff72] hover:underline",children:"[email protected]"})]})]})]})]})]})}),d.jsx("footer",{className:"w-full py-12 mt-auto border-t border-slate-200 dark:border-slate-800 bg-white dark:bg-green-950/30 text-center transition-colors duration-300",children:d.jsxs("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:["Copyright ",new Date().getFullYear()," ",d.jsx("span",{className:"text-[#47ff72]",children:"CSV Meta"})," | All rights reserved | ",d.jsx(Is,{to:"/privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Privacy Policy"})," | ",d.jsx(Is,{to:"/terms-of-service",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"Terms of Service"})," | ",d.jsx(Is,{to:"/promptgen-privacy-policy",className:"hover:text-[#47ff72] transition-colors underline underline-offset-4",children:"PromptGen Privacy Policy"})]})})]})},bLe=()=>d.jsxs("div",{className:"min-h-screen bg-[#011f08] flex flex-col items-center justify-center p-6 text-center font-sans",children:[d.jsxs("div",{className:"max-w-md w-full space-y-8 animate-in fade-in zoom-in duration-500",children:[d.jsxs("div",{className:"relative",children:[d.jsx("h1",{className:"text-[12rem] font-black text-white/5 leading-none select-none",children:"404"}),d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:d.jsx("div",{className:"bg-brand-500/10 p-6 rounded-full border border-brand-500/20 backdrop-blur-sm",children:d.jsx(F0,{className:"w-16 h-16 text-[#47ff72] animate-pulse"})})})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsx("h2",{className:"text-3xl font-bold text-white",children:"Page Not Found"}),d.jsx("p",{className:"text-slate-400 text-lg",children:"Oops! The path you're looking for seems to have vanished into the digital void."})]}),d.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 pt-4",children:[d.jsxs(Is,{to:"/",className:"w-full sm:w-auto flex items-center justify-center gap-2 px-8 py-3 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 font-bold rounded-xl shadow-lg shadow-green-500/20 transition-all hover:scale-105 active:scale-95",children:[d.jsx(Rbe,{className:"w-5 h-5"}),"Return Home"]}),d.jsxs("button",{onClick:()=>window.history.back(),className:"w-full sm:w-auto flex items-center justify-center gap-2 px-8 py-3 bg-white/5 hover:bg-white/10 text-white font-medium rounded-xl border border-white/10 transition-all",children:[d.jsx(HL,{className:"w-5 h-5"}),"Go Back"]})]})]}),d.jsx("div",{className:"fixed bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-[#47ff72]/20 to-transparent"}),d.jsx("div",{className:"fixed top-20 left-1/2 -translate-x-1/2 w-64 h-64 bg-[#47ff72]/5 blur-[120px] rounded-full pointer-events-none"})]});function wLe(t){return t.trim().toUpperCase()}function _Le(t,e){return e==="all"||e.includes(t)}function SLe(t,e){if(e.discountType==="percent"){const n=t*e.amount/100;return Math.max(0,Math.round((t-n)*100)/100)}return Math.max(0,Math.round((t-e.amount)*100)/100)}async function ELe(t,e,n,s,r="monthly"){const i=wLe(t);if(!i)return{valid:!1,error:"Enter a coupon code."};const a=Td(Bc,"coupons",i),o=await Q0(a);if(!o.exists())return{valid:!1,error:"Invalid coupon code."};const l=o.data();if(!l.active)return{valid:!1,error:"This coupon is no longer active."};if(l.expiresAt&&Date.now()>l.expiresAt)return{valid:!1,error:"This coupon has expired."};if(l.usedCount>=l.maxUses)return{valid:!1,error:"This coupon has reached its usage limit."};
7175if(!_Le(e,l.applicablePlans))return{valid:!1,error:"This coupon does not apply to the selected plan."};if(l.currency!=="both"&&l.currency!==n)return{valid:!1,error:`This coupon is only valid for ${l.currency} pricing.`};if(!FX(SA(r),l.applicableBillingInterval))return{valid:!1,error:"This coupon does not apply to the selected pricing term."};const c=SLe(s,l);return{valid:!0,coupon:l,discountedPrice:c,originalPrice:s}}function TLe(t){return t.trim().toUpperCase()}function ALe(t,e){return t?t.active?t.expiresAt&&Date.now()>t.expiresAt?{valid:!1,error:"This trial coupon has expired."}:t.usedCount>=t.maxUses?{valid:!1,error:"This trial coupon has reached its usage limit."}:!Number.isFinite(t.trialDays)||t.trialDays<1?{valid:!1,error:"This trial coupon is misconfigured."}:t.planId!==e?{valid:!1,error:"This trial coupon does not apply to the selected plan."}:{valid:!0,coupon:t,trialDays:t.trialDays}:{valid:!1,error:"This trial coupon is no longer active."}:{valid:!1,error:"Invalid trial coupon code."}}async function CLe(t,e){const n=TLe(t);if(!n)return{valid:!1,error:"Enter a trial coupon code."};const s=await Q0(Td(Bc,"trialCoupons",n));if(!s.exists())return{valid:!1,found:!1,error:"Invalid trial coupon code."};const r=s.data(),i={...r,planId:String(r.planId??"").toLowerCase(),trialDays:Number(r.trialDays??0),maxUses:Number(r.maxUses??0),usedCount:Number(r.usedCount??0),expiresAt:Number(r.expiresAt??0),active:r.active!==!1};return{...ALe(i,e),found:!0}}function kLe(t,e,n){const s=t*(1-e/100);return n==="USD"?Math.max(0,Math.round(s*100)/100):Math.max(0,Math.round(s))}function ILe(t,e){return t==="free"?!1:e==="all"||e.includes(t)}function NLe(t,e){return e==="both"||e===t}function nae(t,e){return FX(t,e)}function sae(t){return t.active&&(!t.expiresAt||Date.now()<=t.expiresAt)}function RLe(t,e){const n=t.filter(s=>sae(s)&&nae(e,s.applicableBillingInterval));return n.sort((s,r)=>{const i=s.applicableBillingInterval===e?1:0,a=r.applicableBillingInterval===e?1:0;return a!==i?a-i:r.updatedAt-s.updatedAt}),n[0]??null}function rae(t,e,n,s="monthly"){const r=gM(t,e,s);if(!n||r===0)return{originalPrice:r,discountedPrice:r,hasDiscount:!1};if(!sae(n))return{originalPrice:r,discountedPrice:r,hasDiscount:!1};if(!ILe(t.id,n.applicablePlans))return{originalPrice:r,discountedPrice:r,hasDiscount:!1};if(!NLe(e,n.currency))return{originalPrice:r,discountedPrice:r,hasDiscount:!1};if(!nae(s,n.applicableBillingInterval))return{originalPrice:r,discountedPrice:r,hasDiscount:!1};const i=kLe(r,n.percent,e);return i>=r?{originalPrice:r,discountedPrice:r,hasDiscount:!1}:{originalPrice:r,discountedPrice:i,hasDiscount:!0}}const MLe={en:{title:"Payment Instructions",steps:[{title:"1. Choose a plan",description:"Pick a pricing plan and go to checkout."},{title:"2. Review pricing",description:"See the final pricing. Add a coupon if you have one."},{title:"3. Go to payment",description:"Proceeding to payment will send you to the payment page. Only MFS is accepted for Bangladesh."},{title:"4. Enter mobile number",description:"Enter your mobile number."},{title:"5. Send money",description:"Then send money to the PERSONAL NUMBER shown. This is NOT a merchant/agent number."},{title:"6. Verify the transaction",description:"The system auto-verifies the transaction. If verification isn't working even after payment, a button will appear to manually enter the transaction ID. Add the transaction ID."},{title:"7. Plan activates",description:"If everything's ok then the plan will activate."}],button:"Got it"},bn:{title:"পেমেন্ট নির্দেশনা",steps:[{title:"১. প্ল্যান বেছে নিন",description:"একটি প্রাইসিং প্ল্যান বেছে নিয়ে চেকআউটে যান।"},{title:"২. মূল্য দেখুন",description:"চূড়ান্ত মূল্য দেখুন। থাকলে কুপন যোগ করুন।"},{title:"৩. পেমেন্টে যান",description:"পেমেন্টে এগিয়ে গেলে আপনাকে পেমেন্ট পেজে নিয়ে যাওয়া হবে। বাংলাদেশের জন্য শুধুমাত্র MFS গ্রহণযোগ্য।"},{title:"৪. মোবাইল নম্বর দিন",description:"আপনার মোবাইল নম্বর দিন।"},{title:"৫. টাকা পাঠান",description:"তারপর দেখানো PERSONAL NUMBER-এ টাকা পাঠান। এটি কোনো মার্চেন্ট/এজেন্ট নম্বর নয়।"},{title:"৬. লেনদেন যাচাই",description:"সিস্টেম লেনদেন স্বয়ংক্রিয়ভাবে যাচাই করে। পেমেন্টের পরও যাচাই কাজ না করলে ট্রানজেকশন আইডি ম্যানুয়ালি দেওয়ার বাটন আসবে। সেখানে ট্রানজেকশন আইডি দিন।"},{title:"৭. প্ল্যান অ্যাক্টিভ",description:"সব ঠিক থাকলে প্ল্যান অ্যাক্টিভেট হবে।"}],button:"বুঝেছি"}},PLe=({isOpen:t,onClose:e})=>{const[n,s]=q.useState("en");if(q.useEffect(()=>{if(!t)return;const i=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t,e]),!t)return null;const r=MLe[n];return d.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",onClick:e,children:d.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:i=>i.stopPropagation(),children:[d.jsxs("div",{className:"flex items-center justify-between gap-3 p-6 border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50",children:[d.jsxs("h2",{className:"text-xl sm:text-2xl font-bold text-slate-800 dark:text-white flex items-center gap-3 min-w-0",children:[d.jsx(GN,{className:"w-6 h-6 text-[#47ff72] 
7175shrink-0"}),d.jsx("span",{className:"truncate",children:r.title})]}),d.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[d.jsxs("div",{className:"flex bg-slate-200 dark:bg-slate-700 rounded-lg p-1",children:[d.jsx("button",{type:"button",onClick:()=>s("en"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all ${n==="en"?"bg-white dark:bg-slate-600 shadow text-brand-600 dark:text-brand-400":"text-slate-500 dark:text-slate-400 hover:text-slate-700"}`,children:"English"}),d.jsx("button",{type:"button",onClick:()=>s("bn"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all ${n==="bn"?"bg-white dark:bg-slate-600 shadow text-brand-600 dark:text-brand-400":"text-slate-500 dark:text-slate-400 hover:text-slate-700"}`,children:"বাংলা"})]}),d.jsx("button",{type:"button",onClick:e,className:"p-2 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 rounded-full hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors","aria-label":"Close",children:d.jsx(Ki,{className:"w-6 h-6"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:r.steps.map(i=>d.jsxs("div",{className:"flex gap-4 p-4 rounded-xl border border-slate-100 dark:border-slate-700 bg-slate-50/50 dark:bg-slate-800/50",children:[d.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-brand-50 dark:bg-brand-900/20 rounded-lg flex items-center justify-center border border-brand-100 dark:border-brand-900/50",children:d.jsx(xd,{className:"w-5 h-5 text-brand-500"})}),d.jsxs("div",{children:[d.jsx("h3",{className:"font-bold text-slate-800 dark:text-slate-100 mb-1",children:i.title}),d.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400 leading-relaxed",children:i.description})]})]},i.title))})}),d.jsx("div",{className:"p-6 border-t border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 flex justify-end",children:d.jsx("button",{type:"button",onClick:e,className:"px-6 py-2.5 bg-[#47ff72] hover:bg-[#32cc59] text-slate-900 font-bold rounded-lg transition-colors",children:r.button})})]})})},$Le=({isOpen:t,onClose:e,plan:n,currency:s,billingInterval:r,pricingDiscount:i=null})=>{const a=co(),[o,l]=q.useState(""),[c,h]=q.useState(null),[p,m]=q.useState(null),[y,v]=q.useState(null),[b,S]=q.useState(null),[E,I]=q.useState(!1),[M,j]=q.useState(!1),[L,K]=q.useState(null),[D,R]=q.useState("bangladeshi"),[B,G]=q.useState(!1),X=D==="bangladeshi"?"BDT":s;if(q.useEffect(()=>{if(!t)return;const wt=zt=>{zt.key==="Escape"&&(B||e())};return window.addEventListener("keydown",wt),()=>window.removeEventListener("keydown",wt)},[t,e,B]),q.useEffect(()=>{t||(l(""),h(null),m(null),v(null),S(null),K(null),R("bangladeshi"),G(!1))},[t]),q.useEffect(()=>{l(""),h(null),m(null),v(null),S(null)},[r]),!n)return null;const H=gM(n,X,r),Y=rae(n,X,i,r),F=Y.hasDiscount?Y.discountedPrice:H,we=r==="annual"?rD(F,X):F,me=we,xe=p??we,Le=p!=null&&p<we,ve=Y.hasDiscount||Le,ce=r==="annual"?rD(H,X):H,ie=r==="annual",de=ie?Le?xe/sD:F:xe,Re=ie?H:ce,Se=ve&&Uf(Re,X)!==Uf(de,X),De=b!=null,gt=async()=>{if(!o.trim()){h("Enter a coupon code.");return}I(!0),h(null);try{const wt=await CLe(o,n.id);if(wt.valid){S({code:o.trim().toUpperCase(),trialDays:wt.trialDays??0}),m(null),v(null);return}if(wt.found){h(wt.error??"Invalid trial coupon."),m(null),v(null),S(null);return}const zt=await ELe(o,n.id,X,me,r);if(!zt.valid){h(zt.error??"Invalid coupon."),m(null),v(null),S(null);return}m(zt.discountedPrice??me),v(o.trim().toUpperCase()),S(null)}catch{h("Could not validate coupon. Try again."),m(null),v(null),S(null)}finally{I(!1)}},yt=()=>{l(""),h(null),m(null),v(null),S(null)},xt=wt=>{R(wt),!De&&(h(null),m(null),v(null),l(""))},Nt=async()=>{if(!Ko.currentUser){a("/auth");return}j(!0),K(null);try{if(De){const _n=await JOe(n.id,b.code);e(),a("/checkout/success",{state:{planName:_n.planName}});return}if(D!=="bangladeshi")return;const zt=await XOe(n.id,X,y??void 0,r);$7(),lTe(zt.invoiceId),cTe(),window.location.href=zt.paymentUrl}catch(zt){K(zt instanceof Error?zt.message:"Checkout failed. Please try again."),j(!1)}};return d.jsx(kv,{children:t&&d.jsxs(ks.div,{initial:{opacity:0}
7175,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:e,children:[d.jsxs(ks.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-2xl shadow-2xl w-full max-w-md overflow-hidden",onClick:wt=>wt.stopPropagation(),children:[d.jsxs("div",{className:"flex items-start justify-between gap-3 p-6 border-b border-slate-200 dark:border-slate-800",children:[d.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[d.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#47ff72]/10 flex items-center justify-center shrink-0",children:d.jsx(kwe,{className:"w-5 h-5 text-[#47ff72]"})}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-xl font-bold text-slate-900 dark:text-white",children:"Checkout"}),d.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-0.5 truncate",children:n.name})]})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.jsxs("button",{type:"button",onClick:()=>G(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-[#47ff72]/40 bg-[#47ff72]/10 text-[#1a7a3a] dark:text-[#47ff72] text-xs font-bold hover:bg-[#47ff72]/20 transition-colors",children:[d.jsx(GN,{className:"w-3.5 h-3.5"}),"Payment Instructions"]}),d.jsx("button",{onClick:e,className:"text-slate-400 hover:text-slate-700 dark:hover:text-white p-2 rounded-full hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors","aria-label":"Close",children:d.jsx(Ki,{className:"w-5 h-5"})})]})]}),d.jsxs("div",{className:"p-6 space-y-5",children:[d.jsxs("div",{className:"rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800/50 p-4 space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-sm text-slate-500 dark:text-slate-400",children:ie?"Annual plan":"Monthly plan"}),d.jsxs("div",{className:"flex items-center gap-2",children:[Se&&!De&&d.jsx("span",{className:"text-sm italic line-through text-slate-400",children:Uf(Re,X)}),d.jsx("span",{className:"text-lg font-bold text-[#47ff72]",children:De?d.jsxs(d.Fragment,{children:["Free trial",d.jsxs("span",{className:"text-sm font-medium text-slate-500",children:[" ","/ ",b.trialDays," day",b.trialDays===1?"":"s"]})]}):d.jsxs(d.Fragment,{children:[Uf(de,X),d.jsx("span",{className:"text-sm font-medium text-slate-500",children:"/mo"})]})})]})]}),ie&&!De&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("span",{className:"text-sm text-slate-500 dark:text-slate-400",children:["Yearly total (",sD," months)"]}),d.jsxs("div",{className:"flex items-center gap-2",children:[ve&&d.jsx("span",{className:"text-sm italic line-through text-slate-400",children:Uf(ce,X)}),d.jsx("span",{className:"text-lg font-bold text-slate-900 dark:text-white",children:Uf(xe,X)})]})]}),ie&&!De&&d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Pay once in advance. CSVBucks refill each month with no rollover."}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("img",{src:JS,alt:"",className:"w-6 h-6 object-contain"}),d.jsxs("span",{className:"text-sm font-semibold text-[#47ff72]",children:[n.csvBucks," CSVBucks",ie?"/month":""]})]}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:n.batchLimit})]}),!De&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Payment method"}),d.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[d.jsxs("button",{type:"button",onClick:()=>xt("bangladeshi"),className:`flex items-center gap-3 p-3.5 rounded-xl border text-left transition-colors ${D==="bangladeshi"?"border-[#47ff72] bg-[#47ff72]/5 ring-1 ring-[#47ff72]/30":"border-slate-200 dark:border-slate-700 hover:border-slate-300 dark:hover:border-slate-600"}`,children:[d.jsx("div",{className:"w-9 h-9 rounded-lg bg-[#47ff72]/10 flex items-center justify-center shrink-0",children:d.jsx(Xbe,{className:"w-4 h-4 text-[#47ff72]"})}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-semibold text-slate-900 dark:text-white",children:"Bangladeshi Payments"}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"bKash, Nagad & local methods via ZiniPay"})]})]}),d.jsxs("button",{type:"button",disabled:!0,className:"flex items-center gap-3 p-3.5 rounded-xl border border-slate-200 dark:border-slate-700 text-left opacity-60 cursor-not-allowed",children:[d.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 dar
7175k:bg-slate-800 flex items-center justify-center shrink-0",children:d.jsx(YL,{className:"w-4 h-4 text-slate-400"})}),d.jsxs("div",{children:[d.jsxs("p",{className:"text-sm font-semibold text-slate-900 dark:text-white",children:["International Payments",d.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-wide font-bold text-amber-600 dark:text-amber-400",children:"Coming soon"})]}),d.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Card & global wallets"})]})]})]})]}),De&&d.jsxs("div",{className:"rounded-xl border border-[#47ff72]/30 bg-[#47ff72]/5 p-4 text-sm text-slate-600 dark:text-slate-300",children:["This free trial coupon activates ",n.name," instantly. No ZiniPay checkout is required."]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Coupon code"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("div",{className:"relative flex-1",children:[d.jsx(e7,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),d.jsx("input",{type:"text",value:o,onChange:wt=>{l(wt.target.value),h(null)},placeholder:"Enter code",className:"w-full pl-10 pr-3 py-2.5 rounded-xl border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-[#47ff72]/50",disabled:!!y||!!b})]}),y||b?d.jsx("button",{type:"button",onClick:yt,className:"px-4 py-2.5 rounded-xl border border-slate-200 dark:border-slate-700 text-sm font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800",children:"Remove"}):d.jsx("button",{type:"button",onClick:gt,disabled:E||!o.trim(),className:"px-4 py-2.5 rounded-xl bg-slate-900 dark:bg-slate-700 text-white text-sm font-bold hover:bg-slate-800 disabled:opacity-50",children:E?d.jsx(Go,{className:"w-4 h-4 animate-spin"}):"Apply"})]}),c&&d.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[d.jsx(F0,{className:"w-3.5 h-3.5"}),c]}),b&&d.jsxs("p",{className:"text-xs text-[#47ff72] font-medium",children:["Trial coupon ",b.code," applied — ",b.trialDays," day",b.trialDays===1?"":"s"," free"]}),y&&d.jsxs("p",{className:"text-xs text-[#47ff72] font-medium",children:["Coupon ",y," applied"]})]}),L&&d.jsxs("p",{className:"text-sm text-red-500 flex items-center gap-1",children:[d.jsx(F0,{className:"w-4 h-4"}),L]}),d.jsx("button",{onClick:Nt,disabled:M||!De&&D!=="bangladeshi",className:"w-full py-3.5 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-xl font-bold transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:M?d.jsxs(d.Fragment,{children:[d.jsx(Go,{className:"w-5 h-5 animate-spin"}),De?"Starting free trial...":"Redirecting to payment..."]}):De?`Start Free Trial (${b.trialDays} day${b.trialDays===1?"":"s"})`:`Pay ${Uf(xe,X)}`})]})]}),d.jsx(PLe,{isOpen:B,onClose:()=>G(!1)})]})})};function XW(t){switch(t){case"left":return"justify-start text-left";case"right":return"justify-end text-right";default:return"justify-center text-center"}}function DLe(t){return t==="top"?"items-start":"items-center"}const OLe=({banner:t})=>{const{rectangle:e,textStyle:n,text:s}=t;return d.jsx("section",{className:"px-4 sm:px-6 lg:px-8 pb-2",children:d.jsx("div",{className:`mx-auto w-full flex ${DLe(n.verticalAlign)} ${XW(n.align)}`,style:{maxWidth:e.maxWidth},children:d.jsx("div",{className:"w-full",style:{backgroundColor:e.backgroundColor,borderRadius:e.borderRadius,paddingLeft:e.paddingX,paddingRight:e.paddingX,paddingTop:e.paddingY,paddingBottom:e.paddingY},children:d.jsx("p",{className:`leading-snug ${XW(n.align).split(" ").pop()}`,style:{color:n.color,fontSize:n.fontSize,fontWeight:n.bold?700:500,fontStyle:n.italic?"italic":"normal",textDecoration:n.underline?"underline":"none"},children:s})})})})},LLe=["config","pricingPromoBanners"];function jLe(t){if(!t||typeof t!="object")return null;const e=t;if(typeof e.id!="string"||typeof e.text!="string")return null;const n=e.textStyle??{},s=e.rectangle??{};return{id:e.id,name:typeof e.name=="string"?e.name:"Promo Banner",text:e.text,active:e.active===!0,createdAt:Number(e.createdAt??0),updatedAt:Number(e.updatedAt??0),textStyle:{bold:n.bold===!0,italic:n.italic===!0,underline:n.underline===!0,align:n.align==="left"||n.align==="right"?n.align:"center",verticalAlign:n.verticalAlign==="top"?"top":"center",color:typeof n.color=="string"?n.color:"#011f08",fontSize:Number(n.fontSize??18)||18},rectangle:{paddingX:Number(s.paddingX??24)||24,paddingY:Number(s.paddingY??14)||
717514,backgroundColor:typeof s.backgroundColor=="string"?s.backgroundColor:"#47ff72",borderRadius:Number(s.borderRadius??12)||12,maxWidth:Number(s.maxWidth??896)||896}}}async function BLe(){try{const t=await Q0(Td(Bc,...LLe));if(!t.exists())return null;const e=t.data().banners;return Array.isArray(e)?e.map(jLe).filter(s=>s!==null&&s.active).sort((s,r)=>r.updatedAt-s.updatedAt)[0]??null:null}catch(t){return console.warn("Could not load pricing promo banner",t),null}}const ULe=["config","pricingDiscounts"];function FLe(t){if(!t||typeof t!="object")return null;const e=t;if(typeof e.id!="string")return null;const n=e.applicablePlans;let s="all";n==="all"?s="all":Array.isArray(n)&&(s=n.map(a=>String(a).toLowerCase()).filter(a=>a==="lite"||a==="plus"||a==="max"));const r=e.currency,i=r==="BDT"||r==="USD"?r:"both";return{id:e.id,name:typeof e.name=="string"?e.name:"Pricing Discount",percent:Number(e.percent??0),currency:i,applicablePlans:s,applicableBillingInterval:UX(e.applicableBillingInterval),expiresAt:Number(e.expiresAt??0),active:e.active===!0,createdAt:Number(e.createdAt??0),updatedAt:Number(e.updatedAt??0)}}async function VLe(t="monthly"){try{const e=await Q0(Td(Bc,...ULe));if(!e.exists())return null;const n=e.data().discounts;if(!Array.isArray(n))return null;const s=n.map(FLe).filter(r=>r!==null);return RLe(s,t)}catch(e){return console.warn("Could not load pricing discount",e),null}}const zLe=["free","lite","plus","max"],vN={free:{name:"Free",prices:{BDT:0,USD:0},annualPrices:{BDT:0,USD:0}},lite:{name:"CSV Lite",prices:{BDT:200,USD:2},annualPrices:{BDT:120,USD:1.99}},plus:{name:"CSV Plus",prices:{BDT:500,USD:5},annualPrices:{BDT:450,USD:3.99}},max:{name:"CSV Max",prices:{BDT:1e3,USD:10},annualPrices:{BDT:900,USD:7.99}}};function JW(t,e){return{BDT:Number.isFinite(t==null?void 0:t.BDT)?Number(t==null?void 0:t.BDT):e.BDT,USD:Number.isFinite(t==null?void 0:t.USD)?Number(t==null?void 0:t.USD):e.USD}}function GLe(t){const e=structuredClone(vN);if(!t)return e;for(const n of zLe){const s=t[n];s&&(e[n]={name:typeof s.name=="string"&&s.name.trim()?s.name.trim():e[n].name,prices:JW(s.prices,e[n].prices),annualPrices:JW(s.annualPrices,e[n].annualPrices)})}return e}function HLe(t,e){return e?t.map(n=>{const s=e[n.id];return s?{...n,name:s.name,prices:{...s.prices},annualPrices:{...s.annualPrices},ctaLabel:n.id==="free"?n.ctaLabel:`Choose ${s.name}`}:n}):t}const qLe=["config","planPricing"];async function WLe(){try{const t=await Q0(Td(Bc,...qLe));if(!t.exists())return{...vN};const e=t.data().plans;return!e||typeof e!="object"?{...vN}:GLe(e)}catch(t){return console.warn("Could not load plan pricing config",t),{...vN}}}const KLe=({plan:t,currency:e,billingInterval:n,index:s,isLoggedIn:r,currentPlanId:i,currentBillingInterval:a,pricingDiscount:o,onPaidPlanClick:l})=>{const c=co(),h=t.recommended,p=t.id==="free",m=r&&i===t.id&&(p||a===n),{discountedPrice:y,hasDiscount:v}=rae(t,e,o,n),b=h?"text-5xl":"text-4xl",S=p||n==="monthly"?`${t.csvBucks} CSVBucks`:`${t.csvBucks} CSVBucks/month`,E=t.features.map(M=>p||n!=="annual"||!M.includes("CSVBucks")||M.includes("/day")?M:M.replace("CSVBucks","CSVBucks/month")),I=()=>{if(!m){if(p){c(r?"/app":"/auth");return}l(t)}};return d.jsxs(ks.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},transition:{duration:.45,delay:s*.08},className:`relative flex flex-col h-full rounded-3xl border transition-all duration-300 ${h?"border-[#47ff72] bg-white dark:bg-slate-900 shadow-[0_0_40px_rgba(71,255,114,0.15)] xl:scale-105 xl:z-10":"border-slate-200 dark:border-slate-700/80 bg-white dark:bg-slate-900/50 hover:border-[#47ff72]/40 hover:shadow-[0_0_24px_rgba(71,255,114,0.08)] shadow-sm dark:shadow-none"}`,children:[h&&d.jsx("div",{className:"absolute inset-0 hidden dark:block rounded-3xl bg-gradient-to-b from-[#47ff72]/10 via-slate-900/80 to-slate-900/90 pointer-events-none"}),h&&d.jsx("div",{className:"absolute -top-3.5 left-1/2 -translate-x-1/2 z-20",children:d.jsxs("span",{className:"inline-flex items-center gap-1.5 px-4 py-1.5 bg-[#47ff72] text-slate-900 text-xs font-black uppercase tracking-wider rounded-full shadow-lg shadow-[#47ff72]/30",children:[d.jsx(EM,{className:"w-3.5 h-3.5 fill-slate-900"}),"Recommended"]})}),d.jsxs("div",{className:"relative z-10 p-6 sm:p-7 flex flex-col flex-1",children:[d.jsxs("div",{className:"flex flex-col items-center text-center mb-6",children:[t.icon?d.jsx("img",{src:t.icon,alt:"",className:"w-14 h-14 object-contain mb-4 drop-shadow-[0_0_12px_rgba(71,255,114,0.25)]"}
7175):d.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#47ff72]/10 border border-[#47ff72]/20 flex items-center justify-center mb-4",children:d.jsx(e7,{className:"w-7 h-7 text-[#47ff72]"})}),d.jsx("h3",{className:"text-xl font-bold text-slate-900 dark:text-white",children:t.name}),d.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-1",children:p?"Free plan":n==="annual"?"Annual plan":"Monthly plan"})]}),d.jsxs("div",{className:"text-center mb-6",children:[v?d.jsxs("div",{className:"flex flex-col items-center gap-1",children:[d.jsx("span",{className:"text-sm italic line-through text-slate-500 dark:text-slate-400",children:IF(t,e,n)}),d.jsxs("div",{className:"flex items-end justify-center gap-1",children:[d.jsx("span",{className:`font-extrabold tracking-tight text-[#47ff72] ${b}`,children:Uf(y,e)}),d.jsx("span",{className:"text-slate-500 dark:text-slate-400 text-sm font-medium pb-1.5",children:"/month"})]})]}):d.jsxs("div",{className:"flex items-end justify-center gap-1",children:[d.jsx("span",{className:`font-extrabold tracking-tight text-slate-900 dark:text-white ${b}`,children:IF(t,e,n)}),!p&&d.jsx("span",{className:"text-slate-500 dark:text-slate-400 text-sm font-medium pb-1.5",children:"/month"})]}),!p&&n==="annual"&&d.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-2",children:["Billed ",Uf(rD(v?y:gM(t,e,"annual"),e),e)," ","yearly"]}),d.jsxs("div",{className:"inline-flex items-center gap-2 mt-3 px-3.5 py-1.5 rounded-full bg-[#47ff72]/10 border border-[#47ff72]/20",children:[d.jsx("img",{src:JS,alt:"",className:"w-7 h-7 object-contain shrink-0"}),d.jsx("span",{className:"text-xs font-semibold text-[#47ff72]",children:S})]})]}),d.jsx("ul",{className:"space-y-3 mb-8 flex-1",children:E.map(M=>d.jsxs("li",{className:"flex items-start gap-3 text-sm text-slate-600 dark:text-slate-300",children:[d.jsx(yd,{className:"w-4 h-4 text-[#47ff72] mt-0.5 shrink-0"}),d.jsx("span",{className:"leading-relaxed",children:M})]},M))}),m?d.jsx("button",{type:"button",disabled:!0,"aria-current":"true",className:"w-full py-3.5 rounded-xl font-bold cursor-not-allowed border-2 border-[#47ff72]/50 text-[#47ff72] bg-[#47ff72]/10 opacity-90",children:"Current Plan"}):d.jsx("button",{onClick:I,className:`w-full py-3.5 rounded-xl font-bold transition-all ${h?"bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 shadow-[0_0_20px_rgba(71,255,114,0.35)] hover:shadow-[0_0_30px_rgba(71,255,114,0.5)] hover:-translate-y-0.5":p?"bg-slate-900 hover:bg-slate-800 text-white dark:bg-white dark:hover:bg-slate-100 dark:text-slate-900":"border-2 border-[#47ff72]/60 text-[#47ff72] hover:bg-[#47ff72]/10"}`,children:t.ctaLabel})]})]})},YLe=()=>{const t=co(),[e,n]=q.useState(()=>{if(typeof window<"u"){const D=localStorage.getItem(kF);if(D==="BDT"||D==="USD")return D}return"BDT"}),[s,r]=q.useState(!1),[i,a]=q.useState(()=>!!Ko.currentUser),[o,l]=q.useState(null),[c,h]=q.useState(null),[p,m]=q.useState("annual"),[y,v]=q.useState(null),[b,S]=q.useState(null),[E,I]=q.useState(null),[M,j]=q.useState(CF);q.useEffect(()=>{BLe().then(S),WLe().then(D=>{j(HLe(CF,D))})},[]),q.useEffect(()=>{VLe(p).then(I)},[p]),q.useEffect(()=>{const D=Vm(Ko,async R=>{if(!R){r(!1),l(null),h(null),a(!1);return}r(!0),a(!0);try{const B=await Vv(R);l(B.plan??"free"),h(B.billingInterval??"monthly")}catch{l("free"),h(null)}finally{a(!1)}});return()=>D()},[]);const L=i;q.useEffect(()=>{localStorage.setItem(kF,e)},[e]);const K=D=>{if(!s){t("/auth");return}o===D.id&&c===p||v(D)};return L?d.jsxs("div",{className:"min-h-screen flex flex-col bg-[#011f08] text-slate-100 font-sans",children:[d.jsx(V0,{}),d.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 px-4",children:[d.jsx(Go,{className:"w-12 h-12 text-[#47ff72] animate-spin"}),d.jsx("p",{className:"text-sm text-slate-400",children:"Initializing CSV Meta..."})]})]}):d.jsxs("div",{className:"min-h-screen flex flex-col bg-[#011f08] text-slate-100 font-sans transition-colors duration-300",children:[d.jsx(V0,{}),d.jsxs("main",{className:"flex-1 w-full",children:[d.jsxs("section",{className:"relative pt-16 pb-10 md:pt-24 md:pb-14 overflow-hidden px-4 sm:px-6 lg:px-8",children:[d.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[#47ff72]/10 to-transparent pointer-events-none"}),d.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-[600px] h-[300px] bg-[#47ff72]/5 rounded-full blur-[100px] pointer-events-none"}),d.jsxs(ks.div,{initial:{opacity:0,y:20}
7175,animate:{opacity:1,y:0},transition:{duration:.5},className:"relative z-10 text-center max-w-3xl mx-auto space-y-5",children:[d.jsx("span",{className:"inline-block px-4 py-1.5 bg-[#47ff72]/10 text-[#47ff72] rounded-full text-xs font-bold tracking-wider border border-[#47ff72]/20",children:"SIMPLE PRICING"}),d.jsxs("h1",{className:"text-4xl md:text-5xl font-extrabold text-white tracking-tight",children:["Choose the plan that"," ",d.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-[#47ff72] to-[#00d2ff]",children:"scales with you"})]}),d.jsx("p",{className:"text-lg text-slate-300 max-w-2xl mx-auto leading-relaxed",children:"Monthly CSVBucks for metadata generation, embedding, and creative tools built for microstock contributors."}),d.jsxs("p",{className:"text-sm text-slate-400",children:["Trusted by ",d.jsx("span",{className:"text-[#47ff72] font-semibold",children:"200+ creators"})," worldwide"]})]})]}),b&&d.jsx(OLe,{banner:b}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-12",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.45,delay:.1},className:"flex flex-col sm:flex-row items-center justify-center gap-4 mb-10",children:[d.jsxs("div",{className:"inline-flex p-1 bg-white dark:bg-slate-900/80 border border-slate-200 dark:border-slate-700 rounded-full shadow-lg",children:[d.jsx("button",{onClick:()=>n("BDT"),className:`px-5 py-2.5 rounded-full text-sm font-bold transition-all ${e==="BDT"?"bg-[#47ff72] text-slate-900 shadow-md":"text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white"}`,children:"à§³ BDT"}),d.jsx("button",{onClick:()=>n("USD"),className:`px-5 py-2.5 rounded-full text-sm font-bold transition-all ${e==="USD"?"bg-[#47ff72] text-slate-900 shadow-md":"text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white"}`,children:"$ USD"})]}),d.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-2 bg-white dark:bg-slate-900/80 border border-slate-200 dark:border-slate-700 rounded-full shadow-lg",children:[d.jsx("span",{className:`text-sm font-bold transition-colors ${p==="monthly"?"text-slate-900 dark:text-white":"text-slate-400 dark:text-slate-500"}`,children:"Monthly"}),d.jsx("button",{type:"button",role:"switch","aria-checked":p==="annual","aria-label":"Toggle annual pricing",onClick:()=>m(D=>D==="annual"?"monthly":"annual"),className:`relative w-12 h-7 rounded-full transition-colors ${p==="annual"?"bg-[#47ff72]":"bg-slate-300 dark:bg-slate-600"}`,children:d.jsx("span",{className:`absolute top-0.5 left-0.5 w-6 h-6 rounded-full bg-white shadow-md transition-transform ${p==="annual"?"translate-x-5":"translate-x-0"}`})}),d.jsx("span",{className:`text-sm font-bold transition-colors ${p==="annual"?"text-slate-900 dark:text-white":"text-slate-400 dark:text-slate-500"}`,children:"Annual"})]})]}),d.jsx("div",{className:"max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-6 xl:gap-5 xl:items-center",children:M.map((D,R)=>d.jsx(KLe,{plan:D,currency:e,billingInterval:p,index:R,isLoggedIn:s,currentPlanId:o,currentBillingInterval:c,pricingDiscount:E,onPaidPlanClick:K},D.id))})]}),d.jsx("section",{className:"px-4 sm:px-6 lg:px-8 pb-16 max-w-5xl mx-auto",children:d.jsxs(ks.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.35},className:"rounded-3xl border border-slate-200 dark:border-slate-700/80 bg-white dark:bg-slate-900/40 overflow-hidden shadow-sm dark:shadow-none",children:[d.jsxs("div",{className:"px-6 py-5 border-b border-slate-200 dark:border-slate-800 text-center",children:[d.jsx("h2",{className:"text-lg font-bold text-slate-900 dark:text-white",children:"Quick comparison"}),d.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-1",children:"See what grows with each tier"})]}),d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full min-w-[640px] text-sm",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-slate-200 dark:border-slate-800",children:[d.jsx("th",{className:"text-left px-6 py-4 text-slate-500 dark:text-slate-400 font-medium",children:"Feature"}),d.jsx("th",{className:"px-4 py-4 text-slate-700 dark:text-slate-300 font-semibold",children:"Free"}),d.jsx("th",{className:"px-4 py-4 text-slate-700 dark:text-slate-300 font-semibold",children:"Lite"}),d.jsx("th",{className:"px-4 py-4 text-[#47ff72] font-bold",children:"Plus"}),d.jsx("th",{className:"px-4 py-4 text-slate-700 dark:text-slate-300 font-semibold",children:"Max"})]})}),d.jsx("tbody",{children:hve.map(D=>{const R=D.label==="CSVBucks"&&p==="annual"?"/month":"";
7175return d.jsxs("tr",{className:"border-b border-slate-100 dark:border-slate-800/80 last:border-0",children:[d.jsx("td",{className:"px-6 py-4 text-slate-500 dark:text-slate-400",children:D.label}),d.jsx("td",{className:"px-4 py-4 text-center text-slate-700 dark:text-slate-300",children:D.free}),d.jsxs("td",{className:"px-4 py-4 text-center text-slate-700 dark:text-slate-300",children:[D.lite,R]}),d.jsxs("td",{className:"px-4 py-4 text-center text-[#47ff72] font-semibold",children:[D.plus,R]}),d.jsxs("td",{className:"px-4 py-4 text-center text-slate-700 dark:text-slate-300",children:[D.max,R]})]},D.label)})})]})})]})}),d.jsx("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-5xl mx-auto",children:d.jsxs(ks.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.4},className:"bg-gradient-to-br from-white via-emerald-50/80 to-slate-50 dark:from-slate-900 dark:via-emerald-950/40 dark:to-slate-900 border border-[#47ff72]/30 rounded-3xl p-8 md:p-12 text-center relative overflow-hidden shadow-[0_0_40px_rgba(71,255,114,0.1)]",children:[d.jsx("div",{className:"absolute -top-32 -left-32 w-64 h-64 bg-[#47ff72] rounded-full mix-blend-overlay filter blur-[100px] opacity-20 dark:opacity-40 animate-pulse pointer-events-none"}),d.jsx("div",{className:"absolute -bottom-32 -right-32 w-64 h-64 bg-emerald-500 rounded-full mix-blend-overlay filter blur-[100px] opacity-20 dark:opacity-40 pointer-events-none"}),d.jsx("h2",{className:"text-2xl md:text-3xl font-extrabold text-slate-900 dark:text-white mb-4 relative z-10",children:"Start free, upgrade when you're ready"}),d.jsx("p",{className:"text-slate-600 dark:text-slate-300 max-w-xl mx-auto mb-8 relative z-10",children:"Every plan includes CSV export, embedding support, and access to Color Extractor. Jump in with 30 CSVBucks/day at no cost."}),d.jsxs("button",{onClick:()=>t(s?"/app":"/auth"),className:"relative z-10 inline-flex items-center justify-center gap-2 px-8 py-4 font-bold text-slate-900 bg-[#47ff72] hover:bg-[#3ce565] transition-all rounded-xl shadow-[0_0_20px_rgba(71,255,114,0.4)] hover:shadow-[0_0_30px_rgba(71,255,114,0.6)] hover:-translate-y-1",children:[d.jsx("span",{children:s?"Open Tool":"Start Generating Free"}),d.jsx(vd,{className:"w-5 h-5"})]})]})})]}),d.jsx(AM,{}),d.jsx($Le,{isOpen:y!==null,onClose:()=>v(null),plan:y,currency:e,billingInterval:p,pricingDiscount:E})]})},XLe="/assets/metadata-generator-Bm1GIm5w.webp",JLe="/assets/background-generator-CtyBAYaO.webp",QLe="/assets/image-upscaler-CI9CxLft.webp",ZLe="/assets/bento-generator-BW9TxKbZ.webp",e7e="/assets/vector-studio-BDlCK2vn.webp",t7e="/assets/color-extractor-tCKTqbkp.webp",QW=[{id:"metadata-generator",name:"Metadata Generator",tagline:"AI-powered stock SEO",description:"Generate titles, keywords, and categories for Adobe Stock, Shutterstock, and Freepik in minutes. Batch-process photos, videos, and vectors — with free EPS/SVG metadata embedding.",image:XLe,icon:mp,featured:!0},{id:"background-generator",name:"Background Generator",tagline:"Stock-ready backdrops",description:"Create gradient, stripe, solid, and seamless vector backgrounds in seconds. Export at any resolution for stock uploads or social content.",image:JLe,icon:Sd},{id:"image-upscaler",name:"Image Upscaler",tagline:"Sharper, bigger, local",description:"Upscale JPG and PNG images up to 4× with Real-ESRGAN AI — entirely in your browser. Your files never leave your device.",image:QLe,icon:AA},{id:"bento-generator",name:"Bento Generator",tagline:"Layouts that convert",description:"Design polished bento grid layouts with custom text, images, and presets. Export as PNG, JPG, or responsive HTML.",image:ZLe,icon:wM},{id:"vector-studio",name:"Vector Studio",tagline:"Edit vectors in browser",description:"Import, edit, and export SVG artwork with paths, text, gradients, and boolean operations — no desktop software required.",image:e7e,icon:JL},{id:"color-extractor",name:"Color Extractor",tagline:"Palette in one click",description:"Pull dominant colors from any image and export palettes for your next design, brand kit, or stock series.",image:t7e,icon:U1}],ZW=({tool:t,index:e,featured:n=!1})=>{const s=t.icon;return d.jsxs(ks.article,{initial:{opacity:0,y:28},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-40px"},transition:{duration:.5,delay:e*.08},className:`group relative flex flex-col overflow-hidden rounded-3xl border transition-all duration-300 ${n?"border-[#47ff72]/50 bg-white dark:bg-slate-900 shadow-[0_0_48px_rgba(71,255,114,0.12)] lg:flex-row":"border-slate-200 dark:border-slate-700/80 bg-white dark:bg-slate-900/50 hover:border-[#47ff72]/40 hover:shadow-[0_0_32px_rgba(71,255,114,0.1)] shadow-sm dark:shadow-none"}`,children:[n&&d.jsx("div",{className:"absolute top-4 left-4 z-20",children:d.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-[#47ff72] text-slate-900 text-xs font-black uppercase tracking-wider rounded-full shadow-lg shadow-[#47ff72]/30",children:[d.jsx(EM,{className:"w-3.5 h-3.5 fill-slate-900"}),"Flagship Tool"]})}),d.jsxs("div",{className:`relative overflow-hidden ${n?"lg:w-1/2 min-h-[260px] lg:min-h-[360px]":"aspect-[16/10]"}`,children:[d.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/60 via-trans
7175parent to-transparent z-10 pointer-events-none"}),d.jsx("img",{src:t.image,alt:`${t.name} preview`,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-[1.03]",loading:"lazy"}),d.jsxs("div",{className:"absolute bottom-4 left-4 z-20 flex items-center gap-2 px-3 py-2 rounded-xl bg-slate-900/70 backdrop-blur-sm border border-white/10",children:[d.jsx(s,{className:"w-4 h-4 text-[#47ff72]"}),d.jsx("span",{className:"text-xs font-bold text-white uppercase tracking-wide",children:t.tagline})]})]}),d.jsxs("div",{className:`flex flex-col flex-1 ${n?"lg:w-1/2 p-8 lg:p-10":"p-6"}`,children:[d.jsx("h2",{className:`font-extrabold text-slate-900 dark:text-white ${n?"text-2xl md:text-3xl":"text-xl"}`,children:t.name}),d.jsx("p",{className:`mt-3 text-slate-600 dark:text-slate-300 leading-relaxed flex-1 ${n?"text-base md:text-lg":"text-sm"}`,children:t.description}),d.jsxs(Is,{to:"/app",className:`mt-6 inline-flex items-center justify-center gap-2 font-bold rounded-xl transition-all ${n?"px-6 py-3.5 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 shadow-[0_0_20px_rgba(71,255,114,0.35)] hover:shadow-[0_0_30px_rgba(71,255,114,0.5)] hover:-translate-y-0.5":"px-5 py-3 border-2 border-[#47ff72]/60 text-[#47ff72] hover:bg-[#47ff72]/10"}`,children:[d.jsxs("span",{children:["Try ",t.name]}),d.jsx(fE,{className:"w-4 h-4 transition-transform group-hover:translate-x-0.5"})]})]})]})},n7e=()=>{const t=co(),e=QW.find(s=>s.featured),n=QW.filter(s=>!s.featured);return d.jsxs("div",{className:"min-h-screen flex flex-col bg-[#011f08] text-slate-100 font-sans transition-colors duration-300",children:[d.jsx(V0,{}),d.jsxs("main",{className:"flex-1 w-full",children:[d.jsxs("section",{className:"relative pt-16 pb-12 md:pt-24 md:pb-16 overflow-hidden px-4 sm:px-6 lg:px-8",children:[d.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[#47ff72]/10 to-transparent pointer-events-none"}),d.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-[700px] h-[350px] bg-[#47ff72]/5 rounded-full blur-[120px] pointer-events-none"}),d.jsxs(ks.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"relative z-10 text-center max-w-3xl mx-auto space-y-5",children:[d.jsx("span",{className:"inline-block px-4 py-1.5 bg-[#47ff72]/10 text-[#47ff72] rounded-full text-xs font-bold tracking-wider border border-[#47ff72]/20",children:"6 TOOLS, ONE WORKSPACE"}),d.jsxs("h1",{className:"text-4xl md:text-5xl font-extrabold text-white tracking-tight",children:["Everything microstockers need,"," ",d.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-[#47ff72] to-[#00d2ff]",children:"built for speed"})]}),d.jsx("p",{className:"text-lg text-slate-300 max-w-2xl mx-auto leading-relaxed",children:"From AI metadata and vector editing to upscaling and color palettes — CSV Meta packs a full creative toolkit into one browser-based workspace."}),d.jsxs("button",{onClick:()=>t("/app"),className:"inline-flex items-center justify-center gap-2 px-8 py-4 mt-2 font-bold text-slate-900 bg-[#47ff72] hover:bg-[#3ce565] transition-all rounded-xl shadow-[0_0_20px_rgba(71,255,114,0.4)] hover:shadow-[0_0_30px_rgba(71,255,114,0.6)] hover:-translate-y-1",children:[d.jsx("span",{children:"Open All Tools Free"}),d.jsx(vd,{className:"w-5 h-5"})]})]})]}),d.jsx("section",{className:"px-4 sm:px-6 lg:px-8 pb-10 max-w-6xl mx-auto",children:d.jsx(ZW,{tool:e,index:0,featured:!0})}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-16 max-w-6xl mx-auto",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.45},className:"text-center mb-10",children:[d.jsx("h2",{className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"Creative Suite"}),d.jsx("p",{className:"text-slate-400 mt-2",children:"More tools to grow your microstock workflow"})]}),d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:n.map((s,r)=>d.jsx(ZW,{tool:s,index:r+1},s.id))})]}),d.jsx("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-5xl mx-auto",children:d.jsxs(ks.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},className:"bg-gradient-to-br from-white via-emerald-50/80 to-slate-50 dark:from-slate-900 dark:via-emerald-950/40 dark:to-slate-900 border border-[#47ff72]/30 rounded-3xl p-8 md:p-12 text-center relative overflow-hidden shadow-[0_0_40px_rgba(71,255,114,0.1)]",children:[d.jsx("div",{className:"absolute -top-32 -left-32 w-64 h-64 bg-[#47ff72] rounded-full mix-blend-overlay filter blur-[100px] opacity-20 dark:opacity-40 animate-pulse pointer-events-none"}),d.jsx("div",{className:"absolute -bottom-32 -right-32 w-64 h-64 bg-emerald-500 rounded-full mix-blend-overlay filter blur-[100px] opacity-20 dark:opacity-40 pointer-events-none"}),d.jsx("h2",{className:"text-2xl md:text-3xl font-extrabold text-slate-900 dark:text-white mb-4 relative z-10",children:"Ready to streamline your workflow?"}
7175),d.jsx("p",{className:"text-slate-600 dark:text-slate-300 max-w-xl mx-auto mb-8 relative z-10",children:"Jump into the app and switch between all six tools instantly. Start with 50 free CSVBucks every day — no credit card required."}),d.jsxs(Is,{to:"/app",className:"relative z-10 inline-flex items-center justify-center gap-2 px-8 py-4 font-bold text-slate-900 bg-[#47ff72] hover:bg-[#3ce565] transition-all rounded-xl shadow-[0_0_20px_rgba(71,255,114,0.4)] hover:shadow-[0_0_30px_rgba(71,255,114,0.6)] hover:-translate-y-1",children:[d.jsx("span",{children:"Launch CSV Meta"}),d.jsx(fE,{className:"w-5 h-5"})]})]})})]}),d.jsx(AM,{})]})},eK="https://csvmeta.com",C3="page-json-ld";function rd(t,e,n=!1){const s=n?"property":"name";let r=document.querySelector(`meta[${s}="${t}"]`);r||(r=document.createElement("meta"),r.setAttribute(s,t),document.head.appendChild(r)),r.content=e}function s7e({title:t,description:e,path:n,keywords:s,ogImage:r=`${eK}/og-image.png`,jsonLd:i}){q.useEffect(()=>{const a=`${eK}${n}`;document.title=t,rd("description",e),rd("keywords",s),rd("og:title",t,!0),rd("og:description",e,!0),rd("og:url",a,!0),rd("og:type","website",!0),rd("og:image",r,!0),rd("twitter:card","summary_large_image",!0),rd("twitter:url",a,!0),rd("twitter:title",t,!0),rd("twitter:description",e,!0),rd("twitter:image",r,!0);let o=document.querySelector('link[rel="canonical"]');o||(o=document.createElement("link"),o.rel="canonical",document.head.appendChild(o)),o.href=a;const l=document.getElementById(C3);if(i){const c=l??document.createElement("script");c.id=C3,c.type="application/ld+json",c.textContent=JSON.stringify(i),l||document.head.appendChild(c)}else l==null||l.remove();return()=>{var c;(c=document.getElementById(C3))==null||c.remove()}},[t,e,n,s,r,i])}const iae=[{question:"Why should microstock contributors use CSV Meta?",answer:"CSV Meta replaces hours of manual tagging with AI-generated titles, keywords, and categories tuned for Adobe Stock, Shutterstock, and Freepik. You also get vector editing, upscaling, backgrounds, and color tools in one browser workspace — so you spend less time on admin and more time creating."},{question:"Is CSV Meta really free to try?",answer:"Yes. Sign in with Google and start with 50 free CSVBucks every day — no credit card required. You can generate metadata, export platform-ready CSV files, and explore creative tools before upgrading."},{question:"Does CSV Meta store my creative files?",answer:"No. CSV Meta follows a local-first approach. Your images and videos are analyzed in your browser and are never uploaded to our servers, keeping your intellectual property private."},{question:"Which stock platforms does CSV Meta support?",answer:"CSV Meta exports metadata formatted for Adobe Stock, Shutterstock, and Freepik — including category mapping and character limits. It also supports free EPS and SVG metadata embedding, a feature rarely offered elsewhere."},{question:"What makes CSV Meta different from other metadata tools?",answer:"CSV Meta is the only all-in-one microstock toolkit that combines AI metadata generation with six creative tools — Background Generator, Image Upscaler, Bento Generator, Vector Studio, and Color Extractor — in a single privacy-first browser app."}],r7e=[{name:"Metadata Generator",icon:mp,benefit:"Batch AI titles & keywords for every major stock platform"},{name:"Background Generator",icon:Sd,benefit:"Stock-ready gradients, stripes, and seamless vectors"},{name:"Image Upscaler",icon:AA,benefit:"4× upscaling with Real-ESRGAN — fully in-browser"},{name:"Bento Generator",icon:wM,benefit:"Polished grid layouts for social and portfolio pages"},{name:"Vector Studio",icon:JL,benefit:"Edit SVG paths, text, and gradients without desktop software"},{name:"Color Extractor",icon:U1,benefit:"Instant palettes from any image for cohesive series"}],i7e=[{icon:EA,title:"Hours lost to manual tagging",desc:"Typing titles and keywords for hundreds of assets eats into your creative time every week."},{icon:YX,title:"Keywords that miss the mark",desc:"Generic tags mean lower search visibility on Adobe Stock, Shutterstock, and Freepik."},{icon:ZX,title:"Vectors are a nightmare",desc:"EPS and SVG metadata embedding is tedious — most tools skip it entirely or charge extra."}],a7e=[{icon:vd,title:"AI that understands stock SEO",desc:"Gemini-powered metadata captures subjects, mood, colors, and context — optimized for how buyers actually search."},{icon:t_,title:"Privacy-first by design",desc:"Files stay on your device. We never store your photos, videos, or vectors on our servers."},{icon:YL,title:"One app, every platform",desc:"Export CSV files with correct categories and limits for Adobe Stock, Shutterstock, and Freepik."},{icon:Fwe,title:"Grow sales, not workload",desc:"Better metadata means more discoverability. Creators report stronger sales after switching to CSV Meta."}],o7e=[{step:"1",title:"Sign in free",desc:"Use your Google account — no credit card, no setup headaches."},{step:"2",title:"Drop your files",desc:"Upload photos, videos, or vectors. AI analyzes them in seconds."},{step:"3",title:"Export & upload",desc:"Download platform-ready CSV files or embed metadata directly into vectors."}],l7e=[{label:"AI metadata for Adobe Stock, Shutterstock & Freepik",csvMeta:!0,manual:!1},{label:"Batch process hundreds of files",csvMeta:!0,manual:!1},{label:"Free EPS/SVG metadata embedding",csvMeta:!0,manual:!1},{label:"6 creative tools in one workspace",csvMeta:!0,manual:!1},{label:"Local-first — files never uploaded",csvMeta:!0,manual:!0},{label:"50 free CSVBucks daily",csvMeta:!0,manual:!1}],c7e=[{quote:"This tool has completely transformed my workflow. What used to take hours now takes minutes. The Adobe Stock metadata generator is spot on!",name:"Siam",role:"Stock Photographer"},{quote:"I've tried many Shutterstock metadata generators, but CSV Meta is by far the most accurate. My sales have increased since I started using it.",n
7175ame:"Rabiul",role:"Vector Artist"},{quote:"The Freepik SEO optimization is incredible. It finds keywords I would never have thought of. Highly recommended for any microstock contributor.",name:"Khalid",role:"Content Creator"}],u7e={"@context":"https://schema.org","@type":"FAQPage",mainEntity:iae.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))},d7e=[{"@context":"https://schema.org","@type":"WebPage",name:"Why CSV Meta",description:"Discover why microstock contributors choose CSV Meta for AI metadata generation, vector tools, and a complete creative workflow.",url:"https://csvmeta.com/why-csv-meta",isPartOf:{"@type":"WebSite",name:"CSV Meta",url:"https://csvmeta.com"}},{"@context":"https://schema.org","@type":"SoftwareApplication",name:"CSV Meta",applicationCategory:"DesignApplication",operatingSystem:"Web Browser",offers:{"@type":"Offer",price:"0",priceCurrency:"USD",description:"Free tier with 30 CSVBucks daily"},description:"All-in-one microstock toolkit with AI metadata generation, background creator, image upscaler, bento layouts, vector studio, and color extractor.",url:"https://csvmeta.com"},u7e],h7e=()=>{const t=co(),[e,n]=q.useState(!1);s7e({title:"Why CSV Meta? | All-in-One Microstock Toolkit for Creators",description:"Discover why 200+ microstock contributors choose CSV Meta. AI metadata for Adobe Stock, Shutterstock & Freepik, plus upscaling, vector editing, and more — free to start, privacy-first.",path:"/why-csv-meta",keywords:"why CSV Meta, microstock tools, Adobe Stock metadata generator, Shutterstock keywords, Freepik SEO, stock photography workflow, AI metadata tool, vector metadata embedding, microstock contributor tools",jsonLd:d7e}),q.useEffect(()=>{const r=Vm(Ko,i=>{n(!!i)});return()=>r()},[]);const s=()=>{t(e?"/app":"/auth")};return d.jsxs("div",{className:"min-h-screen flex flex-col bg-[#011f08] text-slate-100 font-sans transition-colors duration-300",children:[d.jsx(V0,{}),d.jsxs("main",{className:"flex-1 w-full",children:[d.jsxs("section",{className:"relative pt-16 pb-14 md:pt-28 md:pb-20 overflow-hidden px-4 sm:px-6 lg:px-8",children:[d.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[#47ff72]/10 to-transparent pointer-events-none"}),d.jsx("div",{className:"absolute top-20 left-1/4 w-72 h-72 bg-[#47ff72]/5 rounded-full blur-[100px] pointer-events-none"}),d.jsx("div",{className:"absolute bottom-0 right-1/4 w-96 h-96 bg-[#00d2ff]/5 rounded-full blur-[120px] pointer-events-none"}),d.jsxs(ks.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},transition:{duration:.55},className:"relative z-10 max-w-5xl mx-auto text-center space-y-6",children:[d.jsx("span",{className:"inline-block px-4 py-1.5 bg-[#47ff72]/10 text-[#47ff72] rounded-full text-xs font-bold tracking-wider border border-[#47ff72]/20",children:"BUILT FOR MICROSTOCK CREATORS"}),d.jsxs("h1",{className:"text-4xl md:text-6xl font-extrabold text-white tracking-tight leading-tight",children:["Why"," ",d.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-[#47ff72] to-[#00d2ff]",children:"CSV Meta"})," ","is the toolkit serious contributors switch to"]}),d.jsx("p",{className:"text-lg md:text-xl text-slate-300 max-w-3xl mx-auto leading-relaxed",children:"Stop juggling spreadsheets, desktop apps, and half-baked taggers. CSV Meta gives you AI-powered metadata, vector editing, upscaling, and six creative tools in one fast, privacy-first browser workspace — starting free, no credit card."}),d.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 pt-2",children:[d.jsxs("button",{onClick:s,className:"inline-flex items-center justify-center gap-2 px-8 py-4 font-bold text-slate-900 bg-[#47ff72] hover:bg-[#3ce565] transition-all rounded-xl shadow-[0_0_20px_rgba(71,255,114,0.4)] hover:shadow-[0_0_30px_rgba(71,255,114,0.6)] hover:-translate-y-1 w-full sm:w-auto",children:[d.jsx(vd,{className:"w-5 h-5"}),d.jsx("span",{children:e?"Open CSV Meta":"Try CSV Meta Free"})]}),d.jsxs(Is,{to:"/tools",className:"inline-flex items-center justify-center gap-2 px-8 py-4 border-2 border-slate-600 hover:border-[#47ff72] text-white rounded-xl font-bold transition-all w-full sm:w-auto",children:[d.jsx("span",{children:"Explore All Tools"}),d.jsx(fE,{className:"w-5 h-5"})]})]}),d.jsxs("p",{className:"text-sm text-slate-500 flex items-center justify-center gap-2",children:[d.jsx(Jwe,{className:"w-4 h-4 text-[#47ff72]"}),"Trusted by ",d.jsx("span",{className:"text-[#47ff72] font-semibold",children:"200+ creators"})," worldwide"]})]})]}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-16 max-w-5xl mx-auto","aria-labelledby":"pain-points-heading",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.45},className:"text-center mb-10",children:[d.jsx("h2",{id:"pain-points-heading",className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"Sound familiar?"}),d.jsx("p",{className:"text-2xl md:text-3xl font-extrabold text-white mt-3",children:"Microstock workflow shouldn't feel like a second job"})]}),d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:i7e.map((r,i)=>{const a=r.icon;return d.jsxs(ks.article,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.45,delay:i*.08},className:"p-6 rounded-2xl border border-red-200 dark:border-red-500/20 bg-red-50 dark:bg-red-950/10",children:[d.jsx("div",{className:"w-11 h-11 rounded-xl bg-red-100 dark:bg-red-500/10 flex items-center justify-center text-red-600 dark:text-red-400 mb-4",children:d.jsx(a,{className:"w-5 h-5"})}),d.jsx("h3",{className:"font-bold text-slate-900 dark:text-white mb-2",children:r.title}
7175),d.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-sm leading-relaxed",children:r.desc})]},r.title)})})]}),d.jsx("section",{className:"px-4 sm:px-6 lg:px-8 pb-16 max-w-5xl mx-auto",children:d.jsxs(ks.div,{initial:{opacity:0,y:24},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},className:"relative",children:[d.jsx("div",{className:"absolute -inset-6 md:-inset-10 bg-[#47ff72]/8 blur-3xl rounded-full pointer-events-none"}),d.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-700/60 shadow-[0_20px_60px_rgba(0,0,0,0.45)] ring-1 ring-[#47ff72]/15",children:[d.jsx("img",{src:nZ,alt:"CSV Meta microstock metadata generator and creative toolkit interface",className:"w-full h-auto block",loading:"lazy",decoding:"async"}),d.jsx("div",{className:"absolute inset-x-0 bottom-0 h-24 bg-gradient-to-t from-[#011f08]/90 to-transparent pointer-events-none"})]})]})}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-5xl mx-auto","aria-labelledby":"why-pillars-heading",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[d.jsx("h2",{id:"why-pillars-heading",className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"The CSV Meta difference"}),d.jsx("p",{className:"text-2xl md:text-3xl font-extrabold text-white mt-3 max-w-2xl mx-auto",children:"Everything you need to publish faster and rank higher"})]}),d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:a7e.map((r,i)=>{const a=r.icon;return d.jsxs(ks.article,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.45,delay:i*.07},className:"p-7 rounded-2xl border border-slate-200 dark:border-slate-700/60 bg-white dark:bg-white/5 hover:border-[#47ff72]/40 transition-colors group shadow-sm dark:shadow-none",children:[d.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#47ff72]/10 flex items-center justify-center text-[#47ff72] mb-4 group-hover:scale-110 transition-transform",children:d.jsx(a,{className:"w-6 h-6"})}),d.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-white mb-2",children:r.title}),d.jsx("p",{className:"text-slate-500 dark:text-slate-400 text-sm leading-relaxed",children:r.desc})]},r.title)})})]}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-6xl mx-auto","aria-labelledby":"tools-heading",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[d.jsx("h2",{id:"tools-heading",className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"6 tools, one workspace"}),d.jsx("p",{className:"text-2xl md:text-3xl font-extrabold text-white mt-3",children:"A complete microstock creative suite — not just another tagger"}),d.jsx("p",{className:"text-slate-400 mt-3 max-w-2xl mx-auto",children:"From AI metadata to vector editing, every tool is built for contributors who want to ship more assets with less friction."})]}),d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:r7e.map((r,i)=>{const a=r.icon;return d.jsxs(ks.article,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:i*.06},className:"p-5 rounded-2xl border border-slate-200 dark:border-slate-700/60 bg-white dark:bg-slate-900/40 hover:border-[#47ff72]/40 hover:bg-slate-50 dark:hover:bg-slate-900/60 transition-all shadow-sm dark:shadow-none",children:[d.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[d.jsx("div",{className:"w-10 h-10 rounded-lg bg-[#47ff72]/10 flex items-center justify-center text-[#47ff72] shrink-0",children:d.jsx(a,{className:"w-5 h-5"})}),d.jsx("h3",{className:"font-bold text-slate-900 dark:text-white",children:r.name})]}),d.jsx("p",{className:"text-slate-500 dark:text-slate-400 text-sm leading-relaxed",children:r.benefit})]},r.name)})}),d.jsx("div",{className:"text-center mt-10",children:d.jsxs(Is,{to:"/tools",className:"inline-flex items-center gap-2 text-[#47ff72] font-bold hover:underline underline-offset-4",children:["See full tool previews",d.jsx(fE,{className:"w-4 h-4"})]})})]}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-4xl mx-auto","aria-labelledby":"steps-heading",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[d.jsx("h2",{id:"steps-heading",className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"Get started in minutes"}),d.jsx("p",{className:"text-2xl md:text-3xl font-extrabold text-white mt-3",children:"Three steps to better metadata"})]}),d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:o7e.map((r,i)=>d.jsxs(ks.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.45,delay:i*.1},className:"text-center relative",children:[d.jsx("div",{className:"w-14 h-14 mx-auto mb-4 rounded-2xl bg-[#47ff72] text-slate-900 font-black text-xl flex items-center justify-center shadow-[0_0_20px_rgba(71,255,114,0.4)]",children:r.step}),d.jsx("h3",{className:"font-bold text-white text-lg mb-2",children:r.title}),d.jsx("p",{className:"text-slate-400 text-sm leading-relaxed",children:r.desc})]},r.step))})]}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-3xl mx-auto","aria-labelledby":"
7175comparison-heading",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-10",children:[d.jsx("h2",{id:"comparison-heading",className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"CSV Meta vs. manual workflow"}),d.jsx("p",{className:"text-2xl md:text-3xl font-extrabold text-white mt-3",children:"Why creators make the switch"})]}),d.jsxs(ks.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"rounded-2xl border border-slate-200 dark:border-slate-700/60 overflow-hidden bg-white dark:bg-slate-900/40 shadow-sm dark:shadow-none",children:[d.jsxs("div",{className:"grid grid-cols-[1fr_80px_80px] sm:grid-cols-[1fr_100px_100px] bg-slate-50 dark:bg-slate-800/50 border-b border-slate-200 dark:border-slate-700/60 text-sm font-bold",children:[d.jsx("div",{className:"px-4 py-3 text-slate-500 dark:text-slate-400",children:"Feature"}),d.jsx("div",{className:"px-2 py-3 text-center text-[#47ff72]",children:"CSV Meta"}),d.jsx("div",{className:"px-2 py-3 text-center text-slate-500 dark:text-slate-500",children:"Manual"})]}),l7e.map(r=>d.jsxs("div",{className:"grid grid-cols-[1fr_80px_80px] sm:grid-cols-[1fr_100px_100px] border-b border-slate-100 dark:border-slate-800/80 last:border-0 text-sm",children:[d.jsx("div",{className:"px-4 py-3.5 text-slate-700 dark:text-slate-300",children:r.label}),d.jsx("div",{className:"px-2 py-3.5 flex items-center justify-center",children:r.csvMeta?d.jsx(yd,{className:"w-5 h-5 text-[#47ff72]","aria-label":"Yes"}):d.jsx(Ki,{className:"w-5 h-5 text-slate-300 dark:text-slate-600","aria-label":"No"})}),d.jsx("div",{className:"px-2 py-3.5 flex items-center justify-center",children:r.manual?d.jsx(yd,{className:"w-5 h-5 text-slate-400 dark:text-slate-500","aria-label":"Yes"}):d.jsx(Ki,{className:"w-5 h-5 text-slate-300 dark:text-slate-600","aria-label":"No"})})]},r.label))]})]}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-5xl mx-auto","aria-labelledby":"testimonials-heading",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-10",children:[d.jsx("h2",{id:"testimonials-heading",className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"Loved by creators"}),d.jsx("p",{className:"text-2xl md:text-3xl font-extrabold text-white mt-3",children:"Real results from real contributors"})]}),d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:c7e.map((r,i)=>d.jsxs(ks.blockquote,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.45,delay:i*.08},className:"bg-white dark:bg-slate-800 p-6 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700",children:[d.jsx("div",{className:"flex text-yellow-400 mb-4 text-sm","aria-hidden":"true",children:"★★★★★"}),d.jsxs("p",{className:"text-slate-600 dark:text-slate-300 mb-6 text-sm leading-relaxed",children:["“",r.quote,"”"]}),d.jsxs("footer",{children:[d.jsx("cite",{className:"not-italic font-bold text-slate-900 dark:text-white",children:r.name}),d.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:r.role})]})]},r.name))})]}),d.jsxs("section",{className:"px-4 sm:px-6 lg:px-8 pb-20 max-w-3xl mx-auto","aria-labelledby":"faq-heading",children:[d.jsxs(ks.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-10",children:[d.jsx("h2",{id:"faq-heading",className:"text-sm font-bold text-[#47ff72] uppercase tracking-widest",children:"Frequently asked questions"}),d.jsx("p",{className:"text-2xl md:text-3xl font-extrabold text-white mt-3",children:"Still deciding? Start here."})]}),d.jsx("div",{className:"space-y-4",children:iae.map((r,i)=>d.jsxs(ks.details,{initial:{opacity:0,y:12},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:i*.05},className:"group rounded-2xl border border-slate-200 dark:border-slate-700/60 bg-white dark:bg-slate-800/50 open:border-[#47ff72]/30 transition-colors shadow-sm dark:shadow-none",children:[d.jsxs("summary",{className:"cursor-pointer list-none px-6 py-5 font-medium text-slate-800 dark:text-white flex items-center justify-between gap-4 [&::-webkit-details-marker]:hidden",children:[r.question,d.jsx("span",{className:"text-[#47ff72] text-xl shrink-0 group-open:rotate-45 transition-transform",children:"+"})]}
7175),d.jsx("p",{className:"px-6 pb-5 text-slate-600 dark:text-slate-400 text-sm leading-relaxed",children:r.answer})]},r.question))})]}),d.jsx("section",{className:"px-4 sm:px-6 lg:px-8 pb-24 max-w-5xl mx-auto",children:d.jsxs(ks.div,{initial:{opacity:0,y:24},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},className:"bg-white dark:bg-gradient-to-br dark:from-slate-900 dark:via-emerald-950/40 dark:to-slate-900 border border-slate-200 dark:border-[#47ff72]/30 rounded-3xl p-8 md:p-14 text-center relative overflow-hidden shadow-sm dark:shadow-[0_0_40px_rgba(71,255,114,0.1)]",children:[d.jsx("div",{className:"hidden dark:block absolute -top-32 -left-32 w-64 h-64 bg-[#47ff72] rounded-full mix-blend-overlay filter blur-[100px] opacity-40 animate-pulse pointer-events-none"}),d.jsx("div",{className:"hidden dark:block absolute -bottom-32 -right-32 w-64 h-64 bg-emerald-500 rounded-full mix-blend-overlay filter blur-[100px] opacity-40 pointer-events-none"}),d.jsxs("h2",{className:"text-3xl md:text-4xl font-extrabold text-slate-900 dark:text-white mb-4 relative z-10 leading-tight",children:["Ready to see why creators choose"," ",d.jsx("span",{className:"text-emerald-600 dark:text-[#47ff72]",children:"CSV Meta"}),"?"]}),d.jsx("p",{className:"text-lg text-slate-600 dark:text-slate-300 max-w-2xl mx-auto mb-8 relative z-10",children:"Join 200+ microstock contributors. Start with 50 free CSVBucks daily — generate metadata, embed vectors, and explore every tool in minutes."}),d.jsxs("div",{className:"relative z-10 flex flex-col sm:flex-row items-center justify-center gap-4",children:[d.jsxs("button",{onClick:s,className:"inline-flex items-center justify-center gap-2 px-8 py-4 font-bold text-slate-900 bg-[#47ff72] hover:bg-[#3ce565] transition-all rounded-xl shadow-[0_0_20px_rgba(71,255,114,0.4)] hover:shadow-[0_0_30px_rgba(71,255,114,0.6)] hover:-translate-y-1 w-full sm:w-auto",children:[d.jsx(vd,{className:"w-5 h-5"}),d.jsx("span",{children:e?"Open Tool Now":"Start Free — No Credit Card"})]}),d.jsxs("a",{href:"https://chromewebstore.google.com/detail/foliaahbfnegnbmclfomfeamfkmnncjm",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-8 py-4 border-2 border-slate-300 dark:border-slate-600 hover:border-[#47ff72] text-slate-800 dark:text-white rounded-xl font-bold transition-all w-full sm:w-auto",children:[d.jsx(Ua,{className:"w-5 h-5"}),d.jsx("span",{children:"Get Chrome Extension"})]})]}),d.jsxs("p",{className:"relative z-10 mt-6 text-sm text-slate-500 dark:text-slate-400",children:["Also see our"," ",d.jsx(Is,{to:"/pricing",className:"text-emerald-600 dark:text-[#47ff72] hover:underline underline-offset-4 font-medium",children:"pricing plans"})," ","or"," ",d.jsx(Is,{to:"/tools",className:"text-emerald-600 dark:text-[#47ff72] hover:underline underline-offset-4 font-medium",children:"full tools overview"}),"."]})]})})]}),d.jsx(AM,{})]})},tK=["#47ff72","#32cc59","#ffd700","#ff6b9d","#6ecbff","#ffffff","#a78bfa"];function nK(t,e,n){const s=Math.PI/3,i=(n==="left"?-Math.PI/6:Math.PI+Math.PI/6)+(Math.random()-.5)*s,a=4+Math.random()*8;return{x:t,y:e,vx:Math.cos(i)*a,vy:Math.sin(i)*a-2,size:4+Math.random()*6,color:tK[Math.floor(Math.random()*tK.length)],rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.3,opacity:1,shape:Math.random()>.5?"rect":"circle"}}const f7e=()=>{const t=q.useRef(null),e=q.useRef([]),n=q.useRef(0),s=q.useRef(0);return q.useEffect(()=>{const r=t.current;if(!r)return;const i=r.getContext("2d");if(!i)return;const a=()=>{r.width=window.innerWidth,r.height=window.innerHeight};a(),window.addEventListener("resize",a);const o=()=>{const h=r.height,p=h*.35+Math.random()*h*.3,m=h*.35+Math.random()*h*.3;for(let y=0;y<24;y++)e.current.push(nK(-10,p,"left")),e.current.push(nK(r.width+10,m,"right"))};o(),s.current=1;const l=window.setInterval(()=>{if(s.current>=6){clearInterval(l);return}o(),s.current+=1},400),c=()=>{i.clearRect(0,0,r.width,r.height),e.current=e.current.filter(h=>h.opacity>.05&&h.y<r.height+40);for(const h of e.current)h.x+=h.vx,h.y+=h.vy,h.vy+=.15,h.vx*=.99,h.rotation+=h.rotationSpeed,h.opacity*=.992,i.save(),i.globalAlpha=h.opacity,i.translate(h.x,h.y),i.rotate(h.rotation),i.fillStyle=h.color,h.shape==="rect"?i.fillRect(-h.size/2,-h.size/4,h.size,h.size/2):(i.beginPath(),i.arc(0,0,h.size/2,0,Math.PI*2),i.fill()),i.restore(
7175);n.current=requestAnimationFrame(c)};return n.current=requestAnimationFrame(c),()=>{window.removeEventListener("resize",a),clearInterval(l),cancelAnimationFrame(n.current)}},[]),d.jsx("canvas",{ref:t,className:"fixed inset-0 pointer-events-none z-10","aria-hidden":"true"})},p7e=5200,m7e=()=>{const t=co(),e=Qh(),[n]=lA(),s=e.state,r=(s==null?void 0:s.planName)??n.get("planName")??"Premium",[i,a]=q.useState(!0),[o,l]=q.useState(!1),[c,h]=q.useState(!1);return q.useEffect(()=>{if(!(s!=null&&s.planName)&&!n.get("planName")){t("/app",{replace:!0});return}zj(),$7(zv()??void 0),Wy();const p=Vm(Ko,async m=>{if(!m){t("/auth",{replace:!0});return}try{await OX(Td(Bc,"users",m.uid),{pendingPlanCelebration:jh(),pendingPlanCelebrationAt:jh()})}catch(y){console.warn("Could not clear pending celebration on success page",y)}try{await Vv(m)}catch(y){console.error("Error refreshing profile after checkout",y)}a(!1)});return()=>p()},[t,n,s==null?void 0:s.planName]),q.useEffect(()=>{if(i)return;const p=window.setTimeout(()=>l(!0),600),m=window.setTimeout(()=>h(!0),1800),y=window.setTimeout(()=>{qOe(r),t("/app",{replace:!0})},p7e);return()=>{clearTimeout(p),clearTimeout(m),clearTimeout(y)}},[i,t,r]),i?d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08]",children:d.jsx(Go,{className:"w-12 h-12 text-[#47ff72] animate-spin"})}):d.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08] text-slate-100 font-sans overflow-hidden relative",children:[d.jsx(f7e,{}),d.jsxs("div",{className:"relative z-20 text-center px-6 max-w-2xl",children:[o&&d.jsx(ks.h1,{initial:{opacity:0,y:24,filter:"blur(8px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.9,ease:[.22,1,.36,1]},className:"text-4xl sm:text-5xl md:text-6xl font-extrabold text-[#47ff72] tracking-tight",children:"Congratulations!"}),c&&d.jsxs(ks.p,{initial:{opacity:0,y:20,filter:"blur(6px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.9,ease:[.22,1,.36,1]},className:"mt-6 text-xl sm:text-2xl md:text-3xl font-semibold text-white/90 leading-snug",children:["You've Unlocked the"," ",d.jsx("span",{className:"text-[#47ff72]",children:r})," Plan!"]}),c&&d.jsx(ks.p,{initial:{opacity:0}
7175,animate:{opacity:1},transition:{delay:.6,duration:.6},className:"mt-8 text-sm text-slate-400",children:"Taking you to your workspace…"})]})]})},g7e=()=>{const t=co(),[e]=lA(),n=e.get("reason"),[s,r]=q.useState(!1);q.useEffect(()=>{$7(zv()??void 0),Wy();const a=window.setTimeout(()=>r(!0),300);return()=>clearTimeout(a)},[]);const i=n==="missing_invoice"?"We could not identify your payment session. Please try again from the pricing page.":n==="order_not_found"?"We could not find a matching order for this payment. If you were charged, contact support with your transaction details.":"Your payment could not be completed. No charges were applied to your plan.";return d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08] text-slate-100 font-sans overflow-hidden relative px-4",children:d.jsx("div",{className:"relative z-20 text-center max-w-lg",children:s?d.jsxs(ks.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},transition:{duration:.6},className:"space-y-6",children:[d.jsx("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:d.jsx(F0,{className:"w-8 h-8 text-red-400"})}),d.jsxs("div",{className:"space-y-3",children:[d.jsx("h1",{className:"text-3xl sm:text-4xl font-extrabold text-white tracking-tight",children:"Something went wrong"}),d.jsx("p",{className:"text-slate-400 leading-relaxed",children:i})]}),d.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3 pt-2",children:[d.jsxs("button",{onClick:()=>t("/pricing"),className:"inline-flex items-center gap-2 px-6 py-3 bg-[#47ff72] hover:bg-[#3ce565] text-slate-900 rounded-xl font-bold transition-colors",children:[d.jsx(HL,{className:"w-4 h-4"}),"Back to pricing"]}),d.jsx(Is,{to:"/",className:"inline-flex items-center gap-2 px-6 py-3 border border-slate-700 hover:border-slate-500 text-white rounded-xl font-medium transition-colors",children:"Go to homepage"})]})]}):d.jsx(Go,{className:"w-12 h-12 text-[#47ff72] animate-spin mx-auto"})})})},y7e=()=>{const t=co(),[e]=lA(),[n,s]=q.useState("verifying"),[r,i]=q.useState("Confirming your payment…");return q.useEffect(()=>{const a=ZQ(),o=dTe(e),l=eZ(e);if(e.get("cancelled")==="true"||e.get("cancel")==="true"||e.get("canceled")==="true"||o&&J4(o)&&!l){uz(),Wy(),t("/checkout/failed",{replace:!0});return}let h=!0;const p=()=>{uz()},m=b=>{if(!h)return;if(!(a||M7(b))){p(),t("/app",{replace:!0});return}P7(b),p(),s("pending")},y=()=>{const b=zv();if(b){m(b);return}if(a||o&&Lk(o)){p(),s("pending");return}p(),t("/checkout/failed?reason=missing_invoice",{replace:!0})};return(async()=>{if(!l){if(o&&Lk(o)){y();return}if(a){y();return}p(),t("/checkout/failed?reason=missing_invoice",{replace:!0});return}try{const b=await ZOe(l);if(!h)return;if(b.status==="NOT_FOUND"){if(a||o&&Lk(o)){m(l);return}p(),Wy(),t("/checkout/failed?reason=order_not_found",{replace:!0});return}const S=RA(b.status??o);if(hTe(S)){p(),Wy();const E=b.planName??"Premium";t(`/checkout/success?planName=${encodeURIComponent(E)}`,{replace:!0});return}if(J4(S)){p(),Wy(),t("/checkout/failed",{replace:!0});return}m(l)}catch{if(!h)return;if(o&&J4(o)){p(),Wy(),t("/checkout/failed",{replace:!0});return}if(a||o&&Lk(o)){y();return}i("Something went wrong while verifying your payment."),window.setTimeout(()=>{h&&(p(),t("/checkout/failed",{replace:!0}))},1800)}})(),()=>{h=!1}},[t,e]),n==="pending"?d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08] text-slate-100 font-sans px-4",children:d.jsx(N7,{onGoApp:()=>t("/app")})}):d.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[#011f08] text-slate-100 gap-4 px-4",children:[d.jsx(Go,{className:"w-12 h-12 text-[#47ff72] animate-spin"}),d.jsx("p",{className:"text-sm text-slate-400",children:r})]})},x7e=()=>{const t=co(),[e]=lA(),[n,s]=q.useState(!1);return q.useEffect(()=>{const r=eZ(e)??zv();if(!r){t("/",{replace:!0});return}if(!M7(r)){t("/",{replace:!0});return}P7(r),s(!0)},[t,e]),n?d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08] text-slate-100 font-sans overflow-hidden relative px-4",children:d.jsx(N7,{onGoApp:()=>t("/app")})}):d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#011f08]",children:d.jsx(Go,{className:"w-12 h-12 text-[#47ff72] animate-spin"})})},v7e=()=>{const{pathname:t}=Qh();return q.useEffect(()=>{"scrollRestoration"in history&&(history.scrollRestoration="manual")},[]),q.useEffect(()=>{window.scrollTo({top:0,left:0,behavior:"instant"})},[t]),null};function b7e(){const t=Qh(),e=co();return q.useEffect(()=>{if(t.pathname.startsWith("/payment/return")||t.pathname.startsWith("/checkout/"))return;const n=new URLSearchParams(t.search),s=uTe(n),r=ZQ(),i=zv();if(!s&&!r)return;if(!s&&r&&!i){e("/payment/return",{replace:!0});return}const a=new URLSearchParams(t.search);i&&!a.get("invoice_id")&&!a.get("invoiceId")&&a.set("invoice_id",i);const o=a.toString();e(`/payment/return${o?`?${o}`:""}`,{replace:!0})},[t.pathname,t.search,e]),null}const aae=document.getElementById("root");
7175if(!aae)throw new Error("Could not find root element to mount to");const w7e=Fde.createRoot(aae);w7e.render(d.jsx(WO.StrictMode,{children:d.jsxs(Vhe,{children:[d.jsx(v7e,{}),d.jsx(b7e,{}),d.jsxs($he,{children:[d.jsx(Gl,{path:"/",element:d.jsx(yTe,{})}),d.jsx(Gl,{path:"/auth",element:d.jsx(xTe,{})}),d.jsx(Gl,{path:"/app",element:d.jsx(gLe,{})}),d.jsx(Gl,{path:"/checkout/success",element:d.jsx(m7e,{})}),d.jsx(Gl,{path:"/checkout/failed",element:d.jsx(g7e,{})}),d.jsx(Gl,{path:"/payment/return",element:d.jsx(y7e,{})}),d.jsx(Gl,{path:"/payment/pending",element:d.jsx(x7e,{})}),d.jsx(Gl,{path:"/pricing",element:d.jsx(YLe,{})}),d.jsx(Gl,{path:"/tools",element:d.jsx(n7e,{})}),d.jsx(Gl,{path:"/why-csv-meta",element:d.jsx(h7e,{})}),d.jsx(Gl,{path:"/privacy-policy",element:d.jsx(yLe,{})}),d.jsx(Gl,{path:"/terms-of-service",element:d.jsx(xLe,{})}),d.jsx(Gl,{path:"/promptgen-privacy-policy",element:d.jsx(vLe,{})}),d.jsx(Gl,{path:"*",element:d.jsx(bLe,{})})]})]})}));export{Fne as _};

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