@uicopilot/storybook-addon 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/manager.mjs +52 -52
  2. package/package.json +1 -1
package/dist/manager.mjs CHANGED
@@ -1,47 +1,47 @@
1
- var yF=Object.create;var Ea=Object.defineProperty;var bF=Object.getOwnPropertyDescriptor;var SF=Object.getOwnPropertyNames;var wF=Object.getPrototypeOf,vF=Object.prototype.hasOwnProperty;var kF=(e,t,n)=>t in e?Ea(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var Jn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ye=(e,t)=>{for(var n in t)Ea(e,n,{get:t[n],enumerable:!0})},CF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of SF(t))!vF.call(e,o)&&o!==n&&Ea(e,o,{get:()=>t[o],enumerable:!(r=bF(t,o))||r.enumerable});return e};var Aa=(e,t,n)=>(n=e!=null?yF(wF(e)):{},CF(t||!e||!e.__esModule?Ea(n,"default",{value:e,enumerable:!0}):n,e));var Zn=(e,t,n)=>kF(e,typeof t!="symbol"?t+"":t,n);function Kx(){try{return typeof window<"u"&&localStorage.getItem(EF)==="true"}catch{return!1}}var EF,y,De=$(()=>{"use strict";EF="uicopilot:debug";y={debug:(...e)=>{Kx()&&console.log(...e)},info:(...e)=>{Kx()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import AF,{createContext as PF,useContext as LF,useReducer as MF,useMemo as Xx}from"react";function BF(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"RESET_AUTH":return typeof localStorage<"u"&&Object.keys(localStorage).filter(n=>n.startsWith("uicopilot_")).forEach(n=>localStorage.removeItem(n)),typeof sessionStorage<"u"&&Object.keys(sessionStorage).filter(n=>n.startsWith("uicopilot_")||n.startsWith("uicopilot-")).forEach(n=>sessionStorage.removeItem(n)),y.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function Zc({children:e}){let[t,n]=MF(BF,NF),r=Xx(()=>({setIsConnected:i=>n({type:"SET_STATE",payload:{isConnected:i}}),setSessionToken:i=>{y.debug("[AuthContext] setSessionToken:",i?i.substring(0,20)+"...":"null"),typeof localStorage<"u"&&(i?localStorage.setItem("uicopilot_session_token",i):localStorage.removeItem("uicopilot_session_token")),n({type:"SET_STATE",payload:{sessionToken:i,isConnected:!!i}})},setApiKey:i=>{typeof localStorage<"u"&&localStorage.setItem("uicopilot_api_key",i),n({type:"SET_STATE",payload:{apiKey:i}})},setAuthMethod:i=>n({type:"SET_STATE",payload:{authMethod:i}}),setDeviceCode:i=>n({type:"SET_STATE",payload:{deviceCode:i}}),setUserCode:i=>n({type:"SET_STATE",payload:{userCode:i}}),setVerificationUri:i=>n({type:"SET_STATE",payload:{verificationUri:i}}),setPollingInterval:i=>n({type:"SET_STATE",payload:{pollingInterval:i}}),setUsageData:i=>n({type:"SET_STATE",payload:{usageData:i,usageLastFetched:Date.now()}}),setAuthError:i=>n({type:"SET_STATE",payload:{authError:i}}),resetAuth:()=>n({type:"RESET_AUTH"})}),[]),o=Xx(()=>({...t,...r}),[t,r]);return AF.createElement(Jx.Provider,{value:o},e)}function we(){let e=LF(Jx);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var DF,RF,zF,Qx,NF,Jx,eu=$(()=>{"use strict";De();DF=()=>{if(typeof localStorage>"u")return;let e=localStorage.getItem("uicopilot-session-token");e&&!localStorage.getItem("uicopilot_session_token")&&(localStorage.setItem("uicopilot_session_token",e),localStorage.removeItem("uicopilot-session-token"));let t=localStorage.getItem("uicopilot-api-key");t&&!localStorage.getItem("uicopilot_api_key")&&(localStorage.setItem("uicopilot_api_key",t),localStorage.removeItem("uicopilot-api-key"))};DF();RF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),zF=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",Qx=RF(),NF={isConnected:!!Qx,sessionToken:Qx,apiKey:zF(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},Jx=PF(null)});import OF,{createContext as _F,useContext as $F,useReducer as UF,useMemo as Zx,useRef as jF,useEffect as HF}from"react";function WF(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"SET_PROJECTS":return{...e,projects:t.payload};case"ADD_PROJECT":return{...e,projects:[...e.projects,t.payload]};case"UPDATE_PROJECT":return{...e,projects:e.projects.map(n=>n.id===t.payload.id?{...n,...t.payload.updates}:n)};case"DELETE_PROJECT":return{...e,projects:e.projects.filter(n=>n.id!==t.payload),selectedProjectId:e.selectedProjectId===t.payload?null:e.selectedProjectId};default:return e}}function tu({children:e}){let[t,n]=UF(WF,GF),r=jF(t);HF(()=>{r.current=t},[t]);let o=Zx(()=>({setProjects:s=>n({type:"SET_PROJECTS",payload:s}),setSelectedProjectId:s=>{typeof localStorage<"u"&&(s?localStorage.setItem("uicopilot_selected_project_id",s):localStorage.removeItem("uicopilot_selected_project_id")),n({type:"SET_STATE",payload:{selectedProjectId:s}})},setLoadingProjects:s=>n({type:"SET_STATE",payload:{loadingProjects:s}}),setCurrentStorybookPath:s=>n({type:"SET_STATE",payload:{currentStorybookPath:s}}),addProject:s=>n({type:"ADD_PROJECT",payload:s}),updateProject:(s,a)=>n({type:"UPDATE_PROJECT",payload:{id:s,updates:a}}),deleteProject:s=>n({type:"DELETE_PROJECT",payload:s}),getSelectedProject:()=>{let s=r.current;return s.projects.find(a=>a.id===s.selectedProjectId)},getMatchingProject:()=>{let s=r.current;if(s.currentStorybookPath)return s.projects.find(a=>a.storybookRoot===s.currentStorybookPath)}}),[]),i=Zx(()=>({...t,...o}),[t,o]);return OF.createElement(ey.Provider,{value:i},e)}function Ze(){let e=$F(ey);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var VF,GF,ey,nu=$(()=>{"use strict";VF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),GF={projects:[],selectedProjectId:VF(),loadingProjects:!1,currentStorybookPath:null},ey=_F(null)});import qF,{createContext as YF,useContext as KF,useReducer as XF,useMemo as ty}from"react";function QF(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"REFRESH_MAPPINGS":return{...e,mappingsRefreshKey:e.mappingsRefreshKey+1};case"UPDATE_FRAMES_THUMBNAILS":return e.framesCache?{...e,framesCache:{...e.framesCache,thumbnails:{...e.framesCache.thumbnails,...t.payload}}}:e;case"SET_VARIANT_THUMBNAILS":{let n={...e.variantThumbnailsCache,[t.payload.componentSetId]:t.payload.thumbnails},r=Object.keys(n);if(r.length>ny)for(let o of r.slice(0,r.length-ny))delete n[o];return{...e,variantThumbnailsCache:n}}case"CLEAR_VARIANT_THUMBNAILS_FOR_SET":{let{[t.payload]:n,...r}=e.variantThumbnailsCache;return{...e,variantThumbnailsCache:r}}case"CLEAR_ALL_VARIANT_THUMBNAILS":return{...e,variantThumbnailsCache:{}};default:return e}}function ru({children:e}){let[t,n]=XF(QF,JF),r=ty(()=>({setShowComponentBrowser:i=>n({type:"SET_STATE",payload:{showComponentBrowser:i}}),setFigmaFileUrl:i=>n({type:"SET_STATE",payload:{figmaFileUrl:i}}),setCurrentStoryId:i=>n({type:"SET_STATE",payload:{currentStoryId:i}}),setCurrentStoryName:i=>n({type:"SET_STATE",payload:{currentStoryName:i}}),setCurrentMapping:i=>{n({type:"SET_STATE",payload:{currentMapping:i}})},refreshMappings:()=>n({type:"REFRESH_MAPPINGS"}),setReviewFigmaUrl:i=>n({type:"SET_STATE",payload:{reviewFigmaUrl:i}}),setMappingSource:i=>n({type:"SET_STATE",payload:{mappingSource:i}}),setLoadingMapping:i=>n({type:"SET_STATE",payload:{loadingMapping:i}}),setShowFigmaQuality:i=>n({type:"SET_STATE",payload:{showFigmaQuality:i}}),setFramesCache:i=>n({type:"SET_STATE",payload:{framesCache:i}}),setIsLoadingFrames:i=>n({type:"SET_STATE",payload:{isLoadingFrames:i}}),updateFramesThumbnails:i=>n({type:"UPDATE_FRAMES_THUMBNAILS",payload:i}),setVariantThumbnails:(i,s)=>n({type:"SET_VARIANT_THUMBNAILS",payload:{componentSetId:i,thumbnails:s}}),clearVariantThumbnailsForSet:i=>n({type:"CLEAR_VARIANT_THUMBNAILS_FOR_SET",payload:i}),clearAllVariantThumbnails:()=>n({type:"CLEAR_ALL_VARIANT_THUMBNAILS"})}),[]),o=ty(()=>({...t,...r}),[t,r]);return qF.createElement(ry.Provider,{value:o},e)}function rt(){let e=KF(ry);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var ny,JF,ry,ou=$(()=>{"use strict";ny=200;JF={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},ry=YF(null)});var oy=$(()=>{"use strict"});var iu=$(()=>{"use strict"});function _t(e){return e>=48&&e<=57}function Pn(e){return _t(e)||e>=65&&e<=70||e>=97&&e<=102}function Da(e){return e>=65&&e<=90}function eE(e){return e>=97&&e<=122}function tE(e){return Da(e)||eE(e)}function nE(e){return e>=128}function Ba(e){return tE(e)||nE(e)||e===95}function Ra(e){return Ba(e)||_t(e)||e===45}function rE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function os(e){return e===10||e===13||e===12}function Ar(e){return os(e)||e===32||e===9}function An(e,t){return!(e!==92||os(t)||t===0)}function oi(e,t,n){return e===45?Ba(t)||t===45||An(t,n):Ba(e)?!0:e===92?An(e,t):!1}function za(e,t,n){return e===43||e===45?_t(t)?2:t===46&&_t(n)?3:0:e===46?_t(t)?2:0:_t(e)?1:0}function Na(e){return e===65279||e===65534?1:0}function _a(e){return e<128?su[e]:Oa}var su,oE,is,au,Oa,lu,ss=$(()=>{"use strict";su=new Array(128),oE=128,is=130,au=131,Oa=132,lu=133;for(let e=0;e<su.length;e++)su[e]=Ar(e)&&is||_t(e)&&au||Ba(e)&&Oa||rE(e)&&lu||e||oE});function ii(e,t){return t<e.length?e.charCodeAt(t):0}function $a(e,t,n){return n===13&&ii(e,t+1)===10?2:1}function _r(e,t,n){let r=e.charCodeAt(t);return Da(r)&&(r=r|32),r===n}function $r(e,t,n,r){if(n-t!==r.length||t<0||n>e.length)return!1;for(let o=t;o<n;o++){let i=r.charCodeAt(o-t),s=e.charCodeAt(o);if(Da(s)&&(s=s|32),s!==i)return!1}return!0}function iy(e,t){for(;t>=0&&Ar(e.charCodeAt(t));t--);return t+1}function as(e,t){for(;t<e.length&&Ar(e.charCodeAt(t));t++);return t}function cu(e,t){for(;t<e.length&&_t(e.charCodeAt(t));t++);return t}function Ur(e,t){if(t+=2,Pn(ii(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Pn(ii(e,t));t++);let n=ii(e,t);Ar(n)&&(t+=$a(e,t,n))}return t}function ls(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Ra(n)){if(An(n,ii(e,t+1))){t=Ur(e,t)-1;continue}break}}return t}function Do(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),_t(n)&&(t=cu(e,t+1),n=e.charCodeAt(t)),n===46&&_t(e.charCodeAt(t+1))&&(t+=2,t=cu(e,t)),_r(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),_t(n)&&(t=cu(e,t+1+r+1))}return t}function Ua(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}An(n,ii(e,t+1))&&(t=Ur(e,t))}return t}function ja(e){if(e.length===1&&!Pn(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return(t===0||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var Ha=$(()=>{"use strict";ss()});var si,uu=$(()=>{"use strict";si=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"]});function ai(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var pu=$(()=>{"use strict"});function ly(e){let t=e.source,n=t.length,r=t.length>0?Na(t.charCodeAt(0)):0,o=ai(e.lines,n),i=ai(e.columns,n),s=e.startLine,a=e.startColumn;for(let u=r;u<n;u++){let c=t.charCodeAt(u);o[u]=s,i[u]=a++,(c===sy||c===ay||c===iE)&&(c===ay&&u+1<n&&t.charCodeAt(u+1)===sy&&(u++,o[u]=s,i[u]=a),s++,a=1)}o[n]=s,i[n]=a,e.lines=o,e.columns=i,e.computed=!0}var sy,iE,ay,Wa,cy=$(()=>{"use strict";pu();ss();sy=10,iE=12,ay=13;Wa=class{constructor(t,n,r,o){this.setSource(t,n,r,o),this.lines=null,this.columns=null}setSource(t="",n=0,r=1,o=1){this.source=t,this.startOffset=n,this.startLine=r,this.startColumn=o,this.computed=!1}getLocation(t,n){return this.computed||ly(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||ly(this),{source:r,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+n,line:this.lines[n],column:this.columns[n]}}}}});function uy(e,t,n){return e<t?t:e>n?n:e}var gr,mr,cs,Ga,ao,hr,Va,py=$(()=>{"use strict";pu();Ha();uu();gr=16777215,mr=24,cs=1,Ga=2,ao=new Uint8Array(32);ao[2]=22;ao[21]=22;ao[19]=20;ao[23]=24;hr=new Uint8Array(32);hr[2]=cs;hr[21]=cs;hr[19]=cs;hr[23]=cs;hr[22]=Ga;hr[20]=Ga;hr[24]=Ga;Va=class{constructor(t,n){this.setSource(t,n)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(t="",n=()=>{}){t=String(t||"");let r=t.length,o=ai(this.offsetAndType,t.length+1),i=ai(this.balance,t.length+1),s=0,a=-1,u=0,c=t.length;this.offsetAndType=null,this.balance=null,i.fill(0),n(t,(l,d,f)=>{let p=s++;if(o[p]=l<<mr|f,a===-1&&(a=d),i[p]=c,l===u){let g=i[c];i[c]=p,c=g,u=ao[o[g]>>mr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=ao[l])}),o[s]=0<<mr|r,i[s]=s;for(let l=0;l<s;l++){let d=i[l];if(d<=l){let f=i[d];f!==l&&(i[l]=f)}else d>s&&(i[l]=s)}this.source=t,this.firstCharOffset=a===-1?0:a,this.tokenCount=s,this.offsetAndType=o,this.balance=i,this.reset(),this.next()}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>mr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&gr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?$r(this.source,this.offsetAndType[t-1]&gr,this.offsetAndType[t]&gr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&gr:this.offsetAndType[this.tokenCount]&gr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[uy(t,0,this.tokenCount)]&gr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[uy(t,0,this.tokenCount)]>>mr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return hr[t]===cs}isBlockCloserTokenType(t){return hr[t]===Ga}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(hr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return ao[n]===o?r:-1}else if(hr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return ao[o]===n?r:-1}return-1}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,n){return n?this.lookupType(n)===9&&this.source.charCodeAt(this.lookupOffset(n))===t:this.tokenType===9&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let n=this.tokenIndex+t;n<this.tokenCount?(this.tokenIndex=n,this.tokenStart=this.offsetAndType[n-1]&gr,n=this.offsetAndType[n],this.tokenType=n>>mr,this.tokenEnd=n&gr):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>mr,this.tokenEnd=t&gr):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next()}skipUntilBalanced(t,n){let r=t,o=0,i=0;e:for(;r<this.tokenCount;r++){if(o=this.balance[r],o<t)break e;switch(i=r>0?this.offsetAndType[r-1]&gr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>mr)&&(r=o)}}this.skip(r-this.tokenIndex)}forEachToken(t){for(let n=0,r=this.firstCharOffset;n<this.tokenCount;n++){let o=r,i=this.offsetAndType[n],s=i&gr,a=i>>mr;r=s,t(a,o,s,n)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((n,r,o,i)=>{t[i]={idx:i,type:si[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function lo(e,t){function n(d){return d<a?e.charCodeAt(d):0}function r(){if(c=Do(e,c),oi(n(c),n(c+1),n(c+2))){l=12,c=ls(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=ls(e,c),$r(e,d,c,"url")&&n(c)===40){if(c=as(e,c+1),n(c)===34||n(c)===39){l=2,c=d+4;return}s();return}if(n(c)===40){l=2,c++;return}l=1}function i(d){for(d||(d=n(c++)),l=5;c<e.length;c++){let f=e.charCodeAt(c);switch(_a(f)){case d:c++;return;case is:if(os(f)){c+=$a(e,c,f),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);os(p)?c+=$a(e,c+1,p):An(f,p)&&(c=Ur(e,c)-1);break}}}function s(){for(l=7,c=as(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch(_a(d)){case 41:c++;return;case is:if(c=as(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=Ua(e,c),l=8;return;case 34:case 39:case 40:case lu:c=Ua(e,c),l=8;return;case 92:if(An(d,n(c+1))){c=Ur(e,c)-1;break}c=Ua(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=Na(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch(_a(d)){case is:l=13,c=as(e,c+1);break;case 34:i();break;case 35:Ra(n(c+1))||An(n(c+1),n(c+2))?(l=4,c=ls(e,c+1)):(l=9,c++);break;case 39:i();break;case 40:l=21,c++;break;case 41:l=22,c++;break;case 43:za(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:za(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):oi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:za(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 47:n(c+1)===42?(l=25,c=e.indexOf("*/",c+2),c=c===-1?e.length:c+2):(l=9,c++);break;case 58:l=16,c++;break;case 59:l=17,c++;break;case 60:n(c+1)===33&&n(c+2)===45&&n(c+3)===45?(l=14,c=c+4):(l=9,c++);break;case 64:oi(n(c+1),n(c+2),n(c+3))?(l=3,c=ls(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:An(d,n(c+1))?o():(l=9,c++);break;case 93:l=20,c++;break;case 123:l=23,c++;break;case 125:l=24,c++;break;case au:r();break;case Oa:o();break;default:l=9,c++}t(l,u,u=c)}}var nr=$(()=>{"use strict";ss();Ha();iu();iu();uu();ss();Ha();cy();py()});var li,Vn,ps=$(()=>{"use strict";li=null,Vn=class e{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return e.createItem(t)}allocateCursor(t,n){let r;return li!==null?(r=li,li=li.cursor,r.prev=t,r.next=n,r.cursor=this.cursor):r={prev:t,next:n,cursor:this.cursor},this.cursor=r,r}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=li,li=t}updateCursors(t,n,r,o){let{cursor:i}=this;for(;i!==null;)i.prev===t&&(i.prev=n),i.next===r&&(i.next=o),i=i.cursor}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data}get size(){let t=0;for(let n=this.head;n!==null;n=n.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let n=null;this.head=null;for(let r of t){let o=e.createItem(r);n!==null?n.next=o:this.head=o,o.prev=n,n=o}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,n=this){let r=this.allocateCursor(null,this.head);for(;r.next!==null;){let o=r.next;r.next=o.next,t.call(n,o.data,o,this)}this.releaseCursor()}forEachRight(t,n=this){let r=this.allocateCursor(this.tail,null);for(;r.prev!==null;){let o=r.prev;r.prev=o.prev,t.call(n,o.data,o,this)}this.releaseCursor()}reduce(t,n,r=this){let o=this.allocateCursor(null,this.head),i=n,s;for(;o.next!==null;)s=o.next,o.next=s.next,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}reduceRight(t,n,r=this){let o=this.allocateCursor(this.tail,null),i=n,s;for(;o.prev!==null;)s=o.prev,o.prev=s.prev,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}some(t,n=this){for(let r=this.head;r!==null;r=r.next)if(t.call(n,r.data,r,this))return!0;return!1}map(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)r.appendData(t.call(n,o.data,o,this));return r}filter(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)t.call(n,o.data,o,this)&&r.appendData(o.data);return r}nextUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(null,t);for(;o.next!==null;){let i=o.next;if(o.next=i.next,n.call(r,i.data,i,this))break}this.releaseCursor()}prevUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(t,null);for(;o.prev!==null;){let i=o.prev;if(o.prev=i.prev,n.call(r,i.data,i,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new e;for(let n of this)t.appendData(n);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(e.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(e.createItem(t))}insert(t,n=null){if(n!==null)if(this.updateCursors(n.prev,t,n,t),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=t,n.prev=t,t.next=n,this.updateCursors(null,t)}else n.prev.next=t,t.prev=n.prev,n.prev=t,t.next=n;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,n){return this.insert(e.createItem(t),n)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(t.next!==null)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(e.createItem(t))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(e.createItem(t))}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,n){return t.head===null?this:(n!=null?(this.updateCursors(n.prev,t.tail,n,t.head),n.prev!==null?(n.prev.next=t.head,t.head.prev=n.prev):this.head=t.head,n.prev=t.tail,t.tail.next=n):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,n){"head"in n?this.insertList(n,t):this.insert(n,t),this.remove(t)}}});function zo(e,t){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:e,message:t,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
2
- `)}})}var Ya=$(()=>{"use strict"});function gy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(g,S){return c.slice(g,S).map((C,F)=>String(g+F+1).padStart(f)+" |"+C).join(`
1
+ var xF=Object.create;var Aa=Object.defineProperty;var yF=Object.getOwnPropertyDescriptor;var bF=Object.getOwnPropertyNames;var SF=Object.getPrototypeOf,wF=Object.prototype.hasOwnProperty;var vF=(e,t,n)=>t in e?Aa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var Jn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ye=(e,t)=>{for(var n in t)Aa(e,n,{get:t[n],enumerable:!0})},kF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bF(t))!wF.call(e,o)&&o!==n&&Aa(e,o,{get:()=>t[o],enumerable:!(r=yF(t,o))||r.enumerable});return e};var Pa=(e,t,n)=>(n=e!=null?xF(SF(e)):{},kF(t||!e||!e.__esModule?Aa(n,"default",{value:e,enumerable:!0}):n,e));var Zn=(e,t,n)=>vF(e,typeof t!="symbol"?t+"":t,n);function Qx(){try{return typeof window<"u"&&localStorage.getItem(FF)==="true"}catch{return!1}}var FF,y,De=$(()=>{"use strict";FF="uicopilot:debug";y={debug:(...e)=>{Qx()&&console.log(...e)},info:(...e)=>{Qx()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import EF,{createContext as AF,useContext as PF,useReducer as LF,useMemo as Jx}from"react";function MF(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"RESET_AUTH":return typeof localStorage<"u"&&Object.keys(localStorage).filter(n=>n.startsWith("uicopilot_")).forEach(n=>localStorage.removeItem(n)),typeof sessionStorage<"u"&&Object.keys(sessionStorage).filter(n=>n.startsWith("uicopilot_")||n.startsWith("uicopilot-")).forEach(n=>sessionStorage.removeItem(n)),y.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function ru({children:e}){let[t,n]=LF(MF,zF),r=Jx(()=>({setIsConnected:i=>n({type:"SET_STATE",payload:{isConnected:i}}),setSessionToken:i=>{y.debug("[AuthContext] setSessionToken:",i?i.substring(0,20)+"...":"null"),typeof localStorage<"u"&&(i?localStorage.setItem("uicopilot_session_token",i):localStorage.removeItem("uicopilot_session_token")),n({type:"SET_STATE",payload:{sessionToken:i,isConnected:!!i}})},setApiKey:i=>{typeof localStorage<"u"&&localStorage.setItem("uicopilot_api_key",i),n({type:"SET_STATE",payload:{apiKey:i}})},setAuthMethod:i=>n({type:"SET_STATE",payload:{authMethod:i}}),setDeviceCode:i=>n({type:"SET_STATE",payload:{deviceCode:i}}),setUserCode:i=>n({type:"SET_STATE",payload:{userCode:i}}),setVerificationUri:i=>n({type:"SET_STATE",payload:{verificationUri:i}}),setPollingInterval:i=>n({type:"SET_STATE",payload:{pollingInterval:i}}),setUsageData:i=>n({type:"SET_STATE",payload:{usageData:i,usageLastFetched:Date.now()}}),setAuthError:i=>n({type:"SET_STATE",payload:{authError:i}}),resetAuth:()=>n({type:"RESET_AUTH"})}),[]),o=Jx(()=>({...t,...r}),[t,r]);return EF.createElement(ey.Provider,{value:o},e)}function we(){let e=PF(ey);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var BF,DF,RF,Zx,zF,ey,ou=$(()=>{"use strict";De();BF=()=>{if(typeof localStorage>"u")return;let e=localStorage.getItem("uicopilot-session-token");e&&!localStorage.getItem("uicopilot_session_token")&&(localStorage.setItem("uicopilot_session_token",e),localStorage.removeItem("uicopilot-session-token"));let t=localStorage.getItem("uicopilot-api-key");t&&!localStorage.getItem("uicopilot_api_key")&&(localStorage.setItem("uicopilot_api_key",t),localStorage.removeItem("uicopilot-api-key"))};BF();DF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),RF=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",Zx=DF(),zF={isConnected:!!Zx,sessionToken:Zx,apiKey:RF(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},ey=AF(null)});import NF,{createContext as OF,useContext as _F,useReducer as $F,useMemo as ty,useRef as UF,useEffect as jF}from"react";function HF(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"SET_PROJECTS":return{...e,projects:t.payload};case"ADD_PROJECT":return{...e,projects:[...e.projects,t.payload]};case"UPDATE_PROJECT":return{...e,projects:e.projects.map(n=>n.id===t.payload.id?{...n,...t.payload.updates}:n)};case"DELETE_PROJECT":return{...e,projects:e.projects.filter(n=>n.id!==t.payload),selectedProjectId:e.selectedProjectId===t.payload?null:e.selectedProjectId};default:return e}}function iu({children:e}){let[t,n]=$F(HF,VF),r=UF(t);jF(()=>{r.current=t},[t]);let o=ty(()=>({setProjects:s=>n({type:"SET_PROJECTS",payload:s}),setSelectedProjectId:s=>{typeof localStorage<"u"&&(s?localStorage.setItem("uicopilot_selected_project_id",s):localStorage.removeItem("uicopilot_selected_project_id")),n({type:"SET_STATE",payload:{selectedProjectId:s}})},setLoadingProjects:s=>n({type:"SET_STATE",payload:{loadingProjects:s}}),setCurrentStorybookPath:s=>n({type:"SET_STATE",payload:{currentStorybookPath:s}}),addProject:s=>n({type:"ADD_PROJECT",payload:s}),updateProject:(s,a)=>n({type:"UPDATE_PROJECT",payload:{id:s,updates:a}}),deleteProject:s=>n({type:"DELETE_PROJECT",payload:s}),getSelectedProject:()=>{let s=r.current;return s.projects.find(a=>a.id===s.selectedProjectId)},getMatchingProject:()=>{let s=r.current;if(s.currentStorybookPath)return s.projects.find(a=>a.storybookRoot===s.currentStorybookPath)}}),[]),i=ty(()=>({...t,...o}),[t,o]);return NF.createElement(ny.Provider,{value:i},e)}function Ze(){let e=_F(ny);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var WF,VF,ny,su=$(()=>{"use strict";WF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),VF={projects:[],selectedProjectId:WF(),loadingProjects:!1,currentStorybookPath:null},ny=OF(null)});import GF,{createContext as qF,useContext as YF,useReducer as KF,useMemo as ry}from"react";function XF(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"REFRESH_MAPPINGS":return{...e,mappingsRefreshKey:e.mappingsRefreshKey+1};case"UPDATE_FRAMES_THUMBNAILS":return e.framesCache?{...e,framesCache:{...e.framesCache,thumbnails:{...e.framesCache.thumbnails,...t.payload}}}:e;case"SET_VARIANT_THUMBNAILS":{let n={...e.variantThumbnailsCache,[t.payload.componentSetId]:t.payload.thumbnails},r=Object.keys(n);if(r.length>oy)for(let o of r.slice(0,r.length-oy))delete n[o];return{...e,variantThumbnailsCache:n}}case"CLEAR_VARIANT_THUMBNAILS_FOR_SET":{let{[t.payload]:n,...r}=e.variantThumbnailsCache;return{...e,variantThumbnailsCache:r}}case"CLEAR_ALL_VARIANT_THUMBNAILS":return{...e,variantThumbnailsCache:{}};default:return e}}function au({children:e}){let[t,n]=KF(XF,QF),r=ry(()=>({setShowComponentBrowser:i=>n({type:"SET_STATE",payload:{showComponentBrowser:i}}),setFigmaFileUrl:i=>n({type:"SET_STATE",payload:{figmaFileUrl:i}}),setCurrentStoryId:i=>n({type:"SET_STATE",payload:{currentStoryId:i}}),setCurrentStoryName:i=>n({type:"SET_STATE",payload:{currentStoryName:i}}),setCurrentMapping:i=>{n({type:"SET_STATE",payload:{currentMapping:i}})},refreshMappings:()=>n({type:"REFRESH_MAPPINGS"}),setReviewFigmaUrl:i=>n({type:"SET_STATE",payload:{reviewFigmaUrl:i}}),setMappingSource:i=>n({type:"SET_STATE",payload:{mappingSource:i}}),setLoadingMapping:i=>n({type:"SET_STATE",payload:{loadingMapping:i}}),setShowFigmaQuality:i=>n({type:"SET_STATE",payload:{showFigmaQuality:i}}),setFramesCache:i=>n({type:"SET_STATE",payload:{framesCache:i}}),setIsLoadingFrames:i=>n({type:"SET_STATE",payload:{isLoadingFrames:i}}),updateFramesThumbnails:i=>n({type:"UPDATE_FRAMES_THUMBNAILS",payload:i}),setVariantThumbnails:(i,s)=>n({type:"SET_VARIANT_THUMBNAILS",payload:{componentSetId:i,thumbnails:s}}),clearVariantThumbnailsForSet:i=>n({type:"CLEAR_VARIANT_THUMBNAILS_FOR_SET",payload:i}),clearAllVariantThumbnails:()=>n({type:"CLEAR_ALL_VARIANT_THUMBNAILS"})}),[]),o=ry(()=>({...t,...r}),[t,r]);return GF.createElement(iy.Provider,{value:o},e)}function rt(){let e=YF(iy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var oy,QF,iy,lu=$(()=>{"use strict";oy=200;QF={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},iy=qF(null)});var sy=$(()=>{"use strict"});var cu=$(()=>{"use strict"});function _t(e){return e>=48&&e<=57}function Pn(e){return _t(e)||e>=65&&e<=70||e>=97&&e<=102}function Ra(e){return e>=65&&e<=90}function ZF(e){return e>=97&&e<=122}function eE(e){return Ra(e)||ZF(e)}function tE(e){return e>=128}function Da(e){return eE(e)||tE(e)||e===95}function za(e){return Da(e)||_t(e)||e===45}function nE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function os(e){return e===10||e===13||e===12}function Ar(e){return os(e)||e===32||e===9}function An(e,t){return!(e!==92||os(t)||t===0)}function oi(e,t,n){return e===45?Da(t)||t===45||An(t,n):Da(e)?!0:e===92?An(e,t):!1}function Na(e,t,n){return e===43||e===45?_t(t)?2:t===46&&_t(n)?3:0:e===46?_t(t)?2:0:_t(e)?1:0}function Oa(e){return e===65279||e===65534?1:0}function $a(e){return e<128?uu[e]:_a}var uu,rE,is,pu,_a,du,ss=$(()=>{"use strict";uu=new Array(128),rE=128,is=130,pu=131,_a=132,du=133;for(let e=0;e<uu.length;e++)uu[e]=Ar(e)&&is||_t(e)&&pu||Da(e)&&_a||nE(e)&&du||e||rE});function ii(e,t){return t<e.length?e.charCodeAt(t):0}function Ua(e,t,n){return n===13&&ii(e,t+1)===10?2:1}function _r(e,t,n){let r=e.charCodeAt(t);return Ra(r)&&(r=r|32),r===n}function $r(e,t,n,r){if(n-t!==r.length||t<0||n>e.length)return!1;for(let o=t;o<n;o++){let i=r.charCodeAt(o-t),s=e.charCodeAt(o);if(Ra(s)&&(s=s|32),s!==i)return!1}return!0}function ay(e,t){for(;t>=0&&Ar(e.charCodeAt(t));t--);return t+1}function as(e,t){for(;t<e.length&&Ar(e.charCodeAt(t));t++);return t}function fu(e,t){for(;t<e.length&&_t(e.charCodeAt(t));t++);return t}function Ur(e,t){if(t+=2,Pn(ii(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Pn(ii(e,t));t++);let n=ii(e,t);Ar(n)&&(t+=Ua(e,t,n))}return t}function ls(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!za(n)){if(An(n,ii(e,t+1))){t=Ur(e,t)-1;continue}break}}return t}function Do(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),_t(n)&&(t=fu(e,t+1),n=e.charCodeAt(t)),n===46&&_t(e.charCodeAt(t+1))&&(t+=2,t=fu(e,t)),_r(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),_t(n)&&(t=fu(e,t+1+r+1))}return t}function ja(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}An(n,ii(e,t+1))&&(t=Ur(e,t))}return t}function Ha(e){if(e.length===1&&!Pn(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return(t===0||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var Wa=$(()=>{"use strict";ss()});var si,gu=$(()=>{"use strict";si=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"]});function ai(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var mu=$(()=>{"use strict"});function uy(e){let t=e.source,n=t.length,r=t.length>0?Oa(t.charCodeAt(0)):0,o=ai(e.lines,n),i=ai(e.columns,n),s=e.startLine,a=e.startColumn;for(let u=r;u<n;u++){let c=t.charCodeAt(u);o[u]=s,i[u]=a++,(c===ly||c===cy||c===oE)&&(c===cy&&u+1<n&&t.charCodeAt(u+1)===ly&&(u++,o[u]=s,i[u]=a),s++,a=1)}o[n]=s,i[n]=a,e.lines=o,e.columns=i,e.computed=!0}var ly,oE,cy,Va,py=$(()=>{"use strict";mu();ss();ly=10,oE=12,cy=13;Va=class{constructor(t,n,r,o){this.setSource(t,n,r,o),this.lines=null,this.columns=null}setSource(t="",n=0,r=1,o=1){this.source=t,this.startOffset=n,this.startLine=r,this.startColumn=o,this.computed=!1}getLocation(t,n){return this.computed||uy(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||uy(this),{source:r,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+n,line:this.lines[n],column:this.columns[n]}}}}});function dy(e,t,n){return e<t?t:e>n?n:e}var gr,mr,cs,qa,ao,hr,Ga,fy=$(()=>{"use strict";mu();Wa();gu();gr=16777215,mr=24,cs=1,qa=2,ao=new Uint8Array(32);ao[2]=22;ao[21]=22;ao[19]=20;ao[23]=24;hr=new Uint8Array(32);hr[2]=cs;hr[21]=cs;hr[19]=cs;hr[23]=cs;hr[22]=qa;hr[20]=qa;hr[24]=qa;Ga=class{constructor(t,n){this.setSource(t,n)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(t="",n=()=>{}){t=String(t||"");let r=t.length,o=ai(this.offsetAndType,t.length+1),i=ai(this.balance,t.length+1),s=0,a=-1,u=0,c=t.length;this.offsetAndType=null,this.balance=null,i.fill(0),n(t,(l,d,f)=>{let p=s++;if(o[p]=l<<mr|f,a===-1&&(a=d),i[p]=c,l===u){let g=i[c];i[c]=p,c=g,u=ao[o[g]>>mr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=ao[l])}),o[s]=0<<mr|r,i[s]=s;for(let l=0;l<s;l++){let d=i[l];if(d<=l){let f=i[d];f!==l&&(i[l]=f)}else d>s&&(i[l]=s)}this.source=t,this.firstCharOffset=a===-1?0:a,this.tokenCount=s,this.offsetAndType=o,this.balance=i,this.reset(),this.next()}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>mr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&gr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>mr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?$r(this.source,this.offsetAndType[t-1]&gr,this.offsetAndType[t]&gr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&gr:this.offsetAndType[this.tokenCount]&gr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[dy(t,0,this.tokenCount)]&gr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[dy(t,0,this.tokenCount)]>>mr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return hr[t]===cs}isBlockCloserTokenType(t){return hr[t]===qa}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(hr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return ao[n]===o?r:-1}else if(hr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return ao[o]===n?r:-1}return-1}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,n){return n?this.lookupType(n)===9&&this.source.charCodeAt(this.lookupOffset(n))===t:this.tokenType===9&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let n=this.tokenIndex+t;n<this.tokenCount?(this.tokenIndex=n,this.tokenStart=this.offsetAndType[n-1]&gr,n=this.offsetAndType[n],this.tokenType=n>>mr,this.tokenEnd=n&gr):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>mr,this.tokenEnd=t&gr):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next()}skipUntilBalanced(t,n){let r=t,o=0,i=0;e:for(;r<this.tokenCount;r++){if(o=this.balance[r],o<t)break e;switch(i=r>0?this.offsetAndType[r-1]&gr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>mr)&&(r=o)}}this.skip(r-this.tokenIndex)}forEachToken(t){for(let n=0,r=this.firstCharOffset;n<this.tokenCount;n++){let o=r,i=this.offsetAndType[n],s=i&gr,a=i>>mr;r=s,t(a,o,s,n)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((n,r,o,i)=>{t[i]={idx:i,type:si[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function lo(e,t){function n(d){return d<a?e.charCodeAt(d):0}function r(){if(c=Do(e,c),oi(n(c),n(c+1),n(c+2))){l=12,c=ls(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=ls(e,c),$r(e,d,c,"url")&&n(c)===40){if(c=as(e,c+1),n(c)===34||n(c)===39){l=2,c=d+4;return}s();return}if(n(c)===40){l=2,c++;return}l=1}function i(d){for(d||(d=n(c++)),l=5;c<e.length;c++){let f=e.charCodeAt(c);switch($a(f)){case d:c++;return;case is:if(os(f)){c+=Ua(e,c,f),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);os(p)?c+=Ua(e,c+1,p):An(f,p)&&(c=Ur(e,c)-1);break}}}function s(){for(l=7,c=as(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch($a(d)){case 41:c++;return;case is:if(c=as(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=ja(e,c),l=8;return;case 34:case 39:case 40:case du:c=ja(e,c),l=8;return;case 92:if(An(d,n(c+1))){c=Ur(e,c)-1;break}c=ja(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=Oa(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch($a(d)){case is:l=13,c=as(e,c+1);break;case 34:i();break;case 35:za(n(c+1))||An(n(c+1),n(c+2))?(l=4,c=ls(e,c+1)):(l=9,c++);break;case 39:i();break;case 40:l=21,c++;break;case 41:l=22,c++;break;case 43:Na(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Na(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):oi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Na(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 47:n(c+1)===42?(l=25,c=e.indexOf("*/",c+2),c=c===-1?e.length:c+2):(l=9,c++);break;case 58:l=16,c++;break;case 59:l=17,c++;break;case 60:n(c+1)===33&&n(c+2)===45&&n(c+3)===45?(l=14,c=c+4):(l=9,c++);break;case 64:oi(n(c+1),n(c+2),n(c+3))?(l=3,c=ls(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:An(d,n(c+1))?o():(l=9,c++);break;case 93:l=20,c++;break;case 123:l=23,c++;break;case 125:l=24,c++;break;case pu:r();break;case _a:o();break;default:l=9,c++}t(l,u,u=c)}}var nr=$(()=>{"use strict";ss();Wa();cu();cu();gu();ss();Wa();py();fy()});var li,Vn,ps=$(()=>{"use strict";li=null,Vn=class e{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return e.createItem(t)}allocateCursor(t,n){let r;return li!==null?(r=li,li=li.cursor,r.prev=t,r.next=n,r.cursor=this.cursor):r={prev:t,next:n,cursor:this.cursor},this.cursor=r,r}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=li,li=t}updateCursors(t,n,r,o){let{cursor:i}=this;for(;i!==null;)i.prev===t&&(i.prev=n),i.next===r&&(i.next=o),i=i.cursor}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data}get size(){let t=0;for(let n=this.head;n!==null;n=n.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let n=null;this.head=null;for(let r of t){let o=e.createItem(r);n!==null?n.next=o:this.head=o,o.prev=n,n=o}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,n=this){let r=this.allocateCursor(null,this.head);for(;r.next!==null;){let o=r.next;r.next=o.next,t.call(n,o.data,o,this)}this.releaseCursor()}forEachRight(t,n=this){let r=this.allocateCursor(this.tail,null);for(;r.prev!==null;){let o=r.prev;r.prev=o.prev,t.call(n,o.data,o,this)}this.releaseCursor()}reduce(t,n,r=this){let o=this.allocateCursor(null,this.head),i=n,s;for(;o.next!==null;)s=o.next,o.next=s.next,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}reduceRight(t,n,r=this){let o=this.allocateCursor(this.tail,null),i=n,s;for(;o.prev!==null;)s=o.prev,o.prev=s.prev,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}some(t,n=this){for(let r=this.head;r!==null;r=r.next)if(t.call(n,r.data,r,this))return!0;return!1}map(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)r.appendData(t.call(n,o.data,o,this));return r}filter(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)t.call(n,o.data,o,this)&&r.appendData(o.data);return r}nextUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(null,t);for(;o.next!==null;){let i=o.next;if(o.next=i.next,n.call(r,i.data,i,this))break}this.releaseCursor()}prevUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(t,null);for(;o.prev!==null;){let i=o.prev;if(o.prev=i.prev,n.call(r,i.data,i,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new e;for(let n of this)t.appendData(n);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(e.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(e.createItem(t))}insert(t,n=null){if(n!==null)if(this.updateCursors(n.prev,t,n,t),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=t,n.prev=t,t.next=n,this.updateCursors(null,t)}else n.prev.next=t,t.prev=n.prev,n.prev=t,t.next=n;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,n){return this.insert(e.createItem(t),n)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(t.next!==null)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(e.createItem(t))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(e.createItem(t))}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,n){return t.head===null?this:(n!=null?(this.updateCursors(n.prev,t.tail,n,t.head),n.prev!==null?(n.prev.next=t.head,t.head.prev=n.prev):this.head=t.head,n.prev=t.tail,t.tail.next=n):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,n){"head"in n?this.insertList(n,t):this.insert(n,t),this.remove(t)}}});function zo(e,t){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:e,message:t,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
2
+ `)}})}var Ka=$(()=>{"use strict"});function hy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(g,S){return c.slice(g,S).map((C,F)=>String(g+F+1).padStart(f)+" |"+C).join(`
3
3
  `)}let a=`
4
- `.repeat(Math.max(r-1,0)),u=" ".repeat(Math.max(o-1,0)),c=(a+u+e).split(/\r\n?|\n|\f/),l=Math.max(1,t-i)-1,d=Math.min(t+i,c.length+1),f=Math.max(4,String(d).length)+1,p=0;n+=(fy.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>du&&(p=n-dy+3,n=dy-2);for(let g=l;g<=d;g++)g>=0&&g<c.length&&(c[g]=c[g].replace(/\t/g,fy),c[g]=(p>0&&c[g].length>p?"\u2026":"")+c[g].substr(p,du-2)+(c[g].length>p+du-1?"\u2026":""));return[s(l,t),new Array(n+f+2).join("-")+"^",s(t,d)].filter(Boolean).join(`
5
- `).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function fu(e,t,n,r,o,i=1,s=1){return Object.assign(zo("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return gy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
6
- `+gy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var du,dy,fy,my=$(()=>{"use strict";Ya();du=100,dy=60,fy=" "});function hy(e){let t=this.createList(),n=!1,r={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:n=!0,this.next();continue}let o=e.getNode.call(this,r);if(o===void 0)break;n&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,o,t,r),n=!1),t.push(o)}return n&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,r),t}var xy=$(()=>{"use strict"});function uE(e){return function(){return this[e]()}}function mu(e){let t=Object.create(null);for(let n of Object.keys(e)){let r=e[n],o=r.parse||r;o&&(t[n]=o)}return t}function pE(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:mu(e.atrule),pseudo:mu(e.pseudo),node:mu(e.node)};for(let[n,r]of Object.entries(e.parseContext))switch(typeof r){case"function":t.context[n]=r;break;case"string":t.context[n]=uE(r);break}return{config:t,...t,...t.node}}function Sy(e){let t="",n="<unknown>",r=!1,o=ci,i=!1,s=new Wa,a=Object.assign(new Va,pE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:hy,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===yy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===yy||l===gu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===sE||l===gu?1:0},consumeUntilSemicolonIncluded(l){return l===gu?2:0},createList:ci,createSingleNodeList:ci,getFirstListNode:ci,getLastListNode:ci,parseWithFallback(l,d){let f=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(f-this.tokenIndex);let g=d.call(this);return i=!0,o(p,g),i=!1,g}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==by);return by},charCodeAt(l){return l>=0&&l<t.length?t.charCodeAt(l):0},substring(l,d){return t.substring(l,d)},substrToCursor(l){return this.source.substring(l,this.tokenStart)},cmpChar(l,d){return _r(t,l,d)},cmpStr(l,d,f){return $r(t,l,d,f)},consume(l){let d=this.tokenStart;return this.eat(l),this.substrToCursor(d)},consumeFunctionName(){let l=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),l},consumeNumber(l){let d=t.substring(this.tokenStart,Do(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=si[l].slice(0,-6).replace(/-/g," ").replace(/^./,g=>g.toUpperCase()),f=`${/[[\](){}]/.test(d)?`"${d}"`:d} is expected`,p=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(p=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(aE)&&(this.next(),p++,f="Name is expected");break;case 11:this.tokenType===10&&(p=this.tokenEnd,f="Percent sign is expected");break}this.error(f,p)}this.next()},eatIdent(l){(this.tokenType!==1||this.lookupValue(0,l)===!1)&&this.error(`Identifier "${l}" is expected`),this.next()},eatDelim(l){this.isDelim(l)||this.error(`Delim "${String.fromCharCode(l)}" is expected`),this.next()},getLocation(l,d){return r?s.getLocationRange(l,d,n):null},getLocationFromList(l){if(r){let d=this.getFirstListNode(l),f=this.getLastListNode(l);return s.getLocationRange(d!==null?d.loc.start.offset-s.startOffset:this.tokenStart,f!==null?f.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,d){let f=typeof d<"u"&&d<t.length?s.getLocation(d):this.eof?s.getLocation(iy(t,t.length-1)):s.getLocation(this.tokenStart);throw new fu(l||"Unexpected input",t,f.offset,f.line,f.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>si[a.getTokenType(l)],getTokenStart:l=>a.getTokenStart(l),getTokenEnd:l=>a.getTokenEnd(l),getTokenValue:l=>a.source.substring(a.getTokenStart(l),a.getTokenEnd(l)),substring:(l,d)=>a.source.substring(l,d),balance:a.balance.subarray(0,a.tokenCount+1),isBlockOpenerTokenType:a.isBlockOpenerTokenType,isBlockCloserTokenType:a.isBlockCloserTokenType,getBlockTokenPairIndex:l=>a.getBlockTokenPairIndex(l),getLocation:l=>s.getLocation(l,n),getRangeLocation:(l,d)=>s.getLocationRange(l,d,n)});return Object.assign(function(l,d){t=l,d=d||{},a.setSource(t,lo),s.setSource(t,d.offset,d.line,d.column),n=d.filename||"<unknown>",r=!!d.positions,o=typeof d.onParseError=="function"?d.onParseError:ci,i=!1,a.parseAtrulePrelude="parseAtrulePrelude"in d?!!d.parseAtrulePrelude:!0,a.parseRulePrelude="parseRulePrelude"in d?!!d.parseRulePrelude:!0,a.parseValue="parseValue"in d?!!d.parseValue:!0,a.parseCustomProperty="parseCustomProperty"in d?!!d.parseCustomProperty:!1;let{context:f="default",list:p=!0,onComment:g,onToken:S}=d;if(!(f in a.context))throw new Error("Unknown context `"+f+"`");Object.assign(a,p?cE:lE),Array.isArray(S)?a.forEachToken((F,k,R)=>{S.push({type:F,start:k,end:R})}):typeof S=="function"&&a.forEachToken(S.bind(u())),typeof g=="function"&&a.forEachToken((F,k,R)=>{if(F===25){let z=a.getLocation(k,R),_=$r(t,R-2,R,"*/")?t.slice(k+2,R-2):t.slice(k+2,R);g(_,z)}});let C=a.context[f].call(a,d);return a.eof||a.error(),C},{SyntaxError:fu,config:a.config})}var ci,sE,aE,gu,yy,by,lE,cE,wy=$(()=>{"use strict";ps();my();nr();xy();ci=()=>{},sE=33,aE=35,gu=59,yy=123,by=0,lE={createList(){return[]},createSingleNodeList(e){return[e]},getFirstListNode(e){return e&&e[0]||null},getLastListNode(e){return e&&e.length>0?e[e.length-1]:null}},cE={createList(){return new Vn},createSingleNodeList(e){return new Vn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var ky=Jn(hu=>{"use strict";var vy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");hu.encode=function(e){if(0<=e&&e<vy.length)return vy[e];throw new TypeError("Must be between 0 and 63: "+e)};hu.decode=function(e){var t=65,n=90,r=97,o=122,i=48,s=57,a=43,u=47,c=26,l=52;return t<=e&&e<=n?e-t:r<=e&&e<=o?e-r+c:i<=e&&e<=s?e-i+l:e==a?62:e==u?63:-1}});var Ey=Jn(yu=>{"use strict";var Cy=ky(),xu=5,Ty=1<<xu,Iy=Ty-1,Fy=Ty;function dE(e){return e<0?(-e<<1)+1:(e<<1)+0}function fE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}yu.encode=function(t){var n="",r,o=dE(t);do r=o&Iy,o>>>=xu,o>0&&(r|=Fy),n+=Cy.encode(r);while(o>0);return n};yu.decode=function(t,n,r){var o=t.length,i=0,s=0,a,u;do{if(n>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(u=Cy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Fy),u&=Iy,i=i+(u<<s),s+=xu}while(a);r.value=fE(i),r.rest=n}});var Ka=Jn(nn=>{"use strict";function gE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}nn.getArg=gE;var Ay=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,mE=/^data:.+\,.+$/;function ds(e){var t=e.match(Ay);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}nn.urlParse=ds;function ui(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}nn.urlGenerate=ui;var hE=32;function xE(e){var t=[];return function(n){for(var r=0;r<t.length;r++)if(t[r].input===n){var o=t[0];return t[0]=t[r],t[r]=o,t[0].result}var i=e(n);return t.unshift({input:n,result:i}),t.length>hE&&t.pop(),i}}var bu=xE(function(t){var n=t,r=ds(t);if(r){if(!r.path)return t;n=r.path}for(var o=nn.isAbsolute(n),i=[],s=0,a=0;;)if(s=a,a=n.indexOf("/",s),a===-1){i.push(n.slice(s));break}else for(i.push(n.slice(s,a));a<n.length&&n[a]==="/";)a++;for(var u,c=0,a=i.length-1;a>=0;a--)u=i[a],u==="."?i.splice(a,1):u===".."?c++:c>0&&(u===""?(i.splice(a+1,c),c=0):(i.splice(a,2),c--));return n=i.join("/"),n===""&&(n=o?"/":"."),r?(r.path=n,ui(r)):n});nn.normalize=bu;function Py(e,t){e===""&&(e="."),t===""&&(t=".");var n=ds(t),r=ds(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),ui(n);if(n||t.match(mE))return t;if(r&&!r.host&&!r.path)return r.host=t,ui(r);var o=t.charAt(0)==="/"?t:bu(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,ui(r)):o}nn.join=Py;nn.isAbsolute=function(e){return e.charAt(0)==="/"||Ay.test(e)};function yE(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var n=0;t.indexOf(e+"/")!==0;){var r=e.lastIndexOf("/");if(r<0||(e=e.slice(0,r),e.match(/^([^\/]+:\/)?\/*$/)))return t;++n}return Array(n+1).join("../")+t.substr(e.length+1)}nn.relative=yE;var Ly=(function(){var e=Object.create(null);return!("__proto__"in e)})();function My(e){return e}function bE(e){return By(e)?"$"+e:e}nn.toSetString=Ly?My:bE;function SE(e){return By(e)?e.slice(1):e}nn.fromSetString=Ly?My:SE;function By(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var n=t-10;n>=0;n--)if(e.charCodeAt(n)!==36)return!1;return!0}function wE(e,t,n){var r=jr(e.source,t.source);return r!==0||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:jr(e.name,t.name)}nn.compareByOriginalPositions=wE;function vE(e,t,n){var r;return r=e.originalLine-t.originalLine,r!==0||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:jr(e.name,t.name)}nn.compareByOriginalPositionsNoSource=vE;function kE(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:jr(e.name,t.name)}nn.compareByGeneratedPositionsDeflated=kE;function CE(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:jr(e.name,t.name)}nn.compareByGeneratedPositionsDeflatedNoLine=CE;function jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function TE(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=jr(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:jr(e.name,t.name)}nn.compareByGeneratedPositionsInflated=TE;function IE(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}nn.parseSourceMapInput=IE;function FE(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ds(n);if(!r)throw new Error("sourceMapURL could not be parsed");if(r.path){var o=r.path.lastIndexOf("/");o>=0&&(r.path=r.path.substring(0,o+1))}t=Py(ui(r),t)}return bu(t)}nn.computeSourceURL=FE});var Ry=Jn(Dy=>{"use strict";var Su=Ka(),wu=Object.prototype.hasOwnProperty,No=typeof Map<"u";function Hr(){this._array=[],this._set=No?new Map:Object.create(null)}Hr.fromArray=function(t,n){for(var r=new Hr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Hr.prototype.size=function(){return No?this._set.size:Object.getOwnPropertyNames(this._set).length};Hr.prototype.add=function(t,n){var r=No?t:Su.toSetString(t),o=No?this.has(t):wu.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(No?this._set.set(t,i):this._set[r]=i)};Hr.prototype.has=function(t){if(No)return this._set.has(t);var n=Su.toSetString(t);return wu.call(this._set,n)};Hr.prototype.indexOf=function(t){if(No){var n=this._set.get(t);if(n>=0)return n}else{var r=Su.toSetString(t);if(wu.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Hr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Hr.prototype.toArray=function(){return this._array.slice()};Dy.ArraySet=Hr});var Oy=Jn(Ny=>{"use strict";var zy=Ka();function EE(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||zy.compareByGeneratedPositionsInflated(e,t)<=0}function Xa(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Xa.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};Xa.prototype.add=function(t){EE(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Xa.prototype.toArray=function(){return this._sorted||(this._array.sort(zy.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};Ny.MappingList=Xa});var $y=Jn(_y=>{"use strict";var fs=Ey(),$t=Ka(),Qa=Ry().ArraySet,AE=Oy().MappingList;function rr(e){e||(e={}),this._file=$t.getArg(e,"file",null),this._sourceRoot=$t.getArg(e,"sourceRoot",null),this._skipValidation=$t.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=$t.getArg(e,"ignoreInvalidMapping",!1),this._sources=new Qa,this._names=new Qa,this._mappings=new AE,this._sourcesContents=null}rr.prototype._version=3;rr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new rr(Object.assign(n||{},{file:t.file,sourceRoot:r}));return t.eachMapping(function(i){var s={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(s.source=i.source,r!=null&&(s.source=$t.relative(r,s.source)),s.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(s.name=i.name)),o.addMapping(s)}),t.sources.forEach(function(i){var s=i;r!==null&&(s=$t.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};rr.prototype.addMapping=function(t){var n=$t.getArg(t,"generated"),r=$t.getArg(t,"original",null),o=$t.getArg(t,"source",null),i=$t.getArg(t,"name",null);!this._skipValidation&&this._validateMapping(n,r,o,i)===!1||(o!=null&&(o=String(o),this._sources.has(o)||this._sources.add(o)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:r!=null&&r.line,originalColumn:r!=null&&r.column,source:o,name:i}))};rr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=$t.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[$t.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[$t.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};rr.prototype.applySourceMap=function(t,n,r){var o=n;if(n==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=t.file}var i=this._sourceRoot;i!=null&&(o=$t.relative(i,o));var s=new Qa,a=new Qa;this._mappings.unsortedForEach(function(u){if(u.source===o&&u.originalLine!=null){var c=t.originalPositionFor({line:u.originalLine,column:u.originalColumn});c.source!=null&&(u.source=c.source,r!=null&&(u.source=$t.join(r,u.source)),i!=null&&(u.source=$t.relative(i,u.source)),u.originalLine=c.line,u.originalColumn=c.column,c.name!=null&&(u.name=c.name))}var l=u.source;l!=null&&!s.has(l)&&s.add(l);var d=u.name;d!=null&&!a.has(d)&&a.add(d)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){var c=t.sourceContentFor(u);c!=null&&(r!=null&&(u=$t.join(r,u)),i!=null&&(u=$t.relative(i,u)),this.setSourceContent(u,c))},this)};rr.prototype._validateMapping=function(t,n,r,o){if(n&&typeof n.line!="number"&&typeof n.column!="number"){var i="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!n&&!r&&!o)){if(t&&"line"in t&&"column"in t&&n&&"line"in n&&"column"in n&&t.line>0&&t.column>=0&&n.line>0&&n.column>=0&&r)return;var i="Invalid mapping: "+JSON.stringify({generated:t,source:r,original:n,name:o});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}};rr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,d,f=this._mappings.toArray(),p=0,g=f.length;p<g;p++){if(c=f[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!$t.compareByGeneratedPositionsInflated(c,f[p-1]))continue;u+=","}u+=fs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(d=this._sources.indexOf(c.source),u+=fs.encode(d-s),s=d,u+=fs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=fs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=fs.encode(l-i),i=l)),a+=u}return a};rr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=$t.relative(n,r));var o=$t.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};rr.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};rr.prototype.toString=function(){return JSON.stringify(this.toJSON())};_y.SourceMapGenerator=rr});function Hy(e){let t=new jy.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},i={generated:o},s=1,a=0,u=!1,c=e.node;e.node=function(f){if(f.loc&&f.loc.start&&Uy.has(f.type)){let p=f.loc.start.line,g=f.loc.start.column-1;(r.line!==p||r.column!==g)&&(r.line=p,r.column=g,n.line=s,n.column=a,u&&(u=!1,(n.line!==o.line||n.column!==o.column)&&t.addMapping(i)),u=!0,t.addMapping({source:f.loc.source,original:r,generated:n}))}c.call(this,f),u&&Uy.has(f.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(f,p,g){for(let S=0;S<f.length;S++)f.charCodeAt(S)===10?(s++,a=0):a++;l(f,p,g)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var jy,Uy,Wy=$(()=>{"use strict";jy=Aa($y(),1),Uy=new Set(["Atrule","Selector","Declaration"])});var Ja={};ye(Ja,{safe:()=>ku,spec:()=>BE});function Gy(e){let t=new Set(e.map(([n,r])=>vu(n)<<16|vu(r)));return function(n,r,o){let i=vu(r,o),s=o.charCodeAt(0),a=s===LE&&r!==1&&r!==2&&r!==15||s===PE?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var PE,LE,vu,Vy,ME,BE,ku,qy=$(()=>{"use strict";PE=43,LE=45,vu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),Vy=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],ME=Vy.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);BE=Gy(Vy),ku=Gy(ME)});function RE(e,t){if(typeof t=="function"){let n=null;e.children.forEach(r=>{n!==null&&t.call(this,n),this.node(r),n=r});return}e.children.forEach(this.node,this)}function Yy(e){let t=new Map;for(let[n,r]of Object.entries(e.node))typeof(r.generate||r)=="function"&&t.set(n,r.generate||r);return function(n,r){let o="",i=0,s={node(u){if(t.has(u.type))t.get(u.type).call(a,u);else throw new Error("Unknown node type: "+u.type)},tokenBefore:ku,token(u,c,l){i=this.tokenBefore(i,u,c),!l&&i&1&&this.emit(" ",13,!0),this.emit(c,u,!1),u===9&&c.charCodeAt(0)===DE&&this.emit(`
7
- `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=Hy(s)),r.mode in Ja&&(s.tokenBefore=Ja[r.mode]));let a={node:u=>s.node(u),children:RE,token:(u,c)=>s.token(u,c),tokenize:u=>lo(u,(c,l,d)=>{s.token(c,u.slice(l,d),l!==0)})};return s.node(n),s.result()}}var DE,Ky=$(()=>{"use strict";nr();Wy();qy();DE=92});function Xy(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Vn)&&(n.children=new Vn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Vn&&(n.children=n.children.toArray())}}),t}}}var Qy=$(()=>{"use strict";ps()});function Jy(e){return typeof e=="function"?e:gs}function Zy(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function zE(e,t){let n=t.structure,r=[];for(let o in n){if(Cu.call(n,o)===!1)continue;let i=n[o],s={name:o,type:!1,nullable:!1};Array.isArray(i)||(i=[i]);for(let a of i)a===null?s.nullable=!0:typeof a=="string"?s.type="node":Array.isArray(a)&&(s.type="list");s.type&&r.push(s)}return r.length?{context:t.walkContext,fields:r}:null}function NE(e){let t={};for(let n in e.node)if(Cu.call(e.node,n)){let r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=zE(n,r)}return t}function eb(e,t){let n=e.fields.slice(),r=e.context,o=typeof r=="string";return t&&n.reverse(),function(i,s,a,u){let c;o&&(c=s[r],s[r]=i);for(let l of n){let d=i[l.name];if(!l.nullable||d){if(l.type==="list"){if(t?d.reduceRight(u,!1):d.reduce(u,!1))return!0}else if(a(d))return!0}}o&&(s[r]=c)}}function tb({StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}){return{Atrule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Rule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Declaration:{StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}}}function nb(e){let t=NE(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Cu.call(t,c)&&t[c]!==null&&(n[c]=eb(t[c],!1),r[c]=eb(t[c],!0));let s=tb(n),a=tb(r),u=function(c,l){function d(F,k,R){let z=f.call(C,F,k,R);return z===o?!0:z===i?!1:!!(g.hasOwnProperty(F.type)&&g[F.type](F,C,d,S)||p.call(C,F,k,R)===o)}let f=gs,p=gs,g=n,S=(F,k,R,z)=>F||d(k,R,z),C={break:o,skip:i,root:c,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")f=l;else if(l&&(f=Jy(l.enter),p=Jy(l.leave),l.reverse&&(g=r),l.visit)){if(s.hasOwnProperty(l.visit))g=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");f=Zy(f,l.visit),p=Zy(p,l.visit)}if(f===gs&&p===gs)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");d(c)};return u.break=o,u.skip=i,u.find=function(c,l){let d=null;return u(c,function(f,p,g){if(l.call(this,f,p,g))return d=f,o}),d},u.findLast=function(c,l){let d=null;return u(c,{reverse:!0,enter(f,p,g){if(l.call(this,f,p,g))return d=f,o}}),d},u.findAll=function(c,l){let d=[];return u(c,function(f,p,g){l.call(this,f,p,g)&&d.push(f)}),d},u}var Cu,gs,rb=$(()=>{"use strict";({hasOwnProperty:Cu}=Object.prototype),gs=function(){}});function OE(e){return e}function _E(e){let{min:t,max:n,comma:r}=e;return t===0&&n===0?r?"#?":"*":t===0&&n===1?"?":t===1&&n===0?r?"#":"+":t===1&&n===1?"":(r?"#":"")+(t===n?"{"+t+"}":"{"+t+","+(n!==0?n:"")+"}")}function $E(e){if(e.type==="Range")return" ["+(e.min===null?"-\u221E":e.min)+","+(e.max===null?"\u221E":e.max)+"]";throw new Error("Unknown node type `"+e.type+"`")}function UE(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>Za(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function Za(e,t,n,r){let o;switch(e.type){case"Group":o=UE(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return Za(e.term,t,n,r)+t(_E(e),e);case"Boolean":o="<boolean-expr["+Za(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t($E(e.opts),e.opts):"")+">";break;case"Property":o="<'"+e.name+"'>";break;case"Keyword":o=e.name;break;case"AtKeyword":o="@"+e.name;break;case"Function":o=e.name+"(";break;case"String":case"Token":o=e.value;break;case"Comma":o=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(o,e)}function pi(e,t){let n=OE,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),Za(e,n,r,o)}var Tu=$(()=>{"use strict"});function jE(e,t){let n=e.tokens,r=e.longestMatch,o=r<n.length&&n[r].node||null,i=o!==t?o:null,s=0,a=0,u=0,c="",l,d;for(let f=0;f<n.length;f++){let p=n[f].value;f===r&&(a=p.length,s=c.length),i!==null&&n[f].node===i&&(f<=r?u++:u=0),c+=p}return r===n.length||u>1?(l=el(i||t,"end")||ms(ob,c),d=ms(l)):(l=el(i,"start")||ms(el(t,"start")||ob,c.slice(0,s)),d=el(i,"end")||ms(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:d}}function el(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?ms(n):n:null}function ms({offset:e,line:t,column:n},r){let o={offset:e,line:t,column:n};if(r){let i=r.split(/\n|\r\n?|\f/);o.offset+=r.length,o.line+=i.length-1,o.column=i.length===1?o.column+r.length:i.pop().length+1}return o}var ob,di,ib,sb=$(()=>{"use strict";Ya();Tu();ob={offset:0,line:1,column:1};di=function(e,t){let n=zo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},ib=function(e,t,n,r){let o=zo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=jE(r,n);return o.rawMessage=e,o.syntax=t?pi(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=a,o.message=e+`
4
+ `.repeat(Math.max(r-1,0)),u=" ".repeat(Math.max(o-1,0)),c=(a+u+e).split(/\r\n?|\n|\f/),l=Math.max(1,t-i)-1,d=Math.min(t+i,c.length+1),f=Math.max(4,String(d).length)+1,p=0;n+=(my.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>hu&&(p=n-gy+3,n=gy-2);for(let g=l;g<=d;g++)g>=0&&g<c.length&&(c[g]=c[g].replace(/\t/g,my),c[g]=(p>0&&c[g].length>p?"\u2026":"")+c[g].substr(p,hu-2)+(c[g].length>p+hu-1?"\u2026":""));return[s(l,t),new Array(n+f+2).join("-")+"^",s(t,d)].filter(Boolean).join(`
5
+ `).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function xu(e,t,n,r,o,i=1,s=1){return Object.assign(zo("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return hy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
6
+ `+hy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var hu,gy,my,xy=$(()=>{"use strict";Ka();hu=100,gy=60,my=" "});function yy(e){let t=this.createList(),n=!1,r={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:n=!0,this.next();continue}let o=e.getNode.call(this,r);if(o===void 0)break;n&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,o,t,r),n=!1),t.push(o)}return n&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,r),t}var by=$(()=>{"use strict"});function cE(e){return function(){return this[e]()}}function bu(e){let t=Object.create(null);for(let n of Object.keys(e)){let r=e[n],o=r.parse||r;o&&(t[n]=o)}return t}function uE(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:bu(e.atrule),pseudo:bu(e.pseudo),node:bu(e.node)};for(let[n,r]of Object.entries(e.parseContext))switch(typeof r){case"function":t.context[n]=r;break;case"string":t.context[n]=cE(r);break}return{config:t,...t,...t.node}}function vy(e){let t="",n="<unknown>",r=!1,o=ci,i=!1,s=new Va,a=Object.assign(new Ga,uE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:yy,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Sy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Sy||l===yu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===iE||l===yu?1:0},consumeUntilSemicolonIncluded(l){return l===yu?2:0},createList:ci,createSingleNodeList:ci,getFirstListNode:ci,getLastListNode:ci,parseWithFallback(l,d){let f=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(f-this.tokenIndex);let g=d.call(this);return i=!0,o(p,g),i=!1,g}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==wy);return wy},charCodeAt(l){return l>=0&&l<t.length?t.charCodeAt(l):0},substring(l,d){return t.substring(l,d)},substrToCursor(l){return this.source.substring(l,this.tokenStart)},cmpChar(l,d){return _r(t,l,d)},cmpStr(l,d,f){return $r(t,l,d,f)},consume(l){let d=this.tokenStart;return this.eat(l),this.substrToCursor(d)},consumeFunctionName(){let l=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),l},consumeNumber(l){let d=t.substring(this.tokenStart,Do(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=si[l].slice(0,-6).replace(/-/g," ").replace(/^./,g=>g.toUpperCase()),f=`${/[[\](){}]/.test(d)?`"${d}"`:d} is expected`,p=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(p=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(sE)&&(this.next(),p++,f="Name is expected");break;case 11:this.tokenType===10&&(p=this.tokenEnd,f="Percent sign is expected");break}this.error(f,p)}this.next()},eatIdent(l){(this.tokenType!==1||this.lookupValue(0,l)===!1)&&this.error(`Identifier "${l}" is expected`),this.next()},eatDelim(l){this.isDelim(l)||this.error(`Delim "${String.fromCharCode(l)}" is expected`),this.next()},getLocation(l,d){return r?s.getLocationRange(l,d,n):null},getLocationFromList(l){if(r){let d=this.getFirstListNode(l),f=this.getLastListNode(l);return s.getLocationRange(d!==null?d.loc.start.offset-s.startOffset:this.tokenStart,f!==null?f.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,d){let f=typeof d<"u"&&d<t.length?s.getLocation(d):this.eof?s.getLocation(ay(t,t.length-1)):s.getLocation(this.tokenStart);throw new xu(l||"Unexpected input",t,f.offset,f.line,f.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>si[a.getTokenType(l)],getTokenStart:l=>a.getTokenStart(l),getTokenEnd:l=>a.getTokenEnd(l),getTokenValue:l=>a.source.substring(a.getTokenStart(l),a.getTokenEnd(l)),substring:(l,d)=>a.source.substring(l,d),balance:a.balance.subarray(0,a.tokenCount+1),isBlockOpenerTokenType:a.isBlockOpenerTokenType,isBlockCloserTokenType:a.isBlockCloserTokenType,getBlockTokenPairIndex:l=>a.getBlockTokenPairIndex(l),getLocation:l=>s.getLocation(l,n),getRangeLocation:(l,d)=>s.getLocationRange(l,d,n)});return Object.assign(function(l,d){t=l,d=d||{},a.setSource(t,lo),s.setSource(t,d.offset,d.line,d.column),n=d.filename||"<unknown>",r=!!d.positions,o=typeof d.onParseError=="function"?d.onParseError:ci,i=!1,a.parseAtrulePrelude="parseAtrulePrelude"in d?!!d.parseAtrulePrelude:!0,a.parseRulePrelude="parseRulePrelude"in d?!!d.parseRulePrelude:!0,a.parseValue="parseValue"in d?!!d.parseValue:!0,a.parseCustomProperty="parseCustomProperty"in d?!!d.parseCustomProperty:!1;let{context:f="default",list:p=!0,onComment:g,onToken:S}=d;if(!(f in a.context))throw new Error("Unknown context `"+f+"`");Object.assign(a,p?lE:aE),Array.isArray(S)?a.forEachToken((F,k,R)=>{S.push({type:F,start:k,end:R})}):typeof S=="function"&&a.forEachToken(S.bind(u())),typeof g=="function"&&a.forEachToken((F,k,R)=>{if(F===25){let z=a.getLocation(k,R),_=$r(t,R-2,R,"*/")?t.slice(k+2,R-2):t.slice(k+2,R);g(_,z)}});let C=a.context[f].call(a,d);return a.eof||a.error(),C},{SyntaxError:xu,config:a.config})}var ci,iE,sE,yu,Sy,wy,aE,lE,ky=$(()=>{"use strict";ps();xy();nr();by();ci=()=>{},iE=33,sE=35,yu=59,Sy=123,wy=0,aE={createList(){return[]},createSingleNodeList(e){return[e]},getFirstListNode(e){return e&&e[0]||null},getLastListNode(e){return e&&e.length>0?e[e.length-1]:null}},lE={createList(){return new Vn},createSingleNodeList(e){return new Vn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var Ty=Jn(Su=>{"use strict";var Cy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Su.encode=function(e){if(0<=e&&e<Cy.length)return Cy[e];throw new TypeError("Must be between 0 and 63: "+e)};Su.decode=function(e){var t=65,n=90,r=97,o=122,i=48,s=57,a=43,u=47,c=26,l=52;return t<=e&&e<=n?e-t:r<=e&&e<=o?e-r+c:i<=e&&e<=s?e-i+l:e==a?62:e==u?63:-1}});var Py=Jn(vu=>{"use strict";var Iy=Ty(),wu=5,Fy=1<<wu,Ey=Fy-1,Ay=Fy;function pE(e){return e<0?(-e<<1)+1:(e<<1)+0}function dE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}vu.encode=function(t){var n="",r,o=pE(t);do r=o&Ey,o>>>=wu,o>0&&(r|=Ay),n+=Iy.encode(r);while(o>0);return n};vu.decode=function(t,n,r){var o=t.length,i=0,s=0,a,u;do{if(n>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(u=Iy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Ay),u&=Ey,i=i+(u<<s),s+=wu}while(a);r.value=dE(i),r.rest=n}});var Xa=Jn(nn=>{"use strict";function fE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}nn.getArg=fE;var Ly=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,gE=/^data:.+\,.+$/;function ds(e){var t=e.match(Ly);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}nn.urlParse=ds;function ui(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}nn.urlGenerate=ui;var mE=32;function hE(e){var t=[];return function(n){for(var r=0;r<t.length;r++)if(t[r].input===n){var o=t[0];return t[0]=t[r],t[r]=o,t[0].result}var i=e(n);return t.unshift({input:n,result:i}),t.length>mE&&t.pop(),i}}var ku=hE(function(t){var n=t,r=ds(t);if(r){if(!r.path)return t;n=r.path}for(var o=nn.isAbsolute(n),i=[],s=0,a=0;;)if(s=a,a=n.indexOf("/",s),a===-1){i.push(n.slice(s));break}else for(i.push(n.slice(s,a));a<n.length&&n[a]==="/";)a++;for(var u,c=0,a=i.length-1;a>=0;a--)u=i[a],u==="."?i.splice(a,1):u===".."?c++:c>0&&(u===""?(i.splice(a+1,c),c=0):(i.splice(a,2),c--));return n=i.join("/"),n===""&&(n=o?"/":"."),r?(r.path=n,ui(r)):n});nn.normalize=ku;function My(e,t){e===""&&(e="."),t===""&&(t=".");var n=ds(t),r=ds(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),ui(n);if(n||t.match(gE))return t;if(r&&!r.host&&!r.path)return r.host=t,ui(r);var o=t.charAt(0)==="/"?t:ku(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,ui(r)):o}nn.join=My;nn.isAbsolute=function(e){return e.charAt(0)==="/"||Ly.test(e)};function xE(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var n=0;t.indexOf(e+"/")!==0;){var r=e.lastIndexOf("/");if(r<0||(e=e.slice(0,r),e.match(/^([^\/]+:\/)?\/*$/)))return t;++n}return Array(n+1).join("../")+t.substr(e.length+1)}nn.relative=xE;var By=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Dy(e){return e}function yE(e){return Ry(e)?"$"+e:e}nn.toSetString=By?Dy:yE;function bE(e){return Ry(e)?e.slice(1):e}nn.fromSetString=By?Dy:bE;function Ry(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var n=t-10;n>=0;n--)if(e.charCodeAt(n)!==36)return!1;return!0}function SE(e,t,n){var r=jr(e.source,t.source);return r!==0||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:jr(e.name,t.name)}nn.compareByOriginalPositions=SE;function wE(e,t,n){var r;return r=e.originalLine-t.originalLine,r!==0||(r=e.originalColumn-t.originalColumn,r!==0||n)||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e.generatedLine-t.generatedLine,r!==0)?r:jr(e.name,t.name)}nn.compareByOriginalPositionsNoSource=wE;function vE(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:jr(e.name,t.name)}nn.compareByGeneratedPositionsDeflated=vE;function kE(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=jr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:jr(e.name,t.name)}nn.compareByGeneratedPositionsDeflatedNoLine=kE;function jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function CE(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=jr(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:jr(e.name,t.name)}nn.compareByGeneratedPositionsInflated=CE;function TE(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}nn.parseSourceMapInput=TE;function IE(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ds(n);if(!r)throw new Error("sourceMapURL could not be parsed");if(r.path){var o=r.path.lastIndexOf("/");o>=0&&(r.path=r.path.substring(0,o+1))}t=My(ui(r),t)}return ku(t)}nn.computeSourceURL=IE});var Ny=Jn(zy=>{"use strict";var Cu=Xa(),Tu=Object.prototype.hasOwnProperty,No=typeof Map<"u";function Hr(){this._array=[],this._set=No?new Map:Object.create(null)}Hr.fromArray=function(t,n){for(var r=new Hr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Hr.prototype.size=function(){return No?this._set.size:Object.getOwnPropertyNames(this._set).length};Hr.prototype.add=function(t,n){var r=No?t:Cu.toSetString(t),o=No?this.has(t):Tu.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(No?this._set.set(t,i):this._set[r]=i)};Hr.prototype.has=function(t){if(No)return this._set.has(t);var n=Cu.toSetString(t);return Tu.call(this._set,n)};Hr.prototype.indexOf=function(t){if(No){var n=this._set.get(t);if(n>=0)return n}else{var r=Cu.toSetString(t);if(Tu.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Hr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Hr.prototype.toArray=function(){return this._array.slice()};zy.ArraySet=Hr});var $y=Jn(_y=>{"use strict";var Oy=Xa();function FE(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||Oy.compareByGeneratedPositionsInflated(e,t)<=0}function Qa(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Qa.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};Qa.prototype.add=function(t){FE(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Qa.prototype.toArray=function(){return this._sorted||(this._array.sort(Oy.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};_y.MappingList=Qa});var jy=Jn(Uy=>{"use strict";var fs=Py(),$t=Xa(),Ja=Ny().ArraySet,EE=$y().MappingList;function rr(e){e||(e={}),this._file=$t.getArg(e,"file",null),this._sourceRoot=$t.getArg(e,"sourceRoot",null),this._skipValidation=$t.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=$t.getArg(e,"ignoreInvalidMapping",!1),this._sources=new Ja,this._names=new Ja,this._mappings=new EE,this._sourcesContents=null}rr.prototype._version=3;rr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new rr(Object.assign(n||{},{file:t.file,sourceRoot:r}));return t.eachMapping(function(i){var s={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(s.source=i.source,r!=null&&(s.source=$t.relative(r,s.source)),s.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(s.name=i.name)),o.addMapping(s)}),t.sources.forEach(function(i){var s=i;r!==null&&(s=$t.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};rr.prototype.addMapping=function(t){var n=$t.getArg(t,"generated"),r=$t.getArg(t,"original",null),o=$t.getArg(t,"source",null),i=$t.getArg(t,"name",null);!this._skipValidation&&this._validateMapping(n,r,o,i)===!1||(o!=null&&(o=String(o),this._sources.has(o)||this._sources.add(o)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:r!=null&&r.line,originalColumn:r!=null&&r.column,source:o,name:i}))};rr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=$t.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[$t.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[$t.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};rr.prototype.applySourceMap=function(t,n,r){var o=n;if(n==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=t.file}var i=this._sourceRoot;i!=null&&(o=$t.relative(i,o));var s=new Ja,a=new Ja;this._mappings.unsortedForEach(function(u){if(u.source===o&&u.originalLine!=null){var c=t.originalPositionFor({line:u.originalLine,column:u.originalColumn});c.source!=null&&(u.source=c.source,r!=null&&(u.source=$t.join(r,u.source)),i!=null&&(u.source=$t.relative(i,u.source)),u.originalLine=c.line,u.originalColumn=c.column,c.name!=null&&(u.name=c.name))}var l=u.source;l!=null&&!s.has(l)&&s.add(l);var d=u.name;d!=null&&!a.has(d)&&a.add(d)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){var c=t.sourceContentFor(u);c!=null&&(r!=null&&(u=$t.join(r,u)),i!=null&&(u=$t.relative(i,u)),this.setSourceContent(u,c))},this)};rr.prototype._validateMapping=function(t,n,r,o){if(n&&typeof n.line!="number"&&typeof n.column!="number"){var i="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!n&&!r&&!o)){if(t&&"line"in t&&"column"in t&&n&&"line"in n&&"column"in n&&t.line>0&&t.column>=0&&n.line>0&&n.column>=0&&r)return;var i="Invalid mapping: "+JSON.stringify({generated:t,source:r,original:n,name:o});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}};rr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,d,f=this._mappings.toArray(),p=0,g=f.length;p<g;p++){if(c=f[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!$t.compareByGeneratedPositionsInflated(c,f[p-1]))continue;u+=","}u+=fs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(d=this._sources.indexOf(c.source),u+=fs.encode(d-s),s=d,u+=fs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=fs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=fs.encode(l-i),i=l)),a+=u}return a};rr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=$t.relative(n,r));var o=$t.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};rr.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};rr.prototype.toString=function(){return JSON.stringify(this.toJSON())};Uy.SourceMapGenerator=rr});function Vy(e){let t=new Wy.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},i={generated:o},s=1,a=0,u=!1,c=e.node;e.node=function(f){if(f.loc&&f.loc.start&&Hy.has(f.type)){let p=f.loc.start.line,g=f.loc.start.column-1;(r.line!==p||r.column!==g)&&(r.line=p,r.column=g,n.line=s,n.column=a,u&&(u=!1,(n.line!==o.line||n.column!==o.column)&&t.addMapping(i)),u=!0,t.addMapping({source:f.loc.source,original:r,generated:n}))}c.call(this,f),u&&Hy.has(f.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(f,p,g){for(let S=0;S<f.length;S++)f.charCodeAt(S)===10?(s++,a=0):a++;l(f,p,g)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var Wy,Hy,Gy=$(()=>{"use strict";Wy=Pa(jy(),1),Hy=new Set(["Atrule","Selector","Declaration"])});var Za={};ye(Za,{safe:()=>Fu,spec:()=>ME});function Yy(e){let t=new Set(e.map(([n,r])=>Iu(n)<<16|Iu(r)));return function(n,r,o){let i=Iu(r,o),s=o.charCodeAt(0),a=s===PE&&r!==1&&r!==2&&r!==15||s===AE?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var AE,PE,Iu,qy,LE,ME,Fu,Ky=$(()=>{"use strict";AE=43,PE=45,Iu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),qy=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],LE=qy.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);ME=Yy(qy),Fu=Yy(LE)});function DE(e,t){if(typeof t=="function"){let n=null;e.children.forEach(r=>{n!==null&&t.call(this,n),this.node(r),n=r});return}e.children.forEach(this.node,this)}function Xy(e){let t=new Map;for(let[n,r]of Object.entries(e.node))typeof(r.generate||r)=="function"&&t.set(n,r.generate||r);return function(n,r){let o="",i=0,s={node(u){if(t.has(u.type))t.get(u.type).call(a,u);else throw new Error("Unknown node type: "+u.type)},tokenBefore:Fu,token(u,c,l){i=this.tokenBefore(i,u,c),!l&&i&1&&this.emit(" ",13,!0),this.emit(c,u,!1),u===9&&c.charCodeAt(0)===BE&&this.emit(`
7
+ `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=Vy(s)),r.mode in Za&&(s.tokenBefore=Za[r.mode]));let a={node:u=>s.node(u),children:DE,token:(u,c)=>s.token(u,c),tokenize:u=>lo(u,(c,l,d)=>{s.token(c,u.slice(l,d),l!==0)})};return s.node(n),s.result()}}var BE,Qy=$(()=>{"use strict";nr();Gy();Ky();BE=92});function Jy(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Vn)&&(n.children=new Vn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Vn&&(n.children=n.children.toArray())}}),t}}}var Zy=$(()=>{"use strict";ps()});function eb(e){return typeof e=="function"?e:gs}function tb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function RE(e,t){let n=t.structure,r=[];for(let o in n){if(Eu.call(n,o)===!1)continue;let i=n[o],s={name:o,type:!1,nullable:!1};Array.isArray(i)||(i=[i]);for(let a of i)a===null?s.nullable=!0:typeof a=="string"?s.type="node":Array.isArray(a)&&(s.type="list");s.type&&r.push(s)}return r.length?{context:t.walkContext,fields:r}:null}function zE(e){let t={};for(let n in e.node)if(Eu.call(e.node,n)){let r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=RE(n,r)}return t}function nb(e,t){let n=e.fields.slice(),r=e.context,o=typeof r=="string";return t&&n.reverse(),function(i,s,a,u){let c;o&&(c=s[r],s[r]=i);for(let l of n){let d=i[l.name];if(!l.nullable||d){if(l.type==="list"){if(t?d.reduceRight(u,!1):d.reduce(u,!1))return!0}else if(a(d))return!0}}o&&(s[r]=c)}}function rb({StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}){return{Atrule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Rule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Declaration:{StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:o}}}function ob(e){let t=zE(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Eu.call(t,c)&&t[c]!==null&&(n[c]=nb(t[c],!1),r[c]=nb(t[c],!0));let s=rb(n),a=rb(r),u=function(c,l){function d(F,k,R){let z=f.call(C,F,k,R);return z===o?!0:z===i?!1:!!(g.hasOwnProperty(F.type)&&g[F.type](F,C,d,S)||p.call(C,F,k,R)===o)}let f=gs,p=gs,g=n,S=(F,k,R,z)=>F||d(k,R,z),C={break:o,skip:i,root:c,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")f=l;else if(l&&(f=eb(l.enter),p=eb(l.leave),l.reverse&&(g=r),l.visit)){if(s.hasOwnProperty(l.visit))g=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");f=tb(f,l.visit),p=tb(p,l.visit)}if(f===gs&&p===gs)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");d(c)};return u.break=o,u.skip=i,u.find=function(c,l){let d=null;return u(c,function(f,p,g){if(l.call(this,f,p,g))return d=f,o}),d},u.findLast=function(c,l){let d=null;return u(c,{reverse:!0,enter(f,p,g){if(l.call(this,f,p,g))return d=f,o}}),d},u.findAll=function(c,l){let d=[];return u(c,function(f,p,g){l.call(this,f,p,g)&&d.push(f)}),d},u}var Eu,gs,ib=$(()=>{"use strict";({hasOwnProperty:Eu}=Object.prototype),gs=function(){}});function NE(e){return e}function OE(e){let{min:t,max:n,comma:r}=e;return t===0&&n===0?r?"#?":"*":t===0&&n===1?"?":t===1&&n===0?r?"#":"+":t===1&&n===1?"":(r?"#":"")+(t===n?"{"+t+"}":"{"+t+","+(n!==0?n:"")+"}")}function _E(e){if(e.type==="Range")return" ["+(e.min===null?"-\u221E":e.min)+","+(e.max===null?"\u221E":e.max)+"]";throw new Error("Unknown node type `"+e.type+"`")}function $E(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>el(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function el(e,t,n,r){let o;switch(e.type){case"Group":o=$E(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return el(e.term,t,n,r)+t(OE(e),e);case"Boolean":o="<boolean-expr["+el(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(_E(e.opts),e.opts):"")+">";break;case"Property":o="<'"+e.name+"'>";break;case"Keyword":o=e.name;break;case"AtKeyword":o="@"+e.name;break;case"Function":o=e.name+"(";break;case"String":case"Token":o=e.value;break;case"Comma":o=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(o,e)}function pi(e,t){let n=NE,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),el(e,n,r,o)}var Au=$(()=>{"use strict"});function UE(e,t){let n=e.tokens,r=e.longestMatch,o=r<n.length&&n[r].node||null,i=o!==t?o:null,s=0,a=0,u=0,c="",l,d;for(let f=0;f<n.length;f++){let p=n[f].value;f===r&&(a=p.length,s=c.length),i!==null&&n[f].node===i&&(f<=r?u++:u=0),c+=p}return r===n.length||u>1?(l=tl(i||t,"end")||ms(sb,c),d=ms(l)):(l=tl(i,"start")||ms(tl(t,"start")||sb,c.slice(0,s)),d=tl(i,"end")||ms(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:d}}function tl(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?ms(n):n:null}function ms({offset:e,line:t,column:n},r){let o={offset:e,line:t,column:n};if(r){let i=r.split(/\n|\r\n?|\f/);o.offset+=r.length,o.line+=i.length-1,o.column=i.length===1?o.column+r.length:i.pop().length+1}return o}var sb,di,ab,lb=$(()=>{"use strict";Ka();Au();sb={offset:0,line:1,column:1};di=function(e,t){let n=zo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},ab=function(e,t,n,r){let o=zo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=UE(r,n);return o.rawMessage=e,o.syntax=t?pi(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=a,o.message=e+`
8
8
  syntax: `+o.syntax+`
9
9
  value: `+(i||"<empty string>")+`
10
- --------`+new Array(o.mismatchOffset+1).join("-")+"^",Object.assign(o,u),o.loc={source:n&&n.loc&&n.loc.source||"<unknown>",start:u,end:c},o}});function ol(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===nl&&e.charCodeAt(t+1)===nl}function ab(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===nl&&e.charCodeAt(t+1)!==nl){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function HE(e){if(tl.has(e))return tl.get(e);let t=e.toLowerCase(),n=tl.get(t);if(n===void 0){let r=ol(t,0),o=r?"":ab(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return tl.set(e,n),n}function WE(e){if(fi.has(e))return fi.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=ol(t,n.length);if(!r&&(t=t.toLowerCase(),fi.has(t))){let a=fi.get(t);return fi.set(e,a),a}let o=r?"":ab(t,n.length),i=t.substr(0,n.length+o.length),s=Object.freeze({basename:t.substr(i.length),name:t.substr(n.length),hack:n,vendor:o,prefix:i,custom:r});return fi.set(e,s),s}var tl,fi,nl,rl,Iu,il=$(()=>{"use strict";tl=new Map,fi=new Map,nl=45,rl=HE,Iu=WE});var gi,sl=$(()=>{"use strict";gi=["initial","inherit","unset","revert","revert-layer"]});function Au(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function hs(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function co(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===xs||o===Pr){if(n)return 0;t++}for(;t<e.value.length;t++)if(!_t(e.value.charCodeAt(t)))return 0;return r+1}function Eu(e,t,n){let r=!1,o=hs(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(Au(e,xs)||Au(e,Pr)){if(r=!0,o=hs(n(++o),o,n),e=n(o),e===null||e.type!==10)return 0}else return t;if(!r){let i=e.value.charCodeAt(0);if(i!==xs&&i!==Pr)return 0}return co(e,r?0:1,r,o)}function Pu(e,t){let n=0;if(!e)return 0;if(e.type===10)return co(e,0,GE,n);if(e.type===1&&e.value.charCodeAt(0)===Pr){if(!_r(e.value,1,Fu))return 0;switch(e.value.length){case 2:return Eu(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==Pr?0:(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n));default:return e.value.charCodeAt(2)!==Pr?0:co(e,3,mi,n)}}else if(e.type===1||Au(e,xs)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!_r(e.value,0,Fu))return 0;switch(e.value.length){case 1:return Eu(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==Pr?0:(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n));default:return e.value.charCodeAt(1)!==Pr?0:co(e,2,mi,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===xs||r===Pr?1:0,i=o;for(;i<e.value.length&&_t(e.value.charCodeAt(i));i++);return i===o||!_r(e.value,i,Fu)?0:i+1===e.value.length?Eu(t(++n),n,t):e.value.charCodeAt(i+1)!==Pr?0:i+2===e.value.length?(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n)):co(e,i+2,mi,n)}return 0}var xs,Pr,Fu,mi,GE,lb=$(()=>{"use strict";nr();xs=43,Pr=45,Fu=110,mi=!0,GE=!1});function Lu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function KE(e,t){return e.value.charCodeAt(0)===t}function ys(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===cb&&n&&r!==0)return ys(e,t+r+1,!1),6;if(!Pn(i)||++r>6)return 0}return r}function al(e,t,n){if(!e)return 0;for(;Lu(n(t),ub);){if(++e>6)return 0;t++}return t}function Mu(e,t){let n=0;if(e===null||e.type!==1||!_r(e.value,0,YE)||(e=t(++n),e===null))return 0;if(Lu(e,qE))return e=t(++n),e===null?0:e.type===1?al(ys(e,0,!0),++n,t):Lu(e,ub)?al(1,++n,t):0;if(e.type===10){let r=ys(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!KE(e,cb)||!ys(e,1,!1)?0:n+1:al(r,n,t))}return e.type===12?al(ys(e,1,!0),++n,t):0}var qE,cb,ub,YE,pb=$(()=>{"use strict";nr();qE=43,cb=45,ub=63,YE=117});function yr(e,t){return t<e.length?e.charCodeAt(t):0}function fb(e,t){return $r(e,0,e.length,t)}function gb(e,t){for(let n=0;n<t.length;n++)if(fb(e,t[n]))return!0;return!1}function mb(e,t){return t!==e.length-2?!1:yr(e,t)===92&&_t(yr(e,t+1))}function ll(e,t,n){if(e&&e.type==="Range"){let r=Number(n!==void 0&&n!==t.length?t.substr(0,n):t);if(isNaN(r)||e.min!==null&&r<e.min&&typeof e.min!="string"||e.max!==null&&r>e.max&&typeof e.max!="string")return!0}return!1}function eA(e,t){let n=0,r=[],o=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==n)break e;if(n=r.pop(),r.length===0){o++;break e}break;case 2:case 21:case 19:case 23:r.push(n),n=Ou.get(e.type);break}o++}while(e=t(o));return o}function or(e,t){return function(n,r,o){return n===null?0:n.type===2&&gb(n.value,t)?eA(n,r):e(n,r,o)}}function Ft(e){return function(t){return t===null||t.type!==e?0:1}}function tA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return gb(t,gi)||fb(t,"default")?0:1}function hb(e){return e===null||e.type!==1||yr(e.value,0)!==45||yr(e.value,1)!==45?0:1}function nA(e){return!hb(e)||e.value==="--"?0:1}function rA(e){if(e===null||e.type!==4)return 0;let t=e.value.length;if(t!==4&&t!==5&&t!==7&&t!==9)return 0;for(let n=1;n<t;n++)if(!Pn(yr(e.value,n)))return 0;return 1}function oA(e){return e===null||e.type!==4||!oi(yr(e.value,1),yr(e.value,2),yr(e.value,3))?0:1}function iA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 17:if(n===0)break e;break;case 9:if(n===0&&e.value==="!")break e;break;case 2:case 21:case 19:case 23:r.push(n),n=Ou.get(e.type);break}o++}while(e=t(o));return o}function sA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 2:case 21:case 19:case 23:r.push(n),n=Ou.get(e.type);break}o++}while(e=t(o));return o}function Vr(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Do(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!mb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return ll(r,t.value,o)?0:1}}function aA(e,t,n){return e===null||e.type!==11||ll(n,e.value,e.value.length-1)?0:1}function xb(e){return typeof e!="function"&&(e=function(){return 0}),function(t,n,r){return t!==null&&t.type===10&&Number(t.value)===0?1:e(t,n,r)}}function lA(e,t,n){if(e===null)return 0;let r=Do(e.value,0);return!(r===e.value.length)&&!mb(e.value,r)||ll(n,e.value,r)?0:1}function cA(e,t,n){if(e===null||e.type!==10)return 0;let r=yr(e.value,0)===43||yr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!_t(yr(e.value,r)))return 0;return ll(n,e.value,r)?0:1}function fA(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:or(Vr(null),Wr),angle:or(Vr(t),Wr),decibel:or(Vr(n),Wr),frequency:or(Vr(r),Wr),flex:or(Vr(o),Wr),length:or(xb(Vr(i)),Wr),resolution:or(Vr(s),Wr),semitones:or(Vr(a),Wr),time:or(Vr(u),Wr)}}function gA(e){let t=new Set;for(let n of dA)if(Array.isArray(e[n]))for(let r of e[n])t.add(r.toLowerCase());return function(r){return r===null?0:r.type===9&&r.value==="%"||r.type===1&&t.has(r.value.toLowerCase())?1:0}}function yb(e){return{...uA,...pA,...fA(e),"attr-unit":gA(e)}}var Bu,Du,Ru,XE,QE,JE,zu,Nu,db,ZE,Wr,Ou,uA,pA,dA,bb=$(()=>{"use strict";sl();lb();pb();nr();Bu=["calc(","-moz-calc(","-webkit-calc("],Du=["min(","max(","clamp("],Ru=["round(","mod(","rem("],XE=["sin(","cos(","tan("],QE=["asin(","acos(","atan(","atan2("],JE=["pow(","sqrt(","log(","exp(","sign("],zu=["hypot("],Nu=["abs("],db=[...Bu,...Du,...Ru,...XE,...JE,...zu,...Nu],ZE=[...Bu,...Du,...Ru,...zu,...Nu],Wr=[...Bu,...Du,...Ru,...QE,...zu,...Nu],Ou=new Map([[2,22],[21,22],[19,20],[23,24]]);uA={"ident-token":Ft(1),"function-token":Ft(2),"at-keyword-token":Ft(3),"hash-token":Ft(4),"string-token":Ft(5),"bad-string-token":Ft(6),"url-token":Ft(7),"bad-url-token":Ft(8),"delim-token":Ft(9),"number-token":Ft(10),"percentage-token":Ft(11),"dimension-token":Ft(12),"whitespace-token":Ft(13),"CDO-token":Ft(14),"CDC-token":Ft(15),"colon-token":Ft(16),"semicolon-token":Ft(17),"comma-token":Ft(18),"[-token":Ft(19),"]-token":Ft(20),"(-token":Ft(21),")-token":Ft(22),"{-token":Ft(23),"}-token":Ft(24)},pA={string:Ft(5),ident:Ft(1),percentage:or(aA,ZE),zero:xb(),number:or(lA,db),integer:or(cA,db),"custom-ident":tA,"dashed-ident":hb,"custom-property-name":nA,"hex-color":rA,"id-selector":oA,"an-plus-b":Pu,urange:Mu,"declaration-value":iA,"any-value":sA},dA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var cl={};ye(cl,{angle:()=>hA,decibel:()=>wA,flex:()=>SA,frequency:()=>yA,length:()=>mA,resolution:()=>bA,semitones:()=>vA,time:()=>xA});var mA,hA,xA,yA,bA,SA,wA,vA,Sb=$(()=>{"use strict";mA=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],hA=["deg","grad","rad","turn"],xA=["s","ms"],yA=["hz","khz"],bA=["dpi","dpcm","dppx","x"],SA=["fr"],wA=["db"],vA=["st"]});function wb(e,t,n){return Object.assign(zo("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
10
+ --------`+new Array(o.mismatchOffset+1).join("-")+"^",Object.assign(o,u),o.loc={source:n&&n.loc&&n.loc.source||"<unknown>",start:u,end:c},o}});function il(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===rl&&e.charCodeAt(t+1)===rl}function cb(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===rl&&e.charCodeAt(t+1)!==rl){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function jE(e){if(nl.has(e))return nl.get(e);let t=e.toLowerCase(),n=nl.get(t);if(n===void 0){let r=il(t,0),o=r?"":cb(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return nl.set(e,n),n}function HE(e){if(fi.has(e))return fi.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=il(t,n.length);if(!r&&(t=t.toLowerCase(),fi.has(t))){let a=fi.get(t);return fi.set(e,a),a}let o=r?"":cb(t,n.length),i=t.substr(0,n.length+o.length),s=Object.freeze({basename:t.substr(i.length),name:t.substr(n.length),hack:n,vendor:o,prefix:i,custom:r});return fi.set(e,s),s}var nl,fi,rl,ol,Pu,sl=$(()=>{"use strict";nl=new Map,fi=new Map,rl=45,ol=jE,Pu=HE});var gi,al=$(()=>{"use strict";gi=["initial","inherit","unset","revert","revert-layer"]});function Bu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function hs(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function co(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===xs||o===Pr){if(n)return 0;t++}for(;t<e.value.length;t++)if(!_t(e.value.charCodeAt(t)))return 0;return r+1}function Mu(e,t,n){let r=!1,o=hs(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(Bu(e,xs)||Bu(e,Pr)){if(r=!0,o=hs(n(++o),o,n),e=n(o),e===null||e.type!==10)return 0}else return t;if(!r){let i=e.value.charCodeAt(0);if(i!==xs&&i!==Pr)return 0}return co(e,r?0:1,r,o)}function Du(e,t){let n=0;if(!e)return 0;if(e.type===10)return co(e,0,VE,n);if(e.type===1&&e.value.charCodeAt(0)===Pr){if(!_r(e.value,1,Lu))return 0;switch(e.value.length){case 2:return Mu(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==Pr?0:(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n));default:return e.value.charCodeAt(2)!==Pr?0:co(e,3,mi,n)}}else if(e.type===1||Bu(e,xs)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!_r(e.value,0,Lu))return 0;switch(e.value.length){case 1:return Mu(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==Pr?0:(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n));default:return e.value.charCodeAt(1)!==Pr?0:co(e,2,mi,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===xs||r===Pr?1:0,i=o;for(;i<e.value.length&&_t(e.value.charCodeAt(i));i++);return i===o||!_r(e.value,i,Lu)?0:i+1===e.value.length?Mu(t(++n),n,t):e.value.charCodeAt(i+1)!==Pr?0:i+2===e.value.length?(n=hs(t(++n),n,t),e=t(n),co(e,0,mi,n)):co(e,i+2,mi,n)}return 0}var xs,Pr,Lu,mi,VE,ub=$(()=>{"use strict";nr();xs=43,Pr=45,Lu=110,mi=!0,VE=!1});function Ru(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function YE(e,t){return e.value.charCodeAt(0)===t}function ys(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===pb&&n&&r!==0)return ys(e,t+r+1,!1),6;if(!Pn(i)||++r>6)return 0}return r}function ll(e,t,n){if(!e)return 0;for(;Ru(n(t),db);){if(++e>6)return 0;t++}return t}function zu(e,t){let n=0;if(e===null||e.type!==1||!_r(e.value,0,qE)||(e=t(++n),e===null))return 0;if(Ru(e,GE))return e=t(++n),e===null?0:e.type===1?ll(ys(e,0,!0),++n,t):Ru(e,db)?ll(1,++n,t):0;if(e.type===10){let r=ys(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!YE(e,pb)||!ys(e,1,!1)?0:n+1:ll(r,n,t))}return e.type===12?ll(ys(e,1,!0),++n,t):0}var GE,pb,db,qE,fb=$(()=>{"use strict";nr();GE=43,pb=45,db=63,qE=117});function yr(e,t){return t<e.length?e.charCodeAt(t):0}function mb(e,t){return $r(e,0,e.length,t)}function hb(e,t){for(let n=0;n<t.length;n++)if(mb(e,t[n]))return!0;return!1}function xb(e,t){return t!==e.length-2?!1:yr(e,t)===92&&_t(yr(e,t+1))}function cl(e,t,n){if(e&&e.type==="Range"){let r=Number(n!==void 0&&n!==t.length?t.substr(0,n):t);if(isNaN(r)||e.min!==null&&r<e.min&&typeof e.min!="string"||e.max!==null&&r>e.max&&typeof e.max!="string")return!0}return!1}function ZE(e,t){let n=0,r=[],o=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==n)break e;if(n=r.pop(),r.length===0){o++;break e}break;case 2:case 21:case 19:case 23:r.push(n),n=ju.get(e.type);break}o++}while(e=t(o));return o}function or(e,t){return function(n,r,o){return n===null?0:n.type===2&&hb(n.value,t)?ZE(n,r):e(n,r,o)}}function Ft(e){return function(t){return t===null||t.type!==e?0:1}}function eA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return hb(t,gi)||mb(t,"default")?0:1}function yb(e){return e===null||e.type!==1||yr(e.value,0)!==45||yr(e.value,1)!==45?0:1}function tA(e){return!yb(e)||e.value==="--"?0:1}function nA(e){if(e===null||e.type!==4)return 0;let t=e.value.length;if(t!==4&&t!==5&&t!==7&&t!==9)return 0;for(let n=1;n<t;n++)if(!Pn(yr(e.value,n)))return 0;return 1}function rA(e){return e===null||e.type!==4||!oi(yr(e.value,1),yr(e.value,2),yr(e.value,3))?0:1}function oA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 17:if(n===0)break e;break;case 9:if(n===0&&e.value==="!")break e;break;case 2:case 21:case 19:case 23:r.push(n),n=ju.get(e.type);break}o++}while(e=t(o));return o}function iA(e,t){if(!e)return 0;let n=0,r=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==n)break e;n=r.pop();break;case 2:case 21:case 19:case 23:r.push(n),n=ju.get(e.type);break}o++}while(e=t(o));return o}function Vr(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Do(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!xb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return cl(r,t.value,o)?0:1}}function sA(e,t,n){return e===null||e.type!==11||cl(n,e.value,e.value.length-1)?0:1}function bb(e){return typeof e!="function"&&(e=function(){return 0}),function(t,n,r){return t!==null&&t.type===10&&Number(t.value)===0?1:e(t,n,r)}}function aA(e,t,n){if(e===null)return 0;let r=Do(e.value,0);return!(r===e.value.length)&&!xb(e.value,r)||cl(n,e.value,r)?0:1}function lA(e,t,n){if(e===null||e.type!==10)return 0;let r=yr(e.value,0)===43||yr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!_t(yr(e.value,r)))return 0;return cl(n,e.value,r)?0:1}function dA(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:or(Vr(null),Wr),angle:or(Vr(t),Wr),decibel:or(Vr(n),Wr),frequency:or(Vr(r),Wr),flex:or(Vr(o),Wr),length:or(bb(Vr(i)),Wr),resolution:or(Vr(s),Wr),semitones:or(Vr(a),Wr),time:or(Vr(u),Wr)}}function fA(e){let t=new Set;for(let n of pA)if(Array.isArray(e[n]))for(let r of e[n])t.add(r.toLowerCase());return function(r){return r===null?0:r.type===9&&r.value==="%"||r.type===1&&t.has(r.value.toLowerCase())?1:0}}function Sb(e){return{...cA,...uA,...dA(e),"attr-unit":fA(e)}}var Nu,Ou,_u,KE,XE,QE,$u,Uu,gb,JE,Wr,ju,cA,uA,pA,wb=$(()=>{"use strict";al();ub();fb();nr();Nu=["calc(","-moz-calc(","-webkit-calc("],Ou=["min(","max(","clamp("],_u=["round(","mod(","rem("],KE=["sin(","cos(","tan("],XE=["asin(","acos(","atan(","atan2("],QE=["pow(","sqrt(","log(","exp(","sign("],$u=["hypot("],Uu=["abs("],gb=[...Nu,...Ou,..._u,...KE,...QE,...$u,...Uu],JE=[...Nu,...Ou,..._u,...$u,...Uu],Wr=[...Nu,...Ou,..._u,...XE,...$u,...Uu],ju=new Map([[2,22],[21,22],[19,20],[23,24]]);cA={"ident-token":Ft(1),"function-token":Ft(2),"at-keyword-token":Ft(3),"hash-token":Ft(4),"string-token":Ft(5),"bad-string-token":Ft(6),"url-token":Ft(7),"bad-url-token":Ft(8),"delim-token":Ft(9),"number-token":Ft(10),"percentage-token":Ft(11),"dimension-token":Ft(12),"whitespace-token":Ft(13),"CDO-token":Ft(14),"CDC-token":Ft(15),"colon-token":Ft(16),"semicolon-token":Ft(17),"comma-token":Ft(18),"[-token":Ft(19),"]-token":Ft(20),"(-token":Ft(21),")-token":Ft(22),"{-token":Ft(23),"}-token":Ft(24)},uA={string:Ft(5),ident:Ft(1),percentage:or(sA,JE),zero:bb(),number:or(aA,gb),integer:or(lA,gb),"custom-ident":eA,"dashed-ident":yb,"custom-property-name":tA,"hex-color":nA,"id-selector":rA,"an-plus-b":Du,urange:zu,"declaration-value":oA,"any-value":iA},pA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var ul={};ye(ul,{angle:()=>mA,decibel:()=>SA,flex:()=>bA,frequency:()=>xA,length:()=>gA,resolution:()=>yA,semitones:()=>wA,time:()=>hA});var gA,mA,hA,xA,yA,bA,SA,wA,vb=$(()=>{"use strict";gA=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],mA=["deg","grad","rad","turn"],hA=["s","ms"],xA=["hz","khz"],yA=["dpi","dpcm","dppx","x"],bA=["fr"],SA=["db"],wA=["st"]});function kb(e,t,n){return Object.assign(zo("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
11
11
  `+t+`
12
- --`+new Array((n||t.length)+1).join("-")+"^"})}var vb=$(()=>{"use strict";Ya()});var kA,CA,TA,IA,FA,kb,ul,Cb=$(()=>{"use strict";vb();kA=9,CA=10,TA=12,IA=13,FA=32,kb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),ul=class{constructor(t){this.str=t,this.pos=0}charCodeAt(t){return t<this.str.length?this.str.charCodeAt(t):0}charCode(){return this.charCodeAt(this.pos)}isNameCharCode(t=this.charCode()){return t<128&&kb[t]===1}nextCharCode(){return this.charCodeAt(this.pos+1)}nextNonWsCode(t){return this.charCodeAt(this.findWsEnd(t))}skipWs(){this.pos=this.findWsEnd(this.pos)}findWsEnd(t){for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n!==IA&&n!==CA&&n!==TA&&n!==FA&&n!==kA)break}return t}substringToPos(t){return this.str.substring(this.pos,this.pos=t)}eat(t){this.charCode()!==t&&this.error("Expect `"+String.fromCharCode(t)+"`"),this.pos++}peek(){return this.pos<this.str.length?this.str.charAt(this.pos++):""}error(t){throw new wb(t,this.str,this.pos)}scanSpaces(){return this.substringToPos(this.findWsEnd(this.pos))}scanWord(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n>=128||kb[n]===0)break}return this.pos===t&&this.error("Expect a keyword"),this.substringToPos(t)}scanNumber(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n<48||n>57)break}return this.pos===t&&this.error("Expect a number"),this.substringToPos(t)}scanString(){let t=this.str.indexOf("'",this.pos+1);return t===-1&&(this.pos=this.str.length,this.error("Expect an apostrophe")),this.substringToPos(t+1)}}});function Pb(e){let t=null,n=null;return e.eat(fl),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===Wu?(e.pos++,e.skipWs(),e.charCode()!==Uu&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(Uu),{min:Number(t),max:n?Number(n):0}}function DA(e){let t=null,n=!1;switch(e.charCode()){case Db:e.pos++,t={min:0,max:0};break;case Hu:e.pos++,t={min:1,max:0};break;case dl:e.pos++,t={min:0,max:1};break;case ju:e.pos++,n=!0,e.charCode()===fl?t=Pb(e):e.charCode()===dl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case fl:t=Pb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Gr(e,t){let n=DA(e);return n!==null?(n.term=t,e.charCode()===ju&&e.charCodeAt(e.pos-1)===Hu||e.charCode()===dl&&e.charCodeAt(e.pos-1)===Uu?Gr(e,n):n):t}function _u(e){let t=e.peek();return t===""?null:Gr(e,{type:"Token",value:t})}function RA(e){let t;return e.eat(Vu),e.eat(pl),t=e.scanWord(),e.eat(pl),e.eat($u),Gr(e,{type:"Property",name:t})}function zA(e){let t=null,n=null,r=1;return e.eat(bs),e.charCode()===Ib&&(e.peek(),r=-1),r==-1&&e.charCode()===Eb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Wu),e.skipWs(),e.charCode()===Eb?e.peek():(r=1,e.charCode()===Ib&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(hi),{type:"Range",min:t,max:n}}function NA(e){let t,n=null;if(e.eat(Vu),t=e.scanWord(),t==="boolean-expr"){e.eat(bs);let r=gl(e,hi);return e.eat(hi),e.eat($u),Gr(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Mb&&e.nextCharCode()===Bb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===bs&&(e.skipWs(),n=zA(e)),e.eat($u),Gr(e,{type:"Type",name:t,opts:n})}function OA(e){let t=e.scanWord();return e.charCode()===Mb?(e.pos++,{type:"Function",name:t}):Gr(e,{type:"Keyword",name:t})}function _A(e,t){function n(o,i){return{type:"Group",terms:o,combinator:i,disallowEmpty:!1,explicit:!1}}let r;for(t=Object.keys(t).sort((o,i)=>Ab[o]-Ab[i]);t.length>0;){r=t.shift();let o=0,i=0;for(;o<e.length;o++){let s=e[o];s.type==="Combinator"&&(s.value===r?(i===-1&&(i=o-1),e.splice(o,1),o--):(i!==-1&&o-i>1&&(e.splice(i,o-i,n(e.slice(i,o),r)),o=i+1),i=-1))}i!==-1&&t.length&&e.splice(i,o-i,n(e.slice(i,o),r))}return r}function gl(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?gl(e,Bb):UA(e);if(!a)break;if(a.type!=="Spaces"){if(s){if(a.terms.length===0){s=!1;continue}if(a.combinator===" "){for(;a.terms.length>1;)n[" "]=!0,r.push({type:"Combinator",value:" "},a.terms.shift());a=a.terms[0]}}a.type==="Combinator"?((o===null||o.type==="Combinator")&&(e.pos=i,e.error("Unexpected combinator")),n[a.value]=!0):o!==null&&o.type!=="Combinator"&&(n[" "]=!0,r.push({type:"Combinator",value:" "})),r.push(a),o=a,i=e.pos,s=a.type==="Function"}}return o!==null&&o.type==="Combinator"&&(e.pos-=i,e.error("Unexpected combinator")),{type:"Group",terms:r,combinator:_A(r,n)||" ",disallowEmpty:!1,explicit:!1}}function $A(e){let t;return e.eat(bs),t=gl(e,hi),e.eat(hi),t.explicit=!0,e.charCode()===Lb&&(e.pos++,t.disallowEmpty=!0),t}function UA(e){let t=e.charCode();switch(t){case hi:break;case bs:return Gr(e,$A(e));case Vu:return e.nextCharCode()===pl?RA(e):NA(e);case Fb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Fb?2:1))};case Tb:return e.pos++,e.eat(Tb),{type:"Combinator",value:"&&"};case Wu:return e.pos++,{type:"Comma"};case pl:return Gr(e,{type:"String",value:e.scanString()});case MA:case EA:case AA:case LA:case PA:return{type:"Spaces",value:e.scanSpaces()};case BA:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):_u(e);case Db:case Hu:case dl:case ju:case Lb:break;case fl:if(t=e.nextCharCode(),t<48||t>57)return _u(e);break;default:return e.isNameCharCode(t)?OA(e):_u(e)}}function Ss(e){let t=new ul(e),n=gl(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var EA,AA,PA,LA,MA,Lb,ju,Tb,pl,Mb,Bb,Db,Hu,Wu,Ib,Vu,$u,dl,BA,bs,hi,fl,Fb,Uu,Eb,Ab,Gu=$(()=>{"use strict";Cb();EA=9,AA=10,PA=12,LA=13,MA=32,Lb=33,ju=35,Tb=38,pl=39,Mb=40,Bb=41,Db=42,Hu=43,Wu=44,Ib=45,Vu=60,$u=62,dl=63,BA=64,bs=91,hi=93,fl=123,Fb=124,Uu=125,Eb=8734,Ab={" ":1,"&&":2,"||":3,"|":4}});function Rb(e){return typeof e=="function"?e:ws}function qu(e,t,n){function r(s){switch(o.call(n,s),s.type){case"Group":s.terms.forEach(r);break;case"Multiplier":case"Boolean":r(s.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+s.type)}i.call(n,s)}let o=ws,i=ws;if(typeof t=="function"?o=t:t&&(o=Rb(t.enter),i=Rb(t.leave)),o===ws&&i===ws)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var ws,zb=$(()=>{"use strict";ws=function(){}});var Yu=$(()=>{"use strict";Tu();Gu();zb()});function WA(e){let t=[];return lo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function Nb(e,t){return typeof e=="string"?WA(e):t.generate(e,HA)}var HA,Ob=$(()=>{"use strict";nr();HA={decorator(e){let t=[],n=null;return{...e,node(r){let o=n;n=r,e.node.call(this,r),n=o},emit(r,o,i){t.push({type:o,value:r,node:i?null:n})},result(){return t}}}}});function xn(e,t,n){return t===ut&&n===bt||e===ut&&t===ut&&n===ut?e:(e.type==="If"&&e.else===bt&&t===ut&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function $b(e){return e.length>2&&e.charCodeAt(e.length-2)===VA&&e.charCodeAt(e.length-1)===GA}function _b(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&$b(e.name)}function uo(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function vs(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=vs(e.match,t,n),e.then=vs(e.then,t,n),e.else=vs(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function Ku(e,t,n){switch(e){case" ":{let r=ut;for(let o=t.length-1;o>=0;o--){let i=t[o];r=xn(i,r,bt)}return r}case"|":{let r=bt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(_b(s)&&(o===null&&i>0&&_b(t[i-1])&&(o=Object.create(null),r=xn({type:"Enum",map:o},ut,r)),o!==null)){let a=($b(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=xn(s,ut,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=bt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Ku(e,t.filter(function(a){return a!==i}),!1):s=ut,r=xn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?ut:bt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Ku(e,t.filter(function(a){return a!==i}),!0):s=ut,r=xn(i,s,r)}return r}}}function qA(e){let t=ut,n=xi(e.term);if(e.max===0)n=xn(n,ml,bt),t=xn(n,null,bt),t.then=xn(ut,ut,t),e.comma&&(t.then.else=xn({type:"Comma",syntax:e},t,bt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,bt)),t=xn(n,xn(ut,ut,t),bt);if(e.min===0)t=xn(ut,ut,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,bt)),t=xn(n,t,bt);return t}function xi(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=Ku(e.combinator,e.terms.map(xi),!1);return e.disallowEmpty&&(t=xn(t,ml,bt)),t}case"Multiplier":return qA(e);case"Boolean":{let t=xi(e.term),n=xi(uo([uo([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),uo([{type:"Type",name:"!boolean-group"},uo([{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=xi(uo([{type:"Type",name:"!term"},uo([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return vs(r,{"!term":t,"!self":n}),vs(n,{"!boolean-group":r}),n}case"Type":case"Property":return{type:e.type,name:e.name,syntax:e};case"Keyword":return{type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return{type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return{type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return e.value.length===3?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return{type:e.type,value:e.value,syntax:e};case"Comma":return{type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}function ks(e,t){return typeof e=="string"&&(e=Ss(e)),{type:"MatchGraph",match:xi(e),syntax:t||null,source:e}}var ut,bt,ml,VA,GA,Xu=$(()=>{"use strict";Gu();ut={type:"Match"},bt={type:"Mismatch"},ml={type:"DisallowEmpty"},VA=40,GA=41});function ZA(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function Qu(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=t.charCodeAt(n),o=e.charCodeAt(n);if(o>=65&&o<=90&&(o=o|32),o!==r)return!1}return!0}function eP(e){return e.type!==9?!1:e.value!=="?"}function Wb(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||eP(e)}function Vb(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function tP(e,t,n){function r(){do k++,F=k<e.length?e[k]:null;while(F!==null&&(F.type===13||F.type===25))}function o(_){let M=k+_;return M<e.length?e[M]:null}function i(_,M){return{nextState:_,matchStack:z,syntaxStack:d,thenStack:f,tokenIndex:k,prev:M}}function s(_){f={nextState:_,matchStack:z,syntaxStack:d,prev:f}}function a(_){p=i(_,p)}function u(){z={type:KA,syntax:t.syntax,token:F,prev:z},r(),g=null,k>R&&(R=k)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},z={type:Ju,syntax:t.syntax,token:z.token,prev:z}}function l(){z.type===Ju?z=z.prev:z={type:Gb,syntax:d.syntax,token:z.token,prev:z},d=d.prev}let d=null,f=null,p=null,g=null,S=0,C=null,F=null,k=-1,R=0,z={type:YA,syntax:null,token:null,prev:null};for(r();C===null&&++S<Hb;)switch(t.type){case"Match":if(f===null){if(F!==null&&(k!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=bt;break}C=jb;break}if(t=f.nextState,t===ml)if(f.matchStack===z){t=bt;break}else t=ut;for(;f.syntaxStack!==d;)l();f=f.prev;break;case"Mismatch":if(g!==null&&g!==!1)(p===null||k>p.tokenIndex)&&(p=g,g=!1);else if(p===null){C=XA;break}t=p.nextState,f=p.thenStack,d=p.syntaxStack,z=p.matchStack,k=p.tokenIndex,F=k<e.length?e[k]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==bt&&a(t.else),t.then!==ut&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let B=t.syntax.terms;if(t.index===B.length){if(t.mask===0||t.syntax.all){t=bt;break}t=ut;break}if(t.mask===(1<<B.length)-1){t=ut;break}for(;t.index<B.length;t.index++){let m=1<<t.index;if((t.mask&m)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|m}),t=B[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let B=F.value.toLowerCase();if(B.indexOf("\\")!==-1&&(B=B.replace(/\\[09].*$/,"")),Ub.call(t.map,B)){t=t.map[B];break}}t=bt;break;case"Generic":{let B=d!==null?d.opts:null,m=k+Math.floor(t.fn(F,o,B));if(!isNaN(m)&&m>k){for(;k<m;)u();t=ut}else t=bt;break}case"Type":case"Property":{let B=t.type==="Type"?"types":"properties",m=Ub.call(n,B)?n[B][t.name]:null;if(!m||!m.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(g!==!1&&F!==null&&t.type==="Type"&&(t.name==="custom-ident"&&F.type===1||t.name==="length"&&F.value==="0")){g===null&&(g=i(t,p)),t=bt;break}c(),t=m.matchRef||m.match;break}case"Keyword":{let B=t.name;if(F!==null){let m=F.value;if(m.indexOf("\\")!==-1&&(m=m.replace(/\\[09].*$/,"")),Qu(m,B)){u(),t=ut;break}}t=bt;break}case"AtKeyword":case"Function":if(F!==null&&Qu(F.value,t.name)){u(),t=ut;break}t=bt;break;case"Token":if(F!==null&&F.value===t.value){u(),t=ut;break}t=bt;break;case"Comma":F!==null&&F.type===18?Wb(z.token)?t=bt:(u(),t=Vb(F)?bt:ut):t=Wb(z.token)||Vb(F)?ut:bt;break;case"String":let _="",M=k;for(;M<e.length&&_.length<t.value.length;M++)_+=e[M].value;if(Qu(_,t.value)){for(;k<M;)u();t=ut}else t=bt;break;default:throw new Error("Unknown node type: "+t.type)}switch(JA+=S,C){case null:console.warn("[csstree-match] BREAK after "+Hb+" iterations"),C=QA,z=null;break;case jb:for(;d!==null;)l();break;default:z=null}return{tokens:e,reason:C,iterations:S,match:z,longestMatch:R}}function Zu(e,t,n){let r=tP(e,t,n||{});if(r.match===null)return r;let o=r.match,i=r.match={syntax:t.syntax||null,match:[]},s=[i];for(o=ZA(o).prev;o!==null;){switch(o.type){case Ju:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case Gb:s.pop(),i=s[s.length-1];break;default:i.match.push({syntax:o.syntax||null,token:o.token.value,node:o.token.node})}o=o.prev}return r}var Ub,YA,KA,Ju,Gb,jb,XA,QA,Hb,JA,qb=$(()=>{"use strict";Xu();({hasOwnProperty:Ub}=Object.prototype),YA=0,KA=1,Ju=2,Gb=3,jb="Match",XA="Mismatch",QA="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",Hb=15e3,JA=0});var tp={};ye(tp,{getTrace:()=>Yb,isKeyword:()=>oP,isProperty:()=>rP,isType:()=>nP});function Yb(e){function t(o){return o===null?!1:o.type==="Type"||o.type==="Property"||o.type==="Keyword"}function n(o){if(Array.isArray(o.match)){for(let i=0;i<o.match.length;i++)if(n(o.match[i]))return t(o.syntax)&&r.unshift(o.syntax),!0}else if(o.node===e)return r=t(o.syntax)?[o.syntax]:[],!0;return!1}let r=null;return this.matched!==null&&n(this.matched),r}function nP(e,t){return ep(this,e,n=>n.type==="Type"&&n.name===t)}function rP(e,t){return ep(this,e,n=>n.type==="Property"&&n.name===t)}function oP(e){return ep(this,e,t=>t.type==="Keyword")}function ep(e,t,n){let r=Yb.call(e,t);return r===null?!1:r.some(n)}var Kb=$(()=>{"use strict"});function Xb(e){return"node"in e?e.node:Xb(e.match[0])}function Qb(e){return"node"in e?e.node:Qb(e.match[e.match.length-1])}function np(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=Xb(a),c=Qb(a);e.syntax.walk(t,function(l,d,f){if(l===u){let p=new Vn;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:f,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var Jb=$(()=>{"use strict";ps()});function rp(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function Zb(e){return!!e&&rp(e.offset)&&rp(e.line)&&rp(e.column)}function iP(e,t){return function(r,o){if(!r||r.constructor!==Object)return o(r,"Type of node should be an Object");for(let i in r){let s=!0;if(Cs.call(r,i)!==!1){if(i==="type")r.type!==e&&o(r,"Wrong node type `"+r.type+"`, expected `"+e+"`");else if(i==="loc"){if(r.loc===null)continue;if(r.loc&&r.loc.constructor===Object)if(typeof r.loc.source!="string")i+=".source";else if(!Zb(r.loc.start))i+=".start";else if(!Zb(r.loc.end))i+=".end";else continue;s=!1}else if(t.hasOwnProperty(i)){s=!1;for(let a=0;!s&&a<t[i].length;a++){let u=t[i][a];switch(u){case String:s=typeof r[i]=="string";break;case Boolean:s=typeof r[i]=="boolean";break;case null:s=r[i]===null;break;default:typeof u=="string"?s=r[i]&&r[i].type===u:Array.isArray(u)&&(s=r[i]instanceof Vn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Cs.call(t,i)&&Cs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function e0(e,t){let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o===String||o===Boolean)n.push(o.name.toLowerCase());else if(o===null)n.push("null");else if(typeof o=="string")n.push(o);else if(Array.isArray(o))n.push("List<"+(e0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function sP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Cs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=e0(s,e+"."+i)}return{docs:o,check:iP(e,r)}}function t0(e){let t={};if(e.node){for(let n in e.node)if(Cs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=sP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Cs,n0=$(()=>{"use strict";ps();({hasOwnProperty:Cs}=Object.prototype)});function op(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:pi(e[o].syntax,{compact:t}));return r}function aP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:pi(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&op(i.descriptors,t,n)};return r}function lP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function cP(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function br(e,t,n){return{matched:e,iterations:n,error:t,...tp}}function yi(e,t,n,r){let o=Nb(n,e.syntax),i;return lP(o)?br(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=Zu(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=Zu(o,t.match,e),!i.match)?br(null,new ib(i.reason,t.syntax,n,i),i.iterations):br(i.match,null,i.iterations))}var Ts,r0=$(()=>{"use strict";sb();il();sl();bb();Sb();Yu();Ob();Xu();qb();Kb();Jb();n0();Ts=class{constructor(t,n,r){if(this.cssWideKeywords=gi,this.syntax=n,this.generic=!1,this.units={...cl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||t0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(cl))Array.isArray(t.units[o])&&(this.units[o]=t.units[o]);if(t.types)for(let[o,i]of Object.entries(t.types))this.addType_(o,i);if(t.generic){this.generic=!0;for(let[o,i]of Object.entries(yb(this.units)))this.addType_(o,i)}if(t.atrules)for(let[o,i]of Object.entries(t.atrules))this.addAtrule_(o,i);if(t.properties)for(let[o,i]of Object.entries(t.properties))this.addProperty_(o,i)}this.cssWideKeywordsSyntax=ks(this.cssWideKeywords.join(" | "))}checkStructure(t){function n(i,s){o.push({node:i,message:s})}let r=this.structure,o=[];return this.syntax.walk(t,function(i){r.hasOwnProperty(i.type)?r[i.type].check(i,n):n(i,"Unknown node type `"+i.type+"`")}),o.length?o:!1}createDescriptor(t,n,r,o=null){let i={type:n,name:r},s={type:n,name:r,parent:o,serializable:typeof t=="string"||t&&typeof t.type=="string",syntax:null,match:null,matchRef:null};return typeof t=="function"?s.match=ks(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ss(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:ks(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=cP(a)?ks({...a,terms:[a.terms[0].term]},i):null;return Object.defineProperty(s,"matchRef",{value:u}),u}})),s}addAtrule_(t,n){n&&(this.atrules[t]={type:"Atrule",name:t,prelude:n.prelude?this.createDescriptor(n.prelude,"AtrulePrelude",t):null,descriptors:n.descriptors?Object.keys(n.descriptors).reduce((r,o)=>(r[o]=this.createDescriptor(n.descriptors[o],"AtruleDescriptor",o,t),r),Object.create(null)):null})}addProperty_(t,n){n&&(this.properties[t]=this.createDescriptor(n,"Property",t))}addType_(t,n){n&&(this.types[t]=this.createDescriptor(n,"Type",t))}checkAtruleName(t){if(!this.getAtrule(t))return new di("Unknown at-rule","@"+t)}checkAtrulePrelude(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t);if(!o.prelude&&n)return new SyntaxError("At-rule `@"+t+"` should not contain a prelude");if(o.prelude&&!n&&!yi(this,o.prelude,"",!1).matched)return new SyntaxError("At-rule `@"+t+"` should contain a prelude")}checkAtruleDescriptorName(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t),i=rl(n);if(!o.descriptors)return new SyntaxError("At-rule `@"+t+"` has no known descriptors");if(!o.descriptors[i.name]&&!o.descriptors[i.basename])return new di("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new di("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return br(null,r);let o=this.getAtrule(t);return o.prelude?yi(this,o.prelude,n||"",!1):br(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return br(null,o);let i=this.getAtrule(t),s=rl(n);return yi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?br(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Iu(t).custom)return br(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?br(null,r):yi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?yi(this,r,n,!1):br(null,new di("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?br(null,new di("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),yi(this,t,n,!1))}findValueFragments(t,n,r,o){return np(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return np(this,t.value,this.matchDeclaration(t),n,r)}findAllFragments(t,n,r){let o=[];return this.syntax.walk(t,{visit:"Declaration",enter:i=>{o.push.apply(o,this.findDeclarationValueFragments(i,n,r))}}),o}getAtrule(t,n=!0){let r=rl(t);return(r.vendor&&n?this.atrules[r.name]||this.atrules[r.basename]:this.atrules[r.name])||null}getAtrulePrelude(t,n=!0){let r=this.getAtrule(t,n);return r&&r.prelude||null}getAtruleDescriptor(t,n){return this.atrules.hasOwnProperty(t)&&this.atrules.declarators&&this.atrules[t].declarators[n]||null}getProperty(t,n=!0){let r=Iu(t);return(r.vendor&&n?this.properties[r.name]||this.properties[r.basename]:this.properties[r.name])||null}getType(t){return hasOwnProperty.call(this.types,t)?this.types[t]:null}validate(){function t(u,c){return c?`<${u}>`:`<'${u}'>`}function n(u,c,l,d){if(l.has(c))return l.get(c);l.set(c,!1),d.syntax!==null&&qu(d.syntax,function(f){if(f.type!=="Type"&&f.type!=="Property")return;let p=f.type==="Type"?u.types:u.properties,g=f.type==="Type"?o:i;hasOwnProperty.call(p,f.name)?n(u,f.name,g,p[f.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0))},this)}let r=[],o=new Map,i=new Map;for(let u in this.types)n(this,u,o,this.types[u]);for(let u in this.properties)n(this,u,i,this.properties[u]);let s=[...o.keys()].filter(u=>o.get(u)),a=[...i.keys()].filter(u=>i.get(u));return s.length||a.length?{errors:r,types:s,properties:a}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:op(this.types,!n,t),properties:op(this.properties,!n,t),atrules:aP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function ip(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function uP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function sp(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?uP(i,n):i};return r}function Is(e,t){let n={...e};for(let[r,o]of Object.entries(t))switch(r){case"generic":n[r]=!!o;break;case"cssWideKeywords":n[r]=e[r]?[...e[r],...o]:o||[];break;case"units":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=Array.isArray(s)?s:[];break;case"atrules":n[r]={...e[r]};for(let[i,s]of Object.entries(o)){let a=n[r][i]||{},u=n[r][i]={prelude:a.prelude||null,descriptors:{...a.descriptors}};if(s){u.prelude=s.prelude?ip(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?ip(u.descriptors[c],l):null;Object.keys(u.descriptors).length||(u.descriptors=null)}}break;case"types":case"properties":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=ip(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=sp(e[r],o);break;case"atrule":case"pseudo":n[r]=sp(e[r],o,["parse"]);break;case"node":n[r]=sp(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var o0=$(()=>{"use strict"});function i0(e){let t=Sy(e),n=nb(e),r=Yy(e),{fromPlainObject:o,toPlainObject:i}=Xy(n),s={lexer:null,createLexer:a=>new Ts(a,s,s.lexer.structure),tokenize:lo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Is({},e);return i0(typeof a=="function"?a(u):Is(u,a))}};return s.lexer=new Ts({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var s0,a0=$(()=>{"use strict";nr();wy();Ky();Qy();rb();r0();o0();s0=e=>i0(Is({},e))});var l0,c0=$(()=>{"use strict";l0={generic:!0,cssWideKeywords:["initial","inherit","unset","revert","revert-layer"],units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( <calc-sum> )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( <calc-sum> )","alpha-value":"<number>|<percentage>","an+b":"odd|even|<integer>|<n-dimension>|'+'? \u2020 n|-n|<ndashdigit-dimension>|'+'? \u2020 <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? \u2020 n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? \u2020 n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? \u2020 n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>","anchor()":"anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )","anchor-name":"<dashed-ident>","anchor-side":"inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center","anchor-size":"width|height|block|inline|self-block|self-inline","anchor-size()":"anchor-size( [<anchor-name>||<anchor-size>]? , <length-percentage>? )","angle-percentage":"<angle>|<percentage>","angular-color-hint":"<angle-percentage>|<zero>","angular-color-stop":"<color> <color-stop-angle>?","angular-color-stop-list":"<angular-color-stop> , [<angular-color-hint>? , <angular-color-stop>]#?","animateable-feature":"scroll-position|contents|<custom-ident>","animation-action":"none|play|play-once|play-forwards|play-backwards|pause|reset|replay","asin()":"asin( <calc-sum> )","atan()":"atan( <calc-sum> )","atan2()":"atan2( <calc-sum> , <calc-sum> )",attachment:"scroll|fixed|local","attr()":"attr( <attr-name> <attr-type>? , <declaration-value>? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attr-type":"type( <syntax> )|raw-string|number|<attr-unit>","attribute-selector":"'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )","auto-track-list":"[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",axis:"block|inline|x|y","baseline-position":"[first|last]? baseline","basic-shape":"<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>","basic-shape-rect":"<inset()>|<rect()>|<xywh()>","bg-clip":"<visual-box>|border-area|text","bg-image":"<image>|none","bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>","bg-position":"[[left|center|right|top|bottom|<length-percentage>]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]|[center|[left|right] <length-percentage>?]&&[center|[top|bottom] <length-percentage>?]]","bg-size":"[<length-percentage [0,\u221E]>|auto]{1,2}|cover|contain","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","blur()":"blur( <length>? )","brightness()":"brightness( [<number>|<percentage>]? )","calc()":"calc( <calc-sum> )","calc-constant":"e|pi|infinity|-infinity|NaN","calc-product":"<calc-value> ['*' <calc-value>|'/' <number>]*","calc-size()":"calc-size( <calc-size-basis> , <calc-sum> )","calc-size-basis":"<intrinsic-size-keyword>|<calc-size()>|any|<calc-sum>","calc-sum":"<calc-product> [['+'|'-'] <calc-product>]*","calc-value":"<number>|<dimension>|<percentage>|<calc-constant>|( <calc-sum> )","cf-final-image":"<image>|<color>","cf-mixing-image":"<percentage>?&&<image>","circle()":"circle( <radial-size>? [at <position>]? )","clamp()":"clamp( <calc-sum>#{3} )","class-selector":"'.' <ident-token>","clip-source":"<url>",color:"<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>","color()":"color( <colorspace-params> [/ [<alpha-value>|none]]? )","color-base":"<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent","color-function":"<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>","color-interpolation-method":"in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]","color-mix()":"color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )","color-stop":"<color-stop-length>|<color-stop-angle>","color-stop-angle":"[<angle-percentage>|<zero>]{1,2}","color-stop-length":"<length-percentage>{1,2}","color-stop-list":"<linear-color-stop> , [<linear-color-hint>? , <linear-color-stop>]#?","colorspace-params":"[<predefined-rgb-params>|<xyz-params>]",combinator:"'>'|'+'|'~'|['|' '|']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|checkbox|radio|menulist|listbox|meter|progress-bar|button","compat-special":"textfield|menulist-button","complex-selector":"<complex-selector-unit> [<combinator>? <complex-selector-unit>]*","complex-selector-list":"<complex-selector>#","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[<type-selector>? <subclass-selector>*]!","compound-selector-list":"<compound-selector>#","conic-gradient()":"conic-gradient( [<conic-gradient-syntax>] )","conic-gradient-syntax":"[[[from [<angle>|<zero>]]? [at <position>]?]||<color-interpolation-method>]? , <angular-color-stop-list>","container-condition":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","container-name":"<custom-ident>","container-query":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[<string>|contents|<image>|<counter>|<quote>|<target>|<leader()>|<attr()>]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"<image>","contextual-alt-values":"[contextual|no-contextual]","contrast()":"contrast( [<number>|<percentage>]? )","coord-box":"content-box|padding-box|border-box|fill-box|stroke-box|view-box","corner-shape-value":"round|scoop|bevel|notch|square|squircle|<superellipse()>","cos()":"cos( <calc-sum> )",counter:"<counter()>|<counters()>","counter()":"counter( <counter-name> , <counter-style>? )","counter-name":"<custom-ident>","counter-style":"<counter-style-name>|symbols( )","counter-style-name":"<custom-ident>","counters()":"counters( <counter-name> , <string> , <counter-style>? )","cross-fade()":"cross-fade( <cf-mixing-image> , <cf-final-image>? )","cubic-bezier()":"cubic-bezier( [<number [0,1]> , <number>]#{2} )","cubic-bezier-easing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )","cursor-predefined":"auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing","custom-color-space":"<dashed-ident>","custom-params":"<dashed-ident> [<number>|<percentage>|none]+",dasharray:"[[<length-percentage>|<number>]+]#","dashndashdigit-ident":"<ident-token>","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow|CaptionText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"<display-outside>?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( [<color>?&&<length>{2,3}] )","dynamic-range-limit-mix()":"dynamic-range-limit-mix( [<'dynamic-range-limit'>&&<percentage [0,100]>]#{2,} )","easing-function":"<linear-easing-function>|<cubic-bezier-easing-function>|<step-easing-function>","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )","ellipse()":"ellipse( <radial-size>? [at <position>]? )","env()":"env( <custom-ident> , <declaration-value>? )","exp()":"exp( <calc-sum> )","explicit-track-list":"[<line-names>? <track-size>]+ <line-names>?","family-name":"<string>|<custom-ident>+","feature-tag-value":"<string> [<integer>|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":"<feature-type> '{' <feature-value-declaration-list> '}'","feature-value-block-list":"<feature-value-block>+","feature-value-declaration":"<custom-ident> : <integer>+ ;","feature-value-declaration-list":"<feature-value-declaration>","feature-value-name":"<custom-ident>","filter-function":"<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>","filter-value-list":"[<filter-function>|<url>]+","final-bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>||<'background-color'>","fit-content()":"fit-content( <length-percentage [0,\u221E]> )","fixed-breadth":"<length-percentage>","fixed-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <fixed-size>]+ <line-names>? )","fixed-size":"<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>","font-variant-css2":"normal|small-caps","font-weight-absolute":"normal|bold|<number [1,1000]>","font-width-css3":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","form-control-identifier":"select","frequency-percentage":"<frequency>|<percentage>","generic-complete":"serif|sans-serif|system-ui|cursive|fantasy|math|monospace","general-enclosed":"[<function-token> <any-value>? )]|[( <any-value>? )]","generic-family":"<generic-script-specific>|<generic-complete>|<generic-incomplete>|<-non-standard-generic-family>","generic-incomplete":"ui-serif|ui-sans-serif|ui-monospace|ui-rounded","geometry-box":"<shape-box>|fill-box|stroke-box|view-box",gradient:"<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<repeating-conic-gradient()>|<-legacy-gradient>","grayscale()":"grayscale( [<number>|<percentage>]? )","grid-line":"auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hsla()":"hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",hue:"<number>|<angle>","hue-interpolation-method":"[shorter|longer|increasing|decreasing] hue","hue-rotate()":"hue-rotate( [<angle>|<zero>]? )","hwb()":"hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hypot()":"hypot( <calc-sum># )",image:"<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>","image()":"image( <image-tags>? [<image-src>? , <color>?]! )","image-set()":"image-set( <image-set-option># )","image-set-option":"[<image>|<string>] [<resolution>||type( <string> )]","image-src":"<url>|<string>","image-tags":"ltr|rtl","inflexible-breadth":"<length-percentage>|min-content|max-content|auto","inset()":"inset( <length-percentage>{1,4} [round <'border-radius'>]? )","invert()":"invert( [<number>|<percentage>]? )","keyframe-block":"<keyframe-selector># { <declaration-list> }","keyframe-selector":"from|to|<percentage [0,100]>|<timeline-range-name> <percentage>","keyframes-name":"<custom-ident>|<string>","lab()":"lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","layer()":"layer( <layer-name> )","layer-name":"<ident> ['.' <ident>]*","lch()":"lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","leader()":"leader( <leader-type> )","leader-type":"dotted|solid|space|<string>","length-percentage":"<length>|<percentage>","light-dark()":"light-dark( <color> , <color> )","line-name-list":"[<line-names>|<name-repeat>]+","line-names":"'[' <custom-ident>* ']'","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"<length>|thin|medium|thick","linear()":"linear( [<number>&&<percentage>{0,2}]# )","linear-color-hint":"<length-percentage>","linear-color-stop":"<color> <color-stop-length>?","linear-easing-function":"linear|<linear()>","linear-gradient()":"linear-gradient( [<linear-gradient-syntax>] )","linear-gradient-syntax":"[[<angle>|<zero>|to <side-or-corner>]||<color-interpolation-method>]? , <color-stop-list>","log()":"log( <calc-sum> , <calc-sum>? )","mask-layer":"<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>","mask-position":"[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?","mask-reference":"none|<image>|<mask-source>","mask-source":"<url>","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( <number>#{6} )","matrix3d()":"matrix3d( <number>#{16} )","max()":"max( <calc-sum># )","media-and":"<media-in-parens> [and <media-in-parens>]+","media-condition":"<media-not>|<media-and>|<media-or>|<media-in-parens>","media-condition-without-or":"<media-not>|<media-and>|<media-in-parens>","media-feature":"( [<mf-plain>|<mf-boolean>|<mf-range>] )","media-in-parens":"( <media-condition> )|<media-feature>|<general-enclosed>","media-not":"not <media-in-parens>","media-or":"<media-in-parens> [or <media-in-parens>]+","media-query":"<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?","media-query-list":"<media-query>#","media-type":"<ident>","mf-boolean":"<mf-name>","mf-name":"<ident>","mf-plain":"<mf-name> : <mf-value>","mf-range":"<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>","mf-value":"<number>|<dimension>|<ident>|<ratio>","min()":"min( <calc-sum># )","minmax()":"minmax( [<length-percentage>|min-content|max-content|auto] , [<length-percentage>|<flex>|min-content|max-content|auto] )","mod()":"mod( <calc-sum> , <calc-sum> )","n-dimension":"<dimension-token>","name-repeat":"repeat( [<integer [1,\u221E]>|auto-fill] , <line-names>+ )","named-color":"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen","namespace-prefix":"<ident>","ndash-dimension":"<dimension-token>","ndashdigit-dimension":"<dimension-token>","ndashdigit-ident":"<ident-token>","ns-prefix":"[<ident-token>|'*']? '|'","number-percentage":"<number>|<percentage>","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","offset-path":"<ray()>|<url>|<basic-shape>","oklab()":"oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","oklch()":"oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","opacity()":"opacity( [<number>|<percentage>]? )","opacity-value":"<number>|<percentage>","outline-line-style":"none|dotted|dashed|solid|double|groove|ridge|inset|outset","outline-radius":"<length>|<percentage>","overflow-position":"unsafe|safe","page-body":"<declaration>? [; <page-body>]?|<page-margin-box> <page-body>","page-margin-box":"<page-margin-box-type> '{' <declaration-list> '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector":"<pseudo-page>+|<ident> <pseudo-page>*","page-selector-list":"[<page-selector>#]?","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",paint:"none|<color>|<url> [none|<color>]?|context-fill|context-stroke","paint()":"paint( <ident> , <declaration-value>? )","paint-box":"<visual-box>|fill-box|stroke-box","palette-identifier":"<dashed-ident>","palette-mix()":"palette-mix( <color-interpolation-method> , [[normal|light|dark|<palette-identifier>|<palette-mix()>]&&<percentage [0,100]>?]#{2} )","path()":"path( <'fill-rule'>? , <string> )","perspective()":"perspective( [<length [0,\u221E]>|none] )","polar-color-space":"hsl|hwb|lch|oklch","polygon()":"polygon( <'fill-rule'>? , [<length-percentage> <length-percentage>]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]?|[[left|right] <length-percentage>]&&[[top|bottom] <length-percentage>]]","position-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|center|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|center|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]","pow()":"pow( <calc-sum> , <calc-sum> )","predefined-rgb":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020","predefined-rgb-params":"<predefined-rgb> [<number>|<percentage>|none]{3}","pseudo-class-selector":"':' <ident-token>|':' <function-token> <any-value> ')'","pseudo-element-selector":"':' <pseudo-class-selector>|<legacy-pseudo-element-selector>","pseudo-page":": [left|right|first|blank]","query-in-parens":"( <container-condition> )|( <size-feature> )|style( <style-query> )|<general-enclosed>",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-extent":"closest-corner|closest-side|farthest-corner|farthest-side","radial-gradient()":"radial-gradient( [<radial-gradient-syntax>] )","radial-gradient-syntax":"[[[<radial-shape>||<radial-size>]? [at <position>]?]||<color-interpolation-method>]? , <color-stop-list>","radial-shape":"circle|ellipse","radial-size":"<radial-extent>|<length [0,\u221E]>|<length-percentage [0,\u221E]>{2}",ratio:"<number [0,\u221E]> [/ <number [0,\u221E]>]?","ray()":"ray( <angle>&&<ray-size>?&&contain?&&[at <position>]? )","ray-size":"closest-side|closest-corner|farthest-side|farthest-corner|sides","rect()":"rect( [<length-percentage>|auto]{4} [round <'border-radius'>]? )","rectangular-color-space":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65","relative-selector":"<combinator>? <complex-selector>","relative-selector-list":"<relative-selector>#","relative-size":"larger|smaller","rem()":"rem( <calc-sum> , <calc-sum> )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [<conic-gradient-syntax>] )","repeating-linear-gradient()":"repeating-linear-gradient( [<linear-gradient-syntax>] )","repeating-radial-gradient()":"repeating-radial-gradient( [<radial-gradient-syntax>] )","reversed-counter-name":"reversed( <counter-name> )","rgb()":"rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rgba()":"rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rotate()":"rotate( [<angle>|<zero>] )","rotate3d()":"rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )","rotateX()":"rotateX( [<angle>|<zero>] )","rotateY()":"rotateY( [<angle>|<zero>] )","rotateZ()":"rotateZ( [<angle>|<zero>] )","round()":"round( <rounding-strategy>? , <calc-sum> , <calc-sum> )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( [<number>|<percentage>]? )","scale()":"scale( [<number>|<percentage>]#{1,2} )","scale3d()":"scale3d( [<number>|<percentage>]#{3} )","scaleX()":"scaleX( [<number>|<percentage>] )","scaleY()":"scaleY( [<number>|<percentage>] )","scaleZ()":"scaleZ( [<number>|<percentage>] )","scope-end":"<forgiving-selector-list>","scope-start":"<forgiving-selector-list>","scroll()":"scroll( [<scroller>||<axis>]? )",scroller:"root|nearest|self","scroll-state-feature":"<media-query-list>","scroll-state-in-parens":"( <scroll-state-query> )|( <scroll-state-feature> )|<general-enclosed>","scroll-state-query":"not <scroll-state-in-parens>|<scroll-state-in-parens> [[and <scroll-state-in-parens>]*|[or <scroll-state-in-parens>]*]|<scroll-state-feature>","selector-list":"<complex-selector-list>","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","sepia()":"sepia( [<number>|<percentage>]? )",shadow:"inset?&&<length>{2,4}&&<color>?","shadow-t":"[<length>{2,3}&&<color>?]",shape:"rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )","shape-box":"<visual-box>|margin-box","side-or-corner":"[left|right]||[top|bottom]","sign()":"sign( <calc-sum> )","signed-integer":"<number-token>","signless-integer":"<number-token>","sin()":"sin( <calc-sum> )","single-animation":"<'animation-duration'>||<easing-function>||<'animation-delay'>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]||<single-animation-timeline>","single-animation-composition":"replace|add|accumulate","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|<number>","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|<dashed-ident>|<scroll()>|<view()>","single-transition":"[none|<single-transition-property>]||<time>||<easing-function>||<time>||<transition-behavior-value>","single-transition-property":"all|<custom-ident>",size:"closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}","size-feature":"<mf-plain>|<mf-boolean>|<mf-range>","skew()":"skew( [<angle>|<zero>] , [<angle>|<zero>]? )","skewX()":"skewX( [<angle>|<zero>] )","skewY()":"skewY( [<angle>|<zero>] )","sqrt()":"sqrt( <calc-sum> )","step-position":"jump-start|jump-end|jump-none|jump-both|start|end","step-easing-function":"step-start|step-end|<steps()>","steps()":"steps( <integer> , <step-position>? )","style-feature":"<declaration>","style-in-parens":"( <style-condition> )|( <style-feature> )|<general-enclosed>","style-query":"<style-condition>|<style-feature>","subclass-selector":"<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>","superellipse()":"superellipse( [<number>|infinity|-infinity] )","supports-condition":"not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*","supports-decl":"( <declaration> )","supports-feature":"<supports-decl>|<supports-selector-fn>","supports-in-parens":"( <supports-condition> )|<supports-feature>|<general-enclosed>","supports-selector-fn":"selector( <complex-selector> )",symbol:"<string>|<image>|<custom-ident>","symbols()":"symbols( <symbols-type>? [<string>|<image>]+ )","symbols-type":"cyclic|numeric|alphabetic|symbolic|fixed","system-color":"AccentColor|AccentColorText|ActiveText|ButtonBorder|ButtonFace|ButtonText|Canvas|CanvasText|Field|FieldText|GrayText|Highlight|HighlightText|LinkText|Mark|MarkText|SelectedItem|SelectedItemText|VisitedText","system-family-name":"caption|icon|menu|message-box|small-caption|status-bar","tan()":"tan( <calc-sum> )",target:"<target-counter()>|<target-counters()>|<target-text()>","target-counter()":"target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )","target-counters()":"target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )","target-text()":"target-text( [<string>|<url>] , [content|before|after|first-letter]? )","text-edge":"[text|cap|ex|ideographic|ideographic-ink] [text|alphabetic|ideographic|ideographic-ink]?","time-percentage":"<time>|<percentage>","timeline-range-name":"cover|contain|entry|exit|entry-crossing|exit-crossing","track-breadth":"<length-percentage>|<flex>|min-content|max-content|auto","track-list":"[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?","track-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <track-size>]+ <line-names>? )","track-size":"<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( <length-percentage> )","transform-function":"<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>","transform-list":"<transform-function>+","transition-behavior-value":"normal|allow-discrete","translate()":"translate( <length-percentage> , <length-percentage>? )","translate3d()":"translate3d( <length-percentage> , <length-percentage> , <length> )","translateX()":"translateX( <length-percentage> )","translateY()":"translateY( <length-percentage> )","translateZ()":"translateZ( <length> )","try-size":"most-width|most-height|most-block-size|most-inline-size","try-tactic":"flip-block||flip-inline||flip-start","type-or-unit":"string|color|url|integer|number|length|angle|time|frequency|cap|ch|em|ex|ic|lh|rlh|rem|vb|vi|vw|vh|vmin|vmax|mm|Q|cm|in|pt|pc|px|deg|grad|rad|turn|ms|s|Hz|kHz|%","type-selector":"<wq-name>|<ns-prefix>? '*'","var()":"var( <custom-property-name> , <declaration-value>? )","view()":"view( [<axis>||<'view-timeline-inset'>]? )","viewport-length":"auto|<length-percentage>","visual-box":"content-box|padding-box|border-box","wq-name":"<ns-prefix>? <ident-token>","xywh()":"xywh( <length-percentage>{2} <length-percentage [0,\u221E]>{2} [round <'border-radius'>]? )",xyz:"xyz|xyz-d50|xyz-d65","xyz-params":"<xyz-space> [<number>|<percentage>|none]{3}","-legacy-gradient":"<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>","-legacy-linear-gradient":"-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-repeating-linear-gradient":"-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-linear-gradient-arguments":"[<angle>|<side-or-corner>]? , <color-stop-list>","-legacy-radial-gradient":"-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-repeating-radial-gradient":"-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-radial-gradient-arguments":"[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>","-legacy-radial-gradient-size":"closest-side|closest-corner|farthest-side|farthest-corner|contain|cover","-legacy-radial-gradient-shape":"circle|ellipse","-non-standard-font":"-apple-system-body|-apple-system-headline|-apple-system-subheadline|-apple-system-caption1|-apple-system-caption2|-apple-system-footnote|-apple-system-short-body|-apple-system-short-headline|-apple-system-short-subheadline|-apple-system-short-caption1|-apple-system-short-footnote|-apple-system-tall-body","-non-standard-color":"-moz-ButtonDefault|-moz-ButtonHoverFace|-moz-ButtonHoverText|-moz-CellHighlight|-moz-CellHighlightText|-moz-Combobox|-moz-ComboboxText|-moz-Dialog|-moz-DialogText|-moz-dragtargetzone|-moz-EvenTreeRow|-moz-Field|-moz-FieldText|-moz-html-CellHighlight|-moz-html-CellHighlightText|-moz-mac-accentdarkestshadow|-moz-mac-accentdarkshadow|-moz-mac-accentface|-moz-mac-accentlightesthighlight|-moz-mac-accentlightshadow|-moz-mac-accentregularhighlight|-moz-mac-accentregularshadow|-moz-mac-chrome-active|-moz-mac-chrome-inactive|-moz-mac-focusring|-moz-mac-menuselect|-moz-mac-menushadow|-moz-mac-menutextselect|-moz-MenuHover|-moz-MenuHoverText|-moz-MenuBarText|-moz-MenuBarHoverText|-moz-nativehyperlinktext|-moz-OddTreeRow|-moz-win-communicationstext|-moz-win-mediatext|-moz-activehyperlinktext|-moz-default-background-color|-moz-default-color|-moz-hyperlinktext|-moz-visitedhyperlinktext|-webkit-activelink|-webkit-focus-ring-color|-webkit-link|-webkit-text","-non-standard-image-rendering":"optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast","-non-standard-overflow":"overlay|-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable","-non-standard-size":"intrinsic|min-intrinsic|-webkit-fill-available|-webkit-fit-content|-webkit-min-content|-webkit-max-content|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content","-webkit-gradient()":"-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point>|, <-webkit-gradient-radius> , <-webkit-gradient-point>] [, <-webkit-gradient-radius>]? [, <-webkit-gradient-color-stop>]* )","-webkit-gradient-color-stop":"from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )","-webkit-gradient-point":"[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]","-webkit-gradient-radius":"<length>|<percentage>","-webkit-gradient-type":"linear|radial","-webkit-mask-box-repeat":"repeat|stretch|round","-ms-filter-function-list":"<-ms-filter-function>+","-ms-filter-function":"<-ms-filter-function-progid>|<-ms-filter-function-legacy>","-ms-filter-function-progid":"'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]","-ms-filter-function-legacy":"<ident-token>|<function-token> <any-value>? )",age:"child|young|old","attr-name":"<wq-name>","attr-fallback":"<any-value>",autospace:"no-autospace|[ideograph-alpha||ideograph-numeric||punctuation]||[insert|replace]",bottom:"<length>|auto","generic-voice":"[<age>? <gender> <integer>?]",gender:"male|female|neutral","generic-script-specific":"generic( kai )|generic( fangsong )|generic( nastaliq )","-non-standard-generic-family":"-apple-system|BlinkMacSystemFont","intrinsic-size-keyword":"min-content|max-content|fit-content",left:"<length>|auto","device-cmyk()":"<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>","legacy-device-cmyk-syntax":"device-cmyk( <number>#{4} )","modern-device-cmyk-syntax":"device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )","cmyk-component":"<number>|<percentage>|none","color-space":"<rectangular-color-space>|<polar-color-space>|<custom-color-space>",right:"<length>|auto","forgiving-selector-list":"<complex-real-selector-list>","forgiving-relative-selector-list":"<relative-real-selector-list>","complex-real-selector-list":"<complex-real-selector>#","simple-selector-list":"<simple-selector>#","relative-real-selector-list":"<relative-real-selector>#","complex-selector-unit":"[<compound-selector>? <pseudo-compound-selector>*]!","complex-real-selector":"<compound-selector> [<combinator>? <compound-selector>]*","relative-real-selector":"<combinator>? <complex-real-selector>","pseudo-compound-selector":"<pseudo-element-selector> <pseudo-class-selector>*","simple-selector":"<type-selector>|<subclass-selector>","legacy-pseudo-element-selector":"':' [before|after|first-line|first-letter]","svg-length":"<percentage>|<length>|<number>","svg-writing-mode":"lr-tb|rl-tb|tb-rl|lr|rl|tb",top:"<length>|auto",x:"<number>",y:"<number>",declaration:"<ident-token> : <declaration-value>? ['!' important]?","declaration-list":"[<declaration>? ';']* <declaration>?",url:"url( <string> <url-modifier>* )|<url-token>","url-modifier":"<ident>|<function-token> <any-value> )","number-zero-one":"<number [0,1]>","number-one-or-greater":"<number [1,\u221E]>","xyz-space":"xyz|xyz-d50|xyz-d65","style-condition":"not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]","-non-standard-display":"-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box","inset-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]",syntax:"'*'|<syntax-component> [<syntax-combinator> <syntax-component>]*|<syntax-string>","syntax-component":"<syntax-single-component> <syntax-multiplier>?|'<' transform-list '>'","syntax-single-component":"'<' <syntax-type-name> '>'|<ident>","syntax-type-name":"angle|color|custom-ident|image|integer|length|length-percentage|number|percentage|resolution|string|time|url|transform-function","syntax-combinator":"'|'","syntax-multiplier":"'#'|'+'","syntax-string":"<string>"},properties:{"--*":"<declaration-value>","-ms-accelerator":"false|true","-ms-block-progression":"tb|rl|bt|lr","-ms-content-zoom-chaining":"none|chained","-ms-content-zoom-limit":"<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>","-ms-content-zoom-limit-max":"<percentage>","-ms-content-zoom-limit-min":"<percentage>","-ms-content-zoom-snap":"<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>","-ms-content-zoom-snap-points":"snapInterval( <percentage> , <percentage> )|snapList( <percentage># )","-ms-content-zoom-snap-type":"none|proximity|mandatory","-ms-content-zooming":"none|zoom","-ms-filter":"<string>","-ms-flow-from":"[none|<custom-ident>]#","-ms-flow-into":"[none|<custom-ident>]#","-ms-grid-columns":"none|<track-list>|<auto-track-list>","-ms-grid-rows":"none|<track-list>|<auto-track-list>","-ms-high-contrast-adjust":"auto|none","-ms-hyphenate-limit-chars":"auto|<integer>{1,3}","-ms-hyphenate-limit-lines":"no-limit|<integer>","-ms-hyphenate-limit-zone":"<percentage>|<length>","-ms-ime-align":"auto|after","-ms-overflow-style":"auto|none|scrollbar|-ms-autohiding-scrollbar","-ms-scroll-chaining":"chained|none","-ms-scroll-limit":"<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>","-ms-scroll-limit-x-max":"auto|<length>","-ms-scroll-limit-x-min":"<length>","-ms-scroll-limit-y-max":"auto|<length>","-ms-scroll-limit-y-min":"<length>","-ms-scroll-rails":"none|railed","-ms-scroll-snap-points-x":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-points-y":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-type":"none|proximity|mandatory","-ms-scroll-snap-x":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>","-ms-scroll-snap-y":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>","-ms-scroll-translation":"none|vertical-to-horizontal","-ms-scrollbar-3dlight-color":"<color>","-ms-scrollbar-arrow-color":"<color>","-ms-scrollbar-base-color":"<color>","-ms-scrollbar-darkshadow-color":"<color>","-ms-scrollbar-face-color":"<color>","-ms-scrollbar-highlight-color":"<color>","-ms-scrollbar-shadow-color":"<color>","-ms-scrollbar-track-color":"<color>","-ms-text-autospace":"none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space","-ms-touch-select":"grippers|none","-ms-user-select":"none|element|text","-ms-wrap-flow":"auto|both|start|end|maximum|clear","-ms-wrap-margin":"<length>","-ms-wrap-through":"wrap|none","-moz-appearance":"none|button|button-arrow-down|button-arrow-next|button-arrow-previous|button-arrow-up|button-bevel|button-focus|caret|checkbox|checkbox-container|checkbox-label|checkmenuitem|dualbutton|groupbox|listbox|listitem|menuarrow|menubar|menucheckbox|menuimage|menuitem|menuitemtext|menulist|menulist-button|menulist-text|menulist-textfield|menupopup|menuradio|menuseparator|meterbar|meterchunk|progressbar|progressbar-vertical|progresschunk|progresschunk-vertical|radio|radio-container|radio-label|radiomenuitem|range|range-thumb|resizer|resizerpanel|scale-horizontal|scalethumbend|scalethumb-horizontal|scalethumbstart|scalethumbtick|scalethumb-vertical|scale-vertical|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|separator|sheet|spinner|spinner-downbutton|spinner-textfield|spinner-upbutton|splitter|statusbar|statusbarpanel|tab|tabpanel|tabpanels|tab-scroll-arrow-back|tab-scroll-arrow-forward|textfield|textfield-multiline|toolbar|toolbarbutton|toolbarbutton-dropdown|toolbargripper|toolbox|tooltip|treeheader|treeheadercell|treeheadersortarrow|treeitem|treeline|treetwisty|treetwistyopen|treeview|-moz-mac-unified-toolbar|-moz-win-borderless-glass|-moz-win-browsertabbar-toolbox|-moz-win-communicationstext|-moz-win-communications-toolbox|-moz-win-exclude-glass|-moz-win-glass|-moz-win-mediatext|-moz-win-media-toolbox|-moz-window-button-box|-moz-window-button-box-maximized|-moz-window-button-close|-moz-window-button-maximize|-moz-window-button-minimize|-moz-window-button-restore|-moz-window-frame-bottom|-moz-window-frame-left|-moz-window-frame-right|-moz-window-titlebar|-moz-window-titlebar-maximized","-moz-binding":"<url>|none","-moz-border-bottom-colors":"<color>+|none","-moz-border-left-colors":"<color>+|none","-moz-border-right-colors":"<color>+|none","-moz-border-top-colors":"<color>+|none","-moz-context-properties":"none|[fill|fill-opacity|stroke|stroke-opacity]#","-moz-float-edge":"border-box|content-box|margin-box|padding-box","-moz-force-broken-image-icon":"0|1","-moz-orient":"inline|block|horizontal|vertical","-moz-outline-radius":"<outline-radius>{1,4} [/ <outline-radius>{1,4}]?","-moz-outline-radius-bottomleft":"<outline-radius>","-moz-outline-radius-bottomright":"<outline-radius>","-moz-outline-radius-topleft":"<outline-radius>","-moz-outline-radius-topright":"<outline-radius>","-moz-stack-sizing":"ignore|stretch-to-fit","-moz-text-blink":"none|blink","-moz-user-focus":"ignore|normal|select-after|select-before|select-menu|select-same|select-all|none","-moz-user-input":"auto|none|enabled|disabled","-moz-user-modify":"read-only|read-write|write-only","-moz-window-dragging":"drag|no-drag","-moz-window-shadow":"default|menu|tooltip|sheet|none","-webkit-appearance":"none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|push-button|radio|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbargripper-horizontal|scrollbargripper-vertical|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|searchfield-cancel-button|searchfield-decoration|searchfield-results-button|searchfield-results-decoration|slider-horizontal|slider-vertical|sliderthumb-horizontal|sliderthumb-vertical|square-button|textarea|textfield|-apple-pay-button","-webkit-border-before":"<'border-width'>||<'border-style'>||<color>","-webkit-border-before-color":"<color>","-webkit-border-before-style":"<'border-style'>","-webkit-border-before-width":"<'border-width'>","-webkit-box-reflect":"[above|below|right|left]? <length>? <image>?","-webkit-line-clamp":"none|<integer>","-webkit-mask":"[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<visual-box>|border|padding|content|text]||[<visual-box>|border|padding|content]]#","-webkit-mask-attachment":"<attachment>#","-webkit-mask-clip":"[<coord-box>|no-clip|border|padding|content|text]#","-webkit-mask-composite":"<composite-style>#","-webkit-mask-image":"<mask-reference>#","-webkit-mask-origin":"[<coord-box>|border|padding|content]#","-webkit-mask-position":"<position>#","-webkit-mask-position-x":"[<length-percentage>|left|center|right]#","-webkit-mask-position-y":"[<length-percentage>|top|center|bottom]#","-webkit-mask-repeat":"<repeat-style>#","-webkit-mask-repeat-x":"repeat|no-repeat|space|round","-webkit-mask-repeat-y":"repeat|no-repeat|space|round","-webkit-mask-size":"<bg-size>#","-webkit-overflow-scrolling":"auto|touch","-webkit-tap-highlight-color":"<color>","-webkit-text-fill-color":"<color>","-webkit-text-stroke":"<length>||<color>","-webkit-text-stroke-color":"<color>","-webkit-text-stroke-width":"<length>","-webkit-touch-callout":"default|none","-webkit-user-modify":"read-only|read-write|read-write-plaintext-only","-webkit-user-select":"auto|none|text|all","accent-color":"auto|<color>","align-content":"normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>","align-items":"normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]|anchor-center","align-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>|anchor-center","align-tracks":"[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#","alignment-baseline":"auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical",all:"initial|inherit|unset|revert|revert-layer","anchor-name":"none|<dashed-ident>#","anchor-scope":"none|all|<dashed-ident>#",animation:"<single-animation>#","animation-composition":"<single-animation-composition>#","animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"[auto|<time [0s,\u221E]>]#","animation-fill-mode":"<single-animation-fill-mode>#","animation-iteration-count":"<single-animation-iteration-count>#","animation-name":"[none|<keyframes-name>]#","animation-play-state":"<single-animation-play-state>#","animation-range":"[<'animation-range-start'> <'animation-range-end'>?]#","animation-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-timeline":"<single-animation-timeline>#","animation-timing-function":"<easing-function>#","animation-trigger":"[none|[<dashed-ident> <animation-action>+]+]#",appearance:"none|auto|<compat-auto>|<compat-special>","aspect-ratio":"auto||<ratio>","backdrop-filter":"none|<filter-value-list>","backface-visibility":"visible|hidden",background:"<bg-layer>#? , <final-bg-layer>","background-attachment":"<attachment>#","background-blend-mode":"<blend-mode>#","background-clip":"<bg-clip>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<visual-box>#","background-position":"<bg-position>#","background-position-x":"[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#","background-position-y":"[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","baseline-shift":"baseline|sub|super|<svg-length>","baseline-source":"auto|first|last","block-size":"<'width'>",border:"<line-width>||<line-style>||<color>","border-block":"<'border-block-start'>","border-block-color":"<'border-top-color'>{1,2}","border-block-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-end-color":"<'border-top-color'>","border-block-end-style":"<'border-top-style'>","border-block-end-width":"<'border-top-width'>","border-block-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-start-color":"<'border-top-color'>","border-block-start-style":"<'border-top-style'>","border-block-start-width":"<'border-top-width'>","border-block-style":"<'border-top-style'>{1,2}","border-block-width":"<'border-top-width'>{1,2}","border-bottom":"<line-width>||<line-style>||<color>","border-bottom-color":"<'border-top-color'>","border-bottom-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-style":"<line-style>","border-bottom-width":"<line-width>","border-collapse":"separate|collapse","border-color":"<color>{1,4}","border-end-end-radius":"<'border-top-left-radius'>","border-end-start-radius":"<'border-top-left-radius'>","border-image":"<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>","border-image-outset":"[<length [0,\u221E]>|<number [0,\u221E]>]{1,4}","border-image-repeat":"[stretch|repeat|round|space]{1,2}","border-image-slice":"[<number [0,\u221E]>|<percentage [0,\u221E]>]{1,4}&&fill?","border-image-source":"none|<image>","border-image-width":"[<length-percentage [0,\u221E]>|<number [0,\u221E]>|auto]{1,4}","border-inline":"<'border-block-start'>","border-inline-color":"<'border-top-color'>{1,2}","border-inline-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-end-color":"<'border-top-color'>","border-inline-end-style":"<'border-top-style'>","border-inline-end-width":"<'border-top-width'>","border-inline-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-start-color":"<'border-top-color'>","border-inline-start-style":"<'border-top-style'>","border-inline-start-width":"<'border-top-width'>","border-inline-style":"<'border-top-style'>{1,2}","border-inline-width":"<'border-top-width'>{1,2}","border-left":"<line-width>||<line-style>||<color>","border-left-color":"<color>","border-left-style":"<line-style>","border-left-width":"<line-width>","border-radius":"<length-percentage [0,\u221E]>{1,4} [/ <length-percentage [0,\u221E]>{1,4}]?","border-right":"<line-width>||<line-style>||<color>","border-right-color":"<color>","border-right-style":"<line-style>","border-right-width":"<line-width>","border-spacing":"<length>{1,2}","border-start-end-radius":"<'border-top-left-radius'>","border-start-start-radius":"<'border-top-left-radius'>","border-style":"<line-style>{1,4}","border-top":"<line-width>||<line-style>||<color>","border-top-color":"<color>","border-top-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-style":"<line-style>","border-top-width":"<line-width>","border-width":"<line-width>{1,4}",bottom:"auto|<length-percentage>|<anchor()>|<anchor-size()>","box-align":"start|center|end|baseline|stretch","box-decoration-break":"slice|clone","box-direction":"normal|reverse|inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single|multiple","box-ordinal-group":"<integer>","box-orient":"horizontal|vertical|inline-axis|block-axis|inherit","box-pack":"start|center|end|justify","box-shadow":"none|<shadow>#","box-sizing":"content-box|border-box","break-after":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-before":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-inside":"auto|avoid|avoid-page|avoid-column|avoid-region","caption-side":"top|bottom",caret:"<'caret-color'>||<'caret-animation'>||<'caret-shape'>","caret-animation":"auto|manual","caret-color":"auto|<color>","caret-shape":"auto|bar|block|underscore",clear:"none|left|right|both|inline-start|inline-end",clip:"<shape>|auto","clip-path":"<clip-source>|[<basic-shape>||<geometry-box>]|none","clip-rule":"nonzero|evenodd",color:"<color>","color-interpolation-filters":"auto|sRGB|linearRGB","color-scheme":"normal|[light|dark|<custom-ident>]+&&only?","column-count":"<integer>|auto","column-fill":"auto|balance","column-gap":"normal|<length-percentage>","column-height":"auto|<length [0,\u221E]>","column-rule":"<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>","column-rule-color":"<color>","column-rule-style":"<'border-style'>","column-rule-width":"<'border-width'>","column-span":"none|all","column-width":"auto|<length [0,\u221E]>","column-wrap":"auto|nowrap|wrap",columns:"[<'column-width'>||<'column-count'>] [/ <'column-height'>]?",contain:"none|strict|content|[[size||inline-size]||layout||style||paint]","contain-intrinsic-block-size":"auto? [none|<length>]","contain-intrinsic-height":"auto? [none|<length>]","contain-intrinsic-inline-size":"auto? [none|<length>]","contain-intrinsic-size":"[auto? [none|<length>]]{1,2}","contain-intrinsic-width":"auto? [none|<length>]",container:"<'container-name'> [/ <'container-type'>]?","container-name":"none|<custom-ident>+","container-type":"normal||[size|inline-size]",content:"normal|none|[<content-replacement>|<content-list>] [/ [<string>|<counter>|<attr()>]+]?","content-visibility":"visible|auto|hidden","corner-block-end-shape":"<corner-shape-value>{1,2}","corner-block-start-shape":"<corner-shape-value>{1,2}","corner-bottom-shape":"<corner-shape-value>{1,2}","corner-bottom-left-shape":"<corner-shape-value>","corner-bottom-right-shape":"<corner-shape-value>","corner-end-end-shape":"<corner-shape-value>","corner-end-start-shape":"<corner-shape-value>","corner-inline-end-shape":"<corner-shape-value>{1,2}","corner-inline-start-shape":"<corner-shape-value>{1,2}","corner-left-shape":"<corner-shape-value>{1,2}","corner-right-shape":"<corner-shape-value>{1,2}","corner-shape":"<corner-shape-value>{1,4}","corner-start-start-shape":"<corner-shape-value>","corner-start-end-shape":"<corner-shape-value>","corner-top-shape":"<corner-shape-value>{1,2}","corner-top-left-shape":"<corner-shape-value>","corner-top-right-shape":"<corner-shape-value>","counter-increment":"[<counter-name> <integer>?]+|none","counter-reset":"[<counter-name> <integer>?|<reversed-counter-name> <integer>?]+|none","counter-set":"[<counter-name> <integer>?]+|none",cursor:"[[<url> [<x> <y>]? ,]* [auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing|hand|-webkit-grab|-webkit-grabbing|-webkit-zoom-in|-webkit-zoom-out|-moz-grab|-moz-grabbing|-moz-zoom-in|-moz-zoom-out]]",cx:"<length>|<percentage>",cy:"<length>|<percentage>",d:"none|path( <string> )",direction:"ltr|rtl",display:"[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>","dominant-baseline":"auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge","dynamic-range-limit":"standard|no-limit|constrained|<dynamic-range-limit-mix()>","empty-cells":"show|hide","field-sizing":"content|fixed",fill:"<paint>","fill-opacity":"<number-zero-one>|<percentage>","fill-rule":"nonzero|evenodd",filter:"none|<filter-value-list>|<-ms-filter-function-list>",flex:"none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]","flex-basis":"content|<'width'>","flex-direction":"row|row-reverse|column|column-reverse","flex-flow":"<'flex-direction'>||<'flex-wrap'>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap|wrap|wrap-reverse",float:"left|right|none|inline-start|inline-end","flood-color":"<color>","flood-opacity":"<'opacity'>",font:"[[<'font-style'>||<font-variant-css2>||<'font-weight'>||<font-width-css3>]? <'font-size'> [/ <'line-height'>]? <'font-family'>#]|<system-family-name>|<-non-standard-font>","font-family":"[<family-name>|<generic-family>]#","font-feature-settings":"normal|<feature-tag-value>#","font-kerning":"auto|normal|none","font-language-override":"normal|<string>","font-optical-sizing":"auto|none","font-palette":"normal|light|dark|<palette-identifier>|<palette-mix()>","font-size":"<absolute-size>|<relative-size>|<length-percentage [0,\u221E]>|math","font-size-adjust":"none|[ex-height|cap-height|ch-width|ic-width|ic-height]? [from-font|<number>]","font-smooth":"auto|never|always|<absolute-size>|<length>","font-stretch":"<font-stretch-absolute>","font-style":"normal|italic|oblique <angle>?","font-synthesis":"none|[weight||style||small-caps||position]","font-synthesis-position":"auto|none","font-synthesis-small-caps":"auto|none","font-synthesis-style":"auto|none","font-synthesis-weight":"auto|none","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-alternates":"normal|[stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )]","font-variant-caps":"normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","font-variant-east-asian":"normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-emoji":"normal|text|emoji|unicode","font-variant-ligatures":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]","font-variant-numeric":"normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]","font-variant-position":"normal|sub|super","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>|bolder|lighter","font-width":"normal|<percentage [0,\u221E]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","forced-color-adjust":"auto|none|preserve-parent-color",gap:"<'row-gap'> <'column-gap'>?",grid:"<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>","grid-area":"<grid-line> [/ <grid-line>]{0,3}","grid-auto-columns":"<track-size>+","grid-auto-flow":"[row|column]||dense","grid-auto-rows":"<track-size>+","grid-column":"<grid-line> [/ <grid-line>]?","grid-column-end":"<grid-line>","grid-column-gap":"<length-percentage>","grid-column-start":"<grid-line>","grid-gap":"<'grid-row-gap'> <'grid-column-gap'>?","grid-row":"<grid-line> [/ <grid-line>]?","grid-row-end":"<grid-line>","grid-row-gap":"<length-percentage>","grid-row-start":"<grid-line>","grid-template":"none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?","grid-template-areas":"none|<string>+","grid-template-columns":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","grid-template-rows":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","hanging-punctuation":"none|[first||[force-end|allow-end]||last]",height:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","hyphenate-character":"auto|<string>","hyphenate-limit-chars":"[auto|<integer>]{1,3}",hyphens:"none|manual|auto","image-orientation":"from-image|<angle>|[<angle>? flip]","image-rendering":"auto|crisp-edges|pixelated|smooth|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>","image-resolution":"[from-image||<resolution>]&&snap?","ime-mode":"auto|normal|active|inactive|disabled","initial-letter":"normal|[<number> <integer>?]","initial-letter-align":"[auto|alphabetic|hanging|ideographic]","inline-size":"<'width'>",inset:"<'top'>{1,4}","inset-block":"<'top'>{1,2}","inset-block-end":"<'top'>","inset-block-start":"<'top'>","inset-inline":"<'top'>{1,2}","inset-inline-end":"<'top'>","inset-inline-start":"<'top'>","interpolate-size":"numeric-only|allow-keywords",isolation:"auto|isolate",interactivity:"auto|inert","interest-delay":"<'interest-delay-start'>{1,2}","interest-delay-end":"normal|<time>","interest-delay-start":"normal|<time>","justify-content":"normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]","justify-items":"normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]|anchor-center","justify-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|anchor-center","justify-tracks":"[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",left:"auto|<length-percentage>|<anchor()>|<anchor-size()>","letter-spacing":"normal|<length-percentage>","lighting-color":"<color>","line-break":"auto|loose|normal|strict|anywhere","line-clamp":"none|<integer>","line-height":"normal|<number>|<length>|<percentage>","line-height-step":"<length>","list-style":"<'list-style-type'>||<'list-style-position'>||<'list-style-image'>","list-style-image":"<image>|none","list-style-position":"inside|outside","list-style-type":"<counter-style>|<string>|none",margin:"<'margin-top'>{1,4}","margin-block":"<'margin-top'>{1,2}","margin-block-end":"<'margin-top'>","margin-block-start":"<'margin-top'>","margin-bottom":"<length-percentage>|auto|<anchor-size()>","margin-inline":"<'margin-top'>{1,2}","margin-inline-end":"<'margin-top'>","margin-inline-start":"<'margin-top'>","margin-left":"<length-percentage>|auto|<anchor-size()>","margin-right":"<length-percentage>|auto|<anchor-size()>","margin-top":"<length-percentage>|auto|<anchor-size()>","margin-trim":"none|in-flow|all",marker:"none|<url>","marker-end":"none|<url>","marker-mid":"none|<url>","marker-start":"none|<url>",mask:"<mask-layer>#","mask-border":"<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>","mask-border-mode":"luminance|alpha","mask-border-outset":"[<length>|<number>]{1,4}","mask-border-repeat":"[stretch|repeat|round|space]{1,2}","mask-border-slice":"<number-percentage>{1,4} fill?","mask-border-source":"none|<image>","mask-border-width":"[<length-percentage>|<number>|auto]{1,4}","mask-clip":"[<coord-box>|no-clip]#","mask-composite":"<compositing-operator>#","mask-image":"<mask-reference>#","mask-mode":"<masking-mode>#","mask-origin":"<coord-box>#","mask-position":"<position>#","mask-repeat":"<repeat-style>#","mask-size":"<bg-size>#","mask-type":"luminance|alpha","masonry-auto-flow":"[pack|next]||[definite-first|ordered]","math-depth":"auto-add|add( <integer> )|<integer>","math-shift":"normal|compact","math-style":"normal|compact","max-block-size":"<'max-width'>","max-height":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","max-inline-size":"<'max-width'>","max-lines":"none|<integer>","max-width":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-block-size":"<'min-width'>","min-height":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-inline-size":"<'min-width'>","min-width":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","mix-blend-mode":"<blend-mode>|plus-darker|plus-lighter","object-fit":"fill|contain|cover|none|scale-down","object-position":"<position>","object-view-box":"none|<basic-shape-rect>",offset:"[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?","offset-anchor":"auto|<position>","offset-distance":"<length-percentage>","offset-path":"none|<offset-path>||<coord-box>","offset-position":"normal|auto|<position>","offset-rotate":"[auto|reverse]||<angle>",opacity:"<opacity-value>",order:"<integer>",orphans:"<integer>",outline:"<'outline-width'>||<'outline-style'>||<'outline-color'>","outline-color":"auto|<color>","outline-offset":"<length>","outline-style":"auto|<outline-line-style>","outline-width":"<line-width>",overflow:"[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>","overflow-anchor":"auto|none","overflow-block":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-clip-box":"padding-box|content-box","overflow-clip-margin":"<visual-box>||<length [0,\u221E]>","overflow-inline":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-wrap":"normal|break-word|anywhere","overflow-x":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-y":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>",overlay:"none|auto","overscroll-behavior":"[contain|none|auto]{1,2}","overscroll-behavior-block":"contain|none|auto","overscroll-behavior-inline":"contain|none|auto","overscroll-behavior-x":"contain|none|auto","overscroll-behavior-y":"contain|none|auto",padding:"<'padding-top'>{1,4}","padding-block":"<'padding-top'>{1,2}","padding-block-end":"<'padding-top'>","padding-block-start":"<'padding-top'>","padding-bottom":"<length-percentage [0,\u221E]>","padding-inline":"<'padding-top'>{1,2}","padding-inline-end":"<'padding-top'>","padding-inline-start":"<'padding-top'>","padding-left":"<length-percentage [0,\u221E]>","padding-right":"<length-percentage [0,\u221E]>","padding-top":"<length-percentage [0,\u221E]>",page:"auto|<custom-ident>","page-break-after":"auto|always|avoid|left|right|recto|verso","page-break-before":"auto|always|avoid|left|right|recto|verso","page-break-inside":"auto|avoid","paint-order":"normal|[fill||stroke||markers]",perspective:"none|<length>","perspective-origin":"<position>","place-content":"<'align-content'> <'justify-content'>?","place-items":"<'align-items'> <'justify-items'>?","place-self":"<'align-self'> <'justify-self'>?","pointer-events":"auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",position:"static|relative|absolute|sticky|fixed|-webkit-sticky","position-anchor":"auto|none|<anchor-name>","position-area":"none|<position-area>","position-try":"<'position-try-order'>? <'position-try-fallbacks'>","position-try-fallbacks":"none|[[<dashed-ident>||<try-tactic>]|<'position-area'>]#","position-try-order":"normal|<try-size>","position-visibility":"always|[anchors-valid||anchors-visible||no-overflow]","print-color-adjust":"economy|exact",quotes:"none|auto|[<string> <string>]+",r:"<length>|<percentage>","reading-flow":"normal|source-order|flex-visual|flex-flow|grid-rows|grid-columns|grid-order","reading-order":"<integer>",resize:"none|both|horizontal|vertical|block|inline",right:"auto|<length-percentage>|<anchor()>|<anchor-size()>",rotate:"none|<angle>|[x|y|z|<number>{3}]&&<angle>","row-gap":"normal|<length-percentage>","ruby-align":"start|center|space-between|space-around","ruby-merge":"separate|collapse|auto","ruby-overhang":"auto|none","ruby-position":"[alternate||[over|under]]|inter-character",rx:"<length>|<percentage>",ry:"<length>|<percentage>",scale:"none|[<number>|<percentage>]{1,3}","scroll-behavior":"auto|smooth","scroll-initial-target":"none|nearest","scroll-margin":"<length>{1,4}","scroll-margin-block":"<length>{1,2}","scroll-margin-block-end":"<length>","scroll-margin-block-start":"<length>","scroll-margin-bottom":"<length>","scroll-margin-inline":"<length>{1,2}","scroll-margin-inline-end":"<length>","scroll-margin-inline-start":"<length>","scroll-margin-left":"<length>","scroll-margin-right":"<length>","scroll-margin-top":"<length>","scroll-marker-group":"none|before|after","scroll-padding":"[auto|<length-percentage>]{1,4}","scroll-padding-block":"[auto|<length-percentage>]{1,2}","scroll-padding-block-end":"auto|<length-percentage>","scroll-padding-block-start":"auto|<length-percentage>","scroll-padding-bottom":"auto|<length-percentage>","scroll-padding-inline":"[auto|<length-percentage>]{1,2}","scroll-padding-inline-end":"auto|<length-percentage>","scroll-padding-inline-start":"auto|<length-percentage>","scroll-padding-left":"auto|<length-percentage>","scroll-padding-right":"auto|<length-percentage>","scroll-padding-top":"auto|<length-percentage>","scroll-snap-align":"[none|start|end|center]{1,2}","scroll-snap-coordinate":"none|<position>#","scroll-snap-destination":"<position>","scroll-snap-points-x":"none|repeat( <length-percentage> )","scroll-snap-points-y":"none|repeat( <length-percentage> )","scroll-snap-stop":"normal|always","scroll-snap-type":"none|[x|y|block|inline|both] [mandatory|proximity]?","scroll-snap-type-x":"none|mandatory|proximity","scroll-snap-type-y":"none|mandatory|proximity","scroll-target-group":"none|auto","scroll-timeline":"[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#","scroll-timeline-axis":"[block|inline|x|y]#","scroll-timeline-name":"[none|<dashed-ident>]#","scrollbar-color":"auto|<color>{2}","scrollbar-gutter":"auto|stable&&both-edges?","scrollbar-width":"auto|thin|none","shape-image-threshold":"<opacity-value>","shape-margin":"<length-percentage>","shape-outside":"none|[<shape-box>||<basic-shape>]|<image>","shape-rendering":"auto|optimizeSpeed|crispEdges|geometricPrecision","speak-as":"normal|spell-out||digits||[literal-punctuation|no-punctuation]","stop-color":"<'color'>","stop-opacity":"<'opacity'>",stroke:"<paint>","stroke-color":"<color>","stroke-dasharray":"none|[<svg-length>+]#","stroke-dashoffset":"<svg-length>","stroke-linecap":"butt|round|square","stroke-linejoin":"miter|round|bevel","stroke-miterlimit":"<number-one-or-greater>","stroke-opacity":"<'opacity'>","stroke-width":"<svg-length>","tab-size":"<integer>|<length>","table-layout":"auto|fixed","text-align":"start|end|left|right|center|justify|match-parent","text-align-last":"auto|start|end|left|right|center|justify","text-anchor":"start|middle|end","text-autospace":"normal|<autospace>|auto","text-box":"normal|<'text-box-trim'>||<'text-box-edge'>","text-box-edge":"auto|<text-edge>","text-box-trim":"none|trim-start|trim-end|trim-both","text-combine-upright":"none|all|[digits <integer>?]","text-decoration":"<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>","text-decoration-color":"<color>","text-decoration-inset":"<length>{1,2}|auto","text-decoration-line":"none|[underline||overline||line-through||blink]|spelling-error|grammar-error","text-decoration-skip":"none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]","text-decoration-skip-ink":"auto|all|none","text-decoration-style":"solid|double|dotted|dashed|wavy","text-decoration-thickness":"auto|from-font|<length>|<percentage>","text-emphasis":"<'text-emphasis-style'>||<'text-emphasis-color'>","text-emphasis-color":"<color>","text-emphasis-position":"auto|[over|under]&&[right|left]?","text-emphasis-style":"none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>","text-indent":"<length-percentage>&&hanging?&&each-line?","text-justify":"auto|inter-character|inter-word|none","text-orientation":"mixed|upright|sideways","text-overflow":"[clip|ellipsis|<string>]{1,2}","text-rendering":"auto|optimizeSpeed|optimizeLegibility|geometricPrecision","text-shadow":"none|<shadow-t>#","text-size-adjust":"none|auto|<percentage>","text-spacing-trim":"space-all|normal|space-first|trim-start","text-transform":"none|[capitalize|uppercase|lowercase]||full-width||full-size-kana|math-auto","text-underline-offset":"auto|<length>|<percentage>","text-underline-position":"auto|from-font|[under||[left|right]]","text-wrap":"<'text-wrap-mode'>||<'text-wrap-style'>","text-wrap-mode":"wrap|nowrap","text-wrap-style":"auto|balance|stable|pretty","timeline-scope":"none|<dashed-ident>#","timeline-trigger":"none|[<'timeline-trigger-name'> <'timeline-trigger-source'> <'timeline-trigger-range'> ['/' <'timeline-trigger-exit-range'>]?]#","timeline-trigger-name":"none|<dashed-ident>#","timeline-trigger-exit-range":"[<'timeline-trigger-exit-range-start'> <'timeline-trigger-exit-range-end'>?]#","timeline-trigger-exit-range-end":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-exit-range-start":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range":"[<'timeline-trigger-range-start'> <'timeline-trigger-range-end'>?]#","timeline-trigger-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-source":"<single-animation-timeline>#",top:"auto|<length-percentage>|<anchor()>|<anchor-size()>","touch-action":"auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",transform:"none|<transform-list>","transform-box":"content-box|border-box|fill-box|stroke-box|view-box","transform-origin":"[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?","transform-style":"flat|preserve-3d",transition:"<single-transition>#","transition-behavior":"<transition-behavior-value>#","transition-delay":"<time>#","transition-duration":"<time>#","transition-property":"none|<single-transition-property>#","transition-timing-function":"<easing-function>#",translate:"none|<length-percentage> [<length-percentage> <length>?]?","trigger-scope":"none|all|<dashed-ident>#","unicode-bidi":"normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext","user-select":"auto|text|none|all","vector-effect":"none|non-scaling-stroke|non-scaling-size|non-rotation|fixed-position","vertical-align":"baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>","view-timeline":"[<'view-timeline-name'> [<'view-timeline-axis'>||<'view-timeline-inset'>]?]#","view-timeline-axis":"[block|inline|x|y]#","view-timeline-inset":"[[auto|<length-percentage>]{1,2}]#","view-timeline-name":"[none|<dashed-ident>]#","view-transition-class":"none|<custom-ident>+","view-transition-name":"none|<custom-ident>|match-element",visibility:"visible|hidden|collapse","white-space":"normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>","white-space-collapse":"collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",widows:"<integer>",width:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","will-change":"auto|<animateable-feature>#","word-break":"normal|break-all|keep-all|break-word|auto-phrase","word-spacing":"normal|<length>","word-wrap":"normal|break-word","writing-mode":"horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>",x:"<length>|<percentage>",y:"<length>|<percentage>","z-index":"auto|<integer>",zoom:"normal|reset|<number [0,\u221E]>||<percentage [0,\u221E]>","-moz-background-clip":"padding|border","-moz-border-radius-bottomleft":"<'border-bottom-left-radius'>","-moz-border-radius-bottomright":"<'border-bottom-right-radius'>","-moz-border-radius-topleft":"<'border-top-left-radius'>","-moz-border-radius-topright":"<'border-bottom-right-radius'>","-moz-control-character-visibility":"visible|hidden","-moz-osx-font-smoothing":"auto|grayscale","-moz-user-select":"none|text|all|-moz-none","-ms-flex-align":"start|end|center|baseline|stretch","-ms-flex-item-align":"auto|start|end|center|baseline|stretch","-ms-flex-line-pack":"start|end|center|justify|distribute|stretch","-ms-flex-negative":"<'flex-shrink'>","-ms-flex-pack":"start|end|center|justify|distribute","-ms-flex-order":"<integer>","-ms-flex-positive":"<'flex-grow'>","-ms-flex-preferred-size":"<'flex-basis'>","-ms-interpolation-mode":"nearest-neighbor|bicubic","-ms-grid-column-align":"start|end|center|stretch","-ms-grid-row-align":"start|end|center|stretch","-ms-hyphenate-limit-last":"none|always|column|page|spread","-webkit-background-clip":"[<visual-box>|border|padding|content|text]#","-webkit-column-break-after":"always|auto|avoid","-webkit-column-break-before":"always|auto|avoid","-webkit-column-break-inside":"always|auto|avoid","-webkit-font-smoothing":"auto|none|antialiased|subpixel-antialiased","-webkit-mask-box-image":"[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?","-webkit-print-color-adjust":"economy|exact","-webkit-text-security":"none|circle|disc|square","-webkit-user-drag":"none|element|auto",behavior:"<url>+",cue:"<'cue-before'> <'cue-after'>?","cue-after":"<url> <decibel>?|none","cue-before":"<url> <decibel>?|none","glyph-orientation-horizontal":"<angle>","glyph-orientation-vertical":"<angle>",kerning:"auto|<svg-length>",pause:"<'pause-before'> <'pause-after'>?","pause-after":"<time>|none|x-weak|weak|medium|strong|x-strong","pause-before":"<time>|none|x-weak|weak|medium|strong|x-strong","position-try-options":"<'position-try-fallbacks'>",rest:"<'rest-before'> <'rest-after'>?","rest-after":"<time>|none|x-weak|weak|medium|strong|x-strong","rest-before":"<time>|none|x-weak|weak|medium|strong|x-strong",speak:"auto|never|always","voice-balance":"<number>|left|center|right|leftwards|rightwards","voice-duration":"auto|<time>","voice-family":"[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve","voice-pitch":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-range":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-rate":"[normal|x-slow|slow|medium|fast|x-fast]||<percentage>","voice-stress":"normal|strong|moderate|none|reduced","voice-volume":"silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]","white-space-trim":"none|discard-before||discard-after||discard-inner"},atrules:{charset:{prelude:"<string>",descriptors:null},"counter-style":{prelude:"<counter-style-name>",descriptors:{"additive-symbols":"[<integer [0,\u221E]>&&<symbol>]#",fallback:"<counter-style-name>",negative:"<symbol> <symbol>?",pad:"<integer [0,\u221E]>&&<symbol>",prefix:"<symbol>",range:"[[<integer>|infinite]{2}]#|auto","speak-as":"auto|bullets|numbers|words|spell-out|<counter-style-name>",suffix:"<symbol>",symbols:"<symbol>+",system:"cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"}},container:{prelude:"[<container-name>]? <container-condition>",descriptors:null},document:{prelude:"[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",descriptors:null},"font-face":{prelude:null,descriptors:{"ascent-override":"normal|<percentage>","descent-override":"normal|<percentage>","font-display":"auto|block|swap|fallback|optional","font-family":"<family-name>","font-feature-settings":"normal|<feature-tag-value>#","font-stretch":"<font-stretch-absolute>{1,2}","font-style":"normal|italic|oblique <angle>{0,2}","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>{1,2}","line-gap-override":"normal|<percentage>","size-adjust":"<percentage>",src:"[<url> [format( <string># )]?|local( <family-name> )]#","unicode-range":"<urange>#"}},"font-feature-values":{prelude:"<family-name>#",descriptors:null},"font-palette-values":{prelude:"<dashed-ident>",descriptors:{"base-palette":"light|dark|<integer [0,\u221E]>","font-family":"<family-name>#","override-colors":"[<integer [0,\u221E]> <color>]#"}},import:{prelude:"[<string>|<url>] [layer|layer( <layer-name> )]? [supports( [<supports-condition>|<declaration>] )]? <media-query-list>?",descriptors:null},keyframes:{prelude:"<keyframes-name>",descriptors:null},layer:{prelude:"[<layer-name>#|<layer-name>?]",descriptors:null},media:{prelude:"<media-query-list>",descriptors:null},namespace:{prelude:"<namespace-prefix>? [<string>|<url>]",descriptors:null},page:{prelude:"<page-selector-list>",descriptors:{bleed:"auto|<length>",marks:"none|[crop||cross]","page-orientation":"upright|rotate-left|rotate-right",size:"<length [0,\u221E]>{1,2}|auto|[<page-size>||[portrait|landscape]]"}},"position-try":{prelude:"<dashed-ident>",descriptors:{top:"<'top'>",left:"<'left'>",bottom:"<'bottom'>",right:"<'right'>","inset-block-start":"<'inset-block-start'>","inset-block-end":"<'inset-block-end'>","inset-inline-start":"<'inset-inline-start'>","inset-inline-end":"<'inset-inline-end'>","inset-block":"<'inset-block'>","inset-inline":"<'inset-inline'>",inset:"<'inset'>","margin-top":"<'margin-top'>","margin-left":"<'margin-left'>","margin-bottom":"<'margin-bottom'>","margin-right":"<'margin-right'>","margin-block-start":"<'margin-block-start'>","margin-block-end":"<'margin-block-end'>","margin-inline-start":"<'margin-inline-start'>","margin-inline-end":"<'margin-inline-end'>",margin:"<'margin'>","margin-block":"<'margin-block'>","margin-inline":"<'margin-inline'>",width:"<'width'>",height:"<'height'>","min-width":"<'min-width'>","min-height":"<'min-height'>","max-width":"<'max-width'>","max-height":"<'max-height'>","block-size":"<'block-size'>","inline-size":"<'inline-size'>","min-block-size":"<'min-block-size'>","min-inline-size":"<'min-inline-size'>","max-block-size":"<'max-block-size'>","max-inline-size":"<'max-inline-size'>","align-self":"<'align-self'>|anchor-center","justify-self":"<'justify-self'>|anchor-center"}},property:{prelude:"<custom-property-name>",descriptors:{inherits:"true|false","initial-value":"<declaration-value>?",syntax:"<string>"}},scope:{prelude:"[( <scope-start> )]? [to ( <scope-end> )]?",descriptors:null},"starting-style":{prelude:null,descriptors:null},supports:{prelude:"<supports-condition>",descriptors:null},"view-transition":{prelude:null,descriptors:{navigation:"auto|none",types:"none|<custom-ident>+"}},"font-features-values":{prelude:"[<string>|<custom-ident>]+",descriptors:{"font-display":"auto|block|swap|fallback|optional"}}}}});var cp={};ye(cp,{generate:()=>gP,name:()=>dP,parse:()=>lp,structure:()=>fP});function xl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Lr||r===Gn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)_t(this.charCodeAt(n))||this.error("Integer is expected",n)}function bi(e){return xl.call(this,0,e)}function po(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case hl:n="N is expected";break;case Gn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function ap(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Lr,e)||this.isDelim(Gn,e)){t=this.isDelim(Lr,e)?Lr:Gn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),bi.call(this,Oo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Lr&&n!==Gn&&this.error("Number sign is expected")),bi.call(this,t!==0),t===Gn?"-"+this.consume(10):this.consume(10)}function lp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)bi.call(this,pP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Gn))switch(t="-1",po.call(this,1,hl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=ap.call(this);break;case 3:po.call(this,2,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,2,Gn),xl.call(this,3,Oo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Lr)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Lr)&&(r=1,this.next()),po.call(this,0,hl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=ap.call(this);break;case 2:po.call(this,1,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,1,Gn),xl.call(this,2,Oo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Lr||r===Gn,i=this.tokenStart+o;for(;i<this.tokenEnd&&_t(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),po.call(this,i-this.tokenStart,hl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=ap.call(this)):(po.call(this,i-this.tokenStart+1,Gn),i+2===this.tokenEnd?(this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10)):(xl.call(this,i-this.tokenStart+2,Oo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Lr&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Lr&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function gP(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let n=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+n)}else this.tokenize(t)}else this.tokenize(e.b)}var Lr,Gn,hl,Oo,pP,dP,fP,up=$(()=>{"use strict";nr();Lr=43,Gn=45,hl=110,Oo=!0,pP=!1;dP="AnPlusB",fP={a:[String,null],b:[String,null]}});var dp={};ye(dp,{generate:()=>bP,name:()=>hP,parse:()=>pp,structure:()=>yP,walkContext:()=>xP});function u0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function mP(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}function pp(e=!1){let t=this.tokenStart,n,r,o=null,i=null;switch(this.eat(3),n=this.substrToCursor(t+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==23&&this.tokenType!==17&&(this.parseAtrulePrelude?o=this.parseWithFallback(this.AtrulePrelude.bind(this,n,e),u0):o=u0.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?i=this.atrule[r].block.call(this,e):i=this.Block(mP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function bP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var hP,xP,yP,fp=$(()=>{"use strict";hP="Atrule",xP="atrule",yP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var mp={};ye(mp,{generate:()=>kP,name:()=>SP,parse:()=>gp,structure:()=>vP,walkContext:()=>wP});function gp(e){let t=null;return e!==null&&(e=e.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,e)&&typeof this.atrule[e].prelude=="function"?t=this.atrule[e].prelude.call(this):t=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==23&&this.tokenType!==17&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(t),children:t}}function kP(e){this.children(e)}var SP,wP,vP,hp=$(()=>{"use strict";SP="AtrulePrelude",wP="atrulePrelude",vP={children:[[]]}});var bp={};ye(bp,{generate:()=>LP,name:()=>AP,parse:()=>yp,structure:()=>PP});function FP(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(p0)?(t=!0,this.next()):this.isDelim(xp)||this.eat(1),this.isDelim(xp)?this.charCodeAt(this.tokenStart+1)!==yl?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function EP(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==yl&&t!==IP&&t!==TP&&t!==CP&&t!==p0&&t!==xp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==yl&&(this.isDelim(yl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function yp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=FP.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=EP.call(this),this.skipSC(),r=this.tokenType===5?this.String():this.Identifier(),this.skipSC()),this.tokenType===1&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:n,value:r,flags:o}}function LP(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]")}var CP,p0,yl,TP,xp,IP,AP,PP,Sp=$(()=>{"use strict";CP=36,p0=42,yl=61,TP=94,xp=124,IP=126;AP="AttributeSelector",PP={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var vp={};ye(vp,{generate:()=>NP,name:()=>DP,parse:()=>wp,structure:()=>zP,walkContext:()=>RP});function g0(){return this.Raw(null,!0)}function d0(){return this.parseWithFallback(this.Rule,g0)}function f0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function BP(){if(this.tokenType===17)return f0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,f0);return this.tokenType===17&&this.next(),e}function wp(e){let t=e?BP:d0,n=this.tokenStart,r=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:r.push(this.parseWithFallback(this.Atrule.bind(this,e),g0));break;default:e&&this.isDelim(MP)?r.push(d0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function NP(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var MP,DP,RP,zP,kp=$(()=>{"use strict";MP=38;DP="Block",RP="block",zP={children:[["Atrule","Rule","Declaration"]]}});var Tp={};ye(Tp,{generate:()=>$P,name:()=>OP,parse:()=>Cp,structure:()=>_P});function Cp(e,t){let n=this.tokenStart,r=null;return this.eat(19),r=e.call(this,t),this.eof||this.eat(20),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function $P(e){this.token(9,"["),this.children(e),this.token(9,"]")}var OP,_P,Ip=$(()=>{"use strict";OP="Brackets",_P={children:[[]]}});var Ep={};ye(Ep,{generate:()=>HP,name:()=>UP,parse:()=>Fp,structure:()=>jP});function Fp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function HP(){this.token(15,"-->")}var UP,jP,Ap=$(()=>{"use strict";UP="CDC",jP=[]});var Lp={};ye(Lp,{generate:()=>GP,name:()=>WP,parse:()=>Pp,structure:()=>VP});function Pp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function GP(){this.token(14,"<!--")}var WP,VP,Mp=$(()=>{"use strict";WP="CDO",VP=[]});var Dp={};ye(Dp,{generate:()=>XP,name:()=>YP,parse:()=>Bp,structure:()=>KP});function Bp(){return this.eatDelim(qP),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function XP(e){this.token(9,"."),this.token(1,e.name)}var qP,YP,KP,Rp=$(()=>{"use strict";qP=46,YP="ClassSelector",KP={name:String}});var Np={};ye(Np,{generate:()=>n2,name:()=>e2,parse:()=>zp,structure:()=>t2});function zp(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case JP:case QP:case ZP:this.next();break;case m0:this.next(),this.eatIdent("deep"),this.eatDelim(m0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function n2(e){this.tokenize(e.name)}var QP,m0,JP,ZP,e2,t2,Op=$(()=>{"use strict";QP=43,m0=47,JP=62,ZP=126,e2="Combinator",t2={name:String}});var $p={};ye($p,{generate:()=>a2,name:()=>i2,parse:()=>_p,structure:()=>s2});function _p(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===r2&&this.charCodeAt(t-1)===o2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function a2(e){this.token(25,"/*"+e.value+"*/")}var r2,o2,i2,s2,Up=$(()=>{"use strict";r2=42,o2=47,i2="Comment",s2={value:String}});var Hp={};ye(Hp,{generate:()=>d2,name:()=>c2,parse:()=>jp,structure:()=>u2});function h0(e){return this.lookupTypeNonSC(1)===1&&l2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function jp(e="media"){let t=this.createList();e:for(;!this.eof;)switch(this.tokenType){case 25:case 13:this.next();continue;case 1:t.push(this.Identifier());break;case 21:{let n=this.parseWithFallback(()=>p2[e].call(this,e),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(21);let r=this.Condition(e);return this.eat(22),r},()=>this.GeneralEnclosed(e))),t.push(n);break}case 2:{let n=this.parseWithFallback(()=>this.FeatureFunction(e),()=>null);n||(n=this.GeneralEnclosed(e)),t.push(n);break}default:break e}return t.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(t),kind:e,children:t}}function d2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var l2,c2,u2,p2,Wp=$(()=>{"use strict";l2=new Set([16,22,0]),c2="Condition",u2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};p2={media:h0,container:h0,supports(){return this.SupportsDeclaration()}}});var Gp={};ye(Gp,{generate:()=>C2,name:()=>w2,parse:()=>Vp,structure:()=>k2,walkContext:()=>v2});function y2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function b2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function S2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(y0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function Vp(){let e=this.tokenStart,t=this.tokenIndex,n=T2.call(this),r=ol(n),o=r?this.parseCustomProperty:this.parseValue,i=r?b2:y2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(S2,i):a=i.call(this,this.tokenIndex),r&&a.type==="Value"&&a.children.isEmpty){for(let c=u-this.tokenIndex;c<=0;c++)if(this.lookupType(c)===13){a.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(y0)&&(s=I2.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==17&&this.isBalanceEdge(t)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(e,this.tokenStart),important:s,property:n,value:a}}function C2(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important))}function T2(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case h2:case g2:case x2:case f2:case m2:this.next();break;case x0:this.next(),this.isDelim(x0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function I2(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var y0,f2,g2,m2,h2,x2,x0,w2,v2,k2,qp=$(()=>{"use strict";il();y0=33,f2=35,g2=36,m2=38,h2=42,x2=43,x0=47;w2="Declaration",v2="declaration",k2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var Xp={};ye(Xp,{generate:()=>P2,name:()=>E2,parse:()=>Kp,structure:()=>A2});function Yp(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Kp(){let e=this.createList();for(;!this.eof;)switch(this.tokenType){case 13:case 25:case 17:this.next();break;case 3:e.push(this.parseWithFallback(this.Atrule.bind(this,!0),Yp));break;default:this.isDelim(F2)?e.push(this.parseWithFallback(this.Rule,Yp)):e.push(this.parseWithFallback(this.Declaration,Yp))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function P2(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var F2,E2,A2,Qp=$(()=>{"use strict";F2=38;E2="DeclarationList",A2={children:[["Declaration","Atrule","Rule"]]}});var Zp={};ye(Zp,{generate:()=>B2,name:()=>L2,parse:()=>Jp,structure:()=>M2});function Jp(){let e=this.tokenStart,t=this.consumeNumber(12);return{type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function B2(e){this.token(12,e.value+e.unit)}var L2,M2,ed=$(()=>{"use strict";L2="Dimension",M2={value:String,unit:String}});var nd={};ye(nd,{generate:()=>N2,name:()=>R2,parse:()=>td,structure:()=>z2});function td(e){let t=this.tokenStart,n,r=null;if(this.eat(21),this.skipSC(),n=this.consume(1),this.skipSC(),this.tokenType!==22){switch(this.eat(16),this.skipSC(),this.tokenType){case 10:this.lookupNonWSType(1)===9?r=this.Ratio():r=this.Number();break;case 12:r=this.Dimension();break;case 1:r=this.Identifier();break;case 2:r=this.parseWithFallback(()=>{let o=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(D2)&&this.error(),o},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(22),{type:"Feature",loc:this.getLocation(t,this.tokenStart),kind:e,name:n,value:r}}function N2(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var D2,R2,z2,rd=$(()=>{"use strict";D2=47,R2="Feature",z2={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var id={};ye(id,{generate:()=>U2,name:()=>O2,parse:()=>od,structure:()=>_2});function $2(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function od(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=$2.call(this,e,n.toLowerCase());this.skipSC();let o=this.parseWithFallback(()=>{let i=this.tokenIndex,s=r.call(this);return this.eof===!1&&this.isBalanceEdge(i)===!1&&this.error(),s},()=>this.Raw(null,!1));return this.eof||this.eat(22),{type:"FeatureFunction",loc:this.getLocation(t,this.tokenStart),kind:e,feature:n,value:o}}function U2(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var O2,_2,sd=$(()=>{"use strict";O2="FeatureFunction",_2={kind:String,feature:String,value:["Declaration","Selector"]}});var cd={};ye(cd,{generate:()=>G2,name:()=>W2,parse:()=>ld,structure:()=>V2});function ad(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(b0,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case 12:return this.Dimension();case 1:return this.Identifier();case 2:return this.parseWithFallback(()=>{let e=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(b0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function w0(e){if(this.skipSC(),this.isDelim(j2)||this.isDelim(H2)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(S0)?(this.next(),t+"="):t}if(this.isDelim(S0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function ld(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=ad.call(this),r=w0.call(this,n.type==="Identifier"),o=ad.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=w0.call(this),s=ad.call(this)),this.skipSC(),this.eat(22),{type:"FeatureRange",loc:this.getLocation(t,this.tokenStart),kind:e,left:n,leftComparison:r,middle:o,rightComparison:i,right:s}}function G2(e){this.token(21,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(22,")")}var b0,j2,S0,H2,W2,V2,ud=$(()=>{"use strict";b0=47,j2=60,S0=61,H2=62,W2="FeatureRange",V2={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]}});var dd={};ye(dd,{generate:()=>X2,name:()=>q2,parse:()=>pd,structure:()=>K2,walkContext:()=>Y2});function pd(e,t){let n=this.tokenStart,r=this.consumeFunctionName(),o=r.toLowerCase(),i;return i=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:i}}function X2(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var q2,Y2,K2,fd=$(()=>{"use strict";q2="Function",Y2="function",K2={name:String,children:[[]]}});var md={};ye(md,{generate:()=>Z2,name:()=>Q2,parse:()=>gd,structure:()=>J2});function gd(e){let t=this.tokenStart,n=null;this.tokenType===2?n=this.consumeFunctionName():this.eat(21);let r=this.parseWithFallback(()=>{let o=this.tokenIndex,i=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),i},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(22),{type:"GeneralEnclosed",loc:this.getLocation(t,this.tokenStart),kind:e,function:n,children:r}}function Z2(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var Q2,J2,hd=$(()=>{"use strict";Q2="GeneralEnclosed",J2={kind:String,function:[String,null],children:[[]]}});var yd={};ye(yd,{generate:()=>rL,name:()=>tL,parse:()=>xd,structure:()=>nL,xxx:()=>eL});function xd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function rL(e){this.token(4,"#"+e.value)}var eL,tL,nL,bd=$(()=>{"use strict";eL="XXX",tL="Hash",nL={value:String}});var wd={};ye(wd,{generate:()=>sL,name:()=>oL,parse:()=>Sd,structure:()=>iL});function Sd(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function sL(e){this.token(1,e.name)}var oL,iL,vd=$(()=>{"use strict";oL="Identifier",iL={name:String}});var Cd={};ye(Cd,{generate:()=>cL,name:()=>aL,parse:()=>kd,structure:()=>lL});function kd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function cL(e){this.token(9,"#"+e.name)}var aL,lL,Td=$(()=>{"use strict";aL="IdSelector",lL={name:String}});var Fd={};ye(Fd,{generate:()=>fL,name:()=>pL,parse:()=>Id,structure:()=>dL});function Id(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(uL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function fL(e){this.tokenize(e.name)}var uL,pL,dL,Ed=$(()=>{"use strict";uL=46,pL="Layer",dL={name:String}});var Pd={};ye(Pd,{generate:()=>hL,name:()=>gL,parse:()=>Ad,structure:()=>mL});function Ad(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.Layer()),this.lookupTypeNonSC(0)===18);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(e),children:e}}function hL(e){this.children(e,()=>this.token(18,","))}var gL,mL,Ld=$(()=>{"use strict";gL="LayerList",mL={children:[["Layer"]]}});var Bd={};ye(Bd,{generate:()=>bL,name:()=>xL,parse:()=>Md,structure:()=>yL});function Md(){let e=this.tokenStart,t=null,n=null,r=null;if(this.skipSC(),this.tokenType===1&&this.lookupTypeNonSC(1)!==21){let o=this.consume(1),i=o.toLowerCase();switch(i==="not"||i==="only"?(this.skipSC(),t=i,n=this.consume(1)):n=o,this.lookupTypeNonSC(0)){case 1:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case 23:case 17:case 18:case 0:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case 1:case 21:case 2:{r=this.Condition("media");break}case 23:case 17:case 0:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:r}}function bL(e){e.mediaType?(e.modifier&&this.token(1,e.modifier),this.token(1,e.mediaType),e.condition&&(this.token(1,"and"),this.node(e.condition))):e.condition&&this.node(e.condition)}var xL,yL,Dd=$(()=>{"use strict";xL="MediaQuery",yL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var zd={};ye(zd,{generate:()=>vL,name:()=>SL,parse:()=>Rd,structure:()=>wL});function Rd(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),this.tokenType===18);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function vL(e){this.children(e,()=>this.token(18,","))}var SL,wL,Nd=$(()=>{"use strict";SL="MediaQueryList",wL={children:[["MediaQuery"]]}});var _d={};ye(_d,{generate:()=>IL,name:()=>CL,parse:()=>Od,structure:()=>TL});function Od(){let e=this.tokenStart;return this.eatDelim(kL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function IL(){this.token(9,"&")}var kL,CL,TL,$d=$(()=>{"use strict";kL=38,CL="NestingSelector",TL={}});var jd={};ye(jd,{generate:()=>AL,name:()=>FL,parse:()=>Ud,structure:()=>EL});function Ud(){this.skipSC();let e=this.tokenStart,t=e,n=null,r;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?r=this.Identifier():r=this.AnPlusB(),t=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),n=this.SelectorList(),t=this.tokenStart),{type:"Nth",loc:this.getLocation(e,t),nth:r,selector:n}}function AL(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var FL,EL,Hd=$(()=>{"use strict";FL="Nth",EL={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var Vd={};ye(Vd,{generate:()=>ML,name:()=>PL,parse:()=>Wd,structure:()=>LL});function Wd(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function ML(e){this.token(10,e.value)}var PL,LL,Gd=$(()=>{"use strict";PL="Number",LL={value:String}});var Yd={};ye(Yd,{generate:()=>RL,name:()=>BL,parse:()=>qd,structure:()=>DL});function qd(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function RL(e){this.tokenize(e.value)}var BL,DL,Kd=$(()=>{"use strict";BL="Operator",DL={value:String}});var Qd={};ye(Qd,{generate:()=>OL,name:()=>zL,parse:()=>Xd,structure:()=>NL});function Xd(e,t){let n=this.tokenStart,r=null;return this.eat(21),r=e.call(this,t),this.eof||this.eat(22),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:r}}function OL(e){this.token(21,"("),this.children(e),this.token(22,")")}var zL,NL,Jd=$(()=>{"use strict";zL="Parentheses",NL={children:[[]]}});var ef={};ye(ef,{generate:()=>UL,name:()=>_L,parse:()=>Zd,structure:()=>$L});function Zd(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function UL(e){this.token(11,e.value+"%")}var _L,$L,tf=$(()=>{"use strict";_L="Percentage",$L={value:String}});var rf={};ye(rf,{generate:()=>VL,name:()=>jL,parse:()=>nf,structure:()=>WL,walkContext:()=>HL});function nf(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function VL(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var jL,HL,WL,of=$(()=>{"use strict";jL="PseudoClassSelector",HL="function",WL={name:String,children:[["Raw"],null]}});var af={};ye(af,{generate:()=>KL,name:()=>GL,parse:()=>sf,structure:()=>YL,walkContext:()=>qL});function sf(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function KL(e){this.token(16,":"),this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var GL,qL,YL,lf=$(()=>{"use strict";GL="PseudoElementSelector",qL="function",YL={name:String,children:[["Raw"],null]}});var uf={};ye(uf,{generate:()=>JL,name:()=>XL,parse:()=>cf,structure:()=>QL});function k0(){switch(this.skipSC(),this.tokenType){case 10:return this.Number();case 2:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}function cf(){let e=this.tokenStart,t=k0.call(this),n=null;return this.skipSC(),this.isDelim(v0)&&(this.eatDelim(v0),n=k0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function JL(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var v0,XL,QL,pf=$(()=>{"use strict";v0=47;XL="Ratio",QL={left:["Number","Function"],right:["Number","Function",null]}});var ff={};ye(ff,{generate:()=>nM,name:()=>eM,parse:()=>df,structure:()=>tM});function ZL(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function df(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=ZL.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function nM(e){this.tokenize(e.value)}var eM,tM,gf=$(()=>{"use strict";eM="Raw",tM={value:String}});var hf={};ye(hf,{generate:()=>aM,name:()=>oM,parse:()=>mf,structure:()=>sM,walkContext:()=>iM});function C0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function rM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function mf(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(rM,C0):n=C0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function aM(e){this.node(e.prelude),this.node(e.block)}var oM,iM,sM,xf=$(()=>{"use strict";oM="Rule",iM="rule",sM={prelude:["SelectorList","Raw"],block:["Block"]}});var bf={};ye(bf,{generate:()=>uM,name:()=>lM,parse:()=>yf,structure:()=>cM});function yf(){let e=null,t=null;this.skipSC();let n=this.tokenStart;return this.tokenType===21&&(this.next(),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),this.lookupNonWSType(0)===1&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(21),this.skipSC(),t=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),{type:"Scope",loc:this.getLocation(n,this.tokenStart),root:e,limit:t}}function uM(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}var lM,cM,Sf=$(()=>{"use strict";lM="Scope",cM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var vf={};ye(vf,{generate:()=>fM,name:()=>pM,parse:()=>wf,structure:()=>dM});function wf(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function fM(e){this.children(e)}var pM,dM,kf=$(()=>{"use strict";pM="Selector",dM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Tf={};ye(Tf,{generate:()=>xM,name:()=>gM,parse:()=>Cf,structure:()=>hM,walkContext:()=>mM});function Cf(){let e=this.createList();for(;!this.eof;){if(e.push(this.Selector()),this.tokenType===18){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function xM(e){this.children(e,()=>this.token(18,","))}var gM,mM,hM,If=$(()=>{"use strict";gM="SelectorList",mM="selector",hM={children:[["Selector","Raw"]]}});function bl(e){let t=e.length,n=e.charCodeAt(0),r=n===T0||n===I0?1:0,o=r===1&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1,i="";for(let s=r;s<=o;s++){let a=e.charCodeAt(s);if(a===Ff){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),An(Ff,a)){let u=s-1,c=Ur(e,u);s=c-1,i+=ja(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function F0(e,t){let n=t?"'":'"',r=t?I0:T0,o="",i=!1;for(let s=0;s<e.length;s++){let a=e.charCodeAt(s);if(a===0){o+="\uFFFD";continue}if(a<=31||a===127){o+="\\"+a.toString(16),i=!0;continue}a===r||a===Ff?(o+="\\"+e.charAt(s),i=!1):(i&&(Pn(a)||Ar(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var Ff,T0,I0,Sl=$(()=>{"use strict";nr();Ff=92,T0=34,I0=39});var Af={};ye(Af,{generate:()=>SM,name:()=>yM,parse:()=>Ef,structure:()=>bM});function Ef(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:bl(this.consume(5))}}function SM(e){this.token(5,F0(e.value))}var yM,bM,Pf=$(()=>{"use strict";Sl();yM="String",bM={value:String}});var Mf={};ye(Mf,{generate:()=>TM,name:()=>vM,parse:()=>Lf,structure:()=>CM,walkContext:()=>kM});function A0(){return this.Raw(null,!1)}function Lf(){let e=this.tokenStart,t=this.createList(),n;for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(this.charCodeAt(this.tokenStart+2)!==wM){this.next();continue}n=this.Comment();break;case 14:n=this.CDO();break;case 15:n=this.CDC();break;case 3:n=this.parseWithFallback(this.Atrule,A0);break;default:n=this.parseWithFallback(this.Rule,A0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function TM(e){this.children(e)}var wM,vM,kM,CM,Bf=$(()=>{"use strict";wM=33;vM="StyleSheet",kM="stylesheet",CM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var Rf={};ye(Rf,{generate:()=>EM,name:()=>IM,parse:()=>Df,structure:()=>FM});function Df(){let e=this.tokenStart;this.eat(21),this.skipSC();let t=this.Declaration();return this.eof||this.eat(22),{type:"SupportsDeclaration",loc:this.getLocation(e,this.tokenStart),declaration:t}}function EM(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var IM,FM,zf=$(()=>{"use strict";IM="SupportsDeclaration",FM={declaration:"Declaration"}});var _f={};ye(_f,{generate:()=>MM,name:()=>PM,parse:()=>Of,structure:()=>LM});function Nf(){this.tokenType!==1&&this.isDelim(AM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function Of(){let e=this.tokenStart;return this.isDelim(P0)?(this.next(),Nf.call(this)):(Nf.call(this),this.isDelim(P0)&&(this.next(),Nf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function MM(e){this.tokenize(e.name)}var AM,P0,PM,LM,$f=$(()=>{"use strict";AM=42,P0=124;PM="TypeSelector",LM={name:String}});var Hf={};ye(Hf,{generate:()=>NM,name:()=>RM,parse:()=>jf,structure:()=>zM});function Fs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===M0&&t&&n!==0)return Fs.call(this,e+n+1,!1),-1;Pn(o)||this.error(t&&n!==0?"Hyphen minus"+(n<6?" or hex digit":"")+" is expected":n<6?"Hex digit is expected":"Unexpected input",r),++n>6&&this.error("Too many hex digits",r)}return this.next(),n}function wl(e){let t=0;for(;this.isDelim(Uf);)++t>e&&this.error("Too many question marks"),this.next()}function BM(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===L0?"Plus sign":"Hyphen minus")+" is expected")}function DM(){let e=0;switch(this.tokenType){case 10:if(e=Fs.call(this,1,!0),this.isDelim(Uf)){wl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){BM.call(this,M0),Fs.call(this,1,!1);break}break;case 12:e=Fs.call(this,1,!0),e>0&&wl.call(this,6-e);break;default:if(this.eatDelim(L0),this.tokenType===1){e=Fs.call(this,0,!0),e>0&&wl.call(this,6-e);break}if(this.isDelim(Uf)){this.next(),wl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function jf(){let e=this.tokenStart;return this.eatIdent("u"),DM.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function NM(e){this.tokenize(e.value)}var L0,M0,Uf,RM,zM,Wf=$(()=>{"use strict";nr();L0=43,M0=45,Uf=63;RM="UnicodeRange",zM={value:String}});function D0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===B0?t-2:t-1,o="";for(;n<r&&Ar(e.charCodeAt(n));)n++;for(;n<r&&Ar(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Vf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),An(Vf,s)){let a=i-1,u=Ur(e,a);i=u-1,o+=ja(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function R0(e){let t="",n=!1;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===0){t+="\uFFFD";continue}if(o<=31||o===127){t+="\\"+o.toString(16),n=!0;continue}o===OM||o===Vf||o===_M||o===$M||o===UM||o===B0?(t+="\\"+e.charAt(r),n=!1):(n&&Pn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var OM,Vf,_M,$M,UM,B0,Gf=$(()=>{"use strict";nr();OM=32,Vf=92,_M=34,$M=39,UM=40,B0=41});var Yf={};ye(Yf,{generate:()=>WM,name:()=>jM,parse:()=>qf,structure:()=>HM});function qf(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=D0(this.consume(7));break;case 2:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(2),this.skipSC(),t=bl(this.consume(5)),this.skipSC(),this.eof||this.eat(22);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(e,this.tokenStart),value:t}}function WM(e){this.token(7,R0(e.value))}var jM,HM,Kf=$(()=>{"use strict";Gf();Sl();jM="Url",HM={value:String}});var Qf={};ye(Qf,{generate:()=>qM,name:()=>VM,parse:()=>Xf,structure:()=>GM});function Xf(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function qM(e){this.children(e)}var VM,GM,Jf=$(()=>{"use strict";VM="Value",GM={children:[[]]}});var eg={};ye(eg,{generate:()=>QM,name:()=>KM,parse:()=>Zf,structure:()=>XM});function Zf(){return this.eat(13),YM}function QM(e){this.token(13,e.value)}var YM,KM,XM,tg=$(()=>{"use strict";YM=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),KM="WhiteSpace",XM={value:String}});var Es={};ye(Es,{AnPlusB:()=>cp,Atrule:()=>dp,AtrulePrelude:()=>mp,AttributeSelector:()=>bp,Block:()=>vp,Brackets:()=>Tp,CDC:()=>Ep,CDO:()=>Lp,ClassSelector:()=>Dp,Combinator:()=>Np,Comment:()=>$p,Condition:()=>Hp,Declaration:()=>Gp,DeclarationList:()=>Xp,Dimension:()=>Zp,Feature:()=>nd,FeatureFunction:()=>id,FeatureRange:()=>cd,Function:()=>dd,GeneralEnclosed:()=>md,Hash:()=>yd,IdSelector:()=>Cd,Identifier:()=>wd,Layer:()=>Fd,LayerList:()=>Pd,MediaQuery:()=>Bd,MediaQueryList:()=>zd,NestingSelector:()=>_d,Nth:()=>jd,Number:()=>Vd,Operator:()=>Yd,Parentheses:()=>Qd,Percentage:()=>ef,PseudoClassSelector:()=>rf,PseudoElementSelector:()=>af,Ratio:()=>uf,Raw:()=>ff,Rule:()=>hf,Scope:()=>bf,Selector:()=>vf,SelectorList:()=>Tf,String:()=>Af,StyleSheet:()=>Mf,SupportsDeclaration:()=>Rf,TypeSelector:()=>_f,UnicodeRange:()=>Hf,Url:()=>Yf,Value:()=>Qf,WhiteSpace:()=>eg});var ng=$(()=>{"use strict";up();fp();hp();Sp();kp();Ip();Ap();Mp();Rp();Op();Up();Wp();qp();Qp();ed();rd();sd();ud();fd();hd();bd();vd();Td();Ed();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tf();of();lf();pf();gf();xf();Sf();kf();If();Pf();Bf();zf();$f();Wf();Kf();Jf();tg()});var N0,O0=$(()=>{"use strict";sl();c0();ng();N0={generic:!0,cssWideKeywords:gi,...l0,node:Es}});function As(e){switch(this.tokenType){case 4:return this.Hash();case 18:return this.Operator();case 21:return this.Parentheses(this.readSequence,e.recognizer);case 19:return this.Brackets(this.readSequence,e.recognizer);case 5:return this.String();case 12:return this.Dimension();case 11:return this.Percentage();case 10:return this.Number();case 2:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,e.recognizer);case 7:return this.Url();case 1:return this.cmpChar(this.tokenStart,nB)&&this.cmpChar(this.tokenStart+1,_0)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===tB||t===ZM||t===_0||t===eB)return this.Operator();t===JM&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var JM,ZM,_0,eB,tB,nB,rg=$(()=>{"use strict";JM=35,ZM=42,_0=43,eB=45,tB=47,nB=117});var $0,U0=$(()=>{"use strict";rg();$0={getNode:As}});function pB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function dB(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStart)===j0&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case sB:case lB:case uB:case aB:return this.Combinator();case j0:return this.ClassSelector();case iB:case cB:return this.TypeSelector();case rB:return this.IdSelector();case oB:return this.NestingSelector()}break}}}var rB,oB,iB,sB,aB,j0,lB,cB,uB,H0,W0=$(()=>{"use strict";rB=35,oB=38,iB=42,sB=43,aB=47,j0=46,lB=62,cB=124,uB=126;H0={onWhiteSpace:pB,getNode:dB}});function V0(){return this.createSingleNodeList(this.Raw(null,!1))}var G0=$(()=>{"use strict"});function q0(){let e=this.createList();if(this.skipSC(),e.push(this.Identifier()),this.skipSC(),this.tokenType===18){e.push(this.Operator());let t=this.tokenIndex,n=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(n.type==="Value"&&n.children.isEmpty){for(let r=t-this.tokenIndex;r<=0;r++)if(this.lookupType(r)===13){n.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}e.push(n)}return e}var Y0=$(()=>{"use strict"});function K0(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var X0,Q0=$(()=>{"use strict";rg();G0();Y0();X0={getNode:As,onWhiteSpace(e,t){K0(e)&&(e.value=" "+e.value),K0(t.last)&&(t.last.value+=" ")},expression:V0,var:q0}});var og={};ye(og,{AtrulePrelude:()=>$0,Selector:()=>H0,Value:()=>X0});var J0=$(()=>{"use strict";U0();W0();Q0()});var fB,Z0,eS=$(()=>{"use strict";fB=new Set(["none","and","not","or"]),Z0={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);fB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var tS,nS=$(()=>{"use strict";tS={parse:{prelude:null,block(){return this.Block(!0)}}}});function ig(e,t){return this.parseWithFallback(()=>{try{return e.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==22&&this.error()}},t||(()=>this.Raw(null,!0)))}var rS,oS,iS=$(()=>{"use strict";rS={layer(){this.skipSC();let e=this.createList(),t=ig.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=ig.call(this,this.Declaration,()=>ig.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},oS={parse:{prelude(){let e=this.createList();switch(this.tokenType){case 5:e.push(this.String());break;case 7:case 2:e.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===1&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?e.push(this.Identifier()):this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&e.push(this.Function(null,rS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,rS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var sS,aS=$(()=>{"use strict";sS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var lS,cS=$(()=>{"use strict";lS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var uS,pS=$(()=>{"use strict";uS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var dS,fS=$(()=>{"use strict";dS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var gS,mS=$(()=>{"use strict";gS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var hS,xS=$(()=>{"use strict";hS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var yS,bS=$(()=>{"use strict";yS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var SS,wS=$(()=>{"use strict";eS();nS();iS();aS();cS();pS();fS();mS();xS();bS();SS={container:Z0,"font-face":tS,import:oS,layer:sS,media:lS,nest:uS,page:dS,scope:gS,"starting-style":hS,supports:yS}});function vS(){let e=this.createList();this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 1:e.push(this.Identifier());break;case 5:e.push(this.String());break;case 18:e.push(this.Operator());break;case 22:break e;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return e}var kS=$(()=>{"use strict"});var _o,sg,gB,mB,vl,CS,TS=$(()=>{"use strict";kS();_o={parse(){return this.createSingleNodeList(this.SelectorList())}},sg={parse(){return this.createSingleNodeList(this.Selector())}},gB={parse(){return this.createSingleNodeList(this.Identifier())}},mB={parse:vS},vl={parse(){return this.createSingleNodeList(this.Nth())}},CS={dir:gB,has:_o,lang:mB,matches:_o,is:_o,"-moz-any":_o,"-webkit-any":_o,where:_o,not:_o,"nth-child":vl,"nth-last-child":vl,"nth-last-of-type":vl,"nth-of-type":vl,slotted:sg,host:sg,"host-context":sg}});var ag={};ye(ag,{AnPlusB:()=>lp,Atrule:()=>pp,AtrulePrelude:()=>gp,AttributeSelector:()=>yp,Block:()=>wp,Brackets:()=>Cp,CDC:()=>Fp,CDO:()=>Pp,ClassSelector:()=>Bp,Combinator:()=>zp,Comment:()=>_p,Condition:()=>jp,Declaration:()=>Vp,DeclarationList:()=>Kp,Dimension:()=>Jp,Feature:()=>td,FeatureFunction:()=>od,FeatureRange:()=>ld,Function:()=>pd,GeneralEnclosed:()=>gd,Hash:()=>xd,IdSelector:()=>kd,Identifier:()=>Sd,Layer:()=>Id,LayerList:()=>Ad,MediaQuery:()=>Md,MediaQueryList:()=>Rd,NestingSelector:()=>Od,Nth:()=>Ud,Number:()=>Wd,Operator:()=>qd,Parentheses:()=>Xd,Percentage:()=>Zd,PseudoClassSelector:()=>nf,PseudoElementSelector:()=>sf,Ratio:()=>cf,Raw:()=>df,Rule:()=>mf,Scope:()=>yf,Selector:()=>wf,SelectorList:()=>Cf,String:()=>Ef,StyleSheet:()=>Lf,SupportsDeclaration:()=>Df,TypeSelector:()=>Of,UnicodeRange:()=>jf,Url:()=>qf,Value:()=>Xf,WhiteSpace:()=>Zf});var IS=$(()=>{"use strict";up();fp();hp();Sp();kp();Ip();Ap();Mp();Rp();Op();Up();Wp();qp();Qp();ed();rd();sd();ud();fd();hd();bd();vd();Td();Ed();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tf();of();lf();pf();gf();xf();Sf();kf();If();Pf();Bf();zf();$f();Wf();Kf();Jf();tg()});var FS,ES=$(()=>{"use strict";J0();wS();TS();IS();FS={parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(e){return this.AtrulePrelude(e.atrule?String(e.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",condition(e){return this.Condition(e.kind)},rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},features:{supports:{selector(){return this.Selector()}},container:{style(){return this.Declaration()}}},scope:og,atrule:SS,pseudo:CS,node:ag}});var AS,PS=$(()=>{"use strict";ng();AS={node:Es}});var LS,MS=$(()=>{"use strict";a0();O0();ES();PS();LS=s0({...N0,...FS,...AS})});var BS=$(()=>{"use strict"});var DS=$(()=>{"use strict"});var rq,RS,oq,iq,sq,zS,aq,lq,cq,uq,pq,dq,NS=$(()=>{"use strict";MS();BS();Yu();il();DS();Sl();Gf();({tokenize:rq,parse:RS,generate:oq,lexer:iq,createLexer:sq,walk:zS,find:aq,findLast:lq,findAll:cq,toPlainObject:uq,fromPlainObject:pq,fork:dq}=LS)});function bB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function _S(e){try{let t=RS(e.trim(),{context:"value"}),n=[];return zS(t,{enter(r){if(r.type==="Dimension"){let o=parseFloat(r.value);n.push(`${o}${r.unit}`)}else if(r.type==="Number"){let o=parseFloat(r.value);n.push(`${o}`)}else r.type==="Percentage"?n.push(`${parseFloat(r.value)}%`):r.type==="Identifier"?n.push(r.name.toLowerCase()):r.type==="Hash"?n.push(`#${r.value.toLowerCase()}`):r.type}}),n}catch{return[e.trim().toLowerCase()]}}function SB(e,t){let n=bB(e);if(!yB.has(n))return t;let r=_S(t);if(r.length<1||r.length>4)return t;let o=r.map(i=>i==="0"?"0px":i);return o.length===1?`${o[0]} ${o[0]} ${o[0]} ${o[0]}`:o.length===2?`${o[0]} ${o[1]} ${o[0]} ${o[1]}`:o.length===3?`${o[0]} ${o[1]} ${o[2]} ${o[1]}`:o.join(" ")}function OS(e,t){let n=t.trim();if(!n)return"";let r=SB(e,n);return _S(r).map(i=>i==="0"?"0px":i).join(" ")}function $S(e,t,n){let r=OS(e,t),o=OS(e,n);return r!==""&&o!==""&&r===o}var yB,US=$(()=>{"use strict";NS();yB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function wB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function vB(e){let t=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/);if(!t)return null;let n=parseInt(t[1],10).toString(16).padStart(2,"0"),r=parseInt(t[2],10).toString(16).padStart(2,"0"),o=parseInt(t[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`}function jS(e){let t=typeof e=="string"?e:String(e??"");if(!t||t==="[object Object]")return"";let n=t.match(/rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*[\d.]+)?\s*\)/);if(n){let i=vB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return wB(r[0]);let o=t.match(/(-?\d+\.?\d*)(px|em|rem|%|pt|vw|vh)?/g);return o&&o.length>1?o.join(" ").toLowerCase():o&&o.length===1?o[0].toLowerCase():t.toLowerCase().trim().replace(/\s+/g," ")}function $o(e,t,n){if(!e||!t)return!1;let r=String(e),o=String(t),i=r.toLowerCase(),s=o.toLowerCase(),a=i.includes("none"),u=s.includes("none");if(a!==u)return!1;let c=/\b(fill|stroke)\s*:/i,l=c.test(r),d=c.test(o);if(l!==d)return!1;let f=jS(r),p=jS(o);return!!(f===p||n&&$S(n,r,o))}var lg=$(()=>{"use strict";US()});function FB(e){let t=String(e.property||"").toLowerCase(),n=String(e.description||"").toLowerCase(),r=String(e.expected||e.suggestedValue||"").toLowerCase(),o=String(e.actual||e.currentValue||"").toLowerCase();if(t.includes("color")||t.includes("fill")||t.includes("background")||n.includes("color")||n.includes("fill"))return!0;let i=s=>/^#[0-9a-f]{3,8}$/i.test(s)||s.includes("rgb")||["white","black","red","blue","green","orange","yellow","transparent"].includes(s);return!!(i(r)||i(o)||e.relatedProperties?.some(s=>{let a=s.property?.toLowerCase()||"";return a.includes("color")||a.includes("fill")||a.includes("background")}))}function HS(e){if(e.includes("\xD7")||/\d+px\s*x\s*\d+px/i.test(e))return!1;let t=e.match(/\d+px/g);return t?t.length>1:!1}function EB(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase(),r=String(e.property||"").toLowerCase(),o=String(e.description||"").toLowerCase(),i=n.includes("margin")||t.includes("margin")||r==="margin",s=t.includes("gap")||o.includes("gap");return i&&s}function AB(e,t,n){if(!e||!t)return!1;let r=typeof e=="string"?e:String(e??""),o=typeof t=="string"?t:String(t??"");if(!r||!o||r==="[object Object]"||o==="[object Object]"||n&&FB(n)||HS(r)||HS(o)||n&&EB(n))return!1;let i=parseFloat(r),s=parseFloat(o);if(isNaN(i)||isNaN(s))return!1;let a=Math.abs(i-s);if(r.includes("px")||o.includes("px")){let u=n?.property?.toLowerCase()||"";return u==="width"||u==="height"||u.includes("width")||u.includes("height")?a<VS:a<WS}return r.includes("%")||o.includes("%")?a<1:!1}function PB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(IB.some(s=>t.includes(s))||!CB.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!$o(o,i,e.property))}function LB(e){let t=(e.expected!==void 0?"fill":"").toLowerCase(),n=e.actual!==void 0||e.currentValue!==void 0?"fill":"";if(!(t==="fill"||n==="fill"||e.description?.toLowerCase().includes("fill")||e.title?.toLowerCase().includes("fill")))return!1;let o=String(e.expected||e.suggestedValue||"").toLowerCase();if(!(o==="none"||o==="transparent"||o.includes("no fills")||o.includes("transparent")))return!1;let s=`${e.description||""} ${e.title||""}`.toLowerCase();return s.includes("container")||s.includes("svg ")||s.includes("<svg")||s.includes("wrapper")}function MB(e){let t=`${e.description||""} ${e.title||""}`.toLowerCase(),n=e.property?.toLowerCase()||"";if(!(t.includes("text ")||t.includes("text layer")||t.includes("text span")||t.includes("span ")||t.includes("label "))||!(n==="width"||n==="height"||n.includes("width")||n.includes("height")||t.includes("width")||t.includes("height")))return!1;let i=e.expected||e.suggestedValue||"",s=e.actual||e.currentValue||"",a=parseFloat(i),u=parseFloat(s);return isNaN(a)||isNaN(u)?!1:Math.abs(a-u)<GS}function BB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase(),n=String(e.expected||e.suggestedValue||"").toLowerCase(),r=String(e.actual||e.currentValue||"").toLowerCase();if(!TB.some(d=>t.includes(d)||n.includes(d)))return!1;let i=`${t} ${n} ${r}`;if(i.includes("min-width")||i.includes("max-width")||i.includes("min-height")||i.includes("max-height")||i.includes("explicit")||i.includes("constraint")||i.includes("forced"))return!1;let a=n.includes("hug")||n.includes("auto"),u=/\d+\.?\d*px/.test(r);if(!a||!u)return!1;let c=n.match(/(\d+\.?\d*)px/),l=r.match(/(\d+\.?\d*)px/);return!(c&&l&&Math.abs(parseFloat(c[1])-parseFloat(l[1]))>kB)}function DB(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase();return(!n||!t||n.includes("see ")||t.includes("see ")||n.includes("image")||t.includes("image"))&&e.type==="visual"}function Ps(e){if(e.programmaticallyVerified)return{dismissed:!1};let t=e.expected||e.suggestedValue,n=e.actual||e.currentValue;if(e.fixRequired===!1)return{dismissed:!0,dismissReason:"Auto-dismissed: FixRequired is false (no code change needed)",dismissedBy:"post-ai-validation"};if($o(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: expected equals actual (identical values)",dismissedBy:"post-ai-validation"};if(e.fixRequired===!0)return{dismissed:!1};if(MB(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${GS}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(AB(t,n,e)){let r=e.property?.toLowerCase()||"";return{dismissed:!0,dismissReason:`Auto-dismissed: negligible difference (<${r==="width"||r==="height"||r.includes("width")||r.includes("height")?VS:WS}px)`,dismissedBy:"post-ai-validation"}}return DB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:PB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:BB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:LB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var WS,VS,GS,kB,CB,TB,IB,qS=$(()=>{"use strict";lg();WS=.5,VS=2,GS=2,kB=5,CB=["values match","values already match","already correct","correctly implemented","implementation is correct","css matches","matches figma","identical","same value","no difference","none - ","no changes needed","no fix needed"],TB=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],IB=["duplicate","extra","missing","additional","removed","should not exist","does not exist","not in figma","not in storybook","renders 2","renders two","has 1","has one"]});function Si(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var YS=$(()=>{"use strict"});var KS=$(()=>{"use strict"});var XS=$(()=>{"use strict"});var cg=$(()=>{"use strict";lg();qS();YS();KS();XS()});var HB,WB,Aq,ug=$(()=>{"use strict";HB=["flex","inline-flex"],WB=["grid","inline-grid"],Aq=[...HB,...WB]});var JS=$(()=>{"use strict";cg();ug()});var ZS=$(()=>{"use strict"});var Ls=$(()=>{"use strict";oy();cg();ug();JS();ZS()});function GB(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function qn(e){try{let t=e.map(GB),n=JSON.stringify(t,qB);sessionStorage.setItem(pg,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function dg(){try{let e=sessionStorage.getItem(pg);if(!e)return[];let t=JSON.parse(e,YB);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function ew(){try{let e=dg();if(e.length===0)return;let t=!1,n=e.map(r=>{if(r.aiPrompt!==void 0||r.aiResponse!==void 0){t=!0;let{aiPrompt:o,aiResponse:i,...s}=r;return s}return r});t&&(qn(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function tw(){try{sessionStorage.removeItem(pg),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function qB(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function YB(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var pg,fg=$(()=>{"use strict";De();pg="uicopilot_review_history"});import KB,{createContext as XB,useContext as QB,useReducer as JB,useMemo as nw,useRef as ZB,useEffect as eD}from"react";function tD(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"ADD_STREAMING_MESSAGE":return{...e,streamingMessages:[...e.streamingMessages,t.payload]};case"UPDATE_STREAMING_MESSAGE":return{...e,streamingMessages:e.streamingMessages.map((n,r)=>r===t.payload.index?{...n,content:t.payload.content}:n)};case"CLEAR_STREAMING_MESSAGES":return{...e,streamingMessages:[]};case"TOGGLE_MODEL":{let n=e.selectedModels.includes(t.payload);return n&&e.selectedModels.length===1?e:{...e,selectedModels:n?e.selectedModels.filter(r=>r!==t.payload):[...e.selectedModels,t.payload]}}case"SET_REVIEW_RESULTS":{if(!t.payload)return{...e,reviewResults:null,currentReviewId:null};let n=e.userRole==="admin",r={id:t.payload.id,componentId:t.payload.componentId,storyId:t.payload.storyId,modelId:t.payload.modelId,complianceScore:t.payload.complianceScore,issuesCount:t.payload.issuesCount,issues:t.payload.issues,createdAt:t.payload.createdAt,visualSimilarity:t.payload.visualSimilarity,storybookImageData:e.storybookImageUrl||void 0,figmaImageData:e.figmaImageUrl||void 0,aiPrompt:n&&e.fullPrompt||void 0,aiResponse:n&&e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens},o=e.reviewHistory.findIndex(s=>s.id===t.payload.id),i;return o>=0?i=e.reviewHistory.map((s,a)=>a===o?r:s):i=[...e.reviewHistory,r],qn(i),{...e,reviewResults:t.payload,reviewHistory:i,currentReviewId:t.payload.id}}case"UPDATE_MULTI_MODEL_STREAMING":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload.modelId]:{...e.multiModelResults.byModel[t.payload.modelId],streamingMessages:t.payload.messages}}}}:{...e,multiModelResults:{byModel:{[t.payload.modelId]:{streamingMessages:t.payload.messages}},activeModelId:t.payload.modelId}};case"SET_MODEL_COMPLETED":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload]:{...e.multiModelResults.byModel[t.payload],completed:!0}}}}:e;case"BULK_ADD_REVIEWS":{let n=new Set(e.reviewHistory.map(i=>i.id)),r=t.payload.filter(i=>!n.has(i.id));if(r.length===0)return e;let o=[...e.reviewHistory,...r];return qn(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=[...e.reviewHistory,t.payload];return qn(n),{...e,reviewHistory:n,currentReviewId:t.payload.id}}case"TOGGLE_ISSUE_SELECTION":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload?{...o,selectedForFix:!o.selectedForFix}:o)});return qn(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_STATUS":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,status:t.payload.status,error:t.payload.error}:o)});return qn(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_GENERATED_FIX":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,generatedFix:o.generatedFix?{...o.generatedFix,...t.payload.generatedFix}:t.payload.generatedFix,selectedForFix:t.payload.generatedFix?.status==="failed"?!1:o.selectedForFix}:o)});return qn(n),{...e,reviewHistory:n}}case"BATCH_UPDATE_ISSUE_GENERATED_FIXES":{if(!e.currentReviewId)return e;let n=new Map(t.payload.map(o=>[o.issueId,o.generatedFix])),r=e.reviewHistory.map(o=>o.id!==e.currentReviewId?o:{...o,issues:o.issues.map(i=>{let s=n.get(i.id);return s?{...i,generatedFix:i.generatedFix?{...i.generatedFix,...s}:s,selectedForFix:s?.status==="failed"?!1:i.selectedForFix}:i})});return qn(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:o)});return qn(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload?{...o,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:o)});return qn(n),{...e,reviewHistory:n}}case"RECALCULATE_SCORE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.filter(c=>!c.dismissed),i=o.filter(c=>c.severity==="critical").length,s=o.filter(c=>c.severity==="major").length,a=o.filter(c=>c.severity==="minor").length,u=Si(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return qn(n),{...e,reviewHistory:n}}case"UPDATE_REVIEW_SCORE":{let n=e.reviewHistory.map(r=>r.id!==t.payload.reviewId?r:{...r,complianceScore:t.payload.newScore});return qn(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return tw(),{...e,reviewHistory:[],currentReviewId:null};case"CLEAR_STALE_REVIEWS":return{...e,currentReviewId:null,reviewResults:null};case"RESET_REVIEW":{let n=e.isReviewing;return{...e,isReviewing:!1,reviewError:null,reviewResults:n?null:e.reviewResults,multiModelResults:null,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:n?"chat":e.reviewDetailTab,fullPrompt:"",fullResponse:"",figmaImageUrl:n?null:e.figmaImageUrl,storybookImageUrl:n?null:e.storybookImageUrl,currentReviewId:n?null:e.currentReviewId}}case"RESET_PROMPT":return{...e,isGenerating:!1,generatedPrompt:null,promptError:null};case"TRIGGER_SCREENSHOT_REFRESH":return{...e,screenshotRefreshKey:e.screenshotRefreshKey+1};default:return e}}function mg({children:e}){let[t,n]=JB(tD,sD),r=ZB(t);eD(()=>{r.current=t},[t]);let o=nw(()=>({setIsReviewing:s=>n({type:"SET_STATE",payload:{isReviewing:s}}),setReviewError:s=>n({type:"SET_STATE",payload:{reviewError:s}}),bulkAddReviews:s=>n({type:"BULK_ADD_REVIEWS",payload:s}),setReviewResults:s=>n({type:"SET_REVIEW_RESULTS",payload:s}),setMultiModelResults:s=>n({type:"SET_STATE",payload:{multiModelResults:s}}),updateMultiModelStreamingMessages:(s,a)=>n({type:"UPDATE_MULTI_MODEL_STREAMING",payload:{modelId:s,messages:a}}),setModelCompleted:s=>n({type:"SET_MODEL_COMPLETED",payload:s}),setActiveModelId:s=>{let a=r.current;a.multiModelResults&&n({type:"SET_STATE",payload:{multiModelResults:{...a.multiModelResults,activeModelId:s}}})},setShowReviewMenu:s=>n({type:"SET_STATE",payload:{showReviewMenu:s}}),setSeverityFilter:s=>n({type:"SET_STATE",payload:{severityFilter:s}}),setShowStreamingPanel:s=>n({type:"SET_STATE",payload:{showStreamingPanel:s}}),setStreamingPanelCollapsed:s=>n({type:"SET_STATE",payload:{streamingPanelCollapsed:s}}),addStreamingMessage:s=>n({type:"ADD_STREAMING_MESSAGE",payload:s}),updateStreamingMessage:(s,a)=>n({type:"UPDATE_STREAMING_MESSAGE",payload:{index:s,content:a}}),clearStreamingMessages:()=>n({type:"CLEAR_STREAMING_MESSAGES"}),setStreamingProgress:s=>n({type:"SET_STATE",payload:{streamingProgress:s}}),setStreamingStatus:s=>n({type:"SET_STATE",payload:{streamingStatus:s}}),setReviewDetailTab:s=>n({type:"SET_STATE",payload:{reviewDetailTab:s}}),setFullPrompt:s=>n({type:"SET_STATE",payload:{fullPrompt:s}}),setFullResponse:s=>n({type:"SET_STATE",payload:{fullResponse:s}}),setFigmaImageUrl:s=>n({type:"SET_STATE",payload:{figmaImageUrl:s}}),setStorybookImageUrl:s=>n({type:"SET_STATE",payload:{storybookImageUrl:s}}),setFigmaDimensions:s=>n({type:"SET_STATE",payload:{figmaDimensions:s}}),setSelectedModels:s=>n({type:"SET_STATE",payload:{selectedModels:s}}),toggleModel:s=>n({type:"TOGGLE_MODEL",payload:s}),setModelComparisonView:s=>n({type:"SET_STATE",payload:{modelComparisonView:s}}),resetReview:()=>n({type:"RESET_REVIEW"}),addReview:s=>n({type:"ADD_REVIEW",payload:s}),getCurrentReview:()=>{let s=r.current;return s.currentReviewId&&s.reviewHistory.find(a=>a.id===s.currentReviewId)||null},getReviewById:s=>r.current.reviewHistory.find(a=>a.id===s)||null,getParentReview:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return a?.parentReviewId&&s.reviewHistory.find(u=>u.id===a.parentReviewId)||null},hasAppliedFixes:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return!a||!Array.isArray(a.issues)||a.issues.length===0?!1:a.issues.some(u=>u.status==="applied"||u.generatedFix?.status==="applied")},toggleIssueSelection:s=>n({type:"TOGGLE_ISSUE_SELECTION",payload:s}),updateIssueStatus:(s,a,u)=>n({type:"UPDATE_ISSUE_STATUS",payload:{issueId:s,status:a,error:u}}),updateIssueGeneratedFix:(s,a)=>n({type:"UPDATE_ISSUE_GENERATED_FIX",payload:{issueId:s,generatedFix:a}}),batchUpdateIssueGeneratedFixes:s=>n({type:"BATCH_UPDATE_ISSUE_GENERATED_FIXES",payload:s}),dismissIssue:(s,a,u)=>n({type:"DISMISS_ISSUE",payload:{issueId:s,reason:a,dismissedBy:u}}),undismissIssue:s=>n({type:"UNDISMISS_ISSUE",payload:s}),recalculateScore:()=>n({type:"RECALCULATE_SCORE"}),updateReviewScore:(s,a)=>n({type:"UPDATE_REVIEW_SCORE",payload:{reviewId:s,newScore:a}}),clearAllReviews:()=>n({type:"CLEAR_ALL_REVIEWS"}),clearStaleReviewsForStory:s=>n({type:"CLEAR_STALE_REVIEWS",payload:s}),setIsApplying:s=>n({type:"SET_STATE",payload:{isApplying:s}}),setApplyFixesResult:s=>n({type:"SET_STATE",payload:{applyFixesResult:s}}),setIncludeComponentIssues:s=>n({type:"SET_STATE",payload:{includeComponentIssues:s}}),setIncludeTextComparison:s=>n({type:"SET_STATE",payload:{includeTextComparison:s}}),setUsePromptCache:s=>n({type:"SET_STATE",payload:{usePromptCache:s}}),setIsValidating:s=>n({type:"SET_STATE",payload:{isValidating:s}}),setValidationUsage:s=>n({type:"SET_STATE",payload:{validationUsage:s}}),setWorkspacePath:s=>n({type:"SET_STATE",payload:{workspacePath:s}}),triggerScreenshotRefresh:()=>n({type:"TRIGGER_SCREENSHOT_REFRESH"}),setHoveredIssueId:s=>n({type:"SET_STATE",payload:{hoveredIssueId:s}}),setFeatureFlags:s=>n({type:"SET_STATE",payload:{featureFlags:s}}),setUserRole:s=>n({type:"SET_STATE",payload:{userRole:s}}),setRoleOverride:s=>{try{s?localStorage.setItem("uicopilot_role_override",s):localStorage.removeItem("uicopilot_role_override")}catch{}n({type:"SET_STATE",payload:{roleOverride:s}})},setReviewAllConcurrency:s=>{let a=Math.max(1,Math.min(5,s));try{localStorage.setItem("uicopilot_review_all_concurrency",String(a))}catch{}n({type:"SET_STATE",payload:{reviewAllConcurrency:a}})},setIsGenerating:s=>n({type:"SET_STATE",payload:{isGenerating:s}}),setGeneratedPrompt:s=>n({type:"SET_STATE",payload:{generatedPrompt:s}}),setPromptError:s=>n({type:"SET_STATE",payload:{promptError:s}}),resetPrompt:()=>n({type:"RESET_PROMPT"})}),[]),i=nw(()=>({...t,...o}),[t,o]);return KB.createElement(rw.Provider,{value:i},e)}function ie(){let e=QB(rw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var nD,rD,gg,oD,iD,sD,rw,hg=$(()=>{"use strict";Ls();fg();De();nD=()=>{if(typeof localStorage>"u")return 3;try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3},rD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},gg={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},oD=()=>{if(typeof localStorage>"u")return gg;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return gg;let t=JSON.parse(e);return{enableFixGeneration:!!t.enableFixGeneration,enableFixApply:!!t.enableFixApply,enableAutoMap:!!t.enableAutoMap,enableReviewBadges:!!t.enableReviewBadges,showCosts:!!t.showCosts,enableParallelReview:!!t.enableParallelReview,enableModelSelection:!!t.enableModelSelection}}catch{}return gg},iD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},sD={isReviewing:!1,reviewError:null,reviewResults:null,multiModelResults:null,showReviewMenu:!1,severityFilter:"all",showStreamingPanel:!1,streamingPanelCollapsed:!1,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:"chat",fullPrompt:"",fullResponse:"",figmaImageUrl:null,storybookImageUrl:null,figmaDimensions:null,selectedModels:["claude-sonnet-4-5-20250929"],modelComparisonView:"side-by-side",reviewHistory:dg(),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:iD(),roleOverride:rD(),featureFlags:oD(),reviewAllConcurrency:nD(),hoveredIssueId:null},rw=XB(null)});import Ms,{useMemo as aD}from"react";function yg({children:e}){return Ms.createElement(Zc,null,Ms.createElement(tu,null,Ms.createElement(ru,null,Ms.createElement(mg,null,Ms.createElement(lD,null),e))))}function ow(e){let t=we(),n=Ze(),r=rt(),o=ie(),i=aD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function lD(){return xg=ow(),null}var xg,ht,iw=$(()=>{"use strict";eu();nu();ou();hg();xg=null,ht=Object.assign(ow,{getState:()=>{if(!xg)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return xg}})});var ve=$(()=>{"use strict";iw();eu();nu();ou();hg()});function q(){return(process.env.STORYBOOK_UICOPILOT_URL||cD).replace(/\/$/,"")}var cD,sw,je=$(()=>{"use strict";cD="https://app.uicopilot.dev",sw=3.6});async function oe(e,t,n=3e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var pt=$(()=>{"use strict"});import{useEffect as zs,useState as Cl,useRef as ZD,useCallback as Sg}from"react";import{addons as wg}from"storybook/manager-api";async function eR(e,t,n){let r=`${e}:${t}`,o=vg.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await oe(`${kw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{vg.delete(r)});return vg.set(r,i),i}function tR(e,t,n){try{sessionStorage.setItem(`${Tl}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function nR(e,t){try{let n=sessionStorage.getItem(`${Tl}${e}`);if(!n)return null;let r=JSON.parse(n);if(r.figmaNodeId===t&&Date.now()-r.timestamp<1800*1e3)return r.imageUrl;sessionStorage.removeItem(`${Tl}${e}`)}catch{}return null}function rR(e){try{let t=sessionStorage.getItem(`${Tl}${e}`);if(!t)return null;let n=JSON.parse(t);if(n.imageUrl&&Date.now()-n.timestamp<300*1e3)return n.imageUrl}catch{}return null}var bw,Sw,ww,vw,Ci,kw,ir,kg,vg,Tl,Cw,Uo,Ns=$(()=>{"use strict";ve();Cg();De();je();pt();bw="storyArgsUpdated",Sw="storyRendered",ww="forceRemount",vw=null,Ci=()=>vw,kw=q(),ir=new Map,kg=null,vg=new Map;Tl="uicopilot-figma-image-";Cw=(e,t,n)=>{kg=t;let r=ir.get(e);r?r.figmaImageUrl=n:ir.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},Uo=()=>{let[e,t]=Cl(!1),[n,r]=Cl(!1),[o,i]=Cl(!1),[s,a]=Cl(null),u=ZD(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ie(),d=Sg(()=>{let z=ht.getState().currentStoryId;z&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",z),ir.delete(z),u.current=null,i(!0),l())},[l]),f=Sg(()=>{let z=ht.getState().currentStoryId;if(z){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",z);let _=ir.get(z);_&&(_.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=we(),{selectedProjectId:g}=Ze(),{currentStoryId:S,currentMapping:C}=rt(),{setStorybookImageUrl:F,setFigmaImageUrl:k}=ie();zs(()=>{if(!S||ht.getState().figmaImageUrl)return;let _=rR(S);_&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",S),k(_))},[S,k]),zs(()=>{(async()=>{if(!p||!g||!S){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}let _=ht.getState();if(_.storybookImageUrl&&_.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded from persisted review, skipping capture"),u.current=S;return}let M=C?.figmaNodeId??null;if(M!==kg){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",S);let I=ir.get(S);I&&(I.figmaImageUrl=null),kg=M,u.current=null}let B=C?.figmaNodeId;if(B&&!ir.get(S)?.figmaImageUrl){let I=nR(S,B);if(I){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",S),k(I);let v=ir.get(S);v?v.figmaImageUrl=I:ir.set(S,{storybookImageUrl:null,figmaImageUrl:I})}}let m=ir.get(S),x=m&&m.storybookImageUrl&&m.figmaImageUrl,b=m&&m.storybookImageUrl&&!m.figmaImageUrl,E=m&&!m.storybookImageUrl&&m.figmaImageUrl;if(x){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",S),F(m.storybookImageUrl),k(m.figmaImageUrl),u.current=S;return}let h=b&&C?.figmaNodeId;h&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",S),F(m.storybookImageUrl));let T=E;if(T&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",S),k(m.figmaImageUrl)),u.current===S&&C?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{a(null),h?r(!0):(T||(t(!0),r(!0)),i(!0)),u.current=S;let I=T?m.figmaImageUrl:null,v;if(T)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(B){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",B);let P=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let D=await eR(g,B,p);P=D.imageUrl||null;let N=D.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${N}:`,P?"success":"not found")}catch(D){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",D)}if(P)if(P.includes(".azureedge.net")||P.includes(".blob.core.windows.net")||P.includes(".blob.vercel-storage.com")){y.debug("[useReviewScreenshots] Using cached CDN URL directly (fast)"),I=P,k(P);let N=new Image;N.crossOrigin="anonymous",await new Promise(w=>{N.onload=()=>{v={width:N.naturalWidth,height:N.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),w()},N.onerror=()=>w(),N.src=P})}else try{y.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let N=`${kw}/api/proxy/image?url=${encodeURIComponent(P)}`,w=await oe(N);if(w.ok){let j=await w.blob(),G=new FileReader,L=await new Promise((ee,re)=>{G.onloadend=()=>ee(G.result),G.onerror=re,G.readAsDataURL(j)});I=L,k(L),y.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let K=new Image;await new Promise(ee=>{K.onload=()=>{v={width:K.naturalWidth,height:K.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),ee()},K.onerror=()=>ee(),K.src=L})}else I=P,k(P),y.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(N){y.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",N),I=P,k(P)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",B),k(null);I&&B&&tR(S,B,I),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),k(null),r(!1);let A=m?.storybookImageUrl||null;if(A)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",S);let P=await Il({storyId:S,sessionToken:p||void 0,...v&&{figmaWidth:v.width,figmaHeight:v.height}});P?(A=P,F(P),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",v||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}ir.set(S,{storybookImageUrl:A,figmaImageUrl:I}),y.debug("[useReviewScreenshots] Screenshots cached for story:",S)}catch(I){y.error("[useReviewScreenshots] Error loading screenshots:",I),a(I instanceof Error?I.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})()},[p,g,S,C?.figmaNodeId,c]),zs(()=>{let z=wg.getChannel(),_=null,M=B=>{vw=B.args,y.debug("[useReviewScreenshots] Args updated for story:",B.storyId,"args:",B.args),_&&clearTimeout(_),_=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return z.on(bw,M),()=>{z.off(bw,M),_&&clearTimeout(_)}},[d]),zs(()=>{let z=wg.getChannel(),_=!1,M=null,B=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),_=!0,i(!0)},m=()=>{_&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),M&&clearTimeout(M),M=setTimeout(()=>{_=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),f()},500))};return z.on(ww,B),z.on(Sw,m),()=>{z.off(ww,B),z.off(Sw,m),M&&clearTimeout(M)}},[f]),zs(()=>{let z=wg.getChannel(),_=async M=>{if(!M?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let B=ht.getState().currentStoryId,m=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M.snapshot,storyId:B})});if(m.ok){let x=await m.json();if(x.screenshot){F(x.screenshot);let b=ht.getState().currentStoryId;if(b){let E=ir.get(b);E?E.storybookImageUrl=x.screenshot:ir.set(b,{storybookImageUrl:x.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await m.text())}catch(B){y.error("[useReviewScreenshots] Snapshot screenshot error:",B)}finally{i(!1)}};return z.on("UICOPILOT/STORY_DOM_MUTATED",_),()=>{z.off("UICOPILOT/STORY_DOM_MUTATED",_)}},[]);let R=Sg((z,_,M)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Cw(z,_,M),k(M),r(!1),u.current=z},[k]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:f,setFigmaImageDirect:R}}});function iR(){return!q().startsWith("http://localhost")}function sR(e,t,n){let r=t.createElement("div");r.style.color=e,t.body.appendChild(r);let o=n.getComputedStyle(r).color;return r.remove(),o}function Tw(e,t,n){let r=new Map;return e.replace(/(?:color|oklch|oklab|lab|lch)\([^)]+\)/g,o=>{if(r.has(o))return r.get(o);let i=sR(o,t,n);return r.set(o,i),i})}async function aR(){let e=(await import("html2canvas")).default,t=document.getElementById("storybook-preview-iframe");if(!t?.contentDocument||!t.contentWindow)throw new Error("Storybook iframe not accessible");let n=t.contentDocument.querySelector("#storybook-root > *")||t.contentDocument.querySelector("#root > *");if(!n)throw new Error("Story element not found in iframe");let r=t.contentWindow,o=t.contentDocument;return(await e(n,{useCORS:!0,logging:!1,backgroundColor:null,onclone:s=>{s.querySelectorAll("style").forEach(u=>{let c=u.textContent||"";/(?:color|oklch|oklab|lab|lch)\(/.test(c)&&(u.textContent=Tw(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(d=>d.href===c);if(l)try{let d="";for(let f of Array.from(l.cssRules))d+=f.cssText+`
13
- `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let f=s.createElement("style");f.textContent=Tw(d,o,r),u.replaceWith(f)}}catch{}})}})).toDataURL("image/png")}function lR(e){let t=[];for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let o;typeof r=="boolean"?o=`!${r}`:typeof r=="number"?o=String(r):typeof r=="string"?o=encodeURIComponent(r).replace(/%20/g,"+"):o=encodeURIComponent(JSON.stringify(r)),t.push(`${n}:${o}`)}return t.join(";")}async function cR(e,t){y.debug("[Screenshot] Using server-side Chrome capture for:",e);let n={"Content-Type":"application/json"};t?.sessionToken&&(n.Authorization=`Bearer ${t.sessionToken}`);let r=await oe(`${oR}/api/screenshot`,{method:"POST",headers:n,body:JSON.stringify({url:e,selector:t?.selector,width:t?.width,height:t?.height,scale:t?.scale||1,figmaWidth:t?.figmaWidth,figmaHeight:t?.figmaHeight})});if(!r.ok){let i=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Screenshot failed: ${r.status}`)}return(await r.json()).screenshot}function uR(e){let t={};if(!e)return t;let n=e.split(";");for(let r of n){let o=r.indexOf(":");if(o===-1)continue;let i=r.slice(0,o),s=r.slice(o+1);typeof s=="string"&&(s==="!true"?s=!0:s==="!false"?s=!1:!isNaN(Number(s))&&s!==""?s=Number(s):s=decodeURIComponent(s.replace(/\+/g," "))),t[i]=s}return t}function pR(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),y.debug("[Screenshot] Warning: Using story ID from URL (fallback):",n)),!n)throw new Error("Could not determine current story ID. Please select a story first.");let r=window.location.origin,o=Date.now(),i=`${r}/iframe.html?viewMode=story&id=${n}&globals=&_cb=${o}`,s=Ci();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=uR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=lR(s);i+=`&args=${a}`,y.debug("[Screenshot] Using URL with current args:",i)}else y.debug("[Screenshot] No current args, using default URL:",i);return i}async function dR(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return y.info("[Screenshot] Local Puppeteer not available, falling back"),null;if(!t.ok){let r=await t.json().catch(()=>({error:"Unknown"}));throw new Error(r.error||`Screenshot failed: ${t.status}`)}let n=await t.json();return y.info("[Screenshot] Captured via local Puppeteer (pixel-perfect)"),n.screenshot}catch(t){if(t instanceof TypeError&&t.message.includes("fetch"))return null;throw t}}async function Il(e){let t=e?.storyId||fR();if(t){let n=Tg.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Iw(t,e).finally(()=>{Tg.delete(t)});return Tg.set(t,r),r}return Iw(void 0,e)}async function Iw(e,t){try{if(e){let n=await dR(e);if(n)return n}if(!iR()){let n=pR(t?.storyId);return await cR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await aR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function fR(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var oR,Tg,Cg=$(()=>{"use strict";je();Ns();De();pt();oR=q();Tg=new Map});function vn(e){if(e==="transparent"||e==="rgba(0, 0, 0, 0)")return"transparent";let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(!t)return e;let[,n,r,o,i]=t,s=i?parseFloat(i):1;return s<1?`rgba(${n}, ${r}, ${o}, ${s})`:`#${[n,r,o].map(u=>parseInt(u).toString(16).padStart(2,"0")).join("")}`}function Dn(e,t){let r={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"],gap:["normal","0px"],flexDirection:["row"],justifyContent:["normal","flex-start"],alignItems:["normal","stretch"],textAlign:["start","left"],letterSpacing:["normal","0px"],margin:["0px","0px 0px 0px 0px"],padding:["0px","0px 0px 0px 0px"]}[e];return r?r.includes(t):!1}function Os(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Fw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let C=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let k=t.fonts.check(`${F} ${C} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:k,fontWeight:F,fontSize:C,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(R=>({family:R.family,status:R.status}))}),k)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(C=>C.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],f=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,g="unknown",S=new Map;for(let C of f){s.font=`${c} ${u} ${a} "${C}", monospace`;let F=s.measureText(o).width;if(S.set(C,F),F!==p){s.font=`${c} ${u} ${a} "${C}"`;let k=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let R=s.measureText(o).width;if(Math.abs(k-R)<.1){g=C;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:g,declaredFonts:l,fontWidths:Array.from(S.entries()),isIframe:t!==document}),g}var _s=$(()=>{"use strict";De()});function Ti(e,t){if(!t)return e;let n=t.split(" ").filter(i=>i.trim()),r=n.find(i=>!i.includes("--")),o=n.filter(i=>i.includes("--"));return r&&o.length>0?`${e}.${r}.${o[0]}`:r?`${e}.${r}`:n[0]?`${e}.${n[0]}`:e}function Ig(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return y.debug("[computedStyles] Extracting styles:",{fontFamily:n.fontFamily,fontWeight:n.fontWeight,borderRadius:n.borderRadius,backgroundColor:n.backgroundColor,padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},isIframeContext:e.ownerDocument!==document}),{color:vn(n.color),backgroundColor:vn(n.backgroundColor),borderColor:vn(n.borderColor),padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},margin:{top:n.marginTop,right:n.marginRight,bottom:n.marginBottom,left:n.marginLeft},gap:n.gap,fontFamily:n.fontFamily,renderedFont:Fw(e),fontSize:n.fontSize,fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,textAlign:n.textAlign,textTransform:n.textTransform,width:n.width,height:n.height,minWidth:n.minWidth,minHeight:n.minHeight,maxWidth:n.maxWidth,maxHeight:n.maxHeight,borderWidth:n.borderWidth,borderStyle:n.borderStyle,borderRadius:n.borderRadius,boxShadow:n.boxShadow,textShadow:n.textShadow,display:n.display,flexDirection:n.display==="flex"?n.flexDirection:void 0,justifyContent:n.display==="flex"?n.justifyContent:void 0,alignItems:n.display==="flex"?n.alignItems:void 0,position:n.position,opacity:n.opacity,cursor:n.cursor}}function Fg(e,t){let n={width:null,height:null,minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,display:null,flexGrow:null,flexShrink:null,flexBasis:null};try{let r=Array.from(t.styleSheets);for(let i of r)try{let s=i.cssRules||i.rules;if(!s)continue;for(let a of Array.from(s))if(a.type===1){let u=a;try{if(e.matches(u.selectorText)){let c=u.style;c.width&&(n.width=c.width),c.height&&(n.height=c.height),c.minWidth&&(n.minWidth=c.minWidth),c.minHeight&&(n.minHeight=c.minHeight),c.maxWidth&&(n.maxWidth=c.maxWidth),c.maxHeight&&(n.maxHeight=c.maxHeight),c.display&&(n.display=c.display),c.flexGrow&&(n.flexGrow=c.flexGrow),c.flexShrink&&(n.flexShrink=c.flexShrink),c.flexBasis&&(n.flexBasis=c.flexBasis)}}catch{continue}}}catch{continue}let o=e.style;o.width&&(n.width=o.width),o.height&&(n.height=o.height),o.minWidth&&(n.minWidth=o.minWidth),o.minHeight&&(n.minHeight=o.minHeight),o.maxWidth&&(n.maxWidth=o.maxWidth),o.maxHeight&&(n.maxHeight=o.maxHeight),o.display&&(n.display=o.display),o.flexGrow&&(n.flexGrow=o.flexGrow),o.flexShrink&&(n.flexShrink=o.flexShrink),o.flexBasis&&(n.flexBasis=o.flexBasis)}catch(r){y.error("Error extracting declared styles:",r)}return n}var Fl=$(()=>{"use strict";De();_s()});function gR(e){let t=[],n=new Set,r=Ew.join(", "),o=e.querySelectorAll(r);for(let i of Array.from(o)){let s=`${i.tagName.toLowerCase()}.${i.className}`;n.has(s)||(n.add(s),t.push(i))}if(Ew.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function mR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"";return{selector:Ti(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Os(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:vn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function hR(e,t=2){let n=[e],r=new Set,o=s=>{let a=s.className;return typeof a=="string"?a:a?.baseVal||""};r.add(`${e.tagName}.${o(e)}`);function i(s,a){if(a>=t)return;let u=Array.from(s.children);for(let c of u){let l=c.tagName.toLowerCase();if(["script","style","link","meta","br","hr"].includes(l))continue;let d=`${c.tagName}.${o(c)}`;r.has(d)||(r.add(d),n.push(c),i(c,a+1))}}return i(e,0),n}function xR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"",s=n.borderWidth!=="0px",a=n.backgroundColor!=="transparent"&&n.backgroundColor!=="rgba(0, 0, 0, 0)",u=n.borderRadius!=="0px",c=n.gap!=="normal"&&n.gap!=="0px";if(!s&&!a&&!u&&!c)return null;let l=n.borderWidth,d=n.borderStyle,f=vn(n.borderColor),p=s?`${l} ${d} ${f}`:"none";return{selector:Ti(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:vn(n.backgroundColor),gap:n.gap}}function $s(){y.debug("[computedStyles] extractStoryStyles called - FULL CONTEXT VERSION");try{let e=document.getElementById("storybook-preview-iframe");if(!e||!e.contentDocument)throw new Error("Storybook preview iframe not found");let t=e.contentDocument,n=t.getElementById("storybook-root");if(!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(!r)throw new Error("Component element not found in story root");let o=hR(r,2),i=o.map(xR).filter(a=>a!==null);y.debug("[computedStyles] Extracted visual styles from nested elements:",{total:o.length,withVisuals:i.length,elements:i.map(a=>({selector:a.selector,border:a.border,background:a.backgroundColor,borderRadius:a.borderRadius}))});let s=[];try{let a=gR(r);s=a.map(mR),y.debug("[computedStyles] Text elements found:",{count:a.length,elements:s.map(u=>({selector:u.selector,fontSize:u.styles.fontSize,fontWeight:u.styles.fontWeight}))})}catch(a){y.error("[computedStyles] Error extracting text elements:",a)}return{computed:Ig(r),declared:Fg(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Ew,Aw=$(()=>{"use strict";De();_s();Fl();Ew=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Eg(e,t,n,r){return e===t&&t===n&&n===r?e:e===n&&t===r?`${e} ${t}`:t===r?`${e} ${t} ${n}`:`${e} ${t} ${n} ${r}`}function bR(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function SR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=vn(n.backgroundColor);Dn("backgroundColor",o)||(r.backgroundColor=o);let i=bR(n.borderWidth,n.borderStyle,vn(n.borderColor));i&&(r.border=i),Dn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Dn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Dn("opacity",n.opacity)||(r.opacity=n.opacity);let s=e.tagName.toLowerCase(),a=["svg","circle","rect","ellipse","line","polyline","polygon","path","text","tspan","g","use","defs","clipPath","mask"];if(e instanceof SVGElement||a.includes(s)){for(let C=0;C<e.attributes.length;C++){let F=e.attributes[C];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let k=F.name.replace(/-([a-z])/g,(z,_)=>_.toUpperCase()),R=F.value.startsWith("rgb")?vn(F.value):F.value;k==="d"&&R.length>100?r[k]=R.substring(0,100)+"...":r[k]=R}let p=n.getPropertyValue("fill"),g=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?vn(p):p),g&&g!=="none"&&(r.stroke=g.startsWith("rgb")?vn(g):g),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let C=e.getBoundingClientRect();C.width>0&&(r.width=`${Math.round(C.width*100)/100}px`),C.height>0&&(r.height=`${Math.round(C.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=yR.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Os(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=vn(n.color),Dn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Dn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=Eg(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Dn("padding",d)||(r.padding=d);let f=Eg(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Dn("margin",f)||(r.margin=f),Dn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Dn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Dn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Dn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function Pw(e){let t=1;for(let n of e.children)t+=Pw(n);return t}function Lw(e,t=4){function n(o,i){let s=o.tagName.toLowerCase(),a=o.className,u=typeof a=="string"?a:a?.baseVal||"",c=o.id||void 0,l=o.getAttribute("role")||void 0,d;for(let S of Array.from(o.childNodes))if(S.nodeType===Node.TEXT_NODE){let C=S.textContent?.trim();if(C){d=C.length>50?C.substring(0,50)+"...":C;break}}let f=s;c?f=`${s}#${c}`:u&&(f=Ti(s,u));let p=SR(o),g=[];if(i<t){let S=Array.from(o.children);for(let C of S){let F=C.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let R=(C.ownerDocument.defaultView||window).getComputedStyle(C);R.display==="none"||R.visibility==="hidden"||g.push(n(C,i+1))}}return{selector:f,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:g}}y.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return y.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:Pw(r)}),r}function Ag(e=4){y.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(y.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(y.debug("[extractStoryDOMTree] iframe.contentDocument:",!!t.contentDocument),!t.contentDocument)throw new Error("iframe.contentDocument is not accessible (possible cross-origin issue)");let n=t.contentDocument.getElementById("storybook-root");if(y.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(y.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=Lw(r,e);return y.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return y.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var yR,Mw=$(()=>{"use strict";De();_s();Fl();yR=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Pg=$(()=>{"use strict";_s();Fl();Aw();Mw()});var ov=Jn((nX,rv)=>{"use strict";rv.exports={compareTwoStrings:nv,findBestMatch:VR};function nv(e,t){if(e=e.replace(/\s+/g,""),t=t.replace(/\s+/g,""),e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let o=0;o<e.length-1;o++){let i=e.substring(o,o+2),s=n.has(i)?n.get(i)+1:1;n.set(i,s)}let r=0;for(let o=0;o<t.length-1;o++){let i=t.substring(o,o+2),s=n.has(i)?n.get(i):0;s>0&&(n.set(i,s-1),r++)}return 2*r/(e.length+t.length-2)}function VR(e,t){if(!GR(e,t))throw new Error("Bad arguments: First argument should be a string, second should be an array of strings");let n=[],r=0;for(let i=0;i<t.length;i++){let s=t[i],a=nv(e,s);n.push({target:s,rating:a}),a>n[r].rating&&(r=i)}let o=n[r];return{ratings:n,bestMatch:o,bestMatchIndex:r}}function GR(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var KC=Jn((Joe,YC)=>{"use strict";var WC=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,O4=/\n/g,_4=/^\s*/,$4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,U4=/^:\s*/,j4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,H4=/^[;\s]*/,W4=/^\s+|\s+$/g,V4=`
14
- `,VC="/",GC="*",Qo="",G4="comment",q4="declaration";function Y4(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(g){var S=g.match(O4);S&&(n+=S.length);var C=g.lastIndexOf(V4);r=~C?g.length-C:r+g.length}function i(){var g={line:n,column:r};return function(S){return S.position=new s(g),c(),S}}function s(g){this.start=g,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(g){var S=new Error(t.source+":"+n+":"+r+": "+g);if(S.reason=g,S.filename=t.source,S.line=n,S.column=r,S.source=e,!t.silent)throw S}function u(g){var S=g.exec(e);if(S){var C=S[0];return o(C),e=e.slice(C.length),S}}function c(){u(_4)}function l(g){var S;for(g=g||[];S=d();)S!==!1&&g.push(S);return g}function d(){var g=i();if(!(VC!=e.charAt(0)||GC!=e.charAt(1))){for(var S=2;Qo!=e.charAt(S)&&(GC!=e.charAt(S)||VC!=e.charAt(S+1));)++S;if(S+=2,Qo===e.charAt(S-1))return a("End of comment missing");var C=e.slice(2,S-2);return r+=2,o(C),e=e.slice(S),r+=2,g({type:G4,comment:C})}}function f(){var g=i(),S=u($4);if(S){if(d(),!u(U4))return a("property missing ':'");var C=u(j4),F=g({type:q4,property:qC(S[0].replace(WC,Qo)),value:C?qC(C[0].replace(WC,Qo)):Qo});return u(H4),F}}function p(){var g=[];l(g);for(var S;S=f();)S!==!1&&(g.push(S),l(g));return g}return c(),p()}function qC(e){return e?e.replace(W4,Qo):Qo}YC.exports=Y4});var XC=Jn(oa=>{"use strict";var K4=oa&&oa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(oa,"__esModule",{value:!0});oa.default=Q4;var X4=K4(KC());function Q4(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,X4.default)(e),o=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;let{property:s,value:a}=i;o?t(s,a,i):a&&(n=n||{},n[s]=a)}),n}});var JC=Jn(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.camelCase=void 0;var J4=/^--[a-zA-Z0-9_-]+$/,Z4=/-([a-z])/g,eU=/^[^-]+$/,tU=/^-(webkit|moz|ms|o|khtml)-/,nU=/^-(ms)-/,rU=function(e){return!e||eU.test(e)||J4.test(e)},oU=function(e,t){return t.toUpperCase()},QC=function(e,t){return"".concat(t,"-")},iU=function(e,t){return t===void 0&&(t={}),rU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(nU,QC):e=e.replace(tU,QC),e.replace(Z4,oU))};uc.camelCase=iU});var e1=Jn((dh,ZC)=>{"use strict";var sU=dh&&dh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},aU=sU(XC()),lU=JC();function ph(e,t){var n={};return!e||typeof e!="string"||(0,aU.default)(e,function(r,o){r&&o&&(n[(0,lU.camelCase)(r,t)]=o)}),n}ph.default=ph;ZC.exports=ph});var FT=Jn((Fue,IT)=>{"use strict";var Bc=Object.prototype.hasOwnProperty,TT=Object.prototype.toString,bT=Object.defineProperty,ST=Object.getOwnPropertyDescriptor,wT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):TT.call(t)==="[object Array]"},vT=function(t){if(!t||TT.call(t)!=="[object Object]")return!1;var n=Bc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Bc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Bc.call(t,o)},kT=function(t,n){bT&&n.name==="__proto__"?bT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},CT=function(t,n){if(n==="__proto__")if(Bc.call(t,n)){if(ST)return ST(t,n).value}else return;return t[n]};IT.exports=function e(){var t,n,r,o,i,s,a=arguments[0],u=1,c=arguments.length,l=!1;for(typeof a=="boolean"&&(l=a,a=arguments[1]||{},u=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});u<c;++u)if(t=arguments[u],t!=null)for(n in t)r=CT(a,n),o=CT(t,n),a!==o&&(l&&o&&(vT(o)||(i=wT(o)))?(i?(i=!1,s=r&&wT(r)?r:[]):s=r&&vT(r)?r:{},kT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&kT(a,{name:n,newValue:o}));return a}});import Ia from"react";import{addons as Vc,types as _x,experimental_getStatusStore as hF}from"storybook/manager-api";import{AddonPanel as E8}from"storybook/internal/components";import Mt,{useState as qW,useEffect as YW}from"react";import{styled as fr}from"storybook/theming";import Yx from"react";import{styled as At}from"storybook/theming";var le="#ea580c",Yc="#c2410c",Pa="#ff6b35";var jx=At.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),Hx=At.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),ts=At.div({marginBottom:"20px"}),ns=At.label(({theme:e})=>({display:"block",marginBottom:`${e.layoutMargin*.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),rs=At.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,"&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`}})),En=At.select(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px 32px ${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px",transition:"border-color 0.15s, box-shadow 0.15s","&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`},"&:hover":{borderColor:e.color.mediumdark},"&:disabled":{opacity:.6,cursor:"not-allowed"}})),Wx=At(En)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),La=e=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:disabled":{opacity:.5,cursor:"not-allowed"}}),er=At.button(({theme:e})=>({...La(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),qt=At.button(({theme:e})=>({...La(e),backgroundColor:le,color:e.color.inverseText,boxShadow:`0 2px 4px ${le}4d`,"&:hover:not(:disabled)":{backgroundColor:Yc,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${le}66`}})),Er=At.button(({theme:e})=>({...La(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),Vx=At.button(({theme:e})=>({...La(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),wn=At.button(({theme:e})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:`${e.layoutMargin*.4}px`,fontSize:e.typography.size.s2,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Kc=At.button(({theme:e})=>({padding:0,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.secondary,backgroundColor:"transparent",border:"none",cursor:"pointer",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),io=At.button(({theme:e,active:t})=>({padding:`${e.layoutMargin*.6}px ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:t?e.typography.weight.bold:400,color:t?e.color.secondary:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderBottom:t?`2px solid ${e.color.secondary}`:"2px solid transparent",cursor:"pointer",transition:"all 0.15s","&:hover":{color:t?e.color.secondary:e.color.defaultText}})),so=At(rs)(({theme:e})=>({paddingLeft:`${e.layoutMargin*3}px`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:`${e.layoutMargin}px center`,backgroundSize:"14px"})),z8=At.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Gx=At.h2(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s3,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),N8=At.h3(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),Xc=At.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),O8=At.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.background.hoverable,borderRadius:e.appBorderRadius,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"100%",background:`linear-gradient(90deg, transparent, ${e.color.mediumlight}33, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{transform:"translateX(-100%)"},"100%":{transform:"translateX(100%)"}}})),qx=At.span(({theme:e,variant:t="default"})=>{let n={default:{bg:e.background.hoverable,color:e.color.defaultText},success:{bg:`${e.color.positive}40`,color:e.color.positive},warning:{bg:`${e.color.warning}40`,color:e.color.warning},error:{bg:`${e.color.negative}40`,color:e.color.negative}};return{display:"inline-block",padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,borderRadius:"3px",backgroundColor:n[t].bg,color:n[t].color}}),_8=At.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),$8=At.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),U8=At.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var Qc=({header:e,children:t,footer:n})=>Yx.createElement(jx,null,e,Yx.createElement(Hx,null,t),n);import TF from"react";import{styled as IF}from"storybook/theming";var FF=IF.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),Jc=({toolbar:e})=>TF.createElement(FF,null,e);import Q8 from"react";import{styled as Ma}from"storybook/theming";var eV=Ma.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),tV=Ma.div({display:"flex",flex:1}),nV=Ma(io)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),rV=Ma.div({display:"flex",gap:"8px",alignItems:"center"});import pn,{useState as gw,useCallback as mw,useEffect as hw}from"react";import{styled as fo}from"storybook/theming";import Re,{useEffect as aw}from"react";import{styled as at}from"storybook/theming";ve();je();De();pt();var lw=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),cw=at.div(({theme:e})=>({position:"absolute",top:"100%",right:0,marginTop:"8px",backgroundColor:e.background.content,borderRadius:"12px",width:"360px",maxWidth:"90vw",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)",overflow:"hidden",zIndex:10001})),uD=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),pD=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),dD=at.div({display:"flex",flexDirection:"column",gap:"4px"}),fD=at.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),gD=at.span({display:"inline-block",alignSelf:"flex-start",padding:"2px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:600,color:"#7c3aed",backgroundColor:"rgba(124, 58, 237, 0.1)",letterSpacing:"0.3px"}),mD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),hD=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),xD=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),yD=at.div(({theme:e})=>({height:"8px",borderRadius:"4px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",margin:"0 16px 8px",overflow:"hidden"})),bD=at.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${le} 100%)`,transition:"width 0.3s ease"})),SD=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),wD=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),vD=at.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:le,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),kD=at.button(({theme:e})=>({position:"absolute",top:"12px",right:"12px",width:"24px",height:"24px",borderRadius:"4px",border:"none",background:"transparent",color:e.textMutedColor,cursor:"pointer",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:e.background.hoverable}})),CD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),TD=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),ID=at.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),FD=at.div({display:"flex",gap:"8px"}),uw=at(wn)({fontSize:"18px"}),ED=at.div({padding:"20px 16px"}),AD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),PD=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),LD=at.div({fontSize:"28px",fontWeight:700}),MD=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),BD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),DD=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),RD=at.div({display:"flex",alignItems:"center",gap:"8px"}),zD=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),ND=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:le,color:e.color.inverseText})),OD=at.button(({theme:e})=>({background:"none",border:"none",color:le,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),_D=at.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),$D=at.button(({theme:e,variant:t="primary"})=>({width:"100%",padding:"12px",borderRadius:"6px",fontSize:"14px",fontWeight:600,cursor:"pointer",border:"none",marginBottom:"12px",backgroundColor:t==="primary"?le:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),UD=30*1e3,pw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ie(),a=s.showCosts,u=r,c=!r&&t,l=async(g=!1)=>{if(!t)return;let S=o&&Date.now()-o<UD;if(!(!g&&S&&r))try{let C=q(),F=await oe(`${C}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(F.ok){let k=await F.json();i(k)}}catch(C){y.error("Failed to fetch usage:",C)}};aw(()=>{l()},[t]),aw(()=>{let g=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[t]);let d=()=>{n(),e()},f=()=>{let g=q();window.open(`${g}/pricing`,"_blank")},p=()=>{let g=q();window.open(`${g}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let g=Math.floor(u?.creditBalance??0),C=Math.max(g,10),F=Math.max(0,C-g),k=C>0?g/C*100:0;return Re.createElement(Re.Fragment,null,Re.createElement(lw,{onClick:e}),Re.createElement(cw,{onClick:R=>R.stopPropagation(),style:{width:"320px"}},Re.createElement(kD,{onClick:e,title:"Close"},"\xD7"),Re.createElement(uD,null,Re.createElement(pD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement(dD,null,Re.createElement(fD,null,"UI Review"),Re.createElement(gD,null,(u?.plan||"BETA").toUpperCase()))),Re.createElement(mD,null,Re.createElement(hD,null,"Credits"),Re.createElement(xD,null,g," left")),Re.createElement(yD,null,Re.createElement(bD,{percent:k})),Re.createElement(SD,null,F," used \xB7 ",g," remaining"),Re.createElement(wD,null),Re.createElement(vD,{onClick:p},"Get free credits \u2192")))}return Re.createElement(Re.Fragment,null,Re.createElement(lw,{onClick:e}),Re.createElement(cw,{onClick:g=>g.stopPropagation()},Re.createElement(CD,null,Re.createElement(TD,null,Re.createElement(ID,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement("span",null,u?.email||"Loading...")),Re.createElement(FD,null,Re.createElement(uw,{onClick:d,title:"Sign out"},"\u2192"),Re.createElement(uw,{onClick:e,title:"Close"},"\xD7"))),Re.createElement(ED,null,c?Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Re.createElement(Re.Fragment,null,Re.createElement(AD,null,Re.createElement(PD,null,"Credit Balance"),Re.createElement(LD,null,"$",(u?.creditBalance??0).toFixed(2)),Re.createElement(MD,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Re.createElement(BD,null,Re.createElement(DD,null,Re.createElement(RD,null,Re.createElement(zD,null,"Current Plan"),Re.createElement(ND,null,u?.plan||"Free")),Re.createElement(OD,{onClick:f},"View detail >")),Re.createElement(_D,null,"~$0.02-0.05 per review depending on complexity"),Re.createElement($D,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};ve();import wi from"react";import{styled as dw}from"storybook/theming";je();ve();pt();De();var jD=dw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),HD=dw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),WD={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}},fw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ie(),{sessionToken:o}=we();return e!=="admin"?null:wi.createElement(jD,null,wi.createElement(HD,null,"View as:"),wi.createElement(Wx,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&oe(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>y.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=WD[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},wi.createElement("option",{value:"admin"},"Admin"),wi.createElement("option",{value:"beta"},"Beta Tester")),t&&wi.createElement(qx,{variant:"warning"},"Previewing as ",t))};ve();je();pt();var VD=fo.div({display:"flex",alignItems:"center"}),vi=fo.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),GD=fo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),qD=fo.div({position:"relative"}),YD=fo.button(({theme:e})=>({width:"26px",height:"26px",padding:0,background:`linear-gradient(135deg, ${e.color.secondary} 0%, ${e.color.secondary}cc 100%)`,border:"none",borderRadius:"50%",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s","&:hover":{transform:"scale(1.05)",boxShadow:`0 2px 8px ${e.color.secondary}66`}})),xw=fo.button(({isLow:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",background:e?"#FEF3C7":"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",border:"none",borderRadius:"12px",color:e?"#92400E":"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,transition:"all 0.2s",minWidth:"60px",justifyContent:"center","&:hover":{transform:"scale(1.02)",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})),KD=fo.span({display:"inline-block",width:"12px",height:"12px",border:"2px solid rgba(255,255,255,0.3)",borderTopColor:"#fff",borderRadius:"50%",animation:"credit-spin 0.8s linear infinite","@keyframes credit-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),XD=fo.button(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",padding:"4px 10px",height:"28px",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.mediumdark,fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.mediumdark}})),QD=30*1e3,bg=({onOpenSettings:e})=>{let[t,n]=gw(!1),[r,o]=gw(!1),{usageData:i,usageLastFetched:s,setUsageData:a,sessionToken:u}=we(),{userRole:c,roleOverride:l,featureFlags:d}=ie(),f=l??c;hw(()=>{(async()=>{if(!(!u||s&&Date.now()-s<QD&&i)){o(!0);try{let R=q(),z=await oe(`${R}/api/addon/account`,{headers:{Authorization:`Bearer ${u}`}});if(z.ok){let _=await z.json();a(_)}}catch(R){console.error("Failed to fetch balance:",R)}finally{o(!1)}}})()},[u,s,i,a]),hw(()=>{let F=()=>{document.visibilityState==="visible"&&t&&n(!1)},k=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",F),window.addEventListener("focus",k),()=>{document.removeEventListener("visibilitychange",F),window.removeEventListener("focus",k)}},[t]);let p=mw(()=>{n(!0)},[]),g=mw(()=>{n(!1)},[]),S=i?.creditBalance??0,C=S<2&&!r;return pn.createElement(VD,null,e&&pn.createElement(vi,null,pn.createElement(XD,{onClick:e,title:"Settings"},pn.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),u&&c==="admin"&&f==="admin"&&pn.createElement(vi,null,pn.createElement(fw,null)),pn.createElement(vi,null,pn.createElement(GD,null,"v","0.5.3")),u&&d.showCosts&&pn.createElement(vi,null,pn.createElement(xw,{onClick:p,isLow:C,title:r?"Loading...":i?C?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},r?pn.createElement(KD,null):i?`$${S.toFixed(2)}`:"...")),u&&!d.showCosts&&i&&pn.createElement(vi,null,pn.createElement(xw,{onClick:p,isLow:Math.floor(S)<=3,title:`${Math.floor(S)} review credits remaining \u2014 click to manage`},"\u26A1 ",Math.floor(S))),pn.createElement(vi,null,pn.createElement(qD,null,pn.createElement(YD,{title:"Account & Usage",onClick:p},i?.email?i.email[0].toUpperCase():"?"),t&&pn.createElement(pw,{onClose:g}))))};import Et from"react";import{styled as cr}from"storybook/theming";import Lt from"react";ve();De();je();pt();import{useCallback as ki,useRef as yw,useEffect as JD}from"react";var go=q();y.debug("[useAuth] Module loaded, APP_URL:",go);var Bs=()=>{let e=yw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:f,setUserCode:p,setVerificationUri:g,setPollingInterval:S,setAuthError:C,resetAuth:F}=we(),k=yw(null),R=ki(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let x;try{x=await oe(`${go}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let D=A instanceof Error&&A.message.includes("timed out")?`Cannot reach UI Copilot server at ${go}. Is the dashboard running?`:`Connection failed: ${go} is not responding.`;C(D),y.error("[useAuth]",D);return}if(!x.ok)throw new Error("Failed to create poll code");let{poll_code:b}=await x.json();y.debug("[useAuth] Got poll_code:",b.substring(0,15)+"...");let E=600,h=700,T=window.screenX+(window.outerWidth-E)/2,I=window.screenY+(window.outerHeight-h)/2;window.open(`${go}/addon/auth?poll_code=${b}`,"figma-auth",`width=${E},height=${h},left=${T},top=${I}`),y.debug("[useAuth] Starting OAuth poll for token..."),k.current&&clearInterval(k.current);let v=async()=>{try{let P=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:b})})).json();P.status==="authorized"&&P.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),k.current&&(clearInterval(k.current),k.current=null),localStorage.setItem("uicopilot_session_token",P.session_token),c(P.session_token)):P.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),k.current&&(clearInterval(k.current),k.current=null))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};k.current=setInterval(v,2e3),setTimeout(v,1e3)}catch(x){y.error("[useAuth] OAuth flow error:",x)}},[c]),z=ki(async()=>{try{let x=await fetch(`${go}/api/addon/auth/device`,{method:"POST"});if(!x.ok)throw new Error("Failed to start device code flow");let b=await x.json();f(b.device_code),p(b.user_code),g(b.verification_uri),window.open(b.verification_uri,"_blank"),_(b.device_code,b.interval*1e3)}catch(x){throw y.error("[useAuth] Device code flow error:",x),x}},[f,p,g]),_=ki((x,b)=>{y.debug("[useAuth] Starting polling. Device code:",x,"Interval:",b),e.current&&clearInterval(e.current);let E=async()=>{try{let T=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:x})})).json();T.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null),localStorage.setItem("uicopilot_session_token",T.session_token),c(T.session_token)):(T.status==="expired"||T.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null))}catch(h){y.error("[useAuth] Polling error:",h)}};e.current=setInterval(E,b),S(b)},[f,p,g,c,S]),M=ki(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null),S(null)},[f,p,g,S]),B=ki(x=>{l(x),localStorage.setItem("uicopilot_api_key",x)},[l]),m=ki(()=>{F(),e.current&&(clearInterval(e.current),e.current=null)},[F]);return JD(()=>()=>{e.current&&clearInterval(e.current),k.current&&clearInterval(k.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setAuthMethod:d,startOAuth:R,startDeviceCode:z,cancelDeviceCode:M,saveApiKey:B,logout:m}};ve();De();je();pt();import{useCallback as kl}from"react";var Ds=q(),qr=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Ze(),{sessionToken:a}=we(),u=kl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Ds}/api/projects`);let f=await oe(`${Ds}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(f.ok){let p=await f.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",f.status,f.statusText)}catch(f){y.error("[useProjects] Error fetching projects:",f)}finally{i(!1)}},[a,r,i]),c=kl(async f=>{if(!a)throw new Error("Not authenticated");let p=await oe(`${Ds}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)});if(!p.ok)throw new Error("Failed to create project");let g=await p.json();return await u(),g.project},[a,u]),l=kl(async(f,p)=>{if(!a)throw new Error("Not authenticated");let g={};if(p.name!==void 0&&(g.name=p.name),p.description!==void 0&&(g.description=p.description),p.figmaFileUrl!==void 0&&(g.figmaFileId=p.figmaFileUrl||void 0),!(await oe(`${Ds}/api/projects/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=kl(async f=>{if(!a)throw new Error("Not authenticated");if(!(await oe(`${Ds}/api/projects/${f}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===f&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:d}};ve();var Rs=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d}=rt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};ve();Cg();Pg();import{useCallback as Vs,useRef as Rl}from"react";De();function El(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){y.warn("[iframeReload] No preview iframe found"),e();return}let n=t.contentWindow.location.href,r=new URL(n);r.searchParams.set("_cb",Date.now().toString());let o=r.toString();y.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{y.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),y.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{y.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var Al=BigInt(4294967295),Bw=BigInt(32);function wR(e,t=!1){return t?{h:Number(e&Al),l:Number(e>>Bw&Al)}:{h:Number(e>>Bw&Al)|0,l:Number(e&Al)|0}}function Dw(e,t=!1){let n=e.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=wR(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Rw=(e,t,n)=>e<<n|t>>>32-n,zw=(e,t,n)=>t<<n|e>>>32-n,Nw=(e,t,n)=>t<<n-32|e>>>64-n,Ow=(e,t,n)=>e<<n-32|t>>>64-n;function vR(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lg(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Pl(e,t,n=""){let r=vR(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){let s=n&&`"${n}" `,a=i?` of length ${t}`:"",u=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+u)}return e}function Mg(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _w(e,t){Pl(e,void 0,"digestInto() output");let n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function $w(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Bg(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var kR=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function CR(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function TR(e){for(let t=0;t<e.length;t++)e[t]=CR(e[t]);return e}var Dg=kR?e=>e:TR;function Uw(e,t={}){let n=(o,i)=>e(i).update(o).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=o=>e(o),Object.assign(n,t),Object.freeze(n)}var jw=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var IR=BigInt(0),Us=BigInt(1),FR=BigInt(2),ER=BigInt(7),AR=BigInt(256),PR=BigInt(113),Vw=[],Gw=[],qw=[];for(let e=0,t=Us,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Vw.push(2*(5*r+n)),Gw.push((e+1)*(e+2)/2%64);let o=IR;for(let i=0;i<7;i++)t=(t<<Us^(t>>ER)*PR)%AR,t&FR&&(o^=Us<<(Us<<BigInt(i))-Us);qw.push(o)}var Yw=Dw(qw,!0),LR=Yw[0],MR=Yw[1],Hw=(e,t,n)=>n>32?Nw(e,t,n):Rw(e,t,n),Ww=(e,t,n)=>n>32?Ow(e,t,n):zw(e,t,n);function BR(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],d=Hw(c,l,1)^n[a],f=Ww(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=Gw[s],u=Hw(o,i,a),c=Ww(o,i,a),l=Vw[s];o=e[l],i=e[l+1],e[l]=u,e[l+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=LR[r],e[1]^=MR[r]}Bg(n)}var Rg=class e{constructor(t,n,r,o=!1,i=24){Zn(this,"state");Zn(this,"pos",0);Zn(this,"posOut",0);Zn(this,"finished",!1);Zn(this,"state32");Zn(this,"destroyed",!1);Zn(this,"blockLen");Zn(this,"suffix");Zn(this,"outputLen");Zn(this,"enableXOF",!1);Zn(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Lg(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=$w(this.state)}clone(){return this._cloneInto()}keccak(){Dg(this.state32),BR(this.state32,this.rounds),Dg(this.state32),this.posOut=0,this.pos=0}update(t){Mg(this),Pl(t);let{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Mg(this,!1),Pl(t),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Lg(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(_w(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Bg(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new e(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}},DR=(e,t,n,r={})=>Uw(()=>new Rg(t,e,n),r);var Kw=DR(6,72,64,jw(10));var RR=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,zg=Math.ceil,ar=Math.floor,Rn="[BigNumber Error] ",Xw=Rn+"Number primitive has more than 15 significant digits: ",Sr=1e14,He=14,Ng=9007199254740991,Og=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],mo=1e7,rn=1e9;function Qw(e){var t,n,r,o=k.prototype={constructor:k,toString:null,valueOf:null},i=new k(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,f=!1,p=1,g=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function k(m,x){var b,E,h,T,I,v,A,P,D=this;if(!(D instanceof k))return new k(m,x);if(x==null){if(m&&m._isBigNumber===!0){D.s=m.s,!m.c||m.e>d?D.c=D.e=null:m.e<l?D.c=[D.e=0]:(D.e=m.e,D.c=m.c.slice());return}if((v=typeof m=="number")&&m*0==0){if(D.s=1/m<0?(m=-m,-1):1,m===~~m){for(T=0,I=m;I>=10;I/=10,T++);T>d?D.c=D.e=null:(D.e=T,D.c=[m]);return}P=String(m)}else{if(!RR.test(P=String(m)))return r(D,P,v);D.s=P.charCodeAt(0)==45?(P=P.slice(1),-1):1}(T=P.indexOf("."))>-1&&(P=P.replace(".","")),(I=P.search(/e/i))>0?(T<0&&(T=I),T+=+P.slice(I+1),P=P.substring(0,I)):T<0&&(T=P.length)}else{if(Dt(x,2,C.length,"Base"),x==10&&F)return D=new k(m),M(D,s+D.e+1,a);if(P=String(m),v=typeof m=="number"){if(m*0!=0)return r(D,P,v,x);if(D.s=1/m<0?(P=P.slice(1),-1):1,k.DEBUG&&P.replace(/^0\.0*|\./,"").length>15)throw Error(Xw+m)}else D.s=P.charCodeAt(0)===45?(P=P.slice(1),-1):1;for(b=C.slice(0,x),T=I=0,A=P.length;I<A;I++)if(b.indexOf(E=P.charAt(I))<0){if(E=="."){if(I>T){T=A;continue}}else if(!h&&(P==P.toUpperCase()&&(P=P.toLowerCase())||P==P.toLowerCase()&&(P=P.toUpperCase()))){h=!0,I=-1,T=0;continue}return r(D,String(m),v,x)}v=!1,P=n(P,x,10,D.s),(T=P.indexOf("."))>-1?P=P.replace(".",""):T=P.length}for(I=0;P.charCodeAt(I)===48;I++);for(A=P.length;P.charCodeAt(--A)===48;);if(P=P.slice(I,++A)){if(A-=I,v&&k.DEBUG&&A>15&&(m>Ng||m!==ar(m)))throw Error(Xw+D.s*m);if((T=T-I-1)>d)D.c=D.e=null;else if(T<l)D.c=[D.e=0];else{if(D.e=T,D.c=[],I=(T+1)%He,T<0&&(I+=He),I<A){for(I&&D.c.push(+P.slice(0,I)),A-=He;I<A;)D.c.push(+P.slice(I,I+=He));I=He-(P=P.slice(I)).length}else I-=A;for(;I--;P+="0");D.c.push(+P)}}else D.c=[D.e=0]}k.clone=Qw,k.ROUND_UP=0,k.ROUND_DOWN=1,k.ROUND_CEIL=2,k.ROUND_FLOOR=3,k.ROUND_HALF_UP=4,k.ROUND_HALF_DOWN=5,k.ROUND_HALF_EVEN=6,k.ROUND_HALF_CEIL=7,k.ROUND_HALF_FLOOR=8,k.EUCLID=9,k.config=k.set=function(m){var x,b;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(x="DECIMAL_PLACES")&&(b=m[x],Dt(b,0,rn,x),s=b),m.hasOwnProperty(x="ROUNDING_MODE")&&(b=m[x],Dt(b,0,8,x),a=b),m.hasOwnProperty(x="EXPONENTIAL_AT")&&(b=m[x],b&&b.pop?(Dt(b[0],-rn,0,x),Dt(b[1],0,rn,x),u=b[0],c=b[1]):(Dt(b,-rn,rn,x),u=-(c=b<0?-b:b))),m.hasOwnProperty(x="RANGE"))if(b=m[x],b&&b.pop)Dt(b[0],-rn,-1,x),Dt(b[1],1,rn,x),l=b[0],d=b[1];else if(Dt(b,-rn,rn,x),b)l=-(d=b<0?-b:b);else throw Error(Rn+x+" cannot be zero: "+b);if(m.hasOwnProperty(x="CRYPTO"))if(b=m[x],b===!!b)if(b)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=b;else throw f=!b,Error(Rn+"crypto unavailable");else f=b;else throw Error(Rn+x+" not true or false: "+b);if(m.hasOwnProperty(x="MODULO_MODE")&&(b=m[x],Dt(b,0,9,x),p=b),m.hasOwnProperty(x="POW_PRECISION")&&(b=m[x],Dt(b,0,rn,x),g=b),m.hasOwnProperty(x="FORMAT"))if(b=m[x],typeof b=="object")S=b;else throw Error(Rn+x+" not an object: "+b);if(m.hasOwnProperty(x="ALPHABET"))if(b=m[x],typeof b=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(b))F=b.slice(0,10)=="0123456789",C=b;else throw Error(Rn+x+" invalid: "+b)}else throw Error(Rn+"Object expected: "+m);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:g,FORMAT:S,ALPHABET:C}},k.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!k.DEBUG)return!0;var x,b,E=m.c,h=m.e,T=m.s;e:if({}.toString.call(E)=="[object Array]"){if((T===1||T===-1)&&h>=-rn&&h<=rn&&h===ar(h)){if(E[0]===0){if(h===0&&E.length===1)return!0;break e}if(x=(h+1)%He,x<1&&(x+=He),String(E[0]).length==x){for(x=0;x<E.length;x++)if(b=E[x],b<0||b>=Sr||b!==ar(b))break e;if(b!==0)return!0}}}else if(E===null&&h===null&&(T===null||T===1||T===-1))return!0;throw Error(Rn+"Invalid BigNumber: "+m)},k.maximum=k.max=function(){return z(arguments,-1)},k.minimum=k.min=function(){return z(arguments,1)},k.random=(function(){var m=9007199254740992,x=Math.random()*m&2097151?function(){return ar(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(b){var E,h,T,I,v,A=0,P=[],D=new k(i);if(b==null?b=s:Dt(b,0,rn),I=zg(b/He),f)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(I*=2));A<I;)v=E[A]*131072+(E[A+1]>>>11),v>=9e15?(h=crypto.getRandomValues(new Uint32Array(2)),E[A]=h[0],E[A+1]=h[1]):(P.push(v%1e14),A+=2);A=I/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(I*=7);A<I;)v=(E[A]&31)*281474976710656+E[A+1]*1099511627776+E[A+2]*4294967296+E[A+3]*16777216+(E[A+4]<<16)+(E[A+5]<<8)+E[A+6],v>=9e15?crypto.randomBytes(7).copy(E,A):(P.push(v%1e14),A+=7);A=I/7}else throw f=!1,Error(Rn+"crypto unavailable");if(!f)for(;A<I;)v=x(),v<9e15&&(P[A++]=v%1e14);for(I=P[--A],b%=He,I&&b&&(v=Og[He-b],P[A]=ar(I/v)*v);P[A]===0;P.pop(),A--);if(A<0)P=[T=0];else{for(T=-1;P[0]===0;P.splice(0,1),T-=He);for(A=1,v=P[0];v>=10;v/=10,A++);A<He&&(T-=He-A)}return D.e=T,D.c=P,D}})(),k.sum=function(){for(var m=1,x=arguments,b=new k(x[0]);m<x.length;)b=b.plus(x[m++]);return b},n=(function(){var m="0123456789";function x(b,E,h,T){for(var I,v=[0],A,P=0,D=b.length;P<D;){for(A=v.length;A--;v[A]*=E);for(v[0]+=T.indexOf(b.charAt(P++)),I=0;I<v.length;I++)v[I]>h-1&&(v[I+1]==null&&(v[I+1]=0),v[I+1]+=v[I]/h|0,v[I]%=h)}return v.reverse()}return function(b,E,h,T,I){var v,A,P,D,N,w,j,G,L=b.indexOf("."),K=s,ee=a;for(L>=0&&(D=g,g=0,b=b.replace(".",""),G=new k(E),w=G.pow(b.length-L),g=D,G.c=x(Yr(sr(w.c),w.e,"0"),10,h,m),G.e=G.c.length),j=x(b,E,h,I?(v=C,m):(v=m,C)),P=D=j.length;j[--D]==0;j.pop());if(!j[0])return v.charAt(0);if(L<0?--P:(w.c=j,w.e=P,w.s=T,w=t(w,G,K,ee,h),j=w.c,N=w.r,P=w.e),A=P+K+1,L=j[A],D=h/2,N=N||A<0||j[A+1]!=null,N=ee<4?(L!=null||N)&&(ee==0||ee==(w.s<0?3:2)):L>D||L==D&&(ee==4||N||ee==6&&j[A-1]&1||ee==(w.s<0?8:7)),A<1||!j[0])b=N?Yr(v.charAt(1),-K,v.charAt(0)):v.charAt(0);else{if(j.length=A,N)for(--h;++j[--A]>h;)j[A]=0,A||(++P,j=[1].concat(j));for(D=j.length;!j[--D];);for(L=0,b="";L<=D;b+=v.charAt(j[L++]));b=Yr(b,P,v.charAt(0))}return b}})(),t=(function(){function m(E,h,T){var I,v,A,P,D=0,N=E.length,w=h%mo,j=h/mo|0;for(E=E.slice();N--;)A=E[N]%mo,P=E[N]/mo|0,I=j*A+P*w,v=w*A+I%mo*mo+D,D=(v/T|0)+(I/mo|0)+j*P,E[N]=v%T;return D&&(E=[D].concat(E)),E}function x(E,h,T,I){var v,A;if(T!=I)A=T>I?1:-1;else for(v=A=0;v<T;v++)if(E[v]!=h[v]){A=E[v]>h[v]?1:-1;break}return A}function b(E,h,T,I){for(var v=0;T--;)E[T]-=v,v=E[T]<h[T]?1:0,E[T]=v*I+E[T]-h[T];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,h,T,I,v){var A,P,D,N,w,j,G,L,K,ee,re,de,ae,qe,tt,se,pe,Ie=E.s==h.s?1:-1,ze=E.c,me=h.c;if(!ze||!ze[0]||!me||!me[0])return new k(!E.s||!h.s||(ze?me&&ze[0]==me[0]:!me)?NaN:ze&&ze[0]==0||!me?Ie*0:Ie/0);for(L=new k(Ie),K=L.c=[],P=E.e-h.e,Ie=T+P+1,v||(v=Sr,P=lr(E.e/He)-lr(h.e/He),Ie=Ie/He|0),D=0;me[D]==(ze[D]||0);D++);if(me[D]>(ze[D]||0)&&P--,Ie<0)K.push(1),N=!0;else{for(qe=ze.length,se=me.length,D=0,Ie+=2,w=ar(v/(me[0]+1)),w>1&&(me=m(me,w,v),ze=m(ze,w,v),se=me.length,qe=ze.length),ae=se,ee=ze.slice(0,se),re=ee.length;re<se;ee[re++]=0);pe=me.slice(),pe=[0].concat(pe),tt=me[0],me[1]>=v/2&&tt++;do{if(w=0,A=x(me,ee,se,re),A<0){if(de=ee[0],se!=re&&(de=de*v+(ee[1]||0)),w=ar(de/tt),w>1)for(w>=v&&(w=v-1),j=m(me,w,v),G=j.length,re=ee.length;x(j,ee,G,re)==1;)w--,b(j,se<G?pe:me,G,v),G=j.length,A=1;else w==0&&(A=w=1),j=me.slice(),G=j.length;if(G<re&&(j=[0].concat(j)),b(ee,j,re,v),re=ee.length,A==-1)for(;x(me,ee,se,re)<1;)w++,b(ee,se<re?pe:me,re,v),re=ee.length}else A===0&&(w++,ee=[0]);K[D++]=w,ee[0]?ee[re++]=ze[ae]||0:(ee=[ze[ae]],re=1)}while((ae++<qe||ee[0]!=null)&&Ie--);N=ee[0]!=null,K[0]||K.splice(0,1)}if(v==Sr){for(D=1,Ie=K[0];Ie>=10;Ie/=10,D++);M(L,T+(L.e=D+P*He-1)+1,I,N)}else L.e=P,L.r=+N;return L}})();function R(m,x,b,E){var h,T,I,v,A;if(b==null?b=a:Dt(b,0,8),!m.c)return m.toString();if(h=m.c[0],I=m.e,x==null)A=sr(m.c),A=E==1||E==2&&(I<=u||I>=c)?Ml(A,I):Yr(A,I,"0");else if(m=M(new k(m),x,b),T=m.e,A=sr(m.c),v=A.length,E==1||E==2&&(x<=T||T<=u)){for(;v<x;A+="0",v++);A=Ml(A,T)}else if(x-=I+(E===2&&T>I),A=Yr(A,T,"0"),T+1>v){if(--x>0)for(A+=".";x--;A+="0");}else if(x+=T-v,x>0)for(T+1==v&&(A+=".");x--;A+="0");return m.s<0&&h?"-"+A:A}function z(m,x){for(var b,E,h=1,T=new k(m[0]);h<m.length;h++)E=new k(m[h]),(!E.s||(b=jo(T,E))===x||b===0&&T.s===x)&&(T=E);return T}function _(m,x,b){for(var E=1,h=x.length;!x[--h];x.pop());for(h=x[0];h>=10;h/=10,E++);return(b=E+b*He-1)>d?m.c=m.e=null:b<l?m.c=[m.e=0]:(m.e=b,m.c=x),m}r=(function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,x=/^([^.]+)\.$/,b=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(T,I,v,A){var P,D=v?I:I.replace(h,"");if(E.test(D))T.s=isNaN(D)?null:D<0?-1:1;else{if(!v&&(D=D.replace(m,function(N,w,j){return P=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==P?w:N}),A&&(P=A,D=D.replace(x,"$1").replace(b,"0.$1")),I!=D))return new k(D,P);if(k.DEBUG)throw Error(Rn+"Not a"+(A?" base "+A:"")+" number: "+I);T.s=null}T.c=T.e=null}})();function M(m,x,b,E){var h,T,I,v,A,P,D,N=m.c,w=Og;if(N){e:{for(h=1,v=N[0];v>=10;v/=10,h++);if(T=x-h,T<0)T+=He,I=x,A=N[P=0],D=ar(A/w[h-I-1]%10);else if(P=zg((T+1)/He),P>=N.length)if(E){for(;N.length<=P;N.push(0));A=D=0,h=1,T%=He,I=T-He+1}else break e;else{for(A=v=N[P],h=1;v>=10;v/=10,h++);T%=He,I=T-He+h,D=I<0?0:ar(A/w[h-I-1]%10)}if(E=E||x<0||N[P+1]!=null||(I<0?A:A%w[h-I-1]),E=b<4?(D||E)&&(b==0||b==(m.s<0?3:2)):D>5||D==5&&(b==4||E||b==6&&(T>0?I>0?A/w[h-I]:0:N[P-1])%10&1||b==(m.s<0?8:7)),x<1||!N[0])return N.length=0,E?(x-=m.e+1,N[0]=w[(He-x%He)%He],m.e=-x||0):N[0]=m.e=0,m;if(T==0?(N.length=P,v=1,P--):(N.length=P+1,v=w[He-T],N[P]=I>0?ar(A/w[h-I]%w[I])*v:0),E)for(;;)if(P==0){for(T=1,I=N[0];I>=10;I/=10,T++);for(I=N[0]+=v,v=1;I>=10;I/=10,v++);T!=v&&(m.e++,N[0]==Sr&&(N[0]=1));break}else{if(N[P]+=v,N[P]!=Sr)break;N[P--]=0,v=1}for(T=N.length;N[--T]===0;N.pop());}m.e>d?m.c=m.e=null:m.e<l&&(m.c=[m.e=0])}return m}function B(m){var x,b=m.e;return b===null?m.toString():(x=sr(m.c),x=b<=u||b>=c?Ml(x,b):Yr(x,b,"0"),m.s<0?"-"+x:x)}return o.absoluteValue=o.abs=function(){var m=new k(this);return m.s<0&&(m.s=1),m},o.comparedTo=function(m,x){return jo(this,new k(m,x))},o.decimalPlaces=o.dp=function(m,x){var b,E,h,T=this;if(m!=null)return Dt(m,0,rn),x==null?x=a:Dt(x,0,8),M(new k(T),m+T.e+1,x);if(!(b=T.c))return null;if(E=((h=b.length-1)-lr(this.e/He))*He,h=b[h])for(;h%10==0;h/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(m,x){return t(this,new k(m,x),s,a)},o.dividedToIntegerBy=o.idiv=function(m,x){return t(this,new k(m,x),0,1)},o.exponentiatedBy=o.pow=function(m,x){var b,E,h,T,I,v,A,P,D,N=this;if(m=new k(m),m.c&&!m.isInteger())throw Error(Rn+"Exponent not an integer: "+B(m));if(x!=null&&(x=new k(x)),v=m.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!m.c||!m.c[0])return D=new k(Math.pow(+B(N),v?m.s*(2-Ll(m)):+B(m))),x?D.mod(x):D;if(A=m.s<0,x){if(x.c?!x.c[0]:!x.s)return new k(NaN);E=!A&&N.isInteger()&&x.isInteger(),E&&(N=N.mod(x))}else{if(m.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||v&&N.c[1]>=24e7:N.c[0]<8e13||v&&N.c[0]<=9999975e7)))return T=N.s<0&&Ll(m)?-0:0,N.e>-1&&(T=1/T),new k(A?1/T:T);g&&(T=zg(g/He+2))}for(v?(b=new k(.5),A&&(m.s=1),P=Ll(m)):(h=Math.abs(+B(m)),P=h%2),D=new k(i);;){if(P){if(D=D.times(N),!D.c)break;T?D.c.length>T&&(D.c.length=T):E&&(D=D.mod(x))}if(h){if(h=ar(h/2),h===0)break;P=h%2}else if(m=m.times(b),M(m,m.e+1,1),m.e>14)P=Ll(m);else{if(h=+B(m),h===0)break;P=h%2}N=N.times(N),T?N.c&&N.c.length>T&&(N.c.length=T):E&&(N=N.mod(x))}return E?D:(A&&(D=i.div(D)),x?D.mod(x):T?M(D,g,a,I):D)},o.integerValue=function(m){var x=new k(this);return m==null?m=a:Dt(m,0,8),M(x,x.e+1,m)},o.isEqualTo=o.eq=function(m,x){return jo(this,new k(m,x))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(m,x){return jo(this,new k(m,x))>0},o.isGreaterThanOrEqualTo=o.gte=function(m,x){return(x=jo(this,new k(m,x)))===1||x===0},o.isInteger=function(){return!!this.c&&lr(this.e/He)>this.c.length-2},o.isLessThan=o.lt=function(m,x){return jo(this,new k(m,x))<0},o.isLessThanOrEqualTo=o.lte=function(m,x){return(x=jo(this,new k(m,x)))===-1||x===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(m,x){var b,E,h,T,I=this,v=I.s;if(m=new k(m,x),x=m.s,!v||!x)return new k(NaN);if(v!=x)return m.s=-x,I.plus(m);var A=I.e/He,P=m.e/He,D=I.c,N=m.c;if(!A||!P){if(!D||!N)return D?(m.s=-x,m):new k(N?I:NaN);if(!D[0]||!N[0])return N[0]?(m.s=-x,m):new k(D[0]?I:a==3?-0:0)}if(A=lr(A),P=lr(P),D=D.slice(),v=A-P){for((T=v<0)?(v=-v,h=D):(P=A,h=N),h.reverse(),x=v;x--;h.push(0));h.reverse()}else for(E=(T=(v=D.length)<(x=N.length))?v:x,v=x=0;x<E;x++)if(D[x]!=N[x]){T=D[x]<N[x];break}if(T&&(h=D,D=N,N=h,m.s=-m.s),x=(E=N.length)-(b=D.length),x>0)for(;x--;D[b++]=0);for(x=Sr-1;E>v;){if(D[--E]<N[E]){for(b=E;b&&!D[--b];D[b]=x);--D[b],D[E]+=Sr}D[E]-=N[E]}for(;D[0]==0;D.splice(0,1),--P);return D[0]?_(m,D,P):(m.s=a==3?-1:1,m.c=[m.e=0],m)},o.modulo=o.mod=function(m,x){var b,E,h=this;return m=new k(m,x),!h.c||!m.s||m.c&&!m.c[0]?new k(NaN):!m.c||h.c&&!h.c[0]?new k(h):(p==9?(E=m.s,m.s=1,b=t(h,m,0,3),m.s=E,b.s*=E):b=t(h,m,0,p),m=h.minus(b.times(m)),!m.c[0]&&p==1&&(m.s=h.s),m)},o.multipliedBy=o.times=function(m,x){var b,E,h,T,I,v,A,P,D,N,w,j,G,L,K,ee=this,re=ee.c,de=(m=new k(m,x)).c;if(!re||!de||!re[0]||!de[0])return!ee.s||!m.s||re&&!re[0]&&!de||de&&!de[0]&&!re?m.c=m.e=m.s=null:(m.s*=ee.s,!re||!de?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(E=lr(ee.e/He)+lr(m.e/He),m.s*=ee.s,A=re.length,N=de.length,A<N&&(G=re,re=de,de=G,h=A,A=N,N=h),h=A+N,G=[];h--;G.push(0));for(L=Sr,K=mo,h=N;--h>=0;){for(b=0,w=de[h]%K,j=de[h]/K|0,I=A,T=h+I;T>h;)P=re[--I]%K,D=re[I]/K|0,v=j*P+D*w,P=w*P+v%K*K+G[T]+b,b=(P/L|0)+(v/K|0)+j*D,G[T--]=P%L;G[T]=b}return b?++E:G.splice(0,1),_(m,G,E)},o.negated=function(){var m=new k(this);return m.s=-m.s||null,m},o.plus=function(m,x){var b,E=this,h=E.s;if(m=new k(m,x),x=m.s,!h||!x)return new k(NaN);if(h!=x)return m.s=-x,E.minus(m);var T=E.e/He,I=m.e/He,v=E.c,A=m.c;if(!T||!I){if(!v||!A)return new k(h/0);if(!v[0]||!A[0])return A[0]?m:new k(v[0]?E:h*0)}if(T=lr(T),I=lr(I),v=v.slice(),h=T-I){for(h>0?(I=T,b=A):(h=-h,b=v),b.reverse();h--;b.push(0));b.reverse()}for(h=v.length,x=A.length,h-x<0&&(b=A,A=v,v=b,x=h),h=0;x;)h=(v[--x]=v[x]+A[x]+h)/Sr|0,v[x]=Sr===v[x]?0:v[x]%Sr;return h&&(v=[h].concat(v),++I),_(m,v,I)},o.precision=o.sd=function(m,x){var b,E,h,T=this;if(m!=null&&m!==!!m)return Dt(m,1,rn),x==null?x=a:Dt(x,0,8),M(new k(T),m,x);if(!(b=T.c))return null;if(h=b.length-1,E=h*He+1,h=b[h]){for(;h%10==0;h/=10,E--);for(h=b[0];h>=10;h/=10,E++);}return m&&T.e+1>E&&(E=T.e+1),E},o.shiftedBy=function(m){return Dt(m,-Ng,Ng),this.times("1e"+m)},o.squareRoot=o.sqrt=function(){var m,x,b,E,h,T=this,I=T.c,v=T.s,A=T.e,P=s+4,D=new k("0.5");if(v!==1||!I||!I[0])return new k(!v||v<0&&(!I||I[0])?NaN:I?T:1/0);if(v=Math.sqrt(+B(T)),v==0||v==1/0?(x=sr(I),(x.length+A)%2==0&&(x+="0"),v=Math.sqrt(+x),A=lr((A+1)/2)-(A<0||A%2),v==1/0?x="5e"+A:(x=v.toExponential(),x=x.slice(0,x.indexOf("e")+1)+A),b=new k(x)):b=new k(v+""),b.c[0]){for(A=b.e,v=A+P,v<3&&(v=0);;)if(h=b,b=D.times(h.plus(t(T,h,P,1))),sr(h.c).slice(0,v)===(x=sr(b.c)).slice(0,v))if(b.e<A&&--v,x=x.slice(v-3,v+1),x=="9999"||!E&&x=="4999"){if(!E&&(M(h,h.e+s+2,0),h.times(h).eq(T))){b=h;break}P+=4,v+=4,E=1}else{(!+x||!+x.slice(1)&&x.charAt(0)=="5")&&(M(b,b.e+s+2,1),m=!b.times(b).eq(T));break}}return M(b,b.e+s+1,a,m)},o.toExponential=function(m,x){return m!=null&&(Dt(m,0,rn),m++),R(this,m,x,1)},o.toFixed=function(m,x){return m!=null&&(Dt(m,0,rn),m=m+this.e+1),R(this,m,x)},o.toFormat=function(m,x,b){var E,h=this;if(b==null)m!=null&&x&&typeof x=="object"?(b=x,x=null):m&&typeof m=="object"?(b=m,m=x=null):b=S;else if(typeof b!="object")throw Error(Rn+"Argument not an object: "+b);if(E=h.toFixed(m,x),h.c){var T,I=E.split("."),v=+b.groupSize,A=+b.secondaryGroupSize,P=b.groupSeparator||"",D=I[0],N=I[1],w=h.s<0,j=w?D.slice(1):D,G=j.length;if(A&&(T=v,v=A,A=T,G-=T),v>0&&G>0){for(T=G%v||v,D=j.substr(0,T);T<G;T+=v)D+=P+j.substr(T,v);A>0&&(D+=P+j.slice(T)),w&&(D="-"+D)}E=N?D+(b.decimalSeparator||"")+((A=+b.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(b.fractionGroupSeparator||"")):N):D}return(b.prefix||"")+E+(b.suffix||"")},o.toFraction=function(m){var x,b,E,h,T,I,v,A,P,D,N,w,j=this,G=j.c;if(m!=null&&(v=new k(m),!v.isInteger()&&(v.c||v.s!==1)||v.lt(i)))throw Error(Rn+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+B(v));if(!G)return new k(j);for(x=new k(i),P=b=new k(i),E=A=new k(i),w=sr(G),T=x.e=w.length-j.e-1,x.c[0]=Og[(I=T%He)<0?He+I:I],m=!m||v.comparedTo(x)>0?T>0?x:P:v,I=d,d=1/0,v=new k(w),A.c[0]=0;D=t(v,x,0,1),h=b.plus(D.times(E)),h.comparedTo(m)!=1;)b=E,E=h,P=A.plus(D.times(h=P)),A=h,x=v.minus(D.times(h=x)),v=h;return h=t(m.minus(b),E,0,1),A=A.plus(h.times(P)),b=b.plus(h.times(E)),A.s=P.s=j.s,T=T*2,N=t(P,E,T,a).minus(j).abs().comparedTo(t(A,b,T,a).minus(j).abs())<1?[P,E]:[A,b],d=I,N},o.toNumber=function(){return+B(this)},o.toPrecision=function(m,x){return m!=null&&Dt(m,1,rn),R(this,m,x,2)},o.toString=function(m){var x,b=this,E=b.s,h=b.e;return h===null?E?(x="Infinity",E<0&&(x="-"+x)):x="NaN":(m==null?x=h<=u||h>=c?Ml(sr(b.c),h):Yr(sr(b.c),h,"0"):m===10&&F?(b=M(new k(b),s+h+1,a),x=Yr(sr(b.c),b.e,"0")):(Dt(m,2,C.length,"Base"),x=n(Yr(sr(b.c),h,"0"),10,m,E,!0)),E<0&&b.c[0]&&(x="-"+x)),x},o.valueOf=o.toJSON=function(){return B(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&k.set(e),k}function lr(e){var t=e|0;return e>0||e===t?t:t-1}function sr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=He-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function jo(e,t){var n,r,o=e.c,i=t.c,s=e.s,a=t.s,u=e.e,c=t.e;if(!s||!a)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=u==c,!o||!i)return r?0:!o^n?1:-1;if(!r)return u>c^n?1:-1;for(a=(u=o.length)<(c=i.length)?u:c,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^n?1:-1;return u==c?0:u>c^n?1:-1}function Dt(e,t,n,r){if(e<t||e>n||e!==ar(e))throw Error(Rn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Ll(e){var t=e.c.length-1;return lr(e.e/He)==t&&e.c[t]%2!=0}function Ml(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Yr(e,t,n){var r,o;if(t<0){for(o=n+".";++t;o+=n);e=o+e}else if(r=e.length,++t>r){for(o=n,t-=r;--t;o+=n);e+=o}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var zR=Qw(),Jw=zR;var NR=24,js=32,OR=()=>typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"?()=>{let e=new Uint32Array(1);return globalThis.crypto.getRandomValues(e),e[0]/4294967296}:Math.random,$g=OR(),_g=(e=4,t=$g)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function _R(e){let t=new Jw(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var ev=(e="")=>{let t=new TextEncoder;return _R(Kw(t.encode(e))).toString(36).slice(1)},Zw=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),$R=e=>Zw[Math.floor(e()*Zw.length)],UR=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=$g}={})=>{let n=Object.keys(e).toString(),r=n.length?n+_g(js,t):_g(js,t);return ev(r).substring(0,js)},jR=e=>()=>e++,HR=476782367,tv=({random:e=$g,counter:t=jR(Math.floor(e()*HR)),length:n=NR,fingerprint:r=UR({random:e})}={})=>{if(n>js)throw new Error(`Length must be between 2 and ${js}. Received: ${n}`);return function(){let i=$R(e),s=Date.now().toString(36),a=t().toString(36),u=_g(n,e),c=`${s+u+a+r}`;return`${i+ev(c).substring(1,n)}`}},ho=WR(tv);function WR(e){let t;return()=>(t||(t=e()),t())}var qR=Aa(ov());Ls();De();var Bl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function YR(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function Ug(e,t){let n=[],r=e.split(`
15
- `);for(let s=0;s<r.length;s++){let a=YR(r[s]),u=Bl.exec(a);if(u){let[,c,l,,d]=u,f=KR(l),p=XR(r,s+1),g={id:ho(),reviewId:t,type:c.trim(),severity:f,title:d.trim(),description:p.description,file:p.file,lineNumber:p.lineNumber,property:p.property,currentValue:p.currentValue,suggestedValue:p.suggestedValue,suggestedCode:p.suggestedCode,suggestedFix:p.suggestedFix,fixTarget:p.fixTarget,fixRequired:p.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(g)}Bl.lastIndex=0}return n.map(s=>{let a=Ps(s);return a.dismissed?(y.debug(`[parseIssues] Auto-dismissed: ${s.title} - ${a.dismissReason}`),{...s,dismissed:!0,dismissReason:a.dismissReason,dismissedBy:a.dismissedBy,dismissedAt:new Date}):s})}function KR(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function XR(e,t){let n={description:"",file:void 0,lineNumber:void 0,property:void 0,currentValue:void 0,suggestedValue:void 0,suggestedCode:void 0,suggestedFix:void 0,fixTarget:void 0,fixRequired:void 0},r=[];for(let o=t;o<e.length;o++){let i=e[o].trim();if(!i||Bl.test(i)){Bl.lastIndex=0;break}if(i.startsWith("Expected:"))n.suggestedValue=i.replace("Expected:","").trim();else if(i.startsWith("Actual:")||i.startsWith("Current:"))n.currentValue=i.replace(/^(Actual|Current):/,"").trim();else if(i.startsWith("File:")){let s=i.replace("File:","").trim(),a=s.match(/^(.+?):(\d+)$/);a?(n.file=a[1],n.lineNumber=parseInt(a[2],10)):n.file=s}else if(i.startsWith("Property:"))n.property=i.replace("Property:","").trim();else if(i.startsWith("FixTarget:")){let s=i.replace("FixTarget:","").trim().toLowerCase();(s==="css"||s==="component")&&(n.fixTarget=s)}else if(i.startsWith("FixRequired:")){let s=i.replace("FixRequired:","").trim().toLowerCase();n.fixRequired=s==="true"}else if(i.startsWith("Fix:"))n.suggestedFix=i.replace("Fix:","").trim();else if(i.startsWith("```")){let s=[];for(o++;o<e.length&&!e[o].trim().startsWith("```");)s.push(e[o]),o++;n.suggestedCode=s.join(`
16
- `)}else r.push(i)}return n.description=r.join(" ").trim(),n}De();var Hs=null,iv=0,QR=3e4;async function JR(){let e=Date.now();if(Hs&&e-iv<QR)return Hs;try{let t=await fetch("/index.json");if(!t.ok)throw new Error(`Failed to fetch index.json: ${t.status}`);let n=await t.json();return Hs=n.entries||n.stories||{},iv=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Hs).length),Hs}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ws(e){try{let n=(await JR())[e];if(!n?.importPath)return y.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;y.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),y.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,y.debug("[storyFilePaths] Derived componentFile:",i));let s=i.replace(/\.tsx$/,".css").replace(/\.ts$/,".css").replace(/\.jsx$/,".css").replace(/\.js$/,".css"),a=i.substring(0,i.lastIndexOf("/")),u={storyFile:o,componentFile:i,cssFile:s,baseDir:a};return y.debug("[storyFilePaths] Final paths:",u),u}catch(t){return y.error("[storyFilePaths] Error getting file paths:",t),null}}function jg(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function ZR(e,t){let n=e.toLowerCase().trim();return["color","spacing","typography","dimension","border","shadow","layout","background","font","size","margin","padding"].some(i=>n.includes(i))?t.cssFile:t.componentFile}function Hg(e,t){let n=e.property?.toLowerCase()||"",r=e.domElement?.toLowerCase()||"",o=r.startsWith("svg"),i=r.startsWith("img"),s=n==="width"||n==="height",a=/\[(?:width|height)=/.test(r);return(o||i)&&s||a?(y.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):ZR(e.type,t)}De();function ez(e){let t=(e.description||"").toLowerCase(),n=(e.title||"").toLowerCase(),r=`${t} ${n}`;return r.includes("inner icon")||r.includes("inner vector")?"inner-icon":r.includes("second icon")?"icon-2":r.includes("first icon")?"icon-1":r.includes("icon")||r.includes("vector")||r.includes("svg")?"icon":r.includes("button")?"button":r.includes("text")||r.includes("label")?"text":r.includes("container")||r.includes("wrapper")?"container":"other"}function tz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("width")||t.includes("height")||t.includes("size")||t.includes("dimensions")?"dimensions":t.includes("padding")||t.includes("margin")||t.includes("gap")?"spacing":t.includes("color")||t.includes("background")||t.includes("fill")?"colors":t.includes("font")||t.includes("text")||t.includes("line-height")?"typography":t.includes("border")||t.includes("radius")?"border":n.includes("overall")||n.includes("visual fidelity")||n.includes("pixel similarity")||t.includes("overall")?"summary":"other"}function nz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("overall")||t.includes("visual fidelity")||n.includes("pixel similarity score")||n.includes("primarily explained by")||n.includes("visual discrepancy")}function rz(e,t,n){let r={critical:3,major:2,minor:1},i=[...e].sort((c,l)=>(r[l.severity]||0)-(r[c.severity]||0))[0],s=e.length,a,u;if(t.includes("icon")&&n==="dimensions"){let c=e.map(d=>d.currentValue).filter(Boolean),l=e.map(d=>d.suggestedValue).filter(Boolean);a=`Icon sizing is incorrect (${s} related issues)`,u=`Icons are rendered at wrong dimensions. Current: ${c[0]||"10px"}, Expected: ${l[0]||"20px"}. This single CSS fix will resolve all ${s} icon dimension issues.`}else a=`${t} ${n} issues (${s} related)`,u=`${s} related ${n} issues for ${t}. ${i.description}`;return{...i,id:`merged-${t}-${n}-${i.id}`,title:a,description:u,currentValue:i.currentValue,suggestedValue:i.suggestedValue,mergedCount:s,mergedIssueIds:e.map(c=>c.id)}}function Wg(e){if(!e||e.length===0)return[];let t=e.filter(i=>!nz(i)),n=[],r=[];for(let i of t){let s=ez(i),a=tz(i);s.includes("icon")&&a==="dimensions"?n.push(i):r.push(i)}let o=[];return n.length>0&&(n.length===1?o.push(n[0]):o.push(rz(n,"icon","dimensions"))),o.push(...r),y.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),y.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),y.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}De();je();import{addons as Dl}from"storybook/manager-api";var Vg="uireview/badge",Ii={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function oz(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function iz(e){let t=[`Score: ${e.score}`];return e.criticalCount>0&&t.push(`${e.criticalCount} critical`),e.majorCount>0&&t.push(`${e.majorCount} major`),e.minorCount>0&&t.push(`${e.minorCount} minor`),t.join(" \xB7 ")}function sz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Fi(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function av(e){if(Fi())try{Dl.getChannel().emit(Ii.REVIEW_START,{storyId:e})}catch{}}function xo(e,t){if(Fi())try{Dl.getChannel().emit(Ii.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function lv(e){if(Fi())try{Dl.getChannel().emit(Ii.REVIEW_ERROR,{storyId:e})}catch{}}function sv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}function cv(e){let t=Dl.getChannel(),n=o=>i=>{Fi()&&o(i)};t.on(Ii.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:Vg,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(Ii.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:oz(i),typeId:Vg,storyId:o,title:sz(i),description:iz(i)}])})),t.on(Ii.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:Vg,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Fi();r||sv(e),setInterval(()=>{let o=Fi();o!==r&&(r=o,o||sv(e))},1500)}var Gg=q(),qg=180;function yo(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="object"){let t=e;if("value"in t&&typeof t.value=="string")return t.value;if("top"in t||"left"in t){let n=[t.top,t.right,t.bottom,t.left].filter(Boolean);if(n.length>0)return n.join(" ")}return JSON.stringify(e)}return String(e)}var Yg=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:d,setReviewError:f,setReviewResults:p,setShowReviewMenu:g,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:_,setStreamingStatus:M,setFullPrompt:B,setFullResponse:m,setFigmaImageUrl:x,storybookImageUrl:b,setStorybookImageUrl:E,setFigmaDimensions:h,setMultiModelResults:T,updateMultiModelStreamingMessages:I,setModelCompleted:v,setActiveModelId:A,resetReview:P,addReview:D,setReviewDetailTab:N,includeTextComparison:w,usePromptCache:j,setApplyFixesResult:G,featureFlags:L}=ie(),{sessionToken:K,usageData:ee,setUsageData:re}=we(),{selectedProjectId:de}=Ze(),{currentStoryId:ae,currentStoryName:qe}=rt(),tt=Rl(ee);tt.current=ee;let se=Rl(null),pe=Rl(null),Ie=Rl({}),ze=Vs((Ge,lt)=>{k({role:Ge,content:lt})},[k]),me=Vs((Ge,lt)=>{_(Ge),M(lt)},[_,M]),Nt=Vs(async Ge=>{let{isIteration:lt=!1,parentReviewId:nt=null}=Ge||{};if(!K)throw new Error("Not authenticated");if(!de)throw new Error("No project selected");if(!ae||!qe)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let ne=Date.now();try{d(!0),f(null),p(null),N("issues"),G(null),ae&&L.enableReviewBadges&&av(ae),pe.current&&clearTimeout(pe.current),pe.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${qg}s timeout`),se.current&&se.current.abort(),k({role:"system",content:`Review auto-stopped after ${qg} seconds timeout.`})},qg*1e3),B(""),m(""),C(!0),F(!1),z(),me(0,"Starting review..."),me(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await El(),y.debug("[Review] Iframe reloaded, styles should be fresh"),me(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[W,Ae,ge]=await Promise.all([Il({sessionToken:K||void 0}),Promise.resolve($s()),Promise.resolve(Ag())]);if(W&&W!==b&&(E(W),y.debug("[Review] Storybook screenshot captured and set")),!Ae)throw new Error("Failed to extract styles from component");let{computed:O,declared:U,markup:H,textElementStyles:Pe,nestedElementStyles:Ne}=Ae;ge?y.debug("[Review] DOM tree extracted:",{selector:ge.selector,childrenCount:ge.children.length}):(y.error("[Review] DOM tree extraction FAILED - domTree is null"),y.error("[Review] This will cause AI to use comparison table instead of tree comparison")),me(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:ae,name:qe});let yt=ht.getState().currentMapping?.figmaNodeId??null,Un=ht.getState().figmaImageUrl;if(yt&&(y.debug("[Review] Using Figma node ID from store:",yt),Un&&(me(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!yt)try{let Xe=await fetch(`${Gg}/api/mappings?projectId=${de}&storyId=${ae}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`}});if(Xe.ok){let Bt=await Xe.json();Bt.mapping?.figmaNodeId?(yt=Bt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",yt)):y.debug("[Review] No mapping found for story:",ae)}else y.debug("[Review] Failed to fetch mapping:",Xe.status)}catch(Xe){y.error("[Review] Error fetching mapping:",Xe)}if(yt&&!Un){me(65,"Fetching Figma design...");try{let Xe=await fetch(`${Gg}/api/figma/frames?projectId=${de}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`}});if(Xe.ok){let Ot=(await Xe.json()).thumbnails?.[yt];Ot?(x(Ot),y.debug("[Review] Figma thumbnail fetched and displayed:",Ot)):y.warn("[Review] No thumbnail found for node:",yt)}else y.warn("[Review] Failed to fetch Figma frames:",Xe.status)}catch(Xe){y.error("[Review] Error fetching Figma frames:",Xe)}}if(!yt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');me(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let Qn={projectId:de,storyId:ae,storyName:qe,storybookScreenshot:W,computedStyles:O,declaredStyles:U,textElementStyles:Pe,nestedElementStyles:Ne,componentMarkup:H,domTree:ge,figmaNodeId:yt,figmaImageUrl:Un||void 0,aiModels:l,includeTextComparison:w,usePromptCache:j,parentReviewId:lt?nt:void 0,isIteration:lt};y.debug("[Review] Request payload:",{...Qn,storybookScreenshot:W?`${W.substring(0,50)}...`:null,domTree:ge?{selector:ge.selector,childrenCount:ge.children.length}:null}),se.current=new AbortController;let In=await fetch(`${Gg}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`},body:JSON.stringify(Qn),signal:se.current.signal});if(y.debug("[Review] Response status:",In.status,In.statusText),!In.ok){let Xe=await In.json();if(y.error("[Review] API error response:",Xe),In.status===429){let Bt=Xe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Bt} seconds before trying again.`)}if(In.status===402){if(Xe.code==="INSUFFICIENT_CREDITS"){let Bt=Xe.details?.required??1,Ot=Xe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Bt} credit(s) but you have ${Ot}. Visit Settings to add more.`)}throw Xe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Xe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Xe.message||"Payment required")}throw In.status===401&&Xe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Xe.error||Xe.message||"Review request failed")}let oo=In.body?.getReader(),bn=new TextDecoder,Ir="",en="",Oe=null,qc=null,$x=l.length>1,Bo={},Zi={},L8={};if(!oo)throw new Error("Response body is not readable");let Ux=ht.getState().streamingMessages.length;for(ze("assistant","");;){let{done:Xe,value:Bt}=await oo.read();if(Xe)break;Ir+=bn.decode(Bt,{stream:!0});let Ot=Ir.split(`
17
- `);Ir=Ot.pop()||"";for(let jn of Ot)if(jn.startsWith("data: ")){let ln=jn.slice(6);if(ln==="[DONE]")continue;try{let te=JSON.parse(ln);if(te.type!=="text"&&te.type!=="content"&&y.debug("[Review] SSE Event received:",te.type),te.type==="prompt")te.prompt&&(B(te.prompt),y.debug("[Review] Prompt received early"));else if(te.type==="model_started")y.debug("[Review] Model started:",te.modelId),Bo[te.modelId]||(Bo[te.modelId]="",Zi[te.modelId]=[{role:"assistant",content:""}]);else if(te.type==="text"||te.type==="content")if($x&&te.modelId){Bo[te.modelId]||(Bo[te.modelId]="",Zi[te.modelId]=[{role:"assistant",content:""}]),Bo[te.modelId]+=te.content,Zi[te.modelId][0].content=Bo[te.modelId],I(te.modelId,Zi[te.modelId]);let Gt=Object.entries(Bo).map(([cn,st])=>`[${cn}]
12
+ --`+new Array((n||t.length)+1).join("-")+"^"})}var Cb=$(()=>{"use strict";Ka()});var vA,kA,CA,TA,IA,Tb,pl,Ib=$(()=>{"use strict";Cb();vA=9,kA=10,CA=12,TA=13,IA=32,Tb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),pl=class{constructor(t){this.str=t,this.pos=0}charCodeAt(t){return t<this.str.length?this.str.charCodeAt(t):0}charCode(){return this.charCodeAt(this.pos)}isNameCharCode(t=this.charCode()){return t<128&&Tb[t]===1}nextCharCode(){return this.charCodeAt(this.pos+1)}nextNonWsCode(t){return this.charCodeAt(this.findWsEnd(t))}skipWs(){this.pos=this.findWsEnd(this.pos)}findWsEnd(t){for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n!==TA&&n!==kA&&n!==CA&&n!==IA&&n!==vA)break}return t}substringToPos(t){return this.str.substring(this.pos,this.pos=t)}eat(t){this.charCode()!==t&&this.error("Expect `"+String.fromCharCode(t)+"`"),this.pos++}peek(){return this.pos<this.str.length?this.str.charAt(this.pos++):""}error(t){throw new kb(t,this.str,this.pos)}scanSpaces(){return this.substringToPos(this.findWsEnd(this.pos))}scanWord(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n>=128||Tb[n]===0)break}return this.pos===t&&this.error("Expect a keyword"),this.substringToPos(t)}scanNumber(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n<48||n>57)break}return this.pos===t&&this.error("Expect a number"),this.substringToPos(t)}scanString(){let t=this.str.indexOf("'",this.pos+1);return t===-1&&(this.pos=this.str.length,this.error("Expect an apostrophe")),this.substringToPos(t+1)}}});function Mb(e){let t=null,n=null;return e.eat(gl),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===Yu?(e.pos++,e.skipWs(),e.charCode()!==Vu&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(Vu),{min:Number(t),max:n?Number(n):0}}function BA(e){let t=null,n=!1;switch(e.charCode()){case zb:e.pos++,t={min:0,max:0};break;case qu:e.pos++,t={min:1,max:0};break;case fl:e.pos++,t={min:0,max:1};break;case Gu:e.pos++,n=!0,e.charCode()===gl?t=Mb(e):e.charCode()===fl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case gl:t=Mb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Gr(e,t){let n=BA(e);return n!==null?(n.term=t,e.charCode()===Gu&&e.charCodeAt(e.pos-1)===qu||e.charCode()===fl&&e.charCodeAt(e.pos-1)===Vu?Gr(e,n):n):t}function Hu(e){let t=e.peek();return t===""?null:Gr(e,{type:"Token",value:t})}function DA(e){let t;return e.eat(Ku),e.eat(dl),t=e.scanWord(),e.eat(dl),e.eat(Wu),Gr(e,{type:"Property",name:t})}function RA(e){let t=null,n=null,r=1;return e.eat(bs),e.charCode()===Eb&&(e.peek(),r=-1),r==-1&&e.charCode()===Pb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Yu),e.skipWs(),e.charCode()===Pb?e.peek():(r=1,e.charCode()===Eb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(hi),{type:"Range",min:t,max:n}}function zA(e){let t,n=null;if(e.eat(Ku),t=e.scanWord(),t==="boolean-expr"){e.eat(bs);let r=ml(e,hi);return e.eat(hi),e.eat(Wu),Gr(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Db&&e.nextCharCode()===Rb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===bs&&(e.skipWs(),n=RA(e)),e.eat(Wu),Gr(e,{type:"Type",name:t,opts:n})}function NA(e){let t=e.scanWord();return e.charCode()===Db?(e.pos++,{type:"Function",name:t}):Gr(e,{type:"Keyword",name:t})}function OA(e,t){function n(o,i){return{type:"Group",terms:o,combinator:i,disallowEmpty:!1,explicit:!1}}let r;for(t=Object.keys(t).sort((o,i)=>Lb[o]-Lb[i]);t.length>0;){r=t.shift();let o=0,i=0;for(;o<e.length;o++){let s=e[o];s.type==="Combinator"&&(s.value===r?(i===-1&&(i=o-1),e.splice(o,1),o--):(i!==-1&&o-i>1&&(e.splice(i,o-i,n(e.slice(i,o),r)),o=i+1),i=-1))}i!==-1&&t.length&&e.splice(i,o-i,n(e.slice(i,o),r))}return r}function ml(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?ml(e,Rb):$A(e);if(!a)break;if(a.type!=="Spaces"){if(s){if(a.terms.length===0){s=!1;continue}if(a.combinator===" "){for(;a.terms.length>1;)n[" "]=!0,r.push({type:"Combinator",value:" "},a.terms.shift());a=a.terms[0]}}a.type==="Combinator"?((o===null||o.type==="Combinator")&&(e.pos=i,e.error("Unexpected combinator")),n[a.value]=!0):o!==null&&o.type!=="Combinator"&&(n[" "]=!0,r.push({type:"Combinator",value:" "})),r.push(a),o=a,i=e.pos,s=a.type==="Function"}}return o!==null&&o.type==="Combinator"&&(e.pos-=i,e.error("Unexpected combinator")),{type:"Group",terms:r,combinator:OA(r,n)||" ",disallowEmpty:!1,explicit:!1}}function _A(e){let t;return e.eat(bs),t=ml(e,hi),e.eat(hi),t.explicit=!0,e.charCode()===Bb&&(e.pos++,t.disallowEmpty=!0),t}function $A(e){let t=e.charCode();switch(t){case hi:break;case bs:return Gr(e,_A(e));case Ku:return e.nextCharCode()===dl?DA(e):zA(e);case Ab:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Ab?2:1))};case Fb:return e.pos++,e.eat(Fb),{type:"Combinator",value:"&&"};case Yu:return e.pos++,{type:"Comma"};case dl:return Gr(e,{type:"String",value:e.scanString()});case LA:case FA:case EA:case PA:case AA:return{type:"Spaces",value:e.scanSpaces()};case MA:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):Hu(e);case zb:case qu:case fl:case Gu:case Bb:break;case gl:if(t=e.nextCharCode(),t<48||t>57)return Hu(e);break;default:return e.isNameCharCode(t)?NA(e):Hu(e)}}function Ss(e){let t=new pl(e),n=ml(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var FA,EA,AA,PA,LA,Bb,Gu,Fb,dl,Db,Rb,zb,qu,Yu,Eb,Ku,Wu,fl,MA,bs,hi,gl,Ab,Vu,Pb,Lb,Xu=$(()=>{"use strict";Ib();FA=9,EA=10,AA=12,PA=13,LA=32,Bb=33,Gu=35,Fb=38,dl=39,Db=40,Rb=41,zb=42,qu=43,Yu=44,Eb=45,Ku=60,Wu=62,fl=63,MA=64,bs=91,hi=93,gl=123,Ab=124,Vu=125,Pb=8734,Lb={" ":1,"&&":2,"||":3,"|":4}});function Nb(e){return typeof e=="function"?e:ws}function Qu(e,t,n){function r(s){switch(o.call(n,s),s.type){case"Group":s.terms.forEach(r);break;case"Multiplier":case"Boolean":r(s.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+s.type)}i.call(n,s)}let o=ws,i=ws;if(typeof t=="function"?o=t:t&&(o=Nb(t.enter),i=Nb(t.leave)),o===ws&&i===ws)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var ws,Ob=$(()=>{"use strict";ws=function(){}});var Ju=$(()=>{"use strict";Au();Xu();Ob()});function HA(e){let t=[];return lo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function _b(e,t){return typeof e=="string"?HA(e):t.generate(e,jA)}var jA,$b=$(()=>{"use strict";nr();jA={decorator(e){let t=[],n=null;return{...e,node(r){let o=n;n=r,e.node.call(this,r),n=o},emit(r,o,i){t.push({type:o,value:r,node:i?null:n})},result(){return t}}}}});function xn(e,t,n){return t===ut&&n===yt||e===ut&&t===ut&&n===ut?e:(e.type==="If"&&e.else===yt&&t===ut&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function jb(e){return e.length>2&&e.charCodeAt(e.length-2)===WA&&e.charCodeAt(e.length-1)===VA}function Ub(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&jb(e.name)}function uo(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function vs(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=vs(e.match,t,n),e.then=vs(e.then,t,n),e.else=vs(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function Zu(e,t,n){switch(e){case" ":{let r=ut;for(let o=t.length-1;o>=0;o--){let i=t[o];r=xn(i,r,yt)}return r}case"|":{let r=yt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(Ub(s)&&(o===null&&i>0&&Ub(t[i-1])&&(o=Object.create(null),r=xn({type:"Enum",map:o},ut,r)),o!==null)){let a=(jb(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=xn(s,ut,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=yt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Zu(e,t.filter(function(a){return a!==i}),!1):s=ut,r=xn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?ut:yt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Zu(e,t.filter(function(a){return a!==i}),!0):s=ut,r=xn(i,s,r)}return r}}}function GA(e){let t=ut,n=xi(e.term);if(e.max===0)n=xn(n,hl,yt),t=xn(n,null,yt),t.then=xn(ut,ut,t),e.comma&&(t.then.else=xn({type:"Comma",syntax:e},t,yt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,yt)),t=xn(n,xn(ut,ut,t),yt);if(e.min===0)t=xn(ut,ut,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==ut&&(t=xn({type:"Comma",syntax:e},t,yt)),t=xn(n,t,yt);return t}function xi(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=Zu(e.combinator,e.terms.map(xi),!1);return e.disallowEmpty&&(t=xn(t,hl,yt)),t}case"Multiplier":return GA(e);case"Boolean":{let t=xi(e.term),n=xi(uo([uo([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),uo([{type:"Type",name:"!boolean-group"},uo([{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:uo([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=xi(uo([{type:"Type",name:"!term"},uo([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return vs(r,{"!term":t,"!self":n}),vs(n,{"!boolean-group":r}),n}case"Type":case"Property":return{type:e.type,name:e.name,syntax:e};case"Keyword":return{type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return{type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return{type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return e.value.length===3?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return{type:e.type,value:e.value,syntax:e};case"Comma":return{type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}function ks(e,t){return typeof e=="string"&&(e=Ss(e)),{type:"MatchGraph",match:xi(e),syntax:t||null,source:e}}var ut,yt,hl,WA,VA,ep=$(()=>{"use strict";Xu();ut={type:"Match"},yt={type:"Mismatch"},hl={type:"DisallowEmpty"},WA=40,VA=41});function JA(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function tp(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=t.charCodeAt(n),o=e.charCodeAt(n);if(o>=65&&o<=90&&(o=o|32),o!==r)return!1}return!0}function ZA(e){return e.type!==9?!1:e.value!=="?"}function Gb(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||ZA(e)}function qb(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function eP(e,t,n){function r(){do k++,F=k<e.length?e[k]:null;while(F!==null&&(F.type===13||F.type===25))}function o(_){let M=k+_;return M<e.length?e[M]:null}function i(_,M){return{nextState:_,matchStack:z,syntaxStack:d,thenStack:f,tokenIndex:k,prev:M}}function s(_){f={nextState:_,matchStack:z,syntaxStack:d,prev:f}}function a(_){p=i(_,p)}function u(){z={type:YA,syntax:t.syntax,token:F,prev:z},r(),g=null,k>R&&(R=k)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},z={type:np,syntax:t.syntax,token:z.token,prev:z}}function l(){z.type===np?z=z.prev:z={type:Yb,syntax:d.syntax,token:z.token,prev:z},d=d.prev}let d=null,f=null,p=null,g=null,S=0,C=null,F=null,k=-1,R=0,z={type:qA,syntax:null,token:null,prev:null};for(r();C===null&&++S<Vb;)switch(t.type){case"Match":if(f===null){if(F!==null&&(k!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=yt;break}C=Wb;break}if(t=f.nextState,t===hl)if(f.matchStack===z){t=yt;break}else t=ut;for(;f.syntaxStack!==d;)l();f=f.prev;break;case"Mismatch":if(g!==null&&g!==!1)(p===null||k>p.tokenIndex)&&(p=g,g=!1);else if(p===null){C=KA;break}t=p.nextState,f=p.thenStack,d=p.syntaxStack,z=p.matchStack,k=p.tokenIndex,F=k<e.length?e[k]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==yt&&a(t.else),t.then!==ut&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let B=t.syntax.terms;if(t.index===B.length){if(t.mask===0||t.syntax.all){t=yt;break}t=ut;break}if(t.mask===(1<<B.length)-1){t=ut;break}for(;t.index<B.length;t.index++){let m=1<<t.index;if((t.mask&m)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|m}),t=B[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let B=F.value.toLowerCase();if(B.indexOf("\\")!==-1&&(B=B.replace(/\\[09].*$/,"")),Hb.call(t.map,B)){t=t.map[B];break}}t=yt;break;case"Generic":{let B=d!==null?d.opts:null,m=k+Math.floor(t.fn(F,o,B));if(!isNaN(m)&&m>k){for(;k<m;)u();t=ut}else t=yt;break}case"Type":case"Property":{let B=t.type==="Type"?"types":"properties",m=Hb.call(n,B)?n[B][t.name]:null;if(!m||!m.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(g!==!1&&F!==null&&t.type==="Type"&&(t.name==="custom-ident"&&F.type===1||t.name==="length"&&F.value==="0")){g===null&&(g=i(t,p)),t=yt;break}c(),t=m.matchRef||m.match;break}case"Keyword":{let B=t.name;if(F!==null){let m=F.value;if(m.indexOf("\\")!==-1&&(m=m.replace(/\\[09].*$/,"")),tp(m,B)){u(),t=ut;break}}t=yt;break}case"AtKeyword":case"Function":if(F!==null&&tp(F.value,t.name)){u(),t=ut;break}t=yt;break;case"Token":if(F!==null&&F.value===t.value){u(),t=ut;break}t=yt;break;case"Comma":F!==null&&F.type===18?Gb(z.token)?t=yt:(u(),t=qb(F)?yt:ut):t=Gb(z.token)||qb(F)?ut:yt;break;case"String":let _="",M=k;for(;M<e.length&&_.length<t.value.length;M++)_+=e[M].value;if(tp(_,t.value)){for(;k<M;)u();t=ut}else t=yt;break;default:throw new Error("Unknown node type: "+t.type)}switch(QA+=S,C){case null:console.warn("[csstree-match] BREAK after "+Vb+" iterations"),C=XA,z=null;break;case Wb:for(;d!==null;)l();break;default:z=null}return{tokens:e,reason:C,iterations:S,match:z,longestMatch:R}}function rp(e,t,n){let r=eP(e,t,n||{});if(r.match===null)return r;let o=r.match,i=r.match={syntax:t.syntax||null,match:[]},s=[i];for(o=JA(o).prev;o!==null;){switch(o.type){case np:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case Yb:s.pop(),i=s[s.length-1];break;default:i.match.push({syntax:o.syntax||null,token:o.token.value,node:o.token.node})}o=o.prev}return r}var Hb,qA,YA,np,Yb,Wb,KA,XA,Vb,QA,Kb=$(()=>{"use strict";ep();({hasOwnProperty:Hb}=Object.prototype),qA=0,YA=1,np=2,Yb=3,Wb="Match",KA="Mismatch",XA="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",Vb=15e3,QA=0});var ip={};ye(ip,{getTrace:()=>Xb,isKeyword:()=>rP,isProperty:()=>nP,isType:()=>tP});function Xb(e){function t(o){return o===null?!1:o.type==="Type"||o.type==="Property"||o.type==="Keyword"}function n(o){if(Array.isArray(o.match)){for(let i=0;i<o.match.length;i++)if(n(o.match[i]))return t(o.syntax)&&r.unshift(o.syntax),!0}else if(o.node===e)return r=t(o.syntax)?[o.syntax]:[],!0;return!1}let r=null;return this.matched!==null&&n(this.matched),r}function tP(e,t){return op(this,e,n=>n.type==="Type"&&n.name===t)}function nP(e,t){return op(this,e,n=>n.type==="Property"&&n.name===t)}function rP(e){return op(this,e,t=>t.type==="Keyword")}function op(e,t,n){let r=Xb.call(e,t);return r===null?!1:r.some(n)}var Qb=$(()=>{"use strict"});function Jb(e){return"node"in e?e.node:Jb(e.match[0])}function Zb(e){return"node"in e?e.node:Zb(e.match[e.match.length-1])}function sp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=Jb(a),c=Zb(a);e.syntax.walk(t,function(l,d,f){if(l===u){let p=new Vn;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:f,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var e0=$(()=>{"use strict";ps()});function ap(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function t0(e){return!!e&&ap(e.offset)&&ap(e.line)&&ap(e.column)}function oP(e,t){return function(r,o){if(!r||r.constructor!==Object)return o(r,"Type of node should be an Object");for(let i in r){let s=!0;if(Cs.call(r,i)!==!1){if(i==="type")r.type!==e&&o(r,"Wrong node type `"+r.type+"`, expected `"+e+"`");else if(i==="loc"){if(r.loc===null)continue;if(r.loc&&r.loc.constructor===Object)if(typeof r.loc.source!="string")i+=".source";else if(!t0(r.loc.start))i+=".start";else if(!t0(r.loc.end))i+=".end";else continue;s=!1}else if(t.hasOwnProperty(i)){s=!1;for(let a=0;!s&&a<t[i].length;a++){let u=t[i][a];switch(u){case String:s=typeof r[i]=="string";break;case Boolean:s=typeof r[i]=="boolean";break;case null:s=r[i]===null;break;default:typeof u=="string"?s=r[i]&&r[i].type===u:Array.isArray(u)&&(s=r[i]instanceof Vn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Cs.call(t,i)&&Cs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function n0(e,t){let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o===String||o===Boolean)n.push(o.name.toLowerCase());else if(o===null)n.push("null");else if(typeof o=="string")n.push(o);else if(Array.isArray(o))n.push("List<"+(n0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function iP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Cs.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=n0(s,e+"."+i)}return{docs:o,check:oP(e,r)}}function r0(e){let t={};if(e.node){for(let n in e.node)if(Cs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=iP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Cs,o0=$(()=>{"use strict";ps();({hasOwnProperty:Cs}=Object.prototype)});function lp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:pi(e[o].syntax,{compact:t}));return r}function sP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:pi(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&lp(i.descriptors,t,n)};return r}function aP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function lP(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function br(e,t,n){return{matched:e,iterations:n,error:t,...ip}}function yi(e,t,n,r){let o=_b(n,e.syntax),i;return aP(o)?br(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=rp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=rp(o,t.match,e),!i.match)?br(null,new ab(i.reason,t.syntax,n,i),i.iterations):br(i.match,null,i.iterations))}var Ts,i0=$(()=>{"use strict";lb();sl();al();wb();vb();Ju();$b();ep();Kb();Qb();e0();o0();Ts=class{constructor(t,n,r){if(this.cssWideKeywords=gi,this.syntax=n,this.generic=!1,this.units={...ul},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||r0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(ul))Array.isArray(t.units[o])&&(this.units[o]=t.units[o]);if(t.types)for(let[o,i]of Object.entries(t.types))this.addType_(o,i);if(t.generic){this.generic=!0;for(let[o,i]of Object.entries(Sb(this.units)))this.addType_(o,i)}if(t.atrules)for(let[o,i]of Object.entries(t.atrules))this.addAtrule_(o,i);if(t.properties)for(let[o,i]of Object.entries(t.properties))this.addProperty_(o,i)}this.cssWideKeywordsSyntax=ks(this.cssWideKeywords.join(" | "))}checkStructure(t){function n(i,s){o.push({node:i,message:s})}let r=this.structure,o=[];return this.syntax.walk(t,function(i){r.hasOwnProperty(i.type)?r[i.type].check(i,n):n(i,"Unknown node type `"+i.type+"`")}),o.length?o:!1}createDescriptor(t,n,r,o=null){let i={type:n,name:r},s={type:n,name:r,parent:o,serializable:typeof t=="string"||t&&typeof t.type=="string",syntax:null,match:null,matchRef:null};return typeof t=="function"?s.match=ks(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ss(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:ks(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=lP(a)?ks({...a,terms:[a.terms[0].term]},i):null;return Object.defineProperty(s,"matchRef",{value:u}),u}})),s}addAtrule_(t,n){n&&(this.atrules[t]={type:"Atrule",name:t,prelude:n.prelude?this.createDescriptor(n.prelude,"AtrulePrelude",t):null,descriptors:n.descriptors?Object.keys(n.descriptors).reduce((r,o)=>(r[o]=this.createDescriptor(n.descriptors[o],"AtruleDescriptor",o,t),r),Object.create(null)):null})}addProperty_(t,n){n&&(this.properties[t]=this.createDescriptor(n,"Property",t))}addType_(t,n){n&&(this.types[t]=this.createDescriptor(n,"Type",t))}checkAtruleName(t){if(!this.getAtrule(t))return new di("Unknown at-rule","@"+t)}checkAtrulePrelude(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t);if(!o.prelude&&n)return new SyntaxError("At-rule `@"+t+"` should not contain a prelude");if(o.prelude&&!n&&!yi(this,o.prelude,"",!1).matched)return new SyntaxError("At-rule `@"+t+"` should contain a prelude")}checkAtruleDescriptorName(t,n){let r=this.checkAtruleName(t);if(r)return r;let o=this.getAtrule(t),i=ol(n);if(!o.descriptors)return new SyntaxError("At-rule `@"+t+"` has no known descriptors");if(!o.descriptors[i.name]&&!o.descriptors[i.basename])return new di("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new di("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return br(null,r);let o=this.getAtrule(t);return o.prelude?yi(this,o.prelude,n||"",!1):br(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return br(null,o);let i=this.getAtrule(t),s=ol(n);return yi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?br(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Pu(t).custom)return br(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?br(null,r):yi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?yi(this,r,n,!1):br(null,new di("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?br(null,new di("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),yi(this,t,n,!1))}findValueFragments(t,n,r,o){return sp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return sp(this,t.value,this.matchDeclaration(t),n,r)}findAllFragments(t,n,r){let o=[];return this.syntax.walk(t,{visit:"Declaration",enter:i=>{o.push.apply(o,this.findDeclarationValueFragments(i,n,r))}}),o}getAtrule(t,n=!0){let r=ol(t);return(r.vendor&&n?this.atrules[r.name]||this.atrules[r.basename]:this.atrules[r.name])||null}getAtrulePrelude(t,n=!0){let r=this.getAtrule(t,n);return r&&r.prelude||null}getAtruleDescriptor(t,n){return this.atrules.hasOwnProperty(t)&&this.atrules.declarators&&this.atrules[t].declarators[n]||null}getProperty(t,n=!0){let r=Pu(t);return(r.vendor&&n?this.properties[r.name]||this.properties[r.basename]:this.properties[r.name])||null}getType(t){return hasOwnProperty.call(this.types,t)?this.types[t]:null}validate(){function t(u,c){return c?`<${u}>`:`<'${u}'>`}function n(u,c,l,d){if(l.has(c))return l.get(c);l.set(c,!1),d.syntax!==null&&Qu(d.syntax,function(f){if(f.type!=="Type"&&f.type!=="Property")return;let p=f.type==="Type"?u.types:u.properties,g=f.type==="Type"?o:i;hasOwnProperty.call(p,f.name)?n(u,f.name,g,p[f.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0))},this)}let r=[],o=new Map,i=new Map;for(let u in this.types)n(this,u,o,this.types[u]);for(let u in this.properties)n(this,u,i,this.properties[u]);let s=[...o.keys()].filter(u=>o.get(u)),a=[...i.keys()].filter(u=>i.get(u));return s.length||a.length?{errors:r,types:s,properties:a}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:lp(this.types,!n,t),properties:lp(this.properties,!n,t),atrules:sP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function cp(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function cP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function up(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?cP(i,n):i};return r}function Is(e,t){let n={...e};for(let[r,o]of Object.entries(t))switch(r){case"generic":n[r]=!!o;break;case"cssWideKeywords":n[r]=e[r]?[...e[r],...o]:o||[];break;case"units":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=Array.isArray(s)?s:[];break;case"atrules":n[r]={...e[r]};for(let[i,s]of Object.entries(o)){let a=n[r][i]||{},u=n[r][i]={prelude:a.prelude||null,descriptors:{...a.descriptors}};if(s){u.prelude=s.prelude?cp(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?cp(u.descriptors[c],l):null;Object.keys(u.descriptors).length||(u.descriptors=null)}}break;case"types":case"properties":n[r]={...e[r]};for(let[i,s]of Object.entries(o))n[r][i]=cp(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=up(e[r],o);break;case"atrule":case"pseudo":n[r]=up(e[r],o,["parse"]);break;case"node":n[r]=up(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var s0=$(()=>{"use strict"});function a0(e){let t=vy(e),n=ob(e),r=Xy(e),{fromPlainObject:o,toPlainObject:i}=Jy(n),s={lexer:null,createLexer:a=>new Ts(a,s,s.lexer.structure),tokenize:lo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Is({},e);return a0(typeof a=="function"?a(u):Is(u,a))}};return s.lexer=new Ts({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var l0,c0=$(()=>{"use strict";nr();ky();Qy();Zy();ib();i0();s0();l0=e=>a0(Is({},e))});var u0,p0=$(()=>{"use strict";u0={generic:!0,cssWideKeywords:["initial","inherit","unset","revert","revert-layer"],units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( <calc-sum> )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( <calc-sum> )","alpha-value":"<number>|<percentage>","an+b":"odd|even|<integer>|<n-dimension>|'+'? \u2020 n|-n|<ndashdigit-dimension>|'+'? \u2020 <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? \u2020 n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? \u2020 n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? \u2020 n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>","anchor()":"anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )","anchor-name":"<dashed-ident>","anchor-side":"inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center","anchor-size":"width|height|block|inline|self-block|self-inline","anchor-size()":"anchor-size( [<anchor-name>||<anchor-size>]? , <length-percentage>? )","angle-percentage":"<angle>|<percentage>","angular-color-hint":"<angle-percentage>|<zero>","angular-color-stop":"<color> <color-stop-angle>?","angular-color-stop-list":"<angular-color-stop> , [<angular-color-hint>? , <angular-color-stop>]#?","animateable-feature":"scroll-position|contents|<custom-ident>","animation-action":"none|play|play-once|play-forwards|play-backwards|pause|reset|replay","asin()":"asin( <calc-sum> )","atan()":"atan( <calc-sum> )","atan2()":"atan2( <calc-sum> , <calc-sum> )",attachment:"scroll|fixed|local","attr()":"attr( <attr-name> <attr-type>? , <declaration-value>? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attr-type":"type( <syntax> )|raw-string|number|<attr-unit>","attribute-selector":"'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )","auto-track-list":"[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",axis:"block|inline|x|y","baseline-position":"[first|last]? baseline","basic-shape":"<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>","basic-shape-rect":"<inset()>|<rect()>|<xywh()>","bg-clip":"<visual-box>|border-area|text","bg-image":"<image>|none","bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>","bg-position":"[[left|center|right|top|bottom|<length-percentage>]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]|[center|[left|right] <length-percentage>?]&&[center|[top|bottom] <length-percentage>?]]","bg-size":"[<length-percentage [0,\u221E]>|auto]{1,2}|cover|contain","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","blur()":"blur( <length>? )","brightness()":"brightness( [<number>|<percentage>]? )","calc()":"calc( <calc-sum> )","calc-constant":"e|pi|infinity|-infinity|NaN","calc-product":"<calc-value> ['*' <calc-value>|'/' <number>]*","calc-size()":"calc-size( <calc-size-basis> , <calc-sum> )","calc-size-basis":"<intrinsic-size-keyword>|<calc-size()>|any|<calc-sum>","calc-sum":"<calc-product> [['+'|'-'] <calc-product>]*","calc-value":"<number>|<dimension>|<percentage>|<calc-constant>|( <calc-sum> )","cf-final-image":"<image>|<color>","cf-mixing-image":"<percentage>?&&<image>","circle()":"circle( <radial-size>? [at <position>]? )","clamp()":"clamp( <calc-sum>#{3} )","class-selector":"'.' <ident-token>","clip-source":"<url>",color:"<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>","color()":"color( <colorspace-params> [/ [<alpha-value>|none]]? )","color-base":"<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent","color-function":"<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>","color-interpolation-method":"in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]","color-mix()":"color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )","color-stop":"<color-stop-length>|<color-stop-angle>","color-stop-angle":"[<angle-percentage>|<zero>]{1,2}","color-stop-length":"<length-percentage>{1,2}","color-stop-list":"<linear-color-stop> , [<linear-color-hint>? , <linear-color-stop>]#?","colorspace-params":"[<predefined-rgb-params>|<xyz-params>]",combinator:"'>'|'+'|'~'|['|' '|']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|checkbox|radio|menulist|listbox|meter|progress-bar|button","compat-special":"textfield|menulist-button","complex-selector":"<complex-selector-unit> [<combinator>? <complex-selector-unit>]*","complex-selector-list":"<complex-selector>#","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[<type-selector>? <subclass-selector>*]!","compound-selector-list":"<compound-selector>#","conic-gradient()":"conic-gradient( [<conic-gradient-syntax>] )","conic-gradient-syntax":"[[[from [<angle>|<zero>]]? [at <position>]?]||<color-interpolation-method>]? , <angular-color-stop-list>","container-condition":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","container-name":"<custom-ident>","container-query":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[<string>|contents|<image>|<counter>|<quote>|<target>|<leader()>|<attr()>]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"<image>","contextual-alt-values":"[contextual|no-contextual]","contrast()":"contrast( [<number>|<percentage>]? )","coord-box":"content-box|padding-box|border-box|fill-box|stroke-box|view-box","corner-shape-value":"round|scoop|bevel|notch|square|squircle|<superellipse()>","cos()":"cos( <calc-sum> )",counter:"<counter()>|<counters()>","counter()":"counter( <counter-name> , <counter-style>? )","counter-name":"<custom-ident>","counter-style":"<counter-style-name>|symbols( )","counter-style-name":"<custom-ident>","counters()":"counters( <counter-name> , <string> , <counter-style>? )","cross-fade()":"cross-fade( <cf-mixing-image> , <cf-final-image>? )","cubic-bezier()":"cubic-bezier( [<number [0,1]> , <number>]#{2} )","cubic-bezier-easing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )","cursor-predefined":"auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing","custom-color-space":"<dashed-ident>","custom-params":"<dashed-ident> [<number>|<percentage>|none]+",dasharray:"[[<length-percentage>|<number>]+]#","dashndashdigit-ident":"<ident-token>","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow|CaptionText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"<display-outside>?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( [<color>?&&<length>{2,3}] )","dynamic-range-limit-mix()":"dynamic-range-limit-mix( [<'dynamic-range-limit'>&&<percentage [0,100]>]#{2,} )","easing-function":"<linear-easing-function>|<cubic-bezier-easing-function>|<step-easing-function>","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )","ellipse()":"ellipse( <radial-size>? [at <position>]? )","env()":"env( <custom-ident> , <declaration-value>? )","exp()":"exp( <calc-sum> )","explicit-track-list":"[<line-names>? <track-size>]+ <line-names>?","family-name":"<string>|<custom-ident>+","feature-tag-value":"<string> [<integer>|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":"<feature-type> '{' <feature-value-declaration-list> '}'","feature-value-block-list":"<feature-value-block>+","feature-value-declaration":"<custom-ident> : <integer>+ ;","feature-value-declaration-list":"<feature-value-declaration>","feature-value-name":"<custom-ident>","filter-function":"<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>","filter-value-list":"[<filter-function>|<url>]+","final-bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>||<'background-color'>","fit-content()":"fit-content( <length-percentage [0,\u221E]> )","fixed-breadth":"<length-percentage>","fixed-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <fixed-size>]+ <line-names>? )","fixed-size":"<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>","font-variant-css2":"normal|small-caps","font-weight-absolute":"normal|bold|<number [1,1000]>","font-width-css3":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","form-control-identifier":"select","frequency-percentage":"<frequency>|<percentage>","generic-complete":"serif|sans-serif|system-ui|cursive|fantasy|math|monospace","general-enclosed":"[<function-token> <any-value>? )]|[( <any-value>? )]","generic-family":"<generic-script-specific>|<generic-complete>|<generic-incomplete>|<-non-standard-generic-family>","generic-incomplete":"ui-serif|ui-sans-serif|ui-monospace|ui-rounded","geometry-box":"<shape-box>|fill-box|stroke-box|view-box",gradient:"<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<repeating-conic-gradient()>|<-legacy-gradient>","grayscale()":"grayscale( [<number>|<percentage>]? )","grid-line":"auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hsla()":"hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",hue:"<number>|<angle>","hue-interpolation-method":"[shorter|longer|increasing|decreasing] hue","hue-rotate()":"hue-rotate( [<angle>|<zero>]? )","hwb()":"hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hypot()":"hypot( <calc-sum># )",image:"<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>","image()":"image( <image-tags>? [<image-src>? , <color>?]! )","image-set()":"image-set( <image-set-option># )","image-set-option":"[<image>|<string>] [<resolution>||type( <string> )]","image-src":"<url>|<string>","image-tags":"ltr|rtl","inflexible-breadth":"<length-percentage>|min-content|max-content|auto","inset()":"inset( <length-percentage>{1,4} [round <'border-radius'>]? )","invert()":"invert( [<number>|<percentage>]? )","keyframe-block":"<keyframe-selector># { <declaration-list> }","keyframe-selector":"from|to|<percentage [0,100]>|<timeline-range-name> <percentage>","keyframes-name":"<custom-ident>|<string>","lab()":"lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","layer()":"layer( <layer-name> )","layer-name":"<ident> ['.' <ident>]*","lch()":"lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","leader()":"leader( <leader-type> )","leader-type":"dotted|solid|space|<string>","length-percentage":"<length>|<percentage>","light-dark()":"light-dark( <color> , <color> )","line-name-list":"[<line-names>|<name-repeat>]+","line-names":"'[' <custom-ident>* ']'","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"<length>|thin|medium|thick","linear()":"linear( [<number>&&<percentage>{0,2}]# )","linear-color-hint":"<length-percentage>","linear-color-stop":"<color> <color-stop-length>?","linear-easing-function":"linear|<linear()>","linear-gradient()":"linear-gradient( [<linear-gradient-syntax>] )","linear-gradient-syntax":"[[<angle>|<zero>|to <side-or-corner>]||<color-interpolation-method>]? , <color-stop-list>","log()":"log( <calc-sum> , <calc-sum>? )","mask-layer":"<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>","mask-position":"[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?","mask-reference":"none|<image>|<mask-source>","mask-source":"<url>","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( <number>#{6} )","matrix3d()":"matrix3d( <number>#{16} )","max()":"max( <calc-sum># )","media-and":"<media-in-parens> [and <media-in-parens>]+","media-condition":"<media-not>|<media-and>|<media-or>|<media-in-parens>","media-condition-without-or":"<media-not>|<media-and>|<media-in-parens>","media-feature":"( [<mf-plain>|<mf-boolean>|<mf-range>] )","media-in-parens":"( <media-condition> )|<media-feature>|<general-enclosed>","media-not":"not <media-in-parens>","media-or":"<media-in-parens> [or <media-in-parens>]+","media-query":"<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?","media-query-list":"<media-query>#","media-type":"<ident>","mf-boolean":"<mf-name>","mf-name":"<ident>","mf-plain":"<mf-name> : <mf-value>","mf-range":"<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>","mf-value":"<number>|<dimension>|<ident>|<ratio>","min()":"min( <calc-sum># )","minmax()":"minmax( [<length-percentage>|min-content|max-content|auto] , [<length-percentage>|<flex>|min-content|max-content|auto] )","mod()":"mod( <calc-sum> , <calc-sum> )","n-dimension":"<dimension-token>","name-repeat":"repeat( [<integer [1,\u221E]>|auto-fill] , <line-names>+ )","named-color":"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen","namespace-prefix":"<ident>","ndash-dimension":"<dimension-token>","ndashdigit-dimension":"<dimension-token>","ndashdigit-ident":"<ident-token>","ns-prefix":"[<ident-token>|'*']? '|'","number-percentage":"<number>|<percentage>","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","offset-path":"<ray()>|<url>|<basic-shape>","oklab()":"oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","oklch()":"oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","opacity()":"opacity( [<number>|<percentage>]? )","opacity-value":"<number>|<percentage>","outline-line-style":"none|dotted|dashed|solid|double|groove|ridge|inset|outset","outline-radius":"<length>|<percentage>","overflow-position":"unsafe|safe","page-body":"<declaration>? [; <page-body>]?|<page-margin-box> <page-body>","page-margin-box":"<page-margin-box-type> '{' <declaration-list> '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector":"<pseudo-page>+|<ident> <pseudo-page>*","page-selector-list":"[<page-selector>#]?","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",paint:"none|<color>|<url> [none|<color>]?|context-fill|context-stroke","paint()":"paint( <ident> , <declaration-value>? )","paint-box":"<visual-box>|fill-box|stroke-box","palette-identifier":"<dashed-ident>","palette-mix()":"palette-mix( <color-interpolation-method> , [[normal|light|dark|<palette-identifier>|<palette-mix()>]&&<percentage [0,100]>?]#{2} )","path()":"path( <'fill-rule'>? , <string> )","perspective()":"perspective( [<length [0,\u221E]>|none] )","polar-color-space":"hsl|hwb|lch|oklch","polygon()":"polygon( <'fill-rule'>? , [<length-percentage> <length-percentage>]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]?|[[left|right] <length-percentage>]&&[[top|bottom] <length-percentage>]]","position-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|center|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|center|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]","pow()":"pow( <calc-sum> , <calc-sum> )","predefined-rgb":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020","predefined-rgb-params":"<predefined-rgb> [<number>|<percentage>|none]{3}","pseudo-class-selector":"':' <ident-token>|':' <function-token> <any-value> ')'","pseudo-element-selector":"':' <pseudo-class-selector>|<legacy-pseudo-element-selector>","pseudo-page":": [left|right|first|blank]","query-in-parens":"( <container-condition> )|( <size-feature> )|style( <style-query> )|<general-enclosed>",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-extent":"closest-corner|closest-side|farthest-corner|farthest-side","radial-gradient()":"radial-gradient( [<radial-gradient-syntax>] )","radial-gradient-syntax":"[[[<radial-shape>||<radial-size>]? [at <position>]?]||<color-interpolation-method>]? , <color-stop-list>","radial-shape":"circle|ellipse","radial-size":"<radial-extent>|<length [0,\u221E]>|<length-percentage [0,\u221E]>{2}",ratio:"<number [0,\u221E]> [/ <number [0,\u221E]>]?","ray()":"ray( <angle>&&<ray-size>?&&contain?&&[at <position>]? )","ray-size":"closest-side|closest-corner|farthest-side|farthest-corner|sides","rect()":"rect( [<length-percentage>|auto]{4} [round <'border-radius'>]? )","rectangular-color-space":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65","relative-selector":"<combinator>? <complex-selector>","relative-selector-list":"<relative-selector>#","relative-size":"larger|smaller","rem()":"rem( <calc-sum> , <calc-sum> )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [<conic-gradient-syntax>] )","repeating-linear-gradient()":"repeating-linear-gradient( [<linear-gradient-syntax>] )","repeating-radial-gradient()":"repeating-radial-gradient( [<radial-gradient-syntax>] )","reversed-counter-name":"reversed( <counter-name> )","rgb()":"rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rgba()":"rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rotate()":"rotate( [<angle>|<zero>] )","rotate3d()":"rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )","rotateX()":"rotateX( [<angle>|<zero>] )","rotateY()":"rotateY( [<angle>|<zero>] )","rotateZ()":"rotateZ( [<angle>|<zero>] )","round()":"round( <rounding-strategy>? , <calc-sum> , <calc-sum> )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( [<number>|<percentage>]? )","scale()":"scale( [<number>|<percentage>]#{1,2} )","scale3d()":"scale3d( [<number>|<percentage>]#{3} )","scaleX()":"scaleX( [<number>|<percentage>] )","scaleY()":"scaleY( [<number>|<percentage>] )","scaleZ()":"scaleZ( [<number>|<percentage>] )","scope-end":"<forgiving-selector-list>","scope-start":"<forgiving-selector-list>","scroll()":"scroll( [<scroller>||<axis>]? )",scroller:"root|nearest|self","scroll-state-feature":"<media-query-list>","scroll-state-in-parens":"( <scroll-state-query> )|( <scroll-state-feature> )|<general-enclosed>","scroll-state-query":"not <scroll-state-in-parens>|<scroll-state-in-parens> [[and <scroll-state-in-parens>]*|[or <scroll-state-in-parens>]*]|<scroll-state-feature>","selector-list":"<complex-selector-list>","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","sepia()":"sepia( [<number>|<percentage>]? )",shadow:"inset?&&<length>{2,4}&&<color>?","shadow-t":"[<length>{2,3}&&<color>?]",shape:"rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )","shape-box":"<visual-box>|margin-box","side-or-corner":"[left|right]||[top|bottom]","sign()":"sign( <calc-sum> )","signed-integer":"<number-token>","signless-integer":"<number-token>","sin()":"sin( <calc-sum> )","single-animation":"<'animation-duration'>||<easing-function>||<'animation-delay'>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]||<single-animation-timeline>","single-animation-composition":"replace|add|accumulate","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|<number>","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|<dashed-ident>|<scroll()>|<view()>","single-transition":"[none|<single-transition-property>]||<time>||<easing-function>||<time>||<transition-behavior-value>","single-transition-property":"all|<custom-ident>",size:"closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}","size-feature":"<mf-plain>|<mf-boolean>|<mf-range>","skew()":"skew( [<angle>|<zero>] , [<angle>|<zero>]? )","skewX()":"skewX( [<angle>|<zero>] )","skewY()":"skewY( [<angle>|<zero>] )","sqrt()":"sqrt( <calc-sum> )","step-position":"jump-start|jump-end|jump-none|jump-both|start|end","step-easing-function":"step-start|step-end|<steps()>","steps()":"steps( <integer> , <step-position>? )","style-feature":"<declaration>","style-in-parens":"( <style-condition> )|( <style-feature> )|<general-enclosed>","style-query":"<style-condition>|<style-feature>","subclass-selector":"<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>","superellipse()":"superellipse( [<number>|infinity|-infinity] )","supports-condition":"not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*","supports-decl":"( <declaration> )","supports-feature":"<supports-decl>|<supports-selector-fn>","supports-in-parens":"( <supports-condition> )|<supports-feature>|<general-enclosed>","supports-selector-fn":"selector( <complex-selector> )",symbol:"<string>|<image>|<custom-ident>","symbols()":"symbols( <symbols-type>? [<string>|<image>]+ )","symbols-type":"cyclic|numeric|alphabetic|symbolic|fixed","system-color":"AccentColor|AccentColorText|ActiveText|ButtonBorder|ButtonFace|ButtonText|Canvas|CanvasText|Field|FieldText|GrayText|Highlight|HighlightText|LinkText|Mark|MarkText|SelectedItem|SelectedItemText|VisitedText","system-family-name":"caption|icon|menu|message-box|small-caption|status-bar","tan()":"tan( <calc-sum> )",target:"<target-counter()>|<target-counters()>|<target-text()>","target-counter()":"target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )","target-counters()":"target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )","target-text()":"target-text( [<string>|<url>] , [content|before|after|first-letter]? )","text-edge":"[text|cap|ex|ideographic|ideographic-ink] [text|alphabetic|ideographic|ideographic-ink]?","time-percentage":"<time>|<percentage>","timeline-range-name":"cover|contain|entry|exit|entry-crossing|exit-crossing","track-breadth":"<length-percentage>|<flex>|min-content|max-content|auto","track-list":"[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?","track-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <track-size>]+ <line-names>? )","track-size":"<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( <length-percentage> )","transform-function":"<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>","transform-list":"<transform-function>+","transition-behavior-value":"normal|allow-discrete","translate()":"translate( <length-percentage> , <length-percentage>? )","translate3d()":"translate3d( <length-percentage> , <length-percentage> , <length> )","translateX()":"translateX( <length-percentage> )","translateY()":"translateY( <length-percentage> )","translateZ()":"translateZ( <length> )","try-size":"most-width|most-height|most-block-size|most-inline-size","try-tactic":"flip-block||flip-inline||flip-start","type-or-unit":"string|color|url|integer|number|length|angle|time|frequency|cap|ch|em|ex|ic|lh|rlh|rem|vb|vi|vw|vh|vmin|vmax|mm|Q|cm|in|pt|pc|px|deg|grad|rad|turn|ms|s|Hz|kHz|%","type-selector":"<wq-name>|<ns-prefix>? '*'","var()":"var( <custom-property-name> , <declaration-value>? )","view()":"view( [<axis>||<'view-timeline-inset'>]? )","viewport-length":"auto|<length-percentage>","visual-box":"content-box|padding-box|border-box","wq-name":"<ns-prefix>? <ident-token>","xywh()":"xywh( <length-percentage>{2} <length-percentage [0,\u221E]>{2} [round <'border-radius'>]? )",xyz:"xyz|xyz-d50|xyz-d65","xyz-params":"<xyz-space> [<number>|<percentage>|none]{3}","-legacy-gradient":"<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>","-legacy-linear-gradient":"-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-repeating-linear-gradient":"-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-linear-gradient-arguments":"[<angle>|<side-or-corner>]? , <color-stop-list>","-legacy-radial-gradient":"-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-repeating-radial-gradient":"-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-radial-gradient-arguments":"[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>","-legacy-radial-gradient-size":"closest-side|closest-corner|farthest-side|farthest-corner|contain|cover","-legacy-radial-gradient-shape":"circle|ellipse","-non-standard-font":"-apple-system-body|-apple-system-headline|-apple-system-subheadline|-apple-system-caption1|-apple-system-caption2|-apple-system-footnote|-apple-system-short-body|-apple-system-short-headline|-apple-system-short-subheadline|-apple-system-short-caption1|-apple-system-short-footnote|-apple-system-tall-body","-non-standard-color":"-moz-ButtonDefault|-moz-ButtonHoverFace|-moz-ButtonHoverText|-moz-CellHighlight|-moz-CellHighlightText|-moz-Combobox|-moz-ComboboxText|-moz-Dialog|-moz-DialogText|-moz-dragtargetzone|-moz-EvenTreeRow|-moz-Field|-moz-FieldText|-moz-html-CellHighlight|-moz-html-CellHighlightText|-moz-mac-accentdarkestshadow|-moz-mac-accentdarkshadow|-moz-mac-accentface|-moz-mac-accentlightesthighlight|-moz-mac-accentlightshadow|-moz-mac-accentregularhighlight|-moz-mac-accentregularshadow|-moz-mac-chrome-active|-moz-mac-chrome-inactive|-moz-mac-focusring|-moz-mac-menuselect|-moz-mac-menushadow|-moz-mac-menutextselect|-moz-MenuHover|-moz-MenuHoverText|-moz-MenuBarText|-moz-MenuBarHoverText|-moz-nativehyperlinktext|-moz-OddTreeRow|-moz-win-communicationstext|-moz-win-mediatext|-moz-activehyperlinktext|-moz-default-background-color|-moz-default-color|-moz-hyperlinktext|-moz-visitedhyperlinktext|-webkit-activelink|-webkit-focus-ring-color|-webkit-link|-webkit-text","-non-standard-image-rendering":"optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast","-non-standard-overflow":"overlay|-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable","-non-standard-size":"intrinsic|min-intrinsic|-webkit-fill-available|-webkit-fit-content|-webkit-min-content|-webkit-max-content|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content","-webkit-gradient()":"-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point>|, <-webkit-gradient-radius> , <-webkit-gradient-point>] [, <-webkit-gradient-radius>]? [, <-webkit-gradient-color-stop>]* )","-webkit-gradient-color-stop":"from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )","-webkit-gradient-point":"[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]","-webkit-gradient-radius":"<length>|<percentage>","-webkit-gradient-type":"linear|radial","-webkit-mask-box-repeat":"repeat|stretch|round","-ms-filter-function-list":"<-ms-filter-function>+","-ms-filter-function":"<-ms-filter-function-progid>|<-ms-filter-function-legacy>","-ms-filter-function-progid":"'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]","-ms-filter-function-legacy":"<ident-token>|<function-token> <any-value>? )",age:"child|young|old","attr-name":"<wq-name>","attr-fallback":"<any-value>",autospace:"no-autospace|[ideograph-alpha||ideograph-numeric||punctuation]||[insert|replace]",bottom:"<length>|auto","generic-voice":"[<age>? <gender> <integer>?]",gender:"male|female|neutral","generic-script-specific":"generic( kai )|generic( fangsong )|generic( nastaliq )","-non-standard-generic-family":"-apple-system|BlinkMacSystemFont","intrinsic-size-keyword":"min-content|max-content|fit-content",left:"<length>|auto","device-cmyk()":"<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>","legacy-device-cmyk-syntax":"device-cmyk( <number>#{4} )","modern-device-cmyk-syntax":"device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )","cmyk-component":"<number>|<percentage>|none","color-space":"<rectangular-color-space>|<polar-color-space>|<custom-color-space>",right:"<length>|auto","forgiving-selector-list":"<complex-real-selector-list>","forgiving-relative-selector-list":"<relative-real-selector-list>","complex-real-selector-list":"<complex-real-selector>#","simple-selector-list":"<simple-selector>#","relative-real-selector-list":"<relative-real-selector>#","complex-selector-unit":"[<compound-selector>? <pseudo-compound-selector>*]!","complex-real-selector":"<compound-selector> [<combinator>? <compound-selector>]*","relative-real-selector":"<combinator>? <complex-real-selector>","pseudo-compound-selector":"<pseudo-element-selector> <pseudo-class-selector>*","simple-selector":"<type-selector>|<subclass-selector>","legacy-pseudo-element-selector":"':' [before|after|first-line|first-letter]","svg-length":"<percentage>|<length>|<number>","svg-writing-mode":"lr-tb|rl-tb|tb-rl|lr|rl|tb",top:"<length>|auto",x:"<number>",y:"<number>",declaration:"<ident-token> : <declaration-value>? ['!' important]?","declaration-list":"[<declaration>? ';']* <declaration>?",url:"url( <string> <url-modifier>* )|<url-token>","url-modifier":"<ident>|<function-token> <any-value> )","number-zero-one":"<number [0,1]>","number-one-or-greater":"<number [1,\u221E]>","xyz-space":"xyz|xyz-d50|xyz-d65","style-condition":"not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]","-non-standard-display":"-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box","inset-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]",syntax:"'*'|<syntax-component> [<syntax-combinator> <syntax-component>]*|<syntax-string>","syntax-component":"<syntax-single-component> <syntax-multiplier>?|'<' transform-list '>'","syntax-single-component":"'<' <syntax-type-name> '>'|<ident>","syntax-type-name":"angle|color|custom-ident|image|integer|length|length-percentage|number|percentage|resolution|string|time|url|transform-function","syntax-combinator":"'|'","syntax-multiplier":"'#'|'+'","syntax-string":"<string>"},properties:{"--*":"<declaration-value>","-ms-accelerator":"false|true","-ms-block-progression":"tb|rl|bt|lr","-ms-content-zoom-chaining":"none|chained","-ms-content-zoom-limit":"<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>","-ms-content-zoom-limit-max":"<percentage>","-ms-content-zoom-limit-min":"<percentage>","-ms-content-zoom-snap":"<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>","-ms-content-zoom-snap-points":"snapInterval( <percentage> , <percentage> )|snapList( <percentage># )","-ms-content-zoom-snap-type":"none|proximity|mandatory","-ms-content-zooming":"none|zoom","-ms-filter":"<string>","-ms-flow-from":"[none|<custom-ident>]#","-ms-flow-into":"[none|<custom-ident>]#","-ms-grid-columns":"none|<track-list>|<auto-track-list>","-ms-grid-rows":"none|<track-list>|<auto-track-list>","-ms-high-contrast-adjust":"auto|none","-ms-hyphenate-limit-chars":"auto|<integer>{1,3}","-ms-hyphenate-limit-lines":"no-limit|<integer>","-ms-hyphenate-limit-zone":"<percentage>|<length>","-ms-ime-align":"auto|after","-ms-overflow-style":"auto|none|scrollbar|-ms-autohiding-scrollbar","-ms-scroll-chaining":"chained|none","-ms-scroll-limit":"<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>","-ms-scroll-limit-x-max":"auto|<length>","-ms-scroll-limit-x-min":"<length>","-ms-scroll-limit-y-max":"auto|<length>","-ms-scroll-limit-y-min":"<length>","-ms-scroll-rails":"none|railed","-ms-scroll-snap-points-x":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-points-y":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-type":"none|proximity|mandatory","-ms-scroll-snap-x":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>","-ms-scroll-snap-y":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>","-ms-scroll-translation":"none|vertical-to-horizontal","-ms-scrollbar-3dlight-color":"<color>","-ms-scrollbar-arrow-color":"<color>","-ms-scrollbar-base-color":"<color>","-ms-scrollbar-darkshadow-color":"<color>","-ms-scrollbar-face-color":"<color>","-ms-scrollbar-highlight-color":"<color>","-ms-scrollbar-shadow-color":"<color>","-ms-scrollbar-track-color":"<color>","-ms-text-autospace":"none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space","-ms-touch-select":"grippers|none","-ms-user-select":"none|element|text","-ms-wrap-flow":"auto|both|start|end|maximum|clear","-ms-wrap-margin":"<length>","-ms-wrap-through":"wrap|none","-moz-appearance":"none|button|button-arrow-down|button-arrow-next|button-arrow-previous|button-arrow-up|button-bevel|button-focus|caret|checkbox|checkbox-container|checkbox-label|checkmenuitem|dualbutton|groupbox|listbox|listitem|menuarrow|menubar|menucheckbox|menuimage|menuitem|menuitemtext|menulist|menulist-button|menulist-text|menulist-textfield|menupopup|menuradio|menuseparator|meterbar|meterchunk|progressbar|progressbar-vertical|progresschunk|progresschunk-vertical|radio|radio-container|radio-label|radiomenuitem|range|range-thumb|resizer|resizerpanel|scale-horizontal|scalethumbend|scalethumb-horizontal|scalethumbstart|scalethumbtick|scalethumb-vertical|scale-vertical|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|separator|sheet|spinner|spinner-downbutton|spinner-textfield|spinner-upbutton|splitter|statusbar|statusbarpanel|tab|tabpanel|tabpanels|tab-scroll-arrow-back|tab-scroll-arrow-forward|textfield|textfield-multiline|toolbar|toolbarbutton|toolbarbutton-dropdown|toolbargripper|toolbox|tooltip|treeheader|treeheadercell|treeheadersortarrow|treeitem|treeline|treetwisty|treetwistyopen|treeview|-moz-mac-unified-toolbar|-moz-win-borderless-glass|-moz-win-browsertabbar-toolbox|-moz-win-communicationstext|-moz-win-communications-toolbox|-moz-win-exclude-glass|-moz-win-glass|-moz-win-mediatext|-moz-win-media-toolbox|-moz-window-button-box|-moz-window-button-box-maximized|-moz-window-button-close|-moz-window-button-maximize|-moz-window-button-minimize|-moz-window-button-restore|-moz-window-frame-bottom|-moz-window-frame-left|-moz-window-frame-right|-moz-window-titlebar|-moz-window-titlebar-maximized","-moz-binding":"<url>|none","-moz-border-bottom-colors":"<color>+|none","-moz-border-left-colors":"<color>+|none","-moz-border-right-colors":"<color>+|none","-moz-border-top-colors":"<color>+|none","-moz-context-properties":"none|[fill|fill-opacity|stroke|stroke-opacity]#","-moz-float-edge":"border-box|content-box|margin-box|padding-box","-moz-force-broken-image-icon":"0|1","-moz-orient":"inline|block|horizontal|vertical","-moz-outline-radius":"<outline-radius>{1,4} [/ <outline-radius>{1,4}]?","-moz-outline-radius-bottomleft":"<outline-radius>","-moz-outline-radius-bottomright":"<outline-radius>","-moz-outline-radius-topleft":"<outline-radius>","-moz-outline-radius-topright":"<outline-radius>","-moz-stack-sizing":"ignore|stretch-to-fit","-moz-text-blink":"none|blink","-moz-user-focus":"ignore|normal|select-after|select-before|select-menu|select-same|select-all|none","-moz-user-input":"auto|none|enabled|disabled","-moz-user-modify":"read-only|read-write|write-only","-moz-window-dragging":"drag|no-drag","-moz-window-shadow":"default|menu|tooltip|sheet|none","-webkit-appearance":"none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|push-button|radio|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbargripper-horizontal|scrollbargripper-vertical|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|searchfield-cancel-button|searchfield-decoration|searchfield-results-button|searchfield-results-decoration|slider-horizontal|slider-vertical|sliderthumb-horizontal|sliderthumb-vertical|square-button|textarea|textfield|-apple-pay-button","-webkit-border-before":"<'border-width'>||<'border-style'>||<color>","-webkit-border-before-color":"<color>","-webkit-border-before-style":"<'border-style'>","-webkit-border-before-width":"<'border-width'>","-webkit-box-reflect":"[above|below|right|left]? <length>? <image>?","-webkit-line-clamp":"none|<integer>","-webkit-mask":"[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<visual-box>|border|padding|content|text]||[<visual-box>|border|padding|content]]#","-webkit-mask-attachment":"<attachment>#","-webkit-mask-clip":"[<coord-box>|no-clip|border|padding|content|text]#","-webkit-mask-composite":"<composite-style>#","-webkit-mask-image":"<mask-reference>#","-webkit-mask-origin":"[<coord-box>|border|padding|content]#","-webkit-mask-position":"<position>#","-webkit-mask-position-x":"[<length-percentage>|left|center|right]#","-webkit-mask-position-y":"[<length-percentage>|top|center|bottom]#","-webkit-mask-repeat":"<repeat-style>#","-webkit-mask-repeat-x":"repeat|no-repeat|space|round","-webkit-mask-repeat-y":"repeat|no-repeat|space|round","-webkit-mask-size":"<bg-size>#","-webkit-overflow-scrolling":"auto|touch","-webkit-tap-highlight-color":"<color>","-webkit-text-fill-color":"<color>","-webkit-text-stroke":"<length>||<color>","-webkit-text-stroke-color":"<color>","-webkit-text-stroke-width":"<length>","-webkit-touch-callout":"default|none","-webkit-user-modify":"read-only|read-write|read-write-plaintext-only","-webkit-user-select":"auto|none|text|all","accent-color":"auto|<color>","align-content":"normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>","align-items":"normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]|anchor-center","align-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>|anchor-center","align-tracks":"[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#","alignment-baseline":"auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical",all:"initial|inherit|unset|revert|revert-layer","anchor-name":"none|<dashed-ident>#","anchor-scope":"none|all|<dashed-ident>#",animation:"<single-animation>#","animation-composition":"<single-animation-composition>#","animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"[auto|<time [0s,\u221E]>]#","animation-fill-mode":"<single-animation-fill-mode>#","animation-iteration-count":"<single-animation-iteration-count>#","animation-name":"[none|<keyframes-name>]#","animation-play-state":"<single-animation-play-state>#","animation-range":"[<'animation-range-start'> <'animation-range-end'>?]#","animation-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-timeline":"<single-animation-timeline>#","animation-timing-function":"<easing-function>#","animation-trigger":"[none|[<dashed-ident> <animation-action>+]+]#",appearance:"none|auto|<compat-auto>|<compat-special>","aspect-ratio":"auto||<ratio>","backdrop-filter":"none|<filter-value-list>","backface-visibility":"visible|hidden",background:"<bg-layer>#? , <final-bg-layer>","background-attachment":"<attachment>#","background-blend-mode":"<blend-mode>#","background-clip":"<bg-clip>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<visual-box>#","background-position":"<bg-position>#","background-position-x":"[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#","background-position-y":"[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","baseline-shift":"baseline|sub|super|<svg-length>","baseline-source":"auto|first|last","block-size":"<'width'>",border:"<line-width>||<line-style>||<color>","border-block":"<'border-block-start'>","border-block-color":"<'border-top-color'>{1,2}","border-block-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-end-color":"<'border-top-color'>","border-block-end-style":"<'border-top-style'>","border-block-end-width":"<'border-top-width'>","border-block-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-start-color":"<'border-top-color'>","border-block-start-style":"<'border-top-style'>","border-block-start-width":"<'border-top-width'>","border-block-style":"<'border-top-style'>{1,2}","border-block-width":"<'border-top-width'>{1,2}","border-bottom":"<line-width>||<line-style>||<color>","border-bottom-color":"<'border-top-color'>","border-bottom-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-style":"<line-style>","border-bottom-width":"<line-width>","border-collapse":"separate|collapse","border-color":"<color>{1,4}","border-end-end-radius":"<'border-top-left-radius'>","border-end-start-radius":"<'border-top-left-radius'>","border-image":"<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>","border-image-outset":"[<length [0,\u221E]>|<number [0,\u221E]>]{1,4}","border-image-repeat":"[stretch|repeat|round|space]{1,2}","border-image-slice":"[<number [0,\u221E]>|<percentage [0,\u221E]>]{1,4}&&fill?","border-image-source":"none|<image>","border-image-width":"[<length-percentage [0,\u221E]>|<number [0,\u221E]>|auto]{1,4}","border-inline":"<'border-block-start'>","border-inline-color":"<'border-top-color'>{1,2}","border-inline-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-end-color":"<'border-top-color'>","border-inline-end-style":"<'border-top-style'>","border-inline-end-width":"<'border-top-width'>","border-inline-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-start-color":"<'border-top-color'>","border-inline-start-style":"<'border-top-style'>","border-inline-start-width":"<'border-top-width'>","border-inline-style":"<'border-top-style'>{1,2}","border-inline-width":"<'border-top-width'>{1,2}","border-left":"<line-width>||<line-style>||<color>","border-left-color":"<color>","border-left-style":"<line-style>","border-left-width":"<line-width>","border-radius":"<length-percentage [0,\u221E]>{1,4} [/ <length-percentage [0,\u221E]>{1,4}]?","border-right":"<line-width>||<line-style>||<color>","border-right-color":"<color>","border-right-style":"<line-style>","border-right-width":"<line-width>","border-spacing":"<length>{1,2}","border-start-end-radius":"<'border-top-left-radius'>","border-start-start-radius":"<'border-top-left-radius'>","border-style":"<line-style>{1,4}","border-top":"<line-width>||<line-style>||<color>","border-top-color":"<color>","border-top-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-style":"<line-style>","border-top-width":"<line-width>","border-width":"<line-width>{1,4}",bottom:"auto|<length-percentage>|<anchor()>|<anchor-size()>","box-align":"start|center|end|baseline|stretch","box-decoration-break":"slice|clone","box-direction":"normal|reverse|inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single|multiple","box-ordinal-group":"<integer>","box-orient":"horizontal|vertical|inline-axis|block-axis|inherit","box-pack":"start|center|end|justify","box-shadow":"none|<shadow>#","box-sizing":"content-box|border-box","break-after":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-before":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-inside":"auto|avoid|avoid-page|avoid-column|avoid-region","caption-side":"top|bottom",caret:"<'caret-color'>||<'caret-animation'>||<'caret-shape'>","caret-animation":"auto|manual","caret-color":"auto|<color>","caret-shape":"auto|bar|block|underscore",clear:"none|left|right|both|inline-start|inline-end",clip:"<shape>|auto","clip-path":"<clip-source>|[<basic-shape>||<geometry-box>]|none","clip-rule":"nonzero|evenodd",color:"<color>","color-interpolation-filters":"auto|sRGB|linearRGB","color-scheme":"normal|[light|dark|<custom-ident>]+&&only?","column-count":"<integer>|auto","column-fill":"auto|balance","column-gap":"normal|<length-percentage>","column-height":"auto|<length [0,\u221E]>","column-rule":"<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>","column-rule-color":"<color>","column-rule-style":"<'border-style'>","column-rule-width":"<'border-width'>","column-span":"none|all","column-width":"auto|<length [0,\u221E]>","column-wrap":"auto|nowrap|wrap",columns:"[<'column-width'>||<'column-count'>] [/ <'column-height'>]?",contain:"none|strict|content|[[size||inline-size]||layout||style||paint]","contain-intrinsic-block-size":"auto? [none|<length>]","contain-intrinsic-height":"auto? [none|<length>]","contain-intrinsic-inline-size":"auto? [none|<length>]","contain-intrinsic-size":"[auto? [none|<length>]]{1,2}","contain-intrinsic-width":"auto? [none|<length>]",container:"<'container-name'> [/ <'container-type'>]?","container-name":"none|<custom-ident>+","container-type":"normal||[size|inline-size]",content:"normal|none|[<content-replacement>|<content-list>] [/ [<string>|<counter>|<attr()>]+]?","content-visibility":"visible|auto|hidden","corner-block-end-shape":"<corner-shape-value>{1,2}","corner-block-start-shape":"<corner-shape-value>{1,2}","corner-bottom-shape":"<corner-shape-value>{1,2}","corner-bottom-left-shape":"<corner-shape-value>","corner-bottom-right-shape":"<corner-shape-value>","corner-end-end-shape":"<corner-shape-value>","corner-end-start-shape":"<corner-shape-value>","corner-inline-end-shape":"<corner-shape-value>{1,2}","corner-inline-start-shape":"<corner-shape-value>{1,2}","corner-left-shape":"<corner-shape-value>{1,2}","corner-right-shape":"<corner-shape-value>{1,2}","corner-shape":"<corner-shape-value>{1,4}","corner-start-start-shape":"<corner-shape-value>","corner-start-end-shape":"<corner-shape-value>","corner-top-shape":"<corner-shape-value>{1,2}","corner-top-left-shape":"<corner-shape-value>","corner-top-right-shape":"<corner-shape-value>","counter-increment":"[<counter-name> <integer>?]+|none","counter-reset":"[<counter-name> <integer>?|<reversed-counter-name> <integer>?]+|none","counter-set":"[<counter-name> <integer>?]+|none",cursor:"[[<url> [<x> <y>]? ,]* [auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing|hand|-webkit-grab|-webkit-grabbing|-webkit-zoom-in|-webkit-zoom-out|-moz-grab|-moz-grabbing|-moz-zoom-in|-moz-zoom-out]]",cx:"<length>|<percentage>",cy:"<length>|<percentage>",d:"none|path( <string> )",direction:"ltr|rtl",display:"[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>","dominant-baseline":"auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge","dynamic-range-limit":"standard|no-limit|constrained|<dynamic-range-limit-mix()>","empty-cells":"show|hide","field-sizing":"content|fixed",fill:"<paint>","fill-opacity":"<number-zero-one>|<percentage>","fill-rule":"nonzero|evenodd",filter:"none|<filter-value-list>|<-ms-filter-function-list>",flex:"none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]","flex-basis":"content|<'width'>","flex-direction":"row|row-reverse|column|column-reverse","flex-flow":"<'flex-direction'>||<'flex-wrap'>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap|wrap|wrap-reverse",float:"left|right|none|inline-start|inline-end","flood-color":"<color>","flood-opacity":"<'opacity'>",font:"[[<'font-style'>||<font-variant-css2>||<'font-weight'>||<font-width-css3>]? <'font-size'> [/ <'line-height'>]? <'font-family'>#]|<system-family-name>|<-non-standard-font>","font-family":"[<family-name>|<generic-family>]#","font-feature-settings":"normal|<feature-tag-value>#","font-kerning":"auto|normal|none","font-language-override":"normal|<string>","font-optical-sizing":"auto|none","font-palette":"normal|light|dark|<palette-identifier>|<palette-mix()>","font-size":"<absolute-size>|<relative-size>|<length-percentage [0,\u221E]>|math","font-size-adjust":"none|[ex-height|cap-height|ch-width|ic-width|ic-height]? [from-font|<number>]","font-smooth":"auto|never|always|<absolute-size>|<length>","font-stretch":"<font-stretch-absolute>","font-style":"normal|italic|oblique <angle>?","font-synthesis":"none|[weight||style||small-caps||position]","font-synthesis-position":"auto|none","font-synthesis-small-caps":"auto|none","font-synthesis-style":"auto|none","font-synthesis-weight":"auto|none","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-alternates":"normal|[stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )]","font-variant-caps":"normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","font-variant-east-asian":"normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-emoji":"normal|text|emoji|unicode","font-variant-ligatures":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]","font-variant-numeric":"normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]","font-variant-position":"normal|sub|super","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>|bolder|lighter","font-width":"normal|<percentage [0,\u221E]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","forced-color-adjust":"auto|none|preserve-parent-color",gap:"<'row-gap'> <'column-gap'>?",grid:"<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>","grid-area":"<grid-line> [/ <grid-line>]{0,3}","grid-auto-columns":"<track-size>+","grid-auto-flow":"[row|column]||dense","grid-auto-rows":"<track-size>+","grid-column":"<grid-line> [/ <grid-line>]?","grid-column-end":"<grid-line>","grid-column-gap":"<length-percentage>","grid-column-start":"<grid-line>","grid-gap":"<'grid-row-gap'> <'grid-column-gap'>?","grid-row":"<grid-line> [/ <grid-line>]?","grid-row-end":"<grid-line>","grid-row-gap":"<length-percentage>","grid-row-start":"<grid-line>","grid-template":"none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?","grid-template-areas":"none|<string>+","grid-template-columns":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","grid-template-rows":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","hanging-punctuation":"none|[first||[force-end|allow-end]||last]",height:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","hyphenate-character":"auto|<string>","hyphenate-limit-chars":"[auto|<integer>]{1,3}",hyphens:"none|manual|auto","image-orientation":"from-image|<angle>|[<angle>? flip]","image-rendering":"auto|crisp-edges|pixelated|smooth|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>","image-resolution":"[from-image||<resolution>]&&snap?","ime-mode":"auto|normal|active|inactive|disabled","initial-letter":"normal|[<number> <integer>?]","initial-letter-align":"[auto|alphabetic|hanging|ideographic]","inline-size":"<'width'>",inset:"<'top'>{1,4}","inset-block":"<'top'>{1,2}","inset-block-end":"<'top'>","inset-block-start":"<'top'>","inset-inline":"<'top'>{1,2}","inset-inline-end":"<'top'>","inset-inline-start":"<'top'>","interpolate-size":"numeric-only|allow-keywords",isolation:"auto|isolate",interactivity:"auto|inert","interest-delay":"<'interest-delay-start'>{1,2}","interest-delay-end":"normal|<time>","interest-delay-start":"normal|<time>","justify-content":"normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]","justify-items":"normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]|anchor-center","justify-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|anchor-center","justify-tracks":"[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",left:"auto|<length-percentage>|<anchor()>|<anchor-size()>","letter-spacing":"normal|<length-percentage>","lighting-color":"<color>","line-break":"auto|loose|normal|strict|anywhere","line-clamp":"none|<integer>","line-height":"normal|<number>|<length>|<percentage>","line-height-step":"<length>","list-style":"<'list-style-type'>||<'list-style-position'>||<'list-style-image'>","list-style-image":"<image>|none","list-style-position":"inside|outside","list-style-type":"<counter-style>|<string>|none",margin:"<'margin-top'>{1,4}","margin-block":"<'margin-top'>{1,2}","margin-block-end":"<'margin-top'>","margin-block-start":"<'margin-top'>","margin-bottom":"<length-percentage>|auto|<anchor-size()>","margin-inline":"<'margin-top'>{1,2}","margin-inline-end":"<'margin-top'>","margin-inline-start":"<'margin-top'>","margin-left":"<length-percentage>|auto|<anchor-size()>","margin-right":"<length-percentage>|auto|<anchor-size()>","margin-top":"<length-percentage>|auto|<anchor-size()>","margin-trim":"none|in-flow|all",marker:"none|<url>","marker-end":"none|<url>","marker-mid":"none|<url>","marker-start":"none|<url>",mask:"<mask-layer>#","mask-border":"<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>","mask-border-mode":"luminance|alpha","mask-border-outset":"[<length>|<number>]{1,4}","mask-border-repeat":"[stretch|repeat|round|space]{1,2}","mask-border-slice":"<number-percentage>{1,4} fill?","mask-border-source":"none|<image>","mask-border-width":"[<length-percentage>|<number>|auto]{1,4}","mask-clip":"[<coord-box>|no-clip]#","mask-composite":"<compositing-operator>#","mask-image":"<mask-reference>#","mask-mode":"<masking-mode>#","mask-origin":"<coord-box>#","mask-position":"<position>#","mask-repeat":"<repeat-style>#","mask-size":"<bg-size>#","mask-type":"luminance|alpha","masonry-auto-flow":"[pack|next]||[definite-first|ordered]","math-depth":"auto-add|add( <integer> )|<integer>","math-shift":"normal|compact","math-style":"normal|compact","max-block-size":"<'max-width'>","max-height":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","max-inline-size":"<'max-width'>","max-lines":"none|<integer>","max-width":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-block-size":"<'min-width'>","min-height":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-inline-size":"<'min-width'>","min-width":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","mix-blend-mode":"<blend-mode>|plus-darker|plus-lighter","object-fit":"fill|contain|cover|none|scale-down","object-position":"<position>","object-view-box":"none|<basic-shape-rect>",offset:"[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?","offset-anchor":"auto|<position>","offset-distance":"<length-percentage>","offset-path":"none|<offset-path>||<coord-box>","offset-position":"normal|auto|<position>","offset-rotate":"[auto|reverse]||<angle>",opacity:"<opacity-value>",order:"<integer>",orphans:"<integer>",outline:"<'outline-width'>||<'outline-style'>||<'outline-color'>","outline-color":"auto|<color>","outline-offset":"<length>","outline-style":"auto|<outline-line-style>","outline-width":"<line-width>",overflow:"[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>","overflow-anchor":"auto|none","overflow-block":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-clip-box":"padding-box|content-box","overflow-clip-margin":"<visual-box>||<length [0,\u221E]>","overflow-inline":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-wrap":"normal|break-word|anywhere","overflow-x":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-y":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>",overlay:"none|auto","overscroll-behavior":"[contain|none|auto]{1,2}","overscroll-behavior-block":"contain|none|auto","overscroll-behavior-inline":"contain|none|auto","overscroll-behavior-x":"contain|none|auto","overscroll-behavior-y":"contain|none|auto",padding:"<'padding-top'>{1,4}","padding-block":"<'padding-top'>{1,2}","padding-block-end":"<'padding-top'>","padding-block-start":"<'padding-top'>","padding-bottom":"<length-percentage [0,\u221E]>","padding-inline":"<'padding-top'>{1,2}","padding-inline-end":"<'padding-top'>","padding-inline-start":"<'padding-top'>","padding-left":"<length-percentage [0,\u221E]>","padding-right":"<length-percentage [0,\u221E]>","padding-top":"<length-percentage [0,\u221E]>",page:"auto|<custom-ident>","page-break-after":"auto|always|avoid|left|right|recto|verso","page-break-before":"auto|always|avoid|left|right|recto|verso","page-break-inside":"auto|avoid","paint-order":"normal|[fill||stroke||markers]",perspective:"none|<length>","perspective-origin":"<position>","place-content":"<'align-content'> <'justify-content'>?","place-items":"<'align-items'> <'justify-items'>?","place-self":"<'align-self'> <'justify-self'>?","pointer-events":"auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",position:"static|relative|absolute|sticky|fixed|-webkit-sticky","position-anchor":"auto|none|<anchor-name>","position-area":"none|<position-area>","position-try":"<'position-try-order'>? <'position-try-fallbacks'>","position-try-fallbacks":"none|[[<dashed-ident>||<try-tactic>]|<'position-area'>]#","position-try-order":"normal|<try-size>","position-visibility":"always|[anchors-valid||anchors-visible||no-overflow]","print-color-adjust":"economy|exact",quotes:"none|auto|[<string> <string>]+",r:"<length>|<percentage>","reading-flow":"normal|source-order|flex-visual|flex-flow|grid-rows|grid-columns|grid-order","reading-order":"<integer>",resize:"none|both|horizontal|vertical|block|inline",right:"auto|<length-percentage>|<anchor()>|<anchor-size()>",rotate:"none|<angle>|[x|y|z|<number>{3}]&&<angle>","row-gap":"normal|<length-percentage>","ruby-align":"start|center|space-between|space-around","ruby-merge":"separate|collapse|auto","ruby-overhang":"auto|none","ruby-position":"[alternate||[over|under]]|inter-character",rx:"<length>|<percentage>",ry:"<length>|<percentage>",scale:"none|[<number>|<percentage>]{1,3}","scroll-behavior":"auto|smooth","scroll-initial-target":"none|nearest","scroll-margin":"<length>{1,4}","scroll-margin-block":"<length>{1,2}","scroll-margin-block-end":"<length>","scroll-margin-block-start":"<length>","scroll-margin-bottom":"<length>","scroll-margin-inline":"<length>{1,2}","scroll-margin-inline-end":"<length>","scroll-margin-inline-start":"<length>","scroll-margin-left":"<length>","scroll-margin-right":"<length>","scroll-margin-top":"<length>","scroll-marker-group":"none|before|after","scroll-padding":"[auto|<length-percentage>]{1,4}","scroll-padding-block":"[auto|<length-percentage>]{1,2}","scroll-padding-block-end":"auto|<length-percentage>","scroll-padding-block-start":"auto|<length-percentage>","scroll-padding-bottom":"auto|<length-percentage>","scroll-padding-inline":"[auto|<length-percentage>]{1,2}","scroll-padding-inline-end":"auto|<length-percentage>","scroll-padding-inline-start":"auto|<length-percentage>","scroll-padding-left":"auto|<length-percentage>","scroll-padding-right":"auto|<length-percentage>","scroll-padding-top":"auto|<length-percentage>","scroll-snap-align":"[none|start|end|center]{1,2}","scroll-snap-coordinate":"none|<position>#","scroll-snap-destination":"<position>","scroll-snap-points-x":"none|repeat( <length-percentage> )","scroll-snap-points-y":"none|repeat( <length-percentage> )","scroll-snap-stop":"normal|always","scroll-snap-type":"none|[x|y|block|inline|both] [mandatory|proximity]?","scroll-snap-type-x":"none|mandatory|proximity","scroll-snap-type-y":"none|mandatory|proximity","scroll-target-group":"none|auto","scroll-timeline":"[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#","scroll-timeline-axis":"[block|inline|x|y]#","scroll-timeline-name":"[none|<dashed-ident>]#","scrollbar-color":"auto|<color>{2}","scrollbar-gutter":"auto|stable&&both-edges?","scrollbar-width":"auto|thin|none","shape-image-threshold":"<opacity-value>","shape-margin":"<length-percentage>","shape-outside":"none|[<shape-box>||<basic-shape>]|<image>","shape-rendering":"auto|optimizeSpeed|crispEdges|geometricPrecision","speak-as":"normal|spell-out||digits||[literal-punctuation|no-punctuation]","stop-color":"<'color'>","stop-opacity":"<'opacity'>",stroke:"<paint>","stroke-color":"<color>","stroke-dasharray":"none|[<svg-length>+]#","stroke-dashoffset":"<svg-length>","stroke-linecap":"butt|round|square","stroke-linejoin":"miter|round|bevel","stroke-miterlimit":"<number-one-or-greater>","stroke-opacity":"<'opacity'>","stroke-width":"<svg-length>","tab-size":"<integer>|<length>","table-layout":"auto|fixed","text-align":"start|end|left|right|center|justify|match-parent","text-align-last":"auto|start|end|left|right|center|justify","text-anchor":"start|middle|end","text-autospace":"normal|<autospace>|auto","text-box":"normal|<'text-box-trim'>||<'text-box-edge'>","text-box-edge":"auto|<text-edge>","text-box-trim":"none|trim-start|trim-end|trim-both","text-combine-upright":"none|all|[digits <integer>?]","text-decoration":"<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>","text-decoration-color":"<color>","text-decoration-inset":"<length>{1,2}|auto","text-decoration-line":"none|[underline||overline||line-through||blink]|spelling-error|grammar-error","text-decoration-skip":"none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]","text-decoration-skip-ink":"auto|all|none","text-decoration-style":"solid|double|dotted|dashed|wavy","text-decoration-thickness":"auto|from-font|<length>|<percentage>","text-emphasis":"<'text-emphasis-style'>||<'text-emphasis-color'>","text-emphasis-color":"<color>","text-emphasis-position":"auto|[over|under]&&[right|left]?","text-emphasis-style":"none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>","text-indent":"<length-percentage>&&hanging?&&each-line?","text-justify":"auto|inter-character|inter-word|none","text-orientation":"mixed|upright|sideways","text-overflow":"[clip|ellipsis|<string>]{1,2}","text-rendering":"auto|optimizeSpeed|optimizeLegibility|geometricPrecision","text-shadow":"none|<shadow-t>#","text-size-adjust":"none|auto|<percentage>","text-spacing-trim":"space-all|normal|space-first|trim-start","text-transform":"none|[capitalize|uppercase|lowercase]||full-width||full-size-kana|math-auto","text-underline-offset":"auto|<length>|<percentage>","text-underline-position":"auto|from-font|[under||[left|right]]","text-wrap":"<'text-wrap-mode'>||<'text-wrap-style'>","text-wrap-mode":"wrap|nowrap","text-wrap-style":"auto|balance|stable|pretty","timeline-scope":"none|<dashed-ident>#","timeline-trigger":"none|[<'timeline-trigger-name'> <'timeline-trigger-source'> <'timeline-trigger-range'> ['/' <'timeline-trigger-exit-range'>]?]#","timeline-trigger-name":"none|<dashed-ident>#","timeline-trigger-exit-range":"[<'timeline-trigger-exit-range-start'> <'timeline-trigger-exit-range-end'>?]#","timeline-trigger-exit-range-end":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-exit-range-start":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range":"[<'timeline-trigger-range-start'> <'timeline-trigger-range-end'>?]#","timeline-trigger-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-source":"<single-animation-timeline>#",top:"auto|<length-percentage>|<anchor()>|<anchor-size()>","touch-action":"auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",transform:"none|<transform-list>","transform-box":"content-box|border-box|fill-box|stroke-box|view-box","transform-origin":"[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?","transform-style":"flat|preserve-3d",transition:"<single-transition>#","transition-behavior":"<transition-behavior-value>#","transition-delay":"<time>#","transition-duration":"<time>#","transition-property":"none|<single-transition-property>#","transition-timing-function":"<easing-function>#",translate:"none|<length-percentage> [<length-percentage> <length>?]?","trigger-scope":"none|all|<dashed-ident>#","unicode-bidi":"normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext","user-select":"auto|text|none|all","vector-effect":"none|non-scaling-stroke|non-scaling-size|non-rotation|fixed-position","vertical-align":"baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>","view-timeline":"[<'view-timeline-name'> [<'view-timeline-axis'>||<'view-timeline-inset'>]?]#","view-timeline-axis":"[block|inline|x|y]#","view-timeline-inset":"[[auto|<length-percentage>]{1,2}]#","view-timeline-name":"[none|<dashed-ident>]#","view-transition-class":"none|<custom-ident>+","view-transition-name":"none|<custom-ident>|match-element",visibility:"visible|hidden|collapse","white-space":"normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>","white-space-collapse":"collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",widows:"<integer>",width:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","will-change":"auto|<animateable-feature>#","word-break":"normal|break-all|keep-all|break-word|auto-phrase","word-spacing":"normal|<length>","word-wrap":"normal|break-word","writing-mode":"horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>",x:"<length>|<percentage>",y:"<length>|<percentage>","z-index":"auto|<integer>",zoom:"normal|reset|<number [0,\u221E]>||<percentage [0,\u221E]>","-moz-background-clip":"padding|border","-moz-border-radius-bottomleft":"<'border-bottom-left-radius'>","-moz-border-radius-bottomright":"<'border-bottom-right-radius'>","-moz-border-radius-topleft":"<'border-top-left-radius'>","-moz-border-radius-topright":"<'border-bottom-right-radius'>","-moz-control-character-visibility":"visible|hidden","-moz-osx-font-smoothing":"auto|grayscale","-moz-user-select":"none|text|all|-moz-none","-ms-flex-align":"start|end|center|baseline|stretch","-ms-flex-item-align":"auto|start|end|center|baseline|stretch","-ms-flex-line-pack":"start|end|center|justify|distribute|stretch","-ms-flex-negative":"<'flex-shrink'>","-ms-flex-pack":"start|end|center|justify|distribute","-ms-flex-order":"<integer>","-ms-flex-positive":"<'flex-grow'>","-ms-flex-preferred-size":"<'flex-basis'>","-ms-interpolation-mode":"nearest-neighbor|bicubic","-ms-grid-column-align":"start|end|center|stretch","-ms-grid-row-align":"start|end|center|stretch","-ms-hyphenate-limit-last":"none|always|column|page|spread","-webkit-background-clip":"[<visual-box>|border|padding|content|text]#","-webkit-column-break-after":"always|auto|avoid","-webkit-column-break-before":"always|auto|avoid","-webkit-column-break-inside":"always|auto|avoid","-webkit-font-smoothing":"auto|none|antialiased|subpixel-antialiased","-webkit-mask-box-image":"[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?","-webkit-print-color-adjust":"economy|exact","-webkit-text-security":"none|circle|disc|square","-webkit-user-drag":"none|element|auto",behavior:"<url>+",cue:"<'cue-before'> <'cue-after'>?","cue-after":"<url> <decibel>?|none","cue-before":"<url> <decibel>?|none","glyph-orientation-horizontal":"<angle>","glyph-orientation-vertical":"<angle>",kerning:"auto|<svg-length>",pause:"<'pause-before'> <'pause-after'>?","pause-after":"<time>|none|x-weak|weak|medium|strong|x-strong","pause-before":"<time>|none|x-weak|weak|medium|strong|x-strong","position-try-options":"<'position-try-fallbacks'>",rest:"<'rest-before'> <'rest-after'>?","rest-after":"<time>|none|x-weak|weak|medium|strong|x-strong","rest-before":"<time>|none|x-weak|weak|medium|strong|x-strong",speak:"auto|never|always","voice-balance":"<number>|left|center|right|leftwards|rightwards","voice-duration":"auto|<time>","voice-family":"[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve","voice-pitch":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-range":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-rate":"[normal|x-slow|slow|medium|fast|x-fast]||<percentage>","voice-stress":"normal|strong|moderate|none|reduced","voice-volume":"silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]","white-space-trim":"none|discard-before||discard-after||discard-inner"},atrules:{charset:{prelude:"<string>",descriptors:null},"counter-style":{prelude:"<counter-style-name>",descriptors:{"additive-symbols":"[<integer [0,\u221E]>&&<symbol>]#",fallback:"<counter-style-name>",negative:"<symbol> <symbol>?",pad:"<integer [0,\u221E]>&&<symbol>",prefix:"<symbol>",range:"[[<integer>|infinite]{2}]#|auto","speak-as":"auto|bullets|numbers|words|spell-out|<counter-style-name>",suffix:"<symbol>",symbols:"<symbol>+",system:"cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"}},container:{prelude:"[<container-name>]? <container-condition>",descriptors:null},document:{prelude:"[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",descriptors:null},"font-face":{prelude:null,descriptors:{"ascent-override":"normal|<percentage>","descent-override":"normal|<percentage>","font-display":"auto|block|swap|fallback|optional","font-family":"<family-name>","font-feature-settings":"normal|<feature-tag-value>#","font-stretch":"<font-stretch-absolute>{1,2}","font-style":"normal|italic|oblique <angle>{0,2}","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>{1,2}","line-gap-override":"normal|<percentage>","size-adjust":"<percentage>",src:"[<url> [format( <string># )]?|local( <family-name> )]#","unicode-range":"<urange>#"}},"font-feature-values":{prelude:"<family-name>#",descriptors:null},"font-palette-values":{prelude:"<dashed-ident>",descriptors:{"base-palette":"light|dark|<integer [0,\u221E]>","font-family":"<family-name>#","override-colors":"[<integer [0,\u221E]> <color>]#"}},import:{prelude:"[<string>|<url>] [layer|layer( <layer-name> )]? [supports( [<supports-condition>|<declaration>] )]? <media-query-list>?",descriptors:null},keyframes:{prelude:"<keyframes-name>",descriptors:null},layer:{prelude:"[<layer-name>#|<layer-name>?]",descriptors:null},media:{prelude:"<media-query-list>",descriptors:null},namespace:{prelude:"<namespace-prefix>? [<string>|<url>]",descriptors:null},page:{prelude:"<page-selector-list>",descriptors:{bleed:"auto|<length>",marks:"none|[crop||cross]","page-orientation":"upright|rotate-left|rotate-right",size:"<length [0,\u221E]>{1,2}|auto|[<page-size>||[portrait|landscape]]"}},"position-try":{prelude:"<dashed-ident>",descriptors:{top:"<'top'>",left:"<'left'>",bottom:"<'bottom'>",right:"<'right'>","inset-block-start":"<'inset-block-start'>","inset-block-end":"<'inset-block-end'>","inset-inline-start":"<'inset-inline-start'>","inset-inline-end":"<'inset-inline-end'>","inset-block":"<'inset-block'>","inset-inline":"<'inset-inline'>",inset:"<'inset'>","margin-top":"<'margin-top'>","margin-left":"<'margin-left'>","margin-bottom":"<'margin-bottom'>","margin-right":"<'margin-right'>","margin-block-start":"<'margin-block-start'>","margin-block-end":"<'margin-block-end'>","margin-inline-start":"<'margin-inline-start'>","margin-inline-end":"<'margin-inline-end'>",margin:"<'margin'>","margin-block":"<'margin-block'>","margin-inline":"<'margin-inline'>",width:"<'width'>",height:"<'height'>","min-width":"<'min-width'>","min-height":"<'min-height'>","max-width":"<'max-width'>","max-height":"<'max-height'>","block-size":"<'block-size'>","inline-size":"<'inline-size'>","min-block-size":"<'min-block-size'>","min-inline-size":"<'min-inline-size'>","max-block-size":"<'max-block-size'>","max-inline-size":"<'max-inline-size'>","align-self":"<'align-self'>|anchor-center","justify-self":"<'justify-self'>|anchor-center"}},property:{prelude:"<custom-property-name>",descriptors:{inherits:"true|false","initial-value":"<declaration-value>?",syntax:"<string>"}},scope:{prelude:"[( <scope-start> )]? [to ( <scope-end> )]?",descriptors:null},"starting-style":{prelude:null,descriptors:null},supports:{prelude:"<supports-condition>",descriptors:null},"view-transition":{prelude:null,descriptors:{navigation:"auto|none",types:"none|<custom-ident>+"}},"font-features-values":{prelude:"[<string>|<custom-ident>]+",descriptors:{"font-display":"auto|block|swap|fallback|optional"}}}}});var fp={};ye(fp,{generate:()=>fP,name:()=>pP,parse:()=>dp,structure:()=>dP});function yl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Lr||r===Gn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)_t(this.charCodeAt(n))||this.error("Integer is expected",n)}function bi(e){return yl.call(this,0,e)}function po(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case xl:n="N is expected";break;case Gn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function pp(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Lr,e)||this.isDelim(Gn,e)){t=this.isDelim(Lr,e)?Lr:Gn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),bi.call(this,Oo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Lr&&n!==Gn&&this.error("Number sign is expected")),bi.call(this,t!==0),t===Gn?"-"+this.consume(10):this.consume(10)}function dp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)bi.call(this,uP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Gn))switch(t="-1",po.call(this,1,xl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=pp.call(this);break;case 3:po.call(this,2,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,2,Gn),yl.call(this,3,Oo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Lr)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Lr)&&(r=1,this.next()),po.call(this,0,xl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=pp.call(this);break;case 2:po.call(this,1,Gn),this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10);break;default:po.call(this,1,Gn),yl.call(this,2,Oo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Lr||r===Gn,i=this.tokenStart+o;for(;i<this.tokenEnd&&_t(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),po.call(this,i-this.tokenStart,xl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=pp.call(this)):(po.call(this,i-this.tokenStart+1,Gn),i+2===this.tokenEnd?(this.next(),this.skipSC(),bi.call(this,Oo),n="-"+this.consume(10)):(yl.call(this,i-this.tokenStart+2,Oo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Lr&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Lr&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function fP(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let n=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+n)}else this.tokenize(t)}else this.tokenize(e.b)}var Lr,Gn,xl,Oo,uP,pP,dP,gp=$(()=>{"use strict";nr();Lr=43,Gn=45,xl=110,Oo=!0,uP=!1;pP="AnPlusB",dP={a:[String,null],b:[String,null]}});var hp={};ye(hp,{generate:()=>yP,name:()=>mP,parse:()=>mp,structure:()=>xP,walkContext:()=>hP});function d0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function gP(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}function mp(e=!1){let t=this.tokenStart,n,r,o=null,i=null;switch(this.eat(3),n=this.substrToCursor(t+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==23&&this.tokenType!==17&&(this.parseAtrulePrelude?o=this.parseWithFallback(this.AtrulePrelude.bind(this,n,e),d0):o=d0.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?i=this.atrule[r].block.call(this,e):i=this.Block(gP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function yP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var mP,hP,xP,xp=$(()=>{"use strict";mP="Atrule",hP="atrule",xP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var bp={};ye(bp,{generate:()=>vP,name:()=>bP,parse:()=>yp,structure:()=>wP,walkContext:()=>SP});function yp(e){let t=null;return e!==null&&(e=e.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,e)&&typeof this.atrule[e].prelude=="function"?t=this.atrule[e].prelude.call(this):t=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==23&&this.tokenType!==17&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(t),children:t}}function vP(e){this.children(e)}var bP,SP,wP,Sp=$(()=>{"use strict";bP="AtrulePrelude",SP="atrulePrelude",wP={children:[[]]}});var kp={};ye(kp,{generate:()=>PP,name:()=>EP,parse:()=>vp,structure:()=>AP});function IP(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(f0)?(t=!0,this.next()):this.isDelim(wp)||this.eat(1),this.isDelim(wp)?this.charCodeAt(this.tokenStart+1)!==bl?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function FP(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==bl&&t!==TP&&t!==CP&&t!==kP&&t!==f0&&t!==wp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==bl&&(this.isDelim(bl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function vp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=IP.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=FP.call(this),this.skipSC(),r=this.tokenType===5?this.String():this.Identifier(),this.skipSC()),this.tokenType===1&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:n,value:r,flags:o}}function PP(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]")}var kP,f0,bl,CP,wp,TP,EP,AP,Cp=$(()=>{"use strict";kP=36,f0=42,bl=61,CP=94,wp=124,TP=126;EP="AttributeSelector",AP={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Ip={};ye(Ip,{generate:()=>zP,name:()=>BP,parse:()=>Tp,structure:()=>RP,walkContext:()=>DP});function h0(){return this.Raw(null,!0)}function g0(){return this.parseWithFallback(this.Rule,h0)}function m0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function MP(){if(this.tokenType===17)return m0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,m0);return this.tokenType===17&&this.next(),e}function Tp(e){let t=e?MP:g0,n=this.tokenStart,r=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:r.push(this.parseWithFallback(this.Atrule.bind(this,e),h0));break;default:e&&this.isDelim(LP)?r.push(g0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function zP(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var LP,BP,DP,RP,Fp=$(()=>{"use strict";LP=38;BP="Block",DP="block",RP={children:[["Atrule","Rule","Declaration"]]}});var Ap={};ye(Ap,{generate:()=>_P,name:()=>NP,parse:()=>Ep,structure:()=>OP});function Ep(e,t){let n=this.tokenStart,r=null;return this.eat(19),r=e.call(this,t),this.eof||this.eat(20),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function _P(e){this.token(9,"["),this.children(e),this.token(9,"]")}var NP,OP,Pp=$(()=>{"use strict";NP="Brackets",OP={children:[[]]}});var Mp={};ye(Mp,{generate:()=>jP,name:()=>$P,parse:()=>Lp,structure:()=>UP});function Lp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function jP(){this.token(15,"-->")}var $P,UP,Bp=$(()=>{"use strict";$P="CDC",UP=[]});var Rp={};ye(Rp,{generate:()=>VP,name:()=>HP,parse:()=>Dp,structure:()=>WP});function Dp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function VP(){this.token(14,"<!--")}var HP,WP,zp=$(()=>{"use strict";HP="CDO",WP=[]});var Op={};ye(Op,{generate:()=>KP,name:()=>qP,parse:()=>Np,structure:()=>YP});function Np(){return this.eatDelim(GP),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function KP(e){this.token(9,"."),this.token(1,e.name)}var GP,qP,YP,_p=$(()=>{"use strict";GP=46,qP="ClassSelector",YP={name:String}});var Up={};ye(Up,{generate:()=>t2,name:()=>ZP,parse:()=>$p,structure:()=>e2});function $p(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case QP:case XP:case JP:this.next();break;case x0:this.next(),this.eatIdent("deep"),this.eatDelim(x0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function t2(e){this.tokenize(e.name)}var XP,x0,QP,JP,ZP,e2,jp=$(()=>{"use strict";XP=43,x0=47,QP=62,JP=126,ZP="Combinator",e2={name:String}});var Wp={};ye(Wp,{generate:()=>s2,name:()=>o2,parse:()=>Hp,structure:()=>i2});function Hp(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===n2&&this.charCodeAt(t-1)===r2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function s2(e){this.token(25,"/*"+e.value+"*/")}var n2,r2,o2,i2,Vp=$(()=>{"use strict";n2=42,r2=47,o2="Comment",i2={value:String}});var qp={};ye(qp,{generate:()=>p2,name:()=>l2,parse:()=>Gp,structure:()=>c2});function y0(e){return this.lookupTypeNonSC(1)===1&&a2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function Gp(e="media"){let t=this.createList();e:for(;!this.eof;)switch(this.tokenType){case 25:case 13:this.next();continue;case 1:t.push(this.Identifier());break;case 21:{let n=this.parseWithFallback(()=>u2[e].call(this,e),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(21);let r=this.Condition(e);return this.eat(22),r},()=>this.GeneralEnclosed(e))),t.push(n);break}case 2:{let n=this.parseWithFallback(()=>this.FeatureFunction(e),()=>null);n||(n=this.GeneralEnclosed(e)),t.push(n);break}default:break e}return t.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(t),kind:e,children:t}}function p2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var a2,l2,c2,u2,Yp=$(()=>{"use strict";a2=new Set([16,22,0]),l2="Condition",c2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};u2={media:y0,container:y0,supports(){return this.SupportsDeclaration()}}});var Xp={};ye(Xp,{generate:()=>k2,name:()=>S2,parse:()=>Kp,structure:()=>v2,walkContext:()=>w2});function x2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function y2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function b2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(S0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function Kp(){let e=this.tokenStart,t=this.tokenIndex,n=C2.call(this),r=il(n),o=r?this.parseCustomProperty:this.parseValue,i=r?y2:x2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(b2,i):a=i.call(this,this.tokenIndex),r&&a.type==="Value"&&a.children.isEmpty){for(let c=u-this.tokenIndex;c<=0;c++)if(this.lookupType(c)===13){a.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(S0)&&(s=T2.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==17&&this.isBalanceEdge(t)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(e,this.tokenStart),important:s,property:n,value:a}}function k2(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important))}function C2(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case m2:case f2:case h2:case d2:case g2:this.next();break;case b0:this.next(),this.isDelim(b0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function T2(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var S0,d2,f2,g2,m2,h2,b0,S2,w2,v2,Qp=$(()=>{"use strict";sl();S0=33,d2=35,f2=36,g2=38,m2=42,h2=43,b0=47;S2="Declaration",w2="declaration",v2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var ed={};ye(ed,{generate:()=>A2,name:()=>F2,parse:()=>Zp,structure:()=>E2});function Jp(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Zp(){let e=this.createList();for(;!this.eof;)switch(this.tokenType){case 13:case 25:case 17:this.next();break;case 3:e.push(this.parseWithFallback(this.Atrule.bind(this,!0),Jp));break;default:this.isDelim(I2)?e.push(this.parseWithFallback(this.Rule,Jp)):e.push(this.parseWithFallback(this.Declaration,Jp))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function A2(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var I2,F2,E2,td=$(()=>{"use strict";I2=38;F2="DeclarationList",E2={children:[["Declaration","Atrule","Rule"]]}});var rd={};ye(rd,{generate:()=>M2,name:()=>P2,parse:()=>nd,structure:()=>L2});function nd(){let e=this.tokenStart,t=this.consumeNumber(12);return{type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function M2(e){this.token(12,e.value+e.unit)}var P2,L2,od=$(()=>{"use strict";P2="Dimension",L2={value:String,unit:String}});var sd={};ye(sd,{generate:()=>z2,name:()=>D2,parse:()=>id,structure:()=>R2});function id(e){let t=this.tokenStart,n,r=null;if(this.eat(21),this.skipSC(),n=this.consume(1),this.skipSC(),this.tokenType!==22){switch(this.eat(16),this.skipSC(),this.tokenType){case 10:this.lookupNonWSType(1)===9?r=this.Ratio():r=this.Number();break;case 12:r=this.Dimension();break;case 1:r=this.Identifier();break;case 2:r=this.parseWithFallback(()=>{let o=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(B2)&&this.error(),o},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(22),{type:"Feature",loc:this.getLocation(t,this.tokenStart),kind:e,name:n,value:r}}function z2(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var B2,D2,R2,ad=$(()=>{"use strict";B2=47,D2="Feature",R2={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var cd={};ye(cd,{generate:()=>$2,name:()=>N2,parse:()=>ld,structure:()=>O2});function _2(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function ld(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=_2.call(this,e,n.toLowerCase());this.skipSC();let o=this.parseWithFallback(()=>{let i=this.tokenIndex,s=r.call(this);return this.eof===!1&&this.isBalanceEdge(i)===!1&&this.error(),s},()=>this.Raw(null,!1));return this.eof||this.eat(22),{type:"FeatureFunction",loc:this.getLocation(t,this.tokenStart),kind:e,feature:n,value:o}}function $2(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var N2,O2,ud=$(()=>{"use strict";N2="FeatureFunction",O2={kind:String,feature:String,value:["Declaration","Selector"]}});var fd={};ye(fd,{generate:()=>V2,name:()=>H2,parse:()=>dd,structure:()=>W2});function pd(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(w0,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case 12:return this.Dimension();case 1:return this.Identifier();case 2:return this.parseWithFallback(()=>{let e=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(w0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function k0(e){if(this.skipSC(),this.isDelim(U2)||this.isDelim(j2)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(v0)?(this.next(),t+"="):t}if(this.isDelim(v0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function dd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=pd.call(this),r=k0.call(this,n.type==="Identifier"),o=pd.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=k0.call(this),s=pd.call(this)),this.skipSC(),this.eat(22),{type:"FeatureRange",loc:this.getLocation(t,this.tokenStart),kind:e,left:n,leftComparison:r,middle:o,rightComparison:i,right:s}}function V2(e){this.token(21,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(22,")")}var w0,U2,v0,j2,H2,W2,gd=$(()=>{"use strict";w0=47,U2=60,v0=61,j2=62,H2="FeatureRange",W2={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]}});var hd={};ye(hd,{generate:()=>K2,name:()=>G2,parse:()=>md,structure:()=>Y2,walkContext:()=>q2});function md(e,t){let n=this.tokenStart,r=this.consumeFunctionName(),o=r.toLowerCase(),i;return i=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:i}}function K2(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var G2,q2,Y2,xd=$(()=>{"use strict";G2="Function",q2="function",Y2={name:String,children:[[]]}});var bd={};ye(bd,{generate:()=>J2,name:()=>X2,parse:()=>yd,structure:()=>Q2});function yd(e){let t=this.tokenStart,n=null;this.tokenType===2?n=this.consumeFunctionName():this.eat(21);let r=this.parseWithFallback(()=>{let o=this.tokenIndex,i=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),i},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(22),{type:"GeneralEnclosed",loc:this.getLocation(t,this.tokenStart),kind:e,function:n,children:r}}function J2(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var X2,Q2,Sd=$(()=>{"use strict";X2="GeneralEnclosed",Q2={kind:String,function:[String,null],children:[[]]}});var vd={};ye(vd,{generate:()=>nL,name:()=>eL,parse:()=>wd,structure:()=>tL,xxx:()=>Z2});function wd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function nL(e){this.token(4,"#"+e.value)}var Z2,eL,tL,kd=$(()=>{"use strict";Z2="XXX",eL="Hash",tL={value:String}});var Td={};ye(Td,{generate:()=>iL,name:()=>rL,parse:()=>Cd,structure:()=>oL});function Cd(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function iL(e){this.token(1,e.name)}var rL,oL,Id=$(()=>{"use strict";rL="Identifier",oL={name:String}});var Ed={};ye(Ed,{generate:()=>lL,name:()=>sL,parse:()=>Fd,structure:()=>aL});function Fd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function lL(e){this.token(9,"#"+e.name)}var sL,aL,Ad=$(()=>{"use strict";sL="IdSelector",aL={name:String}});var Ld={};ye(Ld,{generate:()=>dL,name:()=>uL,parse:()=>Pd,structure:()=>pL});function Pd(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(cL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function dL(e){this.tokenize(e.name)}var cL,uL,pL,Md=$(()=>{"use strict";cL=46,uL="Layer",pL={name:String}});var Dd={};ye(Dd,{generate:()=>mL,name:()=>fL,parse:()=>Bd,structure:()=>gL});function Bd(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.Layer()),this.lookupTypeNonSC(0)===18);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(e),children:e}}function mL(e){this.children(e,()=>this.token(18,","))}var fL,gL,Rd=$(()=>{"use strict";fL="LayerList",gL={children:[["Layer"]]}});var Nd={};ye(Nd,{generate:()=>yL,name:()=>hL,parse:()=>zd,structure:()=>xL});function zd(){let e=this.tokenStart,t=null,n=null,r=null;if(this.skipSC(),this.tokenType===1&&this.lookupTypeNonSC(1)!==21){let o=this.consume(1),i=o.toLowerCase();switch(i==="not"||i==="only"?(this.skipSC(),t=i,n=this.consume(1)):n=o,this.lookupTypeNonSC(0)){case 1:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case 23:case 17:case 18:case 0:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case 1:case 21:case 2:{r=this.Condition("media");break}case 23:case 17:case 0:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:r}}function yL(e){e.mediaType?(e.modifier&&this.token(1,e.modifier),this.token(1,e.mediaType),e.condition&&(this.token(1,"and"),this.node(e.condition))):e.condition&&this.node(e.condition)}var hL,xL,Od=$(()=>{"use strict";hL="MediaQuery",xL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var $d={};ye($d,{generate:()=>wL,name:()=>bL,parse:()=>_d,structure:()=>SL});function _d(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),this.tokenType===18);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function wL(e){this.children(e,()=>this.token(18,","))}var bL,SL,Ud=$(()=>{"use strict";bL="MediaQueryList",SL={children:[["MediaQuery"]]}});var Hd={};ye(Hd,{generate:()=>TL,name:()=>kL,parse:()=>jd,structure:()=>CL});function jd(){let e=this.tokenStart;return this.eatDelim(vL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function TL(){this.token(9,"&")}var vL,kL,CL,Wd=$(()=>{"use strict";vL=38,kL="NestingSelector",CL={}});var Gd={};ye(Gd,{generate:()=>EL,name:()=>IL,parse:()=>Vd,structure:()=>FL});function Vd(){this.skipSC();let e=this.tokenStart,t=e,n=null,r;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?r=this.Identifier():r=this.AnPlusB(),t=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),n=this.SelectorList(),t=this.tokenStart),{type:"Nth",loc:this.getLocation(e,t),nth:r,selector:n}}function EL(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var IL,FL,qd=$(()=>{"use strict";IL="Nth",FL={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var Kd={};ye(Kd,{generate:()=>LL,name:()=>AL,parse:()=>Yd,structure:()=>PL});function Yd(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function LL(e){this.token(10,e.value)}var AL,PL,Xd=$(()=>{"use strict";AL="Number",PL={value:String}});var Jd={};ye(Jd,{generate:()=>DL,name:()=>ML,parse:()=>Qd,structure:()=>BL});function Qd(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function DL(e){this.tokenize(e.value)}var ML,BL,Zd=$(()=>{"use strict";ML="Operator",BL={value:String}});var tf={};ye(tf,{generate:()=>NL,name:()=>RL,parse:()=>ef,structure:()=>zL});function ef(e,t){let n=this.tokenStart,r=null;return this.eat(21),r=e.call(this,t),this.eof||this.eat(22),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:r}}function NL(e){this.token(21,"("),this.children(e),this.token(22,")")}var RL,zL,nf=$(()=>{"use strict";RL="Parentheses",zL={children:[[]]}});var of={};ye(of,{generate:()=>$L,name:()=>OL,parse:()=>rf,structure:()=>_L});function rf(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function $L(e){this.token(11,e.value+"%")}var OL,_L,sf=$(()=>{"use strict";OL="Percentage",_L={value:String}});var lf={};ye(lf,{generate:()=>WL,name:()=>UL,parse:()=>af,structure:()=>HL,walkContext:()=>jL});function af(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function WL(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var UL,jL,HL,cf=$(()=>{"use strict";UL="PseudoClassSelector",jL="function",HL={name:String,children:[["Raw"],null]}});var pf={};ye(pf,{generate:()=>YL,name:()=>VL,parse:()=>uf,structure:()=>qL,walkContext:()=>GL});function uf(){let e=this.tokenStart,t=null,n,r;return this.eat(16),this.eat(16),this.tokenType===2?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),t=this.pseudo[r].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):n=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:n,children:t}}function YL(e){this.token(16,":"),this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var VL,GL,qL,df=$(()=>{"use strict";VL="PseudoElementSelector",GL="function",qL={name:String,children:[["Raw"],null]}});var gf={};ye(gf,{generate:()=>QL,name:()=>KL,parse:()=>ff,structure:()=>XL});function T0(){switch(this.skipSC(),this.tokenType){case 10:return this.Number();case 2:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}function ff(){let e=this.tokenStart,t=T0.call(this),n=null;return this.skipSC(),this.isDelim(C0)&&(this.eatDelim(C0),n=T0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function QL(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var C0,KL,XL,mf=$(()=>{"use strict";C0=47;KL="Ratio",XL={left:["Number","Function"],right:["Number","Function",null]}});var xf={};ye(xf,{generate:()=>tM,name:()=>ZL,parse:()=>hf,structure:()=>eM});function JL(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function hf(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=JL.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function tM(e){this.tokenize(e.value)}var ZL,eM,yf=$(()=>{"use strict";ZL="Raw",eM={value:String}});var Sf={};ye(Sf,{generate:()=>sM,name:()=>rM,parse:()=>bf,structure:()=>iM,walkContext:()=>oM});function I0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function nM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function bf(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(nM,I0):n=I0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function sM(e){this.node(e.prelude),this.node(e.block)}var rM,oM,iM,wf=$(()=>{"use strict";rM="Rule",oM="rule",iM={prelude:["SelectorList","Raw"],block:["Block"]}});var kf={};ye(kf,{generate:()=>cM,name:()=>aM,parse:()=>vf,structure:()=>lM});function vf(){let e=null,t=null;this.skipSC();let n=this.tokenStart;return this.tokenType===21&&(this.next(),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),this.lookupNonWSType(0)===1&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(21),this.skipSC(),t=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(22)),{type:"Scope",loc:this.getLocation(n,this.tokenStart),root:e,limit:t}}function cM(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}var aM,lM,Cf=$(()=>{"use strict";aM="Scope",lM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var If={};ye(If,{generate:()=>dM,name:()=>uM,parse:()=>Tf,structure:()=>pM});function Tf(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function dM(e){this.children(e)}var uM,pM,Ff=$(()=>{"use strict";uM="Selector",pM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Af={};ye(Af,{generate:()=>hM,name:()=>fM,parse:()=>Ef,structure:()=>mM,walkContext:()=>gM});function Ef(){let e=this.createList();for(;!this.eof;){if(e.push(this.Selector()),this.tokenType===18){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function hM(e){this.children(e,()=>this.token(18,","))}var fM,gM,mM,Pf=$(()=>{"use strict";fM="SelectorList",gM="selector",mM={children:[["Selector","Raw"]]}});function Sl(e){let t=e.length,n=e.charCodeAt(0),r=n===F0||n===E0?1:0,o=r===1&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1,i="";for(let s=r;s<=o;s++){let a=e.charCodeAt(s);if(a===Lf){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),An(Lf,a)){let u=s-1,c=Ur(e,u);s=c-1,i+=Ha(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function A0(e,t){let n=t?"'":'"',r=t?E0:F0,o="",i=!1;for(let s=0;s<e.length;s++){let a=e.charCodeAt(s);if(a===0){o+="\uFFFD";continue}if(a<=31||a===127){o+="\\"+a.toString(16),i=!0;continue}a===r||a===Lf?(o+="\\"+e.charAt(s),i=!1):(i&&(Pn(a)||Ar(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var Lf,F0,E0,wl=$(()=>{"use strict";nr();Lf=92,F0=34,E0=39});var Bf={};ye(Bf,{generate:()=>bM,name:()=>xM,parse:()=>Mf,structure:()=>yM});function Mf(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Sl(this.consume(5))}}function bM(e){this.token(5,A0(e.value))}var xM,yM,Df=$(()=>{"use strict";wl();xM="String",yM={value:String}});var zf={};ye(zf,{generate:()=>CM,name:()=>wM,parse:()=>Rf,structure:()=>kM,walkContext:()=>vM});function L0(){return this.Raw(null,!1)}function Rf(){let e=this.tokenStart,t=this.createList(),n;for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(this.charCodeAt(this.tokenStart+2)!==SM){this.next();continue}n=this.Comment();break;case 14:n=this.CDO();break;case 15:n=this.CDC();break;case 3:n=this.parseWithFallback(this.Atrule,L0);break;default:n=this.parseWithFallback(this.Rule,L0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function CM(e){this.children(e)}var SM,wM,vM,kM,Nf=$(()=>{"use strict";SM=33;wM="StyleSheet",vM="stylesheet",kM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var _f={};ye(_f,{generate:()=>FM,name:()=>TM,parse:()=>Of,structure:()=>IM});function Of(){let e=this.tokenStart;this.eat(21),this.skipSC();let t=this.Declaration();return this.eof||this.eat(22),{type:"SupportsDeclaration",loc:this.getLocation(e,this.tokenStart),declaration:t}}function FM(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var TM,IM,$f=$(()=>{"use strict";TM="SupportsDeclaration",IM={declaration:"Declaration"}});var Hf={};ye(Hf,{generate:()=>LM,name:()=>AM,parse:()=>jf,structure:()=>PM});function Uf(){this.tokenType!==1&&this.isDelim(EM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function jf(){let e=this.tokenStart;return this.isDelim(M0)?(this.next(),Uf.call(this)):(Uf.call(this),this.isDelim(M0)&&(this.next(),Uf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function LM(e){this.tokenize(e.name)}var EM,M0,AM,PM,Wf=$(()=>{"use strict";EM=42,M0=124;AM="TypeSelector",PM={name:String}});var qf={};ye(qf,{generate:()=>zM,name:()=>DM,parse:()=>Gf,structure:()=>RM});function Fs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===D0&&t&&n!==0)return Fs.call(this,e+n+1,!1),-1;Pn(o)||this.error(t&&n!==0?"Hyphen minus"+(n<6?" or hex digit":"")+" is expected":n<6?"Hex digit is expected":"Unexpected input",r),++n>6&&this.error("Too many hex digits",r)}return this.next(),n}function vl(e){let t=0;for(;this.isDelim(Vf);)++t>e&&this.error("Too many question marks"),this.next()}function MM(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===B0?"Plus sign":"Hyphen minus")+" is expected")}function BM(){let e=0;switch(this.tokenType){case 10:if(e=Fs.call(this,1,!0),this.isDelim(Vf)){vl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){MM.call(this,D0),Fs.call(this,1,!1);break}break;case 12:e=Fs.call(this,1,!0),e>0&&vl.call(this,6-e);break;default:if(this.eatDelim(B0),this.tokenType===1){e=Fs.call(this,0,!0),e>0&&vl.call(this,6-e);break}if(this.isDelim(Vf)){this.next(),vl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function Gf(){let e=this.tokenStart;return this.eatIdent("u"),BM.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function zM(e){this.tokenize(e.value)}var B0,D0,Vf,DM,RM,Yf=$(()=>{"use strict";nr();B0=43,D0=45,Vf=63;DM="UnicodeRange",RM={value:String}});function z0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===R0?t-2:t-1,o="";for(;n<r&&Ar(e.charCodeAt(n));)n++;for(;n<r&&Ar(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Kf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),An(Kf,s)){let a=i-1,u=Ur(e,a);i=u-1,o+=Ha(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function N0(e){let t="",n=!1;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===0){t+="\uFFFD";continue}if(o<=31||o===127){t+="\\"+o.toString(16),n=!0;continue}o===NM||o===Kf||o===OM||o===_M||o===$M||o===R0?(t+="\\"+e.charAt(r),n=!1):(n&&Pn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var NM,Kf,OM,_M,$M,R0,Xf=$(()=>{"use strict";nr();NM=32,Kf=92,OM=34,_M=39,$M=40,R0=41});var Jf={};ye(Jf,{generate:()=>HM,name:()=>UM,parse:()=>Qf,structure:()=>jM});function Qf(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=z0(this.consume(7));break;case 2:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(2),this.skipSC(),t=Sl(this.consume(5)),this.skipSC(),this.eof||this.eat(22);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(e,this.tokenStart),value:t}}function HM(e){this.token(7,N0(e.value))}var UM,jM,Zf=$(()=>{"use strict";Xf();wl();UM="Url",jM={value:String}});var tg={};ye(tg,{generate:()=>GM,name:()=>WM,parse:()=>eg,structure:()=>VM});function eg(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function GM(e){this.children(e)}var WM,VM,ng=$(()=>{"use strict";WM="Value",VM={children:[[]]}});var og={};ye(og,{generate:()=>XM,name:()=>YM,parse:()=>rg,structure:()=>KM});function rg(){return this.eat(13),qM}function XM(e){this.token(13,e.value)}var qM,YM,KM,ig=$(()=>{"use strict";qM=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),YM="WhiteSpace",KM={value:String}});var Es={};ye(Es,{AnPlusB:()=>fp,Atrule:()=>hp,AtrulePrelude:()=>bp,AttributeSelector:()=>kp,Block:()=>Ip,Brackets:()=>Ap,CDC:()=>Mp,CDO:()=>Rp,ClassSelector:()=>Op,Combinator:()=>Up,Comment:()=>Wp,Condition:()=>qp,Declaration:()=>Xp,DeclarationList:()=>ed,Dimension:()=>rd,Feature:()=>sd,FeatureFunction:()=>cd,FeatureRange:()=>fd,Function:()=>hd,GeneralEnclosed:()=>bd,Hash:()=>vd,IdSelector:()=>Ed,Identifier:()=>Td,Layer:()=>Ld,LayerList:()=>Dd,MediaQuery:()=>Nd,MediaQueryList:()=>$d,NestingSelector:()=>Hd,Nth:()=>Gd,Number:()=>Kd,Operator:()=>Jd,Parentheses:()=>tf,Percentage:()=>of,PseudoClassSelector:()=>lf,PseudoElementSelector:()=>pf,Ratio:()=>gf,Raw:()=>xf,Rule:()=>Sf,Scope:()=>kf,Selector:()=>If,SelectorList:()=>Af,String:()=>Bf,StyleSheet:()=>zf,SupportsDeclaration:()=>_f,TypeSelector:()=>Hf,UnicodeRange:()=>qf,Url:()=>Jf,Value:()=>tg,WhiteSpace:()=>og});var sg=$(()=>{"use strict";gp();xp();Sp();Cp();Fp();Pp();Bp();zp();_p();jp();Vp();Yp();Qp();td();od();ad();ud();gd();xd();Sd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();nf();sf();cf();df();mf();yf();wf();Cf();Ff();Pf();Df();Nf();$f();Wf();Yf();Zf();ng();ig()});var _0,$0=$(()=>{"use strict";al();p0();sg();_0={generic:!0,cssWideKeywords:gi,...u0,node:Es}});function As(e){switch(this.tokenType){case 4:return this.Hash();case 18:return this.Operator();case 21:return this.Parentheses(this.readSequence,e.recognizer);case 19:return this.Brackets(this.readSequence,e.recognizer);case 5:return this.String();case 12:return this.Dimension();case 11:return this.Percentage();case 10:return this.Number();case 2:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,e.recognizer);case 7:return this.Url();case 1:return this.cmpChar(this.tokenStart,tB)&&this.cmpChar(this.tokenStart+1,U0)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===eB||t===JM||t===U0||t===ZM)return this.Operator();t===QM&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var QM,JM,U0,ZM,eB,tB,ag=$(()=>{"use strict";QM=35,JM=42,U0=43,ZM=45,eB=47,tB=117});var j0,H0=$(()=>{"use strict";ag();j0={getNode:As}});function uB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function pB(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStart)===W0&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case iB:case aB:case cB:case sB:return this.Combinator();case W0:return this.ClassSelector();case oB:case lB:return this.TypeSelector();case nB:return this.IdSelector();case rB:return this.NestingSelector()}break}}}var nB,rB,oB,iB,sB,W0,aB,lB,cB,V0,G0=$(()=>{"use strict";nB=35,rB=38,oB=42,iB=43,sB=47,W0=46,aB=62,lB=124,cB=126;V0={onWhiteSpace:uB,getNode:pB}});function q0(){return this.createSingleNodeList(this.Raw(null,!1))}var Y0=$(()=>{"use strict"});function K0(){let e=this.createList();if(this.skipSC(),e.push(this.Identifier()),this.skipSC(),this.tokenType===18){e.push(this.Operator());let t=this.tokenIndex,n=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(n.type==="Value"&&n.children.isEmpty){for(let r=t-this.tokenIndex;r<=0;r++)if(this.lookupType(r)===13){n.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}e.push(n)}return e}var X0=$(()=>{"use strict"});function Q0(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var J0,Z0=$(()=>{"use strict";ag();Y0();X0();J0={getNode:As,onWhiteSpace(e,t){Q0(e)&&(e.value=" "+e.value),Q0(t.last)&&(t.last.value+=" ")},expression:q0,var:K0}});var lg={};ye(lg,{AtrulePrelude:()=>j0,Selector:()=>V0,Value:()=>J0});var eS=$(()=>{"use strict";H0();G0();Z0()});var dB,tS,nS=$(()=>{"use strict";dB=new Set(["none","and","not","or"]),tS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);dB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var rS,oS=$(()=>{"use strict";rS={parse:{prelude:null,block(){return this.Block(!0)}}}});function cg(e,t){return this.parseWithFallback(()=>{try{return e.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==22&&this.error()}},t||(()=>this.Raw(null,!0)))}var iS,sS,aS=$(()=>{"use strict";iS={layer(){this.skipSC();let e=this.createList(),t=cg.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=cg.call(this,this.Declaration,()=>cg.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},sS={parse:{prelude(){let e=this.createList();switch(this.tokenType){case 5:e.push(this.String());break;case 7:case 2:e.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===1&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?e.push(this.Identifier()):this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&e.push(this.Function(null,iS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,iS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var lS,cS=$(()=>{"use strict";lS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var uS,pS=$(()=>{"use strict";uS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var dS,fS=$(()=>{"use strict";dS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var gS,mS=$(()=>{"use strict";gS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var hS,xS=$(()=>{"use strict";hS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var yS,bS=$(()=>{"use strict";yS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var SS,wS=$(()=>{"use strict";SS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var vS,kS=$(()=>{"use strict";nS();oS();aS();cS();pS();fS();mS();xS();bS();wS();vS={container:tS,"font-face":rS,import:sS,layer:lS,media:uS,nest:dS,page:gS,scope:hS,"starting-style":yS,supports:SS}});function CS(){let e=this.createList();this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 1:e.push(this.Identifier());break;case 5:e.push(this.String());break;case 18:e.push(this.Operator());break;case 22:break e;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return e}var TS=$(()=>{"use strict"});var _o,ug,fB,gB,kl,IS,FS=$(()=>{"use strict";TS();_o={parse(){return this.createSingleNodeList(this.SelectorList())}},ug={parse(){return this.createSingleNodeList(this.Selector())}},fB={parse(){return this.createSingleNodeList(this.Identifier())}},gB={parse:CS},kl={parse(){return this.createSingleNodeList(this.Nth())}},IS={dir:fB,has:_o,lang:gB,matches:_o,is:_o,"-moz-any":_o,"-webkit-any":_o,where:_o,not:_o,"nth-child":kl,"nth-last-child":kl,"nth-last-of-type":kl,"nth-of-type":kl,slotted:ug,host:ug,"host-context":ug}});var pg={};ye(pg,{AnPlusB:()=>dp,Atrule:()=>mp,AtrulePrelude:()=>yp,AttributeSelector:()=>vp,Block:()=>Tp,Brackets:()=>Ep,CDC:()=>Lp,CDO:()=>Dp,ClassSelector:()=>Np,Combinator:()=>$p,Comment:()=>Hp,Condition:()=>Gp,Declaration:()=>Kp,DeclarationList:()=>Zp,Dimension:()=>nd,Feature:()=>id,FeatureFunction:()=>ld,FeatureRange:()=>dd,Function:()=>md,GeneralEnclosed:()=>yd,Hash:()=>wd,IdSelector:()=>Fd,Identifier:()=>Cd,Layer:()=>Pd,LayerList:()=>Bd,MediaQuery:()=>zd,MediaQueryList:()=>_d,NestingSelector:()=>jd,Nth:()=>Vd,Number:()=>Yd,Operator:()=>Qd,Parentheses:()=>ef,Percentage:()=>rf,PseudoClassSelector:()=>af,PseudoElementSelector:()=>uf,Ratio:()=>ff,Raw:()=>hf,Rule:()=>bf,Scope:()=>vf,Selector:()=>Tf,SelectorList:()=>Ef,String:()=>Mf,StyleSheet:()=>Rf,SupportsDeclaration:()=>Of,TypeSelector:()=>jf,UnicodeRange:()=>Gf,Url:()=>Qf,Value:()=>eg,WhiteSpace:()=>rg});var ES=$(()=>{"use strict";gp();xp();Sp();Cp();Fp();Pp();Bp();zp();_p();jp();Vp();Yp();Qp();td();od();ad();ud();gd();xd();Sd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();nf();sf();cf();df();mf();yf();wf();Cf();Ff();Pf();Df();Nf();$f();Wf();Yf();Zf();ng();ig()});var AS,PS=$(()=>{"use strict";eS();kS();FS();ES();AS={parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(e){return this.AtrulePrelude(e.atrule?String(e.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",condition(e){return this.Condition(e.kind)},rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},features:{supports:{selector(){return this.Selector()}},container:{style(){return this.Declaration()}}},scope:lg,atrule:vS,pseudo:IS,node:pg}});var LS,MS=$(()=>{"use strict";sg();LS={node:Es}});var BS,DS=$(()=>{"use strict";c0();$0();PS();MS();BS=l0({..._0,...AS,...LS})});var RS=$(()=>{"use strict"});var zS=$(()=>{"use strict"});var tq,NS,nq,rq,oq,OS,iq,sq,aq,lq,cq,uq,_S=$(()=>{"use strict";DS();RS();Ju();sl();zS();wl();Xf();({tokenize:tq,parse:NS,generate:nq,lexer:rq,createLexer:oq,walk:OS,find:iq,findLast:sq,findAll:aq,toPlainObject:lq,fromPlainObject:cq,fork:uq}=BS)});function yB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function US(e){try{let t=NS(e.trim(),{context:"value"}),n=[];return OS(t,{enter(r){if(r.type==="Dimension"){let o=parseFloat(r.value);n.push(`${o}${r.unit}`)}else if(r.type==="Number"){let o=parseFloat(r.value);n.push(`${o}`)}else r.type==="Percentage"?n.push(`${parseFloat(r.value)}%`):r.type==="Identifier"?n.push(r.name.toLowerCase()):r.type==="Hash"?n.push(`#${r.value.toLowerCase()}`):r.type}}),n}catch{return[e.trim().toLowerCase()]}}function bB(e,t){let n=yB(e);if(!xB.has(n))return t;let r=US(t);if(r.length<1||r.length>4)return t;let o=r.map(i=>i==="0"?"0px":i);return o.length===1?`${o[0]} ${o[0]} ${o[0]} ${o[0]}`:o.length===2?`${o[0]} ${o[1]} ${o[0]} ${o[1]}`:o.length===3?`${o[0]} ${o[1]} ${o[2]} ${o[1]}`:o.join(" ")}function $S(e,t){let n=t.trim();if(!n)return"";let r=bB(e,n);return US(r).map(i=>i==="0"?"0px":i).join(" ")}function jS(e,t,n){let r=$S(e,t),o=$S(e,n);return r!==""&&o!==""&&r===o}var xB,HS=$(()=>{"use strict";_S();xB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function SB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function wB(e){let t=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/);if(!t)return null;let n=parseInt(t[1],10).toString(16).padStart(2,"0"),r=parseInt(t[2],10).toString(16).padStart(2,"0"),o=parseInt(t[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`}function WS(e){let t=typeof e=="string"?e:String(e??"");if(!t||t==="[object Object]")return"";let n=t.match(/rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*[\d.]+)?\s*\)/);if(n){let i=wB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return SB(r[0]);let o=t.match(/(-?\d+\.?\d*)(px|em|rem|%|pt|vw|vh)?/g);return o&&o.length>1?o.join(" ").toLowerCase():o&&o.length===1?o[0].toLowerCase():t.toLowerCase().trim().replace(/\s+/g," ")}function $o(e,t,n){if(!e||!t)return!1;let r=String(e),o=String(t),i=r.toLowerCase(),s=o.toLowerCase(),a=i.includes("none"),u=s.includes("none");if(a!==u)return!1;let c=/\b(fill|stroke)\s*:/i,l=c.test(r),d=c.test(o);if(l!==d)return!1;let f=WS(r),p=WS(o);return!!(f===p||n&&jS(n,r,o))}var dg=$(()=>{"use strict";HS()});function IB(e){let t=String(e.property||"").toLowerCase(),n=String(e.description||"").toLowerCase(),r=String(e.expected||e.suggestedValue||"").toLowerCase(),o=String(e.actual||e.currentValue||"").toLowerCase();if(t.includes("color")||t.includes("fill")||t.includes("background")||n.includes("color")||n.includes("fill"))return!0;let i=s=>/^#[0-9a-f]{3,8}$/i.test(s)||s.includes("rgb")||["white","black","red","blue","green","orange","yellow","transparent"].includes(s);return!!(i(r)||i(o)||e.relatedProperties?.some(s=>{let a=s.property?.toLowerCase()||"";return a.includes("color")||a.includes("fill")||a.includes("background")}))}function VS(e){if(e.includes("\xD7")||/\d+px\s*x\s*\d+px/i.test(e))return!1;let t=e.match(/\d+px/g);return t?t.length>1:!1}function FB(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase(),r=String(e.property||"").toLowerCase(),o=String(e.description||"").toLowerCase(),i=n.includes("margin")||t.includes("margin")||r==="margin",s=t.includes("gap")||o.includes("gap");return i&&s}function EB(e,t,n){if(!e||!t)return!1;let r=typeof e=="string"?e:String(e??""),o=typeof t=="string"?t:String(t??"");if(!r||!o||r==="[object Object]"||o==="[object Object]"||n&&IB(n)||VS(r)||VS(o)||n&&FB(n))return!1;let i=parseFloat(r),s=parseFloat(o);if(isNaN(i)||isNaN(s))return!1;let a=Math.abs(i-s);if(r.includes("px")||o.includes("px")){let u=n?.property?.toLowerCase()||"";return u==="width"||u==="height"||u.includes("width")||u.includes("height")?a<qS:a<GS}return r.includes("%")||o.includes("%")?a<1:!1}function AB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(TB.some(s=>t.includes(s))||!kB.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!$o(o,i,e.property))}function PB(e){let t=(e.expected!==void 0?"fill":"").toLowerCase(),n=e.actual!==void 0||e.currentValue!==void 0?"fill":"";if(!(t==="fill"||n==="fill"||e.description?.toLowerCase().includes("fill")||e.title?.toLowerCase().includes("fill")))return!1;let o=String(e.expected||e.suggestedValue||"").toLowerCase();if(!(o==="none"||o==="transparent"||o.includes("no fills")||o.includes("transparent")))return!1;let s=`${e.description||""} ${e.title||""}`.toLowerCase();return s.includes("container")||s.includes("svg ")||s.includes("<svg")||s.includes("wrapper")}function LB(e){let t=`${e.description||""} ${e.title||""}`.toLowerCase(),n=e.property?.toLowerCase()||"";if(!(t.includes("text ")||t.includes("text layer")||t.includes("text span")||t.includes("span ")||t.includes("label "))||!(n==="width"||n==="height"||n.includes("width")||n.includes("height")||t.includes("width")||t.includes("height")))return!1;let i=e.expected||e.suggestedValue||"",s=e.actual||e.currentValue||"",a=parseFloat(i),u=parseFloat(s);return isNaN(a)||isNaN(u)?!1:Math.abs(a-u)<YS}function MB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase(),n=String(e.expected||e.suggestedValue||"").toLowerCase(),r=String(e.actual||e.currentValue||"").toLowerCase();if(!CB.some(d=>t.includes(d)||n.includes(d)))return!1;let i=`${t} ${n} ${r}`;if(i.includes("min-width")||i.includes("max-width")||i.includes("min-height")||i.includes("max-height")||i.includes("explicit")||i.includes("constraint")||i.includes("forced"))return!1;let a=n.includes("hug")||n.includes("auto"),u=/\d+\.?\d*px/.test(r);if(!a||!u)return!1;let c=n.match(/(\d+\.?\d*)px/),l=r.match(/(\d+\.?\d*)px/);return!(c&&l&&Math.abs(parseFloat(c[1])-parseFloat(l[1]))>vB)}function BB(e){let t=String(e.expected||e.suggestedValue||"").toLowerCase(),n=String(e.actual||e.currentValue||"").toLowerCase();return(!n||!t||n.includes("see ")||t.includes("see ")||n.includes("image")||t.includes("image"))&&e.type==="visual"}function Ps(e){if(e.programmaticallyVerified)return{dismissed:!1};let t=e.expected||e.suggestedValue,n=e.actual||e.currentValue;if(e.fixRequired===!1)return{dismissed:!0,dismissReason:"Auto-dismissed: FixRequired is false (no code change needed)",dismissedBy:"post-ai-validation"};if($o(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: expected equals actual (identical values)",dismissedBy:"post-ai-validation"};if(e.fixRequired===!0)return{dismissed:!1};if(LB(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${YS}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(EB(t,n,e)){let r=e.property?.toLowerCase()||"";return{dismissed:!0,dismissReason:`Auto-dismissed: negligible difference (<${r==="width"||r==="height"||r.includes("width")||r.includes("height")?qS:GS}px)`,dismissedBy:"post-ai-validation"}}return BB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:AB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:MB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:PB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var GS,qS,YS,vB,kB,CB,TB,KS=$(()=>{"use strict";dg();GS=.5,qS=2,YS=2,vB=5,kB=["values match","values already match","already correct","correctly implemented","implementation is correct","css matches","matches figma","identical","same value","no difference","none - ","no changes needed","no fix needed"],CB=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],TB=["duplicate","extra","missing","additional","removed","should not exist","does not exist","not in figma","not in storybook","renders 2","renders two","has 1","has one"]});function Si(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var XS=$(()=>{"use strict"});var QS=$(()=>{"use strict"});var JS=$(()=>{"use strict"});var fg=$(()=>{"use strict";dg();KS();XS();QS();JS()});var jB,HB,Fq,gg=$(()=>{"use strict";jB=["flex","inline-flex"],HB=["grid","inline-grid"],Fq=[...jB,...HB]});var ew=$(()=>{"use strict";fg();gg()});var tw=$(()=>{"use strict"});var Ls=$(()=>{"use strict";sy();fg();gg();ew();tw()});function VB(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function qn(e){try{let t=e.map(VB),n=JSON.stringify(t,GB);sessionStorage.setItem(mg,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function hg(){try{let e=sessionStorage.getItem(mg);if(!e)return[];let t=JSON.parse(e,qB);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function nw(){try{let e=hg();if(e.length===0)return;let t=!1,n=e.map(r=>{if(r.aiPrompt!==void 0||r.aiResponse!==void 0){t=!0;let{aiPrompt:o,aiResponse:i,...s}=r;return s}return r});t&&(qn(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function rw(){try{sessionStorage.removeItem(mg),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function GB(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function qB(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var mg,xg=$(()=>{"use strict";De();mg="uicopilot_review_history"});import YB,{createContext as KB,useContext as XB,useReducer as QB,useMemo as ow,useRef as JB,useEffect as ZB}from"react";function eD(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"ADD_STREAMING_MESSAGE":return{...e,streamingMessages:[...e.streamingMessages,t.payload]};case"UPDATE_STREAMING_MESSAGE":return{...e,streamingMessages:e.streamingMessages.map((n,r)=>r===t.payload.index?{...n,content:t.payload.content}:n)};case"CLEAR_STREAMING_MESSAGES":return{...e,streamingMessages:[]};case"TOGGLE_MODEL":{let n=e.selectedModels.includes(t.payload);return n&&e.selectedModels.length===1?e:{...e,selectedModels:n?e.selectedModels.filter(r=>r!==t.payload):[...e.selectedModels,t.payload]}}case"SET_REVIEW_RESULTS":{if(!t.payload)return{...e,reviewResults:null,currentReviewId:null};let n=e.userRole==="admin",r={id:t.payload.id,componentId:t.payload.componentId,storyId:t.payload.storyId,modelId:t.payload.modelId,complianceScore:t.payload.complianceScore,issuesCount:t.payload.issuesCount,issues:t.payload.issues,createdAt:t.payload.createdAt,visualSimilarity:t.payload.visualSimilarity,storybookImageData:e.storybookImageUrl||void 0,figmaImageData:e.figmaImageUrl||void 0,aiPrompt:n&&e.fullPrompt||void 0,aiResponse:n&&e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens},o=e.reviewHistory.findIndex(s=>s.id===t.payload.id),i;return o>=0?i=e.reviewHistory.map((s,a)=>a===o?r:s):i=[...e.reviewHistory,r],qn(i),{...e,reviewResults:t.payload,reviewHistory:i,currentReviewId:t.payload.id}}case"UPDATE_MULTI_MODEL_STREAMING":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload.modelId]:{...e.multiModelResults.byModel[t.payload.modelId],streamingMessages:t.payload.messages}}}}:{...e,multiModelResults:{byModel:{[t.payload.modelId]:{streamingMessages:t.payload.messages}},activeModelId:t.payload.modelId}};case"SET_MODEL_COMPLETED":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload]:{...e.multiModelResults.byModel[t.payload],completed:!0}}}}:e;case"BULK_ADD_REVIEWS":{let n=new Set(e.reviewHistory.map(i=>i.id)),r=t.payload.filter(i=>!n.has(i.id));if(r.length===0)return e;let o=[...e.reviewHistory,...r];return qn(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=[...e.reviewHistory,t.payload];return qn(n),{...e,reviewHistory:n,currentReviewId:t.payload.id}}case"TOGGLE_ISSUE_SELECTION":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload?{...o,selectedForFix:!o.selectedForFix}:o)});return qn(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_STATUS":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,status:t.payload.status,error:t.payload.error}:o)});return qn(n),{...e,reviewHistory:n}}case"UPDATE_ISSUE_GENERATED_FIX":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,generatedFix:o.generatedFix?{...o.generatedFix,...t.payload.generatedFix}:t.payload.generatedFix,selectedForFix:t.payload.generatedFix?.status==="failed"?!1:o.selectedForFix}:o)});return qn(n),{...e,reviewHistory:n}}case"BATCH_UPDATE_ISSUE_GENERATED_FIXES":{if(!e.currentReviewId)return e;let n=new Map(t.payload.map(o=>[o.issueId,o.generatedFix])),r=e.reviewHistory.map(o=>o.id!==e.currentReviewId?o:{...o,issues:o.issues.map(i=>{let s=n.get(i.id);return s?{...i,generatedFix:i.generatedFix?{...i.generatedFix,...s}:s,selectedForFix:s?.status==="failed"?!1:i.selectedForFix}:i})});return qn(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:o)});return qn(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload?{...o,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:o)});return qn(n),{...e,reviewHistory:n}}case"RECALCULATE_SCORE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.filter(c=>!c.dismissed),i=o.filter(c=>c.severity==="critical").length,s=o.filter(c=>c.severity==="major").length,a=o.filter(c=>c.severity==="minor").length,u=Si(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return qn(n),{...e,reviewHistory:n}}case"UPDATE_REVIEW_SCORE":{let n=e.reviewHistory.map(r=>r.id!==t.payload.reviewId?r:{...r,complianceScore:t.payload.newScore});return qn(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return rw(),{...e,reviewHistory:[],currentReviewId:null};case"CLEAR_STALE_REVIEWS":return{...e,currentReviewId:null,reviewResults:null};case"RESET_REVIEW":{let n=e.isReviewing;return{...e,isReviewing:!1,reviewError:null,reviewResults:n?null:e.reviewResults,multiModelResults:null,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:n?"chat":e.reviewDetailTab,fullPrompt:"",fullResponse:"",figmaImageUrl:n?null:e.figmaImageUrl,storybookImageUrl:n?null:e.storybookImageUrl,currentReviewId:n?null:e.currentReviewId}}case"RESET_PROMPT":return{...e,isGenerating:!1,generatedPrompt:null,promptError:null};case"TRIGGER_SCREENSHOT_REFRESH":return{...e,screenshotRefreshKey:e.screenshotRefreshKey+1};default:return e}}function bg({children:e}){let[t,n]=QB(eD,iD),r=JB(t);ZB(()=>{r.current=t},[t]);let o=ow(()=>({setIsReviewing:s=>n({type:"SET_STATE",payload:{isReviewing:s}}),setReviewError:s=>n({type:"SET_STATE",payload:{reviewError:s}}),bulkAddReviews:s=>n({type:"BULK_ADD_REVIEWS",payload:s}),setReviewResults:s=>n({type:"SET_REVIEW_RESULTS",payload:s}),setMultiModelResults:s=>n({type:"SET_STATE",payload:{multiModelResults:s}}),updateMultiModelStreamingMessages:(s,a)=>n({type:"UPDATE_MULTI_MODEL_STREAMING",payload:{modelId:s,messages:a}}),setModelCompleted:s=>n({type:"SET_MODEL_COMPLETED",payload:s}),setActiveModelId:s=>{let a=r.current;a.multiModelResults&&n({type:"SET_STATE",payload:{multiModelResults:{...a.multiModelResults,activeModelId:s}}})},setShowReviewMenu:s=>n({type:"SET_STATE",payload:{showReviewMenu:s}}),setSeverityFilter:s=>n({type:"SET_STATE",payload:{severityFilter:s}}),setShowStreamingPanel:s=>n({type:"SET_STATE",payload:{showStreamingPanel:s}}),setStreamingPanelCollapsed:s=>n({type:"SET_STATE",payload:{streamingPanelCollapsed:s}}),addStreamingMessage:s=>n({type:"ADD_STREAMING_MESSAGE",payload:s}),updateStreamingMessage:(s,a)=>n({type:"UPDATE_STREAMING_MESSAGE",payload:{index:s,content:a}}),clearStreamingMessages:()=>n({type:"CLEAR_STREAMING_MESSAGES"}),setStreamingProgress:s=>n({type:"SET_STATE",payload:{streamingProgress:s}}),setStreamingStatus:s=>n({type:"SET_STATE",payload:{streamingStatus:s}}),setReviewDetailTab:s=>n({type:"SET_STATE",payload:{reviewDetailTab:s}}),setFullPrompt:s=>n({type:"SET_STATE",payload:{fullPrompt:s}}),setFullResponse:s=>n({type:"SET_STATE",payload:{fullResponse:s}}),setFigmaImageUrl:s=>n({type:"SET_STATE",payload:{figmaImageUrl:s}}),setStorybookImageUrl:s=>n({type:"SET_STATE",payload:{storybookImageUrl:s}}),setFigmaDimensions:s=>n({type:"SET_STATE",payload:{figmaDimensions:s}}),setSelectedModels:s=>n({type:"SET_STATE",payload:{selectedModels:s}}),toggleModel:s=>n({type:"TOGGLE_MODEL",payload:s}),setModelComparisonView:s=>n({type:"SET_STATE",payload:{modelComparisonView:s}}),resetReview:()=>n({type:"RESET_REVIEW"}),addReview:s=>n({type:"ADD_REVIEW",payload:s}),getCurrentReview:()=>{let s=r.current;return s.currentReviewId&&s.reviewHistory.find(a=>a.id===s.currentReviewId)||null},getReviewById:s=>r.current.reviewHistory.find(a=>a.id===s)||null,getParentReview:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return a?.parentReviewId&&s.reviewHistory.find(u=>u.id===a.parentReviewId)||null},hasAppliedFixes:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return!a||!Array.isArray(a.issues)||a.issues.length===0?!1:a.issues.some(u=>u.status==="applied"||u.generatedFix?.status==="applied")},toggleIssueSelection:s=>n({type:"TOGGLE_ISSUE_SELECTION",payload:s}),updateIssueStatus:(s,a,u)=>n({type:"UPDATE_ISSUE_STATUS",payload:{issueId:s,status:a,error:u}}),updateIssueGeneratedFix:(s,a)=>n({type:"UPDATE_ISSUE_GENERATED_FIX",payload:{issueId:s,generatedFix:a}}),batchUpdateIssueGeneratedFixes:s=>n({type:"BATCH_UPDATE_ISSUE_GENERATED_FIXES",payload:s}),dismissIssue:(s,a,u)=>n({type:"DISMISS_ISSUE",payload:{issueId:s,reason:a,dismissedBy:u}}),undismissIssue:s=>n({type:"UNDISMISS_ISSUE",payload:s}),recalculateScore:()=>n({type:"RECALCULATE_SCORE"}),updateReviewScore:(s,a)=>n({type:"UPDATE_REVIEW_SCORE",payload:{reviewId:s,newScore:a}}),clearAllReviews:()=>n({type:"CLEAR_ALL_REVIEWS"}),clearStaleReviewsForStory:s=>n({type:"CLEAR_STALE_REVIEWS",payload:s}),setIsApplying:s=>n({type:"SET_STATE",payload:{isApplying:s}}),setApplyFixesResult:s=>n({type:"SET_STATE",payload:{applyFixesResult:s}}),setIncludeComponentIssues:s=>n({type:"SET_STATE",payload:{includeComponentIssues:s}}),setIncludeTextComparison:s=>n({type:"SET_STATE",payload:{includeTextComparison:s}}),setUsePromptCache:s=>n({type:"SET_STATE",payload:{usePromptCache:s}}),setIsValidating:s=>n({type:"SET_STATE",payload:{isValidating:s}}),setValidationUsage:s=>n({type:"SET_STATE",payload:{validationUsage:s}}),setWorkspacePath:s=>n({type:"SET_STATE",payload:{workspacePath:s}}),triggerScreenshotRefresh:()=>n({type:"TRIGGER_SCREENSHOT_REFRESH"}),setHoveredIssueId:s=>n({type:"SET_STATE",payload:{hoveredIssueId:s}}),setFeatureFlags:s=>n({type:"SET_STATE",payload:{featureFlags:s}}),setUserRole:s=>n({type:"SET_STATE",payload:{userRole:s}}),setRoleOverride:s=>{try{s?localStorage.setItem("uicopilot_role_override",s):localStorage.removeItem("uicopilot_role_override")}catch{}n({type:"SET_STATE",payload:{roleOverride:s}})},setReviewAllConcurrency:s=>{let a=Math.max(1,Math.min(5,s));try{localStorage.setItem("uicopilot_review_all_concurrency",String(a))}catch{}n({type:"SET_STATE",payload:{reviewAllConcurrency:a}})},setIsGenerating:s=>n({type:"SET_STATE",payload:{isGenerating:s}}),setGeneratedPrompt:s=>n({type:"SET_STATE",payload:{generatedPrompt:s}}),setPromptError:s=>n({type:"SET_STATE",payload:{promptError:s}}),resetPrompt:()=>n({type:"RESET_PROMPT"})}),[]),i=ow(()=>({...t,...o}),[t,o]);return YB.createElement(iw.Provider,{value:i},e)}function ie(){let e=XB(iw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var tD,nD,yg,rD,oD,iD,iw,Sg=$(()=>{"use strict";Ls();xg();De();tD=()=>{if(typeof localStorage>"u")return 3;try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3},nD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},yg={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},rD=()=>{if(typeof localStorage>"u")return yg;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return yg;let t=JSON.parse(e);return{enableFixGeneration:!!t.enableFixGeneration,enableFixApply:!!t.enableFixApply,enableAutoMap:!!t.enableAutoMap,enableReviewBadges:!!t.enableReviewBadges,showCosts:!!t.showCosts,enableParallelReview:!!t.enableParallelReview,enableModelSelection:!!t.enableModelSelection}}catch{}return yg},oD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},iD={isReviewing:!1,reviewError:null,reviewResults:null,multiModelResults:null,showReviewMenu:!1,severityFilter:"all",showStreamingPanel:!1,streamingPanelCollapsed:!1,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:"chat",fullPrompt:"",fullResponse:"",figmaImageUrl:null,storybookImageUrl:null,figmaDimensions:null,selectedModels:["claude-sonnet-4-5-20250929"],modelComparisonView:"side-by-side",reviewHistory:hg(),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:oD(),roleOverride:nD(),featureFlags:rD(),reviewAllConcurrency:tD(),hoveredIssueId:null},iw=KB(null)});import Ms,{useMemo as sD}from"react";function vg({children:e}){return Ms.createElement(ru,null,Ms.createElement(iu,null,Ms.createElement(au,null,Ms.createElement(bg,null,Ms.createElement(aD,null),e))))}function sw(e){let t=we(),n=Ze(),r=rt(),o=ie(),i=sD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function aD(){return wg=sw(),null}var wg,mt,aw=$(()=>{"use strict";ou();su();lu();Sg();wg=null,mt=Object.assign(sw,{getState:()=>{if(!wg)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return wg}})});var ve=$(()=>{"use strict";aw();ou();su();lu();Sg()});function q(){return(process.env.STORYBOOK_UICOPILOT_URL||lD).replace(/\/$/,"")}var lD,lw,je=$(()=>{"use strict";lD="https://app.uicopilot.dev",lw=3.6});async function oe(e,t,n=3e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var pt=$(()=>{"use strict"});import{useEffect as zs,useState as Tl,useRef as JD,useCallback as Cg}from"react";import{addons as Tg}from"storybook/manager-api";async function ZD(e,t,n){let r=`${e}:${t}`,o=Ig.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await oe(`${Tw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Ig.delete(r)});return Ig.set(r,i),i}function eR(e,t,n){try{sessionStorage.setItem(`${Il}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function tR(e,t){try{let n=sessionStorage.getItem(`${Il}${e}`);if(!n)return null;let r=JSON.parse(n);if(r.figmaNodeId===t&&Date.now()-r.timestamp<1800*1e3)return r.imageUrl;sessionStorage.removeItem(`${Il}${e}`)}catch{}return null}function nR(e){try{let t=sessionStorage.getItem(`${Il}${e}`);if(!t)return null;let n=JSON.parse(t);if(n.imageUrl&&Date.now()-n.timestamp<300*1e3)return n.imageUrl}catch{}return null}var ww,vw,kw,Cw,Ci,Tw,ir,Fg,Ig,Il,Iw,Uo,Ns=$(()=>{"use strict";ve();Eg();De();je();pt();ww="storyArgsUpdated",vw="storyRendered",kw="forceRemount",Cw=null,Ci=()=>Cw,Tw=q(),ir=new Map,Fg=null,Ig=new Map;Il="uicopilot-figma-image-";Iw=(e,t,n)=>{Fg=t;let r=ir.get(e);r?r.figmaImageUrl=n:ir.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},Uo=()=>{let[e,t]=Tl(!1),[n,r]=Tl(!1),[o,i]=Tl(!1),[s,a]=Tl(null),u=JD(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ie(),d=Cg(()=>{let z=mt.getState().currentStoryId;z&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",z),ir.delete(z),u.current=null,i(!0),l())},[l]),f=Cg(()=>{let z=mt.getState().currentStoryId;if(z){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",z);let _=ir.get(z);_&&(_.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=we(),{selectedProjectId:g}=Ze(),{currentStoryId:S,currentMapping:C}=rt(),{setStorybookImageUrl:F,setFigmaImageUrl:k}=ie();zs(()=>{if(!S||mt.getState().figmaImageUrl)return;let _=nR(S);_&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",S),k(_))},[S,k]),zs(()=>{(async()=>{if(!p||!g||!S){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}let _=mt.getState();if(_.storybookImageUrl&&_.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded from persisted review, skipping capture"),u.current=S;return}let M=C?.figmaNodeId??null;if(M!==Fg){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",S);let I=ir.get(S);I&&(I.figmaImageUrl=null),Fg=M,u.current=null}let B=C?.figmaNodeId;if(B&&!ir.get(S)?.figmaImageUrl){let I=tR(S,B);if(I){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",S),k(I);let v=ir.get(S);v?v.figmaImageUrl=I:ir.set(S,{storybookImageUrl:null,figmaImageUrl:I})}}let m=ir.get(S),x=m&&m.storybookImageUrl&&m.figmaImageUrl,b=m&&m.storybookImageUrl&&!m.figmaImageUrl,E=m&&!m.storybookImageUrl&&m.figmaImageUrl;if(x){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",S),F(m.storybookImageUrl),k(m.figmaImageUrl),u.current=S;return}let h=b&&C?.figmaNodeId;h&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",S),F(m.storybookImageUrl));let T=E;if(T&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",S),k(m.figmaImageUrl)),u.current===S&&C?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{a(null),h?r(!0):(T||(t(!0),r(!0)),i(!0)),u.current=S;let I=T?m.figmaImageUrl:null,v;if(T)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(B){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",B);let P=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let D=await ZD(g,B,p);P=D.imageUrl||null;let N=D.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${N}:`,P?"success":"not found")}catch(D){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",D)}if(P)if(P.includes(".azureedge.net")||P.includes(".blob.core.windows.net")||P.includes(".blob.vercel-storage.com")){y.debug("[useReviewScreenshots] Using cached CDN URL directly (fast)"),I=P,k(P);let N=new Image;N.crossOrigin="anonymous",await new Promise(w=>{N.onload=()=>{v={width:N.naturalWidth,height:N.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),w()},N.onerror=()=>w(),N.src=P})}else try{y.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let N=`${Tw}/api/proxy/image?url=${encodeURIComponent(P)}`,w=await oe(N);if(w.ok){let j=await w.blob(),G=new FileReader,L=await new Promise((ee,re)=>{G.onloadend=()=>ee(G.result),G.onerror=re,G.readAsDataURL(j)});I=L,k(L),y.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let K=new Image;await new Promise(ee=>{K.onload=()=>{v={width:K.naturalWidth,height:K.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",v),ee()},K.onerror=()=>ee(),K.src=L})}else I=P,k(P),y.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(N){y.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",N),I=P,k(P)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",B),k(null);I&&B&&eR(S,B,I),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),k(null),r(!1);let A=m?.storybookImageUrl||null;if(A)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",S);let P=await Fl({storyId:S,sessionToken:p||void 0,...v&&{figmaWidth:v.width,figmaHeight:v.height}});P?(A=P,F(P),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",v||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}ir.set(S,{storybookImageUrl:A,figmaImageUrl:I}),y.debug("[useReviewScreenshots] Screenshots cached for story:",S)}catch(I){y.error("[useReviewScreenshots] Error loading screenshots:",I),a(I instanceof Error?I.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})()},[p,g,S,C?.figmaNodeId,c]),zs(()=>{let z=Tg.getChannel(),_=null,M=B=>{Cw=B.args,y.debug("[useReviewScreenshots] Args updated for story:",B.storyId,"args:",B.args),_&&clearTimeout(_),_=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return z.on(ww,M),()=>{z.off(ww,M),_&&clearTimeout(_)}},[d]),zs(()=>{let z=Tg.getChannel(),_=!1,M=null,B=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),_=!0,i(!0)},m=()=>{_&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),M&&clearTimeout(M),M=setTimeout(()=>{_=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),f()},500))};return z.on(kw,B),z.on(vw,m),()=>{z.off(kw,B),z.off(vw,m),M&&clearTimeout(M)}},[f]),zs(()=>{let z=Tg.getChannel(),_=async M=>{if(!M?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let B=mt.getState().currentStoryId,m=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M.snapshot,storyId:B})});if(m.ok){let x=await m.json();if(x.screenshot){F(x.screenshot);let b=mt.getState().currentStoryId;if(b){let E=ir.get(b);E?E.storybookImageUrl=x.screenshot:ir.set(b,{storybookImageUrl:x.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await m.text())}catch(B){y.error("[useReviewScreenshots] Snapshot screenshot error:",B)}finally{i(!1)}};return z.on("UICOPILOT/STORY_DOM_MUTATED",_),()=>{z.off("UICOPILOT/STORY_DOM_MUTATED",_)}},[]);let R=Cg((z,_,M)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Iw(z,_,M),k(M),r(!1),u.current=z},[k]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:f,setFigmaImageDirect:R}}});function oR(){return!q().startsWith("http://localhost")}function iR(e,t,n){let r=t.createElement("div");r.style.color=e,t.body.appendChild(r);let o=n.getComputedStyle(r).color;return r.remove(),o}function Fw(e,t,n){let r=new Map;return e.replace(/(?:color|oklch|oklab|lab|lch)\([^)]+\)/g,o=>{if(r.has(o))return r.get(o);let i=iR(o,t,n);return r.set(o,i),i})}async function sR(){let e=(await import("html2canvas")).default,t=document.getElementById("storybook-preview-iframe");if(!t?.contentDocument||!t.contentWindow)throw new Error("Storybook iframe not accessible");let n=t.contentDocument.querySelector("#storybook-root > *")||t.contentDocument.querySelector("#root > *");if(!n)throw new Error("Story element not found in iframe");let r=t.contentWindow,o=t.contentDocument;return(await e(n,{useCORS:!0,logging:!1,backgroundColor:null,onclone:s=>{s.querySelectorAll("style").forEach(u=>{let c=u.textContent||"";/(?:color|oklch|oklab|lab|lch)\(/.test(c)&&(u.textContent=Fw(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(d=>d.href===c);if(l)try{let d="";for(let f of Array.from(l.cssRules))d+=f.cssText+`
13
+ `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let f=s.createElement("style");f.textContent=Fw(d,o,r),u.replaceWith(f)}}catch{}})}})).toDataURL("image/png")}function aR(e){let t=[];for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let o;typeof r=="boolean"?o=`!${r}`:typeof r=="number"?o=String(r):typeof r=="string"?o=encodeURIComponent(r).replace(/%20/g,"+"):o=encodeURIComponent(JSON.stringify(r)),t.push(`${n}:${o}`)}return t.join(";")}async function lR(e,t){y.debug("[Screenshot] Using server-side Chrome capture for:",e);let n={"Content-Type":"application/json"};t?.sessionToken&&(n.Authorization=`Bearer ${t.sessionToken}`);let r=await oe(`${rR}/api/screenshot`,{method:"POST",headers:n,body:JSON.stringify({url:e,selector:t?.selector,width:t?.width,height:t?.height,scale:t?.scale||1,figmaWidth:t?.figmaWidth,figmaHeight:t?.figmaHeight})});if(!r.ok){let i=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Screenshot failed: ${r.status}`)}return(await r.json()).screenshot}function cR(e){let t={};if(!e)return t;let n=e.split(";");for(let r of n){let o=r.indexOf(":");if(o===-1)continue;let i=r.slice(0,o),s=r.slice(o+1);typeof s=="string"&&(s==="!true"?s=!0:s==="!false"?s=!1:!isNaN(Number(s))&&s!==""?s=Number(s):s=decodeURIComponent(s.replace(/\+/g," "))),t[i]=s}return t}function uR(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),y.debug("[Screenshot] Warning: Using story ID from URL (fallback):",n)),!n)throw new Error("Could not determine current story ID. Please select a story first.");let r=window.location.origin,o=Date.now(),i=`${r}/iframe.html?viewMode=story&id=${n}&globals=&_cb=${o}`,s=Ci();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=cR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=aR(s);i+=`&args=${a}`,y.debug("[Screenshot] Using URL with current args:",i)}else y.debug("[Screenshot] No current args, using default URL:",i);return i}async function pR(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return y.info("[Screenshot] Local Puppeteer not available, falling back"),null;if(!t.ok){let r=await t.json().catch(()=>({error:"Unknown"}));throw new Error(r.error||`Screenshot failed: ${t.status}`)}let n=await t.json();return y.info("[Screenshot] Captured via local Puppeteer (pixel-perfect)"),n.screenshot}catch(t){if(t instanceof TypeError&&t.message.includes("fetch"))return null;throw t}}async function Fl(e){let t=e?.storyId||dR();if(t){let n=Ag.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Ew(t,e).finally(()=>{Ag.delete(t)});return Ag.set(t,r),r}return Ew(void 0,e)}async function Ew(e,t){try{if(e){let n=await pR(e);if(n)return n}if(!oR()){let n=uR(t?.storyId);return await lR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await sR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function dR(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var rR,Ag,Eg=$(()=>{"use strict";je();Ns();De();pt();rR=q();Ag=new Map});function vn(e){if(e==="transparent"||e==="rgba(0, 0, 0, 0)")return"transparent";let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(!t)return e;let[,n,r,o,i]=t,s=i?parseFloat(i):1;return s<1?`rgba(${n}, ${r}, ${o}, ${s})`:`#${[n,r,o].map(u=>parseInt(u).toString(16).padStart(2,"0")).join("")}`}function Dn(e,t){let r={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"],gap:["normal","0px"],flexDirection:["row"],justifyContent:["normal","flex-start"],alignItems:["normal","stretch"],textAlign:["start","left"],letterSpacing:["normal","0px"],margin:["0px","0px 0px 0px 0px"],padding:["0px","0px 0px 0px 0px"]}[e];return r?r.includes(t):!1}function Os(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Aw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let C=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let k=t.fonts.check(`${F} ${C} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:k,fontWeight:F,fontSize:C,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(R=>({family:R.family,status:R.status}))}),k)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(C=>C.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],f=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,g="unknown",S=new Map;for(let C of f){s.font=`${c} ${u} ${a} "${C}", monospace`;let F=s.measureText(o).width;if(S.set(C,F),F!==p){s.font=`${c} ${u} ${a} "${C}"`;let k=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let R=s.measureText(o).width;if(Math.abs(k-R)<.1){g=C;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:g,declaredFonts:l,fontWidths:Array.from(S.entries()),isIframe:t!==document}),g}var _s=$(()=>{"use strict";De()});function Ti(e,t){if(!t)return e;let n=t.split(" ").filter(i=>i.trim()),r=n.find(i=>!i.includes("--")),o=n.filter(i=>i.includes("--"));return r&&o.length>0?`${e}.${r}.${o[0]}`:r?`${e}.${r}`:n[0]?`${e}.${n[0]}`:e}function Pg(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return y.debug("[computedStyles] Extracting styles:",{fontFamily:n.fontFamily,fontWeight:n.fontWeight,borderRadius:n.borderRadius,backgroundColor:n.backgroundColor,padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},isIframeContext:e.ownerDocument!==document}),{color:vn(n.color),backgroundColor:vn(n.backgroundColor),borderColor:vn(n.borderColor),padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},margin:{top:n.marginTop,right:n.marginRight,bottom:n.marginBottom,left:n.marginLeft},gap:n.gap,fontFamily:n.fontFamily,renderedFont:Aw(e),fontSize:n.fontSize,fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,textAlign:n.textAlign,textTransform:n.textTransform,width:n.width,height:n.height,minWidth:n.minWidth,minHeight:n.minHeight,maxWidth:n.maxWidth,maxHeight:n.maxHeight,borderWidth:n.borderWidth,borderStyle:n.borderStyle,borderRadius:n.borderRadius,boxShadow:n.boxShadow,textShadow:n.textShadow,display:n.display,flexDirection:n.display==="flex"?n.flexDirection:void 0,justifyContent:n.display==="flex"?n.justifyContent:void 0,alignItems:n.display==="flex"?n.alignItems:void 0,position:n.position,opacity:n.opacity,cursor:n.cursor}}function Lg(e,t){let n={width:null,height:null,minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,display:null,flexGrow:null,flexShrink:null,flexBasis:null};try{let r=Array.from(t.styleSheets);for(let i of r)try{let s=i.cssRules||i.rules;if(!s)continue;for(let a of Array.from(s))if(a.type===1){let u=a;try{if(e.matches(u.selectorText)){let c=u.style;c.width&&(n.width=c.width),c.height&&(n.height=c.height),c.minWidth&&(n.minWidth=c.minWidth),c.minHeight&&(n.minHeight=c.minHeight),c.maxWidth&&(n.maxWidth=c.maxWidth),c.maxHeight&&(n.maxHeight=c.maxHeight),c.display&&(n.display=c.display),c.flexGrow&&(n.flexGrow=c.flexGrow),c.flexShrink&&(n.flexShrink=c.flexShrink),c.flexBasis&&(n.flexBasis=c.flexBasis)}}catch{continue}}}catch{continue}let o=e.style;o.width&&(n.width=o.width),o.height&&(n.height=o.height),o.minWidth&&(n.minWidth=o.minWidth),o.minHeight&&(n.minHeight=o.minHeight),o.maxWidth&&(n.maxWidth=o.maxWidth),o.maxHeight&&(n.maxHeight=o.maxHeight),o.display&&(n.display=o.display),o.flexGrow&&(n.flexGrow=o.flexGrow),o.flexShrink&&(n.flexShrink=o.flexShrink),o.flexBasis&&(n.flexBasis=o.flexBasis)}catch(r){y.error("Error extracting declared styles:",r)}return n}var El=$(()=>{"use strict";De();_s()});function fR(e){let t=[],n=new Set,r=Pw.join(", "),o=e.querySelectorAll(r);for(let i of Array.from(o)){let s=`${i.tagName.toLowerCase()}.${i.className}`;n.has(s)||(n.add(s),t.push(i))}if(Pw.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function gR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"";return{selector:Ti(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Os(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:vn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function mR(e,t=2){let n=[e],r=new Set,o=s=>{let a=s.className;return typeof a=="string"?a:a?.baseVal||""};r.add(`${e.tagName}.${o(e)}`);function i(s,a){if(a>=t)return;let u=Array.from(s.children);for(let c of u){let l=c.tagName.toLowerCase();if(["script","style","link","meta","br","hr"].includes(l))continue;let d=`${c.tagName}.${o(c)}`;r.has(d)||(r.add(d),n.push(c),i(c,a+1))}}return i(e,0),n}function hR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"",s=n.borderWidth!=="0px",a=n.backgroundColor!=="transparent"&&n.backgroundColor!=="rgba(0, 0, 0, 0)",u=n.borderRadius!=="0px",c=n.gap!=="normal"&&n.gap!=="0px";if(!s&&!a&&!u&&!c)return null;let l=n.borderWidth,d=n.borderStyle,f=vn(n.borderColor),p=s?`${l} ${d} ${f}`:"none";return{selector:Ti(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:vn(n.backgroundColor),gap:n.gap}}function $s(){y.debug("[computedStyles] extractStoryStyles called - FULL CONTEXT VERSION");try{let e=document.getElementById("storybook-preview-iframe");if(!e||!e.contentDocument)throw new Error("Storybook preview iframe not found");let t=e.contentDocument,n=t.getElementById("storybook-root");if(!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(!r)throw new Error("Component element not found in story root");let o=mR(r,2),i=o.map(hR).filter(a=>a!==null);y.debug("[computedStyles] Extracted visual styles from nested elements:",{total:o.length,withVisuals:i.length,elements:i.map(a=>({selector:a.selector,border:a.border,background:a.backgroundColor,borderRadius:a.borderRadius}))});let s=[];try{let a=fR(r);s=a.map(gR),y.debug("[computedStyles] Text elements found:",{count:a.length,elements:s.map(u=>({selector:u.selector,fontSize:u.styles.fontSize,fontWeight:u.styles.fontWeight}))})}catch(a){y.error("[computedStyles] Error extracting text elements:",a)}return{computed:Pg(r),declared:Lg(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Pw,Lw=$(()=>{"use strict";De();_s();El();Pw=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Mg(e,t,n,r){return e===t&&t===n&&n===r?e:e===n&&t===r?`${e} ${t}`:t===r?`${e} ${t} ${n}`:`${e} ${t} ${n} ${r}`}function yR(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function bR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=vn(n.backgroundColor);Dn("backgroundColor",o)||(r.backgroundColor=o);let i=yR(n.borderWidth,n.borderStyle,vn(n.borderColor));i&&(r.border=i),Dn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Dn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Dn("opacity",n.opacity)||(r.opacity=n.opacity);let s=e.tagName.toLowerCase(),a=["svg","circle","rect","ellipse","line","polyline","polygon","path","text","tspan","g","use","defs","clipPath","mask"];if(e instanceof SVGElement||a.includes(s)){for(let C=0;C<e.attributes.length;C++){let F=e.attributes[C];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let k=F.name.replace(/-([a-z])/g,(z,_)=>_.toUpperCase()),R=F.value.startsWith("rgb")?vn(F.value):F.value;k==="d"&&R.length>100?r[k]=R.substring(0,100)+"...":r[k]=R}let p=n.getPropertyValue("fill"),g=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?vn(p):p),g&&g!=="none"&&(r.stroke=g.startsWith("rgb")?vn(g):g),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let C=e.getBoundingClientRect();C.width>0&&(r.width=`${Math.round(C.width*100)/100}px`),C.height>0&&(r.height=`${Math.round(C.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=xR.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Os(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=vn(n.color),Dn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Dn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=Mg(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Dn("padding",d)||(r.padding=d);let f=Mg(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Dn("margin",f)||(r.margin=f),Dn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Dn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Dn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Dn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function Mw(e){let t=1;for(let n of e.children)t+=Mw(n);return t}function Bw(e,t=4){function n(o,i){let s=o.tagName.toLowerCase(),a=o.className,u=typeof a=="string"?a:a?.baseVal||"",c=o.id||void 0,l=o.getAttribute("role")||void 0,d;for(let S of Array.from(o.childNodes))if(S.nodeType===Node.TEXT_NODE){let C=S.textContent?.trim();if(C){d=C.length>50?C.substring(0,50)+"...":C;break}}let f=s;c?f=`${s}#${c}`:u&&(f=Ti(s,u));let p=bR(o),g=[];if(i<t){let S=Array.from(o.children);for(let C of S){let F=C.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let R=(C.ownerDocument.defaultView||window).getComputedStyle(C);R.display==="none"||R.visibility==="hidden"||g.push(n(C,i+1))}}return{selector:f,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:g}}y.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return y.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:Mw(r)}),r}function Bg(e=4){y.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(y.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(y.debug("[extractStoryDOMTree] iframe.contentDocument:",!!t.contentDocument),!t.contentDocument)throw new Error("iframe.contentDocument is not accessible (possible cross-origin issue)");let n=t.contentDocument.getElementById("storybook-root");if(y.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(y.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=Bw(r,e);return y.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return y.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var xR,Dw=$(()=>{"use strict";De();_s();El();xR=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Dg=$(()=>{"use strict";_s();El();Lw();Dw()});var sv=Jn((eX,iv)=>{"use strict";iv.exports={compareTwoStrings:ov,findBestMatch:WR};function ov(e,t){if(e=e.replace(/\s+/g,""),t=t.replace(/\s+/g,""),e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let o=0;o<e.length-1;o++){let i=e.substring(o,o+2),s=n.has(i)?n.get(i)+1:1;n.set(i,s)}let r=0;for(let o=0;o<t.length-1;o++){let i=t.substring(o,o+2),s=n.has(i)?n.get(i):0;s>0&&(n.set(i,s-1),r++)}return 2*r/(e.length+t.length-2)}function WR(e,t){if(!VR(e,t))throw new Error("Bad arguments: First argument should be a string, second should be an array of strings");let n=[],r=0;for(let i=0;i<t.length;i++){let s=t[i],a=ov(e,s);n.push({target:s,rating:a}),a>n[r].rating&&(r=i)}let o=n[r];return{ratings:n,bestMatch:o,bestMatchIndex:r}}function VR(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var QC=Jn((Xoe,XC)=>{"use strict";var GC=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,N4=/\n/g,O4=/^\s*/,_4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$4=/^:\s*/,U4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,j4=/^[;\s]*/,H4=/^\s+|\s+$/g,W4=`
14
+ `,qC="/",YC="*",Qo="",V4="comment",G4="declaration";function q4(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(g){var S=g.match(N4);S&&(n+=S.length);var C=g.lastIndexOf(W4);r=~C?g.length-C:r+g.length}function i(){var g={line:n,column:r};return function(S){return S.position=new s(g),c(),S}}function s(g){this.start=g,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(g){var S=new Error(t.source+":"+n+":"+r+": "+g);if(S.reason=g,S.filename=t.source,S.line=n,S.column=r,S.source=e,!t.silent)throw S}function u(g){var S=g.exec(e);if(S){var C=S[0];return o(C),e=e.slice(C.length),S}}function c(){u(O4)}function l(g){var S;for(g=g||[];S=d();)S!==!1&&g.push(S);return g}function d(){var g=i();if(!(qC!=e.charAt(0)||YC!=e.charAt(1))){for(var S=2;Qo!=e.charAt(S)&&(YC!=e.charAt(S)||qC!=e.charAt(S+1));)++S;if(S+=2,Qo===e.charAt(S-1))return a("End of comment missing");var C=e.slice(2,S-2);return r+=2,o(C),e=e.slice(S),r+=2,g({type:V4,comment:C})}}function f(){var g=i(),S=u(_4);if(S){if(d(),!u($4))return a("property missing ':'");var C=u(U4),F=g({type:G4,property:KC(S[0].replace(GC,Qo)),value:C?KC(C[0].replace(GC,Qo)):Qo});return u(j4),F}}function p(){var g=[];l(g);for(var S;S=f();)S!==!1&&(g.push(S),l(g));return g}return c(),p()}function KC(e){return e?e.replace(H4,Qo):Qo}XC.exports=q4});var JC=Jn(oa=>{"use strict";var Y4=oa&&oa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(oa,"__esModule",{value:!0});oa.default=X4;var K4=Y4(QC());function X4(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,K4.default)(e),o=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;let{property:s,value:a}=i;o?t(s,a,i):a&&(n=n||{},n[s]=a)}),n}});var e1=Jn(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.camelCase=void 0;var Q4=/^--[a-zA-Z0-9_-]+$/,J4=/-([a-z])/g,Z4=/^[^-]+$/,eU=/^-(webkit|moz|ms|o|khtml)-/,tU=/^-(ms)-/,nU=function(e){return!e||Z4.test(e)||Q4.test(e)},rU=function(e,t){return t.toUpperCase()},ZC=function(e,t){return"".concat(t,"-")},oU=function(e,t){return t===void 0&&(t={}),nU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(tU,ZC):e=e.replace(eU,ZC),e.replace(J4,rU))};pc.camelCase=oU});var n1=Jn((hh,t1)=>{"use strict";var iU=hh&&hh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},sU=iU(JC()),aU=e1();function mh(e,t){var n={};return!e||typeof e!="string"||(0,sU.default)(e,function(r,o){r&&o&&(n[(0,aU.camelCase)(r,t)]=o)}),n}mh.default=mh;t1.exports=mh});var AT=Jn((Tue,ET)=>{"use strict";var Dc=Object.prototype.hasOwnProperty,FT=Object.prototype.toString,wT=Object.defineProperty,vT=Object.getOwnPropertyDescriptor,kT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):FT.call(t)==="[object Array]"},CT=function(t){if(!t||FT.call(t)!=="[object Object]")return!1;var n=Dc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Dc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Dc.call(t,o)},TT=function(t,n){wT&&n.name==="__proto__"?wT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},IT=function(t,n){if(n==="__proto__")if(Dc.call(t,n)){if(vT)return vT(t,n).value}else return;return t[n]};ET.exports=function e(){var t,n,r,o,i,s,a=arguments[0],u=1,c=arguments.length,l=!1;for(typeof a=="boolean"&&(l=a,a=arguments[1]||{},u=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});u<c;++u)if(t=arguments[u],t!=null)for(n in t)r=IT(a,n),o=IT(t,n),a!==o&&(l&&o&&(CT(o)||(i=kT(o)))?(i?(i=!1,s=r&&kT(r)?r:[]):s=r&&CT(r)?r:{},TT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&TT(a,{name:n,newValue:o}));return a}});import Fa from"react";import{addons as Kc,types as Ux,experimental_getStatusStore as mF}from"storybook/manager-api";import{AddonPanel as I8}from"storybook/internal/components";import Mt,{useState as VW,useEffect as GW}from"react";import{styled as fr}from"storybook/theming";import Xx from"react";import{styled as At}from"storybook/theming";var le="#ea580c",Jc="#c2410c",La="#ff6b35";var Wx=At.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),Vx=At.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),ts=At.div({marginBottom:"20px"}),ns=At.label(({theme:e})=>({display:"block",marginBottom:`${e.layoutMargin*.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),rs=At.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,"&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`}})),En=At.select(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.8}px 32px ${e.layoutMargin*.8}px ${e.layoutMargin}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.input.background,color:e.color.defaultText,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px",transition:"border-color 0.15s, box-shadow 0.15s","&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`},"&:hover":{borderColor:e.color.mediumdark},"&:disabled":{opacity:.6,cursor:"not-allowed"}})),Gx=At(En)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),Ma=e=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:disabled":{opacity:.5,cursor:"not-allowed"}}),er=At.button(({theme:e})=>({...Ma(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),en=At.button(({theme:e})=>({...Ma(e),backgroundColor:le,color:e.color.inverseText,boxShadow:`0 2px 4px ${le}4d`,"&:hover:not(:disabled)":{backgroundColor:Jc,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${le}66`}})),Er=At.button(({theme:e})=>({...Ma(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),qx=At.button(({theme:e})=>({...Ma(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),wn=At.button(({theme:e})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:`${e.layoutMargin*.4}px`,fontSize:e.typography.size.s2,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Zc=At.button(({theme:e})=>({padding:0,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.secondary,backgroundColor:"transparent",border:"none",cursor:"pointer",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),io=At.button(({theme:e,active:t})=>({padding:`${e.layoutMargin*.6}px ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:t?e.typography.weight.bold:400,color:t?e.color.secondary:e.color.mediumdark,backgroundColor:"transparent",border:"none",borderBottom:t?`2px solid ${e.color.secondary}`:"2px solid transparent",cursor:"pointer",transition:"all 0.15s","&:hover":{color:t?e.color.secondary:e.color.defaultText}})),so=At(rs)(({theme:e})=>({paddingLeft:`${e.layoutMargin*3}px`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:`${e.layoutMargin}px center`,backgroundSize:"14px"})),D8=At.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Yx=At.h2(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s3,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),R8=At.h3(({theme:e})=>({margin:`0 0 ${e.layoutMargin*1.2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),eu=At.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),z8=At.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.background.hoverable,borderRadius:e.appBorderRadius,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"100%",background:`linear-gradient(90deg, transparent, ${e.color.mediumlight}33, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{transform:"translateX(-100%)"},"100%":{transform:"translateX(100%)"}}})),Kx=At.span(({theme:e,variant:t="default"})=>{let n={default:{bg:e.background.hoverable,color:e.color.defaultText},success:{bg:`${e.color.positive}40`,color:e.color.positive},warning:{bg:`${e.color.warning}40`,color:e.color.warning},error:{bg:`${e.color.negative}40`,color:e.color.negative}};return{display:"inline-block",padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,borderRadius:"3px",backgroundColor:n[t].bg,color:n[t].color}}),N8=At.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),O8=At.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),_8=At.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var tu=({header:e,children:t,footer:n})=>Xx.createElement(Wx,null,e,Xx.createElement(Vx,null,t),n);import CF from"react";import{styled as TF}from"storybook/theming";var IF=TF.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),nu=({toolbar:e})=>CF.createElement(IF,null,e);import K8 from"react";import{styled as Ba}from"storybook/theming";var J8=Ba.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,zIndex:100,backgroundColor:e.background.content})),Z8=Ba.div({display:"flex",flex:1}),eV=Ba(io)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),tV=Ba.div({display:"flex",gap:"8px",alignItems:"center"});import pn,{useState as hw,useCallback as xw,useEffect as yw}from"react";import{styled as fo}from"storybook/theming";import Re,{useEffect as cw}from"react";import{styled as at}from"storybook/theming";ve();je();De();pt();var uw=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),pw=at.div(({theme:e})=>({position:"absolute",top:"100%",right:0,marginTop:"8px",backgroundColor:e.background.content,borderRadius:"12px",width:"360px",maxWidth:"90vw",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)",overflow:"hidden",zIndex:10001})),cD=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),uD=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),pD=at.div({display:"flex",flexDirection:"column",gap:"4px"}),dD=at.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),fD=at.span({display:"inline-block",alignSelf:"flex-start",padding:"2px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:600,color:"#7c3aed",backgroundColor:"rgba(124, 58, 237, 0.1)",letterSpacing:"0.3px"}),gD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),mD=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),hD=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),xD=at.div(({theme:e})=>({height:"8px",borderRadius:"4px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",margin:"0 16px 8px",overflow:"hidden"})),yD=at.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${le} 100%)`,transition:"width 0.3s ease"})),bD=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),SD=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),wD=at.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:le,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),vD=at.button(({theme:e})=>({position:"absolute",top:"12px",right:"12px",width:"24px",height:"24px",borderRadius:"4px",border:"none",background:"transparent",color:e.textMutedColor,cursor:"pointer",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:e.background.hoverable}})),kD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),CD=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),TD=at.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),ID=at.div({display:"flex",gap:"8px"}),dw=at(wn)({fontSize:"18px"}),FD=at.div({padding:"20px 16px"}),ED=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),AD=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),PD=at.div({fontSize:"28px",fontWeight:700}),LD=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),MD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),BD=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),DD=at.div({display:"flex",alignItems:"center",gap:"8px"}),RD=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),zD=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:le,color:e.color.inverseText})),ND=at.button(({theme:e})=>({background:"none",border:"none",color:le,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),OD=at.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),_D=at.button(({theme:e,variant:t="primary"})=>({width:"100%",padding:"12px",borderRadius:"6px",fontSize:"14px",fontWeight:600,cursor:"pointer",border:"none",marginBottom:"12px",backgroundColor:t==="primary"?le:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),$D=30*1e3,fw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ie(),a=s.showCosts,u=r,c=!r&&t,l=async(g=!1)=>{if(!t)return;let S=o&&Date.now()-o<$D;if(!(!g&&S&&r))try{let C=q(),F=await oe(`${C}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(F.ok){let k=await F.json();i(k)}}catch(C){y.error("Failed to fetch usage:",C)}};cw(()=>{l()},[t]),cw(()=>{let g=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[t]);let d=()=>{n(),e()},f=()=>{let g=q();window.open(`${g}/pricing`,"_blank")},p=()=>{let g=q();window.open(`${g}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let g=Math.floor(u?.creditBalance??0),C=Math.max(g,10),F=Math.max(0,C-g),k=C>0?g/C*100:0;return Re.createElement(Re.Fragment,null,Re.createElement(uw,{onClick:e}),Re.createElement(pw,{onClick:R=>R.stopPropagation(),style:{width:"320px"}},Re.createElement(vD,{onClick:e,title:"Close"},"\xD7"),Re.createElement(cD,null,Re.createElement(uD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement(pD,null,Re.createElement(dD,null,"UI Review"),Re.createElement(fD,null,(u?.plan||"BETA").toUpperCase()))),Re.createElement(gD,null,Re.createElement(mD,null,"Credits"),Re.createElement(hD,null,g," left")),Re.createElement(xD,null,Re.createElement(yD,{percent:k})),Re.createElement(bD,null,F," used \xB7 ",g," remaining"),Re.createElement(SD,null),Re.createElement(wD,{onClick:p},"Get free credits \u2192")))}return Re.createElement(Re.Fragment,null,Re.createElement(uw,{onClick:e}),Re.createElement(pw,{onClick:g=>g.stopPropagation()},Re.createElement(kD,null,Re.createElement(CD,null,Re.createElement(TD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement("span",null,u?.email||"Loading...")),Re.createElement(ID,null,Re.createElement(dw,{onClick:d,title:"Sign out"},"\u2192"),Re.createElement(dw,{onClick:e,title:"Close"},"\xD7"))),Re.createElement(FD,null,c?Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Re.createElement(Re.Fragment,null,Re.createElement(ED,null,Re.createElement(AD,null,"Credit Balance"),Re.createElement(PD,null,"$",(u?.creditBalance??0).toFixed(2)),Re.createElement(LD,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Re.createElement(MD,null,Re.createElement(BD,null,Re.createElement(DD,null,Re.createElement(RD,null,"Current Plan"),Re.createElement(zD,null,u?.plan||"Free")),Re.createElement(ND,{onClick:f},"View detail >")),Re.createElement(OD,null,"~$0.02-0.05 per review depending on complexity"),Re.createElement(_D,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};ve();import wi from"react";import{styled as gw}from"storybook/theming";je();ve();pt();De();var UD=gw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),jD=gw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),HD={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}},mw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ie(),{sessionToken:o}=we();return e!=="admin"?null:wi.createElement(UD,null,wi.createElement(jD,null,"View as:"),wi.createElement(Gx,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&oe(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>y.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=HD[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},wi.createElement("option",{value:"admin"},"Admin"),wi.createElement("option",{value:"beta"},"Beta Tester")),t&&wi.createElement(Kx,{variant:"warning"},"Previewing as ",t))};ve();je();pt();var WD=fo.div({display:"flex",alignItems:"center"}),vi=fo.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),VD=fo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),GD=fo.div({position:"relative"}),qD=fo.button(({theme:e})=>({width:"26px",height:"26px",padding:0,background:`linear-gradient(135deg, ${e.color.secondary} 0%, ${e.color.secondary}cc 100%)`,border:"none",borderRadius:"50%",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s","&:hover":{transform:"scale(1.05)",boxShadow:`0 2px 8px ${e.color.secondary}66`}})),bw=fo.button(({isLow:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",background:e?"#FEF3C7":"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",border:"none",borderRadius:"12px",color:e?"#92400E":"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,transition:"all 0.2s",minWidth:"60px",justifyContent:"center","&:hover":{transform:"scale(1.02)",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})),YD=fo.span({display:"inline-block",width:"12px",height:"12px",border:"2px solid rgba(255,255,255,0.3)",borderTopColor:"#fff",borderRadius:"50%",animation:"credit-spin 0.8s linear infinite","@keyframes credit-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),KD=fo.button(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",padding:"4px 10px",height:"28px",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.mediumdark,fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.mediumdark}})),XD=30*1e3,kg=({onOpenSettings:e})=>{let[t,n]=hw(!1),[r,o]=hw(!1),{usageData:i,usageLastFetched:s,setUsageData:a,sessionToken:u}=we(),{userRole:c,roleOverride:l,featureFlags:d}=ie(),f=l??c;yw(()=>{(async()=>{if(!(!u||s&&Date.now()-s<XD&&i)){o(!0);try{let R=q(),z=await oe(`${R}/api/addon/account`,{headers:{Authorization:`Bearer ${u}`}});if(z.ok){let _=await z.json();a(_)}}catch(R){console.error("Failed to fetch balance:",R)}finally{o(!1)}}})()},[u,s,i,a]),yw(()=>{let F=()=>{document.visibilityState==="visible"&&t&&n(!1)},k=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",F),window.addEventListener("focus",k),()=>{document.removeEventListener("visibilitychange",F),window.removeEventListener("focus",k)}},[t]);let p=xw(()=>{n(!0)},[]),g=xw(()=>{n(!1)},[]),S=i?.creditBalance??0,C=S<2&&!r;return pn.createElement(WD,null,e&&pn.createElement(vi,null,pn.createElement(KD,{onClick:e,title:"Settings"},pn.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),u&&c==="admin"&&f==="admin"&&pn.createElement(vi,null,pn.createElement(mw,null)),pn.createElement(vi,null,pn.createElement(VD,null,"v","0.5.5")),u&&d.showCosts&&pn.createElement(vi,null,pn.createElement(bw,{onClick:p,isLow:C,title:r?"Loading...":i?C?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},r?pn.createElement(YD,null):i?`$${S.toFixed(2)}`:"...")),u&&!d.showCosts&&i&&pn.createElement(vi,null,pn.createElement(bw,{onClick:p,isLow:Math.floor(S)<=3,title:`${Math.floor(S)} review credits remaining \u2014 click to manage`},"\u26A1 ",Math.floor(S))),pn.createElement(vi,null,pn.createElement(GD,null,pn.createElement(qD,{title:"Account & Usage",onClick:p},i?.email?i.email[0].toUpperCase():"?"),t&&pn.createElement(fw,{onClose:g}))))};import Et from"react";import{styled as cr}from"storybook/theming";import Lt from"react";ve();De();je();pt();import{useCallback as ki,useRef as Sw,useEffect as QD}from"react";var go=q();y.debug("[useAuth] Module loaded, APP_URL:",go);var Bs=()=>{let e=Sw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:f,setUserCode:p,setVerificationUri:g,setPollingInterval:S,setAuthError:C,resetAuth:F}=we(),k=Sw(null),R=ki(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let x;try{x=await oe(`${go}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let D=A instanceof Error&&A.message.includes("timed out")?`Cannot reach UI Copilot server at ${go}. Is the dashboard running?`:`Connection failed: ${go} is not responding.`;C(D),y.error("[useAuth]",D);return}if(!x.ok)throw new Error("Failed to create poll code");let{poll_code:b}=await x.json();y.debug("[useAuth] Got poll_code:",b.substring(0,15)+"...");let E=600,h=700,T=window.screenX+(window.outerWidth-E)/2,I=window.screenY+(window.outerHeight-h)/2;window.open(`${go}/addon/auth?poll_code=${b}`,"figma-auth",`width=${E},height=${h},left=${T},top=${I}`),y.debug("[useAuth] Starting OAuth poll for token..."),k.current&&clearInterval(k.current);let v=async()=>{try{let P=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:b})})).json();P.status==="authorized"&&P.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),k.current&&(clearInterval(k.current),k.current=null),localStorage.setItem("uicopilot_session_token",P.session_token),c(P.session_token)):P.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),k.current&&(clearInterval(k.current),k.current=null))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};k.current=setInterval(v,2e3),setTimeout(v,1e3)}catch(x){y.error("[useAuth] OAuth flow error:",x)}},[c]),z=ki(async()=>{try{let x=await fetch(`${go}/api/addon/auth/device`,{method:"POST"});if(!x.ok)throw new Error("Failed to start device code flow");let b=await x.json();f(b.device_code),p(b.user_code),g(b.verification_uri),window.open(b.verification_uri,"_blank"),_(b.device_code,b.interval*1e3)}catch(x){throw y.error("[useAuth] Device code flow error:",x),x}},[f,p,g]),_=ki((x,b)=>{y.debug("[useAuth] Starting polling. Device code:",x,"Interval:",b),e.current&&clearInterval(e.current);let E=async()=>{try{let T=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:x})})).json();T.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null),localStorage.setItem("uicopilot_session_token",T.session_token),c(T.session_token)):(T.status==="expired"||T.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null))}catch(h){y.error("[useAuth] Polling error:",h)}};e.current=setInterval(E,b),S(b)},[f,p,g,c,S]),M=ki(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),p(null),g(null),S(null)},[f,p,g,S]),B=ki(x=>{l(x),localStorage.setItem("uicopilot_api_key",x)},[l]),m=ki(()=>{F(),e.current&&(clearInterval(e.current),e.current=null)},[F]);return QD(()=>()=>{e.current&&clearInterval(e.current),k.current&&clearInterval(k.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setAuthMethod:d,startOAuth:R,startDeviceCode:z,cancelDeviceCode:M,saveApiKey:B,logout:m}};ve();De();je();pt();import{useCallback as Cl}from"react";var Ds=q(),qr=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Ze(),{sessionToken:a}=we(),u=Cl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Ds}/api/projects`);let f=await oe(`${Ds}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(f.ok){let p=await f.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",f.status,f.statusText)}catch(f){y.error("[useProjects] Error fetching projects:",f)}finally{i(!1)}},[a,r,i]),c=Cl(async f=>{if(!a)throw new Error("Not authenticated");let p=await oe(`${Ds}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)});if(!p.ok)throw new Error("Failed to create project");let g=await p.json();return await u(),g.project},[a,u]),l=Cl(async(f,p)=>{if(!a)throw new Error("Not authenticated");let g={};if(p.name!==void 0&&(g.name=p.name),p.description!==void 0&&(g.description=p.description),p.figmaFileUrl!==void 0&&(g.figmaFileId=p.figmaFileUrl||void 0),!(await oe(`${Ds}/api/projects/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=Cl(async f=>{if(!a)throw new Error("Not authenticated");if(!(await oe(`${Ds}/api/projects/${f}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===f&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:d}};ve();var Rs=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d}=rt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};ve();Eg();Dg();import{useCallback as Vs,useRef as zl}from"react";De();function Al(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){y.warn("[iframeReload] No preview iframe found"),e();return}let n=t.contentWindow.location.href,r=new URL(n);r.searchParams.set("_cb",Date.now().toString());let o=r.toString();y.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{y.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),y.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{y.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var Pl=BigInt(4294967295),Rw=BigInt(32);function SR(e,t=!1){return t?{h:Number(e&Pl),l:Number(e>>Rw&Pl)}:{h:Number(e>>Rw&Pl)|0,l:Number(e&Pl)|0}}function zw(e,t=!1){let n=e.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=SR(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Nw=(e,t,n)=>e<<n|t>>>32-n,Ow=(e,t,n)=>t<<n|e>>>32-n,_w=(e,t,n)=>t<<n-32|e>>>64-n,$w=(e,t,n)=>e<<n-32|t>>>64-n;function wR(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rg(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Ll(e,t,n=""){let r=wR(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){let s=n&&`"${n}" `,a=i?` of length ${t}`:"",u=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+u)}return e}function zg(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Uw(e,t){Ll(e,void 0,"digestInto() output");let n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function jw(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ng(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var vR=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function kR(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function CR(e){for(let t=0;t<e.length;t++)e[t]=kR(e[t]);return e}var Og=vR?e=>e:CR;function Hw(e,t={}){let n=(o,i)=>e(i).update(o).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=o=>e(o),Object.assign(n,t),Object.freeze(n)}var Ww=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var TR=BigInt(0),Us=BigInt(1),IR=BigInt(2),FR=BigInt(7),ER=BigInt(256),AR=BigInt(113),qw=[],Yw=[],Kw=[];for(let e=0,t=Us,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],qw.push(2*(5*r+n)),Yw.push((e+1)*(e+2)/2%64);let o=TR;for(let i=0;i<7;i++)t=(t<<Us^(t>>FR)*AR)%ER,t&IR&&(o^=Us<<(Us<<BigInt(i))-Us);Kw.push(o)}var Xw=zw(Kw,!0),PR=Xw[0],LR=Xw[1],Vw=(e,t,n)=>n>32?_w(e,t,n):Nw(e,t,n),Gw=(e,t,n)=>n>32?$w(e,t,n):Ow(e,t,n);function MR(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],d=Vw(c,l,1)^n[a],f=Gw(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=Yw[s],u=Vw(o,i,a),c=Gw(o,i,a),l=qw[s];o=e[l],i=e[l+1],e[l]=u,e[l+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=PR[r],e[1]^=LR[r]}Ng(n)}var _g=class e{constructor(t,n,r,o=!1,i=24){Zn(this,"state");Zn(this,"pos",0);Zn(this,"posOut",0);Zn(this,"finished",!1);Zn(this,"state32");Zn(this,"destroyed",!1);Zn(this,"blockLen");Zn(this,"suffix");Zn(this,"outputLen");Zn(this,"enableXOF",!1);Zn(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Rg(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=jw(this.state)}clone(){return this._cloneInto()}keccak(){Og(this.state32),MR(this.state32,this.rounds),Og(this.state32),this.posOut=0,this.pos=0}update(t){zg(this),Ll(t);let{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){zg(this,!1),Ll(t),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Rg(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Uw(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ng(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new e(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}},BR=(e,t,n,r={})=>Hw(()=>new _g(t,e,n),r);var Qw=BR(6,72,64,Ww(10));var DR=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,$g=Math.ceil,ar=Math.floor,Rn="[BigNumber Error] ",Jw=Rn+"Number primitive has more than 15 significant digits: ",Sr=1e14,He=14,Ug=9007199254740991,jg=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],mo=1e7,rn=1e9;function Zw(e){var t,n,r,o=k.prototype={constructor:k,toString:null,valueOf:null},i=new k(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,f=!1,p=1,g=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function k(m,x){var b,E,h,T,I,v,A,P,D=this;if(!(D instanceof k))return new k(m,x);if(x==null){if(m&&m._isBigNumber===!0){D.s=m.s,!m.c||m.e>d?D.c=D.e=null:m.e<l?D.c=[D.e=0]:(D.e=m.e,D.c=m.c.slice());return}if((v=typeof m=="number")&&m*0==0){if(D.s=1/m<0?(m=-m,-1):1,m===~~m){for(T=0,I=m;I>=10;I/=10,T++);T>d?D.c=D.e=null:(D.e=T,D.c=[m]);return}P=String(m)}else{if(!DR.test(P=String(m)))return r(D,P,v);D.s=P.charCodeAt(0)==45?(P=P.slice(1),-1):1}(T=P.indexOf("."))>-1&&(P=P.replace(".","")),(I=P.search(/e/i))>0?(T<0&&(T=I),T+=+P.slice(I+1),P=P.substring(0,I)):T<0&&(T=P.length)}else{if(Dt(x,2,C.length,"Base"),x==10&&F)return D=new k(m),M(D,s+D.e+1,a);if(P=String(m),v=typeof m=="number"){if(m*0!=0)return r(D,P,v,x);if(D.s=1/m<0?(P=P.slice(1),-1):1,k.DEBUG&&P.replace(/^0\.0*|\./,"").length>15)throw Error(Jw+m)}else D.s=P.charCodeAt(0)===45?(P=P.slice(1),-1):1;for(b=C.slice(0,x),T=I=0,A=P.length;I<A;I++)if(b.indexOf(E=P.charAt(I))<0){if(E=="."){if(I>T){T=A;continue}}else if(!h&&(P==P.toUpperCase()&&(P=P.toLowerCase())||P==P.toLowerCase()&&(P=P.toUpperCase()))){h=!0,I=-1,T=0;continue}return r(D,String(m),v,x)}v=!1,P=n(P,x,10,D.s),(T=P.indexOf("."))>-1?P=P.replace(".",""):T=P.length}for(I=0;P.charCodeAt(I)===48;I++);for(A=P.length;P.charCodeAt(--A)===48;);if(P=P.slice(I,++A)){if(A-=I,v&&k.DEBUG&&A>15&&(m>Ug||m!==ar(m)))throw Error(Jw+D.s*m);if((T=T-I-1)>d)D.c=D.e=null;else if(T<l)D.c=[D.e=0];else{if(D.e=T,D.c=[],I=(T+1)%He,T<0&&(I+=He),I<A){for(I&&D.c.push(+P.slice(0,I)),A-=He;I<A;)D.c.push(+P.slice(I,I+=He));I=He-(P=P.slice(I)).length}else I-=A;for(;I--;P+="0");D.c.push(+P)}}else D.c=[D.e=0]}k.clone=Zw,k.ROUND_UP=0,k.ROUND_DOWN=1,k.ROUND_CEIL=2,k.ROUND_FLOOR=3,k.ROUND_HALF_UP=4,k.ROUND_HALF_DOWN=5,k.ROUND_HALF_EVEN=6,k.ROUND_HALF_CEIL=7,k.ROUND_HALF_FLOOR=8,k.EUCLID=9,k.config=k.set=function(m){var x,b;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(x="DECIMAL_PLACES")&&(b=m[x],Dt(b,0,rn,x),s=b),m.hasOwnProperty(x="ROUNDING_MODE")&&(b=m[x],Dt(b,0,8,x),a=b),m.hasOwnProperty(x="EXPONENTIAL_AT")&&(b=m[x],b&&b.pop?(Dt(b[0],-rn,0,x),Dt(b[1],0,rn,x),u=b[0],c=b[1]):(Dt(b,-rn,rn,x),u=-(c=b<0?-b:b))),m.hasOwnProperty(x="RANGE"))if(b=m[x],b&&b.pop)Dt(b[0],-rn,-1,x),Dt(b[1],1,rn,x),l=b[0],d=b[1];else if(Dt(b,-rn,rn,x),b)l=-(d=b<0?-b:b);else throw Error(Rn+x+" cannot be zero: "+b);if(m.hasOwnProperty(x="CRYPTO"))if(b=m[x],b===!!b)if(b)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=b;else throw f=!b,Error(Rn+"crypto unavailable");else f=b;else throw Error(Rn+x+" not true or false: "+b);if(m.hasOwnProperty(x="MODULO_MODE")&&(b=m[x],Dt(b,0,9,x),p=b),m.hasOwnProperty(x="POW_PRECISION")&&(b=m[x],Dt(b,0,rn,x),g=b),m.hasOwnProperty(x="FORMAT"))if(b=m[x],typeof b=="object")S=b;else throw Error(Rn+x+" not an object: "+b);if(m.hasOwnProperty(x="ALPHABET"))if(b=m[x],typeof b=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(b))F=b.slice(0,10)=="0123456789",C=b;else throw Error(Rn+x+" invalid: "+b)}else throw Error(Rn+"Object expected: "+m);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:g,FORMAT:S,ALPHABET:C}},k.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!k.DEBUG)return!0;var x,b,E=m.c,h=m.e,T=m.s;e:if({}.toString.call(E)=="[object Array]"){if((T===1||T===-1)&&h>=-rn&&h<=rn&&h===ar(h)){if(E[0]===0){if(h===0&&E.length===1)return!0;break e}if(x=(h+1)%He,x<1&&(x+=He),String(E[0]).length==x){for(x=0;x<E.length;x++)if(b=E[x],b<0||b>=Sr||b!==ar(b))break e;if(b!==0)return!0}}}else if(E===null&&h===null&&(T===null||T===1||T===-1))return!0;throw Error(Rn+"Invalid BigNumber: "+m)},k.maximum=k.max=function(){return z(arguments,-1)},k.minimum=k.min=function(){return z(arguments,1)},k.random=(function(){var m=9007199254740992,x=Math.random()*m&2097151?function(){return ar(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(b){var E,h,T,I,v,A=0,P=[],D=new k(i);if(b==null?b=s:Dt(b,0,rn),I=$g(b/He),f)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(I*=2));A<I;)v=E[A]*131072+(E[A+1]>>>11),v>=9e15?(h=crypto.getRandomValues(new Uint32Array(2)),E[A]=h[0],E[A+1]=h[1]):(P.push(v%1e14),A+=2);A=I/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(I*=7);A<I;)v=(E[A]&31)*281474976710656+E[A+1]*1099511627776+E[A+2]*4294967296+E[A+3]*16777216+(E[A+4]<<16)+(E[A+5]<<8)+E[A+6],v>=9e15?crypto.randomBytes(7).copy(E,A):(P.push(v%1e14),A+=7);A=I/7}else throw f=!1,Error(Rn+"crypto unavailable");if(!f)for(;A<I;)v=x(),v<9e15&&(P[A++]=v%1e14);for(I=P[--A],b%=He,I&&b&&(v=jg[He-b],P[A]=ar(I/v)*v);P[A]===0;P.pop(),A--);if(A<0)P=[T=0];else{for(T=-1;P[0]===0;P.splice(0,1),T-=He);for(A=1,v=P[0];v>=10;v/=10,A++);A<He&&(T-=He-A)}return D.e=T,D.c=P,D}})(),k.sum=function(){for(var m=1,x=arguments,b=new k(x[0]);m<x.length;)b=b.plus(x[m++]);return b},n=(function(){var m="0123456789";function x(b,E,h,T){for(var I,v=[0],A,P=0,D=b.length;P<D;){for(A=v.length;A--;v[A]*=E);for(v[0]+=T.indexOf(b.charAt(P++)),I=0;I<v.length;I++)v[I]>h-1&&(v[I+1]==null&&(v[I+1]=0),v[I+1]+=v[I]/h|0,v[I]%=h)}return v.reverse()}return function(b,E,h,T,I){var v,A,P,D,N,w,j,G,L=b.indexOf("."),K=s,ee=a;for(L>=0&&(D=g,g=0,b=b.replace(".",""),G=new k(E),w=G.pow(b.length-L),g=D,G.c=x(Yr(sr(w.c),w.e,"0"),10,h,m),G.e=G.c.length),j=x(b,E,h,I?(v=C,m):(v=m,C)),P=D=j.length;j[--D]==0;j.pop());if(!j[0])return v.charAt(0);if(L<0?--P:(w.c=j,w.e=P,w.s=T,w=t(w,G,K,ee,h),j=w.c,N=w.r,P=w.e),A=P+K+1,L=j[A],D=h/2,N=N||A<0||j[A+1]!=null,N=ee<4?(L!=null||N)&&(ee==0||ee==(w.s<0?3:2)):L>D||L==D&&(ee==4||N||ee==6&&j[A-1]&1||ee==(w.s<0?8:7)),A<1||!j[0])b=N?Yr(v.charAt(1),-K,v.charAt(0)):v.charAt(0);else{if(j.length=A,N)for(--h;++j[--A]>h;)j[A]=0,A||(++P,j=[1].concat(j));for(D=j.length;!j[--D];);for(L=0,b="";L<=D;b+=v.charAt(j[L++]));b=Yr(b,P,v.charAt(0))}return b}})(),t=(function(){function m(E,h,T){var I,v,A,P,D=0,N=E.length,w=h%mo,j=h/mo|0;for(E=E.slice();N--;)A=E[N]%mo,P=E[N]/mo|0,I=j*A+P*w,v=w*A+I%mo*mo+D,D=(v/T|0)+(I/mo|0)+j*P,E[N]=v%T;return D&&(E=[D].concat(E)),E}function x(E,h,T,I){var v,A;if(T!=I)A=T>I?1:-1;else for(v=A=0;v<T;v++)if(E[v]!=h[v]){A=E[v]>h[v]?1:-1;break}return A}function b(E,h,T,I){for(var v=0;T--;)E[T]-=v,v=E[T]<h[T]?1:0,E[T]=v*I+E[T]-h[T];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,h,T,I,v){var A,P,D,N,w,j,G,L,K,ee,re,de,ae,qe,tt,se,pe,Ie=E.s==h.s?1:-1,ze=E.c,me=h.c;if(!ze||!ze[0]||!me||!me[0])return new k(!E.s||!h.s||(ze?me&&ze[0]==me[0]:!me)?NaN:ze&&ze[0]==0||!me?Ie*0:Ie/0);for(L=new k(Ie),K=L.c=[],P=E.e-h.e,Ie=T+P+1,v||(v=Sr,P=lr(E.e/He)-lr(h.e/He),Ie=Ie/He|0),D=0;me[D]==(ze[D]||0);D++);if(me[D]>(ze[D]||0)&&P--,Ie<0)K.push(1),N=!0;else{for(qe=ze.length,se=me.length,D=0,Ie+=2,w=ar(v/(me[0]+1)),w>1&&(me=m(me,w,v),ze=m(ze,w,v),se=me.length,qe=ze.length),ae=se,ee=ze.slice(0,se),re=ee.length;re<se;ee[re++]=0);pe=me.slice(),pe=[0].concat(pe),tt=me[0],me[1]>=v/2&&tt++;do{if(w=0,A=x(me,ee,se,re),A<0){if(de=ee[0],se!=re&&(de=de*v+(ee[1]||0)),w=ar(de/tt),w>1)for(w>=v&&(w=v-1),j=m(me,w,v),G=j.length,re=ee.length;x(j,ee,G,re)==1;)w--,b(j,se<G?pe:me,G,v),G=j.length,A=1;else w==0&&(A=w=1),j=me.slice(),G=j.length;if(G<re&&(j=[0].concat(j)),b(ee,j,re,v),re=ee.length,A==-1)for(;x(me,ee,se,re)<1;)w++,b(ee,se<re?pe:me,re,v),re=ee.length}else A===0&&(w++,ee=[0]);K[D++]=w,ee[0]?ee[re++]=ze[ae]||0:(ee=[ze[ae]],re=1)}while((ae++<qe||ee[0]!=null)&&Ie--);N=ee[0]!=null,K[0]||K.splice(0,1)}if(v==Sr){for(D=1,Ie=K[0];Ie>=10;Ie/=10,D++);M(L,T+(L.e=D+P*He-1)+1,I,N)}else L.e=P,L.r=+N;return L}})();function R(m,x,b,E){var h,T,I,v,A;if(b==null?b=a:Dt(b,0,8),!m.c)return m.toString();if(h=m.c[0],I=m.e,x==null)A=sr(m.c),A=E==1||E==2&&(I<=u||I>=c)?Bl(A,I):Yr(A,I,"0");else if(m=M(new k(m),x,b),T=m.e,A=sr(m.c),v=A.length,E==1||E==2&&(x<=T||T<=u)){for(;v<x;A+="0",v++);A=Bl(A,T)}else if(x-=I+(E===2&&T>I),A=Yr(A,T,"0"),T+1>v){if(--x>0)for(A+=".";x--;A+="0");}else if(x+=T-v,x>0)for(T+1==v&&(A+=".");x--;A+="0");return m.s<0&&h?"-"+A:A}function z(m,x){for(var b,E,h=1,T=new k(m[0]);h<m.length;h++)E=new k(m[h]),(!E.s||(b=jo(T,E))===x||b===0&&T.s===x)&&(T=E);return T}function _(m,x,b){for(var E=1,h=x.length;!x[--h];x.pop());for(h=x[0];h>=10;h/=10,E++);return(b=E+b*He-1)>d?m.c=m.e=null:b<l?m.c=[m.e=0]:(m.e=b,m.c=x),m}r=(function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,x=/^([^.]+)\.$/,b=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(T,I,v,A){var P,D=v?I:I.replace(h,"");if(E.test(D))T.s=isNaN(D)?null:D<0?-1:1;else{if(!v&&(D=D.replace(m,function(N,w,j){return P=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==P?w:N}),A&&(P=A,D=D.replace(x,"$1").replace(b,"0.$1")),I!=D))return new k(D,P);if(k.DEBUG)throw Error(Rn+"Not a"+(A?" base "+A:"")+" number: "+I);T.s=null}T.c=T.e=null}})();function M(m,x,b,E){var h,T,I,v,A,P,D,N=m.c,w=jg;if(N){e:{for(h=1,v=N[0];v>=10;v/=10,h++);if(T=x-h,T<0)T+=He,I=x,A=N[P=0],D=ar(A/w[h-I-1]%10);else if(P=$g((T+1)/He),P>=N.length)if(E){for(;N.length<=P;N.push(0));A=D=0,h=1,T%=He,I=T-He+1}else break e;else{for(A=v=N[P],h=1;v>=10;v/=10,h++);T%=He,I=T-He+h,D=I<0?0:ar(A/w[h-I-1]%10)}if(E=E||x<0||N[P+1]!=null||(I<0?A:A%w[h-I-1]),E=b<4?(D||E)&&(b==0||b==(m.s<0?3:2)):D>5||D==5&&(b==4||E||b==6&&(T>0?I>0?A/w[h-I]:0:N[P-1])%10&1||b==(m.s<0?8:7)),x<1||!N[0])return N.length=0,E?(x-=m.e+1,N[0]=w[(He-x%He)%He],m.e=-x||0):N[0]=m.e=0,m;if(T==0?(N.length=P,v=1,P--):(N.length=P+1,v=w[He-T],N[P]=I>0?ar(A/w[h-I]%w[I])*v:0),E)for(;;)if(P==0){for(T=1,I=N[0];I>=10;I/=10,T++);for(I=N[0]+=v,v=1;I>=10;I/=10,v++);T!=v&&(m.e++,N[0]==Sr&&(N[0]=1));break}else{if(N[P]+=v,N[P]!=Sr)break;N[P--]=0,v=1}for(T=N.length;N[--T]===0;N.pop());}m.e>d?m.c=m.e=null:m.e<l&&(m.c=[m.e=0])}return m}function B(m){var x,b=m.e;return b===null?m.toString():(x=sr(m.c),x=b<=u||b>=c?Bl(x,b):Yr(x,b,"0"),m.s<0?"-"+x:x)}return o.absoluteValue=o.abs=function(){var m=new k(this);return m.s<0&&(m.s=1),m},o.comparedTo=function(m,x){return jo(this,new k(m,x))},o.decimalPlaces=o.dp=function(m,x){var b,E,h,T=this;if(m!=null)return Dt(m,0,rn),x==null?x=a:Dt(x,0,8),M(new k(T),m+T.e+1,x);if(!(b=T.c))return null;if(E=((h=b.length-1)-lr(this.e/He))*He,h=b[h])for(;h%10==0;h/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(m,x){return t(this,new k(m,x),s,a)},o.dividedToIntegerBy=o.idiv=function(m,x){return t(this,new k(m,x),0,1)},o.exponentiatedBy=o.pow=function(m,x){var b,E,h,T,I,v,A,P,D,N=this;if(m=new k(m),m.c&&!m.isInteger())throw Error(Rn+"Exponent not an integer: "+B(m));if(x!=null&&(x=new k(x)),v=m.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!m.c||!m.c[0])return D=new k(Math.pow(+B(N),v?m.s*(2-Ml(m)):+B(m))),x?D.mod(x):D;if(A=m.s<0,x){if(x.c?!x.c[0]:!x.s)return new k(NaN);E=!A&&N.isInteger()&&x.isInteger(),E&&(N=N.mod(x))}else{if(m.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||v&&N.c[1]>=24e7:N.c[0]<8e13||v&&N.c[0]<=9999975e7)))return T=N.s<0&&Ml(m)?-0:0,N.e>-1&&(T=1/T),new k(A?1/T:T);g&&(T=$g(g/He+2))}for(v?(b=new k(.5),A&&(m.s=1),P=Ml(m)):(h=Math.abs(+B(m)),P=h%2),D=new k(i);;){if(P){if(D=D.times(N),!D.c)break;T?D.c.length>T&&(D.c.length=T):E&&(D=D.mod(x))}if(h){if(h=ar(h/2),h===0)break;P=h%2}else if(m=m.times(b),M(m,m.e+1,1),m.e>14)P=Ml(m);else{if(h=+B(m),h===0)break;P=h%2}N=N.times(N),T?N.c&&N.c.length>T&&(N.c.length=T):E&&(N=N.mod(x))}return E?D:(A&&(D=i.div(D)),x?D.mod(x):T?M(D,g,a,I):D)},o.integerValue=function(m){var x=new k(this);return m==null?m=a:Dt(m,0,8),M(x,x.e+1,m)},o.isEqualTo=o.eq=function(m,x){return jo(this,new k(m,x))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(m,x){return jo(this,new k(m,x))>0},o.isGreaterThanOrEqualTo=o.gte=function(m,x){return(x=jo(this,new k(m,x)))===1||x===0},o.isInteger=function(){return!!this.c&&lr(this.e/He)>this.c.length-2},o.isLessThan=o.lt=function(m,x){return jo(this,new k(m,x))<0},o.isLessThanOrEqualTo=o.lte=function(m,x){return(x=jo(this,new k(m,x)))===-1||x===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(m,x){var b,E,h,T,I=this,v=I.s;if(m=new k(m,x),x=m.s,!v||!x)return new k(NaN);if(v!=x)return m.s=-x,I.plus(m);var A=I.e/He,P=m.e/He,D=I.c,N=m.c;if(!A||!P){if(!D||!N)return D?(m.s=-x,m):new k(N?I:NaN);if(!D[0]||!N[0])return N[0]?(m.s=-x,m):new k(D[0]?I:a==3?-0:0)}if(A=lr(A),P=lr(P),D=D.slice(),v=A-P){for((T=v<0)?(v=-v,h=D):(P=A,h=N),h.reverse(),x=v;x--;h.push(0));h.reverse()}else for(E=(T=(v=D.length)<(x=N.length))?v:x,v=x=0;x<E;x++)if(D[x]!=N[x]){T=D[x]<N[x];break}if(T&&(h=D,D=N,N=h,m.s=-m.s),x=(E=N.length)-(b=D.length),x>0)for(;x--;D[b++]=0);for(x=Sr-1;E>v;){if(D[--E]<N[E]){for(b=E;b&&!D[--b];D[b]=x);--D[b],D[E]+=Sr}D[E]-=N[E]}for(;D[0]==0;D.splice(0,1),--P);return D[0]?_(m,D,P):(m.s=a==3?-1:1,m.c=[m.e=0],m)},o.modulo=o.mod=function(m,x){var b,E,h=this;return m=new k(m,x),!h.c||!m.s||m.c&&!m.c[0]?new k(NaN):!m.c||h.c&&!h.c[0]?new k(h):(p==9?(E=m.s,m.s=1,b=t(h,m,0,3),m.s=E,b.s*=E):b=t(h,m,0,p),m=h.minus(b.times(m)),!m.c[0]&&p==1&&(m.s=h.s),m)},o.multipliedBy=o.times=function(m,x){var b,E,h,T,I,v,A,P,D,N,w,j,G,L,K,ee=this,re=ee.c,de=(m=new k(m,x)).c;if(!re||!de||!re[0]||!de[0])return!ee.s||!m.s||re&&!re[0]&&!de||de&&!de[0]&&!re?m.c=m.e=m.s=null:(m.s*=ee.s,!re||!de?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(E=lr(ee.e/He)+lr(m.e/He),m.s*=ee.s,A=re.length,N=de.length,A<N&&(G=re,re=de,de=G,h=A,A=N,N=h),h=A+N,G=[];h--;G.push(0));for(L=Sr,K=mo,h=N;--h>=0;){for(b=0,w=de[h]%K,j=de[h]/K|0,I=A,T=h+I;T>h;)P=re[--I]%K,D=re[I]/K|0,v=j*P+D*w,P=w*P+v%K*K+G[T]+b,b=(P/L|0)+(v/K|0)+j*D,G[T--]=P%L;G[T]=b}return b?++E:G.splice(0,1),_(m,G,E)},o.negated=function(){var m=new k(this);return m.s=-m.s||null,m},o.plus=function(m,x){var b,E=this,h=E.s;if(m=new k(m,x),x=m.s,!h||!x)return new k(NaN);if(h!=x)return m.s=-x,E.minus(m);var T=E.e/He,I=m.e/He,v=E.c,A=m.c;if(!T||!I){if(!v||!A)return new k(h/0);if(!v[0]||!A[0])return A[0]?m:new k(v[0]?E:h*0)}if(T=lr(T),I=lr(I),v=v.slice(),h=T-I){for(h>0?(I=T,b=A):(h=-h,b=v),b.reverse();h--;b.push(0));b.reverse()}for(h=v.length,x=A.length,h-x<0&&(b=A,A=v,v=b,x=h),h=0;x;)h=(v[--x]=v[x]+A[x]+h)/Sr|0,v[x]=Sr===v[x]?0:v[x]%Sr;return h&&(v=[h].concat(v),++I),_(m,v,I)},o.precision=o.sd=function(m,x){var b,E,h,T=this;if(m!=null&&m!==!!m)return Dt(m,1,rn),x==null?x=a:Dt(x,0,8),M(new k(T),m,x);if(!(b=T.c))return null;if(h=b.length-1,E=h*He+1,h=b[h]){for(;h%10==0;h/=10,E--);for(h=b[0];h>=10;h/=10,E++);}return m&&T.e+1>E&&(E=T.e+1),E},o.shiftedBy=function(m){return Dt(m,-Ug,Ug),this.times("1e"+m)},o.squareRoot=o.sqrt=function(){var m,x,b,E,h,T=this,I=T.c,v=T.s,A=T.e,P=s+4,D=new k("0.5");if(v!==1||!I||!I[0])return new k(!v||v<0&&(!I||I[0])?NaN:I?T:1/0);if(v=Math.sqrt(+B(T)),v==0||v==1/0?(x=sr(I),(x.length+A)%2==0&&(x+="0"),v=Math.sqrt(+x),A=lr((A+1)/2)-(A<0||A%2),v==1/0?x="5e"+A:(x=v.toExponential(),x=x.slice(0,x.indexOf("e")+1)+A),b=new k(x)):b=new k(v+""),b.c[0]){for(A=b.e,v=A+P,v<3&&(v=0);;)if(h=b,b=D.times(h.plus(t(T,h,P,1))),sr(h.c).slice(0,v)===(x=sr(b.c)).slice(0,v))if(b.e<A&&--v,x=x.slice(v-3,v+1),x=="9999"||!E&&x=="4999"){if(!E&&(M(h,h.e+s+2,0),h.times(h).eq(T))){b=h;break}P+=4,v+=4,E=1}else{(!+x||!+x.slice(1)&&x.charAt(0)=="5")&&(M(b,b.e+s+2,1),m=!b.times(b).eq(T));break}}return M(b,b.e+s+1,a,m)},o.toExponential=function(m,x){return m!=null&&(Dt(m,0,rn),m++),R(this,m,x,1)},o.toFixed=function(m,x){return m!=null&&(Dt(m,0,rn),m=m+this.e+1),R(this,m,x)},o.toFormat=function(m,x,b){var E,h=this;if(b==null)m!=null&&x&&typeof x=="object"?(b=x,x=null):m&&typeof m=="object"?(b=m,m=x=null):b=S;else if(typeof b!="object")throw Error(Rn+"Argument not an object: "+b);if(E=h.toFixed(m,x),h.c){var T,I=E.split("."),v=+b.groupSize,A=+b.secondaryGroupSize,P=b.groupSeparator||"",D=I[0],N=I[1],w=h.s<0,j=w?D.slice(1):D,G=j.length;if(A&&(T=v,v=A,A=T,G-=T),v>0&&G>0){for(T=G%v||v,D=j.substr(0,T);T<G;T+=v)D+=P+j.substr(T,v);A>0&&(D+=P+j.slice(T)),w&&(D="-"+D)}E=N?D+(b.decimalSeparator||"")+((A=+b.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(b.fractionGroupSeparator||"")):N):D}return(b.prefix||"")+E+(b.suffix||"")},o.toFraction=function(m){var x,b,E,h,T,I,v,A,P,D,N,w,j=this,G=j.c;if(m!=null&&(v=new k(m),!v.isInteger()&&(v.c||v.s!==1)||v.lt(i)))throw Error(Rn+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+B(v));if(!G)return new k(j);for(x=new k(i),P=b=new k(i),E=A=new k(i),w=sr(G),T=x.e=w.length-j.e-1,x.c[0]=jg[(I=T%He)<0?He+I:I],m=!m||v.comparedTo(x)>0?T>0?x:P:v,I=d,d=1/0,v=new k(w),A.c[0]=0;D=t(v,x,0,1),h=b.plus(D.times(E)),h.comparedTo(m)!=1;)b=E,E=h,P=A.plus(D.times(h=P)),A=h,x=v.minus(D.times(h=x)),v=h;return h=t(m.minus(b),E,0,1),A=A.plus(h.times(P)),b=b.plus(h.times(E)),A.s=P.s=j.s,T=T*2,N=t(P,E,T,a).minus(j).abs().comparedTo(t(A,b,T,a).minus(j).abs())<1?[P,E]:[A,b],d=I,N},o.toNumber=function(){return+B(this)},o.toPrecision=function(m,x){return m!=null&&Dt(m,1,rn),R(this,m,x,2)},o.toString=function(m){var x,b=this,E=b.s,h=b.e;return h===null?E?(x="Infinity",E<0&&(x="-"+x)):x="NaN":(m==null?x=h<=u||h>=c?Bl(sr(b.c),h):Yr(sr(b.c),h,"0"):m===10&&F?(b=M(new k(b),s+h+1,a),x=Yr(sr(b.c),b.e,"0")):(Dt(m,2,C.length,"Base"),x=n(Yr(sr(b.c),h,"0"),10,m,E,!0)),E<0&&b.c[0]&&(x="-"+x)),x},o.valueOf=o.toJSON=function(){return B(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&k.set(e),k}function lr(e){var t=e|0;return e>0||e===t?t:t-1}function sr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=He-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function jo(e,t){var n,r,o=e.c,i=t.c,s=e.s,a=t.s,u=e.e,c=t.e;if(!s||!a)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=u==c,!o||!i)return r?0:!o^n?1:-1;if(!r)return u>c^n?1:-1;for(a=(u=o.length)<(c=i.length)?u:c,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^n?1:-1;return u==c?0:u>c^n?1:-1}function Dt(e,t,n,r){if(e<t||e>n||e!==ar(e))throw Error(Rn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Ml(e){var t=e.c.length-1;return lr(e.e/He)==t&&e.c[t]%2!=0}function Bl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Yr(e,t,n){var r,o;if(t<0){for(o=n+".";++t;o+=n);e=o+e}else if(r=e.length,++t>r){for(o=n,t-=r;--t;o+=n);e+=o}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var RR=Zw(),ev=RR;var zR=24,js=32,NR=()=>typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"?()=>{let e=new Uint32Array(1);return globalThis.crypto.getRandomValues(e),e[0]/4294967296}:Math.random,Wg=NR(),Hg=(e=4,t=Wg)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function OR(e){let t=new ev(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var nv=(e="")=>{let t=new TextEncoder;return OR(Qw(t.encode(e))).toString(36).slice(1)},tv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),_R=e=>tv[Math.floor(e()*tv.length)],$R=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=Wg}={})=>{let n=Object.keys(e).toString(),r=n.length?n+Hg(js,t):Hg(js,t);return nv(r).substring(0,js)},UR=e=>()=>e++,jR=476782367,rv=({random:e=Wg,counter:t=UR(Math.floor(e()*jR)),length:n=zR,fingerprint:r=$R({random:e})}={})=>{if(n>js)throw new Error(`Length must be between 2 and ${js}. Received: ${n}`);return function(){let i=_R(e),s=Date.now().toString(36),a=t().toString(36),u=Hg(n,e),c=`${s+u+a+r}`;return`${i+nv(c).substring(1,n)}`}},ho=HR(rv);function HR(e){let t;return()=>(t||(t=e()),t())}var GR=Pa(sv());Ls();De();var Dl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function qR(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function Vg(e,t){let n=[],r=e.split(`
15
+ `);for(let s=0;s<r.length;s++){let a=qR(r[s]),u=Dl.exec(a);if(u){let[,c,l,,d]=u,f=YR(l),p=KR(r,s+1),g={id:ho(),reviewId:t,type:c.trim(),severity:f,title:d.trim(),description:p.description,file:p.file,lineNumber:p.lineNumber,property:p.property,currentValue:p.currentValue,suggestedValue:p.suggestedValue,suggestedCode:p.suggestedCode,suggestedFix:p.suggestedFix,fixTarget:p.fixTarget,fixRequired:p.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(g)}Dl.lastIndex=0}return n.map(s=>{let a=Ps(s);return a.dismissed?(y.debug(`[parseIssues] Auto-dismissed: ${s.title} - ${a.dismissReason}`),{...s,dismissed:!0,dismissReason:a.dismissReason,dismissedBy:a.dismissedBy,dismissedAt:new Date}):s})}function YR(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function KR(e,t){let n={description:"",file:void 0,lineNumber:void 0,property:void 0,currentValue:void 0,suggestedValue:void 0,suggestedCode:void 0,suggestedFix:void 0,fixTarget:void 0,fixRequired:void 0},r=[];for(let o=t;o<e.length;o++){let i=e[o].trim();if(!i||Dl.test(i)){Dl.lastIndex=0;break}if(i.startsWith("Expected:"))n.suggestedValue=i.replace("Expected:","").trim();else if(i.startsWith("Actual:")||i.startsWith("Current:"))n.currentValue=i.replace(/^(Actual|Current):/,"").trim();else if(i.startsWith("File:")){let s=i.replace("File:","").trim(),a=s.match(/^(.+?):(\d+)$/);a?(n.file=a[1],n.lineNumber=parseInt(a[2],10)):n.file=s}else if(i.startsWith("Property:"))n.property=i.replace("Property:","").trim();else if(i.startsWith("FixTarget:")){let s=i.replace("FixTarget:","").trim().toLowerCase();(s==="css"||s==="component")&&(n.fixTarget=s)}else if(i.startsWith("FixRequired:")){let s=i.replace("FixRequired:","").trim().toLowerCase();n.fixRequired=s==="true"}else if(i.startsWith("Fix:"))n.suggestedFix=i.replace("Fix:","").trim();else if(i.startsWith("```")){let s=[];for(o++;o<e.length&&!e[o].trim().startsWith("```");)s.push(e[o]),o++;n.suggestedCode=s.join(`
16
+ `)}else r.push(i)}return n.description=r.join(" ").trim(),n}De();var Hs=null,av=0,XR=3e4;async function QR(){let e=Date.now();if(Hs&&e-av<XR)return Hs;try{let t=await fetch("/index.json");if(!t.ok)throw new Error(`Failed to fetch index.json: ${t.status}`);let n=await t.json();return Hs=n.entries||n.stories||{},av=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Hs).length),Hs}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ws(e){try{let n=(await QR())[e];if(!n?.importPath)return y.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;y.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),y.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,y.debug("[storyFilePaths] Derived componentFile:",i));let s=i.replace(/\.tsx$/,".css").replace(/\.ts$/,".css").replace(/\.jsx$/,".css").replace(/\.js$/,".css"),a=i.substring(0,i.lastIndexOf("/")),u={storyFile:o,componentFile:i,cssFile:s,baseDir:a};return y.debug("[storyFilePaths] Final paths:",u),u}catch(t){return y.error("[storyFilePaths] Error getting file paths:",t),null}}function Gg(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function JR(e,t){let n=e.toLowerCase().trim();return["color","spacing","typography","dimension","border","shadow","layout","background","font","size","margin","padding"].some(i=>n.includes(i))?t.cssFile:t.componentFile}function qg(e,t){let n=e.property?.toLowerCase()||"",r=e.domElement?.toLowerCase()||"",o=r.startsWith("svg"),i=r.startsWith("img"),s=n==="width"||n==="height",a=/\[(?:width|height)=/.test(r);return(o||i)&&s||a?(y.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):JR(e.type,t)}De();function ZR(e){let t=(e.description||"").toLowerCase(),n=(e.title||"").toLowerCase(),r=`${t} ${n}`;return r.includes("inner icon")||r.includes("inner vector")?"inner-icon":r.includes("second icon")?"icon-2":r.includes("first icon")?"icon-1":r.includes("icon")||r.includes("vector")||r.includes("svg")?"icon":r.includes("button")?"button":r.includes("text")||r.includes("label")?"text":r.includes("container")||r.includes("wrapper")?"container":"other"}function ez(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("width")||t.includes("height")||t.includes("size")||t.includes("dimensions")?"dimensions":t.includes("padding")||t.includes("margin")||t.includes("gap")?"spacing":t.includes("color")||t.includes("background")||t.includes("fill")?"colors":t.includes("font")||t.includes("text")||t.includes("line-height")?"typography":t.includes("border")||t.includes("radius")?"border":n.includes("overall")||n.includes("visual fidelity")||n.includes("pixel similarity")||t.includes("overall")?"summary":"other"}function tz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("overall")||t.includes("visual fidelity")||n.includes("pixel similarity score")||n.includes("primarily explained by")||n.includes("visual discrepancy")}function nz(e,t,n){let r={critical:3,major:2,minor:1},i=[...e].sort((c,l)=>(r[l.severity]||0)-(r[c.severity]||0))[0],s=e.length,a,u;if(t.includes("icon")&&n==="dimensions"){let c=e.map(d=>d.currentValue).filter(Boolean),l=e.map(d=>d.suggestedValue).filter(Boolean);a=`Icon sizing is incorrect (${s} related issues)`,u=`Icons are rendered at wrong dimensions. Current: ${c[0]||"10px"}, Expected: ${l[0]||"20px"}. This single CSS fix will resolve all ${s} icon dimension issues.`}else a=`${t} ${n} issues (${s} related)`,u=`${s} related ${n} issues for ${t}. ${i.description}`;return{...i,id:`merged-${t}-${n}-${i.id}`,title:a,description:u,currentValue:i.currentValue,suggestedValue:i.suggestedValue,mergedCount:s,mergedIssueIds:e.map(c=>c.id)}}function Yg(e){if(!e||e.length===0)return[];let t=e.filter(i=>!tz(i)),n=[],r=[];for(let i of t){let s=ZR(i),a=ez(i);s.includes("icon")&&a==="dimensions"?n.push(i):r.push(i)}let o=[];return n.length>0&&(n.length===1?o.push(n[0]):o.push(nz(n,"icon","dimensions"))),o.push(...r),y.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),y.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),y.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}De();je();import{addons as Rl}from"storybook/manager-api";var Kg="uireview/badge",Ii={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function rz(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function oz(e){let t=[`Score: ${e.score}`];return e.criticalCount>0&&t.push(`${e.criticalCount} critical`),e.majorCount>0&&t.push(`${e.majorCount} major`),e.minorCount>0&&t.push(`${e.minorCount} minor`),t.join(" \xB7 ")}function iz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Fi(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function cv(e){if(Fi())try{Rl.getChannel().emit(Ii.REVIEW_START,{storyId:e})}catch{}}function xo(e,t){if(Fi())try{Rl.getChannel().emit(Ii.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function uv(e){if(Fi())try{Rl.getChannel().emit(Ii.REVIEW_ERROR,{storyId:e})}catch{}}function lv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}function pv(e){let t=Rl.getChannel(),n=o=>i=>{Fi()&&o(i)};t.on(Ii.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:Kg,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(Ii.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:rz(i),typeId:Kg,storyId:o,title:iz(i),description:oz(i)}])})),t.on(Ii.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:Kg,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Fi();r||lv(e),setInterval(()=>{let o=Fi();o!==r&&(r=o,o||lv(e))},1500)}var Xg=q(),Qg=180;function yo(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="object"){let t=e;if("value"in t&&typeof t.value=="string")return t.value;if("top"in t||"left"in t){let n=[t.top,t.right,t.bottom,t.left].filter(Boolean);if(n.length>0)return n.join(" ")}return JSON.stringify(e)}return String(e)}var Jg=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:d,setReviewError:f,setReviewResults:p,setShowReviewMenu:g,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:_,setStreamingStatus:M,setFullPrompt:B,setFullResponse:m,setFigmaImageUrl:x,storybookImageUrl:b,setStorybookImageUrl:E,setFigmaDimensions:h,setMultiModelResults:T,updateMultiModelStreamingMessages:I,setModelCompleted:v,setActiveModelId:A,resetReview:P,addReview:D,setReviewDetailTab:N,includeTextComparison:w,usePromptCache:j,setApplyFixesResult:G,featureFlags:L}=ie(),{sessionToken:K,usageData:ee,setUsageData:re}=we(),{selectedProjectId:de}=Ze(),{currentStoryId:ae,currentStoryName:qe}=rt(),tt=zl(ee);tt.current=ee;let se=zl(null),pe=zl(null),Ie=zl({}),ze=Vs((Ge,lt)=>{k({role:Ge,content:lt})},[k]),me=Vs((Ge,lt)=>{_(Ge),M(lt)},[_,M]),Nt=Vs(async Ge=>{let{isIteration:lt=!1,parentReviewId:nt=null}=Ge||{};if(!K)throw new Error("Not authenticated");if(!de)throw new Error("No project selected");if(!ae||!qe)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let ne=Date.now();try{d(!0),f(null),p(null),N("issues"),G(null),ae&&L.enableReviewBadges&&cv(ae),pe.current&&clearTimeout(pe.current),pe.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${Qg}s timeout`),se.current&&se.current.abort(),k({role:"system",content:`Review auto-stopped after ${Qg} seconds timeout.`})},Qg*1e3),B(""),m(""),C(!0),F(!1),z(),me(0,"Starting review..."),me(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await Al(),y.debug("[Review] Iframe reloaded, styles should be fresh"),me(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[W,Ae,ge]=await Promise.all([Fl({sessionToken:K||void 0}),Promise.resolve($s()),Promise.resolve(Bg())]);if(W&&W!==b&&(E(W),y.debug("[Review] Storybook screenshot captured and set")),!Ae)throw new Error("Failed to extract styles from component");let{computed:O,declared:U,markup:H,textElementStyles:Pe,nestedElementStyles:Ne}=Ae;ge?y.debug("[Review] DOM tree extracted:",{selector:ge.selector,childrenCount:ge.children.length}):(y.error("[Review] DOM tree extraction FAILED - domTree is null"),y.error("[Review] This will cause AI to use comparison table instead of tree comparison")),me(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:ae,name:qe});let xt=mt.getState().currentMapping?.figmaNodeId??null,Un=mt.getState().figmaImageUrl;if(xt&&(y.debug("[Review] Using Figma node ID from store:",xt),Un&&(me(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!xt)try{let Xe=await fetch(`${Xg}/api/mappings?projectId=${de}&storyId=${ae}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`}});if(Xe.ok){let Bt=await Xe.json();Bt.mapping?.figmaNodeId?(xt=Bt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",xt)):y.debug("[Review] No mapping found for story:",ae)}else y.debug("[Review] Failed to fetch mapping:",Xe.status)}catch(Xe){y.error("[Review] Error fetching mapping:",Xe)}if(xt&&!Un){me(65,"Fetching Figma design...");try{let Xe=await fetch(`${Xg}/api/figma/frames?projectId=${de}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`}});if(Xe.ok){let Ot=(await Xe.json()).thumbnails?.[xt];Ot?(x(Ot),y.debug("[Review] Figma thumbnail fetched and displayed:",Ot)):y.warn("[Review] No thumbnail found for node:",xt)}else y.warn("[Review] Failed to fetch Figma frames:",Xe.status)}catch(Xe){y.error("[Review] Error fetching Figma frames:",Xe)}}if(!xt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');me(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let Qn={projectId:de,storyId:ae,storyName:qe,storybookScreenshot:W,computedStyles:O,declaredStyles:U,textElementStyles:Pe,nestedElementStyles:Ne,componentMarkup:H,domTree:ge,figmaNodeId:xt,figmaImageUrl:Un||void 0,aiModels:l,includeTextComparison:w,usePromptCache:j,parentReviewId:lt?nt:void 0,isIteration:lt};y.debug("[Review] Request payload:",{...Qn,storybookScreenshot:W?`${W.substring(0,50)}...`:null,domTree:ge?{selector:ge.selector,childrenCount:ge.children.length}:null}),se.current=new AbortController;let In=await fetch(`${Xg}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${K}`},body:JSON.stringify(Qn),signal:se.current.signal});if(y.debug("[Review] Response status:",In.status,In.statusText),!In.ok){let Xe=await In.json();if(y.error("[Review] API error response:",Xe),In.status===429){let Bt=Xe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Bt} seconds before trying again.`)}if(In.status===402){if(Xe.code==="INSUFFICIENT_CREDITS"){let Bt=Xe.details?.required??1,Ot=Xe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Bt} credit(s) but you have ${Ot}. Visit Settings to add more.`)}throw Xe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Xe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Xe.message||"Payment required")}throw In.status===401&&Xe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Xe.error||Xe.message||"Review request failed")}let oo=In.body?.getReader(),bn=new TextDecoder,Ir="",Zt="",Oe=null,Qc=null,jx=l.length>1,Bo={},Zi={},A8={};if(!oo)throw new Error("Response body is not readable");let Hx=mt.getState().streamingMessages.length;for(ze("assistant","");;){let{done:Xe,value:Bt}=await oo.read();if(Xe)break;Ir+=bn.decode(Bt,{stream:!0});let Ot=Ir.split(`
17
+ `);Ir=Ot.pop()||"";for(let jn of Ot)if(jn.startsWith("data: ")){let ln=jn.slice(6);if(ln==="[DONE]")continue;try{let te=JSON.parse(ln);if(te.type!=="text"&&te.type!=="content"&&y.debug("[Review] SSE Event received:",te.type),te.type==="prompt")te.prompt&&(B(te.prompt),y.debug("[Review] Prompt received early"));else if(te.type==="model_started")y.debug("[Review] Model started:",te.modelId),Bo[te.modelId]||(Bo[te.modelId]="",Zi[te.modelId]=[{role:"assistant",content:""}]);else if(te.type==="text"||te.type==="content")if(jx&&te.modelId){Bo[te.modelId]||(Bo[te.modelId]="",Zi[te.modelId]=[{role:"assistant",content:""}]),Bo[te.modelId]+=te.content,Zi[te.modelId][0].content=Bo[te.modelId],I(te.modelId,Zi[te.modelId]);let Gt=Object.entries(Bo).map(([cn,st])=>`[${cn}]
18
18
  ${st}`).join(`
19
19
 
20
20
  ---
21
21
 
22
- `);R(Ux,Gt)}else en+=te.content,R(Ux,en);else if(te.type==="model_completed")y.debug("[Review] Model completed:",te.modelId,te.complianceScore),v(te.modelId);else if(te.type==="figma_image")te.url&&(x(te.url),y.debug("[Review] Figma image URL received:",te.url));else if(te.type==="figma_dimensions")te.width&&te.height&&(h({width:te.width,height:te.height}),y.debug("[Review] Figma dimensions received:",te.width,"x",te.height));else if(te.type==="complete"||te.type==="result")Oe=te,y.debug("[Review] Final result received! Type:",te.type),y.debug("[Review] Final result issues count:",te.issues?.length||0),y.debug("[Review] Final result score:",te.validation?.complianceScore),te.remainingCredits!=null&&tt.current&&re({...tt.current,creditBalance:te.remainingCredits,reviewCredits:Math.floor(te.remainingCredits)});else if(te.type==="all_complete")Oe=te,y.debug("[Review] Multi-model results received:",Object.keys(te.byModel)),te.remainingCredits!=null&&tt.current&&re({...tt.current,creditBalance:te.remainingCredits,reviewCredits:Math.floor(te.remainingCredits)});else if(te.type==="error"||te.type==="model_error"){let Gt=new Error(te.message||te.error||"Streaming error");throw Gt.isServerError=!0,Gt}}catch(te){if(te.isServerError)throw te;let Gt=te instanceof Error?{message:te.message,name:te.name,stack:te.stack}:String(te);y.error("[Review] Error parsing SSE data:",Gt),y.error("[Review] Failed to parse data:",ln.substring(0,200)+(ln.length>200?"...":"")),qc=te instanceof Error?te:new Error(String(te))}}}if(me(100,"Review complete!"),!Oe&&qc&&(y.error("[Review] No final result received. Last parse error:",qc),y.error("[Review] Streaming text available:",en.length,"chars")),$x&&Oe?.type==="all_complete"){let Xe=Object.keys(Oe.byModel).reduce((Ot,jn)=>{let ln=Oe.byModel[jn];return Ot[jn]={...ln,fullResponse:ln.response||ln.fullResponse||"",fullPrompt:ln.prompt||ln.fullPrompt||"",streamingMessages:Zi[jn]||[]},Ot},{}),Bt=Object.keys(Oe.byModel)[0];T({byModel:Xe,activeModelId:Bt}),Xe[Bt]?.fullPrompt&&B(Xe[Bt].fullPrompt),y.debug("[Review] Multi-model results stored:",Object.keys(Oe.byModel));try{let Ot=ho(),jn=Oe.byModel?.[Bt]?.issues,ln=jn&&jn.length>0,te=ln?jn.map(fe=>({id:ho(),reviewId:Ot,dbId:fe.dbId,type:fe.type,severity:fe.severity,title:fe.description,description:fe.description,property:fe.property,expected:yo(fe.expected),actual:yo(fe.actual),currentValue:yo(fe.actual),suggestedValue:yo(fe.expected),source:fe.source||"computed-styles",suggestedFix:fe.suggestedFix,file:fe.file,domElement:fe.domElement,figmaElement:fe.figmaElement,fixTarget:fe.fixTarget,fixRequired:fe.fixRequired,detectedBy:fe.detectedBy,dismissed:fe.dismissed??!1,dismissReason:fe.dismissReason,dismissedAt:fe.dismissed?new Date:void 0,_unreliable:fe._unreliable,_validationError:fe._validationError,figmaContext:fe.figmaContext,relatedTo:Array.isArray(fe.relatedTo)?fe.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Ug(Xe[Bt]?.fullResponse||"",Ot);y.debug("[Review] Multi-model issues source:",ln?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Multi-model issues count:",te.length,"issues");let Gt=te.filter(fe=>fe.dismissed).length;Gt>0&&(y.debug("[Review] Multi-model auto-dismissed:",Gt,"false positive issues"),ze("system",`
22
+ `);R(Hx,Gt)}else Zt+=te.content,R(Hx,Zt);else if(te.type==="model_completed")y.debug("[Review] Model completed:",te.modelId,te.complianceScore),v(te.modelId);else if(te.type==="figma_image")te.url&&(x(te.url),y.debug("[Review] Figma image URL received:",te.url));else if(te.type==="figma_dimensions")te.width&&te.height&&(h({width:te.width,height:te.height}),y.debug("[Review] Figma dimensions received:",te.width,"x",te.height));else if(te.type==="complete"||te.type==="result")Oe=te,y.debug("[Review] Final result received! Type:",te.type),y.debug("[Review] Final result issues count:",te.issues?.length||0),y.debug("[Review] Final result score:",te.validation?.complianceScore),te.remainingCredits!=null&&tt.current&&re({...tt.current,creditBalance:te.remainingCredits,reviewCredits:Math.floor(te.remainingCredits)});else if(te.type==="all_complete")Oe=te,y.debug("[Review] Multi-model results received:",Object.keys(te.byModel)),te.remainingCredits!=null&&tt.current&&re({...tt.current,creditBalance:te.remainingCredits,reviewCredits:Math.floor(te.remainingCredits)});else if(te.type==="error"||te.type==="model_error"){let Gt=new Error(te.message||te.error||"Streaming error");throw Gt.isServerError=!0,Gt}}catch(te){if(te.isServerError)throw te;let Gt=te instanceof Error?{message:te.message,name:te.name,stack:te.stack}:String(te);y.error("[Review] Error parsing SSE data:",Gt),y.error("[Review] Failed to parse data:",ln.substring(0,200)+(ln.length>200?"...":"")),Qc=te instanceof Error?te:new Error(String(te))}}}if(me(100,"Review complete!"),!Oe&&Qc&&(y.error("[Review] No final result received. Last parse error:",Qc),y.error("[Review] Streaming text available:",Zt.length,"chars")),jx&&Oe?.type==="all_complete"){let Xe=Object.keys(Oe.byModel).reduce((Ot,jn)=>{let ln=Oe.byModel[jn];return Ot[jn]={...ln,fullResponse:ln.response||ln.fullResponse||"",fullPrompt:ln.prompt||ln.fullPrompt||"",streamingMessages:Zi[jn]||[]},Ot},{}),Bt=Object.keys(Oe.byModel)[0];T({byModel:Xe,activeModelId:Bt}),Xe[Bt]?.fullPrompt&&B(Xe[Bt].fullPrompt),y.debug("[Review] Multi-model results stored:",Object.keys(Oe.byModel));try{let Ot=ho(),jn=Oe.byModel?.[Bt]?.issues,ln=jn&&jn.length>0,te=ln?jn.map(fe=>({id:ho(),reviewId:Ot,dbId:fe.dbId,type:fe.type,severity:fe.severity,title:fe.description,description:fe.description,property:fe.property,expected:yo(fe.expected),actual:yo(fe.actual),currentValue:yo(fe.actual),suggestedValue:yo(fe.expected),source:fe.source||"computed-styles",suggestedFix:fe.suggestedFix,file:fe.file,domElement:fe.domElement,figmaElement:fe.figmaElement,fixTarget:fe.fixTarget,fixRequired:fe.fixRequired,detectedBy:fe.detectedBy,dismissed:fe.dismissed??!1,dismissReason:fe.dismissReason,dismissedAt:fe.dismissed?new Date:void 0,_unreliable:fe._unreliable,_validationError:fe._validationError,figmaContext:fe.figmaContext,relatedTo:Array.isArray(fe.relatedTo)?fe.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Vg(Xe[Bt]?.fullResponse||"",Ot);y.debug("[Review] Multi-model issues source:",ln?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Multi-model issues count:",te.length,"issues");let Gt=te.filter(fe=>fe.dismissed).length;Gt>0&&(y.debug("[Review] Multi-model auto-dismissed:",Gt,"false positive issues"),ze("system",`
23
23
 
24
24
  ---
25
25
 
26
- \u2705 ${Gt} issue${Gt>1?"s were":" was"} auto-dismissed as false positive${Gt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let cn=Ie.current[ae];cn||(cn=await Ws(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},cn.storyFile&&(Ie.current[ae]=cn)),y.debug("[Review] Story file paths:",cn);let st=te.map(fe=>({...fe,file:fe.file||jg(fe.fixTarget,cn)||Hg(fe,cn)}));if(st=Wg(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!w){let fe=st.length;st=st.filter(Sn=>Sn.property?.toLowerCase()!=="textcontent"&&!Sn.description?.toLowerCase().includes("text content")),fe!==st.length&&y.debug("[Review] Filtered out",fe-st.length,"textContent issues (toggle OFF)")}let Fr=Oe.validation?.complianceScore??Xe[Bt]?.complianceScore;if(y.debug("[Review] Multi-model score sources:",{firstModelId:Bt,validationScore:Oe.validation?.complianceScore,modelScore:Xe[Bt]?.complianceScore,multiModelScore:Fr}),Fr==null){let Sn=(Xe[Bt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Fr=Sn?parseInt(Sn[1],10):void 0,y.debug("[Review] Parsed multi-model score from response:",Fr)}let Fn;lt&&nt&&(Fn=(ht.getState().reviewHistory.find(Sn=>Sn.id===nt)?.iterationNumber||0)+1);let es={id:Ot,componentId:ae,storyId:ae,modelId:Bt,parentReviewId:lt&&nt||void 0,iterationNumber:Fn,figmaFileKey:void 0,figmaNodeId:yt||void 0,figmaFileUrl:Un||void 0,complianceScore:Fr,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(fe=>!fe.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-ne,costUsd:Oe.costUsd,inputTokens:Oe.inputTokens,outputTokens:Oe.outputTokens,cacheCreationTokens:Oe.cacheCreationTokens,cacheReadTokens:Oe.cacheReadTokens};if(y.debug("[Review] Multi-model token data:",{costUsd:Oe.costUsd,inputTokens:Oe.inputTokens,outputTokens:Oe.outputTokens,cacheCreationTokens:Oe.cacheCreationTokens,cacheReadTokens:Oe.cacheReadTokens,reviewTokens:es.inputTokens}),D(es),ae&&L.enableReviewBadges){let fe=st.filter(Sn=>!Sn.dismissed);xo(ae,{score:Fr??100,issueCount:fe.length,criticalCount:fe.filter(Sn=>Sn.severity==="critical").length,majorCount:fe.filter(Sn=>Sn.severity==="major").length,minorCount:fe.filter(Sn=>Sn.severity==="minor").length})}N("issues");let Fa=st.filter(fe=>!fe.dismissed).length;y.debug("[Review] Created multi-model review with",Fa,"active issues,",st.length-Fa,"dismissed");let Se=yt||ht.getState().currentMapping?.figmaNodeId;y.debug("[Review] Issue validation handled server-side. Active:",st.filter(fe=>!fe.dismissed).length,"Dismissed:",st.filter(fe=>fe.dismissed).length)}catch(Ot){y.error("[Review] Failed to parse issues from multi-model response:",Ot)}}else if(Oe){Oe.prompt&&B(Oe.prompt),(Oe.response||en)&&m(Oe.response||en),Oe.figmaImageUrl&&x(Oe.figmaImageUrl),y.debug("[Review] State updated with prompt, response, and screenshots");try{let Xe=ho(),Bt=Oe.response||en,Ot=Oe.issues,jn=Ot&&Ot.length>0,ln=jn?Ot.map(Se=>({id:ho(),reviewId:Xe,dbId:Se.dbId,type:Se.type,severity:Se.severity,title:Se.description,description:Se.description,property:Se.property,expected:yo(Se.expected),actual:yo(Se.actual),currentValue:yo(Se.actual),suggestedValue:yo(Se.expected),source:Se.source||"computed-styles",suggestedFix:Se.suggestedFix,file:Se.file,domElement:Se.domElement,figmaElement:Se.figmaElement,fixTarget:Se.fixTarget,fixRequired:Se.fixRequired,detectedBy:Se.detectedBy,dismissed:Se.dismissed??!1,dismissReason:Se.dismissReason,dismissedAt:Se.dismissed?new Date:void 0,_unreliable:Se._unreliable,_validationError:Se._validationError,figmaContext:Se.figmaContext,relatedTo:Array.isArray(Se.relatedTo)?Se.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Ug(Bt,Xe);y.debug("[Review] Issues source:",jn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Issues count:",ln.length,"issues");let te=ln.filter(Se=>Se.dismissed).length;te>0&&(y.debug("[Review] Auto-dismissed:",te,"false positive issues"),ze("system",`
26
+ \u2705 ${Gt} issue${Gt>1?"s were":" was"} auto-dismissed as false positive${Gt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let cn=Ie.current[ae];cn||(cn=await Ws(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},cn.storyFile&&(Ie.current[ae]=cn)),y.debug("[Review] Story file paths:",cn);let st=te.map(fe=>({...fe,file:fe.file||Gg(fe.fixTarget,cn)||qg(fe,cn)}));if(st=Yg(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!w){let fe=st.length;st=st.filter(Sn=>Sn.property?.toLowerCase()!=="textcontent"&&!Sn.description?.toLowerCase().includes("text content")),fe!==st.length&&y.debug("[Review] Filtered out",fe-st.length,"textContent issues (toggle OFF)")}let Fr=Oe.validation?.complianceScore??Xe[Bt]?.complianceScore;if(y.debug("[Review] Multi-model score sources:",{firstModelId:Bt,validationScore:Oe.validation?.complianceScore,modelScore:Xe[Bt]?.complianceScore,multiModelScore:Fr}),Fr==null){let Sn=(Xe[Bt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Fr=Sn?parseInt(Sn[1],10):void 0,y.debug("[Review] Parsed multi-model score from response:",Fr)}let Fn;lt&&nt&&(Fn=(mt.getState().reviewHistory.find(Sn=>Sn.id===nt)?.iterationNumber||0)+1);let es={id:Ot,componentId:ae,storyId:ae,modelId:Bt,parentReviewId:lt&&nt||void 0,iterationNumber:Fn,figmaFileKey:void 0,figmaNodeId:xt||void 0,figmaFileUrl:Un||void 0,complianceScore:Fr,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(fe=>!fe.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-ne,costUsd:Oe.costUsd,inputTokens:Oe.inputTokens,outputTokens:Oe.outputTokens,cacheCreationTokens:Oe.cacheCreationTokens,cacheReadTokens:Oe.cacheReadTokens};if(y.debug("[Review] Multi-model token data:",{costUsd:Oe.costUsd,inputTokens:Oe.inputTokens,outputTokens:Oe.outputTokens,cacheCreationTokens:Oe.cacheCreationTokens,cacheReadTokens:Oe.cacheReadTokens,reviewTokens:es.inputTokens}),D(es),ae&&L.enableReviewBadges){let fe=st.filter(Sn=>!Sn.dismissed);xo(ae,{score:Fr??100,issueCount:fe.length,criticalCount:fe.filter(Sn=>Sn.severity==="critical").length,majorCount:fe.filter(Sn=>Sn.severity==="major").length,minorCount:fe.filter(Sn=>Sn.severity==="minor").length})}N("issues");let Ea=st.filter(fe=>!fe.dismissed).length;y.debug("[Review] Created multi-model review with",Ea,"active issues,",st.length-Ea,"dismissed");let Se=xt||mt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Issue validation handled server-side. Active:",st.filter(fe=>!fe.dismissed).length,"Dismissed:",st.filter(fe=>fe.dismissed).length)}catch(Ot){y.error("[Review] Failed to parse issues from multi-model response:",Ot)}}else if(Oe){Oe.prompt&&B(Oe.prompt),(Oe.response||Zt)&&m(Oe.response||Zt),Oe.figmaImageUrl&&x(Oe.figmaImageUrl),y.debug("[Review] State updated with prompt, response, and screenshots");try{let Xe=ho(),Bt=Oe.response||Zt,Ot=Oe.issues,jn=Ot&&Ot.length>0,ln=jn?Ot.map(Se=>({id:ho(),reviewId:Xe,dbId:Se.dbId,type:Se.type,severity:Se.severity,title:Se.description,description:Se.description,property:Se.property,expected:yo(Se.expected),actual:yo(Se.actual),currentValue:yo(Se.actual),suggestedValue:yo(Se.expected),source:Se.source||"computed-styles",suggestedFix:Se.suggestedFix,file:Se.file,domElement:Se.domElement,figmaElement:Se.figmaElement,fixTarget:Se.fixTarget,fixRequired:Se.fixRequired,detectedBy:Se.detectedBy,dismissed:Se.dismissed??!1,dismissReason:Se.dismissReason,dismissedAt:Se.dismissed?new Date:void 0,_unreliable:Se._unreliable,_validationError:Se._validationError,figmaContext:Se.figmaContext,relatedTo:Array.isArray(Se.relatedTo)?Se.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Vg(Bt,Xe);y.debug("[Review] Issues source:",jn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Issues count:",ln.length,"issues");let te=ln.filter(Se=>Se.dismissed).length;te>0&&(y.debug("[Review] Auto-dismissed:",te,"false positive issues"),ze("system",`
27
27
 
28
28
  ---
29
29
 
30
- \u2705 ${te} issue${te>1?"s were":" was"} auto-dismissed as false positive${te>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Gt=Oe.complianceScore??Oe.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Oe.complianceScore,validationScore:Oe.validation?.complianceScore,parsedScore:Gt}),Gt==null){let Se=Bt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Gt=Se?parseInt(Se[1],10):void 0,y.debug("[Review] Parsed score from response:",Gt)}let cn=Ie.current[ae];cn||(cn=await Ws(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},cn.storyFile&&(Ie.current[ae]=cn)),y.debug("[Review] Story file paths:",cn);let st=ln.map(Se=>({...Se,file:Se.file||jg(Se.fixTarget,cn)||Hg(Se,cn)}));if(st=Wg(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!w){let Se=st.length;st=st.filter(fe=>fe.property?.toLowerCase()!=="textcontent"&&!fe.description?.toLowerCase().includes("text content")),Se!==st.length&&y.debug("[Review] Filtered out",Se-st.length,"textContent issues (toggle OFF)")}let Fr;lt&&nt&&(Fr=(ht.getState().reviewHistory.find(fe=>fe.id===nt)?.iterationNumber||0)+1);let Fn={id:Xe,componentId:ae,storyId:ae,modelId:l[0],parentReviewId:lt&&nt||void 0,iterationNumber:Fr,figmaFileKey:void 0,figmaNodeId:yt||void 0,figmaFileUrl:Un||void 0,complianceScore:Gt,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(Se=>!Se.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-ne,costUsd:Oe.costUsd,inputTokens:Oe.inputTokens,outputTokens:Oe.outputTokens,cacheCreationTokens:Oe.cacheCreationTokens,cacheReadTokens:Oe.cacheReadTokens,variantMismatch:Oe.variantMismatch,storybookVariant:Oe.storybookVariant,figmaVariant:Oe.figmaVariant};if(y.debug("[useAIReview] About to call addReview with review:",{id:Fn.id,storyId:Fn.storyId,issueCount:Fn.issues?.length,complianceScore:Fn.complianceScore,createdAt:Fn.createdAt?.toISOString(),inputTokens:Fn.inputTokens,outputTokens:Fn.outputTokens,costUsd:Fn.costUsd,cacheCreationTokens:Fn.cacheCreationTokens,cacheReadTokens:Fn.cacheReadTokens}),D(Fn),y.debug("[useAIReview] addReview called successfully"),ae&&L.enableReviewBadges){let Se=st.filter(fe=>!fe.dismissed);xo(ae,{score:Gt??100,issueCount:Se.length,criticalCount:Se.filter(fe=>fe.severity==="critical").length,majorCount:Se.filter(fe=>fe.severity==="major").length,minorCount:Se.filter(fe=>fe.severity==="minor").length})}N("issues");let es=st.filter(Se=>!Se.dismissed).length;y.debug("[Review] Created review with",es,"active issues,",st.length-es,"dismissed");let Fa=yt||ht.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:yt,effectiveFigmaNodeIdSingle:Fa,hasSessionToken:!!K,selectedProjectId:de,issueCount:st.length}),y.debug("[Review] Issue validation handled server-side. Active:",st.filter(Se=>!Se.dismissed).length,"Dismissed:",st.filter(Se=>Se.dismissed).length)}catch(Xe){y.error("[Review] Failed to parse issues:",Xe)}}else throw en?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",en.length),y.error("[Review] This indicates a bug in SSE parsing or backend not sending complete event"),new Error("Review completed but failed to receive structured result. Check console for details.")):new Error("No results received from API")}catch(W){if(W instanceof Error&&W.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),me(0,"Review cancelled");return}y.error("[useAIReview] Review error:",W);let Ae=W instanceof Error?W.message:"Review failed";throw f(Ae),ae&&L.enableReviewBadges&&lv(ae),me(0,`Error: ${Ae}`),W}finally{d(!1),se.current=null,pe.current&&(clearTimeout(pe.current),pe.current=null),re(null)}},[e,K,de,ae,qe,l,d,f,p,T,I,v,A,C,F,z,ze,me,R,E,x,B,m,re]),he=Vs(()=>n?.issues?o==="all"?n.issues:n.issues.filter(Ge=>Ge.severity===o):[],[n,o]),vt=Vs(()=>{se.current&&(y.debug("[useAIReview] Cancelling review..."),se.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Nt,cancelReview:vt,setShowReviewMenu:g,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:_,setStreamingStatus:M,resetReview:P,getFilteredIssues:he}};ve();De();je();import{useCallback as AX}from"react";var BX=q();ve();De();import{useEffect as uv,useRef as pv}from"react";import{useStorybookApi as az,useStorybookState as lz,addons as cz}from"storybook/manager-api";var dv="storyArgsUpdated",Kg=()=>{let e=az(),t=lz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=rt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ie(),l=pv(null),d=pv(0);return uv(()=>{let f=t.storyId;if(f){l.current!==f&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",f),s(f),l.current=f,d.current=Date.now()),o(f);let p=e.getData(f),g=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||f;i(g),y.debug("[useCurrentStory] Current story:",{storyId:f,fullName:g})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),uv(()=>{let f=cz.getChannel(),p=null,g=S=>{if(S.storyId===n){if(u||c){y.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}p&&clearTimeout(p),p=setTimeout(()=>{let{isReviewing:C,isValidating:F}=ht.getState();if(C||F){y.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-d.current<2e3){y.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}y.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return f.on(dv,g),()=>{f.off(dv,g),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};ve();je();pt();import{useCallback as fv}from"react";import{addons as gv}from"storybook/manager-api";var mv=q(),Ho=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=rt(),{sessionToken:o}=we(),{selectedProjectId:i}=Ze(),s=fv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await oe(`${mv}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({projectId:i,...c})});if(!l.ok)throw new Error("Failed to create mapping");let d=await l.json();r();try{gv.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=fv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await oe(`${mv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{gv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Ns();ve();import{useCallback as Xg,useEffect as hv,useRef as uz}from"react";import{useChannel as pz,addons as xv}from"storybook/manager-api";De();var dz=3e4,fz="forceRemount";function gz(e,t){let n=parseFloat(e.replace(/[^0-9.-]/g,"")),r=parseFloat(t.replace(/[^0-9.-]/g,""));if(isNaN(n)||isNaN(r))return!1;let o=Math.abs(n-r);return e.includes("px")||t.includes("px")?o<.5:e.includes("%")||t.includes("%")?o<1:o<.5}function mz(e){let t=["design system","design token","css variable","var(--","hard-coded"],n=`${e.description} ${e.suggestedFix||""} ${e.suggestedValue||""}`.toLowerCase();return t.some(r=>n.includes(r))}var hz="UICOPILOT/APPLY_FIXES",xz="UICOPILOT/FIX_STARTED",yz="UICOPILOT/FIX_COMPLETED",bz="UICOPILOT/FIX_FAILED",Sz="UICOPILOT/ALL_FIXES_APPLIED",Qg=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ie(),c=uz(null),l=Xg(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);hv(()=>()=>l(),[l]),hv(()=>{let g=xv.getChannel(),S=()=>{ht.getState().isApplying&&(y.error("[useApplyFixes] WebSocket disconnected while applying fixes"),l(),o(!1),i({succeeded:0,failed:0,total:0,error:"Connection lost. Please restart Storybook and try again."}))};return g.on("channelWSDisconnect",S),()=>g.off("channelWSDisconnect",S)},[l,o,i]);let d=pz({[xz]:({issueId:g})=>{y.debug(`[useApplyFixes] Fix started for issue: ${g}`),a(g,{status:"applying"})},[yz]:({issueId:g,result:S})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${g}`,S),s(g,"applied"),a(g,{status:"applied"})},[bz]:({issueId:g,error:S})=>{y.error(`[useApplyFixes] Fix failed for issue: ${g}`,S),s(g,"failed",S),a(g,{status:"failed",error:S})},[Sz]:async({summary:g})=>{if(y.debug("[useApplyFixes] All fixes applied:",g),l(),o(!1),i({succeeded:g.succeeded,failed:g.failed,total:g.total}),g.failed>0?y.warn(`Applied ${g.succeeded}/${g.total} fixes. ${g.failed} failed.`):y.debug(`Successfully applied all ${g.total} fixes!`),g.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{xv.getChannel().emit(fz,{storyId:ht.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(S){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",S)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await El(),y.debug("[useApplyFixes] Storybook preview reloaded")}t&&(y.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),y.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),f=Xg(g=>{let S=[],C=[],F=[];for(let k of g){let R=k.currentValue||k.actual||"",z=k.suggestedValue||k.expected||"";if(R&&z&&gz(R,z)){S.push(k);continue}if(mz(k)){C.push(k);continue}let _=k.generatedFix?.filePath||k.file||"";if(!_){y.warn(`[useApplyFixes] Skipping issue ${k.id} - no target file path`);continue}let M=_.toLowerCase().split(".").pop()||"",B=["tsx","jsx","ts","js"].includes(M)?"component":"css";F.push({...k,targetFilePath:_,targetFileType:B})}return{actionable:F,negligible:S,designTokens:C}},[]);return{applyFixes:Xg(g=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(g.length===0){y.warn("[useApplyFixes] No issues to fix");return}let S=f(g);if(S.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${S.negligible.length} negligible issue(s)`),S.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${S.designTokens.length} design token suggestion(s)`),S.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let C=S.actionable.filter(R=>R.targetFileType==="css"),F=S.actionable.filter(R=>R.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),C.length>0){let R=[...new Set(C.map(z=>z.targetFilePath))];y.debug(` - ${C.length} CSS issue(s) in: ${R.join(", ")}`)}if(F.length>0){let R=[...new Set(F.map(z=>z.targetFilePath))];y.debug(` - ${F.length} component issue(s) in: ${R.join(", ")}`),y.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){y.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:S.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{ht.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:S.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},dz),d(hz,{issues:S.actionable,storybookRoot:n||void 0})},[d,r,o,i,f,n,l]),isApplying:r}};ve();je();import{useState as eQ}from"react";var rQ=q();ve();import{useState as Wo}from"react";je();De();pt();var wz=q();async function zl(e,t,n,r,o){if(!e)return y.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await oe(`${wz}/api/issues/dismiss`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},credentials:"include",body:JSON.stringify({issueId:e,dismissed:t,dismissReason:n,dismissedBy:r})});if(!i.ok){let a=await i.text();return y.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return y.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return y.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function yv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return y.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>zl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return y.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}Ls();Pg();Ns();De();je();var vz=["no-fix-needed","no-fix-required","no-change-needed","no-changes-needed","no-change-required","no-changes-required","no-action-needed","no-action-required","no_fix_needed","no_change_needed","no_changes_needed","already-correct","values-match","values-already-match","already-matches","css-matches","matches-figma","correctly-implemented","implementation-correct","none-needed","none-required","skipped","skip"],kz=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],Cz=q();function Jg(){let[e,t]=Wo(!1),[n,r]=Wo(null),[o,i]=Wo(null),[s,a]=Wo(null),[u,c]=Wo(null),[l,d]=Wo(null),[f,p]=Wo(null),{sessionToken:g}=we(),{selectedProjectId:S}=Ze(),{currentStoryId:C,currentStoryName:F}=rt(),{workspacePath:k,updateIssueGeneratedFix:R,batchUpdateIssueGeneratedFixes:z,includeComponentIssues:_,dismissIssue:M,recalculateScore:B,addStreamingMessage:m}=ie();return{generateBatchFixes:async b=>{if(!g){r("Not authenticated");return}if(!S){r("No project selected");return}if(!C){r("No story selected");return}if(b.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:b.length,completed:0});let E=b.map(h=>({issueId:h.id,generatedFix:{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"",status:"generating"}}));z(E);try{y.debug("[useBatchGenerateFixes] Generating fixes for",b.length,"issues");let h=null;try{let w=$s();w?.computed&&(h=w.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(w){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",w)}let T=null;try{T=await Ws(C),T&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",T)}catch(w){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",w)}let I=await fetch(`${Cz}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:S,storyId:C,workspacePath:k,includeComponentIssues:_,computedStyles:h,storyFilePaths:T,reviewContext:{storyName:F||void 0,variantArgs:Ci()||void 0},issues:b.map(w=>({id:w.id,dbId:w.dbId,title:w.title,description:w.description,property:w.property,currentValue:w.currentValue,suggestedValue:w.suggestedValue,file:w.file,lineNumber:w.lineNumber,severity:w.severity,type:w.type,fixTarget:w.fixTarget,domElement:w.domElement,figmaContext:w.figmaContext,suggestedFix:w.suggestedFix}))})});if(!I.ok){let w=await I.json().catch(()=>({}));throw new Error(w.error||"Batch fix generation failed")}let v=await I.json();if(!v.success)throw new Error(v.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",v.result.fixes.length,"fixes"),v.result.storybookRoot&&(p(v.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",v.result.storybookRoot)),v.result.selfReview&&(d(v.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",v.result.selfReview)),v.result.partialFailure){let{failedBatches:w,errors:j}=v.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${w.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${w.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:b.length,completed:v.result.fixes.length});let A=new Set(v.result.fixes.map(w=>w.issueId)),P=b.filter(w=>!A.has(w.id));P.length>0&&(y.warn(`[useBatchGenerateFixes] ${P.length} issues not returned by API, marking as failed`),P.forEach(w=>{R(w.id,{code:"",diffPreview:"",filePath:w.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),v.timing&&(i({durationSec:v.timing.durationSec,issueCount:v.timing.issueCount,avgPerIssueSec:v.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${v.timing.durationSec}s for ${v.timing.issueCount} issues`)),v.result?.usage&&(c({inputTokens:v.result.usage.inputTokens||0,outputTokens:v.result.usage.outputTokens||0,costUsd:v.result.usage.costUsd||0,modelId:v.result.usage.modelId||"unknown",provider:v.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${v.result.usage.inputTokens} in, ${v.result.usage.outputTokens} out, $${v.result.usage.costUsd?.toFixed(4)}`));let D=[],N=[];if(v.result.fixes.forEach(w=>{let j=w.noChangesNeeded===!0;if(!j){let K=(w.fixStrategy||"").toLowerCase(),ee=(w.generatedCode||"").toLowerCase(),re=(w.diffPreview||"").toLowerCase(),de=vz.some(qe=>K.includes(qe.toLowerCase())||K.replace(/[-_]/g,"").includes(qe.replace(/[-_]/g,""))),ae=kz.some(qe=>ee.includes(qe)||re.includes(qe));j=de||ae}let G=b.find(K=>K.id===w.issueId);if(j&&G){let K=G.suggestedValue,ee=G.currentValue;K&&ee&&!$o(K,ee)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${K}", actual="${ee}"), NOT auto-dismissing issue ${w.issueId}`),j=!1)}let L=G?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${w.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:L,detectedBy:G?.detectedBy,noChangesNeeded:w.noChangesNeeded,fixStrategy:w.fixStrategy,title:G?.title?.substring(0,50)}),L&&j&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${w.issueId} (detectedBy: ${G?.detectedBy})`),j=!1),j){let K=`Auto-dismissed: ${w.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${w.issueId} - noChangesNeeded: ${w.noChangesNeeded}, strategy: "${w.fixStrategy}"`),M(w.issueId,K),D.push({localId:w.issueId,dbId:G?.dbId,dismissReason:K}),N.push({issueId:w.issueId,generatedFix:{code:w.generatedCode||"",diffPreview:w.diffPreview||"",filePath:w.filePath,confidence:w.confidence,strategy:w.fixStrategy,status:"ready",error:void 0,noChangesExplanation:w.noChangesExplanation}})}else{let K=w.error||w.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:w.issueId,generatedFix:{code:w.generatedCode,diffPreview:w.diffPreview,filePath:w.filePath,confidence:w.confidence,strategy:w.fixStrategy,status:K,error:w.error,noChangesExplanation:w.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),z(N)),D.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${D.length} false positive(s), recalculating score`),B(),g){let j=D.filter(G=>G.dbId).map(G=>({dbId:G.dbId,dismissed:!0,dismissReason:G.dismissReason,dismissedBy:"system"}));j.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),yv(j,g).then(G=>{G.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${G.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",G.error)}).catch(G=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",G)}))}let w=D.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${D.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;m({role:"system",content:w})}y.debug("[useBatchGenerateFixes] Updated",v.result.fixes.length,"issues with fixes")}catch(h){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",h),r(h?.message||"Failed to generate batch fixes");let T=b.map(I=>({issueId:I.id,generatedFix:{code:"",diffPreview:"",filePath:I.file||"",confidence:0,strategy:"",status:"failed",error:h?.message||"Failed to generate fix"}}));z(T)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:f}}ve();De();je();pt();import{useState as Zg,useCallback as em}from"react";var Tz=q();function tm(){let[e,t]=Zg([]),[n,r]=Zg(!1),[o,i]=Zg(null),{sessionToken:s}=we(),{selectedProjectId:a}=Ze(),{currentStoryId:u}=rt(),{setReviewResults:c}=ie(),l=em(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let g=await oe(`${Tz}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!g.ok){let C=await g.json().catch(()=>({}));throw new Error(C.error||"Failed to fetch reviews")}let S=await g.json();if(!S.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",S.reviews.length,"reviews for:",u),t(S.reviews)}catch(p){y.error("[useReviewHistory] Failed to fetch reviews:",p),i(p instanceof Error?p.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),d=em(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let g=[];if(typeof p.models=="string")try{g=JSON.parse(p.models)}catch(k){y.error("[useReviewHistory] Failed to parse models:",k),g=["claude-sonnet-4-20250514"]}else g=p.models;let S=p.issues.map(k=>({id:k.id,reviewId:p.id,type:k.type,severity:k.severity,title:k.description,description:k.description,file:void 0,lineNumber:void 0,property:k.property,currentValue:k.actual,suggestedValue:k.expected,suggestedCode:k.suggestedFix||void 0,status:k.status,dismissed:k.dismissed||!1,dismissReason:k.dismissReason,dismissedBy:k.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(k.createdAt)})),C=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,F=p.storyId||"";if(c({id:p.id,componentId:"",storyId:F,modelId:g[0]||"claude-sonnet-4-5-20250929",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:S,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:C}),F){let k=p.issues.filter(M=>!M.dismissed),R=k.filter(M=>M.severity==="critical").length,z=k.filter(M=>M.severity==="major").length,_=k.filter(M=>M.severity==="minor").length;xo(F,{score:p.complianceScore,issueCount:k.length,criticalCount:R,majorCount:z,minorCount:_})}},[c]),f=em(p=>{let g=e.find(S=>S.id===p);if(!g){y.error("[useReviewHistory] Review not found:",p);return}d(g)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:f}}ve();De();import{useEffect as Iz,useState as Fz,useRef as Nl}from"react";import{useChannel as Ez}from"storybook/manager-api";var Az="UICOPILOT/WORKSPACE_PATH",bv="UICOPILOT/REQUEST_WORKSPACE_PATH",Pz=3e3,Lz=500,Mz=5,nm=()=>{let[e,t]=Fz({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ie(),r=Nl(!1),o=Nl(null),i=Nl(0),s=Nl(null),a=Ez({[Az]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),y.debug("[useAutoApplySupport] Server responded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return Iz(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(bv,{}),s.current=setInterval(()=>{!r.current&&i.current<Mz&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(bv,{}))},Lz),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){y.debug("[useAutoApplySupport] Channel detection timed out, trying HTTP fallback...");try{let u=await fetch("/__uicopilot/health");if(u.ok){let c=await u.json();if(c.ok&&c.workspacePath&&!r.current){r.current=!0,y.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,y.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},Pz),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},rm=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}}catch(t){return y.error("[copyToClipboard] Failed to copy:",t),!1}};ve();je();import{useEffect as Bz,useRef as Dz}from"react";var DQ=q(),Rz=new Set;function om(){let{sessionToken:e}=we(),{selectedProjectId:t}=Ze(),n=Dz(!1);Bz(()=>{t&&Rz.add(t)},[e,t])}ve();import{useCallback as zz,useState as Sv}from"react";function im(){let[e,t]=Sv(!1),[n,r]=Sv(null),{currentStoryId:o}=rt(),{currentReviewId:i}=ie();return{exportPDF:zz(async()=>{if(!i){r("No review to export");return}t(!0),r(null);try{let[{default:a},{jsPDF:u}]=await Promise.all([import("html2canvas"),import("jspdf")]),c=document.querySelector('[data-testid="issues-panel"]')||document.querySelector(".issues-list-container")||document.querySelector('[class*="IssuesList"]');if(c)await wv(a,u,c,o);else{let l=document.querySelector("#storybook-panel-root")||document.querySelector('[id*="panel-tab-content"]')||document.querySelector(".sb-show-main");if(!l)throw new Error("Could not find panel to export");await wv(a,u,l,o)}}catch(a){console.error("[useExportPDF] Export failed:",a),r(a instanceof Error?a.message:"Failed to export PDF")}finally{t(!1)}},[i,o]),isExporting:e,error:n}}async function wv(e,t,n,r){let o=await e(n,{backgroundColor:"#ffffff",scale:2,logging:!1,useCORS:!0,allowTaint:!0}),i=o.toDataURL("image/png"),s=o.width,a=o.height,u=210,c=297,l=10,d=u-l*2,f=d/(s/2),p=a/2*f,g=new t({orientation:(p>c-l*2,"portrait"),unit:"mm",format:"a4"});g.setFillColor("#0ea5e9"),g.rect(0,0,u,20,"F"),g.setTextColor("#ffffff"),g.setFontSize(14),g.setFont("helvetica","bold"),g.text("Design Review Report",l,13);let S=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});g.setFontSize(10),g.setFont("helvetica","normal"),g.text(S,u-l,13,{align:"right"});let C=r?Nz(r):"Component Review";g.setTextColor("#1f2937"),g.setFontSize(16),g.setFont("helvetica","bold"),g.text(C,l,30);let F=38,k=c-F-15;if(p<=k)g.addImage(i,"PNG",l,F,d,p);else{let _=p,M=0,B=!0;for(;_>0;){B||g.addPage();let m=B?F:l,x=B?k:c-l*2-10,b=Math.min(_,x),E=b/f*2,h=document.createElement("canvas");h.width=s,h.height=E;let T=h.getContext("2d");if(T){T.drawImage(o,0,M,s,E,0,0,s,E);let I=h.toDataURL("image/png");g.addImage(I,"PNG",l,m,d,b)}M+=E,_-=b,B=!1}}let R=g.getNumberOfPages();for(let _=1;_<=R;_++)g.setPage(_),g.setDrawColor("#e5e7eb"),g.setLineWidth(.3),g.line(l,c-12,u-l,c-12),g.setTextColor("#6b7280"),g.setFontSize(8),g.setFont("helvetica","normal"),g.text("Generated by UI Copilot",l,c-7),g.text(`Page ${_} of ${R}`,u-l,c-7,{align:"right"});let z=`design-review-${(r||"report").replace(/[^a-zA-Z0-9]/g,"-")}.pdf`;g.save(z)}function Nz(e){let t=e.replace(/^(example|stories)-/i,""),[n,r]=t.split("--"),o=n.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "),i=r?r.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null;return i?`${o} / ${i}`:o}import{useState as Vo,useMemo as Mv,useCallback as Ai}from"react";je();De();pt();import{useState as Kr,useEffect as Ol,useRef as Ei,useCallback as sm}from"react";var Oz=300;function vv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=Kr([]),[u,c]=Kr({}),[l,d]=Kr(0),[f,p]=Kr([]),[g,S]=Kr(new Set),[C,F]=Kr(!1),[k,R]=Kr(!1),[z,_]=Kr(null),M=Ei(1),B=Ei(null),m=Ei(null),[x,b]=Kr(0),E=Ei(!1),h=Ei({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});h.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let T=sm(async(D,N,w=!1)=>{let{projectId:j,typeFilter:G,search:L,figmaPage:K,limit:ee}=h.current;if(!j||!G)return;B.current&&B.current.abort();let re=new AbortController;B.current=re,N?R(!0):F(!0),_(null);try{let de=q(),ae=localStorage.getItem("uicopilot_session_token");if(!ae)throw new Error("Not authenticated. Please connect to UI Copilot first.");let qe=new URLSearchParams({projectId:j,page:String(D),limit:String(ee)});G&&qe.append("type",G),K&&qe.append("figmaPage",K),L.trim()&&qe.append("search",L.trim()),w&&qe.append("refresh","true");let tt=await fetch(`${de}/api/figma/frames?${qe.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`},signal:re.signal});if(!tt.ok){let me=await tt.json();throw new Error(me.error||"Failed to fetch frames")}let se=await tt.json(),pe=se.frames||[],Ie=se.thumbnails||{},ze=tt.headers.get("X-Cache-Status");if(pe.length===0&&D===1&&!N&&!w&&!E.current&&ze!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),E.current=!0,await T(1,!1,!0);return}N?(a(me=>[...me,...pe]),c(me=>({...me,...Ie}))):(a(pe),c(Ie)),d(se.total||pe.length),se.pages&&p(se.pages),se.cacheDiff?.added&&S(new Set(se.cacheDiff.added)),M.current=D}catch(de){if(de instanceof DOMException&&de.name==="AbortError")return;let ae=de instanceof Error?de.message:"Failed to fetch Figma frames.";_(ae),y.error("Error fetching frames:",de)}finally{re.signal.aborted||(F(!1),R(!1))}},[]);Ol(()=>{if(!i||!e||!t)return;E.current=!1,m.current&&clearTimeout(m.current);let D=n.trim()?Oz:0;return m.current=setTimeout(()=>{M.current=1,T(1,!1)},D),()=>{m.current&&clearTimeout(m.current)}},[e,t,n,r,i,x,T]);let I=Ei(new Set);Ol(()=>{if(s.length===0)return;let D={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(D[N.id]=N.thumbnailCdnUrl);Object.keys(D).length>0&&c(N=>({...N,...D}))},[s]),Ol(()=>{if(s.length===0)return;let D=s.filter(w=>!w.thumbnailCdnUrl&&!u[w.id]&&!I.current.has(w.id)).map(w=>w.id);if(D.length===0)return;D.forEach(w=>I.current.add(w)),(async()=>{try{let{projectId:w}=h.current,j=q(),G=localStorage.getItem("uicopilot_session_token");if(!G||!w)return;let L=await oe(`${j}/api/figma/frames?projectId=${w}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(L.ok){let K=await L.json();K.thumbnails&&Object.keys(K.thumbnails).length>0&&c(ee=>({...ee,...K.thumbnails}))}}catch(w){D.forEach(j=>I.current.delete(j)),y.error("Failed to fetch frame thumbnails:",w)}})()},[s,u]),Ol(()=>()=>{B.current&&B.current.abort(),m.current&&clearTimeout(m.current)},[]);let v=sm(async()=>{let D=M.current+1;await T(D,!0)},[T]),A=sm(()=>{E.current=!1,M.current=1,a([]),c({}),b(D=>D+1)},[]),P=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:f,recentlyAdded:g,isLoading:C,loadingMore:k,hasMore:P,loadMore:v,refresh:A,error:z}}je();De();pt();import{useState as _l,useCallback as $l,useRef as _z}from"react";function kv({projectId:e}){let[t,n]=_l({}),[r,o]=_l({}),[i,s]=_l(new Set),[a,u]=_l(new Set),c=_z({}),l=$l(async g=>{if(!(!e||i.has(g))){s(S=>new Set(S).add(g));try{let S=q(),C=localStorage.getItem("uicopilot_session_token"),F=await oe(`${S}/api/figma/variants?projectId=${e}&componentSetId=${g}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`}});if(F.ok){let k=await F.json();if(k.variants){n(z=>({...z,[g]:k.variants}));let R={};for(let z of k.variants)z.thumbnailCdnUrl&&(R[z.id]=z.thumbnailCdnUrl);o(z=>({...z,[g]:{...z[g]||{},...R}})),c.current[g]||(c.current[g]=new Set),Object.keys(R).forEach(z=>c.current[g].add(z))}else o(R=>({...R,[g]:R[g]||{}}))}else o(k=>({...k,[g]:{}}))}catch(S){y.error("Failed to fetch variant metadata:",S),o(C=>({...C,[g]:{}}))}finally{s(S=>{let C=new Set(S);return C.delete(g),C})}}},[e,i]),d=$l(async(g,S)=>{if(!e||S.length===0)return;c.current[g]||(c.current[g]=new Set);let C=r[g]||{},F=S.filter(k=>!c.current[g].has(k)&&!C[k]);if(F.length!==0){F.forEach(k=>c.current[g].add(k)),u(k=>new Set(k).add(g));try{let k=q(),R=localStorage.getItem("uicopilot_session_token"),z=await oe(`${k}/api/figma/variants?projectId=${e}&componentSetId=${g}&thumbnailIds=${F.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`}});if(z.ok){let _=await z.json();_.thumbnails&&Object.keys(_.thumbnails).length>0&&o(M=>({...M,[g]:{...M[g]||{},..._.thumbnails}}))}}catch(k){y.error("Failed to fetch variant thumbnails:",k),F.forEach(R=>c.current[g]?.delete(R))}finally{u(k=>{let R=new Set(k);return R.delete(g),R})}}},[e]),f=$l(g=>{o(S=>{let C={...S};return delete C[g],C}),n(S=>{let C={...S};return delete C[g],C}),delete c.current[g]},[]),p=$l(()=>{o({}),n({}),c.current={}},[]);return{variantChildren:t,variantThumbnails:r,loadingVariants:i,loadingThumbnails:a,fetchVariants:l,fetchVariantThumbnails:d,clearVariantsForSet:f,clearAllVariants:p}}je();Ns();ve();De();pt();import{useState as Cv,useEffect as Tv,useRef as Iv,useCallback as am}from"react";function Fv({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Cv(null),[i,s]=Cv(!1),a=Iv(null),u=Iv(new Set),c=am(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let f=Ci();if(!f||Object.keys(f).length===0)return;let p=ht.getState().currentStoryId||"",g=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,S=>S.toUpperCase());a.current=e,s(!0),o(null);try{let S=q(),C=localStorage.getItem("uicopilot_session_token"),F=await oe(`${S}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`},body:JSON.stringify({storyName:g,storyId:p,storyArgs:f,availableFilters:t.map(k=>({property:k.property,values:k.values}))})});if(F.ok){let k=await F.json();k.confidence>0&&Object.keys(k.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",k),o(k))}}catch(S){y.error("[useFilterSuggestion] Error:",S)}finally{s(!1)}},[e,t,n]);Tv(()=>{c()},[c]),Tv(()=>{e||(o(null),a.current=null)},[e]);let l=am(()=>{},[]),d=am(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function Ev(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Av(e){let t={};for(let n of Object.values(e))for(let r of n)if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);return Object.entries(t).map(([n,r])=>({property:n,values:Array.from(r).sort()}))}function Pv(e){let t={},n=r=>{if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);r.children?.forEach(n)};return e.forEach(n),Object.entries(t).map(([r,o])=>({property:r,values:Array.from(o).sort()}))}function Lv(e,t,n){if(t.length===0||!t.some(o=>o.value))return!0;let r=o=>o.variantProperties?t.every(i=>i.value?o.variantProperties?.[i.property]===i.value:!0):!1;return!!(r(e)||e.children?.some(r)||n?.some(r))}function Gs({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=Vo(!0),[i,s]=Vo(!1),[a,u]=Vo(!1),[c,l]=Vo(""),[d,f]=Vo(""),[p,g]=Vo([]),[S,C]=Vo(new Set),F=Ai(se=>{l(se),p.length>0&&g([]),S.size>0&&C(new Set)},[p.length,S.size]),k=Ev(r,i,a),{frames:R,thumbnails:z,totalFrames:_,availablePages:M,recentlyAdded:B,isLoading:m,loadingMore:x,hasMore:b,loadMore:E,refresh:h,error:T}=vv({projectId:e,typeFilter:k,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!k}),{variantChildren:I,variantThumbnails:v,loadingVariants:A,loadingThumbnails:P,fetchVariants:D,fetchVariantThumbnails:N,clearVariantsForSet:w,clearAllVariants:j}=kv({projectId:e}),G=Mv(()=>{let se=Av(I),pe=Pv(R),Ie={};for(let ze of[...se,...pe])Ie[ze.property]||(Ie[ze.property]=new Set),ze.values.forEach(me=>Ie[ze.property].add(me));return Object.entries(Ie).map(([ze,me])=>({property:ze,values:Array.from(me).sort()}))},[I,R]),L=S.size===1?Array.from(S)[0]:null,K=Fv({expandedSetId:L,availableFilters:G,filtersReady:G.length>0}),ee=Ai(()=>{if(!K.suggestion)return;let{suggestedFilters:se}=K.suggestion,pe=Object.entries(se).map(([Ie,ze])=>({property:Ie,value:ze}));g(pe),K.dismissSuggestion()},[K.suggestion]),re=Mv(()=>p.some(se=>se.value)?R.filter(se=>Lv(se,p,I[se.id])):R,[R,p,I]),de=Ai((se,pe)=>{pe.stopPropagation();let Ie=!S.has(se);C(ze=>{let me=new Set(ze);return me.has(se)?me.delete(se):me.add(se),me}),Ie&&!I[se]&&!A.has(se)&&D(se)},[S,I,A,D]),ae=Ai((se,pe)=>{let Ie=pe===""?null:pe;g(ze=>ze.find(Nt=>Nt.property===se)?ze.map(Nt=>Nt.property===se?{...Nt,value:Ie}:Nt):[...ze,{property:se,value:Ie}])},[]),qe=Ai(()=>{g([])},[]),tt=Ai(se=>{let pe=R.find(Ie=>Ie.id===se);if(pe?.thumbnailCdnUrl)return pe.thumbnailCdnUrl;if(z[se])return z[se];for(let Ie of Object.values(v))if(Ie[se])return Ie[se]},[z,v]);return{frames:R,filteredFrames:re,thumbnails:z,totalFrames:_,isLoading:m,loadingMore:x,hasMore:b,error:T,loadMore:E,refresh:h,search:c,setSearch:F,figmaPage:d,setFigmaPage:f,availablePages:M,recentlyAdded:B,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:G,handleFilterChange:ae,clearFilters:qe,expandedSets:S,toggleExpanded:de,variantChildren:I,variantThumbnails:v,loadingVariants:A,loadingThumbnails:P,fetchVariantThumbnails:N,resolveThumbnail:tt,filterSuggestion:K.suggestion,filterSuggestionLoading:K.isLoading,applySuggestedFilters:ee,dismissFilterSuggestion:K.dismissSuggestion}}ve();import{useEffect as Mr,useCallback as Wz,useState as Vz,useRef as Gz}from"react";import{useChannel as qz}from"storybook/manager-api";function bo(e){return e.status===401||e.status===403}var kn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};function Bv(e){try{let t=new URL(e),n=t.pathname.match(/\/(file|design)\/([a-zA-Z0-9]+)/),r=n?n[2]:null,o=t.searchParams.get("node-id"),i=t.hash.match(/node-id=([0-9-:]+)/),s=o||(i?i[1]:null);if(!r||!s)return null;let a=s.replace(/-/g,":");return{fileKey:r,nodeId:a}}catch(t){return console.error("UI Copilot: Error parsing Figma URL:",t),null}}De();je();je();pt();var $z=q();async function lm(e){let t=await oe(`${$z}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(bo(t))throw new kn(t.status);return t.ok?(await t.json()).projects||[]:[]}je();pt();var Uz=q();async function cm(e,t,n){let r=await oe(`${Uz}/api/mappings?projectId=${t}&storyId=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(r))throw new kn(r.status);return r.ok&&(await r.json()).mapping||null}je();pt();var jz=q();async function um(e,t,n,r=10,o=!1){let i=new URLSearchParams({projectId:t,limit:String(r),storyId:n});o&&i.set("includeAI","true");let s=await oe(`${jz}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(s))throw new kn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}je();pt();var Hz=q();async function pm(e,t){let n=await oe(`${Hz}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(n))throw new kn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}function Yz(e){return e.storyId?{id:e.id,componentId:"",storyId:e.storyId,modelId:e.models?.[0]||"unknown",complianceScore:e.complianceScore,issuesCount:e.issuesCount,costUsd:e.costUsd,inputTokens:e.inputTokens,outputTokens:e.outputTokens,parentReviewId:e.parentReviewId||void 0,iterationNumber:e.iterationNumber,storybookImageData:e.storybookScreenshot||void 0,figmaImageData:e.figmaScreenshot||void 0,aiPrompt:e.aiPrompt||void 0,aiResponse:e.aiResponse||void 0,issues:e.issues.map(t=>({id:t.id,reviewId:e.id,type:t.type,severity:t.severity,title:t.description,description:t.description,property:t.property,currentValue:t.actual,suggestedValue:t.expected,suggestedCode:t.suggestedFix||void 0,status:t.status||"pending",dismissed:t.dismissed||!1,dismissReason:t.dismissReason,dismissedBy:t.dismissedBy,figmaContext:t.figmaContext,selectedForFix:!1,createdAt:new Date(t.createdAt)})),createdAt:new Date(e.createdAt)}:null}var Kz=q(),Xz="UICOPILOT/WORKSPACE_PATH",Qz="UICOPILOT/REQUEST_WORKSPACE_PATH",dm=!1;function fm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Ze(),{currentStoryId:l,mappingsRefreshKey:d,setFigmaFileUrl:f,setCurrentMapping:p,setMappingSource:g,setLoadingMapping:S}=rt(),{setReviewResults:C,setReviewDetailTab:F,setStorybookImageUrl:k,setFigmaImageUrl:R,setFullPrompt:z,setFullResponse:_,bulkAddReviews:M}=ie(),[B,m]=Vz([]),x=Gz(null);Mr(()=>{let h=T=>{T.origin.startsWith(Kz)&&T.data?.type==="UICOPILOT_AUTH_SUCCESS"&&T.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(T.data.token))};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[t]);let b=qz({[Xz]:h=>{y.debug("[useDataInit] Received workspace path:",h.path),c(h.path)}});Mr(()=>{b(Qz)},[b]),Mr(()=>{if(!e)return;let h=!1;return(async()=>{try{u(!0);let I=await lm(e);h||(s(I),n(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch projects:",I)}finally{h||u(!1)}})(),()=>{h=!0}},[e,s,u]),Mr(()=>{if(!i||r.length===0)return;let h=r.find(T=>T.storybookRoot===i);h&&o!==h.id&&(y.debug("[useDataInit] Auto-selecting project:",h.name),a(h.id))},[i,r,o,a]),Mr(()=>{if(!o||r.length===0)return;let h=r.find(I=>I.id===o),T=h?.figmaFileId;if(h&&typeof T=="string"&&T){let I=T,v=I.includes("figma.com")&&Bv(I)?.fileKey||I;f(`https://www.figma.com/file/${v}`)}},[o,r,f]),Mr(()=>!e||!o||dm?void 0:(dm=!0,(async()=>{try{let T=await pm(e,o);for(let[I,v]of Object.entries(T))xo(I,{score:v.score,issueCount:v.issueCount,criticalCount:v.criticalCount,majorCount:v.majorCount,minorCount:v.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(T).length,"stories")}catch(T){T instanceof kn&&n(T.message),y.error("[useDataInit] Failed to fetch review statuses:",T)}})(),()=>{dm=!1}),[e,o]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{S(!0);let I=await cm(e,o,l);if(h)return;I?(p(I),g("database")):(p(null),g(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch mapping:",I)}finally{h||S(!1)}})(),()=>{h=!0}},[e,o,l,d,p,g,S]),Mr(()=>{m([]),x.current=null},[l]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{let I=await um(e,o,l,10,!0);if(!h){m(I);let v=I.map(A=>Yz(A)).filter(Boolean);v.length>0&&M(v)}}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch reviews:",I)}})(),()=>{h=!0}},[e,o,l]);let E=Wz(h=>{y.debug("[useDataInit] Applying review:",h.id,"with",h.issues.length,"issues");let T=[];if(typeof h.models=="string")try{T=JSON.parse(h.models)}catch{T=["claude-sonnet-4-20250514"]}else T=h.models;let I=h.issues.map(P=>({id:P.id,reviewId:h.id,type:P.type,severity:P.severity,title:P.description,description:P.description,file:void 0,lineNumber:void 0,property:P.property,currentValue:P.actual,suggestedValue:P.expected,suggestedCode:P.suggestedFix||void 0,status:P.status,dismissed:P.dismissed||!1,dismissReason:P.dismissReason,dismissedBy:P.dismissedBy,figmaContext:P.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(P.createdAt)})),v=h.completedAt&&h.createdAt?new Date(h.completedAt).getTime()-new Date(h.createdAt).getTime():void 0,A=h.storyId||"";if(C({id:h.id,componentId:"",storyId:A,modelId:T[0]||"claude-sonnet-4-5-20250929",complianceScore:h.complianceScore,issuesCount:h.issuesCount,issues:I,createdAt:new Date(h.createdAt),timestamp:new Date(h.createdAt).toISOString(),costUsd:h.costUsd,inputTokens:h.inputTokens,outputTokens:h.outputTokens,reviewDurationMs:v}),h.storybookScreenshot&&(k(h.storybookScreenshot),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),h.figmaScreenshot&&(R(h.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot")),h.aiPrompt&&(z(h.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),h.aiResponse&&(_(h.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),A){let P=h.issues.filter(j=>!j.dismissed),D=P.filter(j=>j.severity==="critical").length,N=P.filter(j=>j.severity==="major").length,w=P.filter(j=>j.severity==="minor").length;xo(A,{score:h.complianceScore,issueCount:P.length,criticalCount:D,majorCount:N,minorCount:w})}},[C,k,R,z,_]);Mr(()=>{if(B.length>0&&l&&x.current!==l){let h=B[0];h&&h.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",h.id,"for:",l),x.current=l,E(h),F("issues"))}},[B,l,E,F])}import{styled as qs}from"storybook/theming";var Jz=qs.div({display:"flex",gap:"10px",marginTop:"8px"}),Dv=qs.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),Zz=qs.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",marginBottom:"12px",display:"flex",alignItems:"center",justifyContent:"space-between"})),eN=qs.div({display:"flex",alignItems:"center",gap:"8px"}),tN=qs(er)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),Rv=()=>{let{sessionToken:e,authMethod:t,setAuthMethod:n,startOAuth:r,logout:o}=Bs();return Lt.createElement(Lt.Fragment,null,Lt.createElement(ts,null,Lt.createElement(ns,null,"Authentication Method"),Lt.createElement(Jz,null,Lt.createElement(Dv,null,Lt.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),Lt.createElement(Dv,null,Lt.createElement("input",{type:"radio",name:"authMethod",checked:t==="apikey",onChange:()=>n("apikey")}),"API Key"))),t==="oauth"&&Lt.createElement(ts,null,Lt.createElement(ns,null,"Connect to UI Copilot"),e?Lt.createElement(Zz,null,Lt.createElement(eN,null,Lt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),Lt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Copilot")),Lt.createElement(tN,{onClick:o},"Disconnect")):Lt.createElement("div",null,Lt.createElement(Xc,{style:{marginBottom:"12px"}},"Connect to UI Copilot to manage projects and integrations. This will open a browser window for authentication."),Lt.createElement(er,{onClick:r},"\u{1F517} Connect to UI Copilot"))),t==="apikey"&&Lt.createElement(ts,null,Lt.createElement(ns,null,"API Key"),Lt.createElement(Xc,{style:{marginBottom:"12px"}},"Enter your UI Copilot API key below."),Lt.createElement(rs,{type:"password",placeholder:"Enter API key",disabled:!0}),Lt.createElement(er,{disabled:!0,style:{marginTop:"12px"}},"Save API Key")))};import Kt,{useState as gm}from"react";ve();import{styled as wr}from"storybook/theming";var nN=wr.div({marginBottom:"30px"}),rN=wr.div({display:"flex",gap:"8px",alignItems:"center"}),oN=wr(En)({flex:1}),iN=wr(qt)({padding:"8px 12px",whiteSpace:"nowrap"}),sN=wr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),mm=wr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),hm=wr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),xm=wr(rs)({fontSize:"13px",padding:"6px 8px"}),aN=wr.div({display:"flex",gap:"8px",marginTop:"12px"}),zv=wr(qt)({fontSize:"12px",padding:"6px 12px"}),lN=wr(zv)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),Nv=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o}=qr(),{currentStorybookPath:i}=Ze(),[s,a]=gm(!1),[u,c]=gm(!1),[l,d]=gm({name:"",storybookRoot:"",figmaFileUrl:""}),f=C=>{n(C||null),a(!1)},p=()=>{if(a(!0),i){let C=i.replace(/\/+$/,"").split("/").pop()||"";d({storybookRoot:i,name:C,figmaFileUrl:""})}},g=async()=>{if(l.name.trim())try{c(!0);let C;if(l.figmaFileUrl.trim()){let k=l.figmaFileUrl.trim(),R=k.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);C=R?R[1]:k}let F=await o({name:l.name.trim(),storybookRoot:l.storybookRoot.trim()||void 0,figmaFileId:C});n(F.id),a(!1),d({name:"",storybookRoot:"",figmaFileUrl:""})}catch(C){console.error("Failed to create project:",C)}finally{c(!1)}},S=C=>{d(F=>{let k={...F,storybookRoot:C};if(!F.name&&C){let R=C.replace(/\/+$/,"").split("/").pop()||"";k.name=R}return k})};return Kt.createElement(nN,null,Kt.createElement(Gx,null,"Project"),Kt.createElement(rN,null,Kt.createElement(oN,{value:t||"",onChange:C=>f(C.target.value),disabled:r||s},Kt.createElement("option",{value:""},"-- Select a project --"),e.map(C=>Kt.createElement("option",{key:C.id,value:C.id},C.name))),Kt.createElement(iN,{onClick:p,disabled:r,type:"button"},"+ New")),s&&Kt.createElement(sN,null,Kt.createElement(mm,null,Kt.createElement(hm,null,"Storybook Path (for fix generation)"),Kt.createElement(xm,{type:"text",placeholder:"/path/to/your/storybook",value:l.storybookRoot,onChange:C=>S(C.target.value)})),Kt.createElement(mm,null,Kt.createElement(hm,null,"Project Name *"),Kt.createElement(xm,{type:"text",placeholder:"my-storybook",value:l.name,onChange:C=>{let F=C.target.value;d(k=>({...k,name:F}))}})),Kt.createElement(mm,null,Kt.createElement(hm,null,"Figma File URL (for design comparison)"),Kt.createElement(xm,{type:"text",placeholder:"https://www.figma.com/file/...",value:l.figmaFileUrl,onChange:C=>{let F=C.target.value;d(k=>({...k,figmaFileUrl:F}))}})),Kt.createElement(aN,null,Kt.createElement(zv,{onClick:g,disabled:u||!l.name.trim()},u?"Creating...":"Create"),Kt.createElement(lN,{onClick:()=>{a(!1),d({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import St,{useState as Ym,useCallback as xC,useEffect as S$}from"react";import{styled as vr}from"storybook/theming";import So,{useState as bm,useEffect as FN,useCallback as _v}from"react";import{styled as Go}from"storybook/theming";ve();je();pt();ve();je();pt();import Ut,{useState as ym}from"react";import{styled as zn,keyframes as cN}from"storybook/theming";var uN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},pN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",dN=zn.div({position:"relative",display:"inline-flex"}),fN=cN`
30
+ \u2705 ${te} issue${te>1?"s were":" was"} auto-dismissed as false positive${te>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Gt=Oe.complianceScore??Oe.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Oe.complianceScore,validationScore:Oe.validation?.complianceScore,parsedScore:Gt}),Gt==null){let Se=Bt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Gt=Se?parseInt(Se[1],10):void 0,y.debug("[Review] Parsed score from response:",Gt)}let cn=Ie.current[ae];cn||(cn=await Ws(ae)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},cn.storyFile&&(Ie.current[ae]=cn)),y.debug("[Review] Story file paths:",cn);let st=ln.map(Se=>({...Se,file:Se.file||Gg(Se.fixTarget,cn)||qg(Se,cn)}));if(st=Yg(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!w){let Se=st.length;st=st.filter(fe=>fe.property?.toLowerCase()!=="textcontent"&&!fe.description?.toLowerCase().includes("text content")),Se!==st.length&&y.debug("[Review] Filtered out",Se-st.length,"textContent issues (toggle OFF)")}let Fr;lt&&nt&&(Fr=(mt.getState().reviewHistory.find(fe=>fe.id===nt)?.iterationNumber||0)+1);let Fn={id:Xe,componentId:ae,storyId:ae,modelId:l[0],parentReviewId:lt&&nt||void 0,iterationNumber:Fr,figmaFileKey:void 0,figmaNodeId:xt||void 0,figmaFileUrl:Un||void 0,complianceScore:Gt,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(Se=>!Se.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-ne,costUsd:Oe.costUsd,inputTokens:Oe.inputTokens,outputTokens:Oe.outputTokens,cacheCreationTokens:Oe.cacheCreationTokens,cacheReadTokens:Oe.cacheReadTokens,variantMismatch:Oe.variantMismatch,storybookVariant:Oe.storybookVariant,figmaVariant:Oe.figmaVariant};if(y.debug("[useAIReview] About to call addReview with review:",{id:Fn.id,storyId:Fn.storyId,issueCount:Fn.issues?.length,complianceScore:Fn.complianceScore,createdAt:Fn.createdAt?.toISOString(),inputTokens:Fn.inputTokens,outputTokens:Fn.outputTokens,costUsd:Fn.costUsd,cacheCreationTokens:Fn.cacheCreationTokens,cacheReadTokens:Fn.cacheReadTokens}),D(Fn),y.debug("[useAIReview] addReview called successfully"),ae&&L.enableReviewBadges){let Se=st.filter(fe=>!fe.dismissed);xo(ae,{score:Gt??100,issueCount:Se.length,criticalCount:Se.filter(fe=>fe.severity==="critical").length,majorCount:Se.filter(fe=>fe.severity==="major").length,minorCount:Se.filter(fe=>fe.severity==="minor").length})}N("issues");let es=st.filter(Se=>!Se.dismissed).length;y.debug("[Review] Created review with",es,"active issues,",st.length-es,"dismissed");let Ea=xt||mt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:xt,effectiveFigmaNodeIdSingle:Ea,hasSessionToken:!!K,selectedProjectId:de,issueCount:st.length}),y.debug("[Review] Issue validation handled server-side. Active:",st.filter(Se=>!Se.dismissed).length,"Dismissed:",st.filter(Se=>Se.dismissed).length)}catch(Xe){y.error("[Review] Failed to parse issues:",Xe)}}else throw Zt?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",Zt.length),y.error("[Review] This indicates a bug in SSE parsing or backend not sending complete event"),new Error("Review completed but failed to receive structured result. Check console for details.")):new Error("No results received from API")}catch(W){if(W instanceof Error&&W.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),me(0,"Review cancelled");return}y.error("[useAIReview] Review error:",W);let Ae=W instanceof Error?W.message:"Review failed";throw f(Ae),ae&&L.enableReviewBadges&&uv(ae),me(0,`Error: ${Ae}`),W}finally{d(!1),se.current=null,pe.current&&(clearTimeout(pe.current),pe.current=null),re(null)}},[e,K,de,ae,qe,l,d,f,p,T,I,v,A,C,F,z,ze,me,R,E,x,B,m,re]),he=Vs(()=>n?.issues?o==="all"?n.issues:n.issues.filter(Ge=>Ge.severity===o):[],[n,o]),vt=Vs(()=>{se.current&&(y.debug("[useAIReview] Cancelling review..."),se.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Nt,cancelReview:vt,setShowReviewMenu:g,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:_,setStreamingStatus:M,resetReview:P,getFilteredIssues:he}};ve();De();je();import{useCallback as FX}from"react";var LX=q();ve();De();import{useEffect as dv,useRef as fv}from"react";import{useStorybookApi as sz,useStorybookState as az,addons as lz}from"storybook/manager-api";var gv="storyArgsUpdated",Zg=()=>{let e=sz(),t=az(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=rt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ie(),l=fv(null),d=fv(0);return dv(()=>{let f=t.storyId;if(f){l.current!==f&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",f),s(f),l.current=f,d.current=Date.now()),o(f);let p=e.getData(f),g=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||f;i(g),y.debug("[useCurrentStory] Current story:",{storyId:f,fullName:g})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),dv(()=>{let f=lz.getChannel(),p=null,g=S=>{if(S.storyId===n){if(u||c){y.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}p&&clearTimeout(p),p=setTimeout(()=>{let{isReviewing:C,isValidating:F}=mt.getState();if(C||F){y.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-d.current<2e3){y.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}y.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return f.on(gv,g),()=>{f.off(gv,g),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};ve();je();pt();import{useCallback as mv}from"react";import{addons as hv}from"storybook/manager-api";var xv=q(),Ho=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=rt(),{sessionToken:o}=we(),{selectedProjectId:i}=Ze(),s=mv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await oe(`${xv}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({projectId:i,...c})});if(!l.ok)throw new Error("Failed to create mapping");let d=await l.json();r();try{hv.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=mv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await oe(`${xv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{hv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Ns();ve();import{useCallback as em,useEffect as yv,useRef as cz}from"react";import{useChannel as uz,addons as bv}from"storybook/manager-api";De();var pz=3e4,dz="forceRemount";function fz(e,t){let n=parseFloat(e.replace(/[^0-9.-]/g,"")),r=parseFloat(t.replace(/[^0-9.-]/g,""));if(isNaN(n)||isNaN(r))return!1;let o=Math.abs(n-r);return e.includes("px")||t.includes("px")?o<.5:e.includes("%")||t.includes("%")?o<1:o<.5}function gz(e){let t=["design system","design token","css variable","var(--","hard-coded"],n=`${e.description} ${e.suggestedFix||""} ${e.suggestedValue||""}`.toLowerCase();return t.some(r=>n.includes(r))}var mz="UICOPILOT/APPLY_FIXES",hz="UICOPILOT/FIX_STARTED",xz="UICOPILOT/FIX_COMPLETED",yz="UICOPILOT/FIX_FAILED",bz="UICOPILOT/ALL_FIXES_APPLIED",tm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ie(),c=cz(null),l=em(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);yv(()=>()=>l(),[l]),yv(()=>{let g=bv.getChannel(),S=()=>{mt.getState().isApplying&&(y.error("[useApplyFixes] WebSocket disconnected while applying fixes"),l(),o(!1),i({succeeded:0,failed:0,total:0,error:"Connection lost. Please restart Storybook and try again."}))};return g.on("channelWSDisconnect",S),()=>g.off("channelWSDisconnect",S)},[l,o,i]);let d=uz({[hz]:({issueId:g})=>{y.debug(`[useApplyFixes] Fix started for issue: ${g}`),a(g,{status:"applying"})},[xz]:({issueId:g,result:S})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${g}`,S),s(g,"applied"),a(g,{status:"applied"})},[yz]:({issueId:g,error:S})=>{y.error(`[useApplyFixes] Fix failed for issue: ${g}`,S),s(g,"failed",S),a(g,{status:"failed",error:S})},[bz]:async({summary:g})=>{if(y.debug("[useApplyFixes] All fixes applied:",g),l(),o(!1),i({succeeded:g.succeeded,failed:g.failed,total:g.total}),g.failed>0?y.warn(`Applied ${g.succeeded}/${g.total} fixes. ${g.failed} failed.`):y.debug(`Successfully applied all ${g.total} fixes!`),g.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{bv.getChannel().emit(dz,{storyId:mt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(S){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",S)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Al(),y.debug("[useApplyFixes] Storybook preview reloaded")}t&&(y.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),y.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),f=em(g=>{let S=[],C=[],F=[];for(let k of g){let R=k.currentValue||k.actual||"",z=k.suggestedValue||k.expected||"";if(R&&z&&fz(R,z)){S.push(k);continue}if(gz(k)){C.push(k);continue}let _=k.generatedFix?.filePath||k.file||"";if(!_){y.warn(`[useApplyFixes] Skipping issue ${k.id} - no target file path`);continue}let M=_.toLowerCase().split(".").pop()||"",B=["tsx","jsx","ts","js"].includes(M)?"component":"css";F.push({...k,targetFilePath:_,targetFileType:B})}return{actionable:F,negligible:S,designTokens:C}},[]);return{applyFixes:em(g=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(g.length===0){y.warn("[useApplyFixes] No issues to fix");return}let S=f(g);if(S.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${S.negligible.length} negligible issue(s)`),S.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${S.designTokens.length} design token suggestion(s)`),S.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let C=S.actionable.filter(R=>R.targetFileType==="css"),F=S.actionable.filter(R=>R.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),C.length>0){let R=[...new Set(C.map(z=>z.targetFilePath))];y.debug(` - ${C.length} CSS issue(s) in: ${R.join(", ")}`)}if(F.length>0){let R=[...new Set(F.map(z=>z.targetFilePath))];y.debug(` - ${F.length} component issue(s) in: ${R.join(", ")}`),y.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){y.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:S.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{mt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:S.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},pz),d(mz,{issues:S.actionable,storybookRoot:n||void 0})},[d,r,o,i,f,n,l]),isApplying:r}};ve();je();import{useState as JX}from"react";var tQ=q();ve();import{useState as Wo}from"react";je();De();pt();var Sz=q();async function Nl(e,t,n,r,o){if(!e)return y.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await oe(`${Sz}/api/issues/dismiss`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},credentials:"include",body:JSON.stringify({issueId:e,dismissed:t,dismissReason:n,dismissedBy:r})});if(!i.ok){let a=await i.text();return y.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return y.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return y.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function Sv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return y.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>Nl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return y.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}Ls();Dg();Ns();De();je();var wz=["no-fix-needed","no-fix-required","no-change-needed","no-changes-needed","no-change-required","no-changes-required","no-action-needed","no-action-required","no_fix_needed","no_change_needed","no_changes_needed","already-correct","values-match","values-already-match","already-matches","css-matches","matches-figma","correctly-implemented","implementation-correct","none-needed","none-required","skipped","skip"],vz=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],kz=q();function nm(){let[e,t]=Wo(!1),[n,r]=Wo(null),[o,i]=Wo(null),[s,a]=Wo(null),[u,c]=Wo(null),[l,d]=Wo(null),[f,p]=Wo(null),{sessionToken:g}=we(),{selectedProjectId:S}=Ze(),{currentStoryId:C,currentStoryName:F}=rt(),{workspacePath:k,updateIssueGeneratedFix:R,batchUpdateIssueGeneratedFixes:z,includeComponentIssues:_,dismissIssue:M,recalculateScore:B,addStreamingMessage:m}=ie();return{generateBatchFixes:async b=>{if(!g){r("Not authenticated");return}if(!S){r("No project selected");return}if(!C){r("No story selected");return}if(b.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:b.length,completed:0});let E=b.map(h=>({issueId:h.id,generatedFix:{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"",status:"generating"}}));z(E);try{y.debug("[useBatchGenerateFixes] Generating fixes for",b.length,"issues");let h=null;try{let w=$s();w?.computed&&(h=w.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(w){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",w)}let T=null;try{T=await Ws(C),T&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",T)}catch(w){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",w)}let I=await fetch(`${kz}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:S,storyId:C,workspacePath:k,includeComponentIssues:_,computedStyles:h,storyFilePaths:T,reviewContext:{storyName:F||void 0,variantArgs:Ci()||void 0},issues:b.map(w=>({id:w.id,dbId:w.dbId,title:w.title,description:w.description,property:w.property,currentValue:w.currentValue,suggestedValue:w.suggestedValue,file:w.file,lineNumber:w.lineNumber,severity:w.severity,type:w.type,fixTarget:w.fixTarget,domElement:w.domElement,figmaContext:w.figmaContext,suggestedFix:w.suggestedFix}))})});if(!I.ok){let w=await I.json().catch(()=>({}));throw new Error(w.error||"Batch fix generation failed")}let v=await I.json();if(!v.success)throw new Error(v.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",v.result.fixes.length,"fixes"),v.result.storybookRoot&&(p(v.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",v.result.storybookRoot)),v.result.selfReview&&(d(v.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",v.result.selfReview)),v.result.partialFailure){let{failedBatches:w,errors:j}=v.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${w.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${w.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:b.length,completed:v.result.fixes.length});let A=new Set(v.result.fixes.map(w=>w.issueId)),P=b.filter(w=>!A.has(w.id));P.length>0&&(y.warn(`[useBatchGenerateFixes] ${P.length} issues not returned by API, marking as failed`),P.forEach(w=>{R(w.id,{code:"",diffPreview:"",filePath:w.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),v.timing&&(i({durationSec:v.timing.durationSec,issueCount:v.timing.issueCount,avgPerIssueSec:v.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${v.timing.durationSec}s for ${v.timing.issueCount} issues`)),v.result?.usage&&(c({inputTokens:v.result.usage.inputTokens||0,outputTokens:v.result.usage.outputTokens||0,costUsd:v.result.usage.costUsd||0,modelId:v.result.usage.modelId||"unknown",provider:v.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${v.result.usage.inputTokens} in, ${v.result.usage.outputTokens} out, $${v.result.usage.costUsd?.toFixed(4)}`));let D=[],N=[];if(v.result.fixes.forEach(w=>{let j=w.noChangesNeeded===!0;if(!j){let K=(w.fixStrategy||"").toLowerCase(),ee=(w.generatedCode||"").toLowerCase(),re=(w.diffPreview||"").toLowerCase(),de=wz.some(qe=>K.includes(qe.toLowerCase())||K.replace(/[-_]/g,"").includes(qe.replace(/[-_]/g,""))),ae=vz.some(qe=>ee.includes(qe)||re.includes(qe));j=de||ae}let G=b.find(K=>K.id===w.issueId);if(j&&G){let K=G.suggestedValue,ee=G.currentValue;K&&ee&&!$o(K,ee)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${K}", actual="${ee}"), NOT auto-dismissing issue ${w.issueId}`),j=!1)}let L=G?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${w.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:L,detectedBy:G?.detectedBy,noChangesNeeded:w.noChangesNeeded,fixStrategy:w.fixStrategy,title:G?.title?.substring(0,50)}),L&&j&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${w.issueId} (detectedBy: ${G?.detectedBy})`),j=!1),j){let K=`Auto-dismissed: ${w.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${w.issueId} - noChangesNeeded: ${w.noChangesNeeded}, strategy: "${w.fixStrategy}"`),M(w.issueId,K),D.push({localId:w.issueId,dbId:G?.dbId,dismissReason:K}),N.push({issueId:w.issueId,generatedFix:{code:w.generatedCode||"",diffPreview:w.diffPreview||"",filePath:w.filePath,confidence:w.confidence,strategy:w.fixStrategy,status:"ready",error:void 0,noChangesExplanation:w.noChangesExplanation}})}else{let K=w.error||w.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:w.issueId,generatedFix:{code:w.generatedCode,diffPreview:w.diffPreview,filePath:w.filePath,confidence:w.confidence,strategy:w.fixStrategy,status:K,error:w.error,noChangesExplanation:w.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),z(N)),D.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${D.length} false positive(s), recalculating score`),B(),g){let j=D.filter(G=>G.dbId).map(G=>({dbId:G.dbId,dismissed:!0,dismissReason:G.dismissReason,dismissedBy:"system"}));j.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),Sv(j,g).then(G=>{G.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${G.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",G.error)}).catch(G=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",G)}))}let w=D.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${D.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;m({role:"system",content:w})}y.debug("[useBatchGenerateFixes] Updated",v.result.fixes.length,"issues with fixes")}catch(h){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",h),r(h?.message||"Failed to generate batch fixes");let T=b.map(I=>({issueId:I.id,generatedFix:{code:"",diffPreview:"",filePath:I.file||"",confidence:0,strategy:"",status:"failed",error:h?.message||"Failed to generate fix"}}));z(T)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:f}}ve();De();je();pt();import{useState as rm,useCallback as om}from"react";var Cz=q();function im(){let[e,t]=rm([]),[n,r]=rm(!1),[o,i]=rm(null),{sessionToken:s}=we(),{selectedProjectId:a}=Ze(),{currentStoryId:u}=rt(),{setReviewResults:c}=ie(),l=om(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let g=await oe(`${Cz}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!g.ok){let C=await g.json().catch(()=>({}));throw new Error(C.error||"Failed to fetch reviews")}let S=await g.json();if(!S.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",S.reviews.length,"reviews for:",u),t(S.reviews)}catch(p){y.error("[useReviewHistory] Failed to fetch reviews:",p),i(p instanceof Error?p.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),d=om(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let g=[];if(typeof p.models=="string")try{g=JSON.parse(p.models)}catch(k){y.error("[useReviewHistory] Failed to parse models:",k),g=["claude-sonnet-4-20250514"]}else g=p.models;let S=p.issues.map(k=>({id:k.id,reviewId:p.id,type:k.type,severity:k.severity,title:k.description,description:k.description,file:void 0,lineNumber:void 0,property:k.property,currentValue:k.actual,suggestedValue:k.expected,suggestedCode:k.suggestedFix||void 0,status:k.status,dismissed:k.dismissed||!1,dismissReason:k.dismissReason,dismissedBy:k.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(k.createdAt)})),C=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,F=p.storyId||"";if(c({id:p.id,componentId:"",storyId:F,modelId:g[0]||"claude-sonnet-4-5-20250929",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:S,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:C}),F){let k=p.issues.filter(M=>!M.dismissed),R=k.filter(M=>M.severity==="critical").length,z=k.filter(M=>M.severity==="major").length,_=k.filter(M=>M.severity==="minor").length;xo(F,{score:p.complianceScore,issueCount:k.length,criticalCount:R,majorCount:z,minorCount:_})}},[c]),f=om(p=>{let g=e.find(S=>S.id===p);if(!g){y.error("[useReviewHistory] Review not found:",p);return}d(g)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:f}}ve();De();import{useEffect as Tz,useState as Iz,useRef as Ol}from"react";import{useChannel as Fz}from"storybook/manager-api";var Ez="UICOPILOT/WORKSPACE_PATH",wv="UICOPILOT/REQUEST_WORKSPACE_PATH",Az=3e3,Pz=500,Lz=5,sm=()=>{let[e,t]=Iz({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ie(),r=Ol(!1),o=Ol(null),i=Ol(0),s=Ol(null),a=Fz({[Ez]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),y.debug("[useAutoApplySupport] Server responded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return Tz(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(wv,{}),s.current=setInterval(()=>{!r.current&&i.current<Lz&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(wv,{}))},Pz),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){y.debug("[useAutoApplySupport] Channel detection timed out, trying HTTP fallback...");try{let u=await fetch("/__uicopilot/health");if(u.ok){let c=await u.json();if(c.ok&&c.workspacePath&&!r.current){r.current=!0,y.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,y.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},Az),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},am=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}}catch(t){return y.error("[copyToClipboard] Failed to copy:",t),!1}};ve();je();import{useEffect as Mz,useRef as Bz}from"react";var MQ=q(),Dz=new Set;function lm(){let{sessionToken:e}=we(),{selectedProjectId:t}=Ze(),n=Bz(!1);Mz(()=>{t&&Dz.add(t)},[e,t])}ve();import{useCallback as Rz,useState as vv}from"react";function cm(){let[e,t]=vv(!1),[n,r]=vv(null),{currentStoryId:o}=rt(),{currentReviewId:i}=ie();return{exportPDF:Rz(async()=>{if(!i){r("No review to export");return}t(!0),r(null);try{let[{default:a},{jsPDF:u}]=await Promise.all([import("html2canvas"),import("jspdf")]),c=document.querySelector('[data-testid="issues-panel"]')||document.querySelector(".issues-list-container")||document.querySelector('[class*="IssuesList"]');if(c)await kv(a,u,c,o);else{let l=document.querySelector("#storybook-panel-root")||document.querySelector('[id*="panel-tab-content"]')||document.querySelector(".sb-show-main");if(!l)throw new Error("Could not find panel to export");await kv(a,u,l,o)}}catch(a){console.error("[useExportPDF] Export failed:",a),r(a instanceof Error?a.message:"Failed to export PDF")}finally{t(!1)}},[i,o]),isExporting:e,error:n}}async function kv(e,t,n,r){let o=await e(n,{backgroundColor:"#ffffff",scale:2,logging:!1,useCORS:!0,allowTaint:!0}),i=o.toDataURL("image/png"),s=o.width,a=o.height,u=210,c=297,l=10,d=u-l*2,f=d/(s/2),p=a/2*f,g=new t({orientation:(p>c-l*2,"portrait"),unit:"mm",format:"a4"});g.setFillColor("#0ea5e9"),g.rect(0,0,u,20,"F"),g.setTextColor("#ffffff"),g.setFontSize(14),g.setFont("helvetica","bold"),g.text("Design Review Report",l,13);let S=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});g.setFontSize(10),g.setFont("helvetica","normal"),g.text(S,u-l,13,{align:"right"});let C=r?zz(r):"Component Review";g.setTextColor("#1f2937"),g.setFontSize(16),g.setFont("helvetica","bold"),g.text(C,l,30);let F=38,k=c-F-15;if(p<=k)g.addImage(i,"PNG",l,F,d,p);else{let _=p,M=0,B=!0;for(;_>0;){B||g.addPage();let m=B?F:l,x=B?k:c-l*2-10,b=Math.min(_,x),E=b/f*2,h=document.createElement("canvas");h.width=s,h.height=E;let T=h.getContext("2d");if(T){T.drawImage(o,0,M,s,E,0,0,s,E);let I=h.toDataURL("image/png");g.addImage(I,"PNG",l,m,d,b)}M+=E,_-=b,B=!1}}let R=g.getNumberOfPages();for(let _=1;_<=R;_++)g.setPage(_),g.setDrawColor("#e5e7eb"),g.setLineWidth(.3),g.line(l,c-12,u-l,c-12),g.setTextColor("#6b7280"),g.setFontSize(8),g.setFont("helvetica","normal"),g.text("Generated by UI Copilot",l,c-7),g.text(`Page ${_} of ${R}`,u-l,c-7,{align:"right"});let z=`design-review-${(r||"report").replace(/[^a-zA-Z0-9]/g,"-")}.pdf`;g.save(z)}function zz(e){let t=e.replace(/^(example|stories)-/i,""),[n,r]=t.split("--"),o=n.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "),i=r?r.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null;return i?`${o} / ${i}`:o}import{useState as Vo,useMemo as Dv,useCallback as Ai}from"react";je();De();pt();import{useState as Kr,useEffect as _l,useRef as Ei,useCallback as um}from"react";var Nz=300;function Cv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=Kr([]),[u,c]=Kr({}),[l,d]=Kr(0),[f,p]=Kr([]),[g,S]=Kr(new Set),[C,F]=Kr(!1),[k,R]=Kr(!1),[z,_]=Kr(null),M=Ei(1),B=Ei(null),m=Ei(null),[x,b]=Kr(0),E=Ei(!1),h=Ei({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});h.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let T=um(async(D,N,w=!1)=>{let{projectId:j,typeFilter:G,search:L,figmaPage:K,limit:ee}=h.current;if(!j||!G)return;B.current&&B.current.abort();let re=new AbortController;B.current=re,N?R(!0):F(!0),_(null);try{let de=q(),ae=localStorage.getItem("uicopilot_session_token");if(!ae)throw new Error("Not authenticated. Please connect to UI Copilot first.");let qe=new URLSearchParams({projectId:j,page:String(D),limit:String(ee)});G&&qe.append("type",G),K&&qe.append("figmaPage",K),L.trim()&&qe.append("search",L.trim()),w&&qe.append("refresh","true");let tt=await fetch(`${de}/api/figma/frames?${qe.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`},signal:re.signal});if(!tt.ok){let me=await tt.json();throw new Error(me.error||"Failed to fetch frames")}let se=await tt.json(),pe=se.frames||[],Ie=se.thumbnails||{},ze=tt.headers.get("X-Cache-Status");if(pe.length===0&&D===1&&!N&&!w&&!E.current&&ze!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),E.current=!0,await T(1,!1,!0);return}N?(a(me=>[...me,...pe]),c(me=>({...me,...Ie}))):(a(pe),c(Ie)),d(se.total||pe.length),se.pages&&p(se.pages),se.cacheDiff?.added&&S(new Set(se.cacheDiff.added)),M.current=D}catch(de){if(de instanceof DOMException&&de.name==="AbortError")return;let ae=de instanceof Error?de.message:"Failed to fetch Figma frames.";_(ae),y.error("Error fetching frames:",de)}finally{re.signal.aborted||(F(!1),R(!1))}},[]);_l(()=>{if(!i||!e||!t)return;E.current=!1,m.current&&clearTimeout(m.current);let D=n.trim()?Nz:0;return m.current=setTimeout(()=>{M.current=1,T(1,!1)},D),()=>{m.current&&clearTimeout(m.current)}},[e,t,n,r,i,x,T]);let I=Ei(new Set);_l(()=>{if(s.length===0)return;let D={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(D[N.id]=N.thumbnailCdnUrl);Object.keys(D).length>0&&c(N=>({...N,...D}))},[s]),_l(()=>{if(s.length===0)return;let D=s.filter(w=>!w.thumbnailCdnUrl&&!u[w.id]&&!I.current.has(w.id)).map(w=>w.id);if(D.length===0)return;D.forEach(w=>I.current.add(w)),(async()=>{try{let{projectId:w}=h.current,j=q(),G=localStorage.getItem("uicopilot_session_token");if(!G||!w)return;let L=await oe(`${j}/api/figma/frames?projectId=${w}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(L.ok){let K=await L.json();K.thumbnails&&Object.keys(K.thumbnails).length>0&&c(ee=>({...ee,...K.thumbnails}))}}catch(w){D.forEach(j=>I.current.delete(j)),y.error("Failed to fetch frame thumbnails:",w)}})()},[s,u]),_l(()=>()=>{B.current&&B.current.abort(),m.current&&clearTimeout(m.current)},[]);let v=um(async()=>{let D=M.current+1;await T(D,!0)},[T]),A=um(()=>{E.current=!1,M.current=1,a([]),c({}),b(D=>D+1)},[]),P=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:f,recentlyAdded:g,isLoading:C,loadingMore:k,hasMore:P,loadMore:v,refresh:A,error:z}}je();De();pt();import{useState as $l,useCallback as Ul,useRef as Oz}from"react";function Tv({projectId:e}){let[t,n]=$l({}),[r,o]=$l({}),[i,s]=$l(new Set),[a,u]=$l(new Set),c=Oz({}),l=Ul(async g=>{if(!(!e||i.has(g))){s(S=>new Set(S).add(g));try{let S=q(),C=localStorage.getItem("uicopilot_session_token"),F=await oe(`${S}/api/figma/variants?projectId=${e}&componentSetId=${g}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`}});if(F.ok){let k=await F.json();if(k.variants){n(z=>({...z,[g]:k.variants}));let R={};for(let z of k.variants)z.thumbnailCdnUrl&&(R[z.id]=z.thumbnailCdnUrl);o(z=>({...z,[g]:{...z[g]||{},...R}})),c.current[g]||(c.current[g]=new Set),Object.keys(R).forEach(z=>c.current[g].add(z))}else o(R=>({...R,[g]:R[g]||{}}))}else o(k=>({...k,[g]:{}}))}catch(S){y.error("Failed to fetch variant metadata:",S),o(C=>({...C,[g]:{}}))}finally{s(S=>{let C=new Set(S);return C.delete(g),C})}}},[e,i]),d=Ul(async(g,S)=>{if(!e||S.length===0)return;c.current[g]||(c.current[g]=new Set);let C=r[g]||{},F=S.filter(k=>!c.current[g].has(k)&&!C[k]);if(F.length!==0){F.forEach(k=>c.current[g].add(k)),u(k=>new Set(k).add(g));try{let k=q(),R=localStorage.getItem("uicopilot_session_token"),z=await oe(`${k}/api/figma/variants?projectId=${e}&componentSetId=${g}&thumbnailIds=${F.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`}});if(z.ok){let _=await z.json();_.thumbnails&&Object.keys(_.thumbnails).length>0&&o(M=>({...M,[g]:{...M[g]||{},..._.thumbnails}}))}}catch(k){y.error("Failed to fetch variant thumbnails:",k),F.forEach(R=>c.current[g]?.delete(R))}finally{u(k=>{let R=new Set(k);return R.delete(g),R})}}},[e]),f=Ul(g=>{o(S=>{let C={...S};return delete C[g],C}),n(S=>{let C={...S};return delete C[g],C}),delete c.current[g]},[]),p=Ul(()=>{o({}),n({}),c.current={}},[]);return{variantChildren:t,variantThumbnails:r,loadingVariants:i,loadingThumbnails:a,fetchVariants:l,fetchVariantThumbnails:d,clearVariantsForSet:f,clearAllVariants:p}}je();Ns();ve();De();pt();import{useState as Iv,useEffect as Fv,useRef as Ev,useCallback as pm}from"react";function Av({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Iv(null),[i,s]=Iv(!1),a=Ev(null),u=Ev(new Set),c=pm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let f=Ci();if(!f||Object.keys(f).length===0)return;let p=mt.getState().currentStoryId||"",g=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,S=>S.toUpperCase());a.current=e,s(!0),o(null);try{let S=q(),C=localStorage.getItem("uicopilot_session_token"),F=await oe(`${S}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`},body:JSON.stringify({storyName:g,storyId:p,storyArgs:f,availableFilters:t.map(k=>({property:k.property,values:k.values}))})});if(F.ok){let k=await F.json();k.confidence>0&&Object.keys(k.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",k),o(k))}}catch(S){y.error("[useFilterSuggestion] Error:",S)}finally{s(!1)}},[e,t,n]);Fv(()=>{c()},[c]),Fv(()=>{e||(o(null),a.current=null)},[e]);let l=pm(()=>{},[]),d=pm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function Pv(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Lv(e){let t={};for(let n of Object.values(e))for(let r of n)if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);return Object.entries(t).map(([n,r])=>({property:n,values:Array.from(r).sort()}))}function Mv(e){let t={},n=r=>{if(r.variantProperties)for(let[o,i]of Object.entries(r.variantProperties))t[o]||(t[o]=new Set),t[o].add(i);r.children?.forEach(n)};return e.forEach(n),Object.entries(t).map(([r,o])=>({property:r,values:Array.from(o).sort()}))}function Bv(e,t,n){if(t.length===0||!t.some(o=>o.value))return!0;let r=o=>o.variantProperties?t.every(i=>i.value?o.variantProperties?.[i.property]===i.value:!0):!1;return!!(r(e)||e.children?.some(r)||n?.some(r))}function Gs({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=Vo(!0),[i,s]=Vo(!1),[a,u]=Vo(!1),[c,l]=Vo(""),[d,f]=Vo(""),[p,g]=Vo([]),[S,C]=Vo(new Set),F=Ai(se=>{l(se),p.length>0&&g([]),S.size>0&&C(new Set)},[p.length,S.size]),k=Pv(r,i,a),{frames:R,thumbnails:z,totalFrames:_,availablePages:M,recentlyAdded:B,isLoading:m,loadingMore:x,hasMore:b,loadMore:E,refresh:h,error:T}=Cv({projectId:e,typeFilter:k,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!k}),{variantChildren:I,variantThumbnails:v,loadingVariants:A,loadingThumbnails:P,fetchVariants:D,fetchVariantThumbnails:N,clearVariantsForSet:w,clearAllVariants:j}=Tv({projectId:e}),G=Dv(()=>{let se=Lv(I),pe=Mv(R),Ie={};for(let ze of[...se,...pe])Ie[ze.property]||(Ie[ze.property]=new Set),ze.values.forEach(me=>Ie[ze.property].add(me));return Object.entries(Ie).map(([ze,me])=>({property:ze,values:Array.from(me).sort()}))},[I,R]),L=S.size===1?Array.from(S)[0]:null,K=Av({expandedSetId:L,availableFilters:G,filtersReady:G.length>0}),ee=Ai(()=>{if(!K.suggestion)return;let{suggestedFilters:se}=K.suggestion,pe=Object.entries(se).map(([Ie,ze])=>({property:Ie,value:ze}));g(pe),K.dismissSuggestion()},[K.suggestion]),re=Dv(()=>p.some(se=>se.value)?R.filter(se=>Bv(se,p,I[se.id])):R,[R,p,I]),de=Ai((se,pe)=>{pe.stopPropagation();let Ie=!S.has(se);C(ze=>{let me=new Set(ze);return me.has(se)?me.delete(se):me.add(se),me}),Ie&&!I[se]&&!A.has(se)&&D(se)},[S,I,A,D]),ae=Ai((se,pe)=>{let Ie=pe===""?null:pe;g(ze=>ze.find(Nt=>Nt.property===se)?ze.map(Nt=>Nt.property===se?{...Nt,value:Ie}:Nt):[...ze,{property:se,value:Ie}])},[]),qe=Ai(()=>{g([])},[]),tt=Ai(se=>{let pe=R.find(Ie=>Ie.id===se);if(pe?.thumbnailCdnUrl)return pe.thumbnailCdnUrl;if(z[se])return z[se];for(let Ie of Object.values(v))if(Ie[se])return Ie[se]},[z,v]);return{frames:R,filteredFrames:re,thumbnails:z,totalFrames:_,isLoading:m,loadingMore:x,hasMore:b,error:T,loadMore:E,refresh:h,search:c,setSearch:F,figmaPage:d,setFigmaPage:f,availablePages:M,recentlyAdded:B,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:G,handleFilterChange:ae,clearFilters:qe,expandedSets:S,toggleExpanded:de,variantChildren:I,variantThumbnails:v,loadingVariants:A,loadingThumbnails:P,fetchVariantThumbnails:N,resolveThumbnail:tt,filterSuggestion:K.suggestion,filterSuggestionLoading:K.isLoading,applySuggestedFilters:ee,dismissFilterSuggestion:K.dismissSuggestion}}ve();import{useEffect as Mr,useCallback as Hz,useState as Wz,useRef as Vz}from"react";import{useChannel as Gz}from"storybook/manager-api";function bo(e){return e.status===401||e.status===403}var kn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};function Rv(e){try{let t=new URL(e),n=t.pathname.match(/\/(file|design)\/([a-zA-Z0-9]+)/),r=n?n[2]:null,o=t.searchParams.get("node-id"),i=t.hash.match(/node-id=([0-9-:]+)/),s=o||(i?i[1]:null);if(!r||!s)return null;let a=s.replace(/-/g,":");return{fileKey:r,nodeId:a}}catch(t){return console.error("UI Copilot: Error parsing Figma URL:",t),null}}De();je();je();pt();var _z=q();async function dm(e){let t=await oe(`${_z}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(bo(t))throw new kn(t.status);return t.ok?(await t.json()).projects||[]:[]}je();pt();var $z=q();async function fm(e,t,n){let r=await oe(`${$z}/api/mappings?projectId=${t}&storyId=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(r))throw new kn(r.status);return r.ok&&(await r.json()).mapping||null}je();pt();var Uz=q();async function gm(e,t,n,r=10,o=!1){let i=new URLSearchParams({projectId:t,limit:String(r),storyId:n});o&&i.set("includeAI","true");let s=await oe(`${Uz}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(s))throw new kn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}je();pt();var jz=q();async function mm(e,t){let n=await oe(`${jz}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(bo(n))throw new kn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}function qz(e){return e.storyId?{id:e.id,componentId:"",storyId:e.storyId,modelId:e.models?.[0]||"unknown",complianceScore:e.complianceScore,issuesCount:e.issuesCount,costUsd:e.costUsd,inputTokens:e.inputTokens,outputTokens:e.outputTokens,parentReviewId:e.parentReviewId||void 0,iterationNumber:e.iterationNumber,storybookImageData:e.storybookScreenshot||void 0,figmaImageData:e.figmaScreenshot||void 0,aiPrompt:e.aiPrompt||void 0,aiResponse:e.aiResponse||void 0,issues:e.issues.map(t=>({id:t.id,reviewId:e.id,type:t.type,severity:t.severity,title:t.description,description:t.description,property:t.property,currentValue:t.actual,suggestedValue:t.expected,suggestedCode:t.suggestedFix||void 0,status:t.status||"pending",dismissed:t.dismissed||!1,dismissReason:t.dismissReason,dismissedBy:t.dismissedBy,figmaContext:t.figmaContext,selectedForFix:!1,createdAt:new Date(t.createdAt)})),createdAt:new Date(e.createdAt)}:null}var Yz=q(),Kz="UICOPILOT/WORKSPACE_PATH",Xz="UICOPILOT/REQUEST_WORKSPACE_PATH",hm=!1;function xm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Ze(),{currentStoryId:l,mappingsRefreshKey:d,setFigmaFileUrl:f,setCurrentMapping:p,setMappingSource:g,setLoadingMapping:S}=rt(),{setReviewResults:C,setReviewDetailTab:F,setStorybookImageUrl:k,setFigmaImageUrl:R,setFullPrompt:z,setFullResponse:_,bulkAddReviews:M}=ie(),[B,m]=Wz([]),x=Vz(null);Mr(()=>{let h=T=>{T.origin.startsWith(Yz)&&T.data?.type==="UICOPILOT_AUTH_SUCCESS"&&T.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(T.data.token))};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[t]);let b=Gz({[Kz]:h=>{y.debug("[useDataInit] Received workspace path:",h.path),c(h.path)}});Mr(()=>{b(Xz)},[b]),Mr(()=>{if(!e)return;let h=!1;return(async()=>{try{u(!0);let I=await dm(e);h||(s(I),n(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch projects:",I)}finally{h||u(!1)}})(),()=>{h=!0}},[e,s,u]),Mr(()=>{if(!i||r.length===0)return;let h=r.find(T=>T.storybookRoot===i);h&&o!==h.id&&(y.debug("[useDataInit] Auto-selecting project:",h.name),a(h.id))},[i,r,o,a]),Mr(()=>{if(!o||r.length===0)return;let h=r.find(I=>I.id===o),T=h?.figmaFileId;if(h&&typeof T=="string"&&T){let I=T,v=I.includes("figma.com")&&Rv(I)?.fileKey||I;f(`https://www.figma.com/file/${v}`)}},[o,r,f]),Mr(()=>!e||!o||hm?void 0:(hm=!0,(async()=>{try{let T=await mm(e,o);for(let[I,v]of Object.entries(T))xo(I,{score:v.score,issueCount:v.issueCount,criticalCount:v.criticalCount,majorCount:v.majorCount,minorCount:v.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(T).length,"stories")}catch(T){T instanceof kn&&n(T.message),y.error("[useDataInit] Failed to fetch review statuses:",T)}})(),()=>{hm=!1}),[e,o]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{S(!0);let I=await fm(e,o,l);if(h)return;I?(p(I),g("database")):(p(null),g(null))}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch mapping:",I)}finally{h||S(!1)}})(),()=>{h=!0}},[e,o,l,d,p,g,S]),Mr(()=>{m([]),x.current=null},[l]),Mr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{let I=await gm(e,o,l,10,!0);if(!h){m(I);let v=I.map(A=>qz(A)).filter(Boolean);v.length>0&&M(v)}}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch reviews:",I)}})(),()=>{h=!0}},[e,o,l]);let E=Hz(h=>{y.debug("[useDataInit] Applying review:",h.id,"with",h.issues.length,"issues");let T=[];if(typeof h.models=="string")try{T=JSON.parse(h.models)}catch{T=["claude-sonnet-4-20250514"]}else T=h.models;let I=h.issues.map(P=>({id:P.id,reviewId:h.id,type:P.type,severity:P.severity,title:P.description,description:P.description,file:void 0,lineNumber:void 0,property:P.property,currentValue:P.actual,suggestedValue:P.expected,suggestedCode:P.suggestedFix||void 0,status:P.status,dismissed:P.dismissed||!1,dismissReason:P.dismissReason,dismissedBy:P.dismissedBy,figmaContext:P.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(P.createdAt)})),v=h.completedAt&&h.createdAt?new Date(h.completedAt).getTime()-new Date(h.createdAt).getTime():void 0,A=h.storyId||"";if(C({id:h.id,componentId:"",storyId:A,modelId:T[0]||"claude-sonnet-4-5-20250929",complianceScore:h.complianceScore,issuesCount:h.issuesCount,issues:I,createdAt:new Date(h.createdAt),timestamp:new Date(h.createdAt).toISOString(),costUsd:h.costUsd,inputTokens:h.inputTokens,outputTokens:h.outputTokens,reviewDurationMs:v}),h.storybookScreenshot&&(k(h.storybookScreenshot),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),h.figmaScreenshot&&(R(h.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot")),h.aiPrompt&&(z(h.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),h.aiResponse&&(_(h.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),A){let P=h.issues.filter(j=>!j.dismissed),D=P.filter(j=>j.severity==="critical").length,N=P.filter(j=>j.severity==="major").length,w=P.filter(j=>j.severity==="minor").length;xo(A,{score:h.complianceScore,issueCount:P.length,criticalCount:D,majorCount:N,minorCount:w})}},[C,k,R,z,_]);Mr(()=>{if(B.length>0&&l&&x.current!==l){let h=B[0];h&&h.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",h.id,"for:",l),x.current=l,E(h),F("issues"))}},[B,l,E,F])}import{styled as qs}from"storybook/theming";var Qz=qs.div({display:"flex",gap:"10px",marginTop:"8px"}),zv=qs.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),Jz=qs.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",marginBottom:"12px",display:"flex",alignItems:"center",justifyContent:"space-between"})),Zz=qs.div({display:"flex",alignItems:"center",gap:"8px"}),eN=qs(er)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),Nv=()=>{let{sessionToken:e,authMethod:t,setAuthMethod:n,startOAuth:r,logout:o}=Bs();return Lt.createElement(Lt.Fragment,null,Lt.createElement(ts,null,Lt.createElement(ns,null,"Authentication Method"),Lt.createElement(Qz,null,Lt.createElement(zv,null,Lt.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),Lt.createElement(zv,null,Lt.createElement("input",{type:"radio",name:"authMethod",checked:t==="apikey",onChange:()=>n("apikey")}),"API Key"))),t==="oauth"&&Lt.createElement(ts,null,Lt.createElement(ns,null,"Connect to UI Copilot"),e?Lt.createElement(Jz,null,Lt.createElement(Zz,null,Lt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),Lt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Copilot")),Lt.createElement(eN,{onClick:o},"Disconnect")):Lt.createElement("div",null,Lt.createElement(eu,{style:{marginBottom:"12px"}},"Connect to UI Copilot to manage projects and integrations. This will open a browser window for authentication."),Lt.createElement(er,{onClick:r},"\u{1F517} Connect to UI Copilot"))),t==="apikey"&&Lt.createElement(ts,null,Lt.createElement(ns,null,"API Key"),Lt.createElement(eu,{style:{marginBottom:"12px"}},"Enter your UI Copilot API key below."),Lt.createElement(rs,{type:"password",placeholder:"Enter API key",disabled:!0}),Lt.createElement(er,{disabled:!0,style:{marginTop:"12px"}},"Save API Key")))};import Yt,{useState as ym}from"react";ve();import{styled as wr}from"storybook/theming";var tN=wr.div({marginBottom:"30px"}),nN=wr.div({display:"flex",gap:"8px",alignItems:"center"}),rN=wr(En)({flex:1}),oN=wr(en)({padding:"8px 12px",whiteSpace:"nowrap"}),iN=wr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),bm=wr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Sm=wr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),wm=wr(rs)({fontSize:"13px",padding:"6px 8px"}),sN=wr.div({display:"flex",gap:"8px",marginTop:"12px"}),Ov=wr(en)({fontSize:"12px",padding:"6px 12px"}),aN=wr(Ov)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),_v=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o}=qr(),{currentStorybookPath:i}=Ze(),[s,a]=ym(!1),[u,c]=ym(!1),[l,d]=ym({name:"",storybookRoot:"",figmaFileUrl:""}),f=C=>{n(C||null),a(!1)},p=()=>{if(a(!0),i){let C=i.replace(/\/+$/,"").split("/").pop()||"";d({storybookRoot:i,name:C,figmaFileUrl:""})}},g=async()=>{if(l.name.trim())try{c(!0);let C;if(l.figmaFileUrl.trim()){let k=l.figmaFileUrl.trim(),R=k.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);C=R?R[1]:k}let F=await o({name:l.name.trim(),storybookRoot:l.storybookRoot.trim()||void 0,figmaFileId:C});n(F.id),a(!1),d({name:"",storybookRoot:"",figmaFileUrl:""})}catch(C){console.error("Failed to create project:",C)}finally{c(!1)}},S=C=>{d(F=>{let k={...F,storybookRoot:C};if(!F.name&&C){let R=C.replace(/\/+$/,"").split("/").pop()||"";k.name=R}return k})};return Yt.createElement(tN,null,Yt.createElement(Yx,null,"Project"),Yt.createElement(nN,null,Yt.createElement(rN,{value:t||"",onChange:C=>f(C.target.value),disabled:r||s},Yt.createElement("option",{value:""},"-- Select a project --"),e.map(C=>Yt.createElement("option",{key:C.id,value:C.id},C.name))),Yt.createElement(oN,{onClick:p,disabled:r,type:"button"},"+ New")),s&&Yt.createElement(iN,null,Yt.createElement(bm,null,Yt.createElement(Sm,null,"Storybook Path (for fix generation)"),Yt.createElement(wm,{type:"text",placeholder:"/path/to/your/storybook",value:l.storybookRoot,onChange:C=>S(C.target.value)})),Yt.createElement(bm,null,Yt.createElement(Sm,null,"Project Name *"),Yt.createElement(wm,{type:"text",placeholder:"my-storybook",value:l.name,onChange:C=>{let F=C.target.value;d(k=>({...k,name:F}))}})),Yt.createElement(bm,null,Yt.createElement(Sm,null,"Figma File URL (for design comparison)"),Yt.createElement(wm,{type:"text",placeholder:"https://www.figma.com/file/...",value:l.figmaFileUrl,onChange:C=>{let F=C.target.value;d(k=>({...k,figmaFileUrl:F}))}})),Yt.createElement(sN,null,Yt.createElement(Ov,{onClick:g,disabled:u||!l.name.trim()},u?"Creating...":"Create"),Yt.createElement(aN,{onClick:()=>{a(!1),d({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import bt,{useState as Jm,useCallback as bC,useEffect as b$}from"react";import{styled as vr}from"storybook/theming";import So,{useState as km,useEffect as IN,useCallback as Uv}from"react";import{styled as Go}from"storybook/theming";ve();je();pt();ve();je();pt();import Ut,{useState as vm}from"react";import{styled as zn,keyframes as lN}from"storybook/theming";var cN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},uN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",pN=zn.div({position:"relative",display:"inline-flex"}),dN=lN`
31
31
  0% { transform: rotate(0deg); }
32
32
  100% { transform: rotate(360deg); }
33
- `,gN=zn.button(({score:e,isLoading:t,theme:n})=>{let r=()=>t?n.color.secondary:e?e>=80?n.color.positive:e>=50?n.color.warning:n.color.negative:n.color.mediumdark;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",fontSize:n.typography.size.s1,fontWeight:n.typography.weight.bold,fontFamily:n.typography.fonts.base,backgroundColor:r(),color:n.color.inverseText,cursor:t?"wait":"pointer",transition:"all 0.15s",border:"none",outline:"none","&:hover:not(:disabled)":{transform:"scale(1.05)",opacity:.9},"&:disabled":{cursor:"not-allowed",opacity:.7}}}),mN=zn.span`
33
+ `,fN=zn.button(({score:e,isLoading:t,theme:n})=>{let r=()=>t?n.color.secondary:e?e>=80?n.color.positive:e>=50?n.color.warning:n.color.negative:n.color.mediumdark;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",fontSize:n.typography.size.s1,fontWeight:n.typography.weight.bold,fontFamily:n.typography.fonts.base,backgroundColor:r(),color:n.color.inverseText,cursor:t?"wait":"pointer",transition:"all 0.15s",border:"none",outline:"none","&:hover:not(:disabled)":{transform:"scale(1.05)",opacity:.9},"&:disabled":{cursor:"not-allowed",opacity:.7}}}),gN=zn.span`
34
34
  display: inline-block;
35
35
  width: 10px;
36
36
  height: 10px;
37
37
  border: 2px solid rgba(255,255,255,0.3);
38
38
  border-top-color: #fff;
39
39
  border-radius: 50%;
40
- animation: ${fN} 0.8s linear infinite;
41
- `,hN=zn.div(({theme:e})=>({position:"absolute",top:"100%",left:"0",marginTop:"6px",padding:"12px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:1e3,minWidth:"220px",fontSize:e.typography.size.s1})),xN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),yN=zn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),bN=zn.span(({score:e,theme:t})=>{let n=()=>e>=80?t.color.positive:e>=50?t.color.warning:t.color.negative;return{fontWeight:700,fontSize:t.typography.size.s3,color:n()}}),SN=zn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),wN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),vN=zn.span({display:"flex",alignItems:"center",gap:"4px"}),kN=zn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),CN=zn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),TN=zn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),IN=zn.ul(({theme:e})=>({margin:"8px 0 0 0",padding:"0 0 0 14px",fontSize:e.typography.size.s1,color:e.color.defaultText,"& li":{marginBottom:"2px"}})),Ov=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Ze(),[n,r]=ym(!1),[o,i]=ym(!1),[s,a]=ym(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=q(),l=localStorage.getItem("uicopilot_session_token"),d=await oe(`${c}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({projectId:t,figmaFileUrl:e,figmaMetadata:{}})});if(!d.ok)throw new Error("Failed to check quality");let f=await d.json();a(f),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Ut.createElement(dN,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Ut.createElement(gN,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Ut.createElement(Ut.Fragment,null,Ut.createElement(mN,null)," Checking..."):s?Ut.createElement(Ut.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Ut.createElement(Ut.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Ut.createElement(hN,null,Ut.createElement(xN,null,Ut.createElement(yN,null,"Figma Design Quality"),Ut.createElement(bN,{score:s.score},Math.round(s.score),"%")),Ut.createElement(SN,null,Object.entries(s.categories).map(([c,l])=>Ut.createElement(wN,{key:c},Ut.createElement(vN,null,Ut.createElement(kN,{status:l.status},pN(l.status)),uN[c]||c),Ut.createElement(CN,null,l.score)))),s.summary&&Ut.createElement(TN,null,s.summary),s.recommendations?.length>0&&Ut.createElement(IN,null,s.recommendations.slice(0,2).map((c,l)=>Ut.createElement("li",{key:l},c))))):null};var EN=Go.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),AN=Go.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),PN=Go.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),LN=Go.div({display:"flex",gap:"8px",alignItems:"center"}),MN=Go.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight}})),BN=Go(qt)({whiteSpace:"nowrap"}),DN=Go.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),$v=()=>{let{selectedProjectId:e,projects:t}=Ze(),{sessionToken:n}=we(),{updateProject:r}=qr(),o=t.find(S=>S.id===e),[i,s]=bm(""),[a,u]=bm(!1),[c,l]=bm(null),d=o?.figmaFileUrl||o?.figmaFileId||"";FN(()=>{s(d),l(null)},[o?.id,d]);let f=i!==d,p=_v(async()=>{if(!(!e||!f))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let S=q();try{await oe(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}oe(`${S}/api/figma/frames?projectId=${e}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${n}`}},6e4).catch(()=>{}),l({type:"success",message:"Saved \u2014 reloading Figma cache\u2026"}),setTimeout(()=>l(null),3e3)}catch(S){l({type:"error",message:S instanceof Error?S.message:"Failed to save"})}finally{u(!1)}},[e,i,f,r]),g=_v(S=>{S.key==="Enter"&&f&&!a&&p()},[f,a,p]);return e?So.createElement(EN,null,So.createElement(AN,null,So.createElement(PN,null,"Figma File URL"),So.createElement(Ov,{figmaFileUrl:d})),So.createElement(LN,null,So.createElement(MN,{type:"text",value:i,onChange:S=>s(S.target.value),onKeyDown:g,placeholder:"https://www.figma.com/file/..."}),So.createElement(BN,{onClick:p,disabled:!f||a},a?"Saving...":"Save")),c&&So.createElement(DN,{variant:c.type},c.message)):null};import kt,{useState as tc,useEffect as Q_}from"react";import{styled as Yn}from"storybook/theming";ve();je();import Je,{useState as Bi,useEffect as v_,useCallback as Co}from"react";import{styled as Zt}from"storybook/theming";je();je();De();import X,{useState as Li,useEffect as Fk,useMemo as Mm,useCallback as Ek}from"react";import{styled as Ye}from"storybook/theming";pt();import Me,{useState as Ik,useEffect as RN,memo as zN}from"react";import{styled as xe}from"storybook/theming";var Uv=xe.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10001}),jv=xe.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"6px",width:"90%",maxWidth:"900px",maxHeight:"85vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.3)",border:`1px solid ${e.appBorderColor}`})),Hv=xe.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),Wv=xe.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),Vv=xe(wn)({fontSize:"20px",padding:"4px 8px"}),Gv=xe.div({flex:1,overflow:"auto",padding:"20px"}),qv=xe(so)({fontSize:"14px",marginBottom:"16px"}),Sm=xe.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Yv=xe.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s","&:hover":{borderColor:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),wm=xe.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Kv=xe.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Xv=xe.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),Ys=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",height:"100%",minHeight:"80px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:e.color.mediumdark})),vm=xe.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Ks=xe.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),km=xe.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Cm=xe.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Tm=xe.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Im=xe.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Qv=xe.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),Ul=xe.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Jv=xe.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),Zv=xe.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),ek=xe.button(({theme:e})=>({position:"absolute",top:"8px",left:"8px",width:"24px",height:"24px",padding:0,background:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"14px",color:e.color.defaultText,zIndex:10,transition:"all 0.2s","&:hover":{background:e.background.hoverable,borderColor:le}})),tk=xe.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.08)",height:"auto",minHeight:"200px","&:hover":{borderColor:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),nk=xe.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:le,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),rk=xe.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),$Z=xe.div(({theme:e})=>({padding:"20px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",backgroundColor:e.background.app,border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",gridColumn:"1 / -1"})),ok=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),ik=xe.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Fm=xe.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"8px 12px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"}})),sk=xe.span(({theme:e})=>({display:"inline-block",padding:"3px 8px",background:e.background.app,borderRadius:"4px",fontSize:"11px",color:e.color.defaultText,border:`1px solid ${e.appBorderColor}`,lineHeight:1.2})),ak=xe.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),lk=xe.span(({theme:e})=>({color:e.color.defaultText})),jl=xe.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.appBorderColor,borderRadius:"4px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.hoverable}, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),ck=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),uk=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),pk=xe.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),dk=xe(En)({flex:1,width:"auto"}),fk=xe.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),gk=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",marginBottom:"8px",backgroundColor:e.background.hoverable||"#f0f9ff",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s1,flexWrap:"wrap"})),mk=xe.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),hk=xe.span(({theme:e})=>({color:e.color.defaultText})),xk=xe.button(({theme:e})=>({padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.lightest,backgroundColor:e.color.secondary,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer","&:hover":{opacity:.9}})),yk=xe.button(({theme:e})=>({padding:"2px 6px",fontSize:e.typography.size.s1,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",cursor:"pointer","&:hover":{color:e.color.defaultText}})),bk=xe.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),Hl=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),Xs=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Pi=xe(En)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),Wl=xe.button(({theme:e})=>({padding:"6px 10px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:e.color.negative,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:`${e.color.negative}15`}})),Sk=xe.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),wk=xe.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:le,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),vk=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Em=xe.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?le:e.appBorderColor}`,borderRadius:"8px",backgroundColor:t?"rgba(234, 88, 12, 0.06)":e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",position:"relative","&:hover":{borderColor:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Am=xe.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?le:e.appBorderColor}`,backgroundColor:t?le:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),kk=xe.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),Ck=xe.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:le,color:e.color.lightest,fontSize:"14px",fontWeight:500,cursor:t?"not-allowed":"pointer",opacity:t?.6:1,transition:"all 0.2s","&:hover":{backgroundColor:t?e.color.mediumdark:le,opacity:t?.6:.9}})),Tk=xe.span(({theme:e})=>({display:"inline-block",padding:"1px 5px",marginLeft:"6px",borderRadius:"3px",fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:"rgba(16, 185, 129, 0.15)",color:e.color.positive,verticalAlign:"middle"}));De();var Pm=zN(({src:e,alt:t,isComponentSet:n,loadingDone:r})=>{let[o,i]=Ik(!1),[s,a]=Ik(!1);return RN(()=>{i(!1),a(!1)},[e]),o?Me.createElement(Ys,null,Me.createElement(km,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(Ks,null,"Failed to load")):e?Me.createElement(Me.Fragment,null,!s&&Me.createElement(Ys,{style:{position:"absolute",inset:0}},Me.createElement(vm,null),Me.createElement(Ks,null,"Loading...")),Me.createElement(Xv,{src:e,alt:t,onLoad:()=>a(!0),onError:()=>i(!0),style:{opacity:s?1:0}})):r?Me.createElement(Ys,null,Me.createElement(km,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(Ks,null,"No preview")):Me.createElement(Ys,null,Me.createElement(vm,null),Me.createElement(Ks,null,"Loading..."))}),Qs=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,isLoadingVariants:i=!1,isExpanded:s,isNew:a=!1,onToggleExpand:u,onSelect:c,multiSelect:l=!1,selectedFrames:d=new Set,variantFilters:f=[]})=>{let p=e.type==="COMPONENT_SET",g=p&&(e.children&&e.children.length>0||(e.childCount??0)>0),S=e.children||o||[],C=Me.useMemo(()=>S.length===0?[]:f.some(R=>R.value)?S.filter(R=>R.variantProperties?f.every(z=>z.value?R.variantProperties?.[z.property]===z.value:!0):!1):S,[S,f]),F=R=>{if(p&&g){u(e.id,R);return}c(e)},k=l?Em:Yv;return Me.createElement(Me.Fragment,null,Me.createElement(k,{onClick:F,title:e.name,isSelected:l?d.has(e.id):void 0,style:{cursor:"pointer"}},l&&!g&&Me.createElement(Am,{isSelected:d.has(e.id)},d.has(e.id)?"\u2713":""),p?Me.createElement(Kv,null,g&&Me.createElement(ek,{onClick:R=>u(e.id,R),title:s?"Collapse variants":"Expand variants"},s?"\u25BC":"\u25B6"),g&&Me.createElement(nk,null,C.length>0&&C.length!==S.length?`${C.length} / ${S.length}`:e.childCount??S.length," variants"),Me.createElement(Pm,{src:t,alt:e.name,isComponentSet:!0})):Me.createElement(wm,null,Me.createElement(Pm,{src:t,alt:e.name,isComponentSet:!1})),Me.createElement(Cm,null,Me.createElement(Tm,null,e.name,a&&Me.createElement(Tk,null,"New")),Me.createElement(Im,null,e.type))),g&&s&&i&&Me.createElement(Me.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((R,z)=>Me.createElement(ok,{key:`skeleton-${z}`},Me.createElement(ik,null),Me.createElement(Fm,{width:"80%"}),Me.createElement(Fm,{width:"50%"})))),g&&s&&!i&&C.map(R=>Me.createElement(Lm,{key:R.id,variant:R,thumbnail:r?.[R.id]||n[R.id],onSelect:c,multiSelect:l,isSelected:d.has(R.id),loadingDone:!!t||r!==void 0&&R.id in(r||{})})))},Lm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1})=>Me.createElement(r?Em:tk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Me.createElement(Am,{isSelected:o},o?"\u2713":""),Me.createElement(wm,null,Me.createElement(Pm,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i})),Me.createElement(Cm,null,Me.createElement(Tm,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Me.createElement(rk,null,Object.entries(e.variantProperties).map(([u,c])=>Me.createElement(sk,{key:u},Me.createElement(ak,null,u,":")," ",Me.createElement(lk,null,c)))),Me.createElement(Im,{style:{marginTop:"6px"}},"VARIANT")));var NN=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),ON=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),_N=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),Ak=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),Pk=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),Vl=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),$N=Ye(En)({flex:1,width:"auto"}),Lk=Ye(so)({flex:1,fontSize:"13px"}),UN=Ye.div({flex:1,overflow:"auto",padding:"8px"}),jN=Ye.div(({theme:e,selected:t,mapped:n})=>({padding:"12px",marginBottom:"8px",borderRadius:"8px",border:`2px solid ${t?e.color.secondary:n?e.color.positive:e.appBorderColor}`,backgroundColor:t?`${e.color.secondary}10`:e.background.content,cursor:"pointer",transition:"all 0.2s","&:hover":{borderColor:t?e.color.secondary:e.color.mediumlight}})),HN=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),WN=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),VN=Ye.span(({theme:e,mapped:t})=>({fontSize:"10px",fontWeight:500,padding:"2px 6px",borderRadius:"4px",backgroundColor:t?`${e.color.positive}20`:e.background.hoverable,color:t?e.color.positive:e.color.mediumdark})),GN=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),qN=Ye.div(({theme:e})=>({marginTop:"8px",padding:"8px",backgroundColor:`${e.color.positive}10`,borderRadius:"6px",fontSize:"11px",color:e.color.positive,display:"flex",alignItems:"center",gap:"8px",position:"relative"})),YN=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),KN=Ye.div({flex:1,overflow:"hidden"}),XN=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),QN=Ye.div(({theme:e})=>({position:"absolute",bottom:"100%",left:"0",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)",border:`1px solid ${e.appBorderColor}`,padding:"8px",zIndex:100,maxWidth:"280px",animation:"fadeIn 0.15s ease-out","@keyframes fadeIn":{from:{opacity:0,transform:"translateY(4px)"},to:{opacity:1,transform:"translateY(0)"}}})),JN=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),ZN=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),eO=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),tO=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Bm=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),nO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Dm=20,rO=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),oO=Ye.button(({theme:e,disabled:t})=>({padding:"8px 16px",fontSize:"13px",fontWeight:500,color:t?e.color.mediumdark:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${t?e.appBorderColor:e.color.secondary}`,borderRadius:"6px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"all 0.2s","&:hover":{backgroundColor:t?"transparent":`${e.color.secondary}10`}})),iO=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),sO=Ye.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",fontSize:"13px",fontWeight:500,color:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${e.color.secondary}`,borderRadius:"4px",cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:`${e.color.secondary}10`}})),aO=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),Rm=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),zm=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),lO=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),cO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Mk=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),Bk=Ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),Dk=Ye.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"12px",animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),uO=()=>X.createElement(cO,null,Array.from({length:8}).map((e,t)=>X.createElement(Mk,{key:t},X.createElement(Bk,null),X.createElement(Dk,{width:`${60+t%3*15}%`})))),pO=Ye.div(({theme:e})=>({padding:"12px 16px",backgroundColor:`${e.color.secondary}10`,borderBottom:`1px solid ${e.appBorderColor}`,fontSize:"13px",color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),dO=Ye.div({position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.8)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:50,gap:"8px"}),fO=Ye.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),gO=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),Rk=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=Gs({projectId:i,limit:Dm,enabled:!!i}),[a,u]=Li("all"),[c,l]=Li(""),[d,f]=Li(null),[p,g]=Li(1),[S,C]=Li(null),[F,k]=Li(!1),R=Mm(()=>{let h=new Set;return e.forEach(T=>{T.componentTitle&&h.add(T.componentTitle)}),Array.from(h).sort()},[e]),z=Mm(()=>e.filter(h=>{if(a!=="all"&&h.componentTitle!==a)return!1;if(c){let T=c.toLowerCase();return h.name.toLowerCase().includes(T)||h.title.toLowerCase().includes(T)}return!0}),[e,a,c]),_=d?s.frames.find(h=>h.id===d):null,M=Mm(()=>{if(!d)return[];let h=s.variantChildren[d]||[];return h.length===0?[]:s.variantFilters.some(T=>T.value)?h.filter(T=>T.variantProperties?s.variantFilters.every(I=>I.value?T.variantProperties?.[I.property]===I.value:!0):!1):h},[d,s.variantChildren,s.variantFilters]),B=M.slice(0,p*Dm),m=M.length>p*Dm;Fk(()=>{if(!d||B.length===0)return;let h=B.map(T=>T.id);s.fetchVariantThumbnails(d,h)},[d,B.length,p]),Fk(()=>{k(!1)},[]);let x=Ek(async h=>{if(n)try{let T=q(),I=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${T}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:h.id,name:h.name})})).ok)throw new Error("Failed to save mapping");o(n,h.id,h.name)}catch(T){y.error("[MapStoriesTab] Error saving mapping:",T)}},[n,i,o]),b=Ek((h,T)=>{if(T.stopPropagation(),d===h){f(null),g(1);return}f(h),g(1),!s.variantThumbnails[h]&&!s.loadingVariants.has(h)&&s.toggleExpanded(h,T)},[d,s]),E=e.find(h=>h.id===n);return t?X.createElement(lO,null,"Loading stories..."):X.createElement(NN,null,X.createElement(ON,null,X.createElement(Ak,null,X.createElement(Pk,null,"Storybook Stories"),X.createElement(Vl,null,X.createElement($N,{value:a,onChange:h=>u(h.target.value)},X.createElement("option",{value:"all"},"All Components"),R.map(h=>X.createElement("option",{key:h,value:h},h)))),X.createElement(Vl,null,X.createElement(Lk,{type:"text",placeholder:"Search stories...",value:c,onChange:h=>l(h.target.value)}))),X.createElement(UN,null,z.length===0?X.createElement(zm,null,"No stories found"):z.map(h=>X.createElement(jN,{key:h.id,selected:h.id===n,mapped:!!h.figmaMapping,onClick:()=>r(h.id)},X.createElement(HN,null,X.createElement(WN,null,h.name),X.createElement(VN,{mapped:!!h.figmaMapping},h.figmaMapping?"Mapped":"Unmapped")),X.createElement(GN,null,h.title),h.figmaMapping&&X.createElement(qN,{onMouseEnter:()=>C(h.id),onMouseLeave:()=>C(null)},(()=>{let T=h.figmaMapping?.figmaNodeId,I=T?s.resolveThumbnail(T):void 0;return X.createElement(X.Fragment,null,I?X.createElement(YN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}):X.createElement("span",null,"\u{1F517}"),S===h.id&&I&&X.createElement(QN,null,X.createElement(JN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}),X.createElement(ZN,null,h.figmaMapping?.figmaFrameName)))})(),X.createElement(KN,null,X.createElement(XN,null,h.figmaMapping.figmaFrameName))))))),X.createElement(_N,null,n?X.createElement(X.Fragment,null,X.createElement(pO,null,X.createElement("span",null,"Click a Figma component below to link it to"," ",X.createElement("strong",null,E?.name))),X.createElement(Ak,null,X.createElement(Pk,null,"Figma Components"),X.createElement(Vl,null,X.createElement(tO,null,X.createElement(Bm,null,X.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:h=>s.setShowComponentSets(h.target.checked)}),"Component Sets"),X.createElement(Bm,null,X.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:h=>s.setShowFrames(h.target.checked)}),"Frames"),X.createElement(Bm,null,X.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:h=>s.setShowComponents(h.target.checked)}),"Components")),s.availablePages.length>1&&X.createElement(Pi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:h=>s.setFigmaPage(h.target.value)},X.createElement("option",{value:""},"All pages"),s.availablePages.map(h=>X.createElement("option",{key:h,value:h},h)))),s.availableFilters.length>0&&X.createElement(Hl,null,X.createElement(Xs,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:h,values:T})=>{let I=s.variantFilters.find(v=>v.property===h);return X.createElement(Pi,{key:h,isActive:!!I?.value,value:I?.value||"",onChange:v=>s.handleFilterChange(h,v.target.value)},X.createElement("option",{value:""},h),T.map(v=>X.createElement("option",{key:v,value:v},h,"=",v)))}),s.availableFilters.length>5&&X.createElement(Xs,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(h=>h.value)&&X.createElement(Wl,{onClick:s.clearFilters},"Clear All")),X.createElement(Vl,null,X.createElement(Lk,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:h=>s.setSearch(h.target.value)}))),X.createElement(eO,null,F&&X.createElement(dO,null,X.createElement(fO,null),X.createElement(gO,null,"Loading thumbnails...")),s.isLoading?X.createElement(uO,null):s.filteredFrames.length===0?X.createElement(zm,null,X.createElement("span",null,"No components found")):X.createElement(nO,null,d&&_?X.createElement(X.Fragment,null,X.createElement(iO,null,X.createElement(sO,{onClick:()=>{f(null),g(1)}},"Back"),X.createElement(aO,null,_.name)),s.loadingVariants.has(d)?X.createElement(X.Fragment,null,X.createElement(Rm,null,"Loading ",_.childCount??"..."," variants..."),Array.from({length:Math.min(8,_.childCount??8)}).map((h,T)=>X.createElement(Mk,{key:`variant-skeleton-${T}`},X.createElement(Bk,null),X.createElement(Dk,{width:`${60+T%3*15}%`})))):X.createElement(X.Fragment,null,X.createElement(Rm,null,"Showing ",B.length," of ",M.length," variants"),B.map(h=>X.createElement(Lm,{key:h.id,variant:h,thumbnail:s.variantThumbnails[d]?.[h.id]||s.thumbnails[h.id],onSelect:x,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d)})))):X.createElement(X.Fragment,null,X.createElement(Rm,null,"Showing ",s.frames.length," of ",s.totalFrames," components"),s.filteredFrames.map(h=>X.createElement(Qs,{key:h.id,frame:h,thumbnail:s.thumbnails[h.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[h.id],variantChildren:s.variantChildren[h.id],isLoadingVariants:s.loadingVariants.has(h.id),isExpanded:!1,onToggleExpand:b,onSelect:x,variantFilters:s.variantFilters}))),(d?m:s.hasMore)&&X.createElement(rO,null,X.createElement(oO,{disabled:s.loadingMore,onClick:async()=>{d?g(h=>h+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):X.createElement(zm,null,X.createElement("span",null,"Select a story from the left to link it to Figma"))))};je();import et,{useState as Nm,useMemo as zk,useCallback as Nk}from"react";import{styled as Rt}from"storybook/theming";pt();var mO=Rt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),hO=Rt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),xO=Rt(En)({width:"auto",minWidth:"200px"}),yO=Rt(so)({fontSize:"13px",minWidth:"250px"}),bO=Rt.button(({theme:e,active:t})=>({padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${t?e.color.positive:e.appBorderColor}`,borderRadius:"6px",backgroundColor:t?`${e.color.positive}15`:e.background.content,color:t?e.color.positive:e.color.mediumdark,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{borderColor:e.color.positive}})),SO=Rt.button(({theme:e})=>({marginLeft:"auto",padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{backgroundColor:e.background.hoverable}})),wO=Rt.div({flex:1,overflow:"auto"}),vO=Rt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),kO=Rt.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),Gl=Rt.th(({theme:e})=>({padding:"12px 20px",textAlign:"left",fontWeight:600,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px",color:e.color.mediumdark,borderBottom:`1px solid ${e.appBorderColor}`})),CO=Rt.tbody({}),TO=Rt.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),ql=Rt.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),IO=Rt.div({display:"flex",flexDirection:"column",gap:"2px"}),FO=Rt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),EO=Rt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),AO=Rt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),PO=Rt.div({display:"flex",alignItems:"center",gap:"8px"}),LO=Rt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),MO=Rt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),Ok=Rt.button(({theme:e,variant:t})=>({padding:"6px 12px",fontSize:"12px",fontWeight:500,border:`1px solid ${t==="link"?e.color.secondary:e.color.negative}`,borderRadius:"4px",backgroundColor:t==="link"?`${e.color.secondary}10`:`${e.color.negative}10`,color:t==="link"?e.color.secondary:e.color.negative,cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:t==="link"?`${e.color.secondary}20`:`${e.color.negative}20`}})),BO=Rt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),DO=Rt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),_k=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=Nm("all"),[a,u]=Nm(""),[c,l]=Nm(!0),d=zk(()=>{let C=new Set;return e.forEach(F=>{F.componentTitle&&C.add(F.componentTitle)}),Array.from(C).sort()},[e]),f=zk(()=>e.filter(C=>{if(i!=="all"&&C.componentTitle!==i||!c&&!C.figmaMapping)return!1;if(a){let F=a.toLowerCase();return C.name.toLowerCase().includes(F)||C.title.toLowerCase().includes(F)||(C.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),p=Nk(async C=>{try{let F=q(),k=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${F}/api/mappings?projectId=${o}&storyId=${C}`,{method:"DELETE",headers:{Authorization:`Bearer ${k}`}})).ok)throw new Error("Failed to delete mapping");r(C)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),g=Nk(()=>{let C=e.filter(z=>z.figmaMapping).map(z=>({storyId:z.id,storyName:z.name,storyTitle:z.title,figmaNodeId:z.figmaMapping.figmaNodeId,figmaFrameName:z.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(C,null,2)],{type:"application/json"}),k=URL.createObjectURL(F),R=document.createElement("a");R.href=k,R.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL(k)},[e]);if(t)return et.createElement(DO,null,"Loading mappings...");let S=e.filter(C=>C.figmaMapping).length;return et.createElement(mO,null,et.createElement(hO,null,et.createElement(xO,{value:i,onChange:C=>s(C.target.value)},et.createElement("option",{value:"all"},"All Components"),d.map(C=>et.createElement("option",{key:C,value:C},C))),et.createElement(yO,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:C=>u(C.target.value)}),et.createElement(bO,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),et.createElement(SO,{onClick:g,disabled:S===0},"\u{1F4E5} Export JSON")),f.length===0?et.createElement(BO,null,et.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):et.createElement(wO,null,et.createElement(vO,null,et.createElement(kO,null,et.createElement("tr",null,et.createElement(Gl,{style:{width:"35%"}},"Story"),et.createElement(Gl,{style:{width:"35%"}},"Figma Component"),et.createElement(Gl,{style:{width:"15%"}},"Status"),et.createElement(Gl,{style:{width:"15%"}},"Actions"))),et.createElement(CO,null,f.map(C=>et.createElement(TO,{key:C.id,mapped:!!C.figmaMapping},et.createElement(ql,null,et.createElement(IO,null,et.createElement(FO,null,C.name),et.createElement(EO,null,C.title))),et.createElement(ql,null,et.createElement(AO,{mapped:!!C.figmaMapping},C.figmaMapping?et.createElement(et.Fragment,null,et.createElement("span",null,"\u{1F3A8}"),C.figmaMapping.figmaFrameName):"\u2014")),et.createElement(ql,null,et.createElement(PO,null,et.createElement(LO,{mapped:!!C.figmaMapping}),et.createElement(MO,{mapped:!!C.figmaMapping},C.figmaMapping?"Mapped":"Unmapped"))),et.createElement(ql,null,C.figmaMapping?et.createElement(Ok,{variant:"unlink",onClick:()=>p(C.id)},"Unlink"):et.createElement(Ok,{variant:"link",onClick:()=>n(C.id)},"Link"))))))))};import ke,{useState as Zl,useMemo as Gk}from"react";import{styled as dt}from"storybook/theming";import $k from"react";import{styled as Uk,keyframes as RO}from"storybook/theming";var zO=RO`
40
+ animation: ${dN} 0.8s linear infinite;
41
+ `,mN=zn.div(({theme:e})=>({position:"absolute",top:"100%",left:"0",marginTop:"6px",padding:"12px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:1e3,minWidth:"220px",fontSize:e.typography.size.s1})),hN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),xN=zn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),yN=zn.span(({score:e,theme:t})=>{let n=()=>e>=80?t.color.positive:e>=50?t.color.warning:t.color.negative;return{fontWeight:700,fontSize:t.typography.size.s3,color:n()}}),bN=zn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),SN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),wN=zn.span({display:"flex",alignItems:"center",gap:"4px"}),vN=zn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),kN=zn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),CN=zn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),TN=zn.ul(({theme:e})=>({margin:"8px 0 0 0",padding:"0 0 0 14px",fontSize:e.typography.size.s1,color:e.color.defaultText,"& li":{marginBottom:"2px"}})),$v=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Ze(),[n,r]=vm(!1),[o,i]=vm(!1),[s,a]=vm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=q(),l=localStorage.getItem("uicopilot_session_token"),d=await oe(`${c}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({projectId:t,figmaFileUrl:e,figmaMetadata:{}})});if(!d.ok)throw new Error("Failed to check quality");let f=await d.json();a(f),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Ut.createElement(pN,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Ut.createElement(fN,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Ut.createElement(Ut.Fragment,null,Ut.createElement(gN,null)," Checking..."):s?Ut.createElement(Ut.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Ut.createElement(Ut.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Ut.createElement(mN,null,Ut.createElement(hN,null,Ut.createElement(xN,null,"Figma Design Quality"),Ut.createElement(yN,{score:s.score},Math.round(s.score),"%")),Ut.createElement(bN,null,Object.entries(s.categories).map(([c,l])=>Ut.createElement(SN,{key:c},Ut.createElement(wN,null,Ut.createElement(vN,{status:l.status},uN(l.status)),cN[c]||c),Ut.createElement(kN,null,l.score)))),s.summary&&Ut.createElement(CN,null,s.summary),s.recommendations?.length>0&&Ut.createElement(TN,null,s.recommendations.slice(0,2).map((c,l)=>Ut.createElement("li",{key:l},c))))):null};var FN=Go.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),EN=Go.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),AN=Go.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),PN=Go.div({display:"flex",gap:"8px",alignItems:"center"}),LN=Go.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight}})),MN=Go(en)({whiteSpace:"nowrap"}),BN=Go.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),jv=()=>{let{selectedProjectId:e,projects:t}=Ze(),{sessionToken:n}=we(),{updateProject:r}=qr(),o=t.find(S=>S.id===e),[i,s]=km(""),[a,u]=km(!1),[c,l]=km(null),d=o?.figmaFileUrl||o?.figmaFileId||"";IN(()=>{s(d),l(null)},[o?.id,d]);let f=i!==d,p=Uv(async()=>{if(!(!e||!f))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let S=q();try{await oe(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}oe(`${S}/api/figma/frames?projectId=${e}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${n}`}},6e4).catch(()=>{}),l({type:"success",message:"Saved \u2014 reloading Figma cache\u2026"}),setTimeout(()=>l(null),3e3)}catch(S){l({type:"error",message:S instanceof Error?S.message:"Failed to save"})}finally{u(!1)}},[e,i,f,r]),g=Uv(S=>{S.key==="Enter"&&f&&!a&&p()},[f,a,p]);return e?So.createElement(FN,null,So.createElement(EN,null,So.createElement(AN,null,"Figma File URL"),So.createElement($v,{figmaFileUrl:d})),So.createElement(PN,null,So.createElement(LN,{type:"text",value:i,onChange:S=>s(S.target.value),onKeyDown:g,placeholder:"https://www.figma.com/file/..."}),So.createElement(MN,{onClick:p,disabled:!f||a},a?"Saving...":"Save")),c&&So.createElement(BN,{variant:c.type},c.message)):null};import kt,{useState as nc,useEffect as X_}from"react";import{styled as Yn}from"storybook/theming";ve();je();import Je,{useState as Bi,useEffect as w_,useCallback as Co}from"react";import{styled as Jt}from"storybook/theming";je();je();De();import X,{useState as Li,useEffect as Ak,useMemo as zm,useCallback as Pk}from"react";import{styled as Ye}from"storybook/theming";pt();import Me,{useState as Ek,useEffect as DN,memo as RN}from"react";import{styled as xe}from"storybook/theming";var Hv=xe.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10001}),Wv=xe.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"6px",width:"90%",maxWidth:"900px",maxHeight:"85vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.3)",border:`1px solid ${e.appBorderColor}`})),Vv=xe.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),Gv=xe.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),qv=xe(wn)({fontSize:"20px",padding:"4px 8px"}),Yv=xe.div({flex:1,overflow:"auto",padding:"20px"}),Kv=xe(so)({fontSize:"14px",marginBottom:"16px"}),Cm=xe.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Xv=xe.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s","&:hover":{borderColor:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Tm=xe.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Qv=xe.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),Jv=xe.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),Ys=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",height:"100%",minHeight:"80px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:e.color.mediumdark})),Im=xe.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Ks=xe.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Fm=xe.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Em=xe.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Am=xe.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Pm=xe.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Zv=xe.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),jl=xe.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),ek=xe.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),tk=xe.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),nk=xe.button(({theme:e})=>({position:"absolute",top:"8px",left:"8px",width:"24px",height:"24px",padding:0,background:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"14px",color:e.color.defaultText,zIndex:10,transition:"all 0.2s","&:hover":{background:e.background.hoverable,borderColor:le}})),rk=xe.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.08)",height:"auto",minHeight:"200px","&:hover":{borderColor:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),ok=xe.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:le,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),ik=xe.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),OZ=xe.div(({theme:e})=>({padding:"20px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",backgroundColor:e.background.app,border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",gridColumn:"1 / -1"})),sk=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${le}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),ak=xe.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Lm=xe.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"8px 12px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"}})),lk=xe.span(({theme:e})=>({display:"inline-block",padding:"3px 8px",background:e.background.app,borderRadius:"4px",fontSize:"11px",color:e.color.defaultText,border:`1px solid ${e.appBorderColor}`,lineHeight:1.2})),ck=xe.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),uk=xe.span(({theme:e})=>({color:e.color.defaultText})),Hl=xe.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.appBorderColor,borderRadius:"4px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.hoverable}, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),pk=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),dk=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),fk=xe.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),gk=xe(En)({flex:1,width:"auto"}),mk=xe.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),hk=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",marginBottom:"8px",backgroundColor:e.background.hoverable||"#f0f9ff",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s1,flexWrap:"wrap"})),xk=xe.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),yk=xe.span(({theme:e})=>({color:e.color.defaultText})),bk=xe.button(({theme:e})=>({padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.lightest,backgroundColor:e.color.secondary,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer","&:hover":{opacity:.9}})),Sk=xe.button(({theme:e})=>({padding:"2px 6px",fontSize:e.typography.size.s1,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",cursor:"pointer","&:hover":{color:e.color.defaultText}})),wk=xe.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),Wl=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),Xs=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Pi=xe(En)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),Vl=xe.button(({theme:e})=>({padding:"6px 10px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:e.color.negative,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:`${e.color.negative}15`}})),vk=xe.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),kk=xe.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:le,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),Ck=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Mm=xe.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?le:e.appBorderColor}`,borderRadius:"8px",backgroundColor:t?"rgba(234, 88, 12, 0.06)":e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",position:"relative","&:hover":{borderColor:le,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Bm=xe.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?le:e.appBorderColor}`,backgroundColor:t?le:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),Tk=xe.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),Ik=xe.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:le,color:e.color.lightest,fontSize:"14px",fontWeight:500,cursor:t?"not-allowed":"pointer",opacity:t?.6:1,transition:"all 0.2s","&:hover":{backgroundColor:t?e.color.mediumdark:le,opacity:t?.6:.9}})),Fk=xe.span(({theme:e})=>({display:"inline-block",padding:"1px 5px",marginLeft:"6px",borderRadius:"3px",fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:"rgba(16, 185, 129, 0.15)",color:e.color.positive,verticalAlign:"middle"}));De();var Dm=RN(({src:e,alt:t,isComponentSet:n,loadingDone:r})=>{let[o,i]=Ek(!1),[s,a]=Ek(!1);return DN(()=>{i(!1),a(!1)},[e]),o?Me.createElement(Ys,null,Me.createElement(Fm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(Ks,null,"Failed to load")):e?Me.createElement(Me.Fragment,null,!s&&Me.createElement(Ys,{style:{position:"absolute",inset:0}},Me.createElement(Im,null),Me.createElement(Ks,null,"Loading...")),Me.createElement(Jv,{src:e,alt:t,onLoad:()=>a(!0),onError:()=>i(!0),style:{opacity:s?1:0}})):r?Me.createElement(Ys,null,Me.createElement(Fm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(Ks,null,"No preview")):Me.createElement(Ys,null,Me.createElement(Im,null),Me.createElement(Ks,null,"Loading..."))}),Qs=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,isLoadingVariants:i=!1,isExpanded:s,isNew:a=!1,onToggleExpand:u,onSelect:c,multiSelect:l=!1,selectedFrames:d=new Set,variantFilters:f=[]})=>{let p=e.type==="COMPONENT_SET",g=p&&(e.children&&e.children.length>0||(e.childCount??0)>0),S=e.children||o||[],C=Me.useMemo(()=>S.length===0?[]:f.some(R=>R.value)?S.filter(R=>R.variantProperties?f.every(z=>z.value?R.variantProperties?.[z.property]===z.value:!0):!1):S,[S,f]),F=R=>{if(p&&g){u(e.id,R);return}c(e)},k=l?Mm:Xv;return Me.createElement(Me.Fragment,null,Me.createElement(k,{onClick:F,title:e.name,isSelected:l?d.has(e.id):void 0,style:{cursor:"pointer"}},l&&!g&&Me.createElement(Bm,{isSelected:d.has(e.id)},d.has(e.id)?"\u2713":""),p?Me.createElement(Qv,null,g&&Me.createElement(nk,{onClick:R=>u(e.id,R),title:s?"Collapse variants":"Expand variants"},s?"\u25BC":"\u25B6"),g&&Me.createElement(ok,null,C.length>0&&C.length!==S.length?`${C.length} / ${S.length}`:e.childCount??S.length," variants"),Me.createElement(Dm,{src:t,alt:e.name,isComponentSet:!0})):Me.createElement(Tm,null,Me.createElement(Dm,{src:t,alt:e.name,isComponentSet:!1})),Me.createElement(Em,null,Me.createElement(Am,null,e.name,a&&Me.createElement(Fk,null,"New")),Me.createElement(Pm,null,e.type))),g&&s&&i&&Me.createElement(Me.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((R,z)=>Me.createElement(sk,{key:`skeleton-${z}`},Me.createElement(ak,null),Me.createElement(Lm,{width:"80%"}),Me.createElement(Lm,{width:"50%"})))),g&&s&&!i&&C.map(R=>Me.createElement(Rm,{key:R.id,variant:R,thumbnail:r?.[R.id]||n[R.id],onSelect:c,multiSelect:l,isSelected:d.has(R.id),loadingDone:!!t||r!==void 0&&R.id in(r||{})})))},Rm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1})=>Me.createElement(r?Mm:rk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Me.createElement(Bm,{isSelected:o},o?"\u2713":""),Me.createElement(Tm,null,Me.createElement(Dm,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i})),Me.createElement(Em,null,Me.createElement(Am,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Me.createElement(ik,null,Object.entries(e.variantProperties).map(([u,c])=>Me.createElement(lk,{key:u},Me.createElement(ck,null,u,":")," ",Me.createElement(uk,null,c)))),Me.createElement(Pm,{style:{marginTop:"6px"}},"VARIANT")));var zN=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),NN=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),ON=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),Lk=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),Mk=Ye.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),Gl=Ye.div({display:"flex",gap:"8px",marginTop:"10px"}),_N=Ye(En)({flex:1,width:"auto"}),Bk=Ye(so)({flex:1,fontSize:"13px"}),$N=Ye.div({flex:1,overflow:"auto",padding:"8px"}),UN=Ye.div(({theme:e,selected:t,mapped:n})=>({padding:"12px",marginBottom:"8px",borderRadius:"8px",border:`2px solid ${t?e.color.secondary:n?e.color.positive:e.appBorderColor}`,backgroundColor:t?`${e.color.secondary}10`:e.background.content,cursor:"pointer",transition:"all 0.2s","&:hover":{borderColor:t?e.color.secondary:e.color.mediumlight}})),jN=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),HN=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),WN=Ye.span(({theme:e,mapped:t})=>({fontSize:"10px",fontWeight:500,padding:"2px 6px",borderRadius:"4px",backgroundColor:t?`${e.color.positive}20`:e.background.hoverable,color:t?e.color.positive:e.color.mediumdark})),VN=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),GN=Ye.div(({theme:e})=>({marginTop:"8px",padding:"8px",backgroundColor:`${e.color.positive}10`,borderRadius:"6px",fontSize:"11px",color:e.color.positive,display:"flex",alignItems:"center",gap:"8px",position:"relative"})),qN=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),YN=Ye.div({flex:1,overflow:"hidden"}),KN=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),XN=Ye.div(({theme:e})=>({position:"absolute",bottom:"100%",left:"0",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)",border:`1px solid ${e.appBorderColor}`,padding:"8px",zIndex:100,maxWidth:"280px",animation:"fadeIn 0.15s ease-out","@keyframes fadeIn":{from:{opacity:0,transform:"translateY(4px)"},to:{opacity:1,transform:"translateY(0)"}}})),QN=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),JN=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),ZN=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),eO=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Nm=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),tO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Om=20,nO=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),rO=Ye.button(({theme:e,disabled:t})=>({padding:"8px 16px",fontSize:"13px",fontWeight:500,color:t?e.color.mediumdark:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${t?e.appBorderColor:e.color.secondary}`,borderRadius:"6px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"all 0.2s","&:hover":{backgroundColor:t?"transparent":`${e.color.secondary}10`}})),oO=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),iO=Ye.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",fontSize:"13px",fontWeight:500,color:e.color.secondary,backgroundColor:"transparent",border:`1px solid ${e.color.secondary}`,borderRadius:"4px",cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:`${e.color.secondary}10`}})),sO=Ye.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),_m=Ye.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),$m=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),aO=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),lO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Dk=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),Rk=Ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),zk=Ye.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"12px",animation:"shimmer 1.5s infinite",background:`linear-gradient(90deg, ${e.background.hoverable} 25%, ${e.background.app} 50%, ${e.background.hoverable} 75%)`,backgroundSize:"200% 100%","@keyframes shimmer":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})),cO=()=>X.createElement(lO,null,Array.from({length:8}).map((e,t)=>X.createElement(Dk,{key:t},X.createElement(Rk,null),X.createElement(zk,{width:`${60+t%3*15}%`})))),uO=Ye.div(({theme:e})=>({padding:"12px 16px",backgroundColor:`${e.color.secondary}10`,borderBottom:`1px solid ${e.appBorderColor}`,fontSize:"13px",color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),pO=Ye.div({position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.8)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:50,gap:"8px"}),dO=Ye.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),fO=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),Nk=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=Gs({projectId:i,limit:Om,enabled:!!i}),[a,u]=Li("all"),[c,l]=Li(""),[d,f]=Li(null),[p,g]=Li(1),[S,C]=Li(null),[F,k]=Li(!1),R=zm(()=>{let h=new Set;return e.forEach(T=>{T.componentTitle&&h.add(T.componentTitle)}),Array.from(h).sort()},[e]),z=zm(()=>e.filter(h=>{if(a!=="all"&&h.componentTitle!==a)return!1;if(c){let T=c.toLowerCase();return h.name.toLowerCase().includes(T)||h.title.toLowerCase().includes(T)}return!0}),[e,a,c]),_=d?s.frames.find(h=>h.id===d):null,M=zm(()=>{if(!d)return[];let h=s.variantChildren[d]||[];return h.length===0?[]:s.variantFilters.some(T=>T.value)?h.filter(T=>T.variantProperties?s.variantFilters.every(I=>I.value?T.variantProperties?.[I.property]===I.value:!0):!1):h},[d,s.variantChildren,s.variantFilters]),B=M.slice(0,p*Om),m=M.length>p*Om;Ak(()=>{if(!d||B.length===0)return;let h=B.map(T=>T.id);s.fetchVariantThumbnails(d,h)},[d,B.length,p]),Ak(()=>{k(!1)},[]);let x=Pk(async h=>{if(n)try{let T=q(),I=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${T}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:h.id,name:h.name})})).ok)throw new Error("Failed to save mapping");o(n,h.id,h.name)}catch(T){y.error("[MapStoriesTab] Error saving mapping:",T)}},[n,i,o]),b=Pk((h,T)=>{if(T.stopPropagation(),d===h){f(null),g(1);return}f(h),g(1),!s.variantThumbnails[h]&&!s.loadingVariants.has(h)&&s.toggleExpanded(h,T)},[d,s]),E=e.find(h=>h.id===n);return t?X.createElement(aO,null,"Loading stories..."):X.createElement(zN,null,X.createElement(NN,null,X.createElement(Lk,null,X.createElement(Mk,null,"Storybook Stories"),X.createElement(Gl,null,X.createElement(_N,{value:a,onChange:h=>u(h.target.value)},X.createElement("option",{value:"all"},"All Components"),R.map(h=>X.createElement("option",{key:h,value:h},h)))),X.createElement(Gl,null,X.createElement(Bk,{type:"text",placeholder:"Search stories...",value:c,onChange:h=>l(h.target.value)}))),X.createElement($N,null,z.length===0?X.createElement($m,null,"No stories found"):z.map(h=>X.createElement(UN,{key:h.id,selected:h.id===n,mapped:!!h.figmaMapping,onClick:()=>r(h.id)},X.createElement(jN,null,X.createElement(HN,null,h.name),X.createElement(WN,{mapped:!!h.figmaMapping},h.figmaMapping?"Mapped":"Unmapped")),X.createElement(VN,null,h.title),h.figmaMapping&&X.createElement(GN,{onMouseEnter:()=>C(h.id),onMouseLeave:()=>C(null)},(()=>{let T=h.figmaMapping?.figmaNodeId,I=T?s.resolveThumbnail(T):void 0;return X.createElement(X.Fragment,null,I?X.createElement(qN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}):X.createElement("span",null,"\u{1F517}"),S===h.id&&I&&X.createElement(XN,null,X.createElement(QN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}),X.createElement(JN,null,h.figmaMapping?.figmaFrameName)))})(),X.createElement(YN,null,X.createElement(KN,null,h.figmaMapping.figmaFrameName))))))),X.createElement(ON,null,n?X.createElement(X.Fragment,null,X.createElement(uO,null,X.createElement("span",null,"Click a Figma component below to link it to"," ",X.createElement("strong",null,E?.name))),X.createElement(Lk,null,X.createElement(Mk,null,"Figma Components"),X.createElement(Gl,null,X.createElement(eO,null,X.createElement(Nm,null,X.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:h=>s.setShowComponentSets(h.target.checked)}),"Component Sets"),X.createElement(Nm,null,X.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:h=>s.setShowFrames(h.target.checked)}),"Frames"),X.createElement(Nm,null,X.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:h=>s.setShowComponents(h.target.checked)}),"Components")),s.availablePages.length>1&&X.createElement(Pi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:h=>s.setFigmaPage(h.target.value)},X.createElement("option",{value:""},"All pages"),s.availablePages.map(h=>X.createElement("option",{key:h,value:h},h)))),s.availableFilters.length>0&&X.createElement(Wl,null,X.createElement(Xs,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:h,values:T})=>{let I=s.variantFilters.find(v=>v.property===h);return X.createElement(Pi,{key:h,isActive:!!I?.value,value:I?.value||"",onChange:v=>s.handleFilterChange(h,v.target.value)},X.createElement("option",{value:""},h),T.map(v=>X.createElement("option",{key:v,value:v},h,"=",v)))}),s.availableFilters.length>5&&X.createElement(Xs,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(h=>h.value)&&X.createElement(Vl,{onClick:s.clearFilters},"Clear All")),X.createElement(Gl,null,X.createElement(Bk,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:h=>s.setSearch(h.target.value)}))),X.createElement(ZN,null,F&&X.createElement(pO,null,X.createElement(dO,null),X.createElement(fO,null,"Loading thumbnails...")),s.isLoading?X.createElement(cO,null):s.filteredFrames.length===0?X.createElement($m,null,X.createElement("span",null,"No components found")):X.createElement(tO,null,d&&_?X.createElement(X.Fragment,null,X.createElement(oO,null,X.createElement(iO,{onClick:()=>{f(null),g(1)}},"Back"),X.createElement(sO,null,_.name)),s.loadingVariants.has(d)?X.createElement(X.Fragment,null,X.createElement(_m,null,"Loading ",_.childCount??"..."," variants..."),Array.from({length:Math.min(8,_.childCount??8)}).map((h,T)=>X.createElement(Dk,{key:`variant-skeleton-${T}`},X.createElement(Rk,null),X.createElement(zk,{width:`${60+T%3*15}%`})))):X.createElement(X.Fragment,null,X.createElement(_m,null,"Showing ",B.length," of ",M.length," variants"),B.map(h=>X.createElement(Rm,{key:h.id,variant:h,thumbnail:s.variantThumbnails[d]?.[h.id]||s.thumbnails[h.id],onSelect:x,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d)})))):X.createElement(X.Fragment,null,X.createElement(_m,null,"Showing ",s.frames.length," of ",s.totalFrames," components"),s.filteredFrames.map(h=>X.createElement(Qs,{key:h.id,frame:h,thumbnail:s.thumbnails[h.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[h.id],variantChildren:s.variantChildren[h.id],isLoadingVariants:s.loadingVariants.has(h.id),isExpanded:!1,onToggleExpand:b,onSelect:x,variantFilters:s.variantFilters}))),(d?m:s.hasMore)&&X.createElement(nO,null,X.createElement(rO,{disabled:s.loadingMore,onClick:async()=>{d?g(h=>h+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):X.createElement($m,null,X.createElement("span",null,"Select a story from the left to link it to Figma"))))};je();import et,{useState as Um,useMemo as Ok,useCallback as _k}from"react";import{styled as Rt}from"storybook/theming";pt();var gO=Rt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),mO=Rt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),hO=Rt(En)({width:"auto",minWidth:"200px"}),xO=Rt(so)({fontSize:"13px",minWidth:"250px"}),yO=Rt.button(({theme:e,active:t})=>({padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${t?e.color.positive:e.appBorderColor}`,borderRadius:"6px",backgroundColor:t?`${e.color.positive}15`:e.background.content,color:t?e.color.positive:e.color.mediumdark,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{borderColor:e.color.positive}})),bO=Rt.button(({theme:e})=>({marginLeft:"auto",padding:"8px 12px",fontSize:"13px",fontWeight:500,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s","&:hover":{backgroundColor:e.background.hoverable}})),SO=Rt.div({flex:1,overflow:"auto"}),wO=Rt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),vO=Rt.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),ql=Rt.th(({theme:e})=>({padding:"12px 20px",textAlign:"left",fontWeight:600,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px",color:e.color.mediumdark,borderBottom:`1px solid ${e.appBorderColor}`})),kO=Rt.tbody({}),CO=Rt.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),Yl=Rt.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),TO=Rt.div({display:"flex",flexDirection:"column",gap:"2px"}),IO=Rt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),FO=Rt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),EO=Rt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),AO=Rt.div({display:"flex",alignItems:"center",gap:"8px"}),PO=Rt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),LO=Rt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),$k=Rt.button(({theme:e,variant:t})=>({padding:"6px 12px",fontSize:"12px",fontWeight:500,border:`1px solid ${t==="link"?e.color.secondary:e.color.negative}`,borderRadius:"4px",backgroundColor:t==="link"?`${e.color.secondary}10`:`${e.color.negative}10`,color:t==="link"?e.color.secondary:e.color.negative,cursor:"pointer",transition:"all 0.2s","&:hover":{backgroundColor:t==="link"?`${e.color.secondary}20`:`${e.color.negative}20`}})),MO=Rt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),BO=Rt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),Uk=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=Um("all"),[a,u]=Um(""),[c,l]=Um(!0),d=Ok(()=>{let C=new Set;return e.forEach(F=>{F.componentTitle&&C.add(F.componentTitle)}),Array.from(C).sort()},[e]),f=Ok(()=>e.filter(C=>{if(i!=="all"&&C.componentTitle!==i||!c&&!C.figmaMapping)return!1;if(a){let F=a.toLowerCase();return C.name.toLowerCase().includes(F)||C.title.toLowerCase().includes(F)||(C.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),p=_k(async C=>{try{let F=q(),k=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${F}/api/mappings?projectId=${o}&storyId=${C}`,{method:"DELETE",headers:{Authorization:`Bearer ${k}`}})).ok)throw new Error("Failed to delete mapping");r(C)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),g=_k(()=>{let C=e.filter(z=>z.figmaMapping).map(z=>({storyId:z.id,storyName:z.name,storyTitle:z.title,figmaNodeId:z.figmaMapping.figmaNodeId,figmaFrameName:z.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(C,null,2)],{type:"application/json"}),k=URL.createObjectURL(F),R=document.createElement("a");R.href=k,R.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL(k)},[e]);if(t)return et.createElement(BO,null,"Loading mappings...");let S=e.filter(C=>C.figmaMapping).length;return et.createElement(gO,null,et.createElement(mO,null,et.createElement(hO,{value:i,onChange:C=>s(C.target.value)},et.createElement("option",{value:"all"},"All Components"),d.map(C=>et.createElement("option",{key:C,value:C},C))),et.createElement(xO,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:C=>u(C.target.value)}),et.createElement(yO,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),et.createElement(bO,{onClick:g,disabled:S===0},"\u{1F4E5} Export JSON")),f.length===0?et.createElement(MO,null,et.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):et.createElement(SO,null,et.createElement(wO,null,et.createElement(vO,null,et.createElement("tr",null,et.createElement(ql,{style:{width:"35%"}},"Story"),et.createElement(ql,{style:{width:"35%"}},"Figma Component"),et.createElement(ql,{style:{width:"15%"}},"Status"),et.createElement(ql,{style:{width:"15%"}},"Actions"))),et.createElement(kO,null,f.map(C=>et.createElement(CO,{key:C.id,mapped:!!C.figmaMapping},et.createElement(Yl,null,et.createElement(TO,null,et.createElement(IO,null,C.name),et.createElement(FO,null,C.title))),et.createElement(Yl,null,et.createElement(EO,{mapped:!!C.figmaMapping},C.figmaMapping?et.createElement(et.Fragment,null,et.createElement("span",null,"\u{1F3A8}"),C.figmaMapping.figmaFrameName):"\u2014")),et.createElement(Yl,null,et.createElement(AO,null,et.createElement(PO,{mapped:!!C.figmaMapping}),et.createElement(LO,{mapped:!!C.figmaMapping},C.figmaMapping?"Mapped":"Unmapped"))),et.createElement(Yl,null,C.figmaMapping?et.createElement($k,{variant:"unlink",onClick:()=>p(C.id)},"Unlink"):et.createElement($k,{variant:"link",onClick:()=>n(C.id)},"Link"))))))))};import ke,{useState as ec,useMemo as Yk}from"react";import{styled as dt}from"storybook/theming";import jk from"react";import{styled as Hk,keyframes as DO}from"storybook/theming";var RO=DO`
42
42
  0% { transform: rotate(0deg); }
43
43
  100% { transform: rotate(360deg); }
44
- `,NO=Uk.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${zO} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),OO=Uk.button(({theme:e,variant:t="default",disabled:n})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"5px 12px",fontSize:"12px",fontWeight:600,border:`1px solid ${e.color.medium}`,borderRadius:"5px",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,transition:"all 0.2s",whiteSpace:"nowrap",...t==="default"&&{backgroundColor:e.background.content,color:e.color.defaultText,"&:hover":n?{}:{borderColor:e.color.secondary,color:e.color.secondary,backgroundColor:"rgba(30, 167, 253, 0.05)"}},...t==="ghost"&&{backgroundColor:"transparent",border:"none",color:e.color.mediumdark,padding:"5px 8px","&:hover":n?{}:{color:e.color.defaultText,backgroundColor:e.background.hoverable}}})),Br=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>$k.createElement(OO,{variant:r,disabled:t||e,onClick:n},e&&$k.createElement(NO,null),e&&i?i:o);je();import on from"react";import{styled as Js}from"storybook/theming";var jk=Js.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",backgroundColor:e.background.hoverable,borderRadius:"6px",fontFamily:"Inter, sans-serif",fontSize:"11px",color:e.color.mediumdark,gap:"16px"})),_O=Js.div({display:"flex",alignItems:"center",gap:"12px"}),Yl=Js.span({whiteSpace:"nowrap"}),Hk=Js.div({display:"flex",alignItems:"center",gap:"8px"}),Kl=Js.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Xl=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*sw;return r?on.createElement(jk,null,on.createElement(Yl,null,o.toLocaleString()," tokens"),on.createElement(Hk,null,on.createElement(Kl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Kl,null,"\u20AA",i.toFixed(2)))):on.createElement(jk,null,on.createElement(_O,null,on.createElement(Yl,null,e.toLocaleString()," input"),on.createElement("span",null,"+"),on.createElement(Yl,null,t.toLocaleString()," output"),on.createElement("span",null,"="),on.createElement(Yl,null,on.createElement("strong",null,o.toLocaleString())," tokens")),on.createElement(Hk,null,on.createElement(Kl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Kl,null,"\u20AA",i.toFixed(2))))};import Nn from"react";import{styled as wo}from"storybook/theming";function Om(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var $O=wo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),Wk=wo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),UO=wo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),jO=wo.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.2}px`,padding:`1px ${e.layoutMargin*.5}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.mono})),HO=wo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),WO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),VO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),GO=wo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),Vk=({data:e,color:t,compact:n})=>n?Nn.createElement(Wk,{color:t},e.summary):Nn.createElement($O,null,Nn.createElement(Wk,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Nn.createElement(UO,null,e.mappings.map((r,o)=>Nn.createElement(Nn.Fragment,{key:o},Nn.createElement(jO,null,r.from," ",Nn.createElement(HO,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Nn.createElement(WO,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Nn.createElement(Nn.Fragment,null,e.defaults.map((r,o)=>Nn.createElement(VO,{key:o},Nn.createElement(GO,null,r.choice),Nn.createElement("span",null,"\u2014 ",r.why)))));var qO=dt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),YO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),KO=dt.div({display:"flex",flexDirection:"column",gap:"4px"}),XO=dt.div({display:"flex",alignItems:"center",gap:"10px"}),QO=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,letterSpacing:"-0.3px"})),qk=dt.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="success"?`${e.color.positive}1a`:t==="danger"?`${e.color.negative}1a`:`${e.color.secondary}1a`,color:t==="success"?e.color.positive:t==="danger"?e.color.negative:e.color.secondary})),JO=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),ZO=dt.div({display:"flex",gap:"8px"}),e_=dt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),t_=dt(so)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),n_=dt.div({display:"flex",gap:"4px"}),Ql=dt.button(({theme:e,active:t})=>({padding:"6px 12px",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,border:t?"none":`1px solid ${e.appBorderColor}`,backgroundColor:t?e.color.defaultText:e.background.content,color:t?e.color.inverseText:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:t?e.color.defaultText:e.background.hoverable}})),r_=dt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),o_=dt.div(({theme:e,dimmed:t})=>({display:"flex",alignItems:"center",padding:"12px 16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"10px",gap:"12px",backgroundColor:e.background.content,opacity:t?.6:1,transition:"opacity 0.15s",position:"relative",zIndex:0,"&:hover":{zIndex:10}})),i_=dt.div(({theme:e,checked:t})=>({width:"18px",height:"18px",borderRadius:"4px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"all 0.15s",...t?{backgroundColor:e.color.defaultText,color:e.color.inverseText,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold}:{border:`2px solid ${e.color.mediumlight}`}})),s_=dt.div(({theme:e,bgColor:t})=>({width:"48px",height:"40px",borderRadius:"6px",backgroundColor:t||e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden"})),Jl=dt.div(({theme:e})=>({width:"120px",height:"80px",borderRadius:"8px",backgroundColor:e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden",border:`1px solid ${e.appBorderColor}`})),a_=dt.img({width:"100%",height:"100%",objectFit:"contain"}),Jk=dt.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"uicopilot-spin 0.8s linear infinite","@keyframes uicopilot-spin":{to:{transform:"rotate(360deg)"}}})),Yk=dt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),Kk=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),_m=dt.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),Iee=dt.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,lineHeight:1.5,whiteSpace:"pre-line"})),l_=dt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),c_=dt.span(({theme:e,level:t})=>({padding:"4px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,flexShrink:0,backgroundColor:t==="high"?`${e.color.positive}1a`:t==="medium"?`${e.color.warning}1a`:`${e.color.negative}1a`,color:t==="high"?e.color.positive:t==="medium"?e.color.warning:e.color.negative})),u_=dt.button(({theme:e})=>({padding:"4px 8px",borderRadius:e.appBorderRadius,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,border:`1px solid ${e.appBorderColor}`,backgroundColor:"transparent",color:e.color.mediumdark,cursor:"pointer",flexShrink:0,transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText}})),p_=dt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),d_=dt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),f_=dt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),g_=dt.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="cache"?`${e.color.warning}1a`:`${e.color.positive}1a`,color:t==="cache"?e.color.warning:e.color.positive})),m_=dt.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"5px",padding:"5px 12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:"transparent",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Fee=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 24px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Xk=({src:e,alt:t})=>{let[n,r]=Zl(!1);return ke.createElement(ke.Fragment,null,!n&&ke.createElement(Jk,null),ke.createElement(a_,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function Qk(e){return e>=90?"high":e>=70?"medium":"low"}function h_(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var Zk=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:s,source:a,resolveThumbnail:u,resolveStoryScreenshot:c,isCapturingScreenshots:l,onBrowse:d})=>{let[f,p]=Zl(()=>{let b=new Set;for(let E of e.mappings)E.confidence>=90&&b.add(E.storyId);return b}),[g,S]=Zl(""),[C,F]=Zl("all"),k=Gk(()=>{let b=new Map;for(let E of t)b.set(E.id,{name:E.name,title:E.title});return b},[t]),R=Gk(()=>{let b=e.mappings;if(C!=="all"&&(b=b.filter(E=>Qk(E.confidence)===C)),g.trim()){let E=g.toLowerCase();b=b.filter(h=>{let T=k.get(h.storyId);return T?.name.toLowerCase().includes(E)||T?.title.toLowerCase().includes(E)||h.componentSetName.toLowerCase().includes(E)||h.figmaFrameName.toLowerCase().includes(E)})}return b},[e.mappings,C,g,k]),z=b=>{p(E=>{let h=new Set(E);return h.has(b)?h.delete(b):h.add(b),h})},_=()=>{let b=e.mappings.filter(E=>f.has(E.storyId));n(b)},M=e.mappings.filter(b=>b.confidence>=90).length,B=e.mappings.filter(b=>b.confidence>=70&&b.confidence<90).length,m=e.mappings.filter(b=>b.confidence<70).length,x=e.usage;return ke.createElement(qO,null,ke.createElement(YO,null,ke.createElement(KO,null,ke.createElement(XO,null,ke.createElement(QO,null,"Auto-Map Results"),ke.createElement(qk,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&ke.createElement(qk,{variant:"danger"},e.unmatched.length," unmatched"),a&&ke.createElement(g_,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),ke.createElement(JO,null,"Review matches below. Uncheck any incorrect mappings before applying.")),ke.createElement(ZO,null,a==="cache"&&o&&ke.createElement(m_,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),ke.createElement(Br,{onClick:r,variant:"ghost"},"Cancel"),ke.createElement(Br,{loading:i,onClick:_,loadingText:"Applying..."},"Apply ",f.size," Selected"))),ke.createElement(e_,null,ke.createElement(t_,{type:"text",placeholder:"Filter stories...",value:g,onChange:b=>S(b.target.value)}),ke.createElement(n_,null,ke.createElement(Ql,{active:C==="all",onClick:()=>F("all")},"All ",e.mappings.length),M>0&&ke.createElement(Ql,{active:C==="high",onClick:()=>F("high")},"\u226590% (",M,")"),B>0&&ke.createElement(Ql,{active:C==="medium",onClick:()=>F("medium")},"70-89% (",B,")"),m>0&&ke.createElement(Ql,{active:C==="low",onClick:()=>F("low")},"<70% (",m,")"))),ke.createElement(r_,null,R.map(b=>{let E=k.get(b.storyId),h=Qk(b.confidence),T=f.has(b.storyId),I=h==="low";return ke.createElement(o_,{key:b.storyId,dimmed:I&&!T},ke.createElement(i_,{checked:T,onClick:()=>z(b.storyId)},T?"\u2713":""),(()=>{let v=c?.(b.storyId);return v?ke.createElement(Jl,null,ke.createElement(Xk,{src:v,alt:E?.name||b.storyId})):l?ke.createElement(Jl,null,ke.createElement(Jk,null)):ke.createElement(s_,{bgColor:I?"#f1f5f9":"#eff6ff"},ke.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:I?"#94a3b8":"#3b82f6"}},(E?.name||"?").substring(0,4)))})(),ke.createElement(Yk,null,ke.createElement(Kk,null,E?.name||b.storyId),ke.createElement(_m,null,E?.title||"")),ke.createElement(l_,null,"\u2192"),(()=>{let v=u?.(b.figmaNodeId),A=Om(b.reason),P=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return v?ke.createElement(Jl,{title:P},ke.createElement(Xk,{src:v,alt:b.figmaFrameName})):ke.createElement(Jl,{title:P},ke.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),ke.createElement(Yk,null,ke.createElement(Kk,null,b.componentSetName),ke.createElement(_m,null,b.figmaFrameName),ke.createElement(Vk,{data:Om(b.reason),color:h_(h)})),ke.createElement(c_,{level:h},b.confidence,"%"),d&&ke.createElement(u_,{onClick:()=>d(b.componentSetName)},"Browse"))}),e.unmatched.length>0&&ke.createElement(p_,null,ke.createElement(_m,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),ke.createElement(d_,null,e.unmatched.map(b=>{let E=k.get(b);return ke.createElement(f_,{key:b},ke.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),E?`${E.name} (${E.title})`:b)})))),x&&a!=="cache"&&ke.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},ke.createElement(Xl,{inputTokens:x.inputTokens||0,outputTokens:x.outputTokens||0,costUsd:x.costUsd||0})))};je();De();import{useState as vo,useCallback as ko,useRef as x_}from"react";import{useStorybookApi as y_}from"storybook/manager-api";function eC({projectId:e}){let t=y_(),n=x_(null),[r,o]=vo(!1),[i,s]=vo(!1),[a,u]=vo(!1),[c,l]=vo(null),[d,f]=vo(null),[p,g]=vo(null),[S,C]=vo(""),[F,k]=vo(null),R=ko(async()=>{let E=await fetch("/index.json");if(!E.ok)throw new Error("Failed to fetch Storybook index");let h=await E.json(),T=h.entries||h.stories||{},I=Object.keys(T).filter(P=>T[P].type==="story");y.debug(`[useAutoMap] Found ${I.length} stories in index.json`);let v=[];for(let P of I){let D=T[P],N=t.getData(P),w={...N?.initialArgs||{}},j=N?.argTypes||{};for(let[G,L]of Object.entries(j))if(!(G in w)){let K=L;if(K.defaultValue!==void 0)w[G]=K.defaultValue;else if(K.table?.defaultValue?.summary!==void 0){let ee=K.table.defaultValue.summary;ee==="false"?w[G]=!1:ee==="true"?w[G]=!0:w[G]=ee}}v.push({id:P,name:D.name||P.split("--").pop()||P,title:D.title||"",initialArgs:w,argTypes:j})}let A=v.filter(P=>Object.keys(P.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${v.length} stories, ${A.length} with args`),v},[t]),z=ko(async()=>{if(!e)return!1;try{let E=q(),h=localStorage.getItem("uicopilot_session_token");if(!h)return!1;let T=await fetch(`${E}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${h}`}});if(!T.ok)return!1;let I=await T.json();return I.hasSuggestions&&I.mappings?.length>0?(f(I),k("cache"),C(`Loaded ${I.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${I.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),_=ko(async E=>{o(!0),C("Collecting story information...");let h;try{if(h=await R(),E?.length&&(h=h.filter(I=>!E.includes(I.id)),y.debug(`[useAutoMap] After excluding mapped: ${h.length} stories`)),h.length===0){l("No unmapped stories found"),o(!1);return}g(h)}catch(I){l(I instanceof Error?I.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),C(`Analyzing ${h.length} stories against Figma components...`);let T=new AbortController;n.current=T;try{let I=q(),v=localStorage.getItem("uicopilot_session_token");if(!v)throw new Error("Not authenticated");let A=await fetch(`${I}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:e,stories:h.map(D=>({id:D.id,name:D.name,title:D.title,initialArgs:D.initialArgs,argTypes:D.argTypes}))}),signal:T.signal});if(!A.ok){let D=await A.json();throw new Error(D.error||"Auto-map failed")}let P=await A.json();f(P),k("llm"),C(`Found ${P.stats.matched} matches (${P.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${P.stats.matched}/${P.stats.total} matched, ${P.unmatched.length} unmatched`)}catch(I){if(I instanceof DOMException&&I.name==="AbortError"){C("Cancelled");return}l(I instanceof Error?I.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,R]),M=ko(async E=>{if(!e)return;if(l(null),f(null),k(null),o(!0),C("Checking for existing suggestions..."),await z()){o(!1);return}await _(E)},[e,z,_]),B=ko(async E=>{e&&(l(null),f(null),k(null),await _(E))},[e,_]),m=ko(async E=>{if(!(!e||E.length===0)){u(!0),C(`Applying ${E.length} mappings...`);try{let h=q(),T=localStorage.getItem("uicopilot_session_token");if(!T)throw new Error("Not authenticated");let I=0;for(let v of E)try{(await fetch(`${h}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:e,storyId:v.storyId,figmaNodeId:v.figmaNodeId,name:v.figmaFrameName||v.componentSetName})})).ok?I++:y.warn(`[useAutoMap] Failed to apply mapping for ${v.storyId}`)}catch(A){y.error(`[useAutoMap] Error applying mapping for ${v.storyId}:`,A)}C(`Applied ${I}/${E.length} mappings`),y.debug(`[useAutoMap] Applied ${I}/${E.length} mappings`)}catch(h){l(h instanceof Error?h.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),x=ko(()=>{n.current?.abort()},[]),b=ko(()=>{f(null),g(null),l(null),C(""),k(null)},[]);return{collectAndMap:M,rerun:B,loadExisting:z,applyMappings:m,cancel:x,reset:b,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:S,source:F}}De();import{useState as $m,useEffect as b_,useRef as tC}from"react";var nC=2;async function S_(e,t){try{let n=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`,{signal:t});return n.ok&&(await n.json()).screenshot||null}catch{return null}}function rC(e){let[t,n]=$m({}),[r,o]=$m(0),[i,s]=$m(!1),a=tC(null),u=tC(""),c=e.join(",");return b_(()=>{if(!e.length||c===u.current)return;u.current=c,n({}),o(0),s(!0);let l=new AbortController;a.current=l;let d=0;return(async()=>{for(let p=0;p<e.length&&!l.signal.aborted;p+=nC){let g=e.slice(p,p+nC),S=await Promise.all(g.map(F=>S_(F,l.signal).then(k=>({id:F,img:k}))));if(l.signal.aborted)break;let C={};for(let{id:F,img:k}of S)d++,k&&(C[F]=k);Object.keys(C).length>0&&n(F=>({...F,...C})),o(d)}s(!1),y.debug(`[useStoryScreenshots] Captured ${d}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import be,{useState as oC,useEffect as ec,useMemo as w_}from"react";De();var Mi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=Gs({projectId:r||"",enabled:e&&!!r}),d=be.useRef(!1);ec(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[f,p]=oC(new Set),[g,S]=oC(i||o[0]?.id||"");ec(()=>{i&&S(i)},[i]),ec(()=>{l.expandedSets.forEach(B=>{let m=l.variantChildren[B];if(!m||m.length===0)return;let x=m;l.variantFilters.some(E=>E.value)&&(x=m.filter(E=>E.variantProperties?l.variantFilters.every(h=>h.value?E.variantProperties?.[h.property]===h.value:!0):!1));let b=x.slice(0,20).map(E=>E.id);b.length>0&&l.fetchVariantThumbnails(B,b)})},[l.expandedSets,l.variantChildren,l.variantFilters]),ec(()=>{p(new Set)},[g]);let C=w_(()=>{let B=[];return l.filteredFrames.forEach(m=>{if(m.type==="COMPONENT_SET"&&m.children){let x=l.variantFilters.some(b=>b.value)?m.children.filter(b=>b.variantProperties?l.variantFilters.every(E=>E.value?b.variantProperties?.[E.property]===E.value:!0):!1):m.children;B.push(...x)}else B.push(m)}),B},[l.filteredFrames,l.variantFilters]),F=B=>{if(a)p(m=>{let x=new Set(m);return x.has(B.id)?x.delete(B.id):x.add(B.id),x});else{let m=l.resolveThumbnail(B.id);try{n({...B,thumbnail:m})}catch(x){y.error("[ComponentBrowserModal] onSelect threw error:",x)}t()}},k=()=>{let B=C.map(x=>x.id),m=B.every(x=>f.has(x));p(m?new Set:new Set(B))},R=()=>{if(u&&f.size>0){let B=C.filter(m=>f.has(m.id)).map(m=>({...m,thumbnail:l.resolveThumbnail(m.id)}));u(B),p(new Set)}},z=B=>{S(B),s?.(B)},_=B=>{B.target===B.currentTarget&&t()},M=o.find(B=>B.id===g);return e?be.createElement(Uv,{onClick:_},be.createElement(jv,null,be.createElement(Hv,null,be.createElement(Wv,null,"Link Figma Frames"),be.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},be.createElement("button",{onClick:()=>l.refresh(),disabled:l.isLoading,style:{padding:"4px 8px",fontSize:"12px",cursor:l.isLoading?"not-allowed":"pointer",background:"transparent",border:"1px solid #ccc",borderRadius:"4px"},title:"Refresh from Figma"},"Refresh"),be.createElement(Vv,{onClick:t},"\xD7"))),be.createElement(Gv,null,l.error&&be.createElement(Zv,null,l.error),!l.error&&be.createElement(be.Fragment,null,o.length>0&&be.createElement(uk,null,be.createElement(pk,null,"Story:"),be.createElement(dk,{value:g,onChange:B=>z(B.target.value)},o.map(B=>be.createElement("option",{key:B.id,value:B.id},B.name,B.mappingsCount?` (${B.mappingsCount} linked)`:""))),M?.mappingsCount?be.createElement(fk,{hasMapping:!0},M.mappingsCount," frames linked"):null),be.createElement(Qv,null,be.createElement(Ul,null,be.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:B=>l.setShowComponentSets(B.target.checked)}),"Component Sets"),be.createElement(Ul,null,be.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:B=>l.setShowFrames(B.target.checked)}),"Frames"),be.createElement(Ul,null,be.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:B=>l.setShowComponents(B.target.checked)}),"Components"),l.availablePages.length>1&&be.createElement(Pi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:B=>l.setFigmaPage(B.target.value),style:{marginLeft:"auto"}},be.createElement("option",{value:""},"All pages"),l.availablePages.map(B=>be.createElement("option",{key:B,value:B},B)))),l.filterSuggestion&&be.createElement(gk,null,be.createElement(mk,null,"AI suggests:"),be.createElement(hk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([B,m])=>`${B}=${m}`).join(", ")),be.createElement(xk,{onClick:l.applySuggestedFilters},"Apply"),be.createElement(yk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&be.createElement(bk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&be.createElement(Hl,null,be.createElement(Xs,null,"Filters:"),l.availableFilters.map(({property:B,values:m})=>{let x=l.variantFilters.find(b=>b.property===B);return be.createElement(Pi,{key:B,isActive:!!x?.value,value:x?.value||"",onChange:b=>l.handleFilterChange(B,b.target.value)},be.createElement("option",{value:""},B),m.map(b=>be.createElement("option",{key:b,value:b},B,"=",b)))}),l.variantFilters.some(B=>B.value)&&be.createElement(Wl,{onClick:l.clearFilters},"Clear All")),be.createElement(qv,{type:"text",placeholder:"Search frames...",value:l.search,onChange:B=>l.setSearch(B.target.value),autoFocus:!0}),a&&C.length>0&&be.createElement(Sk,null,be.createElement(wk,{onClick:k},f.size===C.length?"Deselect All":"Select All Visible"),be.createElement(vk,null,f.size>0?`${f.size} selected of `:"Showing ",C.length," frames")),l.isLoading&&be.createElement(Sm,null,Array.from({length:6}).map((B,m)=>be.createElement(ck,{key:m},be.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},be.createElement(jl,{width:"100%",height:"100%"})),be.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},be.createElement(jl,{width:"80%",height:"16px"}),be.createElement(jl,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&be.createElement(Jv,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&be.createElement(Sm,null,l.filteredFrames.map(B=>be.createElement(Qs,{key:B.id,frame:B,thumbnail:l.thumbnails[B.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[B.id],variantChildren:l.variantChildren[B.id],isLoadingVariants:l.loadingVariants.has(B.id),isExpanded:l.expandedSets.has(B.id),isNew:l.recentlyAdded.has(B.name),onToggleExpand:l.toggleExpanded,onSelect:F,multiSelect:a,selectedFrames:f,variantFilters:l.variantFilters}))))),a&&be.createElement(kk,null,be.createElement(Ck,{disabled:f.size===0,onClick:R},"Link ",f.size," Selected")))):null};ve();pt();var k_=Zt.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4}),C_=Zt.div(({theme:e})=>({width:"90vw",maxWidth:"1100px",height:"75vh",backgroundColor:e.background.content,borderRadius:"12px",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.3)",overflow:"hidden"})),T_=Zt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),I_=Zt.div({display:"flex",alignItems:"center",gap:"20px"}),F_=Zt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),E_=Zt.div({display:"flex",gap:"4px"}),iC=Zt(io)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),A_=Zt(wn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),P_=Zt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),L_=Zt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),M_=Zt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),B_=Zt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),D_=Zt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),R_=Zt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),z_=Zt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),N_=Zt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),O_=Zt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),__=Zt.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 14px",backgroundColor:e.color.defaultText,color:"white",border:"none",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,cursor:"pointer",transition:"opacity 0.15s","&:hover":{opacity:.85},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),sC=Zt.span(({theme:e,type:t})=>({display:"flex",alignItems:"center",gap:"6px","& .dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:t==="mapped"?e.color.positive:t==="unmapped"?e.color.mediumlight:"transparent"}})),aC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Bi("map"),[i,s]=Bi([]),[a,u]=Bi(!0),[c,l]=Bi(null),[d,f]=Bi(!1),[p,g]=Bi(null),S=eC({projectId:n}),{refreshMappings:C}=rt(),{featureFlags:F}=ie(),k=Je.useMemo(()=>S.results?.mappings.map(v=>v.storyId)||[],[S.results]),R=rC(k),z=Co(async()=>{u(!0);try{let v=await fetch("/index.json");if(!v.ok)throw new Error("Failed to fetch index.json");let A=await v.json(),P=A.entries||A.stories||{},D=Object.entries(P).filter(([,w])=>w.type==="story").map(([w,j])=>({id:w,name:j.name||w.split("--").pop()||w,title:j.title||"",importPath:j.importPath,componentTitle:j.title?.split("/").slice(0,-1).join("/")||j.title,figmaMapping:null}));try{let w=q(),j=localStorage.getItem("uicopilot_session_token"),G=await oe(`${w}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${j}`}});if(G.ok){let L=await G.json(),K=new Map((L.mappings||[]).map(ee=>[ee.storyId,ee]));D.forEach(ee=>{let re=K.get(ee.id);re&&re.figmaNodeId&&(ee.figmaMapping={figmaNodeId:re.figmaNodeId,figmaFrameName:re.name||re.figmaFrameName||""})})}}catch(w){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",w)}s(D);let N=D.find(w=>!w.figmaMapping);N?l(N.id):D.length>0&&l(D[0].id)}catch(v){console.error("[StoryMappingAssistant] Error fetching stories:",v)}finally{u(!1)}},[n]);v_(()=>{e&&z()},[e,z]);let _=Co((v,A,P)=>{s(w=>w.map(j=>j.id===v?{...j,figmaMapping:{figmaNodeId:A,figmaFrameName:P}}:j));let D=i.findIndex(w=>w.id===v),N=i.find((w,j)=>j>D&&!w.figmaMapping);N&&l(N.id)},[i]),M=Co(v=>{s(A=>A.map(P=>P.id===v?{...P,figmaMapping:null}:P))},[]),B=Co(v=>{l(v),o("map")},[]),m=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);S.collectAndMap(v)},[i,S]),x=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);f(!1),S.rerun(v)},[i,S]),b=Co(async v=>{await S.applyMappings(v),f(!1),S.reset(),z(),C()},[S,z,C]),E=Co(()=>{f(!1),S.reset()},[S]);Je.useEffect(()=>{S.results&&f(!0)},[S.results]);let h=v=>{v.target===v.currentTarget&&t()};if(!e)return null;let T=i.filter(v=>v.figmaMapping).length,I=i.length;return Je.createElement(Je.Fragment,null,Je.createElement(k_,{onClick:h},Je.createElement(C_,{onClick:v=>v.stopPropagation()},Je.createElement(T_,null,Je.createElement(I_,null,Je.createElement(F_,null,Je.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Je.createElement(E_,null,Je.createElement(iC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Je.createElement(iC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),Je.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},F.enableAutoMap&&!d&&!S.isCollecting&&!S.isMapping&&Je.createElement(__,{onClick:m,disabled:a||i.length===0},Je.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},Je.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),Je.createElement("path",{d:"M2 17l10 5 10-5"}),Je.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),Je.createElement(A_,{onClick:t},"\xD7"))),Je.createElement(P_,null,(S.isCollecting||S.isMapping)&&Je.createElement(B_,null,Je.createElement(D_,null,Je.createElement(N_,null,Je.createElement(O_,null)),Je.createElement(R_,null,"Auto-mapping stories to Figma"),Je.createElement(z_,null,S.progress),Je.createElement(Br,{onClick:S.cancel,variant:"ghost"},"Cancel"))),d&&S.results&&Je.createElement(Zk,{results:S.results,stories:i,onApply:b,onCancel:E,onRerun:x,isApplying:S.isApplying,isRerunning:S.isCollecting||S.isMapping,source:S.source,resolveThumbnail:v=>S.results?.thumbnailUrls?.[v],resolveStoryScreenshot:v=>R.screenshots[v],isCapturingScreenshots:R.isCapturing,onBrowse:v=>g(v)}),!d&&!S.isCollecting&&!S.isMapping&&(r==="map"?Je.createElement(Rk,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:_,projectId:n}):Je.createElement(_k,{stories:i,loading:a,onLink:B,onUnlink:M,projectId:n}))),Je.createElement(L_,null,Je.createElement(M_,null,Je.createElement("span",null,"Total: ",I," stories"),Je.createElement(sC,{type:"mapped"},Je.createElement("span",{className:"dot"}),T," mapped"),Je.createElement(sC,{type:"unmapped"},Je.createElement("span",{className:"dot"}),I-T," unmapped"))))),Je.createElement(Mi,{isOpen:!!p,onClose:()=>g(null),onSelect:()=>g(null),projectId:n,initialSearch:p||void 0}))};import Xr,{useEffect as $_,useCallback as U_}from"react";import{styled as qo,keyframes as lC}from"storybook/theming";var j_=lC({from:{opacity:0},to:{opacity:1}}),H_=lC({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),W_=qo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${j_} 150ms ease-out`}),V_=qo.div(({theme:e})=>({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10001,backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,padding:`${e.layoutMargin*2.4}px`,minWidth:"320px",maxWidth:"440px",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.2)",animation:`${H_} 150ms ease-out`})),G_=qo.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),q_=qo.p(({theme:e})=>({margin:`${e.layoutMargin}px 0 ${e.layoutMargin*2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),Y_=qo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),K_=qo.button(({theme:e})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,cursor:"pointer",backgroundColor:"transparent",color:e.color.defaultText,transition:"background-color 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),X_=qo.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover":{opacity:.9}})),Di=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",onConfirm:s,onCancel:a})=>{let u=U_(c=>{c.key==="Escape"&&a()},[a]);return $_(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),e?Xr.createElement(Xr.Fragment,null,Xr.createElement(W_,{onClick:a}),Xr.createElement(V_,{role:"dialog","aria-modal":"true","aria-label":t},Xr.createElement(G_,null,t),Xr.createElement(q_,null,n),Xr.createElement(Y_,null,Xr.createElement(K_,{onClick:a},o),Xr.createElement(X_,{variant:i,onClick:s},r)))):null};pt();var cC=Yn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",transition:"border-color 0.2s, box-shadow 0.2s","&:hover":{borderColor:e.color.mediumlight}})),J_=Yn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),Z_=Yn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),e$=Yn.div({display:"flex",alignItems:"center",gap:"8px"}),t$=Yn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),n$=Yn.div(({theme:e,percent:t,state:n})=>({width:`${t}%`,height:"100%",borderRadius:"2px",backgroundColor:n==="complete"?e.color.positive:n==="partial"?e.color.warning:e.color.mediumlight,transition:"width 0.3s ease"})),r$=Yn.span(({theme:e,state:t})=>({fontSize:"12px",fontWeight:600,color:t==="complete"?e.color.positive:t==="partial"?e.color.warning:e.color.mediumdark,whiteSpace:"nowrap"})),o$=Yn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),i$=Yn(Kc)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),s$=Yn(Kc)(({theme:e})=>({padding:"4px 10px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626","&:hover":{textDecoration:"none",backgroundColor:"rgba(220, 38, 38, 0.08)"}})),a$=Yn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),l$=Yn.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),c$=Yn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),uC=()=>{let[e,t]=tc(!1),[n,r]=tc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Ze(),{sessionToken:i}=we();Q_(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(_=>({..._,loading:!0}));try{let _=await fetch("/index.json");if(!_.ok)throw new Error("Failed to fetch Storybook index");let M=await _.json(),B=M.entries||M.stories||{},m=Object.keys(B).filter(T=>B[T].type==="story").length,x=Object.keys(B).filter(T=>B[T].type==="story"),b=q(),E=await oe(`${b}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),h=0;if(E.ok){let T=await E.json(),I=T.mappings||T||[];if(Array.isArray(I)){let v=new Set(I.map(A=>A.storyId).filter(Boolean));h=x.filter(A=>v.has(A)).length}else{let v=await oe(`${b}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(v.ok){let A=await v.json();h=Math.min(A.mappedStoriesCount||0,m)}}}r({totalStories:m,mappedStories:h,loading:!1})}catch(_){console.error("[FigmaMappingsSection] Error fetching stats:",_),r(M=>({...M,loading:!1}))}},[a,u]=tc(!1),[c,l]=tc(!1),d=async()=>{!o||!i||l(!0)},f=async()=>{l(!1),u(!0);try{let _=q(),M=await oe(`${_}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!M.ok)throw new Error("Failed to fetch mappings");let m=(await M.json()).mappings||[];await Promise.all(m.map(x=>oe(`${_}/api/mappings?id=${encodeURIComponent(x.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(_){console.error("[FigmaMappingsSection] Unlink all failed:",_)}finally{u(!1)}},p=()=>t(!0),g=()=>{t(!1),o&&i&&s()};if(!o)return kt.createElement(cC,null,kt.createElement(a$,null,"Select a project to link Figma designs"));let{totalStories:S,loading:C}=n,F=Math.min(n.mappedStories,S),k=F===0?"none":F>=S?"complete":"partial",R=S>0?Math.min(100,Math.round(F/S*100)):0,z=k==="none"?"Link designs":"Manage";return kt.createElement(kt.Fragment,null,kt.createElement(cC,null,kt.createElement(J_,null,kt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},kt.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),kt.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),kt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),kt.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),kt.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),kt.createElement(Z_,null,kt.createElement(o$,null,"Figma Mappings"),kt.createElement(e$,null,C?kt.createElement(kt.Fragment,null,kt.createElement(l$,null),kt.createElement(c$,null,"Loading...")):kt.createElement(kt.Fragment,null,kt.createElement(t$,null,kt.createElement(n$,{percent:R,state:k})),kt.createElement(r$,{state:k},`${F}/${S}`)))),F>0&&kt.createElement(s$,{onClick:d,disabled:C||a},a?"Unlinking...":"Unlink All"),kt.createElement(i$,{onClick:p,disabled:C},z)),e&&kt.createElement(aC,{isOpen:e,onClose:g,projectId:o}),kt.createElement(Di,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:f,onCancel:()=>l(!1)}))};import ce,{useState as Zs,useEffect as Um,useCallback as u$}from"react";import{styled as Kn}from"storybook/theming";ve();je();pt();var jm=Kn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),Hm=Kn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),Wm=Kn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Pte=Kn(Er)({padding:"5px 12px",fontSize:"12px"}),Vm=Kn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),nc=Kn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),p$=Kn.span(({theme:e,status:t})=>({display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="cached"?`${e.color.positive}1a`:t==="expired"?`${e.color.warning}1a`:e.background.hoverable,color:t==="cached"?e.color.positive:t==="expired"?e.color.warning:e.color.mediumdark})),d$=Kn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),Gm=Kn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),f$=Kn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),rc=Kn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),oc=Kn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Yo=Kn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),pC=new Set,dC=()=>{let{userRole:e,featureFlags:t}=ie(),[n,r]=Zs(null),[o,i]=Zs(!0),[s,a]=Zs(!1),[u,c]=Zs(!1),[l,d]=Zs(!1),{selectedProjectId:f,projects:p}=Ze(),{sessionToken:g}=we(),S=u$(async()=>{if(!(!f||!g))try{let M=q(),B=await oe(`${M}/api/figma/cache-status?projectId=${f}`,{headers:{Authorization:`Bearer ${g}`}});if(B.ok){let m=await B.json();r(m)}}catch(M){console.error("[FigmaCacheSection] Error:",M)}finally{i(!1)}},[f,g]);Um(()=>{S()},[S]),Um(()=>{if(o||s||!n||n.structureStatus!=="none"||!f||pC.has(f))return;let M=p.find(m=>m.id===f);(M?.figmaFileUrl||M?.figmaFileId)&&(pC.add(f),C())},[o,s,n?.structureStatus,f,p]),Um(()=>{let M=n?.thumbnailProgress?.status,B=n?.enrichmentProgress?.status,m=n?.thumbnailProgress?.cached??0,x=n?.thumbnailProgress?.total??0,b=M==="in-progress"||M==="pending"||x>0&&m<x,E=B==="in-progress"||B==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(b||E||h)||!n||n.structureStatus==="none")return;let I=setInterval(()=>{S()},3e3);return()=>{clearInterval(I)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,S]);let C=async()=>{if(!(!f||!g)){a(!0);try{let M=q();await oe(`${M}/api/figma/frames?projectId=${f}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${g}`}},6e4),await new Promise(B=>setTimeout(B,1e3)),await S(),setTimeout(async()=>{await S()},3e3)}catch(M){console.error("[FigmaCacheSection] Reload error:",M)}finally{a(!1)}}},F=async()=>{if(!(!f||!g)){c(!0);try{let M=q(),B=await oe(`${M}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})});console.log("[FigmaCacheSection] Cache invalidate response:",B.status),await oe(`${M}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(M){console.error("[FigmaCacheSection] Clear cache error:",M)}finally{c(!1)}}},k=async()=>{if(!(!f||!g)){d(!0);try{let M=q();await oe(`${M}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})});let B=setInterval(async()=>{await S()},3e3),m=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(clearInterval(B),clearInterval(m),d(!1),S())},3e3);setTimeout(()=>{clearInterval(B),clearInterval(m),d(!1)},6e5)}catch(M){console.error("[FigmaCacheSection] Enrich error:",M),d(!1)}}};if(!f)return null;if(o)return ce.createElement(jm,null,ce.createElement(Hm,null,ce.createElement(Wm,null,"Figma Cache")),ce.createElement(Vm,null,ce.createElement(nc,null,"Loading cache status\u2026")),ce.createElement(rc,null,ce.createElement(oc,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return ce.createElement(jm,null,ce.createElement(Hm,null,ce.createElement(Wm,null,"Figma Cache"),ce.createElement(Br,{loading:s,onClick:C,loadingText:"Loading..."},"\u21BB Load")),s?ce.createElement(ce.Fragment,null,ce.createElement(rc,null,ce.createElement(oc,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):ce.createElement(Vm,null,ce.createElement(nc,null,"No cache \u2014 click Load to fetch from Figma")));let R=M=>{let B=Date.now()-new Date(M).getTime(),m=Math.floor(B/6e4);if(m<1)return"just now";if(m<60)return`${m}m ago`;let x=Math.floor(m/60);return x<24?`${x}h ago`:`${Math.floor(x/24)}d ago`},z=n.cacheDiff,_=z&&(z.added.length>0||z.removed.length>0||z.renamed.length>0);return ce.createElement(jm,null,ce.createElement(Hm,null,ce.createElement(Wm,null,"Figma Cache"," ",ce.createElement(p$,{status:n.structureStatus},n.structureStatus)),ce.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&ce.createElement(Br,{loading:l,onClick:k,loadingText:"Enriching..."},"Enrich"),ce.createElement(Br,{loading:u,onClick:F,variant:"ghost",loadingText:"Clearing..."},"Clear"),ce.createElement(Br,{loading:s,onClick:C,loadingText:"Reloading..."},"\u21BB Reload"))),s&&ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma...")),ce.createElement(Vm,null,ce.createElement(nc,null,ce.createElement("strong",null,n.componentSetCount)," component sets"),ce.createElement(nc,null,ce.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&ce.createElement(f$,null,"Updated ",R(n.structureCachedAt))),_&&ce.createElement(d$,null,"Since last reload:"," ",z.added.length>0&&ce.createElement(Gm,{type:"added"},"+",z.added.length," added"),z.added.length>0&&z.removed.length>0&&" \xB7 ",z.removed.length>0&&ce.createElement(Gm,{type:"removed"},"\u2212",z.removed.length," removed"),(z.added.length>0||z.removed.length>0)&&z.renamed.length>0&&" \xB7 ",z.renamed.length>0&&ce.createElement(Gm,{type:"renamed"},z.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(rc,null,ce.createElement(oc,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Caching component set thumbnails to CDN...",n.thumbnailProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.thumbnailProgress.currentName)),ce.createElement("span",null,n.thumbnailProgress.cached," / ",n.thumbnailProgress.total))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: ",n.thumbnailProgress.cached," / ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending")&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: not pre-cached")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(rc,null,ce.createElement(oc,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Enriching components with AI...",n.enrichmentProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.enrichmentProgress.currentName)),ce.createElement("span",null,n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&ce.createElement(ce.Fragment,null,ce.createElement(Yo,null,ce.createElement("span",null,"AI enrichment: ",n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="processing"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&ce.createElement("div",{style:{marginTop:"6px"}},ce.createElement(Xl,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import xt,{useState as Ri}from"react";import{styled as Dr}from"storybook/theming";ve();je();pt();var qm=Dr.div({padding:"12px 16px"}),g$=Dr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),fC=Dr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),gC=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:le,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),m$=Dr.div({display:"flex",gap:"8px",alignItems:"center"}),h$=Dr.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none",fontFamily:"monospace","&:focus":{borderColor:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),mC=Dr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),x$=Dr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:le,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),y$=Dr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"6px",backgroundColor:"#16a34a10",border:"1px solid #16a34a30",fontSize:"12px",color:e.color.defaultText})),b$=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),hC=({onConnected:e})=>{let{sessionToken:t}=we(),[n,r]=Ri(!1),[o,i]=Ri(""),[s,a]=Ri(!1),[u,c]=Ri(null),[l,d]=Ri(null),[f,p]=Ri(!1),g=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let S=q(),C=await oe(`${S}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),F=await C.json();if(!C.ok){c({type:"error",message:F.error||"Failed to save token"});return}d(F.figmaUser?.handle||F.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${F.figmaUser?.handle||"Figma user"}`}),i(""),e?.()}catch{c({type:"error",message:"Failed to connect. Check your token and try again."})}finally{a(!1)}}};return l?xt.createElement(qm,null,xt.createElement(fC,null,"Figma Personal Access Token"),xt.createElement(y$,null,xt.createElement("span",null,"\u2713 Connected as ",xt.createElement("strong",null,l)),xt.createElement(b$,{onClick:()=>{d(null),c(null)}},"Change token"))):n?xt.createElement(qm,null,xt.createElement(g$,null,xt.createElement(fC,null,"Figma Personal Access Token"),xt.createElement(gC,{onClick:()=>p(!f)},f?"Hide instructions":"How to generate")),f&&xt.createElement(x$,null,xt.createElement("ol",null,xt.createElement("li",null,"Open ",xt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),xt.createElement("li",null,"Click the ",xt.createElement("strong",null,"Security")," tab"),xt.createElement("li",null,"Scroll to ",xt.createElement("strong",null,"Personal access tokens")),xt.createElement("li",null,"Click ",xt.createElement("strong",null,"Generate new token")),xt.createElement("li",null,"Enable ",xt.createElement("strong",null,"File content: Read only")," under Scopes"),xt.createElement("li",null,"Copy the token and paste it below"))),xt.createElement(m$,null,xt.createElement(h$,{type:"password",value:o,onChange:S=>i(S.target.value),placeholder:"figd_...",onKeyDown:S=>{S.key==="Enter"&&o.trim()&&g()}}),xt.createElement(qt,{onClick:g,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&xt.createElement(mC,{variant:u.type},u.message),xt.createElement(mC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):xt.createElement(qm,null,xt.createElement(gC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};ve();je();pt();var w$=St.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},St.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),St.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),St.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),St.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),St.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"})),Km=vr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),v$=vr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),k$=vr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),C$=vr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),Xm=vr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),T$=vr.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",margin:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"})),I$=vr.div({display:"flex",alignItems:"center",gap:"8px"}),F$=vr(er)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),E$=vr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Xte=vr.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:"#A259FF",color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:"#8a3de8"}}),A$=vr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.mediumdark,"&::before, &::after":{content:'""',flex:1,height:"1px",backgroundColor:e.appBorderColor}})),yC=({hideHeader:e=!1})=>{let{sessionToken:t}=we(),[n,r]=Ym(!1),[o,i]=Ym(null),[s,a]=Ym(!1);S$(()=>{if(!t)return;let d=q();oe(`${d}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(f=>f.json()).then(f=>i(!!f.connected)).catch(()=>i(!1))},[t]);let u=xC(()=>{let f=`${q()}/addon/auth`;window.open(f,"figma-oauth","width=600,height=700,left=200,top=100")},[]),c=xC(async()=>{try{r(!0);let d=q(),f=await oe(`${d}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});(f.ok||f.status===404)&&i(!1)}catch{}finally{r(!1)}},[t]),l=e?null:St.createElement(v$,null,St.createElement(k$,null,w$),St.createElement(C$,null,"Figma Integration"));return o===null?St.createElement(Km,null,l,St.createElement(Xm,null,St.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?St.createElement(Km,null,l,St.createElement(Xm,null,St.createElement(E$,null,St.createElement(qt,{onClick:u,style:{width:"100%"}},"Connect with Figma"),St.createElement(A$,null,"or"),St.createElement(hC,{onConnected:()=>i(!0)})))):St.createElement(Km,null,l,St.createElement(T$,null,St.createElement(I$,null,St.createElement("span",{style:{fontSize:"18px"}},"\u2713"),St.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),St.createElement(F$,{onClick:()=>a(!0),disabled:n},n?"Disconnecting...":"Disconnect")),St.createElement(Di,{isOpen:s,title:"Disconnect Figma",message:"Your mappings, cache, and review history will be preserved. You will need to re-authenticate to make new Figma API calls.",confirmLabel:"Disconnect",variant:"danger",onConfirm:()=>{a(!1),c()},onCancel:()=>a(!1)}),St.createElement(Xm,null,St.createElement($v,null),St.createElement(uC,null),St.createElement(dC,null)))};ve();var P$=cr.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"32px"}),L$=cr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"14px",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.22)",width:"520px",maxWidth:"94%",maxHeight:"calc(100vh - 64px)",overflow:"auto",position:"relative"})),M$=cr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",position:"sticky",top:0,backgroundColor:e.background.content,borderRadius:"14px 14px 0 0",zIndex:1})),B$=cr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),D$=cr(wn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),R$=cr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),bC=cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),SC=cr.div({display:"flex",alignItems:"center",gap:"10px"}),wC=cr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),z$=cr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:le,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),N$=cr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),vC=cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"12px",fontSize:"12px","& > div, & > section":{padding:0},'[class*="AuthPanelContainer"], [class*="SectionContainer"]':{padding:0},"h3, h4":{fontSize:"12px",margin:"0 0 6px 0"},label:{fontSize:"12px"},"input, select":{fontSize:"12px",padding:"6px 10px",height:"auto"},button:{fontSize:"11px"},p:{fontSize:"11px",margin:"2px 0"}})),kC=({onClose:e})=>{let{isConnected:t}=we(),{selectedProjectId:n}=Ze();return Et.createElement(P$,{onClick:e},Et.createElement(L$,{onClick:r=>r.stopPropagation()},Et.createElement(M$,null,Et.createElement(B$,null,"Settings"),Et.createElement(D$,{onClick:e,title:"Close settings"},"\xD7")),Et.createElement(R$,null,Et.createElement(bC,null,Et.createElement(SC,null,Et.createElement(z$,null,"UI"),Et.createElement(wC,null,"UI Copilot")),Et.createElement(vC,null,Et.createElement(Rv,null),t&&Et.createElement(Nv,null))),t&&n&&Et.createElement(bC,null,Et.createElement(SC,null,Et.createElement(N$,null,Et.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Et.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),Et.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),Et.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Et.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),Et.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),Et.createElement(wC,null,"Figma Integration")),Et.createElement(vC,null,Et.createElement(yC,{hideHeader:!0}))))))};import ft,{useEffect as BC,useMemo as d4,useState as f4,useRef as g4}from"react";import{styled as Cn,keyframes as m4}from"storybook/theming";ve();ve();import Xt,{useState as O$}from"react";import{styled as On}from"storybook/theming";var Qr=[{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Latest Claude model, best balance of speed and quality"},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",provider:"anthropic",description:"Previous generation Sonnet"},{id:"claude-3-5-sonnet-20241022",name:"Claude 3.5 Sonnet",provider:"anthropic",description:"Best balance of speed and quality"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",provider:"anthropic",description:"Fastest, most affordable"},{id:"claude-3-opus-20240229",name:"Claude 3 Opus",provider:"anthropic",description:"Most capable Claude 3 model"},{id:"gpt-5.2",name:"GPT-5.2 Thinking",provider:"openai",description:"47% cheaper, reasoning"},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Instant",provider:"openai",description:"86% cheaper (default)"},{id:"gpt-4o",name:"GPT-4o",provider:"openai",description:"GPT-4 multimodal flagship"},{id:"gpt-4o-mini",name:"GPT-4o Mini",provider:"openai",description:"GPT-4 affordable model"},{id:"o1-preview",name:"o1 Preview",provider:"openai",description:"Reasoning model (slower, advanced)"},{id:"o1-mini",name:"o1 Mini",provider:"openai",description:"Faster reasoning model"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"Fast & cheap, great vision"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",provider:"google",description:"Best Gemini quality"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"google",description:"Previous gen, very fast"}];var _$=On.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),$$=On.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),U$=On.div(({theme:e,disabled:t,provider:n})=>{let r={anthropic:{background:"#D4A574",text:"#ffffff"},openai:{background:e.color.positive||"#10b981",text:"#ffffff"},google:{background:"#4285F4",text:"#ffffff"}},o=n?r[n]:r.anthropic;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:o.background,color:o.text,fontSize:"11px",fontWeight:500,borderRadius:"12px",opacity:t?.6:1,cursor:t?"not-allowed":"default",transition:"opacity 0.15s"}}),j$=On.button(({theme:e,disabled:t})=>({background:"none",border:"none",color:e.color.inverseText,fontSize:"12px",cursor:t?"not-allowed":"pointer",padding:"0 2px",lineHeight:1,opacity:t?.5:.8,transition:"opacity 0.15s","&:hover":{opacity:t?.5:1}})),H$=On.div({position:"relative",display:"inline-block"}),W$=On.button(({disabled:e,isOpen:t,theme:n})=>({padding:`${n.layoutMargin*.8}px 32px ${n.layoutMargin*.8}px ${n.layoutMargin}px`,fontSize:n.typography.size.s2,fontFamily:n.typography.fonts.base,fontWeight:500,color:n.color.defaultText,backgroundColor:n.input.background,border:`1px solid ${t?n.color.secondary:n.appBorderColor}`,borderRadius:n.appBorderRadius,cursor:e?"not-allowed":"pointer",opacity:e?.6:1,whiteSpace:"nowrap",display:"flex",gap:`${n.layoutMargin*.8}px`,alignItems:"center",justifyContent:"space-between",minWidth:"200px",transition:"border-color 0.15s, box-shadow 0.15s",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px","&:hover":{borderColor:e?n.appBorderColor:n.color.mediumdark}})),V$=On.div(({theme:e})=>({position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:e.base==="dark"?"0 4px 12px rgba(0, 0, 0, 0.3)":"0 4px 12px rgba(0, 0, 0, 0.1)",zIndex:1e3,maxHeight:"280px",overflowY:"auto"})),Qm=On.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),Jm=On.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),G$=On.div(({theme:e,disabled:t})=>({padding:"8px 12px",fontSize:"12px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,display:"flex",alignItems:"center",gap:"8px",transition:"background-color 0.15s",color:e.color.defaultText,"&:hover":{backgroundColor:t?"transparent":e.background.hoverable}})),q$=On.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),Y$=On.div({flex:1,minWidth:0}),K$=On.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),X$=On.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),Q$=5,CC=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ie(),[r,o]=O$(!1),i=Qr.filter(p=>p.provider==="anthropic"&&!e.includes(p.id)),s=Qr.filter(p=>p.provider==="openai"&&!e.includes(p.id)),a=Qr.filter(p=>p.provider==="google"&&!e.includes(p.id)),u=Qr.filter(p=>e.includes(p.id)),c=e.length<Q$,l=(p,g)=>{g.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let g=e.includes(p);g&&e.length===1||!g&&!c||n||(t(p),o(!1))},f=p=>{let g=e.includes(p.id),S=g&&e.length===1,C=n||S||!g&&!c;return Xt.createElement(G$,{key:p.id,disabled:C,onClick:()=>d(p.id)},Xt.createElement(q$,{type:"checkbox",checked:g,disabled:C,onChange:()=>{},onClick:F=>F.stopPropagation()}),Xt.createElement(Y$,null,Xt.createElement(K$,null,p.name),p.description&&Xt.createElement(X$,null,p.description)))};return Xt.createElement(_$,null,Xt.createElement(H$,null,Xt.createElement(W$,{disabled:n,isOpen:r,onClick:()=>o(!r)},Xt.createElement("span",null,"Select model"),Xt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Xt.createElement(V$,null,Xt.createElement(Qm,null,Xt.createElement(Jm,null,"Anthropic"),i.map(f)),Xt.createElement(Qm,null,Xt.createElement(Jm,null,"OpenAI"),s.map(f)),Xt.createElement(Qm,null,Xt.createElement(Jm,null,"Google"),a.map(f)))),Xt.createElement($$,null,u.map(p=>Xt.createElement(U$,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Xt.createElement(j$,{disabled:n,onClick:g=>l(p.id,g),title:"Remove model"},"\xD7")))))};import Ce,{useState as J$,useEffect as Z$}from"react";import{styled as jt,keyframes as Ni}from"storybook/theming";ve();var e4=Ni`
44
+ `,zO=Hk.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${RO} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),NO=Hk.button(({theme:e,variant:t="default",disabled:n})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"5px 12px",fontSize:"12px",fontWeight:600,border:`1px solid ${e.color.medium}`,borderRadius:"5px",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,transition:"all 0.2s",whiteSpace:"nowrap",...t==="default"&&{backgroundColor:e.background.content,color:e.color.defaultText,"&:hover":n?{}:{borderColor:e.color.secondary,color:e.color.secondary,backgroundColor:"rgba(30, 167, 253, 0.05)"}},...t==="ghost"&&{backgroundColor:"transparent",border:"none",color:e.color.mediumdark,padding:"5px 8px","&:hover":n?{}:{color:e.color.defaultText,backgroundColor:e.background.hoverable}}})),Br=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>jk.createElement(NO,{variant:r,disabled:t||e,onClick:n},e&&jk.createElement(zO,null),e&&i?i:o);je();import on from"react";import{styled as Js}from"storybook/theming";var Wk=Js.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",backgroundColor:e.background.hoverable,borderRadius:"6px",fontFamily:"Inter, sans-serif",fontSize:"11px",color:e.color.mediumdark,gap:"16px"})),OO=Js.div({display:"flex",alignItems:"center",gap:"12px"}),Kl=Js.span({whiteSpace:"nowrap"}),Vk=Js.div({display:"flex",alignItems:"center",gap:"8px"}),Xl=Js.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Ql=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*lw;return r?on.createElement(Wk,null,on.createElement(Kl,null,o.toLocaleString()," tokens"),on.createElement(Vk,null,on.createElement(Xl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Xl,null,"\u20AA",i.toFixed(2)))):on.createElement(Wk,null,on.createElement(OO,null,on.createElement(Kl,null,e.toLocaleString()," input"),on.createElement("span",null,"+"),on.createElement(Kl,null,t.toLocaleString()," output"),on.createElement("span",null,"="),on.createElement(Kl,null,on.createElement("strong",null,o.toLocaleString())," tokens")),on.createElement(Vk,null,on.createElement(Xl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Xl,null,"\u20AA",i.toFixed(2))))};import Nn from"react";import{styled as wo}from"storybook/theming";function jm(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var _O=wo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),Gk=wo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),$O=wo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),UO=wo.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.2}px`,padding:`1px ${e.layoutMargin*.5}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.mono})),jO=wo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),HO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),WO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),VO=wo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),qk=({data:e,color:t,compact:n})=>n?Nn.createElement(Gk,{color:t},e.summary):Nn.createElement(_O,null,Nn.createElement(Gk,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Nn.createElement($O,null,e.mappings.map((r,o)=>Nn.createElement(Nn.Fragment,{key:o},Nn.createElement(UO,null,r.from," ",Nn.createElement(jO,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Nn.createElement(HO,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Nn.createElement(Nn.Fragment,null,e.defaults.map((r,o)=>Nn.createElement(WO,{key:o},Nn.createElement(VO,null,r.choice),Nn.createElement("span",null,"\u2014 ",r.why)))));var GO=dt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),qO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),YO=dt.div({display:"flex",flexDirection:"column",gap:"4px"}),KO=dt.div({display:"flex",alignItems:"center",gap:"10px"}),XO=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,letterSpacing:"-0.3px"})),Kk=dt.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="success"?`${e.color.positive}1a`:t==="danger"?`${e.color.negative}1a`:`${e.color.secondary}1a`,color:t==="success"?e.color.positive:t==="danger"?e.color.negative:e.color.secondary})),QO=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),JO=dt.div({display:"flex",gap:"8px"}),ZO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),e_=dt(so)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),t_=dt.div({display:"flex",gap:"4px"}),Jl=dt.button(({theme:e,active:t})=>({padding:"6px 12px",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,border:t?"none":`1px solid ${e.appBorderColor}`,backgroundColor:t?e.color.defaultText:e.background.content,color:t?e.color.inverseText:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:t?e.color.defaultText:e.background.hoverable}})),n_=dt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),r_=dt.div(({theme:e,dimmed:t})=>({display:"flex",alignItems:"center",padding:"12px 16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"10px",gap:"12px",backgroundColor:e.background.content,opacity:t?.6:1,transition:"opacity 0.15s",position:"relative",zIndex:0,"&:hover":{zIndex:10}})),o_=dt.div(({theme:e,checked:t})=>({width:"18px",height:"18px",borderRadius:"4px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"all 0.15s",...t?{backgroundColor:e.color.defaultText,color:e.color.inverseText,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold}:{border:`2px solid ${e.color.mediumlight}`}})),i_=dt.div(({theme:e,bgColor:t})=>({width:"48px",height:"40px",borderRadius:"6px",backgroundColor:t||e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden"})),Zl=dt.div(({theme:e})=>({width:"120px",height:"80px",borderRadius:"8px",backgroundColor:e.background.hoverable,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden",border:`1px solid ${e.appBorderColor}`})),s_=dt.img({width:"100%",height:"100%",objectFit:"contain"}),eC=dt.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"uicopilot-spin 0.8s linear infinite","@keyframes uicopilot-spin":{to:{transform:"rotate(360deg)"}}})),Xk=dt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),Qk=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),Hm=dt.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),Cee=dt.span(({theme:e,color:t})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:t||e.color.mediumdark,lineHeight:1.5,whiteSpace:"pre-line"})),a_=dt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),l_=dt.span(({theme:e,level:t})=>({padding:"4px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,flexShrink:0,backgroundColor:t==="high"?`${e.color.positive}1a`:t==="medium"?`${e.color.warning}1a`:`${e.color.negative}1a`,color:t==="high"?e.color.positive:t==="medium"?e.color.warning:e.color.negative})),c_=dt.button(({theme:e})=>({padding:"4px 8px",borderRadius:e.appBorderRadius,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,border:`1px solid ${e.appBorderColor}`,backgroundColor:"transparent",color:e.color.mediumdark,cursor:"pointer",flexShrink:0,transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText}})),u_=dt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),p_=dt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),d_=dt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),f_=dt.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="cache"?`${e.color.warning}1a`:`${e.color.positive}1a`,color:t==="cache"?e.color.warning:e.color.positive})),g_=dt.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"5px",padding:"5px 12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:"transparent",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Tee=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 24px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Jk=({src:e,alt:t})=>{let[n,r]=ec(!1);return ke.createElement(ke.Fragment,null,!n&&ke.createElement(eC,null),ke.createElement(s_,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function Zk(e){return e>=90?"high":e>=70?"medium":"low"}function m_(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var tC=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:s,source:a,resolveThumbnail:u,resolveStoryScreenshot:c,isCapturingScreenshots:l,onBrowse:d})=>{let[f,p]=ec(()=>{let b=new Set;for(let E of e.mappings)E.confidence>=90&&b.add(E.storyId);return b}),[g,S]=ec(""),[C,F]=ec("all"),k=Yk(()=>{let b=new Map;for(let E of t)b.set(E.id,{name:E.name,title:E.title});return b},[t]),R=Yk(()=>{let b=e.mappings;if(C!=="all"&&(b=b.filter(E=>Zk(E.confidence)===C)),g.trim()){let E=g.toLowerCase();b=b.filter(h=>{let T=k.get(h.storyId);return T?.name.toLowerCase().includes(E)||T?.title.toLowerCase().includes(E)||h.componentSetName.toLowerCase().includes(E)||h.figmaFrameName.toLowerCase().includes(E)})}return b},[e.mappings,C,g,k]),z=b=>{p(E=>{let h=new Set(E);return h.has(b)?h.delete(b):h.add(b),h})},_=()=>{let b=e.mappings.filter(E=>f.has(E.storyId));n(b)},M=e.mappings.filter(b=>b.confidence>=90).length,B=e.mappings.filter(b=>b.confidence>=70&&b.confidence<90).length,m=e.mappings.filter(b=>b.confidence<70).length,x=e.usage;return ke.createElement(GO,null,ke.createElement(qO,null,ke.createElement(YO,null,ke.createElement(KO,null,ke.createElement(XO,null,"Auto-Map Results"),ke.createElement(Kk,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&ke.createElement(Kk,{variant:"danger"},e.unmatched.length," unmatched"),a&&ke.createElement(f_,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),ke.createElement(QO,null,"Review matches below. Uncheck any incorrect mappings before applying.")),ke.createElement(JO,null,a==="cache"&&o&&ke.createElement(g_,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),ke.createElement(Br,{onClick:r,variant:"ghost"},"Cancel"),ke.createElement(Br,{loading:i,onClick:_,loadingText:"Applying..."},"Apply ",f.size," Selected"))),ke.createElement(ZO,null,ke.createElement(e_,{type:"text",placeholder:"Filter stories...",value:g,onChange:b=>S(b.target.value)}),ke.createElement(t_,null,ke.createElement(Jl,{active:C==="all",onClick:()=>F("all")},"All ",e.mappings.length),M>0&&ke.createElement(Jl,{active:C==="high",onClick:()=>F("high")},"\u226590% (",M,")"),B>0&&ke.createElement(Jl,{active:C==="medium",onClick:()=>F("medium")},"70-89% (",B,")"),m>0&&ke.createElement(Jl,{active:C==="low",onClick:()=>F("low")},"<70% (",m,")"))),ke.createElement(n_,null,R.map(b=>{let E=k.get(b.storyId),h=Zk(b.confidence),T=f.has(b.storyId),I=h==="low";return ke.createElement(r_,{key:b.storyId,dimmed:I&&!T},ke.createElement(o_,{checked:T,onClick:()=>z(b.storyId)},T?"\u2713":""),(()=>{let v=c?.(b.storyId);return v?ke.createElement(Zl,null,ke.createElement(Jk,{src:v,alt:E?.name||b.storyId})):l?ke.createElement(Zl,null,ke.createElement(eC,null)):ke.createElement(i_,{bgColor:I?"#f1f5f9":"#eff6ff"},ke.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:I?"#94a3b8":"#3b82f6"}},(E?.name||"?").substring(0,4)))})(),ke.createElement(Xk,null,ke.createElement(Qk,null,E?.name||b.storyId),ke.createElement(Hm,null,E?.title||"")),ke.createElement(a_,null,"\u2192"),(()=>{let v=u?.(b.figmaNodeId),A=jm(b.reason),P=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return v?ke.createElement(Zl,{title:P},ke.createElement(Jk,{src:v,alt:b.figmaFrameName})):ke.createElement(Zl,{title:P},ke.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),ke.createElement(Xk,null,ke.createElement(Qk,null,b.componentSetName),ke.createElement(Hm,null,b.figmaFrameName),ke.createElement(qk,{data:jm(b.reason),color:m_(h)})),ke.createElement(l_,{level:h},b.confidence,"%"),d&&ke.createElement(c_,{onClick:()=>d(b.componentSetName)},"Browse"))}),e.unmatched.length>0&&ke.createElement(u_,null,ke.createElement(Hm,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),ke.createElement(p_,null,e.unmatched.map(b=>{let E=k.get(b);return ke.createElement(d_,{key:b},ke.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),E?`${E.name} (${E.title})`:b)})))),x&&a!=="cache"&&ke.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},ke.createElement(Ql,{inputTokens:x.inputTokens||0,outputTokens:x.outputTokens||0,costUsd:x.costUsd||0})))};je();De();import{useState as vo,useCallback as ko,useRef as h_}from"react";import{useStorybookApi as x_}from"storybook/manager-api";function nC({projectId:e}){let t=x_(),n=h_(null),[r,o]=vo(!1),[i,s]=vo(!1),[a,u]=vo(!1),[c,l]=vo(null),[d,f]=vo(null),[p,g]=vo(null),[S,C]=vo(""),[F,k]=vo(null),R=ko(async()=>{let E=await fetch("/index.json");if(!E.ok)throw new Error("Failed to fetch Storybook index");let h=await E.json(),T=h.entries||h.stories||{},I=Object.keys(T).filter(P=>T[P].type==="story");y.debug(`[useAutoMap] Found ${I.length} stories in index.json`);let v=[];for(let P of I){let D=T[P],N=t.getData(P),w={...N?.initialArgs||{}},j=N?.argTypes||{};for(let[G,L]of Object.entries(j))if(!(G in w)){let K=L;if(K.defaultValue!==void 0)w[G]=K.defaultValue;else if(K.table?.defaultValue?.summary!==void 0){let ee=K.table.defaultValue.summary;ee==="false"?w[G]=!1:ee==="true"?w[G]=!0:w[G]=ee}}v.push({id:P,name:D.name||P.split("--").pop()||P,title:D.title||"",initialArgs:w,argTypes:j})}let A=v.filter(P=>Object.keys(P.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${v.length} stories, ${A.length} with args`),v},[t]),z=ko(async()=>{if(!e)return!1;try{let E=q(),h=localStorage.getItem("uicopilot_session_token");if(!h)return!1;let T=await fetch(`${E}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${h}`}});if(!T.ok)return!1;let I=await T.json();return I.hasSuggestions&&I.mappings?.length>0?(f(I),k("cache"),C(`Loaded ${I.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${I.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),_=ko(async E=>{o(!0),C("Collecting story information...");let h;try{if(h=await R(),E?.length&&(h=h.filter(I=>!E.includes(I.id)),y.debug(`[useAutoMap] After excluding mapped: ${h.length} stories`)),h.length===0){l("No unmapped stories found"),o(!1);return}g(h)}catch(I){l(I instanceof Error?I.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),C(`Analyzing ${h.length} stories against Figma components...`);let T=new AbortController;n.current=T;try{let I=q(),v=localStorage.getItem("uicopilot_session_token");if(!v)throw new Error("Not authenticated");let A=await fetch(`${I}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:e,stories:h.map(D=>({id:D.id,name:D.name,title:D.title,initialArgs:D.initialArgs,argTypes:D.argTypes}))}),signal:T.signal});if(!A.ok){let D=await A.json();throw new Error(D.error||"Auto-map failed")}let P=await A.json();f(P),k("llm"),C(`Found ${P.stats.matched} matches (${P.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${P.stats.matched}/${P.stats.total} matched, ${P.unmatched.length} unmatched`)}catch(I){if(I instanceof DOMException&&I.name==="AbortError"){C("Cancelled");return}l(I instanceof Error?I.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,R]),M=ko(async E=>{if(!e)return;if(l(null),f(null),k(null),o(!0),C("Checking for existing suggestions..."),await z()){o(!1);return}await _(E)},[e,z,_]),B=ko(async E=>{e&&(l(null),f(null),k(null),await _(E))},[e,_]),m=ko(async E=>{if(!(!e||E.length===0)){u(!0),C(`Applying ${E.length} mappings...`);try{let h=q(),T=localStorage.getItem("uicopilot_session_token");if(!T)throw new Error("Not authenticated");let I=0;for(let v of E)try{(await fetch(`${h}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:e,storyId:v.storyId,figmaNodeId:v.figmaNodeId,name:v.figmaFrameName||v.componentSetName})})).ok?I++:y.warn(`[useAutoMap] Failed to apply mapping for ${v.storyId}`)}catch(A){y.error(`[useAutoMap] Error applying mapping for ${v.storyId}:`,A)}C(`Applied ${I}/${E.length} mappings`),y.debug(`[useAutoMap] Applied ${I}/${E.length} mappings`)}catch(h){l(h instanceof Error?h.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),x=ko(()=>{n.current?.abort()},[]),b=ko(()=>{f(null),g(null),l(null),C(""),k(null)},[]);return{collectAndMap:M,rerun:B,loadExisting:z,applyMappings:m,cancel:x,reset:b,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:S,source:F}}De();import{useState as Wm,useEffect as y_,useRef as rC}from"react";var oC=2;async function b_(e,t){try{let n=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`,{signal:t});return n.ok&&(await n.json()).screenshot||null}catch{return null}}function iC(e){let[t,n]=Wm({}),[r,o]=Wm(0),[i,s]=Wm(!1),a=rC(null),u=rC(""),c=e.join(",");return y_(()=>{if(!e.length||c===u.current)return;u.current=c,n({}),o(0),s(!0);let l=new AbortController;a.current=l;let d=0;return(async()=>{for(let p=0;p<e.length&&!l.signal.aborted;p+=oC){let g=e.slice(p,p+oC),S=await Promise.all(g.map(F=>b_(F,l.signal).then(k=>({id:F,img:k}))));if(l.signal.aborted)break;let C={};for(let{id:F,img:k}of S)d++,k&&(C[F]=k);Object.keys(C).length>0&&n(F=>({...F,...C})),o(d)}s(!1),y.debug(`[useStoryScreenshots] Captured ${d}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import be,{useState as sC,useEffect as tc,useMemo as S_}from"react";De();var Mi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=Gs({projectId:r||"",enabled:e&&!!r}),d=be.useRef(!1);tc(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[f,p]=sC(new Set),[g,S]=sC(i||o[0]?.id||"");tc(()=>{i&&S(i)},[i]),tc(()=>{l.expandedSets.forEach(B=>{let m=l.variantChildren[B];if(!m||m.length===0)return;let x=m;l.variantFilters.some(E=>E.value)&&(x=m.filter(E=>E.variantProperties?l.variantFilters.every(h=>h.value?E.variantProperties?.[h.property]===h.value:!0):!1));let b=x.slice(0,20).map(E=>E.id);b.length>0&&l.fetchVariantThumbnails(B,b)})},[l.expandedSets,l.variantChildren,l.variantFilters]),tc(()=>{p(new Set)},[g]);let C=S_(()=>{let B=[];return l.filteredFrames.forEach(m=>{if(m.type==="COMPONENT_SET"&&m.children){let x=l.variantFilters.some(b=>b.value)?m.children.filter(b=>b.variantProperties?l.variantFilters.every(E=>E.value?b.variantProperties?.[E.property]===E.value:!0):!1):m.children;B.push(...x)}else B.push(m)}),B},[l.filteredFrames,l.variantFilters]),F=B=>{if(a)p(m=>{let x=new Set(m);return x.has(B.id)?x.delete(B.id):x.add(B.id),x});else{let m=l.resolveThumbnail(B.id);try{n({...B,thumbnail:m})}catch(x){y.error("[ComponentBrowserModal] onSelect threw error:",x)}t()}},k=()=>{let B=C.map(x=>x.id),m=B.every(x=>f.has(x));p(m?new Set:new Set(B))},R=()=>{if(u&&f.size>0){let B=C.filter(m=>f.has(m.id)).map(m=>({...m,thumbnail:l.resolveThumbnail(m.id)}));u(B),p(new Set)}},z=B=>{S(B),s?.(B)},_=B=>{B.target===B.currentTarget&&t()},M=o.find(B=>B.id===g);return e?be.createElement(Hv,{onClick:_},be.createElement(Wv,null,be.createElement(Vv,null,be.createElement(Gv,null,"Link Figma Frames"),be.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},be.createElement("button",{onClick:()=>l.refresh(),disabled:l.isLoading,style:{padding:"4px 8px",fontSize:"12px",cursor:l.isLoading?"not-allowed":"pointer",background:"transparent",border:"1px solid #ccc",borderRadius:"4px"},title:"Refresh from Figma"},"Refresh"),be.createElement(qv,{onClick:t},"\xD7"))),be.createElement(Yv,null,l.error&&be.createElement(tk,null,l.error),!l.error&&be.createElement(be.Fragment,null,o.length>0&&be.createElement(dk,null,be.createElement(fk,null,"Story:"),be.createElement(gk,{value:g,onChange:B=>z(B.target.value)},o.map(B=>be.createElement("option",{key:B.id,value:B.id},B.name,B.mappingsCount?` (${B.mappingsCount} linked)`:""))),M?.mappingsCount?be.createElement(mk,{hasMapping:!0},M.mappingsCount," frames linked"):null),be.createElement(Zv,null,be.createElement(jl,null,be.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:B=>l.setShowComponentSets(B.target.checked)}),"Component Sets"),be.createElement(jl,null,be.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:B=>l.setShowFrames(B.target.checked)}),"Frames"),be.createElement(jl,null,be.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:B=>l.setShowComponents(B.target.checked)}),"Components"),l.availablePages.length>1&&be.createElement(Pi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:B=>l.setFigmaPage(B.target.value),style:{marginLeft:"auto"}},be.createElement("option",{value:""},"All pages"),l.availablePages.map(B=>be.createElement("option",{key:B,value:B},B)))),l.filterSuggestion&&be.createElement(hk,null,be.createElement(xk,null,"AI suggests:"),be.createElement(yk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([B,m])=>`${B}=${m}`).join(", ")),be.createElement(bk,{onClick:l.applySuggestedFilters},"Apply"),be.createElement(Sk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&be.createElement(wk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&be.createElement(Wl,null,be.createElement(Xs,null,"Filters:"),l.availableFilters.map(({property:B,values:m})=>{let x=l.variantFilters.find(b=>b.property===B);return be.createElement(Pi,{key:B,isActive:!!x?.value,value:x?.value||"",onChange:b=>l.handleFilterChange(B,b.target.value)},be.createElement("option",{value:""},B),m.map(b=>be.createElement("option",{key:b,value:b},B,"=",b)))}),l.variantFilters.some(B=>B.value)&&be.createElement(Vl,{onClick:l.clearFilters},"Clear All")),be.createElement(Kv,{type:"text",placeholder:"Search frames...",value:l.search,onChange:B=>l.setSearch(B.target.value),autoFocus:!0}),a&&C.length>0&&be.createElement(vk,null,be.createElement(kk,{onClick:k},f.size===C.length?"Deselect All":"Select All Visible"),be.createElement(Ck,null,f.size>0?`${f.size} selected of `:"Showing ",C.length," frames")),l.isLoading&&be.createElement(Cm,null,Array.from({length:6}).map((B,m)=>be.createElement(pk,{key:m},be.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},be.createElement(Hl,{width:"100%",height:"100%"})),be.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},be.createElement(Hl,{width:"80%",height:"16px"}),be.createElement(Hl,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&be.createElement(ek,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&be.createElement(Cm,null,l.filteredFrames.map(B=>be.createElement(Qs,{key:B.id,frame:B,thumbnail:l.thumbnails[B.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[B.id],variantChildren:l.variantChildren[B.id],isLoadingVariants:l.loadingVariants.has(B.id),isExpanded:l.expandedSets.has(B.id),isNew:l.recentlyAdded.has(B.name),onToggleExpand:l.toggleExpanded,onSelect:F,multiSelect:a,selectedFrames:f,variantFilters:l.variantFilters}))))),a&&be.createElement(Tk,null,be.createElement(Ik,{disabled:f.size===0,onClick:R},"Link ",f.size," Selected")))):null};ve();pt();var v_=Jt.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4}),k_=Jt.div(({theme:e})=>({width:"90vw",maxWidth:"1100px",height:"75vh",backgroundColor:e.background.content,borderRadius:"12px",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.3)",overflow:"hidden"})),C_=Jt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),T_=Jt.div({display:"flex",alignItems:"center",gap:"20px"}),I_=Jt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),F_=Jt.div({display:"flex",gap:"4px"}),aC=Jt(io)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),E_=Jt(wn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),A_=Jt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),P_=Jt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),L_=Jt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),M_=Jt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),B_=Jt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),D_=Jt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),R_=Jt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),z_=Jt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),N_=Jt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),O_=Jt.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 14px",backgroundColor:e.color.defaultText,color:"white",border:"none",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,cursor:"pointer",transition:"opacity 0.15s","&:hover":{opacity:.85},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),lC=Jt.span(({theme:e,type:t})=>({display:"flex",alignItems:"center",gap:"6px","& .dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:t==="mapped"?e.color.positive:t==="unmapped"?e.color.mediumlight:"transparent"}})),cC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Bi("map"),[i,s]=Bi([]),[a,u]=Bi(!0),[c,l]=Bi(null),[d,f]=Bi(!1),[p,g]=Bi(null),S=nC({projectId:n}),{refreshMappings:C}=rt(),{featureFlags:F}=ie(),k=Je.useMemo(()=>S.results?.mappings.map(v=>v.storyId)||[],[S.results]),R=iC(k),z=Co(async()=>{u(!0);try{let v=await fetch("/index.json");if(!v.ok)throw new Error("Failed to fetch index.json");let A=await v.json(),P=A.entries||A.stories||{},D=Object.entries(P).filter(([,w])=>w.type==="story").map(([w,j])=>({id:w,name:j.name||w.split("--").pop()||w,title:j.title||"",importPath:j.importPath,componentTitle:j.title?.split("/").slice(0,-1).join("/")||j.title,figmaMapping:null}));try{let w=q(),j=localStorage.getItem("uicopilot_session_token"),G=await oe(`${w}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${j}`}});if(G.ok){let L=await G.json(),K=new Map((L.mappings||[]).map(ee=>[ee.storyId,ee]));D.forEach(ee=>{let re=K.get(ee.id);re&&re.figmaNodeId&&(ee.figmaMapping={figmaNodeId:re.figmaNodeId,figmaFrameName:re.name||re.figmaFrameName||""})})}}catch(w){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",w)}s(D);let N=D.find(w=>!w.figmaMapping);N?l(N.id):D.length>0&&l(D[0].id)}catch(v){console.error("[StoryMappingAssistant] Error fetching stories:",v)}finally{u(!1)}},[n]);w_(()=>{e&&z()},[e,z]);let _=Co((v,A,P)=>{s(w=>w.map(j=>j.id===v?{...j,figmaMapping:{figmaNodeId:A,figmaFrameName:P}}:j));let D=i.findIndex(w=>w.id===v),N=i.find((w,j)=>j>D&&!w.figmaMapping);N&&l(N.id)},[i]),M=Co(v=>{s(A=>A.map(P=>P.id===v?{...P,figmaMapping:null}:P))},[]),B=Co(v=>{l(v),o("map")},[]),m=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);S.collectAndMap(v)},[i,S]),x=Co(()=>{let v=i.filter(A=>A.figmaMapping).map(A=>A.id);f(!1),S.rerun(v)},[i,S]),b=Co(async v=>{await S.applyMappings(v),f(!1),S.reset(),z(),C()},[S,z,C]),E=Co(()=>{f(!1),S.reset()},[S]);Je.useEffect(()=>{S.results&&f(!0)},[S.results]);let h=v=>{v.target===v.currentTarget&&t()};if(!e)return null;let T=i.filter(v=>v.figmaMapping).length,I=i.length;return Je.createElement(Je.Fragment,null,Je.createElement(v_,{onClick:h},Je.createElement(k_,{onClick:v=>v.stopPropagation()},Je.createElement(C_,null,Je.createElement(T_,null,Je.createElement(I_,null,Je.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Je.createElement(F_,null,Je.createElement(aC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Je.createElement(aC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),Je.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},F.enableAutoMap&&!d&&!S.isCollecting&&!S.isMapping&&Je.createElement(O_,{onClick:m,disabled:a||i.length===0},Je.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},Je.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),Je.createElement("path",{d:"M2 17l10 5 10-5"}),Je.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),Je.createElement(E_,{onClick:t},"\xD7"))),Je.createElement(A_,null,(S.isCollecting||S.isMapping)&&Je.createElement(M_,null,Je.createElement(B_,null,Je.createElement(z_,null,Je.createElement(N_,null)),Je.createElement(D_,null,"Auto-mapping stories to Figma"),Je.createElement(R_,null,S.progress),Je.createElement(Br,{onClick:S.cancel,variant:"ghost"},"Cancel"))),d&&S.results&&Je.createElement(tC,{results:S.results,stories:i,onApply:b,onCancel:E,onRerun:x,isApplying:S.isApplying,isRerunning:S.isCollecting||S.isMapping,source:S.source,resolveThumbnail:v=>S.results?.thumbnailUrls?.[v],resolveStoryScreenshot:v=>R.screenshots[v],isCapturingScreenshots:R.isCapturing,onBrowse:v=>g(v)}),!d&&!S.isCollecting&&!S.isMapping&&(r==="map"?Je.createElement(Nk,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:_,projectId:n}):Je.createElement(Uk,{stories:i,loading:a,onLink:B,onUnlink:M,projectId:n}))),Je.createElement(P_,null,Je.createElement(L_,null,Je.createElement("span",null,"Total: ",I," stories"),Je.createElement(lC,{type:"mapped"},Je.createElement("span",{className:"dot"}),T," mapped"),Je.createElement(lC,{type:"unmapped"},Je.createElement("span",{className:"dot"}),I-T," unmapped"))))),Je.createElement(Mi,{isOpen:!!p,onClose:()=>g(null),onSelect:()=>g(null),projectId:n,initialSearch:p||void 0}))};import Xr,{useEffect as __,useCallback as $_}from"react";import{styled as qo,keyframes as uC}from"storybook/theming";var U_=uC({from:{opacity:0},to:{opacity:1}}),j_=uC({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),H_=qo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${U_} 150ms ease-out`}),W_=qo.div(({theme:e})=>({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10001,backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,padding:`${e.layoutMargin*2.4}px`,minWidth:"320px",maxWidth:"440px",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.2)",animation:`${j_} 150ms ease-out`})),V_=qo.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),G_=qo.p(({theme:e})=>({margin:`${e.layoutMargin}px 0 ${e.layoutMargin*2}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,color:e.color.defaultText,lineHeight:1.5})),q_=qo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),Y_=qo.button(({theme:e})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,cursor:"pointer",backgroundColor:"transparent",color:e.color.defaultText,transition:"background-color 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),K_=qo.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover":{opacity:.9}})),Di=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",onConfirm:s,onCancel:a})=>{let u=$_(c=>{c.key==="Escape"&&a()},[a]);return __(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),e?Xr.createElement(Xr.Fragment,null,Xr.createElement(H_,{onClick:a}),Xr.createElement(W_,{role:"dialog","aria-modal":"true","aria-label":t},Xr.createElement(V_,null,t),Xr.createElement(G_,null,n),Xr.createElement(q_,null,Xr.createElement(Y_,{onClick:a},o),Xr.createElement(K_,{variant:i,onClick:s},r)))):null};pt();var pC=Yn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",transition:"border-color 0.2s, box-shadow 0.2s","&:hover":{borderColor:e.color.mediumlight}})),Q_=Yn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),J_=Yn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),Z_=Yn.div({display:"flex",alignItems:"center",gap:"8px"}),e$=Yn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),t$=Yn.div(({theme:e,percent:t,state:n})=>({width:`${t}%`,height:"100%",borderRadius:"2px",backgroundColor:n==="complete"?e.color.positive:n==="partial"?e.color.warning:e.color.mediumlight,transition:"width 0.3s ease"})),n$=Yn.span(({theme:e,state:t})=>({fontSize:"12px",fontWeight:600,color:t==="complete"?e.color.positive:t==="partial"?e.color.warning:e.color.mediumdark,whiteSpace:"nowrap"})),r$=Yn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),o$=Yn(Zc)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),i$=Yn(Zc)(({theme:e})=>({padding:"4px 10px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626","&:hover":{textDecoration:"none",backgroundColor:"rgba(220, 38, 38, 0.08)"}})),s$=Yn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),a$=Yn.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),l$=Yn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),dC=()=>{let[e,t]=nc(!1),[n,r]=nc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Ze(),{sessionToken:i}=we();X_(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(_=>({..._,loading:!0}));try{let _=await fetch("/index.json");if(!_.ok)throw new Error("Failed to fetch Storybook index");let M=await _.json(),B=M.entries||M.stories||{},m=Object.keys(B).filter(T=>B[T].type==="story").length,x=Object.keys(B).filter(T=>B[T].type==="story"),b=q(),E=await oe(`${b}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),h=0;if(E.ok){let T=await E.json(),I=T.mappings||T||[];if(Array.isArray(I)){let v=new Set(I.map(A=>A.storyId).filter(Boolean));h=x.filter(A=>v.has(A)).length}else{let v=await oe(`${b}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(v.ok){let A=await v.json();h=Math.min(A.mappedStoriesCount||0,m)}}}r({totalStories:m,mappedStories:h,loading:!1})}catch(_){console.error("[FigmaMappingsSection] Error fetching stats:",_),r(M=>({...M,loading:!1}))}},[a,u]=nc(!1),[c,l]=nc(!1),d=async()=>{!o||!i||l(!0)},f=async()=>{l(!1),u(!0);try{let _=q(),M=await oe(`${_}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!M.ok)throw new Error("Failed to fetch mappings");let m=(await M.json()).mappings||[];await Promise.all(m.map(x=>oe(`${_}/api/mappings?id=${encodeURIComponent(x.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(_){console.error("[FigmaMappingsSection] Unlink all failed:",_)}finally{u(!1)}},p=()=>t(!0),g=()=>{t(!1),o&&i&&s()};if(!o)return kt.createElement(pC,null,kt.createElement(s$,null,"Select a project to link Figma designs"));let{totalStories:S,loading:C}=n,F=Math.min(n.mappedStories,S),k=F===0?"none":F>=S?"complete":"partial",R=S>0?Math.min(100,Math.round(F/S*100)):0,z=k==="none"?"Link designs":"Manage";return kt.createElement(kt.Fragment,null,kt.createElement(pC,null,kt.createElement(Q_,null,kt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},kt.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),kt.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),kt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),kt.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),kt.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),kt.createElement(J_,null,kt.createElement(r$,null,"Figma Mappings"),kt.createElement(Z_,null,C?kt.createElement(kt.Fragment,null,kt.createElement(a$,null),kt.createElement(l$,null,"Loading...")):kt.createElement(kt.Fragment,null,kt.createElement(e$,null,kt.createElement(t$,{percent:R,state:k})),kt.createElement(n$,{state:k},`${F}/${S}`)))),F>0&&kt.createElement(i$,{onClick:d,disabled:C||a},a?"Unlinking...":"Unlink All"),kt.createElement(o$,{onClick:p,disabled:C},z)),e&&kt.createElement(cC,{isOpen:e,onClose:g,projectId:o}),kt.createElement(Di,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:f,onCancel:()=>l(!1)}))};import ce,{useState as Zs,useEffect as Vm,useCallback as c$}from"react";import{styled as Kn}from"storybook/theming";ve();je();pt();var Gm=Kn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),qm=Kn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),Ym=Kn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Ete=Kn(Er)({padding:"5px 12px",fontSize:"12px"}),Km=Kn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),rc=Kn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),u$=Kn.span(({theme:e,status:t})=>({display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="cached"?`${e.color.positive}1a`:t==="expired"?`${e.color.warning}1a`:e.background.hoverable,color:t==="cached"?e.color.positive:t==="expired"?e.color.warning:e.color.mediumdark})),p$=Kn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),Xm=Kn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),d$=Kn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),oc=Kn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),ic=Kn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Yo=Kn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),fC=new Set,gC=()=>{let{userRole:e,featureFlags:t}=ie(),[n,r]=Zs(null),[o,i]=Zs(!0),[s,a]=Zs(!1),[u,c]=Zs(!1),[l,d]=Zs(!1),{selectedProjectId:f,projects:p}=Ze(),{sessionToken:g}=we(),S=c$(async()=>{if(!(!f||!g))try{let M=q(),B=await oe(`${M}/api/figma/cache-status?projectId=${f}`,{headers:{Authorization:`Bearer ${g}`}});if(B.ok){let m=await B.json();r(m)}}catch(M){console.error("[FigmaCacheSection] Error:",M)}finally{i(!1)}},[f,g]);Vm(()=>{S()},[S]),Vm(()=>{if(o||s||!n||n.structureStatus!=="none"||!f||fC.has(f))return;let M=p.find(m=>m.id===f);(M?.figmaFileUrl||M?.figmaFileId)&&(fC.add(f),C())},[o,s,n?.structureStatus,f,p]),Vm(()=>{let M=n?.thumbnailProgress?.status,B=n?.enrichmentProgress?.status,m=n?.thumbnailProgress?.cached??0,x=n?.thumbnailProgress?.total??0,b=M==="in-progress"||M==="pending"||x>0&&m<x,E=B==="in-progress"||B==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(b||E||h)||!n||n.structureStatus==="none")return;let I=setInterval(()=>{S()},3e3);return()=>{clearInterval(I)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,S]);let C=async()=>{if(!(!f||!g)){a(!0);try{let M=q();await oe(`${M}/api/figma/frames?projectId=${f}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${g}`}},6e4),await new Promise(B=>setTimeout(B,1e3)),await S(),setTimeout(async()=>{await S()},3e3)}catch(M){console.error("[FigmaCacheSection] Reload error:",M)}finally{a(!1)}}},F=async()=>{if(!(!f||!g)){c(!0);try{let M=q(),B=await oe(`${M}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})});console.log("[FigmaCacheSection] Cache invalidate response:",B.status),await oe(`${M}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(M){console.error("[FigmaCacheSection] Clear cache error:",M)}finally{c(!1)}}},k=async()=>{if(!(!f||!g)){d(!0);try{let M=q();await oe(`${M}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({projectId:f})});let B=setInterval(async()=>{await S()},3e3),m=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(clearInterval(B),clearInterval(m),d(!1),S())},3e3);setTimeout(()=>{clearInterval(B),clearInterval(m),d(!1)},6e5)}catch(M){console.error("[FigmaCacheSection] Enrich error:",M),d(!1)}}};if(!f)return null;if(o)return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache")),ce.createElement(Km,null,ce.createElement(rc,null,"Loading cache status\u2026")),ce.createElement(oc,null,ce.createElement(ic,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache"),ce.createElement(Br,{loading:s,onClick:C,loadingText:"Loading..."},"\u21BB Load")),s?ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):ce.createElement(Km,null,ce.createElement(rc,null,"No cache \u2014 click Load to fetch from Figma")));let R=M=>{let B=Date.now()-new Date(M).getTime(),m=Math.floor(B/6e4);if(m<1)return"just now";if(m<60)return`${m}m ago`;let x=Math.floor(m/60);return x<24?`${x}h ago`:`${Math.floor(x/24)}d ago`},z=n.cacheDiff,_=z&&(z.added.length>0||z.removed.length>0||z.renamed.length>0);return ce.createElement(Gm,null,ce.createElement(qm,null,ce.createElement(Ym,null,"Figma Cache"," ",ce.createElement(u$,{status:n.structureStatus},n.structureStatus)),ce.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&ce.createElement(Br,{loading:l,onClick:k,loadingText:"Enriching..."},"Enrich"),ce.createElement(Br,{loading:u,onClick:F,variant:"ghost",loadingText:"Clearing..."},"Clear"),ce.createElement(Br,{loading:s,onClick:C,loadingText:"Reloading..."},"\u21BB Reload"))),s&&ce.createElement(Yo,null,ce.createElement("span",null,"Downloading structure from Figma...")),ce.createElement(Km,null,ce.createElement(rc,null,ce.createElement("strong",null,n.componentSetCount)," component sets"),ce.createElement(rc,null,ce.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&ce.createElement(d$,null,"Updated ",R(n.structureCachedAt))),_&&ce.createElement(p$,null,"Since last reload:"," ",z.added.length>0&&ce.createElement(Xm,{type:"added"},"+",z.added.length," added"),z.added.length>0&&z.removed.length>0&&" \xB7 ",z.removed.length>0&&ce.createElement(Xm,{type:"removed"},"\u2212",z.removed.length," removed"),(z.added.length>0||z.removed.length>0)&&z.renamed.length>0&&" \xB7 ",z.renamed.length>0&&ce.createElement(Xm,{type:"renamed"},z.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Caching component set thumbnails to CDN...",n.thumbnailProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.thumbnailProgress.currentName)),ce.createElement("span",null,n.thumbnailProgress.cached," / ",n.thumbnailProgress.total))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: ",n.thumbnailProgress.cached," / ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending")&&ce.createElement(Yo,null,ce.createElement("span",null,"Thumbnails: not pre-cached")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&ce.createElement(ce.Fragment,null,ce.createElement(oc,null,ce.createElement(ic,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),ce.createElement(Yo,null,ce.createElement("span",null,"Enriching components with AI...",n.enrichmentProgress.currentName&&ce.createElement(ce.Fragment,null," ",n.enrichmentProgress.currentName)),ce.createElement("span",null,n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&ce.createElement(ce.Fragment,null,ce.createElement(Yo,null,ce.createElement("span",null,"AI enrichment: ",n.enrichmentProgress.enriched," / ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="processing"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&ce.createElement("div",{style:{marginTop:"6px"}},ce.createElement(Ql,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import ht,{useState as Ri}from"react";import{styled as Dr}from"storybook/theming";ve();je();pt();var Qm=Dr.div({padding:"12px 16px"}),f$=Dr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),mC=Dr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),hC=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:le,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),g$=Dr.div({display:"flex",gap:"8px",alignItems:"center"}),m$=Dr.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none",fontFamily:"monospace","&:focus":{borderColor:le,boxShadow:`0 0 0 1px ${le}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),xC=Dr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),h$=Dr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:le,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),x$=Dr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"6px",backgroundColor:"#16a34a10",border:"1px solid #16a34a30",fontSize:"12px",color:e.color.defaultText})),y$=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),yC=({onConnected:e})=>{let{sessionToken:t}=we(),[n,r]=Ri(!1),[o,i]=Ri(""),[s,a]=Ri(!1),[u,c]=Ri(null),[l,d]=Ri(null),[f,p]=Ri(!1),g=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let S=q(),C=await oe(`${S}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),F=await C.json();if(!C.ok){c({type:"error",message:F.error||"Failed to save token"});return}d(F.figmaUser?.handle||F.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${F.figmaUser?.handle||"Figma user"}`}),i(""),e?.()}catch{c({type:"error",message:"Failed to connect. Check your token and try again."})}finally{a(!1)}}};return l?ht.createElement(Qm,null,ht.createElement(mC,null,"Figma Personal Access Token"),ht.createElement(x$,null,ht.createElement("span",null,"\u2713 Connected as ",ht.createElement("strong",null,l)),ht.createElement(y$,{onClick:()=>{d(null),c(null)}},"Change token"))):n?ht.createElement(Qm,null,ht.createElement(f$,null,ht.createElement(mC,null,"Figma Personal Access Token"),ht.createElement(hC,{onClick:()=>p(!f)},f?"Hide instructions":"How to generate")),f&&ht.createElement(h$,null,ht.createElement("ol",null,ht.createElement("li",null,"Open ",ht.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),ht.createElement("li",null,"Click the ",ht.createElement("strong",null,"Security")," tab"),ht.createElement("li",null,"Scroll to ",ht.createElement("strong",null,"Personal access tokens")),ht.createElement("li",null,"Click ",ht.createElement("strong",null,"Generate new token")),ht.createElement("li",null,"Enable ",ht.createElement("strong",null,"File content: Read only")," under Scopes"),ht.createElement("li",null,"Copy the token and paste it below"))),ht.createElement(g$,null,ht.createElement(m$,{type:"password",value:o,onChange:S=>i(S.target.value),placeholder:"figd_...",onKeyDown:S=>{S.key==="Enter"&&o.trim()&&g()}}),ht.createElement(en,{onClick:g,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&ht.createElement(xC,{variant:u.type},u.message),ht.createElement(xC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):ht.createElement(Qm,null,ht.createElement(hC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};ve();je();pt();var S$=bt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},bt.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),bt.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),bt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),bt.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),bt.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"})),Zm=vr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),w$=vr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),v$=vr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),k$=vr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),eh=vr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),C$=vr.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",margin:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"})),T$=vr.div({display:"flex",alignItems:"center",gap:"8px"}),I$=vr(er)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),F$=vr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Yte=vr.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:"#A259FF",color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:"#8a3de8"}}),E$=vr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.mediumdark,"&::before, &::after":{content:'""',flex:1,height:"1px",backgroundColor:e.appBorderColor}})),SC=({hideHeader:e=!1})=>{let{sessionToken:t}=we(),[n,r]=Jm(!1),[o,i]=Jm(null),[s,a]=Jm(!1);b$(()=>{if(!t)return;let d=q();oe(`${d}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(f=>f.json()).then(f=>i(!!f.connected)).catch(()=>i(!1))},[t]);let u=bC(()=>{let f=`${q()}/addon/auth`;window.open(f,"figma-oauth","width=600,height=700,left=200,top=100")},[]),c=bC(async()=>{try{r(!0);let d=q(),f=await oe(`${d}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});(f.ok||f.status===404)&&i(!1)}catch{}finally{r(!1)}},[t]),l=e?null:bt.createElement(w$,null,bt.createElement(v$,null,S$),bt.createElement(k$,null,"Figma Integration"));return o===null?bt.createElement(Zm,null,l,bt.createElement(eh,null,bt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?bt.createElement(Zm,null,l,bt.createElement(eh,null,bt.createElement(F$,null,bt.createElement(en,{onClick:u,style:{width:"100%"}},"Connect with Figma"),bt.createElement(E$,null,"or"),bt.createElement(yC,{onConnected:()=>i(!0)})))):bt.createElement(Zm,null,l,bt.createElement(C$,null,bt.createElement(T$,null,bt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),bt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),bt.createElement(I$,{onClick:()=>a(!0),disabled:n},n?"Disconnecting...":"Disconnect")),bt.createElement(Di,{isOpen:s,title:"Disconnect Figma",message:"Your mappings, cache, and review history will be preserved. You will need to re-authenticate to make new Figma API calls.",confirmLabel:"Disconnect",variant:"danger",onConfirm:()=>{a(!1),c()},onCancel:()=>a(!1)}),bt.createElement(eh,null,bt.createElement(jv,null),bt.createElement(dC,null),bt.createElement(gC,null)))};ve();var A$=cr.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"32px"}),P$=cr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"14px",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.22)",width:"520px",maxWidth:"94%",maxHeight:"calc(100vh - 64px)",overflow:"auto",position:"relative"})),L$=cr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",position:"sticky",top:0,backgroundColor:e.background.content,borderRadius:"14px 14px 0 0",zIndex:1})),M$=cr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),B$=cr(wn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),D$=cr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),wC=cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),vC=cr.div({display:"flex",alignItems:"center",gap:"10px"}),kC=cr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),R$=cr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:le,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),z$=cr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),CC=cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"12px",fontSize:"12px","& > div, & > section":{padding:0},'[class*="AuthPanelContainer"], [class*="SectionContainer"]':{padding:0},"h3, h4":{fontSize:"12px",margin:"0 0 6px 0"},label:{fontSize:"12px"},"input, select":{fontSize:"12px",padding:"6px 10px",height:"auto"},button:{fontSize:"11px"},p:{fontSize:"11px",margin:"2px 0"}})),TC=({onClose:e})=>{let{isConnected:t}=we(),{selectedProjectId:n}=Ze();return Et.createElement(A$,{onClick:e},Et.createElement(P$,{onClick:r=>r.stopPropagation()},Et.createElement(L$,null,Et.createElement(M$,null,"Settings"),Et.createElement(B$,{onClick:e,title:"Close settings"},"\xD7")),Et.createElement(D$,null,Et.createElement(wC,null,Et.createElement(vC,null,Et.createElement(R$,null,"UI"),Et.createElement(kC,null,"UI Copilot")),Et.createElement(CC,null,Et.createElement(Nv,null),t&&Et.createElement(_v,null))),t&&n&&Et.createElement(wC,null,Et.createElement(vC,null,Et.createElement(z$,null,Et.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Et.createElement("path",{d:"M19 28.5C19 23.2533 23.2533 19 28.5 19C33.7467 19 38 23.2533 38 28.5C38 33.7467 33.7467 38 28.5 38C23.2533 38 19 33.7467 19 28.5Z",fill:"#1ABCFE"}),Et.createElement("path",{d:"M0 47.5C0 42.2533 4.25329 38 9.5 38H19V47.5C19 52.7467 14.7467 57 9.5 57C4.25329 57 0 52.7467 0 47.5Z",fill:"#0ACF83"}),Et.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Et.createElement("path",{d:"M0 9.5C0 14.7467 4.25329 19 9.5 19H19V0H9.5C4.25329 0 0 4.25329 0 9.5Z",fill:"#F24E1E"}),Et.createElement("path",{d:"M0 28.5C0 33.7467 4.25329 38 9.5 38H19V19H9.5C4.25329 19 0 23.2533 0 28.5Z",fill:"#A259FF"}))),Et.createElement(kC,null,"Figma Integration")),Et.createElement(CC,null,Et.createElement(SC,{hideHeader:!0}))))))};import ft,{useEffect as RC,useMemo as p4,useState as d4,useRef as f4}from"react";import{styled as Cn,keyframes as g4}from"storybook/theming";ve();ve();import Kt,{useState as N$}from"react";import{styled as On}from"storybook/theming";var Qr=[{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Latest Claude model, best balance of speed and quality"},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",provider:"anthropic",description:"Previous generation Sonnet"},{id:"claude-3-5-sonnet-20241022",name:"Claude 3.5 Sonnet",provider:"anthropic",description:"Best balance of speed and quality"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",provider:"anthropic",description:"Fastest, most affordable"},{id:"claude-3-opus-20240229",name:"Claude 3 Opus",provider:"anthropic",description:"Most capable Claude 3 model"},{id:"gpt-5.2",name:"GPT-5.2 Thinking",provider:"openai",description:"47% cheaper, reasoning"},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Instant",provider:"openai",description:"86% cheaper (default)"},{id:"gpt-4o",name:"GPT-4o",provider:"openai",description:"GPT-4 multimodal flagship"},{id:"gpt-4o-mini",name:"GPT-4o Mini",provider:"openai",description:"GPT-4 affordable model"},{id:"o1-preview",name:"o1 Preview",provider:"openai",description:"Reasoning model (slower, advanced)"},{id:"o1-mini",name:"o1 Mini",provider:"openai",description:"Faster reasoning model"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"Fast & cheap, great vision"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",provider:"google",description:"Best Gemini quality"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"google",description:"Previous gen, very fast"}];var O$=On.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),_$=On.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),$$=On.div(({theme:e,disabled:t,provider:n})=>{let r={anthropic:{background:"#D4A574",text:"#ffffff"},openai:{background:e.color.positive||"#10b981",text:"#ffffff"},google:{background:"#4285F4",text:"#ffffff"}},o=n?r[n]:r.anthropic;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:o.background,color:o.text,fontSize:"11px",fontWeight:500,borderRadius:"12px",opacity:t?.6:1,cursor:t?"not-allowed":"default",transition:"opacity 0.15s"}}),U$=On.button(({theme:e,disabled:t})=>({background:"none",border:"none",color:e.color.inverseText,fontSize:"12px",cursor:t?"not-allowed":"pointer",padding:"0 2px",lineHeight:1,opacity:t?.5:.8,transition:"opacity 0.15s","&:hover":{opacity:t?.5:1}})),j$=On.div({position:"relative",display:"inline-block"}),H$=On.button(({disabled:e,isOpen:t,theme:n})=>({padding:`${n.layoutMargin*.8}px 32px ${n.layoutMargin*.8}px ${n.layoutMargin}px`,fontSize:n.typography.size.s2,fontFamily:n.typography.fonts.base,fontWeight:500,color:n.color.defaultText,backgroundColor:n.input.background,border:`1px solid ${t?n.color.secondary:n.appBorderColor}`,borderRadius:n.appBorderRadius,cursor:e?"not-allowed":"pointer",opacity:e?.6:1,whiteSpace:"nowrap",display:"flex",gap:`${n.layoutMargin*.8}px`,alignItems:"center",justifyContent:"space-between",minWidth:"200px",transition:"border-color 0.15s, box-shadow 0.15s",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",backgroundSize:"12px","&:hover":{borderColor:e?n.appBorderColor:n.color.mediumdark}})),W$=On.div(({theme:e})=>({position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:e.base==="dark"?"0 4px 12px rgba(0, 0, 0, 0.3)":"0 4px 12px rgba(0, 0, 0, 0.1)",zIndex:1e3,maxHeight:"280px",overflowY:"auto"})),th=On.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),nh=On.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),V$=On.div(({theme:e,disabled:t})=>({padding:"8px 12px",fontSize:"12px",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,display:"flex",alignItems:"center",gap:"8px",transition:"background-color 0.15s",color:e.color.defaultText,"&:hover":{backgroundColor:t?"transparent":e.background.hoverable}})),G$=On.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),q$=On.div({flex:1,minWidth:0}),Y$=On.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),K$=On.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),X$=5,IC=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ie(),[r,o]=N$(!1),i=Qr.filter(p=>p.provider==="anthropic"&&!e.includes(p.id)),s=Qr.filter(p=>p.provider==="openai"&&!e.includes(p.id)),a=Qr.filter(p=>p.provider==="google"&&!e.includes(p.id)),u=Qr.filter(p=>e.includes(p.id)),c=e.length<X$,l=(p,g)=>{g.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let g=e.includes(p);g&&e.length===1||!g&&!c||n||(t(p),o(!1))},f=p=>{let g=e.includes(p.id),S=g&&e.length===1,C=n||S||!g&&!c;return Kt.createElement(V$,{key:p.id,disabled:C,onClick:()=>d(p.id)},Kt.createElement(G$,{type:"checkbox",checked:g,disabled:C,onChange:()=>{},onClick:F=>F.stopPropagation()}),Kt.createElement(q$,null,Kt.createElement(Y$,null,p.name),p.description&&Kt.createElement(K$,null,p.description)))};return Kt.createElement(O$,null,Kt.createElement(j$,null,Kt.createElement(H$,{disabled:n,isOpen:r,onClick:()=>o(!r)},Kt.createElement("span",null,"Select model"),Kt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Kt.createElement(W$,null,Kt.createElement(th,null,Kt.createElement(nh,null,"Anthropic"),i.map(f)),Kt.createElement(th,null,Kt.createElement(nh,null,"OpenAI"),s.map(f)),Kt.createElement(th,null,Kt.createElement(nh,null,"Google"),a.map(f)))),Kt.createElement(_$,null,u.map(p=>Kt.createElement($$,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Kt.createElement(U$,{disabled:n,onClick:g=>l(p.id,g),title:"Remove model"},"\xD7")))))};import Ce,{useState as Q$,useEffect as J$}from"react";import{styled as jt,keyframes as Ni}from"storybook/theming";ve();var Z$=Ni`
45
45
  0%, 100% {
46
46
  opacity: 1;
47
47
  transform: scale(1);
@@ -50,20 +50,20 @@ ${st}`).join(`
50
50
  opacity: 0.4;
51
51
  transform: scale(0.8);
52
52
  }
53
- `,t4=Ni`
53
+ `,e4=Ni`
54
54
  0% { transform: rotate(0deg); }
55
55
  100% { transform: rotate(360deg); }
56
- `,FC=Ni`
56
+ `,AC=Ni`
57
57
  0% { opacity: 0; transform: translateY(2px); }
58
58
  100% { opacity: 1; transform: translateY(0); }
59
- `,n4=Ni`
59
+ `,t4=Ni`
60
60
  0%, 100% {
61
61
  opacity: 1;
62
62
  }
63
63
  50% {
64
64
  opacity: 0.6;
65
65
  }
66
- `,r4=Ni`
66
+ `,n4=Ni`
67
67
  0% {
68
68
  transform: translateY(0) rotate(0deg) scale(1);
69
69
  opacity: 1;
@@ -75,27 +75,27 @@ ${st}`).join(`
75
75
  transform: translateY(60px) rotate(720deg) scale(0.5);
76
76
  opacity: 0;
77
77
  }
78
- `;var Cne=jt.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),Zm=jt.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),Tne=jt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",borderRadius:"8px",backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:"12px",fontWeight:500,color:e.textMutedColor,animation:`${FC} 0.3s ease-out`})),o4=Ni`
78
+ `;var vne=jt.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),rh=jt.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),kne=jt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",borderRadius:"8px",backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:"12px",fontWeight:500,color:e.textMutedColor,animation:`${AC} 0.3s ease-out`})),r4=Ni`
79
79
  from { transform: rotate(0deg); }
80
80
  to { transform: rotate(360deg); }
81
- `,Ine=jt.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${o4} 0.8s linear infinite`,flexShrink:0})),TC=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#fee2e2",fontSize:"12px",fontWeight:700,color:"#dc2626",whiteSpace:"nowrap"}),i4=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#dcfce7",fontSize:"12px",fontWeight:700,color:"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"}),Fne=jt.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"-10px",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>6?"50%":"2px",animation:`${r4} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var zi=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),ea=jt.span(({color:e="#6b7280"})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:e,whiteSpace:"nowrap"})),IC=jt.span(({color:e="#6b7280"})=>({fontSize:"12px",color:e})),ta=jt.span(({color:e})=>({fontWeight:700,color:e})),s4=jt.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"12px",backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:"12px",color:t.textMutedColor},"& .score-value":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:"20px",fontWeight:700,color:e,lineHeight:1},"& .score-dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:e}})),Ene=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),Ane=jt.span(({color:e=le})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${e4} 1.2s ease-in-out infinite`,marginRight:"4px"})),Pne=jt.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return le;case"score-high":return"#16a34a";case"score-medium":return"#ca8a04";case"score-low":return"#dc2626";case"cost":return"#7c3aed";case"tokens":return e.color.mediumdark;case"analyzing":return le;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${n4} 1.5s ease-in-out infinite`}:{}})),Lne=jt.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Mne=jt.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),a4=jt.button(({theme:e,isExporting:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",fontSize:"11px",fontWeight:600,color:t?e.color.mediumdark:"#7c3aed",backgroundColor:t?e.background.hoverable:"#ede9fe",border:"none",borderRadius:"12px",cursor:t?"not-allowed":"pointer",transition:"all 0.2s",whiteSpace:"nowrap","&:hover":{backgroundColor:t?e.background.hoverable:"#ddd6fe"}})),l4=jt.span({display:"inline-block",width:"10px",height:"10px",border:"2px solid #c4b5fd",borderTopColor:"#7c3aed",borderRadius:"50%",animation:"export-spin 0.8s linear infinite","@keyframes export-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),c4=jt.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${t4} 1.2s linear infinite`,flexShrink:0}),u4=({color:e=le})=>Ce.createElement(c4,null,Ce.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},Array.from({length:8}).map((t,n)=>{let o=n*360/8*Math.PI/180,i=12+Math.cos(o)*4,s=12+Math.sin(o)*4,a=12+Math.cos(o)*10,u=12+Math.sin(o)*10;return Ce.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Bne=jt.span(({color:e="#6b7280"})=>({fontSize:"12px",fontWeight:500,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",animation:`${FC} 0.3s ease-out`}));function p4(e){let[t,n]=J$(0);return Z$(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var EC=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,visualSimilarity:i,costUsd:s,inputTokens:a,outputTokens:u,showTimer:c=!0,cacheCreationTokens:l,cacheReadTokens:d,durationSeconds:f})=>{let p=p4(e||t),{exportPDF:g,isExporting:S}=im(),{featureFlags:C}=ie(),F=C.showCosts,k=3.65,R=m=>m<.01?`$${m.toFixed(4)}`:m<.1?`$${m.toFixed(3)}`:`$${m.toFixed(2)}`,z=m=>{let x=m*k;return x<.01?`\u20AA${x.toFixed(4)}`:x<.1?`\u20AA${x.toFixed(3)}`:`\u20AA${x.toFixed(2)}`},_=m=>m>=1e3?`${(m/1e3).toFixed(1)}K`:m.toString(),M=m=>m>=80?"score-high":m>=50?"score-medium":"score-low",B=m=>m>=80?"high":m>=50?"medium":"low";if(e)return Ce.createElement(Zm,null,Ce.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},p,"s \xB7 Esc to stop"));if(t)return Ce.createElement(Zm,null,Ce.createElement(TC,null,Ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(u4,{color:"#7c3aed"}),Ce.createElement(ta,{color:"#7c3aed"},"Verifying...")),c&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement("span",{style:{color:"#6b7280"}},p,"s"))));if(r>0||o!==void 0){let m=(a||0)+(u||0),x=(d||0)>0,b=x&&a?Math.round(d/a*100):0,E=Math.max(o??0,i??0),h=I=>I>=80?"#16a34a":I>=50?"#ca8a04":"#dc2626",T=I=>I>=100?"\u25CF":I>=50?"\u25D0":"\u25CB";return Ce.createElement(Zm,null,r===0?Ce.createElement(i4,null,Ce.createElement("span",null,"\u2713"),"Perfect!"):Ce.createElement(TC,null,Ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ce.createElement(s4,{tint:h(E),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},Ce.createElement("span",{className:"score-dot"}),Ce.createElement("span",{className:"score-label"},"Score"),Ce.createElement("span",{className:"score-value"},E)),F&&s!==void 0&&s>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(ta,{color:"#16a34a"},R(s)),Ce.createElement("span",{style:{color:"#6b7280"}},"/"),Ce.createElement(ta,{color:"#16a34a"},z(s)))),F&&m>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${x?` \xB7 Cached: ${d?.toLocaleString()}`:""}`},Ce.createElement(IC,{color:"#7c3aed"},"#"),Ce.createElement(ta,{color:"#7c3aed"},_(m)),Ce.createElement("span",{style:{color:"#6b7280"}},"tokens"),x&&Ce.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",b,"%"))),f!==void 0&&f>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(IC,{color:"#6b7280"},"\u23F1"),Ce.createElement(ta,{color:"#6b7280"},f,"s"))),Ce.createElement(zi,null,"|"),Ce.createElement(a4,{onClick:g,disabled:S,isExporting:S,title:"Download design review report as PDF"},S?Ce.createElement(Ce.Fragment,null,Ce.createElement(l4,null),"Exporting..."):Ce.createElement(Ce.Fragment,null,"\u2193 Report")))}return null};var h4=Cn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),jne=Cn.div({display:"flex",gap:"8px",alignItems:"center"}),x4=m4({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),y4=Cn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${x4} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),b4=Cn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),S4=Cn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"16px",padding:"14px 18px",borderRadius:"14px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02)",flexWrap:"wrap"})),w4=Cn.button(({theme:e,variant:t="orange",disabled:n})=>{let r={green:n?e.textMutedColor:e.color.positive||"#10b981",purple:n?e.textMutedColor:"#7c3aed",yellow:n?e.textMutedColor:"#c4b5fd",orange:n?e.textMutedColor:Pa},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:"#ffffff",border:"none",padding:"12px 24px",fontSize:"14px",fontWeight:600,borderRadius:"10px",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,whiteSpace:"nowrap",transition:"all 0.2s",boxShadow:n?"none":`0 2px 6px rgba(${o}, 0.3)`,flexShrink:0,"&:hover":{opacity:n?.6:.9,transform:n?"none":"translateY(-1px)",boxShadow:n?"none":`0 4px 10px rgba(${o}, 0.4)`}}}),v4=Cn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),k4=Cn.div({marginLeft:"auto",display:"flex",flexDirection:"column",gap:"4px"}),C4=Cn.label(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),T4=Cn(En)({width:"auto",minWidth:"200px"}),I4=Cn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),AC=Cn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),PC=Cn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?Pa:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),LC=Cn.div(({checked:e})=>({width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#fff",position:"absolute",top:"2px",left:e?"16px":"2px",transition:"left 0.2s ease",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.2)"})),MC=Cn.input({position:"absolute",opacity:0,width:0,height:0}),F4=()=>{let[e,t]=f4(0),n=g4();BC(()=>(n.current=setInterval(()=>t(s=>s+1),1e3),()=>clearInterval(n.current)),[]);let r=Math.floor(e/60),o=e%60,i=`${r}:${o.toString().padStart(2,"0")}`;return ft.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},eh=()=>{let{sessionToken:e}=Bs(),{usageData:t}=we(),{selectedProjectId:n}=qr(),{currentMapping:r,hasMapping:o}=Ho(),{loadingMapping:i,currentStoryId:s}=rt(),{startReview:a,cancelReview:u,isReviewing:c}=Yg(),{isLoadingScreenshots:l}=Uo(),{storybookImageUrl:d,figmaImageUrl:f,currentReviewId:p,reviewHistory:g,setReviewDetailTab:S,setReviewResults:C,setFigmaImageUrl:F,setStorybookImageUrl:k,setFullPrompt:R,setFullResponse:z,includeTextComparison:_,setIncludeTextComparison:M,usePromptCache:B,setUsePromptCache:m,isValidating:x,validationUsage:b,isGenerating:E,isApplying:h,streamingStatus:T,featureFlags:I,userRole:v,roleOverride:A,isReviewing:P}=ie(),D=t?.reviewCredits??Math.floor(t?.creditBalance??0),N=g.find(he=>he.id===p),j=(N?.issues||[]).filter(he=>!he.dismissed).length,G=N?.complianceScore,L=N?.visualSimilarity,K=(N?.costUsd||0)+(b?.costUsd||0),ee=(N?.inputTokens||0)+(b?.inputTokens||0),re=(N?.outputTokens||0)+(b?.outputTokens||0),de=d4(()=>{let he=s?g.filter(ne=>ne.storyId===s):g,vt=he.filter(ne=>!ne.parentReviewId).sort((ne,W)=>new Date(W.createdAt).getTime()-new Date(ne.createdAt).getTime()),Ge=he.filter(ne=>ne.parentReviewId),lt=[];for(let ne of vt){lt.push(ne);let W=Ge.filter(Ae=>Ae.parentReviewId===ne.id).sort((Ae,ge)=>(Ae.iterationNumber||0)-(ge.iterationNumber||0));lt.push(...W)}let nt=Ge.filter(ne=>!vt.some(W=>W.id===ne.parentReviewId));return lt.push(...nt),lt},[g,s]);BC(()=>{if(!c)return;let he=vt=>{vt.key==="Escape"&&(vt.preventDefault(),u())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[c,u]);let ae=o&&r?.figmaNodeId,qe=E||h,tt=!!(e&&n&&!c&&!l&&!qe&&s&&d&&ae&&f),se=async(he=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{S("chat"),await a({isIteration:he,parentReviewId:he?p:void 0})}catch(vt){console.error("[ReviewActions] Review error:",vt)}},pe=()=>se(!1),Ie=he=>{let vt=he.target.value;if(vt){let Ge=g.find(lt=>lt.id===vt);Ge&&(C({id:Ge.id,componentId:Ge.componentId,storyId:Ge.storyId,modelId:Ge.modelId,complianceScore:Ge.complianceScore,issuesCount:Ge.issuesCount,issues:Ge.issues,createdAt:new Date(Ge.createdAt),visualSimilarity:Ge.visualSimilarity,timestamp:new Date(Ge.createdAt).toISOString()}),Ge.figmaImageData&&F(Ge.figmaImageData),Ge.storybookImageData&&k(Ge.storybookImageData),(A??v)==="admin"&&(R(Ge.aiPrompt||""),z(Ge.aiResponse||"")),S("issues"))}},ze=he=>{let vt=new Date(he),lt=new Date().getTime()-vt.getTime(),nt=Math.floor(lt/6e4),ne=Math.floor(lt/36e5),W=Math.floor(lt/864e5);return nt<1?"Just now":nt<60?`${nt}m ago`:ne<24?`${ne}h ago`:W<7?`${W}d ago`:vt.toLocaleDateString()},me=he=>he?he.includes("haiku")?"Haiku":he.includes("sonnet")?"Sonnet":he.includes("opus")?"Opus":he.includes("gpt-4o-mini")?"GPT-4o mini":he.includes("gpt-4o")?"GPT-4o":he.includes("gpt-4")?"GPT-4":he.includes("o3")?"o3":he.includes("o1")?"o1":he.split("-")[0]||"":"",Nt=he=>{let vt=he.split("--"),Ge=vt[vt.length-1]||he;return Ge.charAt(0).toUpperCase()+Ge.slice(1)};return ft.createElement("div",null,ft.createElement(h4,null,I.enableModelSelection&&ft.createElement(CC,null),ft.createElement(I4,null,ft.createElement(AC,{title:"Compare text content between Figma design and Storybook component"},ft.createElement(MC,{type:"checkbox",checked:_,onChange:he=>M(he.target.checked)}),ft.createElement(PC,{checked:_},ft.createElement(LC,{checked:_})),"Compare text"),I.showCosts&&ft.createElement(AC,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ft.createElement(MC,{type:"checkbox",checked:B,onChange:he=>m(he.target.checked)}),ft.createElement(PC,{checked:B},ft.createElement(LC,{checked:B})),"Cache prompt")),ft.createElement(S4,null,ft.createElement(w4,{variant:c?"yellow":"purple",disabled:c?!1:!tt,onClick:c?u:pe,title:c?"Click to stop review":e?n?s?ae?l?"Loading screenshots...":qe?"Wait for fixes to complete...":d?f?"Review this component implementation":"Waiting for Figma design image...":"Waiting for Storybook screenshot...":'Figma mapping required - use "Map to Figma" in the Review tab':"No story selected":"Please select a project first":"Please connect to UI Copilot first"},c?ft.createElement(ft.Fragment,null,ft.createElement(y4,null),"Reviewing",ft.createElement(F4,null)):ft.createElement(ft.Fragment,null,ft.createElement(b4,null,ft.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ft.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ft.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),P?null:x||N?ft.createElement(EC,{isReviewing:!1,isValidating:x,streamingStatus:T,issueCount:j,score:G,visualSimilarity:L,costUsd:K||N?.costUsd,inputTokens:ee||N?.inputTokens,outputTokens:re||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,de.length>0&&ft.createElement(k4,null,ft.createElement(C4,null,"Review History"),ft.createElement(T4,{value:p||"",onChange:Ie},ft.createElement("option",{value:""},"Select a review..."),de.map(he=>{let vt=!!he.parentReviewId,Ge=vt?" \u21B3 ":"\u25CF ",lt=vt&&he.iterationNumber?`Iter ${he.iterationNumber} - `:"",nt=he.issuesCount??he.issues?.length??0,ne=he.complianceScore??"--",W=me(he.modelId);return ft.createElement("option",{key:he.id,value:he.id},Ge,lt,ze(he.createdAt)," - ",nt," issues (",ne,"%)",W?` \xB7 ${W}`:"",he.storyId?` \xB7 ${Nt(he.storyId)}`:"")}))))),!ae&&!i&&ft.createElement(v4,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import Vne,{useState as Gne}from"react";import{styled as DC}from"storybook/theming";var Kne=DC.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Xne=DC(io)({padding:"8px 12px",fontSize:"12px"});import Zne,{useState as ere}from"react";import{styled as th}from"storybook/theming";ve();je();De();pt();var are=th.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),lre=th(Er)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),cre=th.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import dre from"react";import{styled as E4}from"storybook/theming";var mre=E4.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));ve();import yre from"react";import{styled as Rr}from"storybook/theming";var wre=Rr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),vre=Rr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),kre=Rr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),Cre=Rr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),Tre=Rr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Ire=Rr.div(({theme:e,progress:t})=>({height:"100%",backgroundColor:t===100?e.color.positive||"#10b981":e.color.secondary,width:`${t}%`,transition:"width 0.3s ease, background-color 0.3s ease"})),Fre=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),Ere=Rr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),Are=Rr.div(({theme:e})=>({display:"inline-block",width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"spin 0.8s linear infinite",marginLeft:"8px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Pre=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));ve();import Bre,{useState as Dre}from"react";import{styled as zr}from"storybook/theming";var Nre=zr.div(({theme:e})=>{let t=(e.base==="dark","102, 126, 234");return{padding:"10px 12px",backgroundColor:`rgba(${t}, 0.08)`,borderRadius:"6px",marginBottom:"16px",border:`1px solid rgba(${t}, 0.2)`}}),Ore=zr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),_re=zr.div({display:"flex",alignItems:"center",gap:"8px"}),$re=zr.span({fontSize:"12px",opacity:.7}),Ure=zr.span({fontSize:"13px",fontWeight:500}),jre=zr.div(({score:e,theme:t})=>({display:"inline-block",padding:"4px 10px",borderRadius:"12px",fontSize:"13px",fontWeight:600,backgroundColor:e>=90?t.color.positive||"#10b981":e>=70?t.color.warning||"#f59e0b":t.color.negative||"#ef4444",color:t.color.inverseText})),Hre=zr.div({marginTop:"12px",fontSize:"11px"}),Wre=zr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),Vre=zr.div(({status:e,theme:t})=>({display:"flex",alignItems:"center",gap:"4px",color:e==="success"?"inherit":e==="success"?t.color.positive||"#10b981":e==="warning"?t.color.warning||"#f59e0b":t.color.negative||"#ef4444"})),Gre=zr.span({fontSize:"12px"});De();je();import Qt from"react";import{styled as Qi}from"storybook/theming";import Tr,{useEffect as mW}from"react";import{styled as ya}from"storybook/theming";ve();import ni,{useState as W5}from"react";import{styled as Wi}from"storybook/theming";var RC={fontBase:'"Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontMono:'"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace',sizeXs:"11px",sizeSm:"12px",sizeMd:"13px",sizeLg:"14px",sizeXl:"16px",weightRegular:400,weightMedium:500,weightBold:600};function zC(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var A4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L4={};function ic(e,t){return((t||L4).jsx?P4:A4).test(e)}var M4=/[ \t\n\f\r]/g;function nh(e){return typeof e=="object"?e.type==="text"?NC(e.value):!1:NC(e)}function NC(e){return e.replace(M4,"")===""}var Jr=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Jr.prototype.normal={};Jr.prototype.property={};Jr.prototype.space=void 0;function rh(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Jr(n,r,t)}function na(e){return e.toLowerCase()}var sn=class{constructor(t,n){this.attribute=n,this.property=t}};sn.prototype.attribute="";sn.prototype.booleanish=!1;sn.prototype.boolean=!1;sn.prototype.commaOrSpaceSeparated=!1;sn.prototype.commaSeparated=!1;sn.prototype.defined=!1;sn.prototype.mustUseProperty=!1;sn.prototype.number=!1;sn.prototype.overloadedBoolean=!1;sn.prototype.property="";sn.prototype.spaceSeparated=!1;sn.prototype.space=void 0;var ra={};ye(ra,{boolean:()=>We,booleanish:()=>zt,commaOrSpaceSeparated:()=>_n,commaSeparated:()=>To,number:()=>Y,overloadedBoolean:()=>sc,spaceSeparated:()=>wt});var B4=0,We=Ko(),zt=Ko(),sc=Ko(),Y=Ko(),wt=Ko(),To=Ko(),_n=Ko();function Ko(){return 2**++B4}var oh=Object.keys(ra),Xo=class extends sn{constructor(t,n,r,o){let i=-1;if(super(t,n),OC(this,"space",o),typeof r=="number")for(;++i<oh.length;){let s=oh[i];OC(this,oh[i],(r&ra[s])===ra[s])}}};Xo.prototype.defined=!0;function OC(e,t,n){n&&(e[t]=n)}function ur(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new Xo(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[na(r)]=r,n[na(i.attribute)]=r}return new Jr(t,n,e.space)}var ih=ur({properties:{ariaActiveDescendant:null,ariaAtomic:zt,ariaAutoComplete:null,ariaBusy:zt,ariaChecked:zt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:wt,ariaCurrent:null,ariaDescribedBy:wt,ariaDetails:null,ariaDisabled:zt,ariaDropEffect:wt,ariaErrorMessage:null,ariaExpanded:zt,ariaFlowTo:wt,ariaGrabbed:zt,ariaHasPopup:null,ariaHidden:zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wt,ariaLevel:Y,ariaLive:null,ariaModal:zt,ariaMultiLine:zt,ariaMultiSelectable:zt,ariaOrientation:null,ariaOwns:wt,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:zt,ariaReadOnly:zt,ariaRelevant:null,ariaRequired:zt,ariaRoleDescription:wt,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:zt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function ac(e,t){return t in e?e[t]:t}function lc(e,t){return ac(e,t.toLowerCase())}var _C=ur({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:To,acceptCharset:wt,accessKey:wt,action:null,allow:null,allowFullScreen:We,allowPaymentRequest:We,allowUserMedia:We,alt:null,as:null,async:We,autoCapitalize:null,autoComplete:wt,autoFocus:We,autoPlay:We,blocking:wt,capture:null,charSet:null,checked:We,cite:null,className:wt,cols:Y,colSpan:null,content:null,contentEditable:zt,controls:We,controlsList:wt,coords:Y|To,crossOrigin:null,data:null,dateTime:null,decoding:null,default:We,defer:We,dir:null,dirName:null,disabled:We,download:sc,draggable:zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:We,formTarget:null,headers:wt,height:Y,hidden:sc,high:Y,href:null,hrefLang:null,htmlFor:wt,httpEquiv:wt,id:null,imageSizes:null,imageSrcSet:null,inert:We,inputMode:null,integrity:null,is:null,isMap:We,itemId:null,itemProp:wt,itemRef:wt,itemScope:We,itemType:wt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:We,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:We,muted:We,name:null,nonce:null,noModule:We,noValidate:We,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:We,optimum:Y,pattern:null,ping:wt,placeholder:null,playsInline:We,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:We,referrerPolicy:null,rel:wt,required:We,reversed:We,rows:Y,rowSpan:Y,sandbox:wt,scope:null,scoped:We,seamless:We,selected:We,shadowRootClonable:We,shadowRootDelegatesFocus:We,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:zt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:We,useMap:null,value:zt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wt,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:We,declare:We,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:We,noHref:We,noShade:We,noWrap:We,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:zt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:We,disableRemotePlayback:We,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:lc});var $C=ur({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:_n,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:wt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:We,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:To,g2:To,glyphName:To,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:_n,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_n,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_n,rev:_n,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_n,requiredFeatures:_n,requiredFonts:_n,requiredFormats:_n,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:_n,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_n,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_n,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ac});var sh=ur({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});var ah=ur({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:lc});var lh=ur({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var ch={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var D4=/[A-Z]/g,UC=/-[a-z]/g,R4=/^data[-\w.:]+$/i;function uh(e,t){let n=na(t),r=t,o=sn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&R4.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(UC,N4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!UC.test(i)){let s=i.replace(D4,z4);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=Xo}return new o(r,t)}function z4(e){return"-"+e.toLowerCase()}function N4(e){return e.charAt(1).toUpperCase()}var jC=rh([ih,_C,sh,ah,lh],"html"),cc=rh([ih,$C,sh,ah,lh],"svg");function HC(e){return e.join(" ").trim()}var o1=Aa(e1(),1);var pc=t1("end"),Oi=t1("start");function t1(e){return t;function t(n){let r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function fh(e){let t=Oi(e),n=pc(e);if(t&&n)return{start:t,end:n}}function Io(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?n1(e.position):"start"in e||"end"in e?n1(e):"line"in e||"column"in e?gh(e):""}function gh(e){return r1(e&&e.line)+":"+r1(e&&e.column)}function n1(e){return gh(e&&e.start)+"-"+gh(e&&e.end)}function r1(e){return e&&typeof e=="number"?e:1}var Ht=class extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},s=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(s=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){let u=r.indexOf(":");u===-1?i.ruleId=r:(i.source=r.slice(0,u),i.ruleId=r.slice(u+1))}if(!i.place&&i.ancestors&&i.ancestors){let u=i.ancestors[i.ancestors.length-1];u&&(i.place=u.position)}let a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=a?a.line:void 0,this.name=Io(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=s&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Ht.prototype.file="";Ht.prototype.name="";Ht.prototype.reason="";Ht.prototype.message="";Ht.prototype.stack="";Ht.prototype.column=void 0;Ht.prototype.line=void 0;Ht.prototype.ancestors=void 0;Ht.prototype.cause=void 0;Ht.prototype.fatal=void 0;Ht.prototype.place=void 0;Ht.prototype.ruleId=void 0;Ht.prototype.source=void 0;var mh={}.hasOwnProperty,cU=new Map,uU=/[A-Z]/g,pU=new Set(["table","tbody","thead","tfoot","tr"]),dU=new Set(["td","th"]),i1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function hh(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=SU(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=bU(n,t.jsx,t.jsxs)}let o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?cc:jC,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=s1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function s1(e,t,n){if(t.type==="element")return fU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return gU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return hU(e,t,n);if(t.type==="mdxjsEsm")return mU(e,t);if(t.type==="root")return xU(e,t,n);if(t.type==="text")return yU(e,t)}function fU(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=cc,e.schema=o),e.ancestors.push(t);let i=l1(e,t.tagName,!1),s=wU(e,t),a=yh(e,t);return pU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!nh(u):!0})),a1(e,s,i,t),xh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function gU(e,t){if(t.data&&t.data.estree&&e.evaluater){let r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ia(e,t.position)}function mU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ia(e,t.position)}function hU(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=cc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:l1(e,t.name,!0),s=vU(e,t),a=yh(e,t);return a1(e,s,i,t),xh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function xU(e,t,n){let r={};return xh(r,yh(e,t)),e.create(t,e.Fragment,r,n)}function yU(e,t){return t.value}function a1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function xh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function bU(e,t,n){return r;function r(o,i,s,a){let c=Array.isArray(s.children)?n:t;return a?c(i,s,a):c(i,s)}}function SU(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Oi(r);return t(o,i,s,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function wU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&mh.call(t.properties,o)){let i=kU(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&dU.has(t.tagName)?r=a:n[s]=a}}if(r){let i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function vU(e,t){let n={};for(let r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){let i=r.data.estree.body[0];i.type;let s=i.expression;s.type;let a=s.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ia(e,t.position);else{let o=r.name,i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){let a=r.value.data.estree.body[0];a.type,i=e.evaluater.evaluateExpression(a.expression)}else ia(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function yh(e,t){let n=[],r=-1,o=e.passKeys?new Map:cU;for(;++r<t.children.length;){let i=t.children[r],s;if(e.passKeys){let u=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(u){let c=o.get(u)||0;s=u+"-"+c,o.set(u,c+1)}}let a=s1(e,i,s);a!==void 0&&n.push(a)}return n}function kU(e,t,n){let r=uh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?zC(n):HC(n)),r.property==="style"){let o=typeof n=="object"?n:CU(e,String(n));return e.stylePropertyNameCase==="css"&&(o=TU(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?ch[r.property]||r.property:r.attribute,n]}}function CU(e,t){try{return(0,o1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Ht("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=i1+"#cannot-parse-style-attribute",o}}function l1(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){let o=t.split("."),i=-1,s;for(;++i<o.length;){let a=ic(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};s=s?{type:"MemberExpression",object:s,property:a,computed:!!(i&&a.type==="Literal"),optional:!1}:a}r=s}else r=ic(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return mh.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);ia(e)}function ia(e,t){let n=new Ht("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=i1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function TU(e){let t={},n;for(n in e)mh.call(e,n)&&(t[IU(n)]=e[n]);return t}function IU(e){let t=e.replace(uU,FU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function FU(e){return"-"+e.toLowerCase()}var sa={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};import{Fragment as R5,jsx as z5,jsxs as N5}from"react/jsx-runtime";import{useEffect as ope,useState as ipe}from"react";var EU={};function bh(e,t){let n=t||EU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return u1(e,r,o)}function u1(e,t,n){if(AU(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return c1(e.children,t,n)}return Array.isArray(e)?c1(e,t,n):""}function c1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=u1(e[o],t,n);return r.join("")}function AU(e){return!!(e&&typeof e=="object")}var p1=document.createElement("i");function _i(e){let t="&"+e+";";p1.innerHTML=t;let n=p1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dn(e,t,n,r){let o=e.length,i=0,s;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function Tn(e,t){return e.length>0?(dn(e,e.length,0,t),e):t}var d1={}.hasOwnProperty;function f1(e){let t={},n=-1;for(;++n<e.length;)PU(t,e[n]);return t}function PU(e,t){let n;for(n in t){let o=(d1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){d1.call(o,s)||(o[s]=[]);let a=i[s];LU(o[s],Array.isArray(a)?a:a?[a]:[])}}}function LU(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dn(e,0,0,r)}function dc(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function Zr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Xn=Fo(/[A-Za-z]/),an=Fo(/[\dA-Za-z]/),g1=Fo(/[#-'*+\--9=?A-Z^-~]/);function aa(e){return e!==null&&(e<32||e===127)}var la=Fo(/\d/),m1=Fo(/[\dA-Fa-f]/),h1=Fo(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Wt(e){return e!==null&&(e<0||e===32)}function $e(e){return e===-2||e===-1||e===32}var x1=Fo(/\p{P}|\p{S}/u),y1=Fo(/\s/);function Fo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&an(e.charCodeAt(n+1))&&an(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(s=String.fromCharCode(i));else if(i>55295&&i<57344){let a=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(s=String.fromCharCode(i,a),o=1):s="\uFFFD"}else s=String.fromCharCode(i);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+o+1,s=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Ve(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return $e(u)?(e.enter(n),a(u)):t(u)}function a(u){return $e(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var b1={tokenize:MU};function MU(e){let t=e.attempt(this.parser.constructs.contentInitial,r,o),n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ve(e,t,"linePrefix")}function o(a){return e.enter("paragraph"),i(a)}function i(a){let u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,s(a)}function s(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ue(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var w1={tokenize:BU},S1={tokenize:DU};function BU(e){let t=this,n=[],r=0,o,i,s;return a;function a(R){if(r<n.length){let z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,u,c)(R)}return c(R)}function u(R){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&k();let z=t.events.length,_=z,M;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){M=t.events[_][1].end;break}F(r);let B=z;for(;B<t.events.length;)t.events[B][1].end={...M},B++;return dn(t.events,_+1,0,t.events.slice(z)),t.events.length=B,c(R)}return a(R)}function c(R){if(r===n.length){if(!o)return f(R);if(o.currentConstruct&&o.currentConstruct.concrete)return g(R);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(S1,l,d)(R)}function l(R){return o&&k(),F(r),f(R)}function d(R){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,g(R)}function f(R){return t.containerState={},e.attempt(S1,p,g)(R)}function p(R){return r++,n.push([t.currentConstruct,t.containerState]),f(R)}function g(R){if(R===null){o&&k(),F(0),e.consume(R);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),S(R)}function S(R){if(R===null){C(e.exit("chunkFlow"),!0),F(0),e.consume(R);return}return ue(R)?(e.consume(R),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(R),S)}function C(R,z){let _=t.sliceStream(R);if(z&&_.push(null),R.previous=i,i&&(i.next=R),i=R,o.defineSkip(R.start),o.write(_),t.parser.lazy[R.start.line]){let M=o.events.length;for(;M--;)if(o.events[M][1].start.offset<s&&(!o.events[M][1].end||o.events[M][1].end.offset>s))return;let B=t.events.length,m=B,x,b;for(;m--;)if(t.events[m][0]==="exit"&&t.events[m][1].type==="chunkFlow"){if(x){b=t.events[m][1].end;break}x=!0}for(F(r),M=B;M<t.events.length;)t.events[M][1].end={...b},M++;dn(t.events,m+1,0,t.events.slice(B)),t.events.length=M}}function F(R){let z=n.length;for(;z-- >R;){let _=n[z];t.containerState=_[1],_[0].exit.call(t,e)}n.length=R}function k(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function DU(e,t,n){return Ve(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Sh(e){if(e===null||Wt(e)||y1(e))return 1;if(x1(e))return 2}function $i(e,t,n){let r=[],o=-1;for(;++o<e.length;){let i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}var ca={name:"attention",resolveAll:RU,tokenize:zU};function RU(e,t){let n=-1,r,o,i,s,a,u,c,l;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};v1(d,-u),v1(f,u),s={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},e[r][1].end={...s.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Tn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Tn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Tn(c,$i(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Tn(c,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(l=2,c=Tn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,dn(e,r-1,n-r+3,c),n=r+c.length-l-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function zU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Sh(r),i;return s;function s(u){return i=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===i)return e.consume(u),a;let c=e.exit("attentionSequence"),l=Sh(u),d=!l||l===2&&o||n.includes(u),f=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?d:d&&(o||!f)),c._close=!!(i===42?f:f&&(l||!d)),t(u)}}function v1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var wh={name:"autolink",tokenize:NU};function NU(e,t,n){let r=0;return o;function o(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return Xn(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||an(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,u):(p===43||p===45||p===46||an(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function u(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||aa(p)?n(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),l):g1(p)?(e.consume(p),c):n(p)}function l(p){return an(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,l):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||an(p))&&r++<63){let g=p===45?f:d;return e.consume(p),g}return n(p)}}var Eo={partial:!0,tokenize:OU};function OU(e,t,n){return r;function r(i){return $e(i)?Ve(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ue(i)?t(i):n(i)}}var fc={continuation:{tokenize:$U},exit:UU,name:"blockQuote",tokenize:_U};function _U(e,t,n){let r=this;return o;function o(s){if(s===62){let a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(s),e.exit("blockQuoteMarker"),i}return n(s)}function i(s){return $e(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function $U(e,t,n){let r=this;return o;function o(s){return $e(s)?Ve(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(fc,t,n)(s)}}function UU(e){e.exit("blockQuote")}var gc={name:"characterEscape",tokenize:jU};function jU(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return h1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var mc={name:"characterReference",tokenize:HU};function HU(e,t,n){let r=this,o=0,i,s;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),u}function u(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,s=an,l(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,s=m1,l):(e.enter("characterReferenceValue"),i=7,s=la,l(d))}function l(d){if(d===59&&o){let f=e.exit("characterReferenceValue");return s===an&&!_i(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(d)&&o++<i?(e.consume(d),l):n(d)}}var k1={partial:!0,tokenize:VU},hc={concrete:!0,name:"codeFenced",tokenize:WU};function WU(e,t,n){let r=this,o={partial:!0,tokenize:_},i=0,s=0,a;return u;function u(M){return c(M)}function c(M){let B=r.events[r.events.length-1];return i=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,a=M,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(M)}function l(M){return M===a?(s++,e.consume(M),l):s<3?n(M):(e.exit("codeFencedFenceSequence"),$e(M)?Ve(e,d,"whitespace")(M):d(M))}function d(M){return M===null||ue(M)?(e.exit("codeFencedFence"),r.interrupt?t(M):e.check(k1,S,z)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(M))}function f(M){return M===null||ue(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(M)):$e(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(M)):M===96&&M===a?n(M):(e.consume(M),f)}function p(M){return M===null||ue(M)?d(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(M))}function g(M){return M===null||ue(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(M)):M===96&&M===a?n(M):(e.consume(M),g)}function S(M){return e.attempt(o,z,C)(M)}function C(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),F}function F(M){return i>0&&$e(M)?Ve(e,k,"linePrefix",i+1)(M):k(M)}function k(M){return M===null||ue(M)?e.check(k1,S,z)(M):(e.enter("codeFlowValue"),R(M))}function R(M){return M===null||ue(M)?(e.exit("codeFlowValue"),k(M)):(e.consume(M),R)}function z(M){return e.exit("codeFenced"),t(M)}function _(M,B,m){let x=0;return b;function b(v){return M.enter("lineEnding"),M.consume(v),M.exit("lineEnding"),E}function E(v){return M.enter("codeFencedFence"),$e(v)?Ve(M,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):h(v)}function h(v){return v===a?(M.enter("codeFencedFenceSequence"),T(v)):m(v)}function T(v){return v===a?(x++,M.consume(v),T):x>=s?(M.exit("codeFencedFenceSequence"),$e(v)?Ve(M,I,"whitespace")(v):I(v)):m(v)}function I(v){return v===null||ue(v)?(M.exit("codeFencedFence"),B(v)):m(v)}}}function VU(e,t,n){let r=this;return o;function o(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}var ua={name:"codeIndented",tokenize:qU},GU={partial:!0,tokenize:YU};function qU(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),Ve(e,i,"linePrefix",5)(c)}function i(c){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?u(c):ue(c)?e.attempt(GU,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ue(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function YU(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):ue(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):Ve(e,i,"linePrefix",5)(s)}function i(s){let a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):ue(s)?o(s):n(s)}}var vh={name:"codeText",previous:XU,resolve:KU,tokenize:QU};function KU(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function XU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function QU(e,t,n){let r=this,o=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),o++,u):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(f))}function l(f){return f===null||f===32||f===96||ue(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),l)}function d(f){return f===96?(e.consume(f),i++,d):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",l(f))}}var xc=class{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){let r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){let o=n||0;this.setCursor(Math.trunc(t));let i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&pa(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),pa(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),pa(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){let n=this.left.splice(t,Number.POSITIVE_INFINITY);pa(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);pa(this.left,n.reverse())}}};function pa(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function yc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new xc(e);for(;++n<l.length;){for(;n in t;)n=t[n];if(r=l.get(n),n&&r[1].type==="chunkFlow"&&l.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,i=0,i<u.length&&u[i][1].type==="lineEndingBlank"&&(i+=2),i<u.length&&u[i][1].type==="content"))for(;++i<u.length&&u[i][1].type!=="content";)u[i][1].type==="chunkText"&&(u[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,JU(l,n)),n=t[n],c=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(s=l.get(i),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(o&&(l.get(o)[1].type="lineEndingBlank"),s[1].type="lineEnding",o=i);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;o&&(r[1].end={...l.get(o)[1].start},a=l.slice(o,n),a.unshift(r),l.splice(o,n-o+1,a))}}return dn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function JU(e,t){let n=e.get(t)[1],r=e.get(t)[2],o=t-1,i=[],s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let a=s.events,u=[],c={},l,d,f=-1,p=n,g=0,S=0,C=[S];for(;p;){for(;e.get(++o)[1]!==p;);i.push(o),p._tokenizer||(l=r.sliceStream(p),p.next||l.push(null),d&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(l),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(S=f+1,C.push(S),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):C.pop(),f=C.length;f--;){let F=a.slice(C[f],C[f+1]),k=i.pop();u.push([k,k+F.length-1]),e.splice(k,2,F)}for(u.reverse(),f=-1;++f<u.length;)c[g+u[f][0]]=g+u[f][1],g+=u[f][1]-u[f][0]-1;return c}var kh={resolve:e3,tokenize:t3},ZU={partial:!0,tokenize:n3};function e3(e){return yc(e),e}function t3(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(a)}function o(a){return a===null?i(a):ue(a)?e.check(ZU,s,i)(a):(e.consume(a),o)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function s(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function n3(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ve(e,i,"linePrefix")}function i(s){if(s===null||ue(s))return n(s);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function bc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return d;function d(F){return F===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(F),e.exit(i),f):F===null||F===32||F===41||aa(F)?n(F):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),S(F))}function f(F){return F===62?(e.enter(i),e.consume(F),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(F))}function p(F){return F===62?(e.exit("chunkString"),e.exit(a),f(F)):F===null||F===60||ue(F)?n(F):(e.consume(F),F===92?g:p)}function g(F){return F===60||F===62||F===92?(e.consume(F),p):p(F)}function S(F){return!l&&(F===null||F===41||Wt(F))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(F)):l<c&&F===40?(e.consume(F),l++,S):F===41?(e.consume(F),l--,S):F===null||F===32||F===40||aa(F)?n(F):(e.consume(F),F===92?C:S)}function C(F){return F===40||F===41||F===92?(e.consume(F),S):S(F)}}function Sc(e,t,n,r,o,i){let s=this,a=0,u;return c;function c(p){return e.enter(r),e.enter(o),e.consume(p),e.exit(o),e.enter(i),l}function l(p){return a>999||p===null||p===91||p===93&&!u||p===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(p):p===93?(e.exit(i),e.enter(o),e.consume(p),e.exit(o),e.exit(r),t):ue(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||ue(p)||a++>999?(e.exit("chunkString"),l(p)):(e.consume(p),u||(u=!$e(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function wc(e,t,n,r,o,i){let s;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(o),e.consume(f),e.exit(o),s=f===40?41:f,u):n(f)}function u(f){return f===s?(e.enter(o),e.consume(f),e.exit(o),e.exit(r),t):(e.enter(i),c(f))}function c(f){return f===s?(e.exit(i),u(s)):f===null?n(f):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===s||f===null||ue(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:l)}function d(f){return f===s||f===92?(e.consume(f),l):l(f)}}function Jo(e,t){let n;return r;function r(o){return ue(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):$e(o)?Ve(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Ch={name:"definition",tokenize:o3},r3={partial:!0,tokenize:i3};function o3(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return Sc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return o=Zr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),u):n(p)}function u(p){return Wt(p)?Jo(e,c)(p):c(p)}function c(p){return bc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(r3,d,d)(p)}function d(p){return $e(p)?Ve(e,f,"whitespace")(p):f(p)}function f(p){return p===null||ue(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function i3(e,t,n){return r;function r(a){return Wt(a)?Jo(e,o)(a):n(a)}function o(a){return wc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return $e(a)?Ve(e,s,"whitespace")(a):s(a)}function s(a){return a===null||ue(a)?t(a):n(a)}}var Th={name:"hardBreakEscape",tokenize:s3};function s3(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return ue(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var Ih={name:"headingAtx",resolve:a3,tokenize:l3};function a3(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},dn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function l3(e,t,n){let r=0;return o;function o(l){return e.enter("atxHeading"),i(l)}function i(l){return e.enter("atxHeadingSequence"),s(l)}function s(l){return l===35&&r++<6?(e.consume(l),s):l===null||Wt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||ue(l)?(e.exit("atxHeading"),t(l)):$e(l)?Ve(e,a,"whitespace")(l):(e.enter("atxHeadingText"),c(l))}function u(l){return l===35?(e.consume(l),u):(e.exit("atxHeadingSequence"),a(l))}function c(l){return l===null||l===35||Wt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var C1=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Fh=["pre","script","style","textarea"];var Eh={concrete:!0,name:"htmlFlow",resolveTo:p3,tokenize:d3},c3={partial:!0,tokenize:g3},u3={partial:!0,tokenize:f3};function p3(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function d3(e,t,n){let r=this,o,i,s,a,u;return c;function c(L){return l(L)}function l(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),d}function d(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),i=!0,S):L===63?(e.consume(L),o=3,r.interrupt?t:w):Xn(L)?(e.consume(L),s=String.fromCharCode(L),C):n(L)}function f(L){return L===45?(e.consume(L),o=2,p):L===91?(e.consume(L),o=5,a=0,g):Xn(L)?(e.consume(L),o=4,r.interrupt?t:w):n(L)}function p(L){return L===45?(e.consume(L),r.interrupt?t:w):n(L)}function g(L){let K="CDATA[";return L===K.charCodeAt(a++)?(e.consume(L),a===K.length?r.interrupt?t:h:g):n(L)}function S(L){return Xn(L)?(e.consume(L),s=String.fromCharCode(L),C):n(L)}function C(L){if(L===null||L===47||L===62||Wt(L)){let K=L===47,ee=s.toLowerCase();return!K&&!i&&Fh.includes(ee)?(o=1,r.interrupt?t(L):h(L)):C1.includes(s.toLowerCase())?(o=6,K?(e.consume(L),F):r.interrupt?t(L):h(L)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):i?k(L):R(L))}return L===45||an(L)?(e.consume(L),s+=String.fromCharCode(L),C):n(L)}function F(L){return L===62?(e.consume(L),r.interrupt?t:h):n(L)}function k(L){return $e(L)?(e.consume(L),k):b(L)}function R(L){return L===47?(e.consume(L),b):L===58||L===95||Xn(L)?(e.consume(L),z):$e(L)?(e.consume(L),R):b(L)}function z(L){return L===45||L===46||L===58||L===95||an(L)?(e.consume(L),z):_(L)}function _(L){return L===61?(e.consume(L),M):$e(L)?(e.consume(L),_):R(L)}function M(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),u=L,B):$e(L)?(e.consume(L),M):m(L)}function B(L){return L===u?(e.consume(L),u=null,x):L===null||ue(L)?n(L):(e.consume(L),B)}function m(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||Wt(L)?_(L):(e.consume(L),m)}function x(L){return L===47||L===62||$e(L)?R(L):n(L)}function b(L){return L===62?(e.consume(L),E):n(L)}function E(L){return L===null||ue(L)?h(L):$e(L)?(e.consume(L),E):n(L)}function h(L){return L===45&&o===2?(e.consume(L),A):L===60&&o===1?(e.consume(L),P):L===62&&o===4?(e.consume(L),j):L===63&&o===3?(e.consume(L),w):L===93&&o===5?(e.consume(L),N):ue(L)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(c3,G,T)(L)):L===null||ue(L)?(e.exit("htmlFlowData"),T(L)):(e.consume(L),h)}function T(L){return e.check(u3,I,G)(L)}function I(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),v}function v(L){return L===null||ue(L)?T(L):(e.enter("htmlFlowData"),h(L))}function A(L){return L===45?(e.consume(L),w):h(L)}function P(L){return L===47?(e.consume(L),s="",D):h(L)}function D(L){if(L===62){let K=s.toLowerCase();return Fh.includes(K)?(e.consume(L),j):h(L)}return Xn(L)&&s.length<8?(e.consume(L),s+=String.fromCharCode(L),D):h(L)}function N(L){return L===93?(e.consume(L),w):h(L)}function w(L){return L===62?(e.consume(L),j):L===45&&o===2?(e.consume(L),w):h(L)}function j(L){return L===null||ue(L)?(e.exit("htmlFlowData"),G(L)):(e.consume(L),j)}function G(L){return e.exit("htmlFlow"),t(L)}}function f3(e,t,n){let r=this;return o;function o(s){return ue(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):n(s)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function g3(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Eo,t,n)}}var Ah={name:"htmlText",tokenize:m3};function m3(e,t,n){let r=this,o,i,s;return a;function a(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),u}function u(w){return w===33?(e.consume(w),c):w===47?(e.consume(w),_):w===63?(e.consume(w),R):Xn(w)?(e.consume(w),m):n(w)}function c(w){return w===45?(e.consume(w),l):w===91?(e.consume(w),i=0,g):Xn(w)?(e.consume(w),k):n(w)}function l(w){return w===45?(e.consume(w),p):n(w)}function d(w){return w===null?n(w):w===45?(e.consume(w),f):ue(w)?(s=d,P(w)):(e.consume(w),d)}function f(w){return w===45?(e.consume(w),p):d(w)}function p(w){return w===62?A(w):w===45?f(w):d(w)}function g(w){let j="CDATA[";return w===j.charCodeAt(i++)?(e.consume(w),i===j.length?S:g):n(w)}function S(w){return w===null?n(w):w===93?(e.consume(w),C):ue(w)?(s=S,P(w)):(e.consume(w),S)}function C(w){return w===93?(e.consume(w),F):S(w)}function F(w){return w===62?A(w):w===93?(e.consume(w),F):S(w)}function k(w){return w===null||w===62?A(w):ue(w)?(s=k,P(w)):(e.consume(w),k)}function R(w){return w===null?n(w):w===63?(e.consume(w),z):ue(w)?(s=R,P(w)):(e.consume(w),R)}function z(w){return w===62?A(w):R(w)}function _(w){return Xn(w)?(e.consume(w),M):n(w)}function M(w){return w===45||an(w)?(e.consume(w),M):B(w)}function B(w){return ue(w)?(s=B,P(w)):$e(w)?(e.consume(w),B):A(w)}function m(w){return w===45||an(w)?(e.consume(w),m):w===47||w===62||Wt(w)?x(w):n(w)}function x(w){return w===47?(e.consume(w),A):w===58||w===95||Xn(w)?(e.consume(w),b):ue(w)?(s=x,P(w)):$e(w)?(e.consume(w),x):A(w)}function b(w){return w===45||w===46||w===58||w===95||an(w)?(e.consume(w),b):E(w)}function E(w){return w===61?(e.consume(w),h):ue(w)?(s=E,P(w)):$e(w)?(e.consume(w),E):x(w)}function h(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),o=w,T):ue(w)?(s=h,P(w)):$e(w)?(e.consume(w),h):(e.consume(w),I)}function T(w){return w===o?(e.consume(w),o=void 0,v):w===null?n(w):ue(w)?(s=T,P(w)):(e.consume(w),T)}function I(w){return w===null||w===34||w===39||w===60||w===61||w===96?n(w):w===47||w===62||Wt(w)?x(w):(e.consume(w),I)}function v(w){return w===47||w===62||Wt(w)?x(w):n(w)}function A(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):n(w)}function P(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),D}function D(w){return $e(w)?Ve(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):N(w)}function N(w){return e.enter("htmlTextData"),s(w)}}var Zo={name:"labelEnd",resolveAll:b3,resolveTo:S3,tokenize:w3},h3={tokenize:v3},x3={tokenize:k3},y3={tokenize:C3};function b3(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&dn(e,0,e.length,n),e}function S3(e,t){let n=e.length,r=0,o,i,s,a;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(s){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(s=n);let u={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[i][1].start},end:{...e[s][1].end}},l={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[s-2][1].start}};return a=[["enter",u,t],["enter",c,t]],a=Tn(a,e.slice(i+1,i+r+3)),a=Tn(a,[["enter",l,t]]),a=Tn(a,$i(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Tn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Tn(a,e.slice(s+1)),a=Tn(a,[["exit",u,t]]),dn(e,i,e.length,a),e}function w3(e,t,n){let r=this,o=r.events.length,i,s;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return a;function a(f){return i?i._inactive?d(f):(s=r.parser.defined.includes(Zr(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),u):n(f)}function u(f){return f===40?e.attempt(h3,l,s?l:d)(f):f===91?e.attempt(x3,l,s?c:d)(f):s?l(f):d(f)}function c(f){return e.attempt(y3,l,d)(f)}function l(f){return t(f)}function d(f){return i._balanced=!0,n(f)}}function v3(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),o}function o(d){return Wt(d)?Jo(e,i)(d):i(d)}function i(d){return d===41?l(d):bc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return Wt(d)?Jo(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?wc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return Wt(d)?Jo(e,l)(d):l(d)}function l(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function k3(e,t,n){let r=this;return o;function o(a){return Sc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(Zr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function C3(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}var Ph={name:"labelStartImage",resolveAll:Zo.resolveAll,tokenize:T3};function T3(e,t,n){let r=this;return o;function o(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),s):n(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}var Lh={name:"labelStartLink",resolveAll:Zo.resolveAll,tokenize:I3};function I3(e,t,n){let r=this;return o;function o(s){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelLink"),i}function i(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}var da={name:"lineEnding",tokenize:F3};function F3(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}var ei={name:"thematicBreak",tokenize:E3};function E3(e,t,n){let r=0,o;return i;function i(c){return e.enter("thematicBreak"),s(c)}function s(c){return o=c,a(c)}function a(c){return c===o?(e.enter("thematicBreakSequence"),u(c)):r>=3&&(c===null||ue(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),$e(c)?Ve(e,a,"whitespace")(c):a(c))}}var yn={continuation:{tokenize:M3},exit:D3,name:"list",tokenize:L3},A3={partial:!0,tokenize:R3},P3={partial:!0,tokenize:B3};function L3(e,t,n){let r=this,o=r.events[r.events.length-1],i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,s=0;return a;function a(p){let g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:la(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(ei,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(p)}return n(p)}function u(p){return la(p)&&++s<10?(e.consume(p),u):(!r.interrupt||s<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Eo,r.interrupt?n:l,e.attempt(A3,f,d))}function l(p){return r.containerState.initialBlankLine=!0,i++,f(p)}function d(p){return $e(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function M3(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Eo,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!$e(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(P3,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(yn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function B3(e,t,n){let r=this;return Ve(e,o,"listItemIndent",r.containerState.size+1);function o(i){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(i):n(i)}}function D3(e){e.exit(this.containerState.type)}function R3(e,t,n){let r=this;return Ve(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){let s=r.events[r.events.length-1];return!$e(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var vc={name:"setextUnderline",resolveTo:z3,tokenize:N3};function z3(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);let s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",s,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=s,e.push(["exit",s,t]),e}function N3(e,t,n){let r=this,o;return i;function i(c){let l=r.events.length,d;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){d=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),o=c,s(c)):n(c)}function s(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===o?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),$e(c)?Ve(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||ue(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var T1={tokenize:O3};function O3(e){let t=this,n=e.attempt(Eo,r,e.attempt(this.parser.constructs.flowInitial,o,Ve(e,e.attempt(this.parser.constructs.flow,o,e.attempt(kh,o)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}var I1={resolveAll:P1()},F1=A1("string"),E1=A1("text");function A1(e){return{resolveAll:P1(e==="text"?_3:void 0),tokenize:t};function t(n){let r=this,o=this.parser.constructs[e],i=n.attempt(o,s,a);return s;function s(l){return c(l)?i(l):a(l)}function a(l){if(l===null){n.consume(l);return}return n.enter("data"),n.consume(l),u}function u(l){return c(l)?(n.exit("data"),i(l)):(n.consume(l),u)}function c(l){if(l===null)return!0;let d=o[l],f=-1;if(d)for(;++f<d.length;){let p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function P1(e){return t;function t(n,r){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,r):n}}function _3(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){let r=e[n-1][1],o=t.sliceStream(r),i=o.length,s=-1,a=0,u;for(;i--;){let c=o[i];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)u=!0,a++;else if(c!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){let c={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:r.start._bufferIndex+s,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}var Mh={};ye(Mh,{attentionMarkers:()=>q3,contentInitial:()=>U3,disable:()=>Y3,document:()=>$3,flow:()=>H3,flowInitial:()=>j3,insideSpan:()=>G3,string:()=>W3,text:()=>V3});var $3={42:yn,43:yn,45:yn,48:yn,49:yn,50:yn,51:yn,52:yn,53:yn,54:yn,55:yn,56:yn,57:yn,62:fc},U3={91:Ch},j3={[-2]:ua,[-1]:ua,32:ua},H3={35:Ih,42:ei,45:[vc,ei],60:Eh,61:vc,95:ei,96:hc,126:hc},W3={38:mc,92:gc},V3={[-5]:da,[-4]:da,[-3]:da,33:Ph,38:mc,42:ca,60:[wh,Ah],91:Lh,92:[Th,gc],93:Zo,95:ca,96:vh},G3={null:[ca,I1]},q3={null:[42,95]},Y3={null:[]};function L1(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},o={},i=[],s=[],a=[],u=!0,c={attempt:x(B),check:x(m),consume:z,enter:_,exit:M,interrupt:x(m,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:C,parser:e,previous:null,sliceSerialize:g,sliceStream:S,write:p},d=t.tokenize.call(l,c),f;return t.resolveAll&&i.push(t),l;function p(T){return s=Tn(s,T),k(),s[s.length-1]!==null?[]:(b(t,0),l.events=$i(i,l.events,l),l.events)}function g(T,I){return X3(S(T),I)}function S(T){return K3(s,T)}function C(){let{_bufferIndex:T,_index:I,line:v,column:A,offset:P}=r;return{_bufferIndex:T,_index:I,line:v,column:A,offset:P}}function F(T){o[T.line]=T.column,h()}function k(){let T;for(;r._index<s.length;){let I=s[r._index];if(typeof I=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<I.length;)R(I.charCodeAt(r._bufferIndex));else R(I)}}function R(T){u=void 0,f=T,d=d(T)}function z(T){ue(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,h()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=T,u=!0}function _(T,I){let v=I||{};return v.type=T,v.start=C(),l.events.push(["enter",v,l]),a.push(v),v}function M(T){let I=a.pop();return I.end=C(),l.events.push(["exit",I,l]),I}function B(T,I){b(T,I.from)}function m(T,I){I.restore()}function x(T,I){return v;function v(A,P,D){let N,w,j,G;return Array.isArray(A)?K(A):"tokenize"in A?K([A]):L(A);function L(ae){return qe;function qe(tt){let se=tt!==null&&ae[tt],pe=tt!==null&&ae.null,Ie=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(pe)?pe:pe?[pe]:[]];return K(Ie)(tt)}}function K(ae){return N=ae,w=0,ae.length===0?D:ee(ae[w])}function ee(ae){return qe;function qe(tt){return G=E(),j=ae,ae.partial||(l.currentConstruct=ae),ae.name&&l.parser.constructs.disable.null.includes(ae.name)?de(tt):ae.tokenize.call(I?Object.assign(Object.create(l),I):l,c,re,de)(tt)}}function re(ae){return u=!0,T(j,G),P}function de(ae){return u=!0,G.restore(),++w<N.length?ee(N[w]):D}}}function b(T,I){T.resolveAll&&!i.includes(T)&&i.push(T),T.resolve&&dn(l.events,I,l.events.length-I,T.resolve(l.events.slice(I),l)),T.resolveTo&&(l.events=T.resolveTo(l.events,l))}function E(){let T=C(),I=l.previous,v=l.currentConstruct,A=l.events.length,P=Array.from(a);return{from:A,restore:D};function D(){r=T,l.previous=I,l.currentConstruct=v,l.events.length=A,a=P,h()}}function h(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function K3(e,t){let n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex,s;if(n===o)s=[e[n].slice(r,i)];else{if(s=e.slice(n,o),r>-1){let a=s[0];typeof a=="string"?s[0]=a.slice(r):s.shift()}i>0&&s.push(e[o].slice(0,i))}return s}function X3(e,t){let n=-1,r=[],o;for(;++n<e.length;){let i=e[n],s;if(typeof i=="string")s=i;else switch(i){case-5:{s="\r";break}case-4:{s=`
81
+ `,Cne=jt.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${r4} 0.8s linear infinite`,flexShrink:0})),FC=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#fee2e2",fontSize:"12px",fontWeight:700,color:"#dc2626",whiteSpace:"nowrap"}),o4=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#dcfce7",fontSize:"12px",fontWeight:700,color:"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"}),Tne=jt.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"-10px",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>6?"50%":"2px",animation:`${n4} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var zi=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),ea=jt.span(({color:e="#6b7280"})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:e,whiteSpace:"nowrap"})),EC=jt.span(({color:e="#6b7280"})=>({fontSize:"12px",color:e})),ta=jt.span(({color:e})=>({fontWeight:700,color:e})),i4=jt.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"12px",backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:"12px",color:t.textMutedColor},"& .score-value":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:"20px",fontWeight:700,color:e,lineHeight:1},"& .score-dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:e}})),Ine=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),Fne=jt.span(({color:e=le})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${Z$} 1.2s ease-in-out infinite`,marginRight:"4px"})),Ene=jt.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return le;case"score-high":return"#16a34a";case"score-medium":return"#ca8a04";case"score-low":return"#dc2626";case"cost":return"#7c3aed";case"tokens":return e.color.mediumdark;case"analyzing":return le;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${t4} 1.5s ease-in-out infinite`}:{}})),Ane=jt.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Pne=jt.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),s4=jt.button(({theme:e,isExporting:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",fontSize:"11px",fontWeight:600,color:t?e.color.mediumdark:"#7c3aed",backgroundColor:t?e.background.hoverable:"#ede9fe",border:"none",borderRadius:"12px",cursor:t?"not-allowed":"pointer",transition:"all 0.2s",whiteSpace:"nowrap","&:hover":{backgroundColor:t?e.background.hoverable:"#ddd6fe"}})),a4=jt.span({display:"inline-block",width:"10px",height:"10px",border:"2px solid #c4b5fd",borderTopColor:"#7c3aed",borderRadius:"50%",animation:"export-spin 0.8s linear infinite","@keyframes export-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),l4=jt.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${e4} 1.2s linear infinite`,flexShrink:0}),c4=({color:e=le})=>Ce.createElement(l4,null,Ce.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},Array.from({length:8}).map((t,n)=>{let o=n*360/8*Math.PI/180,i=12+Math.cos(o)*4,s=12+Math.sin(o)*4,a=12+Math.cos(o)*10,u=12+Math.sin(o)*10;return Ce.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Lne=jt.span(({color:e="#6b7280"})=>({fontSize:"12px",fontWeight:500,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",animation:`${AC} 0.3s ease-out`}));function u4(e){let[t,n]=Q$(0);return J$(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var PC=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,visualSimilarity:i,costUsd:s,inputTokens:a,outputTokens:u,showTimer:c=!0,cacheCreationTokens:l,cacheReadTokens:d,durationSeconds:f})=>{let p=u4(e||t),{exportPDF:g,isExporting:S}=cm(),{featureFlags:C}=ie(),F=C.showCosts,k=3.65,R=m=>m<.01?`$${m.toFixed(4)}`:m<.1?`$${m.toFixed(3)}`:`$${m.toFixed(2)}`,z=m=>{let x=m*k;return x<.01?`\u20AA${x.toFixed(4)}`:x<.1?`\u20AA${x.toFixed(3)}`:`\u20AA${x.toFixed(2)}`},_=m=>m>=1e3?`${(m/1e3).toFixed(1)}K`:m.toString(),M=m=>m>=80?"score-high":m>=50?"score-medium":"score-low",B=m=>m>=80?"high":m>=50?"medium":"low";if(e)return Ce.createElement(rh,null,Ce.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},p,"s \xB7 Esc to stop"));if(t)return Ce.createElement(rh,null,Ce.createElement(FC,null,Ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(c4,{color:"#7c3aed"}),Ce.createElement(ta,{color:"#7c3aed"},"Verifying...")),c&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement("span",{style:{color:"#6b7280"}},p,"s"))));if(r>0||o!==void 0){let m=(a||0)+(u||0),x=(d||0)>0,b=x&&a?Math.round(d/a*100):0,E=Math.max(o??0,i??0),h=I=>I>=80?"#16a34a":I>=50?"#ca8a04":"#dc2626",T=I=>I>=100?"\u25CF":I>=50?"\u25D0":"\u25CB";return Ce.createElement(rh,null,r===0?Ce.createElement(o4,null,Ce.createElement("span",null,"\u2713"),"Perfect!"):Ce.createElement(FC,null,Ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Ce.createElement(i4,{tint:h(E),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},Ce.createElement("span",{className:"score-dot"}),Ce.createElement("span",{className:"score-label"},"Score"),Ce.createElement("span",{className:"score-value"},E)),F&&s!==void 0&&s>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(ta,{color:"#16a34a"},R(s)),Ce.createElement("span",{style:{color:"#6b7280"}},"/"),Ce.createElement(ta,{color:"#16a34a"},z(s)))),F&&m>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${x?` \xB7 Cached: ${d?.toLocaleString()}`:""}`},Ce.createElement(EC,{color:"#7c3aed"},"#"),Ce.createElement(ta,{color:"#7c3aed"},_(m)),Ce.createElement("span",{style:{color:"#6b7280"}},"tokens"),x&&Ce.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",b,"%"))),f!==void 0&&f>0&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zi,null,"|"),Ce.createElement(ea,null,Ce.createElement(EC,{color:"#6b7280"},"\u23F1"),Ce.createElement(ta,{color:"#6b7280"},f,"s"))),Ce.createElement(zi,null,"|"),Ce.createElement(s4,{onClick:g,disabled:S,isExporting:S,title:"Download design review report as PDF"},S?Ce.createElement(Ce.Fragment,null,Ce.createElement(a4,null),"Exporting..."):Ce.createElement(Ce.Fragment,null,"\u2193 Report")))}return null};var m4=Cn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),$ne=Cn.div({display:"flex",gap:"8px",alignItems:"center"}),h4=g4({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),x4=Cn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${h4} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),y4=Cn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),b4=Cn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"16px",padding:"14px 18px",borderRadius:"14px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02)",flexWrap:"wrap"})),S4=Cn.button(({theme:e,variant:t="orange",disabled:n})=>{let r={green:n?e.textMutedColor:e.color.positive||"#10b981",purple:n?e.textMutedColor:"#7c3aed",yellow:n?e.textMutedColor:"#c4b5fd",orange:n?e.textMutedColor:La},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:"#ffffff",border:"none",padding:"12px 24px",fontSize:"14px",fontWeight:600,borderRadius:"10px",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,whiteSpace:"nowrap",transition:"all 0.2s",boxShadow:n?"none":`0 2px 6px rgba(${o}, 0.3)`,flexShrink:0,"&:hover":{opacity:n?.6:.9,transform:n?"none":"translateY(-1px)",boxShadow:n?"none":`0 4px 10px rgba(${o}, 0.4)`}}}),w4=Cn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),v4=Cn.div({marginLeft:"auto",display:"flex",flexDirection:"column",gap:"4px"}),k4=Cn.label(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),C4=Cn(En)({width:"auto",minWidth:"200px"}),T4=Cn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),LC=Cn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),MC=Cn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?La:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),BC=Cn.div(({checked:e})=>({width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#fff",position:"absolute",top:"2px",left:e?"16px":"2px",transition:"left 0.2s ease",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.2)"})),DC=Cn.input({position:"absolute",opacity:0,width:0,height:0}),I4=()=>{let[e,t]=d4(0),n=f4();RC(()=>(n.current=setInterval(()=>t(s=>s+1),1e3),()=>clearInterval(n.current)),[]);let r=Math.floor(e/60),o=e%60,i=`${r}:${o.toString().padStart(2,"0")}`;return ft.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},oh=()=>{let{sessionToken:e}=Bs(),{usageData:t}=we(),{selectedProjectId:n}=qr(),{currentMapping:r,hasMapping:o}=Ho(),{loadingMapping:i,currentStoryId:s}=rt(),{startReview:a,cancelReview:u,isReviewing:c}=Jg(),{isLoadingScreenshots:l}=Uo(),{storybookImageUrl:d,figmaImageUrl:f,currentReviewId:p,reviewHistory:g,setReviewDetailTab:S,setReviewResults:C,setFigmaImageUrl:F,setStorybookImageUrl:k,setFullPrompt:R,setFullResponse:z,includeTextComparison:_,setIncludeTextComparison:M,usePromptCache:B,setUsePromptCache:m,isValidating:x,validationUsage:b,isGenerating:E,isApplying:h,streamingStatus:T,featureFlags:I,userRole:v,roleOverride:A,isReviewing:P}=ie(),D=t?.reviewCredits??Math.floor(t?.creditBalance??0),N=g.find(he=>he.id===p),j=(N?.issues||[]).filter(he=>!he.dismissed).length,G=N?.complianceScore,L=N?.visualSimilarity,K=(N?.costUsd||0)+(b?.costUsd||0),ee=(N?.inputTokens||0)+(b?.inputTokens||0),re=(N?.outputTokens||0)+(b?.outputTokens||0),de=p4(()=>{let he=s?g.filter(ne=>ne.storyId===s):g,vt=he.filter(ne=>!ne.parentReviewId).sort((ne,W)=>new Date(W.createdAt).getTime()-new Date(ne.createdAt).getTime()),Ge=he.filter(ne=>ne.parentReviewId),lt=[];for(let ne of vt){lt.push(ne);let W=Ge.filter(Ae=>Ae.parentReviewId===ne.id).sort((Ae,ge)=>(Ae.iterationNumber||0)-(ge.iterationNumber||0));lt.push(...W)}let nt=Ge.filter(ne=>!vt.some(W=>W.id===ne.parentReviewId));return lt.push(...nt),lt},[g,s]);RC(()=>{if(!c)return;let he=vt=>{vt.key==="Escape"&&(vt.preventDefault(),u())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[c,u]);let ae=o&&r?.figmaNodeId,qe=E||h,tt=!!(e&&n&&!c&&!l&&!qe&&s&&d&&ae&&f),se=async(he=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{S("chat"),await a({isIteration:he,parentReviewId:he?p:void 0})}catch(vt){console.error("[ReviewActions] Review error:",vt)}},pe=()=>se(!1),Ie=he=>{let vt=he.target.value;if(vt){let Ge=g.find(lt=>lt.id===vt);Ge&&(C({id:Ge.id,componentId:Ge.componentId,storyId:Ge.storyId,modelId:Ge.modelId,complianceScore:Ge.complianceScore,issuesCount:Ge.issuesCount,issues:Ge.issues,createdAt:new Date(Ge.createdAt),visualSimilarity:Ge.visualSimilarity,timestamp:new Date(Ge.createdAt).toISOString()}),Ge.figmaImageData&&F(Ge.figmaImageData),Ge.storybookImageData&&k(Ge.storybookImageData),(A??v)==="admin"&&(R(Ge.aiPrompt||""),z(Ge.aiResponse||"")),S("issues"))}},ze=he=>{let vt=new Date(he),lt=new Date().getTime()-vt.getTime(),nt=Math.floor(lt/6e4),ne=Math.floor(lt/36e5),W=Math.floor(lt/864e5);return nt<1?"Just now":nt<60?`${nt}m ago`:ne<24?`${ne}h ago`:W<7?`${W}d ago`:vt.toLocaleDateString()},me=he=>he?he.includes("haiku")?"Haiku":he.includes("sonnet")?"Sonnet":he.includes("opus")?"Opus":he.includes("gpt-4o-mini")?"GPT-4o mini":he.includes("gpt-4o")?"GPT-4o":he.includes("gpt-4")?"GPT-4":he.includes("o3")?"o3":he.includes("o1")?"o1":he.split("-")[0]||"":"",Nt=he=>{let vt=he.split("--"),Ge=vt[vt.length-1]||he;return Ge.charAt(0).toUpperCase()+Ge.slice(1)};return ft.createElement("div",null,ft.createElement(m4,null,I.enableModelSelection&&ft.createElement(IC,null),ft.createElement(T4,null,ft.createElement(LC,{title:"Compare text content between Figma design and Storybook component"},ft.createElement(DC,{type:"checkbox",checked:_,onChange:he=>M(he.target.checked)}),ft.createElement(MC,{checked:_},ft.createElement(BC,{checked:_})),"Compare text"),I.showCosts&&ft.createElement(LC,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ft.createElement(DC,{type:"checkbox",checked:B,onChange:he=>m(he.target.checked)}),ft.createElement(MC,{checked:B},ft.createElement(BC,{checked:B})),"Cache prompt")),ft.createElement(b4,null,ft.createElement(S4,{variant:c?"yellow":"purple",disabled:c?!1:!tt,onClick:c?u:pe,title:c?"Click to stop review":e?n?s?ae?l?"Loading screenshots...":qe?"Wait for fixes to complete...":d?f?"Review this component implementation":"Waiting for Figma design image...":"Waiting for Storybook screenshot...":'Figma mapping required - use "Map to Figma" in the Review tab':"No story selected":"Please select a project first":"Please connect to UI Copilot first"},c?ft.createElement(ft.Fragment,null,ft.createElement(x4,null),"Reviewing",ft.createElement(I4,null)):ft.createElement(ft.Fragment,null,ft.createElement(y4,null,ft.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ft.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ft.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),P?null:x||N?ft.createElement(PC,{isReviewing:!1,isValidating:x,streamingStatus:T,issueCount:j,score:G,visualSimilarity:L,costUsd:K||N?.costUsd,inputTokens:ee||N?.inputTokens,outputTokens:re||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,de.length>0&&ft.createElement(v4,null,ft.createElement(k4,null,"Review History"),ft.createElement(C4,{value:p||"",onChange:Ie},ft.createElement("option",{value:""},"Select a review..."),de.map(he=>{let vt=!!he.parentReviewId,Ge=vt?" \u21B3 ":"\u25CF ",lt=vt&&he.iterationNumber?`Iter ${he.iterationNumber} - `:"",nt=he.issuesCount??he.issues?.length??0,ne=he.complianceScore??"--",W=me(he.modelId);return ft.createElement("option",{key:he.id,value:he.id},Ge,lt,ze(he.createdAt)," - ",nt," issues (",ne,"%)",W?` \xB7 ${W}`:"",he.storyId?` \xB7 ${Nt(he.storyId)}`:"")}))))),!ae&&!i&&ft.createElement(w4,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import Hne,{useState as Wne}from"react";import{styled as zC}from"storybook/theming";var qne=zC.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Yne=zC(io)({padding:"8px 12px",fontSize:"12px"});import Qne,{useState as Jne}from"react";import{styled as ih}from"storybook/theming";ve();je();De();pt();var ire=ih.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),sre=ih(Er)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),are=ih.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import ure from"react";import{styled as F4}from"storybook/theming";var fre=F4.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));ve();import hre from"react";import{styled as Rr}from"storybook/theming";var bre=Rr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),Sre=Rr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),wre=Rr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),vre=Rr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),kre=Rr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Cre=Rr.div(({theme:e,progress:t})=>({height:"100%",backgroundColor:t===100?e.color.positive||"#10b981":e.color.secondary,width:`${t}%`,transition:"width 0.3s ease, background-color 0.3s ease"})),Tre=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),Ire=Rr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),Fre=Rr.div(({theme:e})=>({display:"inline-block",width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:e.color.secondary,borderRadius:"50%",animation:"spin 0.8s linear infinite",marginLeft:"8px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Ere=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));ve();import Lre,{useState as Mre}from"react";import{styled as zr}from"storybook/theming";var Rre=zr.div(({theme:e})=>{let t=(e.base==="dark","102, 126, 234");return{padding:"10px 12px",backgroundColor:`rgba(${t}, 0.08)`,borderRadius:"6px",marginBottom:"16px",border:`1px solid rgba(${t}, 0.2)`}}),zre=zr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),Nre=zr.div({display:"flex",alignItems:"center",gap:"8px"}),Ore=zr.span({fontSize:"12px",opacity:.7}),_re=zr.span({fontSize:"13px",fontWeight:500}),$re=zr.div(({score:e,theme:t})=>({display:"inline-block",padding:"4px 10px",borderRadius:"12px",fontSize:"13px",fontWeight:600,backgroundColor:e>=90?t.color.positive||"#10b981":e>=70?t.color.warning||"#f59e0b":t.color.negative||"#ef4444",color:t.color.inverseText})),Ure=zr.div({marginTop:"12px",fontSize:"11px"}),jre=zr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),Hre=zr.div(({status:e,theme:t})=>({display:"flex",alignItems:"center",gap:"4px",color:e==="success"?"inherit":e==="success"?t.color.positive||"#10b981":e==="warning"?t.color.warning||"#f59e0b":t.color.negative||"#ef4444"})),Wre=zr.span({fontSize:"12px"});De();je();import Xt from"react";import{styled as Qi}from"storybook/theming";import Tr,{useEffect as gW}from"react";import{styled as ya}from"storybook/theming";ve();import ni,{useState as H5}from"react";import{styled as Wi}from"storybook/theming";var NC={fontBase:'"Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontMono:'"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace',sizeXs:"11px",sizeSm:"12px",sizeMd:"13px",sizeLg:"14px",sizeXl:"16px",weightRegular:400,weightMedium:500,weightBold:600};function OC(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var E4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,A4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P4={};function sc(e,t){return((t||P4).jsx?A4:E4).test(e)}var L4=/[ \t\n\f\r]/g;function sh(e){return typeof e=="object"?e.type==="text"?_C(e.value):!1:_C(e)}function _C(e){return e.replace(L4,"")===""}var Jr=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Jr.prototype.normal={};Jr.prototype.property={};Jr.prototype.space=void 0;function ah(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Jr(n,r,t)}function na(e){return e.toLowerCase()}var sn=class{constructor(t,n){this.attribute=n,this.property=t}};sn.prototype.attribute="";sn.prototype.booleanish=!1;sn.prototype.boolean=!1;sn.prototype.commaOrSpaceSeparated=!1;sn.prototype.commaSeparated=!1;sn.prototype.defined=!1;sn.prototype.mustUseProperty=!1;sn.prototype.number=!1;sn.prototype.overloadedBoolean=!1;sn.prototype.property="";sn.prototype.spaceSeparated=!1;sn.prototype.space=void 0;var ra={};ye(ra,{boolean:()=>We,booleanish:()=>zt,commaOrSpaceSeparated:()=>_n,commaSeparated:()=>To,number:()=>Y,overloadedBoolean:()=>ac,spaceSeparated:()=>St});var M4=0,We=Ko(),zt=Ko(),ac=Ko(),Y=Ko(),St=Ko(),To=Ko(),_n=Ko();function Ko(){return 2**++M4}var lh=Object.keys(ra),Xo=class extends sn{constructor(t,n,r,o){let i=-1;if(super(t,n),$C(this,"space",o),typeof r=="number")for(;++i<lh.length;){let s=lh[i];$C(this,lh[i],(r&ra[s])===ra[s])}}};Xo.prototype.defined=!0;function $C(e,t,n){n&&(e[t]=n)}function ur(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new Xo(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[na(r)]=r,n[na(i.attribute)]=r}return new Jr(t,n,e.space)}var ch=ur({properties:{ariaActiveDescendant:null,ariaAtomic:zt,ariaAutoComplete:null,ariaBusy:zt,ariaChecked:zt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:St,ariaCurrent:null,ariaDescribedBy:St,ariaDetails:null,ariaDisabled:zt,ariaDropEffect:St,ariaErrorMessage:null,ariaExpanded:zt,ariaFlowTo:St,ariaGrabbed:zt,ariaHasPopup:null,ariaHidden:zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:St,ariaLevel:Y,ariaLive:null,ariaModal:zt,ariaMultiLine:zt,ariaMultiSelectable:zt,ariaOrientation:null,ariaOwns:St,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:zt,ariaReadOnly:zt,ariaRelevant:null,ariaRequired:zt,ariaRoleDescription:St,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:zt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function lc(e,t){return t in e?e[t]:t}function cc(e,t){return lc(e,t.toLowerCase())}var UC=ur({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:To,acceptCharset:St,accessKey:St,action:null,allow:null,allowFullScreen:We,allowPaymentRequest:We,allowUserMedia:We,alt:null,as:null,async:We,autoCapitalize:null,autoComplete:St,autoFocus:We,autoPlay:We,blocking:St,capture:null,charSet:null,checked:We,cite:null,className:St,cols:Y,colSpan:null,content:null,contentEditable:zt,controls:We,controlsList:St,coords:Y|To,crossOrigin:null,data:null,dateTime:null,decoding:null,default:We,defer:We,dir:null,dirName:null,disabled:We,download:ac,draggable:zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:We,formTarget:null,headers:St,height:Y,hidden:ac,high:Y,href:null,hrefLang:null,htmlFor:St,httpEquiv:St,id:null,imageSizes:null,imageSrcSet:null,inert:We,inputMode:null,integrity:null,is:null,isMap:We,itemId:null,itemProp:St,itemRef:St,itemScope:We,itemType:St,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:We,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:We,muted:We,name:null,nonce:null,noModule:We,noValidate:We,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:We,optimum:Y,pattern:null,ping:St,placeholder:null,playsInline:We,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:We,referrerPolicy:null,rel:St,required:We,reversed:We,rows:Y,rowSpan:Y,sandbox:St,scope:null,scoped:We,seamless:We,selected:We,shadowRootClonable:We,shadowRootDelegatesFocus:We,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:zt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:We,useMap:null,value:zt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:St,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:We,declare:We,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:We,noHref:We,noShade:We,noWrap:We,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:zt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:We,disableRemotePlayback:We,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:cc});var jC=ur({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:_n,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:St,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:We,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:To,g2:To,glyphName:To,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:_n,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:St,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_n,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_n,rev:_n,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_n,requiredFeatures:_n,requiredFonts:_n,requiredFormats:_n,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:_n,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_n,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_n,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:lc});var uh=ur({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});var ph=ur({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:cc});var dh=ur({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var fh={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var B4=/[A-Z]/g,HC=/-[a-z]/g,D4=/^data[-\w.:]+$/i;function gh(e,t){let n=na(t),r=t,o=sn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&D4.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(HC,z4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!HC.test(i)){let s=i.replace(B4,R4);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=Xo}return new o(r,t)}function R4(e){return"-"+e.toLowerCase()}function z4(e){return e.charAt(1).toUpperCase()}var WC=ah([ch,UC,uh,ph,dh],"html"),uc=ah([ch,jC,uh,ph,dh],"svg");function VC(e){return e.join(" ").trim()}var s1=Pa(n1(),1);var dc=r1("end"),Oi=r1("start");function r1(e){return t;function t(n){let r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function xh(e){let t=Oi(e),n=dc(e);if(t&&n)return{start:t,end:n}}function Io(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?o1(e.position):"start"in e||"end"in e?o1(e):"line"in e||"column"in e?yh(e):""}function yh(e){return i1(e&&e.line)+":"+i1(e&&e.column)}function o1(e){return yh(e&&e.start)+"-"+yh(e&&e.end)}function i1(e){return e&&typeof e=="number"?e:1}var Ht=class extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},s=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(s=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){let u=r.indexOf(":");u===-1?i.ruleId=r:(i.source=r.slice(0,u),i.ruleId=r.slice(u+1))}if(!i.place&&i.ancestors&&i.ancestors){let u=i.ancestors[i.ancestors.length-1];u&&(i.place=u.position)}let a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=a?a.line:void 0,this.name=Io(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=s&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Ht.prototype.file="";Ht.prototype.name="";Ht.prototype.reason="";Ht.prototype.message="";Ht.prototype.stack="";Ht.prototype.column=void 0;Ht.prototype.line=void 0;Ht.prototype.ancestors=void 0;Ht.prototype.cause=void 0;Ht.prototype.fatal=void 0;Ht.prototype.place=void 0;Ht.prototype.ruleId=void 0;Ht.prototype.source=void 0;var bh={}.hasOwnProperty,lU=new Map,cU=/[A-Z]/g,uU=new Set(["table","tbody","thead","tfoot","tr"]),pU=new Set(["td","th"]),a1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Sh(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=bU(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=yU(n,t.jsx,t.jsxs)}let o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?uc:WC,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=l1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function l1(e,t,n){if(t.type==="element")return dU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return fU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return mU(e,t,n);if(t.type==="mdxjsEsm")return gU(e,t);if(t.type==="root")return hU(e,t,n);if(t.type==="text")return xU(e,t)}function dU(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=uc,e.schema=o),e.ancestors.push(t);let i=u1(e,t.tagName,!1),s=SU(e,t),a=vh(e,t);return uU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!sh(u):!0})),c1(e,s,i,t),wh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function fU(e,t){if(t.data&&t.data.estree&&e.evaluater){let r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ia(e,t.position)}function gU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ia(e,t.position)}function mU(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=uc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:u1(e,t.name,!0),s=wU(e,t),a=vh(e,t);return c1(e,s,i,t),wh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function hU(e,t,n){let r={};return wh(r,vh(e,t)),e.create(t,e.Fragment,r,n)}function xU(e,t){return t.value}function c1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function wh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function yU(e,t,n){return r;function r(o,i,s,a){let c=Array.isArray(s.children)?n:t;return a?c(i,s,a):c(i,s)}}function bU(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Oi(r);return t(o,i,s,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function SU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&bh.call(t.properties,o)){let i=vU(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&pU.has(t.tagName)?r=a:n[s]=a}}if(r){let i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function wU(e,t){let n={};for(let r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){let i=r.data.estree.body[0];i.type;let s=i.expression;s.type;let a=s.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ia(e,t.position);else{let o=r.name,i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){let a=r.value.data.estree.body[0];a.type,i=e.evaluater.evaluateExpression(a.expression)}else ia(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function vh(e,t){let n=[],r=-1,o=e.passKeys?new Map:lU;for(;++r<t.children.length;){let i=t.children[r],s;if(e.passKeys){let u=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(u){let c=o.get(u)||0;s=u+"-"+c,o.set(u,c+1)}}let a=l1(e,i,s);a!==void 0&&n.push(a)}return n}function vU(e,t,n){let r=gh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?OC(n):VC(n)),r.property==="style"){let o=typeof n=="object"?n:kU(e,String(n));return e.stylePropertyNameCase==="css"&&(o=CU(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?fh[r.property]||r.property:r.attribute,n]}}function kU(e,t){try{return(0,s1.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Ht("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=a1+"#cannot-parse-style-attribute",o}}function u1(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){let o=t.split("."),i=-1,s;for(;++i<o.length;){let a=sc(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};s=s?{type:"MemberExpression",object:s,property:a,computed:!!(i&&a.type==="Literal"),optional:!1}:a}r=s}else r=sc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return bh.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);ia(e)}function ia(e,t){let n=new Ht("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=a1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function CU(e){let t={},n;for(n in e)bh.call(e,n)&&(t[TU(n)]=e[n]);return t}function TU(e){let t=e.replace(cU,IU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function IU(e){return"-"+e.toLowerCase()}var sa={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};import{Fragment as D5,jsx as R5,jsxs as z5}from"react/jsx-runtime";import{useEffect as npe,useState as rpe}from"react";var FU={};function kh(e,t){let n=t||FU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return d1(e,r,o)}function d1(e,t,n){if(EU(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return p1(e.children,t,n)}return Array.isArray(e)?p1(e,t,n):""}function p1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=d1(e[o],t,n);return r.join("")}function EU(e){return!!(e&&typeof e=="object")}var f1=document.createElement("i");function _i(e){let t="&"+e+";";f1.innerHTML=t;let n=f1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dn(e,t,n,r){let o=e.length,i=0,s;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function Tn(e,t){return e.length>0?(dn(e,e.length,0,t),e):t}var g1={}.hasOwnProperty;function m1(e){let t={},n=-1;for(;++n<e.length;)AU(t,e[n]);return t}function AU(e,t){let n;for(n in t){let o=(g1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){g1.call(o,s)||(o[s]=[]);let a=i[s];PU(o[s],Array.isArray(a)?a:a?[a]:[])}}}function PU(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dn(e,0,0,r)}function fc(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function Zr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Xn=Fo(/[A-Za-z]/),an=Fo(/[\dA-Za-z]/),h1=Fo(/[#-'*+\--9=?A-Z^-~]/);function aa(e){return e!==null&&(e<32||e===127)}var la=Fo(/\d/),x1=Fo(/[\dA-Fa-f]/),y1=Fo(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Wt(e){return e!==null&&(e<0||e===32)}function $e(e){return e===-2||e===-1||e===32}var b1=Fo(/\p{P}|\p{S}/u),S1=Fo(/\s/);function Fo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&an(e.charCodeAt(n+1))&&an(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(s=String.fromCharCode(i));else if(i>55295&&i<57344){let a=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(s=String.fromCharCode(i,a),o=1):s="\uFFFD"}else s=String.fromCharCode(i);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+o+1,s=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Ve(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return $e(u)?(e.enter(n),a(u)):t(u)}function a(u){return $e(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var w1={tokenize:LU};function LU(e){let t=e.attempt(this.parser.constructs.contentInitial,r,o),n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ve(e,t,"linePrefix")}function o(a){return e.enter("paragraph"),i(a)}function i(a){let u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,s(a)}function s(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ue(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var k1={tokenize:MU},v1={tokenize:BU};function MU(e){let t=this,n=[],r=0,o,i,s;return a;function a(R){if(r<n.length){let z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,u,c)(R)}return c(R)}function u(R){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&k();let z=t.events.length,_=z,M;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){M=t.events[_][1].end;break}F(r);let B=z;for(;B<t.events.length;)t.events[B][1].end={...M},B++;return dn(t.events,_+1,0,t.events.slice(z)),t.events.length=B,c(R)}return a(R)}function c(R){if(r===n.length){if(!o)return f(R);if(o.currentConstruct&&o.currentConstruct.concrete)return g(R);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(v1,l,d)(R)}function l(R){return o&&k(),F(r),f(R)}function d(R){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,g(R)}function f(R){return t.containerState={},e.attempt(v1,p,g)(R)}function p(R){return r++,n.push([t.currentConstruct,t.containerState]),f(R)}function g(R){if(R===null){o&&k(),F(0),e.consume(R);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),S(R)}function S(R){if(R===null){C(e.exit("chunkFlow"),!0),F(0),e.consume(R);return}return ue(R)?(e.consume(R),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(R),S)}function C(R,z){let _=t.sliceStream(R);if(z&&_.push(null),R.previous=i,i&&(i.next=R),i=R,o.defineSkip(R.start),o.write(_),t.parser.lazy[R.start.line]){let M=o.events.length;for(;M--;)if(o.events[M][1].start.offset<s&&(!o.events[M][1].end||o.events[M][1].end.offset>s))return;let B=t.events.length,m=B,x,b;for(;m--;)if(t.events[m][0]==="exit"&&t.events[m][1].type==="chunkFlow"){if(x){b=t.events[m][1].end;break}x=!0}for(F(r),M=B;M<t.events.length;)t.events[M][1].end={...b},M++;dn(t.events,m+1,0,t.events.slice(B)),t.events.length=M}}function F(R){let z=n.length;for(;z-- >R;){let _=n[z];t.containerState=_[1],_[0].exit.call(t,e)}n.length=R}function k(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function BU(e,t,n){return Ve(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ch(e){if(e===null||Wt(e)||S1(e))return 1;if(b1(e))return 2}function $i(e,t,n){let r=[],o=-1;for(;++o<e.length;){let i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}var ca={name:"attention",resolveAll:DU,tokenize:RU};function DU(e,t){let n=-1,r,o,i,s,a,u,c,l;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};C1(d,-u),C1(f,u),s={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},e[r][1].end={...s.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Tn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Tn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Tn(c,$i(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Tn(c,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(l=2,c=Tn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,dn(e,r-1,n-r+3,c),n=r+c.length-l-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function RU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Ch(r),i;return s;function s(u){return i=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===i)return e.consume(u),a;let c=e.exit("attentionSequence"),l=Ch(u),d=!l||l===2&&o||n.includes(u),f=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?d:d&&(o||!f)),c._close=!!(i===42?f:f&&(l||!d)),t(u)}}function C1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Th={name:"autolink",tokenize:zU};function zU(e,t,n){let r=0;return o;function o(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return Xn(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||an(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,u):(p===43||p===45||p===46||an(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function u(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||aa(p)?n(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),l):h1(p)?(e.consume(p),c):n(p)}function l(p){return an(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,l):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||an(p))&&r++<63){let g=p===45?f:d;return e.consume(p),g}return n(p)}}var Eo={partial:!0,tokenize:NU};function NU(e,t,n){return r;function r(i){return $e(i)?Ve(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ue(i)?t(i):n(i)}}var gc={continuation:{tokenize:_U},exit:$U,name:"blockQuote",tokenize:OU};function OU(e,t,n){let r=this;return o;function o(s){if(s===62){let a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(s),e.exit("blockQuoteMarker"),i}return n(s)}function i(s){return $e(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function _U(e,t,n){let r=this;return o;function o(s){return $e(s)?Ve(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(gc,t,n)(s)}}function $U(e){e.exit("blockQuote")}var mc={name:"characterEscape",tokenize:UU};function UU(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return y1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var hc={name:"characterReference",tokenize:jU};function jU(e,t,n){let r=this,o=0,i,s;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),u}function u(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,s=an,l(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,s=x1,l):(e.enter("characterReferenceValue"),i=7,s=la,l(d))}function l(d){if(d===59&&o){let f=e.exit("characterReferenceValue");return s===an&&!_i(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(d)&&o++<i?(e.consume(d),l):n(d)}}var T1={partial:!0,tokenize:WU},xc={concrete:!0,name:"codeFenced",tokenize:HU};function HU(e,t,n){let r=this,o={partial:!0,tokenize:_},i=0,s=0,a;return u;function u(M){return c(M)}function c(M){let B=r.events[r.events.length-1];return i=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,a=M,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(M)}function l(M){return M===a?(s++,e.consume(M),l):s<3?n(M):(e.exit("codeFencedFenceSequence"),$e(M)?Ve(e,d,"whitespace")(M):d(M))}function d(M){return M===null||ue(M)?(e.exit("codeFencedFence"),r.interrupt?t(M):e.check(T1,S,z)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(M))}function f(M){return M===null||ue(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(M)):$e(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(M)):M===96&&M===a?n(M):(e.consume(M),f)}function p(M){return M===null||ue(M)?d(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(M))}function g(M){return M===null||ue(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(M)):M===96&&M===a?n(M):(e.consume(M),g)}function S(M){return e.attempt(o,z,C)(M)}function C(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),F}function F(M){return i>0&&$e(M)?Ve(e,k,"linePrefix",i+1)(M):k(M)}function k(M){return M===null||ue(M)?e.check(T1,S,z)(M):(e.enter("codeFlowValue"),R(M))}function R(M){return M===null||ue(M)?(e.exit("codeFlowValue"),k(M)):(e.consume(M),R)}function z(M){return e.exit("codeFenced"),t(M)}function _(M,B,m){let x=0;return b;function b(v){return M.enter("lineEnding"),M.consume(v),M.exit("lineEnding"),E}function E(v){return M.enter("codeFencedFence"),$e(v)?Ve(M,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):h(v)}function h(v){return v===a?(M.enter("codeFencedFenceSequence"),T(v)):m(v)}function T(v){return v===a?(x++,M.consume(v),T):x>=s?(M.exit("codeFencedFenceSequence"),$e(v)?Ve(M,I,"whitespace")(v):I(v)):m(v)}function I(v){return v===null||ue(v)?(M.exit("codeFencedFence"),B(v)):m(v)}}}function WU(e,t,n){let r=this;return o;function o(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}var ua={name:"codeIndented",tokenize:GU},VU={partial:!0,tokenize:qU};function GU(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),Ve(e,i,"linePrefix",5)(c)}function i(c){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?u(c):ue(c)?e.attempt(VU,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ue(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function qU(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):ue(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):Ve(e,i,"linePrefix",5)(s)}function i(s){let a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):ue(s)?o(s):n(s)}}var Ih={name:"codeText",previous:KU,resolve:YU,tokenize:XU};function YU(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function KU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function XU(e,t,n){let r=this,o=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),o++,u):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(f))}function l(f){return f===null||f===32||f===96||ue(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),l)}function d(f){return f===96?(e.consume(f),i++,d):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",l(f))}}var yc=class{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){let r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){let o=n||0;this.setCursor(Math.trunc(t));let i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&pa(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),pa(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),pa(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){let n=this.left.splice(t,Number.POSITIVE_INFINITY);pa(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);pa(this.left,n.reverse())}}};function pa(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function bc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new yc(e);for(;++n<l.length;){for(;n in t;)n=t[n];if(r=l.get(n),n&&r[1].type==="chunkFlow"&&l.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,i=0,i<u.length&&u[i][1].type==="lineEndingBlank"&&(i+=2),i<u.length&&u[i][1].type==="content"))for(;++i<u.length&&u[i][1].type!=="content";)u[i][1].type==="chunkText"&&(u[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,QU(l,n)),n=t[n],c=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(s=l.get(i),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(o&&(l.get(o)[1].type="lineEndingBlank"),s[1].type="lineEnding",o=i);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;o&&(r[1].end={...l.get(o)[1].start},a=l.slice(o,n),a.unshift(r),l.splice(o,n-o+1,a))}}return dn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function QU(e,t){let n=e.get(t)[1],r=e.get(t)[2],o=t-1,i=[],s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let a=s.events,u=[],c={},l,d,f=-1,p=n,g=0,S=0,C=[S];for(;p;){for(;e.get(++o)[1]!==p;);i.push(o),p._tokenizer||(l=r.sliceStream(p),p.next||l.push(null),d&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(l),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(S=f+1,C.push(S),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):C.pop(),f=C.length;f--;){let F=a.slice(C[f],C[f+1]),k=i.pop();u.push([k,k+F.length-1]),e.splice(k,2,F)}for(u.reverse(),f=-1;++f<u.length;)c[g+u[f][0]]=g+u[f][1],g+=u[f][1]-u[f][0]-1;return c}var Fh={resolve:ZU,tokenize:e3},JU={partial:!0,tokenize:t3};function ZU(e){return bc(e),e}function e3(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(a)}function o(a){return a===null?i(a):ue(a)?e.check(JU,s,i)(a):(e.consume(a),o)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function s(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function t3(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ve(e,i,"linePrefix")}function i(s){if(s===null||ue(s))return n(s);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function Sc(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return d;function d(F){return F===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(F),e.exit(i),f):F===null||F===32||F===41||aa(F)?n(F):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),S(F))}function f(F){return F===62?(e.enter(i),e.consume(F),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(F))}function p(F){return F===62?(e.exit("chunkString"),e.exit(a),f(F)):F===null||F===60||ue(F)?n(F):(e.consume(F),F===92?g:p)}function g(F){return F===60||F===62||F===92?(e.consume(F),p):p(F)}function S(F){return!l&&(F===null||F===41||Wt(F))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(F)):l<c&&F===40?(e.consume(F),l++,S):F===41?(e.consume(F),l--,S):F===null||F===32||F===40||aa(F)?n(F):(e.consume(F),F===92?C:S)}function C(F){return F===40||F===41||F===92?(e.consume(F),S):S(F)}}function wc(e,t,n,r,o,i){let s=this,a=0,u;return c;function c(p){return e.enter(r),e.enter(o),e.consume(p),e.exit(o),e.enter(i),l}function l(p){return a>999||p===null||p===91||p===93&&!u||p===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(p):p===93?(e.exit(i),e.enter(o),e.consume(p),e.exit(o),e.exit(r),t):ue(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||ue(p)||a++>999?(e.exit("chunkString"),l(p)):(e.consume(p),u||(u=!$e(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function vc(e,t,n,r,o,i){let s;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(o),e.consume(f),e.exit(o),s=f===40?41:f,u):n(f)}function u(f){return f===s?(e.enter(o),e.consume(f),e.exit(o),e.exit(r),t):(e.enter(i),c(f))}function c(f){return f===s?(e.exit(i),u(s)):f===null?n(f):ue(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===s||f===null||ue(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:l)}function d(f){return f===s||f===92?(e.consume(f),l):l(f)}}function Jo(e,t){let n;return r;function r(o){return ue(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):$e(o)?Ve(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Eh={name:"definition",tokenize:r3},n3={partial:!0,tokenize:o3};function r3(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return wc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return o=Zr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),u):n(p)}function u(p){return Wt(p)?Jo(e,c)(p):c(p)}function c(p){return Sc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(n3,d,d)(p)}function d(p){return $e(p)?Ve(e,f,"whitespace")(p):f(p)}function f(p){return p===null||ue(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function o3(e,t,n){return r;function r(a){return Wt(a)?Jo(e,o)(a):n(a)}function o(a){return vc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return $e(a)?Ve(e,s,"whitespace")(a):s(a)}function s(a){return a===null||ue(a)?t(a):n(a)}}var Ah={name:"hardBreakEscape",tokenize:i3};function i3(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return ue(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var Ph={name:"headingAtx",resolve:s3,tokenize:a3};function s3(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},dn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function a3(e,t,n){let r=0;return o;function o(l){return e.enter("atxHeading"),i(l)}function i(l){return e.enter("atxHeadingSequence"),s(l)}function s(l){return l===35&&r++<6?(e.consume(l),s):l===null||Wt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||ue(l)?(e.exit("atxHeading"),t(l)):$e(l)?Ve(e,a,"whitespace")(l):(e.enter("atxHeadingText"),c(l))}function u(l){return l===35?(e.consume(l),u):(e.exit("atxHeadingSequence"),a(l))}function c(l){return l===null||l===35||Wt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var I1=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Lh=["pre","script","style","textarea"];var Mh={concrete:!0,name:"htmlFlow",resolveTo:u3,tokenize:p3},l3={partial:!0,tokenize:f3},c3={partial:!0,tokenize:d3};function u3(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function p3(e,t,n){let r=this,o,i,s,a,u;return c;function c(L){return l(L)}function l(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),d}function d(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),i=!0,S):L===63?(e.consume(L),o=3,r.interrupt?t:w):Xn(L)?(e.consume(L),s=String.fromCharCode(L),C):n(L)}function f(L){return L===45?(e.consume(L),o=2,p):L===91?(e.consume(L),o=5,a=0,g):Xn(L)?(e.consume(L),o=4,r.interrupt?t:w):n(L)}function p(L){return L===45?(e.consume(L),r.interrupt?t:w):n(L)}function g(L){let K="CDATA[";return L===K.charCodeAt(a++)?(e.consume(L),a===K.length?r.interrupt?t:h:g):n(L)}function S(L){return Xn(L)?(e.consume(L),s=String.fromCharCode(L),C):n(L)}function C(L){if(L===null||L===47||L===62||Wt(L)){let K=L===47,ee=s.toLowerCase();return!K&&!i&&Lh.includes(ee)?(o=1,r.interrupt?t(L):h(L)):I1.includes(s.toLowerCase())?(o=6,K?(e.consume(L),F):r.interrupt?t(L):h(L)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):i?k(L):R(L))}return L===45||an(L)?(e.consume(L),s+=String.fromCharCode(L),C):n(L)}function F(L){return L===62?(e.consume(L),r.interrupt?t:h):n(L)}function k(L){return $e(L)?(e.consume(L),k):b(L)}function R(L){return L===47?(e.consume(L),b):L===58||L===95||Xn(L)?(e.consume(L),z):$e(L)?(e.consume(L),R):b(L)}function z(L){return L===45||L===46||L===58||L===95||an(L)?(e.consume(L),z):_(L)}function _(L){return L===61?(e.consume(L),M):$e(L)?(e.consume(L),_):R(L)}function M(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),u=L,B):$e(L)?(e.consume(L),M):m(L)}function B(L){return L===u?(e.consume(L),u=null,x):L===null||ue(L)?n(L):(e.consume(L),B)}function m(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||Wt(L)?_(L):(e.consume(L),m)}function x(L){return L===47||L===62||$e(L)?R(L):n(L)}function b(L){return L===62?(e.consume(L),E):n(L)}function E(L){return L===null||ue(L)?h(L):$e(L)?(e.consume(L),E):n(L)}function h(L){return L===45&&o===2?(e.consume(L),A):L===60&&o===1?(e.consume(L),P):L===62&&o===4?(e.consume(L),j):L===63&&o===3?(e.consume(L),w):L===93&&o===5?(e.consume(L),N):ue(L)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(l3,G,T)(L)):L===null||ue(L)?(e.exit("htmlFlowData"),T(L)):(e.consume(L),h)}function T(L){return e.check(c3,I,G)(L)}function I(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),v}function v(L){return L===null||ue(L)?T(L):(e.enter("htmlFlowData"),h(L))}function A(L){return L===45?(e.consume(L),w):h(L)}function P(L){return L===47?(e.consume(L),s="",D):h(L)}function D(L){if(L===62){let K=s.toLowerCase();return Lh.includes(K)?(e.consume(L),j):h(L)}return Xn(L)&&s.length<8?(e.consume(L),s+=String.fromCharCode(L),D):h(L)}function N(L){return L===93?(e.consume(L),w):h(L)}function w(L){return L===62?(e.consume(L),j):L===45&&o===2?(e.consume(L),w):h(L)}function j(L){return L===null||ue(L)?(e.exit("htmlFlowData"),G(L)):(e.consume(L),j)}function G(L){return e.exit("htmlFlow"),t(L)}}function d3(e,t,n){let r=this;return o;function o(s){return ue(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):n(s)}function i(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function f3(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Eo,t,n)}}var Bh={name:"htmlText",tokenize:g3};function g3(e,t,n){let r=this,o,i,s;return a;function a(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),u}function u(w){return w===33?(e.consume(w),c):w===47?(e.consume(w),_):w===63?(e.consume(w),R):Xn(w)?(e.consume(w),m):n(w)}function c(w){return w===45?(e.consume(w),l):w===91?(e.consume(w),i=0,g):Xn(w)?(e.consume(w),k):n(w)}function l(w){return w===45?(e.consume(w),p):n(w)}function d(w){return w===null?n(w):w===45?(e.consume(w),f):ue(w)?(s=d,P(w)):(e.consume(w),d)}function f(w){return w===45?(e.consume(w),p):d(w)}function p(w){return w===62?A(w):w===45?f(w):d(w)}function g(w){let j="CDATA[";return w===j.charCodeAt(i++)?(e.consume(w),i===j.length?S:g):n(w)}function S(w){return w===null?n(w):w===93?(e.consume(w),C):ue(w)?(s=S,P(w)):(e.consume(w),S)}function C(w){return w===93?(e.consume(w),F):S(w)}function F(w){return w===62?A(w):w===93?(e.consume(w),F):S(w)}function k(w){return w===null||w===62?A(w):ue(w)?(s=k,P(w)):(e.consume(w),k)}function R(w){return w===null?n(w):w===63?(e.consume(w),z):ue(w)?(s=R,P(w)):(e.consume(w),R)}function z(w){return w===62?A(w):R(w)}function _(w){return Xn(w)?(e.consume(w),M):n(w)}function M(w){return w===45||an(w)?(e.consume(w),M):B(w)}function B(w){return ue(w)?(s=B,P(w)):$e(w)?(e.consume(w),B):A(w)}function m(w){return w===45||an(w)?(e.consume(w),m):w===47||w===62||Wt(w)?x(w):n(w)}function x(w){return w===47?(e.consume(w),A):w===58||w===95||Xn(w)?(e.consume(w),b):ue(w)?(s=x,P(w)):$e(w)?(e.consume(w),x):A(w)}function b(w){return w===45||w===46||w===58||w===95||an(w)?(e.consume(w),b):E(w)}function E(w){return w===61?(e.consume(w),h):ue(w)?(s=E,P(w)):$e(w)?(e.consume(w),E):x(w)}function h(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),o=w,T):ue(w)?(s=h,P(w)):$e(w)?(e.consume(w),h):(e.consume(w),I)}function T(w){return w===o?(e.consume(w),o=void 0,v):w===null?n(w):ue(w)?(s=T,P(w)):(e.consume(w),T)}function I(w){return w===null||w===34||w===39||w===60||w===61||w===96?n(w):w===47||w===62||Wt(w)?x(w):(e.consume(w),I)}function v(w){return w===47||w===62||Wt(w)?x(w):n(w)}function A(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):n(w)}function P(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),D}function D(w){return $e(w)?Ve(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):N(w)}function N(w){return e.enter("htmlTextData"),s(w)}}var Zo={name:"labelEnd",resolveAll:y3,resolveTo:b3,tokenize:S3},m3={tokenize:w3},h3={tokenize:v3},x3={tokenize:k3};function y3(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&dn(e,0,e.length,n),e}function b3(e,t){let n=e.length,r=0,o,i,s,a;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(s){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(s=n);let u={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[i][1].start},end:{...e[s][1].end}},l={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[s-2][1].start}};return a=[["enter",u,t],["enter",c,t]],a=Tn(a,e.slice(i+1,i+r+3)),a=Tn(a,[["enter",l,t]]),a=Tn(a,$i(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Tn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Tn(a,e.slice(s+1)),a=Tn(a,[["exit",u,t]]),dn(e,i,e.length,a),e}function S3(e,t,n){let r=this,o=r.events.length,i,s;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return a;function a(f){return i?i._inactive?d(f):(s=r.parser.defined.includes(Zr(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),u):n(f)}function u(f){return f===40?e.attempt(m3,l,s?l:d)(f):f===91?e.attempt(h3,l,s?c:d)(f):s?l(f):d(f)}function c(f){return e.attempt(x3,l,d)(f)}function l(f){return t(f)}function d(f){return i._balanced=!0,n(f)}}function w3(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),o}function o(d){return Wt(d)?Jo(e,i)(d):i(d)}function i(d){return d===41?l(d):Sc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return Wt(d)?Jo(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?vc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return Wt(d)?Jo(e,l)(d):l(d)}function l(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function v3(e,t,n){let r=this;return o;function o(a){return wc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(Zr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function k3(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}var Dh={name:"labelStartImage",resolveAll:Zo.resolveAll,tokenize:C3};function C3(e,t,n){let r=this;return o;function o(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),s):n(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}var Rh={name:"labelStartLink",resolveAll:Zo.resolveAll,tokenize:T3};function T3(e,t,n){let r=this;return o;function o(s){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelLink"),i}function i(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}var da={name:"lineEnding",tokenize:I3};function I3(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}var ei={name:"thematicBreak",tokenize:F3};function F3(e,t,n){let r=0,o;return i;function i(c){return e.enter("thematicBreak"),s(c)}function s(c){return o=c,a(c)}function a(c){return c===o?(e.enter("thematicBreakSequence"),u(c)):r>=3&&(c===null||ue(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),$e(c)?Ve(e,a,"whitespace")(c):a(c))}}var yn={continuation:{tokenize:L3},exit:B3,name:"list",tokenize:P3},E3={partial:!0,tokenize:D3},A3={partial:!0,tokenize:M3};function P3(e,t,n){let r=this,o=r.events[r.events.length-1],i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,s=0;return a;function a(p){let g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:la(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(ei,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(p)}return n(p)}function u(p){return la(p)&&++s<10?(e.consume(p),u):(!r.interrupt||s<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Eo,r.interrupt?n:l,e.attempt(E3,f,d))}function l(p){return r.containerState.initialBlankLine=!0,i++,f(p)}function d(p){return $e(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function L3(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Eo,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!$e(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(A3,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(yn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function M3(e,t,n){let r=this;return Ve(e,o,"listItemIndent",r.containerState.size+1);function o(i){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(i):n(i)}}function B3(e){e.exit(this.containerState.type)}function D3(e,t,n){let r=this;return Ve(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){let s=r.events[r.events.length-1];return!$e(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var kc={name:"setextUnderline",resolveTo:R3,tokenize:z3};function R3(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);let s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",s,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=s,e.push(["exit",s,t]),e}function z3(e,t,n){let r=this,o;return i;function i(c){let l=r.events.length,d;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){d=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),o=c,s(c)):n(c)}function s(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===o?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),$e(c)?Ve(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||ue(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var F1={tokenize:N3};function N3(e){let t=this,n=e.attempt(Eo,r,e.attempt(this.parser.constructs.flowInitial,o,Ve(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Fh,o)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}var E1={resolveAll:M1()},A1=L1("string"),P1=L1("text");function L1(e){return{resolveAll:M1(e==="text"?O3:void 0),tokenize:t};function t(n){let r=this,o=this.parser.constructs[e],i=n.attempt(o,s,a);return s;function s(l){return c(l)?i(l):a(l)}function a(l){if(l===null){n.consume(l);return}return n.enter("data"),n.consume(l),u}function u(l){return c(l)?(n.exit("data"),i(l)):(n.consume(l),u)}function c(l){if(l===null)return!0;let d=o[l],f=-1;if(d)for(;++f<d.length;){let p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function M1(e){return t;function t(n,r){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,r):n}}function O3(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){let r=e[n-1][1],o=t.sliceStream(r),i=o.length,s=-1,a=0,u;for(;i--;){let c=o[i];if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)u=!0,a++;else if(c!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){let c={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:r.start._bufferIndex+s,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}var zh={};ye(zh,{attentionMarkers:()=>G3,contentInitial:()=>$3,disable:()=>q3,document:()=>_3,flow:()=>j3,flowInitial:()=>U3,insideSpan:()=>V3,string:()=>H3,text:()=>W3});var _3={42:yn,43:yn,45:yn,48:yn,49:yn,50:yn,51:yn,52:yn,53:yn,54:yn,55:yn,56:yn,57:yn,62:gc},$3={91:Eh},U3={[-2]:ua,[-1]:ua,32:ua},j3={35:Ph,42:ei,45:[kc,ei],60:Mh,61:kc,95:ei,96:xc,126:xc},H3={38:hc,92:mc},W3={[-5]:da,[-4]:da,[-3]:da,33:Dh,38:hc,42:ca,60:[Th,Bh],91:Rh,92:[Ah,mc],93:Zo,95:ca,96:Ih},V3={null:[ca,E1]},G3={null:[42,95]},q3={null:[]};function B1(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},o={},i=[],s=[],a=[],u=!0,c={attempt:x(B),check:x(m),consume:z,enter:_,exit:M,interrupt:x(m,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:C,parser:e,previous:null,sliceSerialize:g,sliceStream:S,write:p},d=t.tokenize.call(l,c),f;return t.resolveAll&&i.push(t),l;function p(T){return s=Tn(s,T),k(),s[s.length-1]!==null?[]:(b(t,0),l.events=$i(i,l.events,l),l.events)}function g(T,I){return K3(S(T),I)}function S(T){return Y3(s,T)}function C(){let{_bufferIndex:T,_index:I,line:v,column:A,offset:P}=r;return{_bufferIndex:T,_index:I,line:v,column:A,offset:P}}function F(T){o[T.line]=T.column,h()}function k(){let T;for(;r._index<s.length;){let I=s[r._index];if(typeof I=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<I.length;)R(I.charCodeAt(r._bufferIndex));else R(I)}}function R(T){u=void 0,f=T,d=d(T)}function z(T){ue(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,h()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=T,u=!0}function _(T,I){let v=I||{};return v.type=T,v.start=C(),l.events.push(["enter",v,l]),a.push(v),v}function M(T){let I=a.pop();return I.end=C(),l.events.push(["exit",I,l]),I}function B(T,I){b(T,I.from)}function m(T,I){I.restore()}function x(T,I){return v;function v(A,P,D){let N,w,j,G;return Array.isArray(A)?K(A):"tokenize"in A?K([A]):L(A);function L(ae){return qe;function qe(tt){let se=tt!==null&&ae[tt],pe=tt!==null&&ae.null,Ie=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(pe)?pe:pe?[pe]:[]];return K(Ie)(tt)}}function K(ae){return N=ae,w=0,ae.length===0?D:ee(ae[w])}function ee(ae){return qe;function qe(tt){return G=E(),j=ae,ae.partial||(l.currentConstruct=ae),ae.name&&l.parser.constructs.disable.null.includes(ae.name)?de(tt):ae.tokenize.call(I?Object.assign(Object.create(l),I):l,c,re,de)(tt)}}function re(ae){return u=!0,T(j,G),P}function de(ae){return u=!0,G.restore(),++w<N.length?ee(N[w]):D}}}function b(T,I){T.resolveAll&&!i.includes(T)&&i.push(T),T.resolve&&dn(l.events,I,l.events.length-I,T.resolve(l.events.slice(I),l)),T.resolveTo&&(l.events=T.resolveTo(l.events,l))}function E(){let T=C(),I=l.previous,v=l.currentConstruct,A=l.events.length,P=Array.from(a);return{from:A,restore:D};function D(){r=T,l.previous=I,l.currentConstruct=v,l.events.length=A,a=P,h()}}function h(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function Y3(e,t){let n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex,s;if(n===o)s=[e[n].slice(r,i)];else{if(s=e.slice(n,o),r>-1){let a=s[0];typeof a=="string"?s[0]=a.slice(r):s.shift()}i>0&&s.push(e[o].slice(0,i))}return s}function K3(e,t){let n=-1,r=[],o;for(;++n<e.length;){let i=e[n],s;if(typeof i=="string")s=i;else switch(i){case-5:{s="\r";break}case-4:{s=`
82
82
  `;break}case-3:{s=`\r
83
- `;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&o)continue;s=" ";break}default:s=String.fromCharCode(i)}o=i===-2,r.push(s)}return r.join("")}function Bh(e){let r={constructs:f1([Mh,...(e||{}).extensions||[]]),content:o(b1),defined:[],document:o(w1),flow:o(T1),lazy:{},string:o(F1),text:o(E1)};return r;function o(i){return s;function s(a){return L1(r,i,a)}}}function Dh(e){for(;!yc(e););return e}var M1=/[\0\t\n\r]/g;function Rh(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,d,f,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(s||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(M1.lastIndex=d,c=M1.exec(i),f=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(f),!c){t=i.slice(d);break}if(p===10&&d===f&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<f&&(u.push(i.slice(d,f)),e+=f-d),p){case 0:{u.push(65533),e++;break}case 9:{for(l=Math.ceil(e/4)*4,u.push(-2);e++<l;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var Q3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function B1(e){return e.replace(Q3,J3)}function J3(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return dc(n.slice(i?2:1),i?16:10)}return _i(n)||e}var R1={}.hasOwnProperty;function zh(e,t,n){return typeof t!="string"&&(n=t,t=void 0),Z3(n)(Dh(Bh(n).document().write(Rh()(e,t,!0))))}function Z3(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ge),autolinkProtocol:x,autolinkEmail:x,atxHeading:i(me),blockQuote:i(tt),characterEscape:x,characterReference:x,codeFenced:i(se),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(se,s),codeText:i(pe,s),codeTextData:x,data:x,codeFlowValue:x,definition:i(Ie),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(ze),hardBreakEscape:i(Nt),hardBreakTrailing:i(Nt),htmlFlow:i(he,s),htmlFlowData:x,htmlText:i(he,s),htmlTextData:x,image:i(vt),label:s,link:i(Ge),listItem:i(nt),listItemValue:f,listOrdered:i(lt,d),listUnordered:i(lt),paragraph:i(ne),reference:L,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(me),strong:i(W),thematicBreak:i(ge)},exit:{atxHeading:u(),atxHeadingSequence:_,autolink:u(),autolinkEmail:qe,autolinkProtocol:ae,blockQuote:u(),characterEscapeValue:b,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:re,characterReference:de,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:b,codeIndented:u(F),codeText:u(v),codeTextData:b,data:b,definition:u(),definitionDestinationString:z,definitionLabelString:k,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(h),hardBreakTrailing:u(h),htmlFlow:u(T),htmlFlowData:b,htmlText:u(I),htmlTextData:b,image:u(P),label:N,labelText:D,lineEnding:E,link:u(A),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:K,resourceDestinationString:w,resourceTitleString:j,resource:G,setextHeading:u(m),setextHeadingLineSequence:B,setextHeadingText:M,strong:u(),thematicBreak:u()}};z1(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let U={type:"root",children:[]},H={stack:[U],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Pe=[],Ne=-1;for(;++Ne<O.length;)if(O[Ne][1].type==="listOrdered"||O[Ne][1].type==="listUnordered")if(O[Ne][0]==="enter")Pe.push(Ne);else{let yt=Pe.pop();Ne=o(O,yt,Ne)}for(Ne=-1;++Ne<O.length;){let yt=t[O[Ne][0]];R1.call(yt,O[Ne][1].type)&&yt[O[Ne][1].type].call(Object.assign({sliceSerialize:O[Ne][2].sliceSerialize},H),O[Ne][1])}if(H.tokenStack.length>0){let yt=H.tokenStack[H.tokenStack.length-1];(yt[1]||D1).call(H,void 0,yt[0])}for(U.position={start:Ao(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Ao(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},Ne=-1;++Ne<t.transforms.length;)U=t.transforms[Ne](U)||U;return U}function o(O,U,H){let Pe=U-1,Ne=-1,yt=!1,Un,Qn,In,oo;for(;++Pe<=H;){let bn=O[Pe];switch(bn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{bn[0]==="enter"?Ne++:Ne--,oo=void 0;break}case"lineEndingBlank":{bn[0]==="enter"&&(Un&&!oo&&!Ne&&!In&&(In=Pe),oo=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:oo=void 0}if(!Ne&&bn[0]==="enter"&&bn[1].type==="listItemPrefix"||Ne===-1&&bn[0]==="exit"&&(bn[1].type==="listUnordered"||bn[1].type==="listOrdered")){if(Un){let Ir=Pe;for(Qn=void 0;Ir--;){let en=O[Ir];if(en[1].type==="lineEnding"||en[1].type==="lineEndingBlank"){if(en[0]==="exit")continue;Qn&&(O[Qn][1].type="lineEndingBlank",yt=!0),en[1].type="lineEnding",Qn=Ir}else if(!(en[1].type==="linePrefix"||en[1].type==="blockQuotePrefix"||en[1].type==="blockQuotePrefixWhitespace"||en[1].type==="blockQuoteMarker"||en[1].type==="listItemIndent"))break}In&&(!Qn||In<Qn)&&(Un._spread=!0),Un.end=Object.assign({},Qn?O[Qn][1].start:bn[1].end),O.splice(Qn||Pe,0,["exit",Un,bn[2]]),Pe++,H++}if(bn[1].type==="listItemPrefix"){let Ir={type:"listItem",_spread:!1,start:Object.assign({},bn[1].start),end:void 0};Un=Ir,O.splice(Pe,0,["enter",Ir,bn[2]]),Pe++,H++,In=void 0,oo=!0}}}return O[U][1]._spread=yt,H}function i(O,U){return H;function H(Pe){a.call(this,O(Pe),Pe),U&&U.call(this,Pe)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,U,H){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([U,H||void 0]),O.position={start:Ao(U.start),end:void 0}}function u(O){return U;function U(H){O&&O.call(this,H),c.call(this,H)}}function c(O,U){let H=this.stack.pop(),Pe=this.tokenStack.pop();if(Pe)Pe[0].type!==O.type&&(U?U.call(this,O,Pe[0]):(Pe[1]||D1).call(this,O,Pe[0]));else throw new Error("Cannot close `"+O.type+"` ("+Io({start:O.start,end:O.end})+"): it\u2019s not open");H.position.end=Ao(O.end)}function l(){return bh(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(O){if(this.data.expectingFirstListItemValue){let U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),U=this.stack[this.stack.length-1];U.lang=O}function g(){let O=this.resume(),U=this.stack[this.stack.length-1];U.meta=O}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function F(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/(\r?\n|\r)$/g,"")}function k(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(O)).toLowerCase()}function R(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function z(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function _(O){let U=this.stack[this.stack.length-1];if(!U.depth){let H=this.sliceSerialize(O).length;U.depth=H}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function B(O){let U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function m(){this.data.setextHeadingSlurpLineEnding=void 0}function x(O){let H=this.stack[this.stack.length-1].children,Pe=H[H.length-1];(!Pe||Pe.type!=="text")&&(Pe=Ae(),Pe.position={start:Ao(O.start),end:void 0},H.push(Pe)),this.stack.push(Pe)}function b(O){let U=this.stack.pop();U.value+=this.sliceSerialize(O),U.position.end=Ao(O.end)}function E(O){let U=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=U.children[U.children.length-1];H.position.end=Ao(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(x.call(this,O),b.call(this,O))}function h(){this.data.atHardBreak=!0}function T(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function I(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function v(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function A(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function P(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function D(O){let U=this.sliceSerialize(O),H=this.stack[this.stack.length-2];H.label=B1(U),H.identifier=Zr(U).toLowerCase()}function N(){let O=this.stack[this.stack.length-1],U=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Pe=O.children;H.children=Pe}else H.alt=U}function w(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function j(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function G(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function K(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function ee(O){this.data.characterReferenceType=O.type}function re(O){let U=this.sliceSerialize(O),H=this.data.characterReferenceType,Pe;H?(Pe=dc(U,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Pe=_i(U);let Ne=this.stack[this.stack.length-1];Ne.value+=Pe}function de(O){let U=this.stack.pop();U.position.end=Ao(O.end)}function ae(O){b.call(this,O);let U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(O)}function qe(O){b.call(this,O);let U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(O)}function tt(){return{type:"blockquote",children:[]}}function se(){return{type:"code",lang:null,meta:null,value:""}}function pe(){return{type:"inlineCode",value:""}}function Ie(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ze(){return{type:"emphasis",children:[]}}function me(){return{type:"heading",depth:0,children:[]}}function Nt(){return{type:"break"}}function he(){return{type:"html",value:""}}function vt(){return{type:"image",title:null,url:"",alt:null}}function Ge(){return{type:"link",title:null,url:"",children:[]}}function lt(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function nt(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function ne(){return{type:"paragraph",children:[]}}function W(){return{type:"strong",children:[]}}function Ae(){return{type:"text",value:""}}function ge(){return{type:"thematicBreak"}}}function Ao(e){return{line:e.line,column:e.column,offset:e.offset}}function z1(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?z1(e,r):e5(e,r)}}function e5(e,t){let n;for(n in t)if(R1.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r);break}}}function D1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Io({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is still open")}function kc(e){let t=this;t.parser=n;function n(r){return zh(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function N1(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function O1(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
84
- `}]}function _1(e,t){let n=t.value?t.value+`
85
- `:"",r={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(r.className=["language-"+o[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function $1(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function U1(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function j1(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=pr(r.toLowerCase()),i=e.footnoteOrder.indexOf(r),s,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=i+1,a+=1,e.footnoteCounts.set(r,a);let u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,u);let c={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,c),e.applyData(t,c)}function H1(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function W1(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Cc(e,t){let n=t.referenceType,r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];let o=e.all(t),i=o[0];i&&i.type==="text"?i.value="["+i.value:o.unshift({type:"text",value:"["});let s=o[o.length-1];return s&&s.type==="text"?s.value+=r:o.push({type:"text",value:r}),o}function V1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Cc(e,t);let o={src:pr(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,i),e.applyData(t,i)}function G1(e,t){let n={src:pr(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function q1(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Y1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Cc(e,t);let o={href:pr(r.url||"")};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function K1(e,t){let n={href:pr(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function X1(e,t,n){let r=e.all(t),o=n?t5(n):Q1(t),i={},s=[];if(typeof t.checked=="boolean"){let l=r[0],d;l&&l.type==="element"&&l.tagName==="p"?d=l:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let l=r[a];(o||a!==0||l.type!=="element"||l.tagName!=="p")&&s.push({type:"text",value:`
83
+ `;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&o)continue;s=" ";break}default:s=String.fromCharCode(i)}o=i===-2,r.push(s)}return r.join("")}function Nh(e){let r={constructs:m1([zh,...(e||{}).extensions||[]]),content:o(w1),defined:[],document:o(k1),flow:o(F1),lazy:{},string:o(A1),text:o(P1)};return r;function o(i){return s;function s(a){return B1(r,i,a)}}}function Oh(e){for(;!bc(e););return e}var D1=/[\0\t\n\r]/g;function _h(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,d,f,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(s||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(D1.lastIndex=d,c=D1.exec(i),f=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(f),!c){t=i.slice(d);break}if(p===10&&d===f&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<f&&(u.push(i.slice(d,f)),e+=f-d),p){case 0:{u.push(65533),e++;break}case 9:{for(l=Math.ceil(e/4)*4,u.push(-2);e++<l;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var X3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function R1(e){return e.replace(X3,Q3)}function Q3(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return fc(n.slice(i?2:1),i?16:10)}return _i(n)||e}var N1={}.hasOwnProperty;function $h(e,t,n){return typeof t!="string"&&(n=t,t=void 0),J3(n)(Oh(Nh(n).document().write(_h()(e,t,!0))))}function J3(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ge),autolinkProtocol:x,autolinkEmail:x,atxHeading:i(me),blockQuote:i(tt),characterEscape:x,characterReference:x,codeFenced:i(se),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(se,s),codeText:i(pe,s),codeTextData:x,data:x,codeFlowValue:x,definition:i(Ie),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(ze),hardBreakEscape:i(Nt),hardBreakTrailing:i(Nt),htmlFlow:i(he,s),htmlFlowData:x,htmlText:i(he,s),htmlTextData:x,image:i(vt),label:s,link:i(Ge),listItem:i(nt),listItemValue:f,listOrdered:i(lt,d),listUnordered:i(lt),paragraph:i(ne),reference:L,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(me),strong:i(W),thematicBreak:i(ge)},exit:{atxHeading:u(),atxHeadingSequence:_,autolink:u(),autolinkEmail:qe,autolinkProtocol:ae,blockQuote:u(),characterEscapeValue:b,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:re,characterReference:de,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:b,codeIndented:u(F),codeText:u(v),codeTextData:b,data:b,definition:u(),definitionDestinationString:z,definitionLabelString:k,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(h),hardBreakTrailing:u(h),htmlFlow:u(T),htmlFlowData:b,htmlText:u(I),htmlTextData:b,image:u(P),label:N,labelText:D,lineEnding:E,link:u(A),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:K,resourceDestinationString:w,resourceTitleString:j,resource:G,setextHeading:u(m),setextHeadingLineSequence:B,setextHeadingText:M,strong:u(),thematicBreak:u()}};O1(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let U={type:"root",children:[]},H={stack:[U],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Pe=[],Ne=-1;for(;++Ne<O.length;)if(O[Ne][1].type==="listOrdered"||O[Ne][1].type==="listUnordered")if(O[Ne][0]==="enter")Pe.push(Ne);else{let xt=Pe.pop();Ne=o(O,xt,Ne)}for(Ne=-1;++Ne<O.length;){let xt=t[O[Ne][0]];N1.call(xt,O[Ne][1].type)&&xt[O[Ne][1].type].call(Object.assign({sliceSerialize:O[Ne][2].sliceSerialize},H),O[Ne][1])}if(H.tokenStack.length>0){let xt=H.tokenStack[H.tokenStack.length-1];(xt[1]||z1).call(H,void 0,xt[0])}for(U.position={start:Ao(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Ao(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},Ne=-1;++Ne<t.transforms.length;)U=t.transforms[Ne](U)||U;return U}function o(O,U,H){let Pe=U-1,Ne=-1,xt=!1,Un,Qn,In,oo;for(;++Pe<=H;){let bn=O[Pe];switch(bn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{bn[0]==="enter"?Ne++:Ne--,oo=void 0;break}case"lineEndingBlank":{bn[0]==="enter"&&(Un&&!oo&&!Ne&&!In&&(In=Pe),oo=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:oo=void 0}if(!Ne&&bn[0]==="enter"&&bn[1].type==="listItemPrefix"||Ne===-1&&bn[0]==="exit"&&(bn[1].type==="listUnordered"||bn[1].type==="listOrdered")){if(Un){let Ir=Pe;for(Qn=void 0;Ir--;){let Zt=O[Ir];if(Zt[1].type==="lineEnding"||Zt[1].type==="lineEndingBlank"){if(Zt[0]==="exit")continue;Qn&&(O[Qn][1].type="lineEndingBlank",xt=!0),Zt[1].type="lineEnding",Qn=Ir}else if(!(Zt[1].type==="linePrefix"||Zt[1].type==="blockQuotePrefix"||Zt[1].type==="blockQuotePrefixWhitespace"||Zt[1].type==="blockQuoteMarker"||Zt[1].type==="listItemIndent"))break}In&&(!Qn||In<Qn)&&(Un._spread=!0),Un.end=Object.assign({},Qn?O[Qn][1].start:bn[1].end),O.splice(Qn||Pe,0,["exit",Un,bn[2]]),Pe++,H++}if(bn[1].type==="listItemPrefix"){let Ir={type:"listItem",_spread:!1,start:Object.assign({},bn[1].start),end:void 0};Un=Ir,O.splice(Pe,0,["enter",Ir,bn[2]]),Pe++,H++,In=void 0,oo=!0}}}return O[U][1]._spread=xt,H}function i(O,U){return H;function H(Pe){a.call(this,O(Pe),Pe),U&&U.call(this,Pe)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,U,H){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([U,H||void 0]),O.position={start:Ao(U.start),end:void 0}}function u(O){return U;function U(H){O&&O.call(this,H),c.call(this,H)}}function c(O,U){let H=this.stack.pop(),Pe=this.tokenStack.pop();if(Pe)Pe[0].type!==O.type&&(U?U.call(this,O,Pe[0]):(Pe[1]||z1).call(this,O,Pe[0]));else throw new Error("Cannot close `"+O.type+"` ("+Io({start:O.start,end:O.end})+"): it\u2019s not open");H.position.end=Ao(O.end)}function l(){return kh(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(O){if(this.data.expectingFirstListItemValue){let U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),U=this.stack[this.stack.length-1];U.lang=O}function g(){let O=this.resume(),U=this.stack[this.stack.length-1];U.meta=O}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function F(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/(\r?\n|\r)$/g,"")}function k(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(O)).toLowerCase()}function R(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function z(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function _(O){let U=this.stack[this.stack.length-1];if(!U.depth){let H=this.sliceSerialize(O).length;U.depth=H}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function B(O){let U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function m(){this.data.setextHeadingSlurpLineEnding=void 0}function x(O){let H=this.stack[this.stack.length-1].children,Pe=H[H.length-1];(!Pe||Pe.type!=="text")&&(Pe=Ae(),Pe.position={start:Ao(O.start),end:void 0},H.push(Pe)),this.stack.push(Pe)}function b(O){let U=this.stack.pop();U.value+=this.sliceSerialize(O),U.position.end=Ao(O.end)}function E(O){let U=this.stack[this.stack.length-1];if(this.data.atHardBreak){let H=U.children[U.children.length-1];H.position.end=Ao(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(x.call(this,O),b.call(this,O))}function h(){this.data.atHardBreak=!0}function T(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function I(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function v(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function A(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function P(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function D(O){let U=this.sliceSerialize(O),H=this.stack[this.stack.length-2];H.label=R1(U),H.identifier=Zr(U).toLowerCase()}function N(){let O=this.stack[this.stack.length-1],U=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){let Pe=O.children;H.children=Pe}else H.alt=U}function w(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function j(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function G(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function K(O){let U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Zr(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function ee(O){this.data.characterReferenceType=O.type}function re(O){let U=this.sliceSerialize(O),H=this.data.characterReferenceType,Pe;H?(Pe=fc(U,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Pe=_i(U);let Ne=this.stack[this.stack.length-1];Ne.value+=Pe}function de(O){let U=this.stack.pop();U.position.end=Ao(O.end)}function ae(O){b.call(this,O);let U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(O)}function qe(O){b.call(this,O);let U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(O)}function tt(){return{type:"blockquote",children:[]}}function se(){return{type:"code",lang:null,meta:null,value:""}}function pe(){return{type:"inlineCode",value:""}}function Ie(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ze(){return{type:"emphasis",children:[]}}function me(){return{type:"heading",depth:0,children:[]}}function Nt(){return{type:"break"}}function he(){return{type:"html",value:""}}function vt(){return{type:"image",title:null,url:"",alt:null}}function Ge(){return{type:"link",title:null,url:"",children:[]}}function lt(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function nt(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function ne(){return{type:"paragraph",children:[]}}function W(){return{type:"strong",children:[]}}function Ae(){return{type:"text",value:""}}function ge(){return{type:"thematicBreak"}}}function Ao(e){return{line:e.line,column:e.column,offset:e.offset}}function O1(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?O1(e,r):Z3(e,r)}}function Z3(e,t){let n;for(n in t)if(N1.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r);break}}}function z1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Io({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Io({start:t.start,end:t.end})+") is still open")}function Cc(e){let t=this;t.parser=n;function n(r){return $h(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _1(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function $1(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
84
+ `}]}function U1(e,t){let n=t.value?t.value+`
85
+ `:"",r={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(r.className=["language-"+o[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function j1(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function H1(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function W1(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=pr(r.toLowerCase()),i=e.footnoteOrder.indexOf(r),s,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=i+1,a+=1,e.footnoteCounts.set(r,a);let u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,u);let c={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,c),e.applyData(t,c)}function V1(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function G1(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Tc(e,t){let n=t.referenceType,r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];let o=e.all(t),i=o[0];i&&i.type==="text"?i.value="["+i.value:o.unshift({type:"text",value:"["});let s=o[o.length-1];return s&&s.type==="text"?s.value+=r:o.push({type:"text",value:r}),o}function q1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Tc(e,t);let o={src:pr(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,i),e.applyData(t,i)}function Y1(e,t){let n={src:pr(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function K1(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function X1(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Tc(e,t);let o={href:pr(r.url||"")};r.title!==null&&r.title!==void 0&&(o.title=r.title);let i={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function Q1(e,t){let n={href:pr(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function J1(e,t,n){let r=e.all(t),o=n?e5(n):Z1(t),i={},s=[];if(typeof t.checked=="boolean"){let l=r[0],d;l&&l.type==="element"&&l.tagName==="p"?d=l:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let l=r[a];(o||a!==0||l.type!=="element"||l.tagName!=="p")&&s.push({type:"text",value:`
86
86
  `}),l.type==="element"&&l.tagName==="p"&&!o?s.push(...l.children):s.push(l)}let u=r[r.length-1];u&&(o||u.type!=="element"||u.tagName!=="p")&&s.push({type:"text",value:`
87
- `});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function t5(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Q1(n[r])}return t}function Q1(e){let t=e.spread;return t??e.children.length>1}function J1(e,t){let n={},r=e.all(t),o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<r.length;){let s=r[o];if(s.type==="element"&&s.tagName==="li"&&s.properties&&Array.isArray(s.properties.className)&&s.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function Z1(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function eT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function tT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){let n=e.all(t),r=n.shift(),o=[];if(r){let s={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],s),o.push(s)}if(n.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Oi(t.children[1]),u=pc(t.children[t.children.length-1]);a&&u&&(s.position={start:a,end:u}),o.push(s)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,i),e.applyData(t,i)}function rT(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:t.children.length,u=-1,c=[];for(;++u<a;){let d=t.children[u],f={},p=s?s[u]:void 0;p&&(f.align=p);let g={type:"element",tagName:i,properties:f,children:[]};d&&(g.children=e.all(d),e.patch(d,g),g=e.applyData(d,g)),c.push(g)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function oT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(iT(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(iT(t.slice(o),o>0,!1)),i.join("")}function iT(e,t,n){let r=0,o=e.length;if(t){let i=e.codePointAt(r);for(;i===9||i===32;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(o-1);for(;i===9||i===32;)o--,i=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}function aT(e,t){let n={type:"text",value:sT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function lT(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var cT={blockquote:N1,break:O1,code:_1,delete:$1,emphasis:U1,footnoteReference:j1,heading:H1,html:W1,imageReference:V1,image:G1,inlineCode:q1,linkReference:Y1,link:K1,listItem:X1,list:J1,paragraph:Z1,root:eT,strong:tT,table:nT,tableCell:oT,tableRow:rT,text:aT,thematicBreak:lT,toml:Tc,yaml:Tc,definition:Tc,footnoteDefinition:Tc};function Tc(){}var uT=typeof self=="object"?self:globalThis,i5=(e,t)=>{let n=(o,i)=>(e.set(i,o),o),r=o=>{if(e.has(o))return e.get(o);let[i,s]=t[o];switch(i){case 0:case-1:return n(s,o);case 1:{let a=n([],o);for(let u of s)a.push(r(u));return a}case 2:{let a=n({},o);for(let[u,c]of s)a[r(u)]=r(c);return a}case 3:return n(new Date(s),o);case 4:{let{source:a,flags:u}=s;return n(new RegExp(a,u),o)}case 5:{let a=n(new Map,o);for(let[u,c]of s)a.set(r(u),r(c));return a}case 6:{let a=n(new Set,o);for(let u of s)a.add(r(u));return a}case 7:{let{name:a,message:u}=s;return n(new uT[a](u),o)}case 8:return n(BigInt(s),o);case"BigInt":return n(Object(BigInt(s)),o);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{let{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new uT[i](s),o)};return r},_h=e=>i5(new Map,e)(0);var Ui="",{toString:s5}={},{keys:a5}=Object,fa=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=s5.call(e).slice(8,-1);switch(n){case"Array":return[1,Ui];case"Object":return[2,Ui];case"Date":return[3,Ui];case"RegExp":return[4,Ui];case"Map":return[5,Ui];case"Set":return[6,Ui];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Fc=([e,t])=>e===0&&(t==="function"||t==="symbol"),l5=(e,t,n,r)=>{let o=(s,a)=>{let u=r.push(s)-1;return n.set(a,u),u},i=s=>{if(n.has(s))return n.get(s);let[a,u]=fa(s);switch(a){case 0:{let l=s;switch(u){case"bigint":a=8,l=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);l=null;break;case"undefined":return o([-1],s)}return o([a,l],s)}case 1:{if(u){let f=s;return u==="DataView"?f=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(f=new Uint8Array(s)),o([u,[...f]],s)}let l=[],d=o([a,l],s);for(let f of s)l.push(i(f));return d}case 2:{if(u)switch(u){case"BigInt":return o([u,s.toString()],s);case"Boolean":case"Number":case"String":return o([u,s.valueOf()],s)}if(t&&"toJSON"in s)return i(s.toJSON());let l=[],d=o([a,l],s);for(let f of a5(s))(e||!Fc(fa(s[f])))&&l.push([i(f),i(s[f])]);return d}case 3:return o([a,s.toISOString()],s);case 4:{let{source:l,flags:d}=s;return o([a,{source:l,flags:d}],s)}case 5:{let l=[],d=o([a,l],s);for(let[f,p]of s)(e||!(Fc(fa(f))||Fc(fa(p))))&&l.push([i(f),i(p)]);return d}case 6:{let l=[],d=o([a,l],s);for(let f of s)(e||!Fc(fa(f)))&&l.push(i(f));return d}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},$h=(e,{json:t,lossy:n}={})=>{let r=[];return l5(!(t||n),!!t,new Map,r)(e),r};var ji=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?_h($h(e,t)):structuredClone(e):(e,t)=>_h($h(e,t));function c5(e,t){let n=[{type:"text",value:"\u21A9"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function u5(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function mT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||c5,r=e.options.footnoteBackLabel||u5,o=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],u=-1;for(;++u<e.footnoteOrder.length;){let c=e.footnoteById.get(e.footnoteOrder[u]);if(!c)continue;let l=e.all(c),d=String(c.identifier).toUpperCase(),f=pr(d.toLowerCase()),p=0,g=[],S=e.footnoteCounts.get(d);for(;S!==void 0&&++p<=S;){g.length>0&&g.push({type:"text",value:" "});let k=typeof n=="string"?n:n(u,p);typeof k=="string"&&(k={type:"text",value:k}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,p),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}let C=l[l.length-1];if(C&&C.type==="element"&&C.tagName==="p"){let k=C.children[C.children.length-1];k&&k.type==="text"?k.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...g)}else l.push(...g);let F={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(l,!0)};e.patch(c,F),a.push(F)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...ji(s),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
87
+ `});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function e5(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Z1(n[r])}return t}function Z1(e){let t=e.spread;return t??e.children.length>1}function eT(e,t){let n={},r=e.all(t),o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<r.length;){let s=r[o];if(s.type==="element"&&s.tagName==="li"&&s.properties&&Array.isArray(s.properties.className)&&s.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function tT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function rT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oT(e,t){let n=e.all(t),r=n.shift(),o=[];if(r){let s={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],s),o.push(s)}if(n.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Oi(t.children[1]),u=dc(t.children[t.children.length-1]);a&&u&&(s.position={start:a,end:u}),o.push(s)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,i),e.applyData(t,i)}function iT(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:t.children.length,u=-1,c=[];for(;++u<a;){let d=t.children[u],f={},p=s?s[u]:void 0;p&&(f.align=p);let g={type:"element",tagName:i,properties:f,children:[]};d&&(g.children=e.all(d),e.patch(d,g),g=e.applyData(d,g)),c.push(g)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function sT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(aT(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(aT(t.slice(o),o>0,!1)),i.join("")}function aT(e,t,n){let r=0,o=e.length;if(t){let i=e.codePointAt(r);for(;i===9||i===32;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(o-1);for(;i===9||i===32;)o--,i=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}function cT(e,t){let n={type:"text",value:lT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function uT(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var pT={blockquote:_1,break:$1,code:U1,delete:j1,emphasis:H1,footnoteReference:W1,heading:V1,html:G1,imageReference:q1,image:Y1,inlineCode:K1,linkReference:X1,link:Q1,listItem:J1,list:eT,paragraph:tT,root:nT,strong:rT,table:oT,tableCell:sT,tableRow:iT,text:cT,thematicBreak:uT,toml:Ic,yaml:Ic,definition:Ic,footnoteDefinition:Ic};function Ic(){}var dT=typeof self=="object"?self:globalThis,o5=(e,t)=>{let n=(o,i)=>(e.set(i,o),o),r=o=>{if(e.has(o))return e.get(o);let[i,s]=t[o];switch(i){case 0:case-1:return n(s,o);case 1:{let a=n([],o);for(let u of s)a.push(r(u));return a}case 2:{let a=n({},o);for(let[u,c]of s)a[r(u)]=r(c);return a}case 3:return n(new Date(s),o);case 4:{let{source:a,flags:u}=s;return n(new RegExp(a,u),o)}case 5:{let a=n(new Map,o);for(let[u,c]of s)a.set(r(u),r(c));return a}case 6:{let a=n(new Set,o);for(let u of s)a.add(r(u));return a}case 7:{let{name:a,message:u}=s;return n(new dT[a](u),o)}case 8:return n(BigInt(s),o);case"BigInt":return n(Object(BigInt(s)),o);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{let{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new dT[i](s),o)};return r},Hh=e=>o5(new Map,e)(0);var Ui="",{toString:i5}={},{keys:s5}=Object,fa=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=i5.call(e).slice(8,-1);switch(n){case"Array":return[1,Ui];case"Object":return[2,Ui];case"Date":return[3,Ui];case"RegExp":return[4,Ui];case"Map":return[5,Ui];case"Set":return[6,Ui];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Ec=([e,t])=>e===0&&(t==="function"||t==="symbol"),a5=(e,t,n,r)=>{let o=(s,a)=>{let u=r.push(s)-1;return n.set(a,u),u},i=s=>{if(n.has(s))return n.get(s);let[a,u]=fa(s);switch(a){case 0:{let l=s;switch(u){case"bigint":a=8,l=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);l=null;break;case"undefined":return o([-1],s)}return o([a,l],s)}case 1:{if(u){let f=s;return u==="DataView"?f=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(f=new Uint8Array(s)),o([u,[...f]],s)}let l=[],d=o([a,l],s);for(let f of s)l.push(i(f));return d}case 2:{if(u)switch(u){case"BigInt":return o([u,s.toString()],s);case"Boolean":case"Number":case"String":return o([u,s.valueOf()],s)}if(t&&"toJSON"in s)return i(s.toJSON());let l=[],d=o([a,l],s);for(let f of s5(s))(e||!Ec(fa(s[f])))&&l.push([i(f),i(s[f])]);return d}case 3:return o([a,s.toISOString()],s);case 4:{let{source:l,flags:d}=s;return o([a,{source:l,flags:d}],s)}case 5:{let l=[],d=o([a,l],s);for(let[f,p]of s)(e||!(Ec(fa(f))||Ec(fa(p))))&&l.push([i(f),i(p)]);return d}case 6:{let l=[],d=o([a,l],s);for(let f of s)(e||!Ec(fa(f)))&&l.push(i(f));return d}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},Wh=(e,{json:t,lossy:n}={})=>{let r=[];return a5(!(t||n),!!t,new Map,r)(e),r};var ji=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Hh(Wh(e,t)):structuredClone(e):(e,t)=>Hh(Wh(e,t));function l5(e,t){let n=[{type:"text",value:"\u21A9"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function c5(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function xT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||l5,r=e.options.footnoteBackLabel||c5,o=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],u=-1;for(;++u<e.footnoteOrder.length;){let c=e.footnoteById.get(e.footnoteOrder[u]);if(!c)continue;let l=e.all(c),d=String(c.identifier).toUpperCase(),f=pr(d.toLowerCase()),p=0,g=[],S=e.footnoteCounts.get(d);for(;S!==void 0&&++p<=S;){g.length>0&&g.push({type:"text",value:" "});let k=typeof n=="string"?n:n(u,p);typeof k=="string"&&(k={type:"text",value:k}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,p),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}let C=l[l.length-1];if(C&&C.type==="element"&&C.tagName==="p"){let k=C.children[C.children.length-1];k&&k.type==="text"?k.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...g)}else l.push(...g);let F={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(l,!0)};e.patch(c,F),a.push(F)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...ji(s),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
88
88
  `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
89
- `}]}}var Ec=(function(e){if(e==null)return g5;if(typeof e=="function")return Ac(e);if(typeof e=="object")return Array.isArray(e)?p5(e):d5(e);if(typeof e=="string")return f5(e);throw new Error("Expected function, string, or object as test")});function p5(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ec(e[n]);return Ac(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function d5(e){let t=e;return Ac(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function f5(e){return Ac(t);function t(n){return n&&n.type===e}}function Ac(e){return t;function t(n,r,o){return!!(m5(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function g5(){return!0}function m5(e){return e!==null&&typeof e=="object"&&"type"in e}var hT=[],Uh=!0,Pc=!1,jh="skip";function Hh(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Ec(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let d=u&&typeof u=="object"?u:{};if(typeof d.type=="string"){let p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(u.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=hT,g,S,C;if((!t||i(u,c,l[l.length-1]||void 0))&&(p=h5(n(u,l)),p[0]===Pc))return p;if("children"in u&&u.children){let F=u;if(F.children&&p[0]!==jh)for(S=(r?F.children.length:-1)+s,C=l.concat(F);S>-1&&S<F.children.length;){let k=F.children[S];if(g=a(k,S,C)(),g[0]===Pc)return g;S=typeof g[1]=="number"?g[1]:S+s}}return p}}}function h5(e){return Array.isArray(e)?e:typeof e=="number"?[Uh,e]:e==null?hT:[e]}function ga(e,t,n,r){let o,i,s;typeof t=="function"&&typeof n!="function"?(i=void 0,s=t,o=n):(i=t,s=n,o=r),Hh(e,i,a,o);function a(u,c){let l=c[c.length-1],d=l?l.children.indexOf(u):void 0;return s(u,d,l)}}var Wh={}.hasOwnProperty,x5={};function yT(e,t){let n=t||x5,r=new Map,o=new Map,i=new Map,s={...cT,...n.handlers},a={all:c,applyData:b5,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:y5,wrap:w5};return ga(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let d=l.type==="definition"?r:o,f=String(l.identifier).toUpperCase();d.has(f)||d.set(f,l)}}),a;function u(l,d){let f=l.type,p=a.handlers[f];if(Wh.call(a.handlers,f)&&p)return p(a,l,d);if(a.options.passThrough&&a.options.passThrough.includes(f)){if("children"in l){let{children:S,...C}=l,F=ji(C);return F.children=a.all(l),F}return ji(l)}return(a.options.unknownHandler||S5)(a,l,d)}function c(l){let d=[];if("children"in l){let f=l.children,p=-1;for(;++p<f.length;){let g=a.one(f[p],l);if(g){if(p&&f[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=xT(g.value)),!Array.isArray(g)&&g.type==="element")){let S=g.children[0];S&&S.type==="text"&&(S.value=xT(S.value))}Array.isArray(g)?d.push(...g):d.push(g)}}}return d}}function y5(e,t){e.position&&(t.position=fh(e))}function b5(e,t){let n=t;if(e&&e.data){let r=e.data.hName,o=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{let s="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:s}}n.type==="element"&&i&&Object.assign(n.properties,ji(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function S5(e,t){let n=t.data||{},r="value"in t&&!(Wh.call(n,"hProperties")||Wh.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function w5(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
89
+ `}]}}var Ac=(function(e){if(e==null)return f5;if(typeof e=="function")return Pc(e);if(typeof e=="object")return Array.isArray(e)?u5(e):p5(e);if(typeof e=="string")return d5(e);throw new Error("Expected function, string, or object as test")});function u5(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ac(e[n]);return Pc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function p5(e){let t=e;return Pc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function d5(e){return Pc(t);function t(n){return n&&n.type===e}}function Pc(e){return t;function t(n,r,o){return!!(g5(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function f5(){return!0}function g5(e){return e!==null&&typeof e=="object"&&"type"in e}var yT=[],Vh=!0,Lc=!1,Gh="skip";function qh(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Ac(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let d=u&&typeof u=="object"?u:{};if(typeof d.type=="string"){let p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(u.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=yT,g,S,C;if((!t||i(u,c,l[l.length-1]||void 0))&&(p=m5(n(u,l)),p[0]===Lc))return p;if("children"in u&&u.children){let F=u;if(F.children&&p[0]!==Gh)for(S=(r?F.children.length:-1)+s,C=l.concat(F);S>-1&&S<F.children.length;){let k=F.children[S];if(g=a(k,S,C)(),g[0]===Lc)return g;S=typeof g[1]=="number"?g[1]:S+s}}return p}}}function m5(e){return Array.isArray(e)?e:typeof e=="number"?[Vh,e]:e==null?yT:[e]}function ga(e,t,n,r){let o,i,s;typeof t=="function"&&typeof n!="function"?(i=void 0,s=t,o=n):(i=t,s=n,o=r),qh(e,i,a,o);function a(u,c){let l=c[c.length-1],d=l?l.children.indexOf(u):void 0;return s(u,d,l)}}var Yh={}.hasOwnProperty,h5={};function ST(e,t){let n=t||h5,r=new Map,o=new Map,i=new Map,s={...pT,...n.handlers},a={all:c,applyData:y5,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:x5,wrap:S5};return ga(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let d=l.type==="definition"?r:o,f=String(l.identifier).toUpperCase();d.has(f)||d.set(f,l)}}),a;function u(l,d){let f=l.type,p=a.handlers[f];if(Yh.call(a.handlers,f)&&p)return p(a,l,d);if(a.options.passThrough&&a.options.passThrough.includes(f)){if("children"in l){let{children:S,...C}=l,F=ji(C);return F.children=a.all(l),F}return ji(l)}return(a.options.unknownHandler||b5)(a,l,d)}function c(l){let d=[];if("children"in l){let f=l.children,p=-1;for(;++p<f.length;){let g=a.one(f[p],l);if(g){if(p&&f[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=bT(g.value)),!Array.isArray(g)&&g.type==="element")){let S=g.children[0];S&&S.type==="text"&&(S.value=bT(S.value))}Array.isArray(g)?d.push(...g):d.push(g)}}}return d}}function x5(e,t){e.position&&(t.position=xh(e))}function y5(e,t){let n=t;if(e&&e.data){let r=e.data.hName,o=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{let s="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:s}}n.type==="element"&&i&&Object.assign(n.properties,ji(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function b5(e,t){let n=t.data||{},r="value"in t&&!(Yh.call(n,"hProperties")||Yh.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function S5(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
90
90
  `});++r<e.length;)r&&n.push({type:"text",value:`
91
91
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
92
- `}),n}function xT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Lc(e,t){let n=yT(e,t),r=n.one(e,void 0),o=mT(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&("children"in i,i.children.push({type:"text",value:`
93
- `},o)),i}function Mc(e,t){return e&&"run"in e?async function(n,r){let o=Lc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Lc(n,{file:r,...e||t})}}function Vh(e){if(e)throw e}var Rc=Aa(FT(),1);function ma(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Gh(){let e=[],t={run:n,use:r};return t;function n(...o){let i=-1,s=o.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...o);function a(u,...c){let l=e[++i],d=-1;if(u){s(u);return}for(;++d<o.length;)(c[d]===null||c[d]===void 0)&&(c[d]=o[d]);o=c,l?ET(l,a)(...c):s(null,...c)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function ET(e,t){let n;return r;function r(...s){let a=e.length>s.length,u;a&&s.push(o);try{u=e.apply(this,s)}catch(c){let l=c;if(a&&n)throw l;return o(l)}a||(u&&u.then&&typeof u.then=="function"?u.then(i,o):u instanceof Error?o(u):i(u))}function o(s,...a){n||(n=!0,t(s,...a))}function i(s){o(null,s)}}var kr={basename:v5,dirname:k5,extname:C5,join:T5,sep:"/"};function v5(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ha(e);let n=0,r=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,a=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else s<0&&(i=!0,s=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(r=o):(a=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}function k5(e){if(ha(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function C5(e){ha(e);let t=e.length,n=-1,r=0,o=-1,i=0,s;for(;t--;){let a=e.codePointAt(t);if(a===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),a===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||n<0||i===0||i===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function T5(...e){let t=-1,n;for(;++t<e.length;)ha(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":I5(n)}function I5(e){ha(e);let t=e.codePointAt(0)===47,n=F5(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function F5(e,t){let n="",r=0,o=-1,i=0,s=-1,a,u;for(;++s<=e.length;){if(s<e.length)a=e.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(o===s-1||i===1))if(o!==s-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),o=s,i=0;continue}}else if(n.length>0){n="",r=0,o=s,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,s):n=e.slice(o+1,s),r=s-o-1;o=s,i=0}else a===46&&i>-1?i++:i=-1}return n}function ha(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var AT={cwd:E5};function E5(){return"/"}function Hi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function PT(e){if(typeof e=="string")e=new URL(e);else if(!Hi(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return A5(e)}function A5(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let r=t.codePointAt(n+2);if(r===70||r===102){let o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}var qh=["history","path","basename","stem","extname","dirname"],ti=class{constructor(t){let n;t?Hi(t)?n={path:t}:typeof t=="string"||P5(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":AT.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<qh.length;){let i=qh[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let o;for(o in n)qh.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?kr.basename(this.path):void 0}set basename(t){Kh(t,"basename"),Yh(t,"basename"),this.path=kr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?kr.dirname(this.path):void 0}set dirname(t){LT(this.basename,"dirname"),this.path=kr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?kr.extname(this.path):void 0}set extname(t){if(Yh(t,"extname"),LT(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=kr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Hi(t)&&(t=PT(t)),Kh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?kr.basename(this.path,this.extname):void 0}set stem(t){Kh(t,"stem"),Yh(t,"stem"),this.path=kr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){let o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){let o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){let o=new Ht(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Yh(e,t){if(e&&e.includes(kr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+kr.sep+"`")}function Kh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function LT(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function P5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var MT=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var L5={}.hasOwnProperty,Zh=class e extends MT{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Gh()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,Rc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Jh("data",this.frozen),this.namespace[t]=n,this):L5.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Jh("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=Dc(t),r=this.parser||this.Parser;return Xh("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),Xh("process",this.parser||this.Parser),Qh("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=Dc(t),u=r.parse(a);r.run(u,a,function(l,d,f){if(l||!d||!f)return c(l);let p=d,g=r.stringify(p,f);B5(g)?f.value=g:f.result=g,c(l,f)});function c(l,d){l||!d?s(l):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Xh("processSync",this.parser||this.Parser),Qh("processSync",this.compiler||this.Compiler),this.process(t,o),DT("processSync","process",n),r;function o(i,s){n=!0,Vh(i),r=s}}run(t,n,r){BT(t),this.freeze();let o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(s,a){let u=Dc(n);o.run(t,u,c);function c(l,d,f){let p=d||t;l?a(l):s?s(p):r(void 0,p,f)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),DT("runSync","run",r),o;function i(s,a){Vh(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Dc(n),o=this.compiler||this.Compiler;return Qh("stringify",o),BT(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(Jh("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):s(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(c){if(typeof c=="function")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[l,...d]=c;u(l,d)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(o.settings=(0,Rc.default)(!0,o.settings,c.settings))}function a(c){let l=-1;if(c!=null)if(Array.isArray(c))for(;++l<c.length;){let d=c[l];i(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,l){let d=-1,f=-1;for(;++d<r.length;)if(r[d][0]===c){f=d;break}if(f===-1)r.push([c,...l]);else if(l.length>0){let[p,...g]=l,S=r[f][1];ma(S)&&ma(p)&&(p=(0,Rc.default)(!0,S,p)),r[f]=[c,p,...g]}}}},ex=new Zh().freeze();function Xh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Qh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Jh(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function BT(e){if(!ma(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function DT(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Dc(e){return M5(e)?e:new ti(e)}function M5(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function B5(e){return typeof e=="string"||D5(e)}function D5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var O5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",RT=[],zT={allowDangerousHtml:!0},_5=/^(https?|ircs?|mailto|xmpp)$/i,$5=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function tx(e){let t=U5(e),n=j5(e);return H5(t.runSync(t.parse(n),n),e)}function U5(e){let t=e.rehypePlugins||RT,n=e.remarkPlugins||RT,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...zT}:zT;return ex().use(kc).use(n).use(Mc,r).use(t)}function j5(e){let t=e.children||"",n=new ti;return typeof t=="string"?n.value=t:(""+t,void 0),n}function H5(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||NT;for(let l of $5)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+O5+l.id,void 0);return n&&i&&void 0,ga(e,c),hh(e,{Fragment:R5,components:o,ignoreInvalidStyle:!0,jsx:z5,jsxs:N5,passKeys:!0,passNode:!0});function c(l,d,f){if(l.type==="raw"&&f&&typeof d=="number")return s?f.children.splice(d,1):f.children[d]={type:"text",value:l.value},d;if(l.type==="element"){let p;for(p in sa)if(Object.hasOwn(sa,p)&&Object.hasOwn(l.properties,p)){let g=l.properties[p],S=sa[p];(S===null||S.includes(l.tagName))&&(l.properties[p]=u(String(g||""),p,l))}}if(l.type==="element"){let p=n?!n.includes(l.tagName):i?i.includes(l.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(l,d,f)),p&&f&&typeof d=="number")return a&&l.children?f.children.splice(d,1,...l.children):f.children.splice(d,1),d}}}function NT(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||_5.test(e.slice(0,t))?e:""}ve();var V5=Wi.div({display:"flex",flexDirection:"column",gap:"12px"}),G5=Wi.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),q5=Wi.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Y5=Wi(er)({padding:"6px 12px",fontSize:"12px"}),K5=Wi.div(({theme:e})=>({backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"12px",fontSize:"12px",color:e.color.defaultText,overflowY:"auto",maxHeight:"400px",lineHeight:"1.6","& h1, & h2, & h3, & h4":{marginTop:"16px",marginBottom:"8px",fontWeight:600,color:e.color.defaultText},"& h1":{fontSize:"18px"},"& h2":{fontSize:"16px"},"& h3":{fontSize:"14px"},"& h4":{fontSize:"13px"},"& p":{margin:"8px 0"},"& ul, & ol":{paddingLeft:"20px",margin:"8px 0"},"& li":{margin:"4px 0"},"& code":{backgroundColor:e.background.app,padding:"2px 4px",borderRadius:"3px",fontFamily:RC.fontMono,fontSize:"11px"},"& pre":{backgroundColor:e.background.app,padding:"8px",borderRadius:"4px",overflowX:"auto","& code":{backgroundColor:"transparent",padding:0}},"& strong":{fontWeight:600},"& blockquote":{borderLeft:`3px solid ${e.color.secondary}`,paddingLeft:"12px",margin:"8px 0",color:e.color.mediumdark}})),X5=Wi.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),nx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ie(),[r,o]=W5(!1);if((n??t)!=="admin")return null;let s=async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(a){console.error("Failed to copy:",a)}};return e?ni.createElement(V5,null,ni.createElement(G5,null,ni.createElement(q5,null,"Full Prompt"),ni.createElement(Y5,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),ni.createElement(K5,null,ni.createElement(tx,null,e))):ni.createElement(X5,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import eo,{useRef as Q5}from"react";import{styled as Cr}from"storybook/theming";ve();var J5=Cr.div({display:"flex",flexDirection:"column",gap:"8px"}),Fpe=Cr.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"11px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"3px 10px",borderRadius:"12px",border:`1px solid ${o.border}`,whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:"6px"}}),Z5=Cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflowY:"auto",scrollBehavior:"smooth",padding:"6px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app})),e6=Cr.div(({role:e,theme:t})=>({padding:"8px 10px",borderRadius:"4px",fontSize:"11px",lineHeight:"1.4",backgroundColor:e==="system"?t.background.hoverable:t.background.content,border:`1px solid ${t.appBorderColor}`,color:t.color.defaultText})),Epe=Cr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),OT=Cr.div(({theme:e})=>({whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"10px","& .section-header":{fontSize:"11px",fontWeight:700,color:e.color.secondary,marginTop:"8px",marginBottom:"4px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"6px",marginBottom:"2px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||le,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"11px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"1px 6px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"3px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||le,backgroundColor:e.background.warning||"#ffedd5"}})),t6=Cr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),n6=Cr.div(({theme:e})=>({padding:"12px 16px",borderRadius:"8px",backgroundColor:e.background.positive||"#dcfce7",border:`1px solid ${e.color.positive||"#86efac"}`,color:e.color.positive||"#166534",fontSize:"13px",fontWeight:500,lineHeight:1.5,marginBottom:"12px"})),r6=Cr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),o6=Cr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),Ape=Cr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function i6(e){let t=e;return t=t.replace(/^(?:\*?\*?)?(?:##?)?\s*SCORE:\s*\d+.*$/gm,""),t=t.replace(/^(ISSUES:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t}var rx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ie(),s=Q5(null);if((i??o)!=="admin")return null;let u=r?n.find(g=>g.id===r):null,c=u?u.issues.length>0&&u.issues.every(g=>g.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(g=>g.role==="assistant"||g.role==="system"&&g.content.includes("auto-dismissed")),f=d.length===0&&!!t;if(d.length===0&&!f)return eo.createElement(t6,null,"No AI response yet. The AI's analysis will appear here as it streams.");let p=d.length>0?d:[{role:"assistant",content:t}];return eo.createElement(J5,null,l&&eo.createElement(n6,null,eo.createElement(r6,null,"Component Matches Design"),eo.createElement(o6,null,c&&u?.issues.length?`All ${u.issues.length} issue${u.issues.length===1?"":"s"} identified by the AI ${u.issues.length===1?"was":"were"} validated as false positive${u.issues.length===1?"":"s"} and auto-dismissed.`:"No design discrepancies found. The implementation matches the Figma design.")),eo.createElement(Z5,{ref:s},p.map((g,S)=>eo.createElement(e6,{key:S,role:g.role},g.role==="system"?eo.createElement(OT,null,g.content):eo.createElement(OT,{dangerouslySetInnerHTML:{__html:i6(g.content)}})))))};import dr from"react";import{styled as Po}from"storybook/theming";ve();De();var s6=Po.div({display:"flex",flexDirection:"column",gap:"12px"}),a6=Po.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),l6=Po.button(({theme:e,isActive:t,provider:n})=>{let o={anthropic:{background:"#D4A574",text:"#ffffff",hover:"#C49564"},openai:{background:e.color.positive||"#10b981",text:"#ffffff",hover:e.base==="dark"?"#34d399":"#059669"},google:{background:"#4285F4",text:"#ffffff",hover:"#3367D6"}}[n];return{display:"flex",alignItems:"center",gap:"6px",padding:"8px 16px",fontSize:"12px",fontWeight:600,color:t?o.text:e.textMutedColor,backgroundColor:t?o.background:"transparent",border:"none",borderRadius:"6px 6px 0 0",cursor:"pointer",whiteSpace:"nowrap",transition:"all 0.2s",opacity:t?1:.6,"&:hover":{opacity:1,backgroundColor:t?o.hover:e.background.hoverable}}}),_T=Po.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"10px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${o.border}`,whiteSpace:"nowrap"}}),c6=Po.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),$T=Po.div(({theme:e})=>({fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',color:e.color.defaultText,"& .section-header":{fontSize:"13px",fontWeight:700,color:e.color.secondary,marginTop:"12px",marginBottom:"6px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"10px",marginBottom:"4px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||le,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"14px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"2px 8px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"4px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||le,backgroundColor:e.background.warning||"#ffedd5"}})),UT=Po.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),u6=Po.div({width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite",display:"inline-block",marginLeft:"6px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}});function jT(e){let t=e;return t=t.replace(/^(ISSUES:|SCORE:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t=t.replace(/SCORE:\s*(\d+)/g,(n,r)=>{let o=parseInt(r,10);return`SCORE: <span class="${o>=80?"score":o>=60?"score score-medium":"score score-low"}">${r}</span>`}),t}function p6(e){let t=e.match(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-/g),n=t?t.length:0,r=e.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i),o=r?parseInt(r[1],10):null;return{issueCount:n,score:o}}var HT=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ie();if((i??o)!=="admin")return null;dr.useEffect(()=>{e&&(y.debug("[ModelResultsTabs] multiModelResults:",e),Object.entries(e.byModel).forEach(([l,d])=>{y.debug(`[ModelResultsTabs] ${l}:`,{hasStreamingMessages:!!d.streamingMessages,streamingMessagesLength:d.streamingMessages?.length||0,streamingMessagesPreview:d.streamingMessages?.[0]?.content?.substring(0,100),hasFullResponse:!!d.fullResponse,fullResponsePreview:d.fullResponse?.substring(0,100)})}))},[e]);let a=e&&Object.keys(e.byModel).length>0?Object.keys(e.byModel):r,u=e?.activeModelId||(a.length>0?a[0]:""),c=e?.byModel||{};return a.length===0?dr.createElement(UT,null,"No models selected. Select multiple models to compare results."):dr.createElement(s6,null,dr.createElement(a6,null,a.map(l=>{let d=Qr.find(F=>F.id===l),f=c[l],g=p6(t&&f?.streamingMessages&&f.streamingMessages.length>0?f.streamingMessages[0].content||"":f?.fullResponse?f.fullResponse:""),S=l===u;if(!d)return null;let C=t&&!f?.completed;return dr.createElement(l6,{key:l,isActive:S,provider:d.provider,onClick:()=>n(l)},d.name,f&&g.issueCount>0&&dr.createElement(_T,{variant:"issues",value:g.issueCount},g.issueCount," issues"),f&&g.score!==null&&dr.createElement(_T,{variant:"score",value:g.score},"Score: ",g.score),C&&dr.createElement(u6,null))})),dr.createElement(c6,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>dr.createElement($T,{key:d,dangerouslySetInnerHTML:{__html:jT(l.content)}})):c[u]?.fullResponse?dr.createElement($T,{dangerouslySetInnerHTML:{__html:jT(c[u].fullResponse)}}):dr.createElement(UT,null,t?`Waiting for ${Qr.find(l=>l.id===u)?.name}...`:`No response yet for ${Qr.find(l=>l.id===u)?.name}`)))};import Ue from"react";import{styled as Ct}from"storybook/theming";ve();Ls();ve();import{useCallback as ox}from"react";De();function WT(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ie(),{sessionToken:r}=we(),o=ox(a=>{for(let u of n){let c=u.issues.find(l=>l.id===a);if(c)return c.dbId||c.id||null}return null},[n]),i=ox((a,u)=>{e(a,u,"user");let c=o(a);if(!c){y.debug("[useIssuePersistence] Dismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Dismiss skipped \u2014 no session token");return}zl(c,!0,u,"user",r).then(l=>{l.success||y.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=ox(a=>{t(a);let u=o(a);if(!u){y.debug("[useIssuePersistence] Undismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Undismiss skipped \u2014 no session token");return}zl(u,!1,void 0,"user",r).then(c=>{c.success||y.warn("[useIssuePersistence] Undismiss server sync failed:",c.error)})},[t,o,r]);return{dismissAndSync:i,undismissAndSync:s}}import V,{useMemo as wH,useState as vH,useEffect as kH}from"react";import{styled as it,keyframes as CH}from"storybook/theming";import J,{useState as cx,useRef as dj,useCallback as iI,memo as fj}from"react";import{styled as Ee}from"storybook/theming";import to,{useState as d6}from"react";import{styled as no}from"storybook/theming";var f6=no.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999}),g6=no.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"8px",padding:"24px",maxWidth:"500px",width:"90%",boxShadow:e.base==="dark"?"0 10px 40px rgba(0, 0, 0, 0.5)":"0 10px 40px rgba(0, 0, 0, 0.2)",border:`1px solid ${e.appBorderColor}`})),m6=no.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),h6=no.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),x6=no.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),y6=no.textarea(({theme:e})=>({width:"100%",minHeight:"80px",padding:"10px",fontSize:"13px",borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",marginBottom:"20px","&:focus":{outline:"none",borderColor:le,boxShadow:`0 0 0 3px ${e.base==="dark"?"rgba(124, 58, 237, 0.2)":"rgba(124, 58, 237, 0.1)"}`},"&::placeholder":{color:e.textMutedColor}})),b6=no.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),S6=no(qt)({}),w6=no(Er)({}),VT=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=d6("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return to.createElement(f6,{onClick:c=>{c.target===c.currentTarget&&a()}},to.createElement(g6,null,to.createElement(m6,null,"Dismiss as False Positive"),to.createElement(h6,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),to.createElement(x6,{htmlFor:"dismiss-reason"},"Reason (optional)"),to.createElement(y6,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),to.createElement(b6,null,to.createElement(w6,{onClick:a},"Cancel"),to.createElement(S6,{onClick:s},"Dismiss Issue"))))};ve();import Fe from"react";import{styled as ot}from"storybook/theming";var Be={outerBg:"#f0f0f0",borderBoxBg:"#fff",borderBoxStroke:"#999",paddingBg:"#dceefb",paddingStroke:"rgba(0,0,0,0.08)",contentStroke:"#888",text:"#333",dim:"#999",dash:"#aaa",blue:"#4a90d9",pink:"#e91e8c",err:"#d32f2f",errBg:"rgba(211,47,47,0.12)",ok:"#2e7d32"},v6=ot.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),k6=ot.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),C6=ot.div({position:"relative",backgroundColor:Be.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Xpe=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Be.dash,padding:"0 8px",height:18,fontSize:11}),Qpe=ot.div({position:"absolute",color:Be.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Jpe=ot.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"1px 6px",borderRadius:3,zIndex:2,...e.side==="top"&&{top:4,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:4,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:4,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:4,top:"50%",transform:"translateY(-50%)"}})),Zpe=ot.div(e=>({position:"absolute",backgroundColor:e.color,zIndex:1,...e.orient==="v"&&{width:1,left:"50%"},...e.orient==="h"&&{height:1,top:"50%"},...e.side==="top"&&{top:18,height:10},...e.side==="bottom"&&{bottom:18,height:10},...e.side==="left"&&{left:30,width:20},...e.side==="right"&&{right:30,width:20}})),T6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Be.errBg:Be.borderBoxBg,border:`1px solid ${e.isErr?Be.err:Be.borderBoxStroke}`,borderRadius:6,padding:0})),I6=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Be.text}),F6=ot.span({fontWeight:500,fontSize:11}),ede=ot.span({color:Be.dash}),E6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Be.errBg:Be.paddingBg,border:`1px solid ${e.isErr?Be.err:Be.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),A6=ot.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Be.text,fontStyle:"italic"}),zc=ot.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Be.err:Be.text,fontWeight:e.isErr?700:400,...e.side==="top"&&{top:3,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:3,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:8,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:8,top:"50%",transform:"translateY(-50%)"}})),P6=ot.div(e=>({backgroundColor:e.isErr?Be.errBg:"#fff",border:`1.5px dashed ${e.isErr?Be.err:Be.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Be.err:Be.text,fontWeight:e.isErr?600:400})),L6=ot.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Be.dim,fontFamily:"monospace"}),M6=ot.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Be.ok,padding:"4px 8px 6px"}),tde=ot.div({fontSize:11,fontWeight:600,color:Be.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),nde=ot.span({fontSize:12,color:Be.dim}),B6=ot.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),D6=ot.div({fontSize:9,color:Be.dim,marginTop:2}),R6=({property:e,currentValue:t,expectedValue:n,figmaContext:r,elementName:o})=>{let i=e.toLowerCase(),s=i.includes("padding"),a=i.includes("border")||i.includes("stroke")||i.includes("box-shadow"),u=i.includes("width")||i.includes("height")||i==="dimensions",c=i.includes("radius"),{figmaImageUrl:l}=ie(),d=r||{},p=!(!!r&&Object.keys(r).length>0)&&s?H6(n):null,g=d.padding||p||{top:0,right:0,bottom:0,left:0},S=d.strokeWeight??(a?Vi(n)??0:0),C=d.width??(u?W6(n)??"\u2014":"\u2014"),F=d.height??(u?V6(n)??"\u2014":"\u2014");return Fe.createElement(Fe.Fragment,null,Fe.createElement(C6,null,Fe.createElement(T6,{isErr:a},Fe.createElement(I6,null,Fe.createElement(F6,null,"Border"),Fe.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Be.err:Be.dim}},S)),Fe.createElement(E6,{isErr:s},Fe.createElement(A6,null,"Padding"),Fe.createElement(zc,{side:"top",isErr:s},g.top),Fe.createElement(zc,{side:"right",isErr:s},g.right),Fe.createElement(zc,{side:"bottom",isErr:s},g.bottom),Fe.createElement(zc,{side:"left",isErr:s},g.left),Fe.createElement(P6,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Fe.createElement(B6,{src:l,alt:"Figma element"}),Fe.createElement(D6,null,C," \xD7 ",F)))),Fe.createElement(L6,null,"border-box")),Fe.createElement(M6,null,"\u2192 ",n))},GT=ot.div({backgroundColor:Be.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),z6=ot.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),ix=ot.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Be.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),N6=ot.div({position:"absolute",border:`1.5px dashed ${Be.err}`,pointerEvents:"none",zIndex:0}),O6=ot.div({position:"absolute",border:`1.5px dashed ${Be.blue}`,pointerEvents:"none",zIndex:0}),qT=ot.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"2px 6px",borderRadius:3,zIndex:2,whiteSpace:"nowrap",...e.side==="left"&&{left:-4,top:"50%",transform:"translate(-100%, -50%)"},...e.side==="right"&&{right:-4,top:"50%",transform:"translate(100%, -50%)"}})),rde=ot.div({fontSize:12,color:Be.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),_6=ot.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),YT=ot.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Be.err:Be.ok})),$6=ot.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),KT=ot.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),XT=ot.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Be.err:Be.ok})),QT=ot.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Be.err:Be.ok,textDecoration:e.variant==="err"?"line-through":"none"})),U6=ot.span({fontSize:16,color:Be.dim,paddingBottom:20}),JT=ot.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function ZT(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var j6=({property:e,currentValue:t,expectedValue:n,figmaContext:r})=>{let o=r||{},i=e.toLowerCase(),s=i.includes("size"),a=i.includes("weight"),u=i.includes("lineheight")||i.includes("line-height"),c=i.includes("text")||i.includes("content"),l=i.includes("family"),d=s||u,f=o.fontSize??(s?Vi(n):14),p=o.fontWeight??(a?Vi(n):600),S=(o.lineHeight??(u?Vi(n):null))||Math.round((f||14)*1.43),C=`${Math.min(Math.max(f||14,24),48)}px`;if(d)return Fe.createElement(Fe.Fragment,null,Fe.createElement(GT,null,Fe.createElement(z6,null,Fe.createElement(O6,{style:{top:-6,left:0,right:0,bottom:-6}}),Fe.createElement(N6,{style:{top:2,left:8,right:8,bottom:2}}),Fe.createElement(qT,{color:s?Be.err:"#7b3030",side:"left"},s?t:`${f}px`),Fe.createElement(qT,{color:u?Be.err:"#7b3030",side:"right"},u?t:`${S}px`),Fe.createElement(ix,{fSize:C,fWeight:String(p||600)},"Ag")),Fe.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Fe.createElement(JT,{color:Be.err},"\u2508\u2508 font-size",s?" \u2717":""),Fe.createElement(JT,{color:Be.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Fe.createElement(_6,null,Fe.createElement(YT,{variant:"err"},t),Fe.createElement("span",{style:{color:Be.dim}},"\u2192"),Fe.createElement(YT,{variant:"ok"},n))));let F=a?t:String(p||600),k=a?n:F,R=Vi(t),z=Vi(n);return Fe.createElement(Fe.Fragment,null,Fe.createElement(GT,null,Fe.createElement($6,null,Fe.createElement(KT,null,Fe.createElement(XT,{variant:"err"},"Current"),Fe.createElement(ix,{fSize:C,fWeight:a?F:String(p||600),style:{color:Be.err}},c?t:"Ag"),Fe.createElement(QT,{variant:"err"},a&&R?`${t} (${ZT(R)})`:t)),Fe.createElement(U6,null,"\u2192"),Fe.createElement(KT,null,Fe.createElement(XT,{variant:"ok"},"Figma"),Fe.createElement(ix,{fSize:C,fWeight:a?k:String(p||600),style:{color:Be.ok}},c?n:"Ag"),Fe.createElement(QT,{variant:"ok"},a&&z?`${n} (${ZT(z)})`:n)))))};function H6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*px/g);if(!t)return null;let n=t.map(r=>parseFloat(r));return n.length===1?{top:n[0],right:n[0],bottom:n[0],left:n[0]}:n.length===2?{top:n[0],right:n[1],bottom:n[0],left:n[1]}:n.length===3?{top:n[0],right:n[1],bottom:n[2],left:n[1]}:n.length>=4?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:null}function Vi(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function W6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function V6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var eI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function G6(e){if(eI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return eI.has(t)}var tI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=G6(e.property);return Fe.createElement(v6,null,Fe.createElement(k6,null,"\u25BE Layer properties",t?"":" (from review)"),n?Fe.createElement(j6,{...e}):Fe.createElement(R6,{...e}))};import Nr from"react";import{styled as Or}from"storybook/theming";var q6={color:{text:"#3b82f6",bg:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.25)"},border:{text:"#10b981",bg:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.25)"},spacing:{text:"#f97316",bg:"rgba(249, 115, 22, 0.1)",border:"rgba(249, 115, 22, 0.25)"},layout:{text:"#14b8a6",bg:"rgba(20, 184, 166, 0.1)",border:"rgba(20, 184, 166, 0.25)"},sizing:{text:"#8b5cf6",bg:"rgba(139, 92, 246, 0.1)",border:"rgba(139, 92, 246, 0.25)"},typography:{text:"#ec4899",bg:"rgba(236, 72, 153, 0.1)",border:"rgba(236, 72, 153, 0.25)"}},Y6=Or.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),K6=Or.div(({theme:e,category:t})=>{let n=q6[t||""]||{text:e.textMutedColor,bg:"rgba(148, 163, 184, 0.1)",border:"rgba(148, 163, 184, 0.2)"};return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",border:`1px solid ${n.border}`}}),X6=Or.div(({status:e})=>{let n=(()=>{switch(e){case"pending":return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"};case"applied":return{bg:"rgba(245, 158, 11, 0.1)",text:"#d97706",dot:"#f59e0b"};case"verified":return{bg:"rgba(16, 185, 129, 0.1)",text:"#059669",dot:"#10b981"};case"failed":return{bg:"rgba(239, 68, 68, 0.1)",text:"#dc2626",dot:"#ef4444"};default:return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"}}})();return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:n.dot}}}),Q6=Or.div({fontSize:"11px",fontWeight:500,color:"#059669",backgroundColor:"rgba(16, 185, 129, 0.1)",padding:"2px 8px",borderRadius:"4px",border:"1px solid rgba(16, 185, 129, 0.2)",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#10b981"}}),J6=Or.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),Z6=Or.div({fontSize:"10px",fontWeight:600,color:"#0891b2",backgroundColor:"#ecfeff",padding:"2px 8px",borderRadius:"10px",border:"1px solid #0891b2",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F9E0}"',fontSize:"9px"}}),ej=Or.div({fontSize:"10px",fontWeight:600,color:"#7c3aed",backgroundColor:"#ede9fe",padding:"2px 8px",borderRadius:"10px",border:"1px solid #7c3aed",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F50D}"',fontSize:"9px"}}),tj=Or.div({fontSize:"10px",fontWeight:600,color:"#d97706",backgroundColor:"#fef3c7",padding:"2px 8px",borderRadius:"10px",border:"1px solid #d97706",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u26A0\uFE0F"',fontSize:"9px"}}),nj=Or.div(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:600,color:e.color.negative,backgroundColor:e.background.negative,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${e.color.negative}`})),rj=Or.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),oj=e=>{if(!e)return{};let t={};if(e.includes("+")){let n=e.split("+");for(let r of n)r.startsWith("programmatic-")?t.programmatic=r.replace("programmatic-","").replace("-detection",""):r==="ai"||r==="ai-review"?t.ai="AI Review":r==="ai-validation"&&(t.ai="AI Validation");return t}return e.startsWith("programmatic-")?t.programmatic=e.replace("programmatic-","").replace("-detection",""):e==="ai-review"?t.ai="AI Review":e==="ai-validation"&&(t.ai="AI Validation"),t},nI=({issue:e,modelDisplayName:t,showModel:n=!1,showDetection:r=!1,dominantDetector:o,showFilePath:i=!0,enableFilePath:s=!1,unreliable:a=!1,validationErrorMessage:u})=>{let c=oj(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),f=e.generatedFix?.filePath||e.file;return Nr.createElement(Y6,null,Nr.createElement(K6,{category:e.type},e.type),e.status!=="pending"&&Nr.createElement(X6,{status:e.status},e.status),n&&t&&Nr.createElement(Q6,null,t),d&&Nr.createElement(J6,null,c.ai&&!l&&Nr.createElement(Z6,null,c.ai),c.programmatic&&Nr.createElement(ej,null,"Pre-filter: ",c.programmatic)),a&&Nr.createElement(tj,{title:u},"Unreliable"),e.dismissed&&Nr.createElement(nj,null,"Dismissed"),i&&s&&f&&Nr.createElement(rj,null,f))};import $n from"react";import{styled as Lo}from"storybook/theming";var ij=e=>{if(!e)return null;let n=(typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e)).match(/#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b/);return n?n[0]:null},sj=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",aj=Lo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"2px",fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"8px",padding:"8px 10px",backgroundColor:e.background.app,borderRadius:"4px"})),sx=Lo.div({display:"flex",gap:"8px",alignItems:"baseline"}),ax=Lo.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),lx=Lo.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),lj=Lo(lx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),cj=Lo(lx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),uj=Lo.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
92
+ `}),n}function bT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Mc(e,t){let n=ST(e,t),r=n.one(e,void 0),o=xT(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&("children"in i,i.children.push({type:"text",value:`
93
+ `},o)),i}function Bc(e,t){return e&&"run"in e?async function(n,r){let o=Mc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Mc(n,{file:r,...e||t})}}function Kh(e){if(e)throw e}var zc=Pa(AT(),1);function ma(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Xh(){let e=[],t={run:n,use:r};return t;function n(...o){let i=-1,s=o.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...o);function a(u,...c){let l=e[++i],d=-1;if(u){s(u);return}for(;++d<o.length;)(c[d]===null||c[d]===void 0)&&(c[d]=o[d]);o=c,l?PT(l,a)(...c):s(null,...c)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function PT(e,t){let n;return r;function r(...s){let a=e.length>s.length,u;a&&s.push(o);try{u=e.apply(this,s)}catch(c){let l=c;if(a&&n)throw l;return o(l)}a||(u&&u.then&&typeof u.then=="function"?u.then(i,o):u instanceof Error?o(u):i(u))}function o(s,...a){n||(n=!0,t(s,...a))}function i(s){o(null,s)}}var kr={basename:w5,dirname:v5,extname:k5,join:C5,sep:"/"};function w5(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ha(e);let n=0,r=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,a=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else s<0&&(i=!0,s=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(r=o):(a=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}function v5(e){if(ha(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function k5(e){ha(e);let t=e.length,n=-1,r=0,o=-1,i=0,s;for(;t--;){let a=e.codePointAt(t);if(a===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),a===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||n<0||i===0||i===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function C5(...e){let t=-1,n;for(;++t<e.length;)ha(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":T5(n)}function T5(e){ha(e);let t=e.codePointAt(0)===47,n=I5(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function I5(e,t){let n="",r=0,o=-1,i=0,s=-1,a,u;for(;++s<=e.length;){if(s<e.length)a=e.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(o===s-1||i===1))if(o!==s-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),o=s,i=0;continue}}else if(n.length>0){n="",r=0,o=s,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,s):n=e.slice(o+1,s),r=s-o-1;o=s,i=0}else a===46&&i>-1?i++:i=-1}return n}function ha(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var LT={cwd:F5};function F5(){return"/"}function Hi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function MT(e){if(typeof e=="string")e=new URL(e);else if(!Hi(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return E5(e)}function E5(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let r=t.codePointAt(n+2);if(r===70||r===102){let o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}var Qh=["history","path","basename","stem","extname","dirname"],ti=class{constructor(t){let n;t?Hi(t)?n={path:t}:typeof t=="string"||A5(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":LT.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Qh.length;){let i=Qh[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let o;for(o in n)Qh.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?kr.basename(this.path):void 0}set basename(t){Zh(t,"basename"),Jh(t,"basename"),this.path=kr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?kr.dirname(this.path):void 0}set dirname(t){BT(this.basename,"dirname"),this.path=kr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?kr.extname(this.path):void 0}set extname(t){if(Jh(t,"extname"),BT(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=kr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Hi(t)&&(t=MT(t)),Zh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?kr.basename(this.path,this.extname):void 0}set stem(t){Zh(t,"stem"),Jh(t,"stem"),this.path=kr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){let o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){let o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){let o=new Ht(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Jh(e,t){if(e&&e.includes(kr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+kr.sep+"`")}function Zh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function BT(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function A5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var DT=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var P5={}.hasOwnProperty,rx=class e extends DT{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Xh()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,zc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(nx("data",this.frozen),this.namespace[t]=n,this):P5.call(this.namespace,t)&&this.namespace[t]||void 0:t?(nx("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=Rc(t),r=this.parser||this.Parser;return ex("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),ex("process",this.parser||this.Parser),tx("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=Rc(t),u=r.parse(a);r.run(u,a,function(l,d,f){if(l||!d||!f)return c(l);let p=d,g=r.stringify(p,f);M5(g)?f.value=g:f.result=g,c(l,f)});function c(l,d){l||!d?s(l):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),ex("processSync",this.parser||this.Parser),tx("processSync",this.compiler||this.Compiler),this.process(t,o),zT("processSync","process",n),r;function o(i,s){n=!0,Kh(i),r=s}}run(t,n,r){RT(t),this.freeze();let o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(s,a){let u=Rc(n);o.run(t,u,c);function c(l,d,f){let p=d||t;l?a(l):s?s(p):r(void 0,p,f)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),zT("runSync","run",r),o;function i(s,a){Kh(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Rc(n),o=this.compiler||this.Compiler;return tx("stringify",o),RT(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(nx("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):s(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(c){if(typeof c=="function")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[l,...d]=c;u(l,d)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(o.settings=(0,zc.default)(!0,o.settings,c.settings))}function a(c){let l=-1;if(c!=null)if(Array.isArray(c))for(;++l<c.length;){let d=c[l];i(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,l){let d=-1,f=-1;for(;++d<r.length;)if(r[d][0]===c){f=d;break}if(f===-1)r.push([c,...l]);else if(l.length>0){let[p,...g]=l,S=r[f][1];ma(S)&&ma(p)&&(p=(0,zc.default)(!0,S,p)),r[f]=[c,p,...g]}}}},ox=new rx().freeze();function ex(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function tx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function nx(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function RT(e){if(!ma(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zT(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Rc(e){return L5(e)?e:new ti(e)}function L5(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function M5(e){return typeof e=="string"||B5(e)}function B5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var N5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",NT=[],OT={allowDangerousHtml:!0},O5=/^(https?|ircs?|mailto|xmpp)$/i,_5=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function ix(e){let t=$5(e),n=U5(e);return j5(t.runSync(t.parse(n),n),e)}function $5(e){let t=e.rehypePlugins||NT,n=e.remarkPlugins||NT,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...OT}:OT;return ox().use(Cc).use(n).use(Bc,r).use(t)}function U5(e){let t=e.children||"",n=new ti;return typeof t=="string"?n.value=t:(""+t,void 0),n}function j5(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||_T;for(let l of _5)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+N5+l.id,void 0);return n&&i&&void 0,ga(e,c),Sh(e,{Fragment:D5,components:o,ignoreInvalidStyle:!0,jsx:R5,jsxs:z5,passKeys:!0,passNode:!0});function c(l,d,f){if(l.type==="raw"&&f&&typeof d=="number")return s?f.children.splice(d,1):f.children[d]={type:"text",value:l.value},d;if(l.type==="element"){let p;for(p in sa)if(Object.hasOwn(sa,p)&&Object.hasOwn(l.properties,p)){let g=l.properties[p],S=sa[p];(S===null||S.includes(l.tagName))&&(l.properties[p]=u(String(g||""),p,l))}}if(l.type==="element"){let p=n?!n.includes(l.tagName):i?i.includes(l.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(l,d,f)),p&&f&&typeof d=="number")return a&&l.children?f.children.splice(d,1,...l.children):f.children.splice(d,1),d}}}function _T(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||O5.test(e.slice(0,t))?e:""}ve();var W5=Wi.div({display:"flex",flexDirection:"column",gap:"12px"}),V5=Wi.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),G5=Wi.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),q5=Wi(er)({padding:"6px 12px",fontSize:"12px"}),Y5=Wi.div(({theme:e})=>({backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"12px",fontSize:"12px",color:e.color.defaultText,overflowY:"auto",maxHeight:"400px",lineHeight:"1.6","& h1, & h2, & h3, & h4":{marginTop:"16px",marginBottom:"8px",fontWeight:600,color:e.color.defaultText},"& h1":{fontSize:"18px"},"& h2":{fontSize:"16px"},"& h3":{fontSize:"14px"},"& h4":{fontSize:"13px"},"& p":{margin:"8px 0"},"& ul, & ol":{paddingLeft:"20px",margin:"8px 0"},"& li":{margin:"4px 0"},"& code":{backgroundColor:e.background.app,padding:"2px 4px",borderRadius:"3px",fontFamily:NC.fontMono,fontSize:"11px"},"& pre":{backgroundColor:e.background.app,padding:"8px",borderRadius:"4px",overflowX:"auto","& code":{backgroundColor:"transparent",padding:0}},"& strong":{fontWeight:600},"& blockquote":{borderLeft:`3px solid ${e.color.secondary}`,paddingLeft:"12px",margin:"8px 0",color:e.color.mediumdark}})),K5=Wi.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),sx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ie(),[r,o]=H5(!1);if((n??t)!=="admin")return null;let s=async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(a){console.error("Failed to copy:",a)}};return e?ni.createElement(W5,null,ni.createElement(V5,null,ni.createElement(G5,null,"Full Prompt"),ni.createElement(q5,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),ni.createElement(Y5,null,ni.createElement(ix,null,e))):ni.createElement(K5,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import eo,{useRef as X5}from"react";import{styled as Cr}from"storybook/theming";ve();var Q5=Cr.div({display:"flex",flexDirection:"column",gap:"8px"}),Tpe=Cr.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"11px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"3px 10px",borderRadius:"12px",border:`1px solid ${o.border}`,whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:"6px"}}),J5=Cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflowY:"auto",scrollBehavior:"smooth",padding:"6px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app})),Z5=Cr.div(({role:e,theme:t})=>({padding:"8px 10px",borderRadius:"4px",fontSize:"11px",lineHeight:"1.4",backgroundColor:e==="system"?t.background.hoverable:t.background.content,border:`1px solid ${t.appBorderColor}`,color:t.color.defaultText})),Ipe=Cr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),$T=Cr.div(({theme:e})=>({whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"10px","& .section-header":{fontSize:"11px",fontWeight:700,color:e.color.secondary,marginTop:"8px",marginBottom:"4px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"6px",marginBottom:"2px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||le,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"11px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"1px 6px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"3px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||le,backgroundColor:e.background.warning||"#ffedd5"}})),e6=Cr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),t6=Cr.div(({theme:e})=>({padding:"12px 16px",borderRadius:"8px",backgroundColor:e.background.positive||"#dcfce7",border:`1px solid ${e.color.positive||"#86efac"}`,color:e.color.positive||"#166534",fontSize:"13px",fontWeight:500,lineHeight:1.5,marginBottom:"12px"})),n6=Cr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),r6=Cr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),Fpe=Cr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function o6(e){let t=e;return t=t.replace(/^(?:\*?\*?)?(?:##?)?\s*SCORE:\s*\d+.*$/gm,""),t=t.replace(/^(ISSUES:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t}var ax=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ie(),s=X5(null);if((i??o)!=="admin")return null;let u=r?n.find(g=>g.id===r):null,c=u?u.issues.length>0&&u.issues.every(g=>g.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(g=>g.role==="assistant"||g.role==="system"&&g.content.includes("auto-dismissed")),f=d.length===0&&!!t;if(d.length===0&&!f)return eo.createElement(e6,null,"No AI response yet. The AI's analysis will appear here as it streams.");let p=d.length>0?d:[{role:"assistant",content:t}];return eo.createElement(Q5,null,l&&eo.createElement(t6,null,eo.createElement(n6,null,"Component Matches Design"),eo.createElement(r6,null,c&&u?.issues.length?`All ${u.issues.length} issue${u.issues.length===1?"":"s"} identified by the AI ${u.issues.length===1?"was":"were"} validated as false positive${u.issues.length===1?"":"s"} and auto-dismissed.`:"No design discrepancies found. The implementation matches the Figma design.")),eo.createElement(J5,{ref:s},p.map((g,S)=>eo.createElement(Z5,{key:S,role:g.role},g.role==="system"?eo.createElement($T,null,g.content):eo.createElement($T,{dangerouslySetInnerHTML:{__html:o6(g.content)}})))))};import dr from"react";import{styled as Po}from"storybook/theming";ve();De();var i6=Po.div({display:"flex",flexDirection:"column",gap:"12px"}),s6=Po.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),a6=Po.button(({theme:e,isActive:t,provider:n})=>{let o={anthropic:{background:"#D4A574",text:"#ffffff",hover:"#C49564"},openai:{background:e.color.positive||"#10b981",text:"#ffffff",hover:e.base==="dark"?"#34d399":"#059669"},google:{background:"#4285F4",text:"#ffffff",hover:"#3367D6"}}[n];return{display:"flex",alignItems:"center",gap:"6px",padding:"8px 16px",fontSize:"12px",fontWeight:600,color:t?o.text:e.textMutedColor,backgroundColor:t?o.background:"transparent",border:"none",borderRadius:"6px 6px 0 0",cursor:"pointer",whiteSpace:"nowrap",transition:"all 0.2s",opacity:t?1:.6,"&:hover":{opacity:1,backgroundColor:t?o.hover:e.background.hoverable}}}),UT=Po.div(({theme:e,variant:t,value:n})=>{let o=t==="issues"?n===0?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n<=3?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n<=6?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"}:n>=80?{bg:e.background.positive||"#dcfce7",text:e.color.positive||"#166534",border:e.color.positive||"#86efac"}:n>=60?{bg:e.background.warning||"#fef3c7",text:e.color.warning||"#92400e",border:e.color.warning||"#fde68a"}:n>=40?{bg:e.background.warning||"#fed7aa",text:e.color.warning||"#9a3412",border:e.color.warning||"#fdba74"}:{bg:e.background.negative||"#fecaca",text:e.color.negative||"#991b1b",border:e.color.negative||"#fca5a5"};return{fontSize:"10px",fontWeight:700,color:o.text,backgroundColor:o.bg,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${o.border}`,whiteSpace:"nowrap"}}),l6=Po.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),jT=Po.div(({theme:e})=>({fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',color:e.color.defaultText,"& .section-header":{fontSize:"13px",fontWeight:700,color:e.color.secondary,marginTop:"12px",marginBottom:"6px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"10px",marginBottom:"4px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||le,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"14px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"2px 8px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"4px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||le,backgroundColor:e.background.warning||"#ffedd5"}})),HT=Po.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),c6=Po.div({width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite",display:"inline-block",marginLeft:"6px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}});function WT(e){let t=e;return t=t.replace(/^(ISSUES:|SCORE:|SUMMARY:)/gm,'<span class="section-header">$1</span>'),t=t.replace(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g,(n,r,o,i,s)=>{let a=o.toLowerCase().includes("critical")?"severity-critical":o.toLowerCase().includes("major")?"severity-major":"severity-minor";return`<span class="issue-header"><span class="issue-type">[${r}]</span> <span class="${a}">[${o}]</span> <span class="source-tag">[${i}]</span> - ${s}</span>`}),t=t.replace(/^(Expected:|Actual:|Property:|Source:|Fix:|Visual Difference:)\s*(.+)/gm,'<span class="field-label">$1</span> <span class="field-value">$2</span>'),t=t.replace(/SCORE:\s*(\d+)/g,(n,r)=>{let o=parseInt(r,10);return`SCORE: <span class="${o>=80?"score":o>=60?"score score-medium":"score score-low"}">${r}</span>`}),t}function u6(e){let t=e.match(/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-/g),n=t?t.length:0,r=e.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i),o=r?parseInt(r[1],10):null;return{issueCount:n,score:o}}var VT=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ie();if((i??o)!=="admin")return null;dr.useEffect(()=>{e&&(y.debug("[ModelResultsTabs] multiModelResults:",e),Object.entries(e.byModel).forEach(([l,d])=>{y.debug(`[ModelResultsTabs] ${l}:`,{hasStreamingMessages:!!d.streamingMessages,streamingMessagesLength:d.streamingMessages?.length||0,streamingMessagesPreview:d.streamingMessages?.[0]?.content?.substring(0,100),hasFullResponse:!!d.fullResponse,fullResponsePreview:d.fullResponse?.substring(0,100)})}))},[e]);let a=e&&Object.keys(e.byModel).length>0?Object.keys(e.byModel):r,u=e?.activeModelId||(a.length>0?a[0]:""),c=e?.byModel||{};return a.length===0?dr.createElement(HT,null,"No models selected. Select multiple models to compare results."):dr.createElement(i6,null,dr.createElement(s6,null,a.map(l=>{let d=Qr.find(F=>F.id===l),f=c[l],g=u6(t&&f?.streamingMessages&&f.streamingMessages.length>0?f.streamingMessages[0].content||"":f?.fullResponse?f.fullResponse:""),S=l===u;if(!d)return null;let C=t&&!f?.completed;return dr.createElement(a6,{key:l,isActive:S,provider:d.provider,onClick:()=>n(l)},d.name,f&&g.issueCount>0&&dr.createElement(UT,{variant:"issues",value:g.issueCount},g.issueCount," issues"),f&&g.score!==null&&dr.createElement(UT,{variant:"score",value:g.score},"Score: ",g.score),C&&dr.createElement(c6,null))})),dr.createElement(l6,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>dr.createElement(jT,{key:d,dangerouslySetInnerHTML:{__html:WT(l.content)}})):c[u]?.fullResponse?dr.createElement(jT,{dangerouslySetInnerHTML:{__html:WT(c[u].fullResponse)}}):dr.createElement(HT,null,t?`Waiting for ${Qr.find(l=>l.id===u)?.name}...`:`No response yet for ${Qr.find(l=>l.id===u)?.name}`)))};import Ue from"react";import{styled as Ct}from"storybook/theming";ve();Ls();ve();import{useCallback as lx}from"react";De();function GT(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ie(),{sessionToken:r}=we(),o=lx(a=>{for(let u of n){let c=u.issues.find(l=>l.id===a);if(c)return c.dbId||c.id||null}return null},[n]),i=lx((a,u)=>{e(a,u,"user");let c=o(a);if(!c){y.debug("[useIssuePersistence] Dismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Dismiss skipped \u2014 no session token");return}Nl(c,!0,u,"user",r).then(l=>{l.success||y.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=lx(a=>{t(a);let u=o(a);if(!u){y.debug("[useIssuePersistence] Undismiss skipped server sync \u2014 no dbId for",a);return}if(!r){y.debug("[useIssuePersistence] Undismiss skipped \u2014 no session token");return}Nl(u,!1,void 0,"user",r).then(c=>{c.success||y.warn("[useIssuePersistence] Undismiss server sync failed:",c.error)})},[t,o,r]);return{dismissAndSync:i,undismissAndSync:s}}import V,{useMemo as SH,useState as wH,useEffect as vH}from"react";import{styled as it,keyframes as kH}from"storybook/theming";import Z,{useState as fx,useRef as pj,useCallback as aI,memo as dj}from"react";import{styled as Ee}from"storybook/theming";import to,{useState as p6}from"react";import{styled as no}from"storybook/theming";var d6=no.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999}),f6=no.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"8px",padding:"24px",maxWidth:"500px",width:"90%",boxShadow:e.base==="dark"?"0 10px 40px rgba(0, 0, 0, 0.5)":"0 10px 40px rgba(0, 0, 0, 0.2)",border:`1px solid ${e.appBorderColor}`})),g6=no.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),m6=no.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),h6=no.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),x6=no.textarea(({theme:e})=>({width:"100%",minHeight:"80px",padding:"10px",fontSize:"13px",borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",marginBottom:"20px","&:focus":{outline:"none",borderColor:le,boxShadow:`0 0 0 3px ${e.base==="dark"?"rgba(124, 58, 237, 0.2)":"rgba(124, 58, 237, 0.1)"}`},"&::placeholder":{color:e.textMutedColor}})),y6=no.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),b6=no(en)({}),S6=no(Er)({}),qT=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=p6("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return to.createElement(d6,{onClick:c=>{c.target===c.currentTarget&&a()}},to.createElement(f6,null,to.createElement(g6,null,"Dismiss as False Positive"),to.createElement(m6,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),to.createElement(h6,{htmlFor:"dismiss-reason"},"Reason (optional)"),to.createElement(x6,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),to.createElement(y6,null,to.createElement(S6,{onClick:a},"Cancel"),to.createElement(b6,{onClick:s},"Dismiss Issue"))))};ve();import Fe from"react";import{styled as ot}from"storybook/theming";var Be={outerBg:"#f0f0f0",borderBoxBg:"#fff",borderBoxStroke:"#999",paddingBg:"#dceefb",paddingStroke:"rgba(0,0,0,0.08)",contentStroke:"#888",text:"#333",dim:"#999",dash:"#aaa",blue:"#4a90d9",pink:"#e91e8c",err:"#d32f2f",errBg:"rgba(211,47,47,0.12)",ok:"#2e7d32"},w6=ot.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),v6=ot.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),k6=ot.div({position:"relative",backgroundColor:Be.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Ype=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Be.dash,padding:"0 8px",height:18,fontSize:11}),Kpe=ot.div({position:"absolute",color:Be.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Xpe=ot.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"1px 6px",borderRadius:3,zIndex:2,...e.side==="top"&&{top:4,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:4,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:4,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:4,top:"50%",transform:"translateY(-50%)"}})),Qpe=ot.div(e=>({position:"absolute",backgroundColor:e.color,zIndex:1,...e.orient==="v"&&{width:1,left:"50%"},...e.orient==="h"&&{height:1,top:"50%"},...e.side==="top"&&{top:18,height:10},...e.side==="bottom"&&{bottom:18,height:10},...e.side==="left"&&{left:30,width:20},...e.side==="right"&&{right:30,width:20}})),C6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Be.errBg:Be.borderBoxBg,border:`1px solid ${e.isErr?Be.err:Be.borderBoxStroke}`,borderRadius:6,padding:0})),T6=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Be.text}),I6=ot.span({fontWeight:500,fontSize:11}),Jpe=ot.span({color:Be.dash}),F6=ot.div(e=>({position:"relative",backgroundColor:e.isErr?Be.errBg:Be.paddingBg,border:`1px solid ${e.isErr?Be.err:Be.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),E6=ot.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Be.text,fontStyle:"italic"}),Nc=ot.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Be.err:Be.text,fontWeight:e.isErr?700:400,...e.side==="top"&&{top:3,left:"50%",transform:"translateX(-50%)"},...e.side==="bottom"&&{bottom:3,left:"50%",transform:"translateX(-50%)"},...e.side==="left"&&{left:8,top:"50%",transform:"translateY(-50%)"},...e.side==="right"&&{right:8,top:"50%",transform:"translateY(-50%)"}})),A6=ot.div(e=>({backgroundColor:e.isErr?Be.errBg:"#fff",border:`1.5px dashed ${e.isErr?Be.err:Be.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Be.err:Be.text,fontWeight:e.isErr?600:400})),P6=ot.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Be.dim,fontFamily:"monospace"}),L6=ot.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Be.ok,padding:"4px 8px 6px"}),Zpe=ot.div({fontSize:11,fontWeight:600,color:Be.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),ede=ot.span({fontSize:12,color:Be.dim}),M6=ot.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),B6=ot.div({fontSize:9,color:Be.dim,marginTop:2}),D6=({property:e,currentValue:t,expectedValue:n,figmaContext:r,elementName:o})=>{let i=e.toLowerCase(),s=i.includes("padding"),a=i.includes("border")||i.includes("stroke")||i.includes("box-shadow"),u=i.includes("width")||i.includes("height")||i==="dimensions",c=i.includes("radius"),{figmaImageUrl:l}=ie(),d=r||{},p=!(!!r&&Object.keys(r).length>0)&&s?j6(n):null,g=d.padding||p||{top:0,right:0,bottom:0,left:0},S=d.strokeWeight??(a?Vi(n)??0:0),C=d.width??(u?H6(n)??"\u2014":"\u2014"),F=d.height??(u?W6(n)??"\u2014":"\u2014");return Fe.createElement(Fe.Fragment,null,Fe.createElement(k6,null,Fe.createElement(C6,{isErr:a},Fe.createElement(T6,null,Fe.createElement(I6,null,"Border"),Fe.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Be.err:Be.dim}},S)),Fe.createElement(F6,{isErr:s},Fe.createElement(E6,null,"Padding"),Fe.createElement(Nc,{side:"top",isErr:s},g.top),Fe.createElement(Nc,{side:"right",isErr:s},g.right),Fe.createElement(Nc,{side:"bottom",isErr:s},g.bottom),Fe.createElement(Nc,{side:"left",isErr:s},g.left),Fe.createElement(A6,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Fe.createElement(M6,{src:l,alt:"Figma element"}),Fe.createElement(B6,null,C," \xD7 ",F)))),Fe.createElement(P6,null,"border-box")),Fe.createElement(L6,null,"\u2192 ",n))},YT=ot.div({backgroundColor:Be.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),R6=ot.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),cx=ot.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Be.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),z6=ot.div({position:"absolute",border:`1.5px dashed ${Be.err}`,pointerEvents:"none",zIndex:0}),N6=ot.div({position:"absolute",border:`1.5px dashed ${Be.blue}`,pointerEvents:"none",zIndex:0}),KT=ot.div(e=>({position:"absolute",backgroundColor:e.color,color:"#fff",fontSize:10,fontWeight:600,fontFamily:"monospace",padding:"2px 6px",borderRadius:3,zIndex:2,whiteSpace:"nowrap",...e.side==="left"&&{left:-4,top:"50%",transform:"translate(-100%, -50%)"},...e.side==="right"&&{right:-4,top:"50%",transform:"translate(100%, -50%)"}})),tde=ot.div({fontSize:12,color:Be.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),O6=ot.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),XT=ot.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Be.err:Be.ok})),_6=ot.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),QT=ot.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),JT=ot.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Be.err:Be.ok})),ZT=ot.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Be.err:Be.ok,textDecoration:e.variant==="err"?"line-through":"none"})),$6=ot.span({fontSize:16,color:Be.dim,paddingBottom:20}),eI=ot.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function tI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var U6=({property:e,currentValue:t,expectedValue:n,figmaContext:r})=>{let o=r||{},i=e.toLowerCase(),s=i.includes("size"),a=i.includes("weight"),u=i.includes("lineheight")||i.includes("line-height"),c=i.includes("text")||i.includes("content"),l=i.includes("family"),d=s||u,f=o.fontSize??(s?Vi(n):14),p=o.fontWeight??(a?Vi(n):600),S=(o.lineHeight??(u?Vi(n):null))||Math.round((f||14)*1.43),C=`${Math.min(Math.max(f||14,24),48)}px`;if(d)return Fe.createElement(Fe.Fragment,null,Fe.createElement(YT,null,Fe.createElement(R6,null,Fe.createElement(N6,{style:{top:-6,left:0,right:0,bottom:-6}}),Fe.createElement(z6,{style:{top:2,left:8,right:8,bottom:2}}),Fe.createElement(KT,{color:s?Be.err:"#7b3030",side:"left"},s?t:`${f}px`),Fe.createElement(KT,{color:u?Be.err:"#7b3030",side:"right"},u?t:`${S}px`),Fe.createElement(cx,{fSize:C,fWeight:String(p||600)},"Ag")),Fe.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Fe.createElement(eI,{color:Be.err},"\u2508\u2508 font-size",s?" \u2717":""),Fe.createElement(eI,{color:Be.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Fe.createElement(O6,null,Fe.createElement(XT,{variant:"err"},t),Fe.createElement("span",{style:{color:Be.dim}},"\u2192"),Fe.createElement(XT,{variant:"ok"},n))));let F=a?t:String(p||600),k=a?n:F,R=Vi(t),z=Vi(n);return Fe.createElement(Fe.Fragment,null,Fe.createElement(YT,null,Fe.createElement(_6,null,Fe.createElement(QT,null,Fe.createElement(JT,{variant:"err"},"Current"),Fe.createElement(cx,{fSize:C,fWeight:a?F:String(p||600),style:{color:Be.err}},c?t:"Ag"),Fe.createElement(ZT,{variant:"err"},a&&R?`${t} (${tI(R)})`:t)),Fe.createElement($6,null,"\u2192"),Fe.createElement(QT,null,Fe.createElement(JT,{variant:"ok"},"Figma"),Fe.createElement(cx,{fSize:C,fWeight:a?k:String(p||600),style:{color:Be.ok}},c?n:"Ag"),Fe.createElement(ZT,{variant:"ok"},a&&z?`${n} (${tI(z)})`:n)))))};function j6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*px/g);if(!t)return null;let n=t.map(r=>parseFloat(r));return n.length===1?{top:n[0],right:n[0],bottom:n[0],left:n[0]}:n.length===2?{top:n[0],right:n[1],bottom:n[0],left:n[1]}:n.length===3?{top:n[0],right:n[1],bottom:n[2],left:n[1]}:n.length>=4?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:null}function Vi(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function H6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function W6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var nI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function V6(e){if(nI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return nI.has(t)}var rI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=V6(e.property);return Fe.createElement(w6,null,Fe.createElement(v6,null,"\u25BE Layer properties",t?"":" (from review)"),n?Fe.createElement(U6,{...e}):Fe.createElement(D6,{...e}))};import Nr from"react";import{styled as Or}from"storybook/theming";var G6={color:{text:"#3b82f6",bg:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.25)"},border:{text:"#10b981",bg:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.25)"},spacing:{text:"#f97316",bg:"rgba(249, 115, 22, 0.1)",border:"rgba(249, 115, 22, 0.25)"},layout:{text:"#14b8a6",bg:"rgba(20, 184, 166, 0.1)",border:"rgba(20, 184, 166, 0.25)"},sizing:{text:"#8b5cf6",bg:"rgba(139, 92, 246, 0.1)",border:"rgba(139, 92, 246, 0.25)"},typography:{text:"#ec4899",bg:"rgba(236, 72, 153, 0.1)",border:"rgba(236, 72, 153, 0.25)"}},q6=Or.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),Y6=Or.div(({theme:e,category:t})=>{let n=G6[t||""]||{text:e.textMutedColor,bg:"rgba(148, 163, 184, 0.1)",border:"rgba(148, 163, 184, 0.2)"};return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",border:`1px solid ${n.border}`}}),K6=Or.div(({status:e})=>{let n=(()=>{switch(e){case"pending":return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"};case"applied":return{bg:"rgba(245, 158, 11, 0.1)",text:"#d97706",dot:"#f59e0b"};case"verified":return{bg:"rgba(16, 185, 129, 0.1)",text:"#059669",dot:"#10b981"};case"failed":return{bg:"rgba(239, 68, 68, 0.1)",text:"#dc2626",dot:"#ef4444"};default:return{bg:"rgba(148, 163, 184, 0.15)",text:"#64748b",dot:"#94a3b8"}}})();return{fontSize:"11px",fontWeight:500,color:n.text,backgroundColor:n.bg,padding:"2px 8px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:n.dot}}}),X6=Or.div({fontSize:"11px",fontWeight:500,color:"#059669",backgroundColor:"rgba(16, 185, 129, 0.1)",padding:"2px 8px",borderRadius:"4px",border:"1px solid rgba(16, 185, 129, 0.2)",display:"flex",alignItems:"center",gap:"5px","&::before":{content:'""',display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#10b981"}}),Q6=Or.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),J6=Or.div({fontSize:"10px",fontWeight:600,color:"#0891b2",backgroundColor:"#ecfeff",padding:"2px 8px",borderRadius:"10px",border:"1px solid #0891b2",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F9E0}"',fontSize:"9px"}}),Z6=Or.div({fontSize:"10px",fontWeight:600,color:"#7c3aed",backgroundColor:"#ede9fe",padding:"2px 8px",borderRadius:"10px",border:"1px solid #7c3aed",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F50D}"',fontSize:"9px"}}),ej=Or.div({fontSize:"10px",fontWeight:600,color:"#d97706",backgroundColor:"#fef3c7",padding:"2px 8px",borderRadius:"10px",border:"1px solid #d97706",display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u26A0\uFE0F"',fontSize:"9px"}}),tj=Or.div(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:600,color:e.color.negative,backgroundColor:e.background.negative,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${e.color.negative}`})),nj=Or.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),rj=e=>{if(!e)return{};let t={};if(e.includes("+")){let n=e.split("+");for(let r of n)r.startsWith("programmatic-")?t.programmatic=r.replace("programmatic-","").replace("-detection",""):r==="ai"||r==="ai-review"?t.ai="AI Review":r==="ai-validation"&&(t.ai="AI Validation");return t}return e.startsWith("programmatic-")?t.programmatic=e.replace("programmatic-","").replace("-detection",""):e==="ai-review"?t.ai="AI Review":e==="ai-validation"&&(t.ai="AI Validation"),t},oI=({issue:e,modelDisplayName:t,showModel:n=!1,showDetection:r=!1,dominantDetector:o,showFilePath:i=!0,enableFilePath:s=!1,unreliable:a=!1,validationErrorMessage:u})=>{let c=rj(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),f=e.generatedFix?.filePath||e.file;return Nr.createElement(q6,null,Nr.createElement(Y6,{category:e.type},e.type),e.status!=="pending"&&Nr.createElement(K6,{status:e.status},e.status),n&&t&&Nr.createElement(X6,null,t),d&&Nr.createElement(Q6,null,c.ai&&!l&&Nr.createElement(J6,null,c.ai),c.programmatic&&Nr.createElement(Z6,null,"Pre-filter: ",c.programmatic)),a&&Nr.createElement(ej,{title:u},"Unreliable"),e.dismissed&&Nr.createElement(tj,null,"Dismissed"),i&&s&&f&&Nr.createElement(nj,null,f))};import $n from"react";import{styled as Lo}from"storybook/theming";var oj=e=>{if(!e)return null;let n=(typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e)).match(/#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b/);return n?n[0]:null},ij=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",sj=Lo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"2px",fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"8px",padding:"8px 10px",backgroundColor:e.background.app,borderRadius:"4px"})),ux=Lo.div({display:"flex",gap:"8px",alignItems:"baseline"}),px=Lo.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),dx=Lo.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),aj=Lo(dx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),lj=Lo(dx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),cj=Lo.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
94
94
  linear-gradient(${e}, ${e}),
95
95
  linear-gradient(45deg, rgba(0,0,0,0.08) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.08) 75%),
96
96
  linear-gradient(45deg, rgba(0,0,0,0.08) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.08) 75%)
97
- `,backgroundSize:"100% 100%, 6px 6px, 6px 6px",backgroundPosition:"0 0, 0 0, 3px 3px",border:"1px solid rgba(0, 0, 0, 0.15)",marginRight:"6px",verticalAlign:"middle",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.15)"})),pj=Lo.span({display:"flex",alignItems:"center"}),rI=({value:e,isStrikethrough:t=!1})=>{let n=ij(e),r=sj(e),o=t?lj:cj;return n?$n.createElement(pj,null,$n.createElement(uj,{color:n,title:`Color: ${n}`}),$n.createElement(o,null,r)):$n.createElement(o,null,r)},oI=({property:e,currentValue:t,suggestedValue:n})=>$n.createElement(aj,null,$n.createElement(sx,null,$n.createElement(ax,null,"Property"),$n.createElement(lx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&$n.createElement(sx,null,$n.createElement(ax,null,"Current"),$n.createElement(rI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&$n.createElement(sx,null,$n.createElement(ax,null,"Expected"),$n.createElement(rI,{value:n,isStrikethrough:!1})));ve();var sI=new Set(["dimensions","width","height","minWidth","minHeight","maxWidth","maxHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","padding-top","padding-right","padding-bottom","padding-left","border","borderWidth","border-width","border / box-shadow","borderRadius","border-radius","gap","rowGap","columnGap"]);function gj(e){if(sI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return sI.has(t)}var mj=Ee.div(({theme:e,dismissed:t,fixApplied:n})=>({padding:"14px 16px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:t?e.background.negative:n?e.background.positive:"transparent",opacity:t?.7:n?.6:1,position:"relative",transition:"background-color 0.15s","&:hover":{backgroundColor:t||n?void 0:e.base==="dark"?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.02)"},"&:first-of-type":{borderTop:"none"}})),bde=Ee.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),hj=Ee.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),xj=Ee.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),yj=Ee.input(({theme:e})=>({appearance:"none",WebkitAppearance:"none",marginTop:"2px",width:"14px",height:"14px",cursor:"pointer",flexShrink:0,border:`1.5px solid ${e.color.mediumdark||"#cbd5e1"}`,borderRadius:"3px",backgroundColor:e.background.content,position:"relative",transition:"all 0.15s","&:hover":{borderColor:le},"&:checked":{backgroundColor:le,borderColor:le},"&:checked::after":{content:'""',position:"absolute",left:"3px",top:"0px",width:"4px",height:"8px",border:"solid #fff",borderWidth:"0 2px 2px 0",transform:"rotate(45deg)"},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),bj=Ee.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:"#94a3b8","& svg":{width:"16px",height:"16px"}})),Sde=Ee.div({flex:1,minWidth:0}),wde=Ee.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),Sj=Ee.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),ux=Ee.button(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"0",fontSize:"11px",fontWeight:400,color:e.textMutedColor,backgroundColor:"transparent",border:"none",cursor:"pointer",transition:"color 0.15s","&:hover":{color:e.color.defaultText},"& svg":{width:"11px",height:"11px"}})),wj=Ee(ux)(({theme:e})=>({"&:hover":{color:e.color.negative}})),vde=Ee.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),kde=Ee.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),vj=Ee.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),Cde=Ee.pre(({theme:e})=>({fontSize:"13px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"12px",borderRadius:"4px",overflowX:"auto",margin:"8px 0 0 0",lineHeight:"1.5"})),Tde=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),kj=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginTop:"6px",fontStyle:"italic",display:"flex",alignItems:"baseline",gap:"4px","& strong":{fontStyle:"normal",fontWeight:600,color:"#7c3aed",fontSize:"10px"}})),Cj=Ee.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${le}`})),Tj=Ee.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:le,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),Ij=Ee.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr auto auto",gap:"8px",alignItems:"center",padding:"4px 0",fontSize:"11px",borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),Fj=Ee.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),aI=Ee.span(({theme:e,type:t})=>({fontFamily:"monospace",fontSize:"10px",padding:"2px 6px",borderRadius:"3px",backgroundColor:t==="current"?e.background.negative:e.background.positive,color:t==="current"?e.color.negative:e.color.positive,textDecoration:t==="current"?"line-through":"none"})),Ide=Ee.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),Ej=Ee(wn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),Fde=Ee(Ej)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),Aj=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontStyle:"italic",marginTop:"8px",padding:"8px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${e.color.negative}`})),lI=Ee.div(({theme:e})=>({fontSize:"11px",color:e.color.negative,backgroundColor:e.background.negative,padding:"10px",borderRadius:"4px",marginTop:"10px",borderLeft:`3px solid ${e.color.negative}`,fontFamily:"monospace",lineHeight:"1.5"})),Pj=Ee.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),Lj=Ee.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),Mj=Ee.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),Bj=Ee.span(({theme:e,confidence:t})=>({padding:"4px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,backgroundColor:t>=.8?e.background.positive:t>=.6?e.background.warning:e.background.negative,color:t>=.8?e.color.positive:t>=.6?e.color.warning:e.color.negative})),cI=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),uI=Ee.details({marginBottom:"8px"}),pI=Ee.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),Dj=Ee.pre(({theme:e})=>({fontSize:"11px",fontFamily:"monospace",backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"10px",borderRadius:"4px",overflowX:"auto",margin:0,lineHeight:"1.5",maxHeight:"300px",overflowY:"auto"})),Rj=Ee.div({display:"flex",gap:"8px",marginTop:"8px"}),zj=Ee(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),Nj=Ee(Er)({padding:"6px 12px",fontSize:"12px"}),Ede=Ee(qt)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),Ade=Ee.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),Oj=Ee.div({display:"flex",alignItems:"center",gap:"12px"}),_j=Ee.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),$j=Ee.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),Pde=Ee.div(({theme:e,width:t="100%"})=>({height:"10px",backgroundColor:e.background.app,borderRadius:"4px",width:t,animation:"pulse 1.5s ease-in-out infinite","@keyframes pulse":{"0%, 100%":{opacity:1},"50%":{opacity:.5}}})),Uj=Ee.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",fontSize:"11px",fontFamily:"monospace",lineHeight:"1.5",marginTop:"8px"})),dI=Ee.div(({theme:e,side:t})=>({backgroundColor:t==="old"?e.background.negative:e.background.positive,borderRight:t==="old"?`1px solid ${e.appBorderColor}`:"none",minWidth:0,overflow:"hidden"})),fI=Ee.div(({theme:e,side:t})=>({padding:"6px 8px",fontWeight:600,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="old"?e.background.negative:e.background.positive,color:t==="old"?e.color.negative:e.color.positive,borderBottom:`1px solid ${e.appBorderColor}`})),gI=Ee.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),mI=Ee.div(({theme:e,type:t})=>{let n="transparent",r=e.color.defaultText;return t==="removed"?(n=e.background.negative,r=e.color.negative):t==="added"?(n=e.background.positive,r=e.color.positive):t==="empty"&&(n=e.background.app,r=e.textMutedColor),{padding:"2px 8px",backgroundColor:n,color:r,whiteSpace:"pre",minHeight:"20px",borderBottom:"1px solid rgba(0, 0, 0, 0.05)"}}),hI=Ee.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),xI=e=>{let t=e.split(`
98
- `),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(!o.startsWith("@@"))if(o.startsWith("-"))n.push({oldLine:{type:"removed",content:o.substring(1)},newLine:{type:"empty",content:""}});else if(o.startsWith("+"))n.push({oldLine:{type:"empty",content:""},newLine:{type:"added",content:o.substring(1)}});else{let i=o.startsWith(" ")?o.substring(1):o;n.push({oldLine:{type:"context",content:i},newLine:{type:"context",content:i}})}}return n},jj=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},Hj=e=>({"claude-sonnet-4-5-20250929":"Sonnet 4.5","claude-sonnet-4-20250514":"Sonnet 4","claude-sonnet-3-5-20240620":"Sonnet 3.5","claude-3-opus-20240229":"Opus 3","gpt-5":"GPT-5","gpt-5-mini":"GPT-5 Mini","gpt-5.2-chat-latest":"GPT-5.2 Instant","gpt-4o":"GPT-4o"})[e]||e,yI=fj(({issue:e,modelId:t,dominantDetector:n,showFilePath:r=!0,onToggleSelection:o,onDismiss:i,onUndismiss:s,onApplyFix:a,onRegenerateFix:u})=>{let{featureFlags:c,userRole:l,setHoveredIssueId:d}=ie(),[f,p]=cx(!1),[g,S]=cx(!1),[C,F]=cx(!1),k=dj(null),R=iI(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{d(e.id),F(!0)},100)},[e.id,d]),z=iI(()=>{k.current&&clearTimeout(k.current),k.current=null,d(null),F(!1)},[d]),_=()=>{e.dismissed?s(e.id):p(!0)},M=x=>{i(e.id,x),p(!1)},B=async()=>{let x=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&x.push(`Property: ${e.property}`),e.currentValue&&x.push(`Current: ${e.currentValue}`),e.suggestedValue&&x.push(`Expected: ${e.suggestedValue}`),e.file&&x.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&x.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&x.push(`
97
+ `,backgroundSize:"100% 100%, 6px 6px, 6px 6px",backgroundPosition:"0 0, 0 0, 3px 3px",border:"1px solid rgba(0, 0, 0, 0.15)",marginRight:"6px",verticalAlign:"middle",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.15)"})),uj=Lo.span({display:"flex",alignItems:"center"}),iI=({value:e,isStrikethrough:t=!1})=>{let n=oj(e),r=ij(e),o=t?aj:lj;return n?$n.createElement(uj,null,$n.createElement(cj,{color:n,title:`Color: ${n}`}),$n.createElement(o,null,r)):$n.createElement(o,null,r)},sI=({property:e,currentValue:t,suggestedValue:n})=>$n.createElement(sj,null,$n.createElement(ux,null,$n.createElement(px,null,"Property"),$n.createElement(dx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&$n.createElement(ux,null,$n.createElement(px,null,"Current"),$n.createElement(iI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&$n.createElement(ux,null,$n.createElement(px,null,"Expected"),$n.createElement(iI,{value:n,isStrikethrough:!1})));ve();var lI=new Set(["dimensions","width","height","minWidth","minHeight","maxWidth","maxHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","padding-top","padding-right","padding-bottom","padding-left","border","borderWidth","border-width","border / box-shadow","borderRadius","border-radius","gap","rowGap","columnGap"]);function fj(e){if(lI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return lI.has(t)}var gj=Ee.div(({theme:e,dismissed:t,fixApplied:n})=>({padding:"14px 16px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:t?e.background.negative:n?e.background.positive:"transparent",opacity:t?.7:n?.6:1,position:"relative",transition:"background-color 0.15s","&:hover":{backgroundColor:t||n?void 0:e.base==="dark"?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.02)"},"&:first-of-type":{borderTop:"none"}})),xde=Ee.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),mj=Ee.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),hj=Ee.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),xj=Ee.input(({theme:e})=>({appearance:"none",WebkitAppearance:"none",marginTop:"2px",width:"14px",height:"14px",cursor:"pointer",flexShrink:0,border:`1.5px solid ${e.color.mediumdark||"#cbd5e1"}`,borderRadius:"3px",backgroundColor:e.background.content,position:"relative",transition:"all 0.15s","&:hover":{borderColor:le},"&:checked":{backgroundColor:le,borderColor:le},"&:checked::after":{content:'""',position:"absolute",left:"3px",top:"0px",width:"4px",height:"8px",border:"solid #fff",borderWidth:"0 2px 2px 0",transform:"rotate(45deg)"},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),yj=Ee.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:"#94a3b8","& svg":{width:"16px",height:"16px"}})),yde=Ee.div({flex:1,minWidth:0}),bde=Ee.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),bj=Ee.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),gx=Ee.button(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"0",fontSize:"11px",fontWeight:400,color:e.textMutedColor,backgroundColor:"transparent",border:"none",cursor:"pointer",transition:"color 0.15s","&:hover":{color:e.color.defaultText},"& svg":{width:"11px",height:"11px"}})),Sj=Ee(gx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),Sde=Ee.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),wde=Ee.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),wj=Ee.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),vde=Ee.pre(({theme:e})=>({fontSize:"13px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"12px",borderRadius:"4px",overflowX:"auto",margin:"8px 0 0 0",lineHeight:"1.5"})),kde=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),vj=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginTop:"6px",fontStyle:"italic",display:"flex",alignItems:"baseline",gap:"4px","& strong":{fontStyle:"normal",fontWeight:600,color:"#7c3aed",fontSize:"10px"}})),kj=Ee.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${le}`})),Cj=Ee.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:le,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),Tj=Ee.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr auto auto",gap:"8px",alignItems:"center",padding:"4px 0",fontSize:"11px",borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),Ij=Ee.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),cI=Ee.span(({theme:e,type:t})=>({fontFamily:"monospace",fontSize:"10px",padding:"2px 6px",borderRadius:"3px",backgroundColor:t==="current"?e.background.negative:e.background.positive,color:t==="current"?e.color.negative:e.color.positive,textDecoration:t==="current"?"line-through":"none"})),Cde=Ee.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),Fj=Ee(wn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),Tde=Ee(Fj)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),Ej=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontStyle:"italic",marginTop:"8px",padding:"8px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${e.color.negative}`})),uI=Ee.div(({theme:e})=>({fontSize:"11px",color:e.color.negative,backgroundColor:e.background.negative,padding:"10px",borderRadius:"4px",marginTop:"10px",borderLeft:`3px solid ${e.color.negative}`,fontFamily:"monospace",lineHeight:"1.5"})),Aj=Ee.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),Pj=Ee.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),Lj=Ee.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),Mj=Ee.span(({theme:e,confidence:t})=>({padding:"4px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,backgroundColor:t>=.8?e.background.positive:t>=.6?e.background.warning:e.background.negative,color:t>=.8?e.color.positive:t>=.6?e.color.warning:e.color.negative})),pI=Ee.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),dI=Ee.details({marginBottom:"8px"}),fI=Ee.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),Bj=Ee.pre(({theme:e})=>({fontSize:"11px",fontFamily:"monospace",backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"10px",borderRadius:"4px",overflowX:"auto",margin:0,lineHeight:"1.5",maxHeight:"300px",overflowY:"auto"})),Dj=Ee.div({display:"flex",gap:"8px",marginTop:"8px"}),Rj=Ee(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),zj=Ee(Er)({padding:"6px 12px",fontSize:"12px"}),Ide=Ee(en)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),Fde=Ee.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),Nj=Ee.div({display:"flex",alignItems:"center",gap:"12px"}),Oj=Ee.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:le,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),_j=Ee.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),Ede=Ee.div(({theme:e,width:t="100%"})=>({height:"10px",backgroundColor:e.background.app,borderRadius:"4px",width:t,animation:"pulse 1.5s ease-in-out infinite","@keyframes pulse":{"0%, 100%":{opacity:1},"50%":{opacity:.5}}})),$j=Ee.div(({theme:e})=>({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",fontSize:"11px",fontFamily:"monospace",lineHeight:"1.5",marginTop:"8px"})),gI=Ee.div(({theme:e,side:t})=>({backgroundColor:t==="old"?e.background.negative:e.background.positive,borderRight:t==="old"?`1px solid ${e.appBorderColor}`:"none",minWidth:0,overflow:"hidden"})),mI=Ee.div(({theme:e,side:t})=>({padding:"6px 8px",fontWeight:600,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:t==="old"?e.background.negative:e.background.positive,color:t==="old"?e.color.negative:e.color.positive,borderBottom:`1px solid ${e.appBorderColor}`})),hI=Ee.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),xI=Ee.div(({theme:e,type:t})=>{let n="transparent",r=e.color.defaultText;return t==="removed"?(n=e.background.negative,r=e.color.negative):t==="added"?(n=e.background.positive,r=e.color.positive):t==="empty"&&(n=e.background.app,r=e.textMutedColor),{padding:"2px 8px",backgroundColor:n,color:r,whiteSpace:"pre",minHeight:"20px",borderBottom:"1px solid rgba(0, 0, 0, 0.05)"}}),yI=Ee.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),bI=e=>{let t=e.split(`
98
+ `),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(!o.startsWith("@@"))if(o.startsWith("-"))n.push({oldLine:{type:"removed",content:o.substring(1)},newLine:{type:"empty",content:""}});else if(o.startsWith("+"))n.push({oldLine:{type:"empty",content:""},newLine:{type:"added",content:o.substring(1)}});else{let i=o.startsWith(" ")?o.substring(1):o;n.push({oldLine:{type:"context",content:i},newLine:{type:"context",content:i}})}}return n},Uj=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},jj=e=>({"claude-sonnet-4-5-20250929":"Sonnet 4.5","claude-sonnet-4-20250514":"Sonnet 4","claude-sonnet-3-5-20240620":"Sonnet 3.5","claude-3-opus-20240229":"Opus 3","gpt-5":"GPT-5","gpt-5-mini":"GPT-5 Mini","gpt-5.2-chat-latest":"GPT-5.2 Instant","gpt-4o":"GPT-4o"})[e]||e,SI=dj(({issue:e,modelId:t,dominantDetector:n,showFilePath:r=!0,onToggleSelection:o,onDismiss:i,onUndismiss:s,onApplyFix:a,onRegenerateFix:u})=>{let{featureFlags:c,userRole:l,setHoveredIssueId:d}=ie(),[f,p]=fx(!1),[g,S]=fx(!1),[C,F]=fx(!1),k=pj(null),R=aI(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{d(e.id),F(!0)},100)},[e.id,d]),z=aI(()=>{k.current&&clearTimeout(k.current),k.current=null,d(null),F(!1)},[d]),_=()=>{e.dismissed?s(e.id):p(!0)},M=x=>{i(e.id,x),p(!1)},B=async()=>{let x=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&x.push(`Property: ${e.property}`),e.currentValue&&x.push(`Current: ${e.currentValue}`),e.suggestedValue&&x.push(`Expected: ${e.suggestedValue}`),e.file&&x.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&x.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&x.push(`
99
99
  Suggested code:
100
100
  \`\`\`
101
101
  ${e.suggestedCode}
@@ -109,25 +109,25 @@ Diff:
109
109
  \`\`\`diff
110
110
  ${E.diffPreview}
111
111
  \`\`\``),E.error&&x.push(`Error: ${E.error}`)}let b=x.filter(Boolean).join(`
112
- `);try{await navigator.clipboard.writeText(b),S(!0),setTimeout(()=>S(!1),2e3)}catch(E){console.error("Failed to copy:",E)}},m=e.generatedFix?.status==="applied";return J.createElement(J.Fragment,null,J.createElement(mj,{dismissed:!!e.dismissed,fixApplied:m,onMouseEnter:R,onMouseLeave:z},J.createElement(hj,null,J.createElement(yj,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),J.createElement(bj,{severity:e.severity},e.severity==="critical"?J.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},J.createElement("circle",{cx:"12",cy:"12",r:"10"}),J.createElement("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),J.createElement("line",{x1:"9",y1:"9",x2:"15",y2:"15"})):e.severity==="major"?J.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},J.createElement("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),J.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),J.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):J.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},J.createElement("circle",{cx:"12",cy:"12",r:"10"}),J.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),J.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),J.createElement(xj,null,e.title),J.createElement(Sj,null,J.createElement(ux,{onClick:B,title:"Copy issue details"},g?J.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},J.createElement("polyline",{points:"20 6 9 17 4 12"})):J.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},J.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),J.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})),"Copy"),e.dismissed?J.createElement(ux,{onClick:_,title:"Restore issue"},J.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},J.createElement("polyline",{points:"1 4 1 10 7 10"}),J.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})),"Restore"):J.createElement(wj,{onClick:_,title:"Dismiss issue"},J.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},J.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),J.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),"Dismiss"))),J.createElement(nI,{issue:e,modelDisplayName:Hj(t),showModel:c.enableModelSelection,showDetection:l==="admin",dominantDetector:n,showFilePath:r,enableFilePath:c.enableFixGeneration,unreliable:e._unreliable,validationErrorMessage:e._validationError?.message}),e.description&&e.description!==e.title&&J.createElement(vj,null,e.description),e.property&&J.createElement(oI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&C&&e.property&&e.currentValue&&e.suggestedValue&&gj(e.property)&&J.createElement(tI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&J.createElement(kj,null,J.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&J.createElement(Cj,null,J.createElement(Tj,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((x,b)=>J.createElement(Ij,{key:`${x.property}-${b}`},J.createElement(Fj,null,x.property),J.createElement(aI,{type:"current"},x.currentValue),J.createElement(aI,{type:"suggested"},x.suggestedValue)))),e.dismissed&&J.createElement(Aj,null,J.createElement("strong",null,"Filtered by:")," ",jj(e.dismissedBy),e.dismissReason&&J.createElement(J.Fragment,null,J.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&J.createElement(lI,null,J.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&J.createElement(Pj,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?J.createElement(Oj,{style:{margin:0}},J.createElement(_j,null),J.createElement($j,{style:{margin:0}},"Generating fix...")):J.createElement(J.Fragment,null,J.createElement(Lj,null,J.createElement(Mj,null,"AI-Generated Fix"),J.createElement(Bj,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&J.createElement(cI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&J.createElement(cI,{style:{color:"#6b7280",fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?J.createElement(uI,null,J.createElement(pI,null,"View Diff"),J.createElement(Uj,null,J.createElement(dI,{side:"old"},J.createElement(fI,{side:"old"},"Old"),J.createElement(gI,null,xI(e.generatedFix.diffPreview).map((x,b)=>J.createElement(mI,{key:`old-${b}`,type:x.oldLine.type},x.oldLine.content||"\xA0")))),J.createElement(dI,{side:"new"},J.createElement(fI,{side:"new"},"New"),J.createElement(gI,null,xI(e.generatedFix.diffPreview).map((x,b)=>J.createElement(mI,{key:`new-${b}`,type:x.newLine.type},x.newLine.content||"\xA0")))))):e.generatedFix.code&&J.createElement(uI,null,J.createElement(pI,null,"View Generated Code"),J.createElement(Dj,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&J.createElement(lI,null,J.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&J.createElement(Rj,null,J.createElement(zj,{onClick:()=>a(e.id)},"Apply Fix"),u&&J.createElement(Nj,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&J.createElement(hI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&J.createElement(hI,{status:"applied"},"\u2713 Fix applied successfully")))),J.createElement(VT,{isOpen:f,issueTitle:e.title,onConfirm:M,onCancel:()=>p(!1)}))});import px from"react";import{styled as dx,keyframes as Wj}from"storybook/theming";var Vj=Wj`
112
+ `);try{await navigator.clipboard.writeText(b),S(!0),setTimeout(()=>S(!1),2e3)}catch(E){console.error("Failed to copy:",E)}},m=e.generatedFix?.status==="applied";return Z.createElement(Z.Fragment,null,Z.createElement(gj,{dismissed:!!e.dismissed,fixApplied:m,onMouseEnter:R,onMouseLeave:z},Z.createElement(mj,null,Z.createElement(xj,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),Z.createElement(yj,{severity:e.severity},e.severity==="critical"?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("circle",{cx:"12",cy:"12",r:"10"}),Z.createElement("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),Z.createElement("line",{x1:"9",y1:"9",x2:"15",y2:"15"})):e.severity==="major"?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),Z.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),Z.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("circle",{cx:"12",cy:"12",r:"10"}),Z.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),Z.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),Z.createElement(hj,null,e.title),Z.createElement(bj,null,Z.createElement(gx,{onClick:B,title:"Copy issue details"},g?Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("polyline",{points:"20 6 9 17 4 12"})):Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),Z.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})),"Copy"),e.dismissed?Z.createElement(gx,{onClick:_,title:"Restore issue"},Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("polyline",{points:"1 4 1 10 7 10"}),Z.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})),"Restore"):Z.createElement(Sj,{onClick:_,title:"Dismiss issue"},Z.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Z.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Z.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),"Dismiss"))),Z.createElement(oI,{issue:e,modelDisplayName:jj(t),showModel:c.enableModelSelection,showDetection:l==="admin",dominantDetector:n,showFilePath:r,enableFilePath:c.enableFixGeneration,unreliable:e._unreliable,validationErrorMessage:e._validationError?.message}),e.description&&e.description!==e.title&&Z.createElement(wj,null,e.description),e.property&&Z.createElement(sI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&C&&e.property&&e.currentValue&&e.suggestedValue&&fj(e.property)&&Z.createElement(rI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&Z.createElement(vj,null,Z.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&Z.createElement(kj,null,Z.createElement(Cj,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((x,b)=>Z.createElement(Tj,{key:`${x.property}-${b}`},Z.createElement(Ij,null,x.property),Z.createElement(cI,{type:"current"},x.currentValue),Z.createElement(cI,{type:"suggested"},x.suggestedValue)))),e.dismissed&&Z.createElement(Ej,null,Z.createElement("strong",null,"Filtered by:")," ",Uj(e.dismissedBy),e.dismissReason&&Z.createElement(Z.Fragment,null,Z.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&Z.createElement(uI,null,Z.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&Z.createElement(Aj,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?Z.createElement(Nj,{style:{margin:0}},Z.createElement(Oj,null),Z.createElement(_j,{style:{margin:0}},"Generating fix...")):Z.createElement(Z.Fragment,null,Z.createElement(Pj,null,Z.createElement(Lj,null,"AI-Generated Fix"),Z.createElement(Mj,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&Z.createElement(pI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&Z.createElement(pI,{style:{color:"#6b7280",fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?Z.createElement(dI,null,Z.createElement(fI,null,"View Diff"),Z.createElement($j,null,Z.createElement(gI,{side:"old"},Z.createElement(mI,{side:"old"},"Old"),Z.createElement(hI,null,bI(e.generatedFix.diffPreview).map((x,b)=>Z.createElement(xI,{key:`old-${b}`,type:x.oldLine.type},x.oldLine.content||"\xA0")))),Z.createElement(gI,{side:"new"},Z.createElement(mI,{side:"new"},"New"),Z.createElement(hI,null,bI(e.generatedFix.diffPreview).map((x,b)=>Z.createElement(xI,{key:`new-${b}`,type:x.newLine.type},x.newLine.content||"\xA0")))))):e.generatedFix.code&&Z.createElement(dI,null,Z.createElement(fI,null,"View Generated Code"),Z.createElement(Bj,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&Z.createElement(uI,null,Z.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&Z.createElement(Dj,null,Z.createElement(Rj,{onClick:()=>a(e.id)},"Apply Fix"),u&&Z.createElement(zj,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&Z.createElement(yI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&Z.createElement(yI,{status:"applied"},"\u2713 Fix applied successfully")))),Z.createElement(qT,{isOpen:f,issueTitle:e.title,onConfirm:M,onCancel:()=>p(!1)}))});import mx from"react";import{styled as hx,keyframes as Hj}from"storybook/theming";var Wj=Hj`
113
113
  0% { transform: rotate(0deg); }
114
114
  100% { transform: rotate(360deg); }
115
- `,Gj=dx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),qj=dx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${Vj} 0.8s linear infinite`})),Yj=dx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Nc=({label:e="Loading..."})=>px.createElement(Gj,null,px.createElement(qj,null),px.createElement(Yj,null,e));ve();import gt,{useState as Kj,useEffect as Xj,useRef as Qj}from"react";import{styled as fn,keyframes as xa}from"storybook/theming";var Gi="#8b6cc1",Jj="rgba(139, 108, 193, 0.2)",wI="rgba(139, 108, 193, 0.15)",Zj="rgba(139, 108, 193, 0.1)",eH="rgba(139, 108, 193, 0.5)",vI=xa`
115
+ `,Vj=hx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),Gj=hx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${Wj} 0.8s linear infinite`})),qj=hx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Oc=({label:e="Loading..."})=>mx.createElement(Vj,null,mx.createElement(Gj,null),mx.createElement(qj,null,e));ve();import gt,{useState as Yj,useEffect as Kj,useRef as Xj}from"react";import{styled as fn,keyframes as xa}from"storybook/theming";var Gi="#8b6cc1",Qj="rgba(139, 108, 193, 0.2)",kI="rgba(139, 108, 193, 0.15)",Jj="rgba(139, 108, 193, 0.1)",Zj="rgba(139, 108, 193, 0.5)",CI=xa`
116
116
  from { transform: rotate(0deg); }
117
117
  to { transform: rotate(360deg); }
118
- `,tH=xa`
118
+ `,eH=xa`
119
119
  from { transform: rotate(0deg); }
120
120
  to { transform: rotate(-360deg); }
121
- `,nH=xa`
121
+ `,tH=xa`
122
122
  0%, 100% { opacity: 1; transform: scale(1); }
123
123
  50% { opacity: 0.6; transform: scale(1.05); }
124
- `,rH=xa`
124
+ `,nH=xa`
125
125
  from { opacity: 0; transform: translateY(8px); }
126
126
  to { opacity: 1; transform: translateY(0); }
127
- `,oH=xa`
127
+ `,rH=xa`
128
128
  0%, 100% { opacity: 1; }
129
129
  50% { opacity: 0.4; }
130
- `,iH=fn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${rH} 0.4s ease-out`}),sH=fn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),aH=fn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${wI} 0%, transparent 70%)`,animation:`${nH} 2s ease-in-out infinite`}),lH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${Jj}`}),cH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:Gi,borderRightColor:Gi,animation:`${vI} 1.2s linear infinite`}),uH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${wI}`}),pH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:eH,animation:`${tH} 1.8s linear infinite`}),dH=fn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),fH=fn.div({position:"absolute",inset:0,animation:`${vI} 3s linear infinite`}),gH=fn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:Gi}),mH=()=>gt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:Gi,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.createElement("path",{d:"M12 3l1.912 5.813a2 2 0 0 0 1.275 1.275L21 12l-5.813 1.912a2 2 0 0 0-1.275 1.275L12 21l-1.912-5.813a2 2 0 0 0-1.275-1.275L3 12l5.813-1.912a2 2 0 0 0 1.275-1.275L12 3z"}),gt.createElement("path",{d:"M5 3v4"}),gt.createElement("path",{d:"M3 5h4"}),gt.createElement("path",{d:"M19 17v4"}),gt.createElement("path",{d:"M17 19h4"})),hH=fn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),xH=fn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),yH=fn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),fx=fn.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"999px",fontSize:"11px",fontWeight:500,...t==="done"&&{backgroundColor:e.color.positive?`${e.color.positive}1a`:"rgba(16, 185, 129, 0.1)",color:e.color.positive||"#10b981"},...t==="active"&&{backgroundColor:Zj,color:Gi},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),bI=fn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),SI=fn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:Gi,animation:`${oH} 1.5s ease-in-out infinite`}),bH=fn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),SH=()=>gt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.createElement("polyline",{points:"20 6 9 17 4 12"})),kI=()=>{let{streamingProgress:e}=ie(),t=(e||0)>25,[n,r]=Kj(0),o=Qj();return Xj(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),gt.createElement(iH,null,gt.createElement(sH,null,gt.createElement(aH,null),gt.createElement(lH,null),gt.createElement(cH,null),gt.createElement(uH,null),gt.createElement(pH,null),gt.createElement(dH,null,gt.createElement(mH,null)),gt.createElement(fH,null,gt.createElement(gH,null))),gt.createElement(hH,null,"Analyzing designs"),gt.createElement(xH,null,"AI is comparing screenshots and detecting issues"),gt.createElement(yH,null,gt.createElement(fx,{variant:t?"done":"active"},t?gt.createElement(SH,null):gt.createElement(SI,null),"Screenshots"),gt.createElement(bI,null),gt.createElement(fx,{variant:t?"active":"pending"},t?gt.createElement(SI,null):null,"Analysis"),gt.createElement(bI,null),gt.createElement(fx,{variant:"pending"},"Report")),gt.createElement(bH,null,n,"s \xB7 Esc to stop"))};ve();var Yde=it.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",color:e.textMutedColor,cursor:"pointer",padding:"4px 8px",borderRadius:"4px",backgroundColor:e.background.app,"&:hover":{backgroundColor:e.background.hoverable}})),Kde=it.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:le})),TH=it.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),IH=it.div({display:"flex",gap:"8px"}),CI=it(En)({flex:1}),FH=it.div(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:t?"8px 8px 0 0":"8px",border:`1px solid ${e.appBorderColor}`,borderBottom:t?"none":`1px solid ${e.appBorderColor}`,cursor:"pointer",transition:"background-color 0.15s ease","&:hover":{backgroundColor:e.background.hoverable}})),EH=it.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),AH=it.span(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",color:e.textMutedColor,transition:"transform 0.15s ease",transform:t?"rotate(0deg)":"rotate(-90deg)","& svg":{width:"14px",height:"14px"}})),PH=it.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),LH=it.div({display:"flex",alignItems:"center",gap:"2px"}),Oc=it(wn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),gx=it.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),MH=it.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Xde=it.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Mo=it.div(({theme:e,variant:t})=>{let r=(()=>{switch(t){case"total":return{bg:e.background.app,text:e.color.defaultText};case"critical":return{bg:e.background.negative,text:e.color.negative};case"major":return{bg:e.background.warning,text:e.color.warning};case"minor":return{bg:e.color.tertiary,text:le};case"selected":return{bg:e.color.tertiary,text:le};case"score":return{bg:e.background.positive,text:e.color.positive};case"cost":return{bg:e.background.warning,text:e.color.warning};case"timing":return{bg:e.color.tertiary,text:le};case"tokens":return{bg:e.background.app,text:e.color.mediumdark};case"model":return{bg:e.background.app,text:e.color.mediumdark}}})();return{padding:"3px 8px",borderRadius:"10px",backgroundColor:r.bg,color:r.text,fontWeight:600,fontSize:"11px",whiteSpace:"nowrap"}}),BH=it.div({display:"flex",flexDirection:"column"}),DH=it.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),TI=it.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),II=it.div({fontSize:"36px",marginBottom:"12px"}),FI=it.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),EI=it.div({fontSize:"12px"}),RH=CH`
130
+ `,oH=fn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${nH} 0.4s ease-out`}),iH=fn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),sH=fn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${kI} 0%, transparent 70%)`,animation:`${tH} 2s ease-in-out infinite`}),aH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${Qj}`}),lH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:Gi,borderRightColor:Gi,animation:`${CI} 1.2s linear infinite`}),cH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${kI}`}),uH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:Zj,animation:`${eH} 1.8s linear infinite`}),pH=fn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),dH=fn.div({position:"absolute",inset:0,animation:`${CI} 3s linear infinite`}),fH=fn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:Gi}),gH=()=>gt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:Gi,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.createElement("path",{d:"M12 3l1.912 5.813a2 2 0 0 0 1.275 1.275L21 12l-5.813 1.912a2 2 0 0 0-1.275 1.275L12 21l-1.912-5.813a2 2 0 0 0-1.275-1.275L3 12l5.813-1.912a2 2 0 0 0 1.275-1.275L12 3z"}),gt.createElement("path",{d:"M5 3v4"}),gt.createElement("path",{d:"M3 5h4"}),gt.createElement("path",{d:"M19 17v4"}),gt.createElement("path",{d:"M17 19h4"})),mH=fn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),hH=fn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),xH=fn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),xx=fn.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"999px",fontSize:"11px",fontWeight:500,...t==="done"&&{backgroundColor:e.color.positive?`${e.color.positive}1a`:"rgba(16, 185, 129, 0.1)",color:e.color.positive||"#10b981"},...t==="active"&&{backgroundColor:Jj,color:Gi},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),wI=fn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),vI=fn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:Gi,animation:`${rH} 1.5s ease-in-out infinite`}),yH=fn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),bH=()=>gt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.createElement("polyline",{points:"20 6 9 17 4 12"})),TI=()=>{let{streamingProgress:e}=ie(),t=(e||0)>25,[n,r]=Yj(0),o=Xj();return Kj(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),gt.createElement(oH,null,gt.createElement(iH,null,gt.createElement(sH,null),gt.createElement(aH,null),gt.createElement(lH,null),gt.createElement(cH,null),gt.createElement(uH,null),gt.createElement(pH,null,gt.createElement(gH,null)),gt.createElement(dH,null,gt.createElement(fH,null))),gt.createElement(mH,null,"Analyzing designs"),gt.createElement(hH,null,"AI is comparing screenshots and detecting issues"),gt.createElement(xH,null,gt.createElement(xx,{variant:t?"done":"active"},t?gt.createElement(bH,null):gt.createElement(vI,null),"Screenshots"),gt.createElement(wI,null),gt.createElement(xx,{variant:t?"active":"pending"},t?gt.createElement(vI,null):null,"Analysis"),gt.createElement(wI,null),gt.createElement(xx,{variant:"pending"},"Report")),gt.createElement(yH,null,n,"s \xB7 Esc to stop"))};ve();var Gde=it.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",color:e.textMutedColor,cursor:"pointer",padding:"4px 8px",borderRadius:"4px",backgroundColor:e.background.app,"&:hover":{backgroundColor:e.background.hoverable}})),qde=it.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:le})),CH=it.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),TH=it.div({display:"flex",gap:"8px"}),II=it(En)({flex:1}),IH=it.div(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:t?"8px 8px 0 0":"8px",border:`1px solid ${e.appBorderColor}`,borderBottom:t?"none":`1px solid ${e.appBorderColor}`,cursor:"pointer",transition:"background-color 0.15s ease","&:hover":{backgroundColor:e.background.hoverable}})),FH=it.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),EH=it.span(({theme:e,isOpen:t})=>({display:"flex",alignItems:"center",color:e.textMutedColor,transition:"transform 0.15s ease",transform:t?"rotate(0deg)":"rotate(-90deg)","& svg":{width:"14px",height:"14px"}})),AH=it.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),PH=it.div({display:"flex",alignItems:"center",gap:"2px"}),_c=it(wn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),yx=it.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),LH=it.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Yde=it.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Mo=it.div(({theme:e,variant:t})=>{let r=(()=>{switch(t){case"total":return{bg:e.background.app,text:e.color.defaultText};case"critical":return{bg:e.background.negative,text:e.color.negative};case"major":return{bg:e.background.warning,text:e.color.warning};case"minor":return{bg:e.color.tertiary,text:le};case"selected":return{bg:e.color.tertiary,text:le};case"score":return{bg:e.background.positive,text:e.color.positive};case"cost":return{bg:e.background.warning,text:e.color.warning};case"timing":return{bg:e.color.tertiary,text:le};case"tokens":return{bg:e.background.app,text:e.color.mediumdark};case"model":return{bg:e.background.app,text:e.color.mediumdark}}})();return{padding:"3px 8px",borderRadius:"10px",backgroundColor:r.bg,color:r.text,fontWeight:600,fontSize:"11px",whiteSpace:"nowrap"}}),MH=it.div({display:"flex",flexDirection:"column"}),BH=it.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),FI=it.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),EI=it.div({fontSize:"36px",marginBottom:"12px"}),AI=it.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),PI=it.div({fontSize:"12px"}),DH=kH`
131
131
  0% {
132
132
  transform: translateY(0) rotate(0deg) scale(1);
133
133
  opacity: 1;
@@ -139,7 +139,7 @@ ${E.diffPreview}
139
139
  transform: translateY(120px) rotate(720deg) scale(0.3);
140
140
  opacity: 0;
141
141
  }
142
- `;var Qde=it.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Jde=it.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"0",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>8?"50%":"2px",animation:`${RH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var zH=it.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderRadius:"6px",fontSize:"13px",fontWeight:600,backgroundColor:t==="success"?e.background.positive:e.background.warning,color:t==="success"?e.color.positive:e.color.warning,border:`2px solid ${t==="success"?e.color.positive:e.color.warning}`,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out","@keyframes slideIn":{"0%":{transform:"translateY(-10px)",opacity:0},"100%":{transform:"translateY(0)",opacity:1}}})),NH=it(wn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),AI=it.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),PI=it(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),LI=it(qt)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),MI=it(qt)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),OH=it.div(({theme:e,confidence:t})=>{let n=t>=90?"#16a34a":t>=70?"#ca8a04":"#dc2626";return{padding:"10px 14px",borderRadius:"8px",border:`1px solid ${n}30`,backgroundColor:`${n}08`,marginTop:"8px",fontSize:"12px",lineHeight:1.5}}),_H=it.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),$H=it.span(({confidence:e})=>{let t=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:t,fontSize:"11px",fontWeight:700}}),UH=it.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),jH=it.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),_c=it.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),$c=it.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),HH=e=>{if(["layout","content"].includes(e.type))return!0;if(e.type==="typography"){let n=(e.description||"").toLowerCase(),r=(e.property||"").toLowerCase();if(n.includes("text content")||n.includes("text differs")||r.includes("content")||r.includes("innerhtml")||r.includes("textcontent"))return!0}return!1},BI=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:d,onSelectNone:f,onSelectAllFixes:p,onApplyFixes:g,onApplyFix:S,onCopyAllFixes:C,onGenerateFixes:F,onDismiss:k,onUndismiss:R,isGenerating:z=!1,isApplying:_=!1,isCopying:M=!1,applyFixesResult:B,onDismissResult:m,generationTiming:x,generationUsage:b,generationProgress:E,autoApplySupported:h=!0,hasReviewBeenRun:T=!1,isLoadingReview:I=!1,isReviewing:v=!1,selfReview:A})=>{let[P,D]=V.useState("all"),[N,w]=V.useState("all"),[j,G]=V.useState(!1),[L,K]=V.useState(!0),{includeComponentIssues:ee,setIncludeComponentIssues:re,featureFlags:de}=ie(),ae=V.useRef(null),[qe,tt]=vH(0);kH(()=>{if(!z){tt(0);return}let ne=setInterval(()=>tt(W=>W+1),1e3);return()=>clearInterval(ne)},[z]);let se=async()=>{let ne=pe.map(H=>{let Pe=[`[${H.severity.toUpperCase()}] ${H.title||H.description}`,`Status: ${H.status}`,H.description&&H.description!==H.title?`Description: ${H.description}`:"",H.property?`Property: ${H.property}`:"",H.currentValue?`Current: ${H.currentValue}`:"",H.suggestedValue?`Expected: ${H.suggestedValue}`:"",H.file?`File: ${H.file}${H.lineNumber!==void 0?`:${H.lineNumber}`:""}`:"",H.suggestedCode?`Suggested code: ${H.suggestedCode}`:""];if(H.generatedFix){let Ne=H.generatedFix;if(Pe.push(""),Pe.push("--- AI-Generated Fix ---"),Pe.push(`Fix Status: ${Ne.status}`),Ne.confidence!==void 0){let yt=Ne.confidence>1?Ne.confidence:Math.round(Ne.confidence*100);Pe.push(`Confidence: ${yt}%`)}Ne.strategy&&Pe.push(`Strategy: ${Ne.strategy}`),Ne.filePath&&Pe.push(`Target file: ${Ne.filePath}`),Ne.code&&Pe.push(`Generated code:
142
+ `;var Kde=it.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Xde=it.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"0",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>8?"50%":"2px",animation:`${DH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var RH=it.div(({theme:e,variant:t})=>({display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderRadius:"6px",fontSize:"13px",fontWeight:600,backgroundColor:t==="success"?e.background.positive:e.background.warning,color:t==="success"?e.color.positive:e.color.warning,border:`2px solid ${t==="success"?e.color.positive:e.color.warning}`,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out","@keyframes slideIn":{"0%":{transform:"translateY(-10px)",opacity:0},"100%":{transform:"translateY(0)",opacity:1}}})),zH=it(wn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),LI=it.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),MI=it(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),BI=it(en)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),DI=it(en)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),NH=it.div(({theme:e,confidence:t})=>{let n=t>=90?"#16a34a":t>=70?"#ca8a04":"#dc2626";return{padding:"10px 14px",borderRadius:"8px",border:`1px solid ${n}30`,backgroundColor:`${n}08`,marginTop:"8px",fontSize:"12px",lineHeight:1.5}}),OH=it.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),_H=it.span(({confidence:e})=>{let t=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:t,fontSize:"11px",fontWeight:700}}),$H=it.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),UH=it.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),$c=it.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),Uc=it.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),jH=e=>{if(["layout","content"].includes(e.type))return!0;if(e.type==="typography"){let n=(e.description||"").toLowerCase(),r=(e.property||"").toLowerCase();if(n.includes("text content")||n.includes("text differs")||r.includes("content")||r.includes("innerhtml")||r.includes("textcontent"))return!0}return!1},RI=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:d,onSelectNone:f,onSelectAllFixes:p,onApplyFixes:g,onApplyFix:S,onCopyAllFixes:C,onGenerateFixes:F,onDismiss:k,onUndismiss:R,isGenerating:z=!1,isApplying:_=!1,isCopying:M=!1,applyFixesResult:B,onDismissResult:m,generationTiming:x,generationUsage:b,generationProgress:E,autoApplySupported:h=!0,hasReviewBeenRun:T=!1,isLoadingReview:I=!1,isReviewing:v=!1,selfReview:A})=>{let[P,D]=V.useState("all"),[N,w]=V.useState("all"),[j,G]=V.useState(!1),[L,K]=V.useState(!0),{includeComponentIssues:ee,setIncludeComponentIssues:re,featureFlags:de}=ie(),ae=V.useRef(null),[qe,tt]=wH(0);vH(()=>{if(!z){tt(0);return}let ne=setInterval(()=>tt(W=>W+1),1e3);return()=>clearInterval(ne)},[z]);let se=async()=>{let ne=pe.map(H=>{let Pe=[`[${H.severity.toUpperCase()}] ${H.title||H.description}`,`Status: ${H.status}`,H.description&&H.description!==H.title?`Description: ${H.description}`:"",H.property?`Property: ${H.property}`:"",H.currentValue?`Current: ${H.currentValue}`:"",H.suggestedValue?`Expected: ${H.suggestedValue}`:"",H.file?`File: ${H.file}${H.lineNumber!==void 0?`:${H.lineNumber}`:""}`:"",H.suggestedCode?`Suggested code: ${H.suggestedCode}`:""];if(H.generatedFix){let Ne=H.generatedFix;if(Pe.push(""),Pe.push("--- AI-Generated Fix ---"),Pe.push(`Fix Status: ${Ne.status}`),Ne.confidence!==void 0){let xt=Ne.confidence>1?Ne.confidence:Math.round(Ne.confidence*100);Pe.push(`Confidence: ${xt}%`)}Ne.strategy&&Pe.push(`Strategy: ${Ne.strategy}`),Ne.filePath&&Pe.push(`Target file: ${Ne.filePath}`),Ne.code&&Pe.push(`Generated code:
143
143
  ${Ne.code}`),Ne.diffPreview&&Pe.push(`Diff:
144
144
  ${Ne.diffPreview}`),Ne.error&&Pe.push(`Error: ${Ne.error}`)}return Pe.push(""),Pe.filter(Boolean).join(`
145
145
  `)}).join(`
@@ -147,15 +147,15 @@ ${Ne.diffPreview}`),Ne.error&&Pe.push(`Error: ${Ne.error}`)}return Pe.push(""),P
147
147
 
148
148
  `),W=pe.filter(H=>H.generatedFix?.status==="applied").length,Ae=pe.filter(H=>H.generatedFix?.status==="ready").length,ge=W>0||Ae>0?` | Fixes: ${W} applied, ${Ae} ready`:"",O=r!==void 0?` | Similarity: ${r}%`:"",U=`Score: ${n}/100${O} | ${pe.length} issues${ge}
149
149
 
150
- `;try{await navigator.clipboard.writeText(U+ne),G(!0),setTimeout(()=>G(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};V.useEffect(()=>{B&&ae.current&&ae.current.scrollIntoView({behavior:"smooth",block:"start"})},[B]);let pe=wH(()=>e.filter(ne=>{let W=P==="all"||ne.severity===P,Ae=N==="all"||ne.status===N,ge=ee||!HH(ne);return W&&Ae&&ge}),[e,P,N,ee]),Ie=()=>{pe.forEach(ne=>{ne.selectedForFix||l(ne.id)})},ze=()=>{pe.forEach(ne=>{ne.selectedForFix&&l(ne.id)})},me=()=>{pe.forEach(ne=>{ne.generatedFix&&ne.generatedFix.status==="ready"&&!ne.selectedForFix&&l(ne.id)})},Nt=pe.filter(ne=>ne.selectedForFix).length,he=pe.filter(ne=>ne.severity==="critical").length,vt=pe.filter(ne=>ne.severity==="major").length,Ge=pe.filter(ne=>ne.severity==="minor").length,lt=pe.filter(ne=>ne.generatedFix&&ne.generatedFix.status==="ready").length,nt=pe.filter(ne=>ne.selectedForFix&&ne.generatedFix&&ne.generatedFix.status==="ready").length;return e.length===0?I?V.createElement(Nc,{label:"Loading review..."}):v?V.createElement(kI,null):V.createElement(TI,null,V.createElement(II,null,T?"\u2728":"\u{1F441}\uFE0F"),V.createElement(FI,null,T?"No issues found":"No review yet"),V.createElement(EI,null,T?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):V.createElement(TH,{"data-testid":"issues-panel"},V.createElement(IH,null,V.createElement(CI,{value:P,onChange:ne=>D(ne.target.value)},V.createElement("option",{value:"all"},"All Severities"),V.createElement("option",{value:"critical"},"Critical Only"),V.createElement("option",{value:"major"},"Major Only"),V.createElement("option",{value:"minor"},"Minor Only")),V.createElement(CI,{value:N,onChange:ne=>w(ne.target.value)},V.createElement("option",{value:"all"},"All Statuses"),V.createElement("option",{value:"pending"},"Pending"),V.createElement("option",{value:"applied"},"Applied"),V.createElement("option",{value:"verified"},"Verified"),V.createElement("option",{value:"failed"},"Failed"))),V.createElement("div",null,V.createElement(FH,{isOpen:L,onClick:()=>K(!L)},V.createElement(EH,null,V.createElement(AH,{isOpen:L},V.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},V.createElement("polyline",{points:"6 9 12 15 18 9"}))),V.createElement(MH,null,pe.length," issues"),(()=>{if(pe.length===0)return null;let ne=pe.map(ge=>ge.generatedFix?.filePath||ge.file).filter(Boolean);if(ne.length===0)return null;let W=ne[0];return ne.every(ge=>ge===W)?V.createElement(DH,null,"in ",W):null})(),V.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},he>0&&V.createElement(gx,{variant:"critical"},he," critical"),vt>0&&V.createElement(gx,{variant:"major"},vt," major"),Ge>0&&V.createElement(gx,{variant:"minor"},Ge," minor"))),V.createElement(LH,{onClick:ne=>ne.stopPropagation()},V.createElement(Oc,{onClick:Ie},"All"),V.createElement(Oc,{onClick:ze},"None"),V.createElement(Oc,{onClick:se},j?"\u2713":"\u2398"," Copy"),lt>0&&V.createElement(Oc,{onClick:me},"Fixes (",lt,")"))),B&&V.createElement(zH,{ref:ae,variant:B.error||B.failed>0?"warning":"success"},B.error?V.createElement(V.Fragment,null,B.error):B.failed>0?V.createElement(V.Fragment,null,"Applied ",B.succeeded,"/",B.total," fixes. ",B.failed," failed. Run a new review to verify."):V.createElement(V.Fragment,null,"Applied ",B.total," fix",B.total!==1?"es":"","! Run a new review to verify changes."),m&&V.createElement(NH,{onClick:m},"\u2715")),Nt>0&&V.createElement(AI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),de.enableFixGeneration&&F&&V.createElement(MI,{disabled:z||_||M,onClick:F},V.createElement("span",null,"\u{1F916}"),z&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:z?`Generating... (${qe}s)`:`Generate Fixes for ${Nt} Issue${Nt>1?"s":""}`),de.enableFixApply&&h&&g&&V.createElement(PI,{disabled:z||_||nt===0,onClick:g},_?"Applying...":z?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),de.enableFixApply&&!h&&C&&V.createElement(LI,{disabled:z||M||nt===0,copied:M,onClick:C},M?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")),A&&!z&&V.createElement(OH,{confidence:A.overallConfidence},V.createElement(_H,null,V.createElement(UH,null,"AI Self-Review"),V.createElement($H,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),V.createElement(jH,null,A.variantSafety&&V.createElement(_c,null,V.createElement($c,null,"Variant safety: "),A.variantSafety),A.gaps.length>0&&V.createElement(_c,null,V.createElement($c,null,"Gaps: "),V.createElement("ul",null,A.gaps.map((ne,W)=>V.createElement("li",{key:W},ne)))),!A.wouldReachPerfect&&A.reasonsNotPerfect.length>0&&V.createElement(_c,null,V.createElement($c,null,"Why not 100%: "),V.createElement("ul",null,A.reasonsNotPerfect.map((ne,W)=>V.createElement("li",{key:W},ne)))),A.suggestions&&A.suggestions.length>0&&V.createElement(_c,null,V.createElement($c,null,"Suggestions: "),V.createElement("ul",null,A.suggestions.map((ne,W)=>V.createElement("li",{key:W},ne)))))),L&&V.createElement(PH,null,pe.length===0?V.createElement(TI,null,V.createElement(II,null,"\u{1F50D}"),V.createElement(FI,null,"No issues match current filters"),V.createElement(EI,null,"Try adjusting your severity or status filters")):V.createElement(BH,null,(()=>{let ne={};pe.forEach(U=>{let H=U.detectedBy;H&&(ne[H]=(ne[H]||0)+1)});let W=Object.entries(ne).sort((U,H)=>H[1]-U[1])[0],Ae=W&&W[1]>pe.length/2?W[0]:void 0,ge=pe.map(U=>U.generatedFix?.filePath||U.file).filter(Boolean),O=ge.length>0&&ge.every(U=>U===ge[0]);return pe.map(U=>V.createElement(yI,{key:U.id,issue:U,modelId:t,dominantDetector:Ae,showFilePath:!O,onToggleSelection:l,onDismiss:k,onUndismiss:R,onApplyFix:S}))})()))),Nt>0&&V.createElement(AI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),de.enableFixGeneration&&F&&V.createElement(MI,{disabled:z||_||M,onClick:F},V.createElement("span",null,"\u{1F916}"),z&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:z?`Generating... (${qe}s)`:`Generate Fixes for ${Nt} Issue${Nt>1?"s":""}`),de.enableFixApply&&h&&g&&V.createElement(PI,{disabled:z||_||nt===0,onClick:g},_?"Applying...":z?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),de.enableFixApply&&!h&&C&&V.createElement(LI,{disabled:z||M||nt===0,copied:M,onClick:C},M?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")))};De();var WH=Ct.div({display:"flex",flexDirection:"column"}),VH=Ct.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),GH=Ct.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),mx=Ct.span(({theme:e,variant:t})=>{let n={resolved:{bg:e.background.positive,text:e.color.positive},remaining:{bg:e.background.warning,text:e.color.warning},new:{bg:e.color.tertiary,text:le}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),qH=Ct.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),cfe=Ct.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),ufe=Ct.div({fontSize:"48px",marginBottom:"16px"}),pfe=Ct.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),dfe=Ct.div({fontSize:"14px",opacity:.8}),YH=Ct.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),KH=Ct.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),XH=Ct(wn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),QH=Ct(Er)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),JH=Ct.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),ZH=Ct.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),eW=Ct.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),tW=Ct.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),nW=Ct.button(({theme:e})=>({background:"none",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"2px 8px",fontSize:"11px",color:e.color.mediumdark,cursor:"pointer","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.secondary}})),rW=Ct.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),oW=Ct.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),iW=Ct.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",padding:"12px 0 8px 0",marginTop:"8px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"8px","&:first-of-type":{marginTop:0}})),sW=Ct.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),aW=e=>{if(!e)return"Other";let t=e.toLowerCase();return t.includes("hug")||t.includes("fill")||t.includes("content-driven")?"HUG/FILL Sizing":t.includes("sub-pixel")||t.includes("negligible")?"Sub-pixel Differences":t.includes("values match")||t.includes("values already match")||t.includes("identical")?"Values Match":t.includes("no fix needed")||t.includes("no changes needed")?"No Fix Needed":"Other"},DI=e=>{if(!e)return"";let t=e.replace(/^Auto-dismissed:\s*/i,"").replace(/^Programmatic:\s*/i,"").replace(/^Two-Pass:\s*/i,"");return t=t.replace(/Sub-pixel difference \([\d.]+px\) - within [\d.]+px tolerance/i,"Sub-pixel difference").replace(/Dimension issue with HUG\/FILL sizing - width is content-driven, not fixed/i,"Width is content-driven").replace(/Height issue with HUG sizing - dimension is content-driven, not actionable/i,"Height is content-driven").replace(/Width issue with HUG sizing - dimension is content-driven, not actionable/i,"Width is content-driven").replace(/no-changes-needed - values already match/i,"Values already match").replace(/Values are the same - no difference/i,"Values match"),t},lW=Ct.span(({theme:e,phase:t})=>{let n={"post-ai-validation":{bg:"#4b5563",text:"#ffffff"},"ai-validation":{bg:"#7c3aed",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n.user;return{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",fontWeight:600,color:o,backgroundColor:r,padding:"3px 10px",borderRadius:"10px",marginBottom:"8px"}}),cW=Ct.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"8px",marginLeft:"8px",fontSize:"11px",color:e.textMutedColor,"& > span":{display:"inline-flex",alignItems:"center",gap:"3px"}})),xx=e=>{if(!e)return;let t=e.toLowerCase();if(t.includes("no-changes-needed")||t.includes("values already match")||t.includes("sub-pixel")||t.includes("negligible")||t.includes("hug")||t.includes("fill")||t.includes("content-driven")||t.includes("equivalent")||t.includes("layout mechanism"))return"post-ai-validation"},uW=(e,t)=>{switch(e||xx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},RI=(e,t)=>{switch(e||xx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";case"user":return"Manual";default:return"Auto"}},pW=Ct.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),dW=Ct.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),fW=Ct.pre(({theme:e})=>({fontSize:"12px",color:e.color.negative,backgroundColor:e.background.app,padding:"12px",borderRadius:"4px",overflow:"auto",maxHeight:"200px",fontFamily:"monospace",lineHeight:"1.5"})),gW=Ct(Vx)({marginTop:"12px"}),hx=class extends Ue.Component{constructor(n){super(n);this.handleReset=()=>{this.setState({hasError:!1,error:null})};this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){y.error("[IssuesPanel ErrorBoundary] Caught error:",n,r)}render(){return this.state.hasError?Ue.createElement(pW,null,Ue.createElement(dW,null,"\u26A0\uFE0F Issues Panel Error"),Ue.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),Ue.createElement(fW,null,this.state.error?.message||"Unknown error",`
150
+ `;try{await navigator.clipboard.writeText(U+ne),G(!0),setTimeout(()=>G(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};V.useEffect(()=>{B&&ae.current&&ae.current.scrollIntoView({behavior:"smooth",block:"start"})},[B]);let pe=SH(()=>e.filter(ne=>{let W=P==="all"||ne.severity===P,Ae=N==="all"||ne.status===N,ge=ee||!jH(ne);return W&&Ae&&ge}),[e,P,N,ee]),Ie=()=>{pe.forEach(ne=>{ne.selectedForFix||l(ne.id)})},ze=()=>{pe.forEach(ne=>{ne.selectedForFix&&l(ne.id)})},me=()=>{pe.forEach(ne=>{ne.generatedFix&&ne.generatedFix.status==="ready"&&!ne.selectedForFix&&l(ne.id)})},Nt=pe.filter(ne=>ne.selectedForFix).length,he=pe.filter(ne=>ne.severity==="critical").length,vt=pe.filter(ne=>ne.severity==="major").length,Ge=pe.filter(ne=>ne.severity==="minor").length,lt=pe.filter(ne=>ne.generatedFix&&ne.generatedFix.status==="ready").length,nt=pe.filter(ne=>ne.selectedForFix&&ne.generatedFix&&ne.generatedFix.status==="ready").length;return e.length===0?I?V.createElement(Oc,{label:"Loading review..."}):v?V.createElement(TI,null):V.createElement(FI,null,V.createElement(EI,null,T?"\u2728":"\u{1F441}\uFE0F"),V.createElement(AI,null,T?"No issues found":"No review yet"),V.createElement(PI,null,T?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):V.createElement(CH,{"data-testid":"issues-panel"},V.createElement(TH,null,V.createElement(II,{value:P,onChange:ne=>D(ne.target.value)},V.createElement("option",{value:"all"},"All Severities"),V.createElement("option",{value:"critical"},"Critical Only"),V.createElement("option",{value:"major"},"Major Only"),V.createElement("option",{value:"minor"},"Minor Only")),V.createElement(II,{value:N,onChange:ne=>w(ne.target.value)},V.createElement("option",{value:"all"},"All Statuses"),V.createElement("option",{value:"pending"},"Pending"),V.createElement("option",{value:"applied"},"Applied"),V.createElement("option",{value:"verified"},"Verified"),V.createElement("option",{value:"failed"},"Failed"))),V.createElement("div",null,V.createElement(IH,{isOpen:L,onClick:()=>K(!L)},V.createElement(FH,null,V.createElement(EH,{isOpen:L},V.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},V.createElement("polyline",{points:"6 9 12 15 18 9"}))),V.createElement(LH,null,pe.length," issues"),(()=>{if(pe.length===0)return null;let ne=pe.map(ge=>ge.generatedFix?.filePath||ge.file).filter(Boolean);if(ne.length===0)return null;let W=ne[0];return ne.every(ge=>ge===W)?V.createElement(BH,null,"in ",W):null})(),V.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},he>0&&V.createElement(yx,{variant:"critical"},he," critical"),vt>0&&V.createElement(yx,{variant:"major"},vt," major"),Ge>0&&V.createElement(yx,{variant:"minor"},Ge," minor"))),V.createElement(PH,{onClick:ne=>ne.stopPropagation()},V.createElement(_c,{onClick:Ie},"All"),V.createElement(_c,{onClick:ze},"None"),V.createElement(_c,{onClick:se},j?"\u2713":"\u2398"," Copy"),lt>0&&V.createElement(_c,{onClick:me},"Fixes (",lt,")"))),B&&V.createElement(RH,{ref:ae,variant:B.error||B.failed>0?"warning":"success"},B.error?V.createElement(V.Fragment,null,B.error):B.failed>0?V.createElement(V.Fragment,null,"Applied ",B.succeeded,"/",B.total," fixes. ",B.failed," failed. Run a new review to verify."):V.createElement(V.Fragment,null,"Applied ",B.total," fix",B.total!==1?"es":"","! Run a new review to verify changes."),m&&V.createElement(zH,{onClick:m},"\u2715")),Nt>0&&V.createElement(LI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),de.enableFixGeneration&&F&&V.createElement(DI,{disabled:z||_||M,onClick:F},V.createElement("span",null,"\u{1F916}"),z&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:z?`Generating... (${qe}s)`:`Generate Fixes for ${Nt} Issue${Nt>1?"s":""}`),de.enableFixApply&&h&&g&&V.createElement(MI,{disabled:z||_||nt===0,onClick:g},_?"Applying...":z?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),de.enableFixApply&&!h&&C&&V.createElement(BI,{disabled:z||M||nt===0,copied:M,onClick:C},M?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")),A&&!z&&V.createElement(NH,{confidence:A.overallConfidence},V.createElement(OH,null,V.createElement($H,null,"AI Self-Review"),V.createElement(_H,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),V.createElement(UH,null,A.variantSafety&&V.createElement($c,null,V.createElement(Uc,null,"Variant safety: "),A.variantSafety),A.gaps.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Gaps: "),V.createElement("ul",null,A.gaps.map((ne,W)=>V.createElement("li",{key:W},ne)))),!A.wouldReachPerfect&&A.reasonsNotPerfect.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Why not 100%: "),V.createElement("ul",null,A.reasonsNotPerfect.map((ne,W)=>V.createElement("li",{key:W},ne)))),A.suggestions&&A.suggestions.length>0&&V.createElement($c,null,V.createElement(Uc,null,"Suggestions: "),V.createElement("ul",null,A.suggestions.map((ne,W)=>V.createElement("li",{key:W},ne)))))),L&&V.createElement(AH,null,pe.length===0?V.createElement(FI,null,V.createElement(EI,null,"\u{1F50D}"),V.createElement(AI,null,"No issues match current filters"),V.createElement(PI,null,"Try adjusting your severity or status filters")):V.createElement(MH,null,(()=>{let ne={};pe.forEach(U=>{let H=U.detectedBy;H&&(ne[H]=(ne[H]||0)+1)});let W=Object.entries(ne).sort((U,H)=>H[1]-U[1])[0],Ae=W&&W[1]>pe.length/2?W[0]:void 0,ge=pe.map(U=>U.generatedFix?.filePath||U.file).filter(Boolean),O=ge.length>0&&ge.every(U=>U===ge[0]);return pe.map(U=>V.createElement(SI,{key:U.id,issue:U,modelId:t,dominantDetector:Ae,showFilePath:!O,onToggleSelection:l,onDismiss:k,onUndismiss:R,onApplyFix:S}))})()))),Nt>0&&V.createElement(LI,null,x&&V.createElement(Mo,{variant:"timing"},x.durationSec,"s (",x.issueCount," fixes)"),b&&V.createElement(V.Fragment,null,V.createElement(Mo,{variant:"cost"},"$",b.costUsd.toFixed(3)," / \u20AA",(b.costUsd*3.65).toFixed(2)),V.createElement(Mo,{variant:"tokens",title:`Input: ${b.inputTokens.toLocaleString()} \xB7 Output: ${b.outputTokens.toLocaleString()}`},"# ",((b.inputTokens+b.outputTokens)/1e3).toFixed(1),"K"),V.createElement(Mo,{variant:"model",title:b.modelId},b.modelId.replace("claude-","").replace(/-\d{8}$/,""))),de.enableFixGeneration&&F&&V.createElement(DI,{disabled:z||_||M,onClick:F},V.createElement("span",null,"\u{1F916}"),z&&E?`Generating ${E.completed}/${E.total}... (${qe}s)`:z?`Generating... (${qe}s)`:`Generate Fixes for ${Nt} Issue${Nt>1?"s":""}`),de.enableFixApply&&h&&g&&V.createElement(MI,{disabled:z||_||nt===0,onClick:g},_?"Applying...":z?"Generating...":nt>0?`Apply ${nt} Ready Fix${nt>1?"es":""}`:"Apply Fixes (generate first)"),de.enableFixApply&&!h&&C&&V.createElement(BI,{disabled:z||M||nt===0,copied:M,onClick:C},M?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")))};De();var HH=Ct.div({display:"flex",flexDirection:"column"}),WH=Ct.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),VH=Ct.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),bx=Ct.span(({theme:e,variant:t})=>{let n={resolved:{bg:e.background.positive,text:e.color.positive},remaining:{bg:e.background.warning,text:e.color.warning},new:{bg:e.color.tertiary,text:le}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),GH=Ct.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),afe=Ct.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),lfe=Ct.div({fontSize:"48px",marginBottom:"16px"}),cfe=Ct.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),ufe=Ct.div({fontSize:"14px",opacity:.8}),qH=Ct.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),YH=Ct.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),KH=Ct(wn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),XH=Ct(Er)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),QH=Ct.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),JH=Ct.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),ZH=Ct.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),eW=Ct.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),tW=Ct.button(({theme:e})=>({background:"none",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"2px 8px",fontSize:"11px",color:e.color.mediumdark,cursor:"pointer","&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText,borderColor:e.color.secondary}})),nW=Ct.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),rW=Ct.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),oW=Ct.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",padding:"12px 0 8px 0",marginTop:"8px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"8px","&:first-of-type":{marginTop:0}})),iW=Ct.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),sW=e=>{if(!e)return"Other";let t=e.toLowerCase();return t.includes("hug")||t.includes("fill")||t.includes("content-driven")?"HUG/FILL Sizing":t.includes("sub-pixel")||t.includes("negligible")?"Sub-pixel Differences":t.includes("values match")||t.includes("values already match")||t.includes("identical")?"Values Match":t.includes("no fix needed")||t.includes("no changes needed")?"No Fix Needed":"Other"},zI=e=>{if(!e)return"";let t=e.replace(/^Auto-dismissed:\s*/i,"").replace(/^Programmatic:\s*/i,"").replace(/^Two-Pass:\s*/i,"");return t=t.replace(/Sub-pixel difference \([\d.]+px\) - within [\d.]+px tolerance/i,"Sub-pixel difference").replace(/Dimension issue with HUG\/FILL sizing - width is content-driven, not fixed/i,"Width is content-driven").replace(/Height issue with HUG sizing - dimension is content-driven, not actionable/i,"Height is content-driven").replace(/Width issue with HUG sizing - dimension is content-driven, not actionable/i,"Width is content-driven").replace(/no-changes-needed - values already match/i,"Values already match").replace(/Values are the same - no difference/i,"Values match"),t},aW=Ct.span(({theme:e,phase:t})=>{let n={"post-ai-validation":{bg:"#4b5563",text:"#ffffff"},"ai-validation":{bg:"#7c3aed",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n.user;return{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",fontWeight:600,color:o,backgroundColor:r,padding:"3px 10px",borderRadius:"10px",marginBottom:"8px"}}),lW=Ct.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"8px",marginLeft:"8px",fontSize:"11px",color:e.textMutedColor,"& > span":{display:"inline-flex",alignItems:"center",gap:"3px"}})),wx=e=>{if(!e)return;let t=e.toLowerCase();if(t.includes("no-changes-needed")||t.includes("values already match")||t.includes("sub-pixel")||t.includes("negligible")||t.includes("hug")||t.includes("fill")||t.includes("content-driven")||t.includes("equivalent")||t.includes("layout mechanism"))return"post-ai-validation"},cW=(e,t)=>{switch(e||wx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},NI=(e,t)=>{switch(e||wx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";case"user":return"Manual";default:return"Auto"}},uW=Ct.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),pW=Ct.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),dW=Ct.pre(({theme:e})=>({fontSize:"12px",color:e.color.negative,backgroundColor:e.background.app,padding:"12px",borderRadius:"4px",overflow:"auto",maxHeight:"200px",fontFamily:"monospace",lineHeight:"1.5"})),fW=Ct(qx)({marginTop:"12px"}),Sx=class extends Ue.Component{constructor(n){super(n);this.handleReset=()=>{this.setState({hasError:!1,error:null})};this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){y.error("[IssuesPanel ErrorBoundary] Caught error:",n,r)}render(){return this.state.hasError?Ue.createElement(uW,null,Ue.createElement(pW,null,"\u26A0\uFE0F Issues Panel Error"),Ue.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),Ue.createElement(dW,null,this.state.error?.message||"Unknown error",`
151
151
 
152
- `,this.state.error?.stack),Ue.createElement(gW,{onClick:this.handleReset},"Try Again")):this.props.children}},zI=()=>{let{currentStoryId:e}=rt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=ie(),{dismissAndSync:a,undismissAndSync:u}=WT(),{loadingMapping:c}=rt(),l=!!e&&!t&&!n&&c,[d,f]=Ue.useState(!1),[p,g]=Ue.useState(!1),[S,C]=Ue.useState(!1),{isSupported:F,isDetecting:k}=nm(),{refreshStorybookOnly:R}=Uo(),{generateBatchFixes:z,isGenerating:_,error:M,timing:B,progress:m,usage:x,selfReview:b,lastStorybookRoot:E}=Jg(),{applyFixes:h,isApplying:T}=Qg({onComplete:R,storybookRoot:E}),I=r.find(W=>W.id===t),v=I?.issues||[],A=Ue.useMemo(()=>v.filter(W=>!W.dismissed),[v]),P=Ue.useMemo(()=>v.filter(W=>W.dismissed),[v]),D=Ue.useMemo(()=>{let W={postAiValidation:0,aiValidation:0,user:0};for(let Ae of P)switch(Ae.dismissedBy){case"post-ai-validation":W.postAiValidation++;break;case"ai-validation":W.aiValidation++;break;default:W.user++;break}return W},[P]),N=A,w=I?.modelId||"unknown",j=A.filter(W=>W.severity==="critical").length,G=A.filter(W=>W.severity==="major").length,L=A.filter(W=>W.severity==="minor").length,K=I?Si(j,G,L):void 0,ee=I?.visualSimilarity,re=I?.costUsd,de=I?.reviewDurationMs,ae=I?.inputTokens,qe=I?.outputTokens,tt=I?.cacheCreationTokens,se=I?.cacheReadTokens,pe=I?.parentReviewId?r.find(W=>W.id===I.parentReviewId):null,Ie=Ue.useMemo(()=>{if(!pe||!I)return null;let W=new Set(pe.issues.map(H=>`${H.type}:${H.property||""}:${H.description}`)),Ae=new Set(N.map(H=>`${H.type}:${H.property||""}:${H.description}`)),ge=pe.issues.filter(H=>!Ae.has(`${H.type}:${H.property||""}:${H.description}`)).length,O=N.filter(H=>W.has(`${H.type}:${H.property||""}:${H.description}`)).length,U=N.filter(H=>!W.has(`${H.type}:${H.property||""}:${H.description}`)).length;return{resolved:ge,remaining:O,newIssues:U}},[pe,I,N]),ze=()=>{N.forEach(W=>{W.selectedForFix||o(W.id)})},me=()=>{N.forEach(W=>{W.selectedForFix&&o(W.id)})},Nt=()=>{N.forEach(W=>{W.generatedFix&&W.generatedFix.status==="ready"&&!W.selectedForFix&&o(W.id)})},{featureFlags:he}=ie(),vt=()=>{if(!he.enableFixGeneration){y.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let W=N.filter(Ae=>Ae.selectedForFix);if(W.length===0){y.warn("[IssuesPanel] No issues selected for fix generation");return}y.debug(`[IssuesPanel] Generating fixes for ${W.length} issue(s)`,W),z(W)},Ge=()=>{if(!he.enableFixApply){y.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let W=N.filter(ge=>ge.selectedForFix&&ge.generatedFix&&ge.generatedFix.status==="ready"&&ge.generatedFix.code&&ge.generatedFix.filePath);if(W.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Ae=W.map(ge=>({id:ge.id,reviewId:ge.reviewId,type:ge.type,severity:ge.severity,title:ge.title,description:ge.description,generatedFix:ge.generatedFix,storyId:I?.storyId||""}));y.debug(`[IssuesPanel] Applying AI-generated fixes for ${Ae.length} issue(s)`,Ae),h(Ae)},lt=W=>{let Ae=N.find(O=>O.id===W);if(!Ae){y.warn("[IssuesPanel] Issue not found:",W);return}if(!Ae.generatedFix||Ae.generatedFix.status!=="ready"||!Ae.generatedFix.code||!Ae.generatedFix.filePath){y.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",W);return}let ge={id:Ae.id,reviewId:Ae.reviewId,type:Ae.type,severity:Ae.severity,title:Ae.title,description:Ae.description,generatedFix:Ae.generatedFix,storyId:I?.storyId||""};y.debug("[IssuesPanel] Applying single AI-generated fix for issue:",ge),h([ge])},nt=async()=>{let W=N.filter(ge=>ge.selectedForFix&&ge.generatedFix&&ge.generatedFix.status==="ready"&&ge.generatedFix.code&&ge.generatedFix.filePath);if(W.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Ae=W.map(ge=>{let O=ge.generatedFix,U=[];return U.push(`// File: ${O.filePath}`),U.push(`// Issue: ${ge.title||ge.description}`),ge.currentValue&&U.push(`// Actual: ${ge.currentValue}`),ge.suggestedValue&&U.push(`// Expected (Figma): ${ge.suggestedValue}`),O.diffPreview&&(U.push("//"),U.push("// Diff:"),O.diffPreview.split(`
152
+ `,this.state.error?.stack),Ue.createElement(fW,{onClick:this.handleReset},"Try Again")):this.props.children}},OI=()=>{let{currentStoryId:e}=rt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=ie(),{dismissAndSync:a,undismissAndSync:u}=GT(),{loadingMapping:c}=rt(),l=!!e&&!t&&!n&&c,[d,f]=Ue.useState(!1),[p,g]=Ue.useState(!1),[S,C]=Ue.useState(!1),{isSupported:F,isDetecting:k}=sm(),{refreshStorybookOnly:R}=Uo(),{generateBatchFixes:z,isGenerating:_,error:M,timing:B,progress:m,usage:x,selfReview:b,lastStorybookRoot:E}=nm(),{applyFixes:h,isApplying:T}=tm({onComplete:R,storybookRoot:E}),I=r.find(W=>W.id===t),v=I?.issues||[],A=Ue.useMemo(()=>v.filter(W=>!W.dismissed),[v]),P=Ue.useMemo(()=>v.filter(W=>W.dismissed),[v]),D=Ue.useMemo(()=>{let W={postAiValidation:0,aiValidation:0,user:0};for(let Ae of P)switch(Ae.dismissedBy){case"post-ai-validation":W.postAiValidation++;break;case"ai-validation":W.aiValidation++;break;default:W.user++;break}return W},[P]),N=A,w=I?.modelId||"unknown",j=A.filter(W=>W.severity==="critical").length,G=A.filter(W=>W.severity==="major").length,L=A.filter(W=>W.severity==="minor").length,K=I?Si(j,G,L):void 0,ee=I?.visualSimilarity,re=I?.costUsd,de=I?.reviewDurationMs,ae=I?.inputTokens,qe=I?.outputTokens,tt=I?.cacheCreationTokens,se=I?.cacheReadTokens,pe=I?.parentReviewId?r.find(W=>W.id===I.parentReviewId):null,Ie=Ue.useMemo(()=>{if(!pe||!I)return null;let W=new Set(pe.issues.map(H=>`${H.type}:${H.property||""}:${H.description}`)),Ae=new Set(N.map(H=>`${H.type}:${H.property||""}:${H.description}`)),ge=pe.issues.filter(H=>!Ae.has(`${H.type}:${H.property||""}:${H.description}`)).length,O=N.filter(H=>W.has(`${H.type}:${H.property||""}:${H.description}`)).length,U=N.filter(H=>!W.has(`${H.type}:${H.property||""}:${H.description}`)).length;return{resolved:ge,remaining:O,newIssues:U}},[pe,I,N]),ze=()=>{N.forEach(W=>{W.selectedForFix||o(W.id)})},me=()=>{N.forEach(W=>{W.selectedForFix&&o(W.id)})},Nt=()=>{N.forEach(W=>{W.generatedFix&&W.generatedFix.status==="ready"&&!W.selectedForFix&&o(W.id)})},{featureFlags:he}=ie(),vt=()=>{if(!he.enableFixGeneration){y.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let W=N.filter(Ae=>Ae.selectedForFix);if(W.length===0){y.warn("[IssuesPanel] No issues selected for fix generation");return}y.debug(`[IssuesPanel] Generating fixes for ${W.length} issue(s)`,W),z(W)},Ge=()=>{if(!he.enableFixApply){y.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let W=N.filter(ge=>ge.selectedForFix&&ge.generatedFix&&ge.generatedFix.status==="ready"&&ge.generatedFix.code&&ge.generatedFix.filePath);if(W.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Ae=W.map(ge=>({id:ge.id,reviewId:ge.reviewId,type:ge.type,severity:ge.severity,title:ge.title,description:ge.description,generatedFix:ge.generatedFix,storyId:I?.storyId||""}));y.debug(`[IssuesPanel] Applying AI-generated fixes for ${Ae.length} issue(s)`,Ae),h(Ae)},lt=W=>{let Ae=N.find(O=>O.id===W);if(!Ae){y.warn("[IssuesPanel] Issue not found:",W);return}if(!Ae.generatedFix||Ae.generatedFix.status!=="ready"||!Ae.generatedFix.code||!Ae.generatedFix.filePath){y.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",W);return}let ge={id:Ae.id,reviewId:Ae.reviewId,type:Ae.type,severity:Ae.severity,title:Ae.title,description:Ae.description,generatedFix:Ae.generatedFix,storyId:I?.storyId||""};y.debug("[IssuesPanel] Applying single AI-generated fix for issue:",ge),h([ge])},nt=async()=>{let W=N.filter(ge=>ge.selectedForFix&&ge.generatedFix&&ge.generatedFix.status==="ready"&&ge.generatedFix.code&&ge.generatedFix.filePath);if(W.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Ae=W.map(ge=>{let O=ge.generatedFix,U=[];return U.push(`// File: ${O.filePath}`),U.push(`// Issue: ${ge.title||ge.description}`),ge.currentValue&&U.push(`// Actual: ${ge.currentValue}`),ge.suggestedValue&&U.push(`// Expected (Figma): ${ge.suggestedValue}`),O.diffPreview&&(U.push("//"),U.push("// Diff:"),O.diffPreview.split(`
153
153
  `).forEach(H=>{U.push(`// ${H}`)})),U.push("//"),U.push("// Full Fixed Code:"),U.push(O.code),U.join(`
154
154
  `)}).join(`
155
155
 
156
156
  `+"=".repeat(60)+`
157
157
 
158
- `);g(!0);try{await rm(Ae)?y.debug(`[IssuesPanel] Copied ${W.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>g(!1),1500)}catch(ge){y.error("[IssuesPanel] Error copying fixes:",ge),g(!1)}},ne=async W=>{W.stopPropagation();let Ae=P.map(O=>[`[${O.severity.toUpperCase()}] ${O.title||O.description}`,`Phase: ${RI(O.dismissedBy,O.dismissReason)}`,O.dismissReason?`Reason: ${DI(O.dismissReason)}`:"",O.property?`Property: ${O.property}`:"",O.currentValue?`Current: ${O.currentValue}`:"",O.suggestedValue?`Expected: ${O.suggestedValue}`:""].filter(Boolean).join(`
158
+ `);g(!0);try{await am(Ae)?y.debug(`[IssuesPanel] Copied ${W.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>g(!1),1500)}catch(ge){y.error("[IssuesPanel] Error copying fixes:",ge),g(!1)}},ne=async W=>{W.stopPropagation();let Ae=P.map(O=>[`[${O.severity.toUpperCase()}] ${O.title||O.description}`,`Phase: ${NI(O.dismissedBy,O.dismissReason)}`,O.dismissReason?`Reason: ${zI(O.dismissReason)}`:"",O.property?`Property: ${O.property}`:"",O.currentValue?`Current: ${O.currentValue}`:"",O.suggestedValue?`Expected: ${O.suggestedValue}`:""].filter(Boolean).join(`
159
159
  `)).join(`
160
160
 
161
161
  ---
@@ -163,11 +163,11 @@ ${Ne.diffPreview}`),Ne.error&&Pe.push(`Error: ${Ne.error}`)}return Pe.push(""),P
163
163
  `),ge=`Filtered Issues (${P.length})
164
164
  ${"=".repeat(40)}
165
165
 
166
- `;try{await navigator.clipboard.writeText(ge+Ae),C(!0),setTimeout(()=>C(!1),2e3)}catch(O){y.error("Failed to copy dismissed issues:",O)}};return Ue.createElement(WH,null,Ie&&Ue.createElement(VH,null,Ue.createElement(GH,null,"\u{1F4CA} Progress:"),Ue.createElement(mx,{variant:"resolved"},"\u2705 ",Ie.resolved," resolved"),Ue.createElement(mx,{variant:"remaining"},"\u23F3 ",Ie.remaining," remaining"),Ie.newIssues>0&&Ue.createElement(mx,{variant:"new"},"\u{1F195} ",Ie.newIssues," new"),Ue.createElement(qH,null,"Iteration ",I?.iterationNumber||1)),Ue.createElement(hx,null,Ue.createElement(BI,{issues:N,modelId:w,complianceScore:K,visualSimilarity:ee,costUsd:re,reviewDurationMs:de,inputTokens:ae,outputTokens:qe,cacheCreationTokens:tt,cacheReadTokens:se,onToggleSelection:o,onSelectAll:ze,onSelectNone:me,onSelectAllFixes:Nt,onGenerateFixes:vt,onApplyFixes:Ge,onApplyFix:lt,onCopyAllFixes:nt,onDismiss:a,onUndismiss:u,isGenerating:_,isApplying:T,isCopying:p,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:B,generationUsage:x,hasReviewBeenRun:!!I,isLoadingReview:l,isReviewing:n,generationProgress:m,autoApplySupported:F,selfReview:b})),P.length>0&&Ue.createElement(YH,null,Ue.createElement(KH,null,Ue.createElement(XH,{onClick:()=>f(!d)},Ue.createElement("span",null,d?"\u25BC":"\u25B6"),Ue.createElement("span",null,"Filtered out"),Ue.createElement(JH,null,P.length),Ue.createElement(cW,null,D.postAiValidation>0&&Ue.createElement("span",null,"\u2699\uFE0F ",D.postAiValidation),D.aiValidation>0&&Ue.createElement("span",null,"\u2726 ",D.aiValidation),D.user>0&&Ue.createElement("span",null,"\u{1F464} ",D.user))),Ue.createElement(QH,{onClick:ne},S?"\u2713 Copied!":"Copy")),d&&Ue.createElement(ZH,null,(()=>{let W=P.reduce((O,U)=>{let H=aW(U.dismissReason);return O[H]||(O[H]=[]),O[H].push(U),O},{}),Ae=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(W).sort((O,U)=>Ae.indexOf(O)-Ae.indexOf(U)).map(O=>Ue.createElement(Ue.Fragment,{key:O},Ue.createElement(iW,null,O,Ue.createElement(sW,null,W[O].length)),W[O].map(U=>Ue.createElement(eW,{key:U.id},Ue.createElement(tW,null,Ue.createElement(lW,{phase:U.dismissedBy||xx(U.dismissReason)||"post-ai-validation"},uW(U.dismissedBy,U.dismissReason)," ",RI(U.dismissedBy,U.dismissReason)),Ue.createElement(nW,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),Ue.createElement(rW,null,"[",U.severity.toUpperCase(),"] ",U.title||U.description),U.dismissReason&&Ue.createElement(oW,null,DI(U.dismissReason))))))})())))};var hW=ya.div({marginTop:"20px"}),xW=ya.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),yW=ya.div({display:"flex",alignItems:"center"}),yx=ya(io)({padding:"10px 16px"}),bW=ya.div({minHeight:"200px"}),bx=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ie(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return mW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Tr.createElement(hW,null,Tr.createElement(xW,null,Tr.createElement(yW,null,a&&Tr.createElement(yx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Tr.createElement(yx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Tr.createElement(yx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Tr.createElement(bW,null,a&&e==="chat"&&(u?Tr.createElement(HT,null):Tr.createElement(rx,null)),e==="issues"&&Tr.createElement(zI,null),a&&e==="prompt"&&Tr.createElement(nx,null)))};ve();import Z,{useState as ri,useRef as kx,useEffect as kW,useMemo as CW}from"react";import{styled as mt,useTheme as TW}from"storybook/theming";je();De();var Uc={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},ba="uicopilot_feature_flags";function Sx(){try{let e=localStorage.getItem(ba);if(e){let t=JSON.parse(e);return{...Uc,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return Uc}function SW(e,t){try{let r={...Sx(),[e]:t},o={};for(let i in r){let s=i;r[s]!==Uc[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(ba,JSON.stringify(o)):localStorage.removeItem(ba),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function wW(){try{localStorage.removeItem(ba),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function wx(e){return Sx()[e]}function vW(){let e=Object.keys(Uc).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(ba,JSON.stringify(e)),y.debug("[FeatureFlags] All features enabled! Reload to apply.")}catch(t){y.error("[FeatureFlags] Failed to enable all features:",t)}}typeof window<"u"&&(window.uicopilot={...window.uicopilot,featureFlags:{get:Sx,set:SW,reset:wW,enableAll:vW,isEnabled:wx}});De();pt();import gn from"react";var NI=()=>gn.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},gn.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),gn.createElement("circle",{cx:"12",cy:"12",r:"3"}));var vx={xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},OI=()=>gn.createElement("svg",{...vx},gn.createElement("circle",{cx:"11",cy:"11",r:"8"}),gn.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),_I=()=>gn.createElement("svg",{...vx},gn.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),gn.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),gn.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),gn.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),gn.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),gn.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),$I=()=>gn.createElement("svg",{...vx},gn.createElement("polyline",{points:"23 4 23 10 17 10"}),gn.createElement("polyline",{points:"1 20 1 14 7 14"}),gn.createElement("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"}));var Sa=mt.div({marginTop:"20px"}),Cx=mt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Tx=mt.div({display:"flex",alignItems:"center",gap:"12px"}),wa=mt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Ofe=mt.div({display:"flex",gap:"8px"}),_fe=mt.button(({active:e,theme:t})=>({padding:"4px 12px",backgroundColor:e?t.color.secondary:"transparent",color:e?"#fff":t.color.mediumdark,border:`1px solid ${e?t.color.secondary:t.appBorderColor}`,borderRadius:"4px",fontSize:"11px",fontWeight:500,cursor:"pointer",transition:"all 0.2s","&:hover":{opacity:.9}})),UI=mt.div(({layout:e})=>({display:e==="side-by-side"?"grid":"flex",gridTemplateColumns:e==="side-by-side"?"1fr 1fr":void 0,gap:e==="side-by-side"?"12px":0,position:"relative",width:"100%",justifyContent:e==="overlay"?"center":void 0})),Ix=mt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:e.background.app,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center"})),Fx=mt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.7)",color:e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),IW=mt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),Ex=mt.button(({theme:e,accent:t})=>({width:"24px",height:"24px",padding:"0",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.12)":"rgba(255, 255, 255, 0.92)",border:`1px solid ${t}55`,borderRadius:e.appBorderRadius,color:t,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s",backdropFilter:"blur(4px)","&:hover:not(:disabled)":{backgroundColor:t,color:"#ffffff",borderColor:t},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),jI=mt.div({marginTop:"12px",display:"flex",justifyContent:"center"}),HI=mt(qt)({fontSize:"12px",padding:"6px 14px",height:"auto"}),FW=mt.img(({opacity:e=1})=>({maxWidth:"100%",maxHeight:"120px",height:"auto",display:"block",objectFit:"contain",opacity:e})),EW=mt.img({display:"block",objectFit:"contain",maxHeight:"120px",maxWidth:"100%"}),AW=mt.div({position:"relative",display:"inline-block"}),$fe=mt.svg(({isVisible:e})=>({position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",opacity:e?1:0,transition:"opacity 150ms ease-in",...!e&&{transition:"opacity 100ms ease-out"}})),PW=mt.div({position:"relative",display:"inline-block"}),Ufe=mt.div(({width:e,height:t,theme:n})=>({position:"relative",width:e?`${e}px`:"auto",height:t?`${t}px`:"auto",border:`1px solid ${n.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:n.background.app})),LW=mt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),MW=mt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),BW=mt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),DW=mt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),RW=mt.input({flex:1}),Ax=mt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),jfe=mt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),WI=mt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),qi=mt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center","&::before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:e.base==="dark"?"linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent)":"linear-gradient(90deg, transparent, rgba(0,0,0,0.04), transparent)",animation:"shimmer 1.5s ease-in-out infinite",pointerEvents:"none"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Yi=mt.div({textAlign:"center",zIndex:1}),Ki=mt.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"12px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Xi=mt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Px=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=TW(),{currentMapping:o,loadingMapping:i}=rt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:f}=ie(),{selectedProjectId:p}=Ze(),{sessionToken:g}=we(),{openComponentBrowser:S}=Rs(),{hasMapping:C,deleteMapping:F,setCurrentMapping:k}=Ho(),R=wx("enableHoverHighlight"),[z,_]=ri("side-by-side"),[M,B]=ri(.5),[m,x]=ri(!1),[b,E]=ri(!1),[h,T]=ri(!1),I=async()=>{T(!1);try{let re=o?.id;re&&await F(re),k(null)}catch(re){y.error("[ScreenshotComparison] Failed to unlink:",re)}};kW(()=>{E(!1)},[s]);let[v,A]=ri(null),[P,D]=ri(null),N=kx(null),w=kx(null),j=kx(null),G=CW(()=>{if(!R||!l||!f)return null;let re=d.find(de=>de.id===f);return re?.issues&&re.issues.find(de=>de.id===l)||null},[l,f,d]),L=re=>{let de=re.currentTarget;E(!0),!ht.getState().figmaDimensions&&de.naturalWidth&&de.naturalHeight&&ht.getState().setFigmaDimensions({width:de.naturalWidth,height:de.naturalHeight}),requestAnimationFrame(()=>{if(w.current){let{clientWidth:qe,clientHeight:tt}=w.current;qe&&tt&&D({width:qe,height:tt})}})},K=()=>{requestAnimationFrame(()=>{if(N.current){let{clientWidth:re,clientHeight:de}=N.current;re&&de&&A({width:re,height:de})}})},ee=async()=>{if(!(!p||!g)){x(!0);try{let re=q();await oe(`${re}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},credentials:"include"}),c(null),y.debug("Figma cache cleared, image will reload on next review")}catch(re){y.error("Failed to refresh Figma:",re)}finally{x(!1)}}};return e?Z.createElement(Sa,null,Z.createElement(Cx,null,Z.createElement(Tx,null,Z.createElement(wa,null,"Screenshot Comparison"))),Z.createElement(WI,null,Z.createElement(qi,null,Z.createElement(Yi,null,Z.createElement(Ki,null),Z.createElement(Xi,null,"Loading Figma..."))),Z.createElement(qi,null,Z.createElement(Yi,null,Z.createElement(Ki,null),Z.createElement(Xi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?Z.createElement(Sa,null,Z.createElement(Cx,null,Z.createElement(Tx,null,Z.createElement(wa,null,"Screenshot Comparison"))),Z.createElement(WI,null,Z.createElement(qi,null,Z.createElement(Yi,null,Z.createElement(Ki,null),Z.createElement(Xi,null,"Loading..."))))):Z.createElement(Sa,null,Z.createElement(wa,null,"Screenshot Comparison"),Z.createElement(Ax,null,"No Figma mapping. Link this story to a Figma frame to compare designs.",Z.createElement(jI,null,Z.createElement(HI,{onClick:S,disabled:!p},"\u{1F517} Map Component")))):!s&&!a?Z.createElement(Sa,null,Z.createElement(wa,null,"Screenshot Comparison"),Z.createElement(Ax,null,"No screenshots available. Run a review to capture Figma and Storybook screenshots.")):Z.createElement(Sa,{ref:j},Z.createElement(Cx,null,Z.createElement(Tx,null,Z.createElement(wa,null,"Screenshot Comparison"))),z==="side-by-side"?Z.createElement(UI,{layout:"side-by-side"},s&&!t?Z.createElement(Ix,null,Z.createElement(Fx,null,"Figma Design"),Z.createElement(IW,null,C&&Z.createElement(Ex,{accent:r.color.secondary,onClick:S,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},Z.createElement(OI,null)),Z.createElement(Ex,{accent:r.color.positive,onClick:ee,disabled:m,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},Z.createElement($I,null)),C&&Z.createElement(Ex,{accent:r.color.negative,onClick:()=>T(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},Z.createElement(_I,null))),Z.createElement(AW,null,Z.createElement(EW,{ref:w,src:s,alt:"Figma design",onLoad:L,style:{...v?{width:v.width,height:v.height}:{maxWidth:"100%",maxHeight:"120px"},opacity:b?1:0,transition:"opacity 150ms ease-in"}}))):!o&&!i?Z.createElement(Ix,null,Z.createElement(Fx,null,"Figma Design"),Z.createElement(Ax,{style:{border:"none",padding:"16px"}},"No Figma mapping.",Z.createElement(jI,null,Z.createElement(HI,{onClick:S,disabled:!p},"\u{1F517} Map Component")))):Z.createElement(qi,null,Z.createElement(Yi,null,Z.createElement(Ki,null),Z.createElement(Xi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?Z.createElement(Ix,null,Z.createElement(Fx,null,"Storybook Component"),Z.createElement(FW,{ref:N,src:a,alt:"Storybook component",onLoad:K})):Z.createElement(qi,null,Z.createElement(Yi,null,Z.createElement(Ki,null),Z.createElement(Xi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):Z.createElement(Z.Fragment,null,Z.createElement(UI,{layout:"overlay"},Z.createElement(PW,null,s&&a?Z.createElement(Z.Fragment,null,Z.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},Z.createElement(LW,{ref:N,src:a,alt:"Storybook component",onLoad:K,style:{maxHeight:"200px"}}),v&&Z.createElement(MW,{src:s,alt:"Figma design overlay",style:{opacity:M,width:v.width,height:v.height,objectFit:"fill"}})),Z.createElement("div",{style:{fontSize:"10px",color:"#888",marginTop:"8px",textAlign:"center"}},Z.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",Z.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),v&&` \u2022 ${v.width}\xD7${v.height}px`)):Z.createElement(qi,null,Z.createElement(Yi,null,Z.createElement(Ki,null),Z.createElement(Xi,null,"Loading Images..."))))),a&&s&&Z.createElement(BW,null,Z.createElement(DW,null,"Figma Opacity:"),Z.createElement(RW,{type:"range",min:"0",max:"1",step:"0.01",value:M,onChange:re=>B(parseFloat(re.target.value))}),Z.createElement("span",null,Math.round(M*100),"%"))),Z.createElement(Di,{isOpen:h,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:I,onCancel:()=>T(!1)}))};ve();pt();var zW=Qi.div({height:"100%"}),Lx=Qi.div({marginBottom:"20px"}),VI=Qi.div(({theme:e})=>({padding:"12px",backgroundColor:e.background.negative||"#fee2e2",border:`1px solid ${e.color.negative||"#fca5a5"}`,borderRadius:"6px",color:e.color.negative||"#991b1b",fontSize:"13px",marginBottom:"16px",display:"flex",alignItems:"flex-start",gap:"8px"})),GI=Qi.span({fontSize:"16px",flexShrink:0}),NW=Qi.div(({theme:e})=>({padding:"10px 12px",backgroundColor:`${e.color.warning}1a`,border:`1px solid ${e.color.warning}`,borderRadius:"6px",color:e.color.warning,fontSize:e.typography.size.s2,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px",lineHeight:1.4})),qI=Qi.div({flex:1}),Mx=()=>{let{reviewError:e,getCurrentReview:t}=ie(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Rs(),{selectedProjectId:s}=qr(),{setCurrentMapping:a}=Ho(),{currentStoryId:u,currentStoryName:c}=rt(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:f,screenshotError:p,setFigmaImageDirect:g}=Uo(),S=async C=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",C),y.debug("[ReviewPanel] frame.id:",C?.id);let F=ht.getState(),k=F.selectedProjectId,R=F.currentStoryId,z=F.currentStoryName,_=F.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",k),y.debug("[ReviewPanel] currentStoryId (from store):",R),y.debug("[ReviewPanel] currentStoryName (from store):",z),C.thumbnail&&R&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),g(R,C.id,C.thumbnail));try{let M=q(),B=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!B),y.debug("[ReviewPanel] dashboardUrl:",M),!B||!k||!R){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!B,selectedProjectId:k,currentStoryId:R});return}let m=_?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:k,storyId:R,name:z,figmaNodeId:C.id,figmaFileKey:m});let x=await oe(`${M}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${B}`},body:JSON.stringify({projectId:k,storyId:R,name:z,figmaNodeId:C.id,figmaFileKey:m})});if(x.ok){let b=await x.json();b.mapping&&(a(b.mapping),C.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),ht.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",b.mapping))}else{let b=await x.text();y.error("[ReviewPanel] Failed to save mapping:",b)}}catch(M){y.error("[ReviewPanel] Error saving mapping:",M)}};return Qt.createElement(zW,null,Qt.createElement(Lx,null,Qt.createElement(eh,null)),e&&Qt.createElement(VI,null,Qt.createElement(GI,null,"\u26A0\uFE0F"),Qt.createElement(qI,null,e)),p&&Qt.createElement(VI,null,Qt.createElement(GI,null,"\u26A0\uFE0F"),Qt.createElement(qI,null,"Screenshot loading error: ",p)),n?.variantMismatch&&Qt.createElement(NW,null,Qt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Qt.createElement("span",null,Qt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Qt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Qt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Qt.createElement(Lx,null,Qt.createElement(Px,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:f})),Qt.createElement(Lx,null,Qt.createElement(bx,null)),Qt.createElement(Mi,{isOpen:r,onClose:o,onSelect:S,figmaFileUrl:i||"",projectId:s||void 0}))};ve();De();je();pt();import{useEffect as YI,useState as OW,useRef as Bx,useCallback as _W}from"react";var $W=q(),UW=2e3;function KI(){let{sessionToken:e,usageData:t,setUsageData:n}=we(),[r,o]=OW(null),i=Bx(null),s=Bx(!1),a=Bx(0);YI(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=_W(()=>{o(null)},[]);return YI(()=>{if(!e)return;let c=async()=>{let d=Date.now();if(s.current||d-a.current<UW){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=d;try{y.debug("[useBalanceRefresh] Refreshing balance...");let f=await oe(`${$W}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(f.ok){let p=await f.json(),g=p.creditBalance,S=i.current;if(S!==null&&g>S){let C=g-S;o({message:`Credits added! +${Math.floor(C)} credit(s)`,previousBalance:S,newBalance:g}),y.debug("[useBalanceRefresh] Credits added:",C)}i.current=g,n(p),y.debug("[useBalanceRefresh] Balance updated:",g)}}catch(f){y.error("[useBalanceRefresh] Failed to refresh:",f)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}ve();ve();je();De();pt();fg();import{useEffect as jW,useRef as HW}from"react";var WW=300*1e3,XI="uicopilot_feature_flags_fetched_at";function VW(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(XI);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<WW}catch{return!1}}var Dx=null,GW={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}};function QI(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ie(),{sessionToken:r,resetAuth:o}=we(),i=HW(null);jW(()=>{if(!r||r===i.current)return;if(i.current=r,VW()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(Dx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${q()}/api/addon/flags`;Dx=oe(s,{headers:{Authorization:`Bearer ${r}`}}).then(a=>{if(a.status===401||a.status===403)throw y.debug("[useFeatureFlags] Token rejected, resetting auth"),o(),new Error("session token invalid");if(!a.ok)throw new Error(`flags endpoint returned ${a.status}`);return a.json()}).then(a=>{y.debug("[useFeatureFlags] Received flags:",a);let u={enableFixGeneration:!!a.enableFixGeneration,enableFixApply:!!a.enableFixApply,enableAutoMap:!!a.enableAutoMap,enableReviewBadges:!!a.enableReviewBadges,showCosts:!!a.showCosts,enableParallelReview:!!a.enableParallelReview,enableModelSelection:!!a.enableModelSelection};a.role&&(t(a.role),a.role==="beta"&&ew());let c=a.role==="admin"&&n?GW[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(XI,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{Dx=null})},[r,e,t])}ve();je();var KW={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},XW=fr.div`
166
+ `;try{await navigator.clipboard.writeText(ge+Ae),C(!0),setTimeout(()=>C(!1),2e3)}catch(O){y.error("Failed to copy dismissed issues:",O)}};return Ue.createElement(HH,null,Ie&&Ue.createElement(WH,null,Ue.createElement(VH,null,"\u{1F4CA} Progress:"),Ue.createElement(bx,{variant:"resolved"},"\u2705 ",Ie.resolved," resolved"),Ue.createElement(bx,{variant:"remaining"},"\u23F3 ",Ie.remaining," remaining"),Ie.newIssues>0&&Ue.createElement(bx,{variant:"new"},"\u{1F195} ",Ie.newIssues," new"),Ue.createElement(GH,null,"Iteration ",I?.iterationNumber||1)),Ue.createElement(Sx,null,Ue.createElement(RI,{issues:N,modelId:w,complianceScore:K,visualSimilarity:ee,costUsd:re,reviewDurationMs:de,inputTokens:ae,outputTokens:qe,cacheCreationTokens:tt,cacheReadTokens:se,onToggleSelection:o,onSelectAll:ze,onSelectNone:me,onSelectAllFixes:Nt,onGenerateFixes:vt,onApplyFixes:Ge,onApplyFix:lt,onCopyAllFixes:nt,onDismiss:a,onUndismiss:u,isGenerating:_,isApplying:T,isCopying:p,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:B,generationUsage:x,hasReviewBeenRun:!!I,isLoadingReview:l,isReviewing:n,generationProgress:m,autoApplySupported:F,selfReview:b})),P.length>0&&Ue.createElement(qH,null,Ue.createElement(YH,null,Ue.createElement(KH,{onClick:()=>f(!d)},Ue.createElement("span",null,d?"\u25BC":"\u25B6"),Ue.createElement("span",null,"Filtered out"),Ue.createElement(QH,null,P.length),Ue.createElement(lW,null,D.postAiValidation>0&&Ue.createElement("span",null,"\u2699\uFE0F ",D.postAiValidation),D.aiValidation>0&&Ue.createElement("span",null,"\u2726 ",D.aiValidation),D.user>0&&Ue.createElement("span",null,"\u{1F464} ",D.user))),Ue.createElement(XH,{onClick:ne},S?"\u2713 Copied!":"Copy")),d&&Ue.createElement(JH,null,(()=>{let W=P.reduce((O,U)=>{let H=sW(U.dismissReason);return O[H]||(O[H]=[]),O[H].push(U),O},{}),Ae=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(W).sort((O,U)=>Ae.indexOf(O)-Ae.indexOf(U)).map(O=>Ue.createElement(Ue.Fragment,{key:O},Ue.createElement(oW,null,O,Ue.createElement(iW,null,W[O].length)),W[O].map(U=>Ue.createElement(ZH,{key:U.id},Ue.createElement(eW,null,Ue.createElement(aW,{phase:U.dismissedBy||wx(U.dismissReason)||"post-ai-validation"},cW(U.dismissedBy,U.dismissReason)," ",NI(U.dismissedBy,U.dismissReason)),Ue.createElement(tW,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),Ue.createElement(nW,null,"[",U.severity.toUpperCase(),"] ",U.title||U.description),U.dismissReason&&Ue.createElement(rW,null,zI(U.dismissReason))))))})())))};var mW=ya.div({marginTop:"20px"}),hW=ya.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),xW=ya.div({display:"flex",alignItems:"center"}),vx=ya(io)({padding:"10px 16px"}),yW=ya.div({minHeight:"200px"}),kx=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ie(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return gW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Tr.createElement(mW,null,Tr.createElement(hW,null,Tr.createElement(xW,null,a&&Tr.createElement(vx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Tr.createElement(vx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Tr.createElement(vx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Tr.createElement(yW,null,a&&e==="chat"&&(u?Tr.createElement(VT,null):Tr.createElement(ax,null)),e==="issues"&&Tr.createElement(OI,null),a&&e==="prompt"&&Tr.createElement(sx,null)))};ve();import J,{useState as ri,useRef as Fx,useEffect as vW,useMemo as kW}from"react";import{styled as wt,useTheme as CW}from"storybook/theming";je();De();var jc={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},ba="uicopilot_feature_flags";function Cx(){try{let e=localStorage.getItem(ba);if(e){let t=JSON.parse(e);return{...jc,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return jc}function bW(e,t){try{let r={...Cx(),[e]:t},o={};for(let i in r){let s=i;r[s]!==jc[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(ba,JSON.stringify(o)):localStorage.removeItem(ba),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function SW(){try{localStorage.removeItem(ba),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function Tx(e){return Cx()[e]}function wW(){let e=Object.keys(jc).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(ba,JSON.stringify(e)),y.debug("[FeatureFlags] All features enabled! Reload to apply.")}catch(t){y.error("[FeatureFlags] Failed to enable all features:",t)}}typeof window<"u"&&(window.uicopilot={...window.uicopilot,featureFlags:{get:Cx,set:bW,reset:SW,enableAll:wW,isEnabled:Tx}});De();pt();import gn from"react";var _I=()=>gn.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},gn.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),gn.createElement("circle",{cx:"12",cy:"12",r:"3"}));var Ix={xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},Hc=()=>gn.createElement("svg",{...Ix},gn.createElement("circle",{cx:"11",cy:"11",r:"8"}),gn.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),$I=()=>gn.createElement("svg",{...Ix},gn.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),gn.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),gn.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),gn.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),gn.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),gn.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),UI=()=>gn.createElement("svg",{...Ix},gn.createElement("polyline",{points:"23 4 23 10 17 10"}),gn.createElement("polyline",{points:"1 20 1 14 7 14"}),gn.createElement("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"}));var Sa=wt.div({marginTop:"20px"}),Ex=wt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Ax=wt.div({display:"flex",alignItems:"center",gap:"12px"}),wa=wt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Rfe=wt.div({display:"flex",gap:"8px"}),zfe=wt.button(({active:e,theme:t})=>({padding:"4px 12px",backgroundColor:e?t.color.secondary:"transparent",color:e?"#fff":t.color.mediumdark,border:`1px solid ${e?t.color.secondary:t.appBorderColor}`,borderRadius:"4px",fontSize:"11px",fontWeight:500,cursor:"pointer",transition:"all 0.2s","&:hover":{opacity:.9}})),jI=wt.div(({layout:e})=>({display:e==="side-by-side"?"grid":"flex",gridTemplateColumns:e==="side-by-side"?"1fr 1fr":void 0,gap:e==="side-by-side"?"12px":0,position:"relative",width:"100%",justifyContent:e==="overlay"?"center":void 0})),Wc=wt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:e.background.app,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center"})),Vc=wt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.7)",color:e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),Px=wt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),va=wt.button(({theme:e,accent:t})=>({width:"24px",height:"24px",padding:"0",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.12)":"rgba(255, 255, 255, 0.92)",border:`1px solid ${t}55`,borderRadius:e.appBorderRadius,color:t,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s",backdropFilter:"blur(4px)","&:hover:not(:disabled)":{backgroundColor:t,color:"#ffffff",borderColor:t},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),TW=wt.img(({opacity:e=1})=>({maxWidth:"100%",maxHeight:"120px",height:"auto",display:"block",objectFit:"contain",opacity:e})),IW=wt.img({display:"block",objectFit:"contain",maxHeight:"120px",maxWidth:"100%"}),FW=wt.div({position:"relative",display:"inline-block"}),Nfe=wt.svg(({isVisible:e})=>({position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",opacity:e?1:0,transition:"opacity 150ms ease-in",...!e&&{transition:"opacity 100ms ease-out"}})),EW=wt.div({position:"relative",display:"inline-block"}),Ofe=wt.div(({width:e,height:t,theme:n})=>({position:"relative",width:e?`${e}px`:"auto",height:t?`${t}px`:"auto",border:`1px solid ${n.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:n.background.app})),AW=wt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),PW=wt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),LW=wt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),MW=wt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),BW=wt.input({flex:1}),Lx=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),_fe=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),HI=wt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),qi=wt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center","&::before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:e.base==="dark"?"linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent)":"linear-gradient(90deg, transparent, rgba(0,0,0,0.04), transparent)",animation:"shimmer 1.5s ease-in-out infinite",pointerEvents:"none"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Yi=wt.div({textAlign:"center",zIndex:1}),Ki=wt.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTop:`3px solid ${e.color.secondary}`,borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"12px","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Xi=wt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Mx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=CW(),{currentMapping:o,loadingMapping:i}=rt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:f}=ie(),{selectedProjectId:p}=Ze(),{sessionToken:g}=we(),{openComponentBrowser:S}=Rs(),{hasMapping:C,deleteMapping:F,setCurrentMapping:k}=Ho(),R=Tx("enableHoverHighlight"),[z,_]=ri("side-by-side"),[M,B]=ri(.5),[m,x]=ri(!1),[b,E]=ri(!1),[h,T]=ri(!1),I=async()=>{T(!1);try{let re=o?.id;re&&await F(re),k(null)}catch(re){y.error("[ScreenshotComparison] Failed to unlink:",re)}};vW(()=>{E(!1)},[s]);let[v,A]=ri(null),[P,D]=ri(null),N=Fx(null),w=Fx(null),j=Fx(null),G=kW(()=>{if(!R||!l||!f)return null;let re=d.find(de=>de.id===f);return re?.issues&&re.issues.find(de=>de.id===l)||null},[l,f,d]),L=re=>{let de=re.currentTarget;E(!0),!mt.getState().figmaDimensions&&de.naturalWidth&&de.naturalHeight&&mt.getState().setFigmaDimensions({width:de.naturalWidth,height:de.naturalHeight}),requestAnimationFrame(()=>{if(w.current){let{clientWidth:qe,clientHeight:tt}=w.current;qe&&tt&&D({width:qe,height:tt})}})},K=()=>{requestAnimationFrame(()=>{if(N.current){let{clientWidth:re,clientHeight:de}=N.current;re&&de&&A({width:re,height:de})}})},ee=async()=>{if(!(!p||!g)){x(!0);try{let re=q();await oe(`${re}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},credentials:"include"}),c(null),y.debug("Figma cache cleared, image will reload on next review")}catch(re){y.error("Failed to refresh Figma:",re)}finally{x(!1)}}};return e?J.createElement(Sa,null,J.createElement(Ex,null,J.createElement(Ax,null,J.createElement(wa,null,"Screenshot Comparison"))),J.createElement(HI,null,J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading Figma..."))),J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?J.createElement(Sa,null,J.createElement(Ex,null,J.createElement(Ax,null,J.createElement(wa,null,"Screenshot Comparison"))),J.createElement(HI,null,J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading..."))))):J.createElement(Sa,null,J.createElement(wa,null,"Screenshot Comparison"),J.createElement(Wc,null,J.createElement(Vc,null,"Figma Design"),J.createElement(Px,null,J.createElement(va,{accent:r.color.secondary,onClick:S,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},J.createElement(Hc,null))),J.createElement(Lx,{style:{border:"none",padding:"16px"}},"No Figma mapping."))):!s&&!a?J.createElement(Sa,null,J.createElement(wa,null,"Screenshot Comparison"),J.createElement(Lx,null,"No screenshots available. Run a review to capture Figma and Storybook screenshots.")):J.createElement(Sa,{ref:j},J.createElement(Ex,null,J.createElement(Ax,null,J.createElement(wa,null,"Screenshot Comparison"))),z==="side-by-side"?J.createElement(jI,{layout:"side-by-side"},s&&!t?J.createElement(Wc,null,J.createElement(Vc,null,"Figma Design"),J.createElement(Px,null,C&&J.createElement(va,{accent:r.color.secondary,onClick:S,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},J.createElement(Hc,null)),J.createElement(va,{accent:r.color.positive,onClick:ee,disabled:m,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},J.createElement(UI,null)),C&&J.createElement(va,{accent:r.color.negative,onClick:()=>T(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},J.createElement($I,null))),J.createElement(FW,null,J.createElement(IW,{ref:w,src:s,alt:"Figma design",onLoad:L,style:{...v?{width:v.width,height:v.height}:{maxWidth:"100%",maxHeight:"120px"},opacity:b?1:0,transition:"opacity 150ms ease-in"}}))):!o&&!i?J.createElement(Wc,null,J.createElement(Vc,null,"Figma Design"),J.createElement(Px,null,J.createElement(va,{accent:r.color.secondary,onClick:S,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},J.createElement(Hc,null))),J.createElement(Lx,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?J.createElement(Wc,null,J.createElement(Vc,null,"Storybook Component"),J.createElement(TW,{ref:N,src:a,alt:"Storybook component",onLoad:K})):J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):J.createElement(J.Fragment,null,J.createElement(jI,{layout:"overlay"},J.createElement(EW,null,s&&a?J.createElement(J.Fragment,null,J.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},J.createElement(AW,{ref:N,src:a,alt:"Storybook component",onLoad:K,style:{maxHeight:"200px"}}),v&&J.createElement(PW,{src:s,alt:"Figma design overlay",style:{opacity:M,width:v.width,height:v.height,objectFit:"fill"}})),J.createElement("div",{style:{fontSize:"10px",color:"#888",marginTop:"8px",textAlign:"center"}},J.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",J.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),v&&` \u2022 ${v.width}\xD7${v.height}px`)):J.createElement(qi,null,J.createElement(Yi,null,J.createElement(Ki,null),J.createElement(Xi,null,"Loading Images..."))))),a&&s&&J.createElement(LW,null,J.createElement(MW,null,"Figma Opacity:"),J.createElement(BW,{type:"range",min:"0",max:"1",step:"0.01",value:M,onChange:re=>B(parseFloat(re.target.value))}),J.createElement("span",null,Math.round(M*100),"%"))),J.createElement(Di,{isOpen:h,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:I,onCancel:()=>T(!1)}))};ve();pt();var DW=Qi.div({height:"100%"}),Bx=Qi.div({marginBottom:"20px"}),WI=Qi.div(({theme:e})=>({padding:"12px",backgroundColor:e.background.negative||"#fee2e2",border:`1px solid ${e.color.negative||"#fca5a5"}`,borderRadius:"6px",color:e.color.negative||"#991b1b",fontSize:"13px",marginBottom:"16px",display:"flex",alignItems:"flex-start",gap:"8px"})),VI=Qi.span({fontSize:"16px",flexShrink:0}),RW=Qi.div(({theme:e})=>({padding:"10px 12px",backgroundColor:`${e.color.warning}1a`,border:`1px solid ${e.color.warning}`,borderRadius:"6px",color:e.color.warning,fontSize:e.typography.size.s2,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px",lineHeight:1.4})),GI=Qi.div({flex:1}),Dx=()=>{let{reviewError:e,getCurrentReview:t}=ie(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Rs(),{selectedProjectId:s}=qr(),{setCurrentMapping:a}=Ho(),{currentStoryId:u,currentStoryName:c}=rt(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:f,screenshotError:p,setFigmaImageDirect:g}=Uo(),S=async C=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",C),y.debug("[ReviewPanel] frame.id:",C?.id);let F=mt.getState(),k=F.selectedProjectId,R=F.currentStoryId,z=F.currentStoryName,_=F.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",k),y.debug("[ReviewPanel] currentStoryId (from store):",R),y.debug("[ReviewPanel] currentStoryName (from store):",z),C.thumbnail&&R&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),g(R,C.id,C.thumbnail));try{let M=q(),B=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!B),y.debug("[ReviewPanel] dashboardUrl:",M),!B||!k||!R){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!B,selectedProjectId:k,currentStoryId:R});return}let m=_?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:k,storyId:R,name:z,figmaNodeId:C.id,figmaFileKey:m});let x=await oe(`${M}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${B}`},body:JSON.stringify({projectId:k,storyId:R,name:z,figmaNodeId:C.id,figmaFileKey:m})});if(x.ok){let b=await x.json();b.mapping&&(a(b.mapping),C.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),mt.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",b.mapping))}else{let b=await x.text();y.error("[ReviewPanel] Failed to save mapping:",b)}}catch(M){y.error("[ReviewPanel] Error saving mapping:",M)}};return Xt.createElement(DW,null,Xt.createElement(Bx,null,Xt.createElement(oh,null)),e&&Xt.createElement(WI,null,Xt.createElement(VI,null,"\u26A0\uFE0F"),Xt.createElement(GI,null,e)),p&&Xt.createElement(WI,null,Xt.createElement(VI,null,"\u26A0\uFE0F"),Xt.createElement(GI,null,"Screenshot loading error: ",p)),n?.variantMismatch&&Xt.createElement(RW,null,Xt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Xt.createElement("span",null,Xt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Xt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Xt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Xt.createElement(Bx,null,Xt.createElement(Mx,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:f})),Xt.createElement(Bx,null,Xt.createElement(kx,null)),Xt.createElement(Mi,{isOpen:r,onClose:o,onSelect:S,figmaFileUrl:i||"",projectId:s||void 0}))};ve();De();je();pt();import{useEffect as qI,useState as zW,useRef as Rx,useCallback as NW}from"react";var OW=q(),_W=2e3;function YI(){let{sessionToken:e,usageData:t,setUsageData:n}=we(),[r,o]=zW(null),i=Rx(null),s=Rx(!1),a=Rx(0);qI(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=NW(()=>{o(null)},[]);return qI(()=>{if(!e)return;let c=async()=>{let d=Date.now();if(s.current||d-a.current<_W){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=d;try{y.debug("[useBalanceRefresh] Refreshing balance...");let f=await oe(`${OW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(f.ok){let p=await f.json(),g=p.creditBalance,S=i.current;if(S!==null&&g>S){let C=g-S;o({message:`Credits added! +${Math.floor(C)} credit(s)`,previousBalance:S,newBalance:g}),y.debug("[useBalanceRefresh] Credits added:",C)}i.current=g,n(p),y.debug("[useBalanceRefresh] Balance updated:",g)}}catch(f){y.error("[useBalanceRefresh] Failed to refresh:",f)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}ve();ve();je();De();pt();xg();import{useEffect as $W,useRef as UW}from"react";var jW=300*1e3,KI="uicopilot_feature_flags_fetched_at";function HW(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(KI);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<jW}catch{return!1}}var zx=null,WW={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}};function XI(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ie(),{sessionToken:r,resetAuth:o}=we(),i=UW(null);$W(()=>{if(!r||r===i.current)return;if(i.current=r,HW()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(zx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${q()}/api/addon/flags`;zx=oe(s,{headers:{Authorization:`Bearer ${r}`}}).then(a=>{if(a.status===401||a.status===403)throw y.debug("[useFeatureFlags] Token rejected, resetting auth"),o(),new Error("session token invalid");if(!a.ok)throw new Error(`flags endpoint returned ${a.status}`);return a.json()}).then(a=>{y.debug("[useFeatureFlags] Received flags:",a);let u={enableFixGeneration:!!a.enableFixGeneration,enableFixApply:!!a.enableFixApply,enableAutoMap:!!a.enableAutoMap,enableReviewBadges:!!a.enableReviewBadges,showCosts:!!a.showCosts,enableParallelReview:!!a.enableParallelReview,enableModelSelection:!!a.enableModelSelection};a.role&&(t(a.role),a.role==="beta"&&nw());let c=a.role==="admin"&&n?WW[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(KI,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{zx=null})},[r,e,t])}ve();je();var qW={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},YW=fr.div`
167
167
  position: fixed;
168
168
  top: 16px;
169
169
  right: 16px;
170
- background: ${({variant:e})=>KW[e||"success"]};
170
+ background: ${({variant:e})=>qW[e||"success"]};
171
171
  color: white;
172
172
  padding: 12px 20px;
173
173
  border-radius: 8px;
@@ -181,22 +181,22 @@ ${"=".repeat(40)}
181
181
  from { transform: translateX(100%); opacity: 0; }
182
182
  to { transform: translateX(0); opacity: 1; }
183
183
  }
184
- `,QW=fr.span`font-size: 20px;`,JW=fr.span`font-weight: 500; font-size: 14px;`,ZW=fr.button`
184
+ `,KW=fr.span`font-size: 20px;`,XW=fr.span`font-weight: 500; font-size: 14px;`,QW=fr.button`
185
185
  background: rgba(255, 255, 255, 0.2);
186
186
  border: none; color: white;
187
187
  width: 24px; height: 24px; border-radius: 50%;
188
188
  cursor: pointer; display: flex; align-items: center; justify-content: center;
189
189
  font-size: 14px; margin-left: 8px;
190
190
  &:hover { background: rgba(255, 255, 255, 0.3); }
191
- `,e8=fr.div`
191
+ `,JW=fr.div`
192
192
  padding: 8px 16px;
193
193
  border-top: 1px solid ${({theme:e})=>e.appBorderColor};
194
194
  font-size: 11px;
195
195
  color: ${({theme:e})=>e.color.mediumdark};
196
196
  text-align: center;
197
197
  opacity: 0.7;
198
- `,t8=fr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),n8=fr.div({fontSize:"32px"}),r8=fr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),o8=fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),JI=fr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",margin:"8px 12px",backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}50`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s2,color:e.color.defaultText})),ZI=fr.span({flex:1}),eF=fr.button(({theme:e})=>({padding:"4px 12px",fontSize:11,fontWeight:600,border:`1px solid ${e.color.warning}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.warning,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:`${e.color.warning}15`}})),tF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Ze(),{isConnected:r,sessionToken:o,authError:i}=we(),{currentStoryId:s}=rt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ie(),[f,p]=qW(!1),g=()=>{l(null),o&&fetch(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(M=>M.json()).then(M=>{d({enableFixGeneration:!!M.enableFixGeneration,enableFixApply:!!M.enableFixApply,enableAutoMap:!!M.enableAutoMap,enableReviewBadges:!!M.enableReviewBadges,showCosts:!!M.showCosts,enableParallelReview:!!M.enableParallelReview,enableModelSelection:!!M.enableModelSelection})}).catch(()=>{})};Kg(),fm(),QI(),om(),tm();let{notification:S,dismissNotification:C}=KI();YW(()=>{if(S){let M=setTimeout(C,5e3);return()=>clearTimeout(M)}},[S,C]);let F=t.find(M=>M.id===e),k=r&&!!e&&!!F,R=!!o&&!!e&&(n||t.length===0),{loadingMapping:z}=rt(),_=k&&!!s&&!a&&z;return Mt.createElement(Qc,{header:Mt.createElement(Jc,{toolbar:Mt.createElement(bg,{onOpenSettings:()=>p(!0)})}),footer:Mt.createElement(e8,null,"UI Copilot v","0.5.3")},S&&Mt.createElement(XW,{variant:S.variant||"success"},Mt.createElement(QW,null,S.variant==="error"?"!":S.variant==="warning"?"\u26A0":"+"),Mt.createElement(JW,null,S.message),Mt.createElement(ZW,{onClick:C},"x")),i&&Mt.createElement(JI,null,Mt.createElement("span",null,"\u26A0"),Mt.createElement(ZI,null,i),Mt.createElement(eF,{onClick:()=>p(!0)},"Reconnect")),u==="admin"&&c&&Mt.createElement(JI,null,Mt.createElement("span",null,"\u{1F441}"),Mt.createElement(ZI,null,"Previewing as ",c),Mt.createElement(eF,{onClick:g},"Exit preview")),R||_?Mt.createElement(Nc,{label:R?"Loading...":"Loading review..."}):k?Mt.createElement(Mx,null):Mt.createElement(t8,null,Mt.createElement(n8,null,"\u2699"),Mt.createElement(r8,null,i?"Connection issue":"Set up UI Copilot"),Mt.createElement(o8,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),Mt.createElement(qt,{onClick:()=>p(!0)},i?"Reconnect":"Open Settings")),f&&Mt.createElement(kC,{onClose:()=>p(!1)}))};import nF,{useCallback as i8}from"react";import{useStorybookApi as s8}from"storybook/manager-api";import{IconButton as a8}from"storybook/internal/components";var l8="uireview",c8=`${l8}/panel`,rF=()=>{let e=s8(),t=i8(()=>{e.togglePanel(!0),e.setSelectedPanel(c8)},[e]);return nF.createElement(a8,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},nF.createElement(NI,null))};ve();import Vt,{useState as Ta,useCallback as aF,useEffect as Ox}from"react";import{styled as ro,useTheme as S8}from"storybook/theming";import{addons as Wc}from"storybook/manager-api";je();De();import{addons as m8,experimental_getStatusStore as Hc}from"storybook/manager-api";async function oF(e,t,n,r){let o=new Array(e.length),i=0;async function s(){for(;i<e.length&&!r();){let a=i++;try{let u=await e[a]();o[a]=u,r()||n(a,u)}catch(u){o[a]=u,r()||n(a,u)}}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),o}je();De();var u8=q(),p8="uireview/badge";async function d8(e,t,n=3){for(let r=0;r<=n;r++){let o=await fetch(e,t);if(o.status!==429||r===n)return o;let i=Math.pow(2,r)*1e3;y.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(s=>setTimeout(s,i))}throw new Error("Max retries exceeded")}async function f8(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:d,value:f}=await e.read();if(d)break;if(t()){e.cancel();break}r+=n.decode(f,{stream:!0});let p=r.split(`
199
- `);r=p.pop()||"";for(let g of p)if(g.startsWith("data: "))try{let S=JSON.parse(g.slice(6));if(S.type==="complete"){o=S.complianceScore??S.validation?.complianceScore??null;let F=(S.issues||[]).filter(k=>!k.dismissed);i=F.filter(k=>k.severity==="critical").length,s=F.filter(k=>k.severity==="major").length,a=F.filter(k=>k.severity==="minor").length,u=S.costUsd||0,c=S.inputTokens||0,l=S.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function jc(e,t,n,r,o){e&&e.set([{value:n,typeId:p8,storyId:t,title:r,description:o}])}async function g8(e){let t=window.location.origin;try{let n=await fetch(`${t}/__uicopilot/capture?storyId=${encodeURIComponent(e)}`);if(n.ok){let r=await n.json();return{screenshot:r.screenshot||void 0,computedStyles:r.computedStyles||void 0,domTree:r.domTree||void 0}}}catch{}try{let n=await fetch(`${t}/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(n.ok)return{screenshot:(await n.json()).screenshot||void 0}}catch{}return{}}async function iF(e,t,n,r,o,i){jc(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await g8(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await d8(`${u8}/api/review/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({projectId:n,storyId:e.storyId,storyName:e.storyName,storybookScreenshot:s.screenshot,computedStyles:s.computedStyles,domTree:s.domTree,aiModels:[r]})});if(console.warn(`[reviewAll] API response for ${e.storyName}: HTTP ${a.status}`),!a.ok)throw new Error(`HTTP ${a.status}`);let u=a.body?.getReader();if(!u)throw new Error("No response body");let c=await f8(u,i),{score:l,criticalCount:d,majorCount:f,minorCount:p,costUsd:g,inputTokens:S,outputTokens:C}=c;if(l!==null){let F=d>0||l<70?"status-value:error":f>0||l<90?"status-value:warning":"status-value:success",k=[`Score: ${l}`];d>0&&k.push(`${d} critical`),f>0&&k.push(`${f} major`),p>0&&k.push(`${p} minor`);let R=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return jc(o,e.storyId,F,R,k.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:g,inputTokens:S,outputTokens:C}}return jc(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){y.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return jc(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var h8=q(),va="uireview/badge";function sF(){let e=!1,t=!1;try{let n=m8.getChannel();n.on(zx,async()=>{if(!t){t=!0,e=!1;try{await b8(n,()=>e)}finally{t=!1}}}),n.on(Nx,()=>{e=!0})}catch{}}async function Rx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${h8}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(!n.ok)return[];let i=((await n.json()).mappings||[]).filter(s=>s.figmaNodeId).map(s=>{let a=s;return{storyId:a.storyId,storyName:a.name||a.storyId,figmaNodeId:a.figmaNodeId}});return x8(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function x8(e){try{if(typeof Hc!="function")return;let t=Hc(va);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[va]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[va];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:va,storyId:s.storyId,title:"Mapped to Figma",description:"Ready for UI review \u2014 click Run to start"}));i.length>0&&t.set(i)}catch{}}function y8(){try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3}async function b8(e,t){let n=await Rx();if(n.length===0){e.emit(Ca,{total:0,passed:0,failed:0});return}let r=localStorage.getItem("uicopilot_session_token"),o=localStorage.getItem("uicopilot_selected_project_id");if(!r||!o)return;let i="claude-sonnet-4-5-20250929";try{let S=localStorage.getItem("uicopilot_selected_models");if(S){let C=JSON.parse(S);Array.isArray(C)&&C.length>0&&(i=C[0])}}catch{}let s=null;try{typeof Hc=="function"&&(s=Hc(va))}catch{}let a=y8(),u=0,c=0,l=0,d=0,f=0,p=0;e.emit(ka,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let g=n.map(S=>()=>iF(S,r,o,i,s,t));await oF(g,a,(S,C)=>{if(C&&typeof C=="object"&&"score"in C){let F=C;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,d+=F.costUsd||0,f+=F.inputTokens||0,p+=F.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${S+1}/${n.length} done:`,n[S].storyName,C),e.emit(ka,{total:n.length,completed:u+c+l,currentStoryName:n[S].storyName})},t),e.emit(Ca,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:f,outputTokens:p})}var w8=ro.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),v8=ro.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),k8=ro.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),lF=ro.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),cF=ro.button(({theme:e,running:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",background:t?e.color.warning:e.color.secondary,border:"none",borderRadius:"6px",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,transition:"all 0.2s","&:disabled":{opacity:.4,cursor:"not-allowed"},"&:hover:not(:disabled)":{opacity:.9}})),C8=ro.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),T8=ro.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),uF=ro.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Ji=ro.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),zx="uireview/review-all-start",Nx="uireview/review-all-cancel",ka="uireview/review-all-progress",Ca="uireview/review-all-complete";function pF(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var dF=()=>{let[e,t]=Ta(!1),[n,r]=Ta(null),[o,i]=Ta(null),[s,a]=Ta(null),[u,c]=Ta(pF);Ox(()=>{let g=()=>c(pF()),S=setInterval(g,2e3);return window.addEventListener("storage",g),()=>{clearInterval(S),window.removeEventListener("storage",g)}},[]),Ox(()=>{let g=()=>{Rx().then(k=>{a(k.length)}).catch(()=>{})},S=setTimeout(g,3e3),C=null;try{C=Wc.getChannel(),C.on("storyChanged",g),C.on("uireview/mappings-changed",g)}catch{}let F=setInterval(g,6e4);return()=>{clearTimeout(S),clearInterval(F),C&&(C.off("storyChanged",g),C.off("uireview/mappings-changed",g))}},[]),Ox(()=>{let g;try{g=Wc.getChannel()}catch{return}let S=F=>{r(F),t(!0)},C=F=>{t(!1),r(null),i({total:F.total,passed:F.passed,failed:F.failed,warned:F.warnCount||0,costUsd:F.costUsd||0})};return g.on(ka,S),g.on(Ca,C),()=>{g.off(ka,S),g.off(Ca,C)}},[]);let l=aF(()=>{try{Wc.getChannel().emit(zx),t(!0),i(null)}catch{}},[]),d=aF(()=>{try{Wc.getChannel().emit(Nx)}catch{}t(!1),r(null)},[]),f=n?Math.round(n.completed/n.total*100):0,p=S8();return u?Vt.createElement(w8,null,Vt.createElement(v8,null,Vt.createElement(k8,null,"UI Review"),e?Vt.createElement(cF,{running:!0,onClick:d},"Cancel"):Vt.createElement(cF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Vt.createElement(Vt.Fragment,null,Vt.createElement(uF,null,Vt.createElement(Ji,{dotColor:p.color.positive},"Pass (",o.passed,")"),Vt.createElement(Ji,{dotColor:p.color.warning},"Warn (",o.warned,")"),Vt.createElement(Ji,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Vt.createElement(lF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Vt.createElement(uF,null,Vt.createElement(Ji,{dotColor:p.color.positive},"Pass"),Vt.createElement(Ji,{dotColor:p.color.warning},"Warn"),Vt.createElement(Ji,{dotColor:p.color.negative},"Fail")),e&&n&&Vt.createElement(Vt.Fragment,null,Vt.createElement(C8,null,Vt.createElement(T8,{percent:f})),Vt.createElement(lF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as gF from"@sentry/react";var I8="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",fF=!1;function F8(){if(typeof window>"u")return"production";let e=window.location.hostname;return/^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(e)?"localhost":"production"}function mF(){if(!fF){fF=!0;try{gF.init({dsn:I8,environment:F8(),release:`uicopilot-addon@${process.env.npm_package_version||"unknown"}`,tracesSampleRate:0,enabled:!0,beforeSend(e){return e.tags={...e.tags,component:"storybook-addon"},e}})}catch{}}}mF();var Gc="uireview",A8=`${Gc}/panel`,P8=`${Gc}/tool`,xF=`${Gc}/test-provider`;Vc.register(Gc,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof hF=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=hF("uireview/badge");cv(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");Vc.add(P8,{type:_x.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Ia.createElement(rF,null)}),sF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&Vc.add(xF,{type:_x.experimental_TEST_PROVIDER,id:xF,render:()=>Ia.createElement(dF,null)}),Vc.add(A8,{type:_x.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Ia.createElement(E8,{active:t||!1},Ia.createElement(yg,null,Ia.createElement(tF,null)))})});
198
+ `,ZW=fr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),e8=fr.div({fontSize:"32px"}),t8=fr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),n8=fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),QI=fr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",margin:"8px 12px",backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}50`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s2,color:e.color.defaultText})),JI=fr.span({flex:1}),ZI=fr.button(({theme:e})=>({padding:"4px 12px",fontSize:11,fontWeight:600,border:`1px solid ${e.color.warning}`,borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.warning,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:`${e.color.warning}15`}})),eF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Ze(),{isConnected:r,sessionToken:o,authError:i}=we(),{currentStoryId:s}=rt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ie(),[f,p]=VW(!1),g=()=>{l(null),o&&fetch(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(M=>M.json()).then(M=>{d({enableFixGeneration:!!M.enableFixGeneration,enableFixApply:!!M.enableFixApply,enableAutoMap:!!M.enableAutoMap,enableReviewBadges:!!M.enableReviewBadges,showCosts:!!M.showCosts,enableParallelReview:!!M.enableParallelReview,enableModelSelection:!!M.enableModelSelection})}).catch(()=>{})};Zg(),xm(),XI(),lm(),im();let{notification:S,dismissNotification:C}=YI();GW(()=>{if(S){let M=setTimeout(C,5e3);return()=>clearTimeout(M)}},[S,C]);let F=t.find(M=>M.id===e),k=r&&!!e&&!!F,R=!!o&&!!e&&(n||t.length===0),{loadingMapping:z}=rt(),_=k&&!!s&&!a&&z;return Mt.createElement(tu,{header:Mt.createElement(nu,{toolbar:Mt.createElement(kg,{onOpenSettings:()=>p(!0)})}),footer:Mt.createElement(JW,null,"UI Copilot v","0.5.5")},S&&Mt.createElement(YW,{variant:S.variant||"success"},Mt.createElement(KW,null,S.variant==="error"?"!":S.variant==="warning"?"\u26A0":"+"),Mt.createElement(XW,null,S.message),Mt.createElement(QW,{onClick:C},"x")),i&&Mt.createElement(QI,null,Mt.createElement("span",null,"\u26A0"),Mt.createElement(JI,null,i),Mt.createElement(ZI,{onClick:()=>p(!0)},"Reconnect")),u==="admin"&&c&&Mt.createElement(QI,null,Mt.createElement("span",null,"\u{1F441}"),Mt.createElement(JI,null,"Previewing as ",c),Mt.createElement(ZI,{onClick:g},"Exit preview")),R||_?Mt.createElement(Oc,{label:R?"Loading...":"Loading review..."}):k?Mt.createElement(Dx,null):Mt.createElement(ZW,null,Mt.createElement(e8,null,"\u2699"),Mt.createElement(t8,null,i?"Connection issue":"Set up UI Copilot"),Mt.createElement(n8,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),Mt.createElement(en,{onClick:()=>p(!0)},i?"Reconnect":"Open Settings")),f&&Mt.createElement(TC,{onClose:()=>p(!1)}))};import tF,{useCallback as r8}from"react";import{useStorybookApi as o8}from"storybook/manager-api";import{IconButton as i8}from"storybook/internal/components";var s8="uireview",a8=`${s8}/panel`,nF=()=>{let e=o8(),t=r8(()=>{e.togglePanel(!0),e.setSelectedPanel(a8)},[e]);return tF.createElement(i8,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},tF.createElement(_I,null))};ve();import Vt,{useState as Ia,useCallback as sF,useEffect as $x}from"react";import{styled as ro,useTheme as y8}from"storybook/theming";import{addons as Yc}from"storybook/manager-api";je();De();import{addons as f8,experimental_getStatusStore as qc}from"storybook/manager-api";async function rF(e,t,n,r){let o=new Array(e.length),i=0;async function s(){for(;i<e.length&&!r();){let a=i++;try{let u=await e[a]();o[a]=u,r()||n(a,u)}catch(u){o[a]=u,r()||n(a,u)}}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),o}je();De();var l8=q(),c8="uireview/badge";async function u8(e,t,n=3){for(let r=0;r<=n;r++){let o=await fetch(e,t);if(o.status!==429||r===n)return o;let i=Math.pow(2,r)*1e3;y.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(s=>setTimeout(s,i))}throw new Error("Max retries exceeded")}async function p8(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:d,value:f}=await e.read();if(d)break;if(t()){e.cancel();break}r+=n.decode(f,{stream:!0});let p=r.split(`
199
+ `);r=p.pop()||"";for(let g of p)if(g.startsWith("data: "))try{let S=JSON.parse(g.slice(6));if(S.type==="complete"){o=S.complianceScore??S.validation?.complianceScore??null;let F=(S.issues||[]).filter(k=>!k.dismissed);i=F.filter(k=>k.severity==="critical").length,s=F.filter(k=>k.severity==="major").length,a=F.filter(k=>k.severity==="minor").length,u=S.costUsd||0,c=S.inputTokens||0,l=S.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function Gc(e,t,n,r,o){e&&e.set([{value:n,typeId:c8,storyId:t,title:r,description:o}])}async function d8(e){let t=window.location.origin;try{let n=await fetch(`${t}/__uicopilot/capture?storyId=${encodeURIComponent(e)}`);if(n.ok){let r=await n.json();return{screenshot:r.screenshot||void 0,computedStyles:r.computedStyles||void 0,domTree:r.domTree||void 0}}}catch{}try{let n=await fetch(`${t}/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(n.ok)return{screenshot:(await n.json()).screenshot||void 0}}catch{}return{}}async function oF(e,t,n,r,o,i){Gc(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await d8(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await u8(`${l8}/api/review/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({projectId:n,storyId:e.storyId,storyName:e.storyName,storybookScreenshot:s.screenshot,computedStyles:s.computedStyles,domTree:s.domTree,aiModels:[r]})});if(console.warn(`[reviewAll] API response for ${e.storyName}: HTTP ${a.status}`),!a.ok)throw new Error(`HTTP ${a.status}`);let u=a.body?.getReader();if(!u)throw new Error("No response body");let c=await p8(u,i),{score:l,criticalCount:d,majorCount:f,minorCount:p,costUsd:g,inputTokens:S,outputTokens:C}=c;if(l!==null){let F=d>0||l<70?"status-value:error":f>0||l<90?"status-value:warning":"status-value:success",k=[`Score: ${l}`];d>0&&k.push(`${d} critical`),f>0&&k.push(`${f} major`),p>0&&k.push(`${p} minor`);let R=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return Gc(o,e.storyId,F,R,k.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:g,inputTokens:S,outputTokens:C}}return Gc(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){y.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return Gc(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var g8=q(),ka="uireview/badge";function iF(){let e=!1,t=!1;try{let n=f8.getChannel();n.on(Ox,async()=>{if(!t){t=!0,e=!1;try{await x8(n,()=>e)}finally{t=!1}}}),n.on(_x,()=>{e=!0})}catch{}}async function Nx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${g8}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(!n.ok)return[];let i=((await n.json()).mappings||[]).filter(s=>s.figmaNodeId).map(s=>{let a=s;return{storyId:a.storyId,storyName:a.name||a.storyId,figmaNodeId:a.figmaNodeId}});return m8(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function m8(e){try{if(typeof qc!="function")return;let t=qc(ka);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[ka]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[ka];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:ka,storyId:s.storyId,title:"Mapped to Figma",description:"Ready for UI review \u2014 click Run to start"}));i.length>0&&t.set(i)}catch{}}function h8(){try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3}async function x8(e,t){let n=await Nx();if(n.length===0){e.emit(Ta,{total:0,passed:0,failed:0});return}let r=localStorage.getItem("uicopilot_session_token"),o=localStorage.getItem("uicopilot_selected_project_id");if(!r||!o)return;let i="claude-sonnet-4-5-20250929";try{let S=localStorage.getItem("uicopilot_selected_models");if(S){let C=JSON.parse(S);Array.isArray(C)&&C.length>0&&(i=C[0])}}catch{}let s=null;try{typeof qc=="function"&&(s=qc(ka))}catch{}let a=h8(),u=0,c=0,l=0,d=0,f=0,p=0;e.emit(Ca,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let g=n.map(S=>()=>oF(S,r,o,i,s,t));await rF(g,a,(S,C)=>{if(C&&typeof C=="object"&&"score"in C){let F=C;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,d+=F.costUsd||0,f+=F.inputTokens||0,p+=F.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${S+1}/${n.length} done:`,n[S].storyName,C),e.emit(Ca,{total:n.length,completed:u+c+l,currentStoryName:n[S].storyName})},t),e.emit(Ta,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:f,outputTokens:p})}var b8=ro.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),S8=ro.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),w8=ro.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),aF=ro.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),lF=ro.button(({theme:e,running:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",background:t?e.color.warning:e.color.secondary,border:"none",borderRadius:"6px",color:e.color.inverseText,cursor:"pointer",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,transition:"all 0.2s","&:disabled":{opacity:.4,cursor:"not-allowed"},"&:hover:not(:disabled)":{opacity:.9}})),v8=ro.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),k8=ro.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),cF=ro.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Ji=ro.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Ox="uireview/review-all-start",_x="uireview/review-all-cancel",Ca="uireview/review-all-progress",Ta="uireview/review-all-complete";function uF(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var pF=()=>{let[e,t]=Ia(!1),[n,r]=Ia(null),[o,i]=Ia(null),[s,a]=Ia(null),[u,c]=Ia(uF);$x(()=>{let g=()=>c(uF()),S=setInterval(g,2e3);return window.addEventListener("storage",g),()=>{clearInterval(S),window.removeEventListener("storage",g)}},[]),$x(()=>{let g=()=>{Nx().then(k=>{a(k.length)}).catch(()=>{})},S=setTimeout(g,3e3),C=null;try{C=Yc.getChannel(),C.on("storyChanged",g),C.on("uireview/mappings-changed",g)}catch{}let F=setInterval(g,6e4);return()=>{clearTimeout(S),clearInterval(F),C&&(C.off("storyChanged",g),C.off("uireview/mappings-changed",g))}},[]),$x(()=>{let g;try{g=Yc.getChannel()}catch{return}let S=F=>{r(F),t(!0)},C=F=>{t(!1),r(null),i({total:F.total,passed:F.passed,failed:F.failed,warned:F.warnCount||0,costUsd:F.costUsd||0})};return g.on(Ca,S),g.on(Ta,C),()=>{g.off(Ca,S),g.off(Ta,C)}},[]);let l=sF(()=>{try{Yc.getChannel().emit(Ox),t(!0),i(null)}catch{}},[]),d=sF(()=>{try{Yc.getChannel().emit(_x)}catch{}t(!1),r(null)},[]),f=n?Math.round(n.completed/n.total*100):0,p=y8();return u?Vt.createElement(b8,null,Vt.createElement(S8,null,Vt.createElement(w8,null,"UI Review"),e?Vt.createElement(lF,{running:!0,onClick:d},"Cancel"):Vt.createElement(lF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Vt.createElement(Vt.Fragment,null,Vt.createElement(cF,null,Vt.createElement(Ji,{dotColor:p.color.positive},"Pass (",o.passed,")"),Vt.createElement(Ji,{dotColor:p.color.warning},"Warn (",o.warned,")"),Vt.createElement(Ji,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Vt.createElement(aF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Vt.createElement(cF,null,Vt.createElement(Ji,{dotColor:p.color.positive},"Pass"),Vt.createElement(Ji,{dotColor:p.color.warning},"Warn"),Vt.createElement(Ji,{dotColor:p.color.negative},"Fail")),e&&n&&Vt.createElement(Vt.Fragment,null,Vt.createElement(v8,null,Vt.createElement(k8,{percent:f})),Vt.createElement(aF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as fF from"@sentry/react";var C8="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",dF=!1;function T8(){if(typeof window>"u")return"production";let e=window.location.hostname;return/^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(e)?"localhost":"production"}function gF(){if(!dF){dF=!0;try{fF.init({dsn:C8,environment:T8(),release:`uicopilot-addon@${process.env.npm_package_version||"unknown"}`,tracesSampleRate:0,enabled:!0,beforeSend(e){return e.tags={...e.tags,component:"storybook-addon"},e}})}catch{}}}gF();var Xc="uireview",F8=`${Xc}/panel`,E8=`${Xc}/tool`,hF=`${Xc}/test-provider`;Kc.register(Xc,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof mF=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=mF("uireview/badge");pv(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");Kc.add(E8,{type:Ux.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Fa.createElement(nF,null)}),iF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&Kc.add(hF,{type:Ux.experimental_TEST_PROVIDER,id:hF,render:()=>Fa.createElement(pF,null)}),Kc.add(F8,{type:Ux.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Fa.createElement(I8,{active:t||!1},Fa.createElement(vg,null,Fa.createElement(eF,null)))})});
200
200
  /*! Bundled license information:
201
201
 
202
202
  @noble/hashes/utils.js: