@fleox/agentphoto 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +177 -72
  2. package/changelog.json +18 -0
  3. package/dist/agent/agentphoto.mjs +64 -17
  4. package/dist/agent/chunks/{assets-CDQo3VqD.mjs → assets-BZVUUHjg.mjs} +3 -3
  5. package/dist/agent/chunks/{context-DoLoLF9f.mjs → context-CNpRboiC.mjs} +1 -1
  6. package/dist/agent/chunks/{doc-BjY_j4Su.mjs → doc-D_v_yE07.mjs} +25 -286
  7. package/dist/agent/chunks/{export-CLmpFART.mjs → export-aNJcPNbJ.mjs} +1 -1
  8. package/dist/agent/chunks/geometry-BKIhUO9x.mjs +315 -0
  9. package/dist/agent/chunks/{models-C4i_hicr.mjs → models-CxrjmA0W.mjs} +1 -1
  10. package/dist/agent/chunks/{package-DSmAxrla.mjs → package-Cu1GyvKL.mjs} +2 -2
  11. package/dist/agent/chunks/{project-CUykGysG.mjs → project-o1DH2nOw.mjs} +12 -10
  12. package/dist/agent/chunks/{templates--YGpGuHh.mjs → templates-BJ2me4XZ.mjs} +24 -3
  13. package/dist/agent/chunks/{tools-Dnh8g6F9.mjs → tools-DKaAPEV5.mjs} +92 -27
  14. package/dist/agent/chunks/{tree-DO7N0UDV.mjs → tree-D8qZKPAb.mjs} +2 -2
  15. package/dist/engine/agentphoto-engine.js +408 -352
  16. package/dist/studio/assets/index-CmOzzoXv.css +1 -0
  17. package/dist/studio/assets/index-D3Iw5q8v.js +28 -0
  18. package/dist/studio/assets/{transformers.web-DgnCIB_X.js → transformers.web-osEqoMhg.js} +1 -1
  19. package/dist/studio/index.html +2 -2
  20. package/dist/studio/templates/index.json +1 -1
  21. package/dist/studio/templates/product-white/photo.json +2 -2
  22. package/dist/studio/templates/product-white/preview.jpg +0 -0
  23. package/dist/studio/templates/product-white/template.json +1 -1
  24. package/package.json +2 -2
  25. package/plugin/.claude-plugin/plugin.json +1 -1
  26. package/plugin/skills/agentphoto-cutout/SKILL.md +30 -25
  27. package/plugin/skills/agentphoto-design/SKILL.md +24 -24
  28. package/plugin/skills/agentphoto-publish/SKILL.md +10 -10
  29. package/plugin/skills/agentphoto-retouch/SKILL.md +26 -26
  30. package/plugin/skills/agentphoto-retouch/references/filters.md +1 -1
  31. package/plugin/skills/agentphoto-retouch/references/patch-ops.md +14 -13
  32. package/plugin/skills/agentphoto-retouch/references/recipes.md +3 -3
  33. package/templates/product-white/photo.json +2 -2
  34. package/templates/product-white/preview.jpg +0 -0
  35. package/templates/product-white/template.json +1 -1
  36. package/dist/studio/assets/index-Be8JnaFy.js +0 -28
  37. package/dist/studio/assets/index-DwPms2S5.css +0 -1
@@ -0,0 +1,28 @@
1
+ var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var i=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var ee=Array.isArray;function te(){}var C={H:null,A:null,T:null,S:null},w=Object.prototype.hasOwnProperty;function T(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ne(e,t){return T(e.type,t,e.props)}function re(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ie(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ae=/\/+/g;function oe(e,t){return typeof e==`object`&&e&&e.key!=null?ie(``+e.key):t.toString(36)}function se(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(te,te):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ce(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ce(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+oe(e,0):a,ee(o)?(i=``,c!=null&&(i=c.replace(ae,`$&/`)+`/`),ce(o,r,i,``,function(e){return e})):o!=null&&(re(o)&&(o=ne(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ae,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(ee(e))for(var u=0;u<e.length;u++)a=e[u],s=l+oe(a,u),c+=ce(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+oe(a,u++),c+=ce(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ce(se(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function le(e,t,n){if(e==null)return e;var r=[],i=0;return ce(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ue(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var de=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function fe(e){var t=C.T,n={};n.types=t===null?null:t.types,C.T=n;try{var r=e(),i=C.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(te,de)}catch(e){de(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),C.T=t}}function pe(e){var t=C.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else fe(pe.bind(null,e))}var me={map:le,forEach:function(e,t,n){le(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return le(e,function(){t++}),t},toArray:function(e){return le(e,function(e){return e})||[]},only:function(e){if(!re(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=me,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.H.useMemoCache(e)}},e.addTransitionType=pe,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!w.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return T(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)w.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return T(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=re,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ue}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=fe,e.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},e.use=function(e){return C.H.use(e)},e.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},e.useCallback=function(e,t){return C.H.useCallback(e,t)},e.useContext=function(e){return C.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return C.H.useEffect(e,t)},e.useEffectEvent=function(e){return C.H.useEffectEvent(e)},e.useId=function(){return C.H.useId()},e.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return C.H.useMemo(e,t)},e.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},e.useRef=function(e){return C.H.useRef(e)},e.useState=function(e){return C.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return C.H.useTransition()},e.version=`19.3.1`})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ne());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}}var S=!1,ee=-1,te=5,C=-1;function w(){return g?!0:!(e.unstable_now()-C<te)}function T(){if(g=!1,S){var t=e.unstable_now();C=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(ee),ee=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&w());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(T)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=T,ne=function(){ie.postMessage(null)}}else ne=function(){_(T,0)};function ae(t,n){ee=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):te=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(ee),ee=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),s=t(((e,t)=>{t.exports=o()})),c=t((e=>{var t=a();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=i.p;try{if(u.T=null,i.p=2,e)return e()}finally{u.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.1`})),l=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=c()})),u=t((e=>{var t=s(),n=a(),r=l();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(c(e)!==e)throw Error(i(188))}function p(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return f(a),e;if(o===r)return f(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var s=!1,l=a.child;l;){if(l===n){s=!0,n=a,r=o;break}if(l===r){s=!0,r=a,n=o;break}l=l.sibling}if(!s){for(l=o.child;l;){if(l===n){s=!0,n=o,r=a;break}if(l===r){s=!0,r=o,n=a;break}l=l.sibling}if(!s)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function ee(e,t,n){return e===n||e===t&&(x=e,!0)}function te(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function C(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function w(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var T=Object.assign,ne=Symbol.for(`react.element`),re=Symbol.for(`react.transitional.element`),ie=Symbol.for(`react.portal`),ae=Symbol.for(`react.fragment`),oe=Symbol.for(`react.strict_mode`),se=Symbol.for(`react.profiler`),ce=Symbol.for(`react.consumer`),le=Symbol.for(`react.context`),ue=Symbol.for(`react.forward_ref`),de=Symbol.for(`react.suspense`),fe=Symbol.for(`react.suspense_list`),pe=Symbol.for(`react.memo`),me=Symbol.for(`react.lazy`),he=Symbol.for(`react.activity`),ge=Symbol.for(`react.legacy_hidden`),_e=Symbol.for(`react.memo_cache_sentinel`),ve=Symbol.for(`react.view_transition`),ye=Symbol.for(`react.recoverable`),be=Symbol.iterator;function xe(e){return typeof e!=`object`||!e?null:(e=be&&e[be]||e[`@@iterator`],typeof e==`function`?e:null)}var Se=Symbol.for(`react.client.reference`);function Ce(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===Se?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case ae:return`Fragment`;case se:return`Profiler`;case oe:return`StrictMode`;case de:return`Suspense`;case fe:return`SuspenseList`;case he:return`Activity`;case ve:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ie:return`Portal`;case le:return e.displayName||`Context`;case ce:return(e._context.displayName||`Context`)+`.Consumer`;case ue:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case pe:return t=e.displayName||null,t===null?Ce(e.type)||`Memo`:t;case me:t=e._payload,e=e._init;try{return Ce(e(t))}catch{}}return null}var we=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Te={pending:!1,data:null,method:null,action:null},Ee=[],De=-1;function Oe(e){return{current:e}}function ke(e){0>De||(e.current=Ee[De],Ee[De]=null,De--)}function Ae(e,t){De++,Ee[De]=e.current,e.current=t}var je=Oe(null),Me=Oe(null),Ne=Oe(null),Pe=Oe(null);function Fe(e,t){switch(Ae(Ne,t),Ae(Me,e),Ae(je,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ke(je),Ae(je,e)}function O(){ke(je),ke(Me),ke(Ne)}function k(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,Ae(Pe,e)),t=je.current;var n=dp(t,e.type);t!==n&&(Ae(Me,e),Ae(je,n))}function Ie(e){Me.current===e&&(ke(je),ke(Me)),Pe.current===e&&(ke(Pe),sh._currentValue=Te)}var Le,Re;function ze(e){if(Le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Le=t&&t[1]||``,Re=-1<e.stack.indexOf(`
2
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
3
+ `+Le+e+Re}var Be=!1;function Ve(e,t){if(!e||Be)return``;Be=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
4
+ `),l=s.split(`
5
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
6
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Be=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ze(n):``}function He(e,t){switch(e.tag){case 26:case 27:case 5:return ze(e.type);case 16:return ze(`Lazy`);case 13:return e.child!==t&&t!==null?ze(`Suspense Fallback`):ze(`Suspense`);case 19:return ze(`SuspenseList`);case 0:case 15:return Ve(e.type,!1);case 11:return Ve(e.type.render,!1);case 1:return Ve(e.type,!0);case 31:return ze(`Activity`);case 30:return ze(`ViewTransition`);default:return``}}function Ue(e){try{var t=``,n=null;do t+=He(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
7
+ Error generating stack: `+e.message+`
8
+ `+e.stack}}var We=Object.prototype.hasOwnProperty,Ge=t.unstable_scheduleCallback,Ke=t.unstable_cancelCallback,qe=t.unstable_shouldYield,Je=t.unstable_requestPaint,Ye=t.unstable_now,Xe=t.unstable_getCurrentPriorityLevel,Ze=t.unstable_ImmediatePriority,Qe=t.unstable_UserBlockingPriority,$e=t.unstable_NormalPriority,et=t.unstable_LowPriority,tt=t.unstable_IdlePriority,nt=t.log,rt=t.unstable_setDisableYieldValue,it=null,at=null;function ot(e){if(typeof nt==`function`&&rt(e),at&&typeof at.setStrictMode==`function`)try{at.setStrictMode(it,e)}catch{}}var st=Math.clz32?Math.clz32:ut,ct=Math.log,lt=Math.LN2;function ut(e){return e>>>=0,e===0?32:31-(ct(e)/lt|0)|0}var dt=256,ft=262144,pt=4194304;function mt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ht(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=mt(n))):i=mt(o):i=mt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=mt(n))):i=mt(o)):i=mt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function gt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function _t(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-st(n),i=1<<r;t|=e[r],n&=~i}return t}function vt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+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 yt(){var e=pt;return pt<<=1,!(pt&62914560)&&(pt=4194304),e}function bt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function xt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function St(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-st(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ct(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ct(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-st(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function wt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-st(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Tt(e,t){var n=t&-t;return n=n&42?1:Et(n),(n&(e.suspendedLanes|t))===0?n:0}function Et(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Dt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ot(){var e=D.p;return e===0?(e=window.event,e===void 0?32:Ch(e.type)):e}function kt(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}var At=Math.random().toString(36).slice(2),jt=`__reactFiber$`+At,Mt=`__reactProps$`+At,Nt=`__reactContainer$`+At,Pt=`__reactEvents$`+At,Ft=`__reactListeners$`+At,It=`__reactHandles$`+At,Lt=`__reactResources$`+At,Rt=`__reactMarker$`+At,zt=`__reactLoad$`+At;function Bt(e){delete e[jt],delete e[Mt],delete e[Ft],delete e[It]}function Vt(e){var t;if(t=e[jt])return t;for(var n=e.parentNode;n;){if(t=n[Nt]||n[jt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=fm(e);e!==null;){if(n=e[jt])return n;e=fm(e)}return t}e=n,n=e.parentNode}return null}function Ht(e){if(e=e[jt]||e[Nt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Ut(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Wt(e){var t=e[Lt];return t||=e[Lt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Gt(e){e[Rt]=!0}function Kt(e){e[zt]=void 0}var qt=new Set,Jt={};function Yt(e,t){Xt(e,t),Xt(e+`Capture`,t)}function Xt(e,t){for(Jt[e]=t,e=0;e<t.length;e++)qt.add(t[e])}var Zt=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]*$`),Qt={},$t={};function en(e){return We.call($t,e)?!0:We.call(Qt,e)?!1:Zt.test(e)?$t[e]=!0:(Qt[e]=!0,!1)}var tn=!1;function nn(){var e=tn;return tn=!1,e}function rn(e,t,n){if(en(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function an(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function on(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function sn(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function cn(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function ln(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function un(e){if(!e._valueTracker){var t=cn(e)?`checked`:`value`;e._valueTracker=ln(e,t,``+e[t])}}function dn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=cn(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var fn=/[\n"\\]/g;function pn(e){return e.replace(fn,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function mn(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+sn(t)):e.value!==``+sn(t)&&(e.value=``+sn(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):gn(e,sn(n)):o===`number`&&e.value==t?gn(e,sn(e.value)):gn(e,sn(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+sn(s):e.removeAttribute(`name`)}function hn(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){un(e);return}n=n==null?``:``+sn(n),t=t==null?n:``+sn(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),un(e)}function gn(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function _n(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+sn(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function vn(e,t,n){t!=null&&(t=``+sn(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+sn(n)}function yn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(we(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=sn(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),un(e)}function bn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var xn=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 Sn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||xn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Cn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,tn=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(Sn(e,a,r),tn=!0)}else for(var o in t)t.hasOwnProperty(o)&&Sn(e,o,t[o])}function wn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Tn=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`],[`colorRendering`,`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`],[`maskType`,`mask-type`],[`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`]]),En=/^[\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 Dn(e){return En.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function On(){}var kn=null;function An(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var jn=null,Mn=null;function Nn(e){var t=Ht(e);if(t&&(e=t.stateNode)){var n=e[Mt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(mn(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+pn(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Mt]||null;if(!a)throw Error(i(90));mn(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&dn(r)}break a;case`textarea`:vn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&_n(e,!!n.multiple,t,!1)}}}var Pn=!1;function Fn(e,t,n){if(Pn)return e(t,n);Pn=!0;try{return e(t)}finally{if(Pn=!1,(jn!==null||Mn!==null)&&(Ld(),jn&&(t=jn,e=Mn,Mn=jn=null,Nn(t),e)))for(t=0;t<e.length;t++)Nn(e[t])}}function In(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Mt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Ln=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Rn=!1;if(Ln)try{var zn={};Object.defineProperty(zn,"passive",{get:function(){Rn=!0}}),window.addEventListener(`test`,zn,zn),window.removeEventListener(`test`,zn,zn)}catch{Rn=!1}var Bn=null,Vn=null,Hn=null;function Un(){if(Hn)return Hn;var e,t=Vn,n=t.length,r,i=`value`in Bn?Bn.value:Bn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Hn=i.slice(e,1<r?1-r:void 0)}function Wn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Gn(){return!0}function Kn(){return!1}function qn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Gn:Kn,this.isPropagationStopped=Kn,this}return T(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Gn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Gn)},persist:function(){},isPersistent:Gn}),t}var Jn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yn=qn(Jn),Xn=T({},Jn,{view:0,detail:0}),Zn=qn(Xn),Qn,$n,er,tr=T({},Xn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:fr,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==er&&(er&&e.type===`mousemove`?(Qn=e.screenX-er.screenX,$n=e.screenY-er.screenY):$n=Qn=0,er=e),Qn)},movementY:function(e){return`movementY`in e?e.movementY:$n}}),nr=qn(tr),rr=qn(T({},tr,{dataTransfer:0})),ir=qn(T({},Xn,{relatedTarget:0})),ar=qn(T({},Jn,{animationName:0,elapsedTime:0,pseudoElement:0})),or=qn(T({},Jn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),sr=qn(T({},Jn,{data:0})),cr={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},lr={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`},ur={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function dr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ur[e])?!!t[e]:!1}function fr(){return dr}var pr=qn(T({},Xn,{key:function(e){if(e.key){var t=cr[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Wn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?lr[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:fr,charCode:function(e){return e.type===`keypress`?Wn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Wn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),mr=qn(T({},tr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),hr=qn(T({},Jn,{submitter:0})),gr=qn(T({},Xn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:fr})),_r=qn(T({},Jn,{propertyName:0,elapsedTime:0,pseudoElement:0})),vr=qn(T({},tr,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),yr=qn(T({},Jn,{newState:0,oldState:0,source:0})),br=[9,13,27,32],xr=Ln&&`CompositionEvent`in window,Sr=null;Ln&&`documentMode`in document&&(Sr=document.documentMode);var Cr=Ln&&`TextEvent`in window&&!Sr,wr=Ln&&(!xr||Sr&&8<Sr&&11>=Sr),Tr=` `,Er=!1;function Dr(e,t){switch(e){case`keyup`:return br.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Or(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var A=!1;function kr(e,t){switch(e){case`compositionend`:return Or(t);case`keypress`:return t.which===32?(Er=!0,Tr):null;case`textInput`:return e=t.data,e===Tr&&Er?null:e;default:return null}}function Ar(e,t){if(A)return e===`compositionend`||!xr&&Dr(e,t)?(e=Un(),Hn=Vn=Bn=null,A=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return wr&&t.locale!==`ko`?null:t.data;default:return null}}var jr={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 Mr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!jr[e.type]:t===`textarea`}function Nr(e,t,n,r){jn?Mn?Mn.push(r):Mn=[r]:jn=r,t=qf(t,`onChange`),0<t.length&&(n=new Yn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Pr=null,Fr=null;function Ir(e){Bf(e,0)}function Lr(e){if(dn(Ut(e)))return e}function Rr(e,t){if(e===`change`)return t}var zr=!1;if(Ln){var Br;if(Ln){var j=`oninput`in document;if(!j){var Vr=document.createElement(`div`);Vr.setAttribute(`oninput`,`return;`),j=typeof Vr.oninput==`function`}Br=j}else Br=!1;zr=Br&&(!document.documentMode||9<document.documentMode)}function Hr(){Pr&&(Pr.detachEvent(`onpropertychange`,Ur),Fr=Pr=null)}function Ur(e){if(e.propertyName===`value`&&Lr(Fr)){var t=[];Nr(t,Fr,e,An(e)),Fn(Ir,t)}}function Wr(e,t,n){e===`focusin`?(Hr(),Pr=t,Fr=n,Pr.attachEvent(`onpropertychange`,Ur)):e===`focusout`&&Hr()}function Gr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Lr(Fr)}function Kr(e,t){if(e===`click`)return Lr(t)}function qr(e,t){if(e===`input`||e===`change`)return Lr(t)}function Jr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Yr=typeof Object.is==`function`?Object.is:Jr;function Xr(e,t){if(Yr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!We.call(t,i)||!Yr(e[i],t[i]))return!1}return!0}function Zr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Qr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function $r(e,t){var n=Qr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Qr(n)}}function ei(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ei(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ti(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Zr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Zr(e.document)}return t}function ni(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var ri=Ln&&`documentMode`in document&&11>=document.documentMode,ii=null,ai=null,oi=null,si=!1;function ci(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;si||ii==null||ii!==Zr(r)||(r=ii,`selectionStart`in r&&ni(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),oi&&Xr(oi,r)||(oi=r,r=qf(ai,`onSelect`),0<r.length&&(t=new Yn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=ii)))}function li(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ui={animationend:li(`Animation`,`AnimationEnd`),animationiteration:li(`Animation`,`AnimationIteration`),animationstart:li(`Animation`,`AnimationStart`),transitionrun:li(`Transition`,`TransitionRun`),transitionstart:li(`Transition`,`TransitionStart`),transitioncancel:li(`Transition`,`TransitionCancel`),transitionend:li(`Transition`,`TransitionEnd`)},di={},fi={};Ln&&(fi=document.createElement(`div`).style,`AnimationEvent`in window||(delete ui.animationend.animation,delete ui.animationiteration.animation,delete ui.animationstart.animation),`TransitionEvent`in window||delete ui.transitionend.transition);function pi(e){if(di[e])return di[e];if(!ui[e])return e;var t=ui[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in fi)return di[e]=t[n];return e}var mi=pi(`animationend`),hi=pi(`animationiteration`),gi=pi(`animationstart`),_i=pi(`transitionrun`),vi=pi(`transitionstart`),yi=pi(`transitioncancel`),bi=pi(`transitionend`),xi=new Map,Si=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError 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 toggle touchMove waiting wheel`.split(` `);Si.push(`scrollEnd`);function Ci(e,t){xi.set(e,t),Yt(t,[e])}var wi=0;function Ti(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=vd.identifierPrefix;var n=wi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function Ei(e){if(e==null||typeof e==`string`)return e;var t=null,n=Ed;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function Di(e,t){return e=Ei(e),t=Ei(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var Oi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ki=[],Ai=0,ji=0;function Mi(){for(var e=Ai,t=ji=Ai=0;t<e;){var n=ki[t];ki[t++]=null;var r=ki[t];ki[t++]=null;var i=ki[t];ki[t++]=null;var a=ki[t];if(ki[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Fi(n,i,a)}}function M(e,t,n,r){ki[Ai++]=e,ki[Ai++]=t,ki[Ai++]=n,ki[Ai++]=r,ji|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Ni(e,t,n,r){return M(e,t,n,r),Ii(e)}function Pi(e,t){return M(e,null,null,t),Ii(e)}function Fi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-st(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Ii(e){if(50<Dd)throw Dd=0,Od=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Li={};function Ri(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zi(e,t,n,r){return new Ri(e,t,n,r)}function Bi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vi(e,t){var n=e.alternate;return n===null?(n=zi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Hi(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ui(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Bi(r)&&(s=1);else if(typeof r==`string`)s=qm(e,n,je.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case he:return e=zi(31,n,t,a),e.elementType=he,e.lanes=o,e;case ae:return Wi(n.children,a,o,t);case oe:s=8,a|=24;break;case se:return e=zi(12,n,t,a|2),e.elementType=se,e.lanes=o,e;case de:return e=zi(13,n,t,a),e.elementType=de,e.lanes=o,e;case fe:return e=zi(19,n,t,a),e.elementType=fe,e.lanes=o,e;case ge:case ve:return e=a|32,e=zi(30,n,t,e),e.elementType=ve,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case le:s=10;break a;case ce:s=9;break a;case ue:s=11;break a;case pe:s=14;break a;case me:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=zi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Wi(e,t,n,r){return e=zi(7,e,r,t),e.lanes=n,e}function Gi(e,t,n){return e=zi(6,e,null,t),e.lanes=n,e}function Ki(e){var t=zi(18,null,null,0);return t.stateNode=e,t}function qi(e,t,n){return t=zi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ji=new WeakMap;function Yi(e,t){if(typeof e==`object`&&e){var n=Ji.get(e);return n===void 0?(t={value:e,source:t,stack:Ue(t)},Ji.set(e,t),t):n}return{value:e,source:t,stack:Ue(t)}}var Xi=[],Zi=0,Qi=null,$i=0,ea=[],ta=0,na=null,ra=1,ia=``;function aa(e,t){Xi[Zi++]=$i,Xi[Zi++]=Qi,Qi=e,$i=t}function oa(e,t,n){ea[ta++]=ra,ea[ta++]=ia,ea[ta++]=na,na=e;var r=ra;e=ia;var i=32-st(r)-1;r&=~(1<<i),n+=1;var a=32-st(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ra=1<<32-st(t)+i|n<<i|r,ia=a+e}else ra=1<<a|n<<i|r,ia=e}function sa(e){e.return!==null&&(aa(e,1),oa(e,1,0))}function ca(e){for(;e===Qi;)Qi=Xi[--Zi],Xi[Zi]=null,$i=Xi[--Zi],Xi[Zi]=null;for(;e===na;)na=ea[--ta],ea[ta]=null,ia=ea[--ta],ea[ta]=null,ra=ea[--ta],ea[ta]=null}function la(e,t){ea[ta++]=ra,ea[ta++]=ia,ea[ta++]=na,ra=t.id,ia=t.overflow,na=e}var ua=null,N=null,P=!1,da=null,fa=!1,pa=Error(i(519));function ma(e){throw ba(Yi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),pa}function ha(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[jt]=e,t[Mt]=r,n){case`dialog`:$(`cancel`,t),$(`close`,t);break;case`iframe`:case`object`:case`embed`:$(`load`,t);break;case`video`:case`audio`:for(n=0;n<Rf.length;n++)$(Rf[n],t);break;case`source`:$(`error`,t);break;case`img`:case`image`:case`link`:$(`error`,t),$(`load`,t);break;case`details`:$(`toggle`,t);break;case`input`:$(`invalid`,t),hn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:$(`invalid`,t);break;case`textarea`:$(`invalid`,t),yn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||$f(t.textContent,n)?(r.popover!=null&&($(`beforetoggle`,t),$(`toggle`,t)),r.onScroll!=null&&$(`scroll`,t),r.onScrollEnd!=null&&$(`scrollend`,t),r.onClick!=null&&(t.onclick=On),t=!0):t=!1,t||ma(e,!0)}function ga(e){for(ua=e.return;ua;)switch(ua.tag){case 5:case 31:case 13:fa=!1;return;case 27:case 3:fa=!0;return;default:ua=ua.return}}function _a(e){if(e!==ua)return!1;if(!P)return ga(e),P=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||pp(e.type,e.memoizedProps)),n=!n),n&&N&&ma(e),ga(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));N=dm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));N=dm(e)}else t===27?(t=N,Sp(e.type)?(e=um,um=null,N=e):N=t):N=ua?lm(e.stateNode.nextSibling):null;return!0}function va(){N=ua=null,P=!1}function ya(){var e=da;return e!==null&&(ud===null?ud=e:ud.push.apply(ud,e),da=null),e}function ba(e){da===null?da=[e]:da.push(e)}var xa=Oe(null),Sa=null,Ca=null;function wa(e,t,n){Ae(xa,t._currentValue),t._currentValue=n}function Ta(e){e._currentValue=xa.current,ke(xa)}function Ea(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Da(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ea(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ea(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),Ea(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Oa(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Yr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Pe.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[sh]:e.push(sh))}a=a.return}return e!==null&&Da(t,e,n,r),t.flags|=262144,e!==null}function ka(e){for(e=e.firstContext;e!==null;){if(!Yr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Aa(e){Sa=e,Ca=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ja(e){return Na(Sa,e)}function Ma(e,t){return Sa===null&&Aa(e),Na(e,t)}function Na(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ca===null){if(e===null)throw Error(i(308));Ca=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ca=Ca.next=t;return n}var Pa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Fa=t.unstable_scheduleCallback,Ia=t.unstable_NormalPriority,La={$$typeof:le,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ra(){return{controller:new Pa,data:new Map,refCount:0}}function za(e){e.refCount--,e.refCount===0&&Fa(Ia,function(){e.controller.abort()})}function Ba(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Va=null;function Ha(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Ua=null,Wa=0,Ga=0,Ka=null;function qa(e,t){if(Ua===null){var n=Ua=[];Wa=0,Ga=Nf(),Ka={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Wa++,t.then(Ja,Ja),t}function Ja(){if(--Wa===0&&(Va=null,Ua!==null)){Ka!==null&&(Ka.status=`fulfilled`);var e=Ua;Ua=null,Ga=0,Ka=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ya(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Xa=E.S;E.S=function(e,t){if(pd=Ye(),typeof t==`object`&&t&&typeof t.then==`function`&&qa(e,t),Va!==null)for(var n=yf;n!==null;)Ba(n,Va),n=n.next;if(n=e.types,n!==null){for(var r=yf;r!==null;)Ba(r,n),r=r.next;if(Ga!==0){r=Va,r===null&&(r=Va=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Xa!==null&&Xa(e,t)};var Za=Oe(null);function Qa(){var e=Za.current;return e===null?Zu.pooledCache:e}function $a(e,t){t===null?Ae(Za,Za.current):Ae(Za,t.pool)}function eo(){var e=Qa();return e===null?null:{parent:La._currentValue,pool:e}}var to=Error(i(460)),no=Error(i(474)),ro=Error(i(542)),io={then:function(){}};function ao(e){return e=e.status,e===`fulfilled`||e===`rejected`}function oo(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(On,On),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,uo(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(On,On);else{if(e=Zu,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,uo(e),e}throw co=t,to}}function so(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(co=e,to):e}}var co=null;function lo(){if(co===null)throw Error(i(459));var e=co;return co=null,e}function uo(e){if(e===to||e===ro)throw Error(i(483))}var fo=null,po=0;function F(e){var t=po;return po+=1,fo===null&&(fo=[]),oo(fo,e,t)}function mo(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ho(e,t){throw t.$$typeof===ne?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function go(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Vi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Gi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===ae?(e=d(e,t,n.props.children,r,n.key),mo(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===me&&so(i)===t.type)?(t=a(t,n.props),mo(t,n),t.return=e,t):(t=Ui(n.type,n.key,n.props,null,e.mode,r),mo(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=qi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Wi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Gi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case re:return n=Ui(t.type,t.key,t.props,null,e.mode,n),mo(n,t),n.return=e,n;case ie:return t=qi(t,e.mode,n),t.return=e,t;case me:return t=so(t),f(e,t,n)}if(we(t)||xe(t))return t=Wi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,F(t),n);if(t.$$typeof===le)return f(e,Ma(e,t),n);ho(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case re:return n.key===i?l(e,t,n,r):null;case ie:return n.key===i?u(e,t,n,r):null;case me:return n=so(n),p(e,t,n,r)}if(we(n)||xe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,F(n),r);if(n.$$typeof===le)return p(e,t,Ma(e,n),r);ho(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case re:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case ie:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case me:return r=so(r),m(e,t,n,r,i)}if(we(r)||xe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,F(r),i);if(r.$$typeof===le)return m(e,t,n,Ma(t,r),i);ho(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),P&&aa(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return P&&aa(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),P&&aa(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),P&&aa(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return P&&aa(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),P&&aa(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===ae&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case re:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===ae){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),mo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===me&&so(l)===r.type){n(e,r.sibling),c=a(r,o.props),mo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===ae?(c=Wi(o.props.children,e.mode,c,o.key),mo(c,o),c.return=e,e=c):(c=Ui(o.type,o.key,o.props,null,e.mode,c),mo(c,o),c.return=e,e=c)}return s(e);case ie:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=qi(o,e.mode,c),c.return=e,e=c}return s(e);case me:return o=so(o),_(e,r,o,c)}if(we(o))return h(e,r,o,c);if(xe(o)){if(l=xe(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,F(o),c);if(o.$$typeof===le)return _(e,r,Ma(e,o),c);ho(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Gi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{po=0;var i=_(e,t,n,r);return fo=null,i}catch(t){if(t===to||t===ro)throw t;var a=zi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var _o=go(!0),vo=go(!1),yo=!1;function bo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function So(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Co(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Y&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ii(e),Fi(e,null,n),t}return M(e,r,t,n),Ii(e)}function wo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,wt(e,n)}}function To(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Eo=!1;function Do(){if(Eo){var e=Ka;if(e!==null)throw e}}function Oo(e,t,n,r){Eo=!1;var i=e.updateQueue;yo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Z&f)===f:(r&f)===f){f!==0&&f===Ga&&(Eo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=T({},d,f);break a;case 2:yo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Q|=o,e.lanes=o,e.memoizedState=d}}function ko(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ao(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)ko(n[e],t)}var jo=Oe(null),Mo=Oe(0);function No(e,t){e=rd,Ae(Mo,e),Ae(jo,t),rd=e|t.baseLanes}function Po(){Ae(Mo,rd),Ae(jo,jo.current)}function Fo(){rd=Mo.current,ke(jo),ke(Mo)}var Io=Oe(null),Lo=null;function Ro(e){var t=e.alternate;Ae(Uo,Uo.current&1),Ae(Io,e),Lo===null&&(t===null||jo.current!==null||t.memoizedState!==null)&&(Lo=e)}function zo(e){Ae(Uo,Uo.current),Ae(Io,e),Lo===null&&(Lo=e)}function Bo(e){e.tag===22?(Ae(Uo,Uo.current),Ae(Io,e),Lo===null&&(Lo=e)):Vo()}function Vo(){Ae(Uo,Uo.current),Ae(Io,Io.current)}function Ho(e){ke(Io),Lo===e&&(Lo=null),ke(Uo)}var Uo=Oe(0);function Wo(e,t){Ae(Io,Io.current),Ae(Uo,t)}function Go(e){ke(Uo),ke(Io),Lo===e&&(Lo=null)}function Ko(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||om(n)||sm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var qo=0,I=null,Jo=null,Yo=null,Xo=!1,Zo=!1,Qo=!1,$o=0,es=0,ts=null,ns=0;function rs(){throw Error(i(321))}function is(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Yr(e[n],t[n]))return!1;return!0}function as(e,t,n,r,i,a){return qo=a,I=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,E.H=e===null||e.memoizedState===null?bc:xc,Qo=!1,a=n(r,i),Qo=!1,Zo&&(a=os(t,n,r,i)),L(e),a}function L(e){E.H=yc;var t=Jo!==null&&Jo.next!==null;if(qo=0,Yo=Jo=I=null,Xo=!1,es=0,ts=null,t)throw Error(i(300));e===null||Lc||(e=e.dependencies,e!==null&&ka(e)&&(Lc=!0))}function os(e,t,n,r){I=e;var a=0;do{if(Zo&&(ts=null),es=0,Zo=!1,25<=a)throw Error(i(301));if(a+=1,Yo=Jo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}E.H=Sc,o=t(n,r)}while(Zo);return o}function ss(){var e=E.H,t=e.useState()[0];return t=typeof t.then==`function`?ms(t):t,e=e.useState()[0],(Jo===null?null:Jo.memoizedState)!==e&&(I.flags|=1024),t}function cs(){var e=$o!==0;return $o=0,e}function ls(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function us(e){if(Xo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Xo=!1}qo=0,Yo=Jo=I=null,Zo=!1,es=$o=0,ts=null}function ds(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Yo===null?I.memoizedState=Yo=e:Yo=Yo.next=e,Yo}function fs(){if(Jo===null){var e=I.alternate;e=e===null?null:e.memoizedState}else e=Jo.next;var t=Yo===null?I.memoizedState:Yo.next;if(t!==null)Yo=t,Jo=e;else{if(e===null)throw I.alternate===null?Error(i(467)):Error(i(310));Jo=e,e={memoizedState:Jo.memoizedState,baseState:Jo.baseState,baseQueue:Jo.baseQueue,queue:Jo.queue,next:null},Yo===null?I.memoizedState=Yo=e:Yo=Yo.next=e}return Yo}function ps(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ms(e){var t=es;return es+=1,ts===null&&(ts=[]),e=oo(ts,e,t),t=I,(Yo===null?t.memoizedState:Yo.next)===null&&(t=t.alternate,E.H=t===null||t.memoizedState===null?bc:xc),e}function hs(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ms(e);if(e.$$typeof===ye)return;if(e.$$typeof===le)return ja(e)}throw Error(i(438,String(e)))}function gs(e){var t=null,n=I.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=I.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ps(),I.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=_e;return t.index++,n}function _s(e,t){return typeof t==`function`?t(e):t}function vs(e){return ys(fs(),Jo,e)}function ys(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(qo&f)===f:(Z&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Ga&&(d=!0);else if((qo&p)===p){u=u.next,p===Ga&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,I.lanes|=p,Q|=p;f=u.action,Qo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,I.lanes|=f,Q|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Yr(o,e.memoizedState)&&(Lc=!0,d&&(n=Ka,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function bs(e){var t=fs(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Yr(o,t.memoizedState)||(Lc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function xs(e,t,n){var r=I,a=fs(),o=P;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Yr((Jo||a).memoizedState,n);if(s&&(a.memoizedState=n,Lc=!0),a=a.queue,Ks(ws.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Yo!==null&&!!(Yo.memoizedState.tag&1),Vs(e?9:8,{destroy:void 0},Cs.bind(null,r,a,n,t),null),e){if(r.flags|=2048,Zu===null)throw Error(i(349));o||qo&127||Ss(r,t,n)}return n}function Ss(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=I.updateQueue,t===null?(t=ps(),I.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Cs(e,t,n,r){t.value=n,t.getSnapshot=r,Ts(t)&&Es(e)}function ws(e,t,n){return n(function(){Ts(t)&&Es(e)})}function Ts(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Yr(e,n)}catch{return!0}}function Es(e){var t=Pi(e,2);t!==null&&Md(t,e,2)}function Ds(e){var t=ds();if(typeof e==`function`){var n=e;if(e=n(),Qo){ot(!0);try{n()}finally{ot(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:e},t}function Os(e,t,n,r){return e.baseState=n,ys(e,Jo,typeof r==`function`?r:_s)}function ks(e,t,n,r,a){if(gc(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};E.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,As(t,o)):(o.next=n.next,t.pending=n.next=o)}}function As(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=E.T,o={};o.types=a===null?null:a.types,E.T=o;try{var s=n(i,r),c=E.S;c!==null&&c(o,s),js(e,t,s)}catch(n){Ns(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),E.T=a}}else try{a=n(i,r),js(e,t,a)}catch(n){Ns(e,t,n)}}function js(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ms(e,t,n)},function(n){return Ns(e,t,n)}):Ms(e,t,n)}function Ms(e,t,n){t.status=`fulfilled`,t.value=n,Ps(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,As(e,n)))}function Ns(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ps(t),t=t.next;while(t!==r)}e.action=null}function Ps(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Fs(e,t){return t}function Is(e,t){if(P){var n=Zu.formState;if(n!==null){a:{var r=I;if(P){if(N){b:{for(var i=N,a=fa;i.nodeType!==8;)if(!a||(i=lm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){N=lm(i.nextSibling),r=i.data===`F!`;break a}}ma(r)}r=!1}r&&(t=n[0])}}return n=ds(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fs,lastRenderedState:t},n.queue=r,n=pc.bind(null,I,r),r.dispatch=n,r=Ds(!1),a=hc.bind(null,I,!1,r.queue),r=ds(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ks.bind(null,I,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ls(e){return Rs(fs(),Jo,e)}function Rs(e,t,n){if(t=ys(e,t,Fs)[0],e=vs(_s)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ms(t)}catch(e){throw e===to?ro:e}else r=t;t=fs();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(I.flags|=2048,Vs(9,{destroy:void 0},zs.bind(null,i,n),null)),[r,a,e]}function zs(e,t){e.action=t}function Bs(e){var t=fs(),n=Jo;if(n!==null)return Rs(t,n,e);fs(),t=t.memoizedState,n=fs();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Vs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=I.updateQueue,t===null&&(t=ps(),I.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Hs(){return fs().memoizedState}function Us(e,t,n,r){var i=ds();I.flags|=e,i.memoizedState=Vs(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ws(e,t,n,r){var i=fs();r=r===void 0?null:r;var a=i.memoizedState.inst;Jo!==null&&r!==null&&is(r,Jo.memoizedState.deps)?i.memoizedState=Vs(t,a,n,r):(I.flags|=e,i.memoizedState=Vs(1|t,a,n,r))}function Gs(e,t){Us(8390656,8,e,t)}function Ks(e,t){Ws(2048,8,e,t)}function qs(e){I.flags|=4;var t=I.updateQueue;if(t===null)t=ps(),I.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Js(e){var t=fs().memoizedState;return qs({ref:t,nextImpl:e}),function(){if(Y&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ys(e,t){return Ws(4,2,e,t)}function Xs(e,t){return Ws(4,4,e,t)}function Zs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function R(e,t,n){n=n==null?null:n.concat([e]),Ws(4,4,Zs.bind(null,t,e),n)}function Qs(){}function $s(e,t){var n=fs();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&is(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ec(e,t){var n=fs();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&is(t,r[1]))return r[0];if(r=e(),Qo){ot(!0);try{e()}finally{ot(!1)}}return n.memoizedState=[r,t],r}function tc(e,t,n){return n===void 0||qo&1073741824&&!(Z&261930)?e.memoizedState=t:(e.memoizedState=n,e=Ad(),I.lanes|=e,Q|=e,n)}function nc(e,t,n,r){return Yr(n,t)?n:jo.current===null?!(qo&106)||qo&1073741824&&!(Z&261930)?(Lc=!0,e.memoizedState=n):(e=Ad(),I.lanes|=e,Q|=e,t):(e=tc(e,n,r),Yr(e,t)||(Lc=!0),e)}function rc(e,t,n,r,i){var a=D.p;D.p=a!==0&&8>a?a:8;var o=E.T,s={};s.types=o===null?null:o.types,E.T=s,hc(e,!1,t,n);try{var c=i(),l=E.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?mc(e,t,Ya(c,r),kd(e)):mc(e,t,r,kd(e))}catch(n){mc(e,t,{then:function(){},status:`rejected`,reason:n},kd())}finally{D.p=a,o!==null&&s.types!==null&&(o.types=s.types),E.T=o}}function ic(){}function ac(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=oc(e).queue;rc(e,a,t,Te,n===null?ic:function(){return sc(e),n(r)})}function oc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Te,baseState:Te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:Te},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function sc(e){var t=oc(e);t.next===null&&(t=e.alternate.memoizedState),mc(e,t.next.queue,{},kd())}function cc(){return ja(sh)}function lc(){return fs().memoizedState}function uc(){return fs().memoizedState}function dc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=kd();e=So(n);var r=Co(t,e,n);r!==null&&(Md(r,t,n),wo(r,t,n)),t={cache:Ra()},e.payload=t;return}t=t.return}}function fc(e,t,n){var r=kd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},gc(e)?_c(t,n):(n=Ni(e,t,n,r),n!==null&&(Md(n,e,r),vc(n,t,r)))}function pc(e,t,n){mc(e,t,n,kd())}function mc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(gc(e))_c(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Yr(s,o))return M(e,t,i,0),Zu===null&&Mi(),!1}catch{}if(n=Ni(e,t,i,r),n!==null)return Md(n,e,r),vc(n,t,r),!0}return!1}function hc(e,t,n,r){if(r={lane:2,revertLane:Nf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},gc(e)){if(t)throw Error(i(479))}else t=Ni(e,n,r,2),t!==null&&Md(t,e,2)}function gc(e){var t=e.alternate;return e===I||t!==null&&t===I}function _c(e,t){Zo=Xo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function vc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,wt(e,n)}}var yc={readContext:ja,use:hs,useCallback:rs,useContext:rs,useEffect:rs,useImperativeHandle:rs,useLayoutEffect:rs,useInsertionEffect:rs,useMemo:rs,useReducer:rs,useRef:rs,useState:rs,useDebugValue:rs,useDeferredValue:rs,useTransition:rs,useSyncExternalStore:rs,useId:rs,useHostTransitionStatus:rs,useFormState:rs,useActionState:rs,useOptimistic:rs,useMemoCache:rs,useCacheRefresh:rs,useEffectEvent:rs},bc={readContext:ja,use:hs,useCallback:function(e,t){return ds().memoizedState=[e,t===void 0?null:t],e},useContext:ja,useEffect:Gs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Us(4194308,4,Zs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Us(4194308,4,e,t)},useInsertionEffect:function(e,t){Us(4,2,e,t)},useMemo:function(e,t){var n=ds();t=t===void 0?null:t;var r=e();if(Qo){ot(!0);try{e()}finally{ot(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ds();if(n!==void 0){var i=n(t);if(Qo){ot(!0);try{n(t)}finally{ot(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=fc.bind(null,I,e),[r.memoizedState,e]},useRef:function(e){var t=ds();return e={current:e},t.memoizedState=e},useState:function(e){e=Ds(e);var t=e.queue,n=pc.bind(null,I,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Qs,useDeferredValue:function(e,t){return tc(ds(),e,t)},useTransition:function(){var e=Ds(!1);return e=rc.bind(null,I,e.queue,!0,!1),ds().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=I,a=ds();if(P){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Zu===null)throw Error(i(349));Z&127||Ss(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Gs(ws.bind(null,r,o,e),[e]),r.flags|=2048,Vs(9,{destroy:void 0},Cs.bind(null,r,o,n,t),null),n},useId:function(){var e=ds(),t=Zu.identifierPrefix;if(P){var n=ia,r=ra;n=(r&~(1<<32-st(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=$o++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=ns++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:cc,useFormState:Is,useActionState:Is,useOptimistic:function(e){var t=ds();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=hc.bind(null,I,!0,n),n.dispatch=t,[e,t]},useMemoCache:gs,useCacheRefresh:function(){return ds().memoizedState=dc.bind(null,I)},useEffectEvent:function(e){var t=ds(),n={impl:e};return t.memoizedState=n,function(){if(Y&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},xc={readContext:ja,use:hs,useCallback:$s,useContext:ja,useEffect:Ks,useImperativeHandle:R,useInsertionEffect:Ys,useLayoutEffect:Xs,useMemo:ec,useReducer:vs,useRef:Hs,useState:function(){return vs(_s)},useDebugValue:Qs,useDeferredValue:function(e,t){return nc(fs(),Jo.memoizedState,e,t)},useTransition:function(){var e=vs(_s)[0],t=fs().memoizedState;return[typeof e==`boolean`?e:ms(e),t]},useSyncExternalStore:xs,useId:lc,useHostTransitionStatus:cc,useFormState:Ls,useActionState:Ls,useOptimistic:function(e,t){return Os(fs(),Jo,e,t)},useMemoCache:gs,useCacheRefresh:uc,useEffectEvent:Js},Sc={readContext:ja,use:hs,useCallback:$s,useContext:ja,useEffect:Ks,useImperativeHandle:R,useInsertionEffect:Ys,useLayoutEffect:Xs,useMemo:ec,useReducer:bs,useRef:Hs,useState:function(){return bs(_s)},useDebugValue:Qs,useDeferredValue:function(e,t){var n=fs();return Jo===null?tc(n,e,t):nc(n,Jo.memoizedState,e,t)},useTransition:function(){var e=bs(_s)[0],t=fs().memoizedState;return[typeof e==`boolean`?e:ms(e),t]},useSyncExternalStore:xs,useId:lc,useHostTransitionStatus:cc,useFormState:Bs,useActionState:Bs,useOptimistic:function(e,t){var n=fs();return Jo===null?(n.baseState=e,[e,n.queue.dispatch]):Os(n,Jo,e,t)},useMemoCache:gs,useCacheRefresh:uc,useEffectEvent:Js};function Cc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:T({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var wc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=kd(),i=So(r);i.payload=t,n!=null&&(i.callback=n),t=Co(e,i,r),t!==null&&(Md(t,e,r),wo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=kd(),i=So(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Co(e,i,r),t!==null&&(Md(t,e,r),wo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=kd(),r=So(n);r.tag=2,t!=null&&(r.callback=t),t=Co(e,r,n),t!==null&&(Md(t,e,n),wo(t,e,n))}};function z(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Xr(n,r)||!Xr(i,a):!0}function Tc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&wc.enqueueReplaceState(t,t.state,null)}function Ec(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=T({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Dc(e){Oi(e)}function Oc(e){console.error(e)}function kc(e){Oi(e)}function Ac(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function jc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Mc(e,t,n){return n=So(n),n.tag=3,n.payload={element:null},n.callback=function(){Ac(e,t)},n}function Nc(e){return e=So(e),e.tag=3,e}function Pc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){jc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){jc(t,n,r),typeof i!=`function`&&(gd===null?gd=new Set([this]):gd.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Fc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Oa(t,n,a,!0),n=Io.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Lo===null?Wd():n.alternate===null&&id===0&&(id=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===io?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),pf(e,r,a)),!1;case 22:return n.flags|=65536,r===io?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),pf(e,r,a)),!1}throw Error(i(435,n.tag))}return pf(e,r,a),Wd(),!1}if(P)return t=Io.current,t===null?(r!==pa&&(t=Error(i(423),{cause:r}),ba(Yi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Yi(r,n),a=Mc(e.stateNode,r,a),To(e,a),id!==4&&(id=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==pa&&(e=Error(i(422),{cause:r}),ba(Yi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Yi(o,n),ld===null?ld=[o]:ld.push(o),id!==4&&(id=2),t===null)return!0;r=Yi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Mc(n.stateNode,r,e),To(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(gd===null||!gd.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Nc(a),Pc(a,e,n,r),To(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Ic=Error(i(461)),Lc=!1;function Rc(e,t,n,r){t.child=e===null?vo(t,null,n,r):_o(t,e.child,n,r)}function zc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Aa(t),r=as(e,t,n,o,a,i),s=cs(),e!==null&&!Lc?(ls(e,t,i),fl(e,t,i)):(P&&s&&sa(t),t.flags|=1,Rc(e,t,r,i),t.child)}function Bc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Bi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Vc(e,t,a,r,i)):(e=Ui(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!pl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Xr:n,n(o,r)&&e.ref===t.ref)return fl(e,t,i)}return t.flags|=1,e=Vi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Vc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Xr(a,r)&&e.ref===t.ref){if(Lc=!1,t.pendingProps=r=a,pl(e,i))e.flags&131072&&(Lc=!0);else return t.lanes=e.lanes,fl(e,t,i)}}return Jc(e,t,n,r,i)}function Hc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Wc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&$a(t,a===null?null:a.cachePool),a===null?Po():No(t,a),Bo(t);else return r=t.lanes=536870912,Wc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&$a(t,null),Po(),Vo()):($a(t,a.cachePool),No(t,a),Vo(),t.memoizedState=null);return Rc(e,t,i,n),t.child}function Uc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Wc(e,t,n,r,i){var a=Qa();return a=a===null?null:{parent:La._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&$a(t,null),Po(),Bo(t),e!==null&&Oa(e,t,r,!0),t.childLanes=i,null}function Gc(e,t){return t=rl({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Kc(e,t,n){return _o(t,e.child,null,n),e=Gc(t,t.pendingProps),e.flags|=2,Ho(t),t.memoizedState=null,e}function qc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(P){if(r.mode===`hidden`)return e=Gc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Uc(null,e);if(zo(t),(e=N)?(e=am(e,fa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:na===null?null:{id:ra,overflow:ia},retryLane:536870912,hydrationErrors:null},n=Ki(e),n.return=t,t.child=n,ua=t,N=null)):e=null,e===null)throw ma(t);return t.lanes=536870912,null}return Gc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(zo(t),a){if(t.flags&256)t.flags&=-257,t=Kc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Lc||Oa(e,t,n,!1),a=(n&e.childLanes)!==0,Lc||a){if(jo.current===null){if(r=Zu,r!==null&&(s=Tt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Pi(e,s),Md(r,e,s),Ic;Wd()}t=Kc(e,t,n)}else e=o.treeContext,N=lm(s.nextSibling),ua=t,P=!0,da=null,fa=!1,e!==null&&la(t,e),t=Gc(t,r),t.flags|=134221824;return t}return e=Vi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function B(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Jc(e,t,n,r,i){return Aa(t),n=as(e,t,n,r,void 0,i),r=cs(),e!==null&&!Lc?(ls(e,t,i),fl(e,t,i)):(P&&r&&sa(t),t.flags|=1,Rc(e,t,n,i),t.child)}function Yc(e,t,n,r,i,a){return Aa(t),t.updateQueue=null,n=os(t,r,n,i),L(e),r=cs(),e!==null&&!Lc?(ls(e,t,a),fl(e,t,a)):(P&&r&&sa(t),t.flags|=1,Rc(e,t,n,a),t.child)}function Xc(e,t,n,r,i){if(Aa(t),t.stateNode===null){var a=Li,o=n.contextType;typeof o==`object`&&o&&(a=ja(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=wc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},bo(t),o=n.contextType,a.context=typeof o==`object`&&o?ja(o):Li,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Cc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&wc.enqueueReplaceState(a,a.state,null),Oo(t,r,a,i),Do(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Ec(n,s);a.props=c;var l=a.context,u=n.contextType;o=Li,typeof u==`object`&&u&&(o=ja(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Tc(t,a,r,o),yo=!1;var f=t.memoizedState;a.state=f,Oo(t,r,a,i),Do(),l=t.memoizedState,s||f!==l||yo?(typeof d==`function`&&(Cc(t,n,d,r),l=t.memoizedState),(c=yo||z(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,xo(e,t),o=t.memoizedProps,u=Ec(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Li,typeof l==`object`&&l&&(c=ja(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Tc(t,a,r,c),yo=!1,f=t.memoizedState,a.state=f,Oo(t,r,a,i),Do();var p=t.memoizedState;o!==d||f!==p||yo||e!==null&&e.dependencies!==null&&ka(e.dependencies)?(typeof s==`function`&&(Cc(t,n,s,r),p=t.memoizedState),(u=yo||z(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ka(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,B(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=_o(t,e.child,null,i),t.child=_o(t,null,n,i)):Rc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=fl(e,t,i),e}function Zc(e,t,n,r){return va(),t.flags|=256,Rc(e,t,n,r),t.child}var Qc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function $c(e){return{baseLanes:e,cachePool:eo()}}function el(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=sd),e}function tl(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Uo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(P){if(i?Ro(t):Vo(),(e=N)?(e=am(e,fa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:na===null?null:{id:ra,overflow:ia},retryLane:536870912,hydrationErrors:null},n=Ki(e),n.return=t,t.child=n,ua=t,N=null)):e=null,e===null)throw ma(t);return t.lanes=sm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Vo(),i=t.mode,a=rl({mode:`hidden`,children:a},i),r=Wi(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=$c(n),r.childLanes=el(e,o,n),t.memoizedState=Qc,Uc(null,r)):(Ro(t),nl(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return al(e,t,a,o,r,c,s,n)}return i?(Vo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Vi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Wi(i,a,n,null),i.flags|=2):i=Vi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Uc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=$c(n):(a=i.cachePool,a===null?a=eo():(s=La._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=el(e,o,n),t.memoizedState=Qc,Uc(e.child,r)):(Ro(t),n=e.child,e=n.sibling,n=Vi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function nl(e,t){return t=rl({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function rl(e,t){return e=zi(22,e,null,t),e.lanes=0,e}function il(e,t,n){return _o(t,e.child,null,n),e=nl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function al(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(Ro(t),t.flags&=-257,il(e,t,c)):t.memoizedState===null?(Vo(),o=a.fallback,s=t.mode,a=rl({mode:`visible`,children:a.children},s),o=Wi(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,_o(t,e.child,null,c),a=t.child,a.memoizedState=$c(c),a.childLanes=el(e,r,c),t.memoizedState=Qc,Uc(null,a)):(Vo(),t.child=e.child,t.flags|=128,null);if(Ro(t),sm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,ba({value:a,source:null,stack:null})),il(e,t,c)}if(Lc||Oa(e,t,c,!1),r=(c&e.childLanes)!==0,Lc||r){if(jo.current!==null)return il(e,t,c);if(r=Zu,r!==null&&(a=Tt(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,Pi(e,a),Md(r,e,a),Ic;return om(o)||Wd(),il(e,t,c)}return om(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,N=lm(o.nextSibling),ua=t,P=!0,da=null,fa=!1,e!==null&&la(t,e),t=nl(t,a.children),t.flags|=134221824,t)}function ol(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ea(e.return,t,n)}function sl(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Ko(n)===null&&(t=e),e=e.sibling}return t}function cl(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function ll(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function ul(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Uo.current;if(t.flags&128)return Wo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Wo(t,o),i===`backwards`&&e!==null?(ll(e),Rc(e,t,r,n),ll(e)):Rc(e,t,r,n),r=P?$i:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ol(e,n,t);else if(e.tag===19)ol(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=sl(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,ll(t)),cl(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Ko(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}cl(t,!0,n,null,a,r);break;case`together`:cl(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=sl(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),cl(t,!1,i,n,a,r)}return t.child}function dl(e,t,n){var r=t.pendingProps;return wa(t,t.type,r.value),Rc(e,t,r.children,n),t.child}function fl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Q|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Oa(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Vi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Vi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function pl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&ka(e)))}function ml(e,t,n){switch(t.tag){case 3:Fe(t,t.stateNode.containerInfo),wa(t,La,e.memoizedState.cache),va();break;case 27:case 5:k(t);break;case 4:Fe(t,t.stateNode.containerInfo);break;case 10:wa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,zo(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Ro(t),t.flags|=128,null;r=Oa(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?tl(e,t,n):(Ro(t),e=fl(e,t,n),e===null?null:e.sibling)}Ro(t);break;case 19:if(t.flags&128)return ul(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Oa(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return ul(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Wo(t,Uo.current),r)break;return null;case 22:return t.lanes=0,Hc(e,t,n,t.pendingProps);case 24:wa(t,La,e.memoizedState.cache)}return fl(e,t,n)}function hl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Lc=!0;else{if(!pl(e,n)&&!(t.flags&128))return Lc=!1,ml(e,t,n);Lc=!!(e.flags&131072)}}else Lc=!1,P&&t.flags&1048576&&oa(t,$i,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=so(t.elementType),t.type=e,typeof e==`function`)Bi(e)?(r=Ec(e,r),t.tag=1,t=Xc(null,t,e,r,n)):(t.tag=0,t=Jc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===ue){t.tag=11,t=zc(null,t,e,r,n);break a}if(a===pe){t.tag=14,t=Bc(null,t,e,r,n);break a}if(a===le){t.tag=10,t.type=e,t=dl(null,t,n);break a}}throw t=Ce(e)||e,Error(i(306,t,``))}}return t;case 0:return Jc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Ec(r,t.pendingProps),Xc(e,t,r,a,n);case 3:a:{if(Fe(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,xo(e,t),Oo(t,r,null,n);var s=t.memoizedState;if(r=s.cache,wa(t,La,r),r!==o.cache&&Da(t,[La],n,!0),Do(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Zc(e,t,r,n);break a}if(r!==a){a=Yi(Error(i(424)),t),ba(a),t=Zc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(N=lm(e.firstChild),ua=t,P=!0,da=null,fa=!0,n=vo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(va(),r===a){t=fl(e,t,n);break a}Rc(e,t,r,n)}t=t.child}return t;case 26:return B(e,t),e===null?(n=Nm(t.type,null,t.pendingProps,null))?t.memoizedState=n:P||(t.stateNode=fp(t.type,t.pendingProps,Ne.current,t)):t.memoizedState=Nm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return k(t),e===null&&P&&(r=t.stateNode=hm(t.type,t.pendingProps,Ne.current),ua=t,fa=!0,a=N,Sp(t.type)?(um=a,N=lm(r.firstChild)):N=a),Rc(e,t,t.pendingProps.children,n),B(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&P&&((a=r=N)&&(r=rm(r,t.type,t.pendingProps,fa),r===null?a=!1:(t.stateNode=r,ua=t,N=lm(r.firstChild),fa=!1,a=!0)),a||ma(t)),k(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,pp(a,o)?r=null:s!==null&&pp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=as(e,t,ss,null,null,n),sh._currentValue=a),B(e,t),Rc(e,t,r,n),t.child;case 6:return e===null&&P&&((e=n=N)&&(n=im(n,t.pendingProps,fa),n===null?e=!1:(t.stateNode=n,ua=t,N=null,e=!0)),e||ma(t)),null;case 13:return tl(e,t,n);case 4:return Fe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=_o(t,null,r,n):Rc(e,t,r,n),t.child;case 11:return zc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,B(e,t),Rc(e,t,r,n),t.child;case 8:return Rc(e,t,t.pendingProps.children,n),t.child;case 12:return Rc(e,t,t.pendingProps.children,n),t.child;case 10:return dl(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,Aa(t),a=ja(a),r=r(a),t.flags|=1,Rc(e,t,r,n),t.child;case 14:return Bc(e,t,t.type,t.pendingProps,n);case 15:return Vc(e,t,t.type,t.pendingProps,n);case 19:return ul(e,t,n);case 31:return qc(e,t,n);case 22:return Hc(e,t,n,t.pendingProps);case 24:return Aa(t),r=ja(La),e===null?(a=Qa(),a===null&&(a=Zu,o=Ra(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},bo(t),wa(t,La,a)):((e.lanes&n)!==0&&(xo(e,t),Oo(t,null,null,n),Do()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,wa(t,La,r),r!==a.cache&&Da(t,[La],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),wa(t,La,r))),Rc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:P&&sa(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:B(e,t),Rc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function gl(e){e.flags|=4}function _l(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Jm(t,r):Jm(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Vd())e.flags|=8192;else throw co=io,no}}else e.flags&=-16777217}function vl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Ym(t)){if(Vd())e.flags|=8192;else throw co=io,no}}function yl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:yt(),e.lanes|=t,cd|=t)}function bl(e,t){if(!P)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function xl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Sl(e,t,n){var r=t.pendingProps;switch(ca(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xl(t),null;case 1:return xl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ta(La),O(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(_a(t)?gl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ya())),xl(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(gl(t),o===null?(xl(t),_l(t,a,null,r,n)):(xl(t),vl(t,o))):o?o===e.memoizedState?(xl(t),t.flags&=-16777217):(gl(t),xl(t),vl(t,o)):(e=e.memoizedProps,e!==r&&gl(t),xl(t),_l(t,a,e,r,n)),null;case 27:if(Ie(t),n=Ne.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return xl(t),t.subtreeFlags&=-33554433,null}e=je.current,_a(t)?ha(t,e):(e=hm(a,r,n),t.stateNode=e,gl(t))}return xl(t),t.subtreeFlags&=-33554433,null;case 5:if(Ie(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return xl(t),t.subtreeFlags&=-33554433,null}if(o=je.current,_a(t))ha(t,o);else{var s=lp(Ne.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[jt]=t,o[Mt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&gl(t)}}return xl(t),t.subtreeFlags&=-33554433,_l(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=Ne.current,_a(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ua,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[jt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||ma(t,!0)}else e=lp(e).createTextNode(r),e[jt]=t,t.stateNode=e}return xl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=_a(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[jt]=t}else va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;xl(t),e=!1}else n=ya(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ho(t),t):(Ho(t),null);if(t.flags&128)throw Error(i(558))}return xl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=_a(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[jt]=t}else va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;xl(t),a=!1}else a=ya(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Ho(t),t):(Ho(t),null)}return Ho(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),yl(t,t.updateQueue),xl(t),null);case 4:return O(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,xl(t),null;case 10:return Ta(t.type),xl(t),null;case 19:if(Go(t),r=t.memoizedState,r===null)return xl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)bl(r,!1);else{if(id!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Ko(e),o!==null){for(t.flags|=128,bl(r,!1),e=o.updateQueue,t.updateQueue=e,yl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Hi(n,e),n=n.sibling;return Wo(t,Uo.current&1|2),P&&aa(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ye()>md&&(t.flags|=128,a=!0,bl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Ko(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,yl(t,e),bl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!P)return xl(t),null}else 2*Ye()-r.renderingStartTime>md&&n!==536870912&&(t.flags|=128,a=!0,bl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ye(),e.sibling=null,o=Uo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||P?Wo(t,o):(n=o,Ae(Io,t),Ae(Uo,n),Lo===null&&(Lo=t)),P&&aa(t,r.treeForkCount),e}return xl(t),null;case 22:case 23:return Ho(t),Fo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(xl(t),t.subtreeFlags&6&&(t.flags|=8192)):xl(t),n=t.updateQueue,n!==null&&yl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ke(Za),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ta(La),xl(t),null;case 25:return null;case 30:return t.flags|=33554432,xl(t),null}throw Error(i(156,t.tag))}function Cl(e,t){switch(ca(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ta(La),O(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ie(t),null;case 31:if(t.memoizedState!==null){if(Ho(t),t.alternate===null)throw Error(i(340));va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ho(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Go(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return O(),null;case 10:return Ta(t.type),null;case 22:case 23:return Ho(t),Fo(),e!==null&&ke(Za),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ta(La),null;case 25:return null;default:return null}}function wl(e,t){switch(ca(t),t.tag){case 3:Ta(La),O();break;case 26:case 27:case 5:Ie(t);break;case 4:O();break;case 31:t.memoizedState!==null&&Ho(t);break;case 13:Ho(t);break;case 19:Go(t);break;case 10:Ta(t.type);break;case 22:case 23:Ho(t),Fo(),e!==null&&ke(Za);break;case 24:Ta(La)}}function Tl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){ff(t,t.return,e)}}function El(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){ff(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){ff(t,t.return,e)}}function Dl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ao(t,n)}catch(t){ff(e,e.return,t)}}}function Ol(e,t,n){n.props=Ec(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){ff(e,t,n)}}function kl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=Ti(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);h(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){ff(e,t,n)}}function Al(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){ff(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){ff(e,t,n)}else n.current=null}}function jl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)em(e.stateNode,t[n])}function Ml(e){for(var t=e.return;t!==null&&(Fl(t)&&em(e.stateNode,t.stateNode),!Pl(t));)t=t.return}function Nl(e){for(var t=e.return;t!==null&&(Fl(t)&&tm(e.stateNode,t.stateNode),!Pl(t));)t=t.return}function Pl(e){return e.tag===5||e.tag===3||e.tag===27}function Fl(e){return e&&e.tag===7&&e.stateNode!==null}function Il(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){ff(e,e.return,t)}}function Ll(e,t,n){try{var r=e.stateNode;ip(r,e.type,n,t),r[Mt]=t}catch(t){ff(e,e.return,t)}}function Rl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Sp(e.type)||e.tag===4}function zl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Rl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Sp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Bl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=On)),jl(e,r),tn=!0;else if(i!==4&&(i===27&&(jl(e,r),r=null,Sp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Bl(e,t,n,r),e=e.sibling;e!==null;)Bl(e,t,n,r),e=e.sibling}function Vl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),jl(e,r),tn=!0;else if(i!==4&&(i===27&&(jl(e,r),r=null,Sp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Vl(e,t,n,r),e=e.sibling;e!==null;)Vl(e,t,n,r),e=e.sibling}function Hl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);np(t,r,n),t[jt]=e,t[Mt]=n}catch(t){ff(e,e.return,t)}}var Ul=!1,Wl=null;function Gl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Ul=!0)}var Kl=null;function ql(){var e=Kl;return Kl=null,e}var Jl=0;function Yl(e,t,n,r,i){return Jl=0,Xl(e.child,t,n,r,i)}function Xl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Op(o);r.push(s),s.view&&(a=!0)}else a||Op(o).view&&(a=!0);Ul=!0,Tp(o,Jl===0?t:t+`_`+Jl,n),Jl++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Xl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Zl(e,t){for(;e!==null;)e.tag===5?Ep(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Zl(e.child,t),e=e.sibling}function Ql(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Ql(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=Di(t.default,t.share),t!==`none`&&(Yl(e,n,t,null,!1)||Zl(e.child,!1))}e=e.sibling}}function $l(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=Ti(r,n),a=Di(r.default,n.paired?r.share:r.enter);a===`none`?Ql(e):Yl(e,i,a,null,!1)?(Ql(e),n.paired||t||jd(e,r.onEnter)):Zl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)$l(e,t),e=e.sibling;else Ql(e)}function eu(e){if(Wl!==null&&Wl.size!==0){var t=Wl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=Di(n.default,n.share);if(a!==`none`&&(Yl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,jd(e,n.onShare)):Zl(e.child,!1)),t.delete(r),t.size===0)break}}}eu(e)}e=e.sibling}}}function tu(e){if(e.tag===30){var t=e.memoizedProps,n=Ti(t,e.stateNode),r=Wl===null?void 0:Wl.get(n),i=Di(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Yl(e,n,i,null,!1)?r===void 0?jd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Wl.delete(n),jd(e,t.onShare)):Zl(e.child,!1)),Wl!==null&&eu(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)tu(e),e=e.sibling;else Wl!==null&&eu(e)}function nu(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=Ti(t,e.stateNode);t=Di(t.default,t.update),e.flags&=-5,t!==`none`&&Yl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&nu(e);e=e.sibling}}function ru(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Zl(e.child,!1))}ru(e)}e=e.sibling}}function iu(e){if(e.tag===30)e.stateNode.paired=null,Zl(e.child,!1),ru(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)iu(e),e=e.sibling;else ru(e)}function au(e){for(e=e.child;e!==null;)e.tag===30?Zl(e.child,!1):e.subtreeFlags&33554432&&au(e),e=e.sibling}function ou(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Jl<a.length){var l=a[Jl],u=Op(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Tp(c,Jl===0?n:n+`_`+Jl,i),s&&e.flags&4||(Kl===null&&(Kl=[]),Kl.push(c,Jl===0?r:r+`_`+Jl,t.memoizedProps)),Jl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:ou(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function su(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=Ti(n,r),a=Di(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(kp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Jl=0,i=ou(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||jd(e,n.onUpdate))}else e.subtreeFlags&33554432&&su(e,t);e=e.sibling}}var cu=!1,lu=!1,uu=!1,du=!1,fu=typeof WeakSet==`function`?WeakSet:Set,pu=null,mu=!1,hu=!1,gu=!1,_u=!1;function vu(e,t,n){if(e=e.containerInfo,sp=gh,e=ti(e),ni(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(cp={focusedElem:e,selectionRange:r},gh=!1,n=(n&335544064)===n,pu=t,t=n?9270:1024;pu!==null;){if(e=pu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&tu(r[a]);if(e.alternate===null&&e.flags&2)n&&Gl(e),yu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&tu(r),yu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Gl(e),yu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,pu=r):(n&&nu(e),yu(n))}}Wl=null}function yu(e){for(;pu!==null;){var t=pu,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=Ec(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){ff(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)nm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:nm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=Ti(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=Di(a.default,a.update),a!==`none`&&Yl(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,pu=r;break}pu=t.return}}function bu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:q(e,n),r&4&&Tl(5,n);break;case 1:if(q(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){ff(n,n.return,e)}else{var i=Ec(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){ff(n,n.return,e)}}}r&64&&Dl(n),r&512&&kl(n,n.return);break;case 3:if(q(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ao(e,t)}catch(e){ff(n,n.return,e)}}break;case 27:t===null&&r&4&&Hl(n);case 26:case 5:q(e,n),t===null&&r&4&&Il(n),r&512&&kl(n,n.return);break;case 12:q(e,n);break;case 31:q(e,n),r&4&&G(e,n);break;case 13:q(e,n),r&4&&Tu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=gf.bind(null,n),cm(e,n))));break;case 22:if(r=n.memoizedState!==null||cu,!r){var a=t!==null&&t.memoizedState!==null||lu;t=cu,i=lu,cu=r,(lu=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Fu(e,n,r)):q(e,n),cu=t,lu=i}break;case 30:q(e,n),r&512&&kl(n,n.return);break;case 7:r&512&&kl(n,n.return);default:q(e,n)}}function V(e,t){for(e=e.child;e!==null;)H(e,t),e=e.sibling}function H(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){ff(e,e.return,t)}xu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,tn=!0}catch(t){ff(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?wp(s,!0):wp(e.stateNode,!1)}catch(t){ff(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&V(e,t);break;default:V(e,t)}}function xu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:H(n,r);break a;case 22:n.memoizedState===null&&xu(n,r);break a;default:xu(n,r)}}e=e.sibling}}function Su(e){var t=e.alternate;t!==null&&(e.alternate=null,Su(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Bt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var U=null,Cu=!1;function W(e,t,n){for(n=n.child;n!==null;)wu(e,t,n),n=n.sibling}function wu(e,t,n){if(at&&typeof at.onCommitFiberUnmount==`function`)try{at.onCommitFiberUnmount(it,n)}catch{}switch(n.tag){case 26:lu||Al(n,t),W(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!lu&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:lu||Al(n,t),Nl(n);var r=U,i=Cu;Sp(n.type)&&(U=n.stateNode,Cu=!1),W(e,t,n),gm(n.stateNode,n.type,n.memoizedProps),U=r,Cu=i;break;case 5:lu||Al(n,t),Nl(n);case 6:if(n.tag===6&&Nl(n),r=U,i=Cu,U=null,W(e,t,n),U=r,Cu=i,U!==null){if(Cu)try{(U.nodeType===9?U.body:U.nodeName===`HTML`?U.ownerDocument.body:U).removeChild(n.stateNode),tn=!0}catch(e){ff(n,t,e)}else try{U.removeChild(n.stateNode),tn=!0}catch(e){ff(n,t,e)}}break;case 18:U!==null&&(Cu?(e=U,Cp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Hh(e)):Cp(U,n.stateNode));break;case 4:r=U,i=Cu,U=n.stateNode.containerInfo,Cu=!0,W(e,t,n),U=r,Cu=i;break;case 0:case 11:case 14:case 15:El(2,n,t),lu||El(4,n,t),W(e,t,n);break;case 1:lu||(Al(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Ol(n,t,r)),W(e,t,n);break;case 21:W(e,t,n);break;case 22:lu=(r=lu)||n.memoizedState!==null,W(e,t,n),lu=r;break;case 30:Al(n,t),W(e,t,n);break;case 7:lu||Al(n,t),W(e,t,n);break;default:W(e,t,n)}}function G(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Hh(e)}catch(e){ff(t,t.return,e)}}}function Tu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Hh(e)}catch(e){ff(t,t.return,e)}}function Eu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new fu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new fu),t;default:throw Error(i(435,e.tag))}}function Du(e,t){var n=Eu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=_f.bind(null,e,t);t.then(r,r)}})}function K(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Sp(l.type)){U=l.stateNode,Cu=!1;break a}break;case 5:U=l.stateNode,Cu=!1;break a;case 3:case 4:U=l.stateNode.containerInfo,Cu=!0;break a}l=l.return}if(U===null)throw Error(i(160));wu(s,c,o),U=null,Cu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ku(t,e,n),t=t.sibling}var Ou=null;function ku(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}K(t,e,n),Au(e),a&4&&(El(3,e,e.return),Tl(3,e),El(5,e,e.return));break;case 1:K(t,e,n),Au(e),a&512&&(lu||r===null||Al(r,r.return)),a&64&&cu&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Ou,K(t,e,n),Au(e),a&512&&(lu||r===null||Al(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(cu)e.stateNode=fp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[Rt]||r[jt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),np(r,t,n),r[jt]=e,Gt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),np(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=Gm(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),np(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[jt]=e,Gt(r),t=r}e.stateNode=t}}else cu||Km(o,e.type,e.stateNode)}else e.stateNode=Bm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Ll(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||lu||t.parentNode.removeChild(t)):a.count--,n===null?cu||Km(o,e.type,e.stateNode):Bm(o,n,e.memoizedProps))}break;case 27:K(t,e,n),Au(e),a&512&&(lu||r===null||Al(r,r.return)),r!==null&&a&4&&Ll(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=uu,uu=!1,K(t,e,n),uu=o,Au(e),a&512&&(lu||r===null||Al(r,r.return)),e.flags&32){t=e.stateNode;try{bn(t,``),tn=!0}catch(t){ff(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Ll(e,t,r===null?t:r.memoizedProps)),a&1024&&(du=!0);break;case 6:if(K(t,e,n),Au(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,tn=!0}catch(t){ff(e,e.return,t)}}break;case 3:if(tn=!1,Wm=null,o=Ou,Ou=bm(t.containerInfo),K(t,e,n),Ou=o,Au(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){ff(e,e.return,t)}du&&(du=!1,ju(e)),tn=!1;break;case 4:a=uu,uu=cu,r=nn(),o=Ou,Ou=bm(e.stateNode.containerInfo),K(t,e,n),Au(e),Ou=o,tn&&hu&&(gu=!0),tn=r,uu=a;break;case 12:K(t,e,n),Au(e);break;case 31:K(t,e,n),Au(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Du(e,t)));break;case 13:K(t,e,n),Au(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(fd=Ye()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Du(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=cu,l=lu,u=uu;cu=c||o,uu=u||o,lu=l||s,K(t,e,n),lu=l,uu=u,cu=c,Au(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||cu||lu||(t=s||lu,n=cu,r=lu,cu=o||cu,lu=t,Pu(e,2),cu=n,lu=r),!o&&uu||V(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Du(e,n))));break;case 19:K(t,e,n),Au(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Du(e,t)));break;case 30:a&512&&(lu||r===null||Al(r,r.return)),a=nn(),o=hu,s=(n&335544064)===n,c=e.memoizedProps,hu=s&&Di(c.default,c.update)!==`none`,K(t,e,n),Au(e),s&&r!==null&&tn&&(e.flags|=4),hu=o,tn=a;break;case 21:break;case 7:a&512&&(lu||r===null||Al(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:K(t,e,n),Au(e)}}function Au(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Rl(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Fl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Pl(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;Vl(e,zl(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(bn(l,``),n.flags&=-33),Vl(e,zl(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Bl(e,zl(e),u,s);break;default:throw Error(i(161))}}catch(t){ff(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function ju(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;ju(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,gh=!0,t.reset(),gh=!1),e=e.sibling}}function Mu(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Nu(t,e),t=t.sibling;else su(t,!1)}function Nu(e,t){var n=e.alternate;if(n===null)$l(e,!1);else switch(e.tag){case 3:if(_u=mu=!1,ql(),Mu(t,e),!mu&&!gu){if(e=Kl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Ep(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),_u=!0}Kl=null;break;case 5:Mu(t,e);break;case 4:r=mu,mu=!1,Mu(t,e),mu&&(gu=!0),mu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Mu(t,e):$l(e,!1));break;case 30:r=mu,i=ql(),mu=!1,Mu(t,e),mu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=Ti(a,o),o=Ti(n.memoizedProps,o);var s=Di(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Jl=0,t=ou(e,n,t,o,s,a,!0),Jl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(jd(e,e.memoizedProps.onUpdate),Kl=i):i!==null&&(i.push.apply(i,Kl),Kl=i),mu=e.flags&32?!0:r;break;default:Mu(t,e)}}function q(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)bu(e,t.alternate,t),t=t.sibling}function Pu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:El(4,n,n.return),Pu(n,r);break;case 1:Al(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&Ol(n,n.return,i),Pu(n,r);break;case 27:r&2&&gm(n.stateNode,n.type,n.memoizedProps);case 5:Al(n,n.return),n.tag!==5&&n.tag!==27||Nl(n),Pu(n,r);break;case 6:Nl(n);break;case 26:Al(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||lu||i.parentNode.removeChild(i),Pu(n,r);break;case 22:n.memoizedState===null&&Pu(n,r);break;case 30:Al(n,n.return),Pu(n,r);break;case 7:Al(n,n.return);default:Pu(n,r)}e=e.sibling}}function Fu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Fu(i,a,n),Tl(4,a);break;case 1:if(Fu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){ff(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)ko(l[i],c)}catch(e){ff(r,r.return,e)}}s&&o&64&&Dl(a),kl(a,a.return);break;case 27:n&2&&Hl(a);case 5:a.tag!==5&&a.tag!==27||Ml(a),Fu(i,a,n),s&&r===null&&o&4&&Il(a),kl(a,a.return);break;case 6:Ml(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||cu||Km(bm(c.ownerDocument),a.type,c),Fu(i,a,n),s&&r===null&&o&4&&Il(a),kl(a,a.return);break;case 12:Fu(i,a,n);break;case 31:Fu(i,a,n),s&&o&4&&G(i,a);break;case 13:Fu(i,a,n),s&&o&4&&Tu(i,a);break;case 22:a.memoizedState===null&&Fu(i,a,n),kl(a,a.return);break;case 30:Fu(i,a,n),kl(a,a.return);break;case 7:kl(a,a.return);default:Fu(i,a,n)}t=t.sibling}}function J(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&za(n))}function Iu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&za(e))}function Lu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Ru(e,t,n,r),t=t.sibling;else i&&au(t)}function Ru(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&iu(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Lu(e,t,n,r),a&2048&&Tl(9,t);break;case 1:Lu(e,t,n,r);break;case 3:Lu(e,t,n,r),i&&_u&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&za(a)));break;case 12:if(a&2048){Lu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){ff(t,t.return,e)}}else Lu(e,t,n,r);break;case 31:Lu(e,t,n,r);break;case 13:Lu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&iu(t),o._visibility&2?Lu(e,t,n,r):(o._visibility|=2,zu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&iu(s),o._visibility&2?Lu(e,t,n,r):Bu(e,t)),a&2048&&J(s,t);break;case 24:Lu(e,t,n,r),a&2048&&Iu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Zl(a.child,!0),Zl(t.child,!0))),Lu(e,t,n,r);break;default:Lu(e,t,n,r)}}function zu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:zu(a,o,s,c,i),Tl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,zu(a,o,s,c,i)):u._visibility&2?zu(a,o,s,c,i):Bu(a,o),i&&l&2048&&J(o.alternate,o);break;case 24:zu(a,o,s,c,i),i&&l&2048&&Iu(o.alternate,o);break;default:zu(a,o,s,c,i)}t=t.sibling}}function Bu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Bu(n,r),i&2048&&J(r.alternate,r);break;case 24:Bu(n,r),i&2048&&Iu(r.alternate,r);break;default:Bu(n,r)}t=t.sibling}}var Vu=8192;function Hu(e,t,n){if(e.subtreeFlags&Vu)for(e=e.child;e!==null;)Uu(e,t,n),e=e.sibling}function Uu(e,t,n){switch(e.tag){case 26:Hu(e,t,n),e.flags&Vu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&Zm(n,e)):Qm(n,Ou,e.memoizedState,e.memoizedProps));break;case 5:Hu(e,t,n),e.flags&Vu&&(e=e.stateNode,(t&335544128)===t&&Zm(n,e));break;case 3:case 4:var r=Ou;Ou=bm(e.stateNode.containerInfo),Hu(e,t,n),Ou=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Vu,Vu=16777216,Hu(e,t,n),Vu=r):Hu(e,t,n));break;case 30:if((e.flags&Vu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Wl===null&&(Wl=new Map),Wl.set(r,i)}Hu(e,t,n);break;default:Hu(e,t,n)}}function Wu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Gu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];pu=r,Ju(r,e)}Wu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ku(e),e=e.sibling}function Ku(e){switch(e.tag){case 0:case 11:case 15:Gu(e),e.flags&2048&&El(9,e,e.return);break;case 3:Gu(e);break;case 12:Gu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,qu(e)):Gu(e);break;default:Gu(e)}}function qu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];pu=r,Ju(r,e)}Wu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:El(8,t,t.return),qu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,qu(t));break;default:qu(t)}e=e.sibling}}function Ju(e,t){for(;pu!==null;){var n=pu;switch(n.tag){case 0:case 11:case 15:El(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:za(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,pu=r;else a:for(n=e;pu!==null;){r=pu;var i=r.sibling,a=r.return;if(Su(r),r===n){pu=null;break a}if(i!==null){i.return=a,pu=i;break a}pu=a}}}var Yu={getCacheForType:function(e){var t=ja(La),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ja(La).controller.signal}},Xu=typeof WeakMap==`function`?WeakMap:Map,Y=0,Zu=null,X=null,Z=0,Qu=0,$u=null,ed=!1,td=!1,nd=!1,rd=0,id=0,Q=0,ad=0,od=0,sd=0,cd=0,ld=null,ud=null,dd=!1,fd=0,pd=0,md=1/0,hd=null,gd=null,_d=0,vd=null,yd=null,bd=0,xd=0,Sd=null,Cd=null,wd=null,Td=null,Ed=null,Dd=0,Od=null;function kd(){return Y&2&&Z!==0?Z&-Z:E.T===null?Ot():Nf()}function Ad(){if(sd===0){if(!(Z&536870912)||P){var e=ft;ft<<=1,!(ft&3932160)&&(ft=262144),sd=e}else sd=536870912}return e=Io.current,e!==null&&(e.flags|=32),sd}function jd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Pp(Ti(e.memoizedProps,n))),Td===null&&(Td=[]),Td.push(t.bind(null,r))}}function Md(e,t,n){(e===Zu&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)&&(zd(e,0),Id(e,Z,sd,!1)),xt(e,n),Y&2&&e===Zu||(e===Zu&&(!(Y&2)&&(ad|=n),id===4&&Id(e,Z,sd,!1)),Tf(e))}function Nd(e,t,n){if(Y&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||gt(e,t),a=r?qd(e,t):Gd(e,t,!0),o=r;do{if(a===0){td&&!r&&Id(e,t,0,!1);break}if(n=e.current.alternate,o&&!Fd(n))a=Gd(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ld;var l=c.current.memoizedState.isDehydrated;if(l&&(zd(c,s).flags|=256),s=Gd(c,s,!1),s!==2&&s!==6){if(nd&&!l){c.errorRecoveryDisabledLanes|=o,ad|=o,a=4;break a}o=ud,ud=a,o!==null&&(ud===null?ud=o:ud.push.apply(ud,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){zd(e,0),Id(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Id(r,t,sd,!ed);break a;case 2:ud=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=fd+300-Ye(),10<a)){if(Id(r,t,sd,!ed),ht(r,0,!0)!==0)break a;bd=t,r.timeoutHandle=gp(Pd.bind(null,r,n,ud,hd,dd,t,sd,ad,cd,ed,o,`Throttled`,-0,0),a);break a}Pd(r,n,ud,hd,dd,t,sd,ad,cd,ed,o,null,-0,0)}break}}while(1);Tf(e)}function Pd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:On},Wl=null,Uu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=nh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?fd-Ye():(a&4194048)===a?pd-Ye():0,m=eh(d,m),m!==null)?(bd=a,e.cancelPendingCommit=m(ef.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Id(e,a,o,!l)):ef(e,t,a,n,r,i,o,s,c,l,u,d)}function Fd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Yr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Id(e,t,n,r){t=_t(e,t),t&=~od,t&=~ad,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-st(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ct(e,n,t)}function Ld(){return Y&6?!0:(Ef(0,!1),!1)}function Rd(){if(X!==null){if(Qu===0)var e=X.return;else e=X,Ca=Sa=null,us(e),fo=null,po=0,e=X;for(;e!==null;)wl(e.alternate,e),e=e.return;X=null}}function zd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,_p(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),bd=0,Rd(),Zu=e,X=n=Vi(e.current,null),Z=t,Qu=0,$u=null,ed=!1,td=gt(e,t),nd=!1,cd=sd=od=ad=Q=id=0,ud=ld=null,dd=!1,rd=_t(e,t),Mi(),n}function Bd(e,t){I=null,E.H=yc,t===to||t===ro?(t=lo(),Qu=3):t===no?(t=lo(),Qu=4):Qu=t===Ic?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,$u=t,X===null&&(id=1,Ac(e,Yi(t,e.current)))}function Vd(){var e=Io.current;return e===null?!0:(Z&4194048)===Z?Lo===null:(Z&62914560)===Z||Z&536870912?e===Lo:!1}function Hd(){var e=E.H;return E.H=yc,e===null?yc:e}function Ud(){var e=E.A;return E.A=Yu,e}function Wd(){id=4,ed||(Z&4194048)!==Z&&Io.current!==null||(td=!0),!(Q&134217727)&&!(ad&134217727)||Zu===null||Id(Zu,Z,sd,!1)}function Gd(e,t,n){var r=Y;Y|=2;var i=Hd(),a=Ud();(Zu!==e||Z!==t)&&(hd=null,zd(e,t)),t=!1;var o=id;a:do try{if(Qu!==0&&X!==null){var s=X,c=$u;switch(Qu){case 8:Rd(),o=6;break a;case 3:case 2:case 9:case 6:Io.current===null&&(t=!0);var l=Qu;if(Qu=0,$u=null,Zd(e,s,c,l),n&&td){o=0;break a}break;default:l=Qu,Qu=0,$u=null,Zd(e,s,c,l)}}Kd(),o=id;break}catch(t){Bd(e,t)}while(1);return t&&e.shellSuspendCounter++,Ca=Sa=null,Y=r,E.H=i,E.A=a,X===null&&(Zu=null,Z=0,Mi()),o}function Kd(){for(;X!==null;)Yd(X)}function qd(e,t){var n=Y;Y|=2;var r=Hd(),a=Ud();Zu!==e||Z!==t?(hd=null,md=Ye()+500,zd(e,t)):td=gt(e,t);a:do try{if(Qu!==0&&X!==null){t=X;var o=$u;b:switch(Qu){case 1:Qu=0,$u=null,Zd(e,t,o,1);break;case 2:case 9:if(ao(o)){Qu=0,$u=null,Xd(t);break}t=function(){Qu!==2&&Qu!==9||Zu!==e||(Qu=7),Tf(e)},o.then(t,t);break a;case 3:Qu=7;break a;case 4:Qu=5;break a;case 7:ao(o)?(Qu=0,$u=null,Xd(t)):(Qu=0,$u=null,Zd(e,t,o,7));break;case 5:var s=null;switch(X.tag){case 26:s=X.memoizedState;case 5:case 27:var c=X;if(s?Ym(s):c.stateNode.complete){Qu=0,$u=null;var l=c.sibling;if(l!==null)X=l;else{var u=c.return;u===null?X=null:(X=u,Qd(u))}break b}}Qu=0,$u=null,Zd(e,t,o,5);break;case 6:Qu=0,$u=null,Zd(e,t,o,6);break;case 8:Rd(),id=6;break a;default:throw Error(i(462))}}Jd();break}catch(t){Bd(e,t)}while(1);return Ca=Sa=null,E.H=r,E.A=a,Y=n,X===null?(Zu=null,Z=0,Mi(),id):0}function Jd(){for(;X!==null&&!qe();)Yd(X)}function Yd(e){var t=hl(e.alternate,e,rd);e.memoizedProps=e.pendingProps,t===null?Qd(e):X=t}function Xd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Yc(n,t,t.pendingProps,t.type,void 0,Z);break;case 11:t=Yc(n,t,t.pendingProps,t.type.render,t.ref,Z);break;case 5:us(t);var r=t;r===ua&&(P?(ga(r),r.tag===5&&r.stateNode!=null&&(N=r.stateNode)):(ga(r),P=!0));default:wl(n,t),t=X=Hi(t,rd),t=hl(n,t,rd)}e.memoizedProps=e.pendingProps,t===null?Qd(e):X=t}function Zd(e,t,n,r){Ca=Sa=null,us(t),fo=null,po=0;var i=t.return;try{if(Fc(e,i,t,n,Z)){id=1,Ac(e,Yi(n,e.current)),X=null;return}}catch(t){if(i!==null)throw X=i,t;id=1,Ac(e,Yi(n,e.current)),X=null;return}t.flags&32768?(P||r===1?e=!0:td||Z&536870912?e=!1:(ed=e=!0,(r===2||r===9||r===3||r===6)&&(r=Io.current,r!==null&&r.tag===13&&(r.flags|=16384))),$d(t,e)):Qd(t)}function Qd(e){var t=e;do{if(t.flags&32768){$d(t,ed);return}e=t.return;var n=Sl(t.alternate,t,rd);if(n!==null){X=n;return}if(t=t.sibling,t!==null){X=t;return}X=t=e}while(t!==null);id===0&&(id=5)}function $d(e,t){do{var n=Cl(e.alternate,e);if(n!==null){n.flags&=32767,X=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){X=e;return}X=e=n}while(e!==null);id=6,X=null}function ef(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do lf();while(_d!==0);if(Y&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===Zu&&(X=Zu=null,Z=0),yd=t,vd=e,bd=n,Sd=a,Cd=r,tf(e,t,n,s,c,l,f)}}function tf(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(xd=s,s|=ji,St(e,n,s,r,i,a),Td=null,(n&335544064)===n?(Ed=Ha(e),r=10262):(Ed=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,vf($e,function(){return uf(),null})):(e.callbackNode=null,e.callbackPriority=0),Ul=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=E.T,E.T=null,i=D.p,D.p=2,a=Y,Y|=4;try{vu(e,t,n)}finally{Y=a,D.p=i,E.T=r}}_d=1,Ul?wd=Mp(o,e.containerInfo,Ed,af,of,rf,sf,uf,nf,null,null):(af(),of(),sf())}function nf(e){if(_d!==0){var t=vd.onRecoverableError;t(e,{componentStack:null})}}function rf(){_d===3&&(_d=0,Nu(yd,vd),_d=4)}function af(){if(_d===1){_d=0;var e=vd,t=yd,n=bd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=E.T,E.T=null;var i=D.p;D.p=2;var a=Y;Y|=4;try{hu=gu=!1,ku(t,e,n),n=cp;var o=ti(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&ei(s.ownerDocument.documentElement,s)){if(c!==null&&ni(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=$r(s,h),v=$r(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}gh=!!sp,cp=sp=null}finally{Y=a,D.p=i,E.T=r}}e.current=t,_d=2}}function of(){if(_d===2){_d=0;var e=vd,t=yd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=E.T,E.T=null;var r=D.p;D.p=2;var i=Y;Y|=4;try{bu(e,t.alternate,t)}finally{Y=i,D.p=r,E.T=n}}_d=3}}function sf(){if(_d===4||_d===3){_d=0;var e=wd;wd=null,Je();var t=vd,n=yd,r=bd,i=Cd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?_d=5:(_d=0,yd=vd=null,cf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(gd=null),Dt(r),n=n.stateNode,at&&typeof at.onCommitFiberRoot==`function`)try{at.onCommitFiberRoot(it,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=E.T,a=D.p,D.p=2,E.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{E.T=n,D.p=a}}if(i=Td,o=Ed,Ed=null,i!==null&&(Td=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);bd&3&&lf(),Tf(t),a=t.pendingLanes,r&261930&&a&42?t===Od?Dd++:(Dd=0,Od=t):(Dd=0,Od=null),Ef(0,!1)}}function cf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,za(t)))}function lf(){return wd!==null&&(wd.skipTransition(),wd=null),af(),of(),sf(),uf()}function uf(){if(_d!==5)return!1;var e=vd,t=xd;xd=0;var n=Dt(bd),r=E.T,a=D.p;try{D.p=32>n?32:n,E.T=null,n=Sd,Sd=null;var o=vd,s=bd;if(_d=0,yd=vd=null,bd=0,Y&6)throw Error(i(331));var c=Y;if(Y|=4,Ku(o.current),Ru(o,o.current,s,n),Y=c,Ef(0,!1),at&&typeof at.onPostCommitFiberRoot==`function`)try{at.onPostCommitFiberRoot(it,o)}catch{}return!0}finally{D.p=a,E.T=r,cf(e,t)}}function df(e,t,n){t=Yi(n,t),t=Mc(e.stateNode,t,2),e=Co(e,t,2),e!==null&&(xt(e,2),Tf(e))}function ff(e,t,n){if(e.tag===3)df(e,e,n);else for(;t!==null;){if(t.tag===3){df(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(gd===null||!gd.has(r))){e=Yi(n,e),n=Nc(2),r=Co(t,n,2),r!==null&&(Pc(n,r,t,e),xt(r,2),Tf(r));break}}t=t.return}}function pf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Xu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(nd=!0,i.add(n),e=mf.bind(null,e,t,n),t.then(e,e))}function mf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Zu===e&&(Z&n)===n&&(id===4||id===3&&(Z&62914560)===Z&&300>Ye()-fd?Y&2?od|=n:zd(e,0):od|=n,cd===Z&&(cd=0)),Tf(e)}function hf(e,t){t===0&&(t=yt()),e=Pi(e,t),e!==null&&(xt(e,t),Tf(e))}function gf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),hf(e,n)}function _f(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),hf(e,n)}function vf(e,t){return Ge(e,t)}var yf=null,bf=null,xf=!1,Sf=!1,Cf=!1,wf=0;function Tf(e){e!==bf&&e.next===null&&(bf===null?yf=bf=e:bf=bf.next=e),Sf=!0,xf||(xf=!0,Mf())}function Ef(e,t){if(!Cf&&Sf){Cf=!0;do for(var n=!1,r=yf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-st(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,jf(r,a))}else a=Z,a=ht(r,r===Zu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||gt(r,a)||(n=!0,jf(r,a))}r=r.next}while(n);Cf=!1}}function Df(){Of()}function Of(){Sf=xf=!1;var e=0;wf!==0&&hp()&&(e=wf);for(var t=Ye(),n=null,r=yf;r!==null;){var i=r.next,a=kf(r,t);a===0?(r.next=null,n===null?yf=i:n.next=i,i===null&&(bf=n)):(n=r,(e!==0||a&3)&&(Sf=!0)),r=i}_d!==0&&_d!==5||Ef(e,!1),wf!==0&&(wf=0)}function kf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-st(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=vt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Zu,n=Z,n=ht(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Ke(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||gt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Ke(r),Dt(n)){case 2:case 8:n=Qe;break;case 32:n=$e;break;case 268435456:n=tt;break;default:n=$e}return r=Af.bind(null,e),n=Ge(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Ke(r),e.callbackPriority=2,e.callbackNode=null,2}function Af(e,t){if(_d!==0&&_d!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(lf()&&e.callbackNode!==n)return null;var r=Z;return r=ht(e,e===Zu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Nd(e,r,t),kf(e,Ye()),e.callbackNode!=null&&e.callbackNode===n?Af.bind(null,e):null)}function jf(e,t){if(lf())return null;Nd(e,t,!0)}function Mf(){bp(function(){Y&6?Ge(Ze,Df):Of()})}function Nf(){if(wf===0){var e=Ga;e===0&&(e=dt,dt<<=1,!(dt&261888)&&(dt=256)),wf=e}return wf}function Pf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Dn(e)}function Ff(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Pf((i[Mt]||null).action),o=r.submitter;o&&(t=(t=o[Mt]||null)?Pf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Yn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(wf!==0){var e=new FormData(i,o);ac(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),ac(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var If=0;If<Si.length;If++){var Lf=Si[If];Ci(Lf.toLowerCase(),`on`+(Lf[0].toUpperCase()+Lf.slice(1)))}Ci(mi,`onAnimationEnd`),Ci(hi,`onAnimationIteration`),Ci(gi,`onAnimationStart`),Ci(`dblclick`,`onDoubleClick`),Ci(`focusin`,`onFocus`),Ci(`focusout`,`onBlur`),Ci(_i,`onTransitionRun`),Ci(vi,`onTransitionStart`),Ci(yi,`onTransitionCancel`),Ci(bi,`onTransitionEnd`),Xt(`onMouseEnter`,[`mouseout`,`mouseover`]),Xt(`onMouseLeave`,[`mouseout`,`mouseover`]),Xt(`onPointerEnter`,[`pointerout`,`pointerover`]),Xt(`onPointerLeave`,[`pointerout`,`pointerover`]),Yt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Yt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Yt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Yt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Yt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Yt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Rf=`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(` `),zf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Rf));function Bf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Oi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Oi(e)}i.currentTarget=null,a=c}}}}function $(e,t){var n=t[Pt];n===void 0&&(n=t[Pt]=new Set);var r=e+`__bubble`;n.has(r)||(Wf(t,e,2,!1),n.add(r))}function Vf(e,t,n){var r=0;t&&(r|=4),Wf(n,e,r,t)}var Hf=`_reactListening`+Math.random().toString(36).slice(2);function Uf(e){if(!e[Hf]){e[Hf]=!0,qt.forEach(function(t){t!==`selectionchange`&&(zf.has(t)||Vf(t,!1,e),Vf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Hf]||(t[Hf]=!0,Vf(`selectionchange`,!1,t))}}function Wf(e,t,n,r){switch(Ch(t)){case 2:var i=_h;break;case 8:i=vh;break;default:i=yh}n=i.bind(null,t,n,e),i=void 0,!Rn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Gf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=Vt(s),o===null)return;if(l=o.tag,l===5||l===6||l===26||l===27){r=a=o;continue a}s=s.parentNode}}r=r.return}Fn(function(){var r=a,i=An(n),o=[];a:{var s=xi.get(e);if(s!==void 0){var l=Yn,u=e;switch(e){case`keypress`:if(Wn(n)===0)break a;case`keydown`:case`keyup`:l=pr;break;case`focusin`:u=`focus`,l=ir;break;case`focusout`:u=`blur`,l=ir;break;case`beforeblur`:case`afterblur`:l=ir;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=nr;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=rr;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=gr;break;case mi:case hi:case gi:l=ar;break;case bi:l=_r;break;case`scroll`:case`scrollend`:l=Zn;break;case`wheel`:l=vr;break;case`copy`:case`cut`:case`paste`:l=or;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=mr;break;case`submit`:l=hr;break;case`toggle`:case`beforetoggle`:l=yr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=In(m,p),g!=null&&d.push(Kf(m,g,h))),f)break;m=m.return}0<d.length&&(s=new l(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,s=e===`mouseout`||e===`pointerout`,l&&n!==kn&&(u=n.relatedTarget||n.fromElement)&&(Vt(u)||u[Nt]))break a;(s||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,s?(l=n.relatedTarget||n.toElement,s=r,l=l?Vt(l):null,l!==null&&(f=c(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(s=null,l=r),s!==l&&(d=nr,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=mr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=s==null?u:Ut(s),h=l==null?u:Ut(l),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,Vt(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=s&&l?w(s,l,Jf):null,s!==null&&Yf(o,u,s,d,!1),l!==null&&f!==null&&Yf(o,f,l,d,!0)))}a:{if(s=r?Ut(r):window,l=s.nodeName&&s.nodeName.toLowerCase(),l===`select`||l===`input`&&s.type===`file`)var _=Rr;else if(Mr(s)){if(zr)_=qr;else{_=Gr;var v=Wr}}else l=s.nodeName,!l||l.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&wn(r.elementType)&&(_=Rr):_=Kr;if(_&&=_(e,r)){Nr(o,_,n,i);break a}v&&v(e,s,r)}switch(v=r?Ut(r):window,e){case`focusin`:(Mr(v)||v.contentEditable===`true`)&&(ii=v,ai=r,oi=null);break;case`focusout`:oi=ai=ii=null;break;case`mousedown`:si=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:si=!1,ci(o,n,i);break;case`selectionchange`:if(ri)break;case`keydown`:case`keyup`:ci(o,n,i)}var y;if(xr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else A?Dr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(wr&&n.locale!==`ko`&&(A||b!==`onCompositionStart`?b===`onCompositionEnd`&&A&&(y=Un()):(Bn=i,Vn=`value`in Bn?Bn.value:Bn.textContent,A=!0)),v=qf(r,b),0<v.length&&(b=new sr(b,e,null,n,i),o.push({event:b,listeners:v}),y?b.data=y:(y=Or(n),y!==null&&(b.data=y)))),(y=Cr?kr(e,n):Ar(e,n))&&(b=qf(r,`onBeforeInput`),0<b.length&&(v=new sr(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:v,listeners:b}),v.data=y)),Ff(o,e,r,n,i)}Bf(o,t)})}function Kf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=In(e,n),i!=null&&r.unshift(Kf(e,i,a)),i=In(e,t),i!=null&&r.push(Kf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Jf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Yf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=In(n,a),l!=null&&o.unshift(Kf(n,l,c))):i||(l=In(n,a),l!=null&&o.push(Kf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Xf=/\r\n?/g,Zf=/\u0000|\uFFFD/g;function Qf(e){return(typeof e==`string`?e:``+e).replace(Xf,`
9
+ `).replace(Zf,``)}function $f(e,t){return t=Qf(t),Qf(e)===t}function ep(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||bn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&bn(e,``+r);else return;break;case`className`:an(e,`class`,r);break;case`tabIndex`:an(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:an(e,n,r);break;case`style`:Cn(e,r,o);return;case`data`:if(t!==`object`){an(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Dn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`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}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&ep(e,t,`name`,a.name,a,null),ep(e,t,`formEncType`,a.formEncType,a,null),ep(e,t,`formMethod`,a.formMethod,a,null),ep(e,t,`formTarget`,a.formTarget,a,null)):(ep(e,t,`encType`,a.encType,a,null),ep(e,t,`method`,a.method,a,null),ep(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Dn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=On);return;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Dn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`: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`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:$(`beforetoggle`,e),$(`toggle`,e),rn(e,`popover`,r);break;case`xlinkActuate`:on(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:on(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:on(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:on(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:on(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:on(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:on(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:on(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:on(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:rn(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=Tn.get(n)||n,rn(e,n,r);else return}tn=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:Cn(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)bn(e,r);else if(typeof r==`number`||typeof r==`bigint`)bn(e,``+r);else return;break;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=On);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Jt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[Mt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}tn=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):rn(e,n,r)}return}tn=!0}function np(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:$(`error`,e),$(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,o,s,n,null)}}a&&ep(e,t,`srcSet`,n.srcSet,n,null),r&&ep(e,t,`src`,n.src,n,null);return;case`input`:$(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:ep(e,t,r,d,n,null)}}hn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in $(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:ep(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&_n(e,!!r,n,!0):_n(e,!!r,t,!1);return;case`textarea`:for(s in $(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:ep(e,t,s,c,n,null)}yn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:ep(e,t,l,r,n,null)}return;case`dialog`:$(`beforetoggle`,e),$(`toggle`,e),$(`cancel`,e),$(`close`,e);break;case`iframe`:case`object`:$(`load`,e);break;case`video`:case`audio`:for(r=0;r<Rf.length;r++)$(Rf[r],e);break;case`image`:$(`error`,e),$(`load`,e);break;case`details`:$(`toggle`,e);break;case`embed`:case`source`:case`link`:$(`error`,e),$(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,u,r,n,null)}return;default:if(wn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&tp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&ep(e,t,c,r,n,null))}var rp={};function ip(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||ep(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(tn=!0),o=m;break;case`name`:m!==f&&(tn=!0),a=m;break;case`checked`:m!==f&&(tn=!0),u=m;break;case`defaultChecked`:m!==f&&(tn=!0),d=m;break;case`value`:m!==f&&(tn=!0),s=m;break;case`defaultValue`:m!==f&&(tn=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&ep(e,t,p,m,r,f)}}mn(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||ep(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(tn=!0),p=o;break;case`defaultValue`:o!==l&&(tn=!0),c=o;break;case`multiple`:o!==l&&(tn=!0),s=o;default:o!==l&&ep(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?_n(e,!!n,n?[]:``,!1):_n(e,!!n,t,!0)):_n(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:ep(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(tn=!0),p=a;break;case`defaultValue`:a!==o&&(tn=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&ep(e,t,s,a,r,o)}vn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:ep(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(tn=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:ep(e,t,l,p,r,m)}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 g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&ep(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:ep(e,t,u,p,r,m)}return;default:if(wn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&tp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||tp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&ep(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||ep(e,t,f,p,r,m)}function ap(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function op(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&ap(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var sp=null,cp=null;function lp(e){return e.nodeType===9?e:e.ownerDocument}function up(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function fp(e,t,n,r){return n=lp(n).createElement(e),n[jt]=r,n[Mt]=t,np(n,e,t),Gt(n),n}function pp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var mp=null;function hp(){var e=window.event;return e&&e.type===`popstate`?e!==mp&&(mp=e,!0):(mp=null,!1)}var gp=typeof setTimeout==`function`?setTimeout:void 0,_p=typeof clearTimeout==`function`?clearTimeout:void 0,vp=typeof Promise==`function`?Promise:void 0,yp=typeof requestAnimationFrame==`function`?requestAnimationFrame:gp,bp=typeof queueMicrotask==`function`?queueMicrotask:vp===void 0?gp:function(e){return vp.resolve(null).then(e).catch(xp)};function xp(e){setTimeout(function(){throw e})}function Sp(e){return e===`head`}function Cp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_m(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_m(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Rt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_m(e.ownerDocument.body)}n=i}while(n);Hh(t)}function wp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Tp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Ep(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Dp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Op(e){return Dp(e.getBoundingClientRect(),getComputedStyle(e),e)}function kp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Dp(t,n,e)}function Ap(e){return e.documentElement.clientHeight}function jp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Mp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Ap(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Xm(f),u>$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Np(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Np.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:T({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Np.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Np.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Pp(e){return{name:e,group:new Np(`group`,e),imagePair:new Np(`image-pair`,e),old:new Np(`old`,e),new:new Np(`new`,e)}}function Fp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Fp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Bp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Rp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Ip,e,s,r)}this._eventListeners=a}};function Ip(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Fp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Bp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Rp(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,Lp,e,n,i),r.splice(t,1),a!==null&&a()}};function Lp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Rp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function zp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Bp(e,t,n,r){if(e.length===0)return-1;r=zp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&zp(a.optionsOrUseCapture)===r)return i}return-1}Fp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Fp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Vp,e,void 0,void 0)};function Vp(e,t){return e.tag!==6&&(e=b(e),pm(e,t))}Fp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Hp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Vp(t[n],e);n--);};function Hp(e,t){return t.push(e),!1}Fp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=lp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Up,e,void 0,void 0))};function Up(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Fp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Wp,e,void 0,void 0)};function Wp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Fp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0);for(var n=t=0;n<Kp.length;n++){var r=Kp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Kp[t++]=r}Kp.length=t}};function Gp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var Kp=[],qp=!1;function Jp(e,t,n){Kp.push({fragmentInstance:e,observer:t,instance:n}),qp||(qp=!0,mm(function(){qp=!1;var e=Kp;Kp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Fp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Yp,e,void 0,void 0),e};function Yp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Fp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Fp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Hp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Xp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Xp(e,t,n,r,i){var a=Vt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=w(n,a,C),t===null?t=!1:(h(t,!0,ee,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=w(r,a,C),t===null?t=!1:(h(t,!0,te,a,r),a=x,S=x=null,t=a!==null)),t):!1}function Zp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Fp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];h(this._fragmentFiber.child,!1,Hp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),Zp(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=b(a),Zp(a,n)):b(a).scrollIntoView(e),r+=n?-1:1}};function Qp(e,t){return e=b(e),$p(e,t),!1}function $p(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function em(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Kp.length;i++){var a=Kp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Kp[r++]=a)}Kp.length=r,n.observe(e)}),$p(e,t))}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Jp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nm(n),Bt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Rt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lm(e.nextSibling),e===null)break}return null}function im(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lm(e.nextSibling),e===null))return null;return e}function am(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lm(e.nextSibling),e===null))return null;return e}function om(e){return e.data===`$?`||e.data===`$~`}function sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var um=null;function dm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function fm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function mm(e){yp(function(){yp(function(t){return e(t)})})}function hm(e,t,n){switch(t=lp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function gm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&ep(e,t,r,null,rp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===On&&(e.onclick=null),Bt(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Bt(e)}var vm=new Map,ym=new Set;function bm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var xm=D.d;D.d={f:Sm,r:Cm,D:Em,C:Dm,L:Om,m:km,X:jm,S:Am,M:Mm};function Sm(){var e=xm.f(),t=Ld();return e||t}function Cm(e){var t=Ht(e);t!==null&&t.tag===5&&t.type===`form`?sc(t):xm.r(e)}var wm=typeof document>`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=pn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Gt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+pn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+pn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+pn(n.imageSizes)+`"]`)):i+=`[href="`+pn(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=T({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[zt]=!0,o.onload=o.onerror=function(){Kt(o)}),Gt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+pn(r)+`"][href="`+pn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=T({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Gt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Wt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=T({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Gt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Wt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Gt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Wt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Gt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=Ne.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Wt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Wt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Wt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+pn(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return T({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[zt]){r.loading=1;return}}else t=e.createElement(`link`),t[zt]=!0,t.onload=t.onerror=Kt.bind(null,t),np(t,`link`,n),Gt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+pn(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+pn(n.href)+`"]`);if(r)return t.instance=r,Gt(r),r;var a=T({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Gt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Gt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Gt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Gt(a),a):(r=n,(a=vm.get(o))&&(r=T({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Gt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wm=null;function Gm(e,t,n){if(Wm===null){var r=new Map,i=Wm=new Map;i.set(n,r)}else i=Wm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Rt]||a[jt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Km(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Gt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Gt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$m===0&&($m=62500*op());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=nh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sh={$$typeof:le,Provider:null,Consumer:null,_currentValue:Te,_currentValue2:Te,_threadCount:0};function ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,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=bt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bt(0),this.hiddenUpdates=bt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function lh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=zi(3,null,null,t),e.current=a,a.stateNode=e,t=Ra(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},bo(a),e}function uh(e){return e?(e=Li,e):Li}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=So(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Co(e,r,t),n!==null&&(Md(n,e,t),wo(n,e,t))}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(e.tag===13||e.tag===31){var t=Pi(e,67108864);t!==null&&Md(t,e,67108864),ph(e,67108864)}}function hh(e){if(e.tag===13||e.tag===31){var t=kd();t=Et(t);var n=Pi(e,t);n!==null&&Md(n,e,t),ph(e,t)}}var gh=!0;function _h(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=2,yh(e,t,n,r)}finally{D.p=a,E.T=i}}function vh(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=8,yh(e,t,n,r)}finally{D.p=a,E.T=i}}function yh(e,t,n,r){if(gh){var i=bh(r);if(i===null)Gf(e,t,r,xh,n),Mh(e,r);else if(Ph(i,e,t,n,r))r.stopPropagation();else if(Mh(e,r),t&4&&-1<jh.indexOf(e)){for(;i!==null;){var a=Ht(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=mt(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-st(o);s.entanglements[1]|=c,o&=~c}Tf(a),!(Y&6)&&(md=Ye()+500,Ef(0,!1))}}break;case 31:case 13:s=Pi(a,2),s!==null&&Md(s,a,2),Ld(),ph(a,2)}if(a=bh(r),a===null&&Gf(e,t,r,xh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Gf(e,t,r,null,n)}}function bh(e){return e=An(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=Vt(e),e!==null){var t=c(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xh=e,null}function Ch(e){switch(e){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`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`fullscreenerror`: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`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Xe()){case Ze:return 2;case Qe:return 8;case $e:case et:return 32;case tt:return 268435456;default:return 32}default:return 32}}var wh=!1,Th=null,Eh=null,Dh=null,Oh=new Map,kh=new Map,Ah=[],jh=`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 Mh(e,t){switch(e){case`focusin`:case`focusout`:Th=null;break;case`dragenter`:case`dragleave`:Eh=null;break;case`mouseover`:case`mouseout`:Dh=null;break;case`pointerover`:case`pointerout`:Oh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kh.delete(t.pointerId)}}function Nh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ht(t),t!==null&&mh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ph(e,t,n,r,i){switch(t){case`focusin`:return Th=Nh(Th,e,t,n,r,i),!0;case`dragenter`:return Eh=Nh(Eh,e,t,n,r,i),!0;case`mouseover`:return Dh=Nh(Dh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Oh.set(a,Nh(Oh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kh.set(a,Nh(kh.get(a)||null,e,t,n,r,i)),!0}return!1}function Fh(e){var t=Vt(e.target);if(t!==null){var n=c(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,kt(e.priority,function(){hh(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,kt(e.priority,function(){hh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);kn=r,n.target.dispatchEvent(r),kn=null}else return t=Ht(n),t!==null&&mh(t),e.blockedOn=n,!1;t.shift()}return!0}function Lh(e,t,n){Ih(e)&&n.delete(t)}function Rh(){wh=!1,Th!==null&&Ih(Th)&&(Th=null),Eh!==null&&Ih(Eh)&&(Eh=null),Dh!==null&&Ih(Dh)&&(Dh=null),Oh.forEach(Lh),kh.forEach(Lh)}function zh(e,n){e.blockedOn===n&&(e.blockedOn=null,wh||(wh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rh)))}var Bh=null;function Vh(e){Bh!==e&&(Bh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bh===e&&(Bh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sh(r||n)===null)continue;break}var a=Ht(n);a!==null&&(e.splice(t,3),t-=3,ac(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hh(e){function t(t){return zh(t,e)}Th!==null&&zh(Th,e),Eh!==null&&zh(Eh,e),Dh!==null&&zh(Dh,e),Oh.forEach(t),kh.forEach(t);for(var n=0;n<Ah.length;n++){var r=Ah[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ah.length&&(n=Ah[0],n.blockedOn===null);)Fh(n),n.blockedOn===null&&Ah.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Mt]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Mt]||null)s=o.formAction;else if(Sh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vh(n)}}}function Uh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wh(e){this._internalRoot=e}Gh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dh(n,kd(),e,t,null,null)},Gh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dh(e.current,2,null,e,null,null),Ld(),t[Nt]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ot();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ah.length&&t!==0&&t<Ah[n].priority;n++);Ah.splice(n,0,e),n===0&&Fh(e)}};var Kh=n.version;if(Kh!==`19.3.1`)throw Error(i(527,Kh,`19.3.1`));D.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var qh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:E,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jh.isDisabled&&Jh.supportsFiber)try{it=Jh.inject(qh),at=Jh}catch{}}e.createRoot=function(e,t){if(!o(e))throw Error(i(299));var n=!1,r=``,a=Dc,s=Oc,c=kc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(a=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lh(e,1,!1,null,null,n,r,null,a,s,c,Uh),e[Nt]=t.current,Uf(e),new Wh(t)}})),d=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=u()})),f=e=>(e.match(/\d+[xX]\d+|[A-Z]?[a-z]+|[A-Z]|\d+/g)??[]).join(`-`).toLowerCase();function p(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:f(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var m=e=>{let t=``,n=!1;for(let r of e)r===`-`||r===`_`||r<=` `?n=t.length>0:(t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1);return t},h=e=>{let t=m(e);return t.charAt(0).toUpperCase()+t.slice(1)},g=(...e)=>{let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of n.split(/\s+/))e&&t.add(e);return[...t].join(` `)},_={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function v(e){return e!=null}function y(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??_.width,a=e.size??e.height??_.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?g(...c):g(`lucide`,...s,...c),u=t.strokeWidth??_[`stroke-width`];if(t.absoluteStrokeWidth){let n=Number(u)*Number(e.size??e.width??_.width)/Number(t.size??t.width??_.width);Number.isFinite(n)&&(u=n)}return[`svg`,{...Object.entries(_).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&v(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&v(t.width)&&{[r(`width`)]:t.width},...`height`in t&&v(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function b(e,t={}){return y(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var x=e=>{if(typeof e!=`object`||!e)return!1;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&(t.startsWith(`aria-`)||t===`role`||t===`title`)&&e[t]!=null)return!0;return!1},S=a(),ee=(0,S.createContext)({}),te=()=>(0,S.useContext)(ee),C=(0,S.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:_=!1,color:v=`currentColor`,className:y=``}=te()??{},ee=!!c||x(d),[C,w,T=[]]=b(u,{color:e??v,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??_,className:g(y,s),hasA11yProp:ee,attributes:d});return(0,S.createElement)(C,{ref:f,...w},[...T.map(([e,t])=>(0,S.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function w(e,t=[],n=[]){let r=typeof e==`string`?p(e,t,n):e,i=(0,S.forwardRef)(({className:e,...t},n)=>(0,S.createElement)(C,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=h(r.name)),i}var T={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};T.node;var ne=w(T),re={name:`arrow-left-right`,size:24,node:[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]};re.node;var ie=w(re),ae={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};ae.node;var oe=w(ae),se={name:`arrow-up-to-line`,size:24,node:[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]};se.node;var ce=w(se),le={name:`arrows-to-axis-dashed-horizontal`,size:24,node:[[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}]],aliases:[`fold-vertical`]};le.node;var ue=w(le),de={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};de.node;var fe=w(de),pe={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};pe.node;var me=w(pe),he={name:`brush`,size:24,node:[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]};he.node;var ge=w(he),_e={name:`carets-to-axis-dashed-vertical`,size:24,node:[[`path`,{d:`M12 14v2`,key:`8jcxud`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 8v2`,key:`1woqiv`}],[`path`,{d:`M20.288 16.703A1 1 0 0 0 22 16V8a1 1 0 0 0-1.712-.703l-3.99 3.991a1 1 0 0 0-.001 1.424z`,key:`yp0klk`}],[`path`,{d:`M3.712 16.703A1 1 0 0 1 2 16V8a1 1 0 0 1 1.712-.703l3.99 3.991a1 1 0 0 1 .001 1.424z`,key:`1pfpix`}]],aliases:[`flip-vertical-2`,`triangles-centerline-dashed-vertical`]};_e.node;var ve=w(_e),ye={name:`carets-to-axis-dashed-horizontal`,size:24,node:[[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M7.298 20.288A1 1 0 0 0 8 22h8a1 1 0 0 0 .703-1.712l-3.991-3.99a1 1 0 0 0-1.424-.001z`,key:`8e5jlf`}],[`path`,{d:`M7.298 3.712A1 1 0 0 1 8 2h8a1 1 0 0 1 .703 1.712l-3.991 3.99a1 1 0 0 1-1.424.001z`,key:`13b1h1`}]],aliases:[`flip-horizontal-2`,`triangles-centerline-dashed-horizontal`]};ye.node;var be=w(ye),xe={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};xe.node;var Se=w(xe),Ce={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Ce.node;var we=w(Ce),E={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};E.node;var D=w(E),Te={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Te.node;var Ee=w(Te),De={name:`circle-exclamation-point`,size:24,node:[[`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`}]],aliases:[`alert-circle`,`circle-alert`]};De.node;var Oe=w(De),ke={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};ke.node;var Ae=w(ke),je={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};je.node;var Me=w(je),Ne={name:`copy`,size:24,node:[[`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`}]]};Ne.node;var Pe=w(Ne),Fe={name:`crop`,size:24,node:[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`,key:`ron5a4`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`,key:`7s9ehn`}]]};Fe.node;var O=w(Fe),k={name:`crosshair`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]};k.node;var Ie=w(k),Le={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Le.node;var Re=w(Le),ze={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};ze.node;var Be=w(ze),Ve={name:`eye-off`,size:24,node:[[`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`}]]};Ve.node;var He=w(Ve),Ue={name:`eye`,size:24,node:[[`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`}]]};Ue.node;var We=w(Ue),Ge={name:`file-image`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};Ge.node;var Ke=w(Ge),qe={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};qe.node;var Je=w(qe),Ye={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Ye.node;var Xe=w(Ye),Ze={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Ze.node;var Qe=w(Ze),$e={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};$e.node;var et=w($e),tt={name:`grip-vertical`,size:24,node:[[`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`}]]};tt.node;var nt=w(tt),rt={name:`hand`,size:24,node:[[`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`}]]};rt.node;var it=w(rt),at={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};at.node;var ot=w(at),st={name:`hexagon`,size:24,node:[[`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`}]]};st.node;var ct=w(st),lt={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};lt.node;var ut=w(lt),dt={name:`image-up`,size:24,node:[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};dt.node;var ft=w(dt),pt={name:`image`,size:24,node:[[`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`}]]};pt.node;var mt=w(pt),ht={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};ht.node;var gt=w(ht),_t={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};_t.node;var vt=w(_t),yt={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};yt.node;var bt=w(yt),xt={name:`lasso`,size:24,node:[[`path`,{d:`M3.704 14.467a10 8 0 1 1 3.115 2.375`,key:`wxgc5m`}],[`path`,{d:`M7 22a5 5 0 0 1-2-3.994`,key:`1xp6a4`}],[`circle`,{cx:`5`,cy:`16`,r:`2`,key:`18csp3`}]]};xt.node;var St=w(xt),Ct={name:`layers-2`,size:24,node:[[`path`,{d:`M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z`,key:`15q6uc`}],[`path`,{d:`m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845`,key:`byia6g`}]]};Ct.node;var wt=w(Ct),Tt={name:`layers`,size:24,node:[[`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`}]],aliases:[`layers-3`]};Tt.node;var Et=w(Tt),Dt={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};Dt.node;var Ot=w(Dt),kt={name:`link-2`,size:24,node:[[`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`}]]};kt.node;var At=w(kt),jt={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};jt.node;var Mt=w(jt),Nt={name:`lock-open`,size:24,node:[[`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`}]],aliases:[`unlock`]};Nt.node;var Pt=w(Nt),Ft={name:`lock`,size:24,node:[[`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`}]]};Ft.node;var It=w(Ft),Lt={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};Lt.node;var Rt=w(Lt),zt={name:`maximize`,size:24,node:[[`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`}]]};zt.node;var Bt=w(zt),Vt={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Vt.node;var Ht=w(Vt),Ut={name:`mouse-pointer-2`,size:24,node:[[`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`}]]};Ut.node;var Wt=w(Ut),Gt={name:`mouse-pointer-click`,size:24,node:[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]};Gt.node;var Kt=w(Gt),qt={name:`paint-bucket`,size:24,node:[[`path`,{d:`M11 7 6 2`,key:`1jwth8`}],[`path`,{d:`M18.992 12H2.041`,key:`xw1gg`}],[`path`,{d:`M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595`,key:`1nkol4`}],[`path`,{d:`m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33`,key:`1nk1rd`}]]};qt.node;var Jt=w(qt),Yt={name:`paintbrush`,size:24,node:[[`path`,{d:`m14.622 17.897-10.68-2.913`,key:`vj2p1u`}],[`path`,{d:`M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z`,key:`18tc5c`}],[`path`,{d:`M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15`,key:`ytzfxy`}]]};Yt.node;var Xt=w(Yt),Zt={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Zt.node;var Qt=w(Zt),$t={name:`pipette`,size:24,node:[[`path`,{d:`m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12`,key:`1y3wsu`}],[`path`,{d:`m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z`,key:`110lr1`}],[`path`,{d:`m2 22 .414-.414`,key:`jhxm08`}]]};$t.node;var en=w($t),tn={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};tn.node;var nn=w(tn),rn={name:`redo-2`,size:24,node:[[`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`}]]};rn.node;var an=w(rn),on={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};on.node;var sn=w(on),cn={name:`rotate-cw`,size:24,node:[[`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`}]]};cn.node;var ln=w(cn),un={name:`scan-face`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`path`,{d:`M9 9h.01`,key:`1q5me6`}],[`path`,{d:`M15 9h.01`,key:`x1ddxp`}]]};un.node;var dn=w(un),fn={name:`scan-line`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]};fn.node;var pn=w(fn),mn={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};mn.node;var hn=w(mn),gn={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};gn.node;var _n=w(gn),vn={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};vn.node;var yn=w(vn),bn={name:`shapes`,size:24,node:[[`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`}]]};bn.node;var xn=w(bn),Sn={name:`shield-check`,size:24,node:[[`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`}]]};Sn.node;var Cn=w(Sn),wn={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};wn.node;var Tn=w(wn),En={name:`sparkle`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}]]};En.node;var Dn=w(En),On={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};On.node;var kn=w(On),An={name:`spline`,size:24,node:[[`circle`,{cx:`19`,cy:`5`,r:`2`,key:`mhkx31`}],[`circle`,{cx:`5`,cy:`19`,r:`2`,key:`v8kfzx`}],[`path`,{d:`M5 17A12 12 0 0 1 17 5`,key:`1okkup`}]]};An.node;var jn=w(An),Mn={name:`square-axis-dashed-horizontal`,size:24,node:[[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3`,key:`14rx03`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v3`,key:`14bfxa`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}]],aliases:[`flip-vertical`,`square-centerline-dashed-vertical`]};Mn.node;var Nn=w(Mn),Pn={name:`square-dashed`,size:24,node:[[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M21 14v1`,key:`169vum`}]],aliases:[`box-select`]};Pn.node;var Fn=w(Pn),In={name:`square-pen`,size:24,node:[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]],aliases:[`pen-box`,`edit`,`pen-square`]};In.node;var Ln=w(In),Rn={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Rn.node;var zn=w(Rn),Bn={name:`stamp`,size:24,node:[[`path`,{d:`M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-6 0c0 2 1 2 1 3.5V13`,key:`i9gjdv`}],[`path`,{d:`M20 15.5a2.5 2.5 0 0 0-2.5-2.5h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1z`,key:`1vzg3v`}],[`path`,{d:`M5 22h14`,key:`ehvnwv`}]]};Bn.node;var Vn=w(Bn),Hn={name:`star`,size:24,node:[[`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`}]]};Hn.node;var Un=w(Hn),Wn={name:`sun-dim`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 4h.01`,key:`1ujb9j`}],[`path`,{d:`M20 12h.01`,key:`1ykeid`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M4 12h.01`,key:`158zrr`}],[`path`,{d:`M17.657 6.343h.01`,key:`31pqzk`}],[`path`,{d:`M17.657 17.657h.01`,key:`jehnf4`}],[`path`,{d:`M6.343 17.657h.01`,key:`gdk6ow`}],[`path`,{d:`M6.343 6.343h.01`,key:`1uurf0`}]]};Wn.node;var Gn=w(Wn),Kn={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Kn.node;var qn=w(Kn),Jn={name:`text-align-center`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]],aliases:[`align-center`]};Jn.node;var Yn=w(Jn),Xn={name:`text-align-end`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]],aliases:[`align-right`]};Xn.node;var Zn=w(Xn),Qn={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};Qn.node;var $n=w(Qn),er={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};er.node;var tr=w(er),nr={name:`triangle-exclamation-point`,size:24,node:[[`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`}]],aliases:[`alert-triangle`,`triangle-alert`]};nr.node;var rr=w(nr),ir={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};ir.node;var ar=w(ir),or={name:`undo-2`,size:24,node:[[`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`}]]};or.node;var sr=w(or),cr={name:`ungroup`,size:24,node:[[`rect`,{x:`11`,y:`14`,width:`10`,height:`7`,rx:`2`,key:`nfm8rk`}],[`rect`,{x:`3`,y:`3`,width:`10`,height:`7`,rx:`2`,key:`1ljebb`}]]};cr.node;var lr=w(cr),ur={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};ur.node;var dr=w(ur),fr={name:`wand-sparkles`,size:24,node:[[`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`}]],aliases:[`wand-2`]};fr.node;var pr=w(fr),mr={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};mr.node;var hr=w(mr),gr={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};gr.node;var _r=w(gr),vr={name:`zoom-in`,size:24,node:[[`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`}]]};vr.node;var yr=w(vr),br=d();function xr(e,t){if(e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++)i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+(e[r-1]===t[a-1]?0:1));n=i}return n[t.length]}function Sr(e,t){let n=e.toLowerCase(),r,i=1/0;for(let e of t){let t=e.toLowerCase();if(t===n)return e;let a=xr(n,t);t.startsWith(n)||n.startsWith(t)?a=Math.min(a,1.5):n.length>=4&&(t.includes(n)||n.includes(t))&&(a=Math.min(a,2)),a<i&&(i=a,r=e)}let a=Math.max(2,Math.floor(n.length/3));return i<=a?r:void 0}function Cr(e,t){let n=Sr(e,t);return n?`Did you mean "${n}"? `:``}function wr(e,t=40){let n=e.slice(0,t).map(e=>`"${e}"`).join(`, `);return e.length>t?`${n}, … (${e.length} total)`:n}var Tr=class{files=new Map;constructor(e){for(let[t,n]of Object.entries(e??{}))this.files.set(Dr(t),typeof n==`string`?new TextEncoder().encode(n):n)}async readText(e){return new TextDecoder().decode(await this.readBytes(e))}async readBytes(e){let t=this.files.get(Dr(e));if(!t)throw new Er(`notFound`,`File not found: ${e}`);return t}async writeText(e,t){this.files.set(Dr(e),new TextEncoder().encode(t))}async writeBytes(e,t){this.files.set(Dr(e),t)}async exists(e){return this.files.has(Dr(e))}async list(e=``){let t=e?Dr(e).replace(/\/?$/,`/`):``;return[...this.files.keys()].filter(e=>e.startsWith(t)).sort()}async remove(e){this.files.delete(Dr(e))}async size(e){return(await this.readBytes(e)).byteLength}},Er=class extends Error{code;name=`FsError`;constructor(e,t){super(t),this.code=e}};function Dr(e){let t=e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/+/g,`/`);if(t.startsWith(`/`)||t.split(`/`).includes(`..`)||/^[a-zA-Z]:/.test(t))throw new Er(`invalidPath`,`Invalid project path: ${e}`);return t}var Or=`0.1.1`,A=class extends Error{code;hint;details;name=`OpsError`;constructor(e,t,n,r){super(t),this.code=e,this.hint=n,this.details=r}toJSON(){return{code:this.code,message:this.message,...this.hint?{hint:this.hint}:{},...this.details===void 0?{}:{details:this.details}}}};function kr(e,t,n){let r=t.filter(e=>e.severity===`error`),i=r[0];return new A(`validation`,`${e} ${r.length} error${r.length===1?``:`s`}${i?`, first: ${i.path?`${i.path}: `:``}${i.message}`:``}`,n??i?.hint??`Fix the listed issues (details.issues) and retry.`,{issues:t})}var Ar=e=>e.some(e=>e.severity===`error`);function jr(){return new Date().toISOString()}async function Mr(e,t,n){let r;try{r=await e.readText(t)}catch(e){throw e instanceof Er&&e.code===`notFound`?new A(`notFound`,`${n} not found (${t}).`,t===`agentphoto.json`||t===`photo.json`?"This folder is not an AgentPhoto project: create one with `agentphoto new <dir>` (tool project_create) or pass --project <dir>.":void 0):new A(`io`,`Cannot read ${t}: ${e.message}`)}try{return JSON.parse(r)}catch(e){throw new A(`invalid`,`${t} is not valid JSON: ${e.message}`,`Fix the JSON syntax in ${t} (trailing commas and comments are not allowed).`)}}async function Nr(e,t,n){await e.writeText(t,`${JSON.stringify(n,null,2)}\n`)}async function Pr(e,t,n){return await e.exists(t)?Mr(e,t,t):n}var Fr=e=>Math.round(e/1024*10)/10,Ir=[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],Lr=e=>e.type===`image`||e.type===`text`||e.type===`shape`,Rr=e=>typeof e.src==`string`,zr=e=>typeof e.shape==`string`,Br=e=>!!e.gradient,j=(e,t,n,r,i,a={})=>({name:e,type:`number`,description:t,default:n,min:r,max:i,...a}),Vr=(e,t,n,r,i,a={})=>({name:e,type:`int`,description:t,default:n,min:r,max:i,step:1,...a}),Hr=(e,t,n)=>({name:e,type:`boolean`,description:t,default:n}),Ur=(e,t,n)=>({name:e,type:`color`,description:t,default:n}),Wr=(e,t,n,r)=>({name:e,type:`enum`,description:t,default:n,options:r}),Gr=(e,t)=>({name:e,type:`rgb`,description:t,default:[0,0,0],min:-100,max:100}),Kr=[{id:`bw`,title:`B&W`,description:`Neutral black & white.`},{id:`noir`,title:`Noir`,description:`Contrasty black & white with a dark vignette.`},{id:`sepia`,title:`Sepia`,description:`Warm brown monochrome, old print.`},{id:`vintage`,title:`Vintage`,description:`Faded warm colours, soft contrast, light vignette.`},{id:`polaroid`,title:`Polaroid`,description:`Warm, slightly washed instant-film look.`},{id:`lomo`,title:`Lomo`,description:`Saturated, contrasty, strong vignette.`},{id:`warm`,title:`Warm`,description:`Golden warm cast.`},{id:`cool`,title:`Cool`,description:`Blue cool cast.`},{id:`sunset`,title:`Sunset`,description:`Orange-pink evening glow.`},{id:`fade`,title:`Fade`,description:`Lifted blacks, matte pastel finish.`},{id:`punch`,title:`Punch`,description:`Vivid colours and extra contrast.`},{id:`cinema`,title:`Cinema`,description:`Teal shadows, orange highlights (blockbuster grade).`},{id:`cyberpunk`,title:`Cyberpunk`,description:`Magenta / cyan neon grade.`},{id:`cross-process`,title:`Cross process`,description:`Green shadows, warm highlights (XPro film).`},{id:`dramatic`,title:`Dramatic`,description:`Desaturated, hard contrast, dark edges.`},{id:`dreamy`,title:`Dreamy`,description:`Soft, airy, pastel lift.`},{id:`matte`,title:`Matte`,description:`Flat matte finish with lifted shadows and gentle colours.`},{id:`golden-hour`,title:`Golden hour`,description:`Late-afternoon warmth with soft highlights.`},{id:`film`,title:`Film`,description:`Subtle film emulation: soft contrast, warm mids, fine grain.`},{id:`clean`,title:`Clean`,description:`Bright, crisp, slightly cool — product / e-commerce.`}],qr=[{id:`brightnessContrast`,title:`Brightness / Contrast`,group:`light`,description:`Lighten or darken the image and increase or reduce contrast.`,params:[j(`brightness`,`-100 (darker) … 100 (lighter).`,0,-100,100),j(`contrast`,`-100 (flat) … 100 (punchy).`,0,-100,100)],example:{type:`brightnessContrast`,brightness:10,contrast:15},cost:1},{id:`exposure`,title:`Exposure`,group:`light`,description:`Photographic exposure in stops (linear light), with offset and gamma.`,params:[j(`exposure`,`Stops: +1 doubles the light.`,0,-5,5,{step:.05}),j(`offset`,`Lifts (+) or crushes (−) the blacks.`,0,-.5,.5,{step:.01}),j(`gamma`,`Midtone gamma (1 = unchanged).`,1,.1,5,{step:.01})],example:{type:`exposure`,exposure:.5},cost:1},{id:`shadowsHighlights`,title:`Shadows / Highlights`,group:`light`,description:`Open up dark areas and recover bright ones, using local luminance (backlit portraits, skies).`,params:[j(`shadows`,`How much to lighten the shadows.`,35,0,100),j(`highlights`,`How much to darken the highlights.`,0,0,100),j(`radius`,`Neighbourhood size, px.`,30,1,200,{px:!0})],example:{type:`shadowsHighlights`,shadows:40,highlights:20},cost:4},{id:`levels`,title:`Levels`,group:`tone`,description:`Input black / white points and midtone gamma, output range.`,params:[j(`black`,`Input black point.`,0,0,254),j(`white`,`Input white point.`,255,1,255),j(`gamma`,`Midtones (>1 lighter).`,1,.1,9.99,{step:.01}),j(`outBlack`,`Output black.`,0,0,255),j(`outWhite`,`Output white.`,255,0,255)],example:{type:`levels`,black:12,white:240,gamma:1.1},cost:1},{id:`curves`,title:`Curves`,group:`tone`,description:"Tone curves through control points [input, output] (0..255), smooth (monotone cubic). `rgb` affects all channels; `red` / `green` / `blue` affect one.",params:[{name:`rgb`,type:`curve`,description:`Master curve points, e.g. [[0,0],[64,50],[192,210],[255,255]] (an S-curve).`,default:[[0,0],[255,255]]},{name:`red`,type:`curve`,description:`Red channel curve (optional).`},{name:`green`,type:`curve`,description:`Green channel curve (optional).`},{name:`blue`,type:`curve`,description:`Blue channel curve (optional).`}],example:{type:`curves`,rgb:[[0,0],[64,52],[192,206],[255,255]]},cost:1},{id:`hueSaturation`,title:`Hue / Saturation`,group:`color`,description:"Rotate hues, change saturation and lightness. `colorize` tints the whole image with one hue.",params:[j(`hue`,`Hue rotation, degrees.`,0,-180,180),j(`saturation`,`-100 (grey) … 100.`,0,-100,100),j(`lightness`,`-100 … 100.`,0,-100,100),Hr(`colorize`,"Tint everything with `hue` (0..360 then) at `saturation`.",!1)],example:{type:`hueSaturation`,saturation:20},cost:2},{id:`vibrance`,title:`Vibrance`,group:`color`,description:`Boost muted colours more than saturated ones (skin-safe saturation).`,params:[j(`vibrance`,`-100 … 100.`,30,-100,100),j(`saturation`,`Plain saturation on top, -100 … 100.`,0,-100,100)],example:{type:`vibrance`,vibrance:30},cost:1},{id:`temperature`,title:`White balance`,group:`color`,description:`Colour temperature (blue ↔ yellow) and tint (green ↔ magenta). Fixes colour casts.`,params:[j(`temperature`,`-100 (cooler) … 100 (warmer).`,0,-100,100),j(`tint`,`-100 (green) … 100 (magenta).`,0,-100,100)],example:{type:`temperature`,temperature:15},cost:1},{id:`colorBalance`,title:`Color balance`,group:`color`,description:`Shift shadows, midtones and highlights towards cyan/red, magenta/green, yellow/blue: [r, g, b] each -100..100.`,params:[Gr(`shadows`,`[cyan↔red, magenta↔green, yellow↔blue] for the shadows.`),Gr(`midtones`,`Same for the midtones.`),Gr(`highlights`,`Same for the highlights.`),Hr(`preserveLuminosity`,`Keep the brightness unchanged.`,!0)],example:{type:`colorBalance`,shadows:[-10,0,10],highlights:[10,0,-10]},cost:1},{id:`photoFilter`,title:`Photo filter`,group:`color`,description:`Warming / cooling / coloured lens filter.`,params:[Ur(`color`,`Filter colour (warming #ec8a00, cooling #006dff…).`,`#ec8a00`),j(`density`,`Strength, 0 … 100.`,25,0,100),Hr(`preserveLuminosity`,`Keep the brightness unchanged.`,!0)],example:{type:`photoFilter`,color:`#ec8a00`,density:25},cost:1},{id:`gradientMap`,title:`Gradient map`,group:`color`,description:`Map luminance to a gradient (duotones, tritones): shadows take the first stop, highlights the last.`,params:[{name:`stops`,type:`stops`,description:`Colours dark → light: ["#1b1340", "#ff7a59"] or [[0,"#000"],[1,"#fff"]].`,default:[`#000000`,`#ffffff`]}],example:{type:`gradientMap`,stops:[`#1b1340`,`#ff7a59`,`#fff3d6`]},cost:1},{id:`grayscale`,title:`Black & white`,group:`color`,description:`Convert to grey with adjustable channel weights (red / green / blue contributions, %).`,params:[j(`red`,`Red contribution.`,30,-200,300),j(`green`,`Green contribution.`,59,-200,300),j(`blue`,`Blue contribution.`,11,-200,300)],example:{type:`grayscale`},cost:1},{id:`sepia`,title:`Sepia`,group:`color`,description:`Brown monochrome tone.`,params:[j(`intensity`,`0 … 100.`,100,0,100)],example:{type:`sepia`,intensity:80},cost:1},{id:`invert`,title:`Invert`,group:`color`,description:`Negative image.`,params:[],example:{type:`invert`},cost:1},{id:`threshold`,title:`Threshold`,group:`stylize`,description:`Pure black & white at a luminance level.`,params:[j(`level`,`0 … 255.`,128,0,255)],example:{type:`threshold`,level:128},cost:1},{id:`posterize`,title:`Posterize`,group:`stylize`,description:`Reduce the number of tones per channel.`,params:[Vr(`levels`,`Tones per channel.`,6,2,32)],example:{type:`posterize`,levels:5},cost:1},{id:`blur`,title:`Gaussian blur`,group:`blur`,description:`Soft blur (backgrounds, depth of field when masked, privacy).`,params:[j(`radius`,`Radius, px.`,6,0,250,{px:!0})],example:{type:`blur`,radius:12},cost:3},{id:`motionBlur`,title:`Motion blur`,group:`blur`,description:`Directional blur (speed, panning).`,params:[j(`angle`,`Direction, degrees.`,0,-180,180),j(`distance`,`Length, px.`,20,0,400,{px:!0})],example:{type:`motionBlur`,angle:0,distance:30},cost:6},{id:`surfaceBlur`,title:`Surface blur`,group:`blur`,description:`Edge-preserving smoothing (skin retouch, noise): flattens texture while keeping edges sharp. Usually masked to the area to smooth.`,params:[j(`radius`,`Neighbourhood, px.`,8,1,60,{px:!0}),j(`threshold`,`Edge sensitivity, 1 (only flat areas) … 100 (smooth everything).`,25,1,100)],example:{type:`surfaceBlur`,radius:8,threshold:25},cost:6},{id:`sharpen`,title:`Sharpen`,group:`detail`,description:`Unsharp mask: amount %, radius px, threshold (skip low-contrast detail such as skin / noise).`,params:[j(`amount`,`Strength, %.`,80,0,500),j(`radius`,`Px.`,1.2,.3,20,{px:!0,step:.1}),j(`threshold`,`0 … 255.`,2,0,255)],example:{type:`sharpen`,amount:80,radius:1.2},cost:3},{id:`clarity`,title:`Clarity`,group:`detail`,description:`Local midtone contrast (texture, punch) — negative values soften.`,params:[j(`amount`,`-100 … 100.`,30,-100,100),j(`radius`,`Px.`,24,2,200,{px:!0})],example:{type:`clarity`,amount:25},cost:4},{id:`noise`,title:`Grain / noise`,group:`stylize`,description:`Film grain (deterministic: same seed, same grain).`,params:[j(`amount`,`0 … 100.`,12,0,100),Hr(`monochrome`,`Grey grain instead of colour.`,!0),Vr(`seed`,`Random seed.`,1,0,999999),j(`size`,`Grain size, px.`,1,1,8,{px:!0,step:.5})],example:{type:`noise`,amount:10},cost:1},{id:`pixelate`,title:`Pixelate`,group:`stylize`,description:`Big square pixels (mosaic, anonymise a face when masked).`,params:[j(`size`,`Cell size, px.`,16,2,400,{px:!0})],example:{type:`pixelate`,size:20},cost:1},{id:`vignette`,title:`Vignette`,group:`stylize`,description:`Darken (or lighten, negative amount) the edges to draw the eye to the centre.`,params:[j(`amount`,`-100 (white) … 100 (dark).`,40,-100,100),j(`size`,`Clear centre size, 0 … 100.`,50,0,100),j(`feather`,`Softness, 0 … 100.`,60,0,100),Ur(`color`,`Edge colour.`,`#000000`)],example:{type:`vignette`,amount:40},cost:1},{id:`autoTone`,title:`Auto tone`,group:`auto`,description:`Stretch each channel's range (clips 0.5 % at each end) — fixes dull / hazy photos and colour casts.`,params:[j(`clip`,`Percent clipped at each end.`,.5,0,5,{step:.1})],example:{type:`autoTone`},cost:1},{id:`autoContrast`,title:`Auto contrast`,group:`auto`,description:`Stretch the luminance range without changing colours.`,params:[j(`clip`,`Percent clipped at each end.`,.5,0,5,{step:.1})],example:{type:`autoContrast`},cost:1},{id:`autoColor`,title:`Auto color`,group:`auto`,description:`Neutralise the colour cast (grey-world white balance) and stretch contrast.`,params:[],example:{type:`autoColor`},cost:1},{id:`look`,title:`Look`,group:`look`,description:"One-click photo grade (Instagram-style preset). Use `amount` (0..1) to dial it in.",params:[Wr(`look`,`Look id.`,`vintage`,Kr.map(e=>e.id))],example:{type:`look`,look:`cinema`,amount:.7},cost:2}],Jr=[Hr(`enabled`,`false = keep the filter but skip it.`,!0),j(`amount`,`Blend with the unfiltered pixels, 0 … 1.`,1,0,1,{step:.01})],Yr=[{id:`dropShadow`,title:`Drop shadow`,description:`Shadow cast by the layer's shape (cut-outs, text, stickers).`,params:[Ur(`color`,`Shadow colour.`,`#000000`),j(`opacity`,`0 … 1.`,.5,0,1,{step:.01}),j(`angle`,`Light angle, degrees (135 = shadow down-right).`,135,-180,180),j(`distance`,`Offset, px.`,12,0,500,{px:!0}),j(`blur`,`Softness, px.`,16,0,250,{px:!0}),j(`spread`,`Grow before blurring, px.`,0,0,100,{px:!0})]},{id:`outerGlow`,title:`Outer glow`,description:`Soft halo around the layer (neon, separation from the background).`,params:[Ur(`color`,`Glow colour.`,`#ffffff`),j(`opacity`,`0 … 1.`,.6,0,1,{step:.01}),j(`blur`,`Size, px.`,20,0,250,{px:!0}),j(`spread`,`Grow before blurring, px.`,0,0,100,{px:!0})]},{id:`innerShadow`,title:`Inner shadow`,description:`Shadow inside the layer's edges (inset, pressed look).`,params:[Ur(`color`,`Shadow colour.`,`#000000`),j(`opacity`,`0 … 1.`,.5,0,1,{step:.01}),j(`angle`,`Light angle, degrees.`,135,-180,180),j(`distance`,`Offset, px.`,6,0,200,{px:!0}),j(`blur`,`Softness, px.`,10,0,200,{px:!0})]},{id:`stroke`,title:`Stroke`,description:`Outline around the layer's shape (sticker outline, text outline).`,params:[Ur(`color`,`Outline colour.`,`#ffffff`),j(`width`,`Px.`,6,0,200,{px:!0}),Wr(`position`,`Where the outline sits.`,`outside`,[`outside`,`center`,`inside`]),j(`opacity`,`0 … 1.`,1,0,1,{step:.01})]},{id:`colorOverlay`,title:`Color overlay`,description:`Fill the layer's shape with a colour (recolour icons / silhouettes).`,params:[Ur(`color`,`Colour.`,`#ffffff`),j(`opacity`,`0 … 1.`,1,0,1,{step:.01}),Wr(`blend`,`Blend mode of the overlay.`,`normal`,Ir)]}],Xr=[{id:`inter`,family:`Inter`,weights:[400,600,700,800],style:`sans`,description:`Neutral modern sans — UI, body text, clean headlines.`},{id:`montserrat`,family:`Montserrat`,weights:[400,700,800],style:`sans`,description:`Geometric sans — bold marketing headlines.`},{id:`poppins`,family:`Poppins`,weights:[400,600,700],style:`sans`,description:`Friendly geometric sans — social posts, thumbnails.`},{id:`space-grotesk`,family:`Space Grotesk`,weights:[500,700],style:`sans`,description:`Techy grotesk — startups, tech.`},{id:`playfair`,family:`Playfair Display`,weights:[400,700],italic:[400],style:`serif`,description:`Elegant high-contrast serif — luxury, editorial, quotes.`},{id:`dm-serif`,family:`DM Serif Display`,weights:[400],style:`serif`,description:`Display serif — magazine covers, titles.`},{id:`roboto-slab`,family:`Roboto Slab`,weights:[400,700],style:`slab`,description:`Sturdy slab serif — posters, labels.`},{id:`bebas-neue`,family:`Bebas Neue`,weights:[400],style:`display`,description:`Tall all-caps condensed — YouTube thumbnails, posters, sports.`},{id:`anton`,family:`Anton`,weights:[400],style:`display`,description:`Heavy condensed — impact headlines.`},{id:`oswald`,family:`Oswald`,weights:[400,600],style:`display`,description:`Condensed gothic — banners, sale tags.`},{id:`archivo-black`,family:`Archivo Black`,weights:[400],style:`display`,description:`Very bold grotesk — loud short words.`},{id:`lobster`,family:`Lobster`,weights:[400],style:`script`,description:`Retro bold script — food, vintage, fun.`},{id:`pacifico`,family:`Pacifico`,weights:[400],style:`script`,description:`Surf brush script — casual, summer.`},{id:`caveat`,family:`Caveat`,weights:[400,700],style:`script`,description:`Handwriting — notes, annotations, personal touch.`},{id:`jetbrains-mono`,family:`JetBrains Mono`,weights:[400,700],style:`mono`,description:`Monospace — code, tech labels.`}],Zr=[{id:`og`,title:`Open Graph / link preview`,width:1200,height:630,description:`Facebook, LinkedIn, Slack, iMessage link cards.`},{id:`square`,title:`Square post`,width:1080,height:1080,description:`Instagram / Facebook feed.`},{id:`portrait`,title:`Portrait post`,width:1080,height:1350,description:`Instagram 4:5 feed.`},{id:`story`,title:`Story / Reel / TikTok`,width:1080,height:1920,description:`9:16 vertical.`},{id:`landscape`,title:`Full HD`,width:1920,height:1080,description:`16:9 slides, hero images, wallpapers.`},{id:`youtube`,title:`YouTube thumbnail`,width:1280,height:720,description:`16:9 video thumbnail.`},{id:`twitter`,title:`X / Twitter post`,width:1600,height:900,description:`16:9 in-feed image.`},{id:`pinterest`,title:`Pinterest pin`,width:1e3,height:1500,description:`2:3 pin.`},{id:`banner`,title:`Web banner`,width:1920,height:600,description:`Wide hero / header banner.`},{id:`linkedin-banner`,title:`LinkedIn banner`,width:1584,height:396,description:`Profile cover.`},{id:`avatar`,title:`Avatar`,width:800,height:800,description:`Profile picture (often shown round).`},{id:`product`,title:`Product shot`,width:2e3,height:2e3,description:`E-commerce square on white.`},{id:`a4`,title:`A4 portrait (150 dpi)`,width:1240,height:1754,description:`Flyer / print at 150 dpi.`}],Qr=[{id:`rmbg-1.4`,task:`background-removal`,repo:`briaai/RMBG-1.4`,sizeMb:168,license:`bria-rmbg-1.4 (non-commercial)`,description:`General background removal — products, people, animals, objects. Best default.`},{id:`modnet`,task:`background-removal`,repo:`Xenova/modnet`,sizeMb:25,license:`Apache-2.0`,description:`Portrait matting — people only, soft hair edges.`},{id:`slimsam`,task:`segmentation`,repo:`Xenova/slimsam-77-uniform`,sizeMb:30,license:`Apache-2.0`,description:`Segment Anything (light): select an object from points or a box.`},{id:`sam-base`,task:`segmentation`,repo:`Xenova/sam-vit-base`,sizeMb:100,license:`Apache-2.0`,description:`Segment Anything (base): more precise selections, slower.`}],$r={"background-removal":`rmbg-1.4`,segmentation:`slimsam`},ei=[{id:`image`,description:`A photo / bitmap from the project (assets/…) or the library (library:<id>), placed in a box (x, y, width, height, rotation, flip), optionally cropped (crop) and fitted (fit: fill | cover | contain).`},{id:`text`,description:`Live text: text, font (catalog id), size, weight, italic, color (colour or gradient), align, valign, lineHeight, letterSpacing, transform, width (wrap), background (label box).`},{id:`shape`,description:`Vector shape: shape rect | ellipse | line | polygon | star, fill (colour or gradient, null = none), stroke {color, width, dash}, radius, sides, innerRadius.`},{id:`fill`,description:`Solid colour or gradient covering the canvas (backgrounds, colour washes; use a mask to shape it).`},{id:`adjustment`,description:`Applies its filters to everything below it (inside its group) — non-destructive global corrections.`},{id:`group`,description:`Groups layers (children, bottom → top): opacity, blend, mask and filters apply to the group as a whole.`}],ti=[`rect`,`ellipse`,`line`,`polygon`,`star`],ni={layerTypes:ei,blendModes:Ir,filters:qr,commonFilterParams:Jr,looks:Kr,effects:Yr,shapes:ti,fonts:Xr,sizes:Zr,models:Qr},ri=e=>qr.find(t=>t.id===e),ii=e=>Yr.find(t=>t.id===e),ai=e=>Xr.find(t=>t.id===e),oi=e=>Zr.find(t=>t.id===e),si=e=>Qr.find(t=>t.id===e),ci={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`778899`,lightslategrey:`778899`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`00ff00`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`ff00ff`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`ff0000`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`ffffff`,whitesmoke:`f5f5f5`,yellow:`ffff00`,yellowgreen:`9acd32`},li=(e,t,n)=>Math.min(n,Math.max(t,e));function ui(e){if(!/^[0-9a-f]+$/i.test(e)||((e.length===3||e.length===4)&&(e=[...e].map(e=>e+e).join(``)),e.length!==6&&e.length!==8))return null;let t=t=>parseInt(e.slice(t,t+2),16);return{r:t(0),g:t(2),b:t(4),a:e.length===8?t(6)/255:1}}function di(e,t){let n=/^(-?\d*\.?\d+(?:e-?\d+)?)(%?)$/i.exec(e.trim());if(!n)return null;let r=Number(n[1]);return n[2]?r/100*t:r}function fi(e){let t=/^(-?\d*\.?\d+)(deg|rad|turn|grad)?$/i.exec(e.trim());if(!t)return null;let n=Number(t[1]);switch((t[2]??`deg`).toLowerCase()){case`rad`:return n*180/Math.PI;case`turn`:return n*360;case`grad`:return n*.9;default:return n}}function pi(e){let t=e.split(`/`);if(t.length>2)return null;let n=(t[0].includes(`,`)?t[0].split(`,`):t[0].trim().split(/\s+/)).map(e=>e.trim()).filter(e=>e!==``);return t.length===2&&n.push(t[1].trim()),n}function mi(e,t,n){e=(e%360+360)%360;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),a=n-r/2,[o,s,c]=e<60?[r,i,0]:e<120?[i,r,0]:e<180?[0,r,i]:e<240?[0,i,r]:e<300?[i,0,r]:[r,0,i];return[(o+a)*255,(s+a)*255,(c+a)*255]}function hi(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();if(!t)return null;if(t.startsWith(`#`))return ui(t.slice(1));if(t===`transparent`)return{r:0,g:0,b:0,a:0};let n=ci[t];if(n)return ui(n);let r=/^(rgba?|hsla?)\((.*)\)$/.exec(t);if(!r)return null;let i=pi(r[2]);if(!i||i.length!==3&&i.length!==4)return null;let a=i.length===4?di(i[3],1):1;if(a===null)return null;if(r[1].startsWith(`rgb`)){let[e,t,n]=i.slice(0,3).map(e=>di(e,255));return e===null||t===null||n===null?null:{r:li(e,0,255),g:li(t,0,255),b:li(n,0,255),a:li(a,0,1)}}let o=fi(i[0]),s=di(i[1],1),c=di(i[2],1);if(o===null||s===null||c===null||!i[1].trim().endsWith(`%`)||!i[2].trim().endsWith(`%`))return null;let[l,u,d]=mi(o,li(s,0,1),li(c,0,1));return{r:l,g:u,b:d,a:li(a,0,1)}}function gi(e){return hi(e)!==null}function _i({r:e,g:t,b:n}){return`#`+[e,t,n].map(e=>Math.round(li(e,0,255)).toString(16).padStart(2,`0`)).join(``)}var vi=n({slugify:()=>xi,uniqueId:()=>Si}),yi=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function bi(e){return typeof e==`string`&&yi.test(e)}function xi(e,t=`item`){let n=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`);return n?/^[a-z]/.test(n)?n:`${t}-${n}`:t}function Si(e,t){let n=new Set(t),r=bi(e)?e:xi(e);if(!n.has(r))return r;for(let e=2;;e++)if(!n.has(`${r}-${e}`))return`${r}-${e}`}var Ci=e=>!!e&&typeof e==`object`&&!Array.isArray(e),wi=e=>typeof e==`number`&&Number.isFinite(e),Ti=16384,Ei=[`id`,`type`,`name`,`visible`,`locked`,`opacity`,`blend`,`mask`,`clip`,`filters`,`effects`],Di=[`x`,`y`,`width`,`height`,`rotation`,`flipX`,`flipY`],Oi={image:[...Ei,...Di,`src`,`crop`,`fit`,`focus`],text:[...Ei,...Di,`text`,`font`,`size`,`weight`,`italic`,`color`,`align`,`valign`,`lineHeight`,`letterSpacing`,`transform`,`background`],shape:[...Ei,...Di,`shape`,`fill`,`stroke`,`radius`,`sides`,`innerRadius`],fill:[...Ei,`fill`],adjustment:[...Ei],group:[...Ei,`children`]},ki=Object.keys(Oi),Ai=[`version`,`id`,`title`,`description`,`canvas`,`layers`,`export`],ji=class{issues=[];add(e,t,n,r,i){this.issues.push({severity:e,code:t,path:n,message:r,...i?{hint:i}:{}})}error(e,t,n,r){this.add(`error`,e,t,n,r)}warn(e,t,n,r){this.add(`warning`,e,t,n,r)}info(e,t,n,r){this.add(`info`,e,t,n,r)}};function Mi(e,t,n,r,i){for(let a of Object.keys(t))n.includes(a)||e.warn(`unknown-field`,r?`${r}.${a}`:a,`Unknown field "${a}" on ${i} (ignored).`,`${Cr(a,n)}Allowed: ${wr(n)}.`)}function M(e,t,n,r={}){return t===void 0?(r.required&&e.error(`missing`,n,`${r.what??n} is required.`),!1):wi(t)?(r.int&&!Number.isInteger(t)&&e.error(`type`,n,`${n} must be an integer, got ${t}.`),r.min!==void 0&&t<r.min&&e.error(`range`,n,`${n} must be ≥ ${r.min}, got ${t}.`),r.max!==void 0&&t>r.max&&e.error(`range`,n,`${n} must be ≤ ${r.max}, got ${t}.`),!0):(e.error(`type`,n,`${n} must be a number, got ${JSON.stringify(t)}.`),!1)}function Ni(e,t,n){t!==void 0&&typeof t!=`boolean`&&e.error(`type`,n,`${n} must be true or false, got ${JSON.stringify(t)}.`)}function Pi(e,t,n,r=!1){t===void 0?r&&e.error(`missing`,n,`${n} (a CSS colour) is required.`):gi(t)||e.error(`color`,n,`${n}: ${JSON.stringify(t)} is not a CSS colour.`,`Use "#ff3366", "rgb(255 51 102)", "hsl(340 100% 60%)", "rgba(0,0,0,0.5)" or a named colour.`)}function Fi(e,t,n){!Array.isArray(t)||t.length<2?e.error(`stops`,n,`${n} must list at least 2 colour stops.`,`e.g. ["#1b1340", "#ff7a59"] or [[0, "#000"], [0.6, "#f80"], [1, "#fff"]].`):t.forEach((t,r)=>{let i=`${n}[${r}]`;typeof t==`string`?Pi(e,t,i):Array.isArray(t)&&t.length===2?(M(e,t[0],`${i}[0]`,{min:0,max:1}),Pi(e,t[1],`${i}[1]`,!0)):e.error(`stops`,i,`${i} must be a colour or [offset 0..1, colour].`)})}function Ii(e,t,n,r={}){if(t===void 0)r.required&&e.error(`missing`,n,`${n} is required (a CSS colour or a gradient).`);else if(t===null)r.allowNull||e.error(`type`,n,`${n} cannot be null.`);else{if(typeof t==`string`)return Pi(e,t,n);if(!Ci(t))return e.error(`paint`,n,`${n} must be a CSS colour or a gradient object.`,`{ "type": "linear", "angle": 90, "stops": ["#ff7a59", "#1b1340"] }`);t.type!==`linear`&&t.type!==`radial`&&e.error(`paint`,`${n}.type`,`Gradient type must be "linear" or "radial", got ${JSON.stringify(t.type)}.`),Fi(e,t.stops,`${n}.stops`),t.type===`linear`?(Mi(e,t,[`type`,`stops`,`angle`],n,`a linear gradient`),M(e,t.angle,`${n}.angle`)):t.type===`radial`&&(Mi(e,t,[`type`,`stops`,`cx`,`cy`,`radius`],n,`a radial gradient`),M(e,t.cx,`${n}.cx`),M(e,t.cy,`${n}.cy`),M(e,t.radius,`${n}.radius`,{min:0}))}}function Li(e,t,n,r){switch(t.type){case`number`:case`int`:M(e,n,r,{min:t.min,max:t.max,int:t.type===`int`});return;case`boolean`:Ni(e,n,r);return;case`color`:Pi(e,n,r);return;case`enum`:typeof n==`string`&&t.options?.includes(n)||e.error(`enum`,r,`${r}: ${JSON.stringify(n)} is not one of the allowed values.`,`${typeof n==`string`?Cr(n,t.options??[]):``}Allowed: ${wr(t.options??[])}.`);return;case`stops`:Fi(e,n,r);return;case`rgb`:!Array.isArray(n)||n.length!==3?e.error(`type`,r,`${r} must be [r, g, b] (each ${t.min}..${t.max}).`):n.forEach((n,i)=>M(e,n,`${r}[${i}]`,{min:t.min,max:t.max}));return;case`curve`:{if(!Array.isArray(n)||n.length<2){e.error(`curve`,r,`${r} must list at least 2 points [input, output] (0..255).`,`e.g. [[0,0],[64,50],[192,210],[255,255]].`);return}let t=-1;n.forEach((n,i)=>{let a=`${r}[${i}]`;if(!Array.isArray(n)||n.length!==2)return e.error(`curve`,a,`${a} must be [input, output].`);M(e,n[0],`${a}[0]`,{min:0,max:255}),M(e,n[1],`${a}[1]`,{min:0,max:255}),wi(n[0])&&(n[0]<=t&&e.error(`curve`,a,`${r}: inputs must be strictly increasing (point ${i} has ${n[0]} after ${t}).`),t=n[0])});return}}}function Ri(e,t,n,r,i,a){let o=[...a,...n.map(e=>e.name)];for(let[s,c]of Object.entries(t)){if(a.includes(s))continue;let t=n.find(e=>e.name===s);t?c!==void 0&&Li(e,t,c,`${r}.${s}`):e.warn(`unknown-param`,`${r}.${s}`,`Unknown parameter "${s}" for ${i} (ignored).`,`${Cr(s,o)}Parameters: ${wr(n.map(e=>e.name))}. catalog_get documents them.`)}}function zi(e,t,n){if(!Ci(t))return e.error(`type`,n,`${n} must be a filter object { "type": …, …params }.`,`e.g. { "type": "brightnessContrast", "brightness": 10 }.`);if(typeof t.type!=`string`)return e.error(`missing`,`${n}.type`,`${n}.type (a filter id) is required.`,`Filters: ${wr(ni.filters.map(e=>e.id))}.`);let r=ri(t.type);if(!r)return e.error(`unknown-filter`,`${n}.type`,`Unknown filter "${t.type}".`,`${Cr(t.type,ni.filters.map(e=>e.id))}Filters: ${wr(ni.filters.map(e=>e.id))} (catalog_get section "filters").`);let i=Jr.filter(e=>!r.params.some(t=>t.name===e.name));for(let r of i)t[r.name]!==void 0&&Li(e,r,t[r.name],`${n}.${r.name}`);Ri(e,t,r.params,n,`filter "${r.id}"`,[`type`,...i.map(e=>e.name)]),r.id===`look`&&t.look===void 0&&e.error(`missing`,`${n}.look`,`A "look" filter needs a look id.`,`Looks: ${wr(ni.looks.map(e=>e.id))}.`)}function Bi(e,t,n){if(t!==void 0){if(!Array.isArray(t))return e.error(`type`,n,`${n} must be an array of filters.`);t.forEach((t,r)=>zi(e,t,`${n}[${r}]`))}}function Vi(e,t,n){if(t==null)return;if(!Ci(t))return e.error(`type`,n,`${n} must be a mask object.`,`{ "src": "assets/masks/photo.png" } | { "shape": "ellipse", "x": 0, "y": 0, "width": 400, "height": 400, "feather": 30 } | { "gradient": { "type": "linear", "angle": 90, "stops": ["white", "black"] } }`);let r=[`src`,`shape`,`gradient`].filter(e=>t[e]!==void 0);r.length!==1&&e.error(`mask`,n,`${n} must have exactly one of "src", "shape" or "gradient" (has ${r.length?r.join(`, `):`none`}).`);let i=[`invert`,`feather`,`density`,`enabled`];Ni(e,t.invert,`${n}.invert`),Ni(e,t.enabled,`${n}.enabled`),M(e,t.feather,`${n}.feather`,{min:0,max:1e3}),M(e,t.density,`${n}.density`,{min:0,max:1}),t.src===void 0?t.shape===void 0?t.gradient!==void 0&&(Mi(e,t,[`gradient`,...i],n,`a gradient mask`),typeof t.gradient==`string`?e.error(`paint`,`${n}.gradient`,`${n}.gradient must be a gradient object, not a colour.`):Ii(e,t.gradient,`${n}.gradient`)):(Mi(e,t,[`shape`,`x`,`y`,`width`,`height`,`radius`,...i],n,`a shape mask`),t.shape!==`rect`&&t.shape!==`ellipse`&&e.error(`enum`,`${n}.shape`,`${n}.shape must be "rect" or "ellipse".`),M(e,t.x,`${n}.x`,{required:!0}),M(e,t.y,`${n}.y`,{required:!0}),M(e,t.width,`${n}.width`,{required:!0,min:0}),M(e,t.height,`${n}.height`,{required:!0,min:0}),M(e,t.radius,`${n}.radius`,{min:0})):(Mi(e,t,[`src`,...i],n,`an image mask`),typeof t.src==`string`&&t.src.trim()||e.error(`type`,`${n}.src`,`${n}.src must be a project path (e.g. "assets/masks/photo.png").`))}function Hi(e,t,n){if(t===void 0)return;if(!Ci(t))return e.error(`type`,n,`${n} must be an object { dropShadow?, outerGlow?, innerShadow?, stroke?, colorOverlay? }.`);let r=Yr.map(e=>e.id);for(let[i,a]of Object.entries(t)){let t=Yr.find(e=>e.id===i),o=`${n}.${i}`;t?a!==null&&a!==!1&&(Ci(a)?(Ri(e,a,t.params,o,`effect "${i}"`,[]),i===`colorOverlay`&&a.color===void 0&&e.error(`missing`,`${o}.color`,`colorOverlay needs a color.`)):e.error(`type`,o,`${o} must be an object of parameters (or null to remove it).`)):e.warn(`unknown-effect`,o,`Unknown layer effect "${i}" (ignored).`,`${Cr(i,r)}Effects: ${wr(r)}.`)}}function Ui(e,t,n,r={}){M(e,t.x,`${n}.x`),M(e,t.y,`${n}.y`),M(e,t.width,`${n}.width`,{min:0,required:r.sizeRequired}),M(e,t.height,`${n}.height`,{min:0,required:r.sizeRequired}),M(e,t.rotation,`${n}.rotation`),Ni(e,t.flipX,`${n}.flipX`),Ni(e,t.flipY,`${n}.flipY`)}function Wi(e,t,n,r){if(!Ci(t))return e.error(`type`,n,`${n} must be a layer object.`);let i=typeof t.id==`string`&&bi(t.id)?`layers#${t.id}`:n;if(bi(t.id)?r.has(t.id)?e.error(`duplicate-id`,`${i}.id`,`Duplicate layer id "${t.id}".`,`Layer ids are unique across the document (groups included).`):r.add(t.id):e.error(`id`,`${n}.id`,`Layer id ${JSON.stringify(t.id)} is invalid.`,`Ids start with a letter and contain letters, digits, - and _ (e.g. "photo", "title-2").`),typeof t.type!=`string`||!Oi[t.type])e.error(`layer-type`,`${i}.type`,`Unknown layer type ${JSON.stringify(t.type)}.`,`${typeof t.type==`string`?Cr(t.type,ki):``}Types: ${wr(ki)}.`);else switch(Mi(e,t,Oi[t.type],i,`a ${t.type} layer`),t.name!==void 0&&typeof t.name!=`string`&&e.error(`type`,`${i}.name`,`${i}.name must be a string.`),Ni(e,t.visible,`${i}.visible`),Ni(e,t.locked,`${i}.locked`),Ni(e,t.clip,`${i}.clip`),t.opacity!==void 0&&(wi(t.opacity)&&t.opacity>1&&t.opacity<=100?e.error(`range`,`${i}.opacity`,`${i}.opacity is 0..1, got ${t.opacity}.`,`Use ${Math.round(t.opacity)/100} for ${t.opacity} %.`):M(e,t.opacity,`${i}.opacity`,{min:0,max:1})),t.blend===void 0||typeof t.blend==`string`&&Ir.includes(t.blend)||e.error(`enum`,`${i}.blend`,`Unknown blend mode ${JSON.stringify(t.blend)}.`,`${typeof t.blend==`string`?Cr(t.blend,Ir):``}Blend modes: ${wr(Ir)}.`),Vi(e,t.mask,`${i}.mask`),Hi(e,t.effects,`${i}.effects`),t.type){case`image`:Bi(e,t.filters,`${i}.filters`),Ui(e,t,i),typeof t.src==`string`&&t.src.trim()||e.error(`missing`,`${i}.src`,`Image layer "${t.id}" needs a src (a project path like "assets/photo.jpg" or "library:<id>").`,`assets_add imports a file into the project; library_list lists the built-in images.`),t.crop!==void 0&&(Ci(t.crop)?(M(e,t.crop.x,`${i}.crop.x`,{required:!0,min:0}),M(e,t.crop.y,`${i}.crop.y`,{required:!0,min:0}),M(e,t.crop.width,`${i}.crop.width`,{required:!0,min:1}),M(e,t.crop.height,`${i}.crop.height`,{required:!0,min:1})):e.error(`type`,`${i}.crop`,`${i}.crop must be { x, y, width, height } in source pixels.`)),t.fit!==void 0&&![`fill`,`cover`,`contain`].includes(t.fit)&&e.error(`enum`,`${i}.fit`,`${i}.fit must be "fill", "cover" or "contain".`),t.focus===void 0||Array.isArray(t.focus)&&t.focus.length===2&&t.focus.every(e=>wi(e)&&e>=0&&e<=1)||e.error(`type`,`${i}.focus`,`${i}.focus must be [x, y] with values 0..1.`);break;case`text`:if(Bi(e,t.filters,`${i}.filters`),Ui(e,t,i),typeof t.text==`string`?t.text.trim()||e.warn(`empty-text`,`${i}.text`,`Text layer "${t.id}" is empty.`):e.error(`missing`,`${i}.text`,`Text layer "${t.id}" needs a text string.`),t.font!==void 0){if(typeof t.font!=`string`||!t.font.trim())e.error(`type`,`${i}.font`,`${i}.font must be a font id or a CSS font family.`);else if(!ai(t.font)){let n=Cr(t.font,Xr.map(e=>e.id));e.info(`system-font`,`${i}.font`,`Font "${t.font}" is not bundled: it renders with whatever this computer has (exports may differ elsewhere).`,`${n}Bundled fonts: ${wr(Xr.map(e=>e.id))}.`)}}if(M(e,t.size,`${i}.size`,{min:1,max:4e3}),M(e,t.weight,`${i}.weight`,{min:100,max:900}),Ni(e,t.italic,`${i}.italic`),Ii(e,t.color,`${i}.color`),t.align!==void 0&&![`left`,`center`,`right`].includes(t.align)&&e.error(`enum`,`${i}.align`,`${i}.align must be left, center or right.`),t.valign!==void 0&&![`top`,`middle`,`bottom`].includes(t.valign)&&e.error(`enum`,`${i}.valign`,`${i}.valign must be top, middle or bottom.`),M(e,t.lineHeight,`${i}.lineHeight`,{min:.1,max:10}),M(e,t.letterSpacing,`${i}.letterSpacing`,{min:-200,max:1e3}),t.transform!==void 0&&![`none`,`uppercase`,`lowercase`].includes(t.transform)&&e.error(`enum`,`${i}.transform`,`${i}.transform must be none, uppercase or lowercase.`),t.background!==void 0&&t.background!==null){if(!Ci(t.background))e.error(`type`,`${i}.background`,`${i}.background must be { color, padding?, radius? } or null.`);else{Mi(e,t.background,[`color`,`padding`,`radius`],`${i}.background`,`a text background`),Pi(e,t.background.color,`${i}.background.color`,!0);let n=t.background.padding;n!==void 0&&!wi(n)&&!(Array.isArray(n)&&n.length===2&&n.every(wi))&&e.error(`type`,`${i}.background.padding`,`padding must be a number or [horizontal, vertical].`),M(e,t.background.radius,`${i}.background.radius`,{min:0})}}break;case`shape`:Bi(e,t.filters,`${i}.filters`),Ui(e,t,i,{sizeRequired:!0}),typeof t.shape==`string`&&ni.shapes.includes(t.shape)||e.error(`enum`,`${i}.shape`,`${i}.shape must be one of ${wr(ni.shapes)}.`,typeof t.shape==`string`?Cr(t.shape,ni.shapes):void 0),Ii(e,t.fill,`${i}.fill`,{allowNull:!0}),t.stroke!==void 0&&t.stroke!==null&&(Ci(t.stroke)?(Mi(e,t.stroke,[`color`,`width`,`dash`],`${i}.stroke`,`a stroke`),Pi(e,t.stroke.color,`${i}.stroke.color`,!0),M(e,t.stroke.width,`${i}.stroke.width`,{min:0}),t.stroke.dash===void 0||Array.isArray(t.stroke.dash)&&t.stroke.dash.every(e=>wi(e)&&e>=0)||e.error(`type`,`${i}.stroke.dash`,`dash must be an array of lengths, e.g. [12, 6].`)):e.error(`type`,`${i}.stroke`,`${i}.stroke must be { color, width?, dash? } or null.`)),t.fill===void 0&&(t.stroke===void 0||t.stroke===null)&&t.shape!==`line`&&e.info(`invisible-shape`,i,`Shape "${t.id}" has no fill and no stroke: it draws the default fill (#ffffff).`),t.shape===`line`&&(t.stroke===void 0||t.stroke===null)&&e.info(`line-stroke`,i,`Line "${t.id}" has no stroke: it draws a 4 px white line.`),M(e,t.radius,`${i}.radius`,{min:0}),M(e,t.sides,`${i}.sides`,{min:3,max:64,int:!0}),M(e,t.innerRadius,`${i}.innerRadius`,{min:0,max:1});break;case`fill`:Bi(e,t.filters,`${i}.filters`),Ii(e,t.fill,`${i}.fill`,{required:!0});break;case`adjustment`:Array.isArray(t.filters)?(t.filters.length||e.warn(`empty-adjustment`,`${i}.filters`,`Adjustment layer "${t.id}" has no filters (does nothing).`),Bi(e,t.filters,`${i}.filters`)):e.error(`missing`,`${i}.filters`,`Adjustment layer "${t.id}" needs a filters array.`,`e.g. "filters": [{ "type": "brightnessContrast", "contrast": 15 }]`);break;case`group`:Bi(e,t.filters,`${i}.filters`),Array.isArray(t.children)?t.children.forEach((t,n)=>Wi(e,t,`${i}.children[${n}]`,r)):e.error(`missing`,`${i}.children`,`Group "${t.id}" needs a children array.`)}}function Gi(e){let t=new ji;if(!Ci(e))return t.error(`type`,``,`The document must be a JSON object.`,`Minimal: { "version": 1, "id": "photo", "canvas": { "width": 1200, "height": 630 }, "layers": [] }`),t.issues;if(Mi(t,e,Ai,``,`the document`),e.version===void 0?t.warn(`version`,`version`,`Missing "version" (assumed 1).`):e.version!==1&&t.error(`version`,`version`,`Unsupported document version ${JSON.stringify(e.version)} (this engine reads 1).`,`Update agentphoto, or set version to 1.`),bi(e.id)||t.error(`id`,`id`,`Document id ${JSON.stringify(e.id)} is invalid.`,`Use a slug such as "summer-sale".`),e.title!==void 0&&typeof e.title!=`string`&&t.error(`type`,`title`,`title must be a string.`),e.description!==void 0&&typeof e.description!=`string`&&t.error(`type`,`description`,`description must be a string.`),Ci(e.canvas)?(Mi(t,e.canvas,[`width`,`height`,`background`],`canvas`,`canvas`),M(t,e.canvas.width,`canvas.width`,{required:!0,min:1,max:Ti,int:!0}),M(t,e.canvas.height,`canvas.height`,{required:!0,min:1,max:Ti,int:!0}),wi(e.canvas.width)&&wi(e.canvas.height)&&e.canvas.width*e.canvas.height/1e6>40&&t.warn(`large-canvas`,`canvas`,`The canvas is ${Math.round(e.canvas.width*e.canvas.height/1e6)} megapixels: renders and exports will be slow and memory-hungry.`,`Most web uses need ≤ 4000 px on the long side (resize_image).`),Ii(t,e.canvas.background,`canvas.background`,{allowNull:!0})):t.error(`missing`,`canvas`,`canvas { width, height } is required.`,`"canvas": { "width": 1200, "height": 630 }`),!Array.isArray(e.layers))t.error(`missing`,`layers`,`layers (an array, bottom → top) is required.`);else{let n=new Set;e.layers.forEach((e,r)=>Wi(t,e,`layers[${r}]`,n))}return e.export!==void 0&&(Ci(e.export)?(Mi(t,e.export,[`format`,`quality`,`scale`,`width`,`height`,`background`,`name`],`export`,`export settings`),e.export.format!==void 0&&![`png`,`jpeg`,`webp`,`avif`].includes(e.export.format)&&t.error(`enum`,`export.format`,`export.format must be "png", "jpeg", "webp" or "avif".`),M(t,e.export.quality,`export.quality`,{min:1,max:100}),M(t,e.export.scale,`export.scale`,{min:.01,max:8}),M(t,e.export.width,`export.width`,{min:1,max:Ti,int:!0}),M(t,e.export.height,`export.height`,{min:1,max:Ti,int:!0}),e.export.background!==void 0&&e.export.background!==null&&Pi(t,e.export.background,`export.background`),e.export.name===void 0||typeof e.export.name==`string`&&/^[\w.-]+$/.test(e.export.name)||t.error(`type`,`export.name`,`export.name must be a file name without extension (letters, digits, . _ -).`)):t.error(`type`,`export`,`export must be an object of default export settings.`)),t.issues}function Ki(e){return{...e,version:e.version??1,layers:e.layers===void 0||e.layers===null?[]:e.layers}}function qi(e={}){return{version:1,id:e.id??`photo`,...e.title?{title:e.title}:{},canvas:{width:e.width??1200,height:e.height??630,...e.background===void 0?{}:{background:e.background}},layers:[]}}var Ji=n({imageInfo:()=>ra}),Yi={png:`image/png`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`,bmp:`image/bmp`,avif:`image/avif`,svg:`image/svg+xml`},Xi={png:`png`,jpg:`jpeg`,jpeg:`jpeg`,webp:`webp`,gif:`gif`,bmp:`bmp`,avif:`avif`,svg:`svg`},Zi=(e,t)=>e[t]<<8|e[t+1],Qi=(e,t)=>e[t]|e[t+1]<<8,$i=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16,ea=(e,t)=>(e[t]<<24>>>0)+(e[t+1]<<16|e[t+2]<<8|e[t+3]),ta=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,na=(e,t,n)=>String.fromCharCode(...e.subarray(t,t+n));function ra(e){let t=e;if(t.length<12)return null;if(t[0]===137&&na(t,1,3)===`PNG`&&t.length>=26){let e=t[25];return{type:`png`,width:ea(t,16),height:ea(t,20),alpha:e===4||e===6}}if(t[0]===255&&t[1]===216){let e=2;for(;e+9<t.length;){if(t[e]!==255){e++;continue}let n=t[e+1];if(n===255){e++;continue}if(n===216||n===1||n>=208&&n<=215){e+=2;continue}let r=Zi(t,e+2);if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204)return ia(t,{type:`jpeg`,height:Zi(t,e+5),width:Zi(t,e+7),alpha:!1});e+=2+r}return null}if(na(t,0,4)===`RIFF`&&na(t,8,4)===`WEBP`&&t.length>=30){let e=na(t,12,4);if(e===`VP8 `)return{type:`webp`,width:Qi(t,26)&16383,height:Qi(t,28)&16383,alpha:!1};if(e===`VP8L`){let e=t[21]|t[22]<<8|t[23]<<16|t[24]<<24;return{type:`webp`,width:(e&16383)+1,height:(e>>14&16383)+1,alpha:!!(e>>28&1)}}return e===`VP8X`?{type:`webp`,width:$i(t,24)+1,height:$i(t,27)+1,alpha:!!(t[20]&16)}:null}if(na(t,0,4)===`GIF8`)return{type:`gif`,width:Qi(t,6),height:Qi(t,8)};if(t[0]===66&&t[1]===77&&t.length>=26)return{type:`bmp`,width:Math.abs(ta(t,18)),height:Math.abs(ta(t,22))};if(na(t,4,4)===`ftyp`){let e=na(t,8,4);if(/avi[fs]|mif1|heic|heix/.test(e)){for(let e=12;e+20<t.length&&e<65536;e++)if(t[e]===105&&na(t,e,4)===`ispe`)return{type:`avif`,width:ea(t,e+8),height:ea(t,e+12)};return null}}let n=new TextDecoder().decode(t.subarray(0,Math.min(t.length,4096)));if(/<svg[\s>]/i.test(n)){let e=/<svg[^>]*>/i.exec(n)?.[0]??``,t=t=>{let n=RegExp(`\\s${t}\\s*=\\s*["']([\\d.]+)(px)?["']`,`i`).exec(e);return n?Number(n[1]):void 0},r=t(`width`),i=t(`height`),a=/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(e);if((!r||!i)&&a){let e=Number(a[1]),t=Number(a[2]);r&&!i?i=r*t/e:i&&!r?r=i*e/t:(r=e,i=t)}return{type:`svg`,width:Math.round(r??300),height:Math.round(i??150),alpha:!0}}return null}function ia(e,t){let n=aa(e);return n>=5&&n<=8?{...t,width:t.height,height:t.width}:t}function aa(e){let t=2;for(;t+4<e.length;){if(e[t]!==255)return 1;let n=e[t+1],r=Zi(e,t+2);if(n===225&&na(e,t+4,4)===`Exif`){let n=t+10,r=e[n]===73,i=t=>r?Qi(e,t):Zi(e,t),a=n+(t=>r?(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0:ea(e,t))(n+4),o=i(a);for(let t=0;t<o;t++){let n=a+2+t*12;if(n+10>e.length)break;if(i(n)===274)return i(n+8)}return 1}if(n===218)return 1;t+=2+r}return 1}function oa(e){let t=/\.([a-z0-9]+)$/i.exec(e)?.[1]?.toLowerCase();return t?Xi[t]:void 0}function sa(e){return typeof e==`string`&&e.startsWith(`library:`)}function ca(e){return e.slice(8)}function la(e,t){return e?.assets.find(e=>e.id===t)}var ua=n({allLayerIds:()=>da});function N(e,t,n=null,r=0){if(!Array.isArray(e))return null;for(let i=0;i<e.length;i++){let a=e[i];if(a&&a.id===t)return{layer:a,parent:n,container:e,index:i,depth:r}}for(let n of e){let e=n&&n.type===`group`&&Array.isArray(n.children)?N(n.children,t,n,r+1):null;if(e)return e}return null}function P(e,t,n=null,r=0){if(Array.isArray(e))for(let i of e)i&&typeof i==`object`&&t(i,n,r)!==!1&&i.type===`group`&&P(i.children,t,i,r+1)}function da(e){let t=[];return P(e.layers,e=>void t.push(e.id)),t}function fa(e,t){return e.type===`group`&&!!N(e.children,t)}var pa=(e,t=40)=>e.length>t?`${e.slice(0,t-1)}…`:e;function ma(e){switch(e.type){case`image`:return`${e.src}${e.fit&&e.fit!==`fill`?` (${e.fit})`:``}`;case`text`:return`${JSON.stringify(pa(String(e.text??``)))} (${e.font??`inter`} ${e.size??64})`;case`shape`:return`${e.shape}${typeof e.fill==`string`?` ${e.fill}`:e.fill?` gradient`:``}`;case`fill`:return typeof e.fill==`string`?e.fill:`${e.fill?.type??`?`} gradient`;case`adjustment`:return e.filters?.length?`filters the layers below`:`(empty)`;case`group`:return`${e.children?.length??0} layers`;default:return``}}function ha(e){let t=e.mask;if(t)return Rr(t)?`image`:zr(t)?`shape`:Br(t)?`gradient`:void 0}function ga(e,t,n,r){let i={id:e.id,type:e.type,detail:ma(e),parent:t?.id??null,depth:n,index:r};e.name&&(i.name=e.name),Lr(e)&&(i.box=[e.x??0,e.y??0,e.width??null,e.height??null],e.rotation&&(i.rotation=e.rotation)),e.opacity!==void 0&&e.opacity!==1&&(i.opacity=e.opacity),e.blend&&e.blend!==`normal`&&(i.blend=e.blend),e.visible===!1&&(i.hidden=!0),e.locked&&(i.locked=!0),e.clip&&(i.clip=!0);let a=ha(e);if(a&&(i.mask=e.mask&&e.mask.enabled===!1?`${a} (disabled)`:a),e.filters?.length&&(i.filters=e.filters.map(e=>(e.type===`look`?`look:${String(e.look)}`:e.type)+(e.enabled===!1?` (off)`:``))),e.effects){let t=Object.entries(e.effects).filter(([,e])=>e).map(([e])=>e);t.length&&(i.effects=t)}return i}function _a(e){let t=[],n=(e,r,i)=>{for(let a=e.length-1;a>=0;a--){let o=e[a];o&&typeof o==`object`&&(t.push(ga(o,r,i,a)),o.type===`group`&&Array.isArray(o.children)&&n(o.children,o,i+1))}};return n(Array.isArray(e.layers)?e.layers:[],null,0),t}function va(e){let t=[];return P(e.layers,e=>{e.type===`image`&&typeof e.src==`string`&&t.push({path:e.src,by:e.id,role:`src`}),e.mask&&Rr(e.mask)&&typeof e.mask.src==`string`&&t.push({path:e.mask.src,by:e.id,role:`mask`})}),t}var ya=`modulepreload`,ba=function(e,t){return new URL(e,t).href},xa={},Sa=function(e){return e.pathname.endsWith(`.css`)},Ca=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},wa=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ba(t,n);let r=s(t),i=Sa(r);return Ca(xa,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ya,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ta=`agentphoto.json`,Ea=`photo.json`,Da=`assets/manifest.json`,Oa=new TextDecoder,ka=e=>typeof e==`string`?e:Oa.decode(e);function Aa(e){if(e.size){let t=oi(e.size);if(!t)throw new A(`invalid`,`Unknown size preset "${e.size}".`,`${Cr(e.size,Zr.map(e=>e.id))}Presets: ${Zr.map(e=>`${e.id} (${e.width}×${e.height})`).join(`, `)}. Or pass width and height.`);return{width:t.width,height:t.height}}if(e.width!==void 0||e.height!==void 0){let t=Math.round(e.width??e.height??0),n=Math.round(e.height??e.width??0);if(!(t>=1&&n>=1&&t<=16384&&n<=16384))throw new A(`invalid`,`Invalid canvas size ${t}×${n}.`,`Width and height are 1…${Ti} px.`);return{width:t,height:n}}return null}async function ja(e,t){if(!t.name||!t.name.trim())throw new A(`invalid`,`A project needs a name.`,`Pass a name, e.g. "summer-sale".`);if(!t.force&&(await e.exists(`agentphoto.json`)||await e.exists(`photo.json`)))throw new A(`conflict`,`This folder already contains an AgentPhoto project.`,`Choose an empty folder, or pass force: true (CLI --force) to overwrite it.`);if(t.template&&!t.templateFiles)throw new A(`invalid`,`Template "${t.template}" was requested but its files were not provided.`,`The front door reads templates/<id>/ and passes templateFiles (templates_list lists the ids).`);let n=xi(t.name,`photo`),r=t.title?.trim()||t.name.trim(),i=[],a=Aa(t),o,s,c=null;if(t.templateFiles){let e=t.templateFiles;if(!e[`photo.json`])throw new A(`invalid`,`Template "${t.template??`?`}" has no photo.json.`,`A template folder holds photo.json, template.json and optional assets/.`);try{c=Ki(JSON.parse(ka(e[Ea])))}catch(e){throw new A(`invalid`,`Template photo.json is not valid JSON: ${e.message}`)}let n=Gi(c);if(Ar(n))throw kr(`Template "${t.template??`?`}" is invalid.`,n)}if(t.image&&!ra(t.image.bytes))throw new A(`invalid`,`${t.image.name} is not a supported image (PNG, JPEG, WebP, GIF, BMP, AVIF, SVG).`);let l=null;if(t.image){let n=ra(t.image.bytes);if(!n)throw new A(`invalid`,`${t.image.name} is not a supported image (PNG, JPEG, WebP, GIF, BMP, AVIF, SVG).`);let{addAsset:r}=await wa(async()=>{let{addAsset:e}=await Promise.resolve().then(()=>La);return{addAsset:e}},void 0,import.meta.url),a=await r(e,{name:t.image.name,bytes:t.image.bytes,kind:`image`,source:t.image.source??`user`,license:t.image.license,author:t.image.author,sourceUrl:t.image.sourceUrl});l={path:a.path,width:n.width,height:n.height},i.push(a.path)}if(t.templateFiles){let u=t.templateFiles;o=c;try{s=u[`template.json`]?JSON.parse(ka(u[`template.json`])).slot:void 0}catch{s=void 0}if(o.id=n,o.title=r,a&&(o.canvas={...o.canvas,...a}),t.background!==void 0&&(o.canvas.background=t.background),l){let e=s?N(o.layers,s):null;e&&e.layer.type===`image`?(e.layer.src=l.path,e.layer.mask&&Rr(e.layer.mask)&&delete e.layer.mask,delete e.layer.crop):o.layers.unshift(Ma(l,o.canvas))}let d=new Set(va(o).map(e=>e.path));for(let[t,n]of Object.entries(u))t!==`photo.json`&&t!==`agentphoto.json`&&t!==`template.json`&&t!==`preview.png`&&t!==`preview.jpg`&&(!t.startsWith(`assets/`)||t===`assets/manifest.json`||d.has(t))&&(typeof n==`string`?await e.writeText(t,n):await e.writeBytes(t,n),i.push(t))}else o=qi({id:n,title:r,...a??(l?{width:l.width,height:l.height}:{width:1200,height:630}),background:t.background===void 0?l?void 0:`#ffffff`:t.background}),l&&o.layers.push(Ma(l,o.canvas));let u=Gi(o);if(Ar(u))throw kr(`The new project's document is invalid.`,u,`Fix the template (or the options) and retry.`);let d=jr(),f={name:n,title:r,createdAt:d,updatedAt:d,...t.template?{template:t.template}:{},agentphoto:Or};return await Nr(e,Ta,f),await Nr(e,Ea,o),await e.exists(`assets/manifest.json`)||await Nr(e,Da,{assets:[]}),i.push(Ta,Ea,Da),{manifest:f,doc:o,files:[...new Set(i)].sort(),issues:u}}function Ma(e,t){return e.width===t.width&&e.height===t.height?{id:`photo`,type:`image`,name:`Photo`,src:e.path,x:0,y:0,width:e.width,height:e.height}:{id:`photo`,type:`image`,name:`Photo`,src:e.path,x:0,y:0,width:t.width,height:t.height,fit:`cover`}}async function Na(e){return Mr(e,Ta,`Project manifest`)}async function Pa(e){return{manifest:await Na(e),doc:Ki(await Mr(e,Ea,`The document`))}}async function Fa(e,t,n={}){let r=Gi(t);if(Ar(r)&&!n.allowInvalid)throw kr(`Document not saved:`,r);return await Nr(e,Ea,t),await Ia(e),{issues:r}}async function Ia(e){let t=await Pr(e,Ta,null);t&&await Nr(e,Ta,{...t,updatedAt:jr(),agentphoto:Or})}var La=n({addAsset:()=>Wa,removeAsset:()=>Ka}),Ra={image:`assets/images`,mask:`assets/masks`,edit:`assets/edits`,font:`assets/fonts`,other:`assets/files`},za=83886080;async function Ba(e){let t=await Pr(e,Da,{assets:[]});return{assets:Array.isArray(t.assets)?t.assets:[]}}async function Va(e,t){t.assets.sort((e,t)=>e.path.localeCompare(t.path)),await Nr(e,Da,t)}function Ha(e,t=`png`){let n=e.split(/[\\/]/).pop()??e,r=/^(.*?)(?:\.([a-z0-9]{1,5}))?$/i.exec(n),i=xi(r?.[1]||`image`,`image`).slice(0,60),a=(r?.[2]??t).toLowerCase();return`${i}.${a===`jpeg`?`jpg`:a}`}async function Ua(e,t){if(!await e.exists(t))return t;let n=/^(.*?)(\.[^./]+)?$/.exec(t);for(let t=2;;t++){let r=`${n[1]}-${t}${n[2]??``}`;if(!await e.exists(r))return r}}async function Wa(e,t){if(!t.bytes?.byteLength)throw new A(`invalid`,`${t.name}: the file is empty.`);if(t.bytes.byteLength>83886080)throw new A(`invalid`,`${t.name} is ${Math.round(t.bytes.byteLength/1048576)} MB (max ${za/1048576} MB).`,`Resize or recompress it first.`);let n=ra(t.bytes),r=t.kind??(n?`image`:`other`);if((r===`image`||r===`mask`||r===`edit`)&&!n)throw new A(`invalid`,`${t.name} is not a supported image (PNG, JPEG, WebP, GIF, BMP, AVIF, SVG).`);let i=n?n.type===`jpeg`?`jpg`:n.type:void 0,a;if(t.name.includes(`/`)){if(a=t.name.replace(/^\.\//,``),!a.startsWith(`assets/`))throw new A(`invalid`,`Asset paths live under assets/ (got "${t.name}").`)}else{let e=Ha(t.name,i);i&&Xi[e.split(`.`).pop()]!==n?.type&&(e=`${e.replace(/\.[^.]+$/,``)}.${i}`),a=`${Ra[r]}/${e}`}t.overwrite||(a=await Ua(e,a)),await e.writeBytes(a,t.bytes);let o={path:a,kind:r,source:t.source,...t.license?{license:t.license}:{},...t.author?{author:t.author}:{},...t.sourceUrl?{sourceUrl:t.sourceUrl}:{},...t.attribution?{attribution:t.attribution}:{},...n?{width:n.width,height:n.height}:{},bytes:t.bytes.byteLength,addedAt:jr()},s=await Ba(e);return s.assets=[...s.assets.filter(e=>e.path!==a),o],await Va(e,s),o}async function Ga(e){let t=await Ba(e),n=null;try{n=JSON.parse(await e.readText(Ea))}catch{n=null}let r=n?va(n):[],i=new Set((await e.list(`assets`)).filter(e=>e!==Da)),a=[],o=0;for(let n of t.assets){let t=i.has(n.path),s=t?await e.size(n.path):0;o+=s,a.push({...n,exists:t,usedBy:[...new Set(r.filter(e=>e.path===n.path).map(e=>e.by))],kb:Fr(s)}),i.delete(n.path)}return{assets:a,untracked:[...i],totalKb:Fr(o)}}async function Ka(e,t,n={}){let r=await Ba(e);if(!(r.assets.some(e=>e.path===t)||await e.exists(t)))throw new A(`notFound`,`No asset ${t}.`,`assets_list lists the project's assets.`);let i=[];try{let n=JSON.parse(await e.readText(Ea));i=[...new Set(va(n).filter(e=>e.path===t).map(e=>e.by))]}catch{i=[]}if(i.length&&!n.force)throw new A(`conflict`,`${t} is used by layer${i.length>1?`s`:``} ${i.join(`, `)}.`,`Remove or change those layers first, or pass force.`);return await e.remove(t),r.assets=r.assets.filter(e=>e.path!==t),await Va(e,r),{removed:t,usedBy:i}}async function qa(e,t){let n=[];for(let r of va(t)){if(sa(r.path))continue;let t=!1;try{t=await e.exists(r.path)}catch{t=!1}t||n.push(r)}return n}var Ja=class extends Error{hint;name=`PathError`;constructor(e,t){super(e),this.hint=t}},Ya=/^([^#[\]]*)(?:#([^[\]]+))?((?:\[\d+\])*)$/;function Xa(e){if(typeof e!=`string`||!e.trim())throw new Ja(`Empty path.`,`Use a path like "canvas.width" or "layers#title.color".`);let t=[];for(let n of Za(e.trim())){let r=Ya.exec(n);if(!r)throw new Ja(`Invalid path segment "${n}" in "${e}".`,`Segments are keys, "[index]" or "key#id", e.g. "layers#group.children[0].x".`);let[,i,a,o]=r;if(i)t.push({key:i});else if(!a&&!o)throw new Ja(`Empty segment in "${e}".`);a&&t.push({ref:a,tree:i===`layers`||i===`children`});for(let e of o.matchAll(/\[(\d+)\]/g))t.push({index:Number(e[1])})}return t}function Za(e){return e.split(`.`)}function Qa(e){let t=``;for(let n of e)`key`in n?t+=t?`.${n.key}`:n.key:`index`in n?t+=`[${n.index}]`:t+=`#${n.ref}`;return t}var $a=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function eo(e,t,n){for(let n=0;n<e.length;n++){let r=e[n];if($a(r)&&r.id===t)return{container:e,index:n}}if(n){for(let n of e)if($a(n)&&Array.isArray(n.children)){let e=eo(n.children,t,!0);if(e)return e}}return null}function to(e,t,n,r){if(!t.length)throw new Ja(`Empty path.`);let i=e,a=t.map((e,n)=>({tok:e,next:t[n+1]})),o=null;for(let e=0;e<a.length;e++){let{tok:s,next:c}=a[e],l=Qa(t.slice(0,e+1));if(`ref`in s){if(!Array.isArray(i))throw new Ja(`"${Qa(t.slice(0,e))}" is not an array, cannot look up "#${s.ref}" in "${r}".`);let n=eo(i,s.ref,s.tree);if(!n)throw new Ja(`No element with id "${s.ref}" (path "${r}").`,s.tree?`List the layer ids with doc_summary / layer_list.`:void 0);o={parent:n.container,key:n.index}}else if(`index`in s){if(!Array.isArray(i))throw new Ja(`"${Qa(t.slice(0,e))}" is not an array (path "${r}").`);if(s.index>i.length||s.index===i.length&&(e<a.length-1||!n))throw new Ja(`Index ${s.index} out of range at "${l}" (length ${i.length}).`);o={parent:i,key:s.index}}else{if(!$a(i))throw new Ja(`"${Qa(t.slice(0,e))||`<root>`}" is not an object, cannot read "${s.key}" (path "${r}").`);o={parent:i,key:s.key}}if(e===a.length-1)return o;let u=o.parent[o.key];if(u==null){if(!n)throw new Ja(`Nothing at "${l}" (path "${r}").`);u=c&&(`index`in c||`ref`in c)?[]:{},o.parent[o.key]=u}i=u}throw new Ja(`Unreachable`)}function no(e,t){let n=typeof t==`string`?Xa(t):t,r=to(e,n,!1,typeof t==`string`?t:Qa(n));return r.parent[r.key]}function ro(e,t,n){let r=typeof t==`string`?Xa(t):t,i=to(e,r,!0,typeof t==`string`?t:Qa(r));i.parent[i.key]=n}function io(e,t){let n=typeof t==`string`?Xa(t):t,r=to(e,n,!1,typeof t==`string`?t:Qa(n));if(Array.isArray(r.parent)){let e=r.key;return e>=r.parent.length?!1:(r.parent.splice(e,1),!0)}return String(r.key)in r.parent&&(delete r.parent[String(r.key)],!0)}function ao(e,t){if(!$a(t))return oo(t);let n=$a(e)?{...e}:{};for(let[e,r]of Object.entries(t))r===null?delete n[e]:n[e]=ao(n[e],r);return n}function oo(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function so(e){return JSON.stringify(co(e))}function co(e){if(Array.isArray(e))return e.map(co);if($a(e)){let t={};for(let n of Object.keys(e).sort())e[n]!==void 0&&(t[n]=co(e[n]));return t}return e}function lo(e,t){return so(e)===so(t)}var uo=n({cropDoc:()=>bo}),fo=[`top-left`,`top`,`top-right`,`left`,`center`,`right`,`bottom-left`,`bottom`,`bottom-right`],po=e=>JSON.parse(JSON.stringify(e)),F=e=>Math.round(e*100)/100;function mo(e){let t=e.size??64,n=String(e.text??``).split(`
10
+ `),r=Math.max(1,...n.map(e=>e.length));return{width:e.width??r*t*.55+Math.max(0,r-1)*(e.letterSpacing??0),height:e.height??n.length*t*(e.lineHeight??1.2)}}function ho(e,t={}){if(!Lr(e))return null;let n=e.x??0,r=e.y??0;if(e.type===`text`)return{x:n,y:r,...mo(e)};let i=e.width,a=e.height;if(e.type===`image`&&(i===void 0||a===void 0)){let n=t[e.src],r=e.crop?{width:e.crop.width,height:e.crop.height}:n;r&&(i===void 0&&a===void 0?[i,a]=[r.width,r.height]:i===void 0?i=a*r.width/r.height:a=i*r.height/r.width)}return i===void 0||a===void 0?null:{x:n,y:r,width:i,height:a}}function go(e,t){if(e.type!==`image`||e.width!==void 0&&e.height!==void 0)return;let n=ho(e,t);if(!n)throw new A(`invalid`,`The size of image layer "${e.id}" is unknown (its source ${e.src} could not be read).`,`Give the layer an explicit width and height, or fix its src (assets_list).`);e.width=F(n.width),e.height=F(n.height)}function _o(e,t){for(let n of e)t(n),n.type===`group`&&_o(n.children??[],t)}function vo(e,t,n){e&&zr(e)&&(e.x=F(e.x+t),e.y=F(e.y+n))}function yo(e,t,n){_o(e,e=>{Lr(e)?(e.x=F((e.x??0)+t),e.y=F((e.y??0)+n)):vo(e.mask,t,n)})}function bo(e,t){let{x:n,y:r,width:i,height:a}=t;if(![n,r,i,a].every(Number.isFinite)||i<1||a<1)throw new A(`invalid`,`crop needs x, y, width ≥ 1, height ≥ 1 (canvas pixels).`);let o=po(e);return yo(o.layers,-n,-r),o.canvas={...o.canvas,width:Math.round(i),height:Math.round(a)},o}function xo(e,t,n){let r=e.endsWith(`left`)?0:e.endsWith(`right`)?1:.5,i=e.startsWith(`top`)?0:e.startsWith(`bottom`)?1:.5;return[t*r,n*i]}function So(e,t,n,r=`center`){if(!fo.includes(r))throw new A(`invalid`,`Unknown anchor "${r}".`,`Anchors: ${fo.join(`, `)}.`);let[i,a]=xo(r,t-e.canvas.width,n-e.canvas.height);return bo(e,{x:-i,y:-a,width:t,height:n})}function Co(e,t,n){if(e)for(let r of t)typeof e[r]==`number`&&(e[r]=F(e[r]*n))}function wo(e,t){for(let n of e??[])Co(n,(ri(n.type)?.params??[]).filter(e=>e.px).map(e=>e.name),t)}function To(e,t,n,r={}){if(!(t>0)||!(n>0))throw new A(`invalid`,`The scale must be > 0.`);let i=po(e);return _o(i.layers,e=>Eo(e,t,n,r)),i.canvas={...i.canvas,width:Math.max(1,Math.round(e.canvas.width*t)),height:Math.max(1,Math.round(e.canvas.height*n))},i}function Eo(e,t,n,r){let i=Math.sqrt(t*n);if(go(e,r),Lr(e))e.x=F((e.x??0)*t),e.y=F((e.y??0)*n),e.width!==void 0&&(e.width=F(e.width*t)),e.height!==void 0&&(e.height=F(e.height*n));else if(e.mask&&zr(e.mask)){let r=e.mask;r.x=F(r.x*t),r.y=F(r.y*n),r.width=F(r.width*t),r.height=F(r.height*n)}if(e.mask){if(Lr(e)&&zr(e.mask)){let r=e.mask;r.x=F(r.x*t),r.y=F(r.y*n),r.width=F(r.width*t),r.height=F(r.height*n)}Co(e.mask,[`feather`,`radius`],i)}if(e.type===`text`&&(Co(e,[`size`,`letterSpacing`],i),e.background)){let t=e.background.padding;e.background.padding=Array.isArray(t)?[F(t[0]*i),F(t[1]*i)]:typeof t==`number`?F(t*i):t,Co(e.background,[`radius`],i)}if(e.type===`shape`&&(Co(e,[`radius`],i),e.stroke&&Co(e.stroke,[`width`],i)),wo(e.filters,i),e.effects)for(let t of Yr){let n=e.effects[t.id];Co(n,t.params.filter(e=>e.px).map(e=>e.name),i)}}var Do=e=>!!e&&typeof e==`object`&&[`x`,`y`,`width`,`height`].every(t=>Number.isFinite(e[t]));function Oo(e,t,n,r={}){if(!Do(n)||n.width<1||n.height<1)throw new A(`invalid`,`fitLayer needs box { x, y, width ≥ 1, height ≥ 1 } (canvas px).`);let i=r.anchor??`center`;if(!fo.includes(i))throw new A(`invalid`,`Unknown anchor "${i}".`,`Anchors: ${fo.join(`, `)}.`);let a=po(e),o=null;_o(a.layers,e=>{e.id===t&&!o&&(o=e)});let s=o;if(!s)throw new A(`notFound`,`No layer "${t}".`,`layer_list lists the layer ids.`);if(!Lr(s))throw new A(`invalid`,`"${t}" is a ${s.type} layer: fitLayer moves image, text and shape layers.`);go(s,r.sizes??{});let c=ho(s,r.sizes);if(!c||!(c.width>0)||!(c.height>0))throw new A(`invalid`,`The box of layer "${t}" is unknown.`,`Give the layer an explicit width and height.`);let l=r.subject??c;if(!Do(l)||!(l.width>0)||!(l.height>0))throw new A(`invalid`,`fitLayer subject must be { x, y, width > 0, height > 0 } (canvas px).`,`Pass the subject returned by remove_background, or omit it to fit the whole layer.`);let u=Math.min(n.width/l.width,n.height/l.height),[d,f]=xo(i,n.width-l.width*u,n.height-l.height*u),p=l.x-c.x,m=l.y-c.y;return Eo(s,u,u,r.sizes??{}),s.x=F(n.x+d-p*u),s.y=F(n.y+f-m*u),a}var ko=e=>{let t=((e+180)%360+360)%360-180;return t===-180?180:t};function Ao(e,t){if(e&&typeof e==`object`){if(e.type===`linear`)e.angle=F(ko(t.angle(e.angle??90)));else if(e.type===`radial`){let[n,r]=t.point(e.cx??.5,e.cy??.5);e.cx=F(n),e.cy=F(r)}}}function jo(e,t){Ao(e.canvas.background,t),_o(e.layers,e=>{Lr(e)||(e.type===`fill`&&Ao(e.fill,t),e.mask&&Br(e.mask)&&Ao(e.mask.gradient,t))})}function Mo(e,t,n={}){let r=(Math.round(t/90)*90%360+360)%360;if(t%90!=0)throw new A(`invalid`,`Canvas rotation must be a multiple of 90°, got ${t}.`,`To straighten a photo by a few degrees, set the image layer's rotation instead (and crop).`);if(r===0)return po(e);let i=po(e),a=e.canvas.width,o=e.canvas.height,s=(e,t)=>r===90?[o-t,e]:r===180?[a-e,o-t]:[t,a-e];return _o(i.layers,e=>{go(e,n);let t=ho(e,n);if(t){let[n,i]=s(t.x+t.width/2,t.y+t.height/2),a=e;a.x=F(n-t.width/2),a.y=F(i-t.height/2),a.rotation=ko((a.rotation??0)+r),a.rotation===0&&delete a.rotation}else if(e.mask&&zr(e.mask)){let t=e.mask,[n,i]=s(t.x+t.width/2,t.y+t.height/2),[a,o]=r===180?[t.width,t.height]:[t.height,t.width];Object.assign(t,{x:F(n-a/2),y:F(i-o/2),width:a,height:o})}}),jo(i,{angle:e=>e+r,point:(e,t)=>r===90?[1-t,e]:r===180?[1-e,1-t]:[t,1-e]}),r!==180&&(i.canvas={...i.canvas,width:o,height:a}),i}function No(e,t,n={}){if(t!==`horizontal`&&t!==`vertical`)throw new A(`invalid`,`axis must be "horizontal" or "vertical".`);let r=po(e),i=e.canvas.width,a=e.canvas.height;return _o(r.layers,e=>{go(e,n);let r=ho(e,n);if(r){let n=e;t===`horizontal`?(n.x=F(i-r.x-r.width),e.type!==`text`&&(n.flipX=!n.flipX||void 0)):(n.y=F(a-r.y-r.height),e.type!==`text`&&(n.flipY=!n.flipY||void 0)),n.rotation&&=-n.rotation,n.flipX||delete n.flipX,n.flipY||delete n.flipY}else if(e.mask&&zr(e.mask)){let n=e.mask;t===`horizontal`?n.x=F(i-n.x-n.width):n.y=F(a-n.y-n.height)}}),jo(r,t===`horizontal`?{angle:e=>180-e,point:(e,t)=>[1-e,t]}:{angle:e=>-e,point:(e,t)=>[e,1-t]}),r}async function Po(e){return Ki(await Mr(e,Ea,`The document`))}function Fo(e,t){let{parent:n,depth:r,index:i,locked:a,...o}=t,s={...o};return e.type===`group`&&(s.children=[...e.children??[]].reverse().map((t,n,r)=>Fo(t,Io(t,e,r.length-1-n)))),s}var Io=(e,t,n)=>({..._a({layers:[e]})[0],parent:t?.id??null,index:n});function Lo(e){let t={},n=0,r=0,i=0,a=new Set;P(e.layers,e=>{t[e.type]=(t[e.type]??0)+1,e.visible===!1&&n++,e.mask&&r++,i+=e.filters?.length??0,e.type===`image`&&a.add(e.src),e.mask&&`src`in e.mask&&a.add(e.mask.src)});let o=e.canvas?.background;return{id:e.id,...e.title?{title:e.title}:{},canvas:{width:e.canvas?.width,height:e.canvas?.height,background:o==null?`transparent`:typeof o==`string`?o:`${o.type} gradient`},layers:[...Array.isArray(e.layers)?e.layers:[]].reverse().map((e,t,n)=>Fo(e,Io(e,null,n.length-1-t))),counts:{layers:Object.values(t).reduce((e,t)=>e+t,0),byType:t,hidden:n,masks:r,filters:i},sources:[...a],...e.export?{export:e.export}:{}}}function Ro(e,t){let n=e=>{let t=new Map;if(!e)return t;let n=(e,r)=>{Array.isArray(e)&&e.forEach((e,i)=>{e&&typeof e==`object`&&(t.set(e.id,{layer:e,where:`${r}[${i}]`}),e.type===`group`&&n(e.children,e.id))})};return n(e.layers,`root`),t},r=n(e),i=n(t),a=[...i.keys()].filter(e=>!r.has(e)),o=[...r.keys()].filter(e=>!i.has(e)),s=[],c=new Set,l=e=>e.slice(0,e.lastIndexOf(`[`)),u=e=>Number(e.slice(e.lastIndexOf(`[`)+1,-1)),d=new Map;for(let[e,{layer:t,where:n}]of i){let i=r.get(e);if(!i)continue;let a=new Set([...Object.keys(i.layer),...Object.keys(t)]);a.delete(`children`);let o=[...a].filter(e=>!lo(i.layer[e],t[e]));if(o.length&&s.push({id:e,fields:o}),l(i.where)!==l(n))c.add(e);else{let t=d.get(l(n))??[];t.push({id:e,from:u(i.where),to:u(n)}),d.set(l(n),t)}}for(let e of d.values()){e.sort((e,t)=>e.from-t.from);let t=zo(e.map(e=>e.to));e.forEach((e,n)=>{t.has(n)||c.add(e.id)})}let f=[...i.keys()].filter(e=>c.has(e)).map(e=>({id:e,from:r.get(e).where,to:i.get(e).where})),p=[`canvas`,`title`,`description`,`export`,`id`,`version`].filter(n=>!lo(e?.[n],t[n])),m=[];a.length&&m.push(`added ${a.join(`, `)}`),o.length&&m.push(`removed ${o.join(`, `)}`),s.length&&m.push(`changed ${s.map(e=>`${e.id} (${e.fields.join(`, `)})`).join(`; `)}`),f.length&&m.push(`moved ${f.map(e=>e.id).join(`, `)}`),p.length&&m.push(`updated ${p.join(`, `)}`);let h=!m.length;return{empty:h,layers:{added:a,removed:o,changed:s,moved:f},sections:p,summary:h?`No change.`:`${m.join(`; `)}.`}}function zo(e){let t=[],n=[],r=-1;for(let i=0;i<e.length;i++){t[i]=1,n[i]=-1;for(let r=0;r<i;r++)e[r]<e[i]&&t[r]+1>t[i]&&(t[i]=t[r]+1,n[i]=r);(r<0||t[i]>t[r])&&(r=i)}let i=new Set;for(let e=r;e>=0;e=n[e])i.add(e);return i}async function Bo(e,t,n={}){let r=await e.exists(`photo.json`)?await Po(e).catch(()=>null):null,i=Ki(t),a=Gi(i),o=Ro(r,i);return Ar(a)||n.dryRun||o.empty?{plan:o,issues:a,applied:!1}:(await Fa(e,i,{allowInvalid:!1}),{plan:o,issues:a,applied:!0})}var Vo=[`set`,`merge`,`remove`,`addLayer`,`updateLayer`,`removeLayer`,`moveLayer`,`duplicateLayer`,`groupLayers`,`ungroup`,`addFilter`,`updateFilter`,`removeFilter`,`setMask`,`crop`,`resizeCanvas`,`resizeImage`,`rotateCanvas`,`flipCanvas`,`fitLayer`],Ho=new Set([`resizeImage`,`rotateCanvas`,`flipCanvas`,`fitLayer`]),Uo=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function Wo(e,t,n,r){return new A(t===`notFound`?`notFound`:t,`ops[${e}]: ${n}`,r,{opIndex:e})}function Go(e,t,n){if(typeof t!=`string`)throw Wo(n,`invalid`,`"id" (a layer id) is required.`);let r=N(e.layers,t);if(!r)throw Wo(n,`notFound`,`No layer "${t}".`,`${Cr(t,da(e))}doc_summary / layer_list list the layer ids.`);return r}function Ko(e,t,n,r){let i=t.above??t.below;if(i!==void 0){let a=Go(e,i,n);if(r&&(a.layer===r||fa(r,i)))throw Wo(n,`invalid`,`Cannot place "${r.id}" relative to itself or its own child.`);return{container:a.container,index:t.above===void 0?a.index:a.index+1}}let a=e.layers;if(t.parent!==void 0&&t.parent!==null){let i=Go(e,t.parent,n);if(i.layer.type!==`group`)throw Wo(n,`invalid`,`"${t.parent}" is a ${i.layer.type} layer, not a group.`,`Only group layers have children (groupLayers creates one).`);if(r&&(i.layer===r||fa(r,i.layer.id)))throw Wo(n,`invalid`,`Cannot move "${r.id}" into itself.`);a=i.layer.children??=[]}let o=t.index===void 0?a.length:Math.max(0,Math.min(a.length,Math.round(t.index)));return{container:a,index:o}}function qo(e,t,n){let r=new Set(da(e)),i=e=>{if(!Uo(e))throw Wo(n,`invalid`,`layer must be an object.`);if(!bi(e.id))throw Wo(n,`invalid`,`Invalid layer id ${JSON.stringify(e.id)}.`,`Ids start with a letter: "photo", "title", "badge-2".`);if(r.has(e.id))throw Wo(n,`conflict`,`A layer "${e.id}" already exists.`,`Use updateLayer to change it, or another id (e.g. "${Si(e.id,r)}").`);r.add(e.id),e.type===`group`&&(e.children??[]).forEach(i)};i(t)}function I(e,t,n){let r=oo(e),i=(e,r)=>{e.id=r&&n?n:Si(`${e.id}-copy`,t),t.add(e.id),e.type===`group`&&(e.children??[]).forEach(e=>i(e,!1))};return i(r,!0),r}function Jo(e,t){let n=e.layer;return Array.isArray(n.filters)||(n.filters=[]),n.filters}function Yo(e,t,n,r){if(typeof t!=`number`||!Number.isInteger(t)||t<0||t>=e.length)throw Wo(n,`invalid`,`Layer "${r}" has no filter at index ${JSON.stringify(t)} (it has ${e.length}).`,`layer_list / doc_summary list each layer's filters in order.`);return t}function Xo(e,t,n={}){if(!Array.isArray(t))throw new A(`invalid`,`ops must be an array of patch operations.`);let r=oo(e);return t.forEach((e,t)=>{if(!Uo(e)||typeof e.op!=`string`)throw Wo(t,`invalid`,`Each op is an object with an "op" field.`,`Ops: ${Vo.join(`, `)}.`);try{switch(e.op){case`set`:if(typeof e.path!=`string`)throw Wo(t,`invalid`,`"path" is required.`);ro(r,e.path,oo(e.value));break;case`merge`:{if(typeof e.path!=`string`)throw Wo(t,`invalid`,`"path" is required.`);let n;try{n=no(r,e.path)}catch{n=void 0}ro(r,e.path,ao(n,e.value));break}case`remove`:if(typeof e.path!=`string`)throw Wo(t,`invalid`,`"path" is required.`);if(!io(r,e.path))throw Wo(t,`notFound`,`Nothing at "${e.path}".`);break;case`addLayer`:{if(!Uo(e.layer))throw Wo(t,`invalid`,`"layer" (a layer object) is required.`);qo(r,e.layer,t);let n=Ko(r,e,t);n.container.splice(n.index,0,oo(e.layer));break}case`updateLayer`:{let n=Go(r,e.id,t);if(!Uo(e.set))throw Wo(t,`invalid`,`"set" (an object of fields to change) is required.`);for(let n of[`id`,`type`,`children`])if(n in e.set)throw Wo(t,`invalid`,`updateLayer cannot change "${n}".`,n===`children`?`Use addLayer / moveLayer with parent.`:`Remove the layer and add a new one.`);let i=ao(n.layer,e.set);n.container[n.index]=i;break}case`removeLayer`:{let n=Go(r,e.id,t);n.container.splice(n.index,1);break}case`moveLayer`:{let n=Go(r,e.id,t),i=n.layer;Ko(r,e,t,i),n.container.splice(n.index,1);let a=Ko(r,e,t,i);a.container.splice(a.index,0,i);break}case`duplicateLayer`:{let n=Go(r,e.id,t),i=new Set(da(r));if(e.newId!==void 0&&(!bi(e.newId)||i.has(e.newId)))throw Wo(t,`conflict`,`newId ${JSON.stringify(e.newId)} is invalid or taken.`);let a=I(n.layer,i,e.newId);if(e.offset){let[n,r]=e.offset;if(!Number.isFinite(n)||!Number.isFinite(r))throw Wo(t,`invalid`,`offset must be [dx, dy] in px.`);P([a],e=>{Lr(e)?(e.x=(e.x??0)+n,e.y=(e.y??0)+r):e.mask&&zr(e.mask)&&(e.mask.x+=n,e.mask.y+=r)})}a.name&&=`${a.name} copy`,n.container.splice(n.index+1,0,a);break}case`groupLayers`:{if(!Array.isArray(e.ids)||!e.ids.length)throw Wo(t,`invalid`,`"ids" (layers to group) is required.`);if(!bi(e.id)||da(r).includes(e.id))throw Wo(t,`conflict`,`Group id ${JSON.stringify(e.id)} is invalid or taken.`);let n=[...new Set(e.ids)].map(e=>Go(r,e,t)),i=n[0].container;if(n.some(e=>e.container!==i))throw Wo(t,`invalid`,`Grouped layers must be siblings (same parent).`);let a=[...n].sort((e,t)=>e.index-t.index),o=a[0].index,s=a.map(e=>e.layer);for(let e of[...a].reverse())i.splice(e.index,1);i.splice(o,0,{id:e.id,type:`group`,...e.name?{name:e.name}:{},children:s});break}case`ungroup`:{let n=Go(r,e.id,t);if(n.layer.type!==`group`)throw Wo(t,`invalid`,`"${e.id}" is not a group.`);n.container.splice(n.index,1,...n.layer.children??[]);break}case`addFilter`:{let n=Go(r,e.id,t);if(!Uo(e.filter)||typeof e.filter.type!=`string`)throw Wo(t,`invalid`,`"filter" ({ type, ...params }) is required.`,`e.g. { "type": "brightnessContrast", "contrast": 20 } — catalog_get section "filters".`);let i=Jo(n,t),a=e.index===void 0?i.length:Math.max(0,Math.min(i.length,e.index));i.splice(a,0,oo(e.filter));break}case`updateFilter`:{let n=Jo(Go(r,e.id,t),t),i=Yo(n,e.index,t,e.id);if(!Uo(e.set))throw Wo(t,`invalid`,`"set" is required.`);n[i]=ao(n[i],e.set);break}case`removeFilter`:{let n=Jo(Go(r,e.id,t),t);n.splice(Yo(n,e.index,t,e.id),1);break}case`setMask`:{let n=Go(r,e.id,t);e.mask===null||e.mask===void 0?delete n.layer.mask:n.layer.mask=oo(e.mask);break}case`crop`:r=bo(r,e);break;case`resizeCanvas`:if(e.anchor!==void 0&&!fo.includes(e.anchor))throw Wo(t,`invalid`,`Unknown anchor "${e.anchor}".`,`Anchors: ${fo.join(`, `)}.`);if(!(e.width>=1)||!(e.height>=1))throw Wo(t,`invalid`,`resizeCanvas needs width ≥ 1 and height ≥ 1.`);r=So(r,Math.round(e.width),Math.round(e.height),e.anchor);break;case`resizeImage`:{let i=r.canvas.width,a=r.canvas.height,o,s;if(typeof e.scale==`number`)o=s=e.scale;else if(typeof e.width==`number`&&typeof e.height==`number`)[o,s]=[e.width/i,e.height/a];else if(typeof e.width==`number`)o=s=e.width/i;else if(typeof e.height==`number`)o=s=e.height/a;else throw Wo(t,`invalid`,`resizeImage needs scale, width and/or height.`);r=To(r,o,s,n);break}case`rotateCanvas`:r=Mo(r,e.angle,n);break;case`flipCanvas`:r=No(r,e.axis,n);break;case`fitLayer`:Go(r,e.id,t),r=Oo(r,e.id,e.box,{subject:e.subject,anchor:e.anchor,sizes:n});break;default:throw Wo(t,`invalid`,`Unknown op "${e.op}".`,`${Cr(e.op,Vo)}Ops: ${Vo.join(`, `)}.`)}}catch(n){throw n instanceof A?n.details?.opIndex===void 0?new A(n.code,`ops[${t}] (${e.op}): ${n.message}`,n.hint,{opIndex:t}):n:n instanceof Ja?new A(`invalid`,`ops[${t}] (${e.op}): ${n.message}`,n.hint??`Paths look like "canvas.background", "layers#title.size", "layers#photo.filters[0].radius".`,{opIndex:t}):n}}),r}async function Zo(e,t,n){let{imageInfo:r}=await wa(async()=>{let{imageInfo:e}=await Promise.resolve().then(()=>Ji);return{imageInfo:e}},void 0,import.meta.url),i={},a=new Set;P(t.layers,e=>{e.type===`image`&&a.add(e.src)});for(let t of a)try{let a=sa(t)?n?await n(t.slice(8)):null:await e.readBytes(t),o=a?r(a):null;o&&(i[t]={width:o.width,height:o.height})}catch{}return i}async function Qo(e,t,n={}){let r=await Po(e),i=Xo(r,t,n.sizes??(Array.isArray(t)&&t.some(e=>Uo(e)&&Ho.has(e.op))?await Zo(e,r,n.readLibrary):{})),a=Gi(i),o=Ro(r,i);return Ar(a)||n.dryRun||o.empty?{plan:o,issues:a,applied:!1,doc:Ar(a)?r:i}:(await Fa(e,i),{plan:o,issues:a,applied:!0,doc:i})}async function $o(e,t={}){let n=await Po(e),r=[...Gi(n)],i=(e,t,n,i,a)=>r.push({severity:e,code:t,path:n,message:i,...a?{hint:a}:{}});for(let t of await qa(e,n))i(`error`,`missing-file`,`layers#${t.by}.${t.role===`src`?`src`:`mask.src`}`,`${t.path} does not exist in the project.`,`Import it with assets_add, or point the layer at an existing file (assets_list).`);let a={},o=new Set;P(n.layers,e=>{e.type===`image`&&o.add(e.src)});for(let n of o)if(sa(n)){let e=la(t.library,ca(n));t.library&&!e&&i(`error`,`unknown-library`,n,`Unknown library image "${n}".`,`library_list lists the built-in images (reference them as "library:<id>").`),e?.width&&e.height&&(a[n]={width:e.width,height:e.height})}else try{let t=ra(await e.readBytes(n));t?a[n]={width:t.width,height:t.height}:i(`error`,`bad-image`,n,`${n} is not a readable image.`)}catch{}let s=n.canvas.width,c=n.canvas.height,l=0,u=0,d=s*c/1e6;P(n.layers,e=>{l++;let t=`layers#${e.id}`;for(let t of e.filters??[])t.enabled!==!1&&(u+=(ri(t.type)?.cost??1)*d);if(e.visible===!1)return;e.opacity===0&&i(`info`,`invisible`,t,`Layer "${e.id}" has opacity 0 (renders nothing).`);let n=ho(e,a);if(n&&!e.rotation&&(n.x>=s||n.y>=c||n.x+n.width<=0||n.y+n.height<=0?i(`warning`,`off-canvas`,t,`Layer "${e.id}" is entirely outside the canvas (${Math.round(n.x)}, ${Math.round(n.y)}, ${Math.round(n.width)}×${Math.round(n.height)}).`,`The canvas is ${s}×${c}: move it (x, y) or resize it.`):e.type===`text`&&!e.width&&(n.x+n.width>s+2||n.x<-2)&&i(`info`,`text-may-overflow`,t,`Text "${e.id}" may run past the canvas edge (estimated width ${Math.round(n.width)} px).`,`Give it a width (it wraps), reduce size, or look at render_preview.`)),e.type===`image`&&n){let r=a[e.src],o=e.crop??r;if(o&&r){let r=n.width/o.width,a=n.height/o.height,s=e.fit===`contain`?Math.min(r,a):Math.max(r,a);s>1.6&&i(`warning`,`upscaled`,t,`Image "${e.id}" is shown at ${Math.round(s*100)} % of its resolution (${o.width}×${o.height} stretched to ${Math.round(n.width)}×${Math.round(n.height)}): it will look soft.`,`Use a larger source, or a smaller layer / canvas.`)}}e.clip&&e.type===`group`&&i(`info`,`clip-group`,t,`Clipping applies to the group as a whole.`)}),n.layers.length||i(`warning`,`empty`,`layers`,`The document has no layers.`,`layer_add adds one (an image from assets_add, text, shapes…).`),u>60&&i(`info`,`heavy`,``,`Rendering cost ${Math.round(u)} (filters × megapixels): previews may be slow.`,`Fewer blur / sharpen / clarity filters, or a smaller canvas.`);let f=await Ba(e),p=new Set;P(n.layers,e=>{e.type===`image`&&p.add(e.src),e.mask&&`src`in e.mask&&p.add(e.mask.src)});let m=f.assets.filter(e=>p.has(e.path)&&(e.license||e.attribution)).map(e=>({path:e.path,license:e.license,author:e.author,attribution:e.attribution,source:e.source}));for(let e of p){if(!sa(e))continue;let n=la(t.library,ca(e));n&&m.push({path:e,license:n.license,author:n.author,attribution:void 0,source:n.source??`library`})}let h=0;for(let e of f.assets)p.has(e.path)&&(h+=e.bytes??0);let g={errors:0,warnings:0,infos:0};for(let e of r)g[e.severity===`error`?`errors`:e.severity===`warning`?`warnings`:`infos`]++;return{ok:g.errors===0,issues:r,counts:g,canvas:{width:s,height:c,megapixels:Math.round(d*100)/100},layers:l,cost:Math.round(u*10)/10,assetsKb:Fr(h),licences:m}}function es(e,t={}){let n=(t.query??``).toLowerCase().split(/\s+/).filter(Boolean);return(e??[]).filter(e=>{if(t.category&&e.category!==t.category)return!1;let r=`${e.id} ${e.title} ${e.description} ${e.category} ${e.tags.join(` `)}`.toLowerCase();return n.every(e=>r.includes(e))})}function ts(e,t){let n=(e??[]).find(e=>e.id===t);if(!n){let n=Sr(t,(e??[]).map(e=>e.id));throw new A(`notFound`,`Unknown template "${t}".`,`${n?`Did you mean "${n}"? `:``}List templates with templates_list / \`agentphoto templates list\`.`)}return n}function ns(e,t){let n=e??{};return{id:typeof n.id==`string`?n.id:t,title:typeof n.title==`string`?n.title:t,description:typeof n.description==`string`?n.description:``,category:typeof n.category==`string`?n.category:`other`,tags:Array.isArray(n.tags)?n.tags.map(String):[],width:typeof n.width==`number`?n.width:1200,height:typeof n.height==`number`?n.height:630,...typeof n.slot==`string`?{slot:n.slot}:{},...rs(n.subjectArea)?{subjectArea:rs(n.subjectArea)}:{}}}function rs(e){if(!e||typeof e!=`object`)return null;let t=e;if(![`x`,`y`,`width`,`height`].every(e=>typeof t[e]==`number`&&Number.isFinite(t[e]))||!(t.width>=1&&t.height>=1))return null;let n=fo.includes(t.anchor)?t.anchor:void 0;return{x:t.x,y:t.y,width:t.width,height:t.height,...n?{anchor:n}:{}}}function is(e){let t=e.host?.library;if(t)return async e=>{let n=t.index.assets.find(t=>t.id===e);return n?.path?t.read(n.path):null}}function as(e,t,n=!0){let r=e[t];if(typeof r==`string`&&r.trim())return r.trim();if(n)throw new A(`invalid`,`Missing "${t}" (string).`);return``}function L(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function os(e,t,n=!1){let r=e[t];return typeof r==`boolean`?r:n}function ss(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function cs(e,t=40){let n={error:0,warning:1,info:2},r=[...e].sort((e,t)=>n[e.severity]-n[t.severity]),i=r.slice(0,t);return r.length>t?{issues:i,omitted:r.length-t}:{issues:i}}function ls(e){let t={errors:0,warnings:0,infos:0};for(let n of e)t[n.severity===`error`?`errors`:n.severity===`warning`?`warnings`:`infos`]++;return t}function us(e,t){let n=ls(e.issues),r=n.errors?`refused`:e.plan.empty?`unchanged`:t?`dry-run`:`applied`;return{status:r,applied:e.applied,plan:e.plan.empty?{summary:e.plan.summary}:e.plan,counts:n,...cs(e.issues.filter(e=>n.errors===0||e.severity!==`info`)),hint:r===`refused`?`Nothing was written: fix the errors (each issue has a hint) and call again.`:r===`applied`?`Saved. Call render_preview and look at the image to verify the result.`:r===`dry-run`?`Dry run: call again without dryRun to write.`:`The document already matches: nothing to do.`}}function ds(e,t,n){if(t??={},typeof t!=`object`||Array.isArray(t))throw new A(`invalid`,`${n}: input must be a JSON object.`);let r=t;for(let t of e.required??[])if(r[t]===void 0||r[t]===null||r[t]===``)throw new A(`invalid`,`${n}: missing required input "${t}".`,e.properties?.[t]?.description);for(let[t,i]of Object.entries(r)){let r=e.properties?.[t];if(!r||i==null||!r.type)continue;let a=Array.isArray(r.type)?r.type:[r.type],o=Array.isArray(i)?`array`:typeof i==`number`?Number.isInteger(i)?`integer`:`number`:typeof i;if(!a.some(e=>e===o||e===`number`&&o===`integer`))throw new A(`invalid`,`${n}: "${t}" must be ${a.join(` or `)}, got ${o}.`,r.description);if(r.enum&&!r.enum.includes(i))throw new A(`invalid`,`${n}: "${t}" must be one of ${r.enum.map(e=>JSON.stringify(e)).join(`, `)}.`)}return r}var fs={type:`boolean`,description:`Preview the plan and issues without writing (default false).`},ps={type:`object`,description:`A layer: { "id": "title", "type": "image|text|shape|fill|adjustment|group", "name"?, "visible"?, "opacity" (0..1)?, "blend"?, "mask"?, "clip"?, "filters"?: [{ "type": …, …params }], "effects"?: { dropShadow, outerGlow, innerShadow, stroke, colorOverlay } } + by type — image { src: "assets/…" | "library:<id>", x, y, width?, height?, rotation?, flipX?, flipY?, crop?, fit?: fill|cover|contain, focus? }; text { text, x, y, width? (wraps), font (catalog id), size, weight, italic, color (colour | gradient), align, valign, lineHeight, letterSpacing, transform, background? { color, padding, radius } }; shape { shape: rect|ellipse|line|polygon|star, x, y, width, height, fill, stroke { color, width, dash }, radius, sides, innerRadius }; fill { fill: colour | gradient } (whole canvas); adjustment { filters } (affects layers below); group { children: [layers] }. Pixels, origin top-left, degrees.`,additionalProperties:!0},ms={parent:{type:[`string`,`null`],description:`Group id to put it in (default: the root).`},index:{type:`integer`,description:`Position in the parent, 0 = bottom (default: top).`},above:{type:`string`,description:`Place it just above this layer id.`},below:{type:`string`,description:`Place it just below this layer id.`}},hs=Object.keys(ni);function gs(e,t){if(!e)return{sections:{layerTypes:ni.layerTypes.map(e=>`${e.id} — ${e.description}`),filters:ni.filters.map(e=>`${e.id} (${e.group}) — ${e.description}`),looks:ni.looks.map(e=>`${e.id} — ${e.description}`),effects:ni.effects.map(e=>`${e.id} — ${e.description}`),blendModes:ni.blendModes,shapes:ni.shapes,fonts:ni.fonts.map(e=>`${e.id} (${e.style}, weights ${e.weights.join(`/`)}) — ${e.description}`),sizes:ni.sizes.map(e=>`${e.id} ${e.width}×${e.height} — ${e.title}`),models:ni.models.map(e=>`${e.id} (${e.task}, ${e.sizeMb} MB) — ${e.description}`)},commonFilterParams:ni.commonFilterParams,hint:`catalog_get { section: "filters", id: "curves" } gives the parameters (types, ranges, defaults) and an example of one entry.`};let n=hs.find(t=>t.toLowerCase()===e.toLowerCase())??hs.find(t=>t.toLowerCase().startsWith(e.toLowerCase()));if(!n){let t=Sr(e,hs);throw new A(`notFound`,`Unknown catalog section "${e}".`,`${t?`Did you mean "${t}"? `:``}Sections: ${hs.join(`, `)}.`)}let r=ni[n];if(!t)return{section:n,entries:r};let i=r.find(e=>typeof e==`object`&&e&&e.id===t)??r.find(e=>e===t);if(!i){let e=r.map(e=>typeof e==`string`?e:e.id),i=Sr(t,e);throw new A(`notFound`,`No "${t}" in ${n}.`,`${i?`Did you mean "${i}"? `:``}Valid ids: ${wr(e)}.`)}return{section:n,entry:i}}async function _s(e,t,n){return us(await Qo(e.fs,t,{dryRun:n,readLibrary:is(e)}),n)}async function vs(e,t,n){let r=L(t,`file`)??L(t,`image`),i=L(t,`url`)??L(t,`imageUrl`);if(r){if(/^https?:\/\//.test(r))return ys(e,r);if(!e.host?.readLocalFile)throw new A(`invalid`,`${n}: this host cannot read local files.`,`Use url, or import the file from the Studio (drag & drop).`);let i=await e.host.readLocalFile(r);return{name:(n===`assets_add`?L(t,`name`):void 0)??r.split(/[\\/]/).pop()??`image`,bytes:i,source:`user`}}return i?ys(e,i):null}async function ys(e,t){if(!e.fetch)throw new A(`invalid`,`This host has no network access for URLs.`,`Download the file and pass its local path (file).`);let n=await e.fetch(t,{headers:{accept:`image/*`}});if(!n.ok)throw new A(`io`,`Download failed (HTTP ${n.status}): ${t}`);let r=new URL(t);return{name:decodeURIComponent(r.pathname.split(`/`).pop()||`image`),bytes:new Uint8Array(await n.arrayBuffer()),source:r.host,sourceUrl:t}}var bs=[{name:`project_info`,description:`The project: manifest, document summary (canvas, layers top → bottom with type, box, filters, masks, effects) and issue counts. Start here.`,inputSchema:{type:`object`,properties:{}},mutating:!1,async handler(e){let{manifest:t,doc:n}=await Pa(e.fs);return{manifest:t,summary:Lo(n),counts:ls(Gi(n))}}},{name:`project_create`,description:`Create a project in the current folder: blank (size preset or width / height), from a photo (image: local path or URL — the canvas takes its size, it becomes the "photo" layer), and / or from a template (templates_list). Fails if a project exists unless force.`,inputSchema:{type:`object`,properties:{name:{type:`string`,description:`Project name (slug).`},title:{type:`string`},image:{type:`string`,description:`Local file path or http(s) URL of the starting photo.`},size:{type:`string`,description:`Canvas size preset (catalog "sizes": og, square, story, youtube…).`},width:{type:`integer`},height:{type:`integer`},background:{type:[`string`,`object`,`null`],description:`Canvas background (colour, gradient, null = transparent).`},template:{type:`string`,description:`Template id.`},force:{type:`boolean`,description:`Overwrite an existing project.`}},required:[`name`]},mutating:!0,async handler(e,t){let n=await vs(e,t,`project_create`),r=L(t,`template`),i;if(r){if(!e.host?.templates)throw new A(`invalid`,`Templates are not available on this host.`);ts(e.host.templates.index,r),i=await e.host.templates.files(r)}let a=await ja(e.fs,{name:as(t,`name`),title:L(t,`title`),size:L(t,`size`),width:ss(t,`width`),height:ss(t,`height`),background:t.background,template:r,templateFiles:i,image:n??void 0,force:os(t,`force`)});return{created:!0,manifest:a.manifest,files:a.files,summary:Lo(a.doc),...cs(a.issues),hint:`Next: render_preview to see it, then layer_add / doc_patch to edit.`}}},{name:`doc_get`,description:`The full document (photo.json). Prefer doc_summary unless you need exact values.`,inputSchema:{type:`object`,properties:{}},mutating:!1,handler:e=>Po(e.fs)},{name:`doc_summary`,description:`Compact outline: canvas size / background, layers top → bottom (id, type, detail, box [x, y, w, h], opacity, blend, mask kind, filters, effects, children), counts, sources.`,inputSchema:{type:`object`,properties:{}},mutating:!1,handler:async e=>Lo(await Po(e.fs))},{name:`doc_apply`,description:`Replace the whole document (validated; nothing written on errors). Destructive: confirm with the user when it removes layers. Use doc_patch for edits.`,inputSchema:{type:`object`,properties:{doc:{type:`object`,description:`The full PhotoDoc { version: 1, id, title?, canvas: { width, height, background? }, layers: [...] }.`,additionalProperties:!0},dryRun:fs},required:[`doc`]},mutating:!0,async handler(e,t){let n=os(t,`dryRun`);return us(await Bo(e.fs,t.doc,{dryRun:n}),n)}},{name:`doc_patch`,description:`Atomic list of edits, validated together (nothing written if any fails). Ops: ${Vo.join(`, `)}. Shapes: { op: "set", path: "layers#title.size", value: 96 } · { op: "merge", path, value } (objects merge, null deletes) · { op: "remove", path } · { op: "addLayer", layer, parent?, index?, above?, below? } · { op: "updateLayer", id, set } (deep merge, null deletes a field) · { op: "removeLayer", id } · { op: "moveLayer", id, parent?, index?, above?, below? } · { op: "duplicateLayer", id, newId?, offset? } · { op: "groupLayers", ids, id, name? } · { op: "ungroup", id } · { op: "addFilter", id, filter, index? } · { op: "updateFilter", id, index, set } · { op: "removeFilter", id, index } · { op: "setMask", id, mask | null } · { op: "crop", x, y, width, height } · { op: "resizeCanvas", width, height, anchor? } · { op: "resizeImage", width?, height?, scale? } · { op: "rotateCanvas", angle: 90|180|270 } · { op: "flipCanvas", axis: horizontal|vertical } · { op: "fitLayer", id, box: { x, y, width, height }, subject?, anchor? } (scale + move a layer so subject — a canvas-px region of it, e.g. remove_background's subject; default its box — fits in box, aligned on anchor: center, bottom…). Paths: "canvas.background", "layers#<id>.<field>", "layers#<id>.filters[0].radius".`,inputSchema:{type:`object`,properties:{ops:{type:`array`,items:{type:`object`,additionalProperties:!0},description:`Patch operations, applied in order.`},dryRun:fs},required:[`ops`]},mutating:!0,handler:(e,t)=>_s(e,t.ops,os(t,`dryRun`))},{name:`doc_validate`,description:`Validate a document (the given one, or photo.json): issues with JSON paths and hints.`,inputSchema:{type:`object`,properties:{doc:{type:`object`,additionalProperties:!0}}},mutating:!1,async handler(e,t){let n=Gi(t.doc??await Po(e.fs));return{valid:!n.some(e=>e.severity===`error`),counts:ls(n),...cs(n)}}},{name:`layer_list`,description:`Every layer top → bottom (flat, with parent and depth): id, type, detail, box, opacity, blend, mask, filters (in order — their index is what updateFilter / removeFilter use), effects.`,inputSchema:{type:`object`,properties:{}},mutating:!1,handler:async e=>({layers:_a(await Po(e.fs))})},{name:`layer_add`,description:`Add a layer (validated). Default position: top of the stack. Image layers need a src from assets_add / library_list.`,inputSchema:{type:`object`,properties:{layer:ps,...ms,dryRun:fs},required:[`layer`]},mutating:!0,handler:(e,t)=>_s(e,[{op:`addLayer`,layer:t.layer,parent:t.parent,index:ss(t,`index`),above:L(t,`above`),below:L(t,`below`)}],os(t,`dryRun`))},{name:`layer_update`,description:`Change fields of a layer (deep merge; null removes a field, e.g. { "mask": null }). Cannot change id / type / children.`,inputSchema:{type:`object`,properties:{id:{type:`string`},set:{type:`object`,additionalProperties:!0,description:`Fields to change, e.g. { "x": 40, "opacity": 0.8, "effects": { "dropShadow": { "blur": 24 } } }.`},dryRun:fs},required:[`id`,`set`]},mutating:!0,handler:(e,t)=>_s(e,[{op:`updateLayer`,id:as(t,`id`),set:t.set}],os(t,`dryRun`))},{name:`layer_remove`,description:`Remove a layer (and its children for a group). Its files stay in assets/.`,inputSchema:{type:`object`,properties:{id:{type:`string`},dryRun:fs},required:[`id`]},mutating:!0,handler:(e,t)=>_s(e,[{op:`removeLayer`,id:as(t,`id`)}],os(t,`dryRun`))},{name:`layer_move`,description:`Reorder a layer: above / below another layer, or into a group at an index.`,inputSchema:{type:`object`,properties:{id:{type:`string`},...ms,dryRun:fs},required:[`id`]},mutating:!0,handler:(e,t)=>_s(e,[{op:`moveLayer`,id:as(t,`id`),parent:t.parent,index:ss(t,`index`),above:L(t,`above`),below:L(t,`below`)}],os(t,`dryRun`))},{name:`filter_add`,description:`Add a non-destructive filter to a layer (or to an adjustment layer — which affects everything below). e.g. { id: "photo", filter: { "type": "exposure", "exposure": 0.4 } }. catalog_get section "filters" lists them.`,inputSchema:{type:`object`,properties:{id:{type:`string`,description:`Layer id.`},filter:{type:`object`,additionalProperties:!0,description:`{ type, ...params, amount? }`},index:{type:`integer`},dryRun:fs},required:[`id`,`filter`]},mutating:!0,handler:(e,t)=>_s(e,[{op:`addFilter`,id:as(t,`id`),filter:t.filter,index:ss(t,`index`)}],os(t,`dryRun`))},{name:`mask_set`,description:`Set (or remove with null) a layer mask: { "src": "assets/masks/x.png" } | { "shape": "rect|ellipse", x, y, width, height, radius? } | { "gradient": { type, angle, stops } } + invert, feather, density, enabled. Box layers: layer-local px (0,0 = the layer's top-left). For AI masks use remove_background / mask_generate.`,inputSchema:{type:`object`,properties:{id:{type:`string`},mask:{type:[`object`,`null`],additionalProperties:!0},dryRun:fs},required:[`id`]},mutating:!0,handler:(e,t)=>_s(e,[{op:`setMask`,id:as(t,`id`),mask:t.mask??null}],os(t,`dryRun`))},{name:`catalog_get`,description:`The catalog: layer types, filters (+ params), looks, layer effects, blend modes, shapes, bundled fonts, size presets, AI models. No input = an overview; { section, id } = one entry with its parameters.`,inputSchema:{type:`object`,properties:{section:{type:`string`,enum:hs},id:{type:`string`}}},mutating:!1,handler:(e,t)=>gs(L(t,`section`),L(t,`id`))},{name:`templates_list`,description:`Starter templates (social posts, thumbnails, ads, product shots…) with their size and the slot that receives the user's photo. Use with project_create { template, image }.`,inputSchema:{type:`object`,properties:{category:{type:`string`},query:{type:`string`}}},mutating:!1,handler:(e,t)=>({templates:es(e.host?.templates?.index??[],{category:L(t,`category`),query:L(t,`query`)})})},{name:`check`,description:`Everything to fix before export: validation, missing files, layers off the canvas, upscaled (blurry) photos, text that may overflow, heavy filters, licences needing attribution.`,inputSchema:{type:`object`,properties:{}},mutating:!1,async handler(e){let t=await $o(e.fs,{library:e.host?.library?.index});return{...t,...cs(t.issues)}}},{name:`assets_list`,description:`Project files (photos, masks, edits) with size, source, licence and the layers using them.`,inputSchema:{type:`object`,properties:{}},mutating:!1,handler:e=>Ga(e.fs)},{name:`assets_add`,description:`Import an image into assets/images/ from a local path (file) or an http(s) URL (url). With addLayer: true it also adds an image layer (on top, fitted inside the canvas) and returns its id.`,inputSchema:{type:`object`,properties:{file:{type:`string`,description:`Local file path (CLI / MCP hosts).`},url:{type:`string`,description:`http(s) URL of an image.`},name:{type:`string`,description:`File name to store it as.`},license:{type:`string`},author:{type:`string`},addLayer:{type:`boolean`,description:`Also add it as a layer.`},layerId:{type:`string`,description:`Id of the new layer (default from the file name).`}}},mutating:!0,async handler(e,t){let n=await vs(e,t,`assets_add`);if(!n)throw new A(`invalid`,`assets_add needs file or url.`);let r=await Wa(e.fs,{name:L(t,`name`)??n.name,bytes:n.bytes,kind:`image`,source:n.source,sourceUrl:n.sourceUrl,license:L(t,`license`),author:L(t,`author`)});if(!os(t,`addLayer`))return{asset:r,hint:`Use it as { "type": "image", "src": "${r.path}" } (layer_add).`};let i=await Po(e.fs),{uniqueId:a,slugify:o}=await wa(async()=>{let{uniqueId:e,slugify:t}=await Promise.resolve().then(()=>vi);return{uniqueId:e,slugify:t}},void 0,import.meta.url),{allLayerIds:s}=await wa(async()=>{let{allLayerIds:e}=await Promise.resolve().then(()=>ua);return{allLayerIds:e}},void 0,import.meta.url),c=a(L(t,`layerId`)??o(r.path.split(`/`).pop().replace(/\.[^.]+$/,``),`image`),s(i)),l=i.canvas.width,u=i.canvas.height,d=r.width??l,f=r.height??u,p=Math.min(1,l/d,u/f);return{asset:r,layer:c,...await _s(e,[{op:`addLayer`,layer:{id:c,type:`image`,src:r.path,x:Math.round((l-d*p)/2),y:Math.round((u-f*p)/2),width:Math.round(d*p),height:Math.round(f*p)}}],!1)}}},{name:`assets_remove`,description:`Delete a project file. Refused while a layer uses it unless force.`,inputSchema:{type:`object`,properties:{path:{type:`string`},force:{type:`boolean`}},required:[`path`]},mutating:!0,handler:(e,t)=>Ka(e.fs,as(t,`path`),{force:os(t,`force`)})},{name:`library_list`,description:`Built-in assets: sample photos (CC0, use as "library:<id>" in an image layer src) and fonts (use the id as a text layer font).`,inputSchema:{type:`object`,properties:{kind:{type:`string`,enum:[`image`,`font`]},query:{type:`string`}}},mutating:!1,handler(e,t){let n=L(t,`kind`),r=(L(t,`query`)??``).toLowerCase().split(/\s+/).filter(Boolean),i=(e.host?.library?.index.assets??[]).filter(e=>!n||e.kind===n).filter(e=>r.every(t=>`${e.id} ${e.title??``} ${e.description} ${e.tags.join(` `)}`.toLowerCase().includes(t))).map(e=>({id:e.id,kind:e.kind,ref:e.kind===`image`?`library:${e.id}`:e.id,...e.width?{size:`${e.width}×${e.height}`}:{},license:e.license,description:e.description,tags:e.tags}));return{assets:i,total:i.length}}}],xs=[`png`,`jpeg`,`webp`,`avif`],Ss={png:`png`,jpeg:`jpg`,webp:`webp`,avif:`avif`},Cs={png:100,jpeg:88,webp:86,avif:70};function ws(e,t={}){let n={...e.export??{},...Ts(t)},r=n.format??`png`;if(!xs.includes(r))throw new A(`invalid`,`Unknown export format "${String(n.format)}".`,`${Cr(String(n.format),xs)}Formats: ${xs.join(`, `)}.`);let i=Math.max(1,Math.min(100,Math.round(n.quality??Cs[r]))),a=e.canvas.width,o=e.canvas.height,s=a,c=o,l=n.fit??`cover`;if(![`cover`,`contain`,`stretch`].includes(l))throw new A(`invalid`,`Unknown fit "${String(l)}".`,`fit: cover (crop), contain (pad) or stretch.`);for(let e of[`width`,`height`,`scale`]){let t=n[e];if(t!=null&&!(typeof t==`number`&&Number.isFinite(t)&&t>0))throw new A(`invalid`,`Export ${e} must be a positive number, got ${JSON.stringify(t)}.`,e===`scale`?`e.g. scale: 2 (twice the canvas size) or 0.5.`:`${e} in px, e.g. 1080.`)}if(n.preset){let e=oi(n.preset);if(!e)throw new A(`invalid`,`Unknown size preset "${n.preset}".`,`${Cr(n.preset,Zr.map(e=>e.id))}Presets: ${Zr.map(e=>e.id).join(`, `)}.`);s=e.width,c=e.height}else n.width&&n.height?(s=n.width,c=n.height):n.width?(s=n.width,c=n.width*o/a,l=`stretch`):n.height?(c=n.height,s=n.height*a/o,l=`stretch`):n.scale&&(s=a*n.scale,c=o*n.scale,l=`stretch`);if(s=Math.max(1,Math.round(s)),c=Math.max(1,Math.round(c)),s>16384||c>16384)throw new A(`invalid`,`Export size ${s}×${c} exceeds ${Ti} px.`);let u={x:0,y:0,width:a,height:o},d={x:0,y:0,width:s,height:c};if(l===`cover`){let e=Math.max(s/a,c/o),t=s/e,n=c/e;u={x:(a-t)/2,y:(o-n)/2,width:t,height:n}}else if(l===`contain`){let e=Math.min(s/a,c/o);d={x:(s-a*e)/2,y:(c-o*e)/2,width:a*e,height:o*e}}let f=d.width/u.width,p=n.background??null;if(p!==null&&!gi(p))throw new A(`invalid`,`Export background ${JSON.stringify(p)} is not a colour.`);r!==`jpeg`||p&&hi(p)?.a!==0||(p=`#ffffff`);let m=(n.name??e.id??`photo`).replace(/[^\w.-]+/g,`-`),h=n.preset?`-${n.preset}`:n.width||n.height||n.scale?`-${s}x${c}`:``,g=n.out??`dist/${m}${h}.${Ss[r]}`;return{format:r,mime:r===`jpeg`?`image/jpeg`:`image/${r}`,quality:i,width:s,height:c,scale:f,source:u,dest:d,background:p,file:g}}function Ts(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function Es(e){let t=e.host?.engine;if(!t)throw new A(`unavailable`,`This host cannot render images.`,"Run the CLI (`agentphoto`, needs Google Chrome / Chromium) or the Studio.");return t}var Ds={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`,"image/avif":`avif`};function Os(e,t){let n=N(e.layers,t);if(!n)throw new A(`notFound`,`No layer "${t}".`,`layer_list lists the layer ids.`);return n.layer}function ks(e){let t=e=>e.filter(e=>e.type!==`adjustment`).map(e=>{let{filters:n,...r}=e;return e.type===`group`?{...r,children:t(e.children??[])}:r});return{...e,layers:t(e.layers)}}async function As(e,t,n,r,i){let a=Os(t,n),o=i.maskId??n,s=await Wa(e.fs,{name:`${o}-${i.label}.png`,bytes:r.bytes,kind:`mask`,source:i.source}),c={src:s.path,...i.invert?{invert:!0}:{},...i.feather?{feather:i.feather}:{}},l=await Qo(e.fs,[...i.preOps??[],{op:`setMask`,id:o,mask:c},...i.extraOps??[]],{readLibrary:is(e)}).catch(async t=>{throw await Ps(e.fs,s.path),t});l.applied||await Ps(e.fs,s.path);let u=a.mask&&Rr(a.mask)?a.mask.src:null;l.applied&&u&&u!==s.path&&u.startsWith(`assets/masks/`)&&(va(l.doc).some(e=>e.path===u)||await Ps(e.fs,u));let d=l.applied?N(l.doc.layers,o)?.layer??a:a;return{mask:s.path,size:`${r.width}×${r.height}`,...r.bbox===void 0?{}:{subject:Ms(d,r)},...us(l,!1)}}function js(e,t,n={}){let{x:r,y:i,width:a,height:o}=t.source;if(r<=.5&&i<=.5&&a>=e.canvas.width-1&&o>=e.canvas.height-1)return[];let s=[],c=e=>{for(let t of e){if(t.visible===!1||(t.type===`group`&&c(t.children??[]),t.type!==`text`&&t.type!==`shape`))continue;let e=n[t.id],l=t.type===`text`&&e?e.ink??e:ho(t);l&&(l.x<r-1||l.y<i-1||l.x+l.width>r+a+1||l.y+l.height>i+o+1)&&s.push(t.id)}};return c(e.layers),s}function Ms(e,t){let n=t.bbox;if(!n)return null;let r=e,i=(r.width??t.width)/t.width,a=(r.height??t.height)/t.height,o=r.flipX?t.width-n.x-n.width:n.x,s=r.flipY?t.height-n.y-n.height:n.y,c=e=>Math.round(e);return{x:c((r.x??0)+o*i),y:c((r.y??0)+s*a),width:c(n.width*i),height:c(n.height*a)}}async function Ns(e,t,n){if(n===!1||n===null)return null;if(n!==void 0){let e=n;if(!e||typeof e!=`object`||![`x`,`y`,`width`,`height`].every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))||!(e.width>=1&&e.height>=1))throw new A(`invalid`,`fit must be { x, y, width, height, anchor? } in canvas px (or false).`,`e.g. fit: { "x": 500, "y": 400, "width": 1000, "height": 850, "anchor": "bottom" }.`);let t=e.anchor??`center`;if(!fo.includes(t))throw new A(`invalid`,`Unknown anchor "${String(e.anchor)}".`,`Anchors: ${fo.join(`, `)}.`);return{box:{x:e.x,y:e.y,width:e.width,height:e.height},anchor:t,from:`input`}}if(t.mask&&Rr(t.mask))return null;let r=await Na(e.fs).catch(()=>null),i=r?.template?e.host?.templates?.index.find(e=>e.id===r.template):void 0;if(!i?.subjectArea||i.slot!==t.id)return null;let{anchor:a,...o}=i.subjectArea;return{box:o,anchor:a??`center`,from:`template ${i.id}`}}async function Ps(e,t){let{removeAsset:n}=await wa(async()=>{let{removeAsset:e}=await Promise.resolve().then(()=>La);return{removeAsset:e}},void 0,import.meta.url);await n(e,t,{force:!0}).catch(()=>void 0)}var Fs=[{name:`render_preview`,description:`Render the document and LOOK at it (the image is returned to you). Use after every visual change: check composition, crop, legibility of text, colours, mask edges. compare: true also renders the 'before' (no filters / adjustments) for retouching. layer renders one layer alone. zoom: { x, y, width, height } renders a canvas region at full resolution (inspect mask edges, skin, text).`,inputSchema:{type:`object`,properties:{maxWidth:{type:`integer`,description:`Preview width cap in px (default 1000).`},compare:{type:`boolean`,description:`Also render the unedited version (before / after).`},layer:{type:`string`,description:`Render only this layer (and the groups holding it).`},zoom:{type:`object`,description:`Canvas region { x, y, width, height } rendered at 1:1 (max 1600 px).`,additionalProperties:!0},backdrop:{type:`string`,description:`Under transparent areas: "checker" (default when the canvas is transparent or a layer is isolated), a CSS colour, or "none".`}}},mutating:!1,needsEngine:!0,async handler(e,t){let n=Es(e),r=await Po(e.fs),i=ss(t,`maxWidth`)??1e3,a=t.zoom;if(a){let{cropDoc:e}=await wa(async()=>{let{cropDoc:e}=await Promise.resolve().then(()=>uo);return{cropDoc:e}},void 0,import.meta.url);r=e(r,{x:a.x,y:a.y,width:Math.min(1600,a.width),height:Math.min(1600,a.height)})}let o=L(t,`layer`);o&&Os(r,o);let s=L(t,`backdrop`)??(o||!r.canvas.background?`checker`:`none`),c={backdrop:s===`none`?void 0:s,maxWidth:a?void 0:i,maxHeight:a?void 0:Math.max(i,1e3),only:o?[o]:void 0,format:`png`},l=await n.render(r,c),u=`renders/preview.png`;await e.fs.writeBytes(u,l.bytes);let d=[u];if(os(t,`compare`)){let t=await n.render(ks(r),c),i=`renders/preview-before.png`;await e.fs.writeBytes(i,t.bytes),d.unshift(i)}return{preview:u,images:d,size:`${l.width}×${l.height}`,canvas:`${r.canvas.width}×${r.canvas.height}`,...l.errors?.length?{errors:l.errors,hint:`Some layers failed to render (see errors): fix their src / mask.`}:{}}}},{name:`export`,description:`Render the final image(s) into dist/ (or out): format png | jpeg | webp | avif (AVIF only where the browser can encode it — otherwise PNG, with a note), quality, size (preset: ${Zr.map(e=>e.id).join(`, `)} — or width / height / scale), fit (cover crops, contain pads) and background (flatten transparency). variants: several outputs at once (e.g. og + square + story). Run check first.`,inputSchema:{type:`object`,properties:{format:{type:`string`,enum:xs},quality:{type:`integer`,minimum:1,maximum:100},preset:{type:`string`},width:{type:`integer`},height:{type:`integer`},scale:{type:`number`},fit:{type:`string`,enum:[`cover`,`contain`,`stretch`]},background:{type:[`string`,`null`]},name:{type:`string`,description:`File name without extension (default: the document id).`},out:{type:`string`,description:`Output path inside the project (default dist/<name>.<ext>).`},variants:{type:`array`,items:{type:`object`,additionalProperties:!0},description:`Several export requests (same fields) in one call.`}}},mutating:!0,needsEngine:!0,async handler(e,t){let n=Es(e),r=await Po(e.fs),i={format:L(t,`format`),quality:ss(t,`quality`),preset:L(t,`preset`),width:ss(t,`width`),height:ss(t,`height`),scale:ss(t,`scale`),fit:L(t,`fit`),background:t.background===null?null:L(t,`background`),name:L(t,`name`),out:L(t,`out`)},a=Array.isArray(t.variants)&&t.variants.length?t.variants.map(e=>({...i,out:void 0,...e})):[i],o=[],s;for(let t of a){let i=ws(r,t),a=await n.exportImage(r,i),c=i.file,l;a.mime!==i.mime&&(c=c.replace(/\.[^.]+$/,`.${Ds[a.mime]??`png`}`),l=`${i.format.toUpperCase()} encoding is not supported by this browser: written as ${a.mime}.`),await e.fs.writeBytes(c,a.bytes),(i.source.x>.5||i.source.y>.5||i.source.width<r.canvas.width-1||i.source.height<r.canvas.height-1)&&s===void 0&&(s=await n.layerBoxes?.(r).catch(()=>void 0)??{});let u=js(r,i,s);u.length&&(l=`${l?`${l} `:``}fit "cover" crops the canvas to ${Math.round(i.source.width)}×${Math.round(i.source.height)} and cuts layer${u.length>1?`s`:``} ${u.join(`, `)}: use fit "contain", or adapt the layout (doc_patch resizeCanvas / move layers) for this size.`),i.scale>1.05&&(l=`${l?`${l} `:``}Upscaled ×${Math.round(i.scale*100)/100} from the ${r.canvas.width}×${r.canvas.height} canvas: it may look soft.`),o.push({path:c,format:a.mime===`image/jpeg`?`jpeg`:Ds[a.mime]??i.format,width:a.width,height:a.height,kb:Math.round(a.bytes.byteLength/102.4)/10,...l?{note:l}:{}})}return{files:o,hint:`Done. Tell the user where the files are; offer other sizes (variants) if useful.`}}},{name:`image_analyze`,description:`Measure the picture (or one layer): brightness, contrast, tonal range, clipped shadows / highlights, colour cast, saturation, sharpness, dominant colours — with suggested filters (ready to pass to filter_add). Use before retouching.`,inputSchema:{type:`object`,properties:{layer:{type:`string`,description:`Analyse this layer's own pixels (default: the whole render).`}}},mutating:!1,needsEngine:!0,async handler(e,t){let n=await Po(e.fs),r=L(t,`layer`);return r&&Os(n,r),Es(e).analyze(n,{layer:r})}},{name:`remove_background`,description:`Remove the background of a photo layer with local AI (no upload): writes a mask PNG to assets/masks/ and sets it as the layer's mask — non-destructive (mask_set null restores). Optional background: a colour / gradient placed under the cut-out (adds a fill layer), shadow: true adds a soft drop shadow. Models: ${Qr.filter(e=>e.task===`background-removal`).map(e=>`${e.id} (${e.description})`).join(`; `)}. First use downloads the model once (25–170 MB, cached).`,inputSchema:{type:`object`,properties:{id:{type:`string`,description:`Image layer id.`},model:{type:`string`,enum:Qr.filter(e=>e.task===`background-removal`).map(e=>e.id)},feather:{type:`number`,description:`Soften the edge, px (default 0).`},threshold:{type:`integer`,description:`Hard edge: keep pixels whose confidence ≥ threshold (0..255). Default: soft alpha (best for hair).`},background:{type:[`string`,`object`],description:`Colour / gradient to put behind the subject (adds a fill layer below it).`},shadow:{type:`boolean`,description:`Add a soft drop shadow under the subject.`},fit:{type:[`object`,`boolean`],description:`Scale and move the layer so the cut-out subject fits this canvas box: { x, y, width, height, anchor? } (anchor: center (default), bottom = standing on a floor line, top, left…). false leaves the layer where it is. Default: a template's subject area on its photo slot (first cut-out after a photo swap), otherwise nothing moves.`,additionalProperties:!0}},required:[`id`]},mutating:!0,needsEngine:!0,async handler(e,t){let n=as(t,`id`),r=await Po(e.fs),i=Os(r,n);if(i.type!==`image`)throw new A(`invalid`,`"${n}" is a ${i.type} layer: background removal works on image layers.`);let a=await Ns(e,i,t.fit),o=L(t,`model`)??$r[`background-removal`],s=await Es(e).backgroundMask(r,n,{model:o,feather:ss(t,`feather`),threshold:ss(t,`threshold`)}),c=[],l=Ms(i,s);if(a&&l&&c.push({op:`fitLayer`,id:n,box:a.box,subject:l,anchor:a.anchor}),t.background!==void 0&&t.background!==null){let e=Si(`${n}-background`,da(r));c.push({op:`addLayer`,layer:{id:e,type:`fill`,name:`Background`,fill:t.background},below:n})}os(t,`shadow`)&&c.push({op:`updateLayer`,id:n,set:{effects:{dropShadow:{color:`#000000`,opacity:.35,angle:90,distance:18,blur:30}}}});let u=await As(e,r,n,s,{label:`cutout`,extraOps:c,source:`remove_background:${o}`}),d=a&&l&&u.applied===!0?{box:a.box,anchor:a.anchor,from:a.from}:void 0,f=d?`The layer was scaled and moved so the subject fits ${JSON.stringify(d.box)} (anchor ${d.anchor}, from the ${d.from}); fit: false keeps the layer where it was.`:`To recentre / rescale it: doc_patch [{ "op": "fitLayer", "id": "${n}", "subject": <subject>, "box": { "x", "y", "width", "height" }, "anchor": "center" | "bottom" }] (or remove_background again with fit).`;return{...u,model:o,...d?{fitted:d}:{},hint:`subject = the kept area in canvas px (null: nothing found). ${f} Then render_preview (zoom on an edge: hair, fingers) to check; refine with mask_generate (points) or threshold / feather.`}}},{name:`mask_generate`,description:`Make a mask for a layer from pixels, with local AI or colours, and set it as the layer mask: method "subject" (main subject, background-removal model), "points" (Segment Anything: points [[x, y, 1 = include | 0 = exclude], …] in layer px), "box" (SAM: [x1, y1, x2, y2] layer px), "color" (colour range: color + tolerance 0..100). invert: true keeps the rest instead (e.g. select the sky, then invert to protect it; or mask a filter / adjustment). target: "mask" (default) sets it on the layer itself; "copy" duplicates the layer, masks the copy (cut-out on its own layer, the original stays).`,inputSchema:{type:`object`,properties:{id:{type:`string`,description:`Layer id (layer px = relative to the layer's top-left, before rotation).`},method:{type:`string`,enum:[`subject`,`points`,`box`,`color`]},points:{type:`array`,items:{type:`array`,items:{type:`number`}}},box:{type:`array`,items:{type:`number`},minItems:4,maxItems:4},color:{type:`string`},tolerance:{type:`number`,minimum:0,maximum:100},invert:{type:`boolean`},feather:{type:`number`},model:{type:`string`},target:{type:`string`,enum:[`mask`,`copy`]},copyId:{type:`string`,description:`Id of the copy (target "copy").`}},required:[`id`,`method`]},mutating:!0,needsEngine:!0,async handler(e,t){let n=as(t,`id`),r=as(t,`method`),i=await Po(e.fs);Os(i,n);let a=Es(e),o=ss(t,`feather`),s;if(r===`subject`)s=await a.backgroundMask(i,n,{model:L(t,`model`),feather:o});else if(r===`points`||r===`box`){let e=r===`points`?t.points:void 0;if(r===`points`&&(!Array.isArray(e)||!e.length))throw new A(`invalid`,`method "points" needs points: [[x, y, 1], …] (layer px; 1 = include, 0 = exclude).`);let c=r===`box`?t.box:void 0;if(r===`box`&&(!Array.isArray(c)||c.length!==4))throw new A(`invalid`,`method "box" needs box: [x1, y1, x2, y2] (layer px).`);s=await a.segmentMask(i,n,{...e?{points:e.map(e=>[e[0],e[1],e[2]??1])}:{},...c?{box:c}:{}},{model:L(t,`model`),feather:o})}else if(r===`color`)s=await a.colorRangeMask(i,n,{color:as(t,`color`),tolerance:ss(t,`tolerance`),feather:o});else throw new A(`invalid`,`Unknown method "${r}".`,`Methods: subject, points, box, color.`);let c=L(t,`target`)??`mask`,l=os(t,`invert`);if(c===`copy`){let a=Si(L(t,`copyId`)??`${n}-cutout`,da(i));return{...await As(e,i,n,s,{label:r,invert:l,source:`mask_generate:${r}`,preOps:[{op:`duplicateLayer`,id:n,newId:a}],maskId:a}),layer:a}}return As(e,i,n,s,{label:r,invert:l,source:`mask_generate:${r}`})}}],Is=`project_info.project_create.doc_summary.doc_get.doc_patch.doc_apply.doc_validate.layer_list.layer_add.layer_update.layer_remove.layer_move.filter_add.mask_set.remove_background.mask_generate.image_analyze.render_preview.catalog_get.templates_list.library_list.assets_list.assets_add.assets_remove.check.export`.split(`.`),Ls=new Map([...bs,...Fs].map(e=>[e.name,e])),Rs=Is.map(e=>{let t=Ls.get(e);if(!t)throw Error(`AI tool ${e} is not implemented`);return t});function zs(e,t={}){let n=Rs.filter(t=>!t.needsEngine||e?.engine);return t.readOnly?n.filter(e=>!e.mutating):n}function Bs(e,t){let n=zs(t),r=n.find(t=>t.name===e);if(!r){if(Ls.get(e)?.needsEngine)throw new A(`unavailable`,`Tool "${e}" needs an image engine this host does not have.`,`Use the CLI (needs Google Chrome / Chromium) or the Studio.`);let t=Sr(e,n.map(e=>e.name));throw new A(`notFound`,`Unknown tool "${e}".`,`${t?`Did you mean "${t}"? `:``}Tools: ${n.map(e=>e.name).join(`, `)}.`)}return r}async function Vs(e,t,n){let r=Bs(t,e.host);return r.handler(e,ds(r.inputSchema,n,t))}function Hs(e,t){if(e!==`render_preview`||!t||typeof t!=`object`)return[];let n=t;return n.images?.length?n.images:n.preview?[n.preview]:[]}var Us=null,Ws=new Map,Gs={};function Ks(e){Gs={...Gs,...e}}async function qs(){return Us||(Us=wa(()=>import(`./transformers.web-osEqoMhg.js`).then(e=>(e.env.allowLocalModels=!1,Gs.remoteHost&&(e.env.remoteHost=Gs.remoteHost),Gs.remotePathTemplate&&(e.env.remotePathTemplate=Gs.remotePathTemplate),Gs.wasmPaths&&e.env.backends?.onnx?.wasm&&(e.env.backends.onnx.wasm.wasmPaths=Gs.wasmPaths),e.env.backends?.onnx?.wasm&&typeof crossOriginIsolated<`u`&&!crossOriginIsolated&&(e.env.backends.onnx.wasm.numThreads=1),e)),[],import.meta.url),Us.catch(()=>Us=null)),Us}function Js(e){let t=new Map;return n=>{if(!n?.file)return;n.status===`progress`&&typeof n.progress==`number`?t.set(n.file,n.progress):n.status===`done`?t.set(n.file,100):n.status===`initiate`&&!t.has(n.file)&&t.set(n.file,0);let r=[...t.values()],i=r.length?r.reduce((e,t)=>e+t,0)/r.length:0;Gs.onProgress?.({model:e,progress:i/100,label:`Loading ${e} (${Math.round(i)} %)`})}}async function Ys(e){let t=si(e);if(!t)throw Error(`Unknown model "${e}". Models: ${Qr.map(e=>e.id).join(`, `)}.`);let n=await qs(),r=Ws.get(e);if(!r){let i=Js(e);r=(async()=>{if(Gs.onProgress?.({model:e,progress:0,label:`Loading ${e}`}),t.task===`segmentation`){let[e,r]=await Promise.all([n.SamModel.from_pretrained(t.repo,{progress_callback:i,dtype:`fp32`}),n.AutoProcessor.from_pretrained(t.repo,{progress_callback:i})]);return{model:e,processor:r}}let r=t.id===`rmbg-1.4`,[a,o]=await Promise.all([n.AutoModel.from_pretrained(t.repo,{progress_callback:i,dtype:`fp32`,...r?{config:{model_type:`custom`}}:{}}),n.AutoProcessor.from_pretrained(t.repo,{progress_callback:i,...r?{config:{do_normalize:!0,do_pad:!1,do_rescale:!0,do_resize:!0,image_mean:[.5,.5,.5],image_std:[1,1,1],resample:2,rescale_factor:1/255,size:{width:1024,height:1024}}}:{}})]);return{model:a,processor:o}})(),r.catch(()=>Ws.delete(e)),Ws.set(e,r)}let i=await r;return Gs.onProgress?.({model:e,progress:1,label:`${e} ready`}),{...i,tf:n}}async function Xs(e,t=$r[`background-removal`]){if(si(t)?.task!==`background-removal`)throw Error(`"${t}" is not a background-removal model.`);let{model:n,processor:r,tf:i}=await Ys(t),{pixel_values:a}=await r(i.RawImage.fromCanvas(e)),o=await n({input:a}),s=o.output??o.alphas??Object.values(o)[0],c=s[0]??s,l=await i.RawImage.fromTensor(c.mul(255).to(`uint8`)).resize(e.width,e.height),u=l.data,d=l.channels??1,f=new Uint8ClampedArray(e.width*e.height);for(let e=0;e<f.length;e++)f[e]=u[e*d];return f}async function Zs(e,t,n=$r.segmentation){if(si(n)?.task!==`segmentation`)throw Error(`"${n}" is not a segmentation model.`);let{model:r,processor:i,tf:a}=await Ys(n),o=e.width,s=e.height,c=a.RawImage.fromCanvas(e),l=(t.points??[]).map(e=>[Math.max(0,Math.min(o-1,e[0])),Math.max(0,Math.min(s-1,e[1]))]),u=(t.points??[]).map(e=>+!!e[2]),d=t.box?[Math.max(0,t.box[0]),Math.max(0,t.box[1]),Math.min(o,t.box[2]),Math.min(s,t.box[3])]:null;l.length||(l=[d?[(d[0]+d[2])/2,(d[1]+d[3])/2]:[o/2,s/2]],u=[1]);let f=await i(c,{input_points:[[l]],input_labels:[[u]],...d?{input_boxes:[[d]]}:{}}),p=await r(f),m=await i.post_process_masks(p.pred_masks,f.original_sizes,f.reshaped_input_sizes),h=Array.isArray(m)?m[0]:m,g=p.iou_scores?.data??[1],_=0;for(let e=1;e<g.length;e++)g[e]>g[_]&&(_=e);let v=h.dims,y=v.length>=3?v[v.length-3]:1,b=v[v.length-2],x=v[v.length-1],S=Math.min(_,y-1),ee=h.data,te=new Uint8ClampedArray(o*s),C=S*b*x;for(let e=0;e<s;e++){let t=Math.min(b-1,Math.floor(e*b/s));for(let n=0;n<o;n++){let r=Math.min(x-1,Math.floor(n*x/o));te[e*o+n]=ee[C+t*x+r]?255:0}}return te}var R=e=>e<0?0:e>255?255:e,Qs=e=>e<0?0:e>1?1:e;function $s(e){return{data:new Uint8ClampedArray(e.data),width:e.width,height:e.height}}function ec(e,t,n=t,r=t){let i=e.data;for(let e=0;e<i.length;e+=4)i[e]=t[i[e]],i[e+1]=n[i[e+1]],i[e+2]=r[i[e+2]]}function tc(e){let t=new Uint8ClampedArray(256);for(let n=0;n<256;n++)t[n]=Math.round(R(e(n)));return t}var nc=(e,t,n)=>.299*e+.587*t+.114*n,rc=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,ic=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;function ac(e,t,n,r,i){if(r<1)return;let a=1/(r+r+1);for(let o=0;o<n;o++){let n=o*t,s=e[n],c=e[n+t-1],l=r*s;for(let i=0;i<r;i++)l+=e[n+Math.min(i,t-1)];for(let o=0;o<t;o++){let u=e[n+Math.min(o+r,t-1)]??c;l+=u,i[n+o]=l*a;let d=o-r>=0?e[n+o-r]:s;l-=d}}for(let o=0;o<t;o++){let s=i[o],c=r*s;for(let e=0;e<r;e++)c+=i[Math.min(e,n-1)*t+o];for(let l=0;l<n;l++)c+=i[Math.min(l+r,n-1)*t+o],e[l*t+o]=c*a,c-=l-r>=0?i[(l-r)*t+o]:s}}function oc(e,t=3){let n=Math.sqrt(12*e*e/t+1),r=Math.floor(n);r%2==0&&r--;let i=r+2,a=(12*e*e-t*r*r-4*t*r-3*t)/(-4*r-4),o=Math.round(a);return Array.from({length:t},(e,t)=>Math.max(0,((t<o?r:i)-1)/2))}function sc(e,t,n,r){if(r<.5)return;let i=new Float32Array(e.length);for(let a of oc(r/2))ac(e,t,n,Math.round(a),i)}function cc(e,t){if(t<.5)return;let{data:n,width:r,height:i}=e,a=r*i,o=new Float32Array(a),s=new Float32Array(a),c=new Float32Array(a),l=new Float32Array(a),u=!0;for(let e=0,t=0;t<a;e+=4,t++){let r=n[e+3]/255;r<1&&(u=!1),o[t]=n[e]*r,s[t]=n[e+1]*r,c[t]=n[e+2]*r,l[t]=r}sc(o,r,i,t),sc(s,r,i,t),sc(c,r,i,t),u||sc(l,r,i,t);for(let e=0,t=0;t<a;e+=4,t++){let r=l[t];r<=1e-6?n[e+3]=0:(n[e]=o[t]/r,n[e+1]=s[t]/r,n[e+2]=c[t]/r,n[e+3]=r*255)}}function lc(e,t){let{data:n,width:r,height:i}=e,a=new Float32Array(r*i);for(let e=0,t=0;t<a.length;e+=4,t++)a[t]=nc(n[e],n[e+1],n[e+2])/255;return sc(a,r,i,t),a}function uc(e,t,n,r){if(r<.5)return;let i=new Float32Array(e.length);for(let t=0;t<i.length;t++)i[t]=e[t];sc(i,t,n,r);for(let t=0;t<i.length;t++)e[t]=i[t]}function dc(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function fc(e,t,n){e/=255,t/=255,n/=255;let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2;if(r===i)return[0,0,a];let o=r-i,s=a>.5?o/(2-r-i):o/(r+i),c;return c=r===e?(t-n)/o+(t<n?6:0):r===t?(n-e)/o+2:(e-t)/o+4,[c*60,s,a]}function pc(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function mc(e,t,n){if(e=(e%360+360)%360/360,t===0)return[n*255,n*255,n*255];let r=n<.5?n*(1+t):n+t-n*t,i=2*n-r;return[pc(i,r,e+1/3)*255,pc(i,r,e)*255,pc(i,r,e-1/3)*255]}function hc(e){let t=[...e].sort((e,t)=>e[0]-t[0]),n=t.length,r=new Uint8ClampedArray(256);if(n===0)return tc(e=>e);if(n===1)return tc(()=>t[0][1]);let i=t.map(e=>e[0]),a=t.map(e=>e[1]),o=[],s=[];for(let e=0;e<n-1;e++)o.push(i[e+1]-i[e]),s.push((a[e+1]-a[e])/(i[e+1]-i[e]||1));let c=[s[0]];for(let e=1;e<n-1;e++)c.push(s[e-1]*s[e]<=0?0:(s[e-1]+s[e])/2);c.push(s[n-2]);for(let e=0;e<n-1;e++){if(s[e]===0){c[e]=0,c[e+1]=0;continue}let t=c[e]/s[e],n=c[e+1]/s[e],r=t*t+n*n;if(r>9){let i=3/Math.sqrt(r);c[e]=i*t*s[e],c[e+1]=i*n*s[e]}}for(let e=0;e<256;e++){if(e<=i[0]){r[e]=a[0];continue}if(e>=i[n-1]){r[e]=a[n-1];continue}let t=0;for(;t<n-2&&e>i[t+1];)t++;let s=o[t],l=(e-i[t])/s,u=2*l**3-3*l**2+1,d=l**3-2*l**2+l,f=-2*l**3+3*l**2,p=l**3-l**2;r[e]=R(Math.round(u*a[t]+d*s*c[t]+f*a[t+1]+p*s*c[t+1]))}return r}function gc(e){let t=new Uint32Array(256),n=new Uint32Array(256),r=new Uint32Array(256),i=new Uint32Array(256),a=e.data,o=0;for(let e=0;e<a.length;e+=4)a[e+3]<8||(t[a[e]]++,n[a[e+1]]++,r[a[e+2]]++,i[Math.round(nc(a[e],a[e+1],a[e+2]))]++,o++);return{r:t,g:n,b:r,l:i,count:o}}function _c(e,t,n){let r=t*n/100,i=0,a=0;for(;i<255&&a+e[i]<=r;)a+=e[i++];let o=255;for(a=0;o>0&&a+e[o]<=r;)a+=e[o--];return o<=i?[0,255]:[i,o]}var vc=(e,t)=>tc(n=>(n-e)*255/Math.max(1,t-e));function yc(e){let{data:t,width:n,height:r}=e,i=gc(e),a=Math.max(1,i.count),o=0,s=0,c=0,l=0,u=0,d=0;for(let e=0;e<t.length;e+=4){if(t[e+3]<250&&d++,t[e+3]<8)continue;let n=t[e],r=t[e+1],i=t[e+2],a=nc(n,r,i);o+=a,s+=a*a;let f=Math.max(n,r,i);c+=f?(f-Math.min(n,r,i))/f:0,l+=n-i,u+=(n+i)/2-r}let f=o/a,p=Math.sqrt(Math.max(0,s/a-f*f)),[m,h]=_c(i.l,a,1),g=0,_=0;for(let e=0;e<=2;e++)g+=i.l[e];for(let e=253;e<=255;e++)_+=i.l[e];let v=0,y=0,b=Math.max(1,Math.floor(Math.sqrt(n*r/25e4)));for(let e=b;e<r-b;e+=b)for(let r=b;r<n-b;r+=b){let i=(e,r)=>{let i=(r*n+e)*4;return nc(t[i],t[i+1],t[i+2])},a=4*i(r,e)-i(r-1,e)-i(r+1,e)-i(r,e-1)-i(r,e+1);v+=a*a,y++}let x={width:n,height:r,transparent:bc(d/(n*r)*100),brightness:bc(f),contrast:bc(p),range:[m,h],clippedShadows:bc(g/a*100),clippedHighlights:bc(_/a*100),saturation:bc(c/a*100),cast:{warm:bc(l/a),magenta:bc(u/a)},sharpness:bc(y?v/y:0),dominant:xc(e,5),suggestions:[]};return x.suggestions=Sc(x),x}var bc=e=>Math.round(e*10)/10;function xc(e,t){let n=e.data,r=new Map,i=Math.max(1,Math.floor(e.width*e.height/12e4))*4,a=0;for(let e=0;e<n.length;e+=i){if(n[e+3]<128)continue;let t=n[e]>>4<<8|n[e+1]>>4<<4|n[e+2]>>4,i=r.get(t)??{r:0,g:0,b:0,n:0};i.r+=n[e],i.g+=n[e+1],i.b+=n[e+2],i.n++,r.set(t,i),a++}let o=[...r.values()].sort((e,t)=>t.n-e.n),s=[];for(let e of o){let n={r:e.r/e.n,g:e.g/e.n,b:e.b/e.n,n:e.n},r=s.find(e=>Math.abs(e.r-n.r)+Math.abs(e.g-n.g)+Math.abs(e.b-n.b)<60);r?r.n+=n.n:s.length<t&&s.push(n)}return s.sort((e,t)=>t.n-e.n).map(e=>({color:_i({r:e.r,g:e.g,b:e.b,a:1}),share:bc(e.n/Math.max(1,a)*100)}))}function Sc(e){let t=[];return e.brightness<85?t.push({issue:`Underexposed (mean brightness ${e.brightness}/255).`,filter:{type:`exposure`,exposure:bc(Math.min(1.5,(110-e.brightness)/45))}}):e.brightness>185&&t.push({issue:`Overexposed (mean brightness ${e.brightness}/255).`,filter:{type:`exposure`,exposure:bc(-Math.min(1.2,(e.brightness-160)/50))}}),e.range[0]>25||e.range[1]<230?t.push({issue:`Flat / hazy: tones only span ${e.range[0]}–${e.range[1]}.`,filter:{type:`autoContrast`}}):e.contrast<40&&t.push({issue:`Low contrast (std-dev ${e.contrast}).`,filter:{type:`curves`,rgb:[[0,0],[64,52],[192,206],[255,255]]}}),e.clippedShadows>8&&t.push({issue:`${e.clippedShadows} % of the picture is crushed black.`,filter:{type:`shadowsHighlights`,shadows:40}}),e.clippedHighlights>8&&t.push({issue:`${e.clippedHighlights} % of the picture is blown out.`,filter:{type:`shadowsHighlights`,shadows:0,highlights:40}}),Math.abs(e.cast.warm)>18&&t.push({issue:`${e.cast.warm>0?`Warm / orange`:`Cool / blue`} colour cast.`,filter:{type:`temperature`,temperature:bc(Math.max(-60,Math.min(60,-e.cast.warm*.8)))}}),Math.abs(e.cast.magenta)>12&&t.push({issue:`${e.cast.magenta>0?`Magenta`:`Green`} tint.`,filter:{type:`temperature`,tint:bc(Math.max(-60,Math.min(60,-e.cast.magenta*1.2)))}}),e.saturation<18&&e.contrast>10&&t.push({issue:`Muted colours (saturation ${e.saturation}).`,filter:{type:`vibrance`,vibrance:35}}),e.sharpness<60&&t.push({issue:`Soft image (sharpness ${e.sharpness}).`,filter:{type:`sharpen`,amount:90,radius:1.2}}),t}var Cc=16384;function wc(e,t){let n=Math.max(1,Math.min(Cc,Math.ceil(e))),r=Math.max(1,Math.min(Cc,Math.ceil(t)));if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(n,r);let i=document.createElement(`canvas`);return i.width=n,i.height=r,i}function z(e,t){let n=e.getContext(`2d`,{willReadFrequently:!1,...t});if(!n)throw Error(`Canvas 2D is not available.`);return n.imageSmoothingEnabled=!0,n.imageSmoothingQuality=`high`,n}function Tc(e){let t=z(e).getImageData(0,0,e.width,e.height);return{data:t.data,width:t.width,height:t.height}}function Ec(e,t){z(e).putImageData(new ImageData(t.data,t.width,t.height),0,0)}function Dc(e){return!e||e===`normal`?`source-over`:e}function Oc(e,t){let n=wc(e.width,e.height),r=z(n);return r.drawImage(e,0,0),r.globalCompositeOperation=`source-in`,r.fillStyle=t,r.fillRect(0,0,n.width,n.height),n}function kc(e){let t=Tc(e).data,n=new Uint8ClampedArray(t.length/4);for(let e=0,r=3;e<n.length;e++,r+=4)n[e]=t[r];return n}function Ac(e,t,n,r=[255,255,255]){let i=wc(t,n),a=new Uint8ClampedArray(t*n*4);for(let t=0,n=0;t<e.length;t++,n+=4)a[n]=r[0],a[n+1]=r[1],a[n+2]=r[2],a[n+3]=e[t];return Ec(i,{data:a,width:t,height:n}),i}async function jc(e,t,n){let r=n===void 0?void 0:Math.max(.01,Math.min(1,n));return`convertToBlob`in e?e.convertToBlob({type:t,quality:r}):new Promise((n,i)=>e.toBlob(e=>e?n(e):i(Error(`Encoding failed.`)),t,r))}var Mc=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t;function Nc(e,t){if(!e)return 0;let n=0;return e.dropShadow&&(n=Math.max(n,(Mc(e.dropShadow.distance,12)+Mc(e.dropShadow.blur,16)*1.5+Mc(e.dropShadow.spread,0))*t)),e.outerGlow&&(n=Math.max(n,(Mc(e.outerGlow.blur,20)*1.5+Mc(e.outerGlow.spread,0))*t)),e.stroke&&(e.stroke.position??`outside`)!==`inside`&&(n=Math.max(n,Mc(e.stroke.width,6)*t)),Math.ceil(n)+(n?2:0)}var Pc=e=>!!e&&Object.values(e).some(Boolean);function Fc(e,t){let n=wc(e.width,e.height),r=z(n);if(r.drawImage(e,0,0),t<.5)return n;let i=Math.min(8,Math.max(1,Math.ceil(t/3)));for(let n=1;n<=i;n++){let a=t*n/i,o=Math.min(48,Math.max(8,Math.ceil(a*1.5)));for(let t=0;t<o;t++){let n=t/o*Math.PI*2;r.drawImage(e,Math.cos(n)*a,Math.sin(n)*a)}}return n}function Ic(e,t=96){let n=kc(e);for(let e=0;e<n.length;e++)n[e]=n[e]>=t?255:n[e]*255/t;return Ac(n,e.width,e.height)}function Lc(e){let t=wc(e.width,e.height),n=z(t);return n.fillStyle=`#000`,n.fillRect(0,0,t.width,t.height),n.globalCompositeOperation=`destination-out`,n.drawImage(e,0,0),t}function Rc(e,t,n){if(t<.5)return Oc(e,n);let r=kc(e);return uc(r,e.width,e.height,t),Oc(Ac(r,e.width,e.height),n)}function zc(e,t,n){let r=e.canvas,i=r.width,a=r.height,o=wc(i,a),s=z(o);if(t.dropShadow){let e=t.dropShadow,i=Mc(e.spread,0)*n,a=Rc(i?Fc(r,i):r,Mc(e.blur,16)*n,e.color??`#000000`),o=Mc(e.angle,135)*Math.PI/180,c=Mc(e.distance,12)*n;s.globalAlpha=Mc(e.opacity,.5),s.drawImage(a,-Math.cos(o)*c,Math.sin(o)*c),s.globalAlpha=1}if(t.outerGlow){let e=t.outerGlow,i=Mc(e.spread,0)*n,a=Rc(i?Fc(r,i):r,Mc(e.blur,20)*n,e.color??`#ffffff`);s.globalAlpha=Mc(e.opacity,.6),s.drawImage(a,0,0),s.globalAlpha=Mc(e.opacity,.6)*.5,s.drawImage(a,0,0),s.globalAlpha=1}let c=t.stroke,l=c?Mc(c.width,6)*n:0,u=c?.position??`outside`;if(c&&l>0&&u!==`inside`){let e=u===`center`?l/2:l;s.globalAlpha=Mc(c.opacity,1),s.drawImage(Oc(Fc(Ic(r),e),c.color??`#ffffff`),0,0),s.globalAlpha=1}let d=wc(i,a),f=z(d);if(f.drawImage(r,0,0),t.colorOverlay){let e=t.colorOverlay,n=Oc(r,e.color??`#ffffff`);f.globalAlpha=Mc(e.opacity,1),f.globalCompositeOperation=Dc(e.blend),f.drawImage(n,0,0),f.globalAlpha=1,f.globalCompositeOperation=`destination-in`,f.drawImage(r,0,0),f.globalCompositeOperation=`source-over`}if(t.innerShadow){let e=t.innerShadow,o=Rc(Lc(r),Mc(e.blur,10)*n,e.color??`#000000`),s=Mc(e.angle,135)*Math.PI/180,c=Mc(e.distance,6)*n,l=wc(i,a),u=z(l);u.drawImage(o,-Math.cos(s)*c,Math.sin(s)*c),u.globalCompositeOperation=`destination-in`,u.drawImage(r,0,0),f.globalAlpha=Mc(e.opacity,.5),f.drawImage(l,0,0),f.globalAlpha=1}if(c&&l>0&&u!==`outside`){let e=u===`center`?l/2:l,t=Lc(Fc(Lc(r),e)),n=Oc(r,c.color??`#ffffff`),i=z(n);i.globalCompositeOperation=`destination-out`,i.drawImage(t,0,0),f.globalAlpha=Mc(c.opacity,1),f.drawImage(n,0,0),f.globalAlpha=1}return s.drawImage(d,0,0),{canvas:o,x:e.x,y:e.y}}function Bc(e,t,n,r,i=1,a=1,o=1){for(let s=0;s<e.length;s+=4)e[s]=R((e[s]+t)*i),e[s+1]=R((e[s+1]+n)*a),e[s+2]=R((e[s+2]+r)*o)}function Vc(e,t){for(let n=0;n<e.length;n+=4)e[n]=R((e[n]-128)*t+128),e[n+1]=R((e[n+1]-128)*t+128),e[n+2]=R((e[n+2]-128)*t+128)}function Hc(e,t){for(let n=0;n<e.length;n+=4){let r=nc(e[n],e[n+1],e[n+2]);e[n]=R(r+(e[n]-r)*t),e[n+1]=R(r+(e[n+1]-r)*t),e[n+2]=R(r+(e[n+2]-r)*t)}}function Uc(e,t,n,r){let i=e=>{let t=new Uint8ClampedArray(256);for(let n=0;n<256;n++)t[n]=255*(n/255)**(1/e);return t},[a,o,s]=[i(t),i(n),i(r)];for(let t=0;t<e.length;t+=4)e[t]=a[e[t]],e[t+1]=o[e[t+1]],e[t+2]=s[e[t+2]]}function Wc(e,t){let{data:n,width:r,height:i}=e,a=r/2,o=i/2,s=Math.hypot(a,o)||1;for(let e=0;e<i;e++)for(let i=0;i<r;i++){let c=Math.hypot(i-a,e-o)/s,l=1-t*c*c,u=(e*r+i)*4;n[u]*=l,n[u+1]*=l,n[u+2]*=l}}function Gc(e,t,n){for(let r=0;r<e.length;r+=4)e[r]=t+e[r]*n,e[r+1]=t+e[r+1]*n,e[r+2]=t+e[r+2]*n}function Kc(e,t,n){for(let r=0;r<e.length;r+=4){let i=nc(e[r],e[r+1],e[r+2])/255,a=1-i;e[r]=R(e[r]+n[0]*i+t[0]*a),e[r+1]=R(e[r+1]+n[1]*i+t[1]*a),e[r+2]=R(e[r+2]+n[2]*i+t[2]*a)}}var qc={bw:e=>Hc(e.data,0),noir:e=>{Hc(e.data,0),Vc(e.data,1.55),Uc(e.data,.85,.85,.85),Wc(e,.45)},sepia:e=>{let t=e.data;for(let e=0;e<t.length;e+=4){let n=t[e],r=t[e+1],i=t[e+2];t[e]=R(n*.393+r*.769+i*.189),t[e+1]=R(n*.349+r*.686+i*.168),t[e+2]=R(n*.272+r*.534+i*.131)}},vintage:e=>{Bc(e.data,8,-6,-16,1,1,.92),Hc(e.data,.7),Vc(e.data,.92),Uc(e.data,1.05,1,.9),Wc(e,.35)},polaroid:e=>{Bc(e.data,12,4,-8),Hc(e.data,.85),Vc(e.data,.95)},lomo:e=>{Hc(e.data,1.45),Vc(e.data,1.25),Wc(e,.55)},warm:e=>{Bc(e.data,18,6,-14),Hc(e.data,1.1)},cool:e=>{Bc(e.data,-10,0,16),Hc(e.data,.95)},sunset:e=>{Bc(e.data,28,-4,-24,1,1,.95),Hc(e.data,1.2)},fade:e=>{let t=e.data;for(let e=0;e<t.length;e+=4)t[e]=40+t[e]*.78,t[e+1]=40+t[e+1]*.78,t[e+2]=50+t[e+2]*.74;Hc(t,.85)},punch:e=>{Hc(e.data,1.4),Vc(e.data,1.2)},cinema:e=>{Kc(e.data,[-6,2,14],[20,6,-14]),Vc(e.data,1.1)},cyberpunk:e=>{let t=e.data;for(let e=0;e<t.length;e+=4)t[e]=R(t[e]*1.05+18),t[e+1]=R(t[e+1]*.85),t[e+2]=R(t[e+2]*1.1+22);Vc(t,1.25),Hc(t,1.5)},"cross-process":e=>{let t=e.data;for(let e=0;e<t.length;e+=4)t[e]=R(t[e]*1.1),t[e+1]=R(t[e+1]+(255-t[e+1])*.15),t[e+2]=R(t[e+2]*.85);Vc(t,1.18),Hc(t,1.15)},dramatic:e=>{Vc(e.data,1.5),Uc(e.data,.85,.85,.85),Hc(e.data,.6),Wc(e,.4)},dreamy:e=>{Bc(e.data,14,8,16),Hc(e.data,.85),Vc(e.data,.88),Uc(e.data,1.1,1.05,1.1)},matte:e=>{Gc(e.data,28,.86),Hc(e.data,.82),Kc(e.data,[0,4,8],[6,2,-4])},"golden-hour":e=>{Kc(e.data,[6,-2,-10],[26,12,-20]),Hc(e.data,1.12),Uc(e.data,1.06,1.02,.96)},film:e=>{Gc(e.data,14,.92),Vc(e.data,1.06),Kc(e.data,[-4,2,8],[10,4,-6]),Hc(e.data,.92);let t=dc(7),n=e.data;for(let e=0;e<n.length;e+=4){let r=(t()-.5)*14;n[e]=R(n[e]+r),n[e+1]=R(n[e+1]+r),n[e+2]=R(n[e+2]+r)}},clean:e=>{Uc(e.data,1.08,1.08,1.1),Bc(e.data,-2,0,4),Vc(e.data,1.06),Hc(e.data,1.05)}},B=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,Jc=(e,t)=>typeof e==`boolean`?e:t,Yc=e=>Array.isArray(e)&&e.length===3?[B(e[0],0),B(e[1],0),B(e[2],0)]:[0,0,0],Xc=(e,t)=>hi(typeof e==`string`?e:t)??hi(t);function Zc(e){let t=(Array.isArray(e)&&e.length>=2?e:[`#000`,`#fff`]).map((e,t,n)=>Array.isArray(e)?[B(e[0],t/(n.length-1)),Xc(e[1],`#000`)]:[t/(n.length-1),Xc(e,`#000`)]);t.sort((e,t)=>e[0]-t[0]);let n=new Uint8ClampedArray(256),r=new Uint8ClampedArray(256),i=new Uint8ClampedArray(256);for(let e=0;e<256;e++){let a=e/255,o=0;for(;o<t.length-2&&a>t[o+1][0];)o++;let[s,c]=t[o],[l,u]=t[o+1],d=l>s?Qs((a-s)/(l-s)):+(a>=l);n[e]=c.r+(u.r-c.r)*d,r[e]=c.g+(u.g-c.g)*d,i[e]=c.b+(u.b-c.b)*d}return[n,r,i]}function Qc(e,t,n){let r=n-nc(e[t],e[t+1],e[t+2]);e[t]=R(e[t]+r),e[t+1]=R(e[t+1]+r),e[t+2]=R(e[t+2]+r)}var $c={brightnessContrast(e,t){let n=B(t.brightness,0)/100,r=B(t.contrast,0)/100,i=n>=0?1/(1+n*1.2):1-n*1.2,a=r>=0?1/(1-r*.85):1+r*.85;ec(e,tc(e=>(255*(e/255)**i-128)*a+128))},exposure(e,t){let n=2**B(t.exposure,0),r=B(t.offset,0),i=B(t.gamma,1);ec(e,tc(e=>255*ic(Qs(Math.max(0,rc(e/255)*n+r)**(1/i)))))},shadowsHighlights(e,t,n){let r=B(t.shadows,35)/100,i=B(t.highlights,0)/100;if(!r&&!i)return;let a=lc(e,Math.max(1,B(t.radius,30)*n.scale)),o=e.data;for(let e=0,t=0;t<a.length;e+=4,t++){let n=a[t],s=(1-n)**2,c=n**2;for(let t=0;t<3;t++){let n=o[e+t]/255;n+=r*s*(1-n)*n*2.2,n-=i*c*n*(1-n)*2.2,o[e+t]=n*255}}},levels(e,t){let n=B(t.black,0),r=Math.max(n+1,B(t.white,255)),i=B(t.gamma,1),a=B(t.outBlack,0),o=B(t.outWhite,255);ec(e,tc(e=>a+(o-a)*Qs((e-n)/(r-n))**(1/i)))},curves(e,t){let n=tc(e=>e),r=Array.isArray(t.rgb)?hc(t.rgb):n,i=e=>Array.isArray(e)?hc(e):n,[a,o,s]=[i(t.red),i(t.green),i(t.blue)];ec(e,tc(e=>a[r[e]]),tc(e=>o[r[e]]),tc(e=>s[r[e]]))},hueSaturation(e,t){let n=B(t.hue,0),r=B(t.saturation,0)/100,i=B(t.lightness,0)/100,a=Jc(t.colorize,!1),o=e.data;for(let e=0;e<o.length;e+=4){let[t,s,c]=fc(o[e],o[e+1],o[e+2]);a?(t=n,s=Qs(.25+r*.75)):(t+=n,s=r>=0?s+(1-s)*r*s:s*(1+r)),c=i>=0?c+(1-c)*i:c*(1+i);let[l,u,d]=mc(t,Qs(s),Qs(c));o[e]=l,o[e+1]=u,o[e+2]=d}},vibrance(e,t){let n=B(t.vibrance,30)/100,r=B(t.saturation,0)/100,i=e.data;for(let e=0;e<i.length;e+=4){let t=i[e],a=i[e+1],o=i[e+2],s=Math.max(t,a,o);(t+a+o)/3;let c=(s-Math.min(t,a,o))/255,l=t>a&&a>o?.5:1,u=1+r+n*(1-c)*l*1.4,d=nc(t,a,o);i[e]=R(d+(t-d)*u),i[e+1]=R(d+(a-d)*u),i[e+2]=R(d+(o-d)*u)}},temperature(e,t){let n=B(t.temperature,0)/100,r=B(t.tint,0)/100,i=1+n*.32+r*.06,a=1-r*.22+Math.abs(n)*.02,o=1-n*.36+r*.08,s=e=>tc(t=>255*ic(Qs(rc(t/255)*e)));ec(e,s(i),s(a),s(o))},colorBalance(e,t){let n=Yc(t.shadows),r=Yc(t.midtones),i=Yc(t.highlights),a=Jc(t.preserveLuminosity,!0),o=e.data;for(let e=0;e<o.length;e+=4){let t=nc(o[e],o[e+1],o[e+2]),s=t/255,c=Qs(1-s*2.2)*.8,l=Qs(1-Math.abs(s-.5)*2.5)*.8,u=Qs((s-.55)*2.2)*.8;for(let t=0;t<3;t++)o[e+t]=R(o[e+t]+(n[t]*c+r[t]*l+i[t]*u)*1.28);a&&Qc(o,e,t)}},photoFilter(e,t){let n=Xc(t.color,`#ec8a00`),r=Qs(B(t.density,25)/100),i=Jc(t.preserveLuminosity,!0),a=e.data;for(let e=0;e<a.length;e+=4){let t=nc(a[e],a[e+1],a[e+2]);a[e]=a[e]*(1-r)+a[e]*n.r/255*r+n.r*r*.25,a[e+1]=a[e+1]*(1-r)+a[e+1]*n.g/255*r+n.g*r*.25,a[e+2]=a[e+2]*(1-r)+a[e+2]*n.b/255*r+n.b*r*.25,i&&Qc(a,e,t)}},gradientMap(e,t){let[n,r,i]=Zc(t.stops),a=e.data;for(let e=0;e<a.length;e+=4){let t=Math.round(nc(a[e],a[e+1],a[e+2]));a[e]=n[t],a[e+1]=r[t],a[e+2]=i[t]}},grayscale(e,t){let n=B(t.red,30)/100,r=B(t.green,59)/100,i=B(t.blue,11)/100,a=n+r+i;Math.abs(a)<.05&&([n,r,i]=[.3,.59,.11]);let o=e.data;for(let e=0;e<o.length;e+=4){let t=R(o[e]*n+o[e+1]*r+o[e+2]*i);o[e]=o[e+1]=o[e+2]=t}},sepia(e,t){let n=Qs(B(t.intensity,100)/100),r=e.data;for(let e=0;e<r.length;e+=4){let t=r[e],i=r[e+1],a=r[e+2];r[e]=t+(R(t*.393+i*.769+a*.189)-t)*n,r[e+1]=i+(R(t*.349+i*.686+a*.168)-i)*n,r[e+2]=a+(R(t*.272+i*.534+a*.131)-a)*n}},invert(e){ec(e,tc(e=>255-e))},threshold(e,t){let n=B(t.level,128),r=e.data;for(let e=0;e<r.length;e+=4){let t=nc(r[e],r[e+1],r[e+2])>=n?255:0;r[e]=r[e+1]=r[e+2]=t}},posterize(e,t){let n=255/(Math.max(2,Math.round(B(t.levels,6)))-1);ec(e,tc(e=>Math.round(e/n)*n))},blur(e,t,n){cc(e,B(t.radius,6)*n.scale)},motionBlur(e,t,n){let r=Math.round(B(t.distance,20)*n.scale);if(r<1)return;let i=B(t.angle,0)*Math.PI/180,a=Math.cos(i),o=Math.sin(i),{data:s,width:c,height:l}=$s(e),u=e.data,d=r+1;for(let e=0;e<l;e++)for(let t=0;t<c;t++){let n=0,i=0,f=0,p=0;for(let u=0;u<d;u++){let d=u-r/2,m=Math.min(c-1,Math.max(0,Math.round(t+a*d))),h=(Math.min(l-1,Math.max(0,Math.round(e+o*d)))*c+m)*4,g=s[h+3];n+=s[h]*g,i+=s[h+1]*g,f+=s[h+2]*g,p+=g}let m=(e*c+t)*4;p>0&&(u[m]=n/p,u[m+1]=i/p,u[m+2]=f/p),u[m+3]=p/d}},surfaceBlur(e,t,n){let r=Math.max(1,Math.round(B(t.radius,8)*n.scale)),i=B(t.threshold,25)/100,a=(i*i*.25)**1.2+1e-5,{data:o,width:s,height:c}=e,l=s*c,u=new Float32Array(l),d=new Float32Array(l),f=e=>{let t=new Float32Array(e);return sc(t,s,c,r*2),t};for(let e=0;e<3;e++){for(let t=0,n=e;t<l;t++,n+=4){let e=o[n]/255;u[t]=e,d[t]=e*e}let t=f(u),n=f(d),r=new Float32Array(l),i=new Float32Array(l);for(let e=0;e<l;e++){let o=n[e]-t[e]*t[e],s=o/(o+a);r[e]=s,i[e]=t[e]-s*t[e]}let s=f(r),c=f(i);for(let t=0,n=e;t<l;t++,n+=4)o[n]=R((s[t]*u[t]+c[t])*255)}},sharpen(e,t,n){let r=B(t.amount,80)/100,i=Math.max(.3,B(t.radius,1.2)*n.scale),a=B(t.threshold,2),o=$s(e);cc(o,i*2);let s=e.data,c=o.data;for(let e=0;e<s.length;e+=4)for(let t=0;t<3;t++){let n=s[e+t]-c[e+t];Math.abs(n)>=a&&(s[e+t]=R(s[e+t]+n*r))}},clarity(e,t,n){let r=B(t.amount,30)/100,i=lc(e,Math.max(2,B(t.radius,24)*n.scale)),a=e.data;for(let e=0,t=0;t<i.length;e+=4,t++){let n=nc(a[e],a[e+1],a[e+2])/255,o=1-Math.abs(n-.5)*1.6,s=(n-i[t])*r*Math.max(0,o)*255*1.4;a[e]=R(a[e]+s),a[e+1]=R(a[e+1]+s),a[e+2]=R(a[e+2]+s)}},noise(e,t,n){let r=B(t.amount,12)/100*110,i=Jc(t.monochrome,!0),a=dc(Math.round(B(t.seed,1))*7919+17),o=Math.max(1,Math.round(B(t.size,1)*n.scale)),{data:s,width:c,height:l}=e,u=Math.ceil(c/o),d=Math.ceil(l/o),f=new Float32Array(u*d*3);for(let e=0;e<u*d;e++){let t=a()+a()-1;f[e*3]=t,f[e*3+1]=i?t:a()+a()-1,f[e*3+2]=i?t:a()+a()-1}for(let e=0;e<l;e++){let t=Math.floor(e/o)*u;for(let n=0;n<c;n++){let i=(t+Math.floor(n/o))*3,a=(e*c+n)*4;s[a]=R(s[a]+f[i]*r),s[a+1]=R(s[a+1]+f[i+1]*r),s[a+2]=R(s[a+2]+f[i+2]*r)}}},pixelate(e,t,n){let r=Math.max(1,Math.round(B(t.size,16)*n.scale));if(r<2)return;let{data:i,width:a,height:o}=e;for(let e=0;e<o;e+=r)for(let t=0;t<a;t+=r){let n=0,s=0,c=0,l=0,u=0,d=Math.min(o,e+r),f=Math.min(a,t+r);for(let r=e;r<d;r++)for(let e=t;e<f;e++){let t=(r*a+e)*4,o=i[t+3];n+=i[t]*o,s+=i[t+1]*o,c+=i[t+2]*o,l+=o,u++}let p=l?n/l:0,m=l?s/l:0,h=l?c/l:0,g=l/u;for(let n=e;n<d;n++)for(let e=t;e<f;e++){let t=(n*a+e)*4;i[t]=p,i[t+1]=m,i[t+2]=h,i[t+3]=g}}},vignette(e,t){let n=B(t.amount,40)/100,r=B(t.size,50)/100,i=Math.max(.01,B(t.feather,60)/100),a=Xc(t.color,`#000000`),o=n>=0?a:{r:255,g:255,b:255,a:1},s=Math.abs(n),{data:c,width:l,height:u}=e,d=l/2,f=u/2,p=r*.8;for(let e=0;e<u;e++)for(let t=0;t<l;t++){let n=(t-d)/d,r=(e-f)/f,a=Qs((Math.sqrt(n*n+r*r)/Math.SQRT2*1.25-p)/i);a=a*a*(3-2*a)*s;let u=(e*l+t)*4;c[u]+=(o.r-c[u])*a,c[u+1]+=(o.g-c[u+1])*a,c[u+2]+=(o.b-c[u+2])*a}},autoTone(e,t){let n=B(t.clip,.5),r=gc(e);if(!r.count)return;let[i,a]=_c(r.r,r.count,n),[o,s]=_c(r.g,r.count,n),[c,l]=_c(r.b,r.count,n);ec(e,vc(i,a),vc(o,s),vc(c,l))},autoContrast(e,t){let n=gc(e);if(!n.count)return;let[r,i]=_c(n.l,n.count,B(t.clip,.5));ec(e,vc(r,i))},autoColor(e){let t=e.data,n=0,r=0,i=0,a=0;for(let e=0;e<t.length;e+=4)t[e+3]<8||(n+=t[e],r+=t[e+1],i+=t[e+2],a++);if(!a)return;let o=(n+r+i)/3/a,[s,c,l]=[o/Math.max(1,n/a),o/Math.max(1,r/a),o/Math.max(1,i/a)],u=e=>1+(Math.min(1.6,Math.max(.6,e))-1)*.7;ec(e,tc(e=>e*u(s)),tc(e=>e*u(c)),tc(e=>e*u(l))),$c.autoContrast(e,{clip:.3},{scale:1})},look(e,t){let n=qc[String(t.look)];n&&n(e)}};function el(e,t,n){for(let r of t??[]){if(!r||r.enabled===!1)continue;let t=$c[r.type];if(!t)continue;let i=!ri(r.type)?.params.some(e=>e.name===`amount`)&&typeof r.amount==`number`?Qs(r.amount):1;if(i<=0)continue;let a=tl(r);if(i>=1){t(e,a,n);continue}let o=new Uint8ClampedArray(e.data);t(e,a,n);let s=e.data;for(let e=0;e<s.length;e++)s[e]=o[e]+(s[e]-o[e])*i}}function tl(e){let t=ri(e.type),n={};for(let e of t?.params??[])e.default!==void 0&&(n[e.name]=e.default);return{...n,...e}}function nl(e,t){let n=0;for(let r of e??[]){if(!r||typeof r!=`object`||r.enabled===!1)continue;let e=tl(r);r.type===`blur`?n+=B(e.radius,6)*1.5*t:r.type===`motionBlur`&&(n+=B(e.distance,20)/2*t)}return n>=.5?Math.ceil(n)+2:0}new Set(qr.filter(e=>e.group===`blur`||e.group===`detail`||e.id===`shadowsHighlights`||e.id===`pixelate`).map(e=>e.id));function rl(e){let t=Array.isArray(e)&&e.length?e:[`#000`,`#fff`],n=t.length;return t.map((e,t)=>Array.isArray(e)?[Math.min(1,Math.max(0,Number(e[0])||0)),String(e[1])]:[n===1?0:t/(n-1),String(e)])}function il(e,t,n,r=`#ffffff`){if(t==null)return r;if(typeof t==`string`)return t;if(t.type===`radial`){let r=n.x+(t.cx??.5)*n.w,i=n.y+(t.cy??.5)*n.h,a=(t.radius??1)/Math.SQRT2,o=Math.max(.5,a*n.w),s=Math.max(.5,a*n.h);if(n.w===n.h||Math.abs(o-s)<.5){let a=Math.max(.5,(t.radius??1)*Math.hypot(n.w,n.h)*.5);return al(e.createRadialGradient(r,i,0,r,i,a),t.stops)}return ol(e,r,i,o,s,t.stops)}let i=(t.angle??90)*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=Math.abs(n.w/2*a)+Math.abs(n.h/2*o),c=n.x+n.w/2,l=n.y+n.h/2;return al(e.createLinearGradient(c-a*s,l-o*s,c+a*s,l+o*s),t.stops)}function al(e,t){for(let[n,r]of rl(t))try{e.addColorStop(n,r)}catch{}return e}function ol(e,t,n,r,i,a){let o=e.canvas.width,s=e.canvas.height,c=wc(o,s),l=z(c),u=i/r;return l.setTransform(1,0,0,u,t,n),l.fillStyle=al(l.createRadialGradient(0,0,0,0,0,r),a),l.fillRect(-t,-n/u,o,s/u),e.createPattern(c,`no-repeat`)??al(e.createRadialGradient(t,n,0,t,n,Math.max(r,i)),a)}var sl=null,cl=()=>sl??=z(wc(8,8));function ll(e,t,n){let r=/[\s,'"]/.test(t)&&!/^["']/.test(t)&&!t.includes(`,`)?`"${t}"`:t;return`${e.italic?`italic `:``}${e.weight??400} ${n}px ${r}, system-ui, sans-serif`}var ul=(e,t)=>e.transform===`uppercase`?t.toUpperCase():e.transform===`lowercase`?t.toLowerCase():t;function dl(e,t){return`letterSpacing`in e&&(e.letterSpacing=`${t}px`,!0)}function fl(e,t,n,r){return t?r||!n?e.measureText(t).width:e.measureText(t).width+n*(Array.from(t).length-1):0}function pl(e,t,n=1){let r=cl(),i=(e.size??64)*n,a=(e.letterSpacing??0)*n,o=ll(e,t,i);r.font=o;let s=dl(r,a),c=e.width===void 0?1/0:e.width*n,l=[];for(let t of ul(e,String(e.text??``)).split(`
11
+ `)){let e=t.split(/(\s+)/),n=``;for(let t of e){let e=n+t;if(n&&fl(r,e.trimEnd(),a,s)>c&&t.trim())for(l.push({text:n.trimEnd(),width:fl(r,n.trimEnd(),a,s)}),n=t.trimStart();fl(r,n,a,s)>c&&n.length>1;){let e=n.length-1;for(;e>1&&fl(r,n.slice(0,e),a,s)>c;)e--;l.push({text:n.slice(0,e),width:fl(r,n.slice(0,e),a,s)}),n=n.slice(e)}else n=e}l.push({text:n.trimEnd(),width:fl(r,n.trimEnd(),a,s)})}let u=r.measureText(`Hg`),d=u.fontBoundingBoxAscent??u.actualBoundingBoxAscent??i*.8,f=u.fontBoundingBoxDescent??u.actualBoundingBoxDescent??i*.2,p=(e.lineHeight??1.2)*i,m=Math.max(0,...l.map(e=>e.width)),h=p*l.length;return s&&dl(r,0),{font:o,lines:l,width:(e.width===void 0?m:e.width*n)/n,height:(e.height===void 0?h:e.height*n)/n,lineHeight:p,ascent:d,descent:f,textHeight:h}}function ml(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0,o=(e,t,o,s)=>{n=Math.min(n,e),r=Math.min(r,t),i=Math.max(i,o),a=Math.max(a,s)},s=t.width,c=t.height;if(e.background){let[t,n]=hl(e);o(-t,-n,s+t,c+n)}let l=e.valign??`top`,u=l===`middle`?(c-t.textHeight)/2:l===`bottom`?c-t.textHeight:0,d=e.align??`left`;return t.lines.forEach((e,n)=>{if(!e.text||e.width<=0)return;let r=u+n*t.lineHeight+(t.lineHeight-(t.ascent+t.descent))/2,i=d===`center`?(s-e.width)/2:d===`right`?s-e.width:0;o(i,r,i+e.width,r+t.ascent+t.descent)}),Number.isFinite(n)?{x:n,y:r,width:i-n,height:a-r}:null}function hl(e){let t=e.background?.padding??0;return Array.isArray(t)?[t[0],t[1]]:[t,t]}function gl(e,t,n){let r=pl(e,t,n),i=r.width*n,a=r.height*n,[o,s]=e.background?hl(e).map(e=>e*n):[0,0],c=Math.ceil((e.size??64)*n*.25),l=Math.ceil(o)+c,u=Math.ceil(s)+c,d=wc(i+l*2,a+u*2),f=z(d);if(e.background){f.fillStyle=e.background.color;let t=(e.background.radius??0)*n;f.beginPath(),_l(f,l-o,u-s,i+o*2,a+s*2,t),f.fill()}f.font=r.font;let p=dl(f,(e.letterSpacing??0)*n);f.textBaseline=`alphabetic`,f.fillStyle=il(f,e.color??`#ffffff`,{x:l,y:u,w:i,h:a});let m=e.valign??`top`,h=u+(m===`middle`?(a-r.textHeight)/2:m===`bottom`?a-r.textHeight:0),g=(e.letterSpacing??0)*n;return r.lines.forEach((t,n)=>{let a=h+n*r.lineHeight+(r.lineHeight-(r.ascent+r.descent))/2+r.ascent,o=e.align??`left`,s=l+(o===`center`?(i-t.width)/2:o===`right`?i-t.width:0);if(p||!g)f.fillText(t.text,s,a);else{let e=s;for(let n of Array.from(t.text))f.fillText(n,e,a),e+=f.measureText(n).width+g}}),{canvas:d,ox:l,oy:u,w:i,h:a}}function _l(e,t,n,r,i,a){let o=Math.max(0,Math.min(a,r/2,i/2));o?(e.moveTo(t+o,n),e.arcTo(t+r,n,t+r,n+i,o),e.arcTo(t+r,n+i,t,n+i,o),e.arcTo(t,n+i,t,n,o),e.arcTo(t,n,t+r,n,o),e.closePath()):e.rect(t,n,r,i)}var vl=96,yl=class{loader;cache=new Map;tick=0;natural=new Map;constructor(e){this.loader=e}clearCache(){this.cache.clear()}async render(e,t={}){let n=t.scale??1,r=Math.max(1,Math.round(e.canvas.width*n)),i=Math.max(1,Math.round(e.canvas.height*n)),a=wc(r,i),o=z(a);if(t.backdrop===`checker`){let e=Math.max(6,Math.round(12*Math.min(1,n*2)));o.fillStyle=`#ffffff`,o.fillRect(0,0,r,i),o.fillStyle=`#d9d9d9`;for(let t=0;t<i;t+=e)for(let n=t/e%2?e:0;n<r;n+=e*2)o.fillRect(n,t,e,e)}else t.backdrop&&(o.fillStyle=t.backdrop,o.fillRect(0,0,r,i));return t.background!==!1&&e.canvas.background&&(o.fillStyle=il(o,e.canvas.background,{x:0,y:0,w:r,h:i}),o.fillRect(0,0,r,i)),await this.preload(e),await this.compose(e.layers,a,e,n,t),this.evict(),a}async layerSurface(e,t,n){return await this.preload({...t,layers:[e]}),this.surface(e,t,n,{})}async layerBox(e){if(!Lr(e))return null;let t=e.x??0,n=e.y??0,r=e.rotation??0;if(e.type===`text`){let i=pl(e,await this.family(e),1),a=ml(e,i);return{x:t,y:n,width:i.width,height:i.height,rotation:r,...a?{ink:{x:t+a.x,y:n+a.y,width:a.width,height:a.height}}:{}}}if(e.type===`image`){let{w:i,h:a}=Sl(e,await this.naturalSize(e.src).catch(()=>null));return{x:t,y:n,width:i,height:a,rotation:r}}return{x:t,y:n,width:e.width??0,height:e.height??0,rotation:r}}async naturalSize(e){let t=this.natural.get(e);if(t)return t;let n=await this.loader.image(e),r={width:n.width,height:n.height};return this.natural.set(e,r),r}async preload(e){let t=[],n=e=>{for(let r of e)r.type===`text`&&r.font&&ai(r.font)&&this.loader.font&&t.push(this.loader.font(r.font,r.weight??400,!!r.italic).catch(()=>null)),r.type===`group`&&n(r.children??[])};n(e.layers??[]),await Promise.all(t)}async compose(e,t,n,r,i){let a=z(t),o=null,s=!0;for(let c of e??[]){if(!c||typeof c!=`object`)continue;let e=c.visible===!1||i.skip?.has(c.id)||i.only&&!xl(c,i.only);if(c.clip&&(e||!o||!s))continue;if(e){c.clip||(o=null,s=!1);continue}let l;try{l=c.type===`adjustment`?await this.adjust(c,t,r):await this.surface(c,n,r,i)}catch(e){i.onError?.(c.id,e.message),l=null}l?(c.clip&&o&&(l=El(l,o)),a.save(),a.globalAlpha=bl(c.opacity??1),a.globalCompositeOperation=Dc(c.blend),a.drawImage(l.canvas,l.x,l.y),a.restore(),c.clip||(o=l,s=!0)):c.clip||(o=null,s=!1)}}async surface(e,t,n,r){let i=await this.cacheKey(e,t,n,r),a=this.cache.get(e.id);if(a&&a.key===i)return a.used=++this.tick,a.surface;let o=null;return e.type===`group`?o=await this.groupSurface(e,t,n,r):e.type===`fill`?o=this.fillSurface(e,t,n):Lr(e)&&(o=await this.boxSurface(e,n)),o&&e.type!==`group`&&e.type!==`adjustment`&&!Lr(e)&&e.mask&&(o={...o,canvas:await this.maskCanvasSpace(o.canvas,e.mask,t,n)}),o&&Pc(e.effects)&&(o=zc(o,e.effects,n)),this.cache.set(e.id,{key:i,surface:o,used:++this.tick}),o}async cacheKey(e,t,n,r){let i=[],a=this.loader.version,o=e=>{a&&(e.type===`image`&&i.push(`${e.src}@${a(e.src)}`),e.mask&&Rr(e.mask)&&i.push(`${e.mask.src}@${a(e.mask.src)}`)),e.type===`group`&&(e.children??[]).forEach(o)};return o(e),`${n}|${e.type===`fill`||e.type===`group`?`${t.canvas.width}x${t.canvas.height}`:``}|${e.type===`group`?`${[...r.skip??[]].join(`,`)}|${[...r.only??[]].join(`,`)}`:``}|${i.join(`,`)}|${so(e)}`}evict(){if(this.cache.size<=vl)return;let e=[...this.cache.entries()].sort((e,t)=>e[1].used-t[1].used);for(let[t]of e.slice(0,this.cache.size-vl))this.cache.delete(t)}async groupSurface(e,t,n,r){let i=wc(Math.max(1,Math.round(t.canvas.width*n)),Math.max(1,Math.round(t.canvas.height*n)));return await this.compose(e.children??[],i,t,n,r),e.filters?.length&&Cl(i,e.filters,n),{canvas:e.mask?await this.maskCanvasSpace(i,e.mask,t,n):i,x:0,y:0}}fillSurface(e,t,n){let r=Math.max(1,Math.round(t.canvas.width*n)),i=Math.max(1,Math.round(t.canvas.height*n)),a=wc(r,i),o=z(a);return o.fillStyle=il(o,e.fill,{x:0,y:0,w:r,h:i}),o.fillRect(0,0,r,i),e.filters?.length&&Cl(a,e.filters,n),{canvas:a,x:0,y:0}}async adjust(e,t,n){if(!e.filters?.length)return null;let r=wc(t.width,t.height);return z(r).drawImage(t,0,0),Cl(r,e.filters,n),e.mask&&e.mask.enabled!==!1&&Tl(r,await this.maskPlane(e.mask,r.width,r.height,n,null)),{canvas:r,x:0,y:0}}async boxSurface(e,t){let n;if(n=e.type===`image`?await this.imageContent(e,t):e.type===`text`?gl(e,await this.family(e),t):Ol(e,t),!n||n.w<=0||n.h<=0)return null;if(e.type!==`image`&&e.filters?.length){let r=nl(e.filters,t);r&&(n=Dl(n,r))}if(e.filters?.length&&Cl(n.canvas,e.filters,t),e.mask&&e.mask.enabled!==!1){let r=await this.maskPlane(e.mask,Math.max(1,Math.round(n.w)),Math.max(1,Math.round(n.h)),t,e),i=new Uint8ClampedArray(n.canvas.width*n.canvas.height),a=Math.max(1,Math.round(n.w)),o=Math.max(1,Math.round(n.h)),s=Math.round(n.ox),c=Math.round(n.oy);for(let e=0;e<o;e++){let t=e+c;if(!(t<0||t>=n.canvas.height))for(let o=0;o<a;o++){let c=o+s;c<0||c>=n.canvas.width||(i[t*n.canvas.width+c]=r[e*a+o])}}Tl(n.canvas,i)}let r=Nc(e.effects,t),i=(e.x??0)*t,a=(e.y??0)*t,o=i+n.w/2,s=a+n.h/2,c=(e.rotation??0)*Math.PI/180,l=e.flipX?-1:1,u=e.flipY?-1:1,d=-n.w/2-n.ox,f=-n.h/2-n.oy,p=[[d,f],[d+n.canvas.width,f],[d,f+n.canvas.height],[d+n.canvas.width,f+n.canvas.height]].map(([e,t])=>{let n=e*l,r=t*u;return[o+n*Math.cos(c)-r*Math.sin(c),s+n*Math.sin(c)+r*Math.cos(c)]}),m=Math.floor(Math.min(...p.map(e=>e[0])))-r,h=Math.floor(Math.min(...p.map(e=>e[1])))-r,g=Math.ceil(Math.max(...p.map(e=>e[0])))+r,_=Math.ceil(Math.max(...p.map(e=>e[1])))+r;if(!c&&l===1&&u===1&&!r)return{canvas:n.canvas,x:Math.round(i-n.ox),y:Math.round(a-n.oy)};let v=wc(g-m,_-h),y=z(v);return y.translate(o-m,s-h),y.rotate(c),y.scale(l,u),y.drawImage(n.canvas,d,f),{canvas:v,x:m,y:h}}async imageContent(e,t){let n=await this.loader.image(e.src);this.natural.set(e.src,{width:n.width,height:n.height});let{w:r,h:i}=Sl(e,{width:n.width,height:n.height}),a=Math.max(1,Math.round(r*t)),o=Math.max(1,Math.round(i*t)),s=e.crop??{x:0,y:0,width:n.width,height:n.height},c=wc(a,o),l=z(c),u=e.fit??`fill`,[d,f]=e.focus??[.5,.5];if(u===`fill`)l.drawImage(n,s.x,s.y,s.width,s.height,0,0,a,o);else if(u===`cover`){let e=Math.max(a/s.width,o/s.height),t=a/e,r=o/e;l.drawImage(n,s.x+(s.width-t)*d,s.y+(s.height-r)*f,t,r,0,0,a,o)}else{let e=Math.min(a/s.width,o/s.height),t=s.width*e,r=s.height*e;l.drawImage(n,s.x,s.y,s.width,s.height,(a-t)*d,(o-r)*f,t,r)}return{canvas:c,ox:0,oy:0,w:a,h:o}}async family(e){let t=e.font??`inter`,n=ai(t);if(n&&this.loader.font){let n=await this.loader.font(t,e.weight??400,!!e.italic).catch(()=>null);if(n)return n}return n?n.family:t}maskPlane(e,t,n,r,i){let a=i=>{e.feather&&uc(i,t,n,e.feather*r);let a=bl(e.density??1);for(let t=0;t<i.length;t++){let n=e.invert?255-i[t]:i[t];a<1&&(n=255-(255-n)*a),i[t]=n}return i};if(Rr(e))return this.loader.image(e.src).then(e=>{let r=wc(t,n);return z(r).drawImage(e,0,0,t,n),a(wl(r))});let o=wc(t,n),s=z(o);if(zr(e)){s.fillStyle=`#fff`,s.beginPath();let t=e.x*r,n=e.y*r,i=e.width*r,a=e.height*r;e.shape===`ellipse`?s.ellipse(t+i/2,n+a/2,Math.max(0,i/2),Math.max(0,a/2),0,0,Math.PI*2):_l(s,t,n,i,a,(e.radius??0)*r),s.fill()}else Br(e)&&(s.fillStyle=il(s,e.gradient,{x:0,y:0,w:t,h:n}),s.fillRect(0,0,t,n));return a(wl(o))}async maskCanvasSpace(e,t,n,r){return t.enabled===!1||Tl(e,await this.maskPlane(t,e.width,e.height,r,null)),e}},bl=e=>e<0?0:e>1?1:e;function xl(e,t){return t.has(e.id)?!0:e.type===`group`&&(e.children??[]).some(e=>xl(e,t))}function Sl(e,t){let n=e.crop?{width:e.crop.width,height:e.crop.height}:t??{width:e.width??1,height:e.height??1};return e.width!==void 0&&e.height!==void 0?{w:e.width,h:e.height}:e.width===void 0?e.height===void 0?{w:n.width,h:n.height}:{w:e.height*n.width/n.height,h:e.height}:{w:e.width,h:e.width*n.height/n.width}}function Cl(e,t,n){if(!t?.some(e=>e&&e.enabled!==!1))return;let r=Tc(e);el(r,t,{scale:n}),Ec(e,r)}function wl(e){let t=Tc(e).data,n=new Uint8ClampedArray(t.length/4);for(let e=0,r=0;e<n.length;e++,r+=4)n[e]=(.299*t[r]+.587*t[r+1]+.114*t[r+2])*t[r+3]/255;return n}function Tl(e,t){let n=Tc(e),r=n.data;for(let e=0,n=3;e<t.length;e++,n+=4)r[n]=r[n]*t[e]/255;Ec(e,n)}function El(e,t){let n=wc(e.canvas.width,e.canvas.height),r=z(n);return r.drawImage(e.canvas,0,0),r.globalCompositeOperation=`destination-in`,r.drawImage(t.canvas,t.x-e.x,t.y-e.y),{canvas:n,x:e.x,y:e.y}}function Dl(e,t){let n=wc(e.canvas.width+t*2,e.canvas.height+t*2);return z(n).drawImage(e.canvas,t,t),{...e,canvas:n,ox:e.ox+t,oy:e.oy+t}}function Ol(e,t){let n=Math.max(0,(e.width??0)*t),r=Math.max(0,(e.height??0)*t),i=e.stroke?(e.stroke.width??4)*t:e.shape===`line`?4*t:0,a=Math.ceil(i/2+2),o=wc(Math.max(1,n+a*2),Math.max(1,r+a*2)),s=z(o),c={x:a,y:a,w:n,h:r};return s.beginPath(),kl(s,e,c,t),e.shape!==`line`&&e.fill!==null&&(s.fillStyle=il(s,e.fill,c,`#ffffff`),s.fill()),(e.stroke||e.shape===`line`)&&(s.lineWidth=i,s.strokeStyle=e.stroke?.color??`#ffffff`,s.lineJoin=`round`,s.lineCap=e.shape===`line`?`round`:`butt`,e.stroke?.dash?.length&&s.setLineDash(e.stroke.dash.map(e=>e*t)),s.stroke()),{canvas:o,ox:a,oy:a,w:Math.max(n,1),h:Math.max(r,1)}}function kl(e,t,n,r){let{x:i,y:a,w:o,h:s}=n;switch(t.shape){case`ellipse`:e.ellipse(i+o/2,a+s/2,o/2,s/2,0,0,Math.PI*2);break;case`line`:e.moveTo(i,a),e.lineTo(i+o,a+s);break;case`polygon`:case`star`:{let n=Math.max(3,Math.round(t.sides??(t.shape===`star`?5:6))),r=t.shape===`star`?t.innerRadius??.5:1,c=t.shape===`star`?n*2:n;for(let n=0;n<c;n++){let l=t.shape===`star`&&n%2?r:1,u=-Math.PI/2+n/c*Math.PI*2,d=i+o/2+o/2*Math.cos(u)*l,f=a+s/2+s/2*Math.sin(u)*l;n?e.lineTo(d,f):e.moveTo(d,f)}e.closePath();break}default:_l(e,i,a,o,s,(t.radius??0)*r)}}var Al=(e,t)=>`${e.replace(/\/?$/,`/`)}${t.split(`/`).map(encodeURIComponent).join(`/`)}`;async function jl(e){let t=e.type.includes(`svg`);if(!t&&typeof createImageBitmap==`function`)try{return await createImageBitmap(e,{imageOrientation:`from-image`})}catch{}if(typeof Image>`u`)throw Error(`Cannot decode ${e.type||`image`} here.`);let n=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,e.src=n,await e.decode(),!t||e.naturalWidth&&e.naturalHeight||(e.width=512,e.height=512),e}finally{setTimeout(()=>URL.revokeObjectURL(n),3e4)}}function Ml(e){let t=e.fetchImpl??fetch.bind(globalThis),n=e.library,r=new Map,i=new Map,a=new Map,o=async t=>{if(sa(t)){let r=la(n,ca(t));if(!r?.path)throw Error(`Unknown library image "${t}".`);return Al(e.libraryBase,r.path)}if(/^(blob:|data:)/.test(t))return t;let r=e.resolve?await e.resolve(t):Al(e.assetBase,t),a=i.get(t);return a?`${r}${r.includes(`?`)?`&`:`?`}v=${a}`:r};return{image(e){let n=r.get(e);return n||(n=(async()=>{let n=await t(await o(e),{cache:`no-store`});if(!n.ok)throw Error(`${e}: HTTP ${n.status}`);return jl(await n.blob())})(),n.catch(()=>r.delete(e)),r.set(e,n)),n},version:e=>i.get(e)??0,invalidate(e){r.delete(e),i.set(e,(i.get(e)??0)+1)},setLibrary(e){n=e},font(t,r,i){let o=ai(t),s=la(n,t);if(!o||!s?.files?.length||typeof FontFace>`u`)return Promise.resolve(o?.family??null);let c=i?`italic`:`normal`,l=s.files.filter(e=>e.style===c).length?s.files.filter(e=>e.style===c):s.files,u=l.reduce((e,t)=>Math.abs(t.weight-r)<Math.abs(e.weight-r)?t:e).weight,d=`${t}|${u}|${c}`,f=a.get(d);return f||(f=(async()=>{let t=globalThis.document?.fonts??globalThis.fonts,n=l.filter(e=>e.weight===u);return await Promise.all(n.map(async n=>{let i=new FontFace(o.family,`url(${Al(e.libraryBase,n.path)}) format("woff2")`,{weight:String(r),style:c,...n.unicodeRange?{unicodeRange:n.unicodeRange}:{}});await i.load(),t?.add(i)})),o.family})(),f.catch(()=>a.delete(d)),a.set(d,f)),f}}}var Nl=class{loader;compositor;constructor(e,t){this.loader=t??Ml(e),this.compositor=new yl(this.loader),e.ai&&Ks(e.ai)}setLibrary(e){this.loader.setLibrary?.(e)}render(e,t){return this.compositor.render(e,t)}async exportImage(e,t,n={}){let r=await this.compositor.render(e,{...n,scale:t.scale}),i=wc(t.width,t.height),a=z(i);t.background&&(a.fillStyle=t.background,a.fillRect(0,0,t.width,t.height));let o=t.scale;return a.drawImage(r,t.source.x*o,t.source.y*o,t.source.width*o,t.source.height*o,t.dest.x,t.dest.y,t.dest.width,t.dest.height),Rl(i,t.mime,t.quality)}async analyze(e,t={}){return yc(Tc(t.layer?await this.layerPixels(e,t.layer,{maxSide:t.maxSide??1200,withFilters:!0}):await this.render(e,{scale:Math.min(1,(t.maxSide??1200)/Math.max(e.canvas.width,e.canvas.height))})))}async layerPixels(e,t,n={}){let r=N(e.layers,t);if(!r)throw Error(`No layer "${t}".`);let i=r.layer,a=n.maxSide??2048;if(!Lr(i)){let t=Math.min(1,a/Math.max(e.canvas.width,e.canvas.height));return this.compositor.render({...e,canvas:{...e.canvas,background:null},layers:[Pl(i,n.withFilters)]},{scale:t})}let o=await this.compositor.layerBox(i);if(!o)throw Error(`Layer "${t}" has no size.`);let s=1;if(i.type===`image`){let e=await this.compositor.naturalSize(i.src),t=i.crop??e;s=Math.max(t.width/o.width,t.height/o.height)}s=Math.min(s,a/Math.max(o.width,o.height));let c={...Pl(i,n.withFilters),x:0,y:0,rotation:0,flipX:!1,flipY:!1},l=Math.max(1,Math.round(o.width*s)),u=Math.max(1,Math.round(o.height*s));return this.compositor.render({version:1,id:`layer`,canvas:{width:l/s,height:u/s},layers:[c]},{scale:s})}async backgroundMask(e,t,n={}){let r=await this.layerPixels(e,t,{maxSide:2048,withFilters:!1});return Ll(Fl(await Xs(r,n.model),r.width,r.height,n),r.width,r.height)}async segmentMask(e,t,n,r={}){let i=await this.layerPixels(e,t,{maxSide:1600,withFilters:!1}),a=await this.compositor.layerBox(N(e.layers,t).layer),o=a?i.width/a.width:1;return Ll(Fl(await Zs(i,{...n.points?{points:n.points.map(([e,t,n])=>[e*o,t*o,n])}:{},...n.box?{box:n.box.map(e=>e*o)}:{}},r.model),i.width,i.height,{feather:r.feather??1}),i.width,i.height)}async colorRangeMask(e,t,n){let r=Tc(await this.layerPixels(e,t,{maxSide:2048,withFilters:!0})),i=z(wc(1,1));i.fillStyle=n.color,i.fillRect(0,0,1,1);let[a,o,s]=i.getImageData(0,0,1,1).data,c=(n.tolerance??32)/100*441,l=new Uint8ClampedArray(r.width*r.height);for(let e=0,t=0;e<l.length;e++,t+=4){let n=Math.hypot(r.data[t]-a,r.data[t+1]-o,r.data[t+2]-s);l[e]=r.data[t+3]<8?0:n<=c?255:n<=c*1.25?255*(1-(n-c)/(c*.25)):0}return Ll(Fl(l,r.width,r.height,{feather:n.feather}),r.width,r.height)}};function Pl(e,t){let{mask:n,effects:r,opacity:i,blend:a,clip:o,...s}=e,c={...s,visible:!0};return!t&&c.type!==`adjustment`&&delete c.filters,c}function Fl(e,t,n,r){if(r.threshold!==void 0){let t=Math.max(0,Math.min(255,r.threshold));for(let n=0;n<e.length;n++)e[n]=e[n]>=t?255:0}return r.feather&&uc(e,t,n,r.feather),e}function Il(e,t,n){let r=t,i=n,a=-1,o=-1;for(let s=0;s<n;s++){let n=s*t;for(let c=0;c<t;c++)e[n+c]<128||(c<r&&(r=c),c>a&&(a=c),s<i&&(i=s),o=s)}return a<0?null:{x:r,y:i,width:a-r+1,height:o-i+1}}async function Ll(e,t,n){let r=Il(e,t,n),i=wc(t,n),a=z(i);return a.fillStyle=`#000`,a.fillRect(0,0,t,n),a.drawImage(Ac(e,t,n),0,0),{...await Rl(i,`image/png`),bbox:r}}async function Rl(e,t,n=100){let r=await jc(e,t,t===`image/png`?void 0:n/100);return{bytes:new Uint8Array(await r.arrayBuffer()),mime:r.type||t,width:e.width,height:e.height}}var zl=`agentphoto-studio`,Bl=`projects`,Vl=null;function Hl(){return typeof indexedDB>`u`?Promise.resolve(null):(Vl||=new Promise(e=>{try{let t=indexedDB.open(zl,1);t.onupgradeneeded=()=>t.result.createObjectStore(Bl,{keyPath:`id`}),t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)}catch{e(null)}}),Vl)}async function Ul(e,t){let n=await Hl();if(n)return new Promise(r=>{let i=t(n.transaction(Bl,e).objectStore(Bl));i.onsuccess=()=>r(i.result),i.onerror=()=>r(void 0)})}var Wl={async list(){return(await Ul(`readonly`,e=>e.getAll())??[]).map(({id:e,title:t,updatedAt:n,thumb:r})=>({id:e,title:t,updatedAt:n,thumb:r})).sort((e,t)=>String(t.updatedAt).localeCompare(String(e.updatedAt)))},async get(e){return await Ul(`readonly`,t=>t.get(e))},async put(e){await Ul(`readwrite`,t=>t.put(e))},async remove(e){await Ul(`readwrite`,t=>t.delete(e))}},Gl=class extends Tr{id;meta;delay;timer=null;changed=new Set;notifyTimer=null;listeners=new Set;constructor(e,t,n,r=400){super(t),this.id=e,this.meta=n,this.delay=r}touched(e){this.changed.add(e),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>void this.save(),this.delay),this.notifyTimer||=setTimeout(()=>{this.notifyTimer=null;let e=[...this.changed];this.changed.clear(),this.listeners.forEach(t=>t(e))},30)}async save(){this.timer&&clearTimeout(this.timer),this.timer=null,await Wl.put({id:this.id,...this.meta(),updatedAt:new Date().toISOString(),files:Object.fromEntries(this.files)})}async writeText(e,t){await super.writeText(e,t),this.touched(e)}async writeBytes(e,t){await super.writeBytes(e,t),this.touched(e)}async remove(e){await super.remove(e),this.touched(e)}};function Kl(e){let t=async e=>{let t=[],n=await e((e,n)=>t.push({layer:e,message:n}));return{bytes:n.bytes,mime:n.mime,width:n.width,height:n.height,...t.length?{errors:t}:{}}};return{render(n,r){let i=r.scale??1;return r.maxWidth&&(i=Math.min(i,r.maxWidth/n.canvas.width)),r.maxHeight&&(i=Math.min(i,r.maxHeight/n.canvas.height)),t(async t=>Rl(await e.render(n,{scale:i,only:r.only?new Set(r.only):void 0,onError:t}),r.format===`jpeg`?`image/jpeg`:`image/png`,88))},exportImage:(n,r)=>t(t=>e.exportImage(n,r,{onError:t})),analyze:(t,n)=>e.analyze(t,n),backgroundMask:(t,n,r)=>e.backgroundMask(t,n,r),segmentMask:(t,n,r,i)=>e.segmentMask(t,n,r,i),colorRangeMask:(t,n,r)=>e.colorRangeMask(t,n,r),async layerBoxes(t){let n={},r=[];P(t.layers,e=>void r.push(e));for(let t of r){let r=await e.compositor.layerBox(t).catch(()=>null);r&&(n[t.id]=r)}return n}}}var ql=class extends Error{code;hint;details;constructor(e,t,n,r){super(t),this.code=e,this.hint=n,this.details=r,this.name=`ToolCallError`}},Jl=`./library/`,Yl=`./ort/`,Xl=`./templates/`,Zl=`apfs:`,Ql=e=>new URL(e,location.href).href,$l=e=>{let t=oa(e);return t?Yi[t]:e.endsWith(`.json`)?`application/json`:`application/octet-stream`};async function eu(e){try{let t=await fetch(e);return!t.ok||(t.headers.get(`content-type`)??``).includes(`text/html`)?null:new Uint8Array(await t.arrayBuffer())}catch{return null}}var tu=class{mode=`local`;version=void 0;modelSource=`hub`;fs=null;title=``;thumb;libraryIndex={assets:[]};templateIndex=[];blobs=new Map;engine=null;uploads=new Map;progress=new Set;changeListeners=new Set;async init(){let e=await eu(`${Jl}index.json`);try{e&&(this.libraryIndex=JSON.parse(new TextDecoder().decode(e)))}catch{}let t=await eu(`${Xl}index.json`);try{let e=t?JSON.parse(new TextDecoder().decode(t)):[];this.templateIndex=e.map(e=>({...ns(e,e.id),files:Array.isArray(e.files)?e.files.map(String):[]}))}catch{this.templateIndex=[]}}get location(){return this.fs?.id??null}blobUrl=async e=>{let t=this.blobs.get(e);if(t)return t;let n=await this.requireFs().readBytes(e),r=URL.createObjectURL(new Blob([n],{type:$l(e)}));return this.blobs.set(e,r),r};onFsChange=e=>{for(let t of e){let e=this.blobs.get(t);e&&(this.blobs.delete(t),setTimeout(()=>URL.revokeObjectURL(e),1e4)),this.engine?.loader.invalidate(t)}this.changeListeners.forEach(t=>t(e))};fetchFile=async(e,t)=>{if(!e.startsWith(Zl))return fetch(e,t);let n=decodeURIComponent(e.slice(5).replace(/\?v=\d+$/,``));try{let e=await this.requireFs().readBytes(n);return new Response(e,{status:200,headers:{"content-type":$l(n)}})}catch{return new Response(null,{status:404})}};engineOptions(){return{assetBase:Zl,libraryBase:Jl,library:this.libraryIndex,resolve:e=>Zl+encodeURIComponent(e),fetchImpl:this.fetchFile,ai:{wasmPaths:Ql(Yl),onProgress:e=>this.progress.forEach(t=>t(e))}}}onAiProgress(e){return this.progress.add(e),()=>this.progress.delete(e)}host(){let e=this.libraryIndex;return this.engine||=new Nl(this.engineOptions()),{engine:Kl(this.engine),library:{index:e,read:async e=>{let t=await eu(Jl+e);if(!t)throw new A(`notFound`,`Library file ${e} is not available here.`);return t}},templates:{index:this.templateIndex,files:async e=>{let t=this.templateIndex.find(t=>t.id===e);if(!t)throw new A(`notFound`,`Unknown template "${e}".`);let n={};for(let r of t.files){let t=await eu(`${Xl}${e}/${r}`);t&&(n[r]=t)}return n}},readLocalFile:async e=>{let t=this.uploads.get(e);if(!t)throw new A(`invalid`,`In the browser, open files with the Studio (drag & drop or the file picker).`);return t}}}hasProject(){return!!this.fs}canCreate(){return!0}projectTitle(){return this.title||`Untitled`}requireFs(){if(!this.fs)throw new ql(`no-project`,`No project is open.`);return this.fs}async loadDoc(){return Ki(JSON.parse(await this.requireFs().readText(`photo.json`)))}async tools(){return zs(this.host()).map(({name:e,description:t,inputSchema:n,mutating:r,needsEngine:i})=>({name:e,description:t,inputSchema:n,mutating:r,needsEngine:i}))}async call(e,t){try{let n=await Vs({fs:this.requireFs(),host:this.host()},e,t);return(e===`doc_apply`||e===`doc_patch`||e===`project_create`)&&await this.refreshTitle(),n}catch(e){throw e instanceof A?new ql(e.code,e.message,e.hint,e.details):e instanceof ql?e:new ql(`io`,e.message)}}async refreshTitle(){try{let e=await this.loadDoc();e.title&&(this.title=e.title)}catch{}}async library(){return this.libraryIndex}libraryBase(){return Jl}async modelCached(e){return!1}async templates(){return this.templateIndex.map(({files:e,...t})=>t)}templatePreview(e){return`${Xl}${encodeURIComponent(e)}/preview.jpg`}fileUrl(e){return this.blobUrl(e)}readFile(e){return this.requireFs().readBytes(e)}writeFile(e,t){return this.requireFs().writeBytes(e,t)}listFiles(e){return this.requireFs().list(e)}async addImage(e,t){return(await Wa(this.requireFs(),{name:e,bytes:t,kind:`image`,source:`user`})).path}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}attach(e){this.fs?.listeners.delete(this.onFsChange),this.blobs.forEach(e=>URL.revokeObjectURL(e)),this.blobs.clear(),this.engine=null,this.fs=e,e.listeners.add(this.onFsChange)}async createProject(e){let t=xi(e.title,`photo`),n=`${t}-${Date.now().toString(36)}`;this.title=e.title,this.thumb=void 0;let r=new Gl(n,{},()=>({title:this.title,thumb:this.thumb}));this.attach(r);let i={name:t,title:e.title,...e.template?{template:e.template}:{}};if(e.image||e.libraryImage){let n=e.image;if(!n&&e.libraryImage){let t=this.libraryIndex.assets.find(t=>t.id===e.libraryImage),r=t?.path?await eu(Jl+t.path):null;if(!t?.path||!r)throw new ql(`notFound`,`Sample photo "${e.libraryImage}" is not available.`);n={name:t.path.split(`/`).pop(),bytes:r}}let r=`uploads/${n.name}`;this.uploads.set(r,n.bytes),i.image=r,i.name=t}else e.template||(i.width=e.width??1200,i.height=e.height??630,e.background!==void 0&&(i.background=e.background));try{await this.call(`project_create`,i)}finally{this.uploads.clear()}await r.save()}async recent(){return Wl.list()}async open(e){let t=await Wl.get(e);if(!t)throw new ql(`notFound`,`This project is no longer stored in this browser.`);this.title=t.title,this.thumb=t.thumb,this.attach(new Gl(t.id,t.files,()=>({title:this.title,thumb:this.thumb})))}async remove(e){await Wl.remove(e),this.fs?.id===e&&this.close()}async saveThumb(e){this.thumb=e,await this.fs?.save()}close(){this.fs&&this.fs.save(),this.fs?.listeners.delete(this.onFsChange),this.fs=null}},nu=e=>e.split(`/`).map(encodeURIComponent).join(`/`),ru=e=>new URL(e,location.href).href;async function iu(e,t,n=fetch){let r;try{r=await n(e,t)}catch(e){throw new ql(`offline`,`The Studio server is not reachable (${e.message}).`,"Is `agentphoto studio` still running?")}let i;try{i=await r.json()}catch{if(r.ok)return;throw new ql(`bad-response`,`Unexpected response from ${e} (HTTP ${r.status}).`)}if(i&&typeof i==`object`&&`ok`in i){if(!i.ok)throw new ql(i.error.code,i.error.message,i.error.hint,i.error.details);return i.data}if(!r.ok)throw new ql(`http`,`HTTP ${r.status} from ${e}.`);return i}async function au(e=fetch){try{let t=await e(`./api/info`,{headers:{accept:`application/json`}});if(!t.ok||!(t.headers.get(`content-type`)??``).includes(`json`))return null;let n=await t.json();return n.ok?n.data:null}catch{return null}}var ou=`agentphoto.studio.recentDirs`,su=class{info;mode=`cli`;version;modelSource=`cli`;toolsCache=null;libraryCache=null;progress=new Set;constructor(e){this.info=e,this.version=e.version,e.project?.exists&&lu(e.project.dir,this.projectTitle())}get location(){return this.info.project?.dir??null}hasProject(){return!!this.info.project?.exists}canCreate(){return!!this.info.project}projectTitle(){let e=this.info.project?.manifest;return e?.title||e?.name||this.info.project?.dir.split(`/`).pop()||`Untitled`}async loadDoc(){let e=await fetch(`./api/project/photo.json?ts=${Date.now()}`,{cache:`no-store`});if(!e.ok)throw new ql(`notFound`,`photo.json could not be read.`);return Ki(await e.json())}tools(){return this.toolsCache||=iu(`./api/tools`).then(e=>e.tools),this.toolsCache}call(e,t){return iu(`./api/tools/call`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e,input:t})})}library(){return this.libraryCache||=iu(`./api/library`).catch(()=>({assets:[]})),this.libraryCache}libraryBase(){return this.info.libraryBase}async modelCached(e){try{return!!(await iu(`./api/models`))?.models?.some(t=>t.id===e&&t.cached)}catch{return!1}}async templates(){try{let e=await iu(`./api/templates`);return Array.isArray(e)?e:e?.templates??[]}catch{return[]}}templatePreview(e){return`./api/templates/${encodeURIComponent(e)}/preview.jpg`}rel(e){let t=this.info.project?.dir;if(t&&e.startsWith(`${t}/`))return e.slice(t.length+1);let n=t?.replace(/^\/private\//,`/`);return n&&e.startsWith(`${n}/`)?e.slice(n.length+1):e.replace(/^\.\//,``)}async fileUrl(e){return`./api/project/${nu(this.rel(e))}?v=${Date.now()}`}async readFile(e){let t=await fetch(`./api/project/${nu(this.rel(e))}`,{cache:`no-store`});if(!t.ok)throw new ql(`notFound`,`No file ${e}.`);return new Uint8Array(await t.arrayBuffer())}async writeFile(e,t){await iu(`./api/project/${nu(e)}`,{method:`PUT`,body:t})}async listFiles(e){try{let t=await iu(`./api/project?prefix=${encodeURIComponent(e)}`);return(Array.isArray(t)?t:t?.files??[]).map(e=>typeof e==`string`?e:e.path)}catch{return[]}}async addImage(e,t){let n=ra(t),r=Ha(e,n?n.type===`jpeg`?`jpg`:n.type:`png`),i=new Set(await this.listFiles(`assets/images/`)),a=`assets/images/${r}`;for(let e=2;i.has(a);e++)a=`assets/images/${r.replace(/(\.[^.]+)?$/,`-${e}$1`)}`;return await this.writeFile(a,t),a}onChange(e){if(typeof EventSource>`u`)return()=>void 0;let t=new EventSource(`./api/events`);return t.addEventListener(`change`,t=>{try{let n=JSON.parse(String(t.data));Array.isArray(n.paths)&&e(n.paths.map(e=>this.rel(e)))}catch{}}),()=>t.close()}engineOptions(){return{assetBase:this.info.assetBase,libraryBase:this.info.libraryBase,ai:{...this.info.engineBase?{wasmPaths:ru(`${this.info.engineBase.replace(/\/?$/,`/`)}ort/`)}:{},...this.info.modelsBase?{remoteHost:ru(this.info.modelsBase.replace(/\/?$/,`/`))}:{},onProgress:e=>this.progress.forEach(t=>t(e))}}}onAiProgress(e){return this.progress.add(e),()=>this.progress.delete(e)}async createProject(e){let t={name:xi(e.title,`photo`),title:e.title,force:!0};if(e.template){if(await this.call(`project_create`,{...t,template:e.template}),e.image){let t=(await this.templates()).find(t=>t.id===e.template)?.slot,n=await this.addImage(e.image.name,e.image.bytes),r=await this.loadDoc(),i=t&&JSON.stringify(r.layers).includes(`"id":"${t}"`);await this.call(`doc_patch`,{ops:i?[{op:`updateLayer`,id:t,set:{src:n,crop:null}}]:[{op:`addLayer`,layer:{id:`photo`,type:`image`,src:n,x:0,y:0,width:r.canvas.width,height:r.canvas.height,fit:`cover`},index:0}]})}}else if(e.image){let n=ra(e.image.bytes);if(!n)throw new ql(`invalid`,`${e.image.name} is not a supported image.`);await this.call(`project_create`,{...t,width:n.width,height:n.height,background:null});let r=await this.addImage(e.image.name,e.image.bytes);await this.call(`doc_patch`,{ops:[{op:`addLayer`,layer:{id:`photo`,type:`image`,name:`Photo`,src:r,x:0,y:0,width:n.width,height:n.height}}]})}else if(e.libraryImage){let n=(await this.library()).assets.find(t=>t.id===e.libraryImage),r=n?.width??1600,i=n?.height??1067;await this.call(`project_create`,{...t,width:r,height:i,background:null}),await this.call(`doc_patch`,{ops:[{op:`addLayer`,layer:{id:`photo`,type:`image`,name:n?.title??`Photo`,src:`library:${e.libraryImage}`,x:0,y:0,width:r,height:i}}]})}else await this.call(`project_create`,{...t,width:e.width??1200,height:e.height??630,...e.background===void 0?{}:{background:e.background}});this.info=await au()??this.info,this.info.project?.exists&&lu(this.info.project.dir,this.projectTitle())}async recent(){return cu()}async open(){}close(){}};function cu(){try{let e=JSON.parse(localStorage.getItem(ou)??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function lu(e,t){try{let n=[{id:e,title:t,updatedAt:new Date().toISOString()},...cu().filter(t=>t.id!==e)].slice(0,8);localStorage.setItem(ou,JSON.stringify(n))}catch{}}var uu={app:{loading:`Loading…`,loadingDoc:`Opening the document…`,loadFailed:`The project could not be opened`,back:`Back to the start screen`},ui:{close:`Close`,cancel:`Cancel`,reset:`Reset to default`},top:{projects:`Start screen`,inBrowser:`In this browser`,undo:`Undo`,redo:`Redo`,check:`Check`,checkHint:`Look for problems before exporting (missing files, text off the canvas, blurry upscales…)`,export:`Export`,assistant:`Assistant`,shortcuts:`Keyboard shortcuts`,language:`Language`},save:{saved:`Saved`,saving:`Saving…`,pending:`Unsaved`,error:`Not saved`,errorHint:`Fix the problem (or undo) — the next change retries.`,savedToast:`Saved`},zoom:{in:`Zoom in`,out:`Zoom out`,fit:`Fit on screen`,actual:`100% (actual pixels)`,menu:`Zoom`},external:{title:`Changed by the agent`,undo:`Undo`},edit:{failed:`This change could not be applied`},check:{ok:`Ready to export: no problem found`,found:`{errors} errors · {warnings} warnings`,failed:`Check failed`},import:{done:`Added {name}`,failed:`Could not add {name}`,notImage:`{name} is not an image`},tools:{title:`Tools`,move:`Move / transform`,marquee:`Marquee selection`,crop:`Crop`,text:`Text`,shape:`Shape`,hand:`Hand`,zoom:`Zoom`,eyedropper:`Eyedropper`,lasso:`Lasso`,wand:`Magic wand`,quick:`Quick AI select`,brush:`Brush`,eraser:`Eraser`,clone:`Clone stamp`,foreground:`Foreground colour`,color:`Colour`,fill:`Fill`,smartGuides:`Smart guides`,moveHint:`Drag to move · handles resize (⇧ keeps the ratio) · top handle rotates (⇧ snaps 15°) · double-click text to edit`,textHint:`Click to type a new text · click a text layer to edit it`,shapeHint:`Drag to draw (⇧ square, Alt from the centre) · click for a default size`,eyedropperHint:`Click the picture to pick a colour (copied to the clipboard)`,picked:`Picked {color}`,pickedHint:`Set as the foreground colour and copied.`,failed:`{tool} failed`,hints:{move:`Select and transform layers.`,marquee:`Drag a selection.`,crop:`Drag the crop box, Enter to apply.`,text:`Click to add text.`,shape:`Drag to draw a shape.`,hand:`Drag to pan (or hold Space with any tool).`,zoom:`Click to zoom in, Alt-click to zoom out (or ⌘ + wheel).`,eyedropper:`Click to pick a colour.`,lasso:`Draw around an area.`,wand:`Click to select similar colours.`,quick:`Click the object to select it with AI.`,brush:`Paint on the layer.`,eraser:`Erase pixels.`,clone:`Alt-click a source, then paint.`}},ai:{removeBg:`Remove background`,removeBgHint:`local AI masks the background of the selected photo`,selectSubject:`Select subject`,selectSubjectHint:`local AI cuts the subject out to a new layer`,removingBg:`Removing the background…`,selectingSubject:`Selecting the subject…`,downloading:`Downloading {model}… {pct}%`,running:`Running the model…`,consentTitle:`Download an AI model?`,consentAccept:`Download ({size} MB)`,consentHub:`The model is downloaded once from the Hugging Face Hub and kept in this browser's cache. Your photos are processed here, in the page: they are never uploaded.`,consentCli:`The agentphoto CLI downloads the model once from the Hugging Face Hub into its local cache (~/.cache/agentphoto/models). Your photos are processed on this computer: they are never uploaded.`,privacy:`No account, no upload: only the model file is downloaded.`,license:`Licence`},lasso:{free:`Freehand`,poly:`Polygonal`,hint:`Draw around the area (Shift adds, Alt subtracts).`,polyHint:`Click points; click the first point, double-click or Enter to close. Backspace removes the last point.`},wand:{tolerance:`Tolerance`,contiguous:`Contiguous`,sampleAll:`All layers`,hint:`Click a colour (Shift adds, Alt subtracts).`},quick:{hint:`Click the object (Alt-click excludes), then Apply. Runs on this computer.`,points:`Points: {n}`,apply:`Apply`,reset:`Reset`,running:`Segmenting…`,failed:`AI selection failed`,needImage:`Click on a photo layer.`},region:{delete:`Delete (hide the selected pixels)`,copy:`Copy to a new layer`,fill:`Fill with the foreground colour`,invert:`Invert the selection`,feather:`Feather`,featherRadius:`Feather radius`,apply:`Apply`,failed:`Selection action failed`,needLayer:`Select a layer first.`,copyName:`Copy`,fillName:`Fill`},brush:{size:`Size`,hardness:`Hardness`,opacity:`Opacity`,flow:`Flow`,maskMode:`Mask`,hide:`Hide`,reveal:`Reveal`,paintPixels:`Paint pixels`,hint:`[ ] change the size · each stroke is saved as a new file (undo restores)`,newLayerHint:`Paints on a new layer above the selection`,cloneHint:`Alt-click to set the source, then paint`,sourceSet:`Clone source set`,needSource:`Alt-click to set the clone source first`,clipped:`clipped to the selection`,layerName:`Paint`,failed:`Painting failed`},marquee:{rect:`Rectangle`,ellipse:`Ellipse`,hint:`Drag to select (⇧ square, Alt from the centre), drag inside to move it.`,mask:`Mask layer`,maskHint:`Hide everything outside the selection on the selected layer`,adjust:`Adjustment`,adjustHint:`A new adjustment layer that only affects the selection`,crop:`Crop`,deselect:`Deselect`,empty:`The selection is outside the canvas`},crop:{ratio:`Ratio`,free:`Free`,original:`Original`,apply:`Apply`,cancel:`Cancel`,hint:`Enter applies · Esc cancels`},viewport:{dropHere:`Drop to add as new layers`,showingMask:`Showing the mask (white = visible).`,backToImage:`Back to the image`},status:{canvas:`Canvas size`,zoom:`Zoom`,cursor:`Cursor (document px)`,selection:`Selected layer: position · size`,errors:`{n} errors`,render:`Last render time`},panels:{resize:`Resize the layers panel`},tabs:{properties:`Properties`,filters:`Filters`,looks:`Looks`,effects:`Effects`},layerTypes:{image:`Image`,text:`Text`,shape:`Shape`,fill:`Fill`,adjustment:`Adjustment`,group:`Group`},layers:{title:`Layers`,add:`Add layer`,addImage:`Image from a file…`,addText:`Text`,addShape:`Shape`,addSolid:`Solid colour fill`,addGradient:`Gradient fill`,addAdjustment:`Adjustment layer`,addGroup:`Empty group`,solidName:`Colour fill`,gradientName:`Gradient`,adjustmentName:`Adjustment`,group:`Group`,groupSiblings:`Only layers side by side (same parent) can be grouped.`,ungroup:`Ungroup`,duplicate:`Duplicate`,delete:`Delete`,clip:`Clip to the layer below`,unclip:`Release clipping`,clipped:`Clipped to the layer below`,lock:`Lock`,unlock:`Unlock`,show:`Show`,hide:`Hide`,maskInvert:`Invert mask`,maskRemove:`Delete mask`,maskChip:`Mask — click: paint on the mask, Shift-click: enable / disable, Alt-click: show it`,rasterize:`Rasterize layer`,rasterizeEmpty:`This layer has no visible pixels.`,rasterizeFailed:`Could not rasterize the layer`,blend:`Blend mode`,opacity:`Opacity`,toggleGroup:`Expand / collapse`,canvas:`Canvas`},props:{multi:`{n} selected`,transform:`Transform`,position:`Position`,size:`Size`,rotation:`Rotation`,flipH:`Flip horizontally`,flipV:`Flip vertically`,lockRatio:`Keep the ratio`,unlockRatio:`Free ratio`,align:`Align`,alignTo:{left:`Align to the left edge`,hcenter:`Centre horizontally`,right:`Align to the right edge`,top:`Align to the top edge`,vcenter:`Centre vertically`,bottom:`Align to the bottom edge`},image:`Image`,source:`Source`,replace:`Replace the image…`,natural:`Original`,naturalHint:`Back to the image's own size, uncropped`,reset:`Reset`,fit:`Fit`,fits:{fill:`Stretch to the box`,cover:`Cover (crop the overflow)`,contain:`Contain (fit inside)`},focus:`Focus`,crop:`Crop`,addCrop:`Crop the source…`,text:`Text`,textContent:`Text content`,font:`Font`,weight:`Weight`,italic:`Italic`,color:`Colour`,alignText:`Alignment`,aligns:{left:`Left`,center:`Centre`,right:`Right`},valign:`Vertical alignment`,valigns:{top:`Top`,middle:`Middle`,bottom:`Bottom`},lineHeight:`Line height`,letterSpacing:`Letter spacing`,case:`Case`,cases:{none:`As typed`,uppercase:`UPPERCASE`,lowercase:`lowercase`},wrap:`Wrap width`,textBox:`Label box`,padding:`Padding`,radius:`Corner radius`,shape:`Shape`,shapeKind:`Kind`,fill:`Fill`,paint:`Paint`,stroke:`Stroke`,strokeWidth:`Stroke width`,dashed:`Dashed`,sides:`Sides`,points:`Points`,innerRadius:`Inner radius`,adjustment:`Adjustment`,adjustmentInfo:`Its filters apply to every layer below it (inside its group). Mask it to limit the area.`,editFilters:`Edit the filters`,group:`Group`,groupInfo:`{n} layers. Opacity, blend, mask and filters apply to the group as a whole.`},weights:{w100:`Thin`,w200:`Extra light`,w300:`Light`,w400:`Regular`,w500:`Medium`,w600:`Semibold`,w700:`Bold`,w800:`Extra bold`,w900:`Black`},fontStyles:{sans:`Sans serif`,serif:`Serif`,slab:`Slab`,display:`Display`,script:`Script`,mono:`Monospace`},shapes:{rect:`Rectangle`,ellipse:`Ellipse`,line:`Line`,polygon:`Polygon`,star:`Star`},mask:{title:`Mask`,kind:`Kind`,kinds:{image:`Pixels (PNG)`,shape:`Shape`,gradient:`Gradient fade`},enabled:`Enabled`,invert:`Invert`,feather:`Feather`,density:`Density`,shape:`Shape`,delete:`Delete the mask`,showPreview:`Show the mask`,hidePreview:`Back to the image`,fromSelection:`From selection`,needMarquee:`Draw a marquee selection first (M)`,ellipse:`Ellipse`,rect:`Rectangle`,fade:`Fade`,ai:`Local AI`,model:`Model`,aiNote:`Runs on this computer. The first use downloads the model once.`,paint:`Paint the mask`},paint:{none:`None`,solid:`Solid`,linear:`Linear`,radial:`Radial`,edit:`Edit the paint`,addStop:`Click to add a colour stop`,stop:`Stop {n}`,removeStop:`Remove stop`,position:`Position`,reverse:`Reverse`,angle:`Angle`,centerX:`Centre X`,centerY:`Centre Y`,radius:`Radius`},color:{pick:`Pick a colour`,hex:`Hex colour`,alpha:`Opacity`,value:`Colour value`,eyedropper:`Pick from the screen`},curve:{label:`Tone curve`,rgb:`RGB`,red:`Red`,green:`Green`,blue:`Blue`,hint:`Click to add a point, drag out to remove`,reset:`Reset`},filters:{title:`Filters`,hint:`Non-destructive, applied in order to this layer.`,adjustTitle:`Adjustment filters`,adjustHint:`Applied to everything below this layer.`,add:`Add filter`,search:`Search filters…`,auto:`Auto enhance`,autoWhole:`Auto enhance the picture`,analyzing:`Analysing the picture…`,autoDone:`Auto enhance: {n} corrections added`,autoNone:`The picture looks well balanced: nothing to correct`,autoName:`Auto enhance`,empty:`No filter yet`,emptyHint:`Add one, try Auto enhance, or pick a look.`,noLayer:`No layer selected`,noLayerHint:`Select a layer to edit its filters — or enhance the whole picture with an adjustment layer.`,enable:`Enable`,disable:`Disable`,remove:`Remove the filter`,reorder:`Drag to reorder`,amount:`Amount`},filterGroups:{auto:`Automatic`,light:`Light`,tone:`Tone`,color:`Colour`,detail:`Detail`,blur:`Blur`,stylize:`Stylize`,look:`Looks`},filterNames:{brightnessContrast:`Brightness / Contrast`,exposure:`Exposure`,shadowsHighlights:`Shadows / Highlights`,levels:`Levels`,curves:`Curves`,hueSaturation:`Hue / Saturation`,vibrance:`Vibrance`,temperature:`White balance`,colorBalance:`Colour balance`,photoFilter:`Photo filter`,gradientMap:`Gradient map`,grayscale:`Black & white`,sepia:`Sepia`,invert:`Invert`,threshold:`Threshold`,posterize:`Posterize`,blur:`Gaussian blur`,motionBlur:`Motion blur`,surfaceBlur:`Surface blur`,sharpen:`Sharpen`,clarity:`Clarity`,noise:`Grain / noise`,pixelate:`Pixelate`,vignette:`Vignette`,autoTone:`Auto tone`,autoContrast:`Auto contrast`,autoColor:`Auto colour`,look:`Look`},params:{brightness:`Brightness`,contrast:`Contrast`,exposure:`Exposure`,offset:`Offset`,gamma:`Gamma`,shadows:`Shadows`,highlights:`Highlights`,radius:`Radius`,black:`Black point`,white:`White point`,outBlack:`Output black`,outWhite:`Output white`,rgb:`RGB`,red:`Red`,green:`Green`,blue:`Blue`,hue:`Hue`,saturation:`Saturation`,lightness:`Lightness`,colorize:`Colorize`,vibrance:`Vibrance`,temperature:`Temperature`,tint:`Tint`,midtones:`Midtones`,preserveLuminosity:`Keep luminosity`,color:`Colour`,density:`Density`,stops:`Colours`,intensity:`Intensity`,level:`Level`,levels:`Levels`,angle:`Angle`,distance:`Distance`,threshold:`Threshold`,amount:`Amount`,monochrome:`Monochrome`,seed:`Seed`,size:`Size`,feather:`Feather`,clip:`Clip %`,look:`Look`,opacity:`Opacity`,blur:`Blur`,spread:`Spread`,width:`Width`,position:`Position`,blend:`Blend`},options:{outside:`Outside`,center:`Centre`,inside:`Inside`},blend:{normal:`Normal`,multiply:`Multiply`,screen:`Screen`,overlay:`Overlay`,darken:`Darken`,lighten:`Lighten`,colorDodge:`Colour dodge`,colorBurn:`Colour burn`,hardLight:`Hard light`,softLight:`Soft light`,difference:`Difference`,exclusion:`Exclusion`,hue:`Hue`,saturation:`Saturation`,color:`Colour`,luminosity:`Luminosity`},looks:{title:`Looks`,onLayer:`Applied to the layer “{name}”`,onPicture:`Applied to the whole picture (adjustment layer on top)`,intensity:`Intensity`,none:`None`,layerName:`Look`},lookNames:{bw:`B&W`,noir:`Noir`,sepia:`Sepia`,vintage:`Vintage`,polaroid:`Polaroid`,lomo:`Lomo`,warm:`Warm`,cool:`Cool`,sunset:`Sunset`,fade:`Fade`,punch:`Punch`,cinema:`Cinema`,cyberpunk:`Cyberpunk`,crossProcess:`Cross process`,dramatic:`Dramatic`,dreamy:`Dreamy`,matte:`Matte`,goldenHour:`Golden hour`,film:`Film`,clean:`Clean`},effects:{title:`Layer effects`,hint:`Drawn from the layer's shape, after filters and mask.`,noLayer:`No layer selected`,noLayerHint:`Select an image, text, shape or group layer to add a shadow, glow, stroke or colour overlay.`},effectNames:{dropShadow:`Drop shadow`,outerGlow:`Outer glow`,innerShadow:`Inner shadow`,stroke:`Stroke`,colorOverlay:`Colour overlay`},canvas:{title:`Canvas`,subtitle:`Nothing selected — document settings.`,size:`Canvas size`,preset:`Preset`,custom:`Custom`,anchor:`Anchor`,apply:`Resize canvas`,background:`Background`,image:`Image`,transform:`Rotate / flip`,rotateLeft:`Rotate 90° left`,rotateRight:`Rotate 90° right`,flipH:`Flip horizontally`,flipV:`Flip vertically`,resizeImage:`Image size`,resample:`Resize image`,document:`Document`,docTitle:`Title`,description:`Description`,descriptionHint:`Alt text for exports`},anchors:{"top-left":`Top left`,top:`Top`,"top-right":`Top right`,left:`Left`,center:`Centre`,right:`Right`,"bottom-left":`Bottom left`,bottom:`Bottom`,"bottom-right":`Bottom right`},sizeNames:{og:`Open Graph / link preview`,square:`Square post`,portrait:`Portrait post`,story:`Story / Reel / TikTok`,landscape:`Full HD`,youtube:`YouTube thumbnail`,twitter:`X / Twitter post`,pinterest:`Pinterest pin`,banner:`Web banner`,linkedinBanner:`LinkedIn banner`,avatar:`Avatar`,product:`Product shot`,a4:`A4 portrait (150 dpi)`},export:{title:`Export`,format:`Format`,quality:`Quality`,size:`Size`,sizes:{original:`Original size`,preset:`Size preset`,custom:`Custom size`,scale:`Scale`},preset:`Preset`,scale:`Scale`,fit:`Fit`,fits:{cover:`Cover (crop)`,contain:`Contain (pad)`,stretch:`Stretch`},background:`Background`,flatten:`Flatten transparency`,transparent:`Transparent`,name:`File name`,variants:`Quick export:`,write:`Export to dist/`,download:`Download`,downloadOne:`Download`,downloaded:`Saved {file}`,written:`{n} files written`,writtenTitle:`Written`,failed:`Export failed`,previewAlt:`Export preview`,encodedIn:`encoded in {ms} ms`,fallback:`This browser cannot encode {format}: the file is {mime}.`,noAvif:`This browser cannot encode AVIF`},keys:{title:`Keyboard shortcuts`,tools:`Tools`,general:`General`,view:`View & dragging`,undo:`Undo`,redo:`Redo`,save:`Save now`,duplicate:`Duplicate layer`,group:`Group layers`,ungroup:`Ungroup`,selectAll:`Select all layers`,delete:`Delete layer`,nudge:`Nudge 1 px`,nudge10:`Nudge 10 px`,deselect:`Deselect / cancel`,panels:`Hide / show panels`,paste:`Paste an image`,help:`This help`,fit:`Fit on screen`,actual:`Actual pixels`,zoomIn:`Zoom in`,zoomOut:`Zoom out`,zoomWheel:`Zoom at the cursor`,pan:`Pan`,keepRatio:`Keep ratio / square / 15° steps`,noSnap:`Move without snapping`,commitCrop:`Apply the crop`,dragFast:`Number fields: drag faster`,dragFine:`Number fields: drag finer`,wheelKey:`wheel`,dragKey:`drag`},assistant:{title:`Assistant`,model:`Model`,newChat:`New conversation`,settings:`API key`,close:`Close the assistant`,keyTitle:`Use Claude with your own Anthropic API key`,keyBody1:`The key stays in this browser (localStorage) and is sent only to api.anthropic.com. Images go to Claude only when a tool renders a preview.`,keyBody2:`Claude edits the document with the same tools as the CLI / MCP; every change can be undone.`,keyLabel:`Anthropic API key`,showKey:`Show the key`,hideKey:`Hide the key`,saveKey:`Save`,forgetKey:`Forget the key`,emptyTitle:`Ask for an edit, Claude does it and checks the render.`,example1:`Make this photo brighter and warmer, then show me before / after`,example2:`Remove the background and put the subject on a soft gradient`,example3:`Turn it into a YouTube thumbnail with a bold title`,placeholder:`Describe the edit…`,needKey:`Add your API key above`,send:`Send`,stop:`Stop`,working:`Working…`,undo:`Undo`,renderAlt:`Render seen by Claude`,refused:`Claude declined this request.`,stopped:`Stopped.`,maxIterations:`Stopped after many steps — ask to continue.`,toolsCount:`{n} tools`},start:{tagline:`The photo studio your AI agent can run — and you can finish by hand.`,continue:`Continue “{title}”`,cliMode:`agentphoto {v} · this folder`,localMode:`In-browser projects`,noFolderTitle:`No project folder`,noFolderBody:`This Studio server was started without a project. Create one from the terminal, then reopen the Studio:`,replaceConfirm:`Replace the project in {dir}?`,notImage:`That file is not an image.`,openTitle:`Open a photo`,openBody:`Drop a photo here or choose one: it becomes a non-destructive project — layers, masks, filters, looks, text — that an agent can edit too.`,choose:`Choose a photo`,samples:`Try a sample photo`,samplesHint:`CC0 photos bundled with AgentPhoto`,blank:`New blank canvas`,blankHint:`Social, web and print sizes`,templates:`Templates`,templatesHint:`Ready-made layouts — use your photo`,slotHint:`Your photo replaces the template's photo.`,withPhoto:`Use my photo…`,useTemplate:`Use this template`,recent:`Recent`,noRecent:`No recent project yet.`,otherFolder:"{dir} — restart `agentphoto studio --project` there to open it",remove:`Remove`,agentTitle:`Let your agent drive`,agentBody:`Claude Code, Claude or any MCP client edits the same project with the agentphoto tools and looks at the renders. Changes show up here live.`,privacyTitle:`Private by design`,privacyBody:`No server, no account: photos stay on this computer. Only AI models are downloaded, once, after you agree. The optional assistant sends Claude the previews it renders.`}},du={en:uu,fr:{app:{loading:`Chargement…`,loadingDoc:`Ouverture du document…`,loadFailed:`Impossible d'ouvrir le projet`,back:`Retour à l'accueil`},ui:{close:`Fermer`,cancel:`Annuler`,reset:`Valeur par défaut`},top:{projects:`Accueil`,inBrowser:`Dans ce navigateur`,undo:`Annuler`,redo:`Rétablir`,check:`Vérifier`,checkHint:`Chercher les problèmes avant l'export (fichiers manquants, texte hors du canevas, agrandissements flous…)`,export:`Exporter`,assistant:`Assistant`,shortcuts:`Raccourcis clavier`,language:`Langue`},save:{saved:`Enregistré`,saving:`Enregistrement…`,pending:`Non enregistré`,error:`Non enregistré`,errorHint:`Corrigez le problème (ou annulez) — la prochaine modification réessaie.`,savedToast:`Enregistré`},zoom:{in:`Zoom avant`,out:`Zoom arrière`,fit:`Ajuster à l'écran`,actual:`100 % (pixels réels)`,menu:`Zoom`},external:{title:`Modifié par l'agent`,undo:`Annuler`},edit:{failed:`Cette modification n'a pas pu être appliquée`},check:{ok:`Prêt pour l'export : aucun problème`,found:`{errors} erreurs · {warnings} avertissements`,failed:`La vérification a échoué`},import:{done:`{name} ajouté`,failed:`Impossible d'ajouter {name}`,notImage:`{name} n'est pas une image`},tools:{title:`Outils`,move:`Déplacement / transformation`,marquee:`Sélection rectangulaire`,crop:`Recadrage`,text:`Texte`,shape:`Forme`,hand:`Main`,zoom:`Zoom`,eyedropper:`Pipette`,lasso:`Lasso`,wand:`Baguette magique`,quick:`Sélection rapide IA`,brush:`Pinceau`,eraser:`Gomme`,clone:`Tampon de duplication`,foreground:`Couleur de premier plan`,color:`Couleur`,fill:`Remplissage`,smartGuides:`Repères commentés`,moveHint:`Glisser pour déplacer · poignées pour redimensionner (⇧ garde les proportions) · poignée du haut pour pivoter (⇧ par 15°) · double-clic sur un texte pour l'éditer`,textHint:`Cliquez pour saisir un nouveau texte · cliquez un calque texte pour le modifier`,shapeHint:`Glisser pour dessiner (⇧ carré, Alt depuis le centre) · clic pour une taille par défaut`,eyedropperHint:`Cliquez l'image pour prélever une couleur (copiée dans le presse-papiers)`,picked:`Couleur {color} prélevée`,pickedHint:`Définie comme couleur de premier plan et copiée.`,failed:`Échec de {tool}`,hints:{move:`Sélectionner et transformer les calques.`,marquee:`Glisser pour sélectionner.`,crop:`Ajustez le cadre, Entrée pour appliquer.`,text:`Cliquez pour ajouter du texte.`,shape:`Glisser pour dessiner une forme.`,hand:`Glisser pour se déplacer (ou maintenir Espace avec n'importe quel outil).`,zoom:`Clic pour zoomer, Alt-clic pour dézoomer (ou ⌘ + molette).`,eyedropper:`Cliquez pour prélever une couleur.`,lasso:`Dessinez autour d'une zone.`,wand:`Cliquez pour sélectionner les couleurs proches.`,quick:`Cliquez l'objet pour le sélectionner avec l'IA.`,brush:`Peindre sur le calque.`,eraser:`Effacer des pixels.`,clone:`Alt-clic sur une source, puis peignez.`}},ai:{removeBg:`Supprimer l'arrière-plan`,removeBgHint:`l'IA locale masque l'arrière-plan de la photo sélectionnée`,selectSubject:`Sélectionner le sujet`,selectSubjectHint:`l'IA locale détoure le sujet sur un nouveau calque`,removingBg:`Suppression de l'arrière-plan…`,selectingSubject:`Sélection du sujet…`,downloading:`Téléchargement de {model}… {pct} %`,running:`Exécution du modèle…`,consentTitle:`Télécharger un modèle d'IA ?`,consentAccept:`Télécharger ({size} Mo)`,consentHub:`Le modèle est téléchargé une seule fois depuis le Hugging Face Hub et conservé dans le cache de ce navigateur. Vos photos sont traitées ici, dans la page : elles ne sont jamais envoyées.`,consentCli:`La CLI agentphoto télécharge le modèle une seule fois depuis le Hugging Face Hub dans son cache local (~/.cache/agentphoto/models). Vos photos sont traitées sur cet ordinateur : elles ne sont jamais envoyées.`,privacy:`Pas de compte, pas d'envoi : seul le fichier du modèle est téléchargé.`,license:`Licence`},lasso:{free:`Main levée`,poly:`Polygonal`,hint:`Dessinez autour de la zone (Maj ajoute, Alt soustrait).`,polyHint:`Cliquez des points ; cliquez le premier point, double-cliquez ou Entrée pour fermer. Retour arrière retire le dernier point.`},wand:{tolerance:`Tolérance`,contiguous:`Pixels contigus`,sampleAll:`Tous les calques`,hint:`Cliquez une couleur (Maj ajoute, Alt soustrait).`},quick:{hint:`Cliquez l'objet (Alt-clic exclut), puis Appliquer. S'exécute sur cet ordinateur.`,points:`Points : {n}`,apply:`Appliquer`,reset:`Réinitialiser`,running:`Segmentation…`,failed:`La sélection IA a échoué`,needImage:`Cliquez sur un calque photo.`},region:{delete:`Supprimer (masquer les pixels sélectionnés)`,copy:`Copier sur un nouveau calque`,fill:`Remplir avec la couleur de premier plan`,invert:`Intervertir la sélection`,feather:`Contour progressif`,featherRadius:`Rayon du contour progressif`,apply:`Appliquer`,failed:`L'action sur la sélection a échoué`,needLayer:`Sélectionnez d'abord un calque.`,copyName:`Copie`,fillName:`Remplissage`},brush:{size:`Taille`,hardness:`Dureté`,opacity:`Opacité`,flow:`Flux`,maskMode:`Masque`,hide:`Masquer`,reveal:`Révéler`,paintPixels:`Peindre les pixels`,hint:`[ ] changent la taille · chaque trait est enregistré dans un nouveau fichier (annuler le restaure)`,newLayerHint:`Peint sur un nouveau calque au-dessus de la sélection`,cloneHint:`Alt-clic pour définir la source, puis peignez`,sourceSet:`Source de duplication définie`,needSource:`Alt-clic d'abord pour définir la source`,clipped:`limité à la sélection`,layerName:`Peinture`,failed:`La peinture a échoué`},marquee:{rect:`Rectangle`,ellipse:`Ellipse`,hint:`Glisser pour sélectionner (⇧ carré, Alt depuis le centre), glisser à l'intérieur pour la déplacer.`,mask:`Masquer le calque`,maskHint:`Masque tout ce qui est hors de la sélection sur le calque sélectionné`,adjust:`Réglage`,adjustHint:`Un nouveau calque de réglage limité à la sélection`,crop:`Recadrer`,deselect:`Désélectionner`,empty:`La sélection est hors du canevas`},crop:{ratio:`Format`,free:`Libre`,original:`Original`,apply:`Appliquer`,cancel:`Annuler`,hint:`Entrée applique · Échap annule`},viewport:{dropHere:`Déposez pour ajouter de nouveaux calques`,showingMask:`Affichage du masque (blanc = visible).`,backToImage:`Revenir à l'image`},status:{canvas:`Taille du canevas`,zoom:`Zoom`,cursor:`Curseur (px du document)`,selection:`Calque sélectionné : position · taille`,errors:`{n} erreurs`,render:`Durée du dernier rendu`},panels:{resize:`Redimensionner le panneau des calques`},tabs:{properties:`Propriétés`,filters:`Filtres`,looks:`Styles`,effects:`Effets`},layerTypes:{image:`Image`,text:`Texte`,shape:`Forme`,fill:`Remplissage`,adjustment:`Réglage`,group:`Groupe`},layers:{title:`Calques`,add:`Ajouter un calque`,addImage:`Image depuis un fichier…`,addText:`Texte`,addShape:`Forme`,addSolid:`Remplissage uni`,addGradient:`Remplissage en dégradé`,addAdjustment:`Calque de réglage`,addGroup:`Groupe vide`,solidName:`Couleur unie`,gradientName:`Dégradé`,adjustmentName:`Réglage`,group:`Grouper`,groupSiblings:`Seuls des calques voisins (même parent) peuvent être groupés.`,ungroup:`Dissocier`,duplicate:`Dupliquer`,delete:`Supprimer`,clip:`Écrêter sur le calque inférieur`,unclip:`Annuler l'écrêtage`,clipped:`Écrêté sur le calque inférieur`,lock:`Verrouiller`,unlock:`Déverrouiller`,show:`Afficher`,hide:`Masquer`,maskInvert:`Inverser le masque`,maskRemove:`Supprimer le masque`,maskChip:`Masque — clic : peindre le masque, Maj-clic : activer / désactiver, Alt-clic : l'afficher`,rasterize:`Pixelliser le calque`,rasterizeEmpty:`Ce calque n'a aucun pixel visible.`,rasterizeFailed:`Impossible de pixelliser le calque`,blend:`Mode de fusion`,opacity:`Opacité`,toggleGroup:`Déplier / replier`,canvas:`Canevas`},props:{multi:`{n} sélectionnés`,transform:`Transformation`,position:`Position`,size:`Taille`,rotation:`Rotation`,flipH:`Retourner horizontalement`,flipV:`Retourner verticalement`,lockRatio:`Conserver les proportions`,unlockRatio:`Proportions libres`,align:`Aligner`,alignTo:{left:`Aligner sur le bord gauche`,hcenter:`Centrer horizontalement`,right:`Aligner sur le bord droit`,top:`Aligner sur le bord supérieur`,vcenter:`Centrer verticalement`,bottom:`Aligner sur le bord inférieur`},image:`Image`,source:`Source`,replace:`Remplacer l'image…`,natural:`Original`,naturalHint:`Revenir à la taille propre de l'image, sans recadrage`,reset:`Réinitialiser`,fit:`Ajustement`,fits:{fill:`Étirer dans le cadre`,cover:`Couvrir (rogne le dépassement)`,contain:`Contenir (tient dans le cadre)`},focus:`Point focal`,crop:`Recadrage`,addCrop:`Recadrer la source…`,text:`Texte`,textContent:`Contenu du texte`,font:`Police`,weight:`Graisse`,italic:`Italique`,color:`Couleur`,alignText:`Alignement`,aligns:{left:`Gauche`,center:`Centre`,right:`Droite`},valign:`Alignement vertical`,valigns:{top:`Haut`,middle:`Milieu`,bottom:`Bas`},lineHeight:`Interligne`,letterSpacing:`Approche`,case:`Casse`,cases:{none:`Telle que saisie`,uppercase:`MAJUSCULES`,lowercase:`minuscules`},wrap:`Largeur de ligne`,textBox:`Étiquette`,padding:`Marge`,radius:`Arrondi`,shape:`Forme`,shapeKind:`Type`,fill:`Remplissage`,paint:`Peinture`,stroke:`Contour`,strokeWidth:`Épaisseur du contour`,dashed:`Pointillés`,sides:`Côtés`,points:`Branches`,innerRadius:`Rayon intérieur`,adjustment:`Réglage`,adjustmentInfo:`Ses filtres s'appliquent à tous les calques situés dessous (dans son groupe). Ajoutez un masque pour limiter la zone.`,editFilters:`Modifier les filtres`,group:`Groupe`,groupInfo:`{n} calques. Opacité, fusion, masque et filtres s'appliquent au groupe entier.`},weights:{w100:`Fin`,w200:`Extra-léger`,w300:`Léger`,w400:`Normal`,w500:`Medium`,w600:`Demi-gras`,w700:`Gras`,w800:`Extra-gras`,w900:`Noir`},fontStyles:{sans:`Sans empattement`,serif:`Avec empattement`,slab:`Égyptienne`,display:`Titrage`,script:`Manuscrite`,mono:`Chasse fixe`},shapes:{rect:`Rectangle`,ellipse:`Ellipse`,line:`Ligne`,polygon:`Polygone`,star:`Étoile`},mask:{title:`Masque`,kind:`Type`,kinds:{image:`Pixels (PNG)`,shape:`Forme`,gradient:`Fondu dégradé`},enabled:`Activé`,invert:`Inverser`,feather:`Contour progressif`,density:`Densité`,shape:`Forme`,delete:`Supprimer le masque`,showPreview:`Afficher le masque`,hidePreview:`Revenir à l'image`,fromSelection:`Depuis la sélection`,needMarquee:`Tracez d'abord une sélection (M)`,ellipse:`Ellipse`,rect:`Rectangle`,fade:`Fondu`,ai:`IA locale`,model:`Modèle`,aiNote:`S'exécute sur cet ordinateur. La première utilisation télécharge le modèle une fois.`,paint:`Peindre le masque`},paint:{none:`Aucune`,solid:`Unie`,linear:`Linéaire`,radial:`Radiale`,edit:`Modifier la peinture`,addStop:`Cliquez pour ajouter un point de couleur`,stop:`Point {n}`,removeStop:`Supprimer le point`,position:`Position`,reverse:`Inverser`,angle:`Angle`,centerX:`Centre X`,centerY:`Centre Y`,radius:`Rayon`},color:{pick:`Choisir une couleur`,hex:`Couleur hexadécimale`,alpha:`Opacité`,value:`Valeur de la couleur`,eyedropper:`Prélever à l'écran`},curve:{label:`Courbe de tons`,rgb:`RVB`,red:`Rouge`,green:`Vert`,blue:`Bleu`,hint:`Cliquez pour ajouter un point, glissez-le dehors pour le retirer`,reset:`Réinitialiser`},filters:{title:`Filtres`,hint:`Non destructifs, appliqués dans l'ordre à ce calque.`,adjustTitle:`Filtres du réglage`,adjustHint:`Appliqués à tout ce qui est sous ce calque.`,add:`Ajouter un filtre`,search:`Rechercher un filtre…`,auto:`Amélioration auto`,autoWhole:`Améliorer toute l'image`,analyzing:`Analyse de l'image…`,autoDone:`Amélioration auto : {n} corrections ajoutées`,autoNone:`L'image est bien équilibrée : rien à corriger`,autoName:`Amélioration auto`,empty:`Aucun filtre`,emptyHint:`Ajoutez-en un, essayez l'amélioration auto ou choisissez un style.`,noLayer:`Aucun calque sélectionné`,noLayerHint:`Sélectionnez un calque pour modifier ses filtres — ou améliorez toute l'image avec un calque de réglage.`,enable:`Activer`,disable:`Désactiver`,remove:`Supprimer le filtre`,reorder:`Glisser pour réordonner`,amount:`Intensité`},filterGroups:{auto:`Automatique`,light:`Lumière`,tone:`Tons`,color:`Couleur`,detail:`Détail`,blur:`Flou`,stylize:`Stylisation`,look:`Styles`},filterNames:{brightnessContrast:`Luminosité / Contraste`,exposure:`Exposition`,shadowsHighlights:`Tons foncés / Tons clairs`,levels:`Niveaux`,curves:`Courbes`,hueSaturation:`Teinte / Saturation`,vibrance:`Vibrance`,temperature:`Balance des blancs`,colorBalance:`Balance des couleurs`,photoFilter:`Filtre photo`,gradientMap:`Courbe de transfert de dégradé`,grayscale:`Noir et blanc`,sepia:`Sépia`,invert:`Négatif`,threshold:`Seuil`,posterize:`Postérisation`,blur:`Flou gaussien`,motionBlur:`Flou de mouvement`,surfaceBlur:`Flou de surface`,sharpen:`Netteté`,clarity:`Clarté`,noise:`Grain / bruit`,pixelate:`Pixellisation`,vignette:`Vignettage`,autoTone:`Tonalité auto`,autoContrast:`Contraste auto`,autoColor:`Couleur auto`,look:`Style`},params:{brightness:`Luminosité`,contrast:`Contraste`,exposure:`Exposition`,offset:`Décalage`,gamma:`Gamma`,shadows:`Tons foncés`,highlights:`Tons clairs`,radius:`Rayon`,black:`Point noir`,white:`Point blanc`,outBlack:`Noir en sortie`,outWhite:`Blanc en sortie`,rgb:`RVB`,red:`Rouge`,green:`Vert`,blue:`Bleu`,hue:`Teinte`,saturation:`Saturation`,lightness:`Luminosité`,colorize:`Redéfinir`,vibrance:`Vibrance`,temperature:`Température`,tint:`Teinte`,midtones:`Tons moyens`,preserveLuminosity:`Préserver la luminosité`,color:`Couleur`,density:`Densité`,stops:`Couleurs`,intensity:`Intensité`,level:`Niveau`,levels:`Niveaux`,angle:`Angle`,distance:`Distance`,threshold:`Seuil`,amount:`Intensité`,monochrome:`Monochrome`,seed:`Graine`,size:`Taille`,feather:`Adoucissement`,clip:`Écrêtage %`,look:`Style`,opacity:`Opacité`,blur:`Flou`,spread:`Grossissement`,width:`Épaisseur`,position:`Position`,blend:`Fusion`},options:{outside:`Extérieur`,center:`Centre`,inside:`Intérieur`},blend:{normal:`Normal`,multiply:`Produit`,screen:`Superposition`,overlay:`Incrustation`,darken:`Obscurcir`,lighten:`Éclaircir`,colorDodge:`Densité couleur −`,colorBurn:`Densité couleur +`,hardLight:`Lumière crue`,softLight:`Lumière tamisée`,difference:`Différence`,exclusion:`Exclusion`,hue:`Teinte`,saturation:`Saturation`,color:`Couleur`,luminosity:`Luminosité`},looks:{title:`Styles`,onLayer:`Appliqué au calque « {name} »`,onPicture:`Appliqué à toute l'image (calque de réglage au-dessus)`,intensity:`Intensité`,none:`Aucun`,layerName:`Style`},lookNames:{bw:`N&B`,noir:`Noir`,sepia:`Sépia`,vintage:`Vintage`,polaroid:`Polaroid`,lomo:`Lomo`,warm:`Chaud`,cool:`Froid`,sunset:`Coucher de soleil`,fade:`Délavé`,punch:`Éclatant`,cinema:`Cinéma`,cyberpunk:`Cyberpunk`,crossProcess:`Traitement croisé`,dramatic:`Dramatique`,dreamy:`Onirique`,matte:`Mat`,goldenHour:`Heure dorée`,film:`Argentique`,clean:`Net`},effects:{title:`Effets de calque`,hint:`Calculés d'après la forme du calque, après filtres et masque.`,noLayer:`Aucun calque sélectionné`,noLayerHint:`Sélectionnez un calque image, texte, forme ou groupe pour ajouter une ombre, une lueur, un contour ou une incrustation de couleur.`},effectNames:{dropShadow:`Ombre portée`,outerGlow:`Lueur externe`,innerShadow:`Ombre interne`,stroke:`Contour`,colorOverlay:`Incrustation de couleur`},canvas:{title:`Canevas`,subtitle:`Aucune sélection — réglages du document.`,size:`Taille du canevas`,preset:`Format`,custom:`Personnalisé`,anchor:`Ancrage`,apply:`Redimensionner le canevas`,background:`Arrière-plan`,image:`Image`,transform:`Rotation / symétrie`,rotateLeft:`Rotation 90° à gauche`,rotateRight:`Rotation 90° à droite`,flipH:`Symétrie horizontale`,flipV:`Symétrie verticale`,resizeImage:`Taille de l'image`,resample:`Redimensionner l'image`,document:`Document`,docTitle:`Titre`,description:`Description`,descriptionHint:`Texte alternatif des exports`},anchors:{"top-left":`En haut à gauche`,top:`En haut`,"top-right":`En haut à droite`,left:`À gauche`,center:`Centre`,right:`À droite`,"bottom-left":`En bas à gauche`,bottom:`En bas`,"bottom-right":`En bas à droite`},sizeNames:{og:`Open Graph / aperçu de lien`,square:`Publication carrée`,portrait:`Publication portrait`,story:`Story / Reel / TikTok`,landscape:`Full HD`,youtube:`Miniature YouTube`,twitter:`Publication X / Twitter`,pinterest:`Épingle Pinterest`,banner:`Bannière web`,linkedinBanner:`Bannière LinkedIn`,avatar:`Avatar`,product:`Photo produit`,a4:`A4 portrait (150 dpi)`},export:{title:`Exporter`,format:`Format`,quality:`Qualité`,size:`Taille`,sizes:{original:`Taille d'origine`,preset:`Format prédéfini`,custom:`Taille personnalisée`,scale:`Échelle`},preset:`Format`,scale:`Échelle`,fit:`Ajustement`,fits:{cover:`Couvrir (rogner)`,contain:`Contenir (marges)`,stretch:`Étirer`},background:`Arrière-plan`,flatten:`Aplatir la transparence`,transparent:`Transparent`,name:`Nom du fichier`,variants:`Export rapide :`,write:`Exporter dans dist/`,download:`Télécharger`,downloadOne:`Télécharger`,downloaded:`{file} enregistré`,written:`{n} fichiers écrits`,writtenTitle:`Écrits`,failed:`L'export a échoué`,previewAlt:`Aperçu de l'export`,encodedIn:`encodé en {ms} ms`,fallback:`Ce navigateur ne sait pas encoder le {format} : le fichier est en {mime}.`,noAvif:`Ce navigateur ne sait pas encoder l'AVIF`},keys:{title:`Raccourcis clavier`,tools:`Outils`,general:`Général`,view:`Affichage et glisser`,undo:`Annuler`,redo:`Rétablir`,save:`Enregistrer maintenant`,duplicate:`Dupliquer le calque`,group:`Grouper les calques`,ungroup:`Dissocier`,selectAll:`Sélectionner tous les calques`,delete:`Supprimer le calque`,nudge:`Décaler de 1 px`,nudge10:`Décaler de 10 px`,deselect:`Désélectionner / annuler`,panels:`Masquer / afficher les panneaux`,paste:`Coller une image`,help:`Cette aide`,fit:`Ajuster à l'écran`,actual:`Pixels réels`,zoomIn:`Zoom avant`,zoomOut:`Zoom arrière`,zoomWheel:`Zoomer sous le curseur`,pan:`Se déplacer`,keepRatio:`Proportions / carré / pas de 15°`,noSnap:`Déplacer sans magnétisme`,commitCrop:`Appliquer le recadrage`,dragFast:`Champs numériques : glisser plus vite`,dragFine:`Champs numériques : glisser plus finement`,wheelKey:`molette`,dragKey:`glisser`},assistant:{title:`Assistant`,model:`Modèle`,newChat:`Nouvelle conversation`,settings:`Clé d'API`,close:`Fermer l'assistant`,keyTitle:`Utilisez Claude avec votre propre clé d'API Anthropic`,keyBody1:`La clé reste dans ce navigateur (localStorage) et n'est envoyée qu'à api.anthropic.com. Les images ne partent vers Claude que lorsqu'un outil génère un aperçu.`,keyBody2:`Claude modifie le document avec les mêmes outils que la CLI / MCP ; chaque modification peut être annulée.`,keyLabel:`Clé d'API Anthropic`,showKey:`Afficher la clé`,hideKey:`Masquer la clé`,saveKey:`Enregistrer`,forgetKey:`Oublier la clé`,emptyTitle:`Demandez une retouche : Claude l'applique et vérifie le rendu.`,example1:`Éclaircis et réchauffe cette photo, puis montre-moi l'avant / après`,example2:`Supprime l'arrière-plan et pose le sujet sur un dégradé doux`,example3:`Transforme-la en miniature YouTube avec un titre percutant`,placeholder:`Décrivez la retouche…`,needKey:`Ajoutez votre clé d'API ci-dessus`,send:`Envoyer`,stop:`Arrêter`,working:`En cours…`,undo:`Annuler`,renderAlt:`Rendu vu par Claude`,refused:`Claude a refusé cette demande.`,stopped:`Arrêté.`,maxIterations:`Arrêté après de nombreuses étapes — demandez de continuer.`,toolsCount:`{n} outils`},start:{tagline:`Le studio photo que votre agent IA sait piloter — et que vous finissez à la main.`,continue:`Continuer « {title} »`,cliMode:`agentphoto {v} · ce dossier`,localMode:`Projets dans le navigateur`,noFolderTitle:`Aucun dossier de projet`,noFolderBody:`Ce serveur Studio a été lancé sans projet. Créez-en un depuis le terminal, puis rouvrez le Studio :`,replaceConfirm:`Remplacer le projet de {dir} ?`,notImage:`Ce fichier n'est pas une image.`,openTitle:`Ouvrir une photo`,openBody:`Déposez une photo ici ou choisissez-en une : elle devient un projet non destructif — calques, masques, filtres, styles, texte — qu'un agent peut aussi modifier.`,choose:`Choisir une photo`,samples:`Essayer une photo d'exemple`,samplesHint:`Photos CC0 fournies avec AgentPhoto`,blank:`Nouveau canevas vierge`,blankHint:`Formats réseaux sociaux, web et impression`,templates:`Modèles`,templatesHint:`Mises en page prêtes — avec votre photo`,slotHint:`Votre photo remplace celle du modèle.`,withPhoto:`Utiliser ma photo…`,useTemplate:`Utiliser ce modèle`,recent:`Récents`,noRecent:`Aucun projet récent.`,otherFolder:"{dir} — relancez `agentphoto studio --project` sur ce dossier pour l'ouvrir",remove:`Retirer`,agentTitle:`Laissez votre agent piloter`,agentBody:`Claude Code, Claude ou tout client MCP modifie le même projet avec les outils agentphoto et regarde les rendus. Les changements s'affichent ici en direct.`,privacyTitle:`Confidentiel par conception`,privacyBody:`Pas de serveur, pas de compte : les photos restent sur cet ordinateur. Seuls les modèles d'IA sont téléchargés, une fois, avec votre accord. L'assistant (facultatif) envoie à Claude les aperçus qu'il génère.`}}},fu=`agentphoto.studio.lang`;function pu(){try{let e=new URLSearchParams(location.search).get(`lang`);if(e===`en`||e===`fr`)return e;let t=localStorage.getItem(fu);if(t===`en`||t===`fr`)return t}catch{}return(typeof navigator<`u`?navigator.languages?.[0]??navigator.language:`en`)?.toLowerCase().startsWith(`fr`)?`fr`:`en`}var mu=pu(),hu=new Set;function gu(e){mu=e;try{localStorage.setItem(fu,e)}catch{}document.documentElement.lang=e,hu.forEach(e=>e())}function _u(){return mu}function vu(e,t){let n=e;for(let e of t.split(`.`)){if(!n||typeof n!=`object`)return;n=n[e]}return typeof n==`string`?n:void 0}function yu(e,t,n){let r=vu(du[e],t)??vu(uu,t)??t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>t in n?String(n[t]):e):r}function bu(e,t=mu){return vu(du[t],e)??vu(uu,e)}function V(e,t){return yu(mu,e,t)}function H(){return{t:V,lang:(0,S.useSyncExternalStore)(e=>(hu.add(e),()=>hu.delete(e)),()=>mu),setLang:gu}}function xu(e){try{return new URLSearchParams(location.search).get(e)??new URLSearchParams(location.hash.replace(/^#/,``)).get(e)}catch{return null}}function Su(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Su(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function U(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Su(e))&&(r&&(r+=` `),r+=t);return r}var Cu=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),W=t(((e,t)=>{t.exports=Cu()}))();function wu({variant:e=`subtle`,size:t=`sm`,className:n,...r}){return(0,W.jsx)(`button`,{type:`button`,...r,className:U(`inline-flex select-none items-center justify-center gap-1.5 whitespace-nowrap rounded-md font-medium transition-colors disabled:pointer-events-none disabled:opacity-40 [&>svg]:shrink-0`,t===`xs`&&`h-6 px-2 text-xs`,t===`sm`&&`h-7 px-2.5 text-sm`,t===`md`&&`h-8 px-3.5 text-base`,e===`ghost`&&`text-fg-muted hover:bg-ink-3 hover:text-fg`,e===`subtle`&&`bg-ink-3 text-fg hover:bg-ink-4`,e===`primary`&&`bg-accent text-ink-0 hover:bg-accent/90`,e===`danger`&&`bg-danger/15 text-danger hover:bg-danger/25`,n)})}function G({label:e,active:t,className:n,children:r,shortcut:i,...a}){return(0,W.jsx)(`button`,{type:`button`,"aria-label":e,title:i?`${e} (${i})`:e,"aria-pressed":t,...a,className:U(`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-35`,t?`bg-accent/15 text-accent`:`text-fg-muted hover:bg-ink-3 hover:text-fg`,n),children:r})}function Tu({value:e,onCommit:t,placeholder:n,className:r,multiline:i,mono:a,ariaLabel:o}){let[s,c]=(0,S.useState)(e);(0,S.useEffect)(()=>{c(e)},[e]);let l=()=>s!==e&&t(s),u={value:s,placeholder:n,"aria-label":o,onChange:e=>c(e.target.value),onBlur:l};return i?(0,W.jsx)(`textarea`,{...u,rows:2,onKeyDown:t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&l(),t.key===`Escape`&&c(e)},className:U(`field h-auto min-h-[44px] resize-y py-1 leading-snug`,a&&`font-mono text-xs`,r)}):(0,W.jsx)(`input`,{...u,spellCheck:!1,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&(c(e),requestAnimationFrame(()=>t.target.blur()))},className:U(`field`,a&&`font-mono text-xs`,r)})}function Eu({value:e,options:t,onChange:n,className:r,ariaLabel:i,placeholder:a}){return(0,W.jsxs)(`select`,{"aria-label":i,value:e,onChange:e=>n(e.target.value),className:U(`field`,r),children:[a!==void 0&&(0,W.jsx)(`option`,{value:``,children:a}),t.map(e=>{let t=typeof e==`string`?e:e.value;return(0,W.jsx)(`option`,{value:t,children:typeof e==`string`?e:e.label},t)})]})}function Du({checked:e,onChange:t,ariaLabel:n}){return(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,onClick:()=>t(!e),className:U(`relative h-4 w-7 shrink-0 rounded-full transition-colors`,e?`bg-accent`:`bg-ink-4`),children:(0,W.jsx)(`span`,{className:U(`absolute top-0.5 h-3 w-3 rounded-full bg-white shadow transition-[left]`,e?`left-[14px]`:`left-0.5`)})})}function K({label:e,children:t,hint:n,onReset:r,overridden:i,align:a=`center`}){return(0,W.jsxs)(`div`,{className:U(`group grid grid-cols-[86px_minmax(0,1fr)_14px] gap-x-2 px-3 py-[3px]`,a===`center`?`items-center`:`items-start`),children:[(0,W.jsx)(`div`,{className:U(`line-clamp-2 break-words text-xs leading-tight text-fg-muted [hyphens:auto]`,a===`start`&&`pt-1`),title:typeof e==`string`?n?`${e} — ${n}`:e:n,children:e}),(0,W.jsx)(`div`,{className:`flex min-w-0 items-center gap-1`,children:t}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:r&&i&&(0,W.jsx)(`button`,{type:`button`,title:V(`ui.reset`),"aria-label":V(`ui.reset`),onClick:r,className:`text-fg-faint opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,children:(0,W.jsx)(sn,{size:11})})})]})}function Ou({title:e,children:t,defaultOpen:n=!0,actions:r,id:i}){let a=i?`agentphoto.section.${i}`:null,[o,s]=(0,S.useState)(()=>{if(!a)return n;try{let e=localStorage.getItem(a);return e===null?n:e===`1`}catch{return n}});return(0,W.jsxs)(`section`,{className:`border-b border-line`,children:[(0,W.jsxs)(`div`,{className:`flex h-8 items-center gap-1 pl-2 pr-2`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{s(e=>{try{a&&localStorage.setItem(a,e?`0`:`1`)}catch{}return!e})},"aria-expanded":o,className:`flex min-w-0 flex-1 items-center gap-1 text-left text-xs font-semibold text-fg`,children:[o?(0,W.jsx)(we,{size:12,className:`text-fg-faint`}):(0,W.jsx)(Ee,{size:12,className:`text-fg-faint`}),(0,W.jsx)(`span`,{className:`truncate`,children:e})]}),r]}),o&&(0,W.jsx)(`div`,{className:`pb-2`,children:t})]})}function ku({children:e}){return(0,W.jsx)(`kbd`,{className:`rounded border border-line bg-ink-2 px-1 font-sans text-2xs text-fg-muted`,children:e})}function Au({icon:e,title:t,children:n}){return(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-8 text-center`,children:[e&&(0,W.jsx)(`div`,{className:`text-fg-faint`,children:e}),(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg-muted`,children:t}),n&&(0,W.jsx)(`div`,{className:`text-xs text-fg-faint`,children:n})]})}function ju(e){let t=e,n=new Set;return{get:()=>t,set(e){let r=typeof e==`function`?e(t):e;t={...t,...r},n.forEach(e=>e())},subscribe(e){return n.add(e),()=>n.delete(e)}}}function Mu(e,t){return(0,S.useSyncExternalStore)(e.subscribe,()=>t(e.get()))}var Nu=(0,S.createContext)(null);function q(){let e=(0,S.useContext)(Nu);if(!e)throw Error(`useEditor outside EditorContext`);return e}function Pu(){let{store:e}=q();return(0,S.useSyncExternalStore)(e.subscribe,e.getSnapshot)}function Fu(){return Pu().doc}function J(e){return Mu(q().ui,e)}function Iu(){let e=Pu(),t=e.selection[e.selection.length-1];return!t||!e.doc?null:N(e.doc.layers,t)?.layer??null}var Lu=[`claude-sonnet-5-5`,`claude-opus-5-5`,`claude-haiku-5-5`],Ru=`https://api.anthropic.com/v1/messages`,zu=class extends Error{status;constructor(e,t){super(t),this.status=e}};function Bu(e){return/\.jpe?g$/i.test(e)?`image/jpeg`:/\.webp$/i.test(e)?`image/webp`:`image/png`}function Vu(e,t=24e3){return e.length>t?`${e.slice(0,t)}\n… (truncated, ${e.length-t} more characters)`:e}async function Hu(e,t,n){let r=e.fetchImpl??fetch,i={"content-type":`application/json`,"x-api-key":e.apiKey,"anthropic-version":`2023-06-01`,"anthropic-dangerous-direct-browser-access":`true`};n&&(i[`anthropic-beta`]=`server-side-fallback-2026-07-01`);let a=await r(Ru,{method:`POST`,headers:i,body:JSON.stringify(n?{...t,fallbacks:`default`}:t),signal:e.signal}),o=await a.json().catch(()=>({}));if(!a.ok){let e=o.error?.message??`HTTP ${a.status}`;throw new zu(a.status,e)}return o}async function Uu(e){let t=[...e.messages],n=e.tools.map(e=>({name:e.name,description:e.description,input_schema:e.inputSchema})),r=e.fallbacks??e.model!==`claude-haiku-5-5`,i=e.maxIterations??25;for(let a=0;a<i;a++){if(e.signal?.aborted)return{messages:t,status:`aborted`};let i={model:e.model,max_tokens:e.maxTokens??16e3,system:e.system,tools:n,messages:t},a;try{try{a=await Hu(e,i,r)}catch(t){if(r&&t instanceof zu&&t.status===400&&/fallback|beta/i.test(t.message))r=!1,a=await Hu(e,i,!1);else throw t}}catch(e){return e.name===`AbortError`?{messages:t,status:`aborted`}:{messages:t,status:`error`,error:e.message}}let o=a.content??[];t.push({role:`assistant`,content:o});for(let t of o)t.type===`text`&&typeof t.text==`string`&&t.text.trim()&&e.onEvent({type:`text`,text:t.text});if(a.stop_reason===`refusal`)return e.onEvent({type:`refusal`,explanation:a.stop_details?.explanation}),{messages:t,status:`refusal`};let s=o.filter(e=>e.type===`tool_use`);if(a.stop_reason!==`tool_use`||!s.length)return{messages:t,status:`done`};let c=[];for(let n of s){if(e.signal?.aborted)return{messages:t,status:`aborted`};e.onEvent({type:`tool_start`,id:n.id,name:n.name,input:n.input??{}});try{let t=await e.callTool(n.name,n.input??{}),r=[{type:`text`,text:Vu(JSON.stringify(t))}],i=[];for(let a of e.readImage?Hs(n.name,t).slice(0,4):[]){let t=await e.readImage(a).catch(()=>null);t&&(r.push({type:`image`,source:{type:`base64`,media_type:Bu(a),data:t}}),i.push(a))}c.push({type:`tool_result`,tool_use_id:n.id,content:r}),e.onEvent({type:`tool_end`,id:n.id,name:n.name,result:t,images:i})}catch(t){let r=t,i=JSON.stringify({error:r.message,...r.hint?{hint:r.hint}:{},...r.details?{details:r.details}:{}});c.push({type:`tool_result`,tool_use_id:n.id,content:[{type:`text`,text:Vu(i)}],is_error:!0}),e.onEvent({type:`tool_end`,id:n.id,name:n.name,error:r.message})}}t.push({role:`user`,content:c})}return{messages:t,status:`max_iterations`}}var Wu=`You are the assistant inside AgentPhoto Studio, a non-destructive photo editor. The user sees the document live in the Studio while you work; every change you make through the tools is saved to the project's photo.json and shown immediately (each mutating call can be undone from the Studio).
12
+
13
+ The document (PhotoDoc, photo.json): { version: 1, id, title?, description?, canvas: { width, height, background? (CSS colour | gradient | null = transparent) }, layers: [...] (bottom → top), export? }. Layer common fields: id, type, name?, visible?, locked?, opacity (0..1), blend (normal, multiply, screen, overlay, soft-light…), mask?, clip? (clip to the layer below), filters? ([{ type, ...params, amount?, enabled? }], applied in order), effects? ({ dropShadow, outerGlow, innerShadow, stroke, colorOverlay }). Types: image { src ("assets/…" or "library:<id>"), x, y, width, height, rotation, flipX/Y, crop?, fit: fill|cover|contain, focus? }; text { text, font (catalog id), size, weight, italic, color (colour or gradient), align, valign, lineHeight, letterSpacing, transform, width (wrap), background? (label box) }; shape { shape: rect|ellipse|line|polygon|star, x, y, width, height, fill, stroke, radius, sides, innerRadius }; fill { fill } (covers the canvas); adjustment { filters } (filters everything below it, inside its group); group { children }. Paint = CSS colour | { type: "linear", stops, angle } | { type: "radial", stops, cx, cy, radius }. Masks: { src } (PNG) | { shape: rect|ellipse, x, y, width, height } | { gradient } + invert, feather, density, enabled — layer-local px for image / text / shape layers, canvas px otherwise. Coordinates are canvas px, origin top-left; angles in degrees. Filters, looks, effects, blend modes, fonts, sizes and AI models come from the catalog (catalog_get).
14
+
15
+ Rules:
16
+ - Start with doc_summary to see what exists (layer ids are stable; use them).
17
+ - Before colour / exposure corrections, call image_analyze (on the photo layer) and use its measurements and suggested filters instead of guessing.
18
+ - Prefer small doc_patch edits (updateLayer, addFilter, updateFilter, setMask, addLayer…) over replacing the whole document. Use catalog_get before any filter, look, font or parameter you are not sure about.
19
+ - Prefer non-destructive solutions: adjustment layers and masks rather than heavy filters on the photo; remove_background writes a mask, it does not erase pixels.
20
+ - After every visual change, call render_preview and look at the image you get back: check exposure, colours, skin tones, edges of cut-outs (render_preview { zoom } on hair / fingers), text legibility and placement (nothing cut at the edges), then fix and render again. Use compare: true to see before / after.
21
+ - The user may have a layer selected in the Studio: the context message says which; act on it when the request is ambiguous.
22
+ - Run check before suggesting an export; export only when asked (variants: og, square, story…).
23
+ - Be concise: say what you changed in one or two sentences.`,Gu=`agentphoto.studio.anthropicKey`,Ku=`agentphoto.studio.model`,qu=e=>{try{return localStorage.getItem(e)??``}catch{return``}},Ju=(e,t)=>{try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}},Yu=new Map,Xu=0,Y=()=>`i${Date.now().toString(36)}${(Xu++).toString(36)}`;function Zu(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function X(e){if(!e||typeof e!=`object`)return;let t=e;if(t.plan?.summary)return`${t.status??``} · ${t.plan.summary}`;if(t.status)return t.status}function Z(e,t){if(e===`doc_patch`&&Array.isArray(t.ops))return t.ops.map(e=>`${e.op} ${e.path??e.id??``}`.trim()).slice(0,3).join(`, `)+(t.ops.length>3?`…`:``);if(e===`catalog_get`)return[t.section,t.id].filter(Boolean).join(` / `);if(e===`layer_update`||e===`layer_remove`||e===`remove_background`||e===`mask_generate`||e===`mask_set`||e===`filter_add`)return[t.id,t.filter?.type,t.method].filter(Boolean).join(` · `);if(e===`layer_add`)return String(t.layer?.id??``);let n=JSON.stringify(t);return n===`{}`?``:n.slice(0,80)}function Qu({text:e}){let t=(e,t)=>e.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((e,n)=>e.startsWith("`")&&e.endsWith("`")?(0,W.jsx)(`code`,{className:`rounded bg-ink-3 px-1 font-mono text-2xs`,children:e.slice(1,-1)},`${t}${n}`):e.startsWith(`**`)&&e.endsWith(`**`)?(0,W.jsx)(`strong`,{children:e.slice(2,-2)},`${t}${n}`):e);return(0,W.jsx)(`div`,{className:`space-y-1.5`,children:e.split(/\n{2,}/).map((e,n)=>/^\s*[-*] /.test(e)?(0,W.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.split(`
24
+ `).map((e,r)=>(0,W.jsx)(`li`,{children:t(e.replace(/^\s*[-*] /,``),`${n}-${r}-`)},r))},n):(0,W.jsx)(`p`,{className:`whitespace-pre-wrap`,children:t(e,`${n}-`)},n))})}function $u(){let{t:e}=H(),{backend:t,store:n,tools:r,reloadDoc:i,ui:a}=q(),o=t.location??`default`,[s,c]=(0,S.useState)(()=>Yu.get(o)??{messages:[],items:[]}),[l,u]=(0,S.useState)(()=>qu(Gu)),[d,f]=(0,S.useState)(()=>qu(Ku)||`claude-sonnet-5-5`),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(!1),y=(0,S.useRef)(null),b=(0,S.useRef)(null),x=(0,S.useRef)(s);x.current=s,(0,S.useEffect)(()=>{Yu.set(o,s)},[s,o]),(0,S.useEffect)(()=>{b.current?.scrollIntoView({block:`end`})},[s.items.length]),(0,S.useEffect)(()=>()=>y.current?.abort(),[]);let ee=e=>c(t=>({...t,items:e(t.items)})),te=(e,t)=>ee(n=>n.map(n=>n.kind===`tool`&&n.id===e?{...n,...t}:n)),C=async()=>{let a=h.trim();if(!a||_||!l)return;g(``),v(!0);let o=new AbortController;y.current=o;let s=n.getSnapshot(),u=s.selection,f=u.length&&s.doc?N(s.doc.layers,u[u.length-1])?.layer:null,p=`[Studio] Project: ${t.projectTitle()}.${s.doc?` Canvas ${s.doc.canvas.width}×${s.doc.canvas.height}.`:``}${f?` Selected layer: "${f.id}" (${f.type})${u.length>1?`, ${u.length} layers selected: ${u.join(`, `)}`:``}.`:` Nothing selected.`}`,m=[...x.current.messages,{role:`user`,content:[{type:`text`,text:p},{type:`text`,text:a}]}];c(e=>({messages:m,items:[...e.items,{kind:`user`,id:Y(),text:a}]})),await n.flush();let b=new Set(r.filter(e=>e.mutating).map(e=>e.name)),S=new Map,C=``,w=await Uu({apiKey:l,model:d,system:Wu,messages:m,tools:r,signal:o.signal,callTool:async(e,r)=>{let a=C;if(b.has(e)){await n.flush();let e=n.getSnapshot().doc;e&&S.set(a,e)}let o=await t.call(e,r);return b.has(e)&&await i({toast:!1}).catch(()=>void 0),o},readImage:async e=>Zu(await t.readFile(e)),onEvent:n=>{n.type===`text`?ee(e=>[...e,{kind:`assistant`,id:Y(),text:n.text}]):n.type===`tool_start`?(C=n.id,ee(e=>[...e,{kind:`tool`,id:n.id,name:n.name,input:n.input,status:`running`,mutating:b.has(n.name)}])):n.type===`tool_end`?(async()=>{let e=(await Promise.all((n.images??[]).map(e=>t.fileUrl(e).catch(()=>``)))).filter(Boolean);te(n.id,{status:n.error?`error`:`done`,error:n.error,summary:X(n.result),images:e,before:S.get(n.id)})})():n.type===`refusal`&&ee(t=>[...t,{kind:`notice`,id:Y(),text:n.explanation??e(`assistant.refused`),tone:`error`}])}});y.current=null,v(!1),c(t=>({messages:w.messages,items:[...t.items,...w.status===`error`?[{kind:`notice`,id:Y(),text:w.error??`Error`,tone:`error`}]:[],...w.status===`aborted`?[{kind:`notice`,id:Y(),text:e(`assistant.stopped`)}]:[],...w.status===`max_iterations`?[{kind:`notice`,id:Y(),text:e(`assistant.maxIterations`)}]:[]]}))},w=!!l;return(0,W.jsxs)(`aside`,{className:`flex w-[360px] shrink-0 flex-col border-l border-line bg-ink-1`,"aria-label":e(`assistant.title`),children:[(0,W.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-line pl-3 pr-1.5`,children:[(0,W.jsx)(me,{size:15,className:`text-agent`}),(0,W.jsx)(`span`,{className:`text-sm font-semibold`,children:e(`assistant.title`)}),(0,W.jsx)(`select`,{value:d,onChange:e=>(f(e.target.value),Ju(Ku,e.target.value)),"aria-label":e(`assistant.model`),className:`ml-1 h-6 rounded bg-transparent px-1 text-2xs text-fg-muted outline-none hover:bg-ink-3`,children:Lu.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}),(0,W.jsxs)(`div`,{className:`ml-auto flex`,children:[(0,W.jsx)(G,{label:e(`assistant.newChat`),disabled:_,onClick:()=>c({messages:[],items:[]}),children:(0,W.jsx)(Ln,{size:14})}),(0,W.jsx)(G,{label:e(`assistant.settings`),active:p,onClick:()=>m(e=>!e),children:(0,W.jsx)(yn,{size:14})}),(0,W.jsx)(G,{label:e(`assistant.close`),onClick:()=>a.set({assistant:!1}),children:(0,W.jsx)(_r,{size:14})})]})]}),(!w||p)&&(0,W.jsx)(ed,{apiKey:l,onSave:e=>(u(e),Ju(Gu,e||null),m(!1))}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2.5 overflow-auto px-3 py-3 text-sm`,children:[!s.items.length&&w&&(0,W.jsxs)(`div`,{className:`space-y-2 pt-4 text-center`,children:[(0,W.jsx)(`div`,{className:`text-sm text-fg-muted`,children:e(`assistant.emptyTitle`)}),(0,W.jsx)(`div`,{className:`flex flex-col gap-1`,children:[e(`assistant.example1`),e(`assistant.example2`),e(`assistant.example3`)].map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>g(e),className:`rounded-md border border-line px-2.5 py-1.5 text-left text-xs text-fg-muted hover:border-fg-faint hover:text-fg`,children:e},e))})]}),s.items.map(t=>t.kind===`user`?(0,W.jsx)(`div`,{className:`ml-8 rounded-lg bg-accent/15 px-3 py-2 text-fg`,children:t.text},t.id):t.kind===`assistant`?(0,W.jsx)(`div`,{className:`leading-relaxed text-fg`,children:(0,W.jsx)(Qu,{text:t.text})},t.id):t.kind===`notice`?(0,W.jsx)(`div`,{className:U(`rounded-md px-2.5 py-1.5 text-xs`,t.tone===`error`?`bg-danger/10 text-danger`:`bg-ink-2 text-fg-muted`),children:t.text},t.id):(0,W.jsxs)(`div`,{className:U(`rounded-md border bg-ink-0/40`,t.mutating&&t.status===`done`?`border-agent/30`:`border-line`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[t.status===`running`?(0,W.jsx)(Mt,{size:12,className:`animate-spin text-fg-muted`}):t.status===`error`?(0,W.jsx)(Oe,{size:12,className:`text-danger`}):t.status===`undone`?(0,W.jsx)(sn,{size:12,className:`text-fg-faint`}):t.mutating?(0,W.jsx)(Qt,{size:12,className:`text-agent`}):(0,W.jsx)(Se,{size:12,className:`text-fg-faint`}),(0,W.jsx)(`span`,{className:`font-mono text-2xs text-fg`,children:t.name}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-2xs text-fg-faint`,children:Z(t.name,t.input)}),t.mutating&&t.status===`done`&&t.before&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>{n.replace(t.before),te(t.id,{status:`undone`})},className:`rounded px-1.5 py-0.5 text-2xs font-medium text-accent hover:bg-ink-3`,children:e(`assistant.undo`)})]}),(t.summary||t.error)&&(0,W.jsx)(`div`,{className:U(`border-t border-line/70 px-2.5 py-1 text-2xs`,t.error?`text-danger`:`text-fg-muted`),children:t.error??t.summary}),!!t.images?.length&&(0,W.jsx)(`div`,{className:U(`grid gap-px border-t border-line/70`,t.images.length>1&&`grid-cols-2`),children:t.images.map(t=>(0,W.jsx)(`img`,{src:t,alt:e(`assistant.renderAlt`),className:`checker-sm block w-full`},t))})]},t.id)),_&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,W.jsx)(Mt,{size:12,className:`animate-spin`}),` `,e(`assistant.working`)]}),(0,W.jsx)(`div`,{ref:b})]}),(0,W.jsxs)(`div`,{className:`shrink-0 border-t border-line p-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-end gap-1.5 rounded-lg border border-line bg-ink-2 p-1.5 focus-within:border-accent/60`,children:[(0,W.jsx)(`textarea`,{value:h,rows:2,disabled:!w,placeholder:e(w?`assistant.placeholder`:`assistant.needKey`),onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),C())},className:`max-h-40 min-h-[36px] flex-1 resize-none bg-transparent px-1 text-sm outline-none placeholder:text-fg-faint`}),_?(0,W.jsx)(G,{label:e(`assistant.stop`),onClick:()=>y.current?.abort(),children:(0,W.jsx)(zn,{size:13,fill:`currentColor`})}):(0,W.jsx)(G,{label:e(`assistant.send`),disabled:!h.trim()||!w,onClick:()=>void C(),className:`text-accent`,children:(0,W.jsx)(_n,{size:14})})]}),(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 px-1 text-2xs text-fg-faint`,children:[(0,W.jsx)(hr,{size:10}),` `,e(`assistant.toolsCount`,{n:r.length})]})]})]})}function ed({apiKey:e,onSave:t}){let{t:n}=H(),[r,i]=(0,S.useState)(e),[a,o]=(0,S.useState)(!1);return(0,W.jsxs)(`div`,{className:`shrink-0 space-y-2.5 border-b border-line bg-ink-0/40 p-3 text-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(vt,{size:14,className:`mt-0.5 shrink-0 text-key`}),(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:n(`assistant.keyTitle`)}),(0,W.jsx)(`p`,{children:n(`assistant.keyBody1`)}),(0,W.jsx)(`p`,{children:n(`assistant.keyBody2`)})]})]}),(0,W.jsxs)(`div`,{className:`flex gap-1`,children:[(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(`input`,{type:a?`text`:`password`,value:r,onChange:e=>i(e.target.value),placeholder:`sk-ant-…`,autoComplete:`off`,spellCheck:!1,"aria-label":n(`assistant.keyLabel`),className:`field h-7 pr-7 font-mono`}),(0,W.jsx)(`button`,{type:`button`,"aria-label":n(a?`assistant.hideKey`:`assistant.showKey`),onClick:()=>o(e=>!e),className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-fg-faint hover:text-fg`,children:a?(0,W.jsx)(He,{size:12}):(0,W.jsx)(We,{size:12})})]}),(0,W.jsx)(wu,{size:`sm`,variant:`primary`,disabled:!r.trim()||r.trim()===e,onClick:()=>t(r.trim()),children:n(`assistant.saveKey`)})]}),e&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>(i(``),t(``)),className:`text-2xs text-fg-faint hover:text-danger`,children:n(`assistant.forgetKey`)})]})}var td=[],nd=0,rd=new Set,id=()=>rd.forEach(e=>e());function Q(e,t=4200){let n=++nd;return td=[...td.slice(-3),{...e,id:n}],id(),setTimeout(()=>ad(n),t),n}function ad(e){td=td.filter(t=>t.id!==e),id()}var od={info:(0,W.jsx)(gt,{size:14,className:`text-accent`}),success:(0,W.jsx)(Se,{size:14,className:`text-agent`}),error:(0,W.jsx)(Oe,{size:14,className:`text-danger`}),agent:(0,W.jsx)(me,{size:14,className:`text-agent`})};function sd(){let e=(0,S.useSyncExternalStore)(e=>(rd.add(e),()=>rd.delete(e)),()=>td);return(0,W.jsx)(`div`,{"aria-live":`polite`,className:`pointer-events-none absolute bottom-3 left-1/2 z-40 flex w-[min(420px,90%)] -translate-x-1/2 flex-col items-center gap-1.5`,children:e.map(e=>(0,W.jsxs)(`div`,{className:U(`toast-in pointer-events-auto flex w-full items-start gap-2 rounded-lg border bg-ink-1/95 px-3 py-2 shadow-lg shadow-black/40 backdrop-blur`,e.tone===`agent`?`border-agent/40`:e.tone===`error`?`border-danger/40`:`border-line`),children:[(0,W.jsx)(`div`,{className:`mt-0.5`,children:od[e.tone]}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium`,children:e.title}),e.detail&&(0,W.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.detail})]}),e.action&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>{e.action.run(),ad(e.id)},className:`shrink-0 rounded px-1.5 py-0.5 text-xs font-medium text-accent hover:bg-ink-3`,children:e.action.label})]},e.id))})}function cd(e,t,n=`application/octet-stream`){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),setTimeout(()=>URL.revokeObjectURL(i),2e3)}async function ld(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function ud(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function dd(e,t){return`data:${t};base64,${ud(e)}`}async function fd(e,t,n){let r=window;if(typeof r.showSaveFilePicker==`function`)try{let i=e.split(`.`).pop()??``,a=await(await r.showSaveFilePicker({suggestedName:e,types:[{description:i.toUpperCase(),accept:{[n]:[`.${i}`]}}]})).createWritable();return await a.write(new Blob([t],{type:n})),await a.close(),`saved`}catch(e){if(e.name===`AbortError`)return`cancelled`}return cd(e,t,n),`downloaded`}function pd(e,t){return Si(xi(t,`layer`),da(e))}var md={image:`Image`,text:`Text`,shape:`Shape`,fill:`Fill`,adjustment:`Adjustment`,group:`Group`};function hd(e){return e.name?e.name:e.type===`text`?e.text.split(`
25
+ `)[0].slice(0,40)||md.text:e.id}function gd(e){return md[e]}function _d(e,t,n,r={}){let i=r.size??Math.max(24,Math.round(Math.min(e.canvas.width,e.canvas.height)/12));return{id:pd(e,`text`),type:`text`,text:n,font:r.font??`inter`,size:i,weight:700,color:r.color??`#ffffff`,x:Math.round(t.x),y:Math.round(t.y)}}function vd(e,t,n,r){let i={id:pd(e,t),type:`shape`,shape:t,x:Math.round(n.x),y:Math.round(n.y),width:Math.max(1,Math.round(n.width)),height:Math.max(1,Math.round(n.height))};return t===`line`?{...i,fill:null,stroke:{color:r,width:Math.max(2,Math.round(Math.min(e.canvas.width,e.canvas.height)/200))}}:{...i,fill:r,...t===`polygon`?{sides:6}:t===`star`?{sides:5,innerRadius:.5}:{}}}function yd(e,t,n,r,i){let a=e.canvas.width,o=e.canvas.height,s=Math.min(1,a/n.width,o/n.height),c=Math.max(1,Math.round(n.width*s)),l=Math.max(1,Math.round(n.height*s)),u=i?.x??a/2,d=i?.y??o/2;return{id:pd(e,r.replace(/\.[^.]+$/,``)||`image`),type:`image`,name:r.replace(/\.[^.]+$/,``),src:t,x:Math.round(u-c/2),y:Math.round(d-l/2),width:c,height:l}}function bd(e,t){return t&&N(e.layers,t)?{above:t}:{}}function xd(e,t,n,r){let i=N(e.layers,n);if(!i)return null;let a=t.filter(t=>t!==n&&N(e.layers,t));for(let t of a)if(fa(N(e.layers,t).layer,n))return null;return a.length?r===`inside`?i.layer.type===`group`?a.map(e=>({op:`moveLayer`,id:e,parent:n})):null:(r===`above`?[...a].reverse():a).map(e=>({op:`moveLayer`,id:e,[r]:n})):null}function Sd(e,t){let n=t.map(t=>N(e.layers,t)).filter(e=>!!e);if(!n.length)return null;let r=n[0].container;return n.some(e=>e.container!==r)?null:n.sort((e,t)=>e.index-t.index).map(e=>e.layer.id)}function Cd(e,t){let n=Sd(e,t);if(!n)return null;let r=pd(e,`group`);return{ops:[{op:`groupLayers`,ids:n,id:r,name:`Group ${da(e).filter(e=>e.startsWith(`group`)).length+1}`}],id:r}}function wd(e,t,n=0,r=null){let i=[];for(let a=e.length-1;a>=0;a--){let o=e[a];i.push({layer:o,depth:n,parent:r}),o.type===`group`&&!t.has(o.id)&&i.push(...wd(o.children??[],t,n+1,o.id))}return i}function Td(e,t,n,r){let i=[],a=new Set,o=e=>{e.locked||a.has(e.id)||(a.add(e.id),e.type===`image`||e.type===`text`||e.type===`shape`?i.push({op:`updateLayer`,id:e.id,set:{x:(e.x??0)+n,y:(e.y??0)+r}}):e.type===`group`&&(e.children??[]).forEach(o))};for(let n of t){let t=N(e.layers,n);t&&o(t.layer)}return i}function Ed({title:e,onClose:t,children:n,footer:r,width:i=560}){let a=(0,S.useRef)(null);return(0,S.useEffect)(()=>{let e=document.activeElement;a.current?.focus();let n=e=>e.key===`Escape`&&t();return window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`keydown`,n),e?.focus?.()}},[t]),(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,W.jsxs)(`div`,{ref:a,tabIndex:-1,role:`dialog`,"aria-modal":`true`,className:`toast-in flex max-h-[86vh] w-full flex-col overflow-hidden rounded-xl border border-line bg-ink-1 shadow-2xl shadow-black/50 outline-none focus-visible:outline-none`,style:{maxWidth:i},children:[(0,W.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-line pl-4 pr-2`,children:[(0,W.jsx)(`div`,{className:`text-base font-semibold`,children:e}),(0,W.jsx)(G,{label:V(`ui.close`),onClick:t,children:(0,W.jsx)(_r,{size:15})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:n}),r&&(0,W.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-line px-4 py-2.5`,children:r})]})})}var Dd=`agentphoto.studio.modelConsent.`;function Od(e){try{return localStorage.getItem(Dd+e)===`1`}catch{return!1}}function kd(e){try{localStorage.setItem(Dd+e,`1`)}catch{}}function Ad(){let{t:e}=H(),{backend:t}=q(),n=J(e=>e.consent);if(!n)return null;let r=si(n.model);return(0,W.jsx)(Ed,{title:e(`ai.consentTitle`),width:460,onClose:()=>n.resolve(!1),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(wu,{variant:`ghost`,onClick:()=>n.resolve(!1),children:e(`ui.cancel`)}),(0,W.jsxs)(wu,{variant:`primary`,onClick:()=>{kd(n.model),n.resolve(!0)},children:[(0,W.jsx)(Re,{size:13}),` `,e(`ai.consentAccept`,{size:r?.sizeMb??`?`})]})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-line bg-ink-2/50 p-3`,children:[(0,W.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-agent/15 text-agent`,children:(0,W.jsx)(Re,{size:16})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[r?.id,` `,(0,W.jsxs)(`span`,{className:`text-fg-faint`,children:[`· `,r?.sizeMb,` MB`]})]}),(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:r?.description}),(0,W.jsxs)(`div`,{className:`mt-1 text-2xs text-fg-faint`,children:[e(`ai.license`),`: `,r?.license,` · `,r?.repo]})]})]}),(0,W.jsx)(`p`,{className:`text-fg-muted`,children:t.modelSource===`hub`?e(`ai.consentHub`):e(`ai.consentCli`)}),(0,W.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-fg-muted`,children:[(0,W.jsx)(Cn,{size:14,className:`mt-0.5 shrink-0 text-agent`}),` `,e(`ai.privacy`)]})]})})}function jd(){let e=J(e=>e.busy);return e?(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-30 flex justify-center`,children:(0,W.jsxs)(`div`,{className:`toast-in pointer-events-auto flex min-w-[260px] items-center gap-2.5 rounded-lg border border-agent/30 bg-ink-1/95 px-3 py-2 shadow-xl shadow-black/40 backdrop-blur`,children:[(0,W.jsx)(Mt,{size:14,className:`animate-spin text-agent`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm`,children:e.label}),e.progress!==void 0&&(0,W.jsx)(`div`,{className:`mt-1 h-1 overflow-hidden rounded-full bg-ink-3`,children:(0,W.jsx)(`div`,{className:`h-full rounded-full bg-agent transition-[width]`,style:{width:`${Math.round(e.progress*100)}%`}})})]})]})}):null}function Md({r:e,g:t,b:n,a:r}){let i=e/255,a=t/255,o=n/255,s=Math.max(i,a,o),c=s-Math.min(i,a,o),l=0;return c&&(l=s===i?(a-o)/c%6:s===a?(o-i)/c+2:(i-a)/c+4,l*=60,l<0&&(l+=360)),{h:l,s:s?c/s:0,v:s,a:r??1}}function Nd({h:e,s:t,v:n,a:r}){let i=n*t,a=i*(1-Math.abs(e/60%2-1)),o=n-i,[s,c,l]=e<60?[i,a,0]:e<120?[a,i,0]:e<180?[0,i,a]:e<240?[0,a,i]:e<300?[a,0,i]:[i,0,a];return{r:Math.round((s+o)*255),g:Math.round((c+o)*255),b:Math.round((l+o)*255),a:r}}function Pd(e){let t=_i(e),n=e.a??1;return n>=1?t:`${t}${Math.round(Math.max(0,Math.min(1,n))*255).toString(16).padStart(2,`0`)}`}function Fd(e,t=`#000000`){return Md(hi(e)??hi(t))}function Id(e){return Pd(Nd(e))}var Ld=e=>e&&typeof e==`object`?e.type:`solid`;function Rd(e){let t=Array.isArray(e.stops)&&e.stops.length?e.stops:[`#000000`,`#ffffff`],n=t.length;return t.map((e,t)=>Array.isArray(e)?[Math.min(1,Math.max(0,Number(e[0])||0)),String(e[1])]:[n===1?0:t/(n-1),String(e)])}function zd(e){return[...e].sort((e,t)=>e[0]-t[0])}function Bd(e,t){let n=zd(e);if(!n.length)return`#000000`;if(t<=n[0][0])return n[0][1];for(let e=1;e<n.length;e++)if(t<=n[e][0]){let r=hi(n[e-1][1])??{r:0,g:0,b:0,a:1},i=hi(n[e][1])??{r:0,g:0,b:0,a:1},a=(t-n[e-1][0])/Math.max(1e-6,n[e][0]-n[e-1][0]);return Pd({r:r.r+(i.r-r.r)*a,g:r.g+(i.g-r.g)*a,b:r.b+(i.b-r.b)*a,a:(r.a??1)+((i.a??1)-(r.a??1))*a})}return n[n.length-1][1]}function Vd(e,t=`#000000`){return e?typeof e==`string`?e:Rd(e)[0]?.[1]??t:t}function Hd(e){if(!e)return`transparent`;if(typeof e==`string`)return e;let t=zd(Rd(e)).map(([e,t])=>`${t} ${Math.round(e*1e3)/10}%`).join(`, `);return e.type===`radial`?`radial-gradient(circle at ${(e.cx??.5)*100}% ${(e.cy??.5)*100}%, ${t})`:`linear-gradient(${(e.angle??90)+90}deg, ${t})`}function Ud(e,t,n=`#ffffff`){let r=Vd(e,n);if(t===`solid`)return r;let i=e&&typeof e==`object`?Rd(e):[[0,r],[1,`#000000`]];return t===`linear`?{type:`linear`,angle:e&&typeof e==`object`&&e.type===`linear`?e.angle??90:90,stops:i}:{type:`radial`,cx:.5,cy:.5,radius:1,stops:i}}var Wd=l();function Gd({trigger:e,children:t,width:n=280,align:r=`end`,anchorClass:i=`flex min-w-0`}){let[a,o]=(0,S.useState)(!1),s=(0,S.useRef)(null),c=(0,S.useRef)(null),[l,u]=(0,S.useState)(null);return(0,S.useLayoutEffect)(()=>{if(!a||!s.current)return;let e=()=>{let e=s.current.getBoundingClientRect(),t=window.innerWidth,i=window.innerHeight,a=r===`end`?e.right-n:e.left;a=Math.max(8,Math.min(t-n-8,a));let o=i-e.bottom-12,l=e.top-12,d=c.current?.scrollHeight??320;u(o>=Math.min(d,260)||o>=l?{left:a,top:e.bottom+4,maxHeight:o}:{left:a,top:Math.max(8,e.top-4-Math.min(d,l)),maxHeight:l})};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a,n,r]),(0,S.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.target;!s.current?.contains(t)&&!c.current?.contains(t)&&o(!1)},t=e=>e.key===`Escape`&&(e.stopPropagation(),o(!1));return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t,!0)}},[a]),(0,W.jsxs)(`div`,{ref:s,className:i,children:[e(()=>o(e=>!e),a),a&&(0,Wd.createPortal)((0,W.jsx)(`div`,{ref:c,className:`toast-in fixed z-50 overflow-auto rounded-lg border border-line bg-ink-1 shadow-xl shadow-black/50`,style:{width:n,left:l?.left??-9999,top:l?.top??-9999,maxHeight:l?.maxHeight??400},children:t(()=>o(!1))}),document.body)]})}function Kd({onClick:e,children:t,open:n,ariaLabel:r}){return(0,W.jsx)(`button`,{type:`button`,"aria-label":r,"aria-expanded":n,onClick:e,className:`field flex items-center gap-1.5 text-left ${n?`border-accent/70 bg-ink-1`:``}`,style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23989fae' fill='none' stroke-width='1.2'/%3E%3C/svg%3E")`,backgroundRepeat:`no-repeat`,backgroundPosition:`right 6px center`,paddingRight:18},children:t})}var qd=`agentphoto.studio.recentColors`,Jd=[`#ffffff`,`#000000`,`#e5e7eb`,`#6b7280`,`#ef4444`,`#f97316`,`#f59e0b`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`,`#6366f1`,`#a855f7`,`#ec4899`,`#7c8cff`];function Yd(){try{let e=JSON.parse(localStorage.getItem(qd)??`[]`);return Array.isArray(e)?e.filter(e=>gi(e)).slice(0,8):[]}catch{return[]}}function Xd(e){try{localStorage.setItem(qd,JSON.stringify([e,...Yd().filter(t=>t!==e)].slice(0,8)))}catch{}}function Zd(e){let t=(0,S.useRef)(null),n=(n,r)=>{let i=t.current.getBoundingClientRect();e(Math.max(0,Math.min(1,(n.clientX-i.left)/i.width)),Math.max(0,Math.min(1,(n.clientY-i.top)/i.height)),r)};return{ref:t,onPointerDown:e=>{e.target.setPointerCapture(e.pointerId),n(e,!1)},onPointerMove:e=>e.buttons===1&&n(e,!1),onPointerUp:e=>n(e,!0)}}function Qd({value:e,onChange:t,alpha:n=!0}){let[r,i]=(0,S.useState)(()=>Fd(e)),[a,o]=(0,S.useState)(null),s=(0,S.useRef)(e);(0,S.useEffect)(()=>{if(e===s.current)return;s.current=e;let t=Fd(e);i(e=>({...t,h:t.s===0||t.v===0?e.h:t.h}))},[e]);let c=(e,r)=>{i(e);let a=Id(n?e:{...e,a:1});s.current=a,t(a,r),r&&Xd(a)},l=Zd((e,t,n)=>c({...r,s:e,v:1-t},n)),u=Zd((e,t,n)=>c({...r,h:Math.min(359.9,e*360)},n)),d=Zd((e,t,n)=>c({...r,a:Math.round(e*100)/100},n)),f=Pd({...Nd({...r,a:1}),a:1}),p=Pd({...Nd({h:r.h,s:1,v:1,a:1}),a:1}),m=Yd(),h=typeof window<`u`&&`EyeDropper`in window;return(0,W.jsxs)(`div`,{className:`w-[232px] select-none space-y-2.5 p-2.5`,children:[(0,W.jsx)(`div`,{...l,className:`relative h-[150px] cursor-crosshair rounded-md`,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${p})`},children:(0,W.jsx)(`div`,{className:`pointer-events-none absolute h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(0,0,0,0.4)]`,style:{left:`${r.s*100}%`,top:`${(1-r.v)*100}%`,background:f}})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h&&(0,W.jsx)(`button`,{type:`button`,title:V(`color.eyedropper`),"aria-label":V(`color.eyedropper`),onClick:async()=>{try{let e=await new window.EyeDropper().open();c({...Fd(e.sRGBHex),a:r.a},!0)}catch{}},className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-ink-3 hover:text-fg`,children:(0,W.jsx)(en,{size:14})}),(0,W.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,W.jsx)(`div`,{...u,className:`relative h-2.5 cursor-pointer rounded-full`,style:{background:`linear-gradient(to right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)`},children:(0,W.jsx)($d,{at:r.h/360,color:p})}),n&&(0,W.jsxs)(`div`,{...d,className:`checker-sm relative h-2.5 cursor-pointer rounded-full`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 rounded-full`,style:{background:`linear-gradient(to right, transparent, ${f})`}}),(0,W.jsx)($d,{at:r.a,color:f})]})]})]}),(0,W.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,W.jsx)(`input`,{"aria-label":V(`color.hex`),spellCheck:!1,value:a??f,onFocus:e=>(o(f),requestAnimationFrame(()=>e.target.select())),onChange:e=>o(e.target.value),onBlur:()=>{let e=(a??``).trim();o(null);let t=hi(e.startsWith(`#`)||!/^[0-9a-f]{3,8}$/i.test(e)?e:`#${e}`);t&&c({...Fd(Pd(t)),a:n?t.a:1},!0)},onKeyDown:e=>e.key===`Enter`&&e.target.blur(),className:`field h-7 flex-1 font-mono text-xs uppercase`}),n&&(0,W.jsxs)(`div`,{className:`flex h-7 w-[58px] items-center rounded-[5px] bg-ink-2 pr-1.5`,children:[(0,W.jsx)(`input`,{"aria-label":V(`color.alpha`),inputMode:`numeric`,value:Math.round(r.a*100),onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&c({...r,a:Math.max(0,Math.min(100,t))/100},!0)},className:`h-full w-full min-w-0 bg-transparent px-1.5 text-right text-sm tabular-nums outline-none`}),(0,W.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:`%`})]})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-8 gap-1`,children:[...m,...Jd].slice(0,16).map((e,t)=>(0,W.jsx)(`button`,{type:`button`,title:e,"aria-label":e,onClick:()=>c({...Fd(e),a:n?hi(e)?.a??1:1},!0),className:`checker-sm relative h-5 overflow-hidden rounded-[4px] ring-1 ring-white/10 hover:ring-white/40`,children:(0,W.jsx)(`span`,{className:`absolute inset-0`,style:{background:e}})},`${e}${t}`))})]})}function $d({at:e,color:t}){return(0,W.jsx)(`div`,{className:`pointer-events-none absolute top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(0,0,0,0.45)]`,style:{left:`${e*100}%`,background:t}})}function ef({css:e,onClick:t,open:n,ariaLabel:r,className:i}){return(0,W.jsx)(`button`,{type:`button`,"aria-label":r??V(`color.pick`),"aria-expanded":n,onClick:t,className:U(`checker-sm relative h-6 w-6 shrink-0 overflow-hidden rounded-[5px] ring-1 ring-inset ring-white/10 hover:ring-white/30`,n&&`ring-accent`,i),children:(0,W.jsx)(`span`,{className:`absolute inset-0`,style:{background:e}})})}function tf({value:e,onChange:t,alpha:n=!0,compact:r}){let[i,a]=(0,S.useState)(null);return(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,W.jsx)(Gd,{width:232,align:`start`,trigger:(t,n)=>(0,W.jsx)(ef,{css:gi(e)?e:`transparent`,onClick:t,open:n}),children:()=>(0,W.jsx)(Qd,{value:e,onChange:t,alpha:n})}),!r&&(0,W.jsx)(`input`,{"aria-label":V(`color.value`),spellCheck:!1,value:i??e,onChange:e=>a(e.target.value),onBlur:()=>{i!==null&&gi(i.trim())&&t(i.trim(),!0),a(null)},onKeyDown:e=>e.key===`Enter`&&e.target.blur(),className:`field font-mono text-xs`})]})}function nf(e,t){let n=t;return e.min!==void 0&&(n=Math.max(e.min,n)),e.max!==void 0&&(n=Math.min(e.max,n)),e.integer&&(n=Math.round(n)),n}function rf(e,t=3){if(!Number.isFinite(e))return`0`;let n=Number(e.toFixed(t));return Object.is(n,-0)?`0`:String(n)}function af(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:`${(e/1048576).toFixed(2)} MB`}function of({value:e,onChange:t,label:n,labelClass:r,step:i,min:a,max:o,integer:s,suffix:c,placeholder:l,empty:u,ariaLabel:d,className:f}){let[p,m]=(0,S.useState)(null),h=(0,S.useRef)(null),g=(0,S.useRef)(null),_=i??(s?1:Math.abs(e)>=10?.1:.01),v=e=>nf({min:a,max:o,integer:s},e);(0,S.useEffect)(()=>{m(null)},[e]);let y=()=>{if(p===null)return;let n=Number(p.replace(`,`,`.`));m(null),Number.isFinite(n)&&n!==e&&t(v(n),!0)},b=t=>{t.button===0&&(t.target.setPointerCapture(t.pointerId),h.current={x:t.clientX,start:e,moved:!1,last:e},t.preventDefault())},x=e=>{let n=h.current;if(!n)return;let r=e.clientX-n.x;if(!n.moved&&Math.abs(r)<2)return;n.moved=!0;let i=e.shiftKey?10:e.altKey?.1:1,a=n.start+r*_*i,o=s?0:Math.max(0,Math.ceil(-Math.log10(_*i))),c=v(Number(a.toFixed(Math.min(o,6))));c!==n.last&&(n.last=c,t(c,!1))},ee=e=>{let n=h.current;h.current=null,e.target.releasePointerCapture?.(e.pointerId),n&&(n.moved?t(n.last,!0):g.current?.focus())};return(0,W.jsxs)(`div`,{className:U(`flex h-6 min-w-0 flex-1 items-center rounded-[5px] border border-transparent bg-ink-2 focus-within:border-accent/70 focus-within:bg-ink-1 hover:border-line`,f),children:[n!==void 0&&(0,W.jsx)(`span`,{onPointerDown:b,onPointerMove:x,onPointerUp:ee,className:U(`flex h-full w-4 shrink-0 cursor-ew-resize select-none items-center justify-center text-2xs font-semibold`,r??`text-fg-faint`),children:n}),(0,W.jsx)(`input`,{ref:g,"aria-label":d??n,inputMode:`decimal`,value:p??(u?``:rf(e,s?0:3)),placeholder:u?`auto`:void 0,onPointerDown:n===void 0?b:void 0,onPointerMove:n===void 0?x:void 0,onPointerUp:n===void 0?ee:void 0,onFocus:t=>{m(rf(e,s?0:3)),requestAnimationFrame(()=>t.target.select())},onChange:e=>m(e.target.value),onBlur:y,onKeyDown:n=>{if(n.key===`Enter`)n.target.blur();else if(n.key===`Escape`)m(null),requestAnimationFrame(()=>n.target.blur());else if(n.key===`ArrowUp`||n.key===`ArrowDown`){n.preventDefault();let r=v(Number(((Number(p??e)||0)+(n.key===`ArrowUp`?1:-1)*_*(n.shiftKey?10:1)).toFixed(6)));m(rf(r,s?0:3)),t(r,!0)}},className:U(`h-full w-full min-w-0 bg-transparent px-1 text-sm tabular-nums outline-none`,n===void 0&&`cursor-ew-resize focus:cursor-text`,l&&p===null?`text-fg-faint`:`text-fg`)}),c&&(0,W.jsx)(`span`,{className:`pr-1.5 text-2xs text-fg-faint`,children:c})]})}function sf({value:e,min:t,max:n,onChange:r,integer:i,placeholder:a,empty:o,ariaLabel:s,step:c}){let l=n-t||1,u=c??(i?1:l<=2?.01:l<=20?.05:l/200),d=o?0:Math.max(0,Math.min(1,(e-t)/l))*100;return(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`relative flex h-6 min-w-0 flex-1 items-center`,children:[(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 h-[3px] rounded-full bg-ink-4`,children:(0,W.jsx)(`div`,{className:U(`h-full rounded-full`,a?`bg-fg-faint/50`:`bg-accent`),style:{width:`${d}%`}})}),(0,W.jsx)(`input`,{type:`range`,min:t,max:n,step:u,value:Number.isFinite(e)?e:t,"aria-label":s,onChange:e=>r(nf({min:t,max:n,integer:i},Number(e.target.value)),!1),onPointerUp:e=>r(nf({min:t,max:n,integer:i},Number(e.target.value)),!0),onKeyUp:e=>r(nf({min:t,max:n,integer:i},Number(e.target.value)),!0),className:U(`slider relative h-6 w-full cursor-pointer appearance-none bg-transparent`,o&&`opacity-40`)})]}),(0,W.jsx)(of,{value:e,min:t,max:n,integer:i,placeholder:a,empty:o,onChange:r,ariaLabel:s,className:`w-[52px] flex-none`,step:u})]})}function cf(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}var lf=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase()),uf=(e,t)=>bu(`params.${e}`)??cf(e),df=e=>bu(`blend.${lf(e)}`)??cf(e),ff=(e,t)=>Ir.includes(t)?df(t):bu(`options.${lf(t)}`)??cf(t),pf=e=>bu(`filterNames.${e}`)??ri(e)?.title??cf(e),mf=e=>bu(`filterGroups.${e}`)??cf(e),hf=e=>bu(`effectNames.${e}`)??ii(e)?.title??cf(e),gf=e=>bu(`sizeNames.${lf(e)}`)??oi(e)?.title??cf(e),_f=e=>bu(`lookNames.${lf(e)}`)??Kr.find(t=>t.id===e)?.title??cf(e),vf={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`,"image/avif":`avif`},yf=null;function bf(){return yf||=(async()=>{try{let e=wc(2,2);return(`convertToBlob`in e?await e.convertToBlob({type:`image/avif`}):await new Promise(t=>e.toBlob(t,`image/avif`)))?.type===`image/avif`}catch{return!1}})(),yf}function xf(){let{t:e}=H(),t=q(),n=Fu(),r=n.export??{},[i,a]=(0,S.useState)(r.format??`png`),[o,s]=(0,S.useState)(r.quality??Cs[r.format??`png`]),[c,l]=(0,S.useState)(`original`),[u,d]=(0,S.useState)(`og`),[f,p]=(0,S.useState)(n.canvas.width),[m,h]=(0,S.useState)(n.canvas.height),[g,_]=(0,S.useState)(1),[v,y]=(0,S.useState)(`cover`),[b,x]=(0,S.useState)(!!r.background),[ee,te]=(0,S.useState)(r.background??`#ffffff`),[C,w]=(0,S.useState)(r.name??n.id??`photo`),[T,ne]=(0,S.useState)(!1),[re,ie]=(0,S.useState)(null),[ae,oe]=(0,S.useState)(!1),[se,ce]=(0,S.useState)(!1),[le,ue]=(0,S.useState)([]);(0,S.useEffect)(()=>{bf().then(ne)},[]);let de=(0,S.useMemo)(()=>({format:i,quality:o,...c===`preset`?{preset:u,fit:v}:c===`custom`?{width:f,height:m,fit:v}:c===`scale`?{scale:g}:{},background:b||i===`jpeg`?ee:null,name:C}),[i,o,c,u,v,f,m,g,b,ee,C]),fe=(0,S.useMemo)(()=>{try{return{job:ws(n,de),error:null}}catch(e){return{job:null,error:e.message}}},[n,de]);(0,S.useEffect)(()=>{let e=fe.job;if(!e)return;let r=!0;oe(!0);let i=setTimeout(async()=>{let i=performance.now();try{let a=await t.engine.exportImage(n,e);if(!r)return;let o=URL.createObjectURL(new Blob([a.bytes],{type:a.mime}));ie(e=>(e&&URL.revokeObjectURL(e.url),{url:o,bytes:a.bytes,mime:a.mime,width:a.width,height:a.height,ms:Math.round(performance.now()-i)}))}catch{}finally{r&&oe(!1)}},350);return()=>{r=!1,clearTimeout(i)}},[fe.job,n,t]),(0,S.useEffect)(()=>()=>void(re&&URL.revokeObjectURL(re.url)),[]);let pe=()=>t.ui.set({dialog:null}),me=Ss[i],he=re&&fe.job&&re.mime!==fe.job.mime,ge=async r=>{ce(!0);try{if(t.backend.mode===`cli`){let n=await t.runTool(`export`,r);if(n?.files){let r=await Promise.all(n.files.map(async e=>({...e,url:await t.backend.fileUrl(e.path)})));ue(e=>[...r,...e].slice(0,6)),Q({tone:`success`,title:e(`export.written`,{n:r.length}),detail:r.map(e=>e.path).join(`, `)})}}else{let i=ws(n,r),a=re&&r===de?re:await t.engine.exportImage(n,i),o=vf[a.mime]??Ss[i.format],s=`${i.file.split(`/`).pop().replace(/\.[^.]+$/,``)}.${o}`;await fd(s,a.bytes,a.mime)!==`cancelled`&&Q({tone:`success`,title:e(`export.downloaded`,{file:s})})}}catch(t){Q({tone:`error`,title:e(`export.failed`),detail:t.message})}finally{ce(!1)}};return(0,W.jsx)(Ed,{title:e(`export.title`),width:880,onClose:pe,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mr-auto flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,W.jsx)(`span`,{children:e(`export.variants`)}),[`og`,`square`,`story`].map(e=>(0,W.jsx)(wu,{size:`xs`,variant:`ghost`,disabled:se,onClick:()=>void ge({...de,preset:e,fit:`cover`,width:void 0,height:void 0,scale:void 0}),title:gf(e),children:e},e))]}),(0,W.jsx)(wu,{variant:`ghost`,onClick:pe,children:e(`ui.close`)}),(0,W.jsxs)(wu,{variant:`primary`,disabled:!fe.job||se,onClick:()=>void ge(de),children:[se?(0,W.jsx)(Mt,{size:13,className:`animate-spin`}):t.backend.mode===`cli`?(0,W.jsx)(dr,{size:13}):(0,W.jsx)(Re,{size:13}),t.backend.mode===`cli`?e(`export.write`):e(`export.download`)]})]}),children:(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_320px]`,children:[(0,W.jsxs)(`div`,{className:`flex min-h-[420px] flex-col border-r border-line bg-ink-0/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`relative flex flex-1 items-center justify-center overflow-hidden rounded-lg bg-ink-0`,children:[re?(0,W.jsx)(`img`,{src:re.url,alt:e(`export.previewAlt`),className:`checker max-h-[440px] max-w-full object-contain shadow-lg shadow-black/50`}):(0,W.jsx)(Mt,{size:18,className:`animate-spin text-fg-faint`}),ae&&re&&(0,W.jsx)(`div`,{className:`absolute right-2 top-2 rounded bg-black/60 p-1`,children:(0,W.jsx)(Mt,{size:12,className:`animate-spin text-white/80`})})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 text-xs text-fg-muted`,children:[(0,W.jsx)(Ke,{size:13}),fe.job&&(0,W.jsxs)(`span`,{className:`tabular-nums text-fg`,children:[fe.job.width,` × `,fe.job.height,` px`]}),re&&(0,W.jsx)(`span`,{className:`tabular-nums`,children:af(re.bytes.byteLength)}),re&&(0,W.jsx)(`span`,{className:`text-fg-faint`,children:re.mime}),re&&(0,W.jsx)(`span`,{className:`ml-auto text-fg-faint`,children:e(`export.encodedIn`,{ms:re.ms})})]}),he&&(0,W.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 text-xs text-warn`,children:[(0,W.jsx)(rr,{size:12}),` `,e(`export.fallback`,{format:i.toUpperCase(),mime:re.mime})]}),fe.error&&(0,W.jsx)(`div`,{className:`mt-2 text-xs text-danger`,children:fe.error})]}),(0,W.jsxs)(`div`,{className:`space-y-0.5 py-3`,children:[(0,W.jsx)(K,{label:e(`export.format`),children:(0,W.jsx)(`div`,{className:`flex flex-1 rounded-md bg-ink-2 p-0.5`,children:xs.map(t=>(0,W.jsx)(`button`,{type:`button`,disabled:t===`avif`&&!T,title:t===`avif`&&!T?e(`export.noAvif`):void 0,onClick:()=>(a(t),s(Cs[t])),className:U(`h-6 flex-1 rounded text-xs font-medium uppercase disabled:opacity-30`,i===t?`bg-ink-4 text-fg`:`text-fg-muted hover:text-fg`),children:t===`jpeg`?`jpg`:t},t))})}),i!==`png`&&(0,W.jsx)(K,{label:e(`export.quality`),children:(0,W.jsx)(sf,{value:o,min:1,max:100,integer:!0,onChange:e=>s(e),ariaLabel:e(`export.quality`)})}),(0,W.jsx)(K,{label:e(`export.size`),children:(0,W.jsx)(Eu,{value:c,options:[`original`,`preset`,`custom`,`scale`].map(t=>({value:t,label:e(`export.sizes.${t}`)})),onChange:e=>l(e),ariaLabel:e(`export.size`)})}),c===`preset`&&(0,W.jsx)(K,{label:e(`export.preset`),children:(0,W.jsx)(Eu,{value:u,options:Zr.map(e=>({value:e.id,label:`${gf(e.id)} · ${e.width}×${e.height}`})),onChange:d,ariaLabel:e(`export.preset`)})}),c===`custom`&&(0,W.jsxs)(K,{label:e(`props.size`),children:[(0,W.jsx)(of,{label:`W`,value:f,min:1,max:16384,integer:!0,onChange:e=>p(e)}),(0,W.jsx)(of,{label:`H`,value:m,min:1,max:16384,integer:!0,onChange:e=>h(e)})]}),c===`scale`&&(0,W.jsx)(K,{label:e(`export.scale`),children:(0,W.jsx)(sf,{value:g,min:.05,max:4,step:.05,onChange:e=>_(e),ariaLabel:e(`export.scale`)})}),(c===`preset`||c===`custom`)&&(0,W.jsx)(K,{label:e(`export.fit`),children:(0,W.jsx)(Eu,{value:v,options:[`cover`,`contain`,`stretch`].map(t=>({value:t,label:e(`export.fits.${t}`)})),onChange:e=>y(e),ariaLabel:e(`export.fit`)})}),(0,W.jsxs)(K,{label:e(`export.background`),children:[(0,W.jsx)(Du,{checked:b||i===`jpeg`,onChange:x,ariaLabel:e(`export.flatten`)}),(b||i===`jpeg`)&&(0,W.jsx)(tf,{value:ee,alpha:!1,onChange:e=>te(e)}),!b&&i!==`jpeg`&&(0,W.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e(`export.transparent`)})]}),(0,W.jsxs)(K,{label:e(`export.name`),children:[(0,W.jsx)(Tu,{value:C,onCommit:e=>w(e.trim()||n.id),ariaLabel:e(`export.name`)}),(0,W.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`.`,me]})]}),t.backend.mode===`cli`&&fe.job&&(0,W.jsxs)(`div`,{className:`px-3 pt-2 font-mono text-2xs text-fg-faint`,children:[`→ `,fe.job.file]}),le.length>0&&(0,W.jsxs)(`div`,{className:`mx-3 mt-3 space-y-1 rounded-lg border border-agent/30 bg-agent/5 p-2`,children:[(0,W.jsx)(`div`,{className:`text-2xs font-semibold uppercase tracking-wide text-agent`,children:e(`export.writtenTitle`)}),le.map(t=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-2xs`,children:t.path}),(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums text-fg-faint`,children:[t.kb,` KB`]}),(0,W.jsx)(`a`,{href:t.url,download:t.path.split(`/`).pop(),className:`shrink-0 text-accent hover:underline`,children:e(`export.downloadOne`)})]},t.path+t.url))]})]})]})})}var Sf=[{hx:-1,hy:-1},{hx:0,hy:-1},{hx:1,hy:-1},{hx:1,hy:0},{hx:1,hy:1},{hx:0,hy:1},{hx:-1,hy:1},{hx:-1,hy:0}],Cf=e=>e*Math.PI/180;function wf(e,t){let n=Cf(t);return{x:e.x*Math.cos(n)-e.y*Math.sin(n),y:e.x*Math.sin(n)+e.y*Math.cos(n)}}var Tf=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function Ef(e,t){let n=Tf(e),r=wf({x:t.hx*e.width/2,y:t.hy*e.height/2},e.rotation);return{x:n.x+r.x,y:n.y+r.y}}function Df(e,t,n,r,i=1){let a=Tf(e),o=wf({x:n.x-a.x,y:n.y-a.y},-e.rotation),s=-t.hx*e.width/2,c=-t.hy*e.height/2,l=t.hx?Math.max(i,(o.x-s)*t.hx):e.width,u=t.hy?Math.max(i,(o.y-c)*t.hy):e.height;if(r&&e.width>0&&e.height>0){let n;n=t.hx&&t.hy?Math.max(l/e.width,u/e.height):t.hx?l/e.width:u/e.height,l=Math.max(i,e.width*n),u=Math.max(i,e.height*n)}let d=wf({x:t.hx?s+t.hx*l/2:0,y:t.hy?c+t.hy*u/2:0},e.rotation),f=a.x+d.x,p=a.y+d.y;return{x:f-l/2,y:p-u/2,width:l,height:u}}function Of(e,t,n,r){let i=Tf(e),a=Math.atan2(t.y-i.y,t.x-i.x),o=Math.atan2(n.y-i.y,n.x-i.x),s=e.rotation+(o-a)*180/Math.PI;return r&&(s=Math.round(s/15)*15),s=((s+180)%360+360)%360-180,Math.round(s*10)/10}function kf(e,t,n){let r=(e,t)=>{let r=null;for(let i of e)for(let e of t){let t=e-i;Math.abs(t)<=n&&(!r||Math.abs(t)<Math.abs(r.d))&&(r={d:t,at:e})}return r},i=r([e.x,e.x+e.width/2,e.x+e.width],t.xs),a=r([e.y,e.y+e.height/2,e.y+e.height],t.ys),o=[];return i&&o.push({axis:`x`,at:i.at}),a&&o.push({axis:`y`,at:a.at}),{dx:i?.d??0,dy:a?.d??0,guides:o}}function Af(e,t){let n=[0,e.width/2,e.width],r=[0,e.height/2,e.height];for(let e of t)n.push(e.x,e.x+e.width/2,e.x+e.width),r.push(e.y,e.y+e.height/2,e.y+e.height);return{xs:n,ys:r}}function jf(e,t,n=!1,r=!1){let i=t.x-e.x,a=t.y-e.y;if(n){let e=Math.max(Math.abs(i),Math.abs(a));i=Math.sign(i||1)*e,a=Math.sign(a||1)*e}return r?{x:e.x-Math.abs(i),y:e.y-Math.abs(a),width:Math.abs(i)*2,height:Math.abs(a)*2}:{x:Math.min(e.x,e.x+i),y:Math.min(e.y,e.y+a),width:Math.abs(i),height:Math.abs(a)}}function Mf(e,t,n){let r=Math.max(0,Math.min(t,e.x)),i=Math.max(0,Math.min(n,e.y));return{x:r,y:i,width:Math.max(0,Math.min(t,e.x+e.width)-r),height:Math.max(0,Math.min(n,e.y+e.height)-i)}}var Nf=e=>({x:0,y:0,width:e.store.doc.canvas.width,height:e.store.doc.canvas.height});function Pf(e){let t=e.ui.get().crop,n=e.store.doc;if(!t||!n)return;let r=Mf(t,n.canvas.width,n.canvas.height),i=Math.round(r.x),a=Math.round(r.y),o=Math.max(1,Math.round(r.width)),s=Math.max(1,Math.round(r.height));if(i===0&&a===0&&o===n.canvas.width&&s===n.canvas.height)return void e.ui.set({tool:`move`,crop:null});e.edit([{op:`crop`,x:i,y:a,width:o,height:s}])&&e.ui.set(e=>({tool:`move`,crop:null,fitRequest:e.fitRequest+1}))}function Ff(e,t,n){return t?n&&n.hx===0?{...e,width:e.height*t}:{...e,height:e.width/t}:e}var If=(e,t,n)=>{for(let r of Sf){let i=e.toScreen({x:t.x+(r.hx+1)/2*t.width,y:t.y+(r.hy+1)/2*t.height});if(Math.hypot(i.x-n.x,i.y-n.y)<=8)return r}return null},Lf={id:`crop`,icon:O,label:`tools.crop`,shortcut:`C`,group:`select`,activate(e){e.store.doc&&!e.ui.get().crop&&e.ui.set({crop:Nf(e),region:null})},deactivate(e){e.ui.set({crop:null})},cursor(e,t){let n=e.api.ui.get().crop;if(!n||!t)return`crosshair`;let r=If(e,n,t.screen);return r?r.hx&&r.hy?r.hx===r.hy?`nwse-resize`:`nesw-resize`:r.hx?`ew-resize`:`ns-resize`:t.doc.x>=n.x&&t.doc.x<=n.x+n.width&&t.doc.y>=n.y&&t.doc.y<=n.y+n.height?`move`:`crosshair`},down(e,t){let{ui:n}=e.api,r=n.get().crop??Nf(e.api),i=n.get().cropRatio,a=If(e,r,t.screen);return a?{move(e){let t=Df({...r,rotation:0},a,e.doc,e.shift||!!i);n.set({crop:Ff(t,i,a)})},up(){}}:t.doc.x>=r.x&&t.doc.x<=r.x+r.width&&t.doc.y>=r.y&&t.doc.y<=r.y+r.height?{cursor:`move`,move(e){n.set({crop:{...r,x:r.x+e.doc.x-t.doc.x,y:r.y+e.doc.y-t.doc.y}})},up(){}}:{move(e){let r=jf(t.doc,e.doc,e.shift);n.set({crop:Ff(r,i,null)})},up(){}}},key(e,t){return t.key===`Enter`?(Pf(e.api),!0):t.key===`Escape`&&(e.api.ui.set({tool:`move`,crop:null}),!0)},Options:zf},Rf=[`free`,`original`,`1:1`,`4:5`,`3:2`,`16:9`,`9:16`,`2:3`];function zf(){let{t:e}=H(),t=q(),n=J(e=>e.crop),r=J(e=>e.cropRatio),i=J(e=>e.cropRatioId),a=t.store.doc;return a?(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`crop.ratio`)}),(0,W.jsx)(Eu,{value:i,onChange:e=>{let r=e===`free`?null:e===`original`?a.canvas.width/a.canvas.height:Number(e.split(`:`)[0])/Number(e.split(`:`)[1]),i=n??Nf(t),o=i;if(r){let e=Math.min(i.width,i.height*r),t=e/r;o={x:i.x+(i.width-e)/2,y:i.y+(i.height-t)/2,width:e,height:t}}t.ui.set({cropRatio:r,cropRatioId:e,crop:o})},options:Rf.map(t=>({value:t,label:t===`free`?e(`crop.free`):t===`original`?e(`crop.original`):t})),className:`w-[104px]`,ariaLabel:e(`crop.ratio`)}),n&&(0,W.jsxs)(`div`,{className:`flex w-[180px] gap-1`,children:[(0,W.jsx)(of,{label:`W`,value:Math.round(n.width),min:1,integer:!0,onChange:e=>t.ui.set({crop:{...n,width:e,...r?{height:e/r}:{}}})}),(0,W.jsx)(of,{label:`H`,value:Math.round(n.height),min:1,integer:!0,onChange:e=>t.ui.set({crop:{...n,height:e,...r?{width:e*r}:{}}})})]}),(0,W.jsxs)(`div`,{className:`ml-2 flex gap-1`,children:[(0,W.jsxs)(wu,{size:`xs`,variant:`primary`,onClick:()=>Pf(t),children:[(0,W.jsx)(Se,{size:13}),` `,e(`crop.apply`)]}),(0,W.jsxs)(wu,{size:`xs`,variant:`ghost`,onClick:()=>t.ui.set({tool:`move`,crop:null}),children:[(0,W.jsx)(_r,{size:13}),` `,e(`crop.cancel`)]})]}),(0,W.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`crop.hint`)})]}):null}var Bf=class{compositor;boxes=new Map;listeners=new Set;seq=0;constructor(e){this.compositor=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getSnapshot=()=>this.boxes;get(e){return this.boxes.get(e)}async update(e){let t=++this.seq,n=[];P(e.layers,e=>void n.push(e));let r=new Map;for(let e of n){if(!Lr(e))continue;let t=this.boxes.get(e.id),n=e.type===`text`?t?.width:e.width??t?.width,i=e.type===`text`?t?.height:e.height??t?.height;n!==void 0&&i!==void 0&&r.set(e.id,{x:e.x??0,y:e.y??0,width:n,height:i,rotation:e.rotation??0})}this.set(r);let i=new Map;await Promise.all(n.filter(Lr).map(async e=>{let t=await this.compositor.layerBox(e).catch(()=>null);t&&t.width>0&&t.height>0&&i.set(e.id,t)})),t===this.seq&&this.set(i)}set(e){this.boxes=e,this.listeners.forEach(e=>e())}};function $(e){let t=e.x+e.width/2,n=e.y+e.height/2,r=e.rotation*Math.PI/180,i=Math.cos(r),a=Math.sin(r);return[[-e.width/2,-e.height/2],[e.width/2,-e.height/2],[e.width/2,e.height/2],[-e.width/2,e.height/2]].map(([e,r])=>({x:t+e*i-r*a,y:n+e*a+r*i}))}function Vf(e){if(!e.rotation)return{x:e.x,y:e.y,width:e.width,height:e.height};let t=$(e),n=t.map(e=>e.x),r=t.map(e=>e.y),i=Math.min(...n),a=Math.min(...r);return{x:i,y:a,width:Math.max(...n)-i,height:Math.max(...r)-a}}function Hf(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=-e.rotation*Math.PI/180,a=t.x-n,o=t.y-r,s=a*Math.cos(i)-o*Math.sin(i),c=a*Math.sin(i)+o*Math.cos(i);return Math.abs(s)<=e.width/2&&Math.abs(c)<=e.height/2}function Uf(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.visible===!1||i.locked)continue;if(i.type===`group`){let e=Uf(i.children??[],t,n);if(e)return e;continue}if(!Lr(i))continue;let a=t.get(i.id);if(a&&Hf(a,n))return i.id}return null}function Wf(e,t){let n=[],r=e=>{e.locked||(Lr(e)?n.push(e):e.type===`group`&&(e.children??[]).forEach(r))},i=e=>{for(let n of e)t.includes(n.id)?r(n):n.type===`group`&&i(n.children??[])};return i(e),[...new Map(n.map(e=>[e.id,e])).values()]}function Gf(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of t){let t=e.get(o.id);if(!t)continue;let s=Vf(t);n=Math.min(n,s.x),r=Math.min(r,s.y),i=Math.max(i,s.x+s.width),a=Math.max(a,s.y+s.height)}return Number.isFinite(n)?{x:n,y:r,width:i-n,height:a-r}:null}var Kf={id:`text`,icon:ar,label:`tools.text`,shortcut:`T`,group:`draw`,cursor:()=>`text`,down(e,t){let{api:n}=e,r=n.store.doc;if(!r||n.ui.get().textEdit)return null;let i=Uf(r.layers,n.boxes.getSnapshot(),t.doc);return(i?N(r.layers,i)?.layer:null)?.type===`text`?(n.store.select(i),n.ui.set({textEdit:{id:i}})):n.ui.set({textEdit:{id:null,x:t.doc.x,y:t.doc.y}}),null},Options:qf};function qf(){let{t:e}=H(),t=q(),n=Iu(),r=J(e=>e.fg),i=n?.type===`text`?n:null,a=(e,n=!0)=>i&&t.edit([{op:`updateLayer`,id:i.id,set:e}],n?{}:{coalesce:`text-opt:${i.id}`});return(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[i?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Eu,{value:i.font??`inter`,options:Xr.map(e=>({value:e.id,label:e.family})),onChange:e=>a({font:e}),className:`w-[150px]`,ariaLabel:e(`props.font`)}),(0,W.jsx)(`div`,{className:`w-[84px]`,children:(0,W.jsx)(of,{label:`Aa`,value:i.size??64,min:1,max:2e3,onChange:(e,t)=>a({size:e},t),ariaLabel:e(`props.size`)})}),(0,W.jsx)(`div`,{className:`w-[120px]`,children:(0,W.jsx)(tf,{value:Vd(i.color,`#ffffff`),onChange:(e,t)=>a({color:e},t)})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`tools.color`)}),(0,W.jsx)(`div`,{className:`w-[120px]`,children:(0,W.jsx)(tf,{value:r,onChange:e=>t.ui.set({fg:e})})})]}),(0,W.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`tools.textHint`)})]})}var Jf={rect:zn,ellipse:Ae,line:Ht,polygon:ct,star:Un},Yf={id:`shape`,icon:xn,label:`tools.shape`,shortcut:`U`,group:`draw`,cursor:()=>`crosshair`,down(e,t){let{api:n}=e,r=n.ui.get().shapeKind,i={x:t.doc.x,y:t.doc.y,width:0,height:0};return{move(n){i=r===`line`?{x:t.doc.x,y:t.doc.y,width:n.doc.x-t.doc.x,height:n.doc.y-t.doc.y}:jf(t.doc,n.doc,n.shift,n.alt),e.setDraft({kind:r===`ellipse`?`ellipse`:r===`line`?`line`:`rect`,...i})},up(){e.setDraft(null);let a=n.store.doc;if(!a)return;let o=i;if(r===`line`&&(o={x:Math.min(i.x,i.x+i.width),y:Math.min(i.y,i.y+i.height),width:Math.abs(i.width),height:Math.abs(i.height)}),Math.max(o.width,o.height)*e.view().zoom<4){let e=Math.round(Math.min(a.canvas.width,a.canvas.height)/4);o={x:t.doc.x-e/2,y:t.doc.y-e/2,width:e,height:r===`line`?0:e}}let s={...vd(a,r,{...o,height:Math.max(1,o.height)},n.ui.get().fg),name:V(`shapes.${r}`)};r===`line`&&i.width<0!=i.height<0&&(s.flipX=!0),n.edit([{op:`addLayer`,layer:s}],{select:s.id})},cancel(){e.setDraft(null)}}},Options:Zf};function Xf({value:e,onChange:t}){let{t:n}=H();return(0,W.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:Object.keys(Jf).map(r=>{let i=Jf[r];return(0,W.jsx)(`button`,{type:`button`,title:n(`shapes.${r}`),"aria-label":n(`shapes.${r}`),onClick:()=>t(r),className:U(`flex h-6 w-7 items-center justify-center rounded`,e===r?`bg-ink-4 text-fg`:`text-fg-muted hover:text-fg`),children:(0,W.jsx)(i,{size:13})},r)})})}function Zf(){let{t:e}=H(),t=q(),n=J(e=>e.shapeKind),r=J(e=>e.fg);return(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(Xf,{value:n,onChange:e=>t.ui.set({shapeKind:e})}),(0,W.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:e(`tools.fill`)}),(0,W.jsx)(`div`,{className:`w-[120px]`,children:(0,W.jsx)(tf,{value:r,onChange:e=>t.ui.set({fg:e})})}),(0,W.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`tools.shapeHint`)})]})}var Qf=2048;function $f(e,t){return e&&t?`intersect`:e?`add`:t?`subtract`:`replace`}function ep(e,t,n=Qf){let r=Math.min(1,n/Math.max(e,t)),i=Math.max(1,Math.round(e*r)),a=Math.max(1,Math.round(t*r));return{w:i,h:a,scale:r,data:new Uint8Array(i*a)}}function tp(e,t,n=255){let r=Math.max(0,Math.floor(t.x*e.scale)),i=Math.max(0,Math.floor(t.y*e.scale)),a=Math.min(e.w,Math.ceil((t.x+t.width)*e.scale)),o=Math.min(e.h,Math.ceil((t.y+t.height)*e.scale)),s=(t.x+t.width/2)*e.scale,c=(t.y+t.height/2)*e.scale,l=t.width/2*e.scale,u=t.height/2*e.scale;for(let d=i;d<o;d++)for(let i=r;i<a;i++){if(t.kind===`ellipse`){let e=(i+.5-s)/(l||1),t=(d+.5-c)/(u||1);if(e*e+t*t>1)continue}e.data[d*e.w+i]=n}return e}function np(e,t,n=255){if(t.length<3)return e;let r=t.map(t=>({x:t.x*e.scale,y:t.y*e.scale})),i=1/0,a=-1/0;for(let e of r)i=Math.min(i,e.y),a=Math.max(a,e.y);let o=Math.max(0,Math.floor(i)),s=Math.min(e.h-1,Math.ceil(a)),c=[];for(let t=o;t<=s;t++){let i=t+.5;c.length=0;for(let e=0,t=r.length-1;e<r.length;t=e++){let n=r[e],a=r[t];n.y>i!=a.y>i&&c.push(n.x+(i-n.y)/(a.y-n.y)*(a.x-n.x))}c.sort((e,t)=>e-t);for(let r=0;r+1<c.length;r+=2){let i=Math.max(0,Math.ceil(c[r]-.5)),a=Math.min(e.w-1,Math.floor(c[r+1]-.5));for(let r=i;r<=a;r++)e.data[t*e.w+r]=n}}return e}function rp(e,t,n){return e.kind===`raster`?e.raster:tp(ep(t,n),e)}function ip(e,t,n,r,i){if(n===`replace`)return t;if(!e)return n===`add`?t:null;let a=rp(e,r,i),o=ap(rp(t,r,i),a),s=new Uint8Array(a.data.length);for(let e=0;e<s.length;e++){let t=a.data[e],r=o.data[e];s[e]=n===`add`?Math.max(t,r):n===`subtract`?Math.min(t,255-r):Math.min(t,r)}let c={...a,data:s};return cp(c)?null:{kind:`raster`,raster:c}}function ap(e,t){if(e.w===t.w&&e.h===t.h)return e;let n=new Uint8Array(t.w*t.h);for(let r=0;r<t.h;r++)for(let i=0;i<t.w;i++)n[r*t.w+i]=e.data[Math.min(e.h-1,Math.floor(r*e.h/t.h))*e.w+Math.min(e.w-1,Math.floor(i*e.w/t.w))];return{...t,data:n}}function op(e,t,n){if(!e)return{kind:`rect`,x:0,y:0,width:t,height:n};let r=rp(e,t,n),i=new Uint8Array(r.data.length);for(let e=0;e<i.length;e++)i[e]=255-r.data[e];let a={...r,data:i};return cp(a)?null:{kind:`raster`,raster:a}}function sp(e,t,n,r){let i=rp(e,n,r),a=Math.round(t*i.scale);if(a<1)return{kind:`raster`,raster:i};let o=Float32Array.from(i.data),s=new Float32Array(o.length),c=(e,t,n)=>{let r=n?i.w:i.h,o=n?i.h:i.w,s=(e,t)=>n?e*i.w+t:t*i.w+e;for(let n=0;n<o;n++){let i=0;for(let t=-a;t<=a;t++)i+=e[s(n,Math.min(r-1,Math.max(0,t)))];for(let o=0;o<r;o++)t[s(n,o)]=i/(a*2+1),i+=e[s(n,Math.min(r-1,o+a+1))]-e[s(n,Math.max(0,o-a))]}};for(let e=0;e<3;e++)c(o,s,!0),c(s,o,!1);let l=new Uint8Array(o.length);for(let e=0;e<l.length;e++)l[e]=Math.round(o[e]);return{kind:`raster`,raster:{...i,data:l}}}function cp(e){for(let t=0;t<e.data.length;t++)if(e.data[t]>0)return!1;return!0}function lp(e){if(e.kind!==`raster`)return e.width>0&&e.height>0?{x:e.x,y:e.y,width:e.width,height:e.height}:null;let t=e.raster,n=t.w,r=t.h,i=-1,a=-1;for(let e=0;e<t.h;e++)for(let o=0;o<t.w;o++)t.data[e*t.w+o]>0&&(o<n&&(n=o),o>i&&(i=o),e<r&&(r=e),e>a&&(a=e));return i<0?null:{x:n/t.scale,y:r/t.scale,width:(i-n+1)/t.scale,height:(a-r+1)/t.scale}}function up(e,t,n){if(e.kind===`rect`)return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height?255:0;if(e.kind===`ellipse`){let r=(t-(e.x+e.width/2))/(e.width/2||1),i=(n-(e.y+e.height/2))/(e.height/2||1);return r*r+i*i<=1?255:0}let r=e.raster,i=Math.floor(t*r.scale),a=Math.floor(n*r.scale);return i<0||a<0||i>=r.w||a>=r.h?0:r.data[a*r.w+i]}function dp(e,t,n,r,i){let a=new Uint8ClampedArray(t*n),o=r??{x:0,y:0,width:i.width,height:i.height,rotation:0},s=o.x+o.width/2,c=o.y+o.height/2,l=o.rotation*Math.PI/180,u=Math.cos(l),d=Math.sin(l),f=o.flipX?-1:1,p=o.flipY?-1:1;for(let r=0;r<n;r++){let i=((r+.5)/n-.5)*o.height*p;for(let n=0;n<t;n++){let l=((n+.5)/t-.5)*o.width*f;a[r*t+n]=up(e,s+l*u-i*d,c+l*d+i*u)}}return a}function fp(e,t,n,r,i,a){let o=ep(i,a),s=r.x+r.width/2,c=r.y+r.height/2,l=-r.rotation*Math.PI/180,u=Math.cos(l),d=Math.sin(l);for(let i=0;i<o.h;i++)for(let a=0;a<o.w;a++){let l=(a+.5)/o.scale-s,f=(i+.5)/o.scale-c,p=l*u-f*d,m=l*d+f*u;r.flipX&&(p=-p),r.flipY&&(m=-m);let h=Math.floor((p/r.width+.5)*t),g=Math.floor((m/r.height+.5)*n);h>=0&&g>=0&&h<t&&g<n&&(o.data[i*o.w+a]=e[g*t+h])}return cp(o)?null:{kind:`raster`,raster:o}}function pp(e,t,n,r,i,a,o){let s=new Uint8Array(t*n);if(r<0||i<0||r>=t||i>=n)return s;let c=(i*t+r)*4,[l,u,d,f]=[e[c],e[c+1],e[c+2],e[c+3]],p=Math.max(0,Math.min(100,a))/100*510,m=t=>{let n=t*4;return Math.abs(e[n]-l)+Math.abs(e[n+1]-u)+Math.abs(e[n+2]-d)+Math.abs(e[n+3]-f)*.5<=p};if(!o){for(let e=0;e<t*n;e++)m(e)&&(s[e]=255);return s}let h=[i*t+r],g=new Uint8Array(t*n);for(g[i*t+r]=1;h.length;){let e=h.pop();if(!m(e))continue;s[e]=255;let r=e%t,i=(e-r)/t,a=[r>0?e-1:-1,r<t-1?e+1:-1,i>0?e-t:-1,i<n-1?e+t:-1];for(let e of a)e>=0&&!g[e]&&(g[e]=1,h.push(e))}return s}function mp(e,t,n){let r=(r,i)=>r>=0&&i>=0&&r<t&&i<n&&e[i*t+r]>=128,i=(e,t)=>e*(n+2)+t,a=new Map,o=(e,t,n,r)=>{let o=i(e,t),s=a.get(o);s?s.push([n,r]):a.set(o,[[n,r]])};for(let e=0;e<n;e++)for(let n=0;n<t;n++)r(n,e)&&(r(n,e-1)||o(n,e,n+1,e),r(n+1,e)||o(n+1,e,n+1,e+1),r(n,e+1)||o(n+1,e+1,n,e+1),r(n-1,e)||o(n,e+1,n,e));let s=``,c=e=>{let t=a.get(e);if(!t?.length)return null;let n=t.pop();return t.length||a.delete(e),n};for(;a.size;){let e=a.keys().next().value,t=Math.floor(e/(n+2)),r=e-t*(n+2),o=[[t,r]],l=c(e);for(;l&&(o.push(l),l[0]!==t||l[1]!==r);)l=c(i(l[0],l[1]));let u=hp(o);s+=`M${u[0][0]} ${u[0][1]}`;for(let e=1;e<u.length;e++)s+=`L${u[e][0]} ${u[e][1]}`;s+=`Z`}return s}function hp(e){if(e.length<3)return e;let t=[e[0]];for(let n=1;n<e.length-1;n++){let[r,i]=t[t.length-1],[a,o]=e[n],[s,c]=e[n+1];(a-r)*(c-o)-(o-i)*(s-a)!==0&&t.push(e[n])}return t.push(e[e.length-1]),t}function gp(e){let t=Math.min(1,1024/Math.max(e.w,e.h));if(t>=1)return{d:mp(e.data,e.w,e.h),scale:e.scale};let n=Math.max(1,Math.round(e.w*t)),r=Math.max(1,Math.round(e.h*t)),i=new Uint8Array(n*r);for(let a=0;a<r;a++)for(let r=0;r<n;r++)i[a*n+r]=e.data[Math.min(e.h-1,Math.floor(a/t))*e.w+Math.min(e.w-1,Math.floor(r/t))];return{d:mp(i,n,r),scale:e.scale*t}}var _p=e=>Math.round(e*10)/10;function vp(e,t,n,r={}){let i=Lr(e)?n?.x??e.x??0:0,a=Lr(e)?n?.y??e.y??0:0;return{shape:t.kind,x:_p(t.x-i),y:_p(t.y-a),width:_p(t.width),height:_p(t.height),...r.invert?{invert:!0}:{},...r.feather?{feather:r.feather}:{}}}function yp(e){let t=z(e).getImageData(0,0,e.width,e.height).data,n=new Uint8ClampedArray(e.width*e.height);for(let e=0,r=0;e<n.length;e++,r+=4)n[e]=(t[r]*.299+t[r+1]*.587+t[r+2]*.114)*t[r+3]/255|0;return n}async function bp(e,t,n,r,i,a){if(!t)return new Uint8ClampedArray(n*r).fill(255);let o=wc(n,r),s=z(o);if(Rr(t)){let i=await e.image(t.src);s.drawImage(i,0,0,n,r)}else if(zr(t)){let e=n/i,o=r/a;s.fillStyle=`#fff`,s.beginPath(),t.shape===`ellipse`?s.ellipse((t.x+t.width/2)*e,(t.y+t.height/2)*o,Math.max(0,t.width/2*e),Math.max(0,t.height/2*o),0,0,Math.PI*2):_l(s,t.x*e,t.y*o,t.width*e,t.height*o,(t.radius??0)*e),s.fill()}else Br(t)&&(s.fillStyle=il(s,t.gradient,{x:0,y:0,w:n,h:r}),s.fillRect(0,0,n,r));let c=yp(o);if(t.invert)for(let e=0;e<c.length;e++)c[e]=255-c[e];return c}function xp(e,t,n){let r=wc(t,n),i=z(r),a=i.createImageData(t,n);for(let t=0,n=0;t<e.length;t++,n+=4)a.data[n]=a.data[n+1]=a.data[n+2]=e[t],a.data[n+3]=255;return i.putImageData(a,0,0),r}var Sp=new WeakMap;function Cp(e){let t=Sp.get(e.engine);return t||(t=new Nl({assetBase:``,libraryBase:``},e.engine.loader),Sp.set(e.engine,t)),t}async function wp(e){let t=await createImageBitmap(new Blob([e],{type:`image/png`})),n=new OffscreenCanvas(t.width,t.height),r=n.getContext(`2d`);r.drawImage(t,0,0);let i=r.getImageData(0,0,n.width,n.height).data,a=new Uint8ClampedArray(n.width*n.height);for(let e=0,t=0;e<a.length;e++,t+=4)a[e]=(i[t]*.299+i[t+1]*.587+i[t+2]*.114)*i[t+3]/255;return{data:a,w:n.width,h:n.height}}var Tp=2048,Ep=4096;async function Dp(e,t,n,r=`png`){let i=new Set(await e.backend.listFiles(`${t}/`).catch(()=>[]));for(let e=1;;e++){let a=`${t}/${n}-${e}.${r}`;if(!i.has(a))return a}}function Op(e,t){if(!Lr(t))return null;let n=e.boxes.get(t.id),r=t.type===`image`?e.naturalSize(t.src):void 0;return{x:n?.x??t.x??0,y:n?.y??t.y??0,width:n?.width??t.width??r?.width??1,height:n?.height??t.height??r?.height??1,rotation:n?.rotation??t.rotation??0,flipX:t.flipX,flipY:t.flipY}}function kp(e,t,n=Tp){let r=Math.min(1,n/Math.max(e,t));return{w:Math.max(1,Math.round(e*r)),h:Math.max(1,Math.round(t*r))}}async function Ap(e,t,n,r,i){let a=await Ll(n,r,i);return await e.backend.writeFile(t,a.bytes),t}async function jp(e,t,n){let r=e.store.doc,i=Op(e,t);if(n.kind!==`raster`&&!i?.rotation&&!i?.flipX&&!i?.flipY)return vp(t,n,i?{x:i.x,y:i.y,width:i.width,height:i.height,rotation:0}:void 0);let{w:a,h:o}=kp(i?.width??r.canvas.width,i?.height??r.canvas.height),s=dp(n,a,o,i,r.canvas);return{src:await Ap(e,await Dp(e,`assets/masks`,`${t.id}-selection`),s,a,o)}}function Mp(e){let t=e.ui.get().region;if(!t)return null;let n=e.store.primary;return{region:t,layer:n&&e.store.doc?N(e.store.doc.layers,n)?.layer??null:null}}async function Np(e,t){try{await t()}catch(t){Q({tone:`error`,title:e,detail:t.message})}}function Pp(e){return Np(V(`region.failed`),async()=>{let t=Mp(e);if(!t?.layer)return void Q({tone:`info`,title:V(`region.needLayer`)});let n=await jp(e,t.layer,t.region);e.edit([{op:`setMask`,id:t.layer.id,mask:n}])&&e.ui.set({region:null})})}function Fp(e){return Np(V(`region.failed`),async()=>{let t=Mp(e);if(!t?.layer)return void Q({tone:`info`,title:V(`region.needLayer`)});let n=e.store.doc,r=Op(e,t.layer),i=r?.width??n.canvas.width,a=r?.height??n.canvas.height,{w:o,h:s}=kp(i,a),c=t.layer.mask&&t.layer.mask.enabled!==!1?t.layer.mask:null,l=await bp(e.engine.loader,c,o,s,i,a),u=dp(t.region,o,s,r,n.canvas);for(let e=0;e<l.length;e++)l[e]=Math.min(l[e],255-u[e]);let d=await Ap(e,await Dp(e,`assets/masks`,`${t.layer.id}-erase`),l,o,s),f=c?{...c.feather?{feather:c.feather}:{},...c.density===void 0?{}:{density:c.density}}:{};e.edit([{op:`setMask`,id:t.layer.id,mask:{src:d,...f}}])})}function Ip(e){return Np(V(`region.failed`),async()=>{let t=Mp(e);if(!t)return;let n=e.store.doc,r=lp(t.region),i=r&&Mf(r,n.canvas.width,n.canvas.height);if(!i||i.width<1||i.height<1)return void Q({tone:`info`,title:V(`marquee.empty`)});let a=Math.min(1,Ep/Math.max(n.canvas.width,n.canvas.height)),o=await Cp(e).render(n,{scale:a,...t.layer?{only:new Set([t.layer.id]),background:!1}:{}}),s=o.width,c=o.height,l=dp(t.region,s,c,null,n.canvas),u=z(o),d=u.getImageData(0,0,s,c);for(let e=0;e<l.length;e++)d.data[e*4+3]=d.data[e*4+3]*l[e]/255;u.putImageData(d,0,0);let f=Math.floor(i.x),p=Math.floor(i.y),m=Math.ceil(i.x+i.width)-f,h=Math.ceil(i.y+i.height)-p,g=wc(Math.max(1,Math.round(m*a)),Math.max(1,Math.round(h*a)));z(g).drawImage(o,-f*a,-p*a);let _=await Rl(g,`image/png`),v=t.layer?.id??`picture`,y=await Dp(e,`assets/edits`,`${v}-copy`);await e.backend.writeFile(y,_.bytes);let b=pd(n,`${v}-copy`),x={id:b,type:`image`,name:V(`region.copyName`),src:y,x:f,y:p,width:m,height:h};e.edit([{op:`addLayer`,layer:x,...t.layer?{above:t.layer.id}:{}}],{select:b})&&e.ui.set({region:null})})}async function Lp(e,t,n){let r=e.store.doc;if(t.kind!==`raster`)return{shape:t.kind,x:t.x,y:t.y,width:t.width,height:t.height};let{w:i,h:a}=kp(r.canvas.width,r.canvas.height),o=dp(t,i,a,null,r.canvas);return{src:await Ap(e,await Dp(e,`assets/masks`,n),o,i,a)}}function Rp(e){return Np(V(`region.failed`),async()=>{let t=Mp(e);if(!t)return;let n=e.store.doc,r=pd(n,`fill`),i=await Lp(e,t.region,`${r}-selection`),a={id:r,type:`fill`,name:V(`region.fillName`),fill:e.ui.get().fg,mask:i};e.edit([{op:`addLayer`,layer:a,...t.layer?{above:t.layer.id}:{}}],{select:r})&&e.ui.set({region:null})})}function zp(e){return Np(V(`region.failed`),async()=>{let t=Mp(e);if(!t)return;let n=e.store.doc,r=pd(n,`adjustment`),i=await Lp(e,t.region,`${r}-selection`),a={id:r,type:`adjustment`,name:V(`layers.adjustmentName`),filters:[{type:`brightnessContrast`,brightness:0,contrast:0}],mask:{...i,feather:2}};e.edit([{op:`addLayer`,layer:a,...t.layer?{above:t.layer.id}:{}}],{select:r})&&e.ui.set({region:null,rightTab:`filters`})})}function Bp(e){let t=e.ui.get().region,n=e.store.doc;if(!t||!n)return;let r=lp(t),i=r&&Mf(r,n.canvas.width,n.canvas.height);if(!i||i.width<1||i.height<1)return void Q({tone:`info`,title:V(`marquee.empty`)});let a={op:`crop`,x:Math.round(i.x),y:Math.round(i.y),width:Math.max(1,Math.round(i.width)),height:Math.max(1,Math.round(i.height))};e.edit([a])&&e.ui.set(e=>({region:null,fitRequest:e.fitRequest+1}))}function Vp(e){let t=e.store.doc;t&&e.ui.set(e=>({region:op(e.region,t.canvas.width,t.canvas.height)}))}function Hp(e,t){let n=e.store.doc,r=e.ui.get().region;!n||!r||t<=0||e.ui.set({region:sp(r,t,n.canvas.width,n.canvas.height)})}function Up(e){let t=e.store.doc;t&&e.ui.set({region:{kind:`rect`,x:0,y:0,width:t.canvas.width,height:t.canvas.height}})}function Wp(){let{t:e}=H(),t=q(),n=J(e=>e.region),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(8);if(!n)return null;let s=lp(n),c=async e=>{i(!0);try{await e()}finally{i(!1)}};return(0,W.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[s&&(0,W.jsxs)(`span`,{className:`mr-1.5 text-2xs tabular-nums text-fg-faint`,children:[Math.round(s.width),` × `,Math.round(s.height)]}),(0,W.jsxs)(wu,{size:`xs`,variant:`ghost`,disabled:r||!t.store.primary,onClick:()=>void c(()=>Pp(t)),title:e(`marquee.maskHint`),children:[(0,W.jsx)(Fn,{size:13}),` `,e(`marquee.mask`)]}),(0,W.jsx)(G,{label:e(`region.delete`),disabled:r||!t.store.primary,onClick:()=>void c(()=>Fp(t)),className:`h-6 w-6`,children:(0,W.jsx)(Be,{size:13})}),(0,W.jsx)(G,{label:e(`region.copy`),disabled:r,onClick:()=>void c(()=>Ip(t)),className:`h-6 w-6`,children:(0,W.jsx)(Pe,{size:13})}),(0,W.jsx)(G,{label:e(`region.fill`),disabled:r,onClick:()=>void c(()=>Rp(t)),className:`h-6 w-6`,children:(0,W.jsx)(Jt,{size:13})}),(0,W.jsx)(G,{label:e(`marquee.adjustHint`),disabled:r,onClick:()=>void c(()=>zp(t)),className:`h-6 w-6`,children:(0,W.jsx)(wt,{size:13})}),(0,W.jsx)(`div`,{className:`mx-1 h-4 w-px bg-line`}),(0,W.jsx)(G,{label:e(`region.invert`),onClick:()=>Vp(t),className:`h-6 w-6`,children:(0,W.jsx)(Nn,{size:13})}),(0,W.jsx)(Gd,{width:200,align:`start`,trigger:(t,n)=>(0,W.jsx)(G,{label:e(`region.feather`),active:n,onClick:t,className:`h-6 w-6`,children:(0,W.jsx)(Dn,{size:13})}),children:n=>(0,W.jsxs)(`div`,{className:`space-y-2 p-2.5`,children:[(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:e(`region.featherRadius`)}),(0,W.jsx)(of,{value:a,min:1,max:500,integer:!0,suffix:`px`,onChange:e=>o(e),ariaLabel:e(`region.featherRadius`)}),(0,W.jsx)(wu,{size:`xs`,variant:`primary`,className:`w-full`,onClick:()=>(Hp(t,a),n()),children:e(`region.apply`)})]})}),(0,W.jsx)(G,{label:e(`marquee.crop`),onClick:()=>Bp(t),className:`h-6 w-6`,children:(0,W.jsx)(O,{size:13})}),(0,W.jsx)(G,{label:e(`marquee.deselect`),onClick:()=>t.ui.set({region:null}),className:`h-6 w-6`,children:(0,W.jsx)(_r,{size:13})})]})}function Gp(e,t){let{ui:n}=e.api,r=n.get().region;if(!r||t.shift||t.alt)return null;let i=lp(r);return!i||t.doc.x<i.x||t.doc.x>i.x+i.width||t.doc.y<i.y||t.doc.y>i.y+i.height||r.kind===`raster`?null:{cursor:`move`,move(e){n.set({region:{...r,x:r.x+e.doc.x-t.doc.x,y:r.y+e.doc.y-t.doc.y}})},up(){}}}function Kp(e,t,n){let r=e.api.store.doc;e.api.ui.set(e=>({region:ip(e.region,t,n,r.canvas.width,r.canvas.height)}))}var qp={id:`marquee`,icon:Fn,label:`tools.marquee`,shortcut:`M`,group:`select`,cursor:()=>`crosshair`,down(e,t){let n=Gp(e,t);if(n)return n;let r=$f(t.shift,t.alt),i=e.api.ui.get().marqueeKind,a=!1,o={x:0,y:0,width:0,height:0};return{move(n){!a&&Math.hypot(n.screen.x-t.screen.x,n.screen.y-t.screen.y)<3||(a=!0,o=r===`replace`?jf(t.doc,n.doc,n.shift,n.alt):jf(t.doc,n.doc),r===`replace`?e.api.ui.set({region:{kind:i,...o}}):e.setDraft({kind:i,...o}))},up(){e.setDraft(null),a?r!==`replace`&&Kp(e,{kind:i,...o},r):r===`replace`&&e.api.ui.set({region:null})},cancel(){e.setDraft(null)}}},key(e,t){return t.key===`Escape`&&e.api.ui.get().region?(e.api.ui.set({region:null}),!0):!1},Options:Jp};function Jp(){let{t:e}=H(),t=q(),n=J(e=>e.marqueeKind),r=J(e=>e.region);return(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`rect`,`ellipse`].map(i=>(0,W.jsx)(`button`,{type:`button`,title:e(`marquee.${i}`),"aria-label":e(`marquee.${i}`),onClick:()=>t.ui.set({marqueeKind:i,...r&&r.kind!==`raster`?{region:{...r,kind:i}}:{}}),className:U(`flex h-6 w-7 items-center justify-center rounded`,n===i?`bg-ink-4 text-fg`:`text-fg-muted hover:text-fg`),children:i===`rect`?(0,W.jsx)(zn,{size:13}):(0,W.jsx)(Ae,{size:13})},i))}),(0,W.jsx)(`div`,{className:`ml-2`,children:r?(0,W.jsx)(Wp,{}):(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:e(`marquee.hint`)})})]})}var Yp=null;function Xp(e,t,n){if(e.setPath(null),t.length<3)return;let r=e.api.store.doc;Kp(e,{kind:`raster`,raster:np(ep(r.canvas.width,r.canvas.height),t)},n)}var Zp={id:`lasso`,icon:St,label:`tools.lasso`,shortcut:`L`,group:`select`,cursor:()=>`crosshair`,deactivate(){Yp=null},down(e,t){if(e.api.ui.get().lassoKind===`poly`){if(!Yp)Yp={points:[t.doc],mode:$f(t.shift,t.alt)};else{let n=e.toScreen(Yp.points[0]);if(t.clicks>=2||Math.hypot(n.x-t.screen.x,n.y-t.screen.y)<9){let t=Yp.points,n=Yp.mode;return Yp=null,Xp(e,t,n),null}Yp.points.push(t.doc)}return e.setPath({points:Yp.points,toCursor:!0}),null}let n=$f(t.shift,t.alt),r=[t.doc];return{move(t){let n=r[r.length-1],i=e.view().zoom;Math.hypot((t.doc.x-n.x)*i,(t.doc.y-n.y)*i)<2||(r.push(t.doc),e.setPath({points:r}))},up(){r.length<3&&n===`replace`&&e.api.ui.set({region:null}),Xp(e,r,n)},cancel(){e.setPath(null)}}},hover(e){Yp&&e.setPath({points:Yp.points,toCursor:!0})},key(e,t){if(Yp&&t.key===`Enter`){let{points:t,mode:n}=Yp;return Yp=null,Xp(e,t,n),!0}if(t.key===`Escape`){if(Yp)return Yp=null,e.setPath(null),!0;if(e.api.ui.get().region)return e.api.ui.set({region:null}),!0}return Yp&&t.key===`Backspace`?(Yp.points.pop(),Yp.points.length||(Yp=null),e.setPath(Yp?{points:Yp.points,toCursor:!0}:null),!0):!1},Options:Qp};function Qp(){let{t:e}=H(),t=q(),n=J(e=>e.lassoKind),r=J(e=>e.region);return(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`free`,`poly`].map(r=>(0,W.jsxs)(`button`,{type:`button`,title:e(`lasso.${r}`),"aria-label":e(`lasso.${r}`),onClick:()=>(Yp=null,t.ui.set({lassoKind:r})),className:U(`flex h-6 items-center gap-1 rounded px-2 text-xs`,n===r?`bg-ink-4 text-fg`:`text-fg-muted hover:text-fg`),children:[r===`free`?(0,W.jsx)(St,{size:13}):(0,W.jsx)(jn,{size:13}),e(`lasso.${r}`)]},r))}),(0,W.jsx)(`div`,{className:`ml-2`,children:r?(0,W.jsx)(Wp,{}):(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:e(n===`poly`?`lasso.polyHint`:`lasso.hint`)})})]})}var $p=class{base;mode;brush;color;cloneOffset;display;stroke;sctx;dirty=null;last=null;clip=null;w;h;constructor(e,t,n,r,i,a={dx:0,dy:0}){if(this.base=e,this.mode=t,this.brush=n,this.color=r,this.cloneOffset=a,this.w=e.width,this.h=e.height,this.display=document.createElement(`canvas`),this.display.width=this.w,this.display.height=this.h,z(this.display).drawImage(e,0,0),this.stroke=wc(this.w,this.h),this.sctx=z(this.stroke),i){let e=wc(this.w,this.h),t=z(e),n=t.createImageData(this.w,this.h);for(let e=0;e<i.length;e++)n.data[e*4]=n.data[e*4+1]=n.data[e*4+2]=255,n.data[e*4+3]=i[e];t.putImageData(n,0,0),this.clip=e}}dab(e,t){let n=Math.max(.5,this.brush.radius),r=this.sctx.createRadialGradient(e,t,0,e,t,n),i=Math.max(0,Math.min(.999,this.brush.hardness));r.addColorStop(0,`rgba(255,255,255,1)`),r.addColorStop(i,`rgba(255,255,255,1)`),r.addColorStop(1,`rgba(255,255,255,0)`),this.sctx.globalAlpha=Math.max(.01,Math.min(1,this.brush.flow)),this.sctx.fillStyle=r,this.sctx.beginPath(),this.sctx.arc(e,t,n,0,Math.PI*2),this.sctx.fill();let a={x0:Math.floor(e-n-1),y0:Math.floor(t-n-1),x1:Math.ceil(e+n+1),y1:Math.ceil(t+n+1)};this.dirty=this.dirty?{x0:Math.min(this.dirty.x0,a.x0),y0:Math.min(this.dirty.y0,a.y0),x1:Math.max(this.dirty.x1,a.x1),y1:Math.max(this.dirty.y1,a.y1)}:a}lineTo(e,t){if(!this.last){this.dab(e,t),this.last={x:e,y:t};return}let n=Math.max(.5,this.brush.radius*.18),r=e-this.last.x,i=t-this.last.y,a=Math.hypot(r,i);if(a<n)return;let o=Math.floor(a/n);for(let e=1;e<=o;e++)this.dab(this.last.x+r*e*n/a,this.last.y+i*e*n/a);this.last={x:this.last.x+r*o*n/a,y:this.last.y+i*o*n/a}}flush(){let e=this.dirty;if(!e)return null;this.dirty=null;let t=Math.max(0,e.x0),n=Math.max(0,e.y0),r=Math.min(this.w,e.x1)-t,i=Math.min(this.h,e.y1)-n;if(r<=0||i<=0)return null;let a=wc(r,i),o=z(a);o.drawImage(this.stroke,t,n,r,i,0,0,r,i),this.clip&&(o.globalCompositeOperation=`destination-in`,o.drawImage(this.clip,t,n,r,i,0,0,r,i)),o.globalCompositeOperation=`source-in`,this.mode===`clone`?o.drawImage(this.base,t+this.cloneOffset.dx,n+this.cloneOffset.dy,r,i,0,0,r,i):this.mode===`paint`&&(o.fillStyle=this.color,o.fillRect(0,0,r,i));let s=z(this.display);return s.save(),s.clearRect(t,n,r,i),s.drawImage(this.base,t,n,r,i,t,n,r,i),s.globalAlpha=Math.max(0,Math.min(1,this.brush.opacity)),this.mode===`erase`&&(s.globalCompositeOperation=`destination-out`),s.drawImage(a,t,n),s.restore(),{x:t,y:n,w:r,h:i}}};function em(e,t,n){(t.width!==e.width||t.height!==e.height)&&(t.width=e.width,t.height=e.height,n=void 0);let r=n??{x:0,y:0,w:e.width,h:e.height},i=z(e).getImageData(r.x,r.y,r.w,r.h);for(let e=0;e<i.data.length;e+=4){let t=255-i.data[e];i.data[e]=255,i.data[e+1]=60,i.data[e+2]=80,i.data[e+3]=t*.55}z(t).putImageData(i,r.x,r.y)}var tm=4096,nm=new Map,rm=(e,t)=>{for(nm.delete(e),nm.set(e,t);nm.size>6;)nm.delete(nm.keys().next().value)},im=null,am=e=>({x:0,y:0,width:e.store.doc.canvas.width,height:e.store.doc.canvas.height,rotation:0});function om(e){let t=e.store.doc,n=e.store.primary?N(t.layers,e.store.primary)?.layer??null:null;return n&&e.ui.get().maskTarget===n.id?{kind:`mask`,layer:n}:n?.type===`image`&&!n.locked?{kind:`pixels`,layer:n}:{kind:`new`,layer:n}}async function sm(e){let t=e.store.doc,{kind:n,layer:r}=om(e);if(n===`mask`&&r){let t=Op(e,r)??am(e),i=`${r.id}|mask|${JSON.stringify(r.mask??null)}`,a=nm.get(i);if(!a){let{w:n,h:o}=kp(t.width,t.height);a=xp(await bp(e.engine.loader,r.mask??null,n,o,t.width,t.height),n,o),rm(i,a)}return{kind:n,layer:r,frame:t,base:a}}if(n===`pixels`&&r?.type===`image`){let i=Op(e,r),a=`${r.id}|${r.src}|${JSON.stringify(r.crop??null)}|${r.fit??``}|${i.width}x${i.height}`,o=nm.get(a);return o||(o=await Cp(e).layerPixels(t,r.id,{maxSide:tm,withFilters:!1}),rm(a,o)),{kind:n,layer:r,frame:i,base:o}}let i=am(e),{w:a,h:o}=kp(i.width,i.height,tm),s=document.createElement(`canvas`);return s.width=a,s.height=o,{kind:`new`,layer:r,frame:i,base:s}}function cm(e,t){let n=e.frame,r=wf({x:t.x-(n.x+n.width/2),y:t.y-(n.y+n.height/2)},-n.rotation),i=n.flipX?-r.x:r.x,a=n.flipY?-r.y:r.y;return{x:(i/n.width+.5)*e.base.width,y:(a/n.height+.5)*e.base.height}}async function lm(e,t,n){let r=e.store.doc,i=await Rl(n,`image/png`);if(t.kind===`mask`&&t.layer){let r=await Dp(e,`assets/masks`,`${t.layer.id}-paint`);await e.backend.writeFile(r,i.bytes);let a=t.layer.mask,o={src:r,...a?.feather?{feather:a.feather}:{},...a?.density===void 0?{}:{density:a.density},...a?.enabled===!1?{enabled:!1}:{}};rm(`${t.layer.id}|mask|${JSON.stringify(o)}`,n),e.edit([{op:`setMask`,id:t.layer.id,mask:o}]);return}if(t.kind===`pixels`&&t.layer?.type===`image`){let r=t.layer,a=await Dp(e,`assets/edits`,r.id);await e.backend.writeFile(a,i.bytes);let o=t.frame;rm(`${r.id}|${a}|null||${o.width}x${o.height}`,n),e.edit([{op:`updateLayer`,id:r.id,set:{src:a,crop:null,fit:null,focus:null,width:o.width,height:o.height}}]);return}let a=pd(r,`paint`),o=await Dp(e,`assets/edits`,a);await e.backend.writeFile(o,i.bytes);let s=t.frame;rm(`${a}|${o}|null||${s.width}x${s.height}`,n);let c={id:a,type:`image`,name:V(`brush.layerName`),src:o,x:0,y:0,width:s.width,height:s.height};e.edit([{op:`addLayer`,layer:c,...t.layer?{above:t.layer.id}:{}}],{select:a})}function um(e,t,n){let{api:r}=e,i=r.ui.get();if(n===`clone`){if(t.alt)return r.ui.set({cloneSource:t.doc}),im=null,Q({tone:`info`,title:V(`brush.sourceSet`)},1600),null;if(!i.cloneSource)return Q({tone:`info`,title:V(`brush.needSource`)}),null;im||={x:i.cloneSource.x-t.doc.x,y:i.cloneSource.y-t.doc.y}}let a=[t.doc],o=null,s=null,c=null,l=0,u=!1,d=!1,f=()=>{if(l=0,!o||!s)return;let e=o.flush();e&&c&&em(o.display,c,e)},p=()=>{l||=requestAnimationFrame(f)},m=sm(r).then(t=>{s=t;let l=t.base.width/t.frame.width,u={radius:i.brush.size/2*l,hardness:i.brush.hardness,opacity:i.brush.opacity,flow:i.brush.flow},d=i.maskPaint===`reveal`,f=t.kind===`mask`?n===`clone`?`clone`:`paint`:n===`eraser`?`erase`:n===`clone`?`clone`:`paint`,m=t.kind===`mask`?(n===`eraser`?!d:d)?`#ffffff`:`#000000`:i.fg,h=r.ui.get().region,g=h?dp(h,t.base.width,t.base.height,t.kind===`new`?null:t.frame,r.store.doc.canvas):null,_=im?{dx:im.x*l,dy:im.y*l}:void 0;o=new $p(t.base,f,u,m,g,_),t.kind===`mask`&&(c=document.createElement(`canvas`),em(o.display,c)),e.setOverlay({canvas:c??o.display,frame:t.frame,hide:t.kind===`pixels`?t.layer.id:void 0});for(let e of a)o.lineTo(cm(t,e).x,cm(t,e).y);a.length=0,p()}).catch(e=>{d=!0,Q({tone:`error`,title:V(`brush.failed`),detail:e.message})});return{cursor:`none`,move(e){if(o&&s){let t=cm(s,e.doc);o.lineTo(t.x,t.y),p()}else a.push(e.doc)},up(){u||(u=!0,(async()=>{if(await m,d||!o||!s)return e.setOverlay(null);l&&cancelAnimationFrame(l),f();try{await lm(r,s,o.display),await e.nextFrame()}catch(e){Q({tone:`error`,title:V(`brush.failed`),detail:e.message})}finally{e.setOverlay(null)}})())},cancel(){u=!0,e.setOverlay(null)}}}var dm=(e,t,n)=>({id:e,icon:t,label:`tools.${e}`,shortcut:n,group:`paint`,cursor:()=>`none`,down:(t,n)=>um(t,n,e),Options:gm}),fm=dm(`brush`,ge,`B`),pm=dm(`eraser`,Be,`E`),mm=dm(`clone`,Vn,`S`),hm=new Set([`brush`,`eraser`,`clone`]);function gm(){let{t:e}=H(),t=q(),n=J(e=>e.brush),r=J(e=>e.tool),i=J(e=>e.maskTarget),a=J(e=>e.maskPaint),o=J(e=>e.region);Iu();let s=om(t),c=e=>t.ui.set(t=>({brush:{...t.brush,...e}}));return(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`span`,{children:e(`brush.size`)}),(0,W.jsx)(`div`,{className:`w-[64px]`,children:(0,W.jsx)(of,{value:n.size,min:1,max:2e3,integer:!0,suffix:`px`,onChange:e=>c({size:e}),ariaLabel:e(`brush.size`)})}),(0,W.jsx)(`span`,{children:e(`brush.hardness`)}),(0,W.jsx)(`div`,{className:`w-[110px]`,children:(0,W.jsx)(sf,{value:Math.round(n.hardness*100),min:0,max:100,integer:!0,onChange:e=>c({hardness:e/100}),ariaLabel:e(`brush.hardness`)})}),(0,W.jsx)(`span`,{children:e(`brush.opacity`)}),(0,W.jsx)(`div`,{className:`w-[110px]`,children:(0,W.jsx)(sf,{value:Math.round(n.opacity*100),min:1,max:100,integer:!0,onChange:e=>c({opacity:e/100}),ariaLabel:e(`brush.opacity`)})}),(0,W.jsx)(`span`,{children:e(`brush.flow`)}),(0,W.jsx)(`div`,{className:`w-[110px]`,children:(0,W.jsx)(sf,{value:Math.round(n.flow*100),min:1,max:100,integer:!0,onChange:e=>c({flow:e/100}),ariaLabel:e(`brush.flow`)})}),(0,W.jsx)(`div`,{className:`mx-1 h-4 w-px bg-line`}),i&&s.kind===`mask`?(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`rounded bg-danger/15 px-1.5 py-0.5 text-2xs font-semibold uppercase text-danger`,children:e(`brush.maskMode`)}),(0,W.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`hide`,`reveal`].map(n=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.ui.set({maskPaint:n}),className:U(`h-6 rounded px-2`,a===n?`bg-ink-4 text-fg`:`text-fg-muted hover:text-fg`),children:e(`brush.${n}`)},n))}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.ui.set({maskTarget:null}),className:`ml-1 text-accent hover:underline`,children:e(`brush.paintPixels`)})]}):(0,W.jsx)(`span`,{className:`text-fg-faint`,children:r===`clone`?e(`brush.cloneHint`):s.kind===`new`?e(`brush.newLayerHint`):e(`brush.hint`)}),o&&(0,W.jsx)(`span`,{className:`text-2xs text-accent`,children:e(`brush.clipped`)})]})}var _m={id:`wand`,icon:pr,label:`tools.wand`,shortcut:`W`,group:`select`,cursor:()=>`crosshair`,down(e,t){let{api:n}=e,r=n.store.doc,{tolerance:i,contiguous:a,sampleAll:o}=n.ui.get().wand,s=$f(t.shift,t.alt),c=!o&&n.store.primary?n.store.primary:null,l=ep(r.canvas.width,r.canvas.height);return(async()=>{let o=Tc(await Cp(n).render(r,{scale:l.scale,...c?{only:new Set([c]),background:!1}:{}})),u=pp(o.data,o.width,o.height,Math.floor(t.doc.x*l.scale),Math.floor(t.doc.y*l.scale),i,a);Kp(e,{kind:`raster`,raster:{w:o.width,h:o.height,scale:l.scale,data:new Uint8Array(u)}},s)})().catch(e=>Q({tone:`error`,title:V(`region.failed`),detail:e.message})),null},key(e,t){return t.key===`Escape`&&e.api.ui.get().region?(e.api.ui.set({region:null}),!0):!1},Options:vm};function vm(){let{t:e}=H(),t=q(),n=J(e=>e.wand),r=J(e=>e.region),i=e=>t.ui.set(t=>({wand:{...t.wand,...e}}));return(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`span`,{children:e(`wand.tolerance`)}),(0,W.jsx)(`div`,{className:`w-[150px]`,children:(0,W.jsx)(sf,{value:n.tolerance,min:0,max:100,integer:!0,onChange:e=>i({tolerance:e}),ariaLabel:e(`wand.tolerance`)})}),(0,W.jsx)(Du,{checked:n.contiguous,onChange:e=>i({contiguous:e}),ariaLabel:e(`wand.contiguous`)}),(0,W.jsx)(`span`,{children:e(`wand.contiguous`)}),(0,W.jsx)(Du,{checked:n.sampleAll,onChange:e=>i({sampleAll:e}),ariaLabel:e(`wand.sampleAll`)}),(0,W.jsx)(`span`,{children:e(`wand.sampleAll`)}),(0,W.jsx)(`div`,{className:`ml-2`,children:r?(0,W.jsx)(Wp,{}):(0,W.jsx)(`span`,{className:`text-fg-faint`,children:e(`wand.hint`)})})]})}var ym=$r.segmentation;async function bm(e,t,n){let r=e.store.doc,i=N(r.layers,t);if(i){e.ui.set(e=>({quick:{layer:t,points:n,region:e.quick?.layer===t?e.quick.region:null,busy:!0},busy:{label:V(`quick.running`)}}));try{let a=await wp((await Cp(e).segmentMask(r,t,{points:n},{model:ym})).bytes),o=Op(e,i.layer),s=fp(a.data,a.w,a.h,o,r.canvas.width,r.canvas.height);e.ui.set(e=>e.quick?.layer===t&&e.quick.points===n?{quick:{...e.quick,region:s,busy:!1}}:{})}catch(t){e.ui.set(e=>({quick:e.quick?{...e.quick,busy:!1}:null})),Q({tone:`error`,title:V(`quick.failed`),detail:t.message},8e3)}finally{e.ui.set({busy:null})}}}function xm(e){let t=e.ui.get().quick,n=e.store.doc;t?.region&&n&&e.ui.set(e=>({region:ip(e.region,t.region,`replace`,n.canvas.width,n.canvas.height),quick:null}))}var Sm={id:`quick`,icon:Kt,label:`tools.quick`,shortcut:`Q`,group:`select`,cursor:()=>`crosshair`,deactivate(e){e.ui.set({quick:null})},down(e,t){let{api:n}=e,r=n.store.doc;if(n.ui.get().quick?.busy)return null;let i=n.store.primary?N(r.layers,n.store.primary)?.layer??null:null;if(i?.type!==`image`){let e=Uf(r.layers,n.boxes.getSnapshot(),t.doc);if(i=e?N(r.layers,e)?.layer??null:null,i?.type!==`image`)return Q({tone:`info`,title:V(`quick.needImage`)}),null;n.store.select(i.id)}let a=Op(n,i),o={x:a.x+a.width/2,y:a.y+a.height/2},s=wf({x:t.doc.x-o.x,y:t.doc.y-o.y},-a.rotation),c=[(a.flipX?-s.x:s.x)+a.width/2,(a.flipY?-s.y:s.y)+a.height/2,+!t.alt],l=n.ui.get().quick,u=l&&l.layer===i.id?[...l.points,c]:[c],d=i.id;return n.ensureModel(ym).then(e=>e?bm(n,d,u):void 0),null},key(e,t){let n=e.api.ui.get().quick;return n&&t.key===`Enter`?(xm(e.api),!0):t.key===`Escape`&&(n||e.api.ui.get().region)?(e.api.ui.set(n?{quick:null}:{region:null}),!0):!1},Options:Cm};function Cm(){let{t:e}=H(),t=q(),n=J(e=>e.quick),r=J(e=>e.region);return(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`tabular-nums`,children:e(`quick.points`,{n:n.points.length})}),(0,W.jsxs)(wu,{size:`xs`,variant:`primary`,disabled:!n.region||n.busy,onClick:()=>xm(t),children:[(0,W.jsx)(Se,{size:13}),` `,e(`quick.apply`)]}),(0,W.jsxs)(wu,{size:`xs`,variant:`ghost`,onClick:()=>t.ui.set({quick:null}),children:[(0,W.jsx)(sn,{size:13}),` `,e(`quick.reset`)]})]}):r?(0,W.jsx)(Wp,{}):null,(0,W.jsx)(`span`,{className:`ml-2 text-fg-faint`,children:e(`quick.hint`)})]})}var wm=7,Tm=0;function Em(e){return e.type===`text`?Sf.filter(e=>e.hx!==0):Sf}function Dm(e,t){let n=Ef(e,{hx:0,hy:-1}),r=wf({x:0,y:-22/t},e.rotation);return{x:n.x+r.x,y:n.y+r.y}}var Om=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function km(e,t){let{store:n,boxes:r}=e.api,i=n.getSnapshot();if(i.selection.length!==1||!i.doc)return null;let a=N(i.doc.layers,i.selection[0]);if(!a||!Lr(a.layer)||a.layer.locked)return null;let o=r.get(a.layer.id);if(!o)return null;let s=e.view().zoom;if(Om(e.toScreen(Dm(o,s)),t)<=8)return{layer:a.layer,box:o,hit:{kind:`rotate`}};for(let n of Em(a.layer))if(Om(e.toScreen(Ef(o,n)),t)<=wm)return{layer:a.layer,box:o,hit:{kind:`resize`,handle:n}};return null}var Am=[`ew-resize`,`nwse-resize`,`ns-resize`,`nesw-resize`];function jm(e,t){let n=Math.atan2(e.hy,e.hx)*180/Math.PI+t;return Am[Math.round((n%180+180)%180/45)%4]}var Mm=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M21 12a9 9 0 1 1-3-6.7L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E") 11 11, crosshair`;function Nm(e,t,n){let{api:r}=e,i=r.store.doc,a=Wf(i.layers,n),o=a.map(e=>({id:e.id,x:e.x??0,y:e.y??0})),s=r.boxes.getSnapshot(),c=Gf(s,a),l=new Set(a.map(e=>e.id)),u=[...s.entries()].filter(([e])=>!l.has(e)).map(([,e])=>Vf(e)),d=Af(i.canvas,u),f=`move:${++Tm}`,p=!1;return{cursor:`move`,move(n){let i=n.doc.x-t.doc.x,a=n.doc.y-t.doc.y;if(!(!p&&Math.hypot(n.screen.x-t.screen.x,n.screen.y-t.screen.y)<3)){if(p=!0,n.shift&&(Math.abs(i)>Math.abs(a)?a=0:i=0),c&&!n.mod&&r.ui.get().smartGuides){let t=kf({...c,x:c.x+i,y:c.y+a},d,6/e.view().zoom);i+=t.dx,a+=t.dy,e.setGuides(t.guides)}else e.setGuides([]);o.length&&r.edit(o.map(e=>({op:`updateLayer`,id:e.id,set:{x:Math.round(e.x+i),y:Math.round(e.y+a)}})),{coalesce:f})}},up(){e.setGuides([])},cancel(){e.setGuides([])}}}var Pm=e=>Math.round(e*10)/10;function Fm(e,t,n,r){let i=`resize:${++Tm}`,a=t.type===`text`?t:null;return{cursor:jm(r,n.rotation),move(o){let s=r.hx!==0&&r.hy!==0,c=Df(n,r,o.doc,o.shift||!!a&&s),l;if(a&&s){let e=Math.max(c.width/n.width,4/(a.size??64));l={x:Math.round(c.x),y:Math.round(c.y),size:Pm((a.size??64)*e),...a.width?{width:Math.round(a.width*e)}:{},...a.letterSpacing?{letterSpacing:Pm(a.letterSpacing*e)}:{}}}else l=a?{x:Math.round(c.x),y:Math.round(c.y),width:Math.max(8,Math.round(c.width))}:{x:Math.round(c.x),y:Math.round(c.y),width:Math.max(1,Math.round(c.width)),height:Math.max(1,Math.round(c.height))};e.api.edit([{op:`updateLayer`,id:t.id,set:l}],{coalesce:i})},up(){}}}function Im(e,t,n,r){let i=`rotate:${++Tm}`;return{cursor:Mm,move(a){e.api.edit([{op:`updateLayer`,id:t.id,set:{rotation:Of(n,r.doc,a.doc,a.shift)}}],{coalesce:i})},up(){}}}var Lm={id:`move`,icon:Wt,label:`tools.move`,shortcut:`V`,group:`select`,cursor(e,t){if(!t)return`default`;let n=km(e,t.screen);return n?n.hit.kind===`rotate`?Mm:jm(n.hit.handle,n.box.rotation):`default`},down(e,t){let{api:n}=e,r=n.store.getSnapshot(),i=r.doc;if(!i)return null;let a=km(e,t.screen);if(a)return a.hit.kind===`rotate`?Im(e,a.layer,a.box,t):Fm(e,a.layer,a.box,a.hit.handle);let o=n.boxes.getSnapshot(),s=Uf(i.layers,o,t.doc);if(t.clicks>=2&&s&&N(i.layers,s)?.layer?.type===`text`)return n.store.select(s),n.ui.set({textEdit:{id:s}}),null;let c=Wf(i.layers,r.selection),l=c.length?Gf(o,c):null;return l&&t.doc.x>=l.x&&t.doc.x<=l.x+l.width&&t.doc.y>=l.y&&t.doc.y<=l.y+l.height&&!(t.shift||t.mod)?Nm(e,t,r.selection):s?t.shift||t.mod?(n.store.toggleSelect(s),null):(n.store.select(s),Nm(e,t,[s])):(!t.shift&&!t.mod&&n.store.select(null),null)},Options:Rm};function Rm(){let{t:e}=H(),{ui:t}=q(),n=J(e=>e.smartGuides);return(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,W.jsx)(Du,{checked:n,onChange:e=>t.set({smartGuides:e}),ariaLabel:e(`tools.smartGuides`)}),(0,W.jsx)(`span`,{children:e(`tools.smartGuides`)}),(0,W.jsx)(`span`,{className:`ml-3 text-fg-faint`,children:e(`tools.moveHint`)})]})}var zm=.02;function Bm(e,t,n){let r=Math.max(zm,Math.min(32,e.zoom*t)),i=r/e.zoom;return{zoom:r,x:n.x-(n.x-e.x)*i,y:n.y-(n.y-e.y)*i}}function Vm(e,t){let n=e.view();return{cursor:`grabbing`,move(r){e.setView({...n,x:n.x+r.screen.x-t.screen.x,y:n.y+r.screen.y-t.screen.y})},up(){}}}var Hm={id:`hand`,icon:it,label:`tools.hand`,shortcut:`H`,group:`view`,cursor:()=>`grab`,down:(e,t)=>Vm(e,t)},Um={id:`zoom`,icon:yr,label:`tools.zoom`,shortcut:`Z`,group:`view`,cursor:(e,t)=>t?.alt?`zoom-out`:`zoom-in`,down(e,t){return e.setView(Bm(e.view(),t.alt?.5:2,t.screen)),null}},Wm={id:`eyedropper`,icon:en,label:`tools.eyedropper`,shortcut:`I`,group:`view`,cursor:()=>`crosshair`,down(e,t){let n=e.sampleColor(t.doc);return n&&(e.api.ui.set({fg:n}),ld(n),Q({tone:`info`,title:V(`tools.picked`,{color:n}),detail:V(`tools.pickedHint`)},2400)),null},Options:Gm};function Gm(){let{t:e}=H(),t=q(),n=J(e=>e.fg);return(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`tools.color`)}),(0,W.jsx)(`div`,{className:`w-[120px]`,children:(0,W.jsx)(tf,{value:n,onChange:e=>t.ui.set({fg:e})})}),(0,W.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`tools.eyedropperHint`)})]})}var Km=[Lm,qp,Zp,_m,Sm,Lf,Kf,Yf,fm,pm,mm,Wm,Hm,Um],qm=e=>Km.find(t=>t.id===e)??Lm,Jm=e=>Km.find(t=>t.shortcut.toLowerCase()===e.toLowerCase()),Ym=e=>{let t=e.store.primary,n=e.store.doc,r=t&&n?N(n.layers,t)?.layer:null;return r&&r.type===`image`?r.id:null};function Xm(e,t,n=$r[`background-removal`]){return e.runTool(`remove_background`,{id:t,model:n},{busy:`ai.removingBg`,model:n})}function Zm(e,t,n=$r[`background-removal`]){return e.runTool(`mask_generate`,{id:t,method:`subject`,target:`copy`,model:n},{busy:`ai.selectingSubject`,model:n})}var Qm=[{id:`remove-background`,icon:pr,label:`ai.removeBg`,hint:`ai.removeBgHint`,enabled:e=>!!Ym(e),run:e=>void Xm(e,Ym(e))},{id:`select-subject`,icon:dn,label:`ai.selectSubject`,hint:`ai.selectSubjectHint`,enabled:e=>!!Ym(e),run:e=>void Zm(e,Ym(e))}];function $m(){let{t:e}=H(),t=qm(J(e=>e.tool)),n=t.Options;return(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-3 border-b border-line bg-ink-1/80 px-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-[118px] shrink-0 items-center gap-1.5 whitespace-nowrap text-xs font-medium text-fg`,children:[(0,W.jsx)(t.icon,{size:13,className:`text-fg-muted`}),e(t.label)]}),(0,W.jsx)(`div`,{className:`h-4 w-px bg-line`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto whitespace-nowrap [&_span]:whitespace-nowrap`,children:n?(0,W.jsx)(n,{}):(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:e(`tools.hints.${t.id}`)})})]})}var eh=236,th=6,nh=224,rh=e=>th+e/255*nh,ih=e=>th+(1-e/255)*nh;function ah({points:e,onChange:t,color:n=`rgb(var(--fg))`}){let r=(0,S.useRef)(null),i=(0,S.useRef)(null),[a,o]=(0,S.useState)(null),s=e.length>=2?e:[[0,0],[255,255]],c=hc(s),l=Array.from({length:64},(e,t)=>{let n=Math.round(t/63*255);return`${t?`L`:`M`}${rh(n).toFixed(1)},${ih(c[n]).toFixed(1)}`}).join(``),u=e=>{let t=r.current.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*eh,i=(e.clientY-t.top)/t.height*eh;return{x:Math.round((n-th)/nh*255),y:Math.round((1-(i-th)/nh)*255)}},d=(e,t)=>{let n=s,r=e>0?n[e-1][0]+1:0,i=e<n.length-1?n[e+1][0]-1:255,a=e===0?Math.min(t.x,i):e===n.length-1?Math.max(t.x,r):t.x;return[Math.max(r,Math.min(i,a)),Math.max(0,Math.min(255,t.y))]};return(0,W.jsxs)(`svg`,{ref:r,viewBox:`0 0 ${eh} ${eh}`,className:`aspect-square w-full touch-none select-none rounded-md bg-ink-0`,role:`img`,"aria-label":V(`curve.label`),onPointerDown:e=>{if(e.target.tagName===`circle`)return;let n=u(e),r=[...s,[Math.max(0,Math.min(255,n.x)),Math.max(0,Math.min(255,n.y))]].sort((e,t)=>e[0]-t[0]),a=r.findIndex(e=>e[0]===Math.max(0,Math.min(255,n.x)));t(r,!1),i.current={i:a,out:!1},o(a),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let n=i.current;if(!n||e.buttons!==1)return;let r=u(e);n.out=n.i>0&&n.i<s.length-1&&(r.y<-30||r.y>285||r.x<-30||r.x>285),t(s.map((e,t)=>t===n.i?d(t,r):e),!1)},onPointerUp:()=>{let e=i.current;i.current=null,e&&(t(e.out?s.filter((t,n)=>n!==e.i):s,!0),e.out&&o(null))},children:[[.25,.5,.75].map(e=>(0,W.jsxs)(`g`,{stroke:`rgb(255 255 255 / 0.07)`,children:[(0,W.jsx)(`line`,{x1:th+e*nh,y1:th,x2:th+e*nh,y2:230}),(0,W.jsx)(`line`,{x1:th,y1:th+e*nh,x2:230,y2:th+e*nh})]},e)),(0,W.jsx)(`rect`,{x:th,y:th,width:nh,height:nh,fill:`none`,stroke:`rgb(255 255 255 / 0.12)`}),(0,W.jsx)(`line`,{x1:rh(0),y1:ih(0),x2:rh(255),y2:ih(255),stroke:`rgb(255 255 255 / 0.12)`,strokeDasharray:`3 3`}),(0,W.jsx)(`path`,{d:l,fill:`none`,stroke:n,strokeWidth:1.75}),s.map(([e,r],c)=>(0,W.jsx)(`circle`,{cx:rh(e),cy:ih(r),r:a===c?5:4,fill:a===c?n:`rgb(var(--ink-0))`,stroke:n,strokeWidth:1.5,className:`cursor-grab`,onPointerDown:e=>{e.stopPropagation(),i.current={i:c,out:!1},o(c),e.currentTarget.ownerSVGElement.setPointerCapture(e.pointerId)},onDoubleClick:()=>c>0&&c<s.length-1&&t(s.filter((e,t)=>t!==c),!0)},c))]})}function oh({stops:e,onChange:t,selected:n,onSelect:r}){let i=(0,S.useRef)(null),a=(0,S.useRef)(null),o=e=>{let t=i.current.getBoundingClientRect();return Math.max(0,Math.min(1,(e-t.left)/t.width))},s=`linear-gradient(to right, ${zd(e).map(([e,t])=>`${t} ${e*100}%`).join(`, `)})`;return(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`div`,{ref:i,className:`checker-sm relative h-6 cursor-copy rounded-md ring-1 ring-inset ring-white/10`,title:V(`paint.addStop`),onPointerDown:n=>{if(n.target!==n.currentTarget)return;let i=o(n.clientX),a=[...e,[Math.round(i*1e3)/1e3,Bd(e,i)]];t(a,!0),r(a.length-1)},children:(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-0 rounded-md`,style:{background:s}})}),(0,W.jsx)(`div`,{className:`relative h-4`,children:e.map(([i,s],c)=>(0,W.jsx)(`button`,{type:`button`,"aria-label":V(`paint.stop`,{n:c+1}),onPointerDown:e=>{e.target.setPointerCapture(e.pointerId),a.current={i:c,moved:!1},r(c)},onPointerMove:n=>{let r=a.current;r&&n.buttons===1&&(r.moved=!0,t(e.map((e,t)=>t===r.i?[Math.round(o(n.clientX)*1e3)/1e3,e[1]]:e),!1))},onPointerUp:n=>{let r=a.current;a.current=null,r?.moved&&t(e.map((e,t)=>t===r.i?[Math.round(o(n.clientX)*1e3)/1e3,e[1]]:e),!0)},className:U(`absolute top-0 h-4 w-3 -translate-x-1/2 rounded-[3px] border-2 shadow`,c===n?`border-accent`:`border-white`),style:{left:`${i*100}%`,background:s}},c))})]})}function sh({stops:e,onChange:t}){let[n,r]=(0,S.useState)(0),i=Math.min(n,e.length-1),a=e[i];return(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(oh,{stops:e,onChange:t,selected:i,onSelect:r}),a&&(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(Gd,{width:232,align:`start`,trigger:(e,t)=>(0,W.jsx)(ef,{css:a[1],onClick:e,open:t}),children:()=>(0,W.jsx)(Qd,{value:a[1],onChange:(n,r)=>t(e.map((e,t)=>t===i?[e[0],n]:e),r)})}),(0,W.jsx)(of,{label:`%`,value:Math.round(a[0]*100),min:0,max:100,integer:!0,onChange:(n,r)=>t(e.map((e,t)=>t===i?[n/100,e[1]]:e),r),ariaLabel:V(`paint.position`)}),(0,W.jsx)(`button`,{type:`button`,title:V(`paint.reverse`),"aria-label":V(`paint.reverse`),onClick:()=>t(e.map(([e,t])=>[Math.round((1-e)*1e3)/1e3,t]),!0),className:`flex h-6 w-6 items-center justify-center rounded text-fg-muted hover:bg-ink-3 hover:text-fg`,children:(0,W.jsx)(ie,{size:12})}),(0,W.jsx)(`button`,{type:`button`,title:V(`paint.removeStop`),"aria-label":V(`paint.removeStop`),disabled:e.length<=2,onClick:()=>(t(e.filter((e,t)=>t!==i),!0),r(0)),className:`flex h-6 w-6 items-center justify-center rounded text-fg-muted hover:bg-ink-3 hover:text-danger disabled:opacity-30`,children:(0,W.jsx)(tr,{size:12})})]})]})}function ch({value:e,onChange:t,allowNone:n,fallback:r=`#ffffff`}){let i=e==null?`none`:Ld(e),[a,o]=(0,S.useState)(0),s=n?[`none`,`solid`,`linear`,`radial`]:[`solid`,`linear`,`radial`],c=e&&typeof e==`object`?e:null,l=c?Rd(c):[],u=Math.min(a,Math.max(0,l.length-1)),d=(e,n)=>c&&t({...c,...e},n);return(0,W.jsxs)(`div`,{className:`w-[252px]`,children:[(0,W.jsx)(`div`,{className:`flex gap-0.5 border-b border-line p-1.5`,children:s.map(n=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(n===`none`?null:Ud(e,n,r),!0),className:U(`h-6 flex-1 rounded text-xs font-medium`,i===n?`bg-ink-3 text-fg`:`text-fg-muted hover:text-fg`),children:V(`paint.${n}`)},n))}),i===`solid`&&(0,W.jsx)(Qd,{value:e,onChange:(e,n)=>t(e,n)}),c&&(0,W.jsxs)(`div`,{className:`space-y-2.5 p-2.5`,children:[(0,W.jsx)(oh,{stops:l,selected:u,onSelect:o,onChange:(e,t)=>d({stops:e},t)}),c.type===`linear`?(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(lh,{value:c.angle??90,onChange:(e,t)=>d({angle:e},t)}),(0,W.jsx)(of,{label:`°`,value:c.angle??90,min:-360,max:360,integer:!0,onChange:(e,t)=>d({angle:e},t),ariaLabel:V(`paint.angle`)}),(0,W.jsx)(`button`,{type:`button`,title:V(`paint.reverse`),"aria-label":V(`paint.reverse`),onClick:()=>d({stops:l.map(([e,t])=>[Math.round((1-e)*1e3)/1e3,t])},!0),className:`flex h-6 w-6 items-center justify-center rounded text-fg-muted hover:bg-ink-3 hover:text-fg`,children:(0,W.jsx)(ie,{size:12})})]}):(0,W.jsxs)(`div`,{className:`flex gap-1`,children:[(0,W.jsx)(of,{label:`X`,value:Math.round((c.cx??.5)*100),min:0,max:100,integer:!0,onChange:(e,t)=>d({cx:e/100},t),ariaLabel:V(`paint.centerX`)}),(0,W.jsx)(of,{label:`Y`,value:Math.round((c.cy??.5)*100),min:0,max:100,integer:!0,onChange:(e,t)=>d({cy:e/100},t),ariaLabel:V(`paint.centerY`)}),(0,W.jsx)(of,{label:`R`,value:Math.round((c.radius??1)*100),min:1,max:300,integer:!0,onChange:(e,t)=>d({radius:e/100},t),ariaLabel:V(`paint.radius`)})]}),l[u]&&(0,W.jsxs)(`div`,{className:`-mx-2.5 border-t border-line`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 pt-2 text-2xs text-fg-faint`,children:[(0,W.jsx)(`span`,{children:V(`paint.stop`,{n:u+1})}),(0,W.jsx)(`button`,{type:`button`,disabled:l.length<=2,onClick:()=>(d({stops:l.filter((e,t)=>t!==u)},!0),o(0)),className:`hover:text-danger disabled:opacity-30`,children:V(`paint.removeStop`)})]}),(0,W.jsx)(Qd,{value:l[u][1],onChange:(e,t)=>d({stops:l.map((t,n)=>n===u?[t[0],e]:t)},t)})]})]})]})}function lh({value:e,onChange:t}){let n=(0,S.useRef)(null),r=(e,r,i)=>{let a=n.current.getBoundingClientRect(),o=Math.atan2(e.clientY-(a.top+a.height/2),e.clientX-(a.left+a.width/2))*180/Math.PI;i&&(o=Math.round(o/15)*15),t(Math.round(o),r)};return(0,W.jsx)(`div`,{ref:n,role:`slider`,"aria-label":V(`paint.angle`),"aria-valuenow":e,onPointerDown:e=>(e.target.setPointerCapture(e.pointerId),r(e,!1,e.shiftKey)),onPointerMove:e=>e.buttons===1&&r(e,!1,e.shiftKey),onPointerUp:e=>r(e,!0,e.shiftKey),className:`relative h-6 w-6 shrink-0 cursor-pointer rounded-full bg-ink-2 ring-1 ring-inset ring-line`,children:(0,W.jsx)(`div`,{className:`absolute left-1/2 top-1/2 h-[2px] w-[10px] origin-left rounded bg-fg`,style:{transform:`rotate(${e}deg)`}})})}function uh({value:e,onChange:t,allowNone:n,fallback:r,label:i}){let a=e==null?`none`:Ld(e);return(0,W.jsx)(Gd,{width:252,align:`start`,anchorClass:`flex min-w-0 flex-1`,trigger:(t,n)=>(0,W.jsxs)(`button`,{type:`button`,"aria-label":i??V(`paint.edit`),"aria-expanded":n,onClick:t,className:U(`field flex items-center gap-1.5 pl-0.5`,n&&`border-accent/70 bg-ink-1`),children:[(0,W.jsx)(`span`,{className:`checker-sm relative h-5 w-7 shrink-0 overflow-hidden rounded-[4px] ring-1 ring-inset ring-white/10`,children:(0,W.jsx)(`span`,{className:`absolute inset-0`,style:{background:Hd(e??null)}})}),(0,W.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-muted`,children:a===`none`?V(`paint.none`):a===`solid`?String(e):V(`paint.${a}`)})]}),children:()=>(0,W.jsx)(ch,{value:e,onChange:t,allowNone:n,fallback:r})})}function dh({def:e,value:t,onChange:n,scope:r}){let i=uf(e.name,r),a=t===void 0?e.default:t,o=t!==void 0&&JSON.stringify(t)!==JSON.stringify(e.default),s=()=>n(void 0,!0);switch(e.type){case`number`:case`int`:return(0,W.jsx)(K,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,W.jsx)(sf,{value:typeof a==`number`?a:0,min:e.min??0,max:e.max??100,step:e.step,integer:e.type===`int`,onChange:(e,t)=>n(e,t),ariaLabel:i})});case`boolean`:return(0,W.jsx)(K,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,W.jsx)(Du,{checked:!!a,onChange:e=>n(e,!0),ariaLabel:i})});case`color`:return(0,W.jsx)(K,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,W.jsx)(tf,{value:typeof a==`string`?a:`#000000`,onChange:n})});case`enum`:return(0,W.jsx)(K,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,W.jsx)(Eu,{value:String(a??``),options:(e.options??[]).map(t=>({value:t,label:ff(e.name,t)})),onChange:e=>n(e,!0),ariaLabel:i})});case`rgb`:{let t=Array.isArray(a)&&a.length===3?a:[0,0,0],r=[`#f2766d`,`#7bd88f`,`#6fa8ff`];return(0,W.jsxs)(`div`,{className:`px-3 py-1`,children:[(0,W.jsxs)(`div`,{className:`mb-0.5 flex items-center justify-between text-xs text-fg-muted`,title:e.description,children:[i,o&&(0,W.jsx)(`button`,{type:`button`,onClick:s,className:`text-2xs text-fg-faint hover:text-fg`,children:`↺`})]}),t.map((a,o)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{background:r[o]}}),(0,W.jsx)(sf,{value:a,min:e.min??-100,max:e.max??100,integer:!0,onChange:(e,r)=>n(t.map((t,n)=>n===o?e:t),r),ariaLabel:`${i} ${o+1}`})]},o))]})}case`stops`:{let t=Rd({type:`linear`,stops:Array.isArray(a)?a:[`#000000`,`#ffffff`]});return(0,W.jsxs)(`div`,{className:`px-3 py-1.5`,children:[(0,W.jsx)(`div`,{className:`mb-1 text-xs text-fg-muted`,title:e.description,children:i}),(0,W.jsx)(sh,{stops:t,onChange:(e,t)=>n(e,t)})]})}case`curve`:return null;default:return null}}function fh({filter:e,onChange:t}){return(0,W.jsx)(mh,{filter:e,onChange:t})}var ph=[{id:`rgb`,color:`rgb(var(--fg))`},{id:`red`,color:`#f2766d`},{id:`green`,color:`#7bd88f`},{id:`blue`,color:`#6fa8ff`}];function mh({filter:e,onChange:t}){let{t:n}=H(),[r,i]=(0,S.useState)(`rgb`),a=ph.find(e=>e.id===r),o=Array.isArray(e[r])?e[r]:[[0,0],[255,255]];return(0,W.jsxs)(`div`,{className:`space-y-1.5 px-3 py-1.5`,children:[(0,W.jsx)(`div`,{className:`flex gap-0.5`,children:ph.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`flex h-6 flex-1 items-center justify-center gap-1 rounded text-xs ${r===e.id?`bg-ink-3 text-fg`:`text-fg-muted hover:text-fg`}`,children:[(0,W.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{background:e.color}}),n(`curve.${e.id}`)]},e.id))}),(0,W.jsx)(ah,{points:o,color:a.color,onChange:(e,n)=>t(r,e,n)}),(0,W.jsxs)(`div`,{className:`flex justify-between text-2xs text-fg-faint`,children:[(0,W.jsx)(`span`,{children:n(`curve.hint`)}),Array.isArray(e[r])&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(r,void 0,!0),className:`hover:text-fg`,children:n(`curve.reset`)})]})]})}function hh(e){return Object.fromEntries(e.params.filter(e=>e.default!==void 0).map(e=>[e.name,e.default]))}function gh(){let{t:e}=H(),t=q(),n=Iu();if(!n||n.type===`adjustment`)return(0,W.jsx)(Au,{icon:(0,W.jsx)(Dn,{size:22}),title:e(`effects.noLayer`),children:e(`effects.noLayerHint`)});let r=n.effects??{},i=(e,r,i=!0)=>t.edit([{op:`updateLayer`,id:n.id,set:{effects:{[e]:r}}}],i?{}:{coalesce:`fx:${n.id}:${e}:${r?Object.keys(r).join(`,`):``}`});return(0,W.jsxs)(`div`,{className:`pb-4`,children:[(0,W.jsxs)(`div`,{className:`border-b border-line px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`effects.title`)}),(0,W.jsx)(`div`,{className:`text-2xs text-fg-faint`,children:e(`effects.hint`)})]}),(0,W.jsx)(`div`,{className:`space-y-1.5 p-2`,children:Yr.map(e=>{let t=r[e.id],n=!!t;return(0,W.jsxs)(`div`,{className:U(`overflow-hidden rounded-lg border bg-ink-2/40`,n?`border-line`:`border-line/60`),children:[(0,W.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2.5`,children:[(0,W.jsx)(Du,{checked:n,onChange:t=>i(e.id,t?hh(e):null),ariaLabel:hf(e.id)}),(0,W.jsx)(`span`,{className:U(`flex-1 text-sm font-medium`,!n&&`text-fg-muted`),title:e.description,children:hf(e.id)})]}),n&&(0,W.jsx)(`div`,{className:`border-t border-line/70 py-1`,children:e.params.map(n=>(0,W.jsx)(dh,{def:n,scope:e.id,value:t[n.name],onChange:(t,r)=>i(e.id,{[n.name]:t===void 0?null:t},r)},n.name))})]},e.id)})})]})}var _h=[`auto`,`light`,`tone`,`color`,`detail`,`blur`,`stylize`,`look`];function vh(e){let t={type:e.id};for(let n of e.params)n.default!==void 0&&n.type!==`curve`&&(t[n.name]=n.default);return e.id===`curves`&&(t.rgb=[[0,0],[255,255]]),t}async function yh(e,t,n){let r=t&&(t.type===`image`||t.type===`adjustment`)?t:null,i=await e.runTool(`image_analyze`,r?.type===`image`?{layer:r.id}:{},{busy:`filters.analyzing`});if(!i)return;let a=(i.suggestions??[]).map(e=>({...e.filter}));if(!a.length)return void Q({tone:`success`,title:n(`filters.autoNone`)});let o=e.store.doc,s,c;if(r)s=[{op:`updateLayer`,id:r.id,set:{filters:[...r.filters??[],...a]}}],c=r.id;else{let e=pd(o,`auto-enhance`);s=[{op:`addLayer`,layer:{id:e,type:`adjustment`,name:n(`filters.autoName`),filters:a}}],c=e}e.edit(s,{select:c})&&Q({tone:`success`,title:n(`filters.autoDone`,{n:a.length}),detail:i.suggestions.map(e=>e.issue).join(` · `),action:{label:n(`external.undo`),run:()=>e.store.undo()}},7e3)}function bh(){let{t:e}=H(),t=q(),n=Iu(),[r,i]=(0,S.useState)({}),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!1);if(!n)return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Au,{icon:(0,W.jsx)(Tn,{size:22}),title:e(`filters.noLayer`),children:e(`filters.noLayerHint`)}),(0,W.jsx)(`div`,{className:`flex justify-center`,children:(0,W.jsxs)(wu,{size:`sm`,variant:`subtle`,disabled:s,onClick:async()=>(c(!0),await yh(t,null,e),c(!1)),children:[(0,W.jsx)(kn,{size:13,className:`text-agent`}),` `,e(`filters.autoWhole`)]})})]});let l=n.filters??[],u=n.id,d=e=>{let n=ri(e);n&&(t.edit([{op:`addFilter`,id:u,filter:vh(n)}]),i(e=>({...e,[l.length]:!0})))},f=(e,n,r)=>t.edit([{op:`updateFilter`,id:u,index:e,set:n}],r?{}:{coalesce:`filter:${u}:${e}:${Object.keys(n).join(`,`)}`}),p=(e,n)=>{if(e===n)return;let r=[...l],[i]=r.splice(e,1);r.splice(n,0,i),t.edit([{op:`updateLayer`,id:u,set:{filters:r}}])};return(0,W.jsxs)(`div`,{className:`pb-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:n.type===`adjustment`?e(`filters.adjustTitle`):e(`filters.title`)}),(0,W.jsx)(`div`,{className:`truncate text-2xs text-fg-faint`,children:n.type===`adjustment`?e(`filters.adjustHint`):e(`filters.hint`)})]}),(0,W.jsx)(xh,{onPick:d})]}),(0,W.jsx)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:(0,W.jsxs)(wu,{size:`xs`,variant:`subtle`,disabled:s,onClick:async()=>(c(!0),await yh(t,n,e),c(!1)),className:`flex-1`,children:[(0,W.jsx)(kn,{size:12,className:`text-agent`}),` `,e(`filters.auto`)]})}),!l.length&&(0,W.jsx)(Au,{icon:(0,W.jsx)(Tn,{size:20}),title:e(`filters.empty`),children:e(`filters.emptyHint`)}),(0,W.jsx)(`div`,{className:`space-y-1.5 p-2`,children:l.map((n,s)=>{let c=ri(n.type),d=r[s]??s===l.length-1,m=n.enabled!==!1,h=!!c?.params.some(e=>e.name===`amount`);return(0,W.jsxs)(`div`,{onDragOver:e=>{a&&(e.preventDefault(),a.over!==s&&o({...a,over:s}))},onDrop:e=>{e.preventDefault(),a&&p(a.from,a.over),o(null)},className:U(`overflow-hidden rounded-lg border bg-ink-2/40`,a?.over===s&&a.from!==s?`border-accent`:`border-line`,!m&&`opacity-60`),children:[(0,W.jsxs)(`div`,{className:`flex h-8 items-center gap-1 pl-1 pr-1`,children:[(0,W.jsx)(`span`,{draggable:!0,onDragStart:e=>(o({from:s,over:s}),e.dataTransfer.setData(`text/plain`,String(s))),onDragEnd:()=>o(null),className:`flex h-6 w-4 cursor-grab items-center justify-center text-fg-faint hover:text-fg`,"aria-label":e(`filters.reorder`),children:(0,W.jsx)(nt,{size:12})}),(0,W.jsx)(G,{label:e(m?`filters.disable`:`filters.enable`),onClick:()=>f(s,{enabled:!m&&null},!0),className:`h-6 w-6`,children:m?(0,W.jsx)(We,{size:13}):(0,W.jsx)(He,{size:13})}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>({...e,[s]:!d})),className:`flex min-w-0 flex-1 items-center gap-1 text-left`,children:[d?(0,W.jsx)(we,{size:12,className:`shrink-0 text-fg-faint`}):(0,W.jsx)(Ee,{size:12,className:`shrink-0 text-fg-faint`}),(0,W.jsx)(`span`,{className:`truncate text-sm font-medium`,children:pf(n.type)}),n.type===`look`&&typeof n.look==`string`&&(0,W.jsxs)(`span`,{className:`truncate text-xs text-fg-muted`,children:[`· `,_f(n.look)]}),!c&&(0,W.jsx)(`span`,{className:`text-2xs text-danger`,children:`?`})]}),!h&&(0,W.jsxs)(`span`,{className:`text-2xs tabular-nums text-fg-faint`,children:[Math.round((typeof n.amount==`number`?n.amount:1)*100),`%`]}),(0,W.jsx)(G,{label:e(`filters.remove`),onClick:()=>t.edit([{op:`removeFilter`,id:u,index:s}]),className:`h-6 w-6 hover:text-danger`,children:(0,W.jsx)(tr,{size:12})})]}),d&&c&&(0,W.jsxs)(`div`,{className:`border-t border-line/70 pb-1.5 pt-1`,children:[c.id===`curves`?(0,W.jsx)(fh,{filter:n,onChange:(e,t,n)=>f(s,{[e]:t===void 0?null:t},n)}):c.params.map(e=>(0,W.jsx)(dh,{def:e,scope:c.id,value:n[e.name],onChange:(t,n)=>f(s,{[e.name]:t===void 0?null:t},n)},e.name)),!h&&(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-line/50 px-3 pt-1.5`,children:[(0,W.jsx)(`span`,{className:`w-[86px] shrink-0 text-xs text-fg-muted`,children:e(`filters.amount`)}),(0,W.jsx)(sf,{value:Math.round((typeof n.amount==`number`?n.amount:1)*100),min:0,max:100,integer:!0,onChange:(e,t)=>f(s,{amount:e>=100?null:e/100},t),ariaLabel:e(`filters.amount`)})]})]})]},s)})})]})}function xh({onPick:e}){let{t}=H(),[n,r]=(0,S.useState)(``),i=(0,S.useRef)(null),a=(0,S.useMemo)(()=>{let e=n.trim().toLowerCase();return _h.map(t=>({g:t,list:qr.filter(n=>n.group===t&&(!e||pf(n.id).toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)))})).filter(e=>e.list.length)},[n]);return(0,W.jsx)(Gd,{width:268,trigger:(e,n)=>(0,W.jsxs)(wu,{size:`xs`,variant:n?`subtle`:`primary`,onClick:()=>(e(),setTimeout(()=>i.current?.focus(),30)),children:[(0,W.jsx)(nn,{size:12}),` `,t(`filters.add`)]}),children:o=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-2.5`,children:[(0,W.jsx)(hn,{size:12,className:`text-fg-faint`}),(0,W.jsx)(`input`,{ref:i,value:n,onChange:e=>r(e.target.value),placeholder:t(`filters.search`),className:`h-8 flex-1 bg-transparent text-sm outline-none placeholder:text-fg-faint`})]}),(0,W.jsx)(`div`,{className:`max-h-[420px] overflow-auto py-1`,children:a.map(({g:t,list:n})=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pb-0.5 pt-2 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:mf(t)}),n.map(t=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>(e(t.id),o(),r(``)),className:`block w-full px-3 py-1 text-left hover:bg-ink-3`,title:t.description,children:(0,W.jsx)(`div`,{className:`text-sm`,children:pf(t.id)})},t.id))]},t))})]})})}var Sh=Promise.resolve();function Ch(e){let t=Sh.then(e,e);return Sh=t.catch(()=>void 0),t}var wh=()=>typeof window<`u`?Math.min(2,window.devicePixelRatio||1):1;function Th({layer:e,w:t,h:n}){let r=q(),i=Fu(),a=J(e=>e.filesVersion),o=(0,S.useRef)(null),[s,c]=(0,S.useState)(!1),l=`${so(e)}|${i.canvas.width}x${i.canvas.height}|${a}`;(0,S.useEffect)(()=>{let a=!1,s=setTimeout(()=>{Ch(async()=>{if(a)return;let s=r.boxes.get(e.id),l=s?Vf(s):null,u=!!l&&l.width*l.height<i.canvas.width*i.canvas.height*.25,d=u?l.width:i.canvas.width,f=u?l.height:i.canvas.height,p=Math.min(t/d,n/f)*wh()*(u?.9:1),m=await r.thumbs.layerSurface({...e,visible:!0,opacity:1,blend:`normal`,clip:!1},i,p).catch(()=>null),h=o.current;if(!h||a)return;h.width=Math.max(1,Math.round(u?t*wh():i.canvas.width*p)),h.height=Math.max(1,Math.round(u?n*wh():i.canvas.height*p));let g=h.getContext(`2d`);g.clearRect(0,0,h.width,h.height);let _=u?(h.width-l.width*p)/2-l.x*p:0,v=u?(h.height-l.height*p)/2-l.y*p:0;m&&g.drawImage(m.canvas,m.x+_,m.y+v),c(u)})},160);return()=>{a=!0,clearTimeout(s)}},[l]);let u=i.canvas.width/i.canvas.height,d=s||u>=t/n?t:n*u,f=s?n:u>=t/n?t/u:n;return(0,W.jsx)(`div`,{className:`flex shrink-0 items-center justify-center`,style:{width:t,height:n},children:(0,W.jsx)(`canvas`,{ref:o,className:`checker-sm rounded-[2px] ring-1 ring-white/10`,style:{width:d,height:f}})})}function Eh({mask:e,w:t,h:n,frame:r}){let i=q(),a=J(e=>e.filesVersion),o=(0,S.useRef)(null),s=Rr(e)?e.src:null;if((0,S.useEffect)(()=>{if(!s)return;let r=!1;return Ch(async()=>{let a=await i.engine.loader.image(s).catch(()=>null),c=o.current;if(!a||!c||r)return;c.width=t*2,c.height=n*2;let l=c.getContext(`2d`);l.fillStyle=`#000`,l.fillRect(0,0,c.width,c.height);let u=Math.min(c.width/a.width,c.height/a.height);l.drawImage(a,(c.width-a.width*u)/2,(c.height-a.height*u)/2,a.width*u,a.height*u),e.invert&&(l.globalCompositeOperation=`difference`,l.fillStyle=`#fff`,l.fillRect(0,0,c.width,c.height))}),()=>{r=!0}},[i,s,t,n,a,e.invert]),s)return(0,W.jsx)(`canvas`,{ref:o,style:{width:t,height:n},className:`rounded-[2px] bg-black`});if(Br(e))return(0,W.jsx)(`div`,{style:{width:t,height:n,background:Hd(e.gradient),filter:`grayscale(1)${e.invert?` invert(1)`:``}`},className:`rounded-[2px]`});let c=e,l=r?.width||c.x+c.width||1,u=r?.height||c.y+c.height||1,d=(e,t)=>`${Math.max(-50,Math.min(150,e/t*100))}%`;return(0,W.jsx)(`div`,{style:{width:t,height:n,background:e.invert?`#fff`:`#000`},className:`relative overflow-hidden rounded-[2px]`,children:(0,W.jsx)(`div`,{className:`absolute`,style:{left:d(c.x,l),top:d(c.y,u),width:d(c.width,l),height:d(c.height,u),background:e.invert?`#000`:`#fff`,borderRadius:c.shape===`ellipse`?`50%`:1,filter:e.feather?`blur(1px)`:void 0}})})}var Dh=104,Oh=72;function kh(e,t){if(t&&(t.type===`image`||t.type===`adjustment`||t.type===`group`))return{layer:t,index:(t.filters??[]).findIndex(e=>e.type===`look`),kind:t.type===`image`?`layer`:`picture`};for(let t=e.layers.length-1;t>=0;t--){let n=e.layers[t];if(n.type===`adjustment`){let e=n.filters.findIndex(e=>e.type===`look`);if(e>=0)return{layer:n,index:e,kind:`picture`}}}return{layer:null,index:-1,kind:`picture`}}function Ah(e,t){return{...e,filters:(e.filters??[]).filter((e,n)=>n!==t)}}function jh(){let{t:e}=H(),t=q(),n=Pu().doc,r=Iu(),i=J(e=>e.filesVersion),a=kh(n,r),o=a.layer&&a.index>=0?a.layer.filters[a.index]:null,s=o&&typeof o.look==`string`?o.look:null,c=(0,S.useMemo)(()=>new Nl({assetBase:``,libraryBase:``},t.engine.loader),[t]),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(1),p=JSON.stringify([a.kind===`layer`?Ah(a.layer,a.index):null,a.kind===`picture`?n.layers.map(e=>e===a.layer?Ah(e,a.index):e):null,n.canvas,i]);(0,S.useEffect)(()=>{let e=!0,r=setTimeout(()=>{Ch(async()=>{try{let r;if(a.kind===`layer`&&a.layer){let e={...n,layers:n.layers.map(function e(t){return t.id===a.layer.id?Ah(t,a.index):t.type===`group`?{...t,children:t.children.map(e)}:t})};r=await c.layerPixels(e,a.layer.id,{maxSide:208,withFilters:!0})}else{let e={...n,layers:a.layer?n.layers.map(e=>e.id===a.layer.id?Ah(e,a.index):e):n.layers},t=Math.min(208/n.canvas.width,144/n.canvas.height)*1.6;r=await c.render(e,{scale:Math.min(1,t)})}if(e){let e=a.kind===`layer`&&a.layer?t.boxes.get(a.layer.id)?.width??r.width:n.canvas.width;f(r.width/Math.max(1,e)),u(r)}}catch{e&&u(null)}})},150);return()=>{e=!1,clearTimeout(r)}},[p,c]);let m=r=>{if(!r)a.layer&&a.index>=0&&(a.layer.type===`adjustment`&&a.layer.filters.length===1?t.edit([{op:`removeLayer`,id:a.layer.id}]):t.edit([{op:`removeFilter`,id:a.layer.id,index:a.index}]));else if(a.layer&&a.index>=0)t.edit([{op:`updateFilter`,id:a.layer.id,index:a.index,set:{look:r}}]);else if(a.layer)t.edit([{op:`addFilter`,id:a.layer.id,filter:{type:`look`,look:r,amount:.85}}]);else{let i=pd(n,`look`);t.edit([{op:`addLayer`,layer:{id:i,type:`adjustment`,name:e(`looks.layerName`),filters:[{type:`look`,look:r,amount:.85}]}}])}};return(0,W.jsxs)(`div`,{className:`pb-4`,children:[(0,W.jsxs)(`div`,{className:`border-b border-line px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`looks.title`)}),(0,W.jsx)(`div`,{className:`truncate text-2xs text-fg-faint`,children:a.kind===`layer`?e(`looks.onLayer`,{name:a.layer?.name??a.layer?.id??``}):e(`looks.onPicture`)})]}),o&&a.layer&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`w-[70px] shrink-0 text-xs text-fg-muted`,children:e(`looks.intensity`)}),(0,W.jsx)(sf,{value:Math.round((typeof o.amount==`number`?o.amount:1)*100),min:0,max:100,integer:!0,onChange:(e,n)=>t.edit([{op:`updateFilter`,id:a.layer.id,index:a.index,set:{amount:e>=100?null:e/100}}],n?{}:{coalesce:`look-amount:${a.layer.id}`}),ariaLabel:e(`looks.intensity`)})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 p-2.5`,children:[(0,W.jsx)(Mh,{id:null,title:e(`looks.none`),base:l,scale:d,active:!s,onClick:()=>m(null)}),Kr.map(e=>(0,W.jsx)(Mh,{id:e.id,title:_f(e.id),base:l,scale:d,active:s===e.id,onClick:()=>m(e.id),hint:e.description},e.id))]})]})}function Mh({id:e,title:t,base:n,scale:r,active:i,onClick:a,hint:o}){let s=(0,S.useRef)(null),[c,l]=(0,S.useState)(!1);return(0,S.useEffect)(()=>{if(!n)return;let t=!0;return Ch(async()=>{let i=s.current;if(!i||!t)return;let a=wc(208,144),o=Math.max(208/n.width,144/n.height);if(z(a).drawImage(n,(208-n.width*o)/2,(144-n.height*o)/2,n.width*o,n.height*o),e){let t=Tc(a);el(t,[{type:`look`,look:e}],{scale:r*o}),Ec(a,t)}i.width=208,i.height=144,i.getContext(`2d`).drawImage(a,0,0),t&&l(!0)}),()=>{t=!1}},[n,e,r]),(0,W.jsxs)(`button`,{type:`button`,onClick:a,title:o,"aria-pressed":i,className:U(`group relative overflow-hidden rounded-lg text-left ring-1 transition`,i?`ring-2 ring-accent`:`ring-white/10 hover:ring-white/30`),children:[(0,W.jsxs)(`div`,{className:`checker-sm relative`,style:{aspectRatio:`${Dh} / ${Oh}`},children:[(0,W.jsx)(`canvas`,{ref:s,className:U(`absolute inset-0 h-full w-full object-cover transition-opacity`,c?`opacity-100`:`opacity-0`)}),!c&&n&&(0,W.jsx)(Mt,{size:14,className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin text-fg-faint`}),!e&&c&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/30`,children:(0,W.jsx)(fe,{size:16,className:`text-white/80`})}),i&&(0,W.jsx)(`span`,{className:`absolute right-1 top-1 flex h-4 w-4 items-center justify-center rounded-full bg-accent text-ink-0`,children:(0,W.jsx)(Se,{size:10,strokeWidth:3})})]}),(0,W.jsx)(`div`,{className:`flex items-center justify-between bg-ink-2/80 px-2 py-1 text-xs`,children:(0,W.jsx)(`span`,{className:`truncate`,children:t})})]})}var Nh=class{engine;onFrame;pending=null;requested=0;running=!1;raf=0;disposed=!1;constructor(e,t){this.engine=e,this.onFrame=t}request(e){this.pending={...e,seq:++this.requested},this.running||this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.run()}))}async run(){let e=this.pending;if(!e||this.disposed)return;this.pending=null,this.running=!0;let t=performance.now(),n=[];try{let r=await this.engine.render(e.doc,{scale:e.scale,skip:e.skip,only:e.only,onError:(e,t)=>n.push({layer:e,message:t})});this.disposed||this.onFrame({canvas:r,scale:e.scale,ms:performance.now()-t,seq:e.seq,errors:n})}catch(n){this.disposed||this.onFrame({canvas:null,scale:e.scale,ms:performance.now()-t,seq:e.seq,errors:[{layer:`*`,message:n.message}]})}finally{this.running=!1,this.pending&&!this.disposed&&!this.raf&&(this.raf=requestAnimationFrame(()=>{this.raf=0,this.run()}))}}dispose(){this.disposed=!0,this.raf&&cancelAnimationFrame(this.raf)}},Ph={current:null},Fh=new Set([`marquee`,`lasso`,`wand`,`quick`,`brush`,`eraser`,`clone`]),Ih=e=>{let t=e.target;return!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)};function Lh(e,t){let n=e.ui.get().tool;n!==t&&(qm(n).deactivate?.(e),e.ui.set({tool:t,textEdit:null}),qm(t).activate?.(e))}function Rh(e){let t=e.store.doc,n=e.store.getSnapshot().selection;if(!t||!n.length)return;let r=new Set(da(t)),i=[],a=[];for(let e of n){let t=Si(`${e}-copy`,r);r.add(t),i.push({op:`duplicateLayer`,id:e,newId:t}),a.push(t)}e.edit(i,{select:a})}function zh(e){let t=e.store.doc,n=e.store.getSnapshot().selection.filter(e=>t&&N(t.layers,e));if(!n.length)return;let r=n.filter(e=>!n.some(n=>n!==e&&N(N(t.layers,n)?.layer?.children??[],e)));e.edit(r.map(e=>({op:`removeLayer`,id:e})),{select:null})}function Bh(e){let t=e.store.doc;if(!t)return;let n=Cd(t,e.store.getSnapshot().selection);if(!n)return void Q({tone:`error`,title:V(`layers.groupSiblings`)});e.edit(n.ops,{select:n.id})}function Vh(e){let t=e.store.doc,n=e.store.primary,r=n&&t?N(t.layers,n)?.layer:null;r&&r.type===`group`&&e.edit([{op:`ungroup`,id:r.id}],{select:(r.children??[]).map(e=>e.id)})}function Hh(e,t){let n=document.querySelector(`[data-viewport]`)?.getBoundingClientRect();e.ui.set(e=>({view:Bm(e.view,t,{x:(n?.width??800)/2,y:(n?.height??600)/2})}))}function Uh(e,t){let n=e.ui.get().view;Hh(e,t/n.zoom)}function Wh(){let e=q();(0,S.useEffect)(()=>{let t=t=>{let n=t.metaKey||t.ctrlKey,{store:r,ui:i}=e,a=t.key.toLowerCase();if(n&&a===`z`){if(Ih(t))return;t.preventDefault(),t.shiftKey?r.redo():r.undo();return}if(n&&a===`y`){if(Ih(t))return;t.preventDefault(),r.redo();return}if(n&&a===`s`){t.preventDefault(),r.flush().then(()=>Q({tone:`success`,title:V(`save.savedToast`)},1600));return}if(Ih(t)||i.get().dialog)return;let o=Ph.current;if(o&&qm(i.get().tool).key?.(o,t)){t.preventDefault();return}if(n){if(a===`d`)t.preventDefault(),Rh(e);else if(a===`g`)t.preventDefault(),t.shiftKey?Vh(e):Bh(e);else if(a===`0`)t.preventDefault(),i.set(e=>({fitRequest:e.fitRequest+1}));else if(a===`1`)t.preventDefault(),Uh(e,1);else if(a===`=`||a===`+`)t.preventDefault(),Hh(e,1.25);else if(a===`-`)t.preventDefault(),Hh(e,.8);else if(a===`a`){t.preventDefault();let n=r.doc;Fh.has(i.get().tool)?Up(e):n&&r.select(n.layers.map(e=>e.id).reverse())}else a===`i`&&t.shiftKey&&(t.preventDefault(),Vp(e));return}let s={arrowleft:[-1,0],arrowright:[1,0],arrowup:[0,-1],arrowdown:[0,1]};if(s[a]){let n=r.doc,i=r.getSnapshot().selection;if(!n||!i.length)return;t.preventDefault();let o=t.shiftKey?10:1,c=Td(n,i,s[a][0]*o,s[a][1]*o);c.length&&e.edit(c,{coalesce:`nudge`})}else switch(t.key){case`Escape`:i.get().textEdit?i.set({textEdit:null}):i.get().region?i.set({region:null}):r.select(null);break;case`Delete`:case`Backspace`:t.preventDefault(),i.get().region&&r.primary?Fp(e):zh(e);break;case`Tab`:t.preventDefault(),i.set(e=>({panelsHidden:!e.panelsHidden}));break;case`?`:i.set({dialog:`shortcuts`});break;case`[`:case`]`:{let e=t.key===`]`?1.15:1/1.15;i.set(n=>({brush:{...n.brush,size:Math.max(1,Math.min(2e3,Math.round(n.brush.size*e+(t.key===`]`?1:-1))))}}));break}default:{if(t.altKey||t.shiftKey)return;let n=Jm(t.key);n&&Lh(e,n.id)}}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function Gh(){let e=q(),t=J(e=>e.textEdit),n=J(e=>e.view),r=J(e=>e.fg),i=Pu().doc,a=(0,S.useRef)(null),o=(0,S.useRef)(!1),[s,c]=(0,S.useState)(null),l=t?.id?N(i.layers,t.id)?.layer:void 0,[u]=(0,S.useState)(()=>t&&`x`in t?_d(i,{x:t.x,y:t.y},``,{color:r}):null),d=l??u,f=l?e.boxes.get(l.id):null;if((0,S.useEffect)(()=>{if(!d)return;let t=ai(d.font??`inter`);e.engine.loader.font?.(d.font??`inter`,d.weight??400,!!d.italic).then(e=>c(e??t?.family??null)).catch(()=>c(t?.family??null))},[e,d?.font,d?.weight,d?.italic]),(0,S.useLayoutEffect)(()=>{let e=a.current;if(!e||!d)return;e.innerText=d.text,e.focus();let t=document.createRange();t.selectNodeContents(e),d.text||t.collapse(!1);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},[]),!t||!d)return null;let p=()=>{if(o.current)return;o.current=!0;let t=(a.current?.innerText??``).replace(/\n$/,``),n=e.store.doc;if(l)t.trim()?t!==l.text&&e.edit([{op:`updateLayer`,id:l.id,set:{text:t}}]):e.edit([{op:`removeLayer`,id:l.id}],{select:null});else if(t.trim()){let i=_d(n,{x:d.x??0,y:d.y??0},t,{color:Vd(d.color,r),size:d.size}),a=e.store.primary;e.edit([{op:`addLayer`,layer:i,...a?{above:a}:{}}],{select:i.id})}e.ui.set({textEdit:null})},m=n.zoom,h=f?.x??d.x??0,g=f?.y??d.y??0,_=(d.size??64)*m,v=d.transform===`uppercase`?`uppercase`:d.transform===`lowercase`?`lowercase`:`none`;return(0,W.jsx)(`div`,{ref:a,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,role:`textbox`,"aria-multiline":!0,onBlur:p,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),(e.key===`Escape`||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),a.current?.blur())},className:`absolute z-10 cursor-text outline outline-1 outline-offset-2 outline-accent/80`,style:{left:n.x+h*m,top:n.y+g*m,minWidth:Math.max(8,_*.5),width:d.width?d.width*m:void 0,whiteSpace:d.width?`pre-wrap`:`pre`,fontFamily:s?`"${s}", sans-serif`:`sans-serif`,fontSize:_,fontWeight:d.weight??400,fontStyle:d.italic?`italic`:`normal`,lineHeight:d.lineHeight??1.2,letterSpacing:(d.letterSpacing??0)*m,textAlign:d.align??`left`,textTransform:v,color:Vd(d.color,`#ffffff`),caretColor:`rgb(var(--accent))`,transform:d.rotation?`rotate(${d.rotation}deg)`:void 0,transformOrigin:`center`,background:d.background?.color,textShadow:`0 0 1px rgb(0 0 0 / 0.15)`}})}var Kh=`rgb(255 79 216)`;function qh(e,t){let n=e*t;return n>=1?1:Math.min(1,2**(Math.ceil(Math.log2(n)*4)/4))}function Jh(e,t,n,r=56){let i=Math.max(.02,Math.min(4,(t-r*2)/e.canvas.width,(n-r*2)/e.canvas.height));return{zoom:i,x:Math.round((t-e.canvas.width*i)/2),y:Math.round((n-e.canvas.height*i)/2)}}function Yh(e,t){let n=N(e.layers,t)?.layer;if(!n||!n.mask)return null;let{filters:r,effects:i,clip:a,...o}=n,s={...o,opacity:1,blend:`normal`,visible:!0,effects:{colorOverlay:{color:`#ffffff`}}};return n.type===`adjustment`||n.type===`group`?{...e,canvas:{...e.canvas,background:`#000000`},layers:[{id:`mask-preview`,type:`fill`,fill:`#ffffff`,mask:n.mask}]}:{...e,canvas:{...e.canvas,background:`#000000`},layers:[s]}}function Xh(){let{t:e}=H(),t=q(),{ui:n,store:r,engine:i,boxes:a}=t,o=Pu(),s=o.doc,c=o.selection,l=J(e=>e.view),u=J(e=>e.tool),d=J(e=>e.textEdit),f=J(e=>e.region),p=J(e=>e.quick),m=J(e=>e.brush.size),h=J(e=>e.cloneSource),g=J(e=>e.crop),_=J(e=>e.flash),v=J(e=>e.fitRequest),y=J(e=>e.filesVersion),b=J(e=>e.showMask),x=(0,S.useSyncExternalStore)(a.subscribe,a.getSnapshot),ee=(0,S.useRef)(null),te=(0,S.useRef)(null),C=(0,S.useRef)(1),[w,T]=(0,S.useState)([]),[ne,re]=(0,S.useState)(null),[ie,ae]=(0,S.useState)(null),oe=(0,S.useRef)(null),se=(0,S.useRef)(null),ce=(0,S.useRef)(null),le=(0,S.useRef)([]),[ue,de]=(0,S.useState)(null),[fe,pe]=(0,S.useState)(null),[me,he]=(0,S.useState)(`default`),[ge,_e]=(0,S.useState)(!1),[ve,ye]=(0,S.useState)({w:0,h:0}),[be,xe]=(0,S.useState)(!1),Se=(0,S.useRef)(null),Ce=(0,S.useRef)(!1),we=typeof window<`u`&&window.devicePixelRatio||1,E=(0,S.useMemo)(()=>new Nh(i,e=>{let t=te.current;if(!t||!e.canvas)return;(t.width!==e.canvas.width||t.height!==e.canvas.height)&&(t.width=e.canvas.width,t.height=e.canvas.height);let r=t.getContext(`2d`,{willReadFrequently:!0});r.clearRect(0,0,t.width,t.height),r.drawImage(e.canvas,0,0),C.current=e.scale,xe(!0),le.current=le.current.filter(t=>e.seq>=t.seq?(t.resolve(),!1):!0),n.set({renderMs:Math.round(e.ms)})}),[i,n]);(0,S.useEffect)(()=>()=>E.dispose(),[E]);let D=qh(l.zoom,we),[Te,Ee]=(0,S.useState)(D);(0,S.useEffect)(()=>{let e=setTimeout(()=>Ee(D),D>Te?120:250);return()=>clearTimeout(e)},[D,Te]);let De=d?.id??null;(0,S.useEffect)(()=>{let e=b?Yh(s,b):null,t=[De,ie?.hide].filter(e=>!!e);E.request({doc:e??s,scale:Te,skip:t.length?new Set(t):void 0})},[E,s,Te,De,y,b,ie?.hide]),(0,S.useLayoutEffect)(()=>{let e=ee.current;if(!e)return;let t={w:e.clientWidth,h:e.clientHeight},r=new ResizeObserver(()=>{let r={w:e.clientWidth,h:e.clientHeight};if(t.w&&t.h&&(r.w!==t.w||r.h!==t.h)){let e=(r.w-t.w)/2,i=(r.h-t.h)/2;n.set(t=>({view:{...t.view,x:t.view.x+e,y:t.view.y+i}}))}t=r,ye(r)});return r.observe(e),ye({w:e.clientWidth,h:e.clientHeight}),()=>r.disconnect()},[n]);let Oe=(0,S.useRef)(-1);(0,S.useLayoutEffect)(()=>{ve.w&&ve.h&&Oe.current!==v&&(Oe.current=v,n.set({view:Jh(r.doc,ve.w,ve.h)}))},[v,ve,n,r]);let ke=(0,S.useMemo)(()=>({api:t,view:()=>n.get().view,setView:e=>n.set({view:e}),toScreen:e=>{let t=n.get().view;return{x:t.x+e.x*t.zoom,y:t.y+e.y*t.zoom}},sampleColor:e=>{let t=te.current;if(!t)return null;let n=C.current,r=Math.floor(e.x*n),i=Math.floor(e.y*n);if(r<0||i<0||r>=t.width||i>=t.height)return null;let a=t.getContext(`2d`,{willReadFrequently:!0}).getImageData(r,i,1,1).data;return a[3]===0?null:Pd({r:a[0],g:a[1],b:a[2],a:a[3]/255})},setGuides:T,setDraft:de,setPath:e=>re(e?{...e,cursor:ce.current??void 0}:null),setOverlay:e=>ae(e),pointer:()=>ce.current,nextFrame:()=>new Promise(e=>{le.current.push({seq:E.requested+1,resolve:e}),setTimeout(e,1500)})}),[t,n,E]);(0,S.useEffect)(()=>(Ph.current=ke,()=>{Ph.current===ke&&(Ph.current=null)}),[ke]),(0,S.useEffect)(()=>{qm(u).activate?.(t)},[u,t]);let Ae=(0,S.useCallback)(e=>{let t=ee.current.getBoundingClientRect(),r=n.get().view,i={x:e.clientX-t.left,y:e.clientY-t.top};return{screen:i,doc:{x:(i.x-r.x)/r.zoom,y:(i.y-r.y)/r.zoom},shift:e.shiftKey,alt:e.altKey,mod:e.metaKey||e.ctrlKey,button:e.button??0,clicks:e.detail??1}},[n]);(0,S.useEffect)(()=>{let e=ee.current;if(!e)return;let t=t=>{t.preventDefault();let r=e.getBoundingClientRect(),i=n.get().view;if(t.ctrlKey||t.metaKey){let e=Math.max(-60,Math.min(60,t.deltaY*(t.deltaMode===1?16:1))),a=Math.exp(-e*.0075);n.set({view:Bm(i,a,{x:t.clientX-r.left,y:t.clientY-r.top})})}else{let e=t.deltaMode===1?16:1;n.set({view:{...i,x:i.x-(t.shiftKey&&!t.deltaX?t.deltaY:t.deltaX)*e,y:i.y-(t.shiftKey&&!t.deltaX?0:t.deltaY)*e}})}};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[n]),(0,S.useEffect)(()=>{let e=e=>{e.key===` `&&!Ih(e)&&(Ce.current||he(`grab`),Ce.current=!0,e.preventDefault())},t=e=>{e.key===` `&&(Ce.current=!1,he(`default`))};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]),(0,S.useEffect)(()=>{let e=e=>{if(Ih(e)||n.get().dialog)return;let r=[...e.clipboardData?.files??[]].filter(e=>e.type.startsWith(`image/`));r.length&&(e.preventDefault(),tg(r).then(e=>t.importImages(e)))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[t,n]);let je=e=>{if(e.button===2)return;if(n.get().textEdit){document.activeElement?.blur?.(),n.get().textEdit&&n.set({textEdit:null});return}let t=Ae(e),r=qm(n.get().tool),i;e.button===1||Ce.current||r.id===`hand`?i=Vm(ke,t):e.button===0&&(i=r.down?.(ke,t)),i&&(Se.current=i,e.currentTarget.setPointerCapture(e.pointerId),i.cursor&&he(i.cursor),e.preventDefault())},Me=e=>{let t=Ae(e);n.set({cursor:{x:Math.floor(t.doc.x),y:Math.floor(t.doc.y)}}),ce.current=t.doc,Ne(t.screen);let i=Se.current;if(i){i.move(t);return}if(Ce.current)return he(`grab`);let o=qm(n.get().tool);he(o.cursor(ke,t)),o.hover?.(ke,t),o.id===`move`&&r.doc?pe(Uf(r.doc.layers,a.getSnapshot(),t.doc)):fe&&pe(null)},Ne=e=>{let t=se.current;t&&(t.style.transform=`translate(${e.x}px, ${e.y}px)`,t.style.display=`block`)},Pe=(e,t=!1)=>{let r=Se.current;if(Se.current=null,!r)return;t?r.cancel?.():r.up(Ae(e));let i=qm(n.get().tool);he(Ce.current?`grab`:i.cursor(ke,Ae(e)))},Fe=e=>{e.preventDefault(),_e(!1);let n=[...e.dataTransfer.files].filter(e=>e.type.startsWith(`image/`)||/\.(png|jpe?g|webp|gif|avif|bmp|svg)$/i.test(e.name));if(!n.length)return;let r=Ae({clientX:e.clientX,clientY:e.clientY,shiftKey:!1,altKey:!1,metaKey:!1,ctrlKey:!1});tg(n).then(e=>t.importImages(e,r.doc))},O=l.zoom,k=e=>({x:l.x+e.x*O,y:l.y+e.y*O}),Ie=e=>e.map(e=>k(e)).map(e=>`${e.x},${e.y}`).join(` `),Le=s.canvas.width*O,Re=s.canvas.height*O,ze=c.map(e=>N(s.layers,e)?.layer).filter(e=>!!e),Be=ze[ze.length-1],Ve=ze.length===1&&Be&&Lr(Be)?x.get(Be.id):void 0,He=!Ve&&ze.length?Gf(x,Wf(s.layers,c)):null,Ue=u===`move`&&Ve&&Be&&!Be.locked&&!d,We=(0,S.useMemo)(()=>f?.kind===`raster`?gp(f.raster):null,[f]),Ge=_&&Date.now()-_.at<3e3?_:null;return(0,W.jsxs)(`div`,{ref:ee,"data-viewport":!0,tabIndex:-1,className:U(`viewport-stage relative min-h-0 flex-1 overflow-hidden outline-none`,ge&&`ring-2 ring-inset ring-accent/60`),style:{cursor:me},onPointerDown:je,onMouseDown:e=>{e.target.isContentEditable||e.preventDefault()},onPointerMove:Me,onPointerUp:e=>Pe(e),onPointerCancel:e=>Pe(e,!0),onPointerLeave:()=>{n.set({cursor:null}),pe(null),se.current&&(se.current.style.display=`none`)},onContextMenu:e=>e.preventDefault(),onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),_e(!0))},onDragLeave:()=>_e(!1),onDrop:Fe,children:[(0,W.jsx)(`div`,{className:`checker canvas-shadow absolute`,style:{left:l.x,top:l.y,width:Le,height:Re},children:(0,W.jsx)(`canvas`,{ref:te,className:U(`absolute inset-0 h-full w-full transition-opacity duration-150`,be?`opacity-100`:`opacity-0`),style:{imageRendering:O*we>=2.5?`pixelated`:`auto`}})}),(0,W.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 h-full w-full overflow-visible`,children:[fe&&!c.includes(fe)&&x.get(fe)&&u===`move`&&(0,W.jsx)(`polygon`,{points:Ie($(x.get(fe))),fill:`none`,stroke:`rgb(var(--accent) / 0.7)`,strokeWidth:1}),!g&&ze.map(e=>{let t=Lr(e)?x.get(e.id):void 0;return t?(0,W.jsx)(`polygon`,{points:Ie($(t)),fill:`none`,stroke:`rgb(var(--accent))`,strokeWidth:1.25},e.id):null}),!g&&He&&ze.some(e=>!Lr(e)||ze.length>1)&&(0,W.jsx)(`rect`,{x:k(He).x,y:k(He).y,width:He.width*O,height:He.height*O,fill:`none`,stroke:`rgb(var(--accent))`,strokeDasharray:`4 3`,strokeWidth:1}),Ue&&Ve&&(0,W.jsxs)(`g`,{children:[(()=>{let e=k(Ef(Ve,{hx:0,hy:-1})),t=k(Dm(Ve,O));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`line`,{x1:e.x,y1:e.y,x2:t.x,y2:t.y,stroke:`rgb(var(--accent))`,strokeWidth:1}),(0,W.jsx)(`circle`,{cx:t.x,cy:t.y,r:4.5,fill:`#fff`,stroke:`rgb(var(--accent))`,strokeWidth:1.25})]})})(),Em(Be).map(e=>{let t=k(Ef(Ve,e));return(0,W.jsx)(`rect`,{x:t.x-4,y:t.y-4,width:8,height:8,rx:1.5,fill:`#fff`,stroke:`rgb(var(--accent))`,strokeWidth:1.25,transform:Ve.rotation?`rotate(${Ve.rotation} ${t.x} ${t.y})`:void 0},`${e.hx}${e.hy}`)})]}),w.map((e,t)=>e.axis===`x`?(0,W.jsx)(`line`,{x1:l.x+e.at*O,x2:l.x+e.at*O,y1:0,y2:`100%`,stroke:Kh,strokeWidth:1},t):(0,W.jsx)(`line`,{y1:l.y+e.at*O,y2:l.y+e.at*O,x1:0,x2:`100%`,stroke:Kh,strokeWidth:1},t)),f&&f.kind!==`raster`&&(0,W.jsx)($h,{m:f,S:k,z:O}),f&&f.kind===`raster`&&We&&(0,W.jsxs)(`g`,{transform:`translate(${l.x} ${l.y}) scale(${O/We.scale})`,children:[(0,W.jsx)(`path`,{d:We.d,fill:`none`,stroke:`#000`,strokeWidth:We.scale/O,vectorEffect:`non-scaling-stroke`}),(0,W.jsx)(`path`,{d:We.d,fill:`none`,stroke:`#fff`,strokeWidth:1,strokeDasharray:`4 4`,className:`ants`,vectorEffect:`non-scaling-stroke`})]}),ne&&ne.points.length>0&&(0,W.jsxs)(`g`,{children:[(0,W.jsx)(`polyline`,{points:[...ne.points,...ne.toCursor&&ne.cursor?[ne.cursor]:[]].map(e=>`${k(e).x},${k(e).y}`).join(` `),fill:ne.closed?`rgb(var(--accent) / 0.1)`:`none`,stroke:`#000`,strokeWidth:1}),(0,W.jsx)(`polyline`,{points:[...ne.points,...ne.toCursor&&ne.cursor?[ne.cursor]:[]].map(e=>`${k(e).x},${k(e).y}`).join(` `),fill:`none`,stroke:`#fff`,strokeWidth:1,strokeDasharray:`4 4`,className:`ants`}),ne.toCursor&&(0,W.jsx)(`circle`,{cx:k(ne.points[0]).x,cy:k(ne.points[0]).y,r:4,fill:`#fff`,stroke:`rgb(var(--accent))`})]}),u===`clone`&&h&&(0,W.jsxs)(`g`,{stroke:`#fff`,strokeWidth:1.25,style:{filter:`drop-shadow(0 0 1px #000)`},children:[(0,W.jsx)(`circle`,{cx:k(h).x,cy:k(h).y,r:6,fill:`none`}),(0,W.jsx)(`line`,{x1:k(h).x-10,x2:k(h).x+10,y1:k(h).y,y2:k(h).y}),(0,W.jsx)(`line`,{y1:k(h).y-10,y2:k(h).y+10,x1:k(h).x,x2:k(h).x})]}),p?.points.map(([e,t,n],r)=>{let i=x.get(p.layer);if(!i)return null;let a={x:i.x+i.width/2,y:i.y+i.height/2},o=wf({x:e-i.width/2,y:t-i.height/2},i.rotation),s=k({x:a.x+o.x,y:a.y+o.y});return(0,W.jsx)(`circle`,{cx:s.x,cy:s.y,r:5,fill:n?`rgb(var(--agent))`:`rgb(var(--danger))`,stroke:`#fff`,strokeWidth:1.5},r)}),ue&&(ue.kind===`line`?(0,W.jsx)(`line`,{x1:k(ue).x,y1:k(ue).y,x2:k({x:ue.x+ue.width,y:ue.y+ue.height}).x,y2:k({x:ue.x+ue.width,y:ue.y+ue.height}).y,stroke:`rgb(var(--accent))`,strokeWidth:1.5,strokeDasharray:`4 3`}):ue.kind===`ellipse`?(0,W.jsx)(`ellipse`,{cx:k(ue).x+ue.width*O/2,cy:k(ue).y+ue.height*O/2,rx:ue.width*O/2,ry:ue.height*O/2,fill:`rgb(var(--accent) / 0.08)`,stroke:`rgb(var(--accent))`,strokeDasharray:`4 3`}):(0,W.jsx)(`rect`,{x:k(ue).x,y:k(ue).y,width:ue.width*O,height:ue.height*O,fill:`rgb(var(--accent) / 0.08)`,stroke:`rgb(var(--accent))`,strokeDasharray:`4 3`})),g&&u===`crop`&&(0,W.jsx)(eg,{c:g,S:k,z:O,canvas:{x:l.x,y:l.y,w:Le,h:Re}})]}),Ge&&Ge.ids.map(e=>{let t=x.get(e);if(!t)return null;let n=Vf(t);return(0,W.jsx)(`div`,{className:`agent-pulse pointer-events-none absolute rounded-[2px]`,style:{left:l.x+n.x*O,top:l.y+n.y*O,width:n.width*O,height:n.height*O}},`${e}${Ge.at}`)}),p?.region&&p.region.kind===`raster`&&(0,W.jsx)(Qh,{raster:p.region.raster,left:l.x,top:l.y,width:Le,height:Re}),ie&&(0,W.jsx)(`div`,{ref:oe,className:`pointer-events-none absolute left-0 top-0`,style:{width:ie.frame.width*O,height:ie.frame.height*O,transform:`translate(${l.x+ie.frame.x*O}px, ${l.y+ie.frame.y*O}px) rotate(${ie.frame.rotation}deg) scale(${ie.frame.flipX?-1:1}, ${ie.frame.flipY?-1:1})`,transformOrigin:`center`,opacity:ie.opacity??1},children:(0,W.jsx)(Zh,{canvas:ie.canvas})}),hm.has(u)&&(0,W.jsxs)(`div`,{ref:se,className:`pointer-events-none absolute left-0 top-0 hidden`,style:{display:`none`},children:[(0,W.jsx)(`div`,{className:`absolute rounded-full border border-white`,style:{width:m*O,height:m*O,left:-m*O/2,top:-m*O/2,boxShadow:`0 0 0 1px rgb(0 0 0 / 0.55), inset 0 0 0 1px rgb(0 0 0 / 0.35)`}}),(0,W.jsx)(`div`,{className:`absolute -left-[3px] top-0 h-px w-[7px] bg-white mix-blend-difference`}),(0,W.jsx)(`div`,{className:`absolute -top-[3px] left-0 h-[7px] w-px bg-white mix-blend-difference`})]}),d&&(0,W.jsx)(Gh,{},d.id??`new${d.x},${d.y}`),b&&(0,W.jsxs)(`div`,{className:`pointer-events-auto absolute left-1/2 top-3 -translate-x-1/2 rounded-md border border-line bg-ink-1/95 px-3 py-1.5 text-xs shadow-lg`,children:[e(`viewport.showingMask`),` `,(0,W.jsx)(`button`,{type:`button`,className:`ml-1 font-medium text-accent hover:underline`,onClick:()=>n.set({showMask:null}),children:e(`viewport.backToImage`)})]}),ge&&(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center bg-accent/5`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-accent/50 bg-ink-1/95 px-4 py-2.5 text-sm shadow-xl`,children:[(0,W.jsx)(ut,{size:16,className:`text-accent`}),` `,e(`viewport.dropHere`)]})})]})}function Zh({canvas:e}){let t=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{let n=t.current;if(n)return e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`,n.appendChild(e),()=>void e.remove()},[e]),(0,W.jsx)(`div`,{ref:t,className:`h-full w-full`})}function Qh({raster:e,left:t,top:n,width:r,height:i}){let a=(0,S.useRef)(null);return(0,S.useEffect)(()=>{let t=a.current;if(!t)return;t.width=e.w,t.height=e.h;let n=t.getContext(`2d`),r=n.createImageData(e.w,e.h);for(let t=0;t<e.data.length;t++)r.data[t*4]=79,r.data[t*4+1]=209,r.data[t*4+2]=165,r.data[t*4+3]=e.data[t]*.45;n.putImageData(r,0,0)},[e]),(0,W.jsx)(`canvas`,{ref:a,className:`pointer-events-none absolute`,style:{left:t,top:n,width:r,height:i}})}function $h({m:e,S:t,z:n}){let r=t(e),i=e.width*n,a=e.height*n,o=t=>e.kind===`ellipse`?(0,W.jsx)(`ellipse`,{cx:r.x+i/2,cy:r.y+a/2,rx:i/2,ry:a/2,fill:`none`,...t}):(0,W.jsx)(`rect`,{x:r.x,y:r.y,width:i,height:a,fill:`none`,...t});return(0,W.jsxs)(`g`,{children:[o({stroke:`#000`,strokeWidth:1}),o({stroke:`#fff`,strokeWidth:1,strokeDasharray:`4 4`,className:`ants`})]})}function eg({c:e,S:t,z:n,canvas:r}){let i=t(e),a=e.width*n,o=e.height*n,s=1e5;return(0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{d:`M-100000,-100000H${s}V${s}H-100000Z M${i.x},${i.y}v${o}h${a}v${-o}Z`,fill:`rgb(8 9 12 / 0.62)`,fillRule:`evenodd`}),(0,W.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,fill:`none`,stroke:`rgb(255 255 255 / 0.15)`,strokeDasharray:`3 3`}),(0,W.jsx)(`rect`,{x:i.x,y:i.y,width:a,height:o,fill:`none`,stroke:`#fff`,strokeWidth:1.25}),[1,2].map(e=>(0,W.jsxs)(`g`,{stroke:`rgb(255 255 255 / 0.45)`,strokeWidth:.75,children:[(0,W.jsx)(`line`,{x1:i.x+a*e/3,x2:i.x+a*e/3,y1:i.y,y2:i.y+o}),(0,W.jsx)(`line`,{y1:i.y+o*e/3,y2:i.y+o*e/3,x1:i.x,x2:i.x+a})]},e)),Sf.map(e=>{let t=i.x+(e.hx+1)/2*a,n=i.y+(e.hy+1)/2*o;return e.hx&&e.hy?(0,W.jsx)(`path`,{d:`M${t-e.hx*0},${n+e.hy*-14}V${n}H${t+e.hx*-14}`,fill:`none`,stroke:`#fff`,strokeWidth:3,strokeLinecap:`square`},`${e.hx}${e.hy}`):(0,W.jsx)(`rect`,{x:t-(e.hx?2:9),y:n-(e.hy?2:9),width:e.hx?4:18,height:e.hy?4:18,fill:`#fff`},`${e.hx}${e.hy}`)}),(0,W.jsxs)(`text`,{x:i.x+6,y:i.y-8,fill:`#fff`,fontSize:11,style:{paintOrder:`stroke`},stroke:`rgb(0 0 0 / 0.6)`,strokeWidth:3,children:[Math.round(e.width),` × `,Math.round(e.height)]})]})}async function tg(e){return Promise.all(e.map(async e=>({name:e.name||`pasted-${Date.now()}.png`,bytes:new Uint8Array(await e.arrayBuffer())})))}function ng(){let{t:e}=H(),t=q(),n=Fu(),{width:r,height:i}=n.canvas,[a,o]=(0,S.useState)({w:r,h:i}),[s,c]=(0,S.useState)(`center`),[l,u]=(0,S.useState)({w:r,h:i}),[d,f]=(0,S.useState)(!0);(0,S.useEffect)(()=>{o({w:r,h:i}),u({w:r,h:i})},[r,i]);let p=Zr.find(e=>e.width===a.w&&e.height===a.h)?.id??``,m=()=>t.ui.set(e=>({fitRequest:e.fitRequest+1}));return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`border-b border-line px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`canvas.title`)}),(0,W.jsx)(`div`,{className:`text-2xs text-fg-faint`,children:e(`canvas.subtitle`)})]}),(0,W.jsxs)(Ou,{title:e(`canvas.size`),id:`canvas-size`,children:[(0,W.jsx)(K,{label:e(`canvas.preset`),children:(0,W.jsx)(Eu,{value:p,placeholder:e(`canvas.custom`),options:Zr.map(e=>({value:e.id,label:`${gf(e.id)} · ${e.width}×${e.height}`})),onChange:e=>{let t=Zr.find(t=>t.id===e);t&&o({w:t.width,h:t.height})},ariaLabel:e(`canvas.preset`)})}),(0,W.jsxs)(K,{label:e(`props.size`),children:[(0,W.jsx)(of,{label:`W`,value:a.w,min:1,max:16384,integer:!0,onChange:e=>o(t=>({...t,w:e}))}),(0,W.jsx)(of,{label:`H`,value:a.h,min:1,max:16384,integer:!0,onChange:e=>o(t=>({...t,h:e}))})]}),(0,W.jsxs)(K,{label:e(`canvas.anchor`),align:`start`,children:[(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-0.5 rounded-md bg-ink-2 p-0.5`,children:fo.map(t=>(0,W.jsx)(`button`,{type:`button`,"aria-label":e(`anchors.${t}`),title:e(`anchors.${t}`),onClick:()=>c(t),className:U(`flex h-5 w-6 items-center justify-center rounded-[3px]`,s===t?`bg-accent/80`:`hover:bg-ink-4`),children:(0,W.jsx)(`span`,{className:U(`h-1.5 w-1.5 rounded-full`,s===t?`bg-ink-0`:`bg-fg-faint`)})},t))}),(0,W.jsx)(wu,{size:`xs`,variant:`primary`,className:`ml-auto self-end`,disabled:a.w===r&&a.h===i,onClick:()=>t.edit([{op:`resizeCanvas`,width:a.w,height:a.h,anchor:s}])&&m(),children:e(`canvas.apply`)})]})]}),(0,W.jsx)(Ou,{title:e(`canvas.background`),id:`canvas-bg`,children:(0,W.jsx)(K,{label:e(`props.paint`),children:(0,W.jsx)(uh,{value:n.canvas.background??null,allowNone:!0,onChange:(e,n)=>t.edit([{op:`set`,path:`canvas.background`,value:e}],n?{}:{coalesce:`canvas-bg`})})})}),(0,W.jsxs)(Ou,{title:e(`canvas.image`),id:`canvas-image`,children:[(0,W.jsx)(K,{label:e(`canvas.transform`),children:(0,W.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,W.jsx)(G,{label:e(`canvas.rotateLeft`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`rotateCanvas`,angle:-90}])&&m(),children:(0,W.jsx)(sn,{size:13})}),(0,W.jsx)(G,{label:e(`canvas.rotateRight`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`rotateCanvas`,angle:90}])&&m(),children:(0,W.jsx)(ln,{size:13})}),(0,W.jsx)(G,{label:e(`canvas.flipH`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`flipCanvas`,axis:`horizontal`}]),children:(0,W.jsx)(be,{size:13})}),(0,W.jsx)(G,{label:e(`canvas.flipV`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`flipCanvas`,axis:`vertical`}]),children:(0,W.jsx)(ve,{size:13})})]})}),(0,W.jsxs)(K,{label:e(`canvas.resizeImage`),children:[(0,W.jsx)(of,{label:`W`,value:l.w,min:1,max:16384,integer:!0,onChange:e=>u({w:e,h:d?Math.round(e*i/r):l.h})}),(0,W.jsx)(of,{label:`H`,value:l.h,min:1,max:16384,integer:!0,onChange:e=>u({h:e,w:d?Math.round(e*r/i):l.w})}),(0,W.jsx)(G,{label:e(d?`props.unlockRatio`:`props.lockRatio`),active:d,onClick:()=>f(e=>!e),className:`h-6 w-6`,children:d?(0,W.jsx)(At,{size:12}):(0,W.jsx)(Ot,{size:12})})]}),(0,W.jsx)(`div`,{className:`flex justify-end px-3 pb-1`,children:(0,W.jsx)(wu,{size:`xs`,variant:`subtle`,disabled:l.w===r&&l.h===i,onClick:()=>t.edit([{op:`resizeImage`,width:l.w,height:l.h}])&&m(),children:e(`canvas.resample`)})})]}),(0,W.jsxs)(Ou,{title:e(`canvas.document`),id:`canvas-doc`,children:[(0,W.jsx)(K,{label:e(`canvas.docTitle`),children:(0,W.jsx)(Tu,{value:n.title??``,onCommit:e=>t.edit([e.trim()?{op:`set`,path:`title`,value:e.trim()}:{op:`remove`,path:`title`}]),ariaLabel:e(`canvas.docTitle`)})}),(0,W.jsx)(K,{label:e(`canvas.description`),align:`start`,children:(0,W.jsx)(Tu,{value:n.description??``,multiline:!0,onCommit:e=>t.edit([e.trim()?{op:`set`,path:`description`,value:e.trim()}:{op:`remove`,path:`description`}]),ariaLabel:e(`canvas.description`),placeholder:e(`canvas.descriptionHint`)})})]})]})}function rg(){let{engine:e}=q(),[t,n]=(0,S.useState)(!1);return(0,S.useEffect)(()=>{let t=!0;return Promise.all(Xr.map(t=>e.loader.font?.(t.id,t.weights.includes(700)?700:t.weights[0],!1).catch(()=>null))).then(()=>t&&n(!0)),()=>{t=!1}},[e]),t}function ig({value:e,onChange:t}){let{t:n}=H(),r=rg(),i=ai(e),a=[...new Set(Xr.map(e=>e.style))];return(0,W.jsx)(Gd,{width:260,align:`start`,anchorClass:`flex min-w-0 flex-1`,trigger:(t,a)=>(0,W.jsx)(Kd,{onClick:t,open:a,ariaLabel:n(`props.font`),children:(0,W.jsx)(`span`,{className:`truncate`,style:{fontFamily:i&&r?`"${i.family}"`:void 0},children:i?.family??e})}),children:i=>(0,W.jsx)(`div`,{className:`py-1`,children:a.map(a=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pb-0.5 pt-2 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:n(`fontStyles.${a}`)}),Xr.filter(e=>e.style===a).map(n=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>(t(n.id),i()),className:U(`flex w-full items-baseline justify-between gap-2 px-3 py-1 text-left hover:bg-ink-3`,n.id===e&&`bg-accent/10`),title:n.description,children:[(0,W.jsx)(`span`,{className:`truncate text-[15px] leading-6`,style:{fontFamily:r?`"${n.family}"`:void 0,fontWeight:n.weights.includes(700)?700:n.weights[0]},children:n.family}),(0,W.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-faint`,children:n.weights.length})]},n.id))]},a))})})}function ag({layer:e}){let{t}=H(),n=q(),r=J(e=>e.region),i=J(e=>e.showMask),a=J(e=>e.maskTarget),o=J(e=>e.busy),[s,c]=(0,S.useState)($r[`background-removal`]),l=e.mask??null,u=(t,r=!0)=>n.edit([{op:`setMask`,id:e.id,mask:t}],r?{}:{coalesce:`mask:${e.id}`}),d=(e,t=!0)=>l&&u({...l,...e},t),f=n.boxes.get(e.id),p=Lr(e)?f?.width??100:n.store.doc.canvas.width,m=Lr(e)?f?.height??100:n.store.doc.canvas.height,h=l?Rr(l)?`image`:zr(l)?`shape`:`gradient`:null,g=Qr.filter(e=>e.task===`background-removal`);return(0,W.jsxs)(Ou,{title:t(`mask.title`),id:`mask`,actions:l?(0,W.jsxs)(`div`,{className:`flex`,children:[(0,W.jsx)(G,{label:i===e.id?t(`mask.hidePreview`):t(`mask.showPreview`),active:i===e.id,onClick:()=>n.ui.set({showMask:i===e.id?null:e.id}),className:`h-6 w-6`,children:i===e.id?(0,W.jsx)(He,{size:12}):(0,W.jsx)(We,{size:12})}),(0,W.jsx)(G,{label:t(`mask.delete`),onClick:()=>u(null),className:`h-6 w-6 hover:text-danger`,children:(0,W.jsx)(tr,{size:12})})]}):void 0,children:[l?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(K,{label:t(`mask.kind`),children:(0,W.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[t(`mask.kinds.${h}`),Rr(l)&&(0,W.jsx)(`span`,{className:`ml-1 font-mono text-2xs text-fg-faint`,children:l.src.split(`/`).pop()})]})}),(0,W.jsxs)(K,{label:t(`mask.enabled`),children:[(0,W.jsx)(Du,{checked:l.enabled!==!1,onChange:e=>d({enabled:e?void 0:!1}),ariaLabel:t(`mask.enabled`)}),(0,W.jsx)(`span`,{className:`ml-3 text-xs text-fg-muted`,children:t(`mask.invert`)}),(0,W.jsx)(Du,{checked:!!l.invert,onChange:e=>d({invert:e||void 0}),ariaLabel:t(`mask.invert`)})]}),(0,W.jsx)(K,{label:t(`mask.feather`),children:(0,W.jsx)(sf,{value:l.feather??0,min:0,max:200,onChange:(e,t)=>d({feather:e||void 0},t),ariaLabel:t(`mask.feather`)})}),(0,W.jsx)(K,{label:t(`mask.density`),children:(0,W.jsx)(sf,{value:Math.round((l.density??1)*100),min:0,max:100,integer:!0,onChange:(e,t)=>d({density:e>=100?void 0:e/100},t),ariaLabel:t(`mask.density`)})}),(0,W.jsx)(`div`,{className:`px-3 py-1`,children:(0,W.jsxs)(wu,{size:`xs`,variant:a===e.id?`primary`:`subtle`,onClick:()=>(n.ui.set({maskTarget:e.id}),Lh(n,`brush`)),children:[(0,W.jsx)(ge,{size:12}),` `,t(`mask.paint`)]})}),zr(l)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(K,{label:t(`mask.shape`),children:(0,W.jsx)(Eu,{value:l.shape,options:[{value:`rect`,label:t(`shapes.rect`)},{value:`ellipse`,label:t(`shapes.ellipse`)}],onChange:e=>d({shape:e}),ariaLabel:t(`mask.shape`)})}),(0,W.jsxs)(K,{label:t(`props.position`),children:[(0,W.jsx)(of,{label:`X`,value:Math.round(l.x),integer:!0,onChange:(e,t)=>d({x:e},t)}),(0,W.jsx)(of,{label:`Y`,value:Math.round(l.y),integer:!0,onChange:(e,t)=>d({y:e},t)})]}),(0,W.jsxs)(K,{label:t(`props.size`),children:[(0,W.jsx)(of,{label:`W`,value:Math.round(l.width),min:1,integer:!0,onChange:(e,t)=>d({width:e},t)}),(0,W.jsx)(of,{label:`H`,value:Math.round(l.height),min:1,integer:!0,onChange:(e,t)=>d({height:e},t)})]})]}),Br(l)&&(0,W.jsx)(K,{label:t(`paint.angle`),children:(0,W.jsx)(sf,{value:l.gradient.type===`linear`?l.gradient.angle??90:0,min:-180,max:180,integer:!0,onChange:(e,t)=>l.gradient.type===`linear`&&d({gradient:{...l.gradient,angle:e}},t),ariaLabel:t(`paint.angle`)})})]}):(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-1 px-3 pb-1`,children:[(0,W.jsxs)(wu,{size:`xs`,variant:`subtle`,disabled:!r,title:r?void 0:t(`mask.needMarquee`),onClick:()=>r&&void jp(n,e,r).then(e=>(u(e),n.ui.set({region:null}))),children:[(0,W.jsx)(Fn,{size:12}),` `,t(`mask.fromSelection`)]}),(0,W.jsxs)(wu,{size:`xs`,variant:`subtle`,onClick:()=>u({shape:`ellipse`,x:p*.15,y:m*.15,width:p*.7,height:m*.7,feather:Math.round(Math.min(p,m)/20)}),children:[(0,W.jsx)(Ae,{size:12}),` `,t(`mask.ellipse`)]}),(0,W.jsxs)(wu,{size:`xs`,variant:`subtle`,onClick:()=>u({shape:`rect`,x:p*.1,y:m*.1,width:p*.8,height:m*.8,radius:0}),children:[(0,W.jsx)(zn,{size:12}),` `,t(`mask.rect`)]}),(0,W.jsxs)(wu,{size:`xs`,variant:`subtle`,onClick:()=>u({gradient:{type:`linear`,angle:90,stops:[`#ffffff`,`#000000`]}}),children:[(0,W.jsx)(Gn,{size:12}),` `,t(`mask.fade`)]})]}),e.type===`image`&&(0,W.jsxs)(`div`,{className:`mx-3 mt-2 space-y-1.5 rounded-md border border-agent/20 bg-agent/[0.04] p-2`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wide text-agent/90`,children:t(`mask.ai`)}),(0,W.jsx)(`div`,{className:`flex gap-1`,children:(0,W.jsx)(Eu,{value:s,options:g.map(e=>({value:e.id,label:`${e.id} · ${e.sizeMb} MB`})),onChange:c,ariaLabel:t(`mask.model`)})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-1`,children:[(0,W.jsxs)(wu,{size:`xs`,variant:`subtle`,className:`min-w-0`,title:t(`ai.removeBg`),disabled:!!o,onClick:()=>void Xm(n,e.id,s),children:[(0,W.jsx)(pr,{size:12}),` `,(0,W.jsx)(`span`,{className:`truncate`,children:t(`ai.removeBg`)})]}),(0,W.jsxs)(wu,{size:`xs`,variant:`subtle`,className:`min-w-0`,title:t(`ai.selectSubject`),disabled:!!o,onClick:()=>void Zm(n,e.id,s),children:[(0,W.jsx)(dn,{size:12}),` `,(0,W.jsx)(`span`,{className:`truncate`,children:t(`ai.selectSubject`)})]})]}),(0,W.jsx)(`p`,{className:`text-2xs leading-snug text-fg-faint`,children:t(`mask.aiNote`)})]})]})}function og(e){let t=q();return(n,r=!0)=>{e&&t.edit([{op:`updateLayer`,id:e.id,set:n}],r?{}:{coalesce:`props:${e.id}:${Object.keys(n).join(`,`)}`})}}function sg(){let{t:e}=H(),t=Iu(),n=Pu().selection;return t?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2`,children:(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:hd(t)}),(0,W.jsxs)(`div`,{className:`truncate text-2xs text-fg-faint`,children:[e(`layerTypes.${t.type}`),` · `,t.id,n.length>1&&` · ${e(`props.multi`,{n:n.length})}`]})]})}),Lr(t)&&(0,W.jsx)(ug,{layer:t}),t.type===`image`&&(0,W.jsx)(dg,{layer:t}),t.type===`text`&&(0,W.jsx)(pg,{layer:t}),t.type===`shape`&&(0,W.jsx)(mg,{layer:t}),t.type===`fill`&&(0,W.jsx)(Ou,{title:e(`props.fill`),id:`fill`,children:(0,W.jsx)(cg,{layer:t})}),t.type===`adjustment`&&(0,W.jsx)(lg,{}),t.type===`group`&&(0,W.jsx)(Ou,{title:e(`props.group`),id:`group`,children:(0,W.jsx)(`div`,{className:`px-3 text-xs text-fg-muted`,children:e(`props.groupInfo`,{n:t.children?.length??0})})}),(0,W.jsx)(ag,{layer:t})]}):(0,W.jsx)(ng,{})}function cg({layer:e}){let{t}=H(),n=og(e);return(0,W.jsx)(K,{label:t(`props.paint`),children:(0,W.jsx)(uh,{value:e.fill,onChange:(e,t)=>n({fill:e??`#ffffff`},t)})})}function lg(){let{t:e}=H(),{ui:t}=q();return(0,W.jsx)(Ou,{title:e(`props.adjustment`),id:`adjustment`,children:(0,W.jsxs)(`div`,{className:`space-y-2 px-3 text-xs text-fg-muted`,children:[(0,W.jsx)(`p`,{children:e(`props.adjustmentInfo`)}),(0,W.jsxs)(wu,{size:`xs`,onClick:()=>t.set({rightTab:`filters`}),children:[(0,W.jsx)(Tn,{size:12}),` `,e(`props.editFilters`)]})]})})}function ug({layer:e}){let{t}=H(),n=q(),r=og(e),i=n.boxes.get(e.id),[a,o]=(0,S.useState)(e.type===`image`),s=(e.type,e.width??i?.width??0),c=e.type===`text`?i?.height??0:e.height??i?.height??0,l=s&&c?s/c:1;return(0,W.jsxs)(Ou,{title:t(`props.transform`),id:`transform`,children:[(0,W.jsxs)(K,{label:t(`props.position`),children:[(0,W.jsx)(of,{label:`X`,value:Math.round((e.x??0)*10)/10,onChange:(e,t)=>r({x:e},t),step:1}),(0,W.jsx)(of,{label:`Y`,value:Math.round((e.y??0)*10)/10,onChange:(e,t)=>r({y:e},t),step:1})]}),(0,W.jsxs)(K,{label:t(`props.size`),children:[(0,W.jsx)(of,{label:`W`,value:Math.round(s),min:1,step:1,empty:e.type===`text`&&!e.width,onChange:(t,n)=>r(e.type===`text`?{width:t}:a?{width:t,height:Math.round(t/l)}:{width:t,height:Math.round(c)},n)}),e.type!==`text`&&(0,W.jsx)(of,{label:`H`,value:Math.round(c),min:1,step:1,onChange:(e,t)=>r(a?{height:e,width:Math.round(e*l)}:{height:e,width:Math.round(s)},t)}),e.type!==`text`&&(0,W.jsx)(G,{label:t(a?`props.unlockRatio`:`props.lockRatio`),active:a,onClick:()=>o(e=>!e),className:`h-6 w-6`,children:a?(0,W.jsx)(At,{size:12}):(0,W.jsx)(Ot,{size:12})})]}),(0,W.jsxs)(K,{label:t(`props.rotation`),children:[(0,W.jsx)(of,{label:`°`,value:e.rotation??0,min:-360,max:360,step:1,onChange:(e,t)=>r({rotation:e||null},t)}),(0,W.jsx)(G,{label:t(`props.flipH`),active:!!e.flipX,onClick:()=>r({flipX:!e.flipX||null}),className:`h-6 w-6`,children:(0,W.jsx)(be,{size:13})}),(0,W.jsx)(G,{label:t(`props.flipV`),active:!!e.flipY,onClick:()=>r({flipY:!e.flipY||null}),className:`h-6 w-6`,children:(0,W.jsx)(ve,{size:13})})]}),(0,W.jsx)(K,{label:t(`props.align`),children:(0,W.jsx)(`div`,{className:`flex gap-0.5`,children:[[`left`,$n],[`hcenter`,Yn],[`right`,Zn],[`top`,ce],[`vcenter`,ue],[`bottom`,ne]].map(([a,o])=>(0,W.jsx)(G,{label:t(`props.alignTo.${a}`),className:`h-6 w-6`,onClick:()=>{let t=n.store.doc,o=i??{x:e.x??0,y:e.y??0,width:s,height:c},l=t.canvas.width,u=t.canvas.height,d=a===`left`?{x:0}:a===`hcenter`?{x:Math.round((l-o.width)/2)}:a===`right`?{x:Math.round(l-o.width)}:a===`top`?{y:0}:a===`vcenter`?{y:Math.round((u-o.height)/2)}:{y:Math.round(u-o.height)};r(d)},children:(0,W.jsx)(o,{size:13})},a))})})]})}function dg({layer:e}){let{t}=H(),n=q(),r=og(e),i=(0,S.useRef)(null),a=n.naturalSize(e.src);return(0,W.jsxs)(Ou,{title:t(`props.image`),id:`image`,children:[(0,W.jsxs)(K,{label:t(`props.source`),children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-mono text-2xs text-fg-muted`,title:e.src,children:e.src.startsWith(`library:`)?e.src:e.src.split(`/`).pop()}),(0,W.jsx)(G,{label:t(`props.replace`),onClick:()=>i.current?.click(),className:`h-6 w-6`,children:(0,W.jsx)(ft,{size:13})}),(0,W.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;let[i]=await tg([t]);if(!ra(i.bytes))return;let a=await n.backend.addImage(i.name,i.bytes);r({src:a,crop:null})}})]}),a&&(0,W.jsxs)(K,{label:t(`props.natural`),children:[(0,W.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[a.width,` × `,a.height]}),(0,W.jsxs)(wu,{size:`xs`,variant:`ghost`,className:`ml-auto`,onClick:()=>r({width:a.width,height:a.height,crop:null}),title:t(`props.naturalHint`),children:[(0,W.jsx)(Bt,{size:11}),` `,t(`props.reset`)]})]}),(0,W.jsx)(K,{label:t(`props.fit`),children:(0,W.jsx)(Eu,{value:e.fit??`fill`,options:[`fill`,`cover`,`contain`].map(e=>({value:e,label:t(`props.fits.${e}`)})),onChange:e=>r({fit:e===`fill`?null:e}),ariaLabel:t(`props.fit`)})}),e.fit&&e.fit!==`fill`&&(0,W.jsxs)(K,{label:t(`props.focus`),children:[(0,W.jsx)(of,{label:`X`,value:Math.round((e.focus?.[0]??.5)*100),min:0,max:100,integer:!0,suffix:`%`,onChange:(t,n)=>r({focus:[t/100,e.focus?.[1]??.5]},n)}),(0,W.jsx)(of,{label:`Y`,value:Math.round((e.focus?.[1]??.5)*100),min:0,max:100,integer:!0,suffix:`%`,onChange:(t,n)=>r({focus:[e.focus?.[0]??.5,t/100]},n)})]}),(0,W.jsx)(K,{label:t(`props.crop`),overridden:!!e.crop,onReset:()=>r({crop:null}),children:e.crop?(0,W.jsx)(`div`,{className:`grid flex-1 grid-cols-2 gap-1`,children:[`x`,`y`,`width`,`height`].map(t=>(0,W.jsx)(of,{label:t===`width`?`W`:t===`height`?`H`:t.toUpperCase(),value:Math.round(e.crop[t]),min:+(t===`width`||t===`height`),integer:!0,onChange:(n,i)=>r({crop:{...e.crop,[t]:n}},i)},t))}):(0,W.jsx)(wu,{size:`xs`,variant:`ghost`,disabled:!a,onClick:()=>a&&r({crop:{x:0,y:0,width:a.width,height:a.height}}),children:t(`props.addCrop`)})})]})}var fg=[`none`,`uppercase`,`lowercase`];function pg({layer:e}){let{t}=H(),n=og(e),r=ai(e.font??`inter`)?.weights??[100,200,300,400,500,600,700,800,900],i=e.background;return(0,W.jsxs)(Ou,{title:t(`props.text`),id:`text`,children:[(0,W.jsx)(`div`,{className:`px-3 pb-1.5`,children:(0,W.jsx)(Tu,{value:e.text,onCommit:e=>n({text:e}),multiline:!0,ariaLabel:t(`props.textContent`)})}),(0,W.jsx)(K,{label:t(`props.font`),children:(0,W.jsx)(ig,{value:e.font??`inter`,onChange:t=>{let r=ai(t),i=e.weight??400;n({font:t,...r&&!r.weights.includes(i)?{weight:r.weights.reduce((e,t)=>Math.abs(t-i)<Math.abs(e-i)?t:e)}:{}})}})}),(0,W.jsxs)(K,{label:t(`props.weight`),children:[(0,W.jsx)(Eu,{value:String(e.weight??400),options:r.map(e=>({value:String(e),label:t(`weights.w${e}`)})),onChange:e=>n({weight:Number(e)}),ariaLabel:t(`props.weight`)}),(0,W.jsx)(G,{label:t(`props.italic`),active:!!e.italic,onClick:()=>n({italic:!e.italic||null}),className:`h-6 w-6 font-serif italic`,children:`I`})]}),(0,W.jsx)(K,{label:t(`props.size`),children:(0,W.jsx)(sf,{value:e.size??64,min:6,max:600,integer:!0,onChange:(e,t)=>n({size:e},t),ariaLabel:t(`props.size`)})}),(0,W.jsx)(K,{label:t(`props.color`),children:(0,W.jsx)(uh,{value:e.color??`#ffffff`,onChange:(e,t)=>n({color:e??`#ffffff`},t)})}),(0,W.jsxs)(K,{label:t(`props.alignText`),children:[(0,W.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`left`,`center`,`right`].map(r=>{let i=r===`left`?$n:r===`center`?Yn:Zn;return(0,W.jsx)(`button`,{type:`button`,"aria-label":t(`props.aligns.${r}`),title:t(`props.aligns.${r}`),onClick:()=>n({align:r===`left`?null:r}),className:U(`flex h-5 w-7 items-center justify-center rounded`,(e.align??`left`)===r?`bg-ink-4 text-fg`:`text-fg-muted hover:text-fg`),children:(0,W.jsx)(i,{size:12})},r)})}),(0,W.jsx)(Eu,{value:e.valign??`top`,options:[`top`,`middle`,`bottom`].map(e=>({value:e,label:t(`props.valigns.${e}`)})),onChange:e=>n({valign:e===`top`?null:e}),ariaLabel:t(`props.valign`)})]}),(0,W.jsx)(K,{label:t(`props.lineHeight`),children:(0,W.jsx)(sf,{value:e.lineHeight??1.2,min:.6,max:3,step:.05,onChange:(e,t)=>n({lineHeight:e},t),ariaLabel:t(`props.lineHeight`)})}),(0,W.jsx)(K,{label:t(`props.letterSpacing`),children:(0,W.jsx)(sf,{value:e.letterSpacing??0,min:-20,max:100,step:.5,onChange:(e,t)=>n({letterSpacing:e||null},t),ariaLabel:t(`props.letterSpacing`)})}),(0,W.jsx)(K,{label:t(`props.case`),children:(0,W.jsx)(Eu,{value:e.transform??`none`,options:fg.map(e=>({value:e,label:t(`props.cases.${e}`)})),onChange:e=>n({transform:e===`none`?null:e}),ariaLabel:t(`props.case`)})}),(0,W.jsx)(K,{label:t(`props.wrap`),overridden:!!e.width,onReset:()=>n({width:null}),children:(0,W.jsx)(of,{label:`W`,value:e.width??0,empty:!e.width,min:8,integer:!0,onChange:(e,t)=>n({width:e},t),ariaLabel:t(`props.wrap`)})}),(0,W.jsxs)(K,{label:t(`props.textBox`),children:[(0,W.jsx)(Du,{checked:!!i,onChange:e=>n({background:e?{color:`#000000b3`,padding:[16,28],radius:12}:null}),ariaLabel:t(`props.textBox`)}),i&&(0,W.jsx)(tf,{value:i.color,compact:!0,onChange:(e,t)=>n({background:{...i,color:e}},t)}),i&&(0,W.jsx)(of,{label:`P`,value:Array.isArray(i.padding)?i.padding[0]:i.padding??0,min:0,integer:!0,onChange:(e,t)=>n({background:{...i,padding:Array.isArray(i.padding)?[e,Math.round(e*1.75)]:e}},t),ariaLabel:t(`props.padding`)}),i&&(0,W.jsx)(of,{label:`R`,value:i.radius??0,min:0,integer:!0,onChange:(e,t)=>n({background:{...i,radius:e}},t),ariaLabel:t(`props.radius`)})]})]})}function mg({layer:e}){let{t}=H(),n=og(e),r=e.stroke;return(0,W.jsxs)(Ou,{title:t(`props.shape`),id:`shape`,children:[(0,W.jsx)(K,{label:t(`props.shapeKind`),children:(0,W.jsx)(Eu,{value:e.shape,options:ti.map(e=>({value:e,label:t(`shapes.${e}`)})),onChange:e=>n({shape:e}),ariaLabel:t(`props.shapeKind`)})}),(0,W.jsx)(K,{label:t(`props.fill`),children:(0,W.jsx)(uh,{value:e.fill??null,allowNone:!0,onChange:(e,t)=>n({fill:e},t)})}),(0,W.jsxs)(K,{label:t(`props.stroke`),children:[(0,W.jsx)(Du,{checked:!!r,onChange:e=>n({stroke:e?{color:`#ffffff`,width:4}:null}),ariaLabel:t(`props.stroke`)}),r&&(0,W.jsx)(tf,{value:r.color,compact:!0,onChange:(e,t)=>n({stroke:{...r,color:e}},t)}),r&&(0,W.jsx)(of,{label:`W`,value:r.width??4,min:0,max:500,onChange:(e,t)=>n({stroke:{...r,width:e}},t),ariaLabel:t(`props.strokeWidth`)}),r&&(0,W.jsx)(Du,{checked:!!r.dash?.length,onChange:e=>n({stroke:{...r,dash:e?[12,8]:null}}),ariaLabel:t(`props.dashed`)})]}),e.shape===`rect`&&(0,W.jsx)(K,{label:t(`props.radius`),children:(0,W.jsx)(sf,{value:e.radius??0,min:0,max:Math.round(Math.min(e.width??100,e.height??100)/2),integer:!0,onChange:(e,t)=>n({radius:e||null},t),ariaLabel:t(`props.radius`)})}),(e.shape===`polygon`||e.shape===`star`)&&(0,W.jsx)(K,{label:e.shape===`star`?t(`props.points`):t(`props.sides`),children:(0,W.jsx)(sf,{value:e.sides??(e.shape===`star`?5:6),min:3,max:24,integer:!0,onChange:(e,t)=>n({sides:e},t),ariaLabel:t(`props.sides`)})}),e.shape===`star`&&(0,W.jsx)(K,{label:t(`props.innerRadius`),children:(0,W.jsx)(sf,{value:e.innerRadius??.5,min:.05,max:.95,step:.01,onChange:(e,t)=>n({innerRadius:e},t),ariaLabel:t(`props.innerRadius`)})})]})}function hg({x:e,y:t,items:n,onClose:r}){let i=(0,S.useRef)(null),[a,o]=(0,S.useState)({left:e,top:t});return(0,S.useLayoutEffect)(()=>{let n=i.current;if(!n)return;let r=n.getBoundingClientRect();o({left:Math.min(e,window.innerWidth-r.width-8),top:Math.min(t,window.innerHeight-r.height-8)})},[e,t]),(0,S.useEffect)(()=>{let e=e=>!i.current?.contains(e.target)&&r(),t=e=>e.key===`Escape`&&(e.stopPropagation(),r());return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t,!0),window.addEventListener(`blur`,r),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t,!0),window.removeEventListener(`blur`,r)}},[r]),(0,Wd.createPortal)((0,W.jsx)(`div`,{ref:i,role:`menu`,className:`toast-in fixed z-[60] min-w-[200px] rounded-lg border border-line bg-ink-1 py-1 shadow-xl shadow-black/50`,style:a,children:n.map((e,t)=>e===`-`?(0,W.jsx)(`div`,{className:`my-1 h-px bg-line`},t):(0,W.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,onClick:()=>{r(),e.run()},className:U(`flex w-full items-center gap-2 px-2.5 py-1 text-left text-sm disabled:opacity-35`,e.danger?`text-danger hover:bg-danger/10`:`hover:bg-ink-3`),children:[(0,W.jsx)(`span`,{className:`flex w-4 justify-center text-fg-muted`,children:e.icon}),(0,W.jsx)(`span`,{className:`flex-1`,children:e.label}),e.keys&&(0,W.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e.keys})]},t))}),document.body)}var gg=typeof navigator<`u`&&/Mac/.test(navigator.platform)?`⌘`:`Ctrl+`;function _g(){let{t:e,lang:t,setLang:n}=H(),{store:r,ui:i,backend:a,closeProject:o,runCheck:s}=q(),c=Pu(),l=J(e=>e.assistant),u=J(e=>e.check),d=J(e=>e.checkRunning),f=J(e=>e.agentPulse),p=c.issues.filter(e=>e.severity===`error`).length,m=u?(u.counts?.errors??0)+(u.counts?.warnings??0):p;return(0,W.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-line bg-ink-1 px-2`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,style:{width:300},children:[(0,W.jsx)(G,{label:e(`top.projects`),onClick:o,children:(0,W.jsx)(D,{size:15})}),(0,W.jsx)(bg,{className:f?`agent-pulse rounded-[6px]`:void 0},f),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight`,children:c.doc?.title||a.projectTitle()}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 truncate text-2xs text-fg-faint`,title:a.location??``,children:[a.mode===`cli`?(0,W.jsx)(ot,{size:10}):(0,W.jsx)(Me,{size:10}),(0,W.jsx)(`span`,{className:`truncate`,children:a.mode===`cli`?yg(a.location):e(`top.inBrowser`)}),c.doc&&(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`· `,c.doc.canvas.width,`×`,c.doc.canvas.height]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,W.jsx)(G,{label:e(`top.undo`),shortcut:`${gg}Z`,disabled:!c.canUndo,onClick:()=>r.undo(),children:(0,W.jsx)(sr,{size:15})}),(0,W.jsx)(G,{label:e(`top.redo`),shortcut:`${gg}⇧Z`,disabled:!c.canRedo,onClick:()=>r.redo(),children:(0,W.jsx)(an,{size:15})}),(0,W.jsx)(xg,{})]}),(0,W.jsx)(`div`,{className:`mx-auto flex items-center`,children:(0,W.jsx)(vg,{})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsxs)(wu,{variant:`ghost`,onClick:()=>void s(),title:e(`top.checkHint`),children:[d?(0,W.jsx)(Mt,{size:14,className:`animate-spin`}):(0,W.jsx)(Cn,{size:14}),e(`top.check`),m>0&&(0,W.jsx)(`span`,{className:U(`rounded px-1 text-2xs font-semibold`,(u?.counts?.errors??p)>0?`bg-danger/20 text-danger`:`bg-warn/20 text-warn`),children:m})]}),(0,W.jsxs)(wu,{variant:`primary`,onClick:()=>i.set({dialog:`export`}),children:[(0,W.jsx)(dr,{size:14}),e(`top.export`)]}),(0,W.jsx)(`div`,{className:`mx-1 h-5 w-px bg-line`}),(0,W.jsx)(G,{label:e(`top.assistant`),active:l,onClick:()=>i.set({assistant:!l}),children:(0,W.jsx)(me,{size:16})}),(0,W.jsx)(G,{label:e(`top.shortcuts`),shortcut:`?`,onClick:()=>i.set({dialog:`shortcuts`}),children:(0,W.jsx)(bt,{size:15})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>n(t===`en`?`fr`:`en`),title:e(`top.language`),className:`h-7 rounded-md px-1.5 text-2xs font-semibold text-fg-muted hover:bg-ink-3 hover:text-fg`,children:t.toUpperCase()})]})]})}function vg(){let{t:e}=H(),t=q(),n=J(e=>e.view.zoom);return(0,W.jsxs)(`div`,{className:`flex items-center rounded-md bg-ink-2/70 p-0.5`,children:[(0,W.jsx)(G,{label:e(`zoom.out`),shortcut:`${gg}-`,onClick:()=>Hh(t,.8),className:`h-6 w-6`,children:(0,W.jsx)(Ht,{size:13})}),(0,W.jsx)(Gd,{width:180,align:`start`,trigger:(t,r)=>(0,W.jsxs)(`button`,{type:`button`,onClick:t,"aria-expanded":r,"aria-label":e(`zoom.menu`),className:`flex h-6 w-[66px] items-center justify-center gap-0.5 rounded text-xs tabular-nums text-fg hover:bg-ink-3`,children:[Math.round(n*100),`%`,(0,W.jsx)(we,{size:11,className:`text-fg-faint`})]}),children:n=>(0,W.jsx)(`div`,{className:`py-1 text-sm`,children:[{label:e(`zoom.fit`),keys:`${gg}0`,run:()=>t.ui.set(e=>({fitRequest:e.fitRequest+1}))},{label:`50%`,run:()=>Uh(t,.5)},{label:e(`zoom.actual`),keys:`${gg}1`,run:()=>Uh(t,1)},{label:`200%`,run:()=>Uh(t,2)},{label:`400%`,run:()=>Uh(t,4)}].map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>(e.run(),n()),className:`flex w-full items-center justify-between px-3 py-1 text-left hover:bg-ink-3`,children:[e.label,e.keys&&(0,W.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e.keys})]},e.label))})}),(0,W.jsx)(G,{label:e(`zoom.in`),shortcut:`${gg}+`,onClick:()=>Hh(t,1.25),className:`h-6 w-6`,children:(0,W.jsx)(nn,{size:13})}),(0,W.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-line`}),(0,W.jsx)(G,{label:e(`zoom.fit`),shortcut:`${gg}0`,onClick:()=>t.ui.set(e=>({fitRequest:e.fitRequest+1})),className:`h-6 w-6`,children:(0,W.jsx)(Bt,{size:12})})]})}function yg(e){if(!e)return``;let t=e.split(`/`).filter(Boolean);return t.length>2?`…/${t.slice(-2).join(`/`)}`:e}function bg({size:e=22,className:t}){let n=(0,S.useId)().replace(/:/g,``);return(0,W.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 32 32`,"aria-hidden":!0,className:U(`shrink-0`,t),children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsxs)(`linearGradient`,{id:`${n}bg`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0`,stopColor:`#2a2a30`}),(0,W.jsx)(`stop`,{offset:`1`,stopColor:`#0c0c0f`})]}),(0,W.jsxs)(`linearGradient`,{id:`${n}dot`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0`,stopColor:`#7aa5ff`}),(0,W.jsx)(`stop`,{offset:`1`,stopColor:`#3d6bff`})]})]}),(0,W.jsx)(`rect`,{width:`32`,height:`32`,rx:`7.5`,fill:`url(#${n}bg)`}),(0,W.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`31`,height:`31`,rx:`7`,fill:`none`,stroke:`#ffffff`,strokeOpacity:`0.12`}),(0,W.jsx)(`rect`,{x:`7`,y:`9`,width:`18`,height:`14`,rx:`2.5`,fill:`none`,stroke:`#fff`,strokeWidth:`2.2`}),(0,W.jsx)(`path`,{d:`M9 21l5-5 3 3 2.5-2.5L23 20`,fill:`none`,stroke:`#fff`,strokeWidth:`1.8`,strokeLinejoin:`round`,strokeLinecap:`round`}),(0,W.jsx)(`circle`,{cx:`20.5`,cy:`13.5`,r:`2`,fill:`url(#${n}dot)`})]})}function xg(){let{t:e}=H(),t=Pu().save,n=t.state===`saved`?e(`save.saved`):t.state===`saving`?e(`save.saving`):t.state===`pending`?e(`save.pending`):e(`save.error`);return(0,W.jsxs)(`div`,{className:U(`ml-1 flex h-6 items-center gap-1 rounded-md px-1.5 text-2xs`,t.state===`error`?`bg-danger/15 text-danger`:`text-fg-faint`),title:t.state===`error`?`${t.message??``}\n${e(`save.errorHint`)}`:n,children:[t.state===`error`?(0,W.jsx)(Oe,{size:11}):(0,W.jsx)(`span`,{className:U(`h-1.5 w-1.5 rounded-full`,t.state===`saved`?`bg-agent/70`:`animate-pulse bg-key`)}),n]})}async function Sg(e,t){try{let n=e.store.doc,r=N(n.layers,t);if(!r)return;let i=r.layer;if(i.type!==`text`&&i.type!==`shape`&&i.type!==`fill`)return;let a=Lr(i)?e.boxes.get(t):null,o=a?Math.ceil(Math.max(a.width,a.height)*.25+64):0,s=a?a.x-o:0,c=a?a.y-o:0,l=a?a.width+o*2:n.canvas.width,u=a?a.height+o*2:n.canvas.height,d=Math.min(1,4096/Math.max(l,u)),f={...i,visible:!0,opacity:1,blend:`normal`,...Lr(i)?{rotation:0,flipX:!1,flipY:!1,x:(i.x??0)-s,y:(i.y??0)-c}:{}};for(let e of[`filters`,`mask`,`effects`,`clip`])delete f[e];let p={...n,canvas:{width:l,height:u,background:null},layers:[f]},m=await Cp(e).render(p,{scale:d}),h=Cg(m);if(!h)return void Q({tone:`info`,title:V(`layers.rasterizeEmpty`)});let g=wc(h.w,h.h);z(g).drawImage(m,-h.x,-h.y);let _=await Rl(g,`image/png`),v=await Dp(e,`assets/edits`,`${t}-raster`);await e.backend.writeFile(v,_.bytes);let y={x:h.x/d+s,y:h.y/d+c,width:h.w/d,height:h.h/d},b={};for(let e of[`visible`,`locked`,`opacity`,`blend`,`mask`,`clip`,`filters`,`effects`])i[e]!==void 0&&(b[e]=i[e]);let x={...b,id:t,type:`image`,name:i.name??hd(i),src:v,x:y.x,y:y.y,width:y.width,height:y.height,...Lr(i)&&i.rotation?{rotation:i.rotation}:{},...Lr(i)&&i.flipX?{flipX:!0}:{},...Lr(i)&&i.flipY?{flipY:!0}:{}};e.edit([{op:`removeLayer`,id:t},{op:`addLayer`,layer:x,parent:r.parent?.id??null,index:r.index}],{select:t})}catch(e){Q({tone:`error`,title:V(`layers.rasterizeFailed`),detail:e.message})}}function Cg(e){let t=z(e).getImageData(0,0,e.width,e.height).data,n=e.width,r=e.height,i=-1,a=-1;for(let o=0;o<e.height;o++)for(let s=0;s<e.width;s++)t[(o*e.width+s)*4+3]>0&&(s<n&&(n=s),s>i&&(i=s),o<r&&(r=o),o>a&&(a=o));return i<0?null:{x:n,y:r,w:i-n+1,h:a-r+1}}function wg(e){let{enabled:t,...n}=e;return t===!1?n:{...n,enabled:!1}}var Tg={image:mt,text:ar,shape:xn,fill:Xt,adjustment:Tn,group:Qe};function Eg(){let{t:e}=H(),t=q(),{store:n,ui:r}=t,i=Pu(),a=i.doc,o=J(e=>e.collapsed),s=J(e=>e.flash),c=J(e=>e.maskTarget),l=wd(a.layers,new Set(o)),u=i.selection,d=u.length?N(a.layers,u[u.length-1])?.layer:void 0,[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(null),[g,_]=(0,S.useState)(null),v=(0,S.useRef)([]),y=(0,S.useRef)(null),b=(e,n,r)=>t.edit([{op:`updateLayer`,id:e,set:n}],r?{coalesce:r}:{}),x=(e,t)=>{if(e.shiftKey&&u.length){let e=l.map(e=>e.layer.id),r=e.indexOf(u[u.length-1]),i=e.indexOf(t);if(r>=0&&i>=0)return n.select([...new Set([...u,...e.slice(Math.min(r,i),Math.max(r,i)+1)])].filter(e=>e!==t).concat(t))}if(e.metaKey||e.ctrlKey)return n.toggleSelect(t);n.select(t)},ee=i=>{let o=bd(a,n.primary),s=a.canvas.width,c=a.canvas.height,l;i===`text`?(Lh(t,`text`),r.set({textEdit:{id:null,x:s*.1,y:c*.1}})):(l=i===`shape`?vd(a,`rect`,{x:s*.3,y:c*.3,width:s*.4,height:c*.4},r.get().fg):i===`solid`?{id:pd(a,`fill`),type:`fill`,name:e(`layers.solidName`),fill:r.get().fg}:i===`gradient`?{id:pd(a,`gradient`),type:`fill`,name:e(`layers.gradientName`),fill:{type:`linear`,angle:90,stops:[[0,`#00000000`],[1,`#000000cc`]]}}:i===`adjustment`?{id:pd(a,`adjustment`),type:`adjustment`,name:e(`layers.adjustmentName`),filters:[{type:`brightnessContrast`,brightness:0,contrast:0}]}:{id:pd(a,`group`),type:`group`,name:gd(`group`),children:[]},t.edit([{op:`addLayer`,layer:l,...o}],{select:l.id})&&r.set({rightTab:i===`adjustment`?`filters`:`properties`}))},te=n=>{let r=N(a.layers,n)?.layer;return r?[{label:e(`layers.duplicate`),icon:(0,W.jsx)(Pe,{size:13}),keys:`${gg}D`,run:()=>Rh(t)},{label:e(`layers.group`),icon:(0,W.jsx)(Xe,{size:13}),keys:`${gg}G`,run:()=>Bh(t)},{label:e(`layers.ungroup`),icon:(0,W.jsx)(lr,{size:13}),keys:`⇧${gg}G`,disabled:r.type!==`group`,run:()=>Vh(t)},`-`,{label:r.clip?e(`layers.unclip`):e(`layers.clip`),icon:(0,W.jsx)(ne,{size:13}),run:()=>b(n,{clip:!r.clip||null})},{label:r.locked?e(`layers.unlock`):e(`layers.lock`),icon:r.locked?(0,W.jsx)(Pt,{size:13}):(0,W.jsx)(It,{size:13}),run:()=>b(n,{locked:!r.locked||null})},{label:r.visible===!1?e(`layers.show`):e(`layers.hide`),icon:r.visible===!1?(0,W.jsx)(We,{size:13}):(0,W.jsx)(He,{size:13}),run:()=>b(n,{visible:r.visible===!1&&null})},`-`,{label:e(`layers.maskInvert`),icon:(0,W.jsx)(Fn,{size:13}),disabled:!r.mask,run:()=>r.mask&&t.edit([{op:`setMask`,id:n,mask:{...r.mask,invert:!r.mask.invert}}])},{label:e(`layers.maskRemove`),icon:(0,W.jsx)(zn,{size:13}),disabled:!r.mask,run:()=>t.edit([{op:`setMask`,id:n,mask:null}])},{label:e(`layers.rasterize`),icon:(0,W.jsx)(Et,{size:13}),disabled:r.type!==`text`&&r.type!==`shape`&&r.type!==`fill`,run:()=>void Sg(t,n)},`-`,{label:e(`layers.delete`),icon:(0,W.jsx)(tr,{size:13}),keys:`⌫`,danger:!0,run:()=>zh(t)}]:[]},C=(e,t)=>{if(!v.current.length)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=(e.clientY-n.top)/n.height,i=t.type===`group`&&r>.3&&r<.7?`inside`:r<.5?`above`:`below`;(g?.id!==t.id||g.where!==i)&&_({id:t.id,where:i})},w=e=>{e.preventDefault();let n=g;if(_(null),!n)return;let r=xd(a,v.current,n.id,n.where);v.current=[],r&&t.edit(r)};return(0,W.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":e(`layers.title`),children:[(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b border-line pl-3 pr-1.5`,children:[(0,W.jsx)(`span`,{className:`panel-title`,children:e(`layers.title`)}),(0,W.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:l.length}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center`,children:[(0,W.jsx)(Dg,{onAdd:ee,onImage:()=>y.current?.click()}),(0,W.jsx)(G,{label:e(`layers.group`),shortcut:`${gg}G`,disabled:!u.length,onClick:()=>Bh(t),className:`h-6 w-6`,children:(0,W.jsx)(Xe,{size:13})}),(0,W.jsx)(G,{label:e(`layers.delete`),shortcut:`⌫`,disabled:!u.length,onClick:()=>zh(t),className:`h-6 w-6 hover:text-danger`,children:(0,W.jsx)(tr,{size:13})})]}),(0,W.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,onChange:async e=>{let n=[...e.target.files??[]];e.target.value=``,n.length&&await t.importImages(await tg(n))}})]}),d&&(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 border-b border-line px-2.5 py-1.5`,children:[(0,W.jsx)(Eu,{value:d.blend??`normal`,options:Ir.map(e=>({value:e,label:df(e)})),onChange:e=>b(d.id,{blend:e===`normal`?null:e}),className:`w-[112px] flex-none`,ariaLabel:e(`layers.blend`)}),(0,W.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e(`layers.opacity`)}),(0,W.jsx)(sf,{value:Math.round((d.opacity??1)*100),min:0,max:100,integer:!0,onChange:(e,t)=>b(d.id,{opacity:e>=100?null:e/100},t?void 0:`opacity:${d.id}`),ariaLabel:e(`layers.opacity`)})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,onDragLeave:e=>e.currentTarget===e.target&&_(null),children:[l.map(({layer:i,depth:l})=>{let d=i.type===`group`&&!o.includes(i.id)?Je:Tg[i.type],m=u.includes(i.id),y=i.visible===!1,S=s&&s.ids.includes(i.id)&&Date.now()-s.at<2500;return(0,W.jsxs)(`div`,{"data-layer":i.id,draggable:f!==i.id,onDragStart:e=>{v.current=u.includes(i.id)?u:[i.id],e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,i.id)},onDragEnd:()=>(v.current=[],_(null)),onDragOver:e=>C(e,i),onDrop:w,onClick:e=>x(e,i.id),onDoubleClick:()=>i.type===`text`?(Lh(t,`move`),r.set({textEdit:{id:i.id}})):void 0,onContextMenu:e=>{e.preventDefault(),u.includes(i.id)||n.select(i.id),h({x:e.clientX,y:e.clientY,id:i.id})},className:U(`group relative mx-1 flex h-[38px] cursor-default select-none items-center gap-1.5 rounded-md pr-1.5`,m?`bg-accent/15`:`hover:bg-ink-2`,S&&`row-flash`,g?.id===i.id&&g.where===`inside`&&`ring-1 ring-inset ring-accent`),style:{paddingLeft:4+l*14},children:[g?.id===i.id&&g.where!==`inside`&&(0,W.jsx)(`div`,{className:U(`pointer-events-none absolute inset-x-1 h-0.5 rounded bg-accent`,g.where===`above`?`-top-px`:`-bottom-px`)}),(0,W.jsx)(`button`,{type:`button`,"aria-label":e(y?`layers.show`:`layers.hide`),onClick:e=>(e.stopPropagation(),b(i.id,{visible:y?null:!1})),className:U(`flex h-6 w-5 shrink-0 items-center justify-center rounded`,y?`text-fg-faint`:`text-fg-muted hover:text-fg`),children:y?(0,W.jsx)(He,{size:13}):(0,W.jsx)(We,{size:13})}),i.type===`group`?(0,W.jsx)(`button`,{type:`button`,"aria-label":e(`layers.toggleGroup`),onClick:e=>(e.stopPropagation(),r.set(e=>({collapsed:e.collapsed.includes(i.id)?e.collapsed.filter(e=>e!==i.id):[...e.collapsed,i.id]}))),className:`flex h-6 w-3.5 shrink-0 items-center justify-center text-fg-faint hover:text-fg`,children:o.includes(i.id)?(0,W.jsx)(Ee,{size:12}):(0,W.jsx)(we,{size:12})}):(0,W.jsx)(`span`,{className:`w-0`}),i.clip&&(0,W.jsx)(ne,{size:11,className:`-ml-0.5 shrink-0 rotate-[-90deg] text-fg-faint`,"aria-label":e(`layers.clipped`)}),i.type===`adjustment`||i.type===`group`||i.type===`text`?(0,W.jsx)(`div`,{className:`flex h-[28px] w-[36px] shrink-0 items-center justify-center rounded-[3px] bg-ink-2 text-fg-muted`,children:(0,W.jsx)(d,{size:15})}):(0,W.jsx)(Th,{layer:i,w:36,h:28}),i.mask&&(0,W.jsxs)(`button`,{type:`button`,title:e(`layers.maskChip`),"aria-label":e(`layers.maskChip`),onClick:e=>{e.stopPropagation(),e.altKey?r.set(e=>({showMask:e.showMask===i.id?null:i.id})):e.shiftKey?t.edit([{op:`setMask`,id:i.id,mask:wg(i.mask)}]):(n.select(i.id),r.set(e=>({maskTarget:e.maskTarget===i.id?null:i.id})))},className:U(`relative shrink-0 rounded-[3px]`,c===i.id?`ring-2 ring-accent`:`ring-1`,i.mask.enabled===!1?`opacity-50 ring-danger/60`:c!==i.id&&`ring-white/15 hover:ring-accent`),children:[(0,W.jsx)(Eh,{mask:i.mask,w:22,h:28,frame:i.type===`image`||i.type===`text`||i.type===`shape`?t.boxes.get(i.id):a.canvas}),i.mask.enabled===!1&&(0,W.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center text-sm font-bold text-danger`,children:`×`})]}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f===i.id?(0,W.jsx)(`input`,{autoFocus:!0,defaultValue:i.name??hd(i),onClick:e=>e.stopPropagation(),onBlur:e=>{let t=e.target.value.trim();p(null),t!==(i.name??``)&&b(i.id,{name:t||null})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&p(null)},className:`field h-6`}):(0,W.jsx)(`div`,{onDoubleClick:e=>(e.stopPropagation(),p(i.id)),className:U(`truncate text-sm`,y?`text-fg-faint`:`text-fg`),title:`${hd(i)} · ${i.id}`,children:hd(i)}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 truncate text-2xs text-fg-faint`,children:[(0,W.jsx)(d,{size:9}),e(`layerTypes.${i.type}`),(i.blend??`normal`)!==`normal`&&(0,W.jsxs)(`span`,{children:[`· `,df(i.blend)]}),(i.opacity??1)<1&&(0,W.jsxs)(`span`,{children:[`· `,Math.round((i.opacity??1)*100),`%`]}),!!i.filters?.length&&i.type!==`adjustment`&&(0,W.jsxs)(`span`,{className:`text-accent/80`,children:[`· fx `,i.filters.length]})]})]}),(0,W.jsx)(`button`,{type:`button`,"aria-label":i.locked?e(`layers.unlock`):e(`layers.lock`),onClick:e=>(e.stopPropagation(),b(i.id,{locked:!i.locked||null})),className:U(`flex h-6 w-5 shrink-0 items-center justify-center rounded`,i.locked?`text-fg-muted`:`text-fg-faint opacity-0 hover:text-fg group-hover:opacity-100`),children:i.locked?(0,W.jsx)(It,{size:12}):(0,W.jsx)(Pt,{size:12})})]},`${i.id}${S?s.at:``}`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n.select(null),className:U(`mx-1 mt-0.5 flex h-8 w-[calc(100%-8px)] items-center gap-2 rounded-md px-2 text-left text-xs`,u.length?`text-fg-muted hover:bg-ink-2`:`bg-ink-2 text-fg`),children:[(0,W.jsx)(`span`,{className:`checker-sm h-4 w-5 rounded-[2px] ring-1 ring-white/10`,style:{background:void 0}}),e(`layers.canvas`),(0,W.jsxs)(`span`,{className:`ml-auto tabular-nums text-fg-faint`,children:[a.canvas.width,`×`,a.canvas.height]})]})]}),m&&(0,W.jsx)(hg,{x:m.x,y:m.y,items:te(m.id),onClose:()=>h(null)})]})}function Dg({onAdd:e,onImage:t}){let{t:n}=H(),[r,i]=(0,S.useState)(null);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(G,{label:n(`layers.add`),onClick:e=>{let t=e.currentTarget.getBoundingClientRect();i({x:t.left-160,y:t.bottom+4})},className:`h-6 w-6`,children:(0,W.jsx)(nn,{size:14})}),r&&(0,W.jsx)(hg,{x:r.x,y:r.y,onClose:()=>i(null),items:[{label:n(`layers.addImage`),icon:(0,W.jsx)(mt,{size:13}),run:t},{label:n(`layers.addText`),icon:(0,W.jsx)(ar,{size:13}),keys:`T`,run:()=>e(`text`)},{label:n(`layers.addShape`),icon:(0,W.jsx)(xn,{size:13}),keys:`U`,run:()=>e(`shape`)},`-`,{label:n(`layers.addSolid`),icon:(0,W.jsx)(Xt,{size:13}),run:()=>e(`solid`)},{label:n(`layers.addGradient`),icon:(0,W.jsx)(Xt,{size:13}),run:()=>e(`gradient`)},{label:n(`layers.addAdjustment`),icon:(0,W.jsx)(Tn,{size:13}),run:()=>e(`adjustment`)},{label:n(`layers.addGroup`),icon:(0,W.jsx)(Qe,{size:13}),run:()=>e(`group`)}]})]})}var Og=`agentphoto.studio.layersHeight`,kg=[`properties`,`filters`,`looks`,`effects`];function Ag(){let{t:e}=H(),{ui:t}=q(),n=J(e=>e.rightTab),r=Iu(),i=(0,S.useRef)(null),[a,o]=(0,S.useState)(()=>{try{return Number(localStorage.getItem(Og))||300}catch{return 300}});(0,S.useEffect)(()=>{try{localStorage.setItem(Og,String(Math.round(a)))}catch{}},[a]);let s={filters:r?.filters?.length||void 0,effects:r?.effects&&Object.values(r.effects).filter(Boolean).length||void 0};return(0,W.jsxs)(`aside`,{ref:i,className:`flex w-[312px] shrink-0 flex-col border-l border-line bg-ink-1`,children:[(0,W.jsx)(`div`,{className:`flex min-h-[120px] flex-col`,style:{height:a},children:(0,W.jsx)(Eg,{})}),(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":e(`panels.resize`),onPointerDown:e=>{e.target.setPointerCapture(e.pointerId);let t=i.current.getBoundingClientRect().top,n=e=>o(Math.max(120,Math.min(window.innerHeight-260,e.clientY-t))),r=()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r)};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r)},className:`group relative h-1.5 shrink-0 cursor-row-resize border-y border-line bg-ink-1 hover:bg-accent/30`}),(0,W.jsx)(`div`,{className:`flex h-9 shrink-0 items-end gap-0.5 border-b border-line px-1.5`,children:kg.map(r=>(0,W.jsxs)(`button`,{type:`button`,"data-tab":r,onClick:()=>t.set({rightTab:r}),className:U(`relative flex h-8 items-center gap-1 rounded-t-md px-2.5 text-xs font-medium transition-colors`,n===r?`text-fg`:`text-fg-muted hover:text-fg`),children:[e(`tabs.${r}`),s[r]&&(0,W.jsx)(`span`,{className:`rounded bg-ink-3 px-1 text-2xs text-fg-muted`,children:s[r]}),n===r&&(0,W.jsx)(`span`,{className:`absolute inset-x-2 -bottom-px h-0.5 rounded bg-accent`})]},r))}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[n===`properties`&&(0,W.jsx)(sg,{}),n===`filters`&&(0,W.jsx)(bh,{}),n===`looks`&&(0,W.jsx)(jh,{}),n===`effects`&&(0,W.jsx)(gh,{})]})]})}var jg=typeof navigator<`u`&&/Mac/.test(navigator.platform)?`⌘`:`Ctrl`,Mg=[[[jg,`Z`],`keys.undo`],[[jg,`⇧`,`Z`],`keys.redo`],[[jg,`S`],`keys.save`],[[jg,`D`],`keys.duplicate`],[[jg,`G`],`keys.group`],[[jg,`⇧`,`G`],`keys.ungroup`],[[jg,`A`],`keys.selectAll`],[[`⌫`],`keys.delete`],[[`←`,`→`,`↑`,`↓`],`keys.nudge`],[[`⇧`,`↑`],`keys.nudge10`],[[`Esc`],`keys.deselect`],[[`Tab`],`keys.panels`],[[jg,`V`],`keys.paste`],[[`?`],`keys.help`]],Ng=[[[jg,`0`],`keys.fit`],[[jg,`1`],`keys.actual`],[[jg,`+`],`keys.zoomIn`],[[jg,`−`],`keys.zoomOut`],[[jg,`wheel`],`keys.zoomWheel`],[[`Space`,`drag`],`keys.pan`],[[`⇧`,`drag`],`keys.keepRatio`],[[jg,`drag`],`keys.noSnap`],[[`Enter`],`keys.commitCrop`],[[`⇧`,`drag`],`keys.dragFast`],[[`Alt`,`drag`],`keys.dragFine`]];function Pg(){let{t:e}=H(),{ui:t}=q();return(0,W.jsx)(Ed,{title:e(`keys.title`),width:760,onClose:()=>t.set({dialog:null}),children:(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-x-6 px-4 py-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`pb-1 pt-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:e(`keys.tools`)}),(0,W.jsx)(Fg,{rows:Km.map(e=>[[e.shortcut],e.label])})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`pb-1 pt-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:e(`keys.general`)}),(0,W.jsx)(Fg,{rows:Mg})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`pb-1 pt-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:e(`keys.view`)}),(0,W.jsx)(Fg,{rows:Ng})]})]})})}function Fg({rows:e}){let{t}=H();return(0,W.jsx)(`div`,{className:`divide-y divide-line`,children:e.map(([e,n],r)=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:t(n)}),(0,W.jsx)(`span`,{className:`flex shrink-0 gap-1`,children:e.map(e=>(0,W.jsx)(ku,{children:e===`wheel`?t(`keys.wheelKey`):e===`drag`?t(`keys.dragKey`):e},e))})]},r))})}function Ig(){let{t:e}=H(),t=q(),n=Pu(),r=J(e=>e.view.zoom),i=J(e=>e.cursor),a=J(e=>e.renderMs),o=(0,S.useSyncExternalStore)(t.boxes.subscribe,t.boxes.getSnapshot),s=n.doc,c=n.selection[n.selection.length-1],l=c?o.get(c):void 0,u=n.issues.filter(e=>e.severity===`error`);return(0,W.jsxs)(`footer`,{className:`flex h-6 shrink-0 items-center gap-4 border-t border-line bg-ink-1 px-3 text-2xs tabular-nums text-fg-faint`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`status.canvas`),children:[(0,W.jsx)(Rt,{size:10}),` `,s.canvas.width,` × `,s.canvas.height,` px`]}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`status.zoom`),children:[(0,W.jsx)(yr,{size:10}),` `,Math.round(r*1e3)/10,`%`]}),(0,W.jsxs)(`span`,{className:`flex w-[92px] items-center gap-1`,title:e(`status.cursor`),children:[(0,W.jsx)(Ie,{size:10}),` `,i?`${i.x}, ${i.y}`:`—`]}),l&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`status.selection`),children:[(0,W.jsx)(pn,{size:10}),Math.round(l.x),`, `,Math.round(l.y),` · `,Math.round(l.width),` × `,Math.round(l.height),l.rotation?` · ${l.rotation}°`:``]}),u.length>0&&(0,W.jsx)(`span`,{className:`text-danger`,children:e(`status.errors`,{n:u.length})}),(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,title:e(`status.render`),children:[(0,W.jsx)(et,{size:10}),` `,a,` ms`]})]})}function Lg({label:e,keys:t,children:n,side:r=`right`}){return(0,W.jsxs)(`div`,{className:`group/tip relative`,children:[n,(0,W.jsxs)(`div`,{className:U(`pointer-events-none absolute top-1/2 z-50 hidden -translate-y-1/2 whitespace-nowrap rounded-md border border-line bg-ink-1 px-2 py-1 text-xs text-fg shadow-lg shadow-black/40 group-hover/tip:flex`,r===`right`&&`left-full ml-2`),children:[e,t&&(0,W.jsx)(`kbd`,{className:`ml-2 rounded border border-line bg-ink-2 px-1 font-sans text-2xs text-fg-muted`,children:t})]})]})}function Rg(){let{t:e}=H(),t=q(),n=J(e=>e.tool),r=J(e=>e.shapeKind),i=J(e=>e.fg);Pu();let[a,o]=(0,S.useState)(!1);return(0,W.jsxs)(`nav`,{"aria-label":e(`tools.title`),className:`flex w-11 shrink-0 flex-col items-center gap-0.5 border-r border-line bg-ink-1 py-2`,children:[[`select`,`draw`,`paint`,`view`].map((i,s)=>(0,W.jsx)(`div`,{className:U(`flex flex-col items-center gap-0.5`,s>0&&`mt-1.5 border-t border-line pt-1.5`),children:Km.filter(e=>e.group===i).map(i=>{let s=i.id===`shape`?Jf[r]:i.icon,c=n===i.id;return(0,W.jsxs)(Lg,{label:e(i.label),keys:i.shortcut,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-label":e(i.label),"aria-pressed":c,"data-tool":i.id,onClick:()=>i.id===`shape`&&c?o(e=>!e):Lh(t,i.id),onContextMenu:e=>{i.id===`shape`&&(e.preventDefault(),Lh(t,`shape`),o(!0))},className:U(`relative flex h-8 w-8 items-center justify-center rounded-md transition-colors`,c?`bg-accent/15 text-accent`:`text-fg-muted hover:bg-ink-3 hover:text-fg`),children:[(0,W.jsx)(s,{size:16,strokeWidth:1.75}),i.id===`shape`&&(0,W.jsx)(`span`,{className:`absolute bottom-[3px] right-[3px] h-0 w-0 border-l-[4px] border-t-[4px] border-l-transparent border-t-current opacity-60`,style:{transform:`rotate(-90deg)`}})]}),i.id===`shape`&&a&&(0,W.jsx)(`div`,{className:`absolute left-full top-0 z-50 ml-2 rounded-lg border border-line bg-ink-1 p-1 shadow-xl shadow-black/50`,onMouseLeave:()=>o(!1),children:(0,W.jsx)(Xf,{value:r,onChange:e=>{t.ui.set({shapeKind:e}),Lh(t,`shape`),o(!1)}})})]},i.id)})},i)),(0,W.jsxs)(`div`,{className:`mt-1.5 flex flex-col items-center gap-0.5 border-t border-line pt-1.5`,children:[(0,W.jsx)(kn,{size:11,className:`mb-0.5 text-agent/80`,"aria-hidden":!0}),Qm.map(n=>{let r=n.enabled(t);return(0,W.jsx)(Lg,{label:`${e(n.label)} — ${e(n.hint)}`,children:(0,W.jsx)(`button`,{type:`button`,"aria-label":e(n.label),disabled:!r,onClick:()=>void n.run(t),className:`flex h-8 w-8 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-agent/10 hover:text-agent disabled:opacity-30 disabled:hover:bg-transparent`,children:(0,W.jsx)(n.icon,{size:16,strokeWidth:1.75})})},n.id)})]}),(0,W.jsx)(`div`,{className:`mt-auto`,children:(0,W.jsx)(Gd,{width:232,align:`start`,trigger:(t,n)=>(0,W.jsx)(Lg,{label:e(`tools.foreground`),children:(0,W.jsx)(`button`,{type:`button`,"aria-label":e(`tools.foreground`),"aria-expanded":n,onClick:t,className:`checker-sm relative h-6 w-6 overflow-hidden rounded-md ring-1 ring-white/20 hover:ring-white/50`,children:(0,W.jsx)(`span`,{className:`absolute inset-0`,style:{background:i}})})}),children:()=>(0,W.jsx)(Qd,{value:i,onChange:e=>t.ui.set({fg:e})})})})]})}var zg=e=>e.length?e[e.length-1]:null;function Bg(e,t=``){return!e||typeof e!=`object`||Array.isArray(e)?[t]:Object.keys(e).sort().flatMap(n=>Bg(e[n],t?`${t}.${n}`:n))}function Vg(e,t){return e.op===`set`&&t.op===`set`?e.path===t.path:e.op===`updateLayer`&&t.op===`updateLayer`?e.id===t.id&&Bg(e.set).join()===Bg(t.set).join()&&!JSON.stringify(t.set).includes(`null`):e.op===`updateFilter`&&t.op===`updateFilter`&&e.id===t.id&&e.index===t.index&&Bg(e.set).join()===Bg(t.set).join()}var Hg=class{persist;snap={doc:null,selection:[],issues:[],save:{state:`saved`},canUndo:!1,canRedo:!1,revision:0,source:`load`};listeners=new Set;past=[];future=[];pendingOps=[];needsFull=!1;timer=null;chain=Promise.resolve();lastCoalesce=null;sent=[];opts;constructor(e,t={}){this.persist=e,this.opts={debounceMs:300,historyLimit:100,coalesceMs:1e3,now:()=>Date.now(),validate:Gi,...t}}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getSnapshot=()=>this.snap;get doc(){return this.snap.doc}get primary(){return zg(this.snap.selection)}emit(e){this.snap={...this.snap,...e,canUndo:this.past.length>0,canRedo:this.future.length>0},this.listeners.forEach(e=>e())}setDoc(e,t,n={}){let r=(n.selection??this.snap.selection).filter(t=>N(e.layers,t));this.emit({doc:e,source:t,issues:this.opts.validate(e),revision:this.snap.revision+1,...n,selection:r})}pushHistory(e){this.past.push(e),this.past.length>this.opts.historyLimit&&this.past.shift(),this.future=[]}load(e){this.past=[],this.future=[],this.pendingOps=[],this.needsFull=!1,this.lastCoalesce=null,this.setDoc(e,`load`,{save:{state:`saved`},selection:[]})}select(e){let t=e===null?[]:Array.isArray(e)?e:[e];t.join(`
26
+ `)!==this.snap.selection.join(`
27
+ `)&&this.emit({selection:t})}toggleSelect(e){let t=this.snap.selection;this.select(t.includes(e)?t.filter(t=>t!==e):[...t,e])}edit(e,t={}){let n=this.snap.doc;if(!n||!e.length)return null;let r;try{r=Xo(n,e,this.opts.sizes?.()??{})}catch(e){return e.message}let i=this.opts.now();t.coalesce&&this.lastCoalesce?.key===t.coalesce&&i-this.lastCoalesce.at<this.opts.coalesceMs||this.pushHistory(n),this.lastCoalesce=t.coalesce?{key:t.coalesce,at:i}:null;for(let t of e)this.queue(t);let a=t.select===void 0?void 0:t.select===null?[]:Array.isArray(t.select)?t.select:[t.select];return this.setDoc(r,`edit`,{save:{state:`pending`},...a?{selection:a}:{}}),this.schedule(),null}queue(e){let t=this.pendingOps[this.pendingOps.length-1];t&&Vg(t,e)?this.pendingOps[this.pendingOps.length-1]=e:this.pendingOps.push(e)}replace(e){let t=this.snap.doc;t&&lo(t,e)||(t&&this.pushHistory(t),this.lastCoalesce=null,this.needsFull=!0,this.pendingOps=[],this.setDoc(e,`replace`,{save:{state:`pending`}}),this.schedule(0))}undo(){let e=this.past.pop();e&&this.snap.doc&&(this.future.push(this.snap.doc),this.historyMove(e))}redo(){let e=this.future.pop();e&&this.snap.doc&&(this.past.push(this.snap.doc),this.historyMove(e))}historyMove(e){this.lastCoalesce=null,this.needsFull=!0,this.pendingOps=[],this.setDoc(e,`history`,{save:{state:`pending`}}),this.schedule(0)}isEcho(e){return this.sent.includes(so(e))}external(e){let t=this.snap.doc;if(t&&lo(t,e))return!1;let n=e;if(this.pendingOps.length&&!this.needsFull)try{n=Xo(e,this.pendingOps,this.opts.sizes?.()??{})}catch{this.pendingOps=[]}else this.pendingOps=[],this.needsFull=!1;return t&&lo(t,n)?!1:(t&&this.pushHistory(t),this.lastCoalesce=null,this.setDoc(n,`external`,{save:this.pendingOps.length?this.snap.save:{state:`saved`}}),!0)}schedule(e=this.opts.debounceMs){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}get dirty(){return this.needsFull||this.pendingOps.length>0}flush(){return this.timer&&=(clearTimeout(this.timer),null),this.chain=this.chain.then(()=>this.sendOnce()),this.chain}async sendOnce(){let e=this.snap.doc;if(!e||!this.dirty)return;let t=this.needsFull?{kind:`apply`,doc:e}:{kind:`patch`,ops:this.pendingOps};this.pendingOps=[],this.needsFull=!1,this.sent=[...this.sent.slice(-7),so(e)],this.emit({save:{state:`saving`}});try{let e=await this.persist(t);if(e.status===`refused`){this.needsFull=!0;let t=(e.issues??[]).filter(e=>e.severity===`error`);this.emit({save:{state:`error`,message:t[0]?.message??e.hint,issues:t}})}else this.dirty?this.emit({save:{state:`pending`}}):this.emit({save:{state:`saved`}})}catch(e){this.needsFull=!0,this.emit({save:{state:`error`,message:e.message}})}}};function Ug(){let e=xu(`panel`),t=xu(`dialog`),n=xu(`tool`);return{tool:Km.some(e=>e.id===n)?n:`move`,shapeKind:`rect`,marqueeKind:`rect`,view:{zoom:1,x:0,y:0},fitRequest:0,rightTab:[`properties`,`filters`,`looks`,`effects`].includes(e??``)?e:`properties`,assistant:xu(`assistant`)===`1`,panelsHidden:!1,dialog:t===`export`||t===`shortcuts`?t:null,flash:null,agentPulse:0,region:null,crop:null,textEdit:null,fg:`#ffffff`,cursor:null,renderMs:0,busy:null,consent:null,check:null,checkRunning:!1,showMask:null,smartGuides:!0,cropRatio:null,cropRatioId:`free`,filesVersion:0,collapsed:[],lassoKind:`free`,maskTarget:null,brush:{size:60,hardness:.7,opacity:1,flow:1},maskPaint:`hide`,cloneSource:null,wand:{tolerance:24,contiguous:!0,sampleAll:!1},quick:null}}function Wg({backend:e,onClose:t}){let[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null);return(0,S.useEffect)(()=>{let n=!1,i=new Map,o=new Hg(t=>e.call(t.kind===`patch`?`doc_patch`:`doc_apply`,t.kind===`patch`?{ops:t.ops}:{doc:t.doc}),{sizes:()=>Object.fromEntries(i)}),s=ju(Ug()),c=new Nl(e.engineOptions()),l=new yl(c.loader),u=new Bf(l),d=e=>{P(e.layers,e=>{e.type===`image`&&!i.has(e.src)&&l.naturalSize(e.src).then(t=>i.set(e.src,t)).catch(()=>void 0)})},f=o.subscribe(()=>{let e=o.doc;e&&(d(e),u.update(e))}),p=async(t={})=>{let n=await e.loadDoc();if(o.isEcho(n))return;let r=o.doc;if(!o.external(n))return;let i=Ro(r,n),a=[...i.layers.added,...i.layers.changed.map(e=>e.id),...i.layers.moved.map(e=>e.id)];s.set(e=>({flash:{ids:a,at:Date.now()},agentPulse:e.agentPulse+1})),t.toast!==!1&&Q({tone:`agent`,title:V(`external.title`),detail:i.summary,action:{label:V(`external.undo`),run:()=>o.undo()}},6e3)},m=t=>new Promise(n=>{if(Od(t))return n(!0);e.modelCached(t).catch(()=>!1).then(e=>{if(e)return n(!0);s.set({consent:{model:t,resolve:e=>(s.set({consent:null}),n(e))}})})}),h=[],g=n=>({backend:e,store:o,ui:s,tools:h,library:n,engine:c,thumbs:l,boxes:u,edit(e,t){let n=o.edit(e,t);return n&&Q({tone:`error`,title:V(`edit.failed`),detail:n}),!n},async runCheck(){s.set({checkRunning:!0});try{await o.flush();let t=await e.call(`check`,{});s.set({check:{...t,at:Date.now()}});let n=t.counts??{errors:0,warnings:0,infos:0};Q({tone:n.errors?`error`:`success`,title:n.errors||n.warnings?V(`check.found`,{errors:n.errors,warnings:n.warnings}):V(`check.ok`),detail:t.issues?.find(e=>e.severity!==`info`)?.message},5e3)}catch(e){Q({tone:`error`,title:V(`check.failed`),detail:e.message})}finally{s.set({checkRunning:!1})}},reloadDoc:p,async runTool(t,n,r={}){if(r.model&&si(r.model)&&!await m(r.model))return null;await o.flush(),r.busy&&s.set({busy:{label:V(r.busy)}});try{let r=await e.call(t,n);return h.find(e=>e.name===t)?.mutating&&await p({toast:!1}),r}catch(e){let n=e;return Q({tone:`error`,title:V(`tools.failed`,{tool:t}),detail:[n.message,n.hint].filter(Boolean).join(` — `)},8e3),null}finally{r.busy&&s.set({busy:null})}},async importImages(t,n){for(let r of t){let t=ra(r.bytes);if(!t)Q({tone:`error`,title:V(`import.notImage`,{name:r.name})});else try{let i=await e.addImage(r.name,r.bytes),a=o.doc,s=yd(a,i,t,r.name,n),c=o.primary;o.edit([{op:`addLayer`,layer:s,...c?{above:c}:{}}],{select:s.id}),Q({tone:`success`,title:V(`import.done`,{name:r.name})},2400)}catch(e){Q({tone:`error`,title:V(`import.failed`,{name:r.name}),detail:e.message})}}},closeProject(){(async()=>{await o.flush();let n=o.doc;if(n&&e.saveThumb)try{let t=Math.min(1,320/Math.max(n.canvas.width,n.canvas.height)),r=await Rl(await c.render(n,{scale:t}),`image/jpeg`,80);await e.saveThumb(dd(r.bytes,`image/jpeg`))}catch{}t()})()},naturalSize:e=>i.get(e),ensureModel:e=>m(e)});(async()=>{try{let[t,i,a]=await Promise.all([e.loadDoc(),e.tools().catch(()=>[]),e.library().catch(()=>({assets:[]}))]);if(n)return;h=i,c.setLibrary(a),o.load(t);let s=xu(`select`);s&&o.select(s.split(`,`)),r(g(a))}catch(e){n||a(e.message)}})();let _=xu(`events`)===`0`?()=>void 0:e.onChange(e=>{let t=e.filter(e=>e.startsWith(`assets/`));for(let e of t)c.loader.invalidate(e);t.length&&s.set(e=>({filesVersion:e.filesVersion+1})),e.includes(`photo.json`)&&p().catch(()=>void 0)}),v=e.onAiProgress(e=>{s.get().busy&&s.set({busy:{label:e.progress<1?V(`ai.downloading`,{model:e.model,pct:Math.round(e.progress*100)}):V(`ai.running`),progress:e.progress<1?e.progress:void 0}})}),y=e=>{o.dirty&&(o.flush(),e.preventDefault())};return window.addEventListener(`beforeunload`,y),()=>{n=!0,_(),v(),f(),window.removeEventListener(`beforeunload`,y),o.flush()}},[e,t]),i?(0,W.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,W.jsx)(`div`,{className:`text-base font-medium`,children:V(`app.loadFailed`)}),(0,W.jsx)(`div`,{className:`max-w-md text-sm text-fg-muted`,children:i}),(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`mt-2 text-sm text-accent hover:underline`,children:V(`app.back`)})]}):n?(0,W.jsx)(Nu.Provider,{value:n,children:(0,W.jsx)(Gg,{})}):(0,W.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-fg-muted`,children:[(0,W.jsx)(Mt,{size:16,className:`animate-spin`}),` `,V(`app.loadingDoc`)]})}function Gg(){let e=J(e=>e.assistant),t=J(e=>e.dialog),n=J(e=>e.panelsHidden);return Wh(),(0,W.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,W.jsx)(_g,{}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!n&&(0,W.jsx)(Rg,{}),(0,W.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[!n&&(0,W.jsx)($m,{}),(0,W.jsx)(Xh,{}),(0,W.jsx)(Ig,{}),(0,W.jsx)(sd,{}),(0,W.jsx)(jd,{})]}),!n&&(0,W.jsx)(Ag,{}),e&&(0,W.jsx)($u,{})]}),t===`export`&&(0,W.jsx)(xf,{}),t===`shortcuts`&&(0,W.jsx)(Pg,{}),(0,W.jsx)(Ad,{})]})}function Kg({w:e,h:t,max:n=46}){let r=n/Math.max(e,t);return(0,W.jsx)(`div`,{className:`rounded-[3px] border border-fg-faint/60 bg-gradient-to-br from-ink-4/80 to-ink-3/40 transition-colors group-hover:border-accent/80 group-hover:from-accent/25`,style:{width:Math.max(8,e*r),height:Math.max(8,t*r)}})}function qg({backend:e,onOpened:t}){let{t:n,lang:r,setLang:i}=H(),[a,o]=(0,S.useState)([]),[s,c]=(0,S.useState)([]),[l,u]=(0,S.useState)([]),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),[h,g]=(0,S.useState)(!1),[_,v]=(0,S.useState)(null),y=(0,S.useRef)(null);(0,S.useEffect)(()=>{e.templates().then(o),e.library().then(e=>c(e.assets.filter(e=>e.kind===`image`))),e.recent().then(u)},[e]);let b=e.canCreate(),x=async(r,i)=>{if(e.mode!==`cli`||!e.hasProject()||window.confirm(n(`start.replaceConfirm`,{dir:e.location??``}))){f(r),m(null);try{await e.createProject(i),t()}catch(e){m(e.message)}finally{f(null)}}},ee=async e=>{let t=e.find(e=>e.type.startsWith(`image/`)||/\.(png|jpe?g|webp|gif|avif|bmp|svg)$/i.test(e.name));if(!t)return m(n(`start.notImage`));let[r]=await tg([t]);await x(`photo`,{title:t.name.replace(/\.[^.]+$/,``)||`Photo`,image:r})};return(0,W.jsxs)(`div`,{className:`h-full overflow-auto`,children:[(0,W.jsxs)(`div`,{className:`mx-auto max-w-[1240px] px-8 py-8`,children:[(0,W.jsxs)(`header`,{className:`mb-8 flex items-center justify-between gap-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(bg,{size:36}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-[22px] font-semibold leading-tight tracking-tight`,children:`AgentPhoto Studio`}),(0,W.jsx)(`p`,{className:`mt-0.5 max-w-xl text-sm text-fg-muted`,children:n(`start.tagline`)})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.hasProject()&&(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:`flex h-8 items-center gap-1.5 rounded-md bg-accent px-3 text-sm font-medium text-ink-0 hover:bg-accent/90`,children:[n(`start.continue`,{title:e.projectTitle()}),` `,(0,W.jsx)(oe,{size:14})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 text-xs text-fg-muted`,children:[e.mode===`cli`?(0,W.jsx)(ot,{size:12}):(0,W.jsx)(Me,{size:12}),e.mode===`cli`?n(`start.cliMode`,{v:e.version??``}):n(`start.localMode`)]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(r===`en`?`fr`:`en`),title:n(`top.language`),className:`h-8 rounded-md px-2 text-xs font-semibold text-fg-muted hover:bg-ink-3 hover:text-fg`,children:r.toUpperCase()})]})]}),!b&&(0,W.jsxs)(`div`,{className:`mb-6 flex gap-3 rounded-lg border border-line bg-ink-1 p-4`,children:[(0,W.jsx)(qn,{size:16,className:`mt-0.5 shrink-0 text-accent`}),(0,W.jsxs)(`div`,{className:`text-sm`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:n(`start.noFolderTitle`)}),(0,W.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n(`start.noFolderBody`)}),(0,W.jsxs)(`pre`,{className:`mt-2 rounded bg-ink-0 px-2 py-1.5 font-mono text-2xs text-fg`,children:[`agentphoto new my-photo --image photo.jpg`,`
28
+ `,`agentphoto studio --project my-photo`]})]})]}),p&&(0,W.jsx)(`div`,{className:`mb-6 rounded-md bg-danger/10 px-3 py-2 text-sm text-danger`,children:p}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_272px] gap-10`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-9`,children:[(0,W.jsxs)(`section`,{onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:e=>{e.preventDefault(),g(!1),ee([...e.dataTransfer.files])},className:U(`relative flex items-center gap-6 overflow-hidden rounded-xl border border-dashed px-8 py-8 transition-colors`,h?`border-accent bg-accent/10`:`border-line bg-ink-1`),style:h?void 0:{backgroundImage:`radial-gradient(120% 140% at 0% 0%, rgb(var(--accent) / 0.16), transparent 55%), radial-gradient(90% 120% at 100% 100%, rgb(var(--agent) / 0.08), transparent 60%)`},children:[(0,W.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded-2xl bg-accent/15 text-accent ring-1 ring-accent/30`,children:d===`photo`?(0,W.jsx)(Mt,{size:26,className:`animate-spin`}):(0,W.jsx)(ut,{size:28,strokeWidth:1.6})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:n(`start.openTitle`)}),(0,W.jsx)(`p`,{className:`mt-1 max-w-lg text-sm text-fg-muted`,children:n(`start.openBody`)})]}),(0,W.jsxs)(`button`,{type:`button`,disabled:!b||!!d,onClick:()=>y.current?.click(),className:`flex h-9 shrink-0 items-center gap-2 rounded-lg bg-accent px-4 text-sm font-semibold text-ink-0 shadow-lg shadow-accent/20 hover:bg-accent/90 disabled:opacity-50`,children:[(0,W.jsx)(dr,{size:15}),` `,n(`start.choose`)]}),(0,W.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>{let t=[...e.target.files??[]];e.target.value=``,t.length&&ee(t)}})]}),s.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`start.samples`)}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:n(`start.samplesHint`)})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-3 xl:grid-cols-6`,children:s.map(t=>(0,W.jsxs)(`button`,{type:`button`,disabled:!b||!!d,onClick:()=>void x(`sample:${t.id}`,{title:t.title??t.id,libraryImage:t.id}),className:`group text-left disabled:opacity-60`,title:t.description,children:[(0,W.jsxs)(`div`,{className:`relative aspect-[4/3] overflow-hidden rounded-lg bg-ink-2 ring-1 ring-white/5 transition group-hover:ring-accent/60`,children:[(0,W.jsx)(`img`,{src:`${e.libraryBase()}${t.path}`,alt:``,loading:`lazy`,className:`h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.04]`}),d===`sample:${t.id}`&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,W.jsx)(Mt,{size:18,className:`animate-spin`})})]}),(0,W.jsx)(`div`,{className:`mt-1.5 truncate text-xs font-medium capitalize`,children:t.id}),(0,W.jsxs)(`div`,{className:`truncate text-2xs text-fg-faint`,children:[t.width,`×`,t.height,` · `,t.license]})]},t.id))})]}),a.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`start.templates`)}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:n(`start.templatesHint`)})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-3 xl:grid-cols-4`,children:a.map(t=>(0,W.jsxs)(`button`,{type:`button`,"data-template":t.id,disabled:!b||!!d,onClick:()=>v(t),className:`group text-left disabled:opacity-60`,title:t.description,children:[(0,W.jsxs)(`div`,{className:`relative aspect-[4/3] overflow-hidden rounded-lg bg-ink-2 ring-1 ring-white/5 transition group-hover:ring-accent/60`,children:[(0,W.jsx)(Yg,{src:e.templatePreview(t.id)}),d===t.id&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,W.jsx)(Mt,{size:18,className:`animate-spin`})}),(0,W.jsxs)(`span`,{className:`absolute bottom-1.5 left-1.5 rounded bg-black/60 px-1.5 py-0.5 text-2xs font-medium text-white/90 backdrop-blur`,children:[t.width,`×`,t.height]})]}),(0,W.jsx)(`div`,{className:`mt-1.5 truncate text-xs font-medium`,children:t.title}),(0,W.jsx)(`div`,{className:`truncate text-2xs capitalize text-fg-faint`,children:t.category})]},t.id))})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`start.blank`)}),(0,W.jsx)(`span`,{className:`text-xs text-fg-faint`,children:n(`start.blankHint`)})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-4 gap-2 xl:grid-cols-5`,children:Zr.map(e=>(0,W.jsxs)(`button`,{type:`button`,disabled:!b||!!d,onClick:()=>void x(`blank:${e.id}`,{title:gf(e.id),width:e.width,height:e.height,background:`#ffffff`}),className:`group flex items-center gap-3 rounded-lg border border-line bg-ink-1 p-2.5 text-left transition-colors hover:border-accent/50 hover:bg-ink-2 disabled:opacity-60`,title:e.description,children:[(0,W.jsx)(`div`,{className:`flex h-12 w-12 shrink-0 items-center justify-center`,children:d===`blank:${e.id}`?(0,W.jsx)(Mt,{size:16,className:`animate-spin`}):(0,W.jsx)(Kg,{w:e.width,h:e.height})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-xs font-medium`,children:gf(e.id)}),(0,W.jsxs)(`div`,{className:`text-2xs tabular-nums text-fg-faint`,children:[e.width,` × `,e.height]})]})]},e.id))})]})]}),(0,W.jsxs)(`aside`,{children:[(0,W.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:n(`start.recent`)}),l.length?(0,W.jsx)(`ul`,{className:`space-y-1`,children:l.map(r=>(0,W.jsxs)(`li`,{className:`group flex items-center gap-1`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:async()=>{if(e.mode===`cli`)r.id===e.location&&e.hasProject()&&t();else try{await e.open(r.id),t()}catch(e){m(e.message)}},className:U(`flex min-w-0 flex-1 items-center gap-2.5 rounded-lg p-1.5 text-left hover:bg-ink-2`,e.mode===`cli`&&r.id!==e.location&&`cursor-default opacity-60`),title:e.mode===`cli`&&r.id!==e.location?n(`start.otherFolder`,{dir:r.id}):r.id,children:[(0,W.jsx)(`div`,{className:`flex h-10 w-14 shrink-0 items-center justify-center overflow-hidden rounded-md bg-ink-2 ring-1 ring-white/5`,children:r.thumb?(0,W.jsx)(`img`,{src:r.thumb,alt:``,className:`h-full w-full object-cover`}):(0,W.jsx)(Je,{size:14,className:`text-fg-faint`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm`,children:r.title}),(0,W.jsx)(`div`,{className:`truncate text-2xs text-fg-faint`,children:e.mode===`cli`?r.id:r.updatedAt?new Date(r.updatedAt).toLocaleString():``})]})]}),e.remove&&(0,W.jsx)(`button`,{type:`button`,"aria-label":n(`start.remove`),title:n(`start.remove`),onClick:async()=>(await e.remove(r.id),u(await e.recent())),className:`rounded p-1 text-fg-faint opacity-0 hover:text-danger group-hover:opacity-100`,children:(0,W.jsx)(tr,{size:12})})]},r.id))}):(0,W.jsx)(`p`,{className:`text-xs text-fg-faint`,children:n(`start.noRecent`)}),(0,W.jsxs)(`div`,{className:`mt-8 rounded-lg border border-line bg-ink-1 p-3.5 text-xs leading-relaxed text-fg-muted`,children:[(0,W.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:n(`start.agentTitle`)}),n(`start.agentBody`),(0,W.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-ink-0 px-2 py-1.5 font-mono text-2xs text-fg`,children:`agentphoto mcp`})]}),(0,W.jsxs)(`div`,{className:`mt-3 rounded-lg border border-line p-3.5 text-xs leading-relaxed text-fg-muted`,children:[(0,W.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:n(`start.privacyTitle`)}),n(`start.privacyBody`)]})]})]})]}),_&&(0,W.jsx)(Jg,{tp:_,preview:e.templatePreview(_.id),onClose:()=>v(null),onUse:async e=>{v(null),await x(_.id,{title:_.title,template:_.id,...e?{image:e}:{}})}})]})}function Jg({tp:e,preview:t,onClose:n,onUse:r}){let{t:i}=H(),a=(0,S.useRef)(null);return(0,W.jsx)(Ed,{title:e.title,width:620,onClose:n,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`mr-auto text-2xs text-fg-faint`,children:e.slot?i(`start.slotHint`):``}),e.slot&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a.current?.click(),className:`flex h-8 items-center gap-1.5 rounded-md bg-ink-3 px-3 text-sm font-medium hover:bg-ink-4`,children:[(0,W.jsx)(ut,{size:14}),` `,i(`start.withPhoto`)]}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(),className:`flex h-8 items-center gap-1.5 rounded-md bg-accent px-3 text-sm font-medium text-ink-0 hover:bg-accent/90`,children:[i(`start.useTemplate`),` `,(0,W.jsx)(oe,{size:14})]}),(0,W.jsx)(`input`,{ref:a,type:`file`,accept:`image/*`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t&&r((await tg([t]))[0])}})]}),children:(0,W.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,W.jsx)(`div`,{className:`flex h-80 items-center justify-center overflow-hidden rounded-lg bg-ink-2`,children:(0,W.jsx)(Yg,{src:t})}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.description}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1 text-2xs text-fg-faint`,children:[(0,W.jsxs)(`span`,{className:`rounded bg-ink-2 px-1.5 py-0.5 tabular-nums`,children:[e.width,` × `,e.height]}),e.tags.map(e=>(0,W.jsx)(`span`,{className:`rounded bg-ink-2 px-1.5 py-0.5`,children:e},e))]})]})})}function Yg({src:e}){let[t,n]=(0,S.useState)(!e);return t||!e?(0,W.jsx)(`div`,{className:`h-full w-full bg-gradient-to-br from-ink-3 to-ink-1`}):(0,W.jsx)(`img`,{src:e,alt:``,className:`h-full w-full object-contain`,onError:()=>n(!0)})}function Xg(){let{t:e}=H(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(0);(0,S.useEffect)(()=>{let e=!1;return(async()=>{let t=await au(),r;if(t)r=new su(t);else{let e=new tu;await e.init();let t=xu(`project`);t&&await e.open(t).catch(()=>void 0),r=e}e||(n(r),i(r.hasProject()&&xu(`start`)!==`1`))})(),()=>{e=!0}},[]);let s=(0,S.useCallback)(()=>{o(e=>e+1),i(!0)},[]),c=(0,S.useCallback)(()=>i(!1),[]);return t?r?(0,W.jsx)(Wg,{backend:t,onClose:c},a):(0,W.jsx)(qg,{backend:t,onOpened:s}):(0,W.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-fg-muted`,children:[(0,W.jsx)(Mt,{size:16,className:`animate-spin`}),` `,e(`app.loading`)]})}document.documentElement.lang=_u(),(0,br.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(S.StrictMode,{children:(0,W.jsx)(Xg,{})}));export{r as n,n as t};