@uicopilot/storybook-addon 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,182 @@
1
+ var BC=Object.create;var ra=Object.defineProperty;var DC=Object.getOwnPropertyDescriptor;var RC=Object.getOwnPropertyNames;var zC=Object.getPrototypeOf,NC=Object.prototype.hasOwnProperty;var OC=(e,t,n)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var tn=(e,t)=>()=>(e&&(t=e(e=0)),t);var On=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xe=(e,t)=>{for(var n in t)ra(e,n,{get:t[n],enumerable:!0})},_C=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of RC(t))!NC.call(e,o)&&o!==n&&ra(e,o,{get:()=>t[o],enumerable:!(r=DC(t,o))||r.enumerable});return e};var oa=(e,t,n)=>(n=e!=null?BC(zC(e)):{},_C(t||!e||!e.__esModule?ra(n,"default",{value:e,enumerable:!0}):n,e));var _n=(e,t,n)=>OC(e,typeof t!="symbol"?t+"":t,n);function Ym(){try{return typeof window<"u"&&localStorage.getItem(HC)==="true"}catch{return!1}}var HC,b,Pe=tn(()=>{"use strict";HC="uicopilot:debug";b={debug:(...e)=>{Ym()&&console.log(...e)},info:(...e)=>{Ym()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import WC,{createContext as VC,useContext as GC,useReducer as qC,useMemo as Km}from"react";function YC(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"RESET_AUTH":return typeof localStorage<"u"&&(localStorage.removeItem("uicopilot_session_token"),localStorage.removeItem("uicopilot_api_key")),b.debug("[AuthContext] resetAuth: Cleared localStorage"),{...e,isConnected:!1,sessionToken:null,apiKey:"",authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null};default:return e}}function Cc({children:e}){let[t,n]=qC(YC,JC),r=Km(()=>({setIsConnected:i=>n({type:"SET_STATE",payload:{isConnected:i}}),setSessionToken:i=>{b.debug("[AuthContext] setSessionToken:",i?i.substring(0,20)+"...":"null"),typeof localStorage<"u"&&(i?localStorage.setItem("uicopilot_session_token",i):localStorage.removeItem("uicopilot_session_token")),n({type:"SET_STATE",payload:{sessionToken:i,isConnected:!!i}})},setApiKey:i=>{typeof localStorage<"u"&&localStorage.setItem("uicopilot_api_key",i),n({type:"SET_STATE",payload:{apiKey:i}})},setAuthMethod:i=>n({type:"SET_STATE",payload:{authMethod:i}}),setDeviceCode:i=>n({type:"SET_STATE",payload:{deviceCode:i}}),setUserCode:i=>n({type:"SET_STATE",payload:{userCode:i}}),setVerificationUri:i=>n({type:"SET_STATE",payload:{verificationUri:i}}),setPollingInterval:i=>n({type:"SET_STATE",payload:{pollingInterval:i}}),setUsageData:i=>n({type:"SET_STATE",payload:{usageData:i,usageLastFetched:Date.now()}}),setAuthError:i=>n({type:"SET_STATE",payload:{authError:i}}),resetAuth:()=>n({type:"RESET_AUTH"})}),[]),o=Km(()=>({...t,...r}),[t,r]);return WC.createElement(Qm.Provider,{value:o},e)}function ze(){let e=GC(Qm);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var KC,XC,QC,Xm,JC,Qm,Tc=tn(()=>{"use strict";Pe();KC=()=>{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"))};KC();XC=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),QC=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",Xm=XC(),JC={isConnected:!!Xm,sessionToken:Xm,apiKey:QC(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},Qm=VC(null)});import ZC,{createContext as e1,useContext as t1,useReducer as n1,useMemo as Jm,useRef as r1,useEffect as o1}from"react";function i1(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 Ic({children:e}){let[t,n]=n1(i1,a1),r=r1(t);o1(()=>{r.current=t},[t]);let o=Jm(()=>({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=Jm(()=>({...t,...o}),[t,o]);return ZC.createElement(Zm.Provider,{value:i},e)}function Ke(){let e=t1(Zm);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var s1,a1,Zm,Fc=tn(()=>{"use strict";s1=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),a1={projects:[],selectedProjectId:s1(),loadingProjects:!1,currentStorybookPath:null},Zm=e1(null)});import l1,{createContext as c1,useContext as u1,useReducer as p1,useMemo as eh}from"react";function d1(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>th)for(let o of r.slice(0,r.length-th))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 Ec({children:e}){let[t,n]=p1(d1,f1),r=eh(()=>({setShowComponentBrowser:i=>n({type:"SET_STATE",payload:{showComponentBrowser:i}}),setFigmaFileUrl:i=>n({type:"SET_STATE",payload:{figmaFileUrl:i}}),setCurrentStoryId:i=>n({type:"SET_STATE",payload:{currentStoryId:i}}),setCurrentStoryName:i=>n({type:"SET_STATE",payload:{currentStoryName:i}}),setCurrentMapping:i=>{n({type:"SET_STATE",payload:{currentMapping:i}})},refreshMappings:()=>n({type:"REFRESH_MAPPINGS"}),setReviewFigmaUrl:i=>n({type:"SET_STATE",payload:{reviewFigmaUrl:i}}),setMappingSource:i=>n({type:"SET_STATE",payload:{mappingSource:i}}),setLoadingMapping:i=>n({type:"SET_STATE",payload:{loadingMapping:i}}),setShowFigmaQuality:i=>n({type:"SET_STATE",payload:{showFigmaQuality:i}}),setFramesCache:i=>n({type:"SET_STATE",payload:{framesCache:i}}),setIsLoadingFrames:i=>n({type:"SET_STATE",payload:{isLoadingFrames:i}}),updateFramesThumbnails:i=>n({type:"UPDATE_FRAMES_THUMBNAILS",payload:i}),setVariantThumbnails:(i,s)=>n({type:"SET_VARIANT_THUMBNAILS",payload:{componentSetId:i,thumbnails:s}}),clearVariantThumbnailsForSet:i=>n({type:"CLEAR_VARIANT_THUMBNAILS_FOR_SET",payload:i}),clearAllVariantThumbnails:()=>n({type:"CLEAR_ALL_VARIANT_THUMBNAILS"})}),[]),o=eh(()=>({...t,...r}),[t,r]);return l1.createElement(nh.Provider,{value:o},e)}function Ge(){let e=u1(nh);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var th,f1,nh,Ac=tn(()=>{"use strict";th=200;f1={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},nh=c1(null)});function Un(e){try{let t=JSON.stringify(e,g1);sessionStorage.setItem(Pc,t)}catch(t){b.error("[SessionStorage] Failed to save review history:",t)}}function rh(){try{let e=sessionStorage.getItem(Pc);if(!e)return[];let t=JSON.parse(e,m1);return Array.isArray(t)?t:[]}catch(e){return b.error("[SessionStorage] Failed to load review history:",e),[]}}function oh(){try{sessionStorage.removeItem(Pc),b.debug("[SessionStorage] Review history cleared")}catch(e){b.error("[SessionStorage] Failed to clear review history:",e)}}function g1(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function m1(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Pc,ih=tn(()=>{"use strict";Pe();Pc="uicopilot_review_history"});import h1,{createContext as x1,useContext as y1,useReducer as b1,useMemo as sh,useRef as S1,useEffect as w1}from"react";function k1(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={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:e.fullPrompt||void 0,aiResponse:e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens},r=e.reviewHistory.findIndex(i=>i.id===t.payload.id),o;return r>=0?o=e.reviewHistory.map((i,s)=>s===r?n:i):o=[...e.reviewHistory,n],Un(o),{...e,reviewResults:t.payload,reviewHistory:o,currentReviewId:t.payload.id}}case"UPDATE_MULTI_MODEL_STREAMING":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload.modelId]:{...e.multiModelResults.byModel[t.payload.modelId],streamingMessages:t.payload.messages}}}}:{...e,multiModelResults:{byModel:{[t.payload.modelId]:{streamingMessages:t.payload.messages}},activeModelId:t.payload.modelId}};case"SET_MODEL_COMPLETED":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload]:{...e.multiModelResults.byModel[t.payload],completed:!0}}}}:e;case"BULK_ADD_REVIEWS":{let n=new Set(e.reviewHistory.map(i=>i.id)),r=t.payload.filter(i=>!n.has(i.id));if(r.length===0)return e;let o=[...e.reviewHistory,...r];return Un(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=[...e.reviewHistory,t.payload];return Un(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 Un(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 Un(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 Un(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 Un(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload.issueId?{...o,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:o)});return Un(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>r.id!==e.currentReviewId?r:{...r,issues:r.issues.map(o=>o.id===t.payload?{...o,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:o)});return Un(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(l=>!l.dismissed),i=o.filter(l=>l.severity==="critical").length,s=o.filter(l=>l.severity==="major").length,u=o.filter(l=>l.severity==="minor").length*1+s*5+i*25,c=Math.max(0,100-u);return b.debug(`[recalculateScore] Active: ${o.length}, score: ${c}`),{...r,complianceScore:c,issuesCount:o.length}});return Un(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 Un(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return oh(),{...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 Lc({children:e}){let[t,n]=b1(k1,C1),r=S1(t);w1(()=>{r.current=t},[t]);let o=sh(()=>({setIsReviewing:s=>n({type:"SET_STATE",payload:{isReviewing:s}}),setReviewError:s=>n({type:"SET_STATE",payload:{reviewError:s}}),bulkAddReviews:s=>n({type:"BULK_ADD_REVIEWS",payload:s}),setReviewResults:s=>n({type:"SET_REVIEW_RESULTS",payload:s}),setMultiModelResults:s=>n({type:"SET_STATE",payload:{multiModelResults:s}}),updateMultiModelStreamingMessages:(s,a)=>n({type:"UPDATE_MULTI_MODEL_STREAMING",payload:{modelId:s,messages:a}}),setModelCompleted:s=>n({type:"SET_MODEL_COMPLETED",payload:s}),setActiveModelId:s=>{let a=r.current;a.multiModelResults&&n({type:"SET_STATE",payload:{multiModelResults:{...a.multiModelResults,activeModelId:s}}})},setShowReviewMenu:s=>n({type:"SET_STATE",payload:{showReviewMenu:s}}),setSeverityFilter:s=>n({type:"SET_STATE",payload:{severityFilter:s}}),setShowStreamingPanel:s=>n({type:"SET_STATE",payload:{showStreamingPanel:s}}),setStreamingPanelCollapsed:s=>n({type:"SET_STATE",payload:{streamingPanelCollapsed:s}}),addStreamingMessage:s=>n({type:"ADD_STREAMING_MESSAGE",payload:s}),updateStreamingMessage:(s,a)=>n({type:"UPDATE_STREAMING_MESSAGE",payload:{index:s,content:a}}),clearStreamingMessages:()=>n({type:"CLEAR_STREAMING_MESSAGES"}),setStreamingProgress:s=>n({type:"SET_STATE",payload:{streamingProgress:s}}),setStreamingStatus:s=>n({type:"SET_STATE",payload:{streamingStatus:s}}),setReviewDetailTab:s=>n({type:"SET_STATE",payload:{reviewDetailTab:s}}),setFullPrompt:s=>n({type:"SET_STATE",payload:{fullPrompt:s}}),setFullResponse:s=>n({type:"SET_STATE",payload:{fullResponse:s}}),setFigmaImageUrl:s=>n({type:"SET_STATE",payload:{figmaImageUrl:s}}),setStorybookImageUrl:s=>n({type:"SET_STATE",payload:{storybookImageUrl:s}}),setFigmaDimensions:s=>n({type:"SET_STATE",payload:{figmaDimensions:s}}),setSelectedModels:s=>n({type:"SET_STATE",payload:{selectedModels:s}}),toggleModel:s=>n({type:"TOGGLE_MODEL",payload:s}),setModelComparisonView:s=>n({type:"SET_STATE",payload:{modelComparisonView:s}}),resetReview:()=>n({type:"RESET_REVIEW"}),addReview:s=>n({type:"ADD_REVIEW",payload:s}),getCurrentReview:()=>{let s=r.current;return s.currentReviewId&&s.reviewHistory.find(a=>a.id===s.currentReviewId)||null},getReviewById:s=>r.current.reviewHistory.find(a=>a.id===s)||null,getParentReview:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return a?.parentReviewId&&s.reviewHistory.find(u=>u.id===a.parentReviewId)||null},hasAppliedFixes:()=>{let s=r.current,a=s.reviewHistory.find(u=>u.id===s.currentReviewId);return!a||!Array.isArray(a.issues)||a.issues.length===0?!1:a.issues.some(u=>u.status==="applied"||u.generatedFix?.status==="applied")},toggleIssueSelection:s=>n({type:"TOGGLE_ISSUE_SELECTION",payload:s}),updateIssueStatus:(s,a,u)=>n({type:"UPDATE_ISSUE_STATUS",payload:{issueId:s,status:a,error:u}}),updateIssueGeneratedFix:(s,a)=>n({type:"UPDATE_ISSUE_GENERATED_FIX",payload:{issueId:s,generatedFix:a}}),batchUpdateIssueGeneratedFixes:s=>n({type:"BATCH_UPDATE_ISSUE_GENERATED_FIXES",payload:s}),dismissIssue:(s,a,u)=>n({type:"DISMISS_ISSUE",payload:{issueId:s,reason:a,dismissedBy:u}}),undismissIssue:s=>n({type:"UNDISMISS_ISSUE",payload:s}),recalculateScore:()=>n({type:"RECALCULATE_SCORE"}),updateReviewScore:(s,a)=>n({type:"UPDATE_REVIEW_SCORE",payload:{reviewId:s,newScore:a}}),clearAllReviews:()=>n({type:"CLEAR_ALL_REVIEWS"}),clearStaleReviewsForStory:s=>n({type:"CLEAR_STALE_REVIEWS",payload:s}),setIsApplying:s=>n({type:"SET_STATE",payload:{isApplying:s}}),setApplyFixesResult:s=>n({type:"SET_STATE",payload:{applyFixesResult:s}}),setIncludeComponentIssues:s=>n({type:"SET_STATE",payload:{includeComponentIssues:s}}),setIncludeTextComparison:s=>n({type:"SET_STATE",payload:{includeTextComparison:s}}),setUsePromptCache:s=>n({type:"SET_STATE",payload:{usePromptCache:s}}),setIsValidating:s=>n({type:"SET_STATE",payload:{isValidating:s}}),setValidationUsage:s=>n({type:"SET_STATE",payload:{validationUsage:s}}),setWorkspacePath:s=>n({type:"SET_STATE",payload:{workspacePath:s}}),triggerScreenshotRefresh:()=>n({type:"TRIGGER_SCREENSHOT_REFRESH"}),setHoveredIssueId:s=>n({type:"SET_STATE",payload:{hoveredIssueId:s}}),setFeatureFlags:s=>n({type:"SET_STATE",payload:{featureFlags:s}}),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=sh(()=>({...t,...o}),[t,o]);return h1.createElement(ah.Provider,{value:i},e)}function ye(){let e=y1(ah);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var v1,C1,ah,Mc=tn(()=>{"use strict";ih();Pe();v1=()=>{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},C1={isReviewing:!1,reviewError:null,reviewResults:null,multiModelResults:null,showReviewMenu:!1,severityFilter:"all",showStreamingPanel:!1,streamingPanelCollapsed:!1,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:"chat",fullPrompt:"",fullResponse:"",figmaImageUrl:null,storybookImageUrl:null,figmaDimensions:null,selectedModels:["claude-haiku-4-5-20251001"],modelComparisonView:"side-by-side",reviewHistory:rh(),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,featureFlags:{enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1},reviewAllConcurrency:v1(),hoveredIssueId:null},ah=x1(null)});import Ni,{useMemo as T1}from"react";function Dc({children:e}){return Ni.createElement(Cc,null,Ni.createElement(Ic,null,Ni.createElement(Ec,null,Ni.createElement(Lc,null,Ni.createElement(I1,null),e))))}function lh(e){let t=ze(),n=Ke(),r=Ge(),o=ye(),i=T1(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function I1(){return Bc=lh(),null}var Bc,st,ch=tn(()=>{"use strict";Tc();Fc();Ac();Mc();Bc=null,st=Object.assign(lh,{getState:()=>{if(!Bc)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Bc}})});var Ae=tn(()=>{"use strict";ch();Tc();Fc();Ac();Mc()});function J(){return(process.env.STORYBOOK_UICOPILOT_URL||F1).replace(/\/$/,"")}var F1,uh,Ue=tn(()=>{"use strict";F1="https://uicopilot-dashboard.vercel.app",uh=3.6});import{useEffect as Ui,useState as ua,useRef as rT,useCallback as zc}from"react";import{addons as Nc}from"storybook/manager-api";function oT(e,t,n){try{sessionStorage.setItem(`${pa}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function iT(e,t){try{let n=sessionStorage.getItem(`${pa}${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(`${pa}${e}`)}catch{}return null}function sT(e){try{let t=sessionStorage.getItem(`${pa}${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 yh,bh,Sh,kh,qo,wh,jn,Oc,pa,vh,ko,ji=tn(()=>{"use strict";Ae();_c();Pe();Ue();yh="storyArgsUpdated",bh="storyRendered",Sh="forceRemount",kh=null,qo=()=>kh,wh=J(),jn=new Map,Oc=null,pa="uicopilot-figma-image-";vh=(e,t,n)=>{Oc=t;let r=jn.get(e);r?r.figmaImageUrl=n:jn.set(e,{storybookImageUrl:null,figmaImageUrl:n}),b.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},ko=()=>{let[e,t]=ua(!1),[n,r]=ua(!1),[o,i]=ua(!1),[s,a]=ua(null),u=rT(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ye(),p=zc(()=>{let z=st.getState().currentStoryId;z&&(b.debug("[useReviewScreenshots] Refreshing screenshots for story:",z),jn.delete(z),u.current=null,i(!0),l())},[l]),f=zc(()=>{let z=st.getState().currentStoryId;if(z){b.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",z);let N=jn.get(z);N&&(N.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:d}=ze(),{selectedProjectId:h}=Ke(),{currentStoryId:S,currentMapping:C}=Ge(),{setStorybookImageUrl:F,setFigmaImageUrl:T}=ye();Ui(()=>{if(!S||st.getState().figmaImageUrl)return;let N=sT(S);N&&(b.debug("[useReviewScreenshots] Quick-restored Figma image for:",S),T(N))},[S,T]),Ui(()=>{(async()=>{if(!d||!h||!S){b.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}let N=st.getState();if(N.storybookImageUrl&&N.figmaImageUrl){b.debug("[useReviewScreenshots] Screenshots already loaded from persisted review, skipping capture"),u.current=S;return}let E=C?.figmaNodeId??null;if(E!==Oc){b.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",S);let I=jn.get(S);I&&(I.figmaImageUrl=null),Oc=E,u.current=null}let M=C?.figmaNodeId;if(M&&!jn.get(S)?.figmaImageUrl){let I=iT(S,M);if(I){b.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",S),T(I);let x=jn.get(S);x?x.figmaImageUrl=I:jn.set(S,{storybookImageUrl:null,figmaImageUrl:I})}}let g=jn.get(S),k=g&&g.storybookImageUrl&&g.figmaImageUrl,w=g&&g.storybookImageUrl&&!g.figmaImageUrl,A=g&&!g.storybookImageUrl&&g.figmaImageUrl;if(k){b.debug("[useReviewScreenshots] Using fully cached screenshots for story:",S),F(g.storybookImageUrl),T(g.figmaImageUrl),u.current=S;return}let m=w&&C?.figmaNodeId;m&&(b.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",S),F(g.storybookImageUrl));let v=A;if(v&&(b.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",S),T(g.figmaImageUrl)),u.current===S&&C?.figmaNodeId){b.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{a(null),m?r(!0):(v||(t(!0),r(!0)),i(!0)),u.current=S;let I=v?g.figmaImageUrl:null,x;if(v)b.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(M){b.debug("[useReviewScreenshots] Found Figma node ID from mapping:",M);let L=null;try{b.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let D=await fetch(`${wh}/api/figma/image?projectId=${h}&nodeId=${M}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`}});if(D.ok){let O=await D.json();L=O.imageUrl||null;let y=O.cached?"(cached)":"(fresh)";b.debug(`[useReviewScreenshots] Figma image fetched ${y}:`,L?"success":"not found")}}catch(D){b.warn("[useReviewScreenshots] Failed to fetch Figma image:",D)}if(L)if(L.includes(".blob.vercel-storage.com")){b.debug("[useReviewScreenshots] Using cached Vercel Blob URL directly (fast)"),I=L,T(L);let O=new Image;O.crossOrigin="anonymous",await new Promise(y=>{O.onload=()=>{x={width:O.naturalWidth,height:O.naturalHeight},b.debug("[useReviewScreenshots] Figma dimensions:",x),y()},O.onerror=()=>y(),O.src=L})}else try{b.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let O=`${wh}/api/proxy/image?url=${encodeURIComponent(L)}`,y=await fetch(O);if(y.ok){let U=await y.blob(),V=new FileReader,B=await new Promise((ee,Q)=>{V.onloadend=()=>ee(V.result),V.onerror=Q,V.readAsDataURL(U)});I=B,T(B),b.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let X=new Image;await new Promise(ee=>{X.onload=()=>{x={width:X.naturalWidth,height:X.naturalHeight},b.debug("[useReviewScreenshots] Figma dimensions:",x),ee()},X.onerror=()=>ee(),X.src=B})}else I=L,T(L),b.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(O){b.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",O),I=L,T(L)}else b.warn("[useReviewScreenshots] No thumbnail found for node:",M),T(null);I&&M&&oT(S,M,I),r(!1)}else b.debug("[useReviewScreenshots] No Figma mapping exists for this component"),T(null),r(!1);let P=g?.storybookImageUrl||null;if(P)b.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{b.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",S);let L=await da({storyId:S,sessionToken:d||void 0,...x&&{figmaWidth:x.width,figmaHeight:x.height}});L?(P=L,F(L),b.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",x||"natural")):b.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}jn.set(S,{storybookImageUrl:P,figmaImageUrl:I}),b.debug("[useReviewScreenshots] Screenshots cached for story:",S)}catch(I){b.error("[useReviewScreenshots] Error loading screenshots:",I),a(I instanceof Error?I.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})()},[d,h,S,C?.figmaNodeId,c]),Ui(()=>{let z=Nc.getChannel(),N=null,E=M=>{kh=M.args,b.debug("[useReviewScreenshots] Args updated for story:",M.storyId,"args:",M.args),N&&clearTimeout(N),N=setTimeout(()=>{b.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),p()},500)};return z.on(yh,E),()=>{z.off(yh,E),N&&clearTimeout(N)}},[p]),Ui(()=>{let z=Nc.getChannel(),N=!1,E=null,M=()=>{b.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),N=!0,i(!0)},g=()=>{N&&(b.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),E&&clearTimeout(E),E=setTimeout(()=>{N=!1,b.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),f()},500))};return z.on(Sh,M),z.on(bh,g),()=>{z.off(Sh,M),z.off(bh,g),E&&clearTimeout(E)}},[f]),Ui(()=>{let z=Nc.getChannel(),N=async E=>{if(!E?.snapshot?.html){b.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}b.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let M=st.getState().currentStoryId,g=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...E.snapshot,storyId:M})});if(g.ok){let k=await g.json();if(k.screenshot){F(k.screenshot);let w=st.getState().currentStoryId;if(w){let A=jn.get(w);A?A.storybookImageUrl=k.screenshot:jn.set(w,{storybookImageUrl:k.screenshot,figmaImageUrl:null})}}}else b.error("[useReviewScreenshots] Snapshot screenshot failed:",await g.text())}catch(M){b.error("[useReviewScreenshots] Snapshot screenshot error:",M)}finally{i(!1)}};return z.on("UICOPILOT/STORY_DOM_MUTATED",N),()=>{z.off("UICOPILOT/STORY_DOM_MUTATED",N)}},[]);let R=zc((z,N,E)=>{b.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),vh(z,N,E),T(E),r(!1),u.current=z},[T]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:p,refreshStorybookOnly:f,setFigmaImageDirect:R}}});function lT(){return!J().startsWith("http://localhost")}function cT(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 Ch(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=cT(o,t,n);return r.set(o,i),i})}async function uT(){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=Ch(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(p=>p.href===c);if(l)try{let p="";for(let f of Array.from(l.cssRules))p+=f.cssText+`
2
+ `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(p)){let f=s.createElement("style");f.textContent=Ch(p,o,r),u.replaceWith(f)}}catch{}})}})).toDataURL("image/png")}function pT(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 dT(e,t){b.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 fetch(`${aT}/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 fT(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 gT(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),b.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=qo();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=fT(a),b.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=pT(s);i+=`&args=${a}`,b.debug("[Screenshot] Using URL with current args:",i)}else b.debug("[Screenshot] No current args, using default URL:",i);return i}async function mT(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return b.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 b.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 da(e){try{let t=e?.storyId||hT();if(t){let n=await mT(t);if(n)return n}if(!lT()){let n=gT(e?.storyId);return await dT(n,{...e,selector:"#storybook-root > *"})}return b.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await uT()}catch(t){throw b.error("Error capturing screenshot:",t),new Error(`Failed to capture screenshot: ${t instanceof Error?t.message:"Unknown error"}`)}}function hT(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var aT,_c=tn(()=>{"use strict";Ue();ji();Pe();aT=J()});function un(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 hn(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 Hi(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Th(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let C=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let T=t.fonts.check(`${F} ${C} Roboto`);if(b.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:T,fontWeight:F,fontSize:C,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(R=>({family:R.family,status:R.status}))}),T)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(C=>C.trim().replace(/['"]/g,"")),p=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],f=[...new Set([...l,...p])];s.font=`${c} ${u} ${a} monospace`;let d=s.measureText(o).width,h="unknown",S=new Map;for(let C of f){s.font=`${c} ${u} ${a} "${C}", monospace`;let F=s.measureText(o).width;if(S.set(C,F),F!==d){s.font=`${c} ${u} ${a} "${C}"`;let T=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let R=s.measureText(o).width;if(Math.abs(T-R)<.1){h=C;break}}}return b.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:h,declaredFonts:l,fontWidths:Array.from(S.entries()),isIframe:t!==document}),h}var Wi=tn(()=>{"use strict";Pe()});function Yo(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 $c(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return b.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:un(n.color),backgroundColor:un(n.backgroundColor),borderColor:un(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:Th(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 Uc(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){b.error("Error extracting declared styles:",r)}return n}var fa=tn(()=>{"use strict";Pe();Wi()});function xT(e){let t=[],n=new Set,r=Ih.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(Ih.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function yT(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:Yo(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Hi(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:un(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function bT(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 p=`${c.tagName}.${o(c)}`;r.has(p)||(r.add(p),n.push(c),i(c,a+1))}}return i(e,0),n}function ST(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,p=n.borderStyle,f=un(n.borderColor),d=s?`${l} ${p} ${f}`:"none";return{selector:Yo(r,i),className:i,border:d,borderRadius:n.borderRadius,backgroundColor:un(n.backgroundColor),gap:n.gap}}function Vi(){b.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=bT(r,2),i=o.map(ST).filter(a=>a!==null);b.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=xT(r);s=a.map(yT),b.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){b.error("[computedStyles] Error extracting text elements:",a)}return{computed:$c(r),declared:Uc(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return b.error("Error extracting computed styles:",e),null}}var Ih,Fh=tn(()=>{"use strict";Pe();Wi();fa();Ih=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function jc(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 kT(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function vT(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=un(n.backgroundColor);hn("backgroundColor",o)||(r.backgroundColor=o);let i=kT(n.borderWidth,n.borderStyle,un(n.borderColor));i&&(r.border=i),hn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),hn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),hn("opacity",n.opacity)||(r.opacity=n.opacity);let s=e.tagName.toLowerCase(),a=["svg","circle","rect","ellipse","line","polyline","polygon","path","text","tspan","g","use","defs","clipPath","mask"];if(e instanceof SVGElement||a.includes(s)){for(let C=0;C<e.attributes.length;C++){let F=e.attributes[C];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let T=F.name.replace(/-([a-z])/g,(z,N)=>N.toUpperCase()),R=F.value.startsWith("rgb")?un(F.value):F.value;T==="d"&&R.length>100?r[T]=R.substring(0,100)+"...":r[T]=R}let d=n.getPropertyValue("fill"),h=n.getPropertyValue("stroke");if(d&&d!=="none"&&(r.fill=d.startsWith("rgb")?un(d):d),h&&h!=="none"&&(r.stroke=h.startsWith("rgb")?un(h):h),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let C=e.getBoundingClientRect();C.width>0&&(r.width=`${Math.round(C.width*100)/100}px`),C.height>0&&(r.height=`${Math.round(C.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=wT.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Hi(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=un(n.color),hn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),hn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let p=jc(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);hn("padding",p)||(r.padding=p);let f=jc(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return hn("margin",f)||(r.margin=f),hn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(hn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),hn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),hn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function Eh(e){let t=1;for(let n of e.children)t+=Eh(n);return t}function Ah(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,p;for(let S of Array.from(o.childNodes))if(S.nodeType===Node.TEXT_NODE){let C=S.textContent?.trim();if(C){p=C.length>50?C.substring(0,50)+"...":C;break}}let f=s;c?f=`${s}#${c}`:u&&(f=Yo(s,u));let d=vT(o),h=[];if(i<t){let S=Array.from(o.children);for(let C of S){let F=C.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let R=(C.ownerDocument.defaultView||window).getComputedStyle(C);R.display==="none"||R.visibility==="hidden"||h.push(n(C,i+1))}}return{selector:f,tagName:s,className:u,id:c,role:l,textContent:p,styles:d,children:h}}b.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return b.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:Eh(r)}),r}function Hc(e=4){b.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(b.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(b.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(b.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(b.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=Ah(r,e);return b.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return b.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var wT,Ph=tn(()=>{"use strict";Pe();Wi();fa();wT=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Wc=tn(()=>{"use strict";Wi();fa();Fh();Ph()});var nx=On((aH,tx)=>{"use strict";tx.exports={compareTwoStrings:ex,findBestMatch:YT};function ex(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 YT(e,t){if(!KT(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=ex(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 KT(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var hx=On(cu=>{"use strict";var mx="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");cu.encode=function(e){if(0<=e&&e<mx.length)return mx[e];throw new TypeError("Must be between 0 and 63: "+e)};cu.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 wx=On(pu=>{"use strict";var xx=hx(),uu=5,yx=1<<uu,bx=yx-1,Sx=yx;function lI(e){return e<0?(-e<<1)+1:(e<<1)+0}function cI(e){var t=(e&1)===1,n=e>>1;return t?-n:n}pu.encode=function(t){var n="",r,o=lI(t);do r=o&bx,o>>>=uu,o>0&&(r|=Sx),n+=xx.encode(r);while(o>0);return n};pu.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=xx.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Sx),u&=bx,i=i+(u<<s),s+=uu}while(a);r.value=cI(i),r.rest=n}});var Ba=On(Vt=>{"use strict";function uI(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}Vt.getArg=uI;var kx=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,pI=/^data:.+\,.+$/;function es(e){var t=e.match(kx);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}Vt.urlParse=es;function ti(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}Vt.urlGenerate=ti;var dI=32;function fI(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>dI&&t.pop(),i}}var du=fI(function(t){var n=t,r=es(t);if(r){if(!r.path)return t;n=r.path}for(var o=Vt.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,ti(r)):n});Vt.normalize=du;function vx(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),ti(n);if(n||t.match(pI))return t;if(r&&!r.host&&!r.path)return r.host=t,ti(r);var o=t.charAt(0)==="/"?t:du(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,ti(r)):o}Vt.join=vx;Vt.isAbsolute=function(e){return e.charAt(0)==="/"||kx.test(e)};function gI(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)}Vt.relative=gI;var Cx=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Tx(e){return e}function mI(e){return Ix(e)?"$"+e:e}Vt.toSetString=Cx?Tx:mI;function hI(e){return Ix(e)?e.slice(1):e}Vt.fromSetString=Cx?Tx:hI;function Ix(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 xI(e,t,n){var r=Pr(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:Pr(e.name,t.name)}Vt.compareByOriginalPositions=xI;function yI(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:Pr(e.name,t.name)}Vt.compareByOriginalPositionsNoSource=yI;function bI(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=Pr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Pr(e.name,t.name)}Vt.compareByGeneratedPositionsDeflated=bI;function SI(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=Pr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Pr(e.name,t.name)}Vt.compareByGeneratedPositionsDeflatedNoLine=SI;function Pr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function wI(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=Pr(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:Pr(e.name,t.name)}Vt.compareByGeneratedPositionsInflated=wI;function kI(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}Vt.parseSourceMapInput=kI;function vI(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=vx(ti(r),t)}return du(t)}Vt.computeSourceURL=vI});var Ex=On(Fx=>{"use strict";var fu=Ba(),gu=Object.prototype.hasOwnProperty,Fo=typeof Map<"u";function Lr(){this._array=[],this._set=Fo?new Map:Object.create(null)}Lr.fromArray=function(t,n){for(var r=new Lr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Lr.prototype.size=function(){return Fo?this._set.size:Object.getOwnPropertyNames(this._set).length};Lr.prototype.add=function(t,n){var r=Fo?t:fu.toSetString(t),o=Fo?this.has(t):gu.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(Fo?this._set.set(t,i):this._set[r]=i)};Lr.prototype.has=function(t){if(Fo)return this._set.has(t);var n=fu.toSetString(t);return gu.call(this._set,n)};Lr.prototype.indexOf=function(t){if(Fo){var n=this._set.get(t);if(n>=0)return n}else{var r=fu.toSetString(t);if(gu.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Lr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Lr.prototype.toArray=function(){return this._array.slice()};Fx.ArraySet=Lr});var Lx=On(Px=>{"use strict";var Ax=Ba();function CI(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||Ax.compareByGeneratedPositionsInflated(e,t)<=0}function Da(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Da.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};Da.prototype.add=function(t){CI(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Da.prototype.toArray=function(){return this._sorted||(this._array.sort(Ax.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};Px.MappingList=Da});var Bx=On(Mx=>{"use strict";var ts=wx(),Ft=Ba(),Ra=Ex().ArraySet,TI=Lx().MappingList;function qn(e){e||(e={}),this._file=Ft.getArg(e,"file",null),this._sourceRoot=Ft.getArg(e,"sourceRoot",null),this._skipValidation=Ft.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Ft.getArg(e,"ignoreInvalidMapping",!1),this._sources=new Ra,this._names=new Ra,this._mappings=new TI,this._sourcesContents=null}qn.prototype._version=3;qn.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new qn(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=Ft.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=Ft.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};qn.prototype.addMapping=function(t){var n=Ft.getArg(t,"generated"),r=Ft.getArg(t,"original",null),o=Ft.getArg(t,"source",null),i=Ft.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}))};qn.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=Ft.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Ft.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Ft.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};qn.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=Ft.relative(i,o));var s=new Ra,a=new Ra;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=Ft.join(r,u.source)),i!=null&&(u.source=Ft.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 p=u.name;p!=null&&!a.has(p)&&a.add(p)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){var c=t.sourceContentFor(u);c!=null&&(r!=null&&(u=Ft.join(r,u)),i!=null&&(u=Ft.relative(i,u)),this.setSourceContent(u,c))},this)};qn.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)}};qn.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,p,f=this._mappings.toArray(),d=0,h=f.length;d<h;d++){if(c=f[d],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(d>0){if(!Ft.compareByGeneratedPositionsInflated(c,f[d-1]))continue;u+=","}u+=ts.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(p=this._sources.indexOf(c.source),u+=ts.encode(p-s),s=p,u+=ts.encode(c.originalLine-1-o),o=c.originalLine-1,u+=ts.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=ts.encode(l-i),i=l)),a+=u}return a};qn.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=Ft.relative(n,r));var o=Ft.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};qn.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};qn.prototype.toString=function(){return JSON.stringify(this.toJSON())};Mx.SourceMapGenerator=qn});var Tw=On((rZ,Cw)=>{"use strict";var Sw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,xN=/\n/g,yN=/^\s*/,bN=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,SN=/^:\s*/,wN=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,kN=/^[;\s]*/,vN=/^\s+|\s+$/g,CN=`
3
+ `,ww="/",kw="*",Oo="",TN="comment",IN="declaration";function FN(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 S=h.match(xN);S&&(n+=S.length);var C=h.lastIndexOf(CN);r=~C?h.length-C:r+h.length}function i(){var h={line:n,column:r};return function(S){return S.position=new s(h),c(),S}}function s(h){this.start=h,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(h){var S=new Error(t.source+":"+n+":"+r+": "+h);if(S.reason=h,S.filename=t.source,S.line=n,S.column=r,S.source=e,!t.silent)throw S}function u(h){var S=h.exec(e);if(S){var C=S[0];return o(C),e=e.slice(C.length),S}}function c(){u(yN)}function l(h){var S;for(h=h||[];S=p();)S!==!1&&h.push(S);return h}function p(){var h=i();if(!(ww!=e.charAt(0)||kw!=e.charAt(1))){for(var S=2;Oo!=e.charAt(S)&&(kw!=e.charAt(S)||ww!=e.charAt(S+1));)++S;if(S+=2,Oo===e.charAt(S-1))return a("End of comment missing");var C=e.slice(2,S-2);return r+=2,o(C),e=e.slice(S),r+=2,h({type:TN,comment:C})}}function f(){var h=i(),S=u(bN);if(S){if(p(),!u(SN))return a("property missing ':'");var C=u(wN),F=h({type:IN,property:vw(S[0].replace(Sw,Oo)),value:C?vw(C[0].replace(Sw,Oo)):Oo});return u(kN),F}}function d(){var h=[];l(h);for(var S;S=f();)S!==!1&&(h.push(S),l(h));return h}return c(),d()}function vw(e){return e?e.replace(vN,Oo):Oo}Cw.exports=FN});var Iw=On(Ds=>{"use strict";var EN=Ds&&Ds.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ds,"__esModule",{value:!0});Ds.default=PN;var AN=EN(Tw());function PN(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,AN.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 Ew=On(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.camelCase=void 0;var LN=/^--[a-zA-Z0-9_-]+$/,MN=/-([a-z])/g,BN=/^[^-]+$/,DN=/^-(webkit|moz|ms|o|khtml)-/,RN=/^-(ms)-/,zN=function(e){return!e||BN.test(e)||LN.test(e)},NN=function(e,t){return t.toUpperCase()},Fw=function(e,t){return"".concat(t,"-")},ON=function(e,t){return t===void 0&&(t={}),zN(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(RN,Fw):e=e.replace(DN,Fw),e.replace(MN,NN))};Bl.camelCase=ON});var Pw=On((Sg,Aw)=>{"use strict";var _N=Sg&&Sg.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},$N=_N(Iw()),UN=Ew();function bg(e,t){var n={};return!e||typeof e!="string"||(0,$N.default)(e,function(r,o){r&&o&&(n[(0,UN.camelCase)(r,t)]=o)}),n}bg.default=bg;Aw.exports=bg});var rv=On((Moe,nv)=>{"use strict";var nc=Object.prototype.hasOwnProperty,tv=Object.prototype.toString,Kk=Object.defineProperty,Xk=Object.getOwnPropertyDescriptor,Qk=function(t){return typeof Array.isArray=="function"?Array.isArray(t):tv.call(t)==="[object Array]"},Jk=function(t){if(!t||tv.call(t)!=="[object Object]")return!1;var n=nc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&nc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||nc.call(t,o)},Zk=function(t,n){Kk&&n.name==="__proto__"?Kk(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},ev=function(t,n){if(n==="__proto__")if(nc.call(t,n)){if(Xk)return Xk(t,n).value}else return;return t[n]};nv.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=ev(a,n),o=ev(t,n),a!==o&&(l&&o&&(Jk(o)||(i=Qk(o)))?(i?(i=!1,s=r&&Qk(r)?r:[]):s=r&&Jk(r)?r:{},Zk(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&Zk(a,{name:n,newValue:o}));return a}});import ta from"react";import{addons as xc,types as Um,experimental_getStatusStore as LC}from"storybook/manager-api";import{AddonPanel as Lj}from"storybook/internal/components";import Nt,{useState as K3,useEffect as X3}from"react";import{styled as Zn}from"storybook/theming";import qm from"react";import{styled as bt}from"storybook/theming";var ue="#ea580c",bc="#c2410c",ia="#ff6b35";var Hm=bt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),Wm=bt.div({flex:1,overflow:"auto",padding:"20px"}),bo=bt.div({marginBottom:"20px"}),So=bt.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})),wo=bt.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`}})),mn=bt.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"}})),_j=bt(mn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),sa=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"}}),xr=bt.button(({theme:e})=>({...sa(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),nn=bt.button(({theme:e})=>({...sa(e),backgroundColor:ue,color:e.color.inverseText,boxShadow:`0 2px 4px ${ue}4d`,"&:hover:not(:disabled)":{backgroundColor:bc,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ue}66`}})),$n=bt.button(({theme:e})=>({...sa(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),Vm=bt.button(({theme:e})=>({...sa(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),cn=bt.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"}})),Sc=bt.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"}})),Vr=bt.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}})),Gr=bt(wo)(({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"})),$j=bt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Gm=bt.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})),Uj=bt.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})),wc=bt.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})),jj=bt.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%)"}}})),Hj=bt.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}}),Wj=bt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),Vj=bt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),Gj=bt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var kc=({header:e,children:t,footer:n})=>qm.createElement(Hm,null,e,qm.createElement(Wm,null,t),n);import $C from"react";import{styled as UC}from"storybook/theming";var jC=UC.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})),vc=({toolbar:e})=>$C.createElement(jC,null,e);import n6 from"react";import{styled as aa}from"storybook/theming";var i6=aa.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})),s6=aa.div({display:"flex",flex:1}),a6=aa(Vr)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),l6=aa.div({display:"flex",gap:"8px",alignItems:"center"});import En,{useState as gh,useCallback as mh,useEffect as hh}from"react";import{styled as qr}from"storybook/theming";import ct,{useEffect as ph}from"react";import{styled as Bt}from"storybook/theming";Ae();Ue();Pe();var E1=Bt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),A1=Bt.div(({theme:e})=>({position:"absolute",top:"100%",right:0,marginTop:"8px",backgroundColor:e.background.content,borderRadius:"8px",width:"360px",maxWidth:"90vw",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)",overflow:"hidden",zIndex:10001})),P1=Bt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),L1=Bt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),M1=Bt.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:ue,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),B1=Bt.div({display:"flex",gap:"8px"}),dh=Bt(cn)({fontSize:"18px"}),D1=Bt.div({padding:"20px 16px"}),R1=Bt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),z1=Bt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),N1=Bt.div({fontSize:"28px",fontWeight:700}),O1=Bt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),_1=Bt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),$1=Bt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),U1=Bt.div({display:"flex",alignItems:"center",gap:"8px"}),j1=Bt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),H1=Bt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:ue,color:e.color.inverseText})),W1=Bt.button(({theme:e})=>({background:"none",border:"none",color:ue,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),V1=Bt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),G1=Bt.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"?ue:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),q1=30*1e3,fh=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=ze(),s=r,a=!r&&t,u=async(f=!1)=>{if(!t)return;let d=o&&Date.now()-o<q1;if(!(!f&&d&&r))try{let h=J(),S=await fetch(`${h}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(S.ok){let C=await S.json();i(C)}}catch(h){b.error("Failed to fetch usage:",h)}};ph(()=>{u()},[t]),ph(()=>{let f=()=>{document.visibilityState==="visible"&&(b.debug("[TokenUsageModal] Tab visible, refreshing balance..."),u(!0))};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[t]);let c=()=>{n(),e()},l=()=>{let f=J();window.open(`${f}/pricing`,"_blank")},p=()=>{let f=J();window.open(`${f}/pricing#add-credits`,"_blank")};return ct.createElement(ct.Fragment,null,ct.createElement(E1,{onClick:e}),ct.createElement(A1,{onClick:f=>f.stopPropagation()},ct.createElement(P1,null,ct.createElement(L1,null,ct.createElement(M1,null,s?.email?s.email[0].toUpperCase():"U"),ct.createElement("span",null,s?.email||"Loading...")),ct.createElement(B1,null,ct.createElement(dh,{onClick:c,title:"Sign out"},"\u2192"),ct.createElement(dh,{onClick:e,title:"Close"},"\xD7"))),ct.createElement(D1,null,a?ct.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?ct.createElement(ct.Fragment,null,ct.createElement(R1,null,ct.createElement(z1,null,"Credit Balance"),ct.createElement(N1,null,"$",(s?.creditBalance??0).toFixed(2)),ct.createElement(O1,null,(s?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),ct.createElement(_1,null,ct.createElement($1,null,ct.createElement(U1,null,ct.createElement(j1,null,"Current Plan"),ct.createElement(H1,null,s?.plan||"Free")),ct.createElement(W1,{onClick:l},"View detail >")),ct.createElement(V1,null,"~$0.02-0.05 per review depending on complexity"),ct.createElement(G1,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):ct.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};Ae();Ue();var Y1=qr.div({display:"flex",alignItems:"center"}),la=qr.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),K1=qr.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),X1=qr.div({position:"relative"}),Q1=qr.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`}})),J1=qr.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)"}})),Z1=qr.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)"}}}),eT=qr.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}})),tT=30*1e3,Rc=({onOpenSettings:e})=>{let[t,n]=gh(!1),[r,o]=gh(!1),{usageData:i,usageLastFetched:s,setUsageData:a,sessionToken:u}=ze();hh(()=>{(async()=>{if(!(!u||s&&Date.now()-s<tT&&i)){o(!0);try{let S=J(),C=await fetch(`${S}/api/addon/account`,{headers:{Authorization:`Bearer ${u}`}});if(C.ok){let F=await C.json();a(F)}}catch(S){console.error("Failed to fetch balance:",S)}finally{o(!1)}}})()},[u,s,i,a]),hh(()=>{let d=()=>{document.visibilityState==="visible"&&t&&n(!1)},h=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",d),window.addEventListener("focus",h),()=>{document.removeEventListener("visibilitychange",d),window.removeEventListener("focus",h)}},[t]);let c=mh(()=>{n(!0)},[]),l=mh(()=>{n(!1)},[]),p=i?.creditBalance??0,f=p<2&&!r;return En.createElement(Y1,null,e&&En.createElement(la,null,En.createElement(eT,{onClick:e,title:"Settings"},En.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),En.createElement(la,null,En.createElement(K1,null,"v","0.4.1")),u&&En.createElement(la,null,En.createElement(J1,{onClick:c,isLow:f,title:r?"Loading...":i?f?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},r?En.createElement(Z1,null):i?`$${p.toFixed(2)}`:"...")),En.createElement(la,null,En.createElement(X1,null,En.createElement(Q1,{title:"Account & Usage",onClick:c},i?.email?i.email[0].toUpperCase():"?"),t&&En.createElement(fh,{onClose:l}))))};import Nr from"react";import{styled as Si}from"storybook/theming";import wt from"react";Ae();Pe();Ue();import{useCallback as Vo,useRef as xh,useEffect as nT}from"react";var Go=J();b.debug("[useAuth] Module loaded, APP_URL:",Go);var Oi=()=>{let e=xh(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,setSessionToken:u,setApiKey:c,setAuthMethod:l,setDeviceCode:p,setUserCode:f,setVerificationUri:d,setPollingInterval:h,resetAuth:S}=ze(),C=xh(null),F=Vo(async()=>{try{b.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let M=await fetch(`${Go}/api/addon/auth/oauth-poll`,{method:"POST"});if(!M.ok)throw new Error("Failed to create poll code");let{poll_code:g}=await M.json();b.debug("[useAuth] Got poll_code:",g.substring(0,15)+"...");let k=600,w=700,A=window.screenX+(window.outerWidth-k)/2,m=window.screenY+(window.outerHeight-w)/2;window.open(`${Go}/addon/auth?poll_code=${g}`,"figma-auth",`width=${k},height=${w},left=${A},top=${m}`),b.debug("[useAuth] Starting OAuth poll for token..."),C.current&&clearInterval(C.current);let v=async()=>{try{let x=await(await fetch(`${Go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:g})})).json();x.status==="authorized"&&x.session_token?(b.debug("[useAuth] \u2705 OAuth poll successful! Got token."),C.current&&(clearInterval(C.current),C.current=null),localStorage.setItem("uicopilot_session_token",x.session_token),u(x.session_token)):x.status==="expired"&&(b.debug("[useAuth] OAuth poll_code expired"),C.current&&(clearInterval(C.current),C.current=null))}catch(I){b.error("[useAuth] OAuth poll error:",I)}};C.current=setInterval(v,2e3),setTimeout(v,1e3)}catch(M){b.error("[useAuth] OAuth flow error:",M)}},[u]),T=Vo(async()=>{try{let M=await fetch(`${Go}/api/addon/auth/device`,{method:"POST"});if(!M.ok)throw new Error("Failed to start device code flow");let g=await M.json();p(g.device_code),f(g.user_code),d(g.verification_uri),window.open(g.verification_uri,"_blank"),R(g.device_code,g.interval*1e3)}catch(M){throw b.error("[useAuth] Device code flow error:",M),M}},[p,f,d]),R=Vo((M,g)=>{b.debug("[useAuth] Starting polling. Device code:",M,"Interval:",g),e.current&&clearInterval(e.current);let k=async()=>{try{let A=await(await fetch(`${Go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:M})})).json();A.status==="authorized"?(b.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),p(null),f(null),d(null),localStorage.setItem("uicopilot_session_token",A.session_token),u(A.session_token)):(A.status==="expired"||A.status==="denied")&&(b.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),p(null),f(null),d(null))}catch(w){b.error("[useAuth] Polling error:",w)}};e.current=setInterval(k,g),h(g)},[p,f,d,u,h]),z=Vo(()=>{e.current&&(clearInterval(e.current),e.current=null),p(null),f(null),d(null),h(null)},[p,f,d,h]),N=Vo(M=>{c(M),localStorage.setItem("uicopilot_api_key",M)},[c]),E=Vo(()=>{S(),e.current&&(clearInterval(e.current),e.current=null)},[S]);return nT(()=>()=>{e.current&&clearInterval(e.current),C.current&&clearInterval(C.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,setAuthMethod:l,startOAuth:F,startDeviceCode:T,cancelDeviceCode:z,saveApiKey:N,logout:E}};Ae();Pe();Ue();import{useCallback as ca}from"react";var _i=J(),tr=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Ke(),{sessionToken:a}=ze(),u=ca(async()=>{if(!a){b.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),b.debug("[useProjects] Fetching from:",`${_i}/api/projects`);let f=await fetch(`${_i}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(f.ok){let d=await f.json();b.debug("[useProjects] Projects:",d.projects),r(d.projects||[])}else b.error("[useProjects] Failed to fetch projects:",f.status,f.statusText)}catch(f){b.error("[useProjects] Error fetching projects:",f)}finally{i(!1)}},[a,r,i]),c=ca(async f=>{if(!a)throw new Error("Not authenticated");let d=await fetch(`${_i}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)});if(!d.ok)throw new Error("Failed to create project");let h=await d.json();return await u(),h.project},[a,u]),l=ca(async(f,d)=>{if(!a)throw new Error("Not authenticated");let h={};if(d.name!==void 0&&(h.name=d.name),d.description!==void 0&&(h.description=d.description),d.figmaFileUrl!==void 0&&(h.figmaFileId=d.figmaFileUrl||void 0),!(await fetch(`${_i}/api/projects/${f}`,{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]),p=ca(async f=>{if(!a)throw new Error("Not authenticated");if(!(await fetch(`${_i}/api/projects/${f}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===f&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:p}};Ae();var $i=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:p}=Ge();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:p,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};Ae();_c();Wc();import{useCallback as ws,useRef as rf}from"react";Pe();function ga(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){b.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();b.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{b.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),b.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{b.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var ma=BigInt(4294967295),Lh=BigInt(32);function CT(e,t=!1){return t?{h:Number(e&ma),l:Number(e>>Lh&ma)}:{h:Number(e>>Lh&ma)|0,l:Number(e&ma)|0}}function Mh(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}=CT(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Bh=(e,t,n)=>e<<n|t>>>32-n,Dh=(e,t,n)=>t<<n|e>>>32-n,Rh=(e,t,n)=>t<<n-32|e>>>64-n,zh=(e,t,n)=>e<<n-32|t>>>64-n;function TT(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Vc(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function ha(e,t,n=""){let r=TT(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 Gc(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 Nh(e,t){ha(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 Oh(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qc(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var IT=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function FT(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ET(e){for(let t=0;t<e.length;t++)e[t]=FT(e[t]);return e}var Yc=IT?e=>e:ET;function _h(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 $h=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var AT=BigInt(0),Gi=BigInt(1),PT=BigInt(2),LT=BigInt(7),MT=BigInt(256),BT=BigInt(113),Hh=[],Wh=[],Vh=[];for(let e=0,t=Gi,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Hh.push(2*(5*r+n)),Wh.push((e+1)*(e+2)/2%64);let o=AT;for(let i=0;i<7;i++)t=(t<<Gi^(t>>LT)*BT)%MT,t&PT&&(o^=Gi<<(Gi<<BigInt(i))-Gi);Vh.push(o)}var Gh=Mh(Vh,!0),DT=Gh[0],RT=Gh[1],Uh=(e,t,n)=>n>32?Rh(e,t,n):Bh(e,t,n),jh=(e,t,n)=>n>32?zh(e,t,n):Dh(e,t,n);function zT(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],p=Uh(c,l,1)^n[a],f=jh(c,l,1)^n[a+1];for(let d=0;d<50;d+=10)e[s+d]^=p,e[s+d+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=Wh[s],u=Uh(o,i,a),c=jh(o,i,a),l=Hh[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]^=DT[r],e[1]^=RT[r]}qc(n)}var Kc=class e{constructor(t,n,r,o=!1,i=24){_n(this,"state");_n(this,"pos",0);_n(this,"posOut",0);_n(this,"finished",!1);_n(this,"state32");_n(this,"destroyed",!1);_n(this,"blockLen");_n(this,"suffix");_n(this,"outputLen");_n(this,"enableXOF",!1);_n(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Vc(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Oh(this.state)}clone(){return this._cloneInto()}keccak(){Yc(this.state32),zT(this.state32,this.rounds),Yc(this.state32),this.posOut=0,this.pos=0}update(t){Gc(this),ha(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){Gc(this,!1),ha(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 Vc(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Nh(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,qc(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}},NT=(e,t,n,r={})=>_h(()=>new Kc(t,e,n),r);var qh=NT(6,72,64,$h(10));var OT=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Xc=Math.ceil,Wn=Math.floor,xn="[BigNumber Error] ",Yh=xn+"Number primitive has more than 15 significant digits: ",nr=1e14,Be=14,Qc=9007199254740991,Jc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Yr=1e7,Ht=1e9;function Kh(e){var t,n,r,o=T.prototype={constructor:T,toString:null,valueOf:null},i=new T(1),s=20,a=4,u=-7,c=21,l=-1e7,p=1e7,f=!1,d=1,h=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function T(g,k){var w,A,m,v,I,x,P,L,D=this;if(!(D instanceof T))return new T(g,k);if(k==null){if(g&&g._isBigNumber===!0){D.s=g.s,!g.c||g.e>p?D.c=D.e=null:g.e<l?D.c=[D.e=0]:(D.e=g.e,D.c=g.c.slice());return}if((x=typeof g=="number")&&g*0==0){if(D.s=1/g<0?(g=-g,-1):1,g===~~g){for(v=0,I=g;I>=10;I/=10,v++);v>p?D.c=D.e=null:(D.e=v,D.c=[g]);return}L=String(g)}else{if(!OT.test(L=String(g)))return r(D,L,x);D.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(v=L.indexOf("."))>-1&&(L=L.replace(".","")),(I=L.search(/e/i))>0?(v<0&&(v=I),v+=+L.slice(I+1),L=L.substring(0,I)):v<0&&(v=L.length)}else{if(kt(k,2,C.length,"Base"),k==10&&F)return D=new T(g),E(D,s+D.e+1,a);if(L=String(g),x=typeof g=="number"){if(g*0!=0)return r(D,L,x,k);if(D.s=1/g<0?(L=L.slice(1),-1):1,T.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(Yh+g)}else D.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(w=C.slice(0,k),v=I=0,P=L.length;I<P;I++)if(w.indexOf(A=L.charAt(I))<0){if(A=="."){if(I>v){v=P;continue}}else if(!m&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){m=!0,I=-1,v=0;continue}return r(D,String(g),x,k)}x=!1,L=n(L,k,10,D.s),(v=L.indexOf("."))>-1?L=L.replace(".",""):v=L.length}for(I=0;L.charCodeAt(I)===48;I++);for(P=L.length;L.charCodeAt(--P)===48;);if(L=L.slice(I,++P)){if(P-=I,x&&T.DEBUG&&P>15&&(g>Qc||g!==Wn(g)))throw Error(Yh+D.s*g);if((v=v-I-1)>p)D.c=D.e=null;else if(v<l)D.c=[D.e=0];else{if(D.e=v,D.c=[],I=(v+1)%Be,v<0&&(I+=Be),I<P){for(I&&D.c.push(+L.slice(0,I)),P-=Be;I<P;)D.c.push(+L.slice(I,I+=Be));I=Be-(L=L.slice(I)).length}else I-=P;for(;I--;L+="0");D.c.push(+L)}}else D.c=[D.e=0]}T.clone=Kh,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(g){var k,w;if(g!=null)if(typeof g=="object"){if(g.hasOwnProperty(k="DECIMAL_PLACES")&&(w=g[k],kt(w,0,Ht,k),s=w),g.hasOwnProperty(k="ROUNDING_MODE")&&(w=g[k],kt(w,0,8,k),a=w),g.hasOwnProperty(k="EXPONENTIAL_AT")&&(w=g[k],w&&w.pop?(kt(w[0],-Ht,0,k),kt(w[1],0,Ht,k),u=w[0],c=w[1]):(kt(w,-Ht,Ht,k),u=-(c=w<0?-w:w))),g.hasOwnProperty(k="RANGE"))if(w=g[k],w&&w.pop)kt(w[0],-Ht,-1,k),kt(w[1],1,Ht,k),l=w[0],p=w[1];else if(kt(w,-Ht,Ht,k),w)l=-(p=w<0?-w:w);else throw Error(xn+k+" cannot be zero: "+w);if(g.hasOwnProperty(k="CRYPTO"))if(w=g[k],w===!!w)if(w)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=w;else throw f=!w,Error(xn+"crypto unavailable");else f=w;else throw Error(xn+k+" not true or false: "+w);if(g.hasOwnProperty(k="MODULO_MODE")&&(w=g[k],kt(w,0,9,k),d=w),g.hasOwnProperty(k="POW_PRECISION")&&(w=g[k],kt(w,0,Ht,k),h=w),g.hasOwnProperty(k="FORMAT"))if(w=g[k],typeof w=="object")S=w;else throw Error(xn+k+" not an object: "+w);if(g.hasOwnProperty(k="ALPHABET"))if(w=g[k],typeof w=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(w))F=w.slice(0,10)=="0123456789",C=w;else throw Error(xn+k+" invalid: "+w)}else throw Error(xn+"Object expected: "+g);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,p],CRYPTO:f,MODULO_MODE:d,POW_PRECISION:h,FORMAT:S,ALPHABET:C}},T.isBigNumber=function(g){if(!g||g._isBigNumber!==!0)return!1;if(!T.DEBUG)return!0;var k,w,A=g.c,m=g.e,v=g.s;e:if({}.toString.call(A)=="[object Array]"){if((v===1||v===-1)&&m>=-Ht&&m<=Ht&&m===Wn(m)){if(A[0]===0){if(m===0&&A.length===1)return!0;break e}if(k=(m+1)%Be,k<1&&(k+=Be),String(A[0]).length==k){for(k=0;k<A.length;k++)if(w=A[k],w<0||w>=nr||w!==Wn(w))break e;if(w!==0)return!0}}}else if(A===null&&m===null&&(v===null||v===1||v===-1))return!0;throw Error(xn+"Invalid BigNumber: "+g)},T.maximum=T.max=function(){return z(arguments,-1)},T.minimum=T.min=function(){return z(arguments,1)},T.random=(function(){var g=9007199254740992,k=Math.random()*g&2097151?function(){return Wn(Math.random()*g)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(w){var A,m,v,I,x,P=0,L=[],D=new T(i);if(w==null?w=s:kt(w,0,Ht),I=Xc(w/Be),f)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(I*=2));P<I;)x=A[P]*131072+(A[P+1]>>>11),x>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),A[P]=m[0],A[P+1]=m[1]):(L.push(x%1e14),P+=2);P=I/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(I*=7);P<I;)x=(A[P]&31)*281474976710656+A[P+1]*1099511627776+A[P+2]*4294967296+A[P+3]*16777216+(A[P+4]<<16)+(A[P+5]<<8)+A[P+6],x>=9e15?crypto.randomBytes(7).copy(A,P):(L.push(x%1e14),P+=7);P=I/7}else throw f=!1,Error(xn+"crypto unavailable");if(!f)for(;P<I;)x=k(),x<9e15&&(L[P++]=x%1e14);for(I=L[--P],w%=Be,I&&w&&(x=Jc[Be-w],L[P]=Wn(I/x)*x);L[P]===0;L.pop(),P--);if(P<0)L=[v=0];else{for(v=-1;L[0]===0;L.splice(0,1),v-=Be);for(P=1,x=L[0];x>=10;x/=10,P++);P<Be&&(v-=Be-P)}return D.e=v,D.c=L,D}})(),T.sum=function(){for(var g=1,k=arguments,w=new T(k[0]);g<k.length;)w=w.plus(k[g++]);return w},n=(function(){var g="0123456789";function k(w,A,m,v){for(var I,x=[0],P,L=0,D=w.length;L<D;){for(P=x.length;P--;x[P]*=A);for(x[0]+=v.indexOf(w.charAt(L++)),I=0;I<x.length;I++)x[I]>m-1&&(x[I+1]==null&&(x[I+1]=0),x[I+1]+=x[I]/m|0,x[I]%=m)}return x.reverse()}return function(w,A,m,v,I){var x,P,L,D,O,y,U,V,B=w.indexOf("."),X=s,ee=a;for(B>=0&&(D=h,h=0,w=w.replace(".",""),V=new T(A),y=V.pow(w.length-B),h=D,V.c=k(Ir(Hn(y.c),y.e,"0"),10,m,g),V.e=V.c.length),U=k(w,A,m,I?(x=C,g):(x=g,C)),L=D=U.length;U[--D]==0;U.pop());if(!U[0])return x.charAt(0);if(B<0?--L:(y.c=U,y.e=L,y.s=v,y=t(y,V,X,ee,m),U=y.c,O=y.r,L=y.e),P=L+X+1,B=U[P],D=m/2,O=O||P<0||U[P+1]!=null,O=ee<4?(B!=null||O)&&(ee==0||ee==(y.s<0?3:2)):B>D||B==D&&(ee==4||O||ee==6&&U[P-1]&1||ee==(y.s<0?8:7)),P<1||!U[0])w=O?Ir(x.charAt(1),-X,x.charAt(0)):x.charAt(0);else{if(U.length=P,O)for(--m;++U[--P]>m;)U[P]=0,P||(++L,U=[1].concat(U));for(D=U.length;!U[--D];);for(B=0,w="";B<=D;w+=x.charAt(U[B++]));w=Ir(w,L,x.charAt(0))}return w}})(),t=(function(){function g(A,m,v){var I,x,P,L,D=0,O=A.length,y=m%Yr,U=m/Yr|0;for(A=A.slice();O--;)P=A[O]%Yr,L=A[O]/Yr|0,I=U*P+L*y,x=y*P+I%Yr*Yr+D,D=(x/v|0)+(I/Yr|0)+U*L,A[O]=x%v;return D&&(A=[D].concat(A)),A}function k(A,m,v,I){var x,P;if(v!=I)P=v>I?1:-1;else for(x=P=0;x<v;x++)if(A[x]!=m[x]){P=A[x]>m[x]?1:-1;break}return P}function w(A,m,v,I){for(var x=0;v--;)A[v]-=x,x=A[v]<m[v]?1:0,A[v]=x*I+A[v]-m[v];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,m,v,I,x){var P,L,D,O,y,U,V,B,X,ee,Q,Ee,Te,We,ot,j,ie,re=A.s==m.s?1:-1,he=A.c,de=m.c;if(!he||!he[0]||!de||!de[0])return new T(!A.s||!m.s||(he?de&&he[0]==de[0]:!de)?NaN:he&&he[0]==0||!de?re*0:re/0);for(B=new T(re),X=B.c=[],L=A.e-m.e,re=v+L+1,x||(x=nr,L=Vn(A.e/Be)-Vn(m.e/Be),re=re/Be|0),D=0;de[D]==(he[D]||0);D++);if(de[D]>(he[D]||0)&&L--,re<0)X.push(1),O=!0;else{for(We=he.length,j=de.length,D=0,re+=2,y=Wn(x/(de[0]+1)),y>1&&(de=g(de,y,x),he=g(he,y,x),j=de.length,We=he.length),Te=j,ee=he.slice(0,j),Q=ee.length;Q<j;ee[Q++]=0);ie=de.slice(),ie=[0].concat(ie),ot=de[0],de[1]>=x/2&&ot++;do{if(y=0,P=k(de,ee,j,Q),P<0){if(Ee=ee[0],j!=Q&&(Ee=Ee*x+(ee[1]||0)),y=Wn(Ee/ot),y>1)for(y>=x&&(y=x-1),U=g(de,y,x),V=U.length,Q=ee.length;k(U,ee,V,Q)==1;)y--,w(U,j<V?ie:de,V,x),V=U.length,P=1;else y==0&&(P=y=1),U=de.slice(),V=U.length;if(V<Q&&(U=[0].concat(U)),w(ee,U,Q,x),Q=ee.length,P==-1)for(;k(de,ee,j,Q)<1;)y++,w(ee,j<Q?ie:de,Q,x),Q=ee.length}else P===0&&(y++,ee=[0]);X[D++]=y,ee[0]?ee[Q++]=he[Te]||0:(ee=[he[Te]],Q=1)}while((Te++<We||ee[0]!=null)&&re--);O=ee[0]!=null,X[0]||X.splice(0,1)}if(x==nr){for(D=1,re=X[0];re>=10;re/=10,D++);E(B,v+(B.e=D+L*Be-1)+1,I,O)}else B.e=L,B.r=+O;return B}})();function R(g,k,w,A){var m,v,I,x,P;if(w==null?w=a:kt(w,0,8),!g.c)return g.toString();if(m=g.c[0],I=g.e,k==null)P=Hn(g.c),P=A==1||A==2&&(I<=u||I>=c)?ya(P,I):Ir(P,I,"0");else if(g=E(new T(g),k,w),v=g.e,P=Hn(g.c),x=P.length,A==1||A==2&&(k<=v||v<=u)){for(;x<k;P+="0",x++);P=ya(P,v)}else if(k-=I+(A===2&&v>I),P=Ir(P,v,"0"),v+1>x){if(--k>0)for(P+=".";k--;P+="0");}else if(k+=v-x,k>0)for(v+1==x&&(P+=".");k--;P+="0");return g.s<0&&m?"-"+P:P}function z(g,k){for(var w,A,m=1,v=new T(g[0]);m<g.length;m++)A=new T(g[m]),(!A.s||(w=vo(v,A))===k||w===0&&v.s===k)&&(v=A);return v}function N(g,k,w){for(var A=1,m=k.length;!k[--m];k.pop());for(m=k[0];m>=10;m/=10,A++);return(w=A+w*Be-1)>p?g.c=g.e=null:w<l?g.c=[g.e=0]:(g.e=w,g.c=k),g}r=(function(){var g=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,w=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(v,I,x,P){var L,D=x?I:I.replace(m,"");if(A.test(D))v.s=isNaN(D)?null:D<0?-1:1;else{if(!x&&(D=D.replace(g,function(O,y,U){return L=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!P||P==L?y:O}),P&&(L=P,D=D.replace(k,"$1").replace(w,"0.$1")),I!=D))return new T(D,L);if(T.DEBUG)throw Error(xn+"Not a"+(P?" base "+P:"")+" number: "+I);v.s=null}v.c=v.e=null}})();function E(g,k,w,A){var m,v,I,x,P,L,D,O=g.c,y=Jc;if(O){e:{for(m=1,x=O[0];x>=10;x/=10,m++);if(v=k-m,v<0)v+=Be,I=k,P=O[L=0],D=Wn(P/y[m-I-1]%10);else if(L=Xc((v+1)/Be),L>=O.length)if(A){for(;O.length<=L;O.push(0));P=D=0,m=1,v%=Be,I=v-Be+1}else break e;else{for(P=x=O[L],m=1;x>=10;x/=10,m++);v%=Be,I=v-Be+m,D=I<0?0:Wn(P/y[m-I-1]%10)}if(A=A||k<0||O[L+1]!=null||(I<0?P:P%y[m-I-1]),A=w<4?(D||A)&&(w==0||w==(g.s<0?3:2)):D>5||D==5&&(w==4||A||w==6&&(v>0?I>0?P/y[m-I]:0:O[L-1])%10&1||w==(g.s<0?8:7)),k<1||!O[0])return O.length=0,A?(k-=g.e+1,O[0]=y[(Be-k%Be)%Be],g.e=-k||0):O[0]=g.e=0,g;if(v==0?(O.length=L,x=1,L--):(O.length=L+1,x=y[Be-v],O[L]=I>0?Wn(P/y[m-I]%y[I])*x:0),A)for(;;)if(L==0){for(v=1,I=O[0];I>=10;I/=10,v++);for(I=O[0]+=x,x=1;I>=10;I/=10,x++);v!=x&&(g.e++,O[0]==nr&&(O[0]=1));break}else{if(O[L]+=x,O[L]!=nr)break;O[L--]=0,x=1}for(v=O.length;O[--v]===0;O.pop());}g.e>p?g.c=g.e=null:g.e<l&&(g.c=[g.e=0])}return g}function M(g){var k,w=g.e;return w===null?g.toString():(k=Hn(g.c),k=w<=u||w>=c?ya(k,w):Ir(k,w,"0"),g.s<0?"-"+k:k)}return o.absoluteValue=o.abs=function(){var g=new T(this);return g.s<0&&(g.s=1),g},o.comparedTo=function(g,k){return vo(this,new T(g,k))},o.decimalPlaces=o.dp=function(g,k){var w,A,m,v=this;if(g!=null)return kt(g,0,Ht),k==null?k=a:kt(k,0,8),E(new T(v),g+v.e+1,k);if(!(w=v.c))return null;if(A=((m=w.length-1)-Vn(this.e/Be))*Be,m=w[m])for(;m%10==0;m/=10,A--);return A<0&&(A=0),A},o.dividedBy=o.div=function(g,k){return t(this,new T(g,k),s,a)},o.dividedToIntegerBy=o.idiv=function(g,k){return t(this,new T(g,k),0,1)},o.exponentiatedBy=o.pow=function(g,k){var w,A,m,v,I,x,P,L,D,O=this;if(g=new T(g),g.c&&!g.isInteger())throw Error(xn+"Exponent not an integer: "+M(g));if(k!=null&&(k=new T(k)),x=g.e>14,!O.c||!O.c[0]||O.c[0]==1&&!O.e&&O.c.length==1||!g.c||!g.c[0])return D=new T(Math.pow(+M(O),x?g.s*(2-xa(g)):+M(g))),k?D.mod(k):D;if(P=g.s<0,k){if(k.c?!k.c[0]:!k.s)return new T(NaN);A=!P&&O.isInteger()&&k.isInteger(),A&&(O=O.mod(k))}else{if(g.e>9&&(O.e>0||O.e<-1||(O.e==0?O.c[0]>1||x&&O.c[1]>=24e7:O.c[0]<8e13||x&&O.c[0]<=9999975e7)))return v=O.s<0&&xa(g)?-0:0,O.e>-1&&(v=1/v),new T(P?1/v:v);h&&(v=Xc(h/Be+2))}for(x?(w=new T(.5),P&&(g.s=1),L=xa(g)):(m=Math.abs(+M(g)),L=m%2),D=new T(i);;){if(L){if(D=D.times(O),!D.c)break;v?D.c.length>v&&(D.c.length=v):A&&(D=D.mod(k))}if(m){if(m=Wn(m/2),m===0)break;L=m%2}else if(g=g.times(w),E(g,g.e+1,1),g.e>14)L=xa(g);else{if(m=+M(g),m===0)break;L=m%2}O=O.times(O),v?O.c&&O.c.length>v&&(O.c.length=v):A&&(O=O.mod(k))}return A?D:(P&&(D=i.div(D)),k?D.mod(k):v?E(D,h,a,I):D)},o.integerValue=function(g){var k=new T(this);return g==null?g=a:kt(g,0,8),E(k,k.e+1,g)},o.isEqualTo=o.eq=function(g,k){return vo(this,new T(g,k))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(g,k){return vo(this,new T(g,k))>0},o.isGreaterThanOrEqualTo=o.gte=function(g,k){return(k=vo(this,new T(g,k)))===1||k===0},o.isInteger=function(){return!!this.c&&Vn(this.e/Be)>this.c.length-2},o.isLessThan=o.lt=function(g,k){return vo(this,new T(g,k))<0},o.isLessThanOrEqualTo=o.lte=function(g,k){return(k=vo(this,new T(g,k)))===-1||k===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(g,k){var w,A,m,v,I=this,x=I.s;if(g=new T(g,k),k=g.s,!x||!k)return new T(NaN);if(x!=k)return g.s=-k,I.plus(g);var P=I.e/Be,L=g.e/Be,D=I.c,O=g.c;if(!P||!L){if(!D||!O)return D?(g.s=-k,g):new T(O?I:NaN);if(!D[0]||!O[0])return O[0]?(g.s=-k,g):new T(D[0]?I:a==3?-0:0)}if(P=Vn(P),L=Vn(L),D=D.slice(),x=P-L){for((v=x<0)?(x=-x,m=D):(L=P,m=O),m.reverse(),k=x;k--;m.push(0));m.reverse()}else for(A=(v=(x=D.length)<(k=O.length))?x:k,x=k=0;k<A;k++)if(D[k]!=O[k]){v=D[k]<O[k];break}if(v&&(m=D,D=O,O=m,g.s=-g.s),k=(A=O.length)-(w=D.length),k>0)for(;k--;D[w++]=0);for(k=nr-1;A>x;){if(D[--A]<O[A]){for(w=A;w&&!D[--w];D[w]=k);--D[w],D[A]+=nr}D[A]-=O[A]}for(;D[0]==0;D.splice(0,1),--L);return D[0]?N(g,D,L):(g.s=a==3?-1:1,g.c=[g.e=0],g)},o.modulo=o.mod=function(g,k){var w,A,m=this;return g=new T(g,k),!m.c||!g.s||g.c&&!g.c[0]?new T(NaN):!g.c||m.c&&!m.c[0]?new T(m):(d==9?(A=g.s,g.s=1,w=t(m,g,0,3),g.s=A,w.s*=A):w=t(m,g,0,d),g=m.minus(w.times(g)),!g.c[0]&&d==1&&(g.s=m.s),g)},o.multipliedBy=o.times=function(g,k){var w,A,m,v,I,x,P,L,D,O,y,U,V,B,X,ee=this,Q=ee.c,Ee=(g=new T(g,k)).c;if(!Q||!Ee||!Q[0]||!Ee[0])return!ee.s||!g.s||Q&&!Q[0]&&!Ee||Ee&&!Ee[0]&&!Q?g.c=g.e=g.s=null:(g.s*=ee.s,!Q||!Ee?g.c=g.e=null:(g.c=[0],g.e=0)),g;for(A=Vn(ee.e/Be)+Vn(g.e/Be),g.s*=ee.s,P=Q.length,O=Ee.length,P<O&&(V=Q,Q=Ee,Ee=V,m=P,P=O,O=m),m=P+O,V=[];m--;V.push(0));for(B=nr,X=Yr,m=O;--m>=0;){for(w=0,y=Ee[m]%X,U=Ee[m]/X|0,I=P,v=m+I;v>m;)L=Q[--I]%X,D=Q[I]/X|0,x=U*L+D*y,L=y*L+x%X*X+V[v]+w,w=(L/B|0)+(x/X|0)+U*D,V[v--]=L%B;V[v]=w}return w?++A:V.splice(0,1),N(g,V,A)},o.negated=function(){var g=new T(this);return g.s=-g.s||null,g},o.plus=function(g,k){var w,A=this,m=A.s;if(g=new T(g,k),k=g.s,!m||!k)return new T(NaN);if(m!=k)return g.s=-k,A.minus(g);var v=A.e/Be,I=g.e/Be,x=A.c,P=g.c;if(!v||!I){if(!x||!P)return new T(m/0);if(!x[0]||!P[0])return P[0]?g:new T(x[0]?A:m*0)}if(v=Vn(v),I=Vn(I),x=x.slice(),m=v-I){for(m>0?(I=v,w=P):(m=-m,w=x),w.reverse();m--;w.push(0));w.reverse()}for(m=x.length,k=P.length,m-k<0&&(w=P,P=x,x=w,k=m),m=0;k;)m=(x[--k]=x[k]+P[k]+m)/nr|0,x[k]=nr===x[k]?0:x[k]%nr;return m&&(x=[m].concat(x),++I),N(g,x,I)},o.precision=o.sd=function(g,k){var w,A,m,v=this;if(g!=null&&g!==!!g)return kt(g,1,Ht),k==null?k=a:kt(k,0,8),E(new T(v),g,k);if(!(w=v.c))return null;if(m=w.length-1,A=m*Be+1,m=w[m]){for(;m%10==0;m/=10,A--);for(m=w[0];m>=10;m/=10,A++);}return g&&v.e+1>A&&(A=v.e+1),A},o.shiftedBy=function(g){return kt(g,-Qc,Qc),this.times("1e"+g)},o.squareRoot=o.sqrt=function(){var g,k,w,A,m,v=this,I=v.c,x=v.s,P=v.e,L=s+4,D=new T("0.5");if(x!==1||!I||!I[0])return new T(!x||x<0&&(!I||I[0])?NaN:I?v:1/0);if(x=Math.sqrt(+M(v)),x==0||x==1/0?(k=Hn(I),(k.length+P)%2==0&&(k+="0"),x=Math.sqrt(+k),P=Vn((P+1)/2)-(P<0||P%2),x==1/0?k="5e"+P:(k=x.toExponential(),k=k.slice(0,k.indexOf("e")+1)+P),w=new T(k)):w=new T(x+""),w.c[0]){for(P=w.e,x=P+L,x<3&&(x=0);;)if(m=w,w=D.times(m.plus(t(v,m,L,1))),Hn(m.c).slice(0,x)===(k=Hn(w.c)).slice(0,x))if(w.e<P&&--x,k=k.slice(x-3,x+1),k=="9999"||!A&&k=="4999"){if(!A&&(E(m,m.e+s+2,0),m.times(m).eq(v))){w=m;break}L+=4,x+=4,A=1}else{(!+k||!+k.slice(1)&&k.charAt(0)=="5")&&(E(w,w.e+s+2,1),g=!w.times(w).eq(v));break}}return E(w,w.e+s+1,a,g)},o.toExponential=function(g,k){return g!=null&&(kt(g,0,Ht),g++),R(this,g,k,1)},o.toFixed=function(g,k){return g!=null&&(kt(g,0,Ht),g=g+this.e+1),R(this,g,k)},o.toFormat=function(g,k,w){var A,m=this;if(w==null)g!=null&&k&&typeof k=="object"?(w=k,k=null):g&&typeof g=="object"?(w=g,g=k=null):w=S;else if(typeof w!="object")throw Error(xn+"Argument not an object: "+w);if(A=m.toFixed(g,k),m.c){var v,I=A.split("."),x=+w.groupSize,P=+w.secondaryGroupSize,L=w.groupSeparator||"",D=I[0],O=I[1],y=m.s<0,U=y?D.slice(1):D,V=U.length;if(P&&(v=x,x=P,P=v,V-=v),x>0&&V>0){for(v=V%x||x,D=U.substr(0,v);v<V;v+=x)D+=L+U.substr(v,x);P>0&&(D+=L+U.slice(v)),y&&(D="-"+D)}A=O?D+(w.decimalSeparator||"")+((P=+w.fractionGroupSize)?O.replace(new RegExp("\\d{"+P+"}\\B","g"),"$&"+(w.fractionGroupSeparator||"")):O):D}return(w.prefix||"")+A+(w.suffix||"")},o.toFraction=function(g){var k,w,A,m,v,I,x,P,L,D,O,y,U=this,V=U.c;if(g!=null&&(x=new T(g),!x.isInteger()&&(x.c||x.s!==1)||x.lt(i)))throw Error(xn+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+M(x));if(!V)return new T(U);for(k=new T(i),L=w=new T(i),A=P=new T(i),y=Hn(V),v=k.e=y.length-U.e-1,k.c[0]=Jc[(I=v%Be)<0?Be+I:I],g=!g||x.comparedTo(k)>0?v>0?k:L:x,I=p,p=1/0,x=new T(y),P.c[0]=0;D=t(x,k,0,1),m=w.plus(D.times(A)),m.comparedTo(g)!=1;)w=A,A=m,L=P.plus(D.times(m=L)),P=m,k=x.minus(D.times(m=k)),x=m;return m=t(g.minus(w),A,0,1),P=P.plus(m.times(L)),w=w.plus(m.times(A)),P.s=L.s=U.s,v=v*2,O=t(L,A,v,a).minus(U).abs().comparedTo(t(P,w,v,a).minus(U).abs())<1?[L,A]:[P,w],p=I,O},o.toNumber=function(){return+M(this)},o.toPrecision=function(g,k){return g!=null&&kt(g,1,Ht),R(this,g,k,2)},o.toString=function(g){var k,w=this,A=w.s,m=w.e;return m===null?A?(k="Infinity",A<0&&(k="-"+k)):k="NaN":(g==null?k=m<=u||m>=c?ya(Hn(w.c),m):Ir(Hn(w.c),m,"0"):g===10&&F?(w=E(new T(w),s+m+1,a),k=Ir(Hn(w.c),w.e,"0")):(kt(g,2,C.length,"Base"),k=n(Ir(Hn(w.c),m,"0"),10,g,A,!0)),A<0&&w.c[0]&&(k="-"+k)),k},o.valueOf=o.toJSON=function(){return M(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&T.set(e),T}function Vn(e){var t=e|0;return e>0||e===t?t:t-1}function Hn(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=Be-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function vo(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 kt(e,t,n,r){if(e<t||e>n||e!==Wn(e))throw Error(xn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function xa(e){var t=e.c.length-1;return Vn(e.e/Be)==t&&e.c[t]%2!=0}function ya(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Ir(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 _T=Kh(),Xh=_T;var $T=24,qi=32,UT=()=>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,eu=UT(),Zc=(e=4,t=eu)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function jT(e){let t=new Xh(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var Jh=(e="")=>{let t=new TextEncoder;return jT(qh(t.encode(e))).toString(36).slice(1)},Qh=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),HT=e=>Qh[Math.floor(e()*Qh.length)],WT=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=eu}={})=>{let n=Object.keys(e).toString(),r=n.length?n+Zc(qi,t):Zc(qi,t);return Jh(r).substring(0,qi)},VT=e=>()=>e++,GT=476782367,Zh=({random:e=eu,counter:t=VT(Math.floor(e()*GT)),length:n=$T,fingerprint:r=WT({random:e})}={})=>{if(n>qi)throw new Error(`Length must be between 2 and ${qi}. Received: ${n}`);return function(){let i=HT(e),s=Date.now().toString(36),a=t().toString(36),u=Zc(n,e),c=`${s+u+a+r}`;return`${i+Jh(c).substring(1,n)}`}},Kr=qT(Zh);function qT(e){let t;return()=>(t||(t=e()),t())}var jL=oa(nx());function It(e){return e>=48&&e<=57}function bn(e){return It(e)||e>=65&&e<=70||e>=97&&e<=102}function Sa(e){return e>=65&&e<=90}function XT(e){return e>=97&&e<=122}function QT(e){return Sa(e)||XT(e)}function JT(e){return e>=128}function ba(e){return QT(e)||JT(e)||e===95}function wa(e){return ba(e)||It(e)||e===45}function ZT(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function Yi(e){return e===10||e===13||e===12}function yr(e){return Yi(e)||e===32||e===9}function yn(e,t){return!(e!==92||Yi(t)||t===0)}function Ko(e,t,n){return e===45?ba(t)||t===45||yn(t,n):ba(e)?!0:e===92?yn(e,t):!1}function ka(e,t,n){return e===43||e===45?It(t)?2:t===46&&It(n)?3:0:e===46?It(t)?2:0:It(e)?1:0}function va(e){return e===65279||e===65534?1:0}var tu=new Array(128),eI=128,Ki=130,nu=131,Ca=132,ru=133;for(let e=0;e<tu.length;e++)tu[e]=yr(e)&&Ki||It(e)&&nu||ba(e)&&Ca||ZT(e)&&ru||e||eI;function Ta(e){return e<128?tu[e]:Ca}function Xo(e,t){return t<e.length?e.charCodeAt(t):0}function Ia(e,t,n){return n===13&&Xo(e,t+1)===10?2:1}function Fr(e,t,n){let r=e.charCodeAt(t);return Sa(r)&&(r=r|32),r===n}function Er(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(Sa(s)&&(s=s|32),s!==i)return!1}return!0}function rx(e,t){for(;t>=0&&yr(e.charCodeAt(t));t--);return t+1}function Xi(e,t){for(;t<e.length&&yr(e.charCodeAt(t));t++);return t}function ou(e,t){for(;t<e.length&&It(e.charCodeAt(t));t++);return t}function Ar(e,t){if(t+=2,bn(Xo(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&bn(Xo(e,t));t++);let n=Xo(e,t);yr(n)&&(t+=Ia(e,t,n))}return t}function Qi(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!wa(n)){if(yn(n,Xo(e,t+1))){t=Ar(e,t)-1;continue}break}}return t}function Co(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),It(n)&&(t=ou(e,t+1),n=e.charCodeAt(t)),n===46&&It(e.charCodeAt(t+1))&&(t+=2,t=ou(e,t)),Fr(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),It(n)&&(t=ou(e,t+1+r+1))}return t}function Fa(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}yn(n,Xo(e,t+1))&&(t=Ar(e,t))}return t}function Ea(e){if(e.length===1&&!bn(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 Qo=["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 Jo(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var ox=10,tI=12,ix=13;function sx(e){let t=e.source,n=t.length,r=t.length>0?va(t.charCodeAt(0)):0,o=Jo(e.lines,n),i=Jo(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===ox||c===ix||c===tI)&&(c===ix&&u+1<n&&t.charCodeAt(u+1)===ox&&(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 Aa=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||sx(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||sx(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]}}}};var rr=16777215,or=24,Ji=1,La=2,Xr=new Uint8Array(32);Xr[2]=22;Xr[21]=22;Xr[19]=20;Xr[23]=24;var ir=new Uint8Array(32);ir[2]=Ji;ir[21]=Ji;ir[19]=Ji;ir[23]=Ji;ir[22]=La;ir[20]=La;ir[24]=La;function ax(e,t,n){return e<t?t:e>n?n:e}var Pa=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=Jo(this.offsetAndType,t.length+1),i=Jo(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,p,f)=>{let d=s++;if(o[d]=l<<or|f,a===-1&&(a=p),i[d]=c,l===u){let h=i[c];i[c]=d,c=h,u=Xr[o[h]>>or]}else this.isBlockOpenerTokenType(l)&&(c=d,u=Xr[l])}),o[s]=0<<or|r,i[s]=s;for(let l=0;l<s;l++){let p=i[l];if(p<=l){let f=i[p];f!==l&&(i[l]=f)}else p>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]>>or:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>or;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&rr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>or;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?Er(this.source,this.offsetAndType[t-1]&rr,this.offsetAndType[t]&rr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&rr:this.offsetAndType[this.tokenCount]&rr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[ax(t,0,this.tokenCount)]&rr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[ax(t,0,this.tokenCount)]>>or}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return ir[t]===Ji}isBlockCloserTokenType(t){return ir[t]===La}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(ir[n]===1){let r=this.balance[t],o=this.getTokenType(r);return Xr[n]===o?r:-1}else if(ir[n]===2){let r=this.balance[t],o=this.getTokenType(r);return Xr[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]&rr,n=this.offsetAndType[n],this.tokenType=n>>or,this.tokenEnd=n&rr):(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>>or,this.tokenEnd=t&rr):(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]&rr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>or)&&(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&rr,a=i>>or;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:Qo[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}};function Qr(e,t){function n(p){return p<a?e.charCodeAt(p):0}function r(){if(c=Co(e,c),Ko(n(c),n(c+1),n(c+2))){l=12,c=Qi(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let p=c;if(c=Qi(e,c),Er(e,p,c,"url")&&n(c)===40){if(c=Xi(e,c+1),n(c)===34||n(c)===39){l=2,c=p+4;return}s();return}if(n(c)===40){l=2,c++;return}l=1}function i(p){for(p||(p=n(c++)),l=5;c<e.length;c++){let f=e.charCodeAt(c);switch(Ta(f)){case p:c++;return;case Ki:if(Yi(f)){c+=Ia(e,c,f),l=6;return}break;case 92:if(c===e.length-1)break;let d=n(c+1);Yi(d)?c+=Ia(e,c+1,d):yn(f,d)&&(c=Ar(e,c)-1);break}}}function s(){for(l=7,c=Xi(e,c);c<e.length;c++){let p=e.charCodeAt(c);switch(Ta(p)){case 41:c++;return;case Ki:if(c=Xi(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=Fa(e,c),l=8;return;case 34:case 39:case 40:case ru:c=Fa(e,c),l=8;return;case 92:if(yn(p,n(c+1))){c=Ar(e,c)-1;break}c=Fa(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=va(n(0)),c=u,l;for(;c<a;){let p=e.charCodeAt(c);switch(Ta(p)){case Ki:l=13,c=Xi(e,c+1);break;case 34:i();break;case 35:wa(n(c+1))||yn(n(c+1),n(c+2))?(l=4,c=Qi(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:ka(p,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:ka(p,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):Ko(p,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:ka(p,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:Ko(n(c+1),n(c+2),n(c+3))?(l=3,c=Qi(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:yn(p,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 nu:r();break;case Ca:o();break;default:l=9,c++}t(l,u,u=c)}}var Zo=null,Ln=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 Zo!==null?(r=Zo,Zo=Zo.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=Zo,Zo=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 Io(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}
4
+ `)}})}var iu=100,lx=60,cx=" ";function ux({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(h,S){return c.slice(h,S).map((C,F)=>String(h+F+1).padStart(f)+" |"+C).join(`
5
+ `)}let a=`
6
+ `.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,p=Math.min(t+i,c.length+1),f=Math.max(4,String(p).length)+1,d=0;n+=(cx.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>iu&&(d=n-lx+3,n=lx-2);for(let h=l;h<=p;h++)h>=0&&h<c.length&&(c[h]=c[h].replace(/\t/g,cx),c[h]=(d>0&&c[h].length>d?"\u2026":"")+c[h].substr(d,iu-2)+(c[h].length>d+iu-1?"\u2026":""));return[s(l,t),new Array(n+f+2).join("-")+"^",s(t,p)].filter(Boolean).join(`
7
+ `).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function su(e,t,n,r,o,i=1,s=1){return Object.assign(Io("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return ux({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
8
+ `+ux({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}function px(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 ei=()=>{},nI=33,rI=35,au=59,dx=123,fx=0,oI={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}},iI={createList(){return new Ln},createSingleNodeList(e){return new Ln().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}};function sI(e){return function(){return this[e]()}}function lu(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 aI(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:lu(e.atrule),pseudo:lu(e.pseudo),node:lu(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]=sI(r);break}return{config:t,...t,...t.node}}function gx(e){let t="",n="<unknown>",r=!1,o=ei,i=!1,s=new Aa,a=Object.assign(new Pa,aI(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:px,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===dx?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===dx||l===au?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===nI||l===au?1:0},consumeUntilSemicolonIncluded(l){return l===au?2:0},createList:ei,createSingleNodeList:ei,getFirstListNode:ei,getLastListNode:ei,parseWithFallback(l,p){let f=this.tokenIndex;try{return l.call(this)}catch(d){if(i)throw d;this.skip(f-this.tokenIndex);let h=p.call(this);return i=!0,o(d,h),i=!1,h}},lookupNonWSType(l){let p;do if(p=this.lookupType(l++),p!==13&&p!==25)return p;while(p!==fx);return fx},charCodeAt(l){return l>=0&&l<t.length?t.charCodeAt(l):0},substring(l,p){return t.substring(l,p)},substrToCursor(l){return this.source.substring(l,this.tokenStart)},cmpChar(l,p){return Fr(t,l,p)},cmpStr(l,p,f){return Er(t,l,p,f)},consume(l){let p=this.tokenStart;return this.eat(l),this.substrToCursor(p)},consumeFunctionName(){let l=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),l},consumeNumber(l){let p=t.substring(this.tokenStart,Co(t,this.tokenStart));return this.eat(l),p},eat(l){if(this.tokenType!==l){let p=Qo[l].slice(0,-6).replace(/-/g," ").replace(/^./,h=>h.toUpperCase()),f=`${/[[\](){}]/.test(p)?`"${p}"`:p} is expected`,d=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(d=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(rI)&&(this.next(),d++,f="Name is expected");break;case 11:this.tokenType===10&&(d=this.tokenEnd,f="Percent sign is expected");break}this.error(f,d)}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,p){return r?s.getLocationRange(l,p,n):null},getLocationFromList(l){if(r){let p=this.getFirstListNode(l),f=this.getLastListNode(l);return s.getLocationRange(p!==null?p.loc.start.offset-s.startOffset:this.tokenStart,f!==null?f.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,p){let f=typeof p<"u"&&p<t.length?s.getLocation(p):this.eof?s.getLocation(rx(t,t.length-1)):s.getLocation(this.tokenStart);throw new su(l||"Unexpected input",t,f.offset,f.line,f.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>Qo[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,p)=>a.source.substring(l,p),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,p)=>s.getLocationRange(l,p,n)});return Object.assign(function(l,p){t=l,p=p||{},a.setSource(t,Qr),s.setSource(t,p.offset,p.line,p.column),n=p.filename||"<unknown>",r=!!p.positions,o=typeof p.onParseError=="function"?p.onParseError:ei,i=!1,a.parseAtrulePrelude="parseAtrulePrelude"in p?!!p.parseAtrulePrelude:!0,a.parseRulePrelude="parseRulePrelude"in p?!!p.parseRulePrelude:!0,a.parseValue="parseValue"in p?!!p.parseValue:!0,a.parseCustomProperty="parseCustomProperty"in p?!!p.parseCustomProperty:!1;let{context:f="default",list:d=!0,onComment:h,onToken:S}=p;if(!(f in a.context))throw new Error("Unknown context `"+f+"`");Object.assign(a,d?iI:oI),Array.isArray(S)?a.forEachToken((F,T,R)=>{S.push({type:F,start:T,end:R})}):typeof S=="function"&&a.forEachToken(S.bind(u())),typeof h=="function"&&a.forEachToken((F,T,R)=>{if(F===25){let z=a.getLocation(T,R),N=Er(t,R-2,R,"*/")?t.slice(T+2,R-2):t.slice(T+2,R);h(N,z)}});let C=a.context[f].call(a,p);return a.eof||a.error(),C},{SyntaxError:su,config:a.config})}var Rx=oa(Bx(),1),Dx=new Set(["Atrule","Selector","Declaration"]);function zx(e){let t=new Rx.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},i={generated:o},s=1,a=0,u=!1,c=e.node;e.node=function(f){if(f.loc&&f.loc.start&&Dx.has(f.type)){let d=f.loc.start.line,h=f.loc.start.column-1;(r.line!==d||r.column!==h)&&(r.line=d,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:f.loc.source,original:r,generated:n}))}c.call(this,f),u&&Dx.has(f.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(f,d,h){for(let S=0;S<f.length;S++)f.charCodeAt(S)===10?(s++,a=0):a++;l(f,d,h)};let p=e.result;return e.result=function(){return u&&t.addMapping(i),{css:p(),map:t}},e}var za={};xe(za,{safe:()=>hu,spec:()=>AI});var II=43,FI=45,mu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),Nx=[[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],["/","*"]],EI=Nx.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,"-"]]);function Ox(e){let t=new Set(e.map(([n,r])=>mu(n)<<16|mu(r)));return function(n,r,o){let i=mu(r,o),s=o.charCodeAt(0),a=s===FI&&r!==1&&r!==2&&r!==15||s===II?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var AI=Ox(Nx),hu=Ox(EI);var PI=92;function LI(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 _x(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:hu,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)===PI&&this.emit(`
9
+ `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=zx(s)),r.mode in za&&(s.tokenBefore=za[r.mode]));let a={node:u=>s.node(u),children:LI,token:(u,c)=>s.token(u,c),tokenize:u=>Qr(u,(c,l,p)=>{s.token(c,u.slice(l,p),l!==0)})};return s.node(n),s.result()}}function $x(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Ln)&&(n.children=new Ln().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Ln&&(n.children=n.children.toArray())}}),t}}}var{hasOwnProperty:xu}=Object.prototype,ns=function(){};function Ux(e){return typeof e=="function"?e:ns}function jx(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function MI(e,t){let n=t.structure,r=[];for(let o in n){if(xu.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 BI(e){let t={};for(let n in e.node)if(xu.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]=MI(n,r)}return t}function Hx(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 p=i[l.name];if(!l.nullable||p){if(l.type==="list"){if(t?p.reduceRight(u,!1):p.reduce(u,!1))return!0}else if(a(p))return!0}}o&&(s[r]=c)}}function Wx({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 Vx(e){let t=BI(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)xu.call(t,c)&&t[c]!==null&&(n[c]=Hx(t[c],!1),r[c]=Hx(t[c],!0));let s=Wx(n),a=Wx(r),u=function(c,l){function p(F,T,R){let z=f.call(C,F,T,R);return z===o?!0:z===i?!1:!!(h.hasOwnProperty(F.type)&&h[F.type](F,C,p,S)||d.call(C,F,T,R)===o)}let f=ns,d=ns,h=n,S=(F,T,R,z)=>F||p(T,R,z),C={break:o,skip:i,root:c,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")f=l;else if(l&&(f=Ux(l.enter),d=Ux(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(", ")+")");f=jx(f,l.visit),d=jx(d,l.visit)}if(f===ns&&d===ns)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");p(c)};return u.break=o,u.skip=i,u.find=function(c,l){let p=null;return u(c,function(f,d,h){if(l.call(this,f,d,h))return p=f,o}),p},u.findLast=function(c,l){let p=null;return u(c,{reverse:!0,enter(f,d,h){if(l.call(this,f,d,h))return p=f,o}}),p},u.findAll=function(c,l){let p=[];return u(c,function(f,d,h){l.call(this,f,d,h)&&p.push(f)}),p},u}function DI(e){return e}function RI(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 zI(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 NI(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>Na(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function Na(e,t,n,r){let o;switch(e.type){case"Group":o=NI(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return Na(e.term,t,n,r)+t(RI(e),e);case"Boolean":o="<boolean-expr["+Na(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(zI(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 ni(e,t){let n=DI,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),Na(e,n,r,o)}var Gx={offset:0,line:1,column:1};function OI(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,p;for(let f=0;f<n.length;f++){let d=n[f].value;f===r&&(a=d.length,s=c.length),i!==null&&n[f].node===i&&(f<=r?u++:u=0),c+=d}return r===n.length||u>1?(l=Oa(i||t,"end")||rs(Gx,c),p=rs(l)):(l=Oa(i,"start")||rs(Oa(t,"start")||Gx,c.slice(0,s)),p=Oa(i,"end")||rs(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:p}}function Oa(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?rs(n):n:null}function rs({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 ri=function(e,t){let n=Io("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},qx=function(e,t,n,r){let o=Io("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=OI(r,n);return o.rawMessage=e,o.syntax=t?ni(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=a,o.message=e+`
10
+ syntax: `+o.syntax+`
11
+ value: `+(i||"<empty string>")+`
12
+ --------`+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};var _a=new Map,oi=new Map,$a=45,Ua=_I,yu=$I;function ja(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===$a&&e.charCodeAt(t+1)===$a}function Yx(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===$a&&e.charCodeAt(t+1)!==$a){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function _I(e){if(_a.has(e))return _a.get(e);let t=e.toLowerCase(),n=_a.get(t);if(n===void 0){let r=ja(t,0),o=r?"":Yx(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return _a.set(e,n),n}function $I(e){if(oi.has(e))return oi.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=ja(t,n.length);if(!r&&(t=t.toLowerCase(),oi.has(t))){let a=oi.get(t);return oi.set(e,a),a}let o=r?"":Yx(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 oi.set(e,s),s}var ii=["initial","inherit","unset","revert","revert-layer"];var is=43,br=45,bu=110,si=!0,jI=!1;function wu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function os(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function Jr(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===is||o===br){if(n)return 0;t++}for(;t<e.value.length;t++)if(!It(e.value.charCodeAt(t)))return 0;return r+1}function Su(e,t,n){let r=!1,o=os(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(wu(e,is)||wu(e,br)){if(r=!0,o=os(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!==is&&i!==br)return 0}return Jr(e,r?0:1,r,o)}function ku(e,t){let n=0;if(!e)return 0;if(e.type===10)return Jr(e,0,jI,n);if(e.type===1&&e.value.charCodeAt(0)===br){if(!Fr(e.value,1,bu))return 0;switch(e.value.length){case 2:return Su(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==br?0:(n=os(t(++n),n,t),e=t(n),Jr(e,0,si,n));default:return e.value.charCodeAt(2)!==br?0:Jr(e,3,si,n)}}else if(e.type===1||wu(e,is)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Fr(e.value,0,bu))return 0;switch(e.value.length){case 1:return Su(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==br?0:(n=os(t(++n),n,t),e=t(n),Jr(e,0,si,n));default:return e.value.charCodeAt(1)!==br?0:Jr(e,2,si,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===is||r===br?1:0,i=o;for(;i<e.value.length&&It(e.value.charCodeAt(i));i++);return i===o||!Fr(e.value,i,bu)?0:i+1===e.value.length?Su(t(++n),n,t):e.value.charCodeAt(i+1)!==br?0:i+2===e.value.length?(n=os(t(++n),n,t),e=t(n),Jr(e,0,si,n)):Jr(e,i+2,si,n)}return 0}var HI=43,Kx=45,Xx=63,WI=117;function vu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function VI(e,t){return e.value.charCodeAt(0)===t}function ss(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===Kx&&n&&r!==0)return ss(e,t+r+1,!1),6;if(!bn(i)||++r>6)return 0}return r}function Ha(e,t,n){if(!e)return 0;for(;vu(n(t),Xx);){if(++e>6)return 0;t++}return t}function Cu(e,t){let n=0;if(e===null||e.type!==1||!Fr(e.value,0,WI)||(e=t(++n),e===null))return 0;if(vu(e,HI))return e=t(++n),e===null?0:e.type===1?Ha(ss(e,0,!0),++n,t):vu(e,Xx)?Ha(1,++n,t):0;if(e.type===10){let r=ss(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!VI(e,Kx)||!ss(e,1,!1)?0:n+1:Ha(r,n,t))}return e.type===12?Ha(ss(e,1,!0),++n,t):0}var Tu=["calc(","-moz-calc(","-webkit-calc("],Iu=["min(","max(","clamp("],Fu=["round(","mod(","rem("],GI=["sin(","cos(","tan("],qI=["asin(","acos(","atan(","atan2("],YI=["pow(","sqrt(","log(","exp(","sign("],Eu=["hypot("],Au=["abs("],Qx=[...Tu,...Iu,...Fu,...GI,...YI,...Eu,...Au],KI=[...Tu,...Iu,...Fu,...Eu,...Au],Mr=[...Tu,...Iu,...Fu,...qI,...Eu,...Au],Pu=new Map([[2,22],[21,22],[19,20],[23,24]]);function ar(e,t){return t<e.length?e.charCodeAt(t):0}function Jx(e,t){return Er(e,0,e.length,t)}function Zx(e,t){for(let n=0;n<t.length;n++)if(Jx(e,t[n]))return!0;return!1}function ey(e,t){return t!==e.length-2?!1:ar(e,t)===92&&It(ar(e,t+1))}function Wa(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 XI(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=Pu.get(e.type);break}o++}while(e=t(o));return o}function Yn(e,t){return function(n,r,o){return n===null?0:n.type===2&&Zx(n.value,t)?XI(n,r):e(n,r,o)}}function mt(e){return function(t){return t===null||t.type!==e?0:1}}function QI(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return Zx(t,ii)||Jx(t,"default")?0:1}function ty(e){return e===null||e.type!==1||ar(e.value,0)!==45||ar(e.value,1)!==45?0:1}function JI(e){return!ty(e)||e.value==="--"?0:1}function ZI(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(!bn(ar(e.value,n)))return 0;return 1}function eF(e){return e===null||e.type!==4||!Ko(ar(e.value,1),ar(e.value,2),ar(e.value,3))?0:1}function tF(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=Pu.get(e.type);break}o++}while(e=t(o));return o}function nF(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=Pu.get(e.type);break}o++}while(e=t(o));return o}function Br(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Co(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!ey(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return Wa(r,t.value,o)?0:1}}function rF(e,t,n){return e===null||e.type!==11||Wa(n,e.value,e.value.length-1)?0:1}function ny(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 oF(e,t,n){if(e===null)return 0;let r=Co(e.value,0);return!(r===e.value.length)&&!ey(e.value,r)||Wa(n,e.value,r)?0:1}function iF(e,t,n){if(e===null||e.type!==10)return 0;let r=ar(e.value,0)===43||ar(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!It(ar(e.value,r)))return 0;return Wa(n,e.value,r)?0:1}var sF={"ident-token":mt(1),"function-token":mt(2),"at-keyword-token":mt(3),"hash-token":mt(4),"string-token":mt(5),"bad-string-token":mt(6),"url-token":mt(7),"bad-url-token":mt(8),"delim-token":mt(9),"number-token":mt(10),"percentage-token":mt(11),"dimension-token":mt(12),"whitespace-token":mt(13),"CDO-token":mt(14),"CDC-token":mt(15),"colon-token":mt(16),"semicolon-token":mt(17),"comma-token":mt(18),"[-token":mt(19),"]-token":mt(20),"(-token":mt(21),")-token":mt(22),"{-token":mt(23),"}-token":mt(24)},aF={string:mt(5),ident:mt(1),percentage:Yn(rF,KI),zero:ny(),number:Yn(oF,Qx),integer:Yn(iF,Qx),"custom-ident":QI,"dashed-ident":ty,"custom-property-name":JI,"hex-color":ZI,"id-selector":eF,"an-plus-b":ku,urange:Cu,"declaration-value":tF,"any-value":nF},lF=["length","angle","time","frequency","resolution","flex","decibel","semitones"];function cF(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:Yn(Br(null),Mr),angle:Yn(Br(t),Mr),decibel:Yn(Br(n),Mr),frequency:Yn(Br(r),Mr),flex:Yn(Br(o),Mr),length:Yn(ny(Br(i)),Mr),resolution:Yn(Br(s),Mr),semitones:Yn(Br(a),Mr),time:Yn(Br(u),Mr)}}function uF(e){let t=new Set;for(let n of lF)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 ry(e){return{...sF,...aF,...cF(e),"attr-unit":uF(e)}}var Va={};xe(Va,{angle:()=>dF,decibel:()=>xF,flex:()=>hF,frequency:()=>gF,length:()=>pF,resolution:()=>mF,semitones:()=>yF,time:()=>fF});var pF=["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"],dF=["deg","grad","rad","turn"],fF=["s","ms"],gF=["hz","khz"],mF=["dpi","dpcm","dppx","x"],hF=["fr"],xF=["db"],yF=["st"];function oy(e,t,n){return Object.assign(Io("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
13
+ `+t+`
14
+ --`+new Array((n||t.length)+1).join("-")+"^"})}var bF=9,SF=10,wF=12,kF=13,vF=32,iy=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),Ga=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&&iy[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!==kF&&n!==SF&&n!==wF&&n!==vF&&n!==bF)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 oy(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||iy[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)}};var CF=9,TF=10,IF=12,FF=13,EF=32,dy=33,Du=35,sy=38,qa=39,fy=40,gy=41,my=42,Ru=43,zu=44,ay=45,Nu=60,Mu=62,Ya=63,AF=64,as=91,ai=93,Ka=123,ly=124,Bu=125,cy=8734,uy={" ":1,"&&":2,"||":3,"|":4};function py(e){let t=null,n=null;return e.eat(Ka),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===zu?(e.pos++,e.skipWs(),e.charCode()!==Bu&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(Bu),{min:Number(t),max:n?Number(n):0}}function PF(e){let t=null,n=!1;switch(e.charCode()){case my:e.pos++,t={min:0,max:0};break;case Ru:e.pos++,t={min:1,max:0};break;case Ya:e.pos++,t={min:0,max:1};break;case Du:e.pos++,n=!0,e.charCode()===Ka?t=py(e):e.charCode()===Ya?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Ka:t=py(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Dr(e,t){let n=PF(e);return n!==null?(n.term=t,e.charCode()===Du&&e.charCodeAt(e.pos-1)===Ru||e.charCode()===Ya&&e.charCodeAt(e.pos-1)===Bu?Dr(e,n):n):t}function Lu(e){let t=e.peek();return t===""?null:Dr(e,{type:"Token",value:t})}function LF(e){let t;return e.eat(Nu),e.eat(qa),t=e.scanWord(),e.eat(qa),e.eat(Mu),Dr(e,{type:"Property",name:t})}function MF(e){let t=null,n=null,r=1;return e.eat(as),e.charCode()===ay&&(e.peek(),r=-1),r==-1&&e.charCode()===cy?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(zu),e.skipWs(),e.charCode()===cy?e.peek():(r=1,e.charCode()===ay&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(ai),{type:"Range",min:t,max:n}}function BF(e){let t,n=null;if(e.eat(Nu),t=e.scanWord(),t==="boolean-expr"){e.eat(as);let r=Xa(e,ai);return e.eat(ai),e.eat(Mu),Dr(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===fy&&e.nextCharCode()===gy&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===as&&(e.skipWs(),n=MF(e)),e.eat(Mu),Dr(e,{type:"Type",name:t,opts:n})}function DF(e){let t=e.scanWord();return e.charCode()===fy?(e.pos++,{type:"Function",name:t}):Dr(e,{type:"Keyword",name:t})}function RF(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)=>uy[o]-uy[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 Xa(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?Xa(e,gy):NF(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:RF(r,n)||" ",disallowEmpty:!1,explicit:!1}}function zF(e){let t;return e.eat(as),t=Xa(e,ai),e.eat(ai),t.explicit=!0,e.charCode()===dy&&(e.pos++,t.disallowEmpty=!0),t}function NF(e){let t=e.charCode();switch(t){case ai:break;case as:return Dr(e,zF(e));case Nu:return e.nextCharCode()===qa?LF(e):BF(e);case ly:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===ly?2:1))};case sy:return e.pos++,e.eat(sy),{type:"Combinator",value:"&&"};case zu:return e.pos++,{type:"Comma"};case qa:return Dr(e,{type:"String",value:e.scanString()});case EF:case CF:case TF:case FF:case IF:return{type:"Spaces",value:e.scanSpaces()};case AF:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):Lu(e);case my:case Ru:case Ya:case Du:case dy:break;case Ka:if(t=e.nextCharCode(),t<48||t>57)return Lu(e);break;default:return e.isNameCharCode(t)?DF(e):Lu(e)}}function ls(e){let t=new Ga(e),n=Xa(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var cs=function(){};function hy(e){return typeof e=="function"?e:cs}function Ou(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=cs,i=cs;if(typeof t=="function"?o=t:t&&(o=hy(t.enter),i=hy(t.leave)),o===cs&&i===cs)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var _F={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 $F(e){let t=[];return Qr(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function xy(e,t){return typeof e=="string"?$F(e):t.generate(e,_F)}var nt={type:"Match"},at={type:"Mismatch"},Qa={type:"DisallowEmpty"},UF=40,jF=41;function sn(e,t,n){return t===nt&&n===at||e===nt&&t===nt&&n===nt?e:(e.type==="If"&&e.else===at&&t===nt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function by(e){return e.length>2&&e.charCodeAt(e.length-2)===UF&&e.charCodeAt(e.length-1)===jF}function yy(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&by(e.name)}function Zr(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function us(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=us(e.match,t,n),e.then=us(e.then,t,n),e.else=us(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function _u(e,t,n){switch(e){case" ":{let r=nt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=sn(i,r,at)}return r}case"|":{let r=at,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(yy(s)&&(o===null&&i>0&&yy(t[i-1])&&(o=Object.create(null),r=sn({type:"Enum",map:o},nt,r)),o!==null)){let a=(by(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=sn(s,nt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=at;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=_u(e,t.filter(function(a){return a!==i}),!1):s=nt,r=sn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?nt:at;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=_u(e,t.filter(function(a){return a!==i}),!0):s=nt,r=sn(i,s,r)}return r}}}function HF(e){let t=nt,n=li(e.term);if(e.max===0)n=sn(n,Qa,at),t=sn(n,null,at),t.then=sn(nt,nt,t),e.comma&&(t.then.else=sn({type:"Comma",syntax:e},t,at));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==nt&&(t=sn({type:"Comma",syntax:e},t,at)),t=sn(n,sn(nt,nt,t),at);if(e.min===0)t=sn(nt,nt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==nt&&(t=sn({type:"Comma",syntax:e},t,at)),t=sn(n,t,at);return t}function li(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=_u(e.combinator,e.terms.map(li),!1);return e.disallowEmpty&&(t=sn(t,Qa,at)),t}case"Multiplier":return HF(e);case"Boolean":{let t=li(e.term),n=li(Zr([Zr([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),Zr([{type:"Type",name:"!boolean-group"},Zr([{type:"Multiplier",comma:!1,min:0,max:0,term:Zr([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:Zr([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=li(Zr([{type:"Type",name:"!term"},Zr([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return us(r,{"!term":t,"!self":n}),us(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 ps(e,t){return typeof e=="string"&&(e=ls(e)),{type:"MatchGraph",match:li(e),syntax:t||null,source:e}}var{hasOwnProperty:Sy}=Object.prototype,WF=0,VF=1,Uu=2,Ty=3,wy="Match",GF="Mismatch",qF="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",ky=15e3,YF=0;function KF(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function $u(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 XF(e){return e.type!==9?!1:e.value!=="?"}function vy(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||XF(e)}function Cy(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function QF(e,t,n){function r(){do T++,F=T<e.length?e[T]:null;while(F!==null&&(F.type===13||F.type===25))}function o(N){let E=T+N;return E<e.length?e[E]:null}function i(N,E){return{nextState:N,matchStack:z,syntaxStack:p,thenStack:f,tokenIndex:T,prev:E}}function s(N){f={nextState:N,matchStack:z,syntaxStack:p,prev:f}}function a(N){d=i(N,d)}function u(){z={type:VF,syntax:t.syntax,token:F,prev:z},r(),h=null,T>R&&(R=T)}function c(){p={syntax:t.syntax,opts:t.syntax.opts||p!==null&&p.opts||null,prev:p},z={type:Uu,syntax:t.syntax,token:z.token,prev:z}}function l(){z.type===Uu?z=z.prev:z={type:Ty,syntax:p.syntax,token:z.token,prev:z},p=p.prev}let p=null,f=null,d=null,h=null,S=0,C=null,F=null,T=-1,R=0,z={type:WF,syntax:null,token:null,prev:null};for(r();C===null&&++S<ky;)switch(t.type){case"Match":if(f===null){if(F!==null&&(T!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=at;break}C=wy;break}if(t=f.nextState,t===Qa)if(f.matchStack===z){t=at;break}else t=nt;for(;f.syntaxStack!==p;)l();f=f.prev;break;case"Mismatch":if(h!==null&&h!==!1)(d===null||T>d.tokenIndex)&&(d=h,h=!1);else if(d===null){C=GF;break}t=d.nextState,f=d.thenStack,p=d.syntaxStack,z=d.matchStack,T=d.tokenIndex,F=T<e.length?e[T]:null,d=d.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==at&&a(t.else),t.then!==nt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let M=t.syntax.terms;if(t.index===M.length){if(t.mask===0||t.syntax.all){t=at;break}t=nt;break}if(t.mask===(1<<M.length)-1){t=nt;break}for(;t.index<M.length;t.index++){let g=1<<t.index;if((t.mask&g)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|g}),t=M[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let M=F.value.toLowerCase();if(M.indexOf("\\")!==-1&&(M=M.replace(/\\[09].*$/,"")),Sy.call(t.map,M)){t=t.map[M];break}}t=at;break;case"Generic":{let M=p!==null?p.opts:null,g=T+Math.floor(t.fn(F,o,M));if(!isNaN(g)&&g>T){for(;T<g;)u();t=nt}else t=at;break}case"Type":case"Property":{let M=t.type==="Type"?"types":"properties",g=Sy.call(n,M)?n[M][t.name]:null;if(!g||!g.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,d)),t=at;break}c(),t=g.matchRef||g.match;break}case"Keyword":{let M=t.name;if(F!==null){let g=F.value;if(g.indexOf("\\")!==-1&&(g=g.replace(/\\[09].*$/,"")),$u(g,M)){u(),t=nt;break}}t=at;break}case"AtKeyword":case"Function":if(F!==null&&$u(F.value,t.name)){u(),t=nt;break}t=at;break;case"Token":if(F!==null&&F.value===t.value){u(),t=nt;break}t=at;break;case"Comma":F!==null&&F.type===18?vy(z.token)?t=at:(u(),t=Cy(F)?at:nt):t=vy(z.token)||Cy(F)?nt:at;break;case"String":let N="",E=T;for(;E<e.length&&N.length<t.value.length;E++)N+=e[E].value;if($u(N,t.value)){for(;T<E;)u();t=nt}else t=at;break;default:throw new Error("Unknown node type: "+t.type)}switch(YF+=S,C){case null:console.warn("[csstree-match] BREAK after "+ky+" iterations"),C=qF,z=null;break;case wy:for(;p!==null;)l();break;default:z=null}return{tokens:e,reason:C,iterations:S,match:z,longestMatch:R}}function ju(e,t,n){let r=QF(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=KF(o).prev;o!==null;){switch(o.type){case Uu:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case Ty: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 Wu={};xe(Wu,{getTrace:()=>Iy,isKeyword:()=>eE,isProperty:()=>ZF,isType:()=>JF});function Iy(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 JF(e,t){return Hu(this,e,n=>n.type==="Type"&&n.name===t)}function ZF(e,t){return Hu(this,e,n=>n.type==="Property"&&n.name===t)}function eE(e){return Hu(this,e,t=>t.type==="Keyword")}function Hu(e,t,n){let r=Iy.call(e,t);return r===null?!1:r.some(n)}function Fy(e){return"node"in e?e.node:Fy(e.match[0])}function Ey(e){return"node"in e?e.node:Ey(e.match[e.match.length-1])}function Vu(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=Fy(a),c=Ey(a);e.syntax.walk(t,function(l,p,f){if(l===u){let d=new Ln;do{if(d.appendData(p.data),p.data===c)break;p=p.next}while(p!==null);s.push({parent:f,nodes:d})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var{hasOwnProperty:ds}=Object.prototype;function Gu(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function Ay(e){return!!e&&Gu(e.offset)&&Gu(e.line)&&Gu(e.column)}function tE(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(ds.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(!Ay(r.loc.start))i+=".start";else if(!Ay(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 Ln)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)ds.call(t,i)&&ds.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function Py(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<"+(Py(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function nE(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(ds.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=Py(s,e+"."+i)}return{docs:o,check:tE(e,r)}}function Ly(e){let t={};if(e.node){for(let n in e.node)if(ds.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=nE(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}function qu(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:ni(e[o].syntax,{compact:t}));return r}function rE(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:ni(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&qu(i.descriptors,t,n)};return r}function oE(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function iE(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function lr(e,t,n){return{matched:e,iterations:n,error:t,...Wu}}function ci(e,t,n,r){let o=xy(n,e.syntax),i;return oE(o)?lr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=ju(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=ju(o,t.match,e),!i.match)?lr(null,new qx(i.reason,t.syntax,n,i),i.iterations):lr(i.match,null,i.iterations))}var fs=class{constructor(t,n,r){if(this.cssWideKeywords=ii,this.syntax=n,this.generic=!1,this.units={...Va},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||Ly(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(Va))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(ry(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=ps(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=ps(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:ls(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:ps(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=iE(a)?ps({...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 ri("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&&!ci(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=Ua(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 ri("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new ri("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return lr(null,r);let o=this.getAtrule(t);return o.prelude?ci(this,o.prelude,n||"",!1):lr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return lr(null,o);let i=this.getAtrule(t),s=Ua(n);return ci(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?lr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(yu(t).custom)return lr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?lr(null,r):ci(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?ci(this,r,n,!1):lr(null,new ri("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?lr(null,new ri("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),ci(this,t,n,!1))}findValueFragments(t,n,r,o){return Vu(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return Vu(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=Ua(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=yu(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,p){if(l.has(c))return l.get(c);l.set(c,!1),p.syntax!==null&&Ou(p.syntax,function(f){if(f.type!=="Type"&&f.type!=="Property")return;let d=f.type==="Type"?u.types:u.properties,h=f.type==="Type"?o:i;hasOwnProperty.call(d,f.name)?n(u,f.name,h,d[f.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(f.name,f.type==="Type")}`),l.set(c,!0))},this)}let r=[],o=new Map,i=new Map;for(let u in this.types)n(this,u,o,this.types[u]);for(let u in this.properties)n(this,u,i,this.properties[u]);let s=[...o.keys()].filter(u=>o.get(u)),a=[...i.keys()].filter(u=>i.get(u));return s.length||a.length?{errors:r,types:s,properties:a}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:qu(this.types,!n,t),properties:qu(this.properties,!n,t),atrules:rE(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}};function Yu(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function sE(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function Ku(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?sE(i,n):i};return r}function gs(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?Yu(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?Yu(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]=Yu(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=Ku(e[r],o);break;case"atrule":case"pseudo":n[r]=Ku(e[r],o,["parse"]);break;case"node":n[r]=Ku(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}function My(e){let t=gx(e),n=Vx(e),r=_x(e),{fromPlainObject:o,toPlainObject:i}=$x(n),s={lexer:null,createLexer:a=>new fs(a,s,s.lexer.structure),tokenize:Qr,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=gs({},e);return My(typeof a=="function"?a(u):gs(u,a))}};return s.lexer=new fs({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var By=e=>My(gs({},e));var Dy={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 hs={};xe(hs,{AnPlusB:()=>Ju,Atrule:()=>ep,AtrulePrelude:()=>np,AttributeSelector:()=>ip,Block:()=>ap,Brackets:()=>cp,CDC:()=>pp,CDO:()=>fp,ClassSelector:()=>mp,Combinator:()=>xp,Comment:()=>bp,Condition:()=>wp,Declaration:()=>vp,DeclarationList:()=>Ip,Dimension:()=>Ep,Feature:()=>Pp,FeatureFunction:()=>Mp,FeatureRange:()=>Rp,Function:()=>Np,GeneralEnclosed:()=>_p,Hash:()=>Up,IdSelector:()=>Vp,Identifier:()=>Hp,Layer:()=>qp,LayerList:()=>Kp,MediaQuery:()=>Qp,MediaQueryList:()=>Zp,NestingSelector:()=>td,Nth:()=>rd,Number:()=>id,Operator:()=>ad,Parentheses:()=>cd,Percentage:()=>pd,PseudoClassSelector:()=>fd,PseudoElementSelector:()=>md,Ratio:()=>xd,Raw:()=>bd,Rule:()=>wd,Scope:()=>vd,Selector:()=>Td,SelectorList:()=>Fd,String:()=>Pd,StyleSheet:()=>Md,SupportsDeclaration:()=>Dd,TypeSelector:()=>Nd,UnicodeRange:()=>$d,Url:()=>Hd,Value:()=>Vd,WhiteSpace:()=>qd});var Ju={};xe(Ju,{generate:()=>uE,name:()=>lE,parse:()=>Qu,structure:()=>cE});var Sr=43,Mn=45,Ja=110,Eo=!0,aE=!1;function Za(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Sr||r===Mn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)It(this.charCodeAt(n))||this.error("Integer is expected",n)}function ui(e){return Za.call(this,0,e)}function eo(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case Ja:n="N is expected";break;case Mn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Xu(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Sr,e)||this.isDelim(Mn,e)){t=this.isDelim(Sr,e)?Sr:Mn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),ui.call(this,Eo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Sr&&n!==Mn&&this.error("Number sign is expected")),ui.call(this,t!==0),t===Mn?"-"+this.consume(10):this.consume(10)}var lE="AnPlusB",cE={a:[String,null],b:[String,null]};function Qu(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)ui.call(this,aE),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Mn))switch(t="-1",eo.call(this,1,Ja),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Xu.call(this);break;case 3:eo.call(this,2,Mn),this.next(),this.skipSC(),ui.call(this,Eo),n="-"+this.consume(10);break;default:eo.call(this,2,Mn),Za.call(this,3,Eo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Sr)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Sr)&&(r=1,this.next()),eo.call(this,0,Ja),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Xu.call(this);break;case 2:eo.call(this,1,Mn),this.next(),this.skipSC(),ui.call(this,Eo),n="-"+this.consume(10);break;default:eo.call(this,1,Mn),Za.call(this,2,Eo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Sr||r===Mn,i=this.tokenStart+o;for(;i<this.tokenEnd&&It(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),eo.call(this,i-this.tokenStart,Ja),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Xu.call(this)):(eo.call(this,i-this.tokenStart+1,Mn),i+2===this.tokenEnd?(this.next(),this.skipSC(),ui.call(this,Eo),n="-"+this.consume(10)):(Za.call(this,i-this.tokenStart+2,Eo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Sr&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Sr&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function uE(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 ep={};xe(ep,{generate:()=>mE,name:()=>dE,parse:()=>Zu,structure:()=>gE,walkContext:()=>fE});function Ry(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function pE(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}var dE="Atrule",fE="atrule",gE={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function Zu(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),Ry):o=Ry.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(pE.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function mE(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var np={};xe(np,{generate:()=>bE,name:()=>hE,parse:()=>tp,structure:()=>yE,walkContext:()=>xE});var hE="AtrulePrelude",xE="atrulePrelude",yE={children:[[]]};function tp(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 bE(e){this.children(e)}var ip={};xe(ip,{generate:()=>FE,name:()=>TE,parse:()=>op,structure:()=>IE});var SE=36,zy=42,el=61,wE=94,rp=124,kE=126;function vE(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(zy)?(t=!0,this.next()):this.isDelim(rp)||this.eat(1),this.isDelim(rp)?this.charCodeAt(this.tokenStart+1)!==el?(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 CE(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==el&&t!==kE&&t!==wE&&t!==SE&&t!==zy&&t!==rp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==el&&(this.isDelim(el)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}var TE="AttributeSelector",IE={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function op(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=vE.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=CE.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 FE(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 ap={};xe(ap,{generate:()=>BE,name:()=>PE,parse:()=>sp,structure:()=>ME,walkContext:()=>LE});var EE=38;function _y(){return this.Raw(null,!0)}function Ny(){return this.parseWithFallback(this.Rule,_y)}function Oy(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function AE(){if(this.tokenType===17)return Oy.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,Oy);return this.tokenType===17&&this.next(),e}var PE="Block",LE="block",ME={children:[["Atrule","Rule","Declaration"]]};function sp(e){let t=e?AE:Ny,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),_y));break;default:e&&this.isDelim(EE)?r.push(Ny.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function BE(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var cp={};xe(cp,{generate:()=>zE,name:()=>DE,parse:()=>lp,structure:()=>RE});var DE="Brackets",RE={children:[[]]};function lp(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 zE(e){this.token(9,"["),this.children(e),this.token(9,"]")}var pp={};xe(pp,{generate:()=>_E,name:()=>NE,parse:()=>up,structure:()=>OE});var NE="CDC",OE=[];function up(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function _E(){this.token(15,"-->")}var fp={};xe(fp,{generate:()=>jE,name:()=>$E,parse:()=>dp,structure:()=>UE});var $E="CDO",UE=[];function dp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function jE(){this.token(14,"<!--")}var mp={};xe(mp,{generate:()=>GE,name:()=>WE,parse:()=>gp,structure:()=>VE});var HE=46,WE="ClassSelector",VE={name:String};function gp(){return this.eatDelim(HE),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function GE(e){this.token(9,"."),this.token(1,e.name)}var xp={};xe(xp,{generate:()=>JE,name:()=>XE,parse:()=>hp,structure:()=>QE});var qE=43,$y=47,YE=62,KE=126,XE="Combinator",QE={name:String};function hp(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case YE:case qE:case KE:this.next();break;case $y:this.next(),this.eatIdent("deep"),this.eatDelim($y);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function JE(e){this.tokenize(e.name)}var bp={};xe(bp,{generate:()=>rA,name:()=>tA,parse:()=>yp,structure:()=>nA});var ZE=42,eA=47,tA="Comment",nA={value:String};function yp(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===ZE&&this.charCodeAt(t-1)===eA&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function rA(e){this.token(25,"/*"+e.value+"*/")}var wp={};xe(wp,{generate:()=>lA,name:()=>iA,parse:()=>Sp,structure:()=>sA});var oA=new Set([16,22,0]),iA="Condition",sA={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function Uy(e){return this.lookupTypeNonSC(1)===1&&oA.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}var aA={media:Uy,container:Uy,supports(){return this.SupportsDeclaration()}};function Sp(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(()=>aA[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 lA(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var vp={};xe(vp,{generate:()=>SA,name:()=>xA,parse:()=>kp,structure:()=>bA,walkContext:()=>yA});var Hy=33,cA=35,uA=36,pA=38,dA=42,fA=43,jy=47;function gA(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function mA(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function hA(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(Hy)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}var xA="Declaration",yA="declaration",bA={important:[Boolean,String],property:String,value:["Value","Raw"]};function kp(){let e=this.tokenStart,t=this.tokenIndex,n=wA.call(this),r=ja(n),o=r?this.parseCustomProperty:this.parseValue,i=r?mA:gA,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(hA,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(Hy)&&(s=kA.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 SA(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 wA(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case dA:case uA:case fA:case cA:case pA:this.next();break;case jy:this.next(),this.isDelim(jy)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function kA(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var Ip={};xe(Ip,{generate:()=>IA,name:()=>CA,parse:()=>Tp,structure:()=>TA});var vA=38;function Cp(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}var CA="DeclarationList",TA={children:[["Declaration","Atrule","Rule"]]};function Tp(){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),Cp));break;default:this.isDelim(vA)?e.push(this.parseWithFallback(this.Rule,Cp)):e.push(this.parseWithFallback(this.Declaration,Cp))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function IA(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var Ep={};xe(Ep,{generate:()=>AA,name:()=>FA,parse:()=>Fp,structure:()=>EA});var FA="Dimension",EA={value:String,unit:String};function Fp(){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 AA(e){this.token(12,e.value+e.unit)}var Pp={};xe(Pp,{generate:()=>BA,name:()=>LA,parse:()=>Ap,structure:()=>MA});var PA=47,LA="Feature",MA={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function Ap(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(PA)&&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 BA(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var Mp={};xe(Mp,{generate:()=>NA,name:()=>DA,parse:()=>Lp,structure:()=>RA});var DA="FeatureFunction",RA={kind:String,feature:String,value:["Declaration","Selector"]};function zA(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function Lp(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=zA.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 NA(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var Rp={};xe(Rp,{generate:()=>jA,name:()=>$A,parse:()=>Dp,structure:()=>UA});var Wy=47,OA=60,Vy=61,_A=62,$A="FeatureRange",UA={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]};function Bp(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(Wy,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(Wy)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function Gy(e){if(this.skipSC(),this.isDelim(OA)||this.isDelim(_A)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(Vy)?(this.next(),t+"="):t}if(this.isDelim(Vy))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function Dp(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Bp.call(this),r=Gy.call(this,n.type==="Identifier"),o=Bp.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=Gy.call(this),s=Bp.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 jA(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 Np={};xe(Np,{generate:()=>GA,name:()=>HA,parse:()=>zp,structure:()=>VA,walkContext:()=>WA});var HA="Function",WA="function",VA={name:String,children:[[]]};function zp(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 GA(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var _p={};xe(_p,{generate:()=>KA,name:()=>qA,parse:()=>Op,structure:()=>YA});var qA="GeneralEnclosed",YA={kind:String,function:[String,null],children:[[]]};function Op(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 KA(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var Up={};xe(Up,{generate:()=>ZA,name:()=>QA,parse:()=>$p,structure:()=>JA,xxx:()=>XA});var XA="XXX",QA="Hash",JA={value:String};function $p(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function ZA(e){this.token(4,"#"+e.value)}var Hp={};xe(Hp,{generate:()=>nP,name:()=>eP,parse:()=>jp,structure:()=>tP});var eP="Identifier",tP={name:String};function jp(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function nP(e){this.token(1,e.name)}var Vp={};xe(Vp,{generate:()=>iP,name:()=>rP,parse:()=>Wp,structure:()=>oP});var rP="IdSelector",oP={name:String};function Wp(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function iP(e){this.token(9,"#"+e.name)}var qp={};xe(qp,{generate:()=>cP,name:()=>aP,parse:()=>Gp,structure:()=>lP});var sP=46,aP="Layer",lP={name:String};function Gp(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(sP);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function cP(e){this.tokenize(e.name)}var Kp={};xe(Kp,{generate:()=>dP,name:()=>uP,parse:()=>Yp,structure:()=>pP});var uP="LayerList",pP={children:[["Layer"]]};function Yp(){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 dP(e){this.children(e,()=>this.token(18,","))}var Qp={};xe(Qp,{generate:()=>mP,name:()=>fP,parse:()=>Xp,structure:()=>gP});var fP="MediaQuery",gP={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function Xp(){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 mP(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 Zp={};xe(Zp,{generate:()=>yP,name:()=>hP,parse:()=>Jp,structure:()=>xP});var hP="MediaQueryList",xP={children:[["MediaQuery"]]};function Jp(){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 yP(e){this.children(e,()=>this.token(18,","))}var td={};xe(td,{generate:()=>kP,name:()=>SP,parse:()=>ed,structure:()=>wP});var bP=38,SP="NestingSelector",wP={};function ed(){let e=this.tokenStart;return this.eatDelim(bP),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function kP(){this.token(9,"&")}var rd={};xe(rd,{generate:()=>TP,name:()=>vP,parse:()=>nd,structure:()=>CP});var vP="Nth",CP={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function nd(){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 TP(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var id={};xe(id,{generate:()=>EP,name:()=>IP,parse:()=>od,structure:()=>FP});var IP="Number",FP={value:String};function od(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function EP(e){this.token(10,e.value)}var ad={};xe(ad,{generate:()=>LP,name:()=>AP,parse:()=>sd,structure:()=>PP});var AP="Operator",PP={value:String};function sd(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function LP(e){this.tokenize(e.value)}var cd={};xe(cd,{generate:()=>DP,name:()=>MP,parse:()=>ld,structure:()=>BP});var MP="Parentheses",BP={children:[[]]};function ld(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 DP(e){this.token(21,"("),this.children(e),this.token(22,")")}var pd={};xe(pd,{generate:()=>NP,name:()=>RP,parse:()=>ud,structure:()=>zP});var RP="Percentage",zP={value:String};function ud(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function NP(e){this.token(11,e.value+"%")}var fd={};xe(fd,{generate:()=>UP,name:()=>OP,parse:()=>dd,structure:()=>$P,walkContext:()=>_P});var OP="PseudoClassSelector",_P="function",$P={name:String,children:[["Raw"],null]};function dd(){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 UP(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var md={};xe(md,{generate:()=>VP,name:()=>jP,parse:()=>gd,structure:()=>WP,walkContext:()=>HP});var jP="PseudoElementSelector",HP="function",WP={name:String,children:[["Raw"],null]};function gd(){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 VP(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 xd={};xe(xd,{generate:()=>YP,name:()=>GP,parse:()=>hd,structure:()=>qP});var qy=47;function Yy(){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")}}var GP="Ratio",qP={left:["Number","Function"],right:["Number","Function",null]};function hd(){let e=this.tokenStart,t=Yy.call(this),n=null;return this.skipSC(),this.isDelim(qy)&&(this.eatDelim(qy),n=Yy.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function YP(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var bd={};xe(bd,{generate:()=>JP,name:()=>XP,parse:()=>yd,structure:()=>QP});function KP(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}var XP="Raw",QP={value:String};function yd(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=KP.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function JP(e){this.tokenize(e.value)}var wd={};xe(wd,{generate:()=>r2,name:()=>e2,parse:()=>Sd,structure:()=>n2,walkContext:()=>t2});function Ky(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function ZP(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}var e2="Rule",t2="rule",n2={prelude:["SelectorList","Raw"],block:["Block"]};function Sd(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(ZP,Ky):n=Ky.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function r2(e){this.node(e.prelude),this.node(e.block)}var vd={};xe(vd,{generate:()=>s2,name:()=>o2,parse:()=>kd,structure:()=>i2});var o2="Scope",i2={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]};function kd(){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 s2(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 Td={};xe(Td,{generate:()=>c2,name:()=>a2,parse:()=>Cd,structure:()=>l2});var a2="Selector",l2={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]};function Cd(){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 c2(e){this.children(e)}var Fd={};xe(Fd,{generate:()=>f2,name:()=>u2,parse:()=>Id,structure:()=>d2,walkContext:()=>p2});var u2="SelectorList",p2="selector",d2={children:[["Selector","Raw"]]};function Id(){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 f2(e){this.children(e,()=>this.token(18,","))}var Pd={};xe(Pd,{generate:()=>h2,name:()=>g2,parse:()=>Ad,structure:()=>m2});var Ed=92,Xy=34,Qy=39;function tl(e){let t=e.length,n=e.charCodeAt(0),r=n===Xy||n===Qy?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===Ed){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),yn(Ed,a)){let u=s-1,c=Ar(e,u);s=c-1,i+=Ea(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function Jy(e,t){let n=t?"'":'"',r=t?Qy:Xy,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===Ed?(o+="\\"+e.charAt(s),i=!1):(i&&(bn(a)||yr(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var g2="String",m2={value:String};function Ad(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:tl(this.consume(5))}}function h2(e){this.token(5,Jy(e.value))}var Md={};xe(Md,{generate:()=>w2,name:()=>y2,parse:()=>Ld,structure:()=>S2,walkContext:()=>b2});var x2=33;function eb(){return this.Raw(null,!1)}var y2="StyleSheet",b2="stylesheet",S2={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function Ld(){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)!==x2){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,eb);break;default:n=this.parseWithFallback(this.Rule,eb)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function w2(e){this.children(e)}var Dd={};xe(Dd,{generate:()=>C2,name:()=>k2,parse:()=>Bd,structure:()=>v2});var k2="SupportsDeclaration",v2={declaration:"Declaration"};function Bd(){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 C2(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var Nd={};xe(Nd,{generate:()=>E2,name:()=>I2,parse:()=>zd,structure:()=>F2});var T2=42,tb=124;function Rd(){this.tokenType!==1&&this.isDelim(T2)===!1&&this.error("Identifier or asterisk is expected"),this.next()}var I2="TypeSelector",F2={name:String};function zd(){let e=this.tokenStart;return this.isDelim(tb)?(this.next(),Rd.call(this)):(Rd.call(this),this.isDelim(tb)&&(this.next(),Rd.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function E2(e){this.tokenize(e.name)}var $d={};xe($d,{generate:()=>B2,name:()=>L2,parse:()=>_d,structure:()=>M2});var nb=43,rb=45,Od=63;function ms(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===rb&&t&&n!==0)return ms.call(this,e+n+1,!1),-1;bn(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 nl(e){let t=0;for(;this.isDelim(Od);)++t>e&&this.error("Too many question marks"),this.next()}function A2(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===nb?"Plus sign":"Hyphen minus")+" is expected")}function P2(){let e=0;switch(this.tokenType){case 10:if(e=ms.call(this,1,!0),this.isDelim(Od)){nl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){A2.call(this,rb),ms.call(this,1,!1);break}break;case 12:e=ms.call(this,1,!0),e>0&&nl.call(this,6-e);break;default:if(this.eatDelim(nb),this.tokenType===1){e=ms.call(this,0,!0),e>0&&nl.call(this,6-e);break}if(this.isDelim(Od)){this.next(),nl.call(this,5);break}this.error("Hex digit or question mark is expected")}}var L2="UnicodeRange",M2={value:String};function _d(){let e=this.tokenStart;return this.eatIdent("u"),P2.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function B2(e){this.tokenize(e.value)}var Hd={};xe(Hd,{generate:()=>$2,name:()=>O2,parse:()=>jd,structure:()=>_2});var D2=32,Ud=92,R2=34,z2=39,N2=40,ob=41;function ib(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===ob?t-2:t-1,o="";for(;n<r&&yr(e.charCodeAt(n));)n++;for(;n<r&&yr(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Ud){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),yn(Ud,s)){let a=i-1,u=Ar(e,a);i=u-1,o+=Ea(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function sb(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===D2||o===Ud||o===R2||o===z2||o===N2||o===ob?(t+="\\"+e.charAt(r),n=!1):(n&&bn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var O2="Url",_2={value:String};function jd(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=ib(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=tl(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 $2(e){this.token(7,sb(e.value))}var Vd={};xe(Vd,{generate:()=>H2,name:()=>U2,parse:()=>Wd,structure:()=>j2});var U2="Value",j2={children:[[]]};function Wd(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function H2(e){this.children(e)}var qd={};xe(qd,{generate:()=>q2,name:()=>V2,parse:()=>Gd,structure:()=>G2});var W2=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),V2="WhiteSpace",G2={value:String};function Gd(){return this.eat(13),W2}function q2(e){this.token(13,e.value)}var lb={generic:!0,cssWideKeywords:ii,...Dy,node:hs};var Yd={};xe(Yd,{AtrulePrelude:()=>ub,Selector:()=>db,Value:()=>hb});var Y2=35,K2=42,cb=43,X2=45,Q2=47,J2=117;function xs(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,J2)&&this.cmpChar(this.tokenStart+1,cb)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===Q2||t===K2||t===cb||t===X2)return this.Operator();t===Y2&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var ub={getNode:xs};var Z2=35,eL=38,tL=42,nL=43,rL=47,pb=46,oL=62,iL=124,sL=126;function aL(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function lL(){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)===pb&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case nL:case oL:case sL:case rL:return this.Combinator();case pb:return this.ClassSelector();case tL:case iL:return this.TypeSelector();case Z2:return this.IdSelector();case eL:return this.NestingSelector()}break}}}var db={onWhiteSpace:aL,getNode:lL};function fb(){return this.createSingleNodeList(this.Raw(null,!1))}function gb(){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}function mb(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var hb={getNode:xs,onWhiteSpace(e,t){mb(e)&&(e.value=" "+e.value),mb(t.last)&&(t.last.value+=" ")},expression:fb,var:gb};var cL=new Set(["none","and","not","or"]),xb={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);cL.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}};var yb={parse:{prelude:null,block(){return this.Block(!0)}}};function Kd(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 bb={layer(){this.skipSC();let e=this.createList(),t=Kd.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=Kd.call(this,this.Declaration,()=>Kd.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},Sb={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,bb)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,bb)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}};var wb={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}};var kb={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}};var vb={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}};var Cb={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}};var Tb={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}};var Ib={parse:{prelude:null,block(e=!1){return this.Block(e)}}};var Fb={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}};var Eb={container:xb,"font-face":yb,import:Sb,layer:wb,media:kb,nest:vb,page:Cb,scope:Tb,"starting-style":Ib,supports:Fb};function Ab(){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 Ao={parse(){return this.createSingleNodeList(this.SelectorList())}},Xd={parse(){return this.createSingleNodeList(this.Selector())}},uL={parse(){return this.createSingleNodeList(this.Identifier())}},pL={parse:Ab},rl={parse(){return this.createSingleNodeList(this.Nth())}},Pb={dir:uL,has:Ao,lang:pL,matches:Ao,is:Ao,"-moz-any":Ao,"-webkit-any":Ao,where:Ao,not:Ao,"nth-child":rl,"nth-last-child":rl,"nth-last-of-type":rl,"nth-of-type":rl,slotted:Xd,host:Xd,"host-context":Xd};var Qd={};xe(Qd,{AnPlusB:()=>Qu,Atrule:()=>Zu,AtrulePrelude:()=>tp,AttributeSelector:()=>op,Block:()=>sp,Brackets:()=>lp,CDC:()=>up,CDO:()=>dp,ClassSelector:()=>gp,Combinator:()=>hp,Comment:()=>yp,Condition:()=>Sp,Declaration:()=>kp,DeclarationList:()=>Tp,Dimension:()=>Fp,Feature:()=>Ap,FeatureFunction:()=>Lp,FeatureRange:()=>Dp,Function:()=>zp,GeneralEnclosed:()=>Op,Hash:()=>$p,IdSelector:()=>Wp,Identifier:()=>jp,Layer:()=>Gp,LayerList:()=>Yp,MediaQuery:()=>Xp,MediaQueryList:()=>Jp,NestingSelector:()=>ed,Nth:()=>nd,Number:()=>od,Operator:()=>sd,Parentheses:()=>ld,Percentage:()=>ud,PseudoClassSelector:()=>dd,PseudoElementSelector:()=>gd,Ratio:()=>hd,Raw:()=>yd,Rule:()=>Sd,Scope:()=>kd,Selector:()=>Cd,SelectorList:()=>Id,String:()=>Ad,StyleSheet:()=>Ld,SupportsDeclaration:()=>Bd,TypeSelector:()=>zd,UnicodeRange:()=>_d,Url:()=>jd,Value:()=>Wd,WhiteSpace:()=>Gd});var Lb={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:Yd,atrule:Eb,pseudo:Pb,node:Qd};var Mb={node:hs};var Bb=By({...lb,...Lb,...Mb});var{tokenize:J8,parse:Db,generate:Z8,lexer:e9,createLexer:t9,walk:Rb,find:n9,findLast:r9,findAll:o9,toPlainObject:i9,fromPlainObject:s9,fork:a9}=Bb;var fL=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"]);function gL(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Nb(e){try{let t=Db(e.trim(),{context:"value"}),n=[];return Rb(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 mL(e,t){let n=gL(e);if(!fL.has(n))return t;let r=Nb(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 zb(e,t){let n=t.trim();if(!n)return"";let r=mL(e,n);return Nb(r).map(i=>i==="0"?"0px":i).join(" ")}function Ob(e,t,n){let r=zb(e,t),o=zb(e,n);return r!==""&&o!==""&&r===o}function hL(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function xL(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 _b(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=xL(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return hL(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 Po(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),p=c.test(o);if(l!==p)return!1;let f=_b(r),d=_b(o);return!!(f===d||n&&Ob(n,r,o))}var Ub=.5,jb=2,Hb=2,yL=5,bL=["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"],SL=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],wL=["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 kL(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 $b(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 vL(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 CL(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&&kL(n)||$b(r)||$b(o)||n&&vL(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<jb:a<Ub}return r.includes("%")||o.includes("%")?a<1:!1}function TL(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(wL.some(s=>t.includes(s))||!bL.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!Po(o,i,e.property))}function IL(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 FL(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)<Hb}function EL(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(!SL.some(p=>t.includes(p)||n.includes(p)))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]))>yL)}function AL(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 ys(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(Po(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(FL(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${Hb}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(CL(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")?jb:Ub}px)`,dismissedBy:"post-ai-validation"}}return AL(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:TL(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:EL(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:IL(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var _L=["flex","inline-flex"],$L=["grid","inline-grid"],C9=[..._L,...$L];Pe();var ol=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function HL(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function Jd(e,t){let n=[],r=e.split(`
15
+ `);for(let s=0;s<r.length;s++){let a=HL(r[s]),u=ol.exec(a);if(u){let[,c,l,,p]=u,f=WL(l),d=VL(r,s+1),h={id:Kr(),reviewId:t,type:c.trim(),severity:f,title:p.trim(),description:d.description,file:d.file,lineNumber:d.lineNumber,property:d.property,currentValue:d.currentValue,suggestedValue:d.suggestedValue,suggestedCode:d.suggestedCode,suggestedFix:d.suggestedFix,fixTarget:d.fixTarget,fixRequired:d.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(h)}ol.lastIndex=0}return n.map(s=>{let a=ys(s);return a.dismissed?(b.debug(`[parseIssues] Auto-dismissed: ${s.title} - ${a.dismissReason}`),{...s,dismissed:!0,dismissReason:a.dismissReason,dismissedBy:a.dismissedBy,dismissedAt:new Date}):s})}function WL(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function VL(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||ol.test(i)){ol.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}Pe();var bs=null,Vb=0,GL=3e4;async function qL(){let e=Date.now();if(bs&&e-Vb<GL)return bs;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 bs=n.entries||n.stories||{},Vb=e,b.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(bs).length),bs}catch(t){throw b.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ss(e){try{let n=(await qL())[e];if(!n?.importPath)return b.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;b.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),b.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,b.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 b.debug("[storyFilePaths] Final paths:",u),u}catch(t){return b.error("[storyFilePaths] Error getting file paths:",t),null}}function Zd(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function YL(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 ef(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?(b.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):YL(e.type,t)}Pe();function KL(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 XL(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 QL(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 JL(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(p=>p.currentValue).filter(Boolean),l=e.map(p=>p.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 tf(e){if(!e||e.length===0)return[];let t=e.filter(i=>!QL(i)),n=[],r=[];for(let i of t){let s=KL(i),a=XL(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(JL(n,"icon","dimensions"))),o.push(...r),b.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),b.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),b.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}Pe();Ue();import{addons as il}from"storybook/manager-api";var nf="uireview/badge",pi={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function ZL(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function eM(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 tM(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Gb(e){try{il.getChannel().emit(pi.REVIEW_START,{storyId:e})}catch{}}function to(e,t){try{il.getChannel().emit(pi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function qb(e){try{il.getChannel().emit(pi.REVIEW_ERROR,{storyId:e})}catch{}}function Yb(e){let t=il.getChannel();t.on(pi.REVIEW_START,({storyId:n})=>{e.set([{value:"status-value:pending",typeId:nf,storyId:n,title:"Reviewing...",description:"AI review in progress"}])}),t.on(pi.REVIEW_COMPLETE,({storyId:n,summary:r})=>{e.set([{value:ZL(r),typeId:nf,storyId:n,title:tM(r),description:eM(r)}])}),t.on(pi.REVIEW_ERROR,({storyId:n})=>{e.set([{value:"status-value:error",typeId:nf,storyId:n,title:"Review Failed",description:"An error occurred during review"}])})}var of=J(),sf=180;function no(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 af=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:p,setReviewError:f,setReviewResults:d,setShowReviewMenu:h,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:T,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:N,setStreamingStatus:E,setFullPrompt:M,setFullResponse:g,setFigmaImageUrl:k,setStorybookImageUrl:w,setFigmaDimensions:A,setMultiModelResults:m,updateMultiModelStreamingMessages:v,setModelCompleted:I,setActiveModelId:x,resetReview:P,addReview:L,setReviewDetailTab:D,includeTextComparison:O,usePromptCache:y,setApplyFixesResult:U,featureFlags:V}=ye(),{sessionToken:B,setUsageData:X}=ze(),{selectedProjectId:ee}=Ke(),{currentStoryId:Q,currentStoryName:Ee}=Ge(),Te=rf(null),We=rf(null),ot=rf({}),j=ws(($e,it)=>{T({role:$e,content:it})},[T]),ie=ws(($e,it)=>{N($e),E(it)},[N,E]),re=ws(async $e=>{let{isIteration:it=!1,parentReviewId:Ot=null}=$e||{};if(!B)throw new Error("Not authenticated");if(!ee)throw new Error("No project selected");if(!Q||!Ee)throw new Error("No story is currently selected in Storybook");if(e){b.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let zn=Date.now();try{p(!0),f(null),d(null),U(null),Q&&V.enableReviewBadges&&Gb(Q),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{b.debug(`[useAIReview] Auto-stopping review after ${sf}s timeout`),Te.current&&Te.current.abort(),T({role:"system",content:`Review auto-stopped after ${sf} seconds timeout.`})},sf*1e3),M(""),g(""),C(!0),F(!1),z(),ie(0,"Starting review..."),ie(5,"Refreshing component preview..."),b.debug("[Review] Forcing iframe reload for fresh styles..."),await ga(),b.debug("[Review] Iframe reloaded, styles should be fresh"),ie(20,"Capturing screenshot & extracting styles..."),b.debug("[Review] Starting parallel data collection...");let[Qe,le,yt]=await Promise.all([da({sessionToken:B||void 0}),Promise.resolve(Vi()),Promise.resolve(Hc())]);if(Qe&&(w(Qe),b.debug("[Review] Storybook screenshot captured and set")),!le)throw new Error("Failed to extract styles from component");let{computed:fr,declared:se,markup:Ye,textElementStyles:_,nestedElementStyles:$}=le;yt?b.debug("[Review] DOM tree extracted:",{selector:yt.selector,childrenCount:yt.children.length}):(b.error("[Review] DOM tree extraction FAILED - domTree is null"),b.error("[Review] This will cause AI to use comparison table instead of tree comparison")),ie(50,"Preparing metadata..."),b.debug("[Review] Current story:",{id:Q,name:Ee});let W=st.getState().currentMapping?.figmaNodeId??null,Z=st.getState().figmaImageUrl;if(W&&(b.debug("[Review] Using Figma node ID from store:",W),Z&&(ie(65,"Using existing Figma design..."),b.debug("[Review] Reusing already-loaded Figma image"))),!W)try{let et=await fetch(`${of}/api/mappings?projectId=${ee}&storyId=${Q}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${B}`}});if(et.ok){let Tt=await et.json();Tt.mapping?.figmaNodeId?(W=Tt.mapping.figmaNodeId,b.debug("[Review] Found Figma node ID from API:",W)):b.debug("[Review] No mapping found for story:",Q)}else b.debug("[Review] Failed to fetch mapping:",et.status)}catch(et){b.error("[Review] Error fetching mapping:",et)}if(W&&!Z){ie(65,"Fetching Figma design...");try{let et=await fetch(`${of}/api/figma/frames?projectId=${ee}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${B}`}});if(et.ok){let _t=(await et.json()).thumbnails?.[W];_t?(k(_t),b.debug("[Review] Figma thumbnail fetched and displayed:",_t)):b.warn("[Review] No thumbnail found for node:",W)}else b.warn("[Review] Failed to fetch Figma frames:",et.status)}catch(et){b.error("[Review] Error fetching Figma frames:",et)}}if(!W)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');ie(80,"AI is analyzing your component..."),b.debug("[Review] Sending to streaming API...");let Ze={projectId:ee,storyId:Q,storyName:Ee,storybookScreenshot:Qe,computedStyles:fr,declaredStyles:se,textElementStyles:_,nestedElementStyles:$,componentMarkup:Ye,domTree:yt,figmaNodeId:W,figmaImageUrl:Z||void 0,aiModels:l,includeTextComparison:O,usePromptCache:y,parentReviewId:it?Ot:void 0,isIteration:it};b.debug("[Review] Request payload:",{...Ze,storybookScreenshot:Qe?`${Qe.substring(0,50)}...`:null,domTree:yt?{selector:yt.selector,childrenCount:yt.children.length}:null}),Te.current=new AbortController;let jt=await fetch(`${of}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${B}`},body:JSON.stringify(Ze),signal:Te.current.signal});if(b.debug("[Review] Response status:",jt.status,jt.statusText),!jt.ok){let et=await jt.json();if(b.error("[Review] API error response:",et),jt.status===429){let Tt=et.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Tt} seconds before trying again.`)}throw new Error(et.error||et.message||"Review request failed")}let gr=jt.body?.getReader(),er=new TextDecoder,Tr="",fn="",ge=null,mr=null,Nn=l.length>1,yo={},Ri={},Dj={};if(!gr)throw new Error("Response body is not readable");let jm=st.getState().streamingMessages.length;for(j("assistant","");;){let{done:et,value:Tt}=await gr.read();if(et)break;Tr+=er.decode(Tt,{stream:!0});let _t=Tr.split(`
17
+ `);Tr=_t.pop()||"";for(let Fn of _t)if(Fn.startsWith("data: ")){let Qt=Fn.slice(6);if(Qt==="[DONE]")continue;try{let ne=JSON.parse(Qt);if(ne.type!=="text"&&ne.type!=="content"&&b.debug("[Review] SSE Event received:",ne.type),ne.type==="prompt")ne.prompt&&(M(ne.prompt),b.debug("[Review] Prompt received early"));else if(ne.type==="model_started")b.debug("[Review] Model started:",ne.modelId),yo[ne.modelId]||(yo[ne.modelId]="",Ri[ne.modelId]=[{role:"assistant",content:""}]);else if(ne.type==="text"||ne.type==="content")if(Nn&&ne.modelId){yo[ne.modelId]||(yo[ne.modelId]="",Ri[ne.modelId]=[{role:"assistant",content:""}]),yo[ne.modelId]+=ne.content,Ri[ne.modelId][0].content=yo[ne.modelId],v(ne.modelId,Ri[ne.modelId]);let Mt=Object.entries(yo).map(([Jt,Je])=>`[${Jt}]
18
+ ${Je}`).join(`
19
+
20
+ ---
21
+
22
+ `);R(jm,Mt)}else fn+=ne.content,R(jm,fn);else if(ne.type==="model_completed")b.debug("[Review] Model completed:",ne.modelId,ne.complianceScore),I(ne.modelId);else if(ne.type==="figma_image")ne.url&&(k(ne.url),b.debug("[Review] Figma image URL received:",ne.url));else if(ne.type==="figma_dimensions")ne.width&&ne.height&&(A({width:ne.width,height:ne.height}),b.debug("[Review] Figma dimensions received:",ne.width,"x",ne.height));else if(ne.type==="complete"||ne.type==="result")ge=ne,b.debug("[Review] Final result received! Type:",ne.type),b.debug("[Review] Final result issues count:",ne.issues?.length||0),b.debug("[Review] Final result score:",ne.validation?.complianceScore);else if(ne.type==="all_complete")ge=ne,b.debug("[Review] Multi-model results received:",Object.keys(ne.byModel));else if(ne.type==="error"||ne.type==="model_error"){let Mt=new Error(ne.message||ne.error||"Streaming error");throw Mt.isServerError=!0,Mt}}catch(ne){if(ne.isServerError)throw ne;let Mt=ne instanceof Error?{message:ne.message,name:ne.name,stack:ne.stack}:String(ne);b.error("[Review] Error parsing SSE data:",Mt),b.error("[Review] Failed to parse data:",Qt.substring(0,200)+(Qt.length>200?"...":"")),mr=ne instanceof Error?ne:new Error(String(ne))}}}if(ie(100,"Review complete!"),!ge&&mr&&(b.error("[Review] No final result received. Last parse error:",mr),b.error("[Review] Streaming text available:",fn.length,"chars")),Nn&&ge?.type==="all_complete"){let et=Object.keys(ge.byModel).reduce((_t,Fn)=>{let Qt=ge.byModel[Fn];return _t[Fn]={...Qt,fullResponse:Qt.response||Qt.fullResponse||"",fullPrompt:Qt.prompt||Qt.fullPrompt||"",streamingMessages:Ri[Fn]||[]},_t},{}),Tt=Object.keys(ge.byModel)[0];m({byModel:et,activeModelId:Tt}),et[Tt]?.fullPrompt&&M(et[Tt].fullPrompt),b.debug("[Review] Multi-model results stored:",Object.keys(ge.byModel));try{let _t=Kr(),Fn=ge.byModel?.[Tt]?.issues,Qt=Fn&&Fn.length>0,ne=Qt?Fn.map(ae=>({id:Kr(),reviewId:_t,dbId:ae.dbId,type:ae.type,severity:ae.severity,title:ae.description,description:ae.description,property:ae.property,expected:no(ae.expected),actual:no(ae.actual),currentValue:no(ae.actual),suggestedValue:no(ae.expected),source:ae.source||"computed-styles",suggestedFix:ae.suggestedFix,file:ae.file,domElement:ae.domElement,figmaElement:ae.figmaElement,fixTarget:ae.fixTarget,fixRequired:ae.fixRequired,detectedBy:ae.detectedBy,dismissed:ae.dismissed??!1,dismissReason:ae.dismissReason,dismissedAt:ae.dismissed?new Date:void 0,_unreliable:ae._unreliable,_validationError:ae._validationError,figmaContext:ae.figmaContext,relatedTo:Array.isArray(ae.relatedTo)?ae.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Jd(et[Tt]?.fullResponse||"",_t);b.debug("[Review] Multi-model issues source:",Qt?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Multi-model issues count:",ne.length,"issues");let Mt=ne.filter(ae=>ae.dismissed).length;Mt>0&&(b.debug("[Review] Multi-model auto-dismissed:",Mt,"false positive issues"),j("system",`
23
+
24
+ ---
25
+
26
+ \u2705 ${Mt} issue${Mt>1?"s were":" was"} auto-dismissed as false positive${Mt>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Jt=ot.current[Q];Jt||(Jt=await Ss(Q)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},Jt.storyFile&&(ot.current[Q]=Jt)),b.debug("[Review] Story file paths:",Jt);let Je=ne.map(ae=>({...ae,file:ae.file||Zd(ae.fixTarget,Jt)||ef(ae,Jt)}));if(Je=tf(Je),b.debug("[Review] After de-duplication:",Je.length,"issues"),!O){let ae=Je.length;Je=Je.filter(ln=>ln.property?.toLowerCase()!=="textcontent"&&!ln.description?.toLowerCase().includes("text content")),ae!==Je.length&&b.debug("[Review] Filtered out",ae-Je.length,"textContent issues (toggle OFF)")}let hr=ge.validation?.complianceScore??et[Tt]?.complianceScore;if(b.debug("[Review] Multi-model score sources:",{firstModelId:Tt,validationScore:ge.validation?.complianceScore,modelScore:et[Tt]?.complianceScore,multiModelScore:hr}),hr==null){let ln=(et[Tt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);hr=ln?parseInt(ln[1],10):void 0,b.debug("[Review] Parsed multi-model score from response:",hr)}let gn;it&&Ot&&(gn=(st.getState().reviewHistory.find(ln=>ln.id===Ot)?.iterationNumber||0)+1);let zi={id:_t,componentId:Q,storyId:Q,modelId:Tt,parentReviewId:it&&Ot||void 0,iterationNumber:gn,figmaFileKey:void 0,figmaNodeId:W||void 0,figmaFileUrl:Z||void 0,complianceScore:hr,visualSimilarity:ge.visualSimilarity,issuesCount:Je.filter(ae=>!ae.dismissed).length,issues:Je,createdAt:new Date,reviewDurationMs:Date.now()-zn,costUsd:ge.costUsd,inputTokens:ge.inputTokens,outputTokens:ge.outputTokens,cacheCreationTokens:ge.cacheCreationTokens,cacheReadTokens:ge.cacheReadTokens};if(b.debug("[Review] Multi-model token data:",{costUsd:ge.costUsd,inputTokens:ge.inputTokens,outputTokens:ge.outputTokens,cacheCreationTokens:ge.cacheCreationTokens,cacheReadTokens:ge.cacheReadTokens,reviewTokens:zi.inputTokens}),L(zi),Q&&V.enableReviewBadges){let ae=Je.filter(ln=>!ln.dismissed);to(Q,{score:hr??100,issueCount:ae.length,criticalCount:ae.filter(ln=>ln.severity==="critical").length,majorCount:ae.filter(ln=>ln.severity==="major").length,minorCount:ae.filter(ln=>ln.severity==="minor").length})}D("issues");let na=Je.filter(ae=>!ae.dismissed).length;b.debug("[Review] Created multi-model review with",na,"active issues,",Je.length-na,"dismissed");let Se=W||st.getState().currentMapping?.figmaNodeId;b.debug("[Review] Issue validation handled server-side. Active:",Je.filter(ae=>!ae.dismissed).length,"Dismissed:",Je.filter(ae=>ae.dismissed).length)}catch(_t){b.error("[Review] Failed to parse issues from multi-model response:",_t)}}else if(ge){ge.prompt&&M(ge.prompt),(ge.response||fn)&&g(ge.response||fn),ge.figmaImageUrl&&k(ge.figmaImageUrl),b.debug("[Review] State updated with prompt, response, and screenshots");try{let et=Kr(),Tt=ge.response||fn,_t=ge.issues,Fn=_t&&_t.length>0,Qt=Fn?_t.map(Se=>({id:Kr(),reviewId:et,dbId:Se.dbId,type:Se.type,severity:Se.severity,title:Se.description,description:Se.description,property:Se.property,expected:no(Se.expected),actual:no(Se.actual),currentValue:no(Se.actual),suggestedValue:no(Se.expected),source:Se.source||"computed-styles",suggestedFix:Se.suggestedFix,file:Se.file,domElement:Se.domElement,figmaElement:Se.figmaElement,fixTarget:Se.fixTarget,fixRequired:Se.fixRequired,detectedBy:Se.detectedBy,dismissed:Se.dismissed??!1,dismissReason:Se.dismissReason,dismissedAt:Se.dismissed?new Date:void 0,_unreliable:Se._unreliable,_validationError:Se._validationError,figmaContext:Se.figmaContext,relatedTo:Array.isArray(Se.relatedTo)?Se.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):Jd(Tt,et);b.debug("[Review] Issues source:",Fn?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Issues count:",Qt.length,"issues");let ne=Qt.filter(Se=>Se.dismissed).length;ne>0&&(b.debug("[Review] Auto-dismissed:",ne,"false positive issues"),j("system",`
27
+
28
+ ---
29
+
30
+ \u2705 ${ne} issue${ne>1?"s were":" was"} auto-dismissed as false positive${ne>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Mt=ge.complianceScore??ge.validation?.complianceScore;if(b.debug("[Review] Score sources:",{directScore:ge.complianceScore,validationScore:ge.validation?.complianceScore,parsedScore:Mt}),Mt==null){let Se=Tt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Mt=Se?parseInt(Se[1],10):void 0,b.debug("[Review] Parsed score from response:",Mt)}let Jt=ot.current[Q];Jt||(Jt=await Ss(Q)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},Jt.storyFile&&(ot.current[Q]=Jt)),b.debug("[Review] Story file paths:",Jt);let Je=Qt.map(Se=>({...Se,file:Se.file||Zd(Se.fixTarget,Jt)||ef(Se,Jt)}));if(Je=tf(Je),b.debug("[Review] After de-duplication:",Je.length,"issues"),!O){let Se=Je.length;Je=Je.filter(ae=>ae.property?.toLowerCase()!=="textcontent"&&!ae.description?.toLowerCase().includes("text content")),Se!==Je.length&&b.debug("[Review] Filtered out",Se-Je.length,"textContent issues (toggle OFF)")}let hr;it&&Ot&&(hr=(st.getState().reviewHistory.find(ae=>ae.id===Ot)?.iterationNumber||0)+1);let gn={id:et,componentId:Q,storyId:Q,modelId:l[0],parentReviewId:it&&Ot||void 0,iterationNumber:hr,figmaFileKey:void 0,figmaNodeId:W||void 0,figmaFileUrl:Z||void 0,complianceScore:Mt,visualSimilarity:ge.visualSimilarity,issuesCount:Je.filter(Se=>!Se.dismissed).length,issues:Je,createdAt:new Date,reviewDurationMs:Date.now()-zn,costUsd:ge.costUsd,inputTokens:ge.inputTokens,outputTokens:ge.outputTokens,cacheCreationTokens:ge.cacheCreationTokens,cacheReadTokens:ge.cacheReadTokens,variantMismatch:ge.variantMismatch,storybookVariant:ge.storybookVariant,figmaVariant:ge.figmaVariant};if(b.debug("[useAIReview] About to call addReview with review:",{id:gn.id,storyId:gn.storyId,issueCount:gn.issues?.length,complianceScore:gn.complianceScore,createdAt:gn.createdAt?.toISOString(),inputTokens:gn.inputTokens,outputTokens:gn.outputTokens,costUsd:gn.costUsd,cacheCreationTokens:gn.cacheCreationTokens,cacheReadTokens:gn.cacheReadTokens}),L(gn),b.debug("[useAIReview] addReview called successfully"),Q&&V.enableReviewBadges){let Se=Je.filter(ae=>!ae.dismissed);to(Q,{score:Mt??100,issueCount:Se.length,criticalCount:Se.filter(ae=>ae.severity==="critical").length,majorCount:Se.filter(ae=>ae.severity==="major").length,minorCount:Se.filter(ae=>ae.severity==="minor").length})}D("issues");let zi=Je.filter(Se=>!Se.dismissed).length;b.debug("[Review] Created review with",zi,"active issues,",Je.length-zi,"dismissed");let na=W||st.getState().currentMapping?.figmaNodeId;b.debug("[Review] Validation check:",{figmaNodeId:W,effectiveFigmaNodeIdSingle:na,hasSessionToken:!!B,selectedProjectId:ee,issueCount:Je.length}),b.debug("[Review] Issue validation handled server-side. Active:",Je.filter(Se=>!Se.dismissed).length,"Dismissed:",Je.filter(Se=>Se.dismissed).length)}catch(et){b.error("[Review] Failed to parse issues:",et)}}else throw fn?(b.error("[Review] ERROR: No structured result received from backend!"),b.error("[Review] Streaming text length:",fn.length),b.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(Qe){if(Qe instanceof Error&&Qe.name==="AbortError"){b.debug("[useAIReview] Review cancelled by user"),ie(0,"Review cancelled");return}b.error("[useAIReview] Review error:",Qe);let le=Qe instanceof Error?Qe.message:"Review failed";throw f(le),Q&&V.enableReviewBadges&&qb(Q),ie(0,`Error: ${le}`),Qe}finally{p(!1),Te.current=null,We.current&&(clearTimeout(We.current),We.current=null),X(null)}},[e,B,ee,Q,Ee,l,p,f,d,m,v,I,x,C,F,z,j,ie,R,w,k,M,g,X]),he=ws(()=>n?.issues?o==="all"?n.issues:n.issues.filter($e=>$e.severity===o):[],[n,o]),de=ws(()=>{Te.current&&(b.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:re,cancelReview:de,setShowReviewMenu:h,setSeverityFilter:S,setShowStreamingPanel:C,setStreamingPanelCollapsed:F,addStreamingMessage:T,updateStreamingMessage:R,clearStreamingMessages:z,setStreamingProgress:N,setStreamingStatus:E,resetReview:P,getFilteredIssues:he}};Ae();Pe();Ue();import{useCallback as xG}from"react";var wG=J();Ae();Pe();import{useEffect as Kb,useRef as Xb}from"react";import{useStorybookApi as nM,useStorybookState as rM,addons as oM}from"storybook/manager-api";var Qb="storyArgsUpdated",lf=()=>{let e=nM(),t=rM(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=Ge(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ye(),l=Xb(null),p=Xb(0);return Kb(()=>{let f=t.storyId;if(f){l.current!==f&&(b.debug("[useCurrentStory] Story changed from",l.current,"to",f),s(f),l.current=f,p.current=Date.now()),o(f);let d=e.getData(f),h=d?.name&&d.name!=="default"?`${d.title} / ${d.name}`:d?.title||f;i(h),b.debug("[useCurrentStory] Current story:",{storyId:f,fullName:h})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),Kb(()=>{let f=oM.getChannel(),d=null,h=S=>{if(S.storyId===n){if(u||c){b.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}d&&clearTimeout(d),d=setTimeout(()=>{let{isReviewing:C,isValidating:F}=st.getState();if(C||F){b.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-p.current<2e3){b.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}b.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return f.on(Qb,h),()=>{f.off(Qb,h),d&&clearTimeout(d)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};Ae();Ue();import{useCallback as Jb}from"react";import{addons as Zb}from"storybook/manager-api";var e0=J(),Lo=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=Ge(),{sessionToken:o}=ze(),{selectedProjectId:i}=Ke(),s=Jb(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await fetch(`${e0}/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 p=await l.json();r();try{Zb.getChannel().emit("uireview/mappings-changed")}catch{}return p.mapping},[o,i,r]),a=Jb(async c=>{if(!o)throw new Error("Not authenticated");if(!(await fetch(`${e0}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{Zb.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};ji();Ae();import{useCallback as cf,useEffect as t0,useRef as iM}from"react";import{useChannel as sM,addons as n0}from"storybook/manager-api";Pe();var aM=3e4,lM="forceRemount";function cM(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 uM(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 pM="UICOPILOT/APPLY_FIXES",dM="UICOPILOT/FIX_STARTED",fM="UICOPILOT/FIX_COMPLETED",gM="UICOPILOT/FIX_FAILED",mM="UICOPILOT/ALL_FIXES_APPLIED",uf=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ye(),c=iM(null),l=cf(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);t0(()=>()=>l(),[l]),t0(()=>{let h=n0.getChannel(),S=()=>{st.getState().isApplying&&(b.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",S),()=>h.off("channelWSDisconnect",S)},[l,o,i]);let p=sM({[dM]:({issueId:h})=>{b.debug(`[useApplyFixes] Fix started for issue: ${h}`),a(h,{status:"applying"})},[fM]:({issueId:h,result:S})=>{b.debug(`[useApplyFixes] Fix completed for issue: ${h}`,S),s(h,"applied"),a(h,{status:"applied"})},[gM]:({issueId:h,error:S})=>{b.error(`[useApplyFixes] Fix failed for issue: ${h}`,S),s(h,"failed",S),a(h,{status:"failed",error:S})},[mM]:async({summary:h})=>{if(b.debug("[useApplyFixes] All fixes applied:",h),l(),o(!1),i({succeeded:h.succeeded,failed:h.failed,total:h.total}),h.failed>0?b.warn(`Applied ${h.succeeded}/${h.total} fixes. ${h.failed} failed.`):b.debug(`Successfully applied all ${h.total} fixes!`),h.succeeded>0){b.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{n0.getChannel().emit(lM,{storyId:st.getState().currentStoryId}),b.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(S){b.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",S)}b.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await ga(),b.debug("[useApplyFixes] Storybook preview reloaded")}t&&(b.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),b.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),f=cf(h=>{let S=[],C=[],F=[];for(let T of h){let R=T.currentValue||T.actual||"",z=T.suggestedValue||T.expected||"";if(R&&z&&cM(R,z)){S.push(T);continue}if(uM(T)){C.push(T);continue}let N=T.generatedFix?.filePath||T.file||"";if(!N){b.warn(`[useApplyFixes] Skipping issue ${T.id} - no target file path`);continue}let E=N.toLowerCase().split(".").pop()||"",M=["tsx","jsx","ts","js"].includes(E)?"component":"css";F.push({...T,targetFilePath:N,targetFileType:M})}return{actionable:F,negligible:S,designTokens:C}},[]);return{applyFixes:cf(h=>{if(r){b.warn("[useApplyFixes] Already applying fixes");return}if(h.length===0){b.warn("[useApplyFixes] No issues to fix");return}let S=f(h);if(S.negligible.length>0&&b.debug(`[useApplyFixes] Filtered ${S.negligible.length} negligible issue(s)`),S.designTokens.length>0&&b.debug(`[useApplyFixes] Skipped ${S.designTokens.length} design token suggestion(s)`),S.actionable.length===0){b.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let C=S.actionable.filter(R=>R.targetFileType==="css"),F=S.actionable.filter(R=>R.targetFileType==="component");if(b.debug("[useApplyFixes] Applying fixes:"),C.length>0){let R=[...new Set(C.map(z=>z.targetFilePath))];b.debug(` - ${C.length} CSS issue(s) in: ${R.join(", ")}`)}if(F.length>0){let R=[...new Set(F.map(z=>z.targetFilePath))];b.debug(` - ${F.length} component issue(s) in: ${R.join(", ")}`),b.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){b.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:S.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{st.getState().isApplying&&(b.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:S.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},aM),p(pM,{issues:S.actionable,storybookRoot:n||void 0})},[p,r,o,i,f,n,l]),isApplying:r}};Ae();Ue();import{useState as UG}from"react";var WG=J();Ae();import{useState as Mo}from"react";Ue();Pe();var hM=J();async function xM(e,t,n,r,o){if(!e)return b.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await fetch(`${hM}/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 b.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return b.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return b.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function r0(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return b.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>xM(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return b.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}Wc();ji();Pe();Ue();var yM=["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"],bM=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],SM=J();function pf(){let[e,t]=Mo(!1),[n,r]=Mo(null),[o,i]=Mo(null),[s,a]=Mo(null),[u,c]=Mo(null),[l,p]=Mo(null),[f,d]=Mo(null),{sessionToken:h}=ze(),{selectedProjectId:S}=Ke(),{currentStoryId:C,currentStoryName:F}=Ge(),{workspacePath:T,updateIssueGeneratedFix:R,batchUpdateIssueGeneratedFixes:z,includeComponentIssues:N,dismissIssue:E,recalculateScore:M,addStreamingMessage:g}=ye();return{generateBatchFixes:async w=>{if(!h){r("Not authenticated");return}if(!S){r("No project selected");return}if(!C){r("No story selected");return}if(w.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),p(null),a({total:w.length,completed:0});let A=w.map(m=>({issueId:m.id,generatedFix:{code:"",diffPreview:"",filePath:m.file||"",confidence:0,strategy:"",status:"generating"}}));z(A);try{b.debug("[useBatchGenerateFixes] Generating fixes for",w.length,"issues");let m=null;try{let y=Vi();y?.computed&&(m=y.computed,b.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(y){b.warn("[useBatchGenerateFixes] Could not extract computed styles:",y)}let v=null;try{v=await Ss(C),v&&b.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",v)}catch(y){b.warn("[useBatchGenerateFixes] Could not resolve story file paths:",y)}let I=await fetch(`${SM}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify({projectId:S,storyId:C,workspacePath:T,includeComponentIssues:N,computedStyles:m,storyFilePaths:v,reviewContext:{storyName:F||void 0,variantArgs:qo()||void 0},issues:w.map(y=>({id:y.id,dbId:y.dbId,title:y.title,description:y.description,property:y.property,currentValue:y.currentValue,suggestedValue:y.suggestedValue,file:y.file,lineNumber:y.lineNumber,severity:y.severity,type:y.type,fixTarget:y.fixTarget,domElement:y.domElement,figmaContext:y.figmaContext,suggestedFix:y.suggestedFix}))})});if(!I.ok){let y=await I.json().catch(()=>({}));throw new Error(y.error||"Batch fix generation failed")}let x=await I.json();if(!x.success)throw new Error(x.error||"Batch fix generation failed");if(b.debug("[useBatchGenerateFixes] Generated",x.result.fixes.length,"fixes"),x.result.storybookRoot&&(d(x.result.storybookRoot),b.debug("[useBatchGenerateFixes] Stored storybookRoot:",x.result.storybookRoot)),x.result.selfReview&&(p(x.result.selfReview),b.debug("[useBatchGenerateFixes] Self-review:",x.result.selfReview)),x.result.partialFailure){let{failedBatches:y,errors:U}=x.result.partialFailure;b.warn(`[useBatchGenerateFixes] Partial failure: ${y.join(", ")} batch(es) failed`),b.warn("[useBatchGenerateFixes] Errors:",U),r(`Some fixes couldn't be generated (${y.join(", ")}): ${U[0]||"Unknown error"}`)}a({total:w.length,completed:x.result.fixes.length});let P=new Set(x.result.fixes.map(y=>y.issueId)),L=w.filter(y=>!P.has(y.id));L.length>0&&(b.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.forEach(y=>{R(y.id,{code:"",diffPreview:"",filePath:y.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),x.timing&&(i({durationSec:x.timing.durationSec,issueCount:x.timing.issueCount,avgPerIssueSec:x.timing.avgPerIssueSec}),b.debug(`[useBatchGenerateFixes] Generation took ${x.timing.durationSec}s for ${x.timing.issueCount} issues`)),x.result?.usage&&(c({inputTokens:x.result.usage.inputTokens||0,outputTokens:x.result.usage.outputTokens||0,costUsd:x.result.usage.costUsd||0,modelId:x.result.usage.modelId||"unknown",provider:x.result.usage.provider||"unknown"}),b.debug(`[useBatchGenerateFixes] Token usage: ${x.result.usage.inputTokens} in, ${x.result.usage.outputTokens} out, $${x.result.usage.costUsd?.toFixed(4)}`));let D=[],O=[];if(x.result.fixes.forEach(y=>{let U=y.noChangesNeeded===!0;if(!U){let X=(y.fixStrategy||"").toLowerCase(),ee=(y.generatedCode||"").toLowerCase(),Q=(y.diffPreview||"").toLowerCase(),Ee=yM.some(We=>X.includes(We.toLowerCase())||X.replace(/[-_]/g,"").includes(We.replace(/[-_]/g,""))),Te=bM.some(We=>ee.includes(We)||Q.includes(We));U=Ee||Te}let V=w.find(X=>X.id===y.issueId);if(U&&V){let X=V.suggestedValue,ee=V.currentValue;X&&ee&&!Po(X,ee)&&(b.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${X}", actual="${ee}"), NOT auto-dismissing issue ${y.issueId}`),U=!1)}let B=V?.programmaticallyVerified===!0;if(b.debug(`[useBatchGenerateFixes] Processing fix for issue ${y.issueId}:`,{isFalsePositive:U,isProgrammaticIssue:B,detectedBy:V?.detectedBy,noChangesNeeded:y.noChangesNeeded,fixStrategy:y.fixStrategy,title:V?.title?.substring(0,50)}),B&&U&&(b.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${y.issueId} (detectedBy: ${V?.detectedBy})`),U=!1),U){let X=`Auto-dismissed: ${y.fixStrategy} - values already match`;b.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${y.issueId} - noChangesNeeded: ${y.noChangesNeeded}, strategy: "${y.fixStrategy}"`),E(y.issueId,X),D.push({localId:y.issueId,dbId:V?.dbId,dismissReason:X}),O.push({issueId:y.issueId,generatedFix:{code:y.generatedCode||"",diffPreview:y.diffPreview||"",filePath:y.filePath,confidence:y.confidence,strategy:y.fixStrategy,status:"ready",error:void 0,noChangesExplanation:y.noChangesExplanation}})}else{let X=y.error||y.fixStrategy==="skipped"?"failed":"ready";O.push({issueId:y.issueId,generatedFix:{code:y.generatedCode,diffPreview:y.diffPreview,filePath:y.filePath,confidence:y.confidence,strategy:y.fixStrategy,status:X,error:y.error,noChangesExplanation:y.noChangesExplanation}})}}),O.length>0&&(b.debug(`[useBatchGenerateFixes] Applying ${O.length} fix updates in batch`),z(O)),D.length>0){if(b.debug(`[useBatchGenerateFixes] Auto-dismissed ${D.length} false positive(s), recalculating score`),M(),h){let U=D.filter(V=>V.dbId).map(V=>({dbId:V.dbId,dismissed:!0,dismissReason:V.dismissReason,dismissedBy:"system"}));U.length>0&&(b.debug(`[useBatchGenerateFixes] Syncing ${U.length} dismissals to server`),r0(U,h).then(V=>{V.success?b.debug(`[useBatchGenerateFixes] Server score updated to: ${V.newScore}`):b.warn("[useBatchGenerateFixes] Failed to sync dismissals:",V.error)}).catch(V=>{b.error("[useBatchGenerateFixes] Error syncing dismissals:",V)}))}let y=D.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${D.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;g({role:"system",content:y})}b.debug("[useBatchGenerateFixes] Updated",x.result.fixes.length,"issues with fixes")}catch(m){b.error("[useBatchGenerateFixes] Failed to generate batch fixes:",m),r(m?.message||"Failed to generate batch fixes");let v=w.map(I=>({issueId:I.id,generatedFix:{code:"",diffPreview:"",filePath:I.file||"",confidence:0,strategy:"",status:"failed",error:m?.message||"Failed to generate fix"}}));z(v)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:f}}Ae();Pe();Ue();import{useState as df,useCallback as ff}from"react";var wM=J();function gf(){let[e,t]=df([]),[n,r]=df(!1),[o,i]=df(null),{sessionToken:s}=ze(),{selectedProjectId:a}=Ke(),{currentStoryId:u}=Ge(),{setReviewResults:c}=ye(),l=ff(async()=>{if(!(!s||!a)){r(!0),i(null);try{let d=new URLSearchParams({projectId:a,limit:"10"});u&&d.append("storyId",u);let h=await fetch(`${wM}/api/reviews/list?${d.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!h.ok){let C=await h.json().catch(()=>({}));throw new Error(C.error||"Failed to fetch reviews")}let S=await h.json();if(!S.success)throw new Error("Failed to fetch reviews");b.debug("[useReviewHistory] Fetched",S.reviews.length,"reviews for:",u),t(S.reviews)}catch(d){b.error("[useReviewHistory] Failed to fetch reviews:",d),i(d instanceof Error?d.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),p=ff(d=>{b.debug("[useReviewHistory] Applying review:",d.id,"with",d.issues.length,"issues");let h=[];if(typeof d.models=="string")try{h=JSON.parse(d.models)}catch(T){b.error("[useReviewHistory] Failed to parse models:",T),h=["claude-sonnet-4-20250514"]}else h=d.models;let S=d.issues.map(T=>({id:T.id,reviewId:d.id,type:T.type,severity:T.severity,title:T.description,description:T.description,file:T.fixTarget||void 0,lineNumber:void 0,property:T.property,currentValue:T.actual,suggestedValue:T.expected,suggestedCode:T.suggestedFix||void 0,status:T.status,dismissed:T.dismissed||!1,dismissReason:T.dismissReason,dismissedBy:T.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(T.createdAt)})),C=d.completedAt&&d.createdAt?new Date(d.completedAt).getTime()-new Date(d.createdAt).getTime():void 0,F=d.storyId||"";if(c({id:d.id,componentId:"",storyId:F,modelId:h[0]||"claude-haiku-4-5-20251001",complianceScore:d.complianceScore,issuesCount:d.issuesCount,issues:S,createdAt:new Date(d.createdAt),timestamp:new Date(d.createdAt).toISOString(),costUsd:d.costUsd,inputTokens:d.inputTokens,outputTokens:d.outputTokens,reviewDurationMs:C}),F){let T=d.issues.filter(E=>!E.dismissed),R=T.filter(E=>E.severity==="critical").length,z=T.filter(E=>E.severity==="major").length,N=T.filter(E=>E.severity==="minor").length;to(F,{score:d.complianceScore,issueCount:T.length,criticalCount:R,majorCount:z,minorCount:N})}},[c]),f=ff(d=>{let h=e.find(S=>S.id===d);if(!h){b.error("[useReviewHistory] Review not found:",d);return}p(h)},[e,p]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:f}}Ae();Pe();import{useEffect as kM,useState as vM,useRef as sl}from"react";import{useChannel as CM}from"storybook/manager-api";var TM="UICOPILOT/WORKSPACE_PATH",o0="UICOPILOT/REQUEST_WORKSPACE_PATH",IM=3e3,FM=500,EM=5,mf=()=>{let[e,t]=vM({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ye(),r=sl(!1),o=sl(null),i=sl(0),s=sl(null),a=CM({[TM]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),b.debug("[useAutoApplySupport] Server responded - auto-apply supported"),b.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return kM(()=>(b.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(o0,{}),s.current=setInterval(()=>{!r.current&&i.current<EM&&(i.current++,b.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(o0,{}))},FM),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){b.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,b.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),b.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,b.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},IM),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},hf=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 b.error("[copyToClipboard] Failed to copy:",t),!1}};Ae();Ue();import{useEffect as AM,useRef as PM}from"react";var b7=J(),LM=new Set;function xf(){let{sessionToken:e}=ze(),{selectedProjectId:t}=Ke(),n=PM(!1);AM(()=>{t&&LM.add(t)},[e,t])}Ae();import{useCallback as MM,useState as i0}from"react";function yf(){let[e,t]=i0(!1),[n,r]=i0(null),{currentStoryId:o}=Ge(),{currentReviewId:i}=ye();return{exportPDF:MM(async()=>{if(!i){r("No review to export");return}t(!0),r(null);try{let[{default:a},{jsPDF:u}]=await Promise.all([import("html2canvas"),import("jspdf")]),c=document.querySelector('[data-testid="issues-panel"]')||document.querySelector(".issues-list-container")||document.querySelector('[class*="IssuesList"]');if(c)await s0(a,u,c,o);else{let l=document.querySelector("#storybook-panel-root")||document.querySelector('[id*="panel-tab-content"]')||document.querySelector(".sb-show-main");if(!l)throw new Error("Could not find panel to export");await s0(a,u,l,o)}}catch(a){console.error("[useExportPDF] Export failed:",a),r(a instanceof Error?a.message:"Failed to export PDF")}finally{t(!1)}},[i,o]),isExporting:e,error:n}}async function s0(e,t,n,r){let o=await e(n,{backgroundColor:"#ffffff",scale:2,logging:!1,useCORS:!0,allowTaint:!0}),i=o.toDataURL("image/png"),s=o.width,a=o.height,u=210,c=297,l=10,p=u-l*2,f=p/(s/2),d=a/2*f,h=new t({orientation:(d>c-l*2,"portrait"),unit:"mm",format:"a4"});h.setFillColor("#0ea5e9"),h.rect(0,0,u,20,"F"),h.setTextColor("#ffffff"),h.setFontSize(14),h.setFont("helvetica","bold"),h.text("Design Review Report",l,13);let S=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});h.setFontSize(10),h.setFont("helvetica","normal"),h.text(S,u-l,13,{align:"right"});let C=r?BM(r):"Component Review";h.setTextColor("#1f2937"),h.setFontSize(16),h.setFont("helvetica","bold"),h.text(C,l,30);let F=38,T=c-F-15;if(d<=T)h.addImage(i,"PNG",l,F,p,d);else{let N=d,E=0,M=!0;for(;N>0;){M||h.addPage();let g=M?F:l,k=M?T:c-l*2-10,w=Math.min(N,k),A=w/f*2,m=document.createElement("canvas");m.width=s,m.height=A;let v=m.getContext("2d");if(v){v.drawImage(o,0,E,s,A,0,0,s,A);let I=m.toDataURL("image/png");h.addImage(I,"PNG",l,g,p,w)}E+=A,N-=w,M=!1}}let R=h.getNumberOfPages();for(let N=1;N<=R;N++)h.setPage(N),h.setDrawColor("#e5e7eb"),h.setLineWidth(.3),h.line(l,c-12,u-l,c-12),h.setTextColor("#6b7280"),h.setFontSize(8),h.setFont("helvetica","normal"),h.text("Generated by UI Copilot",l,c-7),h.text(`Page ${N} of ${R}`,u-l,c-7,{align:"right"});let z=`design-review-${(r||"report").replace(/[^a-zA-Z0-9]/g,"-")}.pdf`;h.save(z)}function BM(e){let t=e.replace(/^(example|stories)-/i,""),[n,r]=t.split("--"),o=n.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "),i=r?r.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null;return i?`${o} / ${i}`:o}import{useState as Bo,useMemo as x0,useCallback as fi}from"react";Ue();Pe();import{useState as Rr,useEffect as al,useRef as di,useCallback as bf}from"react";var DM=300;function a0({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=Rr([]),[u,c]=Rr({}),[l,p]=Rr(0),[f,d]=Rr([]),[h,S]=Rr(new Set),[C,F]=Rr(!1),[T,R]=Rr(!1),[z,N]=Rr(null),E=di(1),M=di(null),g=di(null),[k,w]=Rr(0),A=di(!1),m=di({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});m.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let v=bf(async(D,O,y=!1)=>{let{projectId:U,typeFilter:V,search:B,figmaPage:X,limit:ee}=m.current;if(!U||!V)return;M.current&&M.current.abort();let Q=new AbortController;M.current=Q,O?R(!0):F(!0),N(null);try{let Ee=J(),Te=localStorage.getItem("uicopilot_session_token");if(!Te)throw new Error("Not authenticated. Please connect to UI Copilot first.");let We=new URLSearchParams({projectId:U,page:String(D),limit:String(ee)});V&&We.append("type",V),X&&We.append("figmaPage",X),B.trim()&&We.append("search",B.trim()),y&&We.append("refresh","true");let ot=await fetch(`${Ee}/api/figma/frames?${We.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Te}`},signal:Q.signal});if(!ot.ok){let de=await ot.json();throw new Error(de.error||"Failed to fetch frames")}let j=await ot.json(),ie=j.frames||[],re=j.thumbnails||{},he=ot.headers.get("X-Cache-Status");if(ie.length===0&&D===1&&!O&&!y&&!A.current&&he!=="HIT"){b.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),A.current=!0,await v(1,!1,!0);return}O?(a(de=>[...de,...ie]),c(de=>({...de,...re}))):(a(ie),c(re)),p(j.total||ie.length),j.pages&&d(j.pages),j.cacheDiff?.added&&S(new Set(j.cacheDiff.added)),E.current=D}catch(Ee){if(Ee instanceof DOMException&&Ee.name==="AbortError")return;let Te=Ee instanceof Error?Ee.message:"Failed to fetch Figma frames.";N(Te),b.error("Error fetching frames:",Ee)}finally{Q.signal.aborted||(F(!1),R(!1))}},[]);al(()=>{if(!i||!e||!t)return;A.current=!1,g.current&&clearTimeout(g.current);let D=n.trim()?DM:0;return g.current=setTimeout(()=>{E.current=1,v(1,!1)},D),()=>{g.current&&clearTimeout(g.current)}},[e,t,n,r,i,k,v]);let I=di(new Set);al(()=>{if(s.length===0)return;let D={};for(let O of s)O.thumbnailCdnUrl&&!u[O.id]&&(D[O.id]=O.thumbnailCdnUrl);Object.keys(D).length>0&&c(O=>({...O,...D}))},[s]),al(()=>{if(s.length===0)return;let D=s.filter(y=>!y.thumbnailCdnUrl&&!u[y.id]&&!I.current.has(y.id)).map(y=>y.id);if(D.length===0)return;D.forEach(y=>I.current.add(y)),(async()=>{try{let{projectId:y}=m.current,U=J(),V=localStorage.getItem("uicopilot_session_token");if(!V||!y)return;let B=await fetch(`${U}/api/figma/frames?projectId=${y}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${V}`}});if(B.ok){let X=await B.json();X.thumbnails&&Object.keys(X.thumbnails).length>0&&c(ee=>({...ee,...X.thumbnails}))}}catch(y){D.forEach(U=>I.current.delete(U)),b.error("Failed to fetch frame thumbnails:",y)}})()},[s,u]),al(()=>()=>{M.current&&M.current.abort(),g.current&&clearTimeout(g.current)},[]);let x=bf(async()=>{let D=E.current+1;await v(D,!0)},[v]),P=bf(()=>{A.current=!1,E.current=1,a([]),c({}),w(D=>D+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:f,recentlyAdded:h,isLoading:C,loadingMore:T,hasMore:L,loadMore:x,refresh:P,error:z}}Ue();Pe();import{useState as ll,useCallback as cl,useRef as RM}from"react";function l0({projectId:e}){let[t,n]=ll({}),[r,o]=ll({}),[i,s]=ll(new Set),[a,u]=ll(new Set),c=RM({}),l=cl(async h=>{if(!(!e||i.has(h))){s(S=>new Set(S).add(h));try{let S=J(),C=localStorage.getItem("uicopilot_session_token"),F=await fetch(`${S}/api/figma/variants?projectId=${e}&componentSetId=${h}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`}});if(F.ok){let T=await F.json();if(T.variants){n(z=>({...z,[h]:T.variants}));let R={};for(let z of T.variants)z.thumbnailCdnUrl&&(R[z.id]=z.thumbnailCdnUrl);o(z=>({...z,[h]:{...z[h]||{},...R}})),c.current[h]||(c.current[h]=new Set),Object.keys(R).forEach(z=>c.current[h].add(z))}else o(R=>({...R,[h]:R[h]||{}}))}else o(T=>({...T,[h]:{}}))}catch(S){b.error("Failed to fetch variant metadata:",S),o(C=>({...C,[h]:{}}))}finally{s(S=>{let C=new Set(S);return C.delete(h),C})}}},[e,i]),p=cl(async(h,S)=>{if(!e||S.length===0)return;c.current[h]||(c.current[h]=new Set);let C=r[h]||{},F=S.filter(T=>!c.current[h].has(T)&&!C[T]);if(F.length!==0){F.forEach(T=>c.current[h].add(T)),u(T=>new Set(T).add(h));try{let T=J(),R=localStorage.getItem("uicopilot_session_token"),z=await fetch(`${T}/api/figma/variants?projectId=${e}&componentSetId=${h}&thumbnailIds=${F.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`}});if(z.ok){let N=await z.json();N.thumbnails&&Object.keys(N.thumbnails).length>0&&o(E=>({...E,[h]:{...E[h]||{},...N.thumbnails}}))}}catch(T){b.error("Failed to fetch variant thumbnails:",T),F.forEach(R=>c.current[h]?.delete(R))}finally{u(T=>{let R=new Set(T);return R.delete(h),R})}}},[e]),f=cl(h=>{o(S=>{let C={...S};return delete C[h],C}),n(S=>{let C={...S};return delete C[h],C}),delete c.current[h]},[]),d=cl(()=>{o({}),n({}),c.current={}},[]);return{variantChildren:t,variantThumbnails:r,loadingVariants:i,loadingThumbnails:a,fetchVariants:l,fetchVariantThumbnails:p,clearVariantsForSet:f,clearAllVariants:d}}Ue();ji();Ae();Pe();import{useState as c0,useEffect as u0,useRef as p0,useCallback as Sf}from"react";function d0({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=c0(null),[i,s]=c0(!1),a=p0(null),u=p0(new Set),c=Sf(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let f=qo();if(!f||Object.keys(f).length===0)return;let d=st.getState().currentStoryId||"",h=d.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,S=>S.toUpperCase());a.current=e,s(!0),o(null);try{let S=J(),C=localStorage.getItem("uicopilot_session_token"),F=await fetch(`${S}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`},body:JSON.stringify({storyName:h,storyId:d,storyArgs:f,availableFilters:t.map(T=>({property:T.property,values:T.values}))})});if(F.ok){let T=await F.json();T.confidence>0&&Object.keys(T.suggestedFilters).length>0&&(b.debug("[useFilterSuggestion] Suggestion:",T),o(T))}}catch(S){b.error("[useFilterSuggestion] Error:",S)}finally{s(!1)}},[e,t,n]);u0(()=>{c()},[c]),u0(()=>{e||(o(null),a.current=null)},[e]);let l=Sf(()=>{},[]),p=Sf(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:p}}function f0(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function g0(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 m0(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 h0(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 ks({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=Bo(!0),[i,s]=Bo(!1),[a,u]=Bo(!1),[c,l]=Bo(""),[p,f]=Bo(""),[d,h]=Bo([]),[S,C]=Bo(new Set),F=fi(j=>{l(j),d.length>0&&h([]),S.size>0&&C(new Set)},[d.length,S.size]),T=f0(r,i,a),{frames:R,thumbnails:z,totalFrames:N,availablePages:E,recentlyAdded:M,isLoading:g,loadingMore:k,hasMore:w,loadMore:A,refresh:m,error:v}=a0({projectId:e,typeFilter:T,search:c,figmaPage:p||void 0,limit:t,enabled:n&&!!T}),{variantChildren:I,variantThumbnails:x,loadingVariants:P,loadingThumbnails:L,fetchVariants:D,fetchVariantThumbnails:O,clearVariantsForSet:y,clearAllVariants:U}=l0({projectId:e}),V=x0(()=>{let j=g0(I),ie=m0(R),re={};for(let he of[...j,...ie])re[he.property]||(re[he.property]=new Set),he.values.forEach(de=>re[he.property].add(de));return Object.entries(re).map(([he,de])=>({property:he,values:Array.from(de).sort()}))},[I,R]),B=S.size===1?Array.from(S)[0]:null,X=d0({expandedSetId:B,availableFilters:V,filtersReady:V.length>0}),ee=fi(()=>{if(!X.suggestion)return;let{suggestedFilters:j}=X.suggestion,ie=Object.entries(j).map(([re,he])=>({property:re,value:he}));h(ie),X.dismissSuggestion()},[X.suggestion]),Q=x0(()=>d.some(j=>j.value)?R.filter(j=>h0(j,d,I[j.id])):R,[R,d,I]),Ee=fi((j,ie)=>{ie.stopPropagation();let re=!S.has(j);C(he=>{let de=new Set(he);return de.has(j)?de.delete(j):de.add(j),de}),re&&!I[j]&&!P.has(j)&&D(j)},[S,I,P,D]),Te=fi((j,ie)=>{let re=ie===""?null:ie;h(he=>he.find($e=>$e.property===j)?he.map($e=>$e.property===j?{...$e,value:re}:$e):[...he,{property:j,value:re}])},[]),We=fi(()=>{h([])},[]),ot=fi(j=>{let ie=R.find(re=>re.id===j);if(ie?.thumbnailCdnUrl)return ie.thumbnailCdnUrl;if(z[j])return z[j];for(let re of Object.values(x))if(re[j])return re[j]},[z,x]);return{frames:R,filteredFrames:Q,thumbnails:z,totalFrames:N,isLoading:g,loadingMore:k,hasMore:w,error:v,loadMore:A,refresh:m,search:c,setSearch:F,figmaPage:p,setFigmaPage:f,availablePages:E,recentlyAdded:M,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:d,availableFilters:V,handleFilterChange:Te,clearFilters:We,expandedSets:S,toggleExpanded:Ee,variantChildren:I,variantThumbnails:x,loadingVariants:P,loadingThumbnails:L,fetchVariantThumbnails:O,resolveThumbnail:ot,filterSuggestion:X.suggestion,filterSuggestionLoading:X.isLoading,applySuggestedFilters:ee,dismissFilterSuggestion:X.dismissSuggestion}}Ae();import{useEffect as wr,useCallback as $M,useState as UM,useRef as jM}from"react";import{useChannel as HM}from"storybook/manager-api";function ro(e){return e.status===401||e.status===403}var pn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};function y0(e){try{let t=new URL(e),n=t.pathname.match(/\/(file|design)\/([a-zA-Z0-9]+)/),r=n?n[2]:null,o=t.searchParams.get("node-id"),i=t.hash.match(/node-id=([0-9-:]+)/),s=o||(i?i[1]:null);if(!r||!s)return null;let a=s.replace(/-/g,":");return{fileKey:r,nodeId:a}}catch(t){return console.error("UI Copilot: Error parsing Figma URL:",t),null}}Pe();Ue();Ue();var zM=J();async function wf(e){let t=await fetch(`${zM}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(ro(t))throw new pn(t.status);return t.ok?(await t.json()).projects||[]:[]}Ue();var NM=J();async function kf(e,t,n){let r=await fetch(`${NM}/api/mappings?projectId=${t}&storyId=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(ro(r))throw new pn(r.status);return r.ok&&(await r.json()).mapping||null}Ue();var OM=J();async function vf(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 fetch(`${OM}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(ro(s))throw new pn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}Ue();var _M=J();async function Cf(e,t){let n=await fetch(`${_M}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(ro(n))throw new pn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}function WM(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 VM=J(),GM="UICOPILOT/WORKSPACE_PATH",qM="UICOPILOT/REQUEST_WORKSPACE_PATH",Tf=!1;function If(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=ze(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Ke(),{currentStoryId:l,mappingsRefreshKey:p,setFigmaFileUrl:f,setCurrentMapping:d,setMappingSource:h,setLoadingMapping:S}=Ge(),{setReviewResults:C,setReviewDetailTab:F,setStorybookImageUrl:T,setFigmaImageUrl:R,setFullPrompt:z,setFullResponse:N,bulkAddReviews:E}=ye(),[M,g]=UM([]),k=jM(null);wr(()=>{let m=v=>{v.origin.startsWith(VM)&&v.data?.type==="UICOPILOT_AUTH_SUCCESS"&&v.data.token&&(b.debug("[useDataInit] OAuth success, setting token"),t(v.data.token))};return window.addEventListener("message",m),()=>window.removeEventListener("message",m)},[t]);let w=HM({[GM]:m=>{b.debug("[useDataInit] Received workspace path:",m.path),c(m.path)}});wr(()=>{w(qM)},[w]),wr(()=>{if(!e)return;let m=!1;return(async()=>{try{u(!0);let I=await wf(e);m||(s(I),n(null))}catch(I){I instanceof pn&&n(I.message),b.error("[useDataInit] Failed to fetch projects:",I)}finally{m||u(!1)}})(),()=>{m=!0}},[e,s,u]),wr(()=>{if(!i||r.length===0)return;let m=r.find(v=>v.storybookRoot===i);m&&o!==m.id&&(b.debug("[useDataInit] Auto-selecting project:",m.name),a(m.id))},[i,r,o,a]),wr(()=>{if(!o||r.length===0)return;let m=r.find(I=>I.id===o),v=m?.figmaFileId;if(m&&typeof v=="string"&&v){let I=v,x=I.includes("figma.com")&&y0(I)?.fileKey||I;f(`https://www.figma.com/file/${x}`)}},[o,r,f]),wr(()=>!e||!o||Tf?void 0:(Tf=!0,(async()=>{try{let v=await Cf(e,o);for(let[I,x]of Object.entries(v))to(I,{score:x.score,issueCount:x.issueCount,criticalCount:x.criticalCount,majorCount:x.majorCount,minorCount:x.minorCount});b.debug("[useDataInit] Populated sidebar badges for",Object.keys(v).length,"stories")}catch(v){v instanceof pn&&n(v.message),b.error("[useDataInit] Failed to fetch review statuses:",v)}})(),()=>{Tf=!1}),[e,o]),wr(()=>{if(!e||!o||!l)return;let m=!1;return(async()=>{try{S(!0);let I=await kf(e,o,l);if(m)return;I?(d(I),h("database")):(d(null),h(null))}catch(I){I instanceof pn&&n(I.message),b.error("[useDataInit] Failed to fetch mapping:",I)}finally{m||S(!1)}})(),()=>{m=!0}},[e,o,l,p,d,h,S]),wr(()=>{g([]),k.current=null},[l]),wr(()=>{if(!e||!o||!l)return;let m=!1;return(async()=>{try{let I=await vf(e,o,l,10,!0);if(!m){g(I);let x=I.map(P=>WM(P)).filter(Boolean);x.length>0&&E(x)}}catch(I){I instanceof pn&&n(I.message),b.error("[useDataInit] Failed to fetch reviews:",I)}})(),()=>{m=!0}},[e,o,l]);let A=$M(m=>{b.debug("[useDataInit] Applying review:",m.id,"with",m.issues.length,"issues");let v=[];if(typeof m.models=="string")try{v=JSON.parse(m.models)}catch{v=["claude-sonnet-4-20250514"]}else v=m.models;let I=m.issues.map(L=>({id:L.id,reviewId:m.id,type:L.type,severity:L.severity,title:L.description,description:L.description,file:L.fixTarget,lineNumber:void 0,property:L.property,currentValue:L.actual,suggestedValue:L.expected,suggestedCode:L.suggestedFix||void 0,status:L.status,dismissed:L.dismissed||!1,dismissReason:L.dismissReason,dismissedBy:L.dismissedBy,figmaContext:L.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(L.createdAt)})),x=m.completedAt&&m.createdAt?new Date(m.completedAt).getTime()-new Date(m.createdAt).getTime():void 0,P=m.storyId||"";if(C({id:m.id,componentId:"",storyId:P,modelId:v[0]||"claude-haiku-4-5-20251001",complianceScore:m.complianceScore,issuesCount:m.issuesCount,issues:I,createdAt:new Date(m.createdAt),timestamp:new Date(m.createdAt).toISOString(),costUsd:m.costUsd,inputTokens:m.inputTokens,outputTokens:m.outputTokens,reviewDurationMs:x}),m.storybookScreenshot&&(T(m.storybookScreenshot),b.debug("[useDataInit] Loaded persisted Storybook screenshot")),m.figmaScreenshot&&(R(m.figmaScreenshot),b.debug("[useDataInit] Loaded persisted Figma screenshot")),m.aiPrompt&&(z(m.aiPrompt),b.debug("[useDataInit] Loaded persisted AI prompt")),m.aiResponse&&(N(m.aiResponse),b.debug("[useDataInit] Loaded persisted AI response")),P){let L=m.issues.filter(U=>!U.dismissed),D=L.filter(U=>U.severity==="critical").length,O=L.filter(U=>U.severity==="major").length,y=L.filter(U=>U.severity==="minor").length;to(P,{score:m.complianceScore,issueCount:L.length,criticalCount:D,majorCount:O,minorCount:y})}},[C,T,R,z,N]);wr(()=>{if(M.length>0&&l&&k.current!==l){let m=M[0];m&&m.storyId===l&&(b.debug("[useDataInit] Auto-loading review:",m.id,"for:",l),k.current=l,A(m),F("issues"))}},[M,l,A,F])}import{styled as vs}from"storybook/theming";var YM=vs.div({display:"flex",gap:"10px",marginTop:"8px"}),b0=vs.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),KM=vs.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"})),XM=vs.div({display:"flex",alignItems:"center",gap:"8px"}),QM=vs(xr)(({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"})),S0=()=>{let{sessionToken:e,authMethod:t,setAuthMethod:n,startOAuth:r,logout:o}=Oi();return wt.createElement(wt.Fragment,null,wt.createElement(bo,null,wt.createElement(So,null,"Authentication Method"),wt.createElement(YM,null,wt.createElement(b0,null,wt.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),wt.createElement(b0,null,wt.createElement("input",{type:"radio",name:"authMethod",checked:t==="apikey",onChange:()=>n("apikey")}),"API Key"))),t==="oauth"&&wt.createElement(bo,null,wt.createElement(So,null,"Connect to UI Copilot"),e?wt.createElement(KM,null,wt.createElement(XM,null,wt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),wt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Copilot")),wt.createElement(QM,{onClick:o},"Disconnect")):wt.createElement("div",null,wt.createElement(wc,{style:{marginBottom:"12px"}},"Connect to UI Copilot to manage projects and integrations. This will open a browser window for authentication."),wt.createElement(xr,{onClick:r},"\u{1F517} Connect to UI Copilot"))),t==="apikey"&&wt.createElement(bo,null,wt.createElement(So,null,"API Key"),wt.createElement(wc,{style:{marginBottom:"12px"}},"Enter your UI Copilot API key below."),wt.createElement(wo,{type:"password",placeholder:"Enter API key",disabled:!0}),wt.createElement(xr,{disabled:!0,style:{marginTop:"12px"}},"Save API Key")))};import Rt,{useState as Ff}from"react";Ae();import{styled as cr}from"storybook/theming";var JM=cr.div({marginBottom:"30px"}),ZM=cr.div({display:"flex",gap:"8px",alignItems:"center"}),eB=cr(mn)({flex:1}),tB=cr(nn)({padding:"8px 12px",whiteSpace:"nowrap"}),nB=cr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),Ef=cr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Af=cr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Pf=cr(wo)({fontSize:"13px",padding:"6px 8px"}),rB=cr.div({display:"flex",gap:"8px",marginTop:"12px"}),w0=cr(nn)({fontSize:"12px",padding:"6px 12px"}),oB=cr(w0)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),k0=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o}=tr(),{currentStorybookPath:i}=Ke(),[s,a]=Ff(!1),[u,c]=Ff(!1),[l,p]=Ff({name:"",storybookRoot:"",figmaFileUrl:""}),f=C=>{n(C||null),a(!1)},d=()=>{if(a(!0),i){let C=i.replace(/\/+$/,"").split("/").pop()||"";p({storybookRoot:i,name:C,figmaFileUrl:""})}},h=async()=>{if(l.name.trim())try{c(!0);let C;if(l.figmaFileUrl.trim()){let T=l.figmaFileUrl.trim(),R=T.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);C=R?R[1]:T}let F=await o({name:l.name.trim(),storybookRoot:l.storybookRoot.trim()||void 0,figmaFileId:C});n(F.id),a(!1),p({name:"",storybookRoot:"",figmaFileUrl:""})}catch(C){console.error("Failed to create project:",C)}finally{c(!1)}},S=C=>{p(F=>{let T={...F,storybookRoot:C};if(!F.name&&C){let R=C.replace(/\/+$/,"").split("/").pop()||"";T.name=R}return T})};return Rt.createElement(JM,null,Rt.createElement(Gm,null,"Project"),Rt.createElement(ZM,null,Rt.createElement(eB,{value:t||"",onChange:C=>f(C.target.value),disabled:r||s},Rt.createElement("option",{value:""},"-- Select a project --"),e.map(C=>Rt.createElement("option",{key:C.id,value:C.id},C.name))),Rt.createElement(tB,{onClick:d,disabled:r,type:"button"},"+ New")),s&&Rt.createElement(nB,null,Rt.createElement(Ef,null,Rt.createElement(Af,null,"Storybook Path (for fix generation)"),Rt.createElement(Pf,{type:"text",placeholder:"/path/to/your/storybook",value:l.storybookRoot,onChange:C=>S(C.target.value)})),Rt.createElement(Ef,null,Rt.createElement(Af,null,"Project Name *"),Rt.createElement(Pf,{type:"text",placeholder:"my-storybook",value:l.name,onChange:C=>{let F=C.target.value;p(T=>({...T,name:F}))}})),Rt.createElement(Ef,null,Rt.createElement(Af,null,"Figma File URL (for design comparison)"),Rt.createElement(Pf,{type:"text",placeholder:"https://www.figma.com/file/...",value:l.figmaFileUrl,onChange:C=>{let F=C.target.value;p(T=>({...T,figmaFileUrl:F}))}})),Rt.createElement(rB,null,Rt.createElement(w0,{onClick:h,disabled:u||!l.name.trim()},u?"Creating...":"Create"),Rt.createElement(oB,{onClick:()=>{a(!1),p({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import Cn from"react";import{styled as Ps}from"storybook/theming";import gi,{useState as Lf,useEffect as iB,useCallback as v0}from"react";import{styled as mi}from"storybook/theming";Ae();Ue();var sB=mi.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),aB=mi.label(({theme:e})=>({display:"block",fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"8px"})),lB=mi.div({display:"flex",gap:"8px",alignItems:"center"}),cB=mi.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:ue,boxShadow:`0 0 0 1px ${ue}`},"&::placeholder":{color:e.color.mediumlight}})),uB=mi(nn)({whiteSpace:"nowrap"}),pB=mi.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),C0=()=>{let{selectedProjectId:e,projects:t}=Ke(),{sessionToken:n}=ze(),{updateProject:r}=tr(),o=t.find(S=>S.id===e),[i,s]=Lf(""),[a,u]=Lf(!1),[c,l]=Lf(null),p=o?.figmaFileUrl||o?.figmaFileId||"";iB(()=>{s(p),l(null)},[o?.id,p]);let f=i!==p,d=v0(async()=>{if(!(!e||!f))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});try{let S=J();await fetch(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}l({type:"success",message:"Saved"}),setTimeout(()=>l(null),3e3)}catch(S){l({type:"error",message:S instanceof Error?S.message:"Failed to save"})}finally{u(!1)}},[e,i,f,r]),h=v0(S=>{S.key==="Enter"&&f&&!a&&d()},[f,a,d]);return e?gi.createElement(sB,null,gi.createElement(aB,null,"Figma File URL"),gi.createElement(lB,null,gi.createElement(cB,{type:"text",value:i,onChange:S=>s(S.target.value),onKeyDown:h,placeholder:"https://www.figma.com/file/..."}),gi.createElement(uB,{onClick:d,disabled:!f||a},a?"Saving...":"Save")),c&&gi.createElement(pB,{variant:c.type},c.message)):null};import ut,{useState as Tl,useEffect as ER}from"react";import{styled as Bn}from"storybook/theming";Ae();Ue();import He,{useState as bi,useEffect as ZD,useCallback as ao}from"react";import{styled as Ut}from"storybook/theming";Ue();Ue();Pe();import Y,{useState as xi,useEffect as pS,useMemo as Wf,useCallback as dS}from"react";import{styled as Oe}from"storybook/theming";import Ie,{useState as uS,useEffect as dB,memo as fB}from"react";import{styled as me}from"storybook/theming";var T0=me.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}),I0=me.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}`})),F0=me.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),E0=me.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),A0=me(cn)({fontSize:"20px",padding:"4px 8px"}),P0=me.div({flex:1,overflow:"auto",padding:"20px"}),L0=me(Gr)({fontSize:"14px",marginBottom:"16px"}),Mf=me.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),M0=me.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:ue,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Bf=me.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"})),B0=me.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"})),D0=me.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),Cs=me.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})),Df=me.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:ue,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),Ts=me.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),Rf=me.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),zf=me.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Nf=me.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Of=me.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),R0=me.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),ul=me.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),z0=me.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),N0=me.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),O0=me.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:ue}})),_0=me.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ue}`,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:ue,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),$0=me.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:ue,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),U0=me.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),uY=me.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"})),j0=me.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ue}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),H0=me.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%"}}})),_f=me.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"}})),W0=me.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})),V0=me.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),G0=me.span(({theme:e})=>({color:e.color.defaultText})),pl=me.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%"}}})),q0=me.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),Y0=me.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),K0=me.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),X0=me(mn)({flex:1,width:"auto"}),Q0=me.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),J0=me.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"})),Z0=me.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),eS=me.span(({theme:e})=>({color:e.color.defaultText})),tS=me.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}})),nS=me.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}})),rS=me.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),dl=me.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),Is=me.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),hi=me(mn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),fl=me.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`}})),oS=me.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),iS=me.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:ue,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),sS=me.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),$f=me.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?ue: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:ue,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Uf=me.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?ue:e.appBorderColor}`,backgroundColor:t?ue:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),aS=me.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),lS=me.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:ue,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:ue,opacity:t?.6:.9}})),cS=me.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"}));Pe();var jf=fB(({src:e,alt:t,isComponentSet:n,loadingDone:r})=>{let[o,i]=uS(!1),[s,a]=uS(!1);return dB(()=>{i(!1),a(!1)},[e]),o?Ie.createElement(Cs,null,Ie.createElement(Rf,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Ie.createElement(Ts,null,"Failed to load")):e?Ie.createElement(Ie.Fragment,null,!s&&Ie.createElement(Cs,{style:{position:"absolute",inset:0}},Ie.createElement(Df,null),Ie.createElement(Ts,null,"Loading...")),Ie.createElement(D0,{src:e,alt:t,onLoad:()=>a(!0),onError:()=>i(!0),style:{opacity:s?1:0}})):r?Ie.createElement(Cs,null,Ie.createElement(Rf,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Ie.createElement(Ts,null,"No preview")):Ie.createElement(Cs,null,Ie.createElement(Df,null),Ie.createElement(Ts,null,"Loading..."))}),Fs=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,isLoadingVariants:i=!1,isExpanded:s,isNew:a=!1,onToggleExpand:u,onSelect:c,multiSelect:l=!1,selectedFrames:p=new Set,variantFilters:f=[]})=>{let d=e.type==="COMPONENT_SET",h=d&&(e.children&&e.children.length>0||(e.childCount??0)>0),S=e.children||o||[],C=Ie.useMemo(()=>S.length===0?[]:f.some(R=>R.value)?S.filter(R=>R.variantProperties?f.every(z=>z.value?R.variantProperties?.[z.property]===z.value:!0):!1):S,[S,f]),F=R=>{if(d&&h){u(e.id,R);return}c(e)},T=l?$f:M0;return Ie.createElement(Ie.Fragment,null,Ie.createElement(T,{onClick:F,title:e.name,isSelected:l?p.has(e.id):void 0,style:{cursor:"pointer"}},l&&!h&&Ie.createElement(Uf,{isSelected:p.has(e.id)},p.has(e.id)?"\u2713":""),d?Ie.createElement(B0,null,h&&Ie.createElement(O0,{onClick:R=>u(e.id,R),title:s?"Collapse variants":"Expand variants"},s?"\u25BC":"\u25B6"),h&&Ie.createElement($0,null,C.length>0&&C.length!==S.length?`${C.length} / ${S.length}`:e.childCount??S.length," variants"),Ie.createElement(jf,{src:t,alt:e.name,isComponentSet:!0})):Ie.createElement(Bf,null,Ie.createElement(jf,{src:t,alt:e.name,isComponentSet:!1})),Ie.createElement(zf,null,Ie.createElement(Nf,null,e.name,a&&Ie.createElement(cS,null,"New")),Ie.createElement(Of,null,e.type))),h&&s&&i&&Ie.createElement(Ie.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((R,z)=>Ie.createElement(j0,{key:`skeleton-${z}`},Ie.createElement(H0,null),Ie.createElement(_f,{width:"80%"}),Ie.createElement(_f,{width:"50%"})))),h&&s&&!i&&C.map(R=>Ie.createElement(Hf,{key:R.id,variant:R,thumbnail:r?.[R.id]||n[R.id],onSelect:c,multiSelect:l,isSelected:p.has(R.id),loadingDone:!!t||r!==void 0&&R.id in(r||{})})))},Hf=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1})=>Ie.createElement(r?$f:_0,{onClick:()=>{b.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Ie.createElement(Uf,{isSelected:o},o?"\u2713":""),Ie.createElement(Bf,null,Ie.createElement(jf,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i})),Ie.createElement(zf,null,Ie.createElement(Nf,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Ie.createElement(U0,null,Object.entries(e.variantProperties).map(([u,c])=>Ie.createElement(W0,{key:u},Ie.createElement(V0,null,u,":")," ",Ie.createElement(G0,null,c)))),Ie.createElement(Of,{style:{marginTop:"6px"}},"VARIANT")));var gB=Oe.div({display:"flex",height:"100%",overflow:"hidden"}),mB=Oe.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),hB=Oe.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),fS=Oe.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),gS=Oe.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),gl=Oe.div({display:"flex",gap:"8px",marginTop:"10px"}),xB=Oe(mn)({flex:1,width:"auto"}),mS=Oe(Gr)({flex:1,fontSize:"13px"}),yB=Oe.div({flex:1,overflow:"auto",padding:"8px"}),bB=Oe.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}})),SB=Oe.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),wB=Oe.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),kB=Oe.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})),vB=Oe.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),CB=Oe.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"})),TB=Oe.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),IB=Oe.div({flex:1,overflow:"hidden"}),FB=Oe.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),EB=Oe.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)"}}})),AB=Oe.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),PB=Oe.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),LB=Oe.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),MB=Oe.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Vf=Oe.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),BB=Oe.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Gf=20,DB=Oe.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),RB=Oe.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`}})),zB=Oe.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),NB=Oe.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`}})),OB=Oe.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),qf=Oe.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),Yf=Oe.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),_B=Oe.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),$B=Oe.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),hS=Oe.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),xS=Oe.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"}}})),yS=Oe.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"}}})),UB=()=>Y.createElement($B,null,Array.from({length:8}).map((e,t)=>Y.createElement(hS,{key:t},Y.createElement(xS,null),Y.createElement(yS,{width:`${60+t%3*15}%`})))),jB=Oe.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"})),HB=Oe.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"}),WB=Oe.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)"}}})),VB=Oe.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),bS=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=ks({projectId:i,limit:Gf,enabled:!!i}),[a,u]=xi("all"),[c,l]=xi(""),[p,f]=xi(null),[d,h]=xi(1),[S,C]=xi(null),[F,T]=xi(!1),R=Wf(()=>{let m=new Set;return e.forEach(v=>{v.componentTitle&&m.add(v.componentTitle)}),Array.from(m).sort()},[e]),z=Wf(()=>e.filter(m=>{if(a!=="all"&&m.componentTitle!==a)return!1;if(c){let v=c.toLowerCase();return m.name.toLowerCase().includes(v)||m.title.toLowerCase().includes(v)}return!0}),[e,a,c]),N=p?s.frames.find(m=>m.id===p):null,E=Wf(()=>{if(!p)return[];let m=s.variantChildren[p]||[];return m.length===0?[]:s.variantFilters.some(v=>v.value)?m.filter(v=>v.variantProperties?s.variantFilters.every(I=>I.value?v.variantProperties?.[I.property]===I.value:!0):!1):m},[p,s.variantChildren,s.variantFilters]),M=E.slice(0,d*Gf),g=E.length>d*Gf;pS(()=>{if(!p||M.length===0)return;let m=M.map(v=>v.id);s.fetchVariantThumbnails(p,m)},[p,M.length,d]),pS(()=>{T(!1)},[]);let k=dS(async m=>{if(n)try{let v=J(),I=localStorage.getItem("uicopilot_session_token");if(!(await fetch(`${v}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:m.id,name:m.name})})).ok)throw new Error("Failed to save mapping");o(n,m.id,m.name)}catch(v){b.error("[MapStoriesTab] Error saving mapping:",v)}},[n,i,o]),w=dS((m,v)=>{if(v.stopPropagation(),p===m){f(null),h(1);return}f(m),h(1),!s.variantThumbnails[m]&&!s.loadingVariants.has(m)&&s.toggleExpanded(m,v)},[p,s]),A=e.find(m=>m.id===n);return t?Y.createElement(_B,null,"Loading stories..."):Y.createElement(gB,null,Y.createElement(mB,null,Y.createElement(fS,null,Y.createElement(gS,null,"Storybook Stories"),Y.createElement(gl,null,Y.createElement(xB,{value:a,onChange:m=>u(m.target.value)},Y.createElement("option",{value:"all"},"All Components"),R.map(m=>Y.createElement("option",{key:m,value:m},m)))),Y.createElement(gl,null,Y.createElement(mS,{type:"text",placeholder:"Search stories...",value:c,onChange:m=>l(m.target.value)}))),Y.createElement(yB,null,z.length===0?Y.createElement(Yf,null,"No stories found"):z.map(m=>Y.createElement(bB,{key:m.id,selected:m.id===n,mapped:!!m.figmaMapping,onClick:()=>r(m.id)},Y.createElement(SB,null,Y.createElement(wB,null,m.name),Y.createElement(kB,{mapped:!!m.figmaMapping},m.figmaMapping?"Mapped":"Unmapped")),Y.createElement(vB,null,m.title),m.figmaMapping&&Y.createElement(CB,{onMouseEnter:()=>C(m.id),onMouseLeave:()=>C(null)},(()=>{let v=m.figmaMapping?.figmaNodeId,I=v?s.resolveThumbnail(v):void 0;return Y.createElement(Y.Fragment,null,I?Y.createElement(TB,{src:I,alt:m.figmaMapping?.figmaFrameName||""}):Y.createElement("span",null,"\u{1F517}"),S===m.id&&I&&Y.createElement(EB,null,Y.createElement(AB,{src:I,alt:m.figmaMapping?.figmaFrameName||""}),Y.createElement(PB,null,m.figmaMapping?.figmaFrameName)))})(),Y.createElement(IB,null,Y.createElement(FB,null,m.figmaMapping.figmaFrameName))))))),Y.createElement(hB,null,n?Y.createElement(Y.Fragment,null,Y.createElement(jB,null,Y.createElement("span",null,"Click a Figma component below to link it to"," ",Y.createElement("strong",null,A?.name))),Y.createElement(fS,null,Y.createElement(gS,null,"Figma Components"),Y.createElement(gl,null,Y.createElement(MB,null,Y.createElement(Vf,null,Y.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:m=>s.setShowComponentSets(m.target.checked)}),"Component Sets"),Y.createElement(Vf,null,Y.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:m=>s.setShowFrames(m.target.checked)}),"Frames"),Y.createElement(Vf,null,Y.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:m=>s.setShowComponents(m.target.checked)}),"Components")),s.availablePages.length>1&&Y.createElement(hi,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:m=>s.setFigmaPage(m.target.value)},Y.createElement("option",{value:""},"All pages"),s.availablePages.map(m=>Y.createElement("option",{key:m,value:m},m)))),s.availableFilters.length>0&&Y.createElement(dl,null,Y.createElement(Is,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:m,values:v})=>{let I=s.variantFilters.find(x=>x.property===m);return Y.createElement(hi,{key:m,isActive:!!I?.value,value:I?.value||"",onChange:x=>s.handleFilterChange(m,x.target.value)},Y.createElement("option",{value:""},m),v.map(x=>Y.createElement("option",{key:x,value:x},m,"=",x)))}),s.availableFilters.length>5&&Y.createElement(Is,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(m=>m.value)&&Y.createElement(fl,{onClick:s.clearFilters},"Clear All")),Y.createElement(gl,null,Y.createElement(mS,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:m=>s.setSearch(m.target.value)}))),Y.createElement(LB,null,F&&Y.createElement(HB,null,Y.createElement(WB,null),Y.createElement(VB,null,"Loading thumbnails...")),s.isLoading?Y.createElement(UB,null):s.filteredFrames.length===0?Y.createElement(Yf,null,Y.createElement("span",null,"No components found")):Y.createElement(BB,null,p&&N?Y.createElement(Y.Fragment,null,Y.createElement(zB,null,Y.createElement(NB,{onClick:()=>{f(null),h(1)}},"Back"),Y.createElement(OB,null,N.name)),s.loadingVariants.has(p)?Y.createElement(Y.Fragment,null,Y.createElement(qf,null,"Loading ",N.childCount??"..."," variants..."),Array.from({length:Math.min(8,N.childCount??8)}).map((m,v)=>Y.createElement(hS,{key:`variant-skeleton-${v}`},Y.createElement(xS,null),Y.createElement(yS,{width:`${60+v%3*15}%`})))):Y.createElement(Y.Fragment,null,Y.createElement(qf,null,"Showing ",M.length," of ",E.length," variants"),M.map(m=>Y.createElement(Hf,{key:m.id,variant:m,thumbnail:s.variantThumbnails[p]?.[m.id]||s.thumbnails[m.id],onSelect:k,loadingDone:s.variantThumbnails[p]!==void 0&&!s.loadingVariants.has(p)})))):Y.createElement(Y.Fragment,null,Y.createElement(qf,null,"Showing ",s.frames.length," of ",s.totalFrames," components"),s.filteredFrames.map(m=>Y.createElement(Fs,{key:m.id,frame:m,thumbnail:s.thumbnails[m.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[m.id],variantChildren:s.variantChildren[m.id],isLoadingVariants:s.loadingVariants.has(m.id),isExpanded:!1,onToggleExpand:w,onSelect:k,variantFilters:s.variantFilters}))),(p?g:s.hasMore)&&Y.createElement(DB,null,Y.createElement(RB,{disabled:s.loadingMore,onClick:async()=>{p?h(m=>m+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):Y.createElement(Yf,null,Y.createElement("span",null,"Select a story from the left to link it to Figma"))))};Ue();import Ve,{useState as Kf,useMemo as SS,useCallback as wS}from"react";import{styled as vt}from"storybook/theming";var GB=vt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),qB=vt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),YB=vt(mn)({width:"auto",minWidth:"200px"}),KB=vt(Gr)({fontSize:"13px",minWidth:"250px"}),XB=vt.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}})),QB=vt.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}})),JB=vt.div({flex:1,overflow:"auto"}),ZB=vt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),eD=vt.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),ml=vt.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}`})),tD=vt.tbody({}),nD=vt.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),hl=vt.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),rD=vt.div({display:"flex",flexDirection:"column",gap:"2px"}),oD=vt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),iD=vt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),sD=vt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),aD=vt.div({display:"flex",alignItems:"center",gap:"8px"}),lD=vt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),cD=vt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),kS=vt.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`}})),uD=vt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),pD=vt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),vS=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=Kf("all"),[a,u]=Kf(""),[c,l]=Kf(!0),p=SS(()=>{let C=new Set;return e.forEach(F=>{F.componentTitle&&C.add(F.componentTitle)}),Array.from(C).sort()},[e]),f=SS(()=>e.filter(C=>{if(i!=="all"&&C.componentTitle!==i||!c&&!C.figmaMapping)return!1;if(a){let F=a.toLowerCase();return C.name.toLowerCase().includes(F)||C.title.toLowerCase().includes(F)||(C.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),d=wS(async C=>{try{let F=J(),T=localStorage.getItem("uicopilot_session_token");if(!(await fetch(`${F}/api/mappings?projectId=${o}&storyId=${C}`,{method:"DELETE",headers:{Authorization:`Bearer ${T}`}})).ok)throw new Error("Failed to delete mapping");r(C)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),h=wS(()=>{let C=e.filter(z=>z.figmaMapping).map(z=>({storyId:z.id,storyName:z.name,storyTitle:z.title,figmaNodeId:z.figmaMapping.figmaNodeId,figmaFrameName:z.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(C,null,2)],{type:"application/json"}),T=URL.createObjectURL(F),R=document.createElement("a");R.href=T,R.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL(T)},[e]);if(t)return Ve.createElement(pD,null,"Loading mappings...");let S=e.filter(C=>C.figmaMapping).length;return Ve.createElement(GB,null,Ve.createElement(qB,null,Ve.createElement(YB,{value:i,onChange:C=>s(C.target.value)},Ve.createElement("option",{value:"all"},"All Components"),p.map(C=>Ve.createElement("option",{key:C,value:C},C))),Ve.createElement(KB,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:C=>u(C.target.value)}),Ve.createElement(XB,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),Ve.createElement(QB,{onClick:h,disabled:S===0},"\u{1F4E5} Export JSON")),f.length===0?Ve.createElement(uD,null,Ve.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):Ve.createElement(JB,null,Ve.createElement(ZB,null,Ve.createElement(eD,null,Ve.createElement("tr",null,Ve.createElement(ml,{style:{width:"35%"}},"Story"),Ve.createElement(ml,{style:{width:"35%"}},"Figma Component"),Ve.createElement(ml,{style:{width:"15%"}},"Status"),Ve.createElement(ml,{style:{width:"15%"}},"Actions"))),Ve.createElement(tD,null,f.map(C=>Ve.createElement(nD,{key:C.id,mapped:!!C.figmaMapping},Ve.createElement(hl,null,Ve.createElement(rD,null,Ve.createElement(oD,null,C.name),Ve.createElement(iD,null,C.title))),Ve.createElement(hl,null,Ve.createElement(sD,{mapped:!!C.figmaMapping},C.figmaMapping?Ve.createElement(Ve.Fragment,null,Ve.createElement("span",null,"\u{1F3A8}"),C.figmaMapping.figmaFrameName):"\u2014")),Ve.createElement(hl,null,Ve.createElement(aD,null,Ve.createElement(lD,{mapped:!!C.figmaMapping}),Ve.createElement(cD,{mapped:!!C.figmaMapping},C.figmaMapping?"Mapped":"Unmapped"))),Ve.createElement(hl,null,C.figmaMapping?Ve.createElement(kS,{variant:"unlink",onClick:()=>d(C.id)},"Unlink"):Ve.createElement(kS,{variant:"link",onClick:()=>n(C.id)},"Link"))))))))};import we,{useState as kl,useMemo as PS}from"react";import{styled as rt}from"storybook/theming";import CS from"react";import{styled as TS,keyframes as dD}from"storybook/theming";var fD=dD`
31
+ 0% { transform: rotate(0deg); }
32
+ 100% { transform: rotate(360deg); }
33
+ `,gD=TS.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${fD} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),mD=TS.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}}})),kr=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>CS.createElement(mD,{variant:r,disabled:t||e,onClick:n},e&&CS.createElement(gD,null),e&&i?i:o);Ue();import Gt from"react";import{styled as Es}from"storybook/theming";var IS=Es.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"})),hD=Es.div({display:"flex",alignItems:"center",gap:"12px"}),xl=Es.span({whiteSpace:"nowrap"}),FS=Es.div({display:"flex",alignItems:"center",gap:"8px"}),yl=Es.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),bl=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*uh;return r?Gt.createElement(IS,null,Gt.createElement(xl,null,o.toLocaleString()," tokens"),Gt.createElement(FS,null,Gt.createElement(yl,null,"$",n.toFixed(4)),Gt.createElement("span",null,"\xB7"),Gt.createElement(yl,null,"\u20AA",i.toFixed(2)))):Gt.createElement(IS,null,Gt.createElement(hD,null,Gt.createElement(xl,null,e.toLocaleString()," input"),Gt.createElement("span",null,"+"),Gt.createElement(xl,null,t.toLocaleString()," output"),Gt.createElement("span",null,"="),Gt.createElement(xl,null,Gt.createElement("strong",null,o.toLocaleString())," tokens")),Gt.createElement(FS,null,Gt.createElement(yl,null,"$",n.toFixed(4)),Gt.createElement("span",null,"\xB7"),Gt.createElement(yl,null,"\u20AA",i.toFixed(2))))};import vn from"react";import{styled as oo}from"storybook/theming";function Xf(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var xD=oo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),ES=oo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),yD=oo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),bD=oo.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})),SD=oo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),wD=oo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),kD=oo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),vD=oo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),AS=({data:e,color:t,compact:n})=>n?vn.createElement(ES,{color:t},e.summary):vn.createElement(xD,null,vn.createElement(ES,{color:t},e.summary),e.mappings&&e.mappings.length>0&&vn.createElement(yD,null,e.mappings.map((r,o)=>vn.createElement(vn.Fragment,{key:o},vn.createElement(bD,null,r.from," ",vn.createElement(SD,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&vn.createElement(wD,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&vn.createElement(vn.Fragment,null,e.defaults.map((r,o)=>vn.createElement(kD,{key:o},vn.createElement(vD,null,r.choice),vn.createElement("span",null,"\u2014 ",r.why)))));var CD=rt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),TD=rt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),ID=rt.div({display:"flex",flexDirection:"column",gap:"4px"}),FD=rt.div({display:"flex",alignItems:"center",gap:"10px"}),ED=rt.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"})),LS=rt.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})),AD=rt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),PD=rt.div({display:"flex",gap:"8px"}),LD=rt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),MD=rt(Gr)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),BD=rt.div({display:"flex",gap:"4px"}),Sl=rt.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}})),DD=rt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),RD=rt.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}})),zD=rt.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}`}})),ND=rt.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"})),wl=rt.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}`})),OD=rt.img({width:"100%",height:"100%",objectFit:"contain"}),zS=rt.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)"}}})),MS=rt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),BS=rt.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"})),Qf=rt.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"})),YY=rt.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"})),_D=rt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),$D=rt.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})),UD=rt.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}})),jD=rt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),HD=rt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),WD=rt.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})),VD=rt.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})),GD=rt.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"}})),KY=rt.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})),DS=({src:e,alt:t})=>{let[n,r]=kl(!1);return we.createElement(we.Fragment,null,!n&&we.createElement(zS,null),we.createElement(OD,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function RS(e){return e>=90?"high":e>=70?"medium":"low"}function qD(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var NS=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:s,source:a,resolveThumbnail:u,resolveStoryScreenshot:c,isCapturingScreenshots:l,onBrowse:p})=>{let[f,d]=kl(()=>{let w=new Set;for(let A of e.mappings)A.confidence>=90&&w.add(A.storyId);return w}),[h,S]=kl(""),[C,F]=kl("all"),T=PS(()=>{let w=new Map;for(let A of t)w.set(A.id,{name:A.name,title:A.title});return w},[t]),R=PS(()=>{let w=e.mappings;if(C!=="all"&&(w=w.filter(A=>RS(A.confidence)===C)),h.trim()){let A=h.toLowerCase();w=w.filter(m=>{let v=T.get(m.storyId);return v?.name.toLowerCase().includes(A)||v?.title.toLowerCase().includes(A)||m.componentSetName.toLowerCase().includes(A)||m.figmaFrameName.toLowerCase().includes(A)})}return w},[e.mappings,C,h,T]),z=w=>{d(A=>{let m=new Set(A);return m.has(w)?m.delete(w):m.add(w),m})},N=()=>{let w=e.mappings.filter(A=>f.has(A.storyId));n(w)},E=e.mappings.filter(w=>w.confidence>=90).length,M=e.mappings.filter(w=>w.confidence>=70&&w.confidence<90).length,g=e.mappings.filter(w=>w.confidence<70).length,k=e.usage;return we.createElement(CD,null,we.createElement(TD,null,we.createElement(ID,null,we.createElement(FD,null,we.createElement(ED,null,"Auto-Map Results"),we.createElement(LS,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&we.createElement(LS,{variant:"danger"},e.unmatched.length," unmatched"),a&&we.createElement(VD,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),we.createElement(AD,null,"Review matches below. Uncheck any incorrect mappings before applying.")),we.createElement(PD,null,a==="cache"&&o&&we.createElement(GD,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),we.createElement(kr,{onClick:r,variant:"ghost"},"Cancel"),we.createElement(kr,{loading:i,onClick:N,loadingText:"Applying..."},"Apply ",f.size," Selected"))),we.createElement(LD,null,we.createElement(MD,{type:"text",placeholder:"Filter stories...",value:h,onChange:w=>S(w.target.value)}),we.createElement(BD,null,we.createElement(Sl,{active:C==="all",onClick:()=>F("all")},"All ",e.mappings.length),E>0&&we.createElement(Sl,{active:C==="high",onClick:()=>F("high")},"\u226590% (",E,")"),M>0&&we.createElement(Sl,{active:C==="medium",onClick:()=>F("medium")},"70-89% (",M,")"),g>0&&we.createElement(Sl,{active:C==="low",onClick:()=>F("low")},"<70% (",g,")"))),we.createElement(DD,null,R.map(w=>{let A=T.get(w.storyId),m=RS(w.confidence),v=f.has(w.storyId),I=m==="low";return we.createElement(RD,{key:w.storyId,dimmed:I&&!v},we.createElement(zD,{checked:v,onClick:()=>z(w.storyId)},v?"\u2713":""),(()=>{let x=c?.(w.storyId);return x?we.createElement(wl,null,we.createElement(DS,{src:x,alt:A?.name||w.storyId})):l?we.createElement(wl,null,we.createElement(zS,null)):we.createElement(ND,{bgColor:I?"#f1f5f9":"#eff6ff"},we.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:I?"#94a3b8":"#3b82f6"}},(A?.name||"?").substring(0,4)))})(),we.createElement(MS,null,we.createElement(BS,null,A?.name||w.storyId),we.createElement(Qf,null,A?.title||"")),we.createElement(_D,null,"\u2192"),(()=>{let x=u?.(w.figmaNodeId),P=Xf(w.reason),L=P.summary+(P.candidates?` (${P.candidates} candidates)`:"");return x?we.createElement(wl,{title:L},we.createElement(DS,{src:x,alt:w.figmaFrameName})):we.createElement(wl,{title:L},we.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),we.createElement(MS,null,we.createElement(BS,null,w.componentSetName),we.createElement(Qf,null,w.figmaFrameName),we.createElement(AS,{data:Xf(w.reason),color:qD(m)})),we.createElement($D,{level:m},w.confidence,"%"),p&&we.createElement(UD,{onClick:()=>p(w.componentSetName)},"Browse"))}),e.unmatched.length>0&&we.createElement(jD,null,we.createElement(Qf,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),we.createElement(HD,null,e.unmatched.map(w=>{let A=T.get(w);return we.createElement(WD,{key:w},we.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),A?`${A.name} (${A.title})`:w)})))),k&&a!=="cache"&&we.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},we.createElement(bl,{inputTokens:k.inputTokens||0,outputTokens:k.outputTokens||0,costUsd:k.costUsd||0})))};Ue();Pe();import{useState as io,useCallback as so,useRef as YD}from"react";import{useStorybookApi as KD}from"storybook/manager-api";function OS({projectId:e}){let t=KD(),n=YD(null),[r,o]=io(!1),[i,s]=io(!1),[a,u]=io(!1),[c,l]=io(null),[p,f]=io(null),[d,h]=io(null),[S,C]=io(""),[F,T]=io(null),R=so(async()=>{let A=await fetch("/index.json");if(!A.ok)throw new Error("Failed to fetch Storybook index");let m=await A.json(),v=m.entries||m.stories||{},I=Object.keys(v).filter(L=>v[L].type==="story");b.debug(`[useAutoMap] Found ${I.length} stories in index.json`);let x=[];for(let L of I){let D=v[L],O=t.getData(L),y={...O?.initialArgs||{}},U=O?.argTypes||{};for(let[V,B]of Object.entries(U))if(!(V in y)){let X=B;if(X.defaultValue!==void 0)y[V]=X.defaultValue;else if(X.table?.defaultValue?.summary!==void 0){let ee=X.table.defaultValue.summary;ee==="false"?y[V]=!1:ee==="true"?y[V]=!0:y[V]=ee}}x.push({id:L,name:D.name||L.split("--").pop()||L,title:D.title||"",initialArgs:y,argTypes:U})}let P=x.filter(L=>Object.keys(L.initialArgs).length>0);return b.debug(`[useAutoMap] Manifest: ${x.length} stories, ${P.length} with args`),x},[t]),z=so(async()=>{if(!e)return!1;try{let A=J(),m=localStorage.getItem("uicopilot_session_token");if(!m)return!1;let v=await fetch(`${A}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${m}`}});if(!v.ok)return!1;let I=await v.json();return I.hasSuggestions&&I.mappings?.length>0?(f(I),T("cache"),C(`Loaded ${I.mappings.length} saved suggestions`),b.debug(`[useAutoMap] Loaded ${I.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),N=so(async A=>{o(!0),C("Collecting story information...");let m;try{if(m=await R(),A?.length&&(m=m.filter(I=>!A.includes(I.id)),b.debug(`[useAutoMap] After excluding mapped: ${m.length} stories`)),m.length===0){l("No unmapped stories found"),o(!1);return}h(m)}catch(I){l(I instanceof Error?I.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),C(`Analyzing ${m.length} stories against Figma components...`);let v=new AbortController;n.current=v;try{let I=J(),x=localStorage.getItem("uicopilot_session_token");if(!x)throw new Error("Not authenticated");let P=await fetch(`${I}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({projectId:e,stories:m.map(D=>({id:D.id,name:D.name,title:D.title,initialArgs:D.initialArgs,argTypes:D.argTypes}))}),signal:v.signal});if(!P.ok){let D=await P.json();throw new Error(D.error||"Auto-map failed")}let L=await P.json();f(L),T("llm"),C(`Found ${L.stats.matched} matches (${L.stats.highConfidence} high confidence)`),b.debug(`[useAutoMap] Results: ${L.stats.matched}/${L.stats.total} matched, ${L.unmatched.length} unmatched`)}catch(I){if(I instanceof DOMException&&I.name==="AbortError"){C("Cancelled");return}l(I instanceof Error?I.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,R]),E=so(async A=>{if(!e)return;if(l(null),f(null),T(null),o(!0),C("Checking for existing suggestions..."),await z()){o(!1);return}await N(A)},[e,z,N]),M=so(async A=>{e&&(l(null),f(null),T(null),await N(A))},[e,N]),g=so(async A=>{if(!(!e||A.length===0)){u(!0),C(`Applying ${A.length} mappings...`);try{let m=J(),v=localStorage.getItem("uicopilot_session_token");if(!v)throw new Error("Not authenticated");let I=0;for(let x of A)try{(await fetch(`${m}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:e,storyId:x.storyId,figmaNodeId:x.figmaNodeId,name:x.figmaFrameName||x.componentSetName})})).ok?I++:b.warn(`[useAutoMap] Failed to apply mapping for ${x.storyId}`)}catch(P){b.error(`[useAutoMap] Error applying mapping for ${x.storyId}:`,P)}C(`Applied ${I}/${A.length} mappings`),b.debug(`[useAutoMap] Applied ${I}/${A.length} mappings`)}catch(m){l(m instanceof Error?m.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),k=so(()=>{n.current?.abort()},[]),w=so(()=>{f(null),h(null),l(null),C(""),T(null)},[]);return{collectAndMap:E,rerun:M,loadExisting:z,applyMappings:g,cancel:k,reset:w,isCollecting:r,isMapping:i,isApplying:a,error:c,results:p,manifest:d,progress:S,source:F}}Pe();import{useState as Jf,useEffect as XD,useRef as _S}from"react";var $S=2;async function QD(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 US(e){let[t,n]=Jf({}),[r,o]=Jf(0),[i,s]=Jf(!1),a=_S(null),u=_S(""),c=e.join(",");return XD(()=>{if(!e.length||c===u.current)return;u.current=c,n({}),o(0),s(!0);let l=new AbortController;a.current=l;let p=0;return(async()=>{for(let d=0;d<e.length&&!l.signal.aborted;d+=$S){let h=e.slice(d,d+$S),S=await Promise.all(h.map(F=>QD(F,l.signal).then(T=>({id:F,img:T}))));if(l.signal.aborted)break;let C={};for(let{id:F,img:T}of S)p++,T&&(C[F]=T);Object.keys(C).length>0&&n(F=>({...F,...C})),o(p)}s(!1),b.debug(`[useStoryScreenshots] Captured ${p}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import be,{useState as jS,useEffect as vl,useMemo as JD}from"react";Pe();var yi=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=ks({projectId:r||"",enabled:e&&!!r}),p=be.useRef(!1);vl(()=>{e&&c&&!p.current&&(l.setSearch(c),p.current=!0),e||(p.current=!1)},[e,c]);let[f,d]=jS(new Set),[h,S]=jS(i||o[0]?.id||"");vl(()=>{i&&S(i)},[i]),vl(()=>{l.expandedSets.forEach(M=>{let g=l.variantChildren[M];if(!g||g.length===0)return;let k=g;l.variantFilters.some(A=>A.value)&&(k=g.filter(A=>A.variantProperties?l.variantFilters.every(m=>m.value?A.variantProperties?.[m.property]===m.value:!0):!1));let w=k.slice(0,20).map(A=>A.id);w.length>0&&l.fetchVariantThumbnails(M,w)})},[l.expandedSets,l.variantChildren,l.variantFilters]),vl(()=>{d(new Set)},[h]);let C=JD(()=>{let M=[];return l.filteredFrames.forEach(g=>{if(g.type==="COMPONENT_SET"&&g.children){let k=l.variantFilters.some(w=>w.value)?g.children.filter(w=>w.variantProperties?l.variantFilters.every(A=>A.value?w.variantProperties?.[A.property]===A.value:!0):!1):g.children;M.push(...k)}else M.push(g)}),M},[l.filteredFrames,l.variantFilters]),F=M=>{if(a)d(g=>{let k=new Set(g);return k.has(M.id)?k.delete(M.id):k.add(M.id),k});else{let g=l.resolveThumbnail(M.id);try{n({...M,thumbnail:g})}catch(k){b.error("[ComponentBrowserModal] onSelect threw error:",k)}t()}},T=()=>{let M=C.map(k=>k.id),g=M.every(k=>f.has(k));d(g?new Set:new Set(M))},R=()=>{if(u&&f.size>0){let M=C.filter(g=>f.has(g.id)).map(g=>({...g,thumbnail:l.resolveThumbnail(g.id)}));u(M),d(new Set)}},z=M=>{S(M),s?.(M)},N=M=>{M.target===M.currentTarget&&t()},E=o.find(M=>M.id===h);return e?be.createElement(T0,{onClick:N},be.createElement(I0,null,be.createElement(F0,null,be.createElement(E0,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(A0,{onClick:t},"\xD7"))),be.createElement(P0,null,l.error&&be.createElement(N0,null,l.error),!l.error&&be.createElement(be.Fragment,null,o.length>0&&be.createElement(Y0,null,be.createElement(K0,null,"Story:"),be.createElement(X0,{value:h,onChange:M=>z(M.target.value)},o.map(M=>be.createElement("option",{key:M.id,value:M.id},M.name,M.mappingsCount?` (${M.mappingsCount} linked)`:""))),E?.mappingsCount?be.createElement(Q0,{hasMapping:!0},E.mappingsCount," frames linked"):null),be.createElement(R0,null,be.createElement(ul,null,be.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:M=>l.setShowComponentSets(M.target.checked)}),"Component Sets"),be.createElement(ul,null,be.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:M=>l.setShowFrames(M.target.checked)}),"Frames"),be.createElement(ul,null,be.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:M=>l.setShowComponents(M.target.checked)}),"Components"),l.availablePages.length>1&&be.createElement(hi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:M=>l.setFigmaPage(M.target.value),style:{marginLeft:"auto"}},be.createElement("option",{value:""},"All pages"),l.availablePages.map(M=>be.createElement("option",{key:M,value:M},M)))),l.filterSuggestion&&be.createElement(J0,null,be.createElement(Z0,null,"AI suggests:"),be.createElement(eS,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([M,g])=>`${M}=${g}`).join(", ")),be.createElement(tS,{onClick:l.applySuggestedFilters},"Apply"),be.createElement(nS,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&be.createElement(rS,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&be.createElement(dl,null,be.createElement(Is,null,"Filters:"),l.availableFilters.map(({property:M,values:g})=>{let k=l.variantFilters.find(w=>w.property===M);return be.createElement(hi,{key:M,isActive:!!k?.value,value:k?.value||"",onChange:w=>l.handleFilterChange(M,w.target.value)},be.createElement("option",{value:""},M),g.map(w=>be.createElement("option",{key:w,value:w},M,"=",w)))}),l.variantFilters.some(M=>M.value)&&be.createElement(fl,{onClick:l.clearFilters},"Clear All")),be.createElement(L0,{type:"text",placeholder:"Search frames...",value:l.search,onChange:M=>l.setSearch(M.target.value),autoFocus:!0}),a&&C.length>0&&be.createElement(oS,null,be.createElement(iS,{onClick:T},f.size===C.length?"Deselect All":"Select All Visible"),be.createElement(sS,null,f.size>0?`${f.size} selected of `:"Showing ",C.length," frames")),l.isLoading&&be.createElement(Mf,null,Array.from({length:6}).map((M,g)=>be.createElement(q0,{key:g},be.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},be.createElement(pl,{width:"100%",height:"100%"})),be.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},be.createElement(pl,{width:"80%",height:"16px"}),be.createElement(pl,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&be.createElement(z0,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&be.createElement(Mf,null,l.filteredFrames.map(M=>be.createElement(Fs,{key:M.id,frame:M,thumbnail:l.thumbnails[M.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[M.id],variantChildren:l.variantChildren[M.id],isLoadingVariants:l.loadingVariants.has(M.id),isExpanded:l.expandedSets.has(M.id),isNew:l.recentlyAdded.has(M.name),onToggleExpand:l.toggleExpanded,onSelect:F,multiSelect:a,selectedFrames:f,variantFilters:l.variantFilters}))))),a&&be.createElement(aS,null,be.createElement(lS,{disabled:f.size===0,onClick:R},"Link ",f.size," Selected")))):null};Ae();var eR=Ut.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}),tR=Ut.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"})),nR=Ut.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),rR=Ut.div({display:"flex",alignItems:"center",gap:"20px"}),oR=Ut.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),iR=Ut.div({display:"flex",gap:"4px"}),HS=Ut(Vr)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),sR=Ut(cn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),aR=Ut.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),lR=Ut.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),cR=Ut.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),uR=Ut.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),pR=Ut.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),dR=Ut.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),fR=Ut.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),gR=Ut.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),mR=Ut.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),hR=Ut.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"}})),WS=Ut.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"}})),VS=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=bi("map"),[i,s]=bi([]),[a,u]=bi(!0),[c,l]=bi(null),[p,f]=bi(!1),[d,h]=bi(null),S=OS({projectId:n}),{refreshMappings:C}=Ge(),{featureFlags:F}=ye(),T=He.useMemo(()=>S.results?.mappings.map(x=>x.storyId)||[],[S.results]),R=US(T),z=ao(async()=>{u(!0);try{let x=await fetch("/index.json");if(!x.ok)throw new Error("Failed to fetch index.json");let P=await x.json(),L=P.entries||P.stories||{},D=Object.entries(L).filter(([,y])=>y.type==="story").map(([y,U])=>({id:y,name:U.name||y.split("--").pop()||y,title:U.title||"",importPath:U.importPath,componentTitle:U.title?.split("/").slice(0,-1).join("/")||U.title,figmaMapping:null}));try{let y=J(),U=localStorage.getItem("uicopilot_session_token"),V=await fetch(`${y}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${U}`}});if(V.ok){let B=await V.json(),X=new Map((B.mappings||[]).map(ee=>[ee.storyId,ee]));D.forEach(ee=>{let Q=X.get(ee.id);Q&&Q.figmaNodeId&&(ee.figmaMapping={figmaNodeId:Q.figmaNodeId,figmaFrameName:Q.name||Q.figmaFrameName||""})})}}catch(y){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",y)}s(D);let O=D.find(y=>!y.figmaMapping);O?l(O.id):D.length>0&&l(D[0].id)}catch(x){console.error("[StoryMappingAssistant] Error fetching stories:",x)}finally{u(!1)}},[n]);ZD(()=>{e&&z()},[e,z]);let N=ao((x,P,L)=>{s(y=>y.map(U=>U.id===x?{...U,figmaMapping:{figmaNodeId:P,figmaFrameName:L}}:U));let D=i.findIndex(y=>y.id===x),O=i.find((y,U)=>U>D&&!y.figmaMapping);O&&l(O.id)},[i]),E=ao(x=>{s(P=>P.map(L=>L.id===x?{...L,figmaMapping:null}:L))},[]),M=ao(x=>{l(x),o("map")},[]),g=ao(()=>{let x=i.filter(P=>P.figmaMapping).map(P=>P.id);S.collectAndMap(x)},[i,S]),k=ao(()=>{let x=i.filter(P=>P.figmaMapping).map(P=>P.id);f(!1),S.rerun(x)},[i,S]),w=ao(async x=>{await S.applyMappings(x),f(!1),S.reset(),z(),C()},[S,z,C]),A=ao(()=>{f(!1),S.reset()},[S]);He.useEffect(()=>{S.results&&f(!0)},[S.results]);let m=x=>{x.target===x.currentTarget&&t()};if(!e)return null;let v=i.filter(x=>x.figmaMapping).length,I=i.length;return He.createElement(He.Fragment,null,He.createElement(eR,{onClick:m},He.createElement(tR,{onClick:x=>x.stopPropagation()},He.createElement(nR,null,He.createElement(rR,null,He.createElement(oR,null,He.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),He.createElement(iR,null,He.createElement(HS,{active:r==="map",onClick:()=>o("map")},"Map Stories"),He.createElement(HS,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),He.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},F.enableAutoMap&&!p&&!S.isCollecting&&!S.isMapping&&He.createElement(hR,{onClick:g,disabled:a||i.length===0},He.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},He.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),He.createElement("path",{d:"M2 17l10 5 10-5"}),He.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),He.createElement(sR,{onClick:t},"\xD7"))),He.createElement(aR,null,(S.isCollecting||S.isMapping)&&He.createElement(uR,null,He.createElement(pR,null,He.createElement(gR,null,He.createElement(mR,null)),He.createElement(dR,null,"Auto-mapping stories to Figma"),He.createElement(fR,null,S.progress),He.createElement(kr,{onClick:S.cancel,variant:"ghost"},"Cancel"))),p&&S.results&&He.createElement(NS,{results:S.results,stories:i,onApply:w,onCancel:A,onRerun:k,isApplying:S.isApplying,isRerunning:S.isCollecting||S.isMapping,source:S.source,resolveThumbnail:x=>S.results?.thumbnailUrls?.[x],resolveStoryScreenshot:x=>R.screenshots[x],isCapturingScreenshots:R.isCapturing,onBrowse:x=>h(x)}),!p&&!S.isCollecting&&!S.isMapping&&(r==="map"?He.createElement(bS,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:N,projectId:n}):He.createElement(vS,{stories:i,loading:a,onLink:M,onUnlink:E,projectId:n}))),He.createElement(lR,null,He.createElement(cR,null,He.createElement("span",null,"Total: ",I," stories"),He.createElement(WS,{type:"mapped"},He.createElement("span",{className:"dot"}),v," mapped"),He.createElement(WS,{type:"unmapped"},He.createElement("span",{className:"dot"}),I-v," unmapped"))))),He.createElement(yi,{isOpen:!!d,onClose:()=>h(null),onSelect:()=>h(null),projectId:n,initialSearch:d||void 0}))};import zr,{useEffect as xR,useCallback as yR}from"react";import{styled as Do,keyframes as GS}from"storybook/theming";var bR=GS({from:{opacity:0},to:{opacity:1}}),SR=GS({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),wR=Do.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${bR} 150ms ease-out`}),kR=Do.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:`${SR} 150ms ease-out`})),vR=Do.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),CR=Do.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})),TR=Do.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),IR=Do.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}})),FR=Do.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover":{opacity:.9}})),Cl=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",onConfirm:s,onCancel:a})=>{let u=yR(c=>{c.key==="Escape"&&a()},[a]);return xR(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),e?zr.createElement(zr.Fragment,null,zr.createElement(wR,{onClick:a}),zr.createElement(kR,{role:"dialog","aria-modal":"true","aria-label":t},zr.createElement(vR,null,t),zr.createElement(CR,null,n),zr.createElement(TR,null,zr.createElement(IR,{onClick:a},o),zr.createElement(FR,{variant:i,onClick:s},r)))):null};var qS=Bn.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}})),AR=Bn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),PR=Bn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),LR=Bn.div({display:"flex",alignItems:"center",gap:"8px"}),MR=Bn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),BR=Bn.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"})),DR=Bn.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"})),RR=Bn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),zR=Bn(Sc)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),NR=Bn(Sc)(({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)"}})),OR=Bn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),_R=Bn.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ue,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),$R=Bn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),YS=()=>{let[e,t]=Tl(!1),[n,r]=Tl({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Ke(),{sessionToken:i}=ze();ER(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(N=>({...N,loading:!0}));try{let N=await fetch("/index.json");if(!N.ok)throw new Error("Failed to fetch Storybook index");let E=await N.json(),M=E.entries||E.stories||{},g=Object.keys(M).filter(v=>M[v].type==="story").length,k=Object.keys(M).filter(v=>M[v].type==="story"),w=J(),A=await fetch(`${w}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),m=0;if(A.ok){let v=await A.json(),I=v.mappings||v||[];if(Array.isArray(I)){let x=new Set(I.map(P=>P.storyId).filter(Boolean));m=k.filter(P=>x.has(P)).length}else{let x=await fetch(`${w}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(x.ok){let P=await x.json();m=Math.min(P.mappedStoriesCount||0,g)}}}r({totalStories:g,mappedStories:m,loading:!1})}catch(N){console.error("[FigmaMappingsSection] Error fetching stats:",N),r(E=>({...E,loading:!1}))}},[a,u]=Tl(!1),[c,l]=Tl(!1),p=async()=>{!o||!i||l(!0)},f=async()=>{l(!1),u(!0);try{let N=J(),E=await fetch(`${N}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!E.ok)throw new Error("Failed to fetch mappings");let g=(await E.json()).mappings||[];await Promise.all(g.map(k=>fetch(`${N}/api/mappings?id=${encodeURIComponent(k.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(N){console.error("[FigmaMappingsSection] Unlink all failed:",N)}finally{u(!1)}},d=()=>t(!0),h=()=>{t(!1),o&&i&&s()};if(!o)return ut.createElement(qS,null,ut.createElement(OR,null,"Select a project to link Figma designs"));let{totalStories:S,loading:C}=n,F=Math.min(n.mappedStories,S),T=F===0?"none":F>=S?"complete":"partial",R=S>0?Math.min(100,Math.round(F/S*100)):0,z=T==="none"?"Link designs":"Manage";return ut.createElement(ut.Fragment,null,ut.createElement(qS,null,ut.createElement(AR,null,ut.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ut.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"}),ut.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"}),ut.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),ut.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"}),ut.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"}))),ut.createElement(PR,null,ut.createElement(RR,null,"Figma Mappings"),ut.createElement(LR,null,C?ut.createElement(ut.Fragment,null,ut.createElement(_R,null),ut.createElement($R,null,"Loading...")):ut.createElement(ut.Fragment,null,ut.createElement(MR,null,ut.createElement(BR,{percent:R,state:T})),ut.createElement(DR,{state:T},`${F}/${S}`)))),F>0&&ut.createElement(NR,{onClick:p,disabled:C||a},a?"Unlinking...":"Unlink All"),ut.createElement(zR,{onClick:d,disabled:C},z)),e&&ut.createElement(VS,{isOpen:e,onClose:h,projectId:o}),ut.createElement(Cl,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:f,onCancel:()=>l(!1)}))};import fe,{useState as As,useEffect as KS,useCallback as UR}from"react";import{styled as Dn}from"storybook/theming";Ae();Ue();var XS=Dn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),QS=Dn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),JS=Dn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),KK=Dn($n)({padding:"5px 12px",fontSize:"12px"}),ZS=Dn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),Zf=Dn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),jR=Dn.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})),HR=Dn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),eg=Dn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),WR=Dn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),tg=Dn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),ng=Dn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Ro=Dn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),ew=()=>{let[e,t]=As(null),[n,r]=As(!0),[o,i]=As(!1),[s,a]=As(!1),[u,c]=As(!1),{selectedProjectId:l}=Ke(),{sessionToken:p}=ze(),f=UR(async()=>{if(!(!l||!p))try{let R=J(),z=await fetch(`${R}/api/figma/cache-status?projectId=${l}`,{headers:{Authorization:`Bearer ${p}`}});if(z.ok){let N=await z.json();t(N)}}catch(R){console.error("[FigmaCacheSection] Error:",R)}finally{r(!1)}},[l,p]);KS(()=>{f()},[f]),KS(()=>{let R=e?.thumbnailProgress?.status==="in-progress",z=e?.enrichmentProgress?.status==="in-progress",N=e?.thumbnailProgress&&e.thumbnailProgress.cached>0;if(!(R||z||!N&&e?.structureStatus==="cached")||!e||e.structureStatus==="none")return;let M=setInterval(()=>{f()},3e3),g=setTimeout(()=>clearInterval(M),3e5);return()=>{clearInterval(M),clearTimeout(g)}},[e?.thumbnailProgress?.status,e?.thumbnailProgress?.cached,e?.enrichmentProgress?.status,e?.structureStatus,f]);let d=async()=>{if(!(!l||!p)){i(!0);try{let R=J();await fetch(`${R}/api/figma/frames?projectId=${l}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${p}`}}),await new Promise(z=>setTimeout(z,1e3)),await f(),setTimeout(async()=>{await f()},3e3)}catch(R){console.error("[FigmaCacheSection] Reload error:",R)}finally{i(!1)}}},h=async()=>{if(!(!l||!p)){a(!0);try{let R=J(),z=await fetch(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p}`},body:JSON.stringify({projectId:l})});console.log("[FigmaCacheSection] Cache invalidate response:",z.status),await fetch(`${R}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p}`},body:JSON.stringify({projectId:l})}).catch(()=>{}),t({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(R){console.error("[FigmaCacheSection] Clear cache error:",R)}finally{a(!1)}}},S=async()=>{if(!(!l||!p)){c(!0);try{let R=J();await fetch(`${R}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p}`},body:JSON.stringify({projectId:l})});let z=setInterval(async()=>{await f()},3e3),N=setInterval(()=>{(e?.enrichmentProgress?.status==="complete"||e?.enrichmentProgress?.status==="error")&&(clearInterval(z),clearInterval(N),c(!1),f())},3e3);setTimeout(()=>{clearInterval(z),clearInterval(N),c(!1)},6e5)}catch(R){console.error("[FigmaCacheSection] Enrich error:",R),c(!1)}}};if(!l||n)return null;if(!e||e.structureStatus==="none")return fe.createElement(XS,null,fe.createElement(QS,null,fe.createElement(JS,null,"Figma Cache"),fe.createElement(kr,{loading:o,onClick:d,loadingText:"Loading..."},"\u21BB Load")),o?fe.createElement(fe.Fragment,null,fe.createElement(tg,null,fe.createElement(ng,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),fe.createElement(Ro,null,fe.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):fe.createElement(ZS,null,fe.createElement(Zf,null,"No cache \u2014 click Load to fetch from Figma")));let C=R=>{let z=Date.now()-new Date(R).getTime(),N=Math.floor(z/6e4);if(N<1)return"just now";if(N<60)return`${N}m ago`;let E=Math.floor(N/60);return E<24?`${E}h ago`:`${Math.floor(E/24)}d ago`},F=e.cacheDiff,T=F&&(F.added.length>0||F.removed.length>0||F.renamed.length>0);return fe.createElement(XS,null,fe.createElement(QS,null,fe.createElement(JS,null,"Figma Cache"," ",fe.createElement(jR,{status:e.structureStatus},e.structureStatus)),fe.createElement("div",{style:{display:"flex",gap:"6px"}},fe.createElement(kr,{loading:u,onClick:S,loadingText:"Enriching..."},"Enrich"),fe.createElement(kr,{loading:s,onClick:h,variant:"ghost",loadingText:"Clearing..."},"Clear"),fe.createElement(kr,{loading:o,onClick:d,loadingText:"Reloading..."},"\u21BB Reload"))),o&&fe.createElement(Ro,null,fe.createElement("span",null,"Downloading structure from Figma...")),fe.createElement(ZS,null,fe.createElement(Zf,null,fe.createElement("strong",null,e.componentSetCount)," component sets"),fe.createElement(Zf,null,fe.createElement("strong",null,e.pageCount)," pages"),e.structureCachedAt&&fe.createElement(WR,null,"Updated ",C(e.structureCachedAt))),T&&fe.createElement(HR,null,"Since last reload:"," ",F.added.length>0&&fe.createElement(eg,{type:"added"},"+",F.added.length," added"),F.added.length>0&&F.removed.length>0&&" \xB7 ",F.removed.length>0&&fe.createElement(eg,{type:"removed"},"\u2212",F.removed.length," removed"),(F.added.length>0||F.removed.length>0)&&F.renamed.length>0&&" \xB7 ",F.renamed.length>0&&fe.createElement(eg,{type:"renamed"},F.renamed.length," renamed")),e.thumbnailProgress&&e.thumbnailProgress.status==="in-progress"&&fe.createElement(fe.Fragment,null,fe.createElement(tg,null,fe.createElement(ng,{percent:e.thumbnailProgress.total>0?Math.round(e.thumbnailProgress.cached/e.thumbnailProgress.total*100):0})),fe.createElement(Ro,null,fe.createElement("span",null,"Caching component set thumbnails to CDN...",e.thumbnailProgress.currentName&&fe.createElement(fe.Fragment,null," ",e.thumbnailProgress.currentName)),fe.createElement("span",null,e.thumbnailProgress.cached," / ",e.thumbnailProgress.total))),e.thumbnailProgress&&e.thumbnailProgress.status==="complete"&&fe.createElement(Ro,null,fe.createElement("span",null,"Thumbnails: ",e.thumbnailProgress.cached," / ",e.thumbnailProgress.total," cached to CDN \u2713")),(!e.thumbnailProgress||e.thumbnailProgress.status==="pending")&&fe.createElement(Ro,null,fe.createElement("span",null,"Thumbnails: not pre-cached")),e.enrichmentProgress&&e.enrichmentProgress.status==="in-progress"&&fe.createElement(fe.Fragment,null,fe.createElement(tg,null,fe.createElement(ng,{percent:e.enrichmentProgress.total>0?Math.round(e.enrichmentProgress.enriched/e.enrichmentProgress.total*100):0})),fe.createElement(Ro,null,fe.createElement("span",null,"Enriching components with AI...",e.enrichmentProgress.currentName&&fe.createElement(fe.Fragment,null," ",e.enrichmentProgress.currentName)),fe.createElement("span",null,e.enrichmentProgress.enriched," / ",e.enrichmentProgress.total))),e.enrichmentProgress&&e.enrichmentProgress.status==="complete"&&fe.createElement(fe.Fragment,null,fe.createElement(Ro,null,fe.createElement("span",null,"AI enrichment: ",e.enrichmentProgress.enriched," / ",e.enrichmentProgress.total," component sets \u2713")),e.enrichmentProgress.costUsd!=null&&e.enrichmentProgress.costUsd>0&&fe.createElement("div",{style:{marginTop:"6px"}},fe.createElement(bl,{inputTokens:e.enrichmentProgress.inputTokens||0,outputTokens:e.enrichmentProgress.outputTokens||0,costUsd:e.enrichmentProgress.costUsd,compact:!0}))))};var VR=Ps.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),GR=Ps.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),qR=Ps.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),YR=Ps.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),KR=Ps.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),tw=()=>Cn.createElement(VR,null,Cn.createElement(GR,null,Cn.createElement(qR,null,Cn.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Cn.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"}),Cn.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"}),Cn.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Cn.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"}),Cn.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"}))),Cn.createElement(YR,null,"Figma Integration")),Cn.createElement(KR,null,Cn.createElement(C0,null),Cn.createElement(YS,null),Cn.createElement(ew,null)));Ae();var XR=Si.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"}),QR=Si.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"10px",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.2)",width:"480px",maxWidth:"90%",maxHeight:"calc(100vh - 64px)",overflow:"auto",position:"relative"})),JR=Si.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,position:"sticky",top:0,backgroundColor:e.background.content,borderRadius:"10px 10px 0 0",zIndex:1})),ZR=Si.h2(({theme:e})=>({margin:0,fontSize:"13px",fontWeight:600,color:e.color.defaultText})),ez=Si(cn)({fontSize:"16px",padding:"2px 6px",lineHeight:1}),tz=Si.div(({theme:e})=>({padding:"4px 0",fontSize:"12px","& > div":{padding:"8px 16px"},"h3, h4":{fontSize:"12px",margin:"0 0 6px 0"},label:{fontSize:"12px"},"input, select":{fontSize:"12px",padding:"6px 10px",height:"auto"},button:{fontSize:"11px",padding:"5px 10px"},"& > div + div":{borderTop:`1px solid ${e.appBorderColor}`},'[class*="Connected"]':{padding:"8px 12px"},p:{fontSize:"11px",margin:"2px 0"}})),nw=({onClose:e})=>{let{isConnected:t}=ze(),{selectedProjectId:n}=Ke();return Nr.createElement(XR,{onClick:e},Nr.createElement(QR,{onClick:r=>r.stopPropagation()},Nr.createElement(JR,null,Nr.createElement(ZR,null,"Settings"),Nr.createElement(ez,{onClick:e,title:"Close settings"},"x")),Nr.createElement(tz,null,Nr.createElement(S0,null),t&&Nr.createElement(k0,null),t&&n&&Nr.createElement(tw,null))))};import Et,{useEffect as Az,useMemo as Pz}from"react";import{styled as Kn}from"storybook/theming";Ae();Ae();import zt,{useState as nz}from"react";import{styled as Tn}from"storybook/theming";var Or=[{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Latest Claude model, highest quality"},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",provider:"anthropic",description:"Previous generation Sonnet"},{id:"claude-3-5-sonnet-20241022",name:"Claude 3.5 Sonnet",provider:"anthropic",description:"Best balance of speed and quality"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",provider:"anthropic",description:"Fastest, most affordable"},{id:"claude-3-opus-20240229",name:"Claude 3 Opus",provider:"anthropic",description:"Most capable Claude 3 model"},{id:"gpt-5.2",name:"GPT-5.2 Thinking",provider:"openai",description:"47% cheaper, reasoning"},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Instant",provider:"openai",description:"86% cheaper (default)"},{id:"gpt-4o",name:"GPT-4o",provider:"openai",description:"GPT-4 multimodal flagship"},{id:"gpt-4o-mini",name:"GPT-4o Mini",provider:"openai",description:"GPT-4 affordable model"},{id:"o1-preview",name:"o1 Preview",provider:"openai",description:"Reasoning model (slower, advanced)"},{id:"o1-mini",name:"o1 Mini",provider:"openai",description:"Faster reasoning model"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"Fast & cheap, great vision"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",provider:"google",description:"Best Gemini quality"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"google",description:"Previous gen, very fast"}];var rz=Tn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),oz=Tn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),iz=Tn.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"}}),sz=Tn.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}})),az=Tn.div({position:"relative",display:"inline-block"}),lz=Tn.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}})),cz=Tn.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"})),rg=Tn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),og=Tn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),uz=Tn.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}})),pz=Tn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),dz=Tn.div({flex:1,minWidth:0}),fz=Tn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),gz=Tn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),mz=5,rw=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ye(),[r,o]=nz(!1),i=Or.filter(d=>d.provider==="anthropic"&&!e.includes(d.id)),s=Or.filter(d=>d.provider==="openai"&&!e.includes(d.id)),a=Or.filter(d=>d.provider==="google"&&!e.includes(d.id)),u=Or.filter(d=>e.includes(d.id)),c=e.length<mz,l=(d,h)=>{h.stopPropagation(),e.length>1&&!n&&t(d)},p=d=>{let h=e.includes(d);h&&e.length===1||!h&&!c||n||(t(d),o(!1))},f=d=>{let h=e.includes(d.id),S=h&&e.length===1,C=n||S||!h&&!c;return zt.createElement(uz,{key:d.id,disabled:C,onClick:()=>p(d.id)},zt.createElement(pz,{type:"checkbox",checked:h,disabled:C,onChange:()=>{},onClick:F=>F.stopPropagation()}),zt.createElement(dz,null,zt.createElement(fz,null,d.name),d.description&&zt.createElement(gz,null,d.description)))};return zt.createElement(rz,null,zt.createElement(az,null,zt.createElement(lz,{disabled:n,isOpen:r,onClick:()=>o(!r)},zt.createElement("span",null,"Select model"),zt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&zt.createElement(cz,null,zt.createElement(rg,null,zt.createElement(og,null,"Anthropic"),i.map(f)),zt.createElement(rg,null,zt.createElement(og,null,"OpenAI"),s.map(f)),zt.createElement(rg,null,zt.createElement(og,null,"Google"),a.map(f)))),zt.createElement(oz,null,u.map(d=>zt.createElement(iz,{key:d.id,disabled:n,provider:d.provider},d.name,e.length>1&&zt.createElement(sz,{disabled:n,onClick:h=>l(d.id,h),title:"Remove model"},"\xD7")))))};import ce,{useState as hz,useEffect as xz}from"react";import{styled as qt,keyframes as Ls}from"storybook/theming";var yz=Ls`
34
+ 0%, 100% {
35
+ opacity: 1;
36
+ transform: scale(1);
37
+ }
38
+ 50% {
39
+ opacity: 0.4;
40
+ transform: scale(0.8);
41
+ }
42
+ `,bz=Ls`
43
+ 0% { transform: rotate(0deg); }
44
+ 100% { transform: rotate(360deg); }
45
+ `,Sz=Ls`
46
+ 0% { opacity: 0; transform: translateY(2px); }
47
+ 100% { opacity: 1; transform: translateY(0); }
48
+ `,wz=Ls`
49
+ 0%, 100% {
50
+ opacity: 1;
51
+ }
52
+ 50% {
53
+ opacity: 0.6;
54
+ }
55
+ `,kz=Ls`
56
+ 0% {
57
+ transform: translateY(0) rotate(0deg) scale(1);
58
+ opacity: 1;
59
+ }
60
+ 50% {
61
+ opacity: 1;
62
+ }
63
+ 100% {
64
+ transform: translateY(60px) rotate(720deg) scale(0.5);
65
+ opacity: 0;
66
+ }
67
+ `;var EX=qt.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),ig=qt.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),ow=qt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#fee2e2",fontSize:"12px",fontWeight:700,color:"#dc2626",whiteSpace:"nowrap"}),vz=qt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#dcfce7",fontSize:"12px",fontWeight:700,color:"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"}),AX=qt.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:`${kz} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var lo=qt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),co=qt.span(({color:e="#6b7280"})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:e,whiteSpace:"nowrap"})),sg=qt.span(({color:e="#6b7280"})=>({fontSize:"12px",color:e})),wi=qt.span(({color:e})=>({fontWeight:700,color:e})),PX=qt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),LX=qt.span(({color:e=ue})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${yz} 1.2s ease-in-out infinite`,marginRight:"4px"})),MX=qt.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return ue;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 ue;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${wz} 1.5s ease-in-out infinite`}:{}})),BX=qt.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),DX=qt.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),Cz=qt.button(({theme:e,isExporting:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",fontSize:"11px",fontWeight:600,color:t?e.color.mediumdark:"#7c3aed",backgroundColor:t?e.background.hoverable:"#ede9fe",border:"none",borderRadius:"12px",cursor:t?"not-allowed":"pointer",transition:"all 0.2s",whiteSpace:"nowrap","&:hover":{backgroundColor:t?e.background.hoverable:"#ddd6fe"}})),Tz=qt.span({display:"inline-block",width:"10px",height:"10px",border:"2px solid #c4b5fd",borderTopColor:"#7c3aed",borderRadius:"50%",animation:"export-spin 0.8s linear infinite","@keyframes export-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),Iz=qt.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${bz} 1.2s linear infinite`,flexShrink:0}),iw=({color:e=ue})=>ce.createElement(Iz,null,ce.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},Array.from({length:8}).map((t,n)=>{let o=n*360/8*Math.PI/180,i=12+Math.cos(o)*4,s=12+Math.sin(o)*4,a=12+Math.cos(o)*10,u=12+Math.sin(o)*10;return ce.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Fz=qt.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:`${Sz} 0.3s ease-out`}));function Ez(e){let[t,n]=hz(0);return xz(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var sw=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,visualSimilarity:i,costUsd:s,inputTokens:a,outputTokens:u,showTimer:c=!0,cacheCreationTokens:l,cacheReadTokens:p,durationSeconds:f})=>{let d=Ez(e||t),{exportPDF:h,isExporting:S}=yf(),C=3.65,F=E=>E<.01?`$${E.toFixed(4)}`:E<.1?`$${E.toFixed(3)}`:`$${E.toFixed(2)}`,T=E=>{let M=E*C;return M<.01?`\u20AA${M.toFixed(4)}`:M<.1?`\u20AA${M.toFixed(3)}`:`\u20AA${M.toFixed(2)}`},R=E=>E>=1e3?`${(E/1e3).toFixed(1)}K`:E.toString(),z=E=>E>=80?"score-high":E>=50?"score-medium":"score-low",N=E=>E>=80?"high":E>=50?"medium":"low";if(e)return ce.createElement(ig,null,ce.createElement(co,null,ce.createElement(iw,{color:ue}),ce.createElement(Fz,{key:n,color:"#6b7280"},n||"Analyzing\u2026")),c&&ce.createElement(ce.Fragment,null,ce.createElement(lo,null,"|"),ce.createElement(co,null,ce.createElement("span",{style:{color:"#6b7280"}},d,"s \xB7 Esc to stop"))));if(t)return ce.createElement(ig,null,ce.createElement(ow,null,ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ce.createElement(lo,null,"|"),ce.createElement(co,null,ce.createElement(iw,{color:"#7c3aed"}),ce.createElement(wi,{color:"#7c3aed"},"Verifying...")),c&&ce.createElement(ce.Fragment,null,ce.createElement(lo,null,"|"),ce.createElement(co,null,ce.createElement("span",{style:{color:"#6b7280"}},d,"s"))));if(r>0||o!==void 0){let E=(a||0)+(u||0),M=(p||0)>0,g=M&&a?Math.round(p/a*100):0,k=Math.max(o??0,i??0),w=m=>m>=80?"#16a34a":m>=50?"#ca8a04":"#dc2626",A=m=>m>=100?"\u25CF":m>=50?"\u25D0":"\u25CB";return ce.createElement(ig,null,r===0?ce.createElement(vz,null,ce.createElement("span",null,"\u2713"),"Perfect!"):ce.createElement(ow,null,ce.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ce.createElement(lo,null,"|"),ce.createElement(co,{title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},ce.createElement(sg,{color:w(k)},A(k)),ce.createElement("span",null,"score"),ce.createElement(wi,{color:w(k)},k)),s!==void 0&&s>0&&ce.createElement(ce.Fragment,null,ce.createElement(lo,null,"|"),ce.createElement(co,null,ce.createElement(wi,{color:"#16a34a"},F(s)),ce.createElement("span",{style:{color:"#6b7280"}},"/"),ce.createElement(wi,{color:"#16a34a"},T(s)))),E>0&&ce.createElement(ce.Fragment,null,ce.createElement(lo,null,"|"),ce.createElement(co,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${M?` \xB7 Cached: ${p?.toLocaleString()}`:""}`},ce.createElement(sg,{color:"#7c3aed"},"#"),ce.createElement(wi,{color:"#7c3aed"},R(E)),ce.createElement("span",{style:{color:"#6b7280"}},"tokens"),M&&ce.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",g,"%"))),f!==void 0&&f>0&&ce.createElement(ce.Fragment,null,ce.createElement(lo,null,"|"),ce.createElement(co,null,ce.createElement(sg,{color:"#6b7280"},"\u23F1"),ce.createElement(wi,{color:"#6b7280"},f,"s"))),ce.createElement(lo,null,"|"),ce.createElement(Cz,{onClick:h,disabled:S,isExporting:S,title:"Download design review report as PDF"},S?ce.createElement(ce.Fragment,null,ce.createElement(Tz,null),"Exporting..."):ce.createElement(ce.Fragment,null,"\u2193 Report")))}return null};var Lz=Kn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),Mz=Kn.div({display:"flex",gap:"8px",alignItems:"center"}),Bz=Kn.button(({theme:e,variant:t="orange",disabled:n})=>({width:"auto",backgroundColor:{green:n?e.textMutedColor:e.color.positive||"#10b981",purple:n?e.textMutedColor:e.color.secondary,yellow:n?e.textMutedColor:e.color.warning||"#fbbf24",orange:n?e.textMutedColor:ia}[t],color:e.color.inverseText,border:"none",padding:"8px 16px",fontSize:"13px",fontWeight:600,borderRadius:"5px",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,whiteSpace:"nowrap",transition:"all 0.2s",boxShadow:n?"none":"0 2px 4px rgba(255, 107, 53, 0.3)","&:hover":{opacity:n?.6:.9,transform:n?"none":"translateY(-1px)",boxShadow:n?"none":"0 4px 8px rgba(255, 107, 53, 0.4)"}})),Dz=Kn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),Rz=Kn.div({marginLeft:"auto",display:"flex",flexDirection:"column",gap:"4px"}),zz=Kn.label(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),Nz=Kn(mn)({width:"auto",minWidth:"200px"}),Oz=Kn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),aw=Kn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),lw=Kn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?ia:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),cw=Kn.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)"})),uw=Kn.input({position:"absolute",opacity:0,width:0,height:0}),ag=()=>{let{sessionToken:e}=Oi(),{selectedProjectId:t}=tr(),{currentMapping:n,hasMapping:r}=Lo(),{loadingMapping:o,currentStoryId:i}=Ge(),{startReview:s,cancelReview:a,isReviewing:u}=af(),{isLoadingScreenshots:c}=ko(),{storybookImageUrl:l,figmaImageUrl:p,currentReviewId:f,reviewHistory:d,setReviewDetailTab:h,setReviewResults:S,setFigmaImageUrl:C,setStorybookImageUrl:F,setFullPrompt:T,setFullResponse:R,includeTextComparison:z,setIncludeTextComparison:N,usePromptCache:E,setUsePromptCache:M,isValidating:g,validationUsage:k,isGenerating:w,isApplying:A,streamingStatus:m}=ye(),v=d.find(j=>j.id===f),x=(v?.issues||[]).filter(j=>!j.dismissed).length,P=v?.complianceScore,L=v?.visualSimilarity,D=(v?.costUsd||0)+(k?.costUsd||0),O=(v?.inputTokens||0)+(k?.inputTokens||0),y=(v?.outputTokens||0)+(k?.outputTokens||0),U=Pz(()=>{let j=i?d.filter($e=>$e.storyId===i):d,ie=j.filter($e=>!$e.parentReviewId).sort(($e,it)=>new Date(it.createdAt).getTime()-new Date($e.createdAt).getTime()),re=j.filter($e=>$e.parentReviewId),he=[];for(let $e of ie){he.push($e);let it=re.filter(Ot=>Ot.parentReviewId===$e.id).sort((Ot,zn)=>(Ot.iterationNumber||0)-(zn.iterationNumber||0));he.push(...it)}let de=re.filter($e=>!ie.some(it=>it.id===$e.parentReviewId));return he.push(...de),he},[d,i]);Az(()=>{if(!u)return;let j=ie=>{ie.key==="Escape"&&(ie.preventDefault(),a())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[u,a]);let V=r&&n?.figmaNodeId,B=w||A,X=!!(e&&t&&!u&&!c&&!B&&i&&l&&V&&p),ee=async(j=!1)=>{if(!i){console.error("[ReviewActions] No story selected");return}try{h("chat"),await s({isIteration:j,parentReviewId:j?f:void 0})}catch(ie){console.error("[ReviewActions] Review error:",ie)}},Q=()=>ee(!1),Ee=j=>{let ie=j.target.value;if(ie){let re=d.find(he=>he.id===ie);re&&(S({id:re.id,componentId:re.componentId,storyId:re.storyId,modelId:re.modelId,complianceScore:re.complianceScore,issuesCount:re.issuesCount,issues:re.issues,createdAt:new Date(re.createdAt),visualSimilarity:re.visualSimilarity,timestamp:new Date(re.createdAt).toISOString()}),re.figmaImageData&&C(re.figmaImageData),re.storybookImageData&&F(re.storybookImageData),T(re.aiPrompt||""),R(re.aiResponse||""),h("issues"))}},Te=j=>{let ie=new Date(j),he=new Date().getTime()-ie.getTime(),de=Math.floor(he/6e4),$e=Math.floor(he/36e5),it=Math.floor(he/864e5);return de<1?"Just now":de<60?`${de}m ago`:$e<24?`${$e}h ago`:it<7?`${it}d ago`:ie.toLocaleDateString()},We=j=>j?j.includes("haiku")?"Haiku":j.includes("sonnet")?"Sonnet":j.includes("opus")?"Opus":j.includes("gpt-4o-mini")?"GPT-4o mini":j.includes("gpt-4o")?"GPT-4o":j.includes("gpt-4")?"GPT-4":j.includes("o3")?"o3":j.includes("o1")?"o1":j.split("-")[0]||"":"",ot=j=>{let ie=j.split("--"),re=ie[ie.length-1]||j;return re.charAt(0).toUpperCase()+re.slice(1)};return Et.createElement("div",null,Et.createElement(Lz,null,Et.createElement(rw,null),Et.createElement(Oz,null,Et.createElement(aw,{title:"Compare text content between Figma design and Storybook component"},Et.createElement(uw,{type:"checkbox",checked:z,onChange:j=>N(j.target.checked)}),Et.createElement(lw,{checked:z},Et.createElement(cw,{checked:z})),"Compare text"),Et.createElement(aw,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},Et.createElement(uw,{type:"checkbox",checked:E,onChange:j=>M(j.target.checked)}),Et.createElement(lw,{checked:E},Et.createElement(cw,{checked:E})),"Cache prompt")),Et.createElement(Mz,null,Et.createElement(Bz,{variant:u?"yellow":"orange",disabled:u?!1:!X,onClick:u?a:Q,title:u?"Click to stop review":e?t?i?V?c?"Loading screenshots...":B?"Wait for fixes to complete...":l?p?"Review this component implementation":"Waiting for Figma design image...":"Waiting for Storybook screenshot...":'Figma mapping required - use "Map to Figma" in the Review tab':"No story selected":"Please select a project first":"Please connect to UI Copilot first"},u?"\u{1F6D1} Stop":"\u{1F441}\uFE0F Review"),(u||g||v)&&Et.createElement(sw,{isReviewing:u,isValidating:g,streamingStatus:m,issueCount:x,score:P,visualSimilarity:L,costUsd:D||v?.costUsd,inputTokens:O||v?.inputTokens,outputTokens:y||v?.outputTokens,cacheCreationTokens:v?.cacheCreationTokens,cacheReadTokens:v?.cacheReadTokens,durationSeconds:v?.reviewDurationMs?Math.round(v.reviewDurationMs/1e3):void 0}),U.length>0&&Et.createElement(Rz,null,Et.createElement(zz,null,"Review History"),Et.createElement(Nz,{value:f||"",onChange:Ee},Et.createElement("option",{value:""},"Select a review..."),U.map(j=>{let ie=!!j.parentReviewId,re=ie?" \u21B3 ":"\u25CF ",he=ie&&j.iterationNumber?`Iter ${j.iterationNumber} - `:"",de=j.issuesCount??j.issues?.length??0,$e=j.complianceScore??"--",it=We(j.modelId);return Et.createElement("option",{key:j.id,value:j.id},re,he,Te(j.createdAt)," - ",de," issues (",$e,"%)",it?` \xB7 ${it}`:"",j.storyId?` \xB7 ${ot(j.storyId)}`:"")}))))),!V&&!o&&Et.createElement(Dz,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import VX,{useState as GX}from"react";import{styled as pw}from"storybook/theming";var KX=pw.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),XX=pw(Vr)({padding:"8px 12px",fontSize:"12px"});import pt,{useState as Il}from"react";import{styled as Yt,keyframes as _z}from"storybook/theming";Ue();var $z=Yt.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),Uz=Yt.div({position:"relative",display:"inline-flex"}),jz=_z`
68
+ 0% { transform: rotate(0deg); }
69
+ 100% { transform: rotate(360deg); }
70
+ `,Hz=Yt.button(({score:e,isLoading:t,theme:n})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:t?"#7c3aed":e?e>=80?n.color.positive||"#10b981":e>=50?n.color.warning||"#f59e0b":n.color.negative||"#ef4444":n.color.mediumdark||"#6b7280",color:"#fff",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}})),Wz=Yt.span`
71
+ display: inline-block;
72
+ width: 10px;
73
+ height: 10px;
74
+ border: 2px solid rgba(255,255,255,0.3);
75
+ border-top-color: #fff;
76
+ border-radius: 50%;
77
+ animation: ${jz} 0.8s linear infinite;
78
+ `,Vz=Yt.div(({theme:e})=>({position:"absolute",top:"100%",left:"0",marginTop:"6px",padding:"12px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:1e3,minWidth:"220px",fontSize:"11px"})),Gz=Yt.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),qz=Yt.div(({theme:e})=>({fontWeight:600,color:e.color.defaultText,fontSize:"12px"})),Yz=Yt.span(({score:e,theme:t})=>({fontWeight:700,fontSize:"14px",color:e>=80?t.color.positive||"#10b981":e>=50?t.color.warning||"#f59e0b":t.color.negative||"#ef4444"})),Kz=Yt.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),Xz=Yt.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"11px",color:e.color.defaultText})),Qz=Yt.span({display:"flex",alignItems:"center",gap:"4px"}),Jz=Yt.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive||"#10b981":e==="warn"?t.color.warning||"#f59e0b":t.color.negative||"#ef4444",fontSize:"10px"})),Zz=Yt.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),eN=Yt.div(({theme:e})=>({fontSize:"10px",color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),tN=Yt.ul(({theme:e})=>({margin:"8px 0 0 0",padding:"0 0 0 14px",fontSize:"10px",color:e.color.defaultText,"& li":{marginBottom:"2px"}})),nN=Yt.div({display:"flex",gap:"8px",alignItems:"flex-start"}),rN=Yt.div({flex:1}),oN=Yt(nn)({height:"36px",whiteSpace:"nowrap"}),iN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},sN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",lg=()=>{let{figmaFileUrl:e,setFigmaFileUrl:t,openComponentBrowser:n}=$i(),{hasMapping:r}=Lo(),{selectedProjectId:o}=tr(),[i,s]=Il(!1),[a,u]=Il(!1),[c,l]=Il(null),[p,f]=Il(null),d=async()=>{if(!(!e||!o||a)){u(!0),f(null);try{let S=J(),C=localStorage.getItem("uicopilot_session_token"),F=await fetch(`${S}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`},body:JSON.stringify({projectId:o,figmaFileUrl:e,figmaMetadata:{}})});if(!F.ok)throw new Error("Failed to check quality");let T=await F.json();l(T),s(!0)}catch(S){console.error("[FigmaUrlInput] Quality check error:",S),f("Failed to check quality")}finally{u(!1)}}};return pt.createElement(bo,null,pt.createElement($z,null,pt.createElement(So,{style:{marginBottom:0}},"Figma File URL"),!!e&&pt.createElement(Uz,{onMouseEnter:()=>c&&s(!0),onMouseLeave:()=>s(!1)},pt.createElement(Hz,{score:c?.score,isLoading:a,onClick:d,disabled:a||!o,title:c?"Click to refresh quality check":"Click to check Figma design quality"},a?pt.createElement(pt.Fragment,null,pt.createElement(Wz,null)," Checking..."):c?pt.createElement(pt.Fragment,null,"\u{1F3A8} ",Math.round(c.score),"%"):pt.createElement(pt.Fragment,null,"\u{1F3A8} Check Quality")),i&&c&&pt.createElement(Vz,null,pt.createElement(Gz,null,pt.createElement(qz,null,"Figma Design Quality"),pt.createElement(Yz,{score:c.score},Math.round(c.score),"%")),pt.createElement(Kz,null,Object.entries(c.categories).map(([S,C])=>pt.createElement(Xz,{key:S},pt.createElement(Qz,null,pt.createElement(Jz,{status:C.status},sN(C.status)),iN[S]||S),pt.createElement(Zz,null,C.score)))),c.summary&&pt.createElement(eN,null,c.summary),c.recommendations?.length>0&&pt.createElement(tN,null,c.recommendations.slice(0,2).map((S,C)=>pt.createElement("li",{key:C},S)))))),pt.createElement(nN,null,pt.createElement(rN,null,pt.createElement(wo,{type:"text",placeholder:"https://www.figma.com/file/...",value:e,onChange:S=>t(S.target.value)})),pt.createElement(oN,{onClick:n,disabled:!e&&!o,title:!e&&!o?"Enter a Figma URL or select a project first":r?"Change Figma mapping":"Map this component to a Figma design"},r?"\u{1F50D} Browse Figma":"\u26A0\uFE0F Map Component")))};import iQ,{useState as sQ}from"react";import{styled as cg}from"storybook/theming";Ae();Ue();Pe();var dQ=cg.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),fQ=cg($n)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),gQ=cg.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import xQ from"react";import{styled as aN}from"storybook/theming";var SQ=aN.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));Ae();import vQ from"react";import{styled as vr}from"storybook/theming";var IQ=vr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),FQ=vr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),EQ=vr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),AQ=vr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),PQ=vr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),LQ=vr.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"})),MQ=vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),BQ=vr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),DQ=vr.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)"}}})),RQ=vr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));Ae();import OQ,{useState as _Q}from"react";import{styled as Cr}from"storybook/theming";var jQ=Cr.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)`}}),HQ=Cr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),WQ=Cr.div({display:"flex",alignItems:"center",gap:"8px"}),VQ=Cr.span({fontSize:"12px",opacity:.7}),GQ=Cr.span({fontSize:"13px",fontWeight:500}),qQ=Cr.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})),YQ=Cr.div({marginTop:"12px",fontSize:"11px"}),KQ=Cr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),XQ=Cr.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"})),QQ=Cr.span({fontSize:"12px"});import xt,{useState as _3}from"react";import{styled as Wo}from"storybook/theming";Pe();Ue();import dr from"react";import{styled as qs}from"storybook/theming";Ae();import Ho,{useState as v$}from"react";import{styled as Ei}from"storybook/theming";var Fl={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 dw(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var lN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uN={};function El(e,t){return((t||uN).jsx?cN:lN).test(e)}var pN=/[ \t\n\f\r]/g;function ug(e){return typeof e=="object"?e.type==="text"?fw(e.value):!1:fw(e)}function fw(e){return e.replace(pN,"")===""}var _r=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};_r.prototype.normal={};_r.prototype.property={};_r.prototype.space=void 0;function pg(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new _r(n,r,t)}function Ms(e){return e.toLowerCase()}var Kt=class{constructor(t,n){this.attribute=n,this.property=t}};Kt.prototype.attribute="";Kt.prototype.booleanish=!1;Kt.prototype.boolean=!1;Kt.prototype.commaOrSpaceSeparated=!1;Kt.prototype.commaSeparated=!1;Kt.prototype.defined=!1;Kt.prototype.mustUseProperty=!1;Kt.prototype.number=!1;Kt.prototype.overloadedBoolean=!1;Kt.prototype.property="";Kt.prototype.spaceSeparated=!1;Kt.prototype.space=void 0;var Bs={};xe(Bs,{boolean:()=>De,booleanish:()=>Ct,commaOrSpaceSeparated:()=>In,commaSeparated:()=>uo,number:()=>q,overloadedBoolean:()=>Al,spaceSeparated:()=>lt});var dN=0,De=zo(),Ct=zo(),Al=zo(),q=zo(),lt=zo(),uo=zo(),In=zo();function zo(){return 2**++dN}var dg=Object.keys(Bs),No=class extends Kt{constructor(t,n,r,o){let i=-1;if(super(t,n),gw(this,"space",o),typeof r=="number")for(;++i<dg.length;){let s=dg[i];gw(this,dg[i],(r&Bs[s])===Bs[s])}}};No.prototype.defined=!0;function gw(e,t,n){n&&(e[t]=n)}function Xn(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new No(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Ms(r)]=r,n[Ms(i.attribute)]=r}return new _r(t,n,e.space)}var fg=Xn({properties:{ariaActiveDescendant:null,ariaAtomic:Ct,ariaAutoComplete:null,ariaBusy:Ct,ariaChecked:Ct,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:lt,ariaCurrent:null,ariaDescribedBy:lt,ariaDetails:null,ariaDisabled:Ct,ariaDropEffect:lt,ariaErrorMessage:null,ariaExpanded:Ct,ariaFlowTo:lt,ariaGrabbed:Ct,ariaHasPopup:null,ariaHidden:Ct,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lt,ariaLevel:q,ariaLive:null,ariaModal:Ct,ariaMultiLine:Ct,ariaMultiSelectable:Ct,ariaOrientation:null,ariaOwns:lt,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:Ct,ariaReadOnly:Ct,ariaRelevant:null,ariaRequired:Ct,ariaRoleDescription:lt,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:Ct,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 Pl(e,t){return t in e?e[t]:t}function Ll(e,t){return Pl(e,t.toLowerCase())}var mw=Xn({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:uo,acceptCharset:lt,accessKey:lt,action:null,allow:null,allowFullScreen:De,allowPaymentRequest:De,allowUserMedia:De,alt:null,as:null,async:De,autoCapitalize:null,autoComplete:lt,autoFocus:De,autoPlay:De,blocking:lt,capture:null,charSet:null,checked:De,cite:null,className:lt,cols:q,colSpan:null,content:null,contentEditable:Ct,controls:De,controlsList:lt,coords:q|uo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:De,defer:De,dir:null,dirName:null,disabled:De,download:Al,draggable:Ct,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:De,formTarget:null,headers:lt,height:q,hidden:Al,high:q,href:null,hrefLang:null,htmlFor:lt,httpEquiv:lt,id:null,imageSizes:null,imageSrcSet:null,inert:De,inputMode:null,integrity:null,is:null,isMap:De,itemId:null,itemProp:lt,itemRef:lt,itemScope:De,itemType:lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:De,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:De,muted:De,name:null,nonce:null,noModule:De,noValidate:De,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:De,optimum:q,pattern:null,ping:lt,placeholder:null,playsInline:De,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:De,referrerPolicy:null,rel:lt,required:De,reversed:De,rows:q,rowSpan:q,sandbox:lt,scope:null,scoped:De,seamless:De,selected:De,shadowRootClonable:De,shadowRootDelegatesFocus:De,shadowRootMode:null,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:Ct,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:De,useMap:null,value:Ct,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lt,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:De,declare:De,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:De,noHref:De,noShade:De,noWrap:De,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:Ct,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:De,disableRemotePlayback:De,prefix:null,property:null,results:q,security:null,unselectable:null},space:"html",transform:Ll});var hw=Xn({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:In,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:lt,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:De,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:In,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:lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:In,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:In,rev:In,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:In,requiredFeatures:In,requiredFonts:In,requiredFormats:In,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:In,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:In,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:In,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:Pl});var gg=Xn({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 mg=Xn({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ll});var hg=Xn({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var xg={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 fN=/[A-Z]/g,xw=/-[a-z]/g,gN=/^data[-\w.:]+$/i;function yg(e,t){let n=Ms(t),r=t,o=Kt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gN.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(xw,hN);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!xw.test(i)){let s=i.replace(fN,mN);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=No}return new o(r,t)}function mN(e){return"-"+e.toLowerCase()}function hN(e){return e.charAt(1).toUpperCase()}var yw=pg([fg,mw,gg,mg,hg],"html"),Ml=pg([fg,hw,gg,mg,hg],"svg");function bw(e){return e.join(" ").trim()}var Dw=oa(Pw(),1);var Dl=Lw("end"),ki=Lw("start");function Lw(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 wg(e){let t=ki(e),n=Dl(e);if(t&&n)return{start:t,end:n}}function po(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Mw(e.position):"start"in e||"end"in e?Mw(e):"line"in e||"column"in e?kg(e):""}function kg(e){return Bw(e&&e.line)+":"+Bw(e&&e.column)}function Mw(e){return kg(e&&e.start)+"-"+kg(e&&e.end)}function Bw(e){return e&&typeof e=="number"?e:1}var At=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=po(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}};At.prototype.file="";At.prototype.name="";At.prototype.reason="";At.prototype.message="";At.prototype.stack="";At.prototype.column=void 0;At.prototype.line=void 0;At.prototype.ancestors=void 0;At.prototype.cause=void 0;At.prototype.fatal=void 0;At.prototype.place=void 0;At.prototype.ruleId=void 0;At.prototype.source=void 0;var vg={}.hasOwnProperty,jN=new Map,HN=/[A-Z]/g,WN=new Set(["table","tbody","thead","tfoot","tr"]),VN=new Set(["td","th"]),Rw="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Cg(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=ZN(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=JN(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"?Ml:yw,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=zw(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function zw(e,t,n){if(t.type==="element")return GN(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return qN(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return KN(e,t,n);if(t.type==="mdxjsEsm")return YN(e,t);if(t.type==="root")return XN(e,t,n);if(t.type==="text")return QN(e,t)}function GN(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=Ml,e.schema=o),e.ancestors.push(t);let i=Ow(e,t.tagName,!1),s=eO(e,t),a=Ig(e,t);return WN.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!ug(u):!0})),Nw(e,s,i,t),Tg(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function qN(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)}Rs(e,t.position)}function YN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Rs(e,t.position)}function KN(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=Ml,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:Ow(e,t.name,!0),s=tO(e,t),a=Ig(e,t);return Nw(e,s,i,t),Tg(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function XN(e,t,n){let r={};return Tg(r,Ig(e,t)),e.create(t,e.Fragment,r,n)}function QN(e,t){return t.value}function Nw(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Tg(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function JN(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 ZN(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=ki(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 eO(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&vg.call(t.properties,o)){let i=nO(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&VN.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 tO(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 Rs(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 Rs(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function Ig(e,t){let n=[],r=-1,o=e.passKeys?new Map:jN;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=zw(e,i,s);a!==void 0&&n.push(a)}return n}function nO(e,t,n){let r=yg(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?dw(n):bw(n)),r.property==="style"){let o=typeof n=="object"?n:rO(e,String(n));return e.stylePropertyNameCase==="css"&&(o=oO(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?xg[r.property]||r.property:r.attribute,n]}}function rO(e,t){try{return(0,Dw.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new At("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=Rw+"#cannot-parse-style-attribute",o}}function Ow(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=El(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=El(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return vg.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);Rs(e)}function Rs(e,t){let n=new At("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=Rw+"#cannot-handle-mdx-estrees-without-createevaluater",n}function oO(e){let t={},n;for(n in e)vg.call(e,n)&&(t[iO(n)]=e[n]);return t}function iO(e){let t=e.replace(HN,sO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function sO(e){return"-"+e.toLowerCase()}var zs={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 g$,jsx as m$,jsxs as h$}from"react/jsx-runtime";import{useEffect as cie,useState as uie}from"react";var aO={};function Fg(e,t){let n=t||aO,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return $w(e,r,o)}function $w(e,t,n){if(lO(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 _w(e.children,t,n)}return Array.isArray(e)?_w(e,t,n):""}function _w(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=$w(e[o],t,n);return r.join("")}function lO(e){return!!(e&&typeof e=="object")}var Uw=document.createElement("i");function vi(e){let t="&"+e+";";Uw.innerHTML=t;let n=Uw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function en(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?(en(e,e.length,0,t),e):t}var jw={}.hasOwnProperty;function Hw(e){let t={},n=-1;for(;++n<e.length;)cO(t,e[n]);return t}function cO(e,t){let n;for(n in t){let o=(jw.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){jw.call(o,s)||(o[s]=[]);let a=i[s];uO(o[s],Array.isArray(a)?a:a?[a]:[])}}}function uO(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);en(e,0,0,r)}function Rl(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 $r(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Rn=fo(/[A-Za-z]/),Xt=fo(/[\dA-Za-z]/),Ww=fo(/[#-'*+\--9=?A-Z^-~]/);function Ns(e){return e!==null&&(e<32||e===127)}var Os=fo(/\d/),Vw=fo(/[\dA-Fa-f]/),Gw=fo(/[!-/:-@[-`{-~]/);function oe(e){return e!==null&&e<-2}function Pt(e){return e!==null&&(e<0||e===32)}function Me(e){return e===-2||e===-1||e===32}var qw=fo(/\p{P}|\p{S}/u),Yw=fo(/\s/);function fo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Qn(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&Xt(e.charCodeAt(n+1))&&Xt(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 Re(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return Me(u)?(e.enter(n),a(u)):t(u)}function a(u){return Me(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var Kw={tokenize:pO};function pO(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"),Re(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 oe(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var Qw={tokenize:dO},Xw={tokenize:fO};function dO(e){let t=this,n=[],r=0,o,i,s;return a;function a(R){if(r<n.length){let z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,u,c)(R)}return c(R)}function u(R){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&T();let z=t.events.length,N=z,E;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){E=t.events[N][1].end;break}F(r);let M=z;for(;M<t.events.length;)t.events[M][1].end={...E},M++;return en(t.events,N+1,0,t.events.slice(z)),t.events.length=M,c(R)}return a(R)}function c(R){if(r===n.length){if(!o)return f(R);if(o.currentConstruct&&o.currentConstruct.concrete)return h(R);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Xw,l,p)(R)}function l(R){return o&&T(),F(r),f(R)}function p(R){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,h(R)}function f(R){return t.containerState={},e.attempt(Xw,d,h)(R)}function d(R){return r++,n.push([t.currentConstruct,t.containerState]),f(R)}function h(R){if(R===null){o&&T(),F(0),e.consume(R);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),S(R)}function S(R){if(R===null){C(e.exit("chunkFlow"),!0),F(0),e.consume(R);return}return oe(R)?(e.consume(R),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(R),S)}function C(R,z){let N=t.sliceStream(R);if(z&&N.push(null),R.previous=i,i&&(i.next=R),i=R,o.defineSkip(R.start),o.write(N),t.parser.lazy[R.start.line]){let E=o.events.length;for(;E--;)if(o.events[E][1].start.offset<s&&(!o.events[E][1].end||o.events[E][1].end.offset>s))return;let M=t.events.length,g=M,k,w;for(;g--;)if(t.events[g][0]==="exit"&&t.events[g][1].type==="chunkFlow"){if(k){w=t.events[g][1].end;break}k=!0}for(F(r),E=M;E<t.events.length;)t.events[E][1].end={...w},E++;en(t.events,g+1,0,t.events.slice(M)),t.events.length=E}}function F(R){let z=n.length;for(;z-- >R;){let N=n[z];t.containerState=N[1],N[0].exit.call(t,e)}n.length=R}function T(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function fO(e,t,n){return Re(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Eg(e){if(e===null||Pt(e)||Yw(e))return 1;if(qw(e))return 2}function Ci(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 _s={name:"attention",resolveAll:gO,tokenize:mO};function gO(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 p={...e[r][1].end},f={...e[n][1].start};Jw(p,-u),Jw(f,u),s={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},e[r][1].end={...s.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=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,Ci(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,en(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 mO(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Eg(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=Eg(u),p=!l||l===2&&o||n.includes(u),f=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?p:p&&(o||!f)),c._close=!!(i===42?f:f&&(l||!p)),t(u)}}function Jw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ag={name:"autolink",tokenize:hO};function hO(e,t,n){let r=0;return o;function o(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(d){return Rn(d)?(e.consume(d),s):d===64?n(d):c(d)}function s(d){return d===43||d===45||d===46||Xt(d)?(r=1,a(d)):c(d)}function a(d){return d===58?(e.consume(d),r=0,u):(d===43||d===45||d===46||Xt(d))&&r++<32?(e.consume(d),a):(r=0,c(d))}function u(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):d===null||d===32||d===60||Ns(d)?n(d):(e.consume(d),u)}function c(d){return d===64?(e.consume(d),l):Ww(d)?(e.consume(d),c):n(d)}function l(d){return Xt(d)?p(d):n(d)}function p(d){return d===46?(e.consume(d),r=0,l):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):f(d)}function f(d){if((d===45||Xt(d))&&r++<63){let h=d===45?f:p;return e.consume(d),h}return n(d)}}var go={partial:!0,tokenize:xO};function xO(e,t,n){return r;function r(i){return Me(i)?Re(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||oe(i)?t(i):n(i)}}var zl={continuation:{tokenize:bO},exit:SO,name:"blockQuote",tokenize:yO};function yO(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 Me(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function bO(e,t,n){let r=this;return o;function o(s){return Me(s)?Re(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(zl,t,n)(s)}}function SO(e){e.exit("blockQuote")}var Nl={name:"characterEscape",tokenize:wO};function wO(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 Gw(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Ol={name:"characterReference",tokenize:kO};function kO(e,t,n){let r=this,o=0,i,s;return a;function a(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,s=Xt,l(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,s=Vw,l):(e.enter("characterReferenceValue"),i=7,s=Os,l(p))}function l(p){if(p===59&&o){let f=e.exit("characterReferenceValue");return s===Xt&&!vi(r.sliceSerialize(f))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(p)&&o++<i?(e.consume(p),l):n(p)}}var Zw={partial:!0,tokenize:CO},_l={concrete:!0,name:"codeFenced",tokenize:vO};function vO(e,t,n){let r=this,o={partial:!0,tokenize:N},i=0,s=0,a;return u;function u(E){return c(E)}function c(E){let M=r.events[r.events.length-1];return i=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,a=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(E)}function l(E){return E===a?(s++,e.consume(E),l):s<3?n(E):(e.exit("codeFencedFenceSequence"),Me(E)?Re(e,p,"whitespace")(E):p(E))}function p(E){return E===null||oe(E)?(e.exit("codeFencedFence"),r.interrupt?t(E):e.check(Zw,S,z)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(E))}function f(E){return E===null||oe(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(E)):Me(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Re(e,d,"whitespace")(E)):E===96&&E===a?n(E):(e.consume(E),f)}function d(E){return E===null||oe(E)?p(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(E))}function h(E){return E===null||oe(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(E)):E===96&&E===a?n(E):(e.consume(E),h)}function S(E){return e.attempt(o,z,C)(E)}function C(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),F}function F(E){return i>0&&Me(E)?Re(e,T,"linePrefix",i+1)(E):T(E)}function T(E){return E===null||oe(E)?e.check(Zw,S,z)(E):(e.enter("codeFlowValue"),R(E))}function R(E){return E===null||oe(E)?(e.exit("codeFlowValue"),T(E)):(e.consume(E),R)}function z(E){return e.exit("codeFenced"),t(E)}function N(E,M,g){let k=0;return w;function w(x){return E.enter("lineEnding"),E.consume(x),E.exit("lineEnding"),A}function A(x){return E.enter("codeFencedFence"),Me(x)?Re(E,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):m(x)}function m(x){return x===a?(E.enter("codeFencedFenceSequence"),v(x)):g(x)}function v(x){return x===a?(k++,E.consume(x),v):k>=s?(E.exit("codeFencedFenceSequence"),Me(x)?Re(E,I,"whitespace")(x):I(x)):g(x)}function I(x){return x===null||oe(x)?(E.exit("codeFencedFence"),M(x)):g(x)}}}function CO(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 $s={name:"codeIndented",tokenize:IO},TO={partial:!0,tokenize:FO};function IO(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),Re(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):oe(c)?e.attempt(TO,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||oe(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function FO(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):oe(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):Re(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):oe(s)?o(s):n(s)}}var Pg={name:"codeText",previous:AO,resolve:EO,tokenize:PO};function EO(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 AO(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function PO(e,t,n){let r=this,o=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),o++,u):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),i=0,p(f)):oe(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(f))}function l(f){return f===null||f===32||f===96||oe(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),l)}function p(f){return f===96?(e.consume(f),i++,p):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",l(f))}}var $l=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&&Us(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),Us(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Us(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);Us(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Us(this.left,n.reverse())}}};function Us(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 Ul(e){let t={},n=-1,r,o,i,s,a,u,c,l=new $l(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,LO(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 en(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function LO(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,p,f=-1,d=n,h=0,S=0,C=[S];for(;d;){for(;e.get(++o)[1]!==d;);i.push(o),d._tokenizer||(l=r.sliceStream(d),d.next||l.push(null),p&&s.defineSkip(d.start),d._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(l),d._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),p=d,d=d.next}for(d=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(S=f+1,C.push(S),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(s.events=[],d?(d._tokenizer=void 0,d.previous=void 0):C.pop(),f=C.length;f--;){let F=a.slice(C[f],C[f+1]),T=i.pop();u.push([T,T+F.length-1]),e.splice(T,2,F)}for(u.reverse(),f=-1;++f<u.length;)c[h+u[f][0]]=h+u[f][1],h+=u[f][1]-u[f][0]-1;return c}var Lg={resolve:BO,tokenize:DO},MO={partial:!0,tokenize:RO};function BO(e){return Ul(e),e}function DO(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):oe(a)?e.check(MO,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 RO(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Re(e,i,"linePrefix")}function i(s){if(s===null||oe(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 jl(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return p;function p(F){return F===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(F),e.exit(i),f):F===null||F===32||F===41||Ns(F)?n(F):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),S(F))}function f(F){return F===62?(e.enter(i),e.consume(F),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(F))}function d(F){return F===62?(e.exit("chunkString"),e.exit(a),f(F)):F===null||F===60||oe(F)?n(F):(e.consume(F),F===92?h:d)}function h(F){return F===60||F===62||F===92?(e.consume(F),d):d(F)}function S(F){return!l&&(F===null||F===41||Pt(F))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(F)):l<c&&F===40?(e.consume(F),l++,S):F===41?(e.consume(F),l--,S):F===null||F===32||F===40||Ns(F)?n(F):(e.consume(F),F===92?C:S)}function C(F){return F===40||F===41||F===92?(e.consume(F),S):S(F)}}function Hl(e,t,n,r,o,i){let s=this,a=0,u;return c;function c(d){return e.enter(r),e.enter(o),e.consume(d),e.exit(o),e.enter(i),l}function l(d){return a>999||d===null||d===91||d===93&&!u||d===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):d===93?(e.exit(i),e.enter(o),e.consume(d),e.exit(o),e.exit(r),t):oe(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===null||d===91||d===93||oe(d)||a++>999?(e.exit("chunkString"),l(d)):(e.consume(d),u||(u=!Me(d)),d===92?f:p)}function f(d){return d===91||d===92||d===93?(e.consume(d),a++,p):p(d)}}function Wl(e,t,n,r,o,i){let s;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(o),e.consume(f),e.exit(o),s=f===40?41:f,u):n(f)}function u(f){return f===s?(e.enter(o),e.consume(f),e.exit(o),e.exit(r),t):(e.enter(i),c(f))}function c(f){return f===s?(e.exit(i),u(s)):f===null?n(f):oe(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Re(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===s||f===null||oe(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?p:l)}function p(f){return f===s||f===92?(e.consume(f),l):l(f)}}function _o(e,t){let n;return r;function r(o){return oe(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Me(o)?Re(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Mg={name:"definition",tokenize:NO},zO={partial:!0,tokenize:OO};function NO(e,t,n){let r=this,o;return i;function i(d){return e.enter("definition"),s(d)}function s(d){return Hl.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return o=$r(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter("definitionMarker"),e.consume(d),e.exit("definitionMarker"),u):n(d)}function u(d){return Pt(d)?_o(e,c)(d):c(d)}function c(d){return jl(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function l(d){return e.attempt(zO,p,p)(d)}function p(d){return Me(d)?Re(e,f,"whitespace")(d):f(d)}function f(d){return d===null||oe(d)?(e.exit("definition"),r.parser.defined.push(o),t(d)):n(d)}}function OO(e,t,n){return r;function r(a){return Pt(a)?_o(e,o)(a):n(a)}function o(a){return Wl(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return Me(a)?Re(e,s,"whitespace")(a):s(a)}function s(a){return a===null||oe(a)?t(a):n(a)}}var Bg={name:"hardBreakEscape",tokenize:_O};function _O(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return oe(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var Dg={name:"headingAtx",resolve:$O,tokenize:UO};function $O(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"},en(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function UO(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||Pt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||oe(l)?(e.exit("atxHeading"),t(l)):Me(l)?Re(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||Pt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var ek=["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"],Rg=["pre","script","style","textarea"];var zg={concrete:!0,name:"htmlFlow",resolveTo:WO,tokenize:VO},jO={partial:!0,tokenize:qO},HO={partial:!0,tokenize:GO};function WO(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 VO(e,t,n){let r=this,o,i,s,a,u;return c;function c(B){return l(B)}function l(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),p}function p(B){return B===33?(e.consume(B),f):B===47?(e.consume(B),i=!0,S):B===63?(e.consume(B),o=3,r.interrupt?t:y):Rn(B)?(e.consume(B),s=String.fromCharCode(B),C):n(B)}function f(B){return B===45?(e.consume(B),o=2,d):B===91?(e.consume(B),o=5,a=0,h):Rn(B)?(e.consume(B),o=4,r.interrupt?t:y):n(B)}function d(B){return B===45?(e.consume(B),r.interrupt?t:y):n(B)}function h(B){let X="CDATA[";return B===X.charCodeAt(a++)?(e.consume(B),a===X.length?r.interrupt?t:m:h):n(B)}function S(B){return Rn(B)?(e.consume(B),s=String.fromCharCode(B),C):n(B)}function C(B){if(B===null||B===47||B===62||Pt(B)){let X=B===47,ee=s.toLowerCase();return!X&&!i&&Rg.includes(ee)?(o=1,r.interrupt?t(B):m(B)):ek.includes(s.toLowerCase())?(o=6,X?(e.consume(B),F):r.interrupt?t(B):m(B)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):i?T(B):R(B))}return B===45||Xt(B)?(e.consume(B),s+=String.fromCharCode(B),C):n(B)}function F(B){return B===62?(e.consume(B),r.interrupt?t:m):n(B)}function T(B){return Me(B)?(e.consume(B),T):w(B)}function R(B){return B===47?(e.consume(B),w):B===58||B===95||Rn(B)?(e.consume(B),z):Me(B)?(e.consume(B),R):w(B)}function z(B){return B===45||B===46||B===58||B===95||Xt(B)?(e.consume(B),z):N(B)}function N(B){return B===61?(e.consume(B),E):Me(B)?(e.consume(B),N):R(B)}function E(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),u=B,M):Me(B)?(e.consume(B),E):g(B)}function M(B){return B===u?(e.consume(B),u=null,k):B===null||oe(B)?n(B):(e.consume(B),M)}function g(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Pt(B)?N(B):(e.consume(B),g)}function k(B){return B===47||B===62||Me(B)?R(B):n(B)}function w(B){return B===62?(e.consume(B),A):n(B)}function A(B){return B===null||oe(B)?m(B):Me(B)?(e.consume(B),A):n(B)}function m(B){return B===45&&o===2?(e.consume(B),P):B===60&&o===1?(e.consume(B),L):B===62&&o===4?(e.consume(B),U):B===63&&o===3?(e.consume(B),y):B===93&&o===5?(e.consume(B),O):oe(B)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(jO,V,v)(B)):B===null||oe(B)?(e.exit("htmlFlowData"),v(B)):(e.consume(B),m)}function v(B){return e.check(HO,I,V)(B)}function I(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),x}function x(B){return B===null||oe(B)?v(B):(e.enter("htmlFlowData"),m(B))}function P(B){return B===45?(e.consume(B),y):m(B)}function L(B){return B===47?(e.consume(B),s="",D):m(B)}function D(B){if(B===62){let X=s.toLowerCase();return Rg.includes(X)?(e.consume(B),U):m(B)}return Rn(B)&&s.length<8?(e.consume(B),s+=String.fromCharCode(B),D):m(B)}function O(B){return B===93?(e.consume(B),y):m(B)}function y(B){return B===62?(e.consume(B),U):B===45&&o===2?(e.consume(B),y):m(B)}function U(B){return B===null||oe(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),U)}function V(B){return e.exit("htmlFlow"),t(B)}}function GO(e,t,n){let r=this;return o;function o(s){return oe(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 qO(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(go,t,n)}}var Ng={name:"htmlText",tokenize:YO};function YO(e,t,n){let r=this,o,i,s;return a;function a(y){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(y),u}function u(y){return y===33?(e.consume(y),c):y===47?(e.consume(y),N):y===63?(e.consume(y),R):Rn(y)?(e.consume(y),g):n(y)}function c(y){return y===45?(e.consume(y),l):y===91?(e.consume(y),i=0,h):Rn(y)?(e.consume(y),T):n(y)}function l(y){return y===45?(e.consume(y),d):n(y)}function p(y){return y===null?n(y):y===45?(e.consume(y),f):oe(y)?(s=p,L(y)):(e.consume(y),p)}function f(y){return y===45?(e.consume(y),d):p(y)}function d(y){return y===62?P(y):y===45?f(y):p(y)}function h(y){let U="CDATA[";return y===U.charCodeAt(i++)?(e.consume(y),i===U.length?S:h):n(y)}function S(y){return y===null?n(y):y===93?(e.consume(y),C):oe(y)?(s=S,L(y)):(e.consume(y),S)}function C(y){return y===93?(e.consume(y),F):S(y)}function F(y){return y===62?P(y):y===93?(e.consume(y),F):S(y)}function T(y){return y===null||y===62?P(y):oe(y)?(s=T,L(y)):(e.consume(y),T)}function R(y){return y===null?n(y):y===63?(e.consume(y),z):oe(y)?(s=R,L(y)):(e.consume(y),R)}function z(y){return y===62?P(y):R(y)}function N(y){return Rn(y)?(e.consume(y),E):n(y)}function E(y){return y===45||Xt(y)?(e.consume(y),E):M(y)}function M(y){return oe(y)?(s=M,L(y)):Me(y)?(e.consume(y),M):P(y)}function g(y){return y===45||Xt(y)?(e.consume(y),g):y===47||y===62||Pt(y)?k(y):n(y)}function k(y){return y===47?(e.consume(y),P):y===58||y===95||Rn(y)?(e.consume(y),w):oe(y)?(s=k,L(y)):Me(y)?(e.consume(y),k):P(y)}function w(y){return y===45||y===46||y===58||y===95||Xt(y)?(e.consume(y),w):A(y)}function A(y){return y===61?(e.consume(y),m):oe(y)?(s=A,L(y)):Me(y)?(e.consume(y),A):k(y)}function m(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),o=y,v):oe(y)?(s=m,L(y)):Me(y)?(e.consume(y),m):(e.consume(y),I)}function v(y){return y===o?(e.consume(y),o=void 0,x):y===null?n(y):oe(y)?(s=v,L(y)):(e.consume(y),v)}function I(y){return y===null||y===34||y===39||y===60||y===61||y===96?n(y):y===47||y===62||Pt(y)?k(y):(e.consume(y),I)}function x(y){return y===47||y===62||Pt(y)?k(y):n(y)}function P(y){return y===62?(e.consume(y),e.exit("htmlTextData"),e.exit("htmlText"),t):n(y)}function L(y){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),D}function D(y){return Me(y)?Re(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):O(y)}function O(y){return e.enter("htmlTextData"),s(y)}}var $o={name:"labelEnd",resolveAll:JO,resolveTo:ZO,tokenize:e_},KO={tokenize:t_},XO={tokenize:n_},QO={tokenize:r_};function JO(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&&en(e,0,e.length,n),e}function ZO(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,Ci(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]]),en(e,i,e.length,a),e}function e_(e,t,n){let r=this,o=r.events.length,i,s;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return a;function a(f){return i?i._inactive?p(f):(s=r.parser.defined.includes($r(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),u):n(f)}function u(f){return f===40?e.attempt(KO,l,s?l:p)(f):f===91?e.attempt(XO,l,s?c:p)(f):s?l(f):p(f)}function c(f){return e.attempt(QO,l,p)(f)}function l(f){return t(f)}function p(f){return i._balanced=!0,n(f)}}function t_(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),o}function o(p){return Pt(p)?_o(e,i)(p):i(p)}function i(p){return p===41?l(p):jl(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function s(p){return Pt(p)?_o(e,u)(p):l(p)}function a(p){return n(p)}function u(p){return p===34||p===39||p===40?Wl(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):l(p)}function c(p){return Pt(p)?_o(e,l)(p):l(p)}function l(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function n_(e,t,n){let r=this;return o;function o(a){return Hl.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes($r(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function r_(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 Og={name:"labelStartImage",resolveAll:$o.resolveAll,tokenize:o_};function o_(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 _g={name:"labelStartLink",resolveAll:$o.resolveAll,tokenize:i_};function i_(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 js={name:"lineEnding",tokenize:s_};function s_(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Re(e,t,"linePrefix")}}var Uo={name:"thematicBreak",tokenize:a_};function a_(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||oe(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),Me(c)?Re(e,a,"whitespace")(c):a(c))}}var an={continuation:{tokenize:p_},exit:f_,name:"list",tokenize:u_},l_={partial:!0,tokenize:g_},c_={partial:!0,tokenize:d_};function u_(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(d){let h=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(h==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:Os(d)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(Uo,n,c)(d):c(d);if(!r.interrupt||d===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(d)}return n(d)}function u(d){return Os(d)&&++s<10?(e.consume(d),u):(!r.interrupt||s<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit("listItemValue"),c(d)):n(d)}function c(d){return e.enter("listItemMarker"),e.consume(d),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||d,e.check(go,r.interrupt?n:l,e.attempt(l_,f,p))}function l(d){return r.containerState.initialBlankLine=!0,i++,f(d)}function p(d){return Me(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),f):n(d)}function f(d){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function p_(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(go,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Re(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!Me(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(c_,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Re(e,e.attempt(an,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function d_(e,t,n){let r=this;return Re(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 f_(e){e.exit(this.containerState.type)}function g_(e,t,n){let r=this;return Re(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!Me(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var Vl={name:"setextUnderline",resolveTo:m_,tokenize:h_};function m_(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 h_(e,t,n){let r=this,o;return i;function i(c){let l=r.events.length,p;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){p=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(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"),Me(c)?Re(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||oe(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var tk={tokenize:x_};function x_(e){let t=this,n=e.attempt(go,r,e.attempt(this.parser.constructs.flowInitial,o,Re(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Lg,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 nk={resolveAll:sk()},rk=ik("string"),ok=ik("text");function ik(e){return{resolveAll:sk(e==="text"?y_: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 p=o[l],f=-1;if(p)for(;++f<p.length;){let d=p[f];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function sk(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 y_(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 $g={};xe($g,{attentionMarkers:()=>I_,contentInitial:()=>S_,disable:()=>F_,document:()=>b_,flow:()=>k_,flowInitial:()=>w_,insideSpan:()=>T_,string:()=>v_,text:()=>C_});var b_={42:an,43:an,45:an,48:an,49:an,50:an,51:an,52:an,53:an,54:an,55:an,56:an,57:an,62:zl},S_={91:Mg},w_={[-2]:$s,[-1]:$s,32:$s},k_={35:Dg,42:Uo,45:[Vl,Uo],60:zg,61:Vl,95:Uo,96:_l,126:_l},v_={38:Ol,92:Nl},C_={[-5]:js,[-4]:js,[-3]:js,33:Og,38:Ol,42:_s,60:[Ag,Ng],91:_g,92:[Bg,Nl],93:$o,95:_s,96:Pg},T_={null:[_s,nk]},I_={null:[42,95]},F_={null:[]};function ak(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:k(M),check:k(g),consume:z,enter:N,exit:E,interrupt:k(g,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:C,parser:e,previous:null,sliceSerialize:h,sliceStream:S,write:d},p=t.tokenize.call(l,c),f;return t.resolveAll&&i.push(t),l;function d(v){return s=dn(s,v),T(),s[s.length-1]!==null?[]:(w(t,0),l.events=Ci(i,l.events,l),l.events)}function h(v,I){return A_(S(v),I)}function S(v){return E_(s,v)}function C(){let{_bufferIndex:v,_index:I,line:x,column:P,offset:L}=r;return{_bufferIndex:v,_index:I,line:x,column:P,offset:L}}function F(v){o[v.line]=v.column,m()}function T(){let v;for(;r._index<s.length;){let I=s[r._index];if(typeof I=="string")for(v=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===v&&r._bufferIndex<I.length;)R(I.charCodeAt(r._bufferIndex));else R(I)}}function R(v){u=void 0,f=v,p=p(v)}function z(v){oe(v)?(r.line++,r.column=1,r.offset+=v===-3?2:1,m()):v!==-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=v,u=!0}function N(v,I){let x=I||{};return x.type=v,x.start=C(),l.events.push(["enter",x,l]),a.push(x),x}function E(v){let I=a.pop();return I.end=C(),l.events.push(["exit",I,l]),I}function M(v,I){w(v,I.from)}function g(v,I){I.restore()}function k(v,I){return x;function x(P,L,D){let O,y,U,V;return Array.isArray(P)?X(P):"tokenize"in P?X([P]):B(P);function B(Te){return We;function We(ot){let j=ot!==null&&Te[ot],ie=ot!==null&&Te.null,re=[...Array.isArray(j)?j:j?[j]:[],...Array.isArray(ie)?ie:ie?[ie]:[]];return X(re)(ot)}}function X(Te){return O=Te,y=0,Te.length===0?D:ee(Te[y])}function ee(Te){return We;function We(ot){return V=A(),U=Te,Te.partial||(l.currentConstruct=Te),Te.name&&l.parser.constructs.disable.null.includes(Te.name)?Ee(ot):Te.tokenize.call(I?Object.assign(Object.create(l),I):l,c,Q,Ee)(ot)}}function Q(Te){return u=!0,v(U,V),L}function Ee(Te){return u=!0,V.restore(),++y<O.length?ee(O[y]):D}}}function w(v,I){v.resolveAll&&!i.includes(v)&&i.push(v),v.resolve&&en(l.events,I,l.events.length-I,v.resolve(l.events.slice(I),l)),v.resolveTo&&(l.events=v.resolveTo(l.events,l))}function A(){let v=C(),I=l.previous,x=l.currentConstruct,P=l.events.length,L=Array.from(a);return{from:P,restore:D};function D(){r=v,l.previous=I,l.currentConstruct=x,l.events.length=P,a=L,m()}}function m(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function E_(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 A_(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=`
79
+ `;break}case-3:{s=`\r
80
+ `;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 Ug(e){let r={constructs:Hw([$g,...(e||{}).extensions||[]]),content:o(Kw),defined:[],document:o(Qw),flow:o(tk),lazy:{},string:o(rk),text:o(ok)};return r;function o(i){return s;function s(a){return ak(r,i,a)}}}function jg(e){for(;!Ul(e););return e}var lk=/[\0\t\n\r]/g;function Hg(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,p,f,d;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(s||void 0).decode(i)),p=0,t="",n&&(i.charCodeAt(0)===65279&&p++,n=void 0);p<i.length;){if(lk.lastIndex=p,c=lk.exec(i),f=c&&c.index!==void 0?c.index:i.length,d=i.charCodeAt(f),!c){t=i.slice(p);break}if(d===10&&p===f&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<f&&(u.push(i.slice(p,f)),e+=f-p),d){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}p=f+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var P_=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ck(e){return e.replace(P_,L_)}function L_(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Rl(n.slice(i?2:1),i?16:10)}return vi(n)||e}var pk={}.hasOwnProperty;function Wg(e,t,n){return typeof t!="string"&&(n=t,t=void 0),M_(n)(jg(Ug(n).document().write(Hg()(e,t,!0))))}function M_(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(zn),autolinkProtocol:k,autolinkEmail:k,atxHeading:i(de),blockQuote:i(ot),characterEscape:k,characterReference:k,codeFenced:i(j),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(j,s),codeText:i(ie,s),codeTextData:k,data:k,codeFlowValue:k,definition:i(re),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(he),hardBreakEscape:i($e),hardBreakTrailing:i($e),htmlFlow:i(it,s),htmlFlowData:k,htmlText:i(it,s),htmlTextData:k,image:i(Ot),label:s,link:i(zn),listItem:i(le),listItemValue:f,listOrdered:i(Qe,p),listUnordered:i(Qe),paragraph:i(yt),reference:B,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(de),strong:i(fr),thematicBreak:i(Ye)},exit:{atxHeading:u(),atxHeadingSequence:N,autolink:u(),autolinkEmail:We,autolinkProtocol:Te,blockQuote:u(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:Q,characterReference:Ee,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:d,codeFencedFenceMeta:h,codeFlowValue:w,codeIndented:u(F),codeText:u(x),codeTextData:w,data:w,definition:u(),definitionDestinationString:z,definitionLabelString:T,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(m),hardBreakTrailing:u(m),htmlFlow:u(v),htmlFlowData:w,htmlText:u(I),htmlTextData:w,image:u(L),label:O,labelText:D,lineEnding:A,link:u(P),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:X,resourceDestinationString:y,resourceTitleString:U,resource:V,setextHeading:u(g),setextHeadingLineSequence:M,setextHeadingText:E,strong:u(),thematicBreak:u()}};dk(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(_){let $={type:"root",children:[]},W={stack:[$],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Z=[],Ze=-1;for(;++Ze<_.length;)if(_[Ze][1].type==="listOrdered"||_[Ze][1].type==="listUnordered")if(_[Ze][0]==="enter")Z.push(Ze);else{let jt=Z.pop();Ze=o(_,jt,Ze)}for(Ze=-1;++Ze<_.length;){let jt=t[_[Ze][0]];pk.call(jt,_[Ze][1].type)&&jt[_[Ze][1].type].call(Object.assign({sliceSerialize:_[Ze][2].sliceSerialize},W),_[Ze][1])}if(W.tokenStack.length>0){let jt=W.tokenStack[W.tokenStack.length-1];(jt[1]||uk).call(W,void 0,jt[0])}for($.position={start:mo(_.length>0?_[0][1].start:{line:1,column:1,offset:0}),end:mo(_.length>0?_[_.length-2][1].end:{line:1,column:1,offset:0})},Ze=-1;++Ze<t.transforms.length;)$=t.transforms[Ze]($)||$;return $}function o(_,$,W){let Z=$-1,Ze=-1,jt=!1,gr,er,Tr,fn;for(;++Z<=W;){let ge=_[Z];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?Ze++:Ze--,fn=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(gr&&!fn&&!Ze&&!Tr&&(Tr=Z),fn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:fn=void 0}if(!Ze&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||Ze===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if(gr){let mr=Z;for(er=void 0;mr--;){let Nn=_[mr];if(Nn[1].type==="lineEnding"||Nn[1].type==="lineEndingBlank"){if(Nn[0]==="exit")continue;er&&(_[er][1].type="lineEndingBlank",jt=!0),Nn[1].type="lineEnding",er=mr}else if(!(Nn[1].type==="linePrefix"||Nn[1].type==="blockQuotePrefix"||Nn[1].type==="blockQuotePrefixWhitespace"||Nn[1].type==="blockQuoteMarker"||Nn[1].type==="listItemIndent"))break}Tr&&(!er||Tr<er)&&(gr._spread=!0),gr.end=Object.assign({},er?_[er][1].start:ge[1].end),_.splice(er||Z,0,["exit",gr,ge[2]]),Z++,W++}if(ge[1].type==="listItemPrefix"){let mr={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};gr=mr,_.splice(Z,0,["enter",mr,ge[2]]),Z++,W++,Tr=void 0,fn=!0}}}return _[$][1]._spread=jt,W}function i(_,$){return W;function W(Z){a.call(this,_(Z),Z),$&&$.call(this,Z)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(_,$,W){this.stack[this.stack.length-1].children.push(_),this.stack.push(_),this.tokenStack.push([$,W||void 0]),_.position={start:mo($.start),end:void 0}}function u(_){return $;function $(W){_&&_.call(this,W),c.call(this,W)}}function c(_,$){let W=this.stack.pop(),Z=this.tokenStack.pop();if(Z)Z[0].type!==_.type&&($?$.call(this,_,Z[0]):(Z[1]||uk).call(this,_,Z[0]));else throw new Error("Cannot close `"+_.type+"` ("+po({start:_.start,end:_.end})+"): it\u2019s not open");W.position.end=mo(_.end)}function l(){return Fg(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function f(_){if(this.data.expectingFirstListItemValue){let $=this.stack[this.stack.length-2];$.start=Number.parseInt(this.sliceSerialize(_),10),this.data.expectingFirstListItemValue=void 0}}function d(){let _=this.resume(),$=this.stack[this.stack.length-1];$.lang=_}function h(){let _=this.resume(),$=this.stack[this.stack.length-1];$.meta=_}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){let _=this.resume(),$=this.stack[this.stack.length-1];$.value=_.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function F(){let _=this.resume(),$=this.stack[this.stack.length-1];$.value=_.replace(/(\r?\n|\r)$/g,"")}function T(_){let $=this.resume(),W=this.stack[this.stack.length-1];W.label=$,W.identifier=$r(this.sliceSerialize(_)).toLowerCase()}function R(){let _=this.resume(),$=this.stack[this.stack.length-1];$.title=_}function z(){let _=this.resume(),$=this.stack[this.stack.length-1];$.url=_}function N(_){let $=this.stack[this.stack.length-1];if(!$.depth){let W=this.sliceSerialize(_).length;$.depth=W}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function M(_){let $=this.stack[this.stack.length-1];$.depth=this.sliceSerialize(_).codePointAt(0)===61?1:2}function g(){this.data.setextHeadingSlurpLineEnding=void 0}function k(_){let W=this.stack[this.stack.length-1].children,Z=W[W.length-1];(!Z||Z.type!=="text")&&(Z=se(),Z.position={start:mo(_.start),end:void 0},W.push(Z)),this.stack.push(Z)}function w(_){let $=this.stack.pop();$.value+=this.sliceSerialize(_),$.position.end=mo(_.end)}function A(_){let $=this.stack[this.stack.length-1];if(this.data.atHardBreak){let W=$.children[$.children.length-1];W.position.end=mo(_.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes($.type)&&(k.call(this,_),w.call(this,_))}function m(){this.data.atHardBreak=!0}function v(){let _=this.resume(),$=this.stack[this.stack.length-1];$.value=_}function I(){let _=this.resume(),$=this.stack[this.stack.length-1];$.value=_}function x(){let _=this.resume(),$=this.stack[this.stack.length-1];$.value=_}function P(){let _=this.stack[this.stack.length-1];if(this.data.inReference){let $=this.data.referenceType||"shortcut";_.type+="Reference",_.referenceType=$,delete _.url,delete _.title}else delete _.identifier,delete _.label;this.data.referenceType=void 0}function L(){let _=this.stack[this.stack.length-1];if(this.data.inReference){let $=this.data.referenceType||"shortcut";_.type+="Reference",_.referenceType=$,delete _.url,delete _.title}else delete _.identifier,delete _.label;this.data.referenceType=void 0}function D(_){let $=this.sliceSerialize(_),W=this.stack[this.stack.length-2];W.label=ck($),W.identifier=$r($).toLowerCase()}function O(){let _=this.stack[this.stack.length-1],$=this.resume(),W=this.stack[this.stack.length-1];if(this.data.inReference=!0,W.type==="link"){let Z=_.children;W.children=Z}else W.alt=$}function y(){let _=this.resume(),$=this.stack[this.stack.length-1];$.url=_}function U(){let _=this.resume(),$=this.stack[this.stack.length-1];$.title=_}function V(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function X(_){let $=this.resume(),W=this.stack[this.stack.length-1];W.label=$,W.identifier=$r(this.sliceSerialize(_)).toLowerCase(),this.data.referenceType="full"}function ee(_){this.data.characterReferenceType=_.type}function Q(_){let $=this.sliceSerialize(_),W=this.data.characterReferenceType,Z;W?(Z=Rl($,W==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Z=vi($);let Ze=this.stack[this.stack.length-1];Ze.value+=Z}function Ee(_){let $=this.stack.pop();$.position.end=mo(_.end)}function Te(_){w.call(this,_);let $=this.stack[this.stack.length-1];$.url=this.sliceSerialize(_)}function We(_){w.call(this,_);let $=this.stack[this.stack.length-1];$.url="mailto:"+this.sliceSerialize(_)}function ot(){return{type:"blockquote",children:[]}}function j(){return{type:"code",lang:null,meta:null,value:""}}function ie(){return{type:"inlineCode",value:""}}function re(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function he(){return{type:"emphasis",children:[]}}function de(){return{type:"heading",depth:0,children:[]}}function $e(){return{type:"break"}}function it(){return{type:"html",value:""}}function Ot(){return{type:"image",title:null,url:"",alt:null}}function zn(){return{type:"link",title:null,url:"",children:[]}}function Qe(_){return{type:"list",ordered:_.type==="listOrdered",start:null,spread:_._spread,children:[]}}function le(_){return{type:"listItem",spread:_._spread,checked:null,children:[]}}function yt(){return{type:"paragraph",children:[]}}function fr(){return{type:"strong",children:[]}}function se(){return{type:"text",value:""}}function Ye(){return{type:"thematicBreak"}}}function mo(e){return{line:e.line,column:e.column,offset:e.offset}}function dk(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?dk(e,r):B_(e,r)}}function B_(e,t){let n;for(n in t)if(pk.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 uk(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+po({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+po({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+po({start:t.start,end:t.end})+") is still open")}function Gl(e){let t=this;t.parser=n;function n(r){return Wg(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function fk(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 gk(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
81
+ `}]}function mk(e,t){let n=t.value?t.value+`
82
+ `:"",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 hk(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xk(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yk(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=Qn(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 bk(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 Sk(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ql(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 wk(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ql(e,t);let o={src:Qn(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 kk(e,t){let n={src:Qn(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 vk(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 Ck(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ql(e,t);let o={href:Qn(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 Tk(e,t){let n={href:Qn(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 Ik(e,t,n){let r=e.all(t),o=n?D_(n):Fk(t),i={},s=[];if(typeof t.checked=="boolean"){let l=r[0],p;l&&l.type==="element"&&l.tagName==="p"?p=l:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let l=r[a];(o||a!==0||l.type!=="element"||l.tagName!=="p")&&s.push({type:"text",value:`
83
+ `}),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:`
84
+ `});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function D_(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Fk(n[r])}return t}function Fk(e){let t=e.spread;return t??e.children.length>1}function Ek(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 Ak(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Pk(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Lk(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Mk(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=ki(t.children[1]),u=Dl(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 Bk(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 p=t.children[u],f={},d=s?s[u]:void 0;d&&(f.align=d);let h={type:"element",tagName:i,properties:f,children:[]};p&&(h.children=e.all(p),e.patch(p,h),h=e.applyData(p,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 Dk(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zk(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(Rk(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(Rk(t.slice(o),o>0,!1)),i.join("")}function Rk(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 Nk(e,t){let n={type:"text",value:zk(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Ok(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var _k={blockquote:fk,break:gk,code:mk,delete:hk,emphasis:xk,footnoteReference:yk,heading:bk,html:Sk,imageReference:wk,image:kk,inlineCode:vk,linkReference:Ck,link:Tk,listItem:Ik,list:Ek,paragraph:Ak,root:Pk,strong:Lk,table:Mk,tableCell:Dk,tableRow:Bk,text:Nk,thematicBreak:Ok,toml:Yl,yaml:Yl,definition:Yl,footnoteDefinition:Yl};function Yl(){}var $k=typeof self=="object"?self:globalThis,O_=(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 $k[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 $k[i](s),o)};return r},qg=e=>O_(new Map,e)(0);var Ti="",{toString:__}={},{keys:$_}=Object,Hs=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=__.call(e).slice(8,-1);switch(n){case"Array":return[1,Ti];case"Object":return[2,Ti];case"Date":return[3,Ti];case"RegExp":return[4,Ti];case"Map":return[5,Ti];case"Set":return[6,Ti];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Xl=([e,t])=>e===0&&(t==="function"||t==="symbol"),U_=(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]=Hs(s);switch(a){case 0:{let l=s;switch(u){case"bigint":a=8,l=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);l=null;break;case"undefined":return o([-1],s)}return o([a,l],s)}case 1:{if(u){let f=s;return u==="DataView"?f=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(f=new Uint8Array(s)),o([u,[...f]],s)}let l=[],p=o([a,l],s);for(let f of s)l.push(i(f));return p}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=[],p=o([a,l],s);for(let f of $_(s))(e||!Xl(Hs(s[f])))&&l.push([i(f),i(s[f])]);return p}case 3:return o([a,s.toISOString()],s);case 4:{let{source:l,flags:p}=s;return o([a,{source:l,flags:p}],s)}case 5:{let l=[],p=o([a,l],s);for(let[f,d]of s)(e||!(Xl(Hs(f))||Xl(Hs(d))))&&l.push([i(f),i(d)]);return p}case 6:{let l=[],p=o([a,l],s);for(let f of s)(e||!Xl(Hs(f)))&&l.push(i(f));return p}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},Yg=(e,{json:t,lossy:n}={})=>{let r=[];return U_(!(t||n),!!t,new Map,r)(e),r};var Ii=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?qg(Yg(e,t)):structuredClone(e):(e,t)=>qg(Yg(e,t));function j_(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 H_(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Vk(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||j_,r=e.options.footnoteBackLabel||H_,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),p=String(c.identifier).toUpperCase(),f=Qn(p.toLowerCase()),d=0,h=[],S=e.footnoteCounts.get(p);for(;S!==void 0&&++d<=S;){h.length>0&&h.push({type:"text",value:" "});let T=typeof n=="string"?n:n(u,d);typeof T=="string"&&(T={type:"text",value:T}),h.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,d),className:["data-footnote-backref"]},children:Array.isArray(T)?T:[T]})}let C=l[l.length-1];if(C&&C.type==="element"&&C.tagName==="p"){let T=C.children[C.children.length-1];T&&T.type==="text"?T.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...h)}else l.push(...h);let F={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(l,!0)};e.patch(c,F),a.push(F)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Ii(s),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
85
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
86
+ `}]}}var Ql=(function(e){if(e==null)return q_;if(typeof e=="function")return Jl(e);if(typeof e=="object")return Array.isArray(e)?W_(e):V_(e);if(typeof e=="string")return G_(e);throw new Error("Expected function, string, or object as test")});function W_(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ql(e[n]);return Jl(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function V_(e){let t=e;return Jl(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function G_(e){return Jl(t);function t(n){return n&&n.type===e}}function Jl(e){return t;function t(n,r,o){return!!(Y_(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function q_(){return!0}function Y_(e){return e!==null&&typeof e=="object"&&"type"in e}var Gk=[],Kg=!0,Zl=!1,Xg="skip";function Qg(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Ql(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){let d=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(u.type+(d?"<"+d+">":""))+")"})}return f;function f(){let d=Gk,h,S,C;if((!t||i(u,c,l[l.length-1]||void 0))&&(d=K_(n(u,l)),d[0]===Zl))return d;if("children"in u&&u.children){let F=u;if(F.children&&d[0]!==Xg)for(S=(r?F.children.length:-1)+s,C=l.concat(F);S>-1&&S<F.children.length;){let T=F.children[S];if(h=a(T,S,C)(),h[0]===Zl)return h;S=typeof h[1]=="number"?h[1]:S+s}}return d}}}function K_(e){return Array.isArray(e)?e:typeof e=="number"?[Kg,e]:e==null?Gk:[e]}function Ws(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),Qg(e,i,a,o);function a(u,c){let l=c[c.length-1],p=l?l.children.indexOf(u):void 0;return s(u,p,l)}}var Jg={}.hasOwnProperty,X_={};function Yk(e,t){let n=t||X_,r=new Map,o=new Map,i=new Map,s={..._k,...n.handlers},a={all:c,applyData:J_,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:Q_,wrap:e$};return Ws(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let p=l.type==="definition"?r:o,f=String(l.identifier).toUpperCase();p.has(f)||p.set(f,l)}}),a;function u(l,p){let f=l.type,d=a.handlers[f];if(Jg.call(a.handlers,f)&&d)return d(a,l,p);if(a.options.passThrough&&a.options.passThrough.includes(f)){if("children"in l){let{children:S,...C}=l,F=Ii(C);return F.children=a.all(l),F}return Ii(l)}return(a.options.unknownHandler||Z_)(a,l,p)}function c(l){let p=[];if("children"in l){let f=l.children,d=-1;for(;++d<f.length;){let h=a.one(f[d],l);if(h){if(d&&f[d-1].type==="break"&&(!Array.isArray(h)&&h.type==="text"&&(h.value=qk(h.value)),!Array.isArray(h)&&h.type==="element")){let S=h.children[0];S&&S.type==="text"&&(S.value=qk(S.value))}Array.isArray(h)?p.push(...h):p.push(h)}}}return p}}function Q_(e,t){e.position&&(t.position=wg(e))}function J_(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,Ii(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function Z_(e,t){let n=t.data||{},r="value"in t&&!(Jg.call(n,"hProperties")||Jg.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 e$(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
87
+ `});++r<e.length;)r&&n.push({type:"text",value:`
88
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
89
+ `}),n}function qk(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ec(e,t){let n=Yk(e,t),r=n.one(e,void 0),o=Vk(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&("children"in i,i.children.push({type:"text",value:`
90
+ `},o)),i}function tc(e,t){return e&&"run"in e?async function(n,r){let o=ec(n,{file:r,...t});await e.run(o,r)}:function(n,r){return ec(n,{file:r,...e||t})}}function Zg(e){if(e)throw e}var oc=oa(rv(),1);function Vs(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 em(){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],p=-1;if(u){s(u);return}for(;++p<o.length;)(c[p]===null||c[p]===void 0)&&(c[p]=o[p]);o=c,l?ov(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 ov(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 ur={basename:t$,dirname:n$,extname:r$,join:o$,sep:"/"};function t$(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Gs(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 n$(e){if(Gs(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 r$(e){Gs(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 o$(...e){let t=-1,n;for(;++t<e.length;)Gs(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":i$(n)}function i$(e){Gs(e);let t=e.codePointAt(0)===47,n=s$(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function s$(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 Gs(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var iv={cwd:a$};function a$(){return"/"}function Fi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function sv(e){if(typeof e=="string")e=new URL(e);else if(!Fi(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 l$(e)}function l$(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 tm=["history","path","basename","stem","extname","dirname"],jo=class{constructor(t){let n;t?Fi(t)?n={path:t}:typeof t=="string"||c$(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":iv.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<tm.length;){let i=tm[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)tm.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?ur.basename(this.path):void 0}set basename(t){rm(t,"basename"),nm(t,"basename"),this.path=ur.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ur.dirname(this.path):void 0}set dirname(t){av(this.basename,"dirname"),this.path=ur.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ur.extname(this.path):void 0}set extname(t){if(nm(t,"extname"),av(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=ur.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Fi(t)&&(t=sv(t)),rm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ur.basename(this.path,this.extname):void 0}set stem(t){rm(t,"stem"),nm(t,"stem"),this.path=ur.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 At(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 nm(e,t){if(e&&e.includes(ur.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ur.sep+"`")}function rm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function av(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function c$(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var lv=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var u$={}.hasOwnProperty,am=class e extends lv{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=em()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,oc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(sm("data",this.frozen),this.namespace[t]=n,this):u$.call(this.namespace,t)&&this.namespace[t]||void 0:t?(sm("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=rc(t),r=this.parser||this.Parser;return om("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),om("process",this.parser||this.Parser),im("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=rc(t),u=r.parse(a);r.run(u,a,function(l,p,f){if(l||!p||!f)return c(l);let d=p,h=r.stringify(d,f);d$(h)?f.value=h:f.result=h,c(l,f)});function c(l,p){l||!p?s(l):i?i(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),om("processSync",this.parser||this.Parser),im("processSync",this.compiler||this.Compiler),this.process(t,o),uv("processSync","process",n),r;function o(i,s){n=!0,Zg(i),r=s}}run(t,n,r){cv(t),this.freeze();let o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(s,a){let u=rc(n);o.run(t,u,c);function c(l,p,f){let d=p||t;l?a(l):s?s(d):r(void 0,d,f)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),uv("runSync","run",r),o;function i(s,a){Zg(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=rc(n),o=this.compiler||this.Compiler;return im("stringify",o),cv(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(sm("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,...p]=c;u(l,p)}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,oc.default)(!0,o.settings,c.settings))}function a(c){let l=-1;if(c!=null)if(Array.isArray(c))for(;++l<c.length;){let p=c[l];i(p)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,l){let p=-1,f=-1;for(;++p<r.length;)if(r[p][0]===c){f=p;break}if(f===-1)r.push([c,...l]);else if(l.length>0){let[d,...h]=l,S=r[f][1];Vs(S)&&Vs(d)&&(d=(0,oc.default)(!0,S,d)),r[f]=[c,d,...h]}}}},lm=new am().freeze();function om(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function im(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function sm(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 cv(e){if(!Vs(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function uv(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function rc(e){return p$(e)?e:new jo(e)}function p$(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function d$(e){return typeof e=="string"||f$(e)}function f$(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var x$="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",pv=[],dv={allowDangerousHtml:!0},y$=/^(https?|ircs?|mailto|xmpp)$/i,b$=[{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 cm(e){let t=S$(e),n=w$(e);return k$(t.runSync(t.parse(n),n),e)}function S$(e){let t=e.rehypePlugins||pv,n=e.remarkPlugins||pv,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dv}:dv;return lm().use(Gl).use(n).use(tc,r).use(t)}function w$(e){let t=e.children||"",n=new jo;return typeof t=="string"?n.value=t:(""+t,void 0),n}function k$(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||fv;for(let l of b$)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+x$+l.id,void 0);return n&&i&&void 0,Ws(e,c),Cg(e,{Fragment:g$,components:o,ignoreInvalidStyle:!0,jsx:m$,jsxs:h$,passKeys:!0,passNode:!0});function c(l,p,f){if(l.type==="raw"&&f&&typeof p=="number")return s?f.children.splice(p,1):f.children[p]={type:"text",value:l.value},p;if(l.type==="element"){let d;for(d in zs)if(Object.hasOwn(zs,d)&&Object.hasOwn(l.properties,d)){let h=l.properties[d],S=zs[d];(S===null||S.includes(l.tagName))&&(l.properties[d]=u(String(h||""),d,l))}}if(l.type==="element"){let d=n?!n.includes(l.tagName):i?i.includes(l.tagName):!1;if(!d&&r&&typeof p=="number"&&(d=!r(l,p,f)),d&&f&&typeof p=="number")return a&&l.children?f.children.splice(p,1,...l.children):f.children.splice(p,1),p}}}function fv(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||y$.test(e.slice(0,t))?e:""}Ae();var C$=Ei.div({display:"flex",flexDirection:"column",gap:"12px"}),T$=Ei.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),I$=Ei.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),F$=Ei(xr)({padding:"6px 12px",fontSize:"12px"}),E$=Ei.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:Fl.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}})),A$=Ei.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),um=()=>{let{fullPrompt:e}=ye(),[t,n]=v$(!1),r=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch(o){console.error("Failed to copy:",o)}};return e?Ho.createElement(C$,null,Ho.createElement(T$,null,Ho.createElement(I$,null,"Full Prompt"),Ho.createElement(F$,{onClick:r,disabled:t},t?"\u2713 Copied!":"\u{1F4CB} Copy")),Ho.createElement(E$,null,Ho.createElement(cm,null,e))):Ho.createElement(A$,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import Ur,{useRef as P$}from"react";import{styled as pr}from"storybook/theming";Ae();var L$=pr.div({display:"flex",flexDirection:"column",gap:"8px"}),Mie=pr.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"}}),M$=pr.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})),B$=pr.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})),Bie=pr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),gv=pr.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||ue,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||ue,backgroundColor:e.background.warning||"#ffedd5"}})),D$=pr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),R$=pr.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"})),z$=pr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),N$=pr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),Die=pr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function O$(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 pm=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r}=ye(),o=P$(null),i=r?n.find(p=>p.id===r):null,s=i?i.issues.length>0&&i.issues.every(p=>p.dismissed):!1,a=i&&(i.complianceScore===100||s),u=e.filter(p=>p.role==="assistant"||p.role==="system"&&p.content.includes("auto-dismissed")),c=u.length===0&&!!t;if(u.length===0&&!c)return Ur.createElement(D$,null,"No AI response yet. The AI's analysis will appear here as it streams.");let l=u.length>0?u:[{role:"assistant",content:t}];return Ur.createElement(L$,null,a&&Ur.createElement(R$,null,Ur.createElement(z$,null,"Component Matches Design"),Ur.createElement(N$,null,s&&i?.issues.length?`All ${i.issues.length} issue${i.issues.length===1?"":"s"} identified by the AI ${i.issues.length===1?"was":"were"} validated as false positive${i.issues.length===1?"":"s"} and auto-dismissed.`:"No design discrepancies found. The implementation matches the Figma design.")),Ur.createElement(M$,{ref:o},l.map((p,f)=>Ur.createElement(B$,{key:f,role:p.role},p.role==="system"?Ur.createElement(gv,null,p.content):Ur.createElement(gv,{dangerouslySetInnerHTML:{__html:O$(p.content)}})))))};import Jn from"react";import{styled as ho}from"storybook/theming";Ae();Pe();var _$=ho.div({display:"flex",flexDirection:"column",gap:"12px"}),$$=ho.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),U$=ho.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}}}),mv=ho.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"}}),j$=ho.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),hv=ho.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||ue,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||ue,backgroundColor:e.background.warning||"#ffedd5"}})),xv=ho.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),H$=ho.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 yv(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 W$(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 bv=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r}=ye();Jn.useEffect(()=>{e&&(b.debug("[ModelResultsTabs] multiModelResults:",e),Object.entries(e.byModel).forEach(([a,u])=>{b.debug(`[ModelResultsTabs] ${a}:`,{hasStreamingMessages:!!u.streamingMessages,streamingMessagesLength:u.streamingMessages?.length||0,streamingMessagesPreview:u.streamingMessages?.[0]?.content?.substring(0,100),hasFullResponse:!!u.fullResponse,fullResponsePreview:u.fullResponse?.substring(0,100)})}))},[e]);let o=e&&Object.keys(e.byModel).length>0?Object.keys(e.byModel):r,i=e?.activeModelId||(o.length>0?o[0]:""),s=e?.byModel||{};return o.length===0?Jn.createElement(xv,null,"No models selected. Select multiple models to compare results."):Jn.createElement(_$,null,Jn.createElement($$,null,o.map(a=>{let u=Or.find(h=>h.id===a),c=s[a],p=W$(t&&c?.streamingMessages&&c.streamingMessages.length>0?c.streamingMessages[0].content||"":c?.fullResponse?c.fullResponse:""),f=a===i;if(!u)return null;let d=t&&!c?.completed;return Jn.createElement(U$,{key:a,isActive:f,provider:u.provider,onClick:()=>n(a)},u.name,c&&p.issueCount>0&&Jn.createElement(mv,{variant:"issues",value:p.issueCount},p.issueCount," issues"),c&&p.score!==null&&Jn.createElement(mv,{variant:"score",value:p.score},"Score: ",p.score),d&&Jn.createElement(H$,null))})),Jn.createElement(j$,null,s[i]?.streamingMessages&&s[i].streamingMessages.length>0?s[i].streamingMessages.map((a,u)=>Jn.createElement(hv,{key:u,dangerouslySetInnerHTML:{__html:yv(a.content)}})):s[i]?.fullResponse?Jn.createElement(hv,{dangerouslySetInnerHTML:{__html:yv(s[i].fullResponse)}}):Jn.createElement(xv,null,t?`Waiting for ${Or.find(a=>a.id===i)?.name}...`:`No response yet for ${Or.find(a=>a.id===i)?.name}`)))};import Ne from"react";import{styled as ht}from"storybook/theming";Ae();import G,{useMemo as F4,useState as E4,useEffect as A4}from"react";import{styled as Xe,keyframes as P4}from"storybook/theming";import H,{useState as fm,useRef as IU,useCallback as Lv,memo as FU}from"react";import{styled as pe}from"storybook/theming";import jr,{useState as V$}from"react";import{styled as Hr}from"storybook/theming";var G$=Hr.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}),q$=Hr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"8px",padding:"24px",maxWidth:"500px",width:"90%",boxShadow:e.base==="dark"?"0 10px 40px rgba(0, 0, 0, 0.5)":"0 10px 40px rgba(0, 0, 0, 0.2)",border:`1px solid ${e.appBorderColor}`})),Y$=Hr.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),K$=Hr.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),X$=Hr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),Q$=Hr.textarea(({theme:e})=>({width:"100%",minHeight:"80px",padding:"10px",fontSize:"13px",borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,color:e.color.defaultText,fontFamily:"inherit",resize:"vertical",marginBottom:"20px","&:focus":{outline:"none",borderColor:ue,boxShadow:`0 0 0 3px ${e.base==="dark"?"rgba(124, 58, 237, 0.2)":"rgba(124, 58, 237, 0.1)"}`},"&::placeholder":{color:e.textMutedColor}})),J$=Hr.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),Z$=Hr(nn)({}),eU=Hr($n)({}),Sv=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=V$("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return jr.createElement(G$,{onClick:c=>{c.target===c.currentTarget&&a()}},jr.createElement(q$,null,jr.createElement(Y$,null,"Dismiss as False Positive"),jr.createElement(K$,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),jr.createElement(X$,{htmlFor:"dismiss-reason"},"Reason (optional)"),jr.createElement(Q$,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),jr.createElement(J$,null,jr.createElement(eU,{onClick:a},"Cancel"),jr.createElement(Z$,{onClick:s},"Dismiss Issue"))))};Ae();import ve from"react";import{styled as qe}from"storybook/theming";var Fe={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"},tU=qe.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),nU=qe.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),rU=qe.div({position:"relative",backgroundColor:Fe.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Xie=qe.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Fe.dash,padding:"0 8px",height:18,fontSize:11}),Qie=qe.div({position:"absolute",color:Fe.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Jie=qe.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%)"}})),Zie=qe.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}})),oU=qe.div(e=>({position:"relative",backgroundColor:e.isErr?Fe.errBg:Fe.borderBoxBg,border:`1px solid ${e.isErr?Fe.err:Fe.borderBoxStroke}`,borderRadius:6,padding:0})),iU=qe.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Fe.text}),sU=qe.span({fontWeight:500,fontSize:11}),ese=qe.span({color:Fe.dash}),aU=qe.div(e=>({position:"relative",backgroundColor:e.isErr?Fe.errBg:Fe.paddingBg,border:`1px solid ${e.isErr?Fe.err:Fe.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),lU=qe.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Fe.text,fontStyle:"italic"}),ic=qe.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Fe.err:Fe.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%)"}})),cU=qe.div(e=>({backgroundColor:e.isErr?Fe.errBg:"#fff",border:`1.5px dashed ${e.isErr?Fe.err:Fe.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Fe.err:Fe.text,fontWeight:e.isErr?600:400})),uU=qe.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Fe.dim,fontFamily:"monospace"}),pU=qe.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Fe.ok,padding:"4px 8px 6px"}),tse=qe.div({fontSize:11,fontWeight:600,color:Fe.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),nse=qe.span({fontSize:12,color:Fe.dim}),dU=qe.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),fU=qe.div({fontSize:9,color:Fe.dim,marginTop:2}),gU=({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}=ye(),p=r||{},d=!(!!r&&Object.keys(r).length>0)&&s?kU(n):null,h=p.padding||d||{top:0,right:0,bottom:0,left:0},S=p.strokeWeight??(a?Ai(n)??0:0),C=p.width??(u?vU(n)??"\u2014":"\u2014"),F=p.height??(u?CU(n)??"\u2014":"\u2014");return ve.createElement(ve.Fragment,null,ve.createElement(rU,null,ve.createElement(oU,{isErr:a},ve.createElement(iU,null,ve.createElement(sU,null,"Border"),ve.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Fe.err:Fe.dim}},S)),ve.createElement(aU,{isErr:s},ve.createElement(lU,null,"Padding"),ve.createElement(ic,{side:"top",isErr:s},h.top),ve.createElement(ic,{side:"right",isErr:s},h.right),ve.createElement(ic,{side:"bottom",isErr:s},h.bottom),ve.createElement(ic,{side:"left",isErr:s},h.left),ve.createElement(cU,{isErr:u,style:{flexDirection:"column",gap:4}},l&&ve.createElement(dU,{src:l,alt:"Figma element"}),ve.createElement(fU,null,C," \xD7 ",F)))),ve.createElement(uU,null,"border-box")),ve.createElement(pU,null,"\u2192 ",n))},wv=qe.div({backgroundColor:Fe.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),mU=qe.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),dm=qe.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Fe.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),hU=qe.div({position:"absolute",border:`1.5px dashed ${Fe.err}`,pointerEvents:"none",zIndex:0}),xU=qe.div({position:"absolute",border:`1.5px dashed ${Fe.blue}`,pointerEvents:"none",zIndex:0}),kv=qe.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%)"}})),rse=qe.div({fontSize:12,color:Fe.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),yU=qe.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),vv=qe.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Fe.err:Fe.ok})),bU=qe.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),Cv=qe.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),Tv=qe.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Fe.err:Fe.ok})),Iv=qe.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Fe.err:Fe.ok,textDecoration:e.variant==="err"?"line-through":"none"})),SU=qe.span({fontSize:16,color:Fe.dim,paddingBottom:20}),Fv=qe.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function Ev(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var wU=({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"),p=s||u,f=o.fontSize??(s?Ai(n):14),d=o.fontWeight??(a?Ai(n):600),S=(o.lineHeight??(u?Ai(n):null))||Math.round((f||14)*1.43),C=`${Math.min(Math.max(f||14,24),48)}px`;if(p)return ve.createElement(ve.Fragment,null,ve.createElement(wv,null,ve.createElement(mU,null,ve.createElement(xU,{style:{top:-6,left:0,right:0,bottom:-6}}),ve.createElement(hU,{style:{top:2,left:8,right:8,bottom:2}}),ve.createElement(kv,{color:s?Fe.err:"#7b3030",side:"left"},s?t:`${f}px`),ve.createElement(kv,{color:u?Fe.err:"#7b3030",side:"right"},u?t:`${S}px`),ve.createElement(dm,{fSize:C,fWeight:String(d||600)},"Ag")),ve.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},ve.createElement(Fv,{color:Fe.err},"\u2508\u2508 font-size",s?" \u2717":""),ve.createElement(Fv,{color:Fe.blue},"\u2508\u2508 line-height",u?" \u2717":"")),ve.createElement(yU,null,ve.createElement(vv,{variant:"err"},t),ve.createElement("span",{style:{color:Fe.dim}},"\u2192"),ve.createElement(vv,{variant:"ok"},n))));let F=a?t:String(d||600),T=a?n:F,R=Ai(t),z=Ai(n);return ve.createElement(ve.Fragment,null,ve.createElement(wv,null,ve.createElement(bU,null,ve.createElement(Cv,null,ve.createElement(Tv,{variant:"err"},"Current"),ve.createElement(dm,{fSize:C,fWeight:a?F:String(d||600),style:{color:Fe.err}},c?t:"Ag"),ve.createElement(Iv,{variant:"err"},a&&R?`${t} (${Ev(R)})`:t)),ve.createElement(SU,null,"\u2192"),ve.createElement(Cv,null,ve.createElement(Tv,{variant:"ok"},"Figma"),ve.createElement(dm,{fSize:C,fWeight:a?T:String(d||600),style:{color:Fe.ok}},c?n:"Ag"),ve.createElement(Iv,{variant:"ok"},a&&z?`${n} (${Ev(z)})`:n)))))};function kU(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 Ai(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function vU(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function CU(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var Av=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function TU(e){if(Av.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return Av.has(t)}var Pv=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=TU(e.property);return ve.createElement(tU,null,ve.createElement(nU,null,"\u25BE Layer properties",t?"":" (from review)"),n?ve.createElement(wU,{...e}):ve.createElement(gU,{...e}))};Ae();var Mv=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 EU(e){if(Mv.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return Mv.has(t)}var AU=pe.div(({theme:e,dismissed:t,fixApplied:n})=>({padding:"12px",borderRadius:"8px",border:t?`1px solid ${e.color.negative}`:n?`1px solid ${e.color.positive}`:`1px solid ${e.appBorderColor}`,backgroundColor:t?e.background.negative:n?e.background.positive:e.background.content,opacity:t?.7:n?.6:1,position:"relative"})),PU=pe.div({display:"flex",alignItems:"flex-start",gap:"8px"}),LU=pe.input(({theme:e})=>({marginTop:"1px",width:"14px",height:"14px",cursor:"pointer",accentColor:ue,flexShrink:0})),MU=pe.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"1px",display:"flex",alignItems:"center",color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor,"& svg":{width:"14px",height:"14px"}})),BU=pe.div({flex:1,minWidth:0,paddingRight:"60px"}),DU=pe.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.4"})),RU=pe.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),zU=pe.div(({theme:e,severity:t})=>{let r=(()=>{switch(t){case"critical":return{bg:e.background.negative,text:e.color.negative,border:e.color.negative};case"major":return{bg:e.background.warning,text:e.color.warning,border:e.color.warning};case"minor":return{bg:e.color.tertiary,text:ue,border:ue};default:return{bg:e.background.app,text:e.textMutedColor,border:e.appBorderColor}}})();return{fontSize:"10px",fontWeight:700,color:r.text,backgroundColor:r.bg,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${r.border}`,textTransform:"uppercase",letterSpacing:"0.5px"}}),NU=pe.div(({theme:e,status:t})=>{let r=(()=>{switch(t){case"pending":return{bg:e.background.app,text:e.textMutedColor,icon:"\u23F3"};case"applied":return{bg:e.color.tertiary,text:ue,icon:"\u{1F527}"};case"verified":return{bg:e.background.positive,text:e.color.positive,icon:"\u2705"};case"failed":return{bg:e.background.negative,text:e.color.negative,icon:"\u274C"};default:return{bg:e.background.app,text:e.textMutedColor,icon:"\u2753"}}})();return{fontSize:"10px",fontWeight:600,color:r.text,backgroundColor:r.bg,padding:"2px 8px",borderRadius:"10px",display:"flex",alignItems:"center",gap:"4px","&::before":{content:`"${r.icon}"`,fontSize:"10px"}}}),OU=pe.div(({theme:e})=>({fontSize:"10px",fontWeight:600,color:ue,backgroundColor:e.color.tertiary,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${ue}`})),_U=pe.div(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.color.positive,backgroundColor:e.background.positive,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${e.color.positive}`,display:"flex",alignItems:"center",gap:"3px","&::before":{content:'"\u{1F916}"',fontSize:"9px"}})),$U=pe.div(({theme:e})=>({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"}})),UU=pe.div(({theme:e})=>({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"}})),jU=pe.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),HU=pe.div(({theme:e})=>({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"}})),pse=pe.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),WU=pe.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"2px",fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"8px",marginLeft:"36px",padding:"8px 10px",backgroundColor:e.background.app,borderRadius:"4px"})),gm=pe.div({display:"flex",gap:"8px",alignItems:"baseline"}),mm=pe.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),xm=pe.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),VU=pe(xm)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),GU=pe(xm)(({theme:e})=>({color:e.color.positive,fontWeight:600})),Bv=pe.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"})),qU=pe.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),YU=pe.span(({theme:e,color:t})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundColor:t,border:`1px solid ${e.appBorderColor}`,marginRight:"6px",verticalAlign:"middle",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.1)"})),KU=pe.span({display:"flex",alignItems:"center"}),XU=pe.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginTop:"6px",marginLeft:"36px",fontStyle:"italic",display:"flex",alignItems:"baseline",gap:"4px","& strong":{fontStyle:"normal",fontWeight:600,color:"#7c3aed",fontSize:"10px"}})),QU=pe.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${ue}`})),JU=pe.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:ue,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),ZU=pe.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"}})),e4=pe.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),Dv=pe.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"})),t4=pe.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),hm=pe(cn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),n4=pe(hm)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),r4=pe.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}`})),o4=pe.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}`})),Rv=pe.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"})),i4=pe.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),s4=pe.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),a4=pe.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),l4=pe.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})),zv=pe.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),Nv=pe.details({marginBottom:"8px"}),Ov=pe.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),c4=pe.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"})),u4=pe.div({display:"flex",gap:"8px",marginTop:"8px"}),p4=pe(xr)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),d4=pe($n)({padding:"6px 12px",fontSize:"12px"}),dse=pe(nn)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),fse=pe.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),f4=pe.div({display:"flex",alignItems:"center",gap:"12px"}),g4=pe.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ue,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),m4=pe.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),gse=pe.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}}})),h4=pe.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"})),_v=pe.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"})),$v=pe.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}`})),Uv=pe.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),jv=pe.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)"}}),Hv=pe.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),Wv=e=>{let t=e.split(`
91
+ `),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},x4=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},y4=e=>{if(!e)return{};let t={};if(e.includes("+")){let n=e.split("+");for(let r of n)if(r.startsWith("programmatic-")){let o=r.replace("programmatic-","").replace("-detection","");t.programmatic=o}else r==="ai"||r==="ai-review"?t.ai="AI Review":r==="ai-validation"&&(t.ai="AI Validation");return t}if(e.startsWith("programmatic-")){let n=e.replace("programmatic-","").replace("-detection","");t.programmatic=n}else e==="ai-review"?t.ai="AI Review":e==="ai-validation"&&(t.ai="AI Validation");return t},b4=e=>({"claude-sonnet-4-5-20250929":"Sonnet 4.5","claude-sonnet-4-20250514":"Sonnet 4","claude-sonnet-3-5-20240620":"Sonnet 3.5","claude-3-opus-20240229":"Opus 3","gpt-5":"GPT-5","gpt-5-mini":"GPT-5 Mini","gpt-5.2-chat-latest":"GPT-5.2 Instant","gpt-4o":"GPT-4o"})[e]||e,S4=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},w4=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",Vv=({value:e,isStrikethrough:t=!1})=>{let n=S4(e),r=w4(e),o=t?VU:GU;return n?H.createElement(KU,null,H.createElement(YU,{color:n}),H.createElement(o,null,r)):H.createElement(o,null,r)},Gv=FU(({issue:e,modelId:t,onToggleSelection:n,onDismiss:r,onUndismiss:o,onApplyFix:i,onRegenerateFix:s})=>{let{featureFlags:a,setHoveredIssueId:u}=ye(),[c,l]=fm(!1),[p,f]=fm(!1),[d,h]=fm(!1),S=IU(null),C=Lv(()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{u(e.id),h(!0)},100)},[e.id,u]),F=Lv(()=>{S.current&&clearTimeout(S.current),S.current=null,u(null),h(!1)},[u]),T=()=>{e.dismissed?o(e.id):l(!0)},R=E=>{r(e.id,E),l(!1)},z=async()=>{let E=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&E.push(`Property: ${e.property}`),e.currentValue&&E.push(`Current: ${e.currentValue}`),e.suggestedValue&&E.push(`Expected: ${e.suggestedValue}`),e.file&&E.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&E.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&E.push(`
92
+ Suggested code:
93
+ \`\`\`
94
+ ${e.suggestedCode}
95
+ \`\`\``),e.generatedFix){let g=e.generatedFix;if(E.push(`
96
+ --- AI-Generated Fix ---`),E.push(`Status: ${g.status}`),g.confidence!==void 0){let k=g.confidence>1?g.confidence:Math.round(g.confidence*100);E.push(`Confidence: ${k}%`)}g.strategy&&E.push(`Strategy: ${g.strategy}`),g.filePath&&E.push(`Target file: ${g.filePath}`),g.code&&E.push(`
97
+ Generated code:
98
+ \`\`\`
99
+ ${g.code}
100
+ \`\`\``),g.diffPreview&&E.push(`
101
+ Diff:
102
+ \`\`\`diff
103
+ ${g.diffPreview}
104
+ \`\`\``),g.error&&E.push(`Error: ${g.error}`)}let M=E.filter(Boolean).join(`
105
+ `);try{await navigator.clipboard.writeText(M),f(!0),setTimeout(()=>f(!1),2e3)}catch(g){console.error("Failed to copy:",g)}},N=e.generatedFix?.status==="applied";return H.createElement(H.Fragment,null,H.createElement(AU,{dismissed:!!e.dismissed,fixApplied:N,onMouseEnter:C,onMouseLeave:F},H.createElement(t4,null,H.createElement(hm,{onClick:z,title:"Copy issue details"},p?H.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("polyline",{points:"20 6 9 17 4 12"})):H.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),H.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))),e.dismissed?H.createElement(hm,{onClick:T,title:"Restore issue"},H.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("polyline",{points:"1 4 1 10 7 10"}),H.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"}))):H.createElement(n4,{onClick:T,title:"Dismiss issue"},H.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),H.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),H.createElement(PU,null,H.createElement(LU,{type:"checkbox",checked:e.selectedForFix,onChange:()=>n(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),H.createElement(MU,{severity:e.severity},e.severity==="critical"?H.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("circle",{cx:"12",cy:"12",r:"10"}),H.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),H.createElement("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})):e.severity==="major"?H.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},H.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"}),H.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),H.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):H.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("circle",{cx:"12",cy:"12",r:"10"}),H.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),H.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),H.createElement(BU,null,H.createElement(DU,null,e.title),H.createElement(RU,null,H.createElement(zU,{severity:e.severity},e.severity),H.createElement(NU,{status:e.status},e.status),H.createElement(OU,null,e.type),H.createElement(_U,null,b4(t)),(()=>{let E=y4(e.detectedBy);return E.ai||E.programmatic?H.createElement(jU,null,E.ai&&H.createElement(UU,null,E.ai),E.programmatic&&H.createElement($U,null,"Pre-filter: ",E.programmatic)):null})(),e._unreliable&&H.createElement(HU,{title:e._validationError?.message},"Unreliable"),e.dismissed&&H.createElement(r4,null,"Dismissed")))),e.property&&H.createElement(WU,null,H.createElement(gm,null,H.createElement(mm,null,"Property"),H.createElement(xm,{style:{fontWeight:600}},e.property)),e.currentValue&&H.createElement(gm,null,H.createElement(mm,null,"Current"),H.createElement(Vv,{value:e.currentValue,isStrikethrough:!0})),e.suggestedValue&&H.createElement(gm,null,H.createElement(mm,null,"Expected"),H.createElement(Vv,{value:e.suggestedValue,isStrikethrough:!1}))),d&&e.property&&e.currentValue&&e.suggestedValue&&EU(e.property)&&H.createElement(Pv,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&H.createElement(XU,null,H.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&H.createElement(QU,null,H.createElement(JU,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((E,M)=>H.createElement(ZU,{key:`${E.property}-${M}`},H.createElement(e4,null,E.property),H.createElement(Dv,{type:"current"},E.currentValue),H.createElement(Dv,{type:"suggested"},E.suggestedValue)))),e.suggestedCode&&H.createElement(H.Fragment,null,(e.suggestedCode.includes("<svg")||e.suggestedCode.includes("&lt;svg"))&&H.createElement("div",{style:{margin:"8px 0 4px 0",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center"},dangerouslySetInnerHTML:{__html:(()=>{let E=e.suggestedCode||"";return E.includes("&lt;svg")&&(E=E.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"')),E.split(/(?=<svg[\s>])/gi).filter(M=>M.trim().match(/^<svg/i)).map(M=>{let g=M.match(/<svg[\s\S]*?<\/svg>/i);return g?`<div style="background:#f1f5f9;border:1px solid #e2e8f0;border-radius:6px;padding:10px;display:inline-flex;align-items:center;justify-content:center">${g[0].replace(/stroke="white"/gi,'stroke="#334155"').replace(/stroke="#ffffff"/gi,'stroke="#334155"').replace(/stroke="#fff"/gi,'stroke="#334155"').replace(/fill="white"/gi,'fill="#f8fafc"')}</div>`:""}).join("")})()}}),(()=>{let E=e.suggestedCode||"";if(!(E.includes("<svg")||E.includes("&lt;svg")))return H.createElement(Bv,null,E);let g=E.replace(/<svg[\s\S]*?<\/svg>/gi,"").replace(/SVG \d+:/g,"").trim();return g?H.createElement(Bv,null,g):null})()),(e.generatedFix?.filePath||e.file)&&H.createElement(qU,null,e.generatedFix?.filePath||e.file,!e.generatedFix?.filePath&&e.lineNumber!==void 0&&`:${e.lineNumber}`),e.dismissed&&H.createElement(o4,null,H.createElement("strong",null,"Filtered by:")," ",x4(e.dismissedBy),e.dismissReason&&H.createElement(H.Fragment,null,H.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&H.createElement(Rv,null,H.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&H.createElement(i4,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?H.createElement(f4,{style:{margin:0}},H.createElement(g4,null),H.createElement(m4,{style:{margin:0}},"Generating fix...")):H.createElement(H.Fragment,null,H.createElement(s4,null,H.createElement(a4,null,"AI-Generated Fix"),H.createElement(l4,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&H.createElement(zv,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&H.createElement(zv,{style:{color:"#6b7280",fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?H.createElement(Nv,null,H.createElement(Ov,null,"View Diff"),H.createElement(h4,null,H.createElement(_v,{side:"old"},H.createElement($v,{side:"old"},"Old"),H.createElement(Uv,null,Wv(e.generatedFix.diffPreview).map((E,M)=>H.createElement(jv,{key:`old-${M}`,type:E.oldLine.type},E.oldLine.content||"\xA0")))),H.createElement(_v,{side:"new"},H.createElement($v,{side:"new"},"New"),H.createElement(Uv,null,Wv(e.generatedFix.diffPreview).map((E,M)=>H.createElement(jv,{key:`new-${M}`,type:E.newLine.type},E.newLine.content||"\xA0")))))):e.generatedFix.code&&H.createElement(Nv,null,H.createElement(Ov,null,"View Generated Code"),H.createElement(c4,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&H.createElement(Rv,null,H.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&a.enableFixApply&&i&&H.createElement(u4,null,H.createElement(p4,{onClick:()=>i(e.id)},"Apply Fix"),s&&H.createElement(d4,{onClick:()=>s(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&H.createElement(Hv,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&H.createElement(Hv,{status:"applied"},"\u2713 Fix applied successfully")))),H.createElement(Sv,{isOpen:c,issueTitle:e.title,onConfirm:R,onCancel:()=>l(!1)}))});import ym from"react";import{styled as bm,keyframes as k4}from"storybook/theming";var v4=k4`
106
+ 0% { transform: rotate(0deg); }
107
+ 100% { transform: rotate(360deg); }
108
+ `,C4=bm.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),T4=bm.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${v4} 0.8s linear infinite`})),I4=bm.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),sc=({label:e="Loading..."})=>ym.createElement(C4,null,ym.createElement(T4,null),ym.createElement(I4,null,e));Ae();var L4=Xe.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}})),M4=Xe.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:ue})),B4=Xe.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),D4=Xe.div({display:"flex",gap:"8px"}),qv=Xe(mn)({flex:1}),R4=Xe.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}})),z4=Xe.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),N4=Xe.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"}})),O4=Xe.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",padding:"12px",display:"flex",flexDirection:"column",gap:"8px"})),_4=Xe.div({display:"flex",alignItems:"center",gap:"2px"}),ac=Xe(cn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Sm=Xe.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),$4=Xe.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Fse=Xe.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),xo=Xe.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:ue};case"selected":return{bg:e.color.tertiary,text:ue};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:ue};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"}}),U4=Xe.div({display:"flex",flexDirection:"column",gap:"8px"}),Yv=Xe.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),Kv=Xe.div({fontSize:"36px",marginBottom:"12px"}),Xv=Xe.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),Qv=Xe.div({fontSize:"12px"}),j4=P4`
109
+ 0% {
110
+ transform: translateY(0) rotate(0deg) scale(1);
111
+ opacity: 1;
112
+ }
113
+ 50% {
114
+ opacity: 1;
115
+ }
116
+ 100% {
117
+ transform: translateY(120px) rotate(720deg) scale(0.3);
118
+ opacity: 0;
119
+ }
120
+ `;var Ese=Xe.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Ase=Xe.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:`${j4} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var H4=Xe.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}}})),W4=Xe(cn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),Jv=Xe.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),Zv=Xe(xr)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),eC=Xe(nn)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),tC=Xe(nn)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),V4=Xe.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}}),G4=Xe.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),q4=Xe.span(({confidence:e})=>{let t=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:t,fontSize:"11px",fontWeight:700}}),Y4=Xe.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),K4=Xe.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),lc=Xe.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),cc=Xe.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),X4=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},nC=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:p,onSelectNone:f,onSelectAllFixes:d,onApplyFixes:h,onApplyFix:S,onCopyAllFixes:C,onGenerateFixes:F,onDismiss:T,onUndismiss:R,isGenerating:z=!1,isApplying:N=!1,isCopying:E=!1,applyFixesResult:M,onDismissResult:g,generationTiming:k,generationUsage:w,generationProgress:A,autoApplySupported:m=!0,hasReviewBeenRun:v=!1,isLoadingReview:I=!1,selfReview:x})=>{let[P,L]=G.useState("all"),[D,O]=G.useState("all"),[y,U]=G.useState(!1),[V,B]=G.useState(!0),{includeComponentIssues:X,setIncludeComponentIssues:ee,featureFlags:Q}=ye(),Ee=G.useRef(null),[Te,We]=E4(0);A4(()=>{if(!z){We(0);return}let le=setInterval(()=>We(yt=>yt+1),1e3);return()=>clearInterval(le)},[z]);let ot=async()=>{let le=j.map($=>{let W=[`[${$.severity.toUpperCase()}] ${$.title||$.description}`,`Status: ${$.status}`,$.description&&$.description!==$.title?`Description: ${$.description}`:"",$.property?`Property: ${$.property}`:"",$.currentValue?`Current: ${$.currentValue}`:"",$.suggestedValue?`Expected: ${$.suggestedValue}`:"",$.file?`File: ${$.file}${$.lineNumber!==void 0?`:${$.lineNumber}`:""}`:"",$.suggestedCode?`Suggested code: ${$.suggestedCode}`:""];if($.generatedFix){let Z=$.generatedFix;if(W.push(""),W.push("--- AI-Generated Fix ---"),W.push(`Fix Status: ${Z.status}`),Z.confidence!==void 0){let Ze=Z.confidence>1?Z.confidence:Math.round(Z.confidence*100);W.push(`Confidence: ${Ze}%`)}Z.strategy&&W.push(`Strategy: ${Z.strategy}`),Z.filePath&&W.push(`Target file: ${Z.filePath}`),Z.code&&W.push(`Generated code:
121
+ ${Z.code}`),Z.diffPreview&&W.push(`Diff:
122
+ ${Z.diffPreview}`),Z.error&&W.push(`Error: ${Z.error}`)}return W.push(""),W.filter(Boolean).join(`
123
+ `)}).join(`
124
+ ---
125
+
126
+ `),yt=j.filter($=>$.generatedFix?.status==="applied").length,fr=j.filter($=>$.generatedFix?.status==="ready").length,se=yt>0||fr>0?` | Fixes: ${yt} applied, ${fr} ready`:"",Ye=r!==void 0?` | Similarity: ${r}%`:"",_=`Score: ${n}/100${Ye} | ${j.length} issues${se}
127
+
128
+ `;try{await navigator.clipboard.writeText(_+le),U(!0),setTimeout(()=>U(!1),2e3)}catch($){console.error("Failed to copy:",$)}};G.useEffect(()=>{M&&Ee.current&&Ee.current.scrollIntoView({behavior:"smooth",block:"start"})},[M]);let j=F4(()=>e.filter(le=>{let yt=P==="all"||le.severity===P,fr=D==="all"||le.status===D,se=X||!X4(le);return yt&&fr&&se}),[e,P,D,X]),ie=()=>{j.forEach(le=>{le.selectedForFix||l(le.id)})},re=()=>{j.forEach(le=>{le.selectedForFix&&l(le.id)})},he=()=>{j.forEach(le=>{le.generatedFix&&le.generatedFix.status==="ready"&&!le.selectedForFix&&l(le.id)})},de=j.filter(le=>le.selectedForFix).length,$e=j.filter(le=>le.severity==="critical").length,it=j.filter(le=>le.severity==="major").length,Ot=j.filter(le=>le.severity==="minor").length,zn=j.filter(le=>le.generatedFix&&le.generatedFix.status==="ready").length,Qe=j.filter(le=>le.selectedForFix&&le.generatedFix&&le.generatedFix.status==="ready").length;return e.length===0?I?G.createElement(sc,{label:"Loading review..."}):G.createElement(Yv,null,G.createElement(Kv,null,v?"\u2728":"\u{1F441}\uFE0F"),G.createElement(Xv,null,v?"No issues found":"No review yet"),G.createElement(Qv,null,v?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):G.createElement(B4,{"data-testid":"issues-panel"},G.createElement(D4,null,G.createElement(qv,{value:P,onChange:le=>L(le.target.value)},G.createElement("option",{value:"all"},"All Severities"),G.createElement("option",{value:"critical"},"Critical Only"),G.createElement("option",{value:"major"},"Major Only"),G.createElement("option",{value:"minor"},"Minor Only")),G.createElement(qv,{value:D,onChange:le=>O(le.target.value)},G.createElement("option",{value:"all"},"All Statuses"),G.createElement("option",{value:"pending"},"Pending"),G.createElement("option",{value:"applied"},"Applied"),G.createElement("option",{value:"verified"},"Verified"),G.createElement("option",{value:"failed"},"Failed"))),G.createElement("div",null,G.createElement(R4,{isOpen:V,onClick:()=>B(!V)},G.createElement(z4,null,G.createElement(N4,{isOpen:V},G.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},G.createElement("polyline",{points:"6 9 12 15 18 9"}))),G.createElement($4,null,j.length," issues"),G.createElement(L4,{onClick:le=>le.stopPropagation()},G.createElement(M4,{type:"checkbox",checked:X,onChange:le=>ee(le.target.checked)}),"+ TSX"),G.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},$e>0&&G.createElement(Sm,{variant:"critical"},$e," critical"),it>0&&G.createElement(Sm,{variant:"major"},it," major"),Ot>0&&G.createElement(Sm,{variant:"minor"},Ot," minor"))),G.createElement(_4,{onClick:le=>le.stopPropagation()},G.createElement(ac,{onClick:ie},"All"),G.createElement(ac,{onClick:re},"None"),G.createElement(ac,{onClick:ot},y?"\u2713":"\u2398"," Copy"),zn>0&&G.createElement(ac,{onClick:he},"Fixes (",zn,")"))),M&&G.createElement(H4,{ref:Ee,variant:M.error||M.failed>0?"warning":"success"},M.error?G.createElement(G.Fragment,null,M.error):M.failed>0?G.createElement(G.Fragment,null,"Applied ",M.succeeded,"/",M.total," fixes. ",M.failed," failed. Run a new review to verify."):G.createElement(G.Fragment,null,"Applied ",M.total," fix",M.total!==1?"es":"","! Run a new review to verify changes."),g&&G.createElement(W4,{onClick:g},"\u2715")),de>0&&G.createElement(Jv,null,k&&G.createElement(xo,{variant:"timing"},k.durationSec,"s (",k.issueCount," fixes)"),w&&G.createElement(G.Fragment,null,G.createElement(xo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),G.createElement(xo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"# ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),G.createElement(xo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),Q.enableFixGeneration&&F&&G.createElement(tC,{disabled:z||N||E,onClick:F},G.createElement("span",null,"\u{1F916}"),z&&A?`Generating ${A.completed}/${A.total}... (${Te}s)`:z?`Generating... (${Te}s)`:`Generate Fixes for ${de} Issue${de>1?"s":""}`),Q.enableFixApply&&m&&h&&G.createElement(Zv,{disabled:z||N||Qe===0,onClick:h},N?"Applying...":z?"Generating...":Qe>0?`Apply ${Qe} Ready Fix${Qe>1?"es":""}`:"Apply Fixes (generate first)"),Q.enableFixApply&&!m&&C&&G.createElement(eC,{disabled:z||E||Qe===0,copied:E,onClick:C},E?"Copied!":Qe>0?`Copy ${Qe} Fix${Qe>1?"es":""}`:"Copy Fixes (generate first)")),x&&!z&&G.createElement(V4,{confidence:x.overallConfidence},G.createElement(G4,null,G.createElement(Y4,null,"AI Self-Review"),G.createElement(q4,{confidence:x.overallConfidence},x.wouldReachPerfect?"\u2713":"\u25B3"," ",x.overallConfidence,"% confidence")),G.createElement(K4,null,x.variantSafety&&G.createElement(lc,null,G.createElement(cc,null,"Variant safety: "),x.variantSafety),x.gaps.length>0&&G.createElement(lc,null,G.createElement(cc,null,"Gaps: "),G.createElement("ul",null,x.gaps.map((le,yt)=>G.createElement("li",{key:yt},le)))),!x.wouldReachPerfect&&x.reasonsNotPerfect.length>0&&G.createElement(lc,null,G.createElement(cc,null,"Why not 100%: "),G.createElement("ul",null,x.reasonsNotPerfect.map((le,yt)=>G.createElement("li",{key:yt},le)))),x.suggestions&&x.suggestions.length>0&&G.createElement(lc,null,G.createElement(cc,null,"Suggestions: "),G.createElement("ul",null,x.suggestions.map((le,yt)=>G.createElement("li",{key:yt},le)))))),V&&G.createElement(O4,null,j.length===0?G.createElement(Yv,null,G.createElement(Kv,null,"\u{1F50D}"),G.createElement(Xv,null,"No issues match current filters"),G.createElement(Qv,null,"Try adjusting your severity or status filters")):G.createElement(U4,null,j.map(le=>G.createElement(Gv,{key:le.id,issue:le,modelId:t,onToggleSelection:l,onDismiss:T,onUndismiss:R,onApplyFix:S}))))),de>0&&G.createElement(Jv,null,k&&G.createElement(xo,{variant:"timing"},k.durationSec,"s (",k.issueCount," fixes)"),w&&G.createElement(G.Fragment,null,G.createElement(xo,{variant:"cost"},"$",w.costUsd.toFixed(3)," / \u20AA",(w.costUsd*3.65).toFixed(2)),G.createElement(xo,{variant:"tokens",title:`Input: ${w.inputTokens.toLocaleString()} \xB7 Output: ${w.outputTokens.toLocaleString()}`},"# ",((w.inputTokens+w.outputTokens)/1e3).toFixed(1),"K"),G.createElement(xo,{variant:"model",title:w.modelId},w.modelId.replace("claude-","").replace(/-\d{8}$/,""))),Q.enableFixGeneration&&F&&G.createElement(tC,{disabled:z||N||E,onClick:F},G.createElement("span",null,"\u{1F916}"),z&&A?`Generating ${A.completed}/${A.total}... (${Te}s)`:z?`Generating... (${Te}s)`:`Generate Fixes for ${de} Issue${de>1?"s":""}`),Q.enableFixApply&&m&&h&&G.createElement(Zv,{disabled:z||N||Qe===0,onClick:h},N?"Applying...":z?"Generating...":Qe>0?`Apply ${Qe} Ready Fix${Qe>1?"es":""}`:"Apply Fixes (generate first)"),Q.enableFixApply&&!m&&C&&G.createElement(eC,{disabled:z||E||Qe===0,copied:E,onClick:C},E?"Copied!":Qe>0?`Copy ${Qe} Fix${Qe>1?"es":""}`:"Copy Fixes (generate first)")))};Pe();var Q4=ht.div({display:"flex",flexDirection:"column"}),J4=ht.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),Z4=ht.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),wm=ht.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:ue}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),e3=ht.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),Ose=ht.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),_se=ht.div({fontSize:"48px",marginBottom:"16px"}),$se=ht.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),Use=ht.div({fontSize:"14px",opacity:.8}),t3=ht.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),n3=ht.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),r3=ht(cn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),o3=ht($n)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),i3=ht.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),s3=ht.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),a3=ht.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),l3=ht.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),c3=ht.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),u3=ht.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}})),p3=ht.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),d3=e=>{if(!e)return"Other";let t=e.toLowerCase();return t.includes("hug")||t.includes("fill")||t.includes("content-driven")?"HUG/FILL Sizing":t.includes("sub-pixel")||t.includes("negligible")?"Sub-pixel Differences":t.includes("values match")||t.includes("values already match")||t.includes("identical")?"Values Match":t.includes("no fix needed")||t.includes("no changes needed")?"No Fix Needed":"Other"},rC=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},f3=ht.span(({theme:e,phase:t})=>{let n={"post-ai-validation":{bg:"#4b5563",text:"#ffffff"},"ai-validation":{bg:"#7c3aed",text:"#ffffff"},user:{bg:"#7c3aed",text:"#ffffff"}},{bg:r,text:o}=n[t]||n.user;return{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",fontWeight:600,color:o,backgroundColor:r,padding:"3px 10px",borderRadius:"10px",marginBottom:"8px"}}),g3=ht.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"}})),vm=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"},m3=(e,t)=>{switch(e||vm(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},oC=(e,t)=>{switch(e||vm(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";case"user":return"Manual";default:return"Auto"}},h3=ht.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),x3=ht.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),y3=ht.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"})),b3=ht(Vm)({marginTop:"12px"}),km=class extends Ne.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){b.error("[IssuesPanel ErrorBoundary] Caught error:",n,r)}render(){return this.state.hasError?Ne.createElement(h3,null,Ne.createElement(x3,null,"\u26A0\uFE0F Issues Panel Error"),Ne.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),Ne.createElement(y3,null,this.state.error?.message||"Unknown error",`
129
+
130
+ `,this.state.error?.stack),Ne.createElement(b3,{onClick:this.handleReset},"Try Again")):this.props.children}},iC=()=>{let{currentStoryId:e}=Ge(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,dismissIssue:i,undismissIssue:s,applyFixesResult:a,setApplyFixesResult:u}=ye(),c=r.some(se=>se.storyId===e||se.componentId===e),{loadingMapping:l}=Ge(),p=!!e&&!t&&!n&&(l||!c),[f,d]=Ne.useState(!1),[h,S]=Ne.useState(!1),[C,F]=Ne.useState(!1),{isSupported:T,isDetecting:R}=mf(),{refreshStorybookOnly:z}=ko(),{generateBatchFixes:N,isGenerating:E,error:M,timing:g,progress:k,usage:w,selfReview:A,lastStorybookRoot:m}=pf(),{applyFixes:v,isApplying:I}=uf({onComplete:z,storybookRoot:m}),x=r.find(se=>se.id===t),P=x?.issues||[],L=Ne.useMemo(()=>P.filter(se=>!se.dismissed),[P]),D=Ne.useMemo(()=>P.filter(se=>se.dismissed),[P]),O=Ne.useMemo(()=>{let se={postAiValidation:0,aiValidation:0,user:0};for(let Ye of D)switch(Ye.dismissedBy){case"post-ai-validation":se.postAiValidation++;break;case"ai-validation":se.aiValidation++;break;default:se.user++;break}return se},[D]),y=L,U=x?.modelId||"unknown",V=L.filter(se=>se.severity==="critical").length,B=L.filter(se=>se.severity==="major").length,X=L.filter(se=>se.severity==="minor").length,ee=x?L.length===0?100:Math.max(0,Math.min(100,100-V*25-B*5-X*1)):void 0,Q=x?.visualSimilarity,Ee=x?.costUsd,Te=x?.reviewDurationMs,We=x?.inputTokens,ot=x?.outputTokens,j=x?.cacheCreationTokens,ie=x?.cacheReadTokens,re=x?.parentReviewId?r.find(se=>se.id===x.parentReviewId):null,he=Ne.useMemo(()=>{if(!re||!x)return null;let se=new Set(re.issues.map(Z=>`${Z.type}:${Z.property||""}:${Z.description}`)),Ye=new Set(y.map(Z=>`${Z.type}:${Z.property||""}:${Z.description}`)),_=re.issues.filter(Z=>!Ye.has(`${Z.type}:${Z.property||""}:${Z.description}`)).length,$=y.filter(Z=>se.has(`${Z.type}:${Z.property||""}:${Z.description}`)).length,W=y.filter(Z=>!se.has(`${Z.type}:${Z.property||""}:${Z.description}`)).length;return{resolved:_,remaining:$,newIssues:W}},[re,x,y]),de=()=>{y.forEach(se=>{se.selectedForFix||o(se.id)})},$e=()=>{y.forEach(se=>{se.selectedForFix&&o(se.id)})},it=()=>{y.forEach(se=>{se.generatedFix&&se.generatedFix.status==="ready"&&!se.selectedForFix&&o(se.id)})},{featureFlags:Ot}=ye(),zn=()=>{if(!Ot.enableFixGeneration){b.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let se=y.filter(Ye=>Ye.selectedForFix);if(se.length===0){b.warn("[IssuesPanel] No issues selected for fix generation");return}b.debug(`[IssuesPanel] Generating fixes for ${se.length} issue(s)`,se),N(se)},Qe=()=>{if(!Ot.enableFixApply){b.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let se=y.filter(_=>_.selectedForFix&&_.generatedFix&&_.generatedFix.status==="ready"&&_.generatedFix.code&&_.generatedFix.filePath);if(se.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Ye=se.map(_=>({id:_.id,reviewId:_.reviewId,type:_.type,severity:_.severity,title:_.title,description:_.description,generatedFix:_.generatedFix,storyId:x?.storyId||""}));b.debug(`[IssuesPanel] Applying AI-generated fixes for ${Ye.length} issue(s)`,Ye),v(Ye)},le=se=>{let Ye=y.find($=>$.id===se);if(!Ye){b.warn("[IssuesPanel] Issue not found:",se);return}if(!Ye.generatedFix||Ye.generatedFix.status!=="ready"||!Ye.generatedFix.code||!Ye.generatedFix.filePath){b.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",se);return}let _={id:Ye.id,reviewId:Ye.reviewId,type:Ye.type,severity:Ye.severity,title:Ye.title,description:Ye.description,generatedFix:Ye.generatedFix,storyId:x?.storyId||""};b.debug("[IssuesPanel] Applying single AI-generated fix for issue:",_),v([_])},yt=async()=>{let se=y.filter(_=>_.selectedForFix&&_.generatedFix&&_.generatedFix.status==="ready"&&_.generatedFix.code&&_.generatedFix.filePath);if(se.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Ye=se.map(_=>{let $=_.generatedFix,W=[];return W.push(`// File: ${$.filePath}`),W.push(`// Issue: ${_.title||_.description}`),_.currentValue&&W.push(`// Actual: ${_.currentValue}`),_.suggestedValue&&W.push(`// Expected (Figma): ${_.suggestedValue}`),$.diffPreview&&(W.push("//"),W.push("// Diff:"),$.diffPreview.split(`
131
+ `).forEach(Z=>{W.push(`// ${Z}`)})),W.push("//"),W.push("// Full Fixed Code:"),W.push($.code),W.join(`
132
+ `)}).join(`
133
+
134
+ `+"=".repeat(60)+`
135
+
136
+ `);S(!0);try{await hf(Ye)?b.debug(`[IssuesPanel] Copied ${se.length} fix(es) to clipboard`):b.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>S(!1),1500)}catch(_){b.error("[IssuesPanel] Error copying fixes:",_),S(!1)}},fr=async se=>{se.stopPropagation();let Ye=D.map($=>[`[${$.severity.toUpperCase()}] ${$.title||$.description}`,`Phase: ${oC($.dismissedBy,$.dismissReason)}`,$.dismissReason?`Reason: ${rC($.dismissReason)}`:"",$.property?`Property: ${$.property}`:"",$.currentValue?`Current: ${$.currentValue}`:"",$.suggestedValue?`Expected: ${$.suggestedValue}`:""].filter(Boolean).join(`
137
+ `)).join(`
138
+
139
+ ---
140
+
141
+ `),_=`Filtered Issues (${D.length})
142
+ ${"=".repeat(40)}
143
+
144
+ `;try{await navigator.clipboard.writeText(_+Ye),F(!0),setTimeout(()=>F(!1),2e3)}catch($){b.error("Failed to copy dismissed issues:",$)}};return Ne.createElement(Q4,null,he&&Ne.createElement(J4,null,Ne.createElement(Z4,null,"\u{1F4CA} Progress:"),Ne.createElement(wm,{variant:"resolved"},"\u2705 ",he.resolved," resolved"),Ne.createElement(wm,{variant:"remaining"},"\u23F3 ",he.remaining," remaining"),he.newIssues>0&&Ne.createElement(wm,{variant:"new"},"\u{1F195} ",he.newIssues," new"),Ne.createElement(e3,null,"Iteration ",x?.iterationNumber||1)),Ne.createElement(km,null,Ne.createElement(nC,{issues:y,modelId:U,complianceScore:ee,visualSimilarity:Q,costUsd:Ee,reviewDurationMs:Te,inputTokens:We,outputTokens:ot,cacheCreationTokens:j,cacheReadTokens:ie,onToggleSelection:o,onSelectAll:de,onSelectNone:$e,onSelectAllFixes:it,onGenerateFixes:zn,onApplyFixes:Qe,onApplyFix:le,onCopyAllFixes:yt,onDismiss:i,onUndismiss:s,isGenerating:E,isApplying:I,isCopying:h,applyFixesResult:a,onDismissResult:()=>u(null),generationTiming:g,generationUsage:w,hasReviewBeenRun:!!x,isLoadingReview:p,generationProgress:k,autoApplySupported:T,selfReview:A})),D.length>0&&Ne.createElement(t3,null,Ne.createElement(n3,null,Ne.createElement(r3,{onClick:()=>d(!f)},Ne.createElement("span",null,f?"\u25BC":"\u25B6"),Ne.createElement("span",null,"Filtered out"),Ne.createElement(i3,null,D.length),Ne.createElement(g3,null,O.postAiValidation>0&&Ne.createElement("span",null,"\u2699\uFE0F ",O.postAiValidation),O.aiValidation>0&&Ne.createElement("span",null,"\u2726 ",O.aiValidation),O.user>0&&Ne.createElement("span",null,"\u{1F464} ",O.user))),Ne.createElement(o3,{onClick:fr},C?"\u2713 Copied!":"Copy")),f&&Ne.createElement(s3,null,(()=>{let se=D.reduce(($,W)=>{let Z=d3(W.dismissReason);return $[Z]||($[Z]=[]),$[Z].push(W),$},{}),Ye=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(se).sort(($,W)=>Ye.indexOf($)-Ye.indexOf(W)).map($=>Ne.createElement(Ne.Fragment,{key:$},Ne.createElement(u3,null,$,Ne.createElement(p3,null,se[$].length)),se[$].map(W=>Ne.createElement(a3,{key:W.id},Ne.createElement(f3,{phase:W.dismissedBy||vm(W.dismissReason)||"post-ai-validation"},m3(W.dismissedBy,W.dismissReason)," ",oC(W.dismissedBy,W.dismissReason)),Ne.createElement(l3,null,"[",W.severity.toUpperCase(),"] ",W.title||W.description),W.dismissReason&&Ne.createElement(c3,null,rC(W.dismissReason))))))})())))};var S3=qs.div({marginTop:"20px"}),w3=qs.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),k3=qs.div({display:"flex",alignItems:"center"}),Cm=qs(Vr)({padding:"10px 16px"}),v3=qs.div({minHeight:"200px"}),Tm=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r}=ye(),o=r.length>1||n&&Object.keys(n.byModel).length>1;return dr.createElement(S3,null,dr.createElement(w3,null,dr.createElement(k3,null,dr.createElement(Cm,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),dr.createElement(Cm,{active:e==="chat",onClick:()=>t("chat")},o?"Models":"Chat"),dr.createElement(Cm,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),dr.createElement(v3,null,e==="chat"&&(o?dr.createElement(bv,null):dr.createElement(pm,null)),e==="issues"&&dr.createElement(iC,null),e==="prompt"&&dr.createElement(um,null)))};Ae();Ue();import te,{useState as Ks,useRef as Em,useMemo as F3}from"react";import{styled as dt}from"storybook/theming";Pe();var uc={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},Ys="uicopilot_feature_flags";function Im(){try{let e=localStorage.getItem(Ys);if(e){let t=JSON.parse(e);return{...uc,...t}}}catch(e){b.warn("[FeatureFlags] Failed to load from localStorage:",e)}return uc}function C3(e,t){try{let r={...Im(),[e]:t},o={};for(let i in r){let s=i;r[s]!==uc[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(Ys,JSON.stringify(o)):localStorage.removeItem(Ys),b.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){b.error("[FeatureFlags] Failed to set flag:",n)}}function T3(){try{localStorage.removeItem(Ys),b.debug("[FeatureFlags] Reset to defaults")}catch(e){b.error("[FeatureFlags] Failed to reset:",e)}}function Fm(e){return Im()[e]}function I3(){let e=Object.keys(uc).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(Ys,JSON.stringify(e)),b.debug("[FeatureFlags] All features enabled! Reload to apply.")}catch(t){b.error("[FeatureFlags] Failed to enable all features:",t)}}typeof window<"u"&&(window.uicopilot={...window.uicopilot,featureFlags:{get:Im,set:C3,reset:T3,enableAll:I3,isEnabled:Fm}});Pe();var Xs=dt.div({marginTop:"20px"}),Am=dt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Pm=dt.div({display:"flex",alignItems:"center",gap:"12px"}),Qs=dt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),E3=dt.div({display:"flex",gap:"8px"}),sC=dt.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}})),aC=dt.div(({layout:e})=>({display:e==="side-by-side"?"grid":"flex",gridTemplateColumns:e==="side-by-side"?"1fr 1fr":void 0,gap:e==="side-by-side"?"12px":0,position:"relative",width:"100%",justifyContent:e==="overlay"?"center":void 0})),Lm=dt.div(({theme:e})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",overflow:"hidden",backgroundColor:e.background.app,minHeight:"80px",maxHeight:"120px",display:"flex",alignItems:"center",justifyContent:"center"})),Mm=dt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.7)",color:e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),A3=dt.button(({theme:e})=>({position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",padding:"0",backgroundColor:e.base==="dark"?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.7)",border:"none",borderRadius:"3px",color:e.color.inverseText,cursor:"pointer",fontSize:"12px",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,transition:"all 0.2s","&:hover":{backgroundColor:e.color.secondary},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),P3=dt.img(({opacity:e=1})=>({maxWidth:"100%",maxHeight:"120px",height:"auto",display:"block",objectFit:"contain",opacity:e})),L3=dt.img({display:"block",objectFit:"contain",maxHeight:"120px",maxWidth:"100%"}),M3=dt.div({position:"relative",display:"inline-block"}),aae=dt.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"}})),B3=dt.div({position:"relative",display:"inline-block"}),lae=dt.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})),D3=dt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),R3=dt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),z3=dt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),N3=dt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),O3=dt.input({flex:1}),Bm=dt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),cae=dt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),lC=dt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),Pi=dt.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%"}}})),Li=dt.div({textAlign:"center",zIndex:1}),Mi=dt.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)"}}})),Bi=dt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Dm=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let{currentMapping:r,loadingMapping:o}=Ge(),{figmaImageUrl:i,storybookImageUrl:s,figmaDimensions:a,setFigmaImageUrl:u,hoveredIssueId:c,reviewHistory:l,currentReviewId:p}=ye(),{selectedProjectId:f}=Ke(),{sessionToken:d}=ze(),h=Fm("enableHoverHighlight"),[S,C]=Ks("side-by-side"),[F,T]=Ks(.5),[R,z]=Ks(!1),[N,E]=Ks(null),[M,g]=Ks(null),k=Em(null),w=Em(null),A=Em(null),m=F3(()=>{if(!h||!c||!p)return null;let P=l.find(L=>L.id===p);return P?.issues&&P.issues.find(L=>L.id===c)||null},[c,p,l]),v=P=>{let L=P.currentTarget;!st.getState().figmaDimensions&&L.naturalWidth&&L.naturalHeight&&st.getState().setFigmaDimensions({width:L.naturalWidth,height:L.naturalHeight}),requestAnimationFrame(()=>{if(w.current){let{clientWidth:O,clientHeight:y}=w.current;O&&y&&g({width:O,height:y})}})},I=()=>{requestAnimationFrame(()=>{if(k.current){let{clientWidth:P,clientHeight:L}=k.current;P&&L&&E({width:P,height:L})}})},x=async()=>{if(!(!f||!d)){z(!0);try{let P=J();await fetch(`${P}/api/figma/frames/invalidate?projectId=${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},credentials:"include"}),u(null),b.debug("Figma cache cleared, image will reload on next review")}catch(P){b.error("Failed to refresh Figma:",P)}finally{z(!1)}}};return e?te.createElement(Xs,null,te.createElement(Am,null,te.createElement(Pm,null,te.createElement(Qs,null,"Screenshot Comparison"))),te.createElement(lC,null,te.createElement(Pi,null,te.createElement(Li,null,te.createElement(Mi,null),te.createElement(Bi,null,"Loading Figma..."))),te.createElement(Pi,null,te.createElement(Li,null,te.createElement(Mi,null),te.createElement(Bi,null,"Loading Storybook..."))))):!i&&!s&&!r?o?te.createElement(Xs,null,te.createElement(Am,null,te.createElement(Pm,null,te.createElement(Qs,null,"Screenshot Comparison"))),te.createElement(lC,null,te.createElement(Pi,null,te.createElement(Li,null,te.createElement(Mi,null),te.createElement(Bi,null,"Loading..."))))):te.createElement(Xs,null,te.createElement(Qs,null,"Screenshot Comparison"),te.createElement(Bm,null,"No Figma mapping. Link this story to a Figma frame to compare designs.")):!i&&!s?te.createElement(Xs,null,te.createElement(Qs,null,"Screenshot Comparison"),te.createElement(Bm,null,"No screenshots available. Run a review to capture Figma and Storybook screenshots.")):te.createElement(Xs,{ref:A},te.createElement(Am,null,te.createElement(Pm,null,te.createElement(Qs,null,"Screenshot Comparison")),te.createElement(E3,null,te.createElement(sC,{active:S==="side-by-side",onClick:()=>C("side-by-side")},"Side by Side"),te.createElement(sC,{active:S==="overlay",onClick:()=>C("overlay")},"Overlay"))),S==="side-by-side"?te.createElement(aC,{layout:"side-by-side"},i&&!t?te.createElement(Lm,null,te.createElement(Mm,null,"Figma Design"),te.createElement(A3,{onClick:x,disabled:R,title:"Refresh Figma cache and reload image"},R?"\u23F3":"\u{1F504}"),te.createElement(M3,null,te.createElement(L3,{ref:w,src:i,alt:"Figma design",onLoad:v,style:N?{width:N.width,height:N.height}:{maxWidth:"100%",maxHeight:"120px"}}))):!r&&!o?te.createElement(Lm,null,te.createElement(Mm,null,"Figma Design"),te.createElement(Bm,{style:{border:"none",padding:"20px"}},"No Figma mapping. Link this story to a Figma frame to compare designs.")):te.createElement(Pi,null,te.createElement(Li,null,te.createElement(Mi,null),te.createElement(Bi,null,t?"Refreshing Figma...":"Loading Figma..."))),s&&!n?te.createElement(Lm,null,te.createElement(Mm,null,"Storybook Component"),te.createElement(P3,{ref:k,src:s,alt:"Storybook component",onLoad:I})):te.createElement(Pi,null,te.createElement(Li,null,te.createElement(Mi,null),te.createElement(Bi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):te.createElement(te.Fragment,null,te.createElement(aC,{layout:"overlay"},te.createElement(B3,null,i&&s?te.createElement(te.Fragment,null,te.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},te.createElement(D3,{ref:k,src:s,alt:"Storybook component",onLoad:I,style:{maxHeight:"200px"}}),N&&te.createElement(R3,{src:i,alt:"Figma design overlay",style:{opacity:F,width:N.width,height:N.height,objectFit:"fill"}})),te.createElement("div",{style:{fontSize:"10px",color:"#888",marginTop:"8px",textAlign:"center"}},te.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",te.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),N&&` \u2022 ${N.width}\xD7${N.height}px`)):te.createElement(Pi,null,te.createElement(Li,null,te.createElement(Mi,null),te.createElement(Bi,null,"Loading Images..."))))),s&&i&&te.createElement(z3,null,te.createElement(N3,null,"Figma Opacity:"),te.createElement(O3,{type:"range",min:"0",max:"1",step:"0.01",value:F,onChange:P=>T(parseFloat(P.target.value))}),te.createElement("span",null,Math.round(F*100),"%"))))};Ae();var $3=Wo.div({padding:"20px",height:"100%",overflowY:"auto"}),pc=Wo.div({marginBottom:"20px"}),cC=Wo.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"})),uC=Wo.span({fontSize:"16px",flexShrink:0}),U3=Wo.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})),pC=Wo.div({flex:1}),j3=Wo($n)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",color:e.color.negative||"#dc2626",borderColor:e.color.negative||"#fca5a5","&:hover:not(:disabled)":{backgroundColor:e.background.negative||"#fee2e2"}})),Rm=()=>{let{reviewError:e,getCurrentReview:t}=ye(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=$i(),{selectedProjectId:s}=tr(),{setCurrentMapping:a,deleteMapping:u,currentMapping:c,hasMapping:l}=Lo(),[p,f]=_3(!1),{currentStoryId:d,currentStoryName:h}=Ge(),{isLoadingScreenshots:S,isLoadingFigma:C,isLoadingStorybook:F,screenshotError:T,setFigmaImageDirect:R}=ko(),z=async N=>{b.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",N),b.debug("[ReviewPanel] frame.id:",N?.id);let E=st.getState(),M=E.selectedProjectId,g=E.currentStoryId,k=E.currentStoryName,w=E.figmaFileUrl;b.debug("[ReviewPanel] selectedProjectId (from store):",M),b.debug("[ReviewPanel] currentStoryId (from store):",g),b.debug("[ReviewPanel] currentStoryName (from store):",k),N.thumbnail&&g&&(b.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),R(g,N.id,N.thumbnail));try{let A=J(),m=localStorage.getItem("uicopilot_session_token");if(b.debug("[ReviewPanel] sessionToken exists:",!!m),b.debug("[ReviewPanel] dashboardUrl:",A),!m||!M||!g){b.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!m,selectedProjectId:M,currentStoryId:g});return}let v=w?.match(/\/file\/([^\/]+)/)?.[1]||void 0;b.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:M,storyId:g,name:k,figmaNodeId:N.id,figmaFileKey:v});let I=await fetch(`${A}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:M,storyId:g,name:k,figmaNodeId:N.id,figmaFileKey:v})});if(I.ok){let x=await I.json();x.mapping&&(a(x.mapping),N.thumbnail||(b.debug("[ReviewPanel] No thumbnail available, triggering fetch"),st.getState().triggerScreenshotRefresh()),b.debug("[ReviewPanel] Mapping saved successfully:",x.mapping))}else{let x=await I.text();b.error("[ReviewPanel] Failed to save mapping:",x)}}catch(A){b.error("[ReviewPanel] Error saving mapping:",A)}};return xt.createElement($3,null,xt.createElement(pc,null,xt.createElement(ag,null)),e&&xt.createElement(cC,null,xt.createElement(uC,null,"\u26A0\uFE0F"),xt.createElement(pC,null,e)),T&&xt.createElement(cC,null,xt.createElement(uC,null,"\u26A0\uFE0F"),xt.createElement(pC,null,"Screenshot loading error: ",T)),n?.variantMismatch&&xt.createElement(U3,null,xt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),xt.createElement("span",null,xt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",xt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",xt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),xt.createElement(pc,null,xt.createElement(Tm,null)),xt.createElement(pc,null,xt.createElement(Dm,{isLoading:S,isLoadingFigma:C,isLoadingStorybook:F})),xt.createElement(pc,null,xt.createElement(lg,null),l&&xt.createElement("div",{style:{marginTop:"8px"}},xt.createElement(j3,{onClick:()=>f(!0)},"Unlink Figma Mapping"),xt.createElement(Cl,{isOpen:p,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:async()=>{f(!1);try{let N=c?.id;N&&await u(N),a(null)}catch(N){console.error("[ReviewPanel] Failed to unlink:",N)}},onCancel:()=>f(!1)}))),xt.createElement(yi,{isOpen:r,onClose:o,onSelect:z,figmaFileUrl:i||"",projectId:s||void 0}))};import Iae from"react";import{styled as dc}from"storybook/theming";Ae();var Pae=dc.div({display:"flex",flexDirection:"column",gap:"12px"}),Lae=dc.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Mae=dc.div(({theme:e})=>({backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"16px",fontSize:"13px",color:e.color.defaultText,overflowY:"auto",maxHeight:"500px",lineHeight:"1.6","& h1, & h2, & h3, & h4, & h5, & h6":{marginTop:"16px",marginBottom:"8px",fontWeight:600},"& h1":{fontSize:"20px"},"& h2":{fontSize:"18px"},"& h3":{fontSize:"16px"},"& h4":{fontSize:"14px"},"& p":{marginBottom:"12px"},"& ul, & ol":{marginLeft:"20px",marginBottom:"12px"},"& li":{marginBottom:"4px"},"& code":{backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"3px",fontSize:"12px",fontFamily:Fl.fontMono},"& pre":{backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",padding:"12px",overflowX:"auto",marginBottom:"12px"},"& pre code":{backgroundColor:"transparent",padding:0},"& blockquote":{borderLeft:`3px solid ${e.color.secondary}`,paddingLeft:"12px",marginLeft:"0",marginBottom:"12px",color:e.color.mediumdark},"& table":{width:"100%",borderCollapse:"collapse",marginBottom:"12px"},"& th, & td":{border:`1px solid ${e.appBorderColor}`,padding:"8px",textAlign:"left"},"& th":{backgroundColor:e.background.hoverable,fontWeight:600}})),Bae=dc.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"}));Ae();Pe();Ue();import{useEffect as dC,useState as H3,useRef as zm,useCallback as W3}from"react";var V3=J(),G3=2e3;function fC(){let{sessionToken:e,usageData:t,setUsageData:n}=ze(),[r,o]=H3(null),i=zm(null),s=zm(!1),a=zm(0);dC(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=W3(()=>{o(null)},[]);return dC(()=>{if(!e)return;let c=async()=>{let p=Date.now();if(s.current||p-a.current<G3){b.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=p;try{b.debug("[useBalanceRefresh] Refreshing balance...");let f=await fetch(`${V3}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(f.ok){let d=await f.json(),h=d.creditBalance,S=i.current;if(S!==null&&h>S){let C=h-S;o({message:`Credits added! +$${C.toFixed(2)}`,previousBalance:S,newBalance:h}),b.debug("[useBalanceRefresh] Credits added:",C)}i.current=h,n(d),b.debug("[useBalanceRefresh] Balance updated:",h)}}catch(f){b.error("[useBalanceRefresh] Failed to refresh:",f)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}Ae();Ue();Pe();import{useEffect as q3,useRef as Y3}from"react";function gC(){let{setFeatureFlags:e}=ye(),t=Y3(!1);q3(()=>{if(t.current)return;t.current=!0;let n=`${J()}/api/addon/flags`;fetch(n).then(r=>{if(!r.ok)throw new Error(`flags endpoint returned ${r.status}`);return r.json()}).then(r=>{b.debug("[useFeatureFlags] Received flags:",r),e({enableFixGeneration:!!r.enableFixGeneration,enableFixApply:!!r.enableFixApply,enableAutoMap:!!r.enableAutoMap,enableReviewBadges:!!r.enableReviewBadges})}).catch(r=>{b.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",r.message)})},[e])}Ae();var Q3=Zn.div`
145
+ position: fixed;
146
+ top: 16px;
147
+ right: 16px;
148
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
149
+ color: white;
150
+ padding: 12px 20px;
151
+ border-radius: 8px;
152
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
153
+ display: flex;
154
+ align-items: center;
155
+ gap: 12px;
156
+ z-index: 9999;
157
+ animation: slideIn 0.3s ease-out;
158
+ @keyframes slideIn {
159
+ from { transform: translateX(100%); opacity: 0; }
160
+ to { transform: translateX(0); opacity: 1; }
161
+ }
162
+ `,J3=Zn.span`font-size: 20px;`,Z3=Zn.span`font-weight: 500; font-size: 14px;`,ej=Zn.button`
163
+ background: rgba(255, 255, 255, 0.2);
164
+ border: none; color: white;
165
+ width: 24px; height: 24px; border-radius: 50%;
166
+ cursor: pointer; display: flex; align-items: center; justify-content: center;
167
+ font-size: 14px; margin-left: 8px;
168
+ &:hover { background: rgba(255, 255, 255, 0.3); }
169
+ `,tj=Zn.div`
170
+ padding: 8px 16px;
171
+ border-top: 1px solid ${({theme:e})=>e.appBorderColor};
172
+ font-size: 11px;
173
+ color: ${({theme:e})=>e.color.mediumdark};
174
+ text-align: center;
175
+ opacity: 0.7;
176
+ `,nj=Zn.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),rj=Zn.div({fontSize:"32px"}),oj=Zn.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),ij=Zn.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),sj=Zn.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})),aj=Zn.span({flex:1}),lj=Zn.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`}})),mC=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Ke(),{isConnected:r,sessionToken:o,authError:i}=ze(),{currentStoryId:s}=Ge(),{currentReviewId:a}=ye(),[u,c]=K3(!1);lf(),If(),gC(),xf(),gf();let{notification:l,dismissNotification:p}=fC();X3(()=>{if(l){let F=setTimeout(p,5e3);return()=>clearTimeout(F)}},[l,p]);let f=t.find(F=>F.id===e),d=r&&!!e&&!!f,h=!!o&&!!e&&(n||t.length===0),{loadingMapping:S}=Ge(),C=d&&!!s&&!a&&S;return Nt.createElement(kc,{header:Nt.createElement(vc,{toolbar:Nt.createElement(Rc,{onOpenSettings:()=>c(!0)})}),footer:Nt.createElement(tj,null,"UI Copilot v","0.4.1")},l&&Nt.createElement(Q3,null,Nt.createElement(J3,null,"+"),Nt.createElement(Z3,null,l.message),Nt.createElement(ej,{onClick:p},"x")),i&&Nt.createElement(sj,null,Nt.createElement("span",null,"\u26A0"),Nt.createElement(aj,null,i),Nt.createElement(lj,{onClick:()=>c(!0)},"Reconnect")),h||C?Nt.createElement(sc,{label:h?"Loading...":"Loading review..."}):d?Nt.createElement(Rm,null):Nt.createElement(nj,null,Nt.createElement(rj,null,"\u2699"),Nt.createElement(oj,null,i?"Connection issue":"Set up UI Copilot"),Nt.createElement(ij,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),Nt.createElement(nn,{onClick:()=>c(!0)},i?"Reconnect":"Open Settings")),u&&Nt.createElement(nw,{onClose:()=>c(!1)}))};import xC,{useCallback as cj}from"react";import{useStorybookApi as uj}from"storybook/manager-api";import{IconButton as pj}from"storybook/internal/components";import Nm from"react";var hC=()=>Nm.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"},Nm.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Nm.createElement("circle",{cx:"12",cy:"12",r:"3"}));var dj="uireview",fj=`${dj}/panel`,yC=()=>{let e=uj(),t=cj(()=>{e.togglePanel(!0),e.setSelectedPanel(fj)},[e]);return xC.createElement(pj,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},xC.createElement(hC,null))};Ae();import Lt,{useState as mc,useCallback as kC,useEffect as vC}from"react";import{styled as Wr,useTheme as Cj}from"storybook/theming";import{addons as hc}from"storybook/manager-api";Ue();Pe();import{addons as bj,experimental_getStatusStore as gc}from"storybook/manager-api";async function bC(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}Ue();Pe();var gj=J(),mj="uireview/badge";async function hj(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;b.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(s=>setTimeout(s,i))}throw new Error("Max retries exceeded")}async function xj(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:p,value:f}=await e.read();if(p)break;if(t()){e.cancel();break}r+=n.decode(f,{stream:!0});let d=r.split(`
177
+ `);r=d.pop()||"";for(let h of d)if(h.startsWith("data: "))try{let S=JSON.parse(h.slice(6));if(S.type==="complete"){o=S.complianceScore??S.validation?.complianceScore??null;let F=(S.issues||[]).filter(T=>!T.dismissed);i=F.filter(T=>T.severity==="critical").length,s=F.filter(T=>T.severity==="major").length,a=F.filter(T=>T.severity==="minor").length,u=S.costUsd||0,c=S.inputTokens||0,l=S.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function fc(e,t,n,r,o){e&&e.set([{value:n,typeId:mj,storyId:t,title:r,description:o}])}async function yj(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 SC(e,t,n,r,o,i){fc(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await yj(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await hj(`${gj}/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 xj(u,i),{score:l,criticalCount:p,majorCount:f,minorCount:d,costUsd:h,inputTokens:S,outputTokens:C}=c;if(l!==null){let F=p>0||l<70?"status-value:error":f>0||l<90?"status-value:warning":"status-value:success",T=[`Score: ${l}`];p>0&&T.push(`${p} critical`),f>0&&T.push(`${f} major`),d>0&&T.push(`${d} minor`);let R=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return fc(o,e.storyId,F,R,T.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:h,inputTokens:S,outputTokens:C}}return fc(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){b.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return fc(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var Sj=J(),Js="uireview/badge";function wC(){let e=!1,t=!1;try{let n=bj.getChannel();n.on(_m,async()=>{if(!t){t=!0,e=!1;try{await vj(n,()=>e)}finally{t=!1}}}),n.on($m,()=>{e=!0})}catch{}}async function Om(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${Sj}/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 wj(i),i}catch(e){return b.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function wj(e){try{if(typeof gc!="function")return;let t=gc(Js);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Js]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Js];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Js,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 kj(){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 vj(e,t){let n=await Om();if(n.length===0){e.emit(ea,{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-haiku-4-5-20251001";try{let S=localStorage.getItem("uicopilot_selected_models");if(S){let C=JSON.parse(S);Array.isArray(C)&&C.length>0&&(i=C[0])}}catch{}let s=null;try{typeof gc=="function"&&(s=gc(Js))}catch{}let a=kj(),u=0,c=0,l=0,p=0,f=0,d=0;e.emit(Zs,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let h=n.map(S=>()=>SC(S,r,o,i,s,t));await bC(h,a,(S,C)=>{if(C&&typeof C=="object"&&"score"in C){let F=C;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,p+=F.costUsd||0,f+=F.inputTokens||0,d+=F.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${S+1}/${n.length} done:`,n[S].storyName,C),e.emit(Zs,{total:n.length,completed:u+c+l,currentStoryName:n[S].storyName})},t),e.emit(ea,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:p,inputTokens:f,outputTokens:d})}var Tj=Wr.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),Ij=Wr.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),Fj=Wr.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),CC=Wr.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),TC=Wr.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}})),Ej=Wr.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),Aj=Wr.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),IC=Wr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Di=Wr.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),_m="uireview/review-all-start",$m="uireview/review-all-cancel",Zs="uireview/review-all-progress",ea="uireview/review-all-complete",FC=()=>{let[e,t]=mc(!1),[n,r]=mc(null),[o,i]=mc(null),[s,a]=mc(null);vC(()=>{let f=()=>{Om().then(C=>{a(C.length)}).catch(()=>{})},d=setTimeout(f,3e3),h=null;try{h=hc.getChannel(),h.on("storyChanged",f),h.on("uireview/mappings-changed",f)}catch{}let S=setInterval(f,6e4);return()=>{clearTimeout(d),clearInterval(S),h&&(h.off("storyChanged",f),h.off("uireview/mappings-changed",f))}},[]),vC(()=>{let f;try{f=hc.getChannel()}catch{return}let d=S=>{r(S),t(!0)},h=S=>{t(!1),r(null),i({total:S.total,passed:S.passed,failed:S.failed,warned:S.warnCount||0,costUsd:S.costUsd||0})};return f.on(Zs,d),f.on(ea,h),()=>{f.off(Zs,d),f.off(ea,h)}},[]);let u=kC(()=>{try{hc.getChannel().emit(_m),t(!0),i(null)}catch{}},[]),c=kC(()=>{try{hc.getChannel().emit($m)}catch{}t(!1),r(null)},[]),l=n?Math.round(n.completed/n.total*100):0,p=Cj();return Lt.createElement(Tj,null,Lt.createElement(Ij,null,Lt.createElement(Fj,null,"UI Review"),e?Lt.createElement(TC,{running:!0,onClick:c},"Cancel"):Lt.createElement(TC,{onClick:u,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Lt.createElement(Lt.Fragment,null,Lt.createElement(IC,null,Lt.createElement(Di,{dotColor:p.color.positive},"Pass (",o.passed,")"),Lt.createElement(Di,{dotColor:p.color.warning},"Warn (",o.warned,")"),Lt.createElement(Di,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Lt.createElement(CC,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Lt.createElement(IC,null,Lt.createElement(Di,{dotColor:p.color.positive},"Pass"),Lt.createElement(Di,{dotColor:p.color.warning},"Warn"),Lt.createElement(Di,{dotColor:p.color.negative},"Fail")),e&&n&&Lt.createElement(Lt.Fragment,null,Lt.createElement(Ej,null,Lt.createElement(Aj,{percent:l})),Lt.createElement(CC,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName)))};import*as AC from"@sentry/react";var Pj="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",EC=!1;function PC(){if(!EC){EC=!0;try{AC.init({dsn:Pj,environment:"production",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{}}}PC();var yc="uireview",Mj=`${yc}/panel`,Bj=`${yc}/tool`,MC=`${yc}/test-provider`;xc.register(yc,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof LC=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let e=LC("uireview/badge");Yb(e),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");xc.add(Bj,{type:Um.TOOL,title:"UI Review",match:({viewMode:e})=>e==="story",render:()=>ta.createElement(yC,null)}),wC(),xc.add(MC,{type:Um.experimental_TEST_PROVIDER,id:MC,render:()=>ta.createElement(FC,null)}),xc.add(Mj,{type:Um.PANEL,title:"UI Review",match:({viewMode:e})=>e==="story",render:({active:e})=>ta.createElement(Lj,{active:e||!1},ta.createElement(Dc,null,ta.createElement(mC,null)))})});
178
+ /*! Bundled license information:
179
+
180
+ @noble/hashes/utils.js:
181
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
182
+ */