@figma-vars/hooks 1.1.1 → 1.3.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.
@@ -1,25 +1,4 @@
1
- (function(A,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],f):(A=typeof globalThis<"u"?globalThis:A||self,f(A.FigmaVarsHooks={},A.require$$0))})(this,function(A,f){"use strict";var ge={exports:{}},le={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var He;function Et(){if(He)return le;He=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function t(r,o,a){var i=null;if(a!==void 0&&(i=""+a),o.key!==void 0&&(i=""+o.key),"key"in o){a={};for(var d in o)d!=="key"&&(a[d]=o[d])}else a=o;return o=a.ref,{$$typeof:e,type:r,key:i,ref:o!==void 0?o:null,props:a}}return le.Fragment=n,le.jsx=t,le.jsxs=t,le}var fe={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Je;function pt(){return Je||(Je=1,process.env.NODE_ENV!=="production"&&function(){function e(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===x?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case E:return"Fragment";case c:return"Profiler";case V:return"StrictMode";case C:return"Suspense";case F:return"SuspenseList";case re:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case _:return"Portal";case se:return(s.displayName||"Context")+".Provider";case Y:return(s._context.displayName||"Context")+".Consumer";case B:var l=s.render;return s=s.displayName,s||(s=l.displayName||l.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ne:return l=s.displayName||null,l!==null?l:e(s.type)||"Memo";case O:l=s._payload,s=s._init;try{return e(s(l))}catch{}}return null}function n(s){return""+s}function t(s){try{n(s);var l=!1}catch{l=!0}if(l){l=console;var b=l.error,w=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return b.call(l,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",w),n(s)}}function r(s){if(s===E)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===O)return"<...>";try{var l=e(s);return l?"<"+l+">":"<...>"}catch{return"<...>"}}function o(){var s=H.A;return s===null?null:s.getOwner()}function a(){return Error("react-stack-top-frame")}function i(s){if(J.call(s,"key")){var l=Object.getOwnPropertyDescriptor(s,"key").get;if(l&&l.isReactWarning)return!1}return s.key!==void 0}function d(s,l){function b(){ae||(ae=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",l))}b.isReactWarning=!0,Object.defineProperty(s,"key",{get:b,configurable:!0})}function p(){var s=e(this.type);return Ee[s]||(Ee[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function S(s,l,b,w,M,P,ie,ce){return b=P.ref,s={$$typeof:u,type:s,key:l,props:P,_owner:M},(b!==void 0?b:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:p}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ce}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function g(s,l,b,w,M,P,ie,ce){var k=l.children;if(k!==void 0)if(w)if(N(k)){for(w=0;w<k.length;w++)m(k[w]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(k);if(J.call(l,"key")){k=e(s);var oe=Object.keys(l).filter(function(Re){return Re!=="key"});w=0<oe.length?"{key: someKey, "+oe.join(": ..., ")+": ...}":"{key: someKey}",ve[k+w]||(oe=0<oe.length?"{"+oe.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
- let props = %s;
19
- <%s {...props} />
20
- React keys must be passed directly to JSX without using spread:
21
- let props = %s;
22
- <%s key={someKey} {...props} />`,w,k,oe,k),ve[k+w]=!0)}if(k=null,b!==void 0&&(t(b),k=""+b),i(l)&&(t(l.key),k=""+l.key),"key"in l){b={};for(var Z in l)Z!=="key"&&(b[Z]=l[Z])}else b=l;return k&&d(b,typeof s=="function"?s.displayName||s.name||"Unknown":s),S(s,k,P,M,o(),b,ie,ce)}function m(s){typeof s=="object"&&s!==null&&s.$$typeof===u&&s._store&&(s._store.validated=1)}var v=f,u=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),se=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),x=Symbol.for("react.client.reference"),H=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,N=Array.isArray,K=console.createTask?console.createTask:function(){return null};v={"react-stack-bottom-frame":function(s){return s()}};var ae,Ee={},pe=v["react-stack-bottom-frame"].bind(v,a)(),X=K(r(a)),ve={};fe.Fragment=E,fe.jsx=function(s,l,b,w,M){var P=1e4>H.recentlyCreatedOwnerStacks++;return g(s,l,b,!1,w,M,P?Error("react-stack-top-frame"):pe,P?K(r(s)):X)},fe.jsxs=function(s,l,b,w,M){var P=1e4>H.recentlyCreatedOwnerStacks++;return g(s,l,b,!0,w,M,P?Error("react-stack-top-frame"):pe,P?K(r(s)):X)}}()),fe}var Ke;function vt(){return Ke||(Ke=1,process.env.NODE_ENV==="production"?ge.exports=Et():ge.exports=pt()),ge.exports}var gt=vt();const ze=f.createContext(void 0),St=({children:e,token:n})=>gt.jsx(ze.Provider,{value:{token:n},children:e}),ht=()=>{const e=f.useContext(ze);if(e===void 0)throw new Error("useFigmaTokenContext must be used within a FigmaVarsProvider");return e},$=()=>{const{token:e}=ht();return e};var Se={exports:{}},Oe={};/**
1
+ (function(g,Z){typeof exports=="object"&&typeof module<"u"?Z(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],Z):(g=typeof globalThis<"u"?globalThis:g||self,Z(g["@figma-vars/hooks"]={},g["react/jsx-runtime"],g.React))})(this,function(g,Z,m){"use strict";const Me=m.createContext(void 0),mt=({children:e,token:t,fileKey:n})=>Z.jsx(Me.Provider,{value:{token:t,fileKey:n},children:e}),H=()=>{const e=m.useContext(Me);if(e===void 0)throw new Error("useFigmaTokenContext must be used within a FigmaVarsProvider");return e};var se={exports:{}},Ee={};/**
23
2
  * @license React
24
3
  * use-sync-external-store-shim.production.js
25
4
  *
@@ -27,7 +6,7 @@ React keys must be passed directly to JSX without using spread:
27
6
  *
28
7
  * This source code is licensed under the MIT license found in the
29
8
  * LICENSE file in the root directory of this source tree.
30
- */var Xe;function _t(){if(Xe)return Oe;Xe=1;var e=f;function n(m,v){return m===v&&(m!==0||1/m===1/v)||m!==m&&v!==v}var t=typeof Object.is=="function"?Object.is:n,r=e.useState,o=e.useEffect,a=e.useLayoutEffect,i=e.useDebugValue;function d(m,v){var u=v(),_=r({inst:{value:u,getSnapshot:v}}),E=_[0].inst,V=_[1];return a(function(){E.value=u,E.getSnapshot=v,p(E)&&V({inst:E})},[m,u,v]),o(function(){return p(E)&&V({inst:E}),m(function(){p(E)&&V({inst:E})})},[m]),i(u),u}function p(m){var v=m.getSnapshot;m=m.value;try{var u=v();return!t(m,u)}catch{return!0}}function S(m,v){return v()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?S:d;return Oe.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Oe}var Te={};/**
9
+ */var Pe;function pt(){if(Pe)return Ee;Pe=1;var e=m;function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function h(c,d){var u=d(),E=r({inst:{value:u,getSnapshot:d}}),l=E[0].inst,C=E[1];return s(function(){l.value=u,l.getSnapshot=d,S(l)&&C({inst:l})},[c,u,d]),o(function(){return S(l)&&C({inst:l}),c(function(){S(l)&&C({inst:l})})},[c]),a(u),u}function S(c){var d=c.getSnapshot;c=c.value;try{var u=d();return!n(c,u)}catch{return!0}}function D(c,d){return d()}var O=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?D:h;return Ee.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:O,Ee}var me={};/**
31
10
  * @license React
32
11
  * use-sync-external-store-shim.development.js
33
12
  *
@@ -35,4 +14,4 @@ React keys must be passed directly to JSX without using spread:
35
14
  *
36
15
  * This source code is licensed under the MIT license found in the
37
16
  * LICENSE file in the root directory of this source tree.
38
- */var Ze;function bt(){return Ze||(Ze=1,process.env.NODE_ENV!=="production"&&function(){function e(u,_){return u===_&&(u!==0||1/u===1/_)||u!==u&&_!==_}function n(u,_){g||o.startTransition===void 0||(g=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var E=_();if(!m){var V=_();a(E,V)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}V=i({inst:{value:E,getSnapshot:_}});var c=V[0].inst,Y=V[1];return p(function(){c.value=E,c.getSnapshot=_,t(c)&&Y({inst:c})},[u,E,_]),d(function(){return t(c)&&Y({inst:c}),u(function(){t(c)&&Y({inst:c})})},[u]),S(E),E}function t(u){var _=u.getSnapshot;u=u.value;try{var E=_();return!a(u,E)}catch{return!0}}function r(u,_){return _()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=f,a=typeof Object.is=="function"?Object.is:e,i=o.useState,d=o.useEffect,p=o.useLayoutEffect,S=o.useDebugValue,g=!1,m=!1,v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;Te.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:v,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Te}var Qe;function Rt(){return Qe||(Qe=1,process.env.NODE_ENV==="production"?Se.exports=_t():Se.exports=bt()),Se.exports}var Ot=Rt();const qe=0,$e=1,et=2,tt=3;var nt=Object.prototype.hasOwnProperty;function we(e,n){var t,r;if(e===n)return!0;if(e&&n&&(t=e.constructor)===n.constructor){if(t===Date)return e.getTime()===n.getTime();if(t===RegExp)return e.toString()===n.toString();if(t===Array){if((r=e.length)===n.length)for(;r--&&we(e[r],n[r]););return r===-1}if(!t||typeof e=="object"){r=0;for(t in e)if(nt.call(e,t)&&++r&&!nt.call(n,t)||!(t in n)||!we(e[t],n[t]))return!1;return Object.keys(n).length===r}}return e!==e&&n!==n}const z=new WeakMap,ee=()=>{},L=ee(),ye=Object,h=e=>e===L,G=e=>typeof e=="function",te=(e,n)=>({...e,...n}),rt=e=>G(e.then),Ae={},he={},Ce="undefined",de=typeof window!=Ce,ke=typeof document!=Ce,Tt=de&&"Deno"in window,wt=()=>de&&typeof window.requestAnimationFrame!=Ce,ot=(e,n)=>{const t=z.get(e);return[()=>!h(n)&&e.get(n)||Ae,r=>{if(!h(n)){const o=e.get(n);n in he||(he[n]=o),t[5](n,te(o,r),o||Ae)}},t[6],()=>!h(n)&&n in he?he[n]:!h(n)&&e.get(n)||Ae]};let De=!0;const yt=()=>De,[Ie,Le]=de&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[ee,ee],At=()=>{const e=ke&&document.visibilityState;return h(e)||e!=="hidden"},Ct=e=>(ke&&document.addEventListener("visibilitychange",e),Ie("focus",e),()=>{ke&&document.removeEventListener("visibilitychange",e),Le("focus",e)}),kt=e=>{const n=()=>{De=!0,e()},t=()=>{De=!1};return Ie("online",n),Ie("offline",t),()=>{Le("online",n),Le("offline",t)}},Dt={isOnline:yt,isVisible:At},It={initFocus:Ct,initReconnect:kt},st=!f.useId,me=!de||Tt,Lt=e=>wt()?window.requestAnimationFrame(e):setTimeout(e,1),Ve=me?f.useEffect:f.useLayoutEffect,Fe=typeof navigator<"u"&&navigator.connection,at=!me&&Fe&&(["slow-2g","2g"].includes(Fe.effectiveType)||Fe.saveData),_e=new WeakMap,Pe=(e,n)=>ye.prototype.toString.call(e)===`[object ${n}]`;let Vt=0;const je=e=>{const n=typeof e,t=Pe(e,"Date"),r=Pe(e,"RegExp"),o=Pe(e,"Object");let a,i;if(ye(e)===e&&!t&&!r){if(a=_e.get(e),a)return a;if(a=++Vt+"~",_e.set(e,a),Array.isArray(e)){for(a="@",i=0;i<e.length;i++)a+=je(e[i])+",";_e.set(e,a)}if(o){a="#";const d=ye.keys(e).sort();for(;!h(i=d.pop());)h(e[i])||(a+=i+":"+je(e[i])+",");_e.set(e,a)}}else a=t?e.toJSON():n=="symbol"?e.toString():n=="string"?JSON.stringify(e):""+e;return a},Ne=e=>{if(G(e))try{e=e()}catch{e=""}const n=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?je(e):"",[e,n]};let Ft=0;const xe=()=>++Ft;async function it(...e){const[n,t,r,o]=e,a=te({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let i=a.populateCache;const d=a.rollbackOnError;let p=a.optimisticData;const S=v=>typeof d=="function"?d(v):d!==!1,g=a.throwOnError;if(G(t)){const v=t,u=[],_=n.keys();for(const E of _)!/^\$(inf|sub)\$/.test(E)&&v(n.get(E)._k)&&u.push(E);return Promise.all(u.map(m))}return m(t);async function m(v){const[u]=Ne(v);if(!u)return;const[_,E]=ot(n,u),[V,c,Y,se]=z.get(n),B=()=>{const N=V[u];return(G(a.revalidate)?a.revalidate(_().data,v):a.revalidate!==!1)&&(delete Y[u],delete se[u],N&&N[0])?N[0](et).then(()=>_().data):_().data};if(e.length<3)return B();let C=r,F;const ne=xe();c[u]=[ne,0];const O=!h(p),re=_(),x=re.data,H=re._c,J=h(H)?x:H;if(O&&(p=G(p)?p(J,x):p,E({data:p,_c:J})),G(C))try{C=C(J)}catch(N){F=N}if(C&&rt(C))if(C=await C.catch(N=>{F=N}),ne!==c[u][0]){if(F)throw F;return C}else F&&O&&S(F)&&(i=!0,E({data:J,_c:L}));if(i&&!F)if(G(i)){const N=i(C,J);E({data:N,error:L,_c:L})}else E({data:C,error:L,_c:L});if(c[u][1]=xe(),Promise.resolve(B()).then(()=>{E({_c:L})}),F){if(g)throw F;return}return C}}const ct=(e,n)=>{for(const t in e)e[t][0]&&e[t][0](n)},Pt=(e,n)=>{if(!z.has(e)){const t=te(It,n),r=Object.create(null),o=it.bind(L,e);let a=ee;const i=Object.create(null),d=(g,m)=>{const v=i[g]||[];return i[g]=v,v.push(m),()=>v.splice(v.indexOf(m),1)},p=(g,m,v)=>{e.set(g,m);const u=i[g];if(u)for(const _ of u)_(m,v)},S=()=>{if(!z.has(e)&&(z.set(e,[r,Object.create(null),Object.create(null),Object.create(null),o,p,d]),!me)){const g=t.initFocus(setTimeout.bind(L,ct.bind(L,r,qe))),m=t.initReconnect(setTimeout.bind(L,ct.bind(L,r,$e)));a=()=>{g&&g(),m&&m(),z.delete(e)}}};return S(),[e,o,S,a]}return[e,z.get(e)[4]]},jt=(e,n,t,r,o)=>{const a=t.errorRetryCount,i=o.retryCount,d=~~((Math.random()+.5)*(1<<(i<8?i:8)))*t.errorRetryInterval;!h(a)&&i>a||setTimeout(r,d,o)},Nt=we,[ut,xt]=Pt(new Map),Mt=te({onLoadingSlow:ee,onSuccess:ee,onError:ee,onErrorRetry:jt,onDiscarded:ee,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:at?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:at?5e3:3e3,compare:Nt,isPaused:()=>!1,cache:ut,mutate:xt,fallback:{}},Dt),Ut=(e,n)=>{const t=te(e,n);if(n){const{use:r,fallback:o}=e,{use:a,fallback:i}=n;r&&a&&(t.use=r.concat(a)),o&&i&&(t.fallback=te(o,i))}return t},Wt=f.createContext({}),Gt="$inf$",lt=de&&window.__SWR_DEVTOOLS_USE__,Yt=lt?window.__SWR_DEVTOOLS_USE__:[],Bt=()=>{lt&&(window.__SWR_DEVTOOLS_REACT__=f)},Ht=e=>G(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Jt=()=>te(Mt,f.useContext(Wt)),Kt=e=>(n,t,r)=>e(n,t&&((...a)=>{const[i]=Ne(n),[,,,d]=z.get(ut);if(i.startsWith(Gt))return t(...a);const p=d[i];return h(p)?t(...a):(delete d[i],p)}),r),zt=Yt.concat(Kt),Xt=e=>function(...t){const r=Jt(),[o,a,i]=Ht(t),d=Ut(r,i);let p=e;const{use:S}=d,g=(S||[]).concat(zt);for(let m=g.length;m--;)p=g[m](p);return p(o,a||d.fetcher||null,d)},Zt=(e,n,t)=>{const r=n[e]||(n[e]=[]);return r.push(t),()=>{const o=r.indexOf(t);o>=0&&(r[o]=r[r.length-1],r.pop())}};Bt();const Me=f.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(n=>{e.status="fulfilled",e.value=n},n=>{e.status="rejected",e.reason=n}),e}}),Ue={dedupe:!0},We=Xt((e,n,t)=>{const{cache:r,compare:o,suspense:a,fallbackData:i,revalidateOnMount:d,revalidateIfStale:p,refreshInterval:S,refreshWhenHidden:g,refreshWhenOffline:m,keepPreviousData:v}=t,[u,_,E,V]=z.get(r),[c,Y]=Ne(e),se=f.useRef(!1),B=f.useRef(!1),C=f.useRef(c),F=f.useRef(n),ne=f.useRef(t),O=()=>ne.current,re=()=>O().isVisible()&&O().isOnline(),[x,H,J,N]=ot(r,c),K=f.useRef({}).current,ae=h(i)?h(t.fallback)?L:t.fallback[c]:i,Ee=(T,R)=>{for(const I in K){const y=I;if(y==="data"){if(!o(T[y],R[y])&&(!h(T[y])||!o(P,R[y])))return!1}else if(R[y]!==T[y])return!1}return!0},pe=f.useMemo(()=>{const T=!c||!n?!1:h(d)?O().isPaused()||a?!1:p!==!1:d,R=j=>{const Q=te(j);return delete Q._k,T?{isValidating:!0,isLoading:!0,...Q}:Q},I=x(),y=N(),W=R(I),ue=I===y?W:R(y);let D=W;return[()=>{const j=R(x());return Ee(j,D)?(D.data=j.data,D.isLoading=j.isLoading,D.isValidating=j.isValidating,D.error=j.error,D):(D=j,j)},()=>ue]},[r,c]),X=Ot.useSyncExternalStore(f.useCallback(T=>J(c,(R,I)=>{Ee(I,R)||T()}),[r,c]),pe[0],pe[1]),ve=!se.current,s=u[c]&&u[c].length>0,l=X.data,b=h(l)?ae&&rt(ae)?Me(ae):ae:l,w=X.error,M=f.useRef(b),P=v?h(l)?h(M.current)?b:M.current:l:b,ie=s&&!h(w)?!1:ve&&!h(d)?d:O().isPaused()?!1:a?h(b)?!1:p:h(b)||p,ce=!!(c&&n&&ve&&ie),k=h(X.isValidating)?ce:X.isValidating,oe=h(X.isLoading)?ce:X.isLoading,Z=f.useCallback(async T=>{const R=F.current;if(!c||!R||B.current||O().isPaused())return!1;let I,y,W=!0;const ue=T||{},D=!E[c]||!ue.dedupe,j=()=>st?!B.current&&c===C.current&&se.current:c===C.current,Q={isValidating:!1,isLoading:!1},ft=()=>{H(Q)},dt=()=>{const U=E[c];U&&U[1]===y&&delete E[c]},mt={isValidating:!0};h(x().data)&&(mt.isLoading=!0);try{if(D&&(H(mt),t.loadingTimeout&&h(x().data)&&setTimeout(()=>{W&&j()&&O().onLoadingSlow(c,t)},t.loadingTimeout),E[c]=[R(Y),xe()]),[I,y]=E[c],I=await I,D&&setTimeout(dt,t.dedupingInterval),!E[c]||E[c][1]!==y)return D&&j()&&O().onDiscarded(c),!1;Q.error=L;const U=_[c];if(!h(U)&&(y<=U[0]||y<=U[1]||U[1]===0))return ft(),D&&j()&&O().onDiscarded(c),!1;const q=x().data;Q.data=o(q,I)?q:I,D&&j()&&O().onSuccess(I,c,t)}catch(U){dt();const q=O(),{shouldRetryOnError:Ye}=q;q.isPaused()||(Q.error=U,D&&j()&&(q.onError(U,c,q),(Ye===!0||G(Ye)&&Ye(U))&&(!O().revalidateOnFocus||!O().revalidateOnReconnect||re())&&q.onErrorRetry(U,c,q,dn=>{const Be=u[c];Be&&Be[0]&&Be[0](tt,dn)},{retryCount:(ue.retryCount||0)+1,dedupe:!0})))}return W=!1,ft(),!0},[c,r]),Re=f.useCallback((...T)=>it(r,C.current,...T),[]);if(Ve(()=>{F.current=n,ne.current=t,h(l)||(M.current=l)}),Ve(()=>{if(!c)return;const T=Z.bind(L,Ue);let R=0;O().revalidateOnFocus&&(R=Date.now()+O().focusThrottleInterval);const y=Zt(c,u,(W,ue={})=>{if(W==qe){const D=Date.now();O().revalidateOnFocus&&D>R&&re()&&(R=D+O().focusThrottleInterval,T())}else if(W==$e)O().revalidateOnReconnect&&re()&&T();else{if(W==et)return Z();if(W==tt)return Z(ue)}});return B.current=!1,C.current=c,se.current=!0,H({_k:Y}),ie&&(h(b)||me?T():Lt(T)),()=>{B.current=!0,y()}},[c]),Ve(()=>{let T;function R(){const y=G(S)?S(x().data):S;y&&T!==-1&&(T=setTimeout(I,y))}function I(){!x().error&&(g||O().isVisible())&&(m||O().isOnline())?Z(Ue).then(R):R()}return R(),()=>{T&&(clearTimeout(T),T=-1)}},[S,g,m,c]),f.useDebugValue(P),a&&h(b)&&c){if(!st&&me)throw new Error("Fallback data is required when using Suspense in SSR.");F.current=n,ne.current=t,B.current=!1;const T=V[c];if(!h(T)){const R=Re(T);Me(R)}if(h(w)){const R=Z(Ue);h(P)||(R.status="fulfilled",R.value=!0),Me(R)}else throw w}return{mutate:Re,get data(){return K.data=!0,P},get error(){return K.error=!0,w},get isValidating(){return K.isValidating=!0,k},get isLoading(){return K.isLoading=!0,oe}}}),Qt=()=>null,be=async(e,n={method:"GET"})=>{throw new Error("Figma API token is not available.")},qt="https://api.figma.com/v1/files",Ge=e=>`${qt}/${e}/variables`,$t=e=>{const n=$(),{data:t,error:r,isLoading:o,isValidating:a}=We(n?Ge(e):null,be),i=t!=null&&t.meta?Object.values(t.meta.variables):[],d=t!=null&&t.meta?t.meta.variables:{};return{variables:i,variablesById:d,isLoading:o,isValidating:a,error:r??(t&&"message"in t?new Error(t.message):null)}},en=e=>{const n=$(),{data:t,error:r,isLoading:o,isValidating:a}=We(n?Ge(e):null,be),i=t!=null&&t.meta?Object.values(t.meta.variableCollections):[],d=t!=null&&t.meta?t.meta.variableCollections:{};return{collections:i,collectionsById:d,isLoading:o,isValidating:a,error:r??(t&&"message"in t?new Error(t.message):null)}},tn=e=>{const n=$(),{data:t,error:r,isLoading:o,isValidating:a}=We(n?Ge(e):null,be),i=[],d={},p={};if(t!=null&&t.meta)for(const S of Object.values(t.meta.variableCollections)){i.push(...S.modes),d[S.id]=S.modes;for(const g of S.modes)p[g.modeId]=g}return{modes:i,modesByCollectionId:d,modesById:p,isLoading:o,isValidating:a,error:r??(t&&"message"in t?new Error(t.message):null)}};async function nn(e,n,t){const r=`https://api.figma.com/v1/files/${n}/variables`;try{const o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(t)}),a=await o.json();return o.ok?{error:!1,status:o.status,meta:a.meta}:{error:!0,status:o.status,message:a.message||"Failed to perform bulk update."}}catch(o){return{error:!0,status:500,message:o instanceof Error?o.message:"An unknown error occurred."}}}const rn=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{bulkUpdate:f.useCallback(async(p,S)=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const g=await nn(e,p,S);i(g),g.error&&o(g.message||"An error occurred during the bulk update."),t(!1)},[e]),loading:n,error:r,data:a}};async function on(e,n){const t="https://api.figma.com/v1/variables";try{const r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(n)});if(!r.ok){const a=await r.json();return{error:!0,status:r.status,message:a.message||"Failed to create Figma variable"}}const o=await r.json();return{error:!1,status:r.status,variable:o}}catch(r){return{error:!0,status:500,message:r instanceof Error?r.message:"An unknown error occurred"}}}const sn=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{createVariable:f.useCallback(async p=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const S=await on(e,p);i(S),S.error&&o(S.message||"An error occurred."),t(!1)},[e]),loading:n,error:r,data:a}};async function an(e,n){const t=`https://api.figma.com/v1/variables/${n}`;try{const r=await fetch(t,{method:"DELETE",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e}});if(!r.ok){const o=await r.json();return{error:!0,status:r.status,message:o.message||"Failed to delete Figma variable"}}return{error:!1,status:r.status}}catch(r){return{error:!0,status:500,message:r instanceof Error?r.message:"An unknown error occurred"}}}const cn=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{deleteVariable:f.useCallback(async p=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const S=await an(e,p);i(S),S.error&&o(S.message||"An error occurred."),t(!1)},[e]),loading:n,error:r,data:a}};async function un(e,n,t){const r=`https://api.figma.com/v1/variables/${n}`;try{const o=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(t)});if(!o.ok){const a=await o.json();return{error:!0,status:o.status,message:a.message||"Failed to update Figma variable"}}return{error:!1,status:o.status}}catch(o){return{error:!0,status:500,message:o instanceof Error?o.message:"An unknown error occurred"}}}const ln=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{updateVariable:f.useCallback(async(p,S)=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const g=await un(e,p,S);i(g),g.error&&o(g.message||"An error occurred."),t(!1)},[e]),loading:n,error:r,data:a}};function fn(e,n){return e.filter(t=>{let r=!0;return n.resolvedType&&(r=r&&t.resolvedType===n.resolvedType),n.name&&(r=r&&t.name.includes(n.name)),r})}A.FigmaVarsProvider=St,A.fetchWithAuth=be,A.filterVariables=fn,A.getFigmaToken=Qt,A.useBulkUpdateVariables=rn,A.useCreateVariable=sn,A.useDeleteVariable=cn,A.useFigmaToken=$,A.useUpdateVariable=ln,A.useVariableCollections=en,A.useVariableModes=tn,A.useVariables=$t,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
17
+ */var je;function ht(){return je||(je=1,process.env.NODE_ENV!=="production"&&function(){function e(u,E){return u===E&&(u!==0||1/u===1/E)||u!==u&&E!==E}function t(u,E){O||o.startTransition===void 0||(O=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var l=E();if(!c){var C=E();s(l,C)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}C=a({inst:{value:l,getSnapshot:E}});var i=C[0].inst,q=C[1];return S(function(){i.value=l,i.getSnapshot=E,n(i)&&q({inst:i})},[u,l,E]),h(function(){return n(i)&&q({inst:i}),u(function(){n(i)&&q({inst:i})})},[u]),D(l),l}function n(u){var E=u.getSnapshot;u=u.value;try{var l=E();return!s(u,l)}catch{return!0}}function r(u,E){return E()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=m,s=typeof Object.is=="function"?Object.is:e,a=o.useState,h=o.useEffect,S=o.useLayoutEffect,D=o.useDebugValue,O=!1,c=!1,d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;me.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),me}var xe;function St(){return xe||(xe=1,process.env.NODE_ENV==="production"?se.exports=pt():se.exports=ht()),se.exports}var _t=St();const Ue=0,ke=1,qe=2,Ge=3;var We=Object.prototype.hasOwnProperty;function pe(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&pe(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(We.call(e,n)&&++r&&!We.call(t,n)||!(n in t)||!pe(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}const P=new WeakMap,U=()=>{},R=U(),he=Object,f=e=>e===R,N=e=>typeof e=="function",k=(e,t)=>({...e,...t}),Be=e=>N(e.then),Se={},ie={},_e="undefined",ee=typeof window!=_e,ve=typeof document!=_e,vt=ee&&"Deno"in window,Ot=()=>ee&&typeof window.requestAnimationFrame!=_e,He=(e,t)=>{const n=P.get(e);return[()=>!f(t)&&e.get(t)||Se,r=>{if(!f(t)){const o=e.get(t);t in ie||(ie[t]=o),n[5](t,k(o,r),o||Se)}},n[6],()=>!f(t)&&t in ie?ie[t]:!f(t)&&e.get(t)||Se]};let Oe=!0;const wt=()=>Oe,[we,ge]=ee&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[U,U],gt=()=>{const e=ve&&document.visibilityState;return f(e)||e!=="hidden"},yt=e=>(ve&&document.addEventListener("visibilitychange",e),we("focus",e),()=>{ve&&document.removeEventListener("visibilitychange",e),ge("focus",e)}),Tt=e=>{const t=()=>{Oe=!0,e()},n=()=>{Oe=!1};return we("online",t),we("offline",n),()=>{ge("online",t),ge("offline",n)}},At={isOnline:wt,isVisible:gt},Rt={initFocus:yt,initReconnect:Tt},$e=!m.useId,te=!ee||vt,Dt=e=>Ot()?window.requestAnimationFrame(e):setTimeout(e,1),ye=te?m.useEffect:m.useLayoutEffect,Te=typeof navigator<"u"&&navigator.connection,Ke=!te&&Te&&(["slow-2g","2g"].includes(Te.effectiveType)||Te.saveData),ae=new WeakMap,Ae=(e,t)=>he.prototype.toString.call(e)===`[object ${t}]`;let It=0;const Re=e=>{const t=typeof e,n=Ae(e,"Date"),r=Ae(e,"RegExp"),o=Ae(e,"Object");let s,a;if(he(e)===e&&!n&&!r){if(s=ae.get(e),s)return s;if(s=++It+"~",ae.set(e,s),Array.isArray(e)){for(s="@",a=0;a<e.length;a++)s+=Re(e[a])+",";ae.set(e,s)}if(o){s="#";const h=he.keys(e).sort();for(;!f(a=h.pop());)f(e[a])||(s+=a+":"+Re(e[a])+",");ae.set(e,s)}}else s=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return s},De=e=>{if(N(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Re(e):"",[e,t]};let Ct=0;const Ie=()=>++Ct;async function Je(...e){const[t,n,r,o]=e,s=k({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let a=s.populateCache;const h=s.rollbackOnError;let S=s.optimisticData;const D=d=>typeof h=="function"?h(d):h!==!1,O=s.throwOnError;if(N(n)){const d=n,u=[],E=t.keys();for(const l of E)!/^\$(inf|sub)\$/.test(l)&&d(t.get(l)._k)&&u.push(l);return Promise.all(u.map(c))}return c(n);async function c(d){const[u]=De(d);if(!u)return;const[E,l]=He(t,u),[C,i,q,re]=P.get(t),G=()=>{const V=C[u];return(N(s.revalidate)?s.revalidate(E().data,d):s.revalidate!==!1)&&(delete q[u],delete re[u],V&&V[0])?V[0](qe).then(()=>E().data):E().data};if(e.length<3)return G();let T=r,b;const $=Ie();i[u]=[$,0];const v=!f(S),K=E(),M=K.data,J=K._c,W=f(J)?M:J;if(v&&(S=N(S)?S(W,M):S,l({data:S,_c:W})),N(T))try{T=T(W)}catch(V){b=V}if(T&&Be(T))if(T=await T.catch(V=>{b=V}),$!==i[u][0]){if(b)throw b;return T}else b&&v&&D(b)&&(a=!0,l({data:W,_c:R}));if(a&&!b)if(N(a)){const V=a(T,W);l({data:V,error:R,_c:R})}else l({data:T,error:R,_c:R});if(i[u][1]=Ie(),Promise.resolve(G()).then(()=>{l({_c:R})}),b){if(O)throw b;return}return T}}const Ye=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},bt=(e,t)=>{if(!P.has(e)){const n=k(Rt,t),r=Object.create(null),o=Je.bind(R,e);let s=U;const a=Object.create(null),h=(O,c)=>{const d=a[O]||[];return a[O]=d,d.push(c),()=>d.splice(d.indexOf(c),1)},S=(O,c,d)=>{e.set(O,c);const u=a[O];if(u)for(const E of u)E(c,d)},D=()=>{if(!P.has(e)&&(P.set(e,[r,Object.create(null),Object.create(null),Object.create(null),o,S,h]),!te)){const O=n.initFocus(setTimeout.bind(R,Ye.bind(R,r,Ue))),c=n.initReconnect(setTimeout.bind(R,Ye.bind(R,r,ke)));s=()=>{O&&O(),c&&c(),P.delete(e)}}};return D(),[e,o,D,s]}return[e,P.get(e)[4]]},Lt=(e,t,n,r,o)=>{const s=n.errorRetryCount,a=o.retryCount,h=~~((Math.random()+.5)*(1<<(a<8?a:8)))*n.errorRetryInterval;!f(s)&&a>s||setTimeout(r,h,o)},Vt=pe,[ze,Ft]=bt(new Map),Nt=k({onLoadingSlow:U,onSuccess:U,onError:U,onErrorRetry:Lt,onDiscarded:U,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ke?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ke?5e3:3e3,compare:Vt,isPaused:()=>!1,cache:ze,mutate:Ft,fallback:{}},At),Mt=(e,t)=>{const n=k(e,t);if(t){const{use:r,fallback:o}=e,{use:s,fallback:a}=t;r&&s&&(n.use=r.concat(s)),o&&a&&(n.fallback=k(o,a))}return n},Pt=m.createContext({}),jt="$inf$",Xe=ee&&window.__SWR_DEVTOOLS_USE__,xt=Xe?window.__SWR_DEVTOOLS_USE__:[],Ut=()=>{Xe&&(window.__SWR_DEVTOOLS_REACT__=m)},kt=e=>N(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],qt=()=>k(Nt,m.useContext(Pt)),Gt=e=>(t,n,r)=>e(t,n&&((...s)=>{const[a]=De(t),[,,,h]=P.get(ze);if(a.startsWith(jt))return n(...s);const S=h[a];return f(S)?n(...s):(delete h[a],S)}),r),Wt=xt.concat(Gt),Bt=e=>function(...n){const r=qt(),[o,s,a]=kt(n),h=Mt(r,a);let S=e;const{use:D}=h,O=(D||[]).concat(Wt);for(let c=O.length;c--;)S=O[c](S);return S(o,s||h.fetcher||null,h)},Ht=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o>=0&&(r[o]=r[r.length-1],r.pop())}};Ut();const Ce=m.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}}),be={dedupe:!0},$t=Bt((e,t,n)=>{const{cache:r,compare:o,suspense:s,fallbackData:a,revalidateOnMount:h,revalidateIfStale:S,refreshInterval:D,refreshWhenHidden:O,refreshWhenOffline:c,keepPreviousData:d}=n,[u,E,l,C]=P.get(r),[i,q]=De(e),re=m.useRef(!1),G=m.useRef(!1),T=m.useRef(i),b=m.useRef(t),$=m.useRef(n),v=()=>$.current,K=()=>v().isVisible()&&v().isOnline(),[M,J,W,V]=He(r,i),Y=m.useRef({}).current,le=f(a)?f(n.fallback)?R:n.fallback[i]:a,st=(_,p)=>{for(const A in Y){const w=A;if(w==="data"){if(!o(_[w],p[w])&&(!f(_[w])||!o(de,p[w])))return!1}else if(p[w]!==_[w])return!1}return!0},it=m.useMemo(()=>{const _=!i||!t?!1:f(h)?v().isPaused()||s?!1:S!==!1:h,p=I=>{const j=k(I);return delete j._k,_?{isValidating:!0,isLoading:!0,...j}:j},A=M(),w=V(),F=p(A),Q=A===w?F:p(w);let y=F;return[()=>{const I=p(M());return st(I,y)?(y.data=I.data,y.isLoading=I.isLoading,y.isValidating=I.isValidating,y.error=I.error,y):(y=I,I)},()=>Q]},[r,i]),z=_t.useSyncExternalStore(m.useCallback(_=>W(i,(p,A)=>{st(A,p)||_()}),[r,i]),it[0],it[1]),at=!re.current,sn=u[i]&&u[i].length>0,X=z.data,B=f(X)?le&&Be(le)?Ce(le):le:X,fe=z.error,Ve=m.useRef(B),de=d?f(X)?f(Ve.current)?B:Ve.current:X:B,ut=sn&&!f(fe)?!1:at&&!f(h)?h:v().isPaused()?!1:s?f(B)?!1:S:f(B)||S,ct=!!(i&&t&&at&&ut),an=f(z.isValidating)?ct:z.isValidating,un=f(z.isLoading)?ct:z.isLoading,oe=m.useCallback(async _=>{const p=b.current;if(!i||!p||G.current||v().isPaused())return!1;let A,w,F=!0;const Q=_||{},y=!l[i]||!Q.dedupe,I=()=>$e?!G.current&&i===T.current&&re.current:i===T.current,j={isValidating:!1,isLoading:!1},ft=()=>{J(j)},dt=()=>{const L=l[i];L&&L[1]===w&&delete l[i]},Et={isValidating:!0};f(M().data)&&(Et.isLoading=!0);try{if(y&&(J(Et),n.loadingTimeout&&f(M().data)&&setTimeout(()=>{F&&I()&&v().onLoadingSlow(i,n)},n.loadingTimeout),l[i]=[p(q),Ie()]),[A,w]=l[i],A=await A,y&&setTimeout(dt,n.dedupingInterval),!l[i]||l[i][1]!==w)return y&&I()&&v().onDiscarded(i),!1;j.error=R;const L=E[i];if(!f(L)&&(w<=L[0]||w<=L[1]||L[1]===0))return ft(),y&&I()&&v().onDiscarded(i),!1;const x=M().data;j.data=o(x,A)?x:A,y&&I()&&v().onSuccess(A,i,n)}catch(L){dt();const x=v(),{shouldRetryOnError:Fe}=x;x.isPaused()||(j.error=L,y&&I()&&(x.onError(L,i,x),(Fe===!0||N(Fe)&&Fe(L))&&(!v().revalidateOnFocus||!v().revalidateOnReconnect||K())&&x.onErrorRetry(L,i,x,cn=>{const Ne=u[i];Ne&&Ne[0]&&Ne[0](Ge,cn)},{retryCount:(Q.retryCount||0)+1,dedupe:!0})))}return F=!1,ft(),!0},[i,r]),lt=m.useCallback((..._)=>Je(r,T.current,..._),[]);if(ye(()=>{b.current=t,$.current=n,f(X)||(Ve.current=X)}),ye(()=>{if(!i)return;const _=oe.bind(R,be);let p=0;v().revalidateOnFocus&&(p=Date.now()+v().focusThrottleInterval);const w=Ht(i,u,(F,Q={})=>{if(F==Ue){const y=Date.now();v().revalidateOnFocus&&y>p&&K()&&(p=y+v().focusThrottleInterval,_())}else if(F==ke)v().revalidateOnReconnect&&K()&&_();else{if(F==qe)return oe();if(F==Ge)return oe(Q)}});return G.current=!1,T.current=i,re.current=!0,J({_k:q}),ut&&(f(B)||te?_():Dt(_)),()=>{G.current=!0,w()}},[i]),ye(()=>{let _;function p(){const w=N(D)?D(M().data):D;w&&_!==-1&&(_=setTimeout(A,w))}function A(){!M().error&&(O||v().isVisible())&&(c||v().isOnline())?oe(be).then(p):p()}return p(),()=>{_&&(clearTimeout(_),_=-1)}},[D,O,c,i]),m.useDebugValue(de),s&&f(B)&&i){if(!$e&&te)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=t,$.current=n,G.current=!1;const _=C[i];if(!f(_)){const p=lt(_);Ce(p)}if(f(fe)){const p=oe(be);f(de)||(p.status="fulfilled",p.value=!0),Ce(p)}else throw fe}return{mutate:lt,get data(){return Y.data=!0,de},get error(){return Y.error=!0,fe},get isValidating(){return Y.isValidating=!0,an},get isLoading(){return Y.isLoading=!0,un}}}),Qe="https://api.figma.com",Kt=`${Qe}/v1/files`,Ze=`${Qe}/v1/variables`,et=Ze,tt=e=>`${Ze}/${e}`,Jt=e=>`${Kt}/${e}/variables/local`,nt="application/json",rt="X-FIGMA-TOKEN",ne="A Figma API token is required.",ot="An error occurred while fetching data from the Figma API.",Yt=async(e,t)=>{if(!t)throw new Error(ne);const n=await fetch(e,{headers:{[rt]:t,"Content-Type":nt}});if(!n.ok){const r=await n.json();throw new Error(r.message||ot)}return n.json()},Le=()=>{const{token:e,fileKey:t}=H(),n=t?Jt(t):null,{data:r,error:o,isLoading:s,isValidating:a}=$t(e&&n?[n,e]:null,Yt);return{data:r,isLoading:s,isValidating:a,error:o}},zt=()=>{const{data:e}=Le(),t=m.useMemo(()=>e!=null&&e.meta?Object.values(e.meta.variableCollections):[],[e]),n=m.useMemo(()=>e!=null&&e.meta?e.meta.variableCollections:{},[e]);return{collections:t,collectionsById:n}},Xt=()=>{const{data:e}=Le();return m.useMemo(()=>{const t=[],n={},r={};if(e!=null&&e.meta)for(const o of Object.values(e.meta.variableCollections)){t.push(...o.modes),n[o.id]=o.modes;for(const s of o.modes)r[s.modeId]=s}return{modes:t,modesByCollectionId:n,modesById:r}},[e])},Qt=()=>{const{token:e}=H();return e};function Zt(e,t){switch(t.type){case"loading":return{...e,status:"loading",error:null};case"success":return{...e,status:"success",data:t.payload};case"error":return{...e,status:"error",error:t.payload};default:return e}}const ue=e=>{const t={status:"idle",data:null,error:null},[n,r]=m.useReducer(Zt,t);return{mutate:m.useCallback(async s=>{r({type:"loading"});try{const a=await e(s);return r({type:"success",payload:a}),a}catch(a){r({type:"error",payload:a});return}},[e]),...n,isLoading:n.status==="loading",isSuccess:n.status==="success",isError:n.status==="error"}},ce=async(e,t,n,r)=>{if(!t)throw new Error(ne);const o=await fetch(e,{method:n,headers:{[rt]:t,"Content-Type":nt},...r&&{body:JSON.stringify(r)}});if(!o.ok){const s=await o.json();throw new Error(s.message||ot)}return o.status===204?Promise.resolve(void 0):o.json()},en=()=>{const{token:e}=H();if(!e)throw new Error(ne);return ue(async n=>await ce(et,e,"POST",n))},tn=()=>{const{token:e}=H();if(!e)throw new Error(ne);return ue(async n=>await ce(tt(n),e,"DELETE"))},nn=()=>{const{token:e}=H();return ue(async({variableId:n,payload:r})=>{if(!e)throw new Error("A Figma API token is required.");const o=tt(n);return await ce(o,e,"PUT",r)})},rn=()=>{const{token:e}=H();return ue(async n=>{if(!e)throw new Error(ne);return await ce(et,e,"PUT",n)})};function on(e,t){return e.filter(n=>{let r=!0;return t.resolvedType&&(r=r&&n.resolvedType===t.resolvedType),t.name&&(r=r&&n.name.includes(t.name)),r})}g.FigmaVarsProvider=mt,g.filterVariables=on,g.useBulkUpdateVariables=rn,g.useCreateVariable=en,g.useDeleteVariable=tn,g.useFigmaToken=Qt,g.useUpdateVariable=nn,g.useVariableCollections=zt,g.useVariableModes=Xt,g.useVariables=Le,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});