@snagset/server 0.1.16 → 0.1.18

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 (193) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +9 -10
  3. package/dist/app.js +51 -47
  4. package/dist/app.js.map +1 -1
  5. package/dist/bin.js +31 -32
  6. package/dist/bin.js.map +1 -1
  7. package/dist/boot.js +21 -21
  8. package/dist/boot.js.map +1 -1
  9. package/dist/config.generated.js +5 -8
  10. package/dist/config.generated.js.map +1 -1
  11. package/dist/config.js +14 -14
  12. package/dist/config.js.map +1 -1
  13. package/dist/crypto.js +1 -1
  14. package/dist/crypto.js.map +1 -1
  15. package/dist/db/connect.js +1 -1
  16. package/dist/db/migrate.js +11 -11
  17. package/dist/db/rls.js +3 -3
  18. package/dist/db/rls.js.map +1 -1
  19. package/dist/domain.js +73 -5
  20. package/dist/domain.js.map +1 -1
  21. package/dist/explain.js +1 -1
  22. package/dist/instance/address.js +3 -3
  23. package/dist/instance/address.js.map +1 -1
  24. package/dist/instance/settings.js +1 -1
  25. package/dist/integrations/github.js +3 -3
  26. package/dist/integrations/github.js.map +1 -1
  27. package/dist/integrations/inbound.js +3 -3
  28. package/dist/integrations/inbound.js.map +1 -1
  29. package/dist/integrations/linear.js +1 -1
  30. package/dist/integrations/linear.js.map +1 -1
  31. package/dist/integrations/outbox.js +4 -4
  32. package/dist/integrations/outbox.js.map +1 -1
  33. package/dist/integrations/slack.js +2 -2
  34. package/dist/integrations/slack.js.map +1 -1
  35. package/dist/jobs/index.js +3 -3
  36. package/dist/jobs/reaper.js +11 -11
  37. package/dist/jobs/reaper.js.map +1 -1
  38. package/dist/jobs/set.js +3 -3
  39. package/dist/jobs/set.js.map +1 -1
  40. package/dist/jobs/soon.js +3 -3
  41. package/dist/keys.js +3 -3
  42. package/dist/keys.js.map +1 -1
  43. package/dist/listen.js +3 -3
  44. package/dist/listen.js.map +1 -1
  45. package/dist/mail/assigned.js +10 -10
  46. package/dist/mail/assigned.js.map +1 -1
  47. package/dist/mail/digest.js +3 -3
  48. package/dist/mail/digest.js.map +1 -1
  49. package/dist/mail/index.js +2 -2
  50. package/dist/mail/links.js +5 -5
  51. package/dist/mail/mailer.js +2 -2
  52. package/dist/mail/notify.js +22 -22
  53. package/dist/mail/notify.js.map +1 -1
  54. package/dist/mail/resend.js +1 -1
  55. package/dist/mail/resolve.js +1 -1
  56. package/dist/mail/resolve.js.map +1 -1
  57. package/dist/mail/smtp.js +1 -1
  58. package/dist/mail/unsubscribe.js +1 -1
  59. package/dist/net/publicFetch.js +1 -1
  60. package/dist/orgs.js +5 -5
  61. package/dist/orgs.js.map +1 -1
  62. package/dist/plan.js +1 -1
  63. package/dist/projects.js +4 -4
  64. package/dist/projects.js.map +1 -1
  65. package/dist/routes/account.js +1 -1
  66. package/dist/routes/account.js.map +1 -1
  67. package/dist/routes/activity.js +1 -1
  68. package/dist/routes/anchorReports.js +9 -9
  69. package/dist/routes/anchorReports.js.map +1 -1
  70. package/dist/routes/assignees.js +4 -4
  71. package/dist/routes/assignees.js.map +1 -1
  72. package/dist/routes/attachments.js +6 -6
  73. package/dist/routes/attachments.js.map +1 -1
  74. package/dist/routes/auth.js +4 -4
  75. package/dist/routes/bodyLimit.js +5 -5
  76. package/dist/routes/bodyLimit.js.map +1 -1
  77. package/dist/routes/commentEdit.js +5 -5
  78. package/dist/routes/commentEdit.js.map +1 -1
  79. package/dist/routes/comments.js +24 -24
  80. package/dist/routes/comments.js.map +1 -1
  81. package/dist/routes/cors.js +33 -15
  82. package/dist/routes/cors.js.map +1 -1
  83. package/dist/routes/instance.js +3 -3
  84. package/dist/routes/instance.js.map +1 -1
  85. package/dist/routes/integrations.js +14 -11
  86. package/dist/routes/integrations.js.map +1 -1
  87. package/dist/routes/invites.js +7 -7
  88. package/dist/routes/invites.js.map +1 -1
  89. package/dist/routes/mcpAuth.js +13 -13
  90. package/dist/routes/mcpAuth.js.map +1 -1
  91. package/dist/routes/mcpToken.js +4 -4
  92. package/dist/routes/mcpToken.js.map +1 -1
  93. package/dist/routes/mcpTokens.js +27 -14
  94. package/dist/routes/mcpTokens.js.map +1 -1
  95. package/dist/routes/members.js +9 -5
  96. package/dist/routes/members.js.map +1 -1
  97. package/dist/routes/owner.js +13 -13
  98. package/dist/routes/owner.js.map +1 -1
  99. package/dist/routes/reviewLinks.js +4 -4
  100. package/dist/routes/reviewLinks.js.map +1 -1
  101. package/dist/routes/rounds.js +3 -3
  102. package/dist/routes/rounds.js.map +1 -1
  103. package/dist/routes/sessions.js +186 -71
  104. package/dist/routes/sessions.js.map +1 -1
  105. package/dist/routes/sites.js +9 -9
  106. package/dist/routes/sites.js.map +1 -1
  107. package/dist/routes/threads.js +95 -95
  108. package/dist/routes/threads.js.map +1 -1
  109. package/dist/routes/widget.js +5 -5
  110. package/dist/routes/widget.js.map +1 -1
  111. package/dist/serverless.js +4 -4
  112. package/dist/serverless.js.map +1 -1
  113. package/dist/session.js +8 -8
  114. package/dist/session.js.map +1 -1
  115. package/dist/storage/bucket.js +4 -4
  116. package/dist/storage/bucket.js.map +1 -1
  117. package/dist/storage/settings.js +4 -4
  118. package/dist/storage/settings.js.map +1 -1
  119. package/dist/studioReviewers.js +4 -4
  120. package/dist/vendor/adapters/outbound/fence.js +2 -2
  121. package/dist/vendor/adapters/outbound/sanitise.js +14 -14
  122. package/dist/vendor/mcp/bin.js +4 -4
  123. package/dist/vendor/mcp/client.js +3 -3
  124. package/dist/vendor/mcp/server.js +3 -3
  125. package/dist/vendor/mcp/source.js +13 -13
  126. package/dist/vendor/mcp/view.js +15 -15
  127. package/dist/vendor/types/brief.js +2 -2
  128. package/dist/vendor/types/index.js +1 -1
  129. package/dist/vendor/types/names.js +20 -18
  130. package/dist/vendor/widget/object.js +3 -3
  131. package/dist/vendor/widget/predicates.js +38 -39
  132. package/package.json +1 -5
  133. package/static/dashboard/assets/{CompositeItem-DP7FLsIz.js → CompositeItem-D1SCvKo_.js} +1 -1
  134. package/static/dashboard/assets/{ConfirmDialog-B-mNmk6U.js → ConfirmDialog-DdUOWt96.js} +1 -1
  135. package/static/dashboard/assets/{CopyButton-bsaLPvqU.js → CopyButton-DX7vax3M.js} +1 -1
  136. package/static/dashboard/assets/{FieldItemContext-Cz9anwiZ.js → FieldItemContext-CMpCHNX8.js} +1 -1
  137. package/static/dashboard/assets/{InstallTag-DDMHFPFi.js → InstallTag-DkYPsEI0.js} +1 -1
  138. package/static/dashboard/assets/{SaveState-rgq6rRHH.js → SaveState-D0Hl8cny.js} +1 -1
  139. package/static/dashboard/assets/{_app-C5aeP_jI.js → _app-CcUZ9WT2.js} +1 -1
  140. package/static/dashboard/assets/{_app-B--Q2p1D.js → _app-CnG-wKIX.js} +1 -1
  141. package/static/dashboard/assets/{activity-CmpMwfWp.js → activity-DnvsedIb.js} +1 -1
  142. package/static/dashboard/assets/{arrow-left-BN3lUG8m.js → arrow-left-4jbTF1bA.js} +1 -1
  143. package/static/dashboard/assets/{avatar-4OkpxHzf.js → avatar-BKSc7tnv.js} +1 -1
  144. package/static/dashboard/assets/{badge-BGUQxxes.js → badge-aWVtPffe.js} +1 -1
  145. package/static/dashboard/assets/{card-BX32udhB.js → card-Bz0VdsxC.js} +1 -1
  146. package/static/dashboard/assets/{check-DjkY9Lhe.js → check-Ti2IOlgc.js} +1 -1
  147. package/static/dashboard/assets/{chevron-right-w26JMtvi.js → chevron-right-g-zbIopD.js} +1 -1
  148. package/static/dashboard/assets/{copy-BtOpNPn3.js → copy-BwBuD0FO.js} +1 -1
  149. package/static/dashboard/assets/{dialog-Ca351GqX.js → dialog-DdpHZobU.js} +1 -1
  150. package/static/dashboard/assets/{dropdown-menu-BdM8D0_i.js → dropdown-menu-CB2L3nig.js} +1 -1
  151. package/static/dashboard/assets/{image-off-DBc5pfc8.js → image-off-w_ej9pIJ.js} +1 -1
  152. package/static/dashboard/assets/{index-Bvmz5Xph.js → index-DtF8YHqn.js} +3 -3
  153. package/static/dashboard/assets/{invite-b1vVPR4n.js → invite-Dy3iQjzf.js} +1 -1
  154. package/static/dashboard/assets/{label-CeHVAC98.js → label-Dj8L94iS.js} +1 -1
  155. package/static/dashboard/assets/{layout-grid-BJUJgcuD.js → layout-grid-DuweH0Vl.js} +1 -1
  156. package/static/dashboard/assets/me-7-r9OeMR.js +1 -0
  157. package/static/dashboard/assets/{parts-BU_5BLga.js → parts-CA4cbfy3.js} +1 -1
  158. package/static/dashboard/assets/{plus-DW3meZh8.js → plus-CEWgXDLj.js} +1 -1
  159. package/static/dashboard/assets/s._site-D69M50OI.js +1 -0
  160. package/static/dashboard/assets/{s._site.comments-CyIqVrl3.js → s._site.comments-DNJ2SE5c.js} +1 -1
  161. package/static/dashboard/assets/{s._site.reviewers-muaVzTtT.js → s._site.reviewers-B07NzSWj.js} +1 -1
  162. package/static/dashboard/assets/{s._site.settings-Bow6VdXW.js → s._site.settings-B577G5iG.js} +1 -1
  163. package/static/dashboard/assets/{setup-B5fdtoM-.js → setup-DcjjtB3g.js} +1 -1
  164. package/static/dashboard/assets/{sign-in-D9Bhw619.js → sign-in-gfvOs6Jw.js} +1 -1
  165. package/static/dashboard/assets/{sign-up-CK-LWLzn.js → sign-up-CFJt7ibH.js} +1 -1
  166. package/static/dashboard/assets/{sites-CLB6RzU6.js → sites-DbB5cjz5.js} +1 -1
  167. package/static/dashboard/assets/studio-BO-MHFqc.js +1 -0
  168. package/static/dashboard/assets/{studio-CVFUbJQb.js → studio-D9GxJaSF.js} +1 -1
  169. package/static/dashboard/assets/{studio.index-CUtMjh5_.js → studio.index-DktAxIPT.js} +1 -1
  170. package/static/dashboard/assets/studio.integrations-CbLyqPLX.js +1 -0
  171. package/static/dashboard/assets/{studio.members-BcVrAT7r.js → studio.members-DFtIL3JS.js} +1 -1
  172. package/static/dashboard/assets/{sun-BzCBfLxA.js → sun-Bg7U-6Y0.js} +1 -1
  173. package/static/dashboard/assets/{switch-Djsy8JA6.js → switch-CTN6hIca.js} +1 -1
  174. package/static/dashboard/assets/{table-Cnpowiv-.js → table-zQ3pj50_.js} +1 -1
  175. package/static/dashboard/assets/{useAriaLabelledBy-D35XdVIh.js → useAriaLabelledBy-BsNncGbx.js} +1 -1
  176. package/static/dashboard/assets/{useBaseQuery-DztMyAqa.js → useBaseQuery-DSqwWD_O.js} +1 -1
  177. package/static/dashboard/assets/useQuery-OgrKuHbc.js +1 -0
  178. package/static/dashboard/assets/useRender-DOFVvGfR.js +1 -0
  179. package/static/dashboard/assets/{useValueChanged-DY7n1sYE.js → useValueChanged-B9k7l-mp.js} +1 -1
  180. package/static/dashboard/assets/{users-CR2o4PsB.js → users-CRiOyD0f.js} +1 -1
  181. package/static/dashboard/assets/{welcome-DJ_8xHTE.js → welcome-DT2DB4jN.js} +1 -1
  182. package/static/dashboard/assets/{widget-signin-BOulktuR.js → widget-signin-CC9owVvs.js} +1 -1
  183. package/static/dashboard/assets/{you-DJGezimL.js → you-CtcXklc_.js} +1 -1
  184. package/static/dashboard/assets/{zod-4RphBaVj.js → zod-CLxHj89d.js} +1 -1
  185. package/static/dashboard/index.html +1 -1
  186. package/static/widget/snag.capture.js +1 -1
  187. package/static/widget/snag.runtime.js +2 -2
  188. package/static/dashboard/assets/me-zNn3-t75.js +0 -1
  189. package/static/dashboard/assets/s._site-DP3hLlXp.js +0 -1
  190. package/static/dashboard/assets/studio-CuiXjnSt.js +0 -1
  191. package/static/dashboard/assets/studio.integrations-CiQ83f7Q.js +0 -1
  192. package/static/dashboard/assets/useQuery-DCEPkmeo.js +0 -1
  193. package/static/dashboard/assets/useRender-C2NyqaXd.js +0 -1
