linear-grab 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.global.js +3 -3
- package/dist/linear-grab.js +12 -7
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),r=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},i={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return a(this.context.count)},getNextContextId(){return a(this.context.count++)}};function a(e){let t=String(e),n=t.length-1;return i.context.id+(n?String.fromCharCode(96+n):``)+t}function o(e){i.context=e}var s=(e,t)=>e===t,c=Symbol(`solid-proxy`),l=typeof Proxy==`function`,u=Symbol(`solid-track`),d={equals:s},f=null,p=Se,m=1,h=2,g={owned:null,cleanups:null,context:null,owner:null},_={},v=null,y=null,b=null,x=null,S=null,C=0;function w(e,t){let n=b,r=v,i=e.length===0,a=t===void 0?r:t,o=i?g:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>ne(()=>Ee(o)));v=o,b=null;try{return be(s,!0)}finally{b=n,v=r}}function T(e,t){t=t?Object.assign({},d,t):d;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[me.bind(n),e=>(typeof e==`function`&&(e=y&&y.running&&y.sources.has(n)?e(n.tValue):e(n.value)),he(n,e))]}function E(e,t,n){ge(ve(e,t,!0,m))}function D(e,t,n){ge(ve(e,t,!1,m))}function O(e,t,n){p=Ce;let r=ve(e,t,!1,m),i=pe&&de(pe);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),S?S.push(r):ge(r)}function k(e,t,n){n=n?Object.assign({},d,n):d;let r=ve(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,ge(r),me.bind(r)}function ee(e){return e&&typeof e==`object`&&`then`in e}function te(e,t,n){let r,a,o;typeof t==`function`?(r=e,a=t,o=n||{}):(r=!0,a=e,o=t||{});let s=null,c=_,l=null,u=!1,d=!1,f=`initialValue`in o,p=typeof r==`function`&&k(r),m=new Set,[h,g]=(o.storage||T)(o.initialValue),[x,S]=T(void 0),[C,w]=T(void 0,{equals:!1}),[D,O]=T(f?`ready`:`unresolved`);v&&ae(()=>{for(let e of m.keys())e.decrement();m.clear(),y&&s&&y.promises.delete(s),s=null}),i.context&&(l=i.getNextContextId(),o.ssrLoadFrom===`initial`?c=o.initialValue:i.load&&i.has(l)&&(c=i.load(l)));function te(e,t,n,r){return s===e&&(s=null,r!==void 0&&(f=!0),(e===c||t===c)&&o.onHydrated&&queueMicrotask(()=>o.onHydrated(r,{value:t})),c=_,y&&e&&u?(y.promises.delete(e),u=!1,be(()=>{y.running=!0,A(t,n)},!1)):A(t,n)),t}function A(e,t){be(()=>{t===void 0&&g(()=>e),O(t===void 0?f?`ready`:`unresolved`:`errored`),S(t);for(let e of m.keys())e.decrement();m.clear()},!1)}function re(){let e=pe&&de(pe),t=h(),n=x();if(n!==void 0&&!s)throw n;return b&&!b.user&&e&&E(()=>{C(),s&&(e.resolved&&y&&u?y.promises.add(s):m.has(e)||(e.increment(),m.add(e)))}),t}function ie(e=!0){if(e!==!1&&d)return;d=!1;let t=p?p():r;if(u=y&&y.running,t==null||t===!1){te(s,ne(h));return}y&&s&&y.promises.delete(s);let n,i=c===_?ne(()=>{try{return a(t,{value:h(),refetching:e})}catch(e){n=e}}):c;if(n!==void 0){te(s,void 0,Oe(n),t);return}else if(!ee(i))return te(s,i,void 0,t),i;return s=i,`v`in i?(i.s===1?te(s,i.v,void 0,t):te(s,void 0,Oe(i.v),t),i):(d=!0,queueMicrotask(()=>d=!1),be(()=>{O(f?`refreshing`:`pending`),w()},!1),i.then(e=>te(i,e,void 0,t),e=>te(i,void 0,Oe(e),t)))}Object.defineProperties(re,{state:{get:()=>D()},error:{get:()=>x()},loading:{get(){let e=D();return e===`pending`||e===`refreshing`}},latest:{get(){if(!f)return re();let e=x();if(e&&!s)throw e;return h()}}});let oe=v;return p?E(()=>(oe=v,ie(!1))):ie(!1),[re,{refetch:e=>se(oe,()=>ie(e)),mutate:g}]}function A(e){return be(e,!1)}function ne(e){if(b===null)return e();let t=b;b=null;try{return e()}finally{b=t}}function re(e,t,n){let r=Array.isArray(e),i,a=n&&n.defer;return n=>{let o;if(r){o=Array(e.length);for(let t=0;t<e.length;t++)o[t]=e[t]()}else o=e();if(a)return a=!1,n;let s=ne(()=>t(o,i,n));return i=o,s}}function ie(e){O(()=>ne(e))}function ae(e){return v===null||(v.cleanups===null?v.cleanups=[e]:v.cleanups.push(e)),e}function oe(){return b}function se(e,t){let n=v,r=b;v=e,b=null;try{return be(t,!0)}catch(e){Ae(e)}finally{v=n,b=r}}var[ce,le]=T(!1);function ue(e,t){let n=Symbol(`context`);return{id:n,Provider:Me(n),defaultValue:e}}function de(e){let t;return v&&v.context&&(t=v.context[e.id])!==void 0?t:e.defaultValue}function fe(e){let t=k(e),n=k(()=>je(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var pe;function me(){let e=y&&y.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===m)ge(this);else{let e=x;x=null,be(()=>we(this),!1),x=e}if(b){let e=this.observers;if(!e||e[e.length-1]!==b){let t=e?e.length:0;b.sources?(b.sources.push(this),b.sourceSlots.push(t)):(b.sources=[this],b.sourceSlots=[t]),e?(e.push(b),this.observerSlots.push(b.sources.length-1)):(this.observers=[b],this.observerSlots=[b.sources.length-1])}}return e&&y.sources.has(this)?this.tValue:this.value}function he(e,t,n){let r=y&&y.running&&y.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(y){let r=y.running;(r||!n&&y.sources.has(e))&&(y.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&be(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=y&&y.running;r&&y.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?x.push(n):S.push(n),n.observers&&Te(n)),r?n.tState=m:n.state=m)}if(x.length>1e6)throw x=[],Error()},!1)}return t}function ge(e){if(!e.fn)return;Ee(e);let t=C;_e(e,y&&y.running&&y.sources.has(e)?e.tValue:e.value,t),y&&!y.running&&y.sources.has(e)&&queueMicrotask(()=>{be(()=>{y&&(y.running=!0),b=v=e,_e(e,e.tValue,t),b=v=null},!1)})}function _e(e,t,n){let r,i=v,a=b;b=v=e;try{r=e.fn(t)}catch(t){return e.pure&&(y&&y.running?(e.tState=m,e.tOwned&&e.tOwned.forEach(Ee),e.tOwned=void 0):(e.state=m,e.owned&&e.owned.forEach(Ee),e.owned=null)),e.updatedAt=n+1,Ae(t)}finally{b=a,v=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?he(e,r,!0):y&&y.running&&e.pure?(y.sources.has(e)||(e.value=r),y.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function ve(e,t,n,r=m,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:v,context:v?v.context:null,pure:n};return y&&y.running&&(a.state=0,a.tState=r),v===null||v!==g&&(y&&y.running&&v.pure?v.tOwned?v.tOwned.push(a):v.tOwned=[a]:v.owned?v.owned.push(a):v.owned=[a]),a}function ye(e){let t=y&&y.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===h)return we(e);if(e.suspense&&ne(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<C);){if(t&&y.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(y.disposed.has(t))return}if((t?e.tState:e.state)===m)ge(e);else if((t?e.tState:e.state)===h){let t=x;x=null,be(()=>we(e,n[0]),!1),x=t}}}function be(e,t){if(x)return e();let n=!1;t||(x=[]),S?n=!0:S=[],C++;try{let t=e();return xe(n),t}catch(e){n||(S=null),x=null,Ae(e)}}function xe(e){if(x&&=(Se(x),null),e)return;let t;if(y){if(!y.promises.size&&!y.queue.size){let e=y.sources,n=y.disposed;S.push.apply(S,y.effects),t=y.resolve;for(let e of S)`tState`in e&&(e.state=e.tState),delete e.tState;y=null,be(()=>{for(let e of n)Ee(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)Ee(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}le(!1)},!1)}else if(y.running){y.running=!1,y.effects.push.apply(y.effects,S),S=null,le(!0);return}}let n=S;S=null,n.length&&be(()=>p(n),!1),t&&t()}function Se(e){for(let t=0;t<e.length;t++)ye(e[t])}function Ce(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:ye(r)}if(i.context){if(i.count){i.effects||=[],i.effects.push(...e.slice(0,n));return}o()}for(i.effects&&(i.done||!i.count)&&(e=[...i.effects,...e],n+=i.effects.length,delete i.effects),t=0;t<n;t++)ye(e[t])}function we(e,t){let n=y&&y.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===m?i!==t&&(!i.updatedAt||i.updatedAt<C)&&ye(i):e===h&&we(i,t)}}}function Te(e){let t=y&&y.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=h:r.state=h,r.pure?x.push(r):S.push(r),r.observers&&Te(r))}}function Ee(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Ee(e.tOwned[t]);delete e.tOwned}if(y&&y.running&&e.pure)De(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)Ee(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}y&&y.running?e.tState=0:e.state=0}function De(e,t){if(t||(e.tState=0,y.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)De(e.owned[t])}function Oe(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function ke(e,t,n){try{for(let n of t)n(e)}catch(e){Ae(e,n&&n.owner||null)}}function Ae(e,t=v){let n=f&&t&&t.context&&t.context[f],r=Oe(e);if(!n)throw r;S?S.push({fn(){ke(r,n,t)},state:m}):ke(r,n,t)}function je(e){if(typeof e==`function`&&!e.length)return je(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=je(e[n]);if(Array.isArray(r))if(r.length<32768)t.push.apply(t,r);else for(let e=0;e<r.length;e++)t.push(r[e]);else t.push(r)}return t}return e}function Me(e,t){return function(t){let n;return D(()=>n=ne(()=>(v.context={...v.context,[e]:t.value},fe(()=>t.children))),void 0),n}}var Ne=Symbol(`fallback`);function Pe(e){for(let t=0;t<e.length;t++)e[t]()}function Fe(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return ae(()=>Pe(a)),()=>{let c=e()||[],l=c.length,d,f;return c[u],ne(()=>{let e,t,u,m,h,g,_,v,y;if(l===0)o!==0&&(Pe(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[Ne],i[0]=w(e=>(a[0]=e,n.fallback())),o=1);else if(o===0){for(i=Array(l),f=0;f<l;f++)r[f]=c[f],i[f]=w(p);o=l}else{for(u=Array(l),m=Array(l),s&&(h=Array(l)),g=0,_=Math.min(o,l);g<_&&r[g]===c[g];g++);for(_=o-1,v=l-1;_>=g&&v>=g&&r[_]===c[v];_--,v--)u[v]=i[_],m[v]=a[_],s&&(h[v]=s[_]);for(e=new Map,t=Array(v+1),f=v;f>=g;f--)y=c[f],d=e.get(y),t[f]=d===void 0?-1:d,e.set(y,f);for(d=g;d<=_;d++)y=r[d],f=e.get(y),f!==void 0&&f!==-1?(u[f]=i[d],m[f]=a[d],s&&(h[f]=s[d]),f=t[f],e.set(y,f)):a[d]();for(f=g;f<l;f++)f in u?(i[f]=u[f],a[f]=m[f],s&&(s[f]=h[f],s[f](f))):i[f]=w(p);i=i.slice(0,o=l),r=c.slice(0)}return i});function p(e){if(a[f]=e,s){let[e,n]=T(f);return s[f]=n,t(c[f],e)}return t(c[f])}}}function Ie(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return ae(()=>Pe(a)),()=>{let l=e()||[],d=l.length;return l[u],ne(()=>{if(d===0)return s!==0&&(Pe(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[Ne],i[0]=w(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===Ne&&(a[0](),a=[],r=[],i=[],s=0),c=0;c<d;c++)c<r.length&&r[c]!==l[c]?o[c](()=>l[c]):c>=r.length&&(i[c]=w(f));for(;c<r.length;c++)a[c]();return s=o.length=a.length=d,r=l.slice(0),i=i.slice(0,s)});function f(e){a[c]=e;let[n,r]=T(l[c]);return o[c]=r,t(n,c)}}}function j(e,t){return ne(()=>e(t||{}))}function Le(){return!0}var Re={get(e,t,n){return t===c?n:e.get(t)},has(e,t){return t===c||e.has(t)},set:Le,deleteProperty:Le,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Le,deleteProperty:Le}},ownKeys(e){return e.keys()}};function ze(e){return(e=typeof e==`function`?e():e)?e:{}}function Be(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function Ve(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&c in r,e[n]=typeof r==`function`?(t=!0,k(r)):r}if(l&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=ze(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in ze(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(ze(e[n])));return[...new Set(t)]}},Re);let n={},r=Object.create(null);for(let t=e.length-1;t>=0;t--){let i=e[t];if(!i)continue;let a=Object.getOwnPropertyNames(i);for(let e=a.length-1;e>=0;e--){let t=a[e];if(t===`__proto__`||t===`constructor`)continue;let o=Object.getOwnPropertyDescriptor(i,t);if(!r[t])r[t]=o.get?{enumerable:!0,configurable:!0,get:Be.bind(n[t]=[o.get.bind(i)])}:o.value===void 0?void 0:o;else{let e=n[t];e&&(o.get?e.push(o.get.bind(i)):o.value!==void 0&&e.push(()=>o.value))}}}let i={},a=Object.keys(r);for(let e=a.length-1;e>=0;e--){let t=a[e],n=r[t];n&&n.get?Object.defineProperty(i,t,n):i[t]=n?n.value:void 0}return i}function He(e,...t){let n=t.length;if(l&&c in e){let r=n>1?t.flat():t[0],i=t.map(t=>new Proxy({get(n){return t.includes(n)?e[n]:void 0},has(n){return t.includes(n)&&n in e},keys(){return t.filter(t=>t in e)}},Re));return i.push(new Proxy({get(t){return r.includes(t)?void 0:e[t]},has(t){return!r.includes(t)&&t in e},keys(){return Object.keys(e).filter(e=>!r.includes(e))}},Re)),i}let r=[];for(let e=0;e<=n;e++)r[e]={};for(let i of Object.getOwnPropertyNames(e)){let a=n;for(let e=0;e<t.length;e++)if(t[e].includes(i)){a=e;break}let o=Object.getOwnPropertyDescriptor(e,i);!o.get&&!o.set&&o.enumerable&&o.writable&&o.configurable?r[a][i]=o.value:Object.defineProperty(r[a],i,o)}return r}var Ue=e=>`Stale read from <${e}>.`;function We(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return k(Fe(()=>e.each,e.children,t||void 0))}function Ge(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return k(Ie(()=>e.each,e.children,t||void 0))}function M(e){let t=e.keyed,n=k(()=>e.when,void 0,void 0),r=t?n:k(n,void 0,{equals:(e,t)=>!e==!t});return k(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?ne(()=>a(t?i:()=>{if(!ne(r))throw Ue(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var Ke=new Set([`className`,`value`,`readOnly`,`noValidate`,`formNoValidate`,`isMap`,`noModule`,`playsInline`,`adAuctionHeaders`,`allowFullscreen`,`browsingTopics`,`defaultChecked`,`defaultMuted`,`defaultSelected`,`disablePictureInPicture`,`disableRemotePlayback`,`preservesPitch`,`shadowRootClonable`,`shadowRootCustomElementRegistry`,`shadowRootDelegatesFocus`,`shadowRootSerializable`,`sharedStorageWritable`,...`allowfullscreen.async.alpha.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.hidden.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.adauctionheaders.browsingtopics.credentialless.defaultchecked.defaultmuted.defaultselected.defer.disablepictureinpicture.disableremoteplayback.preservespitch.shadowrootclonable.shadowrootcustomelementregistry.shadowrootdelegatesfocus.shadowrootserializable.sharedstoragewritable`.split(`.`)]),qe=new Set([`innerHTML`,`textContent`,`innerText`,`children`]),Je=Object.assign(Object.create(null),{className:`class`,htmlFor:`for`}),Ye=Object.assign(Object.create(null),{class:`className`,novalidate:{$:`noValidate`,FORM:1},formnovalidate:{$:`formNoValidate`,BUTTON:1,INPUT:1},ismap:{$:`isMap`,IMG:1},nomodule:{$:`noModule`,SCRIPT:1},playsinline:{$:`playsInline`,VIDEO:1},readonly:{$:`readOnly`,INPUT:1,TEXTAREA:1},adauctionheaders:{$:`adAuctionHeaders`,IFRAME:1},allowfullscreen:{$:`allowFullscreen`,IFRAME:1},browsingtopics:{$:`browsingTopics`,IMG:1},defaultchecked:{$:`defaultChecked`,INPUT:1},defaultmuted:{$:`defaultMuted`,AUDIO:1,VIDEO:1},defaultselected:{$:`defaultSelected`,OPTION:1},disablepictureinpicture:{$:`disablePictureInPicture`,VIDEO:1},disableremoteplayback:{$:`disableRemotePlayback`,AUDIO:1,VIDEO:1},preservespitch:{$:`preservesPitch`,AUDIO:1,VIDEO:1},shadowrootclonable:{$:`shadowRootClonable`,TEMPLATE:1},shadowrootdelegatesfocus:{$:`shadowRootDelegatesFocus`,TEMPLATE:1},shadowrootserializable:{$:`shadowRootSerializable`,TEMPLATE:1},sharedstoragewritable:{$:`sharedStorageWritable`,IFRAME:1,IMG:1}});function Xe(e,t){let n=Ye[e];return typeof n==`object`?n[t]?n.$:void 0:n}var Ze=new Set([`beforeinput`,`click`,`dblclick`,`contextmenu`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mousemove`,`mouseout`,`mouseover`,`mouseup`,`pointerdown`,`pointermove`,`pointerout`,`pointerover`,`pointerup`,`touchend`,`touchmove`,`touchstart`]),Qe={xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`},$e=e=>k(()=>e());function et(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null)if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&!((d=l.get(t[c]))==null||d!==r+u);)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++;else t[o++].remove()}}}var tt=`_$DX_DELEGATE`;function nt(e,t,n,r={}){let i;return w(r=>{i=r,t===document?e():P(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function N(e,t,n,r){let i,a=()=>{let t=r?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},o=t?()=>ne(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function rt(e,t=window.document){let n=t[tt]||(t[tt]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,yt))}}function it(e,t,n){ht(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function at(e,t,n,r){ht(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function ot(e,t,n){ht(e)||(n?e.setAttribute(t,``):e.removeAttribute(t))}function st(e,t){ht(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function ct(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function lt(e,t,n={}){let r=Object.keys(t||{}),i=Object.keys(n),a,o;for(a=0,o=i.length;a<o;a++){let r=i[a];!r||r===`undefined`||t[r]||(_t(e,r,!1),delete n[r])}for(a=0,o=r.length;a<o;a++){let i=r[a],o=!!t[i];!i||i===`undefined`||n[i]===o||!o||(_t(e,i,!0),n[i]=o)}return n}function ut(e,t,n){if(!t)return n?it(e,`style`):t;let r=e.style;if(typeof t==`string`)return r.cssText=t;typeof n==`string`&&(r.cssText=n=void 0),n||={},t||={};let i,a;for(a in n)t[a]??r.removeProperty(a),delete n[a];for(a in t)i=t[a],i!==n[a]&&(r.setProperty(a,i),n[a]=i);return n}function dt(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function ft(e,t={},n,r){let i={};return r||D(()=>i.children=bt(e,t.children,i.children)),D(()=>typeof t.ref==`function`&&pt(t.ref,e)),D(()=>mt(e,t,n,!0,i,!0)),i}function pt(e,t,n){return ne(()=>e(t,n))}function P(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return bt(e,t,r,n);D(r=>bt(e,t(),r,n),r)}function mt(e,t,n,r,i={},a=!1){t||={};for(let r in i)if(!(r in t)){if(r===`children`)continue;i[r]=vt(e,r,null,i[r],n,a,t)}for(let o in t){if(o===`children`){r||bt(e,t.children);continue}let s=t[o];i[o]=vt(e,o,s,i[o],n,a,t)}}function ht(e){return!!i.context&&!i.done&&(!e||e.isConnected)}function gt(e){return e.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function _t(e,t,n){let r=t.trim().split(/\s+/);for(let t=0,i=r.length;t<i;t++)e.classList.toggle(r[t],n)}function vt(e,t,n,r,i,a,o){let s,c,l,u,d;if(t===`style`)return ut(e,n,r);if(t===`classList`)return lt(e,n,r);if(n===r)return r;if(t===`ref`)a||n(e);else if(t.slice(0,3)===`on:`){let i=t.slice(3);r&&e.removeEventListener(i,r,typeof r!=`function`&&r),n&&e.addEventListener(i,n,typeof n!=`function`&&n)}else if(t.slice(0,10)===`oncapture:`){let i=t.slice(10);r&&e.removeEventListener(i,r,!0),n&&e.addEventListener(i,n,!0)}else if(t.slice(0,2)===`on`){let i=t.slice(2).toLowerCase(),a=Ze.has(i);if(!a&&r){let t=Array.isArray(r)?r[0]:r;e.removeEventListener(i,t)}(a||n)&&(ct(e,i,n,a),a&&rt([i]))}else if(t.slice(0,5)===`attr:`)it(e,t.slice(5),n);else if(t.slice(0,5)===`bool:`)ot(e,t.slice(5),n);else if((d=t.slice(0,5)===`prop:`)||(l=qe.has(t))||!i&&((u=Xe(t,e.tagName))||(c=Ke.has(t)))||(s=e.nodeName.includes(`-`)||`is`in o)){if(d)t=t.slice(5),c=!0;else if(ht(e))return n;t===`class`||t===`className`?st(e,n):s&&!c&&!l?e[gt(t)]=n:e[u||t]=n}else{let r=i&&t.indexOf(`:`)>-1&&Qe[t.split(`:`)[0]];r?at(e,r,t,n):it(e,Je[t]||t,n)}return n}function yt(e){if(i.registry&&i.events&&i.events.find(([t,n])=>n===e))return;let t=e.target,n=`$$${e.type}`,r=e.target,a=e.currentTarget,o=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{let r=t[n];if(r&&!t.disabled){let i=t[`${n}Data`];if(i===void 0?r.call(t,e):r.call(t,i,e),e.cancelBubble)return}return t.host&&typeof t.host!=`string`&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},c=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),i.registry&&!i.done&&(i.done=_$HY.done=!0),e.composedPath){let n=e.composedPath();o(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,c();break}if(t.parentNode===a)break}}else c();o(r)}function bt(e,t,n,r,i){let a=ht(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let o=typeof t,s=r!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o===`string`||o===`number`){if(a||o===`number`&&(t=t.toString(),t===n))return n;if(s){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Ct(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||o===`boolean`){if(a)return n;n=Ct(e,n,r)}else if(o===`function`)return D(()=>{let i=t();for(;typeof i==`function`;)i=i();n=bt(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(xt(o,t,n,i))return D(()=>n=bt(e,o,n,r,!0)),()=>n;if(a){if(!o.length)return n;if(r===void 0)return n=[...e.childNodes];let t=o[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(o.length===0){if(n=Ct(e,n,r),s)return n}else c?n.length===0?St(e,o,r):et(e,n,o):(n&&Ct(e),St(e,o));n=o}else if(t.nodeType){if(a&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=Ct(e,n,r,t);Ct(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function xt(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(!(o==null||o===!0||o===!1))if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=xt(e,o,s)||i;else if(c===`function`)if(r){for(;typeof o==`function`;)o=o();i=xt(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0;else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}return i}function St(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Ct(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}var wt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Tt=new class extends wt{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Et={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Dt=new class{#e=Et;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Ot(e){setTimeout(e,0)}var kt=typeof window>`u`||`Deno`in globalThis;function At(){}function jt(e,t){return typeof e==`function`?e(t):e}function Mt(e){return typeof e==`number`&&e>=0&&e!==1/0}function Nt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Pt(e,t){return typeof e==`function`?e(t):e}function Ft(e,t){return typeof e==`function`?e(t):e}function It(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Rt(o,t.options))return!1}else if(!Bt(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Lt(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(zt(t.options.mutationKey)!==zt(a))return!1}else if(!Bt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Rt(e,t){return(t?.queryKeyHashFn||zt)(e)}function zt(e){return JSON.stringify(e,(e,t)=>Gt(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Bt(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Bt(e[n],t[n])):!1}var Vt=Object.prototype.hasOwnProperty;function Ht(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Wt(e)&&Wt(t);if(!r&&!(Gt(e)&&Gt(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Vt.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Ht(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Ut(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Wt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Gt(e){if(!Kt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Kt(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Kt(e){return Object.prototype.toString.call(e)===`[object Object]`}function qt(e){return new Promise(t=>{Dt.setTimeout(t,e)})}function Jt(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ht(e,t)}function Yt(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Xt(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Zt=Symbol();function Qt(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Zt?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function $t(e,t){return typeof e==`function`?e(...t):!!e}function en(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var tn=(()=>{let e=()=>kt;return{isServer(){return e()},setIsServer(t){e=t}}})();function nn(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}function rn(e){let t;if(e.then(e=>(t=e,e),At)?.catch(At),t!==void 0)return{data:t}}function an(e){return e}function on(e,t,n){if(typeof t!=`object`||!t)return;let r=e.getMutationCache(),i=e.getQueryCache(),a=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??an,o=t.mutations||[],s=t.queries||[];o.forEach(({state:t,...i})=>{r.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...i},t)}),s.forEach(({queryKey:t,state:r,queryHash:o,meta:s,promise:c,dehydratedAt:l,queryType:u})=>{let d=c?rn(c):void 0,f=r.data===void 0?d?.data:r.data,p=f===void 0?f:a(f),m=i.get(o),h=m?.state.status===`pending`,g=m?.state.fetchStatus===`fetching`;if(m){let e=d&&l!==void 0&&l>m.state.dataUpdatedAt;if(r.dataUpdatedAt>m.state.dataUpdatedAt||e){let{fetchStatus:e,...t}=r;m.setState({...t,data:p,...r.status===`pending`&&p!==void 0&&{status:`success`,dataUpdatedAt:l??Date.now(),...!g&&{fetchStatus:`idle`}}})}}else m=i.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:t,queryHash:o,meta:s,_type:u},{...r,data:p,fetchStatus:`idle`,status:r.status===`pending`&&p!==void 0?`success`:r.status,...r.status===`pending`&&p!==void 0&&{dataUpdatedAt:l??Date.now()}});c&&!d&&!h&&!g&&(l===void 0||l>m.state.dataUpdatedAt)&&m.fetch(void 0,{initialPromise:Promise.resolve(c).then(a)}).catch(At)})}var sn=Ot;function cn(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=sn,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ln=cn(),un=new class extends wt{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function dn(e){return Math.min(1e3*2**e,3e4)}function fn(e){return(e??`online`)!==`online`||un.isOnline()}var pn=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function mn(e){let t=!1,n=0,r,i=nn(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new pn(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Tt.isFocused()&&(e.networkMode===`always`||un.isOnline())&&e.canRun(),u=()=>fn(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(tn.isServer()?0:3),o=e.retryDelay??dn,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),qt(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var hn=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Mt(this.gcTime)&&(this.#e=Dt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(tn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Dt.clearTimeout(this.#e),this.#e=void 0)}};function gn(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{en(e,()=>t.signal,()=>n=!0)},u=Qt(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Xt:Yt;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?vn:_n,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:_n(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function _n(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function vn(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var yn=class extends hn{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Sn(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Sn(this.options);e.data!==void 0&&(this.setState(xn(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Jt(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(At).catch(At):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Ft(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Zt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Pt(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Nt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Qt(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?gn(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=mn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof pn&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof pn){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...bn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...xn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ln.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function bn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:fn(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function xn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Sn(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Cn=class extends wt{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=nn(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Tn(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return En(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return En(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Ft(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Ut(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Dn(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Ft(this.options.enabled,this.#t)!==Ft(t.enabled,this.#t)||Pt(this.options.staleTime,this.#t)!==Pt(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Ft(this.options.enabled,this.#t)!==Ft(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return kn(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(At)),t}#g(){this.#b();let e=Pt(this.options.staleTime,this.#t);if(tn.isServer()||this.#r.isStale||!Mt(e))return;let t=Nt(this.#r.dataUpdatedAt,e)+1;this.#d=Dt.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(tn.isServer()||Ft(this.options.enabled,this.#t)===!1||!Mt(this.#p)||this.#p===0)&&(this.#f=Dt.setInterval(()=>{(this.options.refetchIntervalInBackground||Tt.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Dt.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Dt.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Tn(e,t),o=i&&Dn(e,n,t,r);(a||o)&&(l={...l,...bn(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Jt(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Jt(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:On(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Ft(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=nn();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Ut(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ln.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function wn(e,t){return Ft(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&Ft(t.retryOnMount,e)===!1)}function Tn(e,t){return wn(e,t)||e.state.data!==void 0&&En(e,t,t.refetchOnMount)}function En(e,t,n){if(Ft(t.enabled,e)!==!1&&Pt(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&On(e,t)}return!1}function Dn(e,t,n,r){return(e!==t||Ft(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&On(e,n)}function On(e,t){return Ft(t.enabled,e)!==!1&&e.isStaleByTime(Pt(t.staleTime,e))}function kn(e,t){return!Ut(e.getCurrentResult(),t)}var An=class extends hn{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||jn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=mn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),ln.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function jn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Mn=class extends wt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new An({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Nn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Nn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Nn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Nn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){ln.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Lt(t,e))}findAll(e={}){return this.getAll().filter(t=>Lt(e,t))}notify(e){ln.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return ln.batch(()=>Promise.all(e.map(e=>e.continue().catch(At))))}};function Nn(e){return e.options.scope?.id}var Pn=class extends wt{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Ut(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&zt(t.mutationKey)!==zt(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??jn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){ln.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Fn=class extends wt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Rt(r,t),a=this.get(i);return a||(a=new yn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){ln.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>It(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>It(e,t)):t}notify(e){ln.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ln.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ln.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},In=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Fn,this.#t=e.mutationCache||new Mn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Tt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=un.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Pt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=jt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ln.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;ln.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return ln.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=ln.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(At).catch(At)}invalidateQueries(e,t={}){return ln.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=ln.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(At)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(At)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Pt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(At).catch(At)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(At).catch(At)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return un.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(zt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Bt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(zt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Bt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Rt(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Zt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Ln=Symbol(`store-raw`),Rn=Symbol(`store-node`),zn=Symbol(`store-has`),Bn=Symbol(`store-self`);function Vn(e){let t=e[c];if(!t&&(Object.defineProperty(e,c,{value:t=new Proxy(e,Yn)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function Hn(e){let t;return typeof e==`object`&&!!e&&(e[c]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Un(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Ln])return n;if(!Hn(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=Un(i,t))!==i&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let s=0,c=n.length;s<c;s++)a=n[s],!o[a].get&&(i=e[a],(r=Un(i,t))!==i&&(e[a]=r))}return e}function Wn(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Gn(e,t,n){if(e[t])return e[t];let[r,i]=T(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Kn(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===c||t===Rn?n:(delete n.value,delete n.writable,n.get=()=>e[c][t],n)}function qn(e){oe()&&Gn(Wn(e,Rn),Bn)()}function Jn(e){return qn(e),Reflect.ownKeys(e)}var Yn={get(e,t,n){if(t===Ln)return e;if(t===c)return n;if(t===u)return qn(e),n;let r=Wn(e,Rn),i=r[t],a=i?i():e[t];if(t===Rn||t===zn||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);oe()&&(typeof a!=`function`||Object.prototype.hasOwnProperty.call(e,t))&&!(n&&n.get)&&(a=Gn(r,t,a)())}return Hn(a)?Vn(a):a},has(e,t){return t===Ln||t===c||t===u||t===Rn||t===zn||t===`__proto__`?!0:(oe()&&Gn(Wn(e,zn),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Jn,getOwnPropertyDescriptor:Kn};function Xn(e,t,n,r=!1){if(t===`__proto__`||!r&&e[t]===n)return;let i=e[t],a=e.length;n===void 0?(delete e[t],e[zn]&&e[zn][t]&&i!==void 0&&e[zn][t].$()):(e[t]=n,e[zn]&&e[zn][t]&&i===void 0&&e[zn][t].$());let o=Wn(e,Rn),s;if((s=Gn(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Gn(o,`length`,a))&&s.$(e.length)}(s=o[Bn])&&s.$()}function Zn(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];Qn(i)||Xn(e,i,t[i])}}function Qn(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function $n(e,t){if(typeof t==`function`&&(t=t(e)),t=Un(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){let r=t[n];e[n]!==r&&Xn(e,n,r)}Xn(e,`length`,r)}else Zn(e,t)}function er(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();let a=typeof r,o=Array.isArray(e);if(a===`string`&&(r===`__proto__`||t.length>1&&Qn(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)er(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&er(e,[i].concat(t),n);return}else if(o&&a===`object`){let{from:i=0,to:a=e.length-1,by:o=1}=r;for(let r=i;r<=a;r+=o)er(e,[r].concat(t),n);return}else if(t.length>1){er(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let a=t[0];typeof a==`function`&&(a=a(i,n),a===i)||r===void 0&&a==null||(a=Un(a),r===void 0||Hn(i)&&Hn(a)&&!Array.isArray(a)?Zn(i,a):Xn(e,r,a))}function tr(...[e,t]){let n=Un(e||{}),r=Array.isArray(n),i=Vn(n);function a(...e){A(()=>{r&&e.length===1?$n(n,e[0]):er(n,e)})}return[i,a]}var nr=Symbol(`store-root`);function rr(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ir(e,t,n,r,i){if(rr(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==nr&&(!Hn(e)||!Hn(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Xn(t,n,e);return}if(o){if(e.length&&a.length&&(!r||i&&e[0]&&e[0][i]!=null)){let t,n,o,s,c,l,u,d;for(o=0,s=Math.min(a.length,e.length);o<s&&(a[o]===e[o]||i&&a[o]&&e[o]&&a[o][i]&&a[o][i]===e[o][i]);o++)ir(e[o],a,o,r,i);let f=Array(e.length),p=new Map;for(s=a.length-1,c=e.length-1;s>=o&&c>=o&&(a[s]===e[c]||i&&a[s]&&e[c]&&a[s][i]&&a[s][i]===e[c][i]);s--,c--)f[c]=a[s];if(o>c||o>s){for(n=o;n<=c;n++)Xn(a,n,e[n]);for(;n<e.length;n++)Xn(a,n,f[n]),ir(e[n],a,n,r,i);a.length>e.length&&Xn(a,`length`,e.length);return}for(u=Array(c+1),n=c;n>=o;n--)l=e[n],d=i&&l?l[i]:l,t=p.get(d),u[n]=t===void 0?-1:t,p.set(d,n);for(t=o;t<=s;t++)l=a[t],d=i&&l?l[i]:l,n=p.get(d),n!==void 0&&n!==-1&&(f[n]=a[t],n=u[n],p.set(d,n));for(n=o;n<e.length;n++)n in f?(Xn(a,n,f[n]),ir(e[n],a,n,r,i)):Xn(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)ir(e[t],a,t,r,i);a.length>e.length&&Xn(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)rr(s[t])||ir(e[s[t]],a,s[t],r,i);let c=Object.keys(a);for(let t=0,n=c.length;t<n;t++)e[c[t]]===void 0&&Xn(a,c[t],void 0)}function ar(e,t={}){let{merge:n,key:r=`id`}=t,i=Un(e);return e=>{if(!Hn(e)||!Hn(i))return i;let t=ir(i,{[nr]:e},nr,n,r);return t===void 0?e:t}}var or=ue(void 0),sr=e=>{if(e)return e;let t=de(or);if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t()},cr=e=>(D(t=>(t?.(),e.client.mount(),e.client.unmount.bind(e.client))),ae(()=>e.client.unmount()),j(or.Provider,{value:()=>e.client,get children(){return e.children}})),lr=ue(()=>!1),ur=()=>de(lr);lr.Provider;function dr(e,t,n,r){if(n===!1)return t;if(typeof n==`function`){let r=n(e.data,t.data);return{...t,data:r}}let i=t.data;if(e.data===void 0)try{i=structuredClone(i)}catch{}let a=ar(i,{key:n})(e.data);return{...t,data:a}}var fr=(e,t)=>t;function pr(e,t,n){let r=k(()=>sr(n?.())),i=ur(),a=k(()=>{let t=r().defaultQueryOptions(e());return t._optimisticResults=i()?`isRestoring`:`optimistic`,t.structuralSharing=!1,t}),o=a(),[s,c]=T(new t(r(),a())),l=s().getOptimisticResult(a()),[u,d]=tr(l),f=()=>s().subscribe(e=>{l=e,queueMicrotask(()=>{h&&v()})});function p(e){let t=s().options,n=t.reconcile;d(r=>dr(r,e,n!==void 0&&n,t.queryHash))}function m(){return[()=>u,e=>{let t=Un(u);if(typeof e==`function`&&(e=e(t)),e?.hydrationData){let{hydrationData:t,...n}=e;e=n}p(e)}]}let h=null,g=null,[_,{refetch:v}]=te(()=>{let e=s();return new Promise((t,n)=>{if(g=t,!h&&!i()&&(h=f()),e.updateResult(),l.isError&&!l.isFetching&&!i()&&$t(e.options.throwOnError,[l.error,e.getCurrentQuery()]))return p(l),n(l.error);if(!l.isLoading)return g=null,t(fr(e.getCurrentQuery(),l));p(l)})},{storage:m,get deferStream(){return e().deferStream},onHydrated(e,t){if(t.value&&`hydrationData`in t.value&&on(r(),{queries:[{...t.value.hydrationData}]}),h)return;let n={...o};(o.staleTime||!o.initialData)&&t.value&&(n.refetchOnMount=!1),s().setOptions(n),p(s().getOptimisticResult(n)),h=f()}});return E(re(r,e=>{h&&h();let n=new t(e,a());h=f(),c(n)},{defer:!0})),E(re(i,e=>{e||v()},{defer:!0})),ae(()=>{h&&=(h(),null),g&&=(g(l),null)}),E(re([s,a],([e,t])=>{e.setOptions(t),p(e.getOptimisticResult(t)),v()},{defer:!0})),new Proxy(u,{get(e,t){return t===`data`?u.data===void 0?_()?.data:_.latest?.data:Reflect.get(e,t)}})}function mr(e,t){return pr(k(()=>e()),Cn,t)}function hr(e,t){let n=new Pn(k(()=>sr(t?.()))(),e()),r=(e,t)=>{n.mutate(e,t).catch(At)},[i,a]=tr({...n.getCurrentResult(),mutate:r,mutateAsync:n.getCurrentResult().mutate});return E(()=>{n.setOptions(e())}),E(re(()=>i.status,()=>{if(i.isError&&$t(n.options.throwOnError,[i.error]))throw i.error})),ae(n.subscribe(e=>{a({...e,mutate:r,mutateAsync:e.mutate})})),i}var gr=class extends In{constructor(e={}){super(e)}},_r=mr,vr=hr,yr,br=t((()=>{yr=typeof chrome<`u`&&!!chrome.runtime?.id&&!!chrome.storage?.local}));function xr(e){for(let t of Fr)t(e)}function Sr(e,t){try{let n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}async function Cr(){return yr?(await chrome.storage.local.get(jr))[jr]??{}:Sr(localStorage,Nr)??{}}async function wr(e){let t={...await Cr(),...e};return yr?await chrome.storage.local.set({[jr]:t}):(localStorage.setItem(Nr,JSON.stringify(t)),xr(`settings`)),t}async function Tr(){if(yr){let e=(await chrome.storage.session.get(Mr))[Mr]??null;if(!e?.length)return e;let t=await chrome.storage.session.get(e.map(e=>Lr(e.grabbedAt)));return e.map(e=>({...e,screenshotDataUrl:t[Lr(e.grabbedAt)]??void 0}))}let e=Sr(sessionStorage,Pr);return e?.length?e.map(e=>({...e,screenshotDataUrl:sessionStorage.getItem(Lr(e.grabbedAt))??void 0})):e}async function Er(e){let t=e.map(({screenshotDataUrl:e,...t})=>t);if(yr){let n={};for(let t of e)t.screenshotDataUrl&&(n[Lr(t.grabbedAt)]=t.screenshotDataUrl);await chrome.storage.session.set({[Mr]:t,...n})}else{for(let t of e)if(t.screenshotDataUrl)try{sessionStorage.setItem(Lr(t.grabbedAt),t.screenshotDataUrl)}catch{}let n=new Set(t.map(e=>Lr(e.grabbedAt)));for(let e=sessionStorage.length-1;e>=0;e--){let t=sessionStorage.key(e);t?.startsWith(Ir)&&!n.has(t)&&sessionStorage.removeItem(t)}sessionStorage.setItem(Pr,JSON.stringify(t)),xr(`grab`)}}async function Dr(e){let t=[...await Tr()??[]];for(let n of e){let e=t.findIndex(e=>e.grabbedAt===n.grabbedAt);if(e>=0){t[e]={...t[e],...n,screenshotDataUrl:n.screenshotDataUrl??t[e].screenshotDataUrl,source:n.source??t[e].source};continue}if(n.source?.filePath){let e=t.findIndex(e=>e.source?.filePath===n.source.filePath&&e.source?.lineNumber===n.source.lineNumber);if(e>=0){t[e]={...t[e],...n};continue}}t.push(n)}await Er(t.slice(-8))}async function Or(e){await Er((await Tr()??[]).filter(t=>t.grabbedAt!==e))}async function kr(){yr?await chrome.storage.session.remove(Mr):(sessionStorage.removeItem(Pr),xr(`grab`))}function Ar(e){if(yr){let t=(t,n)=>{n===`local`&&e(`settings`),n===`session`&&e(`grab`)};return chrome.storage.onChanged.addListener(t),()=>chrome.storage.onChanged.removeListener(t)}return Fr.add(e),()=>Fr.delete(e)}var jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr=t((()=>{br(),jr=`settings`,Mr=`lastGrab`,Nr=`linear-grab:settings`,Pr=`linear-grab:last-grab`,Fr=new Set,Ir=`linear-grab:shot:`,Lr=e=>`${Ir}${e}`}));function zr(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}function Br(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?!0:Array.isArray(e)?e.every(Br):typeof e==`object`&&Object.entries(e).every(([e,t])=>typeof e==`string`&&(t===void 0||Br(t)))}function Vr(e){return Array.isArray(e)&&e.every(Br)}function Hr(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&(t===void 0||Br(t)))}var Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma=t((()=>{Ur=`vercel.ai.error`,Wr=Symbol.for(Ur),qr=class e extends (Kr=Error,Gr=Wr,Kr){constructor({name:e,message:t,cause:n}){super(t),this[Gr]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Ur)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},Jr=`AI_APICallError`,Yr=`vercel.ai.error.${Jr}`,Xr=Symbol.for(Yr),$r=class extends (Qr=qr,Zr=Xr,Qr){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:Jr,message:e,cause:o}),this[Zr]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return qr.hasMarker(e,Yr)}},ei=`AI_EmptyResponseBodyError`,ti=`vercel.ai.error.${ei}`,ni=Symbol.for(ti),ai=class extends (ii=qr,ri=ni,ii){constructor({message:e=`Empty response body`}={}){super({name:ei,message:e}),this[ri]=!0}static isInstance(e){return qr.hasMarker(e,ti)}},oi=`AI_InvalidArgumentError`,si=`vercel.ai.error.${oi}`,ci=Symbol.for(si),di=class extends (ui=qr,li=ci,ui){constructor({message:e,cause:t,argument:n}){super({name:oi,message:e,cause:t}),this[li]=!0,this.argument=n}static isInstance(e){return qr.hasMarker(e,si)}},fi=`AI_InvalidPromptError`,pi=`vercel.ai.error.${fi}`,mi=Symbol.for(pi),_i=class extends (gi=qr,hi=mi,gi){constructor({prompt:e,message:t,cause:n}){super({name:fi,message:`Invalid prompt: ${t}`,cause:n}),this[hi]=!0,this.prompt=e}static isInstance(e){return qr.hasMarker(e,pi)}},vi=`AI_InvalidResponseDataError`,yi=`vercel.ai.error.${vi}`,bi=Symbol.for(yi),Ci=class extends (Si=qr,xi=bi,Si){constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:vi,message:t}),this[xi]=!0,this.data=e}static isInstance(e){return qr.hasMarker(e,yi)}},wi=`AI_JSONParseError`,Ti=`vercel.ai.error.${wi}`,Ei=Symbol.for(Ti),ki=class extends (Oi=qr,Di=Ei,Oi){constructor({text:e,cause:t}){super({name:wi,message:`JSON parsing failed: Text: ${e}.
|
|
1
|
+
(function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),r=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},i={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return a(this.context.count)},getNextContextId(){return a(this.context.count++)}};function a(e){let t=String(e),n=t.length-1;return i.context.id+(n?String.fromCharCode(96+n):``)+t}function o(e){i.context=e}var s=(e,t)=>e===t,c=Symbol(`solid-proxy`),l=typeof Proxy==`function`,u=Symbol(`solid-track`),d={equals:s},f=null,p=Se,m=1,h=2,g={owned:null,cleanups:null,context:null,owner:null},_={},v=null,y=null,b=null,x=null,S=null,C=0;function w(e,t){let n=b,r=v,i=e.length===0,a=t===void 0?r:t,o=i?g:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>ne(()=>Ee(o)));v=o,b=null;try{return be(s,!0)}finally{b=n,v=r}}function T(e,t){t=t?Object.assign({},d,t):d;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[me.bind(n),e=>(typeof e==`function`&&(e=y&&y.running&&y.sources.has(n)?e(n.tValue):e(n.value)),he(n,e))]}function E(e,t,n){ge(ve(e,t,!0,m))}function D(e,t,n){ge(ve(e,t,!1,m))}function O(e,t,n){p=Ce;let r=ve(e,t,!1,m),i=pe&&de(pe);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),S?S.push(r):ge(r)}function k(e,t,n){n=n?Object.assign({},d,n):d;let r=ve(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,ge(r),me.bind(r)}function ee(e){return e&&typeof e==`object`&&`then`in e}function te(e,t,n){let r,a,o;typeof t==`function`?(r=e,a=t,o=n||{}):(r=!0,a=e,o=t||{});let s=null,c=_,l=null,u=!1,d=!1,f=`initialValue`in o,p=typeof r==`function`&&k(r),m=new Set,[h,g]=(o.storage||T)(o.initialValue),[x,S]=T(void 0),[C,w]=T(void 0,{equals:!1}),[D,O]=T(f?`ready`:`unresolved`);v&&ae(()=>{for(let e of m.keys())e.decrement();m.clear(),y&&s&&y.promises.delete(s),s=null}),i.context&&(l=i.getNextContextId(),o.ssrLoadFrom===`initial`?c=o.initialValue:i.load&&i.has(l)&&(c=i.load(l)));function te(e,t,n,r){return s===e&&(s=null,r!==void 0&&(f=!0),(e===c||t===c)&&o.onHydrated&&queueMicrotask(()=>o.onHydrated(r,{value:t})),c=_,y&&e&&u?(y.promises.delete(e),u=!1,be(()=>{y.running=!0,A(t,n)},!1)):A(t,n)),t}function A(e,t){be(()=>{t===void 0&&g(()=>e),O(t===void 0?f?`ready`:`unresolved`:`errored`),S(t);for(let e of m.keys())e.decrement();m.clear()},!1)}function re(){let e=pe&&de(pe),t=h(),n=x();if(n!==void 0&&!s)throw n;return b&&!b.user&&e&&E(()=>{C(),s&&(e.resolved&&y&&u?y.promises.add(s):m.has(e)||(e.increment(),m.add(e)))}),t}function ie(e=!0){if(e!==!1&&d)return;d=!1;let t=p?p():r;if(u=y&&y.running,t==null||t===!1){te(s,ne(h));return}y&&s&&y.promises.delete(s);let n,i=c===_?ne(()=>{try{return a(t,{value:h(),refetching:e})}catch(e){n=e}}):c;if(n!==void 0){te(s,void 0,Oe(n),t);return}else if(!ee(i))return te(s,i,void 0,t),i;return s=i,`v`in i?(i.s===1?te(s,i.v,void 0,t):te(s,void 0,Oe(i.v),t),i):(d=!0,queueMicrotask(()=>d=!1),be(()=>{O(f?`refreshing`:`pending`),w()},!1),i.then(e=>te(i,e,void 0,t),e=>te(i,void 0,Oe(e),t)))}Object.defineProperties(re,{state:{get:()=>D()},error:{get:()=>x()},loading:{get(){let e=D();return e===`pending`||e===`refreshing`}},latest:{get(){if(!f)return re();let e=x();if(e&&!s)throw e;return h()}}});let oe=v;return p?E(()=>(oe=v,ie(!1))):ie(!1),[re,{refetch:e=>se(oe,()=>ie(e)),mutate:g}]}function A(e){return be(e,!1)}function ne(e){if(b===null)return e();let t=b;b=null;try{return e()}finally{b=t}}function re(e,t,n){let r=Array.isArray(e),i,a=n&&n.defer;return n=>{let o;if(r){o=Array(e.length);for(let t=0;t<e.length;t++)o[t]=e[t]()}else o=e();if(a)return a=!1,n;let s=ne(()=>t(o,i,n));return i=o,s}}function ie(e){O(()=>ne(e))}function ae(e){return v===null||(v.cleanups===null?v.cleanups=[e]:v.cleanups.push(e)),e}function oe(){return b}function se(e,t){let n=v,r=b;v=e,b=null;try{return be(t,!0)}catch(e){Ae(e)}finally{v=n,b=r}}var[ce,le]=T(!1);function ue(e,t){let n=Symbol(`context`);return{id:n,Provider:Me(n),defaultValue:e}}function de(e){let t;return v&&v.context&&(t=v.context[e.id])!==void 0?t:e.defaultValue}function fe(e){let t=k(e),n=k(()=>je(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var pe;function me(){let e=y&&y.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===m)ge(this);else{let e=x;x=null,be(()=>we(this),!1),x=e}if(b){let e=this.observers;if(!e||e[e.length-1]!==b){let t=e?e.length:0;b.sources?(b.sources.push(this),b.sourceSlots.push(t)):(b.sources=[this],b.sourceSlots=[t]),e?(e.push(b),this.observerSlots.push(b.sources.length-1)):(this.observers=[b],this.observerSlots=[b.sources.length-1])}}return e&&y.sources.has(this)?this.tValue:this.value}function he(e,t,n){let r=y&&y.running&&y.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(y){let r=y.running;(r||!n&&y.sources.has(e))&&(y.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&be(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=y&&y.running;r&&y.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?x.push(n):S.push(n),n.observers&&Te(n)),r?n.tState=m:n.state=m)}if(x.length>1e6)throw x=[],Error()},!1)}return t}function ge(e){if(!e.fn)return;Ee(e);let t=C;_e(e,y&&y.running&&y.sources.has(e)?e.tValue:e.value,t),y&&!y.running&&y.sources.has(e)&&queueMicrotask(()=>{be(()=>{y&&(y.running=!0),b=v=e,_e(e,e.tValue,t),b=v=null},!1)})}function _e(e,t,n){let r,i=v,a=b;b=v=e;try{r=e.fn(t)}catch(t){return e.pure&&(y&&y.running?(e.tState=m,e.tOwned&&e.tOwned.forEach(Ee),e.tOwned=void 0):(e.state=m,e.owned&&e.owned.forEach(Ee),e.owned=null)),e.updatedAt=n+1,Ae(t)}finally{b=a,v=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?he(e,r,!0):y&&y.running&&e.pure?(y.sources.has(e)||(e.value=r),y.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function ve(e,t,n,r=m,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:v,context:v?v.context:null,pure:n};return y&&y.running&&(a.state=0,a.tState=r),v===null||v!==g&&(y&&y.running&&v.pure?v.tOwned?v.tOwned.push(a):v.tOwned=[a]:v.owned?v.owned.push(a):v.owned=[a]),a}function ye(e){let t=y&&y.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===h)return we(e);if(e.suspense&&ne(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<C);){if(t&&y.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(y.disposed.has(t))return}if((t?e.tState:e.state)===m)ge(e);else if((t?e.tState:e.state)===h){let t=x;x=null,be(()=>we(e,n[0]),!1),x=t}}}function be(e,t){if(x)return e();let n=!1;t||(x=[]),S?n=!0:S=[],C++;try{let t=e();return xe(n),t}catch(e){n||(S=null),x=null,Ae(e)}}function xe(e){if(x&&=(Se(x),null),e)return;let t;if(y){if(!y.promises.size&&!y.queue.size){let e=y.sources,n=y.disposed;S.push.apply(S,y.effects),t=y.resolve;for(let e of S)`tState`in e&&(e.state=e.tState),delete e.tState;y=null,be(()=>{for(let e of n)Ee(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)Ee(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}le(!1)},!1)}else if(y.running){y.running=!1,y.effects.push.apply(y.effects,S),S=null,le(!0);return}}let n=S;S=null,n.length&&be(()=>p(n),!1),t&&t()}function Se(e){for(let t=0;t<e.length;t++)ye(e[t])}function Ce(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:ye(r)}if(i.context){if(i.count){i.effects||=[],i.effects.push(...e.slice(0,n));return}o()}for(i.effects&&(i.done||!i.count)&&(e=[...i.effects,...e],n+=i.effects.length,delete i.effects),t=0;t<n;t++)ye(e[t])}function we(e,t){let n=y&&y.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===m?i!==t&&(!i.updatedAt||i.updatedAt<C)&&ye(i):e===h&&we(i,t)}}}function Te(e){let t=y&&y.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=h:r.state=h,r.pure?x.push(r):S.push(r),r.observers&&Te(r))}}function Ee(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Ee(e.tOwned[t]);delete e.tOwned}if(y&&y.running&&e.pure)De(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)Ee(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}y&&y.running?e.tState=0:e.state=0}function De(e,t){if(t||(e.tState=0,y.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)De(e.owned[t])}function Oe(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function ke(e,t,n){try{for(let n of t)n(e)}catch(e){Ae(e,n&&n.owner||null)}}function Ae(e,t=v){let n=f&&t&&t.context&&t.context[f],r=Oe(e);if(!n)throw r;S?S.push({fn(){ke(r,n,t)},state:m}):ke(r,n,t)}function je(e){if(typeof e==`function`&&!e.length)return je(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=je(e[n]);if(Array.isArray(r))if(r.length<32768)t.push.apply(t,r);else for(let e=0;e<r.length;e++)t.push(r[e]);else t.push(r)}return t}return e}function Me(e,t){return function(t){let n;return D(()=>n=ne(()=>(v.context={...v.context,[e]:t.value},fe(()=>t.children))),void 0),n}}var Ne=Symbol(`fallback`);function Pe(e){for(let t=0;t<e.length;t++)e[t]()}function Fe(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return ae(()=>Pe(a)),()=>{let c=e()||[],l=c.length,d,f;return c[u],ne(()=>{let e,t,u,m,h,g,_,v,y;if(l===0)o!==0&&(Pe(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[Ne],i[0]=w(e=>(a[0]=e,n.fallback())),o=1);else if(o===0){for(i=Array(l),f=0;f<l;f++)r[f]=c[f],i[f]=w(p);o=l}else{for(u=Array(l),m=Array(l),s&&(h=Array(l)),g=0,_=Math.min(o,l);g<_&&r[g]===c[g];g++);for(_=o-1,v=l-1;_>=g&&v>=g&&r[_]===c[v];_--,v--)u[v]=i[_],m[v]=a[_],s&&(h[v]=s[_]);for(e=new Map,t=Array(v+1),f=v;f>=g;f--)y=c[f],d=e.get(y),t[f]=d===void 0?-1:d,e.set(y,f);for(d=g;d<=_;d++)y=r[d],f=e.get(y),f!==void 0&&f!==-1?(u[f]=i[d],m[f]=a[d],s&&(h[f]=s[d]),f=t[f],e.set(y,f)):a[d]();for(f=g;f<l;f++)f in u?(i[f]=u[f],a[f]=m[f],s&&(s[f]=h[f],s[f](f))):i[f]=w(p);i=i.slice(0,o=l),r=c.slice(0)}return i});function p(e){if(a[f]=e,s){let[e,n]=T(f);return s[f]=n,t(c[f],e)}return t(c[f])}}}function Ie(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return ae(()=>Pe(a)),()=>{let l=e()||[],d=l.length;return l[u],ne(()=>{if(d===0)return s!==0&&(Pe(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[Ne],i[0]=w(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===Ne&&(a[0](),a=[],r=[],i=[],s=0),c=0;c<d;c++)c<r.length&&r[c]!==l[c]?o[c](()=>l[c]):c>=r.length&&(i[c]=w(f));for(;c<r.length;c++)a[c]();return s=o.length=a.length=d,r=l.slice(0),i=i.slice(0,s)});function f(e){a[c]=e;let[n,r]=T(l[c]);return o[c]=r,t(n,c)}}}function j(e,t){return ne(()=>e(t||{}))}function Le(){return!0}var Re={get(e,t,n){return t===c?n:e.get(t)},has(e,t){return t===c||e.has(t)},set:Le,deleteProperty:Le,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Le,deleteProperty:Le}},ownKeys(e){return e.keys()}};function ze(e){return(e=typeof e==`function`?e():e)?e:{}}function Be(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function Ve(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&c in r,e[n]=typeof r==`function`?(t=!0,k(r)):r}if(l&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=ze(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in ze(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(ze(e[n])));return[...new Set(t)]}},Re);let n={},r=Object.create(null);for(let t=e.length-1;t>=0;t--){let i=e[t];if(!i)continue;let a=Object.getOwnPropertyNames(i);for(let e=a.length-1;e>=0;e--){let t=a[e];if(t===`__proto__`||t===`constructor`)continue;let o=Object.getOwnPropertyDescriptor(i,t);if(!r[t])r[t]=o.get?{enumerable:!0,configurable:!0,get:Be.bind(n[t]=[o.get.bind(i)])}:o.value===void 0?void 0:o;else{let e=n[t];e&&(o.get?e.push(o.get.bind(i)):o.value!==void 0&&e.push(()=>o.value))}}}let i={},a=Object.keys(r);for(let e=a.length-1;e>=0;e--){let t=a[e],n=r[t];n&&n.get?Object.defineProperty(i,t,n):i[t]=n?n.value:void 0}return i}function He(e,...t){let n=t.length;if(l&&c in e){let r=n>1?t.flat():t[0],i=t.map(t=>new Proxy({get(n){return t.includes(n)?e[n]:void 0},has(n){return t.includes(n)&&n in e},keys(){return t.filter(t=>t in e)}},Re));return i.push(new Proxy({get(t){return r.includes(t)?void 0:e[t]},has(t){return!r.includes(t)&&t in e},keys(){return Object.keys(e).filter(e=>!r.includes(e))}},Re)),i}let r=[];for(let e=0;e<=n;e++)r[e]={};for(let i of Object.getOwnPropertyNames(e)){let a=n;for(let e=0;e<t.length;e++)if(t[e].includes(i)){a=e;break}let o=Object.getOwnPropertyDescriptor(e,i);!o.get&&!o.set&&o.enumerable&&o.writable&&o.configurable?r[a][i]=o.value:Object.defineProperty(r[a],i,o)}return r}var Ue=e=>`Stale read from <${e}>.`;function We(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return k(Fe(()=>e.each,e.children,t||void 0))}function Ge(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return k(Ie(()=>e.each,e.children,t||void 0))}function M(e){let t=e.keyed,n=k(()=>e.when,void 0,void 0),r=t?n:k(n,void 0,{equals:(e,t)=>!e==!t});return k(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?ne(()=>a(t?i:()=>{if(!ne(r))throw Ue(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var Ke=new Set([`className`,`value`,`readOnly`,`noValidate`,`formNoValidate`,`isMap`,`noModule`,`playsInline`,`adAuctionHeaders`,`allowFullscreen`,`browsingTopics`,`defaultChecked`,`defaultMuted`,`defaultSelected`,`disablePictureInPicture`,`disableRemotePlayback`,`preservesPitch`,`shadowRootClonable`,`shadowRootCustomElementRegistry`,`shadowRootDelegatesFocus`,`shadowRootSerializable`,`sharedStorageWritable`,...`allowfullscreen.async.alpha.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.hidden.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.adauctionheaders.browsingtopics.credentialless.defaultchecked.defaultmuted.defaultselected.defer.disablepictureinpicture.disableremoteplayback.preservespitch.shadowrootclonable.shadowrootcustomelementregistry.shadowrootdelegatesfocus.shadowrootserializable.sharedstoragewritable`.split(`.`)]),qe=new Set([`innerHTML`,`textContent`,`innerText`,`children`]),Je=Object.assign(Object.create(null),{className:`class`,htmlFor:`for`}),Ye=Object.assign(Object.create(null),{class:`className`,novalidate:{$:`noValidate`,FORM:1},formnovalidate:{$:`formNoValidate`,BUTTON:1,INPUT:1},ismap:{$:`isMap`,IMG:1},nomodule:{$:`noModule`,SCRIPT:1},playsinline:{$:`playsInline`,VIDEO:1},readonly:{$:`readOnly`,INPUT:1,TEXTAREA:1},adauctionheaders:{$:`adAuctionHeaders`,IFRAME:1},allowfullscreen:{$:`allowFullscreen`,IFRAME:1},browsingtopics:{$:`browsingTopics`,IMG:1},defaultchecked:{$:`defaultChecked`,INPUT:1},defaultmuted:{$:`defaultMuted`,AUDIO:1,VIDEO:1},defaultselected:{$:`defaultSelected`,OPTION:1},disablepictureinpicture:{$:`disablePictureInPicture`,VIDEO:1},disableremoteplayback:{$:`disableRemotePlayback`,AUDIO:1,VIDEO:1},preservespitch:{$:`preservesPitch`,AUDIO:1,VIDEO:1},shadowrootclonable:{$:`shadowRootClonable`,TEMPLATE:1},shadowrootdelegatesfocus:{$:`shadowRootDelegatesFocus`,TEMPLATE:1},shadowrootserializable:{$:`shadowRootSerializable`,TEMPLATE:1},sharedstoragewritable:{$:`sharedStorageWritable`,IFRAME:1,IMG:1}});function Xe(e,t){let n=Ye[e];return typeof n==`object`?n[t]?n.$:void 0:n}var Ze=new Set([`beforeinput`,`click`,`dblclick`,`contextmenu`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mousemove`,`mouseout`,`mouseover`,`mouseup`,`pointerdown`,`pointermove`,`pointerout`,`pointerover`,`pointerup`,`touchend`,`touchmove`,`touchstart`]),Qe={xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`},$e=e=>k(()=>e());function et(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null)if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&!((d=l.get(t[c]))==null||d!==r+u);)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++;else t[o++].remove()}}}var tt=`_$DX_DELEGATE`;function nt(e,t,n,r={}){let i;return w(r=>{i=r,t===document?e():P(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function N(e,t,n,r){let i,a=()=>{let t=r?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},o=t?()=>ne(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function rt(e,t=window.document){let n=t[tt]||(t[tt]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,yt))}}function it(e,t,n){ht(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function at(e,t,n,r){ht(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function ot(e,t,n){ht(e)||(n?e.setAttribute(t,``):e.removeAttribute(t))}function st(e,t){ht(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function ct(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function lt(e,t,n={}){let r=Object.keys(t||{}),i=Object.keys(n),a,o;for(a=0,o=i.length;a<o;a++){let r=i[a];!r||r===`undefined`||t[r]||(_t(e,r,!1),delete n[r])}for(a=0,o=r.length;a<o;a++){let i=r[a],o=!!t[i];!i||i===`undefined`||n[i]===o||!o||(_t(e,i,!0),n[i]=o)}return n}function ut(e,t,n){if(!t)return n?it(e,`style`):t;let r=e.style;if(typeof t==`string`)return r.cssText=t;typeof n==`string`&&(r.cssText=n=void 0),n||={},t||={};let i,a;for(a in n)t[a]??r.removeProperty(a),delete n[a];for(a in t)i=t[a],i!==n[a]&&(r.setProperty(a,i),n[a]=i);return n}function dt(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function ft(e,t={},n,r){let i={};return r||D(()=>i.children=bt(e,t.children,i.children)),D(()=>typeof t.ref==`function`&&pt(t.ref,e)),D(()=>mt(e,t,n,!0,i,!0)),i}function pt(e,t,n){return ne(()=>e(t,n))}function P(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return bt(e,t,r,n);D(r=>bt(e,t(),r,n),r)}function mt(e,t,n,r,i={},a=!1){t||={};for(let r in i)if(!(r in t)){if(r===`children`)continue;i[r]=vt(e,r,null,i[r],n,a,t)}for(let o in t){if(o===`children`){r||bt(e,t.children);continue}let s=t[o];i[o]=vt(e,o,s,i[o],n,a,t)}}function ht(e){return!!i.context&&!i.done&&(!e||e.isConnected)}function gt(e){return e.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function _t(e,t,n){let r=t.trim().split(/\s+/);for(let t=0,i=r.length;t<i;t++)e.classList.toggle(r[t],n)}function vt(e,t,n,r,i,a,o){let s,c,l,u,d;if(t===`style`)return ut(e,n,r);if(t===`classList`)return lt(e,n,r);if(n===r)return r;if(t===`ref`)a||n(e);else if(t.slice(0,3)===`on:`){let i=t.slice(3);r&&e.removeEventListener(i,r,typeof r!=`function`&&r),n&&e.addEventListener(i,n,typeof n!=`function`&&n)}else if(t.slice(0,10)===`oncapture:`){let i=t.slice(10);r&&e.removeEventListener(i,r,!0),n&&e.addEventListener(i,n,!0)}else if(t.slice(0,2)===`on`){let i=t.slice(2).toLowerCase(),a=Ze.has(i);if(!a&&r){let t=Array.isArray(r)?r[0]:r;e.removeEventListener(i,t)}(a||n)&&(ct(e,i,n,a),a&&rt([i]))}else if(t.slice(0,5)===`attr:`)it(e,t.slice(5),n);else if(t.slice(0,5)===`bool:`)ot(e,t.slice(5),n);else if((d=t.slice(0,5)===`prop:`)||(l=qe.has(t))||!i&&((u=Xe(t,e.tagName))||(c=Ke.has(t)))||(s=e.nodeName.includes(`-`)||`is`in o)){if(d)t=t.slice(5),c=!0;else if(ht(e))return n;t===`class`||t===`className`?st(e,n):s&&!c&&!l?e[gt(t)]=n:e[u||t]=n}else{let r=i&&t.indexOf(`:`)>-1&&Qe[t.split(`:`)[0]];r?at(e,r,t,n):it(e,Je[t]||t,n)}return n}function yt(e){if(i.registry&&i.events&&i.events.find(([t,n])=>n===e))return;let t=e.target,n=`$$${e.type}`,r=e.target,a=e.currentTarget,o=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{let r=t[n];if(r&&!t.disabled){let i=t[`${n}Data`];if(i===void 0?r.call(t,e):r.call(t,i,e),e.cancelBubble)return}return t.host&&typeof t.host!=`string`&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},c=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),i.registry&&!i.done&&(i.done=_$HY.done=!0),e.composedPath){let n=e.composedPath();o(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,c();break}if(t.parentNode===a)break}}else c();o(r)}function bt(e,t,n,r,i){let a=ht(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let o=typeof t,s=r!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o===`string`||o===`number`){if(a||o===`number`&&(t=t.toString(),t===n))return n;if(s){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Ct(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||o===`boolean`){if(a)return n;n=Ct(e,n,r)}else if(o===`function`)return D(()=>{let i=t();for(;typeof i==`function`;)i=i();n=bt(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(xt(o,t,n,i))return D(()=>n=bt(e,o,n,r,!0)),()=>n;if(a){if(!o.length)return n;if(r===void 0)return n=[...e.childNodes];let t=o[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(o.length===0){if(n=Ct(e,n,r),s)return n}else c?n.length===0?St(e,o,r):et(e,n,o):(n&&Ct(e),St(e,o));n=o}else if(t.nodeType){if(a&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=Ct(e,n,r,t);Ct(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function xt(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(!(o==null||o===!0||o===!1))if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=xt(e,o,s)||i;else if(c===`function`)if(r){for(;typeof o==`function`;)o=o();i=xt(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0;else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}return i}function St(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Ct(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}var wt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Tt=new class extends wt{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Et={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Dt=new class{#e=Et;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Ot(e){setTimeout(e,0)}var kt=typeof window>`u`||`Deno`in globalThis;function At(){}function jt(e,t){return typeof e==`function`?e(t):e}function Mt(e){return typeof e==`number`&&e>=0&&e!==1/0}function Nt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Pt(e,t){return typeof e==`function`?e(t):e}function Ft(e,t){return typeof e==`function`?e(t):e}function It(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Rt(o,t.options))return!1}else if(!Bt(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Lt(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(zt(t.options.mutationKey)!==zt(a))return!1}else if(!Bt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Rt(e,t){return(t?.queryKeyHashFn||zt)(e)}function zt(e){return JSON.stringify(e,(e,t)=>Gt(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Bt(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Bt(e[n],t[n])):!1}var Vt=Object.prototype.hasOwnProperty;function Ht(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Wt(e)&&Wt(t);if(!r&&!(Gt(e)&&Gt(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Vt.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Ht(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Ut(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Wt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Gt(e){if(!Kt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Kt(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Kt(e){return Object.prototype.toString.call(e)===`[object Object]`}function qt(e){return new Promise(t=>{Dt.setTimeout(t,e)})}function Jt(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ht(e,t)}function Yt(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Xt(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Zt=Symbol();function Qt(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Zt?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function $t(e,t){return typeof e==`function`?e(...t):!!e}function en(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var tn=(()=>{let e=()=>kt;return{isServer(){return e()},setIsServer(t){e=t}}})();function nn(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}function rn(e){let t;if(e.then(e=>(t=e,e),At)?.catch(At),t!==void 0)return{data:t}}function an(e){return e}function on(e,t,n){if(typeof t!=`object`||!t)return;let r=e.getMutationCache(),i=e.getQueryCache(),a=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??an,o=t.mutations||[],s=t.queries||[];o.forEach(({state:t,...i})=>{r.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...i},t)}),s.forEach(({queryKey:t,state:r,queryHash:o,meta:s,promise:c,dehydratedAt:l,queryType:u})=>{let d=c?rn(c):void 0,f=r.data===void 0?d?.data:r.data,p=f===void 0?f:a(f),m=i.get(o),h=m?.state.status===`pending`,g=m?.state.fetchStatus===`fetching`;if(m){let e=d&&l!==void 0&&l>m.state.dataUpdatedAt;if(r.dataUpdatedAt>m.state.dataUpdatedAt||e){let{fetchStatus:e,...t}=r;m.setState({...t,data:p,...r.status===`pending`&&p!==void 0&&{status:`success`,dataUpdatedAt:l??Date.now(),...!g&&{fetchStatus:`idle`}}})}}else m=i.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:t,queryHash:o,meta:s,_type:u},{...r,data:p,fetchStatus:`idle`,status:r.status===`pending`&&p!==void 0?`success`:r.status,...r.status===`pending`&&p!==void 0&&{dataUpdatedAt:l??Date.now()}});c&&!d&&!h&&!g&&(l===void 0||l>m.state.dataUpdatedAt)&&m.fetch(void 0,{initialPromise:Promise.resolve(c).then(a)}).catch(At)})}var sn=Ot;function cn(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=sn,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ln=cn(),un=new class extends wt{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function dn(e){return Math.min(1e3*2**e,3e4)}function fn(e){return(e??`online`)!==`online`||un.isOnline()}var pn=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function mn(e){let t=!1,n=0,r,i=nn(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new pn(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Tt.isFocused()&&(e.networkMode===`always`||un.isOnline())&&e.canRun(),u=()=>fn(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(tn.isServer()?0:3),o=e.retryDelay??dn,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),qt(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var hn=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Mt(this.gcTime)&&(this.#e=Dt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(tn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Dt.clearTimeout(this.#e),this.#e=void 0)}};function gn(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{en(e,()=>t.signal,()=>n=!0)},u=Qt(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Xt:Yt;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?vn:_n,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:_n(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function _n(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function vn(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var yn=class extends hn{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Sn(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Sn(this.options);e.data!==void 0&&(this.setState(xn(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Jt(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(At).catch(At):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Ft(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Zt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Pt(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Nt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Qt(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?gn(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=mn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof pn&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof pn){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...bn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...xn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ln.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function bn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:fn(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function xn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Sn(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Cn=class extends wt{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=nn(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Tn(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return En(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return En(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Ft(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Ut(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Dn(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Ft(this.options.enabled,this.#t)!==Ft(t.enabled,this.#t)||Pt(this.options.staleTime,this.#t)!==Pt(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Ft(this.options.enabled,this.#t)!==Ft(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return kn(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(At)),t}#g(){this.#b();let e=Pt(this.options.staleTime,this.#t);if(tn.isServer()||this.#r.isStale||!Mt(e))return;let t=Nt(this.#r.dataUpdatedAt,e)+1;this.#d=Dt.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(tn.isServer()||Ft(this.options.enabled,this.#t)===!1||!Mt(this.#p)||this.#p===0)&&(this.#f=Dt.setInterval(()=>{(this.options.refetchIntervalInBackground||Tt.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Dt.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Dt.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Tn(e,t),o=i&&Dn(e,n,t,r);(a||o)&&(l={...l,...bn(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Jt(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Jt(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:On(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Ft(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=nn();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Ut(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ln.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function wn(e,t){return Ft(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&Ft(t.retryOnMount,e)===!1)}function Tn(e,t){return wn(e,t)||e.state.data!==void 0&&En(e,t,t.refetchOnMount)}function En(e,t,n){if(Ft(t.enabled,e)!==!1&&Pt(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&On(e,t)}return!1}function Dn(e,t,n,r){return(e!==t||Ft(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&On(e,n)}function On(e,t){return Ft(t.enabled,e)!==!1&&e.isStaleByTime(Pt(t.staleTime,e))}function kn(e,t){return!Ut(e.getCurrentResult(),t)}var An=class extends hn{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||jn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=mn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),ln.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function jn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Mn=class extends wt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new An({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Nn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Nn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Nn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Nn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){ln.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Lt(t,e))}findAll(e={}){return this.getAll().filter(t=>Lt(e,t))}notify(e){ln.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return ln.batch(()=>Promise.all(e.map(e=>e.continue().catch(At))))}};function Nn(e){return e.options.scope?.id}var Pn=class extends wt{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Ut(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&zt(t.mutationKey)!==zt(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??jn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){ln.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Fn=class extends wt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Rt(r,t),a=this.get(i);return a||(a=new yn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){ln.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>It(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>It(e,t)):t}notify(e){ln.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ln.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ln.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},In=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Fn,this.#t=e.mutationCache||new Mn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Tt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=un.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Pt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=jt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ln.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;ln.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return ln.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=ln.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(At).catch(At)}invalidateQueries(e,t={}){return ln.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=ln.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(At)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(At)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Pt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(At).catch(At)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(At).catch(At)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return un.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(zt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Bt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(zt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Bt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Rt(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Zt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Ln=Symbol(`store-raw`),Rn=Symbol(`store-node`),zn=Symbol(`store-has`),Bn=Symbol(`store-self`);function Vn(e){let t=e[c];if(!t&&(Object.defineProperty(e,c,{value:t=new Proxy(e,Yn)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function Hn(e){let t;return typeof e==`object`&&!!e&&(e[c]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Un(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Ln])return n;if(!Hn(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=Un(i,t))!==i&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let s=0,c=n.length;s<c;s++)a=n[s],!o[a].get&&(i=e[a],(r=Un(i,t))!==i&&(e[a]=r))}return e}function Wn(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Gn(e,t,n){if(e[t])return e[t];let[r,i]=T(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Kn(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===c||t===Rn?n:(delete n.value,delete n.writable,n.get=()=>e[c][t],n)}function qn(e){oe()&&Gn(Wn(e,Rn),Bn)()}function Jn(e){return qn(e),Reflect.ownKeys(e)}var Yn={get(e,t,n){if(t===Ln)return e;if(t===c)return n;if(t===u)return qn(e),n;let r=Wn(e,Rn),i=r[t],a=i?i():e[t];if(t===Rn||t===zn||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);oe()&&(typeof a!=`function`||Object.prototype.hasOwnProperty.call(e,t))&&!(n&&n.get)&&(a=Gn(r,t,a)())}return Hn(a)?Vn(a):a},has(e,t){return t===Ln||t===c||t===u||t===Rn||t===zn||t===`__proto__`?!0:(oe()&&Gn(Wn(e,zn),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Jn,getOwnPropertyDescriptor:Kn};function Xn(e,t,n,r=!1){if(t===`__proto__`||!r&&e[t]===n)return;let i=e[t],a=e.length;n===void 0?(delete e[t],e[zn]&&e[zn][t]&&i!==void 0&&e[zn][t].$()):(e[t]=n,e[zn]&&e[zn][t]&&i===void 0&&e[zn][t].$());let o=Wn(e,Rn),s;if((s=Gn(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Gn(o,`length`,a))&&s.$(e.length)}(s=o[Bn])&&s.$()}function Zn(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];Qn(i)||Xn(e,i,t[i])}}function Qn(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function $n(e,t){if(typeof t==`function`&&(t=t(e)),t=Un(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){let r=t[n];e[n]!==r&&Xn(e,n,r)}Xn(e,`length`,r)}else Zn(e,t)}function er(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();let a=typeof r,o=Array.isArray(e);if(a===`string`&&(r===`__proto__`||t.length>1&&Qn(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)er(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&er(e,[i].concat(t),n);return}else if(o&&a===`object`){let{from:i=0,to:a=e.length-1,by:o=1}=r;for(let r=i;r<=a;r+=o)er(e,[r].concat(t),n);return}else if(t.length>1){er(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let a=t[0];typeof a==`function`&&(a=a(i,n),a===i)||r===void 0&&a==null||(a=Un(a),r===void 0||Hn(i)&&Hn(a)&&!Array.isArray(a)?Zn(i,a):Xn(e,r,a))}function tr(...[e,t]){let n=Un(e||{}),r=Array.isArray(n),i=Vn(n);function a(...e){A(()=>{r&&e.length===1?$n(n,e[0]):er(n,e)})}return[i,a]}var nr=Symbol(`store-root`);function rr(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ir(e,t,n,r,i){if(rr(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==nr&&(!Hn(e)||!Hn(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Xn(t,n,e);return}if(o){if(e.length&&a.length&&(!r||i&&e[0]&&e[0][i]!=null)){let t,n,o,s,c,l,u,d;for(o=0,s=Math.min(a.length,e.length);o<s&&(a[o]===e[o]||i&&a[o]&&e[o]&&a[o][i]&&a[o][i]===e[o][i]);o++)ir(e[o],a,o,r,i);let f=Array(e.length),p=new Map;for(s=a.length-1,c=e.length-1;s>=o&&c>=o&&(a[s]===e[c]||i&&a[s]&&e[c]&&a[s][i]&&a[s][i]===e[c][i]);s--,c--)f[c]=a[s];if(o>c||o>s){for(n=o;n<=c;n++)Xn(a,n,e[n]);for(;n<e.length;n++)Xn(a,n,f[n]),ir(e[n],a,n,r,i);a.length>e.length&&Xn(a,`length`,e.length);return}for(u=Array(c+1),n=c;n>=o;n--)l=e[n],d=i&&l?l[i]:l,t=p.get(d),u[n]=t===void 0?-1:t,p.set(d,n);for(t=o;t<=s;t++)l=a[t],d=i&&l?l[i]:l,n=p.get(d),n!==void 0&&n!==-1&&(f[n]=a[t],n=u[n],p.set(d,n));for(n=o;n<e.length;n++)n in f?(Xn(a,n,f[n]),ir(e[n],a,n,r,i)):Xn(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)ir(e[t],a,t,r,i);a.length>e.length&&Xn(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)rr(s[t])||ir(e[s[t]],a,s[t],r,i);let c=Object.keys(a);for(let t=0,n=c.length;t<n;t++)e[c[t]]===void 0&&Xn(a,c[t],void 0)}function ar(e,t={}){let{merge:n,key:r=`id`}=t,i=Un(e);return e=>{if(!Hn(e)||!Hn(i))return i;let t=ir(i,{[nr]:e},nr,n,r);return t===void 0?e:t}}var or=ue(void 0),sr=e=>{if(e)return e;let t=de(or);if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t()},cr=e=>(D(t=>(t?.(),e.client.mount(),e.client.unmount.bind(e.client))),ae(()=>e.client.unmount()),j(or.Provider,{value:()=>e.client,get children(){return e.children}})),lr=ue(()=>!1),ur=()=>de(lr);lr.Provider;function dr(e,t,n,r){if(n===!1)return t;if(typeof n==`function`){let r=n(e.data,t.data);return{...t,data:r}}let i=t.data;if(e.data===void 0)try{i=structuredClone(i)}catch{}let a=ar(i,{key:n})(e.data);return{...t,data:a}}var fr=(e,t)=>t;function pr(e,t,n){let r=k(()=>sr(n?.())),i=ur(),a=k(()=>{let t=r().defaultQueryOptions(e());return t._optimisticResults=i()?`isRestoring`:`optimistic`,t.structuralSharing=!1,t}),o=a(),[s,c]=T(new t(r(),a())),l=s().getOptimisticResult(a()),[u,d]=tr(l),f=()=>s().subscribe(e=>{l=e,queueMicrotask(()=>{h&&v()})});function p(e){let t=s().options,n=t.reconcile;d(r=>dr(r,e,n!==void 0&&n,t.queryHash))}function m(){return[()=>u,e=>{let t=Un(u);if(typeof e==`function`&&(e=e(t)),e?.hydrationData){let{hydrationData:t,...n}=e;e=n}p(e)}]}let h=null,g=null,[_,{refetch:v}]=te(()=>{let e=s();return new Promise((t,n)=>{if(g=t,!h&&!i()&&(h=f()),e.updateResult(),l.isError&&!l.isFetching&&!i()&&$t(e.options.throwOnError,[l.error,e.getCurrentQuery()]))return p(l),n(l.error);if(!l.isLoading)return g=null,t(fr(e.getCurrentQuery(),l));p(l)})},{storage:m,get deferStream(){return e().deferStream},onHydrated(e,t){if(t.value&&`hydrationData`in t.value&&on(r(),{queries:[{...t.value.hydrationData}]}),h)return;let n={...o};(o.staleTime||!o.initialData)&&t.value&&(n.refetchOnMount=!1),s().setOptions(n),p(s().getOptimisticResult(n)),h=f()}});return E(re(r,e=>{h&&h();let n=new t(e,a());h=f(),c(n)},{defer:!0})),E(re(i,e=>{e||v()},{defer:!0})),ae(()=>{h&&=(h(),null),g&&=(g(l),null)}),E(re([s,a],([e,t])=>{e.setOptions(t),p(e.getOptimisticResult(t)),v()},{defer:!0})),new Proxy(u,{get(e,t){return t===`data`?u.data===void 0?_()?.data:_.latest?.data:Reflect.get(e,t)}})}function mr(e,t){return pr(k(()=>e()),Cn,t)}function hr(e,t){let n=new Pn(k(()=>sr(t?.()))(),e()),r=(e,t)=>{n.mutate(e,t).catch(At)},[i,a]=tr({...n.getCurrentResult(),mutate:r,mutateAsync:n.getCurrentResult().mutate});return E(()=>{n.setOptions(e())}),E(re(()=>i.status,()=>{if(i.isError&&$t(n.options.throwOnError,[i.error]))throw i.error})),ae(n.subscribe(e=>{a({...e,mutate:r,mutateAsync:e.mutate})})),i}var gr=class extends In{constructor(e={}){super(e)}},_r=mr,vr=hr,yr,br=t((()=>{yr=typeof chrome<`u`&&!!chrome.runtime?.id&&!!chrome.storage?.local}));function xr(e){for(let t of Fr)t(e)}function Sr(e,t){try{let n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}async function Cr(){return yr?(await chrome.storage.local.get(jr))[jr]??{}:Sr(localStorage,Nr)??{}}async function wr(e){let t={...await Cr(),...e};return yr?await chrome.storage.local.set({[jr]:t}):(localStorage.setItem(Nr,JSON.stringify(t)),xr(`settings`)),t}async function Tr(){if(yr){let e=(await chrome.storage.session.get(Mr))[Mr]??null;if(!e?.length)return e;let t=await chrome.storage.session.get(e.map(e=>Lr(e.grabbedAt)));return e.map(e=>({...e,screenshotDataUrl:t[Lr(e.grabbedAt)]??void 0}))}let e=Sr(sessionStorage,Pr);return e?.length?e.map(e=>({...e,screenshotDataUrl:sessionStorage.getItem(Lr(e.grabbedAt))??void 0})):e}async function Er(e){let t=e.map(({screenshotDataUrl:e,...t})=>t);if(yr){let n={};for(let t of e)t.screenshotDataUrl&&(n[Lr(t.grabbedAt)]=t.screenshotDataUrl);await chrome.storage.session.set({[Mr]:t,...n})}else{for(let t of e)if(t.screenshotDataUrl)try{sessionStorage.setItem(Lr(t.grabbedAt),t.screenshotDataUrl)}catch{}let n=new Set(t.map(e=>Lr(e.grabbedAt)));for(let e=sessionStorage.length-1;e>=0;e--){let t=sessionStorage.key(e);t?.startsWith(Ir)&&!n.has(t)&&sessionStorage.removeItem(t)}sessionStorage.setItem(Pr,JSON.stringify(t)),xr(`grab`)}}async function Dr(e){let t=[...await Tr()??[]];for(let n of e){let e=t.findIndex(e=>e.grabbedAt===n.grabbedAt);if(e>=0){t[e]={...t[e],...n,screenshotDataUrl:n.screenshotDataUrl??t[e].screenshotDataUrl,source:n.source??t[e].source};continue}if(n.source?.filePath){let e=t.findIndex(e=>e.source?.filePath===n.source.filePath&&e.source?.lineNumber===n.source.lineNumber);if(e>=0){t[e]={...t[e],...n};continue}}t.push(n)}let n=new Set,r=[];for(let e=t.length-1;e>=0;e--){let i=t[e],a=i.source?.filePath?`${i.source.filePath}:${i.source.lineNumber??``}`:`id:${i.grabbedAt}`;n.has(a)||(n.add(a),r.unshift(i))}await Er(r.slice(-8))}async function Or(e){await Er((await Tr()??[]).filter(t=>t.grabbedAt!==e))}async function kr(){yr?await chrome.storage.session.remove(Mr):(sessionStorage.removeItem(Pr),xr(`grab`))}function Ar(e){if(yr){let t=(t,n)=>{n===`local`&&e(`settings`),n===`session`&&e(`grab`)};return chrome.storage.onChanged.addListener(t),()=>chrome.storage.onChanged.removeListener(t)}return Fr.add(e),()=>Fr.delete(e)}var jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr=t((()=>{br(),jr=`settings`,Mr=`lastGrab`,Nr=`linear-grab:settings`,Pr=`linear-grab:last-grab`,Fr=new Set,Ir=`linear-grab:shot:`,Lr=e=>`${Ir}${e}`}));function zr(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}function Br(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?!0:Array.isArray(e)?e.every(Br):typeof e==`object`&&Object.entries(e).every(([e,t])=>typeof e==`string`&&(t===void 0||Br(t)))}function Vr(e){return Array.isArray(e)&&e.every(Br)}function Hr(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&(t===void 0||Br(t)))}var Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma=t((()=>{Ur=`vercel.ai.error`,Wr=Symbol.for(Ur),qr=class e extends (Kr=Error,Gr=Wr,Kr){constructor({name:e,message:t,cause:n}){super(t),this[Gr]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Ur)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},Jr=`AI_APICallError`,Yr=`vercel.ai.error.${Jr}`,Xr=Symbol.for(Yr),$r=class extends (Qr=qr,Zr=Xr,Qr){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:Jr,message:e,cause:o}),this[Zr]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return qr.hasMarker(e,Yr)}},ei=`AI_EmptyResponseBodyError`,ti=`vercel.ai.error.${ei}`,ni=Symbol.for(ti),ai=class extends (ii=qr,ri=ni,ii){constructor({message:e=`Empty response body`}={}){super({name:ei,message:e}),this[ri]=!0}static isInstance(e){return qr.hasMarker(e,ti)}},oi=`AI_InvalidArgumentError`,si=`vercel.ai.error.${oi}`,ci=Symbol.for(si),di=class extends (ui=qr,li=ci,ui){constructor({message:e,cause:t,argument:n}){super({name:oi,message:e,cause:t}),this[li]=!0,this.argument=n}static isInstance(e){return qr.hasMarker(e,si)}},fi=`AI_InvalidPromptError`,pi=`vercel.ai.error.${fi}`,mi=Symbol.for(pi),_i=class extends (gi=qr,hi=mi,gi){constructor({prompt:e,message:t,cause:n}){super({name:fi,message:`Invalid prompt: ${t}`,cause:n}),this[hi]=!0,this.prompt=e}static isInstance(e){return qr.hasMarker(e,pi)}},vi=`AI_InvalidResponseDataError`,yi=`vercel.ai.error.${vi}`,bi=Symbol.for(yi),Ci=class extends (Si=qr,xi=bi,Si){constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:vi,message:t}),this[xi]=!0,this.data=e}static isInstance(e){return qr.hasMarker(e,yi)}},wi=`AI_JSONParseError`,Ti=`vercel.ai.error.${wi}`,Ei=Symbol.for(Ti),ki=class extends (Oi=qr,Di=Ei,Oi){constructor({text:e,cause:t}){super({name:wi,message:`JSON parsing failed: Text: ${e}.
|
|
2
2
|
Error message: ${zr(t)}`,cause:t}),this[Di]=!0,this.text=e}static isInstance(e){return qr.hasMarker(e,Ti)}},Ai=`AI_LoadAPIKeyError`,ji=`vercel.ai.error.${Ai}`,Mi=Symbol.for(ji),Fi=class extends (Pi=qr,Ni=Mi,Pi){constructor({message:e}){super({name:Ai,message:e}),this[Ni]=!0}static isInstance(e){return qr.hasMarker(e,ji)}},Ii=`AI_LoadSettingError`,`${Ii}`,Li=`AI_NoContentGeneratedError`,`${Li}`,Ri=`AI_NoSuchModelError`,zi=`vercel.ai.error.${Ri}`,Bi=Symbol.for(zi),Ui=class extends (Hi=qr,Vi=Bi,Hi){constructor({errorName:e=Ri,modelId:t,modelType:n,message:r=`No such ${n}: ${t}`}){super({name:e,message:r}),this[Vi]=!0,this.modelId=t,this.modelType=n}static isInstance(e){return qr.hasMarker(e,zi)}},Wi=`AI_NoSuchProviderReferenceError`,Gi=`vercel.ai.error.${Wi}`,Ki=Symbol.for(Gi),Yi=class extends (Ji=qr,qi=Ki,Ji){constructor({provider:e,reference:t,message:n=`No provider reference found for provider '${e}'. Available providers: ${Object.keys(t).join(`, `)}`}){super({name:Wi,message:n}),this[qi]=!0,this.provider=e,this.reference=t}static isInstance(e){return qr.hasMarker(e,Gi)}},Xi=`AI_TooManyEmbeddingValuesForCallError`,Zi=`vercel.ai.error.${Xi}`,Qi=Symbol.for(Zi),ta=class extends (ea=qr,$i=Qi,ea){constructor(e){super({name:Xi,message:`Too many values for a single embedding call. The ${e.provider} model "${e.modelId}" can only embed up to ${e.maxEmbeddingsPerCall} values per call, but ${e.values.length} values were provided.`}),this[$i]=!0,this.provider=e.provider,this.modelId=e.modelId,this.maxEmbeddingsPerCall=e.maxEmbeddingsPerCall,this.values=e.values}static isInstance(e){return qr.hasMarker(e,Zi)}},na=`AI_TypeValidationError`,ra=`vercel.ai.error.${na}`,ia=Symbol.for(ra),sa=class e extends (oa=qr,aa=ia,oa){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:na,message:`${r}: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${zr(t)}`,cause:t}),this[aa]=!0,this.value=e,this.context=n}static isInstance(e){return qr.hasMarker(e,ra)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},ca=`AI_UnsupportedFunctionalityError`,la=`vercel.ai.error.${ca}`,ua=Symbol.for(la),pa=class extends (fa=qr,da=ua,fa){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:ca,message:t}),this[da]=!0,this.functionality=e}static isInstance(e){return qr.hasMarker(e,la)}}}));function F(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}function ha(e){return e&&Object.assign(_a,e),_a}var ga,_a,va=t((()=>{Object.freeze({status:`aborted`}),ga=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},_a={}}));function ya(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ba(e,t){return typeof t==`bigint`?t.toString():t}function xa(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Sa(e){return e==null}function Ca(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function wa(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function Ta(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}throw Error(`cached value already set`)},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ea(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Da(e){return JSON.stringify(e)}function Oa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ka(e){if(Oa(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(Oa(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Aa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ja(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Ma(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Na(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}function Pa(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return ja(e,{...e._zod.def,shape:n,checks:[]})}function Fa(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return ja(e,{...e._zod.def,shape:n,checks:[]})}function Ia(e,t){if(!ka(t))throw Error(`Invalid input to extend: expected a plain object`);return ja(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Ea(this,`shape`,n),n},checks:[]})}function La(e,t){return ja(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Ea(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function Ra(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ja(t,{...t._zod.def,shape:i,checks:[]})}function za(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ja(t,{...t._zod.def,shape:i,checks:[]})}function Ba(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Va(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ha(e){return typeof e==`string`?e:e?.message}function Ua(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Ha(e.inst?._zod.def?.error?.(e))??Ha(t?.error?.(e))??Ha(n.customError?.(e))??Ha(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Wa(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ga(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Ka,qa,Ja,Ya,Xa=t((()=>{Ka=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{},qa=xa(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),Ja=new Set([`string`,`number`,`symbol`]),Ya={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}}));function Za(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Qa(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var $a,eo,to,no=t((()=>{va(),Xa(),$a=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,ba,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},eo=F(`$ZodError`,$a),to=F(`$ZodError`,$a,{Parent:Error})})),ro,io,ao,oo,so,co,lo=t((()=>{va(),no(),Xa(),ro=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new ga;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Ua(e,a,ha())));throw Ka(t,i?.callee),t}return o.value},io=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Ua(e,a,ha())));throw Ka(t,i?.callee),t}return o.value},ao=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ga;return a.issues.length?{success:!1,error:new(e??eo)(a.issues.map(e=>Ua(e,i,ha())))}:{success:!0,data:a.value}},oo=ao(to),so=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Ua(e,i,ha())))}:{success:!0,data:a.value}},co=so(to)}));function uo(){return new RegExp(To,`u`)}function fo(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function po(e){return RegExp(`^${fo(e)}$`)}function mo(e){let t=fo({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Po}T(?:${r})$`)}var ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo=t((()=>{ho=/^[cC][^\s-]{8,}$/,go=/^[0-9a-z]+$/,_o=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,vo=/^[0-9a-vA-V]{20}$/,yo=/^[A-Za-z0-9]{27}$/,bo=/^[a-zA-Z0-9_-]{21}$/,xo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,So=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Co=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,wo=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,To=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Eo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Do=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Oo=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ko=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ao=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jo=/^[A-Za-z0-9_-]*$/,Mo=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,No=/^\+(?:[0-9]){6,14}[0-9]$/,Po=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Fo=RegExp(`^${Po}$`),Io=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Lo=/^\d+$/,Ro=/^-?\d+(?:\.\d+)?/i,zo=/true|false/i,Bo=/null/i,Vo=/^[^A-Z]*$/,Ho=/^[^a-z]*$/})),Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss=t((()=>{va(),Uo(),Xa(),Wo=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Go={number:`number`,bigint:`bigint`,object:`date`},Ko=F(`$ZodCheckLessThan`,(e,t)=>{Wo.init(e,t);let n=Go[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qo=F(`$ZodCheckGreaterThan`,(e,t)=>{Wo.init(e,t);let n=Go[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jo=F(`$ZodCheckMultipleOf`,(e,t)=>{Wo.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):wa(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Yo=F(`$ZodCheckNumberFormat`,(e,t)=>{Wo.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ya[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Lo)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Xo=F(`$ZodCheckMaxLength`,(e,t)=>{var n;Wo.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sa(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Wa(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Zo=F(`$ZodCheckMinLength`,(e,t)=>{var n;Wo.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sa(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Wa(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qo=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;Wo.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sa(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Wa(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$o=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Wo.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),es=F(`$ZodCheckRegex`,(e,t)=>{$o.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ts=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Vo,$o.init(e,t)}),ns=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ho,$o.init(e,t)}),rs=F(`$ZodCheckIncludes`,(e,t)=>{Wo.init(e,t);let n=Aa(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),is=F(`$ZodCheckStartsWith`,(e,t)=>{Wo.init(e,t);let n=RegExp(`^${Aa(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),as=F(`$ZodCheckEndsWith`,(e,t)=>{Wo.init(e,t);let n=RegExp(`.*${Aa(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),os=F(`$ZodCheckOverwrite`,(e,t)=>{Wo.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),cs,ls=t((()=>{cs=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
4
4
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
@@ -177,7 +177,7 @@ of the other sections.`,pD="- FIRST, self-orient in the repo checkout (skip any
|
|
|
177
177
|
`).slice(-n).join(`
|
|
178
178
|
`).trim();return i.length>WO&&(i=`…\n${i.slice(i.length-WO)}`),i||null}finally{clearTimeout(i)}}var qO=50,JO=[],YO=!1;function XO(e){if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e==`object`&&e)try{return JSON.stringify(e).slice(0,400)}catch{return String(e)}return String(e)}function ZO(e,t){let n=t.map(XO).join(` `).slice(0,600);n.trim()&&(JO.push({at:Date.now(),level:e,text:n}),JO.length>qO&&JO.shift())}function QO(){if(YO||typeof window>`u`)return;YO=!0;let e=console.error.bind(console);console.error=(...t)=>{ZO(`error`,t),e(...t)};let t=console.warn.bind(console);console.warn=(...e)=>{ZO(`warn`,e),t(...e)},window.addEventListener(`error`,e=>{ZO(`error`,[`${e.message}${e.filename?` (${e.filename}:${e.lineno})`:``}`])}),window.addEventListener(`unhandledrejection`,e=>{let t=e.reason;ZO(`unhandled`,[t?.stack??String(e.reason??`unhandled rejection`)])})}function $O(e=30){return JO.slice(-e)}function ek(e=30){let t=$O(e);if(!t.length)return null;let n=t.map(e=>`[${new Date(e.at).toTimeString().slice(0,8)}] ${e.level.toUpperCase()}: ${e.text}`).join(`
|
|
179
179
|
`);return n.length>8e3&&(n=`…\n${n.slice(n.length-8e3)}`),n}function tk(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}var nk=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function rk(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var ik=null;function ak(e={}){return ik||(e.includeStyleProperties?(ik=e.includeStyleProperties,ik):(ik=rk(window.getComputedStyle(document.documentElement)),ik))}function ok(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function sk(e){let t=ok(e,`border-left-width`),n=ok(e,`border-right-width`);return e.clientWidth+t+n}function ck(e){let t=ok(e,`border-top-width`),n=ok(e,`border-bottom-width`);return e.clientHeight+t+n}function lk(e,t={}){return{width:t.width||sk(e),height:t.height||ck(e)}}function uk(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var dk=16384;function fk(e){(e.width>dk||e.height>dk)&&(e.width>dk&&e.height>dk?e.width>e.height?(e.height*=dk/e.width,e.width=dk):(e.width*=dk/e.height,e.height=dk):e.width>dk?(e.height*=dk/e.width,e.width=dk):(e.width*=dk/e.height,e.height=dk))}function pk(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function mk(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function hk(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),mk(i)}var gk=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||gk(n,t)};function _k(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function vk(e,t){return ak(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function yk(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?_k(n):vk(n,r);return document.createTextNode(`${i}{${a}}`)}function bk(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=nk();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(yk(o,n,i,r)),t.appendChild(s)}function xk(e,t,n){bk(e,t,`:before`,n),bk(e,t,`:after`,n)}var Sk=`application/font-woff`,Ck=`image/jpeg`,wk={woff:Sk,woff2:Sk,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:Ck,jpeg:Ck,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function Tk(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function Ek(e){return wk[Tk(e).toLowerCase()]||``}function Dk(e){return e.split(/,/)[1]}function Ok(e){return e.search(/^(data:)/)!==-1}function kk(e,t){return`data:${t};base64,${e}`}async function Ak(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}var jk={};function Mk(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function Nk(e,t,n){let r=Mk(e,t,n.includeQueryParams);if(jk[r]!=null)return jk[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=kk(await Ak(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,Dk(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return jk[r]=i,i}async function Pk(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):pk(t)}async function Fk(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),pk(t.toDataURL())}let n=e.poster;return pk(await Nk(n,Ek(n),t))}async function Ik(e,t){try{if(e?.contentDocument?.body)return await Kk(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function Lk(e,t){return gk(e,HTMLCanvasElement)?Pk(e):gk(e,HTMLVideoElement)?Fk(e,t):gk(e,HTMLIFrameElement)?Ik(e,t):e.cloneNode(zk(e))}var Rk=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,zk=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function Bk(e,t,n){if(zk(t))return t;let r=[];return r=Rk(e)&&e.assignedNodes?rk(e.assignedNodes()):gk(e,HTMLIFrameElement)&&e.contentDocument?.body?rk(e.contentDocument.body.childNodes):rk((e.shadowRoot??e).childNodes),r.length===0||gk(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>Kk(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function Vk(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):ak(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),gk(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function Hk(e,t){gk(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),gk(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function Uk(e,t){if(gk(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function Wk(e,t,n){return gk(t,Element)&&(Vk(e,t,n),xk(e,t,n),Hk(e,t),Uk(e,t)),t}async function Gk(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await Kk(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function Kk(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>Lk(e,t)).then(n=>Bk(e,n,t)).then(n=>Wk(e,n,t)).then(e=>Gk(e,t))}var qk=/url\((['"]?)([^'"]+?)\1\)/g,Jk=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Yk=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Xk(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function Zk(e){let t=[];return e.replace(qk,(e,n,r)=>(t.push(r),e)),t.filter(e=>!Ok(e))}async function Qk(e,t,n,r,i){try{let a=n?tk(t,n):t,o=Ek(t),s;return s=i?kk(await i(a),o):await Nk(a,o,r),e.replace(Xk(t),`$1${s}$3`)}catch{}return e}function $k(e,{preferredFontFormat:t}){return t?e.replace(Yk,e=>{for(;;){let[n,,r]=Jk.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function eA(e){return e.search(qk)!==-1}async function tA(e,t,n){if(!eA(e))return e;let r=$k(e,n);return Zk(r).reduce((e,r)=>e.then(e=>Qk(e,r,t,n)),Promise.resolve(r))}async function nA(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await tA(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function rA(e,t){await nA(`background`,e,t)||await nA(`background-image`,e,t),await nA(`mask`,e,t)||await nA(`-webkit-mask`,e,t)||await nA(`mask-image`,e,t)||await nA(`-webkit-mask-image`,e,t)}async function iA(e,t){let n=gk(e,HTMLImageElement);if(!(n&&!Ok(e.src))&&!(gk(e,SVGImageElement)&&!Ok(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await Nk(r,Ek(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function aA(e,t){let n=rk(e.childNodes).map(e=>oA(e,t));await Promise.all(n).then(()=>e)}async function oA(e,t){gk(e,Element)&&(await rA(e,t),await iA(e,t),await aA(e,t))}function sA(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}var cA={};async function lA(e){let t=cA[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},cA[e]=t,t)}async function uA(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),Ak(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function dA(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function fA(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{rk(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=lA(o).then(e=>uA(e,t)).then(e=>dA(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(lA(n.href).then(e=>uA(e,t)).then(e=>dA(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{rk(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function pA(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>eA(e.style.getPropertyValue(`src`)))}async function mA(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return pA(await fA(rk(e.ownerDocument.styleSheets),t))}function hA(e){return e.trim().replace(/["']/g,``)}function gA(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(hA(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function _A(e,t){let n=await mA(e,t),r=gA(e);return(await Promise.all(n.filter(e=>r.has(hA(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return tA(e.cssText,n,t)}))).join(`
|
|
180
|
-
`)}async function vA(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await _A(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function yA(e,t={}){let{width:n,height:r}=lk(e,t),i=await Kk(e,t,!0);return await vA(i,t),await oA(i,t),sA(i,t),await hk(i,n,r)}async function bA(e,t={}){let{width:n,height:r}=lk(e,t),i=await pk(await yA(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||uk(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||fk(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}async function xA(e,t={}){return _A(e,t)}var SA=6,CA=class{last=performance.now();async tick(){performance.now()-this.last<=SA||(await new Promise(e=>{`requestIdleCallback`in window?requestIdleCallback(()=>e(),{timeout:100}):setTimeout(e,0)}),this.last=performance.now())}},wA=null,TA=new Map;function EA(e){let t=TA.get(e);if(t)return t;if(!wA){let e=document.createElement(`iframe`);if(e.style.cssText=`position:absolute;width:0;height:0;border:0;visibility:hidden`,document.body.appendChild(e),wA=e.contentDocument,!wA)return{}}let n=wA.createElement(e);wA.body.appendChild(n);let r=wA.defaultView.getComputedStyle(n),i={};for(let e=0;e<r.length;e++){let t=r[e];i[t]=r.getPropertyValue(t)}return n.remove(),TA.set(e,i),i}function DA(){try{for(let e of[`div`,`span`,`p`,`a`,`button`,`img`,`ul`,`li`,`svg`])EA(e)}catch{}}function OA(e){if(e.id===`linear-grab-root`)return!0;let t=e.tagName?.toLowerCase()??``;return t===`overlay-canvas`||t.startsWith(`react-grab`)||t===`script`||t===`iframe`}function kA(e,t){try{let n=document.createElement(`canvas`);n.width=e.naturalWidth||e.width||1,n.height=e.naturalHeight||e.height||1,n.getContext(`2d`).drawImage(e,0,0),t.src=n.toDataURL(`image/png`)}catch{t.removeAttribute(`src`),t.setAttribute(`style`,`${t.getAttribute(`style`)??``}background:#8b8e9822;`)}}async function AA(e,t){if(OA(e))return null;if(e instanceof SVGSVGElement)return e.cloneNode(!0);let n=e.cloneNode(!1),r=getComputedStyle(e),i=EA(e.tagName.toLowerCase()),a=``;for(let e=0;e<r.length;e++){let t=r[e],n=r.getPropertyValue(t);n&&n!==i[t]&&(a+=`${t}:${n};`)}if(n.setAttribute(`style`,a),n.removeAttribute(`class`),e instanceof HTMLImageElement&&kA(e,n),e instanceof HTMLCanvasElement)try{let t=document.createElement(`img`);return t.setAttribute(`style`,a),t.src=e.toDataURL(),t}catch{}e instanceof HTMLInputElement&&n.setAttribute(`value`,e.value),e instanceof HTMLTextAreaElement&&(n.textContent=e.value),await t.tick();for(let r of Array.from(e.childNodes))if(r.nodeType===Node.TEXT_NODE)n.appendChild(r.cloneNode());else if(r.nodeType===Node.ELEMENT_NODE){let e=await AA(r,t);e&&n.appendChild(e)}return n}async function jA(e,t){let n=e.getBoundingClientRect(),r=Math.max(1,Math.ceil(n.width)),i=Math.max(1,Math.ceil(n.height)),a=await AA(e,new CA);if(!a)throw Error(`Capture root was filtered`);a.style.margin=`0`;let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${i}"><style>${t}</style><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${new XMLSerializer().serializeToString(a)}</div></foreignObject></svg>`,s=URL.createObjectURL(new Blob([o],{type:`image/svg+xml;charset=utf-8`})),c=new Image;c.decoding=`async`,c.src=s;try{await c.decode()}finally{URL.revokeObjectURL(s)}let l=Math.min(window.devicePixelRatio||1,1.5),u=document.createElement(`canvas`);u.width=Math.round(r*l),u.height=Math.round(i*l);let d=u.getContext(`2d`);if(!d)throw Error(`Canvas 2d unavailable`);return d.drawImage(c,0,0,u.width,u.height),u}var MA=null;function NA(e){return MA??=xA(e).catch(()=>``),MA}function PA(){`requestIdleCallback`in window?requestIdleCallback(()=>{DA(),NA(document.body)},{timeout:3e3}):setTimeout(()=>{DA(),NA(document.body)},1500)}var FA=4e3,IA=1e3;async function LA(e){try{if(await new Promise(e=>{requestAnimationFrame(()=>`requestIdleCallback`in window?requestIdleCallback(()=>e(void 0),{timeout:500}):setTimeout(e,80))}),!e.isConnected)return null;let t=BA(e),n=t.querySelectorAll(`*`).length;n>FA&&(t=e);let r;try{r=await jA(t,await NA(t))}catch{t!==e&&n>IA&&(t=e),r=await bA(t,{pixelRatio:Math.min(window.devicePixelRatio||1,1.5),fontEmbedCSS:await NA(t),filter:e=>{if(!(e instanceof Element))return!0;if(e.id===`linear-grab-root`)return!1;let t=e.tagName?.toLowerCase()??``;return!(t===`overlay-canvas`||t.startsWith(`react-grab`))}})}return t!==e&&VA(r,t,e),await zA(r)}catch{return null}}async function RA(e){try{let t=e.x+e.w/2,n=e.y+e.h/2,r=document.elementFromPoint(t,n)??document.body,i=t=>{let n=t.getBoundingClientRect();return n.left<=e.x&&n.top<=e.y&&n.right>=e.x+e.w&&n.bottom>=e.y+e.h};for(;r!==document.body&&(!i(r)||r.querySelectorAll(`*`).length<1);)r=r.parentElement??document.body;let a=await jA(r,await NA(r)),o=r.getBoundingClientRect(),s=a.width/o.width,c=a.height/o.height,l=document.createElement(`canvas`);l.width=Math.max(1,Math.round(e.w*s)),l.height=Math.max(1,Math.round(e.h*c));let u=l.getContext(`2d`);return u?(u.drawImage(a,(e.x-o.left+r.scrollLeft)*s,(e.y-o.top+r.scrollTop)*c,e.w*s,e.h*c,0,0,l.width,l.height),await zA(l)):null}catch{return null}}async function zA(e){try{if(typeof createImageBitmap==`function`&&typeof OffscreenCanvas<`u`){let t=await createImageBitmap(e);return(await jD({type:`encode-png`,bitmap:t},[t])).dataUrl}}catch{}return HA(e)}function BA(e){let t=window.innerWidth,n=window.innerHeight,r=t*n*1.7,i=e,a=e;for(;a&&a!==document.body&&a!==document.documentElement;){let o=a.getBoundingClientRect();if(o.width*o.height>r||a!==e&&(a.scrollTop>0||a.scrollLeft>0)||(i=a,o.width>=t*.55&&o.height>=n*.35))break;a=a.parentElement}return i}function VA(e,t,n){let r=e.getContext(`2d`);if(!r)return;let i=t.getBoundingClientRect(),a=n.getBoundingClientRect();if(!i.width||!i.height)return;let o=e.width/i.width,s=e.height/i.height,c=(a.left-i.left+t.scrollLeft)*o,l=(a.top-i.top+t.scrollTop)*s,u=a.width*o,d=a.height*s,f=Math.min(6*o,u/2,d/2);r.strokeStyle=`rgba(94, 106, 210, 0.35)`,r.lineWidth=8*o,r.beginPath(),r.roundRect(c,l,u,d,f),r.stroke(),r.strokeStyle=`#5e6ad2`,r.lineWidth=3*o,r.beginPath(),r.roundRect(c,l,u,d,f),r.stroke()}function HA(e){let t=e.toDataURL(`image/png`);return t.length<=25e5?t:e.toDataURL(`image/jpeg`,.85)}function UA(e){let[t,n]=e.split(`,`),r=t.match(/data:([^;]+)/)?.[1]??`image/png`,i=atob(n),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return new Blob([a],{type:r})}var[WA,GA]=T(null),[KA,qA]=T(null);function JA(e,t){GA(e),qA(t??null)}function YA(){GA(null),qA(null)}var[XA,ZA]=T(`capture`);function QA(e){ZA(e)}var $A=N(`<span class="absolute inset-0 grid place-items-center">`),ej=N(`<button><span>`),tj=N(`<span role=status aria-label=Loading class="text-text-dim relative inline-block shrink-0">`),nj=N(`<span class="absolute top-0 left-1/2 rounded-full bg-current"style="animation:geist-spinner-fade 1.2s linear infinite;will-change:opacity">`),rj=N(`<input>`),ij=N(`<textarea>`),aj=N(`<select>`),oj=N(`<a target=_blank rel="noopener noreferrer"><span class="min-w-0 truncate"></span><svg width=11 height=11 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden class=shrink-0><path d="M4.5 11.5 11.5 4.5M5.5 4.5h6v6">`),sj=N(`<span class="text-text-faint text-[10.5px] leading-snug">`),cj=N(`<label class="flex flex-col gap-1"><span class="text-text-dim text-[11px] font-medium">`),lj=N(`<section class="flex flex-col gap-2.5"><h2 class="text-text-dim text-[11px] font-semibold tracking-wide uppercase">`),uj=N(`<span>`),dj=N(`<span aria-hidden class="inline-block size-2 shrink-0 rounded-full">`),fj=N(`<div class="flex flex-col items-center gap-1.5 px-4 py-10 text-center"><p class="text-text-dim text-[12px] font-medium"></p><div class="text-text-faint text-[11.5px] leading-relaxed">`),pj=N(`<p class="bg-danger-soft text-danger rounded-md px-2.5 py-1.5 text-[11.5px] leading-snug break-words">`),mj={primary:`bg-accent hover:bg-accent-hover text-white border-transparent disabled:bg-surface-3 disabled:text-text-faint`,ghost:`bg-surface-2 hover:bg-surface-3 text-text border-border disabled:text-text-faint disabled:hover:bg-surface-2`,danger:`bg-danger-soft hover:bg-danger/30 text-danger border-transparent`};function hj(e){let[t,n]=He(e,[`variant`,`loading`,`children`,`class`,`disabled`,`title`]);return(()=>{var e=ej(),r=e.firstChild;return ft(e,Ve(n,{get"data-tip"(){return t.title||void 0},get"aria-label"(){return n[`aria-label`]??t.title},get disabled(){return t.disabled||t.loading},get class(){return`relative inline-flex h-7 cursor-pointer items-center justify-center gap-1.5 rounded-md border px-3 text-[12px] font-medium transition-colors disabled:cursor-not-allowed ${mj[t.variant??`ghost`]} ${t.class??``}`}}),!1,!0),P(r,()=>t.children),P(e,j(M,{get when(){return t.loading},get children(){var e=$A();return P(e,j(gj,{})),e}}),null),D(()=>st(r,`inline-flex items-center gap-1.5 ${t.loading?`invisible`:``}`)),e})()}function gj(e){let t=()=>e.size??14,n=()=>Math.max(1,Math.round(t()*.09)),r=()=>Math.round(t()*.26);return(()=>{var e=tj();return P(e,j(We,{get each(){return Array.from({length:12},(e,t)=>t)},children:e=>(()=>{var i=nj();return dt(i,`transform`,`rotate(${e*30}deg)`),dt(i,`animation-delay`,`${(e-12)*.1}s`),D(e=>{var a=`${n()}px`,o=`${r()}px`,s=`-${n()/2}px`,c=`center ${t()/2}px`;return a!==e.e&&dt(i,`width`,e.e=a),o!==e.t&&dt(i,`height`,e.t=o),s!==e.a&&dt(i,`margin-left`,e.a=s),c!==e.o&&dt(i,`transform-origin`,e.o=c),e},{e:void 0,t:void 0,a:void 0,o:void 0}),i})()})),D(n=>{var r=`${t()}px`,i=`${t()}px`;return r!==n.e&&dt(e,`width`,n.e=r),i!==n.t&&dt(e,`height`,n.t=i),n},{e:void 0,t:void 0}),e})()}function _j(e){let[t,n]=He(e,[`class`]);return(()=>{var e=rj();return ft(e,Ve(n,{get class(){return`bg-surface-2 border-border focus:border-accent placeholder:text-text-faint h-7 w-full rounded-md border px-2 text-[12px] outline-none transition-colors ${t.class??``}`}}),!1,!1),e})()}function vj(e){let[t,n]=He(e,[`class`]);return(()=>{var e=ij();return ft(e,Ve(n,{get class(){return`bg-surface-2 border-border focus:border-accent placeholder:text-text-faint w-full resize-y rounded-md border px-2 py-1.5 text-[12px] leading-relaxed outline-none transition-colors ${t.class??``}`}}),!1,!1),e})()}function yj(e){let[t,n]=He(e,[`class`,`children`]);return(()=>{var e=aj();return ft(e,Ve(n,{get class(){return`bg-surface-2 border-border focus:border-accent h-7 w-full cursor-pointer rounded-md border px-1.5 text-[12px] outline-none ${t.class??``}`}}),!1,!0),P(e,()=>t.children),e})()}function bj(e){return(()=>{var t=oj(),n=t.firstChild;return P(n,()=>e.children),D(n=>{var r=e.href,i=e.title||void 0,a=`text-accent inline-flex min-w-0 items-center gap-1 text-[11px] underline-offset-2 hover:underline ${e.class??``}`;return r!==n.e&&it(t,`href`,n.e=r),i!==n.t&&it(t,`data-tip`,n.t=i),a!==n.a&&st(t,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}function xj(e){return(()=>{var t=cj(),n=t.firstChild;return P(n,()=>e.label),P(t,()=>e.children,null),P(t,j(M,{get when(){return e.hint},get children(){var t=sj();return P(t,()=>e.hint),t}}),null),t})()}function Sj(e){return(()=>{var t=lj(),n=t.firstChild;return P(n,()=>e.title),P(t,()=>e.children,null),t})()}function Cj(e){return(()=>{var t=uj();return P(t,()=>e.children),D(n=>{var r=`bg-surface-3 text-text-dim inline-flex h-[18px] items-center gap-1 rounded-full px-2 text-[10.5px] font-medium whitespace-nowrap ${e.class??``}`,i=e.color?{color:e.color}:void 0;return r!==n.e&&st(t,n.e=r),n.t=ut(t,i,n.t),n},{e:void 0,t:void 0}),t})()}function wj(e){return(()=>{var t=dj();return D(n=>dt(t,`background`,e.color)),t})()}function Tj(e){return(()=>{var t=fj(),n=t.firstChild,r=n.nextSibling;return P(n,()=>e.title),P(r,()=>e.children),t})()}function Ej(e){return(()=>{var t=pj();return P(t,()=>e.message),t})()}var Dj={0:`No priority`,1:`Urgent`,2:`High`,3:`Medium`,4:`Low`};function Oj(e){let t=typeof e==`number`?e:Date.parse(e),n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}Rr(),Nx(),mD();var kj=N(`<span class="truncate font-mono">`),Aj=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden><path d="M5.5 3.5 6.6 2h2.8l1.1 1.5H13A1.5 1.5 0 0 1 14.5 5v7A1.5 1.5 0 0 1 13 13.5H3A1.5 1.5 0 0 1 1.5 12V5A1.5 1.5 0 0 1 3 3.5h2.5Z"></path><circle cx=8 cy=8.2 r=2.4>`),jj=N(`<div class="flex flex-wrap gap-1.5"><span class="text-text-faint self-end text-[10.5px]">attached on create`),Mj=N(`<div class="flex items-center justify-between gap-1.5"><span class="text-text-faint text-[11px]">Model:</span><div class="flex rounded-md border border-border overflow-hidden">`),Nj=N(`<span class="inline-block min-w-[12ch] text-center">`),Pj=N(`<div class="flex justify-end">`),Fj=N(`<div class="flex flex-col gap-1.5">`),Ij=N(`<p class="text-text-faint text-[11px] leading-snug">Primary provider failed — drafted with <span class=text-text-dim></span> (<!>).`),Lj=N(`<div class="border-warn/40 bg-surface rounded-md border px-2.5 py-2"><p class="text-warn mb-1 text-[10.5px] font-semibold tracking-wide uppercase">Possibly related — check before creating`),Rj=N(`<div class="flex flex-col gap-1">`),zj=N(`<option value>Select a team…`),Bj=N(`<option value=cursor> — cloud agent`),Vj=N(`<option value=local>Local Claude Code (bridge)`),Hj=N(`<option value=none>No one — just create the issue`),Uj=N(`<option value>Claude Code default`),Wj=N(`<option value=fable>Fable 5`),Gj=N(`<option value=opus>Opus`),Kj=N(`<option value=sonnet>Sonnet`),qj=N(`<option value=haiku>Haiku`),Jj=N(`<label class="flex cursor-pointer items-center gap-2 select-none"><input type=checkbox class="accent-accent rounded"><span class="text-text text-[12px]">Isolated worktree <span class=text-text-dim>— own branch, run agents in parallel safely`),Yj=N(`<label class="flex items-center gap-2 cursor-pointer select-none"><input type=checkbox class="rounded accent-accent"><span class="text-[12px] text-text">Attach console errors <span class="text-text-dim tabular-nums">(<!> captured)`),Xj=N(`<label class="flex items-center gap-2 cursor-pointer select-none"><input type=checkbox class="rounded accent-accent"><span class="text-[12px] text-text">Attach dev server logs <span class="text-text-dim tabular-nums">(last <!> lines)`),Zj=N(`<p class="text-warn text-[11px] leading-snug">`),Qj=N(`<div class="flex h-full flex-col gap-4 overflow-y-auto pt-3 pb-4 pl-3 pr-4"><div class="bg-surface border-border flex items-center gap-2 rounded-lg border px-2.5 py-2"><div class="flex min-w-0 flex-1 flex-col gap-1"><span class="text-text-dim text-[11px] font-medium">Attached context</span><div class="flex min-w-0 flex-wrap items-center gap-1.5"></div></div></div><div class="bg-bg border-border sticky bottom-0 z-10 -mb-4 flex flex-col gap-2 border-t pt-2.5 pb-3">`),$j=N(`<div class="border-border relative overflow-hidden rounded-md border"><img alt="Pasted attachment"class="block h-16 w-16 object-cover"><button class="bg-bg/80 text-text-dim hover:text-danger absolute top-0.5 right-0.5 grid size-4 cursor-pointer place-items-center rounded text-[10px] leading-none"title=Remove aria-label="Remove pasted image">×`),eM=N(`<button>`),tM=N(`<div class="flex min-w-0 items-center gap-1.5 py-0.5"><span class="font-mono text-text-dim shrink-0 text-[10.5px]"></span><a target=_blank rel=noreferrer class="text-accent min-w-0 truncate text-[11px] hover:underline">`),nM=N(`<div class="flex items-center gap-1"><span class="text-text-faint text-[11px] tabular-nums w-4 shrink-0 text-right">.</span><button class="text-text-faint hover:text-danger shrink-0 w-5 h-5 flex items-center justify-center rounded transition-colors cursor-pointer text-[12px] leading-none"aria-label="Remove step">×`),rM=N(`<option>`),iM=N(`<option>Loading teams…`),aM=N(`<div class="bg-surface border-border rounded-lg border p-2.5 flex items-center justify-between gap-2"><a target=_blank rel="noopener noreferrer"class="text-accent font-mono text-[12px] hover:underline">`);function oM(e){sr();let t=_r(()=>({queryKey:[`grab`],queryFn:Tr})),n=_r(()=>({queryKey:[`settings`],queryFn:Cr})),r=k(()=>n.data??{}),i=k(()=>t.data?.[0]??null),a=k(()=>!!(r().linearApiKey||r().linearAccessToken)),o=k(()=>Ox(r())),[s,c]=T(``),[l,u]=T(``),[d,f]=T([]),[p,m]=T(``),[h,g]=T(``),[_,v]=T(``),[y,b]=T(``),[x,S]=T(``),[C,w]=T(0),[E,ee]=T(r().defaultTeamId??``),[te,A]=T(r().defaultRepo??``),[ne,re]=T(`none`),[ie,oe]=T(``),[se,ce]=T(``),[le,ue]=T(!1),[de,fe]=T(!0),[pe,me]=T($O().length);O(()=>{let e=setInterval(()=>me($O().length),3e3);ae(()=>clearInterval(e))});let[he,ge]=T(``);O(()=>{let e=s().trim(),t=setTimeout(()=>ge(e.length>=8?e:``),600);ae(()=>clearTimeout(t))});let _e=_r(()=>({queryKey:[`dup-search`,he()],queryFn:()=>pO(he()),enabled:!!he()&&a(),staleTime:3e4})),[ve,ye]=T(``),[be,xe]=T([]),Se=e=>{for(let t of Array.from(e.clipboardData?.items??[])){if(!t.type.startsWith(`image/`))continue;let e=t.getAsFile();if(!e||e.size>8e6)continue;let n=new FileReader;n.onload=()=>xe(e=>[...e,{id:Date.now()+Math.random(),dataUrl:n.result}].slice(-6)),n.readAsDataURL(e)}},[Ce,we]=T(`fast`),[Te,Ee]=T(!0),De=!1;O(()=>{let e=n.data;De||!e||(De=!0,ee(e.defaultTeamId??``),A(e.defaultRepo??``),re(e.cursorAgentId?`cursor`:`none`))});let Oe=_r(()=>({queryKey:[`teams`],queryFn:cO,enabled:a()})),ke=k(()=>(Oe.data??[]).find(e=>e.id===E())?.name),[Ae,je]=T(!1),[Me,Ne]=T(null),[Pe,Fe]=T(null),Ie=null,Le=()=>{Ie?.(),Ie=null};ae(Le);let Re=e=>{e.title!==void 0&&c(e.title),e.description!==void 0&&u(e.description),e.reproSteps!==void 0&&f(e.reproSteps),e.expected!==void 0&&m(e.expected),e.actual!==void 0&&g(e.actual),e.impact!==void 0&&v(e.impact),e.analysisNotes!==void 0&&b(e.analysisNotes),e.suggestedNextSteps!==void 0&&S(e.suggestedNextSteps),e.priority!==void 0&&w(e.priority)},ze=async()=>{if(!o())return;je(!0),Ne(null),Fe(null),Le();let e=r().logUrl&&Te()?await KO({logUrl:r().logUrl,logLines:40}).catch(()=>void 0):void 0,n=de()?ek(15):null,a=[e?`--- dev server ---\n${e}`:null,n?`--- browser console ---\n${n}`:null].filter(Boolean).join(`
|
|
180
|
+
`)}async function vA(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await _A(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function yA(e,t={}){let{width:n,height:r}=lk(e,t),i=await Kk(e,t,!0);return await vA(i,t),await oA(i,t),sA(i,t),await hk(i,n,r)}async function bA(e,t={}){let{width:n,height:r}=lk(e,t),i=await pk(await yA(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||uk(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||fk(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}async function xA(e,t={}){return _A(e,t)}var SA=6,CA=class{last=performance.now();async tick(){performance.now()-this.last<=SA||(await new Promise(e=>{`requestIdleCallback`in window?requestIdleCallback(()=>e(),{timeout:100}):setTimeout(e,0)}),this.last=performance.now())}},wA=null,TA=new Map;function EA(e){let t=TA.get(e);if(t)return t;if(!wA){let e=document.createElement(`iframe`);if(e.style.cssText=`position:absolute;width:0;height:0;border:0;visibility:hidden`,document.body.appendChild(e),wA=e.contentDocument,!wA)return{}}let n=wA.createElement(e);wA.body.appendChild(n);let r=wA.defaultView.getComputedStyle(n),i={};for(let e=0;e<r.length;e++){let t=r[e];i[t]=r.getPropertyValue(t)}return n.remove(),TA.set(e,i),i}function DA(){try{for(let e of[`div`,`span`,`p`,`a`,`button`,`img`,`ul`,`li`,`svg`])EA(e)}catch{}}function OA(e){if(e.id===`linear-grab-root`)return!0;let t=e.tagName?.toLowerCase()??``;return t===`overlay-canvas`||t.startsWith(`react-grab`)||t===`script`||t===`iframe`}function kA(e,t){try{let n=document.createElement(`canvas`);n.width=e.naturalWidth||e.width||1,n.height=e.naturalHeight||e.height||1,n.getContext(`2d`).drawImage(e,0,0),t.src=n.toDataURL(`image/png`)}catch{t.removeAttribute(`src`),t.setAttribute(`style`,`${t.getAttribute(`style`)??``}background:#8b8e9822;`)}}async function AA(e,t){if(OA(e))return null;if(e instanceof SVGSVGElement)return e.cloneNode(!0);let n=e.cloneNode(!1),r=getComputedStyle(e),i=EA(e.tagName.toLowerCase()),a=``;for(let e=0;e<r.length;e++){let t=r[e],n=r.getPropertyValue(t);n&&n!==i[t]&&(a+=`${t}:${n};`)}if(n.setAttribute(`style`,a),n.removeAttribute(`class`),e instanceof HTMLImageElement&&kA(e,n),e instanceof HTMLCanvasElement)try{let t=document.createElement(`img`);return t.setAttribute(`style`,a),t.src=e.toDataURL(),t}catch{}e instanceof HTMLInputElement&&n.setAttribute(`value`,e.value),e instanceof HTMLTextAreaElement&&(n.textContent=e.value),await t.tick();for(let r of Array.from(e.childNodes))if(r.nodeType===Node.TEXT_NODE)n.appendChild(r.cloneNode());else if(r.nodeType===Node.ELEMENT_NODE){let e=await AA(r,t);e&&n.appendChild(e)}return n}async function jA(e,t){let n=e.getBoundingClientRect(),r=Math.max(1,Math.ceil(n.width)),i=Math.max(1,Math.ceil(n.height)),a=await AA(e,new CA);if(!a)throw Error(`Capture root was filtered`);a.style.margin=`0`;let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${i}"><style>${t}</style><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${new XMLSerializer().serializeToString(a)}</div></foreignObject></svg>`,s=URL.createObjectURL(new Blob([o],{type:`image/svg+xml;charset=utf-8`})),c=new Image;c.decoding=`async`,c.src=s;try{await c.decode()}finally{URL.revokeObjectURL(s)}let l=8192,u=Math.min(window.devicePixelRatio||1,1.5,l/r,l/i),d=document.createElement(`canvas`);d.width=Math.max(1,Math.round(r*u)),d.height=Math.max(1,Math.round(i*u));let f=d.getContext(`2d`);if(!f)throw Error(`Canvas 2d unavailable`);return f.drawImage(c,0,0,d.width,d.height),d}var MA=null;function NA(e){return MA??=xA(e).catch(()=>``),MA}function PA(){`requestIdleCallback`in window?requestIdleCallback(()=>{DA(),NA(document.body)},{timeout:3e3}):setTimeout(()=>{DA(),NA(document.body)},1500)}var FA=4e3,IA=1e3;async function LA(e){try{if(await new Promise(e=>{requestAnimationFrame(()=>`requestIdleCallback`in window?requestIdleCallback(()=>e(void 0),{timeout:500}):setTimeout(e,80))}),!e.isConnected)return null;let t=BA(e),n=t.querySelectorAll(`*`).length;n>FA&&(t=e);let r;try{r=await jA(t,await NA(t))}catch{t!==e&&n>IA&&(t=e),r=await bA(t,{pixelRatio:Math.min(window.devicePixelRatio||1,1.5),fontEmbedCSS:await NA(t),filter:e=>{if(!(e instanceof Element))return!0;if(e.id===`linear-grab-root`)return!1;let t=e.tagName?.toLowerCase()??``;return!(t===`overlay-canvas`||t.startsWith(`react-grab`))}})}return t!==e&&VA(r,t,e),await zA(r)}catch{return null}}async function RA(e){try{let t=e.x+e.w/2,n=e.y+e.h/2,r=document.elementFromPoint(t,n)??document.body,i=t=>{let n=t.getBoundingClientRect();return n.left<=e.x&&n.top<=e.y&&n.right>=e.x+e.w&&n.bottom>=e.y+e.h};for(;r!==document.body&&(!i(r)||r.querySelectorAll(`*`).length<1);)r=r.parentElement??document.body;let a=await jA(r,await NA(r)),o=r.getBoundingClientRect(),s=a.width/o.width,c=a.height/o.height,l=document.createElement(`canvas`);l.width=Math.max(1,Math.round(e.w*s)),l.height=Math.max(1,Math.round(e.h*c));let u=l.getContext(`2d`);return u?(u.drawImage(a,(e.x-o.left+r.scrollLeft)*s,(e.y-o.top+r.scrollTop)*c,e.w*s,e.h*c,0,0,l.width,l.height),await zA(l)):null}catch{return null}}async function zA(e){try{if(typeof createImageBitmap==`function`&&typeof OffscreenCanvas<`u`){let t=await createImageBitmap(e);return(await jD({type:`encode-png`,bitmap:t},[t])).dataUrl}}catch{}return HA(e)}function BA(e){let t=window.innerWidth,n=window.innerHeight,r=t*n*1.7,i=e,a=e;for(;a&&a!==document.body&&a!==document.documentElement;){let o=a.getBoundingClientRect();if(o.width*o.height>r||a!==e&&(a.scrollTop>0||a.scrollLeft>0)||(i=a,o.width>=t*.55&&o.height>=n*.35))break;a=a.parentElement}return i}function VA(e,t,n){let r=e.getContext(`2d`);if(!r)return;let i=t.getBoundingClientRect(),a=n.getBoundingClientRect();if(!i.width||!i.height)return;let o=e.width/i.width,s=e.height/i.height,c=(a.left-i.left+t.scrollLeft)*o,l=(a.top-i.top+t.scrollTop)*s,u=a.width*o,d=a.height*s,f=Math.min(6*o,u/2,d/2);r.strokeStyle=`rgba(94, 106, 210, 0.35)`,r.lineWidth=8*o,r.beginPath(),r.roundRect(c,l,u,d,f),r.stroke(),r.strokeStyle=`#5e6ad2`,r.lineWidth=3*o,r.beginPath(),r.roundRect(c,l,u,d,f),r.stroke()}function HA(e){let t=e.toDataURL(`image/png`);return t.length<=25e5?t:e.toDataURL(`image/jpeg`,.85)}function UA(e){let[t,n]=e.split(`,`),r=t.match(/data:([^;]+)/)?.[1]??`image/png`,i=atob(n),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return new Blob([a],{type:r})}var[WA,GA]=T(null),[KA,qA]=T(null);function JA(e,t){GA(e),qA(t??null)}function YA(){GA(null),qA(null)}var[XA,ZA]=T(`capture`);function QA(e){ZA(e)}var $A=N(`<span class="absolute inset-0 grid place-items-center">`),ej=N(`<button><span>`),tj=N(`<span role=status aria-label=Loading class="text-text-dim relative inline-block shrink-0">`),nj=N(`<span class="absolute top-0 left-1/2 rounded-full bg-current"style="animation:geist-spinner-fade 1.2s linear infinite;will-change:opacity">`),rj=N(`<input>`),ij=N(`<textarea>`),aj=N(`<select>`),oj=N(`<a target=_blank rel="noopener noreferrer"><span class="min-w-0 truncate"></span><svg width=11 height=11 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden class=shrink-0><path d="M4.5 11.5 11.5 4.5M5.5 4.5h6v6">`),sj=N(`<span class="text-text-faint text-[10.5px] leading-snug">`),cj=N(`<label class="flex flex-col gap-1"><span class="text-text-dim text-[11px] font-medium">`),lj=N(`<section class="flex flex-col gap-2.5"><h2 class="text-text-dim text-[11px] font-semibold tracking-wide uppercase">`),uj=N(`<span>`),dj=N(`<span aria-hidden class="inline-block size-2 shrink-0 rounded-full">`),fj=N(`<div class="flex flex-col items-center gap-1.5 px-4 py-10 text-center"><p class="text-text-dim text-[12px] font-medium"></p><div class="text-text-faint text-[11.5px] leading-relaxed">`),pj=N(`<p class="bg-danger-soft text-danger rounded-md px-2.5 py-1.5 text-[11.5px] leading-snug break-words">`),mj={primary:`bg-accent hover:bg-accent-hover text-white border-transparent disabled:bg-surface-3 disabled:text-text-faint`,ghost:`bg-surface-2 hover:bg-surface-3 text-text border-border disabled:text-text-faint disabled:hover:bg-surface-2`,danger:`bg-danger-soft hover:bg-danger/30 text-danger border-transparent`};function hj(e){let[t,n]=He(e,[`variant`,`loading`,`children`,`class`,`disabled`,`title`]);return(()=>{var e=ej(),r=e.firstChild;return ft(e,Ve(n,{get"data-tip"(){return t.title||void 0},get"aria-label"(){return n[`aria-label`]??t.title},get disabled(){return t.disabled||t.loading},get class(){return`relative inline-flex h-7 cursor-pointer items-center justify-center gap-1.5 rounded-md border px-3 text-[12px] font-medium transition-colors disabled:cursor-not-allowed ${mj[t.variant??`ghost`]} ${t.class??``}`}}),!1,!0),P(r,()=>t.children),P(e,j(M,{get when(){return t.loading},get children(){var e=$A();return P(e,j(gj,{})),e}}),null),D(()=>st(r,`inline-flex items-center gap-1.5 ${t.loading?`invisible`:``}`)),e})()}function gj(e){let t=()=>e.size??14,n=()=>Math.max(1,Math.round(t()*.09)),r=()=>Math.round(t()*.26);return(()=>{var e=tj();return P(e,j(We,{get each(){return Array.from({length:12},(e,t)=>t)},children:e=>(()=>{var i=nj();return dt(i,`transform`,`rotate(${e*30}deg)`),dt(i,`animation-delay`,`${(e-12)*.1}s`),D(e=>{var a=`${n()}px`,o=`${r()}px`,s=`-${n()/2}px`,c=`center ${t()/2}px`;return a!==e.e&&dt(i,`width`,e.e=a),o!==e.t&&dt(i,`height`,e.t=o),s!==e.a&&dt(i,`margin-left`,e.a=s),c!==e.o&&dt(i,`transform-origin`,e.o=c),e},{e:void 0,t:void 0,a:void 0,o:void 0}),i})()})),D(n=>{var r=`${t()}px`,i=`${t()}px`;return r!==n.e&&dt(e,`width`,n.e=r),i!==n.t&&dt(e,`height`,n.t=i),n},{e:void 0,t:void 0}),e})()}function _j(e){let[t,n]=He(e,[`class`]);return(()=>{var e=rj();return ft(e,Ve(n,{get class(){return`bg-surface-2 border-border focus:border-accent placeholder:text-text-faint h-7 w-full rounded-md border px-2 text-[12px] outline-none transition-colors ${t.class??``}`}}),!1,!1),e})()}function vj(e){let[t,n]=He(e,[`class`]);return(()=>{var e=ij();return ft(e,Ve(n,{get class(){return`bg-surface-2 border-border focus:border-accent placeholder:text-text-faint w-full resize-y rounded-md border px-2 py-1.5 text-[12px] leading-relaxed outline-none transition-colors ${t.class??``}`}}),!1,!1),e})()}function yj(e){let[t,n]=He(e,[`class`,`children`]);return(()=>{var e=aj();return ft(e,Ve(n,{get class(){return`bg-surface-2 border-border focus:border-accent h-7 w-full cursor-pointer rounded-md border px-1.5 text-[12px] outline-none ${t.class??``}`}}),!1,!0),P(e,()=>t.children),e})()}function bj(e){return(()=>{var t=oj(),n=t.firstChild;return P(n,()=>e.children),D(n=>{var r=e.href,i=e.title||void 0,a=`text-accent inline-flex min-w-0 items-center gap-1 text-[11px] underline-offset-2 hover:underline ${e.class??``}`;return r!==n.e&&it(t,`href`,n.e=r),i!==n.t&&it(t,`data-tip`,n.t=i),a!==n.a&&st(t,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}function xj(e){return(()=>{var t=cj(),n=t.firstChild;return P(n,()=>e.label),P(t,()=>e.children,null),P(t,j(M,{get when(){return e.hint},get children(){var t=sj();return P(t,()=>e.hint),t}}),null),t})()}function Sj(e){return(()=>{var t=lj(),n=t.firstChild;return P(n,()=>e.title),P(t,()=>e.children,null),t})()}function Cj(e){return(()=>{var t=uj();return P(t,()=>e.children),D(n=>{var r=`bg-surface-3 text-text-dim inline-flex h-[18px] items-center gap-1 rounded-full px-2 text-[10.5px] font-medium whitespace-nowrap ${e.class??``}`,i=e.color?{color:e.color}:void 0;return r!==n.e&&st(t,n.e=r),n.t=ut(t,i,n.t),n},{e:void 0,t:void 0}),t})()}function wj(e){return(()=>{var t=dj();return D(n=>dt(t,`background`,e.color)),t})()}function Tj(e){return(()=>{var t=fj(),n=t.firstChild,r=n.nextSibling;return P(n,()=>e.title),P(r,()=>e.children),t})()}function Ej(e){return(()=>{var t=pj();return P(t,()=>e.message),t})()}var Dj={0:`No priority`,1:`Urgent`,2:`High`,3:`Medium`,4:`Low`};function Oj(e){let t=typeof e==`number`?e:Date.parse(e),n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}Rr(),Nx(),mD();var kj=N(`<span class="truncate font-mono">`),Aj=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden><path d="M5.5 3.5 6.6 2h2.8l1.1 1.5H13A1.5 1.5 0 0 1 14.5 5v7A1.5 1.5 0 0 1 13 13.5H3A1.5 1.5 0 0 1 1.5 12V5A1.5 1.5 0 0 1 3 3.5h2.5Z"></path><circle cx=8 cy=8.2 r=2.4>`),jj=N(`<div class="flex flex-wrap gap-1.5"><span class="text-text-faint self-end text-[10.5px]">attached on create`),Mj=N(`<div class="flex items-center justify-between gap-1.5"><span class="text-text-faint text-[11px]">Model:</span><div class="flex rounded-md border border-border overflow-hidden">`),Nj=N(`<span class="inline-block min-w-[12ch] text-center">`),Pj=N(`<div class="flex justify-end">`),Fj=N(`<div class="flex flex-col gap-1.5">`),Ij=N(`<p class="text-text-faint text-[11px] leading-snug">Primary provider failed — drafted with <span class=text-text-dim></span> (<!>).`),Lj=N(`<div class="border-warn/40 bg-surface rounded-md border px-2.5 py-2"><p class="text-warn mb-1 text-[10.5px] font-semibold tracking-wide uppercase">Possibly related — check before creating`),Rj=N(`<div class="flex flex-col gap-1">`),zj=N(`<option value>Select a team…`),Bj=N(`<option value=cursor> — cloud agent`),Vj=N(`<option value=local>Local Claude Code (bridge)`),Hj=N(`<option value=none>No one — just create the issue`),Uj=N(`<option value>Claude Code default`),Wj=N(`<option value=fable>Fable 5`),Gj=N(`<option value=opus>Opus`),Kj=N(`<option value=sonnet>Sonnet`),qj=N(`<option value=haiku>Haiku`),Jj=N(`<label class="flex cursor-pointer items-center gap-2 select-none"><input type=checkbox class="accent-accent rounded"><span class="text-text text-[12px]">Isolated worktree <span class=text-text-dim>— own branch, run agents in parallel safely`),Yj=N(`<label class="flex items-center gap-2 cursor-pointer select-none"><input type=checkbox class="rounded accent-accent"><span class="text-[12px] text-text">Attach console errors <span class="text-text-dim tabular-nums">(<!> captured)`),Xj=N(`<label class="flex items-center gap-2 cursor-pointer select-none"><input type=checkbox class="rounded accent-accent"><span class="text-[12px] text-text">Attach dev server logs <span class="text-text-dim tabular-nums">(last <!> lines)`),Zj=N(`<p class="text-warn text-[11px] leading-snug">`),Qj=N(`<div class="flex h-full flex-col gap-4 overflow-y-auto pt-3 pb-4 pl-3 pr-4"><div class="bg-surface border-border flex items-center gap-2 rounded-lg border px-2.5 py-2"><div class="flex min-w-0 flex-1 flex-col gap-1"><span class="text-text-dim text-[11px] font-medium">Attached context</span><div class="flex min-w-0 flex-wrap items-center gap-1.5"></div></div></div><div class="bg-bg border-border sticky bottom-0 z-10 -mb-4 flex flex-col gap-2 border-t pt-2.5 pb-3">`),$j=N(`<div class="border-border relative overflow-hidden rounded-md border"><img alt="Pasted attachment"class="block h-16 w-16 object-cover"><button class="bg-bg/80 text-text-dim hover:text-danger absolute top-0.5 right-0.5 grid size-4 cursor-pointer place-items-center rounded text-[10px] leading-none"title=Remove aria-label="Remove pasted image">×`),eM=N(`<button>`),tM=N(`<div class="flex min-w-0 items-center gap-1.5 py-0.5"><span class="font-mono text-text-dim shrink-0 text-[10.5px]"></span><a target=_blank rel=noreferrer class="text-accent min-w-0 truncate text-[11px] hover:underline">`),nM=N(`<div class="flex items-center gap-1"><span class="text-text-faint text-[11px] tabular-nums w-4 shrink-0 text-right">.</span><button class="text-text-faint hover:text-danger shrink-0 w-5 h-5 flex items-center justify-center rounded transition-colors cursor-pointer text-[12px] leading-none"aria-label="Remove step">×`),rM=N(`<option>`),iM=N(`<option>Loading teams…`),aM=N(`<div class="bg-surface border-border rounded-lg border p-2.5 flex items-center justify-between gap-2"><a target=_blank rel="noopener noreferrer"class="text-accent font-mono text-[12px] hover:underline">`);function oM(e){sr();let t=_r(()=>({queryKey:[`grab`],queryFn:Tr})),n=_r(()=>({queryKey:[`settings`],queryFn:Cr})),r=k(()=>n.data??{}),i=k(()=>t.data?.[0]??null),a=k(()=>!!(r().linearApiKey||r().linearAccessToken)),o=k(()=>Ox(r())),[s,c]=T(``),[l,u]=T(``),[d,f]=T([]),[p,m]=T(``),[h,g]=T(``),[_,v]=T(``),[y,b]=T(``),[x,S]=T(``),[C,w]=T(0),[E,ee]=T(r().defaultTeamId??``),[te,A]=T(r().defaultRepo??``),[ne,re]=T(`none`),[ie,oe]=T(``),[se,ce]=T(``),[le,ue]=T(!1),[de,fe]=T(!0),[pe,me]=T($O().length);O(()=>{let e=setInterval(()=>me($O().length),3e3);ae(()=>clearInterval(e))});let[he,ge]=T(``);O(()=>{let e=s().trim(),t=setTimeout(()=>ge(e.length>=8?e:``),600);ae(()=>clearTimeout(t))});let _e=_r(()=>({queryKey:[`dup-search`,he()],queryFn:()=>pO(he()),enabled:!!he()&&a(),staleTime:3e4})),[ve,ye]=T(``),[be,xe]=T([]),Se=e=>{for(let t of Array.from(e.clipboardData?.items??[])){if(!t.type.startsWith(`image/`))continue;let e=t.getAsFile();if(!e||e.size>8e6)continue;let n=new FileReader;n.onload=()=>xe(e=>[...e,{id:Date.now()+Math.random(),dataUrl:n.result}].slice(-6)),n.readAsDataURL(e)}},[Ce,we]=T(`fast`),[Te,Ee]=T(!0),De=!1;O(()=>{let e=n.data;De||!e||(De=!0,ee(e.defaultTeamId??``),A(e.defaultRepo??``),re(e.cursorAgentId?`cursor`:`none`))});let Oe=_r(()=>({queryKey:[`teams`],queryFn:cO,enabled:a()})),ke=k(()=>(Oe.data??[]).find(e=>e.id===E())?.name),[Ae,je]=T(!1),[Me,Ne]=T(null),[Pe,Fe]=T(null),Ie=null,Le=()=>{Ie?.(),Ie=null};ae(Le);let Re=e=>{e.title!==void 0&&c(e.title),e.description!==void 0&&u(e.description),e.reproSteps!==void 0&&f(e.reproSteps),e.expected!==void 0&&m(e.expected),e.actual!==void 0&&g(e.actual),e.impact!==void 0&&v(e.impact),e.analysisNotes!==void 0&&b(e.analysisNotes),e.suggestedNextSteps!==void 0&&S(e.suggestedNextSteps),e.priority!==void 0&&w(e.priority)},ze=async()=>{if(!o())return;je(!0),Ne(null),Fe(null),Le();let e=r().logUrl&&Te()?await KO({logUrl:r().logUrl,logLines:40}).catch(()=>void 0):void 0,n=de()?ek(15):null,a=[e?`--- dev server ---\n${e}`:null,n?`--- browser console ---\n${n}`:null].filter(Boolean).join(`
|
|
181
181
|
|
|
182
182
|
`)||void 0;Ie=bD({note:be().length?`${ve()}\n\n(${be().length} pasted screenshot(s) will be attached to the issue.)`:ve(),grabbed:i()??null,grabbedList:t.data??void 0,teamName:ke(),tier:Ce(),template:sD(r()),logs:a},{onPartial:Re,onDone:e=>{Re(e.draft),e.fellBack&&Fe({provider:e.provider,modelId:e.modelId}),je(!1),Ie=null},onError:(e,t)=>{Ne(t===`no-provider`?`No AI provider configured — add an OpenAI or Anthropic key in Settings.`:e),je(!1),Ie=null}})},[Be,Ve]=T(BD());ae(VD(Ve));let He=async()=>{let e=BD().result;if(!e)throw Error(`No recording available.`);if(e.assetUrl)return e.assetUrl;let t=await xO(e.blob,`recording-${Date.now()}.gif`);return tO(t),t},[Ue,Ke]=T(null),[qe,Je]=T(null),[Ye,Xe]=T(null),Ze=vr(()=>({mutationFn:async()=>{let e=dD({description:l(),reproSteps:d(),expected:p(),actual:h(),impact:_(),analysisNotes:y(),suggestedNextSteps:x(),grabs:t.data??[],repo:te(),model:se().trim()||r().cursorModel,agentInstructions:sD(r())});Je(null);let n=[],i=BD();if(i.result&&i.attachOnCreate)try{let t=await He();e+=`\n\n### Recording\n`}catch{n.push(`recording`)}let a=(t.data??[]).filter(e=>e.screenshotDataUrl).slice(0,3);for(let[t,r]of a.entries())try{let n=await xO(UA(r.screenshotDataUrl),`element-${Date.now()}-${t}.png`),i=r.componentName?`<${r.componentName}>`:r.tagName??`element`;e+=`\n\n### Element location${a.length>1?` — ${i}`:``}\n`}catch{n.push(`screenshot${a.length>1?` ${t+1}`:``}`)}let o=be();for(let[t,r]of o.entries())try{let n=await xO(UA(r.dataUrl),`pasted-${Date.now()}-${t}.png`);e+=`${t===0?`
|
|
183
183
|
|
|
@@ -212,7 +212,7 @@ of the other sections.`,pD="- FIRST, self-orient in the repo checkout (skip any
|
|
|
212
212
|
`),entries:i}:null},gY=(e,t,n)=>{if(e?.entries)return t===e.content?e.entries:e.entries.length===1?[{...e.entries[0],content:t,commentText:n}]:e.entries.map(e=>({...e,commentText:n}))},_Y=async(e,t,n,r)=>{await t.onBeforeCopy(n);let i=!1,a=``;try{let o=e.getContent?{content:await e.getContent(n)}:await hY(n,e.maxContextLines),s=o?.content;if(s?.trim()){let c=await t.transformCopyContent(s,n);a=r?`${r}\n${c}`:c,i=zU(a,{componentName:e.componentName,entries:gY(o,a,r)})}}catch(e){t.onCopyError(fY(e))}return i&&t.onCopySuccess(n,a),t.onAfterCopy(n,i),i},vY=(e,t)=>{let n=Math.max(e.left,t.left),r=Math.max(e.top,t.top),i=Math.min(e.right,t.right),a=Math.min(e.bottom,t.bottom);return Math.max(0,i-n)*Math.max(0,a-r)},yY=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top,bY=e=>e.sort((e,t)=>{if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}),xY=e=>{if(e.width<=0||e.height<=0)return[];let t=window.innerWidth,n=window.innerHeight,r=e.x,i=e.y,a=e.x+e.width,o=e.y+e.height,s=r+e.width/2,c=i+e.height/2,l=mB(Math.ceil(e.width/32),3,20),u=mB(Math.ceil(e.height/32),3,20),d=l*u,f=d>100?Math.sqrt(100/d):1,p=mB(Math.floor(l*f),3,20),m=mB(Math.floor(u*f),3,20),h=new Set,g=[],_=(e,r)=>{let i=mB(Math.round(e),0,t-1),a=mB(Math.round(r),0,n-1),o=`${i}:${a}`;h.has(o)||(h.add(o),g.push({x:i,y:a}))};_(r+1,i+1),_(a-1,i+1),_(r+1,o-1),_(a-1,o-1),_(s,i+1),_(s,o-1),_(r+1,c),_(a-1,c),_(s,c);for(let t=0;t<p;t+=1){let n=r+(t+.5)/p*e.width;for(let t=0;t<m;t+=1)_(n,i+(t+.5)/m*e.height)}return g},SY=(e,t,n)=>{let r={left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height},i=new Set,a=xY(e);aI();try{for(let e of a){let t=document.elementsFromPoint(e.x,e.y);for(let e of t)i.add(e)}}finally{oI()}let o=[];for(let e of i)!n&&HF(e)||bM(e)&&t(e)&&o.push(e);let s=new Map;for(let e of o)s.set(e,e.getBoundingClientRect());let c=[];for(let e of o){let t=s.get(e);if(t.width<=0||t.height<=0)continue;let i={left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height};if(n){let n=vY(r,i),a=t.width*t.height;a>0&&n/a>=.75&&c.push(e)}else yY(i,r)&&c.push(e)}return bY(c)},CY=e=>{let t=new Set(e);return e.filter(e=>{for(let n=e.parentElement;n;n=n.parentElement)if(t.has(n))return!1;return!0})},wY=(e,t,n=!0)=>CY(SY(e,t,n)),TY=(e,t)=>e.width<=0?0:mB((t.x-e.x)/e.width,0,1),EY=()=>{PJ(),gI(),ZF()},DY=e=>({borderRadius:`0px`,height:e.height,width:e.width,x:e.pageX-window.scrollX,y:e.pageY-window.scrollY}),OY=e=>({pageX:e.x+window.scrollX,pageY:e.y+window.scrollY,width:e.width,height:e.height}),kY=e=>({borderRadius:`0px`,height:e.height,width:e.width,x:e.x,y:e.y}),AY=(e,t,n)=>{let r=(e,t,n,r)=>{let i=[],a=e,o=0;for(;a&&i.length<n&&o<100;)r(a)&&i.push(a),a=t(a),o+=1;return i},i=r(e.parentElement,e=>e.parentElement,6,t);i.reverse();let a=i.map((e,t)=>({element:e,depth:t,isLast:!0})),o=i.length,s=r(e.previousElementSibling,e=>e.previousElementSibling,7,n),c=r(e.nextElementSibling,e=>e.nextElementSibling,7,n),l=Math.min(s.length,Math.max(3,7-c.length)),u=Math.min(c.length,7-l),d=[...s.slice(0,l).reverse(),e,...c.slice(0,u)],f=r(e.firstElementChild,e=>e.nextElementSibling,6,t),p=d.length-1,m=f.length-1;return d.forEach((t,n)=>{a.push({element:t,depth:o,isLast:n===p}),t===e&&f.forEach((e,t)=>{a.push({element:e,depth:o+1,isLast:t===m})})}),a},jY=e=>e instanceof SVGElement&&!(e instanceof SVGSVGElement),MY=e=>{let t=e.getBoundingClientRect();return t.width>=16||t.height>=16},NY=(e,t)=>t(e)&&!jY(e)&&MY(e),PY=new Set([`c`,`C`,`с`,`С`,`ȼ`,`Ȼ`,`ↄ`,`Ↄ`,`ᴄ`,`ᶜ`,`ⱼ`,`ⅽ`,`Ⅽ`,`ç`,`Ç`,`ć`,`Ć`,`č`,`Č`,`ĉ`,`Ĉ`,`ċ`,`Ċ`]),FY=(e,t)=>t===`KeyC`?!0:!e||e.length!==1?!1:PY.has(e),IY=(e,t)=>{if(!e||!t)return!1;let n=e.toLowerCase();return t===`Space`?n===`space`||n===` `:t.startsWith(`Key`)?t.slice(3).toLowerCase()===n:t.startsWith(`Digit`)?t.slice(5)===n:!1},LY={meta:`metaKey`,cmd:`metaKey`,command:`metaKey`,win:`metaKey`,windows:`metaKey`,ctrl:`ctrlKey`,control:`ctrlKey`,shift:`shiftKey`,alt:`altKey`,option:`altKey`,opt:`altKey`},RY=e=>{let t=e.split(`+`).map(e=>e.trim().toLowerCase()),n={metaKey:!1,ctrlKey:!1,shiftKey:!1,altKey:!1,key:null};for(let e of t){let t=LY[e];t?n[t]=!0:n.key=e}return n},zY=e=>{if(typeof e==`function`)return e;let t=RY(e),n=t.key;return e=>{if(n===null){let n=!t.metaKey||e.metaKey||e.key===`Meta`,r=!t.ctrlKey||e.ctrlKey||e.key===`Control`,i=!t.shiftKey||e.shiftKey||e.key===`Shift`,a=!t.altKey||e.altKey||e.key===`Alt`,o=n&&r&&i&&a,s=[t.metaKey,t.ctrlKey,t.shiftKey,t.altKey].filter(Boolean).length,c=[e.metaKey||e.key===`Meta`,e.ctrlKey||e.key===`Control`,e.shiftKey||e.key===`Shift`,e.altKey||e.key===`Alt`].filter(Boolean).length;return o&&c>=s}let r=e.key?.toLowerCase()===n||IY(n,e.code),i=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?(!t.metaKey||e.metaKey)&&(!t.ctrlKey||e.ctrlKey)&&(!t.shiftKey||e.shiftKey)&&(!t.altKey||e.altKey):!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;return r&&i}},BY=e=>!e||typeof e==`function`?{metaKey:_B(),ctrlKey:!_B(),shiftKey:!1,altKey:!1,key:null}:RY(e),VY=(e,t)=>{if(t.activationKey)return zY(t.activationKey)(e);let n=(_B()?e.metaKey:e.ctrlKey)&&!e.shiftKey&&!e.altKey;return!!(e.key&&n&&FY(e.key,e.code))},HY=e=>{if(e.length===0)return{x:0,y:0,width:0,height:0};if(e.length===1)return e[0];let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}},UY=e=>{let t=getComputedStyle(e),n={};for(let e of yB)n[e]=t.getPropertyValue(e);return n},WY=e=>{let t={};for(let n of zB)t[n]=e.getPropertyValue(n);return t},GY=e=>{try{let t=e.parentElement;if(!t)return null;let n=e.namespaceURI,r=e.tagName.toLowerCase(),i=n&&n!==`http://www.w3.org/1999/xhtml`?e.ownerDocument.createElementNS(n,r):e.ownerDocument.createElement(r),a=`style`in i?i.style:null;a instanceof CSSStyleDeclaration&&a.setProperty(`display`,`none`,`important`),t.appendChild(i);try{return WY(getComputedStyle(i))}finally{i.remove()}}catch{return null}},KY=new Set([`display`,`width`,`height`]),qY=(e,t,n)=>e.kind===`color`?!1:e.cssProperties.some(e=>KY.has(e))?JY(e):e.cssProperties.every(e=>{let r=t[e],i=n[e];return r===void 0||i===void 0?!1:r===i}),JY=e=>{if(e.kind===`color`)return!1;if(e.kind===`enum`)return e.key===`font-weight`?e.original===`400`:e.options[0]?.value===e.original;let{key:t,original:n}=e;return t.startsWith(`padding`)||t.startsWith(`margin`)||t.includes(`gap`)||t===`border-width`||t.endsWith(`-radius`)||t===`border-radius`?n===0:t===`opacity`?n===100:t===`letter-spacing`||t===`z-index`?n===0:!jB.has(t)&&!!(t===`width`||t===`height`||t===`width,height`||t.startsWith(`max-`)||t.startsWith(`min-`)||t===`line-height`)},YY=e=>{let t=e.trim();if(!t||t===`auto`||t===`normal`||t===`none`)return null;let n=Number.parseFloat(t);return Number.isFinite(n)?t.endsWith(`%`)?{value:n,unit:`%`}:t.endsWith(`rem`)||t.endsWith(`em`)?{value:n*16,unit:`px`}:t.endsWith(`px`)?{value:n,unit:`px`}:{value:n,unit:``}:null},XY=(e,t)=>{let n=YY(e[t]);if(n)return n;if(t===`line-height`){let t=YY(e[`font-size`]);return t?{value:UB(t.value*vN),unit:t.unit||`px`}:null}return wB.has(t)?{value:0,unit:`px`}:null},ZY=(e,t)=>{let n=XY(e,t[0]);if(!n)return null;for(let r=1;r<t.length;r++){let i=XY(e,t[r]);if(!i||i.unit!==n.unit||Math.abs(i.value-n.value)>=.5)return null}return n},QY=(e,t)=>e===`opacity`?{value:Math.round(t.value*100),unit:`%`}:TB.has(e)?{value:UB(t.value),unit:``}:{value:UB(t.value),unit:t.unit||`px`},$Y=e=>e!==null,eX=(e,t)=>{let n=t.map(t=>{let n=t.longhands.length===1?XY(e,t.longhands[0]):ZY(e,t.longhands);return n?{definition:t,value:n}:null}).filter($Y),r=new Map;for(let e of n)for(let t of e.definition.longhands){let n=r.get(t);(!n||e.definition.longhands.length>n.definition.longhands.length)&&r.set(t,e)}let i=new Set(r.values());return n.map(e=>({...e,isCanonical:i.has(e)}))},tX=(e,t,n)=>e===`opacity`?{min:0,max:100}:e===`z-index`?{min:SB,max:CB}:e===`letter-spacing`?{min:-10,max:20}:e===`font-size`?{min:8,max:96}:e===`line-height`?{min:0,max:120}:e.includes(`radius`)?{min:0,max:96}:e===`width`||e===`height`||e===`width,height`||e.startsWith(`min-`)||e.startsWith(`max-`)?{min:0,max:Math.max(512,Math.ceil(t*2))}:jB.has(e)?{min:xB,max:512}:n===`%`?{min:0,max:100}:{min:e.startsWith(`margin`)?bB:0,max:384},nX=(e,t,n)=>{let r=QY(e.key,t),i=r.unit===`px`&&Math.abs(r.value)>1e7,a=tX(e.key,i?0:r.value,r.unit),o=r.value<0?a.min:a.max,s=i?o:r.value;return{kind:`numeric`,key:e.key,label:e.label,cssProperties:e.longhands,min:a.min,max:a.max,value:s,original:s,unit:r.unit,tailwindAliases:_V(e.key),isPrioritized:!1,isDefault:!1,isCanonical:n}},rX=(e,t,n,r=!1)=>{let i=pB(n),a=i?Qz(i):null,o=a!==null&&a.alpha!==0;if(!o&&!r)return null;let s=o&&i?i:cN;return{kind:`color`,key:e,label:t,cssProperties:[e],value:s,original:s,tailwindAliases:_V(e),isPrioritized:r,isDefault:!1,isCanonical:!0}},iX=(e,t,n)=>{let r=t.trim(),i=n??e.options;return!i||!i.some(e=>e.value===r)?null:{kind:`enum`,key:e.key,label:e.label,cssProperties:[e.key],value:r,original:r,options:i,tailwindAliases:_V(e.key),isPrioritized:!1,isDefault:!1,isCanonical:!0}},aX=new Map(`background-color.color.padding.padding-left,padding-right.padding-top,padding-bottom.padding-top.padding-right.padding-bottom.padding-left.margin.margin-left,margin-right.margin-top,margin-bottom.margin-top.margin-right.margin-bottom.margin-left.font-family.font-size.font-weight.font-style.line-height.letter-spacing.text-transform.text-align.text-decoration-line.white-space.word-break.overflow-wrap.font-variant-numeric.border-radius.border-top-left-radius,border-top-right-radius.border-bottom-left-radius,border-bottom-right-radius.border-top-left-radius,border-bottom-left-radius.border-top-right-radius,border-bottom-right-radius.border-top-left-radius.border-top-right-radius.border-bottom-left-radius.border-bottom-right-radius.width,height.width.height.max-width.max-height.min-width.min-height.opacity.gap.row-gap.column-gap.border-width.border-top-width.border-right-width.border-bottom-width.border-left-width.border-color.align-items.justify-content.top,right,bottom,left.left,right.top,bottom.top.right.bottom.left.z-index`.split(`.`).map((e,t)=>[e,t])),oX=e=>aX.get(e.key)??1/0,sX=e=>e.map((e,t)=>({property:e,index:t})).sort((e,t)=>{let n=oX(e.property)-oX(t.property);return n===0?e.index-t.index:n}).map(e=>e.property),cX=e=>{let t=UY(e),n=getComputedStyle(e),r=WY(n),i=GY(e),a=[],o=new Set,s=e=>{o.has(e.key)||(a.push(e),o.add(e.key))};for(let e of MB)for(let n of eX(t,e))s(nX(n.definition,n.value,n.isCanonical));for(let e of NB){let n=XY(t,e.key);n&&s(nX({key:e.key,label:e.label,longhands:[e.key]},n,!0))}for(let{key:e,label:t,alwaysShow:r}of PB){let i=n.getPropertyValue(e);if(!r&&(!i||eB(i)))continue;let a=rX(e,t,i,r);a&&s(a)}let c=n.getPropertyValue(LB.key);if(c){let e=iX(LB,c,IB(c));e&&s(e)}for(let e of RB){let t=n.getPropertyValue(e.key);if(!t)continue;let r=iX(e,t);r&&s(r)}return lX(a,gV(e),r,i)},lX=(e,t,n,r)=>{let i=[],a=[];for(let o of e)if(o.isPrioritized||t.has(o.key))i.push({...o,isPrioritized:!0,isDefault:!1});else{let e=r?qY(o,n,r):JY(o);a.push({...o,isDefault:e})}return[...sX(i),...sX(a)]},uX=[{keyword:`letter`,family:`letter-spacing`},{keyword:`tracking`,family:`letter-spacing`},{keyword:`leading`,family:`line-height`},{keyword:`line-height`,family:`line-height`},{keyword:`lineheight`,family:`line-height`},{keyword:`radius`,family:`radius`},{keyword:`rounded`,family:`radius`},{keyword:`corner`,family:`radius`},{keyword:`font-size`,family:`font-size`},{keyword:`fontsize`,family:`font-size`},{keyword:`text`,family:`font-size`},{keyword:`stroke`,family:`border-width`},{keyword:`border-width`,family:`border-width`},{keyword:`borderwidth`,family:`border-width`},{keyword:`space`,family:`spacing`},{keyword:`gap`,family:`spacing`},{keyword:`gutter`,family:`spacing`},{keyword:`inset`,family:`spacing`},{keyword:`padding`,family:`spacing`},{keyword:`margin`,family:`spacing`},{keyword:`size`,family:`size`},{keyword:`width`,family:`size`},{keyword:`height`,family:`size`}],dX=e=>{let t=e.toLowerCase();for(let{keyword:e,family:n}of uX)if(t.includes(e))return n;return null},fX=e=>e.includes(`radius`)?`radius`:e.endsWith(`-width`)&&e.includes(`border`)?`border-width`:e===`font-size`?`font-size`:e===`line-height`?`line-height`:e===`letter-spacing`?`letter-spacing`:e.startsWith(`padding`)||e.startsWith(`margin`)||e.endsWith(`gap`)||e===`top`||e===`right`||e===`bottom`||e===`left`||e.startsWith(`inset`)?`spacing`:e===`width`||e===`height`||e.startsWith(`min-`)||e.startsWith(`max-`)?`size`:null,pX=e=>{let t=YY(e);return!t||t.unit!==`px`?null:UB(t.value)},mX=(e,t)=>t===null?!0:e.length===t.length?e<t:e.length<t.length,hX=(e,t,n)=>{if(n===1){for(let n of e)if(n>t)return n;return null}for(let n=e.length-1;n>=0;n--)if(e[n]<t)return e[n];return null},gX=(e,t,n)=>{let r=(t===1?Math.floor(e/n)+1:Math.ceil(e/n)-1)*n;return r<0?null:r},_X=null,vX=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),yX=()=>{let e=Array.from(document.adoptedStyleSheets??[]),t=document.styleSheets.length;if(_X&&_X.documentSheetCount===t&&vX(_X.adoptedSheets,e))return _X.names;let n=new Set;for(let t of[...document.styleSheets,...e]){let e;try{e=t.cssRules}catch{continue}bX(e,n)}return _X={documentSheetCount:t,adoptedSheets:e,names:n},n},bX=(e,t)=>{for(let n of Array.from(e))if(n instanceof CSSStyleRule){let e=n.style;for(let n=0;n<e.length;n++){let r=e.item(n);r.startsWith(`--`)&&t.add(r)}}else n instanceof CSSGroupingRule&&bX(n.cssRules,t)},xX={hasTokens:!1,matchColor:()=>null,matchLength:()=>null,stepLength:()=>null},SX=e=>{if(typeof document>`u`)return xX;let t=yX();if(t.size===0)return xX;let n=getComputedStyle(e),r=new Map,i=new Map,a=new Map,o=null;for(let e of t){let t=n.getPropertyValue(e).trim();if(!t)continue;let s=pX(t);if(s!==null){e===`--spacing`&&s>0&&(o=s);let t=dX(e);if(t!==null){let n=i.get(s);n?n.push({name:e,family:t}):i.set(s,[{name:e,family:t}]);let r=a.get(t);r?r.add(s):a.set(t,new Set([s]))}continue}let c=pB(t);if(c){let t=c.toLowerCase();mX(e,r.get(t)??null)&&r.set(t,e)}}if(r.size===0&&i.size===0)return xX;let s=new Map;for(let[e,t]of a)s.set(e,Array.from(t).sort((e,t)=>e-t));return{hasTokens:!0,matchColor:e=>{let t=pB(e)?.toLowerCase();return t?r.get(t)??null:null},matchLength:(e,t)=>{let n=fX(t);if(n===null)return null;let r=i.get(Math.round(e));if(!r)return null;let a=null;for(let e of r)e.family===n&&mX(e.name,a)&&(a=e.name);return a},stepLength:(e,t,n)=>{let r=fX(n);if(r===null)return null;let i=Math.round(e),a=s.get(r);return a&&a.length>=2?hX(a,i,t):(r===`spacing`||r===`size`)&&o?gX(i,t,o):a?hX(a,i,t):null}}},CX=e=>e.kind===`color`||e.kind===`enum`?e.value:e.key===`opacity`&&e.unit===`%`?HB(e.value/100):`${HB(e.value)}${e.unit}`,wX=(e,t,n)=>{if(!n?.hasTokens)return null;let{edit:r}=t;return r.kind===`color`?n.matchColor(r.value):r.kind===`numeric`&&r.unit===`px`?n.matchLength(r.value,e):null},TX=e=>{let t=new Map;for(let n of e.edits){let e=CX(n);for(let r of n.cssProperties)t.set(r,{edit:n,cssValue:e})}let n=!1;return{lines:Array.from(t,([t,r])=>{let i=wX(t,r,e.designTokens);i&&(n=!0);let a=i?` /* var(${i}) */`:``;return`${t}: ${r.cssValue};${a}`}),usesToken:n}},EX=e=>e.filePath?`${e.filePath}:${e.lineNumber}`:``,DX=e=>["```css",...e,"```"].join(`
|
|
213
213
|
`),OX=e=>{if(e.length===0)return``;let t=e.map(e=>{let{lines:t,usesToken:n}=TX(e);return{header:EX(e),cssLines:t,usesToken:n}}),n=[`Apply these style changes canonically (CSS = visual intent; choose the source change that best expresses the underlying layout intent):`];if(t.some(e=>e.usesToken)&&n.push("Prefer the design token shown in each `/* var(--token) */` comment over the raw value when it matches the project's intent."),t.length===1){let[e]=t;return e.header&&n.push(`\n${e.header}`),n.push(DX(e.cssLines)),n.join(`
|
|
214
214
|
`)}for(let e of t)n.push(e.header?`\n${e.header}`:``),n.push(DX(e.cssLines));return n.join(`
|
|
215
|
-
`)},kX=e=>`style`in e&&e.style instanceof CSSStyleDeclaration,AX=e=>{let t=new Map,n=kX(e)?e:null;return{apply:(e,r)=>{if(n)for(let i of e)t.has(i)||t.set(i,{value:n.style.getPropertyValue(i),priority:n.style.getPropertyPriority(i)}),n.style.setProperty(i,r)},restore:()=>{if(!n){t.clear();return}for(let[e,{value:r,priority:i}]of t)r?n.style.setProperty(e,r,i):n.style.removeProperty(e);t.clear()},hasAppliedStyles:()=>t.size>0}},jX=(e,t)=>{for(let n of t){let t=e.edits.findIndex(e=>e.key===n.key);t>=0?e.edits[t]=n:e.edits.push(n)}},MX=(e,t)=>({element:e.element,preview:e.preview,filePath:e.filePath??``,lineNumber:e.lineNumber??0,edits:t,designTokens:e.designTokens}),NX=e=>{let[t,n]=J(null),[r,i]=J(!1),a=[],o=[],s=e=>{o=e},c=()=>{let r=t()!==null;n(null),i(!1),a=[],o=[],r&&e.onClose?.()},l=()=>{t()?.preview.restore();for(let e=a.length-1;e>=0;e--)a[e].preview.restore();c()},u=e=>{hU(e).then(t=>{t&&n(n=>!n||n.element!==e||n.componentName?n:{...n,componentName:t})})},d=(r,i,a={})=>{if(t()!==null)return!1;let o=cX(r);if(o.length===0)return!1;let s=a.filePath??e.store.selectionFilePath??void 0,c=a.lineNumber??e.store.selectionLineNumber??void 0;return n({element:r,position:i,selectionBounds:IJ(r),properties:o,preview:AX(r),filePath:s,lineNumber:c,componentName:a.componentName,tagName:a.tagName??bN(r),initialSearchQuery:a.initialSearchQuery,designTokens:SX(r)}),u(r),e.isActivated()||e.activateRenderer(),e.actions.setPointer(i),e.actions.setFrozenElement(r),e.actions.freeze(),e.onOpen?.(),!0},f=(r,i)=>{let s=t();if(!s||s.element===r)return!1;let c=cX(r);return c.length===0?!1:((o.length>0||s.preview.hasAppliedStyles())&&a.push(MX(s,o)),o=[],n({element:r,position:i,selectionBounds:IJ(r),properties:c,preview:AX(r),tagName:bN(r),hasSessionEdits:a.some(e=>e.edits.length>0),designTokens:SX(r)}),SU(r).then(e=>{if(e){for(let t of a)t.element===r&&!t.filePath&&(t.filePath=e.filePath,t.lineNumber=e.lineNumber??0);n(t=>!t||t.element!==r||t.filePath?t:{...t,filePath:e.filePath,lineNumber:e.lineNumber??void 0})}}).catch(()=>void 0),u(r),e.actions.setPointer(i),e.actions.setFrozenElement(r),!0)},p=(e,t)=>[...a,MX(e,t)],m=e=>{let t=new Map;for(let n of e){if(n.edits.length===0)continue;let e=t.get(n.element);if(e){!e.filePath&&n.filePath&&(e.filePath=n.filePath,e.lineNumber=n.lineNumber),jX(e,n.edits);continue}t.set(n.element,{filePath:n.filePath,lineNumber:n.lineNumber,edits:[...n.edits],designTokens:n.designTokens})}return Array.from(t.values())},h=e=>{let t=new Set;for(let n of e)n.edits.length>0&&t.add(n.element);for(let n=e.length-1;n>=0;n--){let r=e[n];r.edits.length===0&&!t.has(r.element)&&r.preview.restore()}};return{state:t,trigger:d,switchToElement:f,setPendingEdits:s,dismiss:()=>{t()!==null&&(l(),e.store.wasActivatedByToggle?e.deactivateRenderer():e.actions.unfreeze())},closePreservingRenderer:()=>{t()!==null&&(l(),e.actions.unfreeze())},submit:n=>{let r=t();if(!r)return;let i=r.element,a=p(r,n),o=OX(m(a));h(a),c(),e.store.wasActivatedByToggle||e.actions.unfreeze(),e.performCopyWithLabel({element:i,cursorX:r.position.x,extraPrompt:o||void 0,shouldDeactivateAfter:e.store.wasActivatedByToggle})},resetWithDiscard:l,isOpen:()=>t()!==null,isInteracting:r,setInteracting:i}},PX={enabled:!0,hue:0,selectionBox:{enabled:!0},dragBox:{enabled:!0},grabbedBoxes:{enabled:!0},elementLabel:{enabled:!0},toolbar:{enabled:!0}},FX=(e,t)=>({enabled:t.enabled??e.enabled,hue:t.hue??e.hue,selectionBox:{enabled:t.selectionBox?.enabled??e.selectionBox.enabled},dragBox:{enabled:t.dragBox?.enabled??e.dragBox.enabled},grabbedBoxes:{enabled:t.grabbedBoxes?.enabled??e.grabbedBoxes.enabled},elementLabel:{enabled:t.elementLabel?.enabled??e.elementLabel.enabled},toolbar:{enabled:t.toolbar?.enabled??e.toolbar.enabled}}),IX={activationMode:`toggle`,keyHoldDuration:100,allowActivationInsideInput:!0,activationKey:void 0,getContent:void 0,maxContextLines:3,freezeReactUpdates:!0},LX=(e={})=>{let t=new Map,n={},[r,i]=SJ({theme:PX,options:{...IX,...e},actions:[]}),a=()=>{let r=PX,a={...IX,...e},o=[];for(let{config:e}of t.values())if(e.theme&&(r=FX(r,e.theme)),e.options&&(a={...a,...e.options}),e.actions)for(let t of e.actions)o.push(t);a={...a,...n},i(`theme`,r),i(`options`,a),i(`actions`,o)},o=(e,t)=>{n[e]=t,i(`options`,e,t)},s=[`activationMode`,`keyHoldDuration`,`allowActivationInsideInput`,`activationKey`,`getContent`,`maxContextLines`,`freezeReactUpdates`],c=e=>{for(let t of s)e[t]!==void 0&&o(t,e[t])},l=(e,n)=>{t.has(e.name)&&u(e.name);let r=e.setup?.(n,_)??{};e.theme&&(r.theme=r.theme?FX(FX(PX,e.theme),r.theme):e.theme),e.actions&&(r.actions=[...e.actions,...r.actions??[]]),e.hooks&&(r.hooks=r.hooks?{...e.hooks,...r.hooks}:e.hooks),e.options&&(r.options=r.options?{...e.options,...r.options}:e.options),t.set(e.name,{plugin:e,config:r}),a()},u=e=>{let n=t.get(e);n&&(n.config.cleanup&&n.config.cleanup(),t.delete(e),a())},d=()=>Array.from(t.keys()),f=(e,...n)=>{for(let{config:r}of t.values()){let t=r.hooks?.[e];t&&t(...n)}},p=(e,...n)=>{let r=!1;for(let{config:i}of t.values()){let t=i.hooks?.[e];t&&t(...n)===!0&&(r=!0)}return r},m=async(e,...n)=>{for(let{config:r}of t.values()){let t=r.hooks?.[e];t&&await t(...n)}},h=async(e,n,...r)=>{let i=n;for(let{config:n}of t.values()){let t=n.hooks?.[e];t&&(i=await t(i,...r))}return i},g=(e,n,...r)=>{let i=n;for(let{config:n}of t.values()){let t=n.hooks?.[e];t&&(i=t(i,...r))}return i},_={onActivate:()=>f(`onActivate`),onDeactivate:()=>f(`onDeactivate`),onElementHover:e=>f(`onElementHover`,e),onElementSelect:e=>{let n=!1,r;for(let{config:i}of t.values()){let t=i.hooks?.onElementSelect;if(t){let i=t(e);i===!0?n=!0:i instanceof Promise&&(n=!0,r=i)}}return{wasIntercepted:n,pendingResult:r}},onDragStart:(e,t)=>f(`onDragStart`,e,t),onDragEnd:(e,t)=>f(`onDragEnd`,e,t),onBeforeCopy:async e=>m(`onBeforeCopy`,e),transformCopyContent:async(e,t)=>h(`transformCopyContent`,e,t),onAfterCopy:(e,t)=>f(`onAfterCopy`,e,t),onCopySuccess:(e,t)=>f(`onCopySuccess`,e,t),onCopyError:e=>f(`onCopyError`,e),onStateChange:e=>f(`onStateChange`,e),onPromptModeChange:(e,t)=>f(`onPromptModeChange`,e,t),onSelectionBox:(e,t,n)=>f(`onSelectionBox`,e,t,n),onDragBox:(e,t)=>f(`onDragBox`,e,t),onGrabbedBox:(e,t)=>f(`onGrabbedBox`,e,t),onElementLabel:(e,t,n)=>f(`onElementLabel`,e,t,n),onContextMenu:(e,t)=>f(`onContextMenu`,e,t),onOpenFile:(e,t)=>p(`onOpenFile`,e,t),transformHtmlContent:async(e,t)=>h(`transformHtmlContent`,e,t),transformAgentContext:async(e,t)=>h(`transformAgentContext`,e,t),transformActionContext:e=>g(`transformActionContext`,e),transformOpenFileUrl:(e,t,n)=>g(`transformOpenFileUrl`,e,t,n)};return{register:l,unregister:u,getPluginNames:d,setOptions:c,store:r,hooks:_}},RX=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,zX=e=>{let t=e.bounds.x+e.bounds.width/2,n=e.bounds.width/2,r=e.mouseX===void 0?void 0:e.mouseX-t;return{id:RX(`label`),bounds:e.bounds,boundsMultiple:e.boundsMultiple,tagName:e.tagName,componentName:e.componentName,status:e.status,createdAt:Date.now(),element:e.element,elements:e.elements,mouseX:e.mouseX,mouseXOffsetFromCenter:r,mouseXOffsetRatio:r!==void 0&&n>0?r/n:void 0,hideArrow:e.hideArrow}},BX=(e,t)=>{let n=new Map,r=e=>{let t=n.get(e);t!==void 0&&(window.clearTimeout(t),n.delete(e))},i=()=>{for(let e of n.values())window.clearTimeout(e);n.clear()},a=()=>{i(),e.clearLabelInstances()},o=t=>{r(t);let i=window.setTimeout(()=>{e.updateLabelInstance(t,`fading`);let r=window.setTimeout(()=>{n.delete(t),e.removeLabelInstance(t)},125);n.set(t,r)},DM);n.set(t,i)};return{createInstance:(t,n,r,i,o)=>{a();let s=zX({bounds:t,tagName:n,componentName:r,status:i,element:o?.element,mouseX:o?.mouseX,elements:o?.elements,boundsMultiple:o?.boundsMultiple,hideArrow:o?.hideArrow});return e.addLabelInstance(s),s.id},createPerElementInstances:(t,n)=>{a();let r=[];for(let i of t){let t=zX({bounds:IJ(i.element),tagName:i.tagName,componentName:i.componentName,status:n,element:i.element,mouseX:i.mouseX});e.addLabelInstance(t),r.push(t.id)}return r},updateAfterCopy:(t,n,r)=>{n?e.updateLabelInstance(t,`copied`):e.updateLabelInstance(t,`error`,r||`Unknown error`),o(t)},cancelAllFades:i,clearAll:a,handleHoverChange:(e,n)=>{if(n){r(e);return}let i=t().find(t=>t.id===e);i&&(i.status===`copied`||i.status===`error`||i.status===`fading`)&&o(e)}}},VX=e=>{let t=window.innerWidth,n=window.innerHeight,r=Math.max(0,e.x),i=Math.min(t,e.x+e.width),a=Math.max(0,e.y),o=Math.min(n,e.y+e.height);return{x:(r+i)/2,y:(a+o)/2}},HX=(e,t,n)=>{let r=[],i=(t,r)=>{let i=VX(n(t)),a=mI(i.x,i.y).filter(e),o=a.indexOf(t);return o===-1?null:a[o+r]??null},a=e=>{let t=i(e,1);return t&&(r.push(e),r.length>50&&(r=r.slice(-50))),t},o=e=>{if(r.length>0){let e=r.pop();if(Uz(e))return e}return i(e,-1)},s=(e,n)=>{let i=e=>n?e.nextElementSibling:e.previousElementSibling,a=i(e);for(;a;){if(t(a))return r=[],a;a=i(a)}return null};return{findNext:(e,t)=>{switch(e){case`ArrowUp`:return a(t);case`ArrowDown`:return o(t);case`ArrowRight`:return s(t,!0);case`ArrowLeft`:return s(t,!1);default:return null}},clearHistory:()=>{r=[]}}},UX=e=>{let{metaKey:t,ctrlKey:n,shiftKey:r,altKey:i}=BY(e.activationKey);return{metaKey:t,ctrlKey:n,shiftKey:r,altKey:i}},WX=()=>{let e=new WeakSet,t=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,`key`),n=!1;if(t?.get&&!t.get.__reactGrabPatched){n=!0;let r=t.get,i=function(){return e.has(this)?``:r.call(this)};i.__reactGrabPatched=!0,Object.defineProperty(KeyboardEvent.prototype,"key",{get:i,configurable:!0})}return{claimedEvents:e,originalKeyDescriptor:t,restore:()=>{n&&t&&Object.defineProperty(KeyboardEvent.prototype,"key",t)}}},GX=(e,t)=>({top:t<25,bottom:t>window.innerHeight-25,left:e<25,right:e>window.innerWidth-25}),KX=(e,t,n)=>{let r=null,i=()=>{if(!t()){a();return}let o=e(),s=GX(o.x,o.y),c=0,l=0;if(s.top&&(l-=10),s.bottom&&(l+=10),s.left&&(c-=10),s.right&&(c+=10),c!==0||l!==0){let e=window.scrollX,t=window.scrollY;window.scrollBy(c,l);let r=window.scrollX-e,i=window.scrollY-t;(r!==0||i!==0)&&n?.({x:r,y:i})}r=s.top||s.bottom||s.left||s.right?RF(i):null},a=()=>{r!==null&&(zF(r),r=null)};return{start:i,stop:a,isActive:()=>r!==null}},qX=()=>{let e=globalThis;return!!(e.chrome?.runtime?.id||e.browser?.runtime?.id)},JX=e=>{try{let t=`0.1.48`,n=`data:image/svg+xml;base64,${btoa(`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 294 294"><path fill="#ff40e0" d="M145 47c25-20 50-27 67-17 16 9 23 30 20 60 0 2-1 5-1 7l-2 13h-1l-12-4c-8-3-17-5-25-6l-17-3c-10-1-20-1-29-1-10 0-20 0-29 1-6 8-11 16-16 24-5 9-9 17-13 26 4 9 8 18 13 26s10 16 16 24l11 14c5 7 11 13 18 19l10 8s-1 0 0 0l-11 9c-17 14-35 22-49 22-6 0-13-2-18-5-16-9-23-30-20-59 1-3 1-5 1-8-30-12-48-29-48-50 0-18 14-35 41-47 2-1 5-2 7-3 0-2 0-5-1-7-3-30 4-51 20-60 18-10 42-3 68 17M71 201c-1 2-1 4-1 5-2 24 3 41 13 47h1c11 7 30 1 51-15-10-9-18-18-26-29-13-1-26-4-38-8m9-38c-3 9-5 17-7 26 8 2 17 4 25 6-3-5-6-10-9-16-3-5-6-10-9-16m-19-53c-2 1-3 1-5 2-21 10-34 23-34 35 0 13 14 27 39 37 3-12 7-25 12-37-5-12-9-24-12-37m37-10c-8 1-17 3-25 6 2 8 4 16 7 25 3-5 6-11 9-16zm-3-61c-4-1-8 0-12 2-10 7-15 24-13 47 0 2 0 3 1 5 12-4 25-6 38-8 8-10 16-20 26-29-15-11-29-17-40-17m111 2c-4-2-8-3-12-2-11 0-25 5-40 17 10 9 19 19 26 29 13 2 26 4 39 8v-5c3-23-2-40-13-47m-61 23c-7 6-13 13-19 19h37c-6-6-12-13-18-19"/><mask id="a"><path fill="#fff" d="m235 85-133 27 28 133 133-27Z"/></mask><path fill="#ff40e0" d="m137 130 76 11c8 1 9 11 3 15l-28 16-4 32c-1 8-10 10-14 4l-41-66c-3-6 1-13 8-12" mask="url(#a)"/></svg>`)}`;console.log(`%cReact Grab${` v${t}`}%c\nhttps://react-grab.com`,`background: #330039; color: #ffffff; border: 1px solid #d75fcb; padding: 4px 4px 4px 24px; border-radius: 4px; background-image: url("${n}"); background-size: 16px 16px; background-repeat: no-repeat; background-position: 4px center; display: inline-block; margin-bottom: 4px;`,``),e&&navigator.onLine&&!qX()&&fetch(`https://www.react-grab.com/api/version?source=browser&v=${t}&t=${Date.now()}`,{referrerPolicy:`origin`,keepalive:!0,priority:`low`,cache:`no-store`}).then(e=>e.text()).then(e=>{e&&e!==t&&console.warn(`[React Grab] v${t} is outdated (latest: v${e}). Run \`npx grab@latest upgrade\` to upgrade.`)}).catch(()=>null)}catch{}},YX=e=>typeof e==`object`&&!!e,XX=e=>{if(!YX(e))return null;let t={};return typeof e.enabled==`boolean`&&(t.enabled=e.enabled),(e.activationMode===`toggle`||e.activationMode===`hold`)&&(t.activationMode=e.activationMode),typeof e.keyHoldDuration==`number`&&Number.isFinite(e.keyHoldDuration)&&(t.keyHoldDuration=e.keyHoldDuration),typeof e.allowActivationInsideInput==`boolean`&&(t.allowActivationInsideInput=e.allowActivationInsideInput),typeof e.activationKey==`string`&&(t.activationKey=e.activationKey),typeof e.maxContextLines==`number`&&Number.isFinite(e.maxContextLines)&&(t.maxContextLines=e.maxContextLines),typeof e.freezeReactUpdates==`boolean`&&(t.freezeReactUpdates=e.freezeReactUpdates),typeof e.telemetry==`boolean`&&(t.telemetry=e.telemetry),Object.keys(t).length===0?null:t},ZX=()=>{if(typeof window>`u`)return null;try{let e=(document.currentScript instanceof HTMLScriptElement?document.currentScript:null)?.getAttribute(`data-options`);return e?XX(JSON.parse(e)):null}catch{return null}},QX=e=>e===`Enter`||e===`NumpadEnter`,$X=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,eZ=(e=>({name:e.name,setup:(t,n)=>({actions:[typeof e.contextMenuAction==`function`?e.contextMenuAction(t,n):e.contextMenuAction],cleanup:e.cleanup})}))({name:`copy`,contextMenuAction:{id:`copy`,label:`Copy`,shortcut:`C`,showInToolbarMenu:!0,onAction:e=>{e.copy?.()}}}),tZ={name:`comment`,setup:()=>({actions:[{id:`comment`,label:`Comment`,shortcut:`Enter`,shortcutModifier:!1,showInToolbarMenu:!0,onAction:e=>{e.enterPromptMode?.()}}]})},nZ={name:`edit`,setup:()=>({actions:[{id:`edit`,label:`Style`,shortcut:`S`,shortcutModifier:!1,showInToolbarMenu:!0,onAction:e=>{e.enterEditMode?.()}}]})},rZ={name:`open`,actions:[{id:`open`,label:`Open`,shortcut:`O`,enabled:e=>!!e.filePath,onAction:e=>{e.filePath&&(e.hooks.onOpenFile(e.filePath,e.lineNumber)||vI(e.filePath,e.lineNumber,e.hooks.transformOpenFileUrl),e.hideContextMenu(),e.cleanup())}}]},iZ=e=>{let t=e.left+e.width/2,n=e.top+e.height/2,r=n,i=window.innerHeight-n,a=t,o=window.innerWidth-t,s=Math.min(r,i,a,o);return s===r?`top`:s===a?`left`:s===o?`right`:`bottom`},aZ=()=>{let[e,t]=J(!1),[n,r]=J(null),i=DV(),a=()=>{let e=n();return Uz(e)?e:null},o=()=>{r(null),i.clear(),t(!1)};return{selectedElement:a,isPendingDismiss:e,select:(e,n)=>{r(e),t(!1),n?.shouldPromptBeforeMouseHandoff?i.arm():i.clear()},clear:o,consumeMouseHandoff:()=>i.consume()&&a()!==null,showDismissPrompt:()=>a()?e()?!1:(t(!0),!0):(o(),!1),takeSelection:e=>{let t=a()??(Uz(e)?e:null);return o(),t}}},oZ=async(e,t={})=>(await Promise.allSettled(e.map(e=>LU(e,t)))).map(e=>e.status===`fulfilled`?e.value:``),sZ=[eZ,nZ,tZ,rZ],cZ=!1,lZ=new Set,uZ=e=>{if(typeof window>`u`)return lY();let t={enabled:!0,activationMode:`toggle`,keyHoldDuration:100,allowActivationInsideInput:!0,...ZX(),...e};if(t.enabled===!1||cZ)return lY();cZ=!0,vM(t.container??null),JX(t.telemetry!==!1);let{enabled:n,telemetry:r,container:i,...a}=t;return QL(e=>{let t=!1,n,r=LX(a),{store:i,actions:o,pointer:s,viewportVersion:c,current:l}=zJ({keyHoldDuration:r.store.options.keyHoldDuration??100}),u=Y(()=>l().state===`holding`),d=Y(()=>l().state===`active`),f=Y(()=>{let e=l();return e.state===`active`&&e.phase===`frozen`}),p=Y(()=>{let e=l();return e.state===`active`&&(e.phase===`dragging-select`||e.phase===`dragging-reposition`)}),m=Y(()=>{if(!p())return!1;let e=Math.abs(s().x+window.scrollX-i.dragStart.x),t=Math.abs(s().y+window.scrollY-i.dragStart.y);return e>2||t>2}),h=Y(()=>{let e=l();return e.state===`active`&&e.phase===`dragging-reposition`}),g=Y(()=>{let e=l();return e.state===`active`&&e.phase===`justDragged`}),_=Y(()=>l().state===`copying`),v=Y(()=>i.selectionInteractionLockDepth>0),y=Y(()=>l().state===`justCopied`),b=Y(()=>{let e=l();return e.state===`active`&&!!e.isPromptMode}),x=Y(()=>i.pendingCommentMode||b()),S=Y(()=>{let e=l();return e.state===`active`&&!!e.isPromptMode&&!!e.isPendingDismiss}),C=(e,t)=>{document.body.style[e]=t};tR(oR(d,(e,t)=>{e&&!t?(_L(s().x,s().y),C(`touchAction`,`none`)):!e&&t&&(vL(),C(`touchAction`,``))}));let w=xV(),[T,E]=J(!w||!w.collapsed),[D,O]=J(0),[k,ee]=J(0),[te,A]=J(w),[ne,re]=J(!1),ie=CV(e=>e.shiftKey),[ae,oe]=J(null),[se,ce]=J(null),[le,ue]=J(null),de=NX({store:i,actions:o,isActivated:d,activateRenderer:()=>Gt(),deactivateRenderer:()=>Kt(),performCopyWithLabel:e=>dt(e),onOpen:()=>{kr(),ge?.(),ge=Or(Dr,ce)},onClose:()=>{ge?.(),ge=null,ce(null)}}),fe=Y(()=>i.contextMenuPosition!==null||de.isOpen()),pe=Y(()=>fe()||ae()!==null),me,he=null,ge=null,_e=!1,ve=new WeakMap,ye=aZ(),be=()=>!T()||b()||v()||fe()||ye.isPendingDismiss(),xe=()=>{ve=new WeakMap},Se=()=>{Le(!1),xe()},Ce=e=>{let t=te()??xV(),n={edge:t?.edge??`bottom`,ratio:t?.ratio??.5,collapsed:t?.collapsed??!1,enabled:t?.enabled??!0,defaultAction:t?.defaultAction??`copy`,...e};SV(n),A(n);for(let e of lZ)e(n)},we=()=>{Fe.timerId!==null&&(clearTimeout(Fe.timerId),Fe.timerId=null)},Te=()=>{Fe.copyWaiting=!1,Fe.holdTimerFired=!1,Fe.startTimestamp=null};tR(()=>{if(l().state!==`holding`){we();return}Fe.startTimestamp=Date.now(),Fe.timerId=window.setTimeout(()=>{if(Fe.timerId=null,Fe.copyWaiting){Fe.holdTimerFired=!0;return}o.activate()},i.keyHoldDuration),cR(we)}),tR(()=>{let e=l();if(e.state!==`active`||e.phase!==`justDragged`)return;let t=setTimeout(()=>{o.finishJustDragged()},DM);cR(()=>clearTimeout(t))}),tR(()=>{if(l().state!==`justCopied`)return;let e=setTimeout(()=>{o.finishJustCopied()},DM);cR(()=>clearTimeout(e))}),tR(oR(u,(e,t=!1)=>{!t||e||!d()||(r.store.options.activationMode!==`hold`&&o.setWasActivatedByToggle(!0),r.hooks.onActivate())}));let Ee=(e,t,n)=>{Oe(e,t,n),o.clearInputText()},De=()=>{let e=i.frozenElement||pt();e&&o.enterPromptMode({x:s().x,y:s().y},e)},Oe=(e,t,n)=>{o.setCopyStart({x:t,y:n},e)},ke={lastDetectionTimestamp:0,pendingDetectionScheduledAt:0,latestPointerX:0,latestPointerY:0},Ae=null,[je,Me]=J(null),Ne=(e,t)=>{Ae!==null&&clearTimeout(Ae),Me(null),Ae=window.setTimeout(()=>{Me({x:e,y:t}),Ae=null},32)},Pe=null,Fe={timerId:null,startTimestamp:null,copyWaiting:!1,holdTimerFired:!1},Ie=null,[j,Le]=J(!1),Re=0,ze=!1,Be=null,Ve=()=>{ze=!0,Be!==null&&window.clearTimeout(Be),Be=window.setTimeout(()=>{ze=!1,Be=null},DM)},He=()=>{Be!==null&&(window.clearTimeout(Be),Be=null),ze=!1},Ue=0,We=null,Ge=null,[M,Ke]=J(!1),[qe,Je]=J(null),[Ye,Xe]=J(null),[Ze,Qe]=UJ(Ye),$e=Y(()=>de.isOpen()?tN:x()?eN:M()?qe():d()?$M:null),et=e=>NY(e,QF),tt=HX(QF,et,IJ),nt=KX(s,()=>p(),e=>{if(h()){if(o.shiftDragStart(e),Ie){Ie={x:Ie.x+e.x,y:Ie.y+e.y};return}let{pageX:t,pageY:n}=Et(s().x,s().y);Ie={x:t,y:n}}}),N=Y(()=>d()&&!_()),rt=new Map,it=(e,t)=>{let n=RX(`grabbed`),i={id:n,bounds:e,createdAt:Date.now(),element:t};o.addGrabbedBox(i),r.hooks.onGrabbedBox(e,t);let a=window.setTimeout(()=>{rt.delete(n),o.removeGrabbedBox(n)},DM+125);rt.set(n,a)},at=async e=>{let t=await Promise.all(e.map(async e=>{let t=await SU(e),n=t?.componentName??null,r=t?.filePath,i=t?.lineNumber??void 0,a=t?.columnNumber??void 0;n||=CU(e);let o=e instanceof HTMLElement?e.innerText?.slice(0,100):void 0;return{tagName:bN(e),id:e.id||void 0,className:e.getAttribute(`class`)||void 0,textContent:o,componentName:n??void 0,filePath:r,lineNumber:i,columnNumber:a}}));window.dispatchEvent(new CustomEvent(`react-grab:element-selected`,{detail:{elements:t}}))},ot=BX(o,()=>i.labelInstances),st=async(e,t,n)=>{He(),l().state!==`copying`&&o.startCopy();let r=!1,i;try{r=await e(),r||(i=`Failed to copy`)}catch(e){i=dY(e,`Action failed`)}if(t)for(let e of t)ot.updateAfterCopy(e,r,i);l().state===`copying`&&(r&&o.completeCopy(),n?Kt():r?(o.activate(),Ve()):o.unfreeze())},ct=(e,t,n)=>{let i=e[0],a=n??(i?CU(i):null),o=i?bN(i):null,s=a??o??void 0;return _Y({getContent:r.store.options.getContent,componentName:s,maxContextLines:r.store.options.maxContextLines},r.hooks,e,t)},lt=async(e,t,n)=>{if(e.length===0)return!1;let i=[],a=[];for(let t of e){let{wasIntercepted:e,pendingResult:n}=r.hooks.onElementSelect(t);e||i.push(t),n&&a.push(n),r.store.theme.grabbedBoxes.enabled&&it(IJ(t),t)}await BF();let o=!0;if(i.length>0&&(o=await ct(i,t,n)),a.length>0&&!(await Promise.all(a)).every(Boolean))throw new NV;return at(e),o},ut=e=>{hU(e.primaryElement).then(async t=>{await st(()=>lt(e.targetElements,e.extraPrompt,t??void 0),e.labelInstanceIds.length>0?e.labelInstanceIds:null,e.shouldDeactivateAfter),e.onComplete?.()}).catch(t=>{let n=dY(t,`Action failed`);for(let t of e.labelInstanceIds)ot.updateAfterCopy(t,!1,n);l().state===`copying`&&o.unfreeze()})},dt=e=>{let{element:t,cursorX:n,selectedElements:r,extraPrompt:a,shouldDeactivateAfter:s,onComplete:c,dragRect:l}=e,u=r??[t],d=l??i.frozenDragRect,f=u.length>1,p=!f&&t===yt()?Tt():void 0,m=d&&f?DY(d):p??IJ(t),h=f?m.x+m.width/2:n,g=bN(t);He(),o.startCopy();let _=g?ot.createInstance(m,g,void 0,`copying`,{element:t,mouseX:h,elements:r}):null;ut({primaryElement:t,targetElements:u,labelInstanceIds:_?[_]:[],extraPrompt:a,shouldDeactivateAfter:s,onComplete:c})},ft=e=>{let{elements:t,labelEntries:n,shouldDeactivateAfter:r,onComplete:i}=e,a=t[0];He(),o.startCopy(),ut({primaryElement:a,targetElements:t,labelInstanceIds:ot.createPerElementInstances(n,`copying`),shouldDeactivateAfter:r,onComplete:i})},pt=Y(()=>{if(c(),!N()||m()||v()||ye.isPendingDismiss())return null;let e=i.detectedElement;return Uz(e)?e:null}),P=Y(()=>i.frozenElement||(f()?null:pt())),mt=Y(()=>!d()||b()||j()||_()||pe()||ye.isPendingDismiss()?null:ie()?f()?P():pt()??i.frozenElement:ye.selectedElement()),ht=Y(()=>{let e=mt();return e?AY(e,QF,et):[]}),gt=Y(()=>{let e=mt();return e?Math.max(0,ht().findIndex(t=>t.element===e)):0}),_t=Y(()=>mt()!==null);tR(()=>{let e=i.detectedElement;if(!e)return;let t=setInterval(()=>{Uz(e)||o.setDetectedElement(null)},100);cR(()=>clearInterval(t))}),tR(oR(P,e=>{if(We!==null&&(clearTimeout(We),We=null),!e){Xe(null);return}We=window.setTimeout(()=>{We=null,Xe(e)},100)})),cR(()=>{We!==null&&(clearTimeout(We),We=null)}),tR(()=>{let e=i.frozenElements;cR(XI(e))}),tR(oR(d,e=>{e&&r.store.options.freezeReactUpdates&&cR(JL())}));let vt=()=>{if(i.isTouchMode&&p()){let e=i.detectedElement;return!e||HF(e)?void 0:e}let e=P();if(!(!e||HF(e)))return e},yt=Y(()=>vt()),bt=()=>yt()?i.isTouchMode&&p()?N():N()&&!m():!1,xt=NR(()=>i.frozenElements,e=>Y(()=>(c(),IJ(e)))),St=Y(()=>{let e=i.frozenElements;if(e.length===0)return[];let t=i.frozenDragRect;return t&&e.length>1?[DY(t)]:xt().map(e=>e())}),Ct=Y(()=>{if(!j()||i.pendingCommentMode||M())return null;let e=i.detectedElement;return!Uz(e)||HF(e)||i.frozenElements.includes(e)?null:e}),wt=Y(()=>{c();let e=Ct();if(e)return IJ(e)}),Tt=Y(()=>{c();let e=i.frozenElements;if(e.length>0){let t=St();if(e.length===1){let e=t[0];if(e)return e}let n=i.frozenDragRect;return n?t[0]??DY(n):kY(HY(t))}let t=yt();if(t)return IJ(t)}),Et=(e,t)=>({pageX:e+window.scrollX,pageY:t+window.scrollY}),Dt=(e,t)=>{let{pageX:n,pageY:r}=Et(e,t);return{x:Math.abs(n-i.dragStart.x),y:Math.abs(r-i.dragStart.y)}},Ot=Y(()=>{if(!p())return!1;let e=Dt(s().x,s().y);return e.x>2||e.y>2}),kt=(e,t)=>{let{pageX:n,pageY:r}=Et(e,t),a=Math.min(i.dragStart.x,n),o=Math.min(i.dragStart.y,r),s=Math.abs(n-i.dragStart.x),c=Math.abs(r-i.dragStart.y);return{x:a-window.scrollX,y:o-window.scrollY,width:s,height:c}},At=e=>e.code===`Space`||e.key===` `,jt=()=>{if(!p())return;o.startDragReposition();let{pageX:e,pageY:t}=Et(s().x,s().y);Ie={x:e,y:t}},Mt=()=>{o.stopDragReposition(),Ie=null},Nt=Y(()=>{if(c(),Ot())return kY(kt(s().x,s().y))}),Pt=Y(()=>{if(c(),!Ot())return[];let e=je();if(!e)return[];let t=kt(e.x,e.y),n=wY(t,QF);return(n.length>0?n:wY(t,QF,!1)).map(e=>IJ(e))}),Ft=Y(()=>{let e=Pt();if(e.length>0)return e;let t=wt();return t?[...St(),t]:St()}),It=NR(()=>i.frozenElements,e=>{let t=bN(e)||`element`,n=CU(e)??void 0;return Y(()=>{if(c(),!Uz(e))return null;let r=IJ(e),i=ve.get(e);return{tagName:t,componentName:n,bounds:r,mouseX:i===void 0?void 0:r.x+r.width*i}})}),Lt=Y(()=>{if(b()||i.frozenElements.length<2)return[];let e=[];for(let t of It()){let n=t();n!==null&&e.push(n)}return e}),Rt=Y(()=>{if(b())return null;let e=Ct();return e?(c(),{tagName:bN(e)||`element`,componentName:CU(e)??void 0,bounds:IJ(e),mouseX:s().x}):null}),zt=Y(()=>{if(_()||b()){c();let e=i.frozenElement||pt();return e?{x:LJ(IJ(e)).x+i.copyOffsetFromCenterX,y:i.copyStart.y}:{x:i.copyStart.x,y:i.copyStart.y}}return{x:s().x,y:s().y}}),Bt=Y(()=>{if(!j()||i.frozenElements.length!==1)return;c();let e=i.frozenElements[0];if(!Uz(e))return;let t=ve.get(e);if(t===void 0)return;let n=IJ(e);return n.x+n.width*t});tR(oR(()=>[pt(),i.lastGrabbedElement],([e,t])=>{t&&e&&t!==e&&o.setLastGrabbed(null),e&&r.hooks.onElementHover(e)})),tR(oR(()=>pt(),e=>{let t=++Ue,n=()=>{Ue===t&&o.setSelectionSource(null,null)};if(!e){n();return}SU(e).then(e=>{if(Ue===t){if(!e){n();return}o.setSelectionSource(e.filePath,e.lineNumber)}}).catch(()=>{Ue===t&&o.setSelectionSource(null,null)})}));let Vt=Y(()=>i.grabbedBoxes.map(e=>({id:e.id,bounds:e.bounds,createdAt:e.createdAt}))),Ht=Y(()=>i.labelInstances.map(e=>({id:e.id,status:e.status,tagName:e.tagName,componentName:e.componentName,createdAt:e.createdAt})));tR(oR(Y(()=>{let e=d(),t=p(),n=_(),a=b(),o=pt(),s=Nt(),c=r.store.theme.enabled,l=r.store.theme.selectionBox.enabled,u=r.store.theme.dragBox.enabled,f=Ot(),m=P(),h=y();return{isActive:e,isDragging:t,isCopying:n,isPromptMode:a,isSelectionBoxVisible:!!(c&&l&&e&&!n&&!h&&!t&&m!=null),isDragBoxVisible:!!(c&&u&&e&&!n&&f),targetElement:o,dragBounds:s?{x:s.x,y:s.y,width:s.width,height:s.height}:null,grabbedBoxes:[...Vt()],labelInstances:[...Ht()],selectionFilePath:i.selectionFilePath,toolbarState:te()}}),e=>{r.hooks.onStateChange(e)})),tR(oR(()=>{let e=b();return{inputMode:e,position:e?s():aR(s),target:e?pt():aR(pt)}},({inputMode:e,position:t,target:n})=>{r.hooks.onPromptModeChange(e,{x:t.x,y:t.y,targetElement:n})})),tR(oR(()=>[ar(),Tt(),pt()],([e,t,n])=>{r.hooks.onSelectionBox(!!e,t??null,n)})),tR(oR(()=>[fr(),Nt()],([e,t])=>{r.hooks.onDragBox(!!e,t??null)})),tR(oR(()=>{let e=mr();return[e,pr(),e?zt():aR(zt),e?pt():aR(pt),i.selectionFilePath,i.selectionLineNumber]},([e,t,n,i,a,o])=>{r.hooks.onElementLabel(e,t,{x:n.x,y:n.y,content:``,element:i??void 0,tagName:i&&bN(i)||void 0,filePath:a??void 0,lineNumber:o??void 0})}));let Ut=null,Wt=e=>{if(e){if(!Ut){Ut=document.createElement(`style`),Ut.setAttribute(`data-react-grab-cursor`,``);let e=SN();e&&(Ut.nonce=e),wN(Ut),document.head.appendChild(Ut)}Ut.textContent=`* { cursor: ${e} !important; }`}else Ut&&=(Ut.remove(),null)};tR(oR(()=>[d(),_(),b()],([e,t,n])=>{Wt(t?`progress`:e&&!n?`crosshair`:null)}));let Gt=()=>{let e=u();o.activate(),e||r.hooks.onActivate()},Kt=()=>{let e=p(),t=i.previouslyFocusedElement;Mt(),o.deactivate(),de.resetWithDiscard(),kr(),Se(),wn(),ye.clear(),Ke(!1),Je(null),e&&C(`userSelect`,``),Pe&&window.clearTimeout(Pe),nt.stop(),t instanceof HTMLElement&&t!==document.body&&t!==document.activeElement&&Uz(t)&&t.focus({preventScroll:!0}),r.hooks.onDeactivate()},qt=()=>{u()&&o.releaseHold(),d()&&Kt(),He()},Jt=()=>{o.setWasActivatedByToggle(!0),Gt()},Yt=()=>{let e=[...i.frozenElements],t=i.frozenElement||pt(),n=b()?i.inputText.trim():``;if(!t){Kt();return}let r=e.length>0?e:[t],a=r.map(e=>IJ(e))[0],{x:s,y:c}=LJ(a),l=s+i.copyOffsetFromCenterX;o.setPointer({x:s,y:c}),o.exitPromptMode(),o.clearInputText(),dt({element:t,cursorX:l,selectedElements:r,extraPrompt:n||void 0,shouldDeactivateAfter:!0})},Xt=()=>{if(b()){if(S()){o.clearInputText(),Kt();return}o.setPendingDismiss(!0),ee(e=>e+1)}},Zt=()=>{if(ye.isPendingDismiss()){Dn();return}o.clearInputText(),Kt()},Qt=()=>{o.setPendingDismiss(!1)},$t=()=>{if(de.isOpen()){de.dismiss();return}let e=i.frozenElement||pt();e&&en(e,{x:s().x,y:s().y})},en=(e,t,n={})=>de.trigger(e,t,n),tn=(e,t)=>{if(!de.isOpen()||i.contextMenuPosition!==null)return!1;let n=mI(e,t).find(QF);if(!n)return!1;let r=de.switchToElement(n,{x:e,y:t});return r&&JI([n]),r},nn=e=>({filePath:i.selectionFilePath??void 0,lineNumber:i.selectionLineNumber??void 0,componentName:Ze(),tagName:bN(e)||void 0}),rn=()=>{Ge=null,Ke(!1),o.setPendingCommentMode(!1),Je(null)},an=e=>{let t=i.frozenElement||pt();if(!t)return!1;let n={x:s().x,y:s().y},a=r.store.actions.find(t=>t.id===e);return a?e===`edit`?en(t,n,nn(t))?(o.clearInputText(),o.exitPromptMode(),rn(),!0):!0:(o.clearInputText(),o.exitPromptMode(),rn(),a.onAction(Nn(t,n)),!0):(o.clearInputText(),o.exitPromptMode(),rn(),Mr($M),ln(t,n),!0)},on=e=>{if(d()){if($e()!==e&&b()&&an(e))return;if($e()!==e&&i.pendingCommentMode){o.setPendingCommentMode(!1),Ge=e,Je(e),Ke(!0);return}if($e()!==e&&M()){Ge=e,Je(e);return}Kt();return}T()&&(Ge=e,Je(e),Ke(!0),Jt())},sn=()=>{on(te()?.defaultAction??`copy`)},cn=(e,t,n)=>{rn(),o.clearInputText(),o.enterPromptMode({x:t,y:n},e)},ln=(e,t)=>{Se(),Ar(),o.showContextMenu(t,e),wn(),r.hooks.onContextMenu(e,t)},un=(e,t)=>{let n=Ge;if(Ge=null,Je(null),!n)return;if(n===`edit`){en(e,t,nn(e));return}let i=r.store.actions.find(e=>e.id===n);if(!i){Mr($M),ln(e,t);return}i.onAction(Nn(e,t))},dn=()=>{if(T()){if(d()&&x()){Kt();return}o.setPendingCommentMode(!0),d()||Jt()}},fn=(e,t,n)=>{let r=n&&j()&&!p()&&!i.pendingCommentMode&&!M();if(be()||f()&&!r)return;if(o.setPointer({x:e,y:t}),ke.latestPointerX=e,ke.latestPointerY=t,r){let n=hI(e,t);n!==i.detectedElement&&o.setDetectedElement(n);return}let a=performance.now(),s=ke.pendingDetectionScheduledAt>0&&a-ke.pendingDetectionScheduledAt<200;if(a-ke.lastDetectionTimestamp>=32&&!s&&(ke.lastDetectionTimestamp=a,ke.pendingDetectionScheduledAt=a,setTimeout(()=>{if(be()){ke.pendingDetectionScheduledAt=0;return}let e=hI(ke.latestPointerX,ke.latestPointerY);e!==i.detectedElement&&o.setDetectedElement(e),ke.pendingDetectionScheduledAt=0})),p()){if(h()){let{pageX:n,pageY:r}=Et(e,t);Ie&&o.shiftDragStart({x:n-Ie.x,y:r-Ie.y}),Ie={x:n,y:r}}Ne(e,t);let n=GX(e,t),r=n.top||n.bottom||n.left||n.right;r&&!nt.isActive()?nt.start():!r&&nt.isActive()&&nt.stop()}},pn=(e,t,n)=>{if(!N()||v())return!1;!n&&j()&&Se();let i=ye.selectedElement()!==null;return o.startDrag({x:e,y:t},n||i),o.setPointer({x:e,y:t}),C(`userSelect`,`none`),Ne(e,t),r.hooks.onDragStart(e+window.scrollX,t+window.scrollY),!0},mn=(e,t)=>{let n=i.frozenElements.includes(e),r=i.frozenElements.length===0;if(!n){let n=TY(IJ(e),t);ve.set(e,n),r&&Qe(CU(e)??void 0)}o.toggleFrozenElement(e),gI();let a=i.frozenElements.includes(e);if(a||ve.delete(e),i.frozenElements.length===0){Se(),o.unfreeze();return}JI(i.frozenElements),Le(!0),o.setPointer(t),o.setLastGrabbed(a?e:i.frozenElements[i.frozenElements.length-1]),o.freeze(),wn()},hn=()=>{let e=i.frozenElements.filter(Uz),t=e.map(e=>{let t=bN(e)||`element`,n=CU(e)??void 0,r=ve.get(e),i=IJ(e);return{element:e,tagName:t,componentName:n,mouseX:r===void 0?i.x+i.width/2:i.x+i.width*r}});if(Se(),e.length===0){o.unfreeze();return}if(e.length===1){dt({element:e[0],cursorX:t[0].mouseX,selectedElements:e,shouldDeactivateAfter:i.wasActivatedByToggle});return}ft({elements:e,labelEntries:t,shouldDeactivateAfter:i.wasActivatedByToggle})},gn=(e,t,n)=>{let a=wY(e,QF),s=a.length>0?a:wY(e,QF,!1);if(s.length===0)return;let c=n&&!i.pendingCommentMode&&!M();if(c&&o.addFrozenElements(s),JI(c?i.frozenElements:s),r.hooks.onDragEnd(s,e),c){let e=s[s.length-1];Le(!0),gI(),o.setPointer(LJ(IJ(e))),o.setLastGrabbed(e),o.freeze(),wn();return}let l=s[0],u=LJ(IJ(l));o.setPointer(u),o.setFrozenElements(s);let d=OY(e);if(o.setFrozenDragRect(d),o.freeze(),o.setLastGrabbed(l),i.pendingCommentMode){cn(l,u.x,u.y);return}if(M()){Ke(!1),Ge?un(l,u):ln(l,u);return}let f=i.wasActivatedByToggle&&!t;dt({element:l,cursorX:u.x,selectedElements:s,shouldDeactivateAfter:f,dragRect:d})},_n=e=>{for(let t of i.frozenElements)if(Uz(t)&&$X(e,IJ(t)))return t;return null},vn=(e,t,n,a)=>{let c=Uz(i.frozenElement)?i.frozenElement:null,l=ye.selectedElement(),u=()=>mI(e,t).find(QF)??null;if(a&&!i.pendingCommentMode&&!M()){let n=u();n!==null&&mn(n,{x:e,y:t});return}let d=u()??(Uz(i.detectedElement)?i.detectedElement:null),f=l??d??c;if(!f)return;let p,m,h=d===null&&c===f,g=l===f;if(h)p=s().x,m=s().y;else if(g){let e=LJ(IJ(f));p=e.x,m=e.y}else p=e,m=t;if(i.pendingCommentMode){cn(f,p,m),ye.clear();return}if(M()){Ke(!1);let{wasIntercepted:e}=r.hooks.onElementSelect(f);if(e)return;ye.clear(),JI([f]),o.setFrozenElement(f);let t={x:p,y:m};o.setPointer(t),o.freeze(),Ge?un(f,t):ln(f,t);return}let _=i.wasActivatedByToggle&&!n;o.setLastGrabbed(f),dt({element:f,cursorX:p,shouldDeactivateAfter:_}),ye.clear()},yn=()=>{p()&&(Mt(),o.cancelDrag(),nt.stop(),C(`userSelect`,``))},bn=(e,t,n,r)=>{if(!p())return;Ae!==null&&(clearTimeout(Ae),Ae=null),Me(null);let i=Dt(e,t),a=i.x>2||i.y>2,s=a?kt(e,t):null;a?o.endDrag():o.cancelDrag(),Mt(),nt.stop(),C(`userSelect`,``),s?gn(s,n,r):vn(e,t,n,r)},xn=uY(),Sn=WX(),Cn=e=>{let t;try{t=Sn.originalKeyDescriptor?.get?Sn.originalKeyDescriptor.get.call(e):e.key}catch{return!1}let n=t===`Enter`||QX(e.code),r=d()||u();return n&&r&&!b()&&!ye.isPendingDismiss()&&!i.wasActivatedByToggle?vB(e,`data-react-grab-input`)?!1:(Sn.claimedEvents.add(e),e.preventDefault(),e.stopImmediatePropagation(),!0):!1};xn.addDocumentListener(`keydown`,xM(Cn),{capture:!0}),xn.addDocumentListener(`keyup`,xM(Cn),{capture:!0}),xn.addDocumentListener(`keypress`,xM(Cn),{capture:!0});let wn=()=>{tt.clearHistory(),ye.clear()},Tn=(e,t=!1)=>{o.setFrozenElement(e),o.freeze(),ye.select(e,{shouldPromptBeforeMouseHandoff:t});let n=LJ(IJ(e));o.setPointer(n),i.contextMenuPosition!==null&&o.showContextMenu(n,e)},En=()=>{ye.showDismissPrompt()&&ee(e=>e+1)},Dn=()=>{ye.clear(),o.unfreeze(),wn()},On=()=>{let e=ye.takeSelection(i.frozenElement);if(!e){Dn();return}let t=LJ(IJ(e));wn(),o.setLastGrabbed(e),dt({element:e,cursorX:t.x,shouldDeactivateAfter:i.wasActivatedByToggle})},kn=e=>JM.has(e.key)?e.key:e.key===`Tab`?e.shiftKey?`ArrowLeft`:`ArrowRight`:null,An=(e,t={})=>{if(!d()||b()||j()||ye.isPendingDismiss()&&!t.allowPendingKeyboardSelection)return!1;let n=kn(e);if(!n||pe())return!1;let r=P(),i=!r;if(!r){let e=yM()?.getBoundingClientRect();r=e?hI(e.left+e.width/2,e.top+e.height/2):hI(window.innerWidth/2,window.innerHeight/2)}if(!r)return!1;let a=n===`ArrowUp`||n===`ArrowDown`,o=tt.findNext(n,r);if(!o&&!a&&!i)return!1;let s=o??r;return e.preventDefault(),e.stopPropagation(),Tn(s,!0),!0},jn=e=>e.metaKey||e.ctrlKey||e.altKey||e.repeat||Kz(e)||!d()||_()||v()||pe()?null:i.frozenElement||pt(),Mn=e=>{let t=jn(e);if(!t)return null;let n=EV(r.store.actions,e);return n?{element:t,action:n}:null},Nn=(e,t)=>{let n=IJ(e);return Cr({element:e,filePath:i.selectionFilePath??void 0,lineNumber:i.selectionLineNumber??void 0,tagName:bN(e)||void 0,componentName:Ze(),position:t,shouldDeferHideContextMenu:!1,performWithFeedbackOptions:{fallbackBounds:n,fallbackSelectionBounds:[n],position:t}})},Pn=/^[a-zA-Z0-9-]$/,Fn=e=>{if(!e.key||e.key.length!==1||!Pn.test(e.key))return!1;let t=jn(e);return!t||!de.trigger(t,{x:s().x,y:s().y},{initialSearchQuery:e.key})?!1:(rn(),e.preventDefault(),e.stopImmediatePropagation(),!0)},In=e=>{let t=Mn(e);if(!t)return!1;let{element:n,action:r}=t;if(b())return an(r.id)?(e.preventDefault(),e.stopImmediatePropagation(),!0):!1;let i={x:s().x,y:s().y};return r.onAction(Nn(n,i)),e.preventDefault(),e.stopImmediatePropagation(),!0},Ln=e=>{if(e.key?.toLowerCase()!==`o`||!d()||!(e.metaKey||e.ctrlKey))return!1;let t=i.selectionFilePath,n=i.selectionLineNumber;return t?(e.preventDefault(),e.stopPropagation(),r.hooks.onOpenFile(t,n??void 0)||vI(t,n??void 0,r.hooks.transformOpenFileUrl),!0):!1},Rn=e=>{if(!d()||_()||i.contextMenuPosition!==null||de.isOpen())return!1;let t=e.key===`F10`&&e.shiftKey,n=e.key===`ContextMenu`;if(!t&&!n)return!1;let r=i.frozenElements,a=r.length>1,s=(a?r[0]:null)||i.frozenElement||pt();if(!s)return!1;e.preventDefault(),e.stopPropagation();let c=LJ(IJ(s));return a?JI(r):(JI([s]),o.setFrozenElement(s)),o.setPointer(c),o.freeze(),ln(s,c),!0},zn=Y(()=>ht().map(e=>({tagName:bN(e.element)||`element`,componentName:CU(e.element)??void 0,depth:e.depth,isLast:e.isLast}))),Bn=Y(()=>({items:zn(),activeIndex:gt()})),Vn=e=>{if(!(!r.store.options.allowActivationInsideInput&&Kz(e))&&!(!VY(e,r.store.options)&&((e.metaKey||e.ctrlKey)&&!qM.includes(e.key)&&!QX(e.code)&&(d()&&!i.wasActivatedByToggle?Kt():u()&&(we(),Te(),o.releaseHold())),!QX(e.code)||!u()))){if((d()||u())&&!b()&&(e.preventDefault(),QX(e.code)&&e.stopImmediatePropagation()),d()){if(i.wasActivatedByToggle&&r.store.options.activationMode!==`hold`||e.repeat)return;Pe!==null&&window.clearTimeout(Pe),Pe=window.setTimeout(()=>{Kt()},200);return}if(u()&&e.repeat){if(Fe.copyWaiting){let e=Fe.holdTimerFired;Te(),e&&o.activate()}return}if(!(_()||y())&&!u()){let t=r.store.options.keyHoldDuration??100;Kz(e)?qz(e)?t+=600:t+=400:Jz()&&(t+=600),Te(),o.startHold(t)}}},Hn=e=>{if(!ye.isPendingDismiss())return!1;if(QX(e.code))return!0;let t=JM.has(e.key),n=Mn(e)!==null;return!t&&!n?!1:t?An(e,{allowPendingKeyboardSelection:!0}):In(e)?(wn(),!0):!1};xn.addWindowListener(`keydown`,xM(e=>{if(kn(e)&&Kz(e)||Hn(e))return;if(Cn(e),!T()){VY(e,r.store.options)&&!e.repeat&&O(e=>e+1);return}let t=QX(e.code)&&u()&&!b(),n=vB(e,ZM);if(b()&&VY(e,r.store.options)&&!e.repeat&&!n){e.preventDefault(),e.stopPropagation(),Xt();return}if(e.key===`Escape`&&pe()){ae()!==null&&kr();return}let a=vB(e,`data-react-grab-ignore-events`)&&!t;if(b()||a)return b()&&!n&&In(e)||(e.key===`Escape`&&(b()?Xt():i.wasActivatedByToggle&&Kt()),a&&JM.has(e.key)&&An(e)),void 0;if(p()&&At(e)){e.repeat||jt(),e.preventDefault(),e.stopPropagation();return}if(e.key===`Escape`&&(u()||i.wasActivatedByToggle)){Kt();return}d()&&!qM.includes(e.key)&&e.preventDefault();let o=Date.now()-Re<200;An(e)||Ln(e)||Rn(e)||In(e)||Fn(e)||o||Vn(e)}),{capture:!0}),xn.addWindowListener(`keyup`,xM(e=>{if(Cn(e))return;if(At(e)&&h()&&(Mt(),e.preventDefault(),e.stopPropagation()),e.key===`Shift`&&j()){p()&&yn(),hn();return}if(vB(e,`data-react-grab-ignore-events`))return;let t=UX(r.store.options),n=t.metaKey||t.ctrlKey?_B()?!e.metaKey:!e.ctrlKey:t.shiftKey&&!e.shiftKey||t.altKey&&!e.altKey,a=r.store.options.activationKey?typeof r.store.options.activationKey==`function`?r.store.options.activationKey(e):zY(r.store.options.activationKey)(e):FY(e.key,e.code);if(y()||ze){(a||n)&&(He(),Kt());return}if(!u()&&!d()||b())return;let s=!!r.store.options.activationKey,c=r.store.options.activationMode===`hold`,l=p();if(d()){let e=fe();if(n){if(i.wasActivatedByToggle&&r.store.options.activationMode!==`hold`||e)return;Kt()}else if(c&&a){if(Pe!==null&&(window.clearTimeout(Pe),Pe=null),e||l)return;Kt()}else!s&&a&&Pe!==null&&(window.clearTimeout(Pe),Pe=null);return}if(a||n){if(i.wasActivatedByToggle&&r.store.options.activationMode!==`hold`)return;if(u()||Fe.holdTimerFired&&n){we();let t=(Fe.startTimestamp?Date.now()-Fe.startTimestamp:0)>=200,n=Fe.holdTimerFired&&t&&(r.store.options.allowActivationInsideInput||!Kz(e));Te(),n?o.activate():o.releaseHold()}else Kt()}}),{capture:!0}),xn.addDocumentListener(`copy`,()=>{u()&&(Fe.copyWaiting=!0)}),xn.addWindowListener(`keypress`,xM(Cn),{capture:!0}),xn.addWindowListener(`pointermove`,xM(e=>{if(!e.isPrimary)return;let t=e.pointerType===`touch`;if(o.setTouchMode(t),!vB(e,`data-react-grab-ignore-events`)&&!be()&&!(t&&!u()&&!d())){if((t?u():d())&&!b()&&f()&&!e.shiftKey&&!j()){if(ye.consumeMouseHandoff()){En();return}o.unfreeze(),wn()}fn(e.clientX,e.clientY,e.shiftKey)}}),{passive:!0}),xn.addWindowListener(`pointerdown`,xM(e=>{if(e.button===0&&e.isPrimary&&(o.setTouchMode(e.pointerType===`touch`),_e=!1,!vB(e,`data-react-grab-ignore-events`))){if(fe()){tn(e.clientX,e.clientY)&&(_e=!0,e.preventDefault(),e.stopImmediatePropagation());return}if(b()){let t=Tt();t&&e.clientX>=t.x&&e.clientX<=t.x+t.width&&e.clientY>=t.y&&e.clientY<=t.y+t.height?Yt():Xt();return}if(ye.isPendingDismiss()){e.preventDefault(),e.stopImmediatePropagation();return}if(v()){e.preventDefault(),e.stopImmediatePropagation();return}pn(e.clientX,e.clientY,e.shiftKey)&&(e.pointerId!==void 0&&document.documentElement.setPointerCapture(e.pointerId),e.preventDefault(),e.stopImmediatePropagation())}}),{capture:!0}),xn.addWindowListener(`pointerup`,xM(e=>{if(e.button!==0||!e.isPrimary||vB(e,`data-react-grab-ignore-events`)||fe())return;let t=N()||v()||p(),n=e.metaKey||e.ctrlKey;bn(e.clientX,e.clientY,n,e.shiftKey),t&&(e.preventDefault(),e.stopImmediatePropagation())}),{capture:!0}),xn.addWindowListener(`contextmenu`,xM(e=>{if(!N()||_()||b()||de.isOpen())return;let t=vB(e,`data-react-grab-ignore-events`),n={x:e.clientX,y:e.clientY},r=t&&i.frozenElements.length>1?_n(n):null,a=ye.isPendingDismiss();if(t&&!r&&!a&&!_t())return;if(fe()){e.preventDefault();return}e.preventDefault(),e.stopPropagation();let s=r??hI(e.clientX,e.clientY);if(!s)return;let c=i.frozenElements;c.length>1&&c.includes(s)?JI(c):(JI([s]),o.setFrozenElement(s)),o.setPointer(n),o.freeze(),ln(s,n)}),{capture:!0}),xn.addWindowListener(`pointercancel`,xM(e=>{e.isPrimary&&yn()})),xn.addWindowListener(`click`,xM(e=>{if(!vB(e,`data-react-grab-ignore-events`)){if(_e){_e=!1,e.preventDefault(),e.stopImmediatePropagation();return}fe()||(N()||g())&&(e.preventDefault(),e.stopImmediatePropagation(),i.wasActivatedByToggle&&!b()&&!e.shiftKey&&(u()?o.setWasActivatedByToggle(!1):Kt()))}}),{capture:!0}),xn.addDocumentListener(`visibilitychange`,()=>{if(document.hidden){o.clearGrabbedBoxes();let e=i.activationTimestamp;d()&&!b()&&e!==null&&Date.now()-e>500&&Kt()}}),xn.addWindowListener(`blur`,()=>{yn(),u()&&(we(),o.releaseHold(),Te()),Se()}),xn.addWindowListener(`focus`,()=>{Re=Date.now()}),xn.addWindowListener(`focusin`,e=>{vB(e,SM)&&e.stopPropagation()},{capture:!0});let Un=()=>{if(!(i.isTouchMode&&!u()&&!d())&&!be()&&!f()&&!p()&&i.frozenElements.length===0){let e=hI(s().x,s().y);o.setDetectedElement(e)}},Wn=null,Gn=null,Kn=()=>{EY(),Un(),o.incrementViewportVersion(),o.updateContextMenuPosition()};xn.addWindowListener(`scroll`,Kn,{capture:!0});let qn=window.innerWidth,Jn=window.innerHeight;xn.addWindowListener(`resize`,()=>{let e=window.innerWidth,t=window.innerHeight;if(qn>0&&Jn>0){let n=e/qn,r=t/Jn,i=Math.abs(n-r)<rN,a=Math.abs(n-1)>rN;i&&a&&o.setPointer({x:s().x*n,y:s().y*r})}qn=e,Jn=t,Kn()});let Yn=window.visualViewport;if(Yn){let{signal:e}=xn;Yn.addEventListener(`resize`,Kn,{signal:e}),Yn.addEventListener(`scroll`,Kn,{signal:e})}let Xn=()=>{Gn===null&&(Gn=RF(()=>{Gn=null,o.incrementViewportVersion()}))};tR(()=>{if(r.store.theme.enabled&&(d()||_()||i.labelInstances.length>0||i.grabbedBoxes.length>0)){if(Wn!==null)return;Wn=window.setInterval(()=>{Xn()},100);return}Wn!==null&&(window.clearInterval(Wn),Wn=null),Gn!==null&&(zF(Gn),Gn=null)}),cR(()=>{Wn!==null&&window.clearInterval(Wn),Gn!==null&&zF(Gn)}),xn.addDocumentListener(`copy`,xM(e=>{b()||vB(e,`data-react-grab-ignore-events`)||N()&&e.preventDefault()}),{capture:!0}),cR(()=>{xn.abort(),Ae!==null&&window.clearTimeout(Ae),Pe&&window.clearTimeout(Pe),He(),he?.(),he=null,ge?.(),ge=null,rt.forEach(e=>window.clearTimeout(e)),rt.clear(),ot.cancelAllFades(),nt.stop(),C(`userSelect`,``),C(`touchAction`,``),Wt(null),Sn.restore(),vM(null)});let{root:Zn,host:Qn}=HJ(wJ);cR(sY(Qn).cleanup);let $n=Y(()=>r.store.theme.enabled),er=Y(()=>r.store.theme.selectionBox.enabled),tr=Y(()=>r.store.theme.elementLabel.enabled),nr=Y(()=>r.store.theme.dragBox.enabled),rr=Y(()=>y()||ne()&&!f()||de.isInteracting()),ir=Y(()=>Pt().length>0),ar=Y(()=>!$n()||!er()||rr()?!1:ir()?!0:bt()),or=Y(()=>{let e=yt();if(e)return bN(e)||void 0}),sr=Y(()=>!$n()||fe()||!tr()||rr()?!1:bt()),cr=new Map,lr=e=>{let t=e.elements?.filter(Uz)??[],n=e.element,r=null;t.length>0?r=t.map(IJ):n&&Uz(n)&&(r=[IJ(n)]);let i=e.bounds,a=e.boundsMultiple;r&&(i=r.length>1?kY(HY(r)):r[0],e.boundsMultiple!==void 0&&(a=e.boundsMultiple.length>1&&e.boundsMultiple.length===e.elements?.length?r:[i]));let o=cr.get(e.id),s=o?.boundsMultiple,c=s===a||s!==void 0&&a!==void 0&&s.length===a.length&&s.every((e,t)=>e.x===a[t].x&&e.y===a[t].y&&e.width===a[t].width&&e.height===a[t].height);if(o&&o.status===e.status&&o.errorMessage===e.errorMessage&&o.bounds.x===i.x&&o.bounds.y===i.y&&o.bounds.width===i.width&&o.bounds.height===i.height&&c)return o;let l=i.x+i.width/2,u=i.width/2,d;d=e.mouseXOffsetRatio!==void 0&&u>0?l+e.mouseXOffsetRatio*u:e.mouseXOffsetFromCenter===void 0?e.mouseX??l:l+e.mouseXOffsetFromCenter;let f={...e,bounds:i,boundsMultiple:a,mouseX:d};return cr.set(e.id,f),f},ur=Y(()=>{if(!$n()||!r.store.theme.grabbedBoxes.enabled)return[];c();let e=new Set(i.labelInstances.map(e=>e.id));for(let t of cr.keys())e.has(t)||cr.delete(t);return i.labelInstances.map(lr)}),dr=Y(()=>!$n()||!r.store.theme.grabbedBoxes.enabled?[]:(c(),i.grabbedBoxes.map(e=>!e.element||!document.body.contains(e.element)?e:{...e,bounds:IJ(e.element)}))),fr=Y(()=>$n()&&nr()&&N()&&Ot()),pr=Y(()=>_()?`processing`:`hover`),mr=Y(()=>{if(!$n())return!1;let e=tr(),t=b(),n=_(),r=N(),i=p(),a=!!P(),o=ne(),s=f();return!e||t||o&&!s?!1:n?!0:r&&!i&&a}),hr=Y(()=>{c();let e=i.contextMenuElement;return e?IJ(e):null}),gr=Y(()=>(c(),i.contextMenuPosition)),_r=Y(()=>{let e=i.contextMenuElement;if(!e)return;let t=i.frozenElements.length;return t>1?`${t} elements`:bN(e)||void 0}),[vr]=UJ(()=>i.frozenElements.length>1?null:i.contextMenuElement),[yr]=rR(()=>i.contextMenuElement,async e=>e?SU(e):null),br=async e=>{o.incrementSelectionInteractionLockDepth();try{return await e()}finally{o.decrementSelectionInteractionLockDepth()}},xr=(e,t,n,r,a)=>async c=>{await br(async()=>{let l=a?.fallbackBounds??null,u=a?.fallbackSelectionBounds??[],d=a?.position??i.contextMenuPosition??s(),f=St(),p=hr()??l,m=t.length>1,h=m?kY(HY(f)):p,g=i.wasActivatedByToggle,_;if(_=m?f:p?[p]:u,o.hideContextMenu(),h){let i=m?h.x+h.width/2:d.x,a=ot.createInstance(h,n||`element`,r,`copying`,{element:e,mouseX:i,elements:m?t:void 0,boundsMultiple:_}),o=!1,s;try{o=await c(),o||(s=`Failed to copy`)}catch(e){s=dY(e,`Action failed`)}ot.updateAfterCopy(a,o,s)}else try{await c()}catch{}g?Kt():o.unfreeze()})},Sr=()=>{setTimeout(()=>{o.hideContextMenu()},0)},Cr=e=>{let{element:t,filePath:n,lineNumber:a,tagName:s,componentName:c,position:l,performWithFeedbackOptions:u,shouldDeferHideContextMenu:f,onBeforeCopy:p,onBeforePrompt:m,customEnterPromptMode:h}=e,g=i.frozenElements.length>0?i.frozenElements:[t],_=f?Sr:o.hideContextMenu,v={element:t,elements:g,filePath:n,lineNumber:a,componentName:c,tagName:s,enterPromptMode:h??(()=>{ot.clearAll(),rn(),m?.(),Ee(t,l.x,l.y),o.setPointer({x:l.x,y:l.y}),o.setFrozenElement(t),De(),d()||Gt(),_()}),enterEditMode:()=>{en(t,l,{filePath:n,lineNumber:a,componentName:c,tagName:s})&&rn(),_()},copy:()=>{rn(),p?.(),dt({element:t,cursorX:l.x,selectedElements:g.length>1?g:void 0,shouldDeactivateAfter:i.wasActivatedByToggle}),_()},hooks:{transformHtmlContent:r.hooks.transformHtmlContent,onOpenFile:r.hooks.onOpenFile,transformOpenFileUrl:r.hooks.transformOpenFileUrl},performWithFeedback:xr(t,g,s,c,u),hideContextMenu:_,cleanup:()=>{i.wasActivatedByToggle?Kt():o.unfreeze()}},y=r.hooks.transformActionContext(v);return{...v,...y}},wr=Y(()=>{let e=i.contextMenuElement;if(!e)return;let t=yr(),n=i.contextMenuPosition??s();return Cr({element:e,filePath:t?.filePath,lineNumber:t?.lineNumber??void 0,tagName:_r(),componentName:vr(),position:n,shouldDeferHideContextMenu:!0,onBeforeCopy:()=>{ye.clear()},customEnterPromptMode:()=>{ot.clearAll(),rn(),o.clearInputText(),o.enterPromptMode(n,e),Sr()}})}),Tr=()=>{setTimeout(()=>{o.hideContextMenu(),Kt()},0)},Er=()=>{if(!me)return null;let e=me.getBoundingClientRect(),t=iZ(e);return t===`left`||t===`right`?{x:t===`left`?e.right:e.left,y:e.top+e.height/2,edge:t}:{x:e.left+e.width/2,y:t===`top`?e.bottom:e.top,edge:t}},Dr=()=>{let e=Er();if(e)return e;let t=de.state();return t?{x:t.position.x,y:t.position.y,edge:`bottom`}:null},Or=(e,t)=>{let n=null,r=()=>{let i=e();i&&t(i),n=RF(r)};return r(),()=>{n!==null&&(zF(n),n=null)}};tR(()=>{if(!_t())return;let e=Or(Er,ue);cR(()=>{e(),ue(null)})});let kr=()=>{he?.(),he=null,oe(null)},Ar=()=>{o.hideContextMenu(),kr(),de.dismiss()},jr=()=>{ae()===null?(o.hideContextMenu(),de.isOpen()&&de.closePreservingRenderer(),he?.(),he=Or(Er,oe)):kr()},Mr=e=>{Ce({defaultAction:e})},Nr=e=>{let t=i.labelInstances.find(t=>t.id===e);if(!t?.element||!Uz(t.element))return;let n=t.element,r=LJ(IJ(n)),a={x:t.mouseX??r.x,y:r.y},s=t.elements&&t.elements.length>0?t.elements.filter(e=>Uz(e)):[n];setTimeout(()=>{kr(),de.isOpen()&&de.closePreservingRenderer(),d()||(o.setWasActivatedByToggle(!0),Gt()),o.setPointer(a),o.setFrozenElements(s),s.length>1&&t.bounds&&o.setFrozenDragRect(OY(t.bounds)),o.freeze(),o.showContextMenu(a,n)},0)};tR(()=>{let e=r.store.theme.hue;e===0?Zn.style.filter=``:Zn.style.filter=`hue-rotate(${e}deg)`}),r.store.theme.enabled&&Promise.resolve().then(()=>(lJ(),VU)).then(({ReactGrabRenderer:e})=>{t||(n=qR(()=>X(e,{get selectionVisible(){return ar()},get selectionBounds(){return Tt()},get selectionBoundsMultiple(){return Ft()},get selectionShouldSnap(){return i.frozenElements.length>0||Pt().length>0},get selectionElementsCount(){return i.frozenElements.length},get frozenLabelEntries(){return Lt()},get pendingShiftPreviewEntry(){return Rt()??void 0},get selectionFilePath(){return i.selectionFilePath??void 0},get selectionLineNumber(){return i.selectionLineNumber??void 0},get selectionTagName(){return or()},get selectionComponentName(){return Ze()},get selectionLabelVisible(){return sr()},selectionLabelStatus:`idle`,get hierarchyState(){return Bn()},get hierarchyMenuPosition(){return le()},get labelInstances(){return ur()},get dragVisible(){return fr()},get dragBounds(){return Nt()},get grabbedBoxes(){return dr()},get mouseX(){return Vz(()=>i.frozenElements.length>1)()?void 0:Bt()??zt().x},get isFrozen(){return f()||d()||ne()},get inputValue(){return i.inputText},get isPromptMode(){return b()},onShowContextMenuInstance:Nr,get onLabelInstanceHoverChange(){return ot.handleHoverChange},get onInputChange(){return o.setInputText},onInputSubmit:()=>void Yt(),onToggleExpand:$t,get selectionLabelShakeCount(){return k()},onConfirmDismiss:Zt,get discardPrompt(){return Vz(()=>!!ye.isPendingDismiss())()?{isKeyboardSelection:!0,onConfirm:Zt,onCopy:On}:S()?{onConfirm:Zt,onCancel:Qt}:void 0},get toolbarVisible(){return r.store.theme.toolbar.enabled},get isActive(){return d()},onToggleActive:sn,onActivateAction:on,get activeActionId(){return $e()},get enabled(){return T()},get shakeCount(){return D()},onToolbarStateChange:e=>{A(e),e.enabled!==T()&&(E(e.enabled),e.enabled||(qt(),Ar())),lZ.forEach(t=>t(e))},onSubscribeToToolbarStateChanges:e=>(lZ.add(e),()=>{lZ.delete(e)}),onToolbarSelectHoverChange:re,onToolbarRef:e=>{me=e},get contextMenuPosition(){return gr()},get contextMenuBounds(){return hr()},get contextMenuTagName(){return _r()},get contextMenuComponentName(){return vr()},get contextMenuHasFilePath(){return!!yr()?.filePath},get actions(){return r.store.actions},get actionContext(){return wr()},onContextMenuDismiss:Tr,onContextMenuHide:Sr,get toolbarMenuPosition(){return ae()},get toolbarMenuActions(){return r.store.actions.filter(e=>e.showInToolbarMenu===!0)},get defaultActionId(){return te()?.defaultAction??`copy`},onSetDefaultAction:Mr,onToggleToolbarMenu:jr,onToolbarMenuDismiss:kr,get editPanelState(){return de.state()},get editPanelPosition(){return se()},get onEditPanelDismiss(){return de.dismiss},get onEditPanelSubmit(){return de.submit},get onEditPanelPendingEditsChange(){return de.setPendingEdits},get onEditPanelInteractingChange(){return de.setInteracting}}),Zn))}).catch(e=>{console.warn(`[react-grab] Failed to load renderer:`,e)});let Pr={activate:()=>{o.setPendingCommentMode(!1),!d()&&T()&&Jt()},deactivate:()=>{(d()||_())&&Kt()},toggle:()=>{d()?Kt():T()&&Jt()},comment:dn,isActive:()=>d(),isEnabled:()=>T(),setEnabled:e=>{e!==T()&&(E(e),Ce({enabled:e,collapsed:!e}),e||(qt(),Ar()))},getToolbarState:()=>te()??xV(),setToolbarState:e=>{let t=te()??xV(),n=e.collapsed??t?.collapsed??!1,r={edge:e.edge??t?.edge??`bottom`,ratio:e.ratio??t?.ratio??.5,collapsed:n,enabled:e.enabled??!n,defaultAction:e.defaultAction??t?.defaultAction??`copy`};SV(r),A(r),r.enabled!==T()&&(E(r.enabled),r.enabled||(qt(),Ar())),lZ.forEach(e=>e(r))},onToolbarStateChange:e=>(lZ.add(e),()=>{lZ.delete(e)}),reset:()=>{qt(),Ar(),o.clearGrabbedBoxes(),o.clearLabelInstances(),o.setSelectionSource(null,null)},dispose:()=>{t=!0,cZ=!1,n?.(),he?.(),he=null,ge?.(),ge=null,lZ.clear(),e()},copyElement:async e=>{let t=Array.isArray(e)?e:[e];return t.length!==0&&await ct(t)},getSource:async e=>{let t=await SU(e);return t?{filePath:t.filePath,lineNumber:t.lineNumber,componentName:t.componentName}:null},getStackContext:e=>PU(e,{maxLines:r.store.options.maxContextLines}),getState:()=>({isActive:d(),isDragging:p(),isCopying:_(),isPromptMode:b(),isSelectionBoxVisible:!!ar(),isDragBoxVisible:!!fr(),targetElement:pt(),dragBounds:Nt()??null,grabbedBoxes:[...Vt()],labelInstances:[...Ht()],selectionFilePath:i.selectionFilePath,toolbarState:te()}),setOptions:e=>{r.setOptions(e)},registerPlugin:e=>{r.register(e,Pr)},unregisterPlugin:e=>{r.unregister(e)},getPlugins:()=>r.getPluginNames(),getDisplayName:CU};for(let e of sZ)r.register(e,Pr);return setTimeout(()=>{MF(!0)},sN),Pr})}})),fZ=r({DEFAULT_THEME:()=>PX,commentPlugin:()=>tZ,formatElementInfo:()=>LU,generateSnippet:()=>oZ,getGlobalApi:()=>mZ,getStack:()=>mU,init:()=>uZ,isInstrumentationActive:()=>qN,openPlugin:()=>rZ,registerPlugin:()=>vZ,setGlobalApi:()=>hZ,unregisterPlugin:()=>yZ}),pZ,mZ,hZ,gZ,_Z,vZ,yZ,bZ=t((()=>{dZ(),YL(),BU(),pZ=null,mZ=()=>typeof window>`u`?pZ:window.__REACT_GRAB__??pZ??null,hZ=e=>{pZ=e,typeof window<`u`&&(e?window.__REACT_GRAB__=e:delete window.__REACT_GRAB__)},gZ=[],_Z=e=>{for(;gZ.length>0;){let t=gZ.shift();t&&e.registerPlugin(t)}},vZ=e=>{let t=mZ();if(t){t.registerPlugin(e);return}gZ.push(e)},yZ=e=>{let t=mZ();if(t){t.unregisterPlugin(e);return}let n=gZ.findIndex(t=>t.name===e);n!==-1&&gZ.splice(n,1)},typeof window<`u`&&!window.__REACT_GRAB_DISABLED__&&(window.__REACT_GRAB__?pZ=window.__REACT_GRAB__:(pZ=uZ(),window.__REACT_GRAB__=pZ),_Z(pZ),window.dispatchEvent(new CustomEvent(`react-grab:init`,{detail:pZ})))}));br(),Rr(),mD();var xZ=`linear-grab:context-copied`,SZ=`linear-grab:picker-activated`,CZ=0,wZ=null;function TZ(e){!e||e.grabbedAt===CZ||Cr().then(t=>{if(t.workflowMode!==`local`||e.grabbedAt===CZ)return;let n=()=>{CZ=e.grabbedAt,navigator.clipboard.writeText(uD(e,t)).then(()=>window.dispatchEvent(new CustomEvent(xZ))).catch(()=>{CZ=0})};e.source?.filePath?(wZ&&clearTimeout(wZ),wZ=null,n()):(wZ&&clearTimeout(wZ),wZ=setTimeout(n,900))})}function EZ(e,t=Date.now()){return{tagName:e.tagName||void 0,componentName:e.componentName||void 0,content:e.textContent?e.textContent.slice(0,500):``,source:e.filePath?{filePath:e.filePath,lineNumber:e.lineNumber??null,columnNumber:e.columnNumber??null,componentName:e.componentName??null}:null,stackContext:void 0,pageUrl:location.href,grabbedAt:t}}function DZ(e,t){let n=null,r=0;return{plugin:{name:`linear-grab`,hooks:{onElementSelect:i=>{r=Date.now(),n=Cr().then(e=>e.captureShots?LA(i):null);let a=t?.(),o={tagName:i.tagName?.toLowerCase()||void 0,componentName:a?.getDisplayName?.(i)||void 0,content:(i.textContent??``).slice(0,500),source:null,stackContext:void 0,pageUrl:location.href,grabbedAt:r};e([o]);try{a?.getSource?.(i)?.then(t=>{t?.filePath&&e([{...o,source:{filePath:t.filePath,lineNumber:t.lineNumber??null,columnNumber:t.columnNumber??null,componentName:t.componentName??o.componentName??null}}])})}catch{}}}},handleSelection(t){let i=r&&Date.now()-r<4e3?r:Date.now(),a=t.map((e,t)=>EZ(e,i+t));if(!a.length)return;e(a);let o=n;n=null,o&&o.then(t=>{t&&e([{...a[0],screenshotDataUrl:t},...a.slice(1)])})}}}var OZ=!1;async function kZ(){if(yr||OZ)return;OZ=!0;let e=await Promise.resolve().then(()=>(bZ(),fZ));try{e.init()}catch{OZ=!1;return}let t=DZ(e=>{Dr(e),TZ(e[0])},()=>e.getGlobalApi());e.registerPlugin(t.plugin),PA(),window.addEventListener(`react-grab:element-selected`,e=>{t.handleSelection(e.detail.elements??[])})}async function AZ(){if(yr){let e=await chrome.runtime.sendMessage({type:`grab/activate`});if(e&&e.ok===!1)throw Error(e.error??`Cannot activate the picker on this page.`);return}await kZ();let e=await Promise.resolve().then(()=>(bZ(),fZ));window.dispatchEvent(new CustomEvent(SZ)),e.getGlobalApi()?.activate()}function jZ(e){if(!yr)return()=>{};let t=t=>{t?.type===`grab/updated`&&e()};return chrome.runtime.onMessage.addListener(t),()=>chrome.runtime.onMessage.removeListener(t)}function MZ(){return new Promise(e=>{let t=document.createElement(`div`);t.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:crosshair;user-select:none;`;let n=document.createElement(`div`);n.style.cssText=`position:fixed;display:none;border:2px solid #5e6ad2;border-radius:4px;box-shadow:0 0 0 100000px rgba(0,0,0,0.35);pointer-events:none;`,t.appendChild(n),document.body.appendChild(t);let r=0,i=0,a=!1,o=e=>({x:Math.min(r,e.clientX),y:Math.min(i,e.clientY),w:Math.abs(e.clientX-r),h:Math.abs(e.clientY-i)}),s=()=>{t.remove(),window.removeEventListener(`keydown`,l,!0)},c=()=>{s(),e(null)},l=e=>{e.key===`Escape`&&(e.stopPropagation(),c())};window.addEventListener(`keydown`,l,!0),t.addEventListener(`pointerdown`,e=>{a=!0,r=e.clientX,i=e.clientY,t.setPointerCapture(e.pointerId)}),t.addEventListener(`pointermove`,e=>{if(!a)return;let t=o(e);n.style.display=`block`,n.style.left=`${t.x}px`,n.style.top=`${t.y}px`,n.style.width=`${t.w}px`,n.style.height=`${t.h}px`}),t.addEventListener(`pointerup`,t=>{let n=o(t);if(s(),n.w<8||n.h<8)return e(null);RA(n).then(t=>{if(!t)return e(null);e({tagName:`region`,componentName:void 0,content:`Region capture ${Math.round(n.w)}×${Math.round(n.h)}`,source:null,stackContext:void 0,screenshotDataUrl:t,pageUrl:location.href,grabbedAt:Date.now()})})})})}Rr(),br(),mD();var NZ=N(`<span class="text-text-faint ml-auto text-[10.5px] font-normal normal-case tabular-nums">`),PZ=N(`<details open class=group><summary class="text-text-dim hover:text-text flex cursor-pointer items-center gap-1.5 text-[11px] font-semibold tracking-wide uppercase select-none"><span aria-hidden class="text-text-faint inline-block w-3 text-center transition-transform group-open:rotate-90">›</span></summary><div class="flex flex-col gap-2 pt-2 pl-4">`),FZ=N(`<div class="flex flex-col gap-1.5"><div class="flex items-center justify-between gap-2"><span class="text-text-faint min-w-0 text-[10.5px] leading-snug">All elements post into ONE issue. Shift+click / drag selects several at once.`),IZ=N(`<div class="flex flex-col gap-1.5"><div class="flex gap-1.5">`),LZ=N(`<span class=text-danger>●`),RZ=N(`<div class="flex flex-col gap-1.5"><span class="text-text-faint text-[10.5px] leading-snug">Captures your screen as a looping GIF (max 30s) the coding agent can watch. Pick this tab in the share dialog, then reproduce the issue.`),zZ=N(`<span class="inline-block min-w-[4ch] text-center">Stop`),BZ=N(`<div class="bg-surface border-border flex items-center gap-2 rounded-lg border p-2.5"><span aria-hidden class="bg-danger size-2 shrink-0 animate-pulse rounded-full"></span><span class="text-text min-w-[5ch] text-[12px] tabular-nums"></span><span class="text-text-faint text-[10.5px]">max 0:30`),VZ=N(`<div class="bg-surface border-border flex items-center gap-2 rounded-lg border p-2.5"><span class="text-text-dim text-[12px]">Encoding GIF…`),HZ=N(`<div class="flex h-full flex-col gap-4 overflow-y-auto pt-3 pb-4 pl-3 pr-4">`),UZ=N(`<span class="text-success text-[12px] leading-none">✓`),WZ=N(`<svg width=12 height=12 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><path d="M4 4l8 8M12 4l-8 8">`),GZ=N(`<span class="font-mono text-text-dim break-all text-[11px] leading-snug">`),KZ=N(`<img alt="Element location screenshot"class="border-border bg-bg max-h-32 w-full rounded-md border object-contain">`),qZ=N(`<div class="bg-surface border-border flex flex-col gap-1.5 rounded-lg border p-2.5"><div class="flex items-center justify-between gap-2"><span class="font-mono text-accent min-w-0 truncate text-[12px]"></span><div class="flex shrink-0 items-center gap-1">`),JZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linejoin=round aria-hidden><rect x=5.5 y=5.5 width=9 height=9 rx=1.5></rect><path d="M10.5 5.5v-2a2 2 0 0 0-2-2h-5a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h2">`),YZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden><path d="M8 2.5v8M4.5 7.5 8 11l3.5-3.5M2.5 13.5h11">`),XZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><path d="M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9a1.5 1.5 0 0 0 1.5 1.4h3.6A1.5 1.5 0 0 0 11.3 13l.7-9M6.5 7v4.5M9.5 7v4.5">`),ZZ=N(`<div class="bg-surface border-border flex flex-col gap-2 rounded-lg border p-2.5"><img alt="Screen recording preview"class="border-border bg-bg max-h-44 w-full rounded-md border object-contain"><span class="text-text-faint text-[10.5px] tabular-nums"> KB · <!>s · <!>×</span><label class="flex cursor-pointer items-center gap-2 select-none"><input type=checkbox class="accent-accent rounded"><span class="text-text text-[12px]">Attach to issue on create</span></label><div class="flex items-center gap-1">`),QZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><path d="M6.5 9.5 9.5 6.5M7.5 4.5 9 3a2.5 2.5 0 0 1 3.5 3.5L11 8M8.5 11.5 7 13a2.5 2.5 0 0 1-3.5-3.5L5 8">`);function $Z(e){return(()=>{var t=PZ(),n=t.firstChild;n.firstChild;var r=n.nextSibling;return P(n,()=>e.title,null),P(n,j(M,{get when(){return e.badge},get children(){var t=NZ();return P(t,()=>e.badge),t}}),null),P(r,()=>e.children),t})()}function eQ(){let e=sr(),t=_r(()=>({queryKey:[`grab`],queryFn:Tr})),n=_r(()=>({queryKey:[`settings`],queryFn:Cr})),r=()=>t.data??[],i=()=>!!(n.data?.linearApiKey||n.data?.linearAccessToken),[a,o]=T(null),s=()=>{o(null),AZ().catch(e=>{o(e instanceof Error&&e.message?e.message:`Cannot activate the picker — open your dev app in the active tab first.`)})},c=async()=>{await kr(),e.invalidateQueries({queryKey:[`grab`]})},[l,u]=T(null),d=async e=>{try{await navigator.clipboard.writeText(uD(e,n.data??{})),u(e.grabbedAt),setTimeout(()=>u(null),1800)}catch{o(`Clipboard was blocked — click the button again.`)}},f=async t=>{await Or(t),e.invalidateQueries({queryKey:[`grab`]})},[p,m]=T(!1),h=async()=>{o(null),m(!0),window.dispatchEvent(new CustomEvent(SZ));try{let e=await MZ();e&&await Dr([e])}finally{m(!1)}},[g,_]=T(BD());ae(VD(_));let[v,y]=T(0);O(()=>{if(g().phase!==`recording`)return;let e=setInterval(()=>y(Date.now()-(BD().startedAt??Date.now())),250);ae(()=>clearInterval(e))});let b=e=>{let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},[x,S]=T(`idle`),[C,w]=T(null),E=async()=>{let e=BD().result;if(!e)throw Error(`No recording available.`);if(e.assetUrl)return e.assetUrl;let t=await xO(e.blob,`recording-${Date.now()}.gif`);return tO(t),t},k=async()=>{w(null),S(`busy`);try{let e=E().then(e=>new Blob([``],{type:`text/plain`}));try{await navigator.clipboard.write([new ClipboardItem({"text/plain":e})])}catch{let t=await e;await navigator.clipboard.writeText(await t.text())}S(`copied`),setTimeout(()=>S(`idle`),2e3)}catch{S(`idle`),await ne(),w(`Direct upload is blocked in this browser — copied the GIF instead. Paste it into a Linear comment and Linear uploads it.`)}},ee=()=>{let e=g().result;if(!e)return;let t=document.createElement(`a`);t.href=e.url,t.download=`linear-grab-recording.gif`,t.click()},[te,A]=T(`idle`),ne=async()=>{let e=g().result;if(e){w(null),A(`busy`);try{try{await navigator.clipboard.write([new ClipboardItem({"image/gif":e.blob})])}catch{let t=await createImageBitmap(e.blob),n=document.createElement(`canvas`);n.width=t.width,n.height=t.height,n.getContext(`2d`).drawImage(t,0,0);let r=await new Promise((e,t)=>n.toBlob(n=>n?e(n):t(Error(`PNG encode failed`)),`image/png`));await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),w(`Browser blocks GIF clipboard — copied the first frame as PNG. Use Download for the animation.`)}A(`copied`),setTimeout(()=>A(`idle`),2e3)}catch(e){A(`idle`),w(e instanceof Error?e.message:`Copy failed.`)}}};return(()=>{var e=HZ();return P(e,j($Z,{title:`Captured elements`,get badge(){return $e(()=>!!r().length)()?`${r().length}/8`:void 0},get children(){return[j(M,{get when(){return r().length>0},get fallback(){return j(Tj,{title:`No elements captured`,children:`Click "Pick element" below, then use the react-grab overlay on your dev app. Every pick ADDS to this list — Shift+click or drag in the overlay selects several at once. Source info needs a dev build.`})},get children(){var e=FZ(),t=e.firstChild;return t.firstChild,P(e,j(We,{get each(){return r()},children:e=>(()=>{var t=qZ(),n=t.firstChild.firstChild,r=n.nextSibling;return P(n,(()=>{var t=$e(()=>!!e.componentName);return()=>t()?`<${e.componentName}>`:$e(()=>!!e.tagName)()?`<${e.tagName}>`:`Element`})()),P(r,j(hj,{class:`size-7 px-0`,variant:`ghost`,title:`Copy context for a local agent (Claude Code / Cursor) — includes skills & memory paths`,"aria-label":`Copy context`,onClick:()=>void d(e),get children(){return j(M,{get when(){return l()===e.grabbedAt},get fallback(){return JZ()},get children(){return UZ()}})}}),null),P(r,j(hj,{class:`size-7 px-0`,variant:`ghost`,title:`Remove this element`,"aria-label":`Remove element`,onClick:()=>void f(e.grabbedAt),get children(){return WZ()}}),null),P(t,j(M,{get when(){return e.source?.filePath},get children(){var t=GZ();return P(t,()=>e.source.filePath,null),P(t,(()=>{var t=$e(()=>e.source?.lineNumber!=null);return()=>t()?`:${e.source.lineNumber}`:``})(),null),t}}),null),P(t,j(M,{get when(){return e.screenshotDataUrl},get children(){var t=KZ();return D(()=>it(t,`src`,e.screenshotDataUrl)),t}}),null),t})()}),t),P(t,j(hj,{class:`h-6 shrink-0 px-2 text-[11px]`,variant:`ghost`,onClick:c,children:`Clear all`}),null),e}}),(()=>{var e=IZ(),t=e.firstChild;return P(t,j(hj,{variant:`primary`,class:`min-w-0 flex-1`,onClick:s,children:`Pick element`}),null),P(t,j(M,{when:!yr,get children(){return j(hj,{variant:`ghost`,class:`min-w-0 flex-1`,get loading(){return p()},title:`Drag a rectangle over any part of the page — the shot attaches to the issue`,onClick:()=>void h(),children:`Capture region`})}}),null),P(e,j(M,{get when(){return a()},get children(){return j(Ej,{get message(){return a()}})}}),null),e})()]}}),null),P(e,j($Z,{title:`Recording`,get badge(){return $e(()=>!!g().result)()?`${(g().result.durationMs/1e3).toFixed(1)}s`:void 0},get children(){return[j(M,{get when(){return g().phase===`idle`||g().phase===`error`},get children(){var e=RZ(),t=e.firstChild;return P(e,j(hj,{variant:`ghost`,onClick:()=>void ZD(),get children(){return[LZ(),` Record interaction`]}}),t),P(e,j(M,{get when(){return $e(()=>g().phase===`error`)()&&g().error},get children(){return j(Ej,{get message(){return g().error}})}}),null),e}}),j(M,{get when(){return g().phase===`recording`},get children(){var e=BZ(),t=e.firstChild.nextSibling;return t.nextSibling,P(t,()=>b(v())),P(e,j(hj,{variant:`primary`,class:`ml-auto`,onClick:()=>void QD(),get children(){return zZ()}}),null),e}}),j(M,{get when(){return g().phase===`processing`},get children(){var e=VZ(),t=e.firstChild;return P(e,j(gj,{}),t),e}}),j(M,{get when(){return $e(()=>g().phase===`ready`)()&&g().result},children:e=>(()=>{var t=ZZ(),n=t.firstChild,r=n.nextSibling,a=r.firstChild,o=a.nextSibling,s=o.nextSibling.nextSibling;s.nextSibling;var c=r.nextSibling,l=c.firstChild,u=c.nextSibling;return P(r,()=>(e().blob.size/1024).toFixed(0),a),P(r,()=>(e().durationMs/1e3).toFixed(1),o),P(r,()=>e().width,s),P(r,()=>e().height,null),l.addEventListener(`change`,e=>eO(e.currentTarget.checked)),P(u,j(hj,{variant:`ghost`,class:`size-7 px-0`,get loading(){return x()===`busy`},get disabled(){return!i()},get title(){return i()?`Copy markdown — uploads to Linear, copies embeddable link`:`Connect Linear in Settings first`},"aria-label":`Copy markdown`,onClick:()=>void k(),get children(){return j(M,{get when(){return x()===`copied`},get fallback(){return QZ()},get children(){return UZ()}})}}),null),P(u,j(hj,{variant:`ghost`,class:`size-7 px-0`,get loading(){return te()===`busy`},title:`Copy GIF — paste into a Linear comment and Linear uploads it`,"aria-label":`Copy GIF`,onClick:()=>void ne(),get children(){return j(M,{get when(){return te()===`copied`},get fallback(){return JZ()},get children(){return UZ()}})}}),null),P(u,j(hj,{variant:`ghost`,class:`size-7 px-0`,title:`Download GIF`,"aria-label":`Download GIF`,onClick:ee,get children(){return YZ()}}),null),P(u,j(hj,{variant:`danger`,class:`ml-auto size-7 px-0`,title:`Discard recording`,"aria-label":`Discard recording`,onClick:$D,get children(){return XZ()}}),null),P(t,j(M,{get when(){return C()},get children(){return j(Ej,{get message(){return C()}})}}),null),D(()=>it(n,`src`,e().url)),D(()=>l.checked=g().attachOnCreate),t})()})]}}),null),e})()}function tQ(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function nQ(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function rQ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var iQ=(e,t)=>Math.abs(e-t)<1.01,aQ=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},oQ,sQ=()=>{if(oQ!==void 0)return oQ;if(typeof navigator>`u`)return oQ=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return oQ=!0;let e=navigator.maxTouchPoints;return oQ=navigator.platform===`MacIntel`&&e!==void 0&&e>0},cQ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},lQ=e=>e,uQ=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},dQ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(cQ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(cQ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},fQ={passive:!0},pQ=typeof window>`u`||`onscrollend`in window,mQ=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&pQ,o=0,s=a?null:aQ(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,fQ),a&&r.addEventListener(`scrollend`,u,fQ),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},hQ=(e,t)=>mQ(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),gQ=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},_Q=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},vQ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:lQ,rangeExtractor:uQ,onChange:()=>{},measureElement:gQ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=nQ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!sQ()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,fQ),e.addEventListener(`touchend`,n,fQ),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(sQ()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=nQ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.getMeasurements=nQ(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=tQ(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=nQ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=xQ(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=nQ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=nQ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return rQ(t[yQ(0,t.length-1,r?e=>n[e*2]:e=>rQ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(sQ()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&iQ(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},yQ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function bQ(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function xQ(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=bQ(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=yQ(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}function SQ(e){let t=Ve(e),n=new vQ(t),[r,i]=tr(n.getVirtualItems()),[a,o]=T(n.getTotalSize()),s=new Proxy(n,{get(e,t){switch(t){case`getVirtualItems`:return()=>r;case`getTotalSize`:return()=>a();default:return Reflect.get(e,t)}}});return s.setOptions(t),ie(()=>{let e=s._didMount();s._willUpdate(),ae(e)}),E(()=>{s.setOptions(Ve(t,e,{onChange:(t,n)=>{var r;t._willUpdate(),i(ar(t.getVirtualItems(),{key:`index`})),o(t.getTotalSize()),(r=e.onChange)==null||r.call(e,t,n)}})),s._willUpdate(),i(ar(n.getVirtualItems(),{key:`index`})),o(n.getTotalSize())}),s}function CQ(e){return SQ(Ve({observeElementRect:dQ,observeElementOffset:hQ,scrollToFn:_Q},e))}Rr();var wQ=3e4,TQ=/github\.com\/[^/]+\/[^/]+\/pull\/\d+/i,EQ={running:[],review:[]},DQ=null,OQ=new Set;function kQ(e){return OQ.add(e),DQ||(DQ=setInterval(()=>void MQ(),wQ),MQ()),()=>{OQ.delete(e),!OQ.size&&DQ&&(clearInterval(DQ),DQ=null)}}function AQ(){MQ()}function jQ(e){return{id:e.id,identifier:e.identifier,title:e.title,stateName:e.state.name,stateColor:e.state.color,delegateName:e.delegate?.displayName??`Agent`,updatedAt:e.updatedAt,prUrl:e.attachments?.find(e=>TQ.test(e.url))?.url}}async function MQ(){try{let e=await Cr();if(!e.linearApiKey&&!e.linearAccessToken)return;let t=(await uO()).filter(e=>!!e.delegate&&e.state.type===`started`).map(jQ);EQ={running:t.filter(e=>!e.prUrl),review:t.filter(e=>!!e.prUrl)};for(let e of OQ)e(EQ)}catch{}}function NQ(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var PQ=/^(https?:\/\/|mailto:)/i,FQ=/\.(mp4|mov|webm|m4v)(\?|#|$)/i,IQ=/\.(png|jpe?g|gif|webp|avif|svg)(\?|#|$)/i,LQ=class extends HTMLElement{objectUrl=null;connectedCallback(){let e=this.getAttribute(`src`)??``,t=this.getAttribute(`alt`)??``;(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(String(n.status));let r=await n.blob();if(this.objectUrl=URL.createObjectURL(r),this.textContent=``,r.type.startsWith(`video/`)){let e=document.createElement(`video`);e.controls=!0,e.preload=`metadata`,e.src=this.objectUrl,this.appendChild(e)}else{let e=document.createElement(`img`);e.src=this.objectUrl,e.alt=t,this.appendChild(e)}}catch{this.textContent=``;let e=document.createElement(`span`);e.textContent=`🖼 ${t||`media`} — start the bridge (npx linear-grab-bridge) to view Linear-hosted media here`,e.style.cssText=`font-size:10.5px;color:var(--color-text-faint);`,this.appendChild(e)}})()}disconnectedCallback(){this.objectUrl&&URL.revokeObjectURL(this.objectUrl)}};typeof customElements<`u`&&!customElements.get(`lg-media`)&&customElements.define(`lg-media`,LQ);var RQ=null;function zQ(e){RQ=e?e.replace(/\/$/,``):null}function BQ(e){try{if(RQ&&new URL(e).hostname.endsWith(`uploads.linear.app`))return`${RQ}/fetch?url=${encodeURIComponent(e)}`}catch{}return e}function VQ(e){let t=e;return t=t.replace(/`([^`]+)`/g,(e,t)=>`<code>${t}</code>`),t=t.replace(/!\[([^\]]*)\]\((?:<)?([^()\s]+?)(?:>)?\)/g,(e,t,n)=>{if(!PQ.test(n))return t;let r=BQ(n);return FQ.test(n)?`<video controls preload="metadata" src="${r}"></video>`:r!==n&&!IQ.test(n)?`<lg-media src="${r}" alt="${t}"></lg-media>`:`<img src="${r}" alt="${t}" loading="lazy" />`}),t=t.replace(/\[([^\]]+)\]\((?:<)?([^()\s]+?)(?:>)?\)/g,(e,t,n)=>PQ.test(n)?`<a href="${n}" target="_blank" rel="noopener noreferrer">${t}</a>`:t),t=t.replace(/<(https?:\/\/[^\s&]+)>/g,`<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>`),t=t.replace(/(^|[\s(])((?:https?:\/\/)[^\s<>()"']+)/g,(e,t,n)=>`${t}<a href="${n}" target="_blank" rel="noopener noreferrer">${n}</a>`),t=t.replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(^|\W)\*([^*\n]+)\*(?=\W|$)/g,`$1<em>$2</em>`),t}function HQ(e){let t=NQ(e.trim()).split(`
|
|
215
|
+
`)},kX=e=>`style`in e&&e.style instanceof CSSStyleDeclaration,AX=e=>{let t=new Map,n=kX(e)?e:null;return{apply:(e,r)=>{if(n)for(let i of e)t.has(i)||t.set(i,{value:n.style.getPropertyValue(i),priority:n.style.getPropertyPriority(i)}),n.style.setProperty(i,r)},restore:()=>{if(!n){t.clear();return}for(let[e,{value:r,priority:i}]of t)r?n.style.setProperty(e,r,i):n.style.removeProperty(e);t.clear()},hasAppliedStyles:()=>t.size>0}},jX=(e,t)=>{for(let n of t){let t=e.edits.findIndex(e=>e.key===n.key);t>=0?e.edits[t]=n:e.edits.push(n)}},MX=(e,t)=>({element:e.element,preview:e.preview,filePath:e.filePath??``,lineNumber:e.lineNumber??0,edits:t,designTokens:e.designTokens}),NX=e=>{let[t,n]=J(null),[r,i]=J(!1),a=[],o=[],s=e=>{o=e},c=()=>{let r=t()!==null;n(null),i(!1),a=[],o=[],r&&e.onClose?.()},l=()=>{t()?.preview.restore();for(let e=a.length-1;e>=0;e--)a[e].preview.restore();c()},u=e=>{hU(e).then(t=>{t&&n(n=>!n||n.element!==e||n.componentName?n:{...n,componentName:t})})},d=(r,i,a={})=>{if(t()!==null)return!1;let o=cX(r);if(o.length===0)return!1;let s=a.filePath??e.store.selectionFilePath??void 0,c=a.lineNumber??e.store.selectionLineNumber??void 0;return n({element:r,position:i,selectionBounds:IJ(r),properties:o,preview:AX(r),filePath:s,lineNumber:c,componentName:a.componentName,tagName:a.tagName??bN(r),initialSearchQuery:a.initialSearchQuery,designTokens:SX(r)}),u(r),e.isActivated()||e.activateRenderer(),e.actions.setPointer(i),e.actions.setFrozenElement(r),e.actions.freeze(),e.onOpen?.(),!0},f=(r,i)=>{let s=t();if(!s||s.element===r)return!1;let c=cX(r);return c.length===0?!1:((o.length>0||s.preview.hasAppliedStyles())&&a.push(MX(s,o)),o=[],n({element:r,position:i,selectionBounds:IJ(r),properties:c,preview:AX(r),tagName:bN(r),hasSessionEdits:a.some(e=>e.edits.length>0),designTokens:SX(r)}),SU(r).then(e=>{if(e){for(let t of a)t.element===r&&!t.filePath&&(t.filePath=e.filePath,t.lineNumber=e.lineNumber??0);n(t=>!t||t.element!==r||t.filePath?t:{...t,filePath:e.filePath,lineNumber:e.lineNumber??void 0})}}).catch(()=>void 0),u(r),e.actions.setPointer(i),e.actions.setFrozenElement(r),!0)},p=(e,t)=>[...a,MX(e,t)],m=e=>{let t=new Map;for(let n of e){if(n.edits.length===0)continue;let e=t.get(n.element);if(e){!e.filePath&&n.filePath&&(e.filePath=n.filePath,e.lineNumber=n.lineNumber),jX(e,n.edits);continue}t.set(n.element,{filePath:n.filePath,lineNumber:n.lineNumber,edits:[...n.edits],designTokens:n.designTokens})}return Array.from(t.values())},h=e=>{let t=new Set;for(let n of e)n.edits.length>0&&t.add(n.element);for(let n=e.length-1;n>=0;n--){let r=e[n];r.edits.length===0&&!t.has(r.element)&&r.preview.restore()}};return{state:t,trigger:d,switchToElement:f,setPendingEdits:s,dismiss:()=>{t()!==null&&(l(),e.store.wasActivatedByToggle?e.deactivateRenderer():e.actions.unfreeze())},closePreservingRenderer:()=>{t()!==null&&(l(),e.actions.unfreeze())},submit:n=>{let r=t();if(!r)return;let i=r.element,a=p(r,n),o=OX(m(a));h(a),c(),e.store.wasActivatedByToggle||e.actions.unfreeze(),e.performCopyWithLabel({element:i,cursorX:r.position.x,extraPrompt:o||void 0,shouldDeactivateAfter:e.store.wasActivatedByToggle})},resetWithDiscard:l,isOpen:()=>t()!==null,isInteracting:r,setInteracting:i}},PX={enabled:!0,hue:0,selectionBox:{enabled:!0},dragBox:{enabled:!0},grabbedBoxes:{enabled:!0},elementLabel:{enabled:!0},toolbar:{enabled:!0}},FX=(e,t)=>({enabled:t.enabled??e.enabled,hue:t.hue??e.hue,selectionBox:{enabled:t.selectionBox?.enabled??e.selectionBox.enabled},dragBox:{enabled:t.dragBox?.enabled??e.dragBox.enabled},grabbedBoxes:{enabled:t.grabbedBoxes?.enabled??e.grabbedBoxes.enabled},elementLabel:{enabled:t.elementLabel?.enabled??e.elementLabel.enabled},toolbar:{enabled:t.toolbar?.enabled??e.toolbar.enabled}}),IX={activationMode:`toggle`,keyHoldDuration:100,allowActivationInsideInput:!0,activationKey:void 0,getContent:void 0,maxContextLines:3,freezeReactUpdates:!0},LX=(e={})=>{let t=new Map,n={},[r,i]=SJ({theme:PX,options:{...IX,...e},actions:[]}),a=()=>{let r=PX,a={...IX,...e},o=[];for(let{config:e}of t.values())if(e.theme&&(r=FX(r,e.theme)),e.options&&(a={...a,...e.options}),e.actions)for(let t of e.actions)o.push(t);a={...a,...n},i(`theme`,r),i(`options`,a),i(`actions`,o)},o=(e,t)=>{n[e]=t,i(`options`,e,t)},s=[`activationMode`,`keyHoldDuration`,`allowActivationInsideInput`,`activationKey`,`getContent`,`maxContextLines`,`freezeReactUpdates`],c=e=>{for(let t of s)e[t]!==void 0&&o(t,e[t])},l=(e,n)=>{t.has(e.name)&&u(e.name);let r=e.setup?.(n,_)??{};e.theme&&(r.theme=r.theme?FX(FX(PX,e.theme),r.theme):e.theme),e.actions&&(r.actions=[...e.actions,...r.actions??[]]),e.hooks&&(r.hooks=r.hooks?{...e.hooks,...r.hooks}:e.hooks),e.options&&(r.options=r.options?{...e.options,...r.options}:e.options),t.set(e.name,{plugin:e,config:r}),a()},u=e=>{let n=t.get(e);n&&(n.config.cleanup&&n.config.cleanup(),t.delete(e),a())},d=()=>Array.from(t.keys()),f=(e,...n)=>{for(let{config:r}of t.values()){let t=r.hooks?.[e];t&&t(...n)}},p=(e,...n)=>{let r=!1;for(let{config:i}of t.values()){let t=i.hooks?.[e];t&&t(...n)===!0&&(r=!0)}return r},m=async(e,...n)=>{for(let{config:r}of t.values()){let t=r.hooks?.[e];t&&await t(...n)}},h=async(e,n,...r)=>{let i=n;for(let{config:n}of t.values()){let t=n.hooks?.[e];t&&(i=await t(i,...r))}return i},g=(e,n,...r)=>{let i=n;for(let{config:n}of t.values()){let t=n.hooks?.[e];t&&(i=t(i,...r))}return i},_={onActivate:()=>f(`onActivate`),onDeactivate:()=>f(`onDeactivate`),onElementHover:e=>f(`onElementHover`,e),onElementSelect:e=>{let n=!1,r;for(let{config:i}of t.values()){let t=i.hooks?.onElementSelect;if(t){let i=t(e);i===!0?n=!0:i instanceof Promise&&(n=!0,r=i)}}return{wasIntercepted:n,pendingResult:r}},onDragStart:(e,t)=>f(`onDragStart`,e,t),onDragEnd:(e,t)=>f(`onDragEnd`,e,t),onBeforeCopy:async e=>m(`onBeforeCopy`,e),transformCopyContent:async(e,t)=>h(`transformCopyContent`,e,t),onAfterCopy:(e,t)=>f(`onAfterCopy`,e,t),onCopySuccess:(e,t)=>f(`onCopySuccess`,e,t),onCopyError:e=>f(`onCopyError`,e),onStateChange:e=>f(`onStateChange`,e),onPromptModeChange:(e,t)=>f(`onPromptModeChange`,e,t),onSelectionBox:(e,t,n)=>f(`onSelectionBox`,e,t,n),onDragBox:(e,t)=>f(`onDragBox`,e,t),onGrabbedBox:(e,t)=>f(`onGrabbedBox`,e,t),onElementLabel:(e,t,n)=>f(`onElementLabel`,e,t,n),onContextMenu:(e,t)=>f(`onContextMenu`,e,t),onOpenFile:(e,t)=>p(`onOpenFile`,e,t),transformHtmlContent:async(e,t)=>h(`transformHtmlContent`,e,t),transformAgentContext:async(e,t)=>h(`transformAgentContext`,e,t),transformActionContext:e=>g(`transformActionContext`,e),transformOpenFileUrl:(e,t,n)=>g(`transformOpenFileUrl`,e,t,n)};return{register:l,unregister:u,getPluginNames:d,setOptions:c,store:r,hooks:_}},RX=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,zX=e=>{let t=e.bounds.x+e.bounds.width/2,n=e.bounds.width/2,r=e.mouseX===void 0?void 0:e.mouseX-t;return{id:RX(`label`),bounds:e.bounds,boundsMultiple:e.boundsMultiple,tagName:e.tagName,componentName:e.componentName,status:e.status,createdAt:Date.now(),element:e.element,elements:e.elements,mouseX:e.mouseX,mouseXOffsetFromCenter:r,mouseXOffsetRatio:r!==void 0&&n>0?r/n:void 0,hideArrow:e.hideArrow}},BX=(e,t)=>{let n=new Map,r=e=>{let t=n.get(e);t!==void 0&&(window.clearTimeout(t),n.delete(e))},i=()=>{for(let e of n.values())window.clearTimeout(e);n.clear()},a=()=>{i(),e.clearLabelInstances()},o=t=>{r(t);let i=window.setTimeout(()=>{e.updateLabelInstance(t,`fading`);let r=window.setTimeout(()=>{n.delete(t),e.removeLabelInstance(t)},125);n.set(t,r)},DM);n.set(t,i)};return{createInstance:(t,n,r,i,o)=>{a();let s=zX({bounds:t,tagName:n,componentName:r,status:i,element:o?.element,mouseX:o?.mouseX,elements:o?.elements,boundsMultiple:o?.boundsMultiple,hideArrow:o?.hideArrow});return e.addLabelInstance(s),s.id},createPerElementInstances:(t,n)=>{a();let r=[];for(let i of t){let t=zX({bounds:IJ(i.element),tagName:i.tagName,componentName:i.componentName,status:n,element:i.element,mouseX:i.mouseX});e.addLabelInstance(t),r.push(t.id)}return r},updateAfterCopy:(t,n,r)=>{n?e.updateLabelInstance(t,`copied`):e.updateLabelInstance(t,`error`,r||`Unknown error`),o(t)},cancelAllFades:i,clearAll:a,handleHoverChange:(e,n)=>{if(n){r(e);return}let i=t().find(t=>t.id===e);i&&(i.status===`copied`||i.status===`error`||i.status===`fading`)&&o(e)}}},VX=e=>{let t=window.innerWidth,n=window.innerHeight,r=Math.max(0,e.x),i=Math.min(t,e.x+e.width),a=Math.max(0,e.y),o=Math.min(n,e.y+e.height);return{x:(r+i)/2,y:(a+o)/2}},HX=(e,t,n)=>{let r=[],i=(t,r)=>{let i=VX(n(t)),a=mI(i.x,i.y).filter(e),o=a.indexOf(t);return o===-1?null:a[o+r]??null},a=e=>{let t=i(e,1);return t&&(r.push(e),r.length>50&&(r=r.slice(-50))),t},o=e=>{if(r.length>0){let e=r.pop();if(Uz(e))return e}return i(e,-1)},s=(e,n)=>{let i=e=>n?e.nextElementSibling:e.previousElementSibling,a=i(e);for(;a;){if(t(a))return r=[],a;a=i(a)}return null};return{findNext:(e,t)=>{switch(e){case`ArrowUp`:return a(t);case`ArrowDown`:return o(t);case`ArrowRight`:return s(t,!0);case`ArrowLeft`:return s(t,!1);default:return null}},clearHistory:()=>{r=[]}}},UX=e=>{let{metaKey:t,ctrlKey:n,shiftKey:r,altKey:i}=BY(e.activationKey);return{metaKey:t,ctrlKey:n,shiftKey:r,altKey:i}},WX=()=>{let e=new WeakSet,t=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,`key`),n=!1;if(t?.get&&!t.get.__reactGrabPatched){n=!0;let r=t.get,i=function(){return e.has(this)?``:r.call(this)};i.__reactGrabPatched=!0,Object.defineProperty(KeyboardEvent.prototype,"key",{get:i,configurable:!0})}return{claimedEvents:e,originalKeyDescriptor:t,restore:()=>{n&&t&&Object.defineProperty(KeyboardEvent.prototype,"key",t)}}},GX=(e,t)=>({top:t<25,bottom:t>window.innerHeight-25,left:e<25,right:e>window.innerWidth-25}),KX=(e,t,n)=>{let r=null,i=()=>{if(!t()){a();return}let o=e(),s=GX(o.x,o.y),c=0,l=0;if(s.top&&(l-=10),s.bottom&&(l+=10),s.left&&(c-=10),s.right&&(c+=10),c!==0||l!==0){let e=window.scrollX,t=window.scrollY;window.scrollBy(c,l);let r=window.scrollX-e,i=window.scrollY-t;(r!==0||i!==0)&&n?.({x:r,y:i})}r=s.top||s.bottom||s.left||s.right?RF(i):null},a=()=>{r!==null&&(zF(r),r=null)};return{start:i,stop:a,isActive:()=>r!==null}},qX=()=>{let e=globalThis;return!!(e.chrome?.runtime?.id||e.browser?.runtime?.id)},JX=e=>{try{let t=`0.1.48`,n=`data:image/svg+xml;base64,${btoa(`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 294 294"><path fill="#ff40e0" d="M145 47c25-20 50-27 67-17 16 9 23 30 20 60 0 2-1 5-1 7l-2 13h-1l-12-4c-8-3-17-5-25-6l-17-3c-10-1-20-1-29-1-10 0-20 0-29 1-6 8-11 16-16 24-5 9-9 17-13 26 4 9 8 18 13 26s10 16 16 24l11 14c5 7 11 13 18 19l10 8s-1 0 0 0l-11 9c-17 14-35 22-49 22-6 0-13-2-18-5-16-9-23-30-20-59 1-3 1-5 1-8-30-12-48-29-48-50 0-18 14-35 41-47 2-1 5-2 7-3 0-2 0-5-1-7-3-30 4-51 20-60 18-10 42-3 68 17M71 201c-1 2-1 4-1 5-2 24 3 41 13 47h1c11 7 30 1 51-15-10-9-18-18-26-29-13-1-26-4-38-8m9-38c-3 9-5 17-7 26 8 2 17 4 25 6-3-5-6-10-9-16-3-5-6-10-9-16m-19-53c-2 1-3 1-5 2-21 10-34 23-34 35 0 13 14 27 39 37 3-12 7-25 12-37-5-12-9-24-12-37m37-10c-8 1-17 3-25 6 2 8 4 16 7 25 3-5 6-11 9-16zm-3-61c-4-1-8 0-12 2-10 7-15 24-13 47 0 2 0 3 1 5 12-4 25-6 38-8 8-10 16-20 26-29-15-11-29-17-40-17m111 2c-4-2-8-3-12-2-11 0-25 5-40 17 10 9 19 19 26 29 13 2 26 4 39 8v-5c3-23-2-40-13-47m-61 23c-7 6-13 13-19 19h37c-6-6-12-13-18-19"/><mask id="a"><path fill="#fff" d="m235 85-133 27 28 133 133-27Z"/></mask><path fill="#ff40e0" d="m137 130 76 11c8 1 9 11 3 15l-28 16-4 32c-1 8-10 10-14 4l-41-66c-3-6 1-13 8-12" mask="url(#a)"/></svg>`)}`;console.log(`%cReact Grab${` v${t}`}%c\nhttps://react-grab.com`,`background: #330039; color: #ffffff; border: 1px solid #d75fcb; padding: 4px 4px 4px 24px; border-radius: 4px; background-image: url("${n}"); background-size: 16px 16px; background-repeat: no-repeat; background-position: 4px center; display: inline-block; margin-bottom: 4px;`,``),e&&navigator.onLine&&!qX()&&fetch(`https://www.react-grab.com/api/version?source=browser&v=${t}&t=${Date.now()}`,{referrerPolicy:`origin`,keepalive:!0,priority:`low`,cache:`no-store`}).then(e=>e.text()).then(e=>{e&&e!==t&&console.warn(`[React Grab] v${t} is outdated (latest: v${e}). Run \`npx grab@latest upgrade\` to upgrade.`)}).catch(()=>null)}catch{}},YX=e=>typeof e==`object`&&!!e,XX=e=>{if(!YX(e))return null;let t={};return typeof e.enabled==`boolean`&&(t.enabled=e.enabled),(e.activationMode===`toggle`||e.activationMode===`hold`)&&(t.activationMode=e.activationMode),typeof e.keyHoldDuration==`number`&&Number.isFinite(e.keyHoldDuration)&&(t.keyHoldDuration=e.keyHoldDuration),typeof e.allowActivationInsideInput==`boolean`&&(t.allowActivationInsideInput=e.allowActivationInsideInput),typeof e.activationKey==`string`&&(t.activationKey=e.activationKey),typeof e.maxContextLines==`number`&&Number.isFinite(e.maxContextLines)&&(t.maxContextLines=e.maxContextLines),typeof e.freezeReactUpdates==`boolean`&&(t.freezeReactUpdates=e.freezeReactUpdates),typeof e.telemetry==`boolean`&&(t.telemetry=e.telemetry),Object.keys(t).length===0?null:t},ZX=()=>{if(typeof window>`u`)return null;try{let e=(document.currentScript instanceof HTMLScriptElement?document.currentScript:null)?.getAttribute(`data-options`);return e?XX(JSON.parse(e)):null}catch{return null}},QX=e=>e===`Enter`||e===`NumpadEnter`,$X=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,eZ=(e=>({name:e.name,setup:(t,n)=>({actions:[typeof e.contextMenuAction==`function`?e.contextMenuAction(t,n):e.contextMenuAction],cleanup:e.cleanup})}))({name:`copy`,contextMenuAction:{id:`copy`,label:`Copy`,shortcut:`C`,showInToolbarMenu:!0,onAction:e=>{e.copy?.()}}}),tZ={name:`comment`,setup:()=>({actions:[{id:`comment`,label:`Comment`,shortcut:`Enter`,shortcutModifier:!1,showInToolbarMenu:!0,onAction:e=>{e.enterPromptMode?.()}}]})},nZ={name:`edit`,setup:()=>({actions:[{id:`edit`,label:`Style`,shortcut:`S`,shortcutModifier:!1,showInToolbarMenu:!0,onAction:e=>{e.enterEditMode?.()}}]})},rZ={name:`open`,actions:[{id:`open`,label:`Open`,shortcut:`O`,enabled:e=>!!e.filePath,onAction:e=>{e.filePath&&(e.hooks.onOpenFile(e.filePath,e.lineNumber)||vI(e.filePath,e.lineNumber,e.hooks.transformOpenFileUrl),e.hideContextMenu(),e.cleanup())}}]},iZ=e=>{let t=e.left+e.width/2,n=e.top+e.height/2,r=n,i=window.innerHeight-n,a=t,o=window.innerWidth-t,s=Math.min(r,i,a,o);return s===r?`top`:s===a?`left`:s===o?`right`:`bottom`},aZ=()=>{let[e,t]=J(!1),[n,r]=J(null),i=DV(),a=()=>{let e=n();return Uz(e)?e:null},o=()=>{r(null),i.clear(),t(!1)};return{selectedElement:a,isPendingDismiss:e,select:(e,n)=>{r(e),t(!1),n?.shouldPromptBeforeMouseHandoff?i.arm():i.clear()},clear:o,consumeMouseHandoff:()=>i.consume()&&a()!==null,showDismissPrompt:()=>a()?e()?!1:(t(!0),!0):(o(),!1),takeSelection:e=>{let t=a()??(Uz(e)?e:null);return o(),t}}},oZ=async(e,t={})=>(await Promise.allSettled(e.map(e=>LU(e,t)))).map(e=>e.status===`fulfilled`?e.value:``),sZ=[eZ,nZ,tZ,rZ],cZ=!1,lZ=new Set,uZ=e=>{if(typeof window>`u`)return lY();let t={enabled:!0,activationMode:`toggle`,keyHoldDuration:100,allowActivationInsideInput:!0,...ZX(),...e};if(t.enabled===!1||cZ)return lY();cZ=!0,vM(t.container??null),JX(t.telemetry!==!1);let{enabled:n,telemetry:r,container:i,...a}=t;return QL(e=>{let t=!1,n,r=LX(a),{store:i,actions:o,pointer:s,viewportVersion:c,current:l}=zJ({keyHoldDuration:r.store.options.keyHoldDuration??100}),u=Y(()=>l().state===`holding`),d=Y(()=>l().state===`active`),f=Y(()=>{let e=l();return e.state===`active`&&e.phase===`frozen`}),p=Y(()=>{let e=l();return e.state===`active`&&(e.phase===`dragging-select`||e.phase===`dragging-reposition`)}),m=Y(()=>{if(!p())return!1;let e=Math.abs(s().x+window.scrollX-i.dragStart.x),t=Math.abs(s().y+window.scrollY-i.dragStart.y);return e>2||t>2}),h=Y(()=>{let e=l();return e.state===`active`&&e.phase===`dragging-reposition`}),g=Y(()=>{let e=l();return e.state===`active`&&e.phase===`justDragged`}),_=Y(()=>l().state===`copying`),v=Y(()=>i.selectionInteractionLockDepth>0),y=Y(()=>l().state===`justCopied`),b=Y(()=>{let e=l();return e.state===`active`&&!!e.isPromptMode}),x=Y(()=>i.pendingCommentMode||b()),S=Y(()=>{let e=l();return e.state===`active`&&!!e.isPromptMode&&!!e.isPendingDismiss}),C=(e,t)=>{document.body.style[e]=t};tR(oR(d,(e,t)=>{e&&!t?(_L(s().x,s().y),C(`touchAction`,`none`)):!e&&t&&(vL(),C(`touchAction`,``))}));let w=xV(),[T,E]=J(!w||!w.collapsed),[D,O]=J(0),[k,ee]=J(0),[te,A]=J(w),[ne,re]=J(!1),ie=CV(e=>e.shiftKey),[ae,oe]=J(null),[se,ce]=J(null),[le,ue]=J(null),de=NX({store:i,actions:o,isActivated:d,activateRenderer:()=>Gt(),deactivateRenderer:()=>Kt(),performCopyWithLabel:e=>dt(e),onOpen:()=>{kr(),ge?.(),ge=Or(Dr,ce)},onClose:()=>{ge?.(),ge=null,ce(null)}}),fe=Y(()=>i.contextMenuPosition!==null||de.isOpen()),pe=Y(()=>fe()||ae()!==null),me,he=null,ge=null,_e=!1,ve=new WeakMap,ye=aZ(),be=()=>!T()||b()||v()||fe()||ye.isPendingDismiss(),xe=()=>{ve=new WeakMap},Se=()=>{Le(!1),xe()},Ce=e=>{let t=te()??xV(),n={edge:t?.edge??`bottom`,ratio:t?.ratio??.5,collapsed:t?.collapsed??!1,enabled:t?.enabled??!0,defaultAction:t?.defaultAction??`copy`,...e};SV(n),A(n);for(let e of lZ)e(n)},we=()=>{Fe.timerId!==null&&(clearTimeout(Fe.timerId),Fe.timerId=null)},Te=()=>{Fe.copyWaiting=!1,Fe.holdTimerFired=!1,Fe.startTimestamp=null};tR(()=>{if(l().state!==`holding`){we();return}Fe.startTimestamp=Date.now(),Fe.timerId=window.setTimeout(()=>{if(Fe.timerId=null,Fe.copyWaiting){Fe.holdTimerFired=!0;return}o.activate()},i.keyHoldDuration),cR(we)}),tR(()=>{let e=l();if(e.state!==`active`||e.phase!==`justDragged`)return;let t=setTimeout(()=>{o.finishJustDragged()},DM);cR(()=>clearTimeout(t))}),tR(()=>{if(l().state!==`justCopied`)return;let e=setTimeout(()=>{o.finishJustCopied()},DM);cR(()=>clearTimeout(e))}),tR(oR(u,(e,t=!1)=>{!t||e||!d()||(r.store.options.activationMode!==`hold`&&o.setWasActivatedByToggle(!0),r.hooks.onActivate())}));let Ee=(e,t,n)=>{Oe(e,t,n),o.clearInputText()},De=()=>{let e=i.frozenElement||pt();e&&o.enterPromptMode({x:s().x,y:s().y},e)},Oe=(e,t,n)=>{o.setCopyStart({x:t,y:n},e)},ke={lastDetectionTimestamp:0,pendingDetectionScheduledAt:0,latestPointerX:0,latestPointerY:0},Ae=null,[je,Me]=J(null),Ne=(e,t)=>{Ae!==null&&clearTimeout(Ae),Me(null),Ae=window.setTimeout(()=>{Me({x:e,y:t}),Ae=null},32)},Pe=null,Fe={timerId:null,startTimestamp:null,copyWaiting:!1,holdTimerFired:!1},Ie=null,[j,Le]=J(!1),Re=0,ze=!1,Be=null,Ve=()=>{ze=!0,Be!==null&&window.clearTimeout(Be),Be=window.setTimeout(()=>{ze=!1,Be=null},DM)},He=()=>{Be!==null&&(window.clearTimeout(Be),Be=null),ze=!1},Ue=0,We=null,Ge=null,[M,Ke]=J(!1),[qe,Je]=J(null),[Ye,Xe]=J(null),[Ze,Qe]=UJ(Ye),$e=Y(()=>de.isOpen()?tN:x()?eN:M()?qe():d()?$M:null),et=e=>NY(e,QF),tt=HX(QF,et,IJ),nt=KX(s,()=>p(),e=>{if(h()){if(o.shiftDragStart(e),Ie){Ie={x:Ie.x+e.x,y:Ie.y+e.y};return}let{pageX:t,pageY:n}=Et(s().x,s().y);Ie={x:t,y:n}}}),N=Y(()=>d()&&!_()),rt=new Map,it=(e,t)=>{let n=RX(`grabbed`),i={id:n,bounds:e,createdAt:Date.now(),element:t};o.addGrabbedBox(i),r.hooks.onGrabbedBox(e,t);let a=window.setTimeout(()=>{rt.delete(n),o.removeGrabbedBox(n)},DM+125);rt.set(n,a)},at=async e=>{let t=await Promise.all(e.map(async e=>{let t=await SU(e),n=t?.componentName??null,r=t?.filePath,i=t?.lineNumber??void 0,a=t?.columnNumber??void 0;n||=CU(e);let o=e instanceof HTMLElement?e.innerText?.slice(0,100):void 0;return{tagName:bN(e),id:e.id||void 0,className:e.getAttribute(`class`)||void 0,textContent:o,componentName:n??void 0,filePath:r,lineNumber:i,columnNumber:a}}));window.dispatchEvent(new CustomEvent(`react-grab:element-selected`,{detail:{elements:t}}))},ot=BX(o,()=>i.labelInstances),st=async(e,t,n)=>{He(),l().state!==`copying`&&o.startCopy();let r=!1,i;try{r=await e(),r||(i=`Failed to copy`)}catch(e){i=dY(e,`Action failed`)}if(t)for(let e of t)ot.updateAfterCopy(e,r,i);l().state===`copying`&&(r&&o.completeCopy(),n?Kt():r?(o.activate(),Ve()):o.unfreeze())},ct=(e,t,n)=>{let i=e[0],a=n??(i?CU(i):null),o=i?bN(i):null,s=a??o??void 0;return _Y({getContent:r.store.options.getContent,componentName:s,maxContextLines:r.store.options.maxContextLines},r.hooks,e,t)},lt=async(e,t,n)=>{if(e.length===0)return!1;let i=[],a=[];for(let t of e){let{wasIntercepted:e,pendingResult:n}=r.hooks.onElementSelect(t);e||i.push(t),n&&a.push(n),r.store.theme.grabbedBoxes.enabled&&it(IJ(t),t)}await BF();let o=!0;if(i.length>0&&(o=await ct(i,t,n)),a.length>0&&!(await Promise.all(a)).every(Boolean))throw new NV;return at(e),o},ut=e=>{hU(e.primaryElement).then(async t=>{await st(()=>lt(e.targetElements,e.extraPrompt,t??void 0),e.labelInstanceIds.length>0?e.labelInstanceIds:null,e.shouldDeactivateAfter),e.onComplete?.()}).catch(t=>{let n=dY(t,`Action failed`);for(let t of e.labelInstanceIds)ot.updateAfterCopy(t,!1,n);l().state===`copying`&&o.unfreeze()})},dt=e=>{let{element:t,cursorX:n,selectedElements:r,extraPrompt:a,shouldDeactivateAfter:s,onComplete:c,dragRect:l}=e,u=r??[t],d=l??i.frozenDragRect,f=u.length>1,p=!f&&t===yt()?Tt():void 0,m=d&&f?DY(d):p??IJ(t),h=f?m.x+m.width/2:n,g=bN(t);He(),o.startCopy();let _=g?ot.createInstance(m,g,void 0,`copying`,{element:t,mouseX:h,elements:r}):null;ut({primaryElement:t,targetElements:u,labelInstanceIds:_?[_]:[],extraPrompt:a,shouldDeactivateAfter:s,onComplete:c})},ft=e=>{let{elements:t,labelEntries:n,shouldDeactivateAfter:r,onComplete:i}=e,a=t[0];He(),o.startCopy(),ut({primaryElement:a,targetElements:t,labelInstanceIds:ot.createPerElementInstances(n,`copying`),shouldDeactivateAfter:r,onComplete:i})},pt=Y(()=>{if(c(),!N()||m()||v()||ye.isPendingDismiss())return null;let e=i.detectedElement;return Uz(e)?e:null}),P=Y(()=>i.frozenElement||(f()?null:pt())),mt=Y(()=>!d()||b()||j()||_()||pe()||ye.isPendingDismiss()?null:ie()?f()?P():pt()??i.frozenElement:ye.selectedElement()),ht=Y(()=>{let e=mt();return e?AY(e,QF,et):[]}),gt=Y(()=>{let e=mt();return e?Math.max(0,ht().findIndex(t=>t.element===e)):0}),_t=Y(()=>mt()!==null);tR(()=>{let e=i.detectedElement;if(!e)return;let t=setInterval(()=>{Uz(e)||o.setDetectedElement(null)},100);cR(()=>clearInterval(t))}),tR(oR(P,e=>{if(We!==null&&(clearTimeout(We),We=null),!e){Xe(null);return}We=window.setTimeout(()=>{We=null,Xe(e)},100)})),cR(()=>{We!==null&&(clearTimeout(We),We=null)}),tR(()=>{let e=i.frozenElements;cR(XI(e))}),tR(oR(d,e=>{e&&r.store.options.freezeReactUpdates&&cR(JL())}));let vt=()=>{if(i.isTouchMode&&p()){let e=i.detectedElement;return!e||HF(e)?void 0:e}let e=P();if(!(!e||HF(e)))return e},yt=Y(()=>vt()),bt=()=>yt()?i.isTouchMode&&p()?N():N()&&!m():!1,xt=NR(()=>i.frozenElements,e=>Y(()=>(c(),IJ(e)))),St=Y(()=>{let e=i.frozenElements;if(e.length===0)return[];let t=i.frozenDragRect;return t&&e.length>1?[DY(t)]:xt().map(e=>e())}),Ct=Y(()=>{if(!j()||i.pendingCommentMode||M())return null;let e=i.detectedElement;return!Uz(e)||HF(e)||i.frozenElements.includes(e)?null:e}),wt=Y(()=>{c();let e=Ct();if(e)return IJ(e)}),Tt=Y(()=>{c();let e=i.frozenElements;if(e.length>0){let t=St();if(e.length===1){let e=t[0];if(e)return e}let n=i.frozenDragRect;return n?t[0]??DY(n):kY(HY(t))}let t=yt();if(t)return IJ(t)}),Et=(e,t)=>({pageX:e+window.scrollX,pageY:t+window.scrollY}),Dt=(e,t)=>{let{pageX:n,pageY:r}=Et(e,t);return{x:Math.abs(n-i.dragStart.x),y:Math.abs(r-i.dragStart.y)}},Ot=Y(()=>{if(!p())return!1;let e=Dt(s().x,s().y);return e.x>2||e.y>2}),kt=(e,t)=>{let{pageX:n,pageY:r}=Et(e,t),a=Math.min(i.dragStart.x,n),o=Math.min(i.dragStart.y,r),s=Math.abs(n-i.dragStart.x),c=Math.abs(r-i.dragStart.y);return{x:a-window.scrollX,y:o-window.scrollY,width:s,height:c}},At=e=>e.code===`Space`||e.key===` `,jt=()=>{if(!p())return;o.startDragReposition();let{pageX:e,pageY:t}=Et(s().x,s().y);Ie={x:e,y:t}},Mt=()=>{o.stopDragReposition(),Ie=null},Nt=Y(()=>{if(c(),Ot())return kY(kt(s().x,s().y))}),Pt=Y(()=>{if(c(),!Ot())return[];let e=je();if(!e)return[];let t=kt(e.x,e.y),n=wY(t,QF);return(n.length>0?n:wY(t,QF,!1)).map(e=>IJ(e))}),Ft=Y(()=>{let e=Pt();if(e.length>0)return e;let t=wt();return t?[...St(),t]:St()}),It=NR(()=>i.frozenElements,e=>{let t=bN(e)||`element`,n=CU(e)??void 0;return Y(()=>{if(c(),!Uz(e))return null;let r=IJ(e),i=ve.get(e);return{tagName:t,componentName:n,bounds:r,mouseX:i===void 0?void 0:r.x+r.width*i}})}),Lt=Y(()=>{if(b()||i.frozenElements.length<2)return[];let e=[];for(let t of It()){let n=t();n!==null&&e.push(n)}return e}),Rt=Y(()=>{if(b())return null;let e=Ct();return e?(c(),{tagName:bN(e)||`element`,componentName:CU(e)??void 0,bounds:IJ(e),mouseX:s().x}):null}),zt=Y(()=>{if(_()||b()){c();let e=i.frozenElement||pt();return e?{x:LJ(IJ(e)).x+i.copyOffsetFromCenterX,y:i.copyStart.y}:{x:i.copyStart.x,y:i.copyStart.y}}return{x:s().x,y:s().y}}),Bt=Y(()=>{if(!j()||i.frozenElements.length!==1)return;c();let e=i.frozenElements[0];if(!Uz(e))return;let t=ve.get(e);if(t===void 0)return;let n=IJ(e);return n.x+n.width*t});tR(oR(()=>[pt(),i.lastGrabbedElement],([e,t])=>{t&&e&&t!==e&&o.setLastGrabbed(null),e&&r.hooks.onElementHover(e)})),tR(oR(()=>pt(),e=>{let t=++Ue,n=()=>{Ue===t&&o.setSelectionSource(null,null)};if(!e){n();return}SU(e).then(e=>{if(Ue===t){if(!e){n();return}o.setSelectionSource(e.filePath,e.lineNumber)}}).catch(()=>{Ue===t&&o.setSelectionSource(null,null)})}));let Vt=Y(()=>i.grabbedBoxes.map(e=>({id:e.id,bounds:e.bounds,createdAt:e.createdAt}))),Ht=Y(()=>i.labelInstances.map(e=>({id:e.id,status:e.status,tagName:e.tagName,componentName:e.componentName,createdAt:e.createdAt})));tR(oR(Y(()=>{let e=d(),t=p(),n=_(),a=b(),o=pt(),s=Nt(),c=r.store.theme.enabled,l=r.store.theme.selectionBox.enabled,u=r.store.theme.dragBox.enabled,f=Ot(),m=P(),h=y();return{isActive:e,isDragging:t,isCopying:n,isPromptMode:a,isSelectionBoxVisible:!!(c&&l&&e&&!n&&!h&&!t&&m!=null),isDragBoxVisible:!!(c&&u&&e&&!n&&f),targetElement:o,dragBounds:s?{x:s.x,y:s.y,width:s.width,height:s.height}:null,grabbedBoxes:[...Vt()],labelInstances:[...Ht()],selectionFilePath:i.selectionFilePath,toolbarState:te()}}),e=>{r.hooks.onStateChange(e)})),tR(oR(()=>{let e=b();return{inputMode:e,position:e?s():aR(s),target:e?pt():aR(pt)}},({inputMode:e,position:t,target:n})=>{r.hooks.onPromptModeChange(e,{x:t.x,y:t.y,targetElement:n})})),tR(oR(()=>[ar(),Tt(),pt()],([e,t,n])=>{r.hooks.onSelectionBox(!!e,t??null,n)})),tR(oR(()=>[fr(),Nt()],([e,t])=>{r.hooks.onDragBox(!!e,t??null)})),tR(oR(()=>{let e=mr();return[e,pr(),e?zt():aR(zt),e?pt():aR(pt),i.selectionFilePath,i.selectionLineNumber]},([e,t,n,i,a,o])=>{r.hooks.onElementLabel(e,t,{x:n.x,y:n.y,content:``,element:i??void 0,tagName:i&&bN(i)||void 0,filePath:a??void 0,lineNumber:o??void 0})}));let Ut=null,Wt=e=>{if(e){if(!Ut){Ut=document.createElement(`style`),Ut.setAttribute(`data-react-grab-cursor`,``);let e=SN();e&&(Ut.nonce=e),wN(Ut),document.head.appendChild(Ut)}Ut.textContent=`* { cursor: ${e} !important; }`}else Ut&&=(Ut.remove(),null)};tR(oR(()=>[d(),_(),b()],([e,t,n])=>{Wt(t?`progress`:e&&!n?`crosshair`:null)}));let Gt=()=>{let e=u();o.activate(),e||r.hooks.onActivate()},Kt=()=>{let e=p(),t=i.previouslyFocusedElement;Mt(),o.deactivate(),de.resetWithDiscard(),kr(),Se(),wn(),ye.clear(),Ke(!1),Je(null),e&&C(`userSelect`,``),Pe&&window.clearTimeout(Pe),nt.stop(),t instanceof HTMLElement&&t!==document.body&&t!==document.activeElement&&Uz(t)&&t.focus({preventScroll:!0}),r.hooks.onDeactivate()},qt=()=>{u()&&o.releaseHold(),d()&&Kt(),He()},Jt=()=>{o.setWasActivatedByToggle(!0),Gt()},Yt=()=>{let e=[...i.frozenElements],t=i.frozenElement||pt(),n=b()?i.inputText.trim():``;if(!t){Kt();return}let r=e.length>0?e:[t],a=r.map(e=>IJ(e))[0],{x:s,y:c}=LJ(a),l=s+i.copyOffsetFromCenterX;o.setPointer({x:s,y:c}),o.exitPromptMode(),o.clearInputText(),dt({element:t,cursorX:l,selectedElements:r,extraPrompt:n||void 0,shouldDeactivateAfter:!0})},Xt=()=>{if(b()){if(S()){o.clearInputText(),Kt();return}o.setPendingDismiss(!0),ee(e=>e+1)}},Zt=()=>{if(ye.isPendingDismiss()){Dn();return}o.clearInputText(),Kt()},Qt=()=>{o.setPendingDismiss(!1)},$t=()=>{if(de.isOpen()){de.dismiss();return}let e=i.frozenElement||pt();e&&en(e,{x:s().x,y:s().y})},en=(e,t,n={})=>de.trigger(e,t,n),tn=(e,t)=>{if(!de.isOpen()||i.contextMenuPosition!==null)return!1;let n=mI(e,t).find(QF);if(!n)return!1;let r=de.switchToElement(n,{x:e,y:t});return r&&JI([n]),r},nn=e=>({filePath:i.selectionFilePath??void 0,lineNumber:i.selectionLineNumber??void 0,componentName:Ze(),tagName:bN(e)||void 0}),rn=()=>{Ge=null,Ke(!1),o.setPendingCommentMode(!1),Je(null)},an=e=>{let t=i.frozenElement||pt();if(!t)return!1;let n={x:s().x,y:s().y},a=r.store.actions.find(t=>t.id===e);return a?e===`edit`?en(t,n,nn(t))?(o.clearInputText(),o.exitPromptMode(),rn(),!0):!0:(o.clearInputText(),o.exitPromptMode(),rn(),a.onAction(Nn(t,n)),!0):(o.clearInputText(),o.exitPromptMode(),rn(),Mr($M),ln(t,n),!0)},on=e=>{if(d()){if($e()!==e&&b()&&an(e))return;if($e()!==e&&i.pendingCommentMode){o.setPendingCommentMode(!1),Ge=e,Je(e),Ke(!0);return}if($e()!==e&&M()){Ge=e,Je(e);return}Kt();return}T()&&(Ge=e,Je(e),Ke(!0),Jt())},sn=()=>{on(te()?.defaultAction??`copy`)},cn=(e,t,n)=>{rn(),o.clearInputText(),o.enterPromptMode({x:t,y:n},e)},ln=(e,t)=>{Se(),Ar(),o.showContextMenu(t,e),wn(),r.hooks.onContextMenu(e,t)},un=(e,t)=>{let n=Ge;if(Ge=null,Je(null),!n)return;if(n===`edit`){en(e,t,nn(e));return}let i=r.store.actions.find(e=>e.id===n);if(!i){Mr($M),ln(e,t);return}i.onAction(Nn(e,t))},dn=()=>{if(T()){if(d()&&x()){Kt();return}o.setPendingCommentMode(!0),d()||Jt()}},fn=(e,t,n)=>{let r=n&&j()&&!p()&&!i.pendingCommentMode&&!M();if(be()||f()&&!r)return;if(o.setPointer({x:e,y:t}),ke.latestPointerX=e,ke.latestPointerY=t,r){let n=hI(e,t);n!==i.detectedElement&&o.setDetectedElement(n);return}let a=performance.now(),s=ke.pendingDetectionScheduledAt>0&&a-ke.pendingDetectionScheduledAt<200;if(a-ke.lastDetectionTimestamp>=32&&!s&&(ke.lastDetectionTimestamp=a,ke.pendingDetectionScheduledAt=a,setTimeout(()=>{if(be()){ke.pendingDetectionScheduledAt=0;return}let e=hI(ke.latestPointerX,ke.latestPointerY);e!==i.detectedElement&&o.setDetectedElement(e),ke.pendingDetectionScheduledAt=0})),p()){if(h()){let{pageX:n,pageY:r}=Et(e,t);Ie&&o.shiftDragStart({x:n-Ie.x,y:r-Ie.y}),Ie={x:n,y:r}}Ne(e,t);let n=GX(e,t),r=n.top||n.bottom||n.left||n.right;r&&!nt.isActive()?nt.start():!r&&nt.isActive()&&nt.stop()}},pn=(e,t,n)=>{if(!N()||v())return!1;!n&&j()&&Se();let i=ye.selectedElement()!==null;return o.startDrag({x:e,y:t},n||i),o.setPointer({x:e,y:t}),C(`userSelect`,`none`),Ne(e,t),r.hooks.onDragStart(e+window.scrollX,t+window.scrollY),!0},mn=(e,t)=>{let n=i.frozenElements.includes(e),r=i.frozenElements.length===0;if(!n){let n=TY(IJ(e),t);ve.set(e,n),r&&Qe(CU(e)??void 0)}o.toggleFrozenElement(e),gI();let a=i.frozenElements.includes(e);if(a||ve.delete(e),i.frozenElements.length===0){Se(),o.unfreeze();return}JI(i.frozenElements),Le(!0),o.setPointer(t),o.setLastGrabbed(a?e:i.frozenElements[i.frozenElements.length-1]),o.freeze(),wn()},hn=()=>{let e=i.frozenElements.filter(Uz),t=e.map(e=>{let t=bN(e)||`element`,n=CU(e)??void 0,r=ve.get(e),i=IJ(e);return{element:e,tagName:t,componentName:n,mouseX:r===void 0?i.x+i.width/2:i.x+i.width*r}});if(Se(),e.length===0){o.unfreeze();return}if(e.length===1){dt({element:e[0],cursorX:t[0].mouseX,selectedElements:e,shouldDeactivateAfter:i.wasActivatedByToggle});return}ft({elements:e,labelEntries:t,shouldDeactivateAfter:i.wasActivatedByToggle})},gn=(e,t,n)=>{let a=wY(e,QF),s=a.length>0?a:wY(e,QF,!1);if(s.length===0)return;let c=n&&!i.pendingCommentMode&&!M();if(c&&o.addFrozenElements(s),JI(c?i.frozenElements:s),r.hooks.onDragEnd(s,e),c){let e=s[s.length-1];Le(!0),gI(),o.setPointer(LJ(IJ(e))),o.setLastGrabbed(e),o.freeze(),wn();return}let l=s[0],u=LJ(IJ(l));o.setPointer(u),o.setFrozenElements(s);let d=OY(e);if(o.setFrozenDragRect(d),o.freeze(),o.setLastGrabbed(l),i.pendingCommentMode){cn(l,u.x,u.y);return}if(M()){Ke(!1),Ge?un(l,u):ln(l,u);return}let f=i.wasActivatedByToggle&&!t;dt({element:l,cursorX:u.x,selectedElements:s,shouldDeactivateAfter:f,dragRect:d})},_n=e=>{for(let t of i.frozenElements)if(Uz(t)&&$X(e,IJ(t)))return t;return null},vn=(e,t,n,a)=>{let c=Uz(i.frozenElement)?i.frozenElement:null,l=ye.selectedElement(),u=()=>mI(e,t).find(QF)??null;if(a&&!i.pendingCommentMode&&!M()){let n=u();n!==null&&mn(n,{x:e,y:t});return}let d=u()??(Uz(i.detectedElement)?i.detectedElement:null),f=l??d??c;if(!f)return;let p,m,h=d===null&&c===f,g=l===f;if(h)p=s().x,m=s().y;else if(g){let e=LJ(IJ(f));p=e.x,m=e.y}else p=e,m=t;if(i.pendingCommentMode){cn(f,p,m),ye.clear();return}if(M()){Ke(!1);let{wasIntercepted:e}=r.hooks.onElementSelect(f);if(e)return;ye.clear(),JI([f]),o.setFrozenElement(f);let t={x:p,y:m};o.setPointer(t),o.freeze(),Ge?un(f,t):ln(f,t);return}let _=i.wasActivatedByToggle&&!n;o.setLastGrabbed(f),dt({element:f,cursorX:p,shouldDeactivateAfter:_}),ye.clear()},yn=()=>{p()&&(Mt(),o.cancelDrag(),nt.stop(),C(`userSelect`,``))},bn=(e,t,n,r)=>{if(!p())return;Ae!==null&&(clearTimeout(Ae),Ae=null),Me(null);let i=Dt(e,t),a=i.x>2||i.y>2,s=a?kt(e,t):null;a?o.endDrag():o.cancelDrag(),Mt(),nt.stop(),C(`userSelect`,``),s?gn(s,n,r):vn(e,t,n,r)},xn=uY(),Sn=WX(),Cn=e=>{let t;try{t=Sn.originalKeyDescriptor?.get?Sn.originalKeyDescriptor.get.call(e):e.key}catch{return!1}let n=t===`Enter`||QX(e.code),r=d()||u();return n&&r&&!b()&&!ye.isPendingDismiss()&&!i.wasActivatedByToggle?vB(e,`data-react-grab-input`)?!1:(Sn.claimedEvents.add(e),e.preventDefault(),e.stopImmediatePropagation(),!0):!1};xn.addDocumentListener(`keydown`,xM(Cn),{capture:!0}),xn.addDocumentListener(`keyup`,xM(Cn),{capture:!0}),xn.addDocumentListener(`keypress`,xM(Cn),{capture:!0});let wn=()=>{tt.clearHistory(),ye.clear()},Tn=(e,t=!1)=>{o.setFrozenElement(e),o.freeze(),ye.select(e,{shouldPromptBeforeMouseHandoff:t});let n=LJ(IJ(e));o.setPointer(n),i.contextMenuPosition!==null&&o.showContextMenu(n,e)},En=()=>{ye.showDismissPrompt()&&ee(e=>e+1)},Dn=()=>{ye.clear(),o.unfreeze(),wn()},On=()=>{let e=ye.takeSelection(i.frozenElement);if(!e){Dn();return}let t=LJ(IJ(e));wn(),o.setLastGrabbed(e),dt({element:e,cursorX:t.x,shouldDeactivateAfter:i.wasActivatedByToggle})},kn=e=>JM.has(e.key)?e.key:e.key===`Tab`?e.shiftKey?`ArrowLeft`:`ArrowRight`:null,An=(e,t={})=>{if(!d()||b()||j()||ye.isPendingDismiss()&&!t.allowPendingKeyboardSelection)return!1;let n=kn(e);if(!n||pe())return!1;let r=P(),i=!r;if(!r){let e=yM()?.getBoundingClientRect();r=e?hI(e.left+e.width/2,e.top+e.height/2):hI(window.innerWidth/2,window.innerHeight/2)}if(!r)return!1;let a=n===`ArrowUp`||n===`ArrowDown`,o=tt.findNext(n,r);if(!o&&!a&&!i)return!1;let s=o??r;return e.preventDefault(),e.stopPropagation(),Tn(s,!0),!0},jn=e=>e.metaKey||e.ctrlKey||e.altKey||e.repeat||Kz(e)||!d()||_()||v()||pe()?null:i.frozenElement||pt(),Mn=e=>{let t=jn(e);if(!t)return null;let n=EV(r.store.actions,e);return n?{element:t,action:n}:null},Nn=(e,t)=>{let n=IJ(e);return Cr({element:e,filePath:i.selectionFilePath??void 0,lineNumber:i.selectionLineNumber??void 0,tagName:bN(e)||void 0,componentName:Ze(),position:t,shouldDeferHideContextMenu:!1,performWithFeedbackOptions:{fallbackBounds:n,fallbackSelectionBounds:[n],position:t}})},Pn=/^[a-zA-Z0-9-]$/,Fn=e=>{if(!e.key||e.key.length!==1||!Pn.test(e.key))return!1;let t=jn(e);return!t||!de.trigger(t,{x:s().x,y:s().y},{initialSearchQuery:e.key})?!1:(rn(),e.preventDefault(),e.stopImmediatePropagation(),!0)},In=e=>{let t=Mn(e);if(!t)return!1;let{element:n,action:r}=t;if(b())return an(r.id)?(e.preventDefault(),e.stopImmediatePropagation(),!0):!1;let i={x:s().x,y:s().y};return r.onAction(Nn(n,i)),e.preventDefault(),e.stopImmediatePropagation(),!0},Ln=e=>{if(e.key?.toLowerCase()!==`o`||!d()||!(e.metaKey||e.ctrlKey))return!1;let t=i.selectionFilePath,n=i.selectionLineNumber;return t?(e.preventDefault(),e.stopPropagation(),r.hooks.onOpenFile(t,n??void 0)||vI(t,n??void 0,r.hooks.transformOpenFileUrl),!0):!1},Rn=e=>{if(!d()||_()||i.contextMenuPosition!==null||de.isOpen())return!1;let t=e.key===`F10`&&e.shiftKey,n=e.key===`ContextMenu`;if(!t&&!n)return!1;let r=i.frozenElements,a=r.length>1,s=(a?r[0]:null)||i.frozenElement||pt();if(!s)return!1;e.preventDefault(),e.stopPropagation();let c=LJ(IJ(s));return a?JI(r):(JI([s]),o.setFrozenElement(s)),o.setPointer(c),o.freeze(),ln(s,c),!0},zn=Y(()=>ht().map(e=>({tagName:bN(e.element)||`element`,componentName:CU(e.element)??void 0,depth:e.depth,isLast:e.isLast}))),Bn=Y(()=>({items:zn(),activeIndex:gt()})),Vn=e=>{if(!(!r.store.options.allowActivationInsideInput&&Kz(e))&&!(!VY(e,r.store.options)&&((e.metaKey||e.ctrlKey)&&!qM.includes(e.key)&&!QX(e.code)&&(d()&&!i.wasActivatedByToggle?Kt():u()&&(we(),Te(),o.releaseHold())),!QX(e.code)||!u()))){if((d()||u())&&!b()&&(e.preventDefault(),QX(e.code)&&e.stopImmediatePropagation()),d()){if(i.wasActivatedByToggle&&r.store.options.activationMode!==`hold`||e.repeat)return;Pe!==null&&window.clearTimeout(Pe),Pe=window.setTimeout(()=>{Kt()},200);return}if(u()&&e.repeat){if(Fe.copyWaiting){let e=Fe.holdTimerFired;Te(),e&&o.activate()}return}if(!(_()||y())&&!u()){let t=r.store.options.keyHoldDuration??100;Kz(e)?qz(e)?t+=600:t+=400:Jz()&&(t+=600),Te(),o.startHold(t)}}},Hn=e=>{if(!ye.isPendingDismiss())return!1;if(QX(e.code))return!0;let t=JM.has(e.key),n=Mn(e)!==null;return!t&&!n?!1:t?An(e,{allowPendingKeyboardSelection:!0}):In(e)?(wn(),!0):!1};xn.addWindowListener(`keydown`,xM(e=>{if(kn(e)&&Kz(e)||Hn(e))return;if(Cn(e),!T()){VY(e,r.store.options)&&!e.repeat&&O(e=>e+1);return}let t=QX(e.code)&&u()&&!b(),n=vB(e,ZM);if(b()&&VY(e,r.store.options)&&!e.repeat&&!n){e.preventDefault(),e.stopPropagation(),Xt();return}if(e.key===`Escape`&&pe()){ae()!==null&&kr();return}let a=vB(e,`data-react-grab-ignore-events`)&&!t;if(b()||a)return b()&&!n&&In(e)||(e.key===`Escape`&&(b()?Xt():i.wasActivatedByToggle&&Kt()),a&&JM.has(e.key)&&An(e)),void 0;if(p()&&At(e)){e.repeat||jt(),e.preventDefault(),e.stopPropagation();return}if(e.key===`Escape`&&(u()||i.wasActivatedByToggle)){Kt();return}d()&&!qM.includes(e.key)&&e.preventDefault();let o=Date.now()-Re<200;An(e)||Ln(e)||Rn(e)||In(e)||Fn(e)||o||Vn(e)}),{capture:!0}),xn.addWindowListener(`keyup`,xM(e=>{if(Cn(e))return;if(At(e)&&h()&&(Mt(),e.preventDefault(),e.stopPropagation()),e.key===`Shift`&&j()){p()&&yn(),hn();return}if(vB(e,`data-react-grab-ignore-events`))return;let t=UX(r.store.options),n=t.metaKey||t.ctrlKey?_B()?!e.metaKey:!e.ctrlKey:t.shiftKey&&!e.shiftKey||t.altKey&&!e.altKey,a=r.store.options.activationKey?typeof r.store.options.activationKey==`function`?r.store.options.activationKey(e):zY(r.store.options.activationKey)(e):FY(e.key,e.code);if(y()||ze){(a||n)&&(He(),Kt());return}if(!u()&&!d()||b())return;let s=!!r.store.options.activationKey,c=r.store.options.activationMode===`hold`,l=p();if(d()){let e=fe();if(n){if(i.wasActivatedByToggle&&r.store.options.activationMode!==`hold`||e)return;Kt()}else if(c&&a){if(Pe!==null&&(window.clearTimeout(Pe),Pe=null),e||l)return;Kt()}else!s&&a&&Pe!==null&&(window.clearTimeout(Pe),Pe=null);return}if(a||n){if(i.wasActivatedByToggle&&r.store.options.activationMode!==`hold`)return;if(u()||Fe.holdTimerFired&&n){we();let t=(Fe.startTimestamp?Date.now()-Fe.startTimestamp:0)>=200,n=Fe.holdTimerFired&&t&&(r.store.options.allowActivationInsideInput||!Kz(e));Te(),n?o.activate():o.releaseHold()}else Kt()}}),{capture:!0}),xn.addDocumentListener(`copy`,()=>{u()&&(Fe.copyWaiting=!0)}),xn.addWindowListener(`keypress`,xM(Cn),{capture:!0}),xn.addWindowListener(`pointermove`,xM(e=>{if(!e.isPrimary)return;let t=e.pointerType===`touch`;if(o.setTouchMode(t),!vB(e,`data-react-grab-ignore-events`)&&!be()&&!(t&&!u()&&!d())){if((t?u():d())&&!b()&&f()&&!e.shiftKey&&!j()){if(ye.consumeMouseHandoff()){En();return}o.unfreeze(),wn()}fn(e.clientX,e.clientY,e.shiftKey)}}),{passive:!0}),xn.addWindowListener(`pointerdown`,xM(e=>{if(e.button===0&&e.isPrimary&&(o.setTouchMode(e.pointerType===`touch`),_e=!1,!vB(e,`data-react-grab-ignore-events`))){if(fe()){tn(e.clientX,e.clientY)&&(_e=!0,e.preventDefault(),e.stopImmediatePropagation());return}if(b()){let t=Tt();t&&e.clientX>=t.x&&e.clientX<=t.x+t.width&&e.clientY>=t.y&&e.clientY<=t.y+t.height?Yt():Xt();return}if(ye.isPendingDismiss()){e.preventDefault(),e.stopImmediatePropagation();return}if(v()){e.preventDefault(),e.stopImmediatePropagation();return}pn(e.clientX,e.clientY,e.shiftKey)&&(e.pointerId!==void 0&&document.documentElement.setPointerCapture(e.pointerId),e.preventDefault(),e.stopImmediatePropagation())}}),{capture:!0}),xn.addWindowListener(`pointerup`,xM(e=>{if(e.button!==0||!e.isPrimary||vB(e,`data-react-grab-ignore-events`)||fe())return;let t=N()||v()||p(),n=e.metaKey||e.ctrlKey;bn(e.clientX,e.clientY,n,e.shiftKey),t&&(e.preventDefault(),e.stopImmediatePropagation())}),{capture:!0}),xn.addWindowListener(`contextmenu`,xM(e=>{if(!N()||_()||b()||de.isOpen())return;let t=vB(e,`data-react-grab-ignore-events`),n={x:e.clientX,y:e.clientY},r=t&&i.frozenElements.length>1?_n(n):null,a=ye.isPendingDismiss();if(t&&!r&&!a&&!_t())return;if(fe()){e.preventDefault();return}e.preventDefault(),e.stopPropagation();let s=r??hI(e.clientX,e.clientY);if(!s)return;let c=i.frozenElements;c.length>1&&c.includes(s)?JI(c):(JI([s]),o.setFrozenElement(s)),o.setPointer(n),o.freeze(),ln(s,n)}),{capture:!0}),xn.addWindowListener(`pointercancel`,xM(e=>{e.isPrimary&&yn()})),xn.addWindowListener(`click`,xM(e=>{if(!vB(e,`data-react-grab-ignore-events`)){if(_e){_e=!1,e.preventDefault(),e.stopImmediatePropagation();return}fe()||(N()||g())&&(e.preventDefault(),e.stopImmediatePropagation(),i.wasActivatedByToggle&&!b()&&!e.shiftKey&&(u()?o.setWasActivatedByToggle(!1):Kt()))}}),{capture:!0}),xn.addDocumentListener(`visibilitychange`,()=>{if(document.hidden){o.clearGrabbedBoxes();let e=i.activationTimestamp;d()&&!b()&&e!==null&&Date.now()-e>500&&Kt()}}),xn.addWindowListener(`blur`,()=>{yn(),u()&&(we(),o.releaseHold(),Te()),Se()}),xn.addWindowListener(`focus`,()=>{Re=Date.now()}),xn.addWindowListener(`focusin`,e=>{vB(e,SM)&&e.stopPropagation()},{capture:!0});let Un=()=>{if(!(i.isTouchMode&&!u()&&!d())&&!be()&&!f()&&!p()&&i.frozenElements.length===0){let e=hI(s().x,s().y);o.setDetectedElement(e)}},Wn=null,Gn=null,Kn=()=>{EY(),Un(),o.incrementViewportVersion(),o.updateContextMenuPosition()};xn.addWindowListener(`scroll`,Kn,{capture:!0});let qn=window.innerWidth,Jn=window.innerHeight;xn.addWindowListener(`resize`,()=>{let e=window.innerWidth,t=window.innerHeight;if(qn>0&&Jn>0){let n=e/qn,r=t/Jn,i=Math.abs(n-r)<rN,a=Math.abs(n-1)>rN;i&&a&&o.setPointer({x:s().x*n,y:s().y*r})}qn=e,Jn=t,Kn()});let Yn=window.visualViewport;if(Yn){let{signal:e}=xn;Yn.addEventListener(`resize`,Kn,{signal:e}),Yn.addEventListener(`scroll`,Kn,{signal:e})}let Xn=()=>{Gn===null&&(Gn=RF(()=>{Gn=null,o.incrementViewportVersion()}))};tR(()=>{if(r.store.theme.enabled&&(d()||_()||i.labelInstances.length>0||i.grabbedBoxes.length>0)){if(Wn!==null)return;Wn=window.setInterval(()=>{Xn()},100);return}Wn!==null&&(window.clearInterval(Wn),Wn=null),Gn!==null&&(zF(Gn),Gn=null)}),cR(()=>{Wn!==null&&window.clearInterval(Wn),Gn!==null&&zF(Gn)}),xn.addDocumentListener(`copy`,xM(e=>{b()||vB(e,`data-react-grab-ignore-events`)||N()&&e.preventDefault()}),{capture:!0}),cR(()=>{xn.abort(),Ae!==null&&window.clearTimeout(Ae),Pe&&window.clearTimeout(Pe),He(),he?.(),he=null,ge?.(),ge=null,rt.forEach(e=>window.clearTimeout(e)),rt.clear(),ot.cancelAllFades(),nt.stop(),C(`userSelect`,``),C(`touchAction`,``),Wt(null),Sn.restore(),vM(null)});let{root:Zn,host:Qn}=HJ(wJ);cR(sY(Qn).cleanup);let $n=Y(()=>r.store.theme.enabled),er=Y(()=>r.store.theme.selectionBox.enabled),tr=Y(()=>r.store.theme.elementLabel.enabled),nr=Y(()=>r.store.theme.dragBox.enabled),rr=Y(()=>y()||ne()&&!f()||de.isInteracting()),ir=Y(()=>Pt().length>0),ar=Y(()=>!$n()||!er()||rr()?!1:ir()?!0:bt()),or=Y(()=>{let e=yt();if(e)return bN(e)||void 0}),sr=Y(()=>!$n()||fe()||!tr()||rr()?!1:bt()),cr=new Map,lr=e=>{let t=e.elements?.filter(Uz)??[],n=e.element,r=null;t.length>0?r=t.map(IJ):n&&Uz(n)&&(r=[IJ(n)]);let i=e.bounds,a=e.boundsMultiple;r&&(i=r.length>1?kY(HY(r)):r[0],e.boundsMultiple!==void 0&&(a=e.boundsMultiple.length>1&&e.boundsMultiple.length===e.elements?.length?r:[i]));let o=cr.get(e.id),s=o?.boundsMultiple,c=s===a||s!==void 0&&a!==void 0&&s.length===a.length&&s.every((e,t)=>e.x===a[t].x&&e.y===a[t].y&&e.width===a[t].width&&e.height===a[t].height);if(o&&o.status===e.status&&o.errorMessage===e.errorMessage&&o.bounds.x===i.x&&o.bounds.y===i.y&&o.bounds.width===i.width&&o.bounds.height===i.height&&c)return o;let l=i.x+i.width/2,u=i.width/2,d;d=e.mouseXOffsetRatio!==void 0&&u>0?l+e.mouseXOffsetRatio*u:e.mouseXOffsetFromCenter===void 0?e.mouseX??l:l+e.mouseXOffsetFromCenter;let f={...e,bounds:i,boundsMultiple:a,mouseX:d};return cr.set(e.id,f),f},ur=Y(()=>{if(!$n()||!r.store.theme.grabbedBoxes.enabled)return[];c();let e=new Set(i.labelInstances.map(e=>e.id));for(let t of cr.keys())e.has(t)||cr.delete(t);return i.labelInstances.map(lr)}),dr=Y(()=>!$n()||!r.store.theme.grabbedBoxes.enabled?[]:(c(),i.grabbedBoxes.map(e=>!e.element||!document.body.contains(e.element)?e:{...e,bounds:IJ(e.element)}))),fr=Y(()=>$n()&&nr()&&N()&&Ot()),pr=Y(()=>_()?`processing`:`hover`),mr=Y(()=>{if(!$n())return!1;let e=tr(),t=b(),n=_(),r=N(),i=p(),a=!!P(),o=ne(),s=f();return!e||t||o&&!s?!1:n?!0:r&&!i&&a}),hr=Y(()=>{c();let e=i.contextMenuElement;return e?IJ(e):null}),gr=Y(()=>(c(),i.contextMenuPosition)),_r=Y(()=>{let e=i.contextMenuElement;if(!e)return;let t=i.frozenElements.length;return t>1?`${t} elements`:bN(e)||void 0}),[vr]=UJ(()=>i.frozenElements.length>1?null:i.contextMenuElement),[yr]=rR(()=>i.contextMenuElement,async e=>e?SU(e):null),br=async e=>{o.incrementSelectionInteractionLockDepth();try{return await e()}finally{o.decrementSelectionInteractionLockDepth()}},xr=(e,t,n,r,a)=>async c=>{await br(async()=>{let l=a?.fallbackBounds??null,u=a?.fallbackSelectionBounds??[],d=a?.position??i.contextMenuPosition??s(),f=St(),p=hr()??l,m=t.length>1,h=m?kY(HY(f)):p,g=i.wasActivatedByToggle,_;if(_=m?f:p?[p]:u,o.hideContextMenu(),h){let i=m?h.x+h.width/2:d.x,a=ot.createInstance(h,n||`element`,r,`copying`,{element:e,mouseX:i,elements:m?t:void 0,boundsMultiple:_}),o=!1,s;try{o=await c(),o||(s=`Failed to copy`)}catch(e){s=dY(e,`Action failed`)}ot.updateAfterCopy(a,o,s)}else try{await c()}catch{}g?Kt():o.unfreeze()})},Sr=()=>{setTimeout(()=>{o.hideContextMenu()},0)},Cr=e=>{let{element:t,filePath:n,lineNumber:a,tagName:s,componentName:c,position:l,performWithFeedbackOptions:u,shouldDeferHideContextMenu:f,onBeforeCopy:p,onBeforePrompt:m,customEnterPromptMode:h}=e,g=i.frozenElements.length>0?i.frozenElements:[t],_=f?Sr:o.hideContextMenu,v={element:t,elements:g,filePath:n,lineNumber:a,componentName:c,tagName:s,enterPromptMode:h??(()=>{ot.clearAll(),rn(),m?.(),Ee(t,l.x,l.y),o.setPointer({x:l.x,y:l.y}),o.setFrozenElement(t),De(),d()||Gt(),_()}),enterEditMode:()=>{en(t,l,{filePath:n,lineNumber:a,componentName:c,tagName:s})&&rn(),_()},copy:()=>{rn(),p?.(),dt({element:t,cursorX:l.x,selectedElements:g.length>1?g:void 0,shouldDeactivateAfter:i.wasActivatedByToggle}),_()},hooks:{transformHtmlContent:r.hooks.transformHtmlContent,onOpenFile:r.hooks.onOpenFile,transformOpenFileUrl:r.hooks.transformOpenFileUrl},performWithFeedback:xr(t,g,s,c,u),hideContextMenu:_,cleanup:()=>{i.wasActivatedByToggle?Kt():o.unfreeze()}},y=r.hooks.transformActionContext(v);return{...v,...y}},wr=Y(()=>{let e=i.contextMenuElement;if(!e)return;let t=yr(),n=i.contextMenuPosition??s();return Cr({element:e,filePath:t?.filePath,lineNumber:t?.lineNumber??void 0,tagName:_r(),componentName:vr(),position:n,shouldDeferHideContextMenu:!0,onBeforeCopy:()=>{ye.clear()},customEnterPromptMode:()=>{ot.clearAll(),rn(),o.clearInputText(),o.enterPromptMode(n,e),Sr()}})}),Tr=()=>{setTimeout(()=>{o.hideContextMenu(),Kt()},0)},Er=()=>{if(!me)return null;let e=me.getBoundingClientRect(),t=iZ(e);return t===`left`||t===`right`?{x:t===`left`?e.right:e.left,y:e.top+e.height/2,edge:t}:{x:e.left+e.width/2,y:t===`top`?e.bottom:e.top,edge:t}},Dr=()=>{let e=Er();if(e)return e;let t=de.state();return t?{x:t.position.x,y:t.position.y,edge:`bottom`}:null},Or=(e,t)=>{let n=null,r=()=>{let i=e();i&&t(i),n=RF(r)};return r(),()=>{n!==null&&(zF(n),n=null)}};tR(()=>{if(!_t())return;let e=Or(Er,ue);cR(()=>{e(),ue(null)})});let kr=()=>{he?.(),he=null,oe(null)},Ar=()=>{o.hideContextMenu(),kr(),de.dismiss()},jr=()=>{ae()===null?(o.hideContextMenu(),de.isOpen()&&de.closePreservingRenderer(),he?.(),he=Or(Er,oe)):kr()},Mr=e=>{Ce({defaultAction:e})},Nr=e=>{let t=i.labelInstances.find(t=>t.id===e);if(!t?.element||!Uz(t.element))return;let n=t.element,r=LJ(IJ(n)),a={x:t.mouseX??r.x,y:r.y},s=t.elements&&t.elements.length>0?t.elements.filter(e=>Uz(e)):[n];setTimeout(()=>{kr(),de.isOpen()&&de.closePreservingRenderer(),d()||(o.setWasActivatedByToggle(!0),Gt()),o.setPointer(a),o.setFrozenElements(s),s.length>1&&t.bounds&&o.setFrozenDragRect(OY(t.bounds)),o.freeze(),o.showContextMenu(a,n)},0)};tR(()=>{let e=r.store.theme.hue;e===0?Zn.style.filter=``:Zn.style.filter=`hue-rotate(${e}deg)`}),r.store.theme.enabled&&Promise.resolve().then(()=>(lJ(),VU)).then(({ReactGrabRenderer:e})=>{t||(n=qR(()=>X(e,{get selectionVisible(){return ar()},get selectionBounds(){return Tt()},get selectionBoundsMultiple(){return Ft()},get selectionShouldSnap(){return i.frozenElements.length>0||Pt().length>0},get selectionElementsCount(){return i.frozenElements.length},get frozenLabelEntries(){return Lt()},get pendingShiftPreviewEntry(){return Rt()??void 0},get selectionFilePath(){return i.selectionFilePath??void 0},get selectionLineNumber(){return i.selectionLineNumber??void 0},get selectionTagName(){return or()},get selectionComponentName(){return Ze()},get selectionLabelVisible(){return sr()},selectionLabelStatus:`idle`,get hierarchyState(){return Bn()},get hierarchyMenuPosition(){return le()},get labelInstances(){return ur()},get dragVisible(){return fr()},get dragBounds(){return Nt()},get grabbedBoxes(){return dr()},get mouseX(){return Vz(()=>i.frozenElements.length>1)()?void 0:Bt()??zt().x},get isFrozen(){return f()||d()||ne()},get inputValue(){return i.inputText},get isPromptMode(){return b()},onShowContextMenuInstance:Nr,get onLabelInstanceHoverChange(){return ot.handleHoverChange},get onInputChange(){return o.setInputText},onInputSubmit:()=>void Yt(),onToggleExpand:$t,get selectionLabelShakeCount(){return k()},onConfirmDismiss:Zt,get discardPrompt(){return Vz(()=>!!ye.isPendingDismiss())()?{isKeyboardSelection:!0,onConfirm:Zt,onCopy:On}:S()?{onConfirm:Zt,onCancel:Qt}:void 0},get toolbarVisible(){return r.store.theme.toolbar.enabled},get isActive(){return d()},onToggleActive:sn,onActivateAction:on,get activeActionId(){return $e()},get enabled(){return T()},get shakeCount(){return D()},onToolbarStateChange:e=>{A(e),e.enabled!==T()&&(E(e.enabled),e.enabled||(qt(),Ar())),lZ.forEach(t=>t(e))},onSubscribeToToolbarStateChanges:e=>(lZ.add(e),()=>{lZ.delete(e)}),onToolbarSelectHoverChange:re,onToolbarRef:e=>{me=e},get contextMenuPosition(){return gr()},get contextMenuBounds(){return hr()},get contextMenuTagName(){return _r()},get contextMenuComponentName(){return vr()},get contextMenuHasFilePath(){return!!yr()?.filePath},get actions(){return r.store.actions},get actionContext(){return wr()},onContextMenuDismiss:Tr,onContextMenuHide:Sr,get toolbarMenuPosition(){return ae()},get toolbarMenuActions(){return r.store.actions.filter(e=>e.showInToolbarMenu===!0)},get defaultActionId(){return te()?.defaultAction??`copy`},onSetDefaultAction:Mr,onToggleToolbarMenu:jr,onToolbarMenuDismiss:kr,get editPanelState(){return de.state()},get editPanelPosition(){return se()},get onEditPanelDismiss(){return de.dismiss},get onEditPanelSubmit(){return de.submit},get onEditPanelPendingEditsChange(){return de.setPendingEdits},get onEditPanelInteractingChange(){return de.setInteracting}}),Zn))}).catch(e=>{console.warn(`[react-grab] Failed to load renderer:`,e)});let Pr={activate:()=>{o.setPendingCommentMode(!1),!d()&&T()&&Jt()},deactivate:()=>{(d()||_())&&Kt()},toggle:()=>{d()?Kt():T()&&Jt()},comment:dn,isActive:()=>d(),isEnabled:()=>T(),setEnabled:e=>{e!==T()&&(E(e),Ce({enabled:e,collapsed:!e}),e||(qt(),Ar()))},getToolbarState:()=>te()??xV(),setToolbarState:e=>{let t=te()??xV(),n=e.collapsed??t?.collapsed??!1,r={edge:e.edge??t?.edge??`bottom`,ratio:e.ratio??t?.ratio??.5,collapsed:n,enabled:e.enabled??!n,defaultAction:e.defaultAction??t?.defaultAction??`copy`};SV(r),A(r),r.enabled!==T()&&(E(r.enabled),r.enabled||(qt(),Ar())),lZ.forEach(e=>e(r))},onToolbarStateChange:e=>(lZ.add(e),()=>{lZ.delete(e)}),reset:()=>{qt(),Ar(),o.clearGrabbedBoxes(),o.clearLabelInstances(),o.setSelectionSource(null,null)},dispose:()=>{t=!0,cZ=!1,n?.(),he?.(),he=null,ge?.(),ge=null,lZ.clear(),e()},copyElement:async e=>{let t=Array.isArray(e)?e:[e];return t.length!==0&&await ct(t)},getSource:async e=>{let t=await SU(e);return t?{filePath:t.filePath,lineNumber:t.lineNumber,componentName:t.componentName}:null},getStackContext:e=>PU(e,{maxLines:r.store.options.maxContextLines}),getState:()=>({isActive:d(),isDragging:p(),isCopying:_(),isPromptMode:b(),isSelectionBoxVisible:!!ar(),isDragBoxVisible:!!fr(),targetElement:pt(),dragBounds:Nt()??null,grabbedBoxes:[...Vt()],labelInstances:[...Ht()],selectionFilePath:i.selectionFilePath,toolbarState:te()}),setOptions:e=>{r.setOptions(e)},registerPlugin:e=>{r.register(e,Pr)},unregisterPlugin:e=>{r.unregister(e)},getPlugins:()=>r.getPluginNames(),getDisplayName:CU};for(let e of sZ)r.register(e,Pr);return setTimeout(()=>{MF(!0)},sN),Pr})}})),fZ=r({DEFAULT_THEME:()=>PX,commentPlugin:()=>tZ,formatElementInfo:()=>LU,generateSnippet:()=>oZ,getGlobalApi:()=>mZ,getStack:()=>mU,init:()=>uZ,isInstrumentationActive:()=>qN,openPlugin:()=>rZ,registerPlugin:()=>vZ,setGlobalApi:()=>hZ,unregisterPlugin:()=>yZ}),pZ,mZ,hZ,gZ,_Z,vZ,yZ,bZ=t((()=>{dZ(),YL(),BU(),pZ=null,mZ=()=>typeof window>`u`?pZ:window.__REACT_GRAB__??pZ??null,hZ=e=>{pZ=e,typeof window<`u`&&(e?window.__REACT_GRAB__=e:delete window.__REACT_GRAB__)},gZ=[],_Z=e=>{for(;gZ.length>0;){let t=gZ.shift();t&&e.registerPlugin(t)}},vZ=e=>{let t=mZ();if(t){t.registerPlugin(e);return}gZ.push(e)},yZ=e=>{let t=mZ();if(t){t.unregisterPlugin(e);return}let n=gZ.findIndex(t=>t.name===e);n!==-1&&gZ.splice(n,1)},typeof window<`u`&&!window.__REACT_GRAB_DISABLED__&&(window.__REACT_GRAB__?pZ=window.__REACT_GRAB__:(pZ=uZ(),window.__REACT_GRAB__=pZ),_Z(pZ),window.dispatchEvent(new CustomEvent(`react-grab:init`,{detail:pZ})))}));br(),Rr(),mD();var xZ=`linear-grab:context-copied`,SZ=`linear-grab:picker-activated`,CZ=0,wZ=null;function TZ(e){!e||e.grabbedAt===CZ||Cr().then(t=>{if(t.workflowMode!==`local`||e.grabbedAt===CZ)return;let n=()=>{CZ=e.grabbedAt,navigator.clipboard.writeText(uD(e,t)).then(()=>window.dispatchEvent(new CustomEvent(xZ))).catch(()=>{CZ=0})};e.source?.filePath?(wZ&&clearTimeout(wZ),wZ=null,n()):(wZ&&clearTimeout(wZ),wZ=setTimeout(n,900))})}function EZ(e,t=Date.now()){return{tagName:e.tagName||void 0,componentName:e.componentName||void 0,content:e.textContent?e.textContent.slice(0,500):``,source:e.filePath?{filePath:e.filePath,lineNumber:e.lineNumber??null,columnNumber:e.columnNumber??null,componentName:e.componentName??null}:null,stackContext:void 0,pageUrl:location.href,grabbedAt:t}}function DZ(e,t){let n=null,r=0;return{plugin:{name:`linear-grab`,hooks:{onElementSelect:i=>{r=Date.now(),n=Cr().then(e=>e.captureShots?LA(i):null);let a=t?.(),o={tagName:i.tagName?.toLowerCase()||void 0,componentName:a?.getDisplayName?.(i)||void 0,content:(i.textContent??``).slice(0,500),source:null,stackContext:void 0,pageUrl:location.href,grabbedAt:r};e([o]);try{a?.getSource?.(i)?.then(t=>{t?.filePath&&e([{...o,source:{filePath:t.filePath,lineNumber:t.lineNumber??null,columnNumber:t.columnNumber??null,componentName:t.componentName??o.componentName??null}}])})}catch{}}}},handleSelection(t){let i=r&&Date.now()-r<4e3?r:Date.now(),a=t.map((e,t)=>EZ(e,i+t));if(!a.length)return;e(a);let o=n;n=null,o&&o.then(t=>{t&&e([{...a[0],screenshotDataUrl:t},...a.slice(1)])})}}}var OZ=!1;async function kZ(){if(yr||OZ)return;OZ=!0;let e=await Promise.resolve().then(()=>(bZ(),fZ));try{e.init()}catch{OZ=!1;return}let t=DZ(e=>{Dr(e),TZ(e[0])},()=>e.getGlobalApi());e.registerPlugin(t.plugin),PA(),window.addEventListener(`react-grab:element-selected`,e=>{t.handleSelection(e.detail.elements??[])})}async function AZ(){if(yr){let e=await chrome.runtime.sendMessage({type:`grab/activate`});if(e&&e.ok===!1)throw Error(e.error??`Cannot activate the picker on this page.`);return}await kZ();let e=await Promise.resolve().then(()=>(bZ(),fZ));window.dispatchEvent(new CustomEvent(SZ)),e.getGlobalApi()?.activate()}function jZ(e){if(!yr)return()=>{};let t=t=>{t?.type===`grab/updated`&&e()};return chrome.runtime.onMessage.addListener(t),()=>chrome.runtime.onMessage.removeListener(t)}function MZ(){return new Promise(e=>{let t=document.createElement(`div`);t.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:crosshair;user-select:none;`;let n=document.createElement(`div`);n.style.cssText=`position:fixed;display:none;border:2px solid #5e6ad2;border-radius:4px;box-shadow:0 0 0 100000px rgba(0,0,0,0.35);pointer-events:none;`,t.appendChild(n),document.body.appendChild(t);let r=0,i=0,a=!1,o=e=>({x:Math.min(r,e.clientX),y:Math.min(i,e.clientY),w:Math.abs(e.clientX-r),h:Math.abs(e.clientY-i)}),s=()=>{t.remove(),window.removeEventListener(`keydown`,l,!0)},c=()=>{s(),e(null)},l=e=>{e.key===`Escape`&&(e.stopPropagation(),c())};window.addEventListener(`keydown`,l,!0),t.addEventListener(`pointerdown`,e=>{a=!0,r=e.clientX,i=e.clientY,t.setPointerCapture(e.pointerId)}),t.addEventListener(`pointermove`,e=>{if(!a)return;let t=o(e);n.style.display=`block`,n.style.left=`${t.x}px`,n.style.top=`${t.y}px`,n.style.width=`${t.w}px`,n.style.height=`${t.h}px`}),t.addEventListener(`pointerup`,t=>{let n=o(t);if(s(),n.w<8||n.h<8)return e(null);RA(n).then(t=>{if(!t)return e(null);e({tagName:`region`,componentName:void 0,content:`Region capture ${Math.round(n.w)}×${Math.round(n.h)}`,source:null,stackContext:void 0,screenshotDataUrl:t,pageUrl:location.href,grabbedAt:Date.now()})})})})}Rr(),br(),mD();var NZ=N(`<span class="text-text-faint ml-auto text-[10.5px] font-normal normal-case tabular-nums">`),PZ=N(`<details open class=group><summary class="text-text-dim hover:text-text flex cursor-pointer items-center gap-1.5 text-[11px] font-semibold tracking-wide uppercase select-none"><span aria-hidden class="text-text-faint inline-block w-3 text-center transition-transform group-open:rotate-90">›</span></summary><div class="flex flex-col gap-2 pt-2 pl-4">`),FZ=N(`<div class="flex flex-col gap-1.5"><div class="flex items-center justify-between gap-2"><span class="text-text-faint min-w-0 text-[10.5px] leading-snug">All elements post into ONE issue. Shift+click / drag selects several at once.`),IZ=N(`<div class="flex flex-col gap-1.5"><div class="flex gap-1.5">`),LZ=N(`<span class=text-danger>●`),RZ=N(`<div class="flex flex-col gap-1.5"><span class="text-text-faint text-[10.5px] leading-snug">Captures your screen as a looping GIF (max 30s) the coding agent can watch. Pick this tab in the share dialog, then reproduce the issue.`),zZ=N(`<span class="inline-block min-w-[4ch] text-center">Stop`),BZ=N(`<div class="bg-surface border-border flex items-center gap-2 rounded-lg border p-2.5"><span aria-hidden class="bg-danger size-2 shrink-0 animate-pulse rounded-full"></span><span class="text-text min-w-[5ch] text-[12px] tabular-nums"></span><span class="text-text-faint text-[10.5px]">max 0:30`),VZ=N(`<div class="bg-surface border-border flex items-center gap-2 rounded-lg border p-2.5"><span class="text-text-dim text-[12px]">Encoding GIF…`),HZ=N(`<div class="flex h-full flex-col gap-4 overflow-y-auto pt-3 pb-4 pl-3 pr-4">`),UZ=N(`<span class="text-success text-[12px] leading-none">✓`),WZ=N(`<svg width=12 height=12 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><path d="M4 4l8 8M12 4l-8 8">`),GZ=N(`<span class="font-mono text-text-dim break-all text-[11px] leading-snug">`),KZ=N(`<img alt="Element location screenshot"class="border-border bg-bg max-h-32 w-full rounded-md border object-contain">`),qZ=N(`<div class="bg-surface border-border flex flex-col gap-1.5 rounded-lg border p-2.5"><div class="flex items-center justify-between gap-2"><span class="font-mono text-accent min-w-0 truncate text-[12px]"></span><div class="flex shrink-0 items-center gap-1">`),JZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linejoin=round aria-hidden><rect x=5.5 y=5.5 width=9 height=9 rx=1.5></rect><path d="M10.5 5.5v-2a2 2 0 0 0-2-2h-5a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h2">`),YZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden><path d="M8 2.5v8M4.5 7.5 8 11l3.5-3.5M2.5 13.5h11">`),XZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><path d="M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9a1.5 1.5 0 0 0 1.5 1.4h3.6A1.5 1.5 0 0 0 11.3 13l.7-9M6.5 7v4.5M9.5 7v4.5">`),ZZ=N(`<div class="bg-surface border-border flex flex-col gap-2 rounded-lg border p-2.5"><img alt="Screen recording preview"class="border-border bg-bg max-h-44 w-full rounded-md border object-contain"><span class="text-text-faint text-[10.5px] tabular-nums"> KB · <!>s · <!>×</span><label class="flex cursor-pointer items-center gap-2 select-none"><input type=checkbox class="accent-accent rounded"><span class="text-text text-[12px]">Attach to issue on create</span></label><div class="flex items-center gap-1">`),QZ=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><path d="M6.5 9.5 9.5 6.5M7.5 4.5 9 3a2.5 2.5 0 0 1 3.5 3.5L11 8M8.5 11.5 7 13a2.5 2.5 0 0 1-3.5-3.5L5 8">`);function $Z(e){return(()=>{var t=PZ(),n=t.firstChild;n.firstChild;var r=n.nextSibling;return P(n,()=>e.title,null),P(n,j(M,{get when(){return e.badge},get children(){var t=NZ();return P(t,()=>e.badge),t}}),null),P(r,()=>e.children),t})()}function eQ(){let e=sr(),t=_r(()=>({queryKey:[`grab`],queryFn:Tr})),n=_r(()=>({queryKey:[`settings`],queryFn:Cr})),r=()=>t.data??[],i=()=>!!(n.data?.linearApiKey||n.data?.linearAccessToken),[a,o]=T(null),s=()=>{o(null),AZ().catch(e=>{o(e instanceof Error&&e.message?e.message:`Cannot activate the picker — open your dev app in the active tab first.`)})},c=async()=>{await kr(),e.invalidateQueries({queryKey:[`grab`]})},[l,u]=T(null),d=async e=>{try{await navigator.clipboard.writeText(uD(e,n.data??{})),u(e.grabbedAt),setTimeout(()=>u(null),1800)}catch{o(`Clipboard was blocked — click the button again.`)}},f=async t=>{await Or(t),e.invalidateQueries({queryKey:[`grab`]})},[p,m]=T(!1),h=async()=>{o(null),m(!0),window.dispatchEvent(new CustomEvent(SZ));try{let e=await MZ();e?await Dr([e]):o(`Region capture failed — try a smaller area (huge scrollers exceed canvas limits), or it was cancelled.`)}finally{m(!1)}},[g,_]=T(BD());ae(VD(_));let[v,y]=T(0);O(()=>{if(g().phase!==`recording`)return;let e=setInterval(()=>y(Date.now()-(BD().startedAt??Date.now())),250);ae(()=>clearInterval(e))});let b=e=>{let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},[x,S]=T(`idle`),[C,w]=T(null),E=async()=>{let e=BD().result;if(!e)throw Error(`No recording available.`);if(e.assetUrl)return e.assetUrl;let t=await xO(e.blob,`recording-${Date.now()}.gif`);return tO(t),t},k=async()=>{w(null),S(`busy`);try{let e=E().then(e=>new Blob([``],{type:`text/plain`}));try{await navigator.clipboard.write([new ClipboardItem({"text/plain":e})])}catch{let t=await e;await navigator.clipboard.writeText(await t.text())}S(`copied`),setTimeout(()=>S(`idle`),2e3)}catch{S(`idle`),await ne(),w(`Direct upload is blocked in this browser — copied the GIF instead. Paste it into a Linear comment and Linear uploads it.`)}},ee=()=>{let e=g().result;if(!e)return;let t=document.createElement(`a`);t.href=e.url,t.download=`linear-grab-recording.gif`,t.click()},[te,A]=T(`idle`),ne=async()=>{let e=g().result;if(e){w(null),A(`busy`);try{try{await navigator.clipboard.write([new ClipboardItem({"image/gif":e.blob})])}catch{let t=await createImageBitmap(e.blob),n=document.createElement(`canvas`);n.width=t.width,n.height=t.height,n.getContext(`2d`).drawImage(t,0,0);let r=await new Promise((e,t)=>n.toBlob(n=>n?e(n):t(Error(`PNG encode failed`)),`image/png`));await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),w(`Browser blocks GIF clipboard — copied the first frame as PNG. Use Download for the animation.`)}A(`copied`),setTimeout(()=>A(`idle`),2e3)}catch(e){A(`idle`),w(e instanceof Error?e.message:`Copy failed.`)}}};return(()=>{var e=HZ();return P(e,j($Z,{title:`Captured elements`,get badge(){return $e(()=>!!r().length)()?`${r().length}/8`:void 0},get children(){return[j(M,{get when(){return r().length>0},get fallback(){return j(Tj,{title:`No elements captured`,children:`Click "Pick element" below, then use the react-grab overlay on your dev app. Every pick ADDS to this list — Shift+click or drag in the overlay selects several at once. Source info needs a dev build.`})},get children(){var e=FZ(),t=e.firstChild;return t.firstChild,P(e,j(We,{get each(){return r()},children:e=>(()=>{var t=qZ(),n=t.firstChild.firstChild,r=n.nextSibling;return P(n,(()=>{var t=$e(()=>!!e.componentName);return()=>t()?`<${e.componentName}>`:$e(()=>!!e.tagName)()?`<${e.tagName}>`:`Element`})()),P(r,j(hj,{class:`size-7 px-0`,variant:`ghost`,title:`Copy context for a local agent (Claude Code / Cursor) — includes skills & memory paths`,"aria-label":`Copy context`,onClick:()=>void d(e),get children(){return j(M,{get when(){return l()===e.grabbedAt},get fallback(){return JZ()},get children(){return UZ()}})}}),null),P(r,j(hj,{class:`size-7 px-0`,variant:`ghost`,title:`Remove this element`,"aria-label":`Remove element`,onClick:()=>void f(e.grabbedAt),get children(){return WZ()}}),null),P(t,j(M,{get when(){return e.source?.filePath},get children(){var t=GZ();return P(t,()=>e.source.filePath,null),P(t,(()=>{var t=$e(()=>e.source?.lineNumber!=null);return()=>t()?`:${e.source.lineNumber}`:``})(),null),t}}),null),P(t,j(M,{get when(){return e.screenshotDataUrl},get children(){var t=KZ();return D(()=>it(t,`src`,e.screenshotDataUrl)),t}}),null),t})()}),t),P(t,j(hj,{class:`h-6 shrink-0 px-2 text-[11px]`,variant:`ghost`,onClick:c,children:`Clear all`}),null),e}}),(()=>{var e=IZ(),t=e.firstChild;return P(t,j(hj,{variant:`primary`,class:`min-w-0 flex-1`,onClick:s,children:`Pick element`}),null),P(t,j(M,{when:!yr,get children(){return j(hj,{variant:`ghost`,class:`min-w-0 flex-1`,get loading(){return p()},title:`Drag a rectangle over any part of the page — the shot attaches to the issue`,onClick:()=>void h(),children:`Capture region`})}}),null),P(e,j(M,{get when(){return a()},get children(){return j(Ej,{get message(){return a()}})}}),null),e})()]}}),null),P(e,j($Z,{title:`Recording`,get badge(){return $e(()=>!!g().result)()?`${(g().result.durationMs/1e3).toFixed(1)}s`:void 0},get children(){return[j(M,{get when(){return g().phase===`idle`||g().phase===`error`},get children(){var e=RZ(),t=e.firstChild;return P(e,j(hj,{variant:`ghost`,onClick:()=>void ZD(),get children(){return[LZ(),` Record interaction`]}}),t),P(e,j(M,{get when(){return $e(()=>g().phase===`error`)()&&g().error},get children(){return j(Ej,{get message(){return g().error}})}}),null),e}}),j(M,{get when(){return g().phase===`recording`},get children(){var e=BZ(),t=e.firstChild.nextSibling;return t.nextSibling,P(t,()=>b(v())),P(e,j(hj,{variant:`primary`,class:`ml-auto`,onClick:()=>void QD(),get children(){return zZ()}}),null),e}}),j(M,{get when(){return g().phase===`processing`},get children(){var e=VZ(),t=e.firstChild;return P(e,j(gj,{}),t),e}}),j(M,{get when(){return $e(()=>g().phase===`ready`)()&&g().result},children:e=>(()=>{var t=ZZ(),n=t.firstChild,r=n.nextSibling,a=r.firstChild,o=a.nextSibling,s=o.nextSibling.nextSibling;s.nextSibling;var c=r.nextSibling,l=c.firstChild,u=c.nextSibling;return P(r,()=>(e().blob.size/1024).toFixed(0),a),P(r,()=>(e().durationMs/1e3).toFixed(1),o),P(r,()=>e().width,s),P(r,()=>e().height,null),l.addEventListener(`change`,e=>eO(e.currentTarget.checked)),P(u,j(hj,{variant:`ghost`,class:`size-7 px-0`,get loading(){return x()===`busy`},get disabled(){return!i()},get title(){return i()?`Copy markdown — uploads to Linear, copies embeddable link`:`Connect Linear in Settings first`},"aria-label":`Copy markdown`,onClick:()=>void k(),get children(){return j(M,{get when(){return x()===`copied`},get fallback(){return QZ()},get children(){return UZ()}})}}),null),P(u,j(hj,{variant:`ghost`,class:`size-7 px-0`,get loading(){return te()===`busy`},title:`Copy GIF — paste into a Linear comment and Linear uploads it`,"aria-label":`Copy GIF`,onClick:()=>void ne(),get children(){return j(M,{get when(){return te()===`copied`},get fallback(){return JZ()},get children(){return UZ()}})}}),null),P(u,j(hj,{variant:`ghost`,class:`size-7 px-0`,title:`Download GIF`,"aria-label":`Download GIF`,onClick:ee,get children(){return YZ()}}),null),P(u,j(hj,{variant:`danger`,class:`ml-auto size-7 px-0`,title:`Discard recording`,"aria-label":`Discard recording`,onClick:$D,get children(){return XZ()}}),null),P(t,j(M,{get when(){return C()},get children(){return j(Ej,{get message(){return C()}})}}),null),D(()=>it(n,`src`,e().url)),D(()=>l.checked=g().attachOnCreate),t})()})]}}),null),e})()}function tQ(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function nQ(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function rQ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var iQ=(e,t)=>Math.abs(e-t)<1.01,aQ=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},oQ,sQ=()=>{if(oQ!==void 0)return oQ;if(typeof navigator>`u`)return oQ=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return oQ=!0;let e=navigator.maxTouchPoints;return oQ=navigator.platform===`MacIntel`&&e!==void 0&&e>0},cQ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},lQ=e=>e,uQ=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},dQ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(cQ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(cQ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},fQ={passive:!0},pQ=typeof window>`u`||`onscrollend`in window,mQ=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&pQ,o=0,s=a?null:aQ(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,fQ),a&&r.addEventListener(`scrollend`,u,fQ),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},hQ=(e,t)=>mQ(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),gQ=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},_Q=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},vQ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:lQ,rangeExtractor:uQ,onChange:()=>{},measureElement:gQ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=nQ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!sQ()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,fQ),e.addEventListener(`touchend`,n,fQ),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(sQ()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=nQ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.getMeasurements=nQ(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=tQ(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=nQ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=xQ(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=nQ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=nQ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return rQ(t[yQ(0,t.length-1,r?e=>n[e*2]:e=>rQ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(sQ()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&iQ(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},yQ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function bQ(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function xQ(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=bQ(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=yQ(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}function SQ(e){let t=Ve(e),n=new vQ(t),[r,i]=tr(n.getVirtualItems()),[a,o]=T(n.getTotalSize()),s=new Proxy(n,{get(e,t){switch(t){case`getVirtualItems`:return()=>r;case`getTotalSize`:return()=>a();default:return Reflect.get(e,t)}}});return s.setOptions(t),ie(()=>{let e=s._didMount();s._willUpdate(),ae(e)}),E(()=>{s.setOptions(Ve(t,e,{onChange:(t,n)=>{var r;t._willUpdate(),i(ar(t.getVirtualItems(),{key:`index`})),o(t.getTotalSize()),(r=e.onChange)==null||r.call(e,t,n)}})),s._willUpdate(),i(ar(n.getVirtualItems(),{key:`index`})),o(n.getTotalSize())}),s}function CQ(e){return SQ(Ve({observeElementRect:dQ,observeElementOffset:hQ,scrollToFn:_Q},e))}Rr();var wQ=3e4,TQ=/github\.com\/[^/]+\/[^/]+\/pull\/\d+/i,EQ={running:[],review:[]},DQ=null,OQ=new Set;function kQ(e){return OQ.add(e),DQ||(DQ=setInterval(()=>void MQ(),wQ),MQ()),()=>{OQ.delete(e),!OQ.size&&DQ&&(clearInterval(DQ),DQ=null)}}function AQ(){MQ()}function jQ(e){return{id:e.id,identifier:e.identifier,title:e.title,stateName:e.state.name,stateColor:e.state.color,delegateName:e.delegate?.displayName??`Agent`,updatedAt:e.updatedAt,prUrl:e.attachments?.find(e=>TQ.test(e.url))?.url}}async function MQ(){try{let e=await Cr();if(!e.linearApiKey&&!e.linearAccessToken)return;let t=(await uO()).filter(e=>!!e.delegate&&e.state.type===`started`).map(jQ);EQ={running:t.filter(e=>!e.prUrl),review:t.filter(e=>!!e.prUrl)};for(let e of OQ)e(EQ)}catch{}}function NQ(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var PQ=/^(https?:\/\/|mailto:)/i,FQ=/\.(mp4|mov|webm|m4v)(\?|#|$)/i,IQ=/\.(png|jpe?g|gif|webp|avif|svg)(\?|#|$)/i,LQ=class extends HTMLElement{objectUrl=null;connectedCallback(){let e=this.getAttribute(`src`)??``,t=this.getAttribute(`alt`)??``;(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(String(n.status));let r=await n.blob();if(this.objectUrl=URL.createObjectURL(r),this.textContent=``,r.type.startsWith(`video/`)){let e=document.createElement(`video`);e.controls=!0,e.preload=`metadata`,e.src=this.objectUrl,this.appendChild(e)}else{let e=document.createElement(`img`);e.src=this.objectUrl,e.alt=t,this.appendChild(e)}}catch{this.textContent=``;let e=document.createElement(`span`);e.textContent=`🖼 ${t||`media`} — start the bridge (npx linear-grab-bridge) to view Linear-hosted media here`,e.style.cssText=`font-size:10.5px;color:var(--color-text-faint);`,this.appendChild(e)}})()}disconnectedCallback(){this.objectUrl&&URL.revokeObjectURL(this.objectUrl)}};typeof customElements<`u`&&!customElements.get(`lg-media`)&&customElements.define(`lg-media`,LQ);var RQ=null;function zQ(e){RQ=e?e.replace(/\/$/,``):null}function BQ(e){try{if(RQ&&new URL(e).hostname.endsWith(`uploads.linear.app`))return`${RQ}/fetch?url=${encodeURIComponent(e)}`}catch{}return e}function VQ(e){let t=e;return t=t.replace(/`([^`]+)`/g,(e,t)=>`<code>${t}</code>`),t=t.replace(/!\[([^\]]*)\]\((?:<)?([^()\s]+?)(?:>)?\)/g,(e,t,n)=>{if(!PQ.test(n))return t;let r=BQ(n);return FQ.test(n)?`<video controls preload="metadata" src="${r}"></video>`:r!==n&&!IQ.test(n)?`<lg-media src="${r}" alt="${t}"></lg-media>`:`<img src="${r}" alt="${t}" loading="lazy" />`}),t=t.replace(/\[([^\]]+)\]\((?:<)?([^()\s]+?)(?:>)?\)/g,(e,t,n)=>PQ.test(n)?`<a href="${n}" target="_blank" rel="noopener noreferrer">${t}</a>`:t),t=t.replace(/<(https?:\/\/[^\s&]+)>/g,`<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>`),t=t.replace(/(^|[\s(])((?:https?:\/\/)[^\s<>()"']+)/g,(e,t,n)=>`${t}<a href="${n}" target="_blank" rel="noopener noreferrer">${n}</a>`),t=t.replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(^|\W)\*([^*\n]+)\*(?=\W|$)/g,`$1<em>$2</em>`),t}function HQ(e){let t=NQ(e.trim()).split(`
|
|
216
216
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r++;continue}if(e.startsWith("```")){let e=[];for(r++;r<t.length&&!t[r].startsWith("```");)e.push(t[r++]);r++,n.push(`<pre><code>${e.join(`
|
|
217
217
|
`)}</code></pre>`);continue}let i=e.match(/^(#{1,6})\s+(.*)$/);if(i){n.push(`<h4>${VQ(i[2])}</h4>`),r++;continue}if(/^\s*[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^\s*[-*]\s+/.test(t[r]);)e.push(`<li>${VQ(t[r].replace(/^\s*[-*]\s+/,``))}</li>`),r++;n.push(`<ul>${e.join(``)}</ul>`);continue}if(/^\s*\d+[.)]\s+/.test(e)){let e=[];for(;r<t.length&&/^\s*\d+[.)]\s+/.test(t[r]);)e.push(`<li>${VQ(t[r].replace(/^\s*\d+[.)]\s+/,``))}</li>`),r++;n.push(`<ol>${e.join(``)}</ol>`);continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^(#{1,6}\s|```|\s*[-*]\s+|\s*\d+[.)]\s+)/.test(t[r]);)a.push(t[r]),r++;n.push(`<p>${VQ(a.join(`<br />`))}</p>`)}return n.join(``)}Rr();var UQ=N(`<div class="flex h-full flex-col">`),WQ=N(`<span class="tabular-nums text-[10.5px] text-text-faint">live · updated `),GQ=N(`<svg aria-hidden width=11 height=11 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M1 4.5A7 7 0 0 1 13.5 3"></path><path d="M15 11.5A7 7 0 0 1 2.5 13"></path><polyline points="1 1 1 5 5 5"></polyline><polyline points="15 11 15 15 11 15">`),KQ=N(`<div class="flex-1 overflow-y-auto">`),qQ=N(`<div class="min-h-0 flex-1 overflow-y-auto pl-2 pr-3"><div style=position:relative>`),JQ=N(`<div class="flex h-full flex-col"><div class="border-border flex shrink-0 items-center justify-between border-b px-3 py-2"><span class="text-text text-[12px] font-semibold">My issues</span><div class="flex items-center gap-2">`),YQ=N(`<div style=position:absolute;top:0;left:0;width:100%>`),XQ=N(`<button class="w-full cursor-pointer rounded-md px-2 py-1.5 text-left hover:bg-surface-2 transition-colors"><div class="flex items-center gap-1.5 min-w-0"><span class="font-mono text-[11px] text-text-dim shrink-0"></span><span class="truncate text-[12.5px] text-text"></span></div><div class="mt-0.5 flex items-center gap-1.5"><span class="ml-auto tabular-nums text-[10.5px] text-text-faint">`),ZQ=N(`<span class="inline-block min-w-[6ch] text-left">← Back`),QQ=N(`<span class="font-mono text-[11px] text-text-dim shrink-0">`),$Q=N(`<span class="truncate text-[12px] font-medium text-text">`),e$=N(`<span class="text-[11.5px] text-text-faint">Loading…`),t$=N(`<div class="flex items-center gap-2"><span class="text-[11px] text-text-dim">`),n$=N(`<div class="flex flex-col gap-2">`),r$=N(`<div class="flex flex-col gap-1"><span class="text-[10.5px] font-semibold uppercase tracking-wide text-text-dim">Attachments</span><div class="flex flex-col gap-1">`),i$=N(`<div class="flex flex-col gap-2.5"><span class="text-[10.5px] font-semibold uppercase tracking-wide text-text-dim">Comments`),a$=N(`<option value=new>Start NEW agent (@<!>)`),o$=N(`<option value=comment>Comment only`),s$=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><circle cx=8 cy=8 r=2.2></circle><path d="M8 1v3M8 12v3M1 8h3M12 8h3">`),c$=N(`<span class="inline-block min-w-[4ch] text-left">Send`),l$=N(`<div class="flex h-full flex-col"><div class="border-border flex shrink-0 flex-col gap-1 border-b px-3 py-2"><div class="flex items-center gap-2"></div></div><div class="min-h-0 flex-1 overflow-y-auto pl-3 pr-4 py-3 flex flex-col gap-3"></div><div class="border-border shrink-0 border-t p-2.5 flex flex-col gap-1.5"><div class="flex items-center gap-2">`),u$=N(`<div class="bg-surface border-border overflow-clip rounded-lg border"><div class="border-border flex h-9 min-w-0 items-center justify-between gap-2 border-b px-3"><div class="flex min-w-0 items-center gap-1.5 text-[11.5px] font-medium"><span aria-hidden>🖥</span><span class="text-text shrink-0">Local Claude Code</span><span class="text-text-dim shrink-0">started by you</span><span class="text-text-faint shrink-0 tabular-nums">· </span></div></div><button class="hover:bg-surface-2 flex h-9 w-full min-w-0 cursor-pointer items-center gap-2 px-3 text-left transition-colors"title="Open the live thread in the Local tab"><span></span><span class="text-text-faint min-w-0 flex-1 truncate text-[11.5px]"></span><svg width=14 height=14 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden class="text-text-dim shrink-0"><path d="m6 3.5 4.5 4.5L6 12.5">`),d$=N(`<span class="inline-block min-w-[6ch] text-center">`),f$=N(`<div class="flex min-w-0 items-center gap-1.5"><a target=_blank rel=noreferrer class="text-accent min-w-0 truncate text-[11.5px] hover:underline">`),p$=N(`<div class="flex flex-col gap-0.5"><div class="flex items-center gap-1.5"><span class="text-[11px] font-medium text-text-dim"></span><span class="ml-auto tabular-nums text-[10.5px] text-text-faint"></span></div><div class="lg-md text-text text-[12px] leading-relaxed break-words">`),m$=N(`<option>Steer running agent<!> · `),h$=N(`<span class="text-[11px] text-text-dim">`),g$=N(`<p class="text-[12px] text-text leading-relaxed whitespace-pre-wrap break-words">`),_$=N(`<div class="flex flex-col gap-0.5 border-t border-border pt-1.5 mt-0.5">`),v$=N(`<div class="bg-surface border-border rounded-lg border p-2.5 flex flex-col gap-1.5"><div class="flex items-center gap-1.5 flex-wrap"><span class="ml-auto tabular-nums text-[10.5px] text-text-faint">`),y$=N(`<div class="flex items-start gap-1.5"><span class="tabular-nums text-[10px] text-text-faint shrink-0 mt-px"></span><span class="text-[11px] text-text-dim break-words min-w-0">`);function b$(){let[e,t]=T(null);return O(()=>{let e=KA();e&&(t(e),YA())}),(()=>{var n=UQ();return P(n,j(M,{get when(){return e()===null},get fallback(){return j(C$,{get issueId(){return e()},onBack:()=>t(null)})},get children(){return j(x$,{onSelect:e=>t(e)})}})),n})()}function x$(e){let t,n=_r(()=>({queryKey:[`my-issues`],queryFn:uO,refetchInterval:12e3})),r=k(()=>n.data??[]),i=CQ({get count(){return r().length},getScrollElement:()=>t,estimateSize:()=>56,overscan:5});return(()=>{var a=JQ(),o=a.firstChild.firstChild.nextSibling;return P(o,j(M,{get when(){return n.dataUpdatedAt>0},get children(){var e=WQ();return e.firstChild,P(e,()=>Oj(n.dataUpdatedAt),null),e}}),null),P(o,j(hj,{class:`size-7 px-0`,get loading(){return n.isFetching},onClick:()=>void n.refetch(),title:`Refresh`,"aria-label":`Refresh issues`,get children(){return GQ()}}),null),P(a,j(M,{get when(){return n.isError},get children(){var e=KQ();return P(e,j(Tj,{title:`Connect Linear in Settings`,get children(){return n.error?.message??`Unable to load issues.`}})),e}}),null),P(a,j(M,{get when(){return $e(()=>!n.isError&&!n.isPending)()&&r().length===0},get children(){var e=KQ();return P(e,j(Tj,{title:`No issues found`,children:`Issues you create will appear here.`})),e}}),null),P(a,j(M,{get when(){return $e(()=>!n.isError)()&&r().length>0},get children(){var n=qQ(),a=n.firstChild,o=t;return typeof o==`function`?pt(o,n):t=n,P(a,j(We,{get each(){return i.getVirtualItems()},children:t=>{let n=k(()=>r()[t.index]);return(()=>{var r=YQ();return P(r,j(S$,{get issue(){return n()},get onSelect(){return e.onSelect}})),D(e=>dt(r,`transform`,`translateY(${t.start}px)`)),r})()}})),D(e=>dt(a,`height`,`${i.getTotalSize()}px`)),n}}),null),a})()}function S$(e){return(()=>{var t=XQ(),n=t.firstChild,r=n.firstChild,i=r.nextSibling,a=n.nextSibling,o=a.firstChild;return t.$$click=()=>e.onSelect(e.issue.id),P(n,j(wj,{get color(){return e.issue.state.color}}),r),P(r,()=>e.issue.identifier),P(i,()=>e.issue.title),P(a,j(Cj,{get children(){return e.issue.state.name}}),o),P(a,j(M,{get when(){return e.issue.delegate},get children(){return j(Cj,{class:`text-accent`,get children(){return[`⟠ `,$e(()=>e.issue.delegate.displayName)]}})}}),o),P(a,j(M,{get when(){return $e(()=>!!(e.issue.state.type===`started`&&e.issue.delegate))()&&e.issue.attachments?.some(e=>/github\.com\/[^/]+\/[^/]+\/pull\/\d+/i.test(e.url))},get children(){return j(Cj,{color:`var(--color-warn)`,children:`needs review`})}}),o),P(o,()=>Oj(e.issue.updatedAt)),t})()}function C$(e){let t=sr(),n=_r(()=>({queryKey:[`issue`,e.issueId],queryFn:()=>dO(e.issueId),refetchInterval:8e3,enabled:!!e.issueId})),r=_r(()=>({queryKey:[`sessions`,e.issueId],queryFn:()=>fO(e.issueId),refetchInterval:8e3,enabled:!!e.issueId})),i=_r(()=>({queryKey:[`settings`],queryFn:Cr})),a=_r(()=>({queryKey:[`bridge-tasks`],queryFn:DO,refetchInterval:5e3,retry:0})),o=k(()=>{let e=n.data?.identifier;return e?a.data?.find(t=>t.title.startsWith(e)):void 0}),s=e=>e.status===`running`?{word:`Working…`,cls:`text-accent`}:e.status===`done`?{word:`Finished`,cls:`text-success`}:e.status===`stopped`?{word:`Stopped`,cls:`text-warn`}:{word:`Error`,cls:`text-danger`},[c,l]=T(``),[u,d]=T(null),[f,p]=T(0),m=_r(()=>({queryKey:[`grab`],queryFn:Tr,enabled:XA()===`composer`})),h=()=>{p(Date.now()),QA(`composer`),AZ().catch(()=>QA(`capture`))};O(()=>{if(XA()!==`composer`)return;let e=(m.data??[]).filter(e=>e.grabbedAt>=f());if(!e.length)return;let t=e.map(e=>{let t=e.source?.filePath?` — \`${e.source.filePath}${e.source.lineNumber==null?``:`:${e.source.lineNumber}`}\``:``;return`- \`<${e.componentName??e.tagName??`element`}>\`${t}`}).join(`
|
|
218
218
|
`);l(e=>`${e?`${e}\n`:``}${t}\n`),QA(`capture`)});let[g,_]=T(null),[v,y]=T(new Set),[b,x]=T(null),S=async n=>{x(null),_(n);try{await IO(n),y(e=>new Set(e).add(n)),t.invalidateQueries({queryKey:[`issue`,e.issueId]}),t.invalidateQueries({queryKey:[`my-issues`]}),AQ()}catch(e){x(e instanceof Error?`${e.message} (bridge must be running; gh needs merge rights)`:`Merge failed.`)}finally{_(null)}},C=k(()=>n.data?yO(n.data.comments):[]),[w,E]=T(`comment`),ee=!1;O(()=>{if(ee||!n.data||!i.data)return;ee=!0;let e=C();e.length?E(`thread:${e[0].id}`):n.data.delegate&&i.data.cursorAgentId&&E(`new`)});let te=vr(()=>({mutationFn:async()=>{let t=c().trim();if(!t)throw Error(`Message is empty`);let n=i.data??{},r=w();r.startsWith(`thread:`)?await _O(e.issueId,t,r.slice(7)):r===`new`&&n.cursorAgentId?await vO(e.issueId,t,{name:n.cursorAgentName,displayName:n.cursorAgentName??`Cursor`,url:n.cursorAgentUrl}):await _O(e.issueId,t)},onSuccess:()=>{l(``),d(null),t.invalidateQueries({queryKey:[`issue`,e.issueId]}),AQ()},onError:e=>{d(e.message??`Failed to send`)}})),A=k(()=>n.data),ne=k(()=>r.data??[]);return(()=>{var t=l$(),r=t.firstChild,a=r.firstChild,d=r.nextSibling,f=d.nextSibling,p=f.firstChild;return P(a,j(hj,{class:`min-w-[68px] shrink-0 text-[11px]`,get onClick(){return e.onBack},get children(){return ZQ()}}),null),P(a,j(M,{get when(){return A()},get children(){return[(()=>{var e=QQ();return P(e,()=>A().identifier),e})(),(()=>{var e=$Q();return P(e,()=>A().title),e})()]}}),null),P(a,j(M,{get when(){return $e(()=>!!n.isPending)()&&!A()},get children(){return e$()}}),null),P(r,j(M,{get when(){return A()},get children(){var e=t$(),t=e.firstChild;return P(e,j(wj,{get color(){return A().state.color}}),t),P(t,()=>A().state.name),P(e,j(bj,{get href(){return A().url},class:`ml-auto shrink-0`,children:`Open in Linear`}),null),e}}),null),P(d,j(M,{get when(){return o()},children:e=>{let t=()=>s(e());return(()=>{var n=u$(),r=n.firstChild,i=r.firstChild.firstChild.nextSibling.nextSibling.nextSibling;i.firstChild;var a=r.nextSibling,o=a.firstChild,s=o.nextSibling;return P(i,()=>Oj(e().startedAt),null),P(r,j(Cj,{get children(){return e().model??`default`}}),null),a.$$click=()=>JA(`local`),P(a,j(M,{get when(){return e().status===`running`},get children(){return j(gj,{size:12})}}),o),P(o,()=>t().word),P(s,(()=>{var t=$e(()=>e().status===`done`);return()=>t()?e().result??e().lastText:e().lastText})()),D(()=>st(o,`shrink-0 text-[11.5px] font-medium ${t().cls}`)),n})()}}),null),P(d,j(M,{get when(){return ne().length>0},get children(){var e=n$();return P(e,j(We,{get each(){return ne()},children:e=>j(w$,{session:e})})),e}}),null),P(d,j(M,{get when(){return $e(()=>!!A())()&&A().attachments.length>0},get children(){var e=r$(),t=e.firstChild.nextSibling;return P(t,j(We,{get each(){return A().attachments},children:e=>{let t=/github\.com\/[^/]+\/[^/]+\/pull\/\d+/i.test(e.url);return(()=>{var n=f$(),r=n.firstChild;return P(r,()=>e.title),P(n,j(M,{when:t,get children(){return j(hj,{variant:`primary`,class:`ml-auto h-6 shrink-0 px-2 text-[11px]`,get loading(){return g()===e.url},get disabled(){return v().has(e.url)},title:`Squash-merge this PR via the bridge's gh — reviewed the demo? Ship it.`,onClick:()=>void S(e.url),get children(){var t=d$();return P(t,()=>v().has(e.url)?`Merged ✓`:`Merge`),t}})}}),null),D(t=>{var n=e.url,i=e.title;return n!==t.e&&it(r,`href`,t.e=n),i!==t.t&&it(r,`title`,t.t=i),t},{e:void 0,t:void 0}),n})()}}),null),P(t,j(M,{get when(){return b()},get children(){return j(Ej,{get message(){return b()}})}}),null),e}}),null),P(d,j(M,{get when(){return $e(()=>!!A())()&&A().comments.length>0},get children(){var e=i$();return e.firstChild,P(e,j(We,{get each(){return A().comments},children:e=>(()=>{var t=p$(),n=t.firstChild,r=n.firstChild,i=r.nextSibling,a=n.nextSibling;return P(r,()=>e.user?.displayName??e.user?.name??`Unknown`),P(n,j(M,{get when(){return e.user?.app},get children(){return j(Cj,{children:`agent`})}}),i),P(i,()=>Oj(e.createdAt)),D(()=>a.innerHTML=HQ(e.body)),t})()}),null),e}}),null),P(d,j(M,{get when(){return $e(()=>!!(A()&&A().comments.length===0))()&&ne().length===0},get children(){return j(Tj,{title:`No activity yet`,children:`Comments and agent sessions will appear here.`})}}),null),P(d,j(M,{get when(){return $e(()=>!!n.isError)()&&!A()},get children(){return j(Tj,{title:`Failed to load issue`,get children(){return n.error?.message??`Unknown error`}})}}),null),P(f,j(M,{get when(){return u()},get children(){return j(Ej,{get message(){return u()}})}}),p),P(f,j(vj,{rows:2,placeholder:`Reply — steer the agent or add context…`,get value(){return c()},onInput:e=>l(e.target.value),get disabled(){return te.isPending}}),p),P(p,j(yj,{class:`min-w-0 flex-1`,get value(){return w()},onChange:e=>E(e.currentTarget.value),get children(){return[j(We,{get each(){return C()},children:(e,t)=>(()=>{var n=m$(),r=n.firstChild.nextSibling;return r.nextSibling,P(n,(()=>{var e=$e(()=>C().length>1);return()=>e()?` #${t()+1}`:``})(),r),P(n,()=>Oj(e.createdAt),null),D(()=>n.selected=w()===`thread:${e.id}`),D(()=>n.value=`thread:${e.id}`),n})()}),j(M,{get when(){return i.data?.cursorAgentId},get children(){var e=a$(),t=e.firstChild.nextSibling;return t.nextSibling,P(e,()=>i.data?.cursorAgentName??`Cursor`,t),D(()=>e.selected=w()===`new`),e}}),(()=>{var e=o$();return D(()=>e.selected=w()===`comment`),e})()]}}),null),P(p,j(hj,{variant:`ghost`,class:`size-7 shrink-0 px-0`,title:`Pick elements on the page — their source refs drop into this reply`,"aria-label":`Pick element for reply`,onClick:h,get children(){return s$()}}),null),P(p,j(hj,{class:`min-w-[52px] shrink-0`,variant:`primary`,get loading(){return te.isPending},get disabled(){return c().trim().length===0},onClick:()=>te.mutate(),get children(){return c$()}}),null),t})()}function w$(e){let t=k(()=>{let t=e.session.status;return/complete|done/i.test(t)?`var(--color-success)`:/await|pending|elicit/i.test(t)?`var(--color-warn)`:`var(--color-accent)`}),n=k(()=>e.session.activities.slice(-10));return(()=>{var r=v$(),i=r.firstChild,a=i.firstChild;return P(i,j(Cj,{get color(){return t()},get children(){return e.session.status}}),a),P(i,j(M,{get when(){return e.session.appUser?.displayName},get children(){var t=h$();return P(t,()=>e.session.appUser.displayName),t}}),a),P(a,()=>Oj(e.session.updatedAt)),P(r,j(M,{get when(){return e.session.summary},get children(){var t=g$();return P(t,()=>e.session.summary),t}}),null),P(r,j(M,{get when(){return n().length>0},get children(){var e=_$();return P(e,j(We,{get each(){return n()},children:e=>{let t=e.content,n=String(t?.body??t?.text??t?.type??JSON.stringify(t)).slice(0,300);return(()=>{var t=y$(),r=t.firstChild,i=r.nextSibling;return P(r,()=>Oj(e.createdAt)),P(i,n),t})()}})),e}}),null),r})()}rt([`click`]);var T$=N(`<div class="border-accent/40 bg-accent-soft self-end rounded-lg border px-2.5 py-1.5"><p class="text-accent mb-0.5 text-[9.5px] font-semibold tracking-wide uppercase">You</p><div class="lg-md text-text text-[11.5px] leading-relaxed break-words">`),E$=N(`<div><p></p><div class="lg-md text-text text-[11.5px] leading-relaxed break-words">`),D$=N(`<p>`),O$=N(`<span class="text-text-faint max-w-[55%] truncate text-[10.5px] tabular-nums"> running · `),k$=N(`<div class="flex flex-col gap-1.5">`),A$=N(`<div class="flex h-full flex-col"><div class="border-border flex shrink-0 items-center justify-between border-b px-3 py-2"><span class="text-text text-[12px] font-semibold">Local Claude Code</span></div><div class="min-h-0 flex-1 overflow-y-auto pt-2 pb-3 pl-2 pr-3">`),j$=N(`<span class="bg-surface-2 border-border font-mono mt-2 block rounded-md border px-2 py-1.5 text-[11px] select-all">npx linear-grab-bridge`),M$=N(`<span class="text-text-faint text-[10.5px] tabular-nums">ctx <!> · out `),N$=N(`<div class="flex min-w-0 items-center gap-1.5"><span class="font-mono text-text-faint min-w-0 truncate text-[10.5px]">`),P$=N(`<span class="text-success text-[12px] leading-none">✓`),F$=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linejoin=round aria-hidden><path d="M14 10a2 2 0 0 1-2 2H6l-3.5 2.5V4a2 2 0 0 1 2-2H12a2 2 0 0 1 2 2v6Z">`),I$=N(`<svg width=11 height=11 viewBox="0 0 16 16"fill=currentColor aria-hidden><rect x=3 y=3 width=10 height=10 rx=1.5>`),L$=N(`<span class="font-mono text-text-faint min-w-0 truncate text-[10.5px]">`),R$=N(`<div class="border-border bg-bg flex flex-col gap-1 rounded-md border p-2"><div class="flex min-w-0 items-center gap-1.5"><span class="text-text-dim text-[10.5px] font-semibold tracking-wide uppercase">Changes</span><span class="ml-auto shrink-0 text-[10.5px] tabular-nums"><span class=text-success>+</span> <span class=text-danger>−`),z$=N(`<div class="border-border bg-bg flex max-h-80 flex-col gap-1.5 overflow-y-auto rounded-md border py-2 pl-2 pr-3">`),B$=N(`<span class="inline-block min-w-[4ch] text-center">Send`),V$=N(`<div class="flex flex-col gap-1.5"><div class="flex items-center justify-between gap-2"><span class="text-text-faint min-w-0 truncate text-[10.5px]">`),H$=N(`<div class="bg-surface border-border flex flex-col gap-1.5 rounded-lg border p-2.5"><div class="flex min-w-0 items-center gap-1.5"><span class="text-text min-w-0 truncate text-[12.5px] font-medium"></span><span class="text-text-faint ml-auto shrink-0 text-[10.5px] tabular-nums"></span></div><p class="text-text-dim text-[11.5px] leading-snug break-words"></p><div class="flex flex-wrap items-center gap-1.5"></div><div class="flex items-center gap-1">`),U$=N(`<span aria-hidden class="size-2 shrink-0 rounded-full">`),W$=N(`<div class="flex min-w-0 items-center gap-1.5">`),G$=N(`<option>`),K$=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 aria-hidden><circle cx=8 cy=8 r=6></circle><circle cx=8 cy=8 r=1.6 fill=currentColor stroke=none>`),q$=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round aria-hidden><path d="M2.5 3.5 6 7 2.5 10.5M7.5 12.5h6">`),J$=N(`<span class=text-success>+`),Y$=N(`<span class=text-danger>−`),X$=N(`<div class="flex min-w-0 items-center gap-1.5"><span class="font-mono text-text-dim min-w-0 flex-1 truncate text-[10.5px]"></span><span class="shrink-0 text-[10px] tabular-nums">`),Z$=N(`<span class=text-text-faint>bin`),Q$=N(`<div class="flex min-w-0 items-center gap-1.5"><span class="font-mono text-text-dim min-w-0 flex-1 truncate text-[10.5px]"></span><span class="text-success shrink-0 text-[10px]">new`),$$=N(`<div class="flex min-w-0 items-center gap-1.5 pt-0.5"><a target=_blank rel=noreferrer class="text-accent min-w-0 truncate text-[11px] hover:underline">`),e1=N(`<p class="text-text-faint text-[11px]">Waiting for output…`),t1=[{id:``,label:`Default model`},{id:`fable`,label:`Fable 5`},{id:`opus`,label:`Opus`},{id:`sonnet`,label:`Sonnet`},{id:`haiku`,label:`Haiku`}],n1=e=>e==null?`–`:e>=1e3?`${(e/1e3).toFixed(e>=1e5?0:1)}k`:String(e);function r1(){let e=sr(),t=_r(()=>({queryKey:[`bridge-health`],queryFn:EO,refetchInterval:5e3,retry:0})),n=_r(()=>({queryKey:[`bridge-tasks`],queryFn:DO,refetchInterval:3e3,enabled:!!t.data?.ok})),[r,i]=T(null),a=_r(()=>({queryKey:[`my-issues`],queryFn:uO,staleTime:15e3})),o=e=>{let t=e.title.match(/^([A-Z][A-Z0-9]*-\d+)/)?.[1];return t?a.data?.find(e=>e.identifier===t):void 0},s=_r(()=>({queryKey:[`bridge-task`,r()],queryFn:()=>OO(r()),refetchInterval:1500,enabled:!!r()&&!!t.data?.ok})),c=_r(()=>({queryKey:[`bridge-diff`,r()],queryFn:()=>PO(r()),refetchInterval:6e3,enabled:!!r()&&!!t.data?.ok})),l=()=>{e.invalidateQueries({queryKey:[`bridge-tasks`]}),e.invalidateQueries({queryKey:[`bridge-task`,r()]})},u=vr(()=>({mutationFn:e=>MO(e),onSuccess:l})),[d,f]=T(``),p=vr(()=>({mutationFn:e=>AO(e.id,e.text),onSuccess:()=>{f(``),l()}})),m=vr(()=>({mutationFn:e=>jO(e.id,e.model),onSuccess:l})),h=vr(()=>({mutationFn:e=>NO(e),onSuccess:l})),g,_=!0,v=()=>{g&&(_=g.scrollTop+g.clientHeight>=g.scrollHeight-48)};O(()=>{let e=s.data?.tail?.length??0;r(),!(!g||!e||!_)&&requestAnimationFrame(()=>{g&&(g.scrollTop=g.scrollHeight)})});let[y,b]=T(null),x=async e=>{try{await navigator.clipboard.writeText(RO(e)),b(e.id),setTimeout(()=>b(null),1800)}catch{}},S=e=>e===`running`?`var(--color-accent)`:e===`done`?`var(--color-success)`:e===`stopped`?`var(--color-warn)`:`var(--color-danger)`,C=e=>{let t=e.line.kind;return t===`user`?(()=>{var t=T$(),n=t.firstChild.nextSibling;return D(()=>n.innerHTML=HQ(e.line.text)),t})():t===`assistant`||t===`result`?(()=>{var n=E$(),r=n.firstChild,i=r.nextSibling;return st(n,`bg-surface rounded-lg border px-2.5 py-1.5 ${t===`result`?`border-success/40`:`border-border`}`),st(r,`mb-0.5 text-[9.5px] font-semibold tracking-wide uppercase ${t===`result`?`text-success`:`text-text-faint`}`),P(r,t===`result`?`Result`:`Claude`),D(()=>i.innerHTML=HQ(e.line.text)),n})():(()=>{var n=D$();return st(n,`font-mono px-1 text-[10px] leading-relaxed break-words ${t===`subagent`?`text-warn`:t===`stderr`?`text-danger`:`text-text-faint`}`),P(n,()=>e.line.text),n})()};return(()=>{var e=A$(),a=e.firstChild;a.firstChild;var l=a.nextSibling;return P(a,j(M,{get when(){return t.data?.ok},get fallback(){return j(Cj,{class:`text-danger`,children:`bridge offline`})},get children(){var e=O$(),n=e.firstChild;return P(e,()=>t.data.active,n),P(e,()=>t.data.cwd.split(`/`).slice(-2).join(`/`),null),D(()=>it(e,`title`,t.data?.cwd)),e}}),null),P(l,j(M,{get when(){return t.data?.ok},get fallback(){return j(Tj,{title:`Bridge not running`,get children(){return[`Start it in your repo's terminal:`,j$(),`Then delegate from the Draft tab ("Local Claude Code") or watch tasks here. Sessions stay interactive — send follow-ups, switch models, interrupt, resume in your terminal. History persists across restarts.`]}})},get children(){return j(M,{get when(){return(n.data??[]).length>0},get fallback(){return j(Tj,{title:`No local tasks yet`,children:`Create an issue in Draft with "Delegate to → Local Claude Code", and it appears here with live status and a conversation view.`})},get children(){var e=k$();return P(e,j(We,{get each(){return n.data},children:e=>(()=>{var t=H$(),n=t.firstChild,a=n.firstChild,l=a.nextSibling,b=n.nextSibling,w=b.nextSibling,T=w.nextSibling;return P(n,j(M,{get when(){return e.status===`running`},get fallback(){return(()=>{var t=U$();return D(n=>dt(t,`background`,S(e.status))),t})()},get children(){return j(gj,{})}}),a),P(a,()=>e.title),P(l,()=>Oj(e.startedAt)),P(b,()=>e.lastText),P(w,j(Cj,{get color(){return S(e.status)},get children(){return e.status}}),null),P(w,j(Cj,{get children(){return e.model??`default model`}}),null),P(w,j(M,{get when(){return e.pendingModel},get children(){return j(Cj,{class:`text-warn`,get children(){return[`→ `,$e(()=>e.pendingModel),` next msg`]}})}}),null),P(w,j(M,{get when(){return e.subagents>0},get children(){return j(Cj,{class:`text-warn`,get children(){return[`⛓ `,$e(()=>e.subagents),` subagents`]}})}}),null),P(w,j(M,{get when(){return e.usage},get children(){var t=M$(),n=t.firstChild.nextSibling;return n.nextSibling,P(t,()=>n1(e.usage.contextTokens),n),P(t,()=>n1(e.usage.outputTokens),null),P(t,(()=>{var t=$e(()=>!!e.usage.costUsd);return()=>t()?` · $${e.usage.costUsd.toFixed(2)}`:``})(),null),t}}),null),P(t,j(M,{get when(){return o(e)},children:e=>(()=>{var t=W$();return P(t,j(Cj,{get children(){return e().state.name}}),null),P(t,j(bj,{get href(){return e().url},children:`Open in Linear`}),null),t})()}),T),P(t,j(M,{get when(){return $e(()=>!!e.worktree)()&&!e.worktree.removed},get children(){var t=N$(),n=t.firstChild;return P(t,j(Cj,{class:`text-warn`,children:`⎇ worktree`}),n),P(n,()=>e.worktree.branch),P(t,j(M,{get when(){return e.status!==`running`},get children(){return j(hj,{variant:`ghost`,class:`ml-auto h-6 shrink-0 px-2 text-[11px]`,get loading(){return h.isPending},get title(){return`Remove the worktree at ${e.worktree.path} — the branch (and PR) survive`},onClick:()=>h.mutate(e.id),children:`Remove`})}}),null),D(()=>it(n,`title`,e.worktree.path)),t}}),T),P(T,j(yj,{class:`h-7 w-auto min-w-0 flex-1 text-[11px]`,get value(){return e.pendingModel??e.model??``},onChange:t=>m.mutate({id:e.id,model:t.currentTarget.value}),title:`Model — applies from the next message`,get children(){return j(We,{each:t1,children:t=>(()=>{var n=G$();return P(n,()=>t.label),D(()=>n.selected=(e.pendingModel??e.model??``)===t.id),D(()=>n.value=t.id),n})()})}}),null),P(T,j(M,{get when(){return o(e)},children:e=>j(hj,{variant:`ghost`,class:`size-7 px-0`,title:`Open the issue's Activity thread`,onClick:()=>JA(`activity`,e().id),get children(){return K$()}})}),null),P(T,j(hj,{variant:`ghost`,class:`size-7 px-0`,get disabled(){return!e.sessionId},get title(){return $e(()=>!!e.sessionId)()?`Copy resume command · session ${e.sessionId.slice(0,8)}…`:`No session yet`},onClick:()=>void x(e),get children(){return j(M,{get when(){return y()===e.id},get fallback(){return q$()},get children(){return P$()}})}}),null),P(T,j(hj,{variant:`ghost`,class:`size-7 px-0`,get title(){return r()===e.id?`Hide thread`:`Open thread — chat & changes`},onClick:()=>i(r()===e.id?null:e.id),get children(){return F$()}}),null),P(T,j(M,{get when(){return e.status===`running`},get children(){return j(hj,{variant:`danger`,class:`size-7 px-0`,get loading(){return u.isPending},title:`Interrupt — the session stays resumable`,onClick:()=>u.mutate(e.id),get children(){return I$()}})}}),null),P(t,j(M,{get when(){return r()===e.id},get children(){return[j(M,{get when(){return $e(()=>!!c.data)()&&(c.data.files.length||c.data.untracked.length||c.data.prs.length)},get children(){var e=R$(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.firstChild;r.firstChild;var i=r.nextSibling.nextSibling;return i.firstChild,P(t,j(M,{get when(){return c.data.branch},get children(){var e=L$();return P(e,()=>c.data.branch),e}}),n),P(r,()=>c.data.totalAdded,null),P(i,()=>c.data.totalDeleted,null),P(e,j(We,{get each(){return c.data.files},children:e=>(()=>{var t=X$(),n=t.firstChild,r=n.nextSibling;return P(n,()=>e.path),P(r,j(M,{get when(){return!e.binary},get fallback(){return Z$()},get children(){return[(()=>{var t=J$();return t.firstChild,P(t,()=>e.added,null),t})(),` `,(()=>{var t=Y$();return t.firstChild,P(t,()=>e.deleted,null),t})()]}})),D(()=>it(n,`title`,e.path)),t})()}),null),P(e,j(We,{get each(){return c.data.untracked},children:e=>(()=>{var t=Q$(),n=t.firstChild;return it(n,`title`,e),P(n,e),t})()}),null),P(e,j(We,{get each(){return c.data.prs},children:e=>(()=>{var t=$$(),n=t.firstChild;return P(t,j(Cj,{class:`text-accent`,get children(){return[`PR · `,$e(()=>e.state.toLowerCase())]}}),n),P(n,()=>e.title),D(t=>{var r=e.url,i=e.title;return r!==t.e&&it(n,`href`,t.e=r),i!==t.t&&it(n,`title`,t.t=i),t},{e:void 0,t:void 0}),t})()}),null),e}}),(()=>{var e=z$();return e.addEventListener(`scroll`,v),pt(e=>{g=e,_=!0},e),P(e,j(M,{get when(){return(s.data?.tail??[]).length>0},get fallback(){return e1()},get children(){return j(Ge,{get each(){return s.data?.tail??[]},children:e=>j(C,{get line(){return e()}})})}})),e})(),(()=>{var t=V$(),n=t.firstChild,r=n.firstChild;return P(t,j(vj,{rows:2,get placeholder(){return e.status===`running`?`Message the working agent — it queues into the live session…`:`Follow-up — resumes the session…`},get value(){return d()},onInput:e=>f(e.currentTarget.value)}),n),P(r,(()=>{var t=$e(()=>!!e.alive);return()=>t()?`live session`:e.sessionId?`resumes on send`:`no session`})()),P(n,j(hj,{variant:`primary`,class:`shrink-0`,get loading(){return p.isPending},get disabled(){return!d().trim()||!e.alive&&!e.sessionId},onClick:()=>p.mutate({id:e.id,text:d().trim()}),get children(){return B$()}}),null),t})()]}}),null),t})()})),e}})}})),e})()}var i1=N(`<div class="flex flex-col gap-1.5">`),a1=N(`<div class="flex h-full flex-col"><div class="border-border flex shrink-0 items-center justify-between border-b px-3 py-2"><span class="text-text text-[12px] font-semibold">Pull requests</span><span class="text-text-faint text-[10.5px] tabular-nums">/<!> from your issues</span></div><div class="border-border flex shrink-0 items-center gap-1.5 border-b px-3 py-1.5"><div class="bg-surface-2 border-border flex shrink-0 rounded-md border p-0.5"></div></div><div class="min-h-0 flex-1 overflow-y-auto pt-2 pb-3 pl-2 pr-3">`),o1=N(`<button>`),s1=N(`<span class="text-[12px] leading-none">✓`),c1=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><circle cx=8 cy=8 r=6></circle><circle cx=8 cy=8 r=1.6 fill=currentColor stroke=none>`),l1=N(`<span class="text-success text-[12px] leading-none">✓`),u1=N(`<div class="bg-surface border-border flex flex-col gap-1.5 rounded-lg border p-2.5"><a target=_blank rel=noreferrer class="text-accent truncate text-[12.5px] font-medium hover:underline"></a><div class="flex min-w-0 items-center gap-1.5"><span class="font-mono text-text-dim shrink-0 text-[11px]"></span><span class="text-text-dim truncate text-[11.5px]"></span><span class="text-text-faint ml-auto shrink-0 text-[10.5px] tabular-nums"></span></div><div class="flex min-w-0 flex-wrap items-center gap-1.5"><div class="ml-auto flex shrink-0 items-center gap-1">`),d1=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden><circle cx=4 cy=3.5 r=1.5></circle><circle cx=4 cy=12.5 r=1.5></circle><circle cx=12 cy=8 r=1.5></circle><path d="M4 5v6M4 6.5c0 2 2 3 4.5 3h2">`),f1=N(`<svg width=13 height=13 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=1.5 stroke-linejoin=round aria-hidden><rect x=5.5 y=5.5 width=9 height=9 rx=1.5></rect><path d="M10.5 5.5v-2a2 2 0 0 0-2-2h-5a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h2">`),p1=/github\.com\/[^/]+\/[^/]+\/pull\/\d+/i;function m1(e){let t=_r(()=>({queryKey:[`my-issues`],queryFn:uO,refetchInterval:15e3})),n=k(()=>(t.data??[]).flatMap(e=>(e.attachments??[]).filter(e=>p1.test(e.url)).map(t=>({issue:e,attachment:t})))),r=_r(()=>({queryKey:[`bridge-tasks`],queryFn:DO,refetchInterval:1e4,retry:0})),i=e=>!!r.data?.some(t=>t.title.startsWith(e.issue.identifier)),[a,o]=T(`all`),[s,c]=T(``),l=k(()=>{let e=s().trim().toLowerCase();return n().filter(t=>{let n=t.issue.state.type;return!(a()===`review`&&n!==`started`||a()===`open`&&!(n===`started`||n===`unstarted`||n===`backlog`)||a()===`done`&&n!==`completed`||e&&![t.attachment.title,t.issue.title,t.issue.identifier].join(` `).toLowerCase().includes(e))})}),[u,d]=T(null),[f,p]=T(null),[m,h]=T(new Set),g=async e=>{p(e);try{await IO(e),h(t=>new Set(t).add(e))}catch{}finally{p(null)}},_=async e=>{try{await navigator.clipboard.writeText(e.attachment.url),d(e.attachment.id),setTimeout(()=>d(null),1500)}catch{}};return(()=>{var r=a1(),d=r.firstChild,p=d.firstChild.nextSibling,h=p.firstChild,v=h.nextSibling;v.nextSibling;var y=d.nextSibling,b=y.firstChild,x=y.nextSibling;return P(p,()=>l().length,h),P(p,()=>n().length,v),P(b,j(We,{each:[{id:`all`,label:`All`},{id:`review`,label:`Review`},{id:`open`,label:`Open`},{id:`done`,label:`Done`}],children:e=>(()=>{var t=o1();return t.$$click=()=>o(e.id),P(t,()=>e.label),D(()=>st(t,`rounded-[5px] px-2 py-0.5 text-[11px] font-medium transition-colors ${a()===e.id?`bg-surface-3 text-text`:`text-text-dim hover:text-text cursor-pointer`}`)),t})()})),P(y,j(_j,{class:`h-6 min-w-0 flex-1 text-[11px]`,placeholder:`Search PRs…`,get value(){return s()},onInput:e=>c(e.currentTarget.value)}),null),P(x,j(M,{get when(){return l().length>0},get fallback(){return j(Tj,{title:`No PRs yet`,get children(){return $e(()=>!!t.isError)()?`Connect Linear in Settings.`:n().length>0?`No PRs match the current filter.`:`PRs opened by delegated agents appear here as soon as they link back to your issues.`}})},get children(){var t=i1();return P(t,j(We,{get each(){return l()},children:t=>(()=>{var n=u1(),r=n.firstChild,a=r.nextSibling,o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=a.nextSibling,d=l.firstChild;return P(r,()=>t.attachment.title||t.attachment.url),P(a,j(wj,{get color(){return t.issue.state.color}}),o),P(o,()=>t.issue.identifier),P(s,()=>t.issue.title),P(c,()=>Oj(t.issue.updatedAt)),P(l,j(Cj,{get children(){return t.issue.state.name}}),d),P(l,j(M,{get when(){return t.issue.delegate},get children(){return j(Cj,{class:`text-accent`,get children(){return[`☁ `,$e(()=>t.issue.delegate.displayName)]}})}}),d),P(l,j(M,{get when(){return i(t)},get children(){return j(Cj,{class:`text-warn`,children:`🖥 local`})}}),d),P(l,j(bj,{get href(){return t.issue.url},class:`shrink-0`,title:`Open the issue in Linear`,children:`Linear`}),d),P(d,j(hj,{variant:`primary`,class:`size-7 px-0`,get loading(){return f()===t.attachment.url},get disabled(){return m().has(t.attachment.url)},get title(){return m().has(t.attachment.url)?`Merged`:`Squash-merge this PR (bridge gh)`},"aria-label":`Merge PR`,onClick:()=>void g(t.attachment.url),get children(){return j(M,{get when(){return m().has(t.attachment.url)},get fallback(){return d1()},get children(){return s1()}})}}),null),P(d,j(hj,{variant:`ghost`,class:`size-7 px-0`,title:`Open the issue's Activity thread`,"aria-label":`Open issue activity`,onClick:()=>{JA(`activity`,t.issue.id),e.onOpenIssue()},get children(){return c1()}}),null),P(d,j(hj,{variant:`ghost`,class:`size-7 px-0`,title:`Copy PR URL`,"aria-label":`Copy PR URL`,onClick:()=>void _(t),get children(){return j(M,{get when(){return u()===t.attachment.id},get fallback(){return f1()},get children(){return l1()}})}}),null),D(e=>{var n=t.attachment.url,i=t.attachment.title;return n!==e.e&&it(r,`href`,e.e=n),i!==e.t&&it(r,`title`,e.t=i),e},{e:void 0,t:void 0}),n})()})),t}})),r})()}rt([`click`]),Rr();function h1(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}async function g1(e){let t=h1(crypto.getRandomValues(new Uint8Array(32))),n=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t)),r=h1(new Uint8Array(n)),i=h1(crypto.getRandomValues(new Uint8Array(16))),a=chrome.identity.getRedirectURL(),o=new URL(`https://linear.app/oauth/authorize`);o.searchParams.set(`client_id`,e),o.searchParams.set(`redirect_uri`,a),o.searchParams.set(`response_type`,`code`),o.searchParams.set(`scope`,`read,write`),o.searchParams.set(`state`,i),o.searchParams.set(`code_challenge`,r),o.searchParams.set(`code_challenge_method`,`S256`);let s=await chrome.identity.launchWebAuthFlow({url:o.toString(),interactive:!0});if(!s)throw Error(`OAuth flow was cancelled`);let c=new URL(s).searchParams;if(c.get(`state`)!==i)throw Error(`OAuth state mismatch`);let l=c.get(`code`);if(!l)throw Error(c.get(`error_description`)??`No authorization code returned`);let u=await fetch(`https://api.linear.app/oauth/token`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({grant_type:`authorization_code`,code:l,redirect_uri:a,client_id:e,code_verifier:t})}),d=await u.json().catch(()=>null);if(!u.ok||!d?.access_token)throw Error(`Token exchange failed — check the OAuth app callback URL and client id`);await wr({linearAccessToken:d.access_token,linearOauthClientId:e})}async function _1(){await wr({linearAccessToken:void 0,linearApiKey:void 0})}Rr(),br(),Nx(),mD();var v1=N(`<div class="bg-surface-2 border-border flex rounded-md border p-0.5">`),y1=N(`<span class="text-text-faint text-[10.5px] leading-snug">Cloud: picking an element opens the panel to draft & delegate to the Cursor agent. Local (react-grab style): picking auto-copies the element's context — source, stack, and your skills/memory paths — straight to the clipboard for a local Claude Code or Cursor session; the panel stays out of the way. Both share the same picker; switch anytime.`),b1=N(`<label class="flex cursor-pointer items-center gap-2 select-none"><input type=checkbox class="accent-accent rounded"><span class="text-text text-[12px]">Element screenshots`),x1=N(`<span class="text-text-faint text-[10.5px] leading-snug">Captures a highlighted screenshot of each picked element and attaches it to the issue. Costs a beat on huge pages — with this off, picking is instant (pure react-grab speed).`),S1=N(`<span class=text-text>Connected as <span class=font-medium></span> · <span class=text-text-dim>`),C1=N(`<div class="bg-surface border-border flex items-center justify-between rounded-lg border p-2.5"><span class="text-text text-[12px]">`),w1=N(`<option value>Select a team…`),T1=N(`<p class="text-text-dim text-[11px]">No agents found — install the Cursor integration in Linear first.`),E1=N(`<span class="text-text-faint text-[10.5px] leading-snug">Empty = the default above (computer-use testing, video demo, PR + review babysitting).`),D1=N(`<div class="flex flex-col gap-1.5">`),O1=N(`<div class="flex flex-col gap-1"><span class="text-text-dim text-[11px] font-medium">Mode</span><div class="bg-surface-2 border-border flex rounded-md border p-0.5"></div><span class="text-text-faint text-[10.5px] leading-snug">Beside page squeezes the app next to the panel, DevTools-style — nothing gets covered. Also toggleable from the dock icon in the panel header.`),k1=N(`<div class="flex flex-col gap-1"><span class="text-text-dim text-[11px] font-medium">Dock side</span><div class="bg-surface-2 border-border flex rounded-md border p-0.5"></div><span class="text-text-faint text-[10.5px] leading-snug">The launcher pill is draggable — park it anywhere it doesn't cover your app.`),A1=N(`<option value>Select a channel…`),j1=N(`<label class="flex cursor-pointer items-center gap-2 select-none"><input type=checkbox class="accent-accent rounded"><span class="text-text text-[12px]">Announce new issues on create`),M1=N(`<span class="text-text-faint text-[10.5px] leading-snug">⚠️ Tokens are embedded in issue Agent-instructions so agents can post the finished demo — everyone who can read the issue can read them. Use single-channel-scoped bots.`),N1=N(`<div class="flex flex-col gap-1"><span class="text-text-dim text-[11px] font-medium">Provider preference</span><div class="bg-surface-2 border-border flex rounded-md border p-0.5"><button>Auto</button><button>OpenAI</button><button>Anthropic`),P1=N(`<p class="text-text-dim text-[11px]">`),F1=N(`<div class=min-h-[2lh]>`),I1=N(`<ol class="text-text-faint flex list-decimal flex-col gap-1 pl-4 text-[11px] leading-relaxed"><li>Pick an element on your running dev app.</li><li>Draft the issue (AI optional).</li><li>Create + delegate — Cursor's cloud agent fixes it and opens a PR.</li><li>Track and steer it from Activity.`),L1=N(`<div class="flex h-full flex-col gap-5 overflow-y-auto pt-3 pb-6 pl-3 pr-4">`),R1=N(`<button>`),z1=N(`<div class="flex gap-1.5">`),B1=N(`<p class="text-text-faint text-center text-[10.5px]">or`),V1=N(`<span class="text-text-faint text-[10.5px] leading-snug">Register this callback URL in your Linear OAuth app config:<br><span class="font-mono text-[10.5px] break-all">`),H1=N(`<div class="flex flex-col gap-3">`),U1=N(`<span class=text-text-dim>Connected — verifying…`),W1=N(`<option> (<!>)`),G1=N(`<option value>Select the agent…`),K1=N(`<option>`),q1=N(`<option>#`),J1=N(`<p class="text-text-dim text-[11px]">No key set — AI drafting disabled, manual drafting still works.`);function Y1(){let e=sr(),t=_r(()=>({queryKey:[`settings`],queryFn:Cr,staleTime:0})),n=k(()=>t.data??{});async function r(t,n=!1){await wr(t),await e.invalidateQueries({queryKey:[`settings`]}),n&&(await e.invalidateQueries({queryKey:[`viewer`]}),await e.invalidateQueries({queryKey:[`teams`]}),await e.invalidateQueries({queryKey:[`agents`]}),await e.invalidateQueries({queryKey:[`my-issues`]}))}let i=k(()=>!!(n().linearApiKey||n().linearAccessToken)),a=_r(()=>({queryKey:[`viewer`],queryFn:sO,enabled:i(),retry:0})),o=_r(()=>({queryKey:[`teams`],queryFn:cO,enabled:i()})),s=_r(()=>({queryKey:[`agents`],queryFn:lO,enabled:i()})),[c,l]=T(``),[u,d]=T(!1),[f,p]=T(``);async function m(){let e=c().trim();if(e){d(!0),p(``);try{await r({linearApiKey:e},!0),await sO(),l(``)}catch{p(`Key rejected — could not verify. Check the key and try again.`),await r({linearApiKey:void 0},!0)}finally{d(!1)}}}let[h,g]=T(``),[_,v]=T(!1),[y,b]=T(``);async function x(){let t=(h()||n().linearOauthClientId||``).trim();if(!t){b(`Enter an OAuth client ID first.`);return}v(!0),b(``);try{await g1(t),await e.invalidateQueries({queryKey:[`settings`]}),await e.invalidateQueries({queryKey:[`viewer`]}),await e.invalidateQueries({queryKey:[`teams`]}),await e.invalidateQueries({queryKey:[`agents`]}),await e.invalidateQueries({queryKey:[`my-issues`]})}catch(e){b(e instanceof Error?e.message:`OAuth flow failed.`)}finally{v(!1)}}let[S,C]=T(!1);async function w(){C(!0);try{await _1(),await e.invalidateQueries({queryKey:[`settings`]}),await e.invalidateQueries({queryKey:[`viewer`]}),await e.invalidateQueries({queryKey:[`teams`]}),await e.invalidateQueries({queryKey:[`agents`]}),await e.invalidateQueries({queryKey:[`my-issues`]})}finally{C(!1)}}let E=yr?chrome.identity.getRedirectURL():null,O=_r(()=>({queryKey:[`slack-channels`,n().slackToken],queryFn:()=>UO(n().slackToken),enabled:!!n().slackToken,retry:0,staleTime:6e4})),ee=k(()=>Ox(n())),te=k(()=>{let e=ee();return e?`Drafting with ${e} — ${jx[e].fast} (fast) / ${jx[e].best} (best)`:null});return(()=>{var e=L1();return P(e,j(Sj,{title:`Workflow`,get children(){return[(()=>{var e=v1();return P(e,j(We,{each:[{id:`cloud`,label:`Cloud · Linear + Cursor`},{id:`local`,label:`Local · clipboard`}],children:e=>(()=>{var t=R1();return t.$$click=()=>void r({workflowMode:e.id}),P(t,()=>e.label),D(()=>st(t,`flex-1 rounded-[5px] px-2 py-1 text-[11.5px] font-medium transition-colors ${(n().workflowMode??`cloud`)===e.id?`bg-surface-3 text-text`:`text-text-dim hover:text-text cursor-pointer`}`)),t})()})),e})(),y1()]}}),null),P(e,j(Sj,{title:`Capture`,get children(){return[(()=>{var e=b1(),t=e.firstChild;return t.addEventListener(`change`,e=>void r({captureShots:e.currentTarget.checked||void 0})),D(()=>t.checked=!!n().captureShots),e})(),x1()]}}),null),P(e,j(Sj,{title:`Linear`,get children(){return j(M,{get when(){return i()},get fallback(){return(()=>{var e=H1();return P(e,j(xj,{label:`Personal API key`,hint:`Create one at linear.app → Settings → API — fastest path.`,get children(){return[(()=>{var e=z1();return P(e,j(_j,{type:`password`,placeholder:`lin_api_…`,get value(){return c()},onInput:e=>l(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&m()}}),null),P(e,j(hj,{variant:`primary`,get loading(){return u()},get disabled(){return!c().trim()},onClick:()=>void m(),class:`shrink-0`,children:`Connect`}),null),e})(),j(M,{get when(){return f()},get children(){return j(Ej,{get message(){return f()}})}})]}}),null),P(e,j(M,{when:yr,get children(){return[B1(),j(xj,{label:`OAuth client ID`,get children(){return[(()=>{var e=z1();return P(e,j(_j,{placeholder:`your-client-id`,get value(){return h()||n().linearOauthClientId||``},onInput:e=>g(e.currentTarget.value)}),null),P(e,j(hj,{variant:`ghost`,get loading(){return _()},onClick:()=>void x(),class:`shrink-0 whitespace-nowrap`,children:`Connect with OAuth`}),null),e})(),j(M,{get when(){return y()},get children(){return j(Ej,{get message(){return y()}})}}),(()=>{var e=V1(),t=e.firstChild.nextSibling.nextSibling;return P(t,E),e})()]}})]}}),null),e})()},get children(){var e=C1(),t=e.firstChild;return P(t,j(M,{get when(){return!a.isLoading},get fallback(){return U1()},get children(){return j(M,{get when(){return a.data},get fallback(){return j(M,{get when(){return a.isError},get fallback(){return U1()},get children(){return j(Ej,{message:`Key rejected — reconnect`})}})},get children(){var e=S1(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling;return P(t,()=>a.data.name),P(n,()=>a.data.email),e}})}})),P(e,j(hj,{variant:`ghost`,get loading(){return S()},onClick:()=>void w(),class:`ml-2 shrink-0`,children:`Disconnect`}),null),e}})}}),null),P(e,j(M,{get when(){return i()},get children(){return j(Sj,{title:`Workspace`,get children(){return[j(xj,{label:`Default team`,get children(){return j(yj,{get value(){return n().defaultTeamId??``},onChange:e=>{let t=e.currentTarget.value;r({defaultTeamId:t||void 0})},get disabled(){return o.isLoading},get children(){return[w1(),j(M,{get when(){return o.data},get children(){return j(We,{get each(){return o.data},children:e=>(()=>{var t=W1(),r=t.firstChild,i=r.nextSibling;return i.nextSibling,P(t,()=>e.name,r),P(t,()=>e.key,i),D(()=>t.selected=e.id===n().defaultTeamId),D(()=>t.value=e.id),t})()})}})]}})}}),j(xj,{label:`Cursor agent`,hint:`App users in your workspace. Pick Cursor — requires the Cursor integration installed in Linear (workspace admin) with usage-based pricing enabled in Cursor.`,get children(){return j(M,{get when(){return $e(()=>!!s.data)()&&s.data.length===0},get fallback(){return j(yj,{get value(){return n().cursorAgentId??``},onChange:e=>{let t=e.currentTarget.value;if(!t){r({cursorAgentId:void 0,cursorAgentName:void 0,cursorAgentUrl:void 0});return}let n=s.data?.find(e=>e.id===t);n&&r({cursorAgentId:n.id,cursorAgentName:n.displayName,cursorAgentUrl:n.url??void 0})},get disabled(){return s.isLoading},get children(){return[G1(),j(M,{get when(){return s.data},get children(){return j(We,{get each(){return s.data},children:e=>(()=>{var t=K1();return P(t,()=>e.displayName),D(()=>t.selected=e.id===n().cursorAgentId),D(()=>t.value=e.id),t})()})}})]}})},get children(){return T1()}})}}),j(xj,{label:`Default repository`,hint:`Appended to delegated issues as [repo=…] so Cursor picks the right repo.`,get children(){return j(_j,{placeholder:`owner/repository`,get value(){return n().defaultRepo??``},onBlur:e=>{r({defaultRepo:e.currentTarget.value.trim()||void 0})}})}}),j(xj,{label:`Cursor cloud model`,hint:`Appended as [model=…] — e.g. claude-opus-4-8, gpt-5.2, composer. Empty = Cursor's default.`,get children(){return j(_j,{placeholder:`Cursor's default`,get value(){return n().cursorModel??``},onBlur:e=>{r({cursorModel:e.currentTarget.value.trim()||void 0})}})}}),j(xj,{label:`Agent instructions`,hint:`Appended to every issue as '### Agent instructions' and given to the AI draft. Add demo credentials (username/password) so the agent can log in, test, and record its video. Careful: credentials become visible to everyone who can read the issue.`,get children(){return[j(vj,{rows:5,placeholder:pD,get value(){return n().issueTemplate??``},onBlur:e=>{r({issueTemplate:e.currentTarget.value.trim()||void 0})}}),E1()]}}),j(xj,{label:`Dev server log URL`,hint:`Tail of your dev-server log attached to issues (and fed to AI drafts). Serve the log over HTTP: "dev:http": "next dev 2>&1 | tee public/dev-server.log" (gitignore it), then use /dev-server.log here. Empty = disabled.`,get children(){return j(_j,{placeholder:`/dev-server.log`,get value(){return n().logUrl??``},onBlur:e=>{r({logUrl:e.currentTarget.value.trim()||void 0})}})}}),j(xj,{label:`Log lines to attach`,hint:`Trailing lines included in the issue (10–500).`,get children(){return j(_j,{type:`number`,min:`10`,max:`500`,placeholder:`100`,get value(){return n().logLines??``},onBlur:e=>{let t=Number(e.currentTarget.value);r({logLines:Number.isFinite(t)&&t>0?Math.min(500,Math.max(10,Math.round(t))):void 0})}})}}),j(xj,{label:`Skills & memory paths`,hint:`One path per line. The cloud agent works in a full repo checkout, so committed paths (e.g. .claude/skills/apple-hig-design-principles) are readable directly — every issue gets a MANDATORY-reading section pointing at them. Repo-relative for cloud agents; absolute paths also work when you paste the issue into a local Claude Code session. Per project: these settings live per dev origin.`,get children(){return j(vj,{rows:4,placeholder:`.claude/skills/apple-hig-design-principles
|