@uicopilot/storybook-addon 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manager.mjs +49 -49
- package/package.json +1 -1
package/dist/manager.mjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
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
|
|
1
|
+
var o1=Object.create;var fa=Object.defineProperty;var i1=Object.getOwnPropertyDescriptor;var s1=Object.getOwnPropertyNames;var a1=Object.getPrototypeOf,l1=Object.prototype.hasOwnProperty;var c1=(e,t,n)=>t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var on=(e,t)=>()=>(e&&(t=e(e=0)),t);var Un=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),be=(e,t)=>{for(var n in t)fa(e,n,{get:t[n],enumerable:!0})},u1=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of s1(t))!l1.call(e,o)&&o!==n&&fa(e,o,{get:()=>t[o],enumerable:!(r=i1(t,o))||r.enumerable});return e};var ga=(e,t,n)=>(n=e!=null?o1(a1(e)):{},u1(t||!e||!e.__esModule?fa(n,"default",{value:e,enumerable:!0}):n,e));var jn=(e,t,n)=>c1(e,typeof t!="symbol"?t+"":t,n);function lh(){try{return typeof window<"u"&&localStorage.getItem(g1)==="true"}catch{return!1}}var g1,b,Me=on(()=>{"use strict";g1="uicopilot:debug";b={debug:(...e)=>{lh()&&console.log(...e)},info:(...e)=>{lh()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import m1,{createContext as h1,useContext as x1,useReducer as y1,useMemo as ch}from"react";function b1(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 Lc({children:e}){let[t,n]=y1(b1,k1),r=ch(()=>({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=ch(()=>({...t,...r}),[t,r]);return m1.createElement(ph.Provider,{value:o},e)}function Ie(){let e=x1(ph);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var S1,w1,v1,uh,k1,ph,Mc=on(()=>{"use strict";Me();S1=()=>{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"))};S1();w1=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),v1=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",uh=w1(),k1={isConnected:!!uh,sessionToken:uh,apiKey:v1(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},ph=h1(null)});import C1,{createContext as T1,useContext as I1,useReducer as F1,useMemo as dh,useRef as E1,useEffect as A1}from"react";function P1(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 Bc({children:e}){let[t,n]=F1(P1,M1),r=E1(t);A1(()=>{r.current=t},[t]);let o=dh(()=>({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=dh(()=>({...t,...o}),[t,o]);return C1.createElement(fh.Provider,{value:i},e)}function Qe(){let e=I1(fh);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var L1,M1,fh,Dc=on(()=>{"use strict";L1=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),M1={projects:[],selectedProjectId:L1(),loadingProjects:!1,currentStorybookPath:null},fh=T1(null)});import B1,{createContext as D1,useContext as R1,useReducer as z1,useMemo as gh}from"react";function N1(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>mh)for(let o of r.slice(0,r.length-mh))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 Rc({children:e}){let[t,n]=z1(N1,O1),r=gh(()=>({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=gh(()=>({...t,...r}),[t,r]);return B1.createElement(hh.Provider,{value:o},e)}function Ye(){let e=R1(hh);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var mh,O1,hh,zc=on(()=>{"use strict";mh=200;O1={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},hh=D1(null)});function Vn(e){try{let t=JSON.stringify(e,_1);sessionStorage.setItem(Nc,t)}catch(t){b.error("[SessionStorage] Failed to save review history:",t)}}function xh(){try{let e=sessionStorage.getItem(Nc);if(!e)return[];let t=JSON.parse(e,$1);return Array.isArray(t)?t:[]}catch(e){return b.error("[SessionStorage] Failed to load review history:",e),[]}}function yh(){try{sessionStorage.removeItem(Nc),b.debug("[SessionStorage] Review history cleared")}catch(e){b.error("[SessionStorage] Failed to clear review history:",e)}}function _1(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function $1(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Nc,bh=on(()=>{"use strict";Me();Nc="uicopilot_review_history"});import U1,{createContext as j1,useContext as H1,useReducer as W1,useMemo as Sh,useRef as V1,useEffect as G1}from"react";function q1(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],Vn(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 Vn(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=[...e.reviewHistory,t.payload];return Vn(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 Vn(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 Vn(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 Vn(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 Vn(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 Vn(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 Vn(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 Vn(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 Vn(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return yh(),{...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 Oc({children:e}){let[t,n]=W1(q1,X1),r=V1(t);G1(()=>{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}}),setUserRole:s=>n({type:"SET_STATE",payload:{userRole:s}}),setRoleOverride:s=>{try{s?localStorage.setItem("uicopilot_role_override",s):localStorage.removeItem("uicopilot_role_override")}catch{}n({type:"SET_STATE",payload:{roleOverride:s}})},setReviewAllConcurrency:s=>{let a=Math.max(1,Math.min(5,s));try{localStorage.setItem("uicopilot_review_all_concurrency",String(a))}catch{}n({type:"SET_STATE",payload:{reviewAllConcurrency:a}})},setIsGenerating:s=>n({type:"SET_STATE",payload:{isGenerating:s}}),setGeneratedPrompt:s=>n({type:"SET_STATE",payload:{generatedPrompt:s}}),setPromptError:s=>n({type:"SET_STATE",payload:{promptError:s}}),resetPrompt:()=>n({type:"RESET_PROMPT"})}),[]),i=Sh(()=>({...t,...o}),[t,o]);return U1.createElement(wh.Provider,{value:i},e)}function se(){let e=H1(wh);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var Y1,K1,X1,wh,_c=on(()=>{"use strict";bh();Me();Y1=()=>{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},K1=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},X1={isReviewing:!1,reviewError:null,reviewResults:null,multiModelResults:null,showReviewMenu:!1,severityFilter:"all",showStreamingPanel:!1,streamingPanelCollapsed:!1,streamingMessages:[],streamingProgress:0,streamingStatus:"",reviewDetailTab:"chat",fullPrompt:"",fullResponse:"",figmaImageUrl:null,storybookImageUrl:null,figmaDimensions:null,selectedModels:["claude-sonnet-4-5-20250929"],modelComparisonView:"side-by-side",reviewHistory:xh(),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:"beta",roleOverride:K1(),featureFlags:{enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},reviewAllConcurrency:Y1(),hoveredIssueId:null},wh=j1(null)});import qi,{useMemo as Q1}from"react";function Uc({children:e}){return qi.createElement(Lc,null,qi.createElement(Bc,null,qi.createElement(Rc,null,qi.createElement(Oc,null,qi.createElement(J1,null),e))))}function vh(e){let t=Ie(),n=Qe(),r=Ye(),o=se(),i=Q1(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function J1(){return $c=vh(),null}var $c,at,kh=on(()=>{"use strict";Mc();Dc();zc();_c();$c=null,at=Object.assign(vh,{getState:()=>{if(!$c)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return $c}})});var ke=on(()=>{"use strict";kh();Mc();Dc();zc();_c()});function G(){return(process.env.STORYBOOK_UICOPILOT_URL||Z1).replace(/\/$/,"")}var Z1,Ch,Re=on(()=>{"use strict";Z1="https://uicopilot-dashboard.vercel.app",Ch=3.6});async function ne(e,t,n=1e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var nt=on(()=>{"use strict"});import{useEffect as Ji,useState as ba,useRef as MT,useCallback as Hc}from"react";import{addons as Wc}from"storybook/manager-api";function BT(e,t,n){try{sessionStorage.setItem(`${Sa}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function DT(e,t){try{let n=sessionStorage.getItem(`${Sa}${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(`${Sa}${e}`)}catch{}return null}function RT(e){try{let t=sessionStorage.getItem(`${Sa}${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 Dh,Rh,zh,Oh,Zo,Nh,Gn,Vc,Sa,_h,Eo,Zi=on(()=>{"use strict";ke();Gc();Me();Re();nt();Dh="storyArgsUpdated",Rh="storyRendered",zh="forceRemount",Oh=null,Zo=()=>Oh,Nh=G(),Gn=new Map,Vc=null,Sa="uicopilot-figma-image-";_h=(e,t,n)=>{Vc=t;let r=Gn.get(e);r?r.figmaImageUrl=n:Gn.set(e,{storybookImageUrl:null,figmaImageUrl:n}),b.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},Eo=()=>{let[e,t]=ba(!1),[n,r]=ba(!1),[o,i]=ba(!1),[s,a]=ba(null),u=MT(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=se(),p=Hc(()=>{let R=at.getState().currentStoryId;R&&(b.debug("[useReviewScreenshots] Refreshing screenshots for story:",R),Gn.delete(R),u.current=null,i(!0),l())},[l]),f=Hc(()=>{let R=at.getState().currentStoryId;if(R){b.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",R);let O=Gn.get(R);O&&(O.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:d}=Ie(),{selectedProjectId:m}=Qe(),{currentStoryId:S,currentMapping:T}=Ye(),{setStorybookImageUrl:F,setFigmaImageUrl:k}=se();Ji(()=>{if(!S||at.getState().figmaImageUrl)return;let O=RT(S);O&&(b.debug("[useReviewScreenshots] Quick-restored Figma image for:",S),k(O))},[S,k]),Ji(()=>{(async()=>{if(!d||!m||!S){b.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}let O=at.getState();if(O.storybookImageUrl&&O.figmaImageUrl){b.debug("[useReviewScreenshots] Screenshots already loaded from persisted review, skipping capture"),u.current=S;return}let E=T?.figmaNodeId??null;if(E!==Vc){b.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",S);let I=Gn.get(S);I&&(I.figmaImageUrl=null),Vc=E,u.current=null}let D=T?.figmaNodeId;if(D&&!Gn.get(S)?.figmaImageUrl){let I=DT(S,D);if(I){b.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",S),k(I);let y=Gn.get(S);y?y.figmaImageUrl=I:Gn.set(S,{storybookImageUrl:null,figmaImageUrl:I})}}let g=Gn.get(S),w=g&&g.storybookImageUrl&&g.figmaImageUrl,v=g&&g.storybookImageUrl&&!g.figmaImageUrl,A=g&&!g.storybookImageUrl&&g.figmaImageUrl;if(w){b.debug("[useReviewScreenshots] Using fully cached screenshots for story:",S),F(g.storybookImageUrl),k(g.figmaImageUrl),u.current=S;return}let h=v&&T?.figmaNodeId;h&&(b.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",S),F(g.storybookImageUrl));let C=A;if(C&&(b.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",S),k(g.figmaImageUrl)),u.current===S&&T?.figmaNodeId){b.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{a(null),h?r(!0):(C||(t(!0),r(!0)),i(!0)),u.current=S;let I=C?g.figmaImageUrl:null,y;if(C)b.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(D){b.debug("[useReviewScreenshots] Found Figma node ID from mapping:",D);let L=null;try{b.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let B=await ne(`${Nh}/api/figma/image?projectId=${m}&nodeId=${D}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`}});if(B.ok){let N=await B.json();L=N.imageUrl||null;let x=N.cached?"(cached)":"(fresh)";b.debug(`[useReviewScreenshots] Figma image fetched ${x}:`,L?"success":"not found")}}catch(B){b.warn("[useReviewScreenshots] Failed to fetch Figma image:",B)}if(L)if(L.includes(".blob.vercel-storage.com")){b.debug("[useReviewScreenshots] Using cached Vercel Blob URL directly (fast)"),I=L,k(L);let N=new Image;N.crossOrigin="anonymous",await new Promise(x=>{N.onload=()=>{y={width:N.naturalWidth,height:N.naturalHeight},b.debug("[useReviewScreenshots] Figma dimensions:",y),x()},N.onerror=()=>x(),N.src=L})}else try{b.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let N=`${Nh}/api/proxy/image?url=${encodeURIComponent(L)}`,x=await ne(N);if(x.ok){let U=await x.blob(),H=new FileReader,M=await new Promise((ee,J)=>{H.onloadend=()=>ee(H.result),H.onerror=J,H.readAsDataURL(U)});I=M,k(M),b.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let Q=new Image;await new Promise(ee=>{Q.onload=()=>{y={width:Q.naturalWidth,height:Q.naturalHeight},b.debug("[useReviewScreenshots] Figma dimensions:",y),ee()},Q.onerror=()=>ee(),Q.src=M})}else I=L,k(L),b.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(N){b.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",N),I=L,k(L)}else b.warn("[useReviewScreenshots] No thumbnail found for node:",D),k(null);I&&D&&BT(S,D,I),r(!1)}else b.debug("[useReviewScreenshots] No Figma mapping exists for this component"),k(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 wa({storyId:S,sessionToken:d||void 0,...y&&{figmaWidth:y.width,figmaHeight:y.height}});L?(P=L,F(L),b.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",y||"natural")):b.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}Gn.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,m,S,T?.figmaNodeId,c]),Ji(()=>{let R=Wc.getChannel(),O=null,E=D=>{Oh=D.args,b.debug("[useReviewScreenshots] Args updated for story:",D.storyId,"args:",D.args),O&&clearTimeout(O),O=setTimeout(()=>{b.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),p()},500)};return R.on(Dh,E),()=>{R.off(Dh,E),O&&clearTimeout(O)}},[p]),Ji(()=>{let R=Wc.getChannel(),O=!1,E=null,D=()=>{b.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),O=!0,i(!0)},g=()=>{O&&(b.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),E&&clearTimeout(E),E=setTimeout(()=>{O=!1,b.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),f()},500))};return R.on(zh,D),R.on(Rh,g),()=>{R.off(zh,D),R.off(Rh,g),E&&clearTimeout(E)}},[f]),Ji(()=>{let R=Wc.getChannel(),O=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 D=at.getState().currentStoryId,g=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...E.snapshot,storyId:D})});if(g.ok){let w=await g.json();if(w.screenshot){F(w.screenshot);let v=at.getState().currentStoryId;if(v){let A=Gn.get(v);A?A.storybookImageUrl=w.screenshot:Gn.set(v,{storybookImageUrl:w.screenshot,figmaImageUrl:null})}}}else b.error("[useReviewScreenshots] Snapshot screenshot failed:",await g.text())}catch(D){b.error("[useReviewScreenshots] Snapshot screenshot error:",D)}finally{i(!1)}};return R.on("UICOPILOT/STORY_DOM_MUTATED",O),()=>{R.off("UICOPILOT/STORY_DOM_MUTATED",O)}},[]);let z=Hc((R,O,E)=>{b.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),_h(R,O,E),k(E),r(!1),u.current=R},[k]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:p,refreshStorybookOnly:f,setFigmaImageDirect:z}}});function NT(){return!G().startsWith("http://localhost")}function OT(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 $h(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=OT(o,t,n);return r.set(o,i),i})}async function _T(){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=$h(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=$h(p,o,r),u.replaceWith(f)}}catch{}})}})).toDataURL("image/png")}function $T(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 UT(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 ne(`${zT}/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 jT(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 HT(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=Zo();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=jT(a),b.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=$T(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 WT(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 wa(e){try{let t=e?.storyId||VT();if(t){let n=await WT(t);if(n)return n}if(!NT()){let n=HT(e?.storyId);return await UT(n,{...e,selector:"#storybook-root > *"})}return b.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await _T()}catch(t){throw b.error("Error capturing screenshot:",t),new Error(`Failed to capture screenshot: ${t instanceof Error?t.message:"Unknown error"}`)}}function VT(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var zT,Gc=on(()=>{"use strict";Re();Zi();Me();nt();zT=G()});function mn(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 vn(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 es(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Uh(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let T=r.fontSize||"16px",F=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let k=t.fonts.check(`${F} ${T} Roboto`);if(b.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:k,fontWeight:F,fontSize:T,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(z=>({family:z.family,status:z.status}))}),k)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(T=>T.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,m="unknown",S=new Map;for(let T of f){s.font=`${c} ${u} ${a} "${T}", monospace`;let F=s.measureText(o).width;if(S.set(T,F),F!==d){s.font=`${c} ${u} ${a} "${T}"`;let k=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let z=s.measureText(o).width;if(Math.abs(k-z)<.1){m=T;break}}}return b.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:m,declaredFonts:l,fontWidths:Array.from(S.entries()),isIframe:t!==document}),m}var ts=on(()=>{"use strict";Me()});function ei(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 qc(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:mn(n.color),backgroundColor:mn(n.backgroundColor),borderColor:mn(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:Uh(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 Yc(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 va=on(()=>{"use strict";Me();ts()});function GT(e){let t=[],n=new Set,r=jh.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(jh.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function qT(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:ei(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:es(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:mn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function YT(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 KT(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=mn(n.borderColor),d=s?`${l} ${p} ${f}`:"none";return{selector:ei(r,i),className:i,border:d,borderRadius:n.borderRadius,backgroundColor:mn(n.backgroundColor),gap:n.gap}}function ns(){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=YT(r,2),i=o.map(KT).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=GT(r);s=a.map(qT),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:qc(r),declared:Yc(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return b.error("Error extracting computed styles:",e),null}}var jh,Hh=on(()=>{"use strict";Me();ts();va();jh=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Kc(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 QT(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function JT(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=mn(n.backgroundColor);vn("backgroundColor",o)||(r.backgroundColor=o);let i=QT(n.borderWidth,n.borderStyle,mn(n.borderColor));i&&(r.border=i),vn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),vn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),vn("opacity",n.opacity)||(r.opacity=n.opacity);let s=e.tagName.toLowerCase(),a=["svg","circle","rect","ellipse","line","polyline","polygon","path","text","tspan","g","use","defs","clipPath","mask"];if(e instanceof SVGElement||a.includes(s)){for(let T=0;T<e.attributes.length;T++){let F=e.attributes[T];if(["class","style","id","xmlns","xmlns:xlink"].includes(F.name))continue;let k=F.name.replace(/-([a-z])/g,(R,O)=>O.toUpperCase()),z=F.value.startsWith("rgb")?mn(F.value):F.value;k==="d"&&z.length>100?r[k]=z.substring(0,100)+"...":r[k]=z}let d=n.getPropertyValue("fill"),m=n.getPropertyValue("stroke");if(d&&d!=="none"&&(r.fill=d.startsWith("rgb")?mn(d):d),m&&m!=="none"&&(r.stroke=m.startsWith("rgb")?mn(m):m),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let T=e.getBoundingClientRect();T.width>0&&(r.width=`${Math.round(T.width*100)/100}px`),T.height>0&&(r.height=`${Math.round(T.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=XT.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=es(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=mn(n.color),vn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),vn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let p=Kc(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);vn("padding",p)||(r.padding=p);let f=Kc(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return vn("margin",f)||(r.margin=f),vn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(vn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),vn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),vn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function Wh(e){let t=1;for(let n of e.children)t+=Wh(n);return t}function Vh(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 T=S.textContent?.trim();if(T){p=T.length>50?T.substring(0,50)+"...":T;break}}let f=s;c?f=`${s}#${c}`:u&&(f=ei(s,u));let d=JT(o),m=[];if(i<t){let S=Array.from(o.children);for(let T of S){let F=T.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(F))continue;let z=(T.ownerDocument.defaultView||window).getComputedStyle(T);z.display==="none"||z.visibility==="hidden"||m.push(n(T,i+1))}}return{selector:f,tagName:s,className:u,id:c,role:l,textContent:p,styles:d,children:m}}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:Wh(r)}),r}function Xc(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=Vh(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 XT,Gh=on(()=>{"use strict";Me();ts();va();XT=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Qc=on(()=>{"use strict";ts();va();Hh();Gh()});var yx=Un((aW,xx)=>{"use strict";xx.exports={compareTwoStrings:hx,findBestMatch:kI};function hx(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 kI(e,t){if(!CI(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=hx(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 CI(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var Mx=Un(hu=>{"use strict";var Lx="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");hu.encode=function(e){if(0<=e&&e<Lx.length)return Lx[e];throw new TypeError("Must be between 0 and 63: "+e)};hu.decode=function(e){var t=65,n=90,r=97,o=122,i=48,s=57,a=43,u=47,c=26,l=52;return t<=e&&e<=n?e-t:r<=e&&e<=o?e-r+c:i<=e&&e<=s?e-i+l:e==a?62:e==u?63:-1}});var Nx=Un(yu=>{"use strict";var Bx=Mx(),xu=5,Dx=1<<xu,Rx=Dx-1,zx=Dx;function NI(e){return e<0?(-e<<1)+1:(e<<1)+0}function OI(e){var t=(e&1)===1,n=e>>1;return t?-n:n}yu.encode=function(t){var n="",r,o=NI(t);do r=o&Rx,o>>>=xu,o>0&&(r|=zx),n+=Bx.encode(r);while(o>0);return n};yu.decode=function(t,n,r){var o=t.length,i=0,s=0,a,u;do{if(n>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(u=Bx.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&zx),u&=Rx,i=i+(u<<s),s+=xu}while(a);r.value=OI(i),r.rest=n}});var ja=Un(Xt=>{"use strict";function _I(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}Xt.getArg=_I;var Ox=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,$I=/^data:.+\,.+$/;function ps(e){var t=e.match(Ox);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}Xt.urlParse=ps;function ai(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}Xt.urlGenerate=ai;var UI=32;function jI(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>UI&&t.pop(),i}}var bu=jI(function(t){var n=t,r=ps(t);if(r){if(!r.path)return t;n=r.path}for(var o=Xt.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,ai(r)):n});Xt.normalize=bu;function _x(e,t){e===""&&(e="."),t===""&&(t=".");var n=ps(t),r=ps(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),ai(n);if(n||t.match($I))return t;if(r&&!r.host&&!r.path)return r.host=t,ai(r);var o=t.charAt(0)==="/"?t:bu(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,ai(r)):o}Xt.join=_x;Xt.isAbsolute=function(e){return e.charAt(0)==="/"||Ox.test(e)};function HI(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)}Xt.relative=HI;var $x=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Ux(e){return e}function WI(e){return jx(e)?"$"+e:e}Xt.toSetString=$x?Ux:WI;function VI(e){return jx(e)?e.slice(1):e}Xt.fromSetString=$x?Ux:VI;function jx(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 GI(e,t,n){var r=Rr(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:Rr(e.name,t.name)}Xt.compareByOriginalPositions=GI;function qI(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:Rr(e.name,t.name)}Xt.compareByOriginalPositionsNoSource=qI;function YI(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=Rr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Rr(e.name,t.name)}Xt.compareByGeneratedPositionsDeflated=YI;function KI(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=Rr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Rr(e.name,t.name)}Xt.compareByGeneratedPositionsDeflatedNoLine=KI;function Rr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function XI(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=Rr(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:Rr(e.name,t.name)}Xt.compareByGeneratedPositionsInflated=XI;function QI(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}Xt.parseSourceMapInput=QI;function JI(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=ps(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=_x(ai(r),t)}return bu(t)}Xt.computeSourceURL=JI});var Wx=Un(Hx=>{"use strict";var Su=ja(),wu=Object.prototype.hasOwnProperty,Bo=typeof Map<"u";function zr(){this._array=[],this._set=Bo?new Map:Object.create(null)}zr.fromArray=function(t,n){for(var r=new zr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};zr.prototype.size=function(){return Bo?this._set.size:Object.getOwnPropertyNames(this._set).length};zr.prototype.add=function(t,n){var r=Bo?t:Su.toSetString(t),o=Bo?this.has(t):wu.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(Bo?this._set.set(t,i):this._set[r]=i)};zr.prototype.has=function(t){if(Bo)return this._set.has(t);var n=Su.toSetString(t);return wu.call(this._set,n)};zr.prototype.indexOf=function(t){if(Bo){var n=this._set.get(t);if(n>=0)return n}else{var r=Su.toSetString(t);if(wu.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};zr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};zr.prototype.toArray=function(){return this._array.slice()};Hx.ArraySet=zr});var qx=Un(Gx=>{"use strict";var Vx=ja();function ZI(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||Vx.compareByGeneratedPositionsInflated(e,t)<=0}function Ha(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Ha.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};Ha.prototype.add=function(t){ZI(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Ha.prototype.toArray=function(){return this._sorted||(this._array.sort(Vx.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};Gx.MappingList=Ha});var Kx=Un(Yx=>{"use strict";var ds=Nx(),Bt=ja(),Wa=Wx().ArraySet,eF=qx().MappingList;function Qn(e){e||(e={}),this._file=Bt.getArg(e,"file",null),this._sourceRoot=Bt.getArg(e,"sourceRoot",null),this._skipValidation=Bt.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Bt.getArg(e,"ignoreInvalidMapping",!1),this._sources=new Wa,this._names=new Wa,this._mappings=new eF,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=Bt.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=Bt.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=Bt.getArg(t,"generated"),r=Bt.getArg(t,"original",null),o=Bt.getArg(t,"source",null),i=Bt.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=Bt.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Bt.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Bt.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=Bt.relative(i,o));var s=new Wa,a=new Wa;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=Bt.join(r,u.source)),i!=null&&(u.source=Bt.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=Bt.join(r,u)),i!=null&&(u=Bt.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,m=f.length;d<m;d++){if(c=f[d],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(d>0){if(!Bt.compareByGeneratedPositionsInflated(c,f[d-1]))continue;u+=","}u+=ds.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(p=this._sources.indexOf(c.source),u+=ds.encode(p-s),s=p,u+=ds.encode(c.originalLine-1-o),o=c.originalLine-1,u+=ds.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=ds.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=Bt.relative(n,r));var o=Bt.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())};Yx.SourceMapGenerator=Qn});var qw=Un((zee,Gw)=>{"use strict";var jw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,rO=/\n/g,oO=/^\s*/,iO=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,sO=/^:\s*/,aO=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,lO=/^[;\s]*/,cO=/^\s+|\s+$/g,uO=`
|
|
3
|
+
`,Hw="/",Ww="*",Wo="",pO="comment",dO="declaration";function fO(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(m){var S=m.match(rO);S&&(n+=S.length);var T=m.lastIndexOf(uO);r=~T?m.length-T:r+m.length}function i(){var m={line:n,column:r};return function(S){return S.position=new s(m),c(),S}}function s(m){this.start=m,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(m){var S=new Error(t.source+":"+n+":"+r+": "+m);if(S.reason=m,S.filename=t.source,S.line=n,S.column=r,S.source=e,!t.silent)throw S}function u(m){var S=m.exec(e);if(S){var T=S[0];return o(T),e=e.slice(T.length),S}}function c(){u(oO)}function l(m){var S;for(m=m||[];S=p();)S!==!1&&m.push(S);return m}function p(){var m=i();if(!(Hw!=e.charAt(0)||Ww!=e.charAt(1))){for(var S=2;Wo!=e.charAt(S)&&(Ww!=e.charAt(S)||Hw!=e.charAt(S+1));)++S;if(S+=2,Wo===e.charAt(S-1))return a("End of comment missing");var T=e.slice(2,S-2);return r+=2,o(T),e=e.slice(S),r+=2,m({type:pO,comment:T})}}function f(){var m=i(),S=u(iO);if(S){if(p(),!u(sO))return a("property missing ':'");var T=u(aO),F=m({type:dO,property:Vw(S[0].replace(jw,Wo)),value:T?Vw(T[0].replace(jw,Wo)):Wo});return u(lO),F}}function d(){var m=[];l(m);for(var S;S=f();)S!==!1&&(m.push(S),l(m));return m}return c(),d()}function Vw(e){return e?e.replace(cO,Wo):Wo}Gw.exports=fO});var Yw=Un(Ws=>{"use strict";var gO=Ws&&Ws.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.default=hO;var mO=gO(qw());function hO(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,mO.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 Xw=Un(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.camelCase=void 0;var xO=/^--[a-zA-Z0-9_-]+$/,yO=/-([a-z])/g,bO=/^[^-]+$/,SO=/^-(webkit|moz|ms|o|khtml)-/,wO=/^-(ms)-/,vO=function(e){return!e||bO.test(e)||xO.test(e)},kO=function(e,t){return t.toUpperCase()},Kw=function(e,t){return"".concat(t,"-")},CO=function(e,t){return t===void 0&&(t={}),vO(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(wO,Kw):e=e.replace(SO,Kw),e.replace(yO,kO))};Ul.camelCase=CO});var Jw=Un((Lg,Qw)=>{"use strict";var TO=Lg&&Lg.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},IO=TO(Yw()),FO=Xw();function Pg(e,t){var n={};return!e||typeof e!="string"||(0,IO.default)(e,function(r,o){r&&o&&(n[(0,FO.camelCase)(r,t)]=o)}),n}Pg.default=Pg;Qw.exports=Pg});var Tk=Un((pse,Ck)=>{"use strict";var uc=Object.prototype.hasOwnProperty,kk=Object.prototype.toString,xk=Object.defineProperty,yk=Object.getOwnPropertyDescriptor,bk=function(t){return typeof Array.isArray=="function"?Array.isArray(t):kk.call(t)==="[object Array]"},Sk=function(t){if(!t||kk.call(t)!=="[object Object]")return!1;var n=uc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&uc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||uc.call(t,o)},wk=function(t,n){xk&&n.name==="__proto__"?xk(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},vk=function(t,n){if(n==="__proto__")if(uc.call(t,n)){if(yk)return yk(t,n).value}else return;return t[n]};Ck.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=vk(a,n),o=vk(t,n),a!==o&&(l&&o&&(Sk(o)||(i=bk(o)))?(i?(i=!1,s=r&&bk(r)?r:[]):s=r&&Sk(r)?r:{},wk(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&wk(a,{name:n,newValue:o}));return a}});import pa from"react";import{addons as Cc,types as Zm,experimental_getStatusStore as n1}from"storybook/manager-api";import{AddonPanel as hj}from"storybook/internal/components";import Ft,{useState as N6,useEffect as O6}from"react";import{styled as rr}from"storybook/theming";import ah from"react";import{styled as Ct}from"storybook/theming";var ae="#ea580c",Ic="#c2410c",ma="#ff6b35";var th=Ct.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),nh=Ct.div({flex:1,overflow:"auto",padding:"20px"}),To=Ct.div({marginBottom:"20px"}),Io=Ct.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})),Fo=Ct.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`}})),wn=Ct.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"}})),rh=Ct(wn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),ha=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"}}),Hn=Ct.button(({theme:e})=>({...ha(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),_t=Ct.button(({theme:e})=>({...ha(e),backgroundColor:ae,color:e.color.inverseText,boxShadow:`0 2px 4px ${ae}4d`,"&:hover:not(:disabled)":{backgroundColor:Ic,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ae}66`}})),Wn=Ct.button(({theme:e})=>({...ha(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),oh=Ct.button(({theme:e})=>({...ha(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),fn=Ct.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"}})),Fc=Ct.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"}})),Xr=Ct.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}})),Qr=Ct(Fo)(({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"})),Cj=Ct.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),ih=Ct.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})),Tj=Ct.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})),Ec=Ct.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})),Ij=Ct.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%)"}}})),sh=Ct.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}}),Fj=Ct.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),Ej=Ct.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),Aj=Ct.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var Ac=({header:e,children:t,footer:n})=>ah.createElement(th,null,e,ah.createElement(nh,null,t),n);import p1 from"react";import{styled as d1}from"storybook/theming";var f1=d1.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})),Pc=({toolbar:e})=>p1.createElement(f1,null,e);import _j from"react";import{styled as xa}from"storybook/theming";var jj=xa.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})),Hj=xa.div({display:"flex",flex:1}),Wj=xa(Xr)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),Vj=xa.div({display:"flex",gap:"8px",alignItems:"center"});import gn,{useState as Ph,useCallback as Lh,useEffect as Mh}from"react";import{styled as Jr}from"storybook/theming";import ut,{useEffect as Th}from"react";import{styled as $t}from"storybook/theming";ke();Re();Me();nt();var eT=$t.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),tT=$t.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})),nT=$t.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),rT=$t.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),oT=$t.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:ae,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),iT=$t.div({display:"flex",gap:"8px"}),Ih=$t(fn)({fontSize:"18px"}),sT=$t.div({padding:"20px 16px"}),aT=$t.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),lT=$t.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),cT=$t.div({fontSize:"28px",fontWeight:700}),uT=$t.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),pT=$t.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),dT=$t.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),fT=$t.div({display:"flex",alignItems:"center",gap:"8px"}),gT=$t.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),mT=$t.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:ae,color:e.color.inverseText})),hT=$t.button(({theme:e})=>({background:"none",border:"none",color:ae,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),xT=$t.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),yT=$t.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"?ae:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),bT=30*1e3,Fh=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=Ie(),{featureFlags:s}=se(),a=s.showCosts,u=r,c=!r&&t,l=async(m=!1)=>{if(!t)return;let S=o&&Date.now()-o<bT;if(!(!m&&S&&r))try{let T=G(),F=await ne(`${T}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(F.ok){let k=await F.json();i(k)}}catch(T){b.error("Failed to fetch usage:",T)}};Th(()=>{l()},[t]),Th(()=>{let m=()=>{document.visibilityState==="visible"&&(b.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[t]);let p=()=>{n(),e()},f=()=>{let m=G();window.open(`${m}/pricing`,"_blank")},d=()=>{let m=G();window.open(`${m}/pricing#add-credits`,"_blank")};return ut.createElement(ut.Fragment,null,ut.createElement(eT,{onClick:e}),ut.createElement(tT,{onClick:m=>m.stopPropagation()},ut.createElement(nT,null,ut.createElement(rT,null,ut.createElement(oT,null,u?.email?u.email[0].toUpperCase():"U"),ut.createElement("span",null,u?.email||"Loading...")),ut.createElement(iT,null,ut.createElement(Ih,{onClick:p,title:"Sign out"},"\u2192"),ut.createElement(Ih,{onClick:e,title:"Close"},"\xD7"))),ut.createElement(sT,null,c?ut.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?a?ut.createElement(ut.Fragment,null,ut.createElement(aT,null,ut.createElement(lT,null,"Credit Balance"),ut.createElement(cT,null,"$",(u?.creditBalance??0).toFixed(2)),ut.createElement(uT,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),ut.createElement(pT,null,ut.createElement(dT,null,ut.createElement(fT,null,ut.createElement(gT,null,"Current Plan"),ut.createElement(mT,null,u?.plan||"Free")),ut.createElement(hT,{onClick:f},"View detail >")),ut.createElement(xT,null,"~$0.02-0.05 per review depending on complexity"),ut.createElement(yT,{onClick:d,style:{marginTop:"16px"}},"Add Credits"))):ut.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#6b7280",fontSize:"13px"}},"Signed in as ",u?.email||"user"):ut.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};ke();import Qo from"react";import{styled as Eh}from"storybook/theming";Re();ke();nt();Me();var ST=Eh.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),wT=Eh.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),vT={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}},Ah=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=se(),{sessionToken:o}=Ie();return e!=="admin"?null:Qo.createElement(ST,null,Qo.createElement(wT,null,"View as:"),Qo.createElement(rh,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ne(`${G()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>b.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=vT[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Qo.createElement("option",{value:"admin"},"Admin"),Qo.createElement("option",{value:"beta"},"Beta Tester")),t&&Qo.createElement(sh,{variant:"warning"},"Previewing as ",t))};ke();Re();nt();var kT=Jr.div({display:"flex",alignItems:"center"}),Yi=Jr.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),CT=Jr.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),TT=Jr.div({position:"relative"}),IT=Jr.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`}})),FT=Jr.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)"}})),ET=Jr.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)"}}}),AT=Jr.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}})),PT=30*1e3,jc=({onOpenSettings:e})=>{let[t,n]=Ph(!1),[r,o]=Ph(!1),{usageData:i,usageLastFetched:s,setUsageData:a,sessionToken:u}=Ie(),{userRole:c,roleOverride:l,featureFlags:p}=se(),f=l??c;Mh(()=>{(async()=>{if(!(!u||s&&Date.now()-s<PT&&i)){o(!0);try{let z=G(),R=await ne(`${z}/api/addon/account`,{headers:{Authorization:`Bearer ${u}`}});if(R.ok){let O=await R.json();a(O)}}catch(z){console.error("Failed to fetch balance:",z)}finally{o(!1)}}})()},[u,s,i,a]),Mh(()=>{let F=()=>{document.visibilityState==="visible"&&t&&n(!1)},k=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",F),window.addEventListener("focus",k),()=>{document.removeEventListener("visibilitychange",F),window.removeEventListener("focus",k)}},[t]);let d=Lh(()=>{n(!0)},[]),m=Lh(()=>{n(!1)},[]),S=i?.creditBalance??0,T=S<2&&!r;return gn.createElement(kT,null,e&&gn.createElement(Yi,null,gn.createElement(AT,{onClick:e,title:"Settings"},gn.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),u&&c==="admin"&&f==="admin"&&gn.createElement(Yi,null,gn.createElement(Ah,null)),gn.createElement(Yi,null,gn.createElement(CT,null,"v","0.4.1")),u&&p.showCosts&&gn.createElement(Yi,null,gn.createElement(FT,{onClick:d,isLow:T,title:r?"Loading...":i?T?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},r?gn.createElement(ET,null):i?`$${S.toFixed(2)}`:"...")),gn.createElement(Yi,null,gn.createElement(TT,null,gn.createElement(IT,{title:"Account & Usage",onClick:d},i?.email?i.email[0].toUpperCase():"?"),t&&gn.createElement(Fh,{onClose:m}))))};import jr from"react";import{styled as Ai}from"storybook/theming";import It from"react";ke();Me();Re();nt();import{useCallback as Jo,useRef as Bh,useEffect as LT}from"react";var Zr=G();b.debug("[useAuth] Module loaded, APP_URL:",Zr);var Ki=()=>{let e=Bh(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:p,setDeviceCode:f,setUserCode:d,setVerificationUri:m,setPollingInterval:S,setAuthError:T,resetAuth:F}=Ie(),k=Bh(null),z=Jo(async()=>{try{b.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let w;try{w=await ne(`${Zr}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(P){let B=P instanceof Error&&P.message.includes("timed out")?`Cannot reach UI Copilot server at ${Zr}. Is the dashboard running?`:`Connection failed: ${Zr} is not responding.`;T(B),b.error("[useAuth]",B);return}if(!w.ok)throw new Error("Failed to create poll code");let{poll_code:v}=await w.json();b.debug("[useAuth] Got poll_code:",v.substring(0,15)+"...");let A=600,h=700,C=window.screenX+(window.outerWidth-A)/2,I=window.screenY+(window.outerHeight-h)/2;window.open(`${Zr}/addon/auth?poll_code=${v}`,"figma-auth",`width=${A},height=${h},left=${C},top=${I}`),b.debug("[useAuth] Starting OAuth poll for token..."),k.current&&clearInterval(k.current);let y=async()=>{try{let L=await(await fetch(`${Zr}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:v})})).json();L.status==="authorized"&&L.session_token?(b.debug("[useAuth] \u2705 OAuth poll successful! Got token."),k.current&&(clearInterval(k.current),k.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token)):L.status==="expired"&&(b.debug("[useAuth] OAuth poll_code expired"),k.current&&(clearInterval(k.current),k.current=null))}catch(P){b.error("[useAuth] OAuth poll error:",P)}};k.current=setInterval(y,2e3),setTimeout(y,1e3)}catch(w){b.error("[useAuth] OAuth flow error:",w)}},[c]),R=Jo(async()=>{try{let w=await fetch(`${Zr}/api/addon/auth/device`,{method:"POST"});if(!w.ok)throw new Error("Failed to start device code flow");let v=await w.json();f(v.device_code),d(v.user_code),m(v.verification_uri),window.open(v.verification_uri,"_blank"),O(v.device_code,v.interval*1e3)}catch(w){throw b.error("[useAuth] Device code flow error:",w),w}},[f,d,m]),O=Jo((w,v)=>{b.debug("[useAuth] Starting polling. Device code:",w,"Interval:",v),e.current&&clearInterval(e.current);let A=async()=>{try{let C=await(await fetch(`${Zr}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:w})})).json();C.status==="authorized"?(b.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),f(null),d(null),m(null),localStorage.setItem("uicopilot_session_token",C.session_token),c(C.session_token)):(C.status==="expired"||C.status==="denied")&&(b.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),f(null),d(null),m(null))}catch(h){b.error("[useAuth] Polling error:",h)}};e.current=setInterval(A,v),S(v)},[f,d,m,c,S]),E=Jo(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),d(null),m(null),S(null)},[f,d,m,S]),D=Jo(w=>{l(w),localStorage.setItem("uicopilot_api_key",w)},[l]),g=Jo(()=>{F(),e.current&&(clearInterval(e.current),e.current=null)},[F]);return LT(()=>()=>{e.current&&clearInterval(e.current),k.current&&clearInterval(k.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setAuthMethod:p,startOAuth:z,startDeviceCode:R,cancelDeviceCode:E,saveApiKey:D,logout:g}};ke();Me();Re();nt();import{useCallback as ya}from"react";var Xi=G(),ir=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Qe(),{sessionToken:a}=Ie(),u=ya(async()=>{if(!a){b.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),b.debug("[useProjects] Fetching from:",`${Xi}/api/projects`);let f=await ne(`${Xi}/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=ya(async f=>{if(!a)throw new Error("Not authenticated");let d=await ne(`${Xi}/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 m=await d.json();return await u(),m.project},[a,u]),l=ya(async(f,d)=>{if(!a)throw new Error("Not authenticated");let m={};if(d.name!==void 0&&(m.name=d.name),d.description!==void 0&&(m.description=d.description),d.figmaFileUrl!==void 0&&(m.figmaFileId=d.figmaFileUrl||void 0),!(await ne(`${Xi}/api/projects/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(m)})).ok)throw new Error("Failed to update project");await u()},[a,u]),p=ya(async f=>{if(!a)throw new Error("Not authenticated");if(!(await ne(`${Xi}/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}};ke();var Qi=()=>{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}=Ye();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)}};ke();Gc();Qc();import{useCallback as Ms,useRef as pf}from"react";Me();function ka(){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 Ca=BigInt(4294967295),qh=BigInt(32);function ZT(e,t=!1){return t?{h:Number(e&Ca),l:Number(e>>qh&Ca)}:{h:Number(e>>qh&Ca)|0,l:Number(e&Ca)|0}}function Yh(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}=ZT(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Kh=(e,t,n)=>e<<n|t>>>32-n,Xh=(e,t,n)=>t<<n|e>>>32-n,Qh=(e,t,n)=>t<<n-32|e>>>64-n,Jh=(e,t,n)=>e<<n-32|t>>>64-n;function eI(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jc(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Ta(e,t,n=""){let r=eI(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 Zc(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 Zh(e,t){Ta(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 ex(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function eu(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var tI=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function nI(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function rI(e){for(let t=0;t<e.length;t++)e[t]=nI(e[t]);return e}var tu=tI?e=>e:rI;function tx(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 nx=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var oI=BigInt(0),rs=BigInt(1),iI=BigInt(2),sI=BigInt(7),aI=BigInt(256),lI=BigInt(113),ix=[],sx=[],ax=[];for(let e=0,t=rs,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ix.push(2*(5*r+n)),sx.push((e+1)*(e+2)/2%64);let o=oI;for(let i=0;i<7;i++)t=(t<<rs^(t>>sI)*lI)%aI,t&iI&&(o^=rs<<(rs<<BigInt(i))-rs);ax.push(o)}var lx=Yh(ax,!0),cI=lx[0],uI=lx[1],rx=(e,t,n)=>n>32?Qh(e,t,n):Kh(e,t,n),ox=(e,t,n)=>n>32?Jh(e,t,n):Xh(e,t,n);function pI(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=rx(c,l,1)^n[a],f=ox(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=sx[s],u=rx(o,i,a),c=ox(o,i,a),l=ix[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]^=cI[r],e[1]^=uI[r]}eu(n)}var nu=class e{constructor(t,n,r,o=!1,i=24){jn(this,"state");jn(this,"pos",0);jn(this,"posOut",0);jn(this,"finished",!1);jn(this,"state32");jn(this,"destroyed",!1);jn(this,"blockLen");jn(this,"suffix");jn(this,"outputLen");jn(this,"enableXOF",!1);jn(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Jc(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ex(this.state)}clone(){return this._cloneInto()}keccak(){tu(this.state32),pI(this.state32,this.rounds),tu(this.state32),this.posOut=0,this.pos=0}update(t){Zc(this),Ta(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){Zc(this,!1),Ta(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 Jc(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Zh(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,eu(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}},dI=(e,t,n,r={})=>tx(()=>new nu(t,e,n),r);var cx=dI(6,72,64,nx(10));var fI=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,ru=Math.ceil,Yn=Math.floor,kn="[BigNumber Error] ",ux=kn+"Number primitive has more than 15 significant digits: ",sr=1e14,ze=14,ou=9007199254740991,iu=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],eo=1e7,Yt=1e9;function px(e){var t,n,r,o=k.prototype={constructor:k,toString:null,valueOf:null},i=new k(1),s=20,a=4,u=-7,c=21,l=-1e7,p=1e7,f=!1,d=1,m=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},T="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function k(g,w){var v,A,h,C,I,y,P,L,B=this;if(!(B instanceof k))return new k(g,w);if(w==null){if(g&&g._isBigNumber===!0){B.s=g.s,!g.c||g.e>p?B.c=B.e=null:g.e<l?B.c=[B.e=0]:(B.e=g.e,B.c=g.c.slice());return}if((y=typeof g=="number")&&g*0==0){if(B.s=1/g<0?(g=-g,-1):1,g===~~g){for(C=0,I=g;I>=10;I/=10,C++);C>p?B.c=B.e=null:(B.e=C,B.c=[g]);return}L=String(g)}else{if(!fI.test(L=String(g)))return r(B,L,y);B.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(C=L.indexOf("."))>-1&&(L=L.replace(".","")),(I=L.search(/e/i))>0?(C<0&&(C=I),C+=+L.slice(I+1),L=L.substring(0,I)):C<0&&(C=L.length)}else{if(Et(w,2,T.length,"Base"),w==10&&F)return B=new k(g),E(B,s+B.e+1,a);if(L=String(g),y=typeof g=="number"){if(g*0!=0)return r(B,L,y,w);if(B.s=1/g<0?(L=L.slice(1),-1):1,k.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(ux+g)}else B.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(v=T.slice(0,w),C=I=0,P=L.length;I<P;I++)if(v.indexOf(A=L.charAt(I))<0){if(A=="."){if(I>C){C=P;continue}}else if(!h&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){h=!0,I=-1,C=0;continue}return r(B,String(g),y,w)}y=!1,L=n(L,w,10,B.s),(C=L.indexOf("."))>-1?L=L.replace(".",""):C=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,y&&k.DEBUG&&P>15&&(g>ou||g!==Yn(g)))throw Error(ux+B.s*g);if((C=C-I-1)>p)B.c=B.e=null;else if(C<l)B.c=[B.e=0];else{if(B.e=C,B.c=[],I=(C+1)%ze,C<0&&(I+=ze),I<P){for(I&&B.c.push(+L.slice(0,I)),P-=ze;I<P;)B.c.push(+L.slice(I,I+=ze));I=ze-(L=L.slice(I)).length}else I-=P;for(;I--;L+="0");B.c.push(+L)}}else B.c=[B.e=0]}k.clone=px,k.ROUND_UP=0,k.ROUND_DOWN=1,k.ROUND_CEIL=2,k.ROUND_FLOOR=3,k.ROUND_HALF_UP=4,k.ROUND_HALF_DOWN=5,k.ROUND_HALF_EVEN=6,k.ROUND_HALF_CEIL=7,k.ROUND_HALF_FLOOR=8,k.EUCLID=9,k.config=k.set=function(g){var w,v;if(g!=null)if(typeof g=="object"){if(g.hasOwnProperty(w="DECIMAL_PLACES")&&(v=g[w],Et(v,0,Yt,w),s=v),g.hasOwnProperty(w="ROUNDING_MODE")&&(v=g[w],Et(v,0,8,w),a=v),g.hasOwnProperty(w="EXPONENTIAL_AT")&&(v=g[w],v&&v.pop?(Et(v[0],-Yt,0,w),Et(v[1],0,Yt,w),u=v[0],c=v[1]):(Et(v,-Yt,Yt,w),u=-(c=v<0?-v:v))),g.hasOwnProperty(w="RANGE"))if(v=g[w],v&&v.pop)Et(v[0],-Yt,-1,w),Et(v[1],1,Yt,w),l=v[0],p=v[1];else if(Et(v,-Yt,Yt,w),v)l=-(p=v<0?-v:v);else throw Error(kn+w+" cannot be zero: "+v);if(g.hasOwnProperty(w="CRYPTO"))if(v=g[w],v===!!v)if(v)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=v;else throw f=!v,Error(kn+"crypto unavailable");else f=v;else throw Error(kn+w+" not true or false: "+v);if(g.hasOwnProperty(w="MODULO_MODE")&&(v=g[w],Et(v,0,9,w),d=v),g.hasOwnProperty(w="POW_PRECISION")&&(v=g[w],Et(v,0,Yt,w),m=v),g.hasOwnProperty(w="FORMAT"))if(v=g[w],typeof v=="object")S=v;else throw Error(kn+w+" not an object: "+v);if(g.hasOwnProperty(w="ALPHABET"))if(v=g[w],typeof v=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(v))F=v.slice(0,10)=="0123456789",T=v;else throw Error(kn+w+" invalid: "+v)}else throw Error(kn+"Object expected: "+g);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,p],CRYPTO:f,MODULO_MODE:d,POW_PRECISION:m,FORMAT:S,ALPHABET:T}},k.isBigNumber=function(g){if(!g||g._isBigNumber!==!0)return!1;if(!k.DEBUG)return!0;var w,v,A=g.c,h=g.e,C=g.s;e:if({}.toString.call(A)=="[object Array]"){if((C===1||C===-1)&&h>=-Yt&&h<=Yt&&h===Yn(h)){if(A[0]===0){if(h===0&&A.length===1)return!0;break e}if(w=(h+1)%ze,w<1&&(w+=ze),String(A[0]).length==w){for(w=0;w<A.length;w++)if(v=A[w],v<0||v>=sr||v!==Yn(v))break e;if(v!==0)return!0}}}else if(A===null&&h===null&&(C===null||C===1||C===-1))return!0;throw Error(kn+"Invalid BigNumber: "+g)},k.maximum=k.max=function(){return R(arguments,-1)},k.minimum=k.min=function(){return R(arguments,1)},k.random=(function(){var g=9007199254740992,w=Math.random()*g&2097151?function(){return Yn(Math.random()*g)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(v){var A,h,C,I,y,P=0,L=[],B=new k(i);if(v==null?v=s:Et(v,0,Yt),I=ru(v/ze),f)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(I*=2));P<I;)y=A[P]*131072+(A[P+1]>>>11),y>=9e15?(h=crypto.getRandomValues(new Uint32Array(2)),A[P]=h[0],A[P+1]=h[1]):(L.push(y%1e14),P+=2);P=I/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(I*=7);P<I;)y=(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],y>=9e15?crypto.randomBytes(7).copy(A,P):(L.push(y%1e14),P+=7);P=I/7}else throw f=!1,Error(kn+"crypto unavailable");if(!f)for(;P<I;)y=w(),y<9e15&&(L[P++]=y%1e14);for(I=L[--P],v%=ze,I&&v&&(y=iu[ze-v],L[P]=Yn(I/y)*y);L[P]===0;L.pop(),P--);if(P<0)L=[C=0];else{for(C=-1;L[0]===0;L.splice(0,1),C-=ze);for(P=1,y=L[0];y>=10;y/=10,P++);P<ze&&(C-=ze-P)}return B.e=C,B.c=L,B}})(),k.sum=function(){for(var g=1,w=arguments,v=new k(w[0]);g<w.length;)v=v.plus(w[g++]);return v},n=(function(){var g="0123456789";function w(v,A,h,C){for(var I,y=[0],P,L=0,B=v.length;L<B;){for(P=y.length;P--;y[P]*=A);for(y[0]+=C.indexOf(v.charAt(L++)),I=0;I<y.length;I++)y[I]>h-1&&(y[I+1]==null&&(y[I+1]=0),y[I+1]+=y[I]/h|0,y[I]%=h)}return y.reverse()}return function(v,A,h,C,I){var y,P,L,B,N,x,U,H,M=v.indexOf("."),Q=s,ee=a;for(M>=0&&(B=m,m=0,v=v.replace(".",""),H=new k(A),x=H.pow(v.length-M),m=B,H.c=w(Lr(qn(x.c),x.e,"0"),10,h,g),H.e=H.c.length),U=w(v,A,h,I?(y=T,g):(y=g,T)),L=B=U.length;U[--B]==0;U.pop());if(!U[0])return y.charAt(0);if(M<0?--L:(x.c=U,x.e=L,x.s=C,x=t(x,H,Q,ee,h),U=x.c,N=x.r,L=x.e),P=L+Q+1,M=U[P],B=h/2,N=N||P<0||U[P+1]!=null,N=ee<4?(M!=null||N)&&(ee==0||ee==(x.s<0?3:2)):M>B||M==B&&(ee==4||N||ee==6&&U[P-1]&1||ee==(x.s<0?8:7)),P<1||!U[0])v=N?Lr(y.charAt(1),-Q,y.charAt(0)):y.charAt(0);else{if(U.length=P,N)for(--h;++U[--P]>h;)U[P]=0,P||(++L,U=[1].concat(U));for(B=U.length;!U[--B];);for(M=0,v="";M<=B;v+=y.charAt(U[M++]));v=Lr(v,L,y.charAt(0))}return v}})(),t=(function(){function g(A,h,C){var I,y,P,L,B=0,N=A.length,x=h%eo,U=h/eo|0;for(A=A.slice();N--;)P=A[N]%eo,L=A[N]/eo|0,I=U*P+L*x,y=x*P+I%eo*eo+B,B=(y/C|0)+(I/eo|0)+U*L,A[N]=y%C;return B&&(A=[B].concat(A)),A}function w(A,h,C,I){var y,P;if(C!=I)P=C>I?1:-1;else for(y=P=0;y<C;y++)if(A[y]!=h[y]){P=A[y]>h[y]?1:-1;break}return P}function v(A,h,C,I){for(var y=0;C--;)A[C]-=y,y=A[C]<h[C]?1:0,A[C]=y*I+A[C]-h[C];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,h,C,I,y){var P,L,B,N,x,U,H,M,Q,ee,J,Le,Ee,We,st,te,Y,ce=A.s==h.s?1:-1,ie=A.c,ue=h.c;if(!ie||!ie[0]||!ue||!ue[0])return new k(!A.s||!h.s||(ie?ue&&ie[0]==ue[0]:!ue)?NaN:ie&&ie[0]==0||!ue?ce*0:ce/0);for(M=new k(ce),Q=M.c=[],L=A.e-h.e,ce=C+L+1,y||(y=sr,L=Kn(A.e/ze)-Kn(h.e/ze),ce=ce/ze|0),B=0;ue[B]==(ie[B]||0);B++);if(ue[B]>(ie[B]||0)&&L--,ce<0)Q.push(1),N=!0;else{for(We=ie.length,te=ue.length,B=0,ce+=2,x=Yn(y/(ue[0]+1)),x>1&&(ue=g(ue,x,y),ie=g(ie,x,y),te=ue.length,We=ie.length),Ee=te,ee=ie.slice(0,te),J=ee.length;J<te;ee[J++]=0);Y=ue.slice(),Y=[0].concat(Y),st=ue[0],ue[1]>=y/2&&st++;do{if(x=0,P=w(ue,ee,te,J),P<0){if(Le=ee[0],te!=J&&(Le=Le*y+(ee[1]||0)),x=Yn(Le/st),x>1)for(x>=y&&(x=y-1),U=g(ue,x,y),H=U.length,J=ee.length;w(U,ee,H,J)==1;)x--,v(U,te<H?Y:ue,H,y),H=U.length,P=1;else x==0&&(P=x=1),U=ue.slice(),H=U.length;if(H<J&&(U=[0].concat(U)),v(ee,U,J,y),J=ee.length,P==-1)for(;w(ue,ee,te,J)<1;)x++,v(ee,te<J?Y:ue,J,y),J=ee.length}else P===0&&(x++,ee=[0]);Q[B++]=x,ee[0]?ee[J++]=ie[Ee]||0:(ee=[ie[Ee]],J=1)}while((Ee++<We||ee[0]!=null)&&ce--);N=ee[0]!=null,Q[0]||Q.splice(0,1)}if(y==sr){for(B=1,ce=Q[0];ce>=10;ce/=10,B++);E(M,C+(M.e=B+L*ze-1)+1,I,N)}else M.e=L,M.r=+N;return M}})();function z(g,w,v,A){var h,C,I,y,P;if(v==null?v=a:Et(v,0,8),!g.c)return g.toString();if(h=g.c[0],I=g.e,w==null)P=qn(g.c),P=A==1||A==2&&(I<=u||I>=c)?Fa(P,I):Lr(P,I,"0");else if(g=E(new k(g),w,v),C=g.e,P=qn(g.c),y=P.length,A==1||A==2&&(w<=C||C<=u)){for(;y<w;P+="0",y++);P=Fa(P,C)}else if(w-=I+(A===2&&C>I),P=Lr(P,C,"0"),C+1>y){if(--w>0)for(P+=".";w--;P+="0");}else if(w+=C-y,w>0)for(C+1==y&&(P+=".");w--;P+="0");return g.s<0&&h?"-"+P:P}function R(g,w){for(var v,A,h=1,C=new k(g[0]);h<g.length;h++)A=new k(g[h]),(!A.s||(v=Ao(C,A))===w||v===0&&C.s===w)&&(C=A);return C}function O(g,w,v){for(var A=1,h=w.length;!w[--h];w.pop());for(h=w[0];h>=10;h/=10,A++);return(v=A+v*ze-1)>p?g.c=g.e=null:v<l?g.c=[g.e=0]:(g.e=v,g.c=w),g}r=(function(){var g=/^(-?)0([xbo])(?=\w[\w.]*$)/i,w=/^([^.]+)\.$/,v=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(C,I,y,P){var L,B=y?I:I.replace(h,"");if(A.test(B))C.s=isNaN(B)?null:B<0?-1:1;else{if(!y&&(B=B.replace(g,function(N,x,U){return L=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!P||P==L?x:N}),P&&(L=P,B=B.replace(w,"$1").replace(v,"0.$1")),I!=B))return new k(B,L);if(k.DEBUG)throw Error(kn+"Not a"+(P?" base "+P:"")+" number: "+I);C.s=null}C.c=C.e=null}})();function E(g,w,v,A){var h,C,I,y,P,L,B,N=g.c,x=iu;if(N){e:{for(h=1,y=N[0];y>=10;y/=10,h++);if(C=w-h,C<0)C+=ze,I=w,P=N[L=0],B=Yn(P/x[h-I-1]%10);else if(L=ru((C+1)/ze),L>=N.length)if(A){for(;N.length<=L;N.push(0));P=B=0,h=1,C%=ze,I=C-ze+1}else break e;else{for(P=y=N[L],h=1;y>=10;y/=10,h++);C%=ze,I=C-ze+h,B=I<0?0:Yn(P/x[h-I-1]%10)}if(A=A||w<0||N[L+1]!=null||(I<0?P:P%x[h-I-1]),A=v<4?(B||A)&&(v==0||v==(g.s<0?3:2)):B>5||B==5&&(v==4||A||v==6&&(C>0?I>0?P/x[h-I]:0:N[L-1])%10&1||v==(g.s<0?8:7)),w<1||!N[0])return N.length=0,A?(w-=g.e+1,N[0]=x[(ze-w%ze)%ze],g.e=-w||0):N[0]=g.e=0,g;if(C==0?(N.length=L,y=1,L--):(N.length=L+1,y=x[ze-C],N[L]=I>0?Yn(P/x[h-I]%x[I])*y:0),A)for(;;)if(L==0){for(C=1,I=N[0];I>=10;I/=10,C++);for(I=N[0]+=y,y=1;I>=10;I/=10,y++);C!=y&&(g.e++,N[0]==sr&&(N[0]=1));break}else{if(N[L]+=y,N[L]!=sr)break;N[L--]=0,y=1}for(C=N.length;N[--C]===0;N.pop());}g.e>p?g.c=g.e=null:g.e<l&&(g.c=[g.e=0])}return g}function D(g){var w,v=g.e;return v===null?g.toString():(w=qn(g.c),w=v<=u||v>=c?Fa(w,v):Lr(w,v,"0"),g.s<0?"-"+w:w)}return o.absoluteValue=o.abs=function(){var g=new k(this);return g.s<0&&(g.s=1),g},o.comparedTo=function(g,w){return Ao(this,new k(g,w))},o.decimalPlaces=o.dp=function(g,w){var v,A,h,C=this;if(g!=null)return Et(g,0,Yt),w==null?w=a:Et(w,0,8),E(new k(C),g+C.e+1,w);if(!(v=C.c))return null;if(A=((h=v.length-1)-Kn(this.e/ze))*ze,h=v[h])for(;h%10==0;h/=10,A--);return A<0&&(A=0),A},o.dividedBy=o.div=function(g,w){return t(this,new k(g,w),s,a)},o.dividedToIntegerBy=o.idiv=function(g,w){return t(this,new k(g,w),0,1)},o.exponentiatedBy=o.pow=function(g,w){var v,A,h,C,I,y,P,L,B,N=this;if(g=new k(g),g.c&&!g.isInteger())throw Error(kn+"Exponent not an integer: "+D(g));if(w!=null&&(w=new k(w)),y=g.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!g.c||!g.c[0])return B=new k(Math.pow(+D(N),y?g.s*(2-Ia(g)):+D(g))),w?B.mod(w):B;if(P=g.s<0,w){if(w.c?!w.c[0]:!w.s)return new k(NaN);A=!P&&N.isInteger()&&w.isInteger(),A&&(N=N.mod(w))}else{if(g.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||y&&N.c[1]>=24e7:N.c[0]<8e13||y&&N.c[0]<=9999975e7)))return C=N.s<0&&Ia(g)?-0:0,N.e>-1&&(C=1/C),new k(P?1/C:C);m&&(C=ru(m/ze+2))}for(y?(v=new k(.5),P&&(g.s=1),L=Ia(g)):(h=Math.abs(+D(g)),L=h%2),B=new k(i);;){if(L){if(B=B.times(N),!B.c)break;C?B.c.length>C&&(B.c.length=C):A&&(B=B.mod(w))}if(h){if(h=Yn(h/2),h===0)break;L=h%2}else if(g=g.times(v),E(g,g.e+1,1),g.e>14)L=Ia(g);else{if(h=+D(g),h===0)break;L=h%2}N=N.times(N),C?N.c&&N.c.length>C&&(N.c.length=C):A&&(N=N.mod(w))}return A?B:(P&&(B=i.div(B)),w?B.mod(w):C?E(B,m,a,I):B)},o.integerValue=function(g){var w=new k(this);return g==null?g=a:Et(g,0,8),E(w,w.e+1,g)},o.isEqualTo=o.eq=function(g,w){return Ao(this,new k(g,w))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(g,w){return Ao(this,new k(g,w))>0},o.isGreaterThanOrEqualTo=o.gte=function(g,w){return(w=Ao(this,new k(g,w)))===1||w===0},o.isInteger=function(){return!!this.c&&Kn(this.e/ze)>this.c.length-2},o.isLessThan=o.lt=function(g,w){return Ao(this,new k(g,w))<0},o.isLessThanOrEqualTo=o.lte=function(g,w){return(w=Ao(this,new k(g,w)))===-1||w===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,w){var v,A,h,C,I=this,y=I.s;if(g=new k(g,w),w=g.s,!y||!w)return new k(NaN);if(y!=w)return g.s=-w,I.plus(g);var P=I.e/ze,L=g.e/ze,B=I.c,N=g.c;if(!P||!L){if(!B||!N)return B?(g.s=-w,g):new k(N?I:NaN);if(!B[0]||!N[0])return N[0]?(g.s=-w,g):new k(B[0]?I:a==3?-0:0)}if(P=Kn(P),L=Kn(L),B=B.slice(),y=P-L){for((C=y<0)?(y=-y,h=B):(L=P,h=N),h.reverse(),w=y;w--;h.push(0));h.reverse()}else for(A=(C=(y=B.length)<(w=N.length))?y:w,y=w=0;w<A;w++)if(B[w]!=N[w]){C=B[w]<N[w];break}if(C&&(h=B,B=N,N=h,g.s=-g.s),w=(A=N.length)-(v=B.length),w>0)for(;w--;B[v++]=0);for(w=sr-1;A>y;){if(B[--A]<N[A]){for(v=A;v&&!B[--v];B[v]=w);--B[v],B[A]+=sr}B[A]-=N[A]}for(;B[0]==0;B.splice(0,1),--L);return B[0]?O(g,B,L):(g.s=a==3?-1:1,g.c=[g.e=0],g)},o.modulo=o.mod=function(g,w){var v,A,h=this;return g=new k(g,w),!h.c||!g.s||g.c&&!g.c[0]?new k(NaN):!g.c||h.c&&!h.c[0]?new k(h):(d==9?(A=g.s,g.s=1,v=t(h,g,0,3),g.s=A,v.s*=A):v=t(h,g,0,d),g=h.minus(v.times(g)),!g.c[0]&&d==1&&(g.s=h.s),g)},o.multipliedBy=o.times=function(g,w){var v,A,h,C,I,y,P,L,B,N,x,U,H,M,Q,ee=this,J=ee.c,Le=(g=new k(g,w)).c;if(!J||!Le||!J[0]||!Le[0])return!ee.s||!g.s||J&&!J[0]&&!Le||Le&&!Le[0]&&!J?g.c=g.e=g.s=null:(g.s*=ee.s,!J||!Le?g.c=g.e=null:(g.c=[0],g.e=0)),g;for(A=Kn(ee.e/ze)+Kn(g.e/ze),g.s*=ee.s,P=J.length,N=Le.length,P<N&&(H=J,J=Le,Le=H,h=P,P=N,N=h),h=P+N,H=[];h--;H.push(0));for(M=sr,Q=eo,h=N;--h>=0;){for(v=0,x=Le[h]%Q,U=Le[h]/Q|0,I=P,C=h+I;C>h;)L=J[--I]%Q,B=J[I]/Q|0,y=U*L+B*x,L=x*L+y%Q*Q+H[C]+v,v=(L/M|0)+(y/Q|0)+U*B,H[C--]=L%M;H[C]=v}return v?++A:H.splice(0,1),O(g,H,A)},o.negated=function(){var g=new k(this);return g.s=-g.s||null,g},o.plus=function(g,w){var v,A=this,h=A.s;if(g=new k(g,w),w=g.s,!h||!w)return new k(NaN);if(h!=w)return g.s=-w,A.minus(g);var C=A.e/ze,I=g.e/ze,y=A.c,P=g.c;if(!C||!I){if(!y||!P)return new k(h/0);if(!y[0]||!P[0])return P[0]?g:new k(y[0]?A:h*0)}if(C=Kn(C),I=Kn(I),y=y.slice(),h=C-I){for(h>0?(I=C,v=P):(h=-h,v=y),v.reverse();h--;v.push(0));v.reverse()}for(h=y.length,w=P.length,h-w<0&&(v=P,P=y,y=v,w=h),h=0;w;)h=(y[--w]=y[w]+P[w]+h)/sr|0,y[w]=sr===y[w]?0:y[w]%sr;return h&&(y=[h].concat(y),++I),O(g,y,I)},o.precision=o.sd=function(g,w){var v,A,h,C=this;if(g!=null&&g!==!!g)return Et(g,1,Yt),w==null?w=a:Et(w,0,8),E(new k(C),g,w);if(!(v=C.c))return null;if(h=v.length-1,A=h*ze+1,h=v[h]){for(;h%10==0;h/=10,A--);for(h=v[0];h>=10;h/=10,A++);}return g&&C.e+1>A&&(A=C.e+1),A},o.shiftedBy=function(g){return Et(g,-ou,ou),this.times("1e"+g)},o.squareRoot=o.sqrt=function(){var g,w,v,A,h,C=this,I=C.c,y=C.s,P=C.e,L=s+4,B=new k("0.5");if(y!==1||!I||!I[0])return new k(!y||y<0&&(!I||I[0])?NaN:I?C:1/0);if(y=Math.sqrt(+D(C)),y==0||y==1/0?(w=qn(I),(w.length+P)%2==0&&(w+="0"),y=Math.sqrt(+w),P=Kn((P+1)/2)-(P<0||P%2),y==1/0?w="5e"+P:(w=y.toExponential(),w=w.slice(0,w.indexOf("e")+1)+P),v=new k(w)):v=new k(y+""),v.c[0]){for(P=v.e,y=P+L,y<3&&(y=0);;)if(h=v,v=B.times(h.plus(t(C,h,L,1))),qn(h.c).slice(0,y)===(w=qn(v.c)).slice(0,y))if(v.e<P&&--y,w=w.slice(y-3,y+1),w=="9999"||!A&&w=="4999"){if(!A&&(E(h,h.e+s+2,0),h.times(h).eq(C))){v=h;break}L+=4,y+=4,A=1}else{(!+w||!+w.slice(1)&&w.charAt(0)=="5")&&(E(v,v.e+s+2,1),g=!v.times(v).eq(C));break}}return E(v,v.e+s+1,a,g)},o.toExponential=function(g,w){return g!=null&&(Et(g,0,Yt),g++),z(this,g,w,1)},o.toFixed=function(g,w){return g!=null&&(Et(g,0,Yt),g=g+this.e+1),z(this,g,w)},o.toFormat=function(g,w,v){var A,h=this;if(v==null)g!=null&&w&&typeof w=="object"?(v=w,w=null):g&&typeof g=="object"?(v=g,g=w=null):v=S;else if(typeof v!="object")throw Error(kn+"Argument not an object: "+v);if(A=h.toFixed(g,w),h.c){var C,I=A.split("."),y=+v.groupSize,P=+v.secondaryGroupSize,L=v.groupSeparator||"",B=I[0],N=I[1],x=h.s<0,U=x?B.slice(1):B,H=U.length;if(P&&(C=y,y=P,P=C,H-=C),y>0&&H>0){for(C=H%y||y,B=U.substr(0,C);C<H;C+=y)B+=L+U.substr(C,y);P>0&&(B+=L+U.slice(C)),x&&(B="-"+B)}A=N?B+(v.decimalSeparator||"")+((P=+v.fractionGroupSize)?N.replace(new RegExp("\\d{"+P+"}\\B","g"),"$&"+(v.fractionGroupSeparator||"")):N):B}return(v.prefix||"")+A+(v.suffix||"")},o.toFraction=function(g){var w,v,A,h,C,I,y,P,L,B,N,x,U=this,H=U.c;if(g!=null&&(y=new k(g),!y.isInteger()&&(y.c||y.s!==1)||y.lt(i)))throw Error(kn+"Argument "+(y.isInteger()?"out of range: ":"not an integer: ")+D(y));if(!H)return new k(U);for(w=new k(i),L=v=new k(i),A=P=new k(i),x=qn(H),C=w.e=x.length-U.e-1,w.c[0]=iu[(I=C%ze)<0?ze+I:I],g=!g||y.comparedTo(w)>0?C>0?w:L:y,I=p,p=1/0,y=new k(x),P.c[0]=0;B=t(y,w,0,1),h=v.plus(B.times(A)),h.comparedTo(g)!=1;)v=A,A=h,L=P.plus(B.times(h=L)),P=h,w=y.minus(B.times(h=w)),y=h;return h=t(g.minus(v),A,0,1),P=P.plus(h.times(L)),v=v.plus(h.times(A)),P.s=L.s=U.s,C=C*2,N=t(L,A,C,a).minus(U).abs().comparedTo(t(P,v,C,a).minus(U).abs())<1?[L,A]:[P,v],p=I,N},o.toNumber=function(){return+D(this)},o.toPrecision=function(g,w){return g!=null&&Et(g,1,Yt),z(this,g,w,2)},o.toString=function(g){var w,v=this,A=v.s,h=v.e;return h===null?A?(w="Infinity",A<0&&(w="-"+w)):w="NaN":(g==null?w=h<=u||h>=c?Fa(qn(v.c),h):Lr(qn(v.c),h,"0"):g===10&&F?(v=E(new k(v),s+h+1,a),w=Lr(qn(v.c),v.e,"0")):(Et(g,2,T.length,"Base"),w=n(Lr(qn(v.c),h,"0"),10,g,A,!0)),A<0&&v.c[0]&&(w="-"+w)),w},o.valueOf=o.toJSON=function(){return D(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&k.set(e),k}function Kn(e){var t=e|0;return e>0||e===t?t:t-1}function qn(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=ze-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function Ao(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 Et(e,t,n,r){if(e<t||e>n||e!==Yn(e))throw Error(kn+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Ia(e){var t=e.c.length-1;return Kn(e.e/ze)==t&&e.c[t]%2!=0}function Fa(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Lr(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 gI=px(),dx=gI;var mI=24,os=32,hI=()=>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,au=hI(),su=(e=4,t=au)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function xI(e){let t=new dx(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var gx=(e="")=>{let t=new TextEncoder;return xI(cx(t.encode(e))).toString(36).slice(1)},fx=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),yI=e=>fx[Math.floor(e()*fx.length)],bI=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=au}={})=>{let n=Object.keys(e).toString(),r=n.length?n+su(os,t):su(os,t);return gx(r).substring(0,os)},SI=e=>()=>e++,wI=476782367,mx=({random:e=au,counter:t=SI(Math.floor(e()*wI)),length:n=mI,fingerprint:r=bI({random:e})}={})=>{if(n>os)throw new Error(`Length must be between 2 and ${os}. Received: ${n}`);return function(){let i=yI(e),s=Date.now().toString(36),a=t().toString(36),u=su(n,e),c=`${s+u+a+r}`;return`${i+gx(c).substring(1,n)}`}},to=vI(mx);function vI(e){let t;return()=>(t||(t=e()),t())}var xM=ga(yx());function Mt(e){return e>=48&&e<=57}function Tn(e){return Mt(e)||e>=65&&e<=70||e>=97&&e<=102}function Aa(e){return e>=65&&e<=90}function TI(e){return e>=97&&e<=122}function II(e){return Aa(e)||TI(e)}function FI(e){return e>=128}function Ea(e){return II(e)||FI(e)||e===95}function Pa(e){return Ea(e)||Mt(e)||e===45}function EI(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function is(e){return e===10||e===13||e===12}function vr(e){return is(e)||e===32||e===9}function Cn(e,t){return!(e!==92||is(t)||t===0)}function ti(e,t,n){return e===45?Ea(t)||t===45||Cn(t,n):Ea(e)?!0:e===92?Cn(e,t):!1}function La(e,t,n){return e===43||e===45?Mt(t)?2:t===46&&Mt(n)?3:0:e===46?Mt(t)?2:0:Mt(e)?1:0}function Ma(e){return e===65279||e===65534?1:0}var lu=new Array(128),AI=128,ss=130,cu=131,Ba=132,uu=133;for(let e=0;e<lu.length;e++)lu[e]=vr(e)&&ss||Mt(e)&&cu||Ea(e)&&Ba||EI(e)&&uu||e||AI;function Da(e){return e<128?lu[e]:Ba}function ni(e,t){return t<e.length?e.charCodeAt(t):0}function Ra(e,t,n){return n===13&&ni(e,t+1)===10?2:1}function Mr(e,t,n){let r=e.charCodeAt(t);return Aa(r)&&(r=r|32),r===n}function Br(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(Aa(s)&&(s=s|32),s!==i)return!1}return!0}function bx(e,t){for(;t>=0&&vr(e.charCodeAt(t));t--);return t+1}function as(e,t){for(;t<e.length&&vr(e.charCodeAt(t));t++);return t}function pu(e,t){for(;t<e.length&&Mt(e.charCodeAt(t));t++);return t}function Dr(e,t){if(t+=2,Tn(ni(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Tn(ni(e,t));t++);let n=ni(e,t);vr(n)&&(t+=Ra(e,t,n))}return t}function ls(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Pa(n)){if(Cn(n,ni(e,t+1))){t=Dr(e,t)-1;continue}break}}return t}function Po(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),Mt(n)&&(t=pu(e,t+1),n=e.charCodeAt(t)),n===46&&Mt(e.charCodeAt(t+1))&&(t+=2,t=pu(e,t)),Mr(e,t,101)){let r=0;n=e.charCodeAt(t+1),(n===45||n===43)&&(r=1,n=e.charCodeAt(t+2)),Mt(n)&&(t=pu(e,t+1+r+1))}return t}function za(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}Cn(n,ni(e,t+1))&&(t=Dr(e,t))}return t}function Na(e){if(e.length===1&&!Tn(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 ri=["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 oi(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Sx=10,PI=12,wx=13;function vx(e){let t=e.source,n=t.length,r=t.length>0?Ma(t.charCodeAt(0)):0,o=oi(e.lines,n),i=oi(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===Sx||c===wx||c===PI)&&(c===wx&&u+1<n&&t.charCodeAt(u+1)===Sx&&(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 Oa=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||vx(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||vx(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 ar=16777215,lr=24,cs=1,$a=2,no=new Uint8Array(32);no[2]=22;no[21]=22;no[19]=20;no[23]=24;var cr=new Uint8Array(32);cr[2]=cs;cr[21]=cs;cr[19]=cs;cr[23]=cs;cr[22]=$a;cr[20]=$a;cr[24]=$a;function kx(e,t,n){return e<t?t:e>n?n:e}var _a=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=oi(this.offsetAndType,t.length+1),i=oi(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<<lr|f,a===-1&&(a=p),i[d]=c,l===u){let m=i[c];i[c]=d,c=m,u=no[o[m]>>lr]}else this.isBlockOpenerTokenType(l)&&(c=d,u=no[l])}),o[s]=0<<lr|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]>>lr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>lr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&ar:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>lr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?Br(this.source,this.offsetAndType[t-1]&ar,this.offsetAndType[t]&ar,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&ar:this.offsetAndType[this.tokenCount]&ar:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[kx(t,0,this.tokenCount)]&ar}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[kx(t,0,this.tokenCount)]>>lr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return cr[t]===cs}isBlockCloserTokenType(t){return cr[t]===$a}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(cr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return no[n]===o?r:-1}else if(cr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return no[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]&ar,n=this.offsetAndType[n],this.tokenType=n>>lr,this.tokenEnd=n&ar):(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>>lr,this.tokenEnd=t&ar):(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]&ar:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>lr)&&(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&ar,a=i>>lr;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:ri[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}};function ro(e,t){function n(p){return p<a?e.charCodeAt(p):0}function r(){if(c=Po(e,c),ti(n(c),n(c+1),n(c+2))){l=12,c=ls(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let p=c;if(c=ls(e,c),Br(e,p,c,"url")&&n(c)===40){if(c=as(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(Da(f)){case p:c++;return;case ss:if(is(f)){c+=Ra(e,c,f),l=6;return}break;case 92:if(c===e.length-1)break;let d=n(c+1);is(d)?c+=Ra(e,c+1,d):Cn(f,d)&&(c=Dr(e,c)-1);break}}}function s(){for(l=7,c=as(e,c);c<e.length;c++){let p=e.charCodeAt(c);switch(Da(p)){case 41:c++;return;case ss:if(c=as(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=za(e,c),l=8;return;case 34:case 39:case 40:case uu:c=za(e,c),l=8;return;case 92:if(Cn(p,n(c+1))){c=Dr(e,c)-1;break}c=za(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=Ma(n(0)),c=u,l;for(;c<a;){let p=e.charCodeAt(c);switch(Da(p)){case ss:l=13,c=as(e,c+1);break;case 34:i();break;case 35:Pa(n(c+1))||Cn(n(c+1),n(c+2))?(l=4,c=ls(e,c+1)):(l=9,c++);break;case 39:i();break;case 40:l=21,c++;break;case 41:l=22,c++;break;case 43:La(p,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:La(p,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):ti(p,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:La(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:ti(n(c+1),n(c+2),n(c+3))?(l=3,c=ls(e,c+1)):(l=9,c++);break;case 91:l=19,c++;break;case 92:Cn(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 cu:r();break;case Ba:o();break;default:l=9,c++}t(l,u,u=c)}}var ii=null,Rn=class e{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return e.createItem(t)}allocateCursor(t,n){let r;return ii!==null?(r=ii,ii=ii.cursor,r.prev=t,r.next=n,r.cursor=this.cursor):r={prev:t,next:n,cursor:this.cursor},this.cursor=r,r}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=ii,ii=t}updateCursors(t,n,r,o){let{cursor:i}=this;for(;i!==null;)i.prev===t&&(i.prev=n),i.next===r&&(i.next=o),i=i.cursor}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data}get size(){let t=0;for(let n=this.head;n!==null;n=n.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let n=null;this.head=null;for(let r of t){let o=e.createItem(r);n!==null?n.next=o:this.head=o,o.prev=n,n=o}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,n=this){let r=this.allocateCursor(null,this.head);for(;r.next!==null;){let o=r.next;r.next=o.next,t.call(n,o.data,o,this)}this.releaseCursor()}forEachRight(t,n=this){let r=this.allocateCursor(this.tail,null);for(;r.prev!==null;){let o=r.prev;r.prev=o.prev,t.call(n,o.data,o,this)}this.releaseCursor()}reduce(t,n,r=this){let o=this.allocateCursor(null,this.head),i=n,s;for(;o.next!==null;)s=o.next,o.next=s.next,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}reduceRight(t,n,r=this){let o=this.allocateCursor(this.tail,null),i=n,s;for(;o.prev!==null;)s=o.prev,o.prev=s.prev,i=t.call(r,i,s.data,s,this);return this.releaseCursor(),i}some(t,n=this){for(let r=this.head;r!==null;r=r.next)if(t.call(n,r.data,r,this))return!0;return!1}map(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)r.appendData(t.call(n,o.data,o,this));return r}filter(t,n=this){let r=new e;for(let o=this.head;o!==null;o=o.next)t.call(n,o.data,o,this)&&r.appendData(o.data);return r}nextUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(null,t);for(;o.next!==null;){let i=o.next;if(o.next=i.next,n.call(r,i.data,i,this))break}this.releaseCursor()}prevUntil(t,n,r=this){if(t===null)return;let o=this.allocateCursor(t,null);for(;o.prev!==null;){let i=o.prev;if(o.prev=i.prev,n.call(r,i.data,i,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new e;for(let n of this)t.appendData(n);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(e.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(e.createItem(t))}insert(t,n=null){if(n!==null)if(this.updateCursors(n.prev,t,n,t),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=t,n.prev=t,t.next=n,this.updateCursors(null,t)}else n.prev.next=t,t.prev=n.prev,n.prev=t,t.next=n;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,n){return this.insert(e.createItem(t),n)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(t.next!==null)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(e.createItem(t))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(e.createItem(t))}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,n){return t.head===null?this:(n!=null?(this.updateCursors(n.prev,t.tail,n,t.head),n.prev!==null?(n.prev.next=t.head,t.head.prev=n.prev):this.head=t.head,n.prev=t.tail,t.tail.next=n):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,n){"head"in n?this.insertList(n,t):this.insert(n,t),this.remove(t)}};function Mo(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 du=100,Cx=60,Tx=" ";function Ix({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(m,S){return c.slice(m,S).map((T,F)=>String(m+F+1).padStart(f)+" |"+T).join(`
|
|
5
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+=(
|
|
7
|
-
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function
|
|
8
|
-
`+
|
|
9
|
-
`,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=
|
|
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+=(Tx.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>du&&(d=n-Cx+3,n=Cx-2);for(let m=l;m<=p;m++)m>=0&&m<c.length&&(c[m]=c[m].replace(/\t/g,Tx),c[m]=(d>0&&c[m].length>d?"\u2026":"")+c[m].substr(d,du-2)+(c[m].length>d+du-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 fu(e,t,n,r,o,i=1,s=1){return Object.assign(Mo("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return Ix({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
|
|
8
|
+
`+Ix({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}function Fx(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 si=()=>{},LI=33,MI=35,gu=59,Ex=123,Ax=0,BI={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}},DI={createList(){return new Rn},createSingleNodeList(e){return new Rn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}};function RI(e){return function(){return this[e]()}}function mu(e){let t=Object.create(null);for(let n of Object.keys(e)){let r=e[n],o=r.parse||r;o&&(t[n]=o)}return t}function zI(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:mu(e.atrule),pseudo:mu(e.pseudo),node:mu(e.node)};for(let[n,r]of Object.entries(e.parseContext))switch(typeof r){case"function":t.context[n]=r;break;case"string":t.context[n]=RI(r);break}return{config:t,...t,...t.node}}function Px(e){let t="",n="<unknown>",r=!1,o=si,i=!1,s=new Oa,a=Object.assign(new _a,zI(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Fx,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Ex?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Ex||l===gu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===LI||l===gu?1:0},consumeUntilSemicolonIncluded(l){return l===gu?2:0},createList:si,createSingleNodeList:si,getFirstListNode:si,getLastListNode:si,parseWithFallback(l,p){let f=this.tokenIndex;try{return l.call(this)}catch(d){if(i)throw d;this.skip(f-this.tokenIndex);let m=p.call(this);return i=!0,o(d,m),i=!1,m}},lookupNonWSType(l){let p;do if(p=this.lookupType(l++),p!==13&&p!==25)return p;while(p!==Ax);return Ax},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 Mr(t,l,p)},cmpStr(l,p,f){return Br(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,Po(t,this.tokenStart));return this.eat(l),p},eat(l){if(this.tokenType!==l){let p=ri[l].slice(0,-6).replace(/-/g," ").replace(/^./,m=>m.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(MI)&&(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(bx(t,t.length-1)):s.getLocation(this.tokenStart);throw new fu(l||"Unexpected input",t,f.offset,f.line,f.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>ri[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,ro),s.setSource(t,p.offset,p.line,p.column),n=p.filename||"<unknown>",r=!!p.positions,o=typeof p.onParseError=="function"?p.onParseError:si,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:m,onToken:S}=p;if(!(f in a.context))throw new Error("Unknown context `"+f+"`");Object.assign(a,d?DI:BI),Array.isArray(S)?a.forEachToken((F,k,z)=>{S.push({type:F,start:k,end:z})}):typeof S=="function"&&a.forEachToken(S.bind(u())),typeof m=="function"&&a.forEachToken((F,k,z)=>{if(F===25){let R=a.getLocation(k,z),O=Br(t,z-2,z,"*/")?t.slice(k+2,z-2):t.slice(k+2,z);m(O,R)}});let T=a.context[f].call(a,p);return a.eof||a.error(),T},{SyntaxError:fu,config:a.config})}var Qx=ga(Kx(),1),Xx=new Set(["Atrule","Selector","Declaration"]);function Jx(e){let t=new Qx.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&&Xx.has(f.type)){let d=f.loc.start.line,m=f.loc.start.column-1;(r.line!==d||r.column!==m)&&(r.line=d,r.column=m,n.line=s,n.column=a,u&&(u=!1,(n.line!==o.line||n.column!==o.column)&&t.addMapping(i)),u=!0,t.addMapping({source:f.loc.source,original:r,generated:n}))}c.call(this,f),u&&Xx.has(f.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(f,d,m){for(let S=0;S<f.length;S++)f.charCodeAt(S)===10?(s++,a=0):a++;l(f,d,m)};let p=e.result;return e.result=function(){return u&&t.addMapping(i),{css:p(),map:t}},e}var Va={};be(Va,{safe:()=>ku,spec:()=>oF});var tF=43,nF=45,vu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),Zx=[[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],["/","*"]],rF=Zx.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 ey(e){let t=new Set(e.map(([n,r])=>vu(n)<<16|vu(r)));return function(n,r,o){let i=vu(r,o),s=o.charCodeAt(0),a=s===nF&&r!==1&&r!==2&&r!==15||s===tF?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var oF=ey(Zx),ku=ey(rF);var iF=92;function sF(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 ty(e){let t=new Map;for(let[n,r]of Object.entries(e.node))typeof(r.generate||r)=="function"&&t.set(n,r.generate||r);return function(n,r){let o="",i=0,s={node(u){if(t.has(u.type))t.get(u.type).call(a,u);else throw new Error("Unknown node type: "+u.type)},tokenBefore:ku,token(u,c,l){i=this.tokenBefore(i,u,c),!l&&i&1&&this.emit(" ",13,!0),this.emit(c,u,!1),u===9&&c.charCodeAt(0)===iF&&this.emit(`
|
|
9
|
+
`,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=Jx(s)),r.mode in Va&&(s.tokenBefore=Va[r.mode]));let a={node:u=>s.node(u),children:sF,token:(u,c)=>s.token(u,c),tokenize:u=>ro(u,(c,l,p)=>{s.token(c,u.slice(l,p),l!==0)})};return s.node(n),s.result()}}function ny(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof Rn)&&(n.children=new Rn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof Rn&&(n.children=n.children.toArray())}}),t}}}var{hasOwnProperty:Cu}=Object.prototype,fs=function(){};function ry(e){return typeof e=="function"?e:fs}function oy(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function aF(e,t){let n=t.structure,r=[];for(let o in n){if(Cu.call(n,o)===!1)continue;let i=n[o],s={name:o,type:!1,nullable:!1};Array.isArray(i)||(i=[i]);for(let a of i)a===null?s.nullable=!0:typeof a=="string"?s.type="node":Array.isArray(a)&&(s.type="list");s.type&&r.push(s)}return r.length?{context:t.walkContext,fields:r}:null}function lF(e){let t={};for(let n in e.node)if(Cu.call(e.node,n)){let r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=aF(n,r)}return t}function iy(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 sy({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 ay(e){let t=lF(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Cu.call(t,c)&&t[c]!==null&&(n[c]=iy(t[c],!1),r[c]=iy(t[c],!0));let s=sy(n),a=sy(r),u=function(c,l){function p(F,k,z){let R=f.call(T,F,k,z);return R===o?!0:R===i?!1:!!(m.hasOwnProperty(F.type)&&m[F.type](F,T,p,S)||d.call(T,F,k,z)===o)}let f=fs,d=fs,m=n,S=(F,k,z,R)=>F||p(k,z,R),T={break:o,skip:i,root:c,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")f=l;else if(l&&(f=ry(l.enter),d=ry(l.leave),l.reverse&&(m=r),l.visit)){if(s.hasOwnProperty(l.visit))m=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");f=oy(f,l.visit),d=oy(d,l.visit)}if(f===fs&&d===fs)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,m){if(l.call(this,f,d,m))return p=f,o}),p},u.findLast=function(c,l){let p=null;return u(c,{reverse:!0,enter(f,d,m){if(l.call(this,f,d,m))return p=f,o}}),p},u.findAll=function(c,l){let p=[];return u(c,function(f,d,m){l.call(this,f,d,m)&&p.push(f)}),p},u}function cF(e){return e}function uF(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 pF(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 dF(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>Ga(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function Ga(e,t,n,r){let o;switch(e.type){case"Group":o=dF(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return Ga(e.term,t,n,r)+t(uF(e),e);case"Boolean":o="<boolean-expr["+Ga(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(pF(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 li(e,t){let n=cF,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),Ga(e,n,r,o)}var ly={offset:0,line:1,column:1};function fF(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=qa(i||t,"end")||gs(ly,c),p=gs(l)):(l=qa(i,"start")||gs(qa(t,"start")||ly,c.slice(0,s)),p=qa(i,"end")||gs(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:p}}function qa(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?gs(n):n:null}function gs({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 ci=function(e,t){let n=Mo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},cy=function(e,t,n,r){let o=Mo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=fF(r,n);return o.rawMessage=e,o.syntax=t?li(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=a,o.message=e+`
|
|
10
10
|
syntax: `+o.syntax+`
|
|
11
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
|
|
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 Ya=new Map,ui=new Map,Ka=45,Xa=gF,Tu=mF;function Qa(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===Ka&&e.charCodeAt(t+1)===Ka}function uy(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===Ka&&e.charCodeAt(t+1)!==Ka){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function gF(e){if(Ya.has(e))return Ya.get(e);let t=e.toLowerCase(),n=Ya.get(t);if(n===void 0){let r=Qa(t,0),o=r?"":uy(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return Ya.set(e,n),n}function mF(e){if(ui.has(e))return ui.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=Qa(t,n.length);if(!r&&(t=t.toLowerCase(),ui.has(t))){let a=ui.get(t);return ui.set(e,a),a}let o=r?"":uy(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 ui.set(e,s),s}var pi=["initial","inherit","unset","revert","revert-layer"];var hs=43,kr=45,Iu=110,di=!0,xF=!1;function Eu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function ms(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function oo(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===hs||o===kr){if(n)return 0;t++}for(;t<e.value.length;t++)if(!Mt(e.value.charCodeAt(t)))return 0;return r+1}function Fu(e,t,n){let r=!1,o=ms(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(Eu(e,hs)||Eu(e,kr)){if(r=!0,o=ms(n(++o),o,n),e=n(o),e===null||e.type!==10)return 0}else return t;if(!r){let i=e.value.charCodeAt(0);if(i!==hs&&i!==kr)return 0}return oo(e,r?0:1,r,o)}function Au(e,t){let n=0;if(!e)return 0;if(e.type===10)return oo(e,0,xF,n);if(e.type===1&&e.value.charCodeAt(0)===kr){if(!Mr(e.value,1,Iu))return 0;switch(e.value.length){case 2:return Fu(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==kr?0:(n=ms(t(++n),n,t),e=t(n),oo(e,0,di,n));default:return e.value.charCodeAt(2)!==kr?0:oo(e,3,di,n)}}else if(e.type===1||Eu(e,hs)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Mr(e.value,0,Iu))return 0;switch(e.value.length){case 1:return Fu(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==kr?0:(n=ms(t(++n),n,t),e=t(n),oo(e,0,di,n));default:return e.value.charCodeAt(1)!==kr?0:oo(e,2,di,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===hs||r===kr?1:0,i=o;for(;i<e.value.length&&Mt(e.value.charCodeAt(i));i++);return i===o||!Mr(e.value,i,Iu)?0:i+1===e.value.length?Fu(t(++n),n,t):e.value.charCodeAt(i+1)!==kr?0:i+2===e.value.length?(n=ms(t(++n),n,t),e=t(n),oo(e,0,di,n)):oo(e,i+2,di,n)}return 0}var yF=43,py=45,dy=63,bF=117;function Pu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function SF(e,t){return e.value.charCodeAt(0)===t}function xs(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===py&&n&&r!==0)return xs(e,t+r+1,!1),6;if(!Tn(i)||++r>6)return 0}return r}function Ja(e,t,n){if(!e)return 0;for(;Pu(n(t),dy);){if(++e>6)return 0;t++}return t}function Lu(e,t){let n=0;if(e===null||e.type!==1||!Mr(e.value,0,bF)||(e=t(++n),e===null))return 0;if(Pu(e,yF))return e=t(++n),e===null?0:e.type===1?Ja(xs(e,0,!0),++n,t):Pu(e,dy)?Ja(1,++n,t):0;if(e.type===10){let r=xs(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!SF(e,py)||!xs(e,1,!1)?0:n+1:Ja(r,n,t))}return e.type===12?Ja(xs(e,1,!0),++n,t):0}var Mu=["calc(","-moz-calc(","-webkit-calc("],Bu=["min(","max(","clamp("],Du=["round(","mod(","rem("],wF=["sin(","cos(","tan("],vF=["asin(","acos(","atan(","atan2("],kF=["pow(","sqrt(","log(","exp(","sign("],Ru=["hypot("],zu=["abs("],fy=[...Mu,...Bu,...Du,...wF,...kF,...Ru,...zu],CF=[...Mu,...Bu,...Du,...Ru,...zu],Nr=[...Mu,...Bu,...Du,...vF,...Ru,...zu],Nu=new Map([[2,22],[21,22],[19,20],[23,24]]);function pr(e,t){return t<e.length?e.charCodeAt(t):0}function gy(e,t){return Br(e,0,e.length,t)}function my(e,t){for(let n=0;n<t.length;n++)if(gy(e,t[n]))return!0;return!1}function hy(e,t){return t!==e.length-2?!1:pr(e,t)===92&&Mt(pr(e,t+1))}function Za(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 TF(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=Nu.get(e.type);break}o++}while(e=t(o));return o}function Jn(e,t){return function(n,r,o){return n===null?0:n.type===2&&my(n.value,t)?TF(n,r):e(n,r,o)}}function St(e){return function(t){return t===null||t.type!==e?0:1}}function IF(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return my(t,pi)||gy(t,"default")?0:1}function xy(e){return e===null||e.type!==1||pr(e.value,0)!==45||pr(e.value,1)!==45?0:1}function FF(e){return!xy(e)||e.value==="--"?0:1}function EF(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(!Tn(pr(e.value,n)))return 0;return 1}function AF(e){return e===null||e.type!==4||!ti(pr(e.value,1),pr(e.value,2),pr(e.value,3))?0:1}function PF(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=Nu.get(e.type);break}o++}while(e=t(o));return o}function LF(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=Nu.get(e.type);break}o++}while(e=t(o));return o}function Or(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Po(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!hy(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return Za(r,t.value,o)?0:1}}function MF(e,t,n){return e===null||e.type!==11||Za(n,e.value,e.value.length-1)?0:1}function yy(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 BF(e,t,n){if(e===null)return 0;let r=Po(e.value,0);return!(r===e.value.length)&&!hy(e.value,r)||Za(n,e.value,r)?0:1}function DF(e,t,n){if(e===null||e.type!==10)return 0;let r=pr(e.value,0)===43||pr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!Mt(pr(e.value,r)))return 0;return Za(n,e.value,r)?0:1}var RF={"ident-token":St(1),"function-token":St(2),"at-keyword-token":St(3),"hash-token":St(4),"string-token":St(5),"bad-string-token":St(6),"url-token":St(7),"bad-url-token":St(8),"delim-token":St(9),"number-token":St(10),"percentage-token":St(11),"dimension-token":St(12),"whitespace-token":St(13),"CDO-token":St(14),"CDC-token":St(15),"colon-token":St(16),"semicolon-token":St(17),"comma-token":St(18),"[-token":St(19),"]-token":St(20),"(-token":St(21),")-token":St(22),"{-token":St(23),"}-token":St(24)},zF={string:St(5),ident:St(1),percentage:Jn(MF,CF),zero:yy(),number:Jn(BF,fy),integer:Jn(DF,fy),"custom-ident":IF,"dashed-ident":xy,"custom-property-name":FF,"hex-color":EF,"id-selector":AF,"an-plus-b":Au,urange:Lu,"declaration-value":PF,"any-value":LF},NF=["length","angle","time","frequency","resolution","flex","decibel","semitones"];function OF(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:Jn(Or(null),Nr),angle:Jn(Or(t),Nr),decibel:Jn(Or(n),Nr),frequency:Jn(Or(r),Nr),flex:Jn(Or(o),Nr),length:Jn(yy(Or(i)),Nr),resolution:Jn(Or(s),Nr),semitones:Jn(Or(a),Nr),time:Jn(Or(u),Nr)}}function _F(e){let t=new Set;for(let n of NF)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 by(e){return{...RF,...zF,...OF(e),"attr-unit":_F(e)}}var el={};be(el,{angle:()=>UF,decibel:()=>GF,flex:()=>VF,frequency:()=>HF,length:()=>$F,resolution:()=>WF,semitones:()=>qF,time:()=>jF});var $F=["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"],UF=["deg","grad","rad","turn"],jF=["s","ms"],HF=["hz","khz"],WF=["dpi","dpcm","dppx","x"],VF=["fr"],GF=["db"],qF=["st"];function Sy(e,t,n){return Object.assign(Mo("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
|
|
13
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=
|
|
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
|
-
`);
|
|
18
|
-
${
|
|
14
|
+
--`+new Array((n||t.length)+1).join("-")+"^"})}var YF=9,KF=10,XF=12,QF=13,JF=32,wy=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),tl=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&&wy[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!==QF&&n!==KF&&n!==XF&&n!==JF&&n!==YF)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 Sy(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||wy[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 ZF=9,eE=10,tE=12,nE=13,rE=32,Ey=33,Uu=35,vy=38,nl=39,Ay=40,Py=41,Ly=42,ju=43,Hu=44,ky=45,Wu=60,_u=62,rl=63,oE=64,ys=91,fi=93,ol=123,Cy=124,$u=125,Ty=8734,Iy={" ":1,"&&":2,"||":3,"|":4};function Fy(e){let t=null,n=null;return e.eat(ol),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===Hu?(e.pos++,e.skipWs(),e.charCode()!==$u&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat($u),{min:Number(t),max:n?Number(n):0}}function iE(e){let t=null,n=!1;switch(e.charCode()){case Ly:e.pos++,t={min:0,max:0};break;case ju:e.pos++,t={min:1,max:0};break;case rl:e.pos++,t={min:0,max:1};break;case Uu:e.pos++,n=!0,e.charCode()===ol?t=Fy(e):e.charCode()===rl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case ol:t=Fy(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function _r(e,t){let n=iE(e);return n!==null?(n.term=t,e.charCode()===Uu&&e.charCodeAt(e.pos-1)===ju||e.charCode()===rl&&e.charCodeAt(e.pos-1)===$u?_r(e,n):n):t}function Ou(e){let t=e.peek();return t===""?null:_r(e,{type:"Token",value:t})}function sE(e){let t;return e.eat(Wu),e.eat(nl),t=e.scanWord(),e.eat(nl),e.eat(_u),_r(e,{type:"Property",name:t})}function aE(e){let t=null,n=null,r=1;return e.eat(ys),e.charCode()===ky&&(e.peek(),r=-1),r==-1&&e.charCode()===Ty?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Hu),e.skipWs(),e.charCode()===Ty?e.peek():(r=1,e.charCode()===ky&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(fi),{type:"Range",min:t,max:n}}function lE(e){let t,n=null;if(e.eat(Wu),t=e.scanWord(),t==="boolean-expr"){e.eat(ys);let r=il(e,fi);return e.eat(fi),e.eat(_u),_r(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Ay&&e.nextCharCode()===Py&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===ys&&(e.skipWs(),n=aE(e)),e.eat(_u),_r(e,{type:"Type",name:t,opts:n})}function cE(e){let t=e.scanWord();return e.charCode()===Ay?(e.pos++,{type:"Function",name:t}):_r(e,{type:"Keyword",name:t})}function uE(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)=>Iy[o]-Iy[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 il(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?il(e,Py):dE(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:uE(r,n)||" ",disallowEmpty:!1,explicit:!1}}function pE(e){let t;return e.eat(ys),t=il(e,fi),e.eat(fi),t.explicit=!0,e.charCode()===Ey&&(e.pos++,t.disallowEmpty=!0),t}function dE(e){let t=e.charCode();switch(t){case fi:break;case ys:return _r(e,pE(e));case Wu:return e.nextCharCode()===nl?sE(e):lE(e);case Cy:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Cy?2:1))};case vy:return e.pos++,e.eat(vy),{type:"Combinator",value:"&&"};case Hu:return e.pos++,{type:"Comma"};case nl:return _r(e,{type:"String",value:e.scanString()});case rE:case ZF:case eE:case nE:case tE:return{type:"Spaces",value:e.scanSpaces()};case oE:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):Ou(e);case Ly:case ju:case rl:case Uu:case Ey:break;case ol:if(t=e.nextCharCode(),t<48||t>57)return Ou(e);break;default:return e.isNameCharCode(t)?cE(e):Ou(e)}}function bs(e){let t=new tl(e),n=il(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var Ss=function(){};function My(e){return typeof e=="function"?e:Ss}function Vu(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=Ss,i=Ss;if(typeof t=="function"?o=t:t&&(o=My(t.enter),i=My(t.leave)),o===Ss&&i===Ss)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var gE={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 mE(e){let t=[];return ro(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function By(e,t){return typeof e=="string"?mE(e):t.generate(e,gE)}var ot={type:"Match"},pt={type:"Mismatch"},sl={type:"DisallowEmpty"},hE=40,xE=41;function un(e,t,n){return t===ot&&n===pt||e===ot&&t===ot&&n===ot?e:(e.type==="If"&&e.else===pt&&t===ot&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function Ry(e){return e.length>2&&e.charCodeAt(e.length-2)===hE&&e.charCodeAt(e.length-1)===xE}function Dy(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&Ry(e.name)}function io(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function ws(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=ws(e.match,t,n),e.then=ws(e.then,t,n),e.else=ws(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function Gu(e,t,n){switch(e){case" ":{let r=ot;for(let o=t.length-1;o>=0;o--){let i=t[o];r=un(i,r,pt)}return r}case"|":{let r=pt,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(Dy(s)&&(o===null&&i>0&&Dy(t[i-1])&&(o=Object.create(null),r=un({type:"Enum",map:o},ot,r)),o!==null)){let a=(Ry(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=un(s,ot,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=pt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Gu(e,t.filter(function(a){return a!==i}),!1):s=ot,r=un(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?ot:pt;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Gu(e,t.filter(function(a){return a!==i}),!0):s=ot,r=un(i,s,r)}return r}}}function yE(e){let t=ot,n=gi(e.term);if(e.max===0)n=un(n,sl,pt),t=un(n,null,pt),t.then=un(ot,ot,t),e.comma&&(t.then.else=un({type:"Comma",syntax:e},t,pt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==ot&&(t=un({type:"Comma",syntax:e},t,pt)),t=un(n,un(ot,ot,t),pt);if(e.min===0)t=un(ot,ot,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==ot&&(t=un({type:"Comma",syntax:e},t,pt)),t=un(n,t,pt);return t}function gi(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=Gu(e.combinator,e.terms.map(gi),!1);return e.disallowEmpty&&(t=un(t,sl,pt)),t}case"Multiplier":return yE(e);case"Boolean":{let t=gi(e.term),n=gi(io([io([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),io([{type:"Type",name:"!boolean-group"},io([{type:"Multiplier",comma:!1,min:0,max:0,term:io([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:io([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=gi(io([{type:"Type",name:"!term"},io([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return ws(r,{"!term":t,"!self":n}),ws(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 vs(e,t){return typeof e=="string"&&(e=bs(e)),{type:"MatchGraph",match:gi(e),syntax:t||null,source:e}}var{hasOwnProperty:zy}=Object.prototype,bE=0,SE=1,Yu=2,Uy=3,Ny="Match",wE="Mismatch",vE="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",Oy=15e3,kE=0;function CE(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function qu(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=t.charCodeAt(n),o=e.charCodeAt(n);if(o>=65&&o<=90&&(o=o|32),o!==r)return!1}return!0}function TE(e){return e.type!==9?!1:e.value!=="?"}function _y(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||TE(e)}function $y(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function IE(e,t,n){function r(){do k++,F=k<e.length?e[k]:null;while(F!==null&&(F.type===13||F.type===25))}function o(O){let E=k+O;return E<e.length?e[E]:null}function i(O,E){return{nextState:O,matchStack:R,syntaxStack:p,thenStack:f,tokenIndex:k,prev:E}}function s(O){f={nextState:O,matchStack:R,syntaxStack:p,prev:f}}function a(O){d=i(O,d)}function u(){R={type:SE,syntax:t.syntax,token:F,prev:R},r(),m=null,k>z&&(z=k)}function c(){p={syntax:t.syntax,opts:t.syntax.opts||p!==null&&p.opts||null,prev:p},R={type:Yu,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===Yu?R=R.prev:R={type:Uy,syntax:p.syntax,token:R.token,prev:R},p=p.prev}let p=null,f=null,d=null,m=null,S=0,T=null,F=null,k=-1,z=0,R={type:bE,syntax:null,token:null,prev:null};for(r();T===null&&++S<Oy;)switch(t.type){case"Match":if(f===null){if(F!==null&&(k!==e.length-1||F.value!=="\\0"&&F.value!=="\\9")){t=pt;break}T=Ny;break}if(t=f.nextState,t===sl)if(f.matchStack===R){t=pt;break}else t=ot;for(;f.syntaxStack!==p;)l();f=f.prev;break;case"Mismatch":if(m!==null&&m!==!1)(d===null||k>d.tokenIndex)&&(d=m,m=!1);else if(d===null){T=wE;break}t=d.nextState,f=d.thenStack,p=d.syntaxStack,R=d.matchStack,k=d.tokenIndex,F=k<e.length?e[k]:null,d=d.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==pt&&a(t.else),t.then!==ot&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let D=t.syntax.terms;if(t.index===D.length){if(t.mask===0||t.syntax.all){t=pt;break}t=ot;break}if(t.mask===(1<<D.length)-1){t=ot;break}for(;t.index<D.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=D[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let D=F.value.toLowerCase();if(D.indexOf("\\")!==-1&&(D=D.replace(/\\[09].*$/,"")),zy.call(t.map,D)){t=t.map[D];break}}t=pt;break;case"Generic":{let D=p!==null?p.opts:null,g=k+Math.floor(t.fn(F,o,D));if(!isNaN(g)&&g>k){for(;k<g;)u();t=ot}else t=pt;break}case"Type":case"Property":{let D=t.type==="Type"?"types":"properties",g=zy.call(n,D)?n[D][t.name]:null;if(!g||!g.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(m!==!1&&F!==null&&t.type==="Type"&&(t.name==="custom-ident"&&F.type===1||t.name==="length"&&F.value==="0")){m===null&&(m=i(t,d)),t=pt;break}c(),t=g.matchRef||g.match;break}case"Keyword":{let D=t.name;if(F!==null){let g=F.value;if(g.indexOf("\\")!==-1&&(g=g.replace(/\\[09].*$/,"")),qu(g,D)){u(),t=ot;break}}t=pt;break}case"AtKeyword":case"Function":if(F!==null&&qu(F.value,t.name)){u(),t=ot;break}t=pt;break;case"Token":if(F!==null&&F.value===t.value){u(),t=ot;break}t=pt;break;case"Comma":F!==null&&F.type===18?_y(R.token)?t=pt:(u(),t=$y(F)?pt:ot):t=_y(R.token)||$y(F)?ot:pt;break;case"String":let O="",E=k;for(;E<e.length&&O.length<t.value.length;E++)O+=e[E].value;if(qu(O,t.value)){for(;k<E;)u();t=ot}else t=pt;break;default:throw new Error("Unknown node type: "+t.type)}switch(kE+=S,T){case null:console.warn("[csstree-match] BREAK after "+Oy+" iterations"),T=vE,R=null;break;case Ny:for(;p!==null;)l();break;default:R=null}return{tokens:e,reason:T,iterations:S,match:R,longestMatch:z}}function Ku(e,t,n){let r=IE(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=CE(o).prev;o!==null;){switch(o.type){case Yu:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case Uy: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 Qu={};be(Qu,{getTrace:()=>jy,isKeyword:()=>AE,isProperty:()=>EE,isType:()=>FE});function jy(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 FE(e,t){return Xu(this,e,n=>n.type==="Type"&&n.name===t)}function EE(e,t){return Xu(this,e,n=>n.type==="Property"&&n.name===t)}function AE(e){return Xu(this,e,t=>t.type==="Keyword")}function Xu(e,t,n){let r=jy.call(e,t);return r===null?!1:r.some(n)}function Hy(e){return"node"in e?e.node:Hy(e.match[0])}function Wy(e){return"node"in e?e.node:Wy(e.match[e.match.length-1])}function Ju(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=Hy(a),c=Wy(a);e.syntax.walk(t,function(l,p,f){if(l===u){let d=new Rn;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:ks}=Object.prototype;function Zu(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function Vy(e){return!!e&&Zu(e.offset)&&Zu(e.line)&&Zu(e.column)}function PE(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(ks.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(!Vy(r.loc.start))i+=".start";else if(!Vy(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 Rn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)ks.call(t,i)&&ks.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function Gy(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<"+(Gy(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function LE(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(ks.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=Gy(s,e+"."+i)}return{docs:o,check:PE(e,r)}}function qy(e){let t={};if(e.node){for(let n in e.node)if(ks.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=LE(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}function ep(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:li(e[o].syntax,{compact:t}));return r}function ME(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:li(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&ep(i.descriptors,t,n)};return r}function BE(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function DE(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function dr(e,t,n){return{matched:e,iterations:n,error:t,...Qu}}function mi(e,t,n,r){let o=By(n,e.syntax),i;return BE(o)?dr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=Ku(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=Ku(o,t.match,e),!i.match)?dr(null,new cy(i.reason,t.syntax,n,i),i.iterations):dr(i.match,null,i.iterations))}var Cs=class{constructor(t,n,r){if(this.cssWideKeywords=pi,this.syntax=n,this.generic=!1,this.units={...el},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||qy(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(el))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(by(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=vs(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=vs(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:bs(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:vs(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=DE(a)?vs({...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 ci("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&&!mi(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=Xa(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 ci("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new ci("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return dr(null,r);let o=this.getAtrule(t);return o.prelude?mi(this,o.prelude,n||"",!1):dr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return dr(null,o);let i=this.getAtrule(t),s=Xa(n);return mi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?dr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Tu(t).custom)return dr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?dr(null,r):mi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?mi(this,r,n,!1):dr(null,new ci("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?dr(null,new ci("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),mi(this,t,n,!1))}findValueFragments(t,n,r,o){return Ju(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return Ju(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=Xa(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=Tu(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&&Vu(p.syntax,function(f){if(f.type!=="Type"&&f.type!=="Property")return;let d=f.type==="Type"?u.types:u.properties,m=f.type==="Type"?o:i;hasOwnProperty.call(d,f.name)?n(u,f.name,m,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:ep(this.types,!n,t),properties:ep(this.properties,!n,t),atrules:ME(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}};function tp(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function RE(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function np(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?RE(i,n):i};return r}function Ts(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?tp(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?tp(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]=tp(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=np(e[r],o);break;case"atrule":case"pseudo":n[r]=np(e[r],o,["parse"]);break;case"node":n[r]=np(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}function Yy(e){let t=Px(e),n=ay(e),r=ty(e),{fromPlainObject:o,toPlainObject:i}=ny(n),s={lexer:null,createLexer:a=>new Cs(a,s,s.lexer.structure),tokenize:ro,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Ts({},e);return Yy(typeof a=="function"?a(u):Ts(u,a))}};return s.lexer=new Cs({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var Ky=e=>Yy(Ts({},e));var Xy={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 Fs={};be(Fs,{AnPlusB:()=>ip,Atrule:()=>ap,AtrulePrelude:()=>cp,AttributeSelector:()=>dp,Block:()=>gp,Brackets:()=>hp,CDC:()=>yp,CDO:()=>Sp,ClassSelector:()=>vp,Combinator:()=>Cp,Comment:()=>Ip,Condition:()=>Ep,Declaration:()=>Pp,DeclarationList:()=>Bp,Dimension:()=>Rp,Feature:()=>Np,FeatureFunction:()=>_p,FeatureRange:()=>jp,Function:()=>Wp,GeneralEnclosed:()=>Gp,Hash:()=>Yp,IdSelector:()=>Jp,Identifier:()=>Xp,Layer:()=>ed,LayerList:()=>nd,MediaQuery:()=>od,MediaQueryList:()=>sd,NestingSelector:()=>ld,Nth:()=>ud,Number:()=>dd,Operator:()=>gd,Parentheses:()=>hd,Percentage:()=>yd,PseudoClassSelector:()=>Sd,PseudoElementSelector:()=>vd,Ratio:()=>Cd,Raw:()=>Id,Rule:()=>Ed,Scope:()=>Pd,Selector:()=>Md,SelectorList:()=>Dd,String:()=>Nd,StyleSheet:()=>_d,SupportsDeclaration:()=>Ud,TypeSelector:()=>Wd,UnicodeRange:()=>qd,Url:()=>Xd,Value:()=>Jd,WhiteSpace:()=>ef});var ip={};be(ip,{generate:()=>_E,name:()=>NE,parse:()=>op,structure:()=>OE});var Cr=43,zn=45,al=110,Do=!0,zE=!1;function ll(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Cr||r===zn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)Mt(this.charCodeAt(n))||this.error("Integer is expected",n)}function hi(e){return ll.call(this,0,e)}function so(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case al:n="N is expected";break;case zn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function rp(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Cr,e)||this.isDelim(zn,e)){t=this.isDelim(Cr,e)?Cr:zn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),hi.call(this,Do))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Cr&&n!==zn&&this.error("Number sign is expected")),hi.call(this,t!==0),t===zn?"-"+this.consume(10):this.consume(10)}var NE="AnPlusB",OE={a:[String,null],b:[String,null]};function op(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)hi.call(this,zE),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,zn))switch(t="-1",so.call(this,1,al),this.tokenEnd-this.tokenStart){case 2:this.next(),n=rp.call(this);break;case 3:so.call(this,2,zn),this.next(),this.skipSC(),hi.call(this,Do),n="-"+this.consume(10);break;default:so.call(this,2,zn),ll.call(this,3,Do),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Cr)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Cr)&&(r=1,this.next()),so.call(this,0,al),this.tokenEnd-this.tokenStart){case 1:this.next(),n=rp.call(this);break;case 2:so.call(this,1,zn),this.next(),this.skipSC(),hi.call(this,Do),n="-"+this.consume(10);break;default:so.call(this,1,zn),ll.call(this,2,Do),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Cr||r===zn,i=this.tokenStart+o;for(;i<this.tokenEnd&&Mt(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),so.call(this,i-this.tokenStart,al),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=rp.call(this)):(so.call(this,i-this.tokenStart+1,zn),i+2===this.tokenEnd?(this.next(),this.skipSC(),hi.call(this,Do),n="-"+this.consume(10)):(ll.call(this,i-this.tokenStart+2,Do),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Cr&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Cr&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function _E(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 ap={};be(ap,{generate:()=>WE,name:()=>UE,parse:()=>sp,structure:()=>HE,walkContext:()=>jE});function Qy(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function $E(){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 UE="Atrule",jE="atrule",HE={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function sp(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),Qy):o=Qy.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($E.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function WE(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var cp={};be(cp,{generate:()=>YE,name:()=>VE,parse:()=>lp,structure:()=>qE,walkContext:()=>GE});var VE="AtrulePrelude",GE="atrulePrelude",qE={children:[[]]};function lp(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 YE(e){this.children(e)}var dp={};be(dp,{generate:()=>nA,name:()=>eA,parse:()=>pp,structure:()=>tA});var KE=36,Jy=42,cl=61,XE=94,up=124,QE=126;function JE(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(Jy)?(t=!0,this.next()):this.isDelim(up)||this.eat(1),this.isDelim(up)?this.charCodeAt(this.tokenStart+1)!==cl?(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 ZE(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==cl&&t!==QE&&t!==XE&&t!==KE&&t!==Jy&&t!==up&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==cl&&(this.isDelim(cl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}var eA="AttributeSelector",tA={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function pp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=JE.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=ZE.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 nA(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 gp={};be(gp,{generate:()=>lA,name:()=>iA,parse:()=>fp,structure:()=>aA,walkContext:()=>sA});var rA=38;function tb(){return this.Raw(null,!0)}function Zy(){return this.parseWithFallback(this.Rule,tb)}function eb(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function oA(){if(this.tokenType===17)return eb.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,eb);return this.tokenType===17&&this.next(),e}var iA="Block",sA="block",aA={children:[["Atrule","Rule","Declaration"]]};function fp(e){let t=e?oA:Zy,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),tb));break;default:e&&this.isDelim(rA)?r.push(Zy.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function lA(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var hp={};be(hp,{generate:()=>pA,name:()=>cA,parse:()=>mp,structure:()=>uA});var cA="Brackets",uA={children:[[]]};function mp(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 pA(e){this.token(9,"["),this.children(e),this.token(9,"]")}var yp={};be(yp,{generate:()=>gA,name:()=>dA,parse:()=>xp,structure:()=>fA});var dA="CDC",fA=[];function xp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function gA(){this.token(15,"-->")}var Sp={};be(Sp,{generate:()=>xA,name:()=>mA,parse:()=>bp,structure:()=>hA});var mA="CDO",hA=[];function bp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function xA(){this.token(14,"<!--")}var vp={};be(vp,{generate:()=>wA,name:()=>bA,parse:()=>wp,structure:()=>SA});var yA=46,bA="ClassSelector",SA={name:String};function wp(){return this.eatDelim(yA),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function wA(e){this.token(9,"."),this.token(1,e.name)}var Cp={};be(Cp,{generate:()=>FA,name:()=>TA,parse:()=>kp,structure:()=>IA});var vA=43,nb=47,kA=62,CA=126,TA="Combinator",IA={name:String};function kp(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case kA:case vA:case CA:this.next();break;case nb:this.next(),this.eatIdent("deep"),this.eatDelim(nb);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function FA(e){this.tokenize(e.name)}var Ip={};be(Ip,{generate:()=>MA,name:()=>PA,parse:()=>Tp,structure:()=>LA});var EA=42,AA=47,PA="Comment",LA={value:String};function Tp(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===EA&&this.charCodeAt(t-1)===AA&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function MA(e){this.token(25,"/*"+e.value+"*/")}var Ep={};be(Ep,{generate:()=>NA,name:()=>DA,parse:()=>Fp,structure:()=>RA});var BA=new Set([16,22,0]),DA="Condition",RA={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function rb(e){return this.lookupTypeNonSC(1)===1&&BA.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}var zA={media:rb,container:rb,supports(){return this.SupportsDeclaration()}};function Fp(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(()=>zA[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 NA(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var Pp={};be(Pp,{generate:()=>KA,name:()=>GA,parse:()=>Ap,structure:()=>YA,walkContext:()=>qA});var ib=33,OA=35,_A=36,$A=38,UA=42,jA=43,ob=47;function HA(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function WA(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function VA(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(ib)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}var GA="Declaration",qA="declaration",YA={important:[Boolean,String],property:String,value:["Value","Raw"]};function Ap(){let e=this.tokenStart,t=this.tokenIndex,n=XA.call(this),r=Qa(n),o=r?this.parseCustomProperty:this.parseValue,i=r?WA:HA,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(VA,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(ib)&&(s=QA.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 KA(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 XA(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case UA:case _A:case jA:case OA:case $A:this.next();break;case ob:this.next(),this.isDelim(ob)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function QA(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var Bp={};be(Bp,{generate:()=>tP,name:()=>ZA,parse:()=>Mp,structure:()=>eP});var JA=38;function Lp(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}var ZA="DeclarationList",eP={children:[["Declaration","Atrule","Rule"]]};function Mp(){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),Lp));break;default:this.isDelim(JA)?e.push(this.parseWithFallback(this.Rule,Lp)):e.push(this.parseWithFallback(this.Declaration,Lp))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function tP(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var Rp={};be(Rp,{generate:()=>oP,name:()=>nP,parse:()=>Dp,structure:()=>rP});var nP="Dimension",rP={value:String,unit:String};function Dp(){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 oP(e){this.token(12,e.value+e.unit)}var Np={};be(Np,{generate:()=>lP,name:()=>sP,parse:()=>zp,structure:()=>aP});var iP=47,sP="Feature",aP={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function zp(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(iP)&&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 lP(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var _p={};be(_p,{generate:()=>dP,name:()=>cP,parse:()=>Op,structure:()=>uP});var cP="FeatureFunction",uP={kind:String,feature:String,value:["Declaration","Selector"]};function pP(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function Op(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=pP.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 dP(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var jp={};be(jp,{generate:()=>xP,name:()=>mP,parse:()=>Up,structure:()=>hP});var sb=47,fP=60,ab=61,gP=62,mP="FeatureRange",hP={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 $p(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(sb,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(sb)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function lb(e){if(this.skipSC(),this.isDelim(fP)||this.isDelim(gP)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(ab)?(this.next(),t+"="):t}if(this.isDelim(ab))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function Up(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=$p.call(this),r=lb.call(this,n.type==="Identifier"),o=$p.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=lb.call(this),s=$p.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 xP(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 Wp={};be(Wp,{generate:()=>wP,name:()=>yP,parse:()=>Hp,structure:()=>SP,walkContext:()=>bP});var yP="Function",bP="function",SP={name:String,children:[[]]};function Hp(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 wP(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var Gp={};be(Gp,{generate:()=>CP,name:()=>vP,parse:()=>Vp,structure:()=>kP});var vP="GeneralEnclosed",kP={kind:String,function:[String,null],children:[[]]};function Vp(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 CP(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var Yp={};be(Yp,{generate:()=>EP,name:()=>IP,parse:()=>qp,structure:()=>FP,xxx:()=>TP});var TP="XXX",IP="Hash",FP={value:String};function qp(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function EP(e){this.token(4,"#"+e.value)}var Xp={};be(Xp,{generate:()=>LP,name:()=>AP,parse:()=>Kp,structure:()=>PP});var AP="Identifier",PP={name:String};function Kp(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function LP(e){this.token(1,e.name)}var Jp={};be(Jp,{generate:()=>DP,name:()=>MP,parse:()=>Qp,structure:()=>BP});var MP="IdSelector",BP={name:String};function Qp(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function DP(e){this.token(9,"#"+e.name)}var ed={};be(ed,{generate:()=>OP,name:()=>zP,parse:()=>Zp,structure:()=>NP});var RP=46,zP="Layer",NP={name:String};function Zp(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(RP);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function OP(e){this.tokenize(e.name)}var nd={};be(nd,{generate:()=>UP,name:()=>_P,parse:()=>td,structure:()=>$P});var _P="LayerList",$P={children:[["Layer"]]};function td(){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 UP(e){this.children(e,()=>this.token(18,","))}var od={};be(od,{generate:()=>WP,name:()=>jP,parse:()=>rd,structure:()=>HP});var jP="MediaQuery",HP={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function rd(){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 WP(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 sd={};be(sd,{generate:()=>qP,name:()=>VP,parse:()=>id,structure:()=>GP});var VP="MediaQueryList",GP={children:[["MediaQuery"]]};function id(){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 qP(e){this.children(e,()=>this.token(18,","))}var ld={};be(ld,{generate:()=>QP,name:()=>KP,parse:()=>ad,structure:()=>XP});var YP=38,KP="NestingSelector",XP={};function ad(){let e=this.tokenStart;return this.eatDelim(YP),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function QP(){this.token(9,"&")}var ud={};be(ud,{generate:()=>e2,name:()=>JP,parse:()=>cd,structure:()=>ZP});var JP="Nth",ZP={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function cd(){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 e2(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var dd={};be(dd,{generate:()=>r2,name:()=>t2,parse:()=>pd,structure:()=>n2});var t2="Number",n2={value:String};function pd(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function r2(e){this.token(10,e.value)}var gd={};be(gd,{generate:()=>s2,name:()=>o2,parse:()=>fd,structure:()=>i2});var o2="Operator",i2={value:String};function fd(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function s2(e){this.tokenize(e.value)}var hd={};be(hd,{generate:()=>c2,name:()=>a2,parse:()=>md,structure:()=>l2});var a2="Parentheses",l2={children:[[]]};function md(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 c2(e){this.token(21,"("),this.children(e),this.token(22,")")}var yd={};be(yd,{generate:()=>d2,name:()=>u2,parse:()=>xd,structure:()=>p2});var u2="Percentage",p2={value:String};function xd(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function d2(e){this.token(11,e.value+"%")}var Sd={};be(Sd,{generate:()=>h2,name:()=>f2,parse:()=>bd,structure:()=>m2,walkContext:()=>g2});var f2="PseudoClassSelector",g2="function",m2={name:String,children:[["Raw"],null]};function bd(){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 h2(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var vd={};be(vd,{generate:()=>S2,name:()=>x2,parse:()=>wd,structure:()=>b2,walkContext:()=>y2});var x2="PseudoElementSelector",y2="function",b2={name:String,children:[["Raw"],null]};function wd(){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 S2(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 Cd={};be(Cd,{generate:()=>k2,name:()=>w2,parse:()=>kd,structure:()=>v2});var cb=47;function ub(){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 w2="Ratio",v2={left:["Number","Function"],right:["Number","Function",null]};function kd(){let e=this.tokenStart,t=ub.call(this),n=null;return this.skipSC(),this.isDelim(cb)&&(this.eatDelim(cb),n=ub.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function k2(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var Id={};be(Id,{generate:()=>F2,name:()=>T2,parse:()=>Td,structure:()=>I2});function C2(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}var T2="Raw",I2={value:String};function Td(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=C2.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function F2(e){this.tokenize(e.value)}var Ed={};be(Ed,{generate:()=>M2,name:()=>A2,parse:()=>Fd,structure:()=>L2,walkContext:()=>P2});function pb(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function E2(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}var A2="Rule",P2="rule",L2={prelude:["SelectorList","Raw"],block:["Block"]};function Fd(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(E2,pb):n=pb.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function M2(e){this.node(e.prelude),this.node(e.block)}var Pd={};be(Pd,{generate:()=>R2,name:()=>B2,parse:()=>Ad,structure:()=>D2});var B2="Scope",D2={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]};function Ad(){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 R2(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 Md={};be(Md,{generate:()=>O2,name:()=>z2,parse:()=>Ld,structure:()=>N2});var z2="Selector",N2={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]};function Ld(){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 O2(e){this.children(e)}var Dd={};be(Dd,{generate:()=>j2,name:()=>_2,parse:()=>Bd,structure:()=>U2,walkContext:()=>$2});var _2="SelectorList",$2="selector",U2={children:[["Selector","Raw"]]};function Bd(){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 j2(e){this.children(e,()=>this.token(18,","))}var Nd={};be(Nd,{generate:()=>V2,name:()=>H2,parse:()=>zd,structure:()=>W2});var Rd=92,db=34,fb=39;function ul(e){let t=e.length,n=e.charCodeAt(0),r=n===db||n===fb?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===Rd){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),Cn(Rd,a)){let u=s-1,c=Dr(e,u);s=c-1,i+=Na(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function gb(e,t){let n=t?"'":'"',r=t?fb:db,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===Rd?(o+="\\"+e.charAt(s),i=!1):(i&&(Tn(a)||vr(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var H2="String",W2={value:String};function zd(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:ul(this.consume(5))}}function V2(e){this.token(5,gb(e.value))}var _d={};be(_d,{generate:()=>X2,name:()=>q2,parse:()=>Od,structure:()=>K2,walkContext:()=>Y2});var G2=33;function hb(){return this.Raw(null,!1)}var q2="StyleSheet",Y2="stylesheet",K2={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function Od(){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)!==G2){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,hb);break;default:n=this.parseWithFallback(this.Rule,hb)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function X2(e){this.children(e)}var Ud={};be(Ud,{generate:()=>Z2,name:()=>Q2,parse:()=>$d,structure:()=>J2});var Q2="SupportsDeclaration",J2={declaration:"Declaration"};function $d(){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 Z2(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var Wd={};be(Wd,{generate:()=>rL,name:()=>tL,parse:()=>Hd,structure:()=>nL});var eL=42,xb=124;function jd(){this.tokenType!==1&&this.isDelim(eL)===!1&&this.error("Identifier or asterisk is expected"),this.next()}var tL="TypeSelector",nL={name:String};function Hd(){let e=this.tokenStart;return this.isDelim(xb)?(this.next(),jd.call(this)):(jd.call(this),this.isDelim(xb)&&(this.next(),jd.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function rL(e){this.tokenize(e.name)}var qd={};be(qd,{generate:()=>lL,name:()=>sL,parse:()=>Gd,structure:()=>aL});var yb=43,bb=45,Vd=63;function Is(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===bb&&t&&n!==0)return Is.call(this,e+n+1,!1),-1;Tn(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 pl(e){let t=0;for(;this.isDelim(Vd);)++t>e&&this.error("Too many question marks"),this.next()}function oL(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===yb?"Plus sign":"Hyphen minus")+" is expected")}function iL(){let e=0;switch(this.tokenType){case 10:if(e=Is.call(this,1,!0),this.isDelim(Vd)){pl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){oL.call(this,bb),Is.call(this,1,!1);break}break;case 12:e=Is.call(this,1,!0),e>0&&pl.call(this,6-e);break;default:if(this.eatDelim(yb),this.tokenType===1){e=Is.call(this,0,!0),e>0&&pl.call(this,6-e);break}if(this.isDelim(Vd)){this.next(),pl.call(this,5);break}this.error("Hex digit or question mark is expected")}}var sL="UnicodeRange",aL={value:String};function Gd(){let e=this.tokenStart;return this.eatIdent("u"),iL.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function lL(e){this.tokenize(e.value)}var Xd={};be(Xd,{generate:()=>mL,name:()=>fL,parse:()=>Kd,structure:()=>gL});var cL=32,Yd=92,uL=34,pL=39,dL=40,Sb=41;function wb(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===Sb?t-2:t-1,o="";for(;n<r&&vr(e.charCodeAt(n));)n++;for(;n<r&&vr(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===Yd){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),Cn(Yd,s)){let a=i-1,u=Dr(e,a);i=u-1,o+=Na(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function vb(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===cL||o===Yd||o===uL||o===pL||o===dL||o===Sb?(t+="\\"+e.charAt(r),n=!1):(n&&Tn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var fL="Url",gL={value:String};function Kd(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=wb(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=ul(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 mL(e){this.token(7,vb(e.value))}var Jd={};be(Jd,{generate:()=>yL,name:()=>hL,parse:()=>Qd,structure:()=>xL});var hL="Value",xL={children:[[]]};function Qd(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function yL(e){this.children(e)}var ef={};be(ef,{generate:()=>vL,name:()=>SL,parse:()=>Zd,structure:()=>wL});var bL=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),SL="WhiteSpace",wL={value:String};function Zd(){return this.eat(13),bL}function vL(e){this.token(13,e.value)}var Cb={generic:!0,cssWideKeywords:pi,...Xy,node:Fs};var tf={};be(tf,{AtrulePrelude:()=>Ib,Selector:()=>Eb,Value:()=>Mb});var kL=35,CL=42,Tb=43,TL=45,IL=47,FL=117;function Es(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,FL)&&this.cmpChar(this.tokenStart+1,Tb)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===IL||t===CL||t===Tb||t===TL)return this.Operator();t===kL&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var Ib={getNode:Es};var EL=35,AL=38,PL=42,LL=43,ML=47,Fb=46,BL=62,DL=124,RL=126;function zL(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function NL(){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)===Fb&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case LL:case BL:case RL:case ML:return this.Combinator();case Fb:return this.ClassSelector();case PL:case DL:return this.TypeSelector();case EL:return this.IdSelector();case AL:return this.NestingSelector()}break}}}var Eb={onWhiteSpace:zL,getNode:NL};function Ab(){return this.createSingleNodeList(this.Raw(null,!1))}function Pb(){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 Lb(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var Mb={getNode:Es,onWhiteSpace(e,t){Lb(e)&&(e.value=" "+e.value),Lb(t.last)&&(t.last.value+=" ")},expression:Ab,var:Pb};var OL=new Set(["none","and","not","or"]),Bb={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);OL.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}};var Db={parse:{prelude:null,block(){return this.Block(!0)}}};function nf(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 Rb={layer(){this.skipSC();let e=this.createList(),t=nf.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=nf.call(this,this.Declaration,()=>nf.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},zb={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,Rb)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,Rb)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}};var Nb={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}};var Ob={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}};var _b={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}};var $b={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}};var Ub={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}};var jb={parse:{prelude:null,block(e=!1){return this.Block(e)}}};var Hb={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}};var Wb={container:Bb,"font-face":Db,import:zb,layer:Nb,media:Ob,nest:_b,page:$b,scope:Ub,"starting-style":jb,supports:Hb};function Vb(){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 Ro={parse(){return this.createSingleNodeList(this.SelectorList())}},rf={parse(){return this.createSingleNodeList(this.Selector())}},_L={parse(){return this.createSingleNodeList(this.Identifier())}},$L={parse:Vb},dl={parse(){return this.createSingleNodeList(this.Nth())}},Gb={dir:_L,has:Ro,lang:$L,matches:Ro,is:Ro,"-moz-any":Ro,"-webkit-any":Ro,where:Ro,not:Ro,"nth-child":dl,"nth-last-child":dl,"nth-last-of-type":dl,"nth-of-type":dl,slotted:rf,host:rf,"host-context":rf};var of={};be(of,{AnPlusB:()=>op,Atrule:()=>sp,AtrulePrelude:()=>lp,AttributeSelector:()=>pp,Block:()=>fp,Brackets:()=>mp,CDC:()=>xp,CDO:()=>bp,ClassSelector:()=>wp,Combinator:()=>kp,Comment:()=>Tp,Condition:()=>Fp,Declaration:()=>Ap,DeclarationList:()=>Mp,Dimension:()=>Dp,Feature:()=>zp,FeatureFunction:()=>Op,FeatureRange:()=>Up,Function:()=>Hp,GeneralEnclosed:()=>Vp,Hash:()=>qp,IdSelector:()=>Qp,Identifier:()=>Kp,Layer:()=>Zp,LayerList:()=>td,MediaQuery:()=>rd,MediaQueryList:()=>id,NestingSelector:()=>ad,Nth:()=>cd,Number:()=>pd,Operator:()=>fd,Parentheses:()=>md,Percentage:()=>xd,PseudoClassSelector:()=>bd,PseudoElementSelector:()=>wd,Ratio:()=>kd,Raw:()=>Td,Rule:()=>Fd,Scope:()=>Ad,Selector:()=>Ld,SelectorList:()=>Bd,String:()=>zd,StyleSheet:()=>Od,SupportsDeclaration:()=>$d,TypeSelector:()=>Hd,UnicodeRange:()=>Gd,Url:()=>Kd,Value:()=>Qd,WhiteSpace:()=>Zd});var qb={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:tf,atrule:Wb,pseudo:Gb,node:of};var Yb={node:Fs};var Kb=Ky({...Cb,...qb,...Yb});var{tokenize:J9,parse:Xb,generate:Z9,lexer:eG,createLexer:tG,walk:Qb,find:nG,findLast:rG,findAll:oG,toPlainObject:iG,fromPlainObject:sG,fork:aG}=Kb;var jL=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"]);function HL(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Zb(e){try{let t=Xb(e.trim(),{context:"value"}),n=[];return Qb(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 WL(e,t){let n=HL(e);if(!jL.has(n))return t;let r=Zb(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 Jb(e,t){let n=t.trim();if(!n)return"";let r=WL(e,n);return Zb(r).map(i=>i==="0"?"0px":i).join(" ")}function e0(e,t,n){let r=Jb(e,t),o=Jb(e,n);return r!==""&&o!==""&&r===o}function VL(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function GL(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 t0(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=GL(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return VL(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 zo(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=t0(r),d=t0(o);return!!(f===d||n&&e0(n,r,o))}var r0=.5,o0=2,i0=2,qL=5,YL=["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"],KL=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],XL=["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 QL(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 n0(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 JL(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 ZL(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&&QL(n)||n0(r)||n0(o)||n&&JL(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<o0:a<r0}return r.includes("%")||o.includes("%")?a<1:!1}function eM(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(XL.some(s=>t.includes(s))||!YL.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!zo(o,i,e.property))}function tM(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 nM(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)<i0}function rM(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(!KL.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]))>qL)}function oM(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 As(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(zo(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(nM(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${i0}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(ZL(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")?o0:r0}px)`,dismissedBy:"post-ai-validation"}}return oM(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:eM(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:rM(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:tM(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var gM=["flex","inline-flex"],mM=["grid","inline-grid"],CG=[...gM,...mM];Me();var fl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function yM(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function sf(e,t){let n=[],r=e.split(`
|
|
15
|
+
`);for(let s=0;s<r.length;s++){let a=yM(r[s]),u=fl.exec(a);if(u){let[,c,l,,p]=u,f=bM(l),d=SM(r,s+1),m={id:to(),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(m)}fl.lastIndex=0}return n.map(s=>{let a=As(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 bM(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function SM(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||fl.test(i)){fl.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}Me();var Ps=null,a0=0,wM=3e4;async function vM(){let e=Date.now();if(Ps&&e-a0<wM)return Ps;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 Ps=n.entries||n.stories||{},a0=e,b.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Ps).length),Ps}catch(t){throw b.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ls(e){try{let n=(await vM())[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 af(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function kM(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 lf(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):kM(e.type,t)}Me();function CM(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 TM(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 IM(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 FM(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 cf(e){if(!e||e.length===0)return[];let t=e.filter(i=>!IM(i)),n=[],r=[];for(let i of t){let s=CM(i),a=TM(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(FM(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}Me();Re();import{addons as gl}from"storybook/manager-api";var uf="uireview/badge",xi={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function EM(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function AM(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 PM(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function yi(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function c0(e){if(yi())try{gl.getChannel().emit(xi.REVIEW_START,{storyId:e})}catch{}}function ao(e,t){if(yi())try{gl.getChannel().emit(xi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function u0(e){if(yi())try{gl.getChannel().emit(xi.REVIEW_ERROR,{storyId:e})}catch{}}function l0(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}function p0(e){let t=gl.getChannel(),n=o=>i=>{yi()&&o(i)};t.on(xi.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:uf,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(xi.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:EM(i),typeId:uf,storyId:o,title:PM(i),description:AM(i)}])})),t.on(xi.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:uf,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=yi();r||l0(e),setInterval(()=>{let o=yi();o!==r&&(r=o,o||l0(e))},1500)}var df=G(),ff=180;function lo(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 gf=()=>{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:m,setSeverityFilter:S,setShowStreamingPanel:T,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:z,clearStreamingMessages:R,setStreamingProgress:O,setStreamingStatus:E,setFullPrompt:D,setFullResponse:g,setFigmaImageUrl:w,setStorybookImageUrl:v,setFigmaDimensions:A,setMultiModelResults:h,updateMultiModelStreamingMessages:C,setModelCompleted:I,setActiveModelId:y,resetReview:P,addReview:L,setReviewDetailTab:B,includeTextComparison:N,usePromptCache:x,setApplyFixesResult:U,featureFlags:H}=se(),{sessionToken:M,setUsageData:Q}=Ie(),{selectedProjectId:ee}=Qe(),{currentStoryId:J,currentStoryName:Le}=Ye(),Ee=pf(null),We=pf(null),st=pf({}),te=Ms((ct,Ge)=>{k({role:ct,content:Ge})},[k]),Y=Ms((ct,Ge)=>{O(ct),E(Ge)},[O,E]),ce=Ms(async ct=>{let{isIteration:Ge=!1,parentReviewId:xt=null}=ct||{};if(!M)throw new Error("Not authenticated");if(!ee)throw new Error("No project selected");if(!J||!Le)throw new Error("No story is currently selected in Storybook");if(e){b.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let yn=Date.now();try{p(!0),f(null),d(null),U(null),J&&H.enableReviewBadges&&c0(J),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{b.debug(`[useAIReview] Auto-stopping review after ${ff}s timeout`),Ee.current&&Ee.current.abort(),k({role:"system",content:`Review auto-stopped after ${ff} seconds timeout.`})},ff*1e3),D(""),g(""),T(!0),F(!1),R(),Y(0,"Starting review..."),Y(5,"Refreshing component preview..."),b.debug("[Review] Forcing iframe reload for fresh styles..."),await ka(),b.debug("[Review] Iframe reloaded, styles should be fresh"),Y(20,"Capturing screenshot & extracting styles..."),b.debug("[Review] Starting parallel data collection...");let[qe,fe,kt]=await Promise.all([wa({sessionToken:M||void 0}),Promise.resolve(ns()),Promise.resolve(Xc())]);if(qe&&(v(qe),b.debug("[Review] Storybook screenshot captured and set")),!fe)throw new Error("Failed to extract styles from component");let{computed:yr,declared:pe,markup:Xe,textElementStyles:_,nestedElementStyles:$}=fe;kt?b.debug("[Review] DOM tree extracted:",{selector:kt.selector,childrenCount:kt.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")),Y(50,"Preparing metadata..."),b.debug("[Review] Current story:",{id:J,name:Le});let W=at.getState().currentMapping?.figmaNodeId??null,Z=at.getState().figmaImageUrl;if(W&&(b.debug("[Review] Using Figma node ID from store:",W),Z&&(Y(65,"Using existing Figma design..."),b.debug("[Review] Reusing already-loaded Figma image"))),!W)try{let tt=await fetch(`${df}/api/mappings?projectId=${ee}&storyId=${J}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${M}`}});if(tt.ok){let Lt=await tt.json();Lt.mapping?.figmaNodeId?(W=Lt.mapping.figmaNodeId,b.debug("[Review] Found Figma node ID from API:",W)):b.debug("[Review] No mapping found for story:",J)}else b.debug("[Review] Failed to fetch mapping:",tt.status)}catch(tt){b.error("[Review] Error fetching mapping:",tt)}if(W&&!Z){Y(65,"Fetching Figma design...");try{let tt=await fetch(`${df}/api/figma/frames?projectId=${ee}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${M}`}});if(tt.ok){let Wt=(await tt.json()).thumbnails?.[W];Wt?(w(Wt),b.debug("[Review] Figma thumbnail fetched and displayed:",Wt)):b.warn("[Review] No thumbnail found for node:",W)}else b.warn("[Review] Failed to fetch Figma frames:",tt.status)}catch(tt){b.error("[Review] Error fetching Figma frames:",tt)}}if(!W)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');Y(80,"AI is analyzing your component..."),b.debug("[Review] Sending to streaming API...");let et={projectId:ee,storyId:J,storyName:Le,storybookScreenshot:qe,computedStyles:yr,declaredStyles:pe,textElementStyles:_,nestedElementStyles:$,componentMarkup:Xe,domTree:kt,figmaNodeId:W,figmaImageUrl:Z||void 0,aiModels:l,includeTextComparison:N,usePromptCache:x,parentReviewId:Ge?xt:void 0,isIteration:Ge};b.debug("[Review] Request payload:",{...et,storybookScreenshot:qe?`${qe.substring(0,50)}...`:null,domTree:kt?{selector:kt.selector,childrenCount:kt.children.length}:null}),Ee.current=new AbortController;let qt=await fetch(`${df}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${M}`},body:JSON.stringify(et),signal:Ee.current.signal});if(b.debug("[Review] Response status:",qt.status,qt.statusText),!qt.ok){let tt=await qt.json();if(b.error("[Review] API error response:",tt),qt.status===429){let Lt=tt.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Lt} seconds before trying again.`)}throw new Error(tt.error||tt.message||"Review request failed")}let br=qt.body?.getReader(),or=new TextDecoder,Pr="",bn="",xe=null,Sr=null,$n=l.length>1,Co={},Vi={},bj={};if(!br)throw new Error("Response body is not readable");let eh=at.getState().streamingMessages.length;for(te("assistant","");;){let{done:tt,value:Lt}=await br.read();if(tt)break;Pr+=or.decode(Lt,{stream:!0});let Wt=Pr.split(`
|
|
17
|
+
`);Pr=Wt.pop()||"";for(let Mn of Wt)if(Mn.startsWith("data: ")){let nn=Mn.slice(6);if(nn==="[DONE]")continue;try{let oe=JSON.parse(nn);if(oe.type!=="text"&&oe.type!=="content"&&b.debug("[Review] SSE Event received:",oe.type),oe.type==="prompt")oe.prompt&&(D(oe.prompt),b.debug("[Review] Prompt received early"));else if(oe.type==="model_started")b.debug("[Review] Model started:",oe.modelId),Co[oe.modelId]||(Co[oe.modelId]="",Vi[oe.modelId]=[{role:"assistant",content:""}]);else if(oe.type==="text"||oe.type==="content")if($n&&oe.modelId){Co[oe.modelId]||(Co[oe.modelId]="",Vi[oe.modelId]=[{role:"assistant",content:""}]),Co[oe.modelId]+=oe.content,Vi[oe.modelId][0].content=Co[oe.modelId],C(oe.modelId,Vi[oe.modelId]);let Ot=Object.entries(Co).map(([rn,Ze])=>`[${rn}]
|
|
18
|
+
${Ze}`).join(`
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
`);
|
|
22
|
+
`);z(eh,Ot)}else bn+=oe.content,z(eh,bn);else if(oe.type==="model_completed")b.debug("[Review] Model completed:",oe.modelId,oe.complianceScore),I(oe.modelId);else if(oe.type==="figma_image")oe.url&&(w(oe.url),b.debug("[Review] Figma image URL received:",oe.url));else if(oe.type==="figma_dimensions")oe.width&&oe.height&&(A({width:oe.width,height:oe.height}),b.debug("[Review] Figma dimensions received:",oe.width,"x",oe.height));else if(oe.type==="complete"||oe.type==="result")xe=oe,b.debug("[Review] Final result received! Type:",oe.type),b.debug("[Review] Final result issues count:",oe.issues?.length||0),b.debug("[Review] Final result score:",oe.validation?.complianceScore);else if(oe.type==="all_complete")xe=oe,b.debug("[Review] Multi-model results received:",Object.keys(oe.byModel));else if(oe.type==="error"||oe.type==="model_error"){let Ot=new Error(oe.message||oe.error||"Streaming error");throw Ot.isServerError=!0,Ot}}catch(oe){if(oe.isServerError)throw oe;let Ot=oe instanceof Error?{message:oe.message,name:oe.name,stack:oe.stack}:String(oe);b.error("[Review] Error parsing SSE data:",Ot),b.error("[Review] Failed to parse data:",nn.substring(0,200)+(nn.length>200?"...":"")),Sr=oe instanceof Error?oe:new Error(String(oe))}}}if(Y(100,"Review complete!"),!xe&&Sr&&(b.error("[Review] No final result received. Last parse error:",Sr),b.error("[Review] Streaming text available:",bn.length,"chars")),$n&&xe?.type==="all_complete"){let tt=Object.keys(xe.byModel).reduce((Wt,Mn)=>{let nn=xe.byModel[Mn];return Wt[Mn]={...nn,fullResponse:nn.response||nn.fullResponse||"",fullPrompt:nn.prompt||nn.fullPrompt||"",streamingMessages:Vi[Mn]||[]},Wt},{}),Lt=Object.keys(xe.byModel)[0];h({byModel:tt,activeModelId:Lt}),tt[Lt]?.fullPrompt&&D(tt[Lt].fullPrompt),b.debug("[Review] Multi-model results stored:",Object.keys(xe.byModel));try{let Wt=to(),Mn=xe.byModel?.[Lt]?.issues,nn=Mn&&Mn.length>0,oe=nn?Mn.map(de=>({id:to(),reviewId:Wt,dbId:de.dbId,type:de.type,severity:de.severity,title:de.description,description:de.description,property:de.property,expected:lo(de.expected),actual:lo(de.actual),currentValue:lo(de.actual),suggestedValue:lo(de.expected),source:de.source||"computed-styles",suggestedFix:de.suggestedFix,file:de.file,domElement:de.domElement,figmaElement:de.figmaElement,fixTarget:de.fixTarget,fixRequired:de.fixRequired,detectedBy:de.detectedBy,dismissed:de.dismissed??!1,dismissReason:de.dismissReason,dismissedAt:de.dismissed?new Date:void 0,_unreliable:de._unreliable,_validationError:de._validationError,figmaContext:de.figmaContext,relatedTo:Array.isArray(de.relatedTo)?de.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):sf(tt[Lt]?.fullResponse||"",Wt);b.debug("[Review] Multi-model issues source:",nn?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Multi-model issues count:",oe.length,"issues");let Ot=oe.filter(de=>de.dismissed).length;Ot>0&&(b.debug("[Review] Multi-model auto-dismissed:",Ot,"false positive issues"),te("system",`
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
\u2705 ${
|
|
26
|
+
\u2705 ${Ot} issue${Ot>1?"s were":" was"} auto-dismissed as false positive${Ot>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let rn=st.current[J];rn||(rn=await Ls(J)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},rn.storyFile&&(st.current[J]=rn)),b.debug("[Review] Story file paths:",rn);let Ze=oe.map(de=>({...de,file:de.file||af(de.fixTarget,rn)||lf(de,rn)}));if(Ze=cf(Ze),b.debug("[Review] After de-duplication:",Ze.length,"issues"),!N){let de=Ze.length;Ze=Ze.filter(dn=>dn.property?.toLowerCase()!=="textcontent"&&!dn.description?.toLowerCase().includes("text content")),de!==Ze.length&&b.debug("[Review] Filtered out",de-Ze.length,"textContent issues (toggle OFF)")}let wr=xe.validation?.complianceScore??tt[Lt]?.complianceScore;if(b.debug("[Review] Multi-model score sources:",{firstModelId:Lt,validationScore:xe.validation?.complianceScore,modelScore:tt[Lt]?.complianceScore,multiModelScore:wr}),wr==null){let dn=(tt[Lt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);wr=dn?parseInt(dn[1],10):void 0,b.debug("[Review] Parsed multi-model score from response:",wr)}let Sn;Ge&&xt&&(Sn=(at.getState().reviewHistory.find(dn=>dn.id===xt)?.iterationNumber||0)+1);let Gi={id:Wt,componentId:J,storyId:J,modelId:Lt,parentReviewId:Ge&&xt||void 0,iterationNumber:Sn,figmaFileKey:void 0,figmaNodeId:W||void 0,figmaFileUrl:Z||void 0,complianceScore:wr,visualSimilarity:xe.visualSimilarity,issuesCount:Ze.filter(de=>!de.dismissed).length,issues:Ze,createdAt:new Date,reviewDurationMs:Date.now()-yn,costUsd:xe.costUsd,inputTokens:xe.inputTokens,outputTokens:xe.outputTokens,cacheCreationTokens:xe.cacheCreationTokens,cacheReadTokens:xe.cacheReadTokens};if(b.debug("[Review] Multi-model token data:",{costUsd:xe.costUsd,inputTokens:xe.inputTokens,outputTokens:xe.outputTokens,cacheCreationTokens:xe.cacheCreationTokens,cacheReadTokens:xe.cacheReadTokens,reviewTokens:Gi.inputTokens}),L(Gi),J&&H.enableReviewBadges){let de=Ze.filter(dn=>!dn.dismissed);ao(J,{score:wr??100,issueCount:de.length,criticalCount:de.filter(dn=>dn.severity==="critical").length,majorCount:de.filter(dn=>dn.severity==="major").length,minorCount:de.filter(dn=>dn.severity==="minor").length})}B("issues");let da=Ze.filter(de=>!de.dismissed).length;b.debug("[Review] Created multi-model review with",da,"active issues,",Ze.length-da,"dismissed");let we=W||at.getState().currentMapping?.figmaNodeId;b.debug("[Review] Issue validation handled server-side. Active:",Ze.filter(de=>!de.dismissed).length,"Dismissed:",Ze.filter(de=>de.dismissed).length)}catch(Wt){b.error("[Review] Failed to parse issues from multi-model response:",Wt)}}else if(xe){xe.prompt&&D(xe.prompt),(xe.response||bn)&&g(xe.response||bn),xe.figmaImageUrl&&w(xe.figmaImageUrl),b.debug("[Review] State updated with prompt, response, and screenshots");try{let tt=to(),Lt=xe.response||bn,Wt=xe.issues,Mn=Wt&&Wt.length>0,nn=Mn?Wt.map(we=>({id:to(),reviewId:tt,dbId:we.dbId,type:we.type,severity:we.severity,title:we.description,description:we.description,property:we.property,expected:lo(we.expected),actual:lo(we.actual),currentValue:lo(we.actual),suggestedValue:lo(we.expected),source:we.source||"computed-styles",suggestedFix:we.suggestedFix,file:we.file,domElement:we.domElement,figmaElement:we.figmaElement,fixTarget:we.fixTarget,fixRequired:we.fixRequired,detectedBy:we.detectedBy,dismissed:we.dismissed??!1,dismissReason:we.dismissReason,dismissedAt:we.dismissed?new Date:void 0,_unreliable:we._unreliable,_validationError:we._validationError,figmaContext:we.figmaContext,relatedTo:Array.isArray(we.relatedTo)?we.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):sf(Lt,tt);b.debug("[Review] Issues source:",Mn?"API (server-side dismissal)":"client-side parsing"),b.debug("[Review] Issues count:",nn.length,"issues");let oe=nn.filter(we=>we.dismissed).length;oe>0&&(b.debug("[Review] Auto-dismissed:",oe,"false positive issues"),te("system",`
|
|
27
27
|
|
|
28
28
|
---
|
|
29
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`
|
|
30
|
+
\u2705 ${oe} issue${oe>1?"s were":" was"} auto-dismissed as false positive${oe>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Ot=xe.complianceScore??xe.validation?.complianceScore;if(b.debug("[Review] Score sources:",{directScore:xe.complianceScore,validationScore:xe.validation?.complianceScore,parsedScore:Ot}),Ot==null){let we=Lt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Ot=we?parseInt(we[1],10):void 0,b.debug("[Review] Parsed score from response:",Ot)}let rn=st.current[J];rn||(rn=await Ls(J)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},rn.storyFile&&(st.current[J]=rn)),b.debug("[Review] Story file paths:",rn);let Ze=nn.map(we=>({...we,file:we.file||af(we.fixTarget,rn)||lf(we,rn)}));if(Ze=cf(Ze),b.debug("[Review] After de-duplication:",Ze.length,"issues"),!N){let we=Ze.length;Ze=Ze.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),we!==Ze.length&&b.debug("[Review] Filtered out",we-Ze.length,"textContent issues (toggle OFF)")}let wr;Ge&&xt&&(wr=(at.getState().reviewHistory.find(de=>de.id===xt)?.iterationNumber||0)+1);let Sn={id:tt,componentId:J,storyId:J,modelId:l[0],parentReviewId:Ge&&xt||void 0,iterationNumber:wr,figmaFileKey:void 0,figmaNodeId:W||void 0,figmaFileUrl:Z||void 0,complianceScore:Ot,visualSimilarity:xe.visualSimilarity,issuesCount:Ze.filter(we=>!we.dismissed).length,issues:Ze,createdAt:new Date,reviewDurationMs:Date.now()-yn,costUsd:xe.costUsd,inputTokens:xe.inputTokens,outputTokens:xe.outputTokens,cacheCreationTokens:xe.cacheCreationTokens,cacheReadTokens:xe.cacheReadTokens,variantMismatch:xe.variantMismatch,storybookVariant:xe.storybookVariant,figmaVariant:xe.figmaVariant};if(b.debug("[useAIReview] About to call addReview with review:",{id:Sn.id,storyId:Sn.storyId,issueCount:Sn.issues?.length,complianceScore:Sn.complianceScore,createdAt:Sn.createdAt?.toISOString(),inputTokens:Sn.inputTokens,outputTokens:Sn.outputTokens,costUsd:Sn.costUsd,cacheCreationTokens:Sn.cacheCreationTokens,cacheReadTokens:Sn.cacheReadTokens}),L(Sn),b.debug("[useAIReview] addReview called successfully"),J&&H.enableReviewBadges){let we=Ze.filter(de=>!de.dismissed);ao(J,{score:Ot??100,issueCount:we.length,criticalCount:we.filter(de=>de.severity==="critical").length,majorCount:we.filter(de=>de.severity==="major").length,minorCount:we.filter(de=>de.severity==="minor").length})}B("issues");let Gi=Ze.filter(we=>!we.dismissed).length;b.debug("[Review] Created review with",Gi,"active issues,",Ze.length-Gi,"dismissed");let da=W||at.getState().currentMapping?.figmaNodeId;b.debug("[Review] Validation check:",{figmaNodeId:W,effectiveFigmaNodeIdSingle:da,hasSessionToken:!!M,selectedProjectId:ee,issueCount:Ze.length}),b.debug("[Review] Issue validation handled server-side. Active:",Ze.filter(we=>!we.dismissed).length,"Dismissed:",Ze.filter(we=>we.dismissed).length)}catch(tt){b.error("[Review] Failed to parse issues:",tt)}}else throw bn?(b.error("[Review] ERROR: No structured result received from backend!"),b.error("[Review] Streaming text length:",bn.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"),Y(0,"Review cancelled");return}b.error("[useAIReview] Review error:",qe);let fe=qe instanceof Error?qe.message:"Review failed";throw f(fe),J&&H.enableReviewBadges&&u0(J),Y(0,`Error: ${fe}`),qe}finally{p(!1),Ee.current=null,We.current&&(clearTimeout(We.current),We.current=null),Q(null)}},[e,M,ee,J,Le,l,p,f,d,h,C,I,y,T,F,R,te,Y,z,v,w,D,g,Q]),ie=Ms(()=>n?.issues?o==="all"?n.issues:n.issues.filter(ct=>ct.severity===o):[],[n,o]),ue=Ms(()=>{Ee.current&&(b.debug("[useAIReview] Cancelling review..."),Ee.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:ce,cancelReview:ue,setShowReviewMenu:m,setSeverityFilter:S,setShowStreamingPanel:T,setStreamingPanelCollapsed:F,addStreamingMessage:k,updateStreamingMessage:z,clearStreamingMessages:R,setStreamingProgress:O,setStreamingStatus:E,resetReview:P,getFilteredIssues:ie}};ke();Me();Re();import{useCallback as x7}from"react";var w7=G();ke();Me();import{useEffect as d0,useRef as f0}from"react";import{useStorybookApi as LM,useStorybookState as MM,addons as BM}from"storybook/manager-api";var g0="storyArgsUpdated",mf=()=>{let e=LM(),t=MM(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=Ye(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=se(),l=f0(null),p=f0(0);return d0(()=>{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),m=d?.name&&d.name!=="default"?`${d.title} / ${d.name}`:d?.title||f;i(m),b.debug("[useCurrentStory] Current story:",{storyId:f,fullName:m})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),d0(()=>{let f=BM.getChannel(),d=null,m=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:T,isValidating:F}=at.getState();if(T||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(g0,m),()=>{f.off(g0,m),d&&clearTimeout(d)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};ke();Re();nt();import{useCallback as m0}from"react";import{addons as h0}from"storybook/manager-api";var x0=G(),No=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=Ye(),{sessionToken:o}=Ie(),{selectedProjectId:i}=Qe(),s=m0(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ne(`${x0}/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{h0.getChannel().emit("uireview/mappings-changed")}catch{}return p.mapping},[o,i,r]),a=m0(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ne(`${x0}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{h0.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Zi();ke();import{useCallback as hf,useEffect as y0,useRef as DM}from"react";import{useChannel as RM,addons as b0}from"storybook/manager-api";Me();var zM=3e4,NM="forceRemount";function OM(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 _M(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 $M="UICOPILOT/APPLY_FIXES",UM="UICOPILOT/FIX_STARTED",jM="UICOPILOT/FIX_COMPLETED",HM="UICOPILOT/FIX_FAILED",WM="UICOPILOT/ALL_FIXES_APPLIED",xf=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=se(),c=DM(null),l=hf(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);y0(()=>()=>l(),[l]),y0(()=>{let m=b0.getChannel(),S=()=>{at.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 m.on("channelWSDisconnect",S),()=>m.off("channelWSDisconnect",S)},[l,o,i]);let p=RM({[UM]:({issueId:m})=>{b.debug(`[useApplyFixes] Fix started for issue: ${m}`),a(m,{status:"applying"})},[jM]:({issueId:m,result:S})=>{b.debug(`[useApplyFixes] Fix completed for issue: ${m}`,S),s(m,"applied"),a(m,{status:"applied"})},[HM]:({issueId:m,error:S})=>{b.error(`[useApplyFixes] Fix failed for issue: ${m}`,S),s(m,"failed",S),a(m,{status:"failed",error:S})},[WM]:async({summary:m})=>{if(b.debug("[useApplyFixes] All fixes applied:",m),l(),o(!1),i({succeeded:m.succeeded,failed:m.failed,total:m.total}),m.failed>0?b.warn(`Applied ${m.succeeded}/${m.total} fixes. ${m.failed} failed.`):b.debug(`Successfully applied all ${m.total} fixes!`),m.succeeded>0){b.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{b0.getChannel().emit(NM,{storyId:at.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 ka(),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=hf(m=>{let S=[],T=[],F=[];for(let k of m){let z=k.currentValue||k.actual||"",R=k.suggestedValue||k.expected||"";if(z&&R&&OM(z,R)){S.push(k);continue}if(_M(k)){T.push(k);continue}let O=k.generatedFix?.filePath||k.file||"";if(!O){b.warn(`[useApplyFixes] Skipping issue ${k.id} - no target file path`);continue}let E=O.toLowerCase().split(".").pop()||"",D=["tsx","jsx","ts","js"].includes(E)?"component":"css";F.push({...k,targetFilePath:O,targetFileType:D})}return{actionable:F,negligible:S,designTokens:T}},[]);return{applyFixes:hf(m=>{if(r){b.warn("[useApplyFixes] Already applying fixes");return}if(m.length===0){b.warn("[useApplyFixes] No issues to fix");return}let S=f(m);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 T=S.actionable.filter(z=>z.targetFileType==="css"),F=S.actionable.filter(z=>z.targetFileType==="component");if(b.debug("[useApplyFixes] Applying fixes:"),T.length>0){let z=[...new Set(T.map(R=>R.targetFilePath))];b.debug(` - ${T.length} CSS issue(s) in: ${z.join(", ")}`)}if(F.length>0){let z=[...new Set(F.map(R=>R.targetFilePath))];b.debug(` - ${F.length} component issue(s) in: ${z.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(()=>{at.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."}))},zM),p($M,{issues:S.actionable,storybookRoot:n||void 0})},[p,r,o,i,f,n,l]),isApplying:r}};ke();Re();import{useState as j7}from"react";var V7=G();ke();import{useState as Oo}from"react";Re();Me();nt();var VM=G();async function GM(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 ne(`${VM}/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 S0(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=>GM(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"}}Qc();Zi();Me();Re();var qM=["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"],YM=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],KM=G();function yf(){let[e,t]=Oo(!1),[n,r]=Oo(null),[o,i]=Oo(null),[s,a]=Oo(null),[u,c]=Oo(null),[l,p]=Oo(null),[f,d]=Oo(null),{sessionToken:m}=Ie(),{selectedProjectId:S}=Qe(),{currentStoryId:T,currentStoryName:F}=Ye(),{workspacePath:k,updateIssueGeneratedFix:z,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:O,dismissIssue:E,recalculateScore:D,addStreamingMessage:g}=se();return{generateBatchFixes:async v=>{if(!m){r("Not authenticated");return}if(!S){r("No project selected");return}if(!T){r("No story selected");return}if(v.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),p(null),a({total:v.length,completed:0});let A=v.map(h=>({issueId:h.id,generatedFix:{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"",status:"generating"}}));R(A);try{b.debug("[useBatchGenerateFixes] Generating fixes for",v.length,"issues");let h=null;try{let x=ns();x?.computed&&(h=x.computed,b.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(x){b.warn("[useBatchGenerateFixes] Could not extract computed styles:",x)}let C=null;try{C=await Ls(T),C&&b.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",C)}catch(x){b.warn("[useBatchGenerateFixes] Could not resolve story file paths:",x)}let I=await fetch(`${KM}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:S,storyId:T,workspacePath:k,includeComponentIssues:O,computedStyles:h,storyFilePaths:C,reviewContext:{storyName:F||void 0,variantArgs:Zo()||void 0},issues:v.map(x=>({id:x.id,dbId:x.dbId,title:x.title,description:x.description,property:x.property,currentValue:x.currentValue,suggestedValue:x.suggestedValue,file:x.file,lineNumber:x.lineNumber,severity:x.severity,type:x.type,fixTarget:x.fixTarget,domElement:x.domElement,figmaContext:x.figmaContext,suggestedFix:x.suggestedFix}))})});if(!I.ok){let x=await I.json().catch(()=>({}));throw new Error(x.error||"Batch fix generation failed")}let y=await I.json();if(!y.success)throw new Error(y.error||"Batch fix generation failed");if(b.debug("[useBatchGenerateFixes] Generated",y.result.fixes.length,"fixes"),y.result.storybookRoot&&(d(y.result.storybookRoot),b.debug("[useBatchGenerateFixes] Stored storybookRoot:",y.result.storybookRoot)),y.result.selfReview&&(p(y.result.selfReview),b.debug("[useBatchGenerateFixes] Self-review:",y.result.selfReview)),y.result.partialFailure){let{failedBatches:x,errors:U}=y.result.partialFailure;b.warn(`[useBatchGenerateFixes] Partial failure: ${x.join(", ")} batch(es) failed`),b.warn("[useBatchGenerateFixes] Errors:",U),r(`Some fixes couldn't be generated (${x.join(", ")}): ${U[0]||"Unknown error"}`)}a({total:v.length,completed:y.result.fixes.length});let P=new Set(y.result.fixes.map(x=>x.issueId)),L=v.filter(x=>!P.has(x.id));L.length>0&&(b.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.forEach(x=>{z(x.id,{code:"",diffPreview:"",filePath:x.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),y.timing&&(i({durationSec:y.timing.durationSec,issueCount:y.timing.issueCount,avgPerIssueSec:y.timing.avgPerIssueSec}),b.debug(`[useBatchGenerateFixes] Generation took ${y.timing.durationSec}s for ${y.timing.issueCount} issues`)),y.result?.usage&&(c({inputTokens:y.result.usage.inputTokens||0,outputTokens:y.result.usage.outputTokens||0,costUsd:y.result.usage.costUsd||0,modelId:y.result.usage.modelId||"unknown",provider:y.result.usage.provider||"unknown"}),b.debug(`[useBatchGenerateFixes] Token usage: ${y.result.usage.inputTokens} in, ${y.result.usage.outputTokens} out, $${y.result.usage.costUsd?.toFixed(4)}`));let B=[],N=[];if(y.result.fixes.forEach(x=>{let U=x.noChangesNeeded===!0;if(!U){let Q=(x.fixStrategy||"").toLowerCase(),ee=(x.generatedCode||"").toLowerCase(),J=(x.diffPreview||"").toLowerCase(),Le=qM.some(We=>Q.includes(We.toLowerCase())||Q.replace(/[-_]/g,"").includes(We.replace(/[-_]/g,""))),Ee=YM.some(We=>ee.includes(We)||J.includes(We));U=Le||Ee}let H=v.find(Q=>Q.id===x.issueId);if(U&&H){let Q=H.suggestedValue,ee=H.currentValue;Q&&ee&&!zo(Q,ee)&&(b.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${Q}", actual="${ee}"), NOT auto-dismissing issue ${x.issueId}`),U=!1)}let M=H?.programmaticallyVerified===!0;if(b.debug(`[useBatchGenerateFixes] Processing fix for issue ${x.issueId}:`,{isFalsePositive:U,isProgrammaticIssue:M,detectedBy:H?.detectedBy,noChangesNeeded:x.noChangesNeeded,fixStrategy:x.fixStrategy,title:H?.title?.substring(0,50)}),M&&U&&(b.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${x.issueId} (detectedBy: ${H?.detectedBy})`),U=!1),U){let Q=`Auto-dismissed: ${x.fixStrategy} - values already match`;b.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${x.issueId} - noChangesNeeded: ${x.noChangesNeeded}, strategy: "${x.fixStrategy}"`),E(x.issueId,Q),B.push({localId:x.issueId,dbId:H?.dbId,dismissReason:Q}),N.push({issueId:x.issueId,generatedFix:{code:x.generatedCode||"",diffPreview:x.diffPreview||"",filePath:x.filePath,confidence:x.confidence,strategy:x.fixStrategy,status:"ready",error:void 0,noChangesExplanation:x.noChangesExplanation}})}else{let Q=x.error||x.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:x.issueId,generatedFix:{code:x.generatedCode,diffPreview:x.diffPreview,filePath:x.filePath,confidence:x.confidence,strategy:x.fixStrategy,status:Q,error:x.error,noChangesExplanation:x.noChangesExplanation}})}}),N.length>0&&(b.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),R(N)),B.length>0){if(b.debug(`[useBatchGenerateFixes] Auto-dismissed ${B.length} false positive(s), recalculating score`),D(),m){let U=B.filter(H=>H.dbId).map(H=>({dbId:H.dbId,dismissed:!0,dismissReason:H.dismissReason,dismissedBy:"system"}));U.length>0&&(b.debug(`[useBatchGenerateFixes] Syncing ${U.length} dismissals to server`),S0(U,m).then(H=>{H.success?b.debug(`[useBatchGenerateFixes] Server score updated to: ${H.newScore}`):b.warn("[useBatchGenerateFixes] Failed to sync dismissals:",H.error)}).catch(H=>{b.error("[useBatchGenerateFixes] Error syncing dismissals:",H)}))}let x=B.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${B.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;g({role:"system",content:x})}b.debug("[useBatchGenerateFixes] Updated",y.result.fixes.length,"issues with fixes")}catch(h){b.error("[useBatchGenerateFixes] Failed to generate batch fixes:",h),r(h?.message||"Failed to generate batch fixes");let C=v.map(I=>({issueId:I.id,generatedFix:{code:"",diffPreview:"",filePath:I.file||"",confidence:0,strategy:"",status:"failed",error:h?.message||"Failed to generate fix"}}));R(C)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:f}}ke();Me();Re();nt();import{useState as bf,useCallback as Sf}from"react";var XM=G();function wf(){let[e,t]=bf([]),[n,r]=bf(!1),[o,i]=bf(null),{sessionToken:s}=Ie(),{selectedProjectId:a}=Qe(),{currentStoryId:u}=Ye(),{setReviewResults:c}=se(),l=Sf(async()=>{if(!(!s||!a)){r(!0),i(null);try{let d=new URLSearchParams({projectId:a,limit:"10"});u&&d.append("storyId",u);let m=await ne(`${XM}/api/reviews/list?${d.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!m.ok){let T=await m.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch reviews")}let S=await m.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=Sf(d=>{b.debug("[useReviewHistory] Applying review:",d.id,"with",d.issues.length,"issues");let m=[];if(typeof d.models=="string")try{m=JSON.parse(d.models)}catch(k){b.error("[useReviewHistory] Failed to parse models:",k),m=["claude-sonnet-4-20250514"]}else m=d.models;let S=d.issues.map(k=>({id:k.id,reviewId:d.id,type:k.type,severity:k.severity,title:k.description,description:k.description,file:k.fixTarget||void 0,lineNumber:void 0,property:k.property,currentValue:k.actual,suggestedValue:k.expected,suggestedCode:k.suggestedFix||void 0,status:k.status,dismissed:k.dismissed||!1,dismissReason:k.dismissReason,dismissedBy:k.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(k.createdAt)})),T=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:m[0]||"claude-sonnet-4-5-20250929",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:T}),F){let k=d.issues.filter(E=>!E.dismissed),z=k.filter(E=>E.severity==="critical").length,R=k.filter(E=>E.severity==="major").length,O=k.filter(E=>E.severity==="minor").length;ao(F,{score:d.complianceScore,issueCount:k.length,criticalCount:z,majorCount:R,minorCount:O})}},[c]),f=Sf(d=>{let m=e.find(S=>S.id===d);if(!m){b.error("[useReviewHistory] Review not found:",d);return}p(m)},[e,p]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:f}}ke();Me();import{useEffect as QM,useState as JM,useRef as ml}from"react";import{useChannel as ZM}from"storybook/manager-api";var eB="UICOPILOT/WORKSPACE_PATH",w0="UICOPILOT/REQUEST_WORKSPACE_PATH",tB=3e3,nB=500,rB=5,vf=()=>{let[e,t]=JM({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=se(),r=ml(!1),o=ml(null),i=ml(0),s=ml(null),a=ZM({[eB]:({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 QM(()=>(b.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(w0,{}),s.current=setInterval(()=>{!r.current&&i.current<rB&&(i.current++,b.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(w0,{}))},nB),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}))}},tB),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},kf=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}};ke();Re();import{useEffect as oB,useRef as iB}from"react";var vq=G(),sB=new Set;function Cf(){let{sessionToken:e}=Ie(),{selectedProjectId:t}=Qe(),n=iB(!1);oB(()=>{t&&sB.add(t)},[e,t])}ke();import{useCallback as aB,useState as v0}from"react";function Tf(){let[e,t]=v0(!1),[n,r]=v0(null),{currentStoryId:o}=Ye(),{currentReviewId:i}=se();return{exportPDF:aB(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 k0(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 k0(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 k0(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,m=new t({orientation:(d>c-l*2,"portrait"),unit:"mm",format:"a4"});m.setFillColor("#0ea5e9"),m.rect(0,0,u,20,"F"),m.setTextColor("#ffffff"),m.setFontSize(14),m.setFont("helvetica","bold"),m.text("Design Review Report",l,13);let S=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});m.setFontSize(10),m.setFont("helvetica","normal"),m.text(S,u-l,13,{align:"right"});let T=r?lB(r):"Component Review";m.setTextColor("#1f2937"),m.setFontSize(16),m.setFont("helvetica","bold"),m.text(T,l,30);let F=38,k=c-F-15;if(d<=k)m.addImage(i,"PNG",l,F,p,d);else{let O=d,E=0,D=!0;for(;O>0;){D||m.addPage();let g=D?F:l,w=D?k:c-l*2-10,v=Math.min(O,w),A=v/f*2,h=document.createElement("canvas");h.width=s,h.height=A;let C=h.getContext("2d");if(C){C.drawImage(o,0,E,s,A,0,0,s,A);let I=h.toDataURL("image/png");m.addImage(I,"PNG",l,g,p,v)}E+=A,O-=v,D=!1}}let z=m.getNumberOfPages();for(let O=1;O<=z;O++)m.setPage(O),m.setDrawColor("#e5e7eb"),m.setLineWidth(.3),m.line(l,c-12,u-l,c-12),m.setTextColor("#6b7280"),m.setFontSize(8),m.setFont("helvetica","normal"),m.text("Generated by UI Copilot",l,c-7),m.text(`Page ${O} of ${z}`,u-l,c-7,{align:"right"});let R=`design-review-${(r||"report").replace(/[^a-zA-Z0-9]/g,"-")}.pdf`;m.save(R)}function lB(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 _o,useMemo as D0,useCallback as Si}from"react";Re();Me();nt();import{useState as $r,useEffect as hl,useRef as bi,useCallback as If}from"react";var cB=300;function C0({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=$r([]),[u,c]=$r({}),[l,p]=$r(0),[f,d]=$r([]),[m,S]=$r(new Set),[T,F]=$r(!1),[k,z]=$r(!1),[R,O]=$r(null),E=bi(1),D=bi(null),g=bi(null),[w,v]=$r(0),A=bi(!1),h=bi({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});h.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let C=If(async(B,N,x=!1)=>{let{projectId:U,typeFilter:H,search:M,figmaPage:Q,limit:ee}=h.current;if(!U||!H)return;D.current&&D.current.abort();let J=new AbortController;D.current=J,N?z(!0):F(!0),O(null);try{let Le=G(),Ee=localStorage.getItem("uicopilot_session_token");if(!Ee)throw new Error("Not authenticated. Please connect to UI Copilot first.");let We=new URLSearchParams({projectId:U,page:String(B),limit:String(ee)});H&&We.append("type",H),Q&&We.append("figmaPage",Q),M.trim()&&We.append("search",M.trim()),x&&We.append("refresh","true");let st=await fetch(`${Le}/api/figma/frames?${We.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ee}`},signal:J.signal});if(!st.ok){let ue=await st.json();throw new Error(ue.error||"Failed to fetch frames")}let te=await st.json(),Y=te.frames||[],ce=te.thumbnails||{},ie=st.headers.get("X-Cache-Status");if(Y.length===0&&B===1&&!N&&!x&&!A.current&&ie!=="HIT"){b.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),A.current=!0,await C(1,!1,!0);return}N?(a(ue=>[...ue,...Y]),c(ue=>({...ue,...ce}))):(a(Y),c(ce)),p(te.total||Y.length),te.pages&&d(te.pages),te.cacheDiff?.added&&S(new Set(te.cacheDiff.added)),E.current=B}catch(Le){if(Le instanceof DOMException&&Le.name==="AbortError")return;let Ee=Le instanceof Error?Le.message:"Failed to fetch Figma frames.";O(Ee),b.error("Error fetching frames:",Le)}finally{J.signal.aborted||(F(!1),z(!1))}},[]);hl(()=>{if(!i||!e||!t)return;A.current=!1,g.current&&clearTimeout(g.current);let B=n.trim()?cB:0;return g.current=setTimeout(()=>{E.current=1,C(1,!1)},B),()=>{g.current&&clearTimeout(g.current)}},[e,t,n,r,i,w,C]);let I=bi(new Set);hl(()=>{if(s.length===0)return;let B={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(B[N.id]=N.thumbnailCdnUrl);Object.keys(B).length>0&&c(N=>({...N,...B}))},[s]),hl(()=>{if(s.length===0)return;let B=s.filter(x=>!x.thumbnailCdnUrl&&!u[x.id]&&!I.current.has(x.id)).map(x=>x.id);if(B.length===0)return;B.forEach(x=>I.current.add(x)),(async()=>{try{let{projectId:x}=h.current,U=G(),H=localStorage.getItem("uicopilot_session_token");if(!H||!x)return;let M=await ne(`${U}/api/figma/frames?projectId=${x}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`}});if(M.ok){let Q=await M.json();Q.thumbnails&&Object.keys(Q.thumbnails).length>0&&c(ee=>({...ee,...Q.thumbnails}))}}catch(x){B.forEach(U=>I.current.delete(U)),b.error("Failed to fetch frame thumbnails:",x)}})()},[s,u]),hl(()=>()=>{D.current&&D.current.abort(),g.current&&clearTimeout(g.current)},[]);let y=If(async()=>{let B=E.current+1;await C(B,!0)},[C]),P=If(()=>{A.current=!1,E.current=1,a([]),c({}),v(B=>B+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:f,recentlyAdded:m,isLoading:T,loadingMore:k,hasMore:L,loadMore:y,refresh:P,error:R}}Re();Me();nt();import{useState as xl,useCallback as yl,useRef as uB}from"react";function T0({projectId:e}){let[t,n]=xl({}),[r,o]=xl({}),[i,s]=xl(new Set),[a,u]=xl(new Set),c=uB({}),l=yl(async m=>{if(!(!e||i.has(m))){s(S=>new Set(S).add(m));try{let S=G(),T=localStorage.getItem("uicopilot_session_token"),F=await ne(`${S}/api/figma/variants?projectId=${e}&componentSetId=${m}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`}});if(F.ok){let k=await F.json();if(k.variants){n(R=>({...R,[m]:k.variants}));let z={};for(let R of k.variants)R.thumbnailCdnUrl&&(z[R.id]=R.thumbnailCdnUrl);o(R=>({...R,[m]:{...R[m]||{},...z}})),c.current[m]||(c.current[m]=new Set),Object.keys(z).forEach(R=>c.current[m].add(R))}else o(z=>({...z,[m]:z[m]||{}}))}else o(k=>({...k,[m]:{}}))}catch(S){b.error("Failed to fetch variant metadata:",S),o(T=>({...T,[m]:{}}))}finally{s(S=>{let T=new Set(S);return T.delete(m),T})}}},[e,i]),p=yl(async(m,S)=>{if(!e||S.length===0)return;c.current[m]||(c.current[m]=new Set);let T=r[m]||{},F=S.filter(k=>!c.current[m].has(k)&&!T[k]);if(F.length!==0){F.forEach(k=>c.current[m].add(k)),u(k=>new Set(k).add(m));try{let k=G(),z=localStorage.getItem("uicopilot_session_token"),R=await ne(`${k}/api/figma/variants?projectId=${e}&componentSetId=${m}&thumbnailIds=${F.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`}});if(R.ok){let O=await R.json();O.thumbnails&&Object.keys(O.thumbnails).length>0&&o(E=>({...E,[m]:{...E[m]||{},...O.thumbnails}}))}}catch(k){b.error("Failed to fetch variant thumbnails:",k),F.forEach(z=>c.current[m]?.delete(z))}finally{u(k=>{let z=new Set(k);return z.delete(m),z})}}},[e]),f=yl(m=>{o(S=>{let T={...S};return delete T[m],T}),n(S=>{let T={...S};return delete T[m],T}),delete c.current[m]},[]),d=yl(()=>{o({}),n({}),c.current={}},[]);return{variantChildren:t,variantThumbnails:r,loadingVariants:i,loadingThumbnails:a,fetchVariants:l,fetchVariantThumbnails:p,clearVariantsForSet:f,clearAllVariants:d}}Re();Zi();ke();Me();nt();import{useState as I0,useEffect as F0,useRef as E0,useCallback as Ff}from"react";function A0({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=I0(null),[i,s]=I0(!1),a=E0(null),u=E0(new Set),c=Ff(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let f=Zo();if(!f||Object.keys(f).length===0)return;let d=at.getState().currentStoryId||"",m=d.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,S=>S.toUpperCase());a.current=e,s(!0),o(null);try{let S=G(),T=localStorage.getItem("uicopilot_session_token"),F=await ne(`${S}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({storyName:m,storyId:d,storyArgs:f,availableFilters:t.map(k=>({property:k.property,values:k.values}))})});if(F.ok){let k=await F.json();k.confidence>0&&Object.keys(k.suggestedFilters).length>0&&(b.debug("[useFilterSuggestion] Suggestion:",k),o(k))}}catch(S){b.error("[useFilterSuggestion] Error:",S)}finally{s(!1)}},[e,t,n]);F0(()=>{c()},[c]),F0(()=>{e||(o(null),a.current=null)},[e]);let l=Ff(()=>{},[]),p=Ff(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:p}}function P0(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function L0(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 B0(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 Bs({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=_o(!0),[i,s]=_o(!1),[a,u]=_o(!1),[c,l]=_o(""),[p,f]=_o(""),[d,m]=_o([]),[S,T]=_o(new Set),F=Si(te=>{l(te),d.length>0&&m([]),S.size>0&&T(new Set)},[d.length,S.size]),k=P0(r,i,a),{frames:z,thumbnails:R,totalFrames:O,availablePages:E,recentlyAdded:D,isLoading:g,loadingMore:w,hasMore:v,loadMore:A,refresh:h,error:C}=C0({projectId:e,typeFilter:k,search:c,figmaPage:p||void 0,limit:t,enabled:n&&!!k}),{variantChildren:I,variantThumbnails:y,loadingVariants:P,loadingThumbnails:L,fetchVariants:B,fetchVariantThumbnails:N,clearVariantsForSet:x,clearAllVariants:U}=T0({projectId:e}),H=D0(()=>{let te=L0(I),Y=M0(z),ce={};for(let ie of[...te,...Y])ce[ie.property]||(ce[ie.property]=new Set),ie.values.forEach(ue=>ce[ie.property].add(ue));return Object.entries(ce).map(([ie,ue])=>({property:ie,values:Array.from(ue).sort()}))},[I,z]),M=S.size===1?Array.from(S)[0]:null,Q=A0({expandedSetId:M,availableFilters:H,filtersReady:H.length>0}),ee=Si(()=>{if(!Q.suggestion)return;let{suggestedFilters:te}=Q.suggestion,Y=Object.entries(te).map(([ce,ie])=>({property:ce,value:ie}));m(Y),Q.dismissSuggestion()},[Q.suggestion]),J=D0(()=>d.some(te=>te.value)?z.filter(te=>B0(te,d,I[te.id])):z,[z,d,I]),Le=Si((te,Y)=>{Y.stopPropagation();let ce=!S.has(te);T(ie=>{let ue=new Set(ie);return ue.has(te)?ue.delete(te):ue.add(te),ue}),ce&&!I[te]&&!P.has(te)&&B(te)},[S,I,P,B]),Ee=Si((te,Y)=>{let ce=Y===""?null:Y;m(ie=>ie.find(ct=>ct.property===te)?ie.map(ct=>ct.property===te?{...ct,value:ce}:ct):[...ie,{property:te,value:ce}])},[]),We=Si(()=>{m([])},[]),st=Si(te=>{let Y=z.find(ce=>ce.id===te);if(Y?.thumbnailCdnUrl)return Y.thumbnailCdnUrl;if(R[te])return R[te];for(let ce of Object.values(y))if(ce[te])return ce[te]},[R,y]);return{frames:z,filteredFrames:J,thumbnails:R,totalFrames:O,isLoading:g,loadingMore:w,hasMore:v,error:C,loadMore:A,refresh:h,search:c,setSearch:F,figmaPage:p,setFigmaPage:f,availablePages:E,recentlyAdded:D,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:d,availableFilters:H,handleFilterChange:Ee,clearFilters:We,expandedSets:S,toggleExpanded:Le,variantChildren:I,variantThumbnails:y,loadingVariants:P,loadingThumbnails:L,fetchVariantThumbnails:N,resolveThumbnail:st,filterSuggestion:Q.suggestion,filterSuggestionLoading:Q.isLoading,applySuggestedFilters:ee,dismissFilterSuggestion:Q.dismissSuggestion}}ke();import{useEffect as Tr,useCallback as mB,useState as hB,useRef as xB}from"react";import{useChannel as yB}from"storybook/manager-api";function co(e){return e.status===401||e.status===403}var hn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};function R0(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}}Me();Re();Re();nt();var pB=G();async function Ef(e){let t=await ne(`${pB}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(co(t))throw new hn(t.status);return t.ok?(await t.json()).projects||[]:[]}Re();nt();var dB=G();async function Af(e,t,n){let r=await ne(`${dB}/api/mappings?projectId=${t}&storyId=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(co(r))throw new hn(r.status);return r.ok&&(await r.json()).mapping||null}Re();nt();var fB=G();async function Pf(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 ne(`${fB}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(co(s))throw new hn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}Re();nt();var gB=G();async function Lf(e,t){let n=await ne(`${gB}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(co(n))throw new hn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}function bB(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 SB=G(),wB="UICOPILOT/WORKSPACE_PATH",vB="UICOPILOT/REQUEST_WORKSPACE_PATH",Mf=!1;function Bf(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=Ie(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Qe(),{currentStoryId:l,mappingsRefreshKey:p,setFigmaFileUrl:f,setCurrentMapping:d,setMappingSource:m,setLoadingMapping:S}=Ye(),{setReviewResults:T,setReviewDetailTab:F,setStorybookImageUrl:k,setFigmaImageUrl:z,setFullPrompt:R,setFullResponse:O,bulkAddReviews:E}=se(),[D,g]=hB([]),w=xB(null);Tr(()=>{let h=C=>{C.origin.startsWith(SB)&&C.data?.type==="UICOPILOT_AUTH_SUCCESS"&&C.data.token&&(b.debug("[useDataInit] OAuth success, setting token"),t(C.data.token))};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[t]);let v=yB({[wB]:h=>{b.debug("[useDataInit] Received workspace path:",h.path),c(h.path)}});Tr(()=>{v(vB)},[v]),Tr(()=>{if(!e)return;let h=!1;return(async()=>{try{u(!0);let I=await Ef(e);h||(s(I),n(null))}catch(I){I instanceof hn&&n(I.message),b.error("[useDataInit] Failed to fetch projects:",I)}finally{h||u(!1)}})(),()=>{h=!0}},[e,s,u]),Tr(()=>{if(!i||r.length===0)return;let h=r.find(C=>C.storybookRoot===i);h&&o!==h.id&&(b.debug("[useDataInit] Auto-selecting project:",h.name),a(h.id))},[i,r,o,a]),Tr(()=>{if(!o||r.length===0)return;let h=r.find(I=>I.id===o),C=h?.figmaFileId;if(h&&typeof C=="string"&&C){let I=C,y=I.includes("figma.com")&&R0(I)?.fileKey||I;f(`https://www.figma.com/file/${y}`)}},[o,r,f]),Tr(()=>!e||!o||Mf?void 0:(Mf=!0,(async()=>{try{let C=await Lf(e,o);for(let[I,y]of Object.entries(C))ao(I,{score:y.score,issueCount:y.issueCount,criticalCount:y.criticalCount,majorCount:y.majorCount,minorCount:y.minorCount});b.debug("[useDataInit] Populated sidebar badges for",Object.keys(C).length,"stories")}catch(C){C instanceof hn&&n(C.message),b.error("[useDataInit] Failed to fetch review statuses:",C)}})(),()=>{Mf=!1}),[e,o]),Tr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{S(!0);let I=await Af(e,o,l);if(h)return;I?(d(I),m("database")):(d(null),m(null))}catch(I){I instanceof hn&&n(I.message),b.error("[useDataInit] Failed to fetch mapping:",I)}finally{h||S(!1)}})(),()=>{h=!0}},[e,o,l,p,d,m,S]),Tr(()=>{g([]),w.current=null},[l]),Tr(()=>{if(!e||!o||!l)return;let h=!1;return(async()=>{try{let I=await Pf(e,o,l,10,!0);if(!h){g(I);let y=I.map(P=>bB(P)).filter(Boolean);y.length>0&&E(y)}}catch(I){I instanceof hn&&n(I.message),b.error("[useDataInit] Failed to fetch reviews:",I)}})(),()=>{h=!0}},[e,o,l]);let A=mB(h=>{b.debug("[useDataInit] Applying review:",h.id,"with",h.issues.length,"issues");let C=[];if(typeof h.models=="string")try{C=JSON.parse(h.models)}catch{C=["claude-sonnet-4-20250514"]}else C=h.models;let I=h.issues.map(L=>({id:L.id,reviewId:h.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)})),y=h.completedAt&&h.createdAt?new Date(h.completedAt).getTime()-new Date(h.createdAt).getTime():void 0,P=h.storyId||"";if(T({id:h.id,componentId:"",storyId:P,modelId:C[0]||"claude-sonnet-4-5-20250929",complianceScore:h.complianceScore,issuesCount:h.issuesCount,issues:I,createdAt:new Date(h.createdAt),timestamp:new Date(h.createdAt).toISOString(),costUsd:h.costUsd,inputTokens:h.inputTokens,outputTokens:h.outputTokens,reviewDurationMs:y}),h.storybookScreenshot&&(k(h.storybookScreenshot),b.debug("[useDataInit] Loaded persisted Storybook screenshot")),h.figmaScreenshot&&(z(h.figmaScreenshot),b.debug("[useDataInit] Loaded persisted Figma screenshot")),h.aiPrompt&&(R(h.aiPrompt),b.debug("[useDataInit] Loaded persisted AI prompt")),h.aiResponse&&(O(h.aiResponse),b.debug("[useDataInit] Loaded persisted AI response")),P){let L=h.issues.filter(U=>!U.dismissed),B=L.filter(U=>U.severity==="critical").length,N=L.filter(U=>U.severity==="major").length,x=L.filter(U=>U.severity==="minor").length;ao(P,{score:h.complianceScore,issueCount:L.length,criticalCount:B,majorCount:N,minorCount:x})}},[T,k,z,R,O]);Tr(()=>{if(D.length>0&&l&&w.current!==l){let h=D[0];h&&h.storyId===l&&(b.debug("[useDataInit] Auto-loading review:",h.id,"for:",l),w.current=l,A(h),F("issues"))}},[D,l,A,F])}import{styled as Ds}from"storybook/theming";var kB=Ds.div({display:"flex",gap:"10px",marginTop:"8px"}),z0=Ds.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),CB=Ds.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"})),TB=Ds.div({display:"flex",alignItems:"center",gap:"8px"}),IB=Ds(Hn)(({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"})),N0=()=>{let{sessionToken:e,authMethod:t,setAuthMethod:n,startOAuth:r,logout:o}=Ki();return It.createElement(It.Fragment,null,It.createElement(To,null,It.createElement(Io,null,"Authentication Method"),It.createElement(kB,null,It.createElement(z0,null,It.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),It.createElement(z0,null,It.createElement("input",{type:"radio",name:"authMethod",checked:t==="apikey",onChange:()=>n("apikey")}),"API Key"))),t==="oauth"&&It.createElement(To,null,It.createElement(Io,null,"Connect to UI Copilot"),e?It.createElement(CB,null,It.createElement(TB,null,It.createElement("span",{style:{fontSize:"18px"}},"\u2713"),It.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Copilot")),It.createElement(IB,{onClick:o},"Disconnect")):It.createElement("div",null,It.createElement(Ec,{style:{marginBottom:"12px"}},"Connect to UI Copilot to manage projects and integrations. This will open a browser window for authentication."),It.createElement(Hn,{onClick:r},"\u{1F517} Connect to UI Copilot"))),t==="apikey"&&It.createElement(To,null,It.createElement(Io,null,"API Key"),It.createElement(Ec,{style:{marginBottom:"12px"}},"Enter your UI Copilot API key below."),It.createElement(Fo,{type:"password",placeholder:"Enter API key",disabled:!0}),It.createElement(Hn,{disabled:!0,style:{marginTop:"12px"}},"Save API Key")))};import jt,{useState as Df}from"react";ke();import{styled as fr}from"storybook/theming";var FB=fr.div({marginBottom:"30px"}),EB=fr.div({display:"flex",gap:"8px",alignItems:"center"}),AB=fr(wn)({flex:1}),PB=fr(_t)({padding:"8px 12px",whiteSpace:"nowrap"}),LB=fr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),Rf=fr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),zf=fr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Nf=fr(Fo)({fontSize:"13px",padding:"6px 8px"}),MB=fr.div({display:"flex",gap:"8px",marginTop:"12px"}),O0=fr(_t)({fontSize:"12px",padding:"6px 12px"}),BB=fr(O0)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),_0=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o}=ir(),{currentStorybookPath:i}=Qe(),[s,a]=Df(!1),[u,c]=Df(!1),[l,p]=Df({name:"",storybookRoot:"",figmaFileUrl:""}),f=T=>{n(T||null),a(!1)},d=()=>{if(a(!0),i){let T=i.replace(/\/+$/,"").split("/").pop()||"";p({storybookRoot:i,name:T,figmaFileUrl:""})}},m=async()=>{if(l.name.trim())try{c(!0);let T;if(l.figmaFileUrl.trim()){let k=l.figmaFileUrl.trim(),z=k.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);T=z?z[1]:k}let F=await o({name:l.name.trim(),storybookRoot:l.storybookRoot.trim()||void 0,figmaFileId:T});n(F.id),a(!1),p({name:"",storybookRoot:"",figmaFileUrl:""})}catch(T){console.error("Failed to create project:",T)}finally{c(!1)}},S=T=>{p(F=>{let k={...F,storybookRoot:T};if(!F.name&&T){let z=T.replace(/\/+$/,"").split("/").pop()||"";k.name=z}return k})};return jt.createElement(FB,null,jt.createElement(ih,null,"Project"),jt.createElement(EB,null,jt.createElement(AB,{value:t||"",onChange:T=>f(T.target.value),disabled:r||s},jt.createElement("option",{value:""},"-- Select a project --"),e.map(T=>jt.createElement("option",{key:T.id,value:T.id},T.name))),jt.createElement(PB,{onClick:d,disabled:r,type:"button"},"+ New")),s&&jt.createElement(LB,null,jt.createElement(Rf,null,jt.createElement(zf,null,"Storybook Path (for fix generation)"),jt.createElement(Nf,{type:"text",placeholder:"/path/to/your/storybook",value:l.storybookRoot,onChange:T=>S(T.target.value)})),jt.createElement(Rf,null,jt.createElement(zf,null,"Project Name *"),jt.createElement(Nf,{type:"text",placeholder:"my-storybook",value:l.name,onChange:T=>{let F=T.target.value;p(k=>({...k,name:F}))}})),jt.createElement(Rf,null,jt.createElement(zf,null,"Figma File URL (for design comparison)"),jt.createElement(Nf,{type:"text",placeholder:"https://www.figma.com/file/...",value:l.figmaFileUrl,onChange:T=>{let F=T.target.value;p(k=>({...k,figmaFileUrl:F}))}})),jt.createElement(MB,null,jt.createElement(O0,{onClick:m,disabled:u||!l.name.trim()},u?"Creating...":"Create"),jt.createElement(BB,{onClick:()=>{a(!1),p({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import dt,{useState as pg,useCallback as vw,useEffect as Iz}from"react";import{styled as gr}from"storybook/theming";import wi,{useState as Of,useEffect as DB,useCallback as $0}from"react";import{styled as vi}from"storybook/theming";ke();Re();nt();var RB=vi.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),zB=vi.label(({theme:e})=>({display:"block",fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"8px"})),NB=vi.div({display:"flex",gap:"8px",alignItems:"center"}),OB=vi.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:ae,boxShadow:`0 0 0 1px ${ae}`},"&::placeholder":{color:e.color.mediumlight}})),_B=vi(_t)({whiteSpace:"nowrap"}),$B=vi.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),U0=()=>{let{selectedProjectId:e,projects:t}=Qe(),{sessionToken:n}=Ie(),{updateProject:r}=ir(),o=t.find(S=>S.id===e),[i,s]=Of(""),[a,u]=Of(!1),[c,l]=Of(null),p=o?.figmaFileUrl||o?.figmaFileId||"";DB(()=>{s(p),l(null)},[o?.id,p]);let f=i!==p,d=$0(async()=>{if(!(!e||!f))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});try{let S=G();await ne(`${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]),m=$0(S=>{S.key==="Enter"&&f&&!a&&d()},[f,a,d]);return e?wi.createElement(RB,null,wi.createElement(zB,null,"Figma File URL"),wi.createElement(NB,null,wi.createElement(OB,{type:"text",value:i,onChange:S=>s(S.target.value),onKeyDown:m,placeholder:"https://www.figma.com/file/..."}),wi.createElement(_B,{onClick:d,disabled:!f||a},a?"Saving...":"Save")),c&&wi.createElement($B,{variant:c.type},c.message)):null};import gt,{useState as Bl,useEffect as rz}from"react";import{styled as Nn}from"storybook/theming";ke();Re();import He,{useState as Ii,useEffect as ER,useCallback as go}from"react";import{styled as Gt}from"storybook/theming";Re();Re();Me();import K,{useState as Ci,useEffect as ES,useMemo as Qf,useCallback as AS}from"react";import{styled as $e}from"storybook/theming";nt();import Ae,{useState as FS,useEffect as UB,memo as jB}from"react";import{styled as ye}from"storybook/theming";var j0=ye.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}),H0=ye.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}`})),W0=ye.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),V0=ye.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),G0=ye(fn)({fontSize:"20px",padding:"4px 8px"}),q0=ye.div({flex:1,overflow:"auto",padding:"20px"}),Y0=ye(Qr)({fontSize:"14px",marginBottom:"16px"}),_f=ye.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),K0=ye.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:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),$f=ye.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"})),X0=ye.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"})),Q0=ye.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),Rs=ye.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})),Uf=ye.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),zs=ye.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),jf=ye.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Hf=ye.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Wf=ye.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),Vf=ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),J0=ye.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),bl=ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),Z0=ye.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),eS=ye.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),tS=ye.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:ae}})),nS=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ae}`,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:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),rS=ye.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:ae,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),oS=ye.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),wK=ye.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"})),iS=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ae}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),sS=ye.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%"}}})),Gf=ye.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"}})),aS=ye.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})),lS=ye.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),cS=ye.span(({theme:e})=>({color:e.color.defaultText})),Sl=ye.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%"}}})),uS=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),pS=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),dS=ye.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),fS=ye(wn)({flex:1,width:"auto"}),gS=ye.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),mS=ye.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"})),hS=ye.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),xS=ye.span(({theme:e})=>({color:e.color.defaultText})),yS=ye.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}})),bS=ye.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}})),SS=ye.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),wl=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),Ns=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),ki=ye(wn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),vl=ye.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`}})),wS=ye.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),vS=ye.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:ae,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),kS=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),qf=ye.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?ae: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:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Yf=ye.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?ae:e.appBorderColor}`,backgroundColor:t?ae:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),CS=ye.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),TS=ye.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:ae,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:ae,opacity:t?.6:.9}})),IS=ye.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"}));Me();var Kf=jB(({src:e,alt:t,isComponentSet:n,loadingDone:r})=>{let[o,i]=FS(!1),[s,a]=FS(!1);return UB(()=>{i(!1),a(!1)},[e]),o?Ae.createElement(Rs,null,Ae.createElement(jf,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Ae.createElement(zs,null,"Failed to load")):e?Ae.createElement(Ae.Fragment,null,!s&&Ae.createElement(Rs,{style:{position:"absolute",inset:0}},Ae.createElement(Uf,null),Ae.createElement(zs,null,"Loading...")),Ae.createElement(Q0,{src:e,alt:t,onLoad:()=>a(!0),onError:()=>i(!0),style:{opacity:s?1:0}})):r?Ae.createElement(Rs,null,Ae.createElement(jf,null,n?"\u229E":"\u{1F5BC}\uFE0F"),Ae.createElement(zs,null,"No preview")):Ae.createElement(Rs,null,Ae.createElement(Uf,null),Ae.createElement(zs,null,"Loading..."))}),Os=({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",m=d&&(e.children&&e.children.length>0||(e.childCount??0)>0),S=e.children||o||[],T=Ae.useMemo(()=>S.length===0?[]:f.some(z=>z.value)?S.filter(z=>z.variantProperties?f.every(R=>R.value?z.variantProperties?.[R.property]===R.value:!0):!1):S,[S,f]),F=z=>{if(d&&m){u(e.id,z);return}c(e)},k=l?qf:K0;return Ae.createElement(Ae.Fragment,null,Ae.createElement(k,{onClick:F,title:e.name,isSelected:l?p.has(e.id):void 0,style:{cursor:"pointer"}},l&&!m&&Ae.createElement(Yf,{isSelected:p.has(e.id)},p.has(e.id)?"\u2713":""),d?Ae.createElement(X0,null,m&&Ae.createElement(tS,{onClick:z=>u(e.id,z),title:s?"Collapse variants":"Expand variants"},s?"\u25BC":"\u25B6"),m&&Ae.createElement(rS,null,T.length>0&&T.length!==S.length?`${T.length} / ${S.length}`:e.childCount??S.length," variants"),Ae.createElement(Kf,{src:t,alt:e.name,isComponentSet:!0})):Ae.createElement($f,null,Ae.createElement(Kf,{src:t,alt:e.name,isComponentSet:!1})),Ae.createElement(Hf,null,Ae.createElement(Wf,null,e.name,a&&Ae.createElement(IS,null,"New")),Ae.createElement(Vf,null,e.type))),m&&s&&i&&Ae.createElement(Ae.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((z,R)=>Ae.createElement(iS,{key:`skeleton-${R}`},Ae.createElement(sS,null),Ae.createElement(Gf,{width:"80%"}),Ae.createElement(Gf,{width:"50%"})))),m&&s&&!i&&T.map(z=>Ae.createElement(Xf,{key:z.id,variant:z,thumbnail:r?.[z.id]||n[z.id],onSelect:c,multiSelect:l,isSelected:p.has(z.id),loadingDone:!!t||r!==void 0&&z.id in(r||{})})))},Xf=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1})=>Ae.createElement(r?qf:nS,{onClick:()=>{b.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&Ae.createElement(Yf,{isSelected:o},o?"\u2713":""),Ae.createElement($f,null,Ae.createElement(Kf,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i})),Ae.createElement(Hf,null,Ae.createElement(Wf,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&Ae.createElement(oS,null,Object.entries(e.variantProperties).map(([u,c])=>Ae.createElement(aS,{key:u},Ae.createElement(lS,null,u,":")," ",Ae.createElement(cS,null,c)))),Ae.createElement(Vf,{style:{marginTop:"6px"}},"VARIANT")));var HB=$e.div({display:"flex",height:"100%",overflow:"hidden"}),WB=$e.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),VB=$e.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),PS=$e.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),LS=$e.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),kl=$e.div({display:"flex",gap:"8px",marginTop:"10px"}),GB=$e(wn)({flex:1,width:"auto"}),MS=$e(Qr)({flex:1,fontSize:"13px"}),qB=$e.div({flex:1,overflow:"auto",padding:"8px"}),YB=$e.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}})),KB=$e.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),XB=$e.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),QB=$e.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})),JB=$e.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),ZB=$e.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"})),eD=$e.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),tD=$e.div({flex:1,overflow:"hidden"}),nD=$e.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),rD=$e.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)"}}})),oD=$e.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),iD=$e.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),sD=$e.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),aD=$e.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Jf=$e.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),lD=$e.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Zf=20,cD=$e.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),uD=$e.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`}})),pD=$e.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),dD=$e.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`}})),fD=$e.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),eg=$e.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),tg=$e.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),gD=$e.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),mD=$e.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),BS=$e.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),DS=$e.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"}}})),RS=$e.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"}}})),hD=()=>K.createElement(mD,null,Array.from({length:8}).map((e,t)=>K.createElement(BS,{key:t},K.createElement(DS,null),K.createElement(RS,{width:`${60+t%3*15}%`})))),xD=$e.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"})),yD=$e.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"}),bD=$e.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)"}}})),SD=$e.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),zS=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=Bs({projectId:i,limit:Zf,enabled:!!i}),[a,u]=Ci("all"),[c,l]=Ci(""),[p,f]=Ci(null),[d,m]=Ci(1),[S,T]=Ci(null),[F,k]=Ci(!1),z=Qf(()=>{let h=new Set;return e.forEach(C=>{C.componentTitle&&h.add(C.componentTitle)}),Array.from(h).sort()},[e]),R=Qf(()=>e.filter(h=>{if(a!=="all"&&h.componentTitle!==a)return!1;if(c){let C=c.toLowerCase();return h.name.toLowerCase().includes(C)||h.title.toLowerCase().includes(C)}return!0}),[e,a,c]),O=p?s.frames.find(h=>h.id===p):null,E=Qf(()=>{if(!p)return[];let h=s.variantChildren[p]||[];return h.length===0?[]:s.variantFilters.some(C=>C.value)?h.filter(C=>C.variantProperties?s.variantFilters.every(I=>I.value?C.variantProperties?.[I.property]===I.value:!0):!1):h},[p,s.variantChildren,s.variantFilters]),D=E.slice(0,d*Zf),g=E.length>d*Zf;ES(()=>{if(!p||D.length===0)return;let h=D.map(C=>C.id);s.fetchVariantThumbnails(p,h)},[p,D.length,d]),ES(()=>{k(!1)},[]);let w=AS(async h=>{if(n)try{let C=G(),I=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${C}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:h.id,name:h.name})})).ok)throw new Error("Failed to save mapping");o(n,h.id,h.name)}catch(C){b.error("[MapStoriesTab] Error saving mapping:",C)}},[n,i,o]),v=AS((h,C)=>{if(C.stopPropagation(),p===h){f(null),m(1);return}f(h),m(1),!s.variantThumbnails[h]&&!s.loadingVariants.has(h)&&s.toggleExpanded(h,C)},[p,s]),A=e.find(h=>h.id===n);return t?K.createElement(gD,null,"Loading stories..."):K.createElement(HB,null,K.createElement(WB,null,K.createElement(PS,null,K.createElement(LS,null,"Storybook Stories"),K.createElement(kl,null,K.createElement(GB,{value:a,onChange:h=>u(h.target.value)},K.createElement("option",{value:"all"},"All Components"),z.map(h=>K.createElement("option",{key:h,value:h},h)))),K.createElement(kl,null,K.createElement(MS,{type:"text",placeholder:"Search stories...",value:c,onChange:h=>l(h.target.value)}))),K.createElement(qB,null,R.length===0?K.createElement(tg,null,"No stories found"):R.map(h=>K.createElement(YB,{key:h.id,selected:h.id===n,mapped:!!h.figmaMapping,onClick:()=>r(h.id)},K.createElement(KB,null,K.createElement(XB,null,h.name),K.createElement(QB,{mapped:!!h.figmaMapping},h.figmaMapping?"Mapped":"Unmapped")),K.createElement(JB,null,h.title),h.figmaMapping&&K.createElement(ZB,{onMouseEnter:()=>T(h.id),onMouseLeave:()=>T(null)},(()=>{let C=h.figmaMapping?.figmaNodeId,I=C?s.resolveThumbnail(C):void 0;return K.createElement(K.Fragment,null,I?K.createElement(eD,{src:I,alt:h.figmaMapping?.figmaFrameName||""}):K.createElement("span",null,"\u{1F517}"),S===h.id&&I&&K.createElement(rD,null,K.createElement(oD,{src:I,alt:h.figmaMapping?.figmaFrameName||""}),K.createElement(iD,null,h.figmaMapping?.figmaFrameName)))})(),K.createElement(tD,null,K.createElement(nD,null,h.figmaMapping.figmaFrameName))))))),K.createElement(VB,null,n?K.createElement(K.Fragment,null,K.createElement(xD,null,K.createElement("span",null,"Click a Figma component below to link it to"," ",K.createElement("strong",null,A?.name))),K.createElement(PS,null,K.createElement(LS,null,"Figma Components"),K.createElement(kl,null,K.createElement(aD,null,K.createElement(Jf,null,K.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:h=>s.setShowComponentSets(h.target.checked)}),"Component Sets"),K.createElement(Jf,null,K.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:h=>s.setShowFrames(h.target.checked)}),"Frames"),K.createElement(Jf,null,K.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:h=>s.setShowComponents(h.target.checked)}),"Components")),s.availablePages.length>1&&K.createElement(ki,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:h=>s.setFigmaPage(h.target.value)},K.createElement("option",{value:""},"All pages"),s.availablePages.map(h=>K.createElement("option",{key:h,value:h},h)))),s.availableFilters.length>0&&K.createElement(wl,null,K.createElement(Ns,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:h,values:C})=>{let I=s.variantFilters.find(y=>y.property===h);return K.createElement(ki,{key:h,isActive:!!I?.value,value:I?.value||"",onChange:y=>s.handleFilterChange(h,y.target.value)},K.createElement("option",{value:""},h),C.map(y=>K.createElement("option",{key:y,value:y},h,"=",y)))}),s.availableFilters.length>5&&K.createElement(Ns,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(h=>h.value)&&K.createElement(vl,{onClick:s.clearFilters},"Clear All")),K.createElement(kl,null,K.createElement(MS,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:h=>s.setSearch(h.target.value)}))),K.createElement(sD,null,F&&K.createElement(yD,null,K.createElement(bD,null),K.createElement(SD,null,"Loading thumbnails...")),s.isLoading?K.createElement(hD,null):s.filteredFrames.length===0?K.createElement(tg,null,K.createElement("span",null,"No components found")):K.createElement(lD,null,p&&O?K.createElement(K.Fragment,null,K.createElement(pD,null,K.createElement(dD,{onClick:()=>{f(null),m(1)}},"Back"),K.createElement(fD,null,O.name)),s.loadingVariants.has(p)?K.createElement(K.Fragment,null,K.createElement(eg,null,"Loading ",O.childCount??"..."," variants..."),Array.from({length:Math.min(8,O.childCount??8)}).map((h,C)=>K.createElement(BS,{key:`variant-skeleton-${C}`},K.createElement(DS,null),K.createElement(RS,{width:`${60+C%3*15}%`})))):K.createElement(K.Fragment,null,K.createElement(eg,null,"Showing ",D.length," of ",E.length," variants"),D.map(h=>K.createElement(Xf,{key:h.id,variant:h,thumbnail:s.variantThumbnails[p]?.[h.id]||s.thumbnails[h.id],onSelect:w,loadingDone:s.variantThumbnails[p]!==void 0&&!s.loadingVariants.has(p)})))):K.createElement(K.Fragment,null,K.createElement(eg,null,"Showing ",s.frames.length," of ",s.totalFrames," components"),s.filteredFrames.map(h=>K.createElement(Os,{key:h.id,frame:h,thumbnail:s.thumbnails[h.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[h.id],variantChildren:s.variantChildren[h.id],isLoadingVariants:s.loadingVariants.has(h.id),isExpanded:!1,onToggleExpand:v,onSelect:w,variantFilters:s.variantFilters}))),(p?g:s.hasMore)&&K.createElement(cD,null,K.createElement(uD,{disabled:s.loadingMore,onClick:async()=>{p?m(h=>h+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):K.createElement(tg,null,K.createElement("span",null,"Select a story from the left to link it to Figma"))))};Re();import Ve,{useState as ng,useMemo as NS,useCallback as OS}from"react";import{styled as At}from"storybook/theming";nt();var wD=At.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),vD=At.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),kD=At(wn)({width:"auto",minWidth:"200px"}),CD=At(Qr)({fontSize:"13px",minWidth:"250px"}),TD=At.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}})),ID=At.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}})),FD=At.div({flex:1,overflow:"auto"}),ED=At.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),AD=At.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),Cl=At.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}`})),PD=At.tbody({}),LD=At.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),Tl=At.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),MD=At.div({display:"flex",flexDirection:"column",gap:"2px"}),BD=At.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),DD=At.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),RD=At.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),zD=At.div({display:"flex",alignItems:"center",gap:"8px"}),ND=At.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),OD=At.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),_S=At.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`}})),_D=At.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),$D=At.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),$S=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=ng("all"),[a,u]=ng(""),[c,l]=ng(!0),p=NS(()=>{let T=new Set;return e.forEach(F=>{F.componentTitle&&T.add(F.componentTitle)}),Array.from(T).sort()},[e]),f=NS(()=>e.filter(T=>{if(i!=="all"&&T.componentTitle!==i||!c&&!T.figmaMapping)return!1;if(a){let F=a.toLowerCase();return T.name.toLowerCase().includes(F)||T.title.toLowerCase().includes(F)||(T.figmaMapping?.figmaFrameName?.toLowerCase().includes(F)??!1)}return!0}),[e,i,a,c]),d=OS(async T=>{try{let F=G(),k=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${F}/api/mappings?projectId=${o}&storyId=${T}`,{method:"DELETE",headers:{Authorization:`Bearer ${k}`}})).ok)throw new Error("Failed to delete mapping");r(T)}catch(F){console.error("[ViewAllMappingsTab] Error unlinking:",F)}},[o,r]),m=OS(()=>{let T=e.filter(R=>R.figmaMapping).map(R=>({storyId:R.id,storyName:R.name,storyTitle:R.title,figmaNodeId:R.figmaMapping.figmaNodeId,figmaFrameName:R.figmaMapping.figmaFrameName})),F=new Blob([JSON.stringify(T,null,2)],{type:"application/json"}),k=URL.createObjectURL(F),z=document.createElement("a");z.href=k,z.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(k)},[e]);if(t)return Ve.createElement($D,null,"Loading mappings...");let S=e.filter(T=>T.figmaMapping).length;return Ve.createElement(wD,null,Ve.createElement(vD,null,Ve.createElement(kD,{value:i,onChange:T=>s(T.target.value)},Ve.createElement("option",{value:"all"},"All Components"),p.map(T=>Ve.createElement("option",{key:T,value:T},T))),Ve.createElement(CD,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:T=>u(T.target.value)}),Ve.createElement(TD,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),Ve.createElement(ID,{onClick:m,disabled:S===0},"\u{1F4E5} Export JSON")),f.length===0?Ve.createElement(_D,null,Ve.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):Ve.createElement(FD,null,Ve.createElement(ED,null,Ve.createElement(AD,null,Ve.createElement("tr",null,Ve.createElement(Cl,{style:{width:"35%"}},"Story"),Ve.createElement(Cl,{style:{width:"35%"}},"Figma Component"),Ve.createElement(Cl,{style:{width:"15%"}},"Status"),Ve.createElement(Cl,{style:{width:"15%"}},"Actions"))),Ve.createElement(PD,null,f.map(T=>Ve.createElement(LD,{key:T.id,mapped:!!T.figmaMapping},Ve.createElement(Tl,null,Ve.createElement(MD,null,Ve.createElement(BD,null,T.name),Ve.createElement(DD,null,T.title))),Ve.createElement(Tl,null,Ve.createElement(RD,{mapped:!!T.figmaMapping},T.figmaMapping?Ve.createElement(Ve.Fragment,null,Ve.createElement("span",null,"\u{1F3A8}"),T.figmaMapping.figmaFrameName):"\u2014")),Ve.createElement(Tl,null,Ve.createElement(zD,null,Ve.createElement(ND,{mapped:!!T.figmaMapping}),Ve.createElement(OD,{mapped:!!T.figmaMapping},T.figmaMapping?"Mapped":"Unmapped"))),Ve.createElement(Tl,null,T.figmaMapping?Ve.createElement(_S,{variant:"unlink",onClick:()=>d(T.id)},"Unlink"):Ve.createElement(_S,{variant:"link",onClick:()=>n(T.id)},"Link"))))))))};import ve,{useState as Ll,useMemo as qS}from"react";import{styled as it}from"storybook/theming";import US from"react";import{styled as jS,keyframes as UD}from"storybook/theming";var jD=UD`
|
|
31
31
|
0% { transform: rotate(0deg); }
|
|
32
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`
|
|
33
|
+
`,HD=jS.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${jD} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),WD=jS.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}}})),Ir=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>US.createElement(WD,{variant:r,disabled:t||e,onClick:n},e&&US.createElement(HD,null),e&&i?i:o);Re();import Qt from"react";import{styled as _s}from"storybook/theming";var HS=_s.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"})),VD=_s.div({display:"flex",alignItems:"center",gap:"12px"}),Il=_s.span({whiteSpace:"nowrap"}),WS=_s.div({display:"flex",alignItems:"center",gap:"8px"}),Fl=_s.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),El=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*Ch;return r?Qt.createElement(HS,null,Qt.createElement(Il,null,o.toLocaleString()," tokens"),Qt.createElement(WS,null,Qt.createElement(Fl,null,"$",n.toFixed(4)),Qt.createElement("span",null,"\xB7"),Qt.createElement(Fl,null,"\u20AA",i.toFixed(2)))):Qt.createElement(HS,null,Qt.createElement(VD,null,Qt.createElement(Il,null,e.toLocaleString()," input"),Qt.createElement("span",null,"+"),Qt.createElement(Il,null,t.toLocaleString()," output"),Qt.createElement("span",null,"="),Qt.createElement(Il,null,Qt.createElement("strong",null,o.toLocaleString())," tokens")),Qt.createElement(WS,null,Qt.createElement(Fl,null,"$",n.toFixed(4)),Qt.createElement("span",null,"\xB7"),Qt.createElement(Fl,null,"\u20AA",i.toFixed(2))))};import An from"react";import{styled as uo}from"storybook/theming";function rg(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var GD=uo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),VS=uo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),qD=uo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),YD=uo.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})),KD=uo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),XD=uo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),QD=uo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),JD=uo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),GS=({data:e,color:t,compact:n})=>n?An.createElement(VS,{color:t},e.summary):An.createElement(GD,null,An.createElement(VS,{color:t},e.summary),e.mappings&&e.mappings.length>0&&An.createElement(qD,null,e.mappings.map((r,o)=>An.createElement(An.Fragment,{key:o},An.createElement(YD,null,r.from," ",An.createElement(KD,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&An.createElement(XD,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&An.createElement(An.Fragment,null,e.defaults.map((r,o)=>An.createElement(QD,{key:o},An.createElement(JD,null,r.choice),An.createElement("span",null,"\u2014 ",r.why)))));var ZD=it.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),eR=it.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),tR=it.div({display:"flex",flexDirection:"column",gap:"4px"}),nR=it.div({display:"flex",alignItems:"center",gap:"10px"}),rR=it.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"})),YS=it.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})),oR=it.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),iR=it.div({display:"flex",gap:"8px"}),sR=it.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),aR=it(Qr)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),lR=it.div({display:"flex",gap:"4px"}),Al=it.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}})),cR=it.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),uR=it.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}})),pR=it.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}`}})),dR=it.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"})),Pl=it.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}`})),fR=it.img({width:"100%",height:"100%",objectFit:"contain"}),ZS=it.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)"}}})),KS=it.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),XS=it.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"})),og=it.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"})),aX=it.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"})),gR=it.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),mR=it.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})),hR=it.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}})),xR=it.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),yR=it.div({display:"flex",flexWrap:"wrap",gap:"6px"}),bR=it.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})),SR=it.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})),wR=it.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"}})),lX=it.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})),QS=({src:e,alt:t})=>{let[n,r]=Ll(!1);return ve.createElement(ve.Fragment,null,!n&&ve.createElement(ZS,null),ve.createElement(fR,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function JS(e){return e>=90?"high":e>=70?"medium":"low"}function vR(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var ew=({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]=Ll(()=>{let v=new Set;for(let A of e.mappings)A.confidence>=90&&v.add(A.storyId);return v}),[m,S]=Ll(""),[T,F]=Ll("all"),k=qS(()=>{let v=new Map;for(let A of t)v.set(A.id,{name:A.name,title:A.title});return v},[t]),z=qS(()=>{let v=e.mappings;if(T!=="all"&&(v=v.filter(A=>JS(A.confidence)===T)),m.trim()){let A=m.toLowerCase();v=v.filter(h=>{let C=k.get(h.storyId);return C?.name.toLowerCase().includes(A)||C?.title.toLowerCase().includes(A)||h.componentSetName.toLowerCase().includes(A)||h.figmaFrameName.toLowerCase().includes(A)})}return v},[e.mappings,T,m,k]),R=v=>{d(A=>{let h=new Set(A);return h.has(v)?h.delete(v):h.add(v),h})},O=()=>{let v=e.mappings.filter(A=>f.has(A.storyId));n(v)},E=e.mappings.filter(v=>v.confidence>=90).length,D=e.mappings.filter(v=>v.confidence>=70&&v.confidence<90).length,g=e.mappings.filter(v=>v.confidence<70).length,w=e.usage;return ve.createElement(ZD,null,ve.createElement(eR,null,ve.createElement(tR,null,ve.createElement(nR,null,ve.createElement(rR,null,"Auto-Map Results"),ve.createElement(YS,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&ve.createElement(YS,{variant:"danger"},e.unmatched.length," unmatched"),a&&ve.createElement(SR,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),ve.createElement(oR,null,"Review matches below. Uncheck any incorrect mappings before applying.")),ve.createElement(iR,null,a==="cache"&&o&&ve.createElement(wR,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),ve.createElement(Ir,{onClick:r,variant:"ghost"},"Cancel"),ve.createElement(Ir,{loading:i,onClick:O,loadingText:"Applying..."},"Apply ",f.size," Selected"))),ve.createElement(sR,null,ve.createElement(aR,{type:"text",placeholder:"Filter stories...",value:m,onChange:v=>S(v.target.value)}),ve.createElement(lR,null,ve.createElement(Al,{active:T==="all",onClick:()=>F("all")},"All ",e.mappings.length),E>0&&ve.createElement(Al,{active:T==="high",onClick:()=>F("high")},"\u226590% (",E,")"),D>0&&ve.createElement(Al,{active:T==="medium",onClick:()=>F("medium")},"70-89% (",D,")"),g>0&&ve.createElement(Al,{active:T==="low",onClick:()=>F("low")},"<70% (",g,")"))),ve.createElement(cR,null,z.map(v=>{let A=k.get(v.storyId),h=JS(v.confidence),C=f.has(v.storyId),I=h==="low";return ve.createElement(uR,{key:v.storyId,dimmed:I&&!C},ve.createElement(pR,{checked:C,onClick:()=>R(v.storyId)},C?"\u2713":""),(()=>{let y=c?.(v.storyId);return y?ve.createElement(Pl,null,ve.createElement(QS,{src:y,alt:A?.name||v.storyId})):l?ve.createElement(Pl,null,ve.createElement(ZS,null)):ve.createElement(dR,{bgColor:I?"#f1f5f9":"#eff6ff"},ve.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:I?"#94a3b8":"#3b82f6"}},(A?.name||"?").substring(0,4)))})(),ve.createElement(KS,null,ve.createElement(XS,null,A?.name||v.storyId),ve.createElement(og,null,A?.title||"")),ve.createElement(gR,null,"\u2192"),(()=>{let y=u?.(v.figmaNodeId),P=rg(v.reason),L=P.summary+(P.candidates?` (${P.candidates} candidates)`:"");return y?ve.createElement(Pl,{title:L},ve.createElement(QS,{src:y,alt:v.figmaFrameName})):ve.createElement(Pl,{title:L},ve.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),ve.createElement(KS,null,ve.createElement(XS,null,v.componentSetName),ve.createElement(og,null,v.figmaFrameName),ve.createElement(GS,{data:rg(v.reason),color:vR(h)})),ve.createElement(mR,{level:h},v.confidence,"%"),p&&ve.createElement(hR,{onClick:()=>p(v.componentSetName)},"Browse"))}),e.unmatched.length>0&&ve.createElement(xR,null,ve.createElement(og,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),ve.createElement(yR,null,e.unmatched.map(v=>{let A=k.get(v);return ve.createElement(bR,{key:v},ve.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),A?`${A.name} (${A.title})`:v)})))),w&&a!=="cache"&&ve.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},ve.createElement(El,{inputTokens:w.inputTokens||0,outputTokens:w.outputTokens||0,costUsd:w.costUsd||0})))};Re();Me();import{useState as po,useCallback as fo,useRef as kR}from"react";import{useStorybookApi as CR}from"storybook/manager-api";function tw({projectId:e}){let t=CR(),n=kR(null),[r,o]=po(!1),[i,s]=po(!1),[a,u]=po(!1),[c,l]=po(null),[p,f]=po(null),[d,m]=po(null),[S,T]=po(""),[F,k]=po(null),z=fo(async()=>{let A=await fetch("/index.json");if(!A.ok)throw new Error("Failed to fetch Storybook index");let h=await A.json(),C=h.entries||h.stories||{},I=Object.keys(C).filter(L=>C[L].type==="story");b.debug(`[useAutoMap] Found ${I.length} stories in index.json`);let y=[];for(let L of I){let B=C[L],N=t.getData(L),x={...N?.initialArgs||{}},U=N?.argTypes||{};for(let[H,M]of Object.entries(U))if(!(H in x)){let Q=M;if(Q.defaultValue!==void 0)x[H]=Q.defaultValue;else if(Q.table?.defaultValue?.summary!==void 0){let ee=Q.table.defaultValue.summary;ee==="false"?x[H]=!1:ee==="true"?x[H]=!0:x[H]=ee}}y.push({id:L,name:B.name||L.split("--").pop()||L,title:B.title||"",initialArgs:x,argTypes:U})}let P=y.filter(L=>Object.keys(L.initialArgs).length>0);return b.debug(`[useAutoMap] Manifest: ${y.length} stories, ${P.length} with args`),y},[t]),R=fo(async()=>{if(!e)return!1;try{let A=G(),h=localStorage.getItem("uicopilot_session_token");if(!h)return!1;let C=await fetch(`${A}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${h}`}});if(!C.ok)return!1;let I=await C.json();return I.hasSuggestions&&I.mappings?.length>0?(f(I),k("cache"),T(`Loaded ${I.mappings.length} saved suggestions`),b.debug(`[useAutoMap] Loaded ${I.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),O=fo(async A=>{o(!0),T("Collecting story information...");let h;try{if(h=await z(),A?.length&&(h=h.filter(I=>!A.includes(I.id)),b.debug(`[useAutoMap] After excluding mapped: ${h.length} stories`)),h.length===0){l("No unmapped stories found"),o(!1);return}m(h)}catch(I){l(I instanceof Error?I.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),T(`Analyzing ${h.length} stories against Figma components...`);let C=new AbortController;n.current=C;try{let I=G(),y=localStorage.getItem("uicopilot_session_token");if(!y)throw new Error("Not authenticated");let P=await fetch(`${I}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({projectId:e,stories:h.map(B=>({id:B.id,name:B.name,title:B.title,initialArgs:B.initialArgs,argTypes:B.argTypes}))}),signal:C.signal});if(!P.ok){let B=await P.json();throw new Error(B.error||"Auto-map failed")}let L=await P.json();f(L),k("llm"),T(`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"){T("Cancelled");return}l(I instanceof Error?I.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,z]),E=fo(async A=>{if(!e)return;if(l(null),f(null),k(null),o(!0),T("Checking for existing suggestions..."),await R()){o(!1);return}await O(A)},[e,R,O]),D=fo(async A=>{e&&(l(null),f(null),k(null),await O(A))},[e,O]),g=fo(async A=>{if(!(!e||A.length===0)){u(!0),T(`Applying ${A.length} mappings...`);try{let h=G(),C=localStorage.getItem("uicopilot_session_token");if(!C)throw new Error("Not authenticated");let I=0;for(let y of A)try{(await fetch(`${h}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`},body:JSON.stringify({projectId:e,storyId:y.storyId,figmaNodeId:y.figmaNodeId,name:y.figmaFrameName||y.componentSetName})})).ok?I++:b.warn(`[useAutoMap] Failed to apply mapping for ${y.storyId}`)}catch(P){b.error(`[useAutoMap] Error applying mapping for ${y.storyId}:`,P)}T(`Applied ${I}/${A.length} mappings`),b.debug(`[useAutoMap] Applied ${I}/${A.length} mappings`)}catch(h){l(h instanceof Error?h.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),w=fo(()=>{n.current?.abort()},[]),v=fo(()=>{f(null),m(null),l(null),T(""),k(null)},[]);return{collectAndMap:E,rerun:D,loadExisting:R,applyMappings:g,cancel:w,reset:v,isCollecting:r,isMapping:i,isApplying:a,error:c,results:p,manifest:d,progress:S,source:F}}Me();import{useState as ig,useEffect as TR,useRef as nw}from"react";var rw=2;async function IR(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 ow(e){let[t,n]=ig({}),[r,o]=ig(0),[i,s]=ig(!1),a=nw(null),u=nw(""),c=e.join(",");return TR(()=>{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+=rw){let m=e.slice(d,d+rw),S=await Promise.all(m.map(F=>IR(F,l.signal).then(k=>({id:F,img:k}))));if(l.signal.aborted)break;let T={};for(let{id:F,img:k}of S)p++,k&&(T[F]=k);Object.keys(T).length>0&&n(F=>({...F,...T})),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 Se,{useState as iw,useEffect as Ml,useMemo as FR}from"react";Me();var Ti=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:s,multiSelect:a=!1,onMultiSelect:u,initialSearch:c})=>{let l=Bs({projectId:r||"",enabled:e&&!!r}),p=Se.useRef(!1);Ml(()=>{e&&c&&!p.current&&(l.setSearch(c),p.current=!0),e||(p.current=!1)},[e,c]);let[f,d]=iw(new Set),[m,S]=iw(i||o[0]?.id||"");Ml(()=>{i&&S(i)},[i]),Ml(()=>{l.expandedSets.forEach(D=>{let g=l.variantChildren[D];if(!g||g.length===0)return;let w=g;l.variantFilters.some(A=>A.value)&&(w=g.filter(A=>A.variantProperties?l.variantFilters.every(h=>h.value?A.variantProperties?.[h.property]===h.value:!0):!1));let v=w.slice(0,20).map(A=>A.id);v.length>0&&l.fetchVariantThumbnails(D,v)})},[l.expandedSets,l.variantChildren,l.variantFilters]),Ml(()=>{d(new Set)},[m]);let T=FR(()=>{let D=[];return l.filteredFrames.forEach(g=>{if(g.type==="COMPONENT_SET"&&g.children){let w=l.variantFilters.some(v=>v.value)?g.children.filter(v=>v.variantProperties?l.variantFilters.every(A=>A.value?v.variantProperties?.[A.property]===A.value:!0):!1):g.children;D.push(...w)}else D.push(g)}),D},[l.filteredFrames,l.variantFilters]),F=D=>{if(a)d(g=>{let w=new Set(g);return w.has(D.id)?w.delete(D.id):w.add(D.id),w});else{let g=l.resolveThumbnail(D.id);try{n({...D,thumbnail:g})}catch(w){b.error("[ComponentBrowserModal] onSelect threw error:",w)}t()}},k=()=>{let D=T.map(w=>w.id),g=D.every(w=>f.has(w));d(g?new Set:new Set(D))},z=()=>{if(u&&f.size>0){let D=T.filter(g=>f.has(g.id)).map(g=>({...g,thumbnail:l.resolveThumbnail(g.id)}));u(D),d(new Set)}},R=D=>{S(D),s?.(D)},O=D=>{D.target===D.currentTarget&&t()},E=o.find(D=>D.id===m);return e?Se.createElement(j0,{onClick:O},Se.createElement(H0,null,Se.createElement(W0,null,Se.createElement(V0,null,"Link Figma Frames"),Se.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},Se.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"),Se.createElement(G0,{onClick:t},"\xD7"))),Se.createElement(q0,null,l.error&&Se.createElement(eS,null,l.error),!l.error&&Se.createElement(Se.Fragment,null,o.length>0&&Se.createElement(pS,null,Se.createElement(dS,null,"Story:"),Se.createElement(fS,{value:m,onChange:D=>R(D.target.value)},o.map(D=>Se.createElement("option",{key:D.id,value:D.id},D.name,D.mappingsCount?` (${D.mappingsCount} linked)`:""))),E?.mappingsCount?Se.createElement(gS,{hasMapping:!0},E.mappingsCount," frames linked"):null),Se.createElement(J0,null,Se.createElement(bl,null,Se.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:D=>l.setShowComponentSets(D.target.checked)}),"Component Sets"),Se.createElement(bl,null,Se.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:D=>l.setShowFrames(D.target.checked)}),"Frames"),Se.createElement(bl,null,Se.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:D=>l.setShowComponents(D.target.checked)}),"Components"),l.availablePages.length>1&&Se.createElement(ki,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:D=>l.setFigmaPage(D.target.value),style:{marginLeft:"auto"}},Se.createElement("option",{value:""},"All pages"),l.availablePages.map(D=>Se.createElement("option",{key:D,value:D},D)))),l.filterSuggestion&&Se.createElement(mS,null,Se.createElement(hS,null,"AI suggests:"),Se.createElement(xS,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([D,g])=>`${D}=${g}`).join(", ")),Se.createElement(yS,{onClick:l.applySuggestedFilters},"Apply"),Se.createElement(bS,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&Se.createElement(SS,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&Se.createElement(wl,null,Se.createElement(Ns,null,"Filters:"),l.availableFilters.map(({property:D,values:g})=>{let w=l.variantFilters.find(v=>v.property===D);return Se.createElement(ki,{key:D,isActive:!!w?.value,value:w?.value||"",onChange:v=>l.handleFilterChange(D,v.target.value)},Se.createElement("option",{value:""},D),g.map(v=>Se.createElement("option",{key:v,value:v},D,"=",v)))}),l.variantFilters.some(D=>D.value)&&Se.createElement(vl,{onClick:l.clearFilters},"Clear All")),Se.createElement(Y0,{type:"text",placeholder:"Search frames...",value:l.search,onChange:D=>l.setSearch(D.target.value),autoFocus:!0}),a&&T.length>0&&Se.createElement(wS,null,Se.createElement(vS,{onClick:k},f.size===T.length?"Deselect All":"Select All Visible"),Se.createElement(kS,null,f.size>0?`${f.size} selected of `:"Showing ",T.length," frames")),l.isLoading&&Se.createElement(_f,null,Array.from({length:6}).map((D,g)=>Se.createElement(uS,{key:g},Se.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},Se.createElement(Sl,{width:"100%",height:"100%"})),Se.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},Se.createElement(Sl,{width:"80%",height:"16px"}),Se.createElement(Sl,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&Se.createElement(Z0,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&Se.createElement(_f,null,l.filteredFrames.map(D=>Se.createElement(Os,{key:D.id,frame:D,thumbnail:l.thumbnails[D.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[D.id],variantChildren:l.variantChildren[D.id],isLoadingVariants:l.loadingVariants.has(D.id),isExpanded:l.expandedSets.has(D.id),isNew:l.recentlyAdded.has(D.name),onToggleExpand:l.toggleExpanded,onSelect:F,multiSelect:a,selectedFrames:f,variantFilters:l.variantFilters}))))),a&&Se.createElement(CS,null,Se.createElement(TS,{disabled:f.size===0,onClick:z},"Link ",f.size," Selected")))):null};ke();nt();var AR=Gt.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}),PR=Gt.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"})),LR=Gt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),MR=Gt.div({display:"flex",alignItems:"center",gap:"20px"}),BR=Gt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),DR=Gt.div({display:"flex",gap:"4px"}),sw=Gt(Xr)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),RR=Gt(fn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),zR=Gt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),NR=Gt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),OR=Gt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),_R=Gt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),$R=Gt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),UR=Gt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),jR=Gt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),HR=Gt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),WR=Gt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),VR=Gt.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"}})),aw=Gt.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"}})),lw=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=Ii("map"),[i,s]=Ii([]),[a,u]=Ii(!0),[c,l]=Ii(null),[p,f]=Ii(!1),[d,m]=Ii(null),S=tw({projectId:n}),{refreshMappings:T}=Ye(),{featureFlags:F}=se(),k=He.useMemo(()=>S.results?.mappings.map(y=>y.storyId)||[],[S.results]),z=ow(k),R=go(async()=>{u(!0);try{let y=await fetch("/index.json");if(!y.ok)throw new Error("Failed to fetch index.json");let P=await y.json(),L=P.entries||P.stories||{},B=Object.entries(L).filter(([,x])=>x.type==="story").map(([x,U])=>({id:x,name:U.name||x.split("--").pop()||x,title:U.title||"",importPath:U.importPath,componentTitle:U.title?.split("/").slice(0,-1).join("/")||U.title,figmaMapping:null}));try{let x=G(),U=localStorage.getItem("uicopilot_session_token"),H=await ne(`${x}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${U}`}});if(H.ok){let M=await H.json(),Q=new Map((M.mappings||[]).map(ee=>[ee.storyId,ee]));B.forEach(ee=>{let J=Q.get(ee.id);J&&J.figmaNodeId&&(ee.figmaMapping={figmaNodeId:J.figmaNodeId,figmaFrameName:J.name||J.figmaFrameName||""})})}}catch(x){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",x)}s(B);let N=B.find(x=>!x.figmaMapping);N?l(N.id):B.length>0&&l(B[0].id)}catch(y){console.error("[StoryMappingAssistant] Error fetching stories:",y)}finally{u(!1)}},[n]);ER(()=>{e&&R()},[e,R]);let O=go((y,P,L)=>{s(x=>x.map(U=>U.id===y?{...U,figmaMapping:{figmaNodeId:P,figmaFrameName:L}}:U));let B=i.findIndex(x=>x.id===y),N=i.find((x,U)=>U>B&&!x.figmaMapping);N&&l(N.id)},[i]),E=go(y=>{s(P=>P.map(L=>L.id===y?{...L,figmaMapping:null}:L))},[]),D=go(y=>{l(y),o("map")},[]),g=go(()=>{let y=i.filter(P=>P.figmaMapping).map(P=>P.id);S.collectAndMap(y)},[i,S]),w=go(()=>{let y=i.filter(P=>P.figmaMapping).map(P=>P.id);f(!1),S.rerun(y)},[i,S]),v=go(async y=>{await S.applyMappings(y),f(!1),S.reset(),R(),T()},[S,R,T]),A=go(()=>{f(!1),S.reset()},[S]);He.useEffect(()=>{S.results&&f(!0)},[S.results]);let h=y=>{y.target===y.currentTarget&&t()};if(!e)return null;let C=i.filter(y=>y.figmaMapping).length,I=i.length;return He.createElement(He.Fragment,null,He.createElement(AR,{onClick:h},He.createElement(PR,{onClick:y=>y.stopPropagation()},He.createElement(LR,null,He.createElement(MR,null,He.createElement(BR,null,He.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),He.createElement(DR,null,He.createElement(sw,{active:r==="map",onClick:()=>o("map")},"Map Stories"),He.createElement(sw,{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(VR,{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(RR,{onClick:t},"\xD7"))),He.createElement(zR,null,(S.isCollecting||S.isMapping)&&He.createElement(_R,null,He.createElement($R,null,He.createElement(HR,null,He.createElement(WR,null)),He.createElement(UR,null,"Auto-mapping stories to Figma"),He.createElement(jR,null,S.progress),He.createElement(Ir,{onClick:S.cancel,variant:"ghost"},"Cancel"))),p&&S.results&&He.createElement(ew,{results:S.results,stories:i,onApply:v,onCancel:A,onRerun:w,isApplying:S.isApplying,isRerunning:S.isCollecting||S.isMapping,source:S.source,resolveThumbnail:y=>S.results?.thumbnailUrls?.[y],resolveStoryScreenshot:y=>z.screenshots[y],isCapturingScreenshots:z.isCapturing,onBrowse:y=>m(y)}),!p&&!S.isCollecting&&!S.isMapping&&(r==="map"?He.createElement(zS,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:O,projectId:n}):He.createElement($S,{stories:i,loading:a,onLink:D,onUnlink:E,projectId:n}))),He.createElement(NR,null,He.createElement(OR,null,He.createElement("span",null,"Total: ",I," stories"),He.createElement(aw,{type:"mapped"},He.createElement("span",{className:"dot"}),C," mapped"),He.createElement(aw,{type:"unmapped"},He.createElement("span",{className:"dot"}),I-C," unmapped"))))),He.createElement(Ti,{isOpen:!!d,onClose:()=>m(null),onSelect:()=>m(null),projectId:n,initialSearch:d||void 0}))};import Ur,{useEffect as GR,useCallback as qR}from"react";import{styled as $o,keyframes as cw}from"storybook/theming";var YR=cw({from:{opacity:0},to:{opacity:1}}),KR=cw({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),XR=$o.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${YR} 150ms ease-out`}),QR=$o.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:`${KR} 150ms ease-out`})),JR=$o.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),ZR=$o.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})),ez=$o.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),tz=$o.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}})),nz=$o.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}})),Fi=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",onConfirm:s,onCancel:a})=>{let u=qR(c=>{c.key==="Escape"&&a()},[a]);return GR(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),e?Ur.createElement(Ur.Fragment,null,Ur.createElement(XR,{onClick:a}),Ur.createElement(QR,{role:"dialog","aria-modal":"true","aria-label":t},Ur.createElement(JR,null,t),Ur.createElement(ZR,null,n),Ur.createElement(ez,null,Ur.createElement(tz,{onClick:a},o),Ur.createElement(nz,{variant:i,onClick:s},r)))):null};nt();var uw=Nn.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}})),oz=Nn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),iz=Nn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),sz=Nn.div({display:"flex",alignItems:"center",gap:"8px"}),az=Nn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),lz=Nn.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"})),cz=Nn.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"})),uz=Nn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),pz=Nn(Fc)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),dz=Nn(Fc)(({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)"}})),fz=Nn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),gz=Nn.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),mz=Nn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),pw=()=>{let[e,t]=Bl(!1),[n,r]=Bl({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Qe(),{sessionToken:i}=Ie();rz(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(O=>({...O,loading:!0}));try{let O=await fetch("/index.json");if(!O.ok)throw new Error("Failed to fetch Storybook index");let E=await O.json(),D=E.entries||E.stories||{},g=Object.keys(D).filter(C=>D[C].type==="story").length,w=Object.keys(D).filter(C=>D[C].type==="story"),v=G(),A=await ne(`${v}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),h=0;if(A.ok){let C=await A.json(),I=C.mappings||C||[];if(Array.isArray(I)){let y=new Set(I.map(P=>P.storyId).filter(Boolean));h=w.filter(P=>y.has(P)).length}else{let y=await ne(`${v}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(y.ok){let P=await y.json();h=Math.min(P.mappedStoriesCount||0,g)}}}r({totalStories:g,mappedStories:h,loading:!1})}catch(O){console.error("[FigmaMappingsSection] Error fetching stats:",O),r(E=>({...E,loading:!1}))}},[a,u]=Bl(!1),[c,l]=Bl(!1),p=async()=>{!o||!i||l(!0)},f=async()=>{l(!1),u(!0);try{let O=G(),E=await ne(`${O}/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(w=>ne(`${O}/api/mappings?id=${encodeURIComponent(w.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(O){console.error("[FigmaMappingsSection] Unlink all failed:",O)}finally{u(!1)}},d=()=>t(!0),m=()=>{t(!1),o&&i&&s()};if(!o)return gt.createElement(uw,null,gt.createElement(fz,null,"Select a project to link Figma designs"));let{totalStories:S,loading:T}=n,F=Math.min(n.mappedStories,S),k=F===0?"none":F>=S?"complete":"partial",z=S>0?Math.min(100,Math.round(F/S*100)):0,R=k==="none"?"Link designs":"Manage";return gt.createElement(gt.Fragment,null,gt.createElement(uw,null,gt.createElement(oz,null,gt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},gt.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"}),gt.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"}),gt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),gt.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"}),gt.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"}))),gt.createElement(iz,null,gt.createElement(uz,null,"Figma Mappings"),gt.createElement(sz,null,T?gt.createElement(gt.Fragment,null,gt.createElement(gz,null),gt.createElement(mz,null,"Loading...")):gt.createElement(gt.Fragment,null,gt.createElement(az,null,gt.createElement(lz,{percent:z,state:k})),gt.createElement(cz,{state:k},`${F}/${S}`)))),F>0&>.createElement(dz,{onClick:p,disabled:T||a},a?"Unlinking...":"Unlink All"),gt.createElement(pz,{onClick:d,disabled:T},R)),e&>.createElement(lw,{isOpen:e,onClose:m,projectId:o}),gt.createElement(Fi,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:f,onCancel:()=>l(!1)}))};import he,{useState as $s,useEffect as dw,useCallback as hz}from"react";import{styled as On}from"storybook/theming";ke();Re();nt();var fw=On.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),gw=On.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),mw=On.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),pQ=On(Wn)({padding:"5px 12px",fontSize:"12px"}),hw=On.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),sg=On.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),xz=On.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})),yz=On.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),ag=On.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),bz=On.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),lg=On.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),cg=On.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Uo=On.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),xw=()=>{let{featureFlags:e}=se(),[t,n]=$s(null),[r,o]=$s(!0),[i,s]=$s(!1),[a,u]=$s(!1),[c,l]=$s(!1),{selectedProjectId:p}=Qe(),{sessionToken:f}=Ie(),d=hz(async()=>{if(!(!p||!f))try{let R=G(),O=await ne(`${R}/api/figma/cache-status?projectId=${p}`,{headers:{Authorization:`Bearer ${f}`}});if(O.ok){let E=await O.json();n(E)}}catch(R){console.error("[FigmaCacheSection] Error:",R)}finally{o(!1)}},[p,f]);dw(()=>{d()},[d]),dw(()=>{let R=t?.thumbnailProgress?.status==="in-progress",O=t?.enrichmentProgress?.status==="in-progress",E=t?.thumbnailProgress&&t.thumbnailProgress.cached>0;if(!(R||O||!E&&t?.structureStatus==="cached")||!t||t.structureStatus==="none")return;let g=setInterval(()=>{d()},3e3),w=setTimeout(()=>clearInterval(g),3e5);return()=>{clearInterval(g),clearTimeout(w)}},[t?.thumbnailProgress?.status,t?.thumbnailProgress?.cached,t?.enrichmentProgress?.status,t?.structureStatus,d]);let m=async()=>{if(!(!p||!f)){s(!0);try{let R=G();await ne(`${R}/api/figma/frames?projectId=${p}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${f}`}},6e4),await new Promise(O=>setTimeout(O,1e3)),await d(),setTimeout(async()=>{await d()},3e3)}catch(R){console.error("[FigmaCacheSection] Reload error:",R)}finally{s(!1)}}},S=async()=>{if(!(!p||!f)){u(!0);try{let R=G(),O=await ne(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({projectId:p})});console.log("[FigmaCacheSection] Cache invalidate response:",O.status),await ne(`${R}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({projectId:p})}).catch(()=>{}),n({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{u(!1)}}},T=async()=>{if(!(!p||!f)){l(!0);try{let R=G();await ne(`${R}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({projectId:p})});let O=setInterval(async()=>{await d()},3e3),E=setInterval(()=>{(t?.enrichmentProgress?.status==="complete"||t?.enrichmentProgress?.status==="error")&&(clearInterval(O),clearInterval(E),l(!1),d())},3e3);setTimeout(()=>{clearInterval(O),clearInterval(E),l(!1)},6e5)}catch(R){console.error("[FigmaCacheSection] Enrich error:",R),l(!1)}}};if(!p||r)return null;if(!t||t.structureStatus==="none")return he.createElement(fw,null,he.createElement(gw,null,he.createElement(mw,null,"Figma Cache"),he.createElement(Ir,{loading:i,onClick:m,loadingText:"Loading..."},"\u21BB Load")),i?he.createElement(he.Fragment,null,he.createElement(lg,null,he.createElement(cg,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),he.createElement(Uo,null,he.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):he.createElement(hw,null,he.createElement(sg,null,"No cache \u2014 click Load to fetch from Figma")));let F=R=>{let O=Date.now()-new Date(R).getTime(),E=Math.floor(O/6e4);if(E<1)return"just now";if(E<60)return`${E}m ago`;let D=Math.floor(E/60);return D<24?`${D}h ago`:`${Math.floor(D/24)}d ago`},k=t.cacheDiff,z=k&&(k.added.length>0||k.removed.length>0||k.renamed.length>0);return he.createElement(fw,null,he.createElement(gw,null,he.createElement(mw,null,"Figma Cache"," ",he.createElement(xz,{status:t.structureStatus},t.structureStatus)),he.createElement("div",{style:{display:"flex",gap:"6px"}},he.createElement(Ir,{loading:c,onClick:T,loadingText:"Enriching..."},"Enrich"),he.createElement(Ir,{loading:a,onClick:S,variant:"ghost",loadingText:"Clearing..."},"Clear"),he.createElement(Ir,{loading:i,onClick:m,loadingText:"Reloading..."},"\u21BB Reload"))),i&&he.createElement(Uo,null,he.createElement("span",null,"Downloading structure from Figma...")),he.createElement(hw,null,he.createElement(sg,null,he.createElement("strong",null,t.componentSetCount)," component sets"),he.createElement(sg,null,he.createElement("strong",null,t.pageCount)," pages"),t.structureCachedAt&&he.createElement(bz,null,"Updated ",F(t.structureCachedAt))),z&&he.createElement(yz,null,"Since last reload:"," ",k.added.length>0&&he.createElement(ag,{type:"added"},"+",k.added.length," added"),k.added.length>0&&k.removed.length>0&&" \xB7 ",k.removed.length>0&&he.createElement(ag,{type:"removed"},"\u2212",k.removed.length," removed"),(k.added.length>0||k.removed.length>0)&&k.renamed.length>0&&" \xB7 ",k.renamed.length>0&&he.createElement(ag,{type:"renamed"},k.renamed.length," renamed")),t.thumbnailProgress&&t.thumbnailProgress.status==="in-progress"&&he.createElement(he.Fragment,null,he.createElement(lg,null,he.createElement(cg,{percent:t.thumbnailProgress.total>0?Math.round(t.thumbnailProgress.cached/t.thumbnailProgress.total*100):0})),he.createElement(Uo,null,he.createElement("span",null,"Caching component set thumbnails to CDN...",t.thumbnailProgress.currentName&&he.createElement(he.Fragment,null," ",t.thumbnailProgress.currentName)),he.createElement("span",null,t.thumbnailProgress.cached," / ",t.thumbnailProgress.total))),t.thumbnailProgress&&t.thumbnailProgress.status==="complete"&&he.createElement(Uo,null,he.createElement("span",null,"Thumbnails: ",t.thumbnailProgress.cached," / ",t.thumbnailProgress.total," cached to CDN \u2713")),(!t.thumbnailProgress||t.thumbnailProgress.status==="pending")&&he.createElement(Uo,null,he.createElement("span",null,"Thumbnails: not pre-cached")),t.enrichmentProgress&&t.enrichmentProgress.status==="in-progress"&&he.createElement(he.Fragment,null,he.createElement(lg,null,he.createElement(cg,{percent:t.enrichmentProgress.total>0?Math.round(t.enrichmentProgress.enriched/t.enrichmentProgress.total*100):0})),he.createElement(Uo,null,he.createElement("span",null,"Enriching components with AI...",t.enrichmentProgress.currentName&&he.createElement(he.Fragment,null," ",t.enrichmentProgress.currentName)),he.createElement("span",null,t.enrichmentProgress.enriched," / ",t.enrichmentProgress.total))),t.enrichmentProgress&&t.enrichmentProgress.status==="complete"&&he.createElement(he.Fragment,null,he.createElement(Uo,null,he.createElement("span",null,"AI enrichment: ",t.enrichmentProgress.enriched," / ",t.enrichmentProgress.total," component sets \u2713")),e.showCosts&&t.enrichmentProgress.costUsd!=null&&t.enrichmentProgress.costUsd>0&&he.createElement("div",{style:{marginTop:"6px"}},he.createElement(El,{inputTokens:t.enrichmentProgress.inputTokens||0,outputTokens:t.enrichmentProgress.outputTokens||0,costUsd:t.enrichmentProgress.costUsd,compact:!0}))))};import lt,{useState as Ei}from"react";import{styled as Fr}from"storybook/theming";ke();Re();nt();var ug=Fr.div({padding:"12px 16px"}),Sz=Fr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),yw=Fr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),bw=Fr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:ae,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),wz=Fr.div({display:"flex",gap:"8px",alignItems:"center"}),vz=Fr.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none",fontFamily:"monospace","&:focus":{borderColor:ae,boxShadow:`0 0 0 1px ${ae}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),Sw=Fr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),kz=Fr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:ae,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),Cz=Fr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"6px",backgroundColor:"#16a34a10",border:"1px solid #16a34a30",fontSize:"12px",color:e.color.defaultText})),Tz=Fr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),ww=()=>{let{sessionToken:e}=Ie(),[t,n]=Ei(!1),[r,o]=Ei(""),[i,s]=Ei(!1),[a,u]=Ei(null),[c,l]=Ei(null),[p,f]=Ei(!1),d=async()=>{if(!(!r.trim()||!e)){s(!0),u(null);try{let m=G(),S=await ne(`${m}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({token:r.trim()})}),T=await S.json();if(!S.ok){u({type:"error",message:T.error||"Failed to save token"});return}l(T.figmaUser?.handle||T.figmaUser?.email||"Connected"),u({type:"success",message:`Connected as ${T.figmaUser?.handle||"Figma user"}`}),o("")}catch{u({type:"error",message:"Failed to connect. Check your token and try again."})}finally{s(!1)}}};return c?lt.createElement(ug,null,lt.createElement(yw,null,"Figma Personal Access Token"),lt.createElement(Cz,null,lt.createElement("span",null,"\u2713 Connected as ",lt.createElement("strong",null,c)),lt.createElement(Tz,{onClick:()=>{l(null),u(null)}},"Change token"))):t?lt.createElement(ug,null,lt.createElement(Sz,null,lt.createElement(yw,null,"Figma Personal Access Token"),lt.createElement(bw,{onClick:()=>f(!p)},p?"Hide instructions":"How to generate")),p&<.createElement(kz,null,lt.createElement("ol",null,lt.createElement("li",null,"Open ",lt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),lt.createElement("li",null,"Click the ",lt.createElement("strong",null,"Security")," tab"),lt.createElement("li",null,"Scroll to ",lt.createElement("strong",null,"Personal access tokens")),lt.createElement("li",null,"Click ",lt.createElement("strong",null,"Generate new token")),lt.createElement("li",null,"Enable ",lt.createElement("strong",null,"File content: Read only")," under Scopes"),lt.createElement("li",null,"Copy the token and paste it below"))),lt.createElement(wz,null,lt.createElement(vz,{type:"password",value:r,onChange:m=>o(m.target.value),placeholder:"figd_...",onKeyDown:m=>{m.key==="Enter"&&r.trim()&&d()}}),lt.createElement(_t,{onClick:d,disabled:!r.trim()||i},i?"Verifying...":"Save & Verify")),a&<.createElement(Sw,{variant:a.type},a.message),lt.createElement(Sw,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):lt.createElement(ug,null,lt.createElement(bw,{onClick:()=>n(!0)},"Or use a Personal Access Token \u2192"))};ke();Re();nt();var Fz=dt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},dt.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"}),dt.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"}),dt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),dt.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"}),dt.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"})),dg=gr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),Ez=gr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),Az=gr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),Pz=gr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),fg=gr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),Lz=gr.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",margin:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"})),Mz=gr.div({display:"flex",alignItems:"center",gap:"8px"}),Bz=gr(Hn)(({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"})),Dz=gr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),LQ=gr.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:"#A259FF",color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:"#8a3de8"}}),Rz=gr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.mediumdark,"&::before, &::after":{content:'""',flex:1,height:"1px",backgroundColor:e.appBorderColor}})),kw=()=>{let{sessionToken:e}=Ie(),[t,n]=pg(!1),[r,o]=pg(null),[i,s]=pg(!1);Iz(()=>{if(!e)return;let l=G();ne(`${l}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${e}`}}).then(p=>p.json()).then(p=>o(!!p.connected)).catch(()=>o(!1))},[e]);let a=vw(()=>{let p=`${G()}/addon/auth`;window.open(p,"figma-oauth","width=600,height=700,left=200,top=100")},[]),u=vw(async()=>{try{n(!0);let l=G(),p=await ne(`${l}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});(p.ok||p.status===404)&&o(!1)}catch{}finally{n(!1)}},[e]),c=dt.createElement(Ez,null,dt.createElement(Az,null,Fz),dt.createElement(Pz,null,"Figma Integration"));return r===null?dt.createElement(dg,null,c,dt.createElement(fg,null,dt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):r===!1?dt.createElement(dg,null,c,dt.createElement(fg,null,dt.createElement(Dz,null,dt.createElement(_t,{onClick:a,style:{width:"100%"}},"Connect with Figma"),dt.createElement(Rz,null,"or"),dt.createElement(ww,null)))):dt.createElement(dg,null,c,dt.createElement(Lz,null,dt.createElement(Mz,null,dt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),dt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),dt.createElement(Bz,{onClick:()=>s(!0),disabled:t},t?"Disconnecting...":"Disconnect")),dt.createElement(Fi,{isOpen:i,title:"Disconnect Figma",message:"Your mappings, cache, and review history will be preserved. You will need to re-authenticate to make new Figma API calls.",confirmLabel:"Disconnect",variant:"danger",onConfirm:()=>{s(!1),u()},onCancel:()=>s(!1)}),dt.createElement(fg,null,dt.createElement(U0,null),dt.createElement(pw,null),dt.createElement(xw,null)))};ke();var zz=Ai.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"}),Nz=Ai.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"})),Oz=Ai.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})),_z=Ai.h2(({theme:e})=>({margin:0,fontSize:"13px",fontWeight:600,color:e.color.defaultText})),$z=Ai(fn)({fontSize:"16px",padding:"2px 6px",lineHeight:1}),Uz=Ai.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"}})),Cw=({onClose:e})=>{let{isConnected:t}=Ie(),{selectedProjectId:n}=Qe();return jr.createElement(zz,{onClick:e},jr.createElement(Nz,{onClick:r=>r.stopPropagation()},jr.createElement(Oz,null,jr.createElement(_z,null,"Settings"),jr.createElement($z,{onClick:e,title:"Close settings"},"x")),jr.createElement(Uz,null,jr.createElement(N0,null),t&&jr.createElement(_0,null),t&&n&&jr.createElement(kw,null))))};import Dt,{useEffect as mN,useMemo as hN}from"react";import{styled as Zn}from"storybook/theming";ke();ke();import Ht,{useState as jz}from"react";import{styled as Pn}from"storybook/theming";var Hr=[{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Latest Claude model, best balance of speed and quality"},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",provider:"anthropic",description:"Previous generation Sonnet"},{id:"claude-3-5-sonnet-20241022",name:"Claude 3.5 Sonnet",provider:"anthropic",description:"Best balance of speed and quality"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",provider:"anthropic",description:"Fastest, most affordable"},{id:"claude-3-opus-20240229",name:"Claude 3 Opus",provider:"anthropic",description:"Most capable Claude 3 model"},{id:"gpt-5.2",name:"GPT-5.2 Thinking",provider:"openai",description:"47% cheaper, reasoning"},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Instant",provider:"openai",description:"86% cheaper (default)"},{id:"gpt-4o",name:"GPT-4o",provider:"openai",description:"GPT-4 multimodal flagship"},{id:"gpt-4o-mini",name:"GPT-4o Mini",provider:"openai",description:"GPT-4 affordable model"},{id:"o1-preview",name:"o1 Preview",provider:"openai",description:"Reasoning model (slower, advanced)"},{id:"o1-mini",name:"o1 Mini",provider:"openai",description:"Faster reasoning model"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"Fast & cheap, great vision"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",provider:"google",description:"Best Gemini quality"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"google",description:"Previous gen, very fast"}];var Hz=Pn.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),Wz=Pn.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),Vz=Pn.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"}}),Gz=Pn.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}})),qz=Pn.div({position:"relative",display:"inline-block"}),Yz=Pn.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}})),Kz=Pn.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"})),gg=Pn.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),mg=Pn.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),Xz=Pn.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}})),Qz=Pn.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),Jz=Pn.div({flex:1,minWidth:0}),Zz=Pn.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),eN=Pn.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),tN=5,Tw=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=se(),[r,o]=jz(!1),i=Hr.filter(d=>d.provider==="anthropic"&&!e.includes(d.id)),s=Hr.filter(d=>d.provider==="openai"&&!e.includes(d.id)),a=Hr.filter(d=>d.provider==="google"&&!e.includes(d.id)),u=Hr.filter(d=>e.includes(d.id)),c=e.length<tN,l=(d,m)=>{m.stopPropagation(),e.length>1&&!n&&t(d)},p=d=>{let m=e.includes(d);m&&e.length===1||!m&&!c||n||(t(d),o(!1))},f=d=>{let m=e.includes(d.id),S=m&&e.length===1,T=n||S||!m&&!c;return Ht.createElement(Xz,{key:d.id,disabled:T,onClick:()=>p(d.id)},Ht.createElement(Qz,{type:"checkbox",checked:m,disabled:T,onChange:()=>{},onClick:F=>F.stopPropagation()}),Ht.createElement(Jz,null,Ht.createElement(Zz,null,d.name),d.description&&Ht.createElement(eN,null,d.description)))};return Ht.createElement(Hz,null,Ht.createElement(qz,null,Ht.createElement(Yz,{disabled:n,isOpen:r,onClick:()=>o(!r)},Ht.createElement("span",null,"Select model"),Ht.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Ht.createElement(Kz,null,Ht.createElement(gg,null,Ht.createElement(mg,null,"Anthropic"),i.map(f)),Ht.createElement(gg,null,Ht.createElement(mg,null,"OpenAI"),s.map(f)),Ht.createElement(gg,null,Ht.createElement(mg,null,"Google"),a.map(f)))),Ht.createElement(Wz,null,u.map(d=>Ht.createElement(Vz,{key:d.id,disabled:n,provider:d.provider},d.name,e.length>1&&Ht.createElement(Gz,{disabled:n,onClick:m=>l(d.id,m),title:"Remove model"},"\xD7")))))};import ge,{useState as nN,useEffect as rN}from"react";import{styled as Jt,keyframes as Us}from"storybook/theming";ke();var oN=Us`
|
|
34
34
|
0%, 100% {
|
|
35
35
|
opacity: 1;
|
|
36
36
|
transform: scale(1);
|
|
@@ -39,20 +39,20 @@ ${Je}`).join(`
|
|
|
39
39
|
opacity: 0.4;
|
|
40
40
|
transform: scale(0.8);
|
|
41
41
|
}
|
|
42
|
-
`,
|
|
42
|
+
`,iN=Us`
|
|
43
43
|
0% { transform: rotate(0deg); }
|
|
44
44
|
100% { transform: rotate(360deg); }
|
|
45
|
-
`,
|
|
45
|
+
`,sN=Us`
|
|
46
46
|
0% { opacity: 0; transform: translateY(2px); }
|
|
47
47
|
100% { opacity: 1; transform: translateY(0); }
|
|
48
|
-
`,
|
|
48
|
+
`,aN=Us`
|
|
49
49
|
0%, 100% {
|
|
50
50
|
opacity: 1;
|
|
51
51
|
}
|
|
52
52
|
50% {
|
|
53
53
|
opacity: 0.6;
|
|
54
54
|
}
|
|
55
|
-
`,
|
|
55
|
+
`,lN=Us`
|
|
56
56
|
0% {
|
|
57
57
|
transform: translateY(0) rotate(0deg) scale(1);
|
|
58
58
|
opacity: 1;
|
|
@@ -64,36 +64,36 @@ ${Je}`).join(`
|
|
|
64
64
|
transform: translateY(60px) rotate(720deg) scale(0.5);
|
|
65
65
|
opacity: 0;
|
|
66
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`
|
|
67
|
+
`;var iJ=Jt.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),hg=Jt.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),Iw=Jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#fee2e2",fontSize:"12px",fontWeight:700,color:"#dc2626",whiteSpace:"nowrap"}),cN=Jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#dcfce7",fontSize:"12px",fontWeight:700,color:"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"}),sJ=Jt.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"-10px",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>6?"50%":"2px",animation:`${lN} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var mo=Jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),ho=Jt.span(({color:e="#6b7280"})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:e,whiteSpace:"nowrap"})),xg=Jt.span(({color:e="#6b7280"})=>({fontSize:"12px",color:e})),Pi=Jt.span(({color:e})=>({fontWeight:700,color:e})),aJ=Jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),lJ=Jt.span(({color:e=ae})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${oN} 1.2s ease-in-out infinite`,marginRight:"4px"})),cJ=Jt.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return ae;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 ae;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${aN} 1.5s ease-in-out infinite`}:{}})),uJ=Jt.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),pJ=Jt.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),uN=Jt.button(({theme:e,isExporting:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",fontSize:"11px",fontWeight:600,color:t?e.color.mediumdark:"#7c3aed",backgroundColor:t?e.background.hoverable:"#ede9fe",border:"none",borderRadius:"12px",cursor:t?"not-allowed":"pointer",transition:"all 0.2s",whiteSpace:"nowrap","&:hover":{backgroundColor:t?e.background.hoverable:"#ddd6fe"}})),pN=Jt.span({display:"inline-block",width:"10px",height:"10px",border:"2px solid #c4b5fd",borderTopColor:"#7c3aed",borderRadius:"50%",animation:"export-spin 0.8s linear infinite","@keyframes export-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}),dN=Jt.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${iN} 1.2s linear infinite`,flexShrink:0}),Fw=({color:e=ae})=>ge.createElement(dN,null,ge.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 ge.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),fN=Jt.span(({color:e="#6b7280"})=>({fontSize:"12px",fontWeight:500,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",animation:`${sN} 0.3s ease-out`}));function gN(e){let[t,n]=nN(0);return rN(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var Ew=({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=gN(e||t),{exportPDF:m,isExporting:S}=Tf(),{featureFlags:T}=se(),F=T.showCosts,k=3.65,z=g=>g<.01?`$${g.toFixed(4)}`:g<.1?`$${g.toFixed(3)}`:`$${g.toFixed(2)}`,R=g=>{let w=g*k;return w<.01?`\u20AA${w.toFixed(4)}`:w<.1?`\u20AA${w.toFixed(3)}`:`\u20AA${w.toFixed(2)}`},O=g=>g>=1e3?`${(g/1e3).toFixed(1)}K`:g.toString(),E=g=>g>=80?"score-high":g>=50?"score-medium":"score-low",D=g=>g>=80?"high":g>=50?"medium":"low";if(e)return ge.createElement(hg,null,ge.createElement(ho,null,ge.createElement(Fw,{color:ae}),ge.createElement(fN,{key:n,color:"#6b7280"},n||"Analyzing\u2026")),c&&ge.createElement(ge.Fragment,null,ge.createElement(mo,null,"|"),ge.createElement(ho,null,ge.createElement("span",{style:{color:"#6b7280"}},d,"s \xB7 Esc to stop"))));if(t)return ge.createElement(hg,null,ge.createElement(Iw,null,ge.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ge.createElement(mo,null,"|"),ge.createElement(ho,null,ge.createElement(Fw,{color:"#7c3aed"}),ge.createElement(Pi,{color:"#7c3aed"},"Verifying...")),c&&ge.createElement(ge.Fragment,null,ge.createElement(mo,null,"|"),ge.createElement(ho,null,ge.createElement("span",{style:{color:"#6b7280"}},d,"s"))));if(r>0||o!==void 0){let g=(a||0)+(u||0),w=(p||0)>0,v=w&&a?Math.round(p/a*100):0,A=Math.max(o??0,i??0),h=I=>I>=80?"#16a34a":I>=50?"#ca8a04":"#dc2626",C=I=>I>=100?"\u25CF":I>=50?"\u25D0":"\u25CB";return ge.createElement(hg,null,r===0?ge.createElement(cN,null,ge.createElement("span",null,"\u2713"),"Perfect!"):ge.createElement(Iw,null,ge.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ge.createElement(mo,null,"|"),ge.createElement(ho,{title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},ge.createElement(xg,{color:h(A)},C(A)),ge.createElement("span",null,"score"),ge.createElement(Pi,{color:h(A)},A)),F&&s!==void 0&&s>0&&ge.createElement(ge.Fragment,null,ge.createElement(mo,null,"|"),ge.createElement(ho,null,ge.createElement(Pi,{color:"#16a34a"},z(s)),ge.createElement("span",{style:{color:"#6b7280"}},"/"),ge.createElement(Pi,{color:"#16a34a"},R(s)))),F&&g>0&&ge.createElement(ge.Fragment,null,ge.createElement(mo,null,"|"),ge.createElement(ho,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${w?` \xB7 Cached: ${p?.toLocaleString()}`:""}`},ge.createElement(xg,{color:"#7c3aed"},"#"),ge.createElement(Pi,{color:"#7c3aed"},O(g)),ge.createElement("span",{style:{color:"#6b7280"}},"tokens"),w&&ge.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",v,"%"))),f!==void 0&&f>0&&ge.createElement(ge.Fragment,null,ge.createElement(mo,null,"|"),ge.createElement(ho,null,ge.createElement(xg,{color:"#6b7280"},"\u23F1"),ge.createElement(Pi,{color:"#6b7280"},f,"s"))),ge.createElement(mo,null,"|"),ge.createElement(uN,{onClick:m,disabled:S,isExporting:S,title:"Download design review report as PDF"},S?ge.createElement(ge.Fragment,null,ge.createElement(pN,null),"Exporting..."):ge.createElement(ge.Fragment,null,"\u2193 Report")))}return null};var xN=Zn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),yN=Zn.div({display:"flex",gap:"8px",alignItems:"center"}),bN=Zn.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:ma}[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)"}})),SN=Zn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),wN=Zn.div({marginLeft:"auto",display:"flex",flexDirection:"column",gap:"4px"}),vN=Zn.label(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),kN=Zn(wn)({width:"auto",minWidth:"200px"}),CN=Zn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),Aw=Zn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),Pw=Zn.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?ma:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),Lw=Zn.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)"})),Mw=Zn.input({position:"absolute",opacity:0,width:0,height:0}),yg=()=>{let{sessionToken:e}=Ki(),{selectedProjectId:t}=ir(),{currentMapping:n,hasMapping:r}=No(),{loadingMapping:o,currentStoryId:i}=Ye(),{startReview:s,cancelReview:a,isReviewing:u}=gf(),{isLoadingScreenshots:c}=Eo(),{storybookImageUrl:l,figmaImageUrl:p,currentReviewId:f,reviewHistory:d,setReviewDetailTab:m,setReviewResults:S,setFigmaImageUrl:T,setStorybookImageUrl:F,setFullPrompt:k,setFullResponse:z,includeTextComparison:R,setIncludeTextComparison:O,usePromptCache:E,setUsePromptCache:D,isValidating:g,validationUsage:w,isGenerating:v,isApplying:A,streamingStatus:h,featureFlags:C}=se(),I=d.find(Y=>Y.id===f),P=(I?.issues||[]).filter(Y=>!Y.dismissed).length,L=I?.complianceScore,B=I?.visualSimilarity,N=(I?.costUsd||0)+(w?.costUsd||0),x=(I?.inputTokens||0)+(w?.inputTokens||0),U=(I?.outputTokens||0)+(w?.outputTokens||0),H=hN(()=>{let Y=i?d.filter(Ge=>Ge.storyId===i):d,ce=Y.filter(Ge=>!Ge.parentReviewId).sort((Ge,xt)=>new Date(xt.createdAt).getTime()-new Date(Ge.createdAt).getTime()),ie=Y.filter(Ge=>Ge.parentReviewId),ue=[];for(let Ge of ce){ue.push(Ge);let xt=ie.filter(yn=>yn.parentReviewId===Ge.id).sort((yn,qe)=>(yn.iterationNumber||0)-(qe.iterationNumber||0));ue.push(...xt)}let ct=ie.filter(Ge=>!ce.some(xt=>xt.id===Ge.parentReviewId));return ue.push(...ct),ue},[d,i]);mN(()=>{if(!u)return;let Y=ce=>{ce.key==="Escape"&&(ce.preventDefault(),a())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[u,a]);let M=r&&n?.figmaNodeId,Q=v||A,ee=!!(e&&t&&!u&&!c&&!Q&&i&&l&&M&&p),J=async(Y=!1)=>{if(!i){console.error("[ReviewActions] No story selected");return}try{m("chat"),await s({isIteration:Y,parentReviewId:Y?f:void 0})}catch(ce){console.error("[ReviewActions] Review error:",ce)}},Le=()=>J(!1),Ee=Y=>{let ce=Y.target.value;if(ce){let ie=d.find(ue=>ue.id===ce);ie&&(S({id:ie.id,componentId:ie.componentId,storyId:ie.storyId,modelId:ie.modelId,complianceScore:ie.complianceScore,issuesCount:ie.issuesCount,issues:ie.issues,createdAt:new Date(ie.createdAt),visualSimilarity:ie.visualSimilarity,timestamp:new Date(ie.createdAt).toISOString()}),ie.figmaImageData&&T(ie.figmaImageData),ie.storybookImageData&&F(ie.storybookImageData),k(ie.aiPrompt||""),z(ie.aiResponse||""),m("issues"))}},We=Y=>{let ce=new Date(Y),ue=new Date().getTime()-ce.getTime(),ct=Math.floor(ue/6e4),Ge=Math.floor(ue/36e5),xt=Math.floor(ue/864e5);return ct<1?"Just now":ct<60?`${ct}m ago`:Ge<24?`${Ge}h ago`:xt<7?`${xt}d ago`:ce.toLocaleDateString()},st=Y=>Y?Y.includes("haiku")?"Haiku":Y.includes("sonnet")?"Sonnet":Y.includes("opus")?"Opus":Y.includes("gpt-4o-mini")?"GPT-4o mini":Y.includes("gpt-4o")?"GPT-4o":Y.includes("gpt-4")?"GPT-4":Y.includes("o3")?"o3":Y.includes("o1")?"o1":Y.split("-")[0]||"":"",te=Y=>{let ce=Y.split("--"),ie=ce[ce.length-1]||Y;return ie.charAt(0).toUpperCase()+ie.slice(1)};return Dt.createElement("div",null,Dt.createElement(xN,null,C.enableModelSelection&&Dt.createElement(Tw,null),Dt.createElement(CN,null,Dt.createElement(Aw,{title:"Compare text content between Figma design and Storybook component"},Dt.createElement(Mw,{type:"checkbox",checked:R,onChange:Y=>O(Y.target.checked)}),Dt.createElement(Pw,{checked:R},Dt.createElement(Lw,{checked:R})),"Compare text"),C.showCosts&&Dt.createElement(Aw,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},Dt.createElement(Mw,{type:"checkbox",checked:E,onChange:Y=>D(Y.target.checked)}),Dt.createElement(Pw,{checked:E},Dt.createElement(Lw,{checked:E})),"Cache prompt")),Dt.createElement(yN,null,Dt.createElement(bN,{variant:u?"yellow":"orange",disabled:u?!1:!ee,onClick:u?a:Le,title:u?"Click to stop review":e?t?i?M?c?"Loading screenshots...":Q?"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||I)&&Dt.createElement(Ew,{isReviewing:u,isValidating:g,streamingStatus:h,issueCount:P,score:L,visualSimilarity:B,costUsd:N||I?.costUsd,inputTokens:x||I?.inputTokens,outputTokens:U||I?.outputTokens,cacheCreationTokens:I?.cacheCreationTokens,cacheReadTokens:I?.cacheReadTokens,durationSeconds:I?.reviewDurationMs?Math.round(I.reviewDurationMs/1e3):void 0}),H.length>0&&Dt.createElement(wN,null,Dt.createElement(vN,null,"Review History"),Dt.createElement(kN,{value:f||"",onChange:Ee},Dt.createElement("option",{value:""},"Select a review..."),H.map(Y=>{let ce=!!Y.parentReviewId,ie=ce?" \u21B3 ":"\u25CF ",ue=ce&&Y.iterationNumber?`Iter ${Y.iterationNumber} - `:"",ct=Y.issuesCount??Y.issues?.length??0,Ge=Y.complianceScore??"--",xt=st(Y.modelId);return Dt.createElement("option",{key:Y.id,value:Y.id},ie,ue,We(Y.createdAt)," - ",ct," issues (",Ge,"%)",xt?` \xB7 ${xt}`:"",Y.storyId?` \xB7 ${te(Y.storyId)}`:"")}))))),!M&&!o&&Dt.createElement(SN,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import vJ,{useState as kJ}from"react";import{styled as Bw}from"storybook/theming";var IJ=Bw.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),FJ=Bw(Xr)({padding:"8px 12px",fontSize:"12px"});import mt,{useState as Dl}from"react";import{styled as Zt,keyframes as TN}from"storybook/theming";Re();nt();var IN=Zt.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),FN=Zt.div({position:"relative",display:"inline-flex"}),EN=TN`
|
|
68
68
|
0% { transform: rotate(0deg); }
|
|
69
69
|
100% { transform: rotate(360deg); }
|
|
70
|
-
`,
|
|
70
|
+
`,AN=Zt.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}})),PN=Zt.span`
|
|
71
71
|
display: inline-block;
|
|
72
72
|
width: 10px;
|
|
73
73
|
height: 10px;
|
|
74
74
|
border: 2px solid rgba(255,255,255,0.3);
|
|
75
75
|
border-top-color: #fff;
|
|
76
76
|
border-radius: 50%;
|
|
77
|
-
animation: ${
|
|
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=`
|
|
77
|
+
animation: ${EN} 0.8s linear infinite;
|
|
78
|
+
`,LN=Zt.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"})),MN=Zt.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),BN=Zt.div(({theme:e})=>({fontWeight:600,color:e.color.defaultText,fontSize:"12px"})),DN=Zt.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"})),RN=Zt.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),zN=Zt.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"11px",color:e.color.defaultText})),NN=Zt.span({display:"flex",alignItems:"center",gap:"4px"}),ON=Zt.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive||"#10b981":e==="warn"?t.color.warning||"#f59e0b":t.color.negative||"#ef4444",fontSize:"10px"})),_N=Zt.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),$N=Zt.div(({theme:e})=>({fontSize:"10px",color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),UN=Zt.ul(({theme:e})=>({margin:"8px 0 0 0",padding:"0 0 0 14px",fontSize:"10px",color:e.color.defaultText,"& li":{marginBottom:"2px"}})),jN=Zt.div({display:"flex",gap:"8px",alignItems:"flex-start"}),HN=Zt.div({flex:1}),WN=Zt(_t)({height:"36px",whiteSpace:"nowrap"}),VN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},GN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",bg=()=>{let{figmaFileUrl:e,setFigmaFileUrl:t,openComponentBrowser:n}=Qi(),{hasMapping:r}=No(),{selectedProjectId:o}=ir(),[i,s]=Dl(!1),[a,u]=Dl(!1),[c,l]=Dl(null),[p,f]=Dl(null),d=async()=>{if(!(!e||!o||a)){u(!0),f(null);try{let S=G(),T=localStorage.getItem("uicopilot_session_token"),F=await ne(`${S}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:o,figmaFileUrl:e,figmaMetadata:{}})});if(!F.ok)throw new Error("Failed to check quality");let k=await F.json();l(k),s(!0)}catch(S){console.error("[FigmaUrlInput] Quality check error:",S),f("Failed to check quality")}finally{u(!1)}}};return mt.createElement(To,null,mt.createElement(IN,null,mt.createElement(Io,{style:{marginBottom:0}},"Figma File URL"),!!e&&mt.createElement(FN,{onMouseEnter:()=>c&&s(!0),onMouseLeave:()=>s(!1)},mt.createElement(AN,{score:c?.score,isLoading:a,onClick:d,disabled:a||!o,title:c?"Click to refresh quality check":"Click to check Figma design quality"},a?mt.createElement(mt.Fragment,null,mt.createElement(PN,null)," Checking..."):c?mt.createElement(mt.Fragment,null,"\u{1F3A8} ",Math.round(c.score),"%"):mt.createElement(mt.Fragment,null,"\u{1F3A8} Check Quality")),i&&c&&mt.createElement(LN,null,mt.createElement(MN,null,mt.createElement(BN,null,"Figma Design Quality"),mt.createElement(DN,{score:c.score},Math.round(c.score),"%")),mt.createElement(RN,null,Object.entries(c.categories).map(([S,T])=>mt.createElement(zN,{key:S},mt.createElement(NN,null,mt.createElement(ON,{status:T.status},GN(T.status)),VN[S]||S),mt.createElement(_N,null,T.score)))),c.summary&&mt.createElement($N,null,c.summary),c.recommendations?.length>0&&mt.createElement(UN,null,c.recommendations.slice(0,2).map((S,T)=>mt.createElement("li",{key:T},S)))))),mt.createElement(jN,null,mt.createElement(HN,null,mt.createElement(Fo,{type:"text",placeholder:"https://www.figma.com/file/...",value:e,onChange:S=>t(S.target.value)})),mt.createElement(WN,{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 NJ,{useState as OJ}from"react";import{styled as Sg}from"storybook/theming";ke();Re();Me();nt();var VJ=Sg.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),GJ=Sg(Wn)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),qJ=Sg.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import XJ from"react";import{styled as qN}from"storybook/theming";var ZJ=qN.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));ke();import nZ from"react";import{styled as Er}from"storybook/theming";var iZ=Er.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),sZ=Er.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),aZ=Er.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),lZ=Er.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),cZ=Er.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),uZ=Er.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"})),pZ=Er.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),dZ=Er.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),fZ=Er.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)"}}})),gZ=Er.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));ke();import xZ,{useState as yZ}from"react";import{styled as Ar}from"storybook/theming";var wZ=Ar.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)`}}),vZ=Ar.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),kZ=Ar.div({display:"flex",alignItems:"center",gap:"8px"}),CZ=Ar.span({fontSize:"12px",opacity:.7}),TZ=Ar.span({fontSize:"13px",fontWeight:500}),IZ=Ar.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})),FZ=Ar.div({marginTop:"12px",fontSize:"11px"}),EZ=Ar.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),AZ=Ar.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"})),PZ=Ar.span({fontSize:"12px"});import vt,{useState as I6}from"react";import{styled as Xo}from"storybook/theming";Me();Re();import xr from"react";import{styled as ra}from"storybook/theming";ke();import Ko,{useState as cU}from"react";import{styled as Ni}from"storybook/theming";var Rl={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 YN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XN={};function zl(e,t){return((t||XN).jsx?KN:YN).test(e)}var QN=/[ \t\n\f\r]/g;function wg(e){return typeof e=="object"?e.type==="text"?Rw(e.value):!1:Rw(e)}function Rw(e){return e.replace(QN,"")===""}var Wr=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Wr.prototype.normal={};Wr.prototype.property={};Wr.prototype.space=void 0;function vg(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Wr(n,r,t)}function js(e){return e.toLowerCase()}var en=class{constructor(t,n){this.attribute=n,this.property=t}};en.prototype.attribute="";en.prototype.booleanish=!1;en.prototype.boolean=!1;en.prototype.commaOrSpaceSeparated=!1;en.prototype.commaSeparated=!1;en.prototype.defined=!1;en.prototype.mustUseProperty=!1;en.prototype.number=!1;en.prototype.overloadedBoolean=!1;en.prototype.property="";en.prototype.spaceSeparated=!1;en.prototype.space=void 0;var Hs={};be(Hs,{boolean:()=>Ne,booleanish:()=>Pt,commaOrSpaceSeparated:()=>Ln,commaSeparated:()=>xo,number:()=>q,overloadedBoolean:()=>Nl,spaceSeparated:()=>ft});var JN=0,Ne=jo(),Pt=jo(),Nl=jo(),q=jo(),ft=jo(),xo=jo(),Ln=jo();function jo(){return 2**++JN}var kg=Object.keys(Hs),Ho=class extends en{constructor(t,n,r,o){let i=-1;if(super(t,n),zw(this,"space",o),typeof r=="number")for(;++i<kg.length;){let s=kg[i];zw(this,kg[i],(r&Hs[s])===Hs[s])}}};Ho.prototype.defined=!0;function zw(e,t,n){n&&(e[t]=n)}function er(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new Ho(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[js(r)]=r,n[js(i.attribute)]=r}return new Wr(t,n,e.space)}var Cg=er({properties:{ariaActiveDescendant:null,ariaAtomic:Pt,ariaAutoComplete:null,ariaBusy:Pt,ariaChecked:Pt,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:ft,ariaCurrent:null,ariaDescribedBy:ft,ariaDetails:null,ariaDisabled:Pt,ariaDropEffect:ft,ariaErrorMessage:null,ariaExpanded:Pt,ariaFlowTo:ft,ariaGrabbed:Pt,ariaHasPopup:null,ariaHidden:Pt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ft,ariaLevel:q,ariaLive:null,ariaModal:Pt,ariaMultiLine:Pt,ariaMultiSelectable:Pt,ariaOrientation:null,ariaOwns:ft,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:Pt,ariaReadOnly:Pt,ariaRelevant:null,ariaRequired:Pt,ariaRoleDescription:ft,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:Pt,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 Ol(e,t){return t in e?e[t]:t}function _l(e,t){return Ol(e,t.toLowerCase())}var Nw=er({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:xo,acceptCharset:ft,accessKey:ft,action:null,allow:null,allowFullScreen:Ne,allowPaymentRequest:Ne,allowUserMedia:Ne,alt:null,as:null,async:Ne,autoCapitalize:null,autoComplete:ft,autoFocus:Ne,autoPlay:Ne,blocking:ft,capture:null,charSet:null,checked:Ne,cite:null,className:ft,cols:q,colSpan:null,content:null,contentEditable:Pt,controls:Ne,controlsList:ft,coords:q|xo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ne,defer:Ne,dir:null,dirName:null,disabled:Ne,download:Nl,draggable:Pt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ne,formTarget:null,headers:ft,height:q,hidden:Nl,high:q,href:null,hrefLang:null,htmlFor:ft,httpEquiv:ft,id:null,imageSizes:null,imageSrcSet:null,inert:Ne,inputMode:null,integrity:null,is:null,isMap:Ne,itemId:null,itemProp:ft,itemRef:ft,itemScope:Ne,itemType:ft,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ne,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:Ne,muted:Ne,name:null,nonce:null,noModule:Ne,noValidate:Ne,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:Ne,optimum:q,pattern:null,ping:ft,placeholder:null,playsInline:Ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ne,referrerPolicy:null,rel:ft,required:Ne,reversed:Ne,rows:q,rowSpan:q,sandbox:ft,scope:null,scoped:Ne,seamless:Ne,selected:Ne,shadowRootClonable:Ne,shadowRootDelegatesFocus:Ne,shadowRootMode:null,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:Pt,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:Ne,useMap:null,value:Pt,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ft,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:Ne,declare:Ne,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:Ne,noHref:Ne,noShade:Ne,noWrap:Ne,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:Pt,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:Ne,disableRemotePlayback:Ne,prefix:null,property:null,results:q,security:null,unselectable:null},space:"html",transform:_l});var Ow=er({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:Ln,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:ft,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:Ne,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:xo,g2:xo,glyphName:xo,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:Ln,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:ft,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ln,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ln,rev:Ln,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ln,requiredFeatures:Ln,requiredFonts:Ln,requiredFormats:Ln,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:Ln,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:Ln,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:Ln,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:Ol});var Tg=er({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 Ig=er({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:_l});var Fg=er({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Eg={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 ZN=/[A-Z]/g,_w=/-[a-z]/g,eO=/^data[-\w.:]+$/i;function Ag(e,t){let n=js(t),r=t,o=en;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&eO.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(_w,nO);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!_w.test(i)){let s=i.replace(ZN,tO);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=Ho}return new o(r,t)}function tO(e){return"-"+e.toLowerCase()}function nO(e){return e.charAt(1).toUpperCase()}var $w=vg([Cg,Nw,Tg,Ig,Fg],"html"),$l=vg([Cg,Ow,Tg,Ig,Fg],"svg");function Uw(e){return e.join(" ").trim()}var nv=ga(Jw(),1);var jl=Zw("end"),Li=Zw("start");function Zw(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 Mg(e){let t=Li(e),n=jl(e);if(t&&n)return{start:t,end:n}}function yo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ev(e.position):"start"in e||"end"in e?ev(e):"line"in e||"column"in e?Bg(e):""}function Bg(e){return tv(e&&e.line)+":"+tv(e&&e.column)}function ev(e){return Bg(e&&e.start)+"-"+Bg(e&&e.end)}function tv(e){return e&&typeof e=="number"?e:1}var Rt=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=yo(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}};Rt.prototype.file="";Rt.prototype.name="";Rt.prototype.reason="";Rt.prototype.message="";Rt.prototype.stack="";Rt.prototype.column=void 0;Rt.prototype.line=void 0;Rt.prototype.ancestors=void 0;Rt.prototype.cause=void 0;Rt.prototype.fatal=void 0;Rt.prototype.place=void 0;Rt.prototype.ruleId=void 0;Rt.prototype.source=void 0;var Dg={}.hasOwnProperty,EO=new Map,AO=/[A-Z]/g,PO=new Set(["table","tbody","thead","tfoot","tr"]),LO=new Set(["td","th"]),rv="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Rg(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=_O(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=OO(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"?$l:$w,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=ov(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function ov(e,t,n){if(t.type==="element")return MO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return BO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return RO(e,t,n);if(t.type==="mdxjsEsm")return DO(e,t);if(t.type==="root")return zO(e,t,n);if(t.type==="text")return NO(e,t)}function MO(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=$l,e.schema=o),e.ancestors.push(t);let i=sv(e,t.tagName,!1),s=$O(e,t),a=Ng(e,t);return PO.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!wg(u):!0})),iv(e,s,i,t),zg(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function BO(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)}Vs(e,t.position)}function DO(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Vs(e,t.position)}function RO(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=$l,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:sv(e,t.name,!0),s=UO(e,t),a=Ng(e,t);return iv(e,s,i,t),zg(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function zO(e,t,n){let r={};return zg(r,Ng(e,t)),e.create(t,e.Fragment,r,n)}function NO(e,t){return t.value}function iv(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function zg(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function OO(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 _O(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Li(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 $O(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&Dg.call(t.properties,o)){let i=jO(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&LO.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 UO(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 Vs(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 Vs(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function Ng(e,t){let n=[],r=-1,o=e.passKeys?new Map:EO;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=ov(e,i,s);a!==void 0&&n.push(a)}return n}function jO(e,t,n){let r=Ag(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Dw(n):Uw(n)),r.property==="style"){let o=typeof n=="object"?n:HO(e,String(n));return e.stylePropertyNameCase==="css"&&(o=WO(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?Eg[r.property]||r.property:r.attribute,n]}}function HO(e,t){try{return(0,nv.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,o=new Rt("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=rv+"#cannot-parse-style-attribute",o}}function sv(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=zl(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=zl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return Dg.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);Vs(e)}function Vs(e,t){let n=new Rt("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=rv+"#cannot-handle-mdx-estrees-without-createevaluater",n}function WO(e){let t={},n;for(n in e)Dg.call(e,n)&&(t[VO(n)]=e[n]);return t}function VO(e){let t=e.replace(AO,GO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function GO(e){return"-"+e.toLowerCase()}var Gs={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 eU,jsx as tU,jsxs as nU}from"react/jsx-runtime";import{useEffect as jse,useState as Hse}from"react";var qO={};function Og(e,t){let n=t||qO,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return lv(e,r,o)}function lv(e,t,n){if(YO(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 av(e.children,t,n)}return Array.isArray(e)?av(e,t,n):""}function av(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=lv(e[o],t,n);return r.join("")}function YO(e){return!!(e&&typeof e=="object")}var cv=document.createElement("i");function Mi(e){let t="&"+e+";";cv.innerHTML=t;let n=cv.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function an(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 xn(e,t){return e.length>0?(an(e,e.length,0,t),e):t}var uv={}.hasOwnProperty;function pv(e){let t={},n=-1;for(;++n<e.length;)KO(t,e[n]);return t}function KO(e,t){let n;for(n in t){let o=(uv.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){uv.call(o,s)||(o[s]=[]);let a=i[s];XO(o[s],Array.isArray(a)?a:a?[a]:[])}}}function XO(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);an(e,0,0,r)}function Hl(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 Vr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var _n=bo(/[A-Za-z]/),tn=bo(/[\dA-Za-z]/),dv=bo(/[#-'*+\--9=?A-Z^-~]/);function qs(e){return e!==null&&(e<32||e===127)}var Ys=bo(/\d/),fv=bo(/[\dA-Fa-f]/),gv=bo(/[!-/:-@[-`{-~]/);function le(e){return e!==null&&e<-2}function zt(e){return e!==null&&(e<0||e===32)}function De(e){return e===-2||e===-1||e===32}var mv=bo(/\p{P}|\p{S}/u),hv=bo(/\s/);function bo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function tr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&tn(e.charCodeAt(n+1))&&tn(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 Oe(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return De(u)?(e.enter(n),a(u)):t(u)}function a(u){return De(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var xv={tokenize:QO};function QO(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"),Oe(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 le(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var bv={tokenize:JO},yv={tokenize:ZO};function JO(e){let t=this,n=[],r=0,o,i,s;return a;function a(z){if(r<n.length){let R=n[r];return t.containerState=R[1],e.attempt(R[0].continuation,u,c)(z)}return c(z)}function u(z){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&k();let R=t.events.length,O=R,E;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){E=t.events[O][1].end;break}F(r);let D=R;for(;D<t.events.length;)t.events[D][1].end={...E},D++;return an(t.events,O+1,0,t.events.slice(R)),t.events.length=D,c(z)}return a(z)}function c(z){if(r===n.length){if(!o)return f(z);if(o.currentConstruct&&o.currentConstruct.concrete)return m(z);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(yv,l,p)(z)}function l(z){return o&&k(),F(r),f(z)}function p(z){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,m(z)}function f(z){return t.containerState={},e.attempt(yv,d,m)(z)}function d(z){return r++,n.push([t.currentConstruct,t.containerState]),f(z)}function m(z){if(z===null){o&&k(),F(0),e.consume(z);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),S(z)}function S(z){if(z===null){T(e.exit("chunkFlow"),!0),F(0),e.consume(z);return}return le(z)?(e.consume(z),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(z),S)}function T(z,R){let O=t.sliceStream(z);if(R&&O.push(null),z.previous=i,i&&(i.next=z),i=z,o.defineSkip(z.start),o.write(O),t.parser.lazy[z.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 D=t.events.length,g=D,w,v;for(;g--;)if(t.events[g][0]==="exit"&&t.events[g][1].type==="chunkFlow"){if(w){v=t.events[g][1].end;break}w=!0}for(F(r),E=D;E<t.events.length;)t.events[E][1].end={...v},E++;an(t.events,g+1,0,t.events.slice(D)),t.events.length=E}}function F(z){let R=n.length;for(;R-- >z;){let O=n[R];t.containerState=O[1],O[0].exit.call(t,e)}n.length=z}function k(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function ZO(e,t,n){return Oe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function _g(e){if(e===null||zt(e)||hv(e))return 1;if(mv(e))return 2}function Bi(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 Ks={name:"attention",resolveAll:e_,tokenize:t_};function e_(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};Sv(p,-u),Sv(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=xn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=xn(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=xn(c,Bi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=xn(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=xn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,an(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 t_(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=_g(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=_g(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 Sv(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var $g={name:"autolink",tokenize:n_};function n_(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 _n(d)?(e.consume(d),s):d===64?n(d):c(d)}function s(d){return d===43||d===45||d===46||tn(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||tn(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||qs(d)?n(d):(e.consume(d),u)}function c(d){return d===64?(e.consume(d),l):dv(d)?(e.consume(d),c):n(d)}function l(d){return tn(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||tn(d))&&r++<63){let m=d===45?f:p;return e.consume(d),m}return n(d)}}var So={partial:!0,tokenize:r_};function r_(e,t,n){return r;function r(i){return De(i)?Oe(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||le(i)?t(i):n(i)}}var Wl={continuation:{tokenize:i_},exit:s_,name:"blockQuote",tokenize:o_};function o_(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 De(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function i_(e,t,n){let r=this;return o;function o(s){return De(s)?Oe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(Wl,t,n)(s)}}function s_(e){e.exit("blockQuote")}var Vl={name:"characterEscape",tokenize:a_};function a_(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 gv(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Gl={name:"characterReference",tokenize:l_};function l_(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=tn,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=fv,l):(e.enter("characterReferenceValue"),i=7,s=Ys,l(p))}function l(p){if(p===59&&o){let f=e.exit("characterReferenceValue");return s===tn&&!Mi(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 wv={partial:!0,tokenize:u_},ql={concrete:!0,name:"codeFenced",tokenize:c_};function c_(e,t,n){let r=this,o={partial:!0,tokenize:O},i=0,s=0,a;return u;function u(E){return c(E)}function c(E){let D=r.events[r.events.length-1];return i=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[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"),De(E)?Oe(e,p,"whitespace")(E):p(E))}function p(E){return E===null||le(E)?(e.exit("codeFencedFence"),r.interrupt?t(E):e.check(wv,S,R)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(E))}function f(E){return E===null||le(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(E)):De(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Oe(e,d,"whitespace")(E)):E===96&&E===a?n(E):(e.consume(E),f)}function d(E){return E===null||le(E)?p(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(E))}function m(E){return E===null||le(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(E)):E===96&&E===a?n(E):(e.consume(E),m)}function S(E){return e.attempt(o,R,T)(E)}function T(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),F}function F(E){return i>0&&De(E)?Oe(e,k,"linePrefix",i+1)(E):k(E)}function k(E){return E===null||le(E)?e.check(wv,S,R)(E):(e.enter("codeFlowValue"),z(E))}function z(E){return E===null||le(E)?(e.exit("codeFlowValue"),k(E)):(e.consume(E),z)}function R(E){return e.exit("codeFenced"),t(E)}function O(E,D,g){let w=0;return v;function v(y){return E.enter("lineEnding"),E.consume(y),E.exit("lineEnding"),A}function A(y){return E.enter("codeFencedFence"),De(y)?Oe(E,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):h(y)}function h(y){return y===a?(E.enter("codeFencedFenceSequence"),C(y)):g(y)}function C(y){return y===a?(w++,E.consume(y),C):w>=s?(E.exit("codeFencedFenceSequence"),De(y)?Oe(E,I,"whitespace")(y):I(y)):g(y)}function I(y){return y===null||le(y)?(E.exit("codeFencedFence"),D(y)):g(y)}}}function u_(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 Xs={name:"codeIndented",tokenize:d_},p_={partial:!0,tokenize:f_};function d_(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),Oe(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):le(c)?e.attempt(p_,s,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||le(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),t(c)}}function f_(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):le(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):Oe(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):le(s)?o(s):n(s)}}var Ug={name:"codeText",previous:m_,resolve:g_,tokenize:h_};function g_(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 m_(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function h_(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)):le(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||le(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 Yl=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&&Qs(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),Qs(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Qs(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);Qs(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Qs(this.left,n.reverse())}}};function Qs(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 Kl(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Yl(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,x_(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 an(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function x_(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,m=0,S=0,T=[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,T.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):T.pop(),f=T.length;f--;){let F=a.slice(T[f],T[f+1]),k=i.pop();u.push([k,k+F.length-1]),e.splice(k,2,F)}for(u.reverse(),f=-1;++f<u.length;)c[m+u[f][0]]=m+u[f][1],m+=u[f][1]-u[f][0]-1;return c}var jg={resolve:b_,tokenize:S_},y_={partial:!0,tokenize:w_};function b_(e){return Kl(e),e}function S_(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):le(a)?e.check(y_,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 w_(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Oe(e,i,"linePrefix")}function i(s){if(s===null||le(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 Xl(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||qs(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||le(F)?n(F):(e.consume(F),F===92?m:d)}function m(F){return F===60||F===62||F===92?(e.consume(F),d):d(F)}function S(F){return!l&&(F===null||F===41||zt(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||qs(F)?n(F):(e.consume(F),F===92?T:S)}function T(F){return F===40||F===41||F===92?(e.consume(F),S):S(F)}}function Ql(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):le(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||le(d)||a++>999?(e.exit("chunkString"),l(d)):(e.consume(d),u||(u=!De(d)),d===92?f:p)}function f(d){return d===91||d===92||d===93?(e.consume(d),a++,p):p(d)}}function Jl(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):le(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Oe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===s||f===null||le(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 Vo(e,t){let n;return r;function r(o){return le(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):De(o)?Oe(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Hg={name:"definition",tokenize:k_},v_={partial:!0,tokenize:C_};function k_(e,t,n){let r=this,o;return i;function i(d){return e.enter("definition"),s(d)}function s(d){return Ql.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return o=Vr(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 zt(d)?Vo(e,c)(d):c(d)}function c(d){return Xl(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function l(d){return e.attempt(v_,p,p)(d)}function p(d){return De(d)?Oe(e,f,"whitespace")(d):f(d)}function f(d){return d===null||le(d)?(e.exit("definition"),r.parser.defined.push(o),t(d)):n(d)}}function C_(e,t,n){return r;function r(a){return zt(a)?Vo(e,o)(a):n(a)}function o(a){return Jl(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return De(a)?Oe(e,s,"whitespace")(a):s(a)}function s(a){return a===null||le(a)?t(a):n(a)}}var Wg={name:"hardBreakEscape",tokenize:T_};function T_(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return le(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}var Vg={name:"headingAtx",resolve:I_,tokenize:F_};function I_(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"},an(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function F_(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||zt(l)?(e.exit("atxHeadingSequence"),a(l)):n(l)}function a(l){return l===35?(e.enter("atxHeadingSequence"),u(l)):l===null||le(l)?(e.exit("atxHeading"),t(l)):De(l)?Oe(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||zt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var vv=["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"],Gg=["pre","script","style","textarea"];var qg={concrete:!0,name:"htmlFlow",resolveTo:P_,tokenize:L_},E_={partial:!0,tokenize:B_},A_={partial:!0,tokenize:M_};function P_(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 L_(e,t,n){let r=this,o,i,s,a,u;return c;function c(M){return l(M)}function l(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),p}function p(M){return M===33?(e.consume(M),f):M===47?(e.consume(M),i=!0,S):M===63?(e.consume(M),o=3,r.interrupt?t:x):_n(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function f(M){return M===45?(e.consume(M),o=2,d):M===91?(e.consume(M),o=5,a=0,m):_n(M)?(e.consume(M),o=4,r.interrupt?t:x):n(M)}function d(M){return M===45?(e.consume(M),r.interrupt?t:x):n(M)}function m(M){let Q="CDATA[";return M===Q.charCodeAt(a++)?(e.consume(M),a===Q.length?r.interrupt?t:h:m):n(M)}function S(M){return _n(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function T(M){if(M===null||M===47||M===62||zt(M)){let Q=M===47,ee=s.toLowerCase();return!Q&&!i&&Gg.includes(ee)?(o=1,r.interrupt?t(M):h(M)):vv.includes(s.toLowerCase())?(o=6,Q?(e.consume(M),F):r.interrupt?t(M):h(M)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):i?k(M):z(M))}return M===45||tn(M)?(e.consume(M),s+=String.fromCharCode(M),T):n(M)}function F(M){return M===62?(e.consume(M),r.interrupt?t:h):n(M)}function k(M){return De(M)?(e.consume(M),k):v(M)}function z(M){return M===47?(e.consume(M),v):M===58||M===95||_n(M)?(e.consume(M),R):De(M)?(e.consume(M),z):v(M)}function R(M){return M===45||M===46||M===58||M===95||tn(M)?(e.consume(M),R):O(M)}function O(M){return M===61?(e.consume(M),E):De(M)?(e.consume(M),O):z(M)}function E(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),u=M,D):De(M)?(e.consume(M),E):g(M)}function D(M){return M===u?(e.consume(M),u=null,w):M===null||le(M)?n(M):(e.consume(M),D)}function g(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||zt(M)?O(M):(e.consume(M),g)}function w(M){return M===47||M===62||De(M)?z(M):n(M)}function v(M){return M===62?(e.consume(M),A):n(M)}function A(M){return M===null||le(M)?h(M):De(M)?(e.consume(M),A):n(M)}function h(M){return M===45&&o===2?(e.consume(M),P):M===60&&o===1?(e.consume(M),L):M===62&&o===4?(e.consume(M),U):M===63&&o===3?(e.consume(M),x):M===93&&o===5?(e.consume(M),N):le(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(E_,H,C)(M)):M===null||le(M)?(e.exit("htmlFlowData"),C(M)):(e.consume(M),h)}function C(M){return e.check(A_,I,H)(M)}function I(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),y}function y(M){return M===null||le(M)?C(M):(e.enter("htmlFlowData"),h(M))}function P(M){return M===45?(e.consume(M),x):h(M)}function L(M){return M===47?(e.consume(M),s="",B):h(M)}function B(M){if(M===62){let Q=s.toLowerCase();return Gg.includes(Q)?(e.consume(M),U):h(M)}return _n(M)&&s.length<8?(e.consume(M),s+=String.fromCharCode(M),B):h(M)}function N(M){return M===93?(e.consume(M),x):h(M)}function x(M){return M===62?(e.consume(M),U):M===45&&o===2?(e.consume(M),x):h(M)}function U(M){return M===null||le(M)?(e.exit("htmlFlowData"),H(M)):(e.consume(M),U)}function H(M){return e.exit("htmlFlow"),t(M)}}function M_(e,t,n){let r=this;return o;function o(s){return le(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 B_(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(So,t,n)}}var Yg={name:"htmlText",tokenize:D_};function D_(e,t,n){let r=this,o,i,s;return a;function a(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),u}function u(x){return x===33?(e.consume(x),c):x===47?(e.consume(x),O):x===63?(e.consume(x),z):_n(x)?(e.consume(x),g):n(x)}function c(x){return x===45?(e.consume(x),l):x===91?(e.consume(x),i=0,m):_n(x)?(e.consume(x),k):n(x)}function l(x){return x===45?(e.consume(x),d):n(x)}function p(x){return x===null?n(x):x===45?(e.consume(x),f):le(x)?(s=p,L(x)):(e.consume(x),p)}function f(x){return x===45?(e.consume(x),d):p(x)}function d(x){return x===62?P(x):x===45?f(x):p(x)}function m(x){let U="CDATA[";return x===U.charCodeAt(i++)?(e.consume(x),i===U.length?S:m):n(x)}function S(x){return x===null?n(x):x===93?(e.consume(x),T):le(x)?(s=S,L(x)):(e.consume(x),S)}function T(x){return x===93?(e.consume(x),F):S(x)}function F(x){return x===62?P(x):x===93?(e.consume(x),F):S(x)}function k(x){return x===null||x===62?P(x):le(x)?(s=k,L(x)):(e.consume(x),k)}function z(x){return x===null?n(x):x===63?(e.consume(x),R):le(x)?(s=z,L(x)):(e.consume(x),z)}function R(x){return x===62?P(x):z(x)}function O(x){return _n(x)?(e.consume(x),E):n(x)}function E(x){return x===45||tn(x)?(e.consume(x),E):D(x)}function D(x){return le(x)?(s=D,L(x)):De(x)?(e.consume(x),D):P(x)}function g(x){return x===45||tn(x)?(e.consume(x),g):x===47||x===62||zt(x)?w(x):n(x)}function w(x){return x===47?(e.consume(x),P):x===58||x===95||_n(x)?(e.consume(x),v):le(x)?(s=w,L(x)):De(x)?(e.consume(x),w):P(x)}function v(x){return x===45||x===46||x===58||x===95||tn(x)?(e.consume(x),v):A(x)}function A(x){return x===61?(e.consume(x),h):le(x)?(s=A,L(x)):De(x)?(e.consume(x),A):w(x)}function h(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),o=x,C):le(x)?(s=h,L(x)):De(x)?(e.consume(x),h):(e.consume(x),I)}function C(x){return x===o?(e.consume(x),o=void 0,y):x===null?n(x):le(x)?(s=C,L(x)):(e.consume(x),C)}function I(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||zt(x)?w(x):(e.consume(x),I)}function y(x){return x===47||x===62||zt(x)?w(x):n(x)}function P(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function L(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),B}function B(x){return De(x)?Oe(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):N(x)}function N(x){return e.enter("htmlTextData"),s(x)}}var Go={name:"labelEnd",resolveAll:O_,resolveTo:__,tokenize:$_},R_={tokenize:U_},z_={tokenize:j_},N_={tokenize:H_};function O_(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&&an(e,0,e.length,n),e}function __(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=xn(a,e.slice(i+1,i+r+3)),a=xn(a,[["enter",l,t]]),a=xn(a,Bi(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=xn(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=xn(a,e.slice(s+1)),a=xn(a,[["exit",u,t]]),an(e,i,e.length,a),e}function $_(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(Vr(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(R_,l,s?l:p)(f):f===91?e.attempt(z_,l,s?c:p)(f):s?l(f):p(f)}function c(f){return e.attempt(N_,l,p)(f)}function l(f){return t(f)}function p(f){return i._balanced=!0,n(f)}}function U_(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 zt(p)?Vo(e,i)(p):i(p)}function i(p){return p===41?l(p):Xl(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function s(p){return zt(p)?Vo(e,u)(p):l(p)}function a(p){return n(p)}function u(p){return p===34||p===39||p===40?Jl(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):l(p)}function c(p){return zt(p)?Vo(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 j_(e,t,n){let r=this;return o;function o(a){return Ql.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(Vr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function H_(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 Kg={name:"labelStartImage",resolveAll:Go.resolveAll,tokenize:W_};function W_(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 Xg={name:"labelStartLink",resolveAll:Go.resolveAll,tokenize:V_};function V_(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:G_};function G_(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Oe(e,t,"linePrefix")}}var qo={name:"thematicBreak",tokenize:q_};function q_(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||le(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===o?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),De(c)?Oe(e,a,"whitespace")(c):a(c))}}var pn={continuation:{tokenize:Q_},exit:Z_,name:"list",tokenize:X_},Y_={partial:!0,tokenize:e$},K_={partial:!0,tokenize:J_};function X_(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 m=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:Ys(d)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(qo,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 Ys(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(So,r.interrupt?n:l,e.attempt(Y_,f,p))}function l(d){return r.containerState.initialBlankLine=!0,i++,f(d)}function p(d){return De(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 Q_(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(So,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Oe(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!De(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(K_,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Oe(e,e.attempt(pn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function J_(e,t,n){let r=this;return Oe(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 Z_(e){e.exit(this.containerState.type)}function e$(e,t,n){let r=this;return Oe(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!De(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var Zl={name:"setextUnderline",resolveTo:t$,tokenize:n$};function t$(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 n$(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"),De(c)?Oe(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||le(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var kv={tokenize:r$};function r$(e){let t=this,n=e.attempt(So,r,e.attempt(this.parser.constructs.flowInitial,o,Oe(e,e.attempt(this.parser.constructs.flow,o,e.attempt(jg,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 Cv={resolveAll:Ev()},Tv=Fv("string"),Iv=Fv("text");function Fv(e){return{resolveAll:Ev(e==="text"?o$: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 Ev(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 o$(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 Qg={};be(Qg,{attentionMarkers:()=>d$,contentInitial:()=>s$,disable:()=>f$,document:()=>i$,flow:()=>l$,flowInitial:()=>a$,insideSpan:()=>p$,string:()=>c$,text:()=>u$});var i$={42:pn,43:pn,45:pn,48:pn,49:pn,50:pn,51:pn,52:pn,53:pn,54:pn,55:pn,56:pn,57:pn,62:Wl},s$={91:Hg},a$={[-2]:Xs,[-1]:Xs,32:Xs},l$={35:Vg,42:qo,45:[Zl,qo],60:qg,61:Zl,95:qo,96:ql,126:ql},c$={38:Gl,92:Vl},u$={[-5]:Js,[-4]:Js,[-3]:Js,33:Kg,38:Gl,42:Ks,60:[$g,Yg],91:Xg,92:[Wg,Vl],93:Go,95:Ks,96:Ug},p$={null:[Ks,Cv]},d$={null:[42,95]},f$={null:[]};function Av(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:w(D),check:w(g),consume:R,enter:O,exit:E,interrupt:w(g,{interrupt:!0})},l={code:null,containerState:{},defineSkip:F,events:[],now:T,parser:e,previous:null,sliceSerialize:m,sliceStream:S,write:d},p=t.tokenize.call(l,c),f;return t.resolveAll&&i.push(t),l;function d(C){return s=xn(s,C),k(),s[s.length-1]!==null?[]:(v(t,0),l.events=Bi(i,l.events,l),l.events)}function m(C,I){return m$(S(C),I)}function S(C){return g$(s,C)}function T(){let{_bufferIndex:C,_index:I,line:y,column:P,offset:L}=r;return{_bufferIndex:C,_index:I,line:y,column:P,offset:L}}function F(C){o[C.line]=C.column,h()}function k(){let C;for(;r._index<s.length;){let I=s[r._index];if(typeof I=="string")for(C=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===C&&r._bufferIndex<I.length;)z(I.charCodeAt(r._bufferIndex));else z(I)}}function z(C){u=void 0,f=C,p=p(C)}function R(C){le(C)?(r.line++,r.column=1,r.offset+=C===-3?2:1,h()):C!==-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=C,u=!0}function O(C,I){let y=I||{};return y.type=C,y.start=T(),l.events.push(["enter",y,l]),a.push(y),y}function E(C){let I=a.pop();return I.end=T(),l.events.push(["exit",I,l]),I}function D(C,I){v(C,I.from)}function g(C,I){I.restore()}function w(C,I){return y;function y(P,L,B){let N,x,U,H;return Array.isArray(P)?Q(P):"tokenize"in P?Q([P]):M(P);function M(Ee){return We;function We(st){let te=st!==null&&Ee[st],Y=st!==null&&Ee.null,ce=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(Y)?Y:Y?[Y]:[]];return Q(ce)(st)}}function Q(Ee){return N=Ee,x=0,Ee.length===0?B:ee(Ee[x])}function ee(Ee){return We;function We(st){return H=A(),U=Ee,Ee.partial||(l.currentConstruct=Ee),Ee.name&&l.parser.constructs.disable.null.includes(Ee.name)?Le(st):Ee.tokenize.call(I?Object.assign(Object.create(l),I):l,c,J,Le)(st)}}function J(Ee){return u=!0,C(U,H),L}function Le(Ee){return u=!0,H.restore(),++x<N.length?ee(N[x]):B}}}function v(C,I){C.resolveAll&&!i.includes(C)&&i.push(C),C.resolve&&an(l.events,I,l.events.length-I,C.resolve(l.events.slice(I),l)),C.resolveTo&&(l.events=C.resolveTo(l.events,l))}function A(){let C=T(),I=l.previous,y=l.currentConstruct,P=l.events.length,L=Array.from(a);return{from:P,restore:B};function B(){r=C,l.previous=I,l.currentConstruct=y,l.events.length=P,a=L,h()}}function h(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function g$(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 m$(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
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
|
|
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
|
|
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 Jg(e){let r={constructs:pv([Qg,...(e||{}).extensions||[]]),content:o(xv),defined:[],document:o(bv),flow:o(kv),lazy:{},string:o(Tv),text:o(Iv)};return r;function o(i){return s;function s(a){return Av(r,i,a)}}}function Zg(e){for(;!Kl(e););return e}var Pv=/[\0\t\n\r]/g;function em(){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(Pv.lastIndex=p,c=Pv.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 h$=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Lv(e){return e.replace(h$,x$)}function x$(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return Hl(n.slice(i?2:1),i?16:10)}return Mi(n)||e}var Bv={}.hasOwnProperty;function tm(e,t,n){return typeof t!="string"&&(n=t,t=void 0),y$(n)(Zg(Jg(n).document().write(em()(e,t,!0))))}function y$(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(yn),autolinkProtocol:w,autolinkEmail:w,atxHeading:i(ue),blockQuote:i(st),characterEscape:w,characterReference:w,codeFenced:i(te),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(te,s),codeText:i(Y,s),codeTextData:w,data:w,codeFlowValue:w,definition:i(ce),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(ie),hardBreakEscape:i(ct),hardBreakTrailing:i(ct),htmlFlow:i(Ge,s),htmlFlowData:w,htmlText:i(Ge,s),htmlTextData:w,image:i(xt),label:s,link:i(yn),listItem:i(fe),listItemValue:f,listOrdered:i(qe,p),listUnordered:i(qe),paragraph:i(kt),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(ue),strong:i(yr),thematicBreak:i(Xe)},exit:{atxHeading:u(),atxHeadingSequence:O,autolink:u(),autolinkEmail:We,autolinkProtocol:Ee,blockQuote:u(),characterEscapeValue:v,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:J,characterReference:Le,codeFenced:u(T),codeFencedFence:S,codeFencedFenceInfo:d,codeFencedFenceMeta:m,codeFlowValue:v,codeIndented:u(F),codeText:u(y),codeTextData:v,data:v,definition:u(),definitionDestinationString:R,definitionLabelString:k,definitionTitleString:z,emphasis:u(),hardBreakEscape:u(h),hardBreakTrailing:u(h),htmlFlow:u(C),htmlFlowData:v,htmlText:u(I),htmlTextData:v,image:u(L),label:N,labelText:B,lineEnding:A,link:u(P),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:Q,resourceDestinationString:x,resourceTitleString:U,resource:H,setextHeading:u(g),setextHeadingLineSequence:D,setextHeadingText:E,strong:u(),thematicBreak:u()}};Dv(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=[],et=-1;for(;++et<_.length;)if(_[et][1].type==="listOrdered"||_[et][1].type==="listUnordered")if(_[et][0]==="enter")Z.push(et);else{let qt=Z.pop();et=o(_,qt,et)}for(et=-1;++et<_.length;){let qt=t[_[et][0]];Bv.call(qt,_[et][1].type)&&qt[_[et][1].type].call(Object.assign({sliceSerialize:_[et][2].sliceSerialize},W),_[et][1])}if(W.tokenStack.length>0){let qt=W.tokenStack[W.tokenStack.length-1];(qt[1]||Mv).call(W,void 0,qt[0])}for($.position={start:wo(_.length>0?_[0][1].start:{line:1,column:1,offset:0}),end:wo(_.length>0?_[_.length-2][1].end:{line:1,column:1,offset:0})},et=-1;++et<t.transforms.length;)$=t.transforms[et]($)||$;return $}function o(_,$,W){let Z=$-1,et=-1,qt=!1,br,or,Pr,bn;for(;++Z<=W;){let xe=_[Z];switch(xe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{xe[0]==="enter"?et++:et--,bn=void 0;break}case"lineEndingBlank":{xe[0]==="enter"&&(br&&!bn&&!et&&!Pr&&(Pr=Z),bn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:bn=void 0}if(!et&&xe[0]==="enter"&&xe[1].type==="listItemPrefix"||et===-1&&xe[0]==="exit"&&(xe[1].type==="listUnordered"||xe[1].type==="listOrdered")){if(br){let Sr=Z;for(or=void 0;Sr--;){let $n=_[Sr];if($n[1].type==="lineEnding"||$n[1].type==="lineEndingBlank"){if($n[0]==="exit")continue;or&&(_[or][1].type="lineEndingBlank",qt=!0),$n[1].type="lineEnding",or=Sr}else if(!($n[1].type==="linePrefix"||$n[1].type==="blockQuotePrefix"||$n[1].type==="blockQuotePrefixWhitespace"||$n[1].type==="blockQuoteMarker"||$n[1].type==="listItemIndent"))break}Pr&&(!or||Pr<or)&&(br._spread=!0),br.end=Object.assign({},or?_[or][1].start:xe[1].end),_.splice(or||Z,0,["exit",br,xe[2]]),Z++,W++}if(xe[1].type==="listItemPrefix"){let Sr={type:"listItem",_spread:!1,start:Object.assign({},xe[1].start),end:void 0};br=Sr,_.splice(Z,0,["enter",Sr,xe[2]]),Z++,W++,Pr=void 0,bn=!0}}}return _[$][1]._spread=qt,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:wo($.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]||Mv).call(this,_,Z[0]));else throw new Error("Cannot close `"+_.type+"` ("+yo({start:_.start,end:_.end})+"): it\u2019s not open");W.position.end=wo(_.end)}function l(){return Og(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 m(){let _=this.resume(),$=this.stack[this.stack.length-1];$.meta=_}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){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 k(_){let $=this.resume(),W=this.stack[this.stack.length-1];W.label=$,W.identifier=Vr(this.sliceSerialize(_)).toLowerCase()}function z(){let _=this.resume(),$=this.stack[this.stack.length-1];$.title=_}function R(){let _=this.resume(),$=this.stack[this.stack.length-1];$.url=_}function O(_){let $=this.stack[this.stack.length-1];if(!$.depth){let W=this.sliceSerialize(_).length;$.depth=W}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function D(_){let $=this.stack[this.stack.length-1];$.depth=this.sliceSerialize(_).codePointAt(0)===61?1:2}function g(){this.data.setextHeadingSlurpLineEnding=void 0}function w(_){let W=this.stack[this.stack.length-1].children,Z=W[W.length-1];(!Z||Z.type!=="text")&&(Z=pe(),Z.position={start:wo(_.start),end:void 0},W.push(Z)),this.stack.push(Z)}function v(_){let $=this.stack.pop();$.value+=this.sliceSerialize(_),$.position.end=wo(_.end)}function A(_){let $=this.stack[this.stack.length-1];if(this.data.atHardBreak){let W=$.children[$.children.length-1];W.position.end=wo(_.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes($.type)&&(w.call(this,_),v.call(this,_))}function h(){this.data.atHardBreak=!0}function C(){let _=this.resume(),$=this.stack[this.stack.length-1];$.value=_}function I(){let _=this.resume(),$=this.stack[this.stack.length-1];$.value=_}function y(){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 B(_){let $=this.sliceSerialize(_),W=this.stack[this.stack.length-2];W.label=Lv($),W.identifier=Vr($).toLowerCase()}function N(){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 x(){let _=this.resume(),$=this.stack[this.stack.length-1];$.url=_}function U(){let _=this.resume(),$=this.stack[this.stack.length-1];$.title=_}function H(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function Q(_){let $=this.resume(),W=this.stack[this.stack.length-1];W.label=$,W.identifier=Vr(this.sliceSerialize(_)).toLowerCase(),this.data.referenceType="full"}function ee(_){this.data.characterReferenceType=_.type}function J(_){let $=this.sliceSerialize(_),W=this.data.characterReferenceType,Z;W?(Z=Hl($,W==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Z=Mi($);let et=this.stack[this.stack.length-1];et.value+=Z}function Le(_){let $=this.stack.pop();$.position.end=wo(_.end)}function Ee(_){v.call(this,_);let $=this.stack[this.stack.length-1];$.url=this.sliceSerialize(_)}function We(_){v.call(this,_);let $=this.stack[this.stack.length-1];$.url="mailto:"+this.sliceSerialize(_)}function st(){return{type:"blockquote",children:[]}}function te(){return{type:"code",lang:null,meta:null,value:""}}function Y(){return{type:"inlineCode",value:""}}function ce(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ie(){return{type:"emphasis",children:[]}}function ue(){return{type:"heading",depth:0,children:[]}}function ct(){return{type:"break"}}function Ge(){return{type:"html",value:""}}function xt(){return{type:"image",title:null,url:"",alt:null}}function yn(){return{type:"link",title:null,url:"",children:[]}}function qe(_){return{type:"list",ordered:_.type==="listOrdered",start:null,spread:_._spread,children:[]}}function fe(_){return{type:"listItem",spread:_._spread,checked:null,children:[]}}function kt(){return{type:"paragraph",children:[]}}function yr(){return{type:"strong",children:[]}}function pe(){return{type:"text",value:""}}function Xe(){return{type:"thematicBreak"}}}function wo(e){return{line:e.line,column:e.column,offset:e.offset}}function Dv(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Dv(e,r):b$(e,r)}}function b$(e,t){let n;for(n in t)if(Bv.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 Mv(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+yo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is still open")}function ec(e){let t=this;t.parser=n;function n(r){return tm(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Rv(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 zv(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
81
|
+
`}]}function Nv(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 Ov(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _v(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $v(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=tr(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 Uv(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 jv(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function tc(e,t){let n=t.referenceType,r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];let o=e.all(t),i=o[0];i&&i.type==="text"?i.value="["+i.value:o.unshift({type:"text",value:"["});let s=o[o.length-1];return s&&s.type==="text"?s.value+=r:o.push({type:"text",value:r}),o}function Hv(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return tc(e,t);let o={src:tr(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 Wv(e,t){let n={src:tr(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 Vv(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 Gv(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return tc(e,t);let o={href:tr(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 qv(e,t){let n={href:tr(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 Yv(e,t,n){let r=e.all(t),o=n?S$(n):Kv(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
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
|
|
84
|
+
`});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function S$(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Kv(n[r])}return t}function Kv(e){let t=e.spread;return t??e.children.length>1}function Xv(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 Qv(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Jv(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Zv(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ek(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=Li(t.children[1]),u=jl(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 tk(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 m={type:"element",tagName:i,properties:f,children:[]};p&&(m.children=e.all(p),e.patch(p,m),m=e.applyData(p,m)),c.push(m)}let l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function nk(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ok(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 ik(e,t){let n={type:"text",value:ok(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function sk(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var ak={blockquote:Rv,break:zv,code:Nv,delete:Ov,emphasis:_v,footnoteReference:$v,heading:Uv,html:jv,imageReference:Hv,image:Wv,inlineCode:Vv,linkReference:Gv,link:qv,listItem:Yv,list:Xv,paragraph:Qv,root:Jv,strong:Zv,table:ek,tableCell:nk,tableRow:tk,text:ik,thematicBreak:sk,toml:nc,yaml:nc,definition:nc,footnoteDefinition:nc};function nc(){}var lk=typeof self=="object"?self:globalThis,C$=(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 lk[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 lk[i](s),o)};return r},om=e=>C$(new Map,e)(0);var Di="",{toString:T$}={},{keys:I$}=Object,Zs=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=T$.call(e).slice(8,-1);switch(n){case"Array":return[1,Di];case"Object":return[2,Di];case"Date":return[3,Di];case"RegExp":return[4,Di];case"Map":return[5,Di];case"Set":return[6,Di];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},oc=([e,t])=>e===0&&(t==="function"||t==="symbol"),F$=(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]=Zs(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 I$(s))(e||!oc(Zs(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||!(oc(Zs(f))||oc(Zs(d))))&&l.push([i(f),i(d)]);return p}case 6:{let l=[],p=o([a,l],s);for(let f of s)(e||!oc(Zs(f)))&&l.push(i(f));return p}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},im=(e,{json:t,lossy:n}={})=>{let r=[];return F$(!(t||n),!!t,new Map,r)(e),r};var Ri=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?om(im(e,t)):structuredClone(e):(e,t)=>om(im(e,t));function E$(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 A$(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function fk(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||E$,r=e.options.footnoteBackLabel||A$,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=tr(p.toLowerCase()),d=0,m=[],S=e.footnoteCounts.get(p);for(;S!==void 0&&++d<=S;){m.length>0&&m.push({type:"text",value:" "});let k=typeof n=="string"?n:n(u,d);typeof k=="string"&&(k={type:"text",value:k}),m.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(k)?k:[k]})}let T=l[l.length-1];if(T&&T.type==="element"&&T.tagName==="p"){let k=T.children[T.children.length-1];k&&k.type==="text"?k.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...m)}else l.push(...m);let F={type:"element",tagName:"li",properties:{id:t+"fn-"+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:{...Ri(s),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
85
85
|
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
86
|
-
`}]}}var
|
|
86
|
+
`}]}}var ic=(function(e){if(e==null)return B$;if(typeof e=="function")return sc(e);if(typeof e=="object")return Array.isArray(e)?P$(e):L$(e);if(typeof e=="string")return M$(e);throw new Error("Expected function, string, or object as test")});function P$(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ic(e[n]);return sc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function L$(e){let t=e;return sc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function M$(e){return sc(t);function t(n){return n&&n.type===e}}function sc(e){return t;function t(n,r,o){return!!(D$(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function B$(){return!0}function D$(e){return e!==null&&typeof e=="object"&&"type"in e}var gk=[],sm=!0,ac=!1,am="skip";function lm(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=ic(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,m,S,T;if((!t||i(u,c,l[l.length-1]||void 0))&&(d=R$(n(u,l)),d[0]===ac))return d;if("children"in u&&u.children){let F=u;if(F.children&&d[0]!==am)for(S=(r?F.children.length:-1)+s,T=l.concat(F);S>-1&&S<F.children.length;){let k=F.children[S];if(m=a(k,S,T)(),m[0]===ac)return m;S=typeof m[1]=="number"?m[1]:S+s}}return d}}}function R$(e){return Array.isArray(e)?e:typeof e=="number"?[sm,e]:e==null?gk:[e]}function ea(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),lm(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 cm={}.hasOwnProperty,z$={};function hk(e,t){let n=t||z$,r=new Map,o=new Map,i=new Map,s={...ak,...n.handlers},a={all:c,applyData:O$,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:N$,wrap:$$};return ea(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(cm.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,...T}=l,F=Ri(T);return F.children=a.all(l),F}return Ri(l)}return(a.options.unknownHandler||_$)(a,l,p)}function c(l){let p=[];if("children"in l){let f=l.children,d=-1;for(;++d<f.length;){let m=a.one(f[d],l);if(m){if(d&&f[d-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=mk(m.value)),!Array.isArray(m)&&m.type==="element")){let S=m.children[0];S&&S.type==="text"&&(S.value=mk(S.value))}Array.isArray(m)?p.push(...m):p.push(m)}}}return p}}function N$(e,t){e.position&&(t.position=Mg(e))}function O$(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,Ri(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function _$(e,t){let n=t.data||{},r="value"in t&&!(cm.call(n,"hProperties")||cm.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,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
|
|
87
87
|
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
88
88
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
89
|
-
`}),n}function
|
|
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},
|
|
89
|
+
`}),n}function mk(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function lc(e,t){let n=hk(e,t),r=n.one(e,void 0),o=fk(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 cc(e,t){return e&&"run"in e?async function(n,r){let o=lc(n,{file:r,...t});await e.run(o,r)}:function(n,r){return lc(n,{file:r,...e||t})}}function um(e){if(e)throw e}var dc=ga(Tk(),1);function ta(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 pm(){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?Ik(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 Ik(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 mr={basename:U$,dirname:j$,extname:H$,join:W$,sep:"/"};function U$(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');na(e);let n=0,r=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,a=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else s<0&&(i=!0,s=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(r=o):(a=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}function j$(e){if(na(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function H$(e){na(e);let t=e.length,n=-1,r=0,o=-1,i=0,s;for(;t--;){let a=e.codePointAt(t);if(a===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),a===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||n<0||i===0||i===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function W$(...e){let t=-1,n;for(;++t<e.length;)na(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":V$(n)}function V$(e){na(e);let t=e.codePointAt(0)===47,n=G$(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function G$(e,t){let n="",r=0,o=-1,i=0,s=-1,a,u;for(;++s<=e.length;){if(s<e.length)a=e.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(o===s-1||i===1))if(o!==s-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),o=s,i=0;continue}}else if(n.length>0){n="",r=0,o=s,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,s):n=e.slice(o+1,s),r=s-o-1;o=s,i=0}else a===46&&i>-1?i++:i=-1}return n}function na(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var Fk={cwd:q$};function q$(){return"/"}function zi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Ek(e){if(typeof e=="string")e=new URL(e);else if(!zi(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 Y$(e)}function Y$(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 dm=["history","path","basename","stem","extname","dirname"],Yo=class{constructor(t){let n;t?zi(t)?n={path:t}:typeof t=="string"||K$(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Fk.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<dm.length;){let i=dm[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)dm.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?mr.basename(this.path):void 0}set basename(t){gm(t,"basename"),fm(t,"basename"),this.path=mr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?mr.dirname(this.path):void 0}set dirname(t){Ak(this.basename,"dirname"),this.path=mr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?mr.extname(this.path):void 0}set extname(t){if(fm(t,"extname"),Ak(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=mr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){zi(t)&&(t=Ek(t)),gm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?mr.basename(this.path,this.extname):void 0}set stem(t){gm(t,"stem"),fm(t,"stem"),this.path=mr.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 Rt(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 fm(e,t){if(e&&e.includes(mr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mr.sep+"`")}function gm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ak(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function K$(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var Pk=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var X$={}.hasOwnProperty,ym=class e extends Pk{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=pm()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,dc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(xm("data",this.frozen),this.namespace[t]=n,this):X$.call(this.namespace,t)&&this.namespace[t]||void 0:t?(xm("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=pc(t),r=this.parser||this.Parser;return mm("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),mm("process",this.parser||this.Parser),hm("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=pc(t),u=r.parse(a);r.run(u,a,function(l,p,f){if(l||!p||!f)return c(l);let d=p,m=r.stringify(d,f);J$(m)?f.value=m:f.result=m,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(),mm("processSync",this.parser||this.Parser),hm("processSync",this.compiler||this.Compiler),this.process(t,o),Mk("processSync","process",n),r;function o(i,s){n=!0,um(i),r=s}}run(t,n,r){Lk(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=pc(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),Mk("runSync","run",r),o;function i(s,a){um(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=pc(n),o=this.compiler||this.Compiler;return hm("stringify",o),Lk(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(xm("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,dc.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,...m]=l,S=r[f][1];ta(S)&&ta(d)&&(d=(0,dc.default)(!0,S,d)),r[f]=[c,d,...m]}}}},bm=new ym().freeze();function mm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function hm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xm(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 Lk(e){if(!ta(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Mk(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function pc(e){return Q$(e)?e:new Yo(e)}function Q$(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function J$(e){return typeof e=="string"||Z$(e)}function Z$(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var rU="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Bk=[],Dk={allowDangerousHtml:!0},oU=/^(https?|ircs?|mailto|xmpp)$/i,iU=[{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 Sm(e){let t=sU(e),n=aU(e);return lU(t.runSync(t.parse(n),n),e)}function sU(e){let t=e.rehypePlugins||Bk,n=e.remarkPlugins||Bk,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Dk}:Dk;return bm().use(ec).use(n).use(cc,r).use(t)}function aU(e){let t=e.children||"",n=new Yo;return typeof t=="string"?n.value=t:(""+t,void 0),n}function lU(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||Rk;for(let l of iU)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+rU+l.id,void 0);return n&&i&&void 0,ea(e,c),Rg(e,{Fragment:eU,components:o,ignoreInvalidStyle:!0,jsx:tU,jsxs:nU,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 Gs)if(Object.hasOwn(Gs,d)&&Object.hasOwn(l.properties,d)){let m=l.properties[d],S=Gs[d];(S===null||S.includes(l.tagName))&&(l.properties[d]=u(String(m||""),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 Rk(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||oU.test(e.slice(0,t))?e:""}ke();var uU=Ni.div({display:"flex",flexDirection:"column",gap:"12px"}),pU=Ni.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),dU=Ni.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),fU=Ni(Hn)({padding:"6px 12px",fontSize:"12px"}),gU=Ni.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:Rl.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}})),mU=Ni.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),wm=()=>{let{fullPrompt:e}=se(),[t,n]=cU(!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?Ko.createElement(uU,null,Ko.createElement(pU,null,Ko.createElement(dU,null,"Full Prompt"),Ko.createElement(fU,{onClick:r,disabled:t},t?"\u2713 Copied!":"\u{1F4CB} Copy")),Ko.createElement(gU,null,Ko.createElement(Sm,null,e))):Ko.createElement(mU,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import Gr,{useRef as hU}from"react";import{styled as hr}from"storybook/theming";ke();var xU=hr.div({display:"flex",flexDirection:"column",gap:"8px"}),pae=hr.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"}}),yU=hr.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})),bU=hr.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})),dae=hr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),zk=hr.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||ae,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||ae,backgroundColor:e.background.warning||"#ffedd5"}})),SU=hr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),wU=hr.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"})),vU=hr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),kU=hr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),fae=hr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function CU(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 vm=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r}=se(),o=hU(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 Gr.createElement(SU,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 Gr.createElement(xU,null,a&&Gr.createElement(wU,null,Gr.createElement(vU,null,"Component Matches Design"),Gr.createElement(kU,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.")),Gr.createElement(yU,{ref:o},l.map((p,f)=>Gr.createElement(bU,{key:f,role:p.role},p.role==="system"?Gr.createElement(zk,null,p.content):Gr.createElement(zk,{dangerouslySetInnerHTML:{__html:CU(p.content)}})))))};import nr from"react";import{styled as vo}from"storybook/theming";ke();Me();var TU=vo.div({display:"flex",flexDirection:"column",gap:"12px"}),IU=vo.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),FU=vo.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}}}),Nk=vo.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"}}),EU=vo.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),Ok=vo.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||ae,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||ae,backgroundColor:e.background.warning||"#ffedd5"}})),_k=vo.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),AU=vo.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 $k(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 PU(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 Uk=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r}=se();nr.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?nr.createElement(_k,null,"No models selected. Select multiple models to compare results."):nr.createElement(TU,null,nr.createElement(IU,null,o.map(a=>{let u=Hr.find(m=>m.id===a),c=s[a],p=PU(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 nr.createElement(FU,{key:a,isActive:f,provider:u.provider,onClick:()=>n(a)},u.name,c&&p.issueCount>0&&nr.createElement(Nk,{variant:"issues",value:p.issueCount},p.issueCount," issues"),c&&p.score!==null&&nr.createElement(Nk,{variant:"score",value:p.score},"Score: ",p.score),d&&nr.createElement(AU,null))})),nr.createElement(EU,null,s[i]?.streamingMessages&&s[i].streamingMessages.length>0?s[i].streamingMessages.map((a,u)=>nr.createElement(Ok,{key:u,dangerouslySetInnerHTML:{__html:$k(a.content)}})):s[i]?.fullResponse?nr.createElement(Ok,{dangerouslySetInnerHTML:{__html:$k(s[i].fullResponse)}}):nr.createElement(_k,null,t?`Waiting for ${Hr.find(a=>a.id===i)?.name}...`:`No response yet for ${Hr.find(a=>a.id===i)?.name}`)))};import _e from"react";import{styled as wt}from"storybook/theming";ke();import V,{useMemo as f3,useState as g3,useEffect as m3}from"react";import{styled as Je,keyframes as h3}from"storybook/theming";import j,{useState as Cm,useRef as d4,useCallback as Zk,memo as f4}from"react";import{styled as me}from"storybook/theming";import qr,{useState as LU}from"react";import{styled as Yr}from"storybook/theming";var MU=Yr.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}),BU=Yr.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}`})),DU=Yr.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),RU=Yr.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),zU=Yr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),NU=Yr.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:ae,boxShadow:`0 0 0 3px ${e.base==="dark"?"rgba(124, 58, 237, 0.2)":"rgba(124, 58, 237, 0.1)"}`},"&::placeholder":{color:e.textMutedColor}})),OU=Yr.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),_U=Yr(_t)({}),$U=Yr(Wn)({}),jk=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=LU("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return qr.createElement(MU,{onClick:c=>{c.target===c.currentTarget&&a()}},qr.createElement(BU,null,qr.createElement(DU,null,"Dismiss as False Positive"),qr.createElement(RU,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),qr.createElement(zU,{htmlFor:"dismiss-reason"},"Reason (optional)"),qr.createElement(NU,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),qr.createElement(OU,null,qr.createElement($U,{onClick:a},"Cancel"),qr.createElement(_U,{onClick:s},"Dismiss Issue"))))};ke();import Te from"react";import{styled as Ke}from"storybook/theming";var Pe={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"},UU=Ke.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),jU=Ke.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),HU=Ke.div({position:"relative",backgroundColor:Pe.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Aae=Ke.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Pe.dash,padding:"0 8px",height:18,fontSize:11}),Pae=Ke.div({position:"absolute",color:Pe.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Lae=Ke.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%)"}})),Mae=Ke.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}})),WU=Ke.div(e=>({position:"relative",backgroundColor:e.isErr?Pe.errBg:Pe.borderBoxBg,border:`1px solid ${e.isErr?Pe.err:Pe.borderBoxStroke}`,borderRadius:6,padding:0})),VU=Ke.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Pe.text}),GU=Ke.span({fontWeight:500,fontSize:11}),Bae=Ke.span({color:Pe.dash}),qU=Ke.div(e=>({position:"relative",backgroundColor:e.isErr?Pe.errBg:Pe.paddingBg,border:`1px solid ${e.isErr?Pe.err:Pe.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),YU=Ke.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:Pe.text,fontStyle:"italic"}),fc=Ke.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?Pe.err:Pe.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%)"}})),KU=Ke.div(e=>({backgroundColor:e.isErr?Pe.errBg:"#fff",border:`1.5px dashed ${e.isErr?Pe.err:Pe.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?Pe.err:Pe.text,fontWeight:e.isErr?600:400})),XU=Ke.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Pe.dim,fontFamily:"monospace"}),QU=Ke.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Pe.ok,padding:"4px 8px 6px"}),Dae=Ke.div({fontSize:11,fontWeight:600,color:Pe.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),Rae=Ke.span({fontSize:12,color:Pe.dim}),JU=Ke.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),ZU=Ke.div({fontSize:9,color:Pe.dim,marginTop:2}),e4=({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}=se(),p=r||{},d=!(!!r&&Object.keys(r).length>0)&&s?l4(n):null,m=p.padding||d||{top:0,right:0,bottom:0,left:0},S=p.strokeWeight??(a?Oi(n)??0:0),T=p.width??(u?c4(n)??"\u2014":"\u2014"),F=p.height??(u?u4(n)??"\u2014":"\u2014");return Te.createElement(Te.Fragment,null,Te.createElement(HU,null,Te.createElement(WU,{isErr:a},Te.createElement(VU,null,Te.createElement(GU,null,"Border"),Te.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Pe.err:Pe.dim}},S)),Te.createElement(qU,{isErr:s},Te.createElement(YU,null,"Padding"),Te.createElement(fc,{side:"top",isErr:s},m.top),Te.createElement(fc,{side:"right",isErr:s},m.right),Te.createElement(fc,{side:"bottom",isErr:s},m.bottom),Te.createElement(fc,{side:"left",isErr:s},m.left),Te.createElement(KU,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Te.createElement(JU,{src:l,alt:"Figma element"}),Te.createElement(ZU,null,T," \xD7 ",F)))),Te.createElement(XU,null,"border-box")),Te.createElement(QU,null,"\u2192 ",n))},Hk=Ke.div({backgroundColor:Pe.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),t4=Ke.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),km=Ke.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:Pe.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),n4=Ke.div({position:"absolute",border:`1.5px dashed ${Pe.err}`,pointerEvents:"none",zIndex:0}),r4=Ke.div({position:"absolute",border:`1.5px dashed ${Pe.blue}`,pointerEvents:"none",zIndex:0}),Wk=Ke.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%)"}})),zae=Ke.div({fontSize:12,color:Pe.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),o4=Ke.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),Vk=Ke.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Pe.err:Pe.ok})),i4=Ke.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),Gk=Ke.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),qk=Ke.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Pe.err:Pe.ok})),Yk=Ke.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Pe.err:Pe.ok,textDecoration:e.variant==="err"?"line-through":"none"})),s4=Ke.span({fontSize:16,color:Pe.dim,paddingBottom:20}),Kk=Ke.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function Xk(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var a4=({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?Oi(n):14),d=o.fontWeight??(a?Oi(n):600),S=(o.lineHeight??(u?Oi(n):null))||Math.round((f||14)*1.43),T=`${Math.min(Math.max(f||14,24),48)}px`;if(p)return Te.createElement(Te.Fragment,null,Te.createElement(Hk,null,Te.createElement(t4,null,Te.createElement(r4,{style:{top:-6,left:0,right:0,bottom:-6}}),Te.createElement(n4,{style:{top:2,left:8,right:8,bottom:2}}),Te.createElement(Wk,{color:s?Pe.err:"#7b3030",side:"left"},s?t:`${f}px`),Te.createElement(Wk,{color:u?Pe.err:"#7b3030",side:"right"},u?t:`${S}px`),Te.createElement(km,{fSize:T,fWeight:String(d||600)},"Ag")),Te.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Te.createElement(Kk,{color:Pe.err},"\u2508\u2508 font-size",s?" \u2717":""),Te.createElement(Kk,{color:Pe.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Te.createElement(o4,null,Te.createElement(Vk,{variant:"err"},t),Te.createElement("span",{style:{color:Pe.dim}},"\u2192"),Te.createElement(Vk,{variant:"ok"},n))));let F=a?t:String(d||600),k=a?n:F,z=Oi(t),R=Oi(n);return Te.createElement(Te.Fragment,null,Te.createElement(Hk,null,Te.createElement(i4,null,Te.createElement(Gk,null,Te.createElement(qk,{variant:"err"},"Current"),Te.createElement(km,{fSize:T,fWeight:a?F:String(d||600),style:{color:Pe.err}},c?t:"Ag"),Te.createElement(Yk,{variant:"err"},a&&z?`${t} (${Xk(z)})`:t)),Te.createElement(s4,null,"\u2192"),Te.createElement(Gk,null,Te.createElement(qk,{variant:"ok"},"Figma"),Te.createElement(km,{fSize:T,fWeight:a?k:String(d||600),style:{color:Pe.ok}},c?n:"Ag"),Te.createElement(Yk,{variant:"ok"},a&&R?`${n} (${Xk(R)})`:n)))))};function l4(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 Oi(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function c4(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function u4(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var Qk=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function p4(e){if(Qk.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return Qk.has(t)}var Jk=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=p4(e.property);return Te.createElement(UU,null,Te.createElement(jU,null,"\u25BE Layer properties",t?"":" (from review)"),n?Te.createElement(a4,{...e}):Te.createElement(e4,{...e}))};ke();var eC=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 g4(e){if(eC.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return eC.has(t)}var m4=me.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"})),h4=me.div({display:"flex",alignItems:"flex-start",gap:"8px"}),x4=me.input(({theme:e})=>({marginTop:"1px",width:"14px",height:"14px",cursor:"pointer",accentColor:ae,flexShrink:0})),y4=me.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"}})),b4=me.div({flex:1,minWidth:0,paddingRight:"60px"}),S4=me.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.4"})),w4=me.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),v4=me.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:ae,border:ae};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"}}),k4=me.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:ae,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"}}}),C4=me.div(({theme:e})=>({fontSize:"10px",fontWeight:600,color:ae,backgroundColor:e.color.tertiary,padding:"2px 8px",borderRadius:"10px",border:`1px solid ${ae}`})),T4=me.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"}})),I4=me.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"}})),F4=me.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"}})),E4=me.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),A4=me.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"}})),Wae=me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),P4=me.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"})),Tm=me.div({display:"flex",gap:"8px",alignItems:"baseline"}),Im=me.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),Em=me.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),L4=me(Em)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),M4=me(Em)(({theme:e})=>({color:e.color.positive,fontWeight:600})),tC=me.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"})),B4=me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),D4=me.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)"})),R4=me.span({display:"flex",alignItems:"center"}),z4=me.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"}})),N4=me.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${ae}`})),O4=me.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:ae,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),_4=me.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"}})),$4=me.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),nC=me.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"})),U4=me.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),Fm=me(fn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),j4=me(Fm)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),H4=me.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}`})),W4=me.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}`})),rC=me.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"})),V4=me.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),G4=me.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),q4=me.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),Y4=me.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})),oC=me.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),iC=me.details({marginBottom:"8px"}),sC=me.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),K4=me.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"})),X4=me.div({display:"flex",gap:"8px",marginTop:"8px"}),Q4=me(Hn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),J4=me(Wn)({padding:"6px 12px",fontSize:"12px"}),Vae=me(_t)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),Gae=me.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),Z4=me.div({display:"flex",alignItems:"center",gap:"12px"}),e3=me.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),t3=me.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),qae=me.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}}})),n3=me.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"})),aC=me.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"})),lC=me.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}`})),cC=me.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),uC=me.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)"}}),pC=me.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),dC=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},r3=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},o3=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},i3=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,s3=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},a3=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",fC=({value:e,isStrikethrough:t=!1})=>{let n=s3(e),r=a3(e),o=t?L4:M4;return n?j.createElement(R4,null,j.createElement(D4,{color:n}),j.createElement(o,null,r)):j.createElement(o,null,r)},gC=f4(({issue:e,modelId:t,onToggleSelection:n,onDismiss:r,onUndismiss:o,onApplyFix:i,onRegenerateFix:s})=>{let{featureFlags:a,setHoveredIssueId:u}=se(),[c,l]=Cm(!1),[p,f]=Cm(!1),[d,m]=Cm(!1),S=d4(null),T=Zk(()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{u(e.id),m(!0)},100)},[e.id,u]),F=Zk(()=>{S.current&&clearTimeout(S.current),S.current=null,u(null),m(!1)},[u]),k=()=>{e.dismissed?o(e.id):l(!0)},z=E=>{r(e.id,E),l(!1)},R=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
92
|
Suggested code:
|
|
93
93
|
\`\`\`
|
|
94
94
|
${e.suggestedCode}
|
|
95
95
|
\`\`\``),e.generatedFix){let g=e.generatedFix;if(E.push(`
|
|
96
|
-
--- AI-Generated Fix ---`),E.push(`Status: ${g.status}`),g.confidence!==void 0){let
|
|
96
|
+
--- AI-Generated Fix ---`),E.push(`Status: ${g.status}`),g.confidence!==void 0){let w=g.confidence>1?g.confidence:Math.round(g.confidence*100);E.push(`Confidence: ${w}%`)}g.strategy&&E.push(`Strategy: ${g.strategy}`),g.filePath&&E.push(`Target file: ${g.filePath}`),g.code&&E.push(`
|
|
97
97
|
Generated code:
|
|
98
98
|
\`\`\`
|
|
99
99
|
${g.code}
|
|
@@ -101,11 +101,11 @@ ${g.code}
|
|
|
101
101
|
Diff:
|
|
102
102
|
\`\`\`diff
|
|
103
103
|
${g.diffPreview}
|
|
104
|
-
\`\`\``),g.error&&E.push(`Error: ${g.error}`)}let
|
|
105
|
-
`);try{await navigator.clipboard.writeText(
|
|
104
|
+
\`\`\``),g.error&&E.push(`Error: ${g.error}`)}let D=E.filter(Boolean).join(`
|
|
105
|
+
`);try{await navigator.clipboard.writeText(D),f(!0),setTimeout(()=>f(!1),2e3)}catch(g){console.error("Failed to copy:",g)}},O=e.generatedFix?.status==="applied";return j.createElement(j.Fragment,null,j.createElement(m4,{dismissed:!!e.dismissed,fixApplied:O,onMouseEnter:T,onMouseLeave:F},j.createElement(U4,null,j.createElement(Fm,{onClick:R,title:"Copy issue details"},p?j.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},j.createElement("polyline",{points:"20 6 9 17 4 12"})):j.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},j.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),j.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))),e.dismissed?j.createElement(Fm,{onClick:k,title:"Restore issue"},j.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},j.createElement("polyline",{points:"1 4 1 10 7 10"}),j.createElement("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"}))):j.createElement(j4,{onClick:k,title:"Dismiss issue"},j.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},j.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),j.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),j.createElement(h4,null,j.createElement(x4,{type:"checkbox",checked:e.selectedForFix,onChange:()=>n(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),j.createElement(y4,{severity:e.severity},e.severity==="critical"?j.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},j.createElement("circle",{cx:"12",cy:"12",r:"10"}),j.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),j.createElement("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})):e.severity==="major"?j.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},j.createElement("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),j.createElement("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),j.createElement("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})):j.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},j.createElement("circle",{cx:"12",cy:"12",r:"10"}),j.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),j.createElement("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"}))),j.createElement(b4,null,j.createElement(S4,null,e.title),j.createElement(w4,null,j.createElement(v4,{severity:e.severity},e.severity),j.createElement(k4,{status:e.status},e.status),j.createElement(C4,null,e.type),a.enableModelSelection&&j.createElement(T4,null,i3(t)),(()=>{let E=o3(e.detectedBy);return E.ai||E.programmatic?j.createElement(E4,null,E.ai&&j.createElement(F4,null,E.ai),E.programmatic&&j.createElement(I4,null,"Pre-filter: ",E.programmatic)):null})(),e._unreliable&&j.createElement(A4,{title:e._validationError?.message},"Unreliable"),e.dismissed&&j.createElement(H4,null,"Dismissed")))),e.property&&j.createElement(P4,null,j.createElement(Tm,null,j.createElement(Im,null,"Property"),j.createElement(Em,{style:{fontWeight:600}},e.property)),e.currentValue&&j.createElement(Tm,null,j.createElement(Im,null,"Current"),j.createElement(fC,{value:e.currentValue,isStrikethrough:!0})),e.suggestedValue&&j.createElement(Tm,null,j.createElement(Im,null,"Expected"),j.createElement(fC,{value:e.suggestedValue,isStrikethrough:!1}))),d&&e.property&&e.currentValue&&e.suggestedValue&&g4(e.property)&&j.createElement(Jk,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&j.createElement(z4,null,j.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&j.createElement(N4,null,j.createElement(O4,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((E,D)=>j.createElement(_4,{key:`${E.property}-${D}`},j.createElement($4,null,E.property),j.createElement(nC,{type:"current"},E.currentValue),j.createElement(nC,{type:"suggested"},E.suggestedValue)))),e.suggestedCode&&j.createElement(j.Fragment,null,(e.suggestedCode.includes("<svg")||e.suggestedCode.includes("<svg"))&&j.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("<svg")&&(E=E.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"')),E.split(/(?=<svg[\s>])/gi).filter(D=>D.trim().match(/^<svg/i)).map(D=>{let g=D.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("<svg")))return j.createElement(tC,null,E);let g=E.replace(/<svg[\s\S]*?<\/svg>/gi,"").replace(/SVG \d+:/g,"").trim();return g?j.createElement(tC,null,g):null})()),(e.generatedFix?.filePath||e.file)&&j.createElement(B4,null,e.generatedFix?.filePath||e.file,!e.generatedFix?.filePath&&e.lineNumber!==void 0&&`:${e.lineNumber}`),e.dismissed&&j.createElement(W4,null,j.createElement("strong",null,"Filtered by:")," ",r3(e.dismissedBy),e.dismissReason&&j.createElement(j.Fragment,null,j.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&j.createElement(rC,null,j.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&j.createElement(V4,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?j.createElement(Z4,{style:{margin:0}},j.createElement(e3,null),j.createElement(t3,{style:{margin:0}},"Generating fix...")):j.createElement(j.Fragment,null,j.createElement(G4,null,j.createElement(q4,null,"AI-Generated Fix"),j.createElement(Y4,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&j.createElement(oC,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&j.createElement(oC,{style:{color:"#6b7280",fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?j.createElement(iC,null,j.createElement(sC,null,"View Diff"),j.createElement(n3,null,j.createElement(aC,{side:"old"},j.createElement(lC,{side:"old"},"Old"),j.createElement(cC,null,dC(e.generatedFix.diffPreview).map((E,D)=>j.createElement(uC,{key:`old-${D}`,type:E.oldLine.type},E.oldLine.content||"\xA0")))),j.createElement(aC,{side:"new"},j.createElement(lC,{side:"new"},"New"),j.createElement(cC,null,dC(e.generatedFix.diffPreview).map((E,D)=>j.createElement(uC,{key:`new-${D}`,type:E.newLine.type},E.newLine.content||"\xA0")))))):e.generatedFix.code&&j.createElement(iC,null,j.createElement(sC,null,"View Generated Code"),j.createElement(K4,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&j.createElement(rC,null,j.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&a.enableFixApply&&i&&j.createElement(X4,null,j.createElement(Q4,{onClick:()=>i(e.id)},"Apply Fix"),s&&j.createElement(J4,{onClick:()=>s(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&j.createElement(pC,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&j.createElement(pC,{status:"applied"},"\u2713 Fix applied successfully")))),j.createElement(jk,{isOpen:c,issueTitle:e.title,onConfirm:z,onCancel:()=>l(!1)}))});import Am from"react";import{styled as Pm,keyframes as l3}from"storybook/theming";var c3=l3`
|
|
106
106
|
0% { transform: rotate(0deg); }
|
|
107
107
|
100% { transform: rotate(360deg); }
|
|
108
|
-
`,
|
|
108
|
+
`,u3=Pm.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),p3=Pm.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${c3} 0.8s linear infinite`})),d3=Pm.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),gc=({label:e="Loading..."})=>Am.createElement(u3,null,Am.createElement(p3,null),Am.createElement(d3,null,e));ke();var x3=Je.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}})),y3=Je.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:ae})),b3=Je.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),S3=Je.div({display:"flex",gap:"8px"}),mC=Je(wn)({flex:1}),w3=Je.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}})),v3=Je.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),k3=Je.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"}})),C3=Je.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",padding:"12px",display:"flex",flexDirection:"column",gap:"8px"})),T3=Je.div({display:"flex",alignItems:"center",gap:"2px"}),mc=Je(fn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Lm=Je.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),I3=Je.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),sle=Je.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),ko=Je.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:ae};case"selected":return{bg:e.color.tertiary,text:ae};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:ae};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"}}),F3=Je.div({display:"flex",flexDirection:"column",gap:"8px"}),hC=Je.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),xC=Je.div({fontSize:"36px",marginBottom:"12px"}),yC=Je.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),bC=Je.div({fontSize:"12px"}),E3=h3`
|
|
109
109
|
0% {
|
|
110
110
|
transform: translateY(0) rotate(0deg) scale(1);
|
|
111
111
|
opacity: 1;
|
|
@@ -117,31 +117,31 @@ ${g.diffPreview}
|
|
|
117
117
|
transform: translateY(120px) rotate(720deg) scale(0.3);
|
|
118
118
|
opacity: 0;
|
|
119
119
|
}
|
|
120
|
-
`;var
|
|
120
|
+
`;var ale=Je.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),lle=Je.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:`${E3} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var A3=Je.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}}})),P3=Je(fn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),SC=Je.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),wC=Je(Hn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),vC=Je(_t)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),kC=Je(_t)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),L3=Je.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}}),M3=Je.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),B3=Je.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}}),D3=Je.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),R3=Je.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),hc=Je.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),xc=Je.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),z3=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},CC=({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:m,onApplyFix:S,onCopyAllFixes:T,onGenerateFixes:F,onDismiss:k,onUndismiss:z,isGenerating:R=!1,isApplying:O=!1,isCopying:E=!1,applyFixesResult:D,onDismissResult:g,generationTiming:w,generationUsage:v,generationProgress:A,autoApplySupported:h=!0,hasReviewBeenRun:C=!1,isLoadingReview:I=!1,selfReview:y})=>{let[P,L]=V.useState("all"),[B,N]=V.useState("all"),[x,U]=V.useState(!1),[H,M]=V.useState(!0),{includeComponentIssues:Q,setIncludeComponentIssues:ee,featureFlags:J}=se(),Le=V.useRef(null),[Ee,We]=g3(0);m3(()=>{if(!R){We(0);return}let fe=setInterval(()=>We(kt=>kt+1),1e3);return()=>clearInterval(fe)},[R]);let st=async()=>{let fe=te.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 et=Z.confidence>1?Z.confidence:Math.round(Z.confidence*100);W.push(`Confidence: ${et}%`)}Z.strategy&&W.push(`Strategy: ${Z.strategy}`),Z.filePath&&W.push(`Target file: ${Z.filePath}`),Z.code&&W.push(`Generated code:
|
|
121
121
|
${Z.code}`),Z.diffPreview&&W.push(`Diff:
|
|
122
122
|
${Z.diffPreview}`),Z.error&&W.push(`Error: ${Z.error}`)}return W.push(""),W.filter(Boolean).join(`
|
|
123
123
|
`)}).join(`
|
|
124
124
|
---
|
|
125
125
|
|
|
126
|
-
`),
|
|
126
|
+
`),kt=te.filter($=>$.generatedFix?.status==="applied").length,yr=te.filter($=>$.generatedFix?.status==="ready").length,pe=kt>0||yr>0?` | Fixes: ${kt} applied, ${yr} ready`:"",Xe=r!==void 0?` | Similarity: ${r}%`:"",_=`Score: ${n}/100${Xe} | ${te.length} issues${pe}
|
|
127
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",`
|
|
128
|
+
`;try{await navigator.clipboard.writeText(_+fe),U(!0),setTimeout(()=>U(!1),2e3)}catch($){console.error("Failed to copy:",$)}};V.useEffect(()=>{D&&Le.current&&Le.current.scrollIntoView({behavior:"smooth",block:"start"})},[D]);let te=f3(()=>e.filter(fe=>{let kt=P==="all"||fe.severity===P,yr=B==="all"||fe.status===B,pe=Q||!z3(fe);return kt&&yr&&pe}),[e,P,B,Q]),Y=()=>{te.forEach(fe=>{fe.selectedForFix||l(fe.id)})},ce=()=>{te.forEach(fe=>{fe.selectedForFix&&l(fe.id)})},ie=()=>{te.forEach(fe=>{fe.generatedFix&&fe.generatedFix.status==="ready"&&!fe.selectedForFix&&l(fe.id)})},ue=te.filter(fe=>fe.selectedForFix).length,ct=te.filter(fe=>fe.severity==="critical").length,Ge=te.filter(fe=>fe.severity==="major").length,xt=te.filter(fe=>fe.severity==="minor").length,yn=te.filter(fe=>fe.generatedFix&&fe.generatedFix.status==="ready").length,qe=te.filter(fe=>fe.selectedForFix&&fe.generatedFix&&fe.generatedFix.status==="ready").length;return e.length===0?I?V.createElement(gc,{label:"Loading review..."}):V.createElement(hC,null,V.createElement(xC,null,C?"\u2728":"\u{1F441}\uFE0F"),V.createElement(yC,null,C?"No issues found":"No review yet"),V.createElement(bC,null,C?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):V.createElement(b3,{"data-testid":"issues-panel"},V.createElement(S3,null,V.createElement(mC,{value:P,onChange:fe=>L(fe.target.value)},V.createElement("option",{value:"all"},"All Severities"),V.createElement("option",{value:"critical"},"Critical Only"),V.createElement("option",{value:"major"},"Major Only"),V.createElement("option",{value:"minor"},"Minor Only")),V.createElement(mC,{value:B,onChange:fe=>N(fe.target.value)},V.createElement("option",{value:"all"},"All Statuses"),V.createElement("option",{value:"pending"},"Pending"),V.createElement("option",{value:"applied"},"Applied"),V.createElement("option",{value:"verified"},"Verified"),V.createElement("option",{value:"failed"},"Failed"))),V.createElement("div",null,V.createElement(w3,{isOpen:H,onClick:()=>M(!H)},V.createElement(v3,null,V.createElement(k3,{isOpen:H},V.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},V.createElement("polyline",{points:"6 9 12 15 18 9"}))),V.createElement(I3,null,te.length," issues"),V.createElement(x3,{onClick:fe=>fe.stopPropagation()},V.createElement(y3,{type:"checkbox",checked:Q,onChange:fe=>ee(fe.target.checked)}),"+ TSX"),V.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},ct>0&&V.createElement(Lm,{variant:"critical"},ct," critical"),Ge>0&&V.createElement(Lm,{variant:"major"},Ge," major"),xt>0&&V.createElement(Lm,{variant:"minor"},xt," minor"))),V.createElement(T3,{onClick:fe=>fe.stopPropagation()},V.createElement(mc,{onClick:Y},"All"),V.createElement(mc,{onClick:ce},"None"),V.createElement(mc,{onClick:st},x?"\u2713":"\u2398"," Copy"),yn>0&&V.createElement(mc,{onClick:ie},"Fixes (",yn,")"))),D&&V.createElement(A3,{ref:Le,variant:D.error||D.failed>0?"warning":"success"},D.error?V.createElement(V.Fragment,null,D.error):D.failed>0?V.createElement(V.Fragment,null,"Applied ",D.succeeded,"/",D.total," fixes. ",D.failed," failed. Run a new review to verify."):V.createElement(V.Fragment,null,"Applied ",D.total," fix",D.total!==1?"es":"","! Run a new review to verify changes."),g&&V.createElement(P3,{onClick:g},"\u2715")),ue>0&&V.createElement(SC,null,w&&V.createElement(ko,{variant:"timing"},w.durationSec,"s (",w.issueCount," fixes)"),v&&V.createElement(V.Fragment,null,V.createElement(ko,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),V.createElement(ko,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"# ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),V.createElement(ko,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),J.enableFixGeneration&&F&&V.createElement(kC,{disabled:R||O||E,onClick:F},V.createElement("span",null,"\u{1F916}"),R&&A?`Generating ${A.completed}/${A.total}... (${Ee}s)`:R?`Generating... (${Ee}s)`:`Generate Fixes for ${ue} Issue${ue>1?"s":""}`),J.enableFixApply&&h&&m&&V.createElement(wC,{disabled:R||O||qe===0,onClick:m},O?"Applying...":R?"Generating...":qe>0?`Apply ${qe} Ready Fix${qe>1?"es":""}`:"Apply Fixes (generate first)"),J.enableFixApply&&!h&&T&&V.createElement(vC,{disabled:R||E||qe===0,copied:E,onClick:T},E?"Copied!":qe>0?`Copy ${qe} Fix${qe>1?"es":""}`:"Copy Fixes (generate first)")),y&&!R&&V.createElement(L3,{confidence:y.overallConfidence},V.createElement(M3,null,V.createElement(D3,null,"AI Self-Review"),V.createElement(B3,{confidence:y.overallConfidence},y.wouldReachPerfect?"\u2713":"\u25B3"," ",y.overallConfidence,"% confidence")),V.createElement(R3,null,y.variantSafety&&V.createElement(hc,null,V.createElement(xc,null,"Variant safety: "),y.variantSafety),y.gaps.length>0&&V.createElement(hc,null,V.createElement(xc,null,"Gaps: "),V.createElement("ul",null,y.gaps.map((fe,kt)=>V.createElement("li",{key:kt},fe)))),!y.wouldReachPerfect&&y.reasonsNotPerfect.length>0&&V.createElement(hc,null,V.createElement(xc,null,"Why not 100%: "),V.createElement("ul",null,y.reasonsNotPerfect.map((fe,kt)=>V.createElement("li",{key:kt},fe)))),y.suggestions&&y.suggestions.length>0&&V.createElement(hc,null,V.createElement(xc,null,"Suggestions: "),V.createElement("ul",null,y.suggestions.map((fe,kt)=>V.createElement("li",{key:kt},fe)))))),H&&V.createElement(C3,null,te.length===0?V.createElement(hC,null,V.createElement(xC,null,"\u{1F50D}"),V.createElement(yC,null,"No issues match current filters"),V.createElement(bC,null,"Try adjusting your severity or status filters")):V.createElement(F3,null,te.map(fe=>V.createElement(gC,{key:fe.id,issue:fe,modelId:t,onToggleSelection:l,onDismiss:k,onUndismiss:z,onApplyFix:S}))))),ue>0&&V.createElement(SC,null,w&&V.createElement(ko,{variant:"timing"},w.durationSec,"s (",w.issueCount," fixes)"),v&&V.createElement(V.Fragment,null,V.createElement(ko,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),V.createElement(ko,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"# ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),V.createElement(ko,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),J.enableFixGeneration&&F&&V.createElement(kC,{disabled:R||O||E,onClick:F},V.createElement("span",null,"\u{1F916}"),R&&A?`Generating ${A.completed}/${A.total}... (${Ee}s)`:R?`Generating... (${Ee}s)`:`Generate Fixes for ${ue} Issue${ue>1?"s":""}`),J.enableFixApply&&h&&m&&V.createElement(wC,{disabled:R||O||qe===0,onClick:m},O?"Applying...":R?"Generating...":qe>0?`Apply ${qe} Ready Fix${qe>1?"es":""}`:"Apply Fixes (generate first)"),J.enableFixApply&&!h&&T&&V.createElement(vC,{disabled:R||E||qe===0,copied:E,onClick:T},E?"Copied!":qe>0?`Copy ${qe} Fix${qe>1?"es":""}`:"Copy Fixes (generate first)")))};Me();var N3=wt.div({display:"flex",flexDirection:"column"}),O3=wt.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),_3=wt.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),Mm=wt.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:ae}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),$3=wt.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),xle=wt.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),yle=wt.div({fontSize:"48px",marginBottom:"16px"}),ble=wt.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),Sle=wt.div({fontSize:"14px",opacity:.8}),U3=wt.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),j3=wt.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),H3=wt(fn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),W3=wt(Wn)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),V3=wt.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),G3=wt.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),q3=wt.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),Y3=wt.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),K3=wt.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),X3=wt.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}})),Q3=wt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),J3=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"},TC=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},Z3=wt.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"}}),e6=wt.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"}})),Dm=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"},t6=(e,t)=>{switch(e||Dm(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},IC=(e,t)=>{switch(e||Dm(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";case"user":return"Manual";default:return"Auto"}},n6=wt.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),r6=wt.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),o6=wt.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"})),i6=wt(oh)({marginTop:"12px"}),Bm=class extends _e.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?_e.createElement(n6,null,_e.createElement(r6,null,"\u26A0\uFE0F Issues Panel Error"),_e.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),_e.createElement(o6,null,this.state.error?.message||"Unknown error",`
|
|
129
129
|
|
|
130
|
-
`,this.state.error?.stack),
|
|
130
|
+
`,this.state.error?.stack),_e.createElement(i6,{onClick:this.handleReset},"Try Again")):this.props.children}},FC=()=>{let{currentStoryId:e}=Ye(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,dismissIssue:i,undismissIssue:s,applyFixesResult:a,setApplyFixesResult:u}=se(),c=r.some(pe=>pe.storyId===e||pe.componentId===e),{loadingMapping:l}=Ye(),p=!!e&&!t&&!n&&(l||!c),[f,d]=_e.useState(!1),[m,S]=_e.useState(!1),[T,F]=_e.useState(!1),{isSupported:k,isDetecting:z}=vf(),{refreshStorybookOnly:R}=Eo(),{generateBatchFixes:O,isGenerating:E,error:D,timing:g,progress:w,usage:v,selfReview:A,lastStorybookRoot:h}=yf(),{applyFixes:C,isApplying:I}=xf({onComplete:R,storybookRoot:h}),y=r.find(pe=>pe.id===t),P=y?.issues||[],L=_e.useMemo(()=>P.filter(pe=>!pe.dismissed),[P]),B=_e.useMemo(()=>P.filter(pe=>pe.dismissed),[P]),N=_e.useMemo(()=>{let pe={postAiValidation:0,aiValidation:0,user:0};for(let Xe of B)switch(Xe.dismissedBy){case"post-ai-validation":pe.postAiValidation++;break;case"ai-validation":pe.aiValidation++;break;default:pe.user++;break}return pe},[B]),x=L,U=y?.modelId||"unknown",H=L.filter(pe=>pe.severity==="critical").length,M=L.filter(pe=>pe.severity==="major").length,Q=L.filter(pe=>pe.severity==="minor").length,ee=y?L.length===0?100:Math.max(0,Math.min(100,100-H*25-M*5-Q*1)):void 0,J=y?.visualSimilarity,Le=y?.costUsd,Ee=y?.reviewDurationMs,We=y?.inputTokens,st=y?.outputTokens,te=y?.cacheCreationTokens,Y=y?.cacheReadTokens,ce=y?.parentReviewId?r.find(pe=>pe.id===y.parentReviewId):null,ie=_e.useMemo(()=>{if(!ce||!y)return null;let pe=new Set(ce.issues.map(Z=>`${Z.type}:${Z.property||""}:${Z.description}`)),Xe=new Set(x.map(Z=>`${Z.type}:${Z.property||""}:${Z.description}`)),_=ce.issues.filter(Z=>!Xe.has(`${Z.type}:${Z.property||""}:${Z.description}`)).length,$=x.filter(Z=>pe.has(`${Z.type}:${Z.property||""}:${Z.description}`)).length,W=x.filter(Z=>!pe.has(`${Z.type}:${Z.property||""}:${Z.description}`)).length;return{resolved:_,remaining:$,newIssues:W}},[ce,y,x]),ue=()=>{x.forEach(pe=>{pe.selectedForFix||o(pe.id)})},ct=()=>{x.forEach(pe=>{pe.selectedForFix&&o(pe.id)})},Ge=()=>{x.forEach(pe=>{pe.generatedFix&&pe.generatedFix.status==="ready"&&!pe.selectedForFix&&o(pe.id)})},{featureFlags:xt}=se(),yn=()=>{if(!xt.enableFixGeneration){b.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let pe=x.filter(Xe=>Xe.selectedForFix);if(pe.length===0){b.warn("[IssuesPanel] No issues selected for fix generation");return}b.debug(`[IssuesPanel] Generating fixes for ${pe.length} issue(s)`,pe),O(pe)},qe=()=>{if(!xt.enableFixApply){b.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let pe=x.filter(_=>_.selectedForFix&&_.generatedFix&&_.generatedFix.status==="ready"&&_.generatedFix.code&&_.generatedFix.filePath);if(pe.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Xe=pe.map(_=>({id:_.id,reviewId:_.reviewId,type:_.type,severity:_.severity,title:_.title,description:_.description,generatedFix:_.generatedFix,storyId:y?.storyId||""}));b.debug(`[IssuesPanel] Applying AI-generated fixes for ${Xe.length} issue(s)`,Xe),C(Xe)},fe=pe=>{let Xe=x.find($=>$.id===pe);if(!Xe){b.warn("[IssuesPanel] Issue not found:",pe);return}if(!Xe.generatedFix||Xe.generatedFix.status!=="ready"||!Xe.generatedFix.code||!Xe.generatedFix.filePath){b.warn("[IssuesPanel] Issue does not have a ready AI-generated fix:",pe);return}let _={id:Xe.id,reviewId:Xe.reviewId,type:Xe.type,severity:Xe.severity,title:Xe.title,description:Xe.description,generatedFix:Xe.generatedFix,storyId:y?.storyId||""};b.debug("[IssuesPanel] Applying single AI-generated fix for issue:",_),C([_])},kt=async()=>{let pe=x.filter(_=>_.selectedForFix&&_.generatedFix&&_.generatedFix.status==="ready"&&_.generatedFix.code&&_.generatedFix.filePath);if(pe.length===0){b.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let Xe=pe.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
131
|
`).forEach(Z=>{W.push(`// ${Z}`)})),W.push("//"),W.push("// Full Fixed Code:"),W.push($.code),W.join(`
|
|
132
132
|
`)}).join(`
|
|
133
133
|
|
|
134
134
|
`+"=".repeat(60)+`
|
|
135
135
|
|
|
136
|
-
`);S(!0);try{await
|
|
136
|
+
`);S(!0);try{await kf(Xe)?b.debug(`[IssuesPanel] Copied ${pe.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)}},yr=async pe=>{pe.stopPropagation();let Xe=B.map($=>[`[${$.severity.toUpperCase()}] ${$.title||$.description}`,`Phase: ${IC($.dismissedBy,$.dismissReason)}`,$.dismissReason?`Reason: ${TC($.dismissReason)}`:"",$.property?`Property: ${$.property}`:"",$.currentValue?`Current: ${$.currentValue}`:"",$.suggestedValue?`Expected: ${$.suggestedValue}`:""].filter(Boolean).join(`
|
|
137
137
|
`)).join(`
|
|
138
138
|
|
|
139
139
|
---
|
|
140
140
|
|
|
141
|
-
`),_=`Filtered Issues (${
|
|
141
|
+
`),_=`Filtered Issues (${B.length})
|
|
142
142
|
${"=".repeat(40)}
|
|
143
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`
|
|
144
|
+
`;try{await navigator.clipboard.writeText(_+Xe),F(!0),setTimeout(()=>F(!1),2e3)}catch($){b.error("Failed to copy dismissed issues:",$)}};return _e.createElement(N3,null,ie&&_e.createElement(O3,null,_e.createElement(_3,null,"\u{1F4CA} Progress:"),_e.createElement(Mm,{variant:"resolved"},"\u2705 ",ie.resolved," resolved"),_e.createElement(Mm,{variant:"remaining"},"\u23F3 ",ie.remaining," remaining"),ie.newIssues>0&&_e.createElement(Mm,{variant:"new"},"\u{1F195} ",ie.newIssues," new"),_e.createElement($3,null,"Iteration ",y?.iterationNumber||1)),_e.createElement(Bm,null,_e.createElement(CC,{issues:x,modelId:U,complianceScore:ee,visualSimilarity:J,costUsd:Le,reviewDurationMs:Ee,inputTokens:We,outputTokens:st,cacheCreationTokens:te,cacheReadTokens:Y,onToggleSelection:o,onSelectAll:ue,onSelectNone:ct,onSelectAllFixes:Ge,onGenerateFixes:yn,onApplyFixes:qe,onApplyFix:fe,onCopyAllFixes:kt,onDismiss:i,onUndismiss:s,isGenerating:E,isApplying:I,isCopying:m,applyFixesResult:a,onDismissResult:()=>u(null),generationTiming:g,generationUsage:v,hasReviewBeenRun:!!y,isLoadingReview:p,generationProgress:w,autoApplySupported:k,selfReview:A})),B.length>0&&_e.createElement(U3,null,_e.createElement(j3,null,_e.createElement(H3,{onClick:()=>d(!f)},_e.createElement("span",null,f?"\u25BC":"\u25B6"),_e.createElement("span",null,"Filtered out"),_e.createElement(V3,null,B.length),_e.createElement(e6,null,N.postAiValidation>0&&_e.createElement("span",null,"\u2699\uFE0F ",N.postAiValidation),N.aiValidation>0&&_e.createElement("span",null,"\u2726 ",N.aiValidation),N.user>0&&_e.createElement("span",null,"\u{1F464} ",N.user))),_e.createElement(W3,{onClick:yr},T?"\u2713 Copied!":"Copy")),f&&_e.createElement(G3,null,(()=>{let pe=B.reduce(($,W)=>{let Z=J3(W.dismissReason);return $[Z]||($[Z]=[]),$[Z].push(W),$},{}),Xe=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(pe).sort(($,W)=>Xe.indexOf($)-Xe.indexOf(W)).map($=>_e.createElement(_e.Fragment,{key:$},_e.createElement(X3,null,$,_e.createElement(Q3,null,pe[$].length)),pe[$].map(W=>_e.createElement(q3,{key:W.id},_e.createElement(Z3,{phase:W.dismissedBy||Dm(W.dismissReason)||"post-ai-validation"},t6(W.dismissedBy,W.dismissReason)," ",IC(W.dismissedBy,W.dismissReason)),_e.createElement(Y3,null,"[",W.severity.toUpperCase(),"] ",W.title||W.description),W.dismissReason&&_e.createElement(K3,null,TC(W.dismissReason))))))})())))};var s6=ra.div({marginTop:"20px"}),a6=ra.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),l6=ra.div({display:"flex",alignItems:"center"}),Rm=ra(Xr)({padding:"10px 16px"}),c6=ra.div({minHeight:"200px"}),zm=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r}=se(),o=r.length>1||n&&Object.keys(n.byModel).length>1;return xr.createElement(s6,null,xr.createElement(a6,null,xr.createElement(l6,null,xr.createElement(Rm,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),xr.createElement(Rm,{active:e==="chat",onClick:()=>t("chat")},o?"Models":"Chat"),xr.createElement(Rm,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),xr.createElement(c6,null,e==="chat"&&(o?xr.createElement(Uk,null):xr.createElement(vm,null)),e==="issues"&&xr.createElement(FC,null),e==="prompt"&&xr.createElement(wm,null)))};ke();Re();import re,{useState as _i,useRef as _m,useEffect as f6,useMemo as g6}from"react";import{styled as ht}from"storybook/theming";Me();var yc={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},oa="uicopilot_feature_flags";function Nm(){try{let e=localStorage.getItem(oa);if(e){let t=JSON.parse(e);return{...yc,...t}}}catch(e){b.warn("[FeatureFlags] Failed to load from localStorage:",e)}return yc}function u6(e,t){try{let r={...Nm(),[e]:t},o={};for(let i in r){let s=i;r[s]!==yc[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(oa,JSON.stringify(o)):localStorage.removeItem(oa),b.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){b.error("[FeatureFlags] Failed to set flag:",n)}}function p6(){try{localStorage.removeItem(oa),b.debug("[FeatureFlags] Reset to defaults")}catch(e){b.error("[FeatureFlags] Failed to reset:",e)}}function Om(e){return Nm()[e]}function d6(){let e=Object.keys(yc).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(oa,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:Nm,set:u6,reset:p6,enableAll:d6,isEnabled:Om}});Me();nt();var ia=ht.div({marginTop:"20px"}),$m=ht.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Um=ht.div({display:"flex",alignItems:"center",gap:"12px"}),sa=ht.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),m6=ht.div({display:"flex",gap:"8px"}),EC=ht.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=ht.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})),jm=ht.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"})),Hm=ht.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})),h6=ht.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"}})),x6=ht.img(({opacity:e=1})=>({maxWidth:"100%",maxHeight:"120px",height:"auto",display:"block",objectFit:"contain",opacity:e})),y6=ht.img({display:"block",objectFit:"contain",maxHeight:"120px",maxWidth:"100%"}),b6=ht.div({position:"relative",display:"inline-block"}),$le=ht.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"}})),S6=ht.div({position:"relative",display:"inline-block"}),Ule=ht.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})),w6=ht.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),v6=ht.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),k6=ht.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),C6=ht.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),T6=ht.input({flex:1}),Wm=ht.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),jle=ht.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),PC=ht.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),$i=ht.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%"}}})),Ui=ht.div({textAlign:"center",zIndex:1}),ji=ht.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)"}}})),Hi=ht.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),Vm=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let{currentMapping:r,loadingMapping:o}=Ye(),{figmaImageUrl:i,storybookImageUrl:s,figmaDimensions:a,setFigmaImageUrl:u,hoveredIssueId:c,reviewHistory:l,currentReviewId:p}=se(),{selectedProjectId:f}=Qe(),{sessionToken:d}=Ie(),m=Om("enableHoverHighlight"),[S,T]=_i("side-by-side"),[F,k]=_i(.5),[z,R]=_i(!1),[O,E]=_i(!1);f6(()=>{E(!1)},[i]);let[D,g]=_i(null),[w,v]=_i(null),A=_m(null),h=_m(null),C=_m(null),I=g6(()=>{if(!m||!c||!p)return null;let B=l.find(N=>N.id===p);return B?.issues&&B.issues.find(N=>N.id===c)||null},[c,p,l]),y=B=>{let N=B.currentTarget;E(!0),!at.getState().figmaDimensions&&N.naturalWidth&&N.naturalHeight&&at.getState().setFigmaDimensions({width:N.naturalWidth,height:N.naturalHeight}),requestAnimationFrame(()=>{if(h.current){let{clientWidth:U,clientHeight:H}=h.current;U&&H&&v({width:U,height:H})}})},P=()=>{requestAnimationFrame(()=>{if(A.current){let{clientWidth:B,clientHeight:N}=A.current;B&&N&&g({width:B,height:N})}})},L=async()=>{if(!(!f||!d)){R(!0);try{let B=G();await ne(`${B}/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(B){b.error("Failed to refresh Figma:",B)}finally{R(!1)}}};return e?re.createElement(ia,null,re.createElement($m,null,re.createElement(Um,null,re.createElement(sa,null,"Screenshot Comparison"))),re.createElement(PC,null,re.createElement($i,null,re.createElement(Ui,null,re.createElement(ji,null),re.createElement(Hi,null,"Loading Figma..."))),re.createElement($i,null,re.createElement(Ui,null,re.createElement(ji,null),re.createElement(Hi,null,"Loading Storybook..."))))):!i&&!s&&!r?o?re.createElement(ia,null,re.createElement($m,null,re.createElement(Um,null,re.createElement(sa,null,"Screenshot Comparison"))),re.createElement(PC,null,re.createElement($i,null,re.createElement(Ui,null,re.createElement(ji,null),re.createElement(Hi,null,"Loading..."))))):re.createElement(ia,null,re.createElement(sa,null,"Screenshot Comparison"),re.createElement(Wm,null,"No Figma mapping. Link this story to a Figma frame to compare designs.")):!i&&!s?re.createElement(ia,null,re.createElement(sa,null,"Screenshot Comparison"),re.createElement(Wm,null,"No screenshots available. Run a review to capture Figma and Storybook screenshots.")):re.createElement(ia,{ref:C},re.createElement($m,null,re.createElement(Um,null,re.createElement(sa,null,"Screenshot Comparison")),re.createElement(m6,null,re.createElement(EC,{active:S==="side-by-side",onClick:()=>T("side-by-side")},"Side by Side"),re.createElement(EC,{active:S==="overlay",onClick:()=>T("overlay")},"Overlay"))),S==="side-by-side"?re.createElement(AC,{layout:"side-by-side"},i&&!t?re.createElement(jm,null,re.createElement(Hm,null,"Figma Design"),re.createElement(h6,{onClick:L,disabled:z,title:"Refresh Figma cache and reload image"},z?"\u23F3":"\u{1F504}"),re.createElement(b6,null,re.createElement(y6,{ref:h,src:i,alt:"Figma design",onLoad:y,style:D?{width:D.width,height:D.height}:{maxWidth:"100%",maxHeight:"120px"}}))):!r&&!o?re.createElement(jm,null,re.createElement(Hm,null,"Figma Design"),re.createElement(Wm,{style:{border:"none",padding:"20px"}},"No Figma mapping. Link this story to a Figma frame to compare designs.")):re.createElement($i,null,re.createElement(Ui,null,re.createElement(ji,null),re.createElement(Hi,null,t?"Refreshing Figma...":"Loading Figma..."))),s&&!n?re.createElement(jm,null,re.createElement(Hm,null,"Storybook Component"),re.createElement(x6,{ref:A,src:s,alt:"Storybook component",onLoad:P})):re.createElement($i,null,re.createElement(Ui,null,re.createElement(ji,null),re.createElement(Hi,null,n?"Refreshing Storybook...":"Loading Storybook...")))):re.createElement(re.Fragment,null,re.createElement(AC,{layout:"overlay"},re.createElement(S6,null,i&&s?re.createElement(re.Fragment,null,re.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},re.createElement(w6,{ref:A,src:s,alt:"Storybook component",onLoad:P,style:{maxHeight:"200px"}}),D&&re.createElement(v6,{src:i,alt:"Figma design overlay",style:{opacity:F,width:D.width,height:D.height,objectFit:"fill"}})),re.createElement("div",{style:{fontSize:"10px",color:"#888",marginTop:"8px",textAlign:"center"}},re.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",re.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),D&&` \u2022 ${D.width}\xD7${D.height}px`)):re.createElement($i,null,re.createElement(Ui,null,re.createElement(ji,null),re.createElement(Hi,null,"Loading Images..."))))),s&&i&&re.createElement(k6,null,re.createElement(C6,null,"Figma Opacity:"),re.createElement(T6,{type:"range",min:"0",max:"1",step:"0.01",value:F,onChange:B=>k(parseFloat(B.target.value))}),re.createElement("span",null,Math.round(F*100),"%"))))};ke();nt();var F6=Xo.div({padding:"20px",height:"100%",overflowY:"auto"}),bc=Xo.div({marginBottom:"20px"}),LC=Xo.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"})),MC=Xo.span({fontSize:"16px",flexShrink:0}),E6=Xo.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})),BC=Xo.div({flex:1}),A6=Xo(Wn)(({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"}})),Gm=()=>{let{reviewError:e,getCurrentReview:t}=se(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=Qi(),{selectedProjectId:s}=ir(),{setCurrentMapping:a,deleteMapping:u,currentMapping:c,hasMapping:l}=No(),[p,f]=I6(!1),{currentStoryId:d,currentStoryName:m}=Ye(),{isLoadingScreenshots:S,isLoadingFigma:T,isLoadingStorybook:F,screenshotError:k,setFigmaImageDirect:z}=Eo(),R=async O=>{b.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",O),b.debug("[ReviewPanel] frame.id:",O?.id);let E=at.getState(),D=E.selectedProjectId,g=E.currentStoryId,w=E.currentStoryName,v=E.figmaFileUrl;b.debug("[ReviewPanel] selectedProjectId (from store):",D),b.debug("[ReviewPanel] currentStoryId (from store):",g),b.debug("[ReviewPanel] currentStoryName (from store):",w),O.thumbnail&&g&&(b.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),z(g,O.id,O.thumbnail));try{let A=G(),h=localStorage.getItem("uicopilot_session_token");if(b.debug("[ReviewPanel] sessionToken exists:",!!h),b.debug("[ReviewPanel] dashboardUrl:",A),!h||!D||!g){b.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!h,selectedProjectId:D,currentStoryId:g});return}let C=v?.match(/\/file\/([^\/]+)/)?.[1]||void 0;b.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:D,storyId:g,name:w,figmaNodeId:O.id,figmaFileKey:C});let I=await ne(`${A}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify({projectId:D,storyId:g,name:w,figmaNodeId:O.id,figmaFileKey:C})});if(I.ok){let y=await I.json();y.mapping&&(a(y.mapping),O.thumbnail||(b.debug("[ReviewPanel] No thumbnail available, triggering fetch"),at.getState().triggerScreenshotRefresh()),b.debug("[ReviewPanel] Mapping saved successfully:",y.mapping))}else{let y=await I.text();b.error("[ReviewPanel] Failed to save mapping:",y)}}catch(A){b.error("[ReviewPanel] Error saving mapping:",A)}};return vt.createElement(F6,null,vt.createElement(bc,null,vt.createElement(yg,null)),e&&vt.createElement(LC,null,vt.createElement(MC,null,"\u26A0\uFE0F"),vt.createElement(BC,null,e)),k&&vt.createElement(LC,null,vt.createElement(MC,null,"\u26A0\uFE0F"),vt.createElement(BC,null,"Screenshot loading error: ",k)),n?.variantMismatch&&vt.createElement(E6,null,vt.createElement("span",{style:{fontSize:16,flexShrink:0}},"\u26A0"),vt.createElement("span",null,vt.createElement("strong",null,"Variant mismatch:")," Storybook is showing ",vt.createElement("strong",null,n.storybookVariant)," but Figma frame is ",vt.createElement("strong",null,n.figmaVariant),". Some differences may be expected.")),vt.createElement(bc,null,vt.createElement(zm,null)),vt.createElement(bc,null,vt.createElement(Vm,{isLoading:S,isLoadingFigma:T,isLoadingStorybook:F})),vt.createElement(bc,null,vt.createElement(bg,null),l&&vt.createElement("div",{style:{marginTop:"8px"}},vt.createElement(A6,{onClick:()=>f(!0)},"Unlink Figma Mapping"),vt.createElement(Fi,{isOpen:p,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:async()=>{f(!1);try{let O=c?.id;O&&await u(O),a(null)}catch(O){console.error("[ReviewPanel] Failed to unlink:",O)}},onCancel:()=>f(!1)}))),vt.createElement(Ti,{isOpen:r,onClose:o,onSelect:R,figmaFileUrl:i||"",projectId:s||void 0}))};import sce from"react";import{styled as Sc}from"storybook/theming";ke();var uce=Sc.div({display:"flex",flexDirection:"column",gap:"12px"}),pce=Sc.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),dce=Sc.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:Rl.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}})),fce=Sc.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"}));ke();Me();Re();nt();import{useEffect as DC,useState as P6,useRef as qm,useCallback as L6}from"react";var M6=G(),B6=2e3;function RC(){let{sessionToken:e,usageData:t,setUsageData:n}=Ie(),[r,o]=P6(null),i=qm(null),s=qm(!1),a=qm(0);DC(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=L6(()=>{o(null)},[]);return DC(()=>{if(!e)return;let c=async()=>{let p=Date.now();if(s.current||p-a.current<B6){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 ne(`${M6}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(f.ok){let d=await f.json(),m=d.creditBalance,S=i.current;if(S!==null&&m>S){let T=m-S;o({message:`Credits added! +$${T.toFixed(2)}`,previousBalance:S,newBalance:m}),b.debug("[useBalanceRefresh] Credits added:",T)}i.current=m,n(d),b.debug("[useBalanceRefresh] Balance updated:",m)}}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}}ke();ke();Re();Me();nt();import{useEffect as D6,useRef as R6}from"react";var z6={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}};function zC(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=se(),{sessionToken:r}=Ie(),o=R6(null);D6(()=>{if(!r||r===o.current)return;o.current=r;let i=`${G()}/api/addon/flags`;ne(i,{headers:{Authorization:`Bearer ${r}`}}).then(s=>{if(!s.ok)throw new Error(`flags endpoint returned ${s.status}`);return s.json()}).then(s=>{b.debug("[useFeatureFlags] Received flags:",s);let a={enableFixGeneration:!!s.enableFixGeneration,enableFixApply:!!s.enableFixApply,enableAutoMap:!!s.enableAutoMap,enableReviewBadges:!!s.enableReviewBadges,showCosts:!!s.showCosts,enableParallelReview:!!s.enableParallelReview,enableModelSelection:!!s.enableModelSelection};s.role&&t(s.role);let u=s.role==="admin"&&n?z6[n]:a;e(u);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(u)),s.role&&localStorage.setItem("uicopilot_user_role",s.role)}catch{}}).catch(s=>{b.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",s.message)})},[r,e,t])}ke();Re();var _6=rr.div`
|
|
145
145
|
position: fixed;
|
|
146
146
|
top: 16px;
|
|
147
147
|
right: 16px;
|
|
@@ -159,22 +159,22 @@ ${"=".repeat(40)}
|
|
|
159
159
|
from { transform: translateX(100%); opacity: 0; }
|
|
160
160
|
to { transform: translateX(0); opacity: 1; }
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
`,$6=rr.span`font-size: 20px;`,U6=rr.span`font-weight: 500; font-size: 14px;`,j6=rr.button`
|
|
163
163
|
background: rgba(255, 255, 255, 0.2);
|
|
164
164
|
border: none; color: white;
|
|
165
165
|
width: 24px; height: 24px; border-radius: 50%;
|
|
166
166
|
cursor: pointer; display: flex; align-items: center; justify-content: center;
|
|
167
167
|
font-size: 14px; margin-left: 8px;
|
|
168
168
|
&:hover { background: rgba(255, 255, 255, 0.3); }
|
|
169
|
-
`,
|
|
169
|
+
`,H6=rr.div`
|
|
170
170
|
padding: 8px 16px;
|
|
171
171
|
border-top: 1px solid ${({theme:e})=>e.appBorderColor};
|
|
172
172
|
font-size: 11px;
|
|
173
173
|
color: ${({theme:e})=>e.color.mediumdark};
|
|
174
174
|
text-align: center;
|
|
175
175
|
opacity: 0.7;
|
|
176
|
-
`,
|
|
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)))})});
|
|
176
|
+
`,W6=rr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),V6=rr.div({fontSize:"32px"}),G6=rr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),q6=rr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),NC=rr.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})),OC=rr.span({flex:1}),_C=rr.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`}})),$C=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Qe(),{isConnected:r,sessionToken:o,authError:i}=Ie(),{currentStoryId:s}=Ye(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:p}=se(),[f,d]=N6(!1),m=()=>{l(null),o&&fetch(`${G()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(E=>E.json()).then(E=>{p({enableFixGeneration:!!E.enableFixGeneration,enableFixApply:!!E.enableFixApply,enableAutoMap:!!E.enableAutoMap,enableReviewBadges:!!E.enableReviewBadges,showCosts:!!E.showCosts,enableParallelReview:!!E.enableParallelReview,enableModelSelection:!!E.enableModelSelection})}).catch(()=>{})};mf(),Bf(),zC(),Cf(),wf();let{notification:S,dismissNotification:T}=RC();O6(()=>{if(S){let E=setTimeout(T,5e3);return()=>clearTimeout(E)}},[S,T]);let F=t.find(E=>E.id===e),k=r&&!!e&&!!F,z=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=Ye(),O=k&&!!s&&!a&&R;return Ft.createElement(Ac,{header:Ft.createElement(Pc,{toolbar:Ft.createElement(jc,{onOpenSettings:()=>d(!0)})}),footer:Ft.createElement(H6,null,"UI Copilot v","0.4.1")},S&&Ft.createElement(_6,null,Ft.createElement($6,null,"+"),Ft.createElement(U6,null,S.message),Ft.createElement(j6,{onClick:T},"x")),i&&Ft.createElement(NC,null,Ft.createElement("span",null,"\u26A0"),Ft.createElement(OC,null,i),Ft.createElement(_C,{onClick:()=>d(!0)},"Reconnect")),u==="admin"&&c&&Ft.createElement(NC,null,Ft.createElement("span",null,"\u{1F441}"),Ft.createElement(OC,null,"Previewing as ",c),Ft.createElement(_C,{onClick:m},"Exit preview")),z||O?Ft.createElement(gc,{label:z?"Loading...":"Loading review..."}):k?Ft.createElement(Gm,null):Ft.createElement(W6,null,Ft.createElement(V6,null,"\u2699"),Ft.createElement(G6,null,i?"Connection issue":"Set up UI Copilot"),Ft.createElement(q6,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),Ft.createElement(_t,{onClick:()=>d(!0)},i?"Reconnect":"Open Settings")),f&&Ft.createElement(Cw,{onClose:()=>d(!1)}))};import jC,{useCallback as Y6}from"react";import{useStorybookApi as K6}from"storybook/manager-api";import{IconButton as X6}from"storybook/internal/components";import Ym from"react";var UC=()=>Ym.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"},Ym.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Ym.createElement("circle",{cx:"12",cy:"12",r:"3"}));var Q6="uireview",J6=`${Q6}/panel`,HC=()=>{let e=K6(),t=Y6(()=>{e.togglePanel(!0),e.setSelectedPanel(J6)},[e]);return jC.createElement(X6,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},jC.createElement(UC,null))};ke();import Nt,{useState as ua,useCallback as qC,useEffect as Jm}from"react";import{styled as Kr,useTheme as cj}from"storybook/theming";import{addons as kc}from"storybook/manager-api";Re();Me();import{addons as oj,experimental_getStatusStore as vc}from"storybook/manager-api";async function WC(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}Re();Me();var Z6=G(),ej="uireview/badge";async function tj(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 nj(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 m of d)if(m.startsWith("data: "))try{let S=JSON.parse(m.slice(6));if(S.type==="complete"){o=S.complianceScore??S.validation?.complianceScore??null;let F=(S.issues||[]).filter(k=>!k.dismissed);i=F.filter(k=>k.severity==="critical").length,s=F.filter(k=>k.severity==="major").length,a=F.filter(k=>k.severity==="minor").length,u=S.costUsd||0,c=S.inputTokens||0,l=S.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function wc(e,t,n,r,o){e&&e.set([{value:n,typeId:ej,storyId:t,title:r,description:o}])}async function rj(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 VC(e,t,n,r,o,i){wc(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await rj(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await tj(`${Z6}/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 nj(u,i),{score:l,criticalCount:p,majorCount:f,minorCount:d,costUsd:m,inputTokens:S,outputTokens:T}=c;if(l!==null){let F=p>0||l<70?"status-value:error":f>0||l<90?"status-value:warning":"status-value:success",k=[`Score: ${l}`];p>0&&k.push(`${p} critical`),f>0&&k.push(`${f} major`),d>0&&k.push(`${d} minor`);let z=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return wc(o,e.storyId,F,z,k.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:m,inputTokens:S,outputTokens:T}}return wc(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 wc(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var ij=G(),aa="uireview/badge";function GC(){let e=!1,t=!1;try{let n=oj.getChannel();n.on(Xm,async()=>{if(!t){t=!0,e=!1;try{await lj(n,()=>e)}finally{t=!1}}}),n.on(Qm,()=>{e=!0})}catch{}}async function Km(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${ij}/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 sj(i),i}catch(e){return b.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function sj(e){try{if(typeof vc!="function")return;let t=vc(aa);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[aa]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[aa];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:aa,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 aj(){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 lj(e,t){let n=await Km();if(n.length===0){e.emit(ca,{total:0,passed:0,failed:0});return}let r=localStorage.getItem("uicopilot_session_token"),o=localStorage.getItem("uicopilot_selected_project_id");if(!r||!o)return;let i="claude-sonnet-4-5-20250929";try{let S=localStorage.getItem("uicopilot_selected_models");if(S){let T=JSON.parse(S);Array.isArray(T)&&T.length>0&&(i=T[0])}}catch{}let s=null;try{typeof vc=="function"&&(s=vc(aa))}catch{}let a=aj(),u=0,c=0,l=0,p=0,f=0,d=0;e.emit(la,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let m=n.map(S=>()=>VC(S,r,o,i,s,t));await WC(m,a,(S,T)=>{if(T&&typeof T=="object"&&"score"in T){let F=T;F.score!==null&&F.score>=90?u++:F.score!==null&&F.score>=70?c++:l++,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,T),e.emit(la,{total:n.length,completed:u+c+l,currentStoryName:n[S].storyName})},t),e.emit(ca,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:p,inputTokens:f,outputTokens:d})}var uj=Kr.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),pj=Kr.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),dj=Kr.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),YC=Kr.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),KC=Kr.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}})),fj=Kr.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),gj=Kr.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),XC=Kr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),Wi=Kr.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Xm="uireview/review-all-start",Qm="uireview/review-all-cancel",la="uireview/review-all-progress",ca="uireview/review-all-complete";function QC(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var JC=()=>{let[e,t]=ua(!1),[n,r]=ua(null),[o,i]=ua(null),[s,a]=ua(null),[u,c]=ua(QC);Jm(()=>{let m=()=>c(QC()),S=setInterval(m,2e3);return window.addEventListener("storage",m),()=>{clearInterval(S),window.removeEventListener("storage",m)}},[]),Jm(()=>{let m=()=>{Km().then(k=>{a(k.length)}).catch(()=>{})},S=setTimeout(m,3e3),T=null;try{T=kc.getChannel(),T.on("storyChanged",m),T.on("uireview/mappings-changed",m)}catch{}let F=setInterval(m,6e4);return()=>{clearTimeout(S),clearInterval(F),T&&(T.off("storyChanged",m),T.off("uireview/mappings-changed",m))}},[]),Jm(()=>{let m;try{m=kc.getChannel()}catch{return}let S=F=>{r(F),t(!0)},T=F=>{t(!1),r(null),i({total:F.total,passed:F.passed,failed:F.failed,warned:F.warnCount||0,costUsd:F.costUsd||0})};return m.on(la,S),m.on(ca,T),()=>{m.off(la,S),m.off(ca,T)}},[]);let l=qC(()=>{try{kc.getChannel().emit(Xm),t(!0),i(null)}catch{}},[]),p=qC(()=>{try{kc.getChannel().emit(Qm)}catch{}t(!1),r(null)},[]),f=n?Math.round(n.completed/n.total*100):0,d=cj();return u?Nt.createElement(uj,null,Nt.createElement(pj,null,Nt.createElement(dj,null,"UI Review"),e?Nt.createElement(KC,{running:!0,onClick:p},"Cancel"):Nt.createElement(KC,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Nt.createElement(Nt.Fragment,null,Nt.createElement(XC,null,Nt.createElement(Wi,{dotColor:d.color.positive},"Pass (",o.passed,")"),Nt.createElement(Wi,{dotColor:d.color.warning},"Warn (",o.warned,")"),Nt.createElement(Wi,{dotColor:d.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Nt.createElement(YC,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Nt.createElement(XC,null,Nt.createElement(Wi,{dotColor:d.color.positive},"Pass"),Nt.createElement(Wi,{dotColor:d.color.warning},"Warn"),Nt.createElement(Wi,{dotColor:d.color.negative},"Fail")),e&&n&&Nt.createElement(Nt.Fragment,null,Nt.createElement(fj,null,Nt.createElement(gj,{percent:f})),Nt.createElement(YC,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as e1 from"@sentry/react";var mj="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",ZC=!1;function t1(){if(!ZC){ZC=!0;try{e1.init({dsn:mj,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{}}}t1();var Tc="uireview",xj=`${Tc}/panel`,yj=`${Tc}/tool`,r1=`${Tc}/test-provider`;Cc.register(Tc,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof n1=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=n1("uireview/badge");p0(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");Cc.add(yj,{type:Zm.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>pa.createElement(HC,null)}),GC(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&Cc.add(r1,{type:Zm.experimental_TEST_PROVIDER,id:r1,render:()=>pa.createElement(JC,null)}),Cc.add(xj,{type:Zm.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>pa.createElement(hj,{active:t||!1},pa.createElement(Uc,null,pa.createElement($C,null)))})});
|
|
178
178
|
/*! Bundled license information:
|
|
179
179
|
|
|
180
180
|
@noble/hashes/utils.js:
|