@@ -1 +1 @@
1
- import{j as t,f as l}from"./index-Bvmz5Xph.js";function o({className:a,...e}){return t.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:t.jsx("table",{"data-slot":"table",className:l("w-full caption-bottom text-sm",a),...e})})}function r({className:a,...e}){return t.jsx("thead",{"data-slot":"table-header",className:l("[&_tr]:border-b",a),...e})}function d({className:a,...e}){return t.jsx("tbody",{"data-slot":"table-body",className:l("[&_tr:last-child]:border-0",a),...e})}function n({className:a,...e}){return t.jsx("tr",{"data-slot":"table-row",className:l("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...e})}function b({className:a,...e}){return t.jsx("th",{"data-slot":"table-head",className:l("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",a),...e})}function c({className:a,...e}){return t.jsx("td",{"data-slot":"table-cell",className:l("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...e})}export{o as T,r as a,n as b,b as c,d,c as e};
1
+ import{j as t,f as l}from"./index-DtF8YHqn.js";function o({className:a,...e}){return t.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:t.jsx("table",{"data-slot":"table",className:l("w-full caption-bottom text-sm",a),...e})})}function r({className:a,...e}){return t.jsx("thead",{"data-slot":"table-header",className:l("[&_tr]:border-b",a),...e})}function d({className:a,...e}){return t.jsx("tbody",{"data-slot":"table-body",className:l("[&_tr:last-child]:border-0",a),...e})}function n({className:a,...e}){return t.jsx("tr",{"data-slot":"table-row",className:l("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...e})}function b({className:a,...e}){return t.jsx("th",{"data-slot":"table-head",className:l("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",a),...e})}function c({className:a,...e}){return t.jsx("td",{"data-slot":"table-cell",className:l("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...e})}export{o as T,r as a,n as b,b as c,d,c as e};
@@ -1 +1 @@
1
- import{r as u,d as l}from"./index-Bvmz5Xph.js";import{u as c}from"./label-CeHVAC98.js";function y(e,n,t,r=!0,i){const[a,d]=u.useState(),f=c(i?`${i}-label`:void 0),o=e??n??a;return l(()=>{const s=e||n||!r?void 0:L(t.current,f);a!==s&&d(s)}),o}function L(e,n){const t=b(e);if(t)return!t.id&&n&&(t.id=n),t.id||void 0}function b(e){if(!e)return;const n=e.parentElement;if(n&&n.tagName==="LABEL")return n;const t=e.id;if(t){const i=e.nextElementSibling;if(i&&i.htmlFor===t)return i}const r=e.labels;return r&&r[0]}export{y as u};
1
+ import{r as u,d as l}from"./index-DtF8YHqn.js";import{u as c}from"./label-Dj8L94iS.js";function y(e,n,t,r=!0,i){const[a,d]=u.useState(),f=c(i?`${i}-label`:void 0),o=e??n??a;return l(()=>{const s=e||n||!r?void 0:L(t.current,f);a!==s&&d(s)}),o}function L(e,n){const t=b(e);if(t)return!t.id&&n&&(t.id=n),t.id||void 0}function b(e){if(!e)return;const n=e.parentElement;if(n&&n.tagName==="LABEL")return n;const t=e.id;if(t){const i=e.nextElementSibling;if(i&&i.htmlFor===t)return i}const r=e.labels;return r&&r[0]}export{y as u};
@@ -1 +1 @@
1
- import{aV as N,aW as h,aX as O,aY as U,aZ as k,a_ as B,a$ as A,b0 as y,b1 as V,b2 as H,b3 as M,b4 as _,r as p,b5 as x,t as W}from"./index-Bvmz5Xph.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#n;#c;#i;#p;#u;#l;#a;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return E(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return E(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof h(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!O(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return O(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(a=>{r=a,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),a(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const a=this.createResult(s,e);return r?.(a),a}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&h(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#m();const t=h(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#a=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||V.isFocused())&&this.#h()},this.#r))}#S(){this.#R(),this.#y(this.#v())}#m(){this.#a!==void 0&&(y.clearTimeout(this.#a),this.#a=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#n,a=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let n={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(n={...n,...H(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=n;o=n.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(f=r.data,I=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",o=M(r?.data,f,e),d=!0)}if(e.select&&o!==void 0&&!I)if(r&&o===c?.data&&e.select===this.#p)o=this.#u;else try{this.#p=e.select,o=e.select(o),o=M(r?.data,o,e),this.#u=o,this.#i=null}catch(f){this.#i=f}else o===void 0&&(this.#i=null);this.#i&&(R=this.#i,o=this.#u,v=Date.now(),b="error",d=!1);const S=n.fetchStatus==="fetching",m=b==="pending",g=b==="error",T=m&&S,w=o!==void 0;return{status:b,fetchStatus:n.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:n.dataUpdateCount>u.dataUpdateCount||n.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!w,isPaused:n.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&w,isStale:C(t,e),refetch:this.refetch,isEnabled:h(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#c=this.options,this.#n.data!==void 0&&(this.#l=this.#t),O(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const a=new Set(c??this.#d);return this.options.throwOnError&&a.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&a.has(l)})})();_.batch(()=>{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#O(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}};function j(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function Q(t,e){return j(t,e)||t.state.data!==void 0&&E(t,e,e.refetchOnMount)}function E(t,e,s){if(h(e.enabled,t)!==!1&&h(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||h(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return h(e.enabled,t)!==!1&&t.isStaleByTime(h(e.staleTime,t))}const F=p.createContext(!1),z=()=>p.useContext(F);F.Provider;function K(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const X=p.createContext(K()),Y=()=>p.useContext(X),Z=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?x(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||i)&&(e.isReset()||(t.retryOnMount=!1))},$=t=>{p.useEffect(()=>{t.clearReset()},[t])},G=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||x(s,[t.error,i])),it=(t,e)=>e.state.data===void 0,J=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},q=(t,e)=>t?.suspense&&e.isPending,tt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function rt(t,e,s){const i=z(),r=Y(),c=W(),a=c.defaultQueryOptions(t),u=c.getQueryCache().get(a.queryHash),l=t.subscribed!==!1;a._optimisticResults=i?"isRestoring":l?"optimistic":void 0,J(a),Z(a,r,u),$(r);const[n]=p.useState(()=>new e(c,a)),d=n.getOptimisticResult(a),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?n.subscribe(_.batchCalls(R)):U;return n.updateResult(),v},[n,o]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),p.useEffect(()=>{n.setOptions(a)},[a,n]),q(a,d))throw tt(a,n,r);if(G({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw d.error;return a.notifyOnChangeProps?d:n.trackResult(d)}export{st as Q,it as d,rt as u};
1
+ import{aV as N,aW as h,aX as O,aY as U,aZ as k,a_ as B,a$ as A,b0 as y,b1 as V,b2 as H,b3 as M,b4 as _,r as p,b5 as x,t as W}from"./index-DtF8YHqn.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#n;#c;#i;#p;#u;#l;#a;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return E(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return E(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof h(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!O(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return O(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(a=>{r=a,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),a(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const a=this.createResult(s,e);return r?.(a),a}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&h(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#m();const t=h(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#a=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||V.isFocused())&&this.#h()},this.#r))}#S(){this.#R(),this.#y(this.#v())}#m(){this.#a!==void 0&&(y.clearTimeout(this.#a),this.#a=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#n,a=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let n={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(n={...n,...H(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=n;o=n.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(f=r.data,I=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",o=M(r?.data,f,e),d=!0)}if(e.select&&o!==void 0&&!I)if(r&&o===c?.data&&e.select===this.#p)o=this.#u;else try{this.#p=e.select,o=e.select(o),o=M(r?.data,o,e),this.#u=o,this.#i=null}catch(f){this.#i=f}else o===void 0&&(this.#i=null);this.#i&&(R=this.#i,o=this.#u,v=Date.now(),b="error",d=!1);const S=n.fetchStatus==="fetching",m=b==="pending",g=b==="error",T=m&&S,w=o!==void 0;return{status:b,fetchStatus:n.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:n.dataUpdateCount>u.dataUpdateCount||n.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!w,isPaused:n.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&w,isStale:C(t,e),refetch:this.refetch,isEnabled:h(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#c=this.options,this.#n.data!==void 0&&(this.#l=this.#t),O(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const a=new Set(c??this.#d);return this.options.throwOnError&&a.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&a.has(l)})})();_.batch(()=>{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#O(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}};function j(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function Q(t,e){return j(t,e)||t.state.data!==void 0&&E(t,e,e.refetchOnMount)}function E(t,e,s){if(h(e.enabled,t)!==!1&&h(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||h(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return h(e.enabled,t)!==!1&&t.isStaleByTime(h(e.staleTime,t))}const F=p.createContext(!1),z=()=>p.useContext(F);F.Provider;function K(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const X=p.createContext(K()),Y=()=>p.useContext(X),Z=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?x(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||i)&&(e.isReset()||(t.retryOnMount=!1))},$=t=>{p.useEffect(()=>{t.clearReset()},[t])},G=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||x(s,[t.error,i])),it=(t,e)=>e.state.data===void 0,J=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},q=(t,e)=>t?.suspense&&e.isPending,tt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function rt(t,e,s){const i=z(),r=Y(),c=W(),a=c.defaultQueryOptions(t),u=c.getQueryCache().get(a.queryHash),l=t.subscribed!==!1;a._optimisticResults=i?"isRestoring":l?"optimistic":void 0,J(a),Z(a,r,u),$(r);const[n]=p.useState(()=>new e(c,a)),d=n.getOptimisticResult(a),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?n.subscribe(_.batchCalls(R)):U;return n.updateResult(),v},[n,o]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),p.useEffect(()=>{n.setOptions(a)},[a,n]),q(a,d))throw tt(a,n,r);if(G({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw d.error;return a.notifyOnChangeProps?d:n.trackResult(d)}export{st as Q,it as d,rt as u};
@@ -0,0 +1 @@
1
+ import{u as r,Q as u}from"./useBaseQuery-DSqwWD_O.js";function a(e,s){return r(e,u)}export{a as u};
@@ -0,0 +1 @@
1
+ import{i as n}from"./index-DtF8YHqn.js";function u(e){return n(e.defaultTagName??"div",e,e)}export{u};
@@ -1 +1 @@
1
- import{r as s,e as c,d as n}from"./index-Bvmz5Xph.js";function u(e,r){const t=s.useRef(e),a=c(r);n(()=>{t.current!==e&&a(t.current),t.current=e},[e,a])}export{u};
1
+ import{r as s,e as c,d as n}from"./index-DtF8YHqn.js";function u(e,r){const t=s.useRef(e),a=c(r);n(()=>{t.current!==e&&a(t.current),t.current=e},[e,a])}export{u};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-Bvmz5Xph.js";/**
1
+ import{c as e}from"./index-DtF8YHqn.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as z,K,o as Q,t as B,r as d,j as e,G as L,f as k,B as n,p as w,y as g,A as S}from"./index-Bvmz5Xph.js";import{C as f}from"./card-BX32udhB.js";import{L as C,I as q}from"./label-CeHVAC98.js";import{I as P}from"./InstallTag-DDMHFPFi.js";import{C as R}from"./check-DjkY9Lhe.js";import{A}from"./arrow-left-BN3lUG8m.js";import"./copy-BtOpNPn3.js";/**
1
+ import{c as z,K,o as Q,t as B,r as d,j as e,G as L,f as k,B as n,p as w,y as g,A as S}from"./index-DtF8YHqn.js";import{C as f}from"./card-Bz0VdsxC.js";import{L as C,I as q}from"./label-Dj8L94iS.js";import{I as P}from"./InstallTag-DkYPsEI0.js";import{C as R}from"./check-Ti2IOlgc.js";import{A}from"./arrow-left-4jbTF1bA.js";import"./copy-BwBuD0FO.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{N as h,r as x,j as e,B as a,G as N,p as y,P as b}from"./index-Bvmz5Xph.js";const S=`${b}session`;function E(){const{project:o,origin:t,env:g}=h.useSearch(),{me:n}=h.useRouteContext(),[l,d]=x.useState(""),[f,u]=x.useState(!1),i=n.projects.find(s=>s.uid===o),m=typeof window<"u"?window.opener:null,r=()=>window.close();if(!o||!t||!m)return e.jsx(c,{title:"Nothing to sign in to",children:e.jsxs("p",{className:"m-0 text-muted-foreground",children:["This window is opened by the comment box on a site you are reviewing. Open it from there — choose"," ",e.jsx("em",{children:"Studio member? Sign in"})," — and it will ask you here."]})});if(!i)return e.jsxs(c,{title:"Not one of this studio's sites",children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["You are signed in to ",n.org.name,", and that site is not one of its sites. If it belongs to another studio you are in, switch to it in the dashboard and try again."]}),e.jsx(a,{variant:"outline",onClick:r,children:"Close"})]});const p=async()=>{d(""),u(!0);try{const s=await y.memberSession(i.uid,t,g);if(s.origin!==t)throw new Error("The address changed while signing in. Try again from the site.");const{origin:j,...w}=s;m.postMessage({type:S,session:w},j),r()}catch(s){d(s instanceof Error?s.message:"Could not reach the server."),u(!1)}};return e.jsxs(c,{title:`Sign in to ${i.name}`,children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["Comment on ",e.jsx("span",{className:"font-medium text-foreground",children:t})," as"," ",e.jsx("span",{className:"font-medium text-foreground",children:n.user.name||n.user.email}),", from ",n.org.name,". Your comments there and your replies here will be one author."]}),l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{size:"lg",className:"flex-1",loading:f,onClick:()=>void p(),children:"Continue"}),e.jsx(a,{size:"lg",variant:"outline",onClick:r,children:"Cancel"})]})]})}function c({title:o,children:t}){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h1",{className:"m-0 text-[22px] font-semibold tracking-tight",children:o}),t]})})}export{E as component};
1
+ import{N as h,r as x,j as e,B as a,G as N,p as y,P as b}from"./index-DtF8YHqn.js";const S=`${b}session`;function E(){const{project:o,origin:t,env:g}=h.useSearch(),{me:n}=h.useRouteContext(),[l,d]=x.useState(""),[f,u]=x.useState(!1),i=n.projects.find(s=>s.uid===o),m=typeof window<"u"?window.opener:null,r=()=>window.close();if(!o||!t||!m)return e.jsx(c,{title:"Nothing to sign in to",children:e.jsxs("p",{className:"m-0 text-muted-foreground",children:["This window is opened by the comment box on a site you are reviewing. Open it from there — choose"," ",e.jsx("em",{children:"Studio member? Sign in"})," — and it will ask you here."]})});if(!i)return e.jsxs(c,{title:"Not one of this studio's sites",children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["You are signed in to ",n.org.name,", and that site is not one of its sites. If it belongs to another studio you are in, switch to it in the dashboard and try again."]}),e.jsx(a,{variant:"outline",onClick:r,children:"Close"})]});const p=async()=>{d(""),u(!0);try{const s=await y.memberSession(i.uid,t,g);if(s.origin!==t)throw new Error("The address changed while signing in. Try again from the site.");const{origin:j,...w}=s;m.postMessage({type:S,session:w},j),r()}catch(s){d(s instanceof Error?s.message:"Could not reach the server."),u(!1)}};return e.jsxs(c,{title:`Sign in to ${i.name}`,children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["Comment on ",e.jsx("span",{className:"font-medium text-foreground",children:t})," as"," ",e.jsx("span",{className:"font-medium text-foreground",children:n.user.name||n.user.email}),", from ",n.org.name,". Your comments there and your replies here will be one author."]}),l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{size:"lg",className:"flex-1",loading:f,onClick:()=>void p(),children:"Continue"}),e.jsx(a,{size:"lg",variant:"outline",onClick:r,children:"Cancel"})]})]})}function c({title:o,children:t}){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h1",{className:"m-0 text-[22px] font-semibold tracking-tight",children:o}),t]})})}export{E as component};
@@ -1 +1 @@
1
- import{r,v as w,j as e,f as b,w as y,B as f,X as N}from"./index-Bvmz5Xph.js";import{L as c,I as m}from"./label-CeHVAC98.js";import{P as S,a as h}from"./parts-BU_5BLga.js";import{S as C}from"./SaveState-rgq6rRHH.js";import{u as P}from"./me-zNn3-t75.js";import{u as A,a as k}from"./studio-CVFUbJQb.js";import{M as F,S as E,a as M}from"./sun-BzCBfLxA.js";import"./card-BX32udhB.js";import"./labels--UUyt9uB.js";import"./useBaseQuery-DztMyAqa.js";function T({items:t}){const[a,n]=r.useState(w);return e.jsx("div",{className:"flex gap-2",role:"radiogroup","aria-label":"Theme",children:t.map(s=>e.jsxs("button",{type:"button",role:"radio","aria-checked":a===s.value,onClick:()=>{y(s.value),n(s.value)},className:b("inline-flex h-7 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[12.5px] font-medium text-ink-soft",a===s.value&&"border-line-strong bg-muted text-foreground"),children:[s.icon,s.label]},s.value))})}function G(){const t=P(),a=A(),[n,s]=r.useState(t.user.name),[u,l]=r.useState(null);r.useEffect(()=>s(t.user.name),[t.user.name]);const d=n.trim()!==t.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(S,{title:"You",sub:"Your own account on this studio",actions:e.jsx(C,{saving:a.isPending,savedAt:u})}),e.jsxs(h,{title:"Profile",description:"How you appear on replies and in the members list.",children:[e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:i=>{i.preventDefault(),d&&a.mutate(n.trim(),{onSuccess:()=>l(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{id:"your-name",value:n,onChange:i=>s(i.target.value)}),d&&e.jsx(f,{type:"submit",variant:"outline",children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"your-email",children:"Email"}),e.jsx(m,{id:"your-email",value:t.user.email,readOnly:!0,className:"bg-muted text-ink-soft"}),e.jsxs("p",{className:"m-0 text-[12px] text-muted-foreground",children:["How you sign in, and how the server finds you. An owner changes it with"," ",e.jsx("code",{className:"font-mono",children:"snagset passwd"}),"."]})]})]}),e.jsx(h,{title:"Password",description:"Changing it keeps this session and ends every other one.",children:e.jsx(D,{})}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(T,{items:[{value:"system",label:"System",icon:e.jsx(F,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(E,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(M,{className:"size-3.5"})}]})})]})}function D(){const t=k(),[a,n]=r.useState(""),[s,u]=r.useState(""),[l,d]=r.useState(""),[i,g]=r.useState(""),[j,x]=r.useState(!1),p=a.length>0&&s.length>=12&&s===l;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async o=>{if(o.preventDefault(),!(!p||t.isPending)){g("");try{await t.mutateAsync({current:a,next:s}),n(""),u(""),d(""),x(!0)}catch(v){g(N(v))}}},children:[i&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:i}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(m,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:o=>{n(o.target.value),x(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(m,{id:"pw-next",type:"password",autoComplete:"new-password",value:s,onChange:o=>{u(o.target.value),x(!1)}}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters. No composition rules — length is what matters."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-again",children:"Confirm new password"}),e.jsx(m,{id:"pw-again",type:"password",autoComplete:"new-password",value:l,onChange:o=>{d(o.target.value),x(!1)}}),l.length>0&&s!==l&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Those do not match yet."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",loading:t.isPending,disabled:!p,children:t.isPending?"Changing…":j&&!p?"Changed":"Change password"})})]})}export{G as component};
1
+ import{r,v as w,j as e,f as b,w as y,B as f,X as N}from"./index-DtF8YHqn.js";import{L as c,I as m}from"./label-Dj8L94iS.js";import{P as S,a as h}from"./parts-CA4cbfy3.js";import{S as C}from"./SaveState-D0Hl8cny.js";import{u as P}from"./me-7-r9OeMR.js";import{u as A,a as k}from"./studio-D9GxJaSF.js";import{M as F,S as E,a as M}from"./sun-Bg7U-6Y0.js";import"./card-Bz0VdsxC.js";import"./labels--UUyt9uB.js";import"./useBaseQuery-DSqwWD_O.js";function T({items:t}){const[a,n]=r.useState(w);return e.jsx("div",{className:"flex gap-2",role:"radiogroup","aria-label":"Theme",children:t.map(s=>e.jsxs("button",{type:"button",role:"radio","aria-checked":a===s.value,onClick:()=>{y(s.value),n(s.value)},className:b("inline-flex h-7 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[12.5px] font-medium text-ink-soft",a===s.value&&"border-line-strong bg-muted text-foreground"),children:[s.icon,s.label]},s.value))})}function G(){const t=P(),a=A(),[n,s]=r.useState(t.user.name),[u,l]=r.useState(null);r.useEffect(()=>s(t.user.name),[t.user.name]);const d=n.trim()!==t.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(S,{title:"You",sub:"Your own account on this studio",actions:e.jsx(C,{saving:a.isPending,savedAt:u})}),e.jsxs(h,{title:"Profile",description:"How you appear on replies and in the members list.",children:[e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:i=>{i.preventDefault(),d&&a.mutate(n.trim(),{onSuccess:()=>l(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{id:"your-name",value:n,onChange:i=>s(i.target.value)}),d&&e.jsx(f,{type:"submit",variant:"outline",children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"your-email",children:"Email"}),e.jsx(m,{id:"your-email",value:t.user.email,readOnly:!0,className:"bg-muted text-ink-soft"}),e.jsxs("p",{className:"m-0 text-[12px] text-muted-foreground",children:["How you sign in, and how the server finds you. An owner changes it with"," ",e.jsx("code",{className:"font-mono",children:"snagset passwd"}),"."]})]})]}),e.jsx(h,{title:"Password",description:"Changing it keeps this session and ends every other one.",children:e.jsx(D,{})}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(T,{items:[{value:"system",label:"System",icon:e.jsx(F,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(E,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(M,{className:"size-3.5"})}]})})]})}function D(){const t=k(),[a,n]=r.useState(""),[s,u]=r.useState(""),[l,d]=r.useState(""),[i,g]=r.useState(""),[j,x]=r.useState(!1),p=a.length>0&&s.length>=12&&s===l;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async o=>{if(o.preventDefault(),!(!p||t.isPending)){g("");try{await t.mutateAsync({current:a,next:s}),n(""),u(""),d(""),x(!0)}catch(v){g(N(v))}}},children:[i&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:i}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(m,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:o=>{n(o.target.value),x(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(m,{id:"pw-next",type:"password",autoComplete:"new-password",value:s,onChange:o=>{u(o.target.value),x(!1)}}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters. No composition rules — length is what matters."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-again",children:"Confirm new password"}),e.jsx(m,{id:"pw-again",type:"password",autoComplete:"new-password",value:l,onChange:o=>{d(o.target.value),x(!1)}}),l.length>0&&s!==l&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Those do not match yet."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",loading:t.isPending,disabled:!p,children:t.isPending?"Changing…":j&&!p?"Changed":"Change password"})})]})}export{G as component};
@@ -1 +1 @@
1
- import{aI as I}from"./index-Bvmz5Xph.js";var me=e=>e.type==="checkbox",Se=e=>e.type==="file",te=e=>e instanceof Date,p=e=>e==null;const He=e=>typeof e=="object";var N=e=>!p(e)&&!Array.isArray(e)&&He(e)&&!te(e),Gr=e=>N(e)&&e.target?me(e.target)?e.target.checked:Se(e.target)?e.target.files:e.target.value:e;const Kr=/[.[\]'"]/;var ue=e=>e.split(Kr).filter(Boolean),Zr=(e,s)=>s.split(".").some((r,i,l)=>!isNaN(Number(r))&&e.has(l.slice(0,i).join("."))),Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function C(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Te&&(e instanceof Blob||s))return e;const r=Array.isArray(e);if(!r&&e.constructor!==Object)return e;const i=r?[]:Object.create(Object.getPrototypeOf(e));for(const l in e)Object.prototype.hasOwnProperty.call(e,l)&&(i[l]=C(e[l]));return i}const oe={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},X={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},J={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Dr="root",je=["__proto__","constructor","prototype"],Jr=/^\w*$/;var ne=e=>Jr.test(e),O=e=>e===void 0,v=(e,s,r)=>{if(!s||!N(e))return r;const i=ne(s)?[s]:ue(s);if(i.some(u=>je.includes(u)))return r;const l=i.reduce((u,o)=>p(u)?void 0:u[o],e);return O(l)||l===e?O(e[s])?r:e[s]:l},re=e=>typeof e=="boolean",G=e=>typeof e=="function",k=(e,s,r)=>{let i=-1;const l=ne(s)?[s]:ue(s),u=l.length,o=u-1;for(;++i<u;){const c=l[i];let m=r;if(i!==o){const E=e[c];m=N(E)||Array.isArray(E)?E:isNaN(+l[i+1])?{}:[]}if(je.includes(c))return;e[c]=m,e=e[c]}};const Qr=I.createContext(null);Qr.displayName="HookFormControlContext";var Xr=(e,s,r,i=!0)=>{const l={};for(const u in e)Object.defineProperty(l,u,{get:()=>{const o=u;return s._proxyFormState[o]!==X.all&&(s._proxyFormState[o]=!i||X.all),e[o]}});return l};const et=Te?I.useLayoutEffect:I.useEffect;var rt=e=>{const s=e.constructor&&e.constructor.prototype;return N(s)&&s.hasOwnProperty("isPrototypeOf")},Me=e=>p(e)||!He(e);const lr=(e,s)=>s.length===0&&!Array.isArray(e)&&!rt(e);function Q(e,s,r=new WeakMap){if(e===s)return!0;if(Me(e)||Me(s))return Object.is(e,s);if(te(e)&&te(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),l=Object.keys(s);if(i.length!==l.length)return!1;if(lr(e,i)||lr(s,l))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const u=r.get(e);if(u&&u.has(s))return!0;if(u)u.add(s);else{const o=new WeakSet;o.add(s),r.set(e,o)}for(const o of i){const c=e[o];if(!(o in s))return!1;if(o!=="ref"){const m=s[o];if(te(c)&&te(m)||(N(c)||Array.isArray(c))&&(N(m)||Array.isArray(m))?!Q(c,m,r):!Object.is(c,m))return!1}}return!0}function tt(e){const s=I.useRef(!1),r=I.useRef(!1),i=I.useRef(void 0),l=I.useRef(0);l.current++,r.current;const u=I.useCallback((c,m,E)=>{if(c&&(s.current||r.current&&l.current>1)){const T=m();Q(i.current,T)||E(T)}s.current=!0},[]),o=I.useCallback((c,m)=>{c&&(i.current=C(m()))},[]);return{resyncIfNeeded:u,snapshot:o}}var M=e=>typeof e=="string",st=(e,s,r,i,l)=>M(e)?(i&&s.watch.add(e),v(r,e,l)):Array.isArray(e)?e.map(u=>(i&&s.watch.add(u),v(r,u,v(l,u)))):(i&&(s.watchAll=!0),r),De=e=>({isOnSubmit:!e||e===X.onSubmit,isOnBlur:e===X.onBlur,isOnChange:e===X.onChange,isOnAll:e===X.all,isOnTouch:e===X.onTouched}),Ue=(e,s,r)=>{if(r)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Ve=(e,s,r,i)=>{for(const l of r||Object.keys(e)){if(l==="_f")continue;const u=r?v(e,l):e[l];if(u){const{_f:o}=u;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],l)&&!i)return!0;if(o.ref&&s(o.ref,o.name)&&!i)return!0;if(Ve(u,s))break}else if((N(u)||Array.isArray(u))&&Ve(u,s))break}}};var ur=(e,s,r)=>{const i=v(e,r),l=Array.isArray(i)?i:[];return k(l,Dr,s[r]),k(e,r,l),e},B=e=>N(e)&&!Object.keys(e).length,ke=e=>{if(!Te)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},ze=e=>e.type==="radio",Oe=e=>e instanceof RegExp,Ye=(e,s,r,i,l)=>s?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[i]:l||!0}}:{};const fr={value:!1,isValid:!1},cr={value:!0,isValid:!0};var xr=e=>{if(!Array.isArray(e))return fr;if(e.length>1){const r=e.filter(i=>i&&i.checked&&!i.disabled).map(i=>i.value);return{value:r,isValid:!!r.length}}const s=e[0];return!s||!s.checked||s.disabled?fr:!s.attributes||!("value"in s.attributes)||O(s.value)||s.value===""?cr:{value:s.value,isValid:!0}};const dr={isValid:!1,value:null};var kr=e=>Array.isArray(e)?e.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,dr):dr;function yr(e,s,r="validate"){if(M(e)||Array.isArray(e)&&e.every(M)||re(e)&&!e)return{type:r,message:M(e)?e:"",ref:s}}var le=e=>N(e)&&!Oe(e)?e:{value:e,message:""},hr=async(e,s,r,i,l,u)=>{const{ref:o,refs:c,required:m,maxLength:E,minLength:T,min:H,max:j,pattern:$,validate:A,name:F,valueAsNumber:b,mount:fe}=e._f,w=v(r,F);if(!fe||s.has(F))return{};const ee=c?c[0]:o,P=D=>{if(l&&ee.reportValidity){const x=re(D)?"":D||"";c?c.forEach(R=>R.setCustomValidity(x)):ee.setCustomValidity(x),ee.reportValidity()}},S={},ce=ze(o),be=me(o),Ae=ce||be,ae=(b||Se(o))&&O(o.value)&&O(w)||ke(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,se=Ye.bind(null,F,i,S),Fe=(D,x,R,W=J.maxLength,K=J.minLength)=>{const q=D?x:R;S[F]={type:D?W:K,message:q,ref:o,...se(D?W:K,q)}};if(u?!Array.isArray(w)||!w.length:m&&(!Ae&&(ae||p(w))||re(w)&&!w||be&&!xr(c).isValid||ce&&!kr(c).isValid)){const{value:D,message:x}=M(m)?{value:!!m,message:m}:le(m);if(D&&(S[F]={type:J.required,message:x,ref:ee,...se(J.required,x)},!i))return P(x),S}if(!ae&&(!p(H)||!p(j))){let D,x;const R=le(j),W=le(H);if(!p(w)&&!te(w)&&!isNaN(w)){const K=o.valueAsNumber||w&&+w;p(R.value)||(D=K>R.value),p(W.value)||(x=K<W.value)}else{const K=o.valueAsDate||new Date(w),q=ye=>new Date(new Date().toDateString()+" "+ye),we=o.type=="time",Y=o.type=="week";M(R.value)&&w&&(D=we?q(w)>q(R.value):Y?w>R.value:K>new Date(R.value)),M(W.value)&&w&&(x=we?q(w)<q(W.value):Y?w<W.value:K<new Date(W.value))}if((D||x)&&(Fe(!!D,R.message,W.message,J.max,J.min),!i))return P(S[F].message),S}if((E||T)&&!ae&&(M(w)||u&&Array.isArray(w))){const D=le(E),x=le(T),R=!p(D.value)&&w.length>+D.value,W=!p(x.value)&&w.length<+x.value;if((R||W)&&(Fe(R,D.message,x.message),!i))return P(S[F].message),S}if($&&!ae&&M(w)){const{value:D,message:x}=le($);if(Oe(D)&&!w.match(D)&&(S[F]={type:J.pattern,message:x,ref:o,...se(J.pattern,x)},!i))return P(x),S}if(A){if(G(A)){const D=await A(w,r),x=yr(D,ee);if(x&&(S[F]={...x,...se(J.validate,x.message)},!i))return P(x.message),S}else if(N(A)){let D={};for(const x in A){if(!B(D)&&!i)break;const R=yr(await A[x](w,r),ee,x);R&&(D={...R,...se(x,R.message)},P(R.message),i&&(S[F]=D))}if(!B(D)&&(S[F]={ref:ee,...D},!i))return S}}const de=S[F];return P(de?de.message:!0),S},xe=e=>Array.isArray(e)?e:[e],Or=e=>Array.isArray(e)?e.filter(Boolean):[];function it(e,s){const r=s.length-1;let i=0;for(;i<r;){if(p(e)){e=void 0;break}e=e[s[i]],i++}return e}function nt(e){for(const s in e)if(e.hasOwnProperty(s)&&!O(e[s]))return!1;return!0}function U(e,s){if(M(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const r=Array.isArray(s)?s:ne(s)?[s]:ue(s);if(r.some(o=>je.includes(String(o))))return e;const i=r.length===1?e:it(e,r),l=r.length-1,u=r[l];return i&&delete i[u],l!==0&&(N(i)&&B(i)||Array.isArray(i)&&nt(i))&&U(e,r.slice(0,-1)),e}const at=I.createContext(null);at.displayName="HookFormContext";var gr=()=>{let e=[];return{get observers(){return e},next:l=>{for(const u of e)u.next&&u.next(l)},subscribe:l=>(e.push(l),{unsubscribe:()=>{e=e.filter(u=>u!==l)}}),unsubscribe:()=>{e=[]}}};function Sr(e,s){const r={};for(const i in e)if(e.hasOwnProperty(i)){const l=e[i],u=s[i];if(l&&N(l)&&u){const o=Sr(l,u);N(o)&&(r[i]=o)}else e[i]&&(r[i]=u)}return r}const vr=(e,s)=>e!==null&&He(e)&&Object.prototype.hasOwnProperty.call(e,s);var ot=(e,s)=>{if(!s)return!1;let r=e;for(const i of ne(s)?[s]:ue(s)){if(!vr(r,i))return vr(e,s);r=r[i]}return!0},Tr=e=>e.type==="select-multiple",lt=e=>ze(e)||me(e),Pe=e=>ke(e)&&e.isConnected;function _r(e){return Array.isArray(e)||N(e)}function Rr(e,s,r="",i=[]){for(const l in e){const u=r?`${r}.${l}`:l,o=e[l];_r(o)&&_r(v(s,u))?Rr(o,s,u,i):i.push(u)}return i}var ut=e=>{for(const s in e)if(G(e[s]))return!0;return!1};function Cr(e){return Array.isArray(e)||N(e)&&!ut(e)}function Lr(e){return!!(e&&"_f"in e)}function Ir(e){return Array.isArray(e)?!e.some(s=>!O(s)):!Object.keys(e).length}function Be(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function $e(e,s={},r){for(const i in e){const l=e[i],u=r&&r[i];Cr(l)&&(!Array.isArray(l)||!Lr(u))?(s[i]=Array.isArray(l)?[]:{},$e(l,s[i],u),Ir(s[i])&&Be(s,i)):O(l)||(s[i]=!0)}return s}function ie(e,s,r,i){r||(r=$e(s,{},i));for(const l in e){const u=e[l],o=i&&i[l];Cr(u)&&(!Array.isArray(u)||!Lr(o))?(O(s)||Me(r[l])?r[l]=$e(u,Array.isArray(u)?[]:{},o):ie(u,p(s)?{}:s[l],r[l],o),Ir(r[l])&&Be(r,l)):Q(u,s[l])?Be(r,l):r[l]=!0}return r}var ft=(e,s)=>{const r=s.split("."),i=[];let l=r[0];for(let u=1;u<r.length;l+="."+r[u++])!isNaN(+r[u])&&e.has(l)&&i.push(`${l}.${r[u]}`);return i},Nr=(e,{valueAsNumber:s,valueAsDate:r,setValueAs:i})=>O(e)?e:s?e===""?NaN:e&&+e:r&&M(e)?new Date(e):i?i(e):e;function Vr(e){const s=e.ref;return Se(s)?s.files:ze(s)?kr(e.refs).value:Tr(s)?[...s.selectedOptions].map(({value:r})=>r):me(s)?xr(e.refs).value:Nr(s.value,e)}var ct=(e,s,r,i)=>{const l={};for(const u of e){const o=v(s,u);o&&k(l,u,o._f)}return{criteriaMode:r,names:[...e],fields:l,shouldUseNativeValidation:i}},_e=e=>O(e)?e:Oe(e)?e.source:N(e)?Oe(e.value)?e.value.source:e.value:e;const mr="AsyncFunction";var dt=e=>{if(!e||!e.validate)return!1;if(G(e.validate))return e.validate.constructor.name===mr;if(N(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===mr)return!0}return!1},yt=e=>e.mount&&(e.required||!O(e.required)&&e.required!==!1||!O(e.min)||!O(e.max)||!O(e.maxLength)||!O(e.minLength)||e.pattern||e.validate);function br(e,s,r){const i=v(e,r);if(i||ne(r))return{error:i,name:r};const l=r.split(".");for(;l.length;){const u=l.join("."),o=v(s,u),c=v(e,u);if(o&&!Array.isArray(o)&&r!==u)return{name:r};if(c&&c.type)return{name:u,error:c};if(c&&c.root&&c.root.type)return{name:`${u}.root`,error:c.root};l.pop()}return{name:r}}var ht=(e,s,r,i)=>{r(e);const l=Object.keys(e).filter(u=>u!=="name");return!l.length||i&&l.length>=Object.keys(s).length||l.find(u=>s[u]===(!i||X.all))},gt=(e,s,r)=>!e||!s||e===s||xe(e).some(i=>i&&(r?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),vt=(e,s,r,i,l)=>l.isOnAll?!1:!r&&l.isOnTouch?!(s||e):(r?i.isOnBlur:l.isOnBlur)?!e:(r?i.isOnChange:l.isOnChange)?e:!0,_t=(e,s)=>{const r=v(e,s);!Or(r).length&&!r?.root&&U(e,s)};const Vt={mode:X.onSubmit,reValidateMode:X.onChange,shouldFocusError:!0},pe="form",mt=(e,s)=>{for(const r in e)r in s||delete e[r];Object.assign(e,s)},Ur={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function bt(e={}){let s={...Vt,...e},r={...C(Ur),isLoading:G(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},l=N(s.defaultValues)||N(s.values)?C(s.defaultValues||s.values)||{}:{},u=s.shouldUnregister?{}:C(l),o={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const m={},E={};let T=0,H=De(s.mode),j=De(s.reValidateMode);const $={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},A={...$};let F={...A};const b={array:gr(),state:gr()};let fe=0;const w=s.criteriaMode===X.all,ee=(t,a)=>n=>{clearTimeout(E[t]),E[t]=setTimeout(a,n)},P=async t=>{if(!o.keepIsValid&&!s.disabled&&(A.isValid||F.isValid||t)){const a=++fe;let n;s.resolver?(n=B((await R()).errors),a===fe&&S()):n=await q({fields:i,onlyCheckValid:!0,eventType:oe.VALID}),a===fe&&n!==r.isValid&&b.state.next({isValid:n})}},S=(t,a)=>{!s.disabled&&(A.isValidating||A.validatingFields||F.isValidating||F.validatingFields)&&((t||c.mount).forEach(n=>{n&&(a?k(r.validatingFields,n,a):U(r.validatingFields,n))}),b.state.next({validatingFields:r.validatingFields,isValidating:!B(r.validatingFields)}))},ce=()=>{r.dirtyFields=ie(l,u,void 0,i)},be=(t,a=[],n,f,d=!0,y=!0)=>{if(f&&n&&!s.disabled){o.action=!0;const h=v(i,t);if(o.actionArrayLengths.has(t)||o.actionArrayLengths.set(t,Array.isArray(h)?h.length:0),y&&Array.isArray(h)){const V=n(h,f.argA,f.argB);d&&k(i,t,V)}const g=v(r.errors,t);if(y&&Array.isArray(g)){const V=g.root,L=n(g,f.argA,f.argB)||g;V&&(L.root=V),d&&k(r.errors,t,L),_t(r.errors,t)}const _=v(r.touchedFields,t);if((A.touchedFields||F.touchedFields)&&y&&Array.isArray(_)){const V=n(_,f.argA,f.argB);d&&k(r.touchedFields,t,V)}(A.dirtyFields||F.dirtyFields)&&ce(),b.state.next({name:t,isDirty:Y(t,a),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else k(u,t,a)},Ae=(t,a)=>{k(r.errors,t,a),r.errors={...r.errors},b.state.next({errors:r.errors})},ae=t=>{r.errors=t,b.state.next({errors:r.errors,isValid:!1})},se=t=>{const a=ne(t)?[t]:ue(t);let n=u,f=l;for(let d=0;d<a.length-1;d++){const y=a[d];if(n=p(n)?n:n[y],f=p(f)?f:f[y],n===null&&f!==null)return!0}return!1},Fe=t=>{if(!o.actionArrayLengths.size)return!1;const a=ne(t)?[t]:ue(t);let n=u,f="",d=-1,y=0;for(let h=0;h<a.length;h++){if(p(n))return!1;const g=a[h];if(f=f?`${f}.${g}`:g,Array.isArray(n)&&+g>=n.length)return d===-1?!1:h===d?+g<y:!0;o.actionArrayLengths.has(f)&&(d=h+1,y=o.actionArrayLengths.get(f)),n=n[g]}return!1},de=(t,a,n,f)=>{const d=v(i,t);if(d){if(se(t)||Fe(t))return;const y=O(v(u,t)),h=v(u,t,O(n)?v(l,t):n);O(h)||f&&f.defaultChecked||a?k(u,t,a?h:Vr(d._f)):Re(t,h),o.mount&&!o.action&&(P(),y&&r.isDirty&&(A.isDirty||F.isDirty)&&(Y()||(r.isDirty=!1,b.state.next({...r}))),e.shouldUnregister&&y&&!O(v(u,t))&&Ue(t,c)&&(o.watch=!0))}},D=(t,a,n,f,d)=>{let y=!1,h=!1;const g={name:t};if(!s.disabled||f===!0){if(!n||f){const _=Q(v(l,t),a);(A.isDirty||F.isDirty)&&(h=r.isDirty,r.isDirty=g.isDirty=!_||Y(),y=h!==g.isDirty),h=!!v(r.dirtyFields,t),_!==r.isDirty?mt(r.dirtyFields,ie(l,u,void 0,i)):_?U(r.dirtyFields,t):k(r.dirtyFields,t,!0),g.dirtyFields=r.dirtyFields,y=y||(A.dirtyFields||F.dirtyFields)&&h!==!_}if(n){const _=v(r.touchedFields,t);_||(k(r.touchedFields,t,n),g.touchedFields=r.touchedFields,y=y||(A.touchedFields||F.touchedFields)&&_!==n)}y&&d&&b.state.next(g)}return y?g:{}},x=(t,a,n,f)=>{const d=v(r.errors,t),y=(A.isValid||F.isValid)&&re(a)&&r.isValid!==a;if(s.delayError&&n?(m[t]=ee(t,()=>Ae(t,n)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t],n?k(r.errors,t,n):U(r.errors,t),r.errors={...r.errors}),(n?!Q(d,n):d)||!B(f)||y){const h={...f,...y&&re(a)?{isValid:a}:{},errors:r.errors,name:t};b.state.next(h)}},R=async t=>(S(t,!0),await s.resolver(u,s.context,ct(t||c.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),W=async t=>{const{errors:a}=await R(t);if(S(t),t){for(const n of t){const f=v(a,n);f?c.array.has(n)&&N(f)&&!Object.keys(f).some(d=>!Number.isNaN(Number(d)))?ur(r.errors,{[n]:f},n):k(r.errors,n,f):U(r.errors,n)}r.errors={...r.errors}}else r.errors=a;return a},K=async({name:t,eventType:a})=>{if(e.validate){const n=await e.validate({formValues:u,formState:r,name:t,eventType:a});if(N(n))for(const f in n){const d=n[f];d&&Ee(`${pe}.${f}`,{message:M(d.message)?d.message:"",type:d.type||J.validate})}else M(n)||!n?Ee(pe,{message:n||"",type:J.validate}):Xe(pe);return n}return!0},q=async({fields:t,onlyCheckValid:a,name:n,eventType:f,context:d={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(d.runRootValidation=!0,!await K({name:n,eventType:f})&&(d.valid=!1,a)))return d.valid;for(const y in t){const h=t[y];if(h){const{_f:g,..._}=h;if(g){const V=c.array.has(g.name),L=h._f&&dt(h._f),z=A.validatingFields||A.isValidating||F.validatingFields||F.isValidating;L&&z&&S([g.name],!0);const Z=await hr(h,c.disabled,u,w,s.shouldUseNativeValidation&&!a,V);if(L&&z&&S([g.name]),Z[g.name]&&(d.valid=!1,a)||(!a&&(v(Z,g.name)?V?ur(r.errors,Z,g.name):k(r.errors,g.name,Z[g.name]):U(r.errors,g.name)),e.shouldUseNativeValidation&&Z[g.name]))break}!B(_)&&await q({context:d,onlyCheckValid:a,fields:_,name:y,eventType:f})}}return d.valid},we=()=>{for(const t of c.unMount){const a=v(i,t);a&&(a._f.refs?a._f.refs.every(n=>!Pe(n)):!Pe(a._f.ref))&&Le(t)}c.unMount=new Set},Y=(t,a)=>(t&&a&&k(u,t,a),!Q(o.mount?u:l,l)),ye=(t,a,n)=>st(t,c,{...o.mount?u:O(a)||M(t)?l:a},n,a),Pr=t=>Or(v(o.mount?u:l,t,s.shouldUnregister?v(l,t,[]):[])),Re=(t,a,n={},f=!1,d=!1,y=!1)=>{const h=v(i,t);let g=a;if(h){const _=h._f;_&&(!_.disabled&&k(u,t,Nr(a,_)),g=ke(_.ref)&&p(a)?"":a,Tr(_.ref)?[..._.ref.options].forEach(V=>V.selected=g.includes(V.value)):_.refs?me(_.ref)?_.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(g)?V.checked=!!g.find(L=>L===V.value):V.checked=g===V.value||!!g)}):_.refs.forEach(V=>V.checked=V.value===g):Se(_.ref)?_.ref.value="":(_.ref.value=g,!_.ref.type&&!d&&!y&&b.state.next({name:t,values:f?u:C(u)})))}(n.shouldDirty||n.shouldTouch)&&D(t,g,n.shouldTouch,n.shouldDirty,!d),n.shouldValidate&&Ce(t,{delayError:n.delayError})},Ge=(t,a,n,f=!1,d=!1,y=!1)=>{c.array.has(t)&&b.array.next({name:t,values:f?u:C(u)});for(const h in a){if(!a.hasOwnProperty(h))continue;const g=a[h],_=t+"."+h,V=v(i,_);(c.array.has(t)||N(g)||V&&!V._f)&&!te(g)?Ge(_,g,n,f,d,y):Re(_,g,n,f,d,y)}},Ke=(t,a,n,f,d=!1)=>{const y=v(i,t),h=c.array.has(t),g=f?a:C(a),_=v(u,t),V=Q(_,g);if(V||k(u,t,g),h)b.array.next({name:t,values:f?u:C(u)}),(A.isDirty||A.dirtyFields||F.isDirty||F.dirtyFields)&&n.shouldDirty&&(ce(),d||b.state.next({name:t,dirtyFields:r.dirtyFields,isDirty:Y(t,g)}));else{const L=Array.isArray(g)&&!g.length||B(g),z=!V&&!d;!y||y._f||p(g)||L?Re(t,g,n,f,d,z):Ge(t,g,n,f,d,z)}if(!V&&!d){const L=Ue(t,c),z=f?u:C(u);if(b.state.next({...L&&r,name:o.mount||L?t:void 0,values:z}),!h)for(const Z of ft(c.array,t))b.state.next({name:Z,values:z})}},he=(t,a,n={})=>Ke(t,a,n,!1),pr=(t,a={})=>{const n=G(t)?t(u):t;if(!Q(u,n)){u={...u,...n};for(const f of c.mount)ot(n,f)&&Ke(f,v(n,f),a,!0,!0);b.state.next({...r,name:void 0,type:void 0,...T?{values:u}:{}}),a.shouldValidate&&P()}},Ze=async t=>{o.mount=!0;const a=t.target;let n=a.name,f=!0;const d=v(i,n),y=h=>{f=Number.isNaN(h)||te(h)&&isNaN(h.getTime())||Q(h,v(u,n,h))};if(d){let h,g;const _=a.type?Vr(d._f):Gr(t),V=t.type===oe.BLUR||t.type===oe.FOCUS_OUT,L=!yt(d._f)&&!e.validate&&!s.resolver&&!v(r.errors,n)&&!d._f.deps,z=L||vt(V,v(r.touchedFields,n),r.isSubmitted,j,H),Z=Ue(n,c,V);if(k(u,n,C(_)),V){if(!a||!a.readOnly){d._f.onBlur&&d._f.onBlur(t);const ve=m[n];ve&&ve(0)}}else d._f.onChange&&d._f.onChange(t);const ge=D(n,_,V),zr=!B(ge)||Z;if(!V&&b.state.next({name:n,type:t.type,...T?{values:C(u)}:{}}),z)return(!L||!r.isValid)&&(A.isValid||F.isValid)&&(s.mode==="onBlur"?V&&P():V||P()),zr&&b.state.next({name:n,...Z?{}:ge});if(!s.resolver&&e.validate&&await K({name:n,eventType:t.type}),!V&&Z&&b.state.next({...r}),s.resolver){const{errors:ve}=await R([n]);if(S([n]),y(_),!f){!B(ge)&&b.state.next(ge);return}const Yr=br(r.errors,i,n),or=br(ve,i,Yr.name||n);h=or.error,n=or.name,g=B(ve)}else S([n],!0),h=(await hr(d,c.disabled,u,w,s.shouldUseNativeValidation))[n],S([n]),y(_),f&&(h?g=!1:(A.isValid||F.isValid)&&(g=await q({fields:i,onlyCheckValid:!0,name:n,eventType:t.type})));f&&(d._f.deps&&(!Array.isArray(d._f.deps)||d._f.deps.length>0)&&Ce(d._f.deps),x(n,g,h,ge))}},Je=(t,a)=>{if(v(r.errors,a)&&t.focus)return t.focus(),1},Ce=async(t,a={})=>{let n,f;const d=xe(t);if(s.resolver){const y=await W(O(t)?t:d);n=B(y),f=t?!d.some(h=>v(y,h)):n}else t?(f=(await Promise.all(d.map(async y=>{const h=v(i,y);return await q({fields:h&&h._f?{[y]:h}:h,eventType:oe.TRIGGER})}))).every(Boolean),!(!f&&!r.isValid)&&P()):f=n=await q({fields:i,name:t,eventType:oe.TRIGGER});if(a.delayError&&s.delayError&&M(t)){const y=v(r.errors,t);y?(U(r.errors,t),m[t]=ee(t,()=>Ae(t,y)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t])}if(a.shouldTouch)for(const y of t?d:c.mount)!c.array.has(y)&&k(r.touchedFields,y,!0);return b.state.next({...!M(t)||(A.isValid||F.isValid)&&n!==r.isValid?{}:{name:t},...s.resolver||!t?{isValid:n}:{},...a.shouldTouch&&(A.touchedFields||F.touchedFields)?{touchedFields:r.touchedFields}:{},errors:r.errors}),a.shouldFocus&&!f&&Ve(i,Je,t?d:c.mount),f},Mr=(t,a)=>{let n={...o.mount?u:l};return a&&(n=Sr(a.dirtyFields?r.dirtyFields:r.touchedFields,n)),O(t)?n:M(t)?v(n,t):t.map(f=>v(n,f))},Br=t=>O(t)?{...r.errors}:M(t)?v(r.errors,t):t.map(a=>v(r.errors,a)),Qe=(t,a)=>{const n=a||r,f=v(n.errors,t);return{invalid:!!f,isDirty:!!v(n.dirtyFields,t),error:f,isValidating:!!v(r.validatingFields,t),isTouched:!!v(n.touchedFields,t)}},Xe=t=>{const a=t?xe(t):void 0;a?.forEach(n=>U(r.errors,n)),a?a.forEach(n=>{b.state.next({name:n,errors:r.errors})}):(r.errors={},b.state.next({errors:r.errors}))},Ee=(t,a,n)=>{const f=(v(i,t,{_f:{}})._f||{}).ref,d=v(r.errors,t)||{},{ref:y,message:h,type:g,..._}=d;k(r.errors,t,{..._,...a,ref:f}),b.state.next({name:t,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&f&&f.focus&&f.focus()},$r=(t,a)=>{if(G(t)){T++;const{unsubscribe:n}=b.state.subscribe({next:d=>"values"in d&&t(d.values||ye(void 0,a),d)});let f=!1;return{unsubscribe:()=>{f||(f=!0,T--,n())}}}return ye(t,a,!0)},er=t=>{var a;const n=!!(!((a=t.formState)===null||a===void 0)&&a.values);n&&T++;const{unsubscribe:f}=b.state.subscribe({next:y=>{if(gt(t.name,y.name,t.exact)&&ht(y,t.formState||A,nr,t.reRenderRoot)){const h={...u};t.callback({values:h,...r,...y,defaultValues:l})}}});if(!n)return f;let d=!1;return()=>{d||(d=!0,T--,f())}},Wr=t=>(o.mount=!0,F={...F,...t.formState},er({...t,formState:{...$,...t.formState}})),Le=(t,a={})=>{for(const n of t?xe(t):c.mount)c.mount.delete(n),c.array.delete(n),a.keepValue||(U(i,n),U(u,n)),!a.keepError&&U(r.errors,n),!a.keepDirty&&U(r.dirtyFields,n),!a.keepTouched&&U(r.touchedFields,n),!a.keepIsValidating&&U(r.validatingFields,n),!s.shouldUnregister&&!a.keepDefaultValue&&U(l,n);T&&b.state.next({values:C(u)}),b.state.next({...r,...a.keepDirty?{}:{isDirty:Y()}}),!a.keepIsValid&&P()},rr=({disabled:t,name:a})=>{if(re(t)&&o.mount||t||c.disabled.has(a)){const d=c.disabled.has(a)!==!!t;t?c.disabled.add(a):c.disabled.delete(a),d&&o.mount&&!o.action&&P()}},Ie=(t,a={})=>{let n=v(i,t);const f=re(a.disabled)||re(s.disabled),d=!c.registerName.has(t)&&n&&n._f&&!n._f.mount;return k(i,t,{...n||{},_f:{...n&&n._f?n._f:{ref:{name:t}},name:t,mount:!0,...a}}),c.mount.add(t),n&&!d?rr({disabled:re(a.disabled)?a.disabled:s.disabled,name:t}):de(t,!0,a.value),{...f?{disabled:a.disabled||s.disabled}:{},...s.progressive?{required:!!a.required,min:_e(a.min),max:_e(a.max),minLength:_e(a.minLength),maxLength:_e(a.maxLength),pattern:_e(a.pattern)}:{},name:t,onChange:Ze,onBlur:Ze,ref:y=>{if(y){c.registerName.add(t),Ie(t,a),c.registerName.delete(t),n=v(i,t);const h=O(y.value)&&y.querySelectorAll&&y.querySelectorAll("input,select,textarea")[0]||y,g=lt(h),_=n._f.refs||[];if(g?_.find(L=>L===h):h===n._f.ref)return;const V={...n._f};g?(V.refs=[..._.filter(Pe),h,...Array.isArray(v(l,t))?[{}]:[]],V.ref={type:h.type,name:t}):(V.ref=h,delete V.refs),k(i,t,{_f:V}),de(t,!1,void 0,h)}else n=v(i,t,{}),n._f&&(n._f.mount=!1),(s.shouldUnregister||a.shouldUnregister)&&!(Zr(c.array,t)&&o.action)&&c.unMount.add(t)}}},Ne=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ve(i,Je,c.mount),qr=t=>{re(t)&&(b.state.next({disabled:t}),Ve(i,(a,n)=>{const f=v(i,n);f&&(a.disabled=f._f.disabled||t,Array.isArray(f._f.refs)&&f._f.refs.forEach(d=>{d.disabled=f._f.disabled||t}))},0,!1))},tr=(t,a)=>async n=>{let f,d;n&&(n.preventDefault&&n.preventDefault(),n.persist&&n.persist());let y=C(u);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:h,values:g}=await R();S(),r.errors=h,y=C(g)}else await q({fields:i,eventType:oe.SUBMIT});if(c.disabled.size)for(const h of c.disabled)U(y,h);if(U(r.errors,Dr),B(r.errors)){b.state.next({errors:{}});try{f=await t(y,n)}catch(h){d=h}}else a&&await a({...r.errors},n),Ne(),setTimeout(Ne);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(r.errors)&&!d,submitCount:r.submitCount+1,errors:r.errors}),d)throw d;return f},Hr=(t,a={})=>{v(i,t)&&(O(a.defaultValue)?he(t,C(v(l,t))):(he(t,a.defaultValue),k(l,t,C(a.defaultValue))),a.keepTouched||U(r.touchedFields,t),a.keepDirty||(U(r.dirtyFields,t),r.isDirty=a.defaultValue?Y(t,C(v(l,t))):Y()),a.keepError||(U(r.errors,t),P()),b.state.next({...r}))},sr=(t,a={})=>{const n=t?C(t):l,f=C(n),d=B(t),y=f,h=i;if(a.keepDefaultValues||(l=n),!a.keepValues){if(a.keepDirtyValues){const g=new Set([...c.mount,...Rr(ie(l,u,void 0,h),r.dirtyFields)]);for(const _ of g){const V=v(r.dirtyFields,_),L=v(u,_),z=v(y,_);V&&!O(L)?k(y,_,L):!V&&!O(z)&&he(_,z)}}else{if(Te&&O(t))for(const g of c.mount){const _=v(i,g);if(_&&_._f){const V=Array.isArray(_._f.refs)?_._f.refs[0]:_._f.ref;if(ke(V)){const L=V.closest("form");if(L){L.reset();break}}}}if(a.keepFieldsRef)for(const g of c.mount)he(g,v(y,g));else i={}}if(s.shouldUnregister){if(u=a.keepDefaultValues?C(l):{},a.keepFieldsRef)for(const g of c.mount)k(u,g,v(y,g))}else u=C(y);b.array.next({values:{...y}}),b.state.next({name:void 0,type:void 0,values:{...y}})}c={mount:a.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!A.isValid||!!a.keepIsValid||!!a.keepDirtyValues||!s.shouldUnregister&&!B(y),o.watch=!!s.shouldUnregister,o.keepIsValid=!!a.keepIsValid,o.action=!1,o.actionArrayLengths.clear(),a.keepErrors||(r.errors={}),b.state.next({submitCount:a.keepSubmitCount?r.submitCount:0,isDirty:d?!1:a.keepDirty?r.isDirty:a.keepValues?Y():!!(a.keepDefaultValues&&!Q(t,l)),isSubmitted:a.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:d?{}:a.keepDirtyValues?a.keepDefaultValues&&u?ie(l,u,void 0,h):r.dirtyFields:a.keepDefaultValues&&t?ie(l,t,void 0,h):a.keepDirty?r.dirtyFields:{},touchedFields:a.keepTouched?r.touchedFields:{},errors:a.keepErrors?r.errors:{},isSubmitSuccessful:a.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:l})},ir=(t,a)=>sr(G(t)?t(u):t,{...s.resetOptions,...a}),jr=(t,a={})=>{const n=v(i,t),f=n&&n._f;if(f){const d=f.refs?f.refs[0]:f.ref;d.focus&&setTimeout(()=>{d.focus(),a.shouldSelect&&G(d.select)&&d.select()})}},nr=t=>{const{name:a,type:n,values:f,...d}=t;r={...r,...d}};b.state.subscribe({next:nr});const ar={control:{register:Ie,unregister:Le,getFieldState:Qe,handleSubmit:tr,setError:Ee,_subscribe:er,_runSchema:R,_updateIsValidating:S,_focusError:Ne,_getWatch:ye,_getDirty:Y,_setValid:P,_setFieldArray:be,_setDisabledField:rr,_setErrors:ae,_getFieldArray:Pr,_reset:sr,_resetDefaultValues:()=>G(s.defaultValues)&&s.defaultValues().then(t=>{ir(t,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:we,_disableForm:qr,_subjects:b,_proxyFormState:A,get _fields(){return i},get _formValues(){return u},get _state(){return o},set _state(t){o=t},get _defaultValues(){return l},get _names(){return c},set _names(t){c=t},get _formState(){return r},get _options(){return s},set _options(t){s={...s,...t},H=De(s.mode),j=De(s.reValidateMode)}},subscribe:Wr,trigger:Ce,register:Ie,handleSubmit:tr,watch:$r,setValue:he,setValues:pr,getValues:Mr,getErrors:Br,reset:ir,resetField:Hr,resetDefaultValues:(t,a={})=>{if(l=C(t),!a.keepDirty){const n=ie(l,u,void 0,i);r.dirtyFields=n,r.isDirty=!B(n)}a.keepIsValid||P(),b.state.next({...r,defaultValues:l})},clearErrors:Xe,unregister:Le,setError:Ee,setFocus:jr,getFieldState:Qe};return{...ar,formControl:ar}}function kt(e={}){const s=I.useRef(void 0),r=I.useRef(void 0),i=I.useRef(e.formControl),[l,u]=I.useState(()=>({...C(Ur),isLoading:G(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:G(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:l},e.defaultValues&&!G(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:E,...T}=bt(e);s.current={...T,formState:l}}const o=s.current.control;o._options=e;const{resyncIfNeeded:c,snapshot:m}=tt();return et(()=>{const E=()=>({...o._formState,defaultValues:o._defaultValues});c(!0,E,u);const T=o._subscribe({formState:o._proxyFormState,callback:()=>u({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return u(H=>({...H,isReady:!0})),o._formState.isReady=!0,()=>{T(),m(!0,E)}},[o,c,m]),I.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),I.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),I.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),I.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),I.useEffect(()=>{if(o._proxyFormState.isDirty){const E=o._getDirty();E!==l.isDirty&&o._subjects.state.next({isDirty:E})}},[o,l.isDirty]),I.useEffect(()=>{var E;e.values&&!Q(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((E=o._options.resetOptions)===null||E===void 0)&&E.keepIsValid||o._setValid(),r.current=e.values,u(T=>({...T}))):o._resetDefaultValues()},[o,e.values]),I.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=I.useMemo(()=>Xr(l,o),[o,l]),s.current}const Ar=(e,s,r)=>{if(e&&"reportValidity"in e){const i=v(r,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},We=(e,s)=>{for(const r in s.fields){const i=s.fields[r];i&&i.ref&&"reportValidity"in i.ref?Ar(i.ref,r,e):i&&i.refs&&i.refs.forEach(l=>Ar(l,r,e))}},Fr=(e,s)=>{s.shouldUseNativeValidation&&We(e,s);const r={};for(const i in e){const l=v(s.fields,i),u=Object.assign(e[i]||{},{ref:l&&l.refs?l.refs[0]:l&&l.ref});if(At(s.names||Object.keys(e),i)){const o=Object.assign({},v(r,i));k(o,"root",u),k(r,i,o)}else k(r,i,u)}return r},At=(e,s)=>{const r=wr(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>wr(i).match(`^${r}\\.\\d+`))};function wr(e){return e.replace(/\[(\d+)]/g,".$1").replace(/[[\]]/g,"")}function qe(){return qe=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},qe.apply(null,arguments)}function Er(e,s){try{var r=e()}catch(i){return s(i)}return r&&r.then?r.then(void 0,s):r}function Ft(e,s){for(var r=Object.create(null);e.length;){var i=e[0],l=i.code,u=i.message,o=i.path.join(".");if(!r[o])if("unionErrors"in i){var c,m,E=i.unionErrors.reduce(function(j,$){return $.errors.length<j.errors.length?$:j}).errors[0];r[o]={message:(c=E?.message)!=null?c:u,type:(m=E?.code)!=null?m:l}}else r[o]={message:u,type:l};if("unionErrors"in i&&i.unionErrors.forEach(function(j){return j.errors.forEach(function($){return e.push($)})}),s){var T=r[o].types,H=T&&T[i.code];r[o]=Ye(o,s,r,l,H?[].concat(H,i.message):i.message)}e.shift()}return r}function wt(e,s){for(var r=Object.create(null),i=function(){var l=e[0],u=l.code,o=l.message,c=l.path.join(".");if(!r[c])if(l.code==="invalid_union"&&l.errors.length>0){var m,E,T=l.errors.reduce(function($,A){return A.length<$.length?A:$})[0];r[c]={message:(m=T?.message)!=null?m:o,type:(E=T?.code)!=null?E:u}}else r[c]={message:o,type:u};if(l.code==="invalid_union"&&l.errors.forEach(function($){return $.forEach(function(A){return e.push(qe({},A,{path:[].concat(l.path,A.path)}))})}),s){var H=r[c].types,j=H&&H[l.code];r[c]=Ye(c,s,r,u,j?[].concat(j,l.message):l.message)}e.shift()};e.length;)i();return r}function Ot(e,s,r){if(r===void 0&&(r={}),(function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){function o(m){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):m}}var c=e;return r.mode==="sync"?o(c.parse(i,s)):Promise.resolve(c.parseAsync(i,s)).then(o)},function(o){if((function(c){var m;return!(c==null||(m=c._zod)==null||(m=m.traits)==null||!m.has("$ZodError"))})(o))return{values:{},errors:Fr(wt(o.issues,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_def"in i&&typeof i._def=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(o){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):o}})},function(o){if((function(c){return Array.isArray(c?.issues)})(o))return{values:{},errors:Fr(Ft(o.errors,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}export{Ot as a,kt as u};
1
+ import{aI as I}from"./index-DtF8YHqn.js";var me=e=>e.type==="checkbox",Se=e=>e.type==="file",te=e=>e instanceof Date,p=e=>e==null;const He=e=>typeof e=="object";var N=e=>!p(e)&&!Array.isArray(e)&&He(e)&&!te(e),Gr=e=>N(e)&&e.target?me(e.target)?e.target.checked:Se(e.target)?e.target.files:e.target.value:e;const Kr=/[.[\]'"]/;var ue=e=>e.split(Kr).filter(Boolean),Zr=(e,s)=>s.split(".").some((r,i,l)=>!isNaN(Number(r))&&e.has(l.slice(0,i).join("."))),Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function C(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Te&&(e instanceof Blob||s))return e;const r=Array.isArray(e);if(!r&&e.constructor!==Object)return e;const i=r?[]:Object.create(Object.getPrototypeOf(e));for(const l in e)Object.prototype.hasOwnProperty.call(e,l)&&(i[l]=C(e[l]));return i}const oe={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},X={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},J={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Dr="root",je=["__proto__","constructor","prototype"],Jr=/^\w*$/;var ne=e=>Jr.test(e),O=e=>e===void 0,v=(e,s,r)=>{if(!s||!N(e))return r;const i=ne(s)?[s]:ue(s);if(i.some(u=>je.includes(u)))return r;const l=i.reduce((u,o)=>p(u)?void 0:u[o],e);return O(l)||l===e?O(e[s])?r:e[s]:l},re=e=>typeof e=="boolean",G=e=>typeof e=="function",k=(e,s,r)=>{let i=-1;const l=ne(s)?[s]:ue(s),u=l.length,o=u-1;for(;++i<u;){const c=l[i];let m=r;if(i!==o){const E=e[c];m=N(E)||Array.isArray(E)?E:isNaN(+l[i+1])?{}:[]}if(je.includes(c))return;e[c]=m,e=e[c]}};const Qr=I.createContext(null);Qr.displayName="HookFormControlContext";var Xr=(e,s,r,i=!0)=>{const l={};for(const u in e)Object.defineProperty(l,u,{get:()=>{const o=u;return s._proxyFormState[o]!==X.all&&(s._proxyFormState[o]=!i||X.all),e[o]}});return l};const et=Te?I.useLayoutEffect:I.useEffect;var rt=e=>{const s=e.constructor&&e.constructor.prototype;return N(s)&&s.hasOwnProperty("isPrototypeOf")},Me=e=>p(e)||!He(e);const lr=(e,s)=>s.length===0&&!Array.isArray(e)&&!rt(e);function Q(e,s,r=new WeakMap){if(e===s)return!0;if(Me(e)||Me(s))return Object.is(e,s);if(te(e)&&te(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),l=Object.keys(s);if(i.length!==l.length)return!1;if(lr(e,i)||lr(s,l))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const u=r.get(e);if(u&&u.has(s))return!0;if(u)u.add(s);else{const o=new WeakSet;o.add(s),r.set(e,o)}for(const o of i){const c=e[o];if(!(o in s))return!1;if(o!=="ref"){const m=s[o];if(te(c)&&te(m)||(N(c)||Array.isArray(c))&&(N(m)||Array.isArray(m))?!Q(c,m,r):!Object.is(c,m))return!1}}return!0}function tt(e){const s=I.useRef(!1),r=I.useRef(!1),i=I.useRef(void 0),l=I.useRef(0);l.current++,r.current;const u=I.useCallback((c,m,E)=>{if(c&&(s.current||r.current&&l.current>1)){const T=m();Q(i.current,T)||E(T)}s.current=!0},[]),o=I.useCallback((c,m)=>{c&&(i.current=C(m()))},[]);return{resyncIfNeeded:u,snapshot:o}}var M=e=>typeof e=="string",st=(e,s,r,i,l)=>M(e)?(i&&s.watch.add(e),v(r,e,l)):Array.isArray(e)?e.map(u=>(i&&s.watch.add(u),v(r,u,v(l,u)))):(i&&(s.watchAll=!0),r),De=e=>({isOnSubmit:!e||e===X.onSubmit,isOnBlur:e===X.onBlur,isOnChange:e===X.onChange,isOnAll:e===X.all,isOnTouch:e===X.onTouched}),Ue=(e,s,r)=>{if(r)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Ve=(e,s,r,i)=>{for(const l of r||Object.keys(e)){if(l==="_f")continue;const u=r?v(e,l):e[l];if(u){const{_f:o}=u;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],l)&&!i)return!0;if(o.ref&&s(o.ref,o.name)&&!i)return!0;if(Ve(u,s))break}else if((N(u)||Array.isArray(u))&&Ve(u,s))break}}};var ur=(e,s,r)=>{const i=v(e,r),l=Array.isArray(i)?i:[];return k(l,Dr,s[r]),k(e,r,l),e},B=e=>N(e)&&!Object.keys(e).length,ke=e=>{if(!Te)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},ze=e=>e.type==="radio",Oe=e=>e instanceof RegExp,Ye=(e,s,r,i,l)=>s?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[i]:l||!0}}:{};const fr={value:!1,isValid:!1},cr={value:!0,isValid:!0};var xr=e=>{if(!Array.isArray(e))return fr;if(e.length>1){const r=e.filter(i=>i&&i.checked&&!i.disabled).map(i=>i.value);return{value:r,isValid:!!r.length}}const s=e[0];return!s||!s.checked||s.disabled?fr:!s.attributes||!("value"in s.attributes)||O(s.value)||s.value===""?cr:{value:s.value,isValid:!0}};const dr={isValid:!1,value:null};var kr=e=>Array.isArray(e)?e.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,dr):dr;function yr(e,s,r="validate"){if(M(e)||Array.isArray(e)&&e.every(M)||re(e)&&!e)return{type:r,message:M(e)?e:"",ref:s}}var le=e=>N(e)&&!Oe(e)?e:{value:e,message:""},hr=async(e,s,r,i,l,u)=>{const{ref:o,refs:c,required:m,maxLength:E,minLength:T,min:H,max:j,pattern:$,validate:A,name:F,valueAsNumber:b,mount:fe}=e._f,w=v(r,F);if(!fe||s.has(F))return{};const ee=c?c[0]:o,P=D=>{if(l&&ee.reportValidity){const x=re(D)?"":D||"";c?c.forEach(R=>R.setCustomValidity(x)):ee.setCustomValidity(x),ee.reportValidity()}},S={},ce=ze(o),be=me(o),Ae=ce||be,ae=(b||Se(o))&&O(o.value)&&O(w)||ke(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,se=Ye.bind(null,F,i,S),Fe=(D,x,R,W=J.maxLength,K=J.minLength)=>{const q=D?x:R;S[F]={type:D?W:K,message:q,ref:o,...se(D?W:K,q)}};if(u?!Array.isArray(w)||!w.length:m&&(!Ae&&(ae||p(w))||re(w)&&!w||be&&!xr(c).isValid||ce&&!kr(c).isValid)){const{value:D,message:x}=M(m)?{value:!!m,message:m}:le(m);if(D&&(S[F]={type:J.required,message:x,ref:ee,...se(J.required,x)},!i))return P(x),S}if(!ae&&(!p(H)||!p(j))){let D,x;const R=le(j),W=le(H);if(!p(w)&&!te(w)&&!isNaN(w)){const K=o.valueAsNumber||w&&+w;p(R.value)||(D=K>R.value),p(W.value)||(x=K<W.value)}else{const K=o.valueAsDate||new Date(w),q=ye=>new Date(new Date().toDateString()+" "+ye),we=o.type=="time",Y=o.type=="week";M(R.value)&&w&&(D=we?q(w)>q(R.value):Y?w>R.value:K>new Date(R.value)),M(W.value)&&w&&(x=we?q(w)<q(W.value):Y?w<W.value:K<new Date(W.value))}if((D||x)&&(Fe(!!D,R.message,W.message,J.max,J.min),!i))return P(S[F].message),S}if((E||T)&&!ae&&(M(w)||u&&Array.isArray(w))){const D=le(E),x=le(T),R=!p(D.value)&&w.length>+D.value,W=!p(x.value)&&w.length<+x.value;if((R||W)&&(Fe(R,D.message,x.message),!i))return P(S[F].message),S}if($&&!ae&&M(w)){const{value:D,message:x}=le($);if(Oe(D)&&!w.match(D)&&(S[F]={type:J.pattern,message:x,ref:o,...se(J.pattern,x)},!i))return P(x),S}if(A){if(G(A)){const D=await A(w,r),x=yr(D,ee);if(x&&(S[F]={...x,...se(J.validate,x.message)},!i))return P(x.message),S}else if(N(A)){let D={};for(const x in A){if(!B(D)&&!i)break;const R=yr(await A[x](w,r),ee,x);R&&(D={...R,...se(x,R.message)},P(R.message),i&&(S[F]=D))}if(!B(D)&&(S[F]={ref:ee,...D},!i))return S}}const de=S[F];return P(de?de.message:!0),S},xe=e=>Array.isArray(e)?e:[e],Or=e=>Array.isArray(e)?e.filter(Boolean):[];function it(e,s){const r=s.length-1;let i=0;for(;i<r;){if(p(e)){e=void 0;break}e=e[s[i]],i++}return e}function nt(e){for(const s in e)if(e.hasOwnProperty(s)&&!O(e[s]))return!1;return!0}function U(e,s){if(M(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const r=Array.isArray(s)?s:ne(s)?[s]:ue(s);if(r.some(o=>je.includes(String(o))))return e;const i=r.length===1?e:it(e,r),l=r.length-1,u=r[l];return i&&delete i[u],l!==0&&(N(i)&&B(i)||Array.isArray(i)&&nt(i))&&U(e,r.slice(0,-1)),e}const at=I.createContext(null);at.displayName="HookFormContext";var gr=()=>{let e=[];return{get observers(){return e},next:l=>{for(const u of e)u.next&&u.next(l)},subscribe:l=>(e.push(l),{unsubscribe:()=>{e=e.filter(u=>u!==l)}}),unsubscribe:()=>{e=[]}}};function Sr(e,s){const r={};for(const i in e)if(e.hasOwnProperty(i)){const l=e[i],u=s[i];if(l&&N(l)&&u){const o=Sr(l,u);N(o)&&(r[i]=o)}else e[i]&&(r[i]=u)}return r}const vr=(e,s)=>e!==null&&He(e)&&Object.prototype.hasOwnProperty.call(e,s);var ot=(e,s)=>{if(!s)return!1;let r=e;for(const i of ne(s)?[s]:ue(s)){if(!vr(r,i))return vr(e,s);r=r[i]}return!0},Tr=e=>e.type==="select-multiple",lt=e=>ze(e)||me(e),Pe=e=>ke(e)&&e.isConnected;function _r(e){return Array.isArray(e)||N(e)}function Rr(e,s,r="",i=[]){for(const l in e){const u=r?`${r}.${l}`:l,o=e[l];_r(o)&&_r(v(s,u))?Rr(o,s,u,i):i.push(u)}return i}var ut=e=>{for(const s in e)if(G(e[s]))return!0;return!1};function Cr(e){return Array.isArray(e)||N(e)&&!ut(e)}function Lr(e){return!!(e&&"_f"in e)}function Ir(e){return Array.isArray(e)?!e.some(s=>!O(s)):!Object.keys(e).length}function Be(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function $e(e,s={},r){for(const i in e){const l=e[i],u=r&&r[i];Cr(l)&&(!Array.isArray(l)||!Lr(u))?(s[i]=Array.isArray(l)?[]:{},$e(l,s[i],u),Ir(s[i])&&Be(s,i)):O(l)||(s[i]=!0)}return s}function ie(e,s,r,i){r||(r=$e(s,{},i));for(const l in e){const u=e[l],o=i&&i[l];Cr(u)&&(!Array.isArray(u)||!Lr(o))?(O(s)||Me(r[l])?r[l]=$e(u,Array.isArray(u)?[]:{},o):ie(u,p(s)?{}:s[l],r[l],o),Ir(r[l])&&Be(r,l)):Q(u,s[l])?Be(r,l):r[l]=!0}return r}var ft=(e,s)=>{const r=s.split("."),i=[];let l=r[0];for(let u=1;u<r.length;l+="."+r[u++])!isNaN(+r[u])&&e.has(l)&&i.push(`${l}.${r[u]}`);return i},Nr=(e,{valueAsNumber:s,valueAsDate:r,setValueAs:i})=>O(e)?e:s?e===""?NaN:e&&+e:r&&M(e)?new Date(e):i?i(e):e;function Vr(e){const s=e.ref;return Se(s)?s.files:ze(s)?kr(e.refs).value:Tr(s)?[...s.selectedOptions].map(({value:r})=>r):me(s)?xr(e.refs).value:Nr(s.value,e)}var ct=(e,s,r,i)=>{const l={};for(const u of e){const o=v(s,u);o&&k(l,u,o._f)}return{criteriaMode:r,names:[...e],fields:l,shouldUseNativeValidation:i}},_e=e=>O(e)?e:Oe(e)?e.source:N(e)?Oe(e.value)?e.value.source:e.value:e;const mr="AsyncFunction";var dt=e=>{if(!e||!e.validate)return!1;if(G(e.validate))return e.validate.constructor.name===mr;if(N(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===mr)return!0}return!1},yt=e=>e.mount&&(e.required||!O(e.required)&&e.required!==!1||!O(e.min)||!O(e.max)||!O(e.maxLength)||!O(e.minLength)||e.pattern||e.validate);function br(e,s,r){const i=v(e,r);if(i||ne(r))return{error:i,name:r};const l=r.split(".");for(;l.length;){const u=l.join("."),o=v(s,u),c=v(e,u);if(o&&!Array.isArray(o)&&r!==u)return{name:r};if(c&&c.type)return{name:u,error:c};if(c&&c.root&&c.root.type)return{name:`${u}.root`,error:c.root};l.pop()}return{name:r}}var ht=(e,s,r,i)=>{r(e);const l=Object.keys(e).filter(u=>u!=="name");return!l.length||i&&l.length>=Object.keys(s).length||l.find(u=>s[u]===(!i||X.all))},gt=(e,s,r)=>!e||!s||e===s||xe(e).some(i=>i&&(r?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),vt=(e,s,r,i,l)=>l.isOnAll?!1:!r&&l.isOnTouch?!(s||e):(r?i.isOnBlur:l.isOnBlur)?!e:(r?i.isOnChange:l.isOnChange)?e:!0,_t=(e,s)=>{const r=v(e,s);!Or(r).length&&!r?.root&&U(e,s)};const Vt={mode:X.onSubmit,reValidateMode:X.onChange,shouldFocusError:!0},pe="form",mt=(e,s)=>{for(const r in e)r in s||delete e[r];Object.assign(e,s)},Ur={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function bt(e={}){let s={...Vt,...e},r={...C(Ur),isLoading:G(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},l=N(s.defaultValues)||N(s.values)?C(s.defaultValues||s.values)||{}:{},u=s.shouldUnregister?{}:C(l),o={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const m={},E={};let T=0,H=De(s.mode),j=De(s.reValidateMode);const $={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},A={...$};let F={...A};const b={array:gr(),state:gr()};let fe=0;const w=s.criteriaMode===X.all,ee=(t,a)=>n=>{clearTimeout(E[t]),E[t]=setTimeout(a,n)},P=async t=>{if(!o.keepIsValid&&!s.disabled&&(A.isValid||F.isValid||t)){const a=++fe;let n;s.resolver?(n=B((await R()).errors),a===fe&&S()):n=await q({fields:i,onlyCheckValid:!0,eventType:oe.VALID}),a===fe&&n!==r.isValid&&b.state.next({isValid:n})}},S=(t,a)=>{!s.disabled&&(A.isValidating||A.validatingFields||F.isValidating||F.validatingFields)&&((t||c.mount).forEach(n=>{n&&(a?k(r.validatingFields,n,a):U(r.validatingFields,n))}),b.state.next({validatingFields:r.validatingFields,isValidating:!B(r.validatingFields)}))},ce=()=>{r.dirtyFields=ie(l,u,void 0,i)},be=(t,a=[],n,f,d=!0,y=!0)=>{if(f&&n&&!s.disabled){o.action=!0;const h=v(i,t);if(o.actionArrayLengths.has(t)||o.actionArrayLengths.set(t,Array.isArray(h)?h.length:0),y&&Array.isArray(h)){const V=n(h,f.argA,f.argB);d&&k(i,t,V)}const g=v(r.errors,t);if(y&&Array.isArray(g)){const V=g.root,L=n(g,f.argA,f.argB)||g;V&&(L.root=V),d&&k(r.errors,t,L),_t(r.errors,t)}const _=v(r.touchedFields,t);if((A.touchedFields||F.touchedFields)&&y&&Array.isArray(_)){const V=n(_,f.argA,f.argB);d&&k(r.touchedFields,t,V)}(A.dirtyFields||F.dirtyFields)&&ce(),b.state.next({name:t,isDirty:Y(t,a),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else k(u,t,a)},Ae=(t,a)=>{k(r.errors,t,a),r.errors={...r.errors},b.state.next({errors:r.errors})},ae=t=>{r.errors=t,b.state.next({errors:r.errors,isValid:!1})},se=t=>{const a=ne(t)?[t]:ue(t);let n=u,f=l;for(let d=0;d<a.length-1;d++){const y=a[d];if(n=p(n)?n:n[y],f=p(f)?f:f[y],n===null&&f!==null)return!0}return!1},Fe=t=>{if(!o.actionArrayLengths.size)return!1;const a=ne(t)?[t]:ue(t);let n=u,f="",d=-1,y=0;for(let h=0;h<a.length;h++){if(p(n))return!1;const g=a[h];if(f=f?`${f}.${g}`:g,Array.isArray(n)&&+g>=n.length)return d===-1?!1:h===d?+g<y:!0;o.actionArrayLengths.has(f)&&(d=h+1,y=o.actionArrayLengths.get(f)),n=n[g]}return!1},de=(t,a,n,f)=>{const d=v(i,t);if(d){if(se(t)||Fe(t))return;const y=O(v(u,t)),h=v(u,t,O(n)?v(l,t):n);O(h)||f&&f.defaultChecked||a?k(u,t,a?h:Vr(d._f)):Re(t,h),o.mount&&!o.action&&(P(),y&&r.isDirty&&(A.isDirty||F.isDirty)&&(Y()||(r.isDirty=!1,b.state.next({...r}))),e.shouldUnregister&&y&&!O(v(u,t))&&Ue(t,c)&&(o.watch=!0))}},D=(t,a,n,f,d)=>{let y=!1,h=!1;const g={name:t};if(!s.disabled||f===!0){if(!n||f){const _=Q(v(l,t),a);(A.isDirty||F.isDirty)&&(h=r.isDirty,r.isDirty=g.isDirty=!_||Y(),y=h!==g.isDirty),h=!!v(r.dirtyFields,t),_!==r.isDirty?mt(r.dirtyFields,ie(l,u,void 0,i)):_?U(r.dirtyFields,t):k(r.dirtyFields,t,!0),g.dirtyFields=r.dirtyFields,y=y||(A.dirtyFields||F.dirtyFields)&&h!==!_}if(n){const _=v(r.touchedFields,t);_||(k(r.touchedFields,t,n),g.touchedFields=r.touchedFields,y=y||(A.touchedFields||F.touchedFields)&&_!==n)}y&&d&&b.state.next(g)}return y?g:{}},x=(t,a,n,f)=>{const d=v(r.errors,t),y=(A.isValid||F.isValid)&&re(a)&&r.isValid!==a;if(s.delayError&&n?(m[t]=ee(t,()=>Ae(t,n)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t],n?k(r.errors,t,n):U(r.errors,t),r.errors={...r.errors}),(n?!Q(d,n):d)||!B(f)||y){const h={...f,...y&&re(a)?{isValid:a}:{},errors:r.errors,name:t};b.state.next(h)}},R=async t=>(S(t,!0),await s.resolver(u,s.context,ct(t||c.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),W=async t=>{const{errors:a}=await R(t);if(S(t),t){for(const n of t){const f=v(a,n);f?c.array.has(n)&&N(f)&&!Object.keys(f).some(d=>!Number.isNaN(Number(d)))?ur(r.errors,{[n]:f},n):k(r.errors,n,f):U(r.errors,n)}r.errors={...r.errors}}else r.errors=a;return a},K=async({name:t,eventType:a})=>{if(e.validate){const n=await e.validate({formValues:u,formState:r,name:t,eventType:a});if(N(n))for(const f in n){const d=n[f];d&&Ee(`${pe}.${f}`,{message:M(d.message)?d.message:"",type:d.type||J.validate})}else M(n)||!n?Ee(pe,{message:n||"",type:J.validate}):Xe(pe);return n}return!0},q=async({fields:t,onlyCheckValid:a,name:n,eventType:f,context:d={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(d.runRootValidation=!0,!await K({name:n,eventType:f})&&(d.valid=!1,a)))return d.valid;for(const y in t){const h=t[y];if(h){const{_f:g,..._}=h;if(g){const V=c.array.has(g.name),L=h._f&&dt(h._f),z=A.validatingFields||A.isValidating||F.validatingFields||F.isValidating;L&&z&&S([g.name],!0);const Z=await hr(h,c.disabled,u,w,s.shouldUseNativeValidation&&!a,V);if(L&&z&&S([g.name]),Z[g.name]&&(d.valid=!1,a)||(!a&&(v(Z,g.name)?V?ur(r.errors,Z,g.name):k(r.errors,g.name,Z[g.name]):U(r.errors,g.name)),e.shouldUseNativeValidation&&Z[g.name]))break}!B(_)&&await q({context:d,onlyCheckValid:a,fields:_,name:y,eventType:f})}}return d.valid},we=()=>{for(const t of c.unMount){const a=v(i,t);a&&(a._f.refs?a._f.refs.every(n=>!Pe(n)):!Pe(a._f.ref))&&Le(t)}c.unMount=new Set},Y=(t,a)=>(t&&a&&k(u,t,a),!Q(o.mount?u:l,l)),ye=(t,a,n)=>st(t,c,{...o.mount?u:O(a)||M(t)?l:a},n,a),Pr=t=>Or(v(o.mount?u:l,t,s.shouldUnregister?v(l,t,[]):[])),Re=(t,a,n={},f=!1,d=!1,y=!1)=>{const h=v(i,t);let g=a;if(h){const _=h._f;_&&(!_.disabled&&k(u,t,Nr(a,_)),g=ke(_.ref)&&p(a)?"":a,Tr(_.ref)?[..._.ref.options].forEach(V=>V.selected=g.includes(V.value)):_.refs?me(_.ref)?_.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(g)?V.checked=!!g.find(L=>L===V.value):V.checked=g===V.value||!!g)}):_.refs.forEach(V=>V.checked=V.value===g):Se(_.ref)?_.ref.value="":(_.ref.value=g,!_.ref.type&&!d&&!y&&b.state.next({name:t,values:f?u:C(u)})))}(n.shouldDirty||n.shouldTouch)&&D(t,g,n.shouldTouch,n.shouldDirty,!d),n.shouldValidate&&Ce(t,{delayError:n.delayError})},Ge=(t,a,n,f=!1,d=!1,y=!1)=>{c.array.has(t)&&b.array.next({name:t,values:f?u:C(u)});for(const h in a){if(!a.hasOwnProperty(h))continue;const g=a[h],_=t+"."+h,V=v(i,_);(c.array.has(t)||N(g)||V&&!V._f)&&!te(g)?Ge(_,g,n,f,d,y):Re(_,g,n,f,d,y)}},Ke=(t,a,n,f,d=!1)=>{const y=v(i,t),h=c.array.has(t),g=f?a:C(a),_=v(u,t),V=Q(_,g);if(V||k(u,t,g),h)b.array.next({name:t,values:f?u:C(u)}),(A.isDirty||A.dirtyFields||F.isDirty||F.dirtyFields)&&n.shouldDirty&&(ce(),d||b.state.next({name:t,dirtyFields:r.dirtyFields,isDirty:Y(t,g)}));else{const L=Array.isArray(g)&&!g.length||B(g),z=!V&&!d;!y||y._f||p(g)||L?Re(t,g,n,f,d,z):Ge(t,g,n,f,d,z)}if(!V&&!d){const L=Ue(t,c),z=f?u:C(u);if(b.state.next({...L&&r,name:o.mount||L?t:void 0,values:z}),!h)for(const Z of ft(c.array,t))b.state.next({name:Z,values:z})}},he=(t,a,n={})=>Ke(t,a,n,!1),pr=(t,a={})=>{const n=G(t)?t(u):t;if(!Q(u,n)){u={...u,...n};for(const f of c.mount)ot(n,f)&&Ke(f,v(n,f),a,!0,!0);b.state.next({...r,name:void 0,type:void 0,...T?{values:u}:{}}),a.shouldValidate&&P()}},Ze=async t=>{o.mount=!0;const a=t.target;let n=a.name,f=!0;const d=v(i,n),y=h=>{f=Number.isNaN(h)||te(h)&&isNaN(h.getTime())||Q(h,v(u,n,h))};if(d){let h,g;const _=a.type?Vr(d._f):Gr(t),V=t.type===oe.BLUR||t.type===oe.FOCUS_OUT,L=!yt(d._f)&&!e.validate&&!s.resolver&&!v(r.errors,n)&&!d._f.deps,z=L||vt(V,v(r.touchedFields,n),r.isSubmitted,j,H),Z=Ue(n,c,V);if(k(u,n,C(_)),V){if(!a||!a.readOnly){d._f.onBlur&&d._f.onBlur(t);const ve=m[n];ve&&ve(0)}}else d._f.onChange&&d._f.onChange(t);const ge=D(n,_,V),zr=!B(ge)||Z;if(!V&&b.state.next({name:n,type:t.type,...T?{values:C(u)}:{}}),z)return(!L||!r.isValid)&&(A.isValid||F.isValid)&&(s.mode==="onBlur"?V&&P():V||P()),zr&&b.state.next({name:n,...Z?{}:ge});if(!s.resolver&&e.validate&&await K({name:n,eventType:t.type}),!V&&Z&&b.state.next({...r}),s.resolver){const{errors:ve}=await R([n]);if(S([n]),y(_),!f){!B(ge)&&b.state.next(ge);return}const Yr=br(r.errors,i,n),or=br(ve,i,Yr.name||n);h=or.error,n=or.name,g=B(ve)}else S([n],!0),h=(await hr(d,c.disabled,u,w,s.shouldUseNativeValidation))[n],S([n]),y(_),f&&(h?g=!1:(A.isValid||F.isValid)&&(g=await q({fields:i,onlyCheckValid:!0,name:n,eventType:t.type})));f&&(d._f.deps&&(!Array.isArray(d._f.deps)||d._f.deps.length>0)&&Ce(d._f.deps),x(n,g,h,ge))}},Je=(t,a)=>{if(v(r.errors,a)&&t.focus)return t.focus(),1},Ce=async(t,a={})=>{let n,f;const d=xe(t);if(s.resolver){const y=await W(O(t)?t:d);n=B(y),f=t?!d.some(h=>v(y,h)):n}else t?(f=(await Promise.all(d.map(async y=>{const h=v(i,y);return await q({fields:h&&h._f?{[y]:h}:h,eventType:oe.TRIGGER})}))).every(Boolean),!(!f&&!r.isValid)&&P()):f=n=await q({fields:i,name:t,eventType:oe.TRIGGER});if(a.delayError&&s.delayError&&M(t)){const y=v(r.errors,t);y?(U(r.errors,t),m[t]=ee(t,()=>Ae(t,y)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t])}if(a.shouldTouch)for(const y of t?d:c.mount)!c.array.has(y)&&k(r.touchedFields,y,!0);return b.state.next({...!M(t)||(A.isValid||F.isValid)&&n!==r.isValid?{}:{name:t},...s.resolver||!t?{isValid:n}:{},...a.shouldTouch&&(A.touchedFields||F.touchedFields)?{touchedFields:r.touchedFields}:{},errors:r.errors}),a.shouldFocus&&!f&&Ve(i,Je,t?d:c.mount),f},Mr=(t,a)=>{let n={...o.mount?u:l};return a&&(n=Sr(a.dirtyFields?r.dirtyFields:r.touchedFields,n)),O(t)?n:M(t)?v(n,t):t.map(f=>v(n,f))},Br=t=>O(t)?{...r.errors}:M(t)?v(r.errors,t):t.map(a=>v(r.errors,a)),Qe=(t,a)=>{const n=a||r,f=v(n.errors,t);return{invalid:!!f,isDirty:!!v(n.dirtyFields,t),error:f,isValidating:!!v(r.validatingFields,t),isTouched:!!v(n.touchedFields,t)}},Xe=t=>{const a=t?xe(t):void 0;a?.forEach(n=>U(r.errors,n)),a?a.forEach(n=>{b.state.next({name:n,errors:r.errors})}):(r.errors={},b.state.next({errors:r.errors}))},Ee=(t,a,n)=>{const f=(v(i,t,{_f:{}})._f||{}).ref,d=v(r.errors,t)||{},{ref:y,message:h,type:g,..._}=d;k(r.errors,t,{..._,...a,ref:f}),b.state.next({name:t,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&f&&f.focus&&f.focus()},$r=(t,a)=>{if(G(t)){T++;const{unsubscribe:n}=b.state.subscribe({next:d=>"values"in d&&t(d.values||ye(void 0,a),d)});let f=!1;return{unsubscribe:()=>{f||(f=!0,T--,n())}}}return ye(t,a,!0)},er=t=>{var a;const n=!!(!((a=t.formState)===null||a===void 0)&&a.values);n&&T++;const{unsubscribe:f}=b.state.subscribe({next:y=>{if(gt(t.name,y.name,t.exact)&&ht(y,t.formState||A,nr,t.reRenderRoot)){const h={...u};t.callback({values:h,...r,...y,defaultValues:l})}}});if(!n)return f;let d=!1;return()=>{d||(d=!0,T--,f())}},Wr=t=>(o.mount=!0,F={...F,...t.formState},er({...t,formState:{...$,...t.formState}})),Le=(t,a={})=>{for(const n of t?xe(t):c.mount)c.mount.delete(n),c.array.delete(n),a.keepValue||(U(i,n),U(u,n)),!a.keepError&&U(r.errors,n),!a.keepDirty&&U(r.dirtyFields,n),!a.keepTouched&&U(r.touchedFields,n),!a.keepIsValidating&&U(r.validatingFields,n),!s.shouldUnregister&&!a.keepDefaultValue&&U(l,n);T&&b.state.next({values:C(u)}),b.state.next({...r,...a.keepDirty?{}:{isDirty:Y()}}),!a.keepIsValid&&P()},rr=({disabled:t,name:a})=>{if(re(t)&&o.mount||t||c.disabled.has(a)){const d=c.disabled.has(a)!==!!t;t?c.disabled.add(a):c.disabled.delete(a),d&&o.mount&&!o.action&&P()}},Ie=(t,a={})=>{let n=v(i,t);const f=re(a.disabled)||re(s.disabled),d=!c.registerName.has(t)&&n&&n._f&&!n._f.mount;return k(i,t,{...n||{},_f:{...n&&n._f?n._f:{ref:{name:t}},name:t,mount:!0,...a}}),c.mount.add(t),n&&!d?rr({disabled:re(a.disabled)?a.disabled:s.disabled,name:t}):de(t,!0,a.value),{...f?{disabled:a.disabled||s.disabled}:{},...s.progressive?{required:!!a.required,min:_e(a.min),max:_e(a.max),minLength:_e(a.minLength),maxLength:_e(a.maxLength),pattern:_e(a.pattern)}:{},name:t,onChange:Ze,onBlur:Ze,ref:y=>{if(y){c.registerName.add(t),Ie(t,a),c.registerName.delete(t),n=v(i,t);const h=O(y.value)&&y.querySelectorAll&&y.querySelectorAll("input,select,textarea")[0]||y,g=lt(h),_=n._f.refs||[];if(g?_.find(L=>L===h):h===n._f.ref)return;const V={...n._f};g?(V.refs=[..._.filter(Pe),h,...Array.isArray(v(l,t))?[{}]:[]],V.ref={type:h.type,name:t}):(V.ref=h,delete V.refs),k(i,t,{_f:V}),de(t,!1,void 0,h)}else n=v(i,t,{}),n._f&&(n._f.mount=!1),(s.shouldUnregister||a.shouldUnregister)&&!(Zr(c.array,t)&&o.action)&&c.unMount.add(t)}}},Ne=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ve(i,Je,c.mount),qr=t=>{re(t)&&(b.state.next({disabled:t}),Ve(i,(a,n)=>{const f=v(i,n);f&&(a.disabled=f._f.disabled||t,Array.isArray(f._f.refs)&&f._f.refs.forEach(d=>{d.disabled=f._f.disabled||t}))},0,!1))},tr=(t,a)=>async n=>{let f,d;n&&(n.preventDefault&&n.preventDefault(),n.persist&&n.persist());let y=C(u);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:h,values:g}=await R();S(),r.errors=h,y=C(g)}else await q({fields:i,eventType:oe.SUBMIT});if(c.disabled.size)for(const h of c.disabled)U(y,h);if(U(r.errors,Dr),B(r.errors)){b.state.next({errors:{}});try{f=await t(y,n)}catch(h){d=h}}else a&&await a({...r.errors},n),Ne(),setTimeout(Ne);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(r.errors)&&!d,submitCount:r.submitCount+1,errors:r.errors}),d)throw d;return f},Hr=(t,a={})=>{v(i,t)&&(O(a.defaultValue)?he(t,C(v(l,t))):(he(t,a.defaultValue),k(l,t,C(a.defaultValue))),a.keepTouched||U(r.touchedFields,t),a.keepDirty||(U(r.dirtyFields,t),r.isDirty=a.defaultValue?Y(t,C(v(l,t))):Y()),a.keepError||(U(r.errors,t),P()),b.state.next({...r}))},sr=(t,a={})=>{const n=t?C(t):l,f=C(n),d=B(t),y=f,h=i;if(a.keepDefaultValues||(l=n),!a.keepValues){if(a.keepDirtyValues){const g=new Set([...c.mount,...Rr(ie(l,u,void 0,h),r.dirtyFields)]);for(const _ of g){const V=v(r.dirtyFields,_),L=v(u,_),z=v(y,_);V&&!O(L)?k(y,_,L):!V&&!O(z)&&he(_,z)}}else{if(Te&&O(t))for(const g of c.mount){const _=v(i,g);if(_&&_._f){const V=Array.isArray(_._f.refs)?_._f.refs[0]:_._f.ref;if(ke(V)){const L=V.closest("form");if(L){L.reset();break}}}}if(a.keepFieldsRef)for(const g of c.mount)he(g,v(y,g));else i={}}if(s.shouldUnregister){if(u=a.keepDefaultValues?C(l):{},a.keepFieldsRef)for(const g of c.mount)k(u,g,v(y,g))}else u=C(y);b.array.next({values:{...y}}),b.state.next({name:void 0,type:void 0,values:{...y}})}c={mount:a.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!A.isValid||!!a.keepIsValid||!!a.keepDirtyValues||!s.shouldUnregister&&!B(y),o.watch=!!s.shouldUnregister,o.keepIsValid=!!a.keepIsValid,o.action=!1,o.actionArrayLengths.clear(),a.keepErrors||(r.errors={}),b.state.next({submitCount:a.keepSubmitCount?r.submitCount:0,isDirty:d?!1:a.keepDirty?r.isDirty:a.keepValues?Y():!!(a.keepDefaultValues&&!Q(t,l)),isSubmitted:a.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:d?{}:a.keepDirtyValues?a.keepDefaultValues&&u?ie(l,u,void 0,h):r.dirtyFields:a.keepDefaultValues&&t?ie(l,t,void 0,h):a.keepDirty?r.dirtyFields:{},touchedFields:a.keepTouched?r.touchedFields:{},errors:a.keepErrors?r.errors:{},isSubmitSuccessful:a.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:l})},ir=(t,a)=>sr(G(t)?t(u):t,{...s.resetOptions,...a}),jr=(t,a={})=>{const n=v(i,t),f=n&&n._f;if(f){const d=f.refs?f.refs[0]:f.ref;d.focus&&setTimeout(()=>{d.focus(),a.shouldSelect&&G(d.select)&&d.select()})}},nr=t=>{const{name:a,type:n,values:f,...d}=t;r={...r,...d}};b.state.subscribe({next:nr});const ar={control:{register:Ie,unregister:Le,getFieldState:Qe,handleSubmit:tr,setError:Ee,_subscribe:er,_runSchema:R,_updateIsValidating:S,_focusError:Ne,_getWatch:ye,_getDirty:Y,_setValid:P,_setFieldArray:be,_setDisabledField:rr,_setErrors:ae,_getFieldArray:Pr,_reset:sr,_resetDefaultValues:()=>G(s.defaultValues)&&s.defaultValues().then(t=>{ir(t,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:we,_disableForm:qr,_subjects:b,_proxyFormState:A,get _fields(){return i},get _formValues(){return u},get _state(){return o},set _state(t){o=t},get _defaultValues(){return l},get _names(){return c},set _names(t){c=t},get _formState(){return r},get _options(){return s},set _options(t){s={...s,...t},H=De(s.mode),j=De(s.reValidateMode)}},subscribe:Wr,trigger:Ce,register:Ie,handleSubmit:tr,watch:$r,setValue:he,setValues:pr,getValues:Mr,getErrors:Br,reset:ir,resetField:Hr,resetDefaultValues:(t,a={})=>{if(l=C(t),!a.keepDirty){const n=ie(l,u,void 0,i);r.dirtyFields=n,r.isDirty=!B(n)}a.keepIsValid||P(),b.state.next({...r,defaultValues:l})},clearErrors:Xe,unregister:Le,setError:Ee,setFocus:jr,getFieldState:Qe};return{...ar,formControl:ar}}function kt(e={}){const s=I.useRef(void 0),r=I.useRef(void 0),i=I.useRef(e.formControl),[l,u]=I.useState(()=>({...C(Ur),isLoading:G(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:G(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:l},e.defaultValues&&!G(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:E,...T}=bt(e);s.current={...T,formState:l}}const o=s.current.control;o._options=e;const{resyncIfNeeded:c,snapshot:m}=tt();return et(()=>{const E=()=>({...o._formState,defaultValues:o._defaultValues});c(!0,E,u);const T=o._subscribe({formState:o._proxyFormState,callback:()=>u({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return u(H=>({...H,isReady:!0})),o._formState.isReady=!0,()=>{T(),m(!0,E)}},[o,c,m]),I.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),I.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),I.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),I.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),I.useEffect(()=>{if(o._proxyFormState.isDirty){const E=o._getDirty();E!==l.isDirty&&o._subjects.state.next({isDirty:E})}},[o,l.isDirty]),I.useEffect(()=>{var E;e.values&&!Q(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((E=o._options.resetOptions)===null||E===void 0)&&E.keepIsValid||o._setValid(),r.current=e.values,u(T=>({...T}))):o._resetDefaultValues()},[o,e.values]),I.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=I.useMemo(()=>Xr(l,o),[o,l]),s.current}const Ar=(e,s,r)=>{if(e&&"reportValidity"in e){const i=v(r,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},We=(e,s)=>{for(const r in s.fields){const i=s.fields[r];i&&i.ref&&"reportValidity"in i.ref?Ar(i.ref,r,e):i&&i.refs&&i.refs.forEach(l=>Ar(l,r,e))}},Fr=(e,s)=>{s.shouldUseNativeValidation&&We(e,s);const r={};for(const i in e){const l=v(s.fields,i),u=Object.assign(e[i]||{},{ref:l&&l.refs?l.refs[0]:l&&l.ref});if(At(s.names||Object.keys(e),i)){const o=Object.assign({},v(r,i));k(o,"root",u),k(r,i,o)}else k(r,i,u)}return r},At=(e,s)=>{const r=wr(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>wr(i).match(`^${r}\\.\\d+`))};function wr(e){return e.replace(/\[(\d+)]/g,".$1").replace(/[[\]]/g,"")}function qe(){return qe=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},qe.apply(null,arguments)}function Er(e,s){try{var r=e()}catch(i){return s(i)}return r&&r.then?r.then(void 0,s):r}function Ft(e,s){for(var r=Object.create(null);e.length;){var i=e[0],l=i.code,u=i.message,o=i.path.join(".");if(!r[o])if("unionErrors"in i){var c,m,E=i.unionErrors.reduce(function(j,$){return $.errors.length<j.errors.length?$:j}).errors[0];r[o]={message:(c=E?.message)!=null?c:u,type:(m=E?.code)!=null?m:l}}else r[o]={message:u,type:l};if("unionErrors"in i&&i.unionErrors.forEach(function(j){return j.errors.forEach(function($){return e.push($)})}),s){var T=r[o].types,H=T&&T[i.code];r[o]=Ye(o,s,r,l,H?[].concat(H,i.message):i.message)}e.shift()}return r}function wt(e,s){for(var r=Object.create(null),i=function(){var l=e[0],u=l.code,o=l.message,c=l.path.join(".");if(!r[c])if(l.code==="invalid_union"&&l.errors.length>0){var m,E,T=l.errors.reduce(function($,A){return A.length<$.length?A:$})[0];r[c]={message:(m=T?.message)!=null?m:o,type:(E=T?.code)!=null?E:u}}else r[c]={message:o,type:u};if(l.code==="invalid_union"&&l.errors.forEach(function($){return $.forEach(function(A){return e.push(qe({},A,{path:[].concat(l.path,A.path)}))})}),s){var H=r[c].types,j=H&&H[l.code];r[c]=Ye(c,s,r,u,j?[].concat(j,l.message):l.message)}e.shift()};e.length;)i();return r}function Ot(e,s,r){if(r===void 0&&(r={}),(function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){function o(m){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):m}}var c=e;return r.mode==="sync"?o(c.parse(i,s)):Promise.resolve(c.parseAsync(i,s)).then(o)},function(o){if((function(c){var m;return!(c==null||(m=c._zod)==null||(m=m.traits)==null||!m.has("$ZodError"))})(o))return{values:{},errors:Fr(wt(o.issues,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_def"in i&&typeof i._def=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(o){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):o}})},function(o){if((function(c){return Array.isArray(c?.issues)})(o))return{values:{},errors:Fr(Ft(o.errors,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}export{Ot as a,kt as u};
@@ -21,7 +21,7 @@
21
21
  </script>
22
22
  <link rel="icon" href="/mark.svg" type="image/svg+xml" />
23
23
  <title>Snagset</title>
24
- <script type="module" crossorigin src="/assets/index-Bvmz5Xph.js"></script>
24
+ <script type="module" crossorigin src="/assets/index-DtF8YHqn.js"></script>
25
25
  <link rel="stylesheet" crossorigin href="/assets/index-DAgnfv_E.css">
26
26
  </head>
27
27
  <body>
@@ -1,4 +1,4 @@
1
- const Me="Snagset",H="snagset",T="snagset.v1",Ze="Snagset",Pe="Snag",Ie="Snags",Ue={root:"data-snag-root"},j=e=>Ue[e],Be={anchor:"data-snag-anchor",ignore:"data-snag-ignore",mask:"data-snag-mask",nomask:"data-snag-nomask",src:"data-snag-src",component:"data-snag-component"},A=e=>Be[e],We={mask:"snag-mask",block:"snag-block"},q=e=>We[e],d={font:"--snag-font",accent:"--snag-accent",onAccent:"--snag-onAccent",bg:"--snag-bg",fg:"--snag-fg",muted:"--snag-muted",border:"--snag-border",radius:"--snag-radius",shadow:"--snag-shadow",z:"--snag-z",motion:"--snag-motion",surface:"--snag-surface",sunken:"--snag-sunken",hover:"--snag-hover",focus:"--snag-focus",disabled:"--snag-disabled",statusOpen:"--snag-status-open",statusProgress:"--snag-status-progress",statusReview:"--snag-status-review",statusResolved:"--snag-status-resolved",anchorOrphan:"--snag-anchor-orphan",tbH:"--snag-tb-h",dockW:"--snag-dock-w",kb:"--snag-kb",thumbX:"--snag-thumb-x",thumbW:"--snag-thumb-w"},He=e=>`var(${d[e]})`,C={query:["snag_t","snag_off","snag_debug","snag_theme"],fragment:["snag_k"]},je="snag:disclosure:v1",qe="snag:identity",Fe="data-snag-theme",Ve={session:e=>`snag:session:${e}`,identity:qe,threads:(e,t)=>`snag:threads:${e}:${t}`,seen:(e,t)=>`snag:seen:${e}:${t}`,counts:e=>`snag:counts:${e}`,draft:(e,t)=>`snag:draft:${e}:${t}`,outbox:e=>`snag:outbox:${e}`,mode:"snag:mode",handoff:"snag:handoff",seenCoach:"snag:seen-coach",disclosure:je},z={database:"snag:blobs",store:"blobs"},Ke={route:"snagset:route"};function Xe(e,t){let n="Unknown";/Edg\//.test(e)?n="Edge":/OPR\//.test(e)?n="Opera":/Firefox\//.test(e)?n="Firefox":/Chrome\//.test(e)?n="Chrome":/Safari\//.test(e)&&(n="Safari");let r="";if(/Macintosh/.test(e)?r="macOS":/Windows/.test(e)?r="Windows":/iPhone|iPad/.test(e)?r="iOS":/Android/.test(e)?r="Android":/Linux/.test(e)&&(r="Linux"),t?.brands?.length){const s=t.brands.find(i=>!/Not.?A.?Brand/i.test(i.brand));s&&(n=s.brand)}t?.platform&&(r=t.platform);let a=!1;try{a=typeof matchMedia=="function"&&matchMedia("(pointer:coarse)").matches}catch{}const o=t?.mobile??(a||/Mobi|iPhone|Android/.test(e))?"Mobile":"Desktop";return{browser:n,os:r,device:o}}const Ye={ok:{status:"ok"},release:{status:"disabled",reason:"Screenshots are not available in this release."},"config-off":{status:"disabled",reason:"Screenshots are switched off for this project."},"feature-off":{status:"disabled",reason:"Screenshots are switched off for this project."},"reviewer-removed":{status:"disabled",reason:"You removed the screenshot before sending."},"csp-blocked":{status:"failed",reason:"Your Content-Security-Policy blocks data: images, so no screenshot could be taken."},"engine-load-failed":{status:"failed",reason:"The screenshot engine could not be loaded."},"engine-failed":{status:"failed",reason:"The screenshot engine failed on this page."},timeout:{status:"timeout",reason:"The screenshot timed out."},tainted:{status:"tainted",reason:"A cross-origin image made the page canvas unreadable."},"scope-forced":{status:"ok",reason:"The page was too large to capture in full; captured the area around your pin."},"masking-failed":{status:"failed",reason:"Masking could not be verified, so the screenshot was discarded."},navigated:{status:"failed",reason:"The page changed while the screenshot was being taken."}},Qe={disabled:"Console and network capture is off for this project.",truncated:"Earlier console and network entries were dropped to fit the buffer."};function v(e={}){const t=Ye[e.screenshot??"release"],n=e.breadcrumbs??"disabled",r=[];t.reason&&r.push(t.reason),n!=="ok"&&r.push(Qe[n]);const a={screenshot:t.status,breadcrumbs:n,reasons:r};return e.blindSpots?.length&&(a.blindSpots=e.blindSpots),e.droppedCategories?.length&&(a.droppedCategories=e.droppedCategories),e.maskedCount!==void 0&&e.maskedCount>0&&(a.maskedCount=e.maskedCount),a}function Je(e,t,n,r=!1){const a=e.capture?.breadcrumbs??"disabled";if(n){e.capture=v({screenshot:"config-off",breadcrumbs:a});return}if(r&&!t){e.capture=v({screenshot:"reviewer-removed",breadcrumbs:a});return}t&&(e.capture=v({screenshot:t.situation,breadcrumbs:a,...t.blindSpots.length?{blindSpots:t.blindSpots}:{},...t.maskedCount>0?{maskedCount:t.maskedCount}:{}}))}const Ge="pass(?:word|wd)?|pwd|secret|token|api[_-]?key|apikey|auth(?:orization)?|credential|session|sid|cookie|jwt|bearer|otp|mfa|totp|cvv|cvc|ssn|nino|iban|card(?:[_-]?number)?|account[_-]?number|private[_-]?key|signature|client[_-]?secret|refresh[_-]?token|access[_-]?token",et=new RegExp(`(["'\`]?)(?<![A-Za-z0-9])(?:${Ge})[\\w-]*\\b\\1?\\s*[:=]\\s*(?:(["'\`])((?:\\\\.|(?!\\2)[^\\\\])*)\\2|([^\\s,;&}\\])]{3,}))`,"gi"),tt=/^(?:Bearer|Basic|Digest|Negotiate|Token)$/i,nt=(e,t,n,r,a,o,s)=>{if(!n&&tt.test(a)&&s.slice(o+e.length).startsWith(" [redacted]")||(n?r:a).startsWith("[redacted"))return e;const i=n?`${n}${r}${n}`:a;return e.slice(0,e.length-i.length)+(n?`${n}[redacted]${n}`:"[redacted]")},F=/data:[a-z0-9.+-]*\/?[a-z0-9.+-]*;base64,[A-Za-z0-9+/=]{16,}/gi,V=/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{0,}/g,K=/\b(sk-[A-Za-z0-9]+-[A-Za-z0-9_-]{20,}|sk-ant-[A-Za-z0-9_-]{20,}|sk-[A-Za-z0-9]{20,}|(sk|pk|rk)_(live|test)_[A-Za-z0-9]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|glpat-[A-Za-z0-9_-]{16,}|xox[baprs]-[A-Za-z0-9-]{10,}|xapp-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|ASIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|ya29\.[A-Za-z0-9_-]{20,}|SG\.[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{30,}|dop_v1_[a-f0-9]{40,}|shpat_[a-f0-9]{30,}|sbp_[a-f0-9]{30,}|hf_[A-Za-z0-9]{30,}|nvapi-[A-Za-z0-9_-]{20,})\b/g,rt=/\b(Bearer|Basic|Digest|Negotiate|Token)\s+[A-Za-z0-9._~+/=-]{8,}/gi,X=/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z]{2,24})+\b/g,R=/\b(?:\d[ -]?){12,18}\d\b/g,Y=/\b(?=[A-Za-z0-9+/]*[a-z])(?=[A-Za-z0-9+/]*[A-Z])(?=[A-Za-z0-9+/]*\d)[A-Za-z0-9+/]{40,}={0,2}\b/g,Q=/\b[0-9a-f]{32,}\b/gi,J=/\b(?=[A-Za-z0-9_-]*[a-z])(?=[A-Za-z0-9_-]*[A-Z])(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{40,}\b/g,G=/\b[a-z][a-z0-9]{1,15}(?:_[a-z0-9]{1,15}){0,2}_(?=[A-Za-z0-9_-]*[A-Z])(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{24,}\b/g,ee=/\b[a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:[^\s/@]+@/gi,at=/^(?=[A-Za-z0-9_~.+/=-]*[a-z])(?=[A-Za-z0-9_~.+/=-]*[A-Z])(?=[A-Za-z0-9_~.+/=-]*\d)[A-Za-z0-9_~.+/=-]{24,}$/;function y(e,t){e.lastIndex=0;const n=e.test(t);return e.lastIndex=0,n}function te(e){const t=e.replace(/[ -]/g,"");if(t.length<13||t.length>19)return!1;let n=0,r=!1;for(let a=t.length-1;a>=0;a--){let o=t.charCodeAt(a)-48;r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function ot(e){R.lastIndex=0;for(const t of e.matchAll(R))if(te(t[0]))return!0;return!1}function E(e){let t=e;return t=t.replace(F,"data:[redacted]"),t=t.replace(rt,"$1 [redacted]"),t=t.replace(et,nt),t=t.replace(V,"[redacted:jwt]"),t=t.replace(K,"[redacted:key]"),t=t.replace(G,"[redacted:key]"),t=t.replace(ee,"[redacted:url-cred]@"),t=t.replace(X,"[redacted:email]"),t=t.replace(R,n=>te(n)?"[redacted:card]":n),t=t.replace(J,n=>`[redacted:b64:${n.length}]`),t=t.replace(Y,n=>`[redacted:b64:${n.length}]`),t=t.replace(Q,n=>`[redacted:hex:${n.length}]`),t}const st=C.query,it=C.fragment;function ne(e,t=[]){let n;try{const r=globalThis.location?.href;n=new URL(e,r)}catch{return E(e)}n.username="",n.password="";for(const r of[...n.searchParams.keys()]){if(it.includes(r)){n.searchParams.set(r,"[redacted]");continue}if(st.includes(r))continue;if(!t.includes(r)){n.searchParams.set(r,"[redacted]");continue}const a=n.searchParams.get(r)??"";E(a)!==a&&n.searchParams.set(r,"[redacted]")}return n.hash&&n.hash.length>1&&(n.hash=t.includes("#")?n.hash:"#[redacted]"),E(n.toString().replace(/%5Bredacted%5D/gi,"[redacted]"))}function O(e){return e.length>120?!0:y(X,e)||y(V,e)||y(K,e)||y(Q,e)||y(Y,e)||y(F,e)||y(J,e)||y(G,e)||y(ee,e)||at.test(e)||ot(e)}const ct=/^eyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/,lt=/^[a-f0-9]{32,}$/i,dt=/^(?=[A-Za-z0-9_-]{24,}$)(?=.*[A-Za-z])(?=.*\d)[A-Za-z0-9_-]+$/,ut="[redacted]";function ht(e){return e.includes("/")?e.split("/").map(t=>ct.test(t)||lt.test(t)||dt.test(t)?ut:t).join("/"):e}const ft=/\/index\.(html?|php)$/i;function mt(e){if(!e.startsWith("/"))return e;let t=e.replace(ft,"/");return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t.toLowerCase()}function re(e){try{const t=e.querySelector(`meta[name="${Ke.route}"]`)?.getAttribute("content")?.trim();return!t||t.length>512||!t.startsWith("/")?null:t}catch{return null}}const gt=[/^utm_/,/^(gclid|gbraid|wbraid|fbclid|msclkid|ttclid|twclid|igshid|yclid|li_fat_id)$/,/^(mc_cid|mc_eid|_hsenc|_hsmi|vero_id|oly_enc_id|oly_anon_id)$/,/^_vercel_/,/^__vercel_/,/^_rsc$/],pt=[...C.query,...C.fragment];function bt(e,t=[]){return pt.includes(e)||t.includes(e)?!0:gt.some(n=>n.test(e))}function wt(e,t={}){const n=t.significantQueryParams??[];if(n!=="*"&&n.length===0)return;let r;try{r=new URLSearchParams(e)}catch{return}const a={};for(const[o,s]of r)bt(o,t.ignoredQueryParams??[])||n!=="*"&&!n.includes(o)||(a[o]=s);return Object.keys(a).length>0?a:void 0}function ae(e,t){const n=e.length>4096?e.slice(0,4096):e,r=ne(n,t);return r.length<=2048?r:r.slice(0,2048)+`\u2026[+${r.length-2048}]`}function yt(e=location,t={}){const n=ht(e.pathname),r=t.routeOverride??(t.doc?re(t.doc):typeof document<"u"?re(document):null),a=wt(e.search??"",t.query);return{route:mt(r??n),pathname:n,...a?{query:a}:{},origin:e.origin}}function xt(){try{return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}function $t(e){const t=e.urlParamAllowList??[];let n;try{n=ae(location.href,t)}catch{try{n=ae(document.URL,t)}catch{n=E(location.origin+location.pathname)}}let r=innerWidth,a=innerHeight;(r===0||a===0)&&(r=document.documentElement.clientWidth,a=document.documentElement.clientHeight);let o={w:0,h:0};try{o={w:screen.width,h:screen.height}}catch{}const s=navigator.userAgent||"",i=navigator.userAgentData,l=i?{brands:(i.brands??[]).map(u=>({brand:u.brand,version:u.version})),platform:i.platform,mobile:i.mobile}:void 0,h={schemaVersion:T,url:n,page:e.page,viewport:{w:r,h:a,dpr:devicePixelRatio||1},screen:o,ua:s,derived:Xe(s,l),language:navigator.language||navigator.languages?.[0]||"en",prefersColorScheme:xt()?"dark":"light",timestamp:new Date().toISOString(),capture:v({breadcrumbs:e.breadcrumbs?.status??"disabled"})};return l&&(h.uaData=l),e.breadcrumbs&&e.breadcrumbs.status!=="disabled"&&(h.breadcrumbs=e.breadcrumbs.records),h}const At={product:Me,set:Ze,item:Pe,items:Ie};function oe(e){return(t,n)=>(e[t]??"").replace(/\{(\w+)\}/g,(r,a)=>{const o=n?.[a]??At[a];return o===void 0?r:String(o)})}const se=e=>new Intl.NumberFormat().format(e),ie=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)},ce={"where.anchored":"{label}","where.approximate":"position approximate \u2014 the page changed","where.orphaned":"moved \u2014 the element is gone","status.open":"Active","status.progress":"In progress","status.review":"In review","status.resolved":"Resolved","author.unknown":"Someone","label.image":"an image","label.link":"a link","label.button":"a button","label.tag":"the {tag}"},S=oe(ce),vt={"detail.details":"Anchor details","detail.hidden":"This element isn't visible right now \u2014 it may be inside a closed menu, tab, or accordion.","detail.orphaned":"The element this was pinned to has moved or gone \u2014 it was {label}.","detail.approximate":"The page changed since this was written, so the pin is close rather than exact \u2014 it points at {label}.","detail.unavailable":"Some of the matching steps couldn't load, so this was judged with the basic ones only.","detail.filedat":"Filed at {query}.","detail.openquery":"Open with original query","capture.agent":"{browser} \xB7 {os}","capture.agent.noos":"{browser}","capture.device":"{device} \xB7 {w}\xD7{h} @{dpr}x","capture.device.at1x":"{device} \xB7 {w}\xD7{h}"},Et={"export.title":"{product} \u2014 {origin}","export.summary.one":"1 comment, {unresolved} unresolved \xB7 exported {date}","export.summary.many":"{total} comments, {unresolved} unresolved \xB7 exported {date}","export.heading":"{n} \xB7 {key} \u2014 {status}","export.on":"On {label}","export.device":"Device","export.selector":"Selector","export.by":"By","export.nobody":"_(no comment)_","cursor.proxy":"Pick an element \u2014 Tab to move, Enter to comment","cursor.at":"{role}, {name}, {i} of {n}","cursor.here":"{role} {name}","export.screenshot":"Screenshot {key}","label.text":"\u201C{text}\u201D","hint.fine":"Click anything to comment \u2014 Esc when done","hint.coarse":"Tap anything to comment","highlight.chip":"{tag} \xB7 {name} \xB7 {w}\xD7{h}","highlight.chip.unnamed":"{tag} \xB7 {w}\xD7{h}"},f=oe({...ce,...vt,...Et}),St=[`[${A("mask")}]`,`.${q("mask")}`,`.${q("block")}`].join(", ");function le(e,t){return O(t)||!!e.closest?.(St)}function de(e){const n=(e.innerText??e.textContent??"").slice(0,512).trim().replace(/\s+/g," ");if(n&&!le(e,n))return f("label.text",{text:n.length>52?n.slice(0,52)+"\u2026":n});const r=e.tagName.toLowerCase();return r==="img"?f("label.image"):r==="a"?f("label.link"):r==="button"?f("label.button"):f("label.tag",{tag:r})}function _t(e,t){const n=t.trim().replace(/\s+/g," ");return n&&!le(e,n)?f("label.text",{text:n.length>52?n.slice(0,52)+"\u2026":n}):de(e)}const ue={open:{colour:"#4f6ef7"},progress:{colour:"#f59e0b"},review:{colour:"#8b5cf6"},resolved:{colour:"#10b981"}},kt=e=>e in ue?S(`status.${e}`):e;class Tt extends Error{code;constructor(t,n){super(n??t),this.name="AdapterError",this.code=t}}function he(e,t){const{anchorPending:n,anchorReasons:r,screenshotBlob:a,...o}=e;return o.attachments?.length&&t?.size&&(o.attachments=o.attachments.map(s=>{const i=t.get(s.id);return i?{...s,url:i}:s})),o}function fe(e){const t=e.context,n=t?.derived,r=t?.viewport;if(!t||!n||!r)return"";const a=Math.round(r.dpr*100)/100,o=n.os?f("capture.agent",{browser:n.browser,os:n.os}):f("capture.agent.noos",{browser:n.browser}),s=a===1?f("capture.device.at1x",{device:n.device,w:r.w,h:r.h}):f("capture.device",{device:n.device,w:r.w,h:r.h,dpr:a});return`${o} \xB7 ${s}`}function Ct(e,t,n){const r=e.map(l=>he(l,n)),a=r.filter(l=>l.status!=="resolved").length,o=[],s=[`# ${f("export.title",{origin:t.origin})}`,"",f(r.length===1?"export.summary.one":"export.summary.many",{total:se(r.length),unresolved:se(a),date:ie(t.exportedAt)})],i=new Map;for(const l of r)i.set(l.route,[...i.get(l.route)??[],l]);for(const[l,h]of i)s.push("","---","",`## ${l}`),h.forEach((u,b)=>{const g=u.comments[0];s.push("",`### ${f("export.heading",{n:b+1,key:u.key,status:kt(u.status)})}`,"",`**${f("export.on",{label:u.anchor.label})}**`,...u.anchorState==="anchored"?[]:[f(`detail.${u.anchorState}`,{label:u.anchor.label})],...u.anchor.css?[`**${f("export.selector")}** \`${u.anchor.css}\``]:[],...fe(u)?[`**${f("export.device")}** ${fe(u)}`]:[],`**${f("export.by")}** ${g?.author.name??u.createdBy.name} \xB7 ${ie(u.createdAt)}`,"",g?.body??f("export.nobody"));for(const c of u.attachments??[])c.url.startsWith("data:")&&(s.push("",`![${f("export.screenshot",{key:u.key})}][${c.id}]`),o.push(`[${c.id}]: ${c.url}`));for(const c of u.comments.slice(1))s.push("",`- **${c.author.name}** \u2014 ${c.body??""}`)});return o.length&&s.push("","---","",...o),s.join(`
1
+ const Me="Snagset",H="snagset",T="snagset.v1",Ze="Snagset",Pe="Snag",Ie="Snags",Ue={root:"data-snag-root"},j=e=>Ue[e],Be={anchor:"data-snag-anchor",ignore:"data-snag-ignore",mask:"data-snag-mask",nomask:"data-snag-nomask",src:"data-snag-src",component:"data-snag-component"},A=e=>Be[e],We={mask:"snag-mask",block:"snag-block"},q=e=>We[e],d={font:"--snag-font",accent:"--snag-accent",onAccent:"--snag-onAccent",bg:"--snag-bg",fg:"--snag-fg",muted:"--snag-muted",border:"--snag-border",radius:"--snag-radius",shadow:"--snag-shadow",z:"--snag-z",motion:"--snag-motion",surface:"--snag-surface",sunken:"--snag-sunken",hover:"--snag-hover",focus:"--snag-focus",disabled:"--snag-disabled",statusOpen:"--snag-status-open",statusProgress:"--snag-status-progress",statusReview:"--snag-status-review",statusResolved:"--snag-status-resolved",anchorOrphan:"--snag-anchor-orphan",tbH:"--snag-tb-h",dockW:"--snag-dock-w",kb:"--snag-kb",thumbX:"--snag-thumb-x",thumbW:"--snag-thumb-w"},He=e=>`var(${d[e]})`,C={query:["snag_t","snag_off","snag_debug","snag_theme"],fragment:["snag_k"]},je="snag:disclosure:v1",qe="snag:identity",Fe="data-snag-theme",Ve={session:e=>`snag:session:${e}`,silent:e=>`snag:silent:${e}`,identity:qe,threads:(e,t)=>`snag:threads:${e}:${t}`,seen:(e,t)=>`snag:seen:${e}:${t}`,counts:e=>`snag:counts:${e}`,draft:(e,t)=>`snag:draft:${e}:${t}`,outbox:e=>`snag:outbox:${e}`,mode:"snag:mode",handoff:"snag:handoff",seenCoach:"snag:seen-coach",disclosure:je},z={database:"snag:blobs",store:"blobs"},Ke={route:"snagset:route"};function Xe(e,t){let n="Unknown";/Edg\//.test(e)?n="Edge":/OPR\//.test(e)?n="Opera":/Firefox\//.test(e)?n="Firefox":/Chrome\//.test(e)?n="Chrome":/Safari\//.test(e)&&(n="Safari");let r="";if(/Macintosh/.test(e)?r="macOS":/Windows/.test(e)?r="Windows":/iPhone|iPad/.test(e)?r="iOS":/Android/.test(e)?r="Android":/Linux/.test(e)&&(r="Linux"),t?.brands?.length){const s=t.brands.find(i=>!/Not.?A.?Brand/i.test(i.brand));s&&(n=s.brand)}t?.platform&&(r=t.platform);let a=!1;try{a=typeof matchMedia=="function"&&matchMedia("(pointer:coarse)").matches}catch{}const o=t?.mobile??(a||/Mobi|iPhone|Android/.test(e))?"Mobile":"Desktop";return{browser:n,os:r,device:o}}const Ye={ok:{status:"ok"},release:{status:"disabled",reason:"Screenshots are not available in this release."},"config-off":{status:"disabled",reason:"Screenshots are switched off for this project."},"feature-off":{status:"disabled",reason:"Screenshots are switched off for this project."},"reviewer-removed":{status:"disabled",reason:"You removed the screenshot before sending."},"csp-blocked":{status:"failed",reason:"Your Content-Security-Policy blocks data: images, so no screenshot could be taken."},"engine-load-failed":{status:"failed",reason:"The screenshot engine could not be loaded."},"engine-failed":{status:"failed",reason:"The screenshot engine failed on this page."},timeout:{status:"timeout",reason:"The screenshot timed out."},tainted:{status:"tainted",reason:"A cross-origin image made the page canvas unreadable."},"scope-forced":{status:"ok",reason:"The page was too large to capture in full; captured the area around your pin."},"masking-failed":{status:"failed",reason:"Masking could not be verified, so the screenshot was discarded."},navigated:{status:"failed",reason:"The page changed while the screenshot was being taken."}},Qe={disabled:"Console and network capture is off for this project.",truncated:"Earlier console and network entries were dropped to fit the buffer."};function v(e={}){const t=Ye[e.screenshot??"release"],n=e.breadcrumbs??"disabled",r=[];t.reason&&r.push(t.reason),n!=="ok"&&r.push(Qe[n]);const a={screenshot:t.status,breadcrumbs:n,reasons:r};return e.blindSpots?.length&&(a.blindSpots=e.blindSpots),e.droppedCategories?.length&&(a.droppedCategories=e.droppedCategories),e.maskedCount!==void 0&&e.maskedCount>0&&(a.maskedCount=e.maskedCount),a}function Je(e,t,n,r=!1){const a=e.capture?.breadcrumbs??"disabled";if(n){e.capture=v({screenshot:"config-off",breadcrumbs:a});return}if(r&&!t){e.capture=v({screenshot:"reviewer-removed",breadcrumbs:a});return}t&&(e.capture=v({screenshot:t.situation,breadcrumbs:a,...t.blindSpots.length?{blindSpots:t.blindSpots}:{},...t.maskedCount>0?{maskedCount:t.maskedCount}:{}}))}const Ge="pass(?:word|wd)?|pwd|secret|token|api[_-]?key|apikey|auth(?:orization)?|credential|session|sid|cookie|jwt|bearer|otp|mfa|totp|cvv|cvc|ssn|nino|iban|card(?:[_-]?number)?|account[_-]?number|private[_-]?key|signature|client[_-]?secret|refresh[_-]?token|access[_-]?token",et=new RegExp(`(["'\`]?)(?<![A-Za-z0-9])(?:${Ge})[\\w-]*\\b\\1?\\s*[:=]\\s*(?:(["'\`])((?:\\\\.|(?!\\2)[^\\\\])*)\\2|([^\\s,;&}\\])]{3,}))`,"gi"),tt=/^(?:Bearer|Basic|Digest|Negotiate|Token)$/i,nt=(e,t,n,r,a,o,s)=>{if(!n&&tt.test(a)&&s.slice(o+e.length).startsWith(" [redacted]")||(n?r:a).startsWith("[redacted"))return e;const i=n?`${n}${r}${n}`:a;return e.slice(0,e.length-i.length)+(n?`${n}[redacted]${n}`:"[redacted]")},F=/data:[a-z0-9.+-]*\/?[a-z0-9.+-]*;base64,[A-Za-z0-9+/=]{16,}/gi,V=/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{0,}/g,K=/\b(sk-[A-Za-z0-9]+-[A-Za-z0-9_-]{20,}|sk-ant-[A-Za-z0-9_-]{20,}|sk-[A-Za-z0-9]{20,}|(sk|pk|rk)_(live|test)_[A-Za-z0-9]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|glpat-[A-Za-z0-9_-]{16,}|xox[baprs]-[A-Za-z0-9-]{10,}|xapp-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|ASIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|ya29\.[A-Za-z0-9_-]{20,}|SG\.[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{30,}|dop_v1_[a-f0-9]{40,}|shpat_[a-f0-9]{30,}|sbp_[a-f0-9]{30,}|hf_[A-Za-z0-9]{30,}|nvapi-[A-Za-z0-9_-]{20,})\b/g,rt=/\b(Bearer|Basic|Digest|Negotiate|Token)\s+[A-Za-z0-9._~+/=-]{8,}/gi,X=/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z]{2,24})+\b/g,R=/\b(?:\d[ -]?){12,18}\d\b/g,Y=/\b(?=[A-Za-z0-9+/]*[a-z])(?=[A-Za-z0-9+/]*[A-Z])(?=[A-Za-z0-9+/]*\d)[A-Za-z0-9+/]{40,}={0,2}\b/g,Q=/\b[0-9a-f]{32,}\b/gi,J=/\b(?=[A-Za-z0-9_-]*[a-z])(?=[A-Za-z0-9_-]*[A-Z])(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{40,}\b/g,G=/\b[a-z][a-z0-9]{1,15}(?:_[a-z0-9]{1,15}){0,2}_(?=[A-Za-z0-9_-]*[A-Z])(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{24,}\b/g,ee=/\b[a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:[^\s/@]+@/gi,at=/^(?=[A-Za-z0-9_~.+/=-]*[a-z])(?=[A-Za-z0-9_~.+/=-]*[A-Z])(?=[A-Za-z0-9_~.+/=-]*\d)[A-Za-z0-9_~.+/=-]{24,}$/;function y(e,t){e.lastIndex=0;const n=e.test(t);return e.lastIndex=0,n}function te(e){const t=e.replace(/[ -]/g,"");if(t.length<13||t.length>19)return!1;let n=0,r=!1;for(let a=t.length-1;a>=0;a--){let o=t.charCodeAt(a)-48;r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function ot(e){R.lastIndex=0;for(const t of e.matchAll(R))if(te(t[0]))return!0;return!1}function E(e){let t=e;return t=t.replace(F,"data:[redacted]"),t=t.replace(rt,"$1 [redacted]"),t=t.replace(et,nt),t=t.replace(V,"[redacted:jwt]"),t=t.replace(K,"[redacted:key]"),t=t.replace(G,"[redacted:key]"),t=t.replace(ee,"[redacted:url-cred]@"),t=t.replace(X,"[redacted:email]"),t=t.replace(R,n=>te(n)?"[redacted:card]":n),t=t.replace(J,n=>`[redacted:b64:${n.length}]`),t=t.replace(Y,n=>`[redacted:b64:${n.length}]`),t=t.replace(Q,n=>`[redacted:hex:${n.length}]`),t}const st=C.query,it=C.fragment;function ne(e,t=[]){let n;try{const r=globalThis.location?.href;n=new URL(e,r)}catch{return E(e)}n.username="",n.password="";for(const r of[...n.searchParams.keys()]){if(it.includes(r)){n.searchParams.set(r,"[redacted]");continue}if(st.includes(r))continue;if(!t.includes(r)){n.searchParams.set(r,"[redacted]");continue}const a=n.searchParams.get(r)??"";E(a)!==a&&n.searchParams.set(r,"[redacted]")}return n.hash&&n.hash.length>1&&(n.hash=t.includes("#")?n.hash:"#[redacted]"),E(n.toString().replace(/%5Bredacted%5D/gi,"[redacted]"))}function O(e){return e.length>120?!0:y(X,e)||y(V,e)||y(K,e)||y(Q,e)||y(Y,e)||y(F,e)||y(J,e)||y(G,e)||y(ee,e)||at.test(e)||ot(e)}const ct=/^eyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/,lt=/^[a-f0-9]{32,}$/i,dt=/^(?=[A-Za-z0-9_-]{24,}$)(?=.*[A-Za-z])(?=.*\d)[A-Za-z0-9_-]+$/,ut="[redacted]";function ht(e){return e.includes("/")?e.split("/").map(t=>ct.test(t)||lt.test(t)||dt.test(t)?ut:t).join("/"):e}const ft=/\/index\.(html?|php)$/i;function mt(e){if(!e.startsWith("/"))return e;let t=e.replace(ft,"/");return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t.toLowerCase()}function re(e){try{const t=e.querySelector(`meta[name="${Ke.route}"]`)?.getAttribute("content")?.trim();return!t||t.length>512||!t.startsWith("/")?null:t}catch{return null}}const gt=[/^utm_/,/^(gclid|gbraid|wbraid|fbclid|msclkid|ttclid|twclid|igshid|yclid|li_fat_id)$/,/^(mc_cid|mc_eid|_hsenc|_hsmi|vero_id|oly_enc_id|oly_anon_id)$/,/^_vercel_/,/^__vercel_/,/^_rsc$/],pt=[...C.query,...C.fragment];function bt(e,t=[]){return pt.includes(e)||t.includes(e)?!0:gt.some(n=>n.test(e))}function wt(e,t={}){const n=t.significantQueryParams??[];if(n!=="*"&&n.length===0)return;let r;try{r=new URLSearchParams(e)}catch{return}const a={};for(const[o,s]of r)bt(o,t.ignoredQueryParams??[])||n!=="*"&&!n.includes(o)||(a[o]=s);return Object.keys(a).length>0?a:void 0}function ae(e,t){const n=e.length>4096?e.slice(0,4096):e,r=ne(n,t);return r.length<=2048?r:r.slice(0,2048)+`\u2026[+${r.length-2048}]`}function yt(e=location,t={}){const n=ht(e.pathname),r=t.routeOverride??(t.doc?re(t.doc):typeof document<"u"?re(document):null),a=wt(e.search??"",t.query);return{route:mt(r??n),pathname:n,...a?{query:a}:{},origin:e.origin}}function xt(){try{return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}function $t(e){const t=e.urlParamAllowList??[];let n;try{n=ae(location.href,t)}catch{try{n=ae(document.URL,t)}catch{n=E(location.origin+location.pathname)}}let r=innerWidth,a=innerHeight;(r===0||a===0)&&(r=document.documentElement.clientWidth,a=document.documentElement.clientHeight);let o={w:0,h:0};try{o={w:screen.width,h:screen.height}}catch{}const s=navigator.userAgent||"",i=navigator.userAgentData,l=i?{brands:(i.brands??[]).map(u=>({brand:u.brand,version:u.version})),platform:i.platform,mobile:i.mobile}:void 0,h={schemaVersion:T,url:n,page:e.page,viewport:{w:r,h:a,dpr:devicePixelRatio||1},screen:o,ua:s,derived:Xe(s,l),language:navigator.language||navigator.languages?.[0]||"en",prefersColorScheme:xt()?"dark":"light",timestamp:new Date().toISOString(),capture:v({breadcrumbs:e.breadcrumbs?.status??"disabled"})};return l&&(h.uaData=l),e.breadcrumbs&&e.breadcrumbs.status!=="disabled"&&(h.breadcrumbs=e.breadcrumbs.records),h}const At={product:Me,set:Ze,item:Pe,items:Ie};function oe(e){return(t,n)=>(e[t]??"").replace(/\{(\w+)\}/g,(r,a)=>{const o=n?.[a]??At[a];return o===void 0?r:String(o)})}const se=e=>new Intl.NumberFormat().format(e),ie=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)},ce={"where.anchored":"{label}","where.approximate":"position approximate \u2014 the page changed","where.orphaned":"moved \u2014 the element is gone","status.open":"Active","status.progress":"In progress","status.review":"In review","status.resolved":"Resolved","author.unknown":"Someone","label.image":"an image","label.link":"a link","label.button":"a button","label.tag":"the {tag}"},S=oe(ce),vt={"detail.details":"Anchor details","detail.hidden":"This element isn't visible right now \u2014 it may be inside a closed menu, tab, or accordion.","detail.orphaned":"The element this was pinned to has moved or gone \u2014 it was {label}.","detail.approximate":"The page changed since this was written, so the pin is close rather than exact \u2014 it points at {label}.","detail.unavailable":"Some of the matching steps couldn't load, so this was judged with the basic ones only.","detail.filedat":"Filed at {query}.","detail.openquery":"Open with original query","capture.agent":"{browser} \xB7 {os}","capture.agent.noos":"{browser}","capture.device":"{device} \xB7 {w}\xD7{h} @{dpr}x","capture.device.at1x":"{device} \xB7 {w}\xD7{h}"},Et={"export.title":"{product} \u2014 {origin}","export.summary.one":"1 comment, {unresolved} unresolved \xB7 exported {date}","export.summary.many":"{total} comments, {unresolved} unresolved \xB7 exported {date}","export.heading":"{n} \xB7 {key} \u2014 {status}","export.on":"On {label}","export.device":"Device","export.selector":"Selector","export.by":"By","export.nobody":"_(no comment)_","cursor.proxy":"Pick an element \u2014 Tab to move, Enter to comment","cursor.at":"{role}, {name}, {i} of {n}","cursor.here":"{role} {name}","export.screenshot":"Screenshot {key}","label.text":"\u201C{text}\u201D","hint.fine":"Click anything to comment \u2014 Esc when done","hint.coarse":"Tap anything to comment","highlight.chip":"{tag} \xB7 {name} \xB7 {w}\xD7{h}","highlight.chip.unnamed":"{tag} \xB7 {w}\xD7{h}"},f=oe({...ce,...vt,...Et}),St=[`[${A("mask")}]`,`.${q("mask")}`,`.${q("block")}`].join(", ");function le(e,t){return O(t)||!!e.closest?.(St)}function de(e){const n=(e.innerText??e.textContent??"").slice(0,512).trim().replace(/\s+/g," ");if(n&&!le(e,n))return f("label.text",{text:n.length>52?n.slice(0,52)+"\u2026":n});const r=e.tagName.toLowerCase();return r==="img"?f("label.image"):r==="a"?f("label.link"):r==="button"?f("label.button"):f("label.tag",{tag:r})}function _t(e,t){const n=t.trim().replace(/\s+/g," ");return n&&!le(e,n)?f("label.text",{text:n.length>52?n.slice(0,52)+"\u2026":n}):de(e)}const ue={open:{colour:"#4f6ef7"},progress:{colour:"#f59e0b"},review:{colour:"#8b5cf6"},resolved:{colour:"#10b981"}},kt=e=>e in ue?S(`status.${e}`):e;class Tt extends Error{code;constructor(t,n){super(n??t),this.name="AdapterError",this.code=t}}function he(e,t){const{anchorPending:n,anchorReasons:r,screenshotBlob:a,...o}=e;return o.attachments?.length&&t?.size&&(o.attachments=o.attachments.map(s=>{const i=t.get(s.id);return i?{...s,url:i}:s})),o}function fe(e){const t=e.context,n=t?.derived,r=t?.viewport;if(!t||!n||!r)return"";const a=Math.round(r.dpr*100)/100,o=n.os?f("capture.agent",{browser:n.browser,os:n.os}):f("capture.agent.noos",{browser:n.browser}),s=a===1?f("capture.device.at1x",{device:n.device,w:r.w,h:r.h}):f("capture.device",{device:n.device,w:r.w,h:r.h,dpr:a});return`${o} \xB7 ${s}`}function Ct(e,t,n){const r=e.map(l=>he(l,n)),a=r.filter(l=>l.status!=="resolved").length,o=[],s=[`# ${f("export.title",{origin:t.origin})}`,"",f(r.length===1?"export.summary.one":"export.summary.many",{total:se(r.length),unresolved:se(a),date:ie(t.exportedAt)})],i=new Map;for(const l of r)i.set(l.route,[...i.get(l.route)??[],l]);for(const[l,h]of i)s.push("","---","",`## ${l}`),h.forEach((u,b)=>{const g=u.comments[0];s.push("",`### ${f("export.heading",{n:b+1,key:u.key,status:kt(u.status)})}`,"",`**${f("export.on",{label:u.anchor.label})}**`,...u.anchorState==="anchored"?[]:[f(`detail.${u.anchorState}`,{label:u.anchor.label})],...u.anchor.css?[`**${f("export.selector")}** \`${u.anchor.css}\``]:[],...fe(u)?[`**${f("export.device")}** ${fe(u)}`]:[],`**${f("export.by")}** ${g?.author.name??u.createdBy.name} \xB7 ${ie(u.createdAt)}`,"",g?.body??f("export.nobody"));for(const c of u.attachments??[])c.url.startsWith("data:")&&(s.push("",`![${f("export.screenshot",{key:u.key})}][${c.id}]`),o.push(`[${c.id}]: ${c.url}`));for(const c of u.comments.slice(1))s.push("",`- **${c.author.name}** \u2014 ${c.body??""}`)});return o.length&&s.push("","---","",...o),s.join(`
2
2
  `)+`
3
3
  `}function zt(e,t,n){return JSON.stringify({schemaVersion:T,...t,threads:e.map(r=>he(r,n))},null,2)}function Nt(e,t,n,r){const a=n.exportedAt.slice(0,10);return e==="md"?{name:`${H}-${a}.md`,mime:"text/markdown",text:Ct(t,n,r)}:{name:`${H}-${a}.json`,mime:"application/json",text:zt(t,n,r)}}function Rt(e,t,n){const r=e.ownerDocument??e,a=URL.createObjectURL(new Blob([t.text],{type:`${t.mime};charset=utf-8`})),o=r.createElement("a");o.href=a,o.download=t.name,o.style.display="none",e.appendChild(o),o.dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!0,composed:!1})),o.remove(),n.setTimeout(()=>URL.revokeObjectURL(a),0)}let $=null;function Ot(){return $||($=new Promise((e,t)=>{let n;try{n=indexedDB.open(z.database,1)}catch(r){t(r);return}n.onupgradeneeded=()=>{n.result.createObjectStore(z.store).createIndex("project",["uid","env"])},n.onsuccess=()=>{n.result.onversionchange=()=>{n.result.close(),$=null},e(n.result)},n.onerror=()=>t(n.error??new Error("indexeddb-unavailable")),n.onblocked=()=>t(new Error("indexeddb-blocked"))}),$.catch(()=>{$=null}),$)}function D(e,t){return Ot().then(n=>new Promise((r,a)=>{const o=n.transaction(z.store,e),s=t(o.objectStore(z.store));o.oncomplete=()=>r(s.result),o.onerror=()=>a(o.error??s.error??new Error("indexeddb-error")),o.onabort=()=>{const i=o.error;i&&(i.name==="QuotaExceededError"||/quota/i.test(i.message??""))?a(new Tt("local_quota_exceeded")):a(i??new Error("indexeddb-abort"))}}))}async function me(e,t){const{blob:n,...r}=t,a={...r,bytes:await n.arrayBuffer(),type:n.type};await D("readwrite",o=>o.put(a,e))}function ge(e){return D("readonly",t=>t.get(e)).then(t=>{if(!t)return null;const{bytes:n,type:r,...a}=t;return{...a,blob:new Blob([n],{type:r})}})}function Dt(e){return D("readwrite",t=>t.delete(e)).then(()=>{})}function Lt(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>typeof r.result=="string"?t(r.result):n(new Error("read-failed")),r.onerror=()=>n(r.error??new Error("read-failed")),r.readAsDataURL(e)})}function Mt(e){const t=/^data:([^;,]+)?(;base64)?,(.*)$/s.exec(e);if(!t)throw new Error("not-a-data-uri");const n=t[1]??"application/octet-stream";if(!t[2])return new Blob([decodeURIComponent(t[3])],{type:n});const r=atob(t[3]),a=new Uint8Array(r.length);for(let o=0;o<r.length;o++)a[o]=r.charCodeAt(o);return new Blob([a],{type:n})}async function Zt(e){const t=e.flatMap(r=>r.attachments??[]).filter(r=>!/^https?:/i.test(r.url??"")),n=new Map;return t.length===0||await Promise.all(t.map(async r=>{const a=await ge(r.id).catch(()=>null);a&&n.set(r.id,await Lt(a.blob))})),n}async function Pt(e,t,n){const r=JSON.parse(e);if(r.schemaVersion!==T||!Array.isArray(r.threads))throw new Error(`not a ${T} archive`);const a=[];let o=0;for(const s of r.threads){if(!s.attachments?.length){a.push(s);continue}const i=[];for(const l of s.attachments)if(l.url.startsWith("data:")){const h=Mt(l.url);await me(l.id,{blob:h,uid:t,env:n,kind:l.kind,...l.width!==void 0?{width:l.width}:{},...l.height!==void 0?{height:l.height}:{},createdAt:Date.now()}),o++,i.push({...l,url:""})}else i.push(l);a.push({...s,attachments:i})}return localStorage.setItem(Ve.threads(t,n),JSON.stringify(a)),{threads:a.length,blobs:o}}function L(e){return e.getBoundingClientRect()}function pe(e){if(e.closest('[inert],[aria-hidden="true"]'))return!1;const t=e.checkVisibility;if(typeof t=="function")return t.call(e,{contentVisibilityAuto:!0,opacityProperty:!1,visibilityProperty:!0});const n=L(e);if(!(n.width>0||n.height>0||e.getClientRects().length>0))return!1;const a=e.ownerDocument?.defaultView;return a?a.getComputedStyle(e).visibility!=="hidden":!0}const be=`[${j("root")}]`;function we(e){const t=e.parentElement;return!t||t===e.ownerDocument.body||t===e.ownerDocument.documentElement||t.closest(be)?null:t}function ye(e){for(const t of e.children)if(!t.closest(be)&&pe(t))return t;return null}const xe=10;function $e(e){let t=e,n=0;for(;n++<xe;){const r=t.getRootNode();if(!(r instanceof ShadowRoot))break;t=r.host}return t}function It(e){const t=[];let n=e,r=0;for(;r++<xe;){const a=n.getRootNode();if(!(a instanceof ShadowRoot))break;n=a.host,t.unshift(n)}return t}const Ut=/[\u200B-\u200D\u2060\uFEFF]/gu,Bt=/[\s\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]+/gu,Wt=[[/[\u2018\u2019\u201A\u201B]/gu,"'"],[/[\u201C\u201D\u201E\u201F]/gu,'"'],[/[\u2010-\u2015\u2212]/gu,"-"],[/\u2026/gu,"..."],[/\u2044/gu,"/"]];function Ht(e){let t=e.normalize("NFC").replace(Ut,"");for(const[n,r]of Wt)t=t.replace(n,r);return t.replace(Bt," ").trim()}const jt=[A("anchor"),"data-testid","data-test-id","data-test","data-cy","data-qa","data-pw","data-automation-id"],qt=256,Ft=200,Vt=12;function Kt(e){for(const t of jt){const n=e.getAttribute(t);if(n)return{attr:t,value:n}}}function Xt(e,t=Vt){const n=[];let r=e;for(;r&&r.nodeType===1&&n.length<t;){const a=r.tagName.toLowerCase();if(a==="html")break;const o=r.parentElement;if(o){const s=[...o.children].filter(i=>i.tagName===r.tagName);n.push(s.length>1?`${a}:nth-of-type(${s.indexOf(r)+1})`:a)}else n.push(a);r=o}return n.reverse()}function Ae(e){const t=e.getAttribute("role");if(t)return t;const n=e.tagName.toLowerCase();if(n==="button")return"button";if(n==="a"&&e.hasAttribute("href"))return"link";if(n==="input"){const r=(e.getAttribute("type")??"text").toLowerCase();return r==="checkbox"||r==="radio"||r==="button"||r==="submit"?r==="submit"?"button":r:"textbox"}if(/^h[1-6]$/.test(n))return"heading";if(n==="nav")return"navigation";if(n==="img")return"img"}function M(e){const t=e.getAttribute("aria-label");if(t?.trim())return t.trim();const n=e.getAttribute("aria-labelledby");if(n){const o=n.split(/\s+/).map(s=>e.ownerDocument.getElementById(s)?.textContent??"").join(" ").trim();if(o)return o}const r=e.getAttribute("alt")??e.getAttribute("title");if(r?.trim())return r.trim();const a=(e.textContent??"").trim();return a?a.slice(0,qt):void 0}function Yt(e){const t=e.tagName.toLowerCase();return t==="img"?S("label.image"):t==="a"?S("label.link"):t==="button"?S("label.button"):S("label.tag",{tag:t})}function Qt(e){return e<480?"xs":e<768?"sm":e<1024?"md":e<1440?"lg":"xl"}function Jt(e,t={}){const n=$e(e),r=Kt(n),a=L(n),o=n.ownerDocument,s=o.defaultView?.scrollX??0,i=o.defaultView?.scrollY??0,l=Ht(n.textContent??"").slice(0,Ft),h={path:Xt(n),rect:{x:a.left+s,y:a.top+i,w:a.width,h:a.height},label:t.label??Yt(n)};r&&(h.testid=r.value),t.domid&&(h.domid=t.domid),t.css&&(h.css=t.css),t.hostPath?.length&&(h.hostPath=t.hostPath),t.xpath&&(h.xpath=t.xpath);const u=Ae(n);u&&(h.role=u);const b=M(n);b&&(h.accessibleName=b),l&&(h.text={exact:l}),t.point&&a.width>0&&a.height>0&&(h.offset={fx:ve((t.point.x-a.left)/a.width),fy:ve((t.point.y-a.top)/a.height)});const g=t.viewportWidth??o.defaultView?.innerWidth;return g&&(h.breakpoint=Qt(g)),h}const ve=e=>e<0?0:e>1?1:e,Gt='a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]),[role], h1,h2,h3,h4,h5,h6, img, video, figure, table, li,main, nav, header, footer, aside, section[aria-label], form, [data-testid]',en=`[${j("root")}]`;function Ee(e=document.body){return[...e.querySelectorAll(Gt)].filter(t=>!t.closest(en)&&pe(t))}function tn(e,t){const n=e.ownerDocument??document,r=n.createElement("button");r.type="button",r.className="snag-cursor-proxy",r.setAttribute("aria-label",f("cursor.proxy")),r.style.cssText="position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none",e.appendChild(r);let a=[],o=-1,s=null,i=null;const l=()=>i??a[o]??null;function h(c){const w=Ae(c),p=M(c),x=i?0:o+1;t.announce(i||!p?f("cursor.here",{role:w??c.tagName.toLowerCase(),name:p??""}):f("cursor.at",{role:w??c.tagName.toLowerCase(),name:p,i:x,n:a.length}))}function u(c){c&&(t.show(c),c.scrollIntoView({block:"nearest",behavior:"auto"}),h(c))}function b(c){i=null,a.length!==0&&(o=o<0?c===1?0:a.length-1:(o+c+a.length)%a.length,u(a[o]))}function g(c){const w=l();if(!w)return;const p=c==="out"?we(w):ye(w);if(!p)return;const x=a.indexOf(p);x>=0?(i=null,o=x):i=p,u(p)}return r.addEventListener("keydown",c=>{if(!(c.metaKey||c.ctrlKey||c.altKey))switch(c.key){case"Tab":case"ArrowDown":case"ArrowRight":c.preventDefault(),b(c.key==="Tab"&&c.shiftKey?-1:1);return;case"ArrowUp":case"ArrowLeft":c.preventDefault(),b(-1);return;case"[":c.preventDefault(),g("out");return;case"]":c.preventDefault(),g("in");return;case"Enter":case" ":{const w=l();if(!w)return;c.preventDefault();const p=w.getBoundingClientRect();t.pick(w,{x:p.left+p.width/2,y:p.top+p.height/2});return}}}),{engage(){a=Ee(n.body),o=-1,i=null,s=e.activeElement??n.activeElement,r.focus({preventScroll:!0})},release(){i=null,e.activeElement===r&&s?.focus?.(),s=null},destroy(){r.remove()}}}const m=Object.fromEntries(Object.keys(d).map(e=>[e,He(e)])),nn=Object.entries(ue).map(([e,t])=>` ${d[`status${e[0].toUpperCase()}${e.slice(1)}`]}:${t.colour};`).join(`
4
4
  `);`${m.font}${m.fg}${d.font}${d.accent}${d.bg}${d.fg}${d.muted}${d.border}${d.radius}${d.shadow}${d.z}${d.motion}${d.surface}${m.fg}${m.bg}${d.sunken}${m.fg}${m.bg}${d.hover}${m.fg}${m.bg}${d.onAccent}${d.focus}${m.accent}${m.fg}${d.disabled}${m.muted}${m.bg}${nn}${d.anchorOrphan}${Fe}${d.accent}${d.onAccent}${d.bg}${d.fg}${d.muted}${d.border}${d.shadow}${d.motion}${d.bg}${d.fg}${d.muted}${d.border}${d.accent}${d.onAccent}${d.surface}${d.sunken}${d.hover}${d.focus}${d.disabled}${d.shadow}${d.anchorOrphan}`;const Se={highlight:2,chip:4},_e=new WeakMap;function rn(e,t,n){let r=_e.get(e);if(r||_e.set(e,r=new Set),r.has(t))return;r.add(t);try{const s=new CSSStyleSheet;s.replaceSync(n),e.adoptedStyleSheets=[...e.adoptedStyleSheets,s];return}catch{}const o=(e.ownerDocument??document).createElement("style");o.setAttribute(`data-snag-${t}`,""),o.textContent=n,e.appendChild(o)}const an=` .snag-hl-layer{position:fixed;inset:0;pointer-events:none;z-index:${Se.highlight};contain:layout style;overflow:hidden}.snag-hl{position:absolute;box-sizing:border-box;border:2px solid ${m.accent};border-radius:3px;background:color-mix(in srgb,${m.accent} 12%,transparent);box-shadow:0 0 0 100vmax color-mix(in srgb,#000 4%,transparent);transition:top ${m.motion},left ${m.motion},width ${m.motion},height ${m.motion}}.snag-hl-chip{position:absolute;background:${m.accent};color:${m.onAccent};font:600 11px/1.5 ${m.font};padding:2px 7px;border-radius:4px;white-space:nowrap;max-width:min(48ch,90vw);overflow:hidden;text-overflow:ellipsis}.snag-hint{position:fixed;top:calc(12px + env(safe-area-inset-top));left:50%;transform:translateX(-50%);z-index:${Se.chip};pointer-events:none;background:${m.bg};color:${m.fg};border:1px solid ${m.border};box-shadow:${m.shadow};border-radius:999px;padding:7px 14px;font:500 12px/1 ${m.font};white-space:nowrap;max-width:calc(100vw - 24px);overflow:hidden;text-overflow:ellipsis}`;function on(e,t,n){const r=e.ownerDocument??document;rn(e,"highlight",an);const a=r.createElement("div");a.className="snag-hl-layer",a.hidden=!0;const o=r.createElement("div");o.className="snag-hl";const s=r.createElement("div");s.className="snag-hl-chip",a.append(o,s);const i=r.createElement("div");i.className="snag-hint",i.setAttribute("role","status"),i.hidden=!0,i.textContent=f(t?"hint.coarse":"hint.fine");let l;function h(g){const c=L(g);if(c.width<=0&&c.height<=0)return u();a.hidden=!1,o.style.left=`${c.left}px`,o.style.top=`${c.top}px`,o.style.width=`${c.width}px`,o.style.height=`${c.height}px`;const w=M(g),p=g.tagName.toLowerCase(),x=Math.round(c.width),W=Math.round(c.height);s.textContent=w?f("highlight.chip",{tag:p,name:w,w:x,h:W}):f("highlight.chip.unnamed",{tag:p,w:x,h:W});const Le=c.top>=22;s.style.top=Le?`${c.top-20}px`:`${c.bottom+4}px`,s.style.left=`${Math.max(2,c.left)}px`,t&&(clearTimeout(l),l=setTimeout(u,400))}function u(){a.hidden=!0}let b=null;return{show:h,clear:u,setActive(g){n&&(b??=tn(e,{...n,show:h}),g?b.engage():b.release()),g||u(),g?e.append(a,i):(a.remove(),i.remove()),i.hidden=!g},destroy(){clearTimeout(l),b?.destroy(),a.remove(),i.remove()}}}const sn=new Set(["role","name","aria-label","rel","href"]);function cn(e,t){let n=sn.has(e);n||=e.startsWith("data-")&&_(e);let r=_(t)&&t.length<100;return r||=t.startsWith("#")&&_(t.slice(1)),n&&r}function ln(e){return _(e)}function dn(e){return _(e)}function un(e){return!0}function ke(e,t){if(e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(e.tagName.toLowerCase()==="html")return"html";const n={root:document.body,idName:ln,className:dn,tagName:un,attr:cn,timeoutMs:1e3,seedMinLength:3,optimizedMinLength:2,maxNumberOfPathChecks:1/0},r=new Date,a={...n,...t},o=pn(a.root,n);let s,i=0;for(const h of hn(e,a,o)){if(new Date().getTime()-r.getTime()>a.timeoutMs||i>=a.maxNumberOfPathChecks){const b=mn(e,o);if(!b)throw new Error(`Timeout: Can't find a unique selector after ${a.timeoutMs}ms`);return k(b)}if(i++,I(h,o)){s=h;break}}if(!s)throw new Error("Selector was not found.");const l=[...Ne(s,e,a,o,r)];return l.sort(Z),l.length>0?k(l[0]):k(s)}function*hn(e,t,n){const r=[];let a=[],o=e,s=0;for(;o&&o!==n;){const i=fn(o,t);for(const l of i)l.level=s;if(r.push(i),o=o.parentElement,s++,a.push(...ze(r)),s>=t.seedMinLength){a.sort(Z);for(const l of a)yield l;a=[]}}a.sort(Z);for(const i of a)yield i}function _(e){if(/^[a-z\-]{3,}$/i.test(e)){const t=e.split(/-|[A-Z]/);for(const n of t)if(n.length<=2||/[^aeiou]{4,}/i.test(n))return!1;return!0}return!1}function fn(e,t){const n=[],r=e.getAttribute("id");r&&t.idName(r)&&n.push({name:"#"+CSS.escape(r),penalty:0});for(let s=0;s<e.classList.length;s++){const i=e.classList[s];t.className(i)&&n.push({name:"."+CSS.escape(i),penalty:1})}for(let s=0;s<e.attributes.length;s++){const i=e.attributes[s];t.attr(i.name,i.value)&&n.push({name:`[${CSS.escape(i.name)}="${CSS.escape(i.value)}"]`,penalty:2})}const a=e.tagName.toLowerCase();if(t.tagName(a)){n.push({name:a,penalty:5});const s=P(e,a);s!==void 0&&n.push({name:Ce(a,s),penalty:10})}const o=P(e);return o!==void 0&&n.push({name:gn(a,o),penalty:50}),n}function k(e){let t=e[0],n=t.name;for(let r=1;r<e.length;r++){const a=e[r].level||0;t.level===a-1?n=`${e[r].name} > ${n}`:n=`${e[r].name} ${n}`,t=e[r]}return n}function Te(e){return e.map(t=>t.penalty).reduce((t,n)=>t+n,0)}function Z(e,t){return Te(e)-Te(t)}function P(e,t){const n=e.parentNode;if(!n)return;let r=n.firstChild;if(!r)return;let a=0;for(;r&&(r.nodeType===Node.ELEMENT_NODE&&(t===void 0||r.tagName.toLowerCase()===t)&&a++,r!==e);)r=r.nextSibling;return a}function mn(e,t){let n=0,r=e;const a=[];for(;r&&r!==t;){const o=r.tagName.toLowerCase(),s=P(r,o);if(s===void 0)return;a.push({name:Ce(o,s),penalty:NaN,level:n}),r=r.parentElement,n++}if(I(a,t))return a}function gn(e,t){return e==="html"?"html":`${e}:nth-child(${t})`}function Ce(e,t){return e==="html"?"html":`${e}:nth-of-type(${t})`}function*ze(e,t=[]){if(e.length>0)for(let n of e[0])yield*ze(e.slice(1,e.length),t.concat(n));else yield t}function pn(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}function I(e,t){const n=k(e);switch(t.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return!0;default:return!1}}function*Ne(e,t,n,r,a){if(e.length>2&&e.length>n.optimizedMinLength)for(let o=1;o<e.length-1;o++){if(new Date().getTime()-a.getTime()>n.timeoutMs)return;const i=[...e];i.splice(o,1),I(i,r)&&r.querySelector(k(i))===t&&(yield i,yield*Ne(i,t,n,r,a))}}const bn=A("anchor").replace(/anchor$/,""),wn=[A("anchor"),"data-testid","data-test-id","data-test","data-cy","data-qa","data-pw","data-automation-id"],Re=new Set([...wn,"name","aria-label","role","type","itemprop"]),yn=new Set(["name","type","role","aria-label","itemprop","href","alt","lang"]),xn=[/^class$|^style$/,/^data-v-/,/^_ngcontent-|^_nghost-|^ng-version$|^ng-reflect-/,/^data-reactid$|^data-react-checksum$|^data-react-helmet$/,/^data-radix-|^data-headlessui-|^data-floating-ui-|^data-state$|^data-side$/,/^data-svelte-h$|^data-astro-|^data-styled|^data-emotion$/],$n=[/^[0-9a-f]{8}-[0-9a-f]{4}-/i,/^[0-9a-f]{16,}$/i,/^:r[0-9a-z]+:$/,/^«r[0-9a-z]+»$/,/^\d{4,}$/,/^(ember|mui|mat|cdk|headlessui|radix|reach)-?\d/i,/^(ember|mui|mat|cdk|headlessui|radix|reach)(-?[a-z]+)*-?\d+$/i];function An(e){return e.startsWith(bn)&&e!==A("anchor")||e.startsWith("aria-")&&e!=="aria-label"||xn.some(t=>t.test(e))?!1:Re.has(e)||yn.has(e)}function vn(e,t){return!t||t.length>120||e==="href"&&(t.includes("?")||/^[a-z]+:\/\//i.test(t))?!0:$n.some(n=>n.test(t))}const N=(e,t)=>!vn(e,t)&&!O(t);function U(e){return N("id",e)&&/^[a-zA-Z0-9_-]+$/.test(e)}const En=e=>`"${e.replace(/([\\"])/g,"\\$1")}"`,Oe=e=>e.replace(/"[^"]*"|'[^']*'|#([A-Za-z_-][\w-]*)/g,(t,n)=>n?`[id=${En(n)}]`:t);function De(e,t,n){try{return n.querySelectorAll(e).length===1&&n.querySelector(e)===t}catch{return!1}}function B(e,t=document.body){const n={root:t,tagName:()=>!0,idName:U,seedMinLength:2,optimizedMinLength:2};try{const r=ke(e,{...n,timeoutMs:150,className:()=>!1,attr:(o,s)=>Re.has(o)&&N(o,s)}),a=Oe(r);if(De(a,e,t))return a}catch{}try{const r=ke(e,{...n,timeoutMs:300,className:Sn,attr:(o,s)=>An(o)&&N(o,s)}),a=Oe(r);return De(a,e,t)?a:void 0}catch{return}}function Sn(e){return!(!e||e.length>60||/^[a-z-]*\d/.test(e)||/[:[\]/]/.test(e)||/_[A-Za-z0-9]{5,}$/.test(e)||/^[a-z]+-[0-9a-f]{6,}$/i.test(e))}function _n(e){const t=[];let n=e;for(let r=0;n&&n.nodeType===1&&r<40;r++){const a=n.tagName.toLowerCase();let o=1,s=!1;for(let i=n.previousElementSibling;i;i=i.previousElementSibling)i.tagName===n.tagName&&o++;for(let i=n.nextElementSibling;!s&&i;i=i.nextElementSibling)i.tagName===n.tagName&&(s=!0);t.unshift(o>1||s?`${a}[${o}]`:a),n=n.parentElement}return`/${t.join("/")}`}function kn(e){const t=$e(e),n={},r=It(e);if(r.length){const o=r.map(s=>B(s)).filter(s=>!!s);o.length&&(n.hostPath=o)}const a=B(t);a&&(n.css=a),t.id&&U(t.id)&&(n.domid=t.id);try{n.xpath=_n(t)}catch{}return n}export{Je as applyShotOutcome,Nt as buildExport,Ee as candidates,$t as captureContext,v as captureReport,on as createAddChrome,Jt as createElementAnchor,Dt as deleteBlob,de as deriveAnchorLabel,yt as derivePageRef,_t as deriveQuoteLabel,kn as describeElement,Rt as download,B as generateCss,ge as getBlob,Pt as importArchive,O as isSensitiveValue,U as isStableId,N as isUsableAttrValue,ye as narrow,me as putBlob,E as redactText,ne as redactUrl,Zt as resolveAttachmentUris,we as widen};