@fleox/agentphoto 0.0.0-stage → 0.1.0

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 (231) hide show
  1. package/LICENSE +143 -0
  2. package/README.md +229 -2
  3. package/changelog.json +17 -0
  4. package/dist/agent/agentphoto.mjs +3307 -0
  5. package/dist/agent/chunks/assets-CDQo3VqD.mjs +151 -0
  6. package/dist/agent/chunks/catalog-DIZ5dnH5.mjs +953 -0
  7. package/dist/agent/chunks/context-DoLoLF9f.mjs +75 -0
  8. package/dist/agent/chunks/doc-BjY_j4Su.mjs +773 -0
  9. package/dist/agent/chunks/export-CLmpFART.mjs +140 -0
  10. package/dist/agent/chunks/ids-DAmiNwd9.mjs +28 -0
  11. package/dist/agent/chunks/imageInfo-QxAfu8R6.mjs +173 -0
  12. package/dist/agent/chunks/jsonPath-B7vAPXsi.mjs +155 -0
  13. package/dist/agent/chunks/library-C_EXiphj.mjs +16 -0
  14. package/dist/agent/chunks/models-C4i_hicr.mjs +387 -0
  15. package/dist/agent/chunks/output-3F12IR9O.mjs +130 -0
  16. package/dist/agent/chunks/package-DSmAxrla.mjs +71 -0
  17. package/dist/agent/chunks/project-CUykGysG.mjs +198 -0
  18. package/dist/agent/chunks/rolldown-runtime-CMQPkI6i.mjs +18 -0
  19. package/dist/agent/chunks/server-I0trf5tM.mjs +241 -0
  20. package/dist/agent/chunks/templates--YGpGuHh.mjs +40 -0
  21. package/dist/agent/chunks/tools-Dnh8g6F9.mjs +1354 -0
  22. package/dist/agent/chunks/tree-DO7N0UDV.mjs +127 -0
  23. package/dist/agent/chunks/types-DOK7tAAu.mjs +30 -0
  24. package/dist/agent/chunks/validate-CXPFB-i6.mjs +936 -0
  25. package/dist/engine/agentphoto-engine.js +2777 -0
  26. package/dist/engine/chunks/transformers.web-D5Vsg6-A.js +18494 -0
  27. package/dist/engine/ort/ort-wasm-simd-threaded.asyncify.mjs +124 -0
  28. package/dist/engine/ort/ort-wasm-simd-threaded.asyncify.wasm +0 -0
  29. package/dist/studio/assets/index-Be8JnaFy.js +28 -0
  30. package/dist/studio/assets/index-DwPms2S5.css +1 -0
  31. package/dist/studio/assets/transformers.web-DgnCIB_X.js +38 -0
  32. package/dist/studio/index.html +15 -0
  33. package/dist/studio/library/LICENSES.md +57 -0
  34. package/dist/studio/library/fonts/OFL.txt +90 -0
  35. package/dist/studio/library/fonts/anton/anton-latin-400-normal.woff2 +0 -0
  36. package/dist/studio/library/fonts/anton/anton-latin-ext-400-normal.woff2 +0 -0
  37. package/dist/studio/library/fonts/archivo-black/archivo-black-latin-400-normal.woff2 +0 -0
  38. package/dist/studio/library/fonts/archivo-black/archivo-black-latin-ext-400-normal.woff2 +0 -0
  39. package/dist/studio/library/fonts/bebas-neue/bebas-neue-latin-400-normal.woff2 +0 -0
  40. package/dist/studio/library/fonts/bebas-neue/bebas-neue-latin-ext-400-normal.woff2 +0 -0
  41. package/dist/studio/library/fonts/caveat/caveat-latin-400-normal.woff2 +0 -0
  42. package/dist/studio/library/fonts/caveat/caveat-latin-700-normal.woff2 +0 -0
  43. package/dist/studio/library/fonts/caveat/caveat-latin-ext-400-normal.woff2 +0 -0
  44. package/dist/studio/library/fonts/caveat/caveat-latin-ext-700-normal.woff2 +0 -0
  45. package/dist/studio/library/fonts/dm-serif/dm-serif-display-latin-400-normal.woff2 +0 -0
  46. package/dist/studio/library/fonts/dm-serif/dm-serif-display-latin-ext-400-normal.woff2 +0 -0
  47. package/dist/studio/library/fonts/inter/inter-latin-400-normal.woff2 +0 -0
  48. package/dist/studio/library/fonts/inter/inter-latin-600-normal.woff2 +0 -0
  49. package/dist/studio/library/fonts/inter/inter-latin-700-normal.woff2 +0 -0
  50. package/dist/studio/library/fonts/inter/inter-latin-800-normal.woff2 +0 -0
  51. package/dist/studio/library/fonts/inter/inter-latin-ext-400-normal.woff2 +0 -0
  52. package/dist/studio/library/fonts/inter/inter-latin-ext-600-normal.woff2 +0 -0
  53. package/dist/studio/library/fonts/inter/inter-latin-ext-700-normal.woff2 +0 -0
  54. package/dist/studio/library/fonts/inter/inter-latin-ext-800-normal.woff2 +0 -0
  55. package/dist/studio/library/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
  56. package/dist/studio/library/fonts/jetbrains-mono/jetbrains-mono-latin-700-normal.woff2 +0 -0
  57. package/dist/studio/library/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
  58. package/dist/studio/library/fonts/jetbrains-mono/jetbrains-mono-latin-ext-700-normal.woff2 +0 -0
  59. package/dist/studio/library/fonts/lobster/lobster-latin-400-normal.woff2 +0 -0
  60. package/dist/studio/library/fonts/lobster/lobster-latin-ext-400-normal.woff2 +0 -0
  61. package/dist/studio/library/fonts/montserrat/montserrat-latin-400-normal.woff2 +0 -0
  62. package/dist/studio/library/fonts/montserrat/montserrat-latin-700-normal.woff2 +0 -0
  63. package/dist/studio/library/fonts/montserrat/montserrat-latin-800-normal.woff2 +0 -0
  64. package/dist/studio/library/fonts/montserrat/montserrat-latin-ext-400-normal.woff2 +0 -0
  65. package/dist/studio/library/fonts/montserrat/montserrat-latin-ext-700-normal.woff2 +0 -0
  66. package/dist/studio/library/fonts/montserrat/montserrat-latin-ext-800-normal.woff2 +0 -0
  67. package/dist/studio/library/fonts/oswald/oswald-latin-400-normal.woff2 +0 -0
  68. package/dist/studio/library/fonts/oswald/oswald-latin-600-normal.woff2 +0 -0
  69. package/dist/studio/library/fonts/oswald/oswald-latin-ext-400-normal.woff2 +0 -0
  70. package/dist/studio/library/fonts/oswald/oswald-latin-ext-600-normal.woff2 +0 -0
  71. package/dist/studio/library/fonts/pacifico/pacifico-latin-400-normal.woff2 +0 -0
  72. package/dist/studio/library/fonts/pacifico/pacifico-latin-ext-400-normal.woff2 +0 -0
  73. package/dist/studio/library/fonts/playfair/playfair-display-latin-400-italic.woff2 +0 -0
  74. package/dist/studio/library/fonts/playfair/playfair-display-latin-400-normal.woff2 +0 -0
  75. package/dist/studio/library/fonts/playfair/playfair-display-latin-700-normal.woff2 +0 -0
  76. package/dist/studio/library/fonts/playfair/playfair-display-latin-ext-400-italic.woff2 +0 -0
  77. package/dist/studio/library/fonts/playfair/playfair-display-latin-ext-400-normal.woff2 +0 -0
  78. package/dist/studio/library/fonts/playfair/playfair-display-latin-ext-700-normal.woff2 +0 -0
  79. package/dist/studio/library/fonts/poppins/poppins-latin-400-normal.woff2 +0 -0
  80. package/dist/studio/library/fonts/poppins/poppins-latin-600-normal.woff2 +0 -0
  81. package/dist/studio/library/fonts/poppins/poppins-latin-700-normal.woff2 +0 -0
  82. package/dist/studio/library/fonts/poppins/poppins-latin-ext-400-normal.woff2 +0 -0
  83. package/dist/studio/library/fonts/poppins/poppins-latin-ext-600-normal.woff2 +0 -0
  84. package/dist/studio/library/fonts/poppins/poppins-latin-ext-700-normal.woff2 +0 -0
  85. package/dist/studio/library/fonts/roboto-slab/LICENSE.txt +202 -0
  86. package/dist/studio/library/fonts/roboto-slab/roboto-slab-latin-400-normal.woff2 +0 -0
  87. package/dist/studio/library/fonts/roboto-slab/roboto-slab-latin-700-normal.woff2 +0 -0
  88. package/dist/studio/library/fonts/roboto-slab/roboto-slab-latin-ext-400-normal.woff2 +0 -0
  89. package/dist/studio/library/fonts/roboto-slab/roboto-slab-latin-ext-700-normal.woff2 +0 -0
  90. package/dist/studio/library/fonts/space-grotesk/space-grotesk-latin-500-normal.woff2 +0 -0
  91. package/dist/studio/library/fonts/space-grotesk/space-grotesk-latin-700-normal.woff2 +0 -0
  92. package/dist/studio/library/fonts/space-grotesk/space-grotesk-latin-ext-500-normal.woff2 +0 -0
  93. package/dist/studio/library/fonts/space-grotesk/space-grotesk-latin-ext-700-normal.woff2 +0 -0
  94. package/dist/studio/library/images/city.jpg +0 -0
  95. package/dist/studio/library/images/food.jpg +0 -0
  96. package/dist/studio/library/images/landscape.jpg +0 -0
  97. package/dist/studio/library/images/pet.jpg +0 -0
  98. package/dist/studio/library/images/portrait.jpg +0 -0
  99. package/dist/studio/library/images/product.jpg +0 -0
  100. package/dist/studio/library/index.json +752 -0
  101. package/dist/studio/templates/avatar-pro/assets/masks/photo-cutout.png +0 -0
  102. package/dist/studio/templates/avatar-pro/photo.json +13 -0
  103. package/dist/studio/templates/avatar-pro/preview.jpg +0 -0
  104. package/dist/studio/templates/avatar-pro/template.json +1 -0
  105. package/dist/studio/templates/index.json +1 -0
  106. package/dist/studio/templates/og-article/photo.json +13 -0
  107. package/dist/studio/templates/og-article/preview.jpg +0 -0
  108. package/dist/studio/templates/og-article/template.json +1 -0
  109. package/dist/studio/templates/polaroid/photo.json +13 -0
  110. package/dist/studio/templates/polaroid/preview.jpg +0 -0
  111. package/dist/studio/templates/polaroid/template.json +1 -0
  112. package/dist/studio/templates/product-white/assets/masks/photo-cutout.png +0 -0
  113. package/dist/studio/templates/product-white/photo.json +72 -0
  114. package/dist/studio/templates/product-white/preview.jpg +0 -0
  115. package/dist/studio/templates/product-white/template.json +1 -0
  116. package/dist/studio/templates/sale-banner/photo.json +125 -0
  117. package/dist/studio/templates/sale-banner/preview.jpg +0 -0
  118. package/dist/studio/templates/sale-banner/template.json +1 -0
  119. package/dist/studio/templates/social-quote/photo.json +13 -0
  120. package/dist/studio/templates/social-quote/preview.jpg +0 -0
  121. package/dist/studio/templates/social-quote/template.json +1 -0
  122. package/dist/studio/templates/story-promo/photo.json +13 -0
  123. package/dist/studio/templates/story-promo/preview.jpg +0 -0
  124. package/dist/studio/templates/story-promo/template.json +1 -0
  125. package/dist/studio/templates/youtube-thumbnail/photo.json +12 -0
  126. package/dist/studio/templates/youtube-thumbnail/preview.jpg +0 -0
  127. package/dist/studio/templates/youtube-thumbnail/template.json +1 -0
  128. package/library/LICENSES.md +57 -0
  129. package/library/fonts/OFL.txt +90 -0
  130. package/library/fonts/anton/anton-latin-400-normal.woff2 +0 -0
  131. package/library/fonts/anton/anton-latin-ext-400-normal.woff2 +0 -0
  132. package/library/fonts/archivo-black/archivo-black-latin-400-normal.woff2 +0 -0
  133. package/library/fonts/archivo-black/archivo-black-latin-ext-400-normal.woff2 +0 -0
  134. package/library/fonts/bebas-neue/bebas-neue-latin-400-normal.woff2 +0 -0
  135. package/library/fonts/bebas-neue/bebas-neue-latin-ext-400-normal.woff2 +0 -0
  136. package/library/fonts/caveat/caveat-latin-400-normal.woff2 +0 -0
  137. package/library/fonts/caveat/caveat-latin-700-normal.woff2 +0 -0
  138. package/library/fonts/caveat/caveat-latin-ext-400-normal.woff2 +0 -0
  139. package/library/fonts/caveat/caveat-latin-ext-700-normal.woff2 +0 -0
  140. package/library/fonts/dm-serif/dm-serif-display-latin-400-normal.woff2 +0 -0
  141. package/library/fonts/dm-serif/dm-serif-display-latin-ext-400-normal.woff2 +0 -0
  142. package/library/fonts/inter/inter-latin-400-normal.woff2 +0 -0
  143. package/library/fonts/inter/inter-latin-600-normal.woff2 +0 -0
  144. package/library/fonts/inter/inter-latin-700-normal.woff2 +0 -0
  145. package/library/fonts/inter/inter-latin-800-normal.woff2 +0 -0
  146. package/library/fonts/inter/inter-latin-ext-400-normal.woff2 +0 -0
  147. package/library/fonts/inter/inter-latin-ext-600-normal.woff2 +0 -0
  148. package/library/fonts/inter/inter-latin-ext-700-normal.woff2 +0 -0
  149. package/library/fonts/inter/inter-latin-ext-800-normal.woff2 +0 -0
  150. package/library/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
  151. package/library/fonts/jetbrains-mono/jetbrains-mono-latin-700-normal.woff2 +0 -0
  152. package/library/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
  153. package/library/fonts/jetbrains-mono/jetbrains-mono-latin-ext-700-normal.woff2 +0 -0
  154. package/library/fonts/lobster/lobster-latin-400-normal.woff2 +0 -0
  155. package/library/fonts/lobster/lobster-latin-ext-400-normal.woff2 +0 -0
  156. package/library/fonts/montserrat/montserrat-latin-400-normal.woff2 +0 -0
  157. package/library/fonts/montserrat/montserrat-latin-700-normal.woff2 +0 -0
  158. package/library/fonts/montserrat/montserrat-latin-800-normal.woff2 +0 -0
  159. package/library/fonts/montserrat/montserrat-latin-ext-400-normal.woff2 +0 -0
  160. package/library/fonts/montserrat/montserrat-latin-ext-700-normal.woff2 +0 -0
  161. package/library/fonts/montserrat/montserrat-latin-ext-800-normal.woff2 +0 -0
  162. package/library/fonts/oswald/oswald-latin-400-normal.woff2 +0 -0
  163. package/library/fonts/oswald/oswald-latin-600-normal.woff2 +0 -0
  164. package/library/fonts/oswald/oswald-latin-ext-400-normal.woff2 +0 -0
  165. package/library/fonts/oswald/oswald-latin-ext-600-normal.woff2 +0 -0
  166. package/library/fonts/pacifico/pacifico-latin-400-normal.woff2 +0 -0
  167. package/library/fonts/pacifico/pacifico-latin-ext-400-normal.woff2 +0 -0
  168. package/library/fonts/playfair/playfair-display-latin-400-italic.woff2 +0 -0
  169. package/library/fonts/playfair/playfair-display-latin-400-normal.woff2 +0 -0
  170. package/library/fonts/playfair/playfair-display-latin-700-normal.woff2 +0 -0
  171. package/library/fonts/playfair/playfair-display-latin-ext-400-italic.woff2 +0 -0
  172. package/library/fonts/playfair/playfair-display-latin-ext-400-normal.woff2 +0 -0
  173. package/library/fonts/playfair/playfair-display-latin-ext-700-normal.woff2 +0 -0
  174. package/library/fonts/poppins/poppins-latin-400-normal.woff2 +0 -0
  175. package/library/fonts/poppins/poppins-latin-600-normal.woff2 +0 -0
  176. package/library/fonts/poppins/poppins-latin-700-normal.woff2 +0 -0
  177. package/library/fonts/poppins/poppins-latin-ext-400-normal.woff2 +0 -0
  178. package/library/fonts/poppins/poppins-latin-ext-600-normal.woff2 +0 -0
  179. package/library/fonts/poppins/poppins-latin-ext-700-normal.woff2 +0 -0
  180. package/library/fonts/roboto-slab/LICENSE.txt +202 -0
  181. package/library/fonts/roboto-slab/roboto-slab-latin-400-normal.woff2 +0 -0
  182. package/library/fonts/roboto-slab/roboto-slab-latin-700-normal.woff2 +0 -0
  183. package/library/fonts/roboto-slab/roboto-slab-latin-ext-400-normal.woff2 +0 -0
  184. package/library/fonts/roboto-slab/roboto-slab-latin-ext-700-normal.woff2 +0 -0
  185. package/library/fonts/space-grotesk/space-grotesk-latin-500-normal.woff2 +0 -0
  186. package/library/fonts/space-grotesk/space-grotesk-latin-700-normal.woff2 +0 -0
  187. package/library/fonts/space-grotesk/space-grotesk-latin-ext-500-normal.woff2 +0 -0
  188. package/library/fonts/space-grotesk/space-grotesk-latin-ext-700-normal.woff2 +0 -0
  189. package/library/images/city.jpg +0 -0
  190. package/library/images/food.jpg +0 -0
  191. package/library/images/landscape.jpg +0 -0
  192. package/library/images/pet.jpg +0 -0
  193. package/library/images/portrait.jpg +0 -0
  194. package/library/images/product.jpg +0 -0
  195. package/library/index.json +752 -0
  196. package/package.json +65 -4
  197. package/plugin/.claude-plugin/plugin.json +19 -0
  198. package/plugin/skills/agentphoto-cutout/SKILL.md +132 -0
  199. package/plugin/skills/agentphoto-design/SKILL.md +104 -0
  200. package/plugin/skills/agentphoto-design/references/layouts.md +60 -0
  201. package/plugin/skills/agentphoto-publish/SKILL.md +79 -0
  202. package/plugin/skills/agentphoto-retouch/SKILL.md +144 -0
  203. package/plugin/skills/agentphoto-retouch/references/filters.md +51 -0
  204. package/plugin/skills/agentphoto-retouch/references/patch-ops.md +66 -0
  205. package/plugin/skills/agentphoto-retouch/references/recipes.md +129 -0
  206. package/templates/avatar-pro/assets/masks/photo-cutout.png +0 -0
  207. package/templates/avatar-pro/photo.json +13 -0
  208. package/templates/avatar-pro/preview.jpg +0 -0
  209. package/templates/avatar-pro/template.json +1 -0
  210. package/templates/og-article/photo.json +13 -0
  211. package/templates/og-article/preview.jpg +0 -0
  212. package/templates/og-article/template.json +1 -0
  213. package/templates/polaroid/photo.json +13 -0
  214. package/templates/polaroid/preview.jpg +0 -0
  215. package/templates/polaroid/template.json +1 -0
  216. package/templates/product-white/assets/masks/photo-cutout.png +0 -0
  217. package/templates/product-white/photo.json +72 -0
  218. package/templates/product-white/preview.jpg +0 -0
  219. package/templates/product-white/template.json +1 -0
  220. package/templates/sale-banner/photo.json +125 -0
  221. package/templates/sale-banner/preview.jpg +0 -0
  222. package/templates/sale-banner/template.json +1 -0
  223. package/templates/social-quote/photo.json +13 -0
  224. package/templates/social-quote/preview.jpg +0 -0
  225. package/templates/social-quote/template.json +1 -0
  226. package/templates/story-promo/photo.json +13 -0
  227. package/templates/story-promo/preview.jpg +0 -0
  228. package/templates/story-promo/template.json +1 -0
  229. package/templates/youtube-thumbnail/photo.json +12 -0
  230. package/templates/youtube-thumbnail/preview.jpg +0 -0
  231. package/templates/youtube-thumbnail/template.json +1 -0
@@ -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,Te=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ee={pending:!1,data:null,method:null,action:null},De=[],Oe=-1;function ke(e){return{current:e}}function Ae(e){0>Oe||(e.current=De[Oe],De[Oe]=null,Oe--)}function je(e,t){Oe++,De[Oe]=e.current,e.current=t}var Me=ke(null),Ne=ke(null),Pe=ke(null),Fe=ke(null);function Ie(e,t){switch(je(Pe,t),je(Ne,e),je(Me,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}}Ae(Me),je(Me,e)}function D(){Ae(Me),Ae(Ne),Ae(Pe)}function O(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,je(Fe,e)),t=Me.current;var n=dp(t,e.type);t!==n&&(je(Ne,e),je(Me,n))}function Le(e){Ne.current===e&&(Ae(Me),Ae(Ne)),Fe.current===e&&(Ae(Fe),sh._currentValue=Ee)}var Re,ze;function Be(e){if(Re===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Re=t&&t[1]||``,ze=-1<e.stack.indexOf(`
2
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
3
+ `+Re+e+ze}var Ve=!1;function He(e,t){if(!e||Ve)return``;Ve=!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{Ve=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Be(n):``}function Ue(e,t){switch(e.tag){case 26:case 27:case 5:return Be(e.type);case 16:return Be(`Lazy`);case 13:return e.child!==t&&t!==null?Be(`Suspense Fallback`):Be(`Suspense`);case 19:return Be(`SuspenseList`);case 0:case 15:return He(e.type,!1);case 11:return He(e.type.render,!1);case 1:return He(e.type,!0);case 31:return Be(`Activity`);case 30:return Be(`ViewTransition`);default:return``}}function We(e){try{var t=``,n=null;do t+=Ue(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
7
+ Error generating stack: `+e.message+`
8
+ `+e.stack}}var Ge=Object.prototype.hasOwnProperty,Ke=t.unstable_scheduleCallback,qe=t.unstable_cancelCallback,Je=t.unstable_shouldYield,Ye=t.unstable_requestPaint,Xe=t.unstable_now,Ze=t.unstable_getCurrentPriorityLevel,Qe=t.unstable_ImmediatePriority,$e=t.unstable_UserBlockingPriority,et=t.unstable_NormalPriority,tt=t.unstable_LowPriority,nt=t.unstable_IdlePriority,rt=t.log,it=t.unstable_setDisableYieldValue,at=null,ot=null;function st(e){if(typeof rt==`function`&&it(e),ot&&typeof ot.setStrictMode==`function`)try{ot.setStrictMode(at,e)}catch{}}var ct=Math.clz32?Math.clz32:dt,lt=Math.log,ut=Math.LN2;function dt(e){return e>>>=0,e===0?32:31-(lt(e)/ut|0)|0}var ft=256,pt=262144,mt=4194304;function ht(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 gt(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=ht(n))):i=ht(o):i=ht(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ht(n))):i=ht(o)):i=ht(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 _t(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function vt(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-ct(n),i=1<<r;t|=e[r],n&=~i}return t}function yt(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 bt(){var e=mt;return mt<<=1,!(mt&62914560)&&(mt=4194304),e}function xt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function St(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ct(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-ct(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&&wt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function wt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-ct(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Tt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ct(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Et(e,t){var n=t&-t;return n=n&42?1:Dt(n),(n&(e.suspendedLanes|t))===0?n:0}function Dt(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 Ot(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function kt(){var e=Te.p;return e===0?(e=window.event,e===void 0?32:Ch(e.type)):e}function At(e,t){var n=Te.p;try{return Te.p=e,t()}finally{Te.p=n}}var jt=Math.random().toString(36).slice(2),Mt=`__reactFiber$`+jt,Nt=`__reactProps$`+jt,Pt=`__reactContainer$`+jt,Ft=`__reactEvents$`+jt,It=`__reactListeners$`+jt,Lt=`__reactHandles$`+jt,Rt=`__reactResources$`+jt,zt=`__reactMarker$`+jt,Bt=`__reactLoad$`+jt;function Vt(e){delete e[Mt],delete e[Nt],delete e[It],delete e[Lt]}function Ht(e){var t;if(t=e[Mt])return t;for(var n=e.parentNode;n;){if(t=n[Pt]||n[Mt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=fm(e);e!==null;){if(n=e[Mt])return n;e=fm(e)}return t}e=n,n=e.parentNode}return null}function Ut(e){if(e=e[Mt]||e[Pt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Wt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Gt(e){var t=e[Rt];return t||=e[Rt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Kt(e){e[zt]=!0}function qt(e){e[Bt]=void 0}var Jt=new Set,Yt={};function Xt(e,t){Zt(e,t),Zt(e+`Capture`,t)}function Zt(e,t){for(Yt[e]=t,e=0;e<t.length;e++)Jt.add(t[e])}var Qt=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]*$`),$t={},en={};function tn(e){return Ge.call(en,e)?!0:Ge.call($t,e)?!1:Qt.test(e)?en[e]=!0:($t[e]=!0,!1)}var nn=!1;function rn(){var e=nn;return nn=!1,e}function an(e,t,n){if(tn(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 on(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 sn(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 cn(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function ln(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function un(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 dn(e){if(!e._valueTracker){var t=ln(e)?`checked`:`value`;e._valueTracker=un(e,t,``+e[t])}}function fn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=ln(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var pn=/[\n"\\]/g;function mn(e){return e.replace(pn,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function hn(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=``+cn(t)):e.value!==``+cn(t)&&(e.value=``+cn(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):_n(e,cn(n)):o===`number`&&e.value==t?_n(e,cn(e.value)):_n(e,cn(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=``+cn(s):e.removeAttribute(`name`)}function gn(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)){dn(e);return}n=n==null?``:``+cn(n),t=t==null?n:``+cn(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),dn(e)}function _n(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function vn(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=``+cn(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 yn(e,t,n){t!=null&&(t=``+cn(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+cn(n)}function bn(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=cn(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),dn(e)}function xn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Sn=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 Cn(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||Sn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function wn(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]=``,nn=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(Cn(e,a,r),nn=!0)}else for(var o in t)t.hasOwnProperty(o)&&Cn(e,o,t[o])}function Tn(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 En=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`]]),Dn=/^[\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 On(e){return Dn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function kn(){}var An=null;function jn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Mn=null,Nn=null;function Pn(e){var t=Ut(e);if(t&&(e=t.stateNode)){var n=e[Nt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(hn(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="`+mn(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Nt]||null;if(!a)throw Error(i(90));hn(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&&fn(r)}break a;case`textarea`:yn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&vn(e,!!n.multiple,t,!1)}}}var Fn=!1;function In(e,t,n){if(Fn)return e(t,n);Fn=!0;try{return e(t)}finally{if(Fn=!1,(Mn!==null||Nn!==null)&&(Ld(),Mn&&(t=Mn,e=Nn,Nn=Mn=null,Pn(t),e)))for(t=0;t<e.length;t++)Pn(e[t])}}function Ln(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Nt]||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 Rn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,zn=!1;if(Rn)try{var Bn={};Object.defineProperty(Bn,"passive",{get:function(){zn=!0}}),window.addEventListener(`test`,Bn,Bn),window.removeEventListener(`test`,Bn,Bn)}catch{zn=!1}var Vn=null,Hn=null,Un=null;function Wn(){if(Un)return Un;var e,t=Hn,n=t.length,r,i=`value`in Vn?Vn.value:Vn.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 Un=i.slice(e,1<r?1-r:void 0)}function Gn(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 Kn(){return!0}function qn(){return!1}function Jn(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)?Kn:qn,this.isPropagationStopped=qn,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=Kn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Kn)},persist:function(){},isPersistent:Kn}),t}var Yn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xn=Jn(Yn),Zn=T({},Yn,{view:0,detail:0}),Qn=Jn(Zn),$n,er,tr,nr=T({},Zn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pr,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!==tr&&(tr&&e.type===`mousemove`?($n=e.screenX-tr.screenX,er=e.screenY-tr.screenY):er=$n=0,tr=e),$n)},movementY:function(e){return`movementY`in e?e.movementY:er}}),rr=Jn(nr),ir=Jn(T({},nr,{dataTransfer:0})),ar=Jn(T({},Zn,{relatedTarget:0})),or=Jn(T({},Yn,{animationName:0,elapsedTime:0,pseudoElement:0})),sr=Jn(T({},Yn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),cr=Jn(T({},Yn,{data:0})),lr={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},ur={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`},dr={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function fr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=dr[e])?!!t[e]:!1}function pr(){return fr}var mr=Jn(T({},Zn,{key:function(e){if(e.key){var t=lr[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Gn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?ur[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pr,charCode:function(e){return e.type===`keypress`?Gn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Gn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),hr=Jn(T({},nr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),gr=Jn(T({},Yn,{submitter:0})),_r=Jn(T({},Zn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pr})),vr=Jn(T({},Yn,{propertyName:0,elapsedTime:0,pseudoElement:0})),yr=Jn(T({},nr,{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})),br=Jn(T({},Yn,{newState:0,oldState:0,source:0})),xr=[9,13,27,32],Sr=Rn&&`CompositionEvent`in window,Cr=null;Rn&&`documentMode`in document&&(Cr=document.documentMode);var wr=Rn&&`TextEvent`in window&&!Cr,Tr=Rn&&(!Sr||Cr&&8<Cr&&11>=Cr),Er=` `,Dr=!1;function Or(e,t){switch(e){case`keyup`:return xr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function kr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var k=!1;function Ar(e,t){switch(e){case`compositionend`:return kr(t);case`keypress`:return t.which===32?(Dr=!0,Er):null;case`textInput`:return e=t.data,e===Er&&Dr?null:e;default:return null}}function jr(e,t){if(k)return e===`compositionend`||!Sr&&Or(e,t)?(e=Wn(),Un=Hn=Vn=null,k=!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 Tr&&t.locale!==`ko`?null:t.data;default:return null}}var Mr={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 Nr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Mr[e.type]:t===`textarea`}function Pr(e,t,n,r){Mn?Nn?Nn.push(r):Nn=[r]:Mn=r,t=qf(t,`onChange`),0<t.length&&(n=new Xn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Fr=null,Ir=null;function Lr(e){Bf(e,0)}function Rr(e){if(fn(Wt(e)))return e}function zr(e,t){if(e===`change`)return t}var Br=!1;if(Rn){var Vr;if(Rn){var A=`oninput`in document;if(!A){var Hr=document.createElement(`div`);Hr.setAttribute(`oninput`,`return;`),A=typeof Hr.oninput==`function`}Vr=A}else Vr=!1;Br=Vr&&(!document.documentMode||9<document.documentMode)}function Ur(){Fr&&(Fr.detachEvent(`onpropertychange`,Wr),Ir=Fr=null)}function Wr(e){if(e.propertyName===`value`&&Rr(Ir)){var t=[];Pr(t,Ir,e,jn(e)),In(Lr,t)}}function Gr(e,t,n){e===`focusin`?(Ur(),Fr=t,Ir=n,Fr.attachEvent(`onpropertychange`,Wr)):e===`focusout`&&Ur()}function Kr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Rr(Ir)}function qr(e,t){if(e===`click`)return Rr(t)}function Jr(e,t){if(e===`input`||e===`change`)return Rr(t)}function Yr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Xr=typeof Object.is==`function`?Object.is:Yr;function Zr(e,t){if(Xr(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(!Ge.call(t,i)||!Xr(e[i],t[i]))return!1}return!0}function Qr(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 $r(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ei(e,t){var n=$r(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=$r(n)}}function ti(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ti(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ni(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Qr(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=Qr(e.document)}return t}function ri(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 ii=Rn&&`documentMode`in document&&11>=document.documentMode,ai=null,oi=null,si=null,ci=!1;function li(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ci||ai==null||ai!==Qr(r)||(r=ai,`selectionStart`in r&&ri(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}),si&&Zr(si,r)||(si=r,r=qf(oi,`onSelect`),0<r.length&&(t=new Xn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=ai)))}function ui(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var di={animationend:ui(`Animation`,`AnimationEnd`),animationiteration:ui(`Animation`,`AnimationIteration`),animationstart:ui(`Animation`,`AnimationStart`),transitionrun:ui(`Transition`,`TransitionRun`),transitionstart:ui(`Transition`,`TransitionStart`),transitioncancel:ui(`Transition`,`TransitionCancel`),transitionend:ui(`Transition`,`TransitionEnd`)},fi={},pi={};Rn&&(pi=document.createElement(`div`).style,`AnimationEvent`in window||(delete di.animationend.animation,delete di.animationiteration.animation,delete di.animationstart.animation),`TransitionEvent`in window||delete di.transitionend.transition);function mi(e){if(fi[e])return fi[e];if(!di[e])return e;var t=di[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in pi)return fi[e]=t[n];return e}var hi=mi(`animationend`),gi=mi(`animationiteration`),_i=mi(`animationstart`),vi=mi(`transitionrun`),yi=mi(`transitionstart`),bi=mi(`transitioncancel`),xi=mi(`transitionend`),Si=new Map,Ci=`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(` `);Ci.push(`scrollEnd`);function wi(e,t){Si.set(e,t),Xt(t,[e])}var Ti=0;function Ei(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=vd.identifierPrefix;var n=Ti++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function Di(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 Oi(e,t){return e=Di(e),t=Di(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var ki=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)},Ai=[],ji=0,Mi=0;function Ni(){for(var e=ji,t=Mi=ji=0;t<e;){var n=Ai[t];Ai[t++]=null;var r=Ai[t];Ai[t++]=null;var i=Ai[t];Ai[t++]=null;var a=Ai[t];if(Ai[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&&Ii(n,i,a)}}function j(e,t,n,r){Ai[ji++]=e,Ai[ji++]=t,Ai[ji++]=n,Ai[ji++]=r,Mi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Pi(e,t,n,r){return j(e,t,n,r),Li(e)}function Fi(e,t){return j(e,null,null,t),Li(e)}function Ii(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-ct(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Li(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 Ri={};function zi(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 Bi(e,t,n,r){return new zi(e,t,n,r)}function Vi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hi(e,t){var n=e.alternate;return n===null?(n=Bi(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 Ui(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 Wi(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Vi(r)&&(s=1);else if(typeof r==`string`)s=qm(e,n,Me.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case he:return e=Bi(31,n,t,a),e.elementType=he,e.lanes=o,e;case ae:return Gi(n.children,a,o,t);case oe:s=8,a|=24;break;case se:return e=Bi(12,n,t,a|2),e.elementType=se,e.lanes=o,e;case de:return e=Bi(13,n,t,a),e.elementType=de,e.lanes=o,e;case fe:return e=Bi(19,n,t,a),e.elementType=fe,e.lanes=o,e;case ge:case ve:return e=a|32,e=Bi(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=Bi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Gi(e,t,n,r){return e=Bi(7,e,r,t),e.lanes=n,e}function Ki(e,t,n){return e=Bi(6,e,null,t),e.lanes=n,e}function qi(e){var t=Bi(18,null,null,0);return t.stateNode=e,t}function Ji(e,t,n){return t=Bi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Yi=new WeakMap;function Xi(e,t){if(typeof e==`object`&&e){var n=Yi.get(e);return n===void 0?(t={value:e,source:t,stack:We(t)},Yi.set(e,t),t):n}return{value:e,source:t,stack:We(t)}}var Zi=[],Qi=0,$i=null,ea=0,ta=[],na=0,ra=null,ia=1,aa=``;function oa(e,t){Zi[Qi++]=ea,Zi[Qi++]=$i,$i=e,ea=t}function sa(e,t,n){ta[na++]=ia,ta[na++]=aa,ta[na++]=ra,ra=e;var r=ia;e=aa;var i=32-ct(r)-1;r&=~(1<<i),n+=1;var a=32-ct(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ia=1<<32-ct(t)+i|n<<i|r,aa=a+e}else ia=1<<a|n<<i|r,aa=e}function ca(e){e.return!==null&&(oa(e,1),sa(e,1,0))}function la(e){for(;e===$i;)$i=Zi[--Qi],Zi[Qi]=null,ea=Zi[--Qi],Zi[Qi]=null;for(;e===ra;)ra=ta[--na],ta[na]=null,aa=ta[--na],ta[na]=null,ia=ta[--na],ta[na]=null}function ua(e,t){ta[na++]=ia,ta[na++]=aa,ta[na++]=ra,ia=t.id,aa=t.overflow,ra=e}var da=null,M=null,N=!1,fa=null,pa=!1,ma=Error(i(519));function ha(e){throw xa(Xi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),ma}function ga(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Mt]=e,t[Nt]=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),gn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:$(`invalid`,t);break;case`textarea`:$(`invalid`,t),bn(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=kn),t=!0):t=!1,t||ha(e,!0)}function _a(e){for(da=e.return;da;)switch(da.tag){case 5:case 31:case 13:pa=!1;return;case 27:case 3:pa=!0;return;default:da=da.return}}function va(e){if(e!==da)return!1;if(!N)return _a(e),N=!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&&M&&ha(e),_a(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));M=dm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));M=dm(e)}else t===27?(t=M,Sp(e.type)?(e=um,um=null,M=e):M=t):M=da?lm(e.stateNode.nextSibling):null;return!0}function ya(){M=da=null,N=!1}function ba(){var e=fa;return e!==null&&(ud===null?ud=e:ud.push.apply(ud,e),fa=null),e}function xa(e){fa===null?fa=[e]:fa.push(e)}var Sa=ke(null),Ca=null,wa=null;function Ta(e,t,n){je(Sa,t._currentValue),t._currentValue=n}function Ea(e){e._currentValue=Sa.current,Ae(Sa)}function Da(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 Oa(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),Da(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),Da(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),Da(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 ka(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;Xr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Fe.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&&Oa(t,e,n,r),t.flags|=262144,e!==null}function Aa(e){for(e=e.firstContext;e!==null;){if(!Xr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ja(e){Ca=e,wa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ma(e){return Pa(Ca,e)}function Na(e,t){return Ca===null&&ja(e),Pa(e,t)}function Pa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},wa===null){if(e===null)throw Error(i(308));wa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wa=wa.next=t;return n}var Fa=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()})}},Ia=t.unstable_scheduleCallback,La=t.unstable_NormalPriority,Ra={$$typeof:le,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function za(){return{controller:new Fa,data:new Map,refCount:0}}function Ba(e){e.refCount--,e.refCount===0&&Ia(La,function(){e.controller.abort()})}function Va(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 Ha=null;function Ua(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Wa=null,Ga=0,Ka=0,qa=null;function Ja(e,t){if(Wa===null){var n=Wa=[];Ga=0,Ka=Nf(),qa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ga++,t.then(Ya,Ya),t}function Ya(){if(--Ga===0&&(Ha=null,Wa!==null)){qa!==null&&(qa.status=`fulfilled`);var e=Wa;Wa=null,Ka=0,qa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Xa(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 Za=E.S;E.S=function(e,t){if(pd=Xe(),typeof t==`object`&&t&&typeof t.then==`function`&&Ja(e,t),Ha!==null)for(var n=yf;n!==null;)Va(n,Ha),n=n.next;if(n=e.types,n!==null){for(var r=yf;r!==null;)Va(r,n),r=r.next;if(Ka!==0){r=Ha,r===null&&(r=Ha=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Za!==null&&Za(e,t)};var Qa=ke(null);function $a(){var e=Qa.current;return e===null?Xu.pooledCache:e}function eo(e,t){t===null?je(Qa,Qa.current):je(Qa,t.pool)}function to(){var e=$a();return e===null?null:{parent:Ra._currentValue,pool:e}}var no=Error(i(460)),ro=Error(i(474)),io=Error(i(542)),ao={then:function(){}};function oo(e){return e=e.status,e===`fulfilled`||e===`rejected`}function so(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(kn,kn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,fo(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(kn,kn);else{if(e=Xu,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,fo(e),e}throw lo=t,no}}function co(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(lo=e,no):e}}var lo=null;function uo(){if(lo===null)throw Error(i(459));var e=lo;return lo=null,e}function fo(e){if(e===no||e===io)throw Error(i(483))}var po=null,mo=0;function P(e){var t=mo;return mo+=1,po===null&&(po=[]),so(po,e,t)}function ho(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function go(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 _o(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=Hi(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=Ki(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),ho(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===me&&co(i)===t.type)?(t=a(t,n.props),ho(t,n),t.return=e,t):(t=Wi(n.type,n.key,n.props,null,e.mode,r),ho(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=Ji(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=Gi(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=Ki(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case re:return n=Wi(t.type,t.key,t.props,null,e.mode,n),ho(n,t),n.return=e,n;case ie:return t=Ji(t,e.mode,n),t.return=e,t;case me:return t=co(t),f(e,t,n)}if(we(t)||xe(t))return t=Gi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,P(t),n);if(t.$$typeof===le)return f(e,Na(e,t),n);go(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=co(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,P(n),r);if(n.$$typeof===le)return p(e,t,Na(e,n),r);go(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=co(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,P(r),i);if(r.$$typeof===le)return m(e,t,n,Na(t,r),i);go(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),N&&oa(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 N&&oa(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)}),N&&oa(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),N&&oa(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 N&&oa(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)}),N&&oa(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),ho(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===me&&co(l)===r.type){n(e,r.sibling),c=a(r,o.props),ho(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===ae?(c=Gi(o.props.children,e.mode,c,o.key),ho(c,o),c.return=e,e=c):(c=Wi(o.type,o.key,o.props,null,e.mode,c),ho(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=Ji(o,e.mode,c),c.return=e,e=c}return s(e);case me:return o=co(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,P(o),c);if(o.$$typeof===le)return _(e,r,Na(e,o),c);go(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=Ki(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{mo=0;var i=_(e,t,n,r);return po=null,i}catch(t){if(t===no||t===io)throw t;var a=Bi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var vo=_o(!0),yo=_o(!1),bo=!1;function xo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function So(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 Co(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function wo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,X&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Li(e),Ii(e,null,n),t}return j(e,r,t,n),Li(e)}function To(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,Tt(e,n)}}function Eo(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 Do=!1;function Oo(){if(Do){var e=qa;if(e!==null)throw e}}function ko(e,t,n,r){Do=!1;var i=e.updateQueue;bo=!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?(Q&f)===f:(r&f)===f){f!==0&&f===Ka&&(Do=!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:bo=!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),id|=o,e.lanes=o,e.memoizedState=d}}function Ao(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function jo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ao(n[e],t)}var Mo=ke(null),No=ke(0);function Po(e,t){e=nd,je(No,e),je(Mo,t),nd=e|t.baseLanes}function Fo(){je(No,nd),je(Mo,Mo.current)}function Io(){nd=No.current,Ae(Mo),Ae(No)}var Lo=ke(null),Ro=null;function zo(e){var t=e.alternate;je(Uo,Uo.current&1),je(Lo,e),Ro===null&&(t===null||Mo.current!==null||t.memoizedState!==null)&&(Ro=e)}function Bo(e){je(Uo,Uo.current),je(Lo,e),Ro===null&&(Ro=e)}function Vo(e){e.tag===22?(je(Uo,Uo.current),je(Lo,e),Ro===null&&(Ro=e)):F()}function F(){je(Uo,Uo.current),je(Lo,Lo.current)}function Ho(e){Ae(Lo),Ro===e&&(Ro=null),Ae(Uo)}var Uo=ke(0);function Wo(e,t){je(Lo,Lo.current),je(Uo,t)}function Go(e){Ae(Uo),Ae(Lo),Ro===e&&(Ro=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,L=null,ts=0;function ns(){throw Error(i(321))}function rs(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Xr(e[n],t[n]))return!1;return!0}function is(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?yc:bc,Qo=!1,a=n(r,i),Qo=!1,Zo&&(a=os(t,n,r,i)),as(e),a}function as(e){E.H=z;var t=Jo!==null&&Jo.next!==null;if(qo=0,Yo=Jo=I=null,Xo=!1,es=0,L=null,t)throw Error(i(300));e===null||Lc||(e=e.dependencies,e!==null&&Aa(e)&&(Lc=!0))}function os(e,t,n,r){I=e;var a=0;do{if(Zo&&(L=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=xc,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,L=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,L===null&&(L=[]),e=so(L,e,t),t=I,(Yo===null?t.memoizedState:Yo.next)===null&&(t=t.alternate,E.H=t===null||t.memoizedState===null?yc:bc),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 Ma(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:(Q&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===Ka&&(d=!0);else if((qo&p)===p){u=u.next,p===Ka&&(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,id|=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,id|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Xr(o,e.memoizedState)&&(Lc=!0,d&&(n=qa,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);Xr(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=N;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Xr((Jo||a).memoizedState,n);if(s&&(a.memoizedState=n,Lc=!0),a=a.queue,R(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,Xu===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!Xr(e,n)}catch{return!0}}function Es(e){var t=Fi(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){st(!0);try{n()}finally{st(!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(N){var n=Xu.formState;if(n!==null){a:{var r=I;if(N){if(M){b:{for(var i=M,a=pa;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){M=lm(i.nextSibling),r=i.data===`F!`;break a}}ha(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===no?io: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&&rs(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 R(e,t){Ws(2048,8,e,t)}function Ks(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 qs(e){var t=fs().memoizedState;return Ks({ref:t,nextImpl:e}),function(){if(X&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Js(e,t){return Ws(4,2,e,t)}function Ys(e,t){return Ws(4,4,e,t)}function Xs(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 Zs(e,t,n){n=n==null?null:n.concat([e]),Ws(4,4,Xs.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&&rs(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&&rs(t,r[1]))return r[0];if(r=e(),Qo){st(!0);try{e()}finally{st(!1)}}return n.memoizedState=[r,t],r}function tc(e,t,n){return n===void 0||qo&1073741824&&!(Q&261930)?e.memoizedState=t:(e.memoizedState=n,e=Ad(),I.lanes|=e,id|=e,n)}function nc(e,t,n,r){return Xr(n,t)?n:Mo.current===null?!(qo&106)||qo&1073741824&&!(Q&261930)?(Lc=!0,e.memoizedState=n):(e=Ad(),I.lanes|=e,id|=e,t):(e=tc(e,n,r),Xr(e,t)||(Lc=!0),e)}function rc(e,t,n,r,i){var a=Te.p;Te.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,Xa(c,r),kd(e)):mc(e,t,r,kd(e))}catch(n){mc(e,t,{then:function(){},status:`rejected`,reason:n},kd())}finally{Te.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,Ee,n===null?ic:function(){return sc(e),n(r)})}function oc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Ee,baseState:Ee,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:Ee},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 Ma(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=Co(n);var r=wo(t,e,n);r!==null&&(Md(r,t,n),To(r,t,n)),t={cache:za()},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=Pi(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,Xr(s,o))return j(e,t,i,0),Xu===null&&Ni(),!1}catch{}if(n=Pi(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=Pi(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,Tt(e,n)}}var z={readContext:Ma,use:hs,useCallback:ns,useContext:ns,useEffect:ns,useImperativeHandle:ns,useLayoutEffect:ns,useInsertionEffect:ns,useMemo:ns,useReducer:ns,useRef:ns,useState:ns,useDebugValue:ns,useDeferredValue:ns,useTransition:ns,useSyncExternalStore:ns,useId:ns,useHostTransitionStatus:ns,useFormState:ns,useActionState:ns,useOptimistic:ns,useMemoCache:ns,useCacheRefresh:ns,useEffectEvent:ns},yc={readContext:Ma,use:hs,useCallback:function(e,t){return ds().memoizedState=[e,t===void 0?null:t],e},useContext:Ma,useEffect:Gs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Us(4194308,4,Xs.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){st(!0);try{e()}finally{st(!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){st(!0);try{n(t)}finally{st(!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(N){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Xu===null)throw Error(i(349));Q&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=Xu.identifierPrefix;if(N){var n=aa,r=ia;n=(r&~(1<<32-ct(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=$o++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=ts++,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(X&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},bc={readContext:Ma,use:hs,useCallback:$s,useContext:Ma,useEffect:R,useImperativeHandle:Zs,useInsertionEffect:Js,useLayoutEffect:Ys,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:qs},xc={readContext:Ma,use:hs,useCallback:$s,useContext:Ma,useEffect:R,useImperativeHandle:Zs,useInsertionEffect:Js,useLayoutEffect:Ys,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:qs};function Sc(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 Cc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=kd(),i=Co(r);i.payload=t,n!=null&&(i.callback=n),t=wo(e,i,r),t!==null&&(Md(t,e,r),To(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=kd(),i=Co(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=wo(e,i,r),t!==null&&(Md(t,e,r),To(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=kd(),r=Co(n);r.tag=2,t!=null&&(r.callback=t),t=wo(e,r,n),t!==null&&(Md(t,e,n),To(t,e,n))}};function wc(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?!Zr(n,r)||!Zr(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&&Cc.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){ki(e)}function Oc(e){console.error(e)}function kc(e){ki(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=Co(n),n.tag=3,n.payload={element:null},n.callback=function(){Ac(e,t)},n}function Nc(e){return e=Co(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&&ka(t,n,a,!0),n=Lo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Ro===null?Wd():n.alternate===null&&rd===0&&(rd=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ao?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===ao?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(N)return t=Lo.current,t===null?(r!==ma&&(t=Error(i(423),{cause:r}),xa(Xi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Xi(r,n),a=Mc(e.stateNode,r,a),Eo(e,a),rd!==4&&(rd=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==ma&&(e=Error(i(422),{cause:r}),xa(Xi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Xi(o,n),ld===null?ld=[o]:ld.push(o),rd!==4&&(rd=2),t===null)return!0;r=Xi(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),Eo(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),Eo(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?yo(t,null,n,r):vo(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 ja(t),r=is(e,t,n,o,a,i),s=cs(),e!==null&&!Lc?(ls(e,t,i),fl(e,t,i)):(N&&s&&ca(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`&&!Vi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Vc(e,t,a,r,i)):(e=Wi(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?Zr:n,n(o,r)&&e.ref===t.ref)return fl(e,t,i)}return t.flags|=1,e=Hi(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(Zr(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 B(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 Uc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&eo(t,a===null?null:a.cachePool),a===null?Fo():Po(t,a),Vo(t);else return r=t.lanes=536870912,Uc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&eo(t,null),Fo(),F()):(eo(t,a.cachePool),Po(t,a),F(),t.memoizedState=null);return Rc(e,t,i,n),t.child}function Hc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Uc(e,t,n,r,i){var a=$a();return a=a===null?null:{parent:Ra._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&eo(t,null),Fo(),Vo(t),e!==null&&ka(e,t,r,!0),t.childLanes=i,null}function Wc(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 Gc(e,t,n){return vo(t,e.child,null,n),e=Wc(t,t.pendingProps),e.flags|=2,Ho(t),t.memoizedState=null,e}function Kc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(N){if(r.mode===`hidden`)return e=Wc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Hc(null,e);if(Bo(t),(e=M)?(e=am(e,pa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ra===null?null:{id:ia,overflow:aa},retryLane:536870912,hydrationErrors:null},n=qi(e),n.return=t,t.child=n,da=t,M=null)):e=null,e===null)throw ha(t);return t.lanes=536870912,null}return Wc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Bo(t),a){if(t.flags&256)t.flags&=-257,t=Gc(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||ka(e,t,n,!1),a=(n&e.childLanes)!==0,Lc||a){if(Mo.current===null){if(r=Xu,r!==null&&(s=Et(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Fi(e,s),Md(r,e,s),Ic;Wd()}t=Gc(e,t,n)}else e=o.treeContext,M=lm(s.nextSibling),da=t,N=!0,fa=null,pa=!1,e!==null&&ua(t,e),t=Wc(t,r),t.flags|=134221824;return t}return e=Hi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function qc(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 ja(t),n=is(e,t,n,r,void 0,i),r=cs(),e!==null&&!Lc?(ls(e,t,i),fl(e,t,i)):(N&&r&&ca(t),t.flags|=1,Rc(e,t,n,i),t.child)}function Yc(e,t,n,r,i,a){return ja(t),t.updateQueue=null,n=os(t,r,n,i),as(e),r=cs(),e!==null&&!Lc?(ls(e,t,a),fl(e,t,a)):(N&&r&&ca(t),t.flags|=1,Rc(e,t,n,a),t.child)}function Xc(e,t,n,r,i){if(ja(t),t.stateNode===null){var a=Ri,o=n.contextType;typeof o==`object`&&o&&(a=Ma(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Cc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},xo(t),o=n.contextType,a.context=typeof o==`object`&&o?Ma(o):Ri,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Sc(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&&Cc.enqueueReplaceState(a,a.state,null),ko(t,r,a,i),Oo(),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=Ri,typeof u==`object`&&u&&(o=Ma(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),bo=!1;var f=t.memoizedState;a.state=f,ko(t,r,a,i),Oo(),l=t.memoizedState,s||f!==l||bo?(typeof d==`function`&&(Sc(t,n,d,r),l=t.memoizedState),(c=bo||wc(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,So(e,t),o=t.memoizedProps,u=Ec(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Ri,typeof l==`object`&&l&&(c=Ma(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),bo=!1,f=t.memoizedState,a.state=f,ko(t,r,a,i),Oo();var p=t.memoizedState;o!==d||f!==p||bo||e!==null&&e.dependencies!==null&&Aa(e.dependencies)?(typeof s==`function`&&(Sc(t,n,s,r),p=t.memoizedState),(u=bo||wc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Aa(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,qc(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=vo(t,e.child,null,i),t.child=vo(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 ya(),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:to()}}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(N){if(i?zo(t):F(),(e=M)?(e=am(e,pa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ra===null?null:{id:ia,overflow:aa},retryLane:536870912,hydrationErrors:null},n=qi(e),n.return=t,t.child=n,da=t,M=null)):e=null,e===null)throw ha(t);return t.lanes=sm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(F(),i=t.mode,a=rl({mode:`hidden`,children:a},i),r=Gi(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,Hc(null,r)):(zo(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?(F(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Hi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Gi(i,a,n,null),i.flags|=2):i=Hi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Hc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=$c(n):(a=i.cachePool,a===null?a=to():(s=Ra._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,Hc(e.child,r)):(zo(t),n=e.child,e=n.sibling,n=Hi(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=Bi(22,e,null,t),e.lanes=0,e}function il(e,t,n){return vo(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?(zo(t),t.flags&=-257,il(e,t,c)):t.memoizedState===null?(F(),o=a.fallback,s=t.mode,a=rl({mode:`visible`,children:a.children},s),o=Gi(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,vo(t,e.child,null,c),a=t.child,a.memoizedState=$c(c),a.childLanes=el(e,r,c),t.memoizedState=Qc,Hc(null,a)):(F(),t.child=e.child,t.flags|=128,null);if(zo(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,xa({value:a,source:null,stack:null})),il(e,t,c)}if(Lc||ka(e,t,c,!1),r=(c&e.childLanes)!==0,Lc||r){if(Mo.current!==null)return il(e,t,c);if(r=Xu,r!==null&&(a=Et(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,Fi(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,M=lm(o.nextSibling),da=t,N=!0,fa=null,pa=!1,e!==null&&ua(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),Da(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=N?ea: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 Ta(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),id|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(ka(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=Hi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Hi(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&&Aa(e)))}function ml(e,t,n){switch(t.tag){case 3:Ie(t,t.stateNode.containerInfo),Ta(t,Ra,e.memoizedState.cache),ya();break;case 27:case 5:O(t);break;case 4:Ie(t,t.stateNode.containerInfo);break;case 10:Ta(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Bo(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return zo(t),t.flags|=128,null;r=ka(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?tl(e,t,n):(zo(t),e=fl(e,t,n),e===null?null:e.sibling)}zo(t);break;case 19:if(t.flags&128)return ul(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(ka(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,B(e,t,n,t.pendingProps);case 24:Ta(t,Ra,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,N&&t.flags&1048576&&sa(t,ea,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=co(t.elementType),t.type=e,typeof e==`function`)Vi(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(Ie(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,So(e,t),ko(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ta(t,Ra,r),r!==o.cache&&Oa(t,[Ra],n,!0),Oo(),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=Xi(Error(i(424)),t),xa(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(M=lm(e.firstChild),da=t,N=!0,fa=null,pa=!0,n=yo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(ya(),r===a){t=fl(e,t,n);break a}Rc(e,t,r,n)}t=t.child}return t;case 26:return qc(e,t),e===null?(n=Nm(t.type,null,t.pendingProps,null))?t.memoizedState=n:N||(t.stateNode=fp(t.type,t.pendingProps,Pe.current,t)):t.memoizedState=Nm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return O(t),e===null&&N&&(r=t.stateNode=hm(t.type,t.pendingProps,Pe.current),da=t,pa=!0,a=M,Sp(t.type)?(um=a,M=lm(r.firstChild)):M=a),Rc(e,t,t.pendingProps.children,n),qc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&N&&((a=r=M)&&(r=rm(r,t.type,t.pendingProps,pa),r===null?a=!1:(t.stateNode=r,da=t,M=lm(r.firstChild),pa=!1,a=!0)),a||ha(t)),O(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=is(e,t,ss,null,null,n),sh._currentValue=a),qc(e,t),Rc(e,t,r,n),t.child;case 6:return e===null&&N&&((e=n=M)&&(n=im(n,t.pendingProps,pa),n===null?e=!1:(t.stateNode=n,da=t,M=null,e=!0)),e||ha(t)),null;case 13:return tl(e,t,n);case 4:return Ie(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=vo(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,qc(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,ja(t),a=Ma(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 Kc(e,t,n);case 22:return B(e,t,n,t.pendingProps);case 24:return ja(t),r=Ma(Ra),e===null?(a=$a(),a===null&&(a=Xu,o=za(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},xo(t),Ta(t,Ra,a)):((e.lanes&n)!==0&&(So(e,t),ko(t,null,null,n),Oo()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ta(t,Ra,r),r!==a.cache&&Oa(t,[Ra],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ta(t,Ra,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:N&&ca(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:qc(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 lo=ao,ro}}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 lo=ao,ro}}function yl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:bt(),e.lanes|=t,cd|=t)}function bl(e,t){if(!N)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(la(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),Ea(Ra),D(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(va(t)?gl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ba())),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(Le(t),n=Pe.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=Me.current,va(t)?ga(t,e):(e=hm(a,r,n),t.stateNode=e,gl(t))}return xl(t),t.subtreeFlags&=-33554433,null;case 5:if(Le(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=Me.current,va(t))ga(t,o);else{var s=lp(Pe.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[Mt]=t,o[Nt]=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=Pe.current,va(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=da,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Mt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||ha(t,!0)}else e=lp(e).createTextNode(r),e[Mt]=t,t.stateNode=e}return xl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=va(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[Mt]=t}else ya(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;xl(t),e=!1}else n=ba(),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=va(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[Mt]=t}else ya(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;xl(t),a=!1}else a=ba(),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 D(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,xl(t),null;case 10:return Ea(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(rd!==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;)Ui(n,e),n=n.sibling;return Wo(t,Uo.current&1|2),N&&oa(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Xe()>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&&!N)return xl(t),null}else 2*Xe()-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=Xe(),e.sibling=null,o=Uo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||N?Wo(t,o):(n=o,je(Lo,t),je(Uo,n),Ro===null&&(Ro=t)),N&&oa(t,r.treeForkCount),e}return xl(t),null;case 22:case 23:return Ho(t),Io(),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&&Ae(Qa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ea(Ra),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(la(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ea(Ra),D(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Le(t),null;case 31:if(t.memoizedState!==null){if(Ho(t),t.alternate===null)throw Error(i(340));ya()}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));ya()}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 D(),null;case 10:return Ea(t.type),null;case 22:case 23:return Ho(t),Io(),e!==null&&Ae(Qa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ea(Ra),null;case 25:return null;default:return null}}function wl(e,t){switch(la(t),t.tag){case 3:Ea(Ra),D();break;case 26:case 27:case 5:Le(t);break;case 4:D();break;case 31:t.memoizedState!==null&&Ho(t);break;case 13:Ho(t);break;case 19:Go(t);break;case 10:Ea(t.type);break;case 22:case 23:Ho(t),Io(),e!==null&&Ae(Qa);break;case 24:Ea(Ra)}}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{jo(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=Ei(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[Nt]=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=kn)),jl(e,r),nn=!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),nn=!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[Mt]=e,t[Nt]=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=Oi(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=Ei(r,n),a=Oi(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=Oi(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=Ei(t,e.stateNode),r=Wl===null?void 0:Wl.get(n),i=Oi(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=Ei(t,e.stateNode);t=Oi(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=Ei(n,r),a=Oi(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,V=!1,H=!1,U=!1,lu=typeof WeakSet==`function`?WeakSet:Set,uu=null,W=!1,du=!1,G=!1,fu=!1;function K(e,t,n){if(e=e.containerInfo,sp=gh,e=ni(e),ri(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,uu=t,t=n?9270:1024;uu!==null;){if(e=uu,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),pu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&tu(r),pu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Gl(e),pu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,uu=r):(n&&nu(e),pu(n))}}Wl=null}function pu(e){for(;uu!==null;){var t=uu,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=Ei(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=Oi(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,uu=r;break}uu=t.return}}function mu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ju(e,n),r&4&&Tl(5,n);break;case 1:if(ju(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(ju(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{jo(e,t)}catch(e){ff(n,n.return,e)}}break;case 27:t===null&&r&4&&Hl(n);case 26:case 5:ju(e,n),t===null&&r&4&&Il(n),r&512&&kl(n,n.return);break;case 12:ju(e,n);break;case 31:ju(e,n),r&4&&J(e,n);break;case 13:ju(e,n),r&4&&Su(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||V;t=cu,i=V,cu=r,(V=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Nu(e,n,r)):ju(e,n),cu=t,V=i}break;case 30:ju(e,n),r&512&&kl(n,n.return);break;case 7:r&512&&kl(n,n.return);default:ju(e,n)}}function hu(e,t){for(e=e.child;e!==null;)q(e,t),e=e.sibling}function q(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)}gu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,nn=!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&&hu(e,t);break;default:hu(e,t)}}function gu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:q(n,r);break a;case 22:n.memoizedState===null&&gu(n,r);break a;default:gu(n,r)}}e=e.sibling}}function _u(e){var t=e.alternate;t!==null&&(e.alternate=null,_u(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Vt(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 vu=null,yu=!1;function bu(e,t,n){for(n=n.child;n!==null;)xu(e,t,n),n=n.sibling}function xu(e,t,n){if(ot&&typeof ot.onCommitFiberUnmount==`function`)try{ot.onCommitFiberUnmount(at,n)}catch{}switch(n.tag){case 26:V||Al(n,t),bu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!V&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:V||Al(n,t),Nl(n);var r=vu,i=yu;Sp(n.type)&&(vu=n.stateNode,yu=!1),bu(e,t,n),gm(n.stateNode,n.type,n.memoizedProps),vu=r,yu=i;break;case 5:V||Al(n,t),Nl(n);case 6:if(n.tag===6&&Nl(n),r=vu,i=yu,vu=null,bu(e,t,n),vu=r,yu=i,vu!==null){if(yu)try{(vu.nodeType===9?vu.body:vu.nodeName===`HTML`?vu.ownerDocument.body:vu).removeChild(n.stateNode),nn=!0}catch(e){ff(n,t,e)}else try{vu.removeChild(n.stateNode),nn=!0}catch(e){ff(n,t,e)}}break;case 18:vu!==null&&(yu?(e=vu,Cp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Hh(e)):Cp(vu,n.stateNode));break;case 4:r=vu,i=yu,vu=n.stateNode.containerInfo,yu=!0,bu(e,t,n),vu=r,yu=i;break;case 0:case 11:case 14:case 15:El(2,n,t),V||El(4,n,t),bu(e,t,n);break;case 1:V||(Al(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Ol(n,t,r)),bu(e,t,n);break;case 21:bu(e,t,n);break;case 22:V=(r=V)||n.memoizedState!==null,bu(e,t,n),V=r;break;case 30:Al(n,t),bu(e,t,n);break;case 7:V||Al(n,t),bu(e,t,n);break;default:bu(e,t,n)}}function J(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 Su(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 Cu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new lu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new lu),t;default:throw Error(i(435,e.tag))}}function Y(e,t){var n=Cu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=_f.bind(null,e,t);t.then(r,r)}})}function wu(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)){vu=l.stateNode,yu=!1;break a}break;case 5:vu=l.stateNode,yu=!1;break a;case 3:case 4:vu=l.stateNode.containerInfo,yu=!0;break a}l=l.return}if(vu===null)throw Error(i(160));xu(s,c,o),vu=null,yu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Eu(t,e,n),t=t.sibling}var Tu=null;function Eu(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}wu(t,e,n),Du(e),a&4&&(El(3,e,e.return),Tl(3,e),El(5,e,e.return));break;case 1:wu(t,e,n),Du(e),a&512&&(V||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=Tu,wu(t,e,n),Du(e),a&512&&(V||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[zt]||r[Mt]||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[Mt]=e,Kt(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[Mt]=e,Kt(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||V||t.parentNode.removeChild(t)):a.count--,n===null?cu||Km(o,e.type,e.stateNode):Bm(o,n,e.memoizedProps))}break;case 27:wu(t,e,n),Du(e),a&512&&(V||r===null||Al(r,r.return)),r!==null&&a&4&&Ll(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=H,H=!1,wu(t,e,n),H=o,Du(e),a&512&&(V||r===null||Al(r,r.return)),e.flags&32){t=e.stateNode;try{xn(t,``),nn=!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&&(U=!0);break;case 6:if(wu(t,e,n),Du(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,nn=!0}catch(t){ff(e,e.return,t)}}break;case 3:if(nn=!1,Wm=null,o=Tu,Tu=bm(t.containerInfo),wu(t,e,n),Tu=o,Du(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){ff(e,e.return,t)}U&&(U=!1,Ou(e)),nn=!1;break;case 4:a=H,H=cu,r=rn(),o=Tu,Tu=bm(e.stateNode.containerInfo),wu(t,e,n),Du(e),Tu=o,nn&&du&&(G=!0),nn=r,H=a;break;case 12:wu(t,e,n),Du(e);break;case 31:wu(t,e,n),Du(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Y(e,t)));break;case 13:wu(t,e,n),Du(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(fd=Xe()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Y(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=cu,l=V,u=H;cu=c||o,H=u||o,V=l||s,wu(t,e,n),V=l,H=u,cu=c,Du(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||cu||V||(t=s||V,n=cu,r=V,cu=o||cu,V=t,Mu(e,2),cu=n,V=r),!o&&H||hu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Y(e,n))));break;case 19:wu(t,e,n),Du(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Y(e,t)));break;case 30:a&512&&(V||r===null||Al(r,r.return)),a=rn(),o=du,s=(n&335544064)===n,c=e.memoizedProps,du=s&&Oi(c.default,c.update)!==`none`,wu(t,e,n),Du(e),s&&r!==null&&nn&&(e.flags|=4),du=o,nn=a;break;case 21:break;case 7:a&512&&(V||r===null||Al(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:wu(t,e,n),Du(e)}}function Du(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&&(xn(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 Ou(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Ou(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,gh=!0,t.reset(),gh=!1),e=e.sibling}}function ku(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Au(t,e),t=t.sibling;else su(t,!1)}function Au(e,t){var n=e.alternate;if(n===null)$l(e,!1);else switch(e.tag){case 3:if(fu=W=!1,ql(),ku(t,e),!W&&!G){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`})),fu=!0}Kl=null;break;case 5:ku(t,e);break;case 4:r=W,W=!1,ku(t,e),W&&(G=!0),W=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?ku(t,e):$l(e,!1));break;case 30:r=W,i=ql(),W=!1,ku(t,e),W&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=Ei(a,o),o=Ei(n.memoizedProps,o);var s=Oi(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),W=e.flags&32?!0:r;break;default:ku(t,e)}}function ju(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)mu(e,t.alternate,t),t=t.sibling}function Mu(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),Mu(n,r);break;case 1:Al(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&Ol(n,n.return,i),Mu(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),Mu(n,r);break;case 6:Nl(n);break;case 26:Al(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||V||i.parentNode.removeChild(i),Mu(n,r);break;case 22:n.memoizedState===null&&Mu(n,r);break;case 30:Al(n,n.return),Mu(n,r);break;case 7:Al(n,n.return);default:Mu(n,r)}e=e.sibling}}function Nu(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:Nu(i,a,n),Tl(4,a);break;case 1:if(Nu(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++)Ao(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),Nu(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),Nu(i,a,n),s&&r===null&&o&4&&Il(a),kl(a,a.return);break;case 12:Nu(i,a,n);break;case 31:Nu(i,a,n),s&&o&4&&J(i,a);break;case 13:Nu(i,a,n),s&&o&4&&Su(i,a);break;case 22:a.memoizedState===null&&Nu(i,a,n),kl(a,a.return);break;case 30:Nu(i,a,n),kl(a,a.return);break;case 7:kl(a,a.return);default:Nu(i,a,n)}t=t.sibling}}function Pu(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&&Ba(n))}function Fu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ba(e))}function Iu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Lu(e,t,n,r),t=t.sibling;else i&&au(t)}function Lu(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:Iu(e,t,n,r),a&2048&&Tl(9,t);break;case 1:Iu(e,t,n,r);break;case 3:Iu(e,t,n,r),i&&fu&&(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&&Ba(a)));break;case 12:if(a&2048){Iu(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 Iu(e,t,n,r);break;case 31:Iu(e,t,n,r);break;case 13:Iu(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?Iu(e,t,n,r):(o._visibility|=2,Ru(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&iu(s),o._visibility&2?Iu(e,t,n,r):zu(e,t)),a&2048&&Pu(s,t);break;case 24:Iu(e,t,n,r),a&2048&&Fu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Zl(a.child,!0),Zl(t.child,!0))),Iu(e,t,n,r);break;default:Iu(e,t,n,r)}}function Ru(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:Ru(a,o,s,c,i),Tl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ru(a,o,s,c,i)):u._visibility&2?Ru(a,o,s,c,i):zu(a,o),i&&l&2048&&Pu(o.alternate,o);break;case 24:Ru(a,o,s,c,i),i&&l&2048&&Fu(o.alternate,o);break;default:Ru(a,o,s,c,i)}t=t.sibling}}function zu(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:zu(n,r),i&2048&&Pu(r.alternate,r);break;case 24:zu(n,r),i&2048&&Fu(r.alternate,r);break;default:zu(n,r)}t=t.sibling}}var Bu=8192;function Vu(e,t,n){if(e.subtreeFlags&Bu)for(e=e.child;e!==null;)Hu(e,t,n),e=e.sibling}function Hu(e,t,n){switch(e.tag){case 26:Vu(e,t,n),e.flags&Bu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&Zm(n,e)):Qm(n,Tu,e.memoizedState,e.memoizedProps));break;case 5:Vu(e,t,n),e.flags&Bu&&(e=e.stateNode,(t&335544128)===t&&Zm(n,e));break;case 3:case 4:var r=Tu;Tu=bm(e.stateNode.containerInfo),Vu(e,t,n),Tu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Bu,Bu=16777216,Vu(e,t,n),Bu=r):Vu(e,t,n));break;case 30:if((e.flags&Bu)!==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)}Vu(e,t,n);break;default:Vu(e,t,n)}}function Uu(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 Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];uu=r,qu(r,e)}Uu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Gu(e),e=e.sibling}function Gu(e){switch(e.tag){case 0:case 11:case 15:Wu(e),e.flags&2048&&El(9,e,e.return);break;case 3:Wu(e);break;case 12:Wu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ku(e)):Wu(e);break;default:Wu(e)}}function Ku(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];uu=r,qu(r,e)}Uu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:El(8,t,t.return),Ku(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ku(t));break;default:Ku(t)}e=e.sibling}}function qu(e,t){for(;uu!==null;){var n=uu;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:Ba(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,uu=r;else a:for(n=e;uu!==null;){r=uu;var i=r.sibling,a=r.return;if(_u(r),r===n){uu=null;break a}if(i!==null){i.return=a,uu=i;break a}uu=a}}}var Ju={getCacheForType:function(e){var t=Ma(Ra),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ma(Ra).controller.signal}},Yu=typeof WeakMap==`function`?WeakMap:Map,X=0,Xu=null,Z=null,Q=0,Zu=0,Qu=null,$u=!1,ed=!1,td=!1,nd=0,rd=0,id=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 X&2&&Q!==0?Q&-Q:E.T===null?kt():Nf()}function Ad(){if(sd===0){if(!(Q&536870912)||N){var e=pt;pt<<=1,!(pt&3932160)&&(pt=262144),sd=e}else sd=536870912}return e=Lo.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(Ei(e.memoizedProps,n))),Td===null&&(Td=[]),Td.push(t.bind(null,r))}}function Md(e,t,n){(e===Xu&&(Zu===2||Zu===9)||e.cancelPendingCommit!==null)&&(zd(e,0),Id(e,Q,sd,!1)),St(e,n),X&2&&e===Xu||(e===Xu&&(!(X&2)&&(ad|=n),rd===4&&Id(e,Q,sd,!1)),Tf(e))}function Nd(e,t,n){if(X&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||_t(e,t),a=r?qd(e,t):Gd(e,t,!0),o=r;do{if(a===0){ed&&!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(td&&!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,!$u);break a;case 2:ud=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=fd+300-Xe(),10<a)){if(Id(r,t,sd,!$u),gt(r,0,!0)!==0)break a;bd=t,r.timeoutHandle=gp(Pd.bind(null,r,n,ud,hd,dd,t,sd,ad,cd,$u,o,`Throttled`,-0,0),a);break a}Pd(r,n,ud,hd,dd,t,sd,ad,cd,$u,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:kn},Wl=null,Hu(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-Xe():(a&4194048)===a?pd-Xe():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(!Xr(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=vt(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-ct(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&wt(e,n,t)}function Ld(){return X&6?!0:(Ef(0,!1),!1)}function Rd(){if(Z!==null){if(Zu===0)var e=Z.return;else e=Z,wa=Ca=null,us(e),po=null,mo=0,e=Z;for(;e!==null;)wl(e.alternate,e),e=e.return;Z=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(),Xu=e,Z=n=Hi(e.current,null),Q=t,Zu=0,Qu=null,$u=!1,ed=_t(e,t),td=!1,cd=sd=od=ad=id=rd=0,ud=ld=null,dd=!1,nd=vt(e,t),Ni(),n}function Bd(e,t){I=null,E.H=z,t===no||t===io?(t=uo(),Zu=3):t===ro?(t=uo(),Zu=4):Zu=t===Ic?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Qu=t,Z===null&&(rd=1,Ac(e,Xi(t,e.current)))}function Vd(){var e=Lo.current;return e===null?!0:(Q&4194048)===Q?Ro===null:(Q&62914560)===Q||Q&536870912?e===Ro:!1}function Hd(){var e=E.H;return E.H=z,e===null?z:e}function Ud(){var e=E.A;return E.A=Ju,e}function Wd(){rd=4,$u||(Q&4194048)!==Q&&Lo.current!==null||(ed=!0),!(id&134217727)&&!(ad&134217727)||Xu===null||Id(Xu,Q,sd,!1)}function Gd(e,t,n){var r=X;X|=2;var i=Hd(),a=Ud();(Xu!==e||Q!==t)&&(hd=null,zd(e,t)),t=!1;var o=rd;a:do try{if(Zu!==0&&Z!==null){var s=Z,c=Qu;switch(Zu){case 8:Rd(),o=6;break a;case 3:case 2:case 9:case 6:Lo.current===null&&(t=!0);var l=Zu;if(Zu=0,Qu=null,Zd(e,s,c,l),n&&ed){o=0;break a}break;default:l=Zu,Zu=0,Qu=null,Zd(e,s,c,l)}}Kd(),o=rd;break}catch(t){Bd(e,t)}while(1);return t&&e.shellSuspendCounter++,wa=Ca=null,X=r,E.H=i,E.A=a,Z===null&&(Xu=null,Q=0,Ni()),o}function Kd(){for(;Z!==null;)Yd(Z)}function qd(e,t){var n=X;X|=2;var r=Hd(),a=Ud();Xu!==e||Q!==t?(hd=null,md=Xe()+500,zd(e,t)):ed=_t(e,t);a:do try{if(Zu!==0&&Z!==null){t=Z;var o=Qu;b:switch(Zu){case 1:Zu=0,Qu=null,Zd(e,t,o,1);break;case 2:case 9:if(oo(o)){Zu=0,Qu=null,Xd(t);break}t=function(){Zu!==2&&Zu!==9||Xu!==e||(Zu=7),Tf(e)},o.then(t,t);break a;case 3:Zu=7;break a;case 4:Zu=5;break a;case 7:oo(o)?(Zu=0,Qu=null,Xd(t)):(Zu=0,Qu=null,Zd(e,t,o,7));break;case 5:var s=null;switch(Z.tag){case 26:s=Z.memoizedState;case 5:case 27:var c=Z;if(s?Ym(s):c.stateNode.complete){Zu=0,Qu=null;var l=c.sibling;if(l!==null)Z=l;else{var u=c.return;u===null?Z=null:(Z=u,Qd(u))}break b}}Zu=0,Qu=null,Zd(e,t,o,5);break;case 6:Zu=0,Qu=null,Zd(e,t,o,6);break;case 8:Rd(),rd=6;break a;default:throw Error(i(462))}}Jd();break}catch(t){Bd(e,t)}while(1);return wa=Ca=null,E.H=r,E.A=a,X=n,Z===null?(Xu=null,Q=0,Ni(),rd):0}function Jd(){for(;Z!==null&&!Je();)Yd(Z)}function Yd(e){var t=hl(e.alternate,e,nd);e.memoizedProps=e.pendingProps,t===null?Qd(e):Z=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,Q);break;case 11:t=Yc(n,t,t.pendingProps,t.type.render,t.ref,Q);break;case 5:us(t);var r=t;r===da&&(N?(_a(r),r.tag===5&&r.stateNode!=null&&(M=r.stateNode)):(_a(r),N=!0));default:wl(n,t),t=Z=Ui(t,nd),t=hl(n,t,nd)}e.memoizedProps=e.pendingProps,t===null?Qd(e):Z=t}function Zd(e,t,n,r){wa=Ca=null,us(t),po=null,mo=0;var i=t.return;try{if(Fc(e,i,t,n,Q)){rd=1,Ac(e,Xi(n,e.current)),Z=null;return}}catch(t){if(i!==null)throw Z=i,t;rd=1,Ac(e,Xi(n,e.current)),Z=null;return}t.flags&32768?(N||r===1?e=!0:ed||Q&536870912?e=!1:($u=e=!0,(r===2||r===9||r===3||r===6)&&(r=Lo.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,$u);return}e=t.return;var n=Sl(t.alternate,t,nd);if(n!==null){Z=n;return}if(t=t.sibling,t!==null){Z=t;return}Z=t=e}while(t!==null);rd===0&&(rd=5)}function $d(e,t){do{var n=Cl(e.alternate,e);if(n!==null){n.flags&=32767,Z=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Z=e;return}Z=e=n}while(e!==null);rd=6,Z=null}function ef(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do lf();while(_d!==0);if(X&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===Xu&&(Z=Xu=null,Q=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|=Mi,Ct(e,n,s,r,i,a),Td=null,(n&335544064)===n?(Ed=Ua(e),r=10262):(Ed=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,vf(et,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=Te.p,Te.p=2,a=X,X|=4;try{K(e,t,n)}finally{X=a,Te.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,Au(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=Te.p;Te.p=2;var a=X;X|=4;try{du=G=!1,Eu(t,e,n),n=cp;var o=ni(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&ti(s.ownerDocument.documentElement,s)){if(c!==null&&ri(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 _=ei(s,h),v=ei(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{X=a,Te.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=Te.p;Te.p=2;var i=X;X|=4;try{mu(e,t.alternate,t)}finally{X=i,Te.p=r,E.T=n}}_d=3}}function sf(){if(_d===4||_d===3){_d=0;var e=wd;wd=null,Ye();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),Ot(r),n=n.stateNode,ot&&typeof ot.onCommitFiberRoot==`function`)try{ot.onCommitFiberRoot(at,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=E.T,a=Te.p,Te.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,Te.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,Ba(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=Ot(bd),r=E.T,a=Te.p;try{Te.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,X&6)throw Error(i(331));var c=X;if(X|=4,Gu(o.current),Lu(o,o.current,s,n),X=c,Ef(0,!1),ot&&typeof ot.onPostCommitFiberRoot==`function`)try{ot.onPostCommitFiberRoot(at,o)}catch{}return!0}finally{Te.p=a,E.T=r,cf(e,t)}}function df(e,t,n){t=Xi(n,t),t=Mc(e.stateNode,t,2),e=wo(e,t,2),e!==null&&(St(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=Xi(n,e),n=Nc(2),r=wo(t,n,2),r!==null&&(Pc(n,r,t,e),St(r,2),Tf(r));break}}t=t.return}}function pf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Yu;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)||(td=!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,Xu===e&&(Q&n)===n&&(rd===4||rd===3&&(Q&62914560)===Q&&300>Xe()-fd?X&2?od|=n:zd(e,0):od|=n,cd===Q&&(cd=0)),Tf(e)}function hf(e,t){t===0&&(t=bt()),e=Fi(e,t),e!==null&&(St(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 Ke(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-ct(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=Q,a=gt(r,r===Xu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||_t(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=Xe(),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-ct(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=yt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Xu,n=Q,n=gt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Zu===2||Zu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&qe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||_t(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&qe(r),Ot(n)){case 2:case 8:n=$e;break;case 32:n=et;break;case 268435456:n=nt;break;default:n=et}return r=Af.bind(null,e),n=Ke(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&qe(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=Q;return r=gt(e,e===Xu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Nd(e,r,t),kf(e,Xe()),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(){X&6?Ke(Qe,Df):Of()})}function Nf(){if(wf===0){var e=Ka;e===0&&(e=ft,ft<<=1,!(ft&261888)&&(ft=256)),wf=e}return wf}function Pf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:On(e)}function Ff(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Pf((i[Nt]||null).action),o=r.submitter;o&&(t=(t=o[Nt]||null)?Pf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Xn(`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<Ci.length;If++){var Lf=Ci[If];wi(Lf.toLowerCase(),`on`+(Lf[0].toUpperCase()+Lf.slice(1)))}wi(hi,`onAnimationEnd`),wi(gi,`onAnimationIteration`),wi(_i,`onAnimationStart`),wi(`dblclick`,`onDoubleClick`),wi(`focusin`,`onFocus`),wi(`focusout`,`onBlur`),wi(vi,`onTransitionRun`),wi(yi,`onTransitionStart`),wi(bi,`onTransitionCancel`),wi(xi,`onTransitionEnd`),Zt(`onMouseEnter`,[`mouseout`,`mouseover`]),Zt(`onMouseLeave`,[`mouseout`,`mouseover`]),Zt(`onPointerEnter`,[`pointerout`,`pointerover`]),Zt(`onPointerLeave`,[`pointerout`,`pointerover`]),Xt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Xt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Xt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Xt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Xt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Xt(`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){ki(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){ki(e)}i.currentTarget=null,a=c}}}}function $(e,t){var n=t[Ft];n===void 0&&(n=t[Ft]=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,Jt.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,!zn||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=Ht(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}In(function(){var r=a,i=jn(n),o=[];a:{var s=Si.get(e);if(s!==void 0){var l=Xn,u=e;switch(e){case`keypress`:if(Gn(n)===0)break a;case`keydown`:case`keyup`:l=mr;break;case`focusin`:u=`focus`,l=ar;break;case`focusout`:u=`blur`,l=ar;break;case`beforeblur`:case`afterblur`:l=ar;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=rr;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=ir;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=_r;break;case hi:case gi:case _i:l=or;break;case xi:l=vr;break;case`scroll`:case`scrollend`:l=Qn;break;case`wheel`:l=yr;break;case`copy`:case`cut`:case`paste`:l=sr;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=hr;break;case`submit`:l=gr;break;case`toggle`:case`beforetoggle`:l=br}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=Ln(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!==An&&(u=n.relatedTarget||n.fromElement)&&(Ht(u)||u[Pt]))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?Ht(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=rr,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=hr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=s==null?u:Wt(s),h=l==null?u:Wt(l),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,Ht(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?Wt(r):window,l=s.nodeName&&s.nodeName.toLowerCase(),l===`select`||l===`input`&&s.type===`file`)var _=zr;else if(Nr(s)){if(Br)_=Jr;else{_=Kr;var v=Gr}}else l=s.nodeName,!l||l.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&Tn(r.elementType)&&(_=zr):_=qr;if(_&&=_(e,r)){Pr(o,_,n,i);break a}v&&v(e,s,r)}switch(v=r?Wt(r):window,e){case`focusin`:(Nr(v)||v.contentEditable===`true`)&&(ai=v,oi=r,si=null);break;case`focusout`:si=oi=ai=null;break;case`mousedown`:ci=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:ci=!1,li(o,n,i);break;case`selectionchange`:if(ii)break;case`keydown`:case`keyup`:li(o,n,i)}var y;if(Sr)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 k?Or(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(Tr&&n.locale!==`ko`&&(k||b!==`onCompositionStart`?b===`onCompositionEnd`&&k&&(y=Wn()):(Vn=i,Hn=`value`in Vn?Vn.value:Vn.textContent,k=!0)),v=qf(r,b),0<v.length&&(b=new cr(b,e,null,n,i),o.push({event:b,listeners:v}),y?b.data=y:(y=kr(n),y!==null&&(b.data=y)))),(y=wr?Ar(e,n):jr(e,n))&&(b=qf(r,`onBeforeInput`),0<b.length&&(v=new cr(`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=Ln(e,n),i!=null&&r.unshift(Kf(e,i,a)),i=Ln(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=Ln(n,a),l!=null&&o.unshift(Kf(n,l,c))):i||(l=Ln(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===``||xn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&xn(e,``+r);else return;break;case`className`:on(e,`class`,r);break;case`tabIndex`:on(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:on(e,n,r);break;case`style`:wn(e,r,o);return;case`data`:if(t!==`object`){on(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=On(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=On(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=kn);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=On(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),an(e,`popover`,r);break;case`xlinkActuate`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:sn(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:sn(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:sn(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:an(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=En.get(n)||n,an(e,n,r);else return}nn=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:wn(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`)xn(e,r);else if(typeof r==`number`||typeof r==`bigint`)xn(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=kn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Yt.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[Nt]||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}nn=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):an(e,n,r)}return}nn=!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)}}gn(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&&vn(e,!!r,n,!0):vn(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)}bn(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(Tn(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&&(nn=!0),o=m;break;case`name`:m!==f&&(nn=!0),a=m;break;case`checked`:m!==f&&(nn=!0),u=m;break;case`defaultChecked`:m!==f&&(nn=!0),d=m;break;case`value`:m!==f&&(nn=!0),s=m;break;case`defaultValue`:m!==f&&(nn=!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)}}hn(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&&(nn=!0),p=o;break;case`defaultValue`:o!==l&&(nn=!0),c=o;break;case`multiple`:o!==l&&(nn=!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?vn(e,!!n,n?[]:``,!1):vn(e,!!n,t,!0)):vn(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&&(nn=!0),p=a;break;case`defaultValue`:a!==o&&(nn=!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)}yn(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&&(nn=!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(Tn(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[Mt]=r,n[Nt]=t,np(n,e,t),Kt(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[zt]||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=Ht(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),Vt(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[zt])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===kn&&(e.onclick=null),Vt(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Vt(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=Te.d;Te.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=Ut(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=mn(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),Kt(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="`+mn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+mn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+mn(n.imageSizes)+`"]`)):i+=`[href="`+mn(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[Bt]=!0,o.onload=o.onerror=function(){qt(o)}),Kt(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="`+mn(r)+`"][href="`+mn(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),Kt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Gt(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`);Kt(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=Gt(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`),Kt(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=Gt(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`),Kt(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=Pe.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=Gt(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=Gt(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=Gt(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="`+mn(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[Bt]){r.loading=1;return}}else t=e.createElement(`link`),t[Bt]=!0,t.onload=t.onerror=qt.bind(null,t),np(t,`link`,n),Kt(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="`+mn(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~="`+mn(n.href)+`"]`);if(r)return t.instance=r,Kt(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`),Kt(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,Kt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Kt(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,Kt(a),a):(r=n,(a=vm.get(o))&&(r=T({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Kt(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[zt]||a[Mt]||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,Kt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Kt(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:Ee,_currentValue2:Ee,_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=xt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xt(0),this.hiddenUpdates=xt(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=Bi(3,null,null,t),e.current=a,a.stateNode=e,t=za(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},xo(a),e}function uh(e){return e?(e=Ri,e):Ri}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=Co(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=wo(e,r,t),n!==null&&(Md(n,e,t),To(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=Fi(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=Dt(t);var n=Fi(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=Te.p;try{Te.p=2,yh(e,t,n,r)}finally{Te.p=a,E.T=i}}function vh(e,t,n,r){var i=E.T;E.T=null;var a=Te.p;try{Te.p=8,yh(e,t,n,r)}finally{Te.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=Ut(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=ht(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-ct(o);s.entanglements[1]|=c,o&=~c}Tf(a),!(X&6)&&(md=Xe()+500,Ef(0,!1))}}break;case 31:case 13:s=Fi(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=jn(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=Ht(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(Ze()){case Qe:return 2;case $e:return 8;case et:case tt:return 32;case nt: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=Ut(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=Ht(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,At(e.priority,function(){hh(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,At(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);An=r,n.target.dispatchEvent(r),An=null}else return t=Ut(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=Ut(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[Nt]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Nt]||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[Pt]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=kt();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`));Te.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{at=Jh.inject(qh),ot=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[Pt]=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 Te=w(E),Ee={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ee.node;var De=w(Ee),Oe={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`]};Oe.node;var ke=w(Oe),Ae={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ae.node;var je=w(Ae),Me={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`}]]};Me.node;var Ne=w(Me),Pe={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`}]]};Pe.node;var Fe=w(Pe),Ie={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`}]]};Ie.node;var D=w(Ie),O={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`}]]};O.node;var Le=w(O),Re={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`}]]};Re.node;var ze=w(Re),Be={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`}]]};Be.node;var Ve=w(Be),He={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`}]]};He.node;var Ue=w(He),We={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`}]]};We.node;var Ge=w(We),Ke={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`}]]};Ke.node;var qe=w(Ke),Je={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`}]]};Je.node;var Ye=w(Je),Xe={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`}]]};Xe.node;var Ze=w(Xe),Qe={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`}]]};Qe.node;var $e=w(Qe),et={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`}]]};et.node;var tt=w(et),nt={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`}]]};nt.node;var rt=w(nt),it={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`}]]};it.node;var at=w(it),ot={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`}]]};ot.node;var st=w(ot),ct={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`}]]};ct.node;var lt=w(ct),ut={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`}]]};ut.node;var dt=w(ut),ft={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`}]]};ft.node;var pt=w(ft),mt={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`}]]};mt.node;var ht=w(mt),gt={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`}]]};gt.node;var _t=w(gt),vt={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`}]]};vt.node;var yt=w(vt),bt={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`}]]};bt.node;var xt=w(bt),St={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`}]]};St.node;var Ct=w(St),wt={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`}]]};wt.node;var Tt=w(wt),Et={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`]};Et.node;var Dt=w(Et),Ot={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`}]]};Ot.node;var kt=w(Ot),At={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`}]]};At.node;var jt=w(At),Mt={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Mt.node;var Nt=w(Mt),Pt={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`]};Pt.node;var Ft=w(Pt),It={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`}]]};It.node;var Lt=w(It),Rt={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`}]]};Rt.node;var zt=w(Rt),Bt={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`}]]};Bt.node;var Vt=w(Bt),Ht={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Ht.node;var Ut=w(Ht),Wt={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`}]]};Wt.node;var Gt=w(Wt),Kt={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`}]]};Kt.node;var qt=w(Kt),Jt={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`}]]};Jt.node;var Yt=w(Jt),Xt={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`}]]};Xt.node;var Zt=w(Xt),Qt={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`}]]};Qt.node;var $t=w(Qt),en={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`}]]};en.node;var tn=w(en),nn={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};nn.node;var rn=w(nn),an={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`}]]};an.node;var on=w(an),sn={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`}]]};sn.node;var cn=w(sn),ln={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`}]]};ln.node;var un=w(ln),dn={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`}]]};dn.node;var fn=w(dn),pn={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`}]]};pn.node;var mn=w(pn),hn={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};hn.node;var gn=w(hn),_n={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`}]]};_n.node;var vn=w(_n),yn={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`}]]};yn.node;var bn=w(yn),xn={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`}]]};xn.node;var Sn=w(xn),Cn={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`}]]};Cn.node;var wn=w(Cn),Tn={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`}]]};Tn.node;var En=w(Tn),Dn={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`}]]};Dn.node;var On=w(Dn),kn={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`]};kn.node;var An=w(kn),jn={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`}]]};jn.node;var Mn=w(jn),Nn={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`]};Nn.node;var Pn=w(Nn),Fn={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`]};Fn.node;var In=w(Fn),Ln={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`]};Ln.node;var Rn=w(Ln),zn={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};zn.node;var Bn=w(zn),Vn={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`}]]};Vn.node;var Hn=w(Vn),Un={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`}]]};Un.node;var Wn=w(Un),Gn={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`}]]};Gn.node;var Kn=w(Gn),qn={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};qn.node;var Jn=w(qn),Yn={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`]};Yn.node;var Xn=w(Yn),Zn={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`]};Zn.node;var Qn=w(Zn),$n={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`]};$n.node;var er=w($n),tr={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`]};tr.node;var nr=w(tr),rr={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`]};rr.node;var ir=w(rr),ar={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`}]]};ar.node;var or=w(ar),sr={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`}]]};sr.node;var cr=w(sr),lr={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`}]]};lr.node;var ur=w(lr),dr={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`}]]};dr.node;var fr=w(dr),pr={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`]};pr.node;var mr=w(pr),hr={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`}]]};hr.node;var gr=w(hr),_r={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};_r.node;var vr=w(_r),yr={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`}]]};yr.node;var br=w(yr),xr=d();function Sr(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 Cr(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=Sr(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 wr(e,t){let n=Cr(e,t);return n?`Did you mean "${n}"? `:``}function Tr(e,t=40){let n=e.slice(0,t).map(e=>`"${e}"`).join(`, `);return e.length>t?`${n}, … (${e.length} total)`:n}var Er=class{files=new Map;constructor(e){for(let[t,n]of Object.entries(e??{}))this.files.set(Or(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(Or(e));if(!t)throw new Dr(`notFound`,`File not found: ${e}`);return t}async writeText(e,t){this.files.set(Or(e),new TextEncoder().encode(t))}async writeBytes(e,t){this.files.set(Or(e),t)}async exists(e){return this.files.has(Or(e))}async list(e=``){let t=e?Or(e).replace(/\/?$/,`/`):``;return[...this.files.keys()].filter(e=>e.startsWith(t)).sort()}async remove(e){this.files.delete(Or(e))}async size(e){return(await this.readBytes(e)).byteLength}},Dr=class extends Error{code;name=`FsError`;constructor(e,t){super(t),this.code=e}};function Or(e){let t=e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/+/g,`/`);if(t.startsWith(`/`)||t.split(`/`).includes(`..`)||/^[a-zA-Z]:/.test(t))throw new Dr(`invalidPath`,`Invalid project path: ${e}`);return t}var kr=`0.1.0`,k=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 Ar(e,t,n){let r=t.filter(e=>e.severity===`error`),i=r[0];return new k(`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 jr=e=>e.some(e=>e.severity===`error`);function Mr(){return new Date().toISOString()}async function Nr(e,t,n){let r;try{r=await e.readText(t)}catch(e){throw e instanceof Dr&&e.code===`notFound`?new k(`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 k(`io`,`Cannot read ${t}: ${e.message}`)}try{return JSON.parse(r)}catch(e){throw new k(`invalid`,`${t} is not valid JSON: ${e.message}`,`Fix the JSON syntax in ${t} (trailing commas and comments are not allowed).`)}}async function Pr(e,t,n){await e.writeText(t,`${JSON.stringify(n,null,2)}\n`)}async function Fr(e,t,n){return await e.exists(t)?Nr(e,t,t):n}var Ir=e=>Math.round(e/1024*10)/10,Lr=[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],Rr=e=>e.type===`image`||e.type===`text`||e.type===`shape`,zr=e=>typeof e.src==`string`,Br=e=>typeof e.shape==`string`,Vr=e=>!!e.gradient,A=(e,t,n,r,i,a={})=>({name:e,type:`number`,description:t,default:n,min:r,max:i,...a}),Hr=(e,t,n,r,i,a={})=>({name:e,type:`int`,description:t,default:n,min:r,max:i,step:1,...a}),Ur=(e,t,n)=>({name:e,type:`boolean`,description:t,default:n}),Wr=(e,t,n)=>({name:e,type:`color`,description:t,default:n}),Gr=(e,t,n,r)=>({name:e,type:`enum`,description:t,default:n,options:r}),Kr=(e,t)=>({name:e,type:`rgb`,description:t,default:[0,0,0],min:-100,max:100}),qr=[{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.`}],Jr=[{id:`brightnessContrast`,title:`Brightness / Contrast`,group:`light`,description:`Lighten or darken the image and increase or reduce contrast.`,params:[A(`brightness`,`-100 (darker) … 100 (lighter).`,0,-100,100),A(`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:[A(`exposure`,`Stops: +1 doubles the light.`,0,-5,5,{step:.05}),A(`offset`,`Lifts (+) or crushes (−) the blacks.`,0,-.5,.5,{step:.01}),A(`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:[A(`shadows`,`How much to lighten the shadows.`,35,0,100),A(`highlights`,`How much to darken the highlights.`,0,0,100),A(`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:[A(`black`,`Input black point.`,0,0,254),A(`white`,`Input white point.`,255,1,255),A(`gamma`,`Midtones (>1 lighter).`,1,.1,9.99,{step:.01}),A(`outBlack`,`Output black.`,0,0,255),A(`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:[A(`hue`,`Hue rotation, degrees.`,0,-180,180),A(`saturation`,`-100 (grey) … 100.`,0,-100,100),A(`lightness`,`-100 … 100.`,0,-100,100),Ur(`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:[A(`vibrance`,`-100 … 100.`,30,-100,100),A(`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:[A(`temperature`,`-100 (cooler) … 100 (warmer).`,0,-100,100),A(`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:[Kr(`shadows`,`[cyan↔red, magenta↔green, yellow↔blue] for the shadows.`),Kr(`midtones`,`Same for the midtones.`),Kr(`highlights`,`Same for the highlights.`),Ur(`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:[Wr(`color`,`Filter colour (warming #ec8a00, cooling #006dff…).`,`#ec8a00`),A(`density`,`Strength, 0 … 100.`,25,0,100),Ur(`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:[A(`red`,`Red contribution.`,30,-200,300),A(`green`,`Green contribution.`,59,-200,300),A(`blue`,`Blue contribution.`,11,-200,300)],example:{type:`grayscale`},cost:1},{id:`sepia`,title:`Sepia`,group:`color`,description:`Brown monochrome tone.`,params:[A(`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:[A(`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:[Hr(`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:[A(`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:[A(`angle`,`Direction, degrees.`,0,-180,180),A(`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:[A(`radius`,`Neighbourhood, px.`,8,1,60,{px:!0}),A(`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:[A(`amount`,`Strength, %.`,80,0,500),A(`radius`,`Px.`,1.2,.3,20,{px:!0,step:.1}),A(`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:[A(`amount`,`-100 … 100.`,30,-100,100),A(`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:[A(`amount`,`0 … 100.`,12,0,100),Ur(`monochrome`,`Grey grain instead of colour.`,!0),Hr(`seed`,`Random seed.`,1,0,999999),A(`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:[A(`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:[A(`amount`,`-100 (white) … 100 (dark).`,40,-100,100),A(`size`,`Clear centre size, 0 … 100.`,50,0,100),A(`feather`,`Softness, 0 … 100.`,60,0,100),Wr(`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:[A(`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:[A(`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:[Gr(`look`,`Look id.`,`vintage`,qr.map(e=>e.id))],example:{type:`look`,look:`cinema`,amount:.7},cost:2}],Yr=[Ur(`enabled`,`false = keep the filter but skip it.`,!0),A(`amount`,`Blend with the unfiltered pixels, 0 … 1.`,1,0,1,{step:.01})],Xr=[{id:`dropShadow`,title:`Drop shadow`,description:`Shadow cast by the layer's shape (cut-outs, text, stickers).`,params:[Wr(`color`,`Shadow colour.`,`#000000`),A(`opacity`,`0 … 1.`,.5,0,1,{step:.01}),A(`angle`,`Light angle, degrees (135 = shadow down-right).`,135,-180,180),A(`distance`,`Offset, px.`,12,0,500,{px:!0}),A(`blur`,`Softness, px.`,16,0,250,{px:!0}),A(`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:[Wr(`color`,`Glow colour.`,`#ffffff`),A(`opacity`,`0 … 1.`,.6,0,1,{step:.01}),A(`blur`,`Size, px.`,20,0,250,{px:!0}),A(`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:[Wr(`color`,`Shadow colour.`,`#000000`),A(`opacity`,`0 … 1.`,.5,0,1,{step:.01}),A(`angle`,`Light angle, degrees.`,135,-180,180),A(`distance`,`Offset, px.`,6,0,200,{px:!0}),A(`blur`,`Softness, px.`,10,0,200,{px:!0})]},{id:`stroke`,title:`Stroke`,description:`Outline around the layer's shape (sticker outline, text outline).`,params:[Wr(`color`,`Outline colour.`,`#ffffff`),A(`width`,`Px.`,6,0,200,{px:!0}),Gr(`position`,`Where the outline sits.`,`outside`,[`outside`,`center`,`inside`]),A(`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:[Wr(`color`,`Colour.`,`#ffffff`),A(`opacity`,`0 … 1.`,1,0,1,{step:.01}),Gr(`blend`,`Blend mode of the overlay.`,`normal`,Lr)]}],Zr=[{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.`}],Qr=[{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.`}],$r=[{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.`}],ei={"background-removal":`rmbg-1.4`,segmentation:`slimsam`},ti=[{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.`}],ni=[`rect`,`ellipse`,`line`,`polygon`,`star`],ri={layerTypes:ti,blendModes:Lr,filters:Jr,commonFilterParams:Yr,looks:qr,effects:Xr,shapes:ni,fonts:Zr,sizes:Qr,models:$r},ii=e=>Jr.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=e=>$r.find(t=>t.id===e),li={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`},ui=(e,t,n)=>Math.min(n,Math.max(t,e));function di(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 fi(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 pi(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 mi(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 hi(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 gi(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();if(!t)return null;if(t.startsWith(`#`))return di(t.slice(1));if(t===`transparent`)return{r:0,g:0,b:0,a:0};let n=li[t];if(n)return di(n);let r=/^(rgba?|hsla?)\((.*)\)$/.exec(t);if(!r)return null;let i=mi(r[2]);if(!i||i.length!==3&&i.length!==4)return null;let a=i.length===4?fi(i[3],1):1;if(a===null)return null;if(r[1].startsWith(`rgb`)){let[e,t,n]=i.slice(0,3).map(e=>fi(e,255));return e===null||t===null||n===null?null:{r:ui(e,0,255),g:ui(t,0,255),b:ui(n,0,255),a:ui(a,0,1)}}let o=pi(i[0]),s=fi(i[1],1),c=fi(i[2],1);if(o===null||s===null||c===null||!i[1].trim().endsWith(`%`)||!i[2].trim().endsWith(`%`))return null;let[l,u,d]=hi(o,ui(s,0,1),ui(c,0,1));return{r:l,g:u,b:d,a:ui(a,0,1)}}function _i(e){return gi(e)!==null}function vi({r:e,g:t,b:n}){return`#`+[e,t,n].map(e=>Math.round(ui(e,0,255)).toString(16).padStart(2,`0`)).join(``)}var yi=n({slugify:()=>Si,uniqueId:()=>Ci}),bi=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function xi(e){return typeof e==`string`&&bi.test(e)}function Si(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 Ci(e,t){let n=new Set(t),r=xi(e)?e:Si(e);if(!n.has(r))return r;for(let e=2;;e++)if(!n.has(`${r}-${e}`))return`${r}-${e}`}var wi=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ti=e=>typeof e==`number`&&Number.isFinite(e),Ei=16384,Di=[`id`,`type`,`name`,`visible`,`locked`,`opacity`,`blend`,`mask`,`clip`,`filters`,`effects`],Oi=[`x`,`y`,`width`,`height`,`rotation`,`flipX`,`flipY`],ki={image:[...Di,...Oi,`src`,`crop`,`fit`,`focus`],text:[...Di,...Oi,`text`,`font`,`size`,`weight`,`italic`,`color`,`align`,`valign`,`lineHeight`,`letterSpacing`,`transform`,`background`],shape:[...Di,...Oi,`shape`,`fill`,`stroke`,`radius`,`sides`,`innerRadius`],fill:[...Di,`fill`],adjustment:[...Di],group:[...Di,`children`]},Ai=Object.keys(ki),ji=[`version`,`id`,`title`,`description`,`canvas`,`layers`,`export`],Mi=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 Ni(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).`,`${wr(a,n)}Allowed: ${Tr(n)}.`)}function j(e,t,n,r={}){return t===void 0?(r.required&&e.error(`missing`,n,`${r.what??n} is required.`),!1):Ti(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 Pi(e,t,n){t!==void 0&&typeof t!=`boolean`&&e.error(`type`,n,`${n} must be true or false, got ${JSON.stringify(t)}.`)}function Fi(e,t,n,r=!1){t===void 0?r&&e.error(`missing`,n,`${n} (a CSS colour) is required.`):_i(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 Ii(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`?Fi(e,t,i):Array.isArray(t)&&t.length===2?(j(e,t[0],`${i}[0]`,{min:0,max:1}),Fi(e,t[1],`${i}[1]`,!0)):e.error(`stops`,i,`${i} must be a colour or [offset 0..1, colour].`)})}function Li(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 Fi(e,t,n);if(!wi(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)}.`),Ii(e,t.stops,`${n}.stops`),t.type===`linear`?(Ni(e,t,[`type`,`stops`,`angle`],n,`a linear gradient`),j(e,t.angle,`${n}.angle`)):t.type===`radial`&&(Ni(e,t,[`type`,`stops`,`cx`,`cy`,`radius`],n,`a radial gradient`),j(e,t.cx,`${n}.cx`),j(e,t.cy,`${n}.cy`),j(e,t.radius,`${n}.radius`,{min:0}))}}function Ri(e,t,n,r){switch(t.type){case`number`:case`int`:j(e,n,r,{min:t.min,max:t.max,int:t.type===`int`});return;case`boolean`:Pi(e,n,r);return;case`color`:Fi(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`?wr(n,t.options??[]):``}Allowed: ${Tr(t.options??[])}.`);return;case`stops`:Ii(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)=>j(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].`);j(e,n[0],`${a}[0]`,{min:0,max:255}),j(e,n[1],`${a}[1]`,{min:0,max:255}),Ti(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 zi(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&&Ri(e,t,c,`${r}.${s}`):e.warn(`unknown-param`,`${r}.${s}`,`Unknown parameter "${s}" for ${i} (ignored).`,`${wr(s,o)}Parameters: ${Tr(n.map(e=>e.name))}. catalog_get documents them.`)}}function Bi(e,t,n){if(!wi(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: ${Tr(ri.filters.map(e=>e.id))}.`);let r=ii(t.type);if(!r)return e.error(`unknown-filter`,`${n}.type`,`Unknown filter "${t.type}".`,`${wr(t.type,ri.filters.map(e=>e.id))}Filters: ${Tr(ri.filters.map(e=>e.id))} (catalog_get section "filters").`);let i=Yr.filter(e=>!r.params.some(t=>t.name===e.name));for(let r of i)t[r.name]!==void 0&&Ri(e,r,t[r.name],`${n}.${r.name}`);zi(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: ${Tr(ri.looks.map(e=>e.id))}.`)}function Vi(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)=>Bi(e,t,`${n}[${r}]`))}}function Hi(e,t,n){if(t==null)return;if(!wi(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`];Pi(e,t.invert,`${n}.invert`),Pi(e,t.enabled,`${n}.enabled`),j(e,t.feather,`${n}.feather`,{min:0,max:1e3}),j(e,t.density,`${n}.density`,{min:0,max:1}),t.src===void 0?t.shape===void 0?t.gradient!==void 0&&(Ni(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.`):Li(e,t.gradient,`${n}.gradient`)):(Ni(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".`),j(e,t.x,`${n}.x`,{required:!0}),j(e,t.y,`${n}.y`,{required:!0}),j(e,t.width,`${n}.width`,{required:!0,min:0}),j(e,t.height,`${n}.height`,{required:!0,min:0}),j(e,t.radius,`${n}.radius`,{min:0})):(Ni(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 Ui(e,t,n){if(t===void 0)return;if(!wi(t))return e.error(`type`,n,`${n} must be an object { dropShadow?, outerGlow?, innerShadow?, stroke?, colorOverlay? }.`);let r=Xr.map(e=>e.id);for(let[i,a]of Object.entries(t)){let t=Xr.find(e=>e.id===i),o=`${n}.${i}`;t?a!==null&&a!==!1&&(wi(a)?(zi(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).`,`${wr(i,r)}Effects: ${Tr(r)}.`)}}function Wi(e,t,n,r={}){j(e,t.x,`${n}.x`),j(e,t.y,`${n}.y`),j(e,t.width,`${n}.width`,{min:0,required:r.sizeRequired}),j(e,t.height,`${n}.height`,{min:0,required:r.sizeRequired}),j(e,t.rotation,`${n}.rotation`),Pi(e,t.flipX,`${n}.flipX`),Pi(e,t.flipY,`${n}.flipY`)}function Gi(e,t,n,r){if(!wi(t))return e.error(`type`,n,`${n} must be a layer object.`);let i=typeof t.id==`string`&&xi(t.id)?`layers#${t.id}`:n;if(xi(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`||!ki[t.type])e.error(`layer-type`,`${i}.type`,`Unknown layer type ${JSON.stringify(t.type)}.`,`${typeof t.type==`string`?wr(t.type,Ai):``}Types: ${Tr(Ai)}.`);else switch(Ni(e,t,ki[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.`),Pi(e,t.visible,`${i}.visible`),Pi(e,t.locked,`${i}.locked`),Pi(e,t.clip,`${i}.clip`),t.opacity!==void 0&&(Ti(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} %.`):j(e,t.opacity,`${i}.opacity`,{min:0,max:1})),t.blend===void 0||typeof t.blend==`string`&&Lr.includes(t.blend)||e.error(`enum`,`${i}.blend`,`Unknown blend mode ${JSON.stringify(t.blend)}.`,`${typeof t.blend==`string`?wr(t.blend,Lr):``}Blend modes: ${Tr(Lr)}.`),Hi(e,t.mask,`${i}.mask`),Ui(e,t.effects,`${i}.effects`),t.type){case`image`:Vi(e,t.filters,`${i}.filters`),Wi(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&&(wi(t.crop)?(j(e,t.crop.x,`${i}.crop.x`,{required:!0,min:0}),j(e,t.crop.y,`${i}.crop.y`,{required:!0,min:0}),j(e,t.crop.width,`${i}.crop.width`,{required:!0,min:1}),j(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=>Ti(e)&&e>=0&&e<=1)||e.error(`type`,`${i}.focus`,`${i}.focus must be [x, y] with values 0..1.`);break;case`text`:if(Vi(e,t.filters,`${i}.filters`),Wi(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(!oi(t.font)){let n=wr(t.font,Zr.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: ${Tr(Zr.map(e=>e.id))}.`)}}if(j(e,t.size,`${i}.size`,{min:1,max:4e3}),j(e,t.weight,`${i}.weight`,{min:100,max:900}),Pi(e,t.italic,`${i}.italic`),Li(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.`),j(e,t.lineHeight,`${i}.lineHeight`,{min:.1,max:10}),j(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(!wi(t.background))e.error(`type`,`${i}.background`,`${i}.background must be { color, padding?, radius? } or null.`);else{Ni(e,t.background,[`color`,`padding`,`radius`],`${i}.background`,`a text background`),Fi(e,t.background.color,`${i}.background.color`,!0);let n=t.background.padding;n!==void 0&&!Ti(n)&&!(Array.isArray(n)&&n.length===2&&n.every(Ti))&&e.error(`type`,`${i}.background.padding`,`padding must be a number or [horizontal, vertical].`),j(e,t.background.radius,`${i}.background.radius`,{min:0})}}break;case`shape`:Vi(e,t.filters,`${i}.filters`),Wi(e,t,i,{sizeRequired:!0}),typeof t.shape==`string`&&ri.shapes.includes(t.shape)||e.error(`enum`,`${i}.shape`,`${i}.shape must be one of ${Tr(ri.shapes)}.`,typeof t.shape==`string`?wr(t.shape,ri.shapes):void 0),Li(e,t.fill,`${i}.fill`,{allowNull:!0}),t.stroke!==void 0&&t.stroke!==null&&(wi(t.stroke)?(Ni(e,t.stroke,[`color`,`width`,`dash`],`${i}.stroke`,`a stroke`),Fi(e,t.stroke.color,`${i}.stroke.color`,!0),j(e,t.stroke.width,`${i}.stroke.width`,{min:0}),t.stroke.dash===void 0||Array.isArray(t.stroke.dash)&&t.stroke.dash.every(e=>Ti(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.`),j(e,t.radius,`${i}.radius`,{min:0}),j(e,t.sides,`${i}.sides`,{min:3,max:64,int:!0}),j(e,t.innerRadius,`${i}.innerRadius`,{min:0,max:1});break;case`fill`:Vi(e,t.filters,`${i}.filters`),Li(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).`),Vi(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`:Vi(e,t.filters,`${i}.filters`),Array.isArray(t.children)?t.children.forEach((t,n)=>Gi(e,t,`${i}.children[${n}]`,r)):e.error(`missing`,`${i}.children`,`Group "${t.id}" needs a children array.`)}}function Ki(e){let t=new Mi;if(!wi(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(Ni(t,e,ji,``,`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.`),xi(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.`),wi(e.canvas)?(Ni(t,e.canvas,[`width`,`height`,`background`],`canvas`,`canvas`),j(t,e.canvas.width,`canvas.width`,{required:!0,min:1,max:Ei,int:!0}),j(t,e.canvas.height,`canvas.height`,{required:!0,min:1,max:Ei,int:!0}),Ti(e.canvas.width)&&Ti(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).`),Li(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)=>Gi(t,e,`layers[${r}]`,n))}return e.export!==void 0&&(wi(e.export)?(Ni(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".`),j(t,e.export.quality,`export.quality`,{min:1,max:100}),j(t,e.export.scale,`export.scale`,{min:.01,max:8}),j(t,e.export.width,`export.width`,{min:1,max:Ei,int:!0}),j(t,e.export.height,`export.height`,{min:1,max:Ei,int:!0}),e.export.background!==void 0&&e.export.background!==null&&Fi(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 qi(e){return{...e,version:e.version??1,layers:e.layers===void 0||e.layers===null?[]:e.layers}}function Ji(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 Yi=n({imageInfo:()=>ia}),Xi={png:`image/png`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`,bmp:`image/bmp`,avif:`image/avif`,svg:`image/svg+xml`},Zi={png:`png`,jpg:`jpeg`,jpeg:`jpeg`,webp:`webp`,gif:`gif`,bmp:`bmp`,avif:`avif`,svg:`svg`},Qi=(e,t)=>e[t]<<8|e[t+1],$i=(e,t)=>e[t]|e[t+1]<<8,ea=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16,ta=(e,t)=>(e[t]<<24>>>0)+(e[t+1]<<16|e[t+2]<<8|e[t+3]),na=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,ra=(e,t,n)=>String.fromCharCode(...e.subarray(t,t+n));function ia(e){let t=e;if(t.length<12)return null;if(t[0]===137&&ra(t,1,3)===`PNG`&&t.length>=26){let e=t[25];return{type:`png`,width:ta(t,16),height:ta(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=Qi(t,e+2);if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204)return aa(t,{type:`jpeg`,height:Qi(t,e+5),width:Qi(t,e+7),alpha:!1});e+=2+r}return null}if(ra(t,0,4)===`RIFF`&&ra(t,8,4)===`WEBP`&&t.length>=30){let e=ra(t,12,4);if(e===`VP8 `)return{type:`webp`,width:$i(t,26)&16383,height:$i(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:ea(t,24)+1,height:ea(t,27)+1,alpha:!!(t[20]&16)}:null}if(ra(t,0,4)===`GIF8`)return{type:`gif`,width:$i(t,6),height:$i(t,8)};if(t[0]===66&&t[1]===77&&t.length>=26)return{type:`bmp`,width:Math.abs(na(t,18)),height:Math.abs(na(t,22))};if(ra(t,4,4)===`ftyp`){let e=ra(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&&ra(t,e,4)===`ispe`)return{type:`avif`,width:ta(t,e+8),height:ta(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 aa(e,t){let n=oa(e);return n>=5&&n<=8?{...t,width:t.height,height:t.width}:t}function oa(e){let t=2;for(;t+4<e.length;){if(e[t]!==255)return 1;let n=e[t+1],r=Qi(e,t+2);if(n===225&&ra(e,t+4,4)===`Exif`){let n=t+10,r=e[n]===73,i=t=>r?$i(e,t):Qi(e,t),a=n+(t=>r?(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0:ta(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 sa(e){let t=/\.([a-z0-9]+)$/i.exec(e)?.[1]?.toLowerCase();return t?Zi[t]:void 0}function ca(e){return typeof e==`string`&&e.startsWith(`library:`)}function la(e){return e.slice(8)}function ua(e,t){return e?.assets.find(e=>e.id===t)}var da=n({allLayerIds:()=>fa});function M(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)?M(n.children,t,n,r+1):null;if(e)return e}return null}function N(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`&&N(i.children,t,i,r+1)}function fa(e){let t=[];return N(e.layers,e=>void t.push(e.id)),t}function pa(e,t){return e.type===`group`&&!!M(e.children,t)}var ma=(e,t=40)=>e.length>t?`${e.slice(0,t-1)}…`:e;function ha(e){switch(e.type){case`image`:return`${e.src}${e.fit&&e.fit!==`fill`?` (${e.fit})`:``}`;case`text`:return`${JSON.stringify(ma(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??[]).map(e=>e.type===`look`?`look:${String(e.look)}`:e.type).join(`, `)||`(empty)`;case`group`:return`${e.children?.length??0} layers`;default:return``}}function ga(e){let t=e.mask;if(t)return zr(t)?`image`:Br(t)?`shape`:Vr(t)?`gradient`:void 0}function _a(e,t,n,r){let i={id:e.id,type:e.type,detail:ha(e),parent:t?.id??null,depth:n,index:r};e.name&&(i.name=e.name),Rr(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=ga(e);if(a&&(i.mask=e.mask&&e.mask.enabled===!1?`${a} (disabled)`:a),e.type!==`adjustment`&&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 va(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(_a(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 ya(e){let t=[];return N(e.layers,e=>{e.type===`image`&&typeof e.src==`string`&&t.push({path:e.src,by:e.id,role:`src`}),e.mask&&zr(e.mask)&&typeof e.mask.src==`string`&&t.push({path:e.mask.src,by:e.id,role:`mask`})}),t}var ba=`modulepreload`,xa=function(e,t){return new URL(e,t).href},Sa={},Ca=function(e){return e.pathname.endsWith(`.css`)},wa=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},Ta=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=xa(t,n);let r=s(t),i=Ca(r);return wa(Sa,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`:ba,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)})},Ea=`agentphoto.json`,Da=`photo.json`,Oa=`assets/manifest.json`,ka=new TextDecoder,Aa=e=>typeof e==`string`?e:ka.decode(e);function ja(e){if(e.size){let t=si(e.size);if(!t)throw new k(`invalid`,`Unknown size preset "${e.size}".`,`${wr(e.size,Qr.map(e=>e.id))}Presets: ${Qr.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 k(`invalid`,`Invalid canvas size ${t}×${n}.`,`Width and height are 1…${Ei} px.`);return{width:t,height:n}}return null}async function Ma(e,t){if(!t.name||!t.name.trim())throw new k(`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 k(`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 k(`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=Si(t.name,`photo`),r=t.title?.trim()||t.name.trim(),i=[],a=ja(t),o,s,c=null;if(t.templateFiles){let e=t.templateFiles;if(!e[`photo.json`])throw new k(`invalid`,`Template "${t.template??`?`}" has no photo.json.`,`A template folder holds photo.json, template.json and optional assets/.`);try{c=qi(JSON.parse(Aa(e[Da])))}catch(e){throw new k(`invalid`,`Template photo.json is not valid JSON: ${e.message}`)}let n=Ki(c);if(jr(n))throw Ar(`Template "${t.template??`?`}" is invalid.`,n)}if(t.image&&!ia(t.image.bytes))throw new k(`invalid`,`${t.image.name} is not a supported image (PNG, JPEG, WebP, GIF, BMP, AVIF, SVG).`);let l=null;if(t.image){let n=ia(t.image.bytes);if(!n)throw new k(`invalid`,`${t.image.name} is not a supported image (PNG, JPEG, WebP, GIF, BMP, AVIF, SVG).`);let{addAsset:r}=await Ta(async()=>{let{addAsset:e}=await Promise.resolve().then(()=>Ra);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;for(let[t,n]of Object.entries(u))t!==`photo.json`&&t!==`agentphoto.json`&&t!==`template.json`&&t!==`preview.png`&&t!==`preview.jpg`&&(typeof n==`string`?await e.writeText(t,n):await e.writeBytes(t,n),i.push(t));o=c;try{s=u[`template.json`]?JSON.parse(Aa(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?M(o.layers,s):null;e&&e.layer.type===`image`?(e.layer.src=l.path,e.layer.mask&&zr(e.layer.mask)&&delete e.layer.mask,delete e.layer.crop):o.layers.unshift(Na(l,o.canvas))}}else o=Ji({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(Na(l,o.canvas));let u=Ki(o);if(jr(u))throw Ar(`The new project's document is invalid.`,u,`Fix the template (or the options) and retry.`);let d=Mr(),f={name:n,title:r,createdAt:d,updatedAt:d,...t.template?{template:t.template}:{},agentphoto:kr};return await Pr(e,Ea,f),await Pr(e,Da,o),await e.exists(`assets/manifest.json`)||await Pr(e,Oa,{assets:[]}),i.push(Ea,Da,Oa),{manifest:f,doc:o,files:[...new Set(i)].sort(),issues:u}}function Na(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 Pa(e){return Nr(e,Ea,`Project manifest`)}async function Fa(e){return{manifest:await Pa(e),doc:qi(await Nr(e,Da,`The document`))}}async function Ia(e,t,n={}){let r=Ki(t);if(jr(r)&&!n.allowInvalid)throw Ar(`Document not saved:`,r);return await Pr(e,Da,t),await La(e),{issues:r}}async function La(e){let t=await Fr(e,Ea,null);t&&await Pr(e,Ea,{...t,updatedAt:Mr(),agentphoto:kr})}var Ra=n({addAsset:()=>Ga,removeAsset:()=>qa}),za={image:`assets/images`,mask:`assets/masks`,edit:`assets/edits`,font:`assets/fonts`,other:`assets/files`},Ba=83886080;async function Va(e){let t=await Fr(e,Oa,{assets:[]});return{assets:Array.isArray(t.assets)?t.assets:[]}}async function Ha(e,t){t.assets.sort((e,t)=>e.path.localeCompare(t.path)),await Pr(e,Oa,t)}function Ua(e,t=`png`){let n=e.split(/[\\/]/).pop()??e,r=/^(.*?)(?:\.([a-z0-9]{1,5}))?$/i.exec(n),i=Si(r?.[1]||`image`,`image`).slice(0,60),a=(r?.[2]??t).toLowerCase();return`${i}.${a===`jpeg`?`jpg`:a}`}async function Wa(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 Ga(e,t){if(!t.bytes?.byteLength)throw new k(`invalid`,`${t.name}: the file is empty.`);if(t.bytes.byteLength>83886080)throw new k(`invalid`,`${t.name} is ${Math.round(t.bytes.byteLength/1048576)} MB (max ${Ba/1048576} MB).`,`Resize or recompress it first.`);let n=ia(t.bytes),r=t.kind??(n?`image`:`other`);if((r===`image`||r===`mask`||r===`edit`)&&!n)throw new k(`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 k(`invalid`,`Asset paths live under assets/ (got "${t.name}").`)}else{let e=Ua(t.name,i);i&&Zi[e.split(`.`).pop()]!==n?.type&&(e=`${e.replace(/\.[^.]+$/,``)}.${i}`),a=`${za[r]}/${e}`}t.overwrite||(a=await Wa(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:Mr()},s=await Va(e);return s.assets=[...s.assets.filter(e=>e.path!==a),o],await Ha(e,s),o}async function Ka(e){let t=await Va(e),n=null;try{n=JSON.parse(await e.readText(Da))}catch{n=null}let r=n?ya(n):[],i=new Set((await e.list(`assets`)).filter(e=>e!==Oa)),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:Ir(s)}),i.delete(n.path)}return{assets:a,untracked:[...i],totalKb:Ir(o)}}async function qa(e,t,n={}){let r=await Va(e);if(!(r.assets.some(e=>e.path===t)||await e.exists(t)))throw new k(`notFound`,`No asset ${t}.`,`assets_list lists the project's assets.`);let i=[];try{let n=JSON.parse(await e.readText(Da));i=[...new Set(ya(n).filter(e=>e.path===t).map(e=>e.by))]}catch{i=[]}if(i.length&&!n.force)throw new k(`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 Ha(e,r),{removed:t,usedBy:i}}async function Ja(e,t){let n=[];for(let r of ya(t)){if(ca(r.path))continue;let t=!1;try{t=await e.exists(r.path)}catch{t=!1}t||n.push(r)}return n}var Ya=class extends Error{hint;name=`PathError`;constructor(e,t){super(e),this.hint=t}},Xa=/^([^#[\]]*)(?:#([^[\]]+))?((?:\[\d+\])*)$/;function Za(e){if(typeof e!=`string`||!e.trim())throw new Ya(`Empty path.`,`Use a path like "canvas.width" or "layers#title.color".`);let t=[];for(let n of Qa(e.trim())){let r=Xa.exec(n);if(!r)throw new Ya(`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 Ya(`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 Qa(e){return e.split(`.`)}function $a(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 eo=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function to(e,t,n){for(let n=0;n<e.length;n++){let r=e[n];if(eo(r)&&r.id===t)return{container:e,index:n}}if(n){for(let n of e)if(eo(n)&&Array.isArray(n.children)){let e=to(n.children,t,!0);if(e)return e}}return null}function no(e,t,n,r){if(!t.length)throw new Ya(`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=$a(t.slice(0,e+1));if(`ref`in s){if(!Array.isArray(i))throw new Ya(`"${$a(t.slice(0,e))}" is not an array, cannot look up "#${s.ref}" in "${r}".`);let n=to(i,s.ref,s.tree);if(!n)throw new Ya(`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 Ya(`"${$a(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 Ya(`Index ${s.index} out of range at "${l}" (length ${i.length}).`);o={parent:i,key:s.index}}else{if(!eo(i))throw new Ya(`"${$a(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 Ya(`Nothing at "${l}" (path "${r}").`);u=c&&(`index`in c||`ref`in c)?[]:{},o.parent[o.key]=u}i=u}throw new Ya(`Unreachable`)}function ro(e,t){let n=typeof t==`string`?Za(t):t,r=no(e,n,!1,typeof t==`string`?t:$a(n));return r.parent[r.key]}function io(e,t,n){let r=typeof t==`string`?Za(t):t,i=no(e,r,!0,typeof t==`string`?t:$a(r));i.parent[i.key]=n}function ao(e,t){let n=typeof t==`string`?Za(t):t,r=no(e,n,!1,typeof t==`string`?t:$a(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 oo(e,t){if(!eo(t))return so(t);let n=eo(e)?{...e}:{};for(let[e,r]of Object.entries(t))r===null?delete n[e]:n[e]=oo(n[e],r);return n}function so(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function co(e){return JSON.stringify(lo(e))}function lo(e){if(Array.isArray(e))return e.map(lo);if(eo(e)){let t={};for(let n of Object.keys(e).sort())e[n]!==void 0&&(t[n]=lo(e[n]));return t}return e}function uo(e,t){return co(e)===co(t)}var fo=n({cropDoc:()=>xo}),po=[`top-left`,`top`,`top-right`,`left`,`center`,`right`,`bottom-left`,`bottom`,`bottom-right`],mo=e=>JSON.parse(JSON.stringify(e)),P=e=>Math.round(e*100)/100;function ho(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 go(e,t={}){if(!Rr(e))return null;let n=e.x??0,r=e.y??0;if(e.type===`text`)return{x:n,y:r,...ho(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 _o(e,t){if(e.type!==`image`||e.width!==void 0&&e.height!==void 0)return;let n=go(e,t);if(!n)throw new k(`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=P(n.width),e.height=P(n.height)}function vo(e,t){for(let n of e)t(n),n.type===`group`&&vo(n.children??[],t)}function yo(e,t,n){e&&Br(e)&&(e.x=P(e.x+t),e.y=P(e.y+n))}function bo(e,t,n){vo(e,e=>{Rr(e)?(e.x=P((e.x??0)+t),e.y=P((e.y??0)+n)):yo(e.mask,t,n)})}function xo(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 k(`invalid`,`crop needs x, y, width ≥ 1, height ≥ 1 (canvas pixels).`);let o=mo(e);return bo(o.layers,-n,-r),o.canvas={...o.canvas,width:Math.round(i),height:Math.round(a)},o}function So(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 Co(e,t,n,r=`center`){if(!po.includes(r))throw new k(`invalid`,`Unknown anchor "${r}".`,`Anchors: ${po.join(`, `)}.`);let[i,a]=So(r,t-e.canvas.width,n-e.canvas.height);return xo(e,{x:-i,y:-a,width:t,height:n})}function wo(e,t,n){if(e)for(let r of t)typeof e[r]==`number`&&(e[r]=P(e[r]*n))}function To(e,t){for(let n of e??[])wo(n,(ii(n.type)?.params??[]).filter(e=>e.px).map(e=>e.name),t)}function Eo(e,t,n,r={}){if(!(t>0)||!(n>0))throw new k(`invalid`,`The scale must be > 0.`);let i=mo(e),a=Math.sqrt(t*n);return vo(i.layers,e=>{if(_o(e,r),Rr(e))e.x=P((e.x??0)*t),e.y=P((e.y??0)*n),e.width!==void 0&&(e.width=P(e.width*t)),e.height!==void 0&&(e.height=P(e.height*n));else if(e.mask&&Br(e.mask)){let r=e.mask;r.x=P(r.x*t),r.y=P(r.y*n),r.width=P(r.width*t),r.height=P(r.height*n)}if(e.mask){if(Rr(e)&&Br(e.mask)){let r=e.mask;r.x=P(r.x*t),r.y=P(r.y*n),r.width=P(r.width*t),r.height=P(r.height*n)}wo(e.mask,[`feather`,`radius`],a)}if(e.type===`text`&&(wo(e,[`size`,`letterSpacing`],a),e.background)){let t=e.background.padding;e.background.padding=Array.isArray(t)?[P(t[0]*a),P(t[1]*a)]:typeof t==`number`?P(t*a):t,wo(e.background,[`radius`],a)}if(e.type===`shape`&&(wo(e,[`radius`],a),e.stroke&&wo(e.stroke,[`width`],a)),To(e.filters,a),e.effects)for(let t of Xr){let n=e.effects[t.id];wo(n,t.params.filter(e=>e.px).map(e=>e.name),a)}}),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}var Do=e=>{let t=((e+180)%360+360)%360-180;return t===-180?180:t};function Oo(e,t){if(e&&typeof e==`object`){if(e.type===`linear`)e.angle=P(Do(t.angle(e.angle??90)));else if(e.type===`radial`){let[n,r]=t.point(e.cx??.5,e.cy??.5);e.cx=P(n),e.cy=P(r)}}}function ko(e,t){Oo(e.canvas.background,t),vo(e.layers,e=>{Rr(e)||(e.type===`fill`&&Oo(e.fill,t),e.mask&&Vr(e.mask)&&Oo(e.mask.gradient,t))})}function Ao(e,t,n={}){let r=(Math.round(t/90)*90%360+360)%360;if(t%90!=0)throw new k(`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 mo(e);let i=mo(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 vo(i.layers,e=>{_o(e,n);let t=go(e,n);if(t){let[n,i]=s(t.x+t.width/2,t.y+t.height/2),a=e;a.x=P(n-t.width/2),a.y=P(i-t.height/2),a.rotation=Do((a.rotation??0)+r),a.rotation===0&&delete a.rotation}else if(e.mask&&Br(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:P(n-a/2),y:P(i-o/2),width:a,height:o})}}),ko(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 jo(e,t,n={}){if(t!==`horizontal`&&t!==`vertical`)throw new k(`invalid`,`axis must be "horizontal" or "vertical".`);let r=mo(e),i=e.canvas.width,a=e.canvas.height;return vo(r.layers,e=>{_o(e,n);let r=go(e,n);if(r){let n=e;t===`horizontal`?(n.x=P(i-r.x-r.width),e.type!==`text`&&(n.flipX=!n.flipX||void 0)):(n.y=P(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&&Br(e.mask)){let n=e.mask;t===`horizontal`?n.x=P(i-n.x-n.width):n.y=P(a-n.y-n.height)}}),ko(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 Mo(e){return qi(await Nr(e,Da,`The document`))}function No(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)=>No(t,Po(t,e,r.length-1-n)))),s}var Po=(e,t,n)=>({...va({layers:[e]})[0],parent:t?.id??null,index:n});function Fo(e){let t={},n=0,r=0,i=0,a=new Set;N(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)=>No(e,Po(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 Io(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=>!uo(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=Lo(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=>!uo(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 Lo(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 Ro(e,t,n={}){let r=await e.exists(`photo.json`)?await Mo(e).catch(()=>null):null,i=qi(t),a=Ki(i),o=Io(r,i);return jr(a)||n.dryRun||o.empty?{plan:o,issues:a,applied:!1}:(await Ia(e,i,{allowInvalid:!1}),{plan:o,issues:a,applied:!0})}var zo=[`set`,`merge`,`remove`,`addLayer`,`updateLayer`,`removeLayer`,`moveLayer`,`duplicateLayer`,`groupLayers`,`ungroup`,`addFilter`,`updateFilter`,`removeFilter`,`setMask`,`crop`,`resizeCanvas`,`resizeImage`,`rotateCanvas`,`flipCanvas`],Bo=new Set([`resizeImage`,`rotateCanvas`,`flipCanvas`]),Vo=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function F(e,t,n,r){return new k(t===`notFound`?`notFound`:t,`ops[${e}]: ${n}`,r,{opIndex:e})}function Ho(e,t,n){if(typeof t!=`string`)throw F(n,`invalid`,`"id" (a layer id) is required.`);let r=M(e.layers,t);if(!r)throw F(n,`notFound`,`No layer "${t}".`,`${wr(t,fa(e))}doc_summary / layer_list list the layer ids.`);return r}function Uo(e,t,n,r){let i=t.above??t.below;if(i!==void 0){let a=Ho(e,i,n);if(r&&(a.layer===r||pa(r,i)))throw F(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=Ho(e,t.parent,n);if(i.layer.type!==`group`)throw F(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||pa(r,i.layer.id)))throw F(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 Wo(e,t,n){let r=new Set(fa(e)),i=e=>{if(!Vo(e))throw F(n,`invalid`,`layer must be an object.`);if(!xi(e.id))throw F(n,`invalid`,`Invalid layer id ${JSON.stringify(e.id)}.`,`Ids start with a letter: "photo", "title", "badge-2".`);if(r.has(e.id))throw F(n,`conflict`,`A layer "${e.id}" already exists.`,`Use updateLayer to change it, or another id (e.g. "${Ci(e.id,r)}").`);r.add(e.id),e.type===`group`&&(e.children??[]).forEach(i)};i(t)}function Go(e,t,n){let r=so(e),i=(e,r)=>{e.id=r&&n?n:Ci(`${e.id}-copy`,t),t.add(e.id),e.type===`group`&&(e.children??[]).forEach(e=>i(e,!1))};return i(r,!0),r}function Ko(e,t){let n=e.layer;return Array.isArray(n.filters)||(n.filters=[]),n.filters}function qo(e,t,n,r){if(typeof t!=`number`||!Number.isInteger(t)||t<0||t>=e.length)throw F(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 I(e,t,n={}){if(!Array.isArray(t))throw new k(`invalid`,`ops must be an array of patch operations.`);let r=so(e);return t.forEach((e,t)=>{if(!Vo(e)||typeof e.op!=`string`)throw F(t,`invalid`,`Each op is an object with an "op" field.`,`Ops: ${zo.join(`, `)}.`);try{switch(e.op){case`set`:if(typeof e.path!=`string`)throw F(t,`invalid`,`"path" is required.`);io(r,e.path,so(e.value));break;case`merge`:{if(typeof e.path!=`string`)throw F(t,`invalid`,`"path" is required.`);let n;try{n=ro(r,e.path)}catch{n=void 0}io(r,e.path,oo(n,e.value));break}case`remove`:if(typeof e.path!=`string`)throw F(t,`invalid`,`"path" is required.`);if(!ao(r,e.path))throw F(t,`notFound`,`Nothing at "${e.path}".`);break;case`addLayer`:{if(!Vo(e.layer))throw F(t,`invalid`,`"layer" (a layer object) is required.`);Wo(r,e.layer,t);let n=Uo(r,e,t);n.container.splice(n.index,0,so(e.layer));break}case`updateLayer`:{let n=Ho(r,e.id,t);if(!Vo(e.set))throw F(t,`invalid`,`"set" (an object of fields to change) is required.`);for(let n of[`id`,`type`,`children`])if(n in e.set)throw F(t,`invalid`,`updateLayer cannot change "${n}".`,n===`children`?`Use addLayer / moveLayer with parent.`:`Remove the layer and add a new one.`);let i=oo(n.layer,e.set);n.container[n.index]=i;break}case`removeLayer`:{let n=Ho(r,e.id,t);n.container.splice(n.index,1);break}case`moveLayer`:{let n=Ho(r,e.id,t),i=n.layer;Uo(r,e,t,i),n.container.splice(n.index,1);let a=Uo(r,e,t,i);a.container.splice(a.index,0,i);break}case`duplicateLayer`:{let n=Ho(r,e.id,t),i=new Set(fa(r));if(e.newId!==void 0&&(!xi(e.newId)||i.has(e.newId)))throw F(t,`conflict`,`newId ${JSON.stringify(e.newId)} is invalid or taken.`);let a=Go(n.layer,i,e.newId);if(e.offset){let[n,r]=e.offset;if(!Number.isFinite(n)||!Number.isFinite(r))throw F(t,`invalid`,`offset must be [dx, dy] in px.`);N([a],e=>{Rr(e)?(e.x=(e.x??0)+n,e.y=(e.y??0)+r):e.mask&&Br(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 F(t,`invalid`,`"ids" (layers to group) is required.`);if(!xi(e.id)||fa(r).includes(e.id))throw F(t,`conflict`,`Group id ${JSON.stringify(e.id)} is invalid or taken.`);let n=[...new Set(e.ids)].map(e=>Ho(r,e,t)),i=n[0].container;if(n.some(e=>e.container!==i))throw F(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=Ho(r,e.id,t);if(n.layer.type!==`group`)throw F(t,`invalid`,`"${e.id}" is not a group.`);n.container.splice(n.index,1,...n.layer.children??[]);break}case`addFilter`:{let n=Ho(r,e.id,t);if(!Vo(e.filter)||typeof e.filter.type!=`string`)throw F(t,`invalid`,`"filter" ({ type, ...params }) is required.`,`e.g. { "type": "brightnessContrast", "contrast": 20 } — catalog_get section "filters".`);let i=Ko(n,t),a=e.index===void 0?i.length:Math.max(0,Math.min(i.length,e.index));i.splice(a,0,so(e.filter));break}case`updateFilter`:{let n=Ko(Ho(r,e.id,t),t),i=qo(n,e.index,t,e.id);if(!Vo(e.set))throw F(t,`invalid`,`"set" is required.`);n[i]=oo(n[i],e.set);break}case`removeFilter`:{let n=Ko(Ho(r,e.id,t),t);n.splice(qo(n,e.index,t,e.id),1);break}case`setMask`:{let n=Ho(r,e.id,t);e.mask===null||e.mask===void 0?delete n.layer.mask:n.layer.mask=so(e.mask);break}case`crop`:r=xo(r,e);break;case`resizeCanvas`:if(e.anchor!==void 0&&!po.includes(e.anchor))throw F(t,`invalid`,`Unknown anchor "${e.anchor}".`,`Anchors: ${po.join(`, `)}.`);if(!(e.width>=1)||!(e.height>=1))throw F(t,`invalid`,`resizeCanvas needs width ≥ 1 and height ≥ 1.`);r=Co(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 F(t,`invalid`,`resizeImage needs scale, width and/or height.`);r=Eo(r,o,s,n);break}case`rotateCanvas`:r=Ao(r,e.angle,n);break;case`flipCanvas`:r=jo(r,e.axis,n);break;default:throw F(t,`invalid`,`Unknown op "${e.op}".`,`${wr(e.op,zo)}Ops: ${zo.join(`, `)}.`)}}catch(n){throw n instanceof k?n.details?.opIndex===void 0?new k(n.code,`ops[${t}] (${e.op}): ${n.message}`,n.hint,{opIndex:t}):n:n instanceof Ya?new k(`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 Jo(e,t,n){let{imageInfo:r}=await Ta(async()=>{let{imageInfo:e}=await Promise.resolve().then(()=>Yi);return{imageInfo:e}},void 0,import.meta.url),i={},a=new Set;N(t.layers,e=>{e.type===`image`&&a.add(e.src)});for(let t of a)try{let a=ca(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 Yo(e,t,n={}){let r=await Mo(e),i=I(r,t,n.sizes??(Array.isArray(t)&&t.some(e=>Vo(e)&&Bo.has(e.op))?await Jo(e,r,n.readLibrary):{})),a=Ki(i),o=Io(r,i);return jr(a)||n.dryRun||o.empty?{plan:o,issues:a,applied:!1,doc:jr(a)?r:i}:(await Ia(e,i),{plan:o,issues:a,applied:!0,doc:i})}async function Xo(e,t={}){let n=await Mo(e),r=[...Ki(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 Ja(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;N(n.layers,e=>{e.type===`image`&&o.add(e.src)});for(let n of o)if(ca(n)){let e=ua(t.library,la(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=ia(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;N(n.layers,e=>{l++;let t=`layers#${e.id}`;for(let t of e.filters??[])t.enabled!==!1&&(u+=(ii(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=go(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 Va(e),p=new Set;N(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(!ca(e))continue;let n=ua(t.library,la(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:Ir(h),licences:m}}function Zo(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 Qo(e,t){let n=(e??[]).find(e=>e.id===t);if(!n){let n=Cr(t,(e??[]).map(e=>e.id));throw new k(`notFound`,`Unknown template "${t}".`,`${n?`Did you mean "${n}"? `:``}List templates with templates_list / \`agentphoto templates list\`.`)}return n}function $o(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}:{}}}function es(e,t,n=!0){let r=e[t];if(typeof r==`string`&&r.trim())return r.trim();if(n)throw new k(`invalid`,`Missing "${t}" (string).`);return``}function L(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function ts(e,t,n=!1){let r=e[t];return typeof r==`boolean`?r:n}function ns(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function rs(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 is(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 as(e,t){let n=is(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,...rs(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 os(e,t,n){if(t??={},typeof t!=`object`||Array.isArray(t))throw new k(`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 k(`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 k(`invalid`,`${n}: "${t}" must be ${a.join(` or `)}, got ${o}.`,r.description);if(r.enum&&!r.enum.includes(i))throw new k(`invalid`,`${n}: "${t}" must be one of ${r.enum.map(e=>JSON.stringify(e)).join(`, `)}.`)}return r}var ss={type:`boolean`,description:`Preview the plan and issues without writing (default false).`},cs={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},ls={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.`}},us=Object.keys(ri);function ds(e,t){if(!e)return{sections:{layerTypes:ri.layerTypes.map(e=>`${e.id} — ${e.description}`),filters:ri.filters.map(e=>`${e.id} (${e.group}) — ${e.description}`),looks:ri.looks.map(e=>`${e.id} — ${e.description}`),effects:ri.effects.map(e=>`${e.id} — ${e.description}`),blendModes:ri.blendModes,shapes:ri.shapes,fonts:ri.fonts.map(e=>`${e.id} (${e.style}, weights ${e.weights.join(`/`)}) — ${e.description}`),sizes:ri.sizes.map(e=>`${e.id} ${e.width}×${e.height} — ${e.title}`),models:ri.models.map(e=>`${e.id} (${e.task}, ${e.sizeMb} MB) — ${e.description}`)},commonFilterParams:ri.commonFilterParams,hint:`catalog_get { section: "filters", id: "curves" } gives the parameters (types, ranges, defaults) and an example of one entry.`};let n=us.find(t=>t.toLowerCase()===e.toLowerCase())??us.find(t=>t.toLowerCase().startsWith(e.toLowerCase()));if(!n){let t=Cr(e,us);throw new k(`notFound`,`Unknown catalog section "${e}".`,`${t?`Did you mean "${t}"? `:``}Sections: ${us.join(`, `)}.`)}let r=ri[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=Cr(t,e);throw new k(`notFound`,`No "${t}" in ${n}.`,`${i?`Did you mean "${i}"? `:``}Valid ids: ${Tr(e)}.`)}return{section:n,entry:i}}async function fs(e,t,n){let r=e.host?.library;return as(await Yo(e.fs,t,{dryRun:n,readLibrary:r?async e=>{let t=r.index.assets.find(t=>t.id===e);return t?.path?r.read(t.path):null}:void 0}),n)}async function ps(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 ms(e,r);if(!e.host?.readLocalFile)throw new k(`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?ms(e,i):null}async function ms(e,t){if(!e.fetch)throw new k(`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 k(`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 hs=[{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 Fa(e.fs);return{manifest:t,summary:Fo(n),counts:is(Ki(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 ps(e,t,`project_create`),r=L(t,`template`),i;if(r){if(!e.host?.templates)throw new k(`invalid`,`Templates are not available on this host.`);Qo(e.host.templates.index,r),i=await e.host.templates.files(r)}let a=await Ma(e.fs,{name:es(t,`name`),title:L(t,`title`),size:L(t,`size`),width:ns(t,`width`),height:ns(t,`height`),background:t.background,template:r,templateFiles:i,image:n??void 0,force:ts(t,`force`)});return{created:!0,manifest:a.manifest,files:a.files,summary:Fo(a.doc),...rs(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=>Mo(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=>Fo(await Mo(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:ss},required:[`doc`]},mutating:!0,async handler(e,t){let n=ts(t,`dryRun`);return as(await Ro(e.fs,t.doc,{dryRun:n}),n)}},{name:`doc_patch`,description:`Atomic list of edits, validated together (nothing written if any fails). Ops: ${zo.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 }. 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:ss},required:[`ops`]},mutating:!0,handler:(e,t)=>fs(e,t.ops,ts(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=Ki(t.doc??await Mo(e.fs));return{valid:!n.some(e=>e.severity===`error`),counts:is(n),...rs(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:va(await Mo(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:cs,...ls,dryRun:ss},required:[`layer`]},mutating:!0,handler:(e,t)=>fs(e,[{op:`addLayer`,layer:t.layer,parent:t.parent,index:ns(t,`index`),above:L(t,`above`),below:L(t,`below`)}],ts(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:ss},required:[`id`,`set`]},mutating:!0,handler:(e,t)=>fs(e,[{op:`updateLayer`,id:es(t,`id`),set:t.set}],ts(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:ss},required:[`id`]},mutating:!0,handler:(e,t)=>fs(e,[{op:`removeLayer`,id:es(t,`id`)}],ts(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`},...ls,dryRun:ss},required:[`id`]},mutating:!0,handler:(e,t)=>fs(e,[{op:`moveLayer`,id:es(t,`id`),parent:t.parent,index:ns(t,`index`),above:L(t,`above`),below:L(t,`below`)}],ts(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:ss},required:[`id`,`filter`]},mutating:!0,handler:(e,t)=>fs(e,[{op:`addFilter`,id:es(t,`id`),filter:t.filter,index:ns(t,`index`)}],ts(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:ss},required:[`id`]},mutating:!0,handler:(e,t)=>fs(e,[{op:`setMask`,id:es(t,`id`),mask:t.mask??null}],ts(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:us},id:{type:`string`}}},mutating:!1,handler:(e,t)=>ds(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:Zo(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 Xo(e.fs,{library:e.host?.library?.index});return{...t,...rs(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=>Ka(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 ps(e,t,`assets_add`);if(!n)throw new k(`invalid`,`assets_add needs file or url.`);let r=await Ga(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(!ts(t,`addLayer`))return{asset:r,hint:`Use it as { "type": "image", "src": "${r.path}" } (layer_add).`};let i=await Mo(e.fs),{uniqueId:a,slugify:o}=await Ta(async()=>{let{uniqueId:e,slugify:t}=await Promise.resolve().then(()=>yi);return{uniqueId:e,slugify:t}},void 0,import.meta.url),{allLayerIds:s}=await Ta(async()=>{let{allLayerIds:e}=await Promise.resolve().then(()=>da);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 fs(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)=>qa(e.fs,es(t,`path`),{force:ts(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}}}],gs=[`png`,`jpeg`,`webp`,`avif`],_s={png:`png`,jpeg:`jpg`,webp:`webp`,avif:`avif`},vs={png:100,jpeg:88,webp:86,avif:70};function ys(e,t={}){let n={...e.export??{},...bs(t)},r=n.format??`png`;if(!gs.includes(r))throw new k(`invalid`,`Unknown export format "${String(n.format)}".`,`${wr(String(n.format),gs)}Formats: ${gs.join(`, `)}.`);let i=Math.max(1,Math.min(100,Math.round(n.quality??vs[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 k(`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 k(`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=si(n.preset);if(!e)throw new k(`invalid`,`Unknown size preset "${n.preset}".`,`${wr(n.preset,Qr.map(e=>e.id))}Presets: ${Qr.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 k(`invalid`,`Export size ${s}×${c} exceeds ${Ei} 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&&!_i(p))throw new k(`invalid`,`Export background ${JSON.stringify(p)} is not a colour.`);r!==`jpeg`||p&&gi(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}.${_s[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 bs(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function xs(e){let t=e.host?.engine;if(!t)throw new k(`unavailable`,`This host cannot render images.`,"Run the CLI (`agentphoto`, needs Google Chrome / Chromium) or the Studio.");return t}var Ss={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`,"image/avif":`avif`};function Cs(e,t){let n=M(e.layers,t);if(!n)throw new k(`notFound`,`No layer "${t}".`,`layer_list lists the layer ids.`);return n.layer}function ws(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 Ts(e,t,n,r,i){let a=Cs(t,n),o=i.maskId??n,s=await Ga(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 Yo(e.fs,[...i.preOps??[],{op:`setMask`,id:o,mask:c},...i.extraOps??[]]).catch(async t=>{throw await Os(e.fs,s.path),t});l.applied||await Os(e.fs,s.path);let u=a.mask&&zr(a.mask)?a.mask.src:null;return l.applied&&u&&u!==s.path&&u.startsWith(`assets/masks/`)&&(ya(l.doc).some(e=>e.path===u)||await Os(e.fs,u)),{mask:s.path,size:`${r.width}×${r.height}`,...r.bbox===void 0?{}:{subject:Ds(a,r)},...as(l,!1)}}function Es(e,t){let{x:n,y:r,width:i,height:a}=t.source;if(n<=.5&&r<=.5&&i>=e.canvas.width-1&&a>=e.canvas.height-1)return[];let o=[],s=e=>{for(let t of e){if(t.visible===!1||(t.type===`group`&&s(t.children??[]),t.type!==`text`&&t.type!==`shape`))continue;let e=go(t);e&&(e.x<n-1||e.y<r-1||e.x+e.width>n+i+1||e.y+e.height>r+a+1)&&o.push(t.id)}};return s(e.layers),o}function Ds(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 Os(e,t){let{removeAsset:n}=await Ta(async()=>{let{removeAsset:e}=await Promise.resolve().then(()=>Ra);return{removeAsset:e}},void 0,import.meta.url);await n(e,t,{force:!0}).catch(()=>void 0)}var ks=[{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=xs(e),r=await Mo(e.fs),i=ns(t,`maxWidth`)??1e3,a=t.zoom;if(a){let{cropDoc:e}=await Ta(async()=>{let{cropDoc:e}=await Promise.resolve().then(()=>fo);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&&Cs(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(ts(t,`compare`)){let t=await n.render(ws(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: ${Qr.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:gs},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=xs(e),r=await Mo(e.fs),i={format:L(t,`format`),quality:ns(t,`quality`),preset:L(t,`preset`),width:ns(t,`width`),height:ns(t,`height`),scale:ns(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=[];for(let t of a){let i=ys(r,t),a=await n.exportImage(r,i),s=i.file,c;a.mime!==i.mime&&(s=s.replace(/\.[^.]+$/,`.${Ss[a.mime]??`png`}`),c=`${i.format.toUpperCase()} encoding is not supported by this browser: written as ${a.mime}.`),await e.fs.writeBytes(s,a.bytes);let l=Es(r,i);l.length&&(c=`${c?`${c} `:``}fit "cover" crops the canvas to ${Math.round(i.source.width)}×${Math.round(i.source.height)} and cuts layer${l.length>1?`s`:``} ${l.join(`, `)}: use fit "contain", or adapt the layout (doc_patch resizeCanvas / move layers) for this size.`),i.scale>1.05&&(c=`${c?`${c} `:``}Upscaled ×${Math.round(i.scale*100)/100} from the ${r.canvas.width}×${r.canvas.height} canvas: it may look soft.`),o.push({path:s,format:a.mime===`image/jpeg`?`jpeg`:Ss[a.mime]??i.format,width:a.width,height:a.height,kb:Math.round(a.bytes.byteLength/102.4)/10,...c?{note:c}:{}})}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 Mo(e.fs),r=L(t,`layer`);return r&&Cs(n,r),xs(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: ${$r.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:$r.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.`}},required:[`id`]},mutating:!0,needsEngine:!0,async handler(e,t){let n=es(t,`id`),r=await Mo(e.fs),i=Cs(r,n);if(i.type!==`image`)throw new k(`invalid`,`"${n}" is a ${i.type} layer: background removal works on image layers.`);let a=L(t,`model`)??ei[`background-removal`],o=await xs(e).backgroundMask(r,n,{model:a,feather:ns(t,`feather`),threshold:ns(t,`threshold`)}),s=[];if(t.background!==void 0&&t.background!==null){let e=Ci(`${n}-background`,fa(r));s.push({op:`addLayer`,layer:{id:e,type:`fill`,name:`Background`,fill:t.background},below:n})}return ts(t,`shadow`)&&s.push({op:`updateLayer`,id:n,set:{effects:{dropShadow:{color:`#000000`,opacity:.35,angle:90,distance:18,blur:30}}}}),{...await Ts(e,r,n,o,{label:`cutout`,extraOps:s,source:`remove_background:${a}`}),model:a,hint:`subject = the kept area in canvas px (null: nothing found). Center / scale the layer from it if needed, 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=es(t,`id`),r=es(t,`method`),i=await Mo(e.fs);Cs(i,n);let a=xs(e),o=ns(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 k(`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 k(`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:es(t,`color`),tolerance:ns(t,`tolerance`),feather:o});else throw new k(`invalid`,`Unknown method "${r}".`,`Methods: subject, points, box, color.`);let c=L(t,`target`)??`mask`,l=ts(t,`invert`);if(c===`copy`){let a=Ci(L(t,`copyId`)??`${n}-cutout`,fa(i));return{...await Ts(e,i,n,s,{label:r,invert:l,source:`mask_generate:${r}`,preOps:[{op:`duplicateLayer`,id:n,newId:a}],maskId:a}),layer:a}}return Ts(e,i,n,s,{label:r,invert:l,source:`mask_generate:${r}`})}}],As=`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(`.`),js=new Map([...hs,...ks].map(e=>[e.name,e])),Ms=As.map(e=>{let t=js.get(e);if(!t)throw Error(`AI tool ${e} is not implemented`);return t});function Ns(e,t={}){let n=Ms.filter(t=>!t.needsEngine||e?.engine);return t.readOnly?n.filter(e=>!e.mutating):n}function Ps(e,t){let n=Ns(t),r=n.find(t=>t.name===e);if(!r){if(js.get(e)?.needsEngine)throw new k(`unavailable`,`Tool "${e}" needs an image engine this host does not have.`,`Use the CLI (needs Google Chrome / Chromium) or the Studio.`);let t=Cr(e,n.map(e=>e.name));throw new k(`notFound`,`Unknown tool "${e}".`,`${t?`Did you mean "${t}"? `:``}Tools: ${n.map(e=>e.name).join(`, `)}.`)}return r}async function Fs(e,t,n){let r=Ps(t,e.host);return r.handler(e,os(r.inputSchema,n,t))}function Is(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 Ls=null,Rs=new Map,zs={};function Bs(e){zs={...zs,...e}}async function Vs(){return Ls||(Ls=Ta(()=>import(`./transformers.web-DgnCIB_X.js`).then(e=>(e.env.allowLocalModels=!1,zs.remoteHost&&(e.env.remoteHost=zs.remoteHost),zs.remotePathTemplate&&(e.env.remotePathTemplate=zs.remotePathTemplate),zs.wasmPaths&&e.env.backends?.onnx?.wasm&&(e.env.backends.onnx.wasm.wasmPaths=zs.wasmPaths),e.env.backends?.onnx?.wasm&&typeof crossOriginIsolated<`u`&&!crossOriginIsolated&&(e.env.backends.onnx.wasm.numThreads=1),e)),[],import.meta.url),Ls.catch(()=>Ls=null)),Ls}function Hs(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;zs.onProgress?.({model:e,progress:i/100,label:`Loading ${e} (${Math.round(i)} %)`})}}async function Us(e){let t=ci(e);if(!t)throw Error(`Unknown model "${e}". Models: ${$r.map(e=>e.id).join(`, `)}.`);let n=await Vs(),r=Rs.get(e);if(!r){let i=Hs(e);r=(async()=>{if(zs.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(()=>Rs.delete(e)),Rs.set(e,r)}let i=await r;return zs.onProgress?.({model:e,progress:1,label:`${e} ready`}),{...i,tf:n}}async function Ws(e,t=ei[`background-removal`]){if(ci(t)?.task!==`background-removal`)throw Error(`"${t}" is not a background-removal model.`);let{model:n,processor:r,tf:i}=await Us(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 Gs(e,t,n=ei.segmentation){if(ci(n)?.task!==`segmentation`)throw Error(`"${n}" is not a segmentation model.`);let{model:r,processor:i,tf:a}=await Us(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,Ks=e=>e<0?0:e>1?1:e;function qs(e){return{data:new Uint8ClampedArray(e.data),width:e.width,height:e.height}}function Js(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 Ys(e){let t=new Uint8ClampedArray(256);for(let n=0;n<256;n++)t[n]=Math.round(R(e(n)));return t}var Xs=(e,t,n)=>.299*e+.587*t+.114*n,Zs=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,Qs=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;function $s(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 ec(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 tc(e,t,n,r){if(r<.5)return;let i=new Float32Array(e.length);for(let a of ec(r/2))$s(e,t,n,Math.round(a),i)}function nc(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}tc(o,r,i,t),tc(s,r,i,t),tc(c,r,i,t),u||tc(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 rc(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]=Xs(n[e],n[e+1],n[e+2])/255;return tc(a,r,i,t),a}function ic(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];tc(i,t,n,r);for(let t=0;t<i.length;t++)e[t]=i[t]}function ac(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 oc(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 sc(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 cc(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[sc(i,r,e+1/3)*255,sc(i,r,e)*255,sc(i,r,e-1/3)*255]}function lc(e){let t=[...e].sort((e,t)=>e[0]-t[0]),n=t.length,r=new Uint8ClampedArray(256);if(n===0)return Ys(e=>e);if(n===1)return Ys(()=>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 uc(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(Xs(a[e],a[e+1],a[e+2]))]++,o++);return{r:t,g:n,b:r,l:i,count:o}}function dc(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 fc=(e,t)=>Ys(n=>(n-e)*255/Math.max(1,t-e));function pc(e){let{data:t,width:n,height:r}=e,i=uc(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=Xs(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]=dc(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 Xs(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:mc(d/(n*r)*100),brightness:mc(f),contrast:mc(p),range:[m,h],clippedShadows:mc(g/a*100),clippedHighlights:mc(_/a*100),saturation:mc(c/a*100),cast:{warm:mc(l/a),magenta:mc(u/a)},sharpness:mc(y?v/y:0),dominant:hc(e,5),suggestions:[]};return x.suggestions=gc(x),x}var mc=e=>Math.round(e*10)/10;function hc(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:vi({r:e.r,g:e.g,b:e.b,a:1}),share:mc(e.n/Math.max(1,a)*100)}))}function gc(e){let t=[];return e.brightness<85?t.push({issue:`Underexposed (mean brightness ${e.brightness}/255).`,filter:{type:`exposure`,exposure:mc(Math.min(1.5,(110-e.brightness)/45))}}):e.brightness>185&&t.push({issue:`Overexposed (mean brightness ${e.brightness}/255).`,filter:{type:`exposure`,exposure:mc(-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:mc(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:mc(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 _c=16384;function vc(e,t){let n=Math.max(1,Math.min(_c,Math.ceil(e))),r=Math.max(1,Math.min(_c,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 yc(e){let t=z(e).getImageData(0,0,e.width,e.height);return{data:t.data,width:t.width,height:t.height}}function bc(e,t){z(e).putImageData(new ImageData(t.data,t.width,t.height),0,0)}function xc(e){return!e||e===`normal`?`source-over`:e}function Sc(e,t){let n=vc(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 Cc(e){let t=yc(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 wc(e,t,n,r=[255,255,255]){let i=vc(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 bc(i,{data:a,width:t,height:n}),i}async function Tc(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 Ec=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t;function Dc(e,t){if(!e)return 0;let n=0;return e.dropShadow&&(n=Math.max(n,(Ec(e.dropShadow.distance,12)+Ec(e.dropShadow.blur,16)*1.5+Ec(e.dropShadow.spread,0))*t)),e.outerGlow&&(n=Math.max(n,(Ec(e.outerGlow.blur,20)*1.5+Ec(e.outerGlow.spread,0))*t)),e.stroke&&(e.stroke.position??`outside`)!==`inside`&&(n=Math.max(n,Ec(e.stroke.width,6)*t)),Math.ceil(n)+(n?2:0)}var Oc=e=>!!e&&Object.values(e).some(Boolean);function kc(e,t){let n=vc(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 Ac(e,t=96){let n=Cc(e);for(let e=0;e<n.length;e++)n[e]=n[e]>=t?255:n[e]*255/t;return wc(n,e.width,e.height)}function jc(e){let t=vc(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 Mc(e,t,n){if(t<.5)return Sc(e,n);let r=Cc(e);return ic(r,e.width,e.height,t),Sc(wc(r,e.width,e.height),n)}function Nc(e,t,n){let r=e.canvas,i=r.width,a=r.height,o=vc(i,a),s=z(o);if(t.dropShadow){let e=t.dropShadow,i=Ec(e.spread,0)*n,a=Mc(i?kc(r,i):r,Ec(e.blur,16)*n,e.color??`#000000`),o=Ec(e.angle,135)*Math.PI/180,c=Ec(e.distance,12)*n;s.globalAlpha=Ec(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=Ec(e.spread,0)*n,a=Mc(i?kc(r,i):r,Ec(e.blur,20)*n,e.color??`#ffffff`);s.globalAlpha=Ec(e.opacity,.6),s.drawImage(a,0,0),s.globalAlpha=Ec(e.opacity,.6)*.5,s.drawImage(a,0,0),s.globalAlpha=1}let c=t.stroke,l=c?Ec(c.width,6)*n:0,u=c?.position??`outside`;if(c&&l>0&&u!==`inside`){let e=u===`center`?l/2:l;s.globalAlpha=Ec(c.opacity,1),s.drawImage(Sc(kc(Ac(r),e),c.color??`#ffffff`),0,0),s.globalAlpha=1}let d=vc(i,a),f=z(d);if(f.drawImage(r,0,0),t.colorOverlay){let e=t.colorOverlay,n=Sc(r,e.color??`#ffffff`);f.globalAlpha=Ec(e.opacity,1),f.globalCompositeOperation=xc(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=Mc(jc(r),Ec(e.blur,10)*n,e.color??`#000000`),s=Ec(e.angle,135)*Math.PI/180,c=Ec(e.distance,6)*n,l=vc(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=Ec(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=jc(kc(jc(r),e)),n=Sc(r,c.color??`#ffffff`),i=z(n);i.globalCompositeOperation=`destination-out`,i.drawImage(t,0,0),f.globalAlpha=Ec(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 Pc(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 Fc(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 Ic(e,t){for(let n=0;n<e.length;n+=4){let r=Xs(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 Lc(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 Rc(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 zc(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 Bc(e,t,n){for(let r=0;r<e.length;r+=4){let i=Xs(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 Vc={bw:e=>Ic(e.data,0),noir:e=>{Ic(e.data,0),Fc(e.data,1.55),Lc(e.data,.85,.85,.85),Rc(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=>{Pc(e.data,8,-6,-16,1,1,.92),Ic(e.data,.7),Fc(e.data,.92),Lc(e.data,1.05,1,.9),Rc(e,.35)},polaroid:e=>{Pc(e.data,12,4,-8),Ic(e.data,.85),Fc(e.data,.95)},lomo:e=>{Ic(e.data,1.45),Fc(e.data,1.25),Rc(e,.55)},warm:e=>{Pc(e.data,18,6,-14),Ic(e.data,1.1)},cool:e=>{Pc(e.data,-10,0,16),Ic(e.data,.95)},sunset:e=>{Pc(e.data,28,-4,-24,1,1,.95),Ic(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;Ic(t,.85)},punch:e=>{Ic(e.data,1.4),Fc(e.data,1.2)},cinema:e=>{Bc(e.data,[-6,2,14],[20,6,-14]),Fc(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);Fc(t,1.25),Ic(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);Fc(t,1.18),Ic(t,1.15)},dramatic:e=>{Fc(e.data,1.5),Lc(e.data,.85,.85,.85),Ic(e.data,.6),Rc(e,.4)},dreamy:e=>{Pc(e.data,14,8,16),Ic(e.data,.85),Fc(e.data,.88),Lc(e.data,1.1,1.05,1.1)},matte:e=>{zc(e.data,28,.86),Ic(e.data,.82),Bc(e.data,[0,4,8],[6,2,-4])},"golden-hour":e=>{Bc(e.data,[6,-2,-10],[26,12,-20]),Ic(e.data,1.12),Lc(e.data,1.06,1.02,.96)},film:e=>{zc(e.data,14,.92),Fc(e.data,1.06),Bc(e.data,[-4,2,8],[10,4,-6]),Ic(e.data,.92);let t=ac(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=>{Lc(e.data,1.08,1.08,1.1),Pc(e.data,-2,0,4),Fc(e.data,1.06),Ic(e.data,1.05)}},B=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,Hc=(e,t)=>typeof e==`boolean`?e:t,Uc=e=>Array.isArray(e)&&e.length===3?[B(e[0],0),B(e[1],0),B(e[2],0)]:[0,0,0],Wc=(e,t)=>gi(typeof e==`string`?e:t)??gi(t);function Gc(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)),Wc(e[1],`#000`)]:[t/(n.length-1),Wc(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?Ks((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 Kc(e,t,n){let r=n-Xs(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 qc={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;Js(e,Ys(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);Js(e,Ys(e=>255*Qs(Ks(Math.max(0,Zs(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=rc(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);Js(e,Ys(e=>a+(o-a)*Ks((e-n)/(r-n))**(1/i)))},curves(e,t){let n=Ys(e=>e),r=Array.isArray(t.rgb)?lc(t.rgb):n,i=e=>Array.isArray(e)?lc(e):n,[a,o,s]=[i(t.red),i(t.green),i(t.blue)];Js(e,Ys(e=>a[r[e]]),Ys(e=>o[r[e]]),Ys(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=Hc(t.colorize,!1),o=e.data;for(let e=0;e<o.length;e+=4){let[t,s,c]=oc(o[e],o[e+1],o[e+2]);a?(t=n,s=Ks(.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]=cc(t,Ks(s),Ks(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=Xs(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=>Ys(t=>255*Qs(Ks(Zs(t/255)*e)));Js(e,s(i),s(a),s(o))},colorBalance(e,t){let n=Uc(t.shadows),r=Uc(t.midtones),i=Uc(t.highlights),a=Hc(t.preserveLuminosity,!0),o=e.data;for(let e=0;e<o.length;e+=4){let t=Xs(o[e],o[e+1],o[e+2]),s=t/255,c=Ks(1-s*2.2)*.8,l=Ks(1-Math.abs(s-.5)*2.5)*.8,u=Ks((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&&Kc(o,e,t)}},photoFilter(e,t){let n=Wc(t.color,`#ec8a00`),r=Ks(B(t.density,25)/100),i=Hc(t.preserveLuminosity,!0),a=e.data;for(let e=0;e<a.length;e+=4){let t=Xs(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&&Kc(a,e,t)}},gradientMap(e,t){let[n,r,i]=Gc(t.stops),a=e.data;for(let e=0;e<a.length;e+=4){let t=Math.round(Xs(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=Ks(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){Js(e,Ys(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=Xs(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);Js(e,Ys(e=>Math.round(e/n)*n))},blur(e,t,n){nc(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}=qs(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 tc(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=qs(e);nc(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=rc(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=Xs(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=Hc(t.monochrome,!0),a=ac(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=Wc(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=Ks((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=uc(e);if(!r.count)return;let[i,a]=dc(r.r,r.count,n),[o,s]=dc(r.g,r.count,n),[c,l]=dc(r.b,r.count,n);Js(e,fc(i,a),fc(o,s),fc(c,l))},autoContrast(e,t){let n=uc(e);if(!n.count)return;let[r,i]=dc(n.l,n.count,B(t.clip,.5));Js(e,fc(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;Js(e,Ys(e=>e*u(s)),Ys(e=>e*u(c)),Ys(e=>e*u(l))),qc.autoContrast(e,{clip:.3},{scale:1})},look(e,t){let n=Vc[String(t.look)];n&&n(e)}};function Jc(e,t,n){for(let r of t??[]){if(!r||r.enabled===!1)continue;let t=qc[r.type];if(!t)continue;let i=!ii(r.type)?.params.some(e=>e.name===`amount`)&&typeof r.amount==`number`?Ks(r.amount):1;if(i<=0)continue;let a=Yc(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 Yc(e){let t=ii(e.type),n={};for(let e of t?.params??[])e.default!==void 0&&(n[e.name]=e.default);return{...n,...e}}new Set(Jr.filter(e=>e.group===`blur`||e.group===`detail`||e.id===`shadowsHighlights`||e.id===`pixelate`).map(e=>e.id));function Xc(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 Zc(e,t,n,r=`#ffffff`){if(t==null)return r;if(typeof t==`string`)return t;let i;if(t.type===`radial`){let r=n.x+(t.cx??.5)*n.w,a=n.y+(t.cy??.5)*n.h,o=Math.max(.5,(t.radius??1)*Math.hypot(n.w,n.h)*.5);i=e.createRadialGradient(r,a,0,r,a,o)}else{let r=(t.angle??90)*Math.PI/180,a=Math.cos(r),o=Math.sin(r),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;i=e.createLinearGradient(c-a*s,l-o*s,c+a*s,l+o*s)}for(let[e,n]of Xc(t.stops))try{i.addColorStop(e,n)}catch{}return i}var Qc=null,$c=()=>Qc??=z(vc(8,8));function el(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 tl=(e,t)=>e.transform===`uppercase`?t.toUpperCase():e.transform===`lowercase`?t.toLowerCase():t;function nl(e,t){return`letterSpacing`in e&&(e.letterSpacing=`${t}px`,!0)}function rl(e,t,n,r){return t?r||!n?e.measureText(t).width:e.measureText(t).width+n*(Array.from(t).length-1):0}function il(e,t,n=1){let r=$c(),i=(e.size??64)*n,a=(e.letterSpacing??0)*n,o=el(e,t,i);r.font=o;let s=nl(r,a),c=e.width===void 0?1/0:e.width*n,l=[];for(let t of tl(e,String(e.text??``)).split(`
11
+ `)){let e=t.split(/(\s+)/),n=``;for(let t of e){let e=n+t;if(n&&rl(r,e.trimEnd(),a,s)>c&&t.trim())for(l.push({text:n.trimEnd(),width:rl(r,n.trimEnd(),a,s)}),n=t.trimStart();rl(r,n,a,s)>c&&n.length>1;){let e=n.length-1;for(;e>1&&rl(r,n.slice(0,e),a,s)>c;)e--;l.push({text:n.slice(0,e),width:rl(r,n.slice(0,e),a,s)}),n=n.slice(e)}else n=e}l.push({text:n.trimEnd(),width:rl(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&&nl(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 al(e){let t=e.background?.padding??0;return Array.isArray(t)?[t[0],t[1]]:[t,t]}function ol(e,t,n){let r=il(e,t,n),i=r.width*n,a=r.height*n,[o,s]=e.background?al(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=vc(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(),sl(f,l-o,u-s,i+o*2,a+s*2,t),f.fill()}f.font=r.font;let p=nl(f,(e.letterSpacing??0)*n);f.textBaseline=`alphabetic`,f.fillStyle=Zc(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 sl(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 cl=96,ll=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=vc(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=Zc(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(!Rr(e))return null;let t=e.x??0,n=e.y??0,r=e.rotation??0;if(e.type===`text`){let i=il(e,await this.family(e),1);return{x:t,y:n,width:i.width,height:i.height,rotation:r}}if(e.type===`image`){let{w:i,h:a}=fl(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&&oi(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&&!dl(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=gl(l,o)),a.save(),a.globalAlpha=ul(c.opacity??1),a.globalCompositeOperation=xc(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):Rr(e)&&(o=await this.boxSurface(e,n)),o&&e.type!==`group`&&e.type!==`adjustment`&&!Rr(e)&&e.mask&&(o={...o,canvas:await this.maskCanvasSpace(o.canvas,e.mask,t,n)}),o&&Oc(e.effects)&&(o=Nc(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&&zr(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(`,`)}|${co(e)}`}evict(){if(this.cache.size<=cl)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-cl))this.cache.delete(t)}async groupSurface(e,t,n,r){let i=vc(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&&pl(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=vc(r,i),o=z(a);return o.fillStyle=Zc(o,e.fill,{x:0,y:0,w:r,h:i}),o.fillRect(0,0,r,i),e.filters?.length&&pl(a,e.filters,n),{canvas:a,x:0,y:0}}async adjust(e,t,n){if(!e.filters?.length)return null;let r=vc(t.width,t.height);return z(r).drawImage(t,0,0),pl(r,e.filters,n),e.mask&&e.mask.enabled!==!1&&hl(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`?ol(e,await this.family(e),t):_l(e,t),!n||n.w<=0||n.h<=0)return null;if(e.filters?.length&&pl(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])}}hl(n.canvas,i)}let r=Dc(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=vc(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}=fl(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=vc(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=oi(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&&ic(i,t,n,e.feather*r);let a=ul(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(zr(e))return this.loader.image(e.src).then(e=>{let r=vc(t,n);return z(r).drawImage(e,0,0,t,n),a(ml(r))});let o=vc(t,n),s=z(o);if(Br(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):sl(s,t,n,i,a,(e.radius??0)*r),s.fill()}else Vr(e)&&(s.fillStyle=Zc(s,e.gradient,{x:0,y:0,w:t,h:n}),s.fillRect(0,0,t,n));return a(ml(o))}async maskCanvasSpace(e,t,n,r){return t.enabled===!1||hl(e,await this.maskPlane(t,e.width,e.height,r,null)),e}},ul=e=>e<0?0:e>1?1:e;function dl(e,t){return t.has(e.id)?!0:e.type===`group`&&(e.children??[]).some(e=>dl(e,t))}function fl(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 pl(e,t,n){if(!t?.some(e=>e&&e.enabled!==!1))return;let r=yc(e);Jc(r,t,{scale:n}),bc(e,r)}function ml(e){let t=yc(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 hl(e,t){let n=yc(e),r=n.data;for(let e=0,n=3;e<t.length;e++,n+=4)r[n]=r[n]*t[e]/255;bc(e,n)}function gl(e,t){let n=vc(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 _l(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=vc(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(),vl(s,e,c,t),e.shape!==`line`&&e.fill!==null&&(s.fillStyle=Zc(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 vl(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:sl(e,i,a,o,s,(t.radius??0)*r)}}var yl=(e,t)=>`${e.replace(/\/?$/,`/`)}${t.split(`/`).map(encodeURIComponent).join(`/`)}`;async function bl(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 xl(e){let t=e.fetchImpl??fetch.bind(globalThis),n=e.library,r=new Map,i=new Map,a=new Map,o=async t=>{if(ca(t)){let r=ua(n,la(t));if(!r?.path)throw Error(`Unknown library image "${t}".`);return yl(e.libraryBase,r.path)}if(/^(blob:|data:)/.test(t))return t;let r=e.resolve?await e.resolve(t):yl(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 bl(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=oi(t),s=ua(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(${yl(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 Sl=class{loader;compositor;constructor(e,t){this.loader=t??xl(e),this.compositor=new ll(this.loader),e.ai&&Bs(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=vc(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),Dl(i,t.mime,t.quality)}async analyze(e,t={}){return pc(yc(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=M(e.layers,t);if(!r)throw Error(`No layer "${t}".`);let i=r.layer,a=n.maxSide??2048;if(!Rr(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:[Cl(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={...Cl(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 El(wl(await Ws(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(M(e.layers,t).layer),o=a?i.width/a.width:1;return El(wl(await Gs(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=yc(await this.layerPixels(e,t,{maxSide:2048,withFilters:!0})),i=z(vc(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 El(wl(l,r.width,r.height,{feather:n.feather}),r.width,r.height)}};function Cl(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 wl(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&&ic(e,t,n,r.feather),e}function Tl(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 El(e,t,n){let r=Tl(e,t,n),i=vc(t,n),a=z(i);return a.fillStyle=`#000`,a.fillRect(0,0,t,n),a.drawImage(wc(e,t,n),0,0),{...await Dl(i,`image/png`),bbox:r}}async function Dl(e,t,n=100){let r=await Tc(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 Ol=`agentphoto-studio`,kl=`projects`,Al=null;function jl(){return typeof indexedDB>`u`?Promise.resolve(null):(Al||=new Promise(e=>{try{let t=indexedDB.open(Ol,1);t.onupgradeneeded=()=>t.result.createObjectStore(kl,{keyPath:`id`}),t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)}catch{e(null)}}),Al)}async function Ml(e,t){let n=await jl();if(n)return new Promise(r=>{let i=t(n.transaction(kl,e).objectStore(kl));i.onsuccess=()=>r(i.result),i.onerror=()=>r(void 0)})}var Nl={async list(){return(await Ml(`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 Ml(`readonly`,t=>t.get(e))},async put(e){await Ml(`readwrite`,t=>t.put(e))},async remove(e){await Ml(`readwrite`,t=>t.delete(e))}},Pl=class extends Er{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 Nl.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 Fl(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=>Dl(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=[];N(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 Il=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`}},Ll=`./library/`,Rl=`./ort/`,zl=`./templates/`,Bl=`apfs:`,Vl=e=>new URL(e,location.href).href,Hl=e=>{let t=sa(e);return t?Xi[t]:e.endsWith(`.json`)?`application/json`:`application/octet-stream`};async function Ul(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 Wl=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 Ul(`${Ll}index.json`);try{e&&(this.libraryIndex=JSON.parse(new TextDecoder().decode(e)))}catch{}let t=await Ul(`${zl}index.json`);try{let e=t?JSON.parse(new TextDecoder().decode(t)):[];this.templateIndex=e.map(e=>({...$o(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:Hl(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(Bl))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":Hl(n)}})}catch{return new Response(null,{status:404})}};engineOptions(){return{assetBase:Bl,libraryBase:Ll,library:this.libraryIndex,resolve:e=>Bl+encodeURIComponent(e),fetchImpl:this.fetchFile,ai:{wasmPaths:Vl(Rl),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 Sl(this.engineOptions()),{engine:Fl(this.engine),library:{index:e,read:async e=>{let t=await Ul(Ll+e);if(!t)throw new k(`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 k(`notFound`,`Unknown template "${e}".`);let n={};for(let r of t.files){let t=await Ul(`${zl}${e}/${r}`);t&&(n[r]=t)}return n}},readLocalFile:async e=>{let t=this.uploads.get(e);if(!t)throw new k(`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 Il(`no-project`,`No project is open.`);return this.fs}async loadDoc(){return qi(JSON.parse(await this.requireFs().readText(`photo.json`)))}async tools(){return Ns(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 Fs({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 k?new Il(e.code,e.message,e.hint,e.details):e instanceof Il?e:new Il(`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 Ll}async templates(){return this.templateIndex.map(({files:e,...t})=>t)}templatePreview(e){return`${zl}${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 Ga(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=Si(e.title,`photo`),n=`${t}-${Date.now().toString(36)}`;this.title=e.title,this.thumb=void 0;let r=new Pl(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 Ul(Ll+t.path):null;if(!t?.path||!r)throw new Il(`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 Nl.list()}async open(e){let t=await Nl.get(e);if(!t)throw new Il(`notFound`,`This project is no longer stored in this browser.`);this.title=t.title,this.thumb=t.thumb,this.attach(new Pl(t.id,t.files,()=>({title:this.title,thumb:this.thumb})))}async remove(e){await Nl.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}},Gl=e=>e.split(`/`).map(encodeURIComponent).join(`/`),Kl=e=>new URL(e,location.href).href;async function ql(e,t,n=fetch){let r;try{r=await n(e,t)}catch(e){throw new Il(`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 Il(`bad-response`,`Unexpected response from ${e} (HTTP ${r.status}).`)}if(i&&typeof i==`object`&&`ok`in i){if(!i.ok)throw new Il(i.error.code,i.error.message,i.error.hint,i.error.details);return i.data}if(!r.ok)throw new Il(`http`,`HTTP ${r.status} from ${e}.`);return i}async function Jl(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 Yl=`agentphoto.studio.recentDirs`,Xl=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&&Ql(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 Il(`notFound`,`photo.json could not be read.`);return qi(await e.json())}tools(){return this.toolsCache||=ql(`./api/tools`).then(e=>e.tools),this.toolsCache}call(e,t){return ql(`./api/tools/call`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e,input:t})})}library(){return this.libraryCache||=ql(`./api/library`).catch(()=>({assets:[]})),this.libraryCache}libraryBase(){return this.info.libraryBase}async templates(){try{let e=await ql(`./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/${Gl(this.rel(e))}?v=${Date.now()}`}async readFile(e){let t=await fetch(`./api/project/${Gl(this.rel(e))}`,{cache:`no-store`});if(!t.ok)throw new Il(`notFound`,`No file ${e}.`);return new Uint8Array(await t.arrayBuffer())}async writeFile(e,t){await ql(`./api/project/${Gl(e)}`,{method:`PUT`,body:t})}async listFiles(e){try{let t=await ql(`./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=ia(t),r=Ua(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:Kl(`${this.info.engineBase.replace(/\/?$/,`/`)}ort/`)}:{},...this.info.modelsBase?{remoteHost:Kl(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:Si(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=ia(e.image.bytes);if(!n)throw new Il(`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 Jl()??this.info,this.info.project?.exists&&Ql(this.info.project.dir,this.projectTitle())}async recent(){return Zl()}async open(){}close(){}};function Zl(){try{let e=JSON.parse(localStorage.getItem(Yl)??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function Ql(e,t){try{let n=[{id:e,title:t,updatedAt:new Date().toISOString()},...Zl().filter(t=>t.id!==e)].slice(0,8);localStorage.setItem(Yl,JSON.stringify(n))}catch{}}var $l={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.`}},eu={en:$l,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.`}}},tu=`agentphoto.studio.lang`;function nu(){try{let e=new URLSearchParams(location.search).get(`lang`);if(e===`en`||e===`fr`)return e;let t=localStorage.getItem(tu);if(t===`en`||t===`fr`)return t}catch{}return(typeof navigator<`u`?navigator.languages?.[0]??navigator.language:`en`)?.toLowerCase().startsWith(`fr`)?`fr`:`en`}var ru=nu(),iu=new Set;function au(e){ru=e;try{localStorage.setItem(tu,e)}catch{}document.documentElement.lang=e,iu.forEach(e=>e())}function ou(){return ru}function su(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 cu(e,t,n){let r=su(eu[e],t)??su($l,t)??t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>t in n?String(n[t]):e):r}function V(e,t=ru){return su(eu[t],e)??su($l,e)}function H(e,t){return cu(ru,e,t)}function U(){return{t:H,lang:(0,S.useSyncExternalStore)(e=>(iu.add(e),()=>iu.delete(e)),()=>ru),setLang:au}}function lu(e){try{return new URLSearchParams(location.search).get(e)??new URLSearchParams(location.hash.replace(/^#/,``)).get(e)}catch{return null}}function uu(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=uu(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function W(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=uu(e))&&(r&&(r+=` `),r+=t);return r}var du=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})),G=t(((e,t)=>{t.exports=du()}))();function fu({variant:e=`subtle`,size:t=`sm`,className:n,...r}){return(0,G.jsx)(`button`,{type:`button`,...r,className:W(`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`,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 K({label:e,active:t,className:n,children:r,shortcut:i,...a}){return(0,G.jsx)(`button`,{type:`button`,"aria-label":e,title:i?`${e} (${i})`:e,"aria-pressed":t,...a,className:W(`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 pu({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,G.jsx)(`textarea`,{...u,rows:2,onKeyDown:t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&l(),t.key===`Escape`&&c(e)},className:W(`field h-auto min-h-[44px] resize-y py-1 leading-snug`,a&&`font-mono text-xs`,r)}):(0,G.jsx)(`input`,{...u,spellCheck:!1,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&(c(e),requestAnimationFrame(()=>t.target.blur()))},className:W(`field`,a&&`font-mono text-xs`,r)})}function mu({value:e,options:t,onChange:n,className:r,ariaLabel:i,placeholder:a}){return(0,G.jsxs)(`select`,{"aria-label":i,value:e,onChange:e=>n(e.target.value),className:W(`field`,r),children:[a!==void 0&&(0,G.jsx)(`option`,{value:``,children:a}),t.map(e=>{let t=typeof e==`string`?e:e.value;return(0,G.jsx)(`option`,{value:t,children:typeof e==`string`?e:e.label},t)})]})}function hu({checked:e,onChange:t,ariaLabel:n}){return(0,G.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,onClick:()=>t(!e),className:W(`relative h-4 w-7 shrink-0 rounded-full transition-colors`,e?`bg-accent`:`bg-ink-4`),children:(0,G.jsx)(`span`,{className:W(`absolute top-0.5 h-3 w-3 rounded-full bg-white shadow transition-[left]`,e?`left-[14px]`:`left-0.5`)})})}function q({label:e,children:t,hint:n,onReset:r,overridden:i,align:a=`center`}){return(0,G.jsxs)(`div`,{className:W(`group grid grid-cols-[86px_minmax(0,1fr)_14px] gap-x-2 px-3 py-[3px]`,a===`center`?`items-center`:`items-start`),children:[(0,G.jsx)(`div`,{className:W(`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,G.jsx)(`div`,{className:`flex min-w-0 items-center gap-1`,children:t}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:r&&i&&(0,G.jsx)(`button`,{type:`button`,title:H(`ui.reset`),"aria-label":H(`ui.reset`),onClick:r,className:`text-fg-faint opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,children:(0,G.jsx)(cn,{size:11})})})]})}function gu({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,G.jsxs)(`section`,{className:`border-b border-line`,children:[(0,G.jsxs)(`div`,{className:`flex h-8 items-center gap-1 pl-2 pr-2`,children:[(0,G.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,G.jsx)(we,{size:12,className:`text-fg-faint`}):(0,G.jsx)(De,{size:12,className:`text-fg-faint`}),(0,G.jsx)(`span`,{className:`truncate`,children:e})]}),r]}),o&&(0,G.jsx)(`div`,{className:`pb-2`,children:t})]})}function _u({children:e}){return(0,G.jsx)(`kbd`,{className:`rounded border border-line bg-ink-2 px-1 font-sans text-2xs text-fg-muted`,children:e})}function vu({icon:e,title:t,children:n}){return(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-8 text-center`,children:[e&&(0,G.jsx)(`div`,{className:`text-fg-faint`,children:e}),(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg-muted`,children:t}),n&&(0,G.jsx)(`div`,{className:`text-xs text-fg-faint`,children:n})]})}function yu(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 bu(e,t){return(0,S.useSyncExternalStore)(e.subscribe,()=>t(e.get()))}var xu=(0,S.createContext)(null);function J(){let e=(0,S.useContext)(xu);if(!e)throw Error(`useEditor outside EditorContext`);return e}function Su(){let{store:e}=J();return(0,S.useSyncExternalStore)(e.subscribe,e.getSnapshot)}function Cu(){return Su().doc}function Y(e){return bu(J().ui,e)}function wu(){let e=Su(),t=e.selection[e.selection.length-1];return!t||!e.doc?null:M(e.doc.layers,t)?.layer??null}var Tu=[`claude-sonnet-5-5`,`claude-opus-5-5`,`claude-haiku-5-5`],Eu=`https://api.anthropic.com/v1/messages`,Du=class extends Error{status;constructor(e,t){super(t),this.status=e}};function Ou(e){return/\.jpe?g$/i.test(e)?`image/jpeg`:/\.webp$/i.test(e)?`image/webp`:`image/png`}function ku(e,t=24e3){return e.length>t?`${e.slice(0,t)}\n… (truncated, ${e.length-t} more characters)`:e}async function Au(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(Eu,{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 Du(a.status,e)}return o}async function ju(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 Au(e,i,r)}catch(t){if(r&&t instanceof Du&&t.status===400&&/fallback|beta/i.test(t.message))r=!1,a=await Au(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:ku(JSON.stringify(t))}],i=[];for(let a of e.readImage?Is(n.name,t).slice(0,4):[]){let t=await e.readImage(a).catch(()=>null);t&&(r.push({type:`image`,source:{type:`base64`,media_type:Ou(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:ku(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 Mu=`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.`,Nu=`agentphoto.studio.anthropicKey`,Pu=`agentphoto.studio.model`,Fu=e=>{try{return localStorage.getItem(e)??``}catch{return``}},Iu=(e,t)=>{try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}},Lu=new Map,Ru=0,zu=()=>`i${Date.now().toString(36)}${(Ru++).toString(36)}`;function Bu(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function Vu(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 Hu(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 Uu({text:e}){let t=(e,t)=>e.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((e,n)=>e.startsWith("`")&&e.endsWith("`")?(0,G.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,G.jsx)(`strong`,{children:e.slice(2,-2)},`${t}${n}`):e);return(0,G.jsx)(`div`,{className:`space-y-1.5`,children:e.split(/\n{2,}/).map((e,n)=>/^\s*[-*] /.test(e)?(0,G.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.split(`
24
+ `).map((e,r)=>(0,G.jsx)(`li`,{children:t(e.replace(/^\s*[-*] /,``),`${n}-${r}-`)},r))},n):(0,G.jsx)(`p`,{className:`whitespace-pre-wrap`,children:t(e,`${n}-`)},n))})}function Wu(){let{t:e}=U(),{backend:t,store:n,tools:r,reloadDoc:i,ui:a}=J(),o=t.location??`default`,[s,c]=(0,S.useState)(()=>Lu.get(o)??{messages:[],items:[]}),[l,u]=(0,S.useState)(()=>Fu(Nu)),[d,f]=(0,S.useState)(()=>Fu(Pu)||`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)(()=>{Lu.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?M(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:zu(),text:a}]})),await n.flush();let b=new Set(r.filter(e=>e.mutating).map(e=>e.name)),S=new Map,C=``,w=await ju({apiKey:l,model:d,system:Mu,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=>Bu(await t.readFile(e)),onEvent:n=>{n.type===`text`?ee(e=>[...e,{kind:`assistant`,id:zu(),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:Vu(n.result),images:e,before:S.get(n.id)})})():n.type===`refusal`&&ee(t=>[...t,{kind:`notice`,id:zu(),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:zu(),text:w.error??`Error`,tone:`error`}]:[],...w.status===`aborted`?[{kind:`notice`,id:zu(),text:e(`assistant.stopped`)}]:[],...w.status===`max_iterations`?[{kind:`notice`,id:zu(),text:e(`assistant.maxIterations`)}]:[]]}))},w=!!l;return(0,G.jsxs)(`aside`,{className:`flex w-[360px] shrink-0 flex-col border-l border-line bg-ink-1`,"aria-label":e(`assistant.title`),children:[(0,G.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-line pl-3 pr-1.5`,children:[(0,G.jsx)(me,{size:15,className:`text-agent`}),(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e(`assistant.title`)}),(0,G.jsx)(`select`,{value:d,onChange:e=>(f(e.target.value),Iu(Pu,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:Tu.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:`ml-auto flex`,children:[(0,G.jsx)(K,{label:e(`assistant.newChat`),disabled:_,onClick:()=>c({messages:[],items:[]}),children:(0,G.jsx)(Rn,{size:14})}),(0,G.jsx)(K,{label:e(`assistant.settings`),active:p,onClick:()=>m(e=>!e),children:(0,G.jsx)(bn,{size:14})}),(0,G.jsx)(K,{label:e(`assistant.close`),onClick:()=>a.set({assistant:!1}),children:(0,G.jsx)(vr,{size:14})})]})]}),(!w||p)&&(0,G.jsx)(Gu,{apiKey:l,onSave:e=>(u(e),Iu(Nu,e||null),m(!1))}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2 pt-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-sm text-fg-muted`,children:e(`assistant.emptyTitle`)}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1`,children:[e(`assistant.example1`),e(`assistant.example2`),e(`assistant.example3`)].map(e=>(0,G.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,G.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,G.jsx)(`div`,{className:`leading-relaxed text-fg`,children:(0,G.jsx)(Uu,{text:t.text})},t.id):t.kind===`notice`?(0,G.jsx)(`div`,{className:W(`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,G.jsxs)(`div`,{className:W(`rounded-md border bg-ink-0/40`,t.mutating&&t.status===`done`?`border-agent/30`:`border-line`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[t.status===`running`?(0,G.jsx)(Nt,{size:12,className:`animate-spin text-fg-muted`}):t.status===`error`?(0,G.jsx)(ke,{size:12,className:`text-danger`}):t.status===`undone`?(0,G.jsx)(cn,{size:12,className:`text-fg-faint`}):t.mutating?(0,G.jsx)($t,{size:12,className:`text-agent`}):(0,G.jsx)(Se,{size:12,className:`text-fg-faint`}),(0,G.jsx)(`span`,{className:`font-mono text-2xs text-fg`,children:t.name}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-2xs text-fg-faint`,children:Hu(t.name,t.input)}),t.mutating&&t.status===`done`&&t.before&&(0,G.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,G.jsx)(`div`,{className:W(`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,G.jsx)(`div`,{className:W(`grid gap-px border-t border-line/70`,t.images.length>1&&`grid-cols-2`),children:t.images.map(t=>(0,G.jsx)(`img`,{src:t,alt:e(`assistant.renderAlt`),className:`checker-sm block w-full`},t))})]},t.id)),_&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(Nt,{size:12,className:`animate-spin`}),` `,e(`assistant.working`)]}),(0,G.jsx)(`div`,{ref:b})]}),(0,G.jsxs)(`div`,{className:`shrink-0 border-t border-line p-2`,children:[(0,G.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,G.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,G.jsx)(K,{label:e(`assistant.stop`),onClick:()=>y.current?.abort(),children:(0,G.jsx)(Bn,{size:13,fill:`currentColor`})}):(0,G.jsx)(K,{label:e(`assistant.send`),disabled:!h.trim()||!w,onClick:()=>void C(),className:`text-accent`,children:(0,G.jsx)(vn,{size:14})})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 px-1 text-2xs text-fg-faint`,children:[(0,G.jsx)(gr,{size:10}),` `,e(`assistant.toolsCount`,{n:r.length})]})]})]})}function Gu({apiKey:e,onSave:t}){let{t:n}=U(),[r,i]=(0,S.useState)(e),[a,o]=(0,S.useState)(!1);return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2.5 border-b border-line bg-ink-0/40 p-3 text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(yt,{size:14,className:`mt-0.5 shrink-0 text-key`}),(0,G.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,G.jsx)(`p`,{className:`font-medium text-fg`,children:n(`assistant.keyTitle`)}),(0,G.jsx)(`p`,{children:n(`assistant.keyBody1`)}),(0,G.jsx)(`p`,{children:n(`assistant.keyBody2`)})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.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,G.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,G.jsx)(Ue,{size:12}):(0,G.jsx)(Ge,{size:12})})]}),(0,G.jsx)(fu,{size:`sm`,variant:`primary`,disabled:!r.trim()||r.trim()===e,onClick:()=>t(r.trim()),children:n(`assistant.saveKey`)})]}),e&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>(i(``),t(``)),className:`text-2xs text-fg-faint hover:text-danger`,children:n(`assistant.forgetKey`)})]})}var Ku=[],qu=0,Ju=new Set,Yu=()=>Ju.forEach(e=>e());function X(e,t=4200){let n=++qu;return Ku=[...Ku.slice(-3),{...e,id:n}],Yu(),setTimeout(()=>Xu(n),t),n}function Xu(e){Ku=Ku.filter(t=>t.id!==e),Yu()}var Z={info:(0,G.jsx)(_t,{size:14,className:`text-accent`}),success:(0,G.jsx)(Se,{size:14,className:`text-agent`}),error:(0,G.jsx)(ke,{size:14,className:`text-danger`}),agent:(0,G.jsx)(me,{size:14,className:`text-agent`})};function Q(){let e=(0,S.useSyncExternalStore)(e=>(Ju.add(e),()=>Ju.delete(e)),()=>Ku);return(0,G.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,G.jsxs)(`div`,{className:W(`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,G.jsx)(`div`,{className:`mt-0.5`,children:Z[e.tone]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.title}),e.detail&&(0,G.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.detail})]}),e.action&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{e.action.run(),Xu(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 Zu(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 Qu(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function $u(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function ed(e,t){return`data:${t};base64,${$u(e)}`}async function td(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 Zu(e,t,n),`downloaded`}function nd(e,t){return Ci(Si(t,`layer`),fa(e))}var rd={image:`Image`,text:`Text`,shape:`Shape`,fill:`Fill`,adjustment:`Adjustment`,group:`Group`};function id(e){return e.name?e.name:e.type===`text`?e.text.split(`
25
+ `)[0].slice(0,40)||rd.text:e.id}function ad(e){return rd[e]}function od(e,t,n,r={}){let i=r.size??Math.max(24,Math.round(Math.min(e.canvas.width,e.canvas.height)/12));return{id:nd(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 sd(e,t,n,r){let i={id:nd(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 cd(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:nd(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 ld(e,t){return t&&M(e.layers,t)?{above:t}:{}}function ud(e,t,n,r){let i=M(e.layers,n);if(!i)return null;let a=t.filter(t=>t!==n&&M(e.layers,t));for(let t of a)if(pa(M(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 dd(e,t){let n=t.map(t=>M(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 fd(e,t){let n=dd(e,t);if(!n)return null;let r=nd(e,`group`);return{ops:[{op:`groupLayers`,ids:n,id:r,name:`Group ${fa(e).filter(e=>e.startsWith(`group`)).length+1}`}],id:r}}function pd(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(...pd(o.children??[],t,n+1,o.id))}return i}function md(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=M(e.layers,n);t&&o(t.layer)}return i}function hd({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,G.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,G.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,G.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-line pl-4 pr-2`,children:[(0,G.jsx)(`div`,{className:`text-base font-semibold`,children:e}),(0,G.jsx)(K,{label:H(`ui.close`),onClick:t,children:(0,G.jsx)(vr,{size:15})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:n}),r&&(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-line px-4 py-2.5`,children:r})]})})}var gd=`agentphoto.studio.modelConsent.`;function _d(e){try{return localStorage.getItem(gd+e)===`1`}catch{return!1}}function vd(e){try{localStorage.setItem(gd+e,`1`)}catch{}}function yd(){let{t:e}=U(),{backend:t}=J(),n=Y(e=>e.consent);if(!n)return null;let r=ci(n.model);return(0,G.jsx)(hd,{title:e(`ai.consentTitle`),width:460,onClose:()=>n.resolve(!1),footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fu,{variant:`ghost`,onClick:()=>n.resolve(!1),children:e(`ui.cancel`)}),(0,G.jsxs)(fu,{variant:`primary`,onClick:()=>{vd(n.model),n.resolve(!0)},children:[(0,G.jsx)(ze,{size:13}),` `,e(`ai.consentAccept`,{size:r?.sizeMb??`?`})]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-line bg-ink-2/50 p-3`,children:[(0,G.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-agent/15 text-agent`,children:(0,G.jsx)(ze,{size:16})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`font-medium`,children:[r?.id,` `,(0,G.jsxs)(`span`,{className:`text-fg-faint`,children:[`· `,r?.sizeMb,` MB`]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted`,children:r?.description}),(0,G.jsxs)(`div`,{className:`mt-1 text-2xs text-fg-faint`,children:[e(`ai.license`),`: `,r?.license,` · `,r?.repo]})]})]}),(0,G.jsx)(`p`,{className:`text-fg-muted`,children:t.modelSource===`hub`?e(`ai.consentHub`):e(`ai.consentCli`)}),(0,G.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(wn,{size:14,className:`mt-0.5 shrink-0 text-agent`}),` `,e(`ai.privacy`)]})]})})}function bd(){let e=Y(e=>e.busy);return e?(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-30 flex justify-center`,children:(0,G.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,G.jsx)(Nt,{size:14,className:`animate-spin text-agent`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm`,children:e.label}),e.progress!==void 0&&(0,G.jsx)(`div`,{className:`mt-1 h-1 overflow-hidden rounded-full bg-ink-3`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-agent transition-[width]`,style:{width:`${Math.round(e.progress*100)}%`}})})]})]})}):null}function xd({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 Sd({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 Cd(e){let t=vi(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 wd(e,t=`#000000`){return xd(gi(e)??gi(t))}function Td(e){return Cd(Sd(e))}var Ed=e=>e&&typeof e==`object`?e.type:`solid`;function Dd(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 Od(e){return[...e].sort((e,t)=>e[0]-t[0])}function kd(e,t){let n=Od(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=gi(n[e-1][1])??{r:0,g:0,b:0,a:1},i=gi(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 Cd({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 Ad(e,t=`#000000`){return e?typeof e==`string`?e:Dd(e)[0]?.[1]??t:t}function jd(e){if(!e)return`transparent`;if(typeof e==`string`)return e;let t=Od(Dd(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 Md(e,t,n=`#ffffff`){let r=Ad(e,n);if(t===`solid`)return r;let i=e&&typeof e==`object`?Dd(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 Nd=l();function Pd({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,G.jsxs)(`div`,{ref:s,className:i,children:[e(()=>o(e=>!e),a),a&&(0,Nd.createPortal)((0,G.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 Fd({onClick:e,children:t,open:n,ariaLabel:r}){return(0,G.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 Id=`agentphoto.studio.recentColors`,Ld=[`#ffffff`,`#000000`,`#e5e7eb`,`#6b7280`,`#ef4444`,`#f97316`,`#f59e0b`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`,`#6366f1`,`#a855f7`,`#ec4899`,`#7c8cff`];function Rd(){try{let e=JSON.parse(localStorage.getItem(Id)??`[]`);return Array.isArray(e)?e.filter(e=>_i(e)).slice(0,8):[]}catch{return[]}}function zd(e){try{localStorage.setItem(Id,JSON.stringify([e,...Rd().filter(t=>t!==e)].slice(0,8)))}catch{}}function Bd(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 Vd({value:e,onChange:t,alpha:n=!0}){let[r,i]=(0,S.useState)(()=>wd(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=wd(e);i(e=>({...t,h:t.s===0||t.v===0?e.h:t.h}))},[e]);let c=(e,r)=>{i(e);let a=Td(n?e:{...e,a:1});s.current=a,t(a,r),r&&zd(a)},l=Bd((e,t,n)=>c({...r,s:e,v:1-t},n)),u=Bd((e,t,n)=>c({...r,h:Math.min(359.9,e*360)},n)),d=Bd((e,t,n)=>c({...r,a:Math.round(e*100)/100},n)),f=Cd({...Sd({...r,a:1}),a:1}),p=Cd({...Sd({h:r.h,s:1,v:1,a:1}),a:1}),m=Rd(),h=typeof window<`u`&&`EyeDropper`in window;return(0,G.jsxs)(`div`,{className:`w-[232px] select-none space-y-2.5 p-2.5`,children:[(0,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h&&(0,G.jsx)(`button`,{type:`button`,title:H(`color.eyedropper`),"aria-label":H(`color.eyedropper`),onClick:async()=>{try{let e=await new window.EyeDropper().open();c({...wd(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,G.jsx)(tn,{size:14})}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,G.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,G.jsx)(Hd,{at:r.h/360,color:p})}),n&&(0,G.jsxs)(`div`,{...d,className:`checker-sm relative h-2.5 cursor-pointer rounded-full`,children:[(0,G.jsx)(`div`,{className:`absolute inset-0 rounded-full`,style:{background:`linear-gradient(to right, transparent, ${f})`}}),(0,G.jsx)(Hd,{at:r.a,color:f})]})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,G.jsx)(`input`,{"aria-label":H(`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=gi(e.startsWith(`#`)||!/^[0-9a-f]{3,8}$/i.test(e)?e:`#${e}`);t&&c({...wd(Cd(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,G.jsxs)(`div`,{className:`flex h-7 w-[58px] items-center rounded-[5px] bg-ink-2 pr-1.5`,children:[(0,G.jsx)(`input`,{"aria-label":H(`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,G.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:`%`})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-8 gap-1`,children:[...m,...Ld].slice(0,16).map((e,t)=>(0,G.jsx)(`button`,{type:`button`,title:e,"aria-label":e,onClick:()=>c({...wd(e),a:n?gi(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,G.jsx)(`span`,{className:`absolute inset-0`,style:{background:e}})},`${e}${t}`))})]})}function Hd({at:e,color:t}){return(0,G.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 Ud({css:e,onClick:t,open:n,ariaLabel:r,className:i}){return(0,G.jsx)(`button`,{type:`button`,"aria-label":r??H(`color.pick`),"aria-expanded":n,onClick:t,className:W(`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,G.jsx)(`span`,{className:`absolute inset-0`,style:{background:e}})})}function Wd({value:e,onChange:t,alpha:n=!0,compact:r}){let[i,a]=(0,S.useState)(null);return(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,G.jsx)(Pd,{width:232,align:`start`,trigger:(t,n)=>(0,G.jsx)(Ud,{css:_i(e)?e:`transparent`,onClick:t,open:n}),children:()=>(0,G.jsx)(Vd,{value:e,onChange:t,alpha:n})}),!r&&(0,G.jsx)(`input`,{"aria-label":H(`color.value`),spellCheck:!1,value:i??e,onChange:e=>a(e.target.value),onBlur:()=>{i!==null&&_i(i.trim())&&t(i.trim(),!0),a(null)},onKeyDown:e=>e.key===`Enter`&&e.target.blur(),className:`field font-mono text-xs`})]})}function Gd(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 Kd(e,t=3){if(!Number.isFinite(e))return`0`;let n=Number(e.toFixed(t));return Object.is(n,-0)?`0`:String(n)}function qd(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:`${(e/1048576).toFixed(2)} MB`}function Jd({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=>Gd({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,G.jsxs)(`div`,{className:W(`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,G.jsx)(`span`,{onPointerDown:b,onPointerMove:x,onPointerUp:ee,className:W(`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,G.jsx)(`input`,{ref:g,"aria-label":d??n,inputMode:`decimal`,value:p??(u?``:Kd(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(Kd(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(Kd(r,s?0:3)),t(r,!0)}},className:W(`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,G.jsx)(`span`,{className:`pr-1.5 text-2xs text-fg-faint`,children:c})]})}function Yd({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,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`relative flex h-6 min-w-0 flex-1 items-center`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 h-[3px] rounded-full bg-ink-4`,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,a?`bg-fg-faint/50`:`bg-accent`),style:{width:`${d}%`}})}),(0,G.jsx)(`input`,{type:`range`,min:t,max:n,step:u,value:Number.isFinite(e)?e:t,"aria-label":s,onChange:e=>r(Gd({min:t,max:n,integer:i},Number(e.target.value)),!1),onPointerUp:e=>r(Gd({min:t,max:n,integer:i},Number(e.target.value)),!0),onKeyUp:e=>r(Gd({min:t,max:n,integer:i},Number(e.target.value)),!0),className:W(`slider relative h-6 w-full cursor-pointer appearance-none bg-transparent`,o&&`opacity-40`)})]}),(0,G.jsx)(Jd,{value:e,min:t,max:n,integer:i,placeholder:a,empty:o,onChange:r,ariaLabel:s,className:`w-[52px] flex-none`,step:u})]})}function Xd(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}var Zd=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase()),Qd=(e,t)=>V(`params.${e}`)??Xd(e),$d=e=>V(`blend.${Zd(e)}`)??Xd(e),ef=(e,t)=>Lr.includes(t)?$d(t):V(`options.${Zd(t)}`)??Xd(t),tf=e=>V(`filterNames.${e}`)??ii(e)?.title??Xd(e),nf=e=>V(`filterGroups.${e}`)??Xd(e),rf=e=>V(`effectNames.${e}`)??ai(e)?.title??Xd(e),af=e=>V(`sizeNames.${Zd(e)}`)??si(e)?.title??Xd(e),of=e=>V(`lookNames.${Zd(e)}`)??qr.find(t=>t.id===e)?.title??Xd(e),sf={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`,"image/avif":`avif`},cf=null;function lf(){return cf||=(async()=>{try{let e=vc(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}})(),cf}function uf(){let{t:e}=U(),t=J(),n=Cu(),r=n.export??{},[i,a]=(0,S.useState)(r.format??`png`),[o,s]=(0,S.useState)(r.quality??vs[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)(()=>{lf().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:ys(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=_s[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)),X({tone:`success`,title:e(`export.written`,{n:r.length}),detail:r.map(e=>e.path).join(`, `)})}}else{let i=ys(n,r),a=re&&r===de?re:await t.engine.exportImage(n,i),o=sf[a.mime]??_s[i.format],s=`${i.file.split(`/`).pop().replace(/\.[^.]+$/,``)}.${o}`;await td(s,a.bytes,a.mime)!==`cancelled`&&X({tone:`success`,title:e(`export.downloaded`,{file:s})})}}catch(t){X({tone:`error`,title:e(`export.failed`),detail:t.message})}finally{ce(!1)}};return(0,G.jsx)(hd,{title:e(`export.title`),width:880,onClose:pe,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mr-auto flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{children:e(`export.variants`)}),[`og`,`square`,`story`].map(e=>(0,G.jsx)(fu,{size:`xs`,variant:`ghost`,disabled:se,onClick:()=>void ge({...de,preset:e,fit:`cover`,width:void 0,height:void 0,scale:void 0}),title:af(e),children:e},e))]}),(0,G.jsx)(fu,{variant:`ghost`,onClick:pe,children:e(`ui.close`)}),(0,G.jsxs)(fu,{variant:`primary`,disabled:!fe.job||se,onClick:()=>void ge(de),children:[se?(0,G.jsx)(Nt,{size:13,className:`animate-spin`}):t.backend.mode===`cli`?(0,G.jsx)(fr,{size:13}):(0,G.jsx)(ze,{size:13}),t.backend.mode===`cli`?e(`export.write`):e(`export.download`)]})]}),children:(0,G.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_320px]`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-[420px] flex-col border-r border-line bg-ink-0/50 p-4`,children:[(0,G.jsxs)(`div`,{className:`relative flex flex-1 items-center justify-center overflow-hidden rounded-lg bg-ink-0`,children:[re?(0,G.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,G.jsx)(Nt,{size:18,className:`animate-spin text-fg-faint`}),ae&&re&&(0,G.jsx)(`div`,{className:`absolute right-2 top-2 rounded bg-black/60 p-1`,children:(0,G.jsx)(Nt,{size:12,className:`animate-spin text-white/80`})})]}),(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 text-xs text-fg-muted`,children:[(0,G.jsx)(qe,{size:13}),fe.job&&(0,G.jsxs)(`span`,{className:`tabular-nums text-fg`,children:[fe.job.width,` × `,fe.job.height,` px`]}),re&&(0,G.jsx)(`span`,{className:`tabular-nums`,children:qd(re.bytes.byteLength)}),re&&(0,G.jsx)(`span`,{className:`text-fg-faint`,children:re.mime}),re&&(0,G.jsx)(`span`,{className:`ml-auto text-fg-faint`,children:e(`export.encodedIn`,{ms:re.ms})})]}),he&&(0,G.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 text-xs text-warn`,children:[(0,G.jsx)(ir,{size:12}),` `,e(`export.fallback`,{format:i.toUpperCase(),mime:re.mime})]}),fe.error&&(0,G.jsx)(`div`,{className:`mt-2 text-xs text-danger`,children:fe.error})]}),(0,G.jsxs)(`div`,{className:`space-y-0.5 py-3`,children:[(0,G.jsx)(q,{label:e(`export.format`),children:(0,G.jsx)(`div`,{className:`flex flex-1 rounded-md bg-ink-2 p-0.5`,children:gs.map(t=>(0,G.jsx)(`button`,{type:`button`,disabled:t===`avif`&&!T,title:t===`avif`&&!T?e(`export.noAvif`):void 0,onClick:()=>(a(t),s(vs[t])),className:W(`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,G.jsx)(q,{label:e(`export.quality`),children:(0,G.jsx)(Yd,{value:o,min:1,max:100,integer:!0,onChange:e=>s(e),ariaLabel:e(`export.quality`)})}),(0,G.jsx)(q,{label:e(`export.size`),children:(0,G.jsx)(mu,{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,G.jsx)(q,{label:e(`export.preset`),children:(0,G.jsx)(mu,{value:u,options:Qr.map(e=>({value:e.id,label:`${af(e.id)} · ${e.width}×${e.height}`})),onChange:d,ariaLabel:e(`export.preset`)})}),c===`custom`&&(0,G.jsxs)(q,{label:e(`props.size`),children:[(0,G.jsx)(Jd,{label:`W`,value:f,min:1,max:16384,integer:!0,onChange:e=>p(e)}),(0,G.jsx)(Jd,{label:`H`,value:m,min:1,max:16384,integer:!0,onChange:e=>h(e)})]}),c===`scale`&&(0,G.jsx)(q,{label:e(`export.scale`),children:(0,G.jsx)(Yd,{value:g,min:.05,max:4,step:.05,onChange:e=>_(e),ariaLabel:e(`export.scale`)})}),(c===`preset`||c===`custom`)&&(0,G.jsx)(q,{label:e(`export.fit`),children:(0,G.jsx)(mu,{value:v,options:[`cover`,`contain`,`stretch`].map(t=>({value:t,label:e(`export.fits.${t}`)})),onChange:e=>y(e),ariaLabel:e(`export.fit`)})}),(0,G.jsxs)(q,{label:e(`export.background`),children:[(0,G.jsx)(hu,{checked:b||i===`jpeg`,onChange:x,ariaLabel:e(`export.flatten`)}),(b||i===`jpeg`)&&(0,G.jsx)(Wd,{value:ee,alpha:!1,onChange:e=>te(e)}),!b&&i!==`jpeg`&&(0,G.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e(`export.transparent`)})]}),(0,G.jsxs)(q,{label:e(`export.name`),children:[(0,G.jsx)(pu,{value:C,onCommit:e=>w(e.trim()||n.id),ariaLabel:e(`export.name`)}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`.`,me]})]}),t.backend.mode===`cli`&&fe.job&&(0,G.jsxs)(`div`,{className:`px-3 pt-2 font-mono text-2xs text-fg-faint`,children:[`→ `,fe.job.file]}),le.length>0&&(0,G.jsxs)(`div`,{className:`mx-3 mt-3 space-y-1 rounded-lg border border-agent/30 bg-agent/5 p-2`,children:[(0,G.jsx)(`div`,{className:`text-2xs font-semibold uppercase tracking-wide text-agent`,children:e(`export.writtenTitle`)}),le.map(t=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-2xs`,children:t.path}),(0,G.jsxs)(`span`,{className:`shrink-0 tabular-nums text-fg-faint`,children:[t.kb,` KB`]}),(0,G.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 df=[{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}],ff=e=>e*Math.PI/180;function pf(e,t){let n=ff(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 mf=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function hf(e,t){let n=mf(e),r=pf({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 gf(e,t,n,r,i=1){let a=mf(e),o=pf({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=pf({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 _f(e,t,n,r){let i=mf(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 vf(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 yf(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 bf(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 xf(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 Sf=e=>({x:0,y:0,width:e.store.doc.canvas.width,height:e.store.doc.canvas.height});function Cf(e){let t=e.ui.get().crop,n=e.store.doc;if(!t||!n)return;let r=xf(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 wf(e,t,n){return t?n&&n.hx===0?{...e,width:e.height*t}:{...e,height:e.width/t}:e}var Tf=(e,t,n)=>{for(let r of df){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},Ef={id:`crop`,icon:D,label:`tools.crop`,shortcut:`C`,group:`select`,activate(e){e.store.doc&&!e.ui.get().crop&&e.ui.set({crop:Sf(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=Tf(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??Sf(e.api),i=n.get().cropRatio,a=Tf(e,r,t.screen);return a?{move(e){let t=gf({...r,rotation:0},a,e.doc,e.shift||!!i);n.set({crop:wf(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=bf(t.doc,e.doc,e.shift);n.set({crop:wf(r,i,null)})},up(){}}},key(e,t){return t.key===`Enter`?(Cf(e.api),!0):t.key===`Escape`&&(e.api.ui.set({tool:`move`,crop:null}),!0)},Options:Of},Df=[`free`,`original`,`1:1`,`4:5`,`3:2`,`16:9`,`9:16`,`2:3`];function Of(){let{t:e}=U(),t=J(),n=Y(e=>e.crop),r=Y(e=>e.cropRatio),i=Y(e=>e.cropRatioId),a=t.store.doc;return a?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`crop.ratio`)}),(0,G.jsx)(mu,{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??Sf(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:Df.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,G.jsxs)(`div`,{className:`flex w-[180px] gap-1`,children:[(0,G.jsx)(Jd,{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,G.jsx)(Jd,{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,G.jsxs)(`div`,{className:`ml-2 flex gap-1`,children:[(0,G.jsxs)(fu,{size:`xs`,variant:`primary`,onClick:()=>Cf(t),children:[(0,G.jsx)(Se,{size:13}),` `,e(`crop.apply`)]}),(0,G.jsxs)(fu,{size:`xs`,variant:`ghost`,onClick:()=>t.ui.set({tool:`move`,crop:null}),children:[(0,G.jsx)(vr,{size:13}),` `,e(`crop.cancel`)]})]}),(0,G.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`crop.hint`)})]}):null}var kf=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=[];N(e.layers,e=>void n.push(e));let r=new Map;for(let e of n){if(!Rr(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(Rr).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 Af(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 jf(e){if(!e.rotation)return{x:e.x,y:e.y,width:e.width,height:e.height};let t=Af(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 Mf(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 Nf(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=Nf(i.children??[],t,n);if(e)return e;continue}if(!Rr(i))continue;let a=t.get(i.id);if(a&&Mf(a,n))return i.id}return null}function Pf(e,t){let n=[],r=e=>{e.locked||(Rr(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 Ff(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=jf(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 If={id:`text`,icon:or,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=Nf(r.layers,n.boxes.getSnapshot(),t.doc);return(i?M(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:Lf};function Lf(){let{t:e}=U(),t=J(),n=wu(),r=Y(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,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(mu,{value:i.font??`inter`,options:Zr.map(e=>({value:e.id,label:e.family})),onChange:e=>a({font:e}),className:`w-[150px]`,ariaLabel:e(`props.font`)}),(0,G.jsx)(`div`,{className:`w-[84px]`,children:(0,G.jsx)(Jd,{label:`Aa`,value:i.size??64,min:1,max:2e3,onChange:(e,t)=>a({size:e},t),ariaLabel:e(`props.size`)})}),(0,G.jsx)(`div`,{className:`w-[120px]`,children:(0,G.jsx)(Wd,{value:Ad(i.color,`#ffffff`),onChange:(e,t)=>a({color:e},t)})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`tools.color`)}),(0,G.jsx)(`div`,{className:`w-[120px]`,children:(0,G.jsx)(Wd,{value:r,onChange:e=>t.ui.set({fg:e})})})]}),(0,G.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`tools.textHint`)})]})}var Rf={rect:Bn,ellipse:je,line:Ut,polygon:lt,star:Wn},zf={id:`shape`,icon:Sn,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}:bf(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={...sd(a,r,{...o,height:Math.max(1,o.height)},n.ui.get().fg),name:H(`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:$};function Bf({value:e,onChange:t}){let{t:n}=U();return(0,G.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:Object.keys(Rf).map(r=>{let i=Rf[r];return(0,G.jsx)(`button`,{type:`button`,title:n(`shapes.${r}`),"aria-label":n(`shapes.${r}`),onClick:()=>t(r),className:W(`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,G.jsx)(i,{size:13})},r)})})}function $(){let{t:e}=U(),t=J(),n=Y(e=>e.shapeKind),r=Y(e=>e.fg);return(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Bf,{value:n,onChange:e=>t.ui.set({shapeKind:e})}),(0,G.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:e(`tools.fill`)}),(0,G.jsx)(`div`,{className:`w-[120px]`,children:(0,G.jsx)(Wd,{value:r,onChange:e=>t.ui.set({fg:e})})}),(0,G.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`tools.shapeHint`)})]})}var Vf=2048;function Hf(e,t){return e&&t?`intersect`:e?`add`:t?`subtract`:`replace`}function Uf(e,t,n=Vf){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 Wf(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 Gf(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 Kf(e,t,n){return e.kind===`raster`?e.raster:Wf(Uf(t,n),e)}function qf(e,t,n,r,i){if(n===`replace`)return t;if(!e)return n===`add`?t:null;let a=Kf(e,r,i),o=Jf(Kf(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 Zf(c)?null:{kind:`raster`,raster:c}}function Jf(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 Yf(e,t,n){if(!e)return{kind:`rect`,x:0,y:0,width:t,height:n};let r=Kf(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 Zf(a)?null:{kind:`raster`,raster:a}}function Xf(e,t,n,r){let i=Kf(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 Zf(e){for(let t=0;t<e.data.length;t++)if(e.data[t]>0)return!1;return!0}function Qf(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 $f(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 ep(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]=$f(e,s+l*u-i*d,c+l*d+i*u)}}return a}function tp(e,t,n,r,i,a){let o=Uf(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 Zf(o)?null:{kind:`raster`,raster:o}}function np(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 rp(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=ip(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 ip(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 ap(e){let t=Math.min(1,1024/Math.max(e.w,e.h));if(t>=1)return{d:rp(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:rp(i,n,r),scale:e.scale*t}}var op=e=>Math.round(e*10)/10;function sp(e,t,n,r={}){let i=Rr(e)?n?.x??e.x??0:0,a=Rr(e)?n?.y??e.y??0:0;return{shape:t.kind,x:op(t.x-i),y:op(t.y-a),width:op(t.width),height:op(t.height),...r.invert?{invert:!0}:{},...r.feather?{feather:r.feather}:{}}}function cp(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 lp(e,t,n,r,i,a){if(!t)return new Uint8ClampedArray(n*r).fill(255);let o=vc(n,r),s=z(o);if(zr(t)){let i=await e.image(t.src);s.drawImage(i,0,0,n,r)}else if(Br(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):sl(s,t.x*e,t.y*o,t.width*e,t.height*o,(t.radius??0)*e),s.fill()}else Vr(t)&&(s.fillStyle=Zc(s,t.gradient,{x:0,y:0,w:n,h:r}),s.fillRect(0,0,n,r));let c=cp(o);if(t.invert)for(let e=0;e<c.length;e++)c[e]=255-c[e];return c}function up(e,t,n){let r=vc(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 dp=new WeakMap;function fp(e){let t=dp.get(e.engine);return t||(t=new Sl({assetBase:``,libraryBase:``},e.engine.loader),dp.set(e.engine,t)),t}async function pp(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 mp=2048,hp=4096;async function gp(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 _p(e,t){if(!Rr(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 vp(e,t,n=mp){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 yp(e,t,n,r,i){let a=await El(n,r,i);return await e.backend.writeFile(t,a.bytes),t}async function bp(e,t,n){let r=e.store.doc,i=_p(e,t);if(n.kind!==`raster`&&!i?.rotation&&!i?.flipX&&!i?.flipY)return sp(t,n,i?{x:i.x,y:i.y,width:i.width,height:i.height,rotation:0}:void 0);let{w:a,h:o}=vp(i?.width??r.canvas.width,i?.height??r.canvas.height),s=ep(n,a,o,i,r.canvas);return{src:await yp(e,await gp(e,`assets/masks`,`${t.id}-selection`),s,a,o)}}function xp(e){let t=e.ui.get().region;if(!t)return null;let n=e.store.primary;return{region:t,layer:n&&e.store.doc?M(e.store.doc.layers,n)?.layer??null:null}}async function Sp(e,t){try{await t()}catch(t){X({tone:`error`,title:e,detail:t.message})}}function Cp(e){return Sp(H(`region.failed`),async()=>{let t=xp(e);if(!t?.layer)return void X({tone:`info`,title:H(`region.needLayer`)});let n=await bp(e,t.layer,t.region);e.edit([{op:`setMask`,id:t.layer.id,mask:n}])&&e.ui.set({region:null})})}function wp(e){return Sp(H(`region.failed`),async()=>{let t=xp(e);if(!t?.layer)return void X({tone:`info`,title:H(`region.needLayer`)});let n=e.store.doc,r=_p(e,t.layer),i=r?.width??n.canvas.width,a=r?.height??n.canvas.height,{w:o,h:s}=vp(i,a),c=t.layer.mask&&t.layer.mask.enabled!==!1?t.layer.mask:null,l=await lp(e.engine.loader,c,o,s,i,a),u=ep(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 yp(e,await gp(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 Tp(e){return Sp(H(`region.failed`),async()=>{let t=xp(e);if(!t)return;let n=e.store.doc,r=Qf(t.region),i=r&&xf(r,n.canvas.width,n.canvas.height);if(!i||i.width<1||i.height<1)return void X({tone:`info`,title:H(`marquee.empty`)});let a=Math.min(1,hp/Math.max(n.canvas.width,n.canvas.height)),o=await fp(e).render(n,{scale:a,...t.layer?{only:new Set([t.layer.id]),background:!1}:{}}),s=o.width,c=o.height,l=ep(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=vc(Math.max(1,Math.round(m*a)),Math.max(1,Math.round(h*a)));z(g).drawImage(o,-f*a,-p*a);let _=await Dl(g,`image/png`),v=t.layer?.id??`picture`,y=await gp(e,`assets/edits`,`${v}-copy`);await e.backend.writeFile(y,_.bytes);let b=nd(n,`${v}-copy`),x={id:b,type:`image`,name:H(`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 Ep(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}=vp(r.canvas.width,r.canvas.height),o=ep(t,i,a,null,r.canvas);return{src:await yp(e,await gp(e,`assets/masks`,n),o,i,a)}}function Dp(e){return Sp(H(`region.failed`),async()=>{let t=xp(e);if(!t)return;let n=e.store.doc,r=nd(n,`fill`),i=await Ep(e,t.region,`${r}-selection`),a={id:r,type:`fill`,name:H(`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 Op(e){return Sp(H(`region.failed`),async()=>{let t=xp(e);if(!t)return;let n=e.store.doc,r=nd(n,`adjustment`),i=await Ep(e,t.region,`${r}-selection`),a={id:r,type:`adjustment`,name:H(`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 kp(e){let t=e.ui.get().region,n=e.store.doc;if(!t||!n)return;let r=Qf(t),i=r&&xf(r,n.canvas.width,n.canvas.height);if(!i||i.width<1||i.height<1)return void X({tone:`info`,title:H(`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 Ap(e){let t=e.store.doc;t&&e.ui.set(e=>({region:Yf(e.region,t.canvas.width,t.canvas.height)}))}function jp(e,t){let n=e.store.doc,r=e.ui.get().region;!n||!r||t<=0||e.ui.set({region:Xf(r,t,n.canvas.width,n.canvas.height)})}function Mp(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 Np(){let{t:e}=U(),t=J(),n=Y(e=>e.region),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(8);if(!n)return null;let s=Qf(n),c=async e=>{i(!0);try{await e()}finally{i(!1)}};return(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[s&&(0,G.jsxs)(`span`,{className:`mr-1.5 text-2xs tabular-nums text-fg-faint`,children:[Math.round(s.width),` × `,Math.round(s.height)]}),(0,G.jsxs)(fu,{size:`xs`,variant:`ghost`,disabled:r||!t.store.primary,onClick:()=>void c(()=>Cp(t)),title:e(`marquee.maskHint`),children:[(0,G.jsx)(In,{size:13}),` `,e(`marquee.mask`)]}),(0,G.jsx)(K,{label:e(`region.delete`),disabled:r||!t.store.primary,onClick:()=>void c(()=>wp(t)),className:`h-6 w-6`,children:(0,G.jsx)(Ve,{size:13})}),(0,G.jsx)(K,{label:e(`region.copy`),disabled:r,onClick:()=>void c(()=>Tp(t)),className:`h-6 w-6`,children:(0,G.jsx)(Fe,{size:13})}),(0,G.jsx)(K,{label:e(`region.fill`),disabled:r,onClick:()=>void c(()=>Dp(t)),className:`h-6 w-6`,children:(0,G.jsx)(Yt,{size:13})}),(0,G.jsx)(K,{label:e(`marquee.adjustHint`),disabled:r,onClick:()=>void c(()=>Op(t)),className:`h-6 w-6`,children:(0,G.jsx)(Tt,{size:13})}),(0,G.jsx)(`div`,{className:`mx-1 h-4 w-px bg-line`}),(0,G.jsx)(K,{label:e(`region.invert`),onClick:()=>Ap(t),className:`h-6 w-6`,children:(0,G.jsx)(Pn,{size:13})}),(0,G.jsx)(Pd,{width:200,align:`start`,trigger:(t,n)=>(0,G.jsx)(K,{label:e(`region.feather`),active:n,onClick:t,className:`h-6 w-6`,children:(0,G.jsx)(On,{size:13})}),children:n=>(0,G.jsxs)(`div`,{className:`space-y-2 p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-xs text-fg-muted`,children:e(`region.featherRadius`)}),(0,G.jsx)(Jd,{value:a,min:1,max:500,integer:!0,suffix:`px`,onChange:e=>o(e),ariaLabel:e(`region.featherRadius`)}),(0,G.jsx)(fu,{size:`xs`,variant:`primary`,className:`w-full`,onClick:()=>(jp(t,a),n()),children:e(`region.apply`)})]})}),(0,G.jsx)(K,{label:e(`marquee.crop`),onClick:()=>kp(t),className:`h-6 w-6`,children:(0,G.jsx)(D,{size:13})}),(0,G.jsx)(K,{label:e(`marquee.deselect`),onClick:()=>t.ui.set({region:null}),className:`h-6 w-6`,children:(0,G.jsx)(vr,{size:13})})]})}function Pp(e,t){let{ui:n}=e.api,r=n.get().region;if(!r||t.shift||t.alt)return null;let i=Qf(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 Fp(e,t,n){let r=e.api.store.doc;e.api.ui.set(e=>({region:qf(e.region,t,n,r.canvas.width,r.canvas.height)}))}var Ip={id:`marquee`,icon:In,label:`tools.marquee`,shortcut:`M`,group:`select`,cursor:()=>`crosshair`,down(e,t){let n=Pp(e,t);if(n)return n;let r=Hf(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`?bf(t.doc,n.doc,n.shift,n.alt):bf(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`&&Fp(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:Lp};function Lp(){let{t:e}=U(),t=J(),n=Y(e=>e.marqueeKind),r=Y(e=>e.region);return(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`rect`,`ellipse`].map(i=>(0,G.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:W(`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,G.jsx)(Bn,{size:13}):(0,G.jsx)(je,{size:13})},i))}),(0,G.jsx)(`div`,{className:`ml-2`,children:r?(0,G.jsx)(Np,{}):(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:e(`marquee.hint`)})})]})}var Rp=null;function zp(e,t,n){if(e.setPath(null),t.length<3)return;let r=e.api.store.doc;Fp(e,{kind:`raster`,raster:Gf(Uf(r.canvas.width,r.canvas.height),t)},n)}var Bp={id:`lasso`,icon:Ct,label:`tools.lasso`,shortcut:`L`,group:`select`,cursor:()=>`crosshair`,deactivate(){Rp=null},down(e,t){if(e.api.ui.get().lassoKind===`poly`){if(!Rp)Rp={points:[t.doc],mode:Hf(t.shift,t.alt)};else{let n=e.toScreen(Rp.points[0]);if(t.clicks>=2||Math.hypot(n.x-t.screen.x,n.y-t.screen.y)<9){let t=Rp.points,n=Rp.mode;return Rp=null,zp(e,t,n),null}Rp.points.push(t.doc)}return e.setPath({points:Rp.points,toCursor:!0}),null}let n=Hf(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}),zp(e,r,n)},cancel(){e.setPath(null)}}},hover(e){Rp&&e.setPath({points:Rp.points,toCursor:!0})},key(e,t){if(Rp&&t.key===`Enter`){let{points:t,mode:n}=Rp;return Rp=null,zp(e,t,n),!0}if(t.key===`Escape`){if(Rp)return Rp=null,e.setPath(null),!0;if(e.api.ui.get().region)return e.api.ui.set({region:null}),!0}return Rp&&t.key===`Backspace`?(Rp.points.pop(),Rp.points.length||(Rp=null),e.setPath(Rp?{points:Rp.points,toCursor:!0}:null),!0):!1},Options:Vp};function Vp(){let{t:e}=U(),t=J(),n=Y(e=>e.lassoKind),r=Y(e=>e.region);return(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`free`,`poly`].map(r=>(0,G.jsxs)(`button`,{type:`button`,title:e(`lasso.${r}`),"aria-label":e(`lasso.${r}`),onClick:()=>(Rp=null,t.ui.set({lassoKind:r})),className:W(`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,G.jsx)(Ct,{size:13}):(0,G.jsx)(Mn,{size:13}),e(`lasso.${r}`)]},r))}),(0,G.jsx)(`div`,{className:`ml-2`,children:r?(0,G.jsx)(Np,{}):(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:e(n===`poly`?`lasso.polyHint`:`lasso.hint`)})})]})}var Hp=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=vc(this.w,this.h),this.sctx=z(this.stroke),i){let e=vc(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=vc(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 Up(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 Wp=4096,Gp=new Map,Kp=(e,t)=>{for(Gp.delete(e),Gp.set(e,t);Gp.size>6;)Gp.delete(Gp.keys().next().value)},qp=null,Jp=e=>({x:0,y:0,width:e.store.doc.canvas.width,height:e.store.doc.canvas.height,rotation:0});function Yp(e){let t=e.store.doc,n=e.store.primary?M(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 Xp(e){let t=e.store.doc,{kind:n,layer:r}=Yp(e);if(n===`mask`&&r){let t=_p(e,r)??Jp(e),i=`${r.id}|mask|${JSON.stringify(r.mask??null)}`,a=Gp.get(i);if(!a){let{w:n,h:o}=vp(t.width,t.height);a=up(await lp(e.engine.loader,r.mask??null,n,o,t.width,t.height),n,o),Kp(i,a)}return{kind:n,layer:r,frame:t,base:a}}if(n===`pixels`&&r?.type===`image`){let i=_p(e,r),a=`${r.id}|${r.src}|${JSON.stringify(r.crop??null)}|${r.fit??``}|${i.width}x${i.height}`,o=Gp.get(a);return o||(o=await fp(e).layerPixels(t,r.id,{maxSide:Wp,withFilters:!1}),Kp(a,o)),{kind:n,layer:r,frame:i,base:o}}let i=Jp(e),{w:a,h:o}=vp(i.width,i.height,Wp),s=document.createElement(`canvas`);return s.width=a,s.height=o,{kind:`new`,layer:r,frame:i,base:s}}function Zp(e,t){let n=e.frame,r=pf({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 Qp(e,t,n){let r=e.store.doc,i=await Dl(n,`image/png`);if(t.kind===`mask`&&t.layer){let r=await gp(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}:{}};Kp(`${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 gp(e,`assets/edits`,r.id);await e.backend.writeFile(a,i.bytes);let o=t.frame;Kp(`${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=nd(r,`paint`),o=await gp(e,`assets/edits`,a);await e.backend.writeFile(o,i.bytes);let s=t.frame;Kp(`${a}|${o}|null||${s.width}x${s.height}`,n);let c={id:a,type:`image`,name:H(`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 $p(e,t,n){let{api:r}=e,i=r.ui.get();if(n===`clone`){if(t.alt)return r.ui.set({cloneSource:t.doc}),qp=null,X({tone:`info`,title:H(`brush.sourceSet`)},1600),null;if(!i.cloneSource)return X({tone:`info`,title:H(`brush.needSource`)}),null;qp||={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&&Up(o.display,c,e)},p=()=>{l||=requestAnimationFrame(f)},m=Xp(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?ep(h,t.base.width,t.base.height,t.kind===`new`?null:t.frame,r.store.doc.canvas):null,_=qp?{dx:qp.x*l,dy:qp.y*l}:void 0;o=new Hp(t.base,f,u,m,g,_),t.kind===`mask`&&(c=document.createElement(`canvas`),Up(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(Zp(t,e).x,Zp(t,e).y);a.length=0,p()}).catch(e=>{d=!0,X({tone:`error`,title:H(`brush.failed`),detail:e.message})});return{cursor:`none`,move(e){if(o&&s){let t=Zp(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 Qp(r,s,o.display),await e.nextFrame()}catch(e){X({tone:`error`,title:H(`brush.failed`),detail:e.message})}finally{e.setOverlay(null)}})())},cancel(){u=!0,e.setOverlay(null)}}}var em=(e,t,n)=>({id:e,icon:t,label:`tools.${e}`,shortcut:n,group:`paint`,cursor:()=>`none`,down:(t,n)=>$p(t,n,e),Options:am}),tm=em(`brush`,ge,`B`),nm=em(`eraser`,Ve,`E`),rm=em(`clone`,Hn,`S`),im=new Set([`brush`,`eraser`,`clone`]);function am(){let{t:e}=U(),t=J(),n=Y(e=>e.brush),r=Y(e=>e.tool),i=Y(e=>e.maskTarget),a=Y(e=>e.maskPaint),o=Y(e=>e.region);wu();let s=Yp(t),c=e=>t.ui.set(t=>({brush:{...t.brush,...e}}));return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{children:e(`brush.size`)}),(0,G.jsx)(`div`,{className:`w-[64px]`,children:(0,G.jsx)(Jd,{value:n.size,min:1,max:2e3,integer:!0,suffix:`px`,onChange:e=>c({size:e}),ariaLabel:e(`brush.size`)})}),(0,G.jsx)(`span`,{children:e(`brush.hardness`)}),(0,G.jsx)(`div`,{className:`w-[110px]`,children:(0,G.jsx)(Yd,{value:Math.round(n.hardness*100),min:0,max:100,integer:!0,onChange:e=>c({hardness:e/100}),ariaLabel:e(`brush.hardness`)})}),(0,G.jsx)(`span`,{children:e(`brush.opacity`)}),(0,G.jsx)(`div`,{className:`w-[110px]`,children:(0,G.jsx)(Yd,{value:Math.round(n.opacity*100),min:1,max:100,integer:!0,onChange:e=>c({opacity:e/100}),ariaLabel:e(`brush.opacity`)})}),(0,G.jsx)(`span`,{children:e(`brush.flow`)}),(0,G.jsx)(`div`,{className:`w-[110px]`,children:(0,G.jsx)(Yd,{value:Math.round(n.flow*100),min:1,max:100,integer:!0,onChange:e=>c({flow:e/100}),ariaLabel:e(`brush.flow`)})}),(0,G.jsx)(`div`,{className:`mx-1 h-4 w-px bg-line`}),i&&s.kind===`mask`?(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.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,G.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`hide`,`reveal`].map(n=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.ui.set({maskPaint:n}),className:W(`h-6 rounded px-2`,a===n?`bg-ink-4 text-fg`:`text-fg-muted hover:text-fg`),children:e(`brush.${n}`)},n))}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.ui.set({maskTarget:null}),className:`ml-1 text-accent hover:underline`,children:e(`brush.paintPixels`)})]}):(0,G.jsx)(`span`,{className:`text-fg-faint`,children:r===`clone`?e(`brush.cloneHint`):s.kind===`new`?e(`brush.newLayerHint`):e(`brush.hint`)}),o&&(0,G.jsx)(`span`,{className:`text-2xs text-accent`,children:e(`brush.clipped`)})]})}var om={id:`wand`,icon:mr,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=Hf(t.shift,t.alt),c=!o&&n.store.primary?n.store.primary:null,l=Uf(r.canvas.width,r.canvas.height);return(async()=>{let o=yc(await fp(n).render(r,{scale:l.scale,...c?{only:new Set([c]),background:!1}:{}})),u=np(o.data,o.width,o.height,Math.floor(t.doc.x*l.scale),Math.floor(t.doc.y*l.scale),i,a);Fp(e,{kind:`raster`,raster:{w:o.width,h:o.height,scale:l.scale,data:new Uint8Array(u)}},s)})().catch(e=>X({tone:`error`,title:H(`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:sm};function sm(){let{t:e}=U(),t=J(),n=Y(e=>e.wand),r=Y(e=>e.region),i=e=>t.ui.set(t=>({wand:{...t.wand,...e}}));return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{children:e(`wand.tolerance`)}),(0,G.jsx)(`div`,{className:`w-[150px]`,children:(0,G.jsx)(Yd,{value:n.tolerance,min:0,max:100,integer:!0,onChange:e=>i({tolerance:e}),ariaLabel:e(`wand.tolerance`)})}),(0,G.jsx)(hu,{checked:n.contiguous,onChange:e=>i({contiguous:e}),ariaLabel:e(`wand.contiguous`)}),(0,G.jsx)(`span`,{children:e(`wand.contiguous`)}),(0,G.jsx)(hu,{checked:n.sampleAll,onChange:e=>i({sampleAll:e}),ariaLabel:e(`wand.sampleAll`)}),(0,G.jsx)(`span`,{children:e(`wand.sampleAll`)}),(0,G.jsx)(`div`,{className:`ml-2`,children:r?(0,G.jsx)(Np,{}):(0,G.jsx)(`span`,{className:`text-fg-faint`,children:e(`wand.hint`)})})]})}var cm=ei.segmentation;async function lm(e,t,n){let r=e.store.doc,i=M(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:H(`quick.running`)}}));try{let a=await pp((await fp(e).segmentMask(r,t,{points:n},{model:cm})).bytes),o=_p(e,i.layer),s=tp(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})),X({tone:`error`,title:H(`quick.failed`),detail:t.message},8e3)}finally{e.ui.set({busy:null})}}}function um(e){let t=e.ui.get().quick,n=e.store.doc;t?.region&&n&&e.ui.set(e=>({region:qf(e.region,t.region,`replace`,n.canvas.width,n.canvas.height),quick:null}))}var dm={id:`quick`,icon:qt,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?M(r.layers,n.store.primary)?.layer??null:null;if(i?.type!==`image`){let e=Nf(r.layers,n.boxes.getSnapshot(),t.doc);if(i=e?M(r.layers,e)?.layer??null:null,i?.type!==`image`)return X({tone:`info`,title:H(`quick.needImage`)}),null;n.store.select(i.id)}let a=_p(n,i),o={x:a.x+a.width/2,y:a.y+a.height/2},s=pf({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(cm).then(e=>e?lm(n,d,u):void 0),null},key(e,t){let n=e.api.ui.get().quick;return n&&t.key===`Enter`?(um(e.api),!0):t.key===`Escape`&&(n||e.api.ui.get().region)?(e.api.ui.set(n?{quick:null}:{region:null}),!0):!1},Options:fm};function fm(){let{t:e}=U(),t=J(),n=Y(e=>e.quick),r=Y(e=>e.region);return(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`tabular-nums`,children:e(`quick.points`,{n:n.points.length})}),(0,G.jsxs)(fu,{size:`xs`,variant:`primary`,disabled:!n.region||n.busy,onClick:()=>um(t),children:[(0,G.jsx)(Se,{size:13}),` `,e(`quick.apply`)]}),(0,G.jsxs)(fu,{size:`xs`,variant:`ghost`,onClick:()=>t.ui.set({quick:null}),children:[(0,G.jsx)(cn,{size:13}),` `,e(`quick.reset`)]})]}):r?(0,G.jsx)(Np,{}):null,(0,G.jsx)(`span`,{className:`ml-2 text-fg-faint`,children:e(`quick.hint`)})]})}var pm=7,mm=0;function hm(e){return e.type===`text`?df.filter(e=>e.hx!==0):df}function gm(e,t){let n=hf(e,{hx:0,hy:-1}),r=pf({x:0,y:-22/t},e.rotation);return{x:n.x+r.x,y:n.y+r.y}}var _m=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function vm(e,t){let{store:n,boxes:r}=e.api,i=n.getSnapshot();if(i.selection.length!==1||!i.doc)return null;let a=M(i.doc.layers,i.selection[0]);if(!a||!Rr(a.layer)||a.layer.locked)return null;let o=r.get(a.layer.id);if(!o)return null;let s=e.view().zoom;if(_m(e.toScreen(gm(o,s)),t)<=8)return{layer:a.layer,box:o,hit:{kind:`rotate`}};for(let n of hm(a.layer))if(_m(e.toScreen(hf(o,n)),t)<=pm)return{layer:a.layer,box:o,hit:{kind:`resize`,handle:n}};return null}var ym=[`ew-resize`,`nwse-resize`,`ns-resize`,`nesw-resize`];function bm(e,t){let n=Math.atan2(e.hy,e.hx)*180/Math.PI+t;return ym[Math.round((n%180+180)%180/45)%4]}var xm=`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 Sm(e,t,n){let{api:r}=e,i=r.store.doc,a=Pf(i.layers,n),o=a.map(e=>({id:e.id,x:e.x??0,y:e.y??0})),s=r.boxes.getSnapshot(),c=Ff(s,a),l=new Set(a.map(e=>e.id)),u=[...s.entries()].filter(([e])=>!l.has(e)).map(([,e])=>jf(e)),d=yf(i.canvas,u),f=`move:${++mm}`,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=vf({...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 Cm=e=>Math.round(e*10)/10;function wm(e,t,n,r){let i=`resize:${++mm}`,a=t.type===`text`?t:null;return{cursor:bm(r,n.rotation),move(o){let s=r.hx!==0&&r.hy!==0,c=gf(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:Cm((a.size??64)*e),...a.width?{width:Math.round(a.width*e)}:{},...a.letterSpacing?{letterSpacing:Cm(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 Tm(e,t,n,r){let i=`rotate:${++mm}`;return{cursor:xm,move(a){e.api.edit([{op:`updateLayer`,id:t.id,set:{rotation:_f(n,r.doc,a.doc,a.shift)}}],{coalesce:i})},up(){}}}var Em={id:`move`,icon:Gt,label:`tools.move`,shortcut:`V`,group:`select`,cursor(e,t){if(!t)return`default`;let n=vm(e,t.screen);return n?n.hit.kind===`rotate`?xm:bm(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=vm(e,t.screen);if(a)return a.hit.kind===`rotate`?Tm(e,a.layer,a.box,t):wm(e,a.layer,a.box,a.hit.handle);let o=n.boxes.getSnapshot(),s=Nf(i.layers,o,t.doc);if(t.clicks>=2&&s&&M(i.layers,s)?.layer?.type===`text`)return n.store.select(s),n.ui.set({textEdit:{id:s}}),null;let c=Pf(i.layers,r.selection),l=c.length?Ff(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)?Sm(e,t,r.selection):s?t.shift||t.mod?(n.store.toggleSelect(s),null):(n.store.select(s),Sm(e,t,[s])):(!t.shift&&!t.mod&&n.store.select(null),null)},Options:Dm};function Dm(){let{t:e}=U(),{ui:t}=J(),n=Y(e=>e.smartGuides);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(hu,{checked:n,onChange:e=>t.set({smartGuides:e}),ariaLabel:e(`tools.smartGuides`)}),(0,G.jsx)(`span`,{children:e(`tools.smartGuides`)}),(0,G.jsx)(`span`,{className:`ml-3 text-fg-faint`,children:e(`tools.moveHint`)})]})}var Om=.02;function km(e,t,n){let r=Math.max(Om,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 Am(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 jm={id:`hand`,icon:at,label:`tools.hand`,shortcut:`H`,group:`view`,cursor:()=>`grab`,down:(e,t)=>Am(e,t)},Mm={id:`zoom`,icon:br,label:`tools.zoom`,shortcut:`Z`,group:`view`,cursor:(e,t)=>t?.alt?`zoom-out`:`zoom-in`,down(e,t){return e.setView(km(e.view(),t.alt?.5:2,t.screen)),null}},Nm={id:`eyedropper`,icon:tn,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}),Qu(n),X({tone:`info`,title:H(`tools.picked`,{color:n}),detail:H(`tools.pickedHint`)},2400)),null},Options:Pm};function Pm(){let{t:e}=U(),t=J(),n=Y(e=>e.fg);return(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`tools.color`)}),(0,G.jsx)(`div`,{className:`w-[120px]`,children:(0,G.jsx)(Wd,{value:n,onChange:e=>t.ui.set({fg:e})})}),(0,G.jsx)(`span`,{className:`ml-2 text-2xs text-fg-faint`,children:e(`tools.eyedropperHint`)})]})}var Fm=[Em,Ip,Bp,om,dm,Ef,If,zf,tm,nm,rm,Nm,jm,Mm],Im=e=>Fm.find(t=>t.id===e)??Em,Lm=e=>Fm.find(t=>t.shortcut.toLowerCase()===e.toLowerCase()),Rm=e=>{let t=e.store.primary,n=e.store.doc,r=t&&n?M(n.layers,t)?.layer:null;return r&&r.type===`image`?r.id:null};function zm(e,t,n=ei[`background-removal`]){return e.runTool(`remove_background`,{id:t,model:n},{busy:`ai.removingBg`,model:n})}function Bm(e,t,n=ei[`background-removal`]){return e.runTool(`mask_generate`,{id:t,method:`subject`,target:`copy`,model:n},{busy:`ai.selectingSubject`,model:n})}var Vm=[{id:`remove-background`,icon:mr,label:`ai.removeBg`,hint:`ai.removeBgHint`,enabled:e=>!!Rm(e),run:e=>void zm(e,Rm(e))},{id:`select-subject`,icon:fn,label:`ai.selectSubject`,hint:`ai.selectSubjectHint`,enabled:e=>!!Rm(e),run:e=>void Bm(e,Rm(e))}];function Hm(){let{t:e}=U(),t=Im(Y(e=>e.tool)),n=t.Options;return(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-3 border-b border-line bg-ink-1/80 px-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-[118px] shrink-0 items-center gap-1.5 whitespace-nowrap text-xs font-medium text-fg`,children:[(0,G.jsx)(t.icon,{size:13,className:`text-fg-muted`}),e(t.label)]}),(0,G.jsx)(`div`,{className:`h-4 w-px bg-line`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto whitespace-nowrap [&_span]:whitespace-nowrap`,children:n?(0,G.jsx)(n,{}):(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:e(`tools.hints.${t.id}`)})})]})}var Um=236,Wm=6,Gm=224,Km=e=>Wm+e/255*Gm,qm=e=>Wm+(1-e/255)*Gm;function Jm({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=lc(s),l=Array.from({length:64},(e,t)=>{let n=Math.round(t/63*255);return`${t?`L`:`M`}${Km(n).toFixed(1)},${qm(c[n]).toFixed(1)}`}).join(``),u=e=>{let t=r.current.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*Um,i=(e.clientY-t.top)/t.height*Um;return{x:Math.round((n-Wm)/Gm*255),y:Math.round((1-(i-Wm)/Gm)*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,G.jsxs)(`svg`,{ref:r,viewBox:`0 0 ${Um} ${Um}`,className:`aspect-square w-full touch-none select-none rounded-md bg-ink-0`,role:`img`,"aria-label":H(`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,G.jsxs)(`g`,{stroke:`rgb(255 255 255 / 0.07)`,children:[(0,G.jsx)(`line`,{x1:Wm+e*Gm,y1:Wm,x2:Wm+e*Gm,y2:230}),(0,G.jsx)(`line`,{x1:Wm,y1:Wm+e*Gm,x2:230,y2:Wm+e*Gm})]},e)),(0,G.jsx)(`rect`,{x:Wm,y:Wm,width:Gm,height:Gm,fill:`none`,stroke:`rgb(255 255 255 / 0.12)`}),(0,G.jsx)(`line`,{x1:Km(0),y1:qm(0),x2:Km(255),y2:qm(255),stroke:`rgb(255 255 255 / 0.12)`,strokeDasharray:`3 3`}),(0,G.jsx)(`path`,{d:l,fill:`none`,stroke:n,strokeWidth:1.75}),s.map(([e,r],c)=>(0,G.jsx)(`circle`,{cx:Km(e),cy:qm(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 Ym({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, ${Od(e).map(([e,t])=>`${t} ${e*100}%`).join(`, `)})`;return(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{ref:i,className:`checker-sm relative h-6 cursor-copy rounded-md ring-1 ring-inset ring-white/10`,title:H(`paint.addStop`),onPointerDown:n=>{if(n.target!==n.currentTarget)return;let i=o(n.clientX),a=[...e,[Math.round(i*1e3)/1e3,kd(e,i)]];t(a,!0),r(a.length-1)},children:(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 rounded-md`,style:{background:s}})}),(0,G.jsx)(`div`,{className:`relative h-4`,children:e.map(([i,s],c)=>(0,G.jsx)(`button`,{type:`button`,"aria-label":H(`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:W(`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 Xm({stops:e,onChange:t}){let[n,r]=(0,S.useState)(0),i=Math.min(n,e.length-1),a=e[i];return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Ym,{stops:e,onChange:t,selected:i,onSelect:r}),a&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Pd,{width:232,align:`start`,trigger:(e,t)=>(0,G.jsx)(Ud,{css:a[1],onClick:e,open:t}),children:()=>(0,G.jsx)(Vd,{value:a[1],onChange:(n,r)=>t(e.map((e,t)=>t===i?[e[0],n]:e),r)})}),(0,G.jsx)(Jd,{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:H(`paint.position`)}),(0,G.jsx)(`button`,{type:`button`,title:H(`paint.reverse`),"aria-label":H(`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,G.jsx)(ie,{size:12})}),(0,G.jsx)(`button`,{type:`button`,title:H(`paint.removeStop`),"aria-label":H(`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,G.jsx)(nr,{size:12})})]})]})}function Zm({value:e,onChange:t,allowNone:n,fallback:r=`#ffffff`}){let i=e==null?`none`:Ed(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?Dd(c):[],u=Math.min(a,Math.max(0,l.length-1)),d=(e,n)=>c&&t({...c,...e},n);return(0,G.jsxs)(`div`,{className:`w-[252px]`,children:[(0,G.jsx)(`div`,{className:`flex gap-0.5 border-b border-line p-1.5`,children:s.map(n=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(n===`none`?null:Md(e,n,r),!0),className:W(`h-6 flex-1 rounded text-xs font-medium`,i===n?`bg-ink-3 text-fg`:`text-fg-muted hover:text-fg`),children:H(`paint.${n}`)},n))}),i===`solid`&&(0,G.jsx)(Vd,{value:e,onChange:(e,n)=>t(e,n)}),c&&(0,G.jsxs)(`div`,{className:`space-y-2.5 p-2.5`,children:[(0,G.jsx)(Ym,{stops:l,selected:u,onSelect:o,onChange:(e,t)=>d({stops:e},t)}),c.type===`linear`?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Qm,{value:c.angle??90,onChange:(e,t)=>d({angle:e},t)}),(0,G.jsx)(Jd,{label:`°`,value:c.angle??90,min:-360,max:360,integer:!0,onChange:(e,t)=>d({angle:e},t),ariaLabel:H(`paint.angle`)}),(0,G.jsx)(`button`,{type:`button`,title:H(`paint.reverse`),"aria-label":H(`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,G.jsx)(ie,{size:12})})]}):(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(Jd,{label:`X`,value:Math.round((c.cx??.5)*100),min:0,max:100,integer:!0,onChange:(e,t)=>d({cx:e/100},t),ariaLabel:H(`paint.centerX`)}),(0,G.jsx)(Jd,{label:`Y`,value:Math.round((c.cy??.5)*100),min:0,max:100,integer:!0,onChange:(e,t)=>d({cy:e/100},t),ariaLabel:H(`paint.centerY`)}),(0,G.jsx)(Jd,{label:`R`,value:Math.round((c.radius??1)*100),min:1,max:300,integer:!0,onChange:(e,t)=>d({radius:e/100},t),ariaLabel:H(`paint.radius`)})]}),l[u]&&(0,G.jsxs)(`div`,{className:`-mx-2.5 border-t border-line`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 pt-2 text-2xs text-fg-faint`,children:[(0,G.jsx)(`span`,{children:H(`paint.stop`,{n:u+1})}),(0,G.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:H(`paint.removeStop`)})]}),(0,G.jsx)(Vd,{value:l[u][1],onChange:(e,t)=>d({stops:l.map((t,n)=>n===u?[t[0],e]:t)},t)})]})]})]})}function Qm({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,G.jsx)(`div`,{ref:n,role:`slider`,"aria-label":H(`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,G.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 $m({value:e,onChange:t,allowNone:n,fallback:r,label:i}){let a=e==null?`none`:Ed(e);return(0,G.jsx)(Pd,{width:252,align:`start`,anchorClass:`flex min-w-0 flex-1`,trigger:(t,n)=>(0,G.jsxs)(`button`,{type:`button`,"aria-label":i??H(`paint.edit`),"aria-expanded":n,onClick:t,className:W(`field flex items-center gap-1.5 pl-0.5`,n&&`border-accent/70 bg-ink-1`),children:[(0,G.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,G.jsx)(`span`,{className:`absolute inset-0`,style:{background:jd(e??null)}})}),(0,G.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-muted`,children:a===`none`?H(`paint.none`):a===`solid`?String(e):H(`paint.${a}`)})]}),children:()=>(0,G.jsx)(Zm,{value:e,onChange:t,allowNone:n,fallback:r})})}function eh({def:e,value:t,onChange:n,scope:r}){let i=Qd(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,G.jsx)(q,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,G.jsx)(Yd,{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,G.jsx)(q,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,G.jsx)(hu,{checked:!!a,onChange:e=>n(e,!0),ariaLabel:i})});case`color`:return(0,G.jsx)(q,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,G.jsx)(Wd,{value:typeof a==`string`?a:`#000000`,onChange:n})});case`enum`:return(0,G.jsx)(q,{label:i,hint:e.description,overridden:o,onReset:s,children:(0,G.jsx)(mu,{value:String(a??``),options:(e.options??[]).map(t=>({value:t,label:ef(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,G.jsxs)(`div`,{className:`px-3 py-1`,children:[(0,G.jsxs)(`div`,{className:`mb-0.5 flex items-center justify-between text-xs text-fg-muted`,title:e.description,children:[i,o&&(0,G.jsx)(`button`,{type:`button`,onClick:s,className:`text-2xs text-fg-faint hover:text-fg`,children:`↺`})]}),t.map((a,o)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{background:r[o]}}),(0,G.jsx)(Yd,{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=Dd({type:`linear`,stops:Array.isArray(a)?a:[`#000000`,`#ffffff`]});return(0,G.jsxs)(`div`,{className:`px-3 py-1.5`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs text-fg-muted`,title:e.description,children:i}),(0,G.jsx)(Xm,{stops:t,onChange:(e,t)=>n(e,t)})]})}case`curve`:return null;default:return null}}function th({filter:e,onChange:t}){return(0,G.jsx)(rh,{filter:e,onChange:t})}var nh=[{id:`rgb`,color:`rgb(var(--fg))`},{id:`red`,color:`#f2766d`},{id:`green`,color:`#7bd88f`},{id:`blue`,color:`#6fa8ff`}];function rh({filter:e,onChange:t}){let{t:n}=U(),[r,i]=(0,S.useState)(`rgb`),a=nh.find(e=>e.id===r),o=Array.isArray(e[r])?e[r]:[[0,0],[255,255]];return(0,G.jsxs)(`div`,{className:`space-y-1.5 px-3 py-1.5`,children:[(0,G.jsx)(`div`,{className:`flex gap-0.5`,children:nh.map(e=>(0,G.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,G.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{background:e.color}}),n(`curve.${e.id}`)]},e.id))}),(0,G.jsx)(Jm,{points:o,color:a.color,onChange:(e,n)=>t(r,e,n)}),(0,G.jsxs)(`div`,{className:`flex justify-between text-2xs text-fg-faint`,children:[(0,G.jsx)(`span`,{children:n(`curve.hint`)}),Array.isArray(e[r])&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(r,void 0,!0),className:`hover:text-fg`,children:n(`curve.reset`)})]})]})}function ih(e){return Object.fromEntries(e.params.filter(e=>e.default!==void 0).map(e=>[e.name,e.default]))}function ah(){let{t:e}=U(),t=J(),n=wu();if(!n||n.type===`adjustment`)return(0,G.jsx)(vu,{icon:(0,G.jsx)(On,{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,G.jsxs)(`div`,{className:`pb-4`,children:[(0,G.jsxs)(`div`,{className:`border-b border-line px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`effects.title`)}),(0,G.jsx)(`div`,{className:`text-2xs text-fg-faint`,children:e(`effects.hint`)})]}),(0,G.jsx)(`div`,{className:`space-y-1.5 p-2`,children:Xr.map(e=>{let t=r[e.id],n=!!t;return(0,G.jsxs)(`div`,{className:W(`overflow-hidden rounded-lg border bg-ink-2/40`,n?`border-line`:`border-line/60`),children:[(0,G.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2.5`,children:[(0,G.jsx)(hu,{checked:n,onChange:t=>i(e.id,t?ih(e):null),ariaLabel:rf(e.id)}),(0,G.jsx)(`span`,{className:W(`flex-1 text-sm font-medium`,!n&&`text-fg-muted`),title:e.description,children:rf(e.id)})]}),n&&(0,G.jsx)(`div`,{className:`border-t border-line/70 py-1`,children:e.params.map(n=>(0,G.jsx)(eh,{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 oh=[`auto`,`light`,`tone`,`color`,`detail`,`blur`,`stylize`,`look`];function sh(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 ch(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 X({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=nd(o,`auto-enhance`);s=[{op:`addLayer`,layer:{id:e,type:`adjustment`,name:n(`filters.autoName`),filters:a}}],c=e}e.edit(s,{select:c})&&X({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 lh(){let{t:e}=U(),t=J(),n=wu(),[r,i]=(0,S.useState)({}),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!1);if(!n)return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(vu,{icon:(0,G.jsx)(En,{size:22}),title:e(`filters.noLayer`),children:e(`filters.noLayerHint`)}),(0,G.jsx)(`div`,{className:`flex justify-center`,children:(0,G.jsxs)(fu,{size:`sm`,variant:`subtle`,disabled:s,onClick:async()=>(c(!0),await ch(t,null,e),c(!1)),children:[(0,G.jsx)(An,{size:13,className:`text-agent`}),` `,e(`filters.autoWhole`)]})})]});let l=n.filters??[],u=n.id,d=e=>{let n=ii(e);n&&(t.edit([{op:`addFilter`,id:u,filter:sh(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,G.jsxs)(`div`,{className:`pb-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:n.type===`adjustment`?e(`filters.adjustTitle`):e(`filters.title`)}),(0,G.jsx)(`div`,{className:`truncate text-2xs text-fg-faint`,children:n.type===`adjustment`?e(`filters.adjustHint`):e(`filters.hint`)})]}),(0,G.jsx)(uh,{onPick:d})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:(0,G.jsxs)(fu,{size:`xs`,variant:`subtle`,disabled:s,onClick:async()=>(c(!0),await ch(t,n,e),c(!1)),className:`flex-1`,children:[(0,G.jsx)(An,{size:12,className:`text-agent`}),` `,e(`filters.auto`)]})}),!l.length&&(0,G.jsx)(vu,{icon:(0,G.jsx)(En,{size:20}),title:e(`filters.empty`),children:e(`filters.emptyHint`)}),(0,G.jsx)(`div`,{className:`space-y-1.5 p-2`,children:l.map((n,s)=>{let c=ii(n.type),d=r[s]??s===l.length-1,m=n.enabled!==!1,h=!!c?.params.some(e=>e.name===`amount`);return(0,G.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:W(`overflow-hidden rounded-lg border bg-ink-2/40`,a?.over===s&&a.from!==s?`border-accent`:`border-line`,!m&&`opacity-60`),children:[(0,G.jsxs)(`div`,{className:`flex h-8 items-center gap-1 pl-1 pr-1`,children:[(0,G.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,G.jsx)(rt,{size:12})}),(0,G.jsx)(K,{label:e(m?`filters.disable`:`filters.enable`),onClick:()=>f(s,{enabled:!m&&null},!0),className:`h-6 w-6`,children:m?(0,G.jsx)(Ge,{size:13}):(0,G.jsx)(Ue,{size:13})}),(0,G.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,G.jsx)(we,{size:12,className:`shrink-0 text-fg-faint`}):(0,G.jsx)(De,{size:12,className:`shrink-0 text-fg-faint`}),(0,G.jsx)(`span`,{className:`truncate text-sm font-medium`,children:tf(n.type)}),n.type===`look`&&typeof n.look==`string`&&(0,G.jsxs)(`span`,{className:`truncate text-xs text-fg-muted`,children:[`· `,of(n.look)]}),!c&&(0,G.jsx)(`span`,{className:`text-2xs text-danger`,children:`?`})]}),!h&&(0,G.jsxs)(`span`,{className:`text-2xs tabular-nums text-fg-faint`,children:[Math.round((typeof n.amount==`number`?n.amount:1)*100),`%`]}),(0,G.jsx)(K,{label:e(`filters.remove`),onClick:()=>t.edit([{op:`removeFilter`,id:u,index:s}]),className:`h-6 w-6 hover:text-danger`,children:(0,G.jsx)(nr,{size:12})})]}),d&&c&&(0,G.jsxs)(`div`,{className:`border-t border-line/70 pb-1.5 pt-1`,children:[c.id===`curves`?(0,G.jsx)(th,{filter:n,onChange:(e,t,n)=>f(s,{[e]:t===void 0?null:t},n)}):c.params.map(e=>(0,G.jsx)(eh,{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,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-line/50 px-3 pt-1.5`,children:[(0,G.jsx)(`span`,{className:`w-[86px] shrink-0 text-xs text-fg-muted`,children:e(`filters.amount`)}),(0,G.jsx)(Yd,{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 uh({onPick:e}){let{t}=U(),[n,r]=(0,S.useState)(``),i=(0,S.useRef)(null),a=(0,S.useMemo)(()=>{let e=n.trim().toLowerCase();return oh.map(t=>({g:t,list:Jr.filter(n=>n.group===t&&(!e||tf(n.id).toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)))})).filter(e=>e.list.length)},[n]);return(0,G.jsx)(Pd,{width:268,trigger:(e,n)=>(0,G.jsxs)(fu,{size:`xs`,variant:n?`subtle`:`primary`,onClick:()=>(e(),setTimeout(()=>i.current?.focus(),30)),children:[(0,G.jsx)(rn,{size:12}),` `,t(`filters.add`)]}),children:o=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-2.5`,children:[(0,G.jsx)(gn,{size:12,className:`text-fg-faint`}),(0,G.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,G.jsx)(`div`,{className:`max-h-[420px] overflow-auto py-1`,children:a.map(({g:t,list:n})=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`px-3 pb-0.5 pt-2 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:nf(t)}),n.map(t=>(0,G.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,G.jsx)(`div`,{className:`text-sm`,children:tf(t.id)})},t.id))]},t))})]})})}var dh=Promise.resolve();function fh(e){let t=dh.then(e,e);return dh=t.catch(()=>void 0),t}var ph=()=>typeof window<`u`?Math.min(2,window.devicePixelRatio||1):1;function mh({layer:e,w:t,h:n}){let r=J(),i=Cu(),a=Y(e=>e.filesVersion),o=(0,S.useRef)(null),[s,c]=(0,S.useState)(!1),l=`${co(e)}|${i.canvas.width}x${i.canvas.height}|${a}`;(0,S.useEffect)(()=>{let a=!1,s=setTimeout(()=>{fh(async()=>{if(a)return;let s=r.boxes.get(e.id),l=s?jf(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)*ph()*(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*ph():i.canvas.width*p)),h.height=Math.max(1,Math.round(u?n*ph():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,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-center`,style:{width:t,height:n},children:(0,G.jsx)(`canvas`,{ref:o,className:`checker-sm rounded-[2px] ring-1 ring-white/10`,style:{width:d,height:f}})})}function hh({mask:e,w:t,h:n,frame:r}){let i=J(),a=Y(e=>e.filesVersion),o=(0,S.useRef)(null),s=zr(e)?e.src:null;if((0,S.useEffect)(()=>{if(!s)return;let r=!1;return fh(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,G.jsx)(`canvas`,{ref:o,style:{width:t,height:n},className:`rounded-[2px] bg-black`});if(Vr(e))return(0,G.jsx)(`div`,{style:{width:t,height:n,background:jd(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,G.jsx)(`div`,{style:{width:t,height:n,background:e.invert?`#fff`:`#000`},className:`relative overflow-hidden rounded-[2px]`,children:(0,G.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 gh=104,_h=72;function vh(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 yh(e,t){return{...e,filters:(e.filters??[]).filter((e,n)=>n!==t)}}function bh(){let{t:e}=U(),t=J(),n=Su().doc,r=wu(),i=Y(e=>e.filesVersion),a=vh(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 Sl({assetBase:``,libraryBase:``},t.engine.loader),[t]),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(1),p=JSON.stringify([a.kind===`layer`?yh(a.layer,a.index):null,a.kind===`picture`?n.layers.map(e=>e===a.layer?yh(e,a.index):e):null,n.canvas,i]);(0,S.useEffect)(()=>{let e=!0,r=setTimeout(()=>{fh(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?yh(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?yh(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=nd(n,`look`);t.edit([{op:`addLayer`,layer:{id:i,type:`adjustment`,name:e(`looks.layerName`),filters:[{type:`look`,look:r,amount:.85}]}}])}};return(0,G.jsxs)(`div`,{className:`pb-4`,children:[(0,G.jsxs)(`div`,{className:`border-b border-line px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`looks.title`)}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`w-[70px] shrink-0 text-xs text-fg-muted`,children:e(`looks.intensity`)}),(0,G.jsx)(Yd,{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,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 p-2.5`,children:[(0,G.jsx)(xh,{id:null,title:e(`looks.none`),base:l,scale:d,active:!s,onClick:()=>m(null)}),qr.map(e=>(0,G.jsx)(xh,{id:e.id,title:of(e.id),base:l,scale:d,active:s===e.id,onClick:()=>m(e.id),hint:e.description},e.id))]})]})}function xh({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 fh(async()=>{let i=s.current;if(!i||!t)return;let a=vc(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=yc(a);Jc(t,[{type:`look`,look:e}],{scale:r*o}),bc(a,t)}i.width=208,i.height=144,i.getContext(`2d`).drawImage(a,0,0),t&&l(!0)}),()=>{t=!1}},[n,e,r]),(0,G.jsxs)(`button`,{type:`button`,onClick:a,title:o,"aria-pressed":i,className:W(`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,G.jsxs)(`div`,{className:`checker-sm relative`,style:{aspectRatio:`${gh} / ${_h}`},children:[(0,G.jsx)(`canvas`,{ref:s,className:W(`absolute inset-0 h-full w-full object-cover transition-opacity`,c?`opacity-100`:`opacity-0`)}),!c&&n&&(0,G.jsx)(Nt,{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,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/30`,children:(0,G.jsx)(fe,{size:16,className:`text-white/80`})}),i&&(0,G.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,G.jsx)(Se,{size:10,strokeWidth:3})})]}),(0,G.jsx)(`div`,{className:`flex items-center justify-between bg-ink-2/80 px-2 py-1 text-xs`,children:(0,G.jsx)(`span`,{className:`truncate`,children:t})})]})}var Sh=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)}},Ch={current:null},wh=new Set([`marquee`,`lasso`,`wand`,`quick`,`brush`,`eraser`,`clone`]),Th=e=>{let t=e.target;return!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)};function Eh(e,t){let n=e.ui.get().tool;n!==t&&(Im(n).deactivate?.(e),e.ui.set({tool:t,textEdit:null}),Im(t).activate?.(e))}function Dh(e){let t=e.store.doc,n=e.store.getSnapshot().selection;if(!t||!n.length)return;let r=new Set(fa(t)),i=[],a=[];for(let e of n){let t=Ci(`${e}-copy`,r);r.add(t),i.push({op:`duplicateLayer`,id:e,newId:t}),a.push(t)}e.edit(i,{select:a})}function Oh(e){let t=e.store.doc,n=e.store.getSnapshot().selection.filter(e=>t&&M(t.layers,e));if(!n.length)return;let r=n.filter(e=>!n.some(n=>n!==e&&M(M(t.layers,n)?.layer?.children??[],e)));e.edit(r.map(e=>({op:`removeLayer`,id:e})),{select:null})}function kh(e){let t=e.store.doc;if(!t)return;let n=fd(t,e.store.getSnapshot().selection);if(!n)return void X({tone:`error`,title:H(`layers.groupSiblings`)});e.edit(n.ops,{select:n.id})}function Ah(e){let t=e.store.doc,n=e.store.primary,r=n&&t?M(t.layers,n)?.layer:null;r&&r.type===`group`&&e.edit([{op:`ungroup`,id:r.id}],{select:(r.children??[]).map(e=>e.id)})}function jh(e,t){let n=document.querySelector(`[data-viewport]`)?.getBoundingClientRect();e.ui.set(e=>({view:km(e.view,t,{x:(n?.width??800)/2,y:(n?.height??600)/2})}))}function Mh(e,t){let n=e.ui.get().view;jh(e,t/n.zoom)}function Nh(){let e=J();(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(Th(t))return;t.preventDefault(),t.shiftKey?r.redo():r.undo();return}if(n&&a===`y`){if(Th(t))return;t.preventDefault(),r.redo();return}if(n&&a===`s`){t.preventDefault(),r.flush().then(()=>X({tone:`success`,title:H(`save.savedToast`)},1600));return}if(Th(t)||i.get().dialog)return;let o=Ch.current;if(o&&Im(i.get().tool).key?.(o,t)){t.preventDefault();return}if(n){if(a===`d`)t.preventDefault(),Dh(e);else if(a===`g`)t.preventDefault(),t.shiftKey?Ah(e):kh(e);else if(a===`0`)t.preventDefault(),i.set(e=>({fitRequest:e.fitRequest+1}));else if(a===`1`)t.preventDefault(),Mh(e,1);else if(a===`=`||a===`+`)t.preventDefault(),jh(e,1.25);else if(a===`-`)t.preventDefault(),jh(e,.8);else if(a===`a`){t.preventDefault();let n=r.doc;wh.has(i.get().tool)?Mp(e):n&&r.select(n.layers.map(e=>e.id).reverse())}else a===`i`&&t.shiftKey&&(t.preventDefault(),Ap(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=md(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?wp(e):Oh(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=Lm(t.key);n&&Eh(e,n.id)}}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function Ph(){let e=J(),t=Y(e=>e.textEdit),n=Y(e=>e.view),r=Y(e=>e.fg),i=Su().doc,a=(0,S.useRef)(null),o=(0,S.useRef)(!1),[s,c]=(0,S.useState)(null),l=t?.id?M(i.layers,t.id)?.layer:void 0,[u]=(0,S.useState)(()=>t&&`x`in t?od(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=oi(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=od(n,{x:d.x??0,y:d.y??0},t,{color:Ad(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,G.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:Ad(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 Fh=`rgb(255 79 216)`;function Ih(e,t){let n=e*t;return n>=1?1:Math.min(1,2**(Math.ceil(Math.log2(n)*4)/4))}function Lh(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 Rh(e,t){let n=M(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 zh(){let{t:e}=U(),t=J(),{ui:n,store:r,engine:i,boxes:a}=t,o=Su(),s=o.doc,c=o.selection,l=Y(e=>e.view),u=Y(e=>e.tool),d=Y(e=>e.textEdit),f=Y(e=>e.region),p=Y(e=>e.quick),m=Y(e=>e.brush.size),h=Y(e=>e.cloneSource),g=Y(e=>e.crop),_=Y(e=>e.flash),v=Y(e=>e.fitRequest),y=Y(e=>e.filesVersion),b=Y(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 Sh(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 Te=Ih(l.zoom,we),[Ee,De]=(0,S.useState)(Te);(0,S.useEffect)(()=>{let e=setTimeout(()=>De(Te),Te>Ee?120:250);return()=>clearTimeout(e)},[Te,Ee]);let Oe=d?.id??null;(0,S.useEffect)(()=>{let e=b?Rh(s,b):null,t=[Oe,ie?.hide].filter(e=>!!e);E.request({doc:e??s,scale:Ee,skip:t.length?new Set(t):void 0})},[E,s,Ee,Oe,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 ke=(0,S.useRef)(-1);(0,S.useLayoutEffect)(()=>{ve.w&&ve.h&&ke.current!==v&&(ke.current=v,n.set({view:Lh(r.doc,ve.w,ve.h)}))},[v,ve,n,r]);let Ae=(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:Cd({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)(()=>(Ch.current=Ae,()=>{Ch.current===Ae&&(Ch.current=null)}),[Ae]),(0,S.useEffect)(()=>{Im(u).activate?.(t)},[u,t]);let je=(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:km(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===` `&&!Th(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(Th(e)||n.get().dialog)return;let r=[...e.clipboardData?.files??[]].filter(e=>e.type.startsWith(`image/`));r.length&&(e.preventDefault(),Wh(r).then(e=>t.importImages(e)))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[t,n]);let Me=e=>{if(e.button===2)return;if(n.get().textEdit){document.activeElement?.blur?.(),n.get().textEdit&&n.set({textEdit:null});return}let t=je(e),r=Im(n.get().tool),i;e.button===1||Ce.current||r.id===`hand`?i=Am(Ae,t):e.button===0&&(i=r.down?.(Ae,t)),i&&(Se.current=i,e.currentTarget.setPointerCapture(e.pointerId),i.cursor&&he(i.cursor),e.preventDefault())},Ne=e=>{let t=je(e);n.set({cursor:{x:Math.floor(t.doc.x),y:Math.floor(t.doc.y)}}),ce.current=t.doc,Pe(t.screen);let i=Se.current;if(i){i.move(t);return}if(Ce.current)return he(`grab`);let o=Im(n.get().tool);he(o.cursor(Ae,t)),o.hover?.(Ae,t),o.id===`move`&&r.doc?pe(Nf(r.doc.layers,a.getSnapshot(),t.doc)):fe&&pe(null)},Pe=e=>{let t=se.current;t&&(t.style.transform=`translate(${e.x}px, ${e.y}px)`,t.style.display=`block`)},Fe=(e,t=!1)=>{let r=Se.current;if(Se.current=null,!r)return;t?r.cancel?.():r.up(je(e));let i=Im(n.get().tool);he(Ce.current?`grab`:i.cursor(Ae,je(e)))},Ie=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=je({clientX:e.clientX,clientY:e.clientY,shiftKey:!1,altKey:!1,metaKey:!1,ctrlKey:!1});Wh(n).then(e=>t.importImages(e,r.doc))},D=l.zoom,O=e=>({x:l.x+e.x*D,y:l.y+e.y*D}),Le=e=>e.map(e=>O(e)).map(e=>`${e.x},${e.y}`).join(` `),Re=s.canvas.width*D,ze=s.canvas.height*D,Be=c.map(e=>M(s.layers,e)?.layer).filter(e=>!!e),Ve=Be[Be.length-1],He=Be.length===1&&Ve&&Rr(Ve)?x.get(Ve.id):void 0,Ue=!He&&Be.length?Ff(x,Pf(s.layers,c)):null,We=u===`move`&&He&&Ve&&!Ve.locked&&!d,Ge=(0,S.useMemo)(()=>f?.kind===`raster`?ap(f.raster):null,[f]),Ke=_&&Date.now()-_.at<3e3?_:null;return(0,G.jsxs)(`div`,{ref:ee,"data-viewport":!0,tabIndex:-1,className:W(`viewport-stage relative min-h-0 flex-1 overflow-hidden outline-none`,ge&&`ring-2 ring-inset ring-accent/60`),style:{cursor:me},onPointerDown:Me,onMouseDown:e=>{e.target.isContentEditable||e.preventDefault()},onPointerMove:Ne,onPointerUp:e=>Fe(e),onPointerCancel:e=>Fe(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:Ie,children:[(0,G.jsx)(`div`,{className:`checker canvas-shadow absolute`,style:{left:l.x,top:l.y,width:Re,height:ze},children:(0,G.jsx)(`canvas`,{ref:te,className:W(`absolute inset-0 h-full w-full transition-opacity duration-150`,be?`opacity-100`:`opacity-0`),style:{imageRendering:D*we>=2.5?`pixelated`:`auto`}})}),(0,G.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,G.jsx)(`polygon`,{points:Le(Af(x.get(fe))),fill:`none`,stroke:`rgb(var(--accent) / 0.7)`,strokeWidth:1}),!g&&Be.map(e=>{let t=Rr(e)?x.get(e.id):void 0;return t?(0,G.jsx)(`polygon`,{points:Le(Af(t)),fill:`none`,stroke:`rgb(var(--accent))`,strokeWidth:1.25},e.id):null}),!g&&Ue&&Be.some(e=>!Rr(e)||Be.length>1)&&(0,G.jsx)(`rect`,{x:O(Ue).x,y:O(Ue).y,width:Ue.width*D,height:Ue.height*D,fill:`none`,stroke:`rgb(var(--accent))`,strokeDasharray:`4 3`,strokeWidth:1}),We&&He&&(0,G.jsxs)(`g`,{children:[(()=>{let e=O(hf(He,{hx:0,hy:-1})),t=O(gm(He,D));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`line`,{x1:e.x,y1:e.y,x2:t.x,y2:t.y,stroke:`rgb(var(--accent))`,strokeWidth:1}),(0,G.jsx)(`circle`,{cx:t.x,cy:t.y,r:4.5,fill:`#fff`,stroke:`rgb(var(--accent))`,strokeWidth:1.25})]})})(),hm(Ve).map(e=>{let t=O(hf(He,e));return(0,G.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:He.rotation?`rotate(${He.rotation} ${t.x} ${t.y})`:void 0},`${e.hx}${e.hy}`)})]}),w.map((e,t)=>e.axis===`x`?(0,G.jsx)(`line`,{x1:l.x+e.at*D,x2:l.x+e.at*D,y1:0,y2:`100%`,stroke:Fh,strokeWidth:1},t):(0,G.jsx)(`line`,{y1:l.y+e.at*D,y2:l.y+e.at*D,x1:0,x2:`100%`,stroke:Fh,strokeWidth:1},t)),f&&f.kind!==`raster`&&(0,G.jsx)(Hh,{m:f,S:O,z:D}),f&&f.kind===`raster`&&Ge&&(0,G.jsxs)(`g`,{transform:`translate(${l.x} ${l.y}) scale(${D/Ge.scale})`,children:[(0,G.jsx)(`path`,{d:Ge.d,fill:`none`,stroke:`#000`,strokeWidth:Ge.scale/D,vectorEffect:`non-scaling-stroke`}),(0,G.jsx)(`path`,{d:Ge.d,fill:`none`,stroke:`#fff`,strokeWidth:1,strokeDasharray:`4 4`,className:`ants`,vectorEffect:`non-scaling-stroke`})]}),ne&&ne.points.length>0&&(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`polyline`,{points:[...ne.points,...ne.toCursor&&ne.cursor?[ne.cursor]:[]].map(e=>`${O(e).x},${O(e).y}`).join(` `),fill:ne.closed?`rgb(var(--accent) / 0.1)`:`none`,stroke:`#000`,strokeWidth:1}),(0,G.jsx)(`polyline`,{points:[...ne.points,...ne.toCursor&&ne.cursor?[ne.cursor]:[]].map(e=>`${O(e).x},${O(e).y}`).join(` `),fill:`none`,stroke:`#fff`,strokeWidth:1,strokeDasharray:`4 4`,className:`ants`}),ne.toCursor&&(0,G.jsx)(`circle`,{cx:O(ne.points[0]).x,cy:O(ne.points[0]).y,r:4,fill:`#fff`,stroke:`rgb(var(--accent))`})]}),u===`clone`&&h&&(0,G.jsxs)(`g`,{stroke:`#fff`,strokeWidth:1.25,style:{filter:`drop-shadow(0 0 1px #000)`},children:[(0,G.jsx)(`circle`,{cx:O(h).x,cy:O(h).y,r:6,fill:`none`}),(0,G.jsx)(`line`,{x1:O(h).x-10,x2:O(h).x+10,y1:O(h).y,y2:O(h).y}),(0,G.jsx)(`line`,{y1:O(h).y-10,y2:O(h).y+10,x1:O(h).x,x2:O(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=pf({x:e-i.width/2,y:t-i.height/2},i.rotation),s=O({x:a.x+o.x,y:a.y+o.y});return(0,G.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,G.jsx)(`line`,{x1:O(ue).x,y1:O(ue).y,x2:O({x:ue.x+ue.width,y:ue.y+ue.height}).x,y2:O({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,G.jsx)(`ellipse`,{cx:O(ue).x+ue.width*D/2,cy:O(ue).y+ue.height*D/2,rx:ue.width*D/2,ry:ue.height*D/2,fill:`rgb(var(--accent) / 0.08)`,stroke:`rgb(var(--accent))`,strokeDasharray:`4 3`}):(0,G.jsx)(`rect`,{x:O(ue).x,y:O(ue).y,width:ue.width*D,height:ue.height*D,fill:`rgb(var(--accent) / 0.08)`,stroke:`rgb(var(--accent))`,strokeDasharray:`4 3`})),g&&u===`crop`&&(0,G.jsx)(Uh,{c:g,S:O,z:D,canvas:{x:l.x,y:l.y,w:Re,h:ze}})]}),Ke&&Ke.ids.map(e=>{let t=x.get(e);if(!t)return null;let n=jf(t);return(0,G.jsx)(`div`,{className:`agent-pulse pointer-events-none absolute rounded-[2px]`,style:{left:l.x+n.x*D,top:l.y+n.y*D,width:n.width*D,height:n.height*D}},`${e}${Ke.at}`)}),p?.region&&p.region.kind===`raster`&&(0,G.jsx)(Vh,{raster:p.region.raster,left:l.x,top:l.y,width:Re,height:ze}),ie&&(0,G.jsx)(`div`,{ref:oe,className:`pointer-events-none absolute left-0 top-0`,style:{width:ie.frame.width*D,height:ie.frame.height*D,transform:`translate(${l.x+ie.frame.x*D}px, ${l.y+ie.frame.y*D}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,G.jsx)(Bh,{canvas:ie.canvas})}),im.has(u)&&(0,G.jsxs)(`div`,{ref:se,className:`pointer-events-none absolute left-0 top-0 hidden`,style:{display:`none`},children:[(0,G.jsx)(`div`,{className:`absolute rounded-full border border-white`,style:{width:m*D,height:m*D,left:-m*D/2,top:-m*D/2,boxShadow:`0 0 0 1px rgb(0 0 0 / 0.55), inset 0 0 0 1px rgb(0 0 0 / 0.35)`}}),(0,G.jsx)(`div`,{className:`absolute -left-[3px] top-0 h-px w-[7px] bg-white mix-blend-difference`}),(0,G.jsx)(`div`,{className:`absolute -top-[3px] left-0 h-[7px] w-px bg-white mix-blend-difference`})]}),d&&(0,G.jsx)(Ph,{},d.id??`new${d.x},${d.y}`),b&&(0,G.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,G.jsx)(`button`,{type:`button`,className:`ml-1 font-medium text-accent hover:underline`,onClick:()=>n.set({showMask:null}),children:e(`viewport.backToImage`)})]}),ge&&(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center bg-accent/5`,children:(0,G.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,G.jsx)(dt,{size:16,className:`text-accent`}),` `,e(`viewport.dropHere`)]})})]})}function Bh({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,G.jsx)(`div`,{ref:t,className:`h-full w-full`})}function Vh({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,G.jsx)(`canvas`,{ref:a,className:`pointer-events-none absolute`,style:{left:t,top:n,width:r,height:i}})}function Hh({m:e,S:t,z:n}){let r=t(e),i=e.width*n,a=e.height*n,o=t=>e.kind===`ellipse`?(0,G.jsx)(`ellipse`,{cx:r.x+i/2,cy:r.y+a/2,rx:i/2,ry:a/2,fill:`none`,...t}):(0,G.jsx)(`rect`,{x:r.x,y:r.y,width:i,height:a,fill:`none`,...t});return(0,G.jsxs)(`g`,{children:[o({stroke:`#000`,strokeWidth:1}),o({stroke:`#fff`,strokeWidth:1,strokeDasharray:`4 4`,className:`ants`})]})}function Uh({c:e,S:t,z:n,canvas:r}){let i=t(e),a=e.width*n,o=e.height*n,s=1e5;return(0,G.jsxs)(`g`,{children:[(0,G.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,G.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,G.jsx)(`rect`,{x:i.x,y:i.y,width:a,height:o,fill:`none`,stroke:`#fff`,strokeWidth:1.25}),[1,2].map(e=>(0,G.jsxs)(`g`,{stroke:`rgb(255 255 255 / 0.45)`,strokeWidth:.75,children:[(0,G.jsx)(`line`,{x1:i.x+a*e/3,x2:i.x+a*e/3,y1:i.y,y2:i.y+o}),(0,G.jsx)(`line`,{y1:i.y+o*e/3,y2:i.y+o*e/3,x1:i.x,x2:i.x+a})]},e)),df.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,G.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,G.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,G.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 Wh(e){return Promise.all(e.map(async e=>({name:e.name||`pasted-${Date.now()}.png`,bytes:new Uint8Array(await e.arrayBuffer())})))}function Gh(){let{t:e}=U(),t=J(),n=Cu(),{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=Qr.find(e=>e.width===a.w&&e.height===a.h)?.id??``,m=()=>t.ui.set(e=>({fitRequest:e.fitRequest+1}));return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`border-b border-line px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`canvas.title`)}),(0,G.jsx)(`div`,{className:`text-2xs text-fg-faint`,children:e(`canvas.subtitle`)})]}),(0,G.jsxs)(gu,{title:e(`canvas.size`),id:`canvas-size`,children:[(0,G.jsx)(q,{label:e(`canvas.preset`),children:(0,G.jsx)(mu,{value:p,placeholder:e(`canvas.custom`),options:Qr.map(e=>({value:e.id,label:`${af(e.id)} · ${e.width}×${e.height}`})),onChange:e=>{let t=Qr.find(t=>t.id===e);t&&o({w:t.width,h:t.height})},ariaLabel:e(`canvas.preset`)})}),(0,G.jsxs)(q,{label:e(`props.size`),children:[(0,G.jsx)(Jd,{label:`W`,value:a.w,min:1,max:16384,integer:!0,onChange:e=>o(t=>({...t,w:e}))}),(0,G.jsx)(Jd,{label:`H`,value:a.h,min:1,max:16384,integer:!0,onChange:e=>o(t=>({...t,h:e}))})]}),(0,G.jsxs)(q,{label:e(`canvas.anchor`),align:`start`,children:[(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-0.5 rounded-md bg-ink-2 p-0.5`,children:po.map(t=>(0,G.jsx)(`button`,{type:`button`,"aria-label":e(`anchors.${t}`),title:e(`anchors.${t}`),onClick:()=>c(t),className:W(`flex h-5 w-6 items-center justify-center rounded-[3px]`,s===t?`bg-accent/80`:`hover:bg-ink-4`),children:(0,G.jsx)(`span`,{className:W(`h-1.5 w-1.5 rounded-full`,s===t?`bg-ink-0`:`bg-fg-faint`)})},t))}),(0,G.jsx)(fu,{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,G.jsx)(gu,{title:e(`canvas.background`),id:`canvas-bg`,children:(0,G.jsx)(q,{label:e(`props.paint`),children:(0,G.jsx)($m,{value:n.canvas.background??null,allowNone:!0,onChange:(e,n)=>t.edit([{op:`set`,path:`canvas.background`,value:e}],n?{}:{coalesce:`canvas-bg`})})})}),(0,G.jsxs)(gu,{title:e(`canvas.image`),id:`canvas-image`,children:[(0,G.jsx)(q,{label:e(`canvas.transform`),children:(0,G.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,G.jsx)(K,{label:e(`canvas.rotateLeft`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`rotateCanvas`,angle:-90}])&&m(),children:(0,G.jsx)(cn,{size:13})}),(0,G.jsx)(K,{label:e(`canvas.rotateRight`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`rotateCanvas`,angle:90}])&&m(),children:(0,G.jsx)(un,{size:13})}),(0,G.jsx)(K,{label:e(`canvas.flipH`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`flipCanvas`,axis:`horizontal`}]),children:(0,G.jsx)(be,{size:13})}),(0,G.jsx)(K,{label:e(`canvas.flipV`),className:`h-6 w-6`,onClick:()=>t.edit([{op:`flipCanvas`,axis:`vertical`}]),children:(0,G.jsx)(ve,{size:13})})]})}),(0,G.jsxs)(q,{label:e(`canvas.resizeImage`),children:[(0,G.jsx)(Jd,{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,G.jsx)(Jd,{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,G.jsx)(K,{label:e(d?`props.unlockRatio`:`props.lockRatio`),active:d,onClick:()=>f(e=>!e),className:`h-6 w-6`,children:d?(0,G.jsx)(jt,{size:12}):(0,G.jsx)(kt,{size:12})})]}),(0,G.jsx)(`div`,{className:`flex justify-end px-3 pb-1`,children:(0,G.jsx)(fu,{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,G.jsxs)(gu,{title:e(`canvas.document`),id:`canvas-doc`,children:[(0,G.jsx)(q,{label:e(`canvas.docTitle`),children:(0,G.jsx)(pu,{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,G.jsx)(q,{label:e(`canvas.description`),align:`start`,children:(0,G.jsx)(pu,{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 Kh(){let{engine:e}=J(),[t,n]=(0,S.useState)(!1);return(0,S.useEffect)(()=>{let t=!0;return Promise.all(Zr.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 qh({value:e,onChange:t}){let{t:n}=U(),r=Kh(),i=oi(e),a=[...new Set(Zr.map(e=>e.style))];return(0,G.jsx)(Pd,{width:260,align:`start`,anchorClass:`flex min-w-0 flex-1`,trigger:(t,a)=>(0,G.jsx)(Fd,{onClick:t,open:a,ariaLabel:n(`props.font`),children:(0,G.jsx)(`span`,{className:`truncate`,style:{fontFamily:i&&r?`"${i.family}"`:void 0},children:i?.family??e})}),children:i=>(0,G.jsx)(`div`,{className:`py-1`,children:a.map(a=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`px-3 pb-0.5 pt-2 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:n(`fontStyles.${a}`)}),Zr.filter(e=>e.style===a).map(n=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>(t(n.id),i()),className:W(`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,G.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,G.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-faint`,children:n.weights.length})]},n.id))]},a))})})}function Jh({layer:e}){let{t}=U(),n=J(),r=Y(e=>e.region),i=Y(e=>e.showMask),a=Y(e=>e.maskTarget),o=Y(e=>e.busy),[s,c]=(0,S.useState)(ei[`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=Rr(e)?f?.width??100:n.store.doc.canvas.width,m=Rr(e)?f?.height??100:n.store.doc.canvas.height,h=l?zr(l)?`image`:Br(l)?`shape`:`gradient`:null,g=$r.filter(e=>e.task===`background-removal`);return(0,G.jsxs)(gu,{title:t(`mask.title`),id:`mask`,actions:l?(0,G.jsxs)(`div`,{className:`flex`,children:[(0,G.jsx)(K,{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,G.jsx)(Ue,{size:12}):(0,G.jsx)(Ge,{size:12})}),(0,G.jsx)(K,{label:t(`mask.delete`),onClick:()=>u(null),className:`h-6 w-6 hover:text-danger`,children:(0,G.jsx)(nr,{size:12})})]}):void 0,children:[l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{label:t(`mask.kind`),children:(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[t(`mask.kinds.${h}`),zr(l)&&(0,G.jsx)(`span`,{className:`ml-1 font-mono text-2xs text-fg-faint`,children:l.src.split(`/`).pop()})]})}),(0,G.jsxs)(q,{label:t(`mask.enabled`),children:[(0,G.jsx)(hu,{checked:l.enabled!==!1,onChange:e=>d({enabled:e?void 0:!1}),ariaLabel:t(`mask.enabled`)}),(0,G.jsx)(`span`,{className:`ml-3 text-xs text-fg-muted`,children:t(`mask.invert`)}),(0,G.jsx)(hu,{checked:!!l.invert,onChange:e=>d({invert:e||void 0}),ariaLabel:t(`mask.invert`)})]}),(0,G.jsx)(q,{label:t(`mask.feather`),children:(0,G.jsx)(Yd,{value:l.feather??0,min:0,max:200,onChange:(e,t)=>d({feather:e||void 0},t),ariaLabel:t(`mask.feather`)})}),(0,G.jsx)(q,{label:t(`mask.density`),children:(0,G.jsx)(Yd,{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,G.jsx)(`div`,{className:`px-3 py-1`,children:(0,G.jsxs)(fu,{size:`xs`,variant:a===e.id?`primary`:`subtle`,onClick:()=>(n.ui.set({maskTarget:e.id}),Eh(n,`brush`)),children:[(0,G.jsx)(ge,{size:12}),` `,t(`mask.paint`)]})}),Br(l)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{label:t(`mask.shape`),children:(0,G.jsx)(mu,{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,G.jsxs)(q,{label:t(`props.position`),children:[(0,G.jsx)(Jd,{label:`X`,value:Math.round(l.x),integer:!0,onChange:(e,t)=>d({x:e},t)}),(0,G.jsx)(Jd,{label:`Y`,value:Math.round(l.y),integer:!0,onChange:(e,t)=>d({y:e},t)})]}),(0,G.jsxs)(q,{label:t(`props.size`),children:[(0,G.jsx)(Jd,{label:`W`,value:Math.round(l.width),min:1,integer:!0,onChange:(e,t)=>d({width:e},t)}),(0,G.jsx)(Jd,{label:`H`,value:Math.round(l.height),min:1,integer:!0,onChange:(e,t)=>d({height:e},t)})]})]}),Vr(l)&&(0,G.jsx)(q,{label:t(`paint.angle`),children:(0,G.jsx)(Yd,{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,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1 px-3 pb-1`,children:[(0,G.jsxs)(fu,{size:`xs`,variant:`subtle`,disabled:!r,title:r?void 0:t(`mask.needMarquee`),onClick:()=>r&&void bp(n,e,r).then(e=>(u(e),n.ui.set({region:null}))),children:[(0,G.jsx)(In,{size:12}),` `,t(`mask.fromSelection`)]}),(0,G.jsxs)(fu,{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,G.jsx)(je,{size:12}),` `,t(`mask.ellipse`)]}),(0,G.jsxs)(fu,{size:`xs`,variant:`subtle`,onClick:()=>u({shape:`rect`,x:p*.1,y:m*.1,width:p*.8,height:m*.8,radius:0}),children:[(0,G.jsx)(Bn,{size:12}),` `,t(`mask.rect`)]}),(0,G.jsxs)(fu,{size:`xs`,variant:`subtle`,onClick:()=>u({gradient:{type:`linear`,angle:90,stops:[`#ffffff`,`#000000`]}}),children:[(0,G.jsx)(Kn,{size:12}),` `,t(`mask.fade`)]})]}),e.type===`image`&&(0,G.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,G.jsx)(`div`,{className:`flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wide text-agent/90`,children:t(`mask.ai`)}),(0,G.jsx)(`div`,{className:`flex gap-1`,children:(0,G.jsx)(mu,{value:s,options:g.map(e=>({value:e.id,label:`${e.id} · ${e.sizeMb} MB`})),onChange:c,ariaLabel:t(`mask.model`)})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1`,children:[(0,G.jsxs)(fu,{size:`xs`,variant:`subtle`,disabled:!!o,onClick:()=>void zm(n,e.id,s),children:[(0,G.jsx)(mr,{size:12}),` `,t(`ai.removeBg`)]}),(0,G.jsxs)(fu,{size:`xs`,variant:`subtle`,disabled:!!o,onClick:()=>void Bm(n,e.id,s),children:[(0,G.jsx)(fn,{size:12}),` `,t(`ai.selectSubject`)]})]}),(0,G.jsx)(`p`,{className:`text-2xs leading-snug text-fg-faint`,children:t(`mask.aiNote`)})]})]})}function Yh(e){let t=J();return(n,r=!0)=>{e&&t.edit([{op:`updateLayer`,id:e.id,set:n}],r?{}:{coalesce:`props:${e.id}:${Object.keys(n).join(`,`)}`})}}function Xh(){let{t:e}=U(),t=wu(),n=Su().selection;return t?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2`,children:(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:id(t)}),(0,G.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})}`]})]})}),Rr(t)&&(0,G.jsx)($h,{layer:t}),t.type===`image`&&(0,G.jsx)(eg,{layer:t}),t.type===`text`&&(0,G.jsx)(ng,{layer:t}),t.type===`shape`&&(0,G.jsx)(rg,{layer:t}),t.type===`fill`&&(0,G.jsx)(gu,{title:e(`props.fill`),id:`fill`,children:(0,G.jsx)(Zh,{layer:t})}),t.type===`adjustment`&&(0,G.jsx)(Qh,{}),t.type===`group`&&(0,G.jsx)(gu,{title:e(`props.group`),id:`group`,children:(0,G.jsx)(`div`,{className:`px-3 text-xs text-fg-muted`,children:e(`props.groupInfo`,{n:t.children?.length??0})})}),(0,G.jsx)(Jh,{layer:t})]}):(0,G.jsx)(Gh,{})}function Zh({layer:e}){let{t}=U(),n=Yh(e);return(0,G.jsx)(q,{label:t(`props.paint`),children:(0,G.jsx)($m,{value:e.fill,onChange:(e,t)=>n({fill:e??`#ffffff`},t)})})}function Qh(){let{t:e}=U(),{ui:t}=J();return(0,G.jsx)(gu,{title:e(`props.adjustment`),id:`adjustment`,children:(0,G.jsxs)(`div`,{className:`space-y-2 px-3 text-xs text-fg-muted`,children:[(0,G.jsx)(`p`,{children:e(`props.adjustmentInfo`)}),(0,G.jsxs)(fu,{size:`xs`,onClick:()=>t.set({rightTab:`filters`}),children:[(0,G.jsx)(En,{size:12}),` `,e(`props.editFilters`)]})]})})}function $h({layer:e}){let{t}=U(),n=J(),r=Yh(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,G.jsxs)(gu,{title:t(`props.transform`),id:`transform`,children:[(0,G.jsxs)(q,{label:t(`props.position`),children:[(0,G.jsx)(Jd,{label:`X`,value:Math.round((e.x??0)*10)/10,onChange:(e,t)=>r({x:e},t),step:1}),(0,G.jsx)(Jd,{label:`Y`,value:Math.round((e.y??0)*10)/10,onChange:(e,t)=>r({y:e},t),step:1})]}),(0,G.jsxs)(q,{label:t(`props.size`),children:[(0,G.jsx)(Jd,{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,G.jsx)(Jd,{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,G.jsx)(K,{label:t(a?`props.unlockRatio`:`props.lockRatio`),active:a,onClick:()=>o(e=>!e),className:`h-6 w-6`,children:a?(0,G.jsx)(jt,{size:12}):(0,G.jsx)(kt,{size:12})})]}),(0,G.jsxs)(q,{label:t(`props.rotation`),children:[(0,G.jsx)(Jd,{label:`°`,value:e.rotation??0,min:-360,max:360,step:1,onChange:(e,t)=>r({rotation:e||null},t)}),(0,G.jsx)(K,{label:t(`props.flipH`),active:!!e.flipX,onClick:()=>r({flipX:!e.flipX||null}),className:`h-6 w-6`,children:(0,G.jsx)(be,{size:13})}),(0,G.jsx)(K,{label:t(`props.flipV`),active:!!e.flipY,onClick:()=>r({flipY:!e.flipY||null}),className:`h-6 w-6`,children:(0,G.jsx)(ve,{size:13})})]}),(0,G.jsx)(q,{label:t(`props.align`),children:(0,G.jsx)(`div`,{className:`flex gap-0.5`,children:[[`left`,er],[`hcenter`,Xn],[`right`,Qn],[`top`,ce],[`vcenter`,ue],[`bottom`,ne]].map(([a,o])=>(0,G.jsx)(K,{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,G.jsx)(o,{size:13})},a))})})]})}function eg({layer:e}){let{t}=U(),n=J(),r=Yh(e),i=(0,S.useRef)(null),a=n.naturalSize(e.src);return(0,G.jsxs)(gu,{title:t(`props.image`),id:`image`,children:[(0,G.jsxs)(q,{label:t(`props.source`),children:[(0,G.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,G.jsx)(K,{label:t(`props.replace`),onClick:()=>i.current?.click(),className:`h-6 w-6`,children:(0,G.jsx)(pt,{size:13})}),(0,G.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 Wh([t]);if(!ia(i.bytes))return;let a=await n.backend.addImage(i.name,i.bytes);r({src:a,crop:null})}})]}),a&&(0,G.jsxs)(q,{label:t(`props.natural`),children:[(0,G.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[a.width,` × `,a.height]}),(0,G.jsxs)(fu,{size:`xs`,variant:`ghost`,className:`ml-auto`,onClick:()=>r({width:a.width,height:a.height,crop:null}),title:t(`props.naturalHint`),children:[(0,G.jsx)(Vt,{size:11}),` `,t(`props.reset`)]})]}),(0,G.jsx)(q,{label:t(`props.fit`),children:(0,G.jsx)(mu,{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,G.jsxs)(q,{label:t(`props.focus`),children:[(0,G.jsx)(Jd,{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,G.jsx)(Jd,{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,G.jsx)(q,{label:t(`props.crop`),overridden:!!e.crop,onReset:()=>r({crop:null}),children:e.crop?(0,G.jsx)(`div`,{className:`grid flex-1 grid-cols-2 gap-1`,children:[`x`,`y`,`width`,`height`].map(t=>(0,G.jsx)(Jd,{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,G.jsx)(fu,{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 tg=[`none`,`uppercase`,`lowercase`];function ng({layer:e}){let{t}=U(),n=Yh(e),r=oi(e.font??`inter`)?.weights??[100,200,300,400,500,600,700,800,900],i=e.background;return(0,G.jsxs)(gu,{title:t(`props.text`),id:`text`,children:[(0,G.jsx)(`div`,{className:`px-3 pb-1.5`,children:(0,G.jsx)(pu,{value:e.text,onCommit:e=>n({text:e}),multiline:!0,ariaLabel:t(`props.textContent`)})}),(0,G.jsx)(q,{label:t(`props.font`),children:(0,G.jsx)(qh,{value:e.font??`inter`,onChange:t=>{let r=oi(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,G.jsxs)(q,{label:t(`props.weight`),children:[(0,G.jsx)(mu,{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,G.jsx)(K,{label:t(`props.italic`),active:!!e.italic,onClick:()=>n({italic:!e.italic||null}),className:`h-6 w-6 font-serif italic`,children:`I`})]}),(0,G.jsx)(q,{label:t(`props.size`),children:(0,G.jsx)(Yd,{value:e.size??64,min:6,max:600,integer:!0,onChange:(e,t)=>n({size:e},t),ariaLabel:t(`props.size`)})}),(0,G.jsx)(q,{label:t(`props.color`),children:(0,G.jsx)($m,{value:e.color??`#ffffff`,onChange:(e,t)=>n({color:e??`#ffffff`},t)})}),(0,G.jsxs)(q,{label:t(`props.alignText`),children:[(0,G.jsx)(`div`,{className:`flex rounded-md bg-ink-2 p-0.5`,children:[`left`,`center`,`right`].map(r=>{let i=r===`left`?er:r===`center`?Xn:Qn;return(0,G.jsx)(`button`,{type:`button`,"aria-label":t(`props.aligns.${r}`),title:t(`props.aligns.${r}`),onClick:()=>n({align:r===`left`?null:r}),className:W(`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,G.jsx)(i,{size:12})},r)})}),(0,G.jsx)(mu,{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,G.jsx)(q,{label:t(`props.lineHeight`),children:(0,G.jsx)(Yd,{value:e.lineHeight??1.2,min:.6,max:3,step:.05,onChange:(e,t)=>n({lineHeight:e},t),ariaLabel:t(`props.lineHeight`)})}),(0,G.jsx)(q,{label:t(`props.letterSpacing`),children:(0,G.jsx)(Yd,{value:e.letterSpacing??0,min:-20,max:100,step:.5,onChange:(e,t)=>n({letterSpacing:e||null},t),ariaLabel:t(`props.letterSpacing`)})}),(0,G.jsx)(q,{label:t(`props.case`),children:(0,G.jsx)(mu,{value:e.transform??`none`,options:tg.map(e=>({value:e,label:t(`props.cases.${e}`)})),onChange:e=>n({transform:e===`none`?null:e}),ariaLabel:t(`props.case`)})}),(0,G.jsx)(q,{label:t(`props.wrap`),overridden:!!e.width,onReset:()=>n({width:null}),children:(0,G.jsx)(Jd,{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,G.jsxs)(q,{label:t(`props.textBox`),children:[(0,G.jsx)(hu,{checked:!!i,onChange:e=>n({background:e?{color:`#000000b3`,padding:[16,28],radius:12}:null}),ariaLabel:t(`props.textBox`)}),i&&(0,G.jsx)(Wd,{value:i.color,compact:!0,onChange:(e,t)=>n({background:{...i,color:e}},t)}),i&&(0,G.jsx)(Jd,{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,G.jsx)(Jd,{label:`R`,value:i.radius??0,min:0,integer:!0,onChange:(e,t)=>n({background:{...i,radius:e}},t),ariaLabel:t(`props.radius`)})]})]})}function rg({layer:e}){let{t}=U(),n=Yh(e),r=e.stroke;return(0,G.jsxs)(gu,{title:t(`props.shape`),id:`shape`,children:[(0,G.jsx)(q,{label:t(`props.shapeKind`),children:(0,G.jsx)(mu,{value:e.shape,options:ni.map(e=>({value:e,label:t(`shapes.${e}`)})),onChange:e=>n({shape:e}),ariaLabel:t(`props.shapeKind`)})}),(0,G.jsx)(q,{label:t(`props.fill`),children:(0,G.jsx)($m,{value:e.fill??null,allowNone:!0,onChange:(e,t)=>n({fill:e},t)})}),(0,G.jsxs)(q,{label:t(`props.stroke`),children:[(0,G.jsx)(hu,{checked:!!r,onChange:e=>n({stroke:e?{color:`#ffffff`,width:4}:null}),ariaLabel:t(`props.stroke`)}),r&&(0,G.jsx)(Wd,{value:r.color,compact:!0,onChange:(e,t)=>n({stroke:{...r,color:e}},t)}),r&&(0,G.jsx)(Jd,{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,G.jsx)(hu,{checked:!!r.dash?.length,onChange:e=>n({stroke:{...r,dash:e?[12,8]:null}}),ariaLabel:t(`props.dashed`)})]}),e.shape===`rect`&&(0,G.jsx)(q,{label:t(`props.radius`),children:(0,G.jsx)(Yd,{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,G.jsx)(q,{label:e.shape===`star`?t(`props.points`):t(`props.sides`),children:(0,G.jsx)(Yd,{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,G.jsx)(q,{label:t(`props.innerRadius`),children:(0,G.jsx)(Yd,{value:e.innerRadius??.5,min:.05,max:.95,step:.01,onChange:(e,t)=>n({innerRadius:e},t),ariaLabel:t(`props.innerRadius`)})})]})}function ig({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,Nd.createPortal)((0,G.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,G.jsx)(`div`,{className:`my-1 h-px bg-line`},t):(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,onClick:()=>{r(),e.run()},className:W(`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,G.jsx)(`span`,{className:`flex w-4 justify-center text-fg-muted`,children:e.icon}),(0,G.jsx)(`span`,{className:`flex-1`,children:e.label}),e.keys&&(0,G.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e.keys})]},t))}),document.body)}var ag=typeof navigator<`u`&&/Mac/.test(navigator.platform)?`⌘`:`Ctrl+`;function og(){let{t:e,lang:t,setLang:n}=U(),{store:r,ui:i,backend:a,closeProject:o,runCheck:s}=J(),c=Su(),l=Y(e=>e.assistant),u=Y(e=>e.check),d=Y(e=>e.checkRunning),f=Y(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,G.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-line bg-ink-1 px-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,style:{width:300},children:[(0,G.jsx)(K,{label:e(`top.projects`),onClick:o,children:(0,G.jsx)(Te,{size:15})}),(0,G.jsx)(lg,{className:f?`agent-pulse rounded-[6px]`:void 0},f),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight`,children:c.doc?.title||a.projectTitle()}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 truncate text-2xs text-fg-faint`,title:a.location??``,children:[a.mode===`cli`?(0,G.jsx)(st,{size:10}):(0,G.jsx)(Ne,{size:10}),(0,G.jsx)(`span`,{className:`truncate`,children:a.mode===`cli`?cg(a.location):e(`top.inBrowser`)}),c.doc&&(0,G.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`· `,c.doc.canvas.width,`×`,c.doc.canvas.height]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,G.jsx)(K,{label:e(`top.undo`),shortcut:`${ag}Z`,disabled:!c.canUndo,onClick:()=>r.undo(),children:(0,G.jsx)(cr,{size:15})}),(0,G.jsx)(K,{label:e(`top.redo`),shortcut:`${ag}⇧Z`,disabled:!c.canRedo,onClick:()=>r.redo(),children:(0,G.jsx)(on,{size:15})}),(0,G.jsx)(ug,{})]}),(0,G.jsx)(`div`,{className:`mx-auto flex items-center`,children:(0,G.jsx)(sg,{})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(fu,{variant:`ghost`,onClick:()=>void s(),title:e(`top.checkHint`),children:[d?(0,G.jsx)(Nt,{size:14,className:`animate-spin`}):(0,G.jsx)(wn,{size:14}),e(`top.check`),m>0&&(0,G.jsx)(`span`,{className:W(`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,G.jsxs)(fu,{variant:`primary`,onClick:()=>i.set({dialog:`export`}),children:[(0,G.jsx)(fr,{size:14}),e(`top.export`)]}),(0,G.jsx)(`div`,{className:`mx-1 h-5 w-px bg-line`}),(0,G.jsx)(K,{label:e(`top.assistant`),active:l,onClick:()=>i.set({assistant:!l}),children:(0,G.jsx)(me,{size:16})}),(0,G.jsx)(K,{label:e(`top.shortcuts`),shortcut:`?`,onClick:()=>i.set({dialog:`shortcuts`}),children:(0,G.jsx)(xt,{size:15})}),(0,G.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 sg(){let{t:e}=U(),t=J(),n=Y(e=>e.view.zoom);return(0,G.jsxs)(`div`,{className:`flex items-center rounded-md bg-ink-2/70 p-0.5`,children:[(0,G.jsx)(K,{label:e(`zoom.out`),shortcut:`${ag}-`,onClick:()=>jh(t,.8),className:`h-6 w-6`,children:(0,G.jsx)(Ut,{size:13})}),(0,G.jsx)(Pd,{width:180,align:`start`,trigger:(t,r)=>(0,G.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,G.jsx)(we,{size:11,className:`text-fg-faint`})]}),children:n=>(0,G.jsx)(`div`,{className:`py-1 text-sm`,children:[{label:e(`zoom.fit`),keys:`${ag}0`,run:()=>t.ui.set(e=>({fitRequest:e.fitRequest+1}))},{label:`50%`,run:()=>Mh(t,.5)},{label:e(`zoom.actual`),keys:`${ag}1`,run:()=>Mh(t,1)},{label:`200%`,run:()=>Mh(t,2)},{label:`400%`,run:()=>Mh(t,4)}].map(e=>(0,G.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,G.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e.keys})]},e.label))})}),(0,G.jsx)(K,{label:e(`zoom.in`),shortcut:`${ag}+`,onClick:()=>jh(t,1.25),className:`h-6 w-6`,children:(0,G.jsx)(rn,{size:13})}),(0,G.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-line`}),(0,G.jsx)(K,{label:e(`zoom.fit`),shortcut:`${ag}0`,onClick:()=>t.ui.set(e=>({fitRequest:e.fitRequest+1})),className:`h-6 w-6`,children:(0,G.jsx)(Vt,{size:12})})]})}function cg(e){if(!e)return``;let t=e.split(`/`).filter(Boolean);return t.length>2?`…/${t.slice(-2).join(`/`)}`:e}function lg({size:e=22,className:t}){let n=(0,S.useId)().replace(/:/g,``);return(0,G.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 32 32`,"aria-hidden":!0,className:W(`shrink-0`,t),children:[(0,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`${n}bg`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#2a2a30`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#0c0c0f`})]}),(0,G.jsxs)(`linearGradient`,{id:`${n}dot`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#7aa5ff`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#3d6bff`})]})]}),(0,G.jsx)(`rect`,{width:`32`,height:`32`,rx:`7.5`,fill:`url(#${n}bg)`}),(0,G.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`31`,height:`31`,rx:`7`,fill:`none`,stroke:`#ffffff`,strokeOpacity:`0.12`}),(0,G.jsx)(`rect`,{x:`7`,y:`9`,width:`18`,height:`14`,rx:`2.5`,fill:`none`,stroke:`#fff`,strokeWidth:`2.2`}),(0,G.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,G.jsx)(`circle`,{cx:`20.5`,cy:`13.5`,r:`2`,fill:`url(#${n}dot)`})]})}function ug(){let{t:e}=U(),t=Su().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,G.jsxs)(`div`,{className:W(`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,G.jsx)(ke,{size:11}):(0,G.jsx)(`span`,{className:W(`h-1.5 w-1.5 rounded-full`,t.state===`saved`?`bg-agent/70`:`animate-pulse bg-key`)}),n]})}async function dg(e,t){try{let n=e.store.doc,r=M(n.layers,t);if(!r)return;let i=r.layer;if(i.type!==`text`&&i.type!==`shape`&&i.type!==`fill`)return;let a=Rr(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`,...Rr(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 fp(e).render(p,{scale:d}),h=fg(m);if(!h)return void X({tone:`info`,title:H(`layers.rasterizeEmpty`)});let g=vc(h.w,h.h);z(g).drawImage(m,-h.x,-h.y);let _=await Dl(g,`image/png`),v=await gp(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??id(i),src:v,x:y.x,y:y.y,width:y.width,height:y.height,...Rr(i)&&i.rotation?{rotation:i.rotation}:{},...Rr(i)&&i.flipX?{flipX:!0}:{},...Rr(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){X({tone:`error`,title:H(`layers.rasterizeFailed`),detail:e.message})}}function fg(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 pg(e){let{enabled:t,...n}=e;return t===!1?n:{...n,enabled:!1}}var mg={image:ht,text:or,shape:Sn,fill:Zt,adjustment:En,group:$e};function hg(){let{t:e}=U(),t=J(),{store:n,ui:r}=t,i=Su(),a=i.doc,o=Y(e=>e.collapsed),s=Y(e=>e.flash),c=Y(e=>e.maskTarget),l=pd(a.layers,new Set(o)),u=i.selection,d=u.length?M(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=ld(a,n.primary),s=a.canvas.width,c=a.canvas.height,l;i===`text`?(Eh(t,`text`),r.set({textEdit:{id:null,x:s*.1,y:c*.1}})):(l=i===`shape`?sd(a,`rect`,{x:s*.3,y:c*.3,width:s*.4,height:c*.4},r.get().fg):i===`solid`?{id:nd(a,`fill`),type:`fill`,name:e(`layers.solidName`),fill:r.get().fg}:i===`gradient`?{id:nd(a,`gradient`),type:`fill`,name:e(`layers.gradientName`),fill:{type:`linear`,angle:90,stops:[[0,`#00000000`],[1,`#000000cc`]]}}:i===`adjustment`?{id:nd(a,`adjustment`),type:`adjustment`,name:e(`layers.adjustmentName`),filters:[{type:`brightnessContrast`,brightness:0,contrast:0}]}:{id:nd(a,`group`),type:`group`,name:ad(`group`),children:[]},t.edit([{op:`addLayer`,layer:l,...o}],{select:l.id})&&r.set({rightTab:i===`adjustment`?`filters`:`properties`}))},te=n=>{let r=M(a.layers,n)?.layer;return r?[{label:e(`layers.duplicate`),icon:(0,G.jsx)(Fe,{size:13}),keys:`${ag}D`,run:()=>Dh(t)},{label:e(`layers.group`),icon:(0,G.jsx)(Ze,{size:13}),keys:`${ag}G`,run:()=>kh(t)},{label:e(`layers.ungroup`),icon:(0,G.jsx)(ur,{size:13}),keys:`⇧${ag}G`,disabled:r.type!==`group`,run:()=>Ah(t)},`-`,{label:r.clip?e(`layers.unclip`):e(`layers.clip`),icon:(0,G.jsx)(ne,{size:13}),run:()=>b(n,{clip:!r.clip||null})},{label:r.locked?e(`layers.unlock`):e(`layers.lock`),icon:r.locked?(0,G.jsx)(Ft,{size:13}):(0,G.jsx)(Lt,{size:13}),run:()=>b(n,{locked:!r.locked||null})},{label:r.visible===!1?e(`layers.show`):e(`layers.hide`),icon:r.visible===!1?(0,G.jsx)(Ge,{size:13}):(0,G.jsx)(Ue,{size:13}),run:()=>b(n,{visible:r.visible===!1&&null})},`-`,{label:e(`layers.maskInvert`),icon:(0,G.jsx)(In,{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,G.jsx)(Bn,{size:13}),disabled:!r.mask,run:()=>t.edit([{op:`setMask`,id:n,mask:null}])},{label:e(`layers.rasterize`),icon:(0,G.jsx)(Dt,{size:13}),disabled:r.type!==`text`&&r.type!==`shape`&&r.type!==`fill`,run:()=>void dg(t,n)},`-`,{label:e(`layers.delete`),icon:(0,G.jsx)(nr,{size:13}),keys:`⌫`,danger:!0,run:()=>Oh(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=ud(a,v.current,n.id,n.where);v.current=[],r&&t.edit(r)};return(0,G.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":e(`layers.title`),children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b border-line pl-3 pr-1.5`,children:[(0,G.jsx)(`span`,{className:`panel-title`,children:e(`layers.title`)}),(0,G.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:l.length}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center`,children:[(0,G.jsx)(gg,{onAdd:ee,onImage:()=>y.current?.click()}),(0,G.jsx)(K,{label:e(`layers.group`),shortcut:`${ag}G`,disabled:!u.length,onClick:()=>kh(t),className:`h-6 w-6`,children:(0,G.jsx)(Ze,{size:13})}),(0,G.jsx)(K,{label:e(`layers.delete`),shortcut:`⌫`,disabled:!u.length,onClick:()=>Oh(t),className:`h-6 w-6 hover:text-danger`,children:(0,G.jsx)(nr,{size:13})})]}),(0,G.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 Wh(n))}})]}),d&&(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 border-b border-line px-2.5 py-1.5`,children:[(0,G.jsx)(mu,{value:d.blend??`normal`,options:Lr.map(e=>({value:e,label:$d(e)})),onChange:e=>b(d.id,{blend:e===`normal`?null:e}),className:`w-[112px] flex-none`,ariaLabel:e(`layers.blend`)}),(0,G.jsx)(`span`,{className:`text-2xs text-fg-faint`,children:e(`layers.opacity`)}),(0,G.jsx)(Yd,{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,G.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)?Ye:mg[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,G.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`?(Eh(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:W(`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,G.jsx)(`div`,{className:W(`pointer-events-none absolute inset-x-1 h-0.5 rounded bg-accent`,g.where===`above`?`-top-px`:`-bottom-px`)}),(0,G.jsx)(`button`,{type:`button`,"aria-label":e(y?`layers.show`:`layers.hide`),onClick:e=>(e.stopPropagation(),b(i.id,{visible:y?null:!1})),className:W(`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,G.jsx)(Ue,{size:13}):(0,G.jsx)(Ge,{size:13})}),i.type===`group`?(0,G.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,G.jsx)(De,{size:12}):(0,G.jsx)(we,{size:12})}):(0,G.jsx)(`span`,{className:`w-0`}),i.clip&&(0,G.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,G.jsx)(`div`,{className:`flex h-[28px] w-[36px] shrink-0 items-center justify-center rounded-[3px] bg-ink-2 text-fg-muted`,children:(0,G.jsx)(d,{size:15})}):(0,G.jsx)(mh,{layer:i,w:36,h:28}),i.mask&&(0,G.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:pg(i.mask)}]):(n.select(i.id),r.set(e=>({maskTarget:e.maskTarget===i.id?null:i.id})))},className:W(`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,G.jsx)(hh,{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,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center text-sm font-bold text-danger`,children:`×`})]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f===i.id?(0,G.jsx)(`input`,{autoFocus:!0,defaultValue:i.name??id(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,G.jsx)(`div`,{onDoubleClick:e=>(e.stopPropagation(),p(i.id)),className:W(`truncate text-sm`,y?`text-fg-faint`:`text-fg`),title:`${id(i)} · ${i.id}`,children:id(i)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 truncate text-2xs text-fg-faint`,children:[(0,G.jsx)(d,{size:9}),e(`layerTypes.${i.type}`),(i.blend??`normal`)!==`normal`&&(0,G.jsxs)(`span`,{children:[`· `,$d(i.blend)]}),(i.opacity??1)<1&&(0,G.jsxs)(`span`,{children:[`· `,Math.round((i.opacity??1)*100),`%`]}),!!i.filters?.length&&i.type!==`adjustment`&&(0,G.jsxs)(`span`,{className:`text-accent/80`,children:[`· fx `,i.filters.length]})]})]}),(0,G.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:W(`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,G.jsx)(Lt,{size:12}):(0,G.jsx)(Ft,{size:12})})]},`${i.id}${S?s.at:``}`)}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n.select(null),className:W(`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,G.jsx)(`span`,{className:`checker-sm h-4 w-5 rounded-[2px] ring-1 ring-white/10`,style:{background:void 0}}),e(`layers.canvas`),(0,G.jsxs)(`span`,{className:`ml-auto tabular-nums text-fg-faint`,children:[a.canvas.width,`×`,a.canvas.height]})]})]}),m&&(0,G.jsx)(ig,{x:m.x,y:m.y,items:te(m.id),onClose:()=>h(null)})]})}function gg({onAdd:e,onImage:t}){let{t:n}=U(),[r,i]=(0,S.useState)(null);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{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,G.jsx)(rn,{size:14})}),r&&(0,G.jsx)(ig,{x:r.x,y:r.y,onClose:()=>i(null),items:[{label:n(`layers.addImage`),icon:(0,G.jsx)(ht,{size:13}),run:t},{label:n(`layers.addText`),icon:(0,G.jsx)(or,{size:13}),keys:`T`,run:()=>e(`text`)},{label:n(`layers.addShape`),icon:(0,G.jsx)(Sn,{size:13}),keys:`U`,run:()=>e(`shape`)},`-`,{label:n(`layers.addSolid`),icon:(0,G.jsx)(Zt,{size:13}),run:()=>e(`solid`)},{label:n(`layers.addGradient`),icon:(0,G.jsx)(Zt,{size:13}),run:()=>e(`gradient`)},{label:n(`layers.addAdjustment`),icon:(0,G.jsx)(En,{size:13}),run:()=>e(`adjustment`)},{label:n(`layers.addGroup`),icon:(0,G.jsx)($e,{size:13}),run:()=>e(`group`)}]})]})}var _g=`agentphoto.studio.layersHeight`,vg=[`properties`,`filters`,`looks`,`effects`];function yg(){let{t:e}=U(),{ui:t}=J(),n=Y(e=>e.rightTab),r=wu(),i=(0,S.useRef)(null),[a,o]=(0,S.useState)(()=>{try{return Number(localStorage.getItem(_g))||300}catch{return 300}});(0,S.useEffect)(()=>{try{localStorage.setItem(_g,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,G.jsxs)(`aside`,{ref:i,className:`flex w-[312px] shrink-0 flex-col border-l border-line bg-ink-1`,children:[(0,G.jsx)(`div`,{className:`flex min-h-[120px] flex-col`,style:{height:a},children:(0,G.jsx)(hg,{})}),(0,G.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,G.jsx)(`div`,{className:`flex h-9 shrink-0 items-end gap-0.5 border-b border-line px-1.5`,children:vg.map(r=>(0,G.jsxs)(`button`,{type:`button`,"data-tab":r,onClick:()=>t.set({rightTab:r}),className:W(`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,G.jsx)(`span`,{className:`rounded bg-ink-3 px-1 text-2xs text-fg-muted`,children:s[r]}),n===r&&(0,G.jsx)(`span`,{className:`absolute inset-x-2 -bottom-px h-0.5 rounded bg-accent`})]},r))}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[n===`properties`&&(0,G.jsx)(Xh,{}),n===`filters`&&(0,G.jsx)(lh,{}),n===`looks`&&(0,G.jsx)(bh,{}),n===`effects`&&(0,G.jsx)(ah,{})]})]})}var bg=typeof navigator<`u`&&/Mac/.test(navigator.platform)?`⌘`:`Ctrl`,xg=[[[bg,`Z`],`keys.undo`],[[bg,`⇧`,`Z`],`keys.redo`],[[bg,`S`],`keys.save`],[[bg,`D`],`keys.duplicate`],[[bg,`G`],`keys.group`],[[bg,`⇧`,`G`],`keys.ungroup`],[[bg,`A`],`keys.selectAll`],[[`⌫`],`keys.delete`],[[`←`,`→`,`↑`,`↓`],`keys.nudge`],[[`⇧`,`↑`],`keys.nudge10`],[[`Esc`],`keys.deselect`],[[`Tab`],`keys.panels`],[[bg,`V`],`keys.paste`],[[`?`],`keys.help`]],Sg=[[[bg,`0`],`keys.fit`],[[bg,`1`],`keys.actual`],[[bg,`+`],`keys.zoomIn`],[[bg,`−`],`keys.zoomOut`],[[bg,`wheel`],`keys.zoomWheel`],[[`Space`,`drag`],`keys.pan`],[[`⇧`,`drag`],`keys.keepRatio`],[[bg,`drag`],`keys.noSnap`],[[`Enter`],`keys.commitCrop`],[[`⇧`,`drag`],`keys.dragFast`],[[`Alt`,`drag`],`keys.dragFine`]];function Cg(){let{t:e}=U(),{ui:t}=J();return(0,G.jsx)(hd,{title:e(`keys.title`),width:760,onClose:()=>t.set({dialog:null}),children:(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-x-6 px-4 py-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`pb-1 pt-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:e(`keys.tools`)}),(0,G.jsx)(wg,{rows:Fm.map(e=>[[e.shortcut],e.label])})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`pb-1 pt-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:e(`keys.general`)}),(0,G.jsx)(wg,{rows:xg})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`pb-1 pt-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-faint`,children:e(`keys.view`)}),(0,G.jsx)(wg,{rows:Sg})]})]})})}function wg({rows:e}){let{t}=U();return(0,G.jsx)(`div`,{className:`divide-y divide-line`,children:e.map(([e,n],r)=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5 text-sm`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:t(n)}),(0,G.jsx)(`span`,{className:`flex shrink-0 gap-1`,children:e.map(e=>(0,G.jsx)(_u,{children:e===`wheel`?t(`keys.wheelKey`):e===`drag`?t(`keys.dragKey`):e},e))})]},r))})}function Tg(){let{t:e}=U(),t=J(),n=Su(),r=Y(e=>e.view.zoom),i=Y(e=>e.cursor),a=Y(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,G.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,G.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`status.canvas`),children:[(0,G.jsx)(zt,{size:10}),` `,s.canvas.width,` × `,s.canvas.height,` px`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`status.zoom`),children:[(0,G.jsx)(br,{size:10}),` `,Math.round(r*1e3)/10,`%`]}),(0,G.jsxs)(`span`,{className:`flex w-[92px] items-center gap-1`,title:e(`status.cursor`),children:[(0,G.jsx)(Le,{size:10}),` `,i?`${i.x}, ${i.y}`:`—`]}),l&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`status.selection`),children:[(0,G.jsx)(mn,{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,G.jsx)(`span`,{className:`text-danger`,children:e(`status.errors`,{n:u.length})}),(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,title:e(`status.render`),children:[(0,G.jsx)(tt,{size:10}),` `,a,` ms`]})]})}function Eg({label:e,keys:t,children:n,side:r=`right`}){return(0,G.jsxs)(`div`,{className:`group/tip relative`,children:[n,(0,G.jsxs)(`div`,{className:W(`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,G.jsx)(`kbd`,{className:`ml-2 rounded border border-line bg-ink-2 px-1 font-sans text-2xs text-fg-muted`,children:t})]})]})}function Dg(){let{t:e}=U(),t=J(),n=Y(e=>e.tool),r=Y(e=>e.shapeKind),i=Y(e=>e.fg);Su();let[a,o]=(0,S.useState)(!1);return(0,G.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,G.jsx)(`div`,{className:W(`flex flex-col items-center gap-0.5`,s>0&&`mt-1.5 border-t border-line pt-1.5`),children:Fm.filter(e=>e.group===i).map(i=>{let s=i.id===`shape`?Rf[r]:i.icon,c=n===i.id;return(0,G.jsxs)(Eg,{label:e(i.label),keys:i.shortcut,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-label":e(i.label),"aria-pressed":c,"data-tool":i.id,onClick:()=>i.id===`shape`&&c?o(e=>!e):Eh(t,i.id),onContextMenu:e=>{i.id===`shape`&&(e.preventDefault(),Eh(t,`shape`),o(!0))},className:W(`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,G.jsx)(s,{size:16,strokeWidth:1.75}),i.id===`shape`&&(0,G.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,G.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,G.jsx)(Bf,{value:r,onChange:e=>{t.ui.set({shapeKind:e}),Eh(t,`shape`),o(!1)}})})]},i.id)})},i)),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-col items-center gap-0.5 border-t border-line pt-1.5`,children:[(0,G.jsx)(An,{size:11,className:`mb-0.5 text-agent/80`,"aria-hidden":!0}),Vm.map(n=>{let r=n.enabled(t);return(0,G.jsx)(Eg,{label:`${e(n.label)} — ${e(n.hint)}`,children:(0,G.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,G.jsx)(n.icon,{size:16,strokeWidth:1.75})})},n.id)})]}),(0,G.jsx)(`div`,{className:`mt-auto`,children:(0,G.jsx)(Pd,{width:232,align:`start`,trigger:(t,n)=>(0,G.jsx)(Eg,{label:e(`tools.foreground`),children:(0,G.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,G.jsx)(`span`,{className:`absolute inset-0`,style:{background:i}})})}),children:()=>(0,G.jsx)(Vd,{value:i,onChange:e=>t.ui.set({fg:e})})})})]})}var Og=e=>e.length?e[e.length-1]:null;function kg(e,t=``){return!e||typeof e!=`object`||Array.isArray(e)?[t]:Object.keys(e).sort().flatMap(n=>kg(e[n],t?`${t}.${n}`:n))}function Ag(e,t){return e.op===`set`&&t.op===`set`?e.path===t.path:e.op===`updateLayer`&&t.op===`updateLayer`?e.id===t.id&&kg(e.set).join()===kg(t.set).join()&&!JSON.stringify(t.set).includes(`null`):e.op===`updateFilter`&&t.op===`updateFilter`&&e.id===t.id&&e.index===t.index&&kg(e.set).join()===kg(t.set).join()}var jg=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:Ki,...t}}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getSnapshot=()=>this.snap;get doc(){return this.snap.doc}get primary(){return Og(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=>M(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=I(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&&Ag(t,e)?this.pendingOps[this.pendingOps.length-1]=e:this.pendingOps.push(e)}replace(e){let t=this.snap.doc;t&&uo(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(co(e))}external(e){let t=this.snap.doc;if(t&&uo(t,e))return!1;let n=e;if(this.pendingOps.length&&!this.needsFull)try{n=I(e,this.pendingOps,this.opts.sizes?.()??{})}catch{this.pendingOps=[]}else this.pendingOps=[],this.needsFull=!1;return t&&uo(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),co(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 Mg(){let e=lu(`panel`),t=lu(`dialog`),n=lu(`tool`);return{tool:Fm.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:lu(`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 Ng({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 jg(t=>e.call(t.kind===`patch`?`doc_patch`:`doc_apply`,t.kind===`patch`?{ops:t.ops}:{doc:t.doc}),{sizes:()=>Object.fromEntries(i)}),s=yu(Mg()),c=new Sl(e.engineOptions()),l=new ll(c.loader),u=new kf(l),d=e=>{N(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=Io(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&&X({tone:`agent`,title:H(`external.title`),detail:i.summary,action:{label:H(`external.undo`),run:()=>o.undo()}},6e3)},m=e=>new Promise(t=>{if(_d(e))return t(!0);s.set({consent:{model:e,resolve:e=>(s.set({consent:null}),t(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&&X({tone:`error`,title:H(`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};X({tone:n.errors?`error`:`success`,title:n.errors||n.warnings?H(`check.found`,{errors:n.errors,warnings:n.warnings}):H(`check.ok`),detail:t.issues?.find(e=>e.severity!==`info`)?.message},5e3)}catch(e){X({tone:`error`,title:H(`check.failed`),detail:e.message})}finally{s.set({checkRunning:!1})}},reloadDoc:p,async runTool(t,n,r={}){if(r.model&&ci(r.model)&&!await m(r.model))return null;await o.flush(),r.busy&&s.set({busy:{label:H(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 X({tone:`error`,title:H(`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=ia(r.bytes);if(!t)X({tone:`error`,title:H(`import.notImage`,{name:r.name})});else try{let i=await e.addImage(r.name,r.bytes),a=o.doc,s=cd(a,i,t,r.name,n),c=o.primary;o.edit([{op:`addLayer`,layer:s,...c?{above:c}:{}}],{select:s.id}),X({tone:`success`,title:H(`import.done`,{name:r.name})},2400)}catch(e){X({tone:`error`,title:H(`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 Dl(await c.render(n,{scale:t}),`image/jpeg`,80);await e.saveThumb(ed(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=lu(`select`);s&&o.select(s.split(`,`)),r(g(a))}catch(e){n||a(e.message)}})();let _=lu(`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?H(`ai.downloading`,{model:e.model,pct:Math.round(e.progress*100)}):H(`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,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,G.jsx)(`div`,{className:`text-base font-medium`,children:H(`app.loadFailed`)}),(0,G.jsx)(`div`,{className:`max-w-md text-sm text-fg-muted`,children:i}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`mt-2 text-sm text-accent hover:underline`,children:H(`app.back`)})]}):n?(0,G.jsx)(xu.Provider,{value:n,children:(0,G.jsx)(Pg,{})}):(0,G.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-fg-muted`,children:[(0,G.jsx)(Nt,{size:16,className:`animate-spin`}),` `,H(`app.loadingDoc`)]})}function Pg(){let e=Y(e=>e.assistant),t=Y(e=>e.dialog),n=Y(e=>e.panelsHidden);return Nh(),(0,G.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,G.jsx)(og,{}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!n&&(0,G.jsx)(Dg,{}),(0,G.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[!n&&(0,G.jsx)(Hm,{}),(0,G.jsx)(zh,{}),(0,G.jsx)(Tg,{}),(0,G.jsx)(Q,{}),(0,G.jsx)(bd,{})]}),!n&&(0,G.jsx)(yg,{}),e&&(0,G.jsx)(Wu,{})]}),t===`export`&&(0,G.jsx)(uf,{}),t===`shortcuts`&&(0,G.jsx)(Cg,{}),(0,G.jsx)(yd,{})]})}function Fg({w:e,h:t,max:n=46}){let r=n/Math.max(e,t);return(0,G.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 Ig({backend:e,onOpened:t}){let{t:n,lang:r,setLang:i}=U(),[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 Wh([t]);await x(`photo`,{title:t.name.replace(/\.[^.]+$/,``)||`Photo`,image:r})};return(0,G.jsxs)(`div`,{className:`h-full overflow-auto`,children:[(0,G.jsxs)(`div`,{className:`mx-auto max-w-[1240px] px-8 py-8`,children:[(0,G.jsxs)(`header`,{className:`mb-8 flex items-center justify-between gap-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(lg,{size:36}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-[22px] font-semibold leading-tight tracking-tight`,children:`AgentPhoto Studio`}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-xl text-sm text-fg-muted`,children:n(`start.tagline`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.hasProject()&&(0,G.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,G.jsx)(oe,{size:14})]}),(0,G.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,G.jsx)(st,{size:12}):(0,G.jsx)(Ne,{size:12}),e.mode===`cli`?n(`start.cliMode`,{v:e.version??``}):n(`start.localMode`)]}),(0,G.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,G.jsxs)(`div`,{className:`mb-6 flex gap-3 rounded-lg border border-line bg-ink-1 p-4`,children:[(0,G.jsx)(Jn,{size:16,className:`mt-0.5 shrink-0 text-accent`}),(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:n(`start.noFolderTitle`)}),(0,G.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n(`start.noFolderBody`)}),(0,G.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,G.jsx)(`div`,{className:`mb-6 rounded-md bg-danger/10 px-3 py-2 text-sm text-danger`,children:p}),(0,G.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_272px] gap-10`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-9`,children:[(0,G.jsxs)(`section`,{onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:e=>{e.preventDefault(),g(!1),ee([...e.dataTransfer.files])},className:W(`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,G.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,G.jsx)(Nt,{size:26,className:`animate-spin`}):(0,G.jsx)(dt,{size:28,strokeWidth:1.6})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:n(`start.openTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-lg text-sm text-fg-muted`,children:n(`start.openBody`)})]}),(0,G.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,G.jsx)(fr,{size:15}),` `,n(`start.choose`)]}),(0,G.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,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`start.samples`)}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:n(`start.samplesHint`)})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-3 xl:grid-cols-6`,children:s.map(t=>(0,G.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,G.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,G.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,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,G.jsx)(Nt,{size:18,className:`animate-spin`})})]}),(0,G.jsx)(`div`,{className:`mt-1.5 truncate text-xs font-medium capitalize`,children:t.id}),(0,G.jsxs)(`div`,{className:`truncate text-2xs text-fg-faint`,children:[t.width,`×`,t.height,` · `,t.license]})]},t.id))})]}),a.length>0&&(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`start.templates`)}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:n(`start.templatesHint`)})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-3 xl:grid-cols-4`,children:a.map(t=>(0,G.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,G.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,G.jsx)(Rg,{src:e.templatePreview(t.id)}),d===t.id&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,G.jsx)(Nt,{size:18,className:`animate-spin`})}),(0,G.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,G.jsx)(`div`,{className:`mt-1.5 truncate text-xs font-medium`,children:t.title}),(0,G.jsx)(`div`,{className:`truncate text-2xs capitalize text-fg-faint`,children:t.category})]},t.id))})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`start.blank`)}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:n(`start.blankHint`)})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-4 gap-2 xl:grid-cols-5`,children:Qr.map(e=>(0,G.jsxs)(`button`,{type:`button`,disabled:!b||!!d,onClick:()=>void x(`blank:${e.id}`,{title:af(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,G.jsx)(`div`,{className:`flex h-12 w-12 shrink-0 items-center justify-center`,children:d===`blank:${e.id}`?(0,G.jsx)(Nt,{size:16,className:`animate-spin`}):(0,G.jsx)(Fg,{w:e.width,h:e.height})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-xs font-medium`,children:af(e.id)}),(0,G.jsxs)(`div`,{className:`text-2xs tabular-nums text-fg-faint`,children:[e.width,` × `,e.height]})]})]},e.id))})]})]}),(0,G.jsxs)(`aside`,{children:[(0,G.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:n(`start.recent`)}),l.length?(0,G.jsx)(`ul`,{className:`space-y-1`,children:l.map(r=>(0,G.jsxs)(`li`,{className:`group flex items-center gap-1`,children:[(0,G.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:W(`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,G.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,G.jsx)(`img`,{src:r.thumb,alt:``,className:`h-full w-full object-cover`}):(0,G.jsx)(Ye,{size:14,className:`text-fg-faint`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm`,children:r.title}),(0,G.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,G.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,G.jsx)(nr,{size:12})})]},r.id))}):(0,G.jsx)(`p`,{className:`text-xs text-fg-faint`,children:n(`start.noRecent`)}),(0,G.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,G.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:n(`start.agentTitle`)}),n(`start.agentBody`),(0,G.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,G.jsxs)(`div`,{className:`mt-3 rounded-lg border border-line p-3.5 text-xs leading-relaxed text-fg-muted`,children:[(0,G.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:n(`start.privacyTitle`)}),n(`start.privacyBody`)]})]})]})]}),_&&(0,G.jsx)(Lg,{tp:_,preview:e.templatePreview(_.id),onClose:()=>v(null),onUse:async e=>{v(null),await x(_.id,{title:_.title,template:_.id,...e?{image:e}:{}})}})]})}function Lg({tp:e,preview:t,onClose:n,onUse:r}){let{t:i}=U(),a=(0,S.useRef)(null);return(0,G.jsx)(hd,{title:e.title,width:620,onClose:n,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`mr-auto text-2xs text-fg-faint`,children:e.slot?i(`start.slotHint`):``}),e.slot&&(0,G.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,G.jsx)(dt,{size:14}),` `,i(`start.withPhoto`)]}),(0,G.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,G.jsx)(oe,{size:14})]}),(0,G.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 Wh([t]))[0])}})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,G.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-ink-2`,children:(0,G.jsx)(Rg,{src:t})}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.description}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 text-2xs text-fg-faint`,children:[(0,G.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,G.jsx)(`span`,{className:`rounded bg-ink-2 px-1.5 py-0.5`,children:e},e))]})]})})}function Rg({src:e}){let[t,n]=(0,S.useState)(!e);return t||!e?(0,G.jsx)(`div`,{className:`h-full w-full bg-gradient-to-br from-ink-3 to-ink-1`}):(0,G.jsx)(`img`,{src:e,alt:``,className:`h-full w-full object-cover`,onError:()=>n(!0)})}function zg(){let{t:e}=U(),[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 Jl(),r;if(t)r=new Xl(t);else{let e=new Wl;await e.init();let t=lu(`project`);t&&await e.open(t).catch(()=>void 0),r=e}e||(n(r),i(r.hasProject()&&lu(`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,G.jsx)(Ng,{backend:t,onClose:c},a):(0,G.jsx)(Ig,{backend:t,onOpened:s}):(0,G.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-fg-muted`,children:[(0,G.jsx)(Nt,{size:16,className:`animate-spin`}),` `,e(`app.loading`)]})}document.documentElement.lang=ou(),(0,xr.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(S.StrictMode,{children:(0,G.jsx)(zg,{})}));export{r as n,n as t};