@uicopilot/storybook-addon 0.5.39 → 0.5.40

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 +56 -56
  2. package/package.json +1 -1
package/dist/manager.mjs CHANGED
@@ -1,36 +1,36 @@
1
- var gE=Object.create;var Za=Object.defineProperty;var fE=Object.getOwnPropertyDescriptor;var mE=Object.getOwnPropertyNames;var hE=Object.getPrototypeOf,xE=Object.prototype.hasOwnProperty;var yE=(e,t,n)=>t in e?Za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t)=>()=>(e&&(t=e(e=0)),t);var ir=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ye=(e,t)=>{for(var n in t)Za(e,n,{get:t[n],enumerable:!0})},bE=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mE(t))!xE.call(e,o)&&o!==n&&Za(e,o,{get:()=>t[o],enumerable:!(r=fE(t,o))||r.enumerable});return e};var el=(e,t,n)=>(n=e!=null?gE(hE(e)):{},bE(t||!e||!e.__esModule?Za(n,"default",{value:e,enumerable:!0}):n,e));var sr=(e,t,n)=>yE(e,typeof t!="symbol"?t+"":t,n);function Fy(){try{return typeof window<"u"&&localStorage.getItem(kE)==="true"}catch{return!1}}var kE,y,Ne=U(()=>{"use strict";kE="uicopilot:debug";y={debug:(...e)=>{Fy()&&console.log(...e)},info:(...e)=>{Fy()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import CE,{createContext as TE,useContext as IE,useReducer as FE,useMemo as Ey}from"react";function EE(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)),typeof localStorage<"u"&&localStorage.setItem("uicopilot_force_sign_in","true"),y.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function Lu({children:e}){let[t,n]=FE(EE,ME),r=Ey(()=>({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,...i?{authError:null}:{}}})},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=Ey(()=>({...t,...r}),[t,r]);return CE.createElement(Py.Provider,{value:o},e)}function Se(){let e=IE(Py);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var AE,PE,LE,Ay,ME,Py,Mu=U(()=>{"use strict";Ne();AE=()=>{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"))};AE();PE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),LE=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",Ay=PE(),ME={isConnected:!!Ay,sessionToken:Ay,apiKey:LE(),authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},Py=TE(null)});import BE,{createContext as DE,useContext as RE,useReducer as zE,useMemo as Ly,useRef as NE,useEffect as OE}from"react";function _E(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 Bu({children:e}){let[t,n]=zE(_E,UE),r=NE(t);OE(()=>{r.current=t},[t]);let o=Ly(()=>({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=Ly(()=>({...t,...o}),[t,o]);return BE.createElement(My.Provider,{value:i},e)}function Xe(){let e=RE(My);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var $E,UE,My,Du=U(()=>{"use strict";$E=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),UE={projects:[],selectedProjectId:$E(),loadingProjects:!1,currentStorybookPath:null},My=DE(null)});import jE,{createContext as HE,useContext as WE,useReducer as VE,useMemo as By}from"react";function GE(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>Dy)for(let o of r.slice(0,r.length-Dy))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]=VE(GE,qE),r=By(()=>({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}})},setMappingsByStoryId:i=>n({type:"SET_STATE",payload:{mappingsByStoryId: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=By(()=>({...t,...r}),[t,r]);return jE.createElement(Ry.Provider,{value:o},e)}function Ze(){let e=WE(Ry);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var Dy,qE,Ry,zu=U(()=>{"use strict";Dy=200;qE={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,mappingsByStoryId:{},reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},Ry=HE(null)});var Et,Nu=U(()=>{"use strict";Et={NAME:"UI Parity",SHORT:"Parity",DOMAIN:"uiparity.com",MARKETING_URL:"https://uiparity.com",APP_URL:"https://app.uiparity.com",API_URL:"https://api.uiparity.com",SUPPORT_EMAIL:"feedback@uiparity.com",TAGLINE:"Pixel-perfect isn't a feeling. It's a score."}});function YE(){if(typeof process<"u"&&process.env)return process.env.UICOPILOT_DEBUG==="1";if(typeof globalThis<"u"&&"localStorage"in globalThis)try{return globalThis.localStorage.getItem("uicopilot_debug")==="1"}catch{return!1}return!1}var ol,Ou,zy=U(()=>{"use strict";Nu();ol=`[${Et.NAME}]`,Ou={debug:(...e)=>{YE()&&console.log(ol,...e)},info:(...e)=>{console.log(ol,...e)},warn:(...e)=>{console.warn(ol,...e)},error:(...e)=>{console.error(ol,...e)}}});var Ny=U(()=>{"use strict"});var _u=U(()=>{"use strict"});function Ht(e){return e>=48&&e<=57}function Nn(e){return Ht(e)||e>=65&&e<=70||e>=97&&e<=102}function sl(e){return e>=65&&e<=90}function XE(e){return e>=97&&e<=122}function QE(e){return sl(e)||XE(e)}function JE(e){return e>=128}function il(e){return QE(e)||JE(e)||e===95}function al(e){return il(e)||Ht(e)||e===45}function ZE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function ys(e){return e===10||e===13||e===12}function _r(e){return ys(e)||e===32||e===9}function zn(e,t){return!(e!==92||ys(t)||t===0)}function vi(e,t,n){return e===45?il(t)||t===45||zn(t,n):il(e)?!0:e===92?zn(e,t):!1}function ll(e,t,n){return e===43||e===45?Ht(t)?2:t===46&&Ht(n)?3:0:e===46?Ht(t)?2:0:Ht(e)?1:0}function cl(e){return e===65279||e===65534?1:0}function pl(e){return e<128?$u[e]:ul}var $u,eA,bs,Uu,ul,ju,Ss=U(()=>{"use strict";$u=new Array(128),eA=128,bs=130,Uu=131,ul=132,ju=133;for(let e=0;e<$u.length;e++)$u[e]=_r(e)&&bs||Ht(e)&&Uu||il(e)&&ul||ZE(e)&&ju||e||eA});function ki(e,t){return t<e.length?e.charCodeAt(t):0}function dl(e,t,n){return n===13&&ki(e,t+1)===10?2:1}function Qr(e,t,n){let r=e.charCodeAt(t);return sl(r)&&(r=r|32),r===n}function Jr(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(sl(s)&&(s=s|32),s!==i)return!1}return!0}function Oy(e,t){for(;t>=0&&_r(e.charCodeAt(t));t--);return t+1}function ws(e,t){for(;t<e.length&&_r(e.charCodeAt(t));t++);return t}function Hu(e,t){for(;t<e.length&&Ht(e.charCodeAt(t));t++);return t}function Zr(e,t){if(t+=2,Nn(ki(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Nn(ki(e,t));t++);let n=ki(e,t);_r(n)&&(t+=dl(e,t,n))}return t}function vs(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!al(n)){if(zn(n,ki(e,t+1))){t=Zr(e,t)-1;continue}break}}return t}function Qo(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),Ht(n)&&(t=Hu(e,t+1),n=e.charCodeAt(t)),n===46&&Ht(e.charCodeAt(t+1))&&(t+=2,t=Hu(e,t)),Qr(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),Ht(n)&&(t=Hu(e,t+1+r+1))}return t}function gl(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}zn(n,ki(e,t+1))&&(t=Zr(e,t))}return t}function fl(e){if(e.length===1&&!Nn(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 ml=U(()=>{"use strict";Ss()});var Ci,Wu=U(()=>{"use strict";Ci=["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 Ti(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Vu=U(()=>{"use strict"});function Uy(e){let t=e.source,n=t.length,r=t.length>0?cl(t.charCodeAt(0)):0,o=Ti(e.lines,n),i=Ti(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===_y||c===$y||c===tA)&&(c===$y&&u+1<n&&t.charCodeAt(u+1)===_y&&(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 _y,tA,$y,hl,jy=U(()=>{"use strict";Vu();Ss();_y=10,tA=12,$y=13;hl=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 Hy(e,t,n){return e<t?t:e>n?n:e}var vr,kr,ks,yl,Io,Cr,xl,Wy=U(()=>{"use strict";Vu();ml();Wu();vr=16777215,kr=24,ks=1,yl=2,Io=new Uint8Array(32);Io[2]=22;Io[21]=22;Io[19]=20;Io[23]=24;Cr=new Uint8Array(32);Cr[2]=ks;Cr[21]=ks;Cr[19]=ks;Cr[23]=ks;Cr[22]=yl;Cr[20]=yl;Cr[24]=yl;xl=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=Ti(this.offsetAndType,t.length+1),i=Ti(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,g)=>{let p=s++;if(o[p]=l<<kr|g,a===-1&&(a=d),i[p]=c,l===u){let m=i[c];i[c]=p,c=m,u=Io[o[m]>>kr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=Io[l])}),o[s]=0<<kr|r,i[s]=s;for(let l=0;l<s;l++){let d=i[l];if(d<=l){let g=i[d];g!==l&&(i[l]=g)}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]>>kr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>kr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&vr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>kr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?Jr(this.source,this.offsetAndType[t-1]&vr,this.offsetAndType[t]&vr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&vr:this.offsetAndType[this.tokenCount]&vr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[Hy(t,0,this.tokenCount)]&vr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[Hy(t,0,this.tokenCount)]>>kr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return Cr[t]===ks}isBlockCloserTokenType(t){return Cr[t]===yl}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(Cr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return Io[n]===o?r:-1}else if(Cr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return Io[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]&vr,n=this.offsetAndType[n],this.tokenType=n>>kr,this.tokenEnd=n&vr):(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>>kr,this.tokenEnd=t&vr):(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]&vr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>kr)&&(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&vr,a=i>>kr;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:Ci[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function Fo(e,t){function n(d){return d<a?e.charCodeAt(d):0}function r(){if(c=Qo(e,c),vi(n(c),n(c+1),n(c+2))){l=12,c=vs(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=vs(e,c),Jr(e,d,c,"url")&&n(c)===40){if(c=ws(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 g=e.charCodeAt(c);switch(pl(g)){case d:c++;return;case bs:if(ys(g)){c+=dl(e,c,g),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);ys(p)?c+=dl(e,c+1,p):zn(g,p)&&(c=Zr(e,c)-1);break}}}function s(){for(l=7,c=ws(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch(pl(d)){case 41:c++;return;case bs:if(c=ws(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=gl(e,c),l=8;return;case 34:case 39:case 40:case ju:c=gl(e,c),l=8;return;case 92:if(zn(d,n(c+1))){c=Zr(e,c)-1;break}c=gl(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=cl(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch(pl(d)){case bs:l=13,c=ws(e,c+1);break;case 34:i();break;case 35:al(n(c+1))||zn(n(c+1),n(c+2))?(l=4,c=vs(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:ll(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:ll(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):vi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:ll(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:vi(n(c+1),n(c+2),n(c+3))?(l=3,c=vs(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:zn(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 Uu:r();break;case ul:o();break;default:l=9,c++}t(l,u,u=c)}}var lr=U(()=>{"use strict";Ss();ml();_u();_u();Wu();Ss();ml();jy();Wy()});var Ii,Zn,Ts=U(()=>{"use strict";Ii=null,Zn=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 Ii!==null?(r=Ii,Ii=Ii.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=Ii,Ii=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 Sl=U(()=>{"use strict"});function qy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(m,b){return c.slice(m,b).map((T,F)=>String(m+F+1).padStart(g)+" |"+T).join(`
1
+ var gE=Object.create;var el=Object.defineProperty;var fE=Object.getOwnPropertyDescriptor;var mE=Object.getOwnPropertyNames;var hE=Object.getPrototypeOf,xE=Object.prototype.hasOwnProperty;var yE=(e,t,n)=>t in e?el(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t)=>()=>(e&&(t=e(e=0)),t);var ir=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ye=(e,t)=>{for(var n in t)el(e,n,{get:t[n],enumerable:!0})},bE=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mE(t))!xE.call(e,o)&&o!==n&&el(e,o,{get:()=>t[o],enumerable:!(r=fE(t,o))||r.enumerable});return e};var tl=(e,t,n)=>(n=e!=null?gE(hE(e)):{},bE(t||!e||!e.__esModule?el(n,"default",{value:e,enumerable:!0}):n,e));var sr=(e,t,n)=>yE(e,typeof t!="symbol"?t+"":t,n);function Fy(){try{return typeof window<"u"&&localStorage.getItem(kE)==="true"}catch{return!1}}var kE,y,Ne=U(()=>{"use strict";kE="uicopilot:debug";y={debug:(...e)=>{Fy()&&console.log(...e)},info:(...e)=>{Fy()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import CE,{createContext as TE,useContext as IE,useReducer as FE,useMemo as Ey}from"react";function EE(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)),typeof localStorage<"u"&&localStorage.setItem("uicopilot_force_sign_in","true"),y.debug("[AuthContext] resetAuth: Cleared uicopilot_* localStorage + sessionStorage keys"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function Lu({children:e}){let[t,n]=FE(EE,ME),r=Ey(()=>({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,...i?{authError:null}:{}}})},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=Ey(()=>({...t,...r}),[t,r]);return CE.createElement(Py.Provider,{value:o},e)}function Se(){let e=IE(Py);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var AE,PE,LE,Ay,ME,Py,Mu=U(()=>{"use strict";Ne();AE=()=>{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"))};AE();PE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),LE=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",Ay=PE(),ME={isConnected:!!Ay,sessionToken:Ay,apiKey:LE(),authMethod:"apikey",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},Py=TE(null)});import BE,{createContext as DE,useContext as RE,useReducer as zE,useMemo as Ly,useRef as NE,useEffect as OE}from"react";function _E(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 Bu({children:e}){let[t,n]=zE(_E,UE),r=NE(t);OE(()=>{r.current=t},[t]);let o=Ly(()=>({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=Ly(()=>({...t,...o}),[t,o]);return BE.createElement(My.Provider,{value:i},e)}function Xe(){let e=RE(My);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var $E,UE,My,Du=U(()=>{"use strict";$E=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),UE={projects:[],selectedProjectId:$E(),loadingProjects:!1,currentStorybookPath:null},My=DE(null)});import jE,{createContext as HE,useContext as WE,useReducer as VE,useMemo as By}from"react";function GE(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>Dy)for(let o of r.slice(0,r.length-Dy))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]=VE(GE,qE),r=By(()=>({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}})},setMappingsByStoryId:i=>n({type:"SET_STATE",payload:{mappingsByStoryId: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=By(()=>({...t,...r}),[t,r]);return jE.createElement(Ry.Provider,{value:o},e)}function Ze(){let e=WE(Ry);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var Dy,qE,Ry,zu=U(()=>{"use strict";Dy=200;qE={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,mappingsByStoryId:{},reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},Ry=HE(null)});var Et,Nu=U(()=>{"use strict";Et={NAME:"UI Parity",SHORT:"Parity",DOMAIN:"uiparity.com",MARKETING_URL:"https://uiparity.com",APP_URL:"https://app.uiparity.com",API_URL:"https://api.uiparity.com",SUPPORT_EMAIL:"feedback@uiparity.com",TAGLINE:"Pixel-perfect isn't a feeling. It's a score."}});function YE(){if(typeof process<"u"&&process.env)return process.env.UICOPILOT_DEBUG==="1";if(typeof globalThis<"u"&&"localStorage"in globalThis)try{return globalThis.localStorage.getItem("uicopilot_debug")==="1"}catch{return!1}return!1}var il,Ou,zy=U(()=>{"use strict";Nu();il=`[${Et.NAME}]`,Ou={debug:(...e)=>{YE()&&console.log(il,...e)},info:(...e)=>{console.log(il,...e)},warn:(...e)=>{console.warn(il,...e)},error:(...e)=>{console.error(il,...e)}}});var Ny=U(()=>{"use strict"});var _u=U(()=>{"use strict"});function Ht(e){return e>=48&&e<=57}function On(e){return Ht(e)||e>=65&&e<=70||e>=97&&e<=102}function al(e){return e>=65&&e<=90}function XE(e){return e>=97&&e<=122}function QE(e){return al(e)||XE(e)}function JE(e){return e>=128}function sl(e){return QE(e)||JE(e)||e===95}function ll(e){return sl(e)||Ht(e)||e===45}function ZE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function Ss(e){return e===10||e===13||e===12}function _r(e){return Ss(e)||e===32||e===9}function Nn(e,t){return!(e!==92||Ss(t)||t===0)}function vi(e,t,n){return e===45?sl(t)||t===45||Nn(t,n):sl(e)?!0:e===92?Nn(e,t):!1}function cl(e,t,n){return e===43||e===45?Ht(t)?2:t===46&&Ht(n)?3:0:e===46?Ht(t)?2:0:Ht(e)?1:0}function ul(e){return e===65279||e===65534?1:0}function dl(e){return e<128?$u[e]:pl}var $u,eA,ws,Uu,pl,ju,vs=U(()=>{"use strict";$u=new Array(128),eA=128,ws=130,Uu=131,pl=132,ju=133;for(let e=0;e<$u.length;e++)$u[e]=_r(e)&&ws||Ht(e)&&Uu||sl(e)&&pl||ZE(e)&&ju||e||eA});function ki(e,t){return t<e.length?e.charCodeAt(t):0}function gl(e,t,n){return n===13&&ki(e,t+1)===10?2:1}function Jr(e,t,n){let r=e.charCodeAt(t);return al(r)&&(r=r|32),r===n}function Zr(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(al(s)&&(s=s|32),s!==i)return!1}return!0}function Oy(e,t){for(;t>=0&&_r(e.charCodeAt(t));t--);return t+1}function ks(e,t){for(;t<e.length&&_r(e.charCodeAt(t));t++);return t}function Hu(e,t){for(;t<e.length&&Ht(e.charCodeAt(t));t++);return t}function eo(e,t){if(t+=2,On(ki(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&On(ki(e,t));t++);let n=ki(e,t);_r(n)&&(t+=gl(e,t,n))}return t}function Cs(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!ll(n)){if(Nn(n,ki(e,t+1))){t=eo(e,t)-1;continue}break}}return t}function Jo(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),Ht(n)&&(t=Hu(e,t+1),n=e.charCodeAt(t)),n===46&&Ht(e.charCodeAt(t+1))&&(t+=2,t=Hu(e,t)),Jr(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),Ht(n)&&(t=Hu(e,t+1+r+1))}return t}function fl(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}Nn(n,ki(e,t+1))&&(t=eo(e,t))}return t}function ml(e){if(e.length===1&&!On(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 hl=U(()=>{"use strict";vs()});var Ci,Wu=U(()=>{"use strict";Ci=["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 Ti(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Vu=U(()=>{"use strict"});function Uy(e){let t=e.source,n=t.length,r=t.length>0?ul(t.charCodeAt(0)):0,o=Ti(e.lines,n),i=Ti(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===_y||c===$y||c===tA)&&(c===$y&&u+1<n&&t.charCodeAt(u+1)===_y&&(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 _y,tA,$y,xl,jy=U(()=>{"use strict";Vu();vs();_y=10,tA=12,$y=13;xl=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 Hy(e,t,n){return e<t?t:e>n?n:e}var vr,kr,Ts,bl,Io,Cr,yl,Wy=U(()=>{"use strict";Vu();hl();Wu();vr=16777215,kr=24,Ts=1,bl=2,Io=new Uint8Array(32);Io[2]=22;Io[21]=22;Io[19]=20;Io[23]=24;Cr=new Uint8Array(32);Cr[2]=Ts;Cr[21]=Ts;Cr[19]=Ts;Cr[23]=Ts;Cr[22]=bl;Cr[20]=bl;Cr[24]=bl;yl=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=Ti(this.offsetAndType,t.length+1),i=Ti(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,g)=>{let p=s++;if(o[p]=l<<kr|g,a===-1&&(a=d),i[p]=c,l===u){let h=i[c];i[c]=p,c=h,u=Io[o[h]>>kr]}else this.isBlockOpenerTokenType(l)&&(c=p,u=Io[l])}),o[s]=0<<kr|r,i[s]=s;for(let l=0;l<s;l++){let d=i[l];if(d<=l){let g=i[d];g!==l&&(i[l]=g)}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]>>kr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>kr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&vr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>kr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?Zr(this.source,this.offsetAndType[t-1]&vr,this.offsetAndType[t]&vr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&vr:this.offsetAndType[this.tokenCount]&vr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[Hy(t,0,this.tokenCount)]&vr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[Hy(t,0,this.tokenCount)]>>kr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return Cr[t]===Ts}isBlockCloserTokenType(t){return Cr[t]===bl}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(Cr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return Io[n]===o?r:-1}else if(Cr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return Io[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]&vr,n=this.offsetAndType[n],this.tokenType=n>>kr,this.tokenEnd=n&vr):(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>>kr,this.tokenEnd=t&vr):(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]&vr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>kr)&&(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&vr,a=i>>kr;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:Ci[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function Fo(e,t){function n(d){return d<a?e.charCodeAt(d):0}function r(){if(c=Jo(e,c),vi(n(c),n(c+1),n(c+2))){l=12,c=Cs(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let d=c;if(c=Cs(e,c),Zr(e,d,c,"url")&&n(c)===40){if(c=ks(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 g=e.charCodeAt(c);switch(dl(g)){case d:c++;return;case ws:if(Ss(g)){c+=gl(e,c,g),l=6;return}break;case 92:if(c===e.length-1)break;let p=n(c+1);Ss(p)?c+=gl(e,c+1,p):Nn(g,p)&&(c=eo(e,c)-1);break}}}function s(){for(l=7,c=ks(e,c);c<e.length;c++){let d=e.charCodeAt(c);switch(dl(d)){case 41:c++;return;case ws:if(c=ks(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=fl(e,c),l=8;return;case 34:case 39:case 40:case ju:c=fl(e,c),l=8;return;case 92:if(Nn(d,n(c+1))){c=eo(e,c)-1;break}c=fl(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=ul(n(0)),c=u,l;for(;c<a;){let d=e.charCodeAt(c);switch(dl(d)){case ws:l=13,c=ks(e,c+1);break;case 34:i();break;case 35:ll(n(c+1))||Nn(n(c+1),n(c+2))?(l=4,c=Cs(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:cl(d,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:cl(d,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):vi(d,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:cl(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:vi(n(c+1),n(c+2),n(c+3))?(l=3,c=Cs(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:Nn(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 Uu:r();break;case pl:o();break;default:l=9,c++}t(l,u,u=c)}}var lr=U(()=>{"use strict";vs();hl();_u();_u();Wu();vs();hl();jy();Wy()});var Ii,Zn,Fs=U(()=>{"use strict";Ii=null,Zn=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 Ii!==null?(r=Ii,Ii=Ii.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=Ii,Ii=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 ei(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 wl=U(()=>{"use strict"});function qy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(h,b){return c.slice(h,b).map((I,F)=>String(h+F+1).padStart(g)+" |"+I).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),g=Math.max(4,String(d).length)+1,p=0;n+=(Gy.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>Gu&&(p=n-Vy+3,n=Vy-2);for(let m=l;m<=d;m++)m>=0&&m<c.length&&(c[m]=c[m].replace(/\t/g,Gy),c[m]=(p>0&&c[m].length>p?"\u2026":"")+c[m].substr(p,Gu-2)+(c[m].length>p+Gu-1?"\u2026":""));return[s(l,t),new Array(n+g+2).join("-")+"^",s(t,d)].filter(Boolean).join(`
5
- `).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function qu(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 qy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
6
- `+qy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var Gu,Vy,Gy,Yy=U(()=>{"use strict";Sl();Gu=100,Vy=60,Gy=" "});function Ky(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=U(()=>{"use strict"});function sA(e){return function(){return this[e]()}}function Ku(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 aA(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:Ku(e.atrule),pseudo:Ku(e.pseudo),node:Ku(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]=sA(r);break}return{config:t,...t,...t.node}}function Zy(e){let t="",n="<unknown>",r=!1,o=Fi,i=!1,s=new hl,a=Object.assign(new xl,aA(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Ky,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Qy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Qy||l===Yu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===nA||l===Yu?1:0},consumeUntilSemicolonIncluded(l){return l===Yu?2:0},createList:Fi,createSingleNodeList:Fi,getFirstListNode:Fi,getLastListNode:Fi,parseWithFallback(l,d){let g=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(g-this.tokenIndex);let m=d.call(this);return i=!0,o(p,m),i=!1,m}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==Jy);return Jy},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 Qr(t,l,d)},cmpStr(l,d,g){return Jr(t,l,d,g)},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,Qo(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=Ci[l].slice(0,-6).replace(/-/g," ").replace(/^./,m=>m.toUpperCase()),g=`${/[[\](){}]/.test(d)?`"${d}"`:d} is expected`,p=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(p=this.tokenEnd-1,g="Identifier is expected but function found"):g="Identifier is expected";break;case 4:this.isDelim(rA)&&(this.next(),p++,g="Name is expected");break;case 11:this.tokenType===10&&(p=this.tokenEnd,g="Percent sign is expected");break}this.error(g,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),g=this.getLastListNode(l);return s.getLocationRange(d!==null?d.loc.start.offset-s.startOffset:this.tokenStart,g!==null?g.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,d){let g=typeof d<"u"&&d<t.length?s.getLocation(d):this.eof?s.getLocation(Oy(t,t.length-1)):s.getLocation(this.tokenStart);throw new qu(l||"Unexpected input",t,g.offset,g.line,g.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>Ci[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,Fo),s.setSource(t,d.offset,d.line,d.column),n=d.filename||"<unknown>",r=!!d.positions,o=typeof d.onParseError=="function"?d.onParseError:Fi,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:g="default",list:p=!0,onComment:m,onToken:b}=d;if(!(g in a.context))throw new Error("Unknown context `"+g+"`");Object.assign(a,p?iA:oA),Array.isArray(b)?a.forEachToken((F,v,D)=>{b.push({type:F,start:v,end:D})}):typeof b=="function"&&a.forEachToken(b.bind(u())),typeof m=="function"&&a.forEachToken((F,v,D)=>{if(F===25){let _=a.getLocation(v,D),$=Jr(t,D-2,D,"*/")?t.slice(v+2,D-2):t.slice(v+2,D);m($,_)}});let T=a.context[g].call(a,d);return a.eof||a.error(),T},{SyntaxError:qu,config:a.config})}var Fi,nA,rA,Yu,Qy,Jy,oA,iA,eb=U(()=>{"use strict";Ts();Yy();lr();Xy();Fi=()=>{},nA=33,rA=35,Yu=59,Qy=123,Jy=0,oA={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}},iA={createList(){return new Zn},createSingleNodeList(e){return new Zn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var nb=ir(Xu=>{"use strict";var tb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Xu.encode=function(e){if(0<=e&&e<tb.length)return tb[e];throw new TypeError("Must be between 0 and 63: "+e)};Xu.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 ab=ir(Ju=>{"use strict";var rb=nb(),Qu=5,ob=1<<Qu,ib=ob-1,sb=ob;function lA(e){return e<0?(-e<<1)+1:(e<<1)+0}function cA(e){var t=(e&1)===1,n=e>>1;return t?-n:n}Ju.encode=function(t){var n="",r,o=lA(t);do r=o&ib,o>>>=Qu,o>0&&(r|=sb),n+=rb.encode(r);while(o>0);return n};Ju.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=rb.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&sb),u&=ib,i=i+(u<<s),s+=Qu}while(a);r.value=cA(i),r.rest=n}});var wl=ir(an=>{"use strict";function uA(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}an.getArg=uA;var lb=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,pA=/^data:.+\,.+$/;function Is(e){var t=e.match(lb);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}an.urlParse=Is;function Ei(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}an.urlGenerate=Ei;var dA=32;function gA(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>dA&&t.pop(),i}}var Zu=gA(function(t){var n=t,r=Is(t);if(r){if(!r.path)return t;n=r.path}for(var o=an.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,Ei(r)):n});an.normalize=Zu;function cb(e,t){e===""&&(e="."),t===""&&(t=".");var n=Is(t),r=Is(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),Ei(n);if(n||t.match(pA))return t;if(r&&!r.host&&!r.path)return r.host=t,Ei(r);var o=t.charAt(0)==="/"?t:Zu(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,Ei(r)):o}an.join=cb;an.isAbsolute=function(e){return e.charAt(0)==="/"||lb.test(e)};function fA(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)}an.relative=fA;var ub=(function(){var e=Object.create(null);return!("__proto__"in e)})();function pb(e){return e}function mA(e){return db(e)?"$"+e:e}an.toSetString=ub?pb:mA;function hA(e){return db(e)?e.slice(1):e}an.fromSetString=ub?pb:hA;function db(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 xA(e,t,n){var r=eo(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:eo(e.name,t.name)}an.compareByOriginalPositions=xA;function yA(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:eo(e.name,t.name)}an.compareByOriginalPositionsNoSource=yA;function bA(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=eo(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:eo(e.name,t.name)}an.compareByGeneratedPositionsDeflated=bA;function SA(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=eo(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:eo(e.name,t.name)}an.compareByGeneratedPositionsDeflatedNoLine=SA;function eo(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function wA(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=eo(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:eo(e.name,t.name)}an.compareByGeneratedPositionsInflated=wA;function vA(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}an.parseSourceMapInput=vA;function kA(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=Is(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=cb(Ei(r),t)}return Zu(t)}an.computeSourceURL=kA});var fb=ir(gb=>{"use strict";var ep=wl(),tp=Object.prototype.hasOwnProperty,ei=typeof Map<"u";function to(){this._array=[],this._set=ei?new Map:Object.create(null)}to.fromArray=function(t,n){for(var r=new to,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};to.prototype.size=function(){return ei?this._set.size:Object.getOwnPropertyNames(this._set).length};to.prototype.add=function(t,n){var r=ei?t:ep.toSetString(t),o=ei?this.has(t):tp.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(ei?this._set.set(t,i):this._set[r]=i)};to.prototype.has=function(t){if(ei)return this._set.has(t);var n=ep.toSetString(t);return tp.call(this._set,n)};to.prototype.indexOf=function(t){if(ei){var n=this._set.get(t);if(n>=0)return n}else{var r=ep.toSetString(t);if(tp.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};to.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};to.prototype.toArray=function(){return this._array.slice()};gb.ArraySet=to});var xb=ir(hb=>{"use strict";var mb=wl();function CA(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||mb.compareByGeneratedPositionsInflated(e,t)<=0}function vl(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}vl.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};vl.prototype.add=function(t){CA(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};vl.prototype.toArray=function(){return this._sorted||(this._array.sort(mb.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};hb.MappingList=vl});var bb=ir(yb=>{"use strict";var Fs=ab(),Wt=wl(),kl=fb().ArraySet,TA=xb().MappingList;function cr(e){e||(e={}),this._file=Wt.getArg(e,"file",null),this._sourceRoot=Wt.getArg(e,"sourceRoot",null),this._skipValidation=Wt.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Wt.getArg(e,"ignoreInvalidMapping",!1),this._sources=new kl,this._names=new kl,this._mappings=new TA,this._sourcesContents=null}cr.prototype._version=3;cr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new cr(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=Wt.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=Wt.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};cr.prototype.addMapping=function(t){var n=Wt.getArg(t,"generated"),r=Wt.getArg(t,"original",null),o=Wt.getArg(t,"source",null),i=Wt.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}))};cr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=Wt.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Wt.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Wt.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};cr.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=Wt.relative(i,o));var s=new kl,a=new kl;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=Wt.join(r,u.source)),i!=null&&(u.source=Wt.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=Wt.join(r,u)),i!=null&&(u=Wt.relative(i,u)),this.setSourceContent(u,c))},this)};cr.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)}};cr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,d,g=this._mappings.toArray(),p=0,m=g.length;p<m;p++){if(c=g[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!Wt.compareByGeneratedPositionsInflated(c,g[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};cr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=Wt.relative(n,r));var o=Wt.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};cr.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};cr.prototype.toString=function(){return JSON.stringify(this.toJSON())};yb.SourceMapGenerator=cr});function vb(e){let t=new wb.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(g){if(g.loc&&g.loc.start&&Sb.has(g.type)){let p=g.loc.start.line,m=g.loc.start.column-1;(r.line!==p||r.column!==m)&&(r.line=p,r.column=m,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:g.loc.source,original:r,generated:n}))}c.call(this,g),u&&Sb.has(g.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(g,p,m){for(let b=0;b<g.length;b++)g.charCodeAt(b)===10?(s++,a=0):a++;l(g,p,m)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var wb,Sb,kb=U(()=>{"use strict";wb=el(bb(),1),Sb=new Set(["Atrule","Selector","Declaration"])});var Cl={};ye(Cl,{safe:()=>rp,spec:()=>AA});function Tb(e){let t=new Set(e.map(([n,r])=>np(n)<<16|np(r)));return function(n,r,o){let i=np(r,o),s=o.charCodeAt(0),a=s===FA&&r!==1&&r!==2&&r!==15||s===IA?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var IA,FA,np,Cb,EA,AA,rp,Ib=U(()=>{"use strict";IA=43,FA=45,np=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),Cb=[[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],["/","*"]],EA=Cb.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,"-"]]);AA=Tb(Cb),rp=Tb(EA)});function LA(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 Fb(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:rp,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)===PA&&this.emit(`
7
- `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=vb(s)),r.mode in Cl&&(s.tokenBefore=Cl[r.mode]));let a={node:u=>s.node(u),children:LA,token:(u,c)=>s.token(u,c),tokenize:u=>Fo(u,(c,l,d)=>{s.token(c,u.slice(l,d),l!==0)})};return s.node(n),s.result()}}var PA,Eb=U(()=>{"use strict";lr();kb();Ib();PA=92});function Ab(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Zn)&&(n.children=new Zn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Zn&&(n.children=n.children.toArray())}}),t}}}var Pb=U(()=>{"use strict";Ts()});function Lb(e){return typeof e=="function"?e:Es}function Mb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function MA(e,t){let n=t.structure,r=[];for(let o in n){if(op.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 BA(e){let t={};for(let n in e.node)if(op.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]=MA(n,r)}return t}function Bb(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 Db({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 Rb(e){let t=BA(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)op.call(t,c)&&t[c]!==null&&(n[c]=Bb(t[c],!1),r[c]=Bb(t[c],!0));let s=Db(n),a=Db(r),u=function(c,l){function d(F,v,D){let _=g.call(T,F,v,D);return _===o?!0:_===i?!1:!!(m.hasOwnProperty(F.type)&&m[F.type](F,T,d,b)||p.call(T,F,v,D)===o)}let g=Es,p=Es,m=n,b=(F,v,D,_)=>F||d(v,D,_),T={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")g=l;else if(l&&(g=Lb(l.enter),p=Lb(l.leave),l.reverse&&(m=r),l.visit)){if(s.hasOwnProperty(l.visit))m=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(", ")+")");g=Mb(g,l.visit),p=Mb(p,l.visit)}if(g===Es&&p===Es)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(g,p,m){if(l.call(this,g,p,m))return d=g,o}),d},u.findLast=function(c,l){let d=null;return u(c,{reverse:!0,enter(g,p,m){if(l.call(this,g,p,m))return d=g,o}}),d},u.findAll=function(c,l){let d=[];return u(c,function(g,p,m){l.call(this,g,p,m)&&d.push(g)}),d},u}var op,Es,zb=U(()=>{"use strict";({hasOwnProperty:op}=Object.prototype),Es=function(){}});function DA(e){return e}function RA(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 zA(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 NA(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>Tl(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function Tl(e,t,n,r){let o;switch(e.type){case"Group":o=NA(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return Tl(e.term,t,n,r)+t(RA(e),e);case"Boolean":o="<boolean-expr["+Tl(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(zA(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 Ai(e,t){let n=DA,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),Tl(e,n,r,o)}var ip=U(()=>{"use strict"});function OA(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 g=0;g<n.length;g++){let p=n[g].value;g===r&&(a=p.length,s=c.length),i!==null&&n[g].node===i&&(g<=r?u++:u=0),c+=p}return r===n.length||u>1?(l=Il(i||t,"end")||As(Nb,c),d=As(l)):(l=Il(i,"start")||As(Il(t,"start")||Nb,c.slice(0,s)),d=Il(i,"end")||As(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:d}}function Il(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?As(n):n:null}function As({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 Nb,Pi,Ob,_b=U(()=>{"use strict";Sl();ip();Nb={offset:0,line:1,column:1};Pi=function(e,t){let n=Zo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},Ob=function(e,t,n,r){let o=Zo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=OA(r,n);return o.rawMessage=e,o.syntax=t?Ai(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),g=Math.max(4,String(d).length)+1,p=0;n+=(Gy.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>Gu&&(p=n-Vy+3,n=Vy-2);for(let h=l;h<=d;h++)h>=0&&h<c.length&&(c[h]=c[h].replace(/\t/g,Gy),c[h]=(p>0&&c[h].length>p?"\u2026":"")+c[h].substr(p,Gu-2)+(c[h].length>p+Gu-1?"\u2026":""));return[s(l,t),new Array(n+g+2).join("-")+"^",s(t,d)].filter(Boolean).join(`
5
+ `).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function qu(e,t,n,r,o,i=1,s=1){return Object.assign(ei("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return qy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
6
+ `+qy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var Gu,Vy,Gy,Yy=U(()=>{"use strict";wl();Gu=100,Vy=60,Gy=" "});function Ky(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=U(()=>{"use strict"});function sA(e){return function(){return this[e]()}}function Ku(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 aA(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:Ku(e.atrule),pseudo:Ku(e.pseudo),node:Ku(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]=sA(r);break}return{config:t,...t,...t.node}}function Zy(e){let t="",n="<unknown>",r=!1,o=Fi,i=!1,s=new xl,a=Object.assign(new yl,aA(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Ky,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Qy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Qy||l===Yu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===nA||l===Yu?1:0},consumeUntilSemicolonIncluded(l){return l===Yu?2:0},createList:Fi,createSingleNodeList:Fi,getFirstListNode:Fi,getLastListNode:Fi,parseWithFallback(l,d){let g=this.tokenIndex;try{return l.call(this)}catch(p){if(i)throw p;this.skip(g-this.tokenIndex);let h=d.call(this);return i=!0,o(p,h),i=!1,h}},lookupNonWSType(l){let d;do if(d=this.lookupType(l++),d!==13&&d!==25)return d;while(d!==Jy);return Jy},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 Jr(t,l,d)},cmpStr(l,d,g){return Zr(t,l,d,g)},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,Jo(t,this.tokenStart));return this.eat(l),d},eat(l){if(this.tokenType!==l){let d=Ci[l].slice(0,-6).replace(/-/g," ").replace(/^./,h=>h.toUpperCase()),g=`${/[[\](){}]/.test(d)?`"${d}"`:d} is expected`,p=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(p=this.tokenEnd-1,g="Identifier is expected but function found"):g="Identifier is expected";break;case 4:this.isDelim(rA)&&(this.next(),p++,g="Name is expected");break;case 11:this.tokenType===10&&(p=this.tokenEnd,g="Percent sign is expected");break}this.error(g,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),g=this.getLastListNode(l);return s.getLocationRange(d!==null?d.loc.start.offset-s.startOffset:this.tokenStart,g!==null?g.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,d){let g=typeof d<"u"&&d<t.length?s.getLocation(d):this.eof?s.getLocation(Oy(t,t.length-1)):s.getLocation(this.tokenStart);throw new qu(l||"Unexpected input",t,g.offset,g.line,g.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>Ci[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,Fo),s.setSource(t,d.offset,d.line,d.column),n=d.filename||"<unknown>",r=!!d.positions,o=typeof d.onParseError=="function"?d.onParseError:Fi,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:g="default",list:p=!0,onComment:h,onToken:b}=d;if(!(g in a.context))throw new Error("Unknown context `"+g+"`");Object.assign(a,p?iA:oA),Array.isArray(b)?a.forEachToken((F,v,D)=>{b.push({type:F,start:v,end:D})}):typeof b=="function"&&a.forEachToken(b.bind(u())),typeof h=="function"&&a.forEachToken((F,v,D)=>{if(F===25){let N=a.getLocation(v,D),$=Zr(t,D-2,D,"*/")?t.slice(v+2,D-2):t.slice(v+2,D);h($,N)}});let I=a.context[g].call(a,d);return a.eof||a.error(),I},{SyntaxError:qu,config:a.config})}var Fi,nA,rA,Yu,Qy,Jy,oA,iA,eb=U(()=>{"use strict";Fs();Yy();lr();Xy();Fi=()=>{},nA=33,rA=35,Yu=59,Qy=123,Jy=0,oA={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}},iA={createList(){return new Zn},createSingleNodeList(e){return new Zn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var nb=ir(Xu=>{"use strict";var tb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Xu.encode=function(e){if(0<=e&&e<tb.length)return tb[e];throw new TypeError("Must be between 0 and 63: "+e)};Xu.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 ab=ir(Ju=>{"use strict";var rb=nb(),Qu=5,ob=1<<Qu,ib=ob-1,sb=ob;function lA(e){return e<0?(-e<<1)+1:(e<<1)+0}function cA(e){var t=(e&1)===1,n=e>>1;return t?-n:n}Ju.encode=function(t){var n="",r,o=lA(t);do r=o&ib,o>>>=Qu,o>0&&(r|=sb),n+=rb.encode(r);while(o>0);return n};Ju.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=rb.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&sb),u&=ib,i=i+(u<<s),s+=Qu}while(a);r.value=cA(i),r.rest=n}});var vl=ir(an=>{"use strict";function uA(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}an.getArg=uA;var lb=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,pA=/^data:.+\,.+$/;function Es(e){var t=e.match(lb);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}an.urlParse=Es;function Ei(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}an.urlGenerate=Ei;var dA=32;function gA(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>dA&&t.pop(),i}}var Zu=gA(function(t){var n=t,r=Es(t);if(r){if(!r.path)return t;n=r.path}for(var o=an.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,Ei(r)):n});an.normalize=Zu;function cb(e,t){e===""&&(e="."),t===""&&(t=".");var n=Es(t),r=Es(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),Ei(n);if(n||t.match(pA))return t;if(r&&!r.host&&!r.path)return r.host=t,Ei(r);var o=t.charAt(0)==="/"?t:Zu(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,Ei(r)):o}an.join=cb;an.isAbsolute=function(e){return e.charAt(0)==="/"||lb.test(e)};function fA(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)}an.relative=fA;var ub=(function(){var e=Object.create(null);return!("__proto__"in e)})();function pb(e){return e}function mA(e){return db(e)?"$"+e:e}an.toSetString=ub?pb:mA;function hA(e){return db(e)?e.slice(1):e}an.fromSetString=ub?pb:hA;function db(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 xA(e,t,n){var r=to(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:to(e.name,t.name)}an.compareByOriginalPositions=xA;function yA(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:to(e.name,t.name)}an.compareByOriginalPositionsNoSource=yA;function bA(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=to(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:to(e.name,t.name)}an.compareByGeneratedPositionsDeflated=bA;function SA(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=to(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:to(e.name,t.name)}an.compareByGeneratedPositionsDeflatedNoLine=SA;function to(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function wA(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=to(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:to(e.name,t.name)}an.compareByGeneratedPositionsInflated=wA;function vA(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}an.parseSourceMapInput=vA;function kA(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=Es(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=cb(Ei(r),t)}return Zu(t)}an.computeSourceURL=kA});var fb=ir(gb=>{"use strict";var ep=vl(),tp=Object.prototype.hasOwnProperty,ti=typeof Map<"u";function no(){this._array=[],this._set=ti?new Map:Object.create(null)}no.fromArray=function(t,n){for(var r=new no,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};no.prototype.size=function(){return ti?this._set.size:Object.getOwnPropertyNames(this._set).length};no.prototype.add=function(t,n){var r=ti?t:ep.toSetString(t),o=ti?this.has(t):tp.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(ti?this._set.set(t,i):this._set[r]=i)};no.prototype.has=function(t){if(ti)return this._set.has(t);var n=ep.toSetString(t);return tp.call(this._set,n)};no.prototype.indexOf=function(t){if(ti){var n=this._set.get(t);if(n>=0)return n}else{var r=ep.toSetString(t);if(tp.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};no.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};no.prototype.toArray=function(){return this._array.slice()};gb.ArraySet=no});var xb=ir(hb=>{"use strict";var mb=vl();function CA(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||mb.compareByGeneratedPositionsInflated(e,t)<=0}function kl(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}kl.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};kl.prototype.add=function(t){CA(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};kl.prototype.toArray=function(){return this._sorted||(this._array.sort(mb.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};hb.MappingList=kl});var bb=ir(yb=>{"use strict";var As=ab(),Wt=vl(),Cl=fb().ArraySet,TA=xb().MappingList;function cr(e){e||(e={}),this._file=Wt.getArg(e,"file",null),this._sourceRoot=Wt.getArg(e,"sourceRoot",null),this._skipValidation=Wt.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Wt.getArg(e,"ignoreInvalidMapping",!1),this._sources=new Cl,this._names=new Cl,this._mappings=new TA,this._sourcesContents=null}cr.prototype._version=3;cr.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new cr(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=Wt.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=Wt.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};cr.prototype.addMapping=function(t){var n=Wt.getArg(t,"generated"),r=Wt.getArg(t,"original",null),o=Wt.getArg(t,"source",null),i=Wt.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}))};cr.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=Wt.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Wt.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Wt.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};cr.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=Wt.relative(i,o));var s=new Cl,a=new Cl;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=Wt.join(r,u.source)),i!=null&&(u.source=Wt.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=Wt.join(r,u)),i!=null&&(u=Wt.relative(i,u)),this.setSourceContent(u,c))},this)};cr.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)}};cr.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,d,g=this._mappings.toArray(),p=0,h=g.length;p<h;p++){if(c=g[p],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(p>0){if(!Wt.compareByGeneratedPositionsInflated(c,g[p-1]))continue;u+=","}u+=As.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(d=this._sources.indexOf(c.source),u+=As.encode(d-s),s=d,u+=As.encode(c.originalLine-1-o),o=c.originalLine-1,u+=As.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=As.encode(l-i),i=l)),a+=u}return a};cr.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=Wt.relative(n,r));var o=Wt.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};cr.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};cr.prototype.toString=function(){return JSON.stringify(this.toJSON())};yb.SourceMapGenerator=cr});function vb(e){let t=new wb.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(g){if(g.loc&&g.loc.start&&Sb.has(g.type)){let p=g.loc.start.line,h=g.loc.start.column-1;(r.line!==p||r.column!==h)&&(r.line=p,r.column=h,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:g.loc.source,original:r,generated:n}))}c.call(this,g),u&&Sb.has(g.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(g,p,h){for(let b=0;b<g.length;b++)g.charCodeAt(b)===10?(s++,a=0):a++;l(g,p,h)};let d=e.result;return e.result=function(){return u&&t.addMapping(i),{css:d(),map:t}},e}var wb,Sb,kb=U(()=>{"use strict";wb=tl(bb(),1),Sb=new Set(["Atrule","Selector","Declaration"])});var Tl={};ye(Tl,{safe:()=>rp,spec:()=>AA});function Tb(e){let t=new Set(e.map(([n,r])=>np(n)<<16|np(r)));return function(n,r,o){let i=np(r,o),s=o.charCodeAt(0),a=s===FA&&r!==1&&r!==2&&r!==15||s===IA?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var IA,FA,np,Cb,EA,AA,rp,Ib=U(()=>{"use strict";IA=43,FA=45,np=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),Cb=[[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],["/","*"]],EA=Cb.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,"-"]]);AA=Tb(Cb),rp=Tb(EA)});function LA(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 Fb(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:rp,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)===PA&&this.emit(`
7
+ `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=vb(s)),r.mode in Tl&&(s.tokenBefore=Tl[r.mode]));let a={node:u=>s.node(u),children:LA,token:(u,c)=>s.token(u,c),tokenize:u=>Fo(u,(c,l,d)=>{s.token(c,u.slice(l,d),l!==0)})};return s.node(n),s.result()}}var PA,Eb=U(()=>{"use strict";lr();kb();Ib();PA=92});function Ab(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Zn)&&(n.children=new Zn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Zn&&(n.children=n.children.toArray())}}),t}}}var Pb=U(()=>{"use strict";Fs()});function Lb(e){return typeof e=="function"?e:Ps}function Mb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function MA(e,t){let n=t.structure,r=[];for(let o in n){if(op.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 BA(e){let t={};for(let n in e.node)if(op.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]=MA(n,r)}return t}function Bb(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 Db({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 Rb(e){let t=BA(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)op.call(t,c)&&t[c]!==null&&(n[c]=Bb(t[c],!1),r[c]=Bb(t[c],!0));let s=Db(n),a=Db(r),u=function(c,l){function d(F,v,D){let N=g.call(I,F,v,D);return N===o?!0:N===i?!1:!!(h.hasOwnProperty(F.type)&&h[F.type](F,I,d,b)||p.call(I,F,v,D)===o)}let g=Ps,p=Ps,h=n,b=(F,v,D,N)=>F||d(v,D,N),I={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")g=l;else if(l&&(g=Lb(l.enter),p=Lb(l.leave),l.reverse&&(h=r),l.visit)){if(s.hasOwnProperty(l.visit))h=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(", ")+")");g=Mb(g,l.visit),p=Mb(p,l.visit)}if(g===Ps&&p===Ps)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(g,p,h){if(l.call(this,g,p,h))return d=g,o}),d},u.findLast=function(c,l){let d=null;return u(c,{reverse:!0,enter(g,p,h){if(l.call(this,g,p,h))return d=g,o}}),d},u.findAll=function(c,l){let d=[];return u(c,function(g,p,h){l.call(this,g,p,h)&&d.push(g)}),d},u}var op,Ps,zb=U(()=>{"use strict";({hasOwnProperty:op}=Object.prototype),Ps=function(){}});function DA(e){return e}function RA(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 zA(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 NA(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>Il(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function Il(e,t,n,r){let o;switch(e.type){case"Group":o=NA(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return Il(e.term,t,n,r)+t(RA(e),e);case"Boolean":o="<boolean-expr["+Il(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(zA(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 Ai(e,t){let n=DA,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),Il(e,n,r,o)}var ip=U(()=>{"use strict"});function OA(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 g=0;g<n.length;g++){let p=n[g].value;g===r&&(a=p.length,s=c.length),i!==null&&n[g].node===i&&(g<=r?u++:u=0),c+=p}return r===n.length||u>1?(l=Fl(i||t,"end")||Ls(Nb,c),d=Ls(l)):(l=Fl(i,"start")||Ls(Fl(t,"start")||Nb,c.slice(0,s)),d=Fl(i,"end")||Ls(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:d}}function Fl(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?Ls(n):n:null}function Ls({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 Nb,Pi,Ob,_b=U(()=>{"use strict";wl();ip();Nb={offset:0,line:1,column:1};Pi=function(e,t){let n=ei("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},Ob=function(e,t,n,r){let o=ei("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=OA(r,n);return o.rawMessage=e,o.syntax=t?Ai(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 Pl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===El&&e.charCodeAt(t+1)===El}function $b(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===El&&e.charCodeAt(t+1)!==El){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function _A(e){if(Fl.has(e))return Fl.get(e);let t=e.toLowerCase(),n=Fl.get(t);if(n===void 0){let r=Pl(t,0),o=r?"":$b(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return Fl.set(e,n),n}function $A(e){if(Li.has(e))return Li.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=Pl(t,n.length);if(!r&&(t=t.toLowerCase(),Li.has(t))){let a=Li.get(t);return Li.set(e,a),a}let o=r?"":$b(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 Li.set(e,s),s}var Fl,Li,El,Al,sp,Ll=U(()=>{"use strict";Fl=new Map,Li=new Map,El=45,Al=_A,sp=$A});var Mi,Ml=U(()=>{"use strict";Mi=["initial","inherit","unset","revert","revert-layer"]});function cp(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function Ps(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function Eo(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===Ls||o===$r){if(n)return 0;t++}for(;t<e.value.length;t++)if(!Ht(e.value.charCodeAt(t)))return 0;return r+1}function lp(e,t,n){let r=!1,o=Ps(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(cp(e,Ls)||cp(e,$r)){if(r=!0,o=Ps(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!==Ls&&i!==$r)return 0}return Eo(e,r?0:1,r,o)}function up(e,t){let n=0;if(!e)return 0;if(e.type===10)return Eo(e,0,jA,n);if(e.type===1&&e.value.charCodeAt(0)===$r){if(!Qr(e.value,1,ap))return 0;switch(e.value.length){case 2:return lp(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==$r?0:(n=Ps(t(++n),n,t),e=t(n),Eo(e,0,Bi,n));default:return e.value.charCodeAt(2)!==$r?0:Eo(e,3,Bi,n)}}else if(e.type===1||cp(e,Ls)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Qr(e.value,0,ap))return 0;switch(e.value.length){case 1:return lp(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==$r?0:(n=Ps(t(++n),n,t),e=t(n),Eo(e,0,Bi,n));default:return e.value.charCodeAt(1)!==$r?0:Eo(e,2,Bi,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===Ls||r===$r?1:0,i=o;for(;i<e.value.length&&Ht(e.value.charCodeAt(i));i++);return i===o||!Qr(e.value,i,ap)?0:i+1===e.value.length?lp(t(++n),n,t):e.value.charCodeAt(i+1)!==$r?0:i+2===e.value.length?(n=Ps(t(++n),n,t),e=t(n),Eo(e,0,Bi,n)):Eo(e,i+2,Bi,n)}return 0}var Ls,$r,ap,Bi,jA,Ub=U(()=>{"use strict";lr();Ls=43,$r=45,ap=110,Bi=!0,jA=!1});function pp(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function VA(e,t){return e.value.charCodeAt(0)===t}function Ms(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===jb&&n&&r!==0)return Ms(e,t+r+1,!1),6;if(!Nn(i)||++r>6)return 0}return r}function Bl(e,t,n){if(!e)return 0;for(;pp(n(t),Hb);){if(++e>6)return 0;t++}return t}function dp(e,t){let n=0;if(e===null||e.type!==1||!Qr(e.value,0,WA)||(e=t(++n),e===null))return 0;if(pp(e,HA))return e=t(++n),e===null?0:e.type===1?Bl(Ms(e,0,!0),++n,t):pp(e,Hb)?Bl(1,++n,t):0;if(e.type===10){let r=Ms(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!VA(e,jb)||!Ms(e,1,!1)?0:n+1:Bl(r,n,t))}return e.type===12?Bl(Ms(e,1,!0),++n,t):0}var HA,jb,Hb,WA,Wb=U(()=>{"use strict";lr();HA=43,jb=45,Hb=63,WA=117});function Ir(e,t){return t<e.length?e.charCodeAt(t):0}function Gb(e,t){return Jr(e,0,e.length,t)}function qb(e,t){for(let n=0;n<t.length;n++)if(Gb(e,t[n]))return!0;return!1}function Yb(e,t){return t!==e.length-2?!1:Ir(e,t)===92&&Ht(Ir(e,t+1))}function Dl(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 XA(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=yp.get(e.type);break}o++}while(e=t(o));return o}function ur(e,t){return function(n,r,o){return n===null?0:n.type===2&&qb(n.value,t)?XA(n,r):e(n,r,o)}}function Lt(e){return function(t){return t===null||t.type!==e?0:1}}function QA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return qb(t,Mi)||Gb(t,"default")?0:1}function Kb(e){return e===null||e.type!==1||Ir(e.value,0)!==45||Ir(e.value,1)!==45?0:1}function JA(e){return!Kb(e)||e.value==="--"?0:1}function ZA(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(!Nn(Ir(e.value,n)))return 0;return 1}function eP(e){return e===null||e.type!==4||!vi(Ir(e.value,1),Ir(e.value,2),Ir(e.value,3))?0:1}function tP(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=yp.get(e.type);break}o++}while(e=t(o));return o}function nP(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=yp.get(e.type);break}o++}while(e=t(o));return o}function ro(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Qo(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!Yb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return Dl(r,t.value,o)?0:1}}function rP(e,t,n){return e===null||e.type!==11||Dl(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 oP(e,t,n){if(e===null)return 0;let r=Qo(e.value,0);return!(r===e.value.length)&&!Yb(e.value,r)||Dl(n,e.value,r)?0:1}function iP(e,t,n){if(e===null||e.type!==10)return 0;let r=Ir(e.value,0)===43||Ir(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!Ht(Ir(e.value,r)))return 0;return Dl(n,e.value,r)?0:1}function cP(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:ur(ro(null),no),angle:ur(ro(t),no),decibel:ur(ro(n),no),frequency:ur(ro(r),no),flex:ur(ro(o),no),length:ur(Xb(ro(i)),no),resolution:ur(ro(s),no),semitones:ur(ro(a),no),time:ur(ro(u),no)}}function uP(e){let t=new Set;for(let n of lP)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 Qb(e){return{...sP,...aP,...cP(e),"attr-unit":uP(e)}}var gp,fp,mp,GA,qA,YA,hp,xp,Vb,KA,no,yp,sP,aP,lP,Jb=U(()=>{"use strict";Ml();Ub();Wb();lr();gp=["calc(","-moz-calc(","-webkit-calc("],fp=["min(","max(","clamp("],mp=["round(","mod(","rem("],GA=["sin(","cos(","tan("],qA=["asin(","acos(","atan(","atan2("],YA=["pow(","sqrt(","log(","exp(","sign("],hp=["hypot("],xp=["abs("],Vb=[...gp,...fp,...mp,...GA,...YA,...hp,...xp],KA=[...gp,...fp,...mp,...hp,...xp],no=[...gp,...fp,...mp,...qA,...hp,...xp],yp=new Map([[2,22],[21,22],[19,20],[23,24]]);sP={"ident-token":Lt(1),"function-token":Lt(2),"at-keyword-token":Lt(3),"hash-token":Lt(4),"string-token":Lt(5),"bad-string-token":Lt(6),"url-token":Lt(7),"bad-url-token":Lt(8),"delim-token":Lt(9),"number-token":Lt(10),"percentage-token":Lt(11),"dimension-token":Lt(12),"whitespace-token":Lt(13),"CDO-token":Lt(14),"CDC-token":Lt(15),"colon-token":Lt(16),"semicolon-token":Lt(17),"comma-token":Lt(18),"[-token":Lt(19),"]-token":Lt(20),"(-token":Lt(21),")-token":Lt(22),"{-token":Lt(23),"}-token":Lt(24)},aP={string:Lt(5),ident:Lt(1),percentage:ur(rP,KA),zero:Xb(),number:ur(oP,Vb),integer:ur(iP,Vb),"custom-ident":QA,"dashed-ident":Kb,"custom-property-name":JA,"hex-color":ZA,"id-selector":eP,"an-plus-b":up,urange:dp,"declaration-value":tP,"any-value":nP},lP=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var Rl={};ye(Rl,{angle:()=>dP,decibel:()=>xP,flex:()=>hP,frequency:()=>fP,length:()=>pP,resolution:()=>mP,semitones:()=>yP,time:()=>gP});var pP,dP,gP,fP,mP,hP,xP,yP,Zb=U(()=>{"use strict";pP=["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"],dP=["deg","grad","rad","turn"],gP=["s","ms"],fP=["hz","khz"],mP=["dpi","dpcm","dppx","x"],hP=["fr"],xP=["db"],yP=["st"]});function e0(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 Ll(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===Al&&e.charCodeAt(t+1)===Al}function $b(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===Al&&e.charCodeAt(t+1)!==Al){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function _A(e){if(El.has(e))return El.get(e);let t=e.toLowerCase(),n=El.get(t);if(n===void 0){let r=Ll(t,0),o=r?"":$b(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return El.set(e,n),n}function $A(e){if(Li.has(e))return Li.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=Ll(t,n.length);if(!r&&(t=t.toLowerCase(),Li.has(t))){let a=Li.get(t);return Li.set(e,a),a}let o=r?"":$b(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 Li.set(e,s),s}var El,Li,Al,Pl,sp,Ml=U(()=>{"use strict";El=new Map,Li=new Map,Al=45,Pl=_A,sp=$A});var Mi,Bl=U(()=>{"use strict";Mi=["initial","inherit","unset","revert","revert-layer"]});function cp(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function Ms(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function Eo(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===Bs||o===$r){if(n)return 0;t++}for(;t<e.value.length;t++)if(!Ht(e.value.charCodeAt(t)))return 0;return r+1}function lp(e,t,n){let r=!1,o=Ms(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(cp(e,Bs)||cp(e,$r)){if(r=!0,o=Ms(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!==Bs&&i!==$r)return 0}return Eo(e,r?0:1,r,o)}function up(e,t){let n=0;if(!e)return 0;if(e.type===10)return Eo(e,0,jA,n);if(e.type===1&&e.value.charCodeAt(0)===$r){if(!Jr(e.value,1,ap))return 0;switch(e.value.length){case 2:return lp(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==$r?0:(n=Ms(t(++n),n,t),e=t(n),Eo(e,0,Bi,n));default:return e.value.charCodeAt(2)!==$r?0:Eo(e,3,Bi,n)}}else if(e.type===1||cp(e,Bs)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Jr(e.value,0,ap))return 0;switch(e.value.length){case 1:return lp(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==$r?0:(n=Ms(t(++n),n,t),e=t(n),Eo(e,0,Bi,n));default:return e.value.charCodeAt(1)!==$r?0:Eo(e,2,Bi,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===Bs||r===$r?1:0,i=o;for(;i<e.value.length&&Ht(e.value.charCodeAt(i));i++);return i===o||!Jr(e.value,i,ap)?0:i+1===e.value.length?lp(t(++n),n,t):e.value.charCodeAt(i+1)!==$r?0:i+2===e.value.length?(n=Ms(t(++n),n,t),e=t(n),Eo(e,0,Bi,n)):Eo(e,i+2,Bi,n)}return 0}var Bs,$r,ap,Bi,jA,Ub=U(()=>{"use strict";lr();Bs=43,$r=45,ap=110,Bi=!0,jA=!1});function pp(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function VA(e,t){return e.value.charCodeAt(0)===t}function Ds(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===jb&&n&&r!==0)return Ds(e,t+r+1,!1),6;if(!On(i)||++r>6)return 0}return r}function Dl(e,t,n){if(!e)return 0;for(;pp(n(t),Hb);){if(++e>6)return 0;t++}return t}function dp(e,t){let n=0;if(e===null||e.type!==1||!Jr(e.value,0,WA)||(e=t(++n),e===null))return 0;if(pp(e,HA))return e=t(++n),e===null?0:e.type===1?Dl(Ds(e,0,!0),++n,t):pp(e,Hb)?Dl(1,++n,t):0;if(e.type===10){let r=Ds(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!VA(e,jb)||!Ds(e,1,!1)?0:n+1:Dl(r,n,t))}return e.type===12?Dl(Ds(e,1,!0),++n,t):0}var HA,jb,Hb,WA,Wb=U(()=>{"use strict";lr();HA=43,jb=45,Hb=63,WA=117});function Ir(e,t){return t<e.length?e.charCodeAt(t):0}function Gb(e,t){return Zr(e,0,e.length,t)}function qb(e,t){for(let n=0;n<t.length;n++)if(Gb(e,t[n]))return!0;return!1}function Yb(e,t){return t!==e.length-2?!1:Ir(e,t)===92&&Ht(Ir(e,t+1))}function Rl(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 XA(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=yp.get(e.type);break}o++}while(e=t(o));return o}function ur(e,t){return function(n,r,o){return n===null?0:n.type===2&&qb(n.value,t)?XA(n,r):e(n,r,o)}}function Lt(e){return function(t){return t===null||t.type!==e?0:1}}function QA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return qb(t,Mi)||Gb(t,"default")?0:1}function Kb(e){return e===null||e.type!==1||Ir(e.value,0)!==45||Ir(e.value,1)!==45?0:1}function JA(e){return!Kb(e)||e.value==="--"?0:1}function ZA(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(!On(Ir(e.value,n)))return 0;return 1}function eP(e){return e===null||e.type!==4||!vi(Ir(e.value,1),Ir(e.value,2),Ir(e.value,3))?0:1}function tP(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=yp.get(e.type);break}o++}while(e=t(o));return o}function nP(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=yp.get(e.type);break}o++}while(e=t(o));return o}function oo(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Jo(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!Yb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return Rl(r,t.value,o)?0:1}}function rP(e,t,n){return e===null||e.type!==11||Rl(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 oP(e,t,n){if(e===null)return 0;let r=Jo(e.value,0);return!(r===e.value.length)&&!Yb(e.value,r)||Rl(n,e.value,r)?0:1}function iP(e,t,n){if(e===null||e.type!==10)return 0;let r=Ir(e.value,0)===43||Ir(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!Ht(Ir(e.value,r)))return 0;return Rl(n,e.value,r)?0:1}function cP(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:ur(oo(null),ro),angle:ur(oo(t),ro),decibel:ur(oo(n),ro),frequency:ur(oo(r),ro),flex:ur(oo(o),ro),length:ur(Xb(oo(i)),ro),resolution:ur(oo(s),ro),semitones:ur(oo(a),ro),time:ur(oo(u),ro)}}function uP(e){let t=new Set;for(let n of lP)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 Qb(e){return{...sP,...aP,...cP(e),"attr-unit":uP(e)}}var gp,fp,mp,GA,qA,YA,hp,xp,Vb,KA,ro,yp,sP,aP,lP,Jb=U(()=>{"use strict";Bl();Ub();Wb();lr();gp=["calc(","-moz-calc(","-webkit-calc("],fp=["min(","max(","clamp("],mp=["round(","mod(","rem("],GA=["sin(","cos(","tan("],qA=["asin(","acos(","atan(","atan2("],YA=["pow(","sqrt(","log(","exp(","sign("],hp=["hypot("],xp=["abs("],Vb=[...gp,...fp,...mp,...GA,...YA,...hp,...xp],KA=[...gp,...fp,...mp,...hp,...xp],ro=[...gp,...fp,...mp,...qA,...hp,...xp],yp=new Map([[2,22],[21,22],[19,20],[23,24]]);sP={"ident-token":Lt(1),"function-token":Lt(2),"at-keyword-token":Lt(3),"hash-token":Lt(4),"string-token":Lt(5),"bad-string-token":Lt(6),"url-token":Lt(7),"bad-url-token":Lt(8),"delim-token":Lt(9),"number-token":Lt(10),"percentage-token":Lt(11),"dimension-token":Lt(12),"whitespace-token":Lt(13),"CDO-token":Lt(14),"CDC-token":Lt(15),"colon-token":Lt(16),"semicolon-token":Lt(17),"comma-token":Lt(18),"[-token":Lt(19),"]-token":Lt(20),"(-token":Lt(21),")-token":Lt(22),"{-token":Lt(23),"}-token":Lt(24)},aP={string:Lt(5),ident:Lt(1),percentage:ur(rP,KA),zero:Xb(),number:ur(oP,Vb),integer:ur(iP,Vb),"custom-ident":QA,"dashed-ident":Kb,"custom-property-name":JA,"hex-color":ZA,"id-selector":eP,"an-plus-b":up,urange:dp,"declaration-value":tP,"any-value":nP},lP=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var zl={};ye(zl,{angle:()=>dP,decibel:()=>xP,flex:()=>hP,frequency:()=>fP,length:()=>pP,resolution:()=>mP,semitones:()=>yP,time:()=>gP});var pP,dP,gP,fP,mP,hP,xP,yP,Zb=U(()=>{"use strict";pP=["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"],dP=["deg","grad","rad","turn"],gP=["s","ms"],fP=["hz","khz"],mP=["dpi","dpcm","dppx","x"],hP=["fr"],xP=["db"],yP=["st"]});function e0(e,t,n){return Object.assign(ei("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
11
11
  `+t+`
12
- --`+new Array((n||t.length)+1).join("-")+"^"})}var t0=U(()=>{"use strict";Sl()});var bP,SP,wP,vP,kP,n0,zl,r0=U(()=>{"use strict";t0();bP=9,SP=10,wP=12,vP=13,kP=32,n0=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),zl=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&&n0[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!==vP&&n!==SP&&n!==wP&&n!==kP&&n!==bP)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 e0(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||n0[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 c0(e){let t=null,n=null;return e.eat(_l),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===Cp?(e.pos++,e.skipWs(),e.charCode()!==wp&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(wp),{min:Number(t),max:n?Number(n):0}}function PP(e){let t=null,n=!1;switch(e.charCode()){case g0:e.pos++,t={min:0,max:0};break;case kp:e.pos++,t={min:1,max:0};break;case Ol:e.pos++,t={min:0,max:1};break;case vp:e.pos++,n=!0,e.charCode()===_l?t=c0(e):e.charCode()===Ol?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case _l:t=c0(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function oo(e,t){let n=PP(e);return n!==null?(n.term=t,e.charCode()===vp&&e.charCodeAt(e.pos-1)===kp||e.charCode()===Ol&&e.charCodeAt(e.pos-1)===wp?oo(e,n):n):t}function bp(e){let t=e.peek();return t===""?null:oo(e,{type:"Token",value:t})}function LP(e){let t;return e.eat(Tp),e.eat(Nl),t=e.scanWord(),e.eat(Nl),e.eat(Sp),oo(e,{type:"Property",name:t})}function MP(e){let t=null,n=null,r=1;return e.eat(Bs),e.charCode()===i0&&(e.peek(),r=-1),r==-1&&e.charCode()===a0?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Cp),e.skipWs(),e.charCode()===a0?e.peek():(r=1,e.charCode()===i0&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Di),{type:"Range",min:t,max:n}}function BP(e){let t,n=null;if(e.eat(Tp),t=e.scanWord(),t==="boolean-expr"){e.eat(Bs);let r=$l(e,Di);return e.eat(Di),e.eat(Sp),oo(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===p0&&e.nextCharCode()===d0&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Bs&&(e.skipWs(),n=MP(e)),e.eat(Sp),oo(e,{type:"Type",name:t,opts:n})}function DP(e){let t=e.scanWord();return e.charCode()===p0?(e.pos++,{type:"Function",name:t}):oo(e,{type:"Keyword",name:t})}function RP(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)=>l0[o]-l0[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 $l(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?$l(e,d0):NP(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:RP(r,n)||" ",disallowEmpty:!1,explicit:!1}}function zP(e){let t;return e.eat(Bs),t=$l(e,Di),e.eat(Di),t.explicit=!0,e.charCode()===u0&&(e.pos++,t.disallowEmpty=!0),t}function NP(e){let t=e.charCode();switch(t){case Di:break;case Bs:return oo(e,zP(e));case Tp:return e.nextCharCode()===Nl?LP(e):BP(e);case s0:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===s0?2:1))};case o0:return e.pos++,e.eat(o0),{type:"Combinator",value:"&&"};case Cp:return e.pos++,{type:"Comma"};case Nl:return oo(e,{type:"String",value:e.scanString()});case EP:case CP:case TP:case FP:case IP:return{type:"Spaces",value:e.scanSpaces()};case AP:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):bp(e);case g0:case kp:case Ol:case vp:case u0:break;case _l:if(t=e.nextCharCode(),t<48||t>57)return bp(e);break;default:return e.isNameCharCode(t)?DP(e):bp(e)}}function Ds(e){let t=new zl(e),n=$l(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var CP,TP,IP,FP,EP,u0,vp,o0,Nl,p0,d0,g0,kp,Cp,i0,Tp,Sp,Ol,AP,Bs,Di,_l,s0,wp,a0,l0,Ip=U(()=>{"use strict";r0();CP=9,TP=10,IP=12,FP=13,EP=32,u0=33,vp=35,o0=38,Nl=39,p0=40,d0=41,g0=42,kp=43,Cp=44,i0=45,Tp=60,Sp=62,Ol=63,AP=64,Bs=91,Di=93,_l=123,s0=124,wp=125,a0=8734,l0={" ":1,"&&":2,"||":3,"|":4}});function f0(e){return typeof e=="function"?e:Rs}function Fp(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=Rs,i=Rs;if(typeof t=="function"?o=t:t&&(o=f0(t.enter),i=f0(t.leave)),o===Rs&&i===Rs)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Rs,m0=U(()=>{"use strict";Rs=function(){}});var Ep=U(()=>{"use strict";ip();Ip();m0()});function $P(e){let t=[];return Fo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function h0(e,t){return typeof e=="string"?$P(e):t.generate(e,_P)}var _P,x0=U(()=>{"use strict";lr();_P={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 kn(e,t,n){return t===mt&&n===kt||e===mt&&t===mt&&n===mt?e:(e.type==="If"&&e.else===kt&&t===mt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function b0(e){return e.length>2&&e.charCodeAt(e.length-2)===UP&&e.charCodeAt(e.length-1)===jP}function y0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&b0(e.name)}function Ao(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function zs(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=zs(e.match,t,n),e.then=zs(e.then,t,n),e.else=zs(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function Ap(e,t,n){switch(e){case" ":{let r=mt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=kn(i,r,kt)}return r}case"|":{let r=kt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(y0(s)&&(o===null&&i>0&&y0(t[i-1])&&(o=Object.create(null),r=kn({type:"Enum",map:o},mt,r)),o!==null)){let a=(b0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=kn(s,mt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Ap(e,t.filter(function(a){return a!==i}),!1):s=mt,r=kn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?mt:kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Ap(e,t.filter(function(a){return a!==i}),!0):s=mt,r=kn(i,s,r)}return r}}}function HP(e){let t=mt,n=Ri(e.term);if(e.max===0)n=kn(n,Ul,kt),t=kn(n,null,kt),t.then=kn(mt,mt,t),e.comma&&(t.then.else=kn({type:"Comma",syntax:e},t,kt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==mt&&(t=kn({type:"Comma",syntax:e},t,kt)),t=kn(n,kn(mt,mt,t),kt);if(e.min===0)t=kn(mt,mt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==mt&&(t=kn({type:"Comma",syntax:e},t,kt)),t=kn(n,t,kt);return t}function Ri(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=Ap(e.combinator,e.terms.map(Ri),!1);return e.disallowEmpty&&(t=kn(t,Ul,kt)),t}case"Multiplier":return HP(e);case"Boolean":{let t=Ri(e.term),n=Ri(Ao([Ao([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),Ao([{type:"Type",name:"!boolean-group"},Ao([{type:"Multiplier",comma:!1,min:0,max:0,term:Ao([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:Ao([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=Ri(Ao([{type:"Type",name:"!term"},Ao([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return zs(r,{"!term":t,"!self":n}),zs(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 Ns(e,t){return typeof e=="string"&&(e=Ds(e)),{type:"MatchGraph",match:Ri(e),syntax:t||null,source:e}}var mt,kt,Ul,UP,jP,Pp=U(()=>{"use strict";Ip();mt={type:"Match"},kt={type:"Mismatch"},Ul={type:"DisallowEmpty"},UP=40,jP=41});function KP(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function Lp(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 XP(e){return e.type!==9?!1:e.value!=="?"}function k0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||XP(e)}function C0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function QP(e,t,n){function r(){do v++,F=v<e.length?e[v]:null;while(F!==null&&(F.type===13||F.type===25))}function o($){let L=v+$;return L<e.length?e[L]:null}function i($,L){return{nextState:$,matchStack:_,syntaxStack:d,thenStack:g,tokenIndex:v,prev:L}}function s($){g={nextState:$,matchStack:_,syntaxStack:d,prev:g}}function a($){p=i($,p)}function u(){_={type:VP,syntax:t.syntax,token:F,prev:_},r(),m=null,v>D&&(D=v)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},_={type:Mp,syntax:t.syntax,token:_.token,prev:_}}function l(){_.type===Mp?_=_.prev:_={type:T0,syntax:d.syntax,token:_.token,prev:_},d=d.prev}let d=null,g=null,p=null,m=null,b=0,T=null,F=null,v=-1,D=0,_={type:WP,syntax:null,token:null,prev:null};for(r();T===null&&++b<v0;)switch(t.type){case"Match":if(g===null){if(F!==null&&(v!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=kt;break}T=w0;break}if(t=g.nextState,t===Ul)if(g.matchStack===_){t=kt;break}else t=mt;for(;g.syntaxStack!==d;)l();g=g.prev;break;case"Mismatch":if(m!==null&&m!==!1)(p===null||v>p.tokenIndex)&&(p=m,m=!1);else if(p===null){T=GP;break}t=p.nextState,g=p.thenStack,d=p.syntaxStack,_=p.matchStack,v=p.tokenIndex,F=v<e.length?e[v]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==kt&&a(t.else),t.then!==mt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let R=t.syntax.terms;if(t.index===R.length){if(t.mask===0||t.syntax.all){t=kt;break}t=mt;break}if(t.mask===(1<<R.length)-1){t=mt;break}for(;t.index<R.length;t.index++){let h=1<<t.index;if((t.mask&h)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|h}),t=R[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let R=F.value.toLowerCase();if(R.indexOf("\\")!==-1&&(R=R.replace(/\\[09].*$/,"")),S0.call(t.map,R)){t=t.map[R];break}}t=kt;break;case"Generic":{let R=d!==null?d.opts:null,h=v+Math.floor(t.fn(F,o,R));if(!isNaN(h)&&h>v){for(;v<h;)u();t=mt}else t=kt;break}case"Type":case"Property":{let R=t.type==="Type"?"types":"properties",h=S0.call(n,R)?n[R][t.name]:null;if(!h||!h.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(m!==!1&&F!==null&&t.type==="Type"&&(t.name==="custom-ident"&&F.type===1||t.name==="length"&&F.value==="0")){m===null&&(m=i(t,p)),t=kt;break}c(),t=h.matchRef||h.match;break}case"Keyword":{let R=t.name;if(F!==null){let h=F.value;if(h.indexOf("\\")!==-1&&(h=h.replace(/\\[09].*$/,"")),Lp(h,R)){u(),t=mt;break}}t=kt;break}case"AtKeyword":case"Function":if(F!==null&&Lp(F.value,t.name)){u(),t=mt;break}t=kt;break;case"Token":if(F!==null&&F.value===t.value){u(),t=mt;break}t=kt;break;case"Comma":F!==null&&F.type===18?k0(_.token)?t=kt:(u(),t=C0(F)?kt:mt):t=k0(_.token)||C0(F)?mt:kt;break;case"String":let $="",L=v;for(;L<e.length&&$.length<t.value.length;L++)$+=e[L].value;if(Lp($,t.value)){for(;v<L;)u();t=mt}else t=kt;break;default:throw new Error("Unknown node type: "+t.type)}switch(YP+=b,T){case null:console.warn("[csstree-match] BREAK after "+v0+" iterations"),T=qP,_=null;break;case w0:for(;d!==null;)l();break;default:_=null}return{tokens:e,reason:T,iterations:b,match:_,longestMatch:D}}function Bp(e,t,n){let r=QP(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=KP(o).prev;o!==null;){switch(o.type){case Mp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case T0: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 S0,WP,VP,Mp,T0,w0,GP,qP,v0,YP,I0=U(()=>{"use strict";Pp();({hasOwnProperty:S0}=Object.prototype),WP=0,VP=1,Mp=2,T0=3,w0="Match",GP="Mismatch",qP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",v0=15e3,YP=0});var Rp={};ye(Rp,{getTrace:()=>F0,isKeyword:()=>e2,isProperty:()=>ZP,isType:()=>JP});function F0(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 JP(e,t){return Dp(this,e,n=>n.type==="Type"&&n.name===t)}function ZP(e,t){return Dp(this,e,n=>n.type==="Property"&&n.name===t)}function e2(e){return Dp(this,e,t=>t.type==="Keyword")}function Dp(e,t,n){let r=F0.call(e,t);return r===null?!1:r.some(n)}var E0=U(()=>{"use strict"});function A0(e){return"node"in e?e.node:A0(e.match[0])}function P0(e){return"node"in e?e.node:P0(e.match[e.match.length-1])}function zp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=A0(a),c=P0(a);e.syntax.walk(t,function(l,d,g){if(l===u){let p=new Zn;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:g,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var L0=U(()=>{"use strict";Ts()});function Np(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function M0(e){return!!e&&Np(e.offset)&&Np(e.line)&&Np(e.column)}function t2(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(Os.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(!M0(r.loc.start))i+=".start";else if(!M0(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 Zn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Os.call(t,i)&&Os.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function B0(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<"+(B0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function n2(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Os.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=B0(s,e+"."+i)}return{docs:o,check:t2(e,r)}}function D0(e){let t={};if(e.node){for(let n in e.node)if(Os.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=n2(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Os,R0=U(()=>{"use strict";Ts();({hasOwnProperty:Os}=Object.prototype)});function Op(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:Ai(e[o].syntax,{compact:t}));return r}function r2(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:Ai(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&Op(i.descriptors,t,n)};return r}function o2(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function i2(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function Fr(e,t,n){return{matched:e,iterations:n,error:t,...Rp}}function zi(e,t,n,r){let o=h0(n,e.syntax),i;return o2(o)?Fr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=Bp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=Bp(o,t.match,e),!i.match)?Fr(null,new Ob(i.reason,t.syntax,n,i),i.iterations):Fr(i.match,null,i.iterations))}var _s,z0=U(()=>{"use strict";_b();Ll();Ml();Jb();Zb();Ep();x0();Pp();I0();E0();L0();R0();_s=class{constructor(t,n,r){if(this.cssWideKeywords=Mi,this.syntax=n,this.generic=!1,this.units={...Rl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||D0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(Rl))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(Qb(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=Ns(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=Ns(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ds(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Ns(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=i2(a)?Ns({...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 Pi("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&&!zi(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=Al(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 Pi("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new Pi("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return Fr(null,r);let o=this.getAtrule(t);return o.prelude?zi(this,o.prelude,n||"",!1):Fr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return Fr(null,o);let i=this.getAtrule(t),s=Al(n);return zi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?Fr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(sp(t).custom)return Fr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?Fr(null,r):zi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?zi(this,r,n,!1):Fr(null,new Pi("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?Fr(null,new Pi("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),zi(this,t,n,!1))}findValueFragments(t,n,r,o){return zp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return zp(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=Al(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=sp(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&&Fp(d.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let p=g.type==="Type"?u.types:u.properties,m=g.type==="Type"?o:i;hasOwnProperty.call(p,g.name)?n(u,g.name,m,p[g.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(g.name,g.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:r2(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function _p(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function s2(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function $p(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?s2(i,n):i};return r}function $s(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?_p(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?_p(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]=_p(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=$p(e[r],o);break;case"atrule":case"pseudo":n[r]=$p(e[r],o,["parse"]);break;case"node":n[r]=$p(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var N0=U(()=>{"use strict"});function O0(e){let t=Zy(e),n=Rb(e),r=Fb(e),{fromPlainObject:o,toPlainObject:i}=Ab(n),s={lexer:null,createLexer:a=>new _s(a,s,s.lexer.structure),tokenize:Fo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=$s({},e);return O0(typeof a=="function"?a(u):$s(u,a))}};return s.lexer=new _s({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var _0,$0=U(()=>{"use strict";lr();eb();Eb();Pb();zb();z0();N0();_0=e=>O0($s({},e))});var U0,j0=U(()=>{"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 Hp={};ye(Hp,{generate:()=>u2,name:()=>l2,parse:()=>jp,structure:()=>c2});function Hl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Ur||r===er)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)Ht(this.charCodeAt(n))||this.error("Integer is expected",n)}function Ni(e){return Hl.call(this,0,e)}function Po(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case jl:n="N is expected";break;case er:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Up(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Ur,e)||this.isDelim(er,e)){t=this.isDelim(Ur,e)?Ur:er;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Ni.call(this,ti))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Ur&&n!==er&&this.error("Number sign is expected")),Ni.call(this,t!==0),t===er?"-"+this.consume(10):this.consume(10)}function jp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Ni.call(this,a2),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,er))switch(t="-1",Po.call(this,1,jl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Up.call(this);break;case 3:Po.call(this,2,er),this.next(),this.skipSC(),Ni.call(this,ti),n="-"+this.consume(10);break;default:Po.call(this,2,er),Hl.call(this,3,ti),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Ur)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Ur)&&(r=1,this.next()),Po.call(this,0,jl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Up.call(this);break;case 2:Po.call(this,1,er),this.next(),this.skipSC(),Ni.call(this,ti),n="-"+this.consume(10);break;default:Po.call(this,1,er),Hl.call(this,2,ti),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Ur||r===er,i=this.tokenStart+o;for(;i<this.tokenEnd&&Ht(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),Po.call(this,i-this.tokenStart,jl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Up.call(this)):(Po.call(this,i-this.tokenStart+1,er),i+2===this.tokenEnd?(this.next(),this.skipSC(),Ni.call(this,ti),n="-"+this.consume(10)):(Hl.call(this,i-this.tokenStart+2,ti),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Ur&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Ur&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function u2(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 Ur,er,jl,ti,a2,l2,c2,Wp=U(()=>{"use strict";lr();Ur=43,er=45,jl=110,ti=!0,a2=!1;l2="AnPlusB",c2={a:[String,null],b:[String,null]}});var Gp={};ye(Gp,{generate:()=>m2,name:()=>d2,parse:()=>Vp,structure:()=>f2,walkContext:()=>g2});function H0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function p2(){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 Vp(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),H0):o=H0.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(p2.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function m2(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var d2,g2,f2,qp=U(()=>{"use strict";d2="Atrule",g2="atrule",f2={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var Kp={};ye(Kp,{generate:()=>b2,name:()=>h2,parse:()=>Yp,structure:()=>y2,walkContext:()=>x2});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 b2(e){this.children(e)}var h2,x2,y2,Xp=U(()=>{"use strict";h2="AtrulePrelude",x2="atrulePrelude",y2={children:[[]]}});var Zp={};ye(Zp,{generate:()=>F2,name:()=>T2,parse:()=>Jp,structure:()=>I2});function k2(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(W0)?(t=!0,this.next()):this.isDelim(Qp)||this.eat(1),this.isDelim(Qp)?this.charCodeAt(this.tokenStart+1)!==Wl?(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 C2(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Wl&&t!==v2&&t!==w2&&t!==S2&&t!==W0&&t!==Qp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Wl&&(this.isDelim(Wl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function Jp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=k2.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=C2.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 F2(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 S2,W0,Wl,w2,Qp,v2,T2,I2,ed=U(()=>{"use strict";S2=36,W0=42,Wl=61,w2=94,Qp=124,v2=126;T2="AttributeSelector",I2={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var nd={};ye(nd,{generate:()=>B2,name:()=>P2,parse:()=>td,structure:()=>M2,walkContext:()=>L2});function q0(){return this.Raw(null,!0)}function V0(){return this.parseWithFallback(this.Rule,q0)}function G0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function A2(){if(this.tokenType===17)return G0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,G0);return this.tokenType===17&&this.next(),e}function td(e){let t=e?A2:V0,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),q0));break;default:e&&this.isDelim(E2)?r.push(V0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function B2(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var E2,P2,L2,M2,rd=U(()=>{"use strict";E2=38;P2="Block",L2="block",M2={children:[["Atrule","Rule","Declaration"]]}});var id={};ye(id,{generate:()=>z2,name:()=>D2,parse:()=>od,structure:()=>R2});function od(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 z2(e){this.token(9,"["),this.children(e),this.token(9,"]")}var D2,R2,sd=U(()=>{"use strict";D2="Brackets",R2={children:[[]]}});var ld={};ye(ld,{generate:()=>_2,name:()=>N2,parse:()=>ad,structure:()=>O2});function ad(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function _2(){this.token(15,"-->")}var N2,O2,cd=U(()=>{"use strict";N2="CDC",O2=[]});var pd={};ye(pd,{generate:()=>j2,name:()=>$2,parse:()=>ud,structure:()=>U2});function ud(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function j2(){this.token(14,"<!--")}var $2,U2,dd=U(()=>{"use strict";$2="CDO",U2=[]});var fd={};ye(fd,{generate:()=>G2,name:()=>W2,parse:()=>gd,structure:()=>V2});function gd(){return this.eatDelim(H2),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function G2(e){this.token(9,"."),this.token(1,e.name)}var H2,W2,V2,md=U(()=>{"use strict";H2=46,W2="ClassSelector",V2={name:String}});var xd={};ye(xd,{generate:()=>J2,name:()=>X2,parse:()=>hd,structure:()=>Q2});function hd(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case Y2:case q2:case K2:this.next();break;case Y0:this.next(),this.eatIdent("deep"),this.eatDelim(Y0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function J2(e){this.tokenize(e.name)}var q2,Y0,Y2,K2,X2,Q2,yd=U(()=>{"use strict";q2=43,Y0=47,Y2=62,K2=126,X2="Combinator",Q2={name:String}});var Sd={};ye(Sd,{generate:()=>rL,name:()=>tL,parse:()=>bd,structure:()=>nL});function bd(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===Z2&&this.charCodeAt(t-1)===eL&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function rL(e){this.token(25,"/*"+e.value+"*/")}var Z2,eL,tL,nL,wd=U(()=>{"use strict";Z2=42,eL=47,tL="Comment",nL={value:String}});var kd={};ye(kd,{generate:()=>lL,name:()=>iL,parse:()=>vd,structure:()=>sL});function K0(e){return this.lookupTypeNonSC(1)===1&&oL.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function vd(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(()=>aL[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 lL(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var oL,iL,sL,aL,Cd=U(()=>{"use strict";oL=new Set([16,22,0]),iL="Condition",sL={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};aL={media:K0,container:K0,supports(){return this.SupportsDeclaration()}}});var Id={};ye(Id,{generate:()=>SL,name:()=>xL,parse:()=>Td,structure:()=>bL,walkContext:()=>yL});function fL(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function mL(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function hL(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(Q0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function Td(){let e=this.tokenStart,t=this.tokenIndex,n=wL.call(this),r=Pl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?mL:fL,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(hL,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(Q0)&&(s=vL.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 SL(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 wL(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case dL:case uL:case gL:case cL:case pL: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 vL(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var Q0,cL,uL,pL,dL,gL,X0,xL,yL,bL,Fd=U(()=>{"use strict";Ll();Q0=33,cL=35,uL=36,pL=38,dL=42,gL=43,X0=47;xL="Declaration",yL="declaration",bL={important:[Boolean,String],property:String,value:["Value","Raw"]}});var Pd={};ye(Pd,{generate:()=>IL,name:()=>CL,parse:()=>Ad,structure:()=>TL});function Ed(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Ad(){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),Ed));break;default:this.isDelim(kL)?e.push(this.parseWithFallback(this.Rule,Ed)):e.push(this.parseWithFallback(this.Declaration,Ed))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function IL(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var kL,CL,TL,Ld=U(()=>{"use strict";kL=38;CL="DeclarationList",TL={children:[["Declaration","Atrule","Rule"]]}});var Bd={};ye(Bd,{generate:()=>AL,name:()=>FL,parse:()=>Md,structure:()=>EL});function Md(){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 AL(e){this.token(12,e.value+e.unit)}var FL,EL,Dd=U(()=>{"use strict";FL="Dimension",EL={value:String,unit:String}});var zd={};ye(zd,{generate:()=>BL,name:()=>LL,parse:()=>Rd,structure:()=>ML});function Rd(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(PL)&&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 BL(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var PL,LL,ML,Nd=U(()=>{"use strict";PL=47,LL="Feature",ML={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var _d={};ye(_d,{generate:()=>NL,name:()=>DL,parse:()=>Od,structure:()=>RL});function zL(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=zL.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 NL(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var DL,RL,$d=U(()=>{"use strict";DL="FeatureFunction",RL={kind:String,feature:String,value:["Declaration","Selector"]}});var Hd={};ye(Hd,{generate:()=>jL,name:()=>$L,parse:()=>jd,structure:()=>UL});function Ud(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(J0,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(J0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function eS(e){if(this.skipSC(),this.isDelim(OL)||this.isDelim(_L)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(Z0)?(this.next(),t+"="):t}if(this.isDelim(Z0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function jd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Ud.call(this),r=eS.call(this,n.type==="Identifier"),o=Ud.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=eS.call(this),s=Ud.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 jL(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 J0,OL,Z0,_L,$L,UL,Wd=U(()=>{"use strict";J0=47,OL=60,Z0=61,_L=62,$L="FeatureRange",UL={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 Gd={};ye(Gd,{generate:()=>GL,name:()=>HL,parse:()=>Vd,structure:()=>VL,walkContext:()=>WL});function Vd(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 GL(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var HL,WL,VL,qd=U(()=>{"use strict";HL="Function",WL="function",VL={name:String,children:[[]]}});var Kd={};ye(Kd,{generate:()=>KL,name:()=>qL,parse:()=>Yd,structure:()=>YL});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 KL(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var qL,YL,Xd=U(()=>{"use strict";qL="GeneralEnclosed",YL={kind:String,function:[String,null],children:[[]]}});var Jd={};ye(Jd,{generate:()=>ZL,name:()=>QL,parse:()=>Qd,structure:()=>JL,xxx:()=>XL});function Qd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function ZL(e){this.token(4,"#"+e.value)}var XL,QL,JL,Zd=U(()=>{"use strict";XL="XXX",QL="Hash",JL={value:String}});var tg={};ye(tg,{generate:()=>nM,name:()=>eM,parse:()=>eg,structure:()=>tM});function eg(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function nM(e){this.token(1,e.name)}var eM,tM,ng=U(()=>{"use strict";eM="Identifier",tM={name:String}});var og={};ye(og,{generate:()=>iM,name:()=>rM,parse:()=>rg,structure:()=>oM});function rg(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function iM(e){this.token(9,"#"+e.name)}var rM,oM,ig=U(()=>{"use strict";rM="IdSelector",oM={name:String}});var ag={};ye(ag,{generate:()=>cM,name:()=>aM,parse:()=>sg,structure:()=>lM});function sg(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(sM);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function cM(e){this.tokenize(e.name)}var sM,aM,lM,lg=U(()=>{"use strict";sM=46,aM="Layer",lM={name:String}});var ug={};ye(ug,{generate:()=>dM,name:()=>uM,parse:()=>cg,structure:()=>pM});function cg(){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 dM(e){this.children(e,()=>this.token(18,","))}var uM,pM,pg=U(()=>{"use strict";uM="LayerList",pM={children:[["Layer"]]}});var gg={};ye(gg,{generate:()=>mM,name:()=>gM,parse:()=>dg,structure:()=>fM});function dg(){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 mM(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 gM,fM,fg=U(()=>{"use strict";gM="MediaQuery",fM={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var hg={};ye(hg,{generate:()=>yM,name:()=>hM,parse:()=>mg,structure:()=>xM});function mg(){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 yM(e){this.children(e,()=>this.token(18,","))}var hM,xM,xg=U(()=>{"use strict";hM="MediaQueryList",xM={children:[["MediaQuery"]]}});var bg={};ye(bg,{generate:()=>vM,name:()=>SM,parse:()=>yg,structure:()=>wM});function yg(){let e=this.tokenStart;return this.eatDelim(bM),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function vM(){this.token(9,"&")}var bM,SM,wM,Sg=U(()=>{"use strict";bM=38,SM="NestingSelector",wM={}});var vg={};ye(vg,{generate:()=>TM,name:()=>kM,parse:()=>wg,structure:()=>CM});function wg(){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 TM(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var kM,CM,kg=U(()=>{"use strict";kM="Nth",CM={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var Tg={};ye(Tg,{generate:()=>EM,name:()=>IM,parse:()=>Cg,structure:()=>FM});function Cg(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function EM(e){this.token(10,e.value)}var IM,FM,Ig=U(()=>{"use strict";IM="Number",FM={value:String}});var Eg={};ye(Eg,{generate:()=>LM,name:()=>AM,parse:()=>Fg,structure:()=>PM});function Fg(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function LM(e){this.tokenize(e.value)}var AM,PM,Ag=U(()=>{"use strict";AM="Operator",PM={value:String}});var Lg={};ye(Lg,{generate:()=>DM,name:()=>MM,parse:()=>Pg,structure:()=>BM});function Pg(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 DM(e){this.token(21,"("),this.children(e),this.token(22,")")}var MM,BM,Mg=U(()=>{"use strict";MM="Parentheses",BM={children:[[]]}});var Dg={};ye(Dg,{generate:()=>NM,name:()=>RM,parse:()=>Bg,structure:()=>zM});function Bg(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function NM(e){this.token(11,e.value+"%")}var RM,zM,Rg=U(()=>{"use strict";RM="Percentage",zM={value:String}});var Ng={};ye(Ng,{generate:()=>UM,name:()=>OM,parse:()=>zg,structure:()=>$M,walkContext:()=>_M});function zg(){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 UM(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var OM,_M,$M,Og=U(()=>{"use strict";OM="PseudoClassSelector",_M="function",$M={name:String,children:[["Raw"],null]}});var $g={};ye($g,{generate:()=>VM,name:()=>jM,parse:()=>_g,structure:()=>WM,walkContext:()=>HM});function _g(){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 VM(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 jM,HM,WM,Ug=U(()=>{"use strict";jM="PseudoElementSelector",HM="function",WM={name:String,children:[["Raw"],null]}});var Hg={};ye(Hg,{generate:()=>YM,name:()=>GM,parse:()=>jg,structure:()=>qM});function nS(){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 jg(){let e=this.tokenStart,t=nS.call(this),n=null;return this.skipSC(),this.isDelim(tS)&&(this.eatDelim(tS),n=nS.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function YM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var tS,GM,qM,Wg=U(()=>{"use strict";tS=47;GM="Ratio",qM={left:["Number","Function"],right:["Number","Function",null]}});var Gg={};ye(Gg,{generate:()=>JM,name:()=>XM,parse:()=>Vg,structure:()=>QM});function KM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function Vg(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=KM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function JM(e){this.tokenize(e.value)}var XM,QM,qg=U(()=>{"use strict";XM="Raw",QM={value:String}});var Kg={};ye(Kg,{generate:()=>rB,name:()=>eB,parse:()=>Yg,structure:()=>nB,walkContext:()=>tB});function rS(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function ZM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function Yg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(ZM,rS):n=rS.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function rB(e){this.node(e.prelude),this.node(e.block)}var eB,tB,nB,Xg=U(()=>{"use strict";eB="Rule",tB="rule",nB={prelude:["SelectorList","Raw"],block:["Block"]}});var Jg={};ye(Jg,{generate:()=>sB,name:()=>oB,parse:()=>Qg,structure:()=>iB});function Qg(){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 sB(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 oB,iB,Zg=U(()=>{"use strict";oB="Scope",iB={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var tf={};ye(tf,{generate:()=>cB,name:()=>aB,parse:()=>ef,structure:()=>lB});function ef(){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 cB(e){this.children(e)}var aB,lB,nf=U(()=>{"use strict";aB="Selector",lB={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var of={};ye(of,{generate:()=>gB,name:()=>uB,parse:()=>rf,structure:()=>dB,walkContext:()=>pB});function rf(){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 gB(e){this.children(e,()=>this.token(18,","))}var uB,pB,dB,sf=U(()=>{"use strict";uB="SelectorList",pB="selector",dB={children:[["Selector","Raw"]]}});function Vl(e){let t=e.length,n=e.charCodeAt(0),r=n===oS||n===iS?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===af){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),zn(af,a)){let u=s-1,c=Zr(e,u);s=c-1,i+=fl(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function sS(e,t){let n=t?"'":'"',r=t?iS:oS,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===af?(o+="\\"+e.charAt(s),i=!1):(i&&(Nn(a)||_r(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var af,oS,iS,Gl=U(()=>{"use strict";lr();af=92,oS=34,iS=39});var cf={};ye(cf,{generate:()=>hB,name:()=>fB,parse:()=>lf,structure:()=>mB});function lf(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Vl(this.consume(5))}}function hB(e){this.token(5,sS(e.value))}var fB,mB,uf=U(()=>{"use strict";Gl();fB="String",mB={value:String}});var df={};ye(df,{generate:()=>wB,name:()=>yB,parse:()=>pf,structure:()=>SB,walkContext:()=>bB});function lS(){return this.Raw(null,!1)}function pf(){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)!==xB){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,lS);break;default:n=this.parseWithFallback(this.Rule,lS)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function wB(e){this.children(e)}var xB,yB,bB,SB,gf=U(()=>{"use strict";xB=33;yB="StyleSheet",bB="stylesheet",SB={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var mf={};ye(mf,{generate:()=>CB,name:()=>vB,parse:()=>ff,structure:()=>kB});function ff(){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 CB(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var vB,kB,hf=U(()=>{"use strict";vB="SupportsDeclaration",kB={declaration:"Declaration"}});var bf={};ye(bf,{generate:()=>EB,name:()=>IB,parse:()=>yf,structure:()=>FB});function xf(){this.tokenType!==1&&this.isDelim(TB)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function yf(){let e=this.tokenStart;return this.isDelim(cS)?(this.next(),xf.call(this)):(xf.call(this),this.isDelim(cS)&&(this.next(),xf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function EB(e){this.tokenize(e.name)}var TB,cS,IB,FB,Sf=U(()=>{"use strict";TB=42,cS=124;IB="TypeSelector",FB={name:String}});var kf={};ye(kf,{generate:()=>BB,name:()=>LB,parse:()=>vf,structure:()=>MB});function Us(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===pS&&t&&n!==0)return Us.call(this,e+n+1,!1),-1;Nn(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 ql(e){let t=0;for(;this.isDelim(wf);)++t>e&&this.error("Too many question marks"),this.next()}function AB(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===uS?"Plus sign":"Hyphen minus")+" is expected")}function PB(){let e=0;switch(this.tokenType){case 10:if(e=Us.call(this,1,!0),this.isDelim(wf)){ql.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){AB.call(this,pS),Us.call(this,1,!1);break}break;case 12:e=Us.call(this,1,!0),e>0&&ql.call(this,6-e);break;default:if(this.eatDelim(uS),this.tokenType===1){e=Us.call(this,0,!0),e>0&&ql.call(this,6-e);break}if(this.isDelim(wf)){this.next(),ql.call(this,5);break}this.error("Hex digit or question mark is expected")}}function vf(){let e=this.tokenStart;return this.eatIdent("u"),PB.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function BB(e){this.tokenize(e.value)}var uS,pS,wf,LB,MB,Cf=U(()=>{"use strict";lr();uS=43,pS=45,wf=63;LB="UnicodeRange",MB={value:String}});function gS(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===dS?t-2:t-1,o="";for(;n<r&&_r(e.charCodeAt(n));)n++;for(;n<r&&_r(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Tf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),zn(Tf,s)){let a=i-1,u=Zr(e,a);i=u-1,o+=fl(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function fS(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===DB||o===Tf||o===RB||o===zB||o===NB||o===dS?(t+="\\"+e.charAt(r),n=!1):(n&&Nn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var DB,Tf,RB,zB,NB,dS,If=U(()=>{"use strict";lr();DB=32,Tf=92,RB=34,zB=39,NB=40,dS=41});var Ef={};ye(Ef,{generate:()=>$B,name:()=>OB,parse:()=>Ff,structure:()=>_B});function Ff(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=gS(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=Vl(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 $B(e){this.token(7,fS(e.value))}var OB,_B,Af=U(()=>{"use strict";If();Gl();OB="Url",_B={value:String}});var Lf={};ye(Lf,{generate:()=>HB,name:()=>UB,parse:()=>Pf,structure:()=>jB});function Pf(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function HB(e){this.children(e)}var UB,jB,Mf=U(()=>{"use strict";UB="Value",jB={children:[[]]}});var Df={};ye(Df,{generate:()=>qB,name:()=>VB,parse:()=>Bf,structure:()=>GB});function Bf(){return this.eat(13),WB}function qB(e){this.token(13,e.value)}var WB,VB,GB,Rf=U(()=>{"use strict";WB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),VB="WhiteSpace",GB={value:String}});var js={};ye(js,{AnPlusB:()=>Hp,Atrule:()=>Gp,AtrulePrelude:()=>Kp,AttributeSelector:()=>Zp,Block:()=>nd,Brackets:()=>id,CDC:()=>ld,CDO:()=>pd,ClassSelector:()=>fd,Combinator:()=>xd,Comment:()=>Sd,Condition:()=>kd,Declaration:()=>Id,DeclarationList:()=>Pd,Dimension:()=>Bd,Feature:()=>zd,FeatureFunction:()=>_d,FeatureRange:()=>Hd,Function:()=>Gd,GeneralEnclosed:()=>Kd,Hash:()=>Jd,IdSelector:()=>og,Identifier:()=>tg,Layer:()=>ag,LayerList:()=>ug,MediaQuery:()=>gg,MediaQueryList:()=>hg,NestingSelector:()=>bg,Nth:()=>vg,Number:()=>Tg,Operator:()=>Eg,Parentheses:()=>Lg,Percentage:()=>Dg,PseudoClassSelector:()=>Ng,PseudoElementSelector:()=>$g,Ratio:()=>Hg,Raw:()=>Gg,Rule:()=>Kg,Scope:()=>Jg,Selector:()=>tf,SelectorList:()=>of,String:()=>cf,StyleSheet:()=>df,SupportsDeclaration:()=>mf,TypeSelector:()=>bf,UnicodeRange:()=>kf,Url:()=>Ef,Value:()=>Lf,WhiteSpace:()=>Df});var zf=U(()=>{"use strict";Wp();qp();Xp();ed();rd();sd();cd();dd();md();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();qg();Xg();Zg();nf();sf();uf();gf();hf();Sf();Cf();Af();Mf();Rf()});var hS,xS=U(()=>{"use strict";Ml();j0();zf();hS={generic:!0,cssWideKeywords:Mi,...U0,node:js}});function Hs(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,JB)&&this.cmpChar(this.tokenStart+1,yS)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===QB||t===KB||t===yS||t===XB)return this.Operator();t===YB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var YB,KB,yS,XB,QB,JB,Nf=U(()=>{"use strict";YB=35,KB=42,yS=43,XB=45,QB=47,JB=117});var bS,SS=U(()=>{"use strict";Nf();bS={getNode:Hs}});function aD(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function lD(){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)===wS&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case nD:case oD:case sD:case rD:return this.Combinator();case wS:return this.ClassSelector();case tD:case iD:return this.TypeSelector();case ZB:return this.IdSelector();case eD:return this.NestingSelector()}break}}}var ZB,eD,tD,nD,rD,wS,oD,iD,sD,vS,kS=U(()=>{"use strict";ZB=35,eD=38,tD=42,nD=43,rD=47,wS=46,oD=62,iD=124,sD=126;vS={onWhiteSpace:aD,getNode:lD}});function CS(){return this.createSingleNodeList(this.Raw(null,!1))}var TS=U(()=>{"use strict"});function IS(){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 FS=U(()=>{"use strict"});function ES(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var AS,PS=U(()=>{"use strict";Nf();TS();FS();AS={getNode:Hs,onWhiteSpace(e,t){ES(e)&&(e.value=" "+e.value),ES(t.last)&&(t.last.value+=" ")},expression:CS,var:IS}});var Of={};ye(Of,{AtrulePrelude:()=>bS,Selector:()=>vS,Value:()=>AS});var LS=U(()=>{"use strict";SS();kS();PS()});var cD,MS,BS=U(()=>{"use strict";cD=new Set(["none","and","not","or"]),MS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);cD.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var DS,RS=U(()=>{"use strict";DS={parse:{prelude:null,block(){return this.Block(!0)}}}});function _f(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 zS,NS,OS=U(()=>{"use strict";zS={layer(){this.skipSC();let e=this.createList(),t=_f.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=_f.call(this,this.Declaration,()=>_f.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},NS={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,zS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,zS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var _S,$S=U(()=>{"use strict";_S={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var US,jS=U(()=>{"use strict";US={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var HS,WS=U(()=>{"use strict";HS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var VS,GS=U(()=>{"use strict";VS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var qS,YS=U(()=>{"use strict";qS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var KS,XS=U(()=>{"use strict";KS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var QS,JS=U(()=>{"use strict";QS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var ZS,ew=U(()=>{"use strict";BS();RS();OS();$S();jS();WS();GS();YS();XS();JS();ZS={container:MS,"font-face":DS,import:NS,layer:_S,media:US,nest:HS,page:VS,scope:qS,"starting-style":KS,supports:QS}});function tw(){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 nw=U(()=>{"use strict"});var ni,$f,uD,pD,Yl,rw,ow=U(()=>{"use strict";nw();ni={parse(){return this.createSingleNodeList(this.SelectorList())}},$f={parse(){return this.createSingleNodeList(this.Selector())}},uD={parse(){return this.createSingleNodeList(this.Identifier())}},pD={parse:tw},Yl={parse(){return this.createSingleNodeList(this.Nth())}},rw={dir:uD,has:ni,lang:pD,matches:ni,is:ni,"-moz-any":ni,"-webkit-any":ni,where:ni,not:ni,"nth-child":Yl,"nth-last-child":Yl,"nth-last-of-type":Yl,"nth-of-type":Yl,slotted:$f,host:$f,"host-context":$f}});var Uf={};ye(Uf,{AnPlusB:()=>jp,Atrule:()=>Vp,AtrulePrelude:()=>Yp,AttributeSelector:()=>Jp,Block:()=>td,Brackets:()=>od,CDC:()=>ad,CDO:()=>ud,ClassSelector:()=>gd,Combinator:()=>hd,Comment:()=>bd,Condition:()=>vd,Declaration:()=>Td,DeclarationList:()=>Ad,Dimension:()=>Md,Feature:()=>Rd,FeatureFunction:()=>Od,FeatureRange:()=>jd,Function:()=>Vd,GeneralEnclosed:()=>Yd,Hash:()=>Qd,IdSelector:()=>rg,Identifier:()=>eg,Layer:()=>sg,LayerList:()=>cg,MediaQuery:()=>dg,MediaQueryList:()=>mg,NestingSelector:()=>yg,Nth:()=>wg,Number:()=>Cg,Operator:()=>Fg,Parentheses:()=>Pg,Percentage:()=>Bg,PseudoClassSelector:()=>zg,PseudoElementSelector:()=>_g,Ratio:()=>jg,Raw:()=>Vg,Rule:()=>Yg,Scope:()=>Qg,Selector:()=>ef,SelectorList:()=>rf,String:()=>lf,StyleSheet:()=>pf,SupportsDeclaration:()=>ff,TypeSelector:()=>yf,UnicodeRange:()=>vf,Url:()=>Ff,Value:()=>Pf,WhiteSpace:()=>Bf});var iw=U(()=>{"use strict";Wp();qp();Xp();ed();rd();sd();cd();dd();md();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();qg();Xg();Zg();nf();sf();uf();gf();hf();Sf();Cf();Af();Mf();Rf()});var sw,aw=U(()=>{"use strict";LS();ew();ow();iw();sw={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:Of,atrule:ZS,pseudo:rw,node:Uf}});var lw,cw=U(()=>{"use strict";zf();lw={node:js}});var uw,pw=U(()=>{"use strict";$0();xS();aw();cw();uw=_0({...hS,...sw,...lw})});var dw=U(()=>{"use strict"});var gw=U(()=>{"use strict"});var jY,fw,HY,WY,VY,mw,GY,qY,YY,KY,XY,QY,hw=U(()=>{"use strict";pw();dw();Ep();Ll();gw();Gl();If();({tokenize:jY,parse:fw,generate:HY,lexer:WY,createLexer:VY,walk:mw,find:GY,findLast:qY,findAll:YY,toPlainObject:KY,fromPlainObject:XY,fork:QY}=uw)});function mD(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function yw(e){try{let t=fw(e.trim(),{context:"value"}),n=[];return mw(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 hD(e,t){let n=mD(e);if(!fD.has(n))return t;let r=yw(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 xw(e,t){let n=t.trim();if(!n)return"";let r=hD(e,n);return yw(r).map(i=>i==="0"?"0px":i).join(" ")}function bw(e,t,n){let r=xw(e,t),o=xw(e,n);return r!==""&&o!==""&&r===o}var fD,Sw=U(()=>{"use strict";hw();fD=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function xD(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function yD(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 ww(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=yD(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return xD(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 ri(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 g=ww(r),p=ww(o);return!!(g===p||n&&bw(n,r,o))}var jf=U(()=>{"use strict";Sw()});function kD(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 vw(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 CD(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 TD(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&&kD(n)||vw(r)||vw(o)||n&&CD(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<Cw:a<kw}return r.includes("%")||o.includes("%")?a<1:!1}function ID(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(vD.some(s=>t.includes(s))||!SD.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!ri(o,i,e.property))}function FD(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 ED(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)<Tw}function AD(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(!wD.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]))>bD)}function PD(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 Ws(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(ri(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(ED(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${Tw}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(TD(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")?Cw:kw}px)`,dismissedBy:"post-ai-validation"}}return PD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:ID(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:AD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:FD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var kw,Cw,Tw,bD,SD,wD,vD,Iw=U(()=>{"use strict";jf();kw=.5,Cw=2,Tw=2,bD=5,SD=["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"],wD=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],vD=["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 Fw(e){let t=e.trim().match(/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(!t)return null;let n=t[1];return n.length===3?[parseInt(n[0]+n[0],16),parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16)]:[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function Ew(e){let t=e.trim().match(/^color\(\s*display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*[\d.]+)?\s*\)$/);if(!t)return null;let n=parseFloat(t[1]),r=parseFloat(t[2]),o=parseFloat(t[3]);if(isNaN(n)||isNaN(r)||isNaN(o))return null;let i=p=>p<=.04045?p/12.92:Math.pow((p+.055)/1.055,2.4),s=i(n),a=i(r),u=i(o),c=1.2249*s-.2247*a+0*u,l=-.042*s+1.0419*a+0*u,d=-.0197*s-.0786*a+1.0983*u,g=p=>{let m=Math.max(0,Math.min(1,p));return m<=.0031308?12.92*m:1.055*Math.pow(m,1/2.4)-.055};return[Math.round(g(c)*255),Math.round(g(l)*255),Math.round(g(d)*255)]}function Aw(e,t,n){let r=F=>{let v=F/255;return v<=.04045?v/12.92:Math.pow((v+.055)/1.055,2.4)},o=r(e),i=r(t),s=r(n),a=o*.4124564+i*.3575761+s*.1804375,u=o*.2126729+i*.7151522+s*.072175,c=o*.0193339+i*.119192+s*.9503041,l=.95047,d=1,g=1.08883,p=F=>F>.008856?Math.cbrt(F):7.787*F+16/116,m=p(a/l),b=p(u/d),T=p(c/g);return[116*b-16,500*(m-b),200*(b-T)]}function LD(e,t){let[n,r,o]=Aw(...e),[i,s,a]=Aw(...t),u=(n+i)/2,c=Math.sqrt(r*r+o*o),l=Math.sqrt(s*s+a*a),d=(c+l)/2,g=.5*(1-Math.sqrt(Math.pow(d,7)/(Math.pow(d,7)+Math.pow(25,7)))),p=(1+g)*r,m=(1+g)*s,b=Math.sqrt(p*p+o*o),T=Math.sqrt(m*m+a*a),F=(b+T)/2,v=(Math.atan2(o,p)*180/Math.PI+360)%360,D=(Math.atan2(a,m)*180/Math.PI+360)%360,_=D-v;Math.abs(_)>180&&(_-=Math.sign(_)*360);let $=i-n,L=T-b,R=2*Math.sqrt(b*T)*Math.sin(_*Math.PI/360),h=Math.abs(v-D)>180?(v+D+360)/2:(v+D)/2,S=1-.17*Math.cos((h-30)*Math.PI/180)+.24*Math.cos(2*h*Math.PI/180)+.32*Math.cos((3*h+6)*Math.PI/180)-.2*Math.cos((4*h-63)*Math.PI/180),w=1+.015*Math.pow(u-50,2)/Math.sqrt(20+Math.pow(u-50,2)),A=1+.045*F,f=1+.015*F*S,k=-2*Math.sqrt(Math.pow(F,7)/(Math.pow(F,7)+Math.pow(25,7)))*Math.sin(60*Math.exp(-Math.pow((h-275)/25,2))*Math.PI/180);return Math.sqrt(Math.pow($/w,2)+Math.pow(L/A,2)+Math.pow(R/f,2)+k*(L/A)*(R/f))}function Pw(e){let t=(e.property||"").toLowerCase();if(!(t.includes("color")||t==="fill"||t==="background"||t==="backgroundcolor"))return!1;let r=String(e.expected||e.suggestedValue||""),o=String(e.actual||e.currentValue||""),i=Fw(r)??Fw(o),s=Ew(r)??Ew(o);return!i||!s||r===o?!1:LD(i,s)<5}function Vs(e){let t=e.severity||"minor";if(t==="minor")return t;if(Pw(e))return"minor";let n=["width","height","size","dimension","dimensions","r","cx","cy"],r=["dimension","layout"],o=new Set((e.property||"").replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)),i=(e.type||"").toLowerCase();if(!(n.some(g=>o.has(g))||r.some(g=>i===g)))return t;let a=String(e.expected||e.suggestedValue||""),u=String(e.actual||e.currentValue||""),c=parseFloat(a.replace(/[^0-9.-]/g,"")),l=parseFloat(u.replace(/[^0-9.-]/g,""));if(isNaN(c)||isNaN(l))return t;let d=Math.abs(c-l);return d<5?"minor":d<10&&t==="critical"?"major":t}function Kl(e,t,n){return e>0?"D":t>0?"C":n>0?"B":"A"}function Xl(e){let t=e.filter(n=>!n.dismissed).map(n=>Vs(n));return Kl(t.filter(n=>n==="critical").length,t.filter(n=>n==="major").length,t.filter(n=>n==="minor").length)}function so(e,t,n){let r=100-n*1-t*3-e*10,o=io[Kl(e,t,n)];return Math.max(0,Math.min(o,r))}var io,Lw=U(()=>{"use strict";io={A:100,B:99,C:89,D:69}});var Mw=U(()=>{"use strict"});var Bw=U(()=>{"use strict"});var Hf=U(()=>{"use strict";jf();Iw();Lw();Mw();Bw()});var _D,$D,fK,Wf=U(()=>{"use strict";_D=["flex","inline-flex"],$D=["grid","inline-grid"],fK=[..._D,...$D]});var Rw=U(()=>{"use strict";Hf();Wf()});var zw=U(()=>{"use strict"});var ln=U(()=>{"use strict";Nu();zy();Ny();Hf();Wf();Rw();zw()});function jD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function tr(e){try{let t=e.map(jD),n=JSON.stringify(t,HD);sessionStorage.setItem(Vf,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function Gf(){try{let e=sessionStorage.getItem(Vf);if(!e)return[];let t=JSON.parse(e,WD);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function Nw(){try{let e=Gf();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&&(tr(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function Ow(){try{sessionStorage.removeItem(Vf),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function HD(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function WD(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Vf,qf=U(()=>{"use strict";Ne();Vf="uicopilot_review_history"});import VD,{createContext as GD,useContext as qD,useReducer as YD,useMemo as _w,useRef as KD,useEffect as XD}from"react";function Ql(e){let t=e.length>$w?e.slice(e.length-$w):e,n=Math.max(0,t.length-QD);return n===0?t:t.map((r,o)=>{if(o>=n)return r;let i=r.storybookImageData?.startsWith("data:"),s=r.figmaImageData?.startsWith("data:");return!i&&!s?r:{...r,storybookImageData:i?void 0:r.storybookImageData,figmaImageData:s?void 0:r.figmaImageData}})}function JD(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],i=Ql(i),tr(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":{if(t.payload.length===0)return e;let n=new Map(e.reviewHistory.map(s=>[s.id,s])),r=!1,o=e.reviewHistory.slice();for(let s of t.payload){let a=n.get(s.id);if(!a){o.push(s),r=!0;continue}let u=s.issues?.length??0,c=a.issues?.length??0;if(u>c){let l=o.indexOf(a);l!==-1&&(o[l]=s,r=!0)}}if(!r)return e;let i=Ql(o);return tr(i),{...e,reviewHistory:i}}case"ADD_REVIEW":{let n=Ql([...e.reviewHistory,t.payload]);return tr(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 tr(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 tr(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 tr(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 tr(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload.issueId?{...c,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:so(s,a,u),issuesCount:i.length}});return tr(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload?{...c,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:so(s,a,u),issuesCount:i.length}});return tr(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=so(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return tr(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 tr(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return Ow(),{...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 Kf({children:e}){let[t,n]=YD(JD,rR),r=KD(t);XD(()=>{r.current=t},[t]);let o=_w(()=>({setIsReviewing:s=>n({type:"SET_STATE",payload:{isReviewing:s}}),setReviewingStoryId:s=>n({type:"SET_STATE",payload:{reviewingStoryId: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}}),setReviewHistoryLoading:s=>n({type:"SET_STATE",payload:{reviewHistoryLoading: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=_w(()=>({...t,...o}),[t,o]);return VD.createElement(Uw.Provider,{value:i},e)}function ue(){let e=qD(Uw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var $w,QD,ZD,eR,Yf,tR,nR,rR,Uw,Xf=U(()=>{"use strict";ln();qf();Ne();$w=20,QD=5;ZD=()=>{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},eR=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Yf={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},tR=()=>{if(typeof localStorage>"u")return Yf;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Yf;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 Yf},nR=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},rR={isReviewing:!1,reviewingStoryId:null,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:Ql(Gf()),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,reviewHistoryLoading:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:nR(),roleOverride:eR(),featureFlags:tR(),reviewAllConcurrency:ZD(),hoveredIssueId:null},Uw=GD(null)});import Gs,{useMemo as oR}from"react";function Jf({children:e}){return Gs.createElement(Lu,null,Gs.createElement(Bu,null,Gs.createElement(Ru,null,Gs.createElement(Kf,null,Gs.createElement(iR,null),e))))}function jw(e){let t=Se(),n=Xe(),r=Ze(),o=ue(),i=oR(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function iR(){return Qf=jw(),null}var Qf,yt,Hw=U(()=>{"use strict";Mu();Du();zu();Xf();Qf=null,yt=Object.assign(jw,{getState:()=>{if(!Qf)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Qf}})});var ve=U(()=>{"use strict";Hw();Mu();Du();zu();Xf()});function Y(){return(process.env.STORYBOOK_UICOPILOT_URL||sR).replace(/\/$/,"")}var sR,Ww,$e=U(()=>{"use strict";sR="https://app.uiparity.com";Ww=3.6});async function re(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 lt=U(()=>{"use strict"});import{useEffect as Mo,useState as tc,useRef as sv,useCallback as nm}from"react";import{addons as rm}from"storybook/manager-api";async function lz(e,t,n){let r=`${e}:${t}`,o=om.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await re(`${pv}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{om.delete(r)});return om.set(r,i),i}function cz(e,t,n){try{sessionStorage.setItem(`${nc}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function uz(e,t){try{let n=sessionStorage.getItem(`${nc}${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(`${nc}${e}`)}catch{}return null}function pz(e){try{let t=sessionStorage.getItem(`${nc}${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 av,lv,cv,uv,$i,pv,Cn,im,om,nc,dv,gv,oi,Ui=U(()=>{"use strict";ve();sm();Ne();$e();lt();av="storyArgsUpdated",lv="storyRendered",cv="forceRemount",uv=null,$i=()=>uv,pv=Y(),Cn=new Map,im=null,om=new Map;nc="uicopilot-figma-image-";dv=(e,t,n)=>{let r=Cn.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):Cn.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),y.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},gv=(e,t,n)=>{im=t;let r=Cn.get(e);r?r.figmaImageUrl=n:Cn.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},oi=()=>{let[e,t]=tc(!1),[n,r]=tc(!1),[o,i]=tc(!1),[s,a]=tc(null),u=sv(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ue(),d=nm(()=>{let L=yt.getState().currentStoryId;L&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",L),Cn.delete(L),u.current=null,i(!0),l())},[l]),g=nm(()=>{let L=yt.getState().currentStoryId;if(L){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",L);let R=Cn.get(L);R&&(R.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=Se(),{selectedProjectId:m}=Xe(),{currentStoryId:b,currentMapping:T,loadingMapping:F}=Ze(),{setStorybookImageUrl:v,setFigmaImageUrl:D}=ue(),_=sv(null);Mo(()=>{b&&_.current&&_.current!==b&&(y.debug("[useReviewScreenshots] Story switched, clearing images"),v(""),D("")),_.current=b},[b,v,D]),Mo(()=>{!b||F||T||D("")},[b,T,F,D]),Mo(()=>{if(!b)return;let L=pz(b);L&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",b),D(L))},[b,D]),Mo(()=>{if(!b||F)return;let L=T?.figmaFileUrl;if(L){y.debug("[useReviewScreenshots] Restoring Figma image from mapping.figmaFileUrl for:",b),D(L);let R=Cn.get(b);R?R.figmaImageUrl=L:Cn.set(b,{storybookImageUrl:null,figmaImageUrl:L})}},[b,T,F,D]),Mo(()=>{let L=!1;return(async()=>{if(!p||!m||!b){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==b&&(y.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),v(""),D(""));let h=yt.getState();if(u.current===b&&h.storybookImageUrl&&h.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let S=T?.figmaNodeId??null;if(S!==im){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",b);let P=Cn.get(b);P&&(P.figmaImageUrl=null),im=S,u.current=null}let w=T?.figmaNodeId;if(w&&!Cn.get(b)?.figmaImageUrl){let P=uz(b,w);if(P){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",b),D(P);let B=Cn.get(b);B?B.figmaImageUrl=P:Cn.set(b,{storybookImageUrl:null,figmaImageUrl:P})}}let A=Cn.get(b),f=A&&A.storybookImageUrl&&A.figmaImageUrl,k=A&&A.storybookImageUrl&&!A.figmaImageUrl,E=A&&!A.storybookImageUrl&&A.figmaImageUrl;if(f){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",b),v(A.storybookImageUrl),D(A.figmaImageUrl),u.current=b;return}let x=k&&T?.figmaNodeId;x&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",b),v(A.storybookImageUrl));let C=E;if(C&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",b),D(A.figmaImageUrl)),u.current===b&&T?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),x?r(!0):(C||(t(!0),r(!0)),i(!0)),u.current=b,L)return;let P=C?A.figmaImageUrl:null,B;if(C)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(w){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",w);let I=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let z=await lz(m,w,p);I=z.imageUrl||null;let W=z.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${W}:`,I?"success":"not found")}catch(z){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",z)}if(I)try{y.debug("[useReviewScreenshots] Fetching Figma image via proxy...");let z=`${pv}/api/proxy/image?url=${encodeURIComponent(I)}`,W=await re(z);if(W.ok){let M=await W.blob(),ie=new FileReader,K=await new Promise((xe,Pe)=>{ie.onloadend=()=>xe(ie.result),ie.onerror=Pe,ie.readAsDataURL(M)});P=K,D(K),y.debug("[useReviewScreenshots] Figma image loaded via proxy");let ae=new Image;await new Promise(xe=>{ae.onload=()=>{B={width:ae.naturalWidth,height:ae.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),xe()},ae.onerror=()=>xe(),ae.src=K})}else P=I,D(I),y.warn("[useReviewScreenshots] Proxy failed, using direct URL as fallback")}catch(z){y.warn("[useReviewScreenshots] Proxy error, using direct URL as fallback:",z),P=I,D(I)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",w),D(null);P&&w&&cz(b,w,P),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let N=A?.storybookImageUrl||null;if(N)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",b);let I=await rc({storyId:b,sessionToken:p||void 0,...B&&{figmaWidth:B.width,figmaHeight:B.height}});I&&!L?(N=I,v(I),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",B||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}Cn.set(b,{storybookImageUrl:N,figmaImageUrl:P}),y.debug("[useReviewScreenshots] Screenshots cached for story:",b)}catch(P){y.error("[useReviewScreenshots] Error loading screenshots:",P),a(P instanceof Error?P.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})(),()=>{L=!0}},[p,m,b,T?.figmaNodeId,c]),Mo(()=>{let L=rm.getChannel(),R=null,h=S=>{uv=S.args,y.debug("[useReviewScreenshots] Args updated for story:",S.storyId,"args:",S.args),R&&clearTimeout(R),R=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return L.on(av,h),()=>{L.off(av,h),R&&clearTimeout(R)}},[d]),Mo(()=>{let L=rm.getChannel(),R=!1,h=null,S=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),R=!0,i(!0)},w=()=>{R&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),h&&clearTimeout(h),h=setTimeout(()=>{R=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return L.on(cv,S),L.on(lv,w),()=>{L.off(cv,S),L.off(lv,w),h&&clearTimeout(h)}},[g]),Mo(()=>{let L=rm.getChannel(),R=async h=>{if(!h?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let S=yt.getState().currentStoryId,w=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...h.snapshot,storyId:S})});if(w.ok){let A=await w.json();if(A.screenshot){v(A.screenshot);let f=yt.getState().currentStoryId;if(f){let k=Cn.get(f);k?k.storybookImageUrl=A.screenshot:Cn.set(f,{storybookImageUrl:A.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await w.text())}catch(S){y.error("[useReviewScreenshots] Snapshot screenshot error:",S)}finally{i(!1)}};return L.on("UICOPILOT/STORY_DOM_MUTATED",R),()=>{L.off("UICOPILOT/STORY_DOM_MUTATED",R)}},[]);let $=nm((L,R,h)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),gv(L,R,h),D(h),r(!1),u.current=L},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:g,setFigmaImageDirect:$}}});function gz(){return!Y().startsWith("http://localhost")}function fz(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 fv(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=fz(o,t,n);return r.set(o,i),i})}async function mz(){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=fv(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 g of Array.from(l.cssRules))d+=g.cssText+`
13
- `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let g=s.createElement("style");g.textContent=fv(d,o,r),u.replaceWith(g)}}catch{}})}})).toDataURL("image/png")}function hz(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 xz(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 re(`${dz}/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 yz(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 bz(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=$i();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=yz(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=hz(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 Sz(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 rc(e){let t=e?.storyId||wz();if(t){let n=am.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=mv(t,e).finally(()=>{am.delete(t)});return am.set(t,r),r}return mv(void 0,e)}async function mv(e,t){try{if(e){let n=await Sz(e);if(n)return n}if(!gz()){let n=bz(t?.storyId);return await xz(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await mz()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function wz(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var dz,am,sm=U(()=>{"use strict";$e();Ui();Ne();lt();dz=Y();am=new Map});function Pn(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 Un(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 Zs(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function hv(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let T=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let v=t.fonts.check(`${F} ${T} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:v,fontWeight:F,fontSize:T,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),v)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(T=>T.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],g=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,m="unknown",b=new Map;for(let T of g){s.font=`${c} ${u} ${a} "${T}", monospace`;let F=s.measureText(o).width;if(b.set(T,F),F!==p){s.font=`${c} ${u} ${a} "${T}"`;let v=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(v-D)<.1){m=T;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:m,declaredFonts:l,fontWidths:Array.from(b.entries()),isIframe:t!==document}),m}var ea=U(()=>{"use strict";Ne()});function ji(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 lm(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:Pn(n.color),backgroundColor:Pn(n.backgroundColor),borderColor:Pn(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:hv(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 cm(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 oc=U(()=>{"use strict";Ne();ea()});function vz(e){let t=[],n=new Set,r=xv.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(xv.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function kz(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:ji(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Zs(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:Pn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function Cz(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 Tz(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,g=Pn(n.borderColor),p=s?`${l} ${d} ${g}`:"none";return{selector:ji(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:Pn(n.backgroundColor),gap:n.gap}}function ta(){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=Cz(r,2),i=o.map(Tz).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=vz(r);s=a.map(kz),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:lm(r),declared:cm(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var xv,yv=U(()=>{"use strict";Ne();ea();oc();xv=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function um(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 Fz(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function Ez(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=Pn(n.backgroundColor);Un("backgroundColor",o)||(r.backgroundColor=o);let i=Fz(n.borderWidth,n.borderStyle,Pn(n.borderColor));i&&(r.border=i),Un("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Un("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Un("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 T=0;T<e.attributes.length;T++){let F=e.attributes[T];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let v=F.name.replace(/-([a-z])/g,(_,$)=>$.toUpperCase()),D=F.value.startsWith("rgb")?Pn(F.value):F.value;v==="d"&&D.length>100?r[v]=D.substring(0,100)+"...":r[v]=D}let p=n.getPropertyValue("fill"),m=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?Pn(p):p),m&&m!=="none"&&(r.stroke=m.startsWith("rgb")?Pn(m):m),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let T=e.getBoundingClientRect();T.width>0&&(r.width=`${Math.round(T.width*100)/100}px`),T.height>0&&(r.height=`${Math.round(T.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=Iz.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Zs(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=Pn(n.color),Un("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Un("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=um(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Un("padding",d)||(r.padding=d);let g=um(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Un("margin",g)||(r.margin=g),Un("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Un("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Un("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Un("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function bv(e){let t=1;for(let n of e.children)t+=bv(n);return t}function Sv(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 b of Array.from(o.childNodes))if(b.nodeType===Node.TEXT_NODE){let T=b.textContent?.trim();if(T){d=T.length>50?T.substring(0,50)+"...":T;break}}let g=s;c?g=`${s}#${c}`:u&&(g=ji(s,u));let p=Ez(o),m=[];if(i<t){let b=Array.from(o.children);for(let T of b){let F=T.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let D=(T.ownerDocument.defaultView||window).getComputedStyle(T);D.display==="none"||D.visibility==="hidden"||m.push(n(T,i+1))}}return{selector:g,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:m}}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:bv(r)}),r}function pm(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=Sv(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 Iz,wv=U(()=>{"use strict";Ne();ea();oc();Iz=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var dm=U(()=>{"use strict";ea();oc();yv();wv()});var qv=ir((nJ,Gv)=>{"use strict";Gv.exports={compareTwoStrings:Vv,findBestMatch:Zz};function Vv(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 Zz(e,t){if(!eN(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=Vv(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 eN(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var V1=ir((kae,W1)=>{"use strict";var $1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,u3=/\n/g,p3=/^\s*/,d3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,g3=/^:\s*/,f3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,m3=/^[;\s]*/,h3=/^\s+|\s+$/g,x3=`
14
- `,U1="/",j1="*",di="",y3="comment",b3="declaration";function S3(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(m){var b=m.match(u3);b&&(n+=b.length);var T=m.lastIndexOf(x3);r=~T?m.length-T:r+m.length}function i(){var m={line:n,column:r};return function(b){return b.position=new s(m),c(),b}}function s(m){this.start=m,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(m){var b=new Error(t.source+":"+n+":"+r+": "+m);if(b.reason=m,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function u(m){var b=m.exec(e);if(b){var T=b[0];return o(T),e=e.slice(T.length),b}}function c(){u(p3)}function l(m){var b;for(m=m||[];b=d();)b!==!1&&m.push(b);return m}function d(){var m=i();if(!(U1!=e.charAt(0)||j1!=e.charAt(1))){for(var b=2;di!=e.charAt(b)&&(j1!=e.charAt(b)||U1!=e.charAt(b+1));)++b;if(b+=2,di===e.charAt(b-1))return a("End of comment missing");var T=e.slice(2,b-2);return r+=2,o(T),e=e.slice(b),r+=2,m({type:y3,comment:T})}}function g(){var m=i(),b=u(d3);if(b){if(d(),!u(g3))return a("property missing ':'");var T=u(f3),F=m({type:b3,property:H1(b[0].replace($1,di)),value:T?H1(T[0].replace($1,di)):di});return u(m3),F}}function p(){var m=[];l(m);for(var b;b=g();)b!==!1&&(m.push(b),l(m));return m}return c(),p()}function H1(e){return e?e.replace(h3,di):di}W1.exports=S3});var G1=ir(Ca=>{"use strict";var w3=Ca&&Ca.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ca,"__esModule",{value:!0});Ca.default=k3;var v3=w3(V1());function k3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,v3.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 Y1=ir(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.camelCase=void 0;var C3=/^--[a-zA-Z0-9_-]+$/,T3=/-([a-z])/g,I3=/^[^-]+$/,F3=/^-(webkit|moz|ms|o|khtml)-/,E3=/^-(ms)-/,A3=function(e){return!e||I3.test(e)||C3.test(e)},P3=function(e,t){return t.toUpperCase()},q1=function(e,t){return"".concat(t,"-")},L3=function(e,t){return t===void 0&&(t={}),A3(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(E3,q1):e=e.replace(F3,q1),e.replace(T3,P3))};_c.camelCase=L3});var X1=ir((Gh,K1)=>{"use strict";var M3=Gh&&Gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},B3=M3(G1()),D3=Y1();function Vh(e,t){var n={};return!e||typeof e!="string"||(0,B3.default)(e,function(r,o){r&&o&&(n[(0,D3.camelCase)(r,t)]=o)}),n}Vh.default=Vh;K1.exports=Vh});var kI=ir((Jde,vI)=>{"use strict";var lu=Object.prototype.hasOwnProperty,wI=Object.prototype.toString,mI=Object.defineProperty,hI=Object.getOwnPropertyDescriptor,xI=function(t){return typeof Array.isArray=="function"?Array.isArray(t):wI.call(t)==="[object Array]"},yI=function(t){if(!t||wI.call(t)!=="[object Object]")return!1;var n=lu.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&lu.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||lu.call(t,o)},bI=function(t,n){mI&&n.name==="__proto__"?mI(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},SI=function(t,n){if(n==="__proto__")if(lu.call(t,n)){if(hI)return hI(t,n).value}else return;return t[n]};vI.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=SI(a,n),o=SI(t,n),a!==o&&(l&&o&&(yI(o)||(i=xI(o)))?(i?(i=!1,s=r&&xI(r)?r:[]):s=r&&yI(r)?r:{},bI(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&bI(a,{name:n,newValue:o}));return a}});import Qa from"react";import{addons as ku,types as hy,experimental_getStatusStore as xy}from"storybook/manager-api";import{AddonPanel as u9}from"storybook/internal/components";import zt,{useState as AV,useEffect as PV}from"react";import{styled as yr}from"storybook/theming";import Iy from"react";import{styled as Dt}from"storybook/theming";var ce="#ea580c",Fu="#c2410c",tl="#ff6b35";var Sy=Dt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),wy=Dt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),vo=Dt.div({marginBottom:"20px"}),ko=Dt.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})),hs=Dt.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`}})),Sn=Dt.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"}})),vy=Dt(Sn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),nl=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"}}),En=Dt.button(({theme:e})=>({...nl(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),on=Dt.button(({theme:e})=>({...nl(e),backgroundColor:ce,color:e.color.inverseText,boxShadow:`0 2px 4px ${ce}4d`,"&:hover:not(:disabled)":{backgroundColor:Fu,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ce}66`}})),Or=Dt.button(({theme:e})=>({...nl(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),ky=Dt.button(({theme:e})=>({...nl(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),An=Dt.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"}})),Eu=Dt.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"}})),Co=Dt.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}})),To=Dt(hs)(({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"})),y9=Dt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Cy=Dt.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})),b9=Dt.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})),xs=Dt.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})),S9=Dt.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%)"}}})),Ty=Dt.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}}),w9=Dt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),v9=Dt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),k9=Dt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var Au=({header:e,children:t,footer:n})=>Iy.createElement(Sy,null,e,Iy.createElement(wy,null,t),n);import SE from"react";import{styled as wE}from"storybook/theming";var vE=wE.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})),Pu=({toolbar:e})=>SE.createElement(vE,null,e);import B9 from"react";import{styled as rl}from"storybook/theming";var z9=rl.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})),N9=rl.div({display:"flex",flex:1}),O9=rl(Co)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),_9=rl.div({display:"flex",gap:"8px",alignItems:"center"});import en,{useState as em,useCallback as nv,useEffect as rv}from"react";import{styled as ao}from"storybook/theming";import we,{useEffect as Vw}from"react";import{styled as at}from"storybook/theming";ve();$e();Ne();lt();var Gw=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),qw=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})),aR=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),lR=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:ce,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),cR=at.div({display:"flex",flexDirection:"column",gap:"4px"}),uR=at.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),pR=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"}),dR=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),gR=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),fR=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),mR=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"})),hR=at.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${ce} 100%)`,transition:"width 0.3s ease"})),xR=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),yR=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),bR=at.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:ce,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Yw=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}})),SR=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),wR=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),vR=at.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:ce,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),kR=at.div({display:"flex",gap:"8px"}),Kw=at(An)({fontSize:"18px"}),CR=at.div({padding:"20px 16px"}),TR=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),IR=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),FR=at.div({fontSize:"28px",fontWeight:700}),ER=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),AR=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),PR=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),LR=at.div({display:"flex",alignItems:"center",gap:"8px"}),MR=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),BR=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:ce,color:e.color.inverseText})),DR=at.button(({theme:e})=>({background:"none",border:"none",color:ce,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),RR=at.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),zR=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"?ce:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),NR=30*1e3,Xw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=Se(),{featureFlags:s}=ue(),a=s.showCosts,u=r,c=!r&&t,l=async(m=!1)=>{if(!t)return;let b=o&&Date.now()-o<NR;if(!(!m&&b&&r))try{let T=Y(),F=await re(`${T}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(F.ok){let v=await F.json();i(v)}}catch(T){y.error("Failed to fetch usage:",T)}};Vw(()=>{l()},[t]),Vw(()=>{let m=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[t]);let d=async()=>{if(t){let m=Y();try{await fetch(`${m}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})}catch{}}n(),e()},g=()=>{let m=Y();window.open(`${m}/pricing`,"_blank")},p=()=>{let m=Y();window.open(`${m}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let m=Math.floor(u?.creditBalance??0),T=Math.max(m,10),F=Math.max(0,T-m),v=T>0?m/T*100:0;return we.createElement(we.Fragment,null,we.createElement(Gw,{onClick:e}),we.createElement(qw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},we.createElement(aR,null,we.createElement(lR,null,u?.email?u.email[0].toUpperCase():"U"),we.createElement(cR,null,we.createElement(uR,null,"UI Review"),we.createElement(pR,null,(u?.plan||"BETA").toUpperCase())),we.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},we.createElement(Yw,{onClick:d,title:"Sign out",style:{position:"static"}},we.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},we.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),we.createElement("polyline",{points:"16 17 21 12 16 7"}),we.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),we.createElement(Yw,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),we.createElement(dR,null,we.createElement(gR,null,"Credits"),we.createElement(fR,null,m," left")),we.createElement(mR,null,we.createElement(hR,{percent:v})),we.createElement(xR,null,F," used \xB7 ",m," remaining"),we.createElement(yR,null),we.createElement(bR,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return we.createElement(we.Fragment,null,we.createElement(Gw,{onClick:e}),we.createElement(qw,{onClick:m=>m.stopPropagation()},we.createElement(SR,null,we.createElement(wR,null,we.createElement(vR,null,u?.email?u.email[0].toUpperCase():"U"),we.createElement("span",null,u?.email||"Loading...")),we.createElement(kR,null,we.createElement(Kw,{onClick:d,title:"Sign out"},we.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},we.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),we.createElement("polyline",{points:"16 17 21 12 16 7"}),we.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),we.createElement(Kw,{onClick:e,title:"Close"},"\xD7"))),we.createElement(CR,null,c?we.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?we.createElement(we.Fragment,null,we.createElement(TR,null,we.createElement(IR,null,"Credit Balance"),we.createElement(FR,null,"$",(u?.creditBalance??0).toFixed(2)),we.createElement(ER,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),we.createElement(AR,null,we.createElement(PR,null,we.createElement(LR,null,we.createElement(MR,null,"Current Plan"),we.createElement(BR,null,u?.plan||"Free")),we.createElement(DR,{onClick:g},"View detail >")),we.createElement(RR,null,"~$0.02-0.05 per review depending on complexity"),we.createElement(zR,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):we.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};ve();import Oi from"react";import{styled as Qw}from"storybook/theming";$e();ve();lt();Ne();var OR=Qw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),_R=Qw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),$R={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}},Jw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ue(),{sessionToken:o}=Se();return e!=="admin"?null:Oi.createElement(OR,null,Oi.createElement(_R,null,"View as:"),Oi.createElement(vy,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&re(`${Y()}/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=$R[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Oi.createElement("option",{value:"admin"},"Admin"),Oi.createElement("option",{value:"beta"},"Beta Tester")),t&&Oi.createElement(Ty,{variant:"warning"},"Previewing as ",t))};$e();ve();lt();import St,{useState as qs,useCallback as Zf}from"react";import{styled as Er}from"storybook/theming";var UR="0.5.7",jR=[{value:"bug",label:"\u{1F41E} Bug \u2014 something broke"},{value:"ux",label:"\u{1F9ED} UX \u2014 confusing or slow"},{value:"feature",label:"\u2728 Feature \u2014 missing something"},{value:"praise",label:"\u{1F49A} Praise \u2014 works great"},{value:"other",label:"\u{1F4AC} Other"}],HR=Er.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),WR=Er.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"12px",width:"460px",maxWidth:"94%",maxHeight:"90vh",overflow:"auto",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.25)"})),VR=Er.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),GR=Er.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),qR=Er.button(({theme:e})=>({background:"transparent",border:"none",fontSize:"20px",color:e.color.mediumdark,cursor:"pointer",padding:"0 6px",lineHeight:1,"&:hover":{color:e.color.defaultText}})),YR=Er.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),KR=Er.textarea(({theme:e})=>({width:"100%",minHeight:"110px",padding:"8px 10px",borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.defaultText,backgroundColor:e.background.app,resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:ce}})),Zw=Er.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),ev=Er.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),XR=Er.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),QR=Er.div(({theme:e})=>({padding:"24px 20px",textAlign:"center",display:"flex",flexDirection:"column",gap:"10px","& h4":{margin:0,fontSize:"15px",fontWeight:600,color:e.color.positive},"& p":{margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark}}));function tv({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=Se(),{selectedProjectId:o}=Xe(),{currentStoryId:i}=Ze(),[s,a]=qs("other"),[u,c]=qs(""),[l,d]=qs(!1),[g,p]=qs(!1),[m,b]=qs(null),T=Zf(()=>{c(""),a("other"),p(!1),b(null),d(!1)},[]),F=Zf(()=>{T(),t()},[T,t]),v=Zf(async D=>{if(D.preventDefault(),!u.trim()){b("Please write a message.");return}if(!r||!n){b("Sign in to send feedback.");return}d(!0),b(null);try{let _=await re(`${Y()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:s,projectId:o||void 0,storyId:i||void 0,addonVersion:UR})});if(!_.ok){let $=await _.json().catch(()=>({}));throw new Error($.error||`Request failed (${_.status})`)}p(!0)}catch(_){b(_ instanceof Error?_.message:"Something went wrong")}finally{d(!1)}},[u,s,n,r,o,i]);return e?St.createElement(HR,{onClick:F},St.createElement(WR,{onClick:D=>D.stopPropagation()},St.createElement(VR,null,St.createElement(GR,null,St.createElement("span",null,"\u{1F4AC}"),"Send feedback"),St.createElement(qR,{onClick:F,"aria-label":"Close"},"\xD7")),g?St.createElement(St.Fragment,null,St.createElement(QR,null,St.createElement("h4",null,"Thanks \u2014 got it."),St.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),St.createElement(Zw,null,St.createElement("span",null),St.createElement(En,{onClick:F},"Close"))):St.createElement("form",{onSubmit:v},St.createElement(YR,null,St.createElement(vo,null,St.createElement(ko,{htmlFor:"feedback-severity"},"Type"),St.createElement(Sn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},jR.map(D=>St.createElement("option",{key:D.value,value:D.value},D.label)))),St.createElement(vo,null,St.createElement(ko,{htmlFor:"feedback-message"},"What happened?"),St.createElement(KR,{id:"feedback-message",value:u,onChange:D=>c(D.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:l,autoFocus:!0,maxLength:5e3})),St.createElement(ev,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),m&&St.createElement(XR,null,m)),St.createElement(Zw,null,St.createElement(ev,null,i?`Context: ${i}`:"No story selected"),St.createElement("div",{style:{display:"flex",gap:"8px"}},St.createElement(En,{type:"button",onClick:F,disabled:l},"Cancel"),St.createElement(on,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}ve();$e();lt();var JR=ao.div({display:"flex",alignItems:"center"}),_i=ao.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),ZR=ao.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),ez=ao.div({position:"relative"}),tz=ao.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`}})),ov=ao.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)"}})),nz=ao.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)"}}}),rz=ao.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}})),oz=ao.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:ce,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${ce}66, 0 2px 4px rgba(0,0,0,0.1)`,transition:"all 0.2s ease",zIndex:9999,"&:hover":{transform:"scale(1.08)",boxShadow:`0 6px 20px ${ce}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),iz=30*1e3,tm=({onOpenSettings:e})=>{let[t,n]=em(!1),[r,o]=em(!1),[i,s]=em(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=Se(),{userRole:d,roleOverride:g,featureFlags:p}=ue(),m=g??d;rv(()=>{(async()=>{if(!(!l||u&&Date.now()-u<iz&&a)){s(!0);try{let $=Y(),L=await re(`${$}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(L.ok){let R=await L.json();c(R)}}catch($){console.error("Failed to fetch balance:",$)}finally{s(!1)}}})()},[l,u,a,c]),rv(()=>{let D=()=>{document.visibilityState==="visible"&&t&&n(!1)},_=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",D),window.addEventListener("focus",_),()=>{document.removeEventListener("visibilitychange",D),window.removeEventListener("focus",_)}},[t]);let b=nv(()=>{n(!0)},[]),T=nv(()=>{n(!1)},[]),F=a?.creditBalance??0,v=F<2&&!i;return en.createElement(JR,null,e&&en.createElement(_i,null,en.createElement(rz,{onClick:e,title:"Settings"},en.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&d==="admin"&&m==="admin"&&en.createElement(_i,null,en.createElement(Jw,null)),en.createElement(_i,null,en.createElement(ZR,null,"v","0.5.39")),l&&p.showCosts&&en.createElement(_i,null,en.createElement(ov,{onClick:b,isLow:v,title:i?"Loading...":a?v?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?en.createElement(nz,null):a?`$${F.toFixed(2)}`:"...")),l&&!p.showCosts&&a&&en.createElement(_i,null,en.createElement(ov,{onClick:b,isLow:Math.floor(F)<=3,title:`${Math.floor(F)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(F))),en.createElement(_i,null,en.createElement(ez,null,en.createElement(tz,{title:"Account & Usage",onClick:b},a?.email?a.email[0].toUpperCase():"?"),t&&en.createElement(Xw,{onClose:T}))),l&&en.createElement(oz,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),en.createElement(tv,{isOpen:r,onClose:()=>o(!1)}))};import Bt,{useEffect as r5,useRef as o5}from"react";import{styled as fr}from"storybook/theming";import et from"react";ve();Ne();$e();lt();ln();import{useState as sz,useCallback as Lo,useRef as az,useEffect as iv}from"react";var Ar=Y();y.debug("[useAuth] Module loaded, APP_URL:",Ar);var Jl=null,Zl=null,Ys=null;function Ks(){Jl&&(clearInterval(Jl),Jl=null),Zl&&(clearTimeout(Zl),Zl=null)}var Xs=()=>{let e=az(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:g,setUserCode:p,setVerificationUri:m,setPollingInterval:b,setAuthError:T,resetAuth:F}=Se(),[v,D]=sz(!1),_=Lo(()=>{Ks(),Ys=null},[]),$=Lo(f=>{Ys=f,Ks();let k=async()=>{let E=Ys;if(!E){Ks();return}try{let C=await(await fetch(`${Ar}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:E})})).json();C.status==="authorized"&&C.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),Ks(),Ys=null,localStorage.setItem("uicopilot_session_token",C.session_token),c(C.session_token),D(!1)):C.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),Ks(),Ys=null,D(!1))}catch(x){y.error("[useAuth] OAuth poll error:",x)}};Jl=setInterval(k,2e3),Zl=setTimeout(k,1e3)},[c]);iv(()=>{function f(k){if(!k.origin.startsWith(Ar))return;let E=k.data;if(!E||typeof E!="object")return;let x=E;if(x.type==="UICOPILOT_AUTH_ERROR"){y.debug("[useAuth] Popup reported auth error:",x.step,x.detail),_(),D(!1);let C=typeof x.step=="string"?x.step:"auth",P=typeof x.detail=="string"?x.detail:"Unknown error";T(`${Et.NAME} auth failed (${C}): ${P}`)}else x.type==="UICOPILOT_AUTH_POLL_CODE"&&typeof x.pollCode=="string"&&x.pollCode&&(y.debug("[useAuth] Popup handed us a fresh poll_code, switching"),T(null),$(x.pollCode))}return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[$,_,T]);let L=Lo(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let f;try{f=await re(`${Ar}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(C){let B=C instanceof Error&&C.message.includes("timed out")?`Cannot reach ${Et.NAME} server at ${Ar}. Is the dashboard running?`:`Connection failed: ${Ar} is not responding.`;T(B),y.error("[useAuth]",B);return}if(!f.ok){let C=`Cannot reach ${Et.NAME} server. Is the dashboard running?`;T(C),y.error("[useAuth]",C);return}let{poll_code:k}=await f.json();y.debug("[useAuth] Got poll_code:",k.substring(0,15)+"...");let E=localStorage.getItem("uicopilot_force_sign_in")==="true";E&&localStorage.removeItem("uicopilot_force_sign_in");let x=`${Ar}/addon/auth?poll_code=${k}${E?"&force_sign_in=true":""}`;D(!0),window.open(x,"uiparity-auth","width=520,height=620,left=300,top=150"),y.debug("[useAuth] Starting OAuth poll for token..."),$(k)}catch(f){y.error("[useAuth] OAuth flow error:",f),T(`Connection failed. Is the dashboard running at ${Ar}?`),D(!1)}},[T,$]),R=Lo(async()=>{try{let f=await fetch(`${Ar}/api/addon/auth/device`,{method:"POST"});if(!f.ok)throw new Error("Failed to start device code flow");let k=await f.json();g(k.device_code),p(k.user_code),m(k.verification_uri),window.open(k.verification_uri,"_blank"),h(k.device_code,k.interval*1e3)}catch(f){throw y.error("[useAuth] Device code flow error:",f),f}},[g,p,m]),h=Lo((f,k)=>{y.debug("[useAuth] Starting polling. Device code:",f,"Interval:",k),e.current&&clearInterval(e.current);let E=async()=>{try{let C=await(await fetch(`${Ar}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:f})})).json();C.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null),localStorage.setItem("uicopilot_session_token",C.session_token),c(C.session_token),D(!1)):(C.status==="expired"||C.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null))}catch(x){y.error("[useAuth] Polling error:",x)}};e.current=setInterval(E,k),b(k)},[g,p,m,c,b]),S=Lo(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),m(null),b(null)},[g,p,m,b]),w=Lo(f=>{l(f),c(f),localStorage.setItem("uicopilot_api_key",f)},[l,c]),A=Lo(async()=>{if(t)try{await re(`${Ar}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})}catch{}F(),D(!1),e.current&&(clearInterval(e.current),e.current=null),_()},[t,F,_]);return iv(()=>()=>{e.current&&clearInterval(e.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthPending:v,setAuthMethod:d,startOAuth:L,startDeviceCode:R,cancelDeviceCode:S,saveApiKey:w,logout:A}};ve();Ne();$e();lt();import{useCallback as ec}from"react";var Qs=Y(),lo=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Xe(),{sessionToken:a}=Se(),u=ec(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Qs}/api/projects`);let g=await re(`${Qs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let p=await g.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){y.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=ec(async g=>{if(!a)throw new Error("Not authenticated");let p=await re(`${Qs}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!p.ok)throw new Error("Failed to create project");let m=await p.json();return await u(),m.project},[a,u]),l=ec(async(g,p)=>{if(!a)throw new Error("Not authenticated");let m={};if(p.name!==void 0&&(m.name=p.name),p.description!==void 0&&(m.description=p.description),p.figmaFileUrl!==void 0&&(m.figmaFileId=p.figmaFileUrl===""?null:p.figmaFileUrl),!(await re(`${Qs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(m)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=ec(async g=>{if(!a)throw new Error("Not authenticated");if(!(await re(`${Qs}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&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 Js=()=>{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}=Ze();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();sm();dm();import{useCallback as sa,useRef as dc}from"react";Ne();function ic(){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})}function sc(e){return e&&e!=="admin"?{"X-UIC-Role-Preview":e}:{}}var ac=BigInt(4294967295),vv=BigInt(32);function Az(e,t=!1){return t?{h:Number(e&ac),l:Number(e>>vv&ac)}:{h:Number(e>>vv&ac)|0,l:Number(e&ac)|0}}function kv(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}=Az(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Cv=(e,t,n)=>e<<n|t>>>32-n,Tv=(e,t,n)=>t<<n|e>>>32-n,Iv=(e,t,n)=>t<<n-32|e>>>64-n,Fv=(e,t,n)=>e<<n-32|t>>>64-n;function Pz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function gm(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function lc(e,t,n=""){let r=Pz(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 fm(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 Ev(e,t){lc(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 Av(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function mm(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var Lz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Mz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Bz(e){for(let t=0;t<e.length;t++)e[t]=Mz(e[t]);return e}var hm=Lz?e=>e:Bz;function Pv(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 Lv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var Dz=BigInt(0),na=BigInt(1),Rz=BigInt(2),zz=BigInt(7),Nz=BigInt(256),Oz=BigInt(113),Dv=[],Rv=[],zv=[];for(let e=0,t=na,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Dv.push(2*(5*r+n)),Rv.push((e+1)*(e+2)/2%64);let o=Dz;for(let i=0;i<7;i++)t=(t<<na^(t>>zz)*Oz)%Nz,t&Rz&&(o^=na<<(na<<BigInt(i))-na);zv.push(o)}var Nv=kv(zv,!0),_z=Nv[0],$z=Nv[1],Mv=(e,t,n)=>n>32?Iv(e,t,n):Cv(e,t,n),Bv=(e,t,n)=>n>32?Fv(e,t,n):Tv(e,t,n);function Uz(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=Mv(c,l,1)^n[a],g=Bv(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=Rv[s],u=Mv(o,i,a),c=Bv(o,i,a),l=Dv[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]^=_z[r],e[1]^=$z[r]}mm(n)}var xm=class e{constructor(t,n,r,o=!1,i=24){sr(this,"state");sr(this,"pos",0);sr(this,"posOut",0);sr(this,"finished",!1);sr(this,"state32");sr(this,"destroyed",!1);sr(this,"blockLen");sr(this,"suffix");sr(this,"outputLen");sr(this,"enableXOF",!1);sr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,gm(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Av(this.state)}clone(){return this._cloneInto()}keccak(){hm(this.state32),Uz(this.state32,this.rounds),hm(this.state32),this.posOut=0,this.pos=0}update(t){fm(this),lc(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){fm(this,!1),lc(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 gm(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ev(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,mm(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}},jz=(e,t,n,r={})=>Pv(()=>new xm(t,e,n),r);var Ov=jz(6,72,64,Lv(10));var Hz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,ym=Math.ceil,dr=Math.floor,jn="[BigNumber Error] ",_v=jn+"Number primitive has more than 15 significant digits: ",Pr=1e14,He=14,bm=9007199254740991,Sm=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Bo=1e7,cn=1e9;function $v(e){var t,n,r,o=v.prototype={constructor:v,toString:null,valueOf:null},i=new v(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,g=!1,p=1,m=0,b={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},T="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function v(h,S){var w,A,f,k,E,x,C,P,B=this;if(!(B instanceof v))return new v(h,S);if(S==null){if(h&&h._isBigNumber===!0){B.s=h.s,!h.c||h.e>d?B.c=B.e=null:h.e<l?B.c=[B.e=0]:(B.e=h.e,B.c=h.c.slice());return}if((x=typeof h=="number")&&h*0==0){if(B.s=1/h<0?(h=-h,-1):1,h===~~h){for(k=0,E=h;E>=10;E/=10,k++);k>d?B.c=B.e=null:(B.e=k,B.c=[h]);return}P=String(h)}else{if(!Hz.test(P=String(h)))return r(B,P,x);B.s=P.charCodeAt(0)==45?(P=P.slice(1),-1):1}(k=P.indexOf("."))>-1&&(P=P.replace(".","")),(E=P.search(/e/i))>0?(k<0&&(k=E),k+=+P.slice(E+1),P=P.substring(0,E)):k<0&&(k=P.length)}else{if(Ot(S,2,T.length,"Base"),S==10&&F)return B=new v(h),L(B,s+B.e+1,a);if(P=String(h),x=typeof h=="number"){if(h*0!=0)return r(B,P,x,S);if(B.s=1/h<0?(P=P.slice(1),-1):1,v.DEBUG&&P.replace(/^0\.0*|\./,"").length>15)throw Error(_v+h)}else B.s=P.charCodeAt(0)===45?(P=P.slice(1),-1):1;for(w=T.slice(0,S),k=E=0,C=P.length;E<C;E++)if(w.indexOf(A=P.charAt(E))<0){if(A=="."){if(E>k){k=C;continue}}else if(!f&&(P==P.toUpperCase()&&(P=P.toLowerCase())||P==P.toLowerCase()&&(P=P.toUpperCase()))){f=!0,E=-1,k=0;continue}return r(B,String(h),x,S)}x=!1,P=n(P,S,10,B.s),(k=P.indexOf("."))>-1?P=P.replace(".",""):k=P.length}for(E=0;P.charCodeAt(E)===48;E++);for(C=P.length;P.charCodeAt(--C)===48;);if(P=P.slice(E,++C)){if(C-=E,x&&v.DEBUG&&C>15&&(h>bm||h!==dr(h)))throw Error(_v+B.s*h);if((k=k-E-1)>d)B.c=B.e=null;else if(k<l)B.c=[B.e=0];else{if(B.e=k,B.c=[],E=(k+1)%He,k<0&&(E+=He),E<C){for(E&&B.c.push(+P.slice(0,E)),C-=He;E<C;)B.c.push(+P.slice(E,E+=He));E=He-(P=P.slice(E)).length}else E-=C;for(;E--;P+="0");B.c.push(+P)}}else B.c=[B.e=0]}v.clone=$v,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(h){var S,w;if(h!=null)if(typeof h=="object"){if(h.hasOwnProperty(S="DECIMAL_PLACES")&&(w=h[S],Ot(w,0,cn,S),s=w),h.hasOwnProperty(S="ROUNDING_MODE")&&(w=h[S],Ot(w,0,8,S),a=w),h.hasOwnProperty(S="EXPONENTIAL_AT")&&(w=h[S],w&&w.pop?(Ot(w[0],-cn,0,S),Ot(w[1],0,cn,S),u=w[0],c=w[1]):(Ot(w,-cn,cn,S),u=-(c=w<0?-w:w))),h.hasOwnProperty(S="RANGE"))if(w=h[S],w&&w.pop)Ot(w[0],-cn,-1,S),Ot(w[1],1,cn,S),l=w[0],d=w[1];else if(Ot(w,-cn,cn,S),w)l=-(d=w<0?-w:w);else throw Error(jn+S+" cannot be zero: "+w);if(h.hasOwnProperty(S="CRYPTO"))if(w=h[S],w===!!w)if(w)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=w;else throw g=!w,Error(jn+"crypto unavailable");else g=w;else throw Error(jn+S+" not true or false: "+w);if(h.hasOwnProperty(S="MODULO_MODE")&&(w=h[S],Ot(w,0,9,S),p=w),h.hasOwnProperty(S="POW_PRECISION")&&(w=h[S],Ot(w,0,cn,S),m=w),h.hasOwnProperty(S="FORMAT"))if(w=h[S],typeof w=="object")b=w;else throw Error(jn+S+" not an object: "+w);if(h.hasOwnProperty(S="ALPHABET"))if(w=h[S],typeof w=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(w))F=w.slice(0,10)=="0123456789",T=w;else throw Error(jn+S+" invalid: "+w)}else throw Error(jn+"Object expected: "+h);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:g,MODULO_MODE:p,POW_PRECISION:m,FORMAT:b,ALPHABET:T}},v.isBigNumber=function(h){if(!h||h._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var S,w,A=h.c,f=h.e,k=h.s;e:if({}.toString.call(A)=="[object Array]"){if((k===1||k===-1)&&f>=-cn&&f<=cn&&f===dr(f)){if(A[0]===0){if(f===0&&A.length===1)return!0;break e}if(S=(f+1)%He,S<1&&(S+=He),String(A[0]).length==S){for(S=0;S<A.length;S++)if(w=A[S],w<0||w>=Pr||w!==dr(w))break e;if(w!==0)return!0}}}else if(A===null&&f===null&&(k===null||k===1||k===-1))return!0;throw Error(jn+"Invalid BigNumber: "+h)},v.maximum=v.max=function(){return _(arguments,-1)},v.minimum=v.min=function(){return _(arguments,1)},v.random=(function(){var h=9007199254740992,S=Math.random()*h&2097151?function(){return dr(Math.random()*h)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(w){var A,f,k,E,x,C=0,P=[],B=new v(i);if(w==null?w=s:Ot(w,0,cn),E=ym(w/He),g)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(E*=2));C<E;)x=A[C]*131072+(A[C+1]>>>11),x>=9e15?(f=crypto.getRandomValues(new Uint32Array(2)),A[C]=f[0],A[C+1]=f[1]):(P.push(x%1e14),C+=2);C=E/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(E*=7);C<E;)x=(A[C]&31)*281474976710656+A[C+1]*1099511627776+A[C+2]*4294967296+A[C+3]*16777216+(A[C+4]<<16)+(A[C+5]<<8)+A[C+6],x>=9e15?crypto.randomBytes(7).copy(A,C):(P.push(x%1e14),C+=7);C=E/7}else throw g=!1,Error(jn+"crypto unavailable");if(!g)for(;C<E;)x=S(),x<9e15&&(P[C++]=x%1e14);for(E=P[--C],w%=He,E&&w&&(x=Sm[He-w],P[C]=dr(E/x)*x);P[C]===0;P.pop(),C--);if(C<0)P=[k=0];else{for(k=-1;P[0]===0;P.splice(0,1),k-=He);for(C=1,x=P[0];x>=10;x/=10,C++);C<He&&(k-=He-C)}return B.e=k,B.c=P,B}})(),v.sum=function(){for(var h=1,S=arguments,w=new v(S[0]);h<S.length;)w=w.plus(S[h++]);return w},n=(function(){var h="0123456789";function S(w,A,f,k){for(var E,x=[0],C,P=0,B=w.length;P<B;){for(C=x.length;C--;x[C]*=A);for(x[0]+=k.indexOf(w.charAt(P++)),E=0;E<x.length;E++)x[E]>f-1&&(x[E+1]==null&&(x[E+1]=0),x[E+1]+=x[E]/f|0,x[E]%=f)}return x.reverse()}return function(w,A,f,k,E){var x,C,P,B,N,I,z,W,M=w.indexOf("."),ie=s,K=a;for(M>=0&&(B=m,m=0,w=w.replace(".",""),W=new v(A),I=W.pow(w.length-M),m=B,W.c=S(co(pr(I.c),I.e,"0"),10,f,h),W.e=W.c.length),z=S(w,A,f,E?(x=T,h):(x=h,T)),P=B=z.length;z[--B]==0;z.pop());if(!z[0])return x.charAt(0);if(M<0?--P:(I.c=z,I.e=P,I.s=k,I=t(I,W,ie,K,f),z=I.c,N=I.r,P=I.e),C=P+ie+1,M=z[C],B=f/2,N=N||C<0||z[C+1]!=null,N=K<4?(M!=null||N)&&(K==0||K==(I.s<0?3:2)):M>B||M==B&&(K==4||N||K==6&&z[C-1]&1||K==(I.s<0?8:7)),C<1||!z[0])w=N?co(x.charAt(1),-ie,x.charAt(0)):x.charAt(0);else{if(z.length=C,N)for(--f;++z[--C]>f;)z[C]=0,C||(++P,z=[1].concat(z));for(B=z.length;!z[--B];);for(M=0,w="";M<=B;w+=x.charAt(z[M++]));w=co(w,P,x.charAt(0))}return w}})(),t=(function(){function h(A,f,k){var E,x,C,P,B=0,N=A.length,I=f%Bo,z=f/Bo|0;for(A=A.slice();N--;)C=A[N]%Bo,P=A[N]/Bo|0,E=z*C+P*I,x=I*C+E%Bo*Bo+B,B=(x/k|0)+(E/Bo|0)+z*P,A[N]=x%k;return B&&(A=[B].concat(A)),A}function S(A,f,k,E){var x,C;if(k!=E)C=k>E?1:-1;else for(x=C=0;x<k;x++)if(A[x]!=f[x]){C=A[x]>f[x]?1:-1;break}return C}function w(A,f,k,E){for(var x=0;k--;)A[k]-=x,x=A[k]<f[k]?1:0,A[k]=x*E+A[k]-f[k];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,f,k,E,x){var C,P,B,N,I,z,W,M,ie,K,ae,xe,Pe,Ye,ne,Te,it,te=A.s==f.s?1:-1,Be=A.c,ge=f.c;if(!Be||!Be[0]||!ge||!ge[0])return new v(!A.s||!f.s||(Be?ge&&Be[0]==ge[0]:!ge)?NaN:Be&&Be[0]==0||!ge?te*0:te/0);for(M=new v(te),ie=M.c=[],P=A.e-f.e,te=k+P+1,x||(x=Pr,P=gr(A.e/He)-gr(f.e/He),te=te/He|0),B=0;ge[B]==(Be[B]||0);B++);if(ge[B]>(Be[B]||0)&&P--,te<0)ie.push(1),N=!0;else{for(Ye=Be.length,Te=ge.length,B=0,te+=2,I=dr(x/(ge[0]+1)),I>1&&(ge=h(ge,I,x),Be=h(Be,I,x),Te=ge.length,Ye=Be.length),Pe=Te,K=Be.slice(0,Te),ae=K.length;ae<Te;K[ae++]=0);it=ge.slice(),it=[0].concat(it),ne=ge[0],ge[1]>=x/2&&ne++;do{if(I=0,C=S(ge,K,Te,ae),C<0){if(xe=K[0],Te!=ae&&(xe=xe*x+(K[1]||0)),I=dr(xe/ne),I>1)for(I>=x&&(I=x-1),z=h(ge,I,x),W=z.length,ae=K.length;S(z,K,W,ae)==1;)I--,w(z,Te<W?it:ge,W,x),W=z.length,C=1;else I==0&&(C=I=1),z=ge.slice(),W=z.length;if(W<ae&&(z=[0].concat(z)),w(K,z,ae,x),ae=K.length,C==-1)for(;S(ge,K,Te,ae)<1;)I++,w(K,Te<ae?it:ge,ae,x),ae=K.length}else C===0&&(I++,K=[0]);ie[B++]=I,K[0]?K[ae++]=Be[Pe]||0:(K=[Be[Pe]],ae=1)}while((Pe++<Ye||K[0]!=null)&&te--);N=K[0]!=null,ie[0]||ie.splice(0,1)}if(x==Pr){for(B=1,te=ie[0];te>=10;te/=10,B++);L(M,k+(M.e=B+P*He-1)+1,E,N)}else M.e=P,M.r=+N;return M}})();function D(h,S,w,A){var f,k,E,x,C;if(w==null?w=a:Ot(w,0,8),!h.c)return h.toString();if(f=h.c[0],E=h.e,S==null)C=pr(h.c),C=A==1||A==2&&(E<=u||E>=c)?uc(C,E):co(C,E,"0");else if(h=L(new v(h),S,w),k=h.e,C=pr(h.c),x=C.length,A==1||A==2&&(S<=k||k<=u)){for(;x<S;C+="0",x++);C=uc(C,k)}else if(S-=E+(A===2&&k>E),C=co(C,k,"0"),k+1>x){if(--S>0)for(C+=".";S--;C+="0");}else if(S+=k-x,S>0)for(k+1==x&&(C+=".");S--;C+="0");return h.s<0&&f?"-"+C:C}function _(h,S){for(var w,A,f=1,k=new v(h[0]);f<h.length;f++)A=new v(h[f]),(!A.s||(w=ii(k,A))===S||w===0&&k.s===S)&&(k=A);return k}function $(h,S,w){for(var A=1,f=S.length;!S[--f];S.pop());for(f=S[0];f>=10;f/=10,A++);return(w=A+w*He-1)>d?h.c=h.e=null:w<l?h.c=[h.e=0]:(h.e=w,h.c=S),h}r=(function(){var h=/^(-?)0([xbo])(?=\w[\w.]*$)/i,S=/^([^.]+)\.$/,w=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(k,E,x,C){var P,B=x?E:E.replace(f,"");if(A.test(B))k.s=isNaN(B)?null:B<0?-1:1;else{if(!x&&(B=B.replace(h,function(N,I,z){return P=(z=z.toLowerCase())=="x"?16:z=="b"?2:8,!C||C==P?I:N}),C&&(P=C,B=B.replace(S,"$1").replace(w,"0.$1")),E!=B))return new v(B,P);if(v.DEBUG)throw Error(jn+"Not a"+(C?" base "+C:"")+" number: "+E);k.s=null}k.c=k.e=null}})();function L(h,S,w,A){var f,k,E,x,C,P,B,N=h.c,I=Sm;if(N){e:{for(f=1,x=N[0];x>=10;x/=10,f++);if(k=S-f,k<0)k+=He,E=S,C=N[P=0],B=dr(C/I[f-E-1]%10);else if(P=ym((k+1)/He),P>=N.length)if(A){for(;N.length<=P;N.push(0));C=B=0,f=1,k%=He,E=k-He+1}else break e;else{for(C=x=N[P],f=1;x>=10;x/=10,f++);k%=He,E=k-He+f,B=E<0?0:dr(C/I[f-E-1]%10)}if(A=A||S<0||N[P+1]!=null||(E<0?C:C%I[f-E-1]),A=w<4?(B||A)&&(w==0||w==(h.s<0?3:2)):B>5||B==5&&(w==4||A||w==6&&(k>0?E>0?C/I[f-E]:0:N[P-1])%10&1||w==(h.s<0?8:7)),S<1||!N[0])return N.length=0,A?(S-=h.e+1,N[0]=I[(He-S%He)%He],h.e=-S||0):N[0]=h.e=0,h;if(k==0?(N.length=P,x=1,P--):(N.length=P+1,x=I[He-k],N[P]=E>0?dr(C/I[f-E]%I[E])*x:0),A)for(;;)if(P==0){for(k=1,E=N[0];E>=10;E/=10,k++);for(E=N[0]+=x,x=1;E>=10;E/=10,x++);k!=x&&(h.e++,N[0]==Pr&&(N[0]=1));break}else{if(N[P]+=x,N[P]!=Pr)break;N[P--]=0,x=1}for(k=N.length;N[--k]===0;N.pop());}h.e>d?h.c=h.e=null:h.e<l&&(h.c=[h.e=0])}return h}function R(h){var S,w=h.e;return w===null?h.toString():(S=pr(h.c),S=w<=u||w>=c?uc(S,w):co(S,w,"0"),h.s<0?"-"+S:S)}return o.absoluteValue=o.abs=function(){var h=new v(this);return h.s<0&&(h.s=1),h},o.comparedTo=function(h,S){return ii(this,new v(h,S))},o.decimalPlaces=o.dp=function(h,S){var w,A,f,k=this;if(h!=null)return Ot(h,0,cn),S==null?S=a:Ot(S,0,8),L(new v(k),h+k.e+1,S);if(!(w=k.c))return null;if(A=((f=w.length-1)-gr(this.e/He))*He,f=w[f])for(;f%10==0;f/=10,A--);return A<0&&(A=0),A},o.dividedBy=o.div=function(h,S){return t(this,new v(h,S),s,a)},o.dividedToIntegerBy=o.idiv=function(h,S){return t(this,new v(h,S),0,1)},o.exponentiatedBy=o.pow=function(h,S){var w,A,f,k,E,x,C,P,B,N=this;if(h=new v(h),h.c&&!h.isInteger())throw Error(jn+"Exponent not an integer: "+R(h));if(S!=null&&(S=new v(S)),x=h.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!h.c||!h.c[0])return B=new v(Math.pow(+R(N),x?h.s*(2-cc(h)):+R(h))),S?B.mod(S):B;if(C=h.s<0,S){if(S.c?!S.c[0]:!S.s)return new v(NaN);A=!C&&N.isInteger()&&S.isInteger(),A&&(N=N.mod(S))}else{if(h.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||x&&N.c[1]>=24e7:N.c[0]<8e13||x&&N.c[0]<=9999975e7)))return k=N.s<0&&cc(h)?-0:0,N.e>-1&&(k=1/k),new v(C?1/k:k);m&&(k=ym(m/He+2))}for(x?(w=new v(.5),C&&(h.s=1),P=cc(h)):(f=Math.abs(+R(h)),P=f%2),B=new v(i);;){if(P){if(B=B.times(N),!B.c)break;k?B.c.length>k&&(B.c.length=k):A&&(B=B.mod(S))}if(f){if(f=dr(f/2),f===0)break;P=f%2}else if(h=h.times(w),L(h,h.e+1,1),h.e>14)P=cc(h);else{if(f=+R(h),f===0)break;P=f%2}N=N.times(N),k?N.c&&N.c.length>k&&(N.c.length=k):A&&(N=N.mod(S))}return A?B:(C&&(B=i.div(B)),S?B.mod(S):k?L(B,m,a,E):B)},o.integerValue=function(h){var S=new v(this);return h==null?h=a:Ot(h,0,8),L(S,S.e+1,h)},o.isEqualTo=o.eq=function(h,S){return ii(this,new v(h,S))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(h,S){return ii(this,new v(h,S))>0},o.isGreaterThanOrEqualTo=o.gte=function(h,S){return(S=ii(this,new v(h,S)))===1||S===0},o.isInteger=function(){return!!this.c&&gr(this.e/He)>this.c.length-2},o.isLessThan=o.lt=function(h,S){return ii(this,new v(h,S))<0},o.isLessThanOrEqualTo=o.lte=function(h,S){return(S=ii(this,new v(h,S)))===-1||S===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(h,S){var w,A,f,k,E=this,x=E.s;if(h=new v(h,S),S=h.s,!x||!S)return new v(NaN);if(x!=S)return h.s=-S,E.plus(h);var C=E.e/He,P=h.e/He,B=E.c,N=h.c;if(!C||!P){if(!B||!N)return B?(h.s=-S,h):new v(N?E:NaN);if(!B[0]||!N[0])return N[0]?(h.s=-S,h):new v(B[0]?E:a==3?-0:0)}if(C=gr(C),P=gr(P),B=B.slice(),x=C-P){for((k=x<0)?(x=-x,f=B):(P=C,f=N),f.reverse(),S=x;S--;f.push(0));f.reverse()}else for(A=(k=(x=B.length)<(S=N.length))?x:S,x=S=0;S<A;S++)if(B[S]!=N[S]){k=B[S]<N[S];break}if(k&&(f=B,B=N,N=f,h.s=-h.s),S=(A=N.length)-(w=B.length),S>0)for(;S--;B[w++]=0);for(S=Pr-1;A>x;){if(B[--A]<N[A]){for(w=A;w&&!B[--w];B[w]=S);--B[w],B[A]+=Pr}B[A]-=N[A]}for(;B[0]==0;B.splice(0,1),--P);return B[0]?$(h,B,P):(h.s=a==3?-1:1,h.c=[h.e=0],h)},o.modulo=o.mod=function(h,S){var w,A,f=this;return h=new v(h,S),!f.c||!h.s||h.c&&!h.c[0]?new v(NaN):!h.c||f.c&&!f.c[0]?new v(f):(p==9?(A=h.s,h.s=1,w=t(f,h,0,3),h.s=A,w.s*=A):w=t(f,h,0,p),h=f.minus(w.times(h)),!h.c[0]&&p==1&&(h.s=f.s),h)},o.multipliedBy=o.times=function(h,S){var w,A,f,k,E,x,C,P,B,N,I,z,W,M,ie,K=this,ae=K.c,xe=(h=new v(h,S)).c;if(!ae||!xe||!ae[0]||!xe[0])return!K.s||!h.s||ae&&!ae[0]&&!xe||xe&&!xe[0]&&!ae?h.c=h.e=h.s=null:(h.s*=K.s,!ae||!xe?h.c=h.e=null:(h.c=[0],h.e=0)),h;for(A=gr(K.e/He)+gr(h.e/He),h.s*=K.s,C=ae.length,N=xe.length,C<N&&(W=ae,ae=xe,xe=W,f=C,C=N,N=f),f=C+N,W=[];f--;W.push(0));for(M=Pr,ie=Bo,f=N;--f>=0;){for(w=0,I=xe[f]%ie,z=xe[f]/ie|0,E=C,k=f+E;k>f;)P=ae[--E]%ie,B=ae[E]/ie|0,x=z*P+B*I,P=I*P+x%ie*ie+W[k]+w,w=(P/M|0)+(x/ie|0)+z*B,W[k--]=P%M;W[k]=w}return w?++A:W.splice(0,1),$(h,W,A)},o.negated=function(){var h=new v(this);return h.s=-h.s||null,h},o.plus=function(h,S){var w,A=this,f=A.s;if(h=new v(h,S),S=h.s,!f||!S)return new v(NaN);if(f!=S)return h.s=-S,A.minus(h);var k=A.e/He,E=h.e/He,x=A.c,C=h.c;if(!k||!E){if(!x||!C)return new v(f/0);if(!x[0]||!C[0])return C[0]?h:new v(x[0]?A:f*0)}if(k=gr(k),E=gr(E),x=x.slice(),f=k-E){for(f>0?(E=k,w=C):(f=-f,w=x),w.reverse();f--;w.push(0));w.reverse()}for(f=x.length,S=C.length,f-S<0&&(w=C,C=x,x=w,S=f),f=0;S;)f=(x[--S]=x[S]+C[S]+f)/Pr|0,x[S]=Pr===x[S]?0:x[S]%Pr;return f&&(x=[f].concat(x),++E),$(h,x,E)},o.precision=o.sd=function(h,S){var w,A,f,k=this;if(h!=null&&h!==!!h)return Ot(h,1,cn),S==null?S=a:Ot(S,0,8),L(new v(k),h,S);if(!(w=k.c))return null;if(f=w.length-1,A=f*He+1,f=w[f]){for(;f%10==0;f/=10,A--);for(f=w[0];f>=10;f/=10,A++);}return h&&k.e+1>A&&(A=k.e+1),A},o.shiftedBy=function(h){return Ot(h,-bm,bm),this.times("1e"+h)},o.squareRoot=o.sqrt=function(){var h,S,w,A,f,k=this,E=k.c,x=k.s,C=k.e,P=s+4,B=new v("0.5");if(x!==1||!E||!E[0])return new v(!x||x<0&&(!E||E[0])?NaN:E?k:1/0);if(x=Math.sqrt(+R(k)),x==0||x==1/0?(S=pr(E),(S.length+C)%2==0&&(S+="0"),x=Math.sqrt(+S),C=gr((C+1)/2)-(C<0||C%2),x==1/0?S="5e"+C:(S=x.toExponential(),S=S.slice(0,S.indexOf("e")+1)+C),w=new v(S)):w=new v(x+""),w.c[0]){for(C=w.e,x=C+P,x<3&&(x=0);;)if(f=w,w=B.times(f.plus(t(k,f,P,1))),pr(f.c).slice(0,x)===(S=pr(w.c)).slice(0,x))if(w.e<C&&--x,S=S.slice(x-3,x+1),S=="9999"||!A&&S=="4999"){if(!A&&(L(f,f.e+s+2,0),f.times(f).eq(k))){w=f;break}P+=4,x+=4,A=1}else{(!+S||!+S.slice(1)&&S.charAt(0)=="5")&&(L(w,w.e+s+2,1),h=!w.times(w).eq(k));break}}return L(w,w.e+s+1,a,h)},o.toExponential=function(h,S){return h!=null&&(Ot(h,0,cn),h++),D(this,h,S,1)},o.toFixed=function(h,S){return h!=null&&(Ot(h,0,cn),h=h+this.e+1),D(this,h,S)},o.toFormat=function(h,S,w){var A,f=this;if(w==null)h!=null&&S&&typeof S=="object"?(w=S,S=null):h&&typeof h=="object"?(w=h,h=S=null):w=b;else if(typeof w!="object")throw Error(jn+"Argument not an object: "+w);if(A=f.toFixed(h,S),f.c){var k,E=A.split("."),x=+w.groupSize,C=+w.secondaryGroupSize,P=w.groupSeparator||"",B=E[0],N=E[1],I=f.s<0,z=I?B.slice(1):B,W=z.length;if(C&&(k=x,x=C,C=k,W-=k),x>0&&W>0){for(k=W%x||x,B=z.substr(0,k);k<W;k+=x)B+=P+z.substr(k,x);C>0&&(B+=P+z.slice(k)),I&&(B="-"+B)}A=N?B+(w.decimalSeparator||"")+((C=+w.fractionGroupSize)?N.replace(new RegExp("\\d{"+C+"}\\B","g"),"$&"+(w.fractionGroupSeparator||"")):N):B}return(w.prefix||"")+A+(w.suffix||"")},o.toFraction=function(h){var S,w,A,f,k,E,x,C,P,B,N,I,z=this,W=z.c;if(h!=null&&(x=new v(h),!x.isInteger()&&(x.c||x.s!==1)||x.lt(i)))throw Error(jn+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+R(x));if(!W)return new v(z);for(S=new v(i),P=w=new v(i),A=C=new v(i),I=pr(W),k=S.e=I.length-z.e-1,S.c[0]=Sm[(E=k%He)<0?He+E:E],h=!h||x.comparedTo(S)>0?k>0?S:P:x,E=d,d=1/0,x=new v(I),C.c[0]=0;B=t(x,S,0,1),f=w.plus(B.times(A)),f.comparedTo(h)!=1;)w=A,A=f,P=C.plus(B.times(f=P)),C=f,S=x.minus(B.times(f=S)),x=f;return f=t(h.minus(w),A,0,1),C=C.plus(f.times(P)),w=w.plus(f.times(A)),C.s=P.s=z.s,k=k*2,N=t(P,A,k,a).minus(z).abs().comparedTo(t(C,w,k,a).minus(z).abs())<1?[P,A]:[C,w],d=E,N},o.toNumber=function(){return+R(this)},o.toPrecision=function(h,S){return h!=null&&Ot(h,1,cn),D(this,h,S,2)},o.toString=function(h){var S,w=this,A=w.s,f=w.e;return f===null?A?(S="Infinity",A<0&&(S="-"+S)):S="NaN":(h==null?S=f<=u||f>=c?uc(pr(w.c),f):co(pr(w.c),f,"0"):h===10&&F?(w=L(new v(w),s+f+1,a),S=co(pr(w.c),w.e,"0")):(Ot(h,2,T.length,"Base"),S=n(co(pr(w.c),f,"0"),10,h,A,!0)),A<0&&w.c[0]&&(S="-"+S)),S},o.valueOf=o.toJSON=function(){return R(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&v.set(e),v}function gr(e){var t=e|0;return e>0||e===t?t:t-1}function pr(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 ii(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 Ot(e,t,n,r){if(e<t||e>n||e!==dr(e))throw Error(jn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function cc(e){var t=e.c.length-1;return gr(e.e/He)==t&&e.c[t]%2!=0}function uc(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function co(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 Wz=$v(),Uv=Wz;var Vz=24,ra=32,Gz=()=>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,vm=Gz(),wm=(e=4,t=vm)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function qz(e){let t=new Uv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var Hv=(e="")=>{let t=new TextEncoder;return qz(Ov(t.encode(e))).toString(36).slice(1)},jv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),Yz=e=>jv[Math.floor(e()*jv.length)],Kz=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=vm}={})=>{let n=Object.keys(e).toString(),r=n.length?n+wm(ra,t):wm(ra,t);return Hv(r).substring(0,ra)},Xz=e=>()=>e++,Qz=476782367,Wv=({random:e=vm,counter:t=Xz(Math.floor(e()*Qz)),length:n=Vz,fingerprint:r=Kz({random:e})}={})=>{if(n>ra)throw new Error(`Length must be between 2 and ${ra}. Received: ${n}`);return function(){let i=Yz(e),s=Date.now().toString(36),a=t().toString(36),u=wm(n,e),c=`${s+u+a+r}`;return`${i+Hv(c).substring(1,n)}`}},Do=Jz(Wv);function Jz(e){let t;return()=>(t||(t=e()),t())}var tN=el(qv());ln();Ne();var pc=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function nN(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function km(e,t){let n=[],r=e.split(`
15
- `);for(let s=0;s<r.length;s++){let a=nN(r[s]),u=pc.exec(a);if(u){let[,c,l,,d]=u,g=rN(l),p=oN(r,s+1),m={id:Do(),reviewId:t,type:c.trim(),severity:g,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(m)}pc.lastIndex=0}return n.map(s=>{let a=Ws(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 rN(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function oN(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||pc.test(i)){pc.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}Ne();var oa=null,Yv=0,iN=3e4;async function sN(){let e=Date.now();if(oa&&e-Yv<iN)return oa;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 oa=n.entries||n.stories||{},Yv=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(oa).length),oa}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function ia(e){try{let n=(await sN())[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 Cm(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function aN(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 Tm(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):aN(e.type,t)}ln();Ne();function lN(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 cN(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 uN(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 pN(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 Im(e){if(!e||e.length===0)return[];let t=e.filter(i=>!uN(i)),n=[],r=[];for(let i of t){let s=lN(i),a=cN(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(pN(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}Ne();ln();var dN=[/Failed to fetch/i,/NetworkError/i,/network request failed/i,/load failed/i,/ERR_(NETWORK|INTERNET|CONNECTION|NAME_NOT_RESOLVED)/i,/timed out/i,/aborted/i],gN=[/credits?/i,/Rate limit/i,/Figma connection expired/i,/Map.*to Figma|Figma mapping required/i,/No project selected/i,/Not authenticated/i,/No story/i,/Monthly review limit/i,/Upgrade your plan/i];function Kv(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return gN.some(n=>n.test(t))?t:dN.some(n=>n.test(t))?`Can't reach ${Et.NAME}. Check your internet connection and try again. If the dashboard URL is wrong, fix it in Settings.`:/Unauthorized|401/i.test(t)?"Your session expired. Sign out and back in from Settings to continue.":/Internal Server Error|5\d\d|server error/i.test(t)?`${Et.NAME}'s servers had a hiccup. Try the review again in a moment. If it keeps failing, send feedback.`:/parsing|SSE|stream|structured result|failed to receive/i.test(t)?"Review completed but the result was malformed. Try again, or send feedback if it keeps happening.":`Review failed: ${t}. Try again, or send feedback if this keeps happening.`}$e();import{addons as Vi}from"storybook/manager-api";var Fm="uireview/badge",Hi={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function fN(e){return e.score<70?"status-value:error":e.score<90?"status-value:warning":"status-value:success"}function mN(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 hN(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Wi(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Jv(e){if(Wi())try{Vi.getChannel().emit(Hi.REVIEW_START,{storyId:e})}catch{}}function jr(e,t){if(Wi())try{Vi.getChannel().emit(Hi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function Zv(e){if(Wi())try{Vi.getChannel().emit(Hi.REVIEW_ERROR,{storyId:e})}catch{}}function Xv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Qv=null;function ek(e){if(Qv!==null)return;let t=Vi.getChannel(),n=o=>i=>{Wi()&&o(i)};t.on(Hi.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:Fm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(Hi.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:fN(i),typeId:Fm,storyId:o,title:hN(i),description:mN(i)}])})),t.on(Hi.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:Fm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Wi();r||Xv(e),Qv=setInterval(()=>{let o=Wi();o!==r&&(r=o,o||Xv(e))},1500)}var xN="uireview/mapped",tk="uireview/mappings-updated";function nk(e){try{Vi.getChannel().emit(tk,{storyIds:e})}catch{}}function rk(e){Vi.getChannel().on(tk,({storyIds:n})=>{n.length&&e.set(n.map(r=>({value:"status-value:success",typeId:xN,storyId:r,title:"\u2713 Linked to Figma",description:"Story has a Figma mapping"})))})}var Em=Y(),Am=180;function Ro(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 Pm=()=>{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,setReviewingStoryId:g,setReviewError:p,setReviewResults:m,setShowReviewMenu:b,setSeverityFilter:T,setShowStreamingPanel:F,setStreamingPanelCollapsed:v,addStreamingMessage:D,updateStreamingMessage:_,clearStreamingMessages:$,setStreamingProgress:L,setStreamingStatus:R,setFullPrompt:h,setFullResponse:S,setFigmaImageUrl:w,storybookImageUrl:A,setStorybookImageUrl:f,setFigmaDimensions:k,setMultiModelResults:E,updateMultiModelStreamingMessages:x,setModelCompleted:C,setActiveModelId:P,resetReview:B,addReview:N,setReviewDetailTab:I,includeTextComparison:z,usePromptCache:W,setApplyFixesResult:M,featureFlags:ie,roleOverride:K}=ue(),{sessionToken:ae,usageData:xe,setUsageData:Pe}=Se(),{selectedProjectId:Ye}=Xe(),{currentStoryId:ne,currentStoryName:Te}=Ze(),it=dc(xe);it.current=xe;let te=dc(null),Be=dc(null),ge=dc({}),dt=sa((fe,Fe)=>{D({role:fe,content:Fe})},[D]),ot=sa((fe,Fe)=>{L(fe),R(Fe)},[L,R]),bn=sa(async fe=>{let{isIteration:Fe=!1,parentReviewId:q=null}=fe||{};if(!ae)throw new Error("Not authenticated");if(!Ye)throw new Error("No project selected");if(!ne||!Te)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let je=Date.now();try{d(!0),g(ne),p(null),m(null),I("issues"),M(null),ne&&ie.enableReviewBadges&&Jv(ne),Be.current&&clearTimeout(Be.current),Be.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${Am}s timeout`),te.current&&te.current.abort(),D({role:"system",content:`Review auto-stopped after ${Am} seconds timeout.`})},Am*1e3),h(""),S(""),F(!0),v(!1),$(),ot(0,"Starting review..."),ot(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await ic(),y.debug("[Review] Iframe reloaded, styles should be fresh"),ot(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[gt,O,j]=await Promise.all([rc({sessionToken:ae||void 0}),Promise.resolve(ta()),Promise.resolve(pm())]);if(gt&&gt!==A&&(f(gt),y.debug("[Review] Storybook screenshot captured and set")),!O)throw new Error("Failed to extract styles from component");let{computed:G,declared:H,markup:le,textElementStyles:me,nestedElementStyles:Dn}=O;j?y.debug("[Review] DOM tree extracted:",{selector:j.selector,childrenCount:j.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")),ot(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:ne,name:Te});let vt=yt.getState().currentMapping?.figmaNodeId??null,Sr=yt.getState().figmaImageUrl;if(vt&&(y.debug("[Review] Using Figma node ID from store:",vt),Sr&&(ot(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!vt)try{let Ke=await fetch(`${Em}/api/mappings?projectId=${Ye}&storyId=${ne}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`}});if(Ke.ok){let Nt=await Ke.json();Nt.mapping?.figmaNodeId?(vt=Nt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",vt)):y.debug("[Review] No mapping found for story:",ne)}else y.debug("[Review] Failed to fetch mapping:",Ke.status)}catch(Ke){y.error("[Review] Error fetching mapping:",Ke)}if(vt&&!Sr){ot(65,"Fetching Figma design...");try{let Ke=await fetch(`${Em}/api/figma/frames?projectId=${Ye}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`}});if(Ke.ok){let jt=(await Ke.json()).thumbnails?.[vt];jt?(w(jt),y.debug("[Review] Figma thumbnail fetched and displayed:",jt)):y.warn("[Review] No thumbnail found for node:",vt)}else y.warn("[Review] Failed to fetch Figma frames:",Ke.status)}catch(Ke){y.error("[Review] Error fetching Figma frames:",Ke)}}if(!vt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');ot(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let So={projectId:Ye,storyId:ne,storyName:Te,storybookScreenshot:gt,computedStyles:G,declaredStyles:H,textElementStyles:me,nestedElementStyles:Dn,componentMarkup:le,domTree:j,figmaNodeId:vt,figmaImageUrl:Sr||void 0,aiModels:l,includeTextComparison:z,usePromptCache:W,parentReviewId:Fe?q:void 0,isIteration:Fe};y.debug("[Review] Request payload:",{...So,storybookScreenshot:gt?`${gt.substring(0,50)}...`:null,domTree:j?{selector:j.selector,childrenCount:j.children.length}:null}),te.current=new AbortController;let $t=await fetch(`${Em}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`,...sc(K)},body:JSON.stringify(So),signal:te.current.signal});if(y.debug("[Review] Response status:",$t.status,$t.statusText),!$t.ok){let Ke=await $t.json();if(y.error("[Review] API error response:",Ke),$t.status===429){let Nt=Ke.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Nt} seconds before trying again.`)}if($t.status===402){if(Ke.code==="INSUFFICIENT_CREDITS"){let Nt=Ke.details?.required??1,jt=Ke.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Nt} credit(s) but you have ${jt}. Visit Settings to add more.`)}throw Ke.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Ke.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Ke.message||"Payment required")}throw $t.status===401&&Ke.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Ke.error||Ke.message||"Review request failed")}let Xr=$t.body?.getReader(),wr=new TextDecoder,Tu="",wo="",Oe=null,Iu=null,yy=l.length>1,Xo={},fs={},g9={};if(!Xr)throw new Error("Response body is not readable");let by=yt.getState().streamingMessages.length;for(dt("assistant","");;){let{done:Ke,value:Nt}=await Xr.read();if(Ke)break;Tu+=wr.decode(Nt,{stream:!0});let jt=Tu.split(`
17
- `);Tu=jt.pop()||"";for(let Xn of jt)if(Xn.startsWith("data: ")){let fn=Xn.slice(6);if(fn==="[DONE]")continue;try{let se=JSON.parse(fn);if(se.type!=="text"&&se.type!=="content"&&y.debug("[Review] SSE Event received:",se.type),se.type==="prompt")se.prompt&&(h(se.prompt),y.debug("[Review] Prompt received early"));else if(se.type==="model_started")y.debug("[Review] Model started:",se.modelId),Xo[se.modelId]||(Xo[se.modelId]="",fs[se.modelId]=[{role:"assistant",content:""}]);else if(se.type==="text"||se.type==="content")if(yy&&se.modelId){Xo[se.modelId]||(Xo[se.modelId]="",fs[se.modelId]=[{role:"assistant",content:""}]),Xo[se.modelId]+=se.content,fs[se.modelId][0].content=Xo[se.modelId],x(se.modelId,fs[se.modelId]);let Kt=Object.entries(Xo).map(([mn,st])=>`[${mn}]
12
+ --`+new Array((n||t.length)+1).join("-")+"^"})}var t0=U(()=>{"use strict";wl()});var bP,SP,wP,vP,kP,n0,Nl,r0=U(()=>{"use strict";t0();bP=9,SP=10,wP=12,vP=13,kP=32,n0=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),Nl=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&&n0[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!==vP&&n!==SP&&n!==wP&&n!==kP&&n!==bP)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 e0(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||n0[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 c0(e){let t=null,n=null;return e.eat($l),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===Cp?(e.pos++,e.skipWs(),e.charCode()!==wp&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(wp),{min:Number(t),max:n?Number(n):0}}function PP(e){let t=null,n=!1;switch(e.charCode()){case g0:e.pos++,t={min:0,max:0};break;case kp:e.pos++,t={min:1,max:0};break;case _l:e.pos++,t={min:0,max:1};break;case vp:e.pos++,n=!0,e.charCode()===$l?t=c0(e):e.charCode()===_l?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case $l:t=c0(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function io(e,t){let n=PP(e);return n!==null?(n.term=t,e.charCode()===vp&&e.charCodeAt(e.pos-1)===kp||e.charCode()===_l&&e.charCodeAt(e.pos-1)===wp?io(e,n):n):t}function bp(e){let t=e.peek();return t===""?null:io(e,{type:"Token",value:t})}function LP(e){let t;return e.eat(Tp),e.eat(Ol),t=e.scanWord(),e.eat(Ol),e.eat(Sp),io(e,{type:"Property",name:t})}function MP(e){let t=null,n=null,r=1;return e.eat(Rs),e.charCode()===i0&&(e.peek(),r=-1),r==-1&&e.charCode()===a0?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Cp),e.skipWs(),e.charCode()===a0?e.peek():(r=1,e.charCode()===i0&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Di),{type:"Range",min:t,max:n}}function BP(e){let t,n=null;if(e.eat(Tp),t=e.scanWord(),t==="boolean-expr"){e.eat(Rs);let r=Ul(e,Di);return e.eat(Di),e.eat(Sp),io(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===p0&&e.nextCharCode()===d0&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Rs&&(e.skipWs(),n=MP(e)),e.eat(Sp),io(e,{type:"Type",name:t,opts:n})}function DP(e){let t=e.scanWord();return e.charCode()===p0?(e.pos++,{type:"Function",name:t}):io(e,{type:"Keyword",name:t})}function RP(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)=>l0[o]-l0[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 Ul(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?Ul(e,d0):NP(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:RP(r,n)||" ",disallowEmpty:!1,explicit:!1}}function zP(e){let t;return e.eat(Rs),t=Ul(e,Di),e.eat(Di),t.explicit=!0,e.charCode()===u0&&(e.pos++,t.disallowEmpty=!0),t}function NP(e){let t=e.charCode();switch(t){case Di:break;case Rs:return io(e,zP(e));case Tp:return e.nextCharCode()===Ol?LP(e):BP(e);case s0:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===s0?2:1))};case o0:return e.pos++,e.eat(o0),{type:"Combinator",value:"&&"};case Cp:return e.pos++,{type:"Comma"};case Ol:return io(e,{type:"String",value:e.scanString()});case EP:case CP:case TP:case FP:case IP:return{type:"Spaces",value:e.scanSpaces()};case AP:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):bp(e);case g0:case kp:case _l:case vp:case u0:break;case $l:if(t=e.nextCharCode(),t<48||t>57)return bp(e);break;default:return e.isNameCharCode(t)?DP(e):bp(e)}}function zs(e){let t=new Nl(e),n=Ul(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var CP,TP,IP,FP,EP,u0,vp,o0,Ol,p0,d0,g0,kp,Cp,i0,Tp,Sp,_l,AP,Rs,Di,$l,s0,wp,a0,l0,Ip=U(()=>{"use strict";r0();CP=9,TP=10,IP=12,FP=13,EP=32,u0=33,vp=35,o0=38,Ol=39,p0=40,d0=41,g0=42,kp=43,Cp=44,i0=45,Tp=60,Sp=62,_l=63,AP=64,Rs=91,Di=93,$l=123,s0=124,wp=125,a0=8734,l0={" ":1,"&&":2,"||":3,"|":4}});function f0(e){return typeof e=="function"?e:Ns}function Fp(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=Ns,i=Ns;if(typeof t=="function"?o=t:t&&(o=f0(t.enter),i=f0(t.leave)),o===Ns&&i===Ns)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Ns,m0=U(()=>{"use strict";Ns=function(){}});var Ep=U(()=>{"use strict";ip();Ip();m0()});function $P(e){let t=[];return Fo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function h0(e,t){return typeof e=="string"?$P(e):t.generate(e,_P)}var _P,x0=U(()=>{"use strict";lr();_P={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 kn(e,t,n){return t===mt&&n===kt||e===mt&&t===mt&&n===mt?e:(e.type==="If"&&e.else===kt&&t===mt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function b0(e){return e.length>2&&e.charCodeAt(e.length-2)===UP&&e.charCodeAt(e.length-1)===jP}function y0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&b0(e.name)}function Ao(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Os(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Os(e.match,t,n),e.then=Os(e.then,t,n),e.else=Os(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function Ap(e,t,n){switch(e){case" ":{let r=mt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=kn(i,r,kt)}return r}case"|":{let r=kt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(y0(s)&&(o===null&&i>0&&y0(t[i-1])&&(o=Object.create(null),r=kn({type:"Enum",map:o},mt,r)),o!==null)){let a=(b0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=kn(s,mt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Ap(e,t.filter(function(a){return a!==i}),!1):s=mt,r=kn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?mt:kt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Ap(e,t.filter(function(a){return a!==i}),!0):s=mt,r=kn(i,s,r)}return r}}}function HP(e){let t=mt,n=Ri(e.term);if(e.max===0)n=kn(n,jl,kt),t=kn(n,null,kt),t.then=kn(mt,mt,t),e.comma&&(t.then.else=kn({type:"Comma",syntax:e},t,kt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==mt&&(t=kn({type:"Comma",syntax:e},t,kt)),t=kn(n,kn(mt,mt,t),kt);if(e.min===0)t=kn(mt,mt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==mt&&(t=kn({type:"Comma",syntax:e},t,kt)),t=kn(n,t,kt);return t}function Ri(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=Ap(e.combinator,e.terms.map(Ri),!1);return e.disallowEmpty&&(t=kn(t,jl,kt)),t}case"Multiplier":return HP(e);case"Boolean":{let t=Ri(e.term),n=Ri(Ao([Ao([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),Ao([{type:"Type",name:"!boolean-group"},Ao([{type:"Multiplier",comma:!1,min:0,max:0,term:Ao([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:Ao([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=Ri(Ao([{type:"Type",name:"!term"},Ao([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Os(r,{"!term":t,"!self":n}),Os(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 _s(e,t){return typeof e=="string"&&(e=zs(e)),{type:"MatchGraph",match:Ri(e),syntax:t||null,source:e}}var mt,kt,jl,UP,jP,Pp=U(()=>{"use strict";Ip();mt={type:"Match"},kt={type:"Mismatch"},jl={type:"DisallowEmpty"},UP=40,jP=41});function KP(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function Lp(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 XP(e){return e.type!==9?!1:e.value!=="?"}function k0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||XP(e)}function C0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function QP(e,t,n){function r(){do v++,F=v<e.length?e[v]:null;while(F!==null&&(F.type===13||F.type===25))}function o($){let M=v+$;return M<e.length?e[M]:null}function i($,M){return{nextState:$,matchStack:N,syntaxStack:d,thenStack:g,tokenIndex:v,prev:M}}function s($){g={nextState:$,matchStack:N,syntaxStack:d,prev:g}}function a($){p=i($,p)}function u(){N={type:VP,syntax:t.syntax,token:F,prev:N},r(),h=null,v>D&&(D=v)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},N={type:Mp,syntax:t.syntax,token:N.token,prev:N}}function l(){N.type===Mp?N=N.prev:N={type:T0,syntax:d.syntax,token:N.token,prev:N},d=d.prev}let d=null,g=null,p=null,h=null,b=0,I=null,F=null,v=-1,D=0,N={type:WP,syntax:null,token:null,prev:null};for(r();I===null&&++b<v0;)switch(t.type){case"Match":if(g===null){if(F!==null&&(v!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=kt;break}I=w0;break}if(t=g.nextState,t===jl)if(g.matchStack===N){t=kt;break}else t=mt;for(;g.syntaxStack!==d;)l();g=g.prev;break;case"Mismatch":if(h!==null&&h!==!1)(p===null||v>p.tokenIndex)&&(p=h,h=!1);else if(p===null){I=GP;break}t=p.nextState,g=p.thenStack,d=p.syntaxStack,N=p.matchStack,v=p.tokenIndex,F=v<e.length?e[v]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==kt&&a(t.else),t.then!==mt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let z=t.syntax.terms;if(t.index===z.length){if(t.mask===0||t.syntax.all){t=kt;break}t=mt;break}if(t.mask===(1<<z.length)-1){t=mt;break}for(;t.index<z.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=z[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let z=F.value.toLowerCase();if(z.indexOf("\\")!==-1&&(z=z.replace(/\\[09].*$/,"")),S0.call(t.map,z)){t=t.map[z];break}}t=kt;break;case"Generic":{let z=d!==null?d.opts:null,m=v+Math.floor(t.fn(F,o,z));if(!isNaN(m)&&m>v){for(;v<m;)u();t=mt}else t=kt;break}case"Type":case"Property":{let z=t.type==="Type"?"types":"properties",m=S0.call(n,z)?n[z][t.name]:null;if(!m||!m.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(h!==!1&&F!==null&&t.type==="Type"&&(t.name==="custom-ident"&&F.type===1||t.name==="length"&&F.value==="0")){h===null&&(h=i(t,p)),t=kt;break}c(),t=m.matchRef||m.match;break}case"Keyword":{let z=t.name;if(F!==null){let m=F.value;if(m.indexOf("\\")!==-1&&(m=m.replace(/\\[09].*$/,"")),Lp(m,z)){u(),t=mt;break}}t=kt;break}case"AtKeyword":case"Function":if(F!==null&&Lp(F.value,t.name)){u(),t=mt;break}t=kt;break;case"Token":if(F!==null&&F.value===t.value){u(),t=mt;break}t=kt;break;case"Comma":F!==null&&F.type===18?k0(N.token)?t=kt:(u(),t=C0(F)?kt:mt):t=k0(N.token)||C0(F)?mt:kt;break;case"String":let $="",M=v;for(;M<e.length&&$.length<t.value.length;M++)$+=e[M].value;if(Lp($,t.value)){for(;v<M;)u();t=mt}else t=kt;break;default:throw new Error("Unknown node type: "+t.type)}switch(YP+=b,I){case null:console.warn("[csstree-match] BREAK after "+v0+" iterations"),I=qP,N=null;break;case w0:for(;d!==null;)l();break;default:N=null}return{tokens:e,reason:I,iterations:b,match:N,longestMatch:D}}function Bp(e,t,n){let r=QP(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=KP(o).prev;o!==null;){switch(o.type){case Mp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case T0: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 S0,WP,VP,Mp,T0,w0,GP,qP,v0,YP,I0=U(()=>{"use strict";Pp();({hasOwnProperty:S0}=Object.prototype),WP=0,VP=1,Mp=2,T0=3,w0="Match",GP="Mismatch",qP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",v0=15e3,YP=0});var Rp={};ye(Rp,{getTrace:()=>F0,isKeyword:()=>e2,isProperty:()=>ZP,isType:()=>JP});function F0(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 JP(e,t){return Dp(this,e,n=>n.type==="Type"&&n.name===t)}function ZP(e,t){return Dp(this,e,n=>n.type==="Property"&&n.name===t)}function e2(e){return Dp(this,e,t=>t.type==="Keyword")}function Dp(e,t,n){let r=F0.call(e,t);return r===null?!1:r.some(n)}var E0=U(()=>{"use strict"});function A0(e){return"node"in e?e.node:A0(e.match[0])}function P0(e){return"node"in e?e.node:P0(e.match[e.match.length-1])}function zp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=A0(a),c=P0(a);e.syntax.walk(t,function(l,d,g){if(l===u){let p=new Zn;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:g,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var L0=U(()=>{"use strict";Fs()});function Np(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function M0(e){return!!e&&Np(e.offset)&&Np(e.line)&&Np(e.column)}function t2(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($s.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(!M0(r.loc.start))i+=".start";else if(!M0(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 Zn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)$s.call(t,i)&&$s.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function B0(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<"+(B0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function n2(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if($s.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=B0(s,e+"."+i)}return{docs:o,check:t2(e,r)}}function D0(e){let t={};if(e.node){for(let n in e.node)if($s.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=n2(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var $s,R0=U(()=>{"use strict";Fs();({hasOwnProperty:$s}=Object.prototype)});function Op(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:Ai(e[o].syntax,{compact:t}));return r}function r2(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:Ai(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&Op(i.descriptors,t,n)};return r}function o2(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function i2(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function Fr(e,t,n){return{matched:e,iterations:n,error:t,...Rp}}function zi(e,t,n,r){let o=h0(n,e.syntax),i;return o2(o)?Fr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=Bp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=Bp(o,t.match,e),!i.match)?Fr(null,new Ob(i.reason,t.syntax,n,i),i.iterations):Fr(i.match,null,i.iterations))}var Us,z0=U(()=>{"use strict";_b();Ml();Bl();Jb();Zb();Ep();x0();Pp();I0();E0();L0();R0();Us=class{constructor(t,n,r){if(this.cssWideKeywords=Mi,this.syntax=n,this.generic=!1,this.units={...zl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||D0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(zl))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(Qb(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=_s(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=_s(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:zs(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:_s(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=i2(a)?_s({...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 Pi("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&&!zi(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=Pl(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 Pi("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new Pi("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return Fr(null,r);let o=this.getAtrule(t);return o.prelude?zi(this,o.prelude,n||"",!1):Fr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return Fr(null,o);let i=this.getAtrule(t),s=Pl(n);return zi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?Fr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(sp(t).custom)return Fr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?Fr(null,r):zi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?zi(this,r,n,!1):Fr(null,new Pi("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?Fr(null,new Pi("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),zi(this,t,n,!1))}findValueFragments(t,n,r,o){return zp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return zp(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=Pl(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=sp(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&&Fp(d.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let p=g.type==="Type"?u.types:u.properties,h=g.type==="Type"?o:i;hasOwnProperty.call(p,g.name)?n(u,g.name,h,p[g.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(g.name,g.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:r2(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function _p(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function s2(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function $p(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?s2(i,n):i};return r}function js(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?_p(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?_p(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]=_p(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=$p(e[r],o);break;case"atrule":case"pseudo":n[r]=$p(e[r],o,["parse"]);break;case"node":n[r]=$p(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var N0=U(()=>{"use strict"});function O0(e){let t=Zy(e),n=Rb(e),r=Fb(e),{fromPlainObject:o,toPlainObject:i}=Ab(n),s={lexer:null,createLexer:a=>new Us(a,s,s.lexer.structure),tokenize:Fo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=js({},e);return O0(typeof a=="function"?a(u):js(u,a))}};return s.lexer=new Us({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var _0,$0=U(()=>{"use strict";lr();eb();Eb();Pb();zb();z0();N0();_0=e=>O0(js({},e))});var U0,j0=U(()=>{"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 Hp={};ye(Hp,{generate:()=>u2,name:()=>l2,parse:()=>jp,structure:()=>c2});function Wl(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Ur||r===er)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)Ht(this.charCodeAt(n))||this.error("Integer is expected",n)}function Ni(e){return Wl.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 er:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Up(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Ur,e)||this.isDelim(er,e)){t=this.isDelim(Ur,e)?Ur:er;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Ni.call(this,ni))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Ur&&n!==er&&this.error("Number sign is expected")),Ni.call(this,t!==0),t===er?"-"+this.consume(10):this.consume(10)}function jp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Ni.call(this,a2),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,er))switch(t="-1",Po.call(this,1,Hl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Up.call(this);break;case 3:Po.call(this,2,er),this.next(),this.skipSC(),Ni.call(this,ni),n="-"+this.consume(10);break;default:Po.call(this,2,er),Wl.call(this,3,ni),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Ur)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Ur)&&(r=1,this.next()),Po.call(this,0,Hl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Up.call(this);break;case 2:Po.call(this,1,er),this.next(),this.skipSC(),Ni.call(this,ni),n="-"+this.consume(10);break;default:Po.call(this,1,er),Wl.call(this,2,ni),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Ur||r===er,i=this.tokenStart+o;for(;i<this.tokenEnd&&Ht(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=Up.call(this)):(Po.call(this,i-this.tokenStart+1,er),i+2===this.tokenEnd?(this.next(),this.skipSC(),Ni.call(this,ni),n="-"+this.consume(10)):(Wl.call(this,i-this.tokenStart+2,ni),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Ur&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Ur&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function u2(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 Ur,er,Hl,ni,a2,l2,c2,Wp=U(()=>{"use strict";lr();Ur=43,er=45,Hl=110,ni=!0,a2=!1;l2="AnPlusB",c2={a:[String,null],b:[String,null]}});var Gp={};ye(Gp,{generate:()=>m2,name:()=>d2,parse:()=>Vp,structure:()=>f2,walkContext:()=>g2});function H0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function p2(){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 Vp(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),H0):o=H0.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(p2.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function m2(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var d2,g2,f2,qp=U(()=>{"use strict";d2="Atrule",g2="atrule",f2={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var Kp={};ye(Kp,{generate:()=>b2,name:()=>h2,parse:()=>Yp,structure:()=>y2,walkContext:()=>x2});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 b2(e){this.children(e)}var h2,x2,y2,Xp=U(()=>{"use strict";h2="AtrulePrelude",x2="atrulePrelude",y2={children:[[]]}});var Zp={};ye(Zp,{generate:()=>F2,name:()=>T2,parse:()=>Jp,structure:()=>I2});function k2(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(W0)?(t=!0,this.next()):this.isDelim(Qp)||this.eat(1),this.isDelim(Qp)?this.charCodeAt(this.tokenStart+1)!==Vl?(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 C2(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Vl&&t!==v2&&t!==w2&&t!==S2&&t!==W0&&t!==Qp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Vl&&(this.isDelim(Vl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function Jp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=k2.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=C2.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 F2(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 S2,W0,Vl,w2,Qp,v2,T2,I2,ed=U(()=>{"use strict";S2=36,W0=42,Vl=61,w2=94,Qp=124,v2=126;T2="AttributeSelector",I2={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var nd={};ye(nd,{generate:()=>B2,name:()=>P2,parse:()=>td,structure:()=>M2,walkContext:()=>L2});function q0(){return this.Raw(null,!0)}function V0(){return this.parseWithFallback(this.Rule,q0)}function G0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function A2(){if(this.tokenType===17)return G0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,G0);return this.tokenType===17&&this.next(),e}function td(e){let t=e?A2:V0,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),q0));break;default:e&&this.isDelim(E2)?r.push(V0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function B2(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var E2,P2,L2,M2,rd=U(()=>{"use strict";E2=38;P2="Block",L2="block",M2={children:[["Atrule","Rule","Declaration"]]}});var id={};ye(id,{generate:()=>z2,name:()=>D2,parse:()=>od,structure:()=>R2});function od(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 z2(e){this.token(9,"["),this.children(e),this.token(9,"]")}var D2,R2,sd=U(()=>{"use strict";D2="Brackets",R2={children:[[]]}});var ld={};ye(ld,{generate:()=>_2,name:()=>N2,parse:()=>ad,structure:()=>O2});function ad(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function _2(){this.token(15,"-->")}var N2,O2,cd=U(()=>{"use strict";N2="CDC",O2=[]});var pd={};ye(pd,{generate:()=>j2,name:()=>$2,parse:()=>ud,structure:()=>U2});function ud(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function j2(){this.token(14,"<!--")}var $2,U2,dd=U(()=>{"use strict";$2="CDO",U2=[]});var fd={};ye(fd,{generate:()=>G2,name:()=>W2,parse:()=>gd,structure:()=>V2});function gd(){return this.eatDelim(H2),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function G2(e){this.token(9,"."),this.token(1,e.name)}var H2,W2,V2,md=U(()=>{"use strict";H2=46,W2="ClassSelector",V2={name:String}});var xd={};ye(xd,{generate:()=>J2,name:()=>X2,parse:()=>hd,structure:()=>Q2});function hd(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case Y2:case q2:case K2:this.next();break;case Y0:this.next(),this.eatIdent("deep"),this.eatDelim(Y0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function J2(e){this.tokenize(e.name)}var q2,Y0,Y2,K2,X2,Q2,yd=U(()=>{"use strict";q2=43,Y0=47,Y2=62,K2=126,X2="Combinator",Q2={name:String}});var Sd={};ye(Sd,{generate:()=>rL,name:()=>tL,parse:()=>bd,structure:()=>nL});function bd(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===Z2&&this.charCodeAt(t-1)===eL&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function rL(e){this.token(25,"/*"+e.value+"*/")}var Z2,eL,tL,nL,wd=U(()=>{"use strict";Z2=42,eL=47,tL="Comment",nL={value:String}});var kd={};ye(kd,{generate:()=>lL,name:()=>iL,parse:()=>vd,structure:()=>sL});function K0(e){return this.lookupTypeNonSC(1)===1&&oL.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function vd(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(()=>aL[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 lL(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var oL,iL,sL,aL,Cd=U(()=>{"use strict";oL=new Set([16,22,0]),iL="Condition",sL={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};aL={media:K0,container:K0,supports(){return this.SupportsDeclaration()}}});var Id={};ye(Id,{generate:()=>SL,name:()=>xL,parse:()=>Td,structure:()=>bL,walkContext:()=>yL});function fL(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function mL(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function hL(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(Q0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function Td(){let e=this.tokenStart,t=this.tokenIndex,n=wL.call(this),r=Ll(n),o=r?this.parseCustomProperty:this.parseValue,i=r?mL:fL,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(hL,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(Q0)&&(s=vL.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 SL(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 wL(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case dL:case uL:case gL:case cL:case pL: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 vL(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var Q0,cL,uL,pL,dL,gL,X0,xL,yL,bL,Fd=U(()=>{"use strict";Ml();Q0=33,cL=35,uL=36,pL=38,dL=42,gL=43,X0=47;xL="Declaration",yL="declaration",bL={important:[Boolean,String],property:String,value:["Value","Raw"]}});var Pd={};ye(Pd,{generate:()=>IL,name:()=>CL,parse:()=>Ad,structure:()=>TL});function Ed(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Ad(){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),Ed));break;default:this.isDelim(kL)?e.push(this.parseWithFallback(this.Rule,Ed)):e.push(this.parseWithFallback(this.Declaration,Ed))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function IL(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var kL,CL,TL,Ld=U(()=>{"use strict";kL=38;CL="DeclarationList",TL={children:[["Declaration","Atrule","Rule"]]}});var Bd={};ye(Bd,{generate:()=>AL,name:()=>FL,parse:()=>Md,structure:()=>EL});function Md(){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 AL(e){this.token(12,e.value+e.unit)}var FL,EL,Dd=U(()=>{"use strict";FL="Dimension",EL={value:String,unit:String}});var zd={};ye(zd,{generate:()=>BL,name:()=>LL,parse:()=>Rd,structure:()=>ML});function Rd(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(PL)&&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 BL(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var PL,LL,ML,Nd=U(()=>{"use strict";PL=47,LL="Feature",ML={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var _d={};ye(_d,{generate:()=>NL,name:()=>DL,parse:()=>Od,structure:()=>RL});function zL(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=zL.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 NL(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var DL,RL,$d=U(()=>{"use strict";DL="FeatureFunction",RL={kind:String,feature:String,value:["Declaration","Selector"]}});var Hd={};ye(Hd,{generate:()=>jL,name:()=>$L,parse:()=>jd,structure:()=>UL});function Ud(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(J0,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(J0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function eS(e){if(this.skipSC(),this.isDelim(OL)||this.isDelim(_L)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(Z0)?(this.next(),t+"="):t}if(this.isDelim(Z0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function jd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Ud.call(this),r=eS.call(this,n.type==="Identifier"),o=Ud.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=eS.call(this),s=Ud.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 jL(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 J0,OL,Z0,_L,$L,UL,Wd=U(()=>{"use strict";J0=47,OL=60,Z0=61,_L=62,$L="FeatureRange",UL={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 Gd={};ye(Gd,{generate:()=>GL,name:()=>HL,parse:()=>Vd,structure:()=>VL,walkContext:()=>WL});function Vd(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 GL(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var HL,WL,VL,qd=U(()=>{"use strict";HL="Function",WL="function",VL={name:String,children:[[]]}});var Kd={};ye(Kd,{generate:()=>KL,name:()=>qL,parse:()=>Yd,structure:()=>YL});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 KL(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var qL,YL,Xd=U(()=>{"use strict";qL="GeneralEnclosed",YL={kind:String,function:[String,null],children:[[]]}});var Jd={};ye(Jd,{generate:()=>ZL,name:()=>QL,parse:()=>Qd,structure:()=>JL,xxx:()=>XL});function Qd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function ZL(e){this.token(4,"#"+e.value)}var XL,QL,JL,Zd=U(()=>{"use strict";XL="XXX",QL="Hash",JL={value:String}});var tg={};ye(tg,{generate:()=>nM,name:()=>eM,parse:()=>eg,structure:()=>tM});function eg(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function nM(e){this.token(1,e.name)}var eM,tM,ng=U(()=>{"use strict";eM="Identifier",tM={name:String}});var og={};ye(og,{generate:()=>iM,name:()=>rM,parse:()=>rg,structure:()=>oM});function rg(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function iM(e){this.token(9,"#"+e.name)}var rM,oM,ig=U(()=>{"use strict";rM="IdSelector",oM={name:String}});var ag={};ye(ag,{generate:()=>cM,name:()=>aM,parse:()=>sg,structure:()=>lM});function sg(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(sM);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function cM(e){this.tokenize(e.name)}var sM,aM,lM,lg=U(()=>{"use strict";sM=46,aM="Layer",lM={name:String}});var ug={};ye(ug,{generate:()=>dM,name:()=>uM,parse:()=>cg,structure:()=>pM});function cg(){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 dM(e){this.children(e,()=>this.token(18,","))}var uM,pM,pg=U(()=>{"use strict";uM="LayerList",pM={children:[["Layer"]]}});var gg={};ye(gg,{generate:()=>mM,name:()=>gM,parse:()=>dg,structure:()=>fM});function dg(){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 mM(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 gM,fM,fg=U(()=>{"use strict";gM="MediaQuery",fM={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var hg={};ye(hg,{generate:()=>yM,name:()=>hM,parse:()=>mg,structure:()=>xM});function mg(){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 yM(e){this.children(e,()=>this.token(18,","))}var hM,xM,xg=U(()=>{"use strict";hM="MediaQueryList",xM={children:[["MediaQuery"]]}});var bg={};ye(bg,{generate:()=>vM,name:()=>SM,parse:()=>yg,structure:()=>wM});function yg(){let e=this.tokenStart;return this.eatDelim(bM),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function vM(){this.token(9,"&")}var bM,SM,wM,Sg=U(()=>{"use strict";bM=38,SM="NestingSelector",wM={}});var vg={};ye(vg,{generate:()=>TM,name:()=>kM,parse:()=>wg,structure:()=>CM});function wg(){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 TM(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var kM,CM,kg=U(()=>{"use strict";kM="Nth",CM={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var Tg={};ye(Tg,{generate:()=>EM,name:()=>IM,parse:()=>Cg,structure:()=>FM});function Cg(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function EM(e){this.token(10,e.value)}var IM,FM,Ig=U(()=>{"use strict";IM="Number",FM={value:String}});var Eg={};ye(Eg,{generate:()=>LM,name:()=>AM,parse:()=>Fg,structure:()=>PM});function Fg(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function LM(e){this.tokenize(e.value)}var AM,PM,Ag=U(()=>{"use strict";AM="Operator",PM={value:String}});var Lg={};ye(Lg,{generate:()=>DM,name:()=>MM,parse:()=>Pg,structure:()=>BM});function Pg(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 DM(e){this.token(21,"("),this.children(e),this.token(22,")")}var MM,BM,Mg=U(()=>{"use strict";MM="Parentheses",BM={children:[[]]}});var Dg={};ye(Dg,{generate:()=>NM,name:()=>RM,parse:()=>Bg,structure:()=>zM});function Bg(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function NM(e){this.token(11,e.value+"%")}var RM,zM,Rg=U(()=>{"use strict";RM="Percentage",zM={value:String}});var Ng={};ye(Ng,{generate:()=>UM,name:()=>OM,parse:()=>zg,structure:()=>$M,walkContext:()=>_M});function zg(){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 UM(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var OM,_M,$M,Og=U(()=>{"use strict";OM="PseudoClassSelector",_M="function",$M={name:String,children:[["Raw"],null]}});var $g={};ye($g,{generate:()=>VM,name:()=>jM,parse:()=>_g,structure:()=>WM,walkContext:()=>HM});function _g(){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 VM(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 jM,HM,WM,Ug=U(()=>{"use strict";jM="PseudoElementSelector",HM="function",WM={name:String,children:[["Raw"],null]}});var Hg={};ye(Hg,{generate:()=>YM,name:()=>GM,parse:()=>jg,structure:()=>qM});function nS(){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 jg(){let e=this.tokenStart,t=nS.call(this),n=null;return this.skipSC(),this.isDelim(tS)&&(this.eatDelim(tS),n=nS.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function YM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var tS,GM,qM,Wg=U(()=>{"use strict";tS=47;GM="Ratio",qM={left:["Number","Function"],right:["Number","Function",null]}});var Gg={};ye(Gg,{generate:()=>JM,name:()=>XM,parse:()=>Vg,structure:()=>QM});function KM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function Vg(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=KM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function JM(e){this.tokenize(e.value)}var XM,QM,qg=U(()=>{"use strict";XM="Raw",QM={value:String}});var Kg={};ye(Kg,{generate:()=>rB,name:()=>eB,parse:()=>Yg,structure:()=>nB,walkContext:()=>tB});function rS(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function ZM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function Yg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(ZM,rS):n=rS.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function rB(e){this.node(e.prelude),this.node(e.block)}var eB,tB,nB,Xg=U(()=>{"use strict";eB="Rule",tB="rule",nB={prelude:["SelectorList","Raw"],block:["Block"]}});var Jg={};ye(Jg,{generate:()=>sB,name:()=>oB,parse:()=>Qg,structure:()=>iB});function Qg(){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 sB(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 oB,iB,Zg=U(()=>{"use strict";oB="Scope",iB={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var tf={};ye(tf,{generate:()=>cB,name:()=>aB,parse:()=>ef,structure:()=>lB});function ef(){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 cB(e){this.children(e)}var aB,lB,nf=U(()=>{"use strict";aB="Selector",lB={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var of={};ye(of,{generate:()=>gB,name:()=>uB,parse:()=>rf,structure:()=>dB,walkContext:()=>pB});function rf(){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 gB(e){this.children(e,()=>this.token(18,","))}var uB,pB,dB,sf=U(()=>{"use strict";uB="SelectorList",pB="selector",dB={children:[["Selector","Raw"]]}});function Gl(e){let t=e.length,n=e.charCodeAt(0),r=n===oS||n===iS?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===af){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),Nn(af,a)){let u=s-1,c=eo(e,u);s=c-1,i+=ml(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function sS(e,t){let n=t?"'":'"',r=t?iS:oS,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===af?(o+="\\"+e.charAt(s),i=!1):(i&&(On(a)||_r(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var af,oS,iS,ql=U(()=>{"use strict";lr();af=92,oS=34,iS=39});var cf={};ye(cf,{generate:()=>hB,name:()=>fB,parse:()=>lf,structure:()=>mB});function lf(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Gl(this.consume(5))}}function hB(e){this.token(5,sS(e.value))}var fB,mB,uf=U(()=>{"use strict";ql();fB="String",mB={value:String}});var df={};ye(df,{generate:()=>wB,name:()=>yB,parse:()=>pf,structure:()=>SB,walkContext:()=>bB});function lS(){return this.Raw(null,!1)}function pf(){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)!==xB){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,lS);break;default:n=this.parseWithFallback(this.Rule,lS)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function wB(e){this.children(e)}var xB,yB,bB,SB,gf=U(()=>{"use strict";xB=33;yB="StyleSheet",bB="stylesheet",SB={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var mf={};ye(mf,{generate:()=>CB,name:()=>vB,parse:()=>ff,structure:()=>kB});function ff(){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 CB(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var vB,kB,hf=U(()=>{"use strict";vB="SupportsDeclaration",kB={declaration:"Declaration"}});var bf={};ye(bf,{generate:()=>EB,name:()=>IB,parse:()=>yf,structure:()=>FB});function xf(){this.tokenType!==1&&this.isDelim(TB)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function yf(){let e=this.tokenStart;return this.isDelim(cS)?(this.next(),xf.call(this)):(xf.call(this),this.isDelim(cS)&&(this.next(),xf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function EB(e){this.tokenize(e.name)}var TB,cS,IB,FB,Sf=U(()=>{"use strict";TB=42,cS=124;IB="TypeSelector",FB={name:String}});var kf={};ye(kf,{generate:()=>BB,name:()=>LB,parse:()=>vf,structure:()=>MB});function Hs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===pS&&t&&n!==0)return Hs.call(this,e+n+1,!1),-1;On(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 Yl(e){let t=0;for(;this.isDelim(wf);)++t>e&&this.error("Too many question marks"),this.next()}function AB(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===uS?"Plus sign":"Hyphen minus")+" is expected")}function PB(){let e=0;switch(this.tokenType){case 10:if(e=Hs.call(this,1,!0),this.isDelim(wf)){Yl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){AB.call(this,pS),Hs.call(this,1,!1);break}break;case 12:e=Hs.call(this,1,!0),e>0&&Yl.call(this,6-e);break;default:if(this.eatDelim(uS),this.tokenType===1){e=Hs.call(this,0,!0),e>0&&Yl.call(this,6-e);break}if(this.isDelim(wf)){this.next(),Yl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function vf(){let e=this.tokenStart;return this.eatIdent("u"),PB.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function BB(e){this.tokenize(e.value)}var uS,pS,wf,LB,MB,Cf=U(()=>{"use strict";lr();uS=43,pS=45,wf=63;LB="UnicodeRange",MB={value:String}});function gS(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===dS?t-2:t-1,o="";for(;n<r&&_r(e.charCodeAt(n));)n++;for(;n<r&&_r(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Tf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),Nn(Tf,s)){let a=i-1,u=eo(e,a);i=u-1,o+=ml(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function fS(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===DB||o===Tf||o===RB||o===zB||o===NB||o===dS?(t+="\\"+e.charAt(r),n=!1):(n&&On(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var DB,Tf,RB,zB,NB,dS,If=U(()=>{"use strict";lr();DB=32,Tf=92,RB=34,zB=39,NB=40,dS=41});var Ef={};ye(Ef,{generate:()=>$B,name:()=>OB,parse:()=>Ff,structure:()=>_B});function Ff(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=gS(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=Gl(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 $B(e){this.token(7,fS(e.value))}var OB,_B,Af=U(()=>{"use strict";If();ql();OB="Url",_B={value:String}});var Lf={};ye(Lf,{generate:()=>HB,name:()=>UB,parse:()=>Pf,structure:()=>jB});function Pf(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function HB(e){this.children(e)}var UB,jB,Mf=U(()=>{"use strict";UB="Value",jB={children:[[]]}});var Df={};ye(Df,{generate:()=>qB,name:()=>VB,parse:()=>Bf,structure:()=>GB});function Bf(){return this.eat(13),WB}function qB(e){this.token(13,e.value)}var WB,VB,GB,Rf=U(()=>{"use strict";WB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),VB="WhiteSpace",GB={value:String}});var Ws={};ye(Ws,{AnPlusB:()=>Hp,Atrule:()=>Gp,AtrulePrelude:()=>Kp,AttributeSelector:()=>Zp,Block:()=>nd,Brackets:()=>id,CDC:()=>ld,CDO:()=>pd,ClassSelector:()=>fd,Combinator:()=>xd,Comment:()=>Sd,Condition:()=>kd,Declaration:()=>Id,DeclarationList:()=>Pd,Dimension:()=>Bd,Feature:()=>zd,FeatureFunction:()=>_d,FeatureRange:()=>Hd,Function:()=>Gd,GeneralEnclosed:()=>Kd,Hash:()=>Jd,IdSelector:()=>og,Identifier:()=>tg,Layer:()=>ag,LayerList:()=>ug,MediaQuery:()=>gg,MediaQueryList:()=>hg,NestingSelector:()=>bg,Nth:()=>vg,Number:()=>Tg,Operator:()=>Eg,Parentheses:()=>Lg,Percentage:()=>Dg,PseudoClassSelector:()=>Ng,PseudoElementSelector:()=>$g,Ratio:()=>Hg,Raw:()=>Gg,Rule:()=>Kg,Scope:()=>Jg,Selector:()=>tf,SelectorList:()=>of,String:()=>cf,StyleSheet:()=>df,SupportsDeclaration:()=>mf,TypeSelector:()=>bf,UnicodeRange:()=>kf,Url:()=>Ef,Value:()=>Lf,WhiteSpace:()=>Df});var zf=U(()=>{"use strict";Wp();qp();Xp();ed();rd();sd();cd();dd();md();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();qg();Xg();Zg();nf();sf();uf();gf();hf();Sf();Cf();Af();Mf();Rf()});var hS,xS=U(()=>{"use strict";Bl();j0();zf();hS={generic:!0,cssWideKeywords:Mi,...U0,node:Ws}});function Vs(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,JB)&&this.cmpChar(this.tokenStart+1,yS)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===QB||t===KB||t===yS||t===XB)return this.Operator();t===YB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var YB,KB,yS,XB,QB,JB,Nf=U(()=>{"use strict";YB=35,KB=42,yS=43,XB=45,QB=47,JB=117});var bS,SS=U(()=>{"use strict";Nf();bS={getNode:Vs}});function aD(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function lD(){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)===wS&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case nD:case oD:case sD:case rD:return this.Combinator();case wS:return this.ClassSelector();case tD:case iD:return this.TypeSelector();case ZB:return this.IdSelector();case eD:return this.NestingSelector()}break}}}var ZB,eD,tD,nD,rD,wS,oD,iD,sD,vS,kS=U(()=>{"use strict";ZB=35,eD=38,tD=42,nD=43,rD=47,wS=46,oD=62,iD=124,sD=126;vS={onWhiteSpace:aD,getNode:lD}});function CS(){return this.createSingleNodeList(this.Raw(null,!1))}var TS=U(()=>{"use strict"});function IS(){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 FS=U(()=>{"use strict"});function ES(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var AS,PS=U(()=>{"use strict";Nf();TS();FS();AS={getNode:Vs,onWhiteSpace(e,t){ES(e)&&(e.value=" "+e.value),ES(t.last)&&(t.last.value+=" ")},expression:CS,var:IS}});var Of={};ye(Of,{AtrulePrelude:()=>bS,Selector:()=>vS,Value:()=>AS});var LS=U(()=>{"use strict";SS();kS();PS()});var cD,MS,BS=U(()=>{"use strict";cD=new Set(["none","and","not","or"]),MS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);cD.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var DS,RS=U(()=>{"use strict";DS={parse:{prelude:null,block(){return this.Block(!0)}}}});function _f(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 zS,NS,OS=U(()=>{"use strict";zS={layer(){this.skipSC();let e=this.createList(),t=_f.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=_f.call(this,this.Declaration,()=>_f.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},NS={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,zS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,zS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var _S,$S=U(()=>{"use strict";_S={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var US,jS=U(()=>{"use strict";US={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var HS,WS=U(()=>{"use strict";HS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var VS,GS=U(()=>{"use strict";VS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var qS,YS=U(()=>{"use strict";qS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var KS,XS=U(()=>{"use strict";KS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var QS,JS=U(()=>{"use strict";QS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var ZS,ew=U(()=>{"use strict";BS();RS();OS();$S();jS();WS();GS();YS();XS();JS();ZS={container:MS,"font-face":DS,import:NS,layer:_S,media:US,nest:HS,page:VS,scope:qS,"starting-style":KS,supports:QS}});function tw(){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 nw=U(()=>{"use strict"});var ri,$f,uD,pD,Kl,rw,ow=U(()=>{"use strict";nw();ri={parse(){return this.createSingleNodeList(this.SelectorList())}},$f={parse(){return this.createSingleNodeList(this.Selector())}},uD={parse(){return this.createSingleNodeList(this.Identifier())}},pD={parse:tw},Kl={parse(){return this.createSingleNodeList(this.Nth())}},rw={dir:uD,has:ri,lang:pD,matches:ri,is:ri,"-moz-any":ri,"-webkit-any":ri,where:ri,not:ri,"nth-child":Kl,"nth-last-child":Kl,"nth-last-of-type":Kl,"nth-of-type":Kl,slotted:$f,host:$f,"host-context":$f}});var Uf={};ye(Uf,{AnPlusB:()=>jp,Atrule:()=>Vp,AtrulePrelude:()=>Yp,AttributeSelector:()=>Jp,Block:()=>td,Brackets:()=>od,CDC:()=>ad,CDO:()=>ud,ClassSelector:()=>gd,Combinator:()=>hd,Comment:()=>bd,Condition:()=>vd,Declaration:()=>Td,DeclarationList:()=>Ad,Dimension:()=>Md,Feature:()=>Rd,FeatureFunction:()=>Od,FeatureRange:()=>jd,Function:()=>Vd,GeneralEnclosed:()=>Yd,Hash:()=>Qd,IdSelector:()=>rg,Identifier:()=>eg,Layer:()=>sg,LayerList:()=>cg,MediaQuery:()=>dg,MediaQueryList:()=>mg,NestingSelector:()=>yg,Nth:()=>wg,Number:()=>Cg,Operator:()=>Fg,Parentheses:()=>Pg,Percentage:()=>Bg,PseudoClassSelector:()=>zg,PseudoElementSelector:()=>_g,Ratio:()=>jg,Raw:()=>Vg,Rule:()=>Yg,Scope:()=>Qg,Selector:()=>ef,SelectorList:()=>rf,String:()=>lf,StyleSheet:()=>pf,SupportsDeclaration:()=>ff,TypeSelector:()=>yf,UnicodeRange:()=>vf,Url:()=>Ff,Value:()=>Pf,WhiteSpace:()=>Bf});var iw=U(()=>{"use strict";Wp();qp();Xp();ed();rd();sd();cd();dd();md();yd();wd();Cd();Fd();Ld();Dd();Nd();$d();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();Ug();Wg();qg();Xg();Zg();nf();sf();uf();gf();hf();Sf();Cf();Af();Mf();Rf()});var sw,aw=U(()=>{"use strict";LS();ew();ow();iw();sw={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:Of,atrule:ZS,pseudo:rw,node:Uf}});var lw,cw=U(()=>{"use strict";zf();lw={node:Ws}});var uw,pw=U(()=>{"use strict";$0();xS();aw();cw();uw=_0({...hS,...sw,...lw})});var dw=U(()=>{"use strict"});var gw=U(()=>{"use strict"});var WY,fw,VY,GY,qY,mw,YY,KY,XY,QY,JY,ZY,hw=U(()=>{"use strict";pw();dw();Ep();Ml();gw();ql();If();({tokenize:WY,parse:fw,generate:VY,lexer:GY,createLexer:qY,walk:mw,find:YY,findLast:KY,findAll:XY,toPlainObject:QY,fromPlainObject:JY,fork:ZY}=uw)});function mD(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function yw(e){try{let t=fw(e.trim(),{context:"value"}),n=[];return mw(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 hD(e,t){let n=mD(e);if(!fD.has(n))return t;let r=yw(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 xw(e,t){let n=t.trim();if(!n)return"";let r=hD(e,n);return yw(r).map(i=>i==="0"?"0px":i).join(" ")}function bw(e,t,n){let r=xw(e,t),o=xw(e,n);return r!==""&&o!==""&&r===o}var fD,Sw=U(()=>{"use strict";hw();fD=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function xD(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function yD(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 ww(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=yD(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return xD(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 oi(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 g=ww(r),p=ww(o);return!!(g===p||n&&bw(n,r,o))}var jf=U(()=>{"use strict";Sw()});function kD(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 vw(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 CD(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 TD(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&&kD(n)||vw(r)||vw(o)||n&&CD(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<Cw:a<kw}return r.includes("%")||o.includes("%")?a<1:!1}function ID(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(vD.some(s=>t.includes(s))||!SD.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!oi(o,i,e.property))}function FD(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 ED(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)<Tw}function AD(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(!wD.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]))>bD)}function PD(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 Gs(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(oi(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(ED(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${Tw}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(TD(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")?Cw:kw}px)`,dismissedBy:"post-ai-validation"}}return PD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:ID(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:AD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:FD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var kw,Cw,Tw,bD,SD,wD,vD,Iw=U(()=>{"use strict";jf();kw=.5,Cw=2,Tw=2,bD=5,SD=["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"],wD=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],vD=["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 Fw(e){let t=e.trim().match(/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(!t)return null;let n=t[1];return n.length===3?[parseInt(n[0]+n[0],16),parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16)]:[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function Ew(e){let t=e.trim().match(/^color\(\s*display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*[\d.]+)?\s*\)$/);if(!t)return null;let n=parseFloat(t[1]),r=parseFloat(t[2]),o=parseFloat(t[3]);if(isNaN(n)||isNaN(r)||isNaN(o))return null;let i=p=>p<=.04045?p/12.92:Math.pow((p+.055)/1.055,2.4),s=i(n),a=i(r),u=i(o),c=1.2249*s-.2247*a+0*u,l=-.042*s+1.0419*a+0*u,d=-.0197*s-.0786*a+1.0983*u,g=p=>{let h=Math.max(0,Math.min(1,p));return h<=.0031308?12.92*h:1.055*Math.pow(h,1/2.4)-.055};return[Math.round(g(c)*255),Math.round(g(l)*255),Math.round(g(d)*255)]}function Aw(e,t,n){let r=F=>{let v=F/255;return v<=.04045?v/12.92:Math.pow((v+.055)/1.055,2.4)},o=r(e),i=r(t),s=r(n),a=o*.4124564+i*.3575761+s*.1804375,u=o*.2126729+i*.7151522+s*.072175,c=o*.0193339+i*.119192+s*.9503041,l=.95047,d=1,g=1.08883,p=F=>F>.008856?Math.cbrt(F):7.787*F+16/116,h=p(a/l),b=p(u/d),I=p(c/g);return[116*b-16,500*(h-b),200*(b-I)]}function LD(e,t){let[n,r,o]=Aw(...e),[i,s,a]=Aw(...t),u=(n+i)/2,c=Math.sqrt(r*r+o*o),l=Math.sqrt(s*s+a*a),d=(c+l)/2,g=.5*(1-Math.sqrt(Math.pow(d,7)/(Math.pow(d,7)+Math.pow(25,7)))),p=(1+g)*r,h=(1+g)*s,b=Math.sqrt(p*p+o*o),I=Math.sqrt(h*h+a*a),F=(b+I)/2,v=(Math.atan2(o,p)*180/Math.PI+360)%360,D=(Math.atan2(a,h)*180/Math.PI+360)%360,N=D-v;Math.abs(N)>180&&(N-=Math.sign(N)*360);let $=i-n,M=I-b,z=2*Math.sqrt(b*I)*Math.sin(N*Math.PI/360),m=Math.abs(v-D)>180?(v+D+360)/2:(v+D)/2,S=1-.17*Math.cos((m-30)*Math.PI/180)+.24*Math.cos(2*m*Math.PI/180)+.32*Math.cos((3*m+6)*Math.PI/180)-.2*Math.cos((4*m-63)*Math.PI/180),w=1+.015*Math.pow(u-50,2)/Math.sqrt(20+Math.pow(u-50,2)),A=1+.045*F,f=1+.015*F*S,k=-2*Math.sqrt(Math.pow(F,7)/(Math.pow(F,7)+Math.pow(25,7)))*Math.sin(60*Math.exp(-Math.pow((m-275)/25,2))*Math.PI/180);return Math.sqrt(Math.pow($/w,2)+Math.pow(M/A,2)+Math.pow(z/f,2)+k*(M/A)*(z/f))}function Pw(e){let t=(e.property||"").toLowerCase();if(!(t.includes("color")||t==="fill"||t==="background"||t==="backgroundcolor"))return!1;let r=String(e.expected||e.suggestedValue||""),o=String(e.actual||e.currentValue||""),i=Fw(r)??Fw(o),s=Ew(r)??Ew(o);return!i||!s||r===o?!1:LD(i,s)<5}function qs(e){let t=e.severity||"minor";if(t==="minor")return t;if(Pw(e))return"minor";let n=["width","height","size","dimension","dimensions","r","cx","cy"],r=["dimension","layout"],o=new Set((e.property||"").replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)),i=(e.type||"").toLowerCase();if(!(n.some(g=>o.has(g))||r.some(g=>i===g)))return t;let a=String(e.expected||e.suggestedValue||""),u=String(e.actual||e.currentValue||""),c=parseFloat(a.replace(/[^0-9.-]/g,"")),l=parseFloat(u.replace(/[^0-9.-]/g,""));if(isNaN(c)||isNaN(l))return t;let d=Math.abs(c-l);return d<5?"minor":d<10&&t==="critical"?"major":t}function Xl(e,t,n){return e>0?"D":t>0?"C":n>0?"B":"A"}function Ql(e){let t=e.filter(n=>!n.dismissed).map(n=>qs(n));return Xl(t.filter(n=>n==="critical").length,t.filter(n=>n==="major").length,t.filter(n=>n==="minor").length)}function ao(e,t,n){let r=100-n*1-t*3-e*10,o=so[Xl(e,t,n)];return Math.max(0,Math.min(o,r))}var so,Lw=U(()=>{"use strict";so={A:100,B:99,C:89,D:69}});var Mw=U(()=>{"use strict"});var Bw=U(()=>{"use strict"});var Hf=U(()=>{"use strict";jf();Iw();Lw();Mw();Bw()});var _D,$D,hK,Wf=U(()=>{"use strict";_D=["flex","inline-flex"],$D=["grid","inline-grid"],hK=[..._D,...$D]});var Rw=U(()=>{"use strict";Hf();Wf()});var zw=U(()=>{"use strict"});var ln=U(()=>{"use strict";Nu();zy();Ny();Hf();Wf();Rw();zw()});function jD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function tr(e){try{let t=e.map(jD),n=JSON.stringify(t,HD);sessionStorage.setItem(Vf,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function Gf(){try{let e=sessionStorage.getItem(Vf);if(!e)return[];let t=JSON.parse(e,WD);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function Nw(){try{let e=Gf();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&&(tr(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function Ow(){try{sessionStorage.removeItem(Vf),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function HD(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function WD(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Vf,qf=U(()=>{"use strict";Ne();Vf="uicopilot_review_history"});import VD,{createContext as GD,useContext as qD,useReducer as YD,useMemo as _w,useRef as KD,useEffect as XD}from"react";function Jl(e){let t=e.length>$w?e.slice(e.length-$w):e,n=Math.max(0,t.length-QD);return n===0?t:t.map((r,o)=>{if(o>=n)return r;let i=r.storybookImageData?.startsWith("data:"),s=r.figmaImageData?.startsWith("data:");return!i&&!s?r:{...r,storybookImageData:i?void 0:r.storybookImageData,figmaImageData:s?void 0:r.figmaImageData}})}function JD(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],i=Jl(i),tr(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":{if(t.payload.length===0)return e;let n=new Map(e.reviewHistory.map(s=>[s.id,s])),r=!1,o=e.reviewHistory.slice();for(let s of t.payload){let a=n.get(s.id);if(!a){o.push(s),r=!0;continue}let u=s.issues?.length??0,c=a.issues?.length??0;if(u>c){let l=o.indexOf(a);l!==-1&&(o[l]=s,r=!0)}}if(!r)return e;let i=Jl(o);return tr(i),{...e,reviewHistory:i}}case"ADD_REVIEW":{let n=Jl([...e.reviewHistory,t.payload]);return tr(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 tr(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 tr(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 tr(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 tr(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload.issueId?{...c,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:ao(s,a,u),issuesCount:i.length}});return tr(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(c=>c.id===t.payload?{...c,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:c),i=o.filter(c=>!c.dismissed),s=i.filter(c=>c.severity==="critical").length,a=i.filter(c=>c.severity==="major").length,u=i.filter(c=>c.severity==="minor").length;return{...r,issues:o,complianceScore:ao(s,a,u),issuesCount:i.length}});return tr(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=ao(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return tr(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 tr(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return Ow(),{...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 Kf({children:e}){let[t,n]=YD(JD,rR),r=KD(t);XD(()=>{r.current=t},[t]);let o=_w(()=>({setIsReviewing:s=>n({type:"SET_STATE",payload:{isReviewing:s}}),setReviewingStoryId:s=>n({type:"SET_STATE",payload:{reviewingStoryId: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}}),setReviewHistoryLoading:s=>n({type:"SET_STATE",payload:{reviewHistoryLoading: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=_w(()=>({...t,...o}),[t,o]);return VD.createElement(Uw.Provider,{value:i},e)}function ue(){let e=qD(Uw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var $w,QD,ZD,eR,Yf,tR,nR,rR,Uw,Xf=U(()=>{"use strict";ln();qf();Ne();$w=20,QD=5;ZD=()=>{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},eR=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Yf={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},tR=()=>{if(typeof localStorage>"u")return Yf;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Yf;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 Yf},nR=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},rR={isReviewing:!1,reviewingStoryId:null,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:Jl(Gf()),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,reviewHistoryLoading:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:nR(),roleOverride:eR(),featureFlags:tR(),reviewAllConcurrency:ZD(),hoveredIssueId:null},Uw=GD(null)});import Ys,{useMemo as oR}from"react";function Jf({children:e}){return Ys.createElement(Lu,null,Ys.createElement(Bu,null,Ys.createElement(Ru,null,Ys.createElement(Kf,null,Ys.createElement(iR,null),e))))}function jw(e){let t=Se(),n=Xe(),r=Ze(),o=ue(),i=oR(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function iR(){return Qf=jw(),null}var Qf,yt,Hw=U(()=>{"use strict";Mu();Du();zu();Xf();Qf=null,yt=Object.assign(jw,{getState:()=>{if(!Qf)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Qf}})});var ve=U(()=>{"use strict";Hw();Mu();Du();zu();Xf()});function Y(){return(process.env.STORYBOOK_UICOPILOT_URL||sR).replace(/\/$/,"")}var sR,Ww,$e=U(()=>{"use strict";sR="https://app.uiparity.com";Ww=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 lt=U(()=>{"use strict"});import{useEffect as Mo,useState as nc,useRef as sv,useCallback as nm}from"react";import{addons as rm}from"storybook/manager-api";async function lz(e,t,n){let r=`${e}:${t}`,o=om.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await oe(`${pv}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{om.delete(r)});return om.set(r,i),i}function cz(e,t,n){try{sessionStorage.setItem(`${rc}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function uz(e,t){try{let n=sessionStorage.getItem(`${rc}${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(`${rc}${e}`)}catch{}return null}function pz(e){try{let t=sessionStorage.getItem(`${rc}${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 av,lv,cv,uv,$i,pv,Cn,im,om,rc,dv,gv,ii,Ui=U(()=>{"use strict";ve();sm();Ne();$e();lt();av="storyArgsUpdated",lv="storyRendered",cv="forceRemount",uv=null,$i=()=>uv,pv=Y(),Cn=new Map,im=null,om=new Map;rc="uicopilot-figma-image-";dv=(e,t,n)=>{let r=Cn.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):Cn.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),y.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},gv=(e,t,n)=>{im=t;let r=Cn.get(e);r?r.figmaImageUrl=n:Cn.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},ii=()=>{let[e,t]=nc(!1),[n,r]=nc(!1),[o,i]=nc(!1),[s,a]=nc(null),u=sv(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ue(),d=nm(()=>{let M=yt.getState().currentStoryId;M&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",M),Cn.delete(M),u.current=null,i(!0),l())},[l]),g=nm(()=>{let M=yt.getState().currentStoryId;if(M){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",M);let z=Cn.get(M);z&&(z.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=Se(),{selectedProjectId:h}=Xe(),{currentStoryId:b,currentMapping:I,loadingMapping:F}=Ze(),{setStorybookImageUrl:v,setFigmaImageUrl:D}=ue(),N=sv(null);Mo(()=>{b&&N.current&&N.current!==b&&(y.debug("[useReviewScreenshots] Story switched, clearing images"),v(""),D("")),N.current=b},[b,v,D]),Mo(()=>{!b||F||I||D("")},[b,I,F,D]),Mo(()=>{if(!b)return;let M=pz(b);M&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",b),D(M))},[b,D]),Mo(()=>{if(!b||F)return;let M=I?.figmaFileUrl;if(M){y.debug("[useReviewScreenshots] Restoring Figma image from mapping.figmaFileUrl for:",b),D(M);let z=Cn.get(b);z?z.figmaImageUrl=M:Cn.set(b,{storybookImageUrl:null,figmaImageUrl:M})}},[b,I,F,D]),Mo(()=>{let M=!1;return(async()=>{if(!p||!h||!b){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==b&&(y.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),v(""),D(""));let m=yt.getState();if(u.current===b&&m.storybookImageUrl&&m.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let S=I?.figmaNodeId??null;if(S!==im){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",b);let P=Cn.get(b);P&&(P.figmaImageUrl=null),im=S,u.current=null}let w=I?.figmaNodeId;if(w&&!Cn.get(b)?.figmaImageUrl){let P=uz(b,w);if(P){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",b),D(P);let B=Cn.get(b);B?B.figmaImageUrl=P:Cn.set(b,{storybookImageUrl:null,figmaImageUrl:P})}}let A=Cn.get(b),f=A&&A.storybookImageUrl&&A.figmaImageUrl,k=A&&A.storybookImageUrl&&!A.figmaImageUrl,E=A&&!A.storybookImageUrl&&A.figmaImageUrl;if(f){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",b),v(A.storybookImageUrl),D(A.figmaImageUrl),u.current=b;return}let x=k&&I?.figmaNodeId;x&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",b),v(A.storybookImageUrl));let T=E;if(T&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",b),D(A.figmaImageUrl)),u.current===b&&I?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),x?r(!0):(T||(t(!0),r(!0)),i(!0)),u.current=b,M)return;let P=T?A.figmaImageUrl:null,B;if(T)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(w){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",w);let C=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let R=await lz(h,w,p);C=R.imageUrl||null;let H=R.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${H}:`,C?"success":"not found")}catch(R){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",R)}if(C)try{y.debug("[useReviewScreenshots] Fetching Figma image via proxy...");let R=`${pv}/api/proxy/image?url=${encodeURIComponent(C)}`,H=await oe(R);if(H.ok){let L=await H.blob(),ie=new FileReader,K=await new Promise((me,Pe)=>{ie.onloadend=()=>me(ie.result),ie.onerror=Pe,ie.readAsDataURL(L)});P=K,D(K),y.debug("[useReviewScreenshots] Figma image loaded via proxy");let se=new Image;await new Promise(me=>{se.onload=()=>{B={width:se.naturalWidth,height:se.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),me()},se.onerror=()=>me(),se.src=K})}else P=C,D(C),y.warn("[useReviewScreenshots] Proxy failed, using direct URL as fallback")}catch(R){y.warn("[useReviewScreenshots] Proxy error, using direct URL as fallback:",R),P=C,D(C)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",w),D(null);P&&w&&cz(b,w,P),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let _=A?.storybookImageUrl||null;if(_)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",b);let C=await oc({storyId:b,sessionToken:p||void 0,...B&&{figmaWidth:B.width,figmaHeight:B.height}});C&&!M?(_=C,v(C),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",B||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}Cn.set(b,{storybookImageUrl:_,figmaImageUrl:P}),y.debug("[useReviewScreenshots] Screenshots cached for story:",b)}catch(P){y.error("[useReviewScreenshots] Error loading screenshots:",P),a(P instanceof Error?P.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})(),()=>{M=!0}},[p,h,b,I?.figmaNodeId,c]),Mo(()=>{let M=rm.getChannel(),z=null,m=S=>{uv=S.args,y.debug("[useReviewScreenshots] Args updated for story:",S.storyId,"args:",S.args),z&&clearTimeout(z),z=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return M.on(av,m),()=>{M.off(av,m),z&&clearTimeout(z)}},[d]),Mo(()=>{let M=rm.getChannel(),z=!1,m=null,S=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),z=!0,i(!0)},w=()=>{z&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),m&&clearTimeout(m),m=setTimeout(()=>{z=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return M.on(cv,S),M.on(lv,w),()=>{M.off(cv,S),M.off(lv,w),m&&clearTimeout(m)}},[g]),Mo(()=>{let M=rm.getChannel(),z=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 S=yt.getState().currentStoryId,w=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...m.snapshot,storyId:S})});if(w.ok){let A=await w.json();if(A.screenshot){v(A.screenshot);let f=yt.getState().currentStoryId;if(f){let k=Cn.get(f);k?k.storybookImageUrl=A.screenshot:Cn.set(f,{storybookImageUrl:A.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await w.text())}catch(S){y.error("[useReviewScreenshots] Snapshot screenshot error:",S)}finally{i(!1)}};return M.on("UICOPILOT/STORY_DOM_MUTATED",z),()=>{M.off("UICOPILOT/STORY_DOM_MUTATED",z)}},[]);let $=nm((M,z,m)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),gv(M,z,m),D(m),r(!1),u.current=M},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:g,setFigmaImageDirect:$}}});function gz(){return!Y().startsWith("http://localhost")}function fz(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 fv(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=fz(o,t,n);return r.set(o,i),i})}async function mz(){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=fv(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 g of Array.from(l.cssRules))d+=g.cssText+`
13
+ `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let g=s.createElement("style");g.textContent=fv(d,o,r),u.replaceWith(g)}}catch{}})}})).toDataURL("image/png")}function hz(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 xz(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(`${dz}/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 yz(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 bz(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=$i();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=yz(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=hz(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 Sz(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 oc(e){let t=e?.storyId||wz();if(t){let n=am.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=mv(t,e).finally(()=>{am.delete(t)});return am.set(t,r),r}return mv(void 0,e)}async function mv(e,t){try{if(e){let n=await Sz(e);if(n)return n}if(!gz()){let n=bz(t?.storyId);return await xz(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await mz()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function wz(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var dz,am,sm=U(()=>{"use strict";$e();Ui();Ne();lt();dz=Y();am=new Map});function Ln(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 jn(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 ta(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function hv(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let I=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let v=t.fonts.check(`${F} ${I} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:v,fontWeight:F,fontSize:I,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),v)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(I=>I.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],g=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,h="unknown",b=new Map;for(let I of g){s.font=`${c} ${u} ${a} "${I}", monospace`;let F=s.measureText(o).width;if(b.set(I,F),F!==p){s.font=`${c} ${u} ${a} "${I}"`;let v=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(v-D)<.1){h=I;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:h,declaredFonts:l,fontWidths:Array.from(b.entries()),isIframe:t!==document}),h}var na=U(()=>{"use strict";Ne()});function ji(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 lm(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:Ln(n.color),backgroundColor:Ln(n.backgroundColor),borderColor:Ln(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:hv(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 cm(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 ic=U(()=>{"use strict";Ne();na()});function vz(e){let t=[],n=new Set,r=xv.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(xv.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function kz(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:ji(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:ta(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:Ln(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function Cz(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 Tz(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,g=Ln(n.borderColor),p=s?`${l} ${d} ${g}`:"none";return{selector:ji(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:Ln(n.backgroundColor),gap:n.gap}}function ra(){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=Cz(r,2),i=o.map(Tz).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=vz(r);s=a.map(kz),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:lm(r),declared:cm(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var xv,yv=U(()=>{"use strict";Ne();na();ic();xv=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function um(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 Fz(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function Ez(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=Ln(n.backgroundColor);jn("backgroundColor",o)||(r.backgroundColor=o);let i=Fz(n.borderWidth,n.borderStyle,Ln(n.borderColor));i&&(r.border=i),jn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),jn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),jn("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 I=0;I<e.attributes.length;I++){let F=e.attributes[I];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let v=F.name.replace(/-([a-z])/g,(N,$)=>$.toUpperCase()),D=F.value.startsWith("rgb")?Ln(F.value):F.value;v==="d"&&D.length>100?r[v]=D.substring(0,100)+"...":r[v]=D}let p=n.getPropertyValue("fill"),h=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?Ln(p):p),h&&h!=="none"&&(r.stroke=h.startsWith("rgb")?Ln(h):h),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let I=e.getBoundingClientRect();I.width>0&&(r.width=`${Math.round(I.width*100)/100}px`),I.height>0&&(r.height=`${Math.round(I.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=Iz.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=ta(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=Ln(n.color),jn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),jn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=um(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);jn("padding",d)||(r.padding=d);let g=um(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return jn("margin",g)||(r.margin=g),jn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(jn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),jn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),jn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function bv(e){let t=1;for(let n of e.children)t+=bv(n);return t}function Sv(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 b of Array.from(o.childNodes))if(b.nodeType===Node.TEXT_NODE){let I=b.textContent?.trim();if(I){d=I.length>50?I.substring(0,50)+"...":I;break}}let g=s;c?g=`${s}#${c}`:u&&(g=ji(s,u));let p=Ez(o),h=[];if(i<t){let b=Array.from(o.children);for(let I of b){let F=I.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let D=(I.ownerDocument.defaultView||window).getComputedStyle(I);D.display==="none"||D.visibility==="hidden"||h.push(n(I,i+1))}}return{selector:g,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:h}}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:bv(r)}),r}function pm(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=Sv(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 Iz,wv=U(()=>{"use strict";Ne();na();ic();Iz=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var dm=U(()=>{"use strict";na();ic();yv();wv()});var qv=ir((oJ,Gv)=>{"use strict";Gv.exports={compareTwoStrings:Vv,findBestMatch:Zz};function Vv(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 Zz(e,t){if(!eN(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=Vv(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 eN(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var V1=ir((Tae,W1)=>{"use strict";var $1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,d3=/\n/g,g3=/^\s*/,f3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,m3=/^:\s*/,h3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,x3=/^[;\s]*/,y3=/^\s+|\s+$/g,b3=`
14
+ `,U1="/",j1="*",di="",S3="comment",w3="declaration";function v3(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(h){var b=h.match(d3);b&&(n+=b.length);var I=h.lastIndexOf(b3);r=~I?h.length-I:r+h.length}function i(){var h={line:n,column:r};return function(b){return b.position=new s(h),c(),b}}function s(h){this.start=h,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(h){var b=new Error(t.source+":"+n+":"+r+": "+h);if(b.reason=h,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function u(h){var b=h.exec(e);if(b){var I=b[0];return o(I),e=e.slice(I.length),b}}function c(){u(g3)}function l(h){var b;for(h=h||[];b=d();)b!==!1&&h.push(b);return h}function d(){var h=i();if(!(U1!=e.charAt(0)||j1!=e.charAt(1))){for(var b=2;di!=e.charAt(b)&&(j1!=e.charAt(b)||U1!=e.charAt(b+1));)++b;if(b+=2,di===e.charAt(b-1))return a("End of comment missing");var I=e.slice(2,b-2);return r+=2,o(I),e=e.slice(b),r+=2,h({type:S3,comment:I})}}function g(){var h=i(),b=u(f3);if(b){if(d(),!u(m3))return a("property missing ':'");var I=u(h3),F=h({type:w3,property:H1(b[0].replace($1,di)),value:I?H1(I[0].replace($1,di)):di});return u(x3),F}}function p(){var h=[];l(h);for(var b;b=g();)b!==!1&&(h.push(b),l(h));return h}return c(),p()}function H1(e){return e?e.replace(y3,di):di}W1.exports=v3});var G1=ir(Ta=>{"use strict";var k3=Ta&&Ta.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ta,"__esModule",{value:!0});Ta.default=T3;var C3=k3(V1());function T3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,C3.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 Y1=ir(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.camelCase=void 0;var I3=/^--[a-zA-Z0-9_-]+$/,F3=/-([a-z])/g,E3=/^[^-]+$/,A3=/^-(webkit|moz|ms|o|khtml)-/,P3=/^-(ms)-/,L3=function(e){return!e||E3.test(e)||I3.test(e)},M3=function(e,t){return t.toUpperCase()},q1=function(e,t){return"".concat(t,"-")},B3=function(e,t){return t===void 0&&(t={}),L3(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(P3,q1):e=e.replace(A3,q1),e.replace(F3,M3))};_c.camelCase=B3});var X1=ir((Gh,K1)=>{"use strict";var D3=Gh&&Gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},R3=D3(G1()),z3=Y1();function Vh(e,t){var n={};return!e||typeof e!="string"||(0,R3.default)(e,function(r,o){r&&o&&(n[(0,z3.camelCase)(r,t)]=o)}),n}Vh.default=Vh;K1.exports=Vh});var kI=ir((ege,vI)=>{"use strict";var lu=Object.prototype.hasOwnProperty,wI=Object.prototype.toString,mI=Object.defineProperty,hI=Object.getOwnPropertyDescriptor,xI=function(t){return typeof Array.isArray=="function"?Array.isArray(t):wI.call(t)==="[object Array]"},yI=function(t){if(!t||wI.call(t)!=="[object Object]")return!1;var n=lu.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&lu.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||lu.call(t,o)},bI=function(t,n){mI&&n.name==="__proto__"?mI(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},SI=function(t,n){if(n==="__proto__")if(lu.call(t,n)){if(hI)return hI(t,n).value}else return;return t[n]};vI.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=SI(a,n),o=SI(t,n),a!==o&&(l&&o&&(yI(o)||(i=xI(o)))?(i?(i=!1,s=r&&xI(r)?r:[]):s=r&&yI(r)?r:{},bI(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&bI(a,{name:n,newValue:o}));return a}});import Ja from"react";import{addons as ku,types as hy,experimental_getStatusStore as xy}from"storybook/manager-api";import{AddonPanel as d9}from"storybook/internal/components";import zt,{useState as LV,useEffect as MV}from"react";import{styled as yr}from"storybook/theming";import Iy from"react";import{styled as Dt}from"storybook/theming";var ce="#ea580c",Fu="#c2410c",nl="#ff6b35";var Sy=Dt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),wy=Dt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),vo=Dt.div({marginBottom:"20px"}),ko=Dt.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})),ys=Dt.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`}})),Sn=Dt.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"}})),vy=Dt(Sn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),rl=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"}}),An=Dt.button(({theme:e})=>({...rl(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),on=Dt.button(({theme:e})=>({...rl(e),backgroundColor:ce,color:e.color.inverseText,boxShadow:`0 2px 4px ${ce}4d`,"&:hover:not(:disabled)":{backgroundColor:Fu,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ce}66`}})),Or=Dt.button(({theme:e})=>({...rl(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),ky=Dt.button(({theme:e})=>({...rl(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Pn=Dt.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"}})),Eu=Dt.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"}})),Co=Dt.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}})),To=Dt(ys)(({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"})),S9=Dt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Cy=Dt.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})),w9=Dt.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})),bs=Dt.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})),v9=Dt.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%)"}}})),Ty=Dt.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}}),k9=Dt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),C9=Dt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),T9=Dt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var Au=({header:e,children:t,footer:n})=>Iy.createElement(Sy,null,e,Iy.createElement(wy,null,t),n);import SE from"react";import{styled as wE}from"storybook/theming";var vE=wE.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})),Pu=({toolbar:e})=>SE.createElement(vE,null,e);import R9 from"react";import{styled as ol}from"storybook/theming";var O9=ol.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})),_9=ol.div({display:"flex",flex:1}),$9=ol(Co)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),U9=ol.div({display:"flex",gap:"8px",alignItems:"center"});import en,{useState as em,useCallback as nv,useEffect as rv}from"react";import{styled as lo}from"storybook/theming";import we,{useEffect as Vw}from"react";import{styled as at}from"storybook/theming";ve();$e();Ne();lt();var Gw=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),qw=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})),aR=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),lR=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:ce,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),cR=at.div({display:"flex",flexDirection:"column",gap:"4px"}),uR=at.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),pR=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"}),dR=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),gR=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),fR=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),mR=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"})),hR=at.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${ce} 100%)`,transition:"width 0.3s ease"})),xR=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),yR=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),bR=at.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:ce,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Yw=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}})),SR=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),wR=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),vR=at.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:ce,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),kR=at.div({display:"flex",gap:"8px"}),Kw=at(Pn)({fontSize:"18px"}),CR=at.div({padding:"20px 16px"}),TR=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),IR=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),FR=at.div({fontSize:"28px",fontWeight:700}),ER=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),AR=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),PR=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),LR=at.div({display:"flex",alignItems:"center",gap:"8px"}),MR=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),BR=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:ce,color:e.color.inverseText})),DR=at.button(({theme:e})=>({background:"none",border:"none",color:ce,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),RR=at.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),zR=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"?ce:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),NR=30*1e3,Xw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=Se(),{featureFlags:s}=ue(),a=s.showCosts,u=r,c=!r&&t,l=async(h=!1)=>{if(!t)return;let b=o&&Date.now()-o<NR;if(!(!h&&b&&r))try{let I=Y(),F=await oe(`${I}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(F.ok){let v=await F.json();i(v)}}catch(I){y.error("Failed to fetch usage:",I)}};Vw(()=>{l()},[t]),Vw(()=>{let h=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",h),()=>document.removeEventListener("visibilitychange",h)},[t]);let d=async()=>{if(t){let h=Y();try{await fetch(`${h}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})}catch{}}n(),e()},g=()=>{let h=Y();window.open(`${h}/pricing`,"_blank")},p=()=>{let h=Y();window.open(`${h}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let h=Math.floor(u?.creditBalance??0),I=Math.max(h,10),F=Math.max(0,I-h),v=I>0?h/I*100:0;return we.createElement(we.Fragment,null,we.createElement(Gw,{onClick:e}),we.createElement(qw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},we.createElement(aR,null,we.createElement(lR,null,u?.email?u.email[0].toUpperCase():"U"),we.createElement(cR,null,we.createElement(uR,null,"UI Review"),we.createElement(pR,null,(u?.plan||"BETA").toUpperCase())),we.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},we.createElement(Yw,{onClick:d,title:"Sign out",style:{position:"static"}},we.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},we.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),we.createElement("polyline",{points:"16 17 21 12 16 7"}),we.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),we.createElement(Yw,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),we.createElement(dR,null,we.createElement(gR,null,"Credits"),we.createElement(fR,null,h," left")),we.createElement(mR,null,we.createElement(hR,{percent:v})),we.createElement(xR,null,F," used \xB7 ",h," remaining"),we.createElement(yR,null),we.createElement(bR,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return we.createElement(we.Fragment,null,we.createElement(Gw,{onClick:e}),we.createElement(qw,{onClick:h=>h.stopPropagation()},we.createElement(SR,null,we.createElement(wR,null,we.createElement(vR,null,u?.email?u.email[0].toUpperCase():"U"),we.createElement("span",null,u?.email||"Loading...")),we.createElement(kR,null,we.createElement(Kw,{onClick:d,title:"Sign out"},we.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},we.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),we.createElement("polyline",{points:"16 17 21 12 16 7"}),we.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),we.createElement(Kw,{onClick:e,title:"Close"},"\xD7"))),we.createElement(CR,null,c?we.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?we.createElement(we.Fragment,null,we.createElement(TR,null,we.createElement(IR,null,"Credit Balance"),we.createElement(FR,null,"$",(u?.creditBalance??0).toFixed(2)),we.createElement(ER,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),we.createElement(AR,null,we.createElement(PR,null,we.createElement(LR,null,we.createElement(MR,null,"Current Plan"),we.createElement(BR,null,u?.plan||"Free")),we.createElement(DR,{onClick:g},"View detail >")),we.createElement(RR,null,"~$0.02-0.05 per review depending on complexity"),we.createElement(zR,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):we.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};ve();import Oi from"react";import{styled as Qw}from"storybook/theming";$e();ve();lt();Ne();var OR=Qw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),_R=Qw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),$R={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}},Jw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ue(),{sessionToken:o}=Se();return e!=="admin"?null:Oi.createElement(OR,null,Oi.createElement(_R,null,"View as:"),Oi.createElement(vy,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&oe(`${Y()}/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=$R[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Oi.createElement("option",{value:"admin"},"Admin"),Oi.createElement("option",{value:"beta"},"Beta Tester")),t&&Oi.createElement(Ty,{variant:"warning"},"Previewing as ",t))};$e();ve();lt();import St,{useState as Ks,useCallback as Zf}from"react";import{styled as Er}from"storybook/theming";var UR="0.5.7",jR=[{value:"bug",label:"\u{1F41E} Bug \u2014 something broke"},{value:"ux",label:"\u{1F9ED} UX \u2014 confusing or slow"},{value:"feature",label:"\u2728 Feature \u2014 missing something"},{value:"praise",label:"\u{1F49A} Praise \u2014 works great"},{value:"other",label:"\u{1F4AC} Other"}],HR=Er.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),WR=Er.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"12px",width:"460px",maxWidth:"94%",maxHeight:"90vh",overflow:"auto",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.25)"})),VR=Er.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),GR=Er.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),qR=Er.button(({theme:e})=>({background:"transparent",border:"none",fontSize:"20px",color:e.color.mediumdark,cursor:"pointer",padding:"0 6px",lineHeight:1,"&:hover":{color:e.color.defaultText}})),YR=Er.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),KR=Er.textarea(({theme:e})=>({width:"100%",minHeight:"110px",padding:"8px 10px",borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.defaultText,backgroundColor:e.background.app,resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:ce}})),Zw=Er.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),ev=Er.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),XR=Er.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),QR=Er.div(({theme:e})=>({padding:"24px 20px",textAlign:"center",display:"flex",flexDirection:"column",gap:"10px","& h4":{margin:0,fontSize:"15px",fontWeight:600,color:e.color.positive},"& p":{margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark}}));function tv({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=Se(),{selectedProjectId:o}=Xe(),{currentStoryId:i}=Ze(),[s,a]=Ks("other"),[u,c]=Ks(""),[l,d]=Ks(!1),[g,p]=Ks(!1),[h,b]=Ks(null),I=Zf(()=>{c(""),a("other"),p(!1),b(null),d(!1)},[]),F=Zf(()=>{I(),t()},[I,t]),v=Zf(async D=>{if(D.preventDefault(),!u.trim()){b("Please write a message.");return}if(!r||!n){b("Sign in to send feedback.");return}d(!0),b(null);try{let N=await oe(`${Y()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:s,projectId:o||void 0,storyId:i||void 0,addonVersion:UR})});if(!N.ok){let $=await N.json().catch(()=>({}));throw new Error($.error||`Request failed (${N.status})`)}p(!0)}catch(N){b(N instanceof Error?N.message:"Something went wrong")}finally{d(!1)}},[u,s,n,r,o,i]);return e?St.createElement(HR,{onClick:F},St.createElement(WR,{onClick:D=>D.stopPropagation()},St.createElement(VR,null,St.createElement(GR,null,St.createElement("span",null,"\u{1F4AC}"),"Send feedback"),St.createElement(qR,{onClick:F,"aria-label":"Close"},"\xD7")),g?St.createElement(St.Fragment,null,St.createElement(QR,null,St.createElement("h4",null,"Thanks \u2014 got it."),St.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),St.createElement(Zw,null,St.createElement("span",null),St.createElement(An,{onClick:F},"Close"))):St.createElement("form",{onSubmit:v},St.createElement(YR,null,St.createElement(vo,null,St.createElement(ko,{htmlFor:"feedback-severity"},"Type"),St.createElement(Sn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},jR.map(D=>St.createElement("option",{key:D.value,value:D.value},D.label)))),St.createElement(vo,null,St.createElement(ko,{htmlFor:"feedback-message"},"What happened?"),St.createElement(KR,{id:"feedback-message",value:u,onChange:D=>c(D.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:l,autoFocus:!0,maxLength:5e3})),St.createElement(ev,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),h&&St.createElement(XR,null,h)),St.createElement(Zw,null,St.createElement(ev,null,i?`Context: ${i}`:"No story selected"),St.createElement("div",{style:{display:"flex",gap:"8px"}},St.createElement(An,{type:"button",onClick:F,disabled:l},"Cancel"),St.createElement(on,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}ve();$e();lt();var JR=lo.div({display:"flex",alignItems:"center"}),_i=lo.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),ZR=lo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),ez=lo.div({position:"relative"}),tz=lo.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`}})),ov=lo.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)"}})),nz=lo.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)"}}}),rz=lo.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}})),oz=lo.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:ce,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${ce}66, 0 2px 4px rgba(0,0,0,0.1)`,transition:"all 0.2s ease",zIndex:9999,"&:hover":{transform:"scale(1.08)",boxShadow:`0 6px 20px ${ce}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),iz=30*1e3,tm=({onOpenSettings:e})=>{let[t,n]=em(!1),[r,o]=em(!1),[i,s]=em(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=Se(),{userRole:d,roleOverride:g,featureFlags:p}=ue(),h=g??d;rv(()=>{(async()=>{if(!(!l||u&&Date.now()-u<iz&&a)){s(!0);try{let $=Y(),M=await oe(`${$}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(M.ok){let z=await M.json();c(z)}}catch($){console.error("Failed to fetch balance:",$)}finally{s(!1)}}})()},[l,u,a,c]),rv(()=>{let D=()=>{document.visibilityState==="visible"&&t&&n(!1)},N=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",D),window.addEventListener("focus",N),()=>{document.removeEventListener("visibilitychange",D),window.removeEventListener("focus",N)}},[t]);let b=nv(()=>{n(!0)},[]),I=nv(()=>{n(!1)},[]),F=a?.creditBalance??0,v=F<2&&!i;return en.createElement(JR,null,e&&en.createElement(_i,null,en.createElement(rz,{onClick:e,title:"Settings"},en.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&d==="admin"&&h==="admin"&&en.createElement(_i,null,en.createElement(Jw,null)),en.createElement(_i,null,en.createElement(ZR,null,"v","0.5.40")),l&&p.showCosts&&en.createElement(_i,null,en.createElement(ov,{onClick:b,isLow:v,title:i?"Loading...":a?v?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?en.createElement(nz,null):a?`$${F.toFixed(2)}`:"...")),l&&!p.showCosts&&a&&en.createElement(_i,null,en.createElement(ov,{onClick:b,isLow:Math.floor(F)<=3,title:`${Math.floor(F)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(F))),en.createElement(_i,null,en.createElement(ez,null,en.createElement(tz,{title:"Account & Usage",onClick:b},a?.email?a.email[0].toUpperCase():"?"),t&&en.createElement(Xw,{onClose:I}))),l&&en.createElement(oz,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),en.createElement(tv,{isOpen:r,onClose:()=>o(!1)}))};import Bt,{useEffect as i5,useRef as s5}from"react";import{styled as fr}from"storybook/theming";import et from"react";ve();Ne();$e();lt();ln();import{useState as sz,useCallback as Lo,useRef as az,useEffect as iv}from"react";var Ar=Y();y.debug("[useAuth] Module loaded, APP_URL:",Ar);var Zl=null,ec=null,Xs=null;function Qs(){Zl&&(clearInterval(Zl),Zl=null),ec&&(clearTimeout(ec),ec=null)}var Js=()=>{let e=az(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:g,setUserCode:p,setVerificationUri:h,setPollingInterval:b,setAuthError:I,resetAuth:F}=Se(),[v,D]=sz(!1),N=Lo(()=>{Qs(),Xs=null},[]),$=Lo(f=>{Xs=f,Qs();let k=async()=>{let E=Xs;if(!E){Qs();return}try{let T=await(await fetch(`${Ar}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:E})})).json();T.status==="authorized"&&T.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),Qs(),Xs=null,localStorage.setItem("uicopilot_session_token",T.session_token),c(T.session_token),D(!1)):T.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),Qs(),Xs=null,D(!1))}catch(x){y.error("[useAuth] OAuth poll error:",x)}};Zl=setInterval(k,2e3),ec=setTimeout(k,1e3)},[c]);iv(()=>{function f(k){if(!k.origin.startsWith(Ar))return;let E=k.data;if(!E||typeof E!="object")return;let x=E;if(x.type==="UICOPILOT_AUTH_ERROR"){y.debug("[useAuth] Popup reported auth error:",x.step,x.detail),N(),D(!1);let T=typeof x.step=="string"?x.step:"auth",P=typeof x.detail=="string"?x.detail:"Unknown error";I(`${Et.NAME} auth failed (${T}): ${P}`)}else x.type==="UICOPILOT_AUTH_POLL_CODE"&&typeof x.pollCode=="string"&&x.pollCode&&(y.debug("[useAuth] Popup handed us a fresh poll_code, switching"),I(null),$(x.pollCode))}return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[$,N,I]);let M=Lo(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let f;try{f=await oe(`${Ar}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(T){let B=T instanceof Error&&T.message.includes("timed out")?`Cannot reach ${Et.NAME} server at ${Ar}. Is the dashboard running?`:`Connection failed: ${Ar} is not responding.`;I(B),y.error("[useAuth]",B);return}if(!f.ok){let T=`Cannot reach ${Et.NAME} server. Is the dashboard running?`;I(T),y.error("[useAuth]",T);return}let{poll_code:k}=await f.json();y.debug("[useAuth] Got poll_code:",k.substring(0,15)+"...");let E=localStorage.getItem("uicopilot_force_sign_in")==="true";E&&localStorage.removeItem("uicopilot_force_sign_in");let x=`${Ar}/addon/auth?poll_code=${k}${E?"&force_sign_in=true":""}`;D(!0),window.open(x,"uiparity-auth","width=520,height=620,left=300,top=150"),y.debug("[useAuth] Starting OAuth poll for token..."),$(k)}catch(f){y.error("[useAuth] OAuth flow error:",f),I(`Connection failed. Is the dashboard running at ${Ar}?`),D(!1)}},[I,$]),z=Lo(async()=>{try{let f=await fetch(`${Ar}/api/addon/auth/device`,{method:"POST"});if(!f.ok)throw new Error("Failed to start device code flow");let k=await f.json();g(k.device_code),p(k.user_code),h(k.verification_uri),window.open(k.verification_uri,"_blank"),m(k.device_code,k.interval*1e3)}catch(f){throw y.error("[useAuth] Device code flow error:",f),f}},[g,p,h]),m=Lo((f,k)=>{y.debug("[useAuth] Starting polling. Device code:",f,"Interval:",k),e.current&&clearInterval(e.current);let E=async()=>{try{let T=await(await fetch(`${Ar}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:f})})).json();T.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),h(null),localStorage.setItem("uicopilot_session_token",T.session_token),c(T.session_token),D(!1)):(T.status==="expired"||T.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),h(null))}catch(x){y.error("[useAuth] Polling error:",x)}};e.current=setInterval(E,k),b(k)},[g,p,h,c,b]),S=Lo(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),h(null),b(null)},[g,p,h,b]),w=Lo(f=>{l(f),c(f),localStorage.setItem("uicopilot_api_key",f)},[l,c]),A=Lo(async()=>{if(t)try{await oe(`${Ar}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})}catch{}F(),D(!1),e.current&&(clearInterval(e.current),e.current=null),N()},[t,F,N]);return iv(()=>()=>{e.current&&clearInterval(e.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthPending:v,setAuthMethod:d,startOAuth:M,startDeviceCode:z,cancelDeviceCode:S,saveApiKey:w,logout:A}};ve();Ne();$e();lt();import{useCallback as tc}from"react";var Zs=Y(),co=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Xe(),{sessionToken:a}=Se(),u=tc(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${Zs}/api/projects`);let g=await oe(`${Zs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let p=await g.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){y.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=tc(async g=>{if(!a)throw new Error("Not authenticated");let p=await oe(`${Zs}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!p.ok)throw new Error("Failed to create project");let h=await p.json();return await u(),h.project},[a,u]),l=tc(async(g,p)=>{if(!a)throw new Error("Not authenticated");let h={};if(p.name!==void 0&&(h.name=p.name),p.description!==void 0&&(h.description=p.description),p.figmaFileUrl!==void 0&&(h.figmaFileId=p.figmaFileUrl===""?null:p.figmaFileUrl),!(await oe(`${Zs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(h)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=tc(async g=>{if(!a)throw new Error("Not authenticated");if(!(await oe(`${Zs}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&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 ea=()=>{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}=Ze();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();sm();dm();import{useCallback as la,useRef as gc}from"react";Ne();function sc(){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})}function ac(e){return e&&e!=="admin"?{"X-UIC-Role-Preview":e}:{}}var lc=BigInt(4294967295),vv=BigInt(32);function Az(e,t=!1){return t?{h:Number(e&lc),l:Number(e>>vv&lc)}:{h:Number(e>>vv&lc)|0,l:Number(e&lc)|0}}function kv(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}=Az(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Cv=(e,t,n)=>e<<n|t>>>32-n,Tv=(e,t,n)=>t<<n|e>>>32-n,Iv=(e,t,n)=>t<<n-32|e>>>64-n,Fv=(e,t,n)=>e<<n-32|t>>>64-n;function Pz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function gm(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function cc(e,t,n=""){let r=Pz(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 fm(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 Ev(e,t){cc(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 Av(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function mm(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var Lz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Mz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Bz(e){for(let t=0;t<e.length;t++)e[t]=Mz(e[t]);return e}var hm=Lz?e=>e:Bz;function Pv(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 Lv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var Dz=BigInt(0),oa=BigInt(1),Rz=BigInt(2),zz=BigInt(7),Nz=BigInt(256),Oz=BigInt(113),Dv=[],Rv=[],zv=[];for(let e=0,t=oa,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Dv.push(2*(5*r+n)),Rv.push((e+1)*(e+2)/2%64);let o=Dz;for(let i=0;i<7;i++)t=(t<<oa^(t>>zz)*Oz)%Nz,t&Rz&&(o^=oa<<(oa<<BigInt(i))-oa);zv.push(o)}var Nv=kv(zv,!0),_z=Nv[0],$z=Nv[1],Mv=(e,t,n)=>n>32?Iv(e,t,n):Cv(e,t,n),Bv=(e,t,n)=>n>32?Fv(e,t,n):Tv(e,t,n);function Uz(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=Mv(c,l,1)^n[a],g=Bv(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=Rv[s],u=Mv(o,i,a),c=Bv(o,i,a),l=Dv[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]^=_z[r],e[1]^=$z[r]}mm(n)}var xm=class e{constructor(t,n,r,o=!1,i=24){sr(this,"state");sr(this,"pos",0);sr(this,"posOut",0);sr(this,"finished",!1);sr(this,"state32");sr(this,"destroyed",!1);sr(this,"blockLen");sr(this,"suffix");sr(this,"outputLen");sr(this,"enableXOF",!1);sr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,gm(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Av(this.state)}clone(){return this._cloneInto()}keccak(){hm(this.state32),Uz(this.state32,this.rounds),hm(this.state32),this.posOut=0,this.pos=0}update(t){fm(this),cc(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){fm(this,!1),cc(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 gm(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ev(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,mm(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}},jz=(e,t,n,r={})=>Pv(()=>new xm(t,e,n),r);var Ov=jz(6,72,64,Lv(10));var Hz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,ym=Math.ceil,dr=Math.floor,Hn="[BigNumber Error] ",_v=Hn+"Number primitive has more than 15 significant digits: ",Pr=1e14,He=14,bm=9007199254740991,Sm=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Bo=1e7,cn=1e9;function $v(e){var t,n,r,o=v.prototype={constructor:v,toString:null,valueOf:null},i=new v(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,g=!1,p=1,h=0,b={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},I="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function v(m,S){var w,A,f,k,E,x,T,P,B=this;if(!(B instanceof v))return new v(m,S);if(S==null){if(m&&m._isBigNumber===!0){B.s=m.s,!m.c||m.e>d?B.c=B.e=null:m.e<l?B.c=[B.e=0]:(B.e=m.e,B.c=m.c.slice());return}if((x=typeof m=="number")&&m*0==0){if(B.s=1/m<0?(m=-m,-1):1,m===~~m){for(k=0,E=m;E>=10;E/=10,k++);k>d?B.c=B.e=null:(B.e=k,B.c=[m]);return}P=String(m)}else{if(!Hz.test(P=String(m)))return r(B,P,x);B.s=P.charCodeAt(0)==45?(P=P.slice(1),-1):1}(k=P.indexOf("."))>-1&&(P=P.replace(".","")),(E=P.search(/e/i))>0?(k<0&&(k=E),k+=+P.slice(E+1),P=P.substring(0,E)):k<0&&(k=P.length)}else{if(Ot(S,2,I.length,"Base"),S==10&&F)return B=new v(m),M(B,s+B.e+1,a);if(P=String(m),x=typeof m=="number"){if(m*0!=0)return r(B,P,x,S);if(B.s=1/m<0?(P=P.slice(1),-1):1,v.DEBUG&&P.replace(/^0\.0*|\./,"").length>15)throw Error(_v+m)}else B.s=P.charCodeAt(0)===45?(P=P.slice(1),-1):1;for(w=I.slice(0,S),k=E=0,T=P.length;E<T;E++)if(w.indexOf(A=P.charAt(E))<0){if(A=="."){if(E>k){k=T;continue}}else if(!f&&(P==P.toUpperCase()&&(P=P.toLowerCase())||P==P.toLowerCase()&&(P=P.toUpperCase()))){f=!0,E=-1,k=0;continue}return r(B,String(m),x,S)}x=!1,P=n(P,S,10,B.s),(k=P.indexOf("."))>-1?P=P.replace(".",""):k=P.length}for(E=0;P.charCodeAt(E)===48;E++);for(T=P.length;P.charCodeAt(--T)===48;);if(P=P.slice(E,++T)){if(T-=E,x&&v.DEBUG&&T>15&&(m>bm||m!==dr(m)))throw Error(_v+B.s*m);if((k=k-E-1)>d)B.c=B.e=null;else if(k<l)B.c=[B.e=0];else{if(B.e=k,B.c=[],E=(k+1)%He,k<0&&(E+=He),E<T){for(E&&B.c.push(+P.slice(0,E)),T-=He;E<T;)B.c.push(+P.slice(E,E+=He));E=He-(P=P.slice(E)).length}else E-=T;for(;E--;P+="0");B.c.push(+P)}}else B.c=[B.e=0]}v.clone=$v,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(m){var S,w;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(S="DECIMAL_PLACES")&&(w=m[S],Ot(w,0,cn,S),s=w),m.hasOwnProperty(S="ROUNDING_MODE")&&(w=m[S],Ot(w,0,8,S),a=w),m.hasOwnProperty(S="EXPONENTIAL_AT")&&(w=m[S],w&&w.pop?(Ot(w[0],-cn,0,S),Ot(w[1],0,cn,S),u=w[0],c=w[1]):(Ot(w,-cn,cn,S),u=-(c=w<0?-w:w))),m.hasOwnProperty(S="RANGE"))if(w=m[S],w&&w.pop)Ot(w[0],-cn,-1,S),Ot(w[1],1,cn,S),l=w[0],d=w[1];else if(Ot(w,-cn,cn,S),w)l=-(d=w<0?-w:w);else throw Error(Hn+S+" cannot be zero: "+w);if(m.hasOwnProperty(S="CRYPTO"))if(w=m[S],w===!!w)if(w)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=w;else throw g=!w,Error(Hn+"crypto unavailable");else g=w;else throw Error(Hn+S+" not true or false: "+w);if(m.hasOwnProperty(S="MODULO_MODE")&&(w=m[S],Ot(w,0,9,S),p=w),m.hasOwnProperty(S="POW_PRECISION")&&(w=m[S],Ot(w,0,cn,S),h=w),m.hasOwnProperty(S="FORMAT"))if(w=m[S],typeof w=="object")b=w;else throw Error(Hn+S+" not an object: "+w);if(m.hasOwnProperty(S="ALPHABET"))if(w=m[S],typeof w=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(w))F=w.slice(0,10)=="0123456789",I=w;else throw Error(Hn+S+" invalid: "+w)}else throw Error(Hn+"Object expected: "+m);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:g,MODULO_MODE:p,POW_PRECISION:h,FORMAT:b,ALPHABET:I}},v.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var S,w,A=m.c,f=m.e,k=m.s;e:if({}.toString.call(A)=="[object Array]"){if((k===1||k===-1)&&f>=-cn&&f<=cn&&f===dr(f)){if(A[0]===0){if(f===0&&A.length===1)return!0;break e}if(S=(f+1)%He,S<1&&(S+=He),String(A[0]).length==S){for(S=0;S<A.length;S++)if(w=A[S],w<0||w>=Pr||w!==dr(w))break e;if(w!==0)return!0}}}else if(A===null&&f===null&&(k===null||k===1||k===-1))return!0;throw Error(Hn+"Invalid BigNumber: "+m)},v.maximum=v.max=function(){return N(arguments,-1)},v.minimum=v.min=function(){return N(arguments,1)},v.random=(function(){var m=9007199254740992,S=Math.random()*m&2097151?function(){return dr(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(w){var A,f,k,E,x,T=0,P=[],B=new v(i);if(w==null?w=s:Ot(w,0,cn),E=ym(w/He),g)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(E*=2));T<E;)x=A[T]*131072+(A[T+1]>>>11),x>=9e15?(f=crypto.getRandomValues(new Uint32Array(2)),A[T]=f[0],A[T+1]=f[1]):(P.push(x%1e14),T+=2);T=E/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(E*=7);T<E;)x=(A[T]&31)*281474976710656+A[T+1]*1099511627776+A[T+2]*4294967296+A[T+3]*16777216+(A[T+4]<<16)+(A[T+5]<<8)+A[T+6],x>=9e15?crypto.randomBytes(7).copy(A,T):(P.push(x%1e14),T+=7);T=E/7}else throw g=!1,Error(Hn+"crypto unavailable");if(!g)for(;T<E;)x=S(),x<9e15&&(P[T++]=x%1e14);for(E=P[--T],w%=He,E&&w&&(x=Sm[He-w],P[T]=dr(E/x)*x);P[T]===0;P.pop(),T--);if(T<0)P=[k=0];else{for(k=-1;P[0]===0;P.splice(0,1),k-=He);for(T=1,x=P[0];x>=10;x/=10,T++);T<He&&(k-=He-T)}return B.e=k,B.c=P,B}})(),v.sum=function(){for(var m=1,S=arguments,w=new v(S[0]);m<S.length;)w=w.plus(S[m++]);return w},n=(function(){var m="0123456789";function S(w,A,f,k){for(var E,x=[0],T,P=0,B=w.length;P<B;){for(T=x.length;T--;x[T]*=A);for(x[0]+=k.indexOf(w.charAt(P++)),E=0;E<x.length;E++)x[E]>f-1&&(x[E+1]==null&&(x[E+1]=0),x[E+1]+=x[E]/f|0,x[E]%=f)}return x.reverse()}return function(w,A,f,k,E){var x,T,P,B,_,C,R,H,L=w.indexOf("."),ie=s,K=a;for(L>=0&&(B=h,h=0,w=w.replace(".",""),H=new v(A),C=H.pow(w.length-L),h=B,H.c=S(uo(pr(C.c),C.e,"0"),10,f,m),H.e=H.c.length),R=S(w,A,f,E?(x=I,m):(x=m,I)),P=B=R.length;R[--B]==0;R.pop());if(!R[0])return x.charAt(0);if(L<0?--P:(C.c=R,C.e=P,C.s=k,C=t(C,H,ie,K,f),R=C.c,_=C.r,P=C.e),T=P+ie+1,L=R[T],B=f/2,_=_||T<0||R[T+1]!=null,_=K<4?(L!=null||_)&&(K==0||K==(C.s<0?3:2)):L>B||L==B&&(K==4||_||K==6&&R[T-1]&1||K==(C.s<0?8:7)),T<1||!R[0])w=_?uo(x.charAt(1),-ie,x.charAt(0)):x.charAt(0);else{if(R.length=T,_)for(--f;++R[--T]>f;)R[T]=0,T||(++P,R=[1].concat(R));for(B=R.length;!R[--B];);for(L=0,w="";L<=B;w+=x.charAt(R[L++]));w=uo(w,P,x.charAt(0))}return w}})(),t=(function(){function m(A,f,k){var E,x,T,P,B=0,_=A.length,C=f%Bo,R=f/Bo|0;for(A=A.slice();_--;)T=A[_]%Bo,P=A[_]/Bo|0,E=R*T+P*C,x=C*T+E%Bo*Bo+B,B=(x/k|0)+(E/Bo|0)+R*P,A[_]=x%k;return B&&(A=[B].concat(A)),A}function S(A,f,k,E){var x,T;if(k!=E)T=k>E?1:-1;else for(x=T=0;x<k;x++)if(A[x]!=f[x]){T=A[x]>f[x]?1:-1;break}return T}function w(A,f,k,E){for(var x=0;k--;)A[k]-=x,x=A[k]<f[k]?1:0,A[k]=x*E+A[k]-f[k];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,f,k,E,x){var T,P,B,_,C,R,H,L,ie,K,se,me,Pe,Ge,re,Te,it,ne=A.s==f.s?1:-1,Be=A.c,ge=f.c;if(!Be||!Be[0]||!ge||!ge[0])return new v(!A.s||!f.s||(Be?ge&&Be[0]==ge[0]:!ge)?NaN:Be&&Be[0]==0||!ge?ne*0:ne/0);for(L=new v(ne),ie=L.c=[],P=A.e-f.e,ne=k+P+1,x||(x=Pr,P=gr(A.e/He)-gr(f.e/He),ne=ne/He|0),B=0;ge[B]==(Be[B]||0);B++);if(ge[B]>(Be[B]||0)&&P--,ne<0)ie.push(1),_=!0;else{for(Ge=Be.length,Te=ge.length,B=0,ne+=2,C=dr(x/(ge[0]+1)),C>1&&(ge=m(ge,C,x),Be=m(Be,C,x),Te=ge.length,Ge=Be.length),Pe=Te,K=Be.slice(0,Te),se=K.length;se<Te;K[se++]=0);it=ge.slice(),it=[0].concat(it),re=ge[0],ge[1]>=x/2&&re++;do{if(C=0,T=S(ge,K,Te,se),T<0){if(me=K[0],Te!=se&&(me=me*x+(K[1]||0)),C=dr(me/re),C>1)for(C>=x&&(C=x-1),R=m(ge,C,x),H=R.length,se=K.length;S(R,K,H,se)==1;)C--,w(R,Te<H?it:ge,H,x),H=R.length,T=1;else C==0&&(T=C=1),R=ge.slice(),H=R.length;if(H<se&&(R=[0].concat(R)),w(K,R,se,x),se=K.length,T==-1)for(;S(ge,K,Te,se)<1;)C++,w(K,Te<se?it:ge,se,x),se=K.length}else T===0&&(C++,K=[0]);ie[B++]=C,K[0]?K[se++]=Be[Pe]||0:(K=[Be[Pe]],se=1)}while((Pe++<Ge||K[0]!=null)&&ne--);_=K[0]!=null,ie[0]||ie.splice(0,1)}if(x==Pr){for(B=1,ne=ie[0];ne>=10;ne/=10,B++);M(L,k+(L.e=B+P*He-1)+1,E,_)}else L.e=P,L.r=+_;return L}})();function D(m,S,w,A){var f,k,E,x,T;if(w==null?w=a:Ot(w,0,8),!m.c)return m.toString();if(f=m.c[0],E=m.e,S==null)T=pr(m.c),T=A==1||A==2&&(E<=u||E>=c)?pc(T,E):uo(T,E,"0");else if(m=M(new v(m),S,w),k=m.e,T=pr(m.c),x=T.length,A==1||A==2&&(S<=k||k<=u)){for(;x<S;T+="0",x++);T=pc(T,k)}else if(S-=E+(A===2&&k>E),T=uo(T,k,"0"),k+1>x){if(--S>0)for(T+=".";S--;T+="0");}else if(S+=k-x,S>0)for(k+1==x&&(T+=".");S--;T+="0");return m.s<0&&f?"-"+T:T}function N(m,S){for(var w,A,f=1,k=new v(m[0]);f<m.length;f++)A=new v(m[f]),(!A.s||(w=si(k,A))===S||w===0&&k.s===S)&&(k=A);return k}function $(m,S,w){for(var A=1,f=S.length;!S[--f];S.pop());for(f=S[0];f>=10;f/=10,A++);return(w=A+w*He-1)>d?m.c=m.e=null:w<l?m.c=[m.e=0]:(m.e=w,m.c=S),m}r=(function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,S=/^([^.]+)\.$/,w=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(k,E,x,T){var P,B=x?E:E.replace(f,"");if(A.test(B))k.s=isNaN(B)?null:B<0?-1:1;else{if(!x&&(B=B.replace(m,function(_,C,R){return P=(R=R.toLowerCase())=="x"?16:R=="b"?2:8,!T||T==P?C:_}),T&&(P=T,B=B.replace(S,"$1").replace(w,"0.$1")),E!=B))return new v(B,P);if(v.DEBUG)throw Error(Hn+"Not a"+(T?" base "+T:"")+" number: "+E);k.s=null}k.c=k.e=null}})();function M(m,S,w,A){var f,k,E,x,T,P,B,_=m.c,C=Sm;if(_){e:{for(f=1,x=_[0];x>=10;x/=10,f++);if(k=S-f,k<0)k+=He,E=S,T=_[P=0],B=dr(T/C[f-E-1]%10);else if(P=ym((k+1)/He),P>=_.length)if(A){for(;_.length<=P;_.push(0));T=B=0,f=1,k%=He,E=k-He+1}else break e;else{for(T=x=_[P],f=1;x>=10;x/=10,f++);k%=He,E=k-He+f,B=E<0?0:dr(T/C[f-E-1]%10)}if(A=A||S<0||_[P+1]!=null||(E<0?T:T%C[f-E-1]),A=w<4?(B||A)&&(w==0||w==(m.s<0?3:2)):B>5||B==5&&(w==4||A||w==6&&(k>0?E>0?T/C[f-E]:0:_[P-1])%10&1||w==(m.s<0?8:7)),S<1||!_[0])return _.length=0,A?(S-=m.e+1,_[0]=C[(He-S%He)%He],m.e=-S||0):_[0]=m.e=0,m;if(k==0?(_.length=P,x=1,P--):(_.length=P+1,x=C[He-k],_[P]=E>0?dr(T/C[f-E]%C[E])*x:0),A)for(;;)if(P==0){for(k=1,E=_[0];E>=10;E/=10,k++);for(E=_[0]+=x,x=1;E>=10;E/=10,x++);k!=x&&(m.e++,_[0]==Pr&&(_[0]=1));break}else{if(_[P]+=x,_[P]!=Pr)break;_[P--]=0,x=1}for(k=_.length;_[--k]===0;_.pop());}m.e>d?m.c=m.e=null:m.e<l&&(m.c=[m.e=0])}return m}function z(m){var S,w=m.e;return w===null?m.toString():(S=pr(m.c),S=w<=u||w>=c?pc(S,w):uo(S,w,"0"),m.s<0?"-"+S:S)}return o.absoluteValue=o.abs=function(){var m=new v(this);return m.s<0&&(m.s=1),m},o.comparedTo=function(m,S){return si(this,new v(m,S))},o.decimalPlaces=o.dp=function(m,S){var w,A,f,k=this;if(m!=null)return Ot(m,0,cn),S==null?S=a:Ot(S,0,8),M(new v(k),m+k.e+1,S);if(!(w=k.c))return null;if(A=((f=w.length-1)-gr(this.e/He))*He,f=w[f])for(;f%10==0;f/=10,A--);return A<0&&(A=0),A},o.dividedBy=o.div=function(m,S){return t(this,new v(m,S),s,a)},o.dividedToIntegerBy=o.idiv=function(m,S){return t(this,new v(m,S),0,1)},o.exponentiatedBy=o.pow=function(m,S){var w,A,f,k,E,x,T,P,B,_=this;if(m=new v(m),m.c&&!m.isInteger())throw Error(Hn+"Exponent not an integer: "+z(m));if(S!=null&&(S=new v(S)),x=m.e>14,!_.c||!_.c[0]||_.c[0]==1&&!_.e&&_.c.length==1||!m.c||!m.c[0])return B=new v(Math.pow(+z(_),x?m.s*(2-uc(m)):+z(m))),S?B.mod(S):B;if(T=m.s<0,S){if(S.c?!S.c[0]:!S.s)return new v(NaN);A=!T&&_.isInteger()&&S.isInteger(),A&&(_=_.mod(S))}else{if(m.e>9&&(_.e>0||_.e<-1||(_.e==0?_.c[0]>1||x&&_.c[1]>=24e7:_.c[0]<8e13||x&&_.c[0]<=9999975e7)))return k=_.s<0&&uc(m)?-0:0,_.e>-1&&(k=1/k),new v(T?1/k:k);h&&(k=ym(h/He+2))}for(x?(w=new v(.5),T&&(m.s=1),P=uc(m)):(f=Math.abs(+z(m)),P=f%2),B=new v(i);;){if(P){if(B=B.times(_),!B.c)break;k?B.c.length>k&&(B.c.length=k):A&&(B=B.mod(S))}if(f){if(f=dr(f/2),f===0)break;P=f%2}else if(m=m.times(w),M(m,m.e+1,1),m.e>14)P=uc(m);else{if(f=+z(m),f===0)break;P=f%2}_=_.times(_),k?_.c&&_.c.length>k&&(_.c.length=k):A&&(_=_.mod(S))}return A?B:(T&&(B=i.div(B)),S?B.mod(S):k?M(B,h,a,E):B)},o.integerValue=function(m){var S=new v(this);return m==null?m=a:Ot(m,0,8),M(S,S.e+1,m)},o.isEqualTo=o.eq=function(m,S){return si(this,new v(m,S))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(m,S){return si(this,new v(m,S))>0},o.isGreaterThanOrEqualTo=o.gte=function(m,S){return(S=si(this,new v(m,S)))===1||S===0},o.isInteger=function(){return!!this.c&&gr(this.e/He)>this.c.length-2},o.isLessThan=o.lt=function(m,S){return si(this,new v(m,S))<0},o.isLessThanOrEqualTo=o.lte=function(m,S){return(S=si(this,new v(m,S)))===-1||S===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,S){var w,A,f,k,E=this,x=E.s;if(m=new v(m,S),S=m.s,!x||!S)return new v(NaN);if(x!=S)return m.s=-S,E.plus(m);var T=E.e/He,P=m.e/He,B=E.c,_=m.c;if(!T||!P){if(!B||!_)return B?(m.s=-S,m):new v(_?E:NaN);if(!B[0]||!_[0])return _[0]?(m.s=-S,m):new v(B[0]?E:a==3?-0:0)}if(T=gr(T),P=gr(P),B=B.slice(),x=T-P){for((k=x<0)?(x=-x,f=B):(P=T,f=_),f.reverse(),S=x;S--;f.push(0));f.reverse()}else for(A=(k=(x=B.length)<(S=_.length))?x:S,x=S=0;S<A;S++)if(B[S]!=_[S]){k=B[S]<_[S];break}if(k&&(f=B,B=_,_=f,m.s=-m.s),S=(A=_.length)-(w=B.length),S>0)for(;S--;B[w++]=0);for(S=Pr-1;A>x;){if(B[--A]<_[A]){for(w=A;w&&!B[--w];B[w]=S);--B[w],B[A]+=Pr}B[A]-=_[A]}for(;B[0]==0;B.splice(0,1),--P);return B[0]?$(m,B,P):(m.s=a==3?-1:1,m.c=[m.e=0],m)},o.modulo=o.mod=function(m,S){var w,A,f=this;return m=new v(m,S),!f.c||!m.s||m.c&&!m.c[0]?new v(NaN):!m.c||f.c&&!f.c[0]?new v(f):(p==9?(A=m.s,m.s=1,w=t(f,m,0,3),m.s=A,w.s*=A):w=t(f,m,0,p),m=f.minus(w.times(m)),!m.c[0]&&p==1&&(m.s=f.s),m)},o.multipliedBy=o.times=function(m,S){var w,A,f,k,E,x,T,P,B,_,C,R,H,L,ie,K=this,se=K.c,me=(m=new v(m,S)).c;if(!se||!me||!se[0]||!me[0])return!K.s||!m.s||se&&!se[0]&&!me||me&&!me[0]&&!se?m.c=m.e=m.s=null:(m.s*=K.s,!se||!me?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(A=gr(K.e/He)+gr(m.e/He),m.s*=K.s,T=se.length,_=me.length,T<_&&(H=se,se=me,me=H,f=T,T=_,_=f),f=T+_,H=[];f--;H.push(0));for(L=Pr,ie=Bo,f=_;--f>=0;){for(w=0,C=me[f]%ie,R=me[f]/ie|0,E=T,k=f+E;k>f;)P=se[--E]%ie,B=se[E]/ie|0,x=R*P+B*C,P=C*P+x%ie*ie+H[k]+w,w=(P/L|0)+(x/ie|0)+R*B,H[k--]=P%L;H[k]=w}return w?++A:H.splice(0,1),$(m,H,A)},o.negated=function(){var m=new v(this);return m.s=-m.s||null,m},o.plus=function(m,S){var w,A=this,f=A.s;if(m=new v(m,S),S=m.s,!f||!S)return new v(NaN);if(f!=S)return m.s=-S,A.minus(m);var k=A.e/He,E=m.e/He,x=A.c,T=m.c;if(!k||!E){if(!x||!T)return new v(f/0);if(!x[0]||!T[0])return T[0]?m:new v(x[0]?A:f*0)}if(k=gr(k),E=gr(E),x=x.slice(),f=k-E){for(f>0?(E=k,w=T):(f=-f,w=x),w.reverse();f--;w.push(0));w.reverse()}for(f=x.length,S=T.length,f-S<0&&(w=T,T=x,x=w,S=f),f=0;S;)f=(x[--S]=x[S]+T[S]+f)/Pr|0,x[S]=Pr===x[S]?0:x[S]%Pr;return f&&(x=[f].concat(x),++E),$(m,x,E)},o.precision=o.sd=function(m,S){var w,A,f,k=this;if(m!=null&&m!==!!m)return Ot(m,1,cn),S==null?S=a:Ot(S,0,8),M(new v(k),m,S);if(!(w=k.c))return null;if(f=w.length-1,A=f*He+1,f=w[f]){for(;f%10==0;f/=10,A--);for(f=w[0];f>=10;f/=10,A++);}return m&&k.e+1>A&&(A=k.e+1),A},o.shiftedBy=function(m){return Ot(m,-bm,bm),this.times("1e"+m)},o.squareRoot=o.sqrt=function(){var m,S,w,A,f,k=this,E=k.c,x=k.s,T=k.e,P=s+4,B=new v("0.5");if(x!==1||!E||!E[0])return new v(!x||x<0&&(!E||E[0])?NaN:E?k:1/0);if(x=Math.sqrt(+z(k)),x==0||x==1/0?(S=pr(E),(S.length+T)%2==0&&(S+="0"),x=Math.sqrt(+S),T=gr((T+1)/2)-(T<0||T%2),x==1/0?S="5e"+T:(S=x.toExponential(),S=S.slice(0,S.indexOf("e")+1)+T),w=new v(S)):w=new v(x+""),w.c[0]){for(T=w.e,x=T+P,x<3&&(x=0);;)if(f=w,w=B.times(f.plus(t(k,f,P,1))),pr(f.c).slice(0,x)===(S=pr(w.c)).slice(0,x))if(w.e<T&&--x,S=S.slice(x-3,x+1),S=="9999"||!A&&S=="4999"){if(!A&&(M(f,f.e+s+2,0),f.times(f).eq(k))){w=f;break}P+=4,x+=4,A=1}else{(!+S||!+S.slice(1)&&S.charAt(0)=="5")&&(M(w,w.e+s+2,1),m=!w.times(w).eq(k));break}}return M(w,w.e+s+1,a,m)},o.toExponential=function(m,S){return m!=null&&(Ot(m,0,cn),m++),D(this,m,S,1)},o.toFixed=function(m,S){return m!=null&&(Ot(m,0,cn),m=m+this.e+1),D(this,m,S)},o.toFormat=function(m,S,w){var A,f=this;if(w==null)m!=null&&S&&typeof S=="object"?(w=S,S=null):m&&typeof m=="object"?(w=m,m=S=null):w=b;else if(typeof w!="object")throw Error(Hn+"Argument not an object: "+w);if(A=f.toFixed(m,S),f.c){var k,E=A.split("."),x=+w.groupSize,T=+w.secondaryGroupSize,P=w.groupSeparator||"",B=E[0],_=E[1],C=f.s<0,R=C?B.slice(1):B,H=R.length;if(T&&(k=x,x=T,T=k,H-=k),x>0&&H>0){for(k=H%x||x,B=R.substr(0,k);k<H;k+=x)B+=P+R.substr(k,x);T>0&&(B+=P+R.slice(k)),C&&(B="-"+B)}A=_?B+(w.decimalSeparator||"")+((T=+w.fractionGroupSize)?_.replace(new RegExp("\\d{"+T+"}\\B","g"),"$&"+(w.fractionGroupSeparator||"")):_):B}return(w.prefix||"")+A+(w.suffix||"")},o.toFraction=function(m){var S,w,A,f,k,E,x,T,P,B,_,C,R=this,H=R.c;if(m!=null&&(x=new v(m),!x.isInteger()&&(x.c||x.s!==1)||x.lt(i)))throw Error(Hn+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+z(x));if(!H)return new v(R);for(S=new v(i),P=w=new v(i),A=T=new v(i),C=pr(H),k=S.e=C.length-R.e-1,S.c[0]=Sm[(E=k%He)<0?He+E:E],m=!m||x.comparedTo(S)>0?k>0?S:P:x,E=d,d=1/0,x=new v(C),T.c[0]=0;B=t(x,S,0,1),f=w.plus(B.times(A)),f.comparedTo(m)!=1;)w=A,A=f,P=T.plus(B.times(f=P)),T=f,S=x.minus(B.times(f=S)),x=f;return f=t(m.minus(w),A,0,1),T=T.plus(f.times(P)),w=w.plus(f.times(A)),T.s=P.s=R.s,k=k*2,_=t(P,A,k,a).minus(R).abs().comparedTo(t(T,w,k,a).minus(R).abs())<1?[P,A]:[T,w],d=E,_},o.toNumber=function(){return+z(this)},o.toPrecision=function(m,S){return m!=null&&Ot(m,1,cn),D(this,m,S,2)},o.toString=function(m){var S,w=this,A=w.s,f=w.e;return f===null?A?(S="Infinity",A<0&&(S="-"+S)):S="NaN":(m==null?S=f<=u||f>=c?pc(pr(w.c),f):uo(pr(w.c),f,"0"):m===10&&F?(w=M(new v(w),s+f+1,a),S=uo(pr(w.c),w.e,"0")):(Ot(m,2,I.length,"Base"),S=n(uo(pr(w.c),f,"0"),10,m,A,!0)),A<0&&w.c[0]&&(S="-"+S)),S},o.valueOf=o.toJSON=function(){return z(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&v.set(e),v}function gr(e){var t=e|0;return e>0||e===t?t:t-1}function pr(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 si(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 Ot(e,t,n,r){if(e<t||e>n||e!==dr(e))throw Error(Hn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function uc(e){var t=e.c.length-1;return gr(e.e/He)==t&&e.c[t]%2!=0}function pc(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function uo(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 Wz=$v(),Uv=Wz;var Vz=24,ia=32,Gz=()=>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,vm=Gz(),wm=(e=4,t=vm)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function qz(e){let t=new Uv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var Hv=(e="")=>{let t=new TextEncoder;return qz(Ov(t.encode(e))).toString(36).slice(1)},jv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),Yz=e=>jv[Math.floor(e()*jv.length)],Kz=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=vm}={})=>{let n=Object.keys(e).toString(),r=n.length?n+wm(ia,t):wm(ia,t);return Hv(r).substring(0,ia)},Xz=e=>()=>e++,Qz=476782367,Wv=({random:e=vm,counter:t=Xz(Math.floor(e()*Qz)),length:n=Vz,fingerprint:r=Kz({random:e})}={})=>{if(n>ia)throw new Error(`Length must be between 2 and ${ia}. Received: ${n}`);return function(){let i=Yz(e),s=Date.now().toString(36),a=t().toString(36),u=wm(n,e),c=`${s+u+a+r}`;return`${i+Hv(c).substring(1,n)}`}},Do=Jz(Wv);function Jz(e){let t;return()=>(t||(t=e()),t())}var tN=tl(qv());ln();Ne();var dc=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function nN(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function km(e,t){let n=[],r=e.split(`
15
+ `);for(let s=0;s<r.length;s++){let a=nN(r[s]),u=dc.exec(a);if(u){let[,c,l,,d]=u,g=rN(l),p=oN(r,s+1),h={id:Do(),reviewId:t,type:c.trim(),severity:g,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(h)}dc.lastIndex=0}return n.map(s=>{let a=Gs(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 rN(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function oN(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||dc.test(i)){dc.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}Ne();var sa=null,Yv=0,iN=3e4;async function sN(){let e=Date.now();if(sa&&e-Yv<iN)return sa;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 sa=n.entries||n.stories||{},Yv=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(sa).length),sa}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function aa(e){try{let n=(await sN())[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 Cm(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function aN(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 Tm(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):aN(e.type,t)}ln();Ne();function lN(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 cN(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 uN(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 pN(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 Im(e){if(!e||e.length===0)return[];let t=e.filter(i=>!uN(i)),n=[],r=[];for(let i of t){let s=lN(i),a=cN(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(pN(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}Ne();ln();var dN=[/Failed to fetch/i,/NetworkError/i,/network request failed/i,/load failed/i,/ERR_(NETWORK|INTERNET|CONNECTION|NAME_NOT_RESOLVED)/i,/timed out/i,/aborted/i],gN=[/credits?/i,/Rate limit/i,/Figma connection expired/i,/Map.*to Figma|Figma mapping required/i,/No project selected/i,/Not authenticated/i,/No story/i,/Monthly review limit/i,/Upgrade your plan/i];function Kv(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return gN.some(n=>n.test(t))?t:dN.some(n=>n.test(t))?`Can't reach ${Et.NAME}. Check your internet connection and try again. If the dashboard URL is wrong, fix it in Settings.`:/Unauthorized|401/i.test(t)?"Your session expired. Sign out and back in from Settings to continue.":/Internal Server Error|5\d\d|server error/i.test(t)?`${Et.NAME}'s servers had a hiccup. Try the review again in a moment. If it keeps failing, send feedback.`:/parsing|SSE|stream|structured result|failed to receive/i.test(t)?"Review completed but the result was malformed. Try again, or send feedback if it keeps happening.":`Review failed: ${t}. Try again, or send feedback if this keeps happening.`}$e();import{addons as Vi}from"storybook/manager-api";var Fm="uireview/badge",Hi={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function fN(e){return e.score<70?"status-value:error":e.score<90?"status-value:warning":"status-value:success"}function mN(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 hN(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Wi(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Jv(e){if(Wi())try{Vi.getChannel().emit(Hi.REVIEW_START,{storyId:e})}catch{}}function jr(e,t){if(Wi())try{Vi.getChannel().emit(Hi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function Zv(e){if(Wi())try{Vi.getChannel().emit(Hi.REVIEW_ERROR,{storyId:e})}catch{}}function Xv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Qv=null;function ek(e){if(Qv!==null)return;let t=Vi.getChannel(),n=o=>i=>{Wi()&&o(i)};t.on(Hi.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:Fm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(Hi.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:fN(i),typeId:Fm,storyId:o,title:hN(i),description:mN(i)}])})),t.on(Hi.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:Fm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Wi();r||Xv(e),Qv=setInterval(()=>{let o=Wi();o!==r&&(r=o,o||Xv(e))},1500)}var xN="uireview/mapped",tk="uireview/mappings-updated";function nk(e){try{Vi.getChannel().emit(tk,{storyIds:e})}catch{}}function rk(e){Vi.getChannel().on(tk,({storyIds:n})=>{n.length&&e.set(n.map(r=>({value:"status-value:success",typeId:xN,storyId:r,title:"\u2713 Linked to Figma",description:"Story has a Figma mapping"})))})}var Em=Y(),Am=180;function Ro(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 Pm=()=>{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,setReviewingStoryId:g,setReviewError:p,setReviewResults:h,setShowReviewMenu:b,setSeverityFilter:I,setShowStreamingPanel:F,setStreamingPanelCollapsed:v,addStreamingMessage:D,updateStreamingMessage:N,clearStreamingMessages:$,setStreamingProgress:M,setStreamingStatus:z,setFullPrompt:m,setFullResponse:S,setFigmaImageUrl:w,storybookImageUrl:A,setStorybookImageUrl:f,setFigmaDimensions:k,setMultiModelResults:E,updateMultiModelStreamingMessages:x,setModelCompleted:T,setActiveModelId:P,resetReview:B,addReview:_,setReviewDetailTab:C,includeTextComparison:R,usePromptCache:H,setApplyFixesResult:L,featureFlags:ie,roleOverride:K}=ue(),{sessionToken:se,usageData:me,setUsageData:Pe}=Se(),{selectedProjectId:Ge}=Xe(),{currentStoryId:re,currentStoryName:Te}=Ze(),it=gc(me);it.current=me;let ne=gc(null),Be=gc(null),ge=gc({}),dt=la((fe,Fe)=>{D({role:fe,content:Fe})},[D]),ot=la((fe,Fe)=>{M(fe),z(Fe)},[M,z]),bn=la(async fe=>{let{isIteration:Fe=!1,parentReviewId:q=null}=fe||{};if(!se)throw new Error("Not authenticated");if(!Ge)throw new Error("No project selected");if(!re||!Te)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let je=Date.now();try{d(!0),g(re),p(null),h(null),C("issues"),L(null),re&&ie.enableReviewBadges&&Jv(re),Be.current&&clearTimeout(Be.current),Be.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${Am}s timeout`),ne.current&&ne.current.abort(),D({role:"system",content:`Review auto-stopped after ${Am} seconds timeout.`})},Am*1e3),m(""),S(""),F(!0),v(!1),$(),ot(0,"Starting review..."),ot(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await sc(),y.debug("[Review] Iframe reloaded, styles should be fresh"),ot(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[gt,O,j]=await Promise.all([oc({sessionToken:se||void 0}),Promise.resolve(ra()),Promise.resolve(pm())]);if(gt&&gt!==A&&(f(gt),y.debug("[Review] Storybook screenshot captured and set")),!O)throw new Error("Failed to extract styles from component");let{computed:G,declared:W,markup:le,textElementStyles:he,nestedElementStyles:Rn}=O;j?y.debug("[Review] DOM tree extracted:",{selector:j.selector,childrenCount:j.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")),ot(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:re,name:Te});let vt=yt.getState().currentMapping?.figmaNodeId??null,Sr=yt.getState().figmaImageUrl;if(vt&&(y.debug("[Review] Using Figma node ID from store:",vt),Sr&&(ot(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!vt)try{let Ke=await fetch(`${Em}/api/mappings?projectId=${Ge}&storyId=${re}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${se}`}});if(Ke.ok){let Nt=await Ke.json();Nt.mapping?.figmaNodeId?(vt=Nt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",vt)):y.debug("[Review] No mapping found for story:",re)}else y.debug("[Review] Failed to fetch mapping:",Ke.status)}catch(Ke){y.error("[Review] Error fetching mapping:",Ke)}if(vt&&!Sr){ot(65,"Fetching Figma design...");try{let Ke=await fetch(`${Em}/api/figma/frames?projectId=${Ge}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${se}`}});if(Ke.ok){let jt=(await Ke.json()).thumbnails?.[vt];jt?(w(jt),y.debug("[Review] Figma thumbnail fetched and displayed:",jt)):y.warn("[Review] No thumbnail found for node:",vt)}else y.warn("[Review] Failed to fetch Figma frames:",Ke.status)}catch(Ke){y.error("[Review] Error fetching Figma frames:",Ke)}}if(!vt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');ot(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let So={projectId:Ge,storyId:re,storyName:Te,storybookScreenshot:gt,computedStyles:G,declaredStyles:W,textElementStyles:he,nestedElementStyles:Rn,componentMarkup:le,domTree:j,figmaNodeId:vt,figmaImageUrl:Sr||void 0,aiModels:l,includeTextComparison:R,usePromptCache:H,parentReviewId:Fe?q:void 0,isIteration:Fe};y.debug("[Review] Request payload:",{...So,storybookScreenshot:gt?`${gt.substring(0,50)}...`:null,domTree:j?{selector:j.selector,childrenCount:j.children.length}:null}),ne.current=new AbortController;let $t=await fetch(`${Em}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${se}`,...ac(K)},body:JSON.stringify(So),signal:ne.current.signal});if(y.debug("[Review] Response status:",$t.status,$t.statusText),!$t.ok){let Ke=await $t.json();if(y.error("[Review] API error response:",Ke),$t.status===429){let Nt=Ke.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Nt} seconds before trying again.`)}if($t.status===402){if(Ke.code==="INSUFFICIENT_CREDITS"){let Nt=Ke.details?.required??1,jt=Ke.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Nt} credit(s) but you have ${jt}. Visit Settings to add more.`)}throw Ke.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Ke.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Ke.message||"Payment required")}throw $t.status===401&&Ke.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Ke.error||Ke.message||"Review request failed")}let Qr=$t.body?.getReader(),wr=new TextDecoder,Tu="",wo="",Oe=null,Iu=null,yy=l.length>1,Qo={},hs={},m9={};if(!Qr)throw new Error("Response body is not readable");let by=yt.getState().streamingMessages.length;for(dt("assistant","");;){let{done:Ke,value:Nt}=await Qr.read();if(Ke)break;Tu+=wr.decode(Nt,{stream:!0});let jt=Tu.split(`
17
+ `);Tu=jt.pop()||"";for(let Xn of jt)if(Xn.startsWith("data: ")){let fn=Xn.slice(6);if(fn==="[DONE]")continue;try{let ae=JSON.parse(fn);if(ae.type!=="text"&&ae.type!=="content"&&y.debug("[Review] SSE Event received:",ae.type),ae.type==="prompt")ae.prompt&&(m(ae.prompt),y.debug("[Review] Prompt received early"));else if(ae.type==="model_started")y.debug("[Review] Model started:",ae.modelId),Qo[ae.modelId]||(Qo[ae.modelId]="",hs[ae.modelId]=[{role:"assistant",content:""}]);else if(ae.type==="text"||ae.type==="content")if(yy&&ae.modelId){Qo[ae.modelId]||(Qo[ae.modelId]="",hs[ae.modelId]=[{role:"assistant",content:""}]),Qo[ae.modelId]+=ae.content,hs[ae.modelId][0].content=Qo[ae.modelId],x(ae.modelId,hs[ae.modelId]);let Kt=Object.entries(Qo).map(([mn,st])=>`[${mn}]
18
18
  ${st}`).join(`
19
19
 
20
20
  ---
21
21
 
22
- `);_(by,Kt)}else wo+=se.content,_(by,wo);else if(se.type==="model_completed")y.debug("[Review] Model completed:",se.modelId,se.complianceScore),C(se.modelId);else if(se.type==="figma_image")se.url&&(w(se.url),y.debug("[Review] Figma image URL received:",se.url));else if(se.type==="figma_dimensions")se.width&&se.height&&(k({width:se.width,height:se.height}),y.debug("[Review] Figma dimensions received:",se.width,"x",se.height));else if(se.type==="complete"||se.type==="result")Oe=se,y.debug("[Review] Final result received! Type:",se.type),y.debug("[Review] Final result issues count:",se.issues?.length||0),y.debug("[Review] Final result score:",se.validation?.complianceScore),se.remainingCredits!=null&&it.current&&Pe({...it.current,creditBalance:se.remainingCredits,reviewCredits:Math.floor(se.remainingCredits)});else if(se.type==="all_complete")Oe=se,y.debug("[Review] Multi-model results received:",Object.keys(se.byModel)),se.remainingCredits!=null&&it.current&&Pe({...it.current,creditBalance:se.remainingCredits,reviewCredits:Math.floor(se.remainingCredits)});else if(se.type==="error"||se.type==="model_error"){let Kt=new Error(se.message||se.error||"Streaming error");throw Kt.isServerError=!0,Kt}}catch(se){if(se.isServerError)throw se;let Kt=se instanceof Error?{message:se.message,name:se.name,stack:se.stack}:String(se);y.error("[Review] Error parsing SSE data:",Kt),y.error("[Review] Failed to parse data:",fn.substring(0,200)+(fn.length>200?"...":"")),Iu=se instanceof Error?se:new Error(String(se))}}}if(ot(100,"Review complete!"),!Oe&&Iu&&(y.error("[Review] No final result received. Last parse error:",Iu),y.error("[Review] Streaming text available:",wo.length,"chars")),yy&&Oe?.type==="all_complete"){let Ke=Object.keys(Oe.byModel).reduce((jt,Xn)=>{let fn=Oe.byModel[Xn];return jt[Xn]={...fn,fullResponse:fn.response||fn.fullResponse||"",fullPrompt:fn.prompt||fn.fullPrompt||"",streamingMessages:fs[Xn]||[]},jt},{}),Nt=Object.keys(Oe.byModel)[0];E({byModel:Ke,activeModelId:Nt}),Ke[Nt]?.fullPrompt&&h(Ke[Nt].fullPrompt),y.debug("[Review] Multi-model results stored:",Object.keys(Oe.byModel));try{let jt=Do(),Xn=Oe.byModel?.[Nt]?.issues,fn=Xn&&Xn.length>0,se=fn?Xn.map(de=>({id:Do(),reviewId:jt,dbId:de.dbId,type:de.type,severity:de.severity,title:de.description,description:de.description,property:de.property,expected:Ro(de.expected),actual:Ro(de.actual),currentValue:Ro(de.actual),suggestedValue:Ro(de.expected),source:de.source||"computed-styles",suggestedFix:de.suggestedFix,file:de.file,domElement:de.domElement,figmaElement:de.figmaElement,fixTarget:de.fixTarget,fixRequired:de.fixRequired,detectedBy:de.detectedBy,dismissed:de.dismissed??!1,dismissReason:de.dismissReason,dismissedAt:de.dismissed?new Date:void 0,_unreliable:de._unreliable,_validationError:de._validationError,figmaContext:de.figmaContext,relatedTo:Array.isArray(de.relatedTo)?de.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):km(Ke[Nt]?.fullResponse||"",jt);y.debug("[Review] Multi-model issues source:",fn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Multi-model issues count:",se.length,"issues");let Kt=se.filter(de=>de.dismissed).length;Kt>0&&(y.debug("[Review] Multi-model auto-dismissed:",Kt,"false positive issues"),dt("system",`
22
+ `);N(by,Kt)}else wo+=ae.content,N(by,wo);else if(ae.type==="model_completed")y.debug("[Review] Model completed:",ae.modelId,ae.complianceScore),T(ae.modelId);else if(ae.type==="figma_image")ae.url&&(w(ae.url),y.debug("[Review] Figma image URL received:",ae.url));else if(ae.type==="figma_dimensions")ae.width&&ae.height&&(k({width:ae.width,height:ae.height}),y.debug("[Review] Figma dimensions received:",ae.width,"x",ae.height));else if(ae.type==="complete"||ae.type==="result")Oe=ae,y.debug("[Review] Final result received! Type:",ae.type),y.debug("[Review] Final result issues count:",ae.issues?.length||0),y.debug("[Review] Final result score:",ae.validation?.complianceScore),ae.remainingCredits!=null&&it.current&&Pe({...it.current,creditBalance:ae.remainingCredits,reviewCredits:Math.floor(ae.remainingCredits)});else if(ae.type==="all_complete")Oe=ae,y.debug("[Review] Multi-model results received:",Object.keys(ae.byModel)),ae.remainingCredits!=null&&it.current&&Pe({...it.current,creditBalance:ae.remainingCredits,reviewCredits:Math.floor(ae.remainingCredits)});else if(ae.type==="error"||ae.type==="model_error"){let Kt=new Error(ae.message||ae.error||"Streaming error");throw Kt.isServerError=!0,Kt}}catch(ae){if(ae.isServerError)throw ae;let Kt=ae instanceof Error?{message:ae.message,name:ae.name,stack:ae.stack}:String(ae);y.error("[Review] Error parsing SSE data:",Kt),y.error("[Review] Failed to parse data:",fn.substring(0,200)+(fn.length>200?"...":"")),Iu=ae instanceof Error?ae:new Error(String(ae))}}}if(ot(100,"Review complete!"),!Oe&&Iu&&(y.error("[Review] No final result received. Last parse error:",Iu),y.error("[Review] Streaming text available:",wo.length,"chars")),yy&&Oe?.type==="all_complete"){let Ke=Object.keys(Oe.byModel).reduce((jt,Xn)=>{let fn=Oe.byModel[Xn];return jt[Xn]={...fn,fullResponse:fn.response||fn.fullResponse||"",fullPrompt:fn.prompt||fn.fullPrompt||"",streamingMessages:hs[Xn]||[]},jt},{}),Nt=Object.keys(Oe.byModel)[0];E({byModel:Ke,activeModelId:Nt}),Ke[Nt]?.fullPrompt&&m(Ke[Nt].fullPrompt),y.debug("[Review] Multi-model results stored:",Object.keys(Oe.byModel));try{let jt=Do(),Xn=Oe.byModel?.[Nt]?.issues,fn=Xn&&Xn.length>0,ae=fn?Xn.map(de=>({id:Do(),reviewId:jt,dbId:de.dbId,type:de.type,severity:de.severity,title:de.description,description:de.description,property:de.property,expected:Ro(de.expected),actual:Ro(de.actual),currentValue:Ro(de.actual),suggestedValue:Ro(de.expected),source:de.source||"computed-styles",suggestedFix:de.suggestedFix,file:de.file,domElement:de.domElement,figmaElement:de.figmaElement,fixTarget:de.fixTarget,fixRequired:de.fixRequired,detectedBy:de.detectedBy,dismissed:de.dismissed??!1,dismissReason:de.dismissReason,dismissedAt:de.dismissed?new Date:void 0,_unreliable:de._unreliable,_validationError:de._validationError,figmaContext:de.figmaContext,relatedTo:Array.isArray(de.relatedTo)?de.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):km(Ke[Nt]?.fullResponse||"",jt);y.debug("[Review] Multi-model issues source:",fn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Multi-model issues count:",ae.length,"issues");let Kt=ae.filter(de=>de.dismissed).length;Kt>0&&(y.debug("[Review] Multi-model auto-dismissed:",Kt,"false positive issues"),dt("system",`
23
23
 
24
24
  ---
25
25
 
26
- \u2705 ${Kt} issue${Kt>1?"s were":" was"} auto-dismissed as false positive${Kt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let mn=ge.current[ne];mn||(mn=await ia(ne)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},mn.storyFile&&(ge.current[ne]=mn)),y.debug("[Review] Story file paths:",mn);let st=se.map(de=>({...de,file:de.file||Cm(de.fixTarget,mn)||Tm(de,mn)}));if(st=Im(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!z){let de=st.length;st=st.filter(Fn=>Fn.property?.toLowerCase()!=="textcontent"&&!Fn.description?.toLowerCase().includes("text content")),de!==st.length&&y.debug("[Review] Filtered out",de-st.length,"textContent issues (toggle OFF)")}let Nr=Oe.validation?.complianceScore??Ke[Nt]?.complianceScore;if(y.debug("[Review] Multi-model score sources:",{firstModelId:Nt,validationScore:Oe.validation?.complianceScore,modelScore:Ke[Nt]?.complianceScore,multiModelScore:Nr}),Nr==null){let Fn=(Ke[Nt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Nr=Fn?parseInt(Fn[1],10):void 0,y.debug("[Review] Parsed multi-model score from response:",Nr)}let Rn;Fe&&q&&(Rn=(yt.getState().reviewHistory.find(Fn=>Fn.id===q)?.iterationNumber||0)+1);let ms={id:jt,componentId:ne,storyId:ne,modelId:Nt,parentReviewId:Fe&&q||void 0,iterationNumber:Rn,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Sr||void 0,complianceScore:Nr,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(de=>!de.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-je,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:ms.inputTokens}),N(ms),ne&&ie.enableReviewBadges){let de=st.filter(Fn=>!Fn.dismissed);jr(ne,{score:Nr??100,issueCount:de.length,criticalCount:de.filter(Fn=>Fn.severity==="critical").length,majorCount:de.filter(Fn=>Fn.severity==="major").length,minorCount:de.filter(Fn=>Fn.severity==="minor").length})}I("issues");let Ja=st.filter(de=>!de.dismissed).length;y.debug("[Review] Created multi-model review with",Ja,"active issues,",st.length-Ja,"dismissed");let ke=vt||yt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Issue validation handled server-side. Active:",st.filter(de=>!de.dismissed).length,"Dismissed:",st.filter(de=>de.dismissed).length)}catch(jt){y.error("[Review] Failed to parse issues from multi-model response:",jt)}}else if(Oe){Oe.prompt&&h(Oe.prompt),(Oe.response||wo)&&S(Oe.response||wo),Oe.figmaImageUrl&&w(Oe.figmaImageUrl),y.debug("[Review] State updated with prompt, response, and screenshots");try{let Ke=Do(),Nt=Oe.response||wo,jt=Oe.issues,Xn=jt&&jt.length>0,fn=Xn?jt.map(ke=>({id:Do(),reviewId:Ke,dbId:ke.dbId,type:ke.type,severity:ke.severity,title:ke.description,description:ke.description,property:ke.property,expected:Ro(ke.expected),actual:Ro(ke.actual),currentValue:Ro(ke.actual),suggestedValue:Ro(ke.expected),source:ke.source||"computed-styles",suggestedFix:ke.suggestedFix,file:ke.file,domElement:ke.domElement,figmaElement:ke.figmaElement,fixTarget:ke.fixTarget,fixRequired:ke.fixRequired,detectedBy:ke.detectedBy,dismissed:ke.dismissed??!1,dismissReason:ke.dismissReason,dismissedAt:ke.dismissed?new Date:void 0,_unreliable:ke._unreliable,_validationError:ke._validationError,figmaContext:ke.figmaContext,relatedTo:Array.isArray(ke.relatedTo)?ke.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):km(Nt,Ke);y.debug("[Review] Issues source:",Xn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Issues count:",fn.length,"issues");let se=fn.filter(ke=>ke.dismissed).length;se>0&&(y.debug("[Review] Auto-dismissed:",se,"false positive issues"),dt("system",`
26
+ \u2705 ${Kt} issue${Kt>1?"s were":" was"} auto-dismissed as false positive${Kt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let mn=ge.current[re];mn||(mn=await aa(re)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},mn.storyFile&&(ge.current[re]=mn)),y.debug("[Review] Story file paths:",mn);let st=ae.map(de=>({...de,file:de.file||Cm(de.fixTarget,mn)||Tm(de,mn)}));if(st=Im(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!R){let de=st.length;st=st.filter(En=>En.property?.toLowerCase()!=="textcontent"&&!En.description?.toLowerCase().includes("text content")),de!==st.length&&y.debug("[Review] Filtered out",de-st.length,"textContent issues (toggle OFF)")}let Nr=Oe.validation?.complianceScore??Ke[Nt]?.complianceScore;if(y.debug("[Review] Multi-model score sources:",{firstModelId:Nt,validationScore:Oe.validation?.complianceScore,modelScore:Ke[Nt]?.complianceScore,multiModelScore:Nr}),Nr==null){let En=(Ke[Nt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Nr=En?parseInt(En[1],10):void 0,y.debug("[Review] Parsed multi-model score from response:",Nr)}let zn;Fe&&q&&(zn=(yt.getState().reviewHistory.find(En=>En.id===q)?.iterationNumber||0)+1);let xs={id:jt,componentId:re,storyId:re,modelId:Nt,parentReviewId:Fe&&q||void 0,iterationNumber:zn,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Sr||void 0,complianceScore:Nr,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(de=>!de.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-je,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:xs.inputTokens}),_(xs),re&&ie.enableReviewBadges){let de=st.filter(En=>!En.dismissed);jr(re,{score:Nr??100,issueCount:de.length,criticalCount:de.filter(En=>En.severity==="critical").length,majorCount:de.filter(En=>En.severity==="major").length,minorCount:de.filter(En=>En.severity==="minor").length})}C("issues");let Za=st.filter(de=>!de.dismissed).length;y.debug("[Review] Created multi-model review with",Za,"active issues,",st.length-Za,"dismissed");let ke=vt||yt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Issue validation handled server-side. Active:",st.filter(de=>!de.dismissed).length,"Dismissed:",st.filter(de=>de.dismissed).length)}catch(jt){y.error("[Review] Failed to parse issues from multi-model response:",jt)}}else if(Oe){Oe.prompt&&m(Oe.prompt),(Oe.response||wo)&&S(Oe.response||wo),Oe.figmaImageUrl&&w(Oe.figmaImageUrl),y.debug("[Review] State updated with prompt, response, and screenshots");try{let Ke=Do(),Nt=Oe.response||wo,jt=Oe.issues,Xn=jt&&jt.length>0,fn=Xn?jt.map(ke=>({id:Do(),reviewId:Ke,dbId:ke.dbId,type:ke.type,severity:ke.severity,title:ke.description,description:ke.description,property:ke.property,expected:Ro(ke.expected),actual:Ro(ke.actual),currentValue:Ro(ke.actual),suggestedValue:Ro(ke.expected),source:ke.source||"computed-styles",suggestedFix:ke.suggestedFix,file:ke.file,domElement:ke.domElement,figmaElement:ke.figmaElement,fixTarget:ke.fixTarget,fixRequired:ke.fixRequired,detectedBy:ke.detectedBy,dismissed:ke.dismissed??!1,dismissReason:ke.dismissReason,dismissedAt:ke.dismissed?new Date:void 0,_unreliable:ke._unreliable,_validationError:ke._validationError,figmaContext:ke.figmaContext,relatedTo:Array.isArray(ke.relatedTo)?ke.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):km(Nt,Ke);y.debug("[Review] Issues source:",Xn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Issues count:",fn.length,"issues");let ae=fn.filter(ke=>ke.dismissed).length;ae>0&&(y.debug("[Review] Auto-dismissed:",ae,"false positive issues"),dt("system",`
27
27
 
28
28
  ---
29
29
 
30
- \u2705 ${se} issue${se>1?"s were":" was"} auto-dismissed as false positive${se>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Kt=Oe.complianceScore??Oe.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Oe.complianceScore,validationScore:Oe.validation?.complianceScore,parsedScore:Kt}),Kt==null){let ke=Nt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Kt=ke?parseInt(ke[1],10):void 0,y.debug("[Review] Parsed score from response:",Kt)}let mn=ge.current[ne];mn||(mn=await ia(ne)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},mn.storyFile&&(ge.current[ne]=mn)),y.debug("[Review] Story file paths:",mn);let st=fn.map(ke=>({...ke,file:ke.file||Cm(ke.fixTarget,mn)||Tm(ke,mn)}));if(st=Im(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!z){let ke=st.length;st=st.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),ke!==st.length&&y.debug("[Review] Filtered out",ke-st.length,"textContent issues (toggle OFF)")}let Nr;Fe&&q&&(Nr=(yt.getState().reviewHistory.find(de=>de.id===q)?.iterationNumber||0)+1);let Rn={id:Ke,componentId:ne,storyId:ne,modelId:l[0],parentReviewId:Fe&&q||void 0,iterationNumber:Nr,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Sr||void 0,complianceScore:Kt,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(ke=>!ke.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-je,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:Rn.id,storyId:Rn.storyId,issueCount:Rn.issues?.length,complianceScore:Rn.complianceScore,createdAt:Rn.createdAt?.toISOString(),inputTokens:Rn.inputTokens,outputTokens:Rn.outputTokens,costUsd:Rn.costUsd,cacheCreationTokens:Rn.cacheCreationTokens,cacheReadTokens:Rn.cacheReadTokens}),N(Rn),y.debug("[useAIReview] addReview called successfully"),ne&&ie.enableReviewBadges){let ke=st.filter(de=>!de.dismissed);jr(ne,{score:Kt??100,issueCount:ke.length,criticalCount:ke.filter(de=>de.severity==="critical").length,majorCount:ke.filter(de=>de.severity==="major").length,minorCount:ke.filter(de=>de.severity==="minor").length})}I("issues");let ms=st.filter(ke=>!ke.dismissed).length;y.debug("[Review] Created review with",ms,"active issues,",st.length-ms,"dismissed");let Ja=vt||yt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:vt,effectiveFigmaNodeIdSingle:Ja,hasSessionToken:!!ae,selectedProjectId:Ye,issueCount:st.length}),y.debug("[Review] Issue validation handled server-side. Active:",st.filter(ke=>!ke.dismissed).length,"Dismissed:",st.filter(ke=>ke.dismissed).length)}catch(Ke){y.error("[Review] Failed to parse issues:",Ke)}}else throw wo?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",wo.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(gt){if(gt instanceof Error&&gt.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),ot(0,"Review cancelled");return}y.error("[useAIReview] Review error:",gt);let O=Kv(gt);throw p(O),ne&&ie.enableReviewBadges&&Zv(ne),ot(0,`Error: ${O}`),gt}finally{d(!1),g(null),te.current=null,Be.current&&(clearTimeout(Be.current),Be.current=null),Pe(null)}},[e,ae,Ye,ne,Te,l,d,p,m,E,x,C,P,F,v,$,dt,ot,_,f,w,h,S,Pe]),br=sa(()=>n?.issues?o==="all"?n.issues:n.issues.filter(fe=>fe.severity===o):[],[n,o]),or=sa(()=>{te.current&&(y.debug("[useAIReview] Cancelling review..."),te.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:bn,cancelReview:or,setShowReviewMenu:b,setSeverityFilter:T,setShowStreamingPanel:F,setStreamingPanelCollapsed:v,addStreamingMessage:D,updateStreamingMessage:_,clearStreamingMessages:$,setStreamingProgress:L,setStreamingStatus:R,resetReview:B,getFilteredIssues:br}};ve();Ne();$e();import{useCallback as DJ}from"react";var OJ=Y();ve();Ne();import{useEffect as ok,useRef as ik}from"react";import{useStorybookApi as yN,useStorybookState as bN,addons as SN}from"storybook/manager-api";var sk="storyArgsUpdated",Lm=()=>{let e=yN(),t=bN(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=Ze(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ue(),l=ik(null),d=ik(0);return ok(()=>{let g=t.storyId;if(g){l.current!==g&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,d.current=Date.now()),o(g);let p=e.getData(g),m=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||g;i(m),y.debug("[useCurrentStory] Current story:",{storyId:g,fullName:m})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),ok(()=>{let g=SN.getChannel(),p=null,m=b=>{if(b.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:T,isValidating:F}=yt.getState();if(T||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 g.on(sk,m),()=>{g.off(sk,m),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};ve();$e();lt();import{useCallback as ak}from"react";import{addons as lk}from"storybook/manager-api";var ck=Y(),si=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=Ze(),{sessionToken:o}=Se(),{selectedProjectId:i}=Xe(),s=ak(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await re(`${ck}/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{lk.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=ak(async c=>{if(!o)throw new Error("Not authenticated");if(!(await re(`${ck}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{lk.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Ui();ve();import{useCallback as Mm,useEffect as uk,useRef as wN}from"react";import{useChannel as vN,addons as pk}from"storybook/manager-api";Ne();var kN=3e4,CN="forceRemount";function TN(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 IN(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 FN="UICOPILOT/APPLY_FIXES",EN="UICOPILOT/FIX_STARTED",AN="UICOPILOT/FIX_COMPLETED",PN="UICOPILOT/FIX_FAILED",LN="UICOPILOT/ALL_FIXES_APPLIED",Bm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ue(),c=wN(null),l=Mm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);uk(()=>()=>l(),[l]),uk(()=>{let m=pk.getChannel(),b=()=>{yt.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 m.on("channelWSDisconnect",b),()=>m.off("channelWSDisconnect",b)},[l,o,i]);let d=vN({[EN]:({issueId:m})=>{y.debug(`[useApplyFixes] Fix started for issue: ${m}`),a(m,{status:"applying"})},[AN]:({issueId:m,result:b})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${m}`,b),s(m,"applied"),a(m,{status:"applied"})},[PN]:({issueId:m,error:b})=>{y.error(`[useApplyFixes] Fix failed for issue: ${m}`,b),s(m,"failed",b),a(m,{status:"failed",error:b})},[LN]:async({summary:m})=>{if(y.debug("[useApplyFixes] All fixes applied:",m),l(),o(!1),i({succeeded:m.succeeded,failed:m.failed,total:m.total}),m.failed>0?y.warn(`Applied ${m.succeeded}/${m.total} fixes. ${m.failed} failed.`):y.debug(`Successfully applied all ${m.total} fixes!`),m.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{pk.getChannel().emit(CN,{storyId:yt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(b){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",b)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await ic(),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")}}),g=Mm(m=>{let b=[],T=[],F=[];for(let v of m){let D=v.currentValue||v.actual||"",_=v.suggestedValue||v.expected||"";if(D&&_&&TN(D,_)){b.push(v);continue}if(IN(v)){T.push(v);continue}let $=v.generatedFix?.filePath||v.file||"";if(!$){y.warn(`[useApplyFixes] Skipping issue ${v.id} - no target file path`);continue}let L=$.toLowerCase().split(".").pop()||"",R=["tsx","jsx","ts","js"].includes(L)?"component":"css";F.push({...v,targetFilePath:$,targetFileType:R})}return{actionable:F,negligible:b,designTokens:T}},[]);return{applyFixes:Mm(m=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(m.length===0){y.warn("[useApplyFixes] No issues to fix");return}let b=g(m);if(b.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${b.negligible.length} negligible issue(s)`),b.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${b.designTokens.length} design token suggestion(s)`),b.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let T=b.actionable.filter(D=>D.targetFileType==="css"),F=b.actionable.filter(D=>D.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),T.length>0){let D=[...new Set(T.map(_=>_.targetFilePath))];y.debug(` - ${T.length} CSS issue(s) in: ${D.join(", ")}`)}if(F.length>0){let D=[...new Set(F.map(_=>_.targetFilePath))];y.debug(` - ${F.length} component issue(s) in: ${D.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:b.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{yt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:b.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},kN),d(FN,{issues:b.actionable,storybookRoot:n||void 0})},[d,r,o,i,g,n,l]),isApplying:r}};ve();$e();import{useState as iZ}from"react";var lZ=Y();ve();import{useState as ai}from"react";$e();Ne();lt();var MN=Y();async function gc(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 re(`${MN}/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 dk(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=>gc(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"}}ln();dm();Ui();Ne();$e();var BN=["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"],DN=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],RN=Y();function Dm(){let[e,t]=ai(!1),[n,r]=ai(null),[o,i]=ai(null),[s,a]=ai(null),[u,c]=ai(null),[l,d]=ai(null),[g,p]=ai(null),{sessionToken:m}=Se(),{selectedProjectId:b}=Xe(),{currentStoryId:T,currentStoryName:F}=Ze(),{workspacePath:v,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:_,includeComponentIssues:$,dismissIssue:L,recalculateScore:R,addStreamingMessage:h,roleOverride:S}=ue();return{generateBatchFixes:async A=>{if(!m){r("Not authenticated");return}if(!b){r("No project selected");return}if(!T){r("No story selected");return}if(A.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:A.length,completed:0});let f=A.map(k=>({issueId:k.id,generatedFix:{code:"",diffPreview:"",filePath:k.file||"",confidence:0,strategy:"",status:"generating"}}));_(f);try{y.debug("[useBatchGenerateFixes] Generating fixes for",A.length,"issues");let k=null;try{let z=ta();z?.computed&&(k=z.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(z){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",z)}let E=null;try{E=await ia(T),E&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",E)}catch(z){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",z)}let x=await fetch(`${RN}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`,...sc(S)},body:JSON.stringify({projectId:b,storyId:T,workspacePath:v,includeComponentIssues:$,computedStyles:k,storyFilePaths:E,reviewContext:{storyName:F||void 0,variantArgs:$i()||void 0},issues:A.map(z=>({id:z.id,dbId:z.dbId,title:z.title,description:z.description,property:z.property,currentValue:z.currentValue,suggestedValue:z.suggestedValue,file:z.file,lineNumber:z.lineNumber,severity:z.severity,type:z.type,fixTarget:z.fixTarget,domElement:z.domElement,figmaContext:z.figmaContext,suggestedFix:z.suggestedFix}))})});if(!x.ok){let z=await x.json().catch(()=>({}));throw new Error(z.error||"Batch fix generation failed")}let C=await x.json();if(!C.success)throw new Error(C.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",C.result.fixes.length,"fixes"),C.result.storybookRoot&&(p(C.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",C.result.storybookRoot)),C.result.selfReview&&(d(C.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",C.result.selfReview)),C.result.partialFailure){let{failedBatches:z,errors:W}=C.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${z.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",W),r(`Some fixes couldn't be generated (${z.join(", ")}): ${W[0]||"Unknown error"}`)}a({total:A.length,completed:C.result.fixes.length});let P=new Set(C.result.fixes.map(z=>z.issueId)),B=A.filter(z=>!P.has(z.id));B.length>0&&(y.warn(`[useBatchGenerateFixes] ${B.length} issues not returned by API, marking as failed`),B.forEach(z=>{D(z.id,{code:"",diffPreview:"",filePath:z.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),C.timing&&(i({durationSec:C.timing.durationSec,issueCount:C.timing.issueCount,avgPerIssueSec:C.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${C.timing.durationSec}s for ${C.timing.issueCount} issues`)),C.result?.usage&&(c({inputTokens:C.result.usage.inputTokens||0,outputTokens:C.result.usage.outputTokens||0,costUsd:C.result.usage.costUsd||0,modelId:C.result.usage.modelId||"unknown",provider:C.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${C.result.usage.inputTokens} in, ${C.result.usage.outputTokens} out, $${C.result.usage.costUsd?.toFixed(4)}`));let N=[],I=[];if(C.result.fixes.forEach(z=>{let W=z.noChangesNeeded===!0;if(!W){let K=(z.fixStrategy||"").toLowerCase(),ae=(z.generatedCode||"").toLowerCase(),xe=(z.diffPreview||"").toLowerCase(),Pe=BN.some(ne=>K.includes(ne.toLowerCase())||K.replace(/[-_]/g,"").includes(ne.replace(/[-_]/g,""))),Ye=DN.some(ne=>ae.includes(ne)||xe.includes(ne));W=Pe||Ye}let M=A.find(K=>K.id===z.issueId);if(W&&M){let K=M.suggestedValue,ae=M.currentValue;K&&ae&&!ri(K,ae)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${K}", actual="${ae}"), NOT auto-dismissing issue ${z.issueId}`),W=!1)}let ie=M?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${z.issueId}:`,{isFalsePositive:W,isProgrammaticIssue:ie,detectedBy:M?.detectedBy,noChangesNeeded:z.noChangesNeeded,fixStrategy:z.fixStrategy,title:M?.title?.substring(0,50)}),ie&&W&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${z.issueId} (detectedBy: ${M?.detectedBy})`),W=!1),W){let K=`Auto-dismissed: ${z.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${z.issueId} - noChangesNeeded: ${z.noChangesNeeded}, strategy: "${z.fixStrategy}"`),L(z.issueId,K),N.push({localId:z.issueId,dbId:M?.dbId,dismissReason:K}),I.push({issueId:z.issueId,generatedFix:{code:z.generatedCode||"",diffPreview:z.diffPreview||"",filePath:z.filePath,confidence:z.confidence,strategy:z.fixStrategy,status:"ready",error:void 0,noChangesExplanation:z.noChangesExplanation}})}else{let K=z.error||z.fixStrategy==="skipped"?"failed":"ready";I.push({issueId:z.issueId,generatedFix:{code:z.generatedCode,diffPreview:z.diffPreview,filePath:z.filePath,confidence:z.confidence,strategy:z.fixStrategy,status:K,error:z.error,noChangesExplanation:z.noChangesExplanation}})}}),I.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${I.length} fix updates in batch`),_(I)),N.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${N.length} false positive(s), recalculating score`),R(),m){let W=N.filter(M=>M.dbId).map(M=>({dbId:M.dbId,dismissed:!0,dismissReason:M.dismissReason,dismissedBy:"system"}));W.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${W.length} dismissals to server`),dk(W,m).then(M=>{M.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${M.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",M.error)}).catch(M=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",M)}))}let z=N.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${N.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;h({role:"system",content:z})}y.debug("[useBatchGenerateFixes] Updated",C.result.fixes.length,"issues with fixes")}catch(k){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",k),r(k?.message||"Failed to generate batch fixes");let E=A.map(x=>({issueId:x.id,generatedFix:{code:"",diffPreview:"",filePath:x.file||"",confidence:0,strategy:"",status:"failed",error:k?.message||"Failed to generate fix"}}));_(E)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}ve();Ne();$e();lt();import{useState as Rm,useCallback as zm}from"react";var zN=Y();function Nm(){let[e,t]=Rm([]),[n,r]=Rm(!1),[o,i]=Rm(null),{sessionToken:s}=Se(),{selectedProjectId:a}=Xe(),{currentStoryId:u}=Ze(),{setReviewResults:c}=ue(),l=zm(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let m=await re(`${zN}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!m.ok){let T=await m.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch reviews")}let b=await m.json();if(!b.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",b.reviews.length,"reviews for:",u),t(b.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=zm(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let m=[];if(typeof p.models=="string")try{m=JSON.parse(p.models)}catch(v){y.error("[useReviewHistory] Failed to parse models:",v),m=["claude-sonnet-4-20250514"]}else m=p.models;let b=p.issues.map(v=>({id:v.id,reviewId:p.id,type:v.type,severity:v.severity,title:v.description,description:v.description,file:void 0,lineNumber:void 0,property:v.property,currentValue:v.actual,suggestedValue:v.expected,suggestedCode:v.suggestedFix||void 0,status:v.status,dismissed:v.dismissed||!1,dismissReason:v.dismissReason,dismissedBy:v.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(v.createdAt)})),T=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:m[0]||"claude-sonnet-4-6",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:b,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:T}),F){let v=p.issues.filter(L=>!L.dismissed),D=v.filter(L=>L.severity==="critical").length,_=v.filter(L=>L.severity==="major").length,$=v.filter(L=>L.severity==="minor").length;jr(F,{score:p.complianceScore,issueCount:v.length,criticalCount:D,majorCount:_,minorCount:$})}},[c]),g=zm(p=>{let m=e.find(b=>b.id===p);if(!m){y.error("[useReviewHistory] Review not found:",p);return}d(m)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}ve();Ne();import{useEffect as NN,useState as ON,useRef as fc}from"react";import{useChannel as _N}from"storybook/manager-api";var $N="UICOPILOT/WORKSPACE_PATH",gk="UICOPILOT/REQUEST_WORKSPACE_PATH",UN=3e3,jN=500,HN=5,Om=()=>{let[e,t]=ON({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ue(),r=fc(!1),o=fc(null),i=fc(0),s=fc(null),a=_N({[$N]:({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 NN(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(gk,{}),s.current=setInterval(()=>{!r.current&&i.current<HN&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(gk,{}))},jN),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}))}},UN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},_m=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();$e();import{useEffect as WN,useRef as VN}from"react";var $Z=Y(),GN=new Set;function $m(){let{sessionToken:e}=Se(),{selectedProjectId:t}=Xe(),n=VN(!1);WN(()=>{t&&GN.add(t)},[e,t])}ve();ln();import{useCallback as HZ,useState as WZ}from"react";import{useState as li,useMemo as Ck,useCallback as Yi}from"react";$e();Ne();lt();ln();import{useState as uo,useEffect as mc,useRef as Gi,useCallback as Um}from"react";var qN=300;function fk({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=uo([]),[u,c]=uo({}),[l,d]=uo(0),[g,p]=uo([]),[m,b]=uo(new Set),[T,F]=uo(!1),[v,D]=uo(!1),[_,$]=uo(null),L=Gi(1),R=Gi(null),h=Gi(null),[S,w]=uo(0),A=Gi(!1),f=Gi({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});f.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let k=Um(async(B,N,I=!1)=>{let{projectId:z,typeFilter:W,search:M,figmaPage:ie,limit:K}=f.current;if(!z||!W)return;R.current&&R.current.abort();let ae=new AbortController;R.current=ae,N?D(!0):F(!0),$(null);try{let xe=Y(),Pe=localStorage.getItem("uicopilot_session_token");if(!Pe)throw new Error(`Not authenticated. Please connect to ${Et.NAME} first.`);let Ye=new URLSearchParams({projectId:z,page:String(B),limit:String(K)});W&&Ye.append("type",W),ie&&Ye.append("figmaPage",ie),M.trim()&&Ye.append("search",M.trim()),I&&Ye.append("refresh","true");let ne=await fetch(`${xe}/api/figma/frames?${Ye.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Pe}`},signal:ae.signal});if(!ne.ok){let ge=await ne.json();throw new Error(ge.error||"Failed to fetch frames")}let Te=await ne.json(),it=Te.frames||[],te=Te.thumbnails||{},Be=ne.headers.get("X-Cache-Status");if(it.length===0&&B===1&&!N&&!I&&!A.current&&Be!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),A.current=!0,await k(1,!1,!0);return}N?(a(ge=>[...ge,...it]),c(ge=>({...ge,...te}))):(a(it),c(te)),d(Te.total||it.length),Te.pages&&p(Te.pages),Te.cacheDiff?.added&&b(new Set(Te.cacheDiff.added)),L.current=B}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let Pe=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";$(Pe),y.error("Error fetching frames:",xe)}finally{ae.signal.aborted||(F(!1),D(!1))}},[]);mc(()=>{if(!i||!e||!t)return;A.current=!1,h.current&&clearTimeout(h.current);let B=n.trim()?qN:0;return h.current=setTimeout(()=>{L.current=1,k(1,!1)},B),()=>{h.current&&clearTimeout(h.current)}},[e,t,n,r,i,S,k]);let E=Gi(new Set);mc(()=>{if(s.length===0)return;let B={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(B[N.id]=N.thumbnailCdnUrl);Object.keys(B).length>0&&c(N=>({...N,...B}))},[s]),mc(()=>{if(s.length===0)return;let B=s.filter(I=>!I.thumbnailCdnUrl&&!u[I.id]&&!E.current.has(I.id)).map(I=>I.id);if(B.length===0)return;B.forEach(I=>E.current.add(I)),(async()=>{try{let{projectId:I}=f.current,z=Y(),W=localStorage.getItem("uicopilot_session_token");if(!W||!I)return;let M=await re(`${z}/api/figma/frames?projectId=${I}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${W}`}},6e4);if(M.ok){let ie=await M.json();ie.thumbnails&&Object.keys(ie.thumbnails).length>0&&c(K=>({...K,...ie.thumbnails}))}}catch(I){B.forEach(z=>E.current.delete(z)),y.error("Failed to fetch frame thumbnails:",I)}})()},[s,u]),mc(()=>()=>{R.current&&R.current.abort(),h.current&&clearTimeout(h.current)},[]);let x=Um(async()=>{let B=L.current+1;await k(B,!0)},[k]),C=Um(()=>{A.current=!1,L.current=1,a([]),c({}),w(B=>B+1)},[]),P=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:m,isLoading:T,loadingMore:v,hasMore:P,loadMore:x,refresh:C,error:_}}$e();Ne();lt();import{useState as qi,useCallback as hc,useRef as YN}from"react";function mk({projectId:e}){let[t,n]=qi({}),[r,o]=qi({}),[i,s]=qi(new Set),[a,u]=qi(new Set),[c,l]=qi({}),[d,g]=qi(null),p=YN({}),m=hc(async v=>{if(!(!e||i.has(v))){s(D=>new Set(D).add(v));try{let D=Y(),_=localStorage.getItem("uicopilot_session_token"),$=await re(`${D}/api/figma/variants?projectId=${e}&componentSetId=${v}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${_}`}});if($.ok){let L=await $.json();if(L.variants){n(h=>({...h,[v]:L.variants}));let R={};for(let h of L.variants)h.thumbnailCdnUrl&&(R[h.id]=h.thumbnailCdnUrl);o(h=>({...h,[v]:{...h[v]||{},...R}})),p.current[v]||(p.current[v]=new Set),Object.keys(R).forEach(h=>p.current[v].add(h))}else o(R=>({...R,[v]:R[v]||{}}))}else o(L=>({...L,[v]:{}}))}catch(D){y.error("Failed to fetch variant metadata:",D),o(_=>({..._,[v]:{}}))}finally{s(D=>{let _=new Set(D);return _.delete(v),_})}}},[e,i]),b=hc(async(v,D)=>{if(!e||D.length===0)return;p.current[v]||(p.current[v]=new Set);let _=r[v]||{},$=D.filter(L=>!p.current[v].has(L)&&!_[L]);if($.length!==0){$.forEach(L=>p.current[v].add(L)),u(L=>new Set(L).add(v));try{let L=Y(),R=localStorage.getItem("uicopilot_session_token"),h=await re(`${L}/api/figma/variants?projectId=${e}&componentSetId=${v}&thumbnailIds=${$.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`}});if(h.ok){let S=await h.json();S.rateLimitError?(g(S.rateLimitError),$.forEach(w=>p.current[v]?.delete(w))):(S.thumbnails&&Object.keys(S.thumbnails).length>0&&o(w=>({...w,[v]:{...w[v]||{},...S.thumbnails}})),Array.isArray(S.failed)&&S.failed.length>0&&l(w=>{let A=new Set(w[v]||[]);for(let f of S.failed)A.add(f);return{...w,[v]:A}}))}}catch(L){y.error("Failed to fetch variant thumbnails:",L),$.forEach(R=>p.current[v]?.delete(R))}finally{u(L=>{let R=new Set(L);return R.delete(v),R})}}},[e]),T=hc(v=>{o(D=>{let _={...D};return delete _[v],_}),n(D=>{let _={...D};return delete _[v],_}),l(D=>{let _={...D};return delete _[v],_}),delete p.current[v]},[]),F=hc(()=>{o({}),n({}),l({}),p.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,rateLimitError:d,fetchVariants:m,fetchVariantThumbnails:b,clearVariantsForSet:T,clearAllVariants:F}}$e();Ui();ve();Ne();lt();import{useState as hk,useEffect as xk,useRef as yk,useCallback as jm}from"react";function bk({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=hk(null),[i,s]=hk(!1),a=yk(null),u=yk(new Set),c=jm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=$i();if(!g||Object.keys(g).length===0)return;let p=yt.getState().currentStoryId||"",m=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase());a.current=e,s(!0),o(null);try{let b=Y(),T=localStorage.getItem("uicopilot_session_token"),F=await re(`${b}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({storyName:m,storyId:p,storyArgs:g,availableFilters:t.map(v=>({property:v.property,values:v.values}))})});if(F.ok){let v=await F.json();v.confidence>0&&Object.keys(v.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",v),o(v))}else F.status===404?y.debug("[useFilterSuggestion] match-filters endpoint not available (404), skipping suggestions"):y.error("[useFilterSuggestion] Unexpected status:",F.status)}catch(b){y.error("[useFilterSuggestion] Error:",b)}finally{s(!1)}},[e,t,n]);xk(()=>{c()},[c]),xk(()=>{e||(o(null),a.current=null)},[e]);let l=jm(()=>{},[]),d=jm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function Sk(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function wk(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 vk(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 kk(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 aa({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=li(!0),[i,s]=li(!1),[a,u]=li(!1),[c,l]=li(""),[d,g]=li(""),[p,m]=li([]),[b,T]=li(new Set),F=Yi(te=>{l(te),p.length>0&&m([]),b.size>0&&T(new Set)},[p.length,b.size]),v=Sk(r,i,a),{frames:D,thumbnails:_,totalFrames:$,availablePages:L,recentlyAdded:R,isLoading:h,loadingMore:S,hasMore:w,loadMore:A,refresh:f,error:k}=fk({projectId:e,typeFilter:v,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!v}),{variantChildren:E,variantThumbnails:x,variantFailed:C,loadingVariants:P,loadingThumbnails:B,rateLimitError:N,fetchVariants:I,fetchVariantThumbnails:z,clearVariantsForSet:W,clearAllVariants:M}=mk({projectId:e}),ie=Ck(()=>{let te=wk(E),Be=vk(D),ge={};for(let dt of[...te,...Be])ge[dt.property]||(ge[dt.property]=new Set),dt.values.forEach(ot=>ge[dt.property].add(ot));return Object.entries(ge).map(([dt,ot])=>({property:dt,values:Array.from(ot).sort()}))},[E,D]),K=b.size===1?Array.from(b)[0]:null,ae=bk({expandedSetId:K,availableFilters:ie,filtersReady:ie.length>0}),xe=Yi(()=>{if(!ae.suggestion)return;let{suggestedFilters:te}=ae.suggestion,Be=Object.entries(te).map(([ge,dt])=>({property:ge,value:dt}));m(Be),ae.dismissSuggestion()},[ae.suggestion]),Pe=Ck(()=>p.some(te=>te.value)?D.filter(te=>kk(te,p,E[te.id])):D,[D,p,E]),Ye=Yi((te,Be)=>{Be.stopPropagation();let ge=!b.has(te);T(dt=>{let ot=new Set(dt);return ot.has(te)?ot.delete(te):ot.add(te),ot}),ge&&!E[te]&&!P.has(te)?I(te):ge||W(te)},[b,E,P,I,W]),ne=Yi((te,Be)=>{let ge=Be===""?null:Be;m(dt=>dt.find(bn=>bn.property===te)?dt.map(bn=>bn.property===te?{...bn,value:ge}:bn):[...dt,{property:te,value:ge}])},[]),Te=Yi(()=>{m([])},[]),it=Yi(te=>{let Be=D.find(ge=>ge.id===te);if(Be?.thumbnailCdnUrl)return Be.thumbnailCdnUrl;if(_[te])return _[te];for(let ge of Object.values(x))if(ge[te])return ge[te]},[_,x]);return{frames:D,filteredFrames:Pe,thumbnails:_,totalFrames:$,isLoading:h,loadingMore:S,hasMore:w,error:k,loadMore:A,refresh:f,search:c,setSearch:F,figmaPage:d,setFigmaPage:g,availablePages:L,recentlyAdded:R,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:ie,handleFilterChange:ne,clearFilters:Te,expandedSets:b,toggleExpanded:Ye,variantChildren:E,variantThumbnails:x,variantFailed:C,loadingVariants:P,loadingThumbnails:B,rateLimitError:N,fetchVariantThumbnails:z,resolveThumbnail:it,filterSuggestion:ae.suggestion,filterSuggestionLoading:ae.isLoading,applySuggestedFilters:xe,dismissFilterSuggestion:ae.dismissSuggestion}}ve();import{useEffect as Lr,useCallback as ZN,useState as eO,useRef as tO}from"react";import{useChannel as nO}from"storybook/manager-api";function zo(e){return e.status===401||e.status===403}var Ln=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};ln();function Tk(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 Ou.error("Error parsing Figma URL:",t),null}}Ne();$e();$e();lt();var KN=Y();async function Hm(e){let t=await re(`${KN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(zo(t))throw new Ln(t.status);return t.ok?(await t.json()).projects||[]:[]}$e();lt();var XN=Y();async function Wm(e,t){let n=await re(`${XN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(zo(n))throw new Ln(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}$e();lt();var QN=Y();async function Vm(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 re(`${QN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(zo(s))throw new Ln(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}$e();lt();var JN=Y();async function Gm(e,t){let n=await re(`${JN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(zo(n))throw new Ln(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Ui();function rO(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 oO=Y(),iO="UICOPILOT/WORKSPACE_PATH",sO="UICOPILOT/REQUEST_WORKSPACE_PATH",qm=!1;function Ym(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=Se(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Xe(),{currentStoryId:l,mappingsRefreshKey:d,mappingsByStoryId:g,setFigmaFileUrl:p,setCurrentMapping:m,setMappingsByStoryId:b,setMappingSource:T,setLoadingMapping:F}=Ze(),{setReviewResults:v,setReviewDetailTab:D,setStorybookImageUrl:_,setFigmaImageUrl:$,setFullPrompt:L,setFullResponse:R,bulkAddReviews:h,setReviewHistoryLoading:S}=ue(),[w,A]=eO([]),f=tO(null);Lr(()=>{let x=C=>{C.origin.startsWith(oO)&&C.data?.type==="UICOPILOT_AUTH_SUCCESS"&&C.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(C.data.token))};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[t]);let k=nO({[iO]:x=>{y.debug("[useDataInit] Received workspace path:",x.path),c(x.path)}});Lr(()=>{k(sO)},[k]),Lr(()=>{if(!e)return;let x=!1;return(async()=>{try{u(!0);let P=await Hm(e);x||(s(P),n(null))}catch(P){P instanceof Ln&&(t(null),n(P.message)),y.error("[useDataInit] Failed to fetch projects:",P)}finally{x||u(!1)}})(),()=>{x=!0}},[e,s,u]),Lr(()=>{if(!i||r.length===0)return;let x=r.find(C=>C.storybookRoot===i);x?o!==x.id&&(y.debug("[useDataInit] Auto-selecting project:",x.name),a(x.id)):o&&(y.debug("[useDataInit] No project matches this Storybook \u2014 clearing selection"),a(null))},[i,r,o,a]),Lr(()=>{if(!o||r.length===0)return;let x=r.find(P=>P.id===o),C=x?.figmaFileId;if(x&&typeof C=="string"&&C){let P=C,B=P.includes("figma.com")&&Tk(P)?.fileKey||P;p(`https://www.figma.com/file/${B}`)}},[o,r,p]),Lr(()=>!e||!o||qm?void 0:(qm=!0,(async()=>{try{let C=await Gm(e,o);for(let[P,B]of Object.entries(C))jr(P,{score:B.score,issueCount:B.issueCount,criticalCount:B.criticalCount,majorCount:B.majorCount,minorCount:B.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(C).length,"stories")}catch(C){C instanceof Ln&&(t(null),n(C.message)),y.error("[useDataInit] Failed to fetch review statuses:",C)}})(),()=>{qm=!1}),[e,o]),Lr(()=>{if(!e||!o)return;let x=!1;return(async()=>{try{let P=await Wm(e,o);if(x)return;let B={};for(let N of P)N.storyId&&(B[N.storyId]=N);b(B),nk(Object.keys(B))}catch(P){P instanceof Ln&&(t(null),n(P.message)),y.error("[useDataInit] Failed to fetch all mappings:",P)}})(),()=>{x=!0}},[e,o,d,b]),Lr(()=>{if(!l){m(null),T(null);return}let x=g[l]||null;x?(m(x),T("database")):(m(null),T(null)),F(!1)},[l,g,m,T,F]),Lr(()=>{A([]),f.current=null},[l]),Lr(()=>{if(!e||!o||!l)return;let x=!1;return(async()=>{S(!0);try{let P=await Vm(e,o,l,10,!0);if(!x){A(P);let B=P.map(N=>rO(N)).filter(Boolean);B.length>0&&h(B)}}catch(P){P instanceof Ln&&(t(null),n(P.message)),y.error("[useDataInit] Failed to fetch reviews:",P)}finally{x||S(!1)}})(),()=>{x=!0}},[e,o,l,S,h]);let E=ZN(x=>{y.debug("[useDataInit] Applying review:",x.id,"with",x.issues.length,"issues");let C=[];if(typeof x.models=="string")try{C=JSON.parse(x.models)}catch{C=["claude-sonnet-4-20250514"]}else C=x.models;let P=x.issues.map(z=>({id:z.id,reviewId:x.id,type:z.type,severity:z.severity,title:z.description,description:z.description,file:void 0,lineNumber:void 0,property:z.property,currentValue:z.actual,suggestedValue:z.expected,suggestedCode:z.suggestedFix||void 0,status:z.status,dismissed:z.dismissed||!1,dismissReason:z.dismissReason,dismissedBy:z.dismissedBy,figmaContext:z.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(z.createdAt)})),B=x.completedAt&&x.createdAt?new Date(x.completedAt).getTime()-new Date(x.createdAt).getTime():void 0,N=x.storyId||"";v({id:x.id,componentId:"",storyId:N,modelId:C[0]||"claude-sonnet-4-5-20250929",complianceScore:x.complianceScore,issuesCount:x.issuesCount,issues:P,createdAt:new Date(x.createdAt),timestamp:new Date(x.createdAt).toISOString(),costUsd:x.costUsd,inputTokens:x.inputTokens,outputTokens:x.outputTokens,reviewDurationMs:B});let I=yt.getState().currentStoryId;if(N&&N===I&&(x.storybookScreenshot&&(_(x.storybookScreenshot),dv(N,x.storybookScreenshot,x.figmaScreenshot??void 0),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),x.figmaScreenshot&&($(x.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot"))),x.aiPrompt&&(L(x.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),x.aiResponse&&(R(x.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),N){let z=x.issues.filter(K=>!K.dismissed),W=z.filter(K=>K.severity==="critical").length,M=z.filter(K=>K.severity==="major").length,ie=z.filter(K=>K.severity==="minor").length;jr(N,{score:x.complianceScore,issueCount:z.length,criticalCount:W,majorCount:M,minorCount:ie})}},[v,_,$,L,R]);Lr(()=>{if(w.length>0&&l&&f.current!==l){let x=w[0];x&&x.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",x.id,"for:",l),f.current=l,E(x),D("issues"))}},[w,l,E,D])}ln();import{styled as la}from"storybook/theming";var aO=la.div({display:"flex",gap:"10px",marginTop:"8px"}),Ik=la.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),Fk=la.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"})),Ek=la.div({display:"flex",alignItems:"center",gap:"8px"}),Ak=la(En)(({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"})),Pk=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,saveApiKey:u}=Xs(),[c,l]=et.useState(""),d=()=>{let g=c.trim();g&&(u(g),e?.())};return et.createElement(et.Fragment,null,et.createElement(vo,null,et.createElement(ko,null,"Authentication Method"),et.createElement(aO,null,et.createElement(Ik,null,et.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),et.createElement(Ik,null,et.createElement("input",{type:"radio",name:"authMethod",checked:n==="apikey",onChange:()=>r("apikey")}),"API Key"))),n==="oauth"&&et.createElement(vo,null,et.createElement(ko,null,"Connect to ",Et.NAME),t?et.createElement(Fk,null,et.createElement(Ek,null,et.createElement("span",{style:{fontSize:"18px"}},"\u2713"),et.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Et.NAME)),et.createElement(Ak,{onClick:i,title:"Sign out and switch to a different account"},"Sign out")):s?et.createElement("div",{style:{padding:"20px 0",textAlign:"center",fontSize:"13px"}},et.createElement("div",{style:{fontSize:"24px",marginBottom:"8px"}},"\u{1F510}"),et.createElement(xs,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),et.createElement(xs,{style:{color:"inherit",opacity:.7}},"Complete sign-in in the popup, then return here.")):et.createElement("div",null,a&&et.createElement("div",{style:{marginBottom:"12px",padding:"10px 12px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#b91c1c"}},"\u26A0\uFE0F ",a),et.createElement(xs,{style:{marginBottom:"12px"}},"Connect to ",Et.NAME," to manage projects and integrations."),et.createElement(En,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Et.NAME))),n==="apikey"&&et.createElement(vo,null,et.createElement(ko,null,"Session Token"),t?et.createElement(Fk,null,et.createElement(Ek,null,et.createElement("span",{style:{fontSize:"18px"}},"\u2713"),et.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Et.NAME)),et.createElement(Ak,{onClick:i,title:"Sign out and switch to a different account"},"Sign out")):et.createElement(et.Fragment,null,et.createElement(xs,{style:{marginBottom:"12px"}},"Paste the session token from your ",Et.NAME," setup page."),et.createElement(hs,{type:"password",placeholder:"Paste session token",value:c,onChange:g=>l(g.target.value)}),et.createElement(En,{disabled:!c.trim(),style:{marginTop:"12px"},onClick:d},"Save Token"))))};import ct,{useState as Ki}from"react";ve();import Hn,{useState as lO,useEffect as cO,useCallback as uO}from"react";import{styled as po,keyframes as Lk}from"storybook/theming";var pO=Lk({from:{opacity:0},to:{opacity:1}}),dO=Lk({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),gO=po.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${pO} 150ms ease-out`}),fO=po.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:`${dO} 150ms ease-out`})),mO=po.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),hO=po.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})),xO=po.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),yO=po.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.6}px ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.background.app,color:e.color.defaultText,marginBottom:`${e.layoutMargin}px`,boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary}})),bO=po.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.6}px`,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.mediumdark})),SO=po.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}})),wO=po.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:not(:disabled)":{opacity:.9},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),Hr=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",confirmText:s,onConfirm:a,onCancel:u})=>{let[c,l]=lO(""),d=!!s&&c!==s,g=uO(p=>{p.key==="Escape"&&u()},[u]);return cO(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?Hn.createElement(Hn.Fragment,null,Hn.createElement(gO,{onClick:u}),Hn.createElement(fO,{role:"dialog","aria-modal":"true","aria-label":t},Hn.createElement(mO,null,t),Hn.createElement(hO,null,n),s&&Hn.createElement(Hn.Fragment,null,Hn.createElement(bO,null,"Type ",Hn.createElement("strong",null,s)," to confirm:"),Hn.createElement(yO,{type:"text",value:c,onChange:p=>l(p.target.value),placeholder:s,autoFocus:!0})),Hn.createElement(xO,null,Hn.createElement(SO,{onClick:u},o),Hn.createElement(wO,{variant:i,onClick:a,disabled:d},r)))):null};import{styled as un}from"storybook/theming";function vO(e,t,n){return e.filter(r=>r.id===t||!r.storybookRoot?!0:n?r.storybookRoot===n:!1)}var kO=un.div({marginBottom:"30px"}),CO=un.div({display:"flex",gap:"8px",alignItems:"center"}),TO=un(Sn)({flex:1}),IO=un(on)({padding:"8px 12px",whiteSpace:"nowrap"}),FO=un.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),EO=un.div(({theme:e})=>({marginTop:"6px",padding:"8px 10px",fontSize:"11px",lineHeight:1.4,color:e.color.warning,backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}40`,borderRadius:"4px"})),AO=un.div(({theme:e})=>({marginBottom:"10px",padding:"8px 10px",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",backgroundColor:e.background.content})),PO=un.div(({theme:e})=>({fontSize:"11px",lineHeight:1.5,color:e.color.mediumdark,marginBottom:"6px"})),LO=un.div({display:"flex",alignItems:"center",gap:"6px"}),MO=un.a(({theme:e})=>({flex:1,fontSize:"11px",fontFamily:e.typography.fonts.mono,color:e.color.secondary,textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","&:hover":{textDecoration:"underline"}})),BO=un.button(({theme:e})=>({fontSize:"11px",padding:"3px 8px",borderRadius:"3px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,color:e.color.defaultText,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:e.background.app}}));function Mk(e){return/figma\.com\/community\/file\//.test(e)}var Km=un.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Xm=un.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Qm=un(hs)({fontSize:"13px",padding:"6px 8px"}),DO=un.div({display:"flex",gap:"8px",marginTop:"12px"}),Bk=un(on)({fontSize:"12px",padding:"6px 12px"}),RO=un(Bk)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),zO=un.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.size.s1,transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),Dk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=lo(),{currentStorybookPath:s}=Xe(),[a,u]=Ki(!1),[c,l]=Ki(!1),[d,g]=Ki(!1),[p,m]=Ki(!1),[b,T]=Ki({name:"",storybookRoot:"",figmaFileUrl:""}),F=e.find(f=>f.id===t),v=vO(e,t,s),D=f=>{n(f||null),u(!1)},_=async()=>{if(t)try{m(!0),await i(t),g(!1)}catch(f){console.error("Failed to delete project:",f)}finally{m(!1)}},$=process.env.STORYBOOK_UICOPILOT_FIGMA_KIT||"",[L,R]=Ki(!1),h=()=>{$&&navigator.clipboard.writeText($).then(()=>{R(!0),setTimeout(()=>R(!1),2e3)})},S=()=>{if(u(!0),s){let f=s.replace(/\/+$/,"").split("/").pop()||"";T({storybookRoot:s,name:f,figmaFileUrl:""})}},w=async()=>{if(b.name.trim())try{l(!0);let f;if(b.figmaFileUrl.trim()){let E=b.figmaFileUrl.trim(),x=E.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);f=x?x[1]:E}let k=await o({name:b.name.trim(),storybookRoot:b.storybookRoot.trim()||void 0,figmaFileId:f});n(k.id),u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}catch(f){console.error("Failed to create project:",f)}finally{l(!1)}},A=f=>{T(k=>{let E={...k,storybookRoot:f};if(!k.name&&f){let x=f.replace(/\/+$/,"").split("/").pop()||"";E.name=x}return E})};return ct.createElement(kO,null,ct.createElement(Cy,null,"Project"),ct.createElement(CO,null,ct.createElement(TO,{value:t||"",onChange:f=>D(f.target.value),disabled:r||a},ct.createElement("option",{value:""},"-- Select a project --"),v.map(f=>ct.createElement("option",{key:f.id,value:f.id},f.name))),ct.createElement(IO,{onClick:S,disabled:r,type:"button"},"+ New"),ct.createElement(zO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),ct.createElement(Hr,{isOpen:d,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${F?.name||"this project"}". This cannot be undone.`,confirmLabel:p?"Deleting...":"Delete",confirmText:F?.name,variant:"danger",onConfirm:_,onCancel:()=>g(!1)}),a&&ct.createElement(FO,null,ct.createElement(Km,null,ct.createElement(Xm,null,"Storybook Path (for fix generation)"),ct.createElement(Qm,{type:"text",placeholder:"/path/to/your/storybook",value:b.storybookRoot,onChange:f=>A(f.target.value)})),ct.createElement(Km,null,ct.createElement(Xm,null,"Project Name *"),ct.createElement(Qm,{type:"text",placeholder:"my-storybook",value:b.name,onChange:f=>{let k=f.target.value;T(E=>({...E,name:k}))}})),$&&ct.createElement(AO,null,ct.createElement(PO,null,ct.createElement("strong",null,"1.")," Open this template's Figma kit, then click"," ",ct.createElement("strong",null,"Open in Figma")," (or ",ct.createElement("strong",null,"Get a copy"),") to duplicate it to your own Figma workspace. ",ct.createElement("strong",null,"2.")," ","Paste the URL of your copy (",ct.createElement("code",null,"figma.com/design/\u2026"),") into the field below."),ct.createElement(LO,null,ct.createElement(MO,{href:$,target:"_blank",rel:"noopener noreferrer",title:$},$),ct.createElement(BO,{type:"button",onClick:h},L?"Copied!":"Copy"))),ct.createElement(Km,null,ct.createElement(Xm,null,"Your Figma File URL (after duplicating)"),ct.createElement(Qm,{type:"text",placeholder:"https://www.figma.com/design/...",value:b.figmaFileUrl,onChange:f=>{let k=f.target.value;T(E=>({...E,figmaFileUrl:k}))}}),Mk(b.figmaFileUrl)&&ct.createElement(EO,null,"\u26A0 This is a community file URL \u2014 it can't be read by the API. Use the duplicated copy's URL instead (see instructions above).")),ct.createElement(DO,null,ct.createElement(Bk,{onClick:w,disabled:c||!b.name.trim()||!b.figmaFileUrl.trim()||Mk(b.figmaFileUrl)},c?"Creating...":"Create"),ct.createElement(RO,{onClick:()=>{u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import xt,{useState as ya,useCallback as d1,useEffect as q4}from"react";import{styled as Br}from"storybook/theming";import tn,{useState as Xi,useEffect as t_,useCallback as xc}from"react";import{styled as Wr}from"storybook/theming";ve();$e();lt();ve();$e();lt();import Vt,{useState as Jm}from"react";import{styled as Wn,keyframes as NO}from"storybook/theming";var OO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},_O=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",$O=Wn.div({position:"relative",display:"inline-flex"}),UO=NO`
30
+ \u2705 ${ae} issue${ae>1?"s were":" was"} auto-dismissed as false positive${ae>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Kt=Oe.complianceScore??Oe.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:Oe.complianceScore,validationScore:Oe.validation?.complianceScore,parsedScore:Kt}),Kt==null){let ke=Nt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Kt=ke?parseInt(ke[1],10):void 0,y.debug("[Review] Parsed score from response:",Kt)}let mn=ge.current[re];mn||(mn=await aa(re)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},mn.storyFile&&(ge.current[re]=mn)),y.debug("[Review] Story file paths:",mn);let st=fn.map(ke=>({...ke,file:ke.file||Cm(ke.fixTarget,mn)||Tm(ke,mn)}));if(st=Im(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!R){let ke=st.length;st=st.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),ke!==st.length&&y.debug("[Review] Filtered out",ke-st.length,"textContent issues (toggle OFF)")}let Nr;Fe&&q&&(Nr=(yt.getState().reviewHistory.find(de=>de.id===q)?.iterationNumber||0)+1);let zn={id:Ke,componentId:re,storyId:re,modelId:l[0],parentReviewId:Fe&&q||void 0,iterationNumber:Nr,figmaFileKey:void 0,figmaNodeId:vt||void 0,figmaFileUrl:Sr||void 0,complianceScore:Kt,visualSimilarity:Oe.visualSimilarity,issuesCount:st.filter(ke=>!ke.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-je,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:zn.id,storyId:zn.storyId,issueCount:zn.issues?.length,complianceScore:zn.complianceScore,createdAt:zn.createdAt?.toISOString(),inputTokens:zn.inputTokens,outputTokens:zn.outputTokens,costUsd:zn.costUsd,cacheCreationTokens:zn.cacheCreationTokens,cacheReadTokens:zn.cacheReadTokens}),_(zn),y.debug("[useAIReview] addReview called successfully"),re&&ie.enableReviewBadges){let ke=st.filter(de=>!de.dismissed);jr(re,{score:Kt??100,issueCount:ke.length,criticalCount:ke.filter(de=>de.severity==="critical").length,majorCount:ke.filter(de=>de.severity==="major").length,minorCount:ke.filter(de=>de.severity==="minor").length})}C("issues");let xs=st.filter(ke=>!ke.dismissed).length;y.debug("[Review] Created review with",xs,"active issues,",st.length-xs,"dismissed");let Za=vt||yt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:vt,effectiveFigmaNodeIdSingle:Za,hasSessionToken:!!se,selectedProjectId:Ge,issueCount:st.length}),y.debug("[Review] Issue validation handled server-side. Active:",st.filter(ke=>!ke.dismissed).length,"Dismissed:",st.filter(ke=>ke.dismissed).length)}catch(Ke){y.error("[Review] Failed to parse issues:",Ke)}}else throw wo?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",wo.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(gt){if(gt instanceof Error&&gt.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),ot(0,"Review cancelled");return}y.error("[useAIReview] Review error:",gt);let O=Kv(gt);throw p(O),re&&ie.enableReviewBadges&&Zv(re),ot(0,`Error: ${O}`),gt}finally{d(!1),g(null),ne.current=null,Be.current&&(clearTimeout(Be.current),Be.current=null),Pe(null)}},[e,se,Ge,re,Te,l,d,p,h,E,x,T,P,F,v,$,dt,ot,N,f,w,m,S,Pe]),br=la(()=>n?.issues?o==="all"?n.issues:n.issues.filter(fe=>fe.severity===o):[],[n,o]),or=la(()=>{ne.current&&(y.debug("[useAIReview] Cancelling review..."),ne.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:bn,cancelReview:or,setShowReviewMenu:b,setSeverityFilter:I,setShowStreamingPanel:F,setStreamingPanelCollapsed:v,addStreamingMessage:D,updateStreamingMessage:N,clearStreamingMessages:$,setStreamingProgress:M,setStreamingStatus:z,resetReview:B,getFilteredIssues:br}};ve();Ne();$e();import{useCallback as zJ}from"react";var $J=Y();ve();Ne();import{useEffect as ok,useRef as ik}from"react";import{useStorybookApi as yN,useStorybookState as bN,addons as SN}from"storybook/manager-api";var sk="storyArgsUpdated",Lm=()=>{let e=yN(),t=bN(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=Ze(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ue(),l=ik(null),d=ik(0);return ok(()=>{let g=t.storyId;if(g){l.current!==g&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,d.current=Date.now()),o(g);let p=e.getData(g),h=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||g;i(h),y.debug("[useCurrentStory] Current story:",{storyId:g,fullName:h})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),ok(()=>{let g=SN.getChannel(),p=null,h=b=>{if(b.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:I,isValidating:F}=yt.getState();if(I||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 g.on(sk,h),()=>{g.off(sk,h),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};ve();$e();lt();import{useCallback as ak}from"react";import{addons as lk}from"storybook/manager-api";var ck=Y(),ai=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=Ze(),{sessionToken:o}=Se(),{selectedProjectId:i}=Xe(),s=ak(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await oe(`${ck}/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{lk.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=ak(async c=>{if(!o)throw new Error("Not authenticated");if(!(await oe(`${ck}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{lk.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Ui();ve();import{useCallback as Mm,useEffect as uk,useRef as wN}from"react";import{useChannel as vN,addons as pk}from"storybook/manager-api";Ne();var kN=3e4,CN="forceRemount";function TN(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 IN(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 FN="UICOPILOT/APPLY_FIXES",EN="UICOPILOT/FIX_STARTED",AN="UICOPILOT/FIX_COMPLETED",PN="UICOPILOT/FIX_FAILED",LN="UICOPILOT/ALL_FIXES_APPLIED",Bm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ue(),c=wN(null),l=Mm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);uk(()=>()=>l(),[l]),uk(()=>{let h=pk.getChannel(),b=()=>{yt.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 h.on("channelWSDisconnect",b),()=>h.off("channelWSDisconnect",b)},[l,o,i]);let d=vN({[EN]:({issueId:h})=>{y.debug(`[useApplyFixes] Fix started for issue: ${h}`),a(h,{status:"applying"})},[AN]:({issueId:h,result:b})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${h}`,b),s(h,"applied"),a(h,{status:"applied"})},[PN]:({issueId:h,error:b})=>{y.error(`[useApplyFixes] Fix failed for issue: ${h}`,b),s(h,"failed",b),a(h,{status:"failed",error:b})},[LN]:async({summary:h})=>{if(y.debug("[useApplyFixes] All fixes applied:",h),l(),o(!1),i({succeeded:h.succeeded,failed:h.failed,total:h.total}),h.failed>0?y.warn(`Applied ${h.succeeded}/${h.total} fixes. ${h.failed} failed.`):y.debug(`Successfully applied all ${h.total} fixes!`),h.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{pk.getChannel().emit(CN,{storyId:yt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(b){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",b)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await sc(),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")}}),g=Mm(h=>{let b=[],I=[],F=[];for(let v of h){let D=v.currentValue||v.actual||"",N=v.suggestedValue||v.expected||"";if(D&&N&&TN(D,N)){b.push(v);continue}if(IN(v)){I.push(v);continue}let $=v.generatedFix?.filePath||v.file||"";if(!$){y.warn(`[useApplyFixes] Skipping issue ${v.id} - no target file path`);continue}let M=$.toLowerCase().split(".").pop()||"",z=["tsx","jsx","ts","js"].includes(M)?"component":"css";F.push({...v,targetFilePath:$,targetFileType:z})}return{actionable:F,negligible:b,designTokens:I}},[]);return{applyFixes:Mm(h=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(h.length===0){y.warn("[useApplyFixes] No issues to fix");return}let b=g(h);if(b.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${b.negligible.length} negligible issue(s)`),b.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${b.designTokens.length} design token suggestion(s)`),b.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let I=b.actionable.filter(D=>D.targetFileType==="css"),F=b.actionable.filter(D=>D.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),I.length>0){let D=[...new Set(I.map(N=>N.targetFilePath))];y.debug(` - ${I.length} CSS issue(s) in: ${D.join(", ")}`)}if(F.length>0){let D=[...new Set(F.map(N=>N.targetFilePath))];y.debug(` - ${F.length} component issue(s) in: ${D.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:b.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{yt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:b.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},kN),d(FN,{issues:b.actionable,storybookRoot:n||void 0})},[d,r,o,i,g,n,l]),isApplying:r}};ve();$e();import{useState as aZ}from"react";var uZ=Y();ve();import{useState as li}from"react";$e();Ne();lt();var MN=Y();async function fc(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(`${MN}/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 dk(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=>fc(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"}}ln();dm();Ui();Ne();$e();var BN=["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"],DN=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],RN=Y();function Dm(){let[e,t]=li(!1),[n,r]=li(null),[o,i]=li(null),[s,a]=li(null),[u,c]=li(null),[l,d]=li(null),[g,p]=li(null),{sessionToken:h}=Se(),{selectedProjectId:b}=Xe(),{currentStoryId:I,currentStoryName:F}=Ze(),{workspacePath:v,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:N,includeComponentIssues:$,dismissIssue:M,recalculateScore:z,addStreamingMessage:m,roleOverride:S}=ue();return{generateBatchFixes:async A=>{if(!h){r("Not authenticated");return}if(!b){r("No project selected");return}if(!I){r("No story selected");return}if(A.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),d(null),a({total:A.length,completed:0});let f=A.map(k=>({issueId:k.id,generatedFix:{code:"",diffPreview:"",filePath:k.file||"",confidence:0,strategy:"",status:"generating"}}));N(f);try{y.debug("[useBatchGenerateFixes] Generating fixes for",A.length,"issues");let k=null;try{let R=ra();R?.computed&&(k=R.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(R){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",R)}let E=null;try{E=await aa(I),E&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",E)}catch(R){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",R)}let x=await fetch(`${RN}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`,...ac(S)},body:JSON.stringify({projectId:b,storyId:I,workspacePath:v,includeComponentIssues:$,computedStyles:k,storyFilePaths:E,reviewContext:{storyName:F||void 0,variantArgs:$i()||void 0},issues:A.map(R=>({id:R.id,dbId:R.dbId,title:R.title,description:R.description,property:R.property,currentValue:R.currentValue,suggestedValue:R.suggestedValue,file:R.file,lineNumber:R.lineNumber,severity:R.severity,type:R.type,fixTarget:R.fixTarget,domElement:R.domElement,figmaContext:R.figmaContext,suggestedFix:R.suggestedFix}))})});if(!x.ok){let R=await x.json().catch(()=>({}));throw new Error(R.error||"Batch fix generation failed")}let T=await x.json();if(!T.success)throw new Error(T.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",T.result.fixes.length,"fixes"),T.result.storybookRoot&&(p(T.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",T.result.storybookRoot)),T.result.selfReview&&(d(T.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",T.result.selfReview)),T.result.partialFailure){let{failedBatches:R,errors:H}=T.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${R.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",H),r(`Some fixes couldn't be generated (${R.join(", ")}): ${H[0]||"Unknown error"}`)}a({total:A.length,completed:T.result.fixes.length});let P=new Set(T.result.fixes.map(R=>R.issueId)),B=A.filter(R=>!P.has(R.id));B.length>0&&(y.warn(`[useBatchGenerateFixes] ${B.length} issues not returned by API, marking as failed`),B.forEach(R=>{D(R.id,{code:"",diffPreview:"",filePath:R.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),T.timing&&(i({durationSec:T.timing.durationSec,issueCount:T.timing.issueCount,avgPerIssueSec:T.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${T.timing.durationSec}s for ${T.timing.issueCount} issues`)),T.result?.usage&&(c({inputTokens:T.result.usage.inputTokens||0,outputTokens:T.result.usage.outputTokens||0,costUsd:T.result.usage.costUsd||0,modelId:T.result.usage.modelId||"unknown",provider:T.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${T.result.usage.inputTokens} in, ${T.result.usage.outputTokens} out, $${T.result.usage.costUsd?.toFixed(4)}`));let _=[],C=[];if(T.result.fixes.forEach(R=>{let H=R.noChangesNeeded===!0;if(!H){let K=(R.fixStrategy||"").toLowerCase(),se=(R.generatedCode||"").toLowerCase(),me=(R.diffPreview||"").toLowerCase(),Pe=BN.some(re=>K.includes(re.toLowerCase())||K.replace(/[-_]/g,"").includes(re.replace(/[-_]/g,""))),Ge=DN.some(re=>se.includes(re)||me.includes(re));H=Pe||Ge}let L=A.find(K=>K.id===R.issueId);if(H&&L){let K=L.suggestedValue,se=L.currentValue;K&&se&&!oi(K,se)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${K}", actual="${se}"), NOT auto-dismissing issue ${R.issueId}`),H=!1)}let ie=L?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${R.issueId}:`,{isFalsePositive:H,isProgrammaticIssue:ie,detectedBy:L?.detectedBy,noChangesNeeded:R.noChangesNeeded,fixStrategy:R.fixStrategy,title:L?.title?.substring(0,50)}),ie&&H&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${R.issueId} (detectedBy: ${L?.detectedBy})`),H=!1),H){let K=`Auto-dismissed: ${R.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${R.issueId} - noChangesNeeded: ${R.noChangesNeeded}, strategy: "${R.fixStrategy}"`),M(R.issueId,K),_.push({localId:R.issueId,dbId:L?.dbId,dismissReason:K}),C.push({issueId:R.issueId,generatedFix:{code:R.generatedCode||"",diffPreview:R.diffPreview||"",filePath:R.filePath,confidence:R.confidence,strategy:R.fixStrategy,status:"ready",error:void 0,noChangesExplanation:R.noChangesExplanation}})}else{let K=R.error||R.fixStrategy==="skipped"?"failed":"ready";C.push({issueId:R.issueId,generatedFix:{code:R.generatedCode,diffPreview:R.diffPreview,filePath:R.filePath,confidence:R.confidence,strategy:R.fixStrategy,status:K,error:R.error,noChangesExplanation:R.noChangesExplanation}})}}),C.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${C.length} fix updates in batch`),N(C)),_.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${_.length} false positive(s), recalculating score`),z(),h){let H=_.filter(L=>L.dbId).map(L=>({dbId:L.dbId,dismissed:!0,dismissReason:L.dismissReason,dismissedBy:"system"}));H.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${H.length} dismissals to server`),dk(H,h).then(L=>{L.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${L.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",L.error)}).catch(L=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",L)}))}let R=_.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${_.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;m({role:"system",content:R})}y.debug("[useBatchGenerateFixes] Updated",T.result.fixes.length,"issues with fixes")}catch(k){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",k),r(k?.message||"Failed to generate batch fixes");let E=A.map(x=>({issueId:x.id,generatedFix:{code:"",diffPreview:"",filePath:x.file||"",confidence:0,strategy:"",status:"failed",error:k?.message||"Failed to generate fix"}}));N(E)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}ve();Ne();$e();lt();import{useState as Rm,useCallback as zm}from"react";var zN=Y();function Nm(){let[e,t]=Rm([]),[n,r]=Rm(!1),[o,i]=Rm(null),{sessionToken:s}=Se(),{selectedProjectId:a}=Xe(),{currentStoryId:u}=Ze(),{setReviewResults:c}=ue(),l=zm(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let h=await oe(`${zN}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!h.ok){let I=await h.json().catch(()=>({}));throw new Error(I.error||"Failed to fetch reviews")}let b=await h.json();if(!b.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",b.reviews.length,"reviews for:",u),t(b.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=zm(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let h=[];if(typeof p.models=="string")try{h=JSON.parse(p.models)}catch(v){y.error("[useReviewHistory] Failed to parse models:",v),h=["claude-sonnet-4-20250514"]}else h=p.models;let b=p.issues.map(v=>({id:v.id,reviewId:p.id,type:v.type,severity:v.severity,title:v.description,description:v.description,file:void 0,lineNumber:void 0,property:v.property,currentValue:v.actual,suggestedValue:v.expected,suggestedCode:v.suggestedFix||void 0,status:v.status,dismissed:v.dismissed||!1,dismissReason:v.dismissReason,dismissedBy:v.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(v.createdAt)})),I=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:h[0]||"claude-sonnet-4-6",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:b,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:I}),F){let v=p.issues.filter(M=>!M.dismissed),D=v.filter(M=>M.severity==="critical").length,N=v.filter(M=>M.severity==="major").length,$=v.filter(M=>M.severity==="minor").length;jr(F,{score:p.complianceScore,issueCount:v.length,criticalCount:D,majorCount:N,minorCount:$})}},[c]),g=zm(p=>{let h=e.find(b=>b.id===p);if(!h){y.error("[useReviewHistory] Review not found:",p);return}d(h)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}ve();Ne();import{useEffect as NN,useState as ON,useRef as mc}from"react";import{useChannel as _N}from"storybook/manager-api";var $N="UICOPILOT/WORKSPACE_PATH",gk="UICOPILOT/REQUEST_WORKSPACE_PATH",UN=3e3,jN=500,HN=5,Om=()=>{let[e,t]=ON({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ue(),r=mc(!1),o=mc(null),i=mc(0),s=mc(null),a=_N({[$N]:({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 NN(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(gk,{}),s.current=setInterval(()=>{!r.current&&i.current<HN&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(gk,{}))},jN),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}))}},UN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},_m=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();$e();import{useEffect as WN,useRef as VN}from"react";var jZ=Y(),GN=new Set;function $m(){let{sessionToken:e}=Se(),{selectedProjectId:t}=Xe(),n=VN(!1);WN(()=>{t&&GN.add(t)},[e,t])}ve();ln();import{useCallback as VZ,useState as GZ}from"react";import{useState as ci,useMemo as Ck,useCallback as Yi}from"react";$e();Ne();lt();ln();import{useState as po,useEffect as hc,useRef as Gi,useCallback as Um}from"react";var qN=300;function fk({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=po([]),[u,c]=po({}),[l,d]=po(0),[g,p]=po([]),[h,b]=po(new Set),[I,F]=po(!1),[v,D]=po(!1),[N,$]=po(null),M=Gi(1),z=Gi(null),m=Gi(null),[S,w]=po(0),A=Gi(!1),f=Gi({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});f.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let k=Um(async(B,_,C=!1)=>{let{projectId:R,typeFilter:H,search:L,figmaPage:ie,limit:K}=f.current;if(!R||!H)return;z.current&&z.current.abort();let se=new AbortController;z.current=se,_?D(!0):F(!0),$(null);try{let me=Y(),Pe=localStorage.getItem("uicopilot_session_token");if(!Pe)throw new Error(`Not authenticated. Please connect to ${Et.NAME} first.`);let Ge=new URLSearchParams({projectId:R,page:String(B),limit:String(K)});H&&Ge.append("type",H),ie&&Ge.append("figmaPage",ie),L.trim()&&Ge.append("search",L.trim()),C&&Ge.append("refresh","true");let re=await fetch(`${me}/api/figma/frames?${Ge.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Pe}`},signal:se.signal});if(!re.ok){let ge=await re.json();throw new Error(ge.error||"Failed to fetch frames")}let Te=await re.json(),it=Te.frames||[],ne=Te.thumbnails||{},Be=re.headers.get("X-Cache-Status");if(it.length===0&&B===1&&!_&&!C&&!A.current&&Be!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),A.current=!0,await k(1,!1,!0);return}_?(a(ge=>[...ge,...it]),c(ge=>({...ge,...ne}))):(a(it),c(ne)),d(Te.total||it.length),Te.pages&&p(Te.pages),Te.cacheDiff?.added&&b(new Set(Te.cacheDiff.added)),M.current=B}catch(me){if(me instanceof DOMException&&me.name==="AbortError")return;let Pe=me instanceof Error?me.message:"Failed to fetch Figma frames.";$(Pe),y.error("Error fetching frames:",me)}finally{se.signal.aborted||(F(!1),D(!1))}},[]);hc(()=>{if(!i||!e||!t)return;A.current=!1,m.current&&clearTimeout(m.current);let B=n.trim()?qN:0;return m.current=setTimeout(()=>{M.current=1,k(1,!1)},B),()=>{m.current&&clearTimeout(m.current)}},[e,t,n,r,i,S,k]);let E=Gi(new Set);hc(()=>{if(s.length===0)return;let B={};for(let _ of s)_.thumbnailCdnUrl&&!u[_.id]&&(B[_.id]=_.thumbnailCdnUrl);Object.keys(B).length>0&&c(_=>({..._,...B}))},[s]),hc(()=>{if(s.length===0)return;let B=s.filter(C=>!C.thumbnailCdnUrl&&!u[C.id]&&!E.current.has(C.id)).map(C=>C.id);if(B.length===0)return;B.forEach(C=>E.current.add(C)),(async()=>{try{let{projectId:C}=f.current,R=Y(),H=localStorage.getItem("uicopilot_session_token");if(!H||!C)return;let L=await oe(`${R}/api/figma/frames?projectId=${C}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`}},6e4);if(L.ok){let ie=await L.json();ie.thumbnails&&Object.keys(ie.thumbnails).length>0&&c(K=>({...K,...ie.thumbnails}))}}catch(C){B.forEach(R=>E.current.delete(R)),y.error("Failed to fetch frame thumbnails:",C)}})()},[s,u]),hc(()=>()=>{z.current&&z.current.abort(),m.current&&clearTimeout(m.current)},[]);let x=Um(async()=>{let B=M.current+1;await k(B,!0)},[k]),T=Um(()=>{A.current=!1,M.current=1,a([]),c({}),w(B=>B+1)},[]),P=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:h,isLoading:I,loadingMore:v,hasMore:P,loadMore:x,refresh:T,error:N}}$e();Ne();lt();import{useState as qi,useCallback as xc,useRef as YN}from"react";function mk({projectId:e}){let[t,n]=qi({}),[r,o]=qi({}),[i,s]=qi(new Set),[a,u]=qi(new Set),[c,l]=qi({}),[d,g]=qi(null),p=YN({}),h=xc(async v=>{if(!(!e||i.has(v))){s(D=>new Set(D).add(v));try{let D=Y(),N=localStorage.getItem("uicopilot_session_token"),$=await oe(`${D}/api/figma/variants?projectId=${e}&componentSetId=${v}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`}});if($.ok){let M=await $.json();if(M.variants){n(m=>({...m,[v]:M.variants}));let z={};for(let m of M.variants)m.thumbnailCdnUrl&&(z[m.id]=m.thumbnailCdnUrl);o(m=>({...m,[v]:{...m[v]||{},...z}})),p.current[v]||(p.current[v]=new Set),Object.keys(z).forEach(m=>p.current[v].add(m))}else o(z=>({...z,[v]:z[v]||{}}))}else o(M=>({...M,[v]:{}}))}catch(D){y.error("Failed to fetch variant metadata:",D),o(N=>({...N,[v]:{}}))}finally{s(D=>{let N=new Set(D);return N.delete(v),N})}}},[e,i]),b=xc(async(v,D)=>{if(!e||D.length===0)return;p.current[v]||(p.current[v]=new Set);let N=r[v]||{},$=D.filter(M=>!p.current[v].has(M)&&!N[M]);if($.length!==0){$.forEach(M=>p.current[v].add(M)),u(M=>new Set(M).add(v));try{let M=Y(),z=localStorage.getItem("uicopilot_session_token"),m=await oe(`${M}/api/figma/variants?projectId=${e}&componentSetId=${v}&thumbnailIds=${$.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`}});if(m.ok){let S=await m.json();S.rateLimitError?(g(S.rateLimitError),$.forEach(w=>p.current[v]?.delete(w))):(S.thumbnails&&Object.keys(S.thumbnails).length>0&&o(w=>({...w,[v]:{...w[v]||{},...S.thumbnails}})),Array.isArray(S.failed)&&S.failed.length>0&&l(w=>{let A=new Set(w[v]||[]);for(let f of S.failed)A.add(f);return{...w,[v]:A}}))}}catch(M){y.error("Failed to fetch variant thumbnails:",M),$.forEach(z=>p.current[v]?.delete(z))}finally{u(M=>{let z=new Set(M);return z.delete(v),z})}}},[e]),I=xc(v=>{o(D=>{let N={...D};return delete N[v],N}),n(D=>{let N={...D};return delete N[v],N}),l(D=>{let N={...D};return delete N[v],N}),delete p.current[v]},[]),F=xc(()=>{o({}),n({}),l({}),p.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,rateLimitError:d,fetchVariants:h,fetchVariantThumbnails:b,clearVariantsForSet:I,clearAllVariants:F}}$e();Ui();ve();Ne();lt();import{useState as hk,useEffect as xk,useRef as yk,useCallback as jm}from"react";function bk({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=hk(null),[i,s]=hk(!1),a=yk(null),u=yk(new Set),c=jm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=$i();if(!g||Object.keys(g).length===0)return;let p=yt.getState().currentStoryId||"",h=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase());a.current=e,s(!0),o(null);try{let b=Y(),I=localStorage.getItem("uicopilot_session_token"),F=await oe(`${b}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({storyName:h,storyId:p,storyArgs:g,availableFilters:t.map(v=>({property:v.property,values:v.values}))})});if(F.ok){let v=await F.json();v.confidence>0&&Object.keys(v.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",v),o(v))}else F.status===404?y.debug("[useFilterSuggestion] match-filters endpoint not available (404), skipping suggestions"):y.error("[useFilterSuggestion] Unexpected status:",F.status)}catch(b){y.error("[useFilterSuggestion] Error:",b)}finally{s(!1)}},[e,t,n]);xk(()=>{c()},[c]),xk(()=>{e||(o(null),a.current=null)},[e]);let l=jm(()=>{},[]),d=jm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function Sk(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function wk(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 vk(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 kk(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 ca({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=ci(!0),[i,s]=ci(!1),[a,u]=ci(!1),[c,l]=ci(""),[d,g]=ci(""),[p,h]=ci([]),[b,I]=ci(new Set),F=Yi(ne=>{l(ne),p.length>0&&h([]),b.size>0&&I(new Set)},[p.length,b.size]),v=Sk(r,i,a),{frames:D,thumbnails:N,totalFrames:$,availablePages:M,recentlyAdded:z,isLoading:m,loadingMore:S,hasMore:w,loadMore:A,refresh:f,error:k}=fk({projectId:e,typeFilter:v,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!v}),{variantChildren:E,variantThumbnails:x,variantFailed:T,loadingVariants:P,loadingThumbnails:B,rateLimitError:_,fetchVariants:C,fetchVariantThumbnails:R,clearVariantsForSet:H,clearAllVariants:L}=mk({projectId:e}),ie=Ck(()=>{let ne=wk(E),Be=vk(D),ge={};for(let dt of[...ne,...Be])ge[dt.property]||(ge[dt.property]=new Set),dt.values.forEach(ot=>ge[dt.property].add(ot));return Object.entries(ge).map(([dt,ot])=>({property:dt,values:Array.from(ot).sort()}))},[E,D]),K=b.size===1?Array.from(b)[0]:null,se=bk({expandedSetId:K,availableFilters:ie,filtersReady:ie.length>0}),me=Yi(()=>{if(!se.suggestion)return;let{suggestedFilters:ne}=se.suggestion,Be=Object.entries(ne).map(([ge,dt])=>({property:ge,value:dt}));h(Be),se.dismissSuggestion()},[se.suggestion]),Pe=Ck(()=>p.some(ne=>ne.value)?D.filter(ne=>kk(ne,p,E[ne.id])):D,[D,p,E]),Ge=Yi((ne,Be)=>{Be.stopPropagation();let ge=!b.has(ne);I(dt=>{let ot=new Set(dt);return ot.has(ne)?ot.delete(ne):ot.add(ne),ot}),ge&&!E[ne]&&!P.has(ne)?C(ne):ge||H(ne)},[b,E,P,C,H]),re=Yi((ne,Be)=>{let ge=Be===""?null:Be;h(dt=>dt.find(bn=>bn.property===ne)?dt.map(bn=>bn.property===ne?{...bn,value:ge}:bn):[...dt,{property:ne,value:ge}])},[]),Te=Yi(()=>{h([])},[]),it=Yi(ne=>{let Be=D.find(ge=>ge.id===ne);if(Be?.thumbnailCdnUrl)return Be.thumbnailCdnUrl;if(N[ne])return N[ne];for(let ge of Object.values(x))if(ge[ne])return ge[ne]},[N,x]);return{frames:D,filteredFrames:Pe,thumbnails:N,totalFrames:$,isLoading:m,loadingMore:S,hasMore:w,error:k,loadMore:A,refresh:f,search:c,setSearch:F,figmaPage:d,setFigmaPage:g,availablePages:M,recentlyAdded:z,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:ie,handleFilterChange:re,clearFilters:Te,expandedSets:b,toggleExpanded:Ge,variantChildren:E,variantThumbnails:x,variantFailed:T,loadingVariants:P,loadingThumbnails:B,rateLimitError:_,fetchVariantThumbnails:R,resolveThumbnail:it,filterSuggestion:se.suggestion,filterSuggestionLoading:se.isLoading,applySuggestedFilters:me,dismissFilterSuggestion:se.dismissSuggestion}}ve();import{useEffect as Lr,useCallback as ZN,useState as eO,useRef as tO}from"react";import{useChannel as nO}from"storybook/manager-api";function zo(e){return e.status===401||e.status===403}var Mn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};ln();function Tk(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 Ou.error("Error parsing Figma URL:",t),null}}Ne();$e();$e();lt();var KN=Y();async function Hm(e){let t=await oe(`${KN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(zo(t))throw new Mn(t.status);return t.ok?(await t.json()).projects||[]:[]}$e();lt();var XN=Y();async function Wm(e,t){let n=await oe(`${XN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(zo(n))throw new Mn(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}$e();lt();var QN=Y();async function Vm(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(`${QN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(zo(s))throw new Mn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}$e();lt();var JN=Y();async function Gm(e,t){let n=await oe(`${JN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(zo(n))throw new Mn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Ui();function rO(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 oO=Y(),iO="UICOPILOT/WORKSPACE_PATH",sO="UICOPILOT/REQUEST_WORKSPACE_PATH",qm=!1;function Ym(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=Se(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Xe(),{currentStoryId:l,mappingsRefreshKey:d,mappingsByStoryId:g,setFigmaFileUrl:p,setCurrentMapping:h,setMappingsByStoryId:b,setMappingSource:I,setLoadingMapping:F}=Ze(),{setReviewResults:v,setReviewDetailTab:D,setStorybookImageUrl:N,setFigmaImageUrl:$,setFullPrompt:M,setFullResponse:z,bulkAddReviews:m,setReviewHistoryLoading:S}=ue(),[w,A]=eO([]),f=tO(null);Lr(()=>{let x=T=>{T.origin.startsWith(oO)&&T.data?.type==="UICOPILOT_AUTH_SUCCESS"&&T.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(T.data.token))};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[t]);let k=nO({[iO]:x=>{y.debug("[useDataInit] Received workspace path:",x.path),c(x.path)}});Lr(()=>{k(sO)},[k]),Lr(()=>{if(!e)return;let x=!1;return(async()=>{try{u(!0);let P=await Hm(e);x||(s(P),n(null))}catch(P){P instanceof Mn&&(t(null),n(P.message)),y.error("[useDataInit] Failed to fetch projects:",P)}finally{x||u(!1)}})(),()=>{x=!0}},[e,s,u]),Lr(()=>{if(!i||r.length===0)return;let x=r.find(T=>T.storybookRoot===i);x?o!==x.id&&(y.debug("[useDataInit] Auto-selecting project:",x.name),a(x.id)):o&&(y.debug("[useDataInit] No project matches this Storybook \u2014 clearing selection"),a(null))},[i,r,o,a]),Lr(()=>{if(!o||r.length===0)return;let x=r.find(P=>P.id===o),T=x?.figmaFileId;if(x&&typeof T=="string"&&T){let P=T,B=P.includes("figma.com")&&Tk(P)?.fileKey||P;p(`https://www.figma.com/file/${B}`)}},[o,r,p]),Lr(()=>!e||!o||qm?void 0:(qm=!0,(async()=>{try{let T=await Gm(e,o);for(let[P,B]of Object.entries(T))jr(P,{score:B.score,issueCount:B.issueCount,criticalCount:B.criticalCount,majorCount:B.majorCount,minorCount:B.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(T).length,"stories")}catch(T){T instanceof Mn&&(t(null),n(T.message)),y.error("[useDataInit] Failed to fetch review statuses:",T)}})(),()=>{qm=!1}),[e,o]),Lr(()=>{if(!e||!o)return;let x=!1;return(async()=>{try{let P=await Wm(e,o);if(x)return;let B={};for(let _ of P)_.storyId&&(B[_.storyId]=_);b(B),nk(Object.keys(B))}catch(P){P instanceof Mn&&(t(null),n(P.message)),y.error("[useDataInit] Failed to fetch all mappings:",P)}})(),()=>{x=!0}},[e,o,d,b]),Lr(()=>{if(!l){h(null),I(null);return}let x=g[l]||null;x?(h(x),I("database")):(h(null),I(null)),F(!1)},[l,g,h,I,F]),Lr(()=>{A([]),f.current=null},[l]),Lr(()=>{if(!e||!o||!l)return;let x=!1;return(async()=>{S(!0);try{let P=await Vm(e,o,l,10,!0);if(!x){A(P);let B=P.map(_=>rO(_)).filter(Boolean);B.length>0&&m(B)}}catch(P){P instanceof Mn&&(t(null),n(P.message)),y.error("[useDataInit] Failed to fetch reviews:",P)}finally{x||S(!1)}})(),()=>{x=!0}},[e,o,l,S,m]);let E=ZN(x=>{y.debug("[useDataInit] Applying review:",x.id,"with",x.issues.length,"issues");let T=[];if(typeof x.models=="string")try{T=JSON.parse(x.models)}catch{T=["claude-sonnet-4-20250514"]}else T=x.models;let P=x.issues.map(R=>({id:R.id,reviewId:x.id,type:R.type,severity:R.severity,title:R.description,description:R.description,file:void 0,lineNumber:void 0,property:R.property,currentValue:R.actual,suggestedValue:R.expected,suggestedCode:R.suggestedFix||void 0,status:R.status,dismissed:R.dismissed||!1,dismissReason:R.dismissReason,dismissedBy:R.dismissedBy,figmaContext:R.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(R.createdAt)})),B=x.completedAt&&x.createdAt?new Date(x.completedAt).getTime()-new Date(x.createdAt).getTime():void 0,_=x.storyId||"";v({id:x.id,componentId:"",storyId:_,modelId:T[0]||"claude-sonnet-4-5-20250929",complianceScore:x.complianceScore,issuesCount:x.issuesCount,issues:P,createdAt:new Date(x.createdAt),timestamp:new Date(x.createdAt).toISOString(),costUsd:x.costUsd,inputTokens:x.inputTokens,outputTokens:x.outputTokens,reviewDurationMs:B});let C=yt.getState().currentStoryId;if(_&&_===C&&(x.storybookScreenshot&&(N(x.storybookScreenshot),dv(_,x.storybookScreenshot,x.figmaScreenshot??void 0),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),x.figmaScreenshot&&($(x.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot"))),x.aiPrompt&&(M(x.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),x.aiResponse&&(z(x.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),_){let R=x.issues.filter(K=>!K.dismissed),H=R.filter(K=>K.severity==="critical").length,L=R.filter(K=>K.severity==="major").length,ie=R.filter(K=>K.severity==="minor").length;jr(_,{score:x.complianceScore,issueCount:R.length,criticalCount:H,majorCount:L,minorCount:ie})}},[v,N,$,M,z]);Lr(()=>{if(w.length>0&&l&&f.current!==l){let x=w[0];x&&x.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",x.id,"for:",l),f.current=l,E(x),D("issues"))}},[w,l,E,D])}ln();import{styled as ua}from"storybook/theming";var aO=ua.div({display:"flex",gap:"10px",marginTop:"8px"}),Ik=ua.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),Fk=ua.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"})),Ek=ua.div({display:"flex",alignItems:"center",gap:"8px"}),Ak=ua(An)(({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"})),Pk=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,saveApiKey:u}=Js(),[c,l]=et.useState(""),d=()=>{let g=c.trim();g&&(u(g),e?.())};return et.createElement(et.Fragment,null,et.createElement(vo,null,et.createElement(ko,null,"Authentication Method"),et.createElement(aO,null,et.createElement(Ik,null,et.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),et.createElement(Ik,null,et.createElement("input",{type:"radio",name:"authMethod",checked:n==="apikey",onChange:()=>r("apikey")}),"API Key"))),n==="oauth"&&et.createElement(vo,null,et.createElement(ko,null,"Connect to ",Et.NAME),t?et.createElement(Fk,null,et.createElement(Ek,null,et.createElement("span",{style:{fontSize:"18px"}},"\u2713"),et.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Et.NAME)),et.createElement(Ak,{onClick:i,title:"Sign out and switch to a different account"},"Sign out")):s?et.createElement("div",{style:{padding:"20px 0",textAlign:"center",fontSize:"13px"}},et.createElement("div",{style:{fontSize:"24px",marginBottom:"8px"}},"\u{1F510}"),et.createElement(bs,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),et.createElement(bs,{style:{color:"inherit",opacity:.7}},"Complete sign-in in the popup, then return here.")):et.createElement("div",null,a&&et.createElement("div",{style:{marginBottom:"12px",padding:"10px 12px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#b91c1c"}},"\u26A0\uFE0F ",a),et.createElement(bs,{style:{marginBottom:"12px"}},"Connect to ",Et.NAME," to manage projects and integrations."),et.createElement(An,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Et.NAME))),n==="apikey"&&et.createElement(vo,null,et.createElement(ko,null,"Session Token"),t?et.createElement(Fk,null,et.createElement(Ek,null,et.createElement("span",{style:{fontSize:"18px"}},"\u2713"),et.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Et.NAME)),et.createElement(Ak,{onClick:i,title:"Sign out and switch to a different account"},"Sign out")):et.createElement(et.Fragment,null,et.createElement(bs,{style:{marginBottom:"12px"}},"Paste the session token from your ",Et.NAME," setup page."),et.createElement(ys,{type:"password",placeholder:"Paste session token",value:c,onChange:g=>l(g.target.value)}),et.createElement(An,{disabled:!c.trim(),style:{marginTop:"12px"},onClick:d},"Save Token"))))};import ct,{useState as Ki}from"react";ve();import Wn,{useState as lO,useEffect as cO,useCallback as uO}from"react";import{styled as go,keyframes as Lk}from"storybook/theming";var pO=Lk({from:{opacity:0},to:{opacity:1}}),dO=Lk({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),gO=go.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${pO} 150ms ease-out`}),fO=go.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:`${dO} 150ms ease-out`})),mO=go.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),hO=go.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})),xO=go.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),yO=go.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.6}px ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.background.app,color:e.color.defaultText,marginBottom:`${e.layoutMargin}px`,boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary}})),bO=go.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.6}px`,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.mediumdark})),SO=go.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}})),wO=go.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:not(:disabled)":{opacity:.9},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),Hr=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",confirmText:s,onConfirm:a,onCancel:u})=>{let[c,l]=lO(""),d=!!s&&c!==s,g=uO(p=>{p.key==="Escape"&&u()},[u]);return cO(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?Wn.createElement(Wn.Fragment,null,Wn.createElement(gO,{onClick:u}),Wn.createElement(fO,{role:"dialog","aria-modal":"true","aria-label":t},Wn.createElement(mO,null,t),Wn.createElement(hO,null,n),s&&Wn.createElement(Wn.Fragment,null,Wn.createElement(bO,null,"Type ",Wn.createElement("strong",null,s)," to confirm:"),Wn.createElement(yO,{type:"text",value:c,onChange:p=>l(p.target.value),placeholder:s,autoFocus:!0})),Wn.createElement(xO,null,Wn.createElement(SO,{onClick:u},o),Wn.createElement(wO,{variant:i,onClick:a,disabled:d},r)))):null};import{styled as un}from"storybook/theming";function vO(e,t,n){return e.filter(r=>r.id===t||!r.storybookRoot?!0:n?r.storybookRoot===n:!1)}var kO=un.div({marginBottom:"30px"}),CO=un.div({display:"flex",gap:"8px",alignItems:"center"}),TO=un(Sn)({flex:1}),IO=un(on)({padding:"8px 12px",whiteSpace:"nowrap"}),FO=un.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),EO=un.div(({theme:e})=>({marginTop:"6px",padding:"8px 10px",fontSize:"11px",lineHeight:1.4,color:e.color.warning,backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}40`,borderRadius:"4px"})),AO=un.div(({theme:e})=>({marginBottom:"10px",padding:"8px 10px",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",backgroundColor:e.background.content})),PO=un.div(({theme:e})=>({fontSize:"11px",lineHeight:1.5,color:e.color.mediumdark,marginBottom:"6px"})),LO=un.div({display:"flex",alignItems:"center",gap:"6px"}),MO=un.a(({theme:e})=>({flex:1,fontSize:"11px",fontFamily:e.typography.fonts.mono,color:e.color.secondary,textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","&:hover":{textDecoration:"underline"}})),BO=un.button(({theme:e})=>({fontSize:"11px",padding:"3px 8px",borderRadius:"3px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.hoverable,color:e.color.defaultText,cursor:"pointer",whiteSpace:"nowrap","&:hover":{backgroundColor:e.background.app}}));function Mk(e){return/figma\.com\/community\/file\//.test(e)}var Km=un.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Xm=un.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Qm=un(ys)({fontSize:"13px",padding:"6px 8px"}),DO=un.div({display:"flex",gap:"8px",marginTop:"12px"}),Bk=un(on)({fontSize:"12px",padding:"6px 12px"}),RO=un(Bk)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),zO=un.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.size.s1,transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),Dk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=co(),{currentStorybookPath:s}=Xe(),[a,u]=Ki(!1),[c,l]=Ki(!1),[d,g]=Ki(!1),[p,h]=Ki(!1),[b,I]=Ki({name:"",storybookRoot:"",figmaFileUrl:""}),F=e.find(f=>f.id===t),v=vO(e,t,s),D=f=>{n(f||null),u(!1)},N=async()=>{if(t)try{h(!0),await i(t),g(!1)}catch(f){console.error("Failed to delete project:",f)}finally{h(!1)}},$=process.env.STORYBOOK_UICOPILOT_FIGMA_KIT||"",[M,z]=Ki(!1),m=()=>{$&&navigator.clipboard.writeText($).then(()=>{z(!0),setTimeout(()=>z(!1),2e3)})},S=()=>{if(u(!0),s){let f=s.replace(/\/+$/,"").split("/").pop()||"";I({storybookRoot:s,name:f,figmaFileUrl:""})}},w=async()=>{if(b.name.trim())try{l(!0);let f;if(b.figmaFileUrl.trim()){let E=b.figmaFileUrl.trim(),x=E.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);f=x?x[1]:E}let k=await o({name:b.name.trim(),storybookRoot:b.storybookRoot.trim()||void 0,figmaFileId:f});n(k.id),u(!1),I({name:"",storybookRoot:"",figmaFileUrl:""})}catch(f){console.error("Failed to create project:",f)}finally{l(!1)}},A=f=>{I(k=>{let E={...k,storybookRoot:f};if(!k.name&&f){let x=f.replace(/\/+$/,"").split("/").pop()||"";E.name=x}return E})};return ct.createElement(kO,null,ct.createElement(Cy,null,"Project"),ct.createElement(CO,null,ct.createElement(TO,{value:t||"",onChange:f=>D(f.target.value),disabled:r||a},ct.createElement("option",{value:""},"-- Select a project --"),v.map(f=>ct.createElement("option",{key:f.id,value:f.id},f.name))),ct.createElement(IO,{onClick:S,disabled:r,type:"button"},"+ New"),ct.createElement(zO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),ct.createElement(Hr,{isOpen:d,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${F?.name||"this project"}". This cannot be undone.`,confirmLabel:p?"Deleting...":"Delete",confirmText:F?.name,variant:"danger",onConfirm:N,onCancel:()=>g(!1)}),a&&ct.createElement(FO,null,ct.createElement(Km,null,ct.createElement(Xm,null,"Storybook Path (for fix generation)"),ct.createElement(Qm,{type:"text",placeholder:"/path/to/your/storybook",value:b.storybookRoot,onChange:f=>A(f.target.value)})),ct.createElement(Km,null,ct.createElement(Xm,null,"Project Name *"),ct.createElement(Qm,{type:"text",placeholder:"my-storybook",value:b.name,onChange:f=>{let k=f.target.value;I(E=>({...E,name:k}))}})),$&&ct.createElement(AO,null,ct.createElement(PO,null,ct.createElement("strong",null,"1.")," Open this template's Figma kit, then click"," ",ct.createElement("strong",null,"Open in Figma")," (or ",ct.createElement("strong",null,"Get a copy"),") to duplicate it to your own Figma workspace. ",ct.createElement("strong",null,"2.")," ","Paste the URL of your copy (",ct.createElement("code",null,"figma.com/design/\u2026"),") into the field below."),ct.createElement(LO,null,ct.createElement(MO,{href:$,target:"_blank",rel:"noopener noreferrer",title:$},$),ct.createElement(BO,{type:"button",onClick:m},M?"Copied!":"Copy"))),ct.createElement(Km,null,ct.createElement(Xm,null,"Your Figma File URL (after duplicating)"),ct.createElement(Qm,{type:"text",placeholder:"https://www.figma.com/design/...",value:b.figmaFileUrl,onChange:f=>{let k=f.target.value;I(E=>({...E,figmaFileUrl:k}))}}),Mk(b.figmaFileUrl)&&ct.createElement(EO,null,"\u26A0 This is a community file URL \u2014 it can't be read by the API. Use the duplicated copy's URL instead (see instructions above).")),ct.createElement(DO,null,ct.createElement(Bk,{onClick:w,disabled:c||!b.name.trim()||!b.figmaFileUrl.trim()||Mk(b.figmaFileUrl)},c?"Creating...":"Create"),ct.createElement(RO,{onClick:()=>{u(!1),I({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import xt,{useState as ba,useCallback as d1,useEffect as K4}from"react";import{styled as Br}from"storybook/theming";import tn,{useState as Xi,useEffect as t_,useCallback as yc}from"react";import{styled as Wr}from"storybook/theming";ve();$e();lt();ve();$e();lt();import Vt,{useState as Jm}from"react";import{styled as Vn,keyframes as NO}from"storybook/theming";var OO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},_O=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",$O=Vn.div({position:"relative",display:"inline-flex"}),UO=NO`
31
31
  0% { transform: rotate(0deg); }
32
32
  100% { transform: rotate(360deg); }
33
- `,jO=Wn.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}}}),HO=Wn.span`
33
+ `,jO=Vn.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}}}),HO=Vn.span`
34
34
  display: inline-block;
35
35
  width: 10px;
36
36
  height: 10px;
@@ -38,10 +38,10 @@ ${st}`).join(`
38
38
  border-top-color: #fff;
39
39
  border-radius: 50%;
40
40
  animation: ${UO} 0.8s linear infinite;
41
- `,WO=Wn.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})),VO=Wn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),GO=Wn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),qO=Wn.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()}}),YO=Wn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),KO=Wn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),XO=Wn.span({display:"flex",alignItems:"center",gap:"4px"}),QO=Wn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),JO=Wn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),ZO=Wn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),e_=Wn.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"}})),Rk=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Xe(),[n,r]=Jm(!1),[o,i]=Jm(!1),[s,a]=Jm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=Y(),l=localStorage.getItem("uicopilot_session_token"),d=await re(`${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 g=await d.json();a(g),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Vt.createElement($O,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Vt.createElement(jO,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Vt.createElement(Vt.Fragment,null,Vt.createElement(HO,null)," Checking..."):s?Vt.createElement(Vt.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Vt.createElement(Vt.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Vt.createElement(WO,null,Vt.createElement(VO,null,Vt.createElement(GO,null,"Figma Design Quality"),Vt.createElement(qO,{score:s.score},Math.round(s.score),"%")),Vt.createElement(YO,null,Object.entries(s.categories).map(([c,l])=>Vt.createElement(KO,{key:c},Vt.createElement(XO,null,Vt.createElement(QO,{status:l.status},_O(l.status)),OO[c]||c),Vt.createElement(JO,null,l.score)))),s.summary&&Vt.createElement(ZO,null,s.summary),s.recommendations?.length>0&&Vt.createElement(e_,null,s.recommendations.slice(0,2).map((c,l)=>Vt.createElement("li",{key:l},c))))):null};var n_=Wr.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),r_=Wr.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),o_=Wr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),i_=Wr.div({display:"flex",gap:"8px",alignItems:"center"}),s_=Wr.div({position:"relative",flex:1,display:"flex"}),a_=Wr.input(({theme:e})=>({width:"100%",padding:"8px 36px 8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:ce,boxShadow:`0 0 0 1px ${ce}`},"&::placeholder":{color:e.color.mediumlight}})),l_=Wr(on)({whiteSpace:"nowrap"}),c_=Wr.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"12px",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),u_=Wr.button(({theme:e,copied:t})=>({position:"absolute",top:"50%",right:"5px",transform:"translateY(-50%)",width:"26px",height:"26px",padding:0,border:"none",borderRadius:"5px",background:"transparent",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:t?e.color.positive:e.color.defaultText,transition:"color 0.15s, background 0.15s","&:hover":{color:t?e.color.positive:ce,background:e.background.hoverable}})),p_=()=>tn.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},tn.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),tn.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})),d_=()=>tn.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},tn.createElement("polyline",{points:"20 6 9 17 4 12"}));function g_(e){return e?e.includes("figma.com")?e:/^[a-zA-Z0-9]+$/.test(e)?`https://www.figma.com/design/${e}`:e:""}var f_=Wr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),zk=({onFigmaFileChanged:e})=>{let{selectedProjectId:t,projects:n}=Xe(),{sessionToken:r}=Se(),{updateProject:o}=lo(),i=n.find(S=>S.id===t),[s,a]=Xi(""),[u,c]=Xi(!1),[l,d]=Xi(null),[g,p]=Xi(!1),m=i?.figmaFileUrl||i?.figmaFileId||"",b=g_(m);t_(()=>{a(b),d(null)},[i?.id,b]);let T=s!==b,F=xc(async()=>{if(!(!t||!T))try{c(!0),d(null),await o(t,{figmaFileUrl:s.trim()||void 0});let S=Y();try{await re(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({projectId:t})})}catch{}re(`${S}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({projectId:t})}).catch(()=>{}),d({type:"success",message:"Saved \u2014 reloading Figma cache\u2026"}),setTimeout(()=>d(null),3e3),e?.()}catch(S){d({type:"error",message:S instanceof Error?S.message:"Failed to save"})}finally{c(!1)}},[t,s,T,o,r,e]),v=xc(S=>{S.key==="Enter"&&T&&!u&&F()},[T,u,F]),D=xc(async()=>{if(s)try{await navigator.clipboard.writeText(s),p(!0),setTimeout(()=>p(!1),1500)}catch{}},[s]),[_,$]=Xi(!1),[L,R]=Xi(!1),h=xc(async()=>{if(!(!t||!r))try{R(!0),await o(t,{figmaFileUrl:""});let S=Y();await re(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({projectId:t})}).catch(()=>{}),await re(`${S}/api/figma/frames/invalidate?projectId=${t}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}}).catch(()=>{}),a(""),$(!1),d({type:"success",message:"Figma file removed and cache cleared"}),setTimeout(()=>d(null),3e3),e?.()}catch{d({type:"error",message:"Failed to remove Figma file"})}finally{R(!1)}},[t,r,o,e]);return t?tn.createElement(n_,null,tn.createElement(r_,null,tn.createElement(o_,null,"Figma File URL"),tn.createElement(Rk,{figmaFileUrl:b})),tn.createElement(i_,null,tn.createElement(s_,null,tn.createElement(a_,{type:"text",value:s,onChange:S=>a(S.target.value),onKeyDown:v,placeholder:"https://www.figma.com/file/..."}),s&&tn.createElement(u_,{type:"button",copied:g,onClick:D,title:"Copy Figma URL to clipboard"},g?tn.createElement(d_,null):tn.createElement(p_,null))),tn.createElement(l_,{onClick:F,disabled:!T||u},u?"Saving...":"Save"),b&&tn.createElement(c_,{onClick:()=>$(!0),title:"Remove Figma file and clear cache"},"\u{1F5D1}")),tn.createElement(Hr,{isOpen:_,title:"Remove Figma File",message:"This will remove the Figma file link and clear all cached data (thumbnails, enrichment). Component mappings will be preserved but won't have design data until a new file is linked.",confirmLabel:L?"Removing...":"Remove",variant:"danger",onConfirm:h,onCancel:()=>$(!1)}),l&&tn.createElement(f_,{variant:l.type},l.message)):null};import It,{useState as Lc,useEffect as T4}from"react";import{styled as nr}from"storybook/theming";ve();$e();import Je,{useState as es,useEffect as a4,useCallback as $o}from"react";import{styled as nn}from"storybook/theming";$e();$e();Ne();import J,{useState as Ji,useEffect as kC,useMemo as ph,useCallback as CC}from"react";import{styled as Ge}from"storybook/theming";lt();import Me,{useState as vC,useEffect as m_,memo as h_}from"react";import{styled as he}from"storybook/theming";var Nk=he.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}),Ok=he.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}`})),_k=he.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),$k=he.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),Uk=he(An)({fontSize:"20px",padding:"4px 8px"}),jk=he.div({flex:1,overflow:"auto",padding:"20px"}),Hk=he(To)({fontSize:"14px",marginBottom:"16px"}),Zm=he.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Wk=he.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:ce,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),eh=he.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"})),Vk=he.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"})),Gk=he.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),ca=he.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})),th=he.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:ce,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),ua=he.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),nh=he.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),rh=he.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),oh=he.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),ih=he.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),qk=he.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),yc=he.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Yk=he.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),Kk=he.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),Xk=he.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:ce}})),Qk=he.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ce}`,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:ce,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Jk=he.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:ce,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),Zk=he.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),sne=he.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"})),eC=he.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ce}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),tC=he.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%"}}})),sh=he.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"}})),nC=he.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})),rC=he.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),oC=he.span(({theme:e})=>({color:e.color.defaultText})),bc=he.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%"}}})),iC=he.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),sC=he.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),aC=he.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),lC=he(Sn)({flex:1,width:"auto"}),cC=he.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),uC=he.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"})),pC=he.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),dC=he.span(({theme:e})=>({color:e.color.defaultText})),gC=he.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}})),fC=he.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}})),mC=he.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),Sc=he.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),pa=he.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Qi=he(Sn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),wc=he.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`}})),hC=he.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),xC=he.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:ce,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),yC=he.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),ah=he.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?ce: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:ce,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),lh=he.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?ce:e.appBorderColor}`,backgroundColor:t?ce:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),bC=he.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),SC=he.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:ce,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:ce,opacity:t?.6:.9}})),wC=he.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"}));Ne();import{styled as x_}from"storybook/theming";var y_=x_.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover":{borderColor:e.color.secondary,color:e.color.secondary}})),ch=h_(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=vC(!1),[a,u]=vC(!1);return m_(()=>{s(!1),u(!1)},[e]),i?Me.createElement(ca,null,Me.createElement(nh,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(ua,null,"Failed to load")):e?Me.createElement(Me.Fragment,null,!a&&Me.createElement(ca,{style:{position:"absolute",inset:0}},Me.createElement(th,null),Me.createElement(ua,null,"Loading...")),Me.createElement(Gk,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?Me.createElement(ca,null,Me.createElement(nh,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(ua,null,o?"Render failed":"No preview")):Me.createElement(ca,null,Me.createElement(th,null),Me.createElement(ua,null,"Loading..."))}),da=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,variantFailed:i,isLoadingVariants:s=!1,isExpanded:a,isNew:u=!1,onToggleExpand:c,onSelect:l,multiSelect:d=!1,selectedFrames:g=new Set,variantFilters:p=[],variantPage:m=1,onShowMore:b})=>{let F=e.type==="COMPONENT_SET",v=F&&(e.children&&e.children.length>0||(e.childCount??0)>0),D=e.children||o||[],_=Me.useMemo(()=>D.length===0?[]:p.some(R=>R.value)?D.filter(R=>R.variantProperties?p.every(h=>h.value?R.variantProperties?.[h.property]===h.value:!0):!1):D,[D,p]),$=R=>{if(F){c(e.id,R);return}l(e)},L=d?ah:Wk;return Me.createElement(Me.Fragment,null,Me.createElement(L,{onClick:$,title:e.name,isSelected:d?g.has(e.id):void 0,style:{cursor:"pointer"}},d&&!v&&Me.createElement(lh,{isSelected:g.has(e.id)},g.has(e.id)?"\u2713":""),F?Me.createElement(Vk,null,v&&Me.createElement(Xk,{onClick:R=>c(e.id,R),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),v&&Me.createElement(Jk,null,_.length>0&&_.length!==D.length?`${_.length} / ${D.length}`:e.childCount??D.length," ","variants"),Me.createElement(ch,{src:t,alt:e.name,isComponentSet:!0})):Me.createElement(eh,null,Me.createElement(ch,{src:t,alt:e.name,isComponentSet:!1})),Me.createElement(rh,null,Me.createElement(oh,null,e.name,u&&Me.createElement(wC,null,"New")),Me.createElement(ih,null,e.type))),v&&a&&s&&Me.createElement(Me.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((R,h)=>Me.createElement(eC,{key:`skeleton-${h}`},Me.createElement(tC,null),Me.createElement(sh,{width:"80%"}),Me.createElement(sh,{width:"50%"})))),v&&a&&!s&&_.slice(0,m*50).map(R=>Me.createElement(uh,{key:R.id,variant:R,thumbnail:r?.[R.id]||n[R.id],onSelect:l,multiSelect:d,isSelected:g.has(R.id),loadingDone:!!t||r!==void 0&&R.id in(r||{})||!!i?.has(R.id),failed:i?.has(R.id)})),v&&a&&!s&&_.length>m*50&&Me.createElement(y_,{onClick:()=>b?.(e.id)},"Show more (",_.length-m*50," ","remaining)"))},uh=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>Me.createElement(r?ah:Qk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Me.createElement(lh,{isSelected:o},o?"\u2713":""),Me.createElement(eh,null,Me.createElement(ch,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),Me.createElement(rh,null,Me.createElement(oh,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Me.createElement(Zk,null,Object.entries(e.variantProperties).map(([c,l])=>Me.createElement(nC,{key:c},Me.createElement(rC,null,c,":")," ",Me.createElement(oC,null,l)))),Me.createElement(ih,{style:{marginTop:"6px"}},"VARIANT")));var b_=Ge.div({display:"flex",height:"100%",overflow:"hidden"}),S_=Ge.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),w_=Ge.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),TC=Ge.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),IC=Ge.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),vc=Ge.div({display:"flex",gap:"8px",marginTop:"10px"}),v_=Ge(Sn)({flex:1,width:"auto"}),FC=Ge(To)({flex:1,fontSize:"13px"}),k_=Ge.div({flex:1,overflow:"auto",padding:"8px"}),C_=Ge.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}})),T_=Ge.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),I_=Ge.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),F_=Ge.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})),E_=Ge.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),A_=Ge.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"})),P_=Ge.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),L_=Ge.div({flex:1,overflow:"hidden"}),M_=Ge.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),B_=Ge.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)"}}})),D_=Ge.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),R_=Ge.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),z_=Ge.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),N_=Ge.div({display:"flex",gap:"8px",flexWrap:"wrap"}),dh=Ge.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),O_=Ge.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),gh=20,__=Ge.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),$_=Ge.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`}})),U_=Ge.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),j_=Ge.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`}})),H_=Ge.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),fh=Ge.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),mh=Ge.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),W_=Ge.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),V_=Ge.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),EC=Ge.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),AC=Ge.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"}}})),PC=Ge.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"}}})),G_=()=>J.createElement(V_,null,Array.from({length:8}).map((e,t)=>J.createElement(EC,{key:t},J.createElement(AC,null),J.createElement(PC,{width:`${60+t%3*15}%`})))),q_=Ge.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"})),Y_=Ge.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"}),K_=Ge.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)"}}})),X_=Ge.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),LC=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=aa({projectId:i,limit:gh,enabled:!!i}),[a,u]=Ji("all"),[c,l]=Ji(""),[d,g]=Ji(null),[p,m]=Ji(1),[b,T]=Ji(null),[F,v]=Ji(!1),D=ph(()=>{let f=new Set;return e.forEach(k=>{k.componentTitle&&f.add(k.componentTitle)}),Array.from(f).sort()},[e]),_=ph(()=>e.filter(f=>{if(a!=="all"&&f.componentTitle!==a)return!1;if(c){let k=c.toLowerCase();return f.name.toLowerCase().includes(k)||f.title.toLowerCase().includes(k)}return!0}),[e,a,c]),$=d?s.frames.find(f=>f.id===d):null,L=ph(()=>{if(!d)return[];let f=s.variantChildren[d]||[];return f.length===0?[]:s.variantFilters.some(k=>k.value)?f.filter(k=>k.variantProperties?s.variantFilters.every(E=>E.value?k.variantProperties?.[E.property]===E.value:!0):!1):f},[d,s.variantChildren,s.variantFilters]),R=L.slice(0,p*gh),h=L.length>p*gh;kC(()=>{if(!d||R.length===0)return;let f=R.map(k=>k.id);s.fetchVariantThumbnails(d,f)},[d,R.length,p]),kC(()=>{v(!1)},[]);let S=CC(async f=>{if(n)try{let k=Y(),E=localStorage.getItem("uicopilot_session_token");if(!(await re(`${k}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:f.id,name:f.name})})).ok)throw new Error("Failed to save mapping");o(n,f.id,f.name)}catch(k){y.error("[MapStoriesTab] Error saving mapping:",k)}},[n,i,o]),w=CC((f,k)=>{if(k.stopPropagation(),d===f){g(null),m(1);return}g(f),m(1),!s.variantThumbnails[f]&&!s.loadingVariants.has(f)&&s.toggleExpanded(f,k)},[d,s]),A=e.find(f=>f.id===n);return t?J.createElement(W_,null,"Loading stories..."):J.createElement(b_,null,J.createElement(S_,null,J.createElement(TC,null,J.createElement(IC,null,"Storybook Stories"),J.createElement(vc,null,J.createElement(v_,{value:a,onChange:f=>u(f.target.value)},J.createElement("option",{value:"all"},"All Components"),D.map(f=>J.createElement("option",{key:f,value:f},f)))),J.createElement(vc,null,J.createElement(FC,{type:"text",placeholder:"Search stories...",value:c,onChange:f=>l(f.target.value)}))),J.createElement(k_,null,_.length===0?J.createElement(mh,null,"No stories found"):_.map(f=>J.createElement(C_,{key:f.id,selected:f.id===n,mapped:!!f.figmaMapping,onClick:()=>r(f.id)},J.createElement(T_,null,J.createElement(I_,null,f.name),J.createElement(F_,{mapped:!!f.figmaMapping},f.figmaMapping?"Mapped":"Unmapped")),J.createElement(E_,null,f.title),f.figmaMapping&&J.createElement(A_,{onMouseEnter:()=>T(f.id),onMouseLeave:()=>T(null)},(()=>{let k=f.figmaMapping?.figmaNodeId,E=k?s.resolveThumbnail(k):void 0;return J.createElement(J.Fragment,null,E?J.createElement(P_,{src:E,alt:f.figmaMapping?.figmaFrameName||""}):J.createElement("span",null,"\u{1F517}"),b===f.id&&E&&J.createElement(B_,null,J.createElement(D_,{src:E,alt:f.figmaMapping?.figmaFrameName||""}),J.createElement(R_,null,f.figmaMapping?.figmaFrameName)))})(),J.createElement(L_,null,J.createElement(M_,null,f.figmaMapping.figmaFrameName))))))),J.createElement(w_,null,n?J.createElement(J.Fragment,null,J.createElement(q_,null,J.createElement("span",null,"Click a Figma component below to link it to"," ",J.createElement("strong",null,A?.name))),J.createElement(TC,null,J.createElement(IC,null,"Figma Components"),J.createElement(vc,null,J.createElement(N_,null,J.createElement(dh,null,J.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:f=>s.setShowComponentSets(f.target.checked)}),"Component Sets"),J.createElement(dh,null,J.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:f=>s.setShowFrames(f.target.checked)}),"Frames"),J.createElement(dh,null,J.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:f=>s.setShowComponents(f.target.checked)}),"Components")),s.availablePages.length>1&&J.createElement(Qi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:f=>s.setFigmaPage(f.target.value)},J.createElement("option",{value:""},"All pages"),s.availablePages.map(f=>J.createElement("option",{key:f,value:f},f)))),s.availableFilters.length>0&&J.createElement(Sc,null,J.createElement(pa,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:f,values:k})=>{let E=s.variantFilters.find(x=>x.property===f);return J.createElement(Qi,{key:f,isActive:!!E?.value,value:E?.value||"",onChange:x=>s.handleFilterChange(f,x.target.value)},J.createElement("option",{value:""},f),k.map(x=>J.createElement("option",{key:x,value:x},f,"=",x)))}),s.availableFilters.length>5&&J.createElement(pa,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(f=>f.value)&&J.createElement(wc,{onClick:s.clearFilters},"Clear All")),J.createElement(vc,null,J.createElement(FC,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:f=>s.setSearch(f.target.value)}))),J.createElement(z_,null,F&&J.createElement(Y_,null,J.createElement(K_,null),J.createElement(X_,null,"Loading thumbnails...")),s.isLoading?J.createElement(G_,null):s.filteredFrames.length===0?J.createElement(mh,null,J.createElement("span",null,"No components match. Try a different search term, or check that your Figma file has component sets defined.")):J.createElement(O_,null,d&&$?J.createElement(J.Fragment,null,J.createElement(U_,null,J.createElement(j_,{onClick:()=>{g(null),m(1)}},"Back"),J.createElement(H_,null,$.name)),s.loadingVariants.has(d)?J.createElement(J.Fragment,null,J.createElement(fh,null,"Loading ",$.childCount??"..."," ","variants..."),Array.from({length:Math.min(8,$.childCount??8)}).map((f,k)=>J.createElement(EC,{key:`variant-skeleton-${k}`},J.createElement(AC,null),J.createElement(PC,{width:`${60+k%3*15}%`})))):J.createElement(J.Fragment,null,J.createElement(fh,null,"Showing ",R.length," of"," ",L.length," variants"),R.map(f=>J.createElement(uh,{key:f.id,variant:f,thumbnail:s.variantThumbnails[d]?.[f.id]||s.thumbnails[f.id],onSelect:S,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d),failed:s.variantFailed[d]?.has(f.id)})))):J.createElement(J.Fragment,null,J.createElement(fh,null,"Showing ",s.frames.length," of ",s.totalFrames," ","components"),s.filteredFrames.map(f=>J.createElement(da,{key:f.id,frame:f,thumbnail:s.thumbnails[f.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[f.id],variantChildren:s.variantChildren[f.id],variantFailed:s.variantFailed[f.id],isLoadingVariants:s.loadingVariants.has(f.id),isExpanded:!1,onToggleExpand:w,onSelect:S,variantFilters:s.variantFilters}))),(d?h:s.hasMore)&&J.createElement(__,null,J.createElement($_,{disabled:s.loadingMore,onClick:async()=>{d?m(f=>f+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):J.createElement(mh,null,J.createElement("span",null,"\u{1F448} Pick a story from the left, then browse your Figma file to find a matching frame. The mapping is saved per story."))))};$e();import tt,{useState as hh,useMemo as MC,useCallback as BC}from"react";import{styled as _t}from"storybook/theming";lt();var Q_=_t.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),J_=_t.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),Z_=_t(Sn)({width:"auto",minWidth:"200px"}),e$=_t(To)({fontSize:"13px",minWidth:"250px"}),t$=_t.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}})),n$=_t.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}})),r$=_t.div({flex:1,overflow:"auto"}),o$=_t.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),i$=_t.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),kc=_t.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}`})),s$=_t.tbody({}),a$=_t.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),Cc=_t.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),l$=_t.div({display:"flex",flexDirection:"column",gap:"2px"}),c$=_t.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),u$=_t.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),p$=_t.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),d$=_t.div({display:"flex",alignItems:"center",gap:"8px"}),g$=_t.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),f$=_t.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),DC=_t.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`}})),m$=_t.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),h$=_t.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),RC=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=hh("all"),[a,u]=hh(""),[c,l]=hh(!0),d=MC(()=>{let T=new Set;return e.forEach(F=>{F.componentTitle&&T.add(F.componentTitle)}),Array.from(T).sort()},[e]),g=MC(()=>e.filter(T=>{if(i!=="all"&&T.componentTitle!==i||!c&&!T.figmaMapping)return!1;if(a){let F=a.toLowerCase();return T.name.toLowerCase().includes(F)||T.title.toLowerCase().includes(F)||(T.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),p=BC(async T=>{try{let F=Y(),v=localStorage.getItem("uicopilot_session_token");if(!(await re(`${F}/api/mappings?projectId=${o}&storyId=${T}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}})).ok)throw new Error("Failed to delete mapping");r(T)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),m=BC(()=>{let T=e.filter(_=>_.figmaMapping).map(_=>({storyId:_.id,storyName:_.name,storyTitle:_.title,figmaNodeId:_.figmaMapping.figmaNodeId,figmaFrameName:_.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(T,null,2)],{type:"application/json"}),v=URL.createObjectURL(F),D=document.createElement("a");D.href=v,D.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(v)},[e]);if(t)return tt.createElement(h$,null,"Loading mappings...");let b=e.filter(T=>T.figmaMapping).length;return tt.createElement(Q_,null,tt.createElement(J_,null,tt.createElement(Z_,{value:i,onChange:T=>s(T.target.value)},tt.createElement("option",{value:"all"},"All Components"),d.map(T=>tt.createElement("option",{key:T,value:T},T))),tt.createElement(e$,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:T=>u(T.target.value)}),tt.createElement(t$,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),tt.createElement(n$,{onClick:m,disabled:b===0},"\u{1F4E5} Export JSON")),g.length===0?tt.createElement(m$,null,tt.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):tt.createElement(r$,null,tt.createElement(o$,null,tt.createElement(i$,null,tt.createElement("tr",null,tt.createElement(kc,{style:{width:"35%"}},"Story"),tt.createElement(kc,{style:{width:"35%"}},"Figma Component"),tt.createElement(kc,{style:{width:"15%"}},"Status"),tt.createElement(kc,{style:{width:"15%"}},"Actions"))),tt.createElement(s$,null,g.map(T=>tt.createElement(a$,{key:T.id,mapped:!!T.figmaMapping},tt.createElement(Cc,null,tt.createElement(l$,null,tt.createElement(c$,null,T.name),tt.createElement(u$,null,T.title))),tt.createElement(Cc,null,tt.createElement(p$,{mapped:!!T.figmaMapping},T.figmaMapping?tt.createElement(tt.Fragment,null,tt.createElement("span",null,"\u{1F3A8}"),T.figmaMapping.figmaFrameName):"\u2014")),tt.createElement(Cc,null,tt.createElement(d$,null,tt.createElement(g$,{mapped:!!T.figmaMapping}),tt.createElement(f$,{mapped:!!T.figmaMapping},T.figmaMapping?"Mapped":"Unmapped"))),tt.createElement(Cc,null,T.figmaMapping?tt.createElement(DC,{variant:"unlink",onClick:()=>p(T.id)},"Unlink"):tt.createElement(DC,{variant:"link",onClick:()=>n(T.id)},"Link"))))))))};import Ce,{useState as Pc,useMemo as jC}from"react";import{styled as ht}from"storybook/theming";import zC from"react";import{styled as NC,keyframes as x$}from"storybook/theming";var y$=x$`
41
+ `,WO=Vn.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})),VO=Vn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),GO=Vn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),qO=Vn.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()}}),YO=Vn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),KO=Vn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),XO=Vn.span({display:"flex",alignItems:"center",gap:"4px"}),QO=Vn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),JO=Vn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),ZO=Vn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),e_=Vn.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"}})),Rk=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Xe(),[n,r]=Jm(!1),[o,i]=Jm(!1),[s,a]=Jm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=Y(),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 g=await d.json();a(g),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?Vt.createElement($O,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Vt.createElement(jO,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?Vt.createElement(Vt.Fragment,null,Vt.createElement(HO,null)," Checking..."):s?Vt.createElement(Vt.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):Vt.createElement(Vt.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&Vt.createElement(WO,null,Vt.createElement(VO,null,Vt.createElement(GO,null,"Figma Design Quality"),Vt.createElement(qO,{score:s.score},Math.round(s.score),"%")),Vt.createElement(YO,null,Object.entries(s.categories).map(([c,l])=>Vt.createElement(KO,{key:c},Vt.createElement(XO,null,Vt.createElement(QO,{status:l.status},_O(l.status)),OO[c]||c),Vt.createElement(JO,null,l.score)))),s.summary&&Vt.createElement(ZO,null,s.summary),s.recommendations?.length>0&&Vt.createElement(e_,null,s.recommendations.slice(0,2).map((c,l)=>Vt.createElement("li",{key:l},c))))):null};var n_=Wr.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),r_=Wr.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),o_=Wr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),i_=Wr.div({display:"flex",gap:"8px",alignItems:"center"}),s_=Wr.div({position:"relative",flex:1,display:"flex"}),a_=Wr.input(({theme:e})=>({width:"100%",padding:"8px 36px 8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:ce,boxShadow:`0 0 0 1px ${ce}`},"&::placeholder":{color:e.color.mediumlight}})),l_=Wr(on)({whiteSpace:"nowrap"}),c_=Wr.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"12px",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),u_=Wr.button(({theme:e,copied:t})=>({position:"absolute",top:"50%",right:"5px",transform:"translateY(-50%)",width:"26px",height:"26px",padding:0,border:"none",borderRadius:"5px",background:"transparent",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:t?e.color.positive:e.color.defaultText,transition:"color 0.15s, background 0.15s","&:hover":{color:t?e.color.positive:ce,background:e.background.hoverable}})),p_=()=>tn.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},tn.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),tn.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})),d_=()=>tn.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},tn.createElement("polyline",{points:"20 6 9 17 4 12"}));function g_(e){return e?e.includes("figma.com")?e:/^[a-zA-Z0-9]+$/.test(e)?`https://www.figma.com/design/${e}`:e:""}var f_=Wr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),zk=({onFigmaFileChanged:e})=>{let{selectedProjectId:t,projects:n}=Xe(),{sessionToken:r}=Se(),{updateProject:o}=co(),i=n.find(S=>S.id===t),[s,a]=Xi(""),[u,c]=Xi(!1),[l,d]=Xi(null),[g,p]=Xi(!1),h=i?.figmaFileUrl||i?.figmaFileId||"",b=g_(h);t_(()=>{a(b),d(null)},[i?.id,b]);let I=s!==b,F=yc(async()=>{if(!(!t||!I))try{c(!0),d(null),await o(t,{figmaFileUrl:s.trim()||void 0});let S=Y();try{await oe(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({projectId:t})})}catch{}oe(`${S}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({projectId:t})}).catch(()=>{}),d({type:"success",message:"Saved \u2014 reloading Figma cache\u2026"}),setTimeout(()=>d(null),3e3),e?.()}catch(S){d({type:"error",message:S instanceof Error?S.message:"Failed to save"})}finally{c(!1)}},[t,s,I,o,r,e]),v=yc(S=>{S.key==="Enter"&&I&&!u&&F()},[I,u,F]),D=yc(async()=>{if(s)try{await navigator.clipboard.writeText(s),p(!0),setTimeout(()=>p(!1),1500)}catch{}},[s]),[N,$]=Xi(!1),[M,z]=Xi(!1),m=yc(async()=>{if(!(!t||!r))try{z(!0),await o(t,{figmaFileUrl:""});let S=Y();await oe(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({projectId:t})}).catch(()=>{}),await oe(`${S}/api/figma/frames/invalidate?projectId=${t}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}}).catch(()=>{}),a(""),$(!1),d({type:"success",message:"Figma file removed and cache cleared"}),setTimeout(()=>d(null),3e3),e?.()}catch{d({type:"error",message:"Failed to remove Figma file"})}finally{z(!1)}},[t,r,o,e]);return t?tn.createElement(n_,null,tn.createElement(r_,null,tn.createElement(o_,null,"Figma File URL"),tn.createElement(Rk,{figmaFileUrl:b})),tn.createElement(i_,null,tn.createElement(s_,null,tn.createElement(a_,{type:"text",value:s,onChange:S=>a(S.target.value),onKeyDown:v,placeholder:"https://www.figma.com/file/..."}),s&&tn.createElement(u_,{type:"button",copied:g,onClick:D,title:"Copy Figma URL to clipboard"},g?tn.createElement(d_,null):tn.createElement(p_,null))),tn.createElement(l_,{onClick:F,disabled:!I||u},u?"Saving...":"Save"),b&&tn.createElement(c_,{onClick:()=>$(!0),title:"Remove Figma file and clear cache"},"\u{1F5D1}")),tn.createElement(Hr,{isOpen:N,title:"Remove Figma File",message:"This will remove the Figma file link and clear all cached data (thumbnails, enrichment). Component mappings will be preserved but won't have design data until a new file is linked.",confirmLabel:M?"Removing...":"Remove",variant:"danger",onConfirm:m,onCancel:()=>$(!1)}),l&&tn.createElement(f_,{variant:l.type},l.message)):null};import It,{useState as Mc,useEffect as T4}from"react";import{styled as nr}from"storybook/theming";ve();$e();import Je,{useState as es,useEffect as a4,useCallback as $o}from"react";import{styled as nn}from"storybook/theming";$e();$e();Ne();import Z,{useState as Ji,useEffect as kC,useMemo as ph,useCallback as CC}from"react";import{styled as qe}from"storybook/theming";lt();import Me,{useState as vC,useEffect as m_,memo as h_}from"react";import{styled as xe}from"storybook/theming";var Nk=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}),Ok=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}`})),_k=xe.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),$k=xe.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),Uk=xe(Pn)({fontSize:"20px",padding:"4px 8px"}),jk=xe.div({flex:1,overflow:"auto",padding:"20px"}),Hk=xe(To)({fontSize:"14px",marginBottom:"16px"}),Zm=xe.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Wk=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:ce,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),eh=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"})),Vk=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"})),Gk=xe.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),pa=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})),th=xe.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:ce,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),da=xe.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),nh=xe.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),rh=xe.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),oh=xe.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),ih=xe.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),qk=xe.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),bc=xe.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Yk=xe.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),Kk=xe.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),Xk=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:ce}})),Qk=xe.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ce}`,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:ce,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Jk=xe.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:ce,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),Zk=xe.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),lne=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"})),eC=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ce}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),tC=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%"}}})),sh=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"}})),nC=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})),rC=xe.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),oC=xe.span(({theme:e})=>({color:e.color.defaultText})),Sc=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%"}}})),iC=xe.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),sC=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}`})),aC=xe.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),lC=xe(Sn)({flex:1,width:"auto"}),cC=xe.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),uC=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"})),pC=xe.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),dC=xe.span(({theme:e})=>({color:e.color.defaultText})),gC=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}})),fC=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}})),mC=xe.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),wc=xe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),ga=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Qi=xe(Sn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),vc=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`}})),hC=xe.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),xC=xe.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:ce,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),yC=xe.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),ah=xe.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?ce: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:ce,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),lh=xe.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?ce:e.appBorderColor}`,backgroundColor:t?ce:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),bC=xe.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),SC=xe.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:ce,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:ce,opacity:t?.6:.9}})),wC=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"}));Ne();import{styled as x_}from"storybook/theming";var y_=x_.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover":{borderColor:e.color.secondary,color:e.color.secondary}})),ch=h_(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=vC(!1),[a,u]=vC(!1);return m_(()=>{s(!1),u(!1)},[e]),i?Me.createElement(pa,null,Me.createElement(nh,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(da,null,"Failed to load")):e?Me.createElement(Me.Fragment,null,!a&&Me.createElement(pa,{style:{position:"absolute",inset:0}},Me.createElement(th,null),Me.createElement(da,null,"Loading...")),Me.createElement(Gk,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?Me.createElement(pa,null,Me.createElement(nh,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Me.createElement(da,null,o?"Render failed":"No preview")):Me.createElement(pa,null,Me.createElement(th,null),Me.createElement(da,null,"Loading..."))}),fa=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,variantFailed:i,isLoadingVariants:s=!1,isExpanded:a,isNew:u=!1,onToggleExpand:c,onSelect:l,multiSelect:d=!1,selectedFrames:g=new Set,variantFilters:p=[],variantPage:h=1,onShowMore:b})=>{let F=e.type==="COMPONENT_SET",v=F&&(e.children&&e.children.length>0||(e.childCount??0)>0),D=e.children||o||[],N=Me.useMemo(()=>D.length===0?[]:p.some(z=>z.value)?D.filter(z=>z.variantProperties?p.every(m=>m.value?z.variantProperties?.[m.property]===m.value:!0):!1):D,[D,p]),$=z=>{if(F){c(e.id,z);return}l(e)},M=d?ah:Wk;return Me.createElement(Me.Fragment,null,Me.createElement(M,{onClick:$,title:e.name,isSelected:d?g.has(e.id):void 0,style:{cursor:"pointer"}},d&&!v&&Me.createElement(lh,{isSelected:g.has(e.id)},g.has(e.id)?"\u2713":""),F?Me.createElement(Vk,null,v&&Me.createElement(Xk,{onClick:z=>c(e.id,z),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),v&&Me.createElement(Jk,null,N.length>0&&N.length!==D.length?`${N.length} / ${D.length}`:e.childCount??D.length," ","variants"),Me.createElement(ch,{src:t,alt:e.name,isComponentSet:!0})):Me.createElement(eh,null,Me.createElement(ch,{src:t,alt:e.name,isComponentSet:!1})),Me.createElement(rh,null,Me.createElement(oh,null,e.name,u&&Me.createElement(wC,null,"New")),Me.createElement(ih,null,e.type))),v&&a&&s&&Me.createElement(Me.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((z,m)=>Me.createElement(eC,{key:`skeleton-${m}`},Me.createElement(tC,null),Me.createElement(sh,{width:"80%"}),Me.createElement(sh,{width:"50%"})))),v&&a&&!s&&N.slice(0,h*50).map(z=>Me.createElement(uh,{key:z.id,variant:z,thumbnail:r?.[z.id]||n[z.id],onSelect:l,multiSelect:d,isSelected:g.has(z.id),loadingDone:!!t||r!==void 0&&z.id in(r||{})||!!i?.has(z.id),failed:i?.has(z.id)})),v&&a&&!s&&N.length>h*50&&Me.createElement(y_,{onClick:()=>b?.(e.id)},"Show more (",N.length-h*50," ","remaining)"))},uh=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>Me.createElement(r?ah:Qk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Me.createElement(lh,{isSelected:o},o?"\u2713":""),Me.createElement(eh,null,Me.createElement(ch,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),Me.createElement(rh,null,Me.createElement(oh,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Me.createElement(Zk,null,Object.entries(e.variantProperties).map(([c,l])=>Me.createElement(nC,{key:c},Me.createElement(rC,null,c,":")," ",Me.createElement(oC,null,l)))),Me.createElement(ih,{style:{marginTop:"6px"}},"VARIANT")));var b_=qe.div({display:"flex",height:"100%",overflow:"hidden"}),S_=qe.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),w_=qe.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),TC=qe.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),IC=qe.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),kc=qe.div({display:"flex",gap:"8px",marginTop:"10px"}),v_=qe(Sn)({flex:1,width:"auto"}),FC=qe(To)({flex:1,fontSize:"13px"}),k_=qe.div({flex:1,overflow:"auto",padding:"8px"}),C_=qe.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}})),T_=qe.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),I_=qe.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),F_=qe.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})),E_=qe.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),A_=qe.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"})),P_=qe.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),L_=qe.div({flex:1,overflow:"hidden"}),M_=qe.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),B_=qe.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)"}}})),D_=qe.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),R_=qe.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),z_=qe.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),N_=qe.div({display:"flex",gap:"8px",flexWrap:"wrap"}),dh=qe.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),O_=qe.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),gh=20,__=qe.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),$_=qe.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`}})),U_=qe.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),j_=qe.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`}})),H_=qe.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),fh=qe.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),mh=qe.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),W_=qe.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),V_=qe.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),EC=qe.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),AC=qe.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"}}})),PC=qe.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"}}})),G_=()=>Z.createElement(V_,null,Array.from({length:8}).map((e,t)=>Z.createElement(EC,{key:t},Z.createElement(AC,null),Z.createElement(PC,{width:`${60+t%3*15}%`})))),q_=qe.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"})),Y_=qe.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"}),K_=qe.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)"}}})),X_=qe.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),LC=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=ca({projectId:i,limit:gh,enabled:!!i}),[a,u]=Ji("all"),[c,l]=Ji(""),[d,g]=Ji(null),[p,h]=Ji(1),[b,I]=Ji(null),[F,v]=Ji(!1),D=ph(()=>{let f=new Set;return e.forEach(k=>{k.componentTitle&&f.add(k.componentTitle)}),Array.from(f).sort()},[e]),N=ph(()=>e.filter(f=>{if(a!=="all"&&f.componentTitle!==a)return!1;if(c){let k=c.toLowerCase();return f.name.toLowerCase().includes(k)||f.title.toLowerCase().includes(k)}return!0}),[e,a,c]),$=d?s.frames.find(f=>f.id===d):null,M=ph(()=>{if(!d)return[];let f=s.variantChildren[d]||[];return f.length===0?[]:s.variantFilters.some(k=>k.value)?f.filter(k=>k.variantProperties?s.variantFilters.every(E=>E.value?k.variantProperties?.[E.property]===E.value:!0):!1):f},[d,s.variantChildren,s.variantFilters]),z=M.slice(0,p*gh),m=M.length>p*gh;kC(()=>{if(!d||z.length===0)return;let f=z.map(k=>k.id);s.fetchVariantThumbnails(d,f)},[d,z.length,p]),kC(()=>{v(!1)},[]);let S=CC(async f=>{if(n)try{let k=Y(),E=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${k}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:f.id,name:f.name})})).ok)throw new Error("Failed to save mapping");o(n,f.id,f.name)}catch(k){y.error("[MapStoriesTab] Error saving mapping:",k)}},[n,i,o]),w=CC((f,k)=>{if(k.stopPropagation(),d===f){g(null),h(1);return}g(f),h(1),!s.variantThumbnails[f]&&!s.loadingVariants.has(f)&&s.toggleExpanded(f,k)},[d,s]),A=e.find(f=>f.id===n);return t?Z.createElement(W_,null,"Loading stories..."):Z.createElement(b_,null,Z.createElement(S_,null,Z.createElement(TC,null,Z.createElement(IC,null,"Storybook Stories"),Z.createElement(kc,null,Z.createElement(v_,{value:a,onChange:f=>u(f.target.value)},Z.createElement("option",{value:"all"},"All Components"),D.map(f=>Z.createElement("option",{key:f,value:f},f)))),Z.createElement(kc,null,Z.createElement(FC,{type:"text",placeholder:"Search stories...",value:c,onChange:f=>l(f.target.value)}))),Z.createElement(k_,null,N.length===0?Z.createElement(mh,null,"No stories found"):N.map(f=>Z.createElement(C_,{key:f.id,selected:f.id===n,mapped:!!f.figmaMapping,onClick:()=>r(f.id)},Z.createElement(T_,null,Z.createElement(I_,null,f.name),Z.createElement(F_,{mapped:!!f.figmaMapping},f.figmaMapping?"Mapped":"Unmapped")),Z.createElement(E_,null,f.title),f.figmaMapping&&Z.createElement(A_,{onMouseEnter:()=>I(f.id),onMouseLeave:()=>I(null)},(()=>{let k=f.figmaMapping?.figmaNodeId,E=k?s.resolveThumbnail(k):void 0;return Z.createElement(Z.Fragment,null,E?Z.createElement(P_,{src:E,alt:f.figmaMapping?.figmaFrameName||""}):Z.createElement("span",null,"\u{1F517}"),b===f.id&&E&&Z.createElement(B_,null,Z.createElement(D_,{src:E,alt:f.figmaMapping?.figmaFrameName||""}),Z.createElement(R_,null,f.figmaMapping?.figmaFrameName)))})(),Z.createElement(L_,null,Z.createElement(M_,null,f.figmaMapping.figmaFrameName))))))),Z.createElement(w_,null,n?Z.createElement(Z.Fragment,null,Z.createElement(q_,null,Z.createElement("span",null,"Click a Figma component below to link it to"," ",Z.createElement("strong",null,A?.name))),Z.createElement(TC,null,Z.createElement(IC,null,"Figma Components"),Z.createElement(kc,null,Z.createElement(N_,null,Z.createElement(dh,null,Z.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:f=>s.setShowComponentSets(f.target.checked)}),"Component Sets"),Z.createElement(dh,null,Z.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:f=>s.setShowFrames(f.target.checked)}),"Frames"),Z.createElement(dh,null,Z.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:f=>s.setShowComponents(f.target.checked)}),"Components")),s.availablePages.length>1&&Z.createElement(Qi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:f=>s.setFigmaPage(f.target.value)},Z.createElement("option",{value:""},"All pages"),s.availablePages.map(f=>Z.createElement("option",{key:f,value:f},f)))),s.availableFilters.length>0&&Z.createElement(wc,null,Z.createElement(ga,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:f,values:k})=>{let E=s.variantFilters.find(x=>x.property===f);return Z.createElement(Qi,{key:f,isActive:!!E?.value,value:E?.value||"",onChange:x=>s.handleFilterChange(f,x.target.value)},Z.createElement("option",{value:""},f),k.map(x=>Z.createElement("option",{key:x,value:x},f,"=",x)))}),s.availableFilters.length>5&&Z.createElement(ga,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(f=>f.value)&&Z.createElement(vc,{onClick:s.clearFilters},"Clear All")),Z.createElement(kc,null,Z.createElement(FC,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:f=>s.setSearch(f.target.value)}))),Z.createElement(z_,null,F&&Z.createElement(Y_,null,Z.createElement(K_,null),Z.createElement(X_,null,"Loading thumbnails...")),s.isLoading?Z.createElement(G_,null):s.filteredFrames.length===0?Z.createElement(mh,null,Z.createElement("span",null,"No components match. Try a different search term, or check that your Figma file has component sets defined.")):Z.createElement(O_,null,d&&$?Z.createElement(Z.Fragment,null,Z.createElement(U_,null,Z.createElement(j_,{onClick:()=>{g(null),h(1)}},"Back"),Z.createElement(H_,null,$.name)),s.loadingVariants.has(d)?Z.createElement(Z.Fragment,null,Z.createElement(fh,null,"Loading ",$.childCount??"..."," ","variants..."),Array.from({length:Math.min(8,$.childCount??8)}).map((f,k)=>Z.createElement(EC,{key:`variant-skeleton-${k}`},Z.createElement(AC,null),Z.createElement(PC,{width:`${60+k%3*15}%`})))):Z.createElement(Z.Fragment,null,Z.createElement(fh,null,"Showing ",z.length," of"," ",M.length," variants"),z.map(f=>Z.createElement(uh,{key:f.id,variant:f,thumbnail:s.variantThumbnails[d]?.[f.id]||s.thumbnails[f.id],onSelect:S,loadingDone:s.variantThumbnails[d]!==void 0&&!s.loadingVariants.has(d),failed:s.variantFailed[d]?.has(f.id)})))):Z.createElement(Z.Fragment,null,Z.createElement(fh,null,"Showing ",s.frames.length," of ",s.totalFrames," ","components"),s.filteredFrames.map(f=>Z.createElement(fa,{key:f.id,frame:f,thumbnail:s.thumbnails[f.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[f.id],variantChildren:s.variantChildren[f.id],variantFailed:s.variantFailed[f.id],isLoadingVariants:s.loadingVariants.has(f.id),isExpanded:!1,onToggleExpand:w,onSelect:S,variantFilters:s.variantFilters}))),(d?m:s.hasMore)&&Z.createElement(__,null,Z.createElement($_,{disabled:s.loadingMore,onClick:async()=>{d?h(f=>f+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):Z.createElement(mh,null,Z.createElement("span",null,"\u{1F448} Pick a story from the left, then browse your Figma file to find a matching frame. The mapping is saved per story."))))};$e();import tt,{useState as hh,useMemo as MC,useCallback as BC}from"react";import{styled as _t}from"storybook/theming";lt();var Q_=_t.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),J_=_t.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),Z_=_t(Sn)({width:"auto",minWidth:"200px"}),e$=_t(To)({fontSize:"13px",minWidth:"250px"}),t$=_t.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}})),n$=_t.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}})),r$=_t.div({flex:1,overflow:"auto"}),o$=_t.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),i$=_t.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),Cc=_t.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}`})),s$=_t.tbody({}),a$=_t.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),Tc=_t.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),l$=_t.div({display:"flex",flexDirection:"column",gap:"2px"}),c$=_t.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),u$=_t.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),p$=_t.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),d$=_t.div({display:"flex",alignItems:"center",gap:"8px"}),g$=_t.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),f$=_t.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),DC=_t.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`}})),m$=_t.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),h$=_t.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),RC=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=hh("all"),[a,u]=hh(""),[c,l]=hh(!0),d=MC(()=>{let I=new Set;return e.forEach(F=>{F.componentTitle&&I.add(F.componentTitle)}),Array.from(I).sort()},[e]),g=MC(()=>e.filter(I=>{if(i!=="all"&&I.componentTitle!==i||!c&&!I.figmaMapping)return!1;if(a){let F=a.toLowerCase();return I.name.toLowerCase().includes(F)||I.title.toLowerCase().includes(F)||(I.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),p=BC(async I=>{try{let F=Y(),v=localStorage.getItem("uicopilot_session_token");if(!(await oe(`${F}/api/mappings?projectId=${o}&storyId=${I}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}})).ok)throw new Error("Failed to delete mapping");r(I)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),h=BC(()=>{let I=e.filter(N=>N.figmaMapping).map(N=>({storyId:N.id,storyName:N.name,storyTitle:N.title,figmaNodeId:N.figmaMapping.figmaNodeId,figmaFrameName:N.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),v=URL.createObjectURL(F),D=document.createElement("a");D.href=v,D.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(v)},[e]);if(t)return tt.createElement(h$,null,"Loading mappings...");let b=e.filter(I=>I.figmaMapping).length;return tt.createElement(Q_,null,tt.createElement(J_,null,tt.createElement(Z_,{value:i,onChange:I=>s(I.target.value)},tt.createElement("option",{value:"all"},"All Components"),d.map(I=>tt.createElement("option",{key:I,value:I},I))),tt.createElement(e$,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:I=>u(I.target.value)}),tt.createElement(t$,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),tt.createElement(n$,{onClick:h,disabled:b===0},"\u{1F4E5} Export JSON")),g.length===0?tt.createElement(m$,null,tt.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):tt.createElement(r$,null,tt.createElement(o$,null,tt.createElement(i$,null,tt.createElement("tr",null,tt.createElement(Cc,{style:{width:"35%"}},"Story"),tt.createElement(Cc,{style:{width:"35%"}},"Figma Component"),tt.createElement(Cc,{style:{width:"15%"}},"Status"),tt.createElement(Cc,{style:{width:"15%"}},"Actions"))),tt.createElement(s$,null,g.map(I=>tt.createElement(a$,{key:I.id,mapped:!!I.figmaMapping},tt.createElement(Tc,null,tt.createElement(l$,null,tt.createElement(c$,null,I.name),tt.createElement(u$,null,I.title))),tt.createElement(Tc,null,tt.createElement(p$,{mapped:!!I.figmaMapping},I.figmaMapping?tt.createElement(tt.Fragment,null,tt.createElement("span",null,"\u{1F3A8}"),I.figmaMapping.figmaFrameName):"\u2014")),tt.createElement(Tc,null,tt.createElement(d$,null,tt.createElement(g$,{mapped:!!I.figmaMapping}),tt.createElement(f$,{mapped:!!I.figmaMapping},I.figmaMapping?"Mapped":"Unmapped"))),tt.createElement(Tc,null,I.figmaMapping?tt.createElement(DC,{variant:"unlink",onClick:()=>p(I.id)},"Unlink"):tt.createElement(DC,{variant:"link",onClick:()=>n(I.id)},"Link"))))))))};import Ce,{useState as Lc,useMemo as jC}from"react";import{styled as ht}from"storybook/theming";import zC from"react";import{styled as NC,keyframes as x$}from"storybook/theming";var y$=x$`
42
42
  0% { transform: rotate(0deg); }
43
43
  100% { transform: rotate(360deg); }
44
- `,b$=NC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${y$} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),S$=NC.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}}})),Mr=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>zC.createElement(S$,{variant:r,disabled:t||e,onClick:n},e&&zC.createElement(b$,null),e&&i?i:o);$e();import pn from"react";import{styled as ga}from"storybook/theming";var OC=ga.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"})),w$=ga.div({display:"flex",alignItems:"center",gap:"12px"}),Tc=ga.span({whiteSpace:"nowrap"}),_C=ga.div({display:"flex",alignItems:"center",gap:"8px"}),Ic=ga.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Fc=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*Ww;return r?pn.createElement(OC,null,pn.createElement(Tc,null,o.toLocaleString()," tokens"),pn.createElement(_C,null,pn.createElement(Ic,null,"$",n.toFixed(4)),pn.createElement("span",null,"\xB7"),pn.createElement(Ic,null,"\u20AA",i.toFixed(2)))):pn.createElement(OC,null,pn.createElement(w$,null,pn.createElement(Tc,null,e.toLocaleString()," input"),pn.createElement("span",null,"+"),pn.createElement(Tc,null,t.toLocaleString()," output"),pn.createElement("span",null,"="),pn.createElement(Tc,null,pn.createElement("strong",null,o.toLocaleString())," tokens")),pn.createElement(_C,null,pn.createElement(Ic,null,"$",n.toFixed(4)),pn.createElement("span",null,"\xB7"),pn.createElement(Ic,null,"\u20AA",i.toFixed(2))))};import Vn from"react";import{styled as No}from"storybook/theming";function xh(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var v$=No.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),$C=No.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),k$=No.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),C$=No.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})),T$=No.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),I$=No.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),F$=No.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),E$=No.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),UC=({data:e,color:t,compact:n})=>n?Vn.createElement($C,{color:t},e.summary):Vn.createElement(v$,null,Vn.createElement($C,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Vn.createElement(k$,null,e.mappings.map((r,o)=>Vn.createElement(Vn.Fragment,{key:o},Vn.createElement(C$,null,r.from," ",Vn.createElement(T$,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Vn.createElement(I$,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Vn.createElement(Vn.Fragment,null,e.defaults.map((r,o)=>Vn.createElement(F$,{key:o},Vn.createElement(E$,null,r.choice),Vn.createElement("span",null,"\u2014 ",r.why)))));var A$=ht.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),P$=ht.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),L$=ht.div({display:"flex",flexDirection:"column",gap:"4px"}),M$=ht.div({display:"flex",alignItems:"center",gap:"10px"}),B$=ht.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"})),HC=ht.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})),D$=ht.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),R$=ht.div({display:"flex",gap:"8px"}),z$=ht.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),N$=ht(To)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),O$=ht.div({display:"flex",gap:"4px"}),Ec=ht.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}})),_$=ht.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),$$=ht.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}})),U$=ht.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}`}})),j$=ht.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"})),Ac=ht.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}`})),H$=ht.img({width:"100%",height:"100%",objectFit:"contain"}),YC=ht.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)"}}})),WC=ht.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),VC=ht.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"})),yh=ht.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"})),Yne=ht.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"})),W$=ht.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),V$=ht.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})),G$=ht.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}})),q$=ht.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),Y$=ht.div({display:"flex",flexWrap:"wrap",gap:"6px"}),K$=ht.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})),X$=ht.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})),Q$=ht.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"}})),Kne=ht.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})),GC=({src:e,alt:t})=>{let[n,r]=Pc(!1);return Ce.createElement(Ce.Fragment,null,!n&&Ce.createElement(YC,null),Ce.createElement(H$,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function qC(e){return e>=90?"high":e>=70?"medium":"low"}function J$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var KC=({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[g,p]=Pc(()=>{let w=new Set;for(let A of e.mappings)A.confidence>=90&&w.add(A.storyId);return w}),[m,b]=Pc(""),[T,F]=Pc("all"),v=jC(()=>{let w=new Map;for(let A of t)w.set(A.id,{name:A.name,title:A.title});return w},[t]),D=jC(()=>{let w=e.mappings;if(T!=="all"&&(w=w.filter(A=>qC(A.confidence)===T)),m.trim()){let A=m.toLowerCase();w=w.filter(f=>{let k=v.get(f.storyId);return k?.name.toLowerCase().includes(A)||k?.title.toLowerCase().includes(A)||f.componentSetName.toLowerCase().includes(A)||f.figmaFrameName.toLowerCase().includes(A)})}return w},[e.mappings,T,m,v]),_=w=>{p(A=>{let f=new Set(A);return f.has(w)?f.delete(w):f.add(w),f})},$=()=>{let w=e.mappings.filter(A=>g.has(A.storyId));n(w)},L=e.mappings.filter(w=>w.confidence>=90).length,R=e.mappings.filter(w=>w.confidence>=70&&w.confidence<90).length,h=e.mappings.filter(w=>w.confidence<70).length,S=e.usage;return Ce.createElement(A$,null,Ce.createElement(P$,null,Ce.createElement(L$,null,Ce.createElement(M$,null,Ce.createElement(B$,null,"Auto-Map Results"),Ce.createElement(HC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Ce.createElement(HC,{variant:"danger"},e.unmatched.length," unmatched"),a&&Ce.createElement(X$,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),Ce.createElement(D$,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Ce.createElement(R$,null,a==="cache"&&o&&Ce.createElement(Q$,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),Ce.createElement(Mr,{onClick:r,variant:"ghost"},"Cancel"),Ce.createElement(Mr,{loading:i,onClick:$,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Ce.createElement(z$,null,Ce.createElement(N$,{type:"text",placeholder:"Filter stories...",value:m,onChange:w=>b(w.target.value)}),Ce.createElement(O$,null,Ce.createElement(Ec,{active:T==="all",onClick:()=>F("all")},"All ",e.mappings.length),L>0&&Ce.createElement(Ec,{active:T==="high",onClick:()=>F("high")},"\u226590% (",L,")"),R>0&&Ce.createElement(Ec,{active:T==="medium",onClick:()=>F("medium")},"70-89% (",R,")"),h>0&&Ce.createElement(Ec,{active:T==="low",onClick:()=>F("low")},"<70% (",h,")"))),Ce.createElement(_$,null,D.map(w=>{let A=v.get(w.storyId),f=qC(w.confidence),k=g.has(w.storyId),E=f==="low";return Ce.createElement($$,{key:w.storyId,dimmed:E&&!k},Ce.createElement(U$,{checked:k,onClick:()=>_(w.storyId)},k?"\u2713":""),(()=>{let x=c?.(w.storyId);return x?Ce.createElement(Ac,null,Ce.createElement(GC,{src:x,alt:A?.name||w.storyId})):l?Ce.createElement(Ac,null,Ce.createElement(YC,null)):Ce.createElement(j$,{bgColor:E?"#f1f5f9":"#eff6ff"},Ce.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:E?"#94a3b8":"#3b82f6"}},(A?.name||"?").substring(0,4)))})(),Ce.createElement(WC,null,Ce.createElement(VC,null,A?.name||w.storyId),Ce.createElement(yh,null,A?.title||"")),Ce.createElement(W$,null,"\u2192"),(()=>{let x=u?.(w.figmaNodeId),C=xh(w.reason),P=C.summary+(C.candidates?` (${C.candidates} candidates)`:"");return x?Ce.createElement(Ac,{title:P},Ce.createElement(GC,{src:x,alt:w.figmaFrameName})):Ce.createElement(Ac,{title:P},Ce.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),Ce.createElement(WC,null,Ce.createElement(VC,null,w.componentSetName),Ce.createElement(yh,null,w.figmaFrameName),Ce.createElement(UC,{data:xh(w.reason),color:J$(f)})),Ce.createElement(V$,{level:f},w.confidence,"%"),d&&Ce.createElement(G$,{onClick:()=>d(w.componentSetName)},"Browse"))}),e.unmatched.length>0&&Ce.createElement(q$,null,Ce.createElement(yh,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Ce.createElement(Y$,null,e.unmatched.map(w=>{let A=v.get(w);return Ce.createElement(K$,{key:w},Ce.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),A?`${A.name} (${A.title})`:w)})))),S&&a!=="cache"&&Ce.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Ce.createElement(Fc,{inputTokens:S.inputTokens||0,outputTokens:S.outputTokens||0,costUsd:S.costUsd||0})))};$e();Ne();import{useState as Oo,useCallback as _o,useRef as Z$}from"react";import{useStorybookApi as e4}from"storybook/manager-api";function XC({projectId:e}){let t=e4(),n=Z$(null),[r,o]=Oo(!1),[i,s]=Oo(!1),[a,u]=Oo(!1),[c,l]=Oo(null),[d,g]=Oo(null),[p,m]=Oo(null),[b,T]=Oo(""),[F,v]=Oo(null),D=_o(async()=>{let A=await fetch("/index.json");if(!A.ok)throw new Error("Failed to fetch Storybook index");let f=await A.json(),k=f.entries||f.stories||{},E=Object.keys(k).filter(P=>k[P].type==="story");y.debug(`[useAutoMap] Found ${E.length} stories in index.json`);let x=[];for(let P of E){let B=k[P],N=t.getData(P),I={...N?.initialArgs||{}},z=N?.argTypes||{};for(let[W,M]of Object.entries(z))if(!(W in I)){let ie=M;if(ie.defaultValue!==void 0)I[W]=ie.defaultValue;else if(ie.table?.defaultValue?.summary!==void 0){let K=ie.table.defaultValue.summary;K==="false"?I[W]=!1:K==="true"?I[W]=!0:I[W]=K}}x.push({id:P,name:B.name||P.split("--").pop()||P,title:B.title||"",initialArgs:I,argTypes:z})}let C=x.filter(P=>Object.keys(P.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${x.length} stories, ${C.length} with args`),x},[t]),_=_o(async()=>{if(!e)return!1;try{let A=Y(),f=localStorage.getItem("uicopilot_session_token");if(!f)return!1;let k=await fetch(`${A}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${f}`}});if(!k.ok)return!1;let E=await k.json();return E.hasSuggestions&&E.mappings?.length>0?(g(E),v("cache"),T(`Loaded ${E.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${E.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),$=_o(async A=>{o(!0),T("Collecting story information...");let f;try{if(f=await D(),A?.length&&(f=f.filter(E=>!A.includes(E.id)),y.debug(`[useAutoMap] After excluding mapped: ${f.length} stories`)),f.length===0){l("No unmapped stories found"),o(!1);return}m(f)}catch(E){l(E instanceof Error?E.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),T(`Analyzing ${f.length} stories against Figma components...`);let k=new AbortController;n.current=k;try{let E=Y(),x=localStorage.getItem("uicopilot_session_token");if(!x)throw new Error("Not authenticated");let C=await fetch(`${E}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({projectId:e,stories:f.map(B=>({id:B.id,name:B.name,title:B.title,initialArgs:B.initialArgs,argTypes:B.argTypes}))}),signal:k.signal});if(!C.ok){let B=await C.json();throw new Error(B.error||"Auto-map failed")}let P=await C.json();g(P),v("llm"),T(`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(E){if(E instanceof DOMException&&E.name==="AbortError"){T("Cancelled");return}l(E instanceof Error?E.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,D]),L=_o(async A=>{if(!e)return;if(l(null),g(null),v(null),o(!0),T("Checking for existing suggestions..."),await _()){o(!1);return}await $(A)},[e,_,$]),R=_o(async A=>{e&&(l(null),g(null),v(null),await $(A))},[e,$]),h=_o(async A=>{if(!(!e||A.length===0)){u(!0),T(`Applying ${A.length} mappings...`);try{let f=Y(),k=localStorage.getItem("uicopilot_session_token");if(!k)throw new Error("Not authenticated");let E=0;for(let x of A)try{(await fetch(`${f}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:JSON.stringify({projectId:e,storyId:x.storyId,figmaNodeId:x.figmaNodeId,name:x.figmaFrameName||x.componentSetName})})).ok?E++:y.warn(`[useAutoMap] Failed to apply mapping for ${x.storyId}`)}catch(C){y.error(`[useAutoMap] Error applying mapping for ${x.storyId}:`,C)}T(`Applied ${E}/${A.length} mappings`),y.debug(`[useAutoMap] Applied ${E}/${A.length} mappings`)}catch(f){l(f instanceof Error?f.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),S=_o(()=>{n.current?.abort()},[]),w=_o(()=>{g(null),m(null),l(null),T(""),v(null)},[]);return{collectAndMap:L,rerun:R,loadExisting:_,applyMappings:h,cancel:S,reset:w,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:b,source:F}}Ne();import{useState as bh,useEffect as t4,useRef as QC}from"react";var JC=2;async function n4(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 ZC(e){let[t,n]=bh({}),[r,o]=bh(0),[i,s]=bh(!1),a=QC(null),u=QC(""),c=e.join(",");return t4(()=>{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+=JC){let m=e.slice(p,p+JC),b=await Promise.all(m.map(F=>n4(F,l.signal).then(v=>({id:F,img:v}))));if(l.signal.aborted)break;let T={};for(let{id:F,img:v}of b)d++,v&&(T[F]=v);Object.keys(T).length>0&&n(F=>({...F,...T})),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 Sh,useEffect as fa,useMemo as r4,useCallback as o4}from"react";import{styled as i4}from"storybook/theming";Ne();var s4=i4.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.secondary,color:e.color.secondary},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Zi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=aa({projectId:r||"",enabled:e&&!!r}),d=be.useRef(!1);fa(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[g,p]=Sh(new Set),[m,b]=Sh(i||o[0]?.id||"");fa(()=>{i&&b(i)},[i]);let T=50,F=8,[v,D]=Sh({}),_=o4(f=>{D(k=>({...k,[f]:(k[f]||1)+1}))},[]);fa(()=>{D({})},[l.variantFilters]),fa(()=>{l.expandedSets.forEach(f=>{let k=l.variantChildren[f];if(!k||k.length===0)return;let E=k;l.variantFilters.some(P=>P.value)&&(E=k.filter(P=>P.variantProperties?l.variantFilters.every(B=>B.value?P.variantProperties?.[B.property]===B.value:!0):!1));let x=v[f]||1,C=E.slice(0,x*T).map(P=>P.id);for(let P=0;P<C.length;P+=F){let B=C.slice(P,P+F),N=P/F*300;N===0?l.fetchVariantThumbnails(f,B):setTimeout(()=>l.fetchVariantThumbnails(f,B),N)}})},[l.expandedSets,l.variantChildren,l.variantFilters,v]),fa(()=>{p(new Set)},[m]);let $=r4(()=>{let f=[];return l.filteredFrames.forEach(k=>{if(k.type==="COMPONENT_SET"&&k.children){let E=l.variantFilters.some(x=>x.value)?k.children.filter(x=>x.variantProperties?l.variantFilters.every(C=>C.value?x.variantProperties?.[C.property]===C.value:!0):!1):k.children;f.push(...E)}else f.push(k)}),f},[l.filteredFrames,l.variantFilters]),L=f=>{if(a)p(k=>{let E=new Set(k);return E.has(f.id)?E.delete(f.id):E.add(f.id),E});else{let k=l.resolveThumbnail(f.id);try{n({...f,thumbnail:k})}catch(E){y.error("[ComponentBrowserModal] onSelect threw error:",E)}t()}},R=()=>{let f=$.map(E=>E.id),k=f.every(E=>g.has(E));p(k?new Set:new Set(f))},h=()=>{if(u&&g.size>0){let f=$.filter(k=>g.has(k.id)).map(k=>({...k,thumbnail:l.resolveThumbnail(k.id)}));u(f),p(new Set)}},S=f=>{b(f),s?.(f)},w=f=>{f.target===f.currentTarget&&t()},A=o.find(f=>f.id===m);return e?be.createElement(Nk,{onClick:w},be.createElement(Ok,null,be.createElement(_k,null,be.createElement($k,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(Uk,{onClick:t},"\xD7"))),be.createElement(jk,null,l.error&&be.createElement(Kk,null,l.error),!l.error&&be.createElement(be.Fragment,null,o.length>0&&be.createElement(sC,null,be.createElement(aC,null,"Story:"),be.createElement(lC,{value:m,onChange:f=>S(f.target.value)},o.map(f=>be.createElement("option",{key:f.id,value:f.id},f.name,f.mappingsCount?` (${f.mappingsCount} linked)`:""))),A?.mappingsCount?be.createElement(cC,{hasMapping:!0},A.mappingsCount," frames linked"):null),be.createElement(qk,null,be.createElement(yc,null,be.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:f=>l.setShowComponentSets(f.target.checked)}),"Component Sets"),be.createElement(yc,null,be.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:f=>l.setShowFrames(f.target.checked)}),"Frames"),be.createElement(yc,null,be.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:f=>l.setShowComponents(f.target.checked)}),"Components"),l.availablePages.length>1&&be.createElement(Qi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:f=>l.setFigmaPage(f.target.value),style:{marginLeft:"auto"}},be.createElement("option",{value:""},"All pages"),l.availablePages.map(f=>be.createElement("option",{key:f,value:f},f)))),l.filterSuggestion&&be.createElement(uC,null,be.createElement(pC,null,"AI suggests:"),be.createElement(dC,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([f,k])=>`${f}=${k}`).join(", ")),be.createElement(gC,{onClick:l.applySuggestedFilters},"Apply"),be.createElement(fC,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&be.createElement(mC,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&be.createElement(Sc,null,be.createElement(pa,null,"Filters:"),l.availableFilters.map(({property:f,values:k})=>{let E=l.variantFilters.find(x=>x.property===f);return be.createElement(Qi,{key:f,isActive:!!E?.value,value:E?.value||"",onChange:x=>l.handleFilterChange(f,x.target.value)},be.createElement("option",{value:""},f),k.map(x=>be.createElement("option",{key:x,value:x},f,"=",x)))}),l.variantFilters.some(f=>f.value)&&be.createElement(wc,{onClick:l.clearFilters},"Clear All")),l.rateLimitError&&be.createElement("div",{style:{padding:"8px 12px",marginBottom:"8px",background:"rgba(234, 88, 12, 0.12)",border:"1px solid rgba(234, 88, 12, 0.3)",borderRadius:"6px",fontSize:"12px",color:"#ea580c"}},"\u26A0 Figma thumbnail previews unavailable \u2014"," ",l.rateLimitError,". You can still select by name."),be.createElement(Hk,{type:"text",placeholder:"Search frames...",value:l.search,onChange:f=>l.setSearch(f.target.value),autoFocus:!0}),a&&$.length>0&&be.createElement(hC,null,be.createElement(xC,{onClick:R},g.size===$.length?"Deselect All":"Select All Visible"),be.createElement(yC,null,g.size>0?`${g.size} selected of `:"Showing ",$.length," frames")),l.isLoading&&be.createElement(Zm,null,Array.from({length:6}).map((f,k)=>be.createElement(iC,{key:k},be.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},be.createElement(bc,{width:"100%",height:"100%"})),be.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},be.createElement(bc,{width:"80%",height:"16px"}),be.createElement(bc,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&be.createElement(Yk,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&be.createElement(Zm,null,l.filteredFrames.map(f=>be.createElement(da,{key:f.id,frame:f,thumbnail:l.thumbnails[f.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[f.id],variantChildren:l.variantChildren[f.id],variantFailed:l.variantFailed[f.id],isLoadingVariants:l.loadingVariants.has(f.id),isExpanded:l.expandedSets.has(f.id),isNew:l.recentlyAdded.has(f.name),onToggleExpand:l.toggleExpanded,onSelect:L,multiSelect:a,selectedFrames:g,variantFilters:l.variantFilters,variantPage:v[f.id]||1,onShowMore:_})),l.hasMore&&be.createElement(s4,{onClick:l.loadMore,disabled:l.loadingMore},l.loadingMore?"Loading...":`Show more (${l.totalFrames-l.frames.length} remaining)`)))),a&&be.createElement(bC,null,be.createElement(SC,{disabled:g.size===0,onClick:h},"Link ",g.size," Selected")))):null};ve();lt();var l4=nn.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}),c4=nn.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"})),u4=nn.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),p4=nn.div({display:"flex",alignItems:"center",gap:"20px"}),d4=nn.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),g4=nn.div({display:"flex",gap:"4px"}),e1=nn(Co)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),f4=nn(An)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),m4=nn.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),h4=nn.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),x4=nn.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),y4=nn.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),b4=nn.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),S4=nn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),w4=nn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),v4=nn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),k4=nn.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),C4=nn.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"}})),t1=nn.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"}})),n1=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=es("map"),[i,s]=es([]),[a,u]=es(!0),[c,l]=es(null),[d,g]=es(!1),[p,m]=es(null),b=XC({projectId:n}),{refreshMappings:T}=Ze(),{featureFlags:F}=ue(),v=Je.useMemo(()=>b.results?.mappings.map(x=>x.storyId)||[],[b.results]),D=ZC(v),_=$o(async()=>{u(!0);try{let x=await fetch("/index.json");if(!x.ok)throw new Error("Failed to fetch index.json");let C=await x.json(),P=C.entries||C.stories||{},B=Object.entries(P).filter(([,I])=>I.type==="story").map(([I,z])=>({id:I,name:z.name||I.split("--").pop()||I,title:z.title||"",importPath:z.importPath,componentTitle:z.title?.split("/").slice(0,-1).join("/")||z.title,figmaMapping:null}));try{let I=Y(),z=localStorage.getItem("uicopilot_session_token"),W=await re(`${I}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${z}`}});if(W.ok){let M=await W.json(),ie=new Map((M.mappings||[]).map(K=>[K.storyId,K]));B.forEach(K=>{let ae=ie.get(K.id);ae&&ae.figmaNodeId&&(K.figmaMapping={figmaNodeId:ae.figmaNodeId,figmaFrameName:ae.name||ae.figmaFrameName||""})})}}catch(I){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",I)}s(B);let N=B.find(I=>!I.figmaMapping);N?l(N.id):B.length>0&&l(B[0].id)}catch(x){console.error("[StoryMappingAssistant] Error fetching stories:",x)}finally{u(!1)}},[n]);a4(()=>{e&&_()},[e,_]);let $=$o((x,C,P)=>{s(I=>I.map(z=>z.id===x?{...z,figmaMapping:{figmaNodeId:C,figmaFrameName:P}}:z));let B=i.findIndex(I=>I.id===x),N=i.find((I,z)=>z>B&&!I.figmaMapping);N&&l(N.id)},[i]),L=$o(x=>{s(C=>C.map(P=>P.id===x?{...P,figmaMapping:null}:P))},[]),R=$o(x=>{l(x),o("map")},[]),h=$o(()=>{let x=i.filter(C=>C.figmaMapping).map(C=>C.id);b.collectAndMap(x)},[i,b]),S=$o(()=>{let x=i.filter(C=>C.figmaMapping).map(C=>C.id);g(!1),b.rerun(x)},[i,b]),w=$o(async x=>{await b.applyMappings(x),g(!1),b.reset(),_(),T()},[b,_,T]),A=$o(()=>{g(!1),b.reset()},[b]);Je.useEffect(()=>{b.results&&g(!0)},[b.results]);let f=x=>{x.target===x.currentTarget&&t()};if(!e)return null;let k=i.filter(x=>x.figmaMapping).length,E=i.length;return Je.createElement(Je.Fragment,null,Je.createElement(l4,{onClick:f},Je.createElement(c4,{onClick:x=>x.stopPropagation()},Je.createElement(u4,null,Je.createElement(p4,null,Je.createElement(d4,null,Je.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Je.createElement(g4,null,Je.createElement(e1,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Je.createElement(e1,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),Je.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},F.enableAutoMap&&!d&&!b.isCollecting&&!b.isMapping&&Je.createElement(C4,{onClick:h,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(f4,{onClick:t},"\xD7"))),Je.createElement(m4,null,(b.isCollecting||b.isMapping)&&Je.createElement(y4,null,Je.createElement(b4,null,Je.createElement(v4,null,Je.createElement(k4,null)),Je.createElement(S4,null,"Auto-mapping stories to Figma"),Je.createElement(w4,null,b.progress),Je.createElement(Mr,{onClick:b.cancel,variant:"ghost"},"Cancel"))),d&&b.results&&Je.createElement(KC,{results:b.results,stories:i,onApply:w,onCancel:A,onRerun:S,isApplying:b.isApplying,isRerunning:b.isCollecting||b.isMapping,source:b.source,resolveThumbnail:x=>b.results?.thumbnailUrls?.[x],resolveStoryScreenshot:x=>D.screenshots[x],isCapturingScreenshots:D.isCapturing,onBrowse:x=>m(x)}),!d&&!b.isCollecting&&!b.isMapping&&(r==="map"?Je.createElement(LC,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:$,projectId:n}):Je.createElement(RC,{stories:i,loading:a,onLink:R,onUnlink:L,projectId:n}))),Je.createElement(h4,null,Je.createElement(x4,null,Je.createElement("span",null,"Total: ",E," stories"),Je.createElement(t1,{type:"mapped"},Je.createElement("span",{className:"dot"}),k," mapped"),Je.createElement(t1,{type:"unmapped"},Je.createElement("span",{className:"dot"}),E-k," unmapped"))))),Je.createElement(Zi,{isOpen:!!p,onClose:()=>m(null),onSelect:()=>m(null),projectId:n,initialSearch:p||void 0}))};lt();var r1=nr.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}})),I4=nr.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),F4=nr.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),E4=nr.div({display:"flex",alignItems:"center",gap:"8px"}),A4=nr.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),P4=nr.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"})),L4=nr.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"})),M4=nr.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),B4=nr(Eu)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),D4=nr(Eu)(({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)"}})),R4=nr.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),z4=nr.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ce,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),N4=nr.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),o1=()=>{let[e,t]=Lc(!1),[n,r]=Lc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Xe(),{sessionToken:i}=Se();T4(()=>{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 L=await $.json(),R=L.entries||L.stories||{},h=Object.keys(R).filter(k=>R[k].type==="story").length,S=Object.keys(R).filter(k=>R[k].type==="story"),w=Y(),A=await re(`${w}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),f=0;if(A.ok){let k=await A.json(),E=k.mappings||k||[];if(Array.isArray(E)){let x=new Set(E.map(C=>C.storyId).filter(Boolean));f=S.filter(C=>x.has(C)).length}else{let x=await re(`${w}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(x.ok){let C=await x.json();f=Math.min(C.mappedStoriesCount||0,h)}}}r({totalStories:h,mappedStories:f,loading:!1})}catch($){console.error("[FigmaMappingsSection] Error fetching stats:",$),r(L=>({...L,loading:!1}))}},[a,u]=Lc(!1),[c,l]=Lc(!1),d=async()=>{!o||!i||l(!0)},g=async()=>{l(!1),u(!0);try{let $=Y(),L=await re(`${$}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!L.ok)throw new Error("Failed to fetch mappings");let h=(await L.json()).mappings||[];await Promise.all(h.map(S=>re(`${$}/api/mappings?id=${encodeURIComponent(S.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch($){console.error("[FigmaMappingsSection] Unlink all failed:",$)}finally{u(!1)}},p=()=>t(!0),m=()=>{t(!1),o&&i&&s()};if(!o)return It.createElement(r1,null,It.createElement(R4,null,"Select a project to link Figma designs"));let{totalStories:b,loading:T}=n,F=Math.min(n.mappedStories,b),v=F===0?"none":F>=b?"complete":"partial",D=b>0?Math.min(100,Math.round(F/b*100)):0,_=v==="none"?"Link designs":"Manage";return It.createElement(It.Fragment,null,It.createElement(r1,null,It.createElement(I4,null,It.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},It.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"}),It.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"}),It.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),It.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"}),It.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"}))),It.createElement(F4,null,It.createElement(M4,null,"Figma Mappings"),It.createElement(E4,null,T?It.createElement(It.Fragment,null,It.createElement(z4,null),It.createElement(N4,null,"Loading...")):It.createElement(It.Fragment,null,It.createElement(A4,null,It.createElement(P4,{percent:D,state:v})),It.createElement(L4,{state:v},`${F}/${b}`)))),F>0&&It.createElement(D4,{onClick:d,disabled:T||a},a?"Unlinking...":"Unlink All"),It.createElement(B4,{onClick:p,disabled:T},_)),e&&It.createElement(n1,{isOpen:e,onClose:m,projectId:o}),It.createElement(Hr,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:g,onCancel:()=>l(!1)}))};import oe,{useState as ci,useEffect as Mc,useCallback as i1,useRef as wh}from"react";import{styled as Gn}from"storybook/theming";ve();$e();lt();var vh=Gn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),kh=Gn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),Ch=Gn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Xre=Gn(Or)({padding:"5px 12px",fontSize:"12px"}),Th=Gn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),Bc=Gn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),O4=Gn.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})),_4=Gn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),Ih=Gn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),$4=Gn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),ma=Gn.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.negative}1a`,border:`1px solid ${e.color.negative}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.negative,lineHeight:"1.4"})),ha=Gn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),xa=Gn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),go=Gn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),s1=new Set,a1=()=>{let{userRole:e,featureFlags:t}=ue(),[n,r]=ci(null),[o,i]=ci(!0),[s,a]=ci(!1),[u,c]=ci(null),[l,d]=ci(!1),[g,p]=ci(!1),[m,b]=ci(!1),{selectedProjectId:T,projects:F}=Xe(),{sessionToken:v}=Se(),D=wh(null),_=wh(null),$=wh(null),L=i1(()=>{D.current&&(clearInterval(D.current),D.current=null),_.current&&(clearInterval(_.current),_.current=null),$.current&&(clearTimeout($.current),$.current=null)},[]);Mc(()=>L,[L]);let R=i1(async()=>{if(!(!T||!v))try{let C=Y(),P=await re(`${C}/api/figma/cache-status?projectId=${T}`,{headers:{Authorization:`Bearer ${v}`}});if(P.ok){let B=await P.json();r(B)}}catch(C){console.error("[FigmaCacheSection] Error:",C)}finally{i(!1)}},[T,v]);Mc(()=>{R()},[R]),Mc(()=>{if(o||s||!n||n.structureStatus!=="none"||!T||s1.has(T))return;let C=F.find(B=>B.id===T);(C?.figmaFileUrl||C?.figmaFileId)&&(s1.add(T),h())},[o,s,n?.structureStatus,T,F]),Mc(()=>{let C=n?.thumbnailProgress?.status,P=n?.enrichmentProgress?.status,B=n?.thumbnailProgress?.cached??0,N=n?.thumbnailProgress?.total??0,I=C==="in-progress"||C==="pending"||N>0&&B<N,z=P==="in-progress"||P==="pending",W=!n?.thumbnailProgress&&n?.structureStatus==="cached",M=n?.crawlProgress?.status==="crawling";if(!(M||I||z||W)||!M&&(!n||n.structureStatus==="none"))return;let K=setInterval(()=>{R()},3e3);return()=>{clearInterval(K)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.crawlProgress?.status,n?.structureStatus,R]);let h=async()=>{if(!(!T||!v)){a(!0),c(null);try{let C=Y(),P=await re(`${C}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:T})});if(!P.ok){if(P.status===403){let B=await P.json().catch(()=>({}));c(B.requiresAuth?"auth":"generic")}else c("generic");return}await R()}catch(C){console.error("[FigmaCacheSection] Crawl start error:",C),c("generic")}finally{a(!1)}}},S=async()=>{if(!(!T||!v)){d(!0);try{let C=Y(),P=await re(`${C}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:T})});console.log("[FigmaCacheSection] Cache invalidate response:",P.status),await re(`${C}/api/figma/frames/invalidate?projectId=${T}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`}}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null,crawlProgress:null})}catch(C){console.error("[FigmaCacheSection] Clear cache error:",C)}finally{d(!1)}}},w=async()=>{if(!(!T||!v)){L(),p(!0);try{let C=Y();await re(`${C}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:T})}),D.current=setInterval(async()=>{await R()},3e3),_.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(L(),p(!1),R())},3e3),$.current=setTimeout(()=>{L(),p(!1)},6e5)}catch(C){console.error("[FigmaCacheSection] Enrich error:",C),L(),p(!1)}}},A=async()=>{if(!(!T||!v)){b(!0);try{let C=Y();await re(`${C}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:T})}),await R()}catch(C){console.error("[FigmaCacheSection] Cancel error:",C)}finally{b(!1),p(!1),a(!1)}}},f=n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!T)return null;if(o)return oe.createElement(vh,null,oe.createElement(kh,null,oe.createElement(Ch,null,"Figma Cache")),oe.createElement(Th,null,oe.createElement(Bc,null,"Loading cache status\u2026")),oe.createElement(ha,null,oe.createElement(xa,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return oe.createElement(vh,null,oe.createElement(kh,null,oe.createElement(Ch,null,"Figma Cache"),oe.createElement(Mr,{loading:s,onClick:h,loadingText:"Loading..."},"\u21BB Load")),n?.crawlProgress?.status==="crawling"?oe.createElement(oe.Fragment,null,oe.createElement(ha,null,oe.createElement(xa,{percent:(n.crawlProgress.pagesTotal??0)>0?Math.round(n.crawlProgress.pagesDone/n.crawlProgress.pagesTotal*100):100,style:(n.crawlProgress.pagesTotal??0)>0?void 0:{opacity:.3}})),oe.createElement(go,null,oe.createElement("span",null,"Reading components from Figma\u2026"),oe.createElement("span",null,(n.crawlProgress.pagesTotal??0)>0?`page ${n.crawlProgress.pagesDone} of ${n.crawlProgress.pagesTotal}`:"starting\u2026"))):s?oe.createElement(oe.Fragment,null,oe.createElement(ha,null,oe.createElement(xa,{percent:100,style:{animation:"none",opacity:.3}})),oe.createElement(go,null,oe.createElement("span",null,"Starting crawl\u2026"))):oe.createElement(Th,null,oe.createElement(Bc,null,"No cache \u2014 click Load to fetch from Figma")),n?.crawlProgress?.status==="error"&&oe.createElement(ma,null,"Crawl failed",n.crawlProgress.error?`: ${n.crawlProgress.error}`:"",". Try Load again."),u==="auth"&&oe.createElement(ma,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&oe.createElement(ma,null,"Failed to load Figma cache. Check the browser console for details."));let k=C=>{let P=Date.now()-new Date(C).getTime(),B=Math.floor(P/6e4);if(B<1)return"just now";if(B<60)return`${B}m ago`;let N=Math.floor(B/60);return N<24?`${N}h ago`:`${Math.floor(N/24)}d ago`},E=n.cacheDiff,x=E&&(E.added.length>0||E.removed.length>0||E.renamed.length>0);return oe.createElement(vh,null,oe.createElement(kh,null,oe.createElement(Ch,null,"Figma Cache"," ",oe.createElement(O4,{status:n.structureStatus},n.structureStatus)),oe.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&oe.createElement(Mr,{loading:g,onClick:w,loadingText:"Enriching..."},"Enrich"),oe.createElement(Mr,{loading:l,onClick:S,variant:"ghost",loadingText:"Clearing..."},"Clear"),oe.createElement(Mr,{loading:s,onClick:h,loadingText:"Reloading..."},"\u21BB Reload"),f&&oe.createElement(Mr,{loading:m,onClick:A,variant:"ghost",loadingText:"Cancelling..."},"\u2715 Cancel"))),s&&oe.createElement(go,null,oe.createElement("span",null,"Downloading structure from Figma...")),u==="auth"&&oe.createElement(ma,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&oe.createElement(ma,null,"Failed to reload Figma cache. Check the browser console for details."),oe.createElement(Th,null,oe.createElement(Bc,null,oe.createElement("strong",null,n.componentSetCount)," component sets"),oe.createElement(Bc,null,oe.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&oe.createElement($4,null,"Updated ",k(n.structureCachedAt))),x&&oe.createElement(_4,null,"Since last reload:"," ",E.added.length>0&&oe.createElement(Ih,{type:"added"},"+",E.added.length," added"),E.added.length>0&&E.removed.length>0&&" \xB7 ",E.removed.length>0&&oe.createElement(Ih,{type:"removed"},"\u2212",E.removed.length," removed"),(E.added.length>0||E.removed.length>0)&&E.renamed.length>0&&" \xB7 ",E.renamed.length>0&&oe.createElement(Ih,{type:"renamed"},E.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&oe.createElement(oe.Fragment,null,oe.createElement(ha,null,oe.createElement(xa,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),oe.createElement(go,null,oe.createElement("span",null,"Variant thumbnails: caching to CDN\u2026",n.thumbnailProgress.currentName&&oe.createElement(oe.Fragment,null," ",n.thumbnailProgress.currentName)),oe.createElement("span",null,n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," variants"))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&oe.createElement(go,null,oe.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached===0)&&oe.createElement(go,null,oe.createElement("span",null,"Variant thumbnails: not yet cached",n.thumbnailProgress?.total?` (${n.thumbnailProgress.total} components)`:""," ","\u2014 click Reload to generate")),n.thumbnailProgress&&n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached>0&&oe.createElement(go,null,oe.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN (partial)")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&oe.createElement(oe.Fragment,null,oe.createElement(ha,null,oe.createElement(xa,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),oe.createElement(go,null,oe.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&oe.createElement(oe.Fragment,null," ",n.enrichmentProgress.currentName)),oe.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&oe.createElement(oe.Fragment,null,oe.createElement(go,null,oe.createElement("span",null,"AI descriptions: ",n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&oe.createElement("div",{style:{marginTop:"6px"}},oe.createElement(Fc,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import wt,{useState as ts}from"react";import{styled as Vr}from"storybook/theming";ve();$e();lt();var Fh=Vr.div({padding:"12px 16px"}),U4=Vr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),l1=Vr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),c1=Vr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:ce,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),j4=Vr.div({display:"flex",gap:"8px",alignItems:"center"}),H4=Vr.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:ce,boxShadow:`0 0 0 1px ${ce}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),u1=Vr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),W4=Vr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:ce,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),V4=Vr.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})),G4=Vr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),p1=({onConnected:e})=>{let{sessionToken:t}=Se(),[n,r]=ts(!1),[o,i]=ts(""),[s,a]=ts(!1),[u,c]=ts(null),[l,d]=ts(null),[g,p]=ts(!1),m=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let b=Y(),T=await re(`${b}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),F=await T.json();if(!T.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?wt.createElement(Fh,null,wt.createElement(l1,null,"Figma Personal Access Token"),wt.createElement(V4,null,wt.createElement("span",null,"\u2713 Connected as ",wt.createElement("strong",null,l)),wt.createElement(G4,{onClick:()=>{d(null),c(null)}},"Change token"))):n?wt.createElement(Fh,null,wt.createElement(U4,null,wt.createElement(l1,null,"Figma Personal Access Token"),wt.createElement(c1,{onClick:()=>p(!g)},g?"Hide instructions":"How to generate")),g&&wt.createElement(W4,null,wt.createElement("ol",null,wt.createElement("li",null,"Open ",wt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),wt.createElement("li",null,"Click the ",wt.createElement("strong",null,"Security")," tab"),wt.createElement("li",null,"Scroll to ",wt.createElement("strong",null,"Personal access tokens")),wt.createElement("li",null,"Click ",wt.createElement("strong",null,"Generate new token")),wt.createElement("li",null,"Enable ",wt.createElement("strong",null,"File content: Read only")," under Scopes"),wt.createElement("li",null,"Copy the token and paste it below"))),wt.createElement(j4,null,wt.createElement(H4,{type:"password",value:o,onChange:b=>i(b.target.value),placeholder:"figd_...",onKeyDown:b=>{b.key==="Enter"&&o.trim()&&m()}}),wt.createElement(on,{onClick:m,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&wt.createElement(u1,{variant:u.type},u.message),wt.createElement(u1,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):wt.createElement(Fh,null,wt.createElement(c1,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};ve();$e();lt();var Y4=xt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},xt.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"}),xt.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"}),xt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),xt.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"}),xt.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"})),Eh=Br.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),K4=Br.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),X4=Br.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),Q4=Br.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),Ah=Br.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),J4=Br.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"})),Z4=Br.div({display:"flex",alignItems:"center",gap:"8px"}),e5=Br(En)(({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"})),t5=Br.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),hoe=Br.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"}}),n5=Br.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}})),g1=({hideHeader:e=!1})=>{let{sessionToken:t}=Se(),[n,r]=ya(!1),[o,i]=ya(0),[s,a]=ya(()=>{try{let b=sessionStorage.getItem("uicopilot_figma_connection");if(b){let{connected:T,ts:F}=JSON.parse(b);if(Date.now()-F<300*1e3)return T}}catch{}return null}),[u,c]=ya(!1),[l,d]=ya(!1);q4(()=>{if(!t)return;let b=Y();re(`${b}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(T=>T.json()).then(T=>{let F=!!T.connected;c(!!T.expired),a(F);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:F,ts:Date.now()}))}catch{}}).catch(()=>a(!1))},[t]);let g=d1(()=>{let b=Y(),T=`${b}/api/auth/figma/login?addon=true`;window.open(T,"figma-oauth","width=600,height=700,left=200,top=100");let F=setInterval(async()=>{try{(await(await re(`${b}/api/figma/connection-status`,{headers:t?{Authorization:`Bearer ${t}`}:{}})).json()).connected&&(clearInterval(F),a(!0))}catch{}},2e3);setTimeout(()=>clearInterval(F),300*1e3)},[t]),p=d1(async()=>{try{r(!0);let b=Y(),T=await re(`${b}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(T.ok||T.status===404){a(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{r(!1)}},[t]),m=e?null:xt.createElement(K4,null,xt.createElement(X4,null,Y4),xt.createElement(Q4,null,"Figma Integration"));return s===null?xt.createElement(Eh,null,m,xt.createElement(Ah,null,xt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):s===!1?xt.createElement(Eh,null,m,xt.createElement(Ah,null,xt.createElement(t5,null,u&&xt.createElement("div",{style:{padding:"10px 12px",backgroundColor:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#92400e"}},"\u26A0\uFE0F Your Figma access has expired. Please reconnect."),xt.createElement("div",{style:{padding:"8px 10px",backgroundColor:"rgba(100, 116, 139, 0.1)",border:"1px solid rgba(100, 116, 139, 0.3)",borderRadius:"6px",fontSize:"11px",lineHeight:1.4,color:"#64748b"}},"Requires a Figma ",xt.createElement("strong",null,"Dev or Full seat"),". Free/Viewer seats can't grant design-read access."),xt.createElement(on,{onClick:g,style:{width:"100%"}},u?"Reconnect Figma":"Connect with Figma"),xt.createElement(n5,null,"or"),xt.createElement(p1,{onConnected:()=>a(!0)})))):xt.createElement(Eh,null,m,xt.createElement(J4,null,xt.createElement(Z4,null,xt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),xt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),xt.createElement(e5,{onClick:()=>d(!0),disabled:n},n?"Disconnecting...":"Disconnect")),xt.createElement(Hr,{isOpen:l,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:()=>{d(!1),p()},onCancel:()=>d(!1)}),xt.createElement(Ah,null,xt.createElement(zk,{onFigmaFileChanged:()=>i(b=>b+1)}),xt.createElement(o1,{refreshKey:o}),xt.createElement(a1,null)))};ve();ln();var i5=fr.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"}),s5=fr.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"})),a5=fr.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})),l5=fr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),c5=fr(An)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),u5=fr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),f1=fr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),m1=fr.div({display:"flex",alignItems:"center",gap:"10px"}),h1=fr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),p5=fr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:ce,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),d5=fr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),x1=fr.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"}})),y1=({onClose:e})=>{let{isConnected:t}=Se(),{selectedProjectId:n}=Xe(),r=o5(t);return r5(()=>{!r.current&&t&&n&&e(),r.current=t},[t,n,e]),Bt.createElement(i5,{onClick:e},Bt.createElement(s5,{onClick:o=>o.stopPropagation()},Bt.createElement(a5,null,Bt.createElement(l5,null,"Settings"),Bt.createElement(c5,{onClick:e,title:"Close settings"},"\xD7")),Bt.createElement(u5,null,Bt.createElement(f1,null,Bt.createElement(m1,null,Bt.createElement(p5,null,"UI"),Bt.createElement(h1,null,Et.NAME)),Bt.createElement(x1,null,Bt.createElement(Pk,{onConnect:e}),t&&Bt.createElement(Dk,null))),t&&n&&Bt.createElement(f1,null,Bt.createElement(m1,null,Bt.createElement(d5,null,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"}))),Bt.createElement(h1,null,"Figma Integration")),Bt.createElement(x1,null,Bt.createElement(g1,{hideHeader:!0}))))))};import ut,{useEffect as A1,useMemo as _5,useState as $5,useRef as U5}from"react";import{styled as Mn,keyframes as j5}from"storybook/theming";ve();ln();ln();function Ph(e){let t=e.complianceScore??0;if(!e.issues||e.issues.length===0)return{score:t,band:e.issues?"A":void 0};let n=Xl(e.issues.map(r=>({...r,dismissed:r.dismissed??!1})));return{score:Math.min(t,io[n]),band:n}}ve();import Qt,{useState as g5}from"react";import{styled as qn}from"storybook/theming";var fo=[{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",provider:"anthropic",description:"Latest Claude Sonnet \u2014 best balance of speed and quality"},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Current default \u2014 proven for design comparison"},{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 f5=qn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),m5=qn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),h5=qn.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"}}),x5=qn.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}})),y5=qn.div({position:"relative",display:"inline-block"}),b5=qn.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}})),S5=qn.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"})),Lh=qn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),Mh=qn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),w5=qn.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}})),v5=qn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),k5=qn.div({flex:1,minWidth:0}),C5=qn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),T5=qn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),I5=5,b1=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ue(),[r,o]=g5(!1),i=fo.filter(p=>p.provider==="anthropic"&&!e.includes(p.id)),s=fo.filter(p=>p.provider==="openai"&&!e.includes(p.id)),a=fo.filter(p=>p.provider==="google"&&!e.includes(p.id)),u=fo.filter(p=>e.includes(p.id)),c=e.length<I5,l=(p,m)=>{m.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let m=e.includes(p);m&&e.length===1||!m&&!c||n||(t(p),o(!1))},g=p=>{let m=e.includes(p.id),b=m&&e.length===1,T=n||b||!m&&!c;return Qt.createElement(w5,{key:p.id,disabled:T,onClick:()=>d(p.id)},Qt.createElement(v5,{type:"checkbox",checked:m,disabled:T,onChange:()=>{},onClick:F=>F.stopPropagation()}),Qt.createElement(k5,null,Qt.createElement(C5,null,p.name),p.description&&Qt.createElement(T5,null,p.description)))};return Qt.createElement(f5,null,Qt.createElement(y5,null,Qt.createElement(b5,{disabled:n,isOpen:r,onClick:()=>o(!r)},Qt.createElement("span",null,"Select model"),Qt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Qt.createElement(S5,null,Qt.createElement(Lh,null,Qt.createElement(Mh,null,"Anthropic"),i.map(g)),Qt.createElement(Lh,null,Qt.createElement(Mh,null,"OpenAI"),s.map(g)),Qt.createElement(Lh,null,Qt.createElement(Mh,null,"Google"),a.map(g)))),Qt.createElement(m5,null,u.map(p=>Qt.createElement(h5,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Qt.createElement(x5,{disabled:n,onClick:m=>l(p.id,m),title:"Remove model"},"\xD7")))))};ln();import De,{useState as F5,useEffect as E5}from"react";import{styled as rn,keyframes as ns}from"storybook/theming";ve();var A5=ns`
44
+ `,b$=NC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${y$} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),S$=NC.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}}})),Mr=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>zC.createElement(S$,{variant:r,disabled:t||e,onClick:n},e&&zC.createElement(b$,null),e&&i?i:o);$e();import pn from"react";import{styled as ma}from"storybook/theming";var OC=ma.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"})),w$=ma.div({display:"flex",alignItems:"center",gap:"12px"}),Ic=ma.span({whiteSpace:"nowrap"}),_C=ma.div({display:"flex",alignItems:"center",gap:"8px"}),Fc=ma.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Ec=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*Ww;return r?pn.createElement(OC,null,pn.createElement(Ic,null,o.toLocaleString()," tokens"),pn.createElement(_C,null,pn.createElement(Fc,null,"$",n.toFixed(4)),pn.createElement("span",null,"\xB7"),pn.createElement(Fc,null,"\u20AA",i.toFixed(2)))):pn.createElement(OC,null,pn.createElement(w$,null,pn.createElement(Ic,null,e.toLocaleString()," input"),pn.createElement("span",null,"+"),pn.createElement(Ic,null,t.toLocaleString()," output"),pn.createElement("span",null,"="),pn.createElement(Ic,null,pn.createElement("strong",null,o.toLocaleString())," tokens")),pn.createElement(_C,null,pn.createElement(Fc,null,"$",n.toFixed(4)),pn.createElement("span",null,"\xB7"),pn.createElement(Fc,null,"\u20AA",i.toFixed(2))))};import Gn from"react";import{styled as No}from"storybook/theming";function xh(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var v$=No.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),$C=No.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),k$=No.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),C$=No.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})),T$=No.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),I$=No.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),F$=No.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),E$=No.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),UC=({data:e,color:t,compact:n})=>n?Gn.createElement($C,{color:t},e.summary):Gn.createElement(v$,null,Gn.createElement($C,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Gn.createElement(k$,null,e.mappings.map((r,o)=>Gn.createElement(Gn.Fragment,{key:o},Gn.createElement(C$,null,r.from," ",Gn.createElement(T$,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Gn.createElement(I$,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Gn.createElement(Gn.Fragment,null,e.defaults.map((r,o)=>Gn.createElement(F$,{key:o},Gn.createElement(E$,null,r.choice),Gn.createElement("span",null,"\u2014 ",r.why)))));var A$=ht.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),P$=ht.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),L$=ht.div({display:"flex",flexDirection:"column",gap:"4px"}),M$=ht.div({display:"flex",alignItems:"center",gap:"10px"}),B$=ht.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"})),HC=ht.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})),D$=ht.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),R$=ht.div({display:"flex",gap:"8px"}),z$=ht.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),N$=ht(To)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),O$=ht.div({display:"flex",gap:"4px"}),Ac=ht.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}})),_$=ht.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),$$=ht.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}})),U$=ht.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}`}})),j$=ht.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"})),Pc=ht.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}`})),H$=ht.img({width:"100%",height:"100%",objectFit:"contain"}),YC=ht.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)"}}})),WC=ht.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),VC=ht.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"})),yh=ht.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"})),Xne=ht.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"})),W$=ht.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),V$=ht.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})),G$=ht.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}})),q$=ht.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),Y$=ht.div({display:"flex",flexWrap:"wrap",gap:"6px"}),K$=ht.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})),X$=ht.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})),Q$=ht.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"}})),Qne=ht.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})),GC=({src:e,alt:t})=>{let[n,r]=Lc(!1);return Ce.createElement(Ce.Fragment,null,!n&&Ce.createElement(YC,null),Ce.createElement(H$,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function qC(e){return e>=90?"high":e>=70?"medium":"low"}function J$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var KC=({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[g,p]=Lc(()=>{let w=new Set;for(let A of e.mappings)A.confidence>=90&&w.add(A.storyId);return w}),[h,b]=Lc(""),[I,F]=Lc("all"),v=jC(()=>{let w=new Map;for(let A of t)w.set(A.id,{name:A.name,title:A.title});return w},[t]),D=jC(()=>{let w=e.mappings;if(I!=="all"&&(w=w.filter(A=>qC(A.confidence)===I)),h.trim()){let A=h.toLowerCase();w=w.filter(f=>{let k=v.get(f.storyId);return k?.name.toLowerCase().includes(A)||k?.title.toLowerCase().includes(A)||f.componentSetName.toLowerCase().includes(A)||f.figmaFrameName.toLowerCase().includes(A)})}return w},[e.mappings,I,h,v]),N=w=>{p(A=>{let f=new Set(A);return f.has(w)?f.delete(w):f.add(w),f})},$=()=>{let w=e.mappings.filter(A=>g.has(A.storyId));n(w)},M=e.mappings.filter(w=>w.confidence>=90).length,z=e.mappings.filter(w=>w.confidence>=70&&w.confidence<90).length,m=e.mappings.filter(w=>w.confidence<70).length,S=e.usage;return Ce.createElement(A$,null,Ce.createElement(P$,null,Ce.createElement(L$,null,Ce.createElement(M$,null,Ce.createElement(B$,null,"Auto-Map Results"),Ce.createElement(HC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Ce.createElement(HC,{variant:"danger"},e.unmatched.length," unmatched"),a&&Ce.createElement(X$,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),Ce.createElement(D$,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Ce.createElement(R$,null,a==="cache"&&o&&Ce.createElement(Q$,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),Ce.createElement(Mr,{onClick:r,variant:"ghost"},"Cancel"),Ce.createElement(Mr,{loading:i,onClick:$,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Ce.createElement(z$,null,Ce.createElement(N$,{type:"text",placeholder:"Filter stories...",value:h,onChange:w=>b(w.target.value)}),Ce.createElement(O$,null,Ce.createElement(Ac,{active:I==="all",onClick:()=>F("all")},"All ",e.mappings.length),M>0&&Ce.createElement(Ac,{active:I==="high",onClick:()=>F("high")},"\u226590% (",M,")"),z>0&&Ce.createElement(Ac,{active:I==="medium",onClick:()=>F("medium")},"70-89% (",z,")"),m>0&&Ce.createElement(Ac,{active:I==="low",onClick:()=>F("low")},"<70% (",m,")"))),Ce.createElement(_$,null,D.map(w=>{let A=v.get(w.storyId),f=qC(w.confidence),k=g.has(w.storyId),E=f==="low";return Ce.createElement($$,{key:w.storyId,dimmed:E&&!k},Ce.createElement(U$,{checked:k,onClick:()=>N(w.storyId)},k?"\u2713":""),(()=>{let x=c?.(w.storyId);return x?Ce.createElement(Pc,null,Ce.createElement(GC,{src:x,alt:A?.name||w.storyId})):l?Ce.createElement(Pc,null,Ce.createElement(YC,null)):Ce.createElement(j$,{bgColor:E?"#f1f5f9":"#eff6ff"},Ce.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:E?"#94a3b8":"#3b82f6"}},(A?.name||"?").substring(0,4)))})(),Ce.createElement(WC,null,Ce.createElement(VC,null,A?.name||w.storyId),Ce.createElement(yh,null,A?.title||"")),Ce.createElement(W$,null,"\u2192"),(()=>{let x=u?.(w.figmaNodeId),T=xh(w.reason),P=T.summary+(T.candidates?` (${T.candidates} candidates)`:"");return x?Ce.createElement(Pc,{title:P},Ce.createElement(GC,{src:x,alt:w.figmaFrameName})):Ce.createElement(Pc,{title:P},Ce.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),Ce.createElement(WC,null,Ce.createElement(VC,null,w.componentSetName),Ce.createElement(yh,null,w.figmaFrameName),Ce.createElement(UC,{data:xh(w.reason),color:J$(f)})),Ce.createElement(V$,{level:f},w.confidence,"%"),d&&Ce.createElement(G$,{onClick:()=>d(w.componentSetName)},"Browse"))}),e.unmatched.length>0&&Ce.createElement(q$,null,Ce.createElement(yh,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Ce.createElement(Y$,null,e.unmatched.map(w=>{let A=v.get(w);return Ce.createElement(K$,{key:w},Ce.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),A?`${A.name} (${A.title})`:w)})))),S&&a!=="cache"&&Ce.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Ce.createElement(Ec,{inputTokens:S.inputTokens||0,outputTokens:S.outputTokens||0,costUsd:S.costUsd||0})))};$e();Ne();import{useState as Oo,useCallback as _o,useRef as Z$}from"react";import{useStorybookApi as e4}from"storybook/manager-api";function XC({projectId:e}){let t=e4(),n=Z$(null),[r,o]=Oo(!1),[i,s]=Oo(!1),[a,u]=Oo(!1),[c,l]=Oo(null),[d,g]=Oo(null),[p,h]=Oo(null),[b,I]=Oo(""),[F,v]=Oo(null),D=_o(async()=>{let A=await fetch("/index.json");if(!A.ok)throw new Error("Failed to fetch Storybook index");let f=await A.json(),k=f.entries||f.stories||{},E=Object.keys(k).filter(P=>k[P].type==="story");y.debug(`[useAutoMap] Found ${E.length} stories in index.json`);let x=[];for(let P of E){let B=k[P],_=t.getData(P),C={..._?.initialArgs||{}},R=_?.argTypes||{};for(let[H,L]of Object.entries(R))if(!(H in C)){let ie=L;if(ie.defaultValue!==void 0)C[H]=ie.defaultValue;else if(ie.table?.defaultValue?.summary!==void 0){let K=ie.table.defaultValue.summary;K==="false"?C[H]=!1:K==="true"?C[H]=!0:C[H]=K}}x.push({id:P,name:B.name||P.split("--").pop()||P,title:B.title||"",initialArgs:C,argTypes:R})}let T=x.filter(P=>Object.keys(P.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${x.length} stories, ${T.length} with args`),x},[t]),N=_o(async()=>{if(!e)return!1;try{let A=Y(),f=localStorage.getItem("uicopilot_session_token");if(!f)return!1;let k=await fetch(`${A}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${f}`}});if(!k.ok)return!1;let E=await k.json();return E.hasSuggestions&&E.mappings?.length>0?(g(E),v("cache"),I(`Loaded ${E.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${E.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),$=_o(async A=>{o(!0),I("Collecting story information...");let f;try{if(f=await D(),A?.length&&(f=f.filter(E=>!A.includes(E.id)),y.debug(`[useAutoMap] After excluding mapped: ${f.length} stories`)),f.length===0){l("No unmapped stories found"),o(!1);return}h(f)}catch(E){l(E instanceof Error?E.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),I(`Analyzing ${f.length} stories against Figma components...`);let k=new AbortController;n.current=k;try{let E=Y(),x=localStorage.getItem("uicopilot_session_token");if(!x)throw new Error("Not authenticated");let T=await fetch(`${E}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({projectId:e,stories:f.map(B=>({id:B.id,name:B.name,title:B.title,initialArgs:B.initialArgs,argTypes:B.argTypes}))}),signal:k.signal});if(!T.ok){let B=await T.json();throw new Error(B.error||"Auto-map failed")}let P=await T.json();g(P),v("llm"),I(`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(E){if(E instanceof DOMException&&E.name==="AbortError"){I("Cancelled");return}l(E instanceof Error?E.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,D]),M=_o(async A=>{if(!e)return;if(l(null),g(null),v(null),o(!0),I("Checking for existing suggestions..."),await N()){o(!1);return}await $(A)},[e,N,$]),z=_o(async A=>{e&&(l(null),g(null),v(null),await $(A))},[e,$]),m=_o(async A=>{if(!(!e||A.length===0)){u(!0),I(`Applying ${A.length} mappings...`);try{let f=Y(),k=localStorage.getItem("uicopilot_session_token");if(!k)throw new Error("Not authenticated");let E=0;for(let x of A)try{(await fetch(`${f}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:JSON.stringify({projectId:e,storyId:x.storyId,figmaNodeId:x.figmaNodeId,name:x.figmaFrameName||x.componentSetName})})).ok?E++:y.warn(`[useAutoMap] Failed to apply mapping for ${x.storyId}`)}catch(T){y.error(`[useAutoMap] Error applying mapping for ${x.storyId}:`,T)}I(`Applied ${E}/${A.length} mappings`),y.debug(`[useAutoMap] Applied ${E}/${A.length} mappings`)}catch(f){l(f instanceof Error?f.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),S=_o(()=>{n.current?.abort()},[]),w=_o(()=>{g(null),h(null),l(null),I(""),v(null)},[]);return{collectAndMap:M,rerun:z,loadExisting:N,applyMappings:m,cancel:S,reset:w,isCollecting:r,isMapping:i,isApplying:a,error:c,results:d,manifest:p,progress:b,source:F}}Ne();import{useState as bh,useEffect as t4,useRef as QC}from"react";var JC=2;async function n4(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 ZC(e){let[t,n]=bh({}),[r,o]=bh(0),[i,s]=bh(!1),a=QC(null),u=QC(""),c=e.join(",");return t4(()=>{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+=JC){let h=e.slice(p,p+JC),b=await Promise.all(h.map(F=>n4(F,l.signal).then(v=>({id:F,img:v}))));if(l.signal.aborted)break;let I={};for(let{id:F,img:v}of b)d++,v&&(I[F]=v);Object.keys(I).length>0&&n(F=>({...F,...I})),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 Sh,useEffect as ha,useMemo as r4,useCallback as o4}from"react";import{styled as i4}from"storybook/theming";Ne();var s4=i4.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.secondary,color:e.color.secondary},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),Zi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=ca({projectId:r||"",enabled:e&&!!r}),d=be.useRef(!1);ha(()=>{e&&c&&!d.current&&(l.setSearch(c),d.current=!0),e||(d.current=!1)},[e,c]);let[g,p]=Sh(new Set),[h,b]=Sh(i||o[0]?.id||"");ha(()=>{i&&b(i)},[i]);let I=50,F=8,[v,D]=Sh({}),N=o4(f=>{D(k=>({...k,[f]:(k[f]||1)+1}))},[]);ha(()=>{D({})},[l.variantFilters]),ha(()=>{l.expandedSets.forEach(f=>{let k=l.variantChildren[f];if(!k||k.length===0)return;let E=k;l.variantFilters.some(P=>P.value)&&(E=k.filter(P=>P.variantProperties?l.variantFilters.every(B=>B.value?P.variantProperties?.[B.property]===B.value:!0):!1));let x=v[f]||1,T=E.slice(0,x*I).map(P=>P.id);for(let P=0;P<T.length;P+=F){let B=T.slice(P,P+F),_=P/F*300;_===0?l.fetchVariantThumbnails(f,B):setTimeout(()=>l.fetchVariantThumbnails(f,B),_)}})},[l.expandedSets,l.variantChildren,l.variantFilters,v]),ha(()=>{p(new Set)},[h]);let $=r4(()=>{let f=[];return l.filteredFrames.forEach(k=>{if(k.type==="COMPONENT_SET"&&k.children){let E=l.variantFilters.some(x=>x.value)?k.children.filter(x=>x.variantProperties?l.variantFilters.every(T=>T.value?x.variantProperties?.[T.property]===T.value:!0):!1):k.children;f.push(...E)}else f.push(k)}),f},[l.filteredFrames,l.variantFilters]),M=f=>{if(a)p(k=>{let E=new Set(k);return E.has(f.id)?E.delete(f.id):E.add(f.id),E});else{let k=l.resolveThumbnail(f.id);try{n({...f,thumbnail:k})}catch(E){y.error("[ComponentBrowserModal] onSelect threw error:",E)}t()}},z=()=>{let f=$.map(E=>E.id),k=f.every(E=>g.has(E));p(k?new Set:new Set(f))},m=()=>{if(u&&g.size>0){let f=$.filter(k=>g.has(k.id)).map(k=>({...k,thumbnail:l.resolveThumbnail(k.id)}));u(f),p(new Set)}},S=f=>{b(f),s?.(f)},w=f=>{f.target===f.currentTarget&&t()},A=o.find(f=>f.id===h);return e?be.createElement(Nk,{onClick:w},be.createElement(Ok,null,be.createElement(_k,null,be.createElement($k,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(Uk,{onClick:t},"\xD7"))),be.createElement(jk,null,l.error&&be.createElement(Kk,null,l.error),!l.error&&be.createElement(be.Fragment,null,o.length>0&&be.createElement(sC,null,be.createElement(aC,null,"Story:"),be.createElement(lC,{value:h,onChange:f=>S(f.target.value)},o.map(f=>be.createElement("option",{key:f.id,value:f.id},f.name,f.mappingsCount?` (${f.mappingsCount} linked)`:""))),A?.mappingsCount?be.createElement(cC,{hasMapping:!0},A.mappingsCount," frames linked"):null),be.createElement(qk,null,be.createElement(bc,null,be.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:f=>l.setShowComponentSets(f.target.checked)}),"Component Sets"),be.createElement(bc,null,be.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:f=>l.setShowFrames(f.target.checked)}),"Frames"),be.createElement(bc,null,be.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:f=>l.setShowComponents(f.target.checked)}),"Components"),l.availablePages.length>1&&be.createElement(Qi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:f=>l.setFigmaPage(f.target.value),style:{marginLeft:"auto"}},be.createElement("option",{value:""},"All pages"),l.availablePages.map(f=>be.createElement("option",{key:f,value:f},f)))),l.filterSuggestion&&be.createElement(uC,null,be.createElement(pC,null,"AI suggests:"),be.createElement(dC,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([f,k])=>`${f}=${k}`).join(", ")),be.createElement(gC,{onClick:l.applySuggestedFilters},"Apply"),be.createElement(fC,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&be.createElement(mC,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&be.createElement(wc,null,be.createElement(ga,null,"Filters:"),l.availableFilters.map(({property:f,values:k})=>{let E=l.variantFilters.find(x=>x.property===f);return be.createElement(Qi,{key:f,isActive:!!E?.value,value:E?.value||"",onChange:x=>l.handleFilterChange(f,x.target.value)},be.createElement("option",{value:""},f),k.map(x=>be.createElement("option",{key:x,value:x},f,"=",x)))}),l.variantFilters.some(f=>f.value)&&be.createElement(vc,{onClick:l.clearFilters},"Clear All")),l.rateLimitError&&be.createElement("div",{style:{padding:"8px 12px",marginBottom:"8px",background:"rgba(234, 88, 12, 0.12)",border:"1px solid rgba(234, 88, 12, 0.3)",borderRadius:"6px",fontSize:"12px",color:"#ea580c"}},"\u26A0 Figma thumbnail previews unavailable \u2014"," ",l.rateLimitError,". You can still select by name."),be.createElement(Hk,{type:"text",placeholder:"Search frames...",value:l.search,onChange:f=>l.setSearch(f.target.value),autoFocus:!0}),a&&$.length>0&&be.createElement(hC,null,be.createElement(xC,{onClick:z},g.size===$.length?"Deselect All":"Select All Visible"),be.createElement(yC,null,g.size>0?`${g.size} selected of `:"Showing ",$.length," frames")),l.isLoading&&be.createElement(Zm,null,Array.from({length:6}).map((f,k)=>be.createElement(iC,{key:k},be.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},be.createElement(Sc,{width:"100%",height:"100%"})),be.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},be.createElement(Sc,{width:"80%",height:"16px"}),be.createElement(Sc,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&be.createElement(Yk,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&be.createElement(Zm,null,l.filteredFrames.map(f=>be.createElement(fa,{key:f.id,frame:f,thumbnail:l.thumbnails[f.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[f.id],variantChildren:l.variantChildren[f.id],variantFailed:l.variantFailed[f.id],isLoadingVariants:l.loadingVariants.has(f.id),isExpanded:l.expandedSets.has(f.id),isNew:l.recentlyAdded.has(f.name),onToggleExpand:l.toggleExpanded,onSelect:M,multiSelect:a,selectedFrames:g,variantFilters:l.variantFilters,variantPage:v[f.id]||1,onShowMore:N})),l.hasMore&&be.createElement(s4,{onClick:l.loadMore,disabled:l.loadingMore},l.loadingMore?"Loading...":`Show more (${l.totalFrames-l.frames.length} remaining)`)))),a&&be.createElement(bC,null,be.createElement(SC,{disabled:g.size===0,onClick:m},"Link ",g.size," Selected")))):null};ve();lt();var l4=nn.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}),c4=nn.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"})),u4=nn.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),p4=nn.div({display:"flex",alignItems:"center",gap:"20px"}),d4=nn.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),g4=nn.div({display:"flex",gap:"4px"}),e1=nn(Co)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),f4=nn(Pn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),m4=nn.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),h4=nn.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),x4=nn.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),y4=nn.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),b4=nn.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),S4=nn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),w4=nn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),v4=nn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),k4=nn.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),C4=nn.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"}})),t1=nn.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"}})),n1=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=es("map"),[i,s]=es([]),[a,u]=es(!0),[c,l]=es(null),[d,g]=es(!1),[p,h]=es(null),b=XC({projectId:n}),{refreshMappings:I}=Ze(),{featureFlags:F}=ue(),v=Je.useMemo(()=>b.results?.mappings.map(x=>x.storyId)||[],[b.results]),D=ZC(v),N=$o(async()=>{u(!0);try{let x=await fetch("/index.json");if(!x.ok)throw new Error("Failed to fetch index.json");let T=await x.json(),P=T.entries||T.stories||{},B=Object.entries(P).filter(([,C])=>C.type==="story").map(([C,R])=>({id:C,name:R.name||C.split("--").pop()||C,title:R.title||"",importPath:R.importPath,componentTitle:R.title?.split("/").slice(0,-1).join("/")||R.title,figmaMapping:null}));try{let C=Y(),R=localStorage.getItem("uicopilot_session_token"),H=await oe(`${C}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${R}`}});if(H.ok){let L=await H.json(),ie=new Map((L.mappings||[]).map(K=>[K.storyId,K]));B.forEach(K=>{let se=ie.get(K.id);se&&se.figmaNodeId&&(K.figmaMapping={figmaNodeId:se.figmaNodeId,figmaFrameName:se.name||se.figmaFrameName||""})})}}catch(C){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",C)}s(B);let _=B.find(C=>!C.figmaMapping);_?l(_.id):B.length>0&&l(B[0].id)}catch(x){console.error("[StoryMappingAssistant] Error fetching stories:",x)}finally{u(!1)}},[n]);a4(()=>{e&&N()},[e,N]);let $=$o((x,T,P)=>{s(C=>C.map(R=>R.id===x?{...R,figmaMapping:{figmaNodeId:T,figmaFrameName:P}}:R));let B=i.findIndex(C=>C.id===x),_=i.find((C,R)=>R>B&&!C.figmaMapping);_&&l(_.id)},[i]),M=$o(x=>{s(T=>T.map(P=>P.id===x?{...P,figmaMapping:null}:P))},[]),z=$o(x=>{l(x),o("map")},[]),m=$o(()=>{let x=i.filter(T=>T.figmaMapping).map(T=>T.id);b.collectAndMap(x)},[i,b]),S=$o(()=>{let x=i.filter(T=>T.figmaMapping).map(T=>T.id);g(!1),b.rerun(x)},[i,b]),w=$o(async x=>{await b.applyMappings(x),g(!1),b.reset(),N(),I()},[b,N,I]),A=$o(()=>{g(!1),b.reset()},[b]);Je.useEffect(()=>{b.results&&g(!0)},[b.results]);let f=x=>{x.target===x.currentTarget&&t()};if(!e)return null;let k=i.filter(x=>x.figmaMapping).length,E=i.length;return Je.createElement(Je.Fragment,null,Je.createElement(l4,{onClick:f},Je.createElement(c4,{onClick:x=>x.stopPropagation()},Je.createElement(u4,null,Je.createElement(p4,null,Je.createElement(d4,null,Je.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Je.createElement(g4,null,Je.createElement(e1,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Je.createElement(e1,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),Je.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},F.enableAutoMap&&!d&&!b.isCollecting&&!b.isMapping&&Je.createElement(C4,{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(f4,{onClick:t},"\xD7"))),Je.createElement(m4,null,(b.isCollecting||b.isMapping)&&Je.createElement(y4,null,Je.createElement(b4,null,Je.createElement(v4,null,Je.createElement(k4,null)),Je.createElement(S4,null,"Auto-mapping stories to Figma"),Je.createElement(w4,null,b.progress),Je.createElement(Mr,{onClick:b.cancel,variant:"ghost"},"Cancel"))),d&&b.results&&Je.createElement(KC,{results:b.results,stories:i,onApply:w,onCancel:A,onRerun:S,isApplying:b.isApplying,isRerunning:b.isCollecting||b.isMapping,source:b.source,resolveThumbnail:x=>b.results?.thumbnailUrls?.[x],resolveStoryScreenshot:x=>D.screenshots[x],isCapturingScreenshots:D.isCapturing,onBrowse:x=>h(x)}),!d&&!b.isCollecting&&!b.isMapping&&(r==="map"?Je.createElement(LC,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:$,projectId:n}):Je.createElement(RC,{stories:i,loading:a,onLink:z,onUnlink:M,projectId:n}))),Je.createElement(h4,null,Je.createElement(x4,null,Je.createElement("span",null,"Total: ",E," stories"),Je.createElement(t1,{type:"mapped"},Je.createElement("span",{className:"dot"}),k," mapped"),Je.createElement(t1,{type:"unmapped"},Je.createElement("span",{className:"dot"}),E-k," unmapped"))))),Je.createElement(Zi,{isOpen:!!p,onClose:()=>h(null),onSelect:()=>h(null),projectId:n,initialSearch:p||void 0}))};lt();var r1=nr.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}})),I4=nr.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),F4=nr.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),E4=nr.div({display:"flex",alignItems:"center",gap:"8px"}),A4=nr.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),P4=nr.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"})),L4=nr.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"})),M4=nr.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),B4=nr(Eu)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),D4=nr(Eu)(({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)"}})),R4=nr.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),z4=nr.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ce,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),N4=nr.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),o1=()=>{let[e,t]=Mc(!1),[n,r]=Mc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Xe(),{sessionToken:i}=Se();T4(()=>{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(),z=M.entries||M.stories||{},m=Object.keys(z).filter(k=>z[k].type==="story").length,S=Object.keys(z).filter(k=>z[k].type==="story"),w=Y(),A=await oe(`${w}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),f=0;if(A.ok){let k=await A.json(),E=k.mappings||k||[];if(Array.isArray(E)){let x=new Set(E.map(T=>T.storyId).filter(Boolean));f=S.filter(T=>x.has(T)).length}else{let x=await oe(`${w}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(x.ok){let T=await x.json();f=Math.min(T.mappedStoriesCount||0,m)}}}r({totalStories:m,mappedStories:f,loading:!1})}catch($){console.error("[FigmaMappingsSection] Error fetching stats:",$),r(M=>({...M,loading:!1}))}},[a,u]=Mc(!1),[c,l]=Mc(!1),d=async()=>{!o||!i||l(!0)},g=async()=>{l(!1),u(!0);try{let $=Y(),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(S=>oe(`${$}/api/mappings?id=${encodeURIComponent(S.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch($){console.error("[FigmaMappingsSection] Unlink all failed:",$)}finally{u(!1)}},p=()=>t(!0),h=()=>{t(!1),o&&i&&s()};if(!o)return It.createElement(r1,null,It.createElement(R4,null,"Select a project to link Figma designs"));let{totalStories:b,loading:I}=n,F=Math.min(n.mappedStories,b),v=F===0?"none":F>=b?"complete":"partial",D=b>0?Math.min(100,Math.round(F/b*100)):0,N=v==="none"?"Link designs":"Manage";return It.createElement(It.Fragment,null,It.createElement(r1,null,It.createElement(I4,null,It.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},It.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"}),It.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"}),It.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),It.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"}),It.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"}))),It.createElement(F4,null,It.createElement(M4,null,"Figma Mappings"),It.createElement(E4,null,I?It.createElement(It.Fragment,null,It.createElement(z4,null),It.createElement(N4,null,"Loading...")):It.createElement(It.Fragment,null,It.createElement(A4,null,It.createElement(P4,{percent:D,state:v})),It.createElement(L4,{state:v},`${F}/${b}`)))),F>0&&It.createElement(D4,{onClick:d,disabled:I||a},a?"Unlinking...":"Unlink All"),It.createElement(B4,{onClick:p,disabled:I},N)),e&&It.createElement(n1,{isOpen:e,onClose:h,projectId:o}),It.createElement(Hr,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:g,onCancel:()=>l(!1)}))};import J,{useState as Uo,useEffect as Bc,useCallback as i1,useRef as wh}from"react";import{styled as Tn}from"storybook/theming";ve();$e();lt();var vh=Tn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),kh=Tn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),Ch=Tn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Jre=Tn(Or)({padding:"5px 12px",fontSize:"12px"}),Th=Tn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),xa=Tn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),O4=Tn.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})),_4=Tn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),Ih=Tn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),$4=Tn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),ya=Tn.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.negative}1a`,border:`1px solid ${e.color.negative}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.negative,lineHeight:"1.4"})),U4=Tn.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.warning}1a`,border:`1px solid ${e.color.warning}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.warning,lineHeight:"1.4"})),j4=Tn.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.positive}1a`,border:`1px solid ${e.color.positive}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.positive,lineHeight:"1.4"})),ts=Tn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),ns=Tn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Vr=Tn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),s1=new Set,a1=()=>{let{userRole:e,featureFlags:t}=ue(),[n,r]=Uo(null),[o,i]=Uo(!0),[s,a]=Uo(!1),[u,c]=Uo(null),[l,d]=Uo(null),[g,p]=Uo(!1),[h,b]=Uo(!1),[I,F]=Uo(!1),{selectedProjectId:v,projects:D}=Xe(),{sessionToken:N}=Se(),$=wh(null),M=wh(null),z=wh(null),m=i1(()=>{$.current&&(clearInterval($.current),$.current=null),M.current&&(clearInterval(M.current),M.current=null),z.current&&(clearTimeout(z.current),z.current=null)},[]);Bc(()=>m,[m]);let S=i1(async()=>{if(!(!v||!N))try{let C=Y(),R=await oe(`${C}/api/figma/cache-status?projectId=${v}`,{headers:{Authorization:`Bearer ${N}`}});if(R.ok){let H=await R.json();r(H)}}catch(C){console.error("[FigmaCacheSection] Error:",C)}finally{i(!1)}},[v,N]);Bc(()=>{S()},[S]),Bc(()=>{if(o||s||!n||n.structureStatus!=="none"||!v||s1.has(v))return;let C=D.find(H=>H.id===v);(C?.figmaFileUrl||C?.figmaFileId)&&(s1.add(v),w())},[o,s,n?.structureStatus,v,D]),Bc(()=>{let C=n?.thumbnailProgress?.status,R=n?.enrichmentProgress?.status,H=n?.thumbnailProgress?.cached??0,L=n?.thumbnailProgress?.total??0,ie=C==="in-progress"||C==="pending"||L>0&&H<L,K=R==="in-progress"||R==="pending",se=!n?.thumbnailProgress&&n?.structureStatus==="cached",me=n?.crawlProgress?.status==="crawling";if(!(me||ie||K||se)||!me&&(!n||n.structureStatus==="none"))return;let Ge=setInterval(()=>{S()},3e3);return()=>{clearInterval(Ge)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.crawlProgress?.status,n?.structureStatus,S]);let w=async()=>{if(!(!v||!N)){a(!0),c(null),d(null);try{let C=Y(),R=await oe(`${C}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({projectId:v})});if(!R.ok){if(R.status===403){let L=await R.json().catch(()=>({}));c(L.requiresAuth?"auth":"generic")}else c("generic");return}(await R.json().catch(()=>({})))?.status==="skipped-unchanged"&&d("Figma file unchanged \u2014 reused cached structure."),await S()}catch(C){console.error("[FigmaCacheSection] Crawl start error:",C),c("generic")}finally{a(!1)}}},A=async()=>{if(!(!v||!N)){p(!0);try{let C=Y(),R=await oe(`${C}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({projectId:v})});console.log("[FigmaCacheSection] Cache invalidate response:",R.status),await oe(`${C}/api/figma/frames/invalidate?projectId=${v}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`}}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null,crawlProgress:null})}catch(C){console.error("[FigmaCacheSection] Clear cache error:",C)}finally{p(!1)}}},f=async()=>{if(!(!v||!N)){m(),b(!0);try{let C=Y();await oe(`${C}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({projectId:v})}),$.current=setInterval(async()=>{await S()},3e3),M.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(m(),b(!1),S())},3e3),z.current=setTimeout(()=>{m(),b(!1)},6e5)}catch(C){console.error("[FigmaCacheSection] Enrich error:",C),m(),b(!1)}}},k=async()=>{if(!(!v||!N)){F(!0);try{let C=Y();await oe(`${C}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({projectId:v})}),await S()}catch(C){console.error("[FigmaCacheSection] Cancel error:",C)}finally{F(!1),b(!1),a(!1)}}},E=n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!v)return null;if(o)return J.createElement(vh,null,J.createElement(kh,null,J.createElement(Ch,null,"Figma Cache")),J.createElement(Th,null,J.createElement(xa,null,"Loading cache status\u2026")),J.createElement(ts,null,J.createElement(ns,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return J.createElement(vh,null,J.createElement(kh,null,J.createElement(Ch,null,"Figma Cache"),J.createElement(Mr,{loading:s,onClick:w,loadingText:"Loading..."},"\u21BB Load")),n?.crawlProgress?.status==="crawling"?J.createElement(J.Fragment,null,J.createElement(ts,null,J.createElement(ns,{percent:(n.crawlProgress.pagesTotal??0)>0?Math.round(n.crawlProgress.pagesDone/n.crawlProgress.pagesTotal*100):100,style:(n.crawlProgress.pagesTotal??0)>0?void 0:{opacity:.3}})),J.createElement(Vr,null,J.createElement("span",null,"Reading components from Figma\u2026"),J.createElement("span",null,(n.crawlProgress.pagesTotal??0)>0?`page ${n.crawlProgress.pagesDone} of ${n.crawlProgress.pagesTotal}`:"starting\u2026"))):s?J.createElement(J.Fragment,null,J.createElement(ts,null,J.createElement(ns,{percent:100,style:{animation:"none",opacity:.3}})),J.createElement(Vr,null,J.createElement("span",null,"Starting crawl\u2026"))):J.createElement(Th,null,J.createElement(xa,null,"No cache \u2014 click Load to fetch from Figma")),n?.crawlProgress?.status==="error"&&J.createElement(ya,null,"Crawl failed",n.crawlProgress.error?`: ${n.crawlProgress.error}`:"",". Try Load again."),u==="auth"&&J.createElement(ya,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&J.createElement(ya,null,"Failed to load Figma cache. Check the browser console for details."));let x=C=>{let R=Date.now()-new Date(C).getTime(),H=Math.floor(R/6e4);if(H<1)return"just now";if(H<60)return`${H}m ago`;let L=Math.floor(H/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`},T=C=>C>=1024*1024*1024?`${(C/1024/1024/1024).toFixed(1)} GB`:C>=1024*1024?`${Math.round(C/1024/1024)} MB`:`${Math.max(1,Math.round(C/1024))} KB`,P=n.crawlProgress?.bytesDownloaded,B=n.cacheDiff,_=B&&(B.added.length>0||B.removed.length>0||B.renamed.length>0);return J.createElement(vh,null,J.createElement(kh,null,J.createElement(Ch,null,"Figma Cache"," ",J.createElement(O4,{status:n.structureStatus},n.structureStatus)),J.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&J.createElement(Mr,{loading:h,onClick:f,loadingText:"Enriching..."},"Enrich"),J.createElement(Mr,{loading:g,onClick:A,variant:"ghost",loadingText:"Clearing..."},"Clear"),J.createElement(Mr,{loading:s,onClick:w,loadingText:"Reloading..."},"\u21BB Reload"),E&&J.createElement(Mr,{loading:I,onClick:k,variant:"ghost",loadingText:"Cancelling..."},"\u2715 Cancel"))),n?.crawlProgress?.status==="crawling"&&J.createElement(J.Fragment,null,J.createElement(ts,null,J.createElement(ns,{percent:(n.crawlProgress.pagesTotal??0)>0?Math.round(n.crawlProgress.pagesDone/n.crawlProgress.pagesTotal*100):100,style:(n.crawlProgress.pagesTotal??0)>0?void 0:{opacity:.3}})),J.createElement(Vr,null,J.createElement("span",null,"Re-reading components from Figma\u2026"),J.createElement("span",null,(n.crawlProgress.pagesTotal??0)>0?`page ${n.crawlProgress.pagesDone} of ${n.crawlProgress.pagesTotal}`:"starting\u2026"))),s&&n?.crawlProgress?.status!=="crawling"&&J.createElement(Vr,null,J.createElement("span",null,"Starting crawl\u2026")),u==="auth"&&J.createElement(ya,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&J.createElement(ya,null,"Failed to reload Figma cache. Check the browser console for details."),J.createElement(Th,null,J.createElement(xa,null,J.createElement("strong",null,n.componentSetCount)," component sets"),J.createElement(xa,null,J.createElement("strong",null,n.pageCount)," pages"),typeof P=="number"&&P>0&&J.createElement(xa,null,J.createElement("strong",null,"\u2248 ",T(P))),n.structureCachedAt&&J.createElement($4,null,"Updated ",x(n.structureCachedAt))),n.crawlProgress?.status==="complete"&&n.crawlProgress.pagesFailed>0&&J.createElement(U4,null,"\u26A0 ",n.crawlProgress.pagesFailed," of"," ",n.crawlProgress.pagesTotal," pages couldn\u2019t be read (Figma rate limit) \u2014 some components may be missing. Reload to retry."),l&&J.createElement(j4,null,"\u2713 ",l),_&&J.createElement(_4,null,"Since last reload:"," ",B.added.length>0&&J.createElement(Ih,{type:"added"},"+",B.added.length," added"),B.added.length>0&&B.removed.length>0&&" \xB7 ",B.removed.length>0&&J.createElement(Ih,{type:"removed"},"\u2212",B.removed.length," removed"),(B.added.length>0||B.removed.length>0)&&B.renamed.length>0&&" \xB7 ",B.renamed.length>0&&J.createElement(Ih,{type:"renamed"},B.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&J.createElement(J.Fragment,null,J.createElement(ts,null,J.createElement(ns,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),J.createElement(Vr,null,J.createElement("span",null,"Variant thumbnails: caching to CDN\u2026",n.thumbnailProgress.currentName&&J.createElement(J.Fragment,null," ",n.thumbnailProgress.currentName)),J.createElement("span",null,n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," variants"))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&J.createElement(Vr,null,J.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached===0)&&J.createElement(Vr,null,J.createElement("span",null,"Variant thumbnails: not yet cached",n.thumbnailProgress?.total?` (${n.thumbnailProgress.total} components)`:""," ","\u2014 click Reload to generate")),n.thumbnailProgress&&n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached>0&&J.createElement(Vr,null,J.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of"," ",n.thumbnailProgress.total," cached to CDN (partial)")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&J.createElement(J.Fragment,null,J.createElement(ts,null,J.createElement(ns,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),J.createElement(Vr,null,J.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&J.createElement(J.Fragment,null," ",n.enrichmentProgress.currentName)),J.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&J.createElement(J.Fragment,null,J.createElement(Vr,null,J.createElement("span",null,"AI descriptions: ",n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&J.createElement("div",{style:{marginTop:"6px"}},J.createElement(Ec,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import wt,{useState as rs}from"react";import{styled as Gr}from"storybook/theming";ve();$e();lt();var Fh=Gr.div({padding:"12px 16px"}),H4=Gr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),l1=Gr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),c1=Gr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:ce,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),W4=Gr.div({display:"flex",gap:"8px",alignItems:"center"}),V4=Gr.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:ce,boxShadow:`0 0 0 1px ${ce}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),u1=Gr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),G4=Gr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:ce,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),q4=Gr.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})),Y4=Gr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),p1=({onConnected:e})=>{let{sessionToken:t}=Se(),[n,r]=rs(!1),[o,i]=rs(""),[s,a]=rs(!1),[u,c]=rs(null),[l,d]=rs(null),[g,p]=rs(!1),h=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let b=Y(),I=await oe(`${b}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),F=await I.json();if(!I.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?wt.createElement(Fh,null,wt.createElement(l1,null,"Figma Personal Access Token"),wt.createElement(q4,null,wt.createElement("span",null,"\u2713 Connected as ",wt.createElement("strong",null,l)),wt.createElement(Y4,{onClick:()=>{d(null),c(null)}},"Change token"))):n?wt.createElement(Fh,null,wt.createElement(H4,null,wt.createElement(l1,null,"Figma Personal Access Token"),wt.createElement(c1,{onClick:()=>p(!g)},g?"Hide instructions":"How to generate")),g&&wt.createElement(G4,null,wt.createElement("ol",null,wt.createElement("li",null,"Open ",wt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),wt.createElement("li",null,"Click the ",wt.createElement("strong",null,"Security")," tab"),wt.createElement("li",null,"Scroll to ",wt.createElement("strong",null,"Personal access tokens")),wt.createElement("li",null,"Click ",wt.createElement("strong",null,"Generate new token")),wt.createElement("li",null,"Enable ",wt.createElement("strong",null,"File content: Read only")," under Scopes"),wt.createElement("li",null,"Copy the token and paste it below"))),wt.createElement(W4,null,wt.createElement(V4,{type:"password",value:o,onChange:b=>i(b.target.value),placeholder:"figd_...",onKeyDown:b=>{b.key==="Enter"&&o.trim()&&h()}}),wt.createElement(on,{onClick:h,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&wt.createElement(u1,{variant:u.type},u.message),wt.createElement(u1,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):wt.createElement(Fh,null,wt.createElement(c1,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};ve();$e();lt();var X4=xt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},xt.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"}),xt.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"}),xt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),xt.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"}),xt.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"})),Eh=Br.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),Q4=Br.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),J4=Br.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),Z4=Br.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),Ah=Br.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),e5=Br.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"})),t5=Br.div({display:"flex",alignItems:"center",gap:"8px"}),n5=Br(An)(({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"})),r5=Br.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),yoe=Br.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"}}),o5=Br.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}})),g1=({hideHeader:e=!1})=>{let{sessionToken:t}=Se(),[n,r]=ba(!1),[o,i]=ba(0),[s,a]=ba(()=>{try{let b=sessionStorage.getItem("uicopilot_figma_connection");if(b){let{connected:I,ts:F}=JSON.parse(b);if(Date.now()-F<300*1e3)return I}}catch{}return null}),[u,c]=ba(!1),[l,d]=ba(!1);K4(()=>{if(!t)return;let b=Y();oe(`${b}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(I=>I.json()).then(I=>{let F=!!I.connected;c(!!I.expired),a(F);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:F,ts:Date.now()}))}catch{}}).catch(()=>a(!1))},[t]);let g=d1(()=>{let b=Y(),I=`${b}/api/auth/figma/login?addon=true`;window.open(I,"figma-oauth","width=600,height=700,left=200,top=100");let F=setInterval(async()=>{try{(await(await oe(`${b}/api/figma/connection-status`,{headers:t?{Authorization:`Bearer ${t}`}:{}})).json()).connected&&(clearInterval(F),a(!0))}catch{}},2e3);setTimeout(()=>clearInterval(F),300*1e3)},[t]),p=d1(async()=>{try{r(!0);let b=Y(),I=await oe(`${b}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(I.ok||I.status===404){a(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{r(!1)}},[t]),h=e?null:xt.createElement(Q4,null,xt.createElement(J4,null,X4),xt.createElement(Z4,null,"Figma Integration"));return s===null?xt.createElement(Eh,null,h,xt.createElement(Ah,null,xt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):s===!1?xt.createElement(Eh,null,h,xt.createElement(Ah,null,xt.createElement(r5,null,u&&xt.createElement("div",{style:{padding:"10px 12px",backgroundColor:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#92400e"}},"\u26A0\uFE0F Your Figma access has expired. Please reconnect."),xt.createElement("div",{style:{padding:"8px 10px",backgroundColor:"rgba(100, 116, 139, 0.1)",border:"1px solid rgba(100, 116, 139, 0.3)",borderRadius:"6px",fontSize:"11px",lineHeight:1.4,color:"#64748b"}},"Requires a Figma ",xt.createElement("strong",null,"Dev or Full seat"),". Free/Viewer seats can't grant design-read access."),xt.createElement(on,{onClick:g,style:{width:"100%"}},u?"Reconnect Figma":"Connect with Figma"),xt.createElement(o5,null,"or"),xt.createElement(p1,{onConnected:()=>a(!0)})))):xt.createElement(Eh,null,h,xt.createElement(e5,null,xt.createElement(t5,null,xt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),xt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),xt.createElement(n5,{onClick:()=>d(!0),disabled:n},n?"Disconnecting...":"Disconnect")),xt.createElement(Hr,{isOpen:l,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:()=>{d(!1),p()},onCancel:()=>d(!1)}),xt.createElement(Ah,null,xt.createElement(zk,{onFigmaFileChanged:()=>i(b=>b+1)}),xt.createElement(o1,{refreshKey:o}),xt.createElement(a1,null)))};ve();ln();var a5=fr.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"}),l5=fr.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"})),c5=fr.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})),u5=fr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),p5=fr(Pn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),d5=fr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),f1=fr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),m1=fr.div({display:"flex",alignItems:"center",gap:"10px"}),h1=fr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),g5=fr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:ce,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),f5=fr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),x1=fr.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"}})),y1=({onClose:e})=>{let{isConnected:t}=Se(),{selectedProjectId:n}=Xe(),r=s5(t);return i5(()=>{!r.current&&t&&n&&e(),r.current=t},[t,n,e]),Bt.createElement(a5,{onClick:e},Bt.createElement(l5,{onClick:o=>o.stopPropagation()},Bt.createElement(c5,null,Bt.createElement(u5,null,"Settings"),Bt.createElement(p5,{onClick:e,title:"Close settings"},"\xD7")),Bt.createElement(d5,null,Bt.createElement(f1,null,Bt.createElement(m1,null,Bt.createElement(g5,null,"UI"),Bt.createElement(h1,null,Et.NAME)),Bt.createElement(x1,null,Bt.createElement(Pk,{onConnect:e}),t&&Bt.createElement(Dk,null))),t&&n&&Bt.createElement(f1,null,Bt.createElement(m1,null,Bt.createElement(f5,null,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"}))),Bt.createElement(h1,null,"Figma Integration")),Bt.createElement(x1,null,Bt.createElement(g1,{hideHeader:!0}))))))};import ut,{useEffect as A1,useMemo as U5,useState as j5,useRef as H5}from"react";import{styled as Bn,keyframes as W5}from"storybook/theming";ve();ln();ln();function Ph(e){let t=e.complianceScore??0;if(!e.issues||e.issues.length===0)return{score:t,band:e.issues?"A":void 0};let n=Ql(e.issues.map(r=>({...r,dismissed:r.dismissed??!1})));return{score:Math.min(t,so[n]),band:n}}ve();import Qt,{useState as m5}from"react";import{styled as qn}from"storybook/theming";var fo=[{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",provider:"anthropic",description:"Latest Claude Sonnet \u2014 best balance of speed and quality"},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Current default \u2014 proven for design comparison"},{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 h5=qn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),x5=qn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),y5=qn.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"}}),b5=qn.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}})),S5=qn.div({position:"relative",display:"inline-block"}),w5=qn.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}})),v5=qn.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"})),Lh=qn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),Mh=qn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),k5=qn.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}})),C5=qn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),T5=qn.div({flex:1,minWidth:0}),I5=qn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),F5=qn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),E5=5,b1=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ue(),[r,o]=m5(!1),i=fo.filter(p=>p.provider==="anthropic"&&!e.includes(p.id)),s=fo.filter(p=>p.provider==="openai"&&!e.includes(p.id)),a=fo.filter(p=>p.provider==="google"&&!e.includes(p.id)),u=fo.filter(p=>e.includes(p.id)),c=e.length<E5,l=(p,h)=>{h.stopPropagation(),e.length>1&&!n&&t(p)},d=p=>{let h=e.includes(p);h&&e.length===1||!h&&!c||n||(t(p),o(!1))},g=p=>{let h=e.includes(p.id),b=h&&e.length===1,I=n||b||!h&&!c;return Qt.createElement(k5,{key:p.id,disabled:I,onClick:()=>d(p.id)},Qt.createElement(C5,{type:"checkbox",checked:h,disabled:I,onChange:()=>{},onClick:F=>F.stopPropagation()}),Qt.createElement(T5,null,Qt.createElement(I5,null,p.name),p.description&&Qt.createElement(F5,null,p.description)))};return Qt.createElement(h5,null,Qt.createElement(S5,null,Qt.createElement(w5,{disabled:n,isOpen:r,onClick:()=>o(!r)},Qt.createElement("span",null,"Select model"),Qt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Qt.createElement(v5,null,Qt.createElement(Lh,null,Qt.createElement(Mh,null,"Anthropic"),i.map(g)),Qt.createElement(Lh,null,Qt.createElement(Mh,null,"OpenAI"),s.map(g)),Qt.createElement(Lh,null,Qt.createElement(Mh,null,"Google"),a.map(g)))),Qt.createElement(x5,null,u.map(p=>Qt.createElement(y5,{key:p.id,disabled:n,provider:p.provider},p.name,e.length>1&&Qt.createElement(b5,{disabled:n,onClick:h=>l(p.id,h),title:"Remove model"},"\xD7")))))};ln();import De,{useState as A5,useEffect as P5}from"react";import{styled as rn,keyframes as os}from"storybook/theming";ve();var L5=os`
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
- `,P5=ns`
53
+ `,M5=os`
54
54
  0% { transform: rotate(0deg); }
55
55
  100% { transform: rotate(360deg); }
56
- `,v1=ns`
56
+ `,v1=os`
57
57
  0% { opacity: 0; transform: translateY(2px); }
58
58
  100% { opacity: 1; transform: translateY(0); }
59
- `,L5=ns`
59
+ `,B5=os`
60
60
  0%, 100% {
61
61
  opacity: 1;
62
62
  }
63
63
  50% {
64
64
  opacity: 0.6;
65
65
  }
66
- `,M5=ns`
66
+ `,D5=os`
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 qoe=rn.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),Bh=rn.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),Yoe=rn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.6}px`,padding:`${e.layoutMargin*.4}px ${e.layoutMargin}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.regular,color:e.textMutedColor,animation:`${v1} 0.3s ease-out`})),B5=ns`
78
+ `;var Koe=rn.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),Bh=rn.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),Xoe=rn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.6}px`,padding:`${e.layoutMargin*.4}px ${e.layoutMargin}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.regular,color:e.textMutedColor,animation:`${v1} 0.3s ease-out`})),R5=os`
79
79
  from { transform: rotate(0deg); }
80
80
  to { transform: rotate(360deg); }
81
- `,Koe=rn.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${B5} 0.8s linear infinite`,flexShrink:0})),S1=rn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(220, 38, 38, 0.18)":"#fee2e2",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626",whiteSpace:"nowrap"})),D5=rn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(22, 163, 74, 0.18)":"#dcfce7",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.positive||"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"})),Xoe=rn.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:`${M5} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var ba=rn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),Sa=rn.span(({theme:e,color:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:t??e.color.mediumdark,whiteSpace:"nowrap"})),w1=rn.span(({theme:e,color:t})=>({fontSize:"12px",color:t??e.color.mediumdark})),wa=rn.span(({color:e})=>({fontWeight:700,color:e})),R5=rn.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:`${t.layoutMargin*.6}px`,padding:`${t.layoutMargin*.3}px ${t.layoutMargin}px`,borderRadius:t.appBorderRadius*2,backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:t.typography.size.s1,color:t.textMutedColor},"& .score-value":{fontFamily:t.typography.fonts.mono,fontSize:t.typography.size.s2,fontWeight:t.typography.weight.bold,color:e,lineHeight:1},"& .score-dot":{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:e}})),Qoe=rn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),Joe=rn.span(({color:e=ce})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${A5} 1.2s ease-in-out infinite`,marginRight:"4px"})),Zoe=rn.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return ce;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 ce;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${L5} 1.5s ease-in-out infinite`}:{}})),eie=rn.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),tie=rn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),z5=rn.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${P5} 1.2s linear infinite`,flexShrink:0}),N5=({color:e=ce})=>De.createElement(z5,null,De.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 De.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),nie=rn.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:`${v1} 0.3s ease-out`}));function O5(e){let[t,n]=F5(0);return E5(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var k1=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,band:i,visualSimilarity:s,costUsd:a,inputTokens:u,outputTokens:c,showTimer:l=!0,cacheCreationTokens:d,cacheReadTokens:g,durationSeconds:p})=>{let m=O5(e||t),{featureFlags:b}=ue(),T=b.showCosts,F=3.65,v=R=>R<.01?`$${R.toFixed(4)}`:R<.1?`$${R.toFixed(3)}`:`$${R.toFixed(2)}`,D=R=>{let h=R*F;return h<.01?`\u20AA${h.toFixed(4)}`:h<.1?`\u20AA${h.toFixed(3)}`:`\u20AA${h.toFixed(2)}`},_=R=>R>=1e3?`${(R/1e3).toFixed(1)}K`:R.toString(),$=R=>R>=80?"score-high":R>=50?"score-medium":"score-low",L=R=>R>=80?"high":R>=50?"medium":"low";if(e)return De.createElement(Bh,null,De.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},m,"s \xB7 Esc to stop"));if(t)return De.createElement(Bh,null,De.createElement(S1,null,De.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),De.createElement(ba,null,"|"),De.createElement(Sa,null,De.createElement(N5,{color:"#7c3aed"}),De.createElement(wa,{color:"#7c3aed"},"Verifying...")),l&&De.createElement(De.Fragment,null,De.createElement(ba,null,"|"),De.createElement(Sa,null,De.createElement("span",{style:{color:"#6b7280"}},m,"s"))));if(r>0||o!==void 0){let R=(u||0)+(c||0),h=(g||0)>0,S=h&&u?Math.round(g/u*100):0,w=i?io[i]:100,A=Math.min(Math.max(o??0,s??0),w),f=E=>E>=80?"#16a34a":E>=50?"#ca8a04":"#dc2626",k=E=>E>=100?"\u25CF":E>=50?"\u25D0":"\u25CB";return De.createElement(Bh,null,r===0&&(o===void 0||o>=100)?De.createElement(D5,null,De.createElement("span",null,"\u2713"),"Perfect!"):De.createElement(S1,null,De.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),De.createElement(R5,{tint:f(A),title:i==="D"?`Band D \u2014 has critical issues. Fix criticals to score above ${io.D}.`:i==="C"?`Band C \u2014 has major issues. Fix majors to score above ${io.C}.`:i==="B"?"Band B \u2014 minor issues only.":i==="A"?"Band A \u2014 no open issues.":`Compliance score: ${A}%`},De.createElement("span",{className:"score-dot"}),De.createElement("span",{className:"score-label"},"Score"),De.createElement("span",{className:"score-value"},A,i?` \xB7 ${i}`:"")),T&&a!==void 0&&a>0&&De.createElement(De.Fragment,null,De.createElement(ba,null,"|"),De.createElement(Sa,null,De.createElement(wa,{color:"#16a34a"},v(a)),De.createElement("span",{style:{color:"#6b7280"}},"/"),De.createElement(wa,{color:"#16a34a"},D(a)))),T&&R>0&&De.createElement(De.Fragment,null,De.createElement(ba,null,"|"),De.createElement(Sa,{title:`Input: ${u?.toLocaleString()||0} \xB7 Output: ${c?.toLocaleString()||0}${h?` \xB7 Cached: ${g?.toLocaleString()}`:""}`},De.createElement(w1,{color:"#7c3aed"},"#"),De.createElement(wa,{color:"#7c3aed"},_(R)),De.createElement("span",{style:{color:"#6b7280"}},"tokens"),h&&De.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",S,"%"))),p!==void 0&&p>0&&De.createElement(De.Fragment,null,De.createElement(ba,null,"|"),De.createElement(Sa,null,De.createElement(w1,{color:"#6b7280"},"\u23F1"),De.createElement(wa,{color:"#6b7280"},p,"s"))))}return null};var H5=Mn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),gie=Mn.div({display:"flex",gap:"8px",alignItems:"center"}),W5=j5({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),V5=Mn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${W5} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),G5=Mn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),q5=Mn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin}px`,padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.2}px`,borderRadius:e.appBorderRadius*2,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.03)",flexWrap:"wrap"})),Y5=Mn.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:tl},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:e.color.inverseText,border:"none",padding:`${e.layoutMargin*.7}px ${e.layoutMargin*1.4}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,borderRadius:e.appBorderRadius,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)`}}}),K5=Mn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),X5=Mn.div({marginLeft:"auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",minWidth:0}),Q5=Mn(Sn)({width:"auto",minWidth:"180px",maxWidth:"260px"}),C1=Mn.span(({theme:e,variant:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,padding:"3px 8px",borderRadius:"10px",whiteSpace:"nowrap",color:t==="latest"?e.color.positive:e.color.mediumdark,backgroundColor:t==="latest"?`${e.color.positive}1a`:e.background.hoverable})),J5=Mn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),T1=Mn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),I1=Mn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?tl:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),F1=Mn.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)"})),E1=Mn.input({position:"absolute",opacity:0,width:0,height:0}),Z5=()=>{let[e,t]=$5(0),n=U5();A1(()=>(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 ut.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},Dh=()=>{let{sessionToken:e}=Xs(),{usageData:t}=Se(),{selectedProjectId:n}=lo(),{currentMapping:r,hasMapping:o}=si(),{loadingMapping:i,currentStoryId:s}=Ze(),{startReview:a,cancelReview:u,isReviewing:c}=Pm(),{isLoadingScreenshots:l}=oi(),{storybookImageUrl:d,figmaImageUrl:g,currentReviewId:p,reviewHistory:m,setReviewDetailTab:b,setReviewResults:T,setFigmaImageUrl:F,setStorybookImageUrl:v,setFullPrompt:D,setFullResponse:_,includeTextComparison:$,setIncludeTextComparison:L,usePromptCache:R,setUsePromptCache:h,isValidating:S,validationUsage:w,isGenerating:A,isApplying:f,streamingStatus:k,featureFlags:E,userRole:x,roleOverride:C,isReviewing:P}=ue(),B=t?.reviewCredits??t?.creditBalance??0,N=m.find(fe=>fe.id===p),z=(N?.issues||[]).filter(fe=>!fe.dismissed).length,W=N?Ph(N):null,M=W?.score,ie=W?.band,K=N?.visualSimilarity,ae=(N?.costUsd||0)+(w?.costUsd||0),xe=(N?.inputTokens||0)+(w?.inputTokens||0),Pe=(N?.outputTokens||0)+(w?.outputTokens||0),Ye=_5(()=>{let fe=s?m.filter(O=>O.storyId===s):m,Fe=fe.filter(O=>!O.parentReviewId).sort((O,j)=>new Date(j.createdAt).getTime()-new Date(O.createdAt).getTime()),q=fe.filter(O=>O.parentReviewId),je=[];for(let O of Fe){je.push(O);let j=q.filter(G=>G.parentReviewId===O.id).sort((G,H)=>(G.iterationNumber||0)-(H.iterationNumber||0));je.push(...j)}let gt=q.filter(O=>!Fe.some(j=>j.id===O.parentReviewId));return je.push(...gt),je},[m,s]);A1(()=>{if(!c)return;let fe=Fe=>{Fe.key==="Escape"&&(Fe.preventDefault(),u())};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[c,u]);let ne=o&&r?.figmaNodeId,Te=A||f,it=B>0,te=!!(e&&n&&!c&&!l&&!Te&&s&&d&&ne&&g&&it),Be=async(fe=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{b("chat"),await a({isIteration:fe,parentReviewId:fe?p:void 0})}catch(Fe){console.error("[ReviewActions] Review error:",Fe)}},ge=()=>Be(!1),dt=fe=>{let Fe=fe.target.value;if(Fe){let q=m.find(je=>je.id===Fe);q&&(T({id:q.id,componentId:q.componentId,storyId:q.storyId,modelId:q.modelId,complianceScore:q.complianceScore,issuesCount:q.issuesCount,issues:q.issues,createdAt:new Date(q.createdAt),visualSimilarity:q.visualSimilarity,timestamp:new Date(q.createdAt).toISOString(),costUsd:q.costUsd,inputTokens:q.inputTokens,outputTokens:q.outputTokens,cacheCreationTokens:q.cacheCreationTokens,cacheReadTokens:q.cacheReadTokens,reviewDurationMs:q.reviewDurationMs}),q.figmaImageData&&F(q.figmaImageData),q.storybookImageData&&v(q.storybookImageData),(C??x)==="admin"&&(D(q.aiPrompt||""),_(q.aiResponse||"")),b("issues"))}},ot=fe=>{let Fe=new Date(fe),je=new Date().getTime()-Fe.getTime(),gt=Math.floor(je/6e4),O=Math.floor(je/36e5),j=Math.floor(je/864e5);return gt<1?"Just now":gt<60?`${gt}m ago`:O<24?`${O}h ago`:j<7?`${j}d ago`:Fe.toLocaleDateString()},bn=fe=>fe?fe.includes("haiku")?"Haiku":fe.includes("sonnet")?"Sonnet":fe.includes("opus")?"Opus":fe.includes("gpt-4o-mini")?"GPT-4o mini":fe.includes("gpt-4o")?"GPT-4o":fe.includes("gpt-4")?"GPT-4":fe.includes("o3")?"o3":fe.includes("o1")?"o1":fe.split("-")[0]||"":"",br=fe=>{let Fe=fe.split("--"),q=Fe[Fe.length-1]||fe;return q.charAt(0).toUpperCase()+q.slice(1)},or=(C??x)==="admin";return ut.createElement("div",null,ut.createElement(H5,null,E.enableModelSelection&&ut.createElement(b1,null),or&&ut.createElement(J5,null,ut.createElement(T1,{title:"Compare text content between Figma design and Storybook component"},ut.createElement(E1,{type:"checkbox",checked:$,onChange:fe=>L(fe.target.checked)}),ut.createElement(I1,{checked:$},ut.createElement(F1,{checked:$})),"Compare text"),E.showCosts&&ut.createElement(T1,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ut.createElement(E1,{type:"checkbox",checked:R,onChange:fe=>h(fe.target.checked)}),ut.createElement(I1,{checked:R},ut.createElement(F1,{checked:R})),"Cache prompt")),ut.createElement(q5,null,ut.createElement(Y5,{variant:c?"yellow":"purple",disabled:c?!1:!te,onClick:c?u:ge,title:c?"Click to stop review":e?n?s?ne?l?"Loading screenshots...":Te?"Wait for fixes to complete...":d?g?it?"Review this component implementation":"No credits \u2014 click \u26A1 in the toolbar to get more":"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 ${Et.NAME} first`},c?ut.createElement(ut.Fragment,null,ut.createElement(V5,null),"Reviewing",ut.createElement(Z5,null)):ut.createElement(ut.Fragment,null,ut.createElement(G5,null,ut.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ut.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ut.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),P?null:S||N?ut.createElement(k1,{isReviewing:!1,isValidating:S,streamingStatus:k,issueCount:z,score:M,band:ie,visualSimilarity:K,costUsd:ae||N?.costUsd,inputTokens:xe||N?.inputTokens,outputTokens:Pe||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,Ye.length>0&&ut.createElement(X5,null,p&&(p===Ye[0]?.id?ut.createElement(C1,{variant:"latest",title:"You're viewing the most recent review for this story"},"Latest"):ut.createElement(C1,{variant:"older",title:"You're viewing an older review \u2014 pick the top entry to see the latest"},"Older review")),ut.createElement(Q5,{value:p||"",onChange:dt,title:"Review history"},ut.createElement("option",{value:""},"Select a review..."),Ye.map(fe=>{let Fe=!!fe.parentReviewId,q=Fe?" \u21B3 ":"\u25CF ",je=Fe&&fe.iterationNumber?`Iter ${fe.iterationNumber} - `:"",gt=fe.issuesCount??fe.issues?.length??0,{score:O,band:j}=Ph(fe),G=fe.complianceScore!=null?O:"--",H=bn(fe.modelId);return ut.createElement("option",{key:fe.id,value:fe.id},q,je,ot(fe.createdAt)," - ",gt," issues (",G,"%",j?` \xB7 ${j}`:"",")",E.showCosts&&H?` \xB7 ${H}`:"",!s&&fe.storyId?` \xB7 ${br(fe.storyId)}`:"")}))))),!ne&&!i&&ut.createElement(K5,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import hie,{useState as xie}from"react";import{styled as P1}from"storybook/theming";var Sie=P1.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),wie=P1(Co)({padding:"8px 12px",fontSize:"12px"});import Cie,{useState as Tie}from"react";import{styled as Rh}from"storybook/theming";ve();$e();Ne();lt();var Mie=Rh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),Bie=Rh(Or)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),Die=Rh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import Nie from"react";import{styled as e3}from"storybook/theming";var $ie=e3.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));ve();import Hie from"react";import{styled as Gr}from"storybook/theming";var Gie=Gr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),qie=Gr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),Yie=Gr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),Kie=Gr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),Xie=Gr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Qie=Gr.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"})),Jie=Gr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),Zie=Gr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),ese=Gr.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)"}}})),tse=Gr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));ve();import ose,{useState as ise}from"react";import{styled as qr}from"storybook/theming";var lse=qr.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)`}}),cse=qr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),use=qr.div({display:"flex",alignItems:"center",gap:"8px"}),pse=qr.span({fontSize:"12px",opacity:.7}),dse=qr.span({fontSize:"13px",fontWeight:500}),gse=qr.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})),fse=qr.div({marginTop:"12px",fontSize:"11px"}),mse=qr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),hse=qr.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"})),xse=qr.span({fontSize:"12px"});Ne();$e();import Jt from"react";import{styled as ds}from"storybook/theming";import zr,{useEffect as JW}from"react";import{styled as Oa}from"storybook/theming";ve();import xi,{useState as hj}from"react";import{styled as cs}from"storybook/theming";var L1={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 M1(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var t3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,n3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,r3={};function Dc(e,t){return((t||r3).jsx?n3:t3).test(e)}var o3=/[ \t\n\f\r]/g;function zh(e){return typeof e=="object"?e.type==="text"?B1(e.value):!1:B1(e)}function B1(e){return e.replace(o3,"")===""}var mo=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};mo.prototype.normal={};mo.prototype.property={};mo.prototype.space=void 0;function Nh(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new mo(n,r,t)}function va(e){return e.toLowerCase()}var dn=class{constructor(t,n){this.attribute=n,this.property=t}};dn.prototype.attribute="";dn.prototype.booleanish=!1;dn.prototype.boolean=!1;dn.prototype.commaOrSpaceSeparated=!1;dn.prototype.commaSeparated=!1;dn.prototype.defined=!1;dn.prototype.mustUseProperty=!1;dn.prototype.number=!1;dn.prototype.overloadedBoolean=!1;dn.prototype.property="";dn.prototype.spaceSeparated=!1;dn.prototype.space=void 0;var ka={};ye(ka,{boolean:()=>We,booleanish:()=>Ut,commaOrSpaceSeparated:()=>Yn,commaSeparated:()=>Uo,number:()=>Q,overloadedBoolean:()=>Rc,spaceSeparated:()=>Ct});var i3=0,We=ui(),Ut=ui(),Rc=ui(),Q=ui(),Ct=ui(),Uo=ui(),Yn=ui();function ui(){return 2**++i3}var Oh=Object.keys(ka),pi=class extends dn{constructor(t,n,r,o){let i=-1;if(super(t,n),D1(this,"space",o),typeof r=="number")for(;++i<Oh.length;){let s=Oh[i];D1(this,Oh[i],(r&ka[s])===ka[s])}}};pi.prototype.defined=!0;function D1(e,t,n){n&&(e[t]=n)}function mr(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new pi(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[va(r)]=r,n[va(i.attribute)]=r}return new mo(t,n,e.space)}var _h=mr({properties:{ariaActiveDescendant:null,ariaAtomic:Ut,ariaAutoComplete:null,ariaBusy:Ut,ariaChecked:Ut,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:Ct,ariaCurrent:null,ariaDescribedBy:Ct,ariaDetails:null,ariaDisabled:Ut,ariaDropEffect:Ct,ariaErrorMessage:null,ariaExpanded:Ut,ariaFlowTo:Ct,ariaGrabbed:Ut,ariaHasPopup:null,ariaHidden:Ut,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ct,ariaLevel:Q,ariaLive:null,ariaModal:Ut,ariaMultiLine:Ut,ariaMultiSelectable:Ut,ariaOrientation:null,ariaOwns:Ct,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Ut,ariaReadOnly:Ut,ariaRelevant:null,ariaRequired:Ut,ariaRoleDescription:Ct,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Ut,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function zc(e,t){return t in e?e[t]:t}function Nc(e,t){return zc(e,t.toLowerCase())}var R1=mr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Uo,acceptCharset:Ct,accessKey:Ct,action:null,allow:null,allowFullScreen:We,allowPaymentRequest:We,allowUserMedia:We,alt:null,as:null,async:We,autoCapitalize:null,autoComplete:Ct,autoFocus:We,autoPlay:We,blocking:Ct,capture:null,charSet:null,checked:We,cite:null,className:Ct,cols:Q,colSpan:null,content:null,contentEditable:Ut,controls:We,controlsList:Ct,coords:Q|Uo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:We,defer:We,dir:null,dirName:null,disabled:We,download:Rc,draggable:Ut,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:We,formTarget:null,headers:Ct,height:Q,hidden:Rc,high:Q,href:null,hrefLang:null,htmlFor:Ct,httpEquiv:Ct,id:null,imageSizes:null,imageSrcSet:null,inert:We,inputMode:null,integrity:null,is:null,isMap:We,itemId:null,itemProp:Ct,itemRef:Ct,itemScope:We,itemType:Ct,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:We,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,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:Q,pattern:null,ping:Ct,placeholder:null,playsInline:We,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:We,referrerPolicy:null,rel:Ct,required:We,reversed:We,rows:Q,rowSpan:Q,sandbox:Ct,scope:null,scoped:We,seamless:We,selected:We,shadowRootClonable:We,shadowRootDelegatesFocus:We,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Ut,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:We,useMap:null,value:Ut,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ct,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,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:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:We,noHref:We,noShade:We,noWrap:We,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Ut,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:We,disableRemotePlayback:We,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:Nc});var z1=mr({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:Yn,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:Ct,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:We,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:Uo,g2:Uo,glyphName:Uo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:Yn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,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:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ct,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yn,rev:Yn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yn,requiredFeatures:Yn,requiredFonts:Yn,requiredFormats:Yn,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:Yn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yn,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:zc});var $h=mr({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 Uh=mr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Nc});var jh=mr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Hh={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 s3=/[A-Z]/g,N1=/-[a-z]/g,a3=/^data[-\w.:]+$/i;function Wh(e,t){let n=va(t),r=t,o=dn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&a3.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(N1,c3);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!N1.test(i)){let s=i.replace(s3,l3);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=pi}return new o(r,t)}function l3(e){return"-"+e.toLowerCase()}function c3(e){return e.charAt(1).toUpperCase()}var O1=Nh([_h,R1,$h,Uh,jh],"html"),Oc=Nh([_h,z1,$h,Uh,jh],"svg");function _1(e){return e.join(" ").trim()}var eT=el(X1(),1);var $c=Q1("end"),rs=Q1("start");function Q1(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 qh(e){let t=rs(e),n=$c(e);if(t&&n)return{start:t,end:n}}function jo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?J1(e.position):"start"in e||"end"in e?J1(e):"line"in e||"column"in e?Yh(e):""}function Yh(e){return Z1(e&&e.line)+":"+Z1(e&&e.column)}function J1(e){return Yh(e&&e.start)+"-"+Yh(e&&e.end)}function Z1(e){return e&&typeof e=="number"?e:1}var Gt=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=jo(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}};Gt.prototype.file="";Gt.prototype.name="";Gt.prototype.reason="";Gt.prototype.message="";Gt.prototype.stack="";Gt.prototype.column=void 0;Gt.prototype.line=void 0;Gt.prototype.ancestors=void 0;Gt.prototype.cause=void 0;Gt.prototype.fatal=void 0;Gt.prototype.place=void 0;Gt.prototype.ruleId=void 0;Gt.prototype.source=void 0;var Kh={}.hasOwnProperty,R3=new Map,z3=/[A-Z]/g,N3=new Set(["table","tbody","thead","tfoot","tr"]),O3=new Set(["td","th"]),tT="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Xh(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=G3(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=V3(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"?Oc:O1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=nT(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function nT(e,t,n){if(t.type==="element")return _3(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return $3(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return j3(e,t,n);if(t.type==="mdxjsEsm")return U3(e,t);if(t.type==="root")return H3(e,t,n);if(t.type==="text")return W3(e,t)}function _3(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=Oc,e.schema=o),e.ancestors.push(t);let i=oT(e,t.tagName,!1),s=q3(e,t),a=Jh(e,t);return N3.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!zh(u):!0})),rT(e,s,i,t),Qh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function $3(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)}Ta(e,t.position)}function U3(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ta(e,t.position)}function j3(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=Oc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:oT(e,t.name,!0),s=Y3(e,t),a=Jh(e,t);return rT(e,s,i,t),Qh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function H3(e,t,n){let r={};return Qh(r,Jh(e,t)),e.create(t,e.Fragment,r,n)}function W3(e,t){return t.value}function rT(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Qh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function V3(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 G3(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=rs(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 q3(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&Kh.call(t.properties,o)){let i=K3(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&O3.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 Y3(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 Ta(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 Ta(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function Jh(e,t){let n=[],r=-1,o=e.passKeys?new Map:R3;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=nT(e,i,s);a!==void 0&&n.push(a)}return n}function K3(e,t,n){let r=Wh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?M1(n):_1(n)),r.property==="style"){let o=typeof n=="object"?n:X3(e,String(n));return e.stylePropertyNameCase==="css"&&(o=Q3(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?Hh[r.property]||r.property:r.attribute,n]}}function X3(e,t){try{return(0,eT.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Gt("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=tT+"#cannot-parse-style-attribute",o}}function oT(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=Dc(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=Dc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return Kh.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ta(e)}function Ta(e,t){let n=new Gt("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=tT+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Q3(e){let t={},n;for(n in e)Kh.call(e,n)&&(t[J3(n)]=e[n]);return t}function J3(e){let t=e.replace(z3,Z3);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Z3(e){return"-"+e.toLowerCase()}var Ia={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 aj,jsx as lj,jsxs as cj}from"react/jsx-runtime";import{useEffect as Age,useState as Pge}from"react";var e6={};function Zh(e,t){let n=t||e6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return sT(e,r,o)}function sT(e,t,n){if(t6(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 iT(e.children,t,n)}return Array.isArray(e)?iT(e,t,n):""}function iT(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=sT(e[o],t,n);return r.join("")}function t6(e){return!!(e&&typeof e=="object")}var aT=document.createElement("i");function os(e){let t="&"+e+";";aT.innerHTML=t;let n=aT.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xn(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 Bn(e,t){return e.length>0?(xn(e,e.length,0,t),e):t}var lT={}.hasOwnProperty;function cT(e){let t={},n=-1;for(;++n<e.length;)n6(t,e[n]);return t}function n6(e,t){let n;for(n in t){let o=(lT.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){lT.call(o,s)||(o[s]=[]);let a=i[s];r6(o[s],Array.isArray(a)?a:a?[a]:[])}}}function r6(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);xn(e,0,0,r)}function Uc(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 ho(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var rr=Ho(/[A-Za-z]/),gn=Ho(/[\dA-Za-z]/),uT=Ho(/[#-'*+\--9=?A-Z^-~]/);function Fa(e){return e!==null&&(e<32||e===127)}var Ea=Ho(/\d/),pT=Ho(/[\dA-Fa-f]/),dT=Ho(/[!-/:-@[-`{-~]/);function pe(e){return e!==null&&e<-2}function qt(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}var gT=Ho(/\p{P}|\p{S}/u),fT=Ho(/\s/);function Ho(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function hr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&gn(e.charCodeAt(n+1))&&gn(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 Ue(u)?(e.enter(n),a(u)):t(u)}function a(u){return Ue(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var mT={tokenize:o6};function o6(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 pe(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var xT={tokenize:i6},hT={tokenize:s6};function i6(e){let t=this,n=[],r=0,o,i,s;return a;function a(D){if(r<n.length){let _=n[r];return t.containerState=_[1],e.attempt(_[0].continuation,u,c)(D)}return c(D)}function u(D){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&v();let _=t.events.length,$=_,L;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){L=t.events[$][1].end;break}F(r);let R=_;for(;R<t.events.length;)t.events[R][1].end={...L},R++;return xn(t.events,$+1,0,t.events.slice(_)),t.events.length=R,c(D)}return a(D)}function c(D){if(r===n.length){if(!o)return g(D);if(o.currentConstruct&&o.currentConstruct.concrete)return m(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(hT,l,d)(D)}function l(D){return o&&v(),F(r),g(D)}function d(D){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,m(D)}function g(D){return t.containerState={},e.attempt(hT,p,m)(D)}function p(D){return r++,n.push([t.currentConstruct,t.containerState]),g(D)}function m(D){if(D===null){o&&v(),F(0),e.consume(D);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),b(D)}function b(D){if(D===null){T(e.exit("chunkFlow"),!0),F(0),e.consume(D);return}return pe(D)?(e.consume(D),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(D),b)}function T(D,_){let $=t.sliceStream(D);if(_&&$.push(null),D.previous=i,i&&(i.next=D),i=D,o.defineSkip(D.start),o.write($),t.parser.lazy[D.start.line]){let L=o.events.length;for(;L--;)if(o.events[L][1].start.offset<s&&(!o.events[L][1].end||o.events[L][1].end.offset>s))return;let R=t.events.length,h=R,S,w;for(;h--;)if(t.events[h][0]==="exit"&&t.events[h][1].type==="chunkFlow"){if(S){w=t.events[h][1].end;break}S=!0}for(F(r),L=R;L<t.events.length;)t.events[L][1].end={...w},L++;xn(t.events,h+1,0,t.events.slice(R)),t.events.length=L}}function F(D){let _=n.length;for(;_-- >D;){let $=n[_];t.containerState=$[1],$[0].exit.call(t,e)}n.length=D}function v(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function s6(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 ex(e){if(e===null||qt(e)||fT(e))return 1;if(gT(e))return 2}function is(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 Aa={name:"attention",resolveAll:a6,tokenize:l6};function a6(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},g={...e[n][1].start};yT(d,-u),yT(g,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:g},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=Bn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Bn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Bn(c,is(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Bn(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=Bn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,xn(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 l6(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=ex(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=ex(u),d=!l||l===2&&o||n.includes(u),g=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?d:d&&(o||!g)),c._close=!!(i===42?g:g&&(l||!d)),t(u)}}function yT(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var tx={name:"autolink",tokenize:c6};function c6(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 rr(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||gn(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||gn(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||Fa(p)?n(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),l):uT(p)?(e.consume(p),c):n(p)}function l(p){return gn(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):g(p)}function g(p){if((p===45||gn(p))&&r++<63){let m=p===45?g:d;return e.consume(p),m}return n(p)}}var Wo={partial:!0,tokenize:u6};function u6(e,t,n){return r;function r(i){return Ue(i)?Ve(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||pe(i)?t(i):n(i)}}var jc={continuation:{tokenize:d6},exit:g6,name:"blockQuote",tokenize:p6};function p6(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 Ue(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function d6(e,t,n){let r=this;return o;function o(s){return Ue(s)?Ve(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(jc,t,n)(s)}}function g6(e){e.exit("blockQuote")}var Hc={name:"characterEscape",tokenize:f6};function f6(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 dT(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Wc={name:"characterReference",tokenize:m6};function m6(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=gn,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=pT,l):(e.enter("characterReferenceValue"),i=7,s=Ea,l(d))}function l(d){if(d===59&&o){let g=e.exit("characterReferenceValue");return s===gn&&!os(r.sliceSerialize(g))?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 bT={partial:!0,tokenize:x6},Vc={concrete:!0,name:"codeFenced",tokenize:h6};function h6(e,t,n){let r=this,o={partial:!0,tokenize:$},i=0,s=0,a;return u;function u(L){return c(L)}function c(L){let R=r.events[r.events.length-1];return i=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,a=L,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(L)}function l(L){return L===a?(s++,e.consume(L),l):s<3?n(L):(e.exit("codeFencedFenceSequence"),Ue(L)?Ve(e,d,"whitespace")(L):d(L))}function d(L){return L===null||pe(L)?(e.exit("codeFencedFence"),r.interrupt?t(L):e.check(bT,b,_)(L)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(L))}function g(L){return L===null||pe(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(L)):Ue(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(L)):L===96&&L===a?n(L):(e.consume(L),g)}function p(L){return L===null||pe(L)?d(L):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(L))}function m(L){return L===null||pe(L)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(L)):L===96&&L===a?n(L):(e.consume(L),m)}function b(L){return e.attempt(o,_,T)(L)}function T(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),F}function F(L){return i>0&&Ue(L)?Ve(e,v,"linePrefix",i+1)(L):v(L)}function v(L){return L===null||pe(L)?e.check(bT,b,_)(L):(e.enter("codeFlowValue"),D(L))}function D(L){return L===null||pe(L)?(e.exit("codeFlowValue"),v(L)):(e.consume(L),D)}function _(L){return e.exit("codeFenced"),t(L)}function $(L,R,h){let S=0;return w;function w(x){return L.enter("lineEnding"),L.consume(x),L.exit("lineEnding"),A}function A(x){return L.enter("codeFencedFence"),Ue(x)?Ve(L,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):f(x)}function f(x){return x===a?(L.enter("codeFencedFenceSequence"),k(x)):h(x)}function k(x){return x===a?(S++,L.consume(x),k):S>=s?(L.exit("codeFencedFenceSequence"),Ue(x)?Ve(L,E,"whitespace")(x):E(x)):h(x)}function E(x){return x===null||pe(x)?(L.exit("codeFencedFence"),R(x)):h(x)}}}function x6(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 Pa={name:"codeIndented",tokenize:b6},y6={partial:!0,tokenize:S6};function b6(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):pe(c)?e.attempt(y6,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||pe(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function S6(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):pe(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):pe(s)?o(s):n(s)}}var nx={name:"codeText",previous:v6,resolve:w6,tokenize:k6};function w6(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 v6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function k6(e,t,n){let r=this,o=0,i,s;return a;function a(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),o++,u):(e.exit("codeTextSequence"),c(g))}function c(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),c):g===96?(s=e.enter("codeTextSequence"),i=0,d(g)):pe(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(g))}function l(g){return g===null||g===32||g===96||pe(g)?(e.exit("codeTextData"),c(g)):(e.consume(g),l)}function d(g){return g===96?(e.consume(g),i++,d):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(s.type="codeTextData",l(g))}}var Gc=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&&La(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),La(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),La(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);La(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);La(this.left,n.reverse())}}};function La(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 qc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Gc(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,C6(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 xn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function C6(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,g=-1,p=n,m=0,b=0,T=[b];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;++g<a.length;)a[g][0]==="exit"&&a[g-1][0]==="enter"&&a[g][1].type===a[g-1][1].type&&a[g][1].start.line!==a[g][1].end.line&&(b=g+1,T.push(b),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):T.pop(),g=T.length;g--;){let F=a.slice(T[g],T[g+1]),v=i.pop();u.push([v,v+F.length-1]),e.splice(v,2,F)}for(u.reverse(),g=-1;++g<u.length;)c[m+u[g][0]]=m+u[g][1],m+=u[g][1]-u[g][0]-1;return c}var rx={resolve:I6,tokenize:F6},T6={partial:!0,tokenize:E6};function I6(e){return qc(e),e}function F6(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):pe(a)?e.check(T6,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 E6(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||pe(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 Yc(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),g):F===null||F===32||F===41||Fa(F)?n(F):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),b(F))}function g(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),g(F)):F===null||F===60||pe(F)?n(F):(e.consume(F),F===92?m:p)}function m(F){return F===60||F===62||F===92?(e.consume(F),p):p(F)}function b(F){return!l&&(F===null||F===41||qt(F))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(F)):l<c&&F===40?(e.consume(F),l++,b):F===41?(e.consume(F),l--,b):F===null||F===32||F===40||Fa(F)?n(F):(e.consume(F),F===92?T:b)}function T(F){return F===40||F===41||F===92?(e.consume(F),b):b(F)}}function Kc(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):pe(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||pe(p)||a++>999?(e.exit("chunkString"),l(p)):(e.consume(p),u||(u=!Ue(p)),p===92?g:d)}function g(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Xc(e,t,n,r,o,i){let s;return a;function a(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),s=g===40?41:g,u):n(g)}function u(g){return g===s?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),c(g))}function c(g){return g===s?(e.exit(i),u(s)):g===null?n(g):pe(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(g))}function l(g){return g===s||g===null||pe(g)?(e.exit("chunkString"),c(g)):(e.consume(g),g===92?d:l)}function d(g){return g===s||g===92?(e.consume(g),l):l(g)}}function gi(e,t){let n;return r;function r(o){return pe(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Ue(o)?Ve(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var ox={name:"definition",tokenize:P6},A6={partial:!0,tokenize:L6};function P6(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return Kc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return o=ho(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 qt(p)?gi(e,c)(p):c(p)}function c(p){return Yc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(A6,d,d)(p)}function d(p){return Ue(p)?Ve(e,g,"whitespace")(p):g(p)}function g(p){return p===null||pe(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function L6(e,t,n){return r;function r(a){return qt(a)?gi(e,o)(a):n(a)}function o(a){return Xc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return Ue(a)?Ve(e,s,"whitespace")(a):s(a)}function s(a){return a===null||pe(a)?t(a):n(a)}}var ix={name:"hardBreakEscape",tokenize:M6};function M6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return pe(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var sx={name:"headingAtx",resolve:B6,tokenize:D6};function B6(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"},xn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function D6(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||qt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||pe(l)?(e.exit("atxHeading"),t(l)):Ue(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||qt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var ST=["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"],ax=["pre","script","style","textarea"];var lx={concrete:!0,name:"htmlFlow",resolveTo:N6,tokenize:O6},R6={partial:!0,tokenize:$6},z6={partial:!0,tokenize:_6};function N6(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 O6(e,t,n){let r=this,o,i,s,a,u;return c;function c(M){return l(M)}function l(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),d}function d(M){return M===33?(e.consume(M),g):M===47?(e.consume(M),i=!0,b):M===63?(e.consume(M),o=3,r.interrupt?t:I):rr(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function g(M){return M===45?(e.consume(M),o=2,p):M===91?(e.consume(M),o=5,a=0,m):rr(M)?(e.consume(M),o=4,r.interrupt?t:I):n(M)}function p(M){return M===45?(e.consume(M),r.interrupt?t:I):n(M)}function m(M){let ie="CDATA[";return M===ie.charCodeAt(a++)?(e.consume(M),a===ie.length?r.interrupt?t:f:m):n(M)}function b(M){return rr(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function T(M){if(M===null||M===47||M===62||qt(M)){let ie=M===47,K=s.toLowerCase();return!ie&&!i&&ax.includes(K)?(o=1,r.interrupt?t(M):f(M)):ST.includes(s.toLowerCase())?(o=6,ie?(e.consume(M),F):r.interrupt?t(M):f(M)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):i?v(M):D(M))}return M===45||gn(M)?(e.consume(M),s+=String.fromCharCode(M),T):n(M)}function F(M){return M===62?(e.consume(M),r.interrupt?t:f):n(M)}function v(M){return Ue(M)?(e.consume(M),v):w(M)}function D(M){return M===47?(e.consume(M),w):M===58||M===95||rr(M)?(e.consume(M),_):Ue(M)?(e.consume(M),D):w(M)}function _(M){return M===45||M===46||M===58||M===95||gn(M)?(e.consume(M),_):$(M)}function $(M){return M===61?(e.consume(M),L):Ue(M)?(e.consume(M),$):D(M)}function L(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),u=M,R):Ue(M)?(e.consume(M),L):h(M)}function R(M){return M===u?(e.consume(M),u=null,S):M===null||pe(M)?n(M):(e.consume(M),R)}function h(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||qt(M)?$(M):(e.consume(M),h)}function S(M){return M===47||M===62||Ue(M)?D(M):n(M)}function w(M){return M===62?(e.consume(M),A):n(M)}function A(M){return M===null||pe(M)?f(M):Ue(M)?(e.consume(M),A):n(M)}function f(M){return M===45&&o===2?(e.consume(M),C):M===60&&o===1?(e.consume(M),P):M===62&&o===4?(e.consume(M),z):M===63&&o===3?(e.consume(M),I):M===93&&o===5?(e.consume(M),N):pe(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(R6,W,k)(M)):M===null||pe(M)?(e.exit("htmlFlowData"),k(M)):(e.consume(M),f)}function k(M){return e.check(z6,E,W)(M)}function E(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),x}function x(M){return M===null||pe(M)?k(M):(e.enter("htmlFlowData"),f(M))}function C(M){return M===45?(e.consume(M),I):f(M)}function P(M){return M===47?(e.consume(M),s="",B):f(M)}function B(M){if(M===62){let ie=s.toLowerCase();return ax.includes(ie)?(e.consume(M),z):f(M)}return rr(M)&&s.length<8?(e.consume(M),s+=String.fromCharCode(M),B):f(M)}function N(M){return M===93?(e.consume(M),I):f(M)}function I(M){return M===62?(e.consume(M),z):M===45&&o===2?(e.consume(M),I):f(M)}function z(M){return M===null||pe(M)?(e.exit("htmlFlowData"),W(M)):(e.consume(M),z)}function W(M){return e.exit("htmlFlow"),t(M)}}function _6(e,t,n){let r=this;return o;function o(s){return pe(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 $6(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Wo,t,n)}}var cx={name:"htmlText",tokenize:U6};function U6(e,t,n){let r=this,o,i,s;return a;function a(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),u}function u(I){return I===33?(e.consume(I),c):I===47?(e.consume(I),$):I===63?(e.consume(I),D):rr(I)?(e.consume(I),h):n(I)}function c(I){return I===45?(e.consume(I),l):I===91?(e.consume(I),i=0,m):rr(I)?(e.consume(I),v):n(I)}function l(I){return I===45?(e.consume(I),p):n(I)}function d(I){return I===null?n(I):I===45?(e.consume(I),g):pe(I)?(s=d,P(I)):(e.consume(I),d)}function g(I){return I===45?(e.consume(I),p):d(I)}function p(I){return I===62?C(I):I===45?g(I):d(I)}function m(I){let z="CDATA[";return I===z.charCodeAt(i++)?(e.consume(I),i===z.length?b:m):n(I)}function b(I){return I===null?n(I):I===93?(e.consume(I),T):pe(I)?(s=b,P(I)):(e.consume(I),b)}function T(I){return I===93?(e.consume(I),F):b(I)}function F(I){return I===62?C(I):I===93?(e.consume(I),F):b(I)}function v(I){return I===null||I===62?C(I):pe(I)?(s=v,P(I)):(e.consume(I),v)}function D(I){return I===null?n(I):I===63?(e.consume(I),_):pe(I)?(s=D,P(I)):(e.consume(I),D)}function _(I){return I===62?C(I):D(I)}function $(I){return rr(I)?(e.consume(I),L):n(I)}function L(I){return I===45||gn(I)?(e.consume(I),L):R(I)}function R(I){return pe(I)?(s=R,P(I)):Ue(I)?(e.consume(I),R):C(I)}function h(I){return I===45||gn(I)?(e.consume(I),h):I===47||I===62||qt(I)?S(I):n(I)}function S(I){return I===47?(e.consume(I),C):I===58||I===95||rr(I)?(e.consume(I),w):pe(I)?(s=S,P(I)):Ue(I)?(e.consume(I),S):C(I)}function w(I){return I===45||I===46||I===58||I===95||gn(I)?(e.consume(I),w):A(I)}function A(I){return I===61?(e.consume(I),f):pe(I)?(s=A,P(I)):Ue(I)?(e.consume(I),A):S(I)}function f(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),o=I,k):pe(I)?(s=f,P(I)):Ue(I)?(e.consume(I),f):(e.consume(I),E)}function k(I){return I===o?(e.consume(I),o=void 0,x):I===null?n(I):pe(I)?(s=k,P(I)):(e.consume(I),k)}function E(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||qt(I)?S(I):(e.consume(I),E)}function x(I){return I===47||I===62||qt(I)?S(I):n(I)}function C(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function P(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),B}function B(I){return Ue(I)?Ve(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):N(I)}function N(I){return e.enter("htmlTextData"),s(I)}}var fi={name:"labelEnd",resolveAll:V6,resolveTo:G6,tokenize:q6},j6={tokenize:Y6},H6={tokenize:K6},W6={tokenize:X6};function V6(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&&xn(e,0,e.length,n),e}function G6(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=Bn(a,e.slice(i+1,i+r+3)),a=Bn(a,[["enter",l,t]]),a=Bn(a,is(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Bn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Bn(a,e.slice(s+1)),a=Bn(a,[["exit",u,t]]),xn(e,i,e.length,a),e}function q6(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(g){return i?i._inactive?d(g):(s=r.parser.defined.includes(ho(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(j6,l,s?l:d)(g):g===91?e.attempt(H6,l,s?c:d)(g):s?l(g):d(g)}function c(g){return e.attempt(W6,l,d)(g)}function l(g){return t(g)}function d(g){return i._balanced=!0,n(g)}}function Y6(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 qt(d)?gi(e,i)(d):i(d)}function i(d){return d===41?l(d):Yc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return qt(d)?gi(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?Xc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return qt(d)?gi(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 K6(e,t,n){let r=this;return o;function o(a){return Kc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(ho(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function X6(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 ux={name:"labelStartImage",resolveAll:fi.resolveAll,tokenize:Q6};function Q6(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 px={name:"labelStartLink",resolveAll:fi.resolveAll,tokenize:J6};function J6(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 Ma={name:"lineEnding",tokenize:Z6};function Z6(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}var mi={name:"thematicBreak",tokenize:eU};function eU(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||pe(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),Ue(c)?Ve(e,a,"whitespace")(c):a(c))}}var Tn={continuation:{tokenize:oU},exit:sU,name:"list",tokenize:rU},tU={partial:!0,tokenize:aU},nU={partial:!0,tokenize:iU};function rU(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 m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Ea(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(mi,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 Ea(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(Wo,r.interrupt?n:l,e.attempt(tU,g,d))}function l(p){return r.containerState.initialBlankLine=!0,i++,g(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),g):n(p)}function g(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function oU(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Wo,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||!Ue(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(nU,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(Tn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function iU(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 sU(e){e.exit(this.containerState.type)}function aU(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!Ue(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var Qc={name:"setextUnderline",resolveTo:lU,tokenize:cU};function lU(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 cU(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"),Ue(c)?Ve(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||pe(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var wT={tokenize:uU};function uU(e){let t=this,n=e.attempt(Wo,r,e.attempt(this.parser.constructs.flowInitial,o,Ve(e,e.attempt(this.parser.constructs.flow,o,e.attempt(rx,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 vT={resolveAll:IT()},kT=TT("string"),CT=TT("text");function TT(e){return{resolveAll:IT(e==="text"?pU: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],g=-1;if(d)for(;++g<d.length;){let p=d[g];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function IT(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 pU(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 dx={};ye(dx,{attentionMarkers:()=>bU,contentInitial:()=>gU,disable:()=>SU,document:()=>dU,flow:()=>mU,flowInitial:()=>fU,insideSpan:()=>yU,string:()=>hU,text:()=>xU});var dU={42:Tn,43:Tn,45:Tn,48:Tn,49:Tn,50:Tn,51:Tn,52:Tn,53:Tn,54:Tn,55:Tn,56:Tn,57:Tn,62:jc},gU={91:ox},fU={[-2]:Pa,[-1]:Pa,32:Pa},mU={35:sx,42:mi,45:[Qc,mi],60:lx,61:Qc,95:mi,96:Vc,126:Vc},hU={38:Wc,92:Hc},xU={[-5]:Ma,[-4]:Ma,[-3]:Ma,33:ux,38:Wc,42:Aa,60:[tx,cx],91:px,92:[ix,Hc],93:fi,95:Aa,96:nx},yU={null:[Aa,vT]},bU={null:[42,95]},SU={null:[]};function FT(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:S(R),check:S(h),consume:_,enter:$,exit:L,interrupt:S(h,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:T,parser:e,previous:null,sliceSerialize:m,sliceStream:b,write:p},d=t.tokenize.call(l,c),g;return t.resolveAll&&i.push(t),l;function p(k){return s=Bn(s,k),v(),s[s.length-1]!==null?[]:(w(t,0),l.events=is(i,l.events,l),l.events)}function m(k,E){return vU(b(k),E)}function b(k){return wU(s,k)}function T(){let{_bufferIndex:k,_index:E,line:x,column:C,offset:P}=r;return{_bufferIndex:k,_index:E,line:x,column:C,offset:P}}function F(k){o[k.line]=k.column,f()}function v(){let k;for(;r._index<s.length;){let E=s[r._index];if(typeof E=="string")for(k=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===k&&r._bufferIndex<E.length;)D(E.charCodeAt(r._bufferIndex));else D(E)}}function D(k){u=void 0,g=k,d=d(k)}function _(k){pe(k)?(r.line++,r.column=1,r.offset+=k===-3?2:1,f()):k!==-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=k,u=!0}function $(k,E){let x=E||{};return x.type=k,x.start=T(),l.events.push(["enter",x,l]),a.push(x),x}function L(k){let E=a.pop();return E.end=T(),l.events.push(["exit",E,l]),E}function R(k,E){w(k,E.from)}function h(k,E){E.restore()}function S(k,E){return x;function x(C,P,B){let N,I,z,W;return Array.isArray(C)?ie(C):"tokenize"in C?ie([C]):M(C);function M(Pe){return Ye;function Ye(ne){let Te=ne!==null&&Pe[ne],it=ne!==null&&Pe.null,te=[...Array.isArray(Te)?Te:Te?[Te]:[],...Array.isArray(it)?it:it?[it]:[]];return ie(te)(ne)}}function ie(Pe){return N=Pe,I=0,Pe.length===0?B:K(Pe[I])}function K(Pe){return Ye;function Ye(ne){return W=A(),z=Pe,Pe.partial||(l.currentConstruct=Pe),Pe.name&&l.parser.constructs.disable.null.includes(Pe.name)?xe(ne):Pe.tokenize.call(E?Object.assign(Object.create(l),E):l,c,ae,xe)(ne)}}function ae(Pe){return u=!0,k(z,W),P}function xe(Pe){return u=!0,W.restore(),++I<N.length?K(N[I]):B}}}function w(k,E){k.resolveAll&&!i.includes(k)&&i.push(k),k.resolve&&xn(l.events,E,l.events.length-E,k.resolve(l.events.slice(E),l)),k.resolveTo&&(l.events=k.resolveTo(l.events,l))}function A(){let k=T(),E=l.previous,x=l.currentConstruct,C=l.events.length,P=Array.from(a);return{from:C,restore:B};function B(){r=k,l.previous=E,l.currentConstruct=x,l.events.length=C,a=P,f()}}function f(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function wU(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 vU(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
+ `,Qoe=rn.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${R5} 0.8s linear infinite`,flexShrink:0})),S1=rn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(220, 38, 38, 0.18)":"#fee2e2",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626",whiteSpace:"nowrap"})),z5=rn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(22, 163, 74, 0.18)":"#dcfce7",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.positive||"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"})),Joe=rn.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:`${D5} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var Sa=rn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),wa=rn.span(({theme:e,color:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:t??e.color.mediumdark,whiteSpace:"nowrap"})),w1=rn.span(({theme:e,color:t})=>({fontSize:"12px",color:t??e.color.mediumdark})),va=rn.span(({color:e})=>({fontWeight:700,color:e})),N5=rn.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:`${t.layoutMargin*.6}px`,padding:`${t.layoutMargin*.3}px ${t.layoutMargin}px`,borderRadius:t.appBorderRadius*2,backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:t.typography.size.s1,color:t.textMutedColor},"& .score-value":{fontFamily:t.typography.fonts.mono,fontSize:t.typography.size.s2,fontWeight:t.typography.weight.bold,color:e,lineHeight:1},"& .score-dot":{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:e}})),Zoe=rn.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),eie=rn.span(({color:e=ce})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${L5} 1.2s ease-in-out infinite`,marginRight:"4px"})),tie=rn.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return ce;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 ce;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${B5} 1.5s ease-in-out infinite`}:{}})),nie=rn.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),rie=rn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),O5=rn.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${M5} 1.2s linear infinite`,flexShrink:0}),_5=({color:e=ce})=>De.createElement(O5,null,De.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 De.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),oie=rn.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:`${v1} 0.3s ease-out`}));function $5(e){let[t,n]=A5(0);return P5(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var k1=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,band:i,visualSimilarity:s,costUsd:a,inputTokens:u,outputTokens:c,showTimer:l=!0,cacheCreationTokens:d,cacheReadTokens:g,durationSeconds:p})=>{let h=$5(e||t),{featureFlags:b}=ue(),I=b.showCosts,F=3.65,v=z=>z<.01?`$${z.toFixed(4)}`:z<.1?`$${z.toFixed(3)}`:`$${z.toFixed(2)}`,D=z=>{let m=z*F;return m<.01?`\u20AA${m.toFixed(4)}`:m<.1?`\u20AA${m.toFixed(3)}`:`\u20AA${m.toFixed(2)}`},N=z=>z>=1e3?`${(z/1e3).toFixed(1)}K`:z.toString(),$=z=>z>=80?"score-high":z>=50?"score-medium":"score-low",M=z=>z>=80?"high":z>=50?"medium":"low";if(e)return De.createElement(Bh,null,De.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},h,"s \xB7 Esc to stop"));if(t)return De.createElement(Bh,null,De.createElement(S1,null,De.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),De.createElement(Sa,null,"|"),De.createElement(wa,null,De.createElement(_5,{color:"#7c3aed"}),De.createElement(va,{color:"#7c3aed"},"Verifying...")),l&&De.createElement(De.Fragment,null,De.createElement(Sa,null,"|"),De.createElement(wa,null,De.createElement("span",{style:{color:"#6b7280"}},h,"s"))));if(r>0||o!==void 0){let z=(u||0)+(c||0),m=(g||0)>0,S=m&&u?Math.round(g/u*100):0,w=i?so[i]:100,A=Math.min(Math.max(o??0,s??0),w),f=E=>E>=80?"#16a34a":E>=50?"#ca8a04":"#dc2626",k=E=>E>=100?"\u25CF":E>=50?"\u25D0":"\u25CB";return De.createElement(Bh,null,r===0&&(o===void 0||o>=100)?De.createElement(z5,null,De.createElement("span",null,"\u2713"),"Perfect!"):De.createElement(S1,null,De.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),De.createElement(N5,{tint:f(A),title:i==="D"?`Band D \u2014 has critical issues. Fix criticals to score above ${so.D}.`:i==="C"?`Band C \u2014 has major issues. Fix majors to score above ${so.C}.`:i==="B"?"Band B \u2014 minor issues only.":i==="A"?"Band A \u2014 no open issues.":`Compliance score: ${A}%`},De.createElement("span",{className:"score-dot"}),De.createElement("span",{className:"score-label"},"Score"),De.createElement("span",{className:"score-value"},A,i?` \xB7 ${i}`:"")),I&&a!==void 0&&a>0&&De.createElement(De.Fragment,null,De.createElement(Sa,null,"|"),De.createElement(wa,null,De.createElement(va,{color:"#16a34a"},v(a)),De.createElement("span",{style:{color:"#6b7280"}},"/"),De.createElement(va,{color:"#16a34a"},D(a)))),I&&z>0&&De.createElement(De.Fragment,null,De.createElement(Sa,null,"|"),De.createElement(wa,{title:`Input: ${u?.toLocaleString()||0} \xB7 Output: ${c?.toLocaleString()||0}${m?` \xB7 Cached: ${g?.toLocaleString()}`:""}`},De.createElement(w1,{color:"#7c3aed"},"#"),De.createElement(va,{color:"#7c3aed"},N(z)),De.createElement("span",{style:{color:"#6b7280"}},"tokens"),m&&De.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",S,"%"))),p!==void 0&&p>0&&De.createElement(De.Fragment,null,De.createElement(Sa,null,"|"),De.createElement(wa,null,De.createElement(w1,{color:"#6b7280"},"\u23F1"),De.createElement(va,{color:"#6b7280"},p,"s"))))}return null};var V5=Bn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),mie=Bn.div({display:"flex",gap:"8px",alignItems:"center"}),G5=W5({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),q5=Bn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${G5} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),Y5=Bn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),K5=Bn.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin}px`,padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.2}px`,borderRadius:e.appBorderRadius*2,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.03)",flexWrap:"wrap"})),X5=Bn.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:nl},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:e.color.inverseText,border:"none",padding:`${e.layoutMargin*.7}px ${e.layoutMargin*1.4}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,borderRadius:e.appBorderRadius,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)`}}}),Q5=Bn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),J5=Bn.div({marginLeft:"auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",minWidth:0}),Z5=Bn(Sn)({width:"auto",minWidth:"180px",maxWidth:"260px"}),C1=Bn.span(({theme:e,variant:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,padding:"3px 8px",borderRadius:"10px",whiteSpace:"nowrap",color:t==="latest"?e.color.positive:e.color.mediumdark,backgroundColor:t==="latest"?`${e.color.positive}1a`:e.background.hoverable})),e3=Bn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),T1=Bn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),I1=Bn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?nl:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),F1=Bn.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)"})),E1=Bn.input({position:"absolute",opacity:0,width:0,height:0}),t3=()=>{let[e,t]=j5(0),n=H5();A1(()=>(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 ut.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},Dh=()=>{let{sessionToken:e}=Js(),{usageData:t}=Se(),{selectedProjectId:n}=co(),{currentMapping:r,hasMapping:o}=ai(),{loadingMapping:i,currentStoryId:s}=Ze(),{startReview:a,cancelReview:u,isReviewing:c}=Pm(),{isLoadingScreenshots:l}=ii(),{storybookImageUrl:d,figmaImageUrl:g,currentReviewId:p,reviewHistory:h,setReviewDetailTab:b,setReviewResults:I,setFigmaImageUrl:F,setStorybookImageUrl:v,setFullPrompt:D,setFullResponse:N,includeTextComparison:$,setIncludeTextComparison:M,usePromptCache:z,setUsePromptCache:m,isValidating:S,validationUsage:w,isGenerating:A,isApplying:f,streamingStatus:k,featureFlags:E,userRole:x,roleOverride:T,isReviewing:P}=ue(),B=t?.reviewCredits??t?.creditBalance??0,_=h.find(fe=>fe.id===p),R=(_?.issues||[]).filter(fe=>!fe.dismissed).length,H=_?Ph(_):null,L=H?.score,ie=H?.band,K=_?.visualSimilarity,se=(_?.costUsd||0)+(w?.costUsd||0),me=(_?.inputTokens||0)+(w?.inputTokens||0),Pe=(_?.outputTokens||0)+(w?.outputTokens||0),Ge=U5(()=>{let fe=s?h.filter(O=>O.storyId===s):h,Fe=fe.filter(O=>!O.parentReviewId).sort((O,j)=>new Date(j.createdAt).getTime()-new Date(O.createdAt).getTime()),q=fe.filter(O=>O.parentReviewId),je=[];for(let O of Fe){je.push(O);let j=q.filter(G=>G.parentReviewId===O.id).sort((G,W)=>(G.iterationNumber||0)-(W.iterationNumber||0));je.push(...j)}let gt=q.filter(O=>!Fe.some(j=>j.id===O.parentReviewId));return je.push(...gt),je},[h,s]);A1(()=>{if(!c)return;let fe=Fe=>{Fe.key==="Escape"&&(Fe.preventDefault(),u())};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[c,u]);let re=o&&r?.figmaNodeId,Te=A||f,it=B>0,ne=!!(e&&n&&!c&&!l&&!Te&&s&&d&&re&&g&&it),Be=async(fe=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{b("chat"),await a({isIteration:fe,parentReviewId:fe?p:void 0})}catch(Fe){console.error("[ReviewActions] Review error:",Fe)}},ge=()=>Be(!1),dt=fe=>{let Fe=fe.target.value;if(Fe){let q=h.find(je=>je.id===Fe);q&&(I({id:q.id,componentId:q.componentId,storyId:q.storyId,modelId:q.modelId,complianceScore:q.complianceScore,issuesCount:q.issuesCount,issues:q.issues,createdAt:new Date(q.createdAt),visualSimilarity:q.visualSimilarity,timestamp:new Date(q.createdAt).toISOString(),costUsd:q.costUsd,inputTokens:q.inputTokens,outputTokens:q.outputTokens,cacheCreationTokens:q.cacheCreationTokens,cacheReadTokens:q.cacheReadTokens,reviewDurationMs:q.reviewDurationMs}),q.figmaImageData&&F(q.figmaImageData),q.storybookImageData&&v(q.storybookImageData),(T??x)==="admin"&&(D(q.aiPrompt||""),N(q.aiResponse||"")),b("issues"))}},ot=fe=>{let Fe=new Date(fe),je=new Date().getTime()-Fe.getTime(),gt=Math.floor(je/6e4),O=Math.floor(je/36e5),j=Math.floor(je/864e5);return gt<1?"Just now":gt<60?`${gt}m ago`:O<24?`${O}h ago`:j<7?`${j}d ago`:Fe.toLocaleDateString()},bn=fe=>fe?fe.includes("haiku")?"Haiku":fe.includes("sonnet")?"Sonnet":fe.includes("opus")?"Opus":fe.includes("gpt-4o-mini")?"GPT-4o mini":fe.includes("gpt-4o")?"GPT-4o":fe.includes("gpt-4")?"GPT-4":fe.includes("o3")?"o3":fe.includes("o1")?"o1":fe.split("-")[0]||"":"",br=fe=>{let Fe=fe.split("--"),q=Fe[Fe.length-1]||fe;return q.charAt(0).toUpperCase()+q.slice(1)},or=(T??x)==="admin";return ut.createElement("div",null,ut.createElement(V5,null,E.enableModelSelection&&ut.createElement(b1,null),or&&ut.createElement(e3,null,ut.createElement(T1,{title:"Compare text content between Figma design and Storybook component"},ut.createElement(E1,{type:"checkbox",checked:$,onChange:fe=>M(fe.target.checked)}),ut.createElement(I1,{checked:$},ut.createElement(F1,{checked:$})),"Compare text"),E.showCosts&&ut.createElement(T1,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ut.createElement(E1,{type:"checkbox",checked:z,onChange:fe=>m(fe.target.checked)}),ut.createElement(I1,{checked:z},ut.createElement(F1,{checked:z})),"Cache prompt")),ut.createElement(K5,null,ut.createElement(X5,{variant:c?"yellow":"purple",disabled:c?!1:!ne,onClick:c?u:ge,title:c?"Click to stop review":e?n?s?re?l?"Loading screenshots...":Te?"Wait for fixes to complete...":d?g?it?"Review this component implementation":"No credits \u2014 click \u26A1 in the toolbar to get more":"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 ${Et.NAME} first`},c?ut.createElement(ut.Fragment,null,ut.createElement(q5,null),"Reviewing",ut.createElement(t3,null)):ut.createElement(ut.Fragment,null,ut.createElement(Y5,null,ut.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ut.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ut.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),P?null:S||_?ut.createElement(k1,{isReviewing:!1,isValidating:S,streamingStatus:k,issueCount:R,score:L,band:ie,visualSimilarity:K,costUsd:se||_?.costUsd,inputTokens:me||_?.inputTokens,outputTokens:Pe||_?.outputTokens,cacheCreationTokens:_?.cacheCreationTokens,cacheReadTokens:_?.cacheReadTokens,durationSeconds:_?.reviewDurationMs?Math.round(_.reviewDurationMs/1e3):void 0}):null,Ge.length>0&&ut.createElement(J5,null,p&&(p===Ge[0]?.id?ut.createElement(C1,{variant:"latest",title:"You're viewing the most recent review for this story"},"Latest"):ut.createElement(C1,{variant:"older",title:"You're viewing an older review \u2014 pick the top entry to see the latest"},"Older review")),ut.createElement(Z5,{value:p||"",onChange:dt,title:"Review history"},ut.createElement("option",{value:""},"Select a review..."),Ge.map(fe=>{let Fe=!!fe.parentReviewId,q=Fe?" \u21B3 ":"\u25CF ",je=Fe&&fe.iterationNumber?`Iter ${fe.iterationNumber} - `:"",gt=fe.issuesCount??fe.issues?.length??0,{score:O,band:j}=Ph(fe),G=fe.complianceScore!=null?O:"--",W=bn(fe.modelId);return ut.createElement("option",{key:fe.id,value:fe.id},q,je,ot(fe.createdAt)," - ",gt," issues (",G,"%",j?` \xB7 ${j}`:"",")",E.showCosts&&W?` \xB7 ${W}`:"",!s&&fe.storyId?` \xB7 ${br(fe.storyId)}`:"")}))))),!re&&!i&&ut.createElement(Q5,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import yie,{useState as bie}from"react";import{styled as P1}from"storybook/theming";var vie=P1.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),kie=P1(Co)({padding:"8px 12px",fontSize:"12px"});import Iie,{useState as Fie}from"react";import{styled as Rh}from"storybook/theming";ve();$e();Ne();lt();var Die=Rh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),Rie=Rh(Or)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),zie=Rh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import _ie from"react";import{styled as n3}from"storybook/theming";var jie=n3.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));ve();import Vie from"react";import{styled as qr}from"storybook/theming";var Yie=qr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),Kie=qr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),Xie=qr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),Qie=qr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),Jie=qr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Zie=qr.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"})),ese=qr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),tse=qr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),nse=qr.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)"}}})),rse=qr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));ve();import sse,{useState as ase}from"react";import{styled as Yr}from"storybook/theming";var use=Yr.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)`}}),pse=Yr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),dse=Yr.div({display:"flex",alignItems:"center",gap:"8px"}),gse=Yr.span({fontSize:"12px",opacity:.7}),fse=Yr.span({fontSize:"13px",fontWeight:500}),mse=Yr.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})),hse=Yr.div({marginTop:"12px",fontSize:"11px"}),xse=Yr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),yse=Yr.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"})),bse=Yr.span({fontSize:"12px"});Ne();$e();import Jt from"react";import{styled as fs}from"storybook/theming";import zr,{useEffect as eV}from"react";import{styled as _a}from"storybook/theming";ve();import xi,{useState as yj}from"react";import{styled as ps}from"storybook/theming";var L1={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 M1(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var r3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,o3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,i3={};function Dc(e,t){return((t||i3).jsx?o3:r3).test(e)}var s3=/[ \t\n\f\r]/g;function zh(e){return typeof e=="object"?e.type==="text"?B1(e.value):!1:B1(e)}function B1(e){return e.replace(s3,"")===""}var mo=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};mo.prototype.normal={};mo.prototype.property={};mo.prototype.space=void 0;function Nh(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new mo(n,r,t)}function ka(e){return e.toLowerCase()}var dn=class{constructor(t,n){this.attribute=n,this.property=t}};dn.prototype.attribute="";dn.prototype.booleanish=!1;dn.prototype.boolean=!1;dn.prototype.commaOrSpaceSeparated=!1;dn.prototype.commaSeparated=!1;dn.prototype.defined=!1;dn.prototype.mustUseProperty=!1;dn.prototype.number=!1;dn.prototype.overloadedBoolean=!1;dn.prototype.property="";dn.prototype.spaceSeparated=!1;dn.prototype.space=void 0;var Ca={};ye(Ca,{boolean:()=>We,booleanish:()=>Ut,commaOrSpaceSeparated:()=>Yn,commaSeparated:()=>jo,number:()=>Q,overloadedBoolean:()=>Rc,spaceSeparated:()=>Ct});var a3=0,We=ui(),Ut=ui(),Rc=ui(),Q=ui(),Ct=ui(),jo=ui(),Yn=ui();function ui(){return 2**++a3}var Oh=Object.keys(Ca),pi=class extends dn{constructor(t,n,r,o){let i=-1;if(super(t,n),D1(this,"space",o),typeof r=="number")for(;++i<Oh.length;){let s=Oh[i];D1(this,Oh[i],(r&Ca[s])===Ca[s])}}};pi.prototype.defined=!0;function D1(e,t,n){n&&(e[t]=n)}function mr(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new pi(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ka(r)]=r,n[ka(i.attribute)]=r}return new mo(t,n,e.space)}var _h=mr({properties:{ariaActiveDescendant:null,ariaAtomic:Ut,ariaAutoComplete:null,ariaBusy:Ut,ariaChecked:Ut,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:Ct,ariaCurrent:null,ariaDescribedBy:Ct,ariaDetails:null,ariaDisabled:Ut,ariaDropEffect:Ct,ariaErrorMessage:null,ariaExpanded:Ut,ariaFlowTo:Ct,ariaGrabbed:Ut,ariaHasPopup:null,ariaHidden:Ut,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ct,ariaLevel:Q,ariaLive:null,ariaModal:Ut,ariaMultiLine:Ut,ariaMultiSelectable:Ut,ariaOrientation:null,ariaOwns:Ct,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Ut,ariaReadOnly:Ut,ariaRelevant:null,ariaRequired:Ut,ariaRoleDescription:Ct,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Ut,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function zc(e,t){return t in e?e[t]:t}function Nc(e,t){return zc(e,t.toLowerCase())}var R1=mr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:jo,acceptCharset:Ct,accessKey:Ct,action:null,allow:null,allowFullScreen:We,allowPaymentRequest:We,allowUserMedia:We,alt:null,as:null,async:We,autoCapitalize:null,autoComplete:Ct,autoFocus:We,autoPlay:We,blocking:Ct,capture:null,charSet:null,checked:We,cite:null,className:Ct,cols:Q,colSpan:null,content:null,contentEditable:Ut,controls:We,controlsList:Ct,coords:Q|jo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:We,defer:We,dir:null,dirName:null,disabled:We,download:Rc,draggable:Ut,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:We,formTarget:null,headers:Ct,height:Q,hidden:Rc,high:Q,href:null,hrefLang:null,htmlFor:Ct,httpEquiv:Ct,id:null,imageSizes:null,imageSrcSet:null,inert:We,inputMode:null,integrity:null,is:null,isMap:We,itemId:null,itemProp:Ct,itemRef:Ct,itemScope:We,itemType:Ct,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:We,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,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:Q,pattern:null,ping:Ct,placeholder:null,playsInline:We,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:We,referrerPolicy:null,rel:Ct,required:We,reversed:We,rows:Q,rowSpan:Q,sandbox:Ct,scope:null,scoped:We,seamless:We,selected:We,shadowRootClonable:We,shadowRootDelegatesFocus:We,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Ut,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:We,useMap:null,value:Ut,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ct,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,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:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:We,noHref:We,noShade:We,noWrap:We,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Ut,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:We,disableRemotePlayback:We,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:Nc});var z1=mr({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:Yn,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:Ct,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:We,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:jo,g2:jo,glyphName:jo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:Yn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,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:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ct,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yn,rev:Yn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yn,requiredFeatures:Yn,requiredFonts:Yn,requiredFormats:Yn,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:Yn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yn,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:zc});var $h=mr({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 Uh=mr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Nc});var jh=mr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Hh={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 l3=/[A-Z]/g,N1=/-[a-z]/g,c3=/^data[-\w.:]+$/i;function Wh(e,t){let n=ka(t),r=t,o=dn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&c3.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(N1,p3);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!N1.test(i)){let s=i.replace(l3,u3);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=pi}return new o(r,t)}function u3(e){return"-"+e.toLowerCase()}function p3(e){return e.charAt(1).toUpperCase()}var O1=Nh([_h,R1,$h,Uh,jh],"html"),Oc=Nh([_h,z1,$h,Uh,jh],"svg");function _1(e){return e.join(" ").trim()}var eT=tl(X1(),1);var $c=Q1("end"),is=Q1("start");function Q1(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 qh(e){let t=is(e),n=$c(e);if(t&&n)return{start:t,end:n}}function Ho(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?J1(e.position):"start"in e||"end"in e?J1(e):"line"in e||"column"in e?Yh(e):""}function Yh(e){return Z1(e&&e.line)+":"+Z1(e&&e.column)}function J1(e){return Yh(e&&e.start)+"-"+Yh(e&&e.end)}function Z1(e){return e&&typeof e=="number"?e:1}var Gt=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=Ho(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}};Gt.prototype.file="";Gt.prototype.name="";Gt.prototype.reason="";Gt.prototype.message="";Gt.prototype.stack="";Gt.prototype.column=void 0;Gt.prototype.line=void 0;Gt.prototype.ancestors=void 0;Gt.prototype.cause=void 0;Gt.prototype.fatal=void 0;Gt.prototype.place=void 0;Gt.prototype.ruleId=void 0;Gt.prototype.source=void 0;var Kh={}.hasOwnProperty,N3=new Map,O3=/[A-Z]/g,_3=new Set(["table","tbody","thead","tfoot","tr"]),$3=new Set(["td","th"]),tT="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Xh(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=Y3(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=q3(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"?Oc:O1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=nT(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function nT(e,t,n){if(t.type==="element")return U3(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return j3(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return W3(e,t,n);if(t.type==="mdxjsEsm")return H3(e,t);if(t.type==="root")return V3(e,t,n);if(t.type==="text")return G3(e,t)}function U3(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=Oc,e.schema=o),e.ancestors.push(t);let i=oT(e,t.tagName,!1),s=K3(e,t),a=Jh(e,t);return _3.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!zh(u):!0})),rT(e,s,i,t),Qh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function j3(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 H3(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ia(e,t.position)}function W3(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=Oc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:oT(e,t.name,!0),s=X3(e,t),a=Jh(e,t);return rT(e,s,i,t),Qh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function V3(e,t,n){let r={};return Qh(r,Jh(e,t)),e.create(t,e.Fragment,r,n)}function G3(e,t){return t.value}function rT(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Qh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function q3(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 Y3(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=is(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 K3(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&Kh.call(t.properties,o)){let i=Q3(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&$3.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 X3(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 Jh(e,t){let n=[],r=-1,o=e.passKeys?new Map:N3;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=nT(e,i,s);a!==void 0&&n.push(a)}return n}function Q3(e,t,n){let r=Wh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?M1(n):_1(n)),r.property==="style"){let o=typeof n=="object"?n:J3(e,String(n));return e.stylePropertyNameCase==="css"&&(o=Z3(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?Hh[r.property]||r.property:r.attribute,n]}}function J3(e,t){try{return(0,eT.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Gt("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=tT+"#cannot-parse-style-attribute",o}}function oT(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=Dc(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=Dc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return Kh.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 Gt("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=tT+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Z3(e){let t={},n;for(n in e)Kh.call(e,n)&&(t[e6(n)]=e[n]);return t}function e6(e){let t=e.replace(O3,t6);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function t6(e){return"-"+e.toLowerCase()}var Fa={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 cj,jsx as uj,jsxs as pj}from"react/jsx-runtime";import{useEffect as Lge,useState as Mge}from"react";var n6={};function Zh(e,t){let n=t||n6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return sT(e,r,o)}function sT(e,t,n){if(r6(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 iT(e.children,t,n)}return Array.isArray(e)?iT(e,t,n):""}function iT(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=sT(e[o],t,n);return r.join("")}function r6(e){return!!(e&&typeof e=="object")}var aT=document.createElement("i");function ss(e){let t="&"+e+";";aT.innerHTML=t;let n=aT.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xn(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 Dn(e,t){return e.length>0?(xn(e,e.length,0,t),e):t}var lT={}.hasOwnProperty;function cT(e){let t={},n=-1;for(;++n<e.length;)o6(t,e[n]);return t}function o6(e,t){let n;for(n in t){let o=(lT.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){lT.call(o,s)||(o[s]=[]);let a=i[s];i6(o[s],Array.isArray(a)?a:a?[a]:[])}}}function i6(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);xn(e,0,0,r)}function Uc(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 ho(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var rr=Wo(/[A-Za-z]/),gn=Wo(/[\dA-Za-z]/),uT=Wo(/[#-'*+\--9=?A-Z^-~]/);function Ea(e){return e!==null&&(e<32||e===127)}var Aa=Wo(/\d/),pT=Wo(/[\dA-Fa-f]/),dT=Wo(/[!-/:-@[-`{-~]/);function pe(e){return e!==null&&e<-2}function qt(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}var gT=Wo(/\p{P}|\p{S}/u),fT=Wo(/\s/);function Wo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function hr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&gn(e.charCodeAt(n+1))&&gn(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 Ue(u)?(e.enter(n),a(u)):t(u)}function a(u){return Ue(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var mT={tokenize:s6};function s6(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 pe(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var xT={tokenize:a6},hT={tokenize:l6};function a6(e){let t=this,n=[],r=0,o,i,s;return a;function a(D){if(r<n.length){let N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,u,c)(D)}return c(D)}function u(D){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&v();let N=t.events.length,$=N,M;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){M=t.events[$][1].end;break}F(r);let z=N;for(;z<t.events.length;)t.events[z][1].end={...M},z++;return xn(t.events,$+1,0,t.events.slice(N)),t.events.length=z,c(D)}return a(D)}function c(D){if(r===n.length){if(!o)return g(D);if(o.currentConstruct&&o.currentConstruct.concrete)return h(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(hT,l,d)(D)}function l(D){return o&&v(),F(r),g(D)}function d(D){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,h(D)}function g(D){return t.containerState={},e.attempt(hT,p,h)(D)}function p(D){return r++,n.push([t.currentConstruct,t.containerState]),g(D)}function h(D){if(D===null){o&&v(),F(0),e.consume(D);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),b(D)}function b(D){if(D===null){I(e.exit("chunkFlow"),!0),F(0),e.consume(D);return}return pe(D)?(e.consume(D),I(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(D),b)}function I(D,N){let $=t.sliceStream(D);if(N&&$.push(null),D.previous=i,i&&(i.next=D),i=D,o.defineSkip(D.start),o.write($),t.parser.lazy[D.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 z=t.events.length,m=z,S,w;for(;m--;)if(t.events[m][0]==="exit"&&t.events[m][1].type==="chunkFlow"){if(S){w=t.events[m][1].end;break}S=!0}for(F(r),M=z;M<t.events.length;)t.events[M][1].end={...w},M++;xn(t.events,m+1,0,t.events.slice(z)),t.events.length=M}}function F(D){let N=n.length;for(;N-- >D;){let $=n[N];t.containerState=$[1],$[0].exit.call(t,e)}n.length=D}function v(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function l6(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 ex(e){if(e===null||qt(e)||fT(e))return 1;if(gT(e))return 2}function as(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 Pa={name:"attention",resolveAll:c6,tokenize:u6};function c6(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},g={...e[n][1].start};yT(d,-u),yT(g,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:g},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=Dn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Dn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=Dn(c,as(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Dn(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=Dn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,xn(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 u6(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=ex(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=ex(u),d=!l||l===2&&o||n.includes(u),g=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?d:d&&(o||!g)),c._close=!!(i===42?g:g&&(l||!d)),t(u)}}function yT(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var tx={name:"autolink",tokenize:p6};function p6(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 rr(p)?(e.consume(p),s):p===64?n(p):c(p)}function s(p){return p===43||p===45||p===46||gn(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||gn(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||Ea(p)?n(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),l):uT(p)?(e.consume(p),c):n(p)}function l(p){return gn(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):g(p)}function g(p){if((p===45||gn(p))&&r++<63){let h=p===45?g:d;return e.consume(p),h}return n(p)}}var Vo={partial:!0,tokenize:d6};function d6(e,t,n){return r;function r(i){return Ue(i)?Ve(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||pe(i)?t(i):n(i)}}var jc={continuation:{tokenize:f6},exit:m6,name:"blockQuote",tokenize:g6};function g6(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 Ue(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function f6(e,t,n){let r=this;return o;function o(s){return Ue(s)?Ve(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(jc,t,n)(s)}}function m6(e){e.exit("blockQuote")}var Hc={name:"characterEscape",tokenize:h6};function h6(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 dT(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Wc={name:"characterReference",tokenize:x6};function x6(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=gn,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=pT,l):(e.enter("characterReferenceValue"),i=7,s=Aa,l(d))}function l(d){if(d===59&&o){let g=e.exit("characterReferenceValue");return s===gn&&!ss(r.sliceSerialize(g))?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 bT={partial:!0,tokenize:b6},Vc={concrete:!0,name:"codeFenced",tokenize:y6};function y6(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 z=r.events[r.events.length-1];return i=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[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"),Ue(M)?Ve(e,d,"whitespace")(M):d(M))}function d(M){return M===null||pe(M)?(e.exit("codeFencedFence"),r.interrupt?t(M):e.check(bT,b,N)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(M))}function g(M){return M===null||pe(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(M)):Ue(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(M)):M===96&&M===a?n(M):(e.consume(M),g)}function p(M){return M===null||pe(M)?d(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(M))}function h(M){return M===null||pe(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(M)):M===96&&M===a?n(M):(e.consume(M),h)}function b(M){return e.attempt(o,N,I)(M)}function I(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),F}function F(M){return i>0&&Ue(M)?Ve(e,v,"linePrefix",i+1)(M):v(M)}function v(M){return M===null||pe(M)?e.check(bT,b,N)(M):(e.enter("codeFlowValue"),D(M))}function D(M){return M===null||pe(M)?(e.exit("codeFlowValue"),v(M)):(e.consume(M),D)}function N(M){return e.exit("codeFenced"),t(M)}function $(M,z,m){let S=0;return w;function w(x){return M.enter("lineEnding"),M.consume(x),M.exit("lineEnding"),A}function A(x){return M.enter("codeFencedFence"),Ue(x)?Ve(M,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):f(x)}function f(x){return x===a?(M.enter("codeFencedFenceSequence"),k(x)):m(x)}function k(x){return x===a?(S++,M.consume(x),k):S>=s?(M.exit("codeFencedFenceSequence"),Ue(x)?Ve(M,E,"whitespace")(x):E(x)):m(x)}function E(x){return x===null||pe(x)?(M.exit("codeFencedFence"),z(x)):m(x)}}}function b6(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 La={name:"codeIndented",tokenize:w6},S6={partial:!0,tokenize:v6};function w6(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):pe(c)?e.attempt(S6,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||pe(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function v6(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):pe(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):pe(s)?o(s):n(s)}}var nx={name:"codeText",previous:C6,resolve:k6,tokenize:T6};function k6(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 C6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function T6(e,t,n){let r=this,o=0,i,s;return a;function a(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),o++,u):(e.exit("codeTextSequence"),c(g))}function c(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),c):g===96?(s=e.enter("codeTextSequence"),i=0,d(g)):pe(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(g))}function l(g){return g===null||g===32||g===96||pe(g)?(e.exit("codeTextData"),c(g)):(e.consume(g),l)}function d(g){return g===96?(e.consume(g),i++,d):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(s.type="codeTextData",l(g))}}var Gc=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&&Ma(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),Ma(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ma(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);Ma(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ma(this.left,n.reverse())}}};function Ma(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 qc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Gc(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,I6(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 xn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function I6(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,g=-1,p=n,h=0,b=0,I=[b];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;++g<a.length;)a[g][0]==="exit"&&a[g-1][0]==="enter"&&a[g][1].type===a[g-1][1].type&&a[g][1].start.line!==a[g][1].end.line&&(b=g+1,I.push(b),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):I.pop(),g=I.length;g--;){let F=a.slice(I[g],I[g+1]),v=i.pop();u.push([v,v+F.length-1]),e.splice(v,2,F)}for(u.reverse(),g=-1;++g<u.length;)c[h+u[g][0]]=h+u[g][1],h+=u[g][1]-u[g][0]-1;return c}var rx={resolve:E6,tokenize:A6},F6={partial:!0,tokenize:P6};function E6(e){return qc(e),e}function A6(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):pe(a)?e.check(F6,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 P6(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||pe(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 Yc(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),g):F===null||F===32||F===41||Ea(F)?n(F):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),b(F))}function g(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),g(F)):F===null||F===60||pe(F)?n(F):(e.consume(F),F===92?h:p)}function h(F){return F===60||F===62||F===92?(e.consume(F),p):p(F)}function b(F){return!l&&(F===null||F===41||qt(F))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(F)):l<c&&F===40?(e.consume(F),l++,b):F===41?(e.consume(F),l--,b):F===null||F===32||F===40||Ea(F)?n(F):(e.consume(F),F===92?I:b)}function I(F){return F===40||F===41||F===92?(e.consume(F),b):b(F)}}function Kc(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):pe(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||pe(p)||a++>999?(e.exit("chunkString"),l(p)):(e.consume(p),u||(u=!Ue(p)),p===92?g:d)}function g(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Xc(e,t,n,r,o,i){let s;return a;function a(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),s=g===40?41:g,u):n(g)}function u(g){return g===s?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),c(g))}function c(g){return g===s?(e.exit(i),u(s)):g===null?n(g):pe(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(g))}function l(g){return g===s||g===null||pe(g)?(e.exit("chunkString"),c(g)):(e.consume(g),g===92?d:l)}function d(g){return g===s||g===92?(e.consume(g),l):l(g)}}function gi(e,t){let n;return r;function r(o){return pe(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Ue(o)?Ve(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var ox={name:"definition",tokenize:M6},L6={partial:!0,tokenize:B6};function M6(e,t,n){let r=this,o;return i;function i(p){return e.enter("definition"),s(p)}function s(p){return Kc.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return o=ho(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 qt(p)?gi(e,c)(p):c(p)}function c(p){return Yc(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(L6,d,d)(p)}function d(p){return Ue(p)?Ve(e,g,"whitespace")(p):g(p)}function g(p){return p===null||pe(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function B6(e,t,n){return r;function r(a){return qt(a)?gi(e,o)(a):n(a)}function o(a){return Xc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return Ue(a)?Ve(e,s,"whitespace")(a):s(a)}function s(a){return a===null||pe(a)?t(a):n(a)}}var ix={name:"hardBreakEscape",tokenize:D6};function D6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return pe(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var sx={name:"headingAtx",resolve:R6,tokenize:z6};function R6(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"},xn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function z6(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||qt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||pe(l)?(e.exit("atxHeading"),t(l)):Ue(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||qt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var ST=["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"],ax=["pre","script","style","textarea"];var lx={concrete:!0,name:"htmlFlow",resolveTo:_6,tokenize:$6},N6={partial:!0,tokenize:j6},O6={partial:!0,tokenize:U6};function _6(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 $6(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),g):L===47?(e.consume(L),i=!0,b):L===63?(e.consume(L),o=3,r.interrupt?t:C):rr(L)?(e.consume(L),s=String.fromCharCode(L),I):n(L)}function g(L){return L===45?(e.consume(L),o=2,p):L===91?(e.consume(L),o=5,a=0,h):rr(L)?(e.consume(L),o=4,r.interrupt?t:C):n(L)}function p(L){return L===45?(e.consume(L),r.interrupt?t:C):n(L)}function h(L){let ie="CDATA[";return L===ie.charCodeAt(a++)?(e.consume(L),a===ie.length?r.interrupt?t:f:h):n(L)}function b(L){return rr(L)?(e.consume(L),s=String.fromCharCode(L),I):n(L)}function I(L){if(L===null||L===47||L===62||qt(L)){let ie=L===47,K=s.toLowerCase();return!ie&&!i&&ax.includes(K)?(o=1,r.interrupt?t(L):f(L)):ST.includes(s.toLowerCase())?(o=6,ie?(e.consume(L),F):r.interrupt?t(L):f(L)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):i?v(L):D(L))}return L===45||gn(L)?(e.consume(L),s+=String.fromCharCode(L),I):n(L)}function F(L){return L===62?(e.consume(L),r.interrupt?t:f):n(L)}function v(L){return Ue(L)?(e.consume(L),v):w(L)}function D(L){return L===47?(e.consume(L),w):L===58||L===95||rr(L)?(e.consume(L),N):Ue(L)?(e.consume(L),D):w(L)}function N(L){return L===45||L===46||L===58||L===95||gn(L)?(e.consume(L),N):$(L)}function $(L){return L===61?(e.consume(L),M):Ue(L)?(e.consume(L),$):D(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,z):Ue(L)?(e.consume(L),M):m(L)}function z(L){return L===u?(e.consume(L),u=null,S):L===null||pe(L)?n(L):(e.consume(L),z)}function m(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||qt(L)?$(L):(e.consume(L),m)}function S(L){return L===47||L===62||Ue(L)?D(L):n(L)}function w(L){return L===62?(e.consume(L),A):n(L)}function A(L){return L===null||pe(L)?f(L):Ue(L)?(e.consume(L),A):n(L)}function f(L){return L===45&&o===2?(e.consume(L),T):L===60&&o===1?(e.consume(L),P):L===62&&o===4?(e.consume(L),R):L===63&&o===3?(e.consume(L),C):L===93&&o===5?(e.consume(L),_):pe(L)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(N6,H,k)(L)):L===null||pe(L)?(e.exit("htmlFlowData"),k(L)):(e.consume(L),f)}function k(L){return e.check(O6,E,H)(L)}function E(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),x}function x(L){return L===null||pe(L)?k(L):(e.enter("htmlFlowData"),f(L))}function T(L){return L===45?(e.consume(L),C):f(L)}function P(L){return L===47?(e.consume(L),s="",B):f(L)}function B(L){if(L===62){let ie=s.toLowerCase();return ax.includes(ie)?(e.consume(L),R):f(L)}return rr(L)&&s.length<8?(e.consume(L),s+=String.fromCharCode(L),B):f(L)}function _(L){return L===93?(e.consume(L),C):f(L)}function C(L){return L===62?(e.consume(L),R):L===45&&o===2?(e.consume(L),C):f(L)}function R(L){return L===null||pe(L)?(e.exit("htmlFlowData"),H(L)):(e.consume(L),R)}function H(L){return e.exit("htmlFlow"),t(L)}}function U6(e,t,n){let r=this;return o;function o(s){return pe(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 j6(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Vo,t,n)}}var cx={name:"htmlText",tokenize:H6};function H6(e,t,n){let r=this,o,i,s;return a;function a(C){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(C),u}function u(C){return C===33?(e.consume(C),c):C===47?(e.consume(C),$):C===63?(e.consume(C),D):rr(C)?(e.consume(C),m):n(C)}function c(C){return C===45?(e.consume(C),l):C===91?(e.consume(C),i=0,h):rr(C)?(e.consume(C),v):n(C)}function l(C){return C===45?(e.consume(C),p):n(C)}function d(C){return C===null?n(C):C===45?(e.consume(C),g):pe(C)?(s=d,P(C)):(e.consume(C),d)}function g(C){return C===45?(e.consume(C),p):d(C)}function p(C){return C===62?T(C):C===45?g(C):d(C)}function h(C){let R="CDATA[";return C===R.charCodeAt(i++)?(e.consume(C),i===R.length?b:h):n(C)}function b(C){return C===null?n(C):C===93?(e.consume(C),I):pe(C)?(s=b,P(C)):(e.consume(C),b)}function I(C){return C===93?(e.consume(C),F):b(C)}function F(C){return C===62?T(C):C===93?(e.consume(C),F):b(C)}function v(C){return C===null||C===62?T(C):pe(C)?(s=v,P(C)):(e.consume(C),v)}function D(C){return C===null?n(C):C===63?(e.consume(C),N):pe(C)?(s=D,P(C)):(e.consume(C),D)}function N(C){return C===62?T(C):D(C)}function $(C){return rr(C)?(e.consume(C),M):n(C)}function M(C){return C===45||gn(C)?(e.consume(C),M):z(C)}function z(C){return pe(C)?(s=z,P(C)):Ue(C)?(e.consume(C),z):T(C)}function m(C){return C===45||gn(C)?(e.consume(C),m):C===47||C===62||qt(C)?S(C):n(C)}function S(C){return C===47?(e.consume(C),T):C===58||C===95||rr(C)?(e.consume(C),w):pe(C)?(s=S,P(C)):Ue(C)?(e.consume(C),S):T(C)}function w(C){return C===45||C===46||C===58||C===95||gn(C)?(e.consume(C),w):A(C)}function A(C){return C===61?(e.consume(C),f):pe(C)?(s=A,P(C)):Ue(C)?(e.consume(C),A):S(C)}function f(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),o=C,k):pe(C)?(s=f,P(C)):Ue(C)?(e.consume(C),f):(e.consume(C),E)}function k(C){return C===o?(e.consume(C),o=void 0,x):C===null?n(C):pe(C)?(s=k,P(C)):(e.consume(C),k)}function E(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||qt(C)?S(C):(e.consume(C),E)}function x(C){return C===47||C===62||qt(C)?S(C):n(C)}function T(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function P(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),B}function B(C){return Ue(C)?Ve(e,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):_(C)}function _(C){return e.enter("htmlTextData"),s(C)}}var fi={name:"labelEnd",resolveAll:q6,resolveTo:Y6,tokenize:K6},W6={tokenize:X6},V6={tokenize:Q6},G6={tokenize:J6};function q6(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&&xn(e,0,e.length,n),e}function Y6(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=Dn(a,e.slice(i+1,i+r+3)),a=Dn(a,[["enter",l,t]]),a=Dn(a,as(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=Dn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=Dn(a,e.slice(s+1)),a=Dn(a,[["exit",u,t]]),xn(e,i,e.length,a),e}function K6(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(g){return i?i._inactive?d(g):(s=r.parser.defined.includes(ho(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(W6,l,s?l:d)(g):g===91?e.attempt(V6,l,s?c:d)(g):s?l(g):d(g)}function c(g){return e.attempt(G6,l,d)(g)}function l(g){return t(g)}function d(g){return i._balanced=!0,n(g)}}function X6(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 qt(d)?gi(e,i)(d):i(d)}function i(d){return d===41?l(d):Yc(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return qt(d)?gi(e,u)(d):l(d)}function a(d){return n(d)}function u(d){return d===34||d===39||d===40?Xc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):l(d)}function c(d){return qt(d)?gi(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 Q6(e,t,n){let r=this;return o;function o(a){return Kc.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(ho(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function J6(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 ux={name:"labelStartImage",resolveAll:fi.resolveAll,tokenize:Z6};function Z6(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 px={name:"labelStartLink",resolveAll:fi.resolveAll,tokenize:eU};function eU(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 Ba={name:"lineEnding",tokenize:tU};function tU(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}var mi={name:"thematicBreak",tokenize:nU};function nU(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||pe(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),Ue(c)?Ve(e,a,"whitespace")(c):a(c))}}var In={continuation:{tokenize:sU},exit:lU,name:"list",tokenize:iU},rU={partial:!0,tokenize:cU},oU={partial:!0,tokenize:aU};function iU(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 h=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(h==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Aa(p)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(mi,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 Aa(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(Vo,r.interrupt?n:l,e.attempt(rU,g,d))}function l(p){return r.containerState.initialBlankLine=!0,i++,g(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),g):n(p)}function g(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function sU(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Vo,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||!Ue(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(oU,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(In,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function aU(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 lU(e){e.exit(this.containerState.type)}function cU(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!Ue(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var Qc={name:"setextUnderline",resolveTo:uU,tokenize:pU};function uU(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 pU(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"),Ue(c)?Ve(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||pe(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var wT={tokenize:dU};function dU(e){let t=this,n=e.attempt(Vo,r,e.attempt(this.parser.constructs.flowInitial,o,Ve(e,e.attempt(this.parser.constructs.flow,o,e.attempt(rx,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 vT={resolveAll:IT()},kT=TT("string"),CT=TT("text");function TT(e){return{resolveAll:IT(e==="text"?gU: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],g=-1;if(d)for(;++g<d.length;){let p=d[g];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function IT(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 gU(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 dx={};ye(dx,{attentionMarkers:()=>wU,contentInitial:()=>mU,disable:()=>vU,document:()=>fU,flow:()=>xU,flowInitial:()=>hU,insideSpan:()=>SU,string:()=>yU,text:()=>bU});var fU={42:In,43:In,45:In,48:In,49:In,50:In,51:In,52:In,53:In,54:In,55:In,56:In,57:In,62:jc},mU={91:ox},hU={[-2]:La,[-1]:La,32:La},xU={35:sx,42:mi,45:[Qc,mi],60:lx,61:Qc,95:mi,96:Vc,126:Vc},yU={38:Wc,92:Hc},bU={[-5]:Ba,[-4]:Ba,[-3]:Ba,33:ux,38:Wc,42:Pa,60:[tx,cx],91:px,92:[ix,Hc],93:fi,95:Pa,96:nx},SU={null:[Pa,vT]},wU={null:[42,95]},vU={null:[]};function FT(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:S(z),check:S(m),consume:N,enter:$,exit:M,interrupt:S(m,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:I,parser:e,previous:null,sliceSerialize:h,sliceStream:b,write:p},d=t.tokenize.call(l,c),g;return t.resolveAll&&i.push(t),l;function p(k){return s=Dn(s,k),v(),s[s.length-1]!==null?[]:(w(t,0),l.events=as(i,l.events,l),l.events)}function h(k,E){return CU(b(k),E)}function b(k){return kU(s,k)}function I(){let{_bufferIndex:k,_index:E,line:x,column:T,offset:P}=r;return{_bufferIndex:k,_index:E,line:x,column:T,offset:P}}function F(k){o[k.line]=k.column,f()}function v(){let k;for(;r._index<s.length;){let E=s[r._index];if(typeof E=="string")for(k=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===k&&r._bufferIndex<E.length;)D(E.charCodeAt(r._bufferIndex));else D(E)}}function D(k){u=void 0,g=k,d=d(k)}function N(k){pe(k)?(r.line++,r.column=1,r.offset+=k===-3?2:1,f()):k!==-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=k,u=!0}function $(k,E){let x=E||{};return x.type=k,x.start=I(),l.events.push(["enter",x,l]),a.push(x),x}function M(k){let E=a.pop();return E.end=I(),l.events.push(["exit",E,l]),E}function z(k,E){w(k,E.from)}function m(k,E){E.restore()}function S(k,E){return x;function x(T,P,B){let _,C,R,H;return Array.isArray(T)?ie(T):"tokenize"in T?ie([T]):L(T);function L(Pe){return Ge;function Ge(re){let Te=re!==null&&Pe[re],it=re!==null&&Pe.null,ne=[...Array.isArray(Te)?Te:Te?[Te]:[],...Array.isArray(it)?it:it?[it]:[]];return ie(ne)(re)}}function ie(Pe){return _=Pe,C=0,Pe.length===0?B:K(Pe[C])}function K(Pe){return Ge;function Ge(re){return H=A(),R=Pe,Pe.partial||(l.currentConstruct=Pe),Pe.name&&l.parser.constructs.disable.null.includes(Pe.name)?me(re):Pe.tokenize.call(E?Object.assign(Object.create(l),E):l,c,se,me)(re)}}function se(Pe){return u=!0,k(R,H),P}function me(Pe){return u=!0,H.restore(),++C<_.length?K(_[C]):B}}}function w(k,E){k.resolveAll&&!i.includes(k)&&i.push(k),k.resolve&&xn(l.events,E,l.events.length-E,k.resolve(l.events.slice(E),l)),k.resolveTo&&(l.events=k.resolveTo(l.events,l))}function A(){let k=I(),E=l.previous,x=l.currentConstruct,T=l.events.length,P=Array.from(a);return{from:T,restore:B};function B(){r=k,l.previous=E,l.currentConstruct=x,l.events.length=T,a=P,f()}}function f(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function kU(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 CU(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 gx(e){let r={constructs:cT([dx,...(e||{}).extensions||[]]),content:o(mT),defined:[],document:o(xT),flow:o(wT),lazy:{},string:o(kT),text:o(CT)};return r;function o(i){return s;function s(a){return FT(r,i,a)}}}function fx(e){for(;!qc(e););return e}var ET=/[\0\t\n\r]/g;function mx(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,d,g,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(ET.lastIndex=d,c=ET.exec(i),g=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(g),!c){t=i.slice(d);break}if(p===10&&d===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<g&&(u.push(i.slice(d,g)),e+=g-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=g+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var kU=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function AT(e){return e.replace(kU,CU)}function CU(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Uc(n.slice(i?2:1),i?16:10)}return os(n)||e}var LT={}.hasOwnProperty;function hx(e,t,n){return typeof t!="string"&&(n=t,t=void 0),TU(n)(fx(gx(n).document().write(mx()(e,t,!0))))}function TU(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(br),autolinkProtocol:S,autolinkEmail:S,atxHeading:i(ge),blockQuote:i(ne),characterEscape:S,characterReference:S,codeFenced:i(Te),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Te,s),codeText:i(it,s),codeTextData:S,data:S,codeFlowValue:S,definition:i(te),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(Be),hardBreakEscape:i(dt),hardBreakTrailing:i(dt),htmlFlow:i(ot,s),htmlFlowData:S,htmlText:i(ot,s),htmlTextData:S,image:i(bn),label:s,link:i(br),listItem:i(fe),listItemValue:g,listOrdered:i(or,d),listUnordered:i(or),paragraph:i(Fe),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(ge),strong:i(q),thematicBreak:i(gt)},exit:{atxHeading:u(),atxHeadingSequence:$,autolink:u(),autolinkEmail:Ye,autolinkProtocol:Pe,blockQuote:u(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:K,characterReferenceMarkerNumeric:K,characterReferenceValue:ae,characterReference:xe,codeFenced:u(T),codeFencedFence:b,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:u(F),codeText:u(x),codeTextData:w,data:w,definition:u(),definitionDestinationString:_,definitionLabelString:v,definitionTitleString:D,emphasis:u(),hardBreakEscape:u(f),hardBreakTrailing:u(f),htmlFlow:u(k),htmlFlowData:w,htmlText:u(E),htmlTextData:w,image:u(P),label:N,labelText:B,lineEnding:A,link:u(C),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ie,resourceDestinationString:I,resourceTitleString:z,resource:W,setextHeading:u(h),setextHeadingLineSequence:R,setextHeadingText:L,strong:u(),thematicBreak:u()}};MT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let j={type:"root",children:[]},G={stack:[j],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},H=[],le=-1;for(;++le<O.length;)if(O[le][1].type==="listOrdered"||O[le][1].type==="listUnordered")if(O[le][0]==="enter")H.push(le);else{let me=H.pop();le=o(O,me,le)}for(le=-1;++le<O.length;){let me=t[O[le][0]];LT.call(me,O[le][1].type)&&me[O[le][1].type].call(Object.assign({sliceSerialize:O[le][2].sliceSerialize},G),O[le][1])}if(G.tokenStack.length>0){let me=G.tokenStack[G.tokenStack.length-1];(me[1]||PT).call(G,void 0,me[0])}for(j.position={start:Vo(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Vo(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},le=-1;++le<t.transforms.length;)j=t.transforms[le](j)||j;return j}function o(O,j,G){let H=j-1,le=-1,me=!1,Dn,vt,Sr,So;for(;++H<=G;){let $t=O[H];switch($t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{$t[0]==="enter"?le++:le--,So=void 0;break}case"lineEndingBlank":{$t[0]==="enter"&&(Dn&&!So&&!le&&!Sr&&(Sr=H),So=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:So=void 0}if(!le&&$t[0]==="enter"&&$t[1].type==="listItemPrefix"||le===-1&&$t[0]==="exit"&&($t[1].type==="listUnordered"||$t[1].type==="listOrdered")){if(Dn){let Xr=H;for(vt=void 0;Xr--;){let wr=O[Xr];if(wr[1].type==="lineEnding"||wr[1].type==="lineEndingBlank"){if(wr[0]==="exit")continue;vt&&(O[vt][1].type="lineEndingBlank",me=!0),wr[1].type="lineEnding",vt=Xr}else if(!(wr[1].type==="linePrefix"||wr[1].type==="blockQuotePrefix"||wr[1].type==="blockQuotePrefixWhitespace"||wr[1].type==="blockQuoteMarker"||wr[1].type==="listItemIndent"))break}Sr&&(!vt||Sr<vt)&&(Dn._spread=!0),Dn.end=Object.assign({},vt?O[vt][1].start:$t[1].end),O.splice(vt||H,0,["exit",Dn,$t[2]]),H++,G++}if($t[1].type==="listItemPrefix"){let Xr={type:"listItem",_spread:!1,start:Object.assign({},$t[1].start),end:void 0};Dn=Xr,O.splice(H,0,["enter",Xr,$t[2]]),H++,G++,Sr=void 0,So=!0}}}return O[j][1]._spread=me,G}function i(O,j){return G;function G(H){a.call(this,O(H),H),j&&j.call(this,H)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,j,G){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([j,G||void 0]),O.position={start:Vo(j.start),end:void 0}}function u(O){return j;function j(G){O&&O.call(this,G),c.call(this,G)}}function c(O,j){let G=this.stack.pop(),H=this.tokenStack.pop();if(H)H[0].type!==O.type&&(j?j.call(this,O,H[0]):(H[1]||PT).call(this,O,H[0]));else throw new Error("Cannot close `"+O.type+"` ("+jo({start:O.start,end:O.end})+"): it\u2019s not open");G.position.end=Vo(O.end)}function l(){return Zh(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function g(O){if(this.data.expectingFirstListItemValue){let j=this.stack[this.stack.length-2];j.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),j=this.stack[this.stack.length-1];j.lang=O}function m(){let O=this.resume(),j=this.stack[this.stack.length-1];j.meta=O}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function F(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/(\r?\n|\r)$/g,"")}function v(O){let j=this.resume(),G=this.stack[this.stack.length-1];G.label=j,G.identifier=ho(this.sliceSerialize(O)).toLowerCase()}function D(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function _(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function $(O){let j=this.stack[this.stack.length-1];if(!j.depth){let G=this.sliceSerialize(O).length;j.depth=G}}function L(){this.data.setextHeadingSlurpLineEnding=!0}function R(O){let j=this.stack[this.stack.length-1];j.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function h(){this.data.setextHeadingSlurpLineEnding=void 0}function S(O){let G=this.stack[this.stack.length-1].children,H=G[G.length-1];(!H||H.type!=="text")&&(H=je(),H.position={start:Vo(O.start),end:void 0},G.push(H)),this.stack.push(H)}function w(O){let j=this.stack.pop();j.value+=this.sliceSerialize(O),j.position.end=Vo(O.end)}function A(O){let j=this.stack[this.stack.length-1];if(this.data.atHardBreak){let G=j.children[j.children.length-1];G.position.end=Vo(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(j.type)&&(S.call(this,O),w.call(this,O))}function f(){this.data.atHardBreak=!0}function k(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function E(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function x(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function C(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,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 j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function B(O){let j=this.sliceSerialize(O),G=this.stack[this.stack.length-2];G.label=AT(j),G.identifier=ho(j).toLowerCase()}function N(){let O=this.stack[this.stack.length-1],j=this.resume(),G=this.stack[this.stack.length-1];if(this.data.inReference=!0,G.type==="link"){let H=O.children;G.children=H}else G.alt=j}function I(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function z(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function W(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function ie(O){let j=this.resume(),G=this.stack[this.stack.length-1];G.label=j,G.identifier=ho(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function K(O){this.data.characterReferenceType=O.type}function ae(O){let j=this.sliceSerialize(O),G=this.data.characterReferenceType,H;G?(H=Uc(j,G==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):H=os(j);let le=this.stack[this.stack.length-1];le.value+=H}function xe(O){let j=this.stack.pop();j.position.end=Vo(O.end)}function Pe(O){w.call(this,O);let j=this.stack[this.stack.length-1];j.url=this.sliceSerialize(O)}function Ye(O){w.call(this,O);let j=this.stack[this.stack.length-1];j.url="mailto:"+this.sliceSerialize(O)}function ne(){return{type:"blockquote",children:[]}}function Te(){return{type:"code",lang:null,meta:null,value:""}}function it(){return{type:"inlineCode",value:""}}function te(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Be(){return{type:"emphasis",children:[]}}function ge(){return{type:"heading",depth:0,children:[]}}function dt(){return{type:"break"}}function ot(){return{type:"html",value:""}}function bn(){return{type:"image",title:null,url:"",alt:null}}function br(){return{type:"link",title:null,url:"",children:[]}}function or(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function fe(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function Fe(){return{type:"paragraph",children:[]}}function q(){return{type:"strong",children:[]}}function je(){return{type:"text",value:""}}function gt(){return{type:"thematicBreak"}}}function Vo(e){return{line:e.line,column:e.column,offset:e.offset}}function MT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?MT(e,r):IU(e,r)}}function IU(e,t){let n;for(n in t)if(LT.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 PT(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+jo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+jo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+jo({start:t.start,end:t.end})+") is still open")}function Jc(e){let t=this;t.parser=n;function n(r){return hx(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function BT(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 DT(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{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 gx(e){let r={constructs:cT([dx,...(e||{}).extensions||[]]),content:o(mT),defined:[],document:o(xT),flow:o(wT),lazy:{},string:o(kT),text:o(CT)};return r;function o(i){return s;function s(a){return FT(r,i,a)}}}function fx(e){for(;!qc(e););return e}var ET=/[\0\t\n\r]/g;function mx(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,d,g,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(ET.lastIndex=d,c=ET.exec(i),g=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(g),!c){t=i.slice(d);break}if(p===10&&d===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<g&&(u.push(i.slice(d,g)),e+=g-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=g+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var TU=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function AT(e){return e.replace(TU,IU)}function IU(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Uc(n.slice(i?2:1),i?16:10)}return ss(n)||e}var LT={}.hasOwnProperty;function hx(e,t,n){return typeof t!="string"&&(n=t,t=void 0),FU(n)(fx(gx(n).document().write(mx()(e,t,!0))))}function FU(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(br),autolinkProtocol:S,autolinkEmail:S,atxHeading:i(ge),blockQuote:i(re),characterEscape:S,characterReference:S,codeFenced:i(Te),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Te,s),codeText:i(it,s),codeTextData:S,data:S,codeFlowValue:S,definition:i(ne),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(Be),hardBreakEscape:i(dt),hardBreakTrailing:i(dt),htmlFlow:i(ot,s),htmlFlowData:S,htmlText:i(ot,s),htmlTextData:S,image:i(bn),label:s,link:i(br),listItem:i(fe),listItemValue:g,listOrdered:i(or,d),listUnordered:i(or),paragraph:i(Fe),reference:L,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(ge),strong:i(q),thematicBreak:i(gt)},exit:{atxHeading:u(),atxHeadingSequence:$,autolink:u(),autolinkEmail:Ge,autolinkProtocol:Pe,blockQuote:u(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:K,characterReferenceMarkerNumeric:K,characterReferenceValue:se,characterReference:me,codeFenced:u(I),codeFencedFence:b,codeFencedFenceInfo:p,codeFencedFenceMeta:h,codeFlowValue:w,codeIndented:u(F),codeText:u(x),codeTextData:w,data:w,definition:u(),definitionDestinationString:N,definitionLabelString:v,definitionTitleString:D,emphasis:u(),hardBreakEscape:u(f),hardBreakTrailing:u(f),htmlFlow:u(k),htmlFlowData:w,htmlText:u(E),htmlTextData:w,image:u(P),label:_,labelText:B,lineEnding:A,link:u(T),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ie,resourceDestinationString:C,resourceTitleString:R,resource:H,setextHeading:u(m),setextHeadingLineSequence:z,setextHeadingText:M,strong:u(),thematicBreak:u()}};MT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let j={type:"root",children:[]},G={stack:[j],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},W=[],le=-1;for(;++le<O.length;)if(O[le][1].type==="listOrdered"||O[le][1].type==="listUnordered")if(O[le][0]==="enter")W.push(le);else{let he=W.pop();le=o(O,he,le)}for(le=-1;++le<O.length;){let he=t[O[le][0]];LT.call(he,O[le][1].type)&&he[O[le][1].type].call(Object.assign({sliceSerialize:O[le][2].sliceSerialize},G),O[le][1])}if(G.tokenStack.length>0){let he=G.tokenStack[G.tokenStack.length-1];(he[1]||PT).call(G,void 0,he[0])}for(j.position={start:Go(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Go(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},le=-1;++le<t.transforms.length;)j=t.transforms[le](j)||j;return j}function o(O,j,G){let W=j-1,le=-1,he=!1,Rn,vt,Sr,So;for(;++W<=G;){let $t=O[W];switch($t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{$t[0]==="enter"?le++:le--,So=void 0;break}case"lineEndingBlank":{$t[0]==="enter"&&(Rn&&!So&&!le&&!Sr&&(Sr=W),So=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:So=void 0}if(!le&&$t[0]==="enter"&&$t[1].type==="listItemPrefix"||le===-1&&$t[0]==="exit"&&($t[1].type==="listUnordered"||$t[1].type==="listOrdered")){if(Rn){let Qr=W;for(vt=void 0;Qr--;){let wr=O[Qr];if(wr[1].type==="lineEnding"||wr[1].type==="lineEndingBlank"){if(wr[0]==="exit")continue;vt&&(O[vt][1].type="lineEndingBlank",he=!0),wr[1].type="lineEnding",vt=Qr}else if(!(wr[1].type==="linePrefix"||wr[1].type==="blockQuotePrefix"||wr[1].type==="blockQuotePrefixWhitespace"||wr[1].type==="blockQuoteMarker"||wr[1].type==="listItemIndent"))break}Sr&&(!vt||Sr<vt)&&(Rn._spread=!0),Rn.end=Object.assign({},vt?O[vt][1].start:$t[1].end),O.splice(vt||W,0,["exit",Rn,$t[2]]),W++,G++}if($t[1].type==="listItemPrefix"){let Qr={type:"listItem",_spread:!1,start:Object.assign({},$t[1].start),end:void 0};Rn=Qr,O.splice(W,0,["enter",Qr,$t[2]]),W++,G++,Sr=void 0,So=!0}}}return O[j][1]._spread=he,G}function i(O,j){return G;function G(W){a.call(this,O(W),W),j&&j.call(this,W)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,j,G){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([j,G||void 0]),O.position={start:Go(j.start),end:void 0}}function u(O){return j;function j(G){O&&O.call(this,G),c.call(this,G)}}function c(O,j){let G=this.stack.pop(),W=this.tokenStack.pop();if(W)W[0].type!==O.type&&(j?j.call(this,O,W[0]):(W[1]||PT).call(this,O,W[0]));else throw new Error("Cannot close `"+O.type+"` ("+Ho({start:O.start,end:O.end})+"): it\u2019s not open");G.position.end=Go(O.end)}function l(){return Zh(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function g(O){if(this.data.expectingFirstListItemValue){let j=this.stack[this.stack.length-2];j.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function p(){let O=this.resume(),j=this.stack[this.stack.length-1];j.lang=O}function h(){let O=this.resume(),j=this.stack[this.stack.length-1];j.meta=O}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function I(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function F(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O.replace(/(\r?\n|\r)$/g,"")}function v(O){let j=this.resume(),G=this.stack[this.stack.length-1];G.label=j,G.identifier=ho(this.sliceSerialize(O)).toLowerCase()}function D(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function N(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function $(O){let j=this.stack[this.stack.length-1];if(!j.depth){let G=this.sliceSerialize(O).length;j.depth=G}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function z(O){let j=this.stack[this.stack.length-1];j.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function m(){this.data.setextHeadingSlurpLineEnding=void 0}function S(O){let G=this.stack[this.stack.length-1].children,W=G[G.length-1];(!W||W.type!=="text")&&(W=je(),W.position={start:Go(O.start),end:void 0},G.push(W)),this.stack.push(W)}function w(O){let j=this.stack.pop();j.value+=this.sliceSerialize(O),j.position.end=Go(O.end)}function A(O){let j=this.stack[this.stack.length-1];if(this.data.atHardBreak){let G=j.children[j.children.length-1];G.position.end=Go(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(j.type)&&(S.call(this,O),w.call(this,O))}function f(){this.data.atHardBreak=!0}function k(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function E(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function x(){let O=this.resume(),j=this.stack[this.stack.length-1];j.value=O}function T(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,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 j=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=j,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function B(O){let j=this.sliceSerialize(O),G=this.stack[this.stack.length-2];G.label=AT(j),G.identifier=ho(j).toLowerCase()}function _(){let O=this.stack[this.stack.length-1],j=this.resume(),G=this.stack[this.stack.length-1];if(this.data.inReference=!0,G.type==="link"){let W=O.children;G.children=W}else G.alt=j}function C(){let O=this.resume(),j=this.stack[this.stack.length-1];j.url=O}function R(){let O=this.resume(),j=this.stack[this.stack.length-1];j.title=O}function H(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function ie(O){let j=this.resume(),G=this.stack[this.stack.length-1];G.label=j,G.identifier=ho(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function K(O){this.data.characterReferenceType=O.type}function se(O){let j=this.sliceSerialize(O),G=this.data.characterReferenceType,W;G?(W=Uc(j,G==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):W=ss(j);let le=this.stack[this.stack.length-1];le.value+=W}function me(O){let j=this.stack.pop();j.position.end=Go(O.end)}function Pe(O){w.call(this,O);let j=this.stack[this.stack.length-1];j.url=this.sliceSerialize(O)}function Ge(O){w.call(this,O);let j=this.stack[this.stack.length-1];j.url="mailto:"+this.sliceSerialize(O)}function re(){return{type:"blockquote",children:[]}}function Te(){return{type:"code",lang:null,meta:null,value:""}}function it(){return{type:"inlineCode",value:""}}function ne(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Be(){return{type:"emphasis",children:[]}}function ge(){return{type:"heading",depth:0,children:[]}}function dt(){return{type:"break"}}function ot(){return{type:"html",value:""}}function bn(){return{type:"image",title:null,url:"",alt:null}}function br(){return{type:"link",title:null,url:"",children:[]}}function or(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function fe(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function Fe(){return{type:"paragraph",children:[]}}function q(){return{type:"strong",children:[]}}function je(){return{type:"text",value:""}}function gt(){return{type:"thematicBreak"}}}function Go(e){return{line:e.line,column:e.column,offset:e.offset}}function MT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?MT(e,r):EU(e,r)}}function EU(e,t){let n;for(n in t)if(LT.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 PT(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ho({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ho({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ho({start:t.start,end:t.end})+") is still open")}function Jc(e){let t=this;t.parser=n;function n(r){return hx(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function BT(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 DT(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
84
84
  `}]}function RT(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 zT(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function NT(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function OT(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=hr(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 _T(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 $T(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Zc(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 UT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zc(e,t);let o={src:hr(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 jT(e,t){let n={src:hr(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 HT(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 WT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zc(e,t);let o={href:hr(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 VT(e,t){let n={href:hr(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 GT(e,t,n){let r=e.all(t),o=n?FU(n):qT(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:`
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 zT(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function NT(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function OT(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=hr(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 _T(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 $T(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Zc(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 UT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zc(e,t);let o={src:hr(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 jT(e,t){let n={src:hr(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 HT(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 WT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zc(e,t);let o={href:hr(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 VT(e,t){let n={href:hr(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 GT(e,t,n){let r=e.all(t),o=n?AU(n):qT(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 FU(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=qT(n[r])}return t}function qT(e){let t=e.spread;return t??e.children.length>1}function YT(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 KT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function QT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JT(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=rs(t.children[1]),u=$c(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 ZT(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],g={},p=s?s[u]:void 0;p&&(g.align=p);let m={type:"element",tagName:i,properties:g,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),c.push(m)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function eI(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nI(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(tI(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(tI(t.slice(o),o>0,!1)),i.join("")}function tI(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 rI(e,t){let n={type:"text",value:nI(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function oI(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var iI={blockquote:BT,break:DT,code:RT,delete:zT,emphasis:NT,footnoteReference:OT,heading:_T,html:$T,imageReference:UT,image:jT,inlineCode:HT,linkReference:WT,link:VT,listItem:GT,list:YT,paragraph:KT,root:XT,strong:QT,table:JT,tableCell:eI,tableRow:ZT,text:rI,thematicBreak:oI,toml:eu,yaml:eu,definition:eu,footnoteDefinition:eu};function eu(){}var sI=typeof self=="object"?self:globalThis,LU=(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 sI[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 sI[i](s),o)};return r},bx=e=>LU(new Map,e)(0);var ss="",{toString:MU}={},{keys:BU}=Object,Ba=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=MU.call(e).slice(8,-1);switch(n){case"Array":return[1,ss];case"Object":return[2,ss];case"Date":return[3,ss];case"RegExp":return[4,ss];case"Map":return[5,ss];case"Set":return[6,ss];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},nu=([e,t])=>e===0&&(t==="function"||t==="symbol"),DU=(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]=Ba(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 g=s;return u==="DataView"?g=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(s)),o([u,[...g]],s)}let l=[],d=o([a,l],s);for(let g of s)l.push(i(g));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 g of BU(s))(e||!nu(Ba(s[g])))&&l.push([i(g),i(s[g])]);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[g,p]of s)(e||!(nu(Ba(g))||nu(Ba(p))))&&l.push([i(g),i(p)]);return d}case 6:{let l=[],d=o([a,l],s);for(let g of s)(e||!nu(Ba(g)))&&l.push(i(g));return d}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},Sx=(e,{json:t,lossy:n}={})=>{let r=[];return DU(!(t||n),!!t,new Map,r)(e),r};var as=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?bx(Sx(e,t)):structuredClone(e):(e,t)=>bx(Sx(e,t));function RU(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 zU(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function pI(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||RU,r=e.options.footnoteBackLabel||zU,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(),g=hr(d.toLowerCase()),p=0,m=[],b=e.footnoteCounts.get(d);for(;b!==void 0&&++p<=b;){m.length>0&&m.push({type:"text",value:" "});let v=typeof n=="string"?n:n(u,p);typeof v=="string"&&(v={type:"text",value:v}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,p),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}let T=l[l.length-1];if(T&&T.type==="element"&&T.tagName==="p"){let v=T.children[T.children.length-1];v&&v.type==="text"?v.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...m)}else l.push(...m);let F={type:"element",tagName:"li",properties:{id:t+"fn-"+g},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:{...as(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 AU(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=qT(n[r])}return t}function qT(e){let t=e.spread;return t??e.children.length>1}function YT(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 KT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function QT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JT(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=is(t.children[1]),u=$c(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 ZT(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],g={},p=s?s[u]:void 0;p&&(g.align=p);let h={type:"element",tagName:i,properties:g,children:[]};d&&(h.children=e.all(d),e.patch(d,h),h=e.applyData(d,h)),c.push(h)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function eI(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nI(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(tI(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(tI(t.slice(o),o>0,!1)),i.join("")}function tI(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 rI(e,t){let n={type:"text",value:nI(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function oI(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var iI={blockquote:BT,break:DT,code:RT,delete:zT,emphasis:NT,footnoteReference:OT,heading:_T,html:$T,imageReference:UT,image:jT,inlineCode:HT,linkReference:WT,link:VT,listItem:GT,list:YT,paragraph:KT,root:XT,strong:QT,table:JT,tableCell:eI,tableRow:ZT,text:rI,thematicBreak:oI,toml:eu,yaml:eu,definition:eu,footnoteDefinition:eu};function eu(){}var sI=typeof self=="object"?self:globalThis,BU=(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 sI[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 sI[i](s),o)};return r},bx=e=>BU(new Map,e)(0);var ls="",{toString:DU}={},{keys:RU}=Object,Da=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=DU.call(e).slice(8,-1);switch(n){case"Array":return[1,ls];case"Object":return[2,ls];case"Date":return[3,ls];case"RegExp":return[4,ls];case"Map":return[5,ls];case"Set":return[6,ls];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},nu=([e,t])=>e===0&&(t==="function"||t==="symbol"),zU=(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]=Da(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 g=s;return u==="DataView"?g=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(s)),o([u,[...g]],s)}let l=[],d=o([a,l],s);for(let g of s)l.push(i(g));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 g of RU(s))(e||!nu(Da(s[g])))&&l.push([i(g),i(s[g])]);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[g,p]of s)(e||!(nu(Da(g))||nu(Da(p))))&&l.push([i(g),i(p)]);return d}case 6:{let l=[],d=o([a,l],s);for(let g of s)(e||!nu(Da(g)))&&l.push(i(g));return d}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},Sx=(e,{json:t,lossy:n}={})=>{let r=[];return zU(!(t||n),!!t,new Map,r)(e),r};var cs=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?bx(Sx(e,t)):structuredClone(e):(e,t)=>bx(Sx(e,t));function NU(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 OU(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function pI(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||NU,r=e.options.footnoteBackLabel||OU,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(),g=hr(d.toLowerCase()),p=0,h=[],b=e.footnoteCounts.get(d);for(;b!==void 0&&++p<=b;){h.length>0&&h.push({type:"text",value:" "});let v=typeof n=="string"?n:n(u,p);typeof v=="string"&&(v={type:"text",value:v}),h.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,p),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}let I=l[l.length-1];if(I&&I.type==="element"&&I.tagName==="p"){let v=I.children[I.children.length-1];v&&v.type==="text"?v.value+=" ":I.children.push({type:"text",value:" "}),I.children.push(...h)}else l.push(...h);let F={type:"element",tagName:"li",properties:{id:t+"fn-"+g},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:{...cs(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 ru=(function(e){if(e==null)return $U;if(typeof e=="function")return ou(e);if(typeof e=="object")return Array.isArray(e)?NU(e):OU(e);if(typeof e=="string")return _U(e);throw new Error("Expected function, string, or object as test")});function NU(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ru(e[n]);return ou(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function OU(e){let t=e;return ou(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function _U(e){return ou(t);function t(n){return n&&n.type===e}}function ou(e){return t;function t(n,r,o){return!!(UU(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function $U(){return!0}function UU(e){return e!==null&&typeof e=="object"&&"type"in e}var dI=[],wx=!0,iu=!1,vx="skip";function kx(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=ru(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(g,"name",{value:"node ("+(u.type+(p?"<"+p+">":""))+")"})}return g;function g(){let p=dI,m,b,T;if((!t||i(u,c,l[l.length-1]||void 0))&&(p=jU(n(u,l)),p[0]===iu))return p;if("children"in u&&u.children){let F=u;if(F.children&&p[0]!==vx)for(b=(r?F.children.length:-1)+s,T=l.concat(F);b>-1&&b<F.children.length;){let v=F.children[b];if(m=a(v,b,T)(),m[0]===iu)return m;b=typeof m[1]=="number"?m[1]:b+s}}return p}}}function jU(e){return Array.isArray(e)?e:typeof e=="number"?[wx,e]:e==null?dI:[e]}function Da(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),kx(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 Cx={}.hasOwnProperty,HU={};function fI(e,t){let n=t||HU,r=new Map,o=new Map,i=new Map,s={...iI,...n.handlers},a={all:c,applyData:VU,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:WU,wrap:qU};return Da(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let d=l.type==="definition"?r:o,g=String(l.identifier).toUpperCase();d.has(g)||d.set(g,l)}}),a;function u(l,d){let g=l.type,p=a.handlers[g];if(Cx.call(a.handlers,g)&&p)return p(a,l,d);if(a.options.passThrough&&a.options.passThrough.includes(g)){if("children"in l){let{children:b,...T}=l,F=as(T);return F.children=a.all(l),F}return as(l)}return(a.options.unknownHandler||GU)(a,l,d)}function c(l){let d=[];if("children"in l){let g=l.children,p=-1;for(;++p<g.length;){let m=a.one(g[p],l);if(m){if(p&&g[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=gI(m.value)),!Array.isArray(m)&&m.type==="element")){let b=m.children[0];b&&b.type==="text"&&(b.value=gI(b.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function WU(e,t){e.position&&(t.position=qh(e))}function VU(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,as(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function GU(e,t){let n=t.data||{},r="value"in t&&!(Cx.call(n,"hProperties")||Cx.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 qU(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
89
+ `}]}}var ru=(function(e){if(e==null)return jU;if(typeof e=="function")return ou(e);if(typeof e=="object")return Array.isArray(e)?_U(e):$U(e);if(typeof e=="string")return UU(e);throw new Error("Expected function, string, or object as test")});function _U(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ru(e[n]);return ou(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function $U(e){let t=e;return ou(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function UU(e){return ou(t);function t(n){return n&&n.type===e}}function ou(e){return t;function t(n,r,o){return!!(HU(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function jU(){return!0}function HU(e){return e!==null&&typeof e=="object"&&"type"in e}var dI=[],wx=!0,iu=!1,vx="skip";function kx(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=ru(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(g,"name",{value:"node ("+(u.type+(p?"<"+p+">":""))+")"})}return g;function g(){let p=dI,h,b,I;if((!t||i(u,c,l[l.length-1]||void 0))&&(p=WU(n(u,l)),p[0]===iu))return p;if("children"in u&&u.children){let F=u;if(F.children&&p[0]!==vx)for(b=(r?F.children.length:-1)+s,I=l.concat(F);b>-1&&b<F.children.length;){let v=F.children[b];if(h=a(v,b,I)(),h[0]===iu)return h;b=typeof h[1]=="number"?h[1]:b+s}}return p}}}function WU(e){return Array.isArray(e)?e:typeof e=="number"?[wx,e]:e==null?dI:[e]}function Ra(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),kx(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 Cx={}.hasOwnProperty,VU={};function fI(e,t){let n=t||VU,r=new Map,o=new Map,i=new Map,s={...iI,...n.handlers},a={all:c,applyData:qU,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:GU,wrap:KU};return Ra(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let d=l.type==="definition"?r:o,g=String(l.identifier).toUpperCase();d.has(g)||d.set(g,l)}}),a;function u(l,d){let g=l.type,p=a.handlers[g];if(Cx.call(a.handlers,g)&&p)return p(a,l,d);if(a.options.passThrough&&a.options.passThrough.includes(g)){if("children"in l){let{children:b,...I}=l,F=cs(I);return F.children=a.all(l),F}return cs(l)}return(a.options.unknownHandler||YU)(a,l,d)}function c(l){let d=[];if("children"in l){let g=l.children,p=-1;for(;++p<g.length;){let h=a.one(g[p],l);if(h){if(p&&g[p-1].type==="break"&&(!Array.isArray(h)&&h.type==="text"&&(h.value=gI(h.value)),!Array.isArray(h)&&h.type==="element")){let b=h.children[0];b&&b.type==="text"&&(b.value=gI(b.value))}Array.isArray(h)?d.push(...h):d.push(h)}}}return d}}function GU(e,t){e.position&&(t.position=qh(e))}function qU(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,cs(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function YU(e,t){let n=t.data||{},r="value"in t&&!(Cx.call(n,"hProperties")||Cx.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 KU(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
92
  `}),n}function gI(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function su(e,t){let n=fI(e,t),r=n.one(e,void 0),o=pI(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 au(e,t){return e&&"run"in e?async function(n,r){let o=su(n,{file:r,...t});await e.run(o,r)}:function(n,r){return su(n,{file:r,...e||t})}}function Tx(e){if(e)throw e}var uu=el(kI(),1);function Ra(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 Ix(){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?CI(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 CI(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 Dr={basename:YU,dirname:KU,extname:XU,join:QU,sep:"/"};function YU(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');za(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 KU(e){if(za(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 XU(e){za(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 QU(...e){let t=-1,n;for(;++t<e.length;)za(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":JU(n)}function JU(e){za(e);let t=e.codePointAt(0)===47,n=ZU(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function ZU(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 za(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var TI={cwd:ej};function ej(){return"/"}function ls(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function II(e){if(typeof e=="string")e=new URL(e);else if(!ls(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 tj(e)}function tj(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 Fx=["history","path","basename","stem","extname","dirname"],hi=class{constructor(t){let n;t?ls(t)?n={path:t}:typeof t=="string"||nj(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":TI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Fx.length;){let i=Fx[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)Fx.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Dr.basename(this.path):void 0}set basename(t){Ax(t,"basename"),Ex(t,"basename"),this.path=Dr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Dr.dirname(this.path):void 0}set dirname(t){FI(this.basename,"dirname"),this.path=Dr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Dr.extname(this.path):void 0}set extname(t){if(Ex(t,"extname"),FI(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=Dr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ls(t)&&(t=II(t)),Ax(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Dr.basename(this.path,this.extname):void 0}set stem(t){Ax(t,"stem"),Ex(t,"stem"),this.path=Dr.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 Gt(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 Ex(e,t){if(e&&e.includes(Dr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Dr.sep+"`")}function Ax(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function FI(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function nj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var EI=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var rj={}.hasOwnProperty,Bx=class e extends EI{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=Ix()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,uu.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Mx("data",this.frozen),this.namespace[t]=n,this):rj.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Mx("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=cu(t),r=this.parser||this.Parser;return Px("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),Px("process",this.parser||this.Parser),Lx("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=cu(t),u=r.parse(a);r.run(u,a,function(l,d,g){if(l||!d||!g)return c(l);let p=d,m=r.stringify(p,g);ij(m)?g.value=m:g.result=m,c(l,g)});function c(l,d){l||!d?s(l):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Px("processSync",this.parser||this.Parser),Lx("processSync",this.compiler||this.Compiler),this.process(t,o),PI("processSync","process",n),r;function o(i,s){n=!0,Tx(i),r=s}}run(t,n,r){AI(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=cu(n);o.run(t,u,c);function c(l,d,g){let p=d||t;l?a(l):s?s(p):r(void 0,p,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),PI("runSync","run",r),o;function i(s,a){Tx(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=cu(n),o=this.compiler||this.Compiler;return Lx("stringify",o),AI(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(Mx("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,uu.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,g=-1;for(;++d<r.length;)if(r[d][0]===c){g=d;break}if(g===-1)r.push([c,...l]);else if(l.length>0){let[p,...m]=l,b=r[g][1];Ra(b)&&Ra(p)&&(p=(0,uu.default)(!0,b,p)),r[g]=[c,p,...m]}}}},Dx=new Bx().freeze();function Px(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Lx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Mx(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 AI(e){if(!Ra(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function PI(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function cu(e){return oj(e)?e:new hi(e)}function oj(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function ij(e){return typeof e=="string"||sj(e)}function sj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var uj="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",LI=[],MI={allowDangerousHtml:!0},pj=/^(https?|ircs?|mailto|xmpp)$/i,dj=[{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 Rx(e){let t=gj(e),n=fj(e);return mj(t.runSync(t.parse(n),n),e)}function gj(e){let t=e.rehypePlugins||LI,n=e.remarkPlugins||LI,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...MI}:MI;return Dx().use(Jc).use(n).use(au,r).use(t)}function fj(e){let t=e.children||"",n=new hi;return typeof t=="string"?n.value=t:(""+t,void 0),n}function mj(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||BI;for(let l of dj)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+uj+l.id,void 0);return n&&i&&void 0,Da(e,c),Xh(e,{Fragment:aj,components:o,ignoreInvalidStyle:!0,jsx:lj,jsxs:cj,passKeys:!0,passNode:!0});function c(l,d,g){if(l.type==="raw"&&g&&typeof d=="number")return s?g.children.splice(d,1):g.children[d]={type:"text",value:l.value},d;if(l.type==="element"){let p;for(p in Ia)if(Object.hasOwn(Ia,p)&&Object.hasOwn(l.properties,p)){let m=l.properties[p],b=Ia[p];(b===null||b.includes(l.tagName))&&(l.properties[p]=u(String(m||""),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,g)),p&&g&&typeof d=="number")return a&&l.children?g.children.splice(d,1,...l.children):g.children.splice(d,1),d}}}function BI(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||pj.test(e.slice(0,t))?e:""}ve();var xj=cs.div({display:"flex",flexDirection:"column",gap:"12px"}),yj=cs.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),bj=cs.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Sj=cs(En)({padding:"6px 12px",fontSize:"12px"}),wj=cs.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:L1.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}})),vj=cs.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),zx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ue(),[r,o]=hj(!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?xi.createElement(xj,null,xi.createElement(yj,null,xi.createElement(bj,null,"Full Prompt"),xi.createElement(Sj,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),xi.createElement(wj,null,xi.createElement(Rx,null,e))):xi.createElement(vj,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import xo,{useRef as kj}from"react";import{styled as Rr}from"storybook/theming";ve();var Cj=Rr.div({display:"flex",flexDirection:"column",gap:"8px"}),Jge=Rr.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"}}),Tj=Rr.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})),Ij=Rr.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})),Zge=Rr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),DI=Rr.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||ce,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||ce,backgroundColor:e.background.warning||"#ffedd5"}})),Fj=Rr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),Ej=Rr.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"})),Aj=Rr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),Pj=Rr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),efe=Rr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function Lj(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 Nx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ue(),s=kj(null);if((i??o)!=="admin")return null;let u=r?n.find(m=>m.id===r):null,c=u?u.issues.length>0&&u.issues.every(m=>m.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(m=>m.role==="assistant"||m.role==="system"&&m.content.includes("auto-dismissed")),g=d.length===0&&!!t;if(d.length===0&&!g)return xo.createElement(Fj,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 xo.createElement(Cj,null,l&&xo.createElement(Ej,null,xo.createElement(Aj,null,"Component Matches Design"),xo.createElement(Pj,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.")),xo.createElement(Tj,{ref:s},p.map((m,b)=>xo.createElement(Ij,{key:b,role:m.role},m.role==="system"?xo.createElement(DI,null,m.content):xo.createElement(DI,{dangerouslySetInnerHTML:{__html:Lj(m.content)}})))))};import xr from"react";import{styled as Go}from"storybook/theming";ve();Ne();var Mj=Go.div({display:"flex",flexDirection:"column",gap:"12px"}),Bj=Go.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),Dj=Go.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}}}),RI=Go.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"}}),Rj=Go.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),zI=Go.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||ce,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||ce,backgroundColor:e.background.warning||"#ffedd5"}})),NI=Go.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),zj=Go.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 OI(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 Nj(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 _I=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ue();if((i??o)!=="admin")return null;xr.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?xr.createElement(NI,null,"No models selected. Select multiple models to compare results."):xr.createElement(Mj,null,xr.createElement(Bj,null,a.map(l=>{let d=fo.find(F=>F.id===l),g=c[l],m=Nj(t&&g?.streamingMessages&&g.streamingMessages.length>0?g.streamingMessages[0].content||"":g?.fullResponse?g.fullResponse:""),b=l===u;if(!d)return null;let T=t&&!g?.completed;return xr.createElement(Dj,{key:l,isActive:b,provider:d.provider,onClick:()=>n(l)},d.name,g&&m.issueCount>0&&xr.createElement(RI,{variant:"issues",value:m.issueCount},m.issueCount," issues"),g&&m.score!==null&&xr.createElement(RI,{variant:"score",value:m.score},"Score: ",m.score),T&&xr.createElement(zj,null))})),xr.createElement(Rj,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>xr.createElement(zI,{key:d,dangerouslySetInnerHTML:{__html:OI(l.content)}})):c[u]?.fullResponse?xr.createElement(zI,{dangerouslySetInnerHTML:{__html:OI(c[u].fullResponse)}}):xr.createElement(NI,null,t?`Waiting for ${fo.find(l=>l.id===u)?.name}...`:`No response yet for ${fo.find(l=>l.id===u)?.name}`)))};import ze from"react";import{styled as Ft}from"storybook/theming";ve();ln();ve();import{useCallback as Ox}from"react";Ne();function $I(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ue(),{sessionToken:r}=Se(),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}gc(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}gc(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 X,{useMemo as vF,useState as iW,useEffect as sW}from"react";import{styled as rt,keyframes as aW}from"storybook/theming";ln();import ee,{useState as Hx,useRef as K8,useCallback as rF,memo as X8}from"react";import{styled as Ae}from"storybook/theming";import pt,{useState as UI}from"react";import{styled as In}from"storybook/theming";var Oj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),_j=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("polyline",{points:"12 6 12 12 16 14"})),$j=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})),Uj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})),jj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("path",{d:"M12 3l1.68 5.17L19 10l-5.32 1.83L12 17l-1.68-5.17L5 10l5.32-1.83z"}),pt.createElement("path",{d:"M5 3l.74 2.26L8 6l-2.26.74L5 9l-.74-2.26L2 6l2.26-.74z"}),pt.createElement("path",{d:"M19 15l.74 2.26L22 18l-2.26.74L19 21l-.74-2.26L16 18l2.26-.74z"})),jI=[{id:"false-positive",Icon:Oj,label:"False positive",description:"The AI flagged something that isn't actually a design issue",color:"#9ca3af",bg:"rgba(156,163,175,0.15)"},{id:"planned",Icon:_j,label:"Planned",description:"Valid issue \u2014 logged and scheduled to fix in a future sprint",color:"#60a5fa",bg:"rgba(96,165,250,0.15)"},{id:"wont-fix",Icon:$j,label:"Won't fix",description:"Intentional deviation \u2014 design has approved this difference",color:"#fbbf24",bg:"rgba(251,191,36,0.15)"},{id:"no-figma-state",Icon:Uj,label:"No Figma state",description:"No Figma frame exists for this specific story variant or state",color:"#a78bfa",bg:"rgba(167,139,250,0.15)"},{id:"design-pending",Icon:jj,label:"Design pending",description:"Code was built first \u2014 designer will add the Figma spec later",color:"#34d399",bg:"rgba(52,211,153,0.15)"}],Hj=In.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}),Wj=In.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"10px",padding:"24px",maxWidth:"480px",width:"90%",boxShadow:"0 10px 40px rgba(0,0,0,0.25)",border:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"20px"})),Vj=In.div({display:"flex",flexDirection:"column",gap:"4px"}),Gj=In.h3(({theme:e})=>({fontSize:"17px",fontWeight:700,color:e.color.defaultText,margin:0})),qj=In.p(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,margin:0,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),Yj=In.div({display:"flex",flexDirection:"column",gap:"6px"}),Kj=In.button(({theme:e,selected:t,accentColor:n})=>({display:"flex",alignItems:"flex-start",gap:"12px",padding:"10px 12px",borderRadius:"8px",border:`1px solid ${t?n:e.appBorderColor}`,backgroundColor:t?`${n}10`:e.background.app,boxShadow:t?`0 0 0 1px ${n}`:"none",cursor:"pointer",textAlign:"left",width:"100%",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),Xj=In.div(({color:e,bg:t})=>({width:"36px",height:"36px",borderRadius:"7px",backgroundColor:t,color:e,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0})),Qj=In.div({display:"flex",flexDirection:"column",gap:"2px",minWidth:0,flex:1}),Jj=In.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,lineHeight:"1.3"})),Zj=In.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,lineHeight:"1.4"})),e8=In.div({display:"flex",flexDirection:"column",gap:"6px"}),t8=In.label(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.defaultText})),n8=In.textarea(({theme:e})=>({width:"100%",minHeight:"72px",padding:"8px 10px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary},"&::placeholder":{color:e.textMutedColor}})),r8=In.div({display:"flex",justifyContent:"flex-end",gap:"8px"}),o8=In.button(({theme:e,disabled:t,accentColor:n})=>({padding:"8px 18px",fontSize:"13px",fontWeight:600,borderRadius:"6px",border:"none",cursor:t?"not-allowed":"pointer",backgroundColor:t?e.color.medium:n||e.color.secondary,color:"#ffffff",opacity:t?.5:1,transition:"opacity 0.15s","&:hover":{opacity:t?.5:.85}})),HI=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=UI(null),[s,a]=UI("");if(!e)return null;let u=jI.find(d=>d.id===o),c=()=>{o&&(n(o,s.trim()||void 0),i(null),a(""))},l=()=>{i(null),a(""),r()};return pt.createElement(Hj,{onClick:d=>d.target===d.currentTarget&&l()},pt.createElement(Wj,null,pt.createElement(Vj,null,pt.createElement(Gj,null,"Dismiss Issue"),pt.createElement(qj,{title:t},t)),pt.createElement(Yj,{role:"radiogroup"},jI.map(({id:d,Icon:g,label:p,description:m,color:b,bg:T})=>pt.createElement(Kj,{key:d,selected:o===d,accentColor:b,onClick:()=>i(d),role:"radio","aria-checked":o===d},pt.createElement(Xj,{color:b,bg:T},pt.createElement(g,null)),pt.createElement(Qj,null,pt.createElement(Jj,null,p),pt.createElement(Zj,null,m))))),pt.createElement(e8,null,pt.createElement(t8,{htmlFor:"dismiss-note"},"Note (optional)"),pt.createElement(n8,{id:"dismiss-note",placeholder:"Add context\u2026",value:s,onChange:d=>a(d.target.value),rows:3})),pt.createElement(r8,null,pt.createElement(Or,{onClick:l},"Cancel"),pt.createElement(o8,{disabled:!o,accentColor:u?.color,onClick:c},"Dismiss Issue"))))};ve();import Ee from"react";import{styled as nt}from"storybook/theming";var Re={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"},i8=nt.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),s8=nt.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),a8=nt.div({position:"relative",backgroundColor:Re.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),wfe=nt.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Re.dash,padding:"0 8px",height:18,fontSize:11}),vfe=nt.div({position:"absolute",color:Re.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),kfe=nt.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%)"}})),Cfe=nt.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}})),l8=nt.div(e=>({position:"relative",backgroundColor:e.isErr?Re.errBg:Re.borderBoxBg,border:`1px solid ${e.isErr?Re.err:Re.borderBoxStroke}`,borderRadius:6,padding:0})),c8=nt.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Re.text}),u8=nt.span({fontWeight:500,fontSize:11}),Tfe=nt.span({color:Re.dash}),p8=nt.div(e=>({position:"relative",backgroundColor:e.isErr?Re.errBg:Re.paddingBg,border:`1px solid ${e.isErr?Re.err:Re.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),d8=nt.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Re.text,fontStyle:"italic"}),pu=nt.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Re.err:Re.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%)"}})),g8=nt.div(e=>({backgroundColor:e.isErr?Re.errBg:"#fff",border:`1.5px dashed ${e.isErr?Re.err:Re.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Re.err:Re.text,fontWeight:e.isErr?600:400})),f8=nt.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Re.dim,fontFamily:"monospace"}),m8=nt.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Re.ok,padding:"4px 8px 6px"}),Ife=nt.div({fontSize:11,fontWeight:600,color:Re.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),Ffe=nt.span({fontSize:12,color:Re.dim}),h8=nt.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),x8=nt.div({fontSize:9,color:Re.dim,marginTop:2}),y8=({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}=ue(),d=r||{},p=!(!!r&&Object.keys(r).length>0)&&s?I8(n):null,m=d.padding||p||{top:0,right:0,bottom:0,left:0},b=d.strokeWeight??(a?us(n)??0:0),T=d.width??(u?F8(n)??"\u2014":"\u2014"),F=d.height??(u?E8(n)??"\u2014":"\u2014");return Ee.createElement(Ee.Fragment,null,Ee.createElement(a8,null,Ee.createElement(l8,{isErr:a},Ee.createElement(c8,null,Ee.createElement(u8,null,"Border"),Ee.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Re.err:Re.dim}},b)),Ee.createElement(p8,{isErr:s},Ee.createElement(d8,null,"Padding"),Ee.createElement(pu,{side:"top",isErr:s},m.top),Ee.createElement(pu,{side:"right",isErr:s},m.right),Ee.createElement(pu,{side:"bottom",isErr:s},m.bottom),Ee.createElement(pu,{side:"left",isErr:s},m.left),Ee.createElement(g8,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Ee.createElement(h8,{src:l,alt:"Figma element"}),Ee.createElement(x8,null,T," \xD7 ",F)))),Ee.createElement(f8,null,"border-box")),Ee.createElement(m8,null,"\u2192 ",n))},WI=nt.div({backgroundColor:Re.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),b8=nt.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),_x=nt.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Re.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),S8=nt.div({position:"absolute",border:`1.5px dashed ${Re.err}`,pointerEvents:"none",zIndex:0}),w8=nt.div({position:"absolute",border:`1.5px dashed ${Re.blue}`,pointerEvents:"none",zIndex:0}),VI=nt.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%)"}})),Efe=nt.div({fontSize:12,color:Re.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),v8=nt.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),GI=nt.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Re.err:Re.ok})),k8=nt.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),qI=nt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),YI=nt.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Re.err:Re.ok})),KI=nt.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Re.err:Re.ok,textDecoration:e.variant==="err"?"line-through":"none"})),C8=nt.span({fontSize:16,color:Re.dim,paddingBottom:20}),XI=nt.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function QI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var T8=({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,g=o.fontSize??(s?us(n):14),p=o.fontWeight??(a?us(n):600),b=(o.lineHeight??(u?us(n):null))||Math.round((g||14)*1.43),T=`${Math.min(Math.max(g||14,24),48)}px`;if(d)return Ee.createElement(Ee.Fragment,null,Ee.createElement(WI,null,Ee.createElement(b8,null,Ee.createElement(w8,{style:{top:-6,left:0,right:0,bottom:-6}}),Ee.createElement(S8,{style:{top:2,left:8,right:8,bottom:2}}),Ee.createElement(VI,{color:s?Re.err:"#7b3030",side:"left"},s?t:`${g}px`),Ee.createElement(VI,{color:u?Re.err:"#7b3030",side:"right"},u?t:`${b}px`),Ee.createElement(_x,{fSize:T,fWeight:String(p||600)},"Ag")),Ee.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Ee.createElement(XI,{color:Re.err},"\u2508\u2508 font-size",s?" \u2717":""),Ee.createElement(XI,{color:Re.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Ee.createElement(v8,null,Ee.createElement(GI,{variant:"err"},t),Ee.createElement("span",{style:{color:Re.dim}},"\u2192"),Ee.createElement(GI,{variant:"ok"},n))));let F=a?t:String(p||600),v=a?n:F,D=us(t),_=us(n);return Ee.createElement(Ee.Fragment,null,Ee.createElement(WI,null,Ee.createElement(k8,null,Ee.createElement(qI,null,Ee.createElement(YI,{variant:"err"},"Current"),Ee.createElement(_x,{fSize:T,fWeight:a?F:String(p||600),style:{color:Re.err}},c?t:"Ag"),Ee.createElement(KI,{variant:"err"},a&&D?`${t} (${QI(D)})`:t)),Ee.createElement(C8,null,"\u2192"),Ee.createElement(qI,null,Ee.createElement(YI,{variant:"ok"},"Figma"),Ee.createElement(_x,{fSize:T,fWeight:a?v:String(p||600),style:{color:Re.ok}},c?n:"Ag"),Ee.createElement(KI,{variant:"ok"},a&&_?`${n} (${QI(_)})`:n)))))};function I8(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 us(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function F8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function E8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var JI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function A8(e){if(JI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return JI.has(t)}var ZI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=A8(e.property);return Ee.createElement(i8,null,Ee.createElement(s8,null,"\u25BE Layer properties",t?"":" (from review)"),n?Ee.createElement(T8,{...e}):Ee.createElement(y8,{...e}))};import Yr from"react";import{styled as Kr}from"storybook/theming";var P8={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)"}},L8=Kr.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),M8=Kr.div(({theme:e,category:t})=>{let n=P8[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}`}}),B8=Kr.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}}}),D8=Kr.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"}}),R8=Kr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),z8=Kr.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"}}),N8=Kr.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"}}),O8=Kr.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"}}),_8=Kr.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}`})),$8=Kr.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),U8=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},eF=({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=U8(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),g=e.generatedFix?.filePath||e.file;return Yr.createElement(L8,null,Yr.createElement(M8,{category:e.type},e.type),e.status!=="pending"&&Yr.createElement(B8,{status:e.status},e.status),n&&t&&Yr.createElement(D8,null,t),d&&Yr.createElement(R8,null,c.ai&&!l&&Yr.createElement(z8,null,c.ai),c.programmatic&&Yr.createElement(N8,null,"Pre-filter: ",c.programmatic)),a&&Yr.createElement(O8,{title:u},"Unreliable"),e.dismissed&&Yr.createElement(_8,null,"Dismissed"),i&&s&&g&&Yr.createElement($8,null,g))};import Kn from"react";import{styled as qo}from"storybook/theming";var j8=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},H8=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",W8=qo.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"})),$x=qo.div({display:"flex",gap:"8px",alignItems:"baseline"}),Ux=qo.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),jx=qo.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),V8=qo(jx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),G8=qo(jx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),q8=qo.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
93
+ `},o)),i}function au(e,t){return e&&"run"in e?async function(n,r){let o=su(n,{file:r,...t});await e.run(o,r)}:function(n,r){return su(n,{file:r,...e||t})}}function Tx(e){if(e)throw e}var uu=tl(kI(),1);function za(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 Ix(){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?CI(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 CI(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 Dr={basename:XU,dirname:QU,extname:JU,join:ZU,sep:"/"};function XU(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Na(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 QU(e){if(Na(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 JU(e){Na(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 ZU(...e){let t=-1,n;for(;++t<e.length;)Na(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":ej(n)}function ej(e){Na(e);let t=e.codePointAt(0)===47,n=tj(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function tj(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 Na(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var TI={cwd:nj};function nj(){return"/"}function us(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function II(e){if(typeof e=="string")e=new URL(e);else if(!us(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 rj(e)}function rj(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 Fx=["history","path","basename","stem","extname","dirname"],hi=class{constructor(t){let n;t?us(t)?n={path:t}:typeof t=="string"||oj(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":TI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Fx.length;){let i=Fx[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)Fx.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Dr.basename(this.path):void 0}set basename(t){Ax(t,"basename"),Ex(t,"basename"),this.path=Dr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Dr.dirname(this.path):void 0}set dirname(t){FI(this.basename,"dirname"),this.path=Dr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Dr.extname(this.path):void 0}set extname(t){if(Ex(t,"extname"),FI(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=Dr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){us(t)&&(t=II(t)),Ax(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Dr.basename(this.path,this.extname):void 0}set stem(t){Ax(t,"stem"),Ex(t,"stem"),this.path=Dr.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 Gt(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 Ex(e,t){if(e&&e.includes(Dr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Dr.sep+"`")}function Ax(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function FI(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function oj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var EI=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var ij={}.hasOwnProperty,Bx=class e extends EI{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=Ix()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,uu.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Mx("data",this.frozen),this.namespace[t]=n,this):ij.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Mx("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=cu(t),r=this.parser||this.Parser;return Px("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),Px("process",this.parser||this.Parser),Lx("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=cu(t),u=r.parse(a);r.run(u,a,function(l,d,g){if(l||!d||!g)return c(l);let p=d,h=r.stringify(p,g);aj(h)?g.value=h:g.result=h,c(l,g)});function c(l,d){l||!d?s(l):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Px("processSync",this.parser||this.Parser),Lx("processSync",this.compiler||this.Compiler),this.process(t,o),PI("processSync","process",n),r;function o(i,s){n=!0,Tx(i),r=s}}run(t,n,r){AI(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=cu(n);o.run(t,u,c);function c(l,d,g){let p=d||t;l?a(l):s?s(p):r(void 0,p,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),PI("runSync","run",r),o;function i(s,a){Tx(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=cu(n),o=this.compiler||this.Compiler;return Lx("stringify",o),AI(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(Mx("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,uu.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,g=-1;for(;++d<r.length;)if(r[d][0]===c){g=d;break}if(g===-1)r.push([c,...l]);else if(l.length>0){let[p,...h]=l,b=r[g][1];za(b)&&za(p)&&(p=(0,uu.default)(!0,b,p)),r[g]=[c,p,...h]}}}},Dx=new Bx().freeze();function Px(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Lx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Mx(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 AI(e){if(!za(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function PI(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function cu(e){return sj(e)?e:new hi(e)}function sj(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function aj(e){return typeof e=="string"||lj(e)}function lj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var dj="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",LI=[],MI={allowDangerousHtml:!0},gj=/^(https?|ircs?|mailto|xmpp)$/i,fj=[{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 Rx(e){let t=mj(e),n=hj(e);return xj(t.runSync(t.parse(n),n),e)}function mj(e){let t=e.rehypePlugins||LI,n=e.remarkPlugins||LI,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...MI}:MI;return Dx().use(Jc).use(n).use(au,r).use(t)}function hj(e){let t=e.children||"",n=new hi;return typeof t=="string"?n.value=t:(""+t,void 0),n}function xj(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||BI;for(let l of fj)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+dj+l.id,void 0);return n&&i&&void 0,Ra(e,c),Xh(e,{Fragment:cj,components:o,ignoreInvalidStyle:!0,jsx:uj,jsxs:pj,passKeys:!0,passNode:!0});function c(l,d,g){if(l.type==="raw"&&g&&typeof d=="number")return s?g.children.splice(d,1):g.children[d]={type:"text",value:l.value},d;if(l.type==="element"){let p;for(p in Fa)if(Object.hasOwn(Fa,p)&&Object.hasOwn(l.properties,p)){let h=l.properties[p],b=Fa[p];(b===null||b.includes(l.tagName))&&(l.properties[p]=u(String(h||""),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,g)),p&&g&&typeof d=="number")return a&&l.children?g.children.splice(d,1,...l.children):g.children.splice(d,1),d}}}function BI(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||gj.test(e.slice(0,t))?e:""}ve();var bj=ps.div({display:"flex",flexDirection:"column",gap:"12px"}),Sj=ps.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),wj=ps.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),vj=ps(An)({padding:"6px 12px",fontSize:"12px"}),kj=ps.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:L1.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}})),Cj=ps.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),zx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ue(),[r,o]=yj(!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?xi.createElement(bj,null,xi.createElement(Sj,null,xi.createElement(wj,null,"Full Prompt"),xi.createElement(vj,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),xi.createElement(kj,null,xi.createElement(Rx,null,e))):xi.createElement(Cj,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import xo,{useRef as Tj}from"react";import{styled as Rr}from"storybook/theming";ve();var Ij=Rr.div({display:"flex",flexDirection:"column",gap:"8px"}),efe=Rr.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"}}),Fj=Rr.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})),Ej=Rr.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})),tfe=Rr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),DI=Rr.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||ce,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||ce,backgroundColor:e.background.warning||"#ffedd5"}})),Aj=Rr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),Pj=Rr.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"})),Lj=Rr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),Mj=Rr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),nfe=Rr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function Bj(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 Nx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ue(),s=Tj(null);if((i??o)!=="admin")return null;let u=r?n.find(h=>h.id===r):null,c=u?u.issues.length>0&&u.issues.every(h=>h.dismissed):!1,l=u&&(u.complianceScore===100||c),d=e.filter(h=>h.role==="assistant"||h.role==="system"&&h.content.includes("auto-dismissed")),g=d.length===0&&!!t;if(d.length===0&&!g)return xo.createElement(Aj,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 xo.createElement(Ij,null,l&&xo.createElement(Pj,null,xo.createElement(Lj,null,"Component Matches Design"),xo.createElement(Mj,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.")),xo.createElement(Fj,{ref:s},p.map((h,b)=>xo.createElement(Ej,{key:b,role:h.role},h.role==="system"?xo.createElement(DI,null,h.content):xo.createElement(DI,{dangerouslySetInnerHTML:{__html:Bj(h.content)}})))))};import xr from"react";import{styled as qo}from"storybook/theming";ve();Ne();var Dj=qo.div({display:"flex",flexDirection:"column",gap:"12px"}),Rj=qo.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),zj=qo.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}}}),RI=qo.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"}}),Nj=qo.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),zI=qo.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||ce,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||ce,backgroundColor:e.background.warning||"#ffedd5"}})),NI=qo.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),Oj=qo.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 OI(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 _j(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 _I=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ue();if((i??o)!=="admin")return null;xr.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?xr.createElement(NI,null,"No models selected. Select multiple models to compare results."):xr.createElement(Dj,null,xr.createElement(Rj,null,a.map(l=>{let d=fo.find(F=>F.id===l),g=c[l],h=_j(t&&g?.streamingMessages&&g.streamingMessages.length>0?g.streamingMessages[0].content||"":g?.fullResponse?g.fullResponse:""),b=l===u;if(!d)return null;let I=t&&!g?.completed;return xr.createElement(zj,{key:l,isActive:b,provider:d.provider,onClick:()=>n(l)},d.name,g&&h.issueCount>0&&xr.createElement(RI,{variant:"issues",value:h.issueCount},h.issueCount," issues"),g&&h.score!==null&&xr.createElement(RI,{variant:"score",value:h.score},"Score: ",h.score),I&&xr.createElement(Oj,null))})),xr.createElement(Nj,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,d)=>xr.createElement(zI,{key:d,dangerouslySetInnerHTML:{__html:OI(l.content)}})):c[u]?.fullResponse?xr.createElement(zI,{dangerouslySetInnerHTML:{__html:OI(c[u].fullResponse)}}):xr.createElement(NI,null,t?`Waiting for ${fo.find(l=>l.id===u)?.name}...`:`No response yet for ${fo.find(l=>l.id===u)?.name}`)))};import ze from"react";import{styled as Ft}from"storybook/theming";ve();ln();ve();import{useCallback as Ox}from"react";Ne();function $I(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ue(),{sessionToken:r}=Se(),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}fc(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}fc(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 X,{useMemo as vF,useState as aW,useEffect as lW}from"react";import{styled as rt,keyframes as cW}from"storybook/theming";ln();import te,{useState as Hx,useRef as Q8,useCallback as rF,memo as J8}from"react";import{styled as Ae}from"storybook/theming";import pt,{useState as UI}from"react";import{styled as Fn}from"storybook/theming";var $j=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Uj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("polyline",{points:"12 6 12 12 16 14"})),jj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("circle",{cx:"12",cy:"12",r:"10"}),pt.createElement("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})),Hj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})),Wj=()=>pt.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("path",{d:"M12 3l1.68 5.17L19 10l-5.32 1.83L12 17l-1.68-5.17L5 10l5.32-1.83z"}),pt.createElement("path",{d:"M5 3l.74 2.26L8 6l-2.26.74L5 9l-.74-2.26L2 6l2.26-.74z"}),pt.createElement("path",{d:"M19 15l.74 2.26L22 18l-2.26.74L19 21l-.74-2.26L16 18l2.26-.74z"})),jI=[{id:"false-positive",Icon:$j,label:"False positive",description:"The AI flagged something that isn't actually a design issue",color:"#9ca3af",bg:"rgba(156,163,175,0.15)"},{id:"planned",Icon:Uj,label:"Planned",description:"Valid issue \u2014 logged and scheduled to fix in a future sprint",color:"#60a5fa",bg:"rgba(96,165,250,0.15)"},{id:"wont-fix",Icon:jj,label:"Won't fix",description:"Intentional deviation \u2014 design has approved this difference",color:"#fbbf24",bg:"rgba(251,191,36,0.15)"},{id:"no-figma-state",Icon:Hj,label:"No Figma state",description:"No Figma frame exists for this specific story variant or state",color:"#a78bfa",bg:"rgba(167,139,250,0.15)"},{id:"design-pending",Icon:Wj,label:"Design pending",description:"Code was built first \u2014 designer will add the Figma spec later",color:"#34d399",bg:"rgba(52,211,153,0.15)"}],Vj=Fn.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}),Gj=Fn.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"10px",padding:"24px",maxWidth:"480px",width:"90%",boxShadow:"0 10px 40px rgba(0,0,0,0.25)",border:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"20px"})),qj=Fn.div({display:"flex",flexDirection:"column",gap:"4px"}),Yj=Fn.h3(({theme:e})=>({fontSize:"17px",fontWeight:700,color:e.color.defaultText,margin:0})),Kj=Fn.p(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,margin:0,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),Xj=Fn.div({display:"flex",flexDirection:"column",gap:"6px"}),Qj=Fn.button(({theme:e,selected:t,accentColor:n})=>({display:"flex",alignItems:"flex-start",gap:"12px",padding:"10px 12px",borderRadius:"8px",border:`1px solid ${t?n:e.appBorderColor}`,backgroundColor:t?`${n}10`:e.background.app,boxShadow:t?`0 0 0 1px ${n}`:"none",cursor:"pointer",textAlign:"left",width:"100%",transition:"all 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),Jj=Fn.div(({color:e,bg:t})=>({width:"36px",height:"36px",borderRadius:"7px",backgroundColor:t,color:e,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0})),Zj=Fn.div({display:"flex",flexDirection:"column",gap:"2px",minWidth:0,flex:1}),e8=Fn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,lineHeight:"1.3"})),t8=Fn.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,lineHeight:"1.4"})),n8=Fn.div({display:"flex",flexDirection:"column",gap:"6px"}),r8=Fn.label(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.defaultText})),o8=Fn.textarea(({theme:e})=>({width:"100%",minHeight:"72px",padding:"8px 10px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary},"&::placeholder":{color:e.textMutedColor}})),i8=Fn.div({display:"flex",justifyContent:"flex-end",gap:"8px"}),s8=Fn.button(({theme:e,disabled:t,accentColor:n})=>({padding:"8px 18px",fontSize:"13px",fontWeight:600,borderRadius:"6px",border:"none",cursor:t?"not-allowed":"pointer",backgroundColor:t?e.color.medium:n||e.color.secondary,color:"#ffffff",opacity:t?.5:1,transition:"opacity 0.15s","&:hover":{opacity:t?.5:.85}})),HI=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=UI(null),[s,a]=UI("");if(!e)return null;let u=jI.find(d=>d.id===o),c=()=>{o&&(n(o,s.trim()||void 0),i(null),a(""))},l=()=>{i(null),a(""),r()};return pt.createElement(Vj,{onClick:d=>d.target===d.currentTarget&&l()},pt.createElement(Gj,null,pt.createElement(qj,null,pt.createElement(Yj,null,"Dismiss Issue"),pt.createElement(Kj,{title:t},t)),pt.createElement(Xj,{role:"radiogroup"},jI.map(({id:d,Icon:g,label:p,description:h,color:b,bg:I})=>pt.createElement(Qj,{key:d,selected:o===d,accentColor:b,onClick:()=>i(d),role:"radio","aria-checked":o===d},pt.createElement(Jj,{color:b,bg:I},pt.createElement(g,null)),pt.createElement(Zj,null,pt.createElement(e8,null,p),pt.createElement(t8,null,h))))),pt.createElement(n8,null,pt.createElement(r8,{htmlFor:"dismiss-note"},"Note (optional)"),pt.createElement(o8,{id:"dismiss-note",placeholder:"Add context\u2026",value:s,onChange:d=>a(d.target.value),rows:3})),pt.createElement(i8,null,pt.createElement(Or,{onClick:l},"Cancel"),pt.createElement(s8,{disabled:!o,accentColor:u?.color,onClick:c},"Dismiss Issue"))))};ve();import Ee from"react";import{styled as nt}from"storybook/theming";var Re={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"},a8=nt.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),l8=nt.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),c8=nt.div({position:"relative",backgroundColor:Re.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),kfe=nt.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Re.dash,padding:"0 8px",height:18,fontSize:11}),Cfe=nt.div({position:"absolute",color:Re.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Tfe=nt.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%)"}})),Ife=nt.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}})),u8=nt.div(e=>({position:"relative",backgroundColor:e.isErr?Re.errBg:Re.borderBoxBg,border:`1px solid ${e.isErr?Re.err:Re.borderBoxStroke}`,borderRadius:6,padding:0})),p8=nt.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Re.text}),d8=nt.span({fontWeight:500,fontSize:11}),Ffe=nt.span({color:Re.dash}),g8=nt.div(e=>({position:"relative",backgroundColor:e.isErr?Re.errBg:Re.paddingBg,border:`1px solid ${e.isErr?Re.err:Re.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),f8=nt.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Re.text,fontStyle:"italic"}),pu=nt.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Re.err:Re.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%)"}})),m8=nt.div(e=>({backgroundColor:e.isErr?Re.errBg:"#fff",border:`1.5px dashed ${e.isErr?Re.err:Re.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Re.err:Re.text,fontWeight:e.isErr?600:400})),h8=nt.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Re.dim,fontFamily:"monospace"}),x8=nt.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Re.ok,padding:"4px 8px 6px"}),Efe=nt.div({fontSize:11,fontWeight:600,color:Re.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),Afe=nt.span({fontSize:12,color:Re.dim}),y8=nt.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),b8=nt.div({fontSize:9,color:Re.dim,marginTop:2}),S8=({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}=ue(),d=r||{},p=!(!!r&&Object.keys(r).length>0)&&s?E8(n):null,h=d.padding||p||{top:0,right:0,bottom:0,left:0},b=d.strokeWeight??(a?ds(n)??0:0),I=d.width??(u?A8(n)??"\u2014":"\u2014"),F=d.height??(u?P8(n)??"\u2014":"\u2014");return Ee.createElement(Ee.Fragment,null,Ee.createElement(c8,null,Ee.createElement(u8,{isErr:a},Ee.createElement(p8,null,Ee.createElement(d8,null,"Border"),Ee.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Re.err:Re.dim}},b)),Ee.createElement(g8,{isErr:s},Ee.createElement(f8,null,"Padding"),Ee.createElement(pu,{side:"top",isErr:s},h.top),Ee.createElement(pu,{side:"right",isErr:s},h.right),Ee.createElement(pu,{side:"bottom",isErr:s},h.bottom),Ee.createElement(pu,{side:"left",isErr:s},h.left),Ee.createElement(m8,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Ee.createElement(y8,{src:l,alt:"Figma element"}),Ee.createElement(b8,null,I," \xD7 ",F)))),Ee.createElement(h8,null,"border-box")),Ee.createElement(x8,null,"\u2192 ",n))},WI=nt.div({backgroundColor:Re.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),w8=nt.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),_x=nt.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Re.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),v8=nt.div({position:"absolute",border:`1.5px dashed ${Re.err}`,pointerEvents:"none",zIndex:0}),k8=nt.div({position:"absolute",border:`1.5px dashed ${Re.blue}`,pointerEvents:"none",zIndex:0}),VI=nt.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%)"}})),Pfe=nt.div({fontSize:12,color:Re.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),C8=nt.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),GI=nt.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Re.err:Re.ok})),T8=nt.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),qI=nt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),YI=nt.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Re.err:Re.ok})),KI=nt.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Re.err:Re.ok,textDecoration:e.variant==="err"?"line-through":"none"})),I8=nt.span({fontSize:16,color:Re.dim,paddingBottom:20}),XI=nt.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function QI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var F8=({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,g=o.fontSize??(s?ds(n):14),p=o.fontWeight??(a?ds(n):600),b=(o.lineHeight??(u?ds(n):null))||Math.round((g||14)*1.43),I=`${Math.min(Math.max(g||14,24),48)}px`;if(d)return Ee.createElement(Ee.Fragment,null,Ee.createElement(WI,null,Ee.createElement(w8,null,Ee.createElement(k8,{style:{top:-6,left:0,right:0,bottom:-6}}),Ee.createElement(v8,{style:{top:2,left:8,right:8,bottom:2}}),Ee.createElement(VI,{color:s?Re.err:"#7b3030",side:"left"},s?t:`${g}px`),Ee.createElement(VI,{color:u?Re.err:"#7b3030",side:"right"},u?t:`${b}px`),Ee.createElement(_x,{fSize:I,fWeight:String(p||600)},"Ag")),Ee.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Ee.createElement(XI,{color:Re.err},"\u2508\u2508 font-size",s?" \u2717":""),Ee.createElement(XI,{color:Re.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Ee.createElement(C8,null,Ee.createElement(GI,{variant:"err"},t),Ee.createElement("span",{style:{color:Re.dim}},"\u2192"),Ee.createElement(GI,{variant:"ok"},n))));let F=a?t:String(p||600),v=a?n:F,D=ds(t),N=ds(n);return Ee.createElement(Ee.Fragment,null,Ee.createElement(WI,null,Ee.createElement(T8,null,Ee.createElement(qI,null,Ee.createElement(YI,{variant:"err"},"Current"),Ee.createElement(_x,{fSize:I,fWeight:a?F:String(p||600),style:{color:Re.err}},c?t:"Ag"),Ee.createElement(KI,{variant:"err"},a&&D?`${t} (${QI(D)})`:t)),Ee.createElement(I8,null,"\u2192"),Ee.createElement(qI,null,Ee.createElement(YI,{variant:"ok"},"Figma"),Ee.createElement(_x,{fSize:I,fWeight:a?v:String(p||600),style:{color:Re.ok}},c?n:"Ag"),Ee.createElement(KI,{variant:"ok"},a&&N?`${n} (${QI(N)})`:n)))))};function E8(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 ds(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function A8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function P8(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var JI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function L8(e){if(JI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return JI.has(t)}var ZI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=L8(e.property);return Ee.createElement(a8,null,Ee.createElement(l8,null,"\u25BE Layer properties",t?"":" (from review)"),n?Ee.createElement(F8,{...e}):Ee.createElement(S8,{...e}))};import Kr from"react";import{styled as Xr}from"storybook/theming";var M8={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)"}},B8=Xr.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),D8=Xr.div(({theme:e,category:t})=>{let n=M8[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}`}}),R8=Xr.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}}}),z8=Xr.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"}}),N8=Xr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),O8=Xr.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"}}),_8=Xr.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"}}),$8=Xr.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"}}),U8=Xr.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}`})),j8=Xr.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),H8=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},eF=({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=H8(e.detectedBy),l=o&&c.ai===o,d=r&&!l&&(c.ai||c.programmatic),g=e.generatedFix?.filePath||e.file;return Kr.createElement(B8,null,Kr.createElement(D8,{category:e.type},e.type),e.status!=="pending"&&Kr.createElement(R8,{status:e.status},e.status),n&&t&&Kr.createElement(z8,null,t),d&&Kr.createElement(N8,null,c.ai&&!l&&Kr.createElement(O8,null,c.ai),c.programmatic&&Kr.createElement(_8,null,"Pre-filter: ",c.programmatic)),a&&Kr.createElement($8,{title:u},"Unreliable"),e.dismissed&&Kr.createElement(U8,null,"Dismissed"),i&&s&&g&&Kr.createElement(j8,null,g))};import Kn from"react";import{styled as Yo}from"storybook/theming";var W8=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},V8=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",G8=Yo.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"})),$x=Yo.div({display:"flex",gap:"8px",alignItems:"baseline"}),Ux=Yo.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),jx=Yo.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),q8=Yo(jx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),Y8=Yo(jx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),K8=Yo.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)"})),Y8=qo.span({display:"flex",alignItems:"center"}),tF=({value:e,isStrikethrough:t=!1})=>{let n=j8(e),r=H8(e),o=t?V8:G8;return n?Kn.createElement(Y8,null,Kn.createElement(q8,{color:n,title:`Color: ${n}`}),Kn.createElement(o,null,r)):Kn.createElement(o,null,r)},nF=({property:e,currentValue:t,suggestedValue:n})=>Kn.createElement(W8,null,Kn.createElement($x,null,Kn.createElement(Ux,null,"Property"),Kn.createElement(jx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&Kn.createElement($x,null,Kn.createElement(Ux,null,"Current"),Kn.createElement(tF,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&Kn.createElement($x,null,Kn.createElement(Ux,null,"Expected"),Kn.createElement(tF,{value:n,isStrikethrough:!1})));ve();var oF=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 Q8(e){if(oF.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return oF.has(t)}var J8=Ae.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"}})),Wfe=Ae.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),Z8=Ae.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),eH=Ae.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),tH=Ae.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:ce},"&:checked":{backgroundColor:ce,borderColor:ce},"&: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"}})),nH=Ae.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark,"& svg":{width:"16px",height:"16px"}})),rH=Ae.span(({theme:e,severity:t})=>({flexShrink:0,fontSize:"10px",fontWeight:e.typography.weight.bold,textTransform:"uppercase",letterSpacing:"0.04em",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark})),Vfe=Ae.div({flex:1,minWidth:0}),Gfe=Ae.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),oH=Ae.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),Wx=Ae.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"}})),iH=Ae(Wx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),qfe=Ae.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),Yfe=Ae.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),sH=Ae.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),Kfe=Ae.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"})),Xfe=Ae.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),aH=Ae.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"}})),lH=Ae.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${ce}`})),cH=Ae.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:ce,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),uH=Ae.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"}})),pH=Ae.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),iF=Ae.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"})),Qfe=Ae.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),dH=Ae(An)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),Jfe=Ae(dH)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),gH=Ae.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}`})),sF=Ae.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"})),fH=Ae.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),mH=Ae.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),hH=Ae.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),xH=Ae.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})),aF=Ae.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),lF=Ae.details({marginBottom:"8px"}),cF=Ae.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),yH=Ae.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"})),bH=Ae.div({display:"flex",gap:"8px",marginTop:"8px"}),SH=Ae(En)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),wH=Ae(Or)({padding:"6px 12px",fontSize:"12px"}),Zfe=Ae(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),eme=Ae.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),vH=Ae.div({display:"flex",alignItems:"center",gap:"12px"}),kH=Ae.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ce,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),CH=Ae.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),tme=Ae.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}}})),TH=Ae.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"})),uF=Ae.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"})),pF=Ae.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}`})),dF=Ae.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),gF=Ae.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)"}}),fF=Ae.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),mF=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},IH=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},FH=e=>({"claude-sonnet-4-6":"Sonnet 4.6","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,hF=X8(({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}=ue(),[g,p]=Hx(!1),[m,b]=Hx(!1),[T,F]=Hx(!1),v=K8(null),D=rF(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{d(e.id),F(!0)},100)},[e.id,d]),_=rF(()=>{v.current&&clearTimeout(v.current),v.current=null,d(null),F(!1)},[d]),$=()=>{e.dismissed?s(e.id):p(!0)},L=(S,w)=>{let A=w?`${S}: ${w}`:S;i(e.id,A),p(!1)},R=async()=>{let S=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&S.push(`Property: ${e.property}`),e.currentValue&&S.push(`Current: ${e.currentValue}`),e.suggestedValue&&S.push(`Expected: ${e.suggestedValue}`),e.file&&S.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&S.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&S.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)"})),X8=Yo.span({display:"flex",alignItems:"center"}),tF=({value:e,isStrikethrough:t=!1})=>{let n=W8(e),r=V8(e),o=t?q8:Y8;return n?Kn.createElement(X8,null,Kn.createElement(K8,{color:n,title:`Color: ${n}`}),Kn.createElement(o,null,r)):Kn.createElement(o,null,r)},nF=({property:e,currentValue:t,suggestedValue:n})=>Kn.createElement(G8,null,Kn.createElement($x,null,Kn.createElement(Ux,null,"Property"),Kn.createElement(jx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&Kn.createElement($x,null,Kn.createElement(Ux,null,"Current"),Kn.createElement(tF,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&Kn.createElement($x,null,Kn.createElement(Ux,null,"Expected"),Kn.createElement(tF,{value:n,isStrikethrough:!1})));ve();var oF=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 Z8(e){if(oF.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return oF.has(t)}var eH=Ae.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"}})),Gfe=Ae.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),tH=Ae.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),nH=Ae.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),rH=Ae.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:ce},"&:checked":{backgroundColor:ce,borderColor:ce},"&: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"}})),oH=Ae.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark,"& svg":{width:"16px",height:"16px"}})),iH=Ae.span(({theme:e,severity:t})=>({flexShrink:0,fontSize:"10px",fontWeight:e.typography.weight.bold,textTransform:"uppercase",letterSpacing:"0.04em",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.color.mediumdark})),qfe=Ae.div({flex:1,minWidth:0}),Yfe=Ae.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),sH=Ae.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),Wx=Ae.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"}})),aH=Ae(Wx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),Kfe=Ae.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),Xfe=Ae.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),lH=Ae.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),Qfe=Ae.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"})),Jfe=Ae.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),cH=Ae.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"}})),uH=Ae.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${ce}`})),pH=Ae.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:ce,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),dH=Ae.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"}})),gH=Ae.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),iF=Ae.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"})),Zfe=Ae.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),fH=Ae(Pn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),eme=Ae(fH)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),mH=Ae.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}`})),sF=Ae.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"})),hH=Ae.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),xH=Ae.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),yH=Ae.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),bH=Ae.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})),aF=Ae.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),lF=Ae.details({marginBottom:"8px"}),cF=Ae.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),SH=Ae.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"})),wH=Ae.div({display:"flex",gap:"8px",marginTop:"8px"}),vH=Ae(An)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),kH=Ae(Or)({padding:"6px 12px",fontSize:"12px"}),tme=Ae(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),nme=Ae.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),CH=Ae.div({display:"flex",alignItems:"center",gap:"12px"}),TH=Ae.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ce,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),IH=Ae.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),rme=Ae.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}}})),FH=Ae.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"})),uF=Ae.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"})),pF=Ae.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}`})),dF=Ae.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),gF=Ae.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)"}}),fF=Ae.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),mF=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},EH=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},AH=e=>({"claude-sonnet-4-6":"Sonnet 4.6","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,hF=J8(({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}=ue(),[g,p]=Hx(!1),[h,b]=Hx(!1),[I,F]=Hx(!1),v=Q8(null),D=rF(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{d(e.id),F(!0)},100)},[e.id,d]),N=rF(()=>{v.current&&clearTimeout(v.current),v.current=null,d(null),F(!1)},[d]),$=()=>{e.dismissed?s(e.id):p(!0)},M=(S,w)=>{let A=w?`${S}: ${w}`:S;i(e.id,A),p(!1)},z=async()=>{let S=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&S.push(`Property: ${e.property}`),e.currentValue&&S.push(`Current: ${e.currentValue}`),e.suggestedValue&&S.push(`Expected: ${e.suggestedValue}`),e.file&&S.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&S.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&S.push(`
99
99
  Suggested code:
100
100
  \`\`\`
101
101
  ${e.suggestedCode}
@@ -109,25 +109,25 @@ Diff:
109
109
  \`\`\`diff
110
110
  ${A.diffPreview}
111
111
  \`\`\``),A.error&&S.push(`Error: ${A.error}`)}let w=S.filter(Boolean).join(`
112
- `);try{await navigator.clipboard.writeText(w),b(!0),setTimeout(()=>b(!1),2e3)}catch(A){console.error("Failed to copy:",A)}},h=e.generatedFix?.status==="applied";return ee.createElement(ee.Fragment,null,ee.createElement(J8,{dismissed:!!e.dismissed,fixApplied:h,onMouseEnter:D,onMouseLeave:_},ee.createElement(Z8,null,ee.createElement(tH,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),ee.createElement(nH,{severity:e.severity},e.severity==="critical"?ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("circle",{cx:"12",cy:"12",r:"10"}),ee.createElement("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),ee.createElement("line",{x1:"9",y1:"9",x2:"15",y2:"15"})):e.severity==="major"?ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.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"}),ee.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),ee.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("circle",{cx:"12",cy:"12",r:"10"}),ee.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),ee.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),ee.createElement(rH,{severity:e.severity},e.severity),ee.createElement(eH,null,e.title),ee.createElement(oH,null,ee.createElement(Wx,{onClick:R,title:"Copy issue details"},m?ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("polyline",{points:"20 6 9 17 4 12"})):ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),ee.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?ee.createElement(Wx,{onClick:$,title:"Restore issue"},ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("polyline",{points:"1 4 1 10 7 10"}),ee.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})),"Restore"):ee.createElement(iH,{onClick:$,title:"Dismiss issue"},ee.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ee.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),"Dismiss"))),ee.createElement(eF,{issue:e,modelDisplayName:FH(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&&ee.createElement(sH,null,e.description),e.property&&ee.createElement(nF,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&T&&e.property&&e.currentValue&&e.suggestedValue&&Q8(e.property)&&ee.createElement(ZI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&ee.createElement(aH,null,ee.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&ee.createElement(lH,null,ee.createElement(cH,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((S,w)=>ee.createElement(uH,{key:`${S.property}-${w}`},ee.createElement(pH,null,S.property),ee.createElement(iF,{type:"current"},S.currentValue),ee.createElement(iF,{type:"suggested"},S.suggestedValue)))),e.dismissed&&ee.createElement(gH,null,ee.createElement("strong",null,"Filtered by:")," ",IH(e.dismissedBy),e.dismissReason&&ee.createElement(ee.Fragment,null,ee.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&ee.createElement(sF,null,ee.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&ee.createElement(fH,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?ee.createElement(vH,{style:{margin:0}},ee.createElement(kH,null),ee.createElement(CH,{style:{margin:0}},"Generating fix...")):ee.createElement(ee.Fragment,null,ee.createElement(mH,null,ee.createElement(hH,null,"AI-Generated Fix"),ee.createElement(xH,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&ee.createElement(aF,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&ee.createElement(aF,{style:{fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?ee.createElement(lF,null,ee.createElement(cF,null,"View Diff"),ee.createElement(TH,null,ee.createElement(uF,{side:"old"},ee.createElement(pF,{side:"old"},"Old"),ee.createElement(dF,null,mF(e.generatedFix.diffPreview).map((S,w)=>ee.createElement(gF,{key:`old-${w}`,type:S.oldLine.type},S.oldLine.content||"\xA0")))),ee.createElement(uF,{side:"new"},ee.createElement(pF,{side:"new"},"New"),ee.createElement(dF,null,mF(e.generatedFix.diffPreview).map((S,w)=>ee.createElement(gF,{key:`new-${w}`,type:S.newLine.type},S.newLine.content||"\xA0")))))):e.generatedFix.code&&ee.createElement(lF,null,ee.createElement(cF,null,"View Generated Code"),ee.createElement(yH,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&ee.createElement(sF,null,ee.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&ee.createElement(bH,null,ee.createElement(SH,{onClick:()=>a(e.id)},"Apply Fix"),u&&ee.createElement(wH,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&ee.createElement(fF,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&ee.createElement(fF,{status:"applied"},"\u2713 Fix applied successfully")))),ee.createElement(HI,{isOpen:g,issueTitle:e.title,onConfirm:L,onCancel:()=>p(!1)}))});import Vx from"react";import{styled as Gx,keyframes as EH}from"storybook/theming";var AH=EH`
112
+ `);try{await navigator.clipboard.writeText(w),b(!0),setTimeout(()=>b(!1),2e3)}catch(A){console.error("Failed to copy:",A)}},m=e.generatedFix?.status==="applied";return te.createElement(te.Fragment,null,te.createElement(eH,{dismissed:!!e.dismissed,fixApplied:m,onMouseEnter:D,onMouseLeave:N},te.createElement(tH,null,te.createElement(rH,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),te.createElement(oH,{severity:e.severity},e.severity==="critical"?te.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},te.createElement("circle",{cx:"12",cy:"12",r:"10"}),te.createElement("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),te.createElement("line",{x1:"9",y1:"9",x2:"15",y2:"15"})):e.severity==="major"?te.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},te.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"}),te.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),te.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):te.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},te.createElement("circle",{cx:"12",cy:"12",r:"10"}),te.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),te.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),te.createElement(iH,{severity:e.severity},e.severity),te.createElement(nH,null,e.title),te.createElement(sH,null,te.createElement(Wx,{onClick:z,title:"Copy issue details"},h?te.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},te.createElement("polyline",{points:"20 6 9 17 4 12"})):te.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},te.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),te.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?te.createElement(Wx,{onClick:$,title:"Restore issue"},te.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},te.createElement("polyline",{points:"1 4 1 10 7 10"}),te.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})),"Restore"):te.createElement(aH,{onClick:$,title:"Dismiss issue"},te.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},te.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),te.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),"Dismiss"))),te.createElement(eF,{issue:e,modelDisplayName:AH(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&&te.createElement(lH,null,e.description),e.property&&te.createElement(nF,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&I&&e.property&&e.currentValue&&e.suggestedValue&&Z8(e.property)&&te.createElement(ZI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&te.createElement(cH,null,te.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&te.createElement(uH,null,te.createElement(pH,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((S,w)=>te.createElement(dH,{key:`${S.property}-${w}`},te.createElement(gH,null,S.property),te.createElement(iF,{type:"current"},S.currentValue),te.createElement(iF,{type:"suggested"},S.suggestedValue)))),e.dismissed&&te.createElement(mH,null,te.createElement("strong",null,"Filtered by:")," ",EH(e.dismissedBy),e.dismissReason&&te.createElement(te.Fragment,null,te.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&te.createElement(sF,null,te.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&te.createElement(hH,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?te.createElement(CH,{style:{margin:0}},te.createElement(TH,null),te.createElement(IH,{style:{margin:0}},"Generating fix...")):te.createElement(te.Fragment,null,te.createElement(xH,null,te.createElement(yH,null,"AI-Generated Fix"),te.createElement(bH,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&te.createElement(aF,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&te.createElement(aF,{style:{fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?te.createElement(lF,null,te.createElement(cF,null,"View Diff"),te.createElement(FH,null,te.createElement(uF,{side:"old"},te.createElement(pF,{side:"old"},"Old"),te.createElement(dF,null,mF(e.generatedFix.diffPreview).map((S,w)=>te.createElement(gF,{key:`old-${w}`,type:S.oldLine.type},S.oldLine.content||"\xA0")))),te.createElement(uF,{side:"new"},te.createElement(pF,{side:"new"},"New"),te.createElement(dF,null,mF(e.generatedFix.diffPreview).map((S,w)=>te.createElement(gF,{key:`new-${w}`,type:S.newLine.type},S.newLine.content||"\xA0")))))):e.generatedFix.code&&te.createElement(lF,null,te.createElement(cF,null,"View Generated Code"),te.createElement(SH,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&te.createElement(sF,null,te.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&te.createElement(wH,null,te.createElement(vH,{onClick:()=>a(e.id)},"Apply Fix"),u&&te.createElement(kH,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&te.createElement(fF,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&te.createElement(fF,{status:"applied"},"\u2713 Fix applied successfully")))),te.createElement(HI,{isOpen:g,issueTitle:e.title,onConfirm:M,onCancel:()=>p(!1)}))});import Vx from"react";import{styled as Gx,keyframes as PH}from"storybook/theming";var LH=PH`
113
113
  0% { transform: rotate(0deg); }
114
114
  100% { transform: rotate(360deg); }
115
- `,PH=Gx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),LH=Gx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${AH} 0.8s linear infinite`})),MH=Gx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),du=({label:e="Loading..."})=>Vx.createElement(PH,null,Vx.createElement(LH,null),Vx.createElement(MH,null,e));ve();import bt,{useState as BH,useEffect as DH,useRef as RH}from"react";import{styled as yn,keyframes as Na}from"storybook/theming";var ps="#8b6cc1",zH="rgba(139, 108, 193, 0.2)",bF="rgba(139, 108, 193, 0.15)",NH="rgba(139, 108, 193, 0.1)",OH="rgba(139, 108, 193, 0.5)",SF=Na`
115
+ `,MH=Gx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),BH=Gx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${LH} 0.8s linear infinite`})),DH=Gx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),du=({label:e="Loading..."})=>Vx.createElement(MH,null,Vx.createElement(BH,null),Vx.createElement(DH,null,e));ve();import bt,{useState as RH,useEffect as zH,useRef as NH}from"react";import{styled as yn,keyframes as Oa}from"storybook/theming";var gs="#8b6cc1",OH="rgba(139, 108, 193, 0.2)",bF="rgba(139, 108, 193, 0.15)",_H="rgba(139, 108, 193, 0.1)",$H="rgba(139, 108, 193, 0.5)",SF=Oa`
116
116
  from { transform: rotate(0deg); }
117
117
  to { transform: rotate(360deg); }
118
- `,_H=Na`
118
+ `,UH=Oa`
119
119
  from { transform: rotate(0deg); }
120
120
  to { transform: rotate(-360deg); }
121
- `,$H=Na`
121
+ `,jH=Oa`
122
122
  0%, 100% { opacity: 1; transform: scale(1); }
123
123
  50% { opacity: 0.6; transform: scale(1.05); }
124
- `,UH=Na`
124
+ `,HH=Oa`
125
125
  from { opacity: 0; transform: translateY(8px); }
126
126
  to { opacity: 1; transform: translateY(0); }
127
- `,jH=Na`
127
+ `,WH=Oa`
128
128
  0%, 100% { opacity: 1; }
129
129
  50% { opacity: 0.4; }
130
- `,HH=yn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${UH} 0.4s ease-out`}),WH=yn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),VH=yn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${bF} 0%, transparent 70%)`,animation:`${$H} 2s ease-in-out infinite`}),GH=yn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${zH}`}),qH=yn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:ps,borderRightColor:ps,animation:`${SF} 1.2s linear infinite`}),YH=yn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${bF}`}),KH=yn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:OH,animation:`${_H} 1.8s linear infinite`}),XH=yn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),QH=yn.div({position:"absolute",inset:0,animation:`${SF} 3s linear infinite`}),JH=yn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:ps}),ZH=()=>bt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:ps,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},bt.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"}),bt.createElement("path",{d:"M5 3v4"}),bt.createElement("path",{d:"M3 5h4"}),bt.createElement("path",{d:"M19 17v4"}),bt.createElement("path",{d:"M17 19h4"})),eW=yn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),tW=yn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),nW=yn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),qx=yn.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:NH,color:ps},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),xF=yn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),yF=yn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:ps,animation:`${jH} 1.5s ease-in-out infinite`}),rW=yn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),oW=()=>bt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},bt.createElement("polyline",{points:"20 6 9 17 4 12"})),wF=()=>{let{streamingProgress:e}=ue(),t=(e||0)>25,[n,r]=BH(0),o=RH();return DH(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),bt.createElement(HH,null,bt.createElement(WH,null,bt.createElement(VH,null),bt.createElement(GH,null),bt.createElement(qH,null),bt.createElement(YH,null),bt.createElement(KH,null),bt.createElement(XH,null,bt.createElement(ZH,null)),bt.createElement(QH,null,bt.createElement(JH,null))),bt.createElement(eW,null,"Analyzing designs"),bt.createElement(tW,null,"AI is comparing screenshots and detecting issues"),bt.createElement(nW,null,bt.createElement(qx,{variant:t?"done":"active"},t?bt.createElement(oW,null):bt.createElement(yF,null),"Screenshots"),bt.createElement(xF,null),bt.createElement(qx,{variant:t?"active":"pending"},t?bt.createElement(yF,null):null,"Analysis"),bt.createElement(xF,null),bt.createElement(qx,{variant:"pending"},"Report")),bt.createElement(rW,null,n,"s \xB7 Esc to stop"))};ve();var Sme=rt.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}})),wme=rt.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:ce})),lW=rt.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),cW=rt.div({display:"flex",gap:"8px"}),kF=rt(Sn)({flex:1}),uW=rt.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}})),pW=rt.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),dW=rt.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"}})),gW=rt.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),fW=rt.div({display:"flex",alignItems:"center",gap:"2px"}),gu=rt(An)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Yx=rt.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),mW=rt.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),vme=rt.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Yo=rt.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:ce};case"selected":return{bg:e.color.tertiary,text:ce};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:ce};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"}}),hW=rt.div({display:"flex",flexDirection:"column"}),xW=rt.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),CF=rt.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),TF=rt.div({fontSize:"36px",marginBottom:"12px"}),IF=rt.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),FF=rt.div({fontSize:"12px"}),yW=aW`
130
+ `,VH=yn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${HH} 0.4s ease-out`}),GH=yn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),qH=yn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${bF} 0%, transparent 70%)`,animation:`${jH} 2s ease-in-out infinite`}),YH=yn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${OH}`}),KH=yn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:gs,borderRightColor:gs,animation:`${SF} 1.2s linear infinite`}),XH=yn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${bF}`}),QH=yn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:$H,animation:`${UH} 1.8s linear infinite`}),JH=yn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),ZH=yn.div({position:"absolute",inset:0,animation:`${SF} 3s linear infinite`}),eW=yn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:gs}),tW=()=>bt.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:gs,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},bt.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"}),bt.createElement("path",{d:"M5 3v4"}),bt.createElement("path",{d:"M3 5h4"}),bt.createElement("path",{d:"M19 17v4"}),bt.createElement("path",{d:"M17 19h4"})),nW=yn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),rW=yn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),oW=yn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),qx=yn.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:_H,color:gs},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),xF=yn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),yF=yn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:gs,animation:`${WH} 1.5s ease-in-out infinite`}),iW=yn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),sW=()=>bt.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},bt.createElement("polyline",{points:"20 6 9 17 4 12"})),wF=()=>{let{streamingProgress:e}=ue(),t=(e||0)>25,[n,r]=RH(0),o=NH();return zH(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),bt.createElement(VH,null,bt.createElement(GH,null,bt.createElement(qH,null),bt.createElement(YH,null),bt.createElement(KH,null),bt.createElement(XH,null),bt.createElement(QH,null),bt.createElement(JH,null,bt.createElement(tW,null)),bt.createElement(ZH,null,bt.createElement(eW,null))),bt.createElement(nW,null,"Analyzing designs"),bt.createElement(rW,null,"AI is comparing screenshots and detecting issues"),bt.createElement(oW,null,bt.createElement(qx,{variant:t?"done":"active"},t?bt.createElement(sW,null):bt.createElement(yF,null),"Screenshots"),bt.createElement(xF,null),bt.createElement(qx,{variant:t?"active":"pending"},t?bt.createElement(yF,null):null,"Analysis"),bt.createElement(xF,null),bt.createElement(qx,{variant:"pending"},"Report")),bt.createElement(iW,null,n,"s \xB7 Esc to stop"))};ve();var vme=rt.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}})),kme=rt.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:ce})),uW=rt.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),pW=rt.div({display:"flex",gap:"8px"}),kF=rt(Sn)({flex:1}),dW=rt.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}})),gW=rt.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),fW=rt.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"}})),mW=rt.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),hW=rt.div({display:"flex",alignItems:"center",gap:"2px"}),gu=rt(Pn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Yx=rt.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),xW=rt.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Cme=rt.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Ko=rt.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:ce};case"selected":return{bg:e.color.tertiary,text:ce};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:ce};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"}}),yW=rt.div({display:"flex",flexDirection:"column"}),bW=rt.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),CF=rt.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),TF=rt.div({fontSize:"36px",marginBottom:"12px"}),IF=rt.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),FF=rt.div({fontSize:"12px"}),SW=cW`
131
131
  0% {
132
132
  transform: translateY(0) rotate(0deg) scale(1);
133
133
  opacity: 1;
@@ -139,35 +139,35 @@ ${A.diffPreview}
139
139
  transform: translateY(120px) rotate(720deg) scale(0.3);
140
140
  opacity: 0;
141
141
  }
142
- `;var kme=rt.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Cme=rt.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:`${yW} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var bW=rt.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}}})),SW=rt(An)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),EF=rt.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),AF=rt(En)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),PF=rt(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),LF=rt(on)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),wW=rt.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}}),vW=rt.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),kW=rt.span(({confidence:e,theme:t})=>{let n=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:t.base==="dark"?e>=90?"rgba(22, 163, 74, 0.18)":e>=70?"rgba(202, 138, 4, 0.18)":"rgba(220, 38, 38, 0.18)":e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:n,fontSize:"11px",fontWeight:700}}),CW=rt.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),TW=rt.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),fu=rt.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),mu=rt.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),IW=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},MF=({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:g,onSelectAllFixes:p,onApplyFixes:m,onApplyFix:b,onCopyAllFixes:T,onGenerateFixes:F,onDismiss:v,onUndismiss:D,isGenerating:_=!1,isApplying:$=!1,isCopying:L=!1,applyFixesResult:R,onDismissResult:h,generationTiming:S,generationUsage:w,generationProgress:A,autoApplySupported:f=!0,hasReviewBeenRun:k=!1,isLoadingReview:E=!1,isReviewing:x=!1,selfReview:C})=>{let[P,B]=X.useState("all"),[N,I]=X.useState("all"),[z,W]=X.useState(!1),[M,ie]=X.useState(!0),{includeComponentIssues:K,setIncludeComponentIssues:ae,featureFlags:xe}=ue(),Pe=X.useRef(null),[Ye,ne]=iW(0);sW(()=>{if(!_){ne(0);return}let q=setInterval(()=>ne(je=>je+1),1e3);return()=>clearInterval(q)},[_]);let Te=async()=>{let q=te.map(H=>{let le=[`[${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 me=H.generatedFix;if(le.push(""),le.push("--- AI-Generated Fix ---"),le.push(`Fix Status: ${me.status}`),me.confidence!==void 0){let Dn=me.confidence>1?me.confidence:Math.round(me.confidence*100);le.push(`Confidence: ${Dn}%`)}me.strategy&&le.push(`Strategy: ${me.strategy}`),me.filePath&&le.push(`Target file: ${me.filePath}`),me.code&&le.push(`Generated code:
143
- ${me.code}`),me.diffPreview&&le.push(`Diff:
144
- ${me.diffPreview}`),me.error&&le.push(`Error: ${me.error}`)}return le.push(""),le.filter(Boolean).join(`
142
+ `;var Tme=rt.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Ime=rt.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:`${SW} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var wW=rt.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}}})),vW=rt(Pn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),EF=rt.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),AF=rt(An)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),PF=rt(on)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),LF=rt(on)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),kW=rt.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}}),CW=rt.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),TW=rt.span(({confidence:e,theme:t})=>{let n=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:t.base==="dark"?e>=90?"rgba(22, 163, 74, 0.18)":e>=70?"rgba(202, 138, 4, 0.18)":"rgba(220, 38, 38, 0.18)":e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:n,fontSize:"11px",fontWeight:700}}),IW=rt.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),FW=rt.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),fu=rt.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),mu=rt.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),EW=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},MF=({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:g,onSelectAllFixes:p,onApplyFixes:h,onApplyFix:b,onCopyAllFixes:I,onGenerateFixes:F,onDismiss:v,onUndismiss:D,isGenerating:N=!1,isApplying:$=!1,isCopying:M=!1,applyFixesResult:z,onDismissResult:m,generationTiming:S,generationUsage:w,generationProgress:A,autoApplySupported:f=!0,hasReviewBeenRun:k=!1,isLoadingReview:E=!1,isReviewing:x=!1,selfReview:T})=>{let[P,B]=X.useState("all"),[_,C]=X.useState("all"),[R,H]=X.useState(!1),[L,ie]=X.useState(!0),{includeComponentIssues:K,setIncludeComponentIssues:se,featureFlags:me}=ue(),Pe=X.useRef(null),[Ge,re]=aW(0);lW(()=>{if(!N){re(0);return}let q=setInterval(()=>re(je=>je+1),1e3);return()=>clearInterval(q)},[N]);let Te=async()=>{let q=ne.map(W=>{let le=[`[${W.severity.toUpperCase()}] ${W.title||W.description}`,`Status: ${W.status}`,W.description&&W.description!==W.title?`Description: ${W.description}`:"",W.property?`Property: ${W.property}`:"",W.currentValue?`Current: ${W.currentValue}`:"",W.suggestedValue?`Expected: ${W.suggestedValue}`:"",W.file?`File: ${W.file}${W.lineNumber!==void 0?`:${W.lineNumber}`:""}`:"",W.suggestedCode?`Suggested code: ${W.suggestedCode}`:""];if(W.generatedFix){let he=W.generatedFix;if(le.push(""),le.push("--- AI-Generated Fix ---"),le.push(`Fix Status: ${he.status}`),he.confidence!==void 0){let Rn=he.confidence>1?he.confidence:Math.round(he.confidence*100);le.push(`Confidence: ${Rn}%`)}he.strategy&&le.push(`Strategy: ${he.strategy}`),he.filePath&&le.push(`Target file: ${he.filePath}`),he.code&&le.push(`Generated code:
143
+ ${he.code}`),he.diffPreview&&le.push(`Diff:
144
+ ${he.diffPreview}`),he.error&&le.push(`Error: ${he.error}`)}return le.push(""),le.filter(Boolean).join(`
145
145
  `)}).join(`
146
146
  ---
147
147
 
148
- `),je=te.filter(H=>H.generatedFix?.status==="applied").length,gt=te.filter(H=>H.generatedFix?.status==="ready").length,O=je>0||gt>0?` | Fixes: ${je} applied, ${gt} ready`:"",j=r!==void 0?` | Similarity: ${r}%`:"",G=`Score: ${n}/100${j} | ${te.length} issues${O}
148
+ `),je=ne.filter(W=>W.generatedFix?.status==="applied").length,gt=ne.filter(W=>W.generatedFix?.status==="ready").length,O=je>0||gt>0?` | Fixes: ${je} applied, ${gt} ready`:"",j=r!==void 0?` | Similarity: ${r}%`:"",G=`Score: ${n}/100${j} | ${ne.length} issues${O}
149
149
 
150
- `;try{await navigator.clipboard.writeText(G+q),W(!0),setTimeout(()=>W(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};X.useEffect(()=>{R&&Pe.current&&Pe.current.scrollIntoView({behavior:"smooth",block:"start"})},[R]);let it=vF(()=>e.map(q=>{let je=Vs(q);return je===q.severity?q:{...q,severity:je}}),[e]),te=vF(()=>it.filter(q=>{let je=P==="all"||q.severity===P,gt=N==="all"||q.status===N,O=K||!IW(q);return je&&gt&&O}),[it,P,N,K]),Be=()=>{te.forEach(q=>{q.selectedForFix||l(q.id)})},ge=()=>{te.forEach(q=>{q.selectedForFix&&l(q.id)})},dt=()=>{te.forEach(q=>{q.generatedFix&&q.generatedFix.status==="ready"&&!q.selectedForFix&&l(q.id)})},ot=te.filter(q=>q.selectedForFix).length,bn=te.filter(q=>q.severity==="critical").length,br=te.filter(q=>q.severity==="major").length,or=te.filter(q=>q.severity==="minor").length,fe=te.filter(q=>q.generatedFix&&q.generatedFix.status==="ready").length,Fe=te.filter(q=>q.selectedForFix&&q.generatedFix&&q.generatedFix.status==="ready").length;return e.length===0?E?X.createElement(du,{label:"Loading review..."}):x?X.createElement(wF,null):X.createElement(CF,null,X.createElement(TF,null,k?"\u2728":"\u{1F441}\uFE0F"),X.createElement(IF,null,k?"No issues found":"No review yet"),X.createElement(FF,null,k?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):X.createElement(lW,{"data-testid":"issues-panel"},X.createElement(cW,null,X.createElement(kF,{value:P,onChange:q=>B(q.target.value)},X.createElement("option",{value:"all"},"All Severities"),X.createElement("option",{value:"critical"},"Critical Only"),X.createElement("option",{value:"major"},"Major Only"),X.createElement("option",{value:"minor"},"Minor Only")),X.createElement(kF,{value:N,onChange:q=>I(q.target.value)},X.createElement("option",{value:"all"},"All Statuses"),X.createElement("option",{value:"pending"},"Pending"),X.createElement("option",{value:"applied"},"Applied"),X.createElement("option",{value:"verified"},"Verified"),X.createElement("option",{value:"failed"},"Failed"))),X.createElement("div",null,X.createElement(uW,{isOpen:M,onClick:()=>ie(!M)},X.createElement(pW,null,X.createElement(dW,{isOpen:M},X.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},X.createElement("polyline",{points:"6 9 12 15 18 9"}))),X.createElement(mW,null,te.length," issues"),(()=>{if(te.length===0)return null;let q=te.map(O=>O.generatedFix?.filePath||O.file).filter(Boolean);if(q.length===0)return null;let je=q[0];return q.every(O=>O===je)?X.createElement(xW,null,"in ",je):null})(),X.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},bn>0&&X.createElement(Yx,{variant:"critical"},bn," critical"),br>0&&X.createElement(Yx,{variant:"major"},br," major"),or>0&&X.createElement(Yx,{variant:"minor"},or," minor"))),X.createElement(fW,{onClick:q=>q.stopPropagation()},X.createElement(gu,{onClick:Be},"All"),X.createElement(gu,{onClick:ge},"None"),X.createElement(gu,{onClick:Te},z?"\u2713":"\u2398"," Copy"),fe>0&&X.createElement(gu,{onClick:dt},"Fixes (",fe,")"))),R&&X.createElement(bW,{ref:Pe,variant:R.error||R.failed>0?"warning":"success"},R.error?X.createElement(X.Fragment,null,R.error):R.failed>0?X.createElement(X.Fragment,null,"Applied ",R.succeeded,"/",R.total," ","fixes. ",R.failed," failed. Run a new review to verify."):X.createElement(X.Fragment,null,"Applied ",R.total," fix",R.total!==1?"es":"","! Run a new review to verify changes."),h&&X.createElement(SW,{onClick:h},"\u2715")),ot>0&&X.createElement(EF,null,S&&X.createElement(Yo,{variant:"timing"},S.durationSec,"s (",S.issueCount," ","fixes)"),w&&X.createElement(X.Fragment,null,X.createElement(Yo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),X.createElement(Yo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),X.createElement(Yo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&F&&X.createElement(LF,{disabled:_||$||L,onClick:F},X.createElement("span",null,"\u{1F916}"),_&&A?`Generating ${A.completed}/${A.total}... (${Ye}s)`:_?`Generating... (${Ye}s)`:`Generate Fixes for ${ot} Issue${ot>1?"s":""}`),xe.enableFixApply&&f&&m&&X.createElement(AF,{disabled:_||$||Fe===0,onClick:m},$?"Applying...":_?"Generating...":Fe>0?`Apply ${Fe} Ready Fix${Fe>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&T&&X.createElement(PF,{disabled:_||L||Fe===0,copied:L,onClick:T},L?"Copied!":Fe>0?`Copy ${Fe} Fix${Fe>1?"es":""}`:"Copy Fixes (generate first)")),C&&!_&&X.createElement(wW,{confidence:C.overallConfidence},X.createElement(vW,null,X.createElement(CW,null,"AI Self-Review"),X.createElement(kW,{confidence:C.overallConfidence},C.wouldReachPerfect?"\u2713":"\u25B3"," ",C.overallConfidence,"% confidence")),X.createElement(TW,null,C.variantSafety&&X.createElement(fu,null,X.createElement(mu,null,"Variant safety:"," "),C.variantSafety),C.gaps.length>0&&X.createElement(fu,null,X.createElement(mu,null,"Gaps: "),X.createElement("ul",null,C.gaps.map((q,je)=>X.createElement("li",{key:je},q)))),!C.wouldReachPerfect&&C.reasonsNotPerfect.length>0&&X.createElement(fu,null,X.createElement(mu,null,"Why not 100%:"," "),X.createElement("ul",null,C.reasonsNotPerfect.map((q,je)=>X.createElement("li",{key:je},q)))),C.suggestions&&C.suggestions.length>0&&X.createElement(fu,null,X.createElement(mu,null,"Suggestions: "),X.createElement("ul",null,C.suggestions.map((q,je)=>X.createElement("li",{key:je},q)))))),M&&X.createElement(gW,null,te.length===0?X.createElement(CF,null,X.createElement(TF,null,"\u{1F50D}"),X.createElement(IF,null,"No issues match current filters"),X.createElement(FF,null,"Try adjusting your severity or status filters")):X.createElement(hW,null,(()=>{let q={};te.forEach(G=>{let H=G.detectedBy;H&&(q[H]=(q[H]||0)+1)});let je=Object.entries(q).sort((G,H)=>H[1]-G[1])[0],gt=je&&je[1]>te.length/2?je[0]:void 0,O=te.map(G=>G.generatedFix?.filePath||G.file).filter(Boolean),j=O.length>0&&O.every(G=>G===O[0]);return te.map(G=>X.createElement(hF,{key:G.id,issue:G,modelId:t,dominantDetector:gt,showFilePath:!j,onToggleSelection:l,onDismiss:v,onUndismiss:D,onApplyFix:b}))})()))),ot>0&&X.createElement(EF,null,S&&X.createElement(Yo,{variant:"timing"},S.durationSec,"s (",S.issueCount," ","fixes)"),w&&X.createElement(X.Fragment,null,X.createElement(Yo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),X.createElement(Yo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),X.createElement(Yo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&F&&X.createElement(LF,{disabled:_||$||L,onClick:F},X.createElement("span",null,"\u{1F916}"),_&&A?`Generating ${A.completed}/${A.total}... (${Ye}s)`:_?`Generating... (${Ye}s)`:`Generate Fixes for ${ot} Issue${ot>1?"s":""}`),xe.enableFixApply&&f&&m&&X.createElement(AF,{disabled:_||$||Fe===0,onClick:m},$?"Applying...":_?"Generating...":Fe>0?`Apply ${Fe} Ready Fix${Fe>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&T&&X.createElement(PF,{disabled:_||L||Fe===0,copied:L,onClick:T},L?"Copied!":Fe>0?`Copy ${Fe} Fix${Fe>1?"es":""}`:"Copy Fixes (generate first)")))};Ne();var FW=Ft.div({display:"flex",flexDirection:"column"}),EW=Ft.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),AW=Ft.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),Kx=Ft.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:ce}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),PW=Ft.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),zme=Ft.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),Nme=Ft.div({fontSize:"48px",marginBottom:"16px"}),Ome=Ft.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),_me=Ft.div({fontSize:"14px",opacity:.8}),LW=Ft.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),MW=Ft.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),BW=Ft(An)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),DW=Ft(Or)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),RW=Ft.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),zW=Ft.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),NW=Ft.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),OW=Ft.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),_W=Ft.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}})),$W=Ft.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),UW=Ft.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),jW=Ft.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}})),HW=Ft.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),hu={"false-positive":{icon:"\u2715",label:"False positive",group:"False Positive"},planned:{icon:"\u25F7",label:"Planned",group:"Planned"},"wont-fix":{icon:"\u2298",label:"Won't fix",group:"Won't Fix"},"no-figma-state":{icon:"\u25FB",label:"No Figma state",group:"No Figma State"},"design-pending":{icon:"\u2726",label:"Design pending",group:"Design Pending"}},RF=e=>{if(!e)return{categoryId:null,note:""};let t=e.indexOf(": "),n=t>-1?e.slice(0,t):e.trim();return hu[n]?{categoryId:n,note:t>-1?e.slice(t+2):""}:{categoryId:null,note:e}},WW=e=>{if(!e)return"Other";let{categoryId:t}=RF(e);if(t&&hu[t])return hu[t].group;let n=e.toLowerCase();return n.includes("hug")||n.includes("fill")||n.includes("content-driven")?"HUG/FILL Sizing":n.includes("sub-pixel")||n.includes("negligible")?"Sub-pixel Differences":n.includes("values match")||n.includes("values already match")||n.includes("identical")?"Values Match":n.includes("no fix needed")||n.includes("no changes needed")?"No Fix Needed":"Other"},BF=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},VW=Ft.span(({theme:e,phase:t})=>{let n={"post-ai-validation":{bg:"#4b5563",text:"#ffffff"},"ai-validation":{bg:"#0369a1",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n["post-ai-validation"];return{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",fontWeight:600,color:o,backgroundColor:r,padding:"3px 10px",borderRadius:"10px",marginBottom:"8px"}}),GW=Ft.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"}})),Qx=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"},qW=(e,t)=>{switch(e||Qx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},DF=(e,t)=>{switch(e||Qx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Auto";case"user":return"Manual";default:return"Auto"}},YW=Ft.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),KW=Ft.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),XW=Ft.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"})),QW=Ft(ky)({marginTop:"12px"}),Xx=class extends ze.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?ze.createElement(YW,null,ze.createElement(KW,null,"\u26A0\uFE0F Issues Panel Error"),ze.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),ze.createElement(XW,null,this.state.error?.message||"Unknown error",`
150
+ `;try{await navigator.clipboard.writeText(G+q),H(!0),setTimeout(()=>H(!1),2e3)}catch(W){console.error("Failed to copy:",W)}};X.useEffect(()=>{z&&Pe.current&&Pe.current.scrollIntoView({behavior:"smooth",block:"start"})},[z]);let it=vF(()=>e.map(q=>{let je=qs(q);return je===q.severity?q:{...q,severity:je}}),[e]),ne=vF(()=>it.filter(q=>{let je=P==="all"||q.severity===P,gt=_==="all"||q.status===_,O=K||!EW(q);return je&&gt&&O}),[it,P,_,K]),Be=()=>{ne.forEach(q=>{q.selectedForFix||l(q.id)})},ge=()=>{ne.forEach(q=>{q.selectedForFix&&l(q.id)})},dt=()=>{ne.forEach(q=>{q.generatedFix&&q.generatedFix.status==="ready"&&!q.selectedForFix&&l(q.id)})},ot=ne.filter(q=>q.selectedForFix).length,bn=ne.filter(q=>q.severity==="critical").length,br=ne.filter(q=>q.severity==="major").length,or=ne.filter(q=>q.severity==="minor").length,fe=ne.filter(q=>q.generatedFix&&q.generatedFix.status==="ready").length,Fe=ne.filter(q=>q.selectedForFix&&q.generatedFix&&q.generatedFix.status==="ready").length;return e.length===0?E?X.createElement(du,{label:"Loading review..."}):x?X.createElement(wF,null):X.createElement(CF,null,X.createElement(TF,null,k?"\u2728":"\u{1F441}\uFE0F"),X.createElement(IF,null,k?"No issues found":"No review yet"),X.createElement(FF,null,k?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):X.createElement(uW,{"data-testid":"issues-panel"},X.createElement(pW,null,X.createElement(kF,{value:P,onChange:q=>B(q.target.value)},X.createElement("option",{value:"all"},"All Severities"),X.createElement("option",{value:"critical"},"Critical Only"),X.createElement("option",{value:"major"},"Major Only"),X.createElement("option",{value:"minor"},"Minor Only")),X.createElement(kF,{value:_,onChange:q=>C(q.target.value)},X.createElement("option",{value:"all"},"All Statuses"),X.createElement("option",{value:"pending"},"Pending"),X.createElement("option",{value:"applied"},"Applied"),X.createElement("option",{value:"verified"},"Verified"),X.createElement("option",{value:"failed"},"Failed"))),X.createElement("div",null,X.createElement(dW,{isOpen:L,onClick:()=>ie(!L)},X.createElement(gW,null,X.createElement(fW,{isOpen:L},X.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},X.createElement("polyline",{points:"6 9 12 15 18 9"}))),X.createElement(xW,null,ne.length," issues"),(()=>{if(ne.length===0)return null;let q=ne.map(O=>O.generatedFix?.filePath||O.file).filter(Boolean);if(q.length===0)return null;let je=q[0];return q.every(O=>O===je)?X.createElement(bW,null,"in ",je):null})(),X.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},bn>0&&X.createElement(Yx,{variant:"critical"},bn," critical"),br>0&&X.createElement(Yx,{variant:"major"},br," major"),or>0&&X.createElement(Yx,{variant:"minor"},or," minor"))),X.createElement(hW,{onClick:q=>q.stopPropagation()},X.createElement(gu,{onClick:Be},"All"),X.createElement(gu,{onClick:ge},"None"),X.createElement(gu,{onClick:Te},R?"\u2713":"\u2398"," Copy"),fe>0&&X.createElement(gu,{onClick:dt},"Fixes (",fe,")"))),z&&X.createElement(wW,{ref:Pe,variant:z.error||z.failed>0?"warning":"success"},z.error?X.createElement(X.Fragment,null,z.error):z.failed>0?X.createElement(X.Fragment,null,"Applied ",z.succeeded,"/",z.total," ","fixes. ",z.failed," failed. Run a new review to verify."):X.createElement(X.Fragment,null,"Applied ",z.total," fix",z.total!==1?"es":"","! Run a new review to verify changes."),m&&X.createElement(vW,{onClick:m},"\u2715")),ot>0&&X.createElement(EF,null,S&&X.createElement(Ko,{variant:"timing"},S.durationSec,"s (",S.issueCount," ","fixes)"),w&&X.createElement(X.Fragment,null,X.createElement(Ko,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),X.createElement(Ko,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),X.createElement(Ko,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),me.enableFixGeneration&&F&&X.createElement(LF,{disabled:N||$||M,onClick:F},X.createElement("span",null,"\u{1F916}"),N&&A?`Generating ${A.completed}/${A.total}... (${Ge}s)`:N?`Generating... (${Ge}s)`:`Generate Fixes for ${ot} Issue${ot>1?"s":""}`),me.enableFixApply&&f&&h&&X.createElement(AF,{disabled:N||$||Fe===0,onClick:h},$?"Applying...":N?"Generating...":Fe>0?`Apply ${Fe} Ready Fix${Fe>1?"es":""}`:"Apply Fixes (generate first)"),me.enableFixApply&&!f&&I&&X.createElement(PF,{disabled:N||M||Fe===0,copied:M,onClick:I},M?"Copied!":Fe>0?`Copy ${Fe} Fix${Fe>1?"es":""}`:"Copy Fixes (generate first)")),T&&!N&&X.createElement(kW,{confidence:T.overallConfidence},X.createElement(CW,null,X.createElement(IW,null,"AI Self-Review"),X.createElement(TW,{confidence:T.overallConfidence},T.wouldReachPerfect?"\u2713":"\u25B3"," ",T.overallConfidence,"% confidence")),X.createElement(FW,null,T.variantSafety&&X.createElement(fu,null,X.createElement(mu,null,"Variant safety:"," "),T.variantSafety),T.gaps.length>0&&X.createElement(fu,null,X.createElement(mu,null,"Gaps: "),X.createElement("ul",null,T.gaps.map((q,je)=>X.createElement("li",{key:je},q)))),!T.wouldReachPerfect&&T.reasonsNotPerfect.length>0&&X.createElement(fu,null,X.createElement(mu,null,"Why not 100%:"," "),X.createElement("ul",null,T.reasonsNotPerfect.map((q,je)=>X.createElement("li",{key:je},q)))),T.suggestions&&T.suggestions.length>0&&X.createElement(fu,null,X.createElement(mu,null,"Suggestions: "),X.createElement("ul",null,T.suggestions.map((q,je)=>X.createElement("li",{key:je},q)))))),L&&X.createElement(mW,null,ne.length===0?X.createElement(CF,null,X.createElement(TF,null,"\u{1F50D}"),X.createElement(IF,null,"No issues match current filters"),X.createElement(FF,null,"Try adjusting your severity or status filters")):X.createElement(yW,null,(()=>{let q={};ne.forEach(G=>{let W=G.detectedBy;W&&(q[W]=(q[W]||0)+1)});let je=Object.entries(q).sort((G,W)=>W[1]-G[1])[0],gt=je&&je[1]>ne.length/2?je[0]:void 0,O=ne.map(G=>G.generatedFix?.filePath||G.file).filter(Boolean),j=O.length>0&&O.every(G=>G===O[0]);return ne.map(G=>X.createElement(hF,{key:G.id,issue:G,modelId:t,dominantDetector:gt,showFilePath:!j,onToggleSelection:l,onDismiss:v,onUndismiss:D,onApplyFix:b}))})()))),ot>0&&X.createElement(EF,null,S&&X.createElement(Ko,{variant:"timing"},S.durationSec,"s (",S.issueCount," ","fixes)"),w&&X.createElement(X.Fragment,null,X.createElement(Ko,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),X.createElement(Ko,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"#"," ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),X.createElement(Ko,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),me.enableFixGeneration&&F&&X.createElement(LF,{disabled:N||$||M,onClick:F},X.createElement("span",null,"\u{1F916}"),N&&A?`Generating ${A.completed}/${A.total}... (${Ge}s)`:N?`Generating... (${Ge}s)`:`Generate Fixes for ${ot} Issue${ot>1?"s":""}`),me.enableFixApply&&f&&h&&X.createElement(AF,{disabled:N||$||Fe===0,onClick:h},$?"Applying...":N?"Generating...":Fe>0?`Apply ${Fe} Ready Fix${Fe>1?"es":""}`:"Apply Fixes (generate first)"),me.enableFixApply&&!f&&I&&X.createElement(PF,{disabled:N||M||Fe===0,copied:M,onClick:I},M?"Copied!":Fe>0?`Copy ${Fe} Fix${Fe>1?"es":""}`:"Copy Fixes (generate first)")))};Ne();var AW=Ft.div({display:"flex",flexDirection:"column"}),PW=Ft.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),LW=Ft.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),Kx=Ft.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:ce}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),MW=Ft.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),Ome=Ft.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),_me=Ft.div({fontSize:"48px",marginBottom:"16px"}),$me=Ft.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),Ume=Ft.div({fontSize:"14px",opacity:.8}),BW=Ft.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),DW=Ft.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),RW=Ft(Pn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),zW=Ft(Or)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),NW=Ft.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),OW=Ft.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),_W=Ft.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),$W=Ft.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),UW=Ft.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}})),jW=Ft.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),HW=Ft.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),WW=Ft.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}})),VW=Ft.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),hu={"false-positive":{icon:"\u2715",label:"False positive",group:"False Positive"},planned:{icon:"\u25F7",label:"Planned",group:"Planned"},"wont-fix":{icon:"\u2298",label:"Won't fix",group:"Won't Fix"},"no-figma-state":{icon:"\u25FB",label:"No Figma state",group:"No Figma State"},"design-pending":{icon:"\u2726",label:"Design pending",group:"Design Pending"}},RF=e=>{if(!e)return{categoryId:null,note:""};let t=e.indexOf(": "),n=t>-1?e.slice(0,t):e.trim();return hu[n]?{categoryId:n,note:t>-1?e.slice(t+2):""}:{categoryId:null,note:e}},GW=e=>{if(!e)return"Other";let{categoryId:t}=RF(e);if(t&&hu[t])return hu[t].group;let n=e.toLowerCase();return n.includes("hug")||n.includes("fill")||n.includes("content-driven")?"HUG/FILL Sizing":n.includes("sub-pixel")||n.includes("negligible")?"Sub-pixel Differences":n.includes("values match")||n.includes("values already match")||n.includes("identical")?"Values Match":n.includes("no fix needed")||n.includes("no changes needed")?"No Fix Needed":"Other"},BF=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},qW=Ft.span(({theme:e,phase:t})=>{let n={"post-ai-validation":{bg:"#4b5563",text:"#ffffff"},"ai-validation":{bg:"#0369a1",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n["post-ai-validation"];return{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",fontWeight:600,color:o,backgroundColor:r,padding:"3px 10px",borderRadius:"10px",marginBottom:"8px"}}),YW=Ft.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"}})),Qx=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"},KW=(e,t)=>{switch(e||Qx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},DF=(e,t)=>{switch(e||Qx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Auto";case"user":return"Manual";default:return"Auto"}},XW=Ft.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),QW=Ft.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),JW=Ft.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"})),ZW=Ft(ky)({marginTop:"12px"}),Xx=class extends ze.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?ze.createElement(XW,null,ze.createElement(QW,null,"\u26A0\uFE0F Issues Panel Error"),ze.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),ze.createElement(JW,null,this.state.error?.message||"Unknown error",`
151
151
 
152
- `,this.state.error?.stack),ze.createElement(QW,{onClick:this.handleReset},"Try Again")):this.props.children}},zF=()=>{let{currentStoryId:e}=Ze(),{currentReviewId:t,isReviewing:n,reviewingStoryId:r,reviewHistory:o,reviewHistoryLoading:i,toggleIssueSelection:s,applyFixesResult:a,setApplyFixesResult:u}=ue(),c=n&&!!e&&e===r,{dismissAndSync:l,undismissAndSync:d}=$I(),{loadingMapping:g}=Ze(),p=!!e&&!t&&!c&&(g||i),[m,b]=ze.useState(!1),[T,F]=ze.useState(!1),[v,D]=ze.useState(!1),{isSupported:_,isDetecting:$}=Om(),{refreshStorybookOnly:L}=oi(),{generateBatchFixes:R,isGenerating:h,error:S,timing:w,progress:A,usage:f,selfReview:k,lastStorybookRoot:E}=Dm(),{applyFixes:x,isApplying:C}=Bm({onComplete:L,storybookRoot:E}),P=o.find(O=>O.id===t),B=P?.issues||[],N=ze.useMemo(()=>B.filter(O=>!O.dismissed),[B]),I=ze.useMemo(()=>B.filter(O=>O.dismissed),[B]),z=ze.useMemo(()=>{let O={postAiValidation:0,aiValidation:0,user:0};for(let j of I)switch(j.dismissedBy){case"post-ai-validation":O.postAiValidation++;break;case"ai-validation":O.aiValidation++;break;default:O.user++;break}return O},[I]),W=N,M=P?.modelId||"unknown",ie=N.filter(O=>O.severity==="critical").length,K=N.filter(O=>O.severity==="major").length,ae=N.filter(O=>O.severity==="minor").length,xe=P?so(ie,K,ae):void 0;ze.useEffect(()=>{!e||xe==null||jr(e,{score:xe,issueCount:N.length,criticalCount:ie,majorCount:K,minorCount:ae})},[xe,e,N.length,ie,K,ae]);let Pe=P?.visualSimilarity,Ye=P?.costUsd,ne=P?.reviewDurationMs,Te=P?.inputTokens,it=P?.outputTokens,te=P?.cacheCreationTokens,Be=P?.cacheReadTokens,ge=P?.parentReviewId?o.find(O=>O.id===P.parentReviewId):null,dt=ze.useMemo(()=>{if(!ge||!P)return null;let O=new Set(ge.issues.map(me=>`${me.type}:${me.property||""}:${me.description}`)),j=new Set(W.map(me=>`${me.type}:${me.property||""}:${me.description}`)),G=ge.issues.filter(me=>!j.has(`${me.type}:${me.property||""}:${me.description}`)).length,H=W.filter(me=>O.has(`${me.type}:${me.property||""}:${me.description}`)).length,le=W.filter(me=>!O.has(`${me.type}:${me.property||""}:${me.description}`)).length;return{resolved:G,remaining:H,newIssues:le}},[ge,P,W]),ot=()=>{W.forEach(O=>{O.selectedForFix||s(O.id)})},bn=()=>{W.forEach(O=>{O.selectedForFix&&s(O.id)})},br=()=>{W.forEach(O=>{O.generatedFix&&O.generatedFix.status==="ready"&&!O.selectedForFix&&s(O.id)})},{featureFlags:or}=ue(),fe=()=>{if(!or.enableFixGeneration){y.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let O=W.filter(j=>j.selectedForFix);if(O.length===0){y.warn("[IssuesPanel] No issues selected for fix generation");return}y.debug(`[IssuesPanel] Generating fixes for ${O.length} issue(s)`,O),R(O)},Fe=()=>{if(!or.enableFixApply){y.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let O=W.filter(G=>G.selectedForFix&&G.generatedFix&&G.generatedFix.status==="ready"&&G.generatedFix.code&&G.generatedFix.filePath);if(O.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let j=O.map(G=>({id:G.id,reviewId:G.reviewId,type:G.type,severity:G.severity,title:G.title,description:G.description,generatedFix:G.generatedFix,storyId:P?.storyId||""}));y.debug(`[IssuesPanel] Applying AI-generated fixes for ${j.length} issue(s)`,j),x(j)},q=O=>{let j=W.find(H=>H.id===O);if(!j){y.warn("[IssuesPanel] Issue not found:",O);return}if(!j.generatedFix||j.generatedFix.status!=="ready"||!j.generatedFix.code||!j.generatedFix.filePath){y.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",O);return}let G={id:j.id,reviewId:j.reviewId,type:j.type,severity:j.severity,title:j.title,description:j.description,generatedFix:j.generatedFix,storyId:P?.storyId||""};y.debug("[IssuesPanel] Applying single AI-generated fix for issue:",G),x([G])},je=async()=>{let O=W.filter(G=>G.selectedForFix&&G.generatedFix&&G.generatedFix.status==="ready"&&G.generatedFix.code&&G.generatedFix.filePath);if(O.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let j=O.map(G=>{let H=G.generatedFix,le=[];return le.push(`// File: ${H.filePath}`),le.push(`// Issue: ${G.title||G.description}`),G.currentValue&&le.push(`// Actual: ${G.currentValue}`),G.suggestedValue&&le.push(`// Expected (Figma): ${G.suggestedValue}`),H.diffPreview&&(le.push("//"),le.push("// Diff:"),H.diffPreview.split(`
153
- `).forEach(me=>{le.push(`// ${me}`)})),le.push("//"),le.push("// Full Fixed Code:"),le.push(H.code),le.join(`
152
+ `,this.state.error?.stack),ze.createElement(ZW,{onClick:this.handleReset},"Try Again")):this.props.children}},zF=()=>{let{currentStoryId:e}=Ze(),{currentReviewId:t,isReviewing:n,reviewingStoryId:r,reviewHistory:o,reviewHistoryLoading:i,toggleIssueSelection:s,applyFixesResult:a,setApplyFixesResult:u}=ue(),c=n&&!!e&&e===r,{dismissAndSync:l,undismissAndSync:d}=$I(),{loadingMapping:g}=Ze(),p=!!e&&!t&&!c&&(g||i),[h,b]=ze.useState(!1),[I,F]=ze.useState(!1),[v,D]=ze.useState(!1),{isSupported:N,isDetecting:$}=Om(),{refreshStorybookOnly:M}=ii(),{generateBatchFixes:z,isGenerating:m,error:S,timing:w,progress:A,usage:f,selfReview:k,lastStorybookRoot:E}=Dm(),{applyFixes:x,isApplying:T}=Bm({onComplete:M,storybookRoot:E}),P=o.find(O=>O.id===t),B=P?.issues||[],_=ze.useMemo(()=>B.filter(O=>!O.dismissed),[B]),C=ze.useMemo(()=>B.filter(O=>O.dismissed),[B]),R=ze.useMemo(()=>{let O={postAiValidation:0,aiValidation:0,user:0};for(let j of C)switch(j.dismissedBy){case"post-ai-validation":O.postAiValidation++;break;case"ai-validation":O.aiValidation++;break;default:O.user++;break}return O},[C]),H=_,L=P?.modelId||"unknown",ie=_.filter(O=>O.severity==="critical").length,K=_.filter(O=>O.severity==="major").length,se=_.filter(O=>O.severity==="minor").length,me=P?ao(ie,K,se):void 0;ze.useEffect(()=>{!e||me==null||jr(e,{score:me,issueCount:_.length,criticalCount:ie,majorCount:K,minorCount:se})},[me,e,_.length,ie,K,se]);let Pe=P?.visualSimilarity,Ge=P?.costUsd,re=P?.reviewDurationMs,Te=P?.inputTokens,it=P?.outputTokens,ne=P?.cacheCreationTokens,Be=P?.cacheReadTokens,ge=P?.parentReviewId?o.find(O=>O.id===P.parentReviewId):null,dt=ze.useMemo(()=>{if(!ge||!P)return null;let O=new Set(ge.issues.map(he=>`${he.type}:${he.property||""}:${he.description}`)),j=new Set(H.map(he=>`${he.type}:${he.property||""}:${he.description}`)),G=ge.issues.filter(he=>!j.has(`${he.type}:${he.property||""}:${he.description}`)).length,W=H.filter(he=>O.has(`${he.type}:${he.property||""}:${he.description}`)).length,le=H.filter(he=>!O.has(`${he.type}:${he.property||""}:${he.description}`)).length;return{resolved:G,remaining:W,newIssues:le}},[ge,P,H]),ot=()=>{H.forEach(O=>{O.selectedForFix||s(O.id)})},bn=()=>{H.forEach(O=>{O.selectedForFix&&s(O.id)})},br=()=>{H.forEach(O=>{O.generatedFix&&O.generatedFix.status==="ready"&&!O.selectedForFix&&s(O.id)})},{featureFlags:or}=ue(),fe=()=>{if(!or.enableFixGeneration){y.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let O=H.filter(j=>j.selectedForFix);if(O.length===0){y.warn("[IssuesPanel] No issues selected for fix generation");return}y.debug(`[IssuesPanel] Generating fixes for ${O.length} issue(s)`,O),z(O)},Fe=()=>{if(!or.enableFixApply){y.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let O=H.filter(G=>G.selectedForFix&&G.generatedFix&&G.generatedFix.status==="ready"&&G.generatedFix.code&&G.generatedFix.filePath);if(O.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let j=O.map(G=>({id:G.id,reviewId:G.reviewId,type:G.type,severity:G.severity,title:G.title,description:G.description,generatedFix:G.generatedFix,storyId:P?.storyId||""}));y.debug(`[IssuesPanel] Applying AI-generated fixes for ${j.length} issue(s)`,j),x(j)},q=O=>{let j=H.find(W=>W.id===O);if(!j){y.warn("[IssuesPanel] Issue not found:",O);return}if(!j.generatedFix||j.generatedFix.status!=="ready"||!j.generatedFix.code||!j.generatedFix.filePath){y.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",O);return}let G={id:j.id,reviewId:j.reviewId,type:j.type,severity:j.severity,title:j.title,description:j.description,generatedFix:j.generatedFix,storyId:P?.storyId||""};y.debug("[IssuesPanel] Applying single AI-generated fix for issue:",G),x([G])},je=async()=>{let O=H.filter(G=>G.selectedForFix&&G.generatedFix&&G.generatedFix.status==="ready"&&G.generatedFix.code&&G.generatedFix.filePath);if(O.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let j=O.map(G=>{let W=G.generatedFix,le=[];return le.push(`// File: ${W.filePath}`),le.push(`// Issue: ${G.title||G.description}`),G.currentValue&&le.push(`// Actual: ${G.currentValue}`),G.suggestedValue&&le.push(`// Expected (Figma): ${G.suggestedValue}`),W.diffPreview&&(le.push("//"),le.push("// Diff:"),W.diffPreview.split(`
153
+ `).forEach(he=>{le.push(`// ${he}`)})),le.push("//"),le.push("// Full Fixed Code:"),le.push(W.code),le.join(`
154
154
  `)}).join(`
155
155
 
156
156
  `+"=".repeat(60)+`
157
157
 
158
- `);F(!0);try{await _m(j)?y.debug(`[IssuesPanel] Copied ${O.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>F(!1),1500)}catch(G){y.error("[IssuesPanel] Error copying fixes:",G),F(!1)}},gt=async O=>{O.stopPropagation();let j=I.map(H=>[`[${H.severity.toUpperCase()}] ${H.title||H.description}`,`Phase: ${DF(H.dismissedBy,H.dismissReason)}`,H.dismissReason?`Reason: ${BF(H.dismissReason)}`:"",H.property?`Property: ${H.property}`:"",H.currentValue?`Current: ${H.currentValue}`:"",H.suggestedValue?`Expected: ${H.suggestedValue}`:""].filter(Boolean).join(`
158
+ `);F(!0);try{await _m(j)?y.debug(`[IssuesPanel] Copied ${O.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>F(!1),1500)}catch(G){y.error("[IssuesPanel] Error copying fixes:",G),F(!1)}},gt=async O=>{O.stopPropagation();let j=C.map(W=>[`[${W.severity.toUpperCase()}] ${W.title||W.description}`,`Phase: ${DF(W.dismissedBy,W.dismissReason)}`,W.dismissReason?`Reason: ${BF(W.dismissReason)}`:"",W.property?`Property: ${W.property}`:"",W.currentValue?`Current: ${W.currentValue}`:"",W.suggestedValue?`Expected: ${W.suggestedValue}`:""].filter(Boolean).join(`
159
159
  `)).join(`
160
160
 
161
161
  ---
162
162
 
163
- `),G=`Filtered Issues (${I.length})
163
+ `),G=`Filtered Issues (${C.length})
164
164
  ${"=".repeat(40)}
165
165
 
166
- `;try{await navigator.clipboard.writeText(G+j),D(!0),setTimeout(()=>D(!1),2e3)}catch(H){y.error("Failed to copy dismissed issues:",H)}};return ze.createElement(FW,null,dt&&ze.createElement(EW,null,ze.createElement(AW,null,"\u{1F4CA} Progress:"),ze.createElement(Kx,{variant:"resolved"},"\u2705 ",dt.resolved," resolved"),ze.createElement(Kx,{variant:"remaining"},"\u23F3 ",dt.remaining," remaining"),dt.newIssues>0&&ze.createElement(Kx,{variant:"new"},"\u{1F195} ",dt.newIssues," new"),ze.createElement(PW,null,"Iteration ",P?.iterationNumber||1)),ze.createElement(Xx,null,ze.createElement(MF,{issues:W,modelId:M,complianceScore:xe,visualSimilarity:Pe,costUsd:Ye,reviewDurationMs:ne,inputTokens:Te,outputTokens:it,cacheCreationTokens:te,cacheReadTokens:Be,onToggleSelection:s,onSelectAll:ot,onSelectNone:bn,onSelectAllFixes:br,onGenerateFixes:fe,onApplyFixes:Fe,onApplyFix:q,onCopyAllFixes:je,onDismiss:l,onUndismiss:d,isGenerating:h,isApplying:C,isCopying:T,applyFixesResult:a,onDismissResult:()=>u(null),generationTiming:w,generationUsage:f,hasReviewBeenRun:!!P,isLoadingReview:p,isReviewing:c,generationProgress:A,autoApplySupported:_,selfReview:k})),I.length>0&&ze.createElement(LW,null,ze.createElement(MW,null,ze.createElement(BW,{onClick:()=>b(!m)},ze.createElement("span",null,m?"\u25BC":"\u25B6"),ze.createElement("span",null,"Filtered out"),ze.createElement(RW,null,I.length),ze.createElement(GW,null,z.postAiValidation>0&&ze.createElement("span",null,"\u2699\uFE0F ",z.postAiValidation),z.aiValidation>0&&ze.createElement("span",null,"\u2726 ",z.aiValidation),z.user>0&&ze.createElement("span",null,"\u{1F464} ",z.user))),ze.createElement(DW,{onClick:gt},v?"\u2713 Copied!":"Copy")),m&&ze.createElement(zW,null,(()=>{let O=I.reduce((H,le)=>{let me=WW(le.dismissReason);return H[me]||(H[me]=[]),H[me].push(le),H},{}),j=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(O).sort((H,le)=>j.indexOf(H)-j.indexOf(le)).map(H=>ze.createElement(ze.Fragment,{key:H},ze.createElement(jW,null,H,ze.createElement(HW,null,O[H].length)),O[H].map(le=>ze.createElement(NW,{key:le.id},ze.createElement(OW,null,ze.createElement(VW,{phase:le.dismissedBy||Qx(le.dismissReason)||"post-ai-validation"},qW(le.dismissedBy,le.dismissReason)," ",DF(le.dismissedBy,le.dismissReason)),ze.createElement(_W,{onClick:()=>d(le.id),title:"Restore to active issues"},"\u21A9 Restore")),ze.createElement($W,null,"[",le.severity.toUpperCase(),"]"," ",le.title||le.description),le.dismissReason&&(()=>{let{categoryId:me,note:Dn}=RF(le.dismissReason),vt=me?hu[me]:null;return ze.createElement(UW,null,vt?ze.createElement(ze.Fragment,null,vt.icon," ",vt.label,Dn?` \u2014 ${Dn}`:""):BF(le.dismissReason))})()))))})())))};var ZW=Oa.div({marginTop:"20px"}),eV=Oa.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),tV=Oa.div({display:"flex",alignItems:"center"}),Jx=Oa(Co)({padding:"10px 16px"}),nV=Oa.div({minHeight:"200px"}),Zx=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ue(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return JW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),zr.createElement(ZW,null,zr.createElement(eV,null,zr.createElement(tV,null,a&&zr.createElement(Jx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&zr.createElement(Jx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),zr.createElement(Jx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),zr.createElement(nV,null,a&&e==="chat"&&(u?zr.createElement(_I,null):zr.createElement(Nx,null)),e==="issues"&&zr.createElement(zF,null),a&&e==="prompt"&&zr.createElement(zx,null)))};ve();import V,{useState as yo,useRef as oy,useEffect as sV,useMemo as aV}from"react";import{styled as Tt,useTheme as lV}from"storybook/theming";$e();Ne();var xu={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},_a="uicopilot_feature_flags";function ey(){try{let e=localStorage.getItem(_a);if(e){let t=JSON.parse(e);return{...xu,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return xu}function rV(e,t){try{let r={...ey(),[e]:t},o={};for(let i in r){let s=i;r[s]!==xu[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(_a,JSON.stringify(o)):localStorage.removeItem(_a),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function oV(){try{localStorage.removeItem(_a),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function ty(e){return ey()[e]}function iV(){let e=Object.keys(xu).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(_a,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:ey,set:rV,reset:oV,enableAll:iV,isEnabled:ty}});Ne();lt();import Mt from"react";var NF=()=>Mt.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"},Mt.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Mt.createElement("circle",{cx:"12",cy:"12",r:"3"}));var $a={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"},Ua=()=>Mt.createElement("svg",{...$a},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),OF=()=>Mt.createElement("svg",{...$a},Mt.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Mt.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Mt.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Mt.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Mt.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Mt.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),_F=()=>Mt.createElement("svg",{...$a},Mt.createElement("polyline",{points:"23 4 23 10 17 10"}),Mt.createElement("polyline",{points:"1 20 1 14 7 14"}),Mt.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"})),ny=()=>Mt.createElement("svg",{...$a},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"})),ry=()=>Mt.createElement("svg",{...$a},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"}));var ja=Tt.div({marginTop:"20px"}),yu=Tt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),bu=Tt.div({display:"flex",alignItems:"center",gap:"12px"}),Ha=Tt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),uhe=Tt.div({display:"flex",gap:"8px"}),phe=Tt.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}})),$F=Tt.div(({theme:e,layout:t})=>({display:t==="side-by-side"?"grid":"flex",gridTemplateColumns:t==="side-by-side"?"minmax(0, 1fr) minmax(0, 1fr)":void 0,gap:t==="side-by-side"?`${e.layoutMargin}px`:0,position:"relative",width:"100%",justifyContent:t==="overlay"?"center":void 0})),Wa=Tt.div(({theme:e,zoomed:t})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,overflow:"hidden",backgroundColor:e.background.app,minHeight:"60px",maxHeight:t?"400px":"150px",display:"flex",alignItems:"center",justifyContent:"center",transition:"max-height 0.2s ease, box-shadow 0.2s ease",boxShadow:t?"0 8px 30px rgba(0, 0, 0, 0.15)":"none","& img":t?{maxWidth:"100%",maxHeight:"400px"}:void 0})),Va=Tt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.92)":"rgba(0, 0, 0, 0.7)",color:e.base==="dark"?"#0a0a0f":e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),Ga=Tt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),Ko=Tt.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"}})),cV=Tt.img(({opacity:e=1})=>({maxWidth:"150px",maxHeight:"150px",height:"auto",display:"block",objectFit:"contain",opacity:e})),uV=Tt.img({display:"block",objectFit:"contain",maxHeight:"150px",maxWidth:"150px"}),pV=Tt.div({position:"relative",display:"inline-block",maxHeight:"150px",overflow:"hidden"}),dhe=Tt.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"}})),dV=Tt.div({position:"relative",display:"inline-block"}),ghe=Tt.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})),gV=Tt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),fV=Tt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),mV=Tt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),hV=Tt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),xV=Tt.input({flex:1}),iy=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),fhe=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),sy=Tt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),yi=Tt.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%"}}})),bi=Tt.div({textAlign:"center",zIndex:1}),Si=Tt.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)"}}})),wi=Tt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),ay=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=lV(),{currentMapping:o,loadingMapping:i}=Ze(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:g}=ue(),{selectedProjectId:p}=Xe(),{sessionToken:m}=Se(),{openComponentBrowser:b}=Js(),{hasMapping:T,deleteMapping:F,setCurrentMapping:v}=si(),D=ty("enableHoverHighlight"),[_,$]=yo("side-by-side"),[L,R]=yo(.5),[h,S]=yo(!1),[w,A]=yo(!1),[f,k]=yo(!1),[E,x]=yo(!1),[C,P]=yo(!1),B=async()=>{k(!1);try{let ne=o?.id;ne&&await F(ne),v(null)}catch(ne){y.error("[ScreenshotComparison] Failed to unlink:",ne)}};sV(()=>{A(!1)},[s]);let[N,I]=yo(null),[z,W]=yo(null),M=oy(null),ie=oy(null),K=oy(null),ae=aV(()=>{if(!D||!l||!g)return null;let ne=d.find(Te=>Te.id===g);return ne?.issues&&ne.issues.find(Te=>Te.id===l)||null},[l,g,d]),xe=ne=>{let Te=ne.currentTarget;A(!0),!yt.getState().figmaDimensions&&Te.naturalWidth&&Te.naturalHeight&&yt.getState().setFigmaDimensions({width:Te.naturalWidth,height:Te.naturalHeight}),requestAnimationFrame(()=>{if(ie.current){let{clientWidth:te,clientHeight:Be}=ie.current;te&&Be&&W({width:te,height:Be})}})},Pe=()=>{requestAnimationFrame(()=>{if(M.current){let{clientWidth:ne,clientHeight:Te}=M.current;ne&&Te&&I({width:ne,height:Te})}})},Ye=async()=>{if(!(!p||!m)){S(!0);try{let ne=Y();await re(`${ne}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},credentials:"include"}),c(null),y.debug("Figma cache cleared, image will reload on next review")}catch(ne){y.error("Failed to refresh Figma:",ne)}finally{S(!1)}}};return e?V.createElement(ja,null,V.createElement(yu,null,V.createElement(bu,null,V.createElement(Ha,null,"Screenshots from this review"))),V.createElement(sy,null,V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading Figma..."))),V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?V.createElement(ja,null,V.createElement(yu,null,V.createElement(bu,null,V.createElement(Ha,null,"Screenshots from this review"))),V.createElement(sy,null,V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading..."))))):V.createElement(ja,null,V.createElement(Ha,null,"Screenshots from this review"),V.createElement(Wa,null,V.createElement(Va,null,"Figma Design"),V.createElement(Ga,null,V.createElement(Ko,{accent:r.color.secondary,onClick:b,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},V.createElement(Ua,null))),V.createElement(iy,{style:{border:"none",padding:"20px 16px",lineHeight:"1.6"}},V.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u2728 This story isn't linked to a Figma frame yet"),V.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the \u{1F50D} above to browse your Figma file and pick a matching frame. Once linked, run a Review to compare your code with the design.")))):!s&&!a?V.createElement(ja,null,V.createElement(yu,null,V.createElement(bu,null,V.createElement(Ha,null,"Screenshots from this review"))),V.createElement(sy,null,V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading..."))))):V.createElement(ja,{ref:K},V.createElement(yu,null,V.createElement(bu,null,V.createElement(Ha,null,"Screenshots from this review"))),_==="side-by-side"?V.createElement($F,{layout:"side-by-side"},o&&s&&!t?V.createElement(Wa,{zoomed:E},V.createElement(Va,null,"Figma Design"),V.createElement(Ga,null,V.createElement(Ko,{accent:r.color.secondary,onClick:()=>x(ne=>!ne),title:E?"Shrink preview":"Enlarge preview","aria-label":E?"Shrink preview":"Enlarge preview"},E?V.createElement(ry,null):V.createElement(ny,null)),T&&V.createElement(Ko,{accent:r.color.secondary,onClick:b,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},V.createElement(Ua,null)),V.createElement(Ko,{accent:r.color.positive,onClick:Ye,disabled:h,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},V.createElement(_F,null)),T&&V.createElement(Ko,{accent:r.color.negative,onClick:()=>k(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},V.createElement(OF,null))),V.createElement(pV,null,V.createElement(uV,{ref:ie,src:s,alt:"Figma design",onLoad:xe,style:{opacity:w?1:0,transition:"opacity 150ms ease-in"}}))):o&&!s&&!t?V.createElement(Wa,null,V.createElement(Va,null,"Figma Design"),V.createElement(Ga,null,V.createElement(Ko,{accent:r.color.secondary,onClick:b,disabled:!p,title:"Change Figma mapping","aria-label":"Change Figma mapping"},V.createElement(Ua,null))),V.createElement(iy,{style:{border:"none",padding:"16px"}},"Figma image unavailable. Try mapping to a specific variant.")):!o&&!i?V.createElement(Wa,null,V.createElement(Va,null,"Figma Design"),V.createElement(Ga,null,V.createElement(Ko,{accent:r.color.secondary,onClick:b,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},V.createElement(Ua,null))),V.createElement(iy,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?V.createElement(Wa,{zoomed:C},V.createElement(Va,null,"Storybook Component"),V.createElement(Ga,null,V.createElement(Ko,{accent:r.color.secondary,onClick:()=>P(ne=>!ne),title:C?"Shrink preview":"Enlarge preview","aria-label":C?"Shrink preview":"Enlarge preview"},C?V.createElement(ry,null):V.createElement(ny,null))),V.createElement(cV,{ref:M,src:a,alt:"Storybook component",onLoad:Pe})):V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):V.createElement(V.Fragment,null,V.createElement($F,{layout:"overlay"},V.createElement(dV,null,s&&a?V.createElement(V.Fragment,null,V.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},V.createElement(gV,{ref:M,src:a,alt:"Storybook component",onLoad:Pe,style:{maxHeight:"150px"}}),N&&V.createElement(fV,{src:s,alt:"Figma design overlay",style:{opacity:L,width:N.width,height:N.height,objectFit:"fill"}})),V.createElement("div",{style:{fontSize:"10px",color:r.color.mediumdark,marginTop:"8px",textAlign:"center"}},V.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",V.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),N&&` \u2022 ${N.width}\xD7${N.height}px`)):V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading Images..."))))),a&&s&&V.createElement(mV,null,V.createElement(hV,null,"Figma Opacity:"),V.createElement(xV,{type:"range",min:"0",max:"1",step:"0.01",value:L,onChange:ne=>R(parseFloat(ne.target.value))}),V.createElement("span",null,Math.round(L*100),"%"))),V.createElement(Hr,{isOpen:f,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:B,onCancel:()=>k(!1)}))};ve();lt();var yV=ds.div({height:"100%"}),ly=ds.div({marginBottom:"20px"}),UF=ds.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"})),jF=ds.span({fontSize:"16px",flexShrink:0}),bV=ds.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})),HF=ds.div({flex:1}),cy=()=>{let{reviewError:e,getCurrentReview:t}=ue(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Js(),{selectedProjectId:s}=lo(),{setCurrentMapping:a}=si(),{currentStoryId:u,currentStoryName:c}=Ze(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:g,screenshotError:p,setFigmaImageDirect:m}=oi(),b=async T=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",T),y.debug("[ReviewPanel] frame.id:",T?.id);let F=yt.getState(),v=F.selectedProjectId,D=F.currentStoryId,_=F.currentStoryName,$=F.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",v),y.debug("[ReviewPanel] currentStoryId (from store):",D),y.debug("[ReviewPanel] currentStoryName (from store):",_),T.thumbnail&&D&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),m(D,T.id,T.thumbnail));try{let L=Y(),R=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!R),y.debug("[ReviewPanel] dashboardUrl:",L),!R||!v||!D){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!R,selectedProjectId:v,currentStoryId:D});return}let h=$?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:v,storyId:D,name:_,figmaNodeId:T.id,figmaFileKey:h});let S=await re(`${L}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`},body:JSON.stringify({projectId:v,storyId:D,name:_,figmaNodeId:T.id,figmaFileKey:h})});if(S.ok){let w=await S.json();w.mapping&&(a(w.mapping),T.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),yt.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",w.mapping))}else{let w=await S.text();y.error("[ReviewPanel] Failed to save mapping:",w)}}catch(L){y.error("[ReviewPanel] Error saving mapping:",L)}};return Jt.createElement(yV,null,Jt.createElement(ly,null,Jt.createElement(Dh,null)),e&&Jt.createElement(UF,null,Jt.createElement(jF,null,"\u26A0\uFE0F"),Jt.createElement(HF,null,e)),p&&Jt.createElement(UF,null,Jt.createElement(jF,null,"\u26A0\uFE0F"),Jt.createElement(HF,null,"Screenshot loading error: ",p)),n?.variantMismatch&&Jt.createElement(bV,null,Jt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Jt.createElement("span",null,Jt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Jt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Jt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Jt.createElement(ly,null,Jt.createElement(ay,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:g})),Jt.createElement(ly,null,Jt.createElement(Zx,null)),Jt.createElement(Zi,{isOpen:r,onClose:o,onSelect:b,figmaFileUrl:i||"",projectId:s||void 0}))};ve();Ne();$e();lt();import{useEffect as WF,useState as SV,useRef as uy,useCallback as wV}from"react";var vV=Y(),kV=2e3;function VF(){let{sessionToken:e,usageData:t,setUsageData:n}=Se(),[r,o]=SV(null),i=uy(null),s=uy(!1),a=uy(0);WF(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=wV(()=>{o(null)},[]);return WF(()=>{if(!e)return;let c=async()=>{let d=Date.now();if(s.current||d-a.current<kV){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=d;try{y.debug("[useBalanceRefresh] Refreshing balance...");let g=await re(`${vV}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(g.ok){let p=await g.json(),m=p.creditBalance,b=i.current;if(b!==null&&m>b){let T=m-b;o({message:`Credits added! +${Math.floor(T)} credit(s)`,previousBalance:b,newBalance:m}),y.debug("[useBalanceRefresh] Credits added:",T)}i.current=m,n(p),y.debug("[useBalanceRefresh] Balance updated:",m)}}catch(g){y.error("[useBalanceRefresh] Failed to refresh:",g)}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();$e();Ne();lt();qf();import{useEffect as CV,useRef as TV}from"react";var IV=300*1e3,GF="uicopilot_feature_flags_fetched_at";function FV(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(GF);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<IV}catch{return!1}}var py=null,EV={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 qF(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ue(),{sessionToken:r,resetAuth:o}=Se(),i=TV(null);CV(()=>{if(!r||r===i.current)return;if(i.current=r,FV()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(py){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${Y()}/api/addon/flags`;py=re(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?EV[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(GF,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{py=null})},[r,e,t])}ve();$e();ln();var LV={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},MV=yr.div`
166
+ `;try{await navigator.clipboard.writeText(G+j),D(!0),setTimeout(()=>D(!1),2e3)}catch(W){y.error("Failed to copy dismissed issues:",W)}};return ze.createElement(AW,null,dt&&ze.createElement(PW,null,ze.createElement(LW,null,"\u{1F4CA} Progress:"),ze.createElement(Kx,{variant:"resolved"},"\u2705 ",dt.resolved," resolved"),ze.createElement(Kx,{variant:"remaining"},"\u23F3 ",dt.remaining," remaining"),dt.newIssues>0&&ze.createElement(Kx,{variant:"new"},"\u{1F195} ",dt.newIssues," new"),ze.createElement(MW,null,"Iteration ",P?.iterationNumber||1)),ze.createElement(Xx,null,ze.createElement(MF,{issues:H,modelId:L,complianceScore:me,visualSimilarity:Pe,costUsd:Ge,reviewDurationMs:re,inputTokens:Te,outputTokens:it,cacheCreationTokens:ne,cacheReadTokens:Be,onToggleSelection:s,onSelectAll:ot,onSelectNone:bn,onSelectAllFixes:br,onGenerateFixes:fe,onApplyFixes:Fe,onApplyFix:q,onCopyAllFixes:je,onDismiss:l,onUndismiss:d,isGenerating:m,isApplying:T,isCopying:I,applyFixesResult:a,onDismissResult:()=>u(null),generationTiming:w,generationUsage:f,hasReviewBeenRun:!!P,isLoadingReview:p,isReviewing:c,generationProgress:A,autoApplySupported:N,selfReview:k})),C.length>0&&ze.createElement(BW,null,ze.createElement(DW,null,ze.createElement(RW,{onClick:()=>b(!h)},ze.createElement("span",null,h?"\u25BC":"\u25B6"),ze.createElement("span",null,"Filtered out"),ze.createElement(NW,null,C.length),ze.createElement(YW,null,R.postAiValidation>0&&ze.createElement("span",null,"\u2699\uFE0F ",R.postAiValidation),R.aiValidation>0&&ze.createElement("span",null,"\u2726 ",R.aiValidation),R.user>0&&ze.createElement("span",null,"\u{1F464} ",R.user))),ze.createElement(zW,{onClick:gt},v?"\u2713 Copied!":"Copy")),h&&ze.createElement(OW,null,(()=>{let O=C.reduce((W,le)=>{let he=GW(le.dismissReason);return W[he]||(W[he]=[]),W[he].push(le),W},{}),j=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(O).sort((W,le)=>j.indexOf(W)-j.indexOf(le)).map(W=>ze.createElement(ze.Fragment,{key:W},ze.createElement(WW,null,W,ze.createElement(VW,null,O[W].length)),O[W].map(le=>ze.createElement(_W,{key:le.id},ze.createElement($W,null,ze.createElement(qW,{phase:le.dismissedBy||Qx(le.dismissReason)||"post-ai-validation"},KW(le.dismissedBy,le.dismissReason)," ",DF(le.dismissedBy,le.dismissReason)),ze.createElement(UW,{onClick:()=>d(le.id),title:"Restore to active issues"},"\u21A9 Restore")),ze.createElement(jW,null,"[",le.severity.toUpperCase(),"]"," ",le.title||le.description),le.dismissReason&&(()=>{let{categoryId:he,note:Rn}=RF(le.dismissReason),vt=he?hu[he]:null;return ze.createElement(HW,null,vt?ze.createElement(ze.Fragment,null,vt.icon," ",vt.label,Rn?` \u2014 ${Rn}`:""):BF(le.dismissReason))})()))))})())))};var tV=_a.div({marginTop:"20px"}),nV=_a.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),rV=_a.div({display:"flex",alignItems:"center"}),Jx=_a(Co)({padding:"10px 16px"}),oV=_a.div({minHeight:"200px"}),Zx=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ue(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return eV(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),zr.createElement(tV,null,zr.createElement(nV,null,zr.createElement(rV,null,a&&zr.createElement(Jx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&zr.createElement(Jx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),zr.createElement(Jx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),zr.createElement(oV,null,a&&e==="chat"&&(u?zr.createElement(_I,null):zr.createElement(Nx,null)),e==="issues"&&zr.createElement(zF,null),a&&e==="prompt"&&zr.createElement(zx,null)))};ve();import V,{useState as yo,useRef as oy,useEffect as lV,useMemo as cV}from"react";import{styled as Tt,useTheme as uV}from"storybook/theming";$e();Ne();var xu={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},$a="uicopilot_feature_flags";function ey(){try{let e=localStorage.getItem($a);if(e){let t=JSON.parse(e);return{...xu,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return xu}function iV(e,t){try{let r={...ey(),[e]:t},o={};for(let i in r){let s=i;r[s]!==xu[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem($a,JSON.stringify(o)):localStorage.removeItem($a),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function sV(){try{localStorage.removeItem($a),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function ty(e){return ey()[e]}function aV(){let e=Object.keys(xu).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem($a,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:ey,set:iV,reset:sV,enableAll:aV,isEnabled:ty}});Ne();lt();import Mt from"react";var NF=()=>Mt.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"},Mt.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Mt.createElement("circle",{cx:"12",cy:"12",r:"3"}));var Ua={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"},ja=()=>Mt.createElement("svg",{...Ua},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),OF=()=>Mt.createElement("svg",{...Ua},Mt.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Mt.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Mt.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Mt.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Mt.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Mt.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),_F=()=>Mt.createElement("svg",{...Ua},Mt.createElement("polyline",{points:"23 4 23 10 17 10"}),Mt.createElement("polyline",{points:"1 20 1 14 7 14"}),Mt.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"})),ny=()=>Mt.createElement("svg",{...Ua},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"})),ry=()=>Mt.createElement("svg",{...Ua},Mt.createElement("circle",{cx:"11",cy:"11",r:"8"}),Mt.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Mt.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"}));var Ha=Tt.div({marginTop:"20px"}),yu=Tt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),bu=Tt.div({display:"flex",alignItems:"center",gap:"12px"}),Wa=Tt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),dhe=Tt.div({display:"flex",gap:"8px"}),ghe=Tt.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}})),$F=Tt.div(({theme:e,layout:t})=>({display:t==="side-by-side"?"grid":"flex",gridTemplateColumns:t==="side-by-side"?"minmax(0, 1fr) minmax(0, 1fr)":void 0,gap:t==="side-by-side"?`${e.layoutMargin}px`:0,position:"relative",width:"100%",justifyContent:t==="overlay"?"center":void 0})),Va=Tt.div(({theme:e,zoomed:t})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,overflow:"hidden",backgroundColor:e.background.app,minHeight:"60px",maxHeight:t?"400px":"150px",display:"flex",alignItems:"center",justifyContent:"center",transition:"max-height 0.2s ease, box-shadow 0.2s ease",boxShadow:t?"0 8px 30px rgba(0, 0, 0, 0.15)":"none","& img":t?{maxWidth:"100%",maxHeight:"400px"}:void 0})),Ga=Tt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.92)":"rgba(0, 0, 0, 0.7)",color:e.base==="dark"?"#0a0a0f":e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),qa=Tt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),Xo=Tt.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"}})),pV=Tt.img(({opacity:e=1})=>({maxWidth:"150px",maxHeight:"150px",height:"auto",display:"block",objectFit:"contain",opacity:e})),dV=Tt.img({display:"block",objectFit:"contain",maxHeight:"150px",maxWidth:"150px"}),gV=Tt.div({position:"relative",display:"inline-block",maxHeight:"150px",overflow:"hidden"}),fhe=Tt.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"}})),fV=Tt.div({position:"relative",display:"inline-block"}),mhe=Tt.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})),mV=Tt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),hV=Tt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),xV=Tt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),yV=Tt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),bV=Tt.input({flex:1}),iy=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),hhe=Tt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),sy=Tt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),yi=Tt.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%"}}})),bi=Tt.div({textAlign:"center",zIndex:1}),Si=Tt.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)"}}})),wi=Tt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),ay=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=uV(),{currentMapping:o,loadingMapping:i}=Ze(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:d,currentReviewId:g}=ue(),{selectedProjectId:p}=Xe(),{sessionToken:h}=Se(),{openComponentBrowser:b}=ea(),{hasMapping:I,deleteMapping:F,setCurrentMapping:v}=ai(),D=ty("enableHoverHighlight"),[N,$]=yo("side-by-side"),[M,z]=yo(.5),[m,S]=yo(!1),[w,A]=yo(!1),[f,k]=yo(!1),[E,x]=yo(!1),[T,P]=yo(!1),B=async()=>{k(!1);try{let re=o?.id;re&&await F(re),v(null)}catch(re){y.error("[ScreenshotComparison] Failed to unlink:",re)}};lV(()=>{A(!1)},[s]);let[_,C]=yo(null),[R,H]=yo(null),L=oy(null),ie=oy(null),K=oy(null),se=cV(()=>{if(!D||!l||!g)return null;let re=d.find(Te=>Te.id===g);return re?.issues&&re.issues.find(Te=>Te.id===l)||null},[l,g,d]),me=re=>{let Te=re.currentTarget;A(!0),!yt.getState().figmaDimensions&&Te.naturalWidth&&Te.naturalHeight&&yt.getState().setFigmaDimensions({width:Te.naturalWidth,height:Te.naturalHeight}),requestAnimationFrame(()=>{if(ie.current){let{clientWidth:ne,clientHeight:Be}=ie.current;ne&&Be&&H({width:ne,height:Be})}})},Pe=()=>{requestAnimationFrame(()=>{if(L.current){let{clientWidth:re,clientHeight:Te}=L.current;re&&Te&&C({width:re,height:Te})}})},Ge=async()=>{if(!(!p||!h)){S(!0);try{let re=Y();await oe(`${re}/api/figma/frames/invalidate?projectId=${p}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},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{S(!1)}}};return e?V.createElement(Ha,null,V.createElement(yu,null,V.createElement(bu,null,V.createElement(Wa,null,"Screenshots from this review"))),V.createElement(sy,null,V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading Figma..."))),V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading Storybook..."))))):!s&&!a&&!o?i?V.createElement(Ha,null,V.createElement(yu,null,V.createElement(bu,null,V.createElement(Wa,null,"Screenshots from this review"))),V.createElement(sy,null,V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading..."))))):V.createElement(Ha,null,V.createElement(Wa,null,"Screenshots from this review"),V.createElement(Va,null,V.createElement(Ga,null,"Figma Design"),V.createElement(qa,null,V.createElement(Xo,{accent:r.color.secondary,onClick:b,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},V.createElement(ja,null))),V.createElement(iy,{style:{border:"none",padding:"20px 16px",lineHeight:"1.6"}},V.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u2728 This story isn't linked to a Figma frame yet"),V.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the \u{1F50D} above to browse your Figma file and pick a matching frame. Once linked, run a Review to compare your code with the design.")))):!s&&!a?V.createElement(Ha,null,V.createElement(yu,null,V.createElement(bu,null,V.createElement(Wa,null,"Screenshots from this review"))),V.createElement(sy,null,V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading..."))))):V.createElement(Ha,{ref:K},V.createElement(yu,null,V.createElement(bu,null,V.createElement(Wa,null,"Screenshots from this review"))),N==="side-by-side"?V.createElement($F,{layout:"side-by-side"},o&&s&&!t?V.createElement(Va,{zoomed:E},V.createElement(Ga,null,"Figma Design"),V.createElement(qa,null,V.createElement(Xo,{accent:r.color.secondary,onClick:()=>x(re=>!re),title:E?"Shrink preview":"Enlarge preview","aria-label":E?"Shrink preview":"Enlarge preview"},E?V.createElement(ry,null):V.createElement(ny,null)),I&&V.createElement(Xo,{accent:r.color.secondary,onClick:b,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},V.createElement(ja,null)),V.createElement(Xo,{accent:r.color.positive,onClick:Ge,disabled:m,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},V.createElement(_F,null)),I&&V.createElement(Xo,{accent:r.color.negative,onClick:()=>k(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},V.createElement(OF,null))),V.createElement(gV,null,V.createElement(dV,{ref:ie,src:s,alt:"Figma design",onLoad:me,style:{opacity:w?1:0,transition:"opacity 150ms ease-in"}}))):o&&!s&&!t?V.createElement(Va,null,V.createElement(Ga,null,"Figma Design"),V.createElement(qa,null,V.createElement(Xo,{accent:r.color.secondary,onClick:b,disabled:!p,title:"Change Figma mapping","aria-label":"Change Figma mapping"},V.createElement(ja,null))),V.createElement(iy,{style:{border:"none",padding:"16px"}},"Figma image unavailable. Try mapping to a specific variant.")):!o&&!i?V.createElement(Va,null,V.createElement(Ga,null,"Figma Design"),V.createElement(qa,null,V.createElement(Xo,{accent:r.color.secondary,onClick:b,disabled:!p,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},V.createElement(ja,null))),V.createElement(iy,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?V.createElement(Va,{zoomed:T},V.createElement(Ga,null,"Storybook Component"),V.createElement(qa,null,V.createElement(Xo,{accent:r.color.secondary,onClick:()=>P(re=>!re),title:T?"Shrink preview":"Enlarge preview","aria-label":T?"Shrink preview":"Enlarge preview"},T?V.createElement(ry,null):V.createElement(ny,null))),V.createElement(pV,{ref:L,src:a,alt:"Storybook component",onLoad:Pe})):V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):V.createElement(V.Fragment,null,V.createElement($F,{layout:"overlay"},V.createElement(fV,null,s&&a?V.createElement(V.Fragment,null,V.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},V.createElement(mV,{ref:L,src:a,alt:"Storybook component",onLoad:Pe,style:{maxHeight:"150px"}}),_&&V.createElement(hV,{src:s,alt:"Figma design overlay",style:{opacity:M,width:_.width,height:_.height,objectFit:"fill"}})),V.createElement("div",{style:{fontSize:"10px",color:r.color.mediumdark,marginTop:"8px",textAlign:"center"}},V.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",V.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),_&&` \u2022 ${_.width}\xD7${_.height}px`)):V.createElement(yi,null,V.createElement(bi,null,V.createElement(Si,null),V.createElement(wi,null,"Loading Images..."))))),a&&s&&V.createElement(xV,null,V.createElement(yV,null,"Figma Opacity:"),V.createElement(bV,{type:"range",min:"0",max:"1",step:"0.01",value:M,onChange:re=>z(parseFloat(re.target.value))}),V.createElement("span",null,Math.round(M*100),"%"))),V.createElement(Hr,{isOpen:f,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:B,onCancel:()=>k(!1)}))};ve();lt();var SV=fs.div({height:"100%"}),ly=fs.div({marginBottom:"20px"}),UF=fs.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"})),jF=fs.span({fontSize:"16px",flexShrink:0}),wV=fs.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})),HF=fs.div({flex:1}),cy=()=>{let{reviewError:e,getCurrentReview:t}=ue(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=ea(),{selectedProjectId:s}=co(),{setCurrentMapping:a}=ai(),{currentStoryId:u,currentStoryName:c}=Ze(),{isLoadingScreenshots:l,isLoadingFigma:d,isLoadingStorybook:g,screenshotError:p,setFigmaImageDirect:h}=ii(),b=async I=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",I),y.debug("[ReviewPanel] frame.id:",I?.id);let F=yt.getState(),v=F.selectedProjectId,D=F.currentStoryId,N=F.currentStoryName,$=F.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",v),y.debug("[ReviewPanel] currentStoryId (from store):",D),y.debug("[ReviewPanel] currentStoryName (from store):",N),I.thumbnail&&D&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),h(D,I.id,I.thumbnail));try{let M=Y(),z=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!z),y.debug("[ReviewPanel] dashboardUrl:",M),!z||!v||!D){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!z,selectedProjectId:v,currentStoryId:D});return}let m=$?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:v,storyId:D,name:N,figmaNodeId:I.id,figmaFileKey:m});let S=await oe(`${M}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:v,storyId:D,name:N,figmaNodeId:I.id,figmaFileKey:m})});if(S.ok){let w=await S.json();w.mapping&&(a(w.mapping),I.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),yt.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",w.mapping))}else{let w=await S.text();y.error("[ReviewPanel] Failed to save mapping:",w)}}catch(M){y.error("[ReviewPanel] Error saving mapping:",M)}};return Jt.createElement(SV,null,Jt.createElement(ly,null,Jt.createElement(Dh,null)),e&&Jt.createElement(UF,null,Jt.createElement(jF,null,"\u26A0\uFE0F"),Jt.createElement(HF,null,e)),p&&Jt.createElement(UF,null,Jt.createElement(jF,null,"\u26A0\uFE0F"),Jt.createElement(HF,null,"Screenshot loading error: ",p)),n?.variantMismatch&&Jt.createElement(wV,null,Jt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),Jt.createElement("span",null,Jt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",Jt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",Jt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),Jt.createElement(ly,null,Jt.createElement(ay,{isLoading:l,isLoadingFigma:d,isLoadingStorybook:g})),Jt.createElement(ly,null,Jt.createElement(Zx,null)),Jt.createElement(Zi,{isOpen:r,onClose:o,onSelect:b,figmaFileUrl:i||"",projectId:s||void 0}))};ve();Ne();$e();lt();import{useEffect as WF,useState as vV,useRef as uy,useCallback as kV}from"react";var CV=Y(),TV=2e3;function VF(){let{sessionToken:e,usageData:t,setUsageData:n}=Se(),[r,o]=vV(null),i=uy(null),s=uy(!1),a=uy(0);WF(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=kV(()=>{o(null)},[]);return WF(()=>{if(!e)return;let c=async()=>{let d=Date.now();if(s.current||d-a.current<TV){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=d;try{y.debug("[useBalanceRefresh] Refreshing balance...");let g=await oe(`${CV}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(g.ok){let p=await g.json(),h=p.creditBalance,b=i.current;if(b!==null&&h>b){let I=h-b;o({message:`Credits added! +${Math.floor(I)} credit(s)`,previousBalance:b,newBalance:h}),y.debug("[useBalanceRefresh] Credits added:",I)}i.current=h,n(p),y.debug("[useBalanceRefresh] Balance updated:",h)}}catch(g){y.error("[useBalanceRefresh] Failed to refresh:",g)}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();$e();Ne();lt();qf();import{useEffect as IV,useRef as FV}from"react";var EV=300*1e3,GF="uicopilot_feature_flags_fetched_at";function AV(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(GF);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<EV}catch{return!1}}var py=null,PV={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 qF(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ue(),{sessionToken:r,resetAuth:o}=Se(),i=FV(null);IV(()=>{if(!r||r===i.current)return;if(i.current=r,AV()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(py){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${Y()}/api/addon/flags`;py=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?PV[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(GF,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{py=null})},[r,e,t])}ve();$e();ln();var BV={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},DV=yr.div`
167
167
  position: fixed;
168
168
  top: 16px;
169
169
  right: 16px;
170
- background: ${({variant:e})=>LV[e||"success"]};
170
+ background: ${({variant:e})=>BV[e||"success"]};
171
171
  color: white;
172
172
  padding: 12px 20px;
173
173
  border-radius: 8px;
@@ -187,12 +187,12 @@ ${"=".repeat(40)}
187
187
  opacity: 1;
188
188
  }
189
189
  }
190
- `,BV=yr.span`
190
+ `,RV=yr.span`
191
191
  font-size: 20px;
192
- `,DV=yr.span`
192
+ `,zV=yr.span`
193
193
  font-weight: 500;
194
194
  font-size: 14px;
195
- `,RV=yr.button`
195
+ `,NV=yr.button`
196
196
  background: rgba(255, 255, 255, 0.2);
197
197
  border: none;
198
198
  color: white;
@@ -208,15 +208,15 @@ ${"=".repeat(40)}
208
208
  &:hover {
209
209
  background: rgba(255, 255, 255, 0.3);
210
210
  }
211
- `,zV=yr.div`
211
+ `,OV=yr.div`
212
212
  padding: 8px 16px;
213
213
  border-top: 1px solid ${({theme:e})=>e.appBorderColor};
214
214
  font-size: 11px;
215
215
  color: ${({theme:e})=>e.color.mediumdark};
216
216
  text-align: center;
217
217
  opacity: 0.7;
218
- `,NV=yr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),OV=yr.div({fontSize:"32px"}),_V=yr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),$V=yr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),YF=yr.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})),KF=yr.span({flex:1}),XF=yr.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`}})),QF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Xe(),{isConnected:r,sessionToken:o,authError:i}=Se(),{currentStoryId:s}=Ze(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ue(),[g,p]=AV(!1),m=()=>{l(null),o&&fetch(`${Y()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(L=>L.json()).then(L=>{d({enableFixGeneration:!!L.enableFixGeneration,enableFixApply:!!L.enableFixApply,enableAutoMap:!!L.enableAutoMap,enableReviewBadges:!!L.enableReviewBadges,showCosts:!!L.showCosts,enableParallelReview:!!L.enableParallelReview,enableModelSelection:!!L.enableModelSelection})}).catch(()=>{})};Lm(),Ym(),qF(),$m(),Nm();let{notification:b,dismissNotification:T}=VF();PV(()=>{if(b){let L=setTimeout(T,5e3);return()=>clearTimeout(L)}},[b,T]);let F=t.find(L=>L.id===e),v=r&&!!e&&!!F,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:_}=Ze(),$=v&&!!s&&!a&&_;return zt.createElement(Au,{header:zt.createElement(Pu,{toolbar:zt.createElement(tm,{onOpenSettings:()=>p(!0)})}),footer:zt.createElement(zV,null,Et.NAME," v","0.5.39")},b&&zt.createElement(MV,{variant:b.variant||"success"},zt.createElement(BV,null,b.variant==="error"?"!":b.variant==="warning"?"\u26A0":"+"),zt.createElement(DV,null,b.message),zt.createElement(RV,{onClick:T},"x")),i&&zt.createElement(YF,null,zt.createElement("span",null,"\u26A0"),zt.createElement(KF,null,i),zt.createElement(XF,{onClick:()=>p(!0)},"Reconnect")),u==="admin"&&c&&zt.createElement(YF,null,zt.createElement("span",null,"\u{1F441}"),zt.createElement(KF,null,"Previewing as ",c),zt.createElement(XF,{onClick:m},"Exit preview")),D||$?zt.createElement(du,{label:D?"Loading...":"Loading review..."}):v?zt.createElement(cy,null):zt.createElement(NV,null,zt.createElement(OV,null,"\u2699"),zt.createElement(_V,null,i?"Connection issue":`Set up ${Et.NAME}`),zt.createElement($V,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),zt.createElement(on,{onClick:()=>p(!0)},i?"Reconnect":"Open Settings")),g&&zt.createElement(y1,{onClose:()=>p(!1)}))};import JF,{useCallback as UV}from"react";import{useStorybookApi as jV}from"storybook/manager-api";import{IconButton as HV}from"storybook/internal/components";var WV="uireview",VV=`${WV}/panel`,ZF=()=>{let e=jV(),t=UV(()=>{e.togglePanel(!0),e.setSelectedPanel(VV)},[e]);return JF.createElement(HV,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},JF.createElement(NF,null))};ve();import Yt,{useState as Xa,useCallback as rE,useEffect as my}from"react";import{styled as bo,useTheme as n9}from"storybook/theming";import{addons as vu}from"storybook/manager-api";$e();Ne();import{addons as QV,experimental_getStatusStore as wu}from"storybook/manager-api";async function eE(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}$e();Ne();var GV=Y(),qV="uireview/badge";async function YV(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 KV(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:g}=await e.read();if(d)break;if(t()){e.cancel();break}r+=n.decode(g,{stream:!0});let p=r.split(`
219
- `);r=p.pop()||"";for(let m of p)if(m.startsWith("data: "))try{let b=JSON.parse(m.slice(6));if(b.type==="complete"){o=b.complianceScore??b.validation?.complianceScore??null;let F=(b.issues||[]).filter(v=>!v.dismissed);i=F.filter(v=>v.severity==="critical").length,s=F.filter(v=>v.severity==="major").length,a=F.filter(v=>v.severity==="minor").length,u=b.costUsd||0,c=b.inputTokens||0,l=b.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function Su(e,t,n,r,o){e&&e.set([{value:n,typeId:qV,storyId:t,title:r,description:o}])}async function XV(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 tE(e,t,n,r,o,i){Su(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await XV(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await YV(`${GV}/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 KV(u,i),{score:l,criticalCount:d,majorCount:g,minorCount:p,costUsd:m,inputTokens:b,outputTokens:T}=c;if(l!==null){let F=d>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",v=[`Score: ${l}`];d>0&&v.push(`${d} critical`),g>0&&v.push(`${g} major`),p>0&&v.push(`${p} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return Su(o,e.storyId,F,D,v.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:m,inputTokens:b,outputTokens:T}}return Su(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 Su(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var JV=Y(),qa="uireview/badge";function nE(){let e=!1,t=!1;try{let n=QV.getChannel();n.on(gy,async()=>{if(!t){t=!0,e=!1;try{await t9(n,()=>e)}finally{t=!1}}}),n.on(fy,()=>{e=!0})}catch{}}async function dy(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${JV}/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 ZV(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function ZV(e){try{if(typeof wu!="function")return;let t=wu(qa);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[qa]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[qa];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:qa,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 e9(){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 t9(e,t){let n=await dy();if(n.length===0){e.emit(Ka,{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-6";try{let b=localStorage.getItem("uicopilot_selected_models");if(b){let T=JSON.parse(b);Array.isArray(T)&&T.length>0&&(i=T[0])}}catch{}let s=null;try{typeof wu=="function"&&(s=wu(qa))}catch{}let a=e9(),u=0,c=0,l=0,d=0,g=0,p=0;e.emit(Ya,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let m=n.map(b=>()=>tE(b,r,o,i,s,t));await eE(m,a,(b,T)=>{if(T&&typeof T=="object"&&"score"in T){let F=T;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,d+=F.costUsd||0,g+=F.inputTokens||0,p+=F.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${b+1}/${n.length} done:`,n[b].storyName,T),e.emit(Ya,{total:n.length,completed:u+c+l,currentStoryName:n[b].storyName})},t),e.emit(Ka,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:g,outputTokens:p})}var r9=bo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),o9=bo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),i9=bo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),oE=bo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),iE=bo.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}})),s9=bo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),a9=bo.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),sE=bo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),gs=bo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),gy="uireview/review-all-start",fy="uireview/review-all-cancel",Ya="uireview/review-all-progress",Ka="uireview/review-all-complete";function aE(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var lE=()=>{let[e,t]=Xa(!1),[n,r]=Xa(null),[o,i]=Xa(null),[s,a]=Xa(null),[u,c]=Xa(aE);my(()=>{let m=()=>c(aE()),b=setInterval(m,2e3);return window.addEventListener("storage",m),()=>{clearInterval(b),window.removeEventListener("storage",m)}},[]),my(()=>{let m=()=>{dy().then(v=>{a(v.length)}).catch(()=>{})},b=setTimeout(m,3e3),T=null;try{T=vu.getChannel(),T.on("storyChanged",m),T.on("uireview/mappings-changed",m)}catch{}let F=setInterval(m,6e4);return()=>{clearTimeout(b),clearInterval(F),T&&(T.off("storyChanged",m),T.off("uireview/mappings-changed",m))}},[]),my(()=>{let m;try{m=vu.getChannel()}catch{return}let b=F=>{r(F),t(!0)},T=F=>{t(!1),r(null),i({total:F.total,passed:F.passed,failed:F.failed,warned:F.warnCount||0,costUsd:F.costUsd||0})};return m.on(Ya,b),m.on(Ka,T),()=>{m.off(Ya,b),m.off(Ka,T)}},[]);let l=rE(()=>{try{vu.getChannel().emit(gy),t(!0),i(null)}catch{}},[]),d=rE(()=>{try{vu.getChannel().emit(fy)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,p=n9();return u?Yt.createElement(r9,null,Yt.createElement(o9,null,Yt.createElement(i9,null,"UI Review"),e?Yt.createElement(iE,{running:!0,onClick:d},"Cancel"):Yt.createElement(iE,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Yt.createElement(Yt.Fragment,null,Yt.createElement(sE,null,Yt.createElement(gs,{dotColor:p.color.positive},"Pass (",o.passed,")"),Yt.createElement(gs,{dotColor:p.color.warning},"Warn (",o.warned,")"),Yt.createElement(gs,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Yt.createElement(oE,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Yt.createElement(sE,null,Yt.createElement(gs,{dotColor:p.color.positive},"Pass"),Yt.createElement(gs,{dotColor:p.color.warning},"Warn"),Yt.createElement(gs,{dotColor:p.color.negative},"Fail")),e&&n&&Yt.createElement(Yt.Fragment,null,Yt.createElement(s9,null,Yt.createElement(a9,{percent:g})),Yt.createElement(oE,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as uE from"@sentry/react";var l9="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",cE=!1;function c9(){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 pE(){if(!cE){cE=!0;try{uE.init({dsn:l9,environment:c9(),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{}}}pE();var Cu="uireview",p9=`${Cu}/panel`,d9=`${Cu}/tool`,dE=`${Cu}/test-provider`;ku.register(Cu,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof xy=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=xy("uireview/badge");ek(t);let n=xy("uireview/mapped");rk(n),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");ku.add(d9,{type:hy.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Qa.createElement(ZF,null)}),nE(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&ku.add(dE,{type:hy.experimental_TEST_PROVIDER,id:dE,render:()=>Qa.createElement(lE,null)}),ku.add(p9,{type:hy.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Qa.createElement(u9,{active:t||!1},Qa.createElement(Jf,null,Qa.createElement(QF,null)))})});
218
+ `,_V=yr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),$V=yr.div({fontSize:"32px"}),UV=yr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),jV=yr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),YF=yr.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})),KF=yr.span({flex:1}),XF=yr.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`}})),QF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Xe(),{isConnected:r,sessionToken:o,authError:i}=Se(),{currentStoryId:s}=Ze(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ue(),[g,p]=LV(!1),h=()=>{l(null),o&&fetch(`${Y()}/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(()=>{})};Lm(),Ym(),qF(),$m(),Nm();let{notification:b,dismissNotification:I}=VF();MV(()=>{if(b){let M=setTimeout(I,5e3);return()=>clearTimeout(M)}},[b,I]);let F=t.find(M=>M.id===e),v=r&&!!e&&!!F,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:N}=Ze(),$=v&&!!s&&!a&&N;return zt.createElement(Au,{header:zt.createElement(Pu,{toolbar:zt.createElement(tm,{onOpenSettings:()=>p(!0)})}),footer:zt.createElement(OV,null,Et.NAME," v","0.5.40")},b&&zt.createElement(DV,{variant:b.variant||"success"},zt.createElement(RV,null,b.variant==="error"?"!":b.variant==="warning"?"\u26A0":"+"),zt.createElement(zV,null,b.message),zt.createElement(NV,{onClick:I},"x")),i&&zt.createElement(YF,null,zt.createElement("span",null,"\u26A0"),zt.createElement(KF,null,i),zt.createElement(XF,{onClick:()=>p(!0)},"Reconnect")),u==="admin"&&c&&zt.createElement(YF,null,zt.createElement("span",null,"\u{1F441}"),zt.createElement(KF,null,"Previewing as ",c),zt.createElement(XF,{onClick:h},"Exit preview")),D||$?zt.createElement(du,{label:D?"Loading...":"Loading review..."}):v?zt.createElement(cy,null):zt.createElement(_V,null,zt.createElement($V,null,"\u2699"),zt.createElement(UV,null,i?"Connection issue":`Set up ${Et.NAME}`),zt.createElement(jV,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),zt.createElement(on,{onClick:()=>p(!0)},i?"Reconnect":"Open Settings")),g&&zt.createElement(y1,{onClose:()=>p(!1)}))};import JF,{useCallback as HV}from"react";import{useStorybookApi as WV}from"storybook/manager-api";import{IconButton as VV}from"storybook/internal/components";var GV="uireview",qV=`${GV}/panel`,ZF=()=>{let e=WV(),t=HV(()=>{e.togglePanel(!0),e.setSelectedPanel(qV)},[e]);return JF.createElement(VV,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},JF.createElement(NF,null))};ve();import Yt,{useState as Qa,useCallback as rE,useEffect as my}from"react";import{styled as bo,useTheme as o9}from"storybook/theming";import{addons as vu}from"storybook/manager-api";$e();Ne();import{addons as ZV,experimental_getStatusStore as wu}from"storybook/manager-api";async function eE(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}$e();Ne();var YV=Y(),KV="uireview/badge";async function XV(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 QV(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:g}=await e.read();if(d)break;if(t()){e.cancel();break}r+=n.decode(g,{stream:!0});let p=r.split(`
219
+ `);r=p.pop()||"";for(let h of p)if(h.startsWith("data: "))try{let b=JSON.parse(h.slice(6));if(b.type==="complete"){o=b.complianceScore??b.validation?.complianceScore??null;let F=(b.issues||[]).filter(v=>!v.dismissed);i=F.filter(v=>v.severity==="critical").length,s=F.filter(v=>v.severity==="major").length,a=F.filter(v=>v.severity==="minor").length,u=b.costUsd||0,c=b.inputTokens||0,l=b.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function Su(e,t,n,r,o){e&&e.set([{value:n,typeId:KV,storyId:t,title:r,description:o}])}async function JV(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 tE(e,t,n,r,o,i){Su(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await JV(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await XV(`${YV}/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 QV(u,i),{score:l,criticalCount:d,majorCount:g,minorCount:p,costUsd:h,inputTokens:b,outputTokens:I}=c;if(l!==null){let F=d>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",v=[`Score: ${l}`];d>0&&v.push(`${d} critical`),g>0&&v.push(`${g} major`),p>0&&v.push(`${p} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return Su(o,e.storyId,F,D,v.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:h,inputTokens:b,outputTokens:I}}return Su(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 Su(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var e9=Y(),Ya="uireview/badge";function nE(){let e=!1,t=!1;try{let n=ZV.getChannel();n.on(gy,async()=>{if(!t){t=!0,e=!1;try{await r9(n,()=>e)}finally{t=!1}}}),n.on(fy,()=>{e=!0})}catch{}}async function dy(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${e9}/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 t9(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function t9(e){try{if(typeof wu!="function")return;let t=wu(Ya);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Ya]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Ya];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Ya,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 n9(){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 r9(e,t){let n=await dy();if(n.length===0){e.emit(Xa,{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-6";try{let b=localStorage.getItem("uicopilot_selected_models");if(b){let I=JSON.parse(b);Array.isArray(I)&&I.length>0&&(i=I[0])}}catch{}let s=null;try{typeof wu=="function"&&(s=wu(Ya))}catch{}let a=n9(),u=0,c=0,l=0,d=0,g=0,p=0;e.emit(Ka,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let h=n.map(b=>()=>tE(b,r,o,i,s,t));await eE(h,a,(b,I)=>{if(I&&typeof I=="object"&&"score"in I){let F=I;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,d+=F.costUsd||0,g+=F.inputTokens||0,p+=F.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${b+1}/${n.length} done:`,n[b].storyName,I),e.emit(Ka,{total:n.length,completed:u+c+l,currentStoryName:n[b].storyName})},t),e.emit(Xa,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:g,outputTokens:p})}var i9=bo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),s9=bo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),a9=bo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),oE=bo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),iE=bo.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}})),l9=bo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),c9=bo.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),sE=bo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),ms=bo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),gy="uireview/review-all-start",fy="uireview/review-all-cancel",Ka="uireview/review-all-progress",Xa="uireview/review-all-complete";function aE(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var lE=()=>{let[e,t]=Qa(!1),[n,r]=Qa(null),[o,i]=Qa(null),[s,a]=Qa(null),[u,c]=Qa(aE);my(()=>{let h=()=>c(aE()),b=setInterval(h,2e3);return window.addEventListener("storage",h),()=>{clearInterval(b),window.removeEventListener("storage",h)}},[]),my(()=>{let h=()=>{dy().then(v=>{a(v.length)}).catch(()=>{})},b=setTimeout(h,3e3),I=null;try{I=vu.getChannel(),I.on("storyChanged",h),I.on("uireview/mappings-changed",h)}catch{}let F=setInterval(h,6e4);return()=>{clearTimeout(b),clearInterval(F),I&&(I.off("storyChanged",h),I.off("uireview/mappings-changed",h))}},[]),my(()=>{let h;try{h=vu.getChannel()}catch{return}let b=F=>{r(F),t(!0)},I=F=>{t(!1),r(null),i({total:F.total,passed:F.passed,failed:F.failed,warned:F.warnCount||0,costUsd:F.costUsd||0})};return h.on(Ka,b),h.on(Xa,I),()=>{h.off(Ka,b),h.off(Xa,I)}},[]);let l=rE(()=>{try{vu.getChannel().emit(gy),t(!0),i(null)}catch{}},[]),d=rE(()=>{try{vu.getChannel().emit(fy)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,p=o9();return u?Yt.createElement(i9,null,Yt.createElement(s9,null,Yt.createElement(a9,null,"UI Review"),e?Yt.createElement(iE,{running:!0,onClick:d},"Cancel"):Yt.createElement(iE,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Yt.createElement(Yt.Fragment,null,Yt.createElement(sE,null,Yt.createElement(ms,{dotColor:p.color.positive},"Pass (",o.passed,")"),Yt.createElement(ms,{dotColor:p.color.warning},"Warn (",o.warned,")"),Yt.createElement(ms,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Yt.createElement(oE,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Yt.createElement(sE,null,Yt.createElement(ms,{dotColor:p.color.positive},"Pass"),Yt.createElement(ms,{dotColor:p.color.warning},"Warn"),Yt.createElement(ms,{dotColor:p.color.negative},"Fail")),e&&n&&Yt.createElement(Yt.Fragment,null,Yt.createElement(l9,null,Yt.createElement(c9,{percent:g})),Yt.createElement(oE,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as uE from"@sentry/react";var u9="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",cE=!1;function p9(){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 pE(){if(!cE){cE=!0;try{uE.init({dsn:u9,environment:p9(),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{}}}pE();var Cu="uireview",g9=`${Cu}/panel`,f9=`${Cu}/tool`,dE=`${Cu}/test-provider`;ku.register(Cu,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof xy=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=xy("uireview/badge");ek(t);let n=xy("uireview/mapped");rk(n),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");ku.add(f9,{type:hy.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Ja.createElement(ZF,null)}),nE(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&ku.add(dE,{type:hy.experimental_TEST_PROVIDER,id:dE,render:()=>Ja.createElement(lE,null)}),ku.add(g9,{type:hy.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Ja.createElement(d9,{active:t||!1},Ja.createElement(Jf,null,Ja.createElement(QF,null)))})});
220
220
  /*! Bundled license information:
221
221
 
222
222
  @noble/hashes/utils.js: