@uicopilot/storybook-addon 0.5.11 → 0.5.12
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 +3 -3
- package/package.json +1 -1
package/dist/manager.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var $F=Object.create;var _a=Object.defineProperty;var UF=Object.getOwnPropertyDe
|
|
|
11
11
|
`+t+`
|
|
12
12
|
--`+new Array((n||t.length)+1).join("-")+"^"})}var _b=_(()=>{"use strict";sl()});var GA,qA,YA,KA,XA,$b,vl,Ub=_(()=>{"use strict";_b();GA=9,qA=10,YA=12,KA=13,XA=32,$b=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),vl=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&&$b[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!==KA&&n!==qA&&n!==YA&&n!==XA&&n!==GA)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 Ob(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||$b[n]===0)break}return this.pos===t&&this.error("Expect a keyword"),this.substringToPos(t)}scanNumber(){let t=this.pos;for(;t<this.str.length;t++){let n=this.str.charCodeAt(t);if(n<48||n>57)break}return this.pos===t&&this.error("Expect a number"),this.substringToPos(t)}scanString(){let t=this.str.indexOf("'",this.pos+1);return t===-1&&(this.pos=this.str.length,this.error("Expect an apostrophe")),this.substringToPos(t+1)}}});function qb(e){let t=null,n=null;return e.eat(Tl),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===lp?(e.pos++,e.skipWs(),e.charCode()!==ip&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(ip),{min:Number(t),max:n?Number(n):0}}function rP(e){let t=null,n=!1;switch(e.charCode()){case Qb:e.pos++,t={min:0,max:0};break;case ap:e.pos++,t={min:1,max:0};break;case Cl:e.pos++,t={min:0,max:1};break;case sp:e.pos++,n=!0,e.charCode()===Tl?t=qb(e):e.charCode()===Cl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Tl:t=qb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Zr(e,t){let n=rP(e);return n!==null?(n.term=t,e.charCode()===sp&&e.charCodeAt(e.pos-1)===ap||e.charCode()===Cl&&e.charCodeAt(e.pos-1)===ip?Zr(e,n):n):t}function rp(e){let t=e.peek();return t===""?null:Zr(e,{type:"Token",value:t})}function oP(e){let t;return e.eat(cp),e.eat(kl),t=e.scanWord(),e.eat(kl),e.eat(op),Zr(e,{type:"Property",name:t})}function iP(e){let t=null,n=null,r=1;return e.eat(Fs),e.charCode()===Hb&&(e.peek(),r=-1),r==-1&&e.charCode()===Vb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(lp),e.skipWs(),e.charCode()===Vb?e.peek():(r=1,e.charCode()===Hb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Ti),{type:"Range",min:t,max:n}}function sP(e){let t,n=null;if(e.eat(cp),t=e.scanWord(),t==="boolean-expr"){e.eat(Fs);let r=Il(e,Ti);return e.eat(Ti),e.eat(op),Zr(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Kb&&e.nextCharCode()===Xb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Fs&&(e.skipWs(),n=iP(e)),e.eat(op),Zr(e,{type:"Type",name:t,opts:n})}function aP(e){let t=e.scanWord();return e.charCode()===Kb?(e.pos++,{type:"Function",name:t}):Zr(e,{type:"Keyword",name:t})}function lP(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)=>Gb[o]-Gb[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,Xb):uP(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:lP(r,n)||" ",disallowEmpty:!1,explicit:!1}}function cP(e){let t;return e.eat(Fs),t=Il(e,Ti),e.eat(Ti),t.explicit=!0,e.charCode()===Yb&&(e.pos++,t.disallowEmpty=!0),t}function uP(e){let t=e.charCode();switch(t){case Ti:break;case Fs:return Zr(e,cP(e));case cp:return e.nextCharCode()===kl?oP(e):sP(e);case Wb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Wb?2:1))};case jb:return e.pos++,e.eat(jb),{type:"Combinator",value:"&&"};case lp:return e.pos++,{type:"Comma"};case kl:return Zr(e,{type:"String",value:e.scanString()});case tP:case QA:case JA:case eP:case ZA:return{type:"Spaces",value:e.scanSpaces()};case nP:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):rp(e);case Qb:case ap:case Cl:case sp:case Yb:break;case Tl:if(t=e.nextCharCode(),t<48||t>57)return rp(e);break;default:return e.isNameCharCode(t)?aP(e):rp(e)}}function Es(e){let t=new vl(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 QA,JA,ZA,eP,tP,Yb,sp,jb,kl,Kb,Xb,Qb,ap,lp,Hb,cp,op,Cl,nP,Fs,Ti,Tl,Wb,ip,Vb,Gb,up=_(()=>{"use strict";Ub();QA=9,JA=10,ZA=12,eP=13,tP=32,Yb=33,sp=35,jb=38,kl=39,Kb=40,Xb=41,Qb=42,ap=43,lp=44,Hb=45,cp=60,op=62,Cl=63,nP=64,Fs=91,Ti=93,Tl=123,Wb=124,ip=125,Vb=8734,Gb={" ":1,"&&":2,"||":3,"|":4}});function Jb(e){return typeof e=="function"?e:As}function pp(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=As,i=As;if(typeof t=="function"?o=t:t&&(o=Jb(t.enter),i=Jb(t.leave)),o===As&&i===As)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var As,Zb=_(()=>{"use strict";As=function(){}});var dp=_(()=>{"use strict";Hu();up();Zb()});function gP(e){let t=[];return wo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function e0(e,t){return typeof e=="string"?gP(e):t.generate(e,dP)}var dP,t0=_(()=>{"use strict";sr();dP={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 bn(e,t,n){return t===pt&&n===St||e===pt&&t===pt&&n===pt?e:(e.type==="If"&&e.else===St&&t===pt&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function r0(e){return e.length>2&&e.charCodeAt(e.length-2)===fP&&e.charCodeAt(e.length-1)===mP}function n0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&r0(e.name)}function ko(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Ps(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Ps(e.match,t,n),e.then=Ps(e.then,t,n),e.else=Ps(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function gp(e,t,n){switch(e){case" ":{let r=pt;for(let o=t.length-1;o>=0;o--){let i=t[o];r=bn(i,r,St)}return r}case"|":{let r=St,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(n0(s)&&(o===null&&i>0&&n0(t[i-1])&&(o=Object.create(null),r=bn({type:"Enum",map:o},pt,r)),o!==null)){let a=(r0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(a in o)){o[a]=s;continue}}o=null,r=bn(s,pt,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=St;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=gp(e,t.filter(function(a){return a!==i}),!1):s=pt,r=bn(i,s,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?pt:St;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=gp(e,t.filter(function(a){return a!==i}),!0):s=pt,r=bn(i,s,r)}return r}}}function hP(e){let t=pt,n=Ii(e.term);if(e.max===0)n=bn(n,Fl,St),t=bn(n,null,St),t.then=bn(pt,pt,t),e.comma&&(t.then.else=bn({type:"Comma",syntax:e},t,St));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==pt&&(t=bn({type:"Comma",syntax:e},t,St)),t=bn(n,bn(pt,pt,t),St);if(e.min===0)t=bn(pt,pt,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==pt&&(t=bn({type:"Comma",syntax:e},t,St)),t=bn(n,t,St);return t}function Ii(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=gp(e.combinator,e.terms.map(Ii),!1);return e.disallowEmpty&&(t=bn(t,Fl,St)),t}case"Multiplier":return hP(e);case"Boolean":{let t=Ii(e.term),n=Ii(ko([ko([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),ko([{type:"Type",name:"!boolean-group"},ko([{type:"Multiplier",comma:!1,min:0,max:0,term:ko([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:ko([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=Ii(ko([{type:"Type",name:"!term"},ko([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Ps(r,{"!term":t,"!self":n}),Ps(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 Ls(e,t){return typeof e=="string"&&(e=Es(e)),{type:"MatchGraph",match:Ii(e),syntax:t||null,source:e}}var pt,St,Fl,fP,mP,fp=_(()=>{"use strict";up();pt={type:"Match"},St={type:"Mismatch"},Fl={type:"DisallowEmpty"},fP=40,mP=41});function vP(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function mp(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 kP(e){return e.type!==9?!1:e.value!=="?"}function a0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||kP(e)}function l0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function CP(e,t,n){function r(){do I++,E=I<e.length?e[I]:null;while(E!==null&&(E.type===13||E.type===25))}function o($){let P=I+$;return P<e.length?e[P]:null}function i($,P){return{nextState:$,matchStack:R,syntaxStack:d,thenStack:g,tokenIndex:I,prev:P}}function s($){g={nextState:$,matchStack:R,syntaxStack:d,prev:g}}function a($){p=i($,p)}function u(){R={type:yP,syntax:t.syntax,token:E,prev:R},r(),f=null,I>D&&(D=I)}function c(){d={syntax:t.syntax,opts:t.syntax.opts||d!==null&&d.opts||null,prev:d},R={type:hp,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===hp?R=R.prev:R={type:c0,syntax:d.syntax,token:R.token,prev:R},d=d.prev}let d=null,g=null,p=null,f=null,k=0,T=null,E=null,I=-1,D=0,R={type:xP,syntax:null,token:null,prev:null};for(r();T===null&&++k<s0;)switch(t.type){case"Match":if(g===null){if(E!==null&&(I!==e.length-1||E.value!=="\\0"&&E.value!=="\\9")){t=St;break}T=i0;break}if(t=g.nextState,t===Fl)if(g.matchStack===R){t=St;break}else t=pt;for(;g.syntaxStack!==d;)l();g=g.prev;break;case"Mismatch":if(f!==null&&f!==!1)(p===null||I>p.tokenIndex)&&(p=f,f=!1);else if(p===null){T=bP;break}t=p.nextState,g=p.thenStack,d=p.syntaxStack,R=p.matchStack,I=p.tokenIndex,E=I<e.length?e[I]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==St&&a(t.else),t.then!==pt&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let z=t.syntax.terms;if(t.index===z.length){if(t.mask===0||t.syntax.all){t=St;break}t=pt;break}if(t.mask===(1<<z.length)-1){t=pt;break}for(;t.index<z.length;t.index++){let x=1<<t.index;if((t.mask&x)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|x}),t=z[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(E!==null){let z=E.value.toLowerCase();if(z.indexOf("\\")!==-1&&(z=z.replace(/\\[09].*$/,"")),o0.call(t.map,z)){t=t.map[z];break}}t=St;break;case"Generic":{let z=d!==null?d.opts:null,x=I+Math.floor(t.fn(E,o,z));if(!isNaN(x)&&x>I){for(;I<x;)u();t=pt}else t=St;break}case"Type":case"Property":{let z=t.type==="Type"?"types":"properties",x=o0.call(n,z)?n[z][t.name]:null;if(!x||!x.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(f!==!1&&E!==null&&t.type==="Type"&&(t.name==="custom-ident"&&E.type===1||t.name==="length"&&E.value==="0")){f===null&&(f=i(t,p)),t=St;break}c(),t=x.matchRef||x.match;break}case"Keyword":{let z=t.name;if(E!==null){let x=E.value;if(x.indexOf("\\")!==-1&&(x=x.replace(/\\[09].*$/,"")),mp(x,z)){u(),t=pt;break}}t=St;break}case"AtKeyword":case"Function":if(E!==null&&mp(E.value,t.name)){u(),t=pt;break}t=St;break;case"Token":if(E!==null&&E.value===t.value){u(),t=pt;break}t=St;break;case"Comma":E!==null&&E.type===18?a0(R.token)?t=St:(u(),t=l0(E)?St:pt):t=a0(R.token)||l0(E)?pt:St;break;case"String":let $="",P=I;for(;P<e.length&&$.length<t.value.length;P++)$+=e[P].value;if(mp($,t.value)){for(;I<P;)u();t=pt}else t=St;break;default:throw new Error("Unknown node type: "+t.type)}switch(wP+=k,T){case null:console.warn("[csstree-match] BREAK after "+s0+" iterations"),T=SP,R=null;break;case i0:for(;d!==null;)l();break;default:R=null}return{tokens:e,reason:T,iterations:k,match:R,longestMatch:D}}function xp(e,t,n){let r=CP(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=vP(o).prev;o!==null;){switch(o.type){case hp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case c0: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 o0,xP,yP,hp,c0,i0,bP,SP,s0,wP,u0=_(()=>{"use strict";fp();({hasOwnProperty:o0}=Object.prototype),xP=0,yP=1,hp=2,c0=3,i0="Match",bP="Mismatch",SP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",s0=15e3,wP=0});var bp={};Se(bp,{getTrace:()=>p0,isKeyword:()=>FP,isProperty:()=>IP,isType:()=>TP});function p0(e){function t(o){return o===null?!1:o.type==="Type"||o.type==="Property"||o.type==="Keyword"}function n(o){if(Array.isArray(o.match)){for(let i=0;i<o.match.length;i++)if(n(o.match[i]))return t(o.syntax)&&r.unshift(o.syntax),!0}else if(o.node===e)return r=t(o.syntax)?[o.syntax]:[],!0;return!1}let r=null;return this.matched!==null&&n(this.matched),r}function TP(e,t){return yp(this,e,n=>n.type==="Type"&&n.name===t)}function IP(e,t){return yp(this,e,n=>n.type==="Property"&&n.name===t)}function FP(e){return yp(this,e,t=>t.type==="Keyword")}function yp(e,t,n){let r=p0.call(e,t);return r===null?!1:r.some(n)}var d0=_(()=>{"use strict"});function g0(e){return"node"in e?e.node:g0(e.match[0])}function f0(e){return"node"in e?e.node:f0(e.match[e.match.length-1])}function Sp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=g0(a),c=f0(a);e.syntax.walk(t,function(l,d,g){if(l===u){let p=new Xn;do{if(p.appendData(d.data),d.data===c)break;d=d.next}while(d!==null);s.push({parent:g,nodes:p})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var m0=_(()=>{"use strict";bs()});function wp(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function h0(e){return!!e&&wp(e.offset)&&wp(e.line)&&wp(e.column)}function EP(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(Ms.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(!h0(r.loc.start))i+=".start";else if(!h0(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 Xn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Ms.call(t,i)&&Ms.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function x0(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<"+(x0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function AP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Ms.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=x0(s,e+"."+i)}return{docs:o,check:EP(e,r)}}function y0(e){let t={};if(e.node){for(let n in e.node)if(Ms.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=AP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Ms,b0=_(()=>{"use strict";bs();({hasOwnProperty:Ms}=Object.prototype)});function vp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:Si(e[o].syntax,{compact:t}));return r}function PP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:Si(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&vp(i.descriptors,t,n)};return r}function LP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function MP(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function kr(e,t,n){return{matched:e,iterations:n,error:t,...bp}}function Fi(e,t,n,r){let o=e0(n,e.syntax),i;return LP(o)?kr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=xp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=xp(o,t.match,e),!i.match)?kr(null,new vb(i.reason,t.syntax,n,i),i.iterations):kr(i.match,null,i.iterations))}var Bs,S0=_(()=>{"use strict";kb();xl();yl();zb();Nb();dp();t0();fp();u0();d0();m0();b0();Bs=class{constructor(t,n,r){if(this.cssWideKeywords=ki,this.syntax=n,this.generic=!1,this.units={...wl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||y0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(wl))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(Rb(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=Ls(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=Ls(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Es(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Ls(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=MP(a)?Ls({...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 wi("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&&!Fi(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=ml(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 wi("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new wi("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return kr(null,r);let o=this.getAtrule(t);return o.prelude?Fi(this,o.prelude,n||"",!1):kr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return kr(null,o);let i=this.getAtrule(t),s=ml(n);return Fi(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?kr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Wu(t).custom)return kr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?kr(null,r):Fi(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?Fi(this,r,n,!1):kr(null,new wi("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?kr(null,new wi("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Fi(this,t,n,!1))}findValueFragments(t,n,r,o){return Sp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return Sp(this,t.value,this.matchDeclaration(t),n,r)}findAllFragments(t,n,r){let o=[];return this.syntax.walk(t,{visit:"Declaration",enter:i=>{o.push.apply(o,this.findDeclarationValueFragments(i,n,r))}}),o}getAtrule(t,n=!0){let r=ml(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=Wu(t);return(r.vendor&&n?this.properties[r.name]||this.properties[r.basename]:this.properties[r.name])||null}getType(t){return hasOwnProperty.call(this.types,t)?this.types[t]:null}validate(){function t(u,c){return c?`<${u}>`:`<'${u}'>`}function n(u,c,l,d){if(l.has(c))return l.get(c);l.set(c,!1),d.syntax!==null&&pp(d.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let p=g.type==="Type"?u.types:u.properties,f=g.type==="Type"?o:i;hasOwnProperty.call(p,g.name)?n(u,g.name,f,p[g.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0))},this)}let r=[],o=new Map,i=new Map;for(let u in this.types)n(this,u,o,this.types[u]);for(let u in this.properties)n(this,u,i,this.properties[u]);let s=[...o.keys()].filter(u=>o.get(u)),a=[...i.keys()].filter(u=>i.get(u));return s.length||a.length?{errors:r,types:s,properties:a}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:vp(this.types,!n,t),properties:vp(this.properties,!n,t),atrules:PP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function kp(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function BP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function Cp(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?BP(i,n):i};return r}function Ds(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?kp(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?kp(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]=kp(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=Cp(e[r],o);break;case"atrule":case"pseudo":n[r]=Cp(e[r],o,["parse"]);break;case"node":n[r]=Cp(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var w0=_(()=>{"use strict"});function v0(e){let t=Ny(e),n=bb(e),r=pb(e),{fromPlainObject:o,toPlainObject:i}=gb(n),s={lexer:null,createLexer:a=>new Bs(a,s,s.lexer.structure),tokenize:wo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Ds({},e);return v0(typeof a=="function"?a(u):Ds(u,a))}};return s.lexer=new Bs({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var k0,C0=_(()=>{"use strict";sr();Oy();db();fb();Sb();S0();w0();k0=e=>v0(Ds({},e))});var T0,I0=_(()=>{"use strict";T0={generic:!0,cssWideKeywords:["initial","inherit","unset","revert","revert-layer"],units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( <calc-sum> )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( <calc-sum> )","alpha-value":"<number>|<percentage>","an+b":"odd|even|<integer>|<n-dimension>|'+'? \u2020 n|-n|<ndashdigit-dimension>|'+'? \u2020 <ndashdigit-ident>|<dashndashdigit-ident>|<n-dimension> <signed-integer>|'+'? \u2020 n <signed-integer>|-n <signed-integer>|<ndash-dimension> <signless-integer>|'+'? \u2020 n- <signless-integer>|-n- <signless-integer>|<n-dimension> ['+'|'-'] <signless-integer>|'+'? \u2020 n ['+'|'-'] <signless-integer>|-n ['+'|'-'] <signless-integer>","anchor()":"anchor( <anchor-name>?&&<anchor-side> , <length-percentage>? )","anchor-name":"<dashed-ident>","anchor-side":"inside|outside|top|left|right|bottom|start|end|self-start|self-end|<percentage>|center","anchor-size":"width|height|block|inline|self-block|self-inline","anchor-size()":"anchor-size( [<anchor-name>||<anchor-size>]? , <length-percentage>? )","angle-percentage":"<angle>|<percentage>","angular-color-hint":"<angle-percentage>|<zero>","angular-color-stop":"<color> <color-stop-angle>?","angular-color-stop-list":"<angular-color-stop> , [<angular-color-hint>? , <angular-color-stop>]#?","animateable-feature":"scroll-position|contents|<custom-ident>","animation-action":"none|play|play-once|play-forwards|play-backwards|pause|reset|replay","asin()":"asin( <calc-sum> )","atan()":"atan( <calc-sum> )","atan2()":"atan2( <calc-sum> , <calc-sum> )",attachment:"scroll|fixed|local","attr()":"attr( <attr-name> <attr-type>? , <declaration-value>? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attr-type":"type( <syntax> )|raw-string|number|<attr-unit>","attribute-selector":"'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )","auto-track-list":"[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",axis:"block|inline|x|y","baseline-position":"[first|last]? baseline","basic-shape":"<inset()>|<xywh()>|<rect()>|<circle()>|<ellipse()>|<polygon()>|<path()>","basic-shape-rect":"<inset()>|<rect()>|<xywh()>","bg-clip":"<visual-box>|border-area|text","bg-image":"<image>|none","bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>","bg-position":"[[left|center|right|top|bottom|<length-percentage>]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]|[center|[left|right] <length-percentage>?]&&[center|[top|bottom] <length-percentage>?]]","bg-size":"[<length-percentage [0,\u221E]>|auto]{1,2}|cover|contain","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","blur()":"blur( <length>? )","brightness()":"brightness( [<number>|<percentage>]? )","calc()":"calc( <calc-sum> )","calc-constant":"e|pi|infinity|-infinity|NaN","calc-product":"<calc-value> ['*' <calc-value>|'/' <number>]*","calc-size()":"calc-size( <calc-size-basis> , <calc-sum> )","calc-size-basis":"<intrinsic-size-keyword>|<calc-size()>|any|<calc-sum>","calc-sum":"<calc-product> [['+'|'-'] <calc-product>]*","calc-value":"<number>|<dimension>|<percentage>|<calc-constant>|( <calc-sum> )","cf-final-image":"<image>|<color>","cf-mixing-image":"<percentage>?&&<image>","circle()":"circle( <radial-size>? [at <position>]? )","clamp()":"clamp( <calc-sum>#{3} )","class-selector":"'.' <ident-token>","clip-source":"<url>",color:"<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>","color()":"color( <colorspace-params> [/ [<alpha-value>|none]]? )","color-base":"<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent","color-function":"<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>","color-interpolation-method":"in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]","color-mix()":"color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )","color-stop":"<color-stop-length>|<color-stop-angle>","color-stop-angle":"[<angle-percentage>|<zero>]{1,2}","color-stop-length":"<length-percentage>{1,2}","color-stop-list":"<linear-color-stop> , [<linear-color-hint>? , <linear-color-stop>]#?","colorspace-params":"[<predefined-rgb-params>|<xyz-params>]",combinator:"'>'|'+'|'~'|['|' '|']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|checkbox|radio|menulist|listbox|meter|progress-bar|button","compat-special":"textfield|menulist-button","complex-selector":"<complex-selector-unit> [<combinator>? <complex-selector-unit>]*","complex-selector-list":"<complex-selector>#","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[<type-selector>? <subclass-selector>*]!","compound-selector-list":"<compound-selector>#","conic-gradient()":"conic-gradient( [<conic-gradient-syntax>] )","conic-gradient-syntax":"[[[from [<angle>|<zero>]]? [at <position>]?]||<color-interpolation-method>]? , <angular-color-stop-list>","container-condition":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","container-name":"<custom-ident>","container-query":"not <query-in-parens>|<query-in-parens> [[and <query-in-parens>]*|[or <query-in-parens>]*]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[<string>|contents|<image>|<counter>|<quote>|<target>|<leader()>|<attr()>]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"<image>","contextual-alt-values":"[contextual|no-contextual]","contrast()":"contrast( [<number>|<percentage>]? )","coord-box":"content-box|padding-box|border-box|fill-box|stroke-box|view-box","corner-shape-value":"round|scoop|bevel|notch|square|squircle|<superellipse()>","cos()":"cos( <calc-sum> )",counter:"<counter()>|<counters()>","counter()":"counter( <counter-name> , <counter-style>? )","counter-name":"<custom-ident>","counter-style":"<counter-style-name>|symbols( )","counter-style-name":"<custom-ident>","counters()":"counters( <counter-name> , <string> , <counter-style>? )","cross-fade()":"cross-fade( <cf-mixing-image> , <cf-final-image>? )","cubic-bezier()":"cubic-bezier( [<number [0,1]> , <number>]#{2} )","cubic-bezier-easing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )","cursor-predefined":"auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing","custom-color-space":"<dashed-ident>","custom-params":"<dashed-ident> [<number>|<percentage>|none]+",dasharray:"[[<length-percentage>|<number>]+]#","dashndashdigit-ident":"<ident-token>","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow|CaptionText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"<display-outside>?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( [<color>?&&<length>{2,3}] )","dynamic-range-limit-mix()":"dynamic-range-limit-mix( [<'dynamic-range-limit'>&&<percentage [0,100]>]#{2,} )","easing-function":"<linear-easing-function>|<cubic-bezier-easing-function>|<step-easing-function>","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )","ellipse()":"ellipse( <radial-size>? [at <position>]? )","env()":"env( <custom-ident> , <declaration-value>? )","exp()":"exp( <calc-sum> )","explicit-track-list":"[<line-names>? <track-size>]+ <line-names>?","family-name":"<string>|<custom-ident>+","feature-tag-value":"<string> [<integer>|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":"<feature-type> '{' <feature-value-declaration-list> '}'","feature-value-block-list":"<feature-value-block>+","feature-value-declaration":"<custom-ident> : <integer>+ ;","feature-value-declaration-list":"<feature-value-declaration>","feature-value-name":"<custom-ident>","filter-function":"<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>","filter-value-list":"[<filter-function>|<url>]+","final-bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<visual-box>||<visual-box>||<'background-color'>","fit-content()":"fit-content( <length-percentage [0,\u221E]> )","fixed-breadth":"<length-percentage>","fixed-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <fixed-size>]+ <line-names>? )","fixed-size":"<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>","font-variant-css2":"normal|small-caps","font-weight-absolute":"normal|bold|<number [1,1000]>","font-width-css3":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","form-control-identifier":"select","frequency-percentage":"<frequency>|<percentage>","generic-complete":"serif|sans-serif|system-ui|cursive|fantasy|math|monospace","general-enclosed":"[<function-token> <any-value>? )]|[( <any-value>? )]","generic-family":"<generic-script-specific>|<generic-complete>|<generic-incomplete>|<-non-standard-generic-family>","generic-incomplete":"ui-serif|ui-sans-serif|ui-monospace|ui-rounded","geometry-box":"<shape-box>|fill-box|stroke-box|view-box",gradient:"<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<repeating-conic-gradient()>|<-legacy-gradient>","grayscale()":"grayscale( [<number>|<percentage>]? )","grid-line":"auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hsla()":"hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",hue:"<number>|<angle>","hue-interpolation-method":"[shorter|longer|increasing|decreasing] hue","hue-rotate()":"hue-rotate( [<angle>|<zero>]? )","hwb()":"hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","hypot()":"hypot( <calc-sum># )",image:"<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>","image()":"image( <image-tags>? [<image-src>? , <color>?]! )","image-set()":"image-set( <image-set-option># )","image-set-option":"[<image>|<string>] [<resolution>||type( <string> )]","image-src":"<url>|<string>","image-tags":"ltr|rtl","inflexible-breadth":"<length-percentage>|min-content|max-content|auto","inset()":"inset( <length-percentage>{1,4} [round <'border-radius'>]? )","invert()":"invert( [<number>|<percentage>]? )","keyframe-block":"<keyframe-selector># { <declaration-list> }","keyframe-selector":"from|to|<percentage [0,100]>|<timeline-range-name> <percentage>","keyframes-name":"<custom-ident>|<string>","lab()":"lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","layer()":"layer( <layer-name> )","layer-name":"<ident> ['.' <ident>]*","lch()":"lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","leader()":"leader( <leader-type> )","leader-type":"dotted|solid|space|<string>","length-percentage":"<length>|<percentage>","light-dark()":"light-dark( <color> , <color> )","line-name-list":"[<line-names>|<name-repeat>]+","line-names":"'[' <custom-ident>* ']'","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"<length>|thin|medium|thick","linear()":"linear( [<number>&&<percentage>{0,2}]# )","linear-color-hint":"<length-percentage>","linear-color-stop":"<color> <color-stop-length>?","linear-easing-function":"linear|<linear()>","linear-gradient()":"linear-gradient( [<linear-gradient-syntax>] )","linear-gradient-syntax":"[[<angle>|<zero>|to <side-or-corner>]||<color-interpolation-method>]? , <color-stop-list>","log()":"log( <calc-sum> , <calc-sum>? )","mask-layer":"<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>","mask-position":"[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?","mask-reference":"none|<image>|<mask-source>","mask-source":"<url>","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( <number>#{6} )","matrix3d()":"matrix3d( <number>#{16} )","max()":"max( <calc-sum># )","media-and":"<media-in-parens> [and <media-in-parens>]+","media-condition":"<media-not>|<media-and>|<media-or>|<media-in-parens>","media-condition-without-or":"<media-not>|<media-and>|<media-in-parens>","media-feature":"( [<mf-plain>|<mf-boolean>|<mf-range>] )","media-in-parens":"( <media-condition> )|<media-feature>|<general-enclosed>","media-not":"not <media-in-parens>","media-or":"<media-in-parens> [or <media-in-parens>]+","media-query":"<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?","media-query-list":"<media-query>#","media-type":"<ident>","mf-boolean":"<mf-name>","mf-name":"<ident>","mf-plain":"<mf-name> : <mf-value>","mf-range":"<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>","mf-value":"<number>|<dimension>|<ident>|<ratio>","min()":"min( <calc-sum># )","minmax()":"minmax( [<length-percentage>|min-content|max-content|auto] , [<length-percentage>|<flex>|min-content|max-content|auto] )","mod()":"mod( <calc-sum> , <calc-sum> )","n-dimension":"<dimension-token>","name-repeat":"repeat( [<integer [1,\u221E]>|auto-fill] , <line-names>+ )","named-color":"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen","namespace-prefix":"<ident>","ndash-dimension":"<dimension-token>","ndashdigit-dimension":"<dimension-token>","ndashdigit-ident":"<ident-token>","ns-prefix":"[<ident-token>|'*']? '|'","number-percentage":"<number>|<percentage>","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","offset-path":"<ray()>|<url>|<basic-shape>","oklab()":"oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","oklch()":"oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","opacity()":"opacity( [<number>|<percentage>]? )","opacity-value":"<number>|<percentage>","outline-line-style":"none|dotted|dashed|solid|double|groove|ridge|inset|outset","outline-radius":"<length>|<percentage>","overflow-position":"unsafe|safe","page-body":"<declaration>? [; <page-body>]?|<page-margin-box> <page-body>","page-margin-box":"<page-margin-box-type> '{' <declaration-list> '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector":"<pseudo-page>+|<ident> <pseudo-page>*","page-selector-list":"[<page-selector>#]?","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",paint:"none|<color>|<url> [none|<color>]?|context-fill|context-stroke","paint()":"paint( <ident> , <declaration-value>? )","paint-box":"<visual-box>|fill-box|stroke-box","palette-identifier":"<dashed-ident>","palette-mix()":"palette-mix( <color-interpolation-method> , [[normal|light|dark|<palette-identifier>|<palette-mix()>]&&<percentage [0,100]>?]#{2} )","path()":"path( <'fill-rule'>? , <string> )","perspective()":"perspective( [<length [0,\u221E]>|none] )","polar-color-space":"hsl|hwb|lch|oklch","polygon()":"polygon( <'fill-rule'>? , [<length-percentage> <length-percentage>]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]?|[[left|right] <length-percentage>]&&[[top|bottom] <length-percentage>]]","position-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|center|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|center|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]","pow()":"pow( <calc-sum> , <calc-sum> )","predefined-rgb":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020","predefined-rgb-params":"<predefined-rgb> [<number>|<percentage>|none]{3}","pseudo-class-selector":"':' <ident-token>|':' <function-token> <any-value> ')'","pseudo-element-selector":"':' <pseudo-class-selector>|<legacy-pseudo-element-selector>","pseudo-page":": [left|right|first|blank]","query-in-parens":"( <container-condition> )|( <size-feature> )|style( <style-query> )|<general-enclosed>",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-extent":"closest-corner|closest-side|farthest-corner|farthest-side","radial-gradient()":"radial-gradient( [<radial-gradient-syntax>] )","radial-gradient-syntax":"[[[<radial-shape>||<radial-size>]? [at <position>]?]||<color-interpolation-method>]? , <color-stop-list>","radial-shape":"circle|ellipse","radial-size":"<radial-extent>|<length [0,\u221E]>|<length-percentage [0,\u221E]>{2}",ratio:"<number [0,\u221E]> [/ <number [0,\u221E]>]?","ray()":"ray( <angle>&&<ray-size>?&&contain?&&[at <position>]? )","ray-size":"closest-side|closest-corner|farthest-side|farthest-corner|sides","rect()":"rect( [<length-percentage>|auto]{4} [round <'border-radius'>]? )","rectangular-color-space":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65","relative-selector":"<combinator>? <complex-selector>","relative-selector-list":"<relative-selector>#","relative-size":"larger|smaller","rem()":"rem( <calc-sum> , <calc-sum> )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [<conic-gradient-syntax>] )","repeating-linear-gradient()":"repeating-linear-gradient( [<linear-gradient-syntax>] )","repeating-radial-gradient()":"repeating-radial-gradient( [<radial-gradient-syntax>] )","reversed-counter-name":"reversed( <counter-name> )","rgb()":"rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rgba()":"rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )","rotate()":"rotate( [<angle>|<zero>] )","rotate3d()":"rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )","rotateX()":"rotateX( [<angle>|<zero>] )","rotateY()":"rotateY( [<angle>|<zero>] )","rotateZ()":"rotateZ( [<angle>|<zero>] )","round()":"round( <rounding-strategy>? , <calc-sum> , <calc-sum> )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( [<number>|<percentage>]? )","scale()":"scale( [<number>|<percentage>]#{1,2} )","scale3d()":"scale3d( [<number>|<percentage>]#{3} )","scaleX()":"scaleX( [<number>|<percentage>] )","scaleY()":"scaleY( [<number>|<percentage>] )","scaleZ()":"scaleZ( [<number>|<percentage>] )","scope-end":"<forgiving-selector-list>","scope-start":"<forgiving-selector-list>","scroll()":"scroll( [<scroller>||<axis>]? )",scroller:"root|nearest|self","scroll-state-feature":"<media-query-list>","scroll-state-in-parens":"( <scroll-state-query> )|( <scroll-state-feature> )|<general-enclosed>","scroll-state-query":"not <scroll-state-in-parens>|<scroll-state-in-parens> [[and <scroll-state-in-parens>]*|[or <scroll-state-in-parens>]*]|<scroll-state-feature>","selector-list":"<complex-selector-list>","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","sepia()":"sepia( [<number>|<percentage>]? )",shadow:"inset?&&<length>{2,4}&&<color>?","shadow-t":"[<length>{2,3}&&<color>?]",shape:"rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )","shape-box":"<visual-box>|margin-box","side-or-corner":"[left|right]||[top|bottom]","sign()":"sign( <calc-sum> )","signed-integer":"<number-token>","signless-integer":"<number-token>","sin()":"sin( <calc-sum> )","single-animation":"<'animation-duration'>||<easing-function>||<'animation-delay'>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]||<single-animation-timeline>","single-animation-composition":"replace|add|accumulate","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|<number>","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|<dashed-ident>|<scroll()>|<view()>","single-transition":"[none|<single-transition-property>]||<time>||<easing-function>||<time>||<transition-behavior-value>","single-transition-property":"all|<custom-ident>",size:"closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}","size-feature":"<mf-plain>|<mf-boolean>|<mf-range>","skew()":"skew( [<angle>|<zero>] , [<angle>|<zero>]? )","skewX()":"skewX( [<angle>|<zero>] )","skewY()":"skewY( [<angle>|<zero>] )","sqrt()":"sqrt( <calc-sum> )","step-position":"jump-start|jump-end|jump-none|jump-both|start|end","step-easing-function":"step-start|step-end|<steps()>","steps()":"steps( <integer> , <step-position>? )","style-feature":"<declaration>","style-in-parens":"( <style-condition> )|( <style-feature> )|<general-enclosed>","style-query":"<style-condition>|<style-feature>","subclass-selector":"<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>","superellipse()":"superellipse( [<number>|infinity|-infinity] )","supports-condition":"not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*","supports-decl":"( <declaration> )","supports-feature":"<supports-decl>|<supports-selector-fn>","supports-in-parens":"( <supports-condition> )|<supports-feature>|<general-enclosed>","supports-selector-fn":"selector( <complex-selector> )",symbol:"<string>|<image>|<custom-ident>","symbols()":"symbols( <symbols-type>? [<string>|<image>]+ )","symbols-type":"cyclic|numeric|alphabetic|symbolic|fixed","system-color":"AccentColor|AccentColorText|ActiveText|ButtonBorder|ButtonFace|ButtonText|Canvas|CanvasText|Field|FieldText|GrayText|Highlight|HighlightText|LinkText|Mark|MarkText|SelectedItem|SelectedItemText|VisitedText","system-family-name":"caption|icon|menu|message-box|small-caption|status-bar","tan()":"tan( <calc-sum> )",target:"<target-counter()>|<target-counters()>|<target-text()>","target-counter()":"target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )","target-counters()":"target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )","target-text()":"target-text( [<string>|<url>] , [content|before|after|first-letter]? )","text-edge":"[text|cap|ex|ideographic|ideographic-ink] [text|alphabetic|ideographic|ideographic-ink]?","time-percentage":"<time>|<percentage>","timeline-range-name":"cover|contain|entry|exit|entry-crossing|exit-crossing","track-breadth":"<length-percentage>|<flex>|min-content|max-content|auto","track-list":"[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?","track-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <track-size>]+ <line-names>? )","track-size":"<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( <length-percentage> )","transform-function":"<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>","transform-list":"<transform-function>+","transition-behavior-value":"normal|allow-discrete","translate()":"translate( <length-percentage> , <length-percentage>? )","translate3d()":"translate3d( <length-percentage> , <length-percentage> , <length> )","translateX()":"translateX( <length-percentage> )","translateY()":"translateY( <length-percentage> )","translateZ()":"translateZ( <length> )","try-size":"most-width|most-height|most-block-size|most-inline-size","try-tactic":"flip-block||flip-inline||flip-start","type-or-unit":"string|color|url|integer|number|length|angle|time|frequency|cap|ch|em|ex|ic|lh|rlh|rem|vb|vi|vw|vh|vmin|vmax|mm|Q|cm|in|pt|pc|px|deg|grad|rad|turn|ms|s|Hz|kHz|%","type-selector":"<wq-name>|<ns-prefix>? '*'","var()":"var( <custom-property-name> , <declaration-value>? )","view()":"view( [<axis>||<'view-timeline-inset'>]? )","viewport-length":"auto|<length-percentage>","visual-box":"content-box|padding-box|border-box","wq-name":"<ns-prefix>? <ident-token>","xywh()":"xywh( <length-percentage>{2} <length-percentage [0,\u221E]>{2} [round <'border-radius'>]? )",xyz:"xyz|xyz-d50|xyz-d65","xyz-params":"<xyz-space> [<number>|<percentage>|none]{3}","-legacy-gradient":"<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>","-legacy-linear-gradient":"-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-repeating-linear-gradient":"-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-linear-gradient-arguments":"[<angle>|<side-or-corner>]? , <color-stop-list>","-legacy-radial-gradient":"-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-repeating-radial-gradient":"-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-radial-gradient-arguments":"[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>","-legacy-radial-gradient-size":"closest-side|closest-corner|farthest-side|farthest-corner|contain|cover","-legacy-radial-gradient-shape":"circle|ellipse","-non-standard-font":"-apple-system-body|-apple-system-headline|-apple-system-subheadline|-apple-system-caption1|-apple-system-caption2|-apple-system-footnote|-apple-system-short-body|-apple-system-short-headline|-apple-system-short-subheadline|-apple-system-short-caption1|-apple-system-short-footnote|-apple-system-tall-body","-non-standard-color":"-moz-ButtonDefault|-moz-ButtonHoverFace|-moz-ButtonHoverText|-moz-CellHighlight|-moz-CellHighlightText|-moz-Combobox|-moz-ComboboxText|-moz-Dialog|-moz-DialogText|-moz-dragtargetzone|-moz-EvenTreeRow|-moz-Field|-moz-FieldText|-moz-html-CellHighlight|-moz-html-CellHighlightText|-moz-mac-accentdarkestshadow|-moz-mac-accentdarkshadow|-moz-mac-accentface|-moz-mac-accentlightesthighlight|-moz-mac-accentlightshadow|-moz-mac-accentregularhighlight|-moz-mac-accentregularshadow|-moz-mac-chrome-active|-moz-mac-chrome-inactive|-moz-mac-focusring|-moz-mac-menuselect|-moz-mac-menushadow|-moz-mac-menutextselect|-moz-MenuHover|-moz-MenuHoverText|-moz-MenuBarText|-moz-MenuBarHoverText|-moz-nativehyperlinktext|-moz-OddTreeRow|-moz-win-communicationstext|-moz-win-mediatext|-moz-activehyperlinktext|-moz-default-background-color|-moz-default-color|-moz-hyperlinktext|-moz-visitedhyperlinktext|-webkit-activelink|-webkit-focus-ring-color|-webkit-link|-webkit-text","-non-standard-image-rendering":"optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast","-non-standard-overflow":"overlay|-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable","-non-standard-size":"intrinsic|min-intrinsic|-webkit-fill-available|-webkit-fit-content|-webkit-min-content|-webkit-max-content|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content","-webkit-gradient()":"-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point>|, <-webkit-gradient-radius> , <-webkit-gradient-point>] [, <-webkit-gradient-radius>]? [, <-webkit-gradient-color-stop>]* )","-webkit-gradient-color-stop":"from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )","-webkit-gradient-point":"[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]","-webkit-gradient-radius":"<length>|<percentage>","-webkit-gradient-type":"linear|radial","-webkit-mask-box-repeat":"repeat|stretch|round","-ms-filter-function-list":"<-ms-filter-function>+","-ms-filter-function":"<-ms-filter-function-progid>|<-ms-filter-function-legacy>","-ms-filter-function-progid":"'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]","-ms-filter-function-legacy":"<ident-token>|<function-token> <any-value>? )",age:"child|young|old","attr-name":"<wq-name>","attr-fallback":"<any-value>",autospace:"no-autospace|[ideograph-alpha||ideograph-numeric||punctuation]||[insert|replace]",bottom:"<length>|auto","generic-voice":"[<age>? <gender> <integer>?]",gender:"male|female|neutral","generic-script-specific":"generic( kai )|generic( fangsong )|generic( nastaliq )","-non-standard-generic-family":"-apple-system|BlinkMacSystemFont","intrinsic-size-keyword":"min-content|max-content|fit-content",left:"<length>|auto","device-cmyk()":"<legacy-device-cmyk-syntax>|<modern-device-cmyk-syntax>","legacy-device-cmyk-syntax":"device-cmyk( <number>#{4} )","modern-device-cmyk-syntax":"device-cmyk( <cmyk-component>{4} [/ [<alpha-value>|none]]? )","cmyk-component":"<number>|<percentage>|none","color-space":"<rectangular-color-space>|<polar-color-space>|<custom-color-space>",right:"<length>|auto","forgiving-selector-list":"<complex-real-selector-list>","forgiving-relative-selector-list":"<relative-real-selector-list>","complex-real-selector-list":"<complex-real-selector>#","simple-selector-list":"<simple-selector>#","relative-real-selector-list":"<relative-real-selector>#","complex-selector-unit":"[<compound-selector>? <pseudo-compound-selector>*]!","complex-real-selector":"<compound-selector> [<combinator>? <compound-selector>]*","relative-real-selector":"<combinator>? <complex-real-selector>","pseudo-compound-selector":"<pseudo-element-selector> <pseudo-class-selector>*","simple-selector":"<type-selector>|<subclass-selector>","legacy-pseudo-element-selector":"':' [before|after|first-line|first-letter]","svg-length":"<percentage>|<length>|<number>","svg-writing-mode":"lr-tb|rl-tb|tb-rl|lr|rl|tb",top:"<length>|auto",x:"<number>",y:"<number>",declaration:"<ident-token> : <declaration-value>? ['!' important]?","declaration-list":"[<declaration>? ';']* <declaration>?",url:"url( <string> <url-modifier>* )|<url-token>","url-modifier":"<ident>|<function-token> <any-value> )","number-zero-one":"<number [0,1]>","number-one-or-greater":"<number [1,\u221E]>","xyz-space":"xyz|xyz-d50|xyz-d65","style-condition":"not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]","-non-standard-display":"-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box","inset-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]",syntax:"'*'|<syntax-component> [<syntax-combinator> <syntax-component>]*|<syntax-string>","syntax-component":"<syntax-single-component> <syntax-multiplier>?|'<' transform-list '>'","syntax-single-component":"'<' <syntax-type-name> '>'|<ident>","syntax-type-name":"angle|color|custom-ident|image|integer|length|length-percentage|number|percentage|resolution|string|time|url|transform-function","syntax-combinator":"'|'","syntax-multiplier":"'#'|'+'","syntax-string":"<string>"},properties:{"--*":"<declaration-value>","-ms-accelerator":"false|true","-ms-block-progression":"tb|rl|bt|lr","-ms-content-zoom-chaining":"none|chained","-ms-content-zoom-limit":"<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>","-ms-content-zoom-limit-max":"<percentage>","-ms-content-zoom-limit-min":"<percentage>","-ms-content-zoom-snap":"<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>","-ms-content-zoom-snap-points":"snapInterval( <percentage> , <percentage> )|snapList( <percentage># )","-ms-content-zoom-snap-type":"none|proximity|mandatory","-ms-content-zooming":"none|zoom","-ms-filter":"<string>","-ms-flow-from":"[none|<custom-ident>]#","-ms-flow-into":"[none|<custom-ident>]#","-ms-grid-columns":"none|<track-list>|<auto-track-list>","-ms-grid-rows":"none|<track-list>|<auto-track-list>","-ms-high-contrast-adjust":"auto|none","-ms-hyphenate-limit-chars":"auto|<integer>{1,3}","-ms-hyphenate-limit-lines":"no-limit|<integer>","-ms-hyphenate-limit-zone":"<percentage>|<length>","-ms-ime-align":"auto|after","-ms-overflow-style":"auto|none|scrollbar|-ms-autohiding-scrollbar","-ms-scroll-chaining":"chained|none","-ms-scroll-limit":"<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>","-ms-scroll-limit-x-max":"auto|<length>","-ms-scroll-limit-x-min":"<length>","-ms-scroll-limit-y-max":"auto|<length>","-ms-scroll-limit-y-min":"<length>","-ms-scroll-rails":"none|railed","-ms-scroll-snap-points-x":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-points-y":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-type":"none|proximity|mandatory","-ms-scroll-snap-x":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>","-ms-scroll-snap-y":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>","-ms-scroll-translation":"none|vertical-to-horizontal","-ms-scrollbar-3dlight-color":"<color>","-ms-scrollbar-arrow-color":"<color>","-ms-scrollbar-base-color":"<color>","-ms-scrollbar-darkshadow-color":"<color>","-ms-scrollbar-face-color":"<color>","-ms-scrollbar-highlight-color":"<color>","-ms-scrollbar-shadow-color":"<color>","-ms-scrollbar-track-color":"<color>","-ms-text-autospace":"none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space","-ms-touch-select":"grippers|none","-ms-user-select":"none|element|text","-ms-wrap-flow":"auto|both|start|end|maximum|clear","-ms-wrap-margin":"<length>","-ms-wrap-through":"wrap|none","-moz-appearance":"none|button|button-arrow-down|button-arrow-next|button-arrow-previous|button-arrow-up|button-bevel|button-focus|caret|checkbox|checkbox-container|checkbox-label|checkmenuitem|dualbutton|groupbox|listbox|listitem|menuarrow|menubar|menucheckbox|menuimage|menuitem|menuitemtext|menulist|menulist-button|menulist-text|menulist-textfield|menupopup|menuradio|menuseparator|meterbar|meterchunk|progressbar|progressbar-vertical|progresschunk|progresschunk-vertical|radio|radio-container|radio-label|radiomenuitem|range|range-thumb|resizer|resizerpanel|scale-horizontal|scalethumbend|scalethumb-horizontal|scalethumbstart|scalethumbtick|scalethumb-vertical|scale-vertical|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|separator|sheet|spinner|spinner-downbutton|spinner-textfield|spinner-upbutton|splitter|statusbar|statusbarpanel|tab|tabpanel|tabpanels|tab-scroll-arrow-back|tab-scroll-arrow-forward|textfield|textfield-multiline|toolbar|toolbarbutton|toolbarbutton-dropdown|toolbargripper|toolbox|tooltip|treeheader|treeheadercell|treeheadersortarrow|treeitem|treeline|treetwisty|treetwistyopen|treeview|-moz-mac-unified-toolbar|-moz-win-borderless-glass|-moz-win-browsertabbar-toolbox|-moz-win-communicationstext|-moz-win-communications-toolbox|-moz-win-exclude-glass|-moz-win-glass|-moz-win-mediatext|-moz-win-media-toolbox|-moz-window-button-box|-moz-window-button-box-maximized|-moz-window-button-close|-moz-window-button-maximize|-moz-window-button-minimize|-moz-window-button-restore|-moz-window-frame-bottom|-moz-window-frame-left|-moz-window-frame-right|-moz-window-titlebar|-moz-window-titlebar-maximized","-moz-binding":"<url>|none","-moz-border-bottom-colors":"<color>+|none","-moz-border-left-colors":"<color>+|none","-moz-border-right-colors":"<color>+|none","-moz-border-top-colors":"<color>+|none","-moz-context-properties":"none|[fill|fill-opacity|stroke|stroke-opacity]#","-moz-float-edge":"border-box|content-box|margin-box|padding-box","-moz-force-broken-image-icon":"0|1","-moz-orient":"inline|block|horizontal|vertical","-moz-outline-radius":"<outline-radius>{1,4} [/ <outline-radius>{1,4}]?","-moz-outline-radius-bottomleft":"<outline-radius>","-moz-outline-radius-bottomright":"<outline-radius>","-moz-outline-radius-topleft":"<outline-radius>","-moz-outline-radius-topright":"<outline-radius>","-moz-stack-sizing":"ignore|stretch-to-fit","-moz-text-blink":"none|blink","-moz-user-focus":"ignore|normal|select-after|select-before|select-menu|select-same|select-all|none","-moz-user-input":"auto|none|enabled|disabled","-moz-user-modify":"read-only|read-write|write-only","-moz-window-dragging":"drag|no-drag","-moz-window-shadow":"default|menu|tooltip|sheet|none","-webkit-appearance":"none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|push-button|radio|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbargripper-horizontal|scrollbargripper-vertical|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|searchfield-cancel-button|searchfield-decoration|searchfield-results-button|searchfield-results-decoration|slider-horizontal|slider-vertical|sliderthumb-horizontal|sliderthumb-vertical|square-button|textarea|textfield|-apple-pay-button","-webkit-border-before":"<'border-width'>||<'border-style'>||<color>","-webkit-border-before-color":"<color>","-webkit-border-before-style":"<'border-style'>","-webkit-border-before-width":"<'border-width'>","-webkit-box-reflect":"[above|below|right|left]? <length>? <image>?","-webkit-line-clamp":"none|<integer>","-webkit-mask":"[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<visual-box>|border|padding|content|text]||[<visual-box>|border|padding|content]]#","-webkit-mask-attachment":"<attachment>#","-webkit-mask-clip":"[<coord-box>|no-clip|border|padding|content|text]#","-webkit-mask-composite":"<composite-style>#","-webkit-mask-image":"<mask-reference>#","-webkit-mask-origin":"[<coord-box>|border|padding|content]#","-webkit-mask-position":"<position>#","-webkit-mask-position-x":"[<length-percentage>|left|center|right]#","-webkit-mask-position-y":"[<length-percentage>|top|center|bottom]#","-webkit-mask-repeat":"<repeat-style>#","-webkit-mask-repeat-x":"repeat|no-repeat|space|round","-webkit-mask-repeat-y":"repeat|no-repeat|space|round","-webkit-mask-size":"<bg-size>#","-webkit-overflow-scrolling":"auto|touch","-webkit-tap-highlight-color":"<color>","-webkit-text-fill-color":"<color>","-webkit-text-stroke":"<length>||<color>","-webkit-text-stroke-color":"<color>","-webkit-text-stroke-width":"<length>","-webkit-touch-callout":"default|none","-webkit-user-modify":"read-only|read-write|read-write-plaintext-only","-webkit-user-select":"auto|none|text|all","accent-color":"auto|<color>","align-content":"normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>","align-items":"normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]|anchor-center","align-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>|anchor-center","align-tracks":"[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#","alignment-baseline":"auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical",all:"initial|inherit|unset|revert|revert-layer","anchor-name":"none|<dashed-ident>#","anchor-scope":"none|all|<dashed-ident>#",animation:"<single-animation>#","animation-composition":"<single-animation-composition>#","animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"[auto|<time [0s,\u221E]>]#","animation-fill-mode":"<single-animation-fill-mode>#","animation-iteration-count":"<single-animation-iteration-count>#","animation-name":"[none|<keyframes-name>]#","animation-play-state":"<single-animation-play-state>#","animation-range":"[<'animation-range-start'> <'animation-range-end'>?]#","animation-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","animation-timeline":"<single-animation-timeline>#","animation-timing-function":"<easing-function>#","animation-trigger":"[none|[<dashed-ident> <animation-action>+]+]#",appearance:"none|auto|<compat-auto>|<compat-special>","aspect-ratio":"auto||<ratio>","backdrop-filter":"none|<filter-value-list>","backface-visibility":"visible|hidden",background:"<bg-layer>#? , <final-bg-layer>","background-attachment":"<attachment>#","background-blend-mode":"<blend-mode>#","background-clip":"<bg-clip>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<visual-box>#","background-position":"<bg-position>#","background-position-x":"[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#","background-position-y":"[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","baseline-shift":"baseline|sub|super|<svg-length>","baseline-source":"auto|first|last","block-size":"<'width'>",border:"<line-width>||<line-style>||<color>","border-block":"<'border-block-start'>","border-block-color":"<'border-top-color'>{1,2}","border-block-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-end-color":"<'border-top-color'>","border-block-end-style":"<'border-top-style'>","border-block-end-width":"<'border-top-width'>","border-block-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-start-color":"<'border-top-color'>","border-block-start-style":"<'border-top-style'>","border-block-start-width":"<'border-top-width'>","border-block-style":"<'border-top-style'>{1,2}","border-block-width":"<'border-top-width'>{1,2}","border-bottom":"<line-width>||<line-style>||<color>","border-bottom-color":"<'border-top-color'>","border-bottom-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-bottom-style":"<line-style>","border-bottom-width":"<line-width>","border-collapse":"separate|collapse","border-color":"<color>{1,4}","border-end-end-radius":"<'border-top-left-radius'>","border-end-start-radius":"<'border-top-left-radius'>","border-image":"<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>","border-image-outset":"[<length [0,\u221E]>|<number [0,\u221E]>]{1,4}","border-image-repeat":"[stretch|repeat|round|space]{1,2}","border-image-slice":"[<number [0,\u221E]>|<percentage [0,\u221E]>]{1,4}&&fill?","border-image-source":"none|<image>","border-image-width":"[<length-percentage [0,\u221E]>|<number [0,\u221E]>|auto]{1,4}","border-inline":"<'border-block-start'>","border-inline-color":"<'border-top-color'>{1,2}","border-inline-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-end-color":"<'border-top-color'>","border-inline-end-style":"<'border-top-style'>","border-inline-end-width":"<'border-top-width'>","border-inline-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-start-color":"<'border-top-color'>","border-inline-start-style":"<'border-top-style'>","border-inline-start-width":"<'border-top-width'>","border-inline-style":"<'border-top-style'>{1,2}","border-inline-width":"<'border-top-width'>{1,2}","border-left":"<line-width>||<line-style>||<color>","border-left-color":"<color>","border-left-style":"<line-style>","border-left-width":"<line-width>","border-radius":"<length-percentage [0,\u221E]>{1,4} [/ <length-percentage [0,\u221E]>{1,4}]?","border-right":"<line-width>||<line-style>||<color>","border-right-color":"<color>","border-right-style":"<line-style>","border-right-width":"<line-width>","border-spacing":"<length>{1,2}","border-start-end-radius":"<'border-top-left-radius'>","border-start-start-radius":"<'border-top-left-radius'>","border-style":"<line-style>{1,4}","border-top":"<line-width>||<line-style>||<color>","border-top-color":"<color>","border-top-left-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-right-radius":"<length-percentage [0,\u221E]>{1,2}","border-top-style":"<line-style>","border-top-width":"<line-width>","border-width":"<line-width>{1,4}",bottom:"auto|<length-percentage>|<anchor()>|<anchor-size()>","box-align":"start|center|end|baseline|stretch","box-decoration-break":"slice|clone","box-direction":"normal|reverse|inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single|multiple","box-ordinal-group":"<integer>","box-orient":"horizontal|vertical|inline-axis|block-axis|inherit","box-pack":"start|center|end|justify","box-shadow":"none|<shadow>#","box-sizing":"content-box|border-box","break-after":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-before":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-inside":"auto|avoid|avoid-page|avoid-column|avoid-region","caption-side":"top|bottom",caret:"<'caret-color'>||<'caret-animation'>||<'caret-shape'>","caret-animation":"auto|manual","caret-color":"auto|<color>","caret-shape":"auto|bar|block|underscore",clear:"none|left|right|both|inline-start|inline-end",clip:"<shape>|auto","clip-path":"<clip-source>|[<basic-shape>||<geometry-box>]|none","clip-rule":"nonzero|evenodd",color:"<color>","color-interpolation-filters":"auto|sRGB|linearRGB","color-scheme":"normal|[light|dark|<custom-ident>]+&&only?","column-count":"<integer>|auto","column-fill":"auto|balance","column-gap":"normal|<length-percentage>","column-height":"auto|<length [0,\u221E]>","column-rule":"<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>","column-rule-color":"<color>","column-rule-style":"<'border-style'>","column-rule-width":"<'border-width'>","column-span":"none|all","column-width":"auto|<length [0,\u221E]>","column-wrap":"auto|nowrap|wrap",columns:"[<'column-width'>||<'column-count'>] [/ <'column-height'>]?",contain:"none|strict|content|[[size||inline-size]||layout||style||paint]","contain-intrinsic-block-size":"auto? [none|<length>]","contain-intrinsic-height":"auto? [none|<length>]","contain-intrinsic-inline-size":"auto? [none|<length>]","contain-intrinsic-size":"[auto? [none|<length>]]{1,2}","contain-intrinsic-width":"auto? [none|<length>]",container:"<'container-name'> [/ <'container-type'>]?","container-name":"none|<custom-ident>+","container-type":"normal||[size|inline-size]",content:"normal|none|[<content-replacement>|<content-list>] [/ [<string>|<counter>|<attr()>]+]?","content-visibility":"visible|auto|hidden","corner-block-end-shape":"<corner-shape-value>{1,2}","corner-block-start-shape":"<corner-shape-value>{1,2}","corner-bottom-shape":"<corner-shape-value>{1,2}","corner-bottom-left-shape":"<corner-shape-value>","corner-bottom-right-shape":"<corner-shape-value>","corner-end-end-shape":"<corner-shape-value>","corner-end-start-shape":"<corner-shape-value>","corner-inline-end-shape":"<corner-shape-value>{1,2}","corner-inline-start-shape":"<corner-shape-value>{1,2}","corner-left-shape":"<corner-shape-value>{1,2}","corner-right-shape":"<corner-shape-value>{1,2}","corner-shape":"<corner-shape-value>{1,4}","corner-start-start-shape":"<corner-shape-value>","corner-start-end-shape":"<corner-shape-value>","corner-top-shape":"<corner-shape-value>{1,2}","corner-top-left-shape":"<corner-shape-value>","corner-top-right-shape":"<corner-shape-value>","counter-increment":"[<counter-name> <integer>?]+|none","counter-reset":"[<counter-name> <integer>?|<reversed-counter-name> <integer>?]+|none","counter-set":"[<counter-name> <integer>?]+|none",cursor:"[[<url> [<x> <y>]? ,]* [auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing|hand|-webkit-grab|-webkit-grabbing|-webkit-zoom-in|-webkit-zoom-out|-moz-grab|-moz-grabbing|-moz-zoom-in|-moz-zoom-out]]",cx:"<length>|<percentage>",cy:"<length>|<percentage>",d:"none|path( <string> )",direction:"ltr|rtl",display:"[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>","dominant-baseline":"auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge","dynamic-range-limit":"standard|no-limit|constrained|<dynamic-range-limit-mix()>","empty-cells":"show|hide","field-sizing":"content|fixed",fill:"<paint>","fill-opacity":"<number-zero-one>|<percentage>","fill-rule":"nonzero|evenodd",filter:"none|<filter-value-list>|<-ms-filter-function-list>",flex:"none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]","flex-basis":"content|<'width'>","flex-direction":"row|row-reverse|column|column-reverse","flex-flow":"<'flex-direction'>||<'flex-wrap'>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap|wrap|wrap-reverse",float:"left|right|none|inline-start|inline-end","flood-color":"<color>","flood-opacity":"<'opacity'>",font:"[[<'font-style'>||<font-variant-css2>||<'font-weight'>||<font-width-css3>]? <'font-size'> [/ <'line-height'>]? <'font-family'>#]|<system-family-name>|<-non-standard-font>","font-family":"[<family-name>|<generic-family>]#","font-feature-settings":"normal|<feature-tag-value>#","font-kerning":"auto|normal|none","font-language-override":"normal|<string>","font-optical-sizing":"auto|none","font-palette":"normal|light|dark|<palette-identifier>|<palette-mix()>","font-size":"<absolute-size>|<relative-size>|<length-percentage [0,\u221E]>|math","font-size-adjust":"none|[ex-height|cap-height|ch-width|ic-width|ic-height]? [from-font|<number>]","font-smooth":"auto|never|always|<absolute-size>|<length>","font-stretch":"<font-stretch-absolute>","font-style":"normal|italic|oblique <angle>?","font-synthesis":"none|[weight||style||small-caps||position]","font-synthesis-position":"auto|none","font-synthesis-small-caps":"auto|none","font-synthesis-style":"auto|none","font-synthesis-weight":"auto|none","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-alternates":"normal|[stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )]","font-variant-caps":"normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","font-variant-east-asian":"normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-emoji":"normal|text|emoji|unicode","font-variant-ligatures":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]","font-variant-numeric":"normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]","font-variant-position":"normal|sub|super","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>|bolder|lighter","font-width":"normal|<percentage [0,\u221E]>|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","forced-color-adjust":"auto|none|preserve-parent-color",gap:"<'row-gap'> <'column-gap'>?",grid:"<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>","grid-area":"<grid-line> [/ <grid-line>]{0,3}","grid-auto-columns":"<track-size>+","grid-auto-flow":"[row|column]||dense","grid-auto-rows":"<track-size>+","grid-column":"<grid-line> [/ <grid-line>]?","grid-column-end":"<grid-line>","grid-column-gap":"<length-percentage>","grid-column-start":"<grid-line>","grid-gap":"<'grid-row-gap'> <'grid-column-gap'>?","grid-row":"<grid-line> [/ <grid-line>]?","grid-row-end":"<grid-line>","grid-row-gap":"<length-percentage>","grid-row-start":"<grid-line>","grid-template":"none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?","grid-template-areas":"none|<string>+","grid-template-columns":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","grid-template-rows":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","hanging-punctuation":"none|[first||[force-end|allow-end]||last]",height:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","hyphenate-character":"auto|<string>","hyphenate-limit-chars":"[auto|<integer>]{1,3}",hyphens:"none|manual|auto","image-orientation":"from-image|<angle>|[<angle>? flip]","image-rendering":"auto|crisp-edges|pixelated|smooth|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>","image-resolution":"[from-image||<resolution>]&&snap?","ime-mode":"auto|normal|active|inactive|disabled","initial-letter":"normal|[<number> <integer>?]","initial-letter-align":"[auto|alphabetic|hanging|ideographic]","inline-size":"<'width'>",inset:"<'top'>{1,4}","inset-block":"<'top'>{1,2}","inset-block-end":"<'top'>","inset-block-start":"<'top'>","inset-inline":"<'top'>{1,2}","inset-inline-end":"<'top'>","inset-inline-start":"<'top'>","interpolate-size":"numeric-only|allow-keywords",isolation:"auto|isolate",interactivity:"auto|inert","interest-delay":"<'interest-delay-start'>{1,2}","interest-delay-end":"normal|<time>","interest-delay-start":"normal|<time>","justify-content":"normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]","justify-items":"normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]|anchor-center","justify-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|anchor-center","justify-tracks":"[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",left:"auto|<length-percentage>|<anchor()>|<anchor-size()>","letter-spacing":"normal|<length-percentage>","lighting-color":"<color>","line-break":"auto|loose|normal|strict|anywhere","line-clamp":"none|<integer>","line-height":"normal|<number>|<length>|<percentage>","line-height-step":"<length>","list-style":"<'list-style-type'>||<'list-style-position'>||<'list-style-image'>","list-style-image":"<image>|none","list-style-position":"inside|outside","list-style-type":"<counter-style>|<string>|none",margin:"<'margin-top'>{1,4}","margin-block":"<'margin-top'>{1,2}","margin-block-end":"<'margin-top'>","margin-block-start":"<'margin-top'>","margin-bottom":"<length-percentage>|auto|<anchor-size()>","margin-inline":"<'margin-top'>{1,2}","margin-inline-end":"<'margin-top'>","margin-inline-start":"<'margin-top'>","margin-left":"<length-percentage>|auto|<anchor-size()>","margin-right":"<length-percentage>|auto|<anchor-size()>","margin-top":"<length-percentage>|auto|<anchor-size()>","margin-trim":"none|in-flow|all",marker:"none|<url>","marker-end":"none|<url>","marker-mid":"none|<url>","marker-start":"none|<url>",mask:"<mask-layer>#","mask-border":"<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>","mask-border-mode":"luminance|alpha","mask-border-outset":"[<length>|<number>]{1,4}","mask-border-repeat":"[stretch|repeat|round|space]{1,2}","mask-border-slice":"<number-percentage>{1,4} fill?","mask-border-source":"none|<image>","mask-border-width":"[<length-percentage>|<number>|auto]{1,4}","mask-clip":"[<coord-box>|no-clip]#","mask-composite":"<compositing-operator>#","mask-image":"<mask-reference>#","mask-mode":"<masking-mode>#","mask-origin":"<coord-box>#","mask-position":"<position>#","mask-repeat":"<repeat-style>#","mask-size":"<bg-size>#","mask-type":"luminance|alpha","masonry-auto-flow":"[pack|next]||[definite-first|ordered]","math-depth":"auto-add|add( <integer> )|<integer>","math-shift":"normal|compact","math-style":"normal|compact","max-block-size":"<'max-width'>","max-height":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","max-inline-size":"<'max-width'>","max-lines":"none|<integer>","max-width":"none|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-block-size":"<'min-width'>","min-height":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","min-inline-size":"<'min-width'>","min-width":"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","mix-blend-mode":"<blend-mode>|plus-darker|plus-lighter","object-fit":"fill|contain|cover|none|scale-down","object-position":"<position>","object-view-box":"none|<basic-shape-rect>",offset:"[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?","offset-anchor":"auto|<position>","offset-distance":"<length-percentage>","offset-path":"none|<offset-path>||<coord-box>","offset-position":"normal|auto|<position>","offset-rotate":"[auto|reverse]||<angle>",opacity:"<opacity-value>",order:"<integer>",orphans:"<integer>",outline:"<'outline-width'>||<'outline-style'>||<'outline-color'>","outline-color":"auto|<color>","outline-offset":"<length>","outline-style":"auto|<outline-line-style>","outline-width":"<line-width>",overflow:"[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>","overflow-anchor":"auto|none","overflow-block":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-clip-box":"padding-box|content-box","overflow-clip-margin":"<visual-box>||<length [0,\u221E]>","overflow-inline":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-wrap":"normal|break-word|anywhere","overflow-x":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>","overflow-y":"visible|hidden|clip|scroll|auto|<-non-standard-overflow>",overlay:"none|auto","overscroll-behavior":"[contain|none|auto]{1,2}","overscroll-behavior-block":"contain|none|auto","overscroll-behavior-inline":"contain|none|auto","overscroll-behavior-x":"contain|none|auto","overscroll-behavior-y":"contain|none|auto",padding:"<'padding-top'>{1,4}","padding-block":"<'padding-top'>{1,2}","padding-block-end":"<'padding-top'>","padding-block-start":"<'padding-top'>","padding-bottom":"<length-percentage [0,\u221E]>","padding-inline":"<'padding-top'>{1,2}","padding-inline-end":"<'padding-top'>","padding-inline-start":"<'padding-top'>","padding-left":"<length-percentage [0,\u221E]>","padding-right":"<length-percentage [0,\u221E]>","padding-top":"<length-percentage [0,\u221E]>",page:"auto|<custom-ident>","page-break-after":"auto|always|avoid|left|right|recto|verso","page-break-before":"auto|always|avoid|left|right|recto|verso","page-break-inside":"auto|avoid","paint-order":"normal|[fill||stroke||markers]",perspective:"none|<length>","perspective-origin":"<position>","place-content":"<'align-content'> <'justify-content'>?","place-items":"<'align-items'> <'justify-items'>?","place-self":"<'align-self'> <'justify-self'>?","pointer-events":"auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",position:"static|relative|absolute|sticky|fixed|-webkit-sticky","position-anchor":"auto|none|<anchor-name>","position-area":"none|<position-area>","position-try":"<'position-try-order'>? <'position-try-fallbacks'>","position-try-fallbacks":"none|[[<dashed-ident>||<try-tactic>]|<'position-area'>]#","position-try-order":"normal|<try-size>","position-visibility":"always|[anchors-valid||anchors-visible||no-overflow]","print-color-adjust":"economy|exact",quotes:"none|auto|[<string> <string>]+",r:"<length>|<percentage>","reading-flow":"normal|source-order|flex-visual|flex-flow|grid-rows|grid-columns|grid-order","reading-order":"<integer>",resize:"none|both|horizontal|vertical|block|inline",right:"auto|<length-percentage>|<anchor()>|<anchor-size()>",rotate:"none|<angle>|[x|y|z|<number>{3}]&&<angle>","row-gap":"normal|<length-percentage>","ruby-align":"start|center|space-between|space-around","ruby-merge":"separate|collapse|auto","ruby-overhang":"auto|none","ruby-position":"[alternate||[over|under]]|inter-character",rx:"<length>|<percentage>",ry:"<length>|<percentage>",scale:"none|[<number>|<percentage>]{1,3}","scroll-behavior":"auto|smooth","scroll-initial-target":"none|nearest","scroll-margin":"<length>{1,4}","scroll-margin-block":"<length>{1,2}","scroll-margin-block-end":"<length>","scroll-margin-block-start":"<length>","scroll-margin-bottom":"<length>","scroll-margin-inline":"<length>{1,2}","scroll-margin-inline-end":"<length>","scroll-margin-inline-start":"<length>","scroll-margin-left":"<length>","scroll-margin-right":"<length>","scroll-margin-top":"<length>","scroll-marker-group":"none|before|after","scroll-padding":"[auto|<length-percentage>]{1,4}","scroll-padding-block":"[auto|<length-percentage>]{1,2}","scroll-padding-block-end":"auto|<length-percentage>","scroll-padding-block-start":"auto|<length-percentage>","scroll-padding-bottom":"auto|<length-percentage>","scroll-padding-inline":"[auto|<length-percentage>]{1,2}","scroll-padding-inline-end":"auto|<length-percentage>","scroll-padding-inline-start":"auto|<length-percentage>","scroll-padding-left":"auto|<length-percentage>","scroll-padding-right":"auto|<length-percentage>","scroll-padding-top":"auto|<length-percentage>","scroll-snap-align":"[none|start|end|center]{1,2}","scroll-snap-coordinate":"none|<position>#","scroll-snap-destination":"<position>","scroll-snap-points-x":"none|repeat( <length-percentage> )","scroll-snap-points-y":"none|repeat( <length-percentage> )","scroll-snap-stop":"normal|always","scroll-snap-type":"none|[x|y|block|inline|both] [mandatory|proximity]?","scroll-snap-type-x":"none|mandatory|proximity","scroll-snap-type-y":"none|mandatory|proximity","scroll-target-group":"none|auto","scroll-timeline":"[<'scroll-timeline-name'> <'scroll-timeline-axis'>?]#","scroll-timeline-axis":"[block|inline|x|y]#","scroll-timeline-name":"[none|<dashed-ident>]#","scrollbar-color":"auto|<color>{2}","scrollbar-gutter":"auto|stable&&both-edges?","scrollbar-width":"auto|thin|none","shape-image-threshold":"<opacity-value>","shape-margin":"<length-percentage>","shape-outside":"none|[<shape-box>||<basic-shape>]|<image>","shape-rendering":"auto|optimizeSpeed|crispEdges|geometricPrecision","speak-as":"normal|spell-out||digits||[literal-punctuation|no-punctuation]","stop-color":"<'color'>","stop-opacity":"<'opacity'>",stroke:"<paint>","stroke-color":"<color>","stroke-dasharray":"none|[<svg-length>+]#","stroke-dashoffset":"<svg-length>","stroke-linecap":"butt|round|square","stroke-linejoin":"miter|round|bevel","stroke-miterlimit":"<number-one-or-greater>","stroke-opacity":"<'opacity'>","stroke-width":"<svg-length>","tab-size":"<integer>|<length>","table-layout":"auto|fixed","text-align":"start|end|left|right|center|justify|match-parent","text-align-last":"auto|start|end|left|right|center|justify","text-anchor":"start|middle|end","text-autospace":"normal|<autospace>|auto","text-box":"normal|<'text-box-trim'>||<'text-box-edge'>","text-box-edge":"auto|<text-edge>","text-box-trim":"none|trim-start|trim-end|trim-both","text-combine-upright":"none|all|[digits <integer>?]","text-decoration":"<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>","text-decoration-color":"<color>","text-decoration-inset":"<length>{1,2}|auto","text-decoration-line":"none|[underline||overline||line-through||blink]|spelling-error|grammar-error","text-decoration-skip":"none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]","text-decoration-skip-ink":"auto|all|none","text-decoration-style":"solid|double|dotted|dashed|wavy","text-decoration-thickness":"auto|from-font|<length>|<percentage>","text-emphasis":"<'text-emphasis-style'>||<'text-emphasis-color'>","text-emphasis-color":"<color>","text-emphasis-position":"auto|[over|under]&&[right|left]?","text-emphasis-style":"none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>","text-indent":"<length-percentage>&&hanging?&&each-line?","text-justify":"auto|inter-character|inter-word|none","text-orientation":"mixed|upright|sideways","text-overflow":"[clip|ellipsis|<string>]{1,2}","text-rendering":"auto|optimizeSpeed|optimizeLegibility|geometricPrecision","text-shadow":"none|<shadow-t>#","text-size-adjust":"none|auto|<percentage>","text-spacing-trim":"space-all|normal|space-first|trim-start","text-transform":"none|[capitalize|uppercase|lowercase]||full-width||full-size-kana|math-auto","text-underline-offset":"auto|<length>|<percentage>","text-underline-position":"auto|from-font|[under||[left|right]]","text-wrap":"<'text-wrap-mode'>||<'text-wrap-style'>","text-wrap-mode":"wrap|nowrap","text-wrap-style":"auto|balance|stable|pretty","timeline-scope":"none|<dashed-ident>#","timeline-trigger":"none|[<'timeline-trigger-name'> <'timeline-trigger-source'> <'timeline-trigger-range'> ['/' <'timeline-trigger-exit-range'>]?]#","timeline-trigger-name":"none|<dashed-ident>#","timeline-trigger-exit-range":"[<'timeline-trigger-exit-range-start'> <'timeline-trigger-exit-range-end'>?]#","timeline-trigger-exit-range-end":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-exit-range-start":"[auto|normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range":"[<'timeline-trigger-range-start'> <'timeline-trigger-range-end'>?]#","timeline-trigger-range-end":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-range-start":"[normal|<length-percentage>|<timeline-range-name> <length-percentage>?]#","timeline-trigger-source":"<single-animation-timeline>#",top:"auto|<length-percentage>|<anchor()>|<anchor-size()>","touch-action":"auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",transform:"none|<transform-list>","transform-box":"content-box|border-box|fill-box|stroke-box|view-box","transform-origin":"[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?","transform-style":"flat|preserve-3d",transition:"<single-transition>#","transition-behavior":"<transition-behavior-value>#","transition-delay":"<time>#","transition-duration":"<time>#","transition-property":"none|<single-transition-property>#","transition-timing-function":"<easing-function>#",translate:"none|<length-percentage> [<length-percentage> <length>?]?","trigger-scope":"none|all|<dashed-ident>#","unicode-bidi":"normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext","user-select":"auto|text|none|all","vector-effect":"none|non-scaling-stroke|non-scaling-size|non-rotation|fixed-position","vertical-align":"baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>","view-timeline":"[<'view-timeline-name'> [<'view-timeline-axis'>||<'view-timeline-inset'>]?]#","view-timeline-axis":"[block|inline|x|y]#","view-timeline-inset":"[[auto|<length-percentage>]{1,2}]#","view-timeline-name":"[none|<dashed-ident>]#","view-transition-class":"none|<custom-ident>+","view-transition-name":"none|<custom-ident>|match-element",visibility:"visible|hidden|collapse","white-space":"normal|pre|pre-wrap|pre-line|<'white-space-collapse'>||<'text-wrap-mode'>","white-space-collapse":"collapse|preserve|preserve-breaks|preserve-spaces|break-spaces",widows:"<integer>",width:"auto|<length-percentage [0,\u221E]>|min-content|max-content|fit-content|fit-content( <length-percentage [0,\u221E]> )|<calc-size()>|<anchor-size()>|stretch|<-non-standard-size>","will-change":"auto|<animateable-feature>#","word-break":"normal|break-all|keep-all|break-word|auto-phrase","word-spacing":"normal|<length>","word-wrap":"normal|break-word","writing-mode":"horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>",x:"<length>|<percentage>",y:"<length>|<percentage>","z-index":"auto|<integer>",zoom:"normal|reset|<number [0,\u221E]>||<percentage [0,\u221E]>","-moz-background-clip":"padding|border","-moz-border-radius-bottomleft":"<'border-bottom-left-radius'>","-moz-border-radius-bottomright":"<'border-bottom-right-radius'>","-moz-border-radius-topleft":"<'border-top-left-radius'>","-moz-border-radius-topright":"<'border-bottom-right-radius'>","-moz-control-character-visibility":"visible|hidden","-moz-osx-font-smoothing":"auto|grayscale","-moz-user-select":"none|text|all|-moz-none","-ms-flex-align":"start|end|center|baseline|stretch","-ms-flex-item-align":"auto|start|end|center|baseline|stretch","-ms-flex-line-pack":"start|end|center|justify|distribute|stretch","-ms-flex-negative":"<'flex-shrink'>","-ms-flex-pack":"start|end|center|justify|distribute","-ms-flex-order":"<integer>","-ms-flex-positive":"<'flex-grow'>","-ms-flex-preferred-size":"<'flex-basis'>","-ms-interpolation-mode":"nearest-neighbor|bicubic","-ms-grid-column-align":"start|end|center|stretch","-ms-grid-row-align":"start|end|center|stretch","-ms-hyphenate-limit-last":"none|always|column|page|spread","-webkit-background-clip":"[<visual-box>|border|padding|content|text]#","-webkit-column-break-after":"always|auto|avoid","-webkit-column-break-before":"always|auto|avoid","-webkit-column-break-inside":"always|auto|avoid","-webkit-font-smoothing":"auto|none|antialiased|subpixel-antialiased","-webkit-mask-box-image":"[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?","-webkit-print-color-adjust":"economy|exact","-webkit-text-security":"none|circle|disc|square","-webkit-user-drag":"none|element|auto",behavior:"<url>+",cue:"<'cue-before'> <'cue-after'>?","cue-after":"<url> <decibel>?|none","cue-before":"<url> <decibel>?|none","glyph-orientation-horizontal":"<angle>","glyph-orientation-vertical":"<angle>",kerning:"auto|<svg-length>",pause:"<'pause-before'> <'pause-after'>?","pause-after":"<time>|none|x-weak|weak|medium|strong|x-strong","pause-before":"<time>|none|x-weak|weak|medium|strong|x-strong","position-try-options":"<'position-try-fallbacks'>",rest:"<'rest-before'> <'rest-after'>?","rest-after":"<time>|none|x-weak|weak|medium|strong|x-strong","rest-before":"<time>|none|x-weak|weak|medium|strong|x-strong",speak:"auto|never|always","voice-balance":"<number>|left|center|right|leftwards|rightwards","voice-duration":"auto|<time>","voice-family":"[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve","voice-pitch":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-range":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-rate":"[normal|x-slow|slow|medium|fast|x-fast]||<percentage>","voice-stress":"normal|strong|moderate|none|reduced","voice-volume":"silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]","white-space-trim":"none|discard-before||discard-after||discard-inner"},atrules:{charset:{prelude:"<string>",descriptors:null},"counter-style":{prelude:"<counter-style-name>",descriptors:{"additive-symbols":"[<integer [0,\u221E]>&&<symbol>]#",fallback:"<counter-style-name>",negative:"<symbol> <symbol>?",pad:"<integer [0,\u221E]>&&<symbol>",prefix:"<symbol>",range:"[[<integer>|infinite]{2}]#|auto","speak-as":"auto|bullets|numbers|words|spell-out|<counter-style-name>",suffix:"<symbol>",symbols:"<symbol>+",system:"cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"}},container:{prelude:"[<container-name>]? <container-condition>",descriptors:null},document:{prelude:"[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",descriptors:null},"font-face":{prelude:null,descriptors:{"ascent-override":"normal|<percentage>","descent-override":"normal|<percentage>","font-display":"auto|block|swap|fallback|optional","font-family":"<family-name>","font-feature-settings":"normal|<feature-tag-value>#","font-stretch":"<font-stretch-absolute>{1,2}","font-style":"normal|italic|oblique <angle>{0,2}","font-variation-settings":"normal|[<string> <number>]#","font-weight":"<font-weight-absolute>{1,2}","line-gap-override":"normal|<percentage>","size-adjust":"<percentage>",src:"[<url> [format( <string># )]?|local( <family-name> )]#","unicode-range":"<urange>#"}},"font-feature-values":{prelude:"<family-name>#",descriptors:null},"font-palette-values":{prelude:"<dashed-ident>",descriptors:{"base-palette":"light|dark|<integer [0,\u221E]>","font-family":"<family-name>#","override-colors":"[<integer [0,\u221E]> <color>]#"}},import:{prelude:"[<string>|<url>] [layer|layer( <layer-name> )]? [supports( [<supports-condition>|<declaration>] )]? <media-query-list>?",descriptors:null},keyframes:{prelude:"<keyframes-name>",descriptors:null},layer:{prelude:"[<layer-name>#|<layer-name>?]",descriptors:null},media:{prelude:"<media-query-list>",descriptors:null},namespace:{prelude:"<namespace-prefix>? [<string>|<url>]",descriptors:null},page:{prelude:"<page-selector-list>",descriptors:{bleed:"auto|<length>",marks:"none|[crop||cross]","page-orientation":"upright|rotate-left|rotate-right",size:"<length [0,\u221E]>{1,2}|auto|[<page-size>||[portrait|landscape]]"}},"position-try":{prelude:"<dashed-ident>",descriptors:{top:"<'top'>",left:"<'left'>",bottom:"<'bottom'>",right:"<'right'>","inset-block-start":"<'inset-block-start'>","inset-block-end":"<'inset-block-end'>","inset-inline-start":"<'inset-inline-start'>","inset-inline-end":"<'inset-inline-end'>","inset-block":"<'inset-block'>","inset-inline":"<'inset-inline'>",inset:"<'inset'>","margin-top":"<'margin-top'>","margin-left":"<'margin-left'>","margin-bottom":"<'margin-bottom'>","margin-right":"<'margin-right'>","margin-block-start":"<'margin-block-start'>","margin-block-end":"<'margin-block-end'>","margin-inline-start":"<'margin-inline-start'>","margin-inline-end":"<'margin-inline-end'>",margin:"<'margin'>","margin-block":"<'margin-block'>","margin-inline":"<'margin-inline'>",width:"<'width'>",height:"<'height'>","min-width":"<'min-width'>","min-height":"<'min-height'>","max-width":"<'max-width'>","max-height":"<'max-height'>","block-size":"<'block-size'>","inline-size":"<'inline-size'>","min-block-size":"<'min-block-size'>","min-inline-size":"<'min-inline-size'>","max-block-size":"<'max-block-size'>","max-inline-size":"<'max-inline-size'>","align-self":"<'align-self'>|anchor-center","justify-self":"<'justify-self'>|anchor-center"}},property:{prelude:"<custom-property-name>",descriptors:{inherits:"true|false","initial-value":"<declaration-value>?",syntax:"<string>"}},scope:{prelude:"[( <scope-start> )]? [to ( <scope-end> )]?",descriptors:null},"starting-style":{prelude:null,descriptors:null},supports:{prelude:"<supports-condition>",descriptors:null},"view-transition":{prelude:null,descriptors:{navigation:"auto|none",types:"none|<custom-ident>+"}},"font-features-values":{prelude:"[<string>|<custom-ident>]+",descriptors:{"font-display":"auto|block|swap|fallback|optional"}}}}});var Fp={};Se(Fp,{generate:()=>NP,name:()=>RP,parse:()=>Ip,structure:()=>zP});function Al(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Or||r===Qn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)Ut(this.charCodeAt(n))||this.error("Integer is expected",n)}function Ei(e){return Al.call(this,0,e)}function Co(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case El:n="N is expected";break;case Qn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Tp(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(Or,e)||this.isDelim(Qn,e)){t=this.isDelim(Or,e)?Or:Qn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Ei.call(this,Ko))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==Or&&n!==Qn&&this.error("Number sign is expected")),Ei.call(this,t!==0),t===Qn?"-"+this.consume(10):this.consume(10)}function Ip(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Ei.call(this,DP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Qn))switch(t="-1",Co.call(this,1,El),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Tp.call(this);break;case 3:Co.call(this,2,Qn),this.next(),this.skipSC(),Ei.call(this,Ko),n="-"+this.consume(10);break;default:Co.call(this,2,Qn),Al.call(this,3,Ko),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Or)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(Or)&&(r=1,this.next()),Co.call(this,0,El),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Tp.call(this);break;case 2:Co.call(this,1,Qn),this.next(),this.skipSC(),Ei.call(this,Ko),n="-"+this.consume(10);break;default:Co.call(this,1,Qn),Al.call(this,2,Ko),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===Or||r===Qn,i=this.tokenStart+o;for(;i<this.tokenEnd&&Ut(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),Co.call(this,i-this.tokenStart,El),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Tp.call(this)):(Co.call(this,i-this.tokenStart+1,Qn),i+2===this.tokenEnd?(this.next(),this.skipSC(),Ei.call(this,Ko),n="-"+this.consume(10)):(Al.call(this,i-this.tokenStart+2,Ko),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Or&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===Or&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function NP(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 Or,Qn,El,Ko,DP,RP,zP,Ep=_(()=>{"use strict";sr();Or=43,Qn=45,El=110,Ko=!0,DP=!1;RP="AnPlusB",zP={a:[String,null],b:[String,null]}});var Pp={};Se(Pp,{generate:()=>jP,name:()=>_P,parse:()=>Ap,structure:()=>UP,walkContext:()=>$P});function F0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function OP(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return!0;if(t===23||t===3)return!1}return!1}function Ap(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),F0):o=F0.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(OP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function jP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var _P,$P,UP,Lp=_(()=>{"use strict";_P="Atrule",$P="atrule",UP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var Bp={};Se(Bp,{generate:()=>GP,name:()=>HP,parse:()=>Mp,structure:()=>VP,walkContext:()=>WP});function Mp(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 GP(e){this.children(e)}var HP,WP,VP,Dp=_(()=>{"use strict";HP="AtrulePrelude",WP="atrulePrelude",VP={children:[[]]}});var Np={};Se(Np,{generate:()=>e2,name:()=>JP,parse:()=>zp,structure:()=>ZP});function XP(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(E0)?(t=!0,this.next()):this.isDelim(Rp)||this.eat(1),this.isDelim(Rp)?this.charCodeAt(this.tokenStart+1)!==Pl?(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 QP(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Pl&&t!==KP&&t!==YP&&t!==qP&&t!==E0&&t!==Rp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Pl&&(this.isDelim(Pl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function zp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=XP.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=QP.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 e2(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 qP,E0,Pl,YP,Rp,KP,JP,ZP,Op=_(()=>{"use strict";qP=36,E0=42,Pl=61,YP=94,Rp=124,KP=126;JP="AttributeSelector",ZP={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var $p={};Se($p,{generate:()=>s2,name:()=>r2,parse:()=>_p,structure:()=>i2,walkContext:()=>o2});function L0(){return this.Raw(null,!0)}function A0(){return this.parseWithFallback(this.Rule,L0)}function P0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function n2(){if(this.tokenType===17)return P0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,P0);return this.tokenType===17&&this.next(),e}function _p(e){let t=e?n2:A0,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),L0));break;default:e&&this.isDelim(t2)?r.push(A0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function s2(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var t2,r2,o2,i2,Up=_(()=>{"use strict";t2=38;r2="Block",o2="block",i2={children:[["Atrule","Rule","Declaration"]]}});var Hp={};Se(Hp,{generate:()=>c2,name:()=>a2,parse:()=>jp,structure:()=>l2});function jp(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 c2(e){this.token(9,"["),this.children(e),this.token(9,"]")}var a2,l2,Wp=_(()=>{"use strict";a2="Brackets",l2={children:[[]]}});var Gp={};Se(Gp,{generate:()=>d2,name:()=>u2,parse:()=>Vp,structure:()=>p2});function Vp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function d2(){this.token(15,"-->")}var u2,p2,qp=_(()=>{"use strict";u2="CDC",p2=[]});var Kp={};Se(Kp,{generate:()=>m2,name:()=>g2,parse:()=>Yp,structure:()=>f2});function Yp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function m2(){this.token(14,"<!--")}var g2,f2,Xp=_(()=>{"use strict";g2="CDO",f2=[]});var Jp={};Se(Jp,{generate:()=>b2,name:()=>x2,parse:()=>Qp,structure:()=>y2});function Qp(){return this.eatDelim(h2),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function b2(e){this.token(9,"."),this.token(1,e.name)}var h2,x2,y2,Zp=_(()=>{"use strict";h2=46,x2="ClassSelector",y2={name:String}});var td={};Se(td,{generate:()=>T2,name:()=>k2,parse:()=>ed,structure:()=>C2});function ed(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case w2:case S2:case v2:this.next();break;case M0:this.next(),this.eatIdent("deep"),this.eatDelim(M0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function T2(e){this.tokenize(e.name)}var S2,M0,w2,v2,k2,C2,nd=_(()=>{"use strict";S2=43,M0=47,w2=62,v2=126,k2="Combinator",C2={name:String}});var od={};Se(od,{generate:()=>P2,name:()=>E2,parse:()=>rd,structure:()=>A2});function rd(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===I2&&this.charCodeAt(t-1)===F2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function P2(e){this.token(25,"/*"+e.value+"*/")}var I2,F2,E2,A2,id=_(()=>{"use strict";I2=42,F2=47,E2="Comment",A2={value:String}});var ad={};Se(ad,{generate:()=>R2,name:()=>M2,parse:()=>sd,structure:()=>B2});function B0(e){return this.lookupTypeNonSC(1)===1&&L2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function sd(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(()=>D2[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 R2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var L2,M2,B2,D2,ld=_(()=>{"use strict";L2=new Set([16,22,0]),M2="Condition",B2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};D2={media:B0,container:B0,supports(){return this.SupportsDeclaration()}}});var ud={};Se(ud,{generate:()=>q2,name:()=>W2,parse:()=>cd,structure:()=>G2,walkContext:()=>V2});function U2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function j2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function H2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(R0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function cd(){let e=this.tokenStart,t=this.tokenIndex,n=Y2.call(this),r=hl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?j2:U2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(H2,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(R0)&&(s=K2.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 q2(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 Y2(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case _2:case N2:case $2:case z2:case O2:this.next();break;case D0:this.next(),this.isDelim(D0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function K2(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var R0,z2,N2,O2,_2,$2,D0,W2,V2,G2,pd=_(()=>{"use strict";xl();R0=33,z2=35,N2=36,O2=38,_2=42,$2=43,D0=47;W2="Declaration",V2="declaration",G2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var fd={};Se(fd,{generate:()=>Z2,name:()=>Q2,parse:()=>gd,structure:()=>J2});function dd(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function gd(){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),dd));break;default:this.isDelim(X2)?e.push(this.parseWithFallback(this.Rule,dd)):e.push(this.parseWithFallback(this.Declaration,dd))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function Z2(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var X2,Q2,J2,md=_(()=>{"use strict";X2=38;Q2="DeclarationList",J2={children:[["Declaration","Atrule","Rule"]]}});var xd={};Se(xd,{generate:()=>nL,name:()=>eL,parse:()=>hd,structure:()=>tL});function hd(){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 nL(e){this.token(12,e.value+e.unit)}var eL,tL,yd=_(()=>{"use strict";eL="Dimension",tL={value:String,unit:String}});var Sd={};Se(Sd,{generate:()=>sL,name:()=>oL,parse:()=>bd,structure:()=>iL});function bd(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(rL)&&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 sL(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var rL,oL,iL,wd=_(()=>{"use strict";rL=47,oL="Feature",iL={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var kd={};Se(kd,{generate:()=>uL,name:()=>aL,parse:()=>vd,structure:()=>lL});function cL(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function vd(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=cL.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 uL(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var aL,lL,Cd=_(()=>{"use strict";aL="FeatureFunction",lL={kind:String,feature:String,value:["Declaration","Selector"]}});var Fd={};Se(Fd,{generate:()=>mL,name:()=>gL,parse:()=>Id,structure:()=>fL});function Td(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(z0,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(z0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function O0(e){if(this.skipSC(),this.isDelim(pL)||this.isDelim(dL)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(N0)?(this.next(),t+"="):t}if(this.isDelim(N0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function Id(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Td.call(this),r=O0.call(this,n.type==="Identifier"),o=Td.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=O0.call(this),s=Td.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 mL(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 z0,pL,N0,dL,gL,fL,Ed=_(()=>{"use strict";z0=47,pL=60,N0=61,dL=62,gL="FeatureRange",fL={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]}});var Pd={};Se(Pd,{generate:()=>bL,name:()=>hL,parse:()=>Ad,structure:()=>yL,walkContext:()=>xL});function Ad(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 bL(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var hL,xL,yL,Ld=_(()=>{"use strict";hL="Function",xL="function",yL={name:String,children:[[]]}});var Bd={};Se(Bd,{generate:()=>vL,name:()=>SL,parse:()=>Md,structure:()=>wL});function Md(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 vL(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var SL,wL,Dd=_(()=>{"use strict";SL="GeneralEnclosed",wL={kind:String,function:[String,null],children:[[]]}});var zd={};Se(zd,{generate:()=>IL,name:()=>CL,parse:()=>Rd,structure:()=>TL,xxx:()=>kL});function Rd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function IL(e){this.token(4,"#"+e.value)}var kL,CL,TL,Nd=_(()=>{"use strict";kL="XXX",CL="Hash",TL={value:String}});var _d={};Se(_d,{generate:()=>AL,name:()=>FL,parse:()=>Od,structure:()=>EL});function Od(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function AL(e){this.token(1,e.name)}var FL,EL,$d=_(()=>{"use strict";FL="Identifier",EL={name:String}});var jd={};Se(jd,{generate:()=>ML,name:()=>PL,parse:()=>Ud,structure:()=>LL});function Ud(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function ML(e){this.token(9,"#"+e.name)}var PL,LL,Hd=_(()=>{"use strict";PL="IdSelector",LL={name:String}});var Vd={};Se(Vd,{generate:()=>zL,name:()=>DL,parse:()=>Wd,structure:()=>RL});function Wd(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(BL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function zL(e){this.tokenize(e.name)}var BL,DL,RL,Gd=_(()=>{"use strict";BL=46,DL="Layer",RL={name:String}});var Yd={};Se(Yd,{generate:()=>_L,name:()=>NL,parse:()=>qd,structure:()=>OL});function qd(){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 _L(e){this.children(e,()=>this.token(18,","))}var NL,OL,Kd=_(()=>{"use strict";NL="LayerList",OL={children:[["Layer"]]}});var Qd={};Se(Qd,{generate:()=>jL,name:()=>$L,parse:()=>Xd,structure:()=>UL});function Xd(){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 jL(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 $L,UL,Jd=_(()=>{"use strict";$L="MediaQuery",UL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var eg={};Se(eg,{generate:()=>VL,name:()=>HL,parse:()=>Zd,structure:()=>WL});function Zd(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),this.tokenType===18);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function VL(e){this.children(e,()=>this.token(18,","))}var HL,WL,tg=_(()=>{"use strict";HL="MediaQueryList",WL={children:[["MediaQuery"]]}});var rg={};Se(rg,{generate:()=>KL,name:()=>qL,parse:()=>ng,structure:()=>YL});function ng(){let e=this.tokenStart;return this.eatDelim(GL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function KL(){this.token(9,"&")}var GL,qL,YL,og=_(()=>{"use strict";GL=38,qL="NestingSelector",YL={}});var sg={};Se(sg,{generate:()=>JL,name:()=>XL,parse:()=>ig,structure:()=>QL});function ig(){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 JL(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var XL,QL,ag=_(()=>{"use strict";XL="Nth",QL={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var cg={};Se(cg,{generate:()=>tM,name:()=>ZL,parse:()=>lg,structure:()=>eM});function lg(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function tM(e){this.token(10,e.value)}var ZL,eM,ug=_(()=>{"use strict";ZL="Number",eM={value:String}});var dg={};Se(dg,{generate:()=>oM,name:()=>nM,parse:()=>pg,structure:()=>rM});function pg(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function oM(e){this.tokenize(e.value)}var nM,rM,gg=_(()=>{"use strict";nM="Operator",rM={value:String}});var mg={};Se(mg,{generate:()=>aM,name:()=>iM,parse:()=>fg,structure:()=>sM});function fg(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 aM(e){this.token(21,"("),this.children(e),this.token(22,")")}var iM,sM,hg=_(()=>{"use strict";iM="Parentheses",sM={children:[[]]}});var yg={};Se(yg,{generate:()=>uM,name:()=>lM,parse:()=>xg,structure:()=>cM});function xg(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function uM(e){this.token(11,e.value+"%")}var lM,cM,bg=_(()=>{"use strict";lM="Percentage",cM={value:String}});var wg={};Se(wg,{generate:()=>fM,name:()=>pM,parse:()=>Sg,structure:()=>gM,walkContext:()=>dM});function Sg(){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 fM(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var pM,dM,gM,vg=_(()=>{"use strict";pM="PseudoClassSelector",dM="function",gM={name:String,children:[["Raw"],null]}});var Cg={};Se(Cg,{generate:()=>yM,name:()=>mM,parse:()=>kg,structure:()=>xM,walkContext:()=>hM});function kg(){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 yM(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 mM,hM,xM,Tg=_(()=>{"use strict";mM="PseudoElementSelector",hM="function",xM={name:String,children:[["Raw"],null]}});var Fg={};Se(Fg,{generate:()=>wM,name:()=>bM,parse:()=>Ig,structure:()=>SM});function $0(){switch(this.skipSC(),this.tokenType){case 10:return this.Number();case 2:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}function Ig(){let e=this.tokenStart,t=$0.call(this),n=null;return this.skipSC(),this.isDelim(_0)&&(this.eatDelim(_0),n=$0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function wM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var _0,bM,SM,Eg=_(()=>{"use strict";_0=47;bM="Ratio",SM={left:["Number","Function"],right:["Number","Function",null]}});var Pg={};Se(Pg,{generate:()=>TM,name:()=>kM,parse:()=>Ag,structure:()=>CM});function vM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function Ag(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=vM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function TM(e){this.tokenize(e.value)}var kM,CM,Lg=_(()=>{"use strict";kM="Raw",CM={value:String}});var Bg={};Se(Bg,{generate:()=>PM,name:()=>FM,parse:()=>Mg,structure:()=>AM,walkContext:()=>EM});function U0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function IM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function Mg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(IM,U0):n=U0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function PM(e){this.node(e.prelude),this.node(e.block)}var FM,EM,AM,Dg=_(()=>{"use strict";FM="Rule",EM="rule",AM={prelude:["SelectorList","Raw"],block:["Block"]}});var zg={};Se(zg,{generate:()=>BM,name:()=>LM,parse:()=>Rg,structure:()=>MM});function Rg(){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 BM(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}var LM,MM,Ng=_(()=>{"use strict";LM="Scope",MM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var _g={};Se(_g,{generate:()=>zM,name:()=>DM,parse:()=>Og,structure:()=>RM});function Og(){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 zM(e){this.children(e)}var DM,RM,$g=_(()=>{"use strict";DM="Selector",RM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var jg={};Se(jg,{generate:()=>$M,name:()=>NM,parse:()=>Ug,structure:()=>_M,walkContext:()=>OM});function Ug(){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 $M(e){this.children(e,()=>this.token(18,","))}var NM,OM,_M,Hg=_(()=>{"use strict";NM="SelectorList",OM="selector",_M={children:[["Selector","Raw"]]}});function Ll(e){let t=e.length,n=e.charCodeAt(0),r=n===j0||n===H0?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===Wg){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),Pn(Wg,a)){let u=s-1,c=Yr(e,u);s=c-1,i+=el(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function W0(e,t){let n=t?"'":'"',r=t?H0:j0,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===Wg?(o+="\\"+e.charAt(s),i=!1):(i&&(Ln(a)||zr(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var Wg,j0,H0,Ml=_(()=>{"use strict";sr();Wg=92,j0=34,H0=39});var Gg={};Se(Gg,{generate:()=>HM,name:()=>UM,parse:()=>Vg,structure:()=>jM});function Vg(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Ll(this.consume(5))}}function HM(e){this.token(5,W0(e.value))}var UM,jM,qg=_(()=>{"use strict";Ml();UM="String",jM={value:String}});var Kg={};Se(Kg,{generate:()=>YM,name:()=>VM,parse:()=>Yg,structure:()=>qM,walkContext:()=>GM});function G0(){return this.Raw(null,!1)}function Yg(){let e=this.tokenStart,t=this.createList(),n;for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(this.charCodeAt(this.tokenStart+2)!==WM){this.next();continue}n=this.Comment();break;case 14:n=this.CDO();break;case 15:n=this.CDC();break;case 3:n=this.parseWithFallback(this.Atrule,G0);break;default:n=this.parseWithFallback(this.Rule,G0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function YM(e){this.children(e)}var WM,VM,GM,qM,Xg=_(()=>{"use strict";WM=33;VM="StyleSheet",GM="stylesheet",qM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var Jg={};Se(Jg,{generate:()=>QM,name:()=>KM,parse:()=>Qg,structure:()=>XM});function Qg(){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 QM(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var KM,XM,Zg=_(()=>{"use strict";KM="SupportsDeclaration",XM={declaration:"Declaration"}});var nf={};Se(nf,{generate:()=>tB,name:()=>ZM,parse:()=>tf,structure:()=>eB});function ef(){this.tokenType!==1&&this.isDelim(JM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function tf(){let e=this.tokenStart;return this.isDelim(q0)?(this.next(),ef.call(this)):(ef.call(this),this.isDelim(q0)&&(this.next(),ef.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function tB(e){this.tokenize(e.name)}var JM,q0,ZM,eB,rf=_(()=>{"use strict";JM=42,q0=124;ZM="TypeSelector",eB={name:String}});var af={};Se(af,{generate:()=>sB,name:()=>oB,parse:()=>sf,structure:()=>iB});function Rs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===K0&&t&&n!==0)return Rs.call(this,e+n+1,!1),-1;Ln(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 Bl(e){let t=0;for(;this.isDelim(of);)++t>e&&this.error("Too many question marks"),this.next()}function nB(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===Y0?"Plus sign":"Hyphen minus")+" is expected")}function rB(){let e=0;switch(this.tokenType){case 10:if(e=Rs.call(this,1,!0),this.isDelim(of)){Bl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){nB.call(this,K0),Rs.call(this,1,!1);break}break;case 12:e=Rs.call(this,1,!0),e>0&&Bl.call(this,6-e);break;default:if(this.eatDelim(Y0),this.tokenType===1){e=Rs.call(this,0,!0),e>0&&Bl.call(this,6-e);break}if(this.isDelim(of)){this.next(),Bl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function sf(){let e=this.tokenStart;return this.eatIdent("u"),rB.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function sB(e){this.tokenize(e.value)}var Y0,K0,of,oB,iB,lf=_(()=>{"use strict";sr();Y0=43,K0=45,of=63;oB="UnicodeRange",iB={value:String}});function Q0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===X0?t-2:t-1,o="";for(;n<r&&zr(e.charCodeAt(n));)n++;for(;n<r&&zr(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===cf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),Pn(cf,s)){let a=i-1,u=Yr(e,a);i=u-1,o+=el(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function J0(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===aB||o===cf||o===lB||o===cB||o===uB||o===X0?(t+="\\"+e.charAt(r),n=!1):(n&&Ln(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var aB,cf,lB,cB,uB,X0,uf=_(()=>{"use strict";sr();aB=32,cf=92,lB=34,cB=39,uB=40,X0=41});var df={};Se(df,{generate:()=>gB,name:()=>pB,parse:()=>pf,structure:()=>dB});function pf(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=Q0(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=Ll(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 gB(e){this.token(7,J0(e.value))}var pB,dB,gf=_(()=>{"use strict";uf();Ml();pB="Url",dB={value:String}});var mf={};Se(mf,{generate:()=>hB,name:()=>fB,parse:()=>ff,structure:()=>mB});function ff(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function hB(e){this.children(e)}var fB,mB,hf=_(()=>{"use strict";fB="Value",mB={children:[[]]}});var yf={};Se(yf,{generate:()=>SB,name:()=>yB,parse:()=>xf,structure:()=>bB});function xf(){return this.eat(13),xB}function SB(e){this.token(13,e.value)}var xB,yB,bB,bf=_(()=>{"use strict";xB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),yB="WhiteSpace",bB={value:String}});var zs={};Se(zs,{AnPlusB:()=>Fp,Atrule:()=>Pp,AtrulePrelude:()=>Bp,AttributeSelector:()=>Np,Block:()=>$p,Brackets:()=>Hp,CDC:()=>Gp,CDO:()=>Kp,ClassSelector:()=>Jp,Combinator:()=>td,Comment:()=>od,Condition:()=>ad,Declaration:()=>ud,DeclarationList:()=>fd,Dimension:()=>xd,Feature:()=>Sd,FeatureFunction:()=>kd,FeatureRange:()=>Fd,Function:()=>Pd,GeneralEnclosed:()=>Bd,Hash:()=>zd,IdSelector:()=>jd,Identifier:()=>_d,Layer:()=>Vd,LayerList:()=>Yd,MediaQuery:()=>Qd,MediaQueryList:()=>eg,NestingSelector:()=>rg,Nth:()=>sg,Number:()=>cg,Operator:()=>dg,Parentheses:()=>mg,Percentage:()=>yg,PseudoClassSelector:()=>wg,PseudoElementSelector:()=>Cg,Ratio:()=>Fg,Raw:()=>Pg,Rule:()=>Bg,Scope:()=>zg,Selector:()=>_g,SelectorList:()=>jg,String:()=>Gg,StyleSheet:()=>Kg,SupportsDeclaration:()=>Jg,TypeSelector:()=>nf,UnicodeRange:()=>af,Url:()=>df,Value:()=>mf,WhiteSpace:()=>yf});var Sf=_(()=>{"use strict";Ep();Lp();Dp();Op();Up();Wp();qp();Xp();Zp();nd();id();ld();pd();md();yd();wd();Cd();Ed();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tg();og();ag();ug();gg();hg();bg();vg();Tg();Eg();Lg();Dg();Ng();$g();Hg();qg();Xg();Zg();rf();lf();gf();hf();bf()});var eS,tS=_(()=>{"use strict";yl();I0();Sf();eS={generic:!0,cssWideKeywords:ki,...T0,node:zs}});function Ns(e){switch(this.tokenType){case 4:return this.Hash();case 18:return this.Operator();case 21:return this.Parentheses(this.readSequence,e.recognizer);case 19:return this.Brackets(this.readSequence,e.recognizer);case 5:return this.String();case 12:return this.Dimension();case 11:return this.Percentage();case 10:return this.Number();case 2:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,e.recognizer);case 7:return this.Url();case 1:return this.cmpChar(this.tokenStart,TB)&&this.cmpChar(this.tokenStart+1,nS)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===CB||t===vB||t===nS||t===kB)return this.Operator();t===wB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var wB,vB,nS,kB,CB,TB,wf=_(()=>{"use strict";wB=35,vB=42,nS=43,kB=45,CB=47,TB=117});var rS,oS=_(()=>{"use strict";wf();rS={getNode:Ns}});function DB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function RB(){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)===iS&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case AB:case LB:case BB:case PB:return this.Combinator();case iS:return this.ClassSelector();case EB:case MB:return this.TypeSelector();case IB:return this.IdSelector();case FB:return this.NestingSelector()}break}}}var IB,FB,EB,AB,PB,iS,LB,MB,BB,sS,aS=_(()=>{"use strict";IB=35,FB=38,EB=42,AB=43,PB=47,iS=46,LB=62,MB=124,BB=126;sS={onWhiteSpace:DB,getNode:RB}});function lS(){return this.createSingleNodeList(this.Raw(null,!1))}var cS=_(()=>{"use strict"});function uS(){let e=this.createList();if(this.skipSC(),e.push(this.Identifier()),this.skipSC(),this.tokenType===18){e.push(this.Operator());let t=this.tokenIndex,n=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(n.type==="Value"&&n.children.isEmpty){for(let r=t-this.tokenIndex;r<=0;r++)if(this.lookupType(r)===13){n.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}e.push(n)}return e}var pS=_(()=>{"use strict"});function dS(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var gS,fS=_(()=>{"use strict";wf();cS();pS();gS={getNode:Ns,onWhiteSpace(e,t){dS(e)&&(e.value=" "+e.value),dS(t.last)&&(t.last.value+=" ")},expression:lS,var:uS}});var vf={};Se(vf,{AtrulePrelude:()=>rS,Selector:()=>sS,Value:()=>gS});var mS=_(()=>{"use strict";oS();aS();fS()});var zB,hS,xS=_(()=>{"use strict";zB=new Set(["none","and","not","or"]),hS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);zB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var yS,bS=_(()=>{"use strict";yS={parse:{prelude:null,block(){return this.Block(!0)}}}});function kf(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 SS,wS,vS=_(()=>{"use strict";SS={layer(){this.skipSC();let e=this.createList(),t=kf.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=kf.call(this,this.Declaration,()=>kf.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},wS={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,SS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,SS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var kS,CS=_(()=>{"use strict";kS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var TS,IS=_(()=>{"use strict";TS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var FS,ES=_(()=>{"use strict";FS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var AS,PS=_(()=>{"use strict";AS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var LS,MS=_(()=>{"use strict";LS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var BS,DS=_(()=>{"use strict";BS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var RS,zS=_(()=>{"use strict";RS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var NS,OS=_(()=>{"use strict";xS();bS();vS();CS();IS();ES();PS();MS();DS();zS();NS={container:hS,"font-face":yS,import:wS,layer:kS,media:TS,nest:FS,page:AS,scope:LS,"starting-style":BS,supports:RS}});function _S(){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 $S=_(()=>{"use strict"});var Xo,Cf,NB,OB,Dl,US,jS=_(()=>{"use strict";$S();Xo={parse(){return this.createSingleNodeList(this.SelectorList())}},Cf={parse(){return this.createSingleNodeList(this.Selector())}},NB={parse(){return this.createSingleNodeList(this.Identifier())}},OB={parse:_S},Dl={parse(){return this.createSingleNodeList(this.Nth())}},US={dir:NB,has:Xo,lang:OB,matches:Xo,is:Xo,"-moz-any":Xo,"-webkit-any":Xo,where:Xo,not:Xo,"nth-child":Dl,"nth-last-child":Dl,"nth-last-of-type":Dl,"nth-of-type":Dl,slotted:Cf,host:Cf,"host-context":Cf}});var Tf={};Se(Tf,{AnPlusB:()=>Ip,Atrule:()=>Ap,AtrulePrelude:()=>Mp,AttributeSelector:()=>zp,Block:()=>_p,Brackets:()=>jp,CDC:()=>Vp,CDO:()=>Yp,ClassSelector:()=>Qp,Combinator:()=>ed,Comment:()=>rd,Condition:()=>sd,Declaration:()=>cd,DeclarationList:()=>gd,Dimension:()=>hd,Feature:()=>bd,FeatureFunction:()=>vd,FeatureRange:()=>Id,Function:()=>Ad,GeneralEnclosed:()=>Md,Hash:()=>Rd,IdSelector:()=>Ud,Identifier:()=>Od,Layer:()=>Wd,LayerList:()=>qd,MediaQuery:()=>Xd,MediaQueryList:()=>Zd,NestingSelector:()=>ng,Nth:()=>ig,Number:()=>lg,Operator:()=>pg,Parentheses:()=>fg,Percentage:()=>xg,PseudoClassSelector:()=>Sg,PseudoElementSelector:()=>kg,Ratio:()=>Ig,Raw:()=>Ag,Rule:()=>Mg,Scope:()=>Rg,Selector:()=>Og,SelectorList:()=>Ug,String:()=>Vg,StyleSheet:()=>Yg,SupportsDeclaration:()=>Qg,TypeSelector:()=>tf,UnicodeRange:()=>sf,Url:()=>pf,Value:()=>ff,WhiteSpace:()=>xf});var HS=_(()=>{"use strict";Ep();Lp();Dp();Op();Up();Wp();qp();Xp();Zp();nd();id();ld();pd();md();yd();wd();Cd();Ed();Ld();Dd();Nd();$d();Hd();Gd();Kd();Jd();tg();og();ag();ug();gg();hg();bg();vg();Tg();Eg();Lg();Dg();Ng();$g();Hg();qg();Xg();Zg();rf();lf();gf();hf();bf()});var WS,VS=_(()=>{"use strict";mS();OS();jS();HS();WS={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:vf,atrule:NS,pseudo:US,node:Tf}});var GS,qS=_(()=>{"use strict";Sf();GS={node:zs}});var YS,KS=_(()=>{"use strict";C0();tS();VS();qS();YS=k0({...eS,...WS,...GS})});var XS=_(()=>{"use strict"});var QS=_(()=>{"use strict"});var Gq,JS,qq,Yq,Kq,ZS,Xq,Qq,Jq,Zq,eY,tY,ew=_(()=>{"use strict";KS();XS();dp();xl();QS();Ml();uf();({tokenize:Gq,parse:JS,generate:qq,lexer:Yq,createLexer:Kq,walk:ZS,find:Xq,findLast:Qq,findAll:Jq,toPlainObject:Zq,fromPlainObject:eY,fork:tY}=YS)});function jB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function nw(e){try{let t=JS(e.trim(),{context:"value"}),n=[];return ZS(t,{enter(r){if(r.type==="Dimension"){let o=parseFloat(r.value);n.push(`${o}${r.unit}`)}else if(r.type==="Number"){let o=parseFloat(r.value);n.push(`${o}`)}else r.type==="Percentage"?n.push(`${parseFloat(r.value)}%`):r.type==="Identifier"?n.push(r.name.toLowerCase()):r.type==="Hash"?n.push(`#${r.value.toLowerCase()}`):r.type}}),n}catch{return[e.trim().toLowerCase()]}}function HB(e,t){let n=jB(e);if(!UB.has(n))return t;let r=nw(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 tw(e,t){let n=t.trim();if(!n)return"";let r=HB(e,n);return nw(r).map(i=>i==="0"?"0px":i).join(" ")}function rw(e,t,n){let r=tw(e,t),o=tw(e,n);return r!==""&&o!==""&&r===o}var UB,ow=_(()=>{"use strict";ew();UB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function WB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function VB(e){let t=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/);if(!t)return null;let n=parseInt(t[1],10).toString(16).padStart(2,"0"),r=parseInt(t[2],10).toString(16).padStart(2,"0"),o=parseInt(t[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`}function iw(e){let t=typeof e=="string"?e:String(e??"");if(!t||t==="[object Object]")return"";let n=t.match(/rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*[\d.]+)?\s*\)/);if(n){let i=VB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return WB(r[0]);let o=t.match(/(-?\d+\.?\d*)(px|em|rem|%|pt|vw|vh)?/g);return o&&o.length>1?o.join(" ").toLowerCase():o&&o.length===1?o[0].toLowerCase():t.toLowerCase().trim().replace(/\s+/g," ")}function Qo(e,t,n){if(!e||!t)return!1;let r=String(e),o=String(t),i=r.toLowerCase(),s=o.toLowerCase(),a=i.includes("none"),u=s.includes("none");if(a!==u)return!1;let c=/\b(fill|stroke)\s*:/i,l=c.test(r),d=c.test(o);if(l!==d)return!1;let g=iw(r),p=iw(o);return!!(g===p||n&&rw(n,r,o))}var If=_(()=>{"use strict";ow()});function XB(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 sw(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 QB(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 JB(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&&XB(n)||sw(r)||sw(o)||n&&QB(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<lw:a<aw}return r.includes("%")||o.includes("%")?a<1:!1}function ZB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(KB.some(s=>t.includes(s))||!qB.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!Qo(o,i,e.property))}function eD(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 tD(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)<cw}function nD(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(!YB.some(d=>t.includes(d)||n.includes(d)))return!1;let i=`${t} ${n} ${r}`;if(i.includes("min-width")||i.includes("max-width")||i.includes("min-height")||i.includes("max-height")||i.includes("explicit")||i.includes("constraint")||i.includes("forced"))return!1;let a=n.includes("hug")||n.includes("auto"),u=/\d+\.?\d*px/.test(r);if(!a||!u)return!1;let c=n.match(/(\d+\.?\d*)px/),l=r.match(/(\d+\.?\d*)px/);return!(c&&l&&Math.abs(parseFloat(c[1])-parseFloat(l[1]))>GB)}function rD(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 Os(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(Qo(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(tD(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${cw}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(JB(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")?lw:aw}px)`,dismissedBy:"post-ai-validation"}}return rD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:ZB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:nD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:eD(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var aw,lw,cw,GB,qB,YB,KB,uw=_(()=>{"use strict";If();aw=.5,lw=2,cw=2,GB=5,qB=["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"],YB=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],KB=["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 Ai(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var pw=_(()=>{"use strict"});var dw=_(()=>{"use strict"});var gw=_(()=>{"use strict"});var Ff=_(()=>{"use strict";If();uw();pw();dw();gw()});var dD,gD,yY,Ef=_(()=>{"use strict";dD=["flex","inline-flex"],gD=["grid","inline-grid"],yY=[...dD,...gD]});var mw=_(()=>{"use strict";Ff();Ef()});var hw=_(()=>{"use strict"});var Rn=_(()=>{"use strict";wu();Sy();wy();Ff();Ef();mw();hw()});function mD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function Jn(e){try{let t=e.map(mD),n=JSON.stringify(t,hD);sessionStorage.setItem(Af,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function Pf(){try{let e=sessionStorage.getItem(Af);if(!e)return[];let t=JSON.parse(e,xD);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function xw(){try{let e=Pf();if(e.length===0)return;let t=!1,n=e.map(r=>{if(r.aiPrompt!==void 0||r.aiResponse!==void 0){t=!0;let{aiPrompt:o,aiResponse:i,...s}=r;return s}return r});t&&(Jn(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function yw(){try{sessionStorage.removeItem(Af),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function hD(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function xD(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Af,Lf=_(()=>{"use strict";Oe();Af="uicopilot_review_history"});import yD,{createContext as bD,useContext as SD,useReducer as wD,useMemo as bw,useRef as vD,useEffect as kD}from"react";function Rl(e){let t=e.length>Sw?e.slice(e.length-Sw):e,n=Math.max(0,t.length-CD);return n===0?t:t.map((r,o)=>{if(o>=n)return r;let i=r.storybookImageData?.startsWith("data:"),s=r.figmaImageData?.startsWith("data:");return!i&&!s?r:{...r,storybookImageData:i?void 0:r.storybookImageData,figmaImageData:s?void 0:r.figmaImageData}})}function TD(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"ADD_STREAMING_MESSAGE":return{...e,streamingMessages:[...e.streamingMessages,t.payload]};case"UPDATE_STREAMING_MESSAGE":return{...e,streamingMessages:e.streamingMessages.map((n,r)=>r===t.payload.index?{...n,content:t.payload.content}:n)};case"CLEAR_STREAMING_MESSAGES":return{...e,streamingMessages:[]};case"TOGGLE_MODEL":{let n=e.selectedModels.includes(t.payload);return n&&e.selectedModels.length===1?e:{...e,selectedModels:n?e.selectedModels.filter(r=>r!==t.payload):[...e.selectedModels,t.payload]}}case"SET_REVIEW_RESULTS":{if(!t.payload)return{...e,reviewResults:null,currentReviewId:null};let n=e.userRole==="admin",r={id:t.payload.id,componentId:t.payload.componentId,storyId:t.payload.storyId,modelId:t.payload.modelId,complianceScore:t.payload.complianceScore,issuesCount:t.payload.issuesCount,issues:t.payload.issues,createdAt:t.payload.createdAt,visualSimilarity:t.payload.visualSimilarity,storybookImageData:e.storybookImageUrl||void 0,figmaImageData:e.figmaImageUrl||void 0,aiPrompt:n&&e.fullPrompt||void 0,aiResponse:n&&e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens},o=e.reviewHistory.findIndex(s=>s.id===t.payload.id),i;return o>=0?i=e.reviewHistory.map((s,a)=>a===o?r:s):i=[...e.reviewHistory,r],i=Rl(i),Jn(i),{...e,reviewResults:t.payload,reviewHistory:i,currentReviewId:t.payload.id}}case"UPDATE_MULTI_MODEL_STREAMING":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload.modelId]:{...e.multiModelResults.byModel[t.payload.modelId],streamingMessages:t.payload.messages}}}}:{...e,multiModelResults:{byModel:{[t.payload.modelId]:{streamingMessages:t.payload.messages}},activeModelId:t.payload.modelId}};case"SET_MODEL_COMPLETED":return e.multiModelResults?{...e,multiModelResults:{...e.multiModelResults,byModel:{...e.multiModelResults.byModel,[t.payload]:{...e.multiModelResults.byModel[t.payload],completed:!0}}}}:e;case"BULK_ADD_REVIEWS":{let n=new Set(e.reviewHistory.map(i=>i.id)),r=t.payload.filter(i=>!n.has(i.id));if(r.length===0)return e;let o=Rl([...e.reviewHistory,...r]);return Jn(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=Rl([...e.reviewHistory,t.payload]);return Jn(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 Jn(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 Jn(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 Jn(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 Jn(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 Jn(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 Jn(n),{...e,reviewHistory:n}}case"RECALCULATE_SCORE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.filter(c=>!c.dismissed),i=o.filter(c=>c.severity==="critical").length,s=o.filter(c=>c.severity==="major").length,a=o.filter(c=>c.severity==="minor").length,u=Ai(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return Jn(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 Jn(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return yw(),{...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 Bf({children:e}){let[t,n]=wD(TD,PD),r=vD(t);kD(()=>{r.current=t},[t]);let o=bw(()=>({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=bw(()=>({...t,...o}),[t,o]);return yD.createElement(ww.Provider,{value:i},e)}function ce(){let e=SD(ww);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var Sw,CD,ID,FD,Mf,ED,AD,PD,ww,Df=_(()=>{"use strict";Rn();Lf();Oe();Sw=20,CD=5;ID=()=>{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},FD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Mf={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},ED=()=>{if(typeof localStorage>"u")return Mf;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Mf;let t=JSON.parse(e);return{enableFixGeneration:!!t.enableFixGeneration,enableFixApply:!!t.enableFixApply,enableAutoMap:!!t.enableAutoMap,enableReviewBadges:!!t.enableReviewBadges,showCosts:!!t.showCosts,enableParallelReview:!!t.enableParallelReview,enableModelSelection:!!t.enableModelSelection}}catch{}return Mf},AD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},PD={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:Rl(Pf()),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:AD(),roleOverride:FD(),featureFlags:ED(),reviewAllConcurrency:ID(),hoveredIssueId:null},ww=bD(null)});import _s,{useMemo as LD}from"react";function zf({children:e}){return _s.createElement(mu,null,_s.createElement(xu,null,_s.createElement(bu,null,_s.createElement(Bf,null,_s.createElement(MD,null),e))))}function vw(e){let t=we(),n=Je(),r=nt(),o=ce(),i=LD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function MD(){return Rf=vw(),null}var Rf,gt,kw=_(()=>{"use strict";hu();yu();Su();Df();Rf=null,gt=Object.assign(vw,{getState:()=>{if(!Rf)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Rf}})});var Ce=_(()=>{"use strict";kw();hu();yu();Su();Df()});function V(){return(process.env.STORYBOOK_UICOPILOT_URL||BD).replace(/\/$/,"")}var BD,Cw,je=_(()=>{"use strict";BD="https://app.uiparity.com";Cw=3.6});async function ne(e,t,n=3e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var ct=_(()=>{"use strict"});import{useEffect as Jo,useState as Nl,useRef as $w,useCallback as $f}from"react";import{addons as Uf}from"storybook/manager-api";async function RR(e,t,n){let r=`${e}:${t}`,o=jf.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await ne(`${Vw}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{jf.delete(r)});return jf.set(r,i),i}function zR(e,t,n){try{sessionStorage.setItem(`${Ol}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function NR(e,t){try{let n=sessionStorage.getItem(`${Ol}${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(`${Ol}${e}`)}catch{}return null}function OR(e){try{let t=sessionStorage.getItem(`${Ol}${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 Uw,jw,Hw,Ww,Bi,Vw,zn,Hf,jf,Ol,Gw,qw,Zo,Di=_(()=>{"use strict";Ce();Wf();Oe();je();ct();Uw="storyArgsUpdated",jw="storyRendered",Hw="forceRemount",Ww=null,Bi=()=>Ww,Vw=V(),zn=new Map,Hf=null,jf=new Map;Ol="uicopilot-figma-image-";Gw=(e,t,n)=>{let r=zn.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):zn.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),y.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},qw=(e,t,n)=>{Hf=t;let r=zn.get(e);r?r.figmaImageUrl=n:zn.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},Zo=()=>{let[e,t]=Nl(!1),[n,r]=Nl(!1),[o,i]=Nl(!1),[s,a]=Nl(null),u=$w(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ce(),d=$f(()=>{let P=gt.getState().currentStoryId;P&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",P),zn.delete(P),u.current=null,i(!0),l())},[l]),g=$f(()=>{let P=gt.getState().currentStoryId;if(P){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",P);let z=zn.get(P);z&&(z.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:p}=we(),{selectedProjectId:f}=Je(),{currentStoryId:k,currentMapping:T,loadingMapping:E}=nt(),{setStorybookImageUrl:I,setFigmaImageUrl:D}=ce(),R=$w(null);Jo(()=>{k&&R.current&&R.current!==k&&(y.debug("[useReviewScreenshots] Story switched, clearing images"),I(""),D("")),R.current=k},[k,I,D]),Jo(()=>{!k||E||T||D("")},[k,T,E,D]),Jo(()=>{if(!k)return;let P=OR(k);P&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",k),D(P))},[k,D]),Jo(()=>{let P=!1;return(async()=>{if(!p||!f||!k){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==k&&(y.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),I(""),D(""));let x=gt.getState();if(u.current===k&&x.storybookImageUrl&&x.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let w=T?.figmaNodeId??null;if(w!==Hf){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",k);let L=zn.get(k);L&&(L.figmaImageUrl=null),Hf=w,u.current=null}let v=T?.figmaNodeId;if(v&&!zn.get(k)?.figmaImageUrl){let L=NR(k,v);if(L){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",k),D(L);let B=zn.get(k);B?B.figmaImageUrl=L:zn.set(k,{storybookImageUrl:null,figmaImageUrl:L})}}let C=zn.get(k),m=C&&C.storybookImageUrl&&C.figmaImageUrl,F=C&&C.storybookImageUrl&&!C.figmaImageUrl,S=C&&!C.storybookImageUrl&&C.figmaImageUrl;if(m){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",k),I(C.storybookImageUrl),D(C.figmaImageUrl),u.current=k;return}let b=F&&T?.figmaNodeId;b&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",k),I(C.storybookImageUrl));let A=S;if(A&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",k),D(C.figmaImageUrl)),u.current===k&&T?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),b?r(!0):(A||(t(!0),r(!0)),i(!0)),u.current=k,P)return;let L=A?C.figmaImageUrl:null,B;if(A)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(v){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",v);let h=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let j=await RR(f,v,p);h=j.imageUrl||null;let H=j.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${H}:`,h?"success":"not found")}catch(j){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",j)}if(h)if(h.includes(".azureedge.net")||h.includes(".blob.core.windows.net")||h.includes(".blob.vercel-storage.com")){y.debug("[useReviewScreenshots] Using cached CDN URL directly (fast)"),L=h,D(h);let H=new Image;H.crossOrigin="anonymous",await new Promise(M=>{H.onload=()=>{B={width:H.naturalWidth,height:H.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),M()},H.onerror=()=>M(),H.src=h})}else try{y.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let H=`${Vw}/api/proxy/image?url=${encodeURIComponent(h)}`,M=await ne(H);if(M.ok){let X=await M.blob(),ee=new FileReader,me=await new Promise((oe,Ye)=>{ee.onloadend=()=>oe(ee.result),ee.onerror=Ye,ee.readAsDataURL(X)});L=me,D(me),y.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let xe=new Image;await new Promise(oe=>{xe.onload=()=>{B={width:xe.naturalWidth,height:xe.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),oe()},xe.onerror=()=>oe(),xe.src=me})}else L=h,D(h),y.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(H){y.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",H),L=h,D(h)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",v),D(null);L&&v&&zR(k,v,L),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let N=C?.storybookImageUrl||null;if(N)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",k);let h=await _l({storyId:k,sessionToken:p||void 0,...B&&{figmaWidth:B.width,figmaHeight:B.height}});h&&!P?(N=h,I(h),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",B||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}zn.set(k,{storybookImageUrl:N,figmaImageUrl:L}),y.debug("[useReviewScreenshots] Screenshots cached for story:",k)}catch(L){y.error("[useReviewScreenshots] Error loading screenshots:",L),a(L instanceof Error?L.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})(),()=>{P=!0}},[p,f,k,T?.figmaNodeId,c]),Jo(()=>{let P=Uf.getChannel(),z=null,x=w=>{Ww=w.args,y.debug("[useReviewScreenshots] Args updated for story:",w.storyId,"args:",w.args),z&&clearTimeout(z),z=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),d()},500)};return P.on(Uw,x),()=>{P.off(Uw,x),z&&clearTimeout(z)}},[d]),Jo(()=>{let P=Uf.getChannel(),z=!1,x=null,w=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),z=!0,i(!0)},v=()=>{z&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),x&&clearTimeout(x),x=setTimeout(()=>{z=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return P.on(Hw,w),P.on(jw,v),()=>{P.off(Hw,w),P.off(jw,v),x&&clearTimeout(x)}},[g]),Jo(()=>{let P=Uf.getChannel(),z=async x=>{if(!x?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let w=gt.getState().currentStoryId,v=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x.snapshot,storyId:w})});if(v.ok){let C=await v.json();if(C.screenshot){I(C.screenshot);let m=gt.getState().currentStoryId;if(m){let F=zn.get(m);F?F.storybookImageUrl=C.screenshot:zn.set(m,{storybookImageUrl:C.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await v.text())}catch(w){y.error("[useReviewScreenshots] Snapshot screenshot error:",w)}finally{i(!1)}};return P.on("UICOPILOT/STORY_DOM_MUTATED",z),()=>{P.off("UICOPILOT/STORY_DOM_MUTATED",z)}},[]);let $=$f((P,z,x)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),qw(P,z,x),D(x),r(!1),u.current=P},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:d,refreshStorybookOnly:g,setFigmaImageDirect:$}}});function $R(){return!V().startsWith("http://localhost")}function UR(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 Yw(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=UR(o,t,n);return r.set(o,i),i})}async function jR(){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=Yw(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(d=>d.href===c);if(l)try{let d="";for(let g of Array.from(l.cssRules))d+=g.cssText+`
|
|
13
13
|
`;if(/(?:color|oklch|oklab|lab|lch)\(/.test(d)){let g=s.createElement("style");g.textContent=Yw(d,o,r),u.replaceWith(g)}}catch{}})}})).toDataURL("image/png")}function HR(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 WR(e,t){y.debug("[Screenshot] Using server-side Chrome capture for:",e);let n={"Content-Type":"application/json"};t?.sessionToken&&(n.Authorization=`Bearer ${t.sessionToken}`);let r=await ne(`${_R}/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 VR(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 GR(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),y.debug("[Screenshot] Warning: Using story ID from URL (fallback):",n)),!n)throw new Error("Could not determine current story ID. Please select a story first.");let r=window.location.origin,o=Date.now(),i=`${r}/iframe.html?viewMode=story&id=${n}&globals=&_cb=${o}`,s=Bi();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=VR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=HR(s);i+=`&args=${a}`,y.debug("[Screenshot] Using URL with current args:",i)}else y.debug("[Screenshot] No current args, using default URL:",i);return i}async function qR(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return y.info("[Screenshot] Local Puppeteer not available, falling back"),null;if(!t.ok){let r=await t.json().catch(()=>({error:"Unknown"}));throw new Error(r.error||`Screenshot failed: ${t.status}`)}let n=await t.json();return y.info("[Screenshot] Captured via local Puppeteer (pixel-perfect)"),n.screenshot}catch(t){if(t instanceof TypeError&&t.message.includes("fetch"))return null;throw t}}async function _l(e){let t=e?.storyId||YR();if(t){let n=Vf.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Kw(t,e).finally(()=>{Vf.delete(t)});return Vf.set(t,r),r}return Kw(void 0,e)}async function Kw(e,t){try{if(e){let n=await qR(e);if(n)return n}if(!$R()){let n=GR(t?.storyId);return await WR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await jR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function YR(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var _R,Vf,Wf=_(()=>{"use strict";je();Di();Oe();ct();_R=V();Vf=new Map});function Tn(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 Nn(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 Ws(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Xw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let T=r.fontSize||"16px",E=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let I=t.fonts.check(`${E} ${T} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:I,fontWeight:E,fontSize:T,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),I)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(T=>T.trim().replace(/['"]/g,"")),d=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],g=[...new Set([...l,...d])];s.font=`${c} ${u} ${a} monospace`;let p=s.measureText(o).width,f="unknown",k=new Map;for(let T of g){s.font=`${c} ${u} ${a} "${T}", monospace`;let E=s.measureText(o).width;if(k.set(T,E),E!==p){s.font=`${c} ${u} ${a} "${T}"`;let I=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(I-D)<.1){f=T;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:f,declaredFonts:l,fontWidths:Array.from(k.entries()),isIframe:t!==document}),f}var Vs=_(()=>{"use strict";Oe()});function Ri(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 Gf(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return y.debug("[computedStyles] Extracting styles:",{fontFamily:n.fontFamily,fontWeight:n.fontWeight,borderRadius:n.borderRadius,backgroundColor:n.backgroundColor,padding:{top:n.paddingTop,right:n.paddingRight,bottom:n.paddingBottom,left:n.paddingLeft},isIframeContext:e.ownerDocument!==document}),{color:Tn(n.color),backgroundColor:Tn(n.backgroundColor),borderColor:Tn(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:Xw(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 qf(e,t){let n={width:null,height:null,minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,display:null,flexGrow:null,flexShrink:null,flexBasis:null};try{let r=Array.from(t.styleSheets);for(let i of r)try{let s=i.cssRules||i.rules;if(!s)continue;for(let a of Array.from(s))if(a.type===1){let u=a;try{if(e.matches(u.selectorText)){let c=u.style;c.width&&(n.width=c.width),c.height&&(n.height=c.height),c.minWidth&&(n.minWidth=c.minWidth),c.minHeight&&(n.minHeight=c.minHeight),c.maxWidth&&(n.maxWidth=c.maxWidth),c.maxHeight&&(n.maxHeight=c.maxHeight),c.display&&(n.display=c.display),c.flexGrow&&(n.flexGrow=c.flexGrow),c.flexShrink&&(n.flexShrink=c.flexShrink),c.flexBasis&&(n.flexBasis=c.flexBasis)}}catch{continue}}}catch{continue}let o=e.style;o.width&&(n.width=o.width),o.height&&(n.height=o.height),o.minWidth&&(n.minWidth=o.minWidth),o.minHeight&&(n.minHeight=o.minHeight),o.maxWidth&&(n.maxWidth=o.maxWidth),o.maxHeight&&(n.maxHeight=o.maxHeight),o.display&&(n.display=o.display),o.flexGrow&&(n.flexGrow=o.flexGrow),o.flexShrink&&(n.flexShrink=o.flexShrink),o.flexBasis&&(n.flexBasis=o.flexBasis)}catch(r){y.error("Error extracting declared styles:",r)}return n}var $l=_(()=>{"use strict";Oe();Vs()});function KR(e){let t=[],n=new Set,r=Qw.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(Qw.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function XR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"";return{selector:Ri(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Ws(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:Tn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function QR(e,t=2){let n=[e],r=new Set,o=s=>{let a=s.className;return typeof a=="string"?a:a?.baseVal||""};r.add(`${e.tagName}.${o(e)}`);function i(s,a){if(a>=t)return;let u=Array.from(s.children);for(let c of u){let l=c.tagName.toLowerCase();if(["script","style","link","meta","br","hr"].includes(l))continue;let d=`${c.tagName}.${o(c)}`;r.has(d)||(r.add(d),n.push(c),i(c,a+1))}}return i(e,0),n}function JR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"",s=n.borderWidth!=="0px",a=n.backgroundColor!=="transparent"&&n.backgroundColor!=="rgba(0, 0, 0, 0)",u=n.borderRadius!=="0px",c=n.gap!=="normal"&&n.gap!=="0px";if(!s&&!a&&!u&&!c)return null;let l=n.borderWidth,d=n.borderStyle,g=Tn(n.borderColor),p=s?`${l} ${d} ${g}`:"none";return{selector:Ri(r,i),className:i,border:p,borderRadius:n.borderRadius,backgroundColor:Tn(n.backgroundColor),gap:n.gap}}function Gs(){y.debug("[computedStyles] extractStoryStyles called - FULL CONTEXT VERSION");try{let e=document.getElementById("storybook-preview-iframe");if(!e||!e.contentDocument)throw new Error("Storybook preview iframe not found");let t=e.contentDocument,n=t.getElementById("storybook-root");if(!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(!r)throw new Error("Component element not found in story root");let o=QR(r,2),i=o.map(JR).filter(a=>a!==null);y.debug("[computedStyles] Extracted visual styles from nested elements:",{total:o.length,withVisuals:i.length,elements:i.map(a=>({selector:a.selector,border:a.border,background:a.backgroundColor,borderRadius:a.borderRadius}))});let s=[];try{let a=KR(r);s=a.map(XR),y.debug("[computedStyles] Text elements found:",{count:a.length,elements:s.map(u=>({selector:u.selector,fontSize:u.styles.fontSize,fontWeight:u.styles.fontWeight}))})}catch(a){y.error("[computedStyles] Error extracting text elements:",a)}return{computed:Gf(r),declared:qf(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Qw,Jw=_(()=>{"use strict";Oe();Vs();$l();Qw=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Yf(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 ez(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function tz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=Tn(n.backgroundColor);Nn("backgroundColor",o)||(r.backgroundColor=o);let i=ez(n.borderWidth,n.borderStyle,Tn(n.borderColor));i&&(r.border=i),Nn("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),Nn("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),Nn("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 E=e.attributes[T];if(["class","style","id","xmlns","xmlns:xlink"].includes(E.name))continue;let I=E.name.replace(/-([a-z])/g,(R,$)=>$.toUpperCase()),D=E.value.startsWith("rgb")?Tn(E.value):E.value;I==="d"&&D.length>100?r[I]=D.substring(0,100)+"...":r[I]=D}let p=n.getPropertyValue("fill"),f=n.getPropertyValue("stroke");if(p&&p!=="none"&&(r.fill=p.startsWith("rgb")?Tn(p):p),f&&f!=="none"&&(r.stroke=f.startsWith("rgb")?Tn(f):f),["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=ZR.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=Ws(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=Tn(n.color),Nn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Nn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let d=Yf(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Nn("padding",d)||(r.padding=d);let g=Yf(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Nn("margin",g)||(r.margin=g),Nn("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(Nn("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),Nn("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),Nn("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function Zw(e){let t=1;for(let n of e.children)t+=Zw(n);return t}function ev(e,t=4){function n(o,i){let s=o.tagName.toLowerCase(),a=o.className,u=typeof a=="string"?a:a?.baseVal||"",c=o.id||void 0,l=o.getAttribute("role")||void 0,d;for(let k of Array.from(o.childNodes))if(k.nodeType===Node.TEXT_NODE){let T=k.textContent?.trim();if(T){d=T.length>50?T.substring(0,50)+"...":T;break}}let g=s;c?g=`${s}#${c}`:u&&(g=Ri(s,u));let p=tz(o),f=[];if(i<t){let k=Array.from(o.children);for(let T of k){let E=T.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(E))continue;let D=(T.ownerDocument.defaultView||window).getComputedStyle(T);D.display==="none"||D.visibility==="hidden"||f.push(n(T,i+1))}}return{selector:g,tagName:s,className:u,id:c,role:l,textContent:d,styles:p,children:f}}y.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return y.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:Zw(r)}),r}function Kf(e=4){y.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(y.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(y.debug("[extractStoryDOMTree] iframe.contentDocument:",!!t.contentDocument),!t.contentDocument)throw new Error("iframe.contentDocument is not accessible (possible cross-origin issue)");let n=t.contentDocument.getElementById("storybook-root");if(y.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=n.firstElementChild;if(y.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=ev(r,e);return y.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return y.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var ZR,tv=_(()=>{"use strict";Oe();Vs();$l();ZR=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Xf=_(()=>{"use strict";Vs();$l();Jw();tv()});var Fv=rr((iQ,Iv)=>{"use strict";Iv.exports={compareTwoStrings:Tv,findBestMatch:Iz};function Tv(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 Iz(e,t){if(!Fz(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=Tv(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 Fz(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var S1=rr((bse,b1)=>{"use strict";var m1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,C3=/\n/g,T3=/^\s*/,I3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,F3=/^:\s*/,E3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,A3=/^[;\s]*/,P3=/^\s+|\s+$/g,L3=`
|
|
14
|
-
`,h1="/",x1="*",si="",M3="comment",B3="declaration";function D3(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(f){var k=f.match(C3);k&&(n+=k.length);var T=f.lastIndexOf(L3);r=~T?f.length-T:r+f.length}function i(){var f={line:n,column:r};return function(k){return k.position=new s(f),c(),k}}function s(f){this.start=f,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(f){var k=new Error(t.source+":"+n+":"+r+": "+f);if(k.reason=f,k.filename=t.source,k.line=n,k.column=r,k.source=e,!t.silent)throw k}function u(f){var k=f.exec(e);if(k){var T=k[0];return o(T),e=e.slice(T.length),k}}function c(){u(T3)}function l(f){var k;for(f=f||[];k=d();)k!==!1&&f.push(k);return f}function d(){var f=i();if(!(h1!=e.charAt(0)||x1!=e.charAt(1))){for(var k=2;si!=e.charAt(k)&&(x1!=e.charAt(k)||h1!=e.charAt(k+1));)++k;if(k+=2,si===e.charAt(k-1))return a("End of comment missing");var T=e.slice(2,k-2);return r+=2,o(T),e=e.slice(k),r+=2,f({type:M3,comment:T})}}function g(){var f=i(),k=u(I3);if(k){if(d(),!u(F3))return a("property missing ':'");var T=u(E3),E=f({type:B3,property:y1(k[0].replace(m1,si)),value:T?y1(T[0].replace(m1,si)):si});return u(A3),E}}function p(){var f=[];l(f);for(var k;k=g();)k!==!1&&(f.push(k),l(f));return f}return c(),p()}function y1(e){return e?e.replace(P3,si):si}b1.exports=D3});var w1=rr(fa=>{"use strict";var R3=fa&&fa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(fa,"__esModule",{value:!0});fa.default=N3;var z3=R3(S1());function N3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,z3.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 k1=rr(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.camelCase=void 0;var O3=/^--[a-zA-Z0-9_-]+$/,_3=/-([a-z])/g,$3=/^[^-]+$/,U3=/^-(webkit|moz|ms|o|khtml)-/,j3=/^-(ms)-/,H3=function(e){return!e||$3.test(e)||O3.test(e)},W3=function(e,t){return t.toUpperCase()},v1=function(e,t){return"".concat(t,"-")},V3=function(e,t){return t===void 0&&(t={}),H3(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(j3,v1):e=e.replace(U3,v1),e.replace(_3,W3))};kc.camelCase=V3});var T1=rr((Ph,C1)=>{"use strict";var G3=Ph&&Ph.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},q3=G3(w1()),Y3=k1();function Ah(e,t){var n={};return!e||typeof e!="string"||(0,q3.default)(e,function(r,o){r&&o&&(n[(0,Y3.camelCase)(r,t)]=o)}),n}Ah.default=Ah;C1.exports=Ah});var JT=rr((Ype,QT)=>{"use strict";var Gc=Object.prototype.hasOwnProperty,XT=Object.prototype.toString,WT=Object.defineProperty,VT=Object.getOwnPropertyDescriptor,GT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):XT.call(t)==="[object Array]"},qT=function(t){if(!t||XT.call(t)!=="[object Object]")return!1;var n=Gc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Gc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Gc.call(t,o)},YT=function(t,n){WT&&n.name==="__proto__"?WT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},KT=function(t,n){if(n==="__proto__")if(Gc.call(t,n)){if(VT)return VT(t,n).value}else return;return t[n]};QT.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=KT(a,n),o=KT(t,n),a!==o&&(l&&o&&(qT(o)||(i=GT(o)))?(i?(i=!1,s=r&>(r)?r:[]):s=r&&qT(r)?r:{},YT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&YT(a,{name:n,newValue:o}));return a}});import Na from"react";import{addons as lu,types as ty,experimental_getStatusStore as OF}from"storybook/manager-api";import{AddonPanel as fV}from"storybook/internal/components";import Dt,{useState as BW,useEffect as DW}from"react";import{styled as xr}from"storybook/theming";import uy from"react";import{styled as Mt}from"storybook/theming";var ae="#ea580c",pu="#c2410c",Ua="#ff6b35";var oy=Mt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),iy=Mt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),ho=Mt.div({marginBottom:"20px"}),xo=Mt.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})),us=Mt.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`}})),hn=Mt.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"}})),sy=Mt(hn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),ja=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"}}),kn=Mt.button(({theme:e})=>({...ja(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Yt=Mt.button(({theme:e})=>({...ja(e),backgroundColor:ae,color:e.color.inverseText,boxShadow:`0 2px 4px ${ae}4d`,"&:hover:not(:disabled)":{backgroundColor:pu,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ae}66`}})),Rr=Mt.button(({theme:e})=>({...ja(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),ay=Mt.button(({theme:e})=>({...ja(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Cn=Mt.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"}})),du=Mt.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"}})),yo=Mt.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}})),bo=Mt(us)(({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"})),vV=Mt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),ly=Mt.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})),kV=Mt.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})),ps=Mt.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})),CV=Mt.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%)"}}})),cy=Mt.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}}),TV=Mt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),IV=Mt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),FV=Mt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var gu=({header:e,children:t,footer:n})=>uy.createElement(oy,null,e,uy.createElement(iy,null,t),n);import qF from"react";import{styled as YF}from"storybook/theming";var KF=YF.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})),fu=({toolbar:e})=>qF.createElement(KF,null,e);import NV from"react";import{styled as Ha}from"storybook/theming";var $V=Ha.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})),UV=Ha.div({display:"flex",flex:1}),jV=Ha(yo)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),HV=Ha.div({display:"flex",gap:"8px",alignItems:"center"});import Zt,{useState as Of,useCallback as zw,useEffect as Nw}from"react";import{styled as eo}from"storybook/theming";import ve,{useEffect as Tw}from"react";import{styled as lt}from"storybook/theming";Ce();je();Oe();ct();var Iw=lt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),Fw=lt.div(({theme:e})=>({position:"absolute",top:"100%",right:0,marginTop:"8px",backgroundColor:e.background.content,borderRadius:"12px",width:"360px",maxWidth:"90vw",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)",overflow:"hidden",zIndex:10001})),DD=lt.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),RD=lt.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:ae,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),zD=lt.div({display:"flex",flexDirection:"column",gap:"4px"}),ND=lt.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),OD=lt.span({display:"inline-block",alignSelf:"flex-start",padding:"2px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:600,color:"#7c3aed",backgroundColor:"rgba(124, 58, 237, 0.1)",letterSpacing:"0.3px"}),_D=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),$D=lt.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),UD=lt.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),jD=lt.div(({theme:e})=>({height:"8px",borderRadius:"4px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",margin:"0 16px 8px",overflow:"hidden"})),HD=lt.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${ae} 100%)`,transition:"width 0.3s ease"})),WD=lt.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),VD=lt.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),GD=lt.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:ae,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Ew=lt.button(({theme:e})=>({position:"absolute",top:"12px",right:"12px",width:"24px",height:"24px",borderRadius:"4px",border:"none",background:"transparent",color:e.textMutedColor,cursor:"pointer",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:e.background.hoverable}})),qD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),YD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),KD=lt.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})),XD=lt.div({display:"flex",gap:"8px"}),Aw=lt(Cn)({fontSize:"18px"}),QD=lt.div({padding:"20px 16px"}),JD=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),ZD=lt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),eR=lt.div({fontSize:"28px",fontWeight:700}),tR=lt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),nR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),rR=lt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),oR=lt.div({display:"flex",alignItems:"center",gap:"8px"}),iR=lt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),sR=lt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:ae,color:e.color.inverseText})),aR=lt.button(({theme:e})=>({background:"none",border:"none",color:ae,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),lR=lt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),cR=lt.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}})),uR=30*1e3,Pw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ce(),a=s.showCosts,u=r,c=!r&&t,l=async(f=!1)=>{if(!t)return;let k=o&&Date.now()-o<uR;if(!(!f&&k&&r))try{let T=V(),E=await ne(`${T}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(E.ok){let I=await E.json();i(I)}}catch(T){y.error("Failed to fetch usage:",T)}};Tw(()=>{l()},[t]),Tw(()=>{let f=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[t]);let d=()=>{if(t){let f=V();fetch(`${f}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}).catch(()=>{})}n(),e()},g=()=>{let f=V();window.open(`${f}/pricing`,"_blank")},p=()=>{let f=V();window.open(`${f}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let f=Math.floor(u?.creditBalance??0),T=Math.max(f,10),E=Math.max(0,T-f),I=T>0?f/T*100:0;return ve.createElement(ve.Fragment,null,ve.createElement(Iw,{onClick:e}),ve.createElement(Fw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},ve.createElement(DD,null,ve.createElement(RD,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement(zD,null,ve.createElement(ND,null,"UI Review"),ve.createElement(OD,null,(u?.plan||"BETA").toUpperCase())),ve.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},ve.createElement(Ew,{onClick:d,title:"Sign out",style:{position:"static"}},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Ew,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),ve.createElement(_D,null,ve.createElement($D,null,"Credits"),ve.createElement(UD,null,f," left")),ve.createElement(jD,null,ve.createElement(HD,{percent:I})),ve.createElement(WD,null,E," used \xB7 ",f," remaining"),ve.createElement(VD,null),ve.createElement(GD,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return ve.createElement(ve.Fragment,null,ve.createElement(Iw,{onClick:e}),ve.createElement(Fw,{onClick:f=>f.stopPropagation()},ve.createElement(qD,null,ve.createElement(YD,null,ve.createElement(KD,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement("span",null,u?.email||"Loading...")),ve.createElement(XD,null,ve.createElement(Aw,{onClick:d,title:"Sign out"},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Aw,{onClick:e,title:"Close"},"\xD7"))),ve.createElement(QD,null,c?ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?ve.createElement(ve.Fragment,null,ve.createElement(JD,null,ve.createElement(ZD,null,"Credit Balance"),ve.createElement(eR,null,"$",(u?.creditBalance??0).toFixed(2)),ve.createElement(tR,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),ve.createElement(nR,null,ve.createElement(rR,null,ve.createElement(oR,null,ve.createElement(iR,null,"Current Plan"),ve.createElement(sR,null,u?.plan||"Free")),ve.createElement(aR,{onClick:g},"View detail >")),ve.createElement(lR,null,"~$0.02-0.05 per review depending on complexity"),ve.createElement(cR,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};Ce();import Pi from"react";import{styled as Lw}from"storybook/theming";je();Ce();ct();Oe();var pR=Lw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),dR=Lw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),gR={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}},Mw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ce(),{sessionToken:o}=we();return e!=="admin"?null:Pi.createElement(pR,null,Pi.createElement(dR,null,"View as:"),Pi.createElement(sy,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ne(`${V()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>y.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=gR[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Pi.createElement("option",{value:"admin"},"Admin"),Pi.createElement("option",{value:"beta"},"Beta Tester")),t&&Pi.createElement(cy,{variant:"warning"},"Previewing as ",t))};je();Ce();ct();import ht,{useState as $s,useCallback as Nf}from"react";import{styled as Cr}from"storybook/theming";var fR="0.5.7",mR=[{value:"bug",label:"\u{1F41E} Bug \u2014 something broke"},{value:"ux",label:"\u{1F9ED} UX \u2014 confusing or slow"},{value:"feature",label:"\u2728 Feature \u2014 missing something"},{value:"praise",label:"\u{1F49A} Praise \u2014 works great"},{value:"other",label:"\u{1F4AC} Other"}],hR=Cr.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),xR=Cr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"12px",width:"460px",maxWidth:"94%",maxHeight:"90vh",overflow:"auto",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.25)"})),yR=Cr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),bR=Cr.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),SR=Cr.button(({theme:e})=>({background:"transparent",border:"none",fontSize:"20px",color:e.color.mediumdark,cursor:"pointer",padding:"0 6px",lineHeight:1,"&:hover":{color:e.color.defaultText}})),wR=Cr.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),vR=Cr.textarea(({theme:e})=>({width:"100%",minHeight:"110px",padding:"8px 10px",borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.defaultText,backgroundColor:e.background.app,resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:ae}})),Bw=Cr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),Dw=Cr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),kR=Cr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),CR=Cr.div(({theme:e})=>({padding:"24px 20px",textAlign:"center",display:"flex",flexDirection:"column",gap:"10px","& h4":{margin:0,fontSize:"15px",fontWeight:600,color:e.color.positive},"& p":{margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark}}));function Rw({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=we(),{selectedProjectId:o}=Je(),{currentStoryId:i}=nt(),[s,a]=$s("other"),[u,c]=$s(""),[l,d]=$s(!1),[g,p]=$s(!1),[f,k]=$s(null),T=Nf(()=>{c(""),a("other"),p(!1),k(null),d(!1)},[]),E=Nf(()=>{T(),t()},[T,t]),I=Nf(async D=>{if(D.preventDefault(),!u.trim()){k("Please write a message.");return}if(!r||!n){k("Sign in to send feedback.");return}d(!0),k(null);try{let R=await ne(`${V()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:s,projectId:o||void 0,storyId:i||void 0,addonVersion:fR})});if(!R.ok){let $=await R.json().catch(()=>({}));throw new Error($.error||`Request failed (${R.status})`)}p(!0)}catch(R){k(R instanceof Error?R.message:"Something went wrong")}finally{d(!1)}},[u,s,n,r,o,i]);return e?ht.createElement(hR,{onClick:E},ht.createElement(xR,{onClick:D=>D.stopPropagation()},ht.createElement(yR,null,ht.createElement(bR,null,ht.createElement("span",null,"\u{1F4AC}"),"Send feedback"),ht.createElement(SR,{onClick:E,"aria-label":"Close"},"\xD7")),g?ht.createElement(ht.Fragment,null,ht.createElement(CR,null,ht.createElement("h4",null,"Thanks \u2014 got it."),ht.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),ht.createElement(Bw,null,ht.createElement("span",null),ht.createElement(kn,{onClick:E},"Close"))):ht.createElement("form",{onSubmit:I},ht.createElement(wR,null,ht.createElement(ho,null,ht.createElement(xo,{htmlFor:"feedback-severity"},"Type"),ht.createElement(hn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},mR.map(D=>ht.createElement("option",{key:D.value,value:D.value},D.label)))),ht.createElement(ho,null,ht.createElement(xo,{htmlFor:"feedback-message"},"What happened?"),ht.createElement(vR,{id:"feedback-message",value:u,onChange:D=>c(D.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:l,autoFocus:!0,maxLength:5e3})),ht.createElement(Dw,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),f&&ht.createElement(kR,null,f)),ht.createElement(Bw,null,ht.createElement(Dw,null,i?`Context: ${i}`:"No story selected"),ht.createElement("div",{style:{display:"flex",gap:"8px"}},ht.createElement(kn,{type:"button",onClick:E,disabled:l},"Cancel"),ht.createElement(Yt,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}Ce();je();ct();var TR=eo.div({display:"flex",alignItems:"center"}),Li=eo.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),IR=eo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),FR=eo.div({position:"relative"}),ER=eo.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`}})),Ow=eo.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)"}})),AR=eo.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)"}}}),PR=eo.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}})),LR=eo.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:ae,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${ae}66, 0 2px 4px rgba(0,0,0,0.1)`,transition:"all 0.2s ease",zIndex:9999,"&:hover":{transform:"scale(1.08)",boxShadow:`0 6px 20px ${ae}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),MR=30*1e3,_f=({onOpenSettings:e})=>{let[t,n]=Of(!1),[r,o]=Of(!1),[i,s]=Of(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=we(),{userRole:d,roleOverride:g,featureFlags:p}=ce(),f=g??d;Nw(()=>{(async()=>{if(!(!l||u&&Date.now()-u<MR&&a)){s(!0);try{let $=V(),P=await ne(`${$}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(P.ok){let z=await P.json();c(z)}}catch($){console.error("Failed to fetch balance:",$)}finally{s(!1)}}})()},[l,u,a,c]),Nw(()=>{let D=()=>{document.visibilityState==="visible"&&t&&n(!1)},R=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",D),window.addEventListener("focus",R),()=>{document.removeEventListener("visibilitychange",D),window.removeEventListener("focus",R)}},[t]);let k=zw(()=>{n(!0)},[]),T=zw(()=>{n(!1)},[]),E=a?.creditBalance??0,I=E<2&&!i;return Zt.createElement(TR,null,e&&Zt.createElement(Li,null,Zt.createElement(PR,{onClick:e,title:"Settings"},Zt.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&d==="admin"&&f==="admin"&&Zt.createElement(Li,null,Zt.createElement(Mw,null)),Zt.createElement(Li,null,Zt.createElement(IR,null,"v","0.5.11")),l&&p.showCosts&&Zt.createElement(Li,null,Zt.createElement(Ow,{onClick:k,isLow:I,title:i?"Loading...":a?I?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?Zt.createElement(AR,null):a?`$${E.toFixed(2)}`:"...")),l&&!p.showCosts&&a&&Zt.createElement(Li,null,Zt.createElement(Ow,{onClick:k,isLow:Math.floor(E)<=3,title:`${Math.floor(E)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(E))),Zt.createElement(Li,null,Zt.createElement(FR,null,Zt.createElement(ER,{title:"Account & Usage",onClick:k},a?.email?a.email[0].toUpperCase():"?"),t&&Zt.createElement(Pw,{onClose:T}))),l&&Zt.createElement(LR,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),Zt.createElement(Rw,{isOpen:r,onClose:()=>o(!1)}))};import Lt,{useEffect as x4,useRef as y4}from"react";import{styled as gr}from"storybook/theming";import rt from"react";Ce();Oe();je();ct();Rn();import{useState as BR,useCallback as Mi,useRef as _w,useEffect as DR}from"react";var to=V();y.debug("[useAuth] Module loaded, APP_URL:",to);var Us=()=>{let e=_w(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:g,setUserCode:p,setVerificationUri:f,setPollingInterval:k,setAuthError:T,resetAuth:E}=we(),I=_w(null),[D,R]=BR(!1),$=Mi(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let C;try{C=await ne(`${to}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let B=A instanceof Error&&A.message.includes("timed out")?`Cannot reach ${Ft.NAME} server at ${to}. Is the dashboard running?`:`Connection failed: ${to} is not responding.`;T(B),y.error("[useAuth]",B);return}if(!C.ok){let A=`Cannot reach ${Ft.NAME} server. Is the dashboard running?`;T(A),y.error("[useAuth]",A);return}let{poll_code:m}=await C.json();y.debug("[useAuth] Got poll_code:",m.substring(0,15)+"...");let F=localStorage.getItem("uicopilot_force_sign_in")==="true";F&&localStorage.removeItem("uicopilot_force_sign_in");let S=`${to}/addon/auth?poll_code=${m}${F?"&force_sign_in=true":""}`;R(!0),window.open(S,"uiparity-auth","width=520,height=620,left=300,top=150"),y.debug("[useAuth] Starting OAuth poll for token..."),I.current&&clearInterval(I.current);let b=async()=>{try{let L=await(await fetch(`${to}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:m})})).json();L.status==="authorized"&&L.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),I.current&&(clearInterval(I.current),I.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token),R(!1)):L.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),I.current&&(clearInterval(I.current),I.current=null),R(!1))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};I.current=setInterval(b,2e3),setTimeout(b,1e3)}catch(C){y.error("[useAuth] OAuth flow error:",C),T(`Connection failed. Is the dashboard running at ${to}?`),R(!1)}},[c,T]),P=Mi(async()=>{try{let C=await fetch(`${to}/api/addon/auth/device`,{method:"POST"});if(!C.ok)throw new Error("Failed to start device code flow");let m=await C.json();g(m.device_code),p(m.user_code),f(m.verification_uri),window.open(m.verification_uri,"_blank"),z(m.device_code,m.interval*1e3)}catch(C){throw y.error("[useAuth] Device code flow error:",C),C}},[g,p,f]),z=Mi((C,m)=>{y.debug("[useAuth] Starting polling. Device code:",C,"Interval:",m),e.current&&clearInterval(e.current);let F=async()=>{try{let b=await(await fetch(`${to}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:C})})).json();b.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null),localStorage.setItem("uicopilot_session_token",b.session_token),c(b.session_token),setOauthUrl(null)):(b.status==="expired"||b.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null))}catch(S){y.error("[useAuth] Polling error:",S)}};e.current=setInterval(F,m),k(m)},[g,p,f,c,k]),x=Mi(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null),k(null)},[g,p,f,k]),w=Mi(C=>{l(C),localStorage.setItem("uicopilot_api_key",C)},[l]),v=Mi(()=>{E(),setOauthUrl(null),e.current&&(clearInterval(e.current),e.current=null),I.current&&(clearInterval(I.current),I.current=null)},[E]);return DR(()=>()=>{e.current&&clearInterval(e.current),I.current&&clearInterval(I.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthPending:D,setAuthMethod:d,startOAuth:$,startDeviceCode:P,cancelDeviceCode:x,saveApiKey:w,logout:v}};Ce();Oe();je();ct();import{useCallback as zl}from"react";var js=V(),no=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Je(),{sessionToken:a}=we(),u=zl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${js}/api/projects`);let g=await ne(`${js}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let p=await g.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){y.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=zl(async g=>{if(!a)throw new Error("Not authenticated");let p=await ne(`${js}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!p.ok)throw new Error("Failed to create project");let f=await p.json();return await u(),f.project},[a,u]),l=zl(async(g,p)=>{if(!a)throw new Error("Not authenticated");let f={};if(p.name!==void 0&&(f.name=p.name),p.description!==void 0&&(f.description=p.description),p.figmaFileUrl!==void 0&&(f.figmaFileId=p.figmaFileUrl||void 0),!(await ne(`${js}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=zl(async g=>{if(!a)throw new Error("Not authenticated");if(!(await ne(`${js}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:d}};Ce();var Hs=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d}=nt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};Ce();Wf();Xf();import{useCallback as Qs,useRef as Yl}from"react";Oe();function Ul(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){y.warn("[iframeReload] No preview iframe found"),e();return}let n=t.contentWindow.location.href,r=new URL(n);r.searchParams.set("_cb",Date.now().toString());let o=r.toString();y.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{y.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),y.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{y.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var jl=BigInt(4294967295),nv=BigInt(32);function nz(e,t=!1){return t?{h:Number(e&jl),l:Number(e>>nv&jl)}:{h:Number(e>>nv&jl)|0,l:Number(e&jl)|0}}function rv(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}=nz(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var ov=(e,t,n)=>e<<n|t>>>32-n,iv=(e,t,n)=>t<<n|e>>>32-n,sv=(e,t,n)=>t<<n-32|e>>>64-n,av=(e,t,n)=>e<<n-32|t>>>64-n;function rz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qf(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Hl(e,t,n=""){let r=rz(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 Jf(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 lv(e,t){Hl(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 cv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Zf(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var oz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function iz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function sz(e){for(let t=0;t<e.length;t++)e[t]=iz(e[t]);return e}var em=oz?e=>e:sz;function uv(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 pv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var az=BigInt(0),qs=BigInt(1),lz=BigInt(2),cz=BigInt(7),uz=BigInt(256),pz=BigInt(113),fv=[],mv=[],hv=[];for(let e=0,t=qs,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],fv.push(2*(5*r+n)),mv.push((e+1)*(e+2)/2%64);let o=az;for(let i=0;i<7;i++)t=(t<<qs^(t>>cz)*pz)%uz,t&lz&&(o^=qs<<(qs<<BigInt(i))-qs);hv.push(o)}var xv=rv(hv,!0),dz=xv[0],gz=xv[1],dv=(e,t,n)=>n>32?sv(e,t,n):ov(e,t,n),gv=(e,t,n)=>n>32?av(e,t,n):iv(e,t,n);function fz(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],d=dv(c,l,1)^n[a],g=gv(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=mv[s],u=dv(o,i,a),c=gv(o,i,a),l=fv[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]^=dz[r],e[1]^=gz[r]}Zf(n)}var tm=class e{constructor(t,n,r,o=!1,i=24){or(this,"state");or(this,"pos",0);or(this,"posOut",0);or(this,"finished",!1);or(this,"state32");or(this,"destroyed",!1);or(this,"blockLen");or(this,"suffix");or(this,"outputLen");or(this,"enableXOF",!1);or(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Qf(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=cv(this.state)}clone(){return this._cloneInto()}keccak(){em(this.state32),fz(this.state32,this.rounds),em(this.state32),this.posOut=0,this.pos=0}update(t){Jf(this),Hl(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){Jf(this,!1),Hl(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 Qf(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lv(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,Zf(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}},mz=(e,t,n,r={})=>uv(()=>new tm(t,e,n),r);var yv=mz(6,72,64,pv(10));var hz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,nm=Math.ceil,ur=Math.floor,On="[BigNumber Error] ",bv=On+"Number primitive has more than 15 significant digits: ",Tr=1e14,Ve=14,rm=9007199254740991,om=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],To=1e7,an=1e9;function Sv(e){var t,n,r,o=I.prototype={constructor:I,toString:null,valueOf:null},i=new I(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,g=!1,p=1,f=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},T="0123456789abcdefghijklmnopqrstuvwxyz",E=!0;function I(x,w){var v,C,m,F,S,b,A,L,B=this;if(!(B instanceof I))return new I(x,w);if(w==null){if(x&&x._isBigNumber===!0){B.s=x.s,!x.c||x.e>d?B.c=B.e=null:x.e<l?B.c=[B.e=0]:(B.e=x.e,B.c=x.c.slice());return}if((b=typeof x=="number")&&x*0==0){if(B.s=1/x<0?(x=-x,-1):1,x===~~x){for(F=0,S=x;S>=10;S/=10,F++);F>d?B.c=B.e=null:(B.e=F,B.c=[x]);return}L=String(x)}else{if(!hz.test(L=String(x)))return r(B,L,b);B.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(F=L.indexOf("."))>-1&&(L=L.replace(".","")),(S=L.search(/e/i))>0?(F<0&&(F=S),F+=+L.slice(S+1),L=L.substring(0,S)):F<0&&(F=L.length)}else{if(zt(w,2,T.length,"Base"),w==10&&E)return B=new I(x),P(B,s+B.e+1,a);if(L=String(x),b=typeof x=="number"){if(x*0!=0)return r(B,L,b,w);if(B.s=1/x<0?(L=L.slice(1),-1):1,I.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(bv+x)}else B.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(v=T.slice(0,w),F=S=0,A=L.length;S<A;S++)if(v.indexOf(C=L.charAt(S))<0){if(C=="."){if(S>F){F=A;continue}}else if(!m&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){m=!0,S=-1,F=0;continue}return r(B,String(x),b,w)}b=!1,L=n(L,w,10,B.s),(F=L.indexOf("."))>-1?L=L.replace(".",""):F=L.length}for(S=0;L.charCodeAt(S)===48;S++);for(A=L.length;L.charCodeAt(--A)===48;);if(L=L.slice(S,++A)){if(A-=S,b&&I.DEBUG&&A>15&&(x>rm||x!==ur(x)))throw Error(bv+B.s*x);if((F=F-S-1)>d)B.c=B.e=null;else if(F<l)B.c=[B.e=0];else{if(B.e=F,B.c=[],S=(F+1)%Ve,F<0&&(S+=Ve),S<A){for(S&&B.c.push(+L.slice(0,S)),A-=Ve;S<A;)B.c.push(+L.slice(S,S+=Ve));S=Ve-(L=L.slice(S)).length}else S-=A;for(;S--;L+="0");B.c.push(+L)}}else B.c=[B.e=0]}I.clone=Sv,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(x){var w,v;if(x!=null)if(typeof x=="object"){if(x.hasOwnProperty(w="DECIMAL_PLACES")&&(v=x[w],zt(v,0,an,w),s=v),x.hasOwnProperty(w="ROUNDING_MODE")&&(v=x[w],zt(v,0,8,w),a=v),x.hasOwnProperty(w="EXPONENTIAL_AT")&&(v=x[w],v&&v.pop?(zt(v[0],-an,0,w),zt(v[1],0,an,w),u=v[0],c=v[1]):(zt(v,-an,an,w),u=-(c=v<0?-v:v))),x.hasOwnProperty(w="RANGE"))if(v=x[w],v&&v.pop)zt(v[0],-an,-1,w),zt(v[1],1,an,w),l=v[0],d=v[1];else if(zt(v,-an,an,w),v)l=-(d=v<0?-v:v);else throw Error(On+w+" cannot be zero: "+v);if(x.hasOwnProperty(w="CRYPTO"))if(v=x[w],v===!!v)if(v)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=v;else throw g=!v,Error(On+"crypto unavailable");else g=v;else throw Error(On+w+" not true or false: "+v);if(x.hasOwnProperty(w="MODULO_MODE")&&(v=x[w],zt(v,0,9,w),p=v),x.hasOwnProperty(w="POW_PRECISION")&&(v=x[w],zt(v,0,an,w),f=v),x.hasOwnProperty(w="FORMAT"))if(v=x[w],typeof v=="object")k=v;else throw Error(On+w+" not an object: "+v);if(x.hasOwnProperty(w="ALPHABET"))if(v=x[w],typeof v=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(v))E=v.slice(0,10)=="0123456789",T=v;else throw Error(On+w+" invalid: "+v)}else throw Error(On+"Object expected: "+x);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:g,MODULO_MODE:p,POW_PRECISION:f,FORMAT:k,ALPHABET:T}},I.isBigNumber=function(x){if(!x||x._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var w,v,C=x.c,m=x.e,F=x.s;e:if({}.toString.call(C)=="[object Array]"){if((F===1||F===-1)&&m>=-an&&m<=an&&m===ur(m)){if(C[0]===0){if(m===0&&C.length===1)return!0;break e}if(w=(m+1)%Ve,w<1&&(w+=Ve),String(C[0]).length==w){for(w=0;w<C.length;w++)if(v=C[w],v<0||v>=Tr||v!==ur(v))break e;if(v!==0)return!0}}}else if(C===null&&m===null&&(F===null||F===1||F===-1))return!0;throw Error(On+"Invalid BigNumber: "+x)},I.maximum=I.max=function(){return R(arguments,-1)},I.minimum=I.min=function(){return R(arguments,1)},I.random=(function(){var x=9007199254740992,w=Math.random()*x&2097151?function(){return ur(Math.random()*x)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(v){var C,m,F,S,b,A=0,L=[],B=new I(i);if(v==null?v=s:zt(v,0,an),S=nm(v/Ve),g)if(crypto.getRandomValues){for(C=crypto.getRandomValues(new Uint32Array(S*=2));A<S;)b=C[A]*131072+(C[A+1]>>>11),b>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),C[A]=m[0],C[A+1]=m[1]):(L.push(b%1e14),A+=2);A=S/2}else if(crypto.randomBytes){for(C=crypto.randomBytes(S*=7);A<S;)b=(C[A]&31)*281474976710656+C[A+1]*1099511627776+C[A+2]*4294967296+C[A+3]*16777216+(C[A+4]<<16)+(C[A+5]<<8)+C[A+6],b>=9e15?crypto.randomBytes(7).copy(C,A):(L.push(b%1e14),A+=7);A=S/7}else throw g=!1,Error(On+"crypto unavailable");if(!g)for(;A<S;)b=w(),b<9e15&&(L[A++]=b%1e14);for(S=L[--A],v%=Ve,S&&v&&(b=om[Ve-v],L[A]=ur(S/b)*b);L[A]===0;L.pop(),A--);if(A<0)L=[F=0];else{for(F=-1;L[0]===0;L.splice(0,1),F-=Ve);for(A=1,b=L[0];b>=10;b/=10,A++);A<Ve&&(F-=Ve-A)}return B.e=F,B.c=L,B}})(),I.sum=function(){for(var x=1,w=arguments,v=new I(w[0]);x<w.length;)v=v.plus(w[x++]);return v},n=(function(){var x="0123456789";function w(v,C,m,F){for(var S,b=[0],A,L=0,B=v.length;L<B;){for(A=b.length;A--;b[A]*=C);for(b[0]+=F.indexOf(v.charAt(L++)),S=0;S<b.length;S++)b[S]>m-1&&(b[S+1]==null&&(b[S+1]=0),b[S+1]+=b[S]/m|0,b[S]%=m)}return b.reverse()}return function(v,C,m,F,S){var b,A,L,B,N,h,j,H,M=v.indexOf("."),X=s,ee=a;for(M>=0&&(B=f,f=0,v=v.replace(".",""),H=new I(C),h=H.pow(v.length-M),f=B,H.c=w(ro(cr(h.c),h.e,"0"),10,m,x),H.e=H.c.length),j=w(v,C,m,S?(b=T,x):(b=x,T)),L=B=j.length;j[--B]==0;j.pop());if(!j[0])return b.charAt(0);if(M<0?--L:(h.c=j,h.e=L,h.s=F,h=t(h,H,X,ee,m),j=h.c,N=h.r,L=h.e),A=L+X+1,M=j[A],B=m/2,N=N||A<0||j[A+1]!=null,N=ee<4?(M!=null||N)&&(ee==0||ee==(h.s<0?3:2)):M>B||M==B&&(ee==4||N||ee==6&&j[A-1]&1||ee==(h.s<0?8:7)),A<1||!j[0])v=N?ro(b.charAt(1),-X,b.charAt(0)):b.charAt(0);else{if(j.length=A,N)for(--m;++j[--A]>m;)j[A]=0,A||(++L,j=[1].concat(j));for(B=j.length;!j[--B];);for(M=0,v="";M<=B;v+=b.charAt(j[M++]));v=ro(v,L,b.charAt(0))}return v}})(),t=(function(){function x(C,m,F){var S,b,A,L,B=0,N=C.length,h=m%To,j=m/To|0;for(C=C.slice();N--;)A=C[N]%To,L=C[N]/To|0,S=j*A+L*h,b=h*A+S%To*To+B,B=(b/F|0)+(S/To|0)+j*L,C[N]=b%F;return B&&(C=[B].concat(C)),C}function w(C,m,F,S){var b,A;if(F!=S)A=F>S?1:-1;else for(b=A=0;b<F;b++)if(C[b]!=m[b]){A=C[b]>m[b]?1:-1;break}return A}function v(C,m,F,S){for(var b=0;F--;)C[F]-=b,b=C[F]<m[F]?1:0,C[F]=b*S+C[F]-m[F];for(;!C[0]&&C.length>1;C.splice(0,1));}return function(C,m,F,S,b){var A,L,B,N,h,j,H,M,X,ee,me,xe,oe,Ye,be,Te,te,Me=C.s==m.s?1:-1,Ae=C.c,pe=m.c;if(!Ae||!Ae[0]||!pe||!pe[0])return new I(!C.s||!m.s||(Ae?pe&&Ae[0]==pe[0]:!pe)?NaN:Ae&&Ae[0]==0||!pe?Me*0:Me/0);for(M=new I(Me),X=M.c=[],L=C.e-m.e,Me=F+L+1,b||(b=Tr,L=pr(C.e/Ve)-pr(m.e/Ve),Me=Me/Ve|0),B=0;pe[B]==(Ae[B]||0);B++);if(pe[B]>(Ae[B]||0)&&L--,Me<0)X.push(1),N=!0;else{for(Ye=Ae.length,Te=pe.length,B=0,Me+=2,h=ur(b/(pe[0]+1)),h>1&&(pe=x(pe,h,b),Ae=x(Ae,h,b),Te=pe.length,Ye=Ae.length),oe=Te,ee=Ae.slice(0,Te),me=ee.length;me<Te;ee[me++]=0);te=pe.slice(),te=[0].concat(te),be=pe[0],pe[1]>=b/2&&be++;do{if(h=0,A=w(pe,ee,Te,me),A<0){if(xe=ee[0],Te!=me&&(xe=xe*b+(ee[1]||0)),h=ur(xe/be),h>1)for(h>=b&&(h=b-1),j=x(pe,h,b),H=j.length,me=ee.length;w(j,ee,H,me)==1;)h--,v(j,Te<H?te:pe,H,b),H=j.length,A=1;else h==0&&(A=h=1),j=pe.slice(),H=j.length;if(H<me&&(j=[0].concat(j)),v(ee,j,me,b),me=ee.length,A==-1)for(;w(pe,ee,Te,me)<1;)h++,v(ee,Te<me?te:pe,me,b),me=ee.length}else A===0&&(h++,ee=[0]);X[B++]=h,ee[0]?ee[me++]=Ae[oe]||0:(ee=[Ae[oe]],me=1)}while((oe++<Ye||ee[0]!=null)&&Me--);N=ee[0]!=null,X[0]||X.splice(0,1)}if(b==Tr){for(B=1,Me=X[0];Me>=10;Me/=10,B++);P(M,F+(M.e=B+L*Ve-1)+1,S,N)}else M.e=L,M.r=+N;return M}})();function D(x,w,v,C){var m,F,S,b,A;if(v==null?v=a:zt(v,0,8),!x.c)return x.toString();if(m=x.c[0],S=x.e,w==null)A=cr(x.c),A=C==1||C==2&&(S<=u||S>=c)?Vl(A,S):ro(A,S,"0");else if(x=P(new I(x),w,v),F=x.e,A=cr(x.c),b=A.length,C==1||C==2&&(w<=F||F<=u)){for(;b<w;A+="0",b++);A=Vl(A,F)}else if(w-=S+(C===2&&F>S),A=ro(A,F,"0"),F+1>b){if(--w>0)for(A+=".";w--;A+="0");}else if(w+=F-b,w>0)for(F+1==b&&(A+=".");w--;A+="0");return x.s<0&&m?"-"+A:A}function R(x,w){for(var v,C,m=1,F=new I(x[0]);m<x.length;m++)C=new I(x[m]),(!C.s||(v=ei(F,C))===w||v===0&&F.s===w)&&(F=C);return F}function $(x,w,v){for(var C=1,m=w.length;!w[--m];w.pop());for(m=w[0];m>=10;m/=10,C++);return(v=C+v*Ve-1)>d?x.c=x.e=null:v<l?x.c=[x.e=0]:(x.e=v,x.c=w),x}r=(function(){var x=/^(-?)0([xbo])(?=\w[\w.]*$)/i,w=/^([^.]+)\.$/,v=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(F,S,b,A){var L,B=b?S:S.replace(m,"");if(C.test(B))F.s=isNaN(B)?null:B<0?-1:1;else{if(!b&&(B=B.replace(x,function(N,h,j){return L=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==L?h:N}),A&&(L=A,B=B.replace(w,"$1").replace(v,"0.$1")),S!=B))return new I(B,L);if(I.DEBUG)throw Error(On+"Not a"+(A?" base "+A:"")+" number: "+S);F.s=null}F.c=F.e=null}})();function P(x,w,v,C){var m,F,S,b,A,L,B,N=x.c,h=om;if(N){e:{for(m=1,b=N[0];b>=10;b/=10,m++);if(F=w-m,F<0)F+=Ve,S=w,A=N[L=0],B=ur(A/h[m-S-1]%10);else if(L=nm((F+1)/Ve),L>=N.length)if(C){for(;N.length<=L;N.push(0));A=B=0,m=1,F%=Ve,S=F-Ve+1}else break e;else{for(A=b=N[L],m=1;b>=10;b/=10,m++);F%=Ve,S=F-Ve+m,B=S<0?0:ur(A/h[m-S-1]%10)}if(C=C||w<0||N[L+1]!=null||(S<0?A:A%h[m-S-1]),C=v<4?(B||C)&&(v==0||v==(x.s<0?3:2)):B>5||B==5&&(v==4||C||v==6&&(F>0?S>0?A/h[m-S]:0:N[L-1])%10&1||v==(x.s<0?8:7)),w<1||!N[0])return N.length=0,C?(w-=x.e+1,N[0]=h[(Ve-w%Ve)%Ve],x.e=-w||0):N[0]=x.e=0,x;if(F==0?(N.length=L,b=1,L--):(N.length=L+1,b=h[Ve-F],N[L]=S>0?ur(A/h[m-S]%h[S])*b:0),C)for(;;)if(L==0){for(F=1,S=N[0];S>=10;S/=10,F++);for(S=N[0]+=b,b=1;S>=10;S/=10,b++);F!=b&&(x.e++,N[0]==Tr&&(N[0]=1));break}else{if(N[L]+=b,N[L]!=Tr)break;N[L--]=0,b=1}for(F=N.length;N[--F]===0;N.pop());}x.e>d?x.c=x.e=null:x.e<l&&(x.c=[x.e=0])}return x}function z(x){var w,v=x.e;return v===null?x.toString():(w=cr(x.c),w=v<=u||v>=c?Vl(w,v):ro(w,v,"0"),x.s<0?"-"+w:w)}return o.absoluteValue=o.abs=function(){var x=new I(this);return x.s<0&&(x.s=1),x},o.comparedTo=function(x,w){return ei(this,new I(x,w))},o.decimalPlaces=o.dp=function(x,w){var v,C,m,F=this;if(x!=null)return zt(x,0,an),w==null?w=a:zt(w,0,8),P(new I(F),x+F.e+1,w);if(!(v=F.c))return null;if(C=((m=v.length-1)-pr(this.e/Ve))*Ve,m=v[m])for(;m%10==0;m/=10,C--);return C<0&&(C=0),C},o.dividedBy=o.div=function(x,w){return t(this,new I(x,w),s,a)},o.dividedToIntegerBy=o.idiv=function(x,w){return t(this,new I(x,w),0,1)},o.exponentiatedBy=o.pow=function(x,w){var v,C,m,F,S,b,A,L,B,N=this;if(x=new I(x),x.c&&!x.isInteger())throw Error(On+"Exponent not an integer: "+z(x));if(w!=null&&(w=new I(w)),b=x.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!x.c||!x.c[0])return B=new I(Math.pow(+z(N),b?x.s*(2-Wl(x)):+z(x))),w?B.mod(w):B;if(A=x.s<0,w){if(w.c?!w.c[0]:!w.s)return new I(NaN);C=!A&&N.isInteger()&&w.isInteger(),C&&(N=N.mod(w))}else{if(x.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||b&&N.c[1]>=24e7:N.c[0]<8e13||b&&N.c[0]<=9999975e7)))return F=N.s<0&&Wl(x)?-0:0,N.e>-1&&(F=1/F),new I(A?1/F:F);f&&(F=nm(f/Ve+2))}for(b?(v=new I(.5),A&&(x.s=1),L=Wl(x)):(m=Math.abs(+z(x)),L=m%2),B=new I(i);;){if(L){if(B=B.times(N),!B.c)break;F?B.c.length>F&&(B.c.length=F):C&&(B=B.mod(w))}if(m){if(m=ur(m/2),m===0)break;L=m%2}else if(x=x.times(v),P(x,x.e+1,1),x.e>14)L=Wl(x);else{if(m=+z(x),m===0)break;L=m%2}N=N.times(N),F?N.c&&N.c.length>F&&(N.c.length=F):C&&(N=N.mod(w))}return C?B:(A&&(B=i.div(B)),w?B.mod(w):F?P(B,f,a,S):B)},o.integerValue=function(x){var w=new I(this);return x==null?x=a:zt(x,0,8),P(w,w.e+1,x)},o.isEqualTo=o.eq=function(x,w){return ei(this,new I(x,w))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(x,w){return ei(this,new I(x,w))>0},o.isGreaterThanOrEqualTo=o.gte=function(x,w){return(w=ei(this,new I(x,w)))===1||w===0},o.isInteger=function(){return!!this.c&&pr(this.e/Ve)>this.c.length-2},o.isLessThan=o.lt=function(x,w){return ei(this,new I(x,w))<0},o.isLessThanOrEqualTo=o.lte=function(x,w){return(w=ei(this,new I(x,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(x,w){var v,C,m,F,S=this,b=S.s;if(x=new I(x,w),w=x.s,!b||!w)return new I(NaN);if(b!=w)return x.s=-w,S.plus(x);var A=S.e/Ve,L=x.e/Ve,B=S.c,N=x.c;if(!A||!L){if(!B||!N)return B?(x.s=-w,x):new I(N?S:NaN);if(!B[0]||!N[0])return N[0]?(x.s=-w,x):new I(B[0]?S:a==3?-0:0)}if(A=pr(A),L=pr(L),B=B.slice(),b=A-L){for((F=b<0)?(b=-b,m=B):(L=A,m=N),m.reverse(),w=b;w--;m.push(0));m.reverse()}else for(C=(F=(b=B.length)<(w=N.length))?b:w,b=w=0;w<C;w++)if(B[w]!=N[w]){F=B[w]<N[w];break}if(F&&(m=B,B=N,N=m,x.s=-x.s),w=(C=N.length)-(v=B.length),w>0)for(;w--;B[v++]=0);for(w=Tr-1;C>b;){if(B[--C]<N[C]){for(v=C;v&&!B[--v];B[v]=w);--B[v],B[C]+=Tr}B[C]-=N[C]}for(;B[0]==0;B.splice(0,1),--L);return B[0]?$(x,B,L):(x.s=a==3?-1:1,x.c=[x.e=0],x)},o.modulo=o.mod=function(x,w){var v,C,m=this;return x=new I(x,w),!m.c||!x.s||x.c&&!x.c[0]?new I(NaN):!x.c||m.c&&!m.c[0]?new I(m):(p==9?(C=x.s,x.s=1,v=t(m,x,0,3),x.s=C,v.s*=C):v=t(m,x,0,p),x=m.minus(v.times(x)),!x.c[0]&&p==1&&(x.s=m.s),x)},o.multipliedBy=o.times=function(x,w){var v,C,m,F,S,b,A,L,B,N,h,j,H,M,X,ee=this,me=ee.c,xe=(x=new I(x,w)).c;if(!me||!xe||!me[0]||!xe[0])return!ee.s||!x.s||me&&!me[0]&&!xe||xe&&!xe[0]&&!me?x.c=x.e=x.s=null:(x.s*=ee.s,!me||!xe?x.c=x.e=null:(x.c=[0],x.e=0)),x;for(C=pr(ee.e/Ve)+pr(x.e/Ve),x.s*=ee.s,A=me.length,N=xe.length,A<N&&(H=me,me=xe,xe=H,m=A,A=N,N=m),m=A+N,H=[];m--;H.push(0));for(M=Tr,X=To,m=N;--m>=0;){for(v=0,h=xe[m]%X,j=xe[m]/X|0,S=A,F=m+S;F>m;)L=me[--S]%X,B=me[S]/X|0,b=j*L+B*h,L=h*L+b%X*X+H[F]+v,v=(L/M|0)+(b/X|0)+j*B,H[F--]=L%M;H[F]=v}return v?++C:H.splice(0,1),$(x,H,C)},o.negated=function(){var x=new I(this);return x.s=-x.s||null,x},o.plus=function(x,w){var v,C=this,m=C.s;if(x=new I(x,w),w=x.s,!m||!w)return new I(NaN);if(m!=w)return x.s=-w,C.minus(x);var F=C.e/Ve,S=x.e/Ve,b=C.c,A=x.c;if(!F||!S){if(!b||!A)return new I(m/0);if(!b[0]||!A[0])return A[0]?x:new I(b[0]?C:m*0)}if(F=pr(F),S=pr(S),b=b.slice(),m=F-S){for(m>0?(S=F,v=A):(m=-m,v=b),v.reverse();m--;v.push(0));v.reverse()}for(m=b.length,w=A.length,m-w<0&&(v=A,A=b,b=v,w=m),m=0;w;)m=(b[--w]=b[w]+A[w]+m)/Tr|0,b[w]=Tr===b[w]?0:b[w]%Tr;return m&&(b=[m].concat(b),++S),$(x,b,S)},o.precision=o.sd=function(x,w){var v,C,m,F=this;if(x!=null&&x!==!!x)return zt(x,1,an),w==null?w=a:zt(w,0,8),P(new I(F),x,w);if(!(v=F.c))return null;if(m=v.length-1,C=m*Ve+1,m=v[m]){for(;m%10==0;m/=10,C--);for(m=v[0];m>=10;m/=10,C++);}return x&&F.e+1>C&&(C=F.e+1),C},o.shiftedBy=function(x){return zt(x,-rm,rm),this.times("1e"+x)},o.squareRoot=o.sqrt=function(){var x,w,v,C,m,F=this,S=F.c,b=F.s,A=F.e,L=s+4,B=new I("0.5");if(b!==1||!S||!S[0])return new I(!b||b<0&&(!S||S[0])?NaN:S?F:1/0);if(b=Math.sqrt(+z(F)),b==0||b==1/0?(w=cr(S),(w.length+A)%2==0&&(w+="0"),b=Math.sqrt(+w),A=pr((A+1)/2)-(A<0||A%2),b==1/0?w="5e"+A:(w=b.toExponential(),w=w.slice(0,w.indexOf("e")+1)+A),v=new I(w)):v=new I(b+""),v.c[0]){for(A=v.e,b=A+L,b<3&&(b=0);;)if(m=v,v=B.times(m.plus(t(F,m,L,1))),cr(m.c).slice(0,b)===(w=cr(v.c)).slice(0,b))if(v.e<A&&--b,w=w.slice(b-3,b+1),w=="9999"||!C&&w=="4999"){if(!C&&(P(m,m.e+s+2,0),m.times(m).eq(F))){v=m;break}L+=4,b+=4,C=1}else{(!+w||!+w.slice(1)&&w.charAt(0)=="5")&&(P(v,v.e+s+2,1),x=!v.times(v).eq(F));break}}return P(v,v.e+s+1,a,x)},o.toExponential=function(x,w){return x!=null&&(zt(x,0,an),x++),D(this,x,w,1)},o.toFixed=function(x,w){return x!=null&&(zt(x,0,an),x=x+this.e+1),D(this,x,w)},o.toFormat=function(x,w,v){var C,m=this;if(v==null)x!=null&&w&&typeof w=="object"?(v=w,w=null):x&&typeof x=="object"?(v=x,x=w=null):v=k;else if(typeof v!="object")throw Error(On+"Argument not an object: "+v);if(C=m.toFixed(x,w),m.c){var F,S=C.split("."),b=+v.groupSize,A=+v.secondaryGroupSize,L=v.groupSeparator||"",B=S[0],N=S[1],h=m.s<0,j=h?B.slice(1):B,H=j.length;if(A&&(F=b,b=A,A=F,H-=F),b>0&&H>0){for(F=H%b||b,B=j.substr(0,F);F<H;F+=b)B+=L+j.substr(F,b);A>0&&(B+=L+j.slice(F)),h&&(B="-"+B)}C=N?B+(v.decimalSeparator||"")+((A=+v.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(v.fractionGroupSeparator||"")):N):B}return(v.prefix||"")+C+(v.suffix||"")},o.toFraction=function(x){var w,v,C,m,F,S,b,A,L,B,N,h,j=this,H=j.c;if(x!=null&&(b=new I(x),!b.isInteger()&&(b.c||b.s!==1)||b.lt(i)))throw Error(On+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+z(b));if(!H)return new I(j);for(w=new I(i),L=v=new I(i),C=A=new I(i),h=cr(H),F=w.e=h.length-j.e-1,w.c[0]=om[(S=F%Ve)<0?Ve+S:S],x=!x||b.comparedTo(w)>0?F>0?w:L:b,S=d,d=1/0,b=new I(h),A.c[0]=0;B=t(b,w,0,1),m=v.plus(B.times(C)),m.comparedTo(x)!=1;)v=C,C=m,L=A.plus(B.times(m=L)),A=m,w=b.minus(B.times(m=w)),b=m;return m=t(x.minus(v),C,0,1),A=A.plus(m.times(L)),v=v.plus(m.times(C)),A.s=L.s=j.s,F=F*2,N=t(L,C,F,a).minus(j).abs().comparedTo(t(A,v,F,a).minus(j).abs())<1?[L,C]:[A,v],d=S,N},o.toNumber=function(){return+z(this)},o.toPrecision=function(x,w){return x!=null&&zt(x,1,an),D(this,x,w,2)},o.toString=function(x){var w,v=this,C=v.s,m=v.e;return m===null?C?(w="Infinity",C<0&&(w="-"+w)):w="NaN":(x==null?w=m<=u||m>=c?Vl(cr(v.c),m):ro(cr(v.c),m,"0"):x===10&&E?(v=P(new I(v),s+m+1,a),w=ro(cr(v.c),v.e,"0")):(zt(x,2,T.length,"Base"),w=n(ro(cr(v.c),m,"0"),10,x,C,!0)),C<0&&v.c[0]&&(w="-"+w)),w},o.valueOf=o.toJSON=function(){return z(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&I.set(e),I}function pr(e){var t=e|0;return e>0||e===t?t:t-1}function cr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=Ve-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function ei(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 zt(e,t,n,r){if(e<t||e>n||e!==ur(e))throw Error(On+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Wl(e){var t=e.c.length-1;return pr(e.e/Ve)==t&&e.c[t]%2!=0}function Vl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ro(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 xz=Sv(),wv=xz;var yz=24,Ys=32,bz=()=>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,sm=bz(),im=(e=4,t=sm)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function Sz(e){let t=new wv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var kv=(e="")=>{let t=new TextEncoder;return Sz(yv(t.encode(e))).toString(36).slice(1)},vv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),wz=e=>vv[Math.floor(e()*vv.length)],vz=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=sm}={})=>{let n=Object.keys(e).toString(),r=n.length?n+im(Ys,t):im(Ys,t);return kv(r).substring(0,Ys)},kz=e=>()=>e++,Cz=476782367,Cv=({random:e=sm,counter:t=kz(Math.floor(e()*Cz)),length:n=yz,fingerprint:r=vz({random:e})}={})=>{if(n>Ys)throw new Error(`Length must be between 2 and ${Ys}. Received: ${n}`);return function(){let i=wz(e),s=Date.now().toString(36),a=t().toString(36),u=im(n,e),c=`${s+u+a+r}`;return`${i+kv(c).substring(1,n)}`}},Io=Tz(Cv);function Tz(e){let t;return()=>(t||(t=e()),t())}var Ez=$a(Fv());Rn();Oe();var Gl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function Az(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function am(e,t){let n=[],r=e.split(`
|
|
14
|
+
`,h1="/",x1="*",si="",M3="comment",B3="declaration";function D3(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(f){var k=f.match(C3);k&&(n+=k.length);var T=f.lastIndexOf(L3);r=~T?f.length-T:r+f.length}function i(){var f={line:n,column:r};return function(k){return k.position=new s(f),c(),k}}function s(f){this.start=f,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(f){var k=new Error(t.source+":"+n+":"+r+": "+f);if(k.reason=f,k.filename=t.source,k.line=n,k.column=r,k.source=e,!t.silent)throw k}function u(f){var k=f.exec(e);if(k){var T=k[0];return o(T),e=e.slice(T.length),k}}function c(){u(T3)}function l(f){var k;for(f=f||[];k=d();)k!==!1&&f.push(k);return f}function d(){var f=i();if(!(h1!=e.charAt(0)||x1!=e.charAt(1))){for(var k=2;si!=e.charAt(k)&&(x1!=e.charAt(k)||h1!=e.charAt(k+1));)++k;if(k+=2,si===e.charAt(k-1))return a("End of comment missing");var T=e.slice(2,k-2);return r+=2,o(T),e=e.slice(k),r+=2,f({type:M3,comment:T})}}function g(){var f=i(),k=u(I3);if(k){if(d(),!u(F3))return a("property missing ':'");var T=u(E3),E=f({type:B3,property:y1(k[0].replace(m1,si)),value:T?y1(T[0].replace(m1,si)):si});return u(A3),E}}function p(){var f=[];l(f);for(var k;k=g();)k!==!1&&(f.push(k),l(f));return f}return c(),p()}function y1(e){return e?e.replace(P3,si):si}b1.exports=D3});var w1=rr(fa=>{"use strict";var R3=fa&&fa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(fa,"__esModule",{value:!0});fa.default=N3;var z3=R3(S1());function N3(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,z3.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 k1=rr(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.camelCase=void 0;var O3=/^--[a-zA-Z0-9_-]+$/,_3=/-([a-z])/g,$3=/^[^-]+$/,U3=/^-(webkit|moz|ms|o|khtml)-/,j3=/^-(ms)-/,H3=function(e){return!e||$3.test(e)||O3.test(e)},W3=function(e,t){return t.toUpperCase()},v1=function(e,t){return"".concat(t,"-")},V3=function(e,t){return t===void 0&&(t={}),H3(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(j3,v1):e=e.replace(U3,v1),e.replace(_3,W3))};kc.camelCase=V3});var T1=rr((Ph,C1)=>{"use strict";var G3=Ph&&Ph.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},q3=G3(w1()),Y3=k1();function Ah(e,t){var n={};return!e||typeof e!="string"||(0,q3.default)(e,function(r,o){r&&o&&(n[(0,Y3.camelCase)(r,t)]=o)}),n}Ah.default=Ah;C1.exports=Ah});var JT=rr((Ype,QT)=>{"use strict";var Gc=Object.prototype.hasOwnProperty,XT=Object.prototype.toString,WT=Object.defineProperty,VT=Object.getOwnPropertyDescriptor,GT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):XT.call(t)==="[object Array]"},qT=function(t){if(!t||XT.call(t)!=="[object Object]")return!1;var n=Gc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Gc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Gc.call(t,o)},YT=function(t,n){WT&&n.name==="__proto__"?WT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},KT=function(t,n){if(n==="__proto__")if(Gc.call(t,n)){if(VT)return VT(t,n).value}else return;return t[n]};QT.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=KT(a,n),o=KT(t,n),a!==o&&(l&&o&&(qT(o)||(i=GT(o)))?(i?(i=!1,s=r&>(r)?r:[]):s=r&&qT(r)?r:{},YT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&YT(a,{name:n,newValue:o}));return a}});import Na from"react";import{addons as lu,types as ty,experimental_getStatusStore as OF}from"storybook/manager-api";import{AddonPanel as fV}from"storybook/internal/components";import Dt,{useState as BW,useEffect as DW}from"react";import{styled as xr}from"storybook/theming";import uy from"react";import{styled as Mt}from"storybook/theming";var ae="#ea580c",pu="#c2410c",Ua="#ff6b35";var oy=Mt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),iy=Mt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),ho=Mt.div({marginBottom:"20px"}),xo=Mt.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})),us=Mt.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`}})),hn=Mt.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"}})),sy=Mt(hn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),ja=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"}}),kn=Mt.button(({theme:e})=>({...ja(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Yt=Mt.button(({theme:e})=>({...ja(e),backgroundColor:ae,color:e.color.inverseText,boxShadow:`0 2px 4px ${ae}4d`,"&:hover:not(:disabled)":{backgroundColor:pu,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ae}66`}})),Rr=Mt.button(({theme:e})=>({...ja(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),ay=Mt.button(({theme:e})=>({...ja(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Cn=Mt.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"}})),du=Mt.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"}})),yo=Mt.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}})),bo=Mt(us)(({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"})),vV=Mt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),ly=Mt.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})),kV=Mt.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})),ps=Mt.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})),CV=Mt.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%)"}}})),cy=Mt.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}}),TV=Mt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),IV=Mt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),FV=Mt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var gu=({header:e,children:t,footer:n})=>uy.createElement(oy,null,e,uy.createElement(iy,null,t),n);import qF from"react";import{styled as YF}from"storybook/theming";var KF=YF.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})),fu=({toolbar:e})=>qF.createElement(KF,null,e);import NV from"react";import{styled as Ha}from"storybook/theming";var $V=Ha.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})),UV=Ha.div({display:"flex",flex:1}),jV=Ha(yo)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),HV=Ha.div({display:"flex",gap:"8px",alignItems:"center"});import Zt,{useState as Of,useCallback as zw,useEffect as Nw}from"react";import{styled as eo}from"storybook/theming";import ve,{useEffect as Tw}from"react";import{styled as lt}from"storybook/theming";Ce();je();Oe();ct();var Iw=lt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),Fw=lt.div(({theme:e})=>({position:"absolute",top:"100%",right:0,marginTop:"8px",backgroundColor:e.background.content,borderRadius:"12px",width:"360px",maxWidth:"90vw",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)",overflow:"hidden",zIndex:10001})),DD=lt.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),RD=lt.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:ae,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),zD=lt.div({display:"flex",flexDirection:"column",gap:"4px"}),ND=lt.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),OD=lt.span({display:"inline-block",alignSelf:"flex-start",padding:"2px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:600,color:"#7c3aed",backgroundColor:"rgba(124, 58, 237, 0.1)",letterSpacing:"0.3px"}),_D=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),$D=lt.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),UD=lt.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),jD=lt.div(({theme:e})=>({height:"8px",borderRadius:"4px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",margin:"0 16px 8px",overflow:"hidden"})),HD=lt.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${ae} 100%)`,transition:"width 0.3s ease"})),WD=lt.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),VD=lt.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),GD=lt.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:ae,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),Ew=lt.button(({theme:e})=>({position:"absolute",top:"12px",right:"12px",width:"24px",height:"24px",borderRadius:"4px",border:"none",background:"transparent",color:e.textMutedColor,cursor:"pointer",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:e.background.hoverable}})),qD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),YD=lt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),KD=lt.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})),XD=lt.div({display:"flex",gap:"8px"}),Aw=lt(Cn)({fontSize:"18px"}),QD=lt.div({padding:"20px 16px"}),JD=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),ZD=lt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),eR=lt.div({fontSize:"28px",fontWeight:700}),tR=lt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),nR=lt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),rR=lt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),oR=lt.div({display:"flex",alignItems:"center",gap:"8px"}),iR=lt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),sR=lt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:ae,color:e.color.inverseText})),aR=lt.button(({theme:e})=>({background:"none",border:"none",color:ae,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),lR=lt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),cR=lt.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}})),uR=30*1e3,Pw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ce(),a=s.showCosts,u=r,c=!r&&t,l=async(f=!1)=>{if(!t)return;let k=o&&Date.now()-o<uR;if(!(!f&&k&&r))try{let T=V(),E=await ne(`${T}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(E.ok){let I=await E.json();i(I)}}catch(T){y.error("Failed to fetch usage:",T)}};Tw(()=>{l()},[t]),Tw(()=>{let f=()=>{document.visibilityState==="visible"&&(y.debug("[TokenUsageModal] Tab visible, refreshing balance..."),l(!0))};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[t]);let d=()=>{if(t){let f=V();fetch(`${f}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}).catch(()=>{})}n(),e()},g=()=>{let f=V();window.open(`${f}/pricing`,"_blank")},p=()=>{let f=V();window.open(`${f}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let f=Math.floor(u?.creditBalance??0),T=Math.max(f,10),E=Math.max(0,T-f),I=T>0?f/T*100:0;return ve.createElement(ve.Fragment,null,ve.createElement(Iw,{onClick:e}),ve.createElement(Fw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},ve.createElement(DD,null,ve.createElement(RD,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement(zD,null,ve.createElement(ND,null,"UI Review"),ve.createElement(OD,null,(u?.plan||"BETA").toUpperCase())),ve.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},ve.createElement(Ew,{onClick:d,title:"Sign out",style:{position:"static"}},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Ew,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),ve.createElement(_D,null,ve.createElement($D,null,"Credits"),ve.createElement(UD,null,f," left")),ve.createElement(jD,null,ve.createElement(HD,{percent:I})),ve.createElement(WD,null,E," used \xB7 ",f," remaining"),ve.createElement(VD,null),ve.createElement(GD,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return ve.createElement(ve.Fragment,null,ve.createElement(Iw,{onClick:e}),ve.createElement(Fw,{onClick:f=>f.stopPropagation()},ve.createElement(qD,null,ve.createElement(YD,null,ve.createElement(KD,null,u?.email?u.email[0].toUpperCase():"U"),ve.createElement("span",null,u?.email||"Loading...")),ve.createElement(XD,null,ve.createElement(Aw,{onClick:d,title:"Sign out"},ve.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),ve.createElement("polyline",{points:"16 17 21 12 16 7"}),ve.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),ve.createElement(Aw,{onClick:e,title:"Close"},"\xD7"))),ve.createElement(QD,null,c?ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?ve.createElement(ve.Fragment,null,ve.createElement(JD,null,ve.createElement(ZD,null,"Credit Balance"),ve.createElement(eR,null,"$",(u?.creditBalance??0).toFixed(2)),ve.createElement(tR,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),ve.createElement(nR,null,ve.createElement(rR,null,ve.createElement(oR,null,ve.createElement(iR,null,"Current Plan"),ve.createElement(sR,null,u?.plan||"Free")),ve.createElement(aR,{onClick:g},"View detail >")),ve.createElement(lR,null,"~$0.02-0.05 per review depending on complexity"),ve.createElement(cR,{onClick:p,style:{marginTop:"16px"}},"Add Credits"))):ve.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};Ce();import Pi from"react";import{styled as Lw}from"storybook/theming";je();Ce();ct();Oe();var pR=Lw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),dR=Lw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),gR={admin:{enableFixGeneration:!0,enableFixApply:!0,enableAutoMap:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!0,enableFixApply:!1,enableAutoMap:!0,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1}},Mw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ce(),{sessionToken:o}=we();return e!=="admin"?null:Pi.createElement(pR,null,Pi.createElement(dR,null,"View as:"),Pi.createElement(sy,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ne(`${V()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(c=>c.json()).then(c=>{let l={enableFixGeneration:!!c.enableFixGeneration,enableFixApply:!!c.enableFixApply,enableAutoMap:!!c.enableAutoMap,enableReviewBadges:!!c.enableReviewBadges,showCosts:!!c.showCosts,enableParallelReview:!!c.enableParallelReview,enableModelSelection:!!c.enableModelSelection};r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}).catch(c=>y.warn("[RoleSwitcher] Failed to re-fetch flags:",c.message));else{n(u);let c=gR[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Pi.createElement("option",{value:"admin"},"Admin"),Pi.createElement("option",{value:"beta"},"Beta Tester")),t&&Pi.createElement(cy,{variant:"warning"},"Previewing as ",t))};je();Ce();ct();import ht,{useState as $s,useCallback as Nf}from"react";import{styled as Cr}from"storybook/theming";var fR="0.5.7",mR=[{value:"bug",label:"\u{1F41E} Bug \u2014 something broke"},{value:"ux",label:"\u{1F9ED} UX \u2014 confusing or slow"},{value:"feature",label:"\u2728 Feature \u2014 missing something"},{value:"praise",label:"\u{1F49A} Praise \u2014 works great"},{value:"other",label:"\u{1F4AC} Other"}],hR=Cr.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),xR=Cr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"12px",width:"460px",maxWidth:"94%",maxHeight:"90vh",overflow:"auto",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.25)"})),yR=Cr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),bR=Cr.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),SR=Cr.button(({theme:e})=>({background:"transparent",border:"none",fontSize:"20px",color:e.color.mediumdark,cursor:"pointer",padding:"0 6px",lineHeight:1,"&:hover":{color:e.color.defaultText}})),wR=Cr.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),vR=Cr.textarea(({theme:e})=>({width:"100%",minHeight:"110px",padding:"8px 10px",borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.defaultText,backgroundColor:e.background.app,resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:ae}})),Bw=Cr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),Dw=Cr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),kR=Cr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),CR=Cr.div(({theme:e})=>({padding:"24px 20px",textAlign:"center",display:"flex",flexDirection:"column",gap:"10px","& h4":{margin:0,fontSize:"15px",fontWeight:600,color:e.color.positive},"& p":{margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark}}));function Rw({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=we(),{selectedProjectId:o}=Je(),{currentStoryId:i}=nt(),[s,a]=$s("other"),[u,c]=$s(""),[l,d]=$s(!1),[g,p]=$s(!1),[f,k]=$s(null),T=Nf(()=>{c(""),a("other"),p(!1),k(null),d(!1)},[]),E=Nf(()=>{T(),t()},[T,t]),I=Nf(async D=>{if(D.preventDefault(),!u.trim()){k("Please write a message.");return}if(!r||!n){k("Sign in to send feedback.");return}d(!0),k(null);try{let R=await ne(`${V()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:s,projectId:o||void 0,storyId:i||void 0,addonVersion:fR})});if(!R.ok){let $=await R.json().catch(()=>({}));throw new Error($.error||`Request failed (${R.status})`)}p(!0)}catch(R){k(R instanceof Error?R.message:"Something went wrong")}finally{d(!1)}},[u,s,n,r,o,i]);return e?ht.createElement(hR,{onClick:E},ht.createElement(xR,{onClick:D=>D.stopPropagation()},ht.createElement(yR,null,ht.createElement(bR,null,ht.createElement("span",null,"\u{1F4AC}"),"Send feedback"),ht.createElement(SR,{onClick:E,"aria-label":"Close"},"\xD7")),g?ht.createElement(ht.Fragment,null,ht.createElement(CR,null,ht.createElement("h4",null,"Thanks \u2014 got it."),ht.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),ht.createElement(Bw,null,ht.createElement("span",null),ht.createElement(kn,{onClick:E},"Close"))):ht.createElement("form",{onSubmit:I},ht.createElement(wR,null,ht.createElement(ho,null,ht.createElement(xo,{htmlFor:"feedback-severity"},"Type"),ht.createElement(hn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},mR.map(D=>ht.createElement("option",{key:D.value,value:D.value},D.label)))),ht.createElement(ho,null,ht.createElement(xo,{htmlFor:"feedback-message"},"What happened?"),ht.createElement(vR,{id:"feedback-message",value:u,onChange:D=>c(D.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:l,autoFocus:!0,maxLength:5e3})),ht.createElement(Dw,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),f&&ht.createElement(kR,null,f)),ht.createElement(Bw,null,ht.createElement(Dw,null,i?`Context: ${i}`:"No story selected"),ht.createElement("div",{style:{display:"flex",gap:"8px"}},ht.createElement(kn,{type:"button",onClick:E,disabled:l},"Cancel"),ht.createElement(Yt,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}Ce();je();ct();var TR=eo.div({display:"flex",alignItems:"center"}),Li=eo.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),IR=eo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),FR=eo.div({position:"relative"}),ER=eo.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`}})),Ow=eo.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)"}})),AR=eo.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)"}}}),PR=eo.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}})),LR=eo.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:ae,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${ae}66, 0 2px 4px rgba(0,0,0,0.1)`,transition:"all 0.2s ease",zIndex:9999,"&:hover":{transform:"scale(1.08)",boxShadow:`0 6px 20px ${ae}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),MR=30*1e3,_f=({onOpenSettings:e})=>{let[t,n]=Of(!1),[r,o]=Of(!1),[i,s]=Of(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=we(),{userRole:d,roleOverride:g,featureFlags:p}=ce(),f=g??d;Nw(()=>{(async()=>{if(!(!l||u&&Date.now()-u<MR&&a)){s(!0);try{let $=V(),P=await ne(`${$}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(P.ok){let z=await P.json();c(z)}}catch($){console.error("Failed to fetch balance:",$)}finally{s(!1)}}})()},[l,u,a,c]),Nw(()=>{let D=()=>{document.visibilityState==="visible"&&t&&n(!1)},R=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",D),window.addEventListener("focus",R),()=>{document.removeEventListener("visibilitychange",D),window.removeEventListener("focus",R)}},[t]);let k=zw(()=>{n(!0)},[]),T=zw(()=>{n(!1)},[]),E=a?.creditBalance??0,I=E<2&&!i;return Zt.createElement(TR,null,e&&Zt.createElement(Li,null,Zt.createElement(PR,{onClick:e,title:"Settings"},Zt.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&d==="admin"&&f==="admin"&&Zt.createElement(Li,null,Zt.createElement(Mw,null)),Zt.createElement(Li,null,Zt.createElement(IR,null,"v","0.5.12")),l&&p.showCosts&&Zt.createElement(Li,null,Zt.createElement(Ow,{onClick:k,isLow:I,title:i?"Loading...":a?I?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?Zt.createElement(AR,null):a?`$${E.toFixed(2)}`:"...")),l&&!p.showCosts&&a&&Zt.createElement(Li,null,Zt.createElement(Ow,{onClick:k,isLow:Math.floor(E)<=3,title:`${Math.floor(E)} review credits \u2014 click for details`},"\u26A1 ",Math.floor(E))),Zt.createElement(Li,null,Zt.createElement(FR,null,Zt.createElement(ER,{title:"Account & Usage",onClick:k},a?.email?a.email[0].toUpperCase():"?"),t&&Zt.createElement(Pw,{onClose:T}))),l&&Zt.createElement(LR,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),Zt.createElement(Rw,{isOpen:r,onClose:()=>o(!1)}))};import Lt,{useEffect as x4,useRef as y4}from"react";import{styled as gr}from"storybook/theming";import rt from"react";Ce();Oe();je();ct();Rn();import{useState as BR,useCallback as Mi,useRef as _w,useEffect as DR}from"react";var to=V();y.debug("[useAuth] Module loaded, APP_URL:",to);var Us=()=>{let e=_w(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:d,setDeviceCode:g,setUserCode:p,setVerificationUri:f,setPollingInterval:k,setAuthError:T,resetAuth:E}=we(),I=_w(null),[D,R]=BR(!1),$=Mi(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let C;try{C=await ne(`${to}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(A){let B=A instanceof Error&&A.message.includes("timed out")?`Cannot reach ${Ft.NAME} server at ${to}. Is the dashboard running?`:`Connection failed: ${to} is not responding.`;T(B),y.error("[useAuth]",B);return}if(!C.ok){let A=`Cannot reach ${Ft.NAME} server. Is the dashboard running?`;T(A),y.error("[useAuth]",A);return}let{poll_code:m}=await C.json();y.debug("[useAuth] Got poll_code:",m.substring(0,15)+"...");let F=localStorage.getItem("uicopilot_force_sign_in")==="true";F&&localStorage.removeItem("uicopilot_force_sign_in");let S=`${to}/addon/auth?poll_code=${m}${F?"&force_sign_in=true":""}`;R(!0),window.open(S,"uiparity-auth","width=520,height=620,left=300,top=150"),y.debug("[useAuth] Starting OAuth poll for token..."),I.current&&clearInterval(I.current);let b=async()=>{try{let L=await(await fetch(`${to}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:m})})).json();L.status==="authorized"&&L.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),I.current&&(clearInterval(I.current),I.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token),R(!1)):L.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),I.current&&(clearInterval(I.current),I.current=null),R(!1))}catch(A){y.error("[useAuth] OAuth poll error:",A)}};I.current=setInterval(b,2e3),setTimeout(b,1e3)}catch(C){y.error("[useAuth] OAuth flow error:",C),T(`Connection failed. Is the dashboard running at ${to}?`),R(!1)}},[c,T]),P=Mi(async()=>{try{let C=await fetch(`${to}/api/addon/auth/device`,{method:"POST"});if(!C.ok)throw new Error("Failed to start device code flow");let m=await C.json();g(m.device_code),p(m.user_code),f(m.verification_uri),window.open(m.verification_uri,"_blank"),z(m.device_code,m.interval*1e3)}catch(C){throw y.error("[useAuth] Device code flow error:",C),C}},[g,p,f]),z=Mi((C,m)=>{y.debug("[useAuth] Starting polling. Device code:",C,"Interval:",m),e.current&&clearInterval(e.current);let F=async()=>{try{let b=await(await fetch(`${to}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:C})})).json();b.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null),localStorage.setItem("uicopilot_session_token",b.session_token),c(b.session_token),setOauthUrl(null)):(b.status==="expired"||b.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null))}catch(S){y.error("[useAuth] Polling error:",S)}};e.current=setInterval(F,m),k(m)},[g,p,f,c,k]),x=Mi(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),p(null),f(null),k(null)},[g,p,f,k]),w=Mi(C=>{l(C),c(C),localStorage.setItem("uicopilot_api_key",C)},[l,c]),v=Mi(()=>{E(),setOauthUrl(null),e.current&&(clearInterval(e.current),e.current=null),I.current&&(clearInterval(I.current),I.current=null)},[E]);return DR(()=>()=>{e.current&&clearInterval(e.current),I.current&&clearInterval(I.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthPending:D,setAuthMethod:d,startOAuth:$,startDeviceCode:P,cancelDeviceCode:x,saveApiKey:w,logout:v}};Ce();Oe();je();ct();import{useCallback as zl}from"react";var js=V(),no=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Je(),{sessionToken:a}=we(),u=zl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${js}/api/projects`);let g=await ne(`${js}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let p=await g.json();y.debug("[useProjects] Projects:",p.projects),r(p.projects||[])}else y.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){y.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=zl(async g=>{if(!a)throw new Error("Not authenticated");let p=await ne(`${js}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!p.ok)throw new Error("Failed to create project");let f=await p.json();return await u(),f.project},[a,u]),l=zl(async(g,p)=>{if(!a)throw new Error("Not authenticated");let f={};if(p.name!==void 0&&(f.name=p.name),p.description!==void 0&&(f.description=p.description),p.figmaFileUrl!==void 0&&(f.figmaFileId=p.figmaFileUrl||void 0),!(await ne(`${js}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(f)})).ok)throw new Error("Failed to update project");await u()},[a,u]),d=zl(async g=>{if(!a)throw new Error("Not authenticated");if(!(await ne(`${js}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:d}};Ce();var Hs=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d}=nt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:d,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};Ce();Wf();Xf();import{useCallback as Qs,useRef as Yl}from"react";Oe();function Ul(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){y.warn("[iframeReload] No preview iframe found"),e();return}let n=t.contentWindow.location.href,r=new URL(n);r.searchParams.set("_cb",Date.now().toString());let o=r.toString();y.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{y.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",s),e()},5e3),s=()=>{clearTimeout(i),t.removeEventListener("load",s),y.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{y.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",s),t.contentWindow.location.href=o})}var jl=BigInt(4294967295),nv=BigInt(32);function nz(e,t=!1){return t?{h:Number(e&jl),l:Number(e>>nv&jl)}:{h:Number(e>>nv&jl)|0,l:Number(e&jl)|0}}function rv(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}=nz(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var ov=(e,t,n)=>e<<n|t>>>32-n,iv=(e,t,n)=>t<<n|e>>>32-n,sv=(e,t,n)=>t<<n-32|e>>>64-n,av=(e,t,n)=>e<<n-32|t>>>64-n;function rz(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qf(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Hl(e,t,n=""){let r=rz(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 Jf(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 lv(e,t){Hl(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 cv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Zf(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var oz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function iz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function sz(e){for(let t=0;t<e.length;t++)e[t]=iz(e[t]);return e}var em=oz?e=>e:sz;function uv(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 pv=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var az=BigInt(0),qs=BigInt(1),lz=BigInt(2),cz=BigInt(7),uz=BigInt(256),pz=BigInt(113),fv=[],mv=[],hv=[];for(let e=0,t=qs,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],fv.push(2*(5*r+n)),mv.push((e+1)*(e+2)/2%64);let o=az;for(let i=0;i<7;i++)t=(t<<qs^(t>>cz)*pz)%uz,t&lz&&(o^=qs<<(qs<<BigInt(i))-qs);hv.push(o)}var xv=rv(hv,!0),dz=xv[0],gz=xv[1],dv=(e,t,n)=>n>32?sv(e,t,n):ov(e,t,n),gv=(e,t,n)=>n>32?av(e,t,n):iv(e,t,n);function fz(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],d=dv(c,l,1)^n[a],g=gv(c,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=mv[s],u=dv(o,i,a),c=gv(o,i,a),l=fv[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]^=dz[r],e[1]^=gz[r]}Zf(n)}var tm=class e{constructor(t,n,r,o=!1,i=24){or(this,"state");or(this,"pos",0);or(this,"posOut",0);or(this,"finished",!1);or(this,"state32");or(this,"destroyed",!1);or(this,"blockLen");or(this,"suffix");or(this,"outputLen");or(this,"enableXOF",!1);or(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Qf(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=cv(this.state)}clone(){return this._cloneInto()}keccak(){em(this.state32),fz(this.state32,this.rounds),em(this.state32),this.posOut=0,this.pos=0}update(t){Jf(this),Hl(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){Jf(this,!1),Hl(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 Qf(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lv(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,Zf(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}},mz=(e,t,n,r={})=>uv(()=>new tm(t,e,n),r);var yv=mz(6,72,64,pv(10));var hz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,nm=Math.ceil,ur=Math.floor,On="[BigNumber Error] ",bv=On+"Number primitive has more than 15 significant digits: ",Tr=1e14,Ve=14,rm=9007199254740991,om=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],To=1e7,an=1e9;function Sv(e){var t,n,r,o=I.prototype={constructor:I,toString:null,valueOf:null},i=new I(1),s=20,a=4,u=-7,c=21,l=-1e7,d=1e7,g=!1,p=1,f=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},T="0123456789abcdefghijklmnopqrstuvwxyz",E=!0;function I(x,w){var v,C,m,F,S,b,A,L,B=this;if(!(B instanceof I))return new I(x,w);if(w==null){if(x&&x._isBigNumber===!0){B.s=x.s,!x.c||x.e>d?B.c=B.e=null:x.e<l?B.c=[B.e=0]:(B.e=x.e,B.c=x.c.slice());return}if((b=typeof x=="number")&&x*0==0){if(B.s=1/x<0?(x=-x,-1):1,x===~~x){for(F=0,S=x;S>=10;S/=10,F++);F>d?B.c=B.e=null:(B.e=F,B.c=[x]);return}L=String(x)}else{if(!hz.test(L=String(x)))return r(B,L,b);B.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(F=L.indexOf("."))>-1&&(L=L.replace(".","")),(S=L.search(/e/i))>0?(F<0&&(F=S),F+=+L.slice(S+1),L=L.substring(0,S)):F<0&&(F=L.length)}else{if(zt(w,2,T.length,"Base"),w==10&&E)return B=new I(x),P(B,s+B.e+1,a);if(L=String(x),b=typeof x=="number"){if(x*0!=0)return r(B,L,b,w);if(B.s=1/x<0?(L=L.slice(1),-1):1,I.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(bv+x)}else B.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(v=T.slice(0,w),F=S=0,A=L.length;S<A;S++)if(v.indexOf(C=L.charAt(S))<0){if(C=="."){if(S>F){F=A;continue}}else if(!m&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){m=!0,S=-1,F=0;continue}return r(B,String(x),b,w)}b=!1,L=n(L,w,10,B.s),(F=L.indexOf("."))>-1?L=L.replace(".",""):F=L.length}for(S=0;L.charCodeAt(S)===48;S++);for(A=L.length;L.charCodeAt(--A)===48;);if(L=L.slice(S,++A)){if(A-=S,b&&I.DEBUG&&A>15&&(x>rm||x!==ur(x)))throw Error(bv+B.s*x);if((F=F-S-1)>d)B.c=B.e=null;else if(F<l)B.c=[B.e=0];else{if(B.e=F,B.c=[],S=(F+1)%Ve,F<0&&(S+=Ve),S<A){for(S&&B.c.push(+L.slice(0,S)),A-=Ve;S<A;)B.c.push(+L.slice(S,S+=Ve));S=Ve-(L=L.slice(S)).length}else S-=A;for(;S--;L+="0");B.c.push(+L)}}else B.c=[B.e=0]}I.clone=Sv,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(x){var w,v;if(x!=null)if(typeof x=="object"){if(x.hasOwnProperty(w="DECIMAL_PLACES")&&(v=x[w],zt(v,0,an,w),s=v),x.hasOwnProperty(w="ROUNDING_MODE")&&(v=x[w],zt(v,0,8,w),a=v),x.hasOwnProperty(w="EXPONENTIAL_AT")&&(v=x[w],v&&v.pop?(zt(v[0],-an,0,w),zt(v[1],0,an,w),u=v[0],c=v[1]):(zt(v,-an,an,w),u=-(c=v<0?-v:v))),x.hasOwnProperty(w="RANGE"))if(v=x[w],v&&v.pop)zt(v[0],-an,-1,w),zt(v[1],1,an,w),l=v[0],d=v[1];else if(zt(v,-an,an,w),v)l=-(d=v<0?-v:v);else throw Error(On+w+" cannot be zero: "+v);if(x.hasOwnProperty(w="CRYPTO"))if(v=x[w],v===!!v)if(v)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=v;else throw g=!v,Error(On+"crypto unavailable");else g=v;else throw Error(On+w+" not true or false: "+v);if(x.hasOwnProperty(w="MODULO_MODE")&&(v=x[w],zt(v,0,9,w),p=v),x.hasOwnProperty(w="POW_PRECISION")&&(v=x[w],zt(v,0,an,w),f=v),x.hasOwnProperty(w="FORMAT"))if(v=x[w],typeof v=="object")k=v;else throw Error(On+w+" not an object: "+v);if(x.hasOwnProperty(w="ALPHABET"))if(v=x[w],typeof v=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(v))E=v.slice(0,10)=="0123456789",T=v;else throw Error(On+w+" invalid: "+v)}else throw Error(On+"Object expected: "+x);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,d],CRYPTO:g,MODULO_MODE:p,POW_PRECISION:f,FORMAT:k,ALPHABET:T}},I.isBigNumber=function(x){if(!x||x._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var w,v,C=x.c,m=x.e,F=x.s;e:if({}.toString.call(C)=="[object Array]"){if((F===1||F===-1)&&m>=-an&&m<=an&&m===ur(m)){if(C[0]===0){if(m===0&&C.length===1)return!0;break e}if(w=(m+1)%Ve,w<1&&(w+=Ve),String(C[0]).length==w){for(w=0;w<C.length;w++)if(v=C[w],v<0||v>=Tr||v!==ur(v))break e;if(v!==0)return!0}}}else if(C===null&&m===null&&(F===null||F===1||F===-1))return!0;throw Error(On+"Invalid BigNumber: "+x)},I.maximum=I.max=function(){return R(arguments,-1)},I.minimum=I.min=function(){return R(arguments,1)},I.random=(function(){var x=9007199254740992,w=Math.random()*x&2097151?function(){return ur(Math.random()*x)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(v){var C,m,F,S,b,A=0,L=[],B=new I(i);if(v==null?v=s:zt(v,0,an),S=nm(v/Ve),g)if(crypto.getRandomValues){for(C=crypto.getRandomValues(new Uint32Array(S*=2));A<S;)b=C[A]*131072+(C[A+1]>>>11),b>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),C[A]=m[0],C[A+1]=m[1]):(L.push(b%1e14),A+=2);A=S/2}else if(crypto.randomBytes){for(C=crypto.randomBytes(S*=7);A<S;)b=(C[A]&31)*281474976710656+C[A+1]*1099511627776+C[A+2]*4294967296+C[A+3]*16777216+(C[A+4]<<16)+(C[A+5]<<8)+C[A+6],b>=9e15?crypto.randomBytes(7).copy(C,A):(L.push(b%1e14),A+=7);A=S/7}else throw g=!1,Error(On+"crypto unavailable");if(!g)for(;A<S;)b=w(),b<9e15&&(L[A++]=b%1e14);for(S=L[--A],v%=Ve,S&&v&&(b=om[Ve-v],L[A]=ur(S/b)*b);L[A]===0;L.pop(),A--);if(A<0)L=[F=0];else{for(F=-1;L[0]===0;L.splice(0,1),F-=Ve);for(A=1,b=L[0];b>=10;b/=10,A++);A<Ve&&(F-=Ve-A)}return B.e=F,B.c=L,B}})(),I.sum=function(){for(var x=1,w=arguments,v=new I(w[0]);x<w.length;)v=v.plus(w[x++]);return v},n=(function(){var x="0123456789";function w(v,C,m,F){for(var S,b=[0],A,L=0,B=v.length;L<B;){for(A=b.length;A--;b[A]*=C);for(b[0]+=F.indexOf(v.charAt(L++)),S=0;S<b.length;S++)b[S]>m-1&&(b[S+1]==null&&(b[S+1]=0),b[S+1]+=b[S]/m|0,b[S]%=m)}return b.reverse()}return function(v,C,m,F,S){var b,A,L,B,N,h,j,H,M=v.indexOf("."),X=s,ee=a;for(M>=0&&(B=f,f=0,v=v.replace(".",""),H=new I(C),h=H.pow(v.length-M),f=B,H.c=w(ro(cr(h.c),h.e,"0"),10,m,x),H.e=H.c.length),j=w(v,C,m,S?(b=T,x):(b=x,T)),L=B=j.length;j[--B]==0;j.pop());if(!j[0])return b.charAt(0);if(M<0?--L:(h.c=j,h.e=L,h.s=F,h=t(h,H,X,ee,m),j=h.c,N=h.r,L=h.e),A=L+X+1,M=j[A],B=m/2,N=N||A<0||j[A+1]!=null,N=ee<4?(M!=null||N)&&(ee==0||ee==(h.s<0?3:2)):M>B||M==B&&(ee==4||N||ee==6&&j[A-1]&1||ee==(h.s<0?8:7)),A<1||!j[0])v=N?ro(b.charAt(1),-X,b.charAt(0)):b.charAt(0);else{if(j.length=A,N)for(--m;++j[--A]>m;)j[A]=0,A||(++L,j=[1].concat(j));for(B=j.length;!j[--B];);for(M=0,v="";M<=B;v+=b.charAt(j[M++]));v=ro(v,L,b.charAt(0))}return v}})(),t=(function(){function x(C,m,F){var S,b,A,L,B=0,N=C.length,h=m%To,j=m/To|0;for(C=C.slice();N--;)A=C[N]%To,L=C[N]/To|0,S=j*A+L*h,b=h*A+S%To*To+B,B=(b/F|0)+(S/To|0)+j*L,C[N]=b%F;return B&&(C=[B].concat(C)),C}function w(C,m,F,S){var b,A;if(F!=S)A=F>S?1:-1;else for(b=A=0;b<F;b++)if(C[b]!=m[b]){A=C[b]>m[b]?1:-1;break}return A}function v(C,m,F,S){for(var b=0;F--;)C[F]-=b,b=C[F]<m[F]?1:0,C[F]=b*S+C[F]-m[F];for(;!C[0]&&C.length>1;C.splice(0,1));}return function(C,m,F,S,b){var A,L,B,N,h,j,H,M,X,ee,me,xe,oe,Ye,be,Te,te,Me=C.s==m.s?1:-1,Ae=C.c,pe=m.c;if(!Ae||!Ae[0]||!pe||!pe[0])return new I(!C.s||!m.s||(Ae?pe&&Ae[0]==pe[0]:!pe)?NaN:Ae&&Ae[0]==0||!pe?Me*0:Me/0);for(M=new I(Me),X=M.c=[],L=C.e-m.e,Me=F+L+1,b||(b=Tr,L=pr(C.e/Ve)-pr(m.e/Ve),Me=Me/Ve|0),B=0;pe[B]==(Ae[B]||0);B++);if(pe[B]>(Ae[B]||0)&&L--,Me<0)X.push(1),N=!0;else{for(Ye=Ae.length,Te=pe.length,B=0,Me+=2,h=ur(b/(pe[0]+1)),h>1&&(pe=x(pe,h,b),Ae=x(Ae,h,b),Te=pe.length,Ye=Ae.length),oe=Te,ee=Ae.slice(0,Te),me=ee.length;me<Te;ee[me++]=0);te=pe.slice(),te=[0].concat(te),be=pe[0],pe[1]>=b/2&&be++;do{if(h=0,A=w(pe,ee,Te,me),A<0){if(xe=ee[0],Te!=me&&(xe=xe*b+(ee[1]||0)),h=ur(xe/be),h>1)for(h>=b&&(h=b-1),j=x(pe,h,b),H=j.length,me=ee.length;w(j,ee,H,me)==1;)h--,v(j,Te<H?te:pe,H,b),H=j.length,A=1;else h==0&&(A=h=1),j=pe.slice(),H=j.length;if(H<me&&(j=[0].concat(j)),v(ee,j,me,b),me=ee.length,A==-1)for(;w(pe,ee,Te,me)<1;)h++,v(ee,Te<me?te:pe,me,b),me=ee.length}else A===0&&(h++,ee=[0]);X[B++]=h,ee[0]?ee[me++]=Ae[oe]||0:(ee=[Ae[oe]],me=1)}while((oe++<Ye||ee[0]!=null)&&Me--);N=ee[0]!=null,X[0]||X.splice(0,1)}if(b==Tr){for(B=1,Me=X[0];Me>=10;Me/=10,B++);P(M,F+(M.e=B+L*Ve-1)+1,S,N)}else M.e=L,M.r=+N;return M}})();function D(x,w,v,C){var m,F,S,b,A;if(v==null?v=a:zt(v,0,8),!x.c)return x.toString();if(m=x.c[0],S=x.e,w==null)A=cr(x.c),A=C==1||C==2&&(S<=u||S>=c)?Vl(A,S):ro(A,S,"0");else if(x=P(new I(x),w,v),F=x.e,A=cr(x.c),b=A.length,C==1||C==2&&(w<=F||F<=u)){for(;b<w;A+="0",b++);A=Vl(A,F)}else if(w-=S+(C===2&&F>S),A=ro(A,F,"0"),F+1>b){if(--w>0)for(A+=".";w--;A+="0");}else if(w+=F-b,w>0)for(F+1==b&&(A+=".");w--;A+="0");return x.s<0&&m?"-"+A:A}function R(x,w){for(var v,C,m=1,F=new I(x[0]);m<x.length;m++)C=new I(x[m]),(!C.s||(v=ei(F,C))===w||v===0&&F.s===w)&&(F=C);return F}function $(x,w,v){for(var C=1,m=w.length;!w[--m];w.pop());for(m=w[0];m>=10;m/=10,C++);return(v=C+v*Ve-1)>d?x.c=x.e=null:v<l?x.c=[x.e=0]:(x.e=v,x.c=w),x}r=(function(){var x=/^(-?)0([xbo])(?=\w[\w.]*$)/i,w=/^([^.]+)\.$/,v=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(F,S,b,A){var L,B=b?S:S.replace(m,"");if(C.test(B))F.s=isNaN(B)?null:B<0?-1:1;else{if(!b&&(B=B.replace(x,function(N,h,j){return L=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==L?h:N}),A&&(L=A,B=B.replace(w,"$1").replace(v,"0.$1")),S!=B))return new I(B,L);if(I.DEBUG)throw Error(On+"Not a"+(A?" base "+A:"")+" number: "+S);F.s=null}F.c=F.e=null}})();function P(x,w,v,C){var m,F,S,b,A,L,B,N=x.c,h=om;if(N){e:{for(m=1,b=N[0];b>=10;b/=10,m++);if(F=w-m,F<0)F+=Ve,S=w,A=N[L=0],B=ur(A/h[m-S-1]%10);else if(L=nm((F+1)/Ve),L>=N.length)if(C){for(;N.length<=L;N.push(0));A=B=0,m=1,F%=Ve,S=F-Ve+1}else break e;else{for(A=b=N[L],m=1;b>=10;b/=10,m++);F%=Ve,S=F-Ve+m,B=S<0?0:ur(A/h[m-S-1]%10)}if(C=C||w<0||N[L+1]!=null||(S<0?A:A%h[m-S-1]),C=v<4?(B||C)&&(v==0||v==(x.s<0?3:2)):B>5||B==5&&(v==4||C||v==6&&(F>0?S>0?A/h[m-S]:0:N[L-1])%10&1||v==(x.s<0?8:7)),w<1||!N[0])return N.length=0,C?(w-=x.e+1,N[0]=h[(Ve-w%Ve)%Ve],x.e=-w||0):N[0]=x.e=0,x;if(F==0?(N.length=L,b=1,L--):(N.length=L+1,b=h[Ve-F],N[L]=S>0?ur(A/h[m-S]%h[S])*b:0),C)for(;;)if(L==0){for(F=1,S=N[0];S>=10;S/=10,F++);for(S=N[0]+=b,b=1;S>=10;S/=10,b++);F!=b&&(x.e++,N[0]==Tr&&(N[0]=1));break}else{if(N[L]+=b,N[L]!=Tr)break;N[L--]=0,b=1}for(F=N.length;N[--F]===0;N.pop());}x.e>d?x.c=x.e=null:x.e<l&&(x.c=[x.e=0])}return x}function z(x){var w,v=x.e;return v===null?x.toString():(w=cr(x.c),w=v<=u||v>=c?Vl(w,v):ro(w,v,"0"),x.s<0?"-"+w:w)}return o.absoluteValue=o.abs=function(){var x=new I(this);return x.s<0&&(x.s=1),x},o.comparedTo=function(x,w){return ei(this,new I(x,w))},o.decimalPlaces=o.dp=function(x,w){var v,C,m,F=this;if(x!=null)return zt(x,0,an),w==null?w=a:zt(w,0,8),P(new I(F),x+F.e+1,w);if(!(v=F.c))return null;if(C=((m=v.length-1)-pr(this.e/Ve))*Ve,m=v[m])for(;m%10==0;m/=10,C--);return C<0&&(C=0),C},o.dividedBy=o.div=function(x,w){return t(this,new I(x,w),s,a)},o.dividedToIntegerBy=o.idiv=function(x,w){return t(this,new I(x,w),0,1)},o.exponentiatedBy=o.pow=function(x,w){var v,C,m,F,S,b,A,L,B,N=this;if(x=new I(x),x.c&&!x.isInteger())throw Error(On+"Exponent not an integer: "+z(x));if(w!=null&&(w=new I(w)),b=x.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!x.c||!x.c[0])return B=new I(Math.pow(+z(N),b?x.s*(2-Wl(x)):+z(x))),w?B.mod(w):B;if(A=x.s<0,w){if(w.c?!w.c[0]:!w.s)return new I(NaN);C=!A&&N.isInteger()&&w.isInteger(),C&&(N=N.mod(w))}else{if(x.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||b&&N.c[1]>=24e7:N.c[0]<8e13||b&&N.c[0]<=9999975e7)))return F=N.s<0&&Wl(x)?-0:0,N.e>-1&&(F=1/F),new I(A?1/F:F);f&&(F=nm(f/Ve+2))}for(b?(v=new I(.5),A&&(x.s=1),L=Wl(x)):(m=Math.abs(+z(x)),L=m%2),B=new I(i);;){if(L){if(B=B.times(N),!B.c)break;F?B.c.length>F&&(B.c.length=F):C&&(B=B.mod(w))}if(m){if(m=ur(m/2),m===0)break;L=m%2}else if(x=x.times(v),P(x,x.e+1,1),x.e>14)L=Wl(x);else{if(m=+z(x),m===0)break;L=m%2}N=N.times(N),F?N.c&&N.c.length>F&&(N.c.length=F):C&&(N=N.mod(w))}return C?B:(A&&(B=i.div(B)),w?B.mod(w):F?P(B,f,a,S):B)},o.integerValue=function(x){var w=new I(this);return x==null?x=a:zt(x,0,8),P(w,w.e+1,x)},o.isEqualTo=o.eq=function(x,w){return ei(this,new I(x,w))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(x,w){return ei(this,new I(x,w))>0},o.isGreaterThanOrEqualTo=o.gte=function(x,w){return(w=ei(this,new I(x,w)))===1||w===0},o.isInteger=function(){return!!this.c&&pr(this.e/Ve)>this.c.length-2},o.isLessThan=o.lt=function(x,w){return ei(this,new I(x,w))<0},o.isLessThanOrEqualTo=o.lte=function(x,w){return(w=ei(this,new I(x,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(x,w){var v,C,m,F,S=this,b=S.s;if(x=new I(x,w),w=x.s,!b||!w)return new I(NaN);if(b!=w)return x.s=-w,S.plus(x);var A=S.e/Ve,L=x.e/Ve,B=S.c,N=x.c;if(!A||!L){if(!B||!N)return B?(x.s=-w,x):new I(N?S:NaN);if(!B[0]||!N[0])return N[0]?(x.s=-w,x):new I(B[0]?S:a==3?-0:0)}if(A=pr(A),L=pr(L),B=B.slice(),b=A-L){for((F=b<0)?(b=-b,m=B):(L=A,m=N),m.reverse(),w=b;w--;m.push(0));m.reverse()}else for(C=(F=(b=B.length)<(w=N.length))?b:w,b=w=0;w<C;w++)if(B[w]!=N[w]){F=B[w]<N[w];break}if(F&&(m=B,B=N,N=m,x.s=-x.s),w=(C=N.length)-(v=B.length),w>0)for(;w--;B[v++]=0);for(w=Tr-1;C>b;){if(B[--C]<N[C]){for(v=C;v&&!B[--v];B[v]=w);--B[v],B[C]+=Tr}B[C]-=N[C]}for(;B[0]==0;B.splice(0,1),--L);return B[0]?$(x,B,L):(x.s=a==3?-1:1,x.c=[x.e=0],x)},o.modulo=o.mod=function(x,w){var v,C,m=this;return x=new I(x,w),!m.c||!x.s||x.c&&!x.c[0]?new I(NaN):!x.c||m.c&&!m.c[0]?new I(m):(p==9?(C=x.s,x.s=1,v=t(m,x,0,3),x.s=C,v.s*=C):v=t(m,x,0,p),x=m.minus(v.times(x)),!x.c[0]&&p==1&&(x.s=m.s),x)},o.multipliedBy=o.times=function(x,w){var v,C,m,F,S,b,A,L,B,N,h,j,H,M,X,ee=this,me=ee.c,xe=(x=new I(x,w)).c;if(!me||!xe||!me[0]||!xe[0])return!ee.s||!x.s||me&&!me[0]&&!xe||xe&&!xe[0]&&!me?x.c=x.e=x.s=null:(x.s*=ee.s,!me||!xe?x.c=x.e=null:(x.c=[0],x.e=0)),x;for(C=pr(ee.e/Ve)+pr(x.e/Ve),x.s*=ee.s,A=me.length,N=xe.length,A<N&&(H=me,me=xe,xe=H,m=A,A=N,N=m),m=A+N,H=[];m--;H.push(0));for(M=Tr,X=To,m=N;--m>=0;){for(v=0,h=xe[m]%X,j=xe[m]/X|0,S=A,F=m+S;F>m;)L=me[--S]%X,B=me[S]/X|0,b=j*L+B*h,L=h*L+b%X*X+H[F]+v,v=(L/M|0)+(b/X|0)+j*B,H[F--]=L%M;H[F]=v}return v?++C:H.splice(0,1),$(x,H,C)},o.negated=function(){var x=new I(this);return x.s=-x.s||null,x},o.plus=function(x,w){var v,C=this,m=C.s;if(x=new I(x,w),w=x.s,!m||!w)return new I(NaN);if(m!=w)return x.s=-w,C.minus(x);var F=C.e/Ve,S=x.e/Ve,b=C.c,A=x.c;if(!F||!S){if(!b||!A)return new I(m/0);if(!b[0]||!A[0])return A[0]?x:new I(b[0]?C:m*0)}if(F=pr(F),S=pr(S),b=b.slice(),m=F-S){for(m>0?(S=F,v=A):(m=-m,v=b),v.reverse();m--;v.push(0));v.reverse()}for(m=b.length,w=A.length,m-w<0&&(v=A,A=b,b=v,w=m),m=0;w;)m=(b[--w]=b[w]+A[w]+m)/Tr|0,b[w]=Tr===b[w]?0:b[w]%Tr;return m&&(b=[m].concat(b),++S),$(x,b,S)},o.precision=o.sd=function(x,w){var v,C,m,F=this;if(x!=null&&x!==!!x)return zt(x,1,an),w==null?w=a:zt(w,0,8),P(new I(F),x,w);if(!(v=F.c))return null;if(m=v.length-1,C=m*Ve+1,m=v[m]){for(;m%10==0;m/=10,C--);for(m=v[0];m>=10;m/=10,C++);}return x&&F.e+1>C&&(C=F.e+1),C},o.shiftedBy=function(x){return zt(x,-rm,rm),this.times("1e"+x)},o.squareRoot=o.sqrt=function(){var x,w,v,C,m,F=this,S=F.c,b=F.s,A=F.e,L=s+4,B=new I("0.5");if(b!==1||!S||!S[0])return new I(!b||b<0&&(!S||S[0])?NaN:S?F:1/0);if(b=Math.sqrt(+z(F)),b==0||b==1/0?(w=cr(S),(w.length+A)%2==0&&(w+="0"),b=Math.sqrt(+w),A=pr((A+1)/2)-(A<0||A%2),b==1/0?w="5e"+A:(w=b.toExponential(),w=w.slice(0,w.indexOf("e")+1)+A),v=new I(w)):v=new I(b+""),v.c[0]){for(A=v.e,b=A+L,b<3&&(b=0);;)if(m=v,v=B.times(m.plus(t(F,m,L,1))),cr(m.c).slice(0,b)===(w=cr(v.c)).slice(0,b))if(v.e<A&&--b,w=w.slice(b-3,b+1),w=="9999"||!C&&w=="4999"){if(!C&&(P(m,m.e+s+2,0),m.times(m).eq(F))){v=m;break}L+=4,b+=4,C=1}else{(!+w||!+w.slice(1)&&w.charAt(0)=="5")&&(P(v,v.e+s+2,1),x=!v.times(v).eq(F));break}}return P(v,v.e+s+1,a,x)},o.toExponential=function(x,w){return x!=null&&(zt(x,0,an),x++),D(this,x,w,1)},o.toFixed=function(x,w){return x!=null&&(zt(x,0,an),x=x+this.e+1),D(this,x,w)},o.toFormat=function(x,w,v){var C,m=this;if(v==null)x!=null&&w&&typeof w=="object"?(v=w,w=null):x&&typeof x=="object"?(v=x,x=w=null):v=k;else if(typeof v!="object")throw Error(On+"Argument not an object: "+v);if(C=m.toFixed(x,w),m.c){var F,S=C.split("."),b=+v.groupSize,A=+v.secondaryGroupSize,L=v.groupSeparator||"",B=S[0],N=S[1],h=m.s<0,j=h?B.slice(1):B,H=j.length;if(A&&(F=b,b=A,A=F,H-=F),b>0&&H>0){for(F=H%b||b,B=j.substr(0,F);F<H;F+=b)B+=L+j.substr(F,b);A>0&&(B+=L+j.slice(F)),h&&(B="-"+B)}C=N?B+(v.decimalSeparator||"")+((A=+v.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(v.fractionGroupSeparator||"")):N):B}return(v.prefix||"")+C+(v.suffix||"")},o.toFraction=function(x){var w,v,C,m,F,S,b,A,L,B,N,h,j=this,H=j.c;if(x!=null&&(b=new I(x),!b.isInteger()&&(b.c||b.s!==1)||b.lt(i)))throw Error(On+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+z(b));if(!H)return new I(j);for(w=new I(i),L=v=new I(i),C=A=new I(i),h=cr(H),F=w.e=h.length-j.e-1,w.c[0]=om[(S=F%Ve)<0?Ve+S:S],x=!x||b.comparedTo(w)>0?F>0?w:L:b,S=d,d=1/0,b=new I(h),A.c[0]=0;B=t(b,w,0,1),m=v.plus(B.times(C)),m.comparedTo(x)!=1;)v=C,C=m,L=A.plus(B.times(m=L)),A=m,w=b.minus(B.times(m=w)),b=m;return m=t(x.minus(v),C,0,1),A=A.plus(m.times(L)),v=v.plus(m.times(C)),A.s=L.s=j.s,F=F*2,N=t(L,C,F,a).minus(j).abs().comparedTo(t(A,v,F,a).minus(j).abs())<1?[L,C]:[A,v],d=S,N},o.toNumber=function(){return+z(this)},o.toPrecision=function(x,w){return x!=null&&zt(x,1,an),D(this,x,w,2)},o.toString=function(x){var w,v=this,C=v.s,m=v.e;return m===null?C?(w="Infinity",C<0&&(w="-"+w)):w="NaN":(x==null?w=m<=u||m>=c?Vl(cr(v.c),m):ro(cr(v.c),m,"0"):x===10&&E?(v=P(new I(v),s+m+1,a),w=ro(cr(v.c),v.e,"0")):(zt(x,2,T.length,"Base"),w=n(ro(cr(v.c),m,"0"),10,x,C,!0)),C<0&&v.c[0]&&(w="-"+w)),w},o.valueOf=o.toJSON=function(){return z(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&I.set(e),I}function pr(e){var t=e|0;return e>0||e===t?t:t-1}function cr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=Ve-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function ei(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 zt(e,t,n,r){if(e<t||e>n||e!==ur(e))throw Error(On+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Wl(e){var t=e.c.length-1;return pr(e.e/Ve)==t&&e.c[t]%2!=0}function Vl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ro(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 xz=Sv(),wv=xz;var yz=24,Ys=32,bz=()=>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,sm=bz(),im=(e=4,t=sm)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function Sz(e){let t=new wv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var kv=(e="")=>{let t=new TextEncoder;return Sz(yv(t.encode(e))).toString(36).slice(1)},vv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),wz=e=>vv[Math.floor(e()*vv.length)],vz=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=sm}={})=>{let n=Object.keys(e).toString(),r=n.length?n+im(Ys,t):im(Ys,t);return kv(r).substring(0,Ys)},kz=e=>()=>e++,Cz=476782367,Cv=({random:e=sm,counter:t=kz(Math.floor(e()*Cz)),length:n=yz,fingerprint:r=vz({random:e})}={})=>{if(n>Ys)throw new Error(`Length must be between 2 and ${Ys}. Received: ${n}`);return function(){let i=wz(e),s=Date.now().toString(36),a=t().toString(36),u=im(n,e),c=`${s+u+a+r}`;return`${i+kv(c).substring(1,n)}`}},Io=Tz(Cv);function Tz(e){let t;return()=>(t||(t=e()),t())}var Ez=$a(Fv());Rn();Oe();var Gl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function Az(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function am(e,t){let n=[],r=e.split(`
|
|
15
15
|
`);for(let s=0;s<r.length;s++){let a=Az(r[s]),u=Gl.exec(a);if(u){let[,c,l,,d]=u,g=Pz(l),p=Lz(r,s+1),f={id:Io(),reviewId:t,type:c.trim(),severity:g,title:d.trim(),description:p.description,file:p.file,lineNumber:p.lineNumber,property:p.property,currentValue:p.currentValue,suggestedValue:p.suggestedValue,suggestedCode:p.suggestedCode,suggestedFix:p.suggestedFix,fixTarget:p.fixTarget,fixRequired:p.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(f)}Gl.lastIndex=0}return n.map(s=>{let a=Os(s);return a.dismissed?(y.debug(`[parseIssues] Auto-dismissed: ${s.title} - ${a.dismissReason}`),{...s,dismissed:!0,dismissReason:a.dismissReason,dismissedBy:a.dismissedBy,dismissedAt:new Date}):s})}function Pz(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function Lz(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||Gl.test(i)){Gl.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
16
|
`)}else r.push(i)}return n.description=r.join(" ").trim(),n}Oe();var Ks=null,Ev=0,Mz=3e4;async function Bz(){let e=Date.now();if(Ks&&e-Ev<Mz)return Ks;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 Ks=n.entries||n.stories||{},Ev=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(Ks).length),Ks}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Xs(e){try{let n=(await Bz())[e];if(!n?.importPath)return y.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;y.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),y.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,y.debug("[storyFilePaths] Derived componentFile:",i));let s=i.replace(/\.tsx$/,".css").replace(/\.ts$/,".css").replace(/\.jsx$/,".css").replace(/\.js$/,".css"),a=i.substring(0,i.lastIndexOf("/")),u={storyFile:o,componentFile:i,cssFile:s,baseDir:a};return y.debug("[storyFilePaths] Final paths:",u),u}catch(t){return y.error("[storyFilePaths] Error getting file paths:",t),null}}function lm(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function Dz(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 cm(e,t){let n=e.property?.toLowerCase()||"",r=e.domElement?.toLowerCase()||"",o=r.startsWith("svg"),i=r.startsWith("img"),s=n==="width"||n==="height",a=/\[(?:width|height)=/.test(r);return(o||i)&&s||a?(y.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):Dz(e.type,t)}Oe();function Rz(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 zz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("width")||t.includes("height")||t.includes("size")||t.includes("dimensions")?"dimensions":t.includes("padding")||t.includes("margin")||t.includes("gap")?"spacing":t.includes("color")||t.includes("background")||t.includes("fill")?"colors":t.includes("font")||t.includes("text")||t.includes("line-height")?"typography":t.includes("border")||t.includes("radius")?"border":n.includes("overall")||n.includes("visual fidelity")||n.includes("pixel similarity")||t.includes("overall")?"summary":"other"}function Nz(e){let t=(e.property||"").toLowerCase(),n=(e.description||"").toLowerCase();return t.includes("overall")||t.includes("visual fidelity")||n.includes("pixel similarity score")||n.includes("primarily explained by")||n.includes("visual discrepancy")}function Oz(e,t,n){let r={critical:3,major:2,minor:1},i=[...e].sort((c,l)=>(r[l.severity]||0)-(r[c.severity]||0))[0],s=e.length,a,u;if(t.includes("icon")&&n==="dimensions"){let c=e.map(d=>d.currentValue).filter(Boolean),l=e.map(d=>d.suggestedValue).filter(Boolean);a=`Icon sizing is incorrect (${s} related issues)`,u=`Icons are rendered at wrong dimensions. Current: ${c[0]||"10px"}, Expected: ${l[0]||"20px"}. This single CSS fix will resolve all ${s} icon dimension issues.`}else a=`${t} ${n} issues (${s} related)`,u=`${s} related ${n} issues for ${t}. ${i.description}`;return{...i,id:`merged-${t}-${n}-${i.id}`,title:a,description:u,currentValue:i.currentValue,suggestedValue:i.suggestedValue,mergedCount:s,mergedIssueIds:e.map(c=>c.id)}}function um(e){if(!e||e.length===0)return[];let t=e.filter(i=>!Nz(i)),n=[],r=[];for(let i of t){let s=Rz(i),a=zz(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(Oz(n,"icon","dimensions"))),o.push(...r),y.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),y.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),y.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}Oe();Rn();var _z=[/Failed to fetch/i,/NetworkError/i,/network request failed/i,/load failed/i,/ERR_(NETWORK|INTERNET|CONNECTION|NAME_NOT_RESOLVED)/i,/timed out/i,/aborted/i],$z=[/credits?/i,/Rate limit/i,/Figma connection expired/i,/Map.*to Figma|Figma mapping required/i,/No project selected/i,/Not authenticated/i,/No story/i,/Monthly review limit/i,/Upgrade your plan/i];function Av(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return $z.some(n=>n.test(t))?t:_z.some(n=>n.test(t))?`Can't reach ${Ft.NAME}. Check your internet connection and try again. If the dashboard URL is wrong, fix it in Settings.`:/Unauthorized|401/i.test(t)?"Your session expired. Sign out and back in from Settings to continue.":/Internal Server Error|5\d\d|server error/i.test(t)?`${Ft.NAME}'s servers had a hiccup. Try the review again in a moment. If it keeps failing, send feedback.`:/parsing|SSE|stream|structured result|failed to receive/i.test(t)?"Review completed but the result was malformed. Try again, or send feedback if it keeps happening.":`Review failed: ${t}. Try again, or send feedback if this keeps happening.`}je();import{addons as ql}from"storybook/manager-api";var pm="uireview/badge",zi={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function Uz(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function jz(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 Hz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Ni(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Mv(e){if(Ni())try{ql.getChannel().emit(zi.REVIEW_START,{storyId:e})}catch{}}function Fo(e,t){if(Ni())try{ql.getChannel().emit(zi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function Bv(e){if(Ni())try{ql.getChannel().emit(zi.REVIEW_ERROR,{storyId:e})}catch{}}function Pv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Lv=null;function Dv(e){if(Lv!==null)return;let t=ql.getChannel(),n=o=>i=>{Ni()&&o(i)};t.on(zi.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:pm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(zi.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:Uz(i),typeId:pm,storyId:o,title:Hz(i),description:jz(i)}])})),t.on(zi.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:pm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Ni();r||Pv(e),Lv=setInterval(()=>{let o=Ni();o!==r&&(r=o,o||Pv(e))},1500)}var dm=V(),gm=180;function Eo(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 fm=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:d,setReviewError:g,setReviewResults:p,setShowReviewMenu:f,setSeverityFilter:k,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:$,setStreamingStatus:P,setFullPrompt:z,setFullResponse:x,setFigmaImageUrl:w,storybookImageUrl:v,setStorybookImageUrl:C,setFigmaDimensions:m,setMultiModelResults:F,updateMultiModelStreamingMessages:S,setModelCompleted:b,setActiveModelId:A,resetReview:L,addReview:B,setReviewDetailTab:N,includeTextComparison:h,usePromptCache:j,setApplyFixesResult:H,featureFlags:M}=ce(),{sessionToken:X,usageData:ee,setUsageData:me}=we(),{selectedProjectId:xe}=Je(),{currentStoryId:oe,currentStoryName:Ye}=nt(),be=Yl(ee);be.current=ee;let Te=Yl(null),te=Yl(null),Me=Yl({}),Ae=Qs((ge,tt)=>{I({role:ge,content:tt})},[I]),pe=Qs((ge,tt)=>{$(ge),P(tt)},[$,P]),Pt=Qs(async ge=>{let{isIteration:tt=!1,parentReviewId:he=null}=ge||{};if(!X)throw new Error("Not authenticated");if(!xe)throw new Error("No project selected");if(!oe||!Ye)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let ie=Date.now();try{d(!0),g(null),p(null),N("issues"),H(null),oe&&M.enableReviewBadges&&Mv(oe),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${gm}s timeout`),Te.current&&Te.current.abort(),I({role:"system",content:`Review auto-stopped after ${gm} seconds timeout.`})},gm*1e3),z(""),x(""),T(!0),E(!1),R(),pe(0,"Starting review..."),pe(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await Ul(),y.debug("[Review] Iframe reloaded, styles should be fresh"),pe(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[Y,fe,se]=await Promise.all([_l({sessionToken:X||void 0}),Promise.resolve(Gs()),Promise.resolve(Kf())]);if(Y&&Y!==v&&(C(Y),y.debug("[Review] Storybook screenshot captured and set")),!fe)throw new Error("Failed to extract styles from component");let{computed:O,declared:U,markup:W,textElementStyles:Be,nestedElementStyles:_e}=fe;se?y.debug("[Review] DOM tree extracted:",{selector:se.selector,childrenCount:se.children.length}):(y.error("[Review] DOM tree extraction FAILED - domTree is null"),y.error("[Review] This will cause AI to use comparison table instead of tree comparison")),pe(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:oe,name:Ye});let bt=gt.getState().currentMapping?.figmaNodeId??null,Gn=gt.getState().figmaImageUrl;if(bt&&(y.debug("[Review] Using Figma node ID from store:",bt),Gn&&(pe(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!bt)try{let Qe=await fetch(`${dm}/api/mappings?projectId=${xe}&storyId=${oe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${X}`}});if(Qe.ok){let Rt=await Qe.json();Rt.mapping?.figmaNodeId?(bt=Rt.mapping.figmaNodeId,y.debug("[Review] Found Figma node ID from API:",bt)):y.debug("[Review] No mapping found for story:",oe)}else y.debug("[Review] Failed to fetch mapping:",Qe.status)}catch(Qe){y.error("[Review] Error fetching mapping:",Qe)}if(bt&&!Gn){pe(65,"Fetching Figma design...");try{let Qe=await fetch(`${dm}/api/figma/frames?projectId=${xe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${X}`}});if(Qe.ok){let $t=(await Qe.json()).thumbnails?.[bt];$t?(w($t),y.debug("[Review] Figma thumbnail fetched and displayed:",$t)):y.warn("[Review] No thumbnail found for node:",bt)}else y.warn("[Review] Failed to fetch Figma frames:",Qe.status)}catch(Qe){y.error("[Review] Error fetching Figma frames:",Qe)}}if(!bt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');pe(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let nr={projectId:xe,storyId:oe,storyName:Ye,storybookScreenshot:Y,computedStyles:O,declaredStyles:U,textElementStyles:Be,nestedElementStyles:_e,componentMarkup:W,domTree:se,figmaNodeId:bt,figmaImageUrl:Gn||void 0,aiModels:l,includeTextComparison:h,usePromptCache:j,parentReviewId:tt?he:void 0,isIteration:tt};y.debug("[Review] Request payload:",{...nr,storybookScreenshot:Y?`${Y.substring(0,50)}...`:null,domTree:se?{selector:se.selector,childrenCount:se.children.length}:null}),Te.current=new AbortController;let En=await fetch(`${dm}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${X}`},body:JSON.stringify(nr),signal:Te.current.signal});if(y.debug("[Review] Response status:",En.status,En.statusText),!En.ok){let Qe=await En.json();if(y.error("[Review] API error response:",Qe),En.status===429){let Rt=Qe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Rt} seconds before trying again.`)}if(En.status===402){if(Qe.code==="INSUFFICIENT_CREDITS"){let Rt=Qe.details?.required??1,$t=Qe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Rt} credit(s) but you have ${$t}. Visit Settings to add more.`)}throw Qe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Qe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Qe.message||"Payment required")}throw En.status===401&&Qe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Qe.error||Qe.message||"Review request failed")}let mo=En.body?.getReader(),wn=new TextDecoder,Br="",rn="",$e=null,uu=null,ny=l.length>1,Wo={},ls={},xV={};if(!mo)throw new Error("Response body is not readable");let ry=gt.getState().streamingMessages.length;for(Ae("assistant","");;){let{done:Qe,value:Rt}=await mo.read();if(Qe)break;Br+=wn.decode(Rt,{stream:!0});let $t=Br.split(`
|
|
17
17
|
`);Br=$t.pop()||"";for(let qn of $t)if(qn.startsWith("data: ")){let pn=qn.slice(6);if(pn==="[DONE]")continue;try{let re=JSON.parse(pn);if(re.type!=="text"&&re.type!=="content"&&y.debug("[Review] SSE Event received:",re.type),re.type==="prompt")re.prompt&&(z(re.prompt),y.debug("[Review] Prompt received early"));else if(re.type==="model_started")y.debug("[Review] Model started:",re.modelId),Wo[re.modelId]||(Wo[re.modelId]="",ls[re.modelId]=[{role:"assistant",content:""}]);else if(re.type==="text"||re.type==="content")if(ny&&re.modelId){Wo[re.modelId]||(Wo[re.modelId]="",ls[re.modelId]=[{role:"assistant",content:""}]),Wo[re.modelId]+=re.content,ls[re.modelId][0].content=Wo[re.modelId],S(re.modelId,ls[re.modelId]);let qt=Object.entries(Wo).map(([dn,at])=>`[${dn}]
|
|
@@ -27,7 +27,7 @@ ${at}`).join(`
|
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
-
\u2705 ${re} issue${re>1?"s were":" was"} auto-dismissed as false positive${re>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let qt=$e.complianceScore??$e.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:$e.complianceScore,validationScore:$e.validation?.complianceScore,parsedScore:qt}),qt==null){let Ie=Rt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);qt=Ie?parseInt(Ie[1],10):void 0,y.debug("[Review] Parsed score from response:",qt)}let dn=Me.current[oe];dn||(dn=await Xs(oe)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},dn.storyFile&&(Me.current[oe]=dn)),y.debug("[Review] Story file paths:",dn);let at=pn.map(Ie=>({...Ie,file:Ie.file||lm(Ie.fixTarget,dn)||cm(Ie,dn)}));if(at=um(at),y.debug("[Review] After de-duplication:",at.length,"issues"),!h){let Ie=at.length;at=at.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),Ie!==at.length&&y.debug("[Review] Filtered out",Ie-at.length,"textContent issues (toggle OFF)")}let Dr;tt&&he&&(Dr=(gt.getState().reviewHistory.find(de=>de.id===he)?.iterationNumber||0)+1);let An={id:Qe,componentId:oe,storyId:oe,modelId:l[0],parentReviewId:tt&&he||void 0,iterationNumber:Dr,figmaFileKey:void 0,figmaNodeId:bt||void 0,figmaFileUrl:Gn||void 0,complianceScore:qt,visualSimilarity:$e.visualSimilarity,issuesCount:at.filter(Ie=>!Ie.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-ie,costUsd:$e.costUsd,inputTokens:$e.inputTokens,outputTokens:$e.outputTokens,cacheCreationTokens:$e.cacheCreationTokens,cacheReadTokens:$e.cacheReadTokens,variantMismatch:$e.variantMismatch,storybookVariant:$e.storybookVariant,figmaVariant:$e.figmaVariant};if(y.debug("[useAIReview] About to call addReview with review:",{id:An.id,storyId:An.storyId,issueCount:An.issues?.length,complianceScore:An.complianceScore,createdAt:An.createdAt?.toISOString(),inputTokens:An.inputTokens,outputTokens:An.outputTokens,costUsd:An.costUsd,cacheCreationTokens:An.cacheCreationTokens,cacheReadTokens:An.cacheReadTokens}),B(An),y.debug("[useAIReview] addReview called successfully"),oe&&M.enableReviewBadges){let Ie=at.filter(de=>!de.dismissed);Fo(oe,{score:qt??100,issueCount:Ie.length,criticalCount:Ie.filter(de=>de.severity==="critical").length,majorCount:Ie.filter(de=>de.severity==="major").length,minorCount:Ie.filter(de=>de.severity==="minor").length})}N("issues");let cs=at.filter(Ie=>!Ie.dismissed).length;y.debug("[Review] Created review with",cs,"active issues,",at.length-cs,"dismissed");let Oa=bt||gt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:bt,effectiveFigmaNodeIdSingle:Oa,hasSessionToken:!!X,selectedProjectId:xe,issueCount:at.length}),y.debug("[Review] Issue validation handled server-side. Active:",at.filter(Ie=>!Ie.dismissed).length,"Dismissed:",at.filter(Ie=>Ie.dismissed).length)}catch(Qe){y.error("[Review] Failed to parse issues:",Qe)}}else throw rn?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",rn.length),y.error("[Review] This indicates a bug in SSE parsing or backend not sending complete event"),new Error("Review completed but failed to receive structured result. Check console for details.")):new Error("No results received from API")}catch(Y){if(Y instanceof Error&&Y.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),pe(0,"Review cancelled");return}y.error("[useAIReview] Review error:",Y);let fe=Av(Y);throw g(fe),oe&&M.enableReviewBadges&&Bv(oe),pe(0,`Error: ${fe}`),Y}finally{d(!1),Te.current=null,te.current&&(clearTimeout(te.current),te.current=null),me(null)}},[e,X,xe,oe,Ye,l,d,g,p,F,S,b,A,T,E,R,Ae,pe,D,C,w,z,x,me]),nn=Qs(()=>n?.issues?o==="all"?n.issues:n.issues.filter(ge=>ge.severity===o):[],[n,o]),Mr=Qs(()=>{Te.current&&(y.debug("[useAIReview] Cancelling review..."),Te.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Pt,cancelReview:Mr,setShowReviewMenu:f,setSeverityFilter:k,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:$,setStreamingStatus:P,resetReview:L,getFilteredIssues:nn}};Ce();Oe();je();import{useCallback as RQ}from"react";var _Q=V();Ce();Oe();import{useEffect as Rv,useRef as zv}from"react";import{useStorybookApi as Wz,useStorybookState as Vz,addons as Gz}from"storybook/manager-api";var Nv="storyArgsUpdated",mm=()=>{let e=Wz(),t=Vz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=nt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ce(),l=zv(null),d=zv(0);return Rv(()=>{let g=t.storyId;if(g){l.current!==g&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,d.current=Date.now()),o(g);let p=e.getData(g),f=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||g;i(f),y.debug("[useCurrentStory] Current story:",{storyId:g,fullName:f})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),Rv(()=>{let g=Gz.getChannel(),p=null,f=k=>{if(k.storyId===n){if(u||c){y.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}p&&clearTimeout(p),p=setTimeout(()=>{let{isReviewing:T,isValidating:E}=gt.getState();if(T||E){y.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-d.current<2e3){y.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}y.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return g.on(Nv,f),()=>{g.off(Nv,f),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};Ce();je();ct();import{useCallback as Ov}from"react";import{addons as _v}from"storybook/manager-api";var $v=V(),ti=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=nt(),{sessionToken:o}=we(),{selectedProjectId:i}=Je(),s=Ov(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ne(`${$v}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({projectId:i,...c})});if(!l.ok)throw new Error("Failed to create mapping");let d=await l.json();r();try{_v.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=Ov(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ne(`${$v}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{_v.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Di();Ce();import{useCallback as hm,useEffect as Uv,useRef as qz}from"react";import{useChannel as Yz,addons as jv}from"storybook/manager-api";Oe();var Kz=3e4,Xz="forceRemount";function Qz(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 Jz(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 Zz="UICOPILOT/APPLY_FIXES",eN="UICOPILOT/FIX_STARTED",tN="UICOPILOT/FIX_COMPLETED",nN="UICOPILOT/FIX_FAILED",rN="UICOPILOT/ALL_FIXES_APPLIED",xm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ce(),c=qz(null),l=hm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);Uv(()=>()=>l(),[l]),Uv(()=>{let f=jv.getChannel(),k=()=>{gt.getState().isApplying&&(y.error("[useApplyFixes] WebSocket disconnected while applying fixes"),l(),o(!1),i({succeeded:0,failed:0,total:0,error:"Connection lost. Please restart Storybook and try again."}))};return f.on("channelWSDisconnect",k),()=>f.off("channelWSDisconnect",k)},[l,o,i]);let d=Yz({[eN]:({issueId:f})=>{y.debug(`[useApplyFixes] Fix started for issue: ${f}`),a(f,{status:"applying"})},[tN]:({issueId:f,result:k})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${f}`,k),s(f,"applied"),a(f,{status:"applied"})},[nN]:({issueId:f,error:k})=>{y.error(`[useApplyFixes] Fix failed for issue: ${f}`,k),s(f,"failed",k),a(f,{status:"failed",error:k})},[rN]:async({summary:f})=>{if(y.debug("[useApplyFixes] All fixes applied:",f),l(),o(!1),i({succeeded:f.succeeded,failed:f.failed,total:f.total}),f.failed>0?y.warn(`Applied ${f.succeeded}/${f.total} fixes. ${f.failed} failed.`):y.debug(`Successfully applied all ${f.total} fixes!`),f.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{jv.getChannel().emit(Xz,{storyId:gt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(k){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",k)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Ul(),y.debug("[useApplyFixes] Storybook preview reloaded")}t&&(y.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),y.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),g=hm(f=>{let k=[],T=[],E=[];for(let I of f){let D=I.currentValue||I.actual||"",R=I.suggestedValue||I.expected||"";if(D&&R&&Qz(D,R)){k.push(I);continue}if(Jz(I)){T.push(I);continue}let $=I.generatedFix?.filePath||I.file||"";if(!$){y.warn(`[useApplyFixes] Skipping issue ${I.id} - no target file path`);continue}let P=$.toLowerCase().split(".").pop()||"",z=["tsx","jsx","ts","js"].includes(P)?"component":"css";E.push({...I,targetFilePath:$,targetFileType:z})}return{actionable:E,negligible:k,designTokens:T}},[]);return{applyFixes:hm(f=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(f.length===0){y.warn("[useApplyFixes] No issues to fix");return}let k=g(f);if(k.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${k.negligible.length} negligible issue(s)`),k.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${k.designTokens.length} design token suggestion(s)`),k.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let T=k.actionable.filter(D=>D.targetFileType==="css"),E=k.actionable.filter(D=>D.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),T.length>0){let D=[...new Set(T.map(R=>R.targetFilePath))];y.debug(` - ${T.length} CSS issue(s) in: ${D.join(", ")}`)}if(E.length>0){let D=[...new Set(E.map(R=>R.targetFilePath))];y.debug(` - ${E.length} component issue(s) in: ${D.join(", ")}`),y.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){y.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:k.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{gt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:k.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},Kz),d(Zz,{issues:k.actionable,storybookRoot:n||void 0})},[d,r,o,i,g,n,l]),isApplying:r}};Ce();je();import{useState as sJ}from"react";var cJ=V();Ce();import{useState as ni}from"react";je();Oe();ct();var oN=V();async function Kl(e,t,n,r,o){if(!e)return y.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await ne(`${oN}/api/issues/dismiss`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},credentials:"include",body:JSON.stringify({issueId:e,dismissed:t,dismissReason:n,dismissedBy:r})});if(!i.ok){let a=await i.text();return y.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return y.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return y.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function Hv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return y.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>Kl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return y.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}Rn();Xf();Di();Oe();je();var iN=["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"],sN=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],aN=V();function ym(){let[e,t]=ni(!1),[n,r]=ni(null),[o,i]=ni(null),[s,a]=ni(null),[u,c]=ni(null),[l,d]=ni(null),[g,p]=ni(null),{sessionToken:f}=we(),{selectedProjectId:k}=Je(),{currentStoryId:T,currentStoryName:E}=nt(),{workspacePath:I,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:$,dismissIssue:P,recalculateScore:z,addStreamingMessage:x}=ce();return{generateBatchFixes:async v=>{if(!f){r("Not authenticated");return}if(!k){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),d(null),a({total:v.length,completed:0});let C=v.map(m=>({issueId:m.id,generatedFix:{code:"",diffPreview:"",filePath:m.file||"",confidence:0,strategy:"",status:"generating"}}));R(C);try{y.debug("[useBatchGenerateFixes] Generating fixes for",v.length,"issues");let m=null;try{let h=Gs();h?.computed&&(m=h.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(h){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",h)}let F=null;try{F=await Xs(T),F&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",F)}catch(h){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",h)}let S=await fetch(`${aN}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({projectId:k,storyId:T,workspacePath:I,includeComponentIssues:$,computedStyles:m,storyFilePaths:F,reviewContext:{storyName:E||void 0,variantArgs:Bi()||void 0},issues:v.map(h=>({id:h.id,dbId:h.dbId,title:h.title,description:h.description,property:h.property,currentValue:h.currentValue,suggestedValue:h.suggestedValue,file:h.file,lineNumber:h.lineNumber,severity:h.severity,type:h.type,fixTarget:h.fixTarget,domElement:h.domElement,figmaContext:h.figmaContext,suggestedFix:h.suggestedFix}))})});if(!S.ok){let h=await S.json().catch(()=>({}));throw new Error(h.error||"Batch fix generation failed")}let b=await S.json();if(!b.success)throw new Error(b.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",b.result.fixes.length,"fixes"),b.result.storybookRoot&&(p(b.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",b.result.storybookRoot)),b.result.selfReview&&(d(b.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",b.result.selfReview)),b.result.partialFailure){let{failedBatches:h,errors:j}=b.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${h.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${h.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:v.length,completed:b.result.fixes.length});let A=new Set(b.result.fixes.map(h=>h.issueId)),L=v.filter(h=>!A.has(h.id));L.length>0&&(y.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.forEach(h=>{D(h.id,{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),b.timing&&(i({durationSec:b.timing.durationSec,issueCount:b.timing.issueCount,avgPerIssueSec:b.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${b.timing.durationSec}s for ${b.timing.issueCount} issues`)),b.result?.usage&&(c({inputTokens:b.result.usage.inputTokens||0,outputTokens:b.result.usage.outputTokens||0,costUsd:b.result.usage.costUsd||0,modelId:b.result.usage.modelId||"unknown",provider:b.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${b.result.usage.inputTokens} in, ${b.result.usage.outputTokens} out, $${b.result.usage.costUsd?.toFixed(4)}`));let B=[],N=[];if(b.result.fixes.forEach(h=>{let j=h.noChangesNeeded===!0;if(!j){let X=(h.fixStrategy||"").toLowerCase(),ee=(h.generatedCode||"").toLowerCase(),me=(h.diffPreview||"").toLowerCase(),xe=iN.some(Ye=>X.includes(Ye.toLowerCase())||X.replace(/[-_]/g,"").includes(Ye.replace(/[-_]/g,""))),oe=sN.some(Ye=>ee.includes(Ye)||me.includes(Ye));j=xe||oe}let H=v.find(X=>X.id===h.issueId);if(j&&H){let X=H.suggestedValue,ee=H.currentValue;X&&ee&&!Qo(X,ee)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${X}", actual="${ee}"), NOT auto-dismissing issue ${h.issueId}`),j=!1)}let M=H?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${h.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:M,detectedBy:H?.detectedBy,noChangesNeeded:h.noChangesNeeded,fixStrategy:h.fixStrategy,title:H?.title?.substring(0,50)}),M&&j&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${h.issueId} (detectedBy: ${H?.detectedBy})`),j=!1),j){let X=`Auto-dismissed: ${h.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${h.issueId} - noChangesNeeded: ${h.noChangesNeeded}, strategy: "${h.fixStrategy}"`),P(h.issueId,X),B.push({localId:h.issueId,dbId:H?.dbId,dismissReason:X}),N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode||"",diffPreview:h.diffPreview||"",filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:"ready",error:void 0,noChangesExplanation:h.noChangesExplanation}})}else{let X=h.error||h.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode,diffPreview:h.diffPreview,filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:X,error:h.error,noChangesExplanation:h.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),R(N)),B.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${B.length} false positive(s), recalculating score`),z(),f){let j=B.filter(H=>H.dbId).map(H=>({dbId:H.dbId,dismissed:!0,dismissReason:H.dismissReason,dismissedBy:"system"}));j.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),Hv(j,f).then(H=>{H.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${H.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",H.error)}).catch(H=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",H)}))}let h=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.`;x({role:"system",content:h})}y.debug("[useBatchGenerateFixes] Updated",b.result.fixes.length,"issues with fixes")}catch(m){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",m),r(m?.message||"Failed to generate batch fixes");let F=v.map(S=>({issueId:S.id,generatedFix:{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"",status:"failed",error:m?.message||"Failed to generate fix"}}));R(F)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}Ce();Oe();je();ct();import{useState as bm,useCallback as Sm}from"react";var lN=V();function wm(){let[e,t]=bm([]),[n,r]=bm(!1),[o,i]=bm(null),{sessionToken:s}=we(),{selectedProjectId:a}=Je(),{currentStoryId:u}=nt(),{setReviewResults:c}=ce(),l=Sm(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let f=await ne(`${lN}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!f.ok){let T=await f.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch reviews")}let k=await f.json();if(!k.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",k.reviews.length,"reviews for:",u),t(k.reviews)}catch(p){y.error("[useReviewHistory] Failed to fetch reviews:",p),i(p instanceof Error?p.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),d=Sm(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let f=[];if(typeof p.models=="string")try{f=JSON.parse(p.models)}catch(I){y.error("[useReviewHistory] Failed to parse models:",I),f=["claude-sonnet-4-20250514"]}else f=p.models;let k=p.issues.map(I=>({id:I.id,reviewId:p.id,type:I.type,severity:I.severity,title:I.description,description:I.description,file:void 0,lineNumber:void 0,property:I.property,currentValue:I.actual,suggestedValue:I.expected,suggestedCode:I.suggestedFix||void 0,status:I.status,dismissed:I.dismissed||!1,dismissReason:I.dismissReason,dismissedBy:I.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(I.createdAt)})),T=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,E=p.storyId||"";if(c({id:p.id,componentId:"",storyId:E,modelId:f[0]||"claude-sonnet-4-5-20250929",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:k,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:T}),E){let I=p.issues.filter(P=>!P.dismissed),D=I.filter(P=>P.severity==="critical").length,R=I.filter(P=>P.severity==="major").length,$=I.filter(P=>P.severity==="minor").length;Fo(E,{score:p.complianceScore,issueCount:I.length,criticalCount:D,majorCount:R,minorCount:$})}},[c]),g=Sm(p=>{let f=e.find(k=>k.id===p);if(!f){y.error("[useReviewHistory] Review not found:",p);return}d(f)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}Ce();Oe();import{useEffect as cN,useState as uN,useRef as Xl}from"react";import{useChannel as pN}from"storybook/manager-api";var dN="UICOPILOT/WORKSPACE_PATH",Wv="UICOPILOT/REQUEST_WORKSPACE_PATH",gN=3e3,fN=500,mN=5,vm=()=>{let[e,t]=uN({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ce(),r=Xl(!1),o=Xl(null),i=Xl(0),s=Xl(null),a=pN({[dN]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),y.debug("[useAutoApplySupport] Server responded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return cN(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(Wv,{}),s.current=setInterval(()=>{!r.current&&i.current<mN&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(Wv,{}))},fN),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){y.debug("[useAutoApplySupport] Channel detection timed out, trying HTTP fallback...");try{let u=await fetch("/__uicopilot/health");if(u.ok){let c=await u.json();if(c.ok&&c.workspacePath&&!r.current){r.current=!0,y.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,y.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},gN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},km=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}}catch(t){return y.error("[copyToClipboard] Failed to copy:",t),!1}};Ce();je();import{useEffect as hN,useRef as xN}from"react";var $J=V(),yN=new Set;function Cm(){let{sessionToken:e}=we(),{selectedProjectId:t}=Je(),n=xN(!1);hN(()=>{t&&yN.add(t)},[e,t])}Ce();Rn();import{useCallback as HJ,useState as WJ}from"react";import{useState as ri,useMemo as tk,useCallback as _i}from"react";je();Oe();ct();Rn();import{useState as oo,useEffect as Ql,useRef as Oi,useCallback as Tm}from"react";var bN=300;function Vv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=oo([]),[u,c]=oo({}),[l,d]=oo(0),[g,p]=oo([]),[f,k]=oo(new Set),[T,E]=oo(!1),[I,D]=oo(!1),[R,$]=oo(null),P=Oi(1),z=Oi(null),x=Oi(null),[w,v]=oo(0),C=Oi(!1),m=Oi({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});m.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let F=Tm(async(B,N,h=!1)=>{let{projectId:j,typeFilter:H,search:M,figmaPage:X,limit:ee}=m.current;if(!j||!H)return;z.current&&z.current.abort();let me=new AbortController;z.current=me,N?D(!0):E(!0),$(null);try{let xe=V(),oe=localStorage.getItem("uicopilot_session_token");if(!oe)throw new Error(`Not authenticated. Please connect to ${Ft.NAME} first.`);let Ye=new URLSearchParams({projectId:j,page:String(B),limit:String(ee)});H&&Ye.append("type",H),X&&Ye.append("figmaPage",X),M.trim()&&Ye.append("search",M.trim()),h&&Ye.append("refresh","true");let be=await fetch(`${xe}/api/figma/frames?${Ye.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe}`},signal:me.signal});if(!be.ok){let pe=await be.json();throw new Error(pe.error||"Failed to fetch frames")}let Te=await be.json(),te=Te.frames||[],Me=Te.thumbnails||{},Ae=be.headers.get("X-Cache-Status");if(te.length===0&&B===1&&!N&&!h&&!C.current&&Ae!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),C.current=!0,await F(1,!1,!0);return}N?(a(pe=>[...pe,...te]),c(pe=>({...pe,...Me}))):(a(te),c(Me)),d(Te.total||te.length),Te.pages&&p(Te.pages),Te.cacheDiff?.added&&k(new Set(Te.cacheDiff.added)),P.current=B}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let oe=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";$(oe),y.error("Error fetching frames:",xe)}finally{me.signal.aborted||(E(!1),D(!1))}},[]);Ql(()=>{if(!i||!e||!t)return;C.current=!1,x.current&&clearTimeout(x.current);let B=n.trim()?bN:0;return x.current=setTimeout(()=>{P.current=1,F(1,!1)},B),()=>{x.current&&clearTimeout(x.current)}},[e,t,n,r,i,w,F]);let S=Oi(new Set);Ql(()=>{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]),Ql(()=>{if(s.length===0)return;let B=s.filter(h=>!h.thumbnailCdnUrl&&!u[h.id]&&!S.current.has(h.id)).map(h=>h.id);if(B.length===0)return;B.forEach(h=>S.current.add(h)),(async()=>{try{let{projectId:h}=m.current,j=V(),H=localStorage.getItem("uicopilot_session_token");if(!H||!h)return;let M=await ne(`${j}/api/figma/frames?projectId=${h}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`}});if(M.ok){let X=await M.json();X.thumbnails&&Object.keys(X.thumbnails).length>0&&c(ee=>({...ee,...X.thumbnails}))}}catch(h){B.forEach(j=>S.current.delete(j)),y.error("Failed to fetch frame thumbnails:",h)}})()},[s,u]),Ql(()=>()=>{z.current&&z.current.abort(),x.current&&clearTimeout(x.current)},[]);let b=Tm(async()=>{let B=P.current+1;await F(B,!0)},[F]),A=Tm(()=>{C.current=!1,P.current=1,a([]),c({}),v(B=>B+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:f,isLoading:T,loadingMore:I,hasMore:L,loadMore:b,refresh:A,error:R}}je();Oe();ct();import{useState as Js,useCallback as Jl,useRef as SN}from"react";function Gv({projectId:e}){let[t,n]=Js({}),[r,o]=Js({}),[i,s]=Js(new Set),[a,u]=Js(new Set),[c,l]=Js({}),d=SN({}),g=Jl(async T=>{if(!(!e||i.has(T))){s(E=>new Set(E).add(T));try{let E=V(),I=localStorage.getItem("uicopilot_session_token"),D=await ne(`${E}/api/figma/variants?projectId=${e}&componentSetId=${T}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`}});if(D.ok){let R=await D.json();if(R.variants){n(P=>({...P,[T]:R.variants}));let $={};for(let P of R.variants)P.thumbnailCdnUrl&&($[P.id]=P.thumbnailCdnUrl);o(P=>({...P,[T]:{...P[T]||{},...$}})),d.current[T]||(d.current[T]=new Set),Object.keys($).forEach(P=>d.current[T].add(P))}else o($=>({...$,[T]:$[T]||{}}))}else o(R=>({...R,[T]:{}}))}catch(E){y.error("Failed to fetch variant metadata:",E),o(I=>({...I,[T]:{}}))}finally{s(E=>{let I=new Set(E);return I.delete(T),I})}}},[e,i]),p=Jl(async(T,E)=>{if(!e||E.length===0)return;d.current[T]||(d.current[T]=new Set);let I=r[T]||{},D=E.filter(R=>!d.current[T].has(R)&&!I[R]);if(D.length!==0){D.forEach(R=>d.current[T].add(R)),u(R=>new Set(R).add(T));try{let R=V(),$=localStorage.getItem("uicopilot_session_token"),P=await ne(`${R}/api/figma/variants?projectId=${e}&componentSetId=${T}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${$}`}});if(P.ok){let z=await P.json();z.thumbnails&&Object.keys(z.thumbnails).length>0&&o(x=>({...x,[T]:{...x[T]||{},...z.thumbnails}})),Array.isArray(z.failed)&&z.failed.length>0&&l(x=>{let w=new Set(x[T]||[]);for(let v of z.failed)w.add(v);return{...x,[T]:w}})}}catch(R){y.error("Failed to fetch variant thumbnails:",R),D.forEach($=>d.current[T]?.delete($))}finally{u(R=>{let $=new Set(R);return $.delete(T),$})}}},[e]),f=Jl(T=>{o(E=>{let I={...E};return delete I[T],I}),n(E=>{let I={...E};return delete I[T],I}),l(E=>{let I={...E};return delete I[T],I}),delete d.current[T]},[]),k=Jl(()=>{o({}),n({}),l({}),d.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,fetchVariants:g,fetchVariantThumbnails:p,clearVariantsForSet:f,clearAllVariants:k}}je();Di();Ce();Oe();ct();import{useState as qv,useEffect as Yv,useRef as Kv,useCallback as Im}from"react";function Xv({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=qv(null),[i,s]=qv(!1),a=Kv(null),u=Kv(new Set),c=Im(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=Bi();if(!g||Object.keys(g).length===0)return;let p=gt.getState().currentStoryId||"",f=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,k=>k.toUpperCase());a.current=e,s(!0),o(null);try{let k=V(),T=localStorage.getItem("uicopilot_session_token"),E=await ne(`${k}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({storyName:f,storyId:p,storyArgs:g,availableFilters:t.map(I=>({property:I.property,values:I.values}))})});if(E.ok){let I=await E.json();I.confidence>0&&Object.keys(I.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",I),o(I))}}catch(k){y.error("[useFilterSuggestion] Error:",k)}finally{s(!1)}},[e,t,n]);Yv(()=>{c()},[c]),Yv(()=>{e||(o(null),a.current=null)},[e]);let l=Im(()=>{},[]),d=Im(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function Qv(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Jv(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 Zv(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 ek(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 Zs({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=ri(!0),[i,s]=ri(!1),[a,u]=ri(!1),[c,l]=ri(""),[d,g]=ri(""),[p,f]=ri([]),[k,T]=ri(new Set),E=_i(te=>{l(te),p.length>0&&f([]),k.size>0&&T(new Set)},[p.length,k.size]),I=Qv(r,i,a),{frames:D,thumbnails:R,totalFrames:$,availablePages:P,recentlyAdded:z,isLoading:x,loadingMore:w,hasMore:v,loadMore:C,refresh:m,error:F}=Vv({projectId:e,typeFilter:I,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!I}),{variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariants:N,fetchVariantThumbnails:h,clearVariantsForSet:j,clearAllVariants:H}=Gv({projectId:e}),M=tk(()=>{let te=Jv(S),Me=Zv(D),Ae={};for(let pe of[...te,...Me])Ae[pe.property]||(Ae[pe.property]=new Set),pe.values.forEach(Pt=>Ae[pe.property].add(Pt));return Object.entries(Ae).map(([pe,Pt])=>({property:pe,values:Array.from(Pt).sort()}))},[S,D]),X=k.size===1?Array.from(k)[0]:null,ee=Xv({expandedSetId:X,availableFilters:M,filtersReady:M.length>0}),me=_i(()=>{if(!ee.suggestion)return;let{suggestedFilters:te}=ee.suggestion,Me=Object.entries(te).map(([Ae,pe])=>({property:Ae,value:pe}));f(Me),ee.dismissSuggestion()},[ee.suggestion]),xe=tk(()=>p.some(te=>te.value)?D.filter(te=>ek(te,p,S[te.id])):D,[D,p,S]),oe=_i((te,Me)=>{Me.stopPropagation();let Ae=!k.has(te);T(pe=>{let Pt=new Set(pe);return Pt.has(te)?Pt.delete(te):Pt.add(te),Pt}),Ae&&!S[te]&&!L.has(te)?N(te):Ae||j(te)},[k,S,L,N,j]),Ye=_i((te,Me)=>{let Ae=Me===""?null:Me;f(pe=>pe.find(nn=>nn.property===te)?pe.map(nn=>nn.property===te?{...nn,value:Ae}:nn):[...pe,{property:te,value:Ae}])},[]),be=_i(()=>{f([])},[]),Te=_i(te=>{let Me=D.find(Ae=>Ae.id===te);if(Me?.thumbnailCdnUrl)return Me.thumbnailCdnUrl;if(R[te])return R[te];for(let Ae of Object.values(b))if(Ae[te])return Ae[te]},[R,b]);return{frames:D,filteredFrames:xe,thumbnails:R,totalFrames:$,isLoading:x,loadingMore:w,hasMore:v,error:F,loadMore:C,refresh:m,search:c,setSearch:E,figmaPage:d,setFigmaPage:g,availablePages:P,recentlyAdded:z,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:M,handleFilterChange:Ye,clearFilters:be,expandedSets:k,toggleExpanded:oe,variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariantThumbnails:h,resolveThumbnail:Te,filterSuggestion:ee.suggestion,filterSuggestionLoading:ee.isLoading,applySuggestedFilters:me,dismissFilterSuggestion:ee.dismissSuggestion}}Ce();import{useEffect as Ir,useCallback as TN,useState as IN,useRef as FN}from"react";import{useChannel as EN}from"storybook/manager-api";function Ao(e){return e.status===401||e.status===403}var In=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};Rn();function nk(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 vu.error("Error parsing Figma URL:",t),null}}Oe();je();je();ct();var wN=V();async function Fm(e){let t=await ne(`${wN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(t))throw new In(t.status);return t.ok?(await t.json()).projects||[]:[]}je();ct();var vN=V();async function Em(e,t){let n=await ne(`${vN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(n))throw new In(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}je();ct();var kN=V();async function Am(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(`${kN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(s))throw new In(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}je();ct();var CN=V();async function Pm(e,t){let n=await ne(`${CN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(n))throw new In(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Di();function AN(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 PN=V(),LN="UICOPILOT/WORKSPACE_PATH",MN="UICOPILOT/REQUEST_WORKSPACE_PATH",Lm=!1;function Mm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Je(),{currentStoryId:l,mappingsRefreshKey:d,mappingsByStoryId:g,setFigmaFileUrl:p,setCurrentMapping:f,setMappingsByStoryId:k,setMappingSource:T,setLoadingMapping:E}=nt(),{setReviewResults:I,setReviewDetailTab:D,setStorybookImageUrl:R,setFigmaImageUrl:$,setFullPrompt:P,setFullResponse:z,bulkAddReviews:x}=ce(),[w,v]=IN([]),C=FN(null);Ir(()=>{let S=b=>{b.origin.startsWith(PN)&&b.data?.type==="UICOPILOT_AUTH_SUCCESS"&&b.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(b.data.token))};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[t]);let m=EN({[LN]:S=>{y.debug("[useDataInit] Received workspace path:",S.path),c(S.path)}});Ir(()=>{m(MN)},[m]),Ir(()=>{if(!e)return;let S=!1;return(async()=>{try{u(!0);let A=await Fm(e);S||(s(A),n(null))}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch projects:",A)}finally{S||u(!1)}})(),()=>{S=!0}},[e,s,u]),Ir(()=>{if(!i||r.length===0)return;let S=r.find(b=>b.storybookRoot===i);S&&o!==S.id&&(y.debug("[useDataInit] Auto-selecting project:",S.name),a(S.id))},[i,r,o,a]),Ir(()=>{if(!o||r.length===0)return;let S=r.find(A=>A.id===o),b=S?.figmaFileId;if(S&&typeof b=="string"&&b){let A=b,L=A.includes("figma.com")&&nk(A)?.fileKey||A;p(`https://www.figma.com/file/${L}`)}},[o,r,p]),Ir(()=>!e||!o||Lm?void 0:(Lm=!0,(async()=>{try{let b=await Pm(e,o);for(let[A,L]of Object.entries(b))Fo(A,{score:L.score,issueCount:L.issueCount,criticalCount:L.criticalCount,majorCount:L.majorCount,minorCount:L.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(b).length,"stories")}catch(b){b instanceof In&&n(b.message),y.error("[useDataInit] Failed to fetch review statuses:",b)}})(),()=>{Lm=!1}),[e,o]),Ir(()=>{if(!e||!o)return;let S=!1;return(async()=>{try{let A=await Em(e,o);if(S)return;let L={};for(let B of A)B.storyId&&(L[B.storyId]=B);k(L)}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch all mappings:",A)}})(),()=>{S=!0}},[e,o,d,k]),Ir(()=>{if(!l){f(null),T(null);return}let S=g[l]||null;S?(f(S),T("database")):(f(null),T(null)),E(!1)},[l,g,f,T,E]),Ir(()=>{v([]),C.current=null},[l]),Ir(()=>{if(!e||!o||!l)return;let S=!1;return(async()=>{try{let A=await Am(e,o,l,10,!0);if(!S){v(A);let L=A.map(B=>AN(B)).filter(Boolean);L.length>0&&x(L)}}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch reviews:",A)}})(),()=>{S=!0}},[e,o,l]);let F=TN(S=>{y.debug("[useDataInit] Applying review:",S.id,"with",S.issues.length,"issues");let b=[];if(typeof S.models=="string")try{b=JSON.parse(S.models)}catch{b=["claude-sonnet-4-20250514"]}else b=S.models;let A=S.issues.map(h=>({id:h.id,reviewId:S.id,type:h.type,severity:h.severity,title:h.description,description:h.description,file:void 0,lineNumber:void 0,property:h.property,currentValue:h.actual,suggestedValue:h.expected,suggestedCode:h.suggestedFix||void 0,status:h.status,dismissed:h.dismissed||!1,dismissReason:h.dismissReason,dismissedBy:h.dismissedBy,figmaContext:h.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(h.createdAt)})),L=S.completedAt&&S.createdAt?new Date(S.completedAt).getTime()-new Date(S.createdAt).getTime():void 0,B=S.storyId||"";I({id:S.id,componentId:"",storyId:B,modelId:b[0]||"claude-sonnet-4-5-20250929",complianceScore:S.complianceScore,issuesCount:S.issuesCount,issues:A,createdAt:new Date(S.createdAt),timestamp:new Date(S.createdAt).toISOString(),costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens,reviewDurationMs:L});let N=gt.getState().currentStoryId;if(B&&B===N&&(S.storybookScreenshot&&(R(S.storybookScreenshot),Gw(B,S.storybookScreenshot,S.figmaScreenshot??void 0),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),S.figmaScreenshot&&($(S.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot"))),S.aiPrompt&&(P(S.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),S.aiResponse&&(z(S.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),B){let h=S.issues.filter(X=>!X.dismissed),j=h.filter(X=>X.severity==="critical").length,H=h.filter(X=>X.severity==="major").length,M=h.filter(X=>X.severity==="minor").length;Fo(B,{score:S.complianceScore,issueCount:h.length,criticalCount:j,majorCount:H,minorCount:M})}},[I,R,$,P,z]);Ir(()=>{if(w.length>0&&l&&C.current!==l){let S=w[0];S&&S.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",S.id,"for:",l),C.current=l,F(S),D("issues"))}},[w,l,F,D])}Rn();import{styled as ea}from"storybook/theming";var BN=ea.div({display:"flex",gap:"10px",marginTop:"8px"}),rk=ea.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),ok=ea.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"})),ik=ea.div({display:"flex",alignItems:"center",gap:"8px"}),sk=ea(kn)(({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"})),ak=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,setSessionToken:u,setApiKey:c}=Us(),[l,d]=rt.useState(""),g=()=>{let p=l.trim();p&&(c(p),u(p),e?.())};return rt.createElement(rt.Fragment,null,rt.createElement(ho,null,rt.createElement(xo,null,"Authentication Method"),rt.createElement(BN,null,rt.createElement(rk,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),rt.createElement(rk,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="apikey",onChange:()=>r("apikey")}),"API Key"))),n==="oauth"&&rt.createElement(ho,null,rt.createElement(xo,null,"Connect to ",Ft.NAME),t?rt.createElement(ok,null,rt.createElement(ik,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Ft.NAME)),rt.createElement(sk,{onClick:i},"Disconnect")):s?rt.createElement("div",{style:{padding:"20px 0",textAlign:"center",fontSize:"13px"}},rt.createElement("div",{style:{fontSize:"24px",marginBottom:"8px"}},"\u{1F510}"),rt.createElement(ps,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),rt.createElement(ps,{style:{color:"inherit",opacity:.7}},"Complete sign-in in the popup, then return here.")):rt.createElement("div",null,a&&rt.createElement("div",{style:{marginBottom:"12px",padding:"10px 12px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#b91c1c"}},"\u26A0\uFE0F ",a),rt.createElement(ps,{style:{marginBottom:"12px"}},"Connect to ",Ft.NAME," to manage projects and integrations."),rt.createElement(kn,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Ft.NAME))),n==="apikey"&&rt.createElement(ho,null,rt.createElement(xo,null,"Session Token"),t?rt.createElement(ok,null,rt.createElement(ik,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Ft.NAME)),rt.createElement(sk,{onClick:i},"Disconnect")):rt.createElement(rt.Fragment,null,rt.createElement(ps,{style:{marginBottom:"12px"}},"Paste the session token from your ",Ft.NAME," setup page."),rt.createElement(us,{type:"password",placeholder:"Paste session token",value:l,onChange:p=>d(p.target.value)}),rt.createElement(kn,{disabled:!l.trim(),style:{marginTop:"12px"},onClick:g},"Save Token"))))};import Ot,{useState as ta}from"react";Ce();import _n,{useState as DN,useEffect as RN,useCallback as zN}from"react";import{styled as io,keyframes as lk}from"storybook/theming";var NN=lk({from:{opacity:0},to:{opacity:1}}),ON=lk({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),_N=io.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${NN} 150ms ease-out`}),$N=io.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:`${ON} 150ms ease-out`})),UN=io.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),jN=io.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})),HN=io.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),WN=io.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.6}px ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.background.app,color:e.color.defaultText,marginBottom:`${e.layoutMargin}px`,boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary}})),VN=io.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.6}px`,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.mediumdark})),GN=io.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}})),qN=io.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),_r=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",confirmText:s,onConfirm:a,onCancel:u})=>{let[c,l]=DN(""),d=!!s&&c!==s,g=zN(p=>{p.key==="Escape"&&u()},[u]);return RN(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?_n.createElement(_n.Fragment,null,_n.createElement(_N,{onClick:u}),_n.createElement($N,{role:"dialog","aria-modal":"true","aria-label":t},_n.createElement(UN,null,t),_n.createElement(jN,null,n),s&&_n.createElement(_n.Fragment,null,_n.createElement(VN,null,"Type ",_n.createElement("strong",null,s)," to confirm:"),_n.createElement(WN,{type:"text",value:c,onChange:p=>l(p.target.value),placeholder:s,autoFocus:!0})),_n.createElement(HN,null,_n.createElement(GN,{onClick:u},o),_n.createElement(qN,{variant:i,onClick:a,disabled:d},r)))):null};import{styled as dr}from"storybook/theming";var YN=dr.div({marginBottom:"30px"}),KN=dr.div({display:"flex",gap:"8px",alignItems:"center"}),XN=dr(hn)({flex:1}),QN=dr(Yt)({padding:"8px 12px",whiteSpace:"nowrap"}),JN=dr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),Bm=dr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Dm=dr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Rm=dr(us)({fontSize:"13px",padding:"6px 8px"}),ZN=dr.div({display:"flex",gap:"8px",marginTop:"12px"}),ck=dr(Yt)({fontSize:"12px",padding:"6px 12px"}),eO=dr(ck)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),tO=dr.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.size.s1,transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),uk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=no(),{currentStorybookPath:s}=Je(),[a,u]=ta(!1),[c,l]=ta(!1),[d,g]=ta(!1),[p,f]=ta(!1),[k,T]=ta({name:"",storybookRoot:"",figmaFileUrl:""}),E=e.find(z=>z.id===t),I=z=>{n(z||null),u(!1)},D=async()=>{if(t)try{f(!0),await i(t),g(!1)}catch(z){console.error("Failed to delete project:",z)}finally{f(!1)}},R=()=>{if(u(!0),s){let z=s.replace(/\/+$/,"").split("/").pop()||"";T({storybookRoot:s,name:z,figmaFileUrl:""})}},$=async()=>{if(k.name.trim())try{l(!0);let z;if(k.figmaFileUrl.trim()){let w=k.figmaFileUrl.trim(),v=w.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);z=v?v[1]:w}let x=await o({name:k.name.trim(),storybookRoot:k.storybookRoot.trim()||void 0,figmaFileId:z});n(x.id),u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}catch(z){console.error("Failed to create project:",z)}finally{l(!1)}},P=z=>{T(x=>{let w={...x,storybookRoot:z};if(!x.name&&z){let v=z.replace(/\/+$/,"").split("/").pop()||"";w.name=v}return w})};return Ot.createElement(YN,null,Ot.createElement(ly,null,"Project"),Ot.createElement(KN,null,Ot.createElement(XN,{value:t||"",onChange:z=>I(z.target.value),disabled:r||a},Ot.createElement("option",{value:""},"-- Select a project --"),e.map(z=>Ot.createElement("option",{key:z.id,value:z.id},z.name))),Ot.createElement(QN,{onClick:R,disabled:r,type:"button"},"+ New"),Ot.createElement(tO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),Ot.createElement(_r,{isOpen:d,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${E?.name||"this project"}". This cannot be undone.`,confirmLabel:p?"Deleting...":"Delete",confirmText:E?.name,variant:"danger",onConfirm:D,onCancel:()=>g(!1)}),a&&Ot.createElement(JN,null,Ot.createElement(Bm,null,Ot.createElement(Dm,null,"Storybook Path (for fix generation)"),Ot.createElement(Rm,{type:"text",placeholder:"/path/to/your/storybook",value:k.storybookRoot,onChange:z=>P(z.target.value)})),Ot.createElement(Bm,null,Ot.createElement(Dm,null,"Project Name *"),Ot.createElement(Rm,{type:"text",placeholder:"my-storybook",value:k.name,onChange:z=>{let x=z.target.value;T(w=>({...w,name:x}))}})),Ot.createElement(Bm,null,Ot.createElement(Dm,null,"Figma File URL (for design comparison)"),Ot.createElement(Rm,{type:"text",placeholder:"https://www.figma.com/file/...",value:k.figmaFileUrl,onChange:z=>{let x=z.target.value;T(w=>({...w,figmaFileUrl:x}))}})),Ot.createElement(ZN,null,Ot.createElement(ck,{onClick:$,disabled:c||!k.name.trim()},c?"Creating...":"Create"),Ot.createElement(eO,{onClick:()=>{u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import yt,{useState as xc,useCallback as jC,useEffect as a4}from"react";import{styled as Er}from"storybook/theming";import $r,{useState as na,useEffect as SO,useCallback as Nm}from"react";import{styled as Po}from"storybook/theming";Ce();je();ct();Ce();je();ct();import Ht,{useState as zm}from"react";import{styled as $n,keyframes as nO}from"storybook/theming";var rO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},oO=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",iO=$n.div({position:"relative",display:"inline-flex"}),sO=nO`
|
|
30
|
+
\u2705 ${re} issue${re>1?"s were":" was"} auto-dismissed as false positive${re>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let qt=$e.complianceScore??$e.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:$e.complianceScore,validationScore:$e.validation?.complianceScore,parsedScore:qt}),qt==null){let Ie=Rt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);qt=Ie?parseInt(Ie[1],10):void 0,y.debug("[Review] Parsed score from response:",qt)}let dn=Me.current[oe];dn||(dn=await Xs(oe)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},dn.storyFile&&(Me.current[oe]=dn)),y.debug("[Review] Story file paths:",dn);let at=pn.map(Ie=>({...Ie,file:Ie.file||lm(Ie.fixTarget,dn)||cm(Ie,dn)}));if(at=um(at),y.debug("[Review] After de-duplication:",at.length,"issues"),!h){let Ie=at.length;at=at.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),Ie!==at.length&&y.debug("[Review] Filtered out",Ie-at.length,"textContent issues (toggle OFF)")}let Dr;tt&&he&&(Dr=(gt.getState().reviewHistory.find(de=>de.id===he)?.iterationNumber||0)+1);let An={id:Qe,componentId:oe,storyId:oe,modelId:l[0],parentReviewId:tt&&he||void 0,iterationNumber:Dr,figmaFileKey:void 0,figmaNodeId:bt||void 0,figmaFileUrl:Gn||void 0,complianceScore:qt,visualSimilarity:$e.visualSimilarity,issuesCount:at.filter(Ie=>!Ie.dismissed).length,issues:at,createdAt:new Date,reviewDurationMs:Date.now()-ie,costUsd:$e.costUsd,inputTokens:$e.inputTokens,outputTokens:$e.outputTokens,cacheCreationTokens:$e.cacheCreationTokens,cacheReadTokens:$e.cacheReadTokens,variantMismatch:$e.variantMismatch,storybookVariant:$e.storybookVariant,figmaVariant:$e.figmaVariant};if(y.debug("[useAIReview] About to call addReview with review:",{id:An.id,storyId:An.storyId,issueCount:An.issues?.length,complianceScore:An.complianceScore,createdAt:An.createdAt?.toISOString(),inputTokens:An.inputTokens,outputTokens:An.outputTokens,costUsd:An.costUsd,cacheCreationTokens:An.cacheCreationTokens,cacheReadTokens:An.cacheReadTokens}),B(An),y.debug("[useAIReview] addReview called successfully"),oe&&M.enableReviewBadges){let Ie=at.filter(de=>!de.dismissed);Fo(oe,{score:qt??100,issueCount:Ie.length,criticalCount:Ie.filter(de=>de.severity==="critical").length,majorCount:Ie.filter(de=>de.severity==="major").length,minorCount:Ie.filter(de=>de.severity==="minor").length})}N("issues");let cs=at.filter(Ie=>!Ie.dismissed).length;y.debug("[Review] Created review with",cs,"active issues,",at.length-cs,"dismissed");let Oa=bt||gt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:bt,effectiveFigmaNodeIdSingle:Oa,hasSessionToken:!!X,selectedProjectId:xe,issueCount:at.length}),y.debug("[Review] Issue validation handled server-side. Active:",at.filter(Ie=>!Ie.dismissed).length,"Dismissed:",at.filter(Ie=>Ie.dismissed).length)}catch(Qe){y.error("[Review] Failed to parse issues:",Qe)}}else throw rn?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",rn.length),y.error("[Review] This indicates a bug in SSE parsing or backend not sending complete event"),new Error("Review completed but failed to receive structured result. Check console for details.")):new Error("No results received from API")}catch(Y){if(Y instanceof Error&&Y.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),pe(0,"Review cancelled");return}y.error("[useAIReview] Review error:",Y);let fe=Av(Y);throw g(fe),oe&&M.enableReviewBadges&&Bv(oe),pe(0,`Error: ${fe}`),Y}finally{d(!1),Te.current=null,te.current&&(clearTimeout(te.current),te.current=null),me(null)}},[e,X,xe,oe,Ye,l,d,g,p,F,S,b,A,T,E,R,Ae,pe,D,C,w,z,x,me]),nn=Qs(()=>n?.issues?o==="all"?n.issues:n.issues.filter(ge=>ge.severity===o):[],[n,o]),Mr=Qs(()=>{Te.current&&(y.debug("[useAIReview] Cancelling review..."),Te.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:Pt,cancelReview:Mr,setShowReviewMenu:f,setSeverityFilter:k,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:$,setStreamingStatus:P,resetReview:L,getFilteredIssues:nn}};Ce();Oe();je();import{useCallback as RQ}from"react";var _Q=V();Ce();Oe();import{useEffect as Rv,useRef as zv}from"react";import{useStorybookApi as Wz,useStorybookState as Vz,addons as Gz}from"storybook/manager-api";var Nv="storyArgsUpdated",mm=()=>{let e=Wz(),t=Vz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=nt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ce(),l=zv(null),d=zv(0);return Rv(()=>{let g=t.storyId;if(g){l.current!==g&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,d.current=Date.now()),o(g);let p=e.getData(g),f=p?.name&&p.name!=="default"?`${p.title} / ${p.name}`:p?.title||g;i(f),y.debug("[useCurrentStory] Current story:",{storyId:g,fullName:f})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),Rv(()=>{let g=Gz.getChannel(),p=null,f=k=>{if(k.storyId===n){if(u||c){y.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}p&&clearTimeout(p),p=setTimeout(()=>{let{isReviewing:T,isValidating:E}=gt.getState();if(T||E){y.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-d.current<2e3){y.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}y.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return g.on(Nv,f),()=>{g.off(Nv,f),p&&clearTimeout(p)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};Ce();je();ct();import{useCallback as Ov}from"react";import{addons as _v}from"storybook/manager-api";var $v=V(),ti=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=nt(),{sessionToken:o}=we(),{selectedProjectId:i}=Je(),s=Ov(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ne(`${$v}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({projectId:i,...c})});if(!l.ok)throw new Error("Failed to create mapping");let d=await l.json();r();try{_v.getChannel().emit("uireview/mappings-changed")}catch{}return d.mapping},[o,i,r]),a=Ov(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ne(`${$v}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{_v.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Di();Ce();import{useCallback as hm,useEffect as Uv,useRef as qz}from"react";import{useChannel as Yz,addons as jv}from"storybook/manager-api";Oe();var Kz=3e4,Xz="forceRemount";function Qz(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 Jz(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 Zz="UICOPILOT/APPLY_FIXES",eN="UICOPILOT/FIX_STARTED",tN="UICOPILOT/FIX_COMPLETED",nN="UICOPILOT/FIX_FAILED",rN="UICOPILOT/ALL_FIXES_APPLIED",xm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ce(),c=qz(null),l=hm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);Uv(()=>()=>l(),[l]),Uv(()=>{let f=jv.getChannel(),k=()=>{gt.getState().isApplying&&(y.error("[useApplyFixes] WebSocket disconnected while applying fixes"),l(),o(!1),i({succeeded:0,failed:0,total:0,error:"Connection lost. Please restart Storybook and try again."}))};return f.on("channelWSDisconnect",k),()=>f.off("channelWSDisconnect",k)},[l,o,i]);let d=Yz({[eN]:({issueId:f})=>{y.debug(`[useApplyFixes] Fix started for issue: ${f}`),a(f,{status:"applying"})},[tN]:({issueId:f,result:k})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${f}`,k),s(f,"applied"),a(f,{status:"applied"})},[nN]:({issueId:f,error:k})=>{y.error(`[useApplyFixes] Fix failed for issue: ${f}`,k),s(f,"failed",k),a(f,{status:"failed",error:k})},[rN]:async({summary:f})=>{if(y.debug("[useApplyFixes] All fixes applied:",f),l(),o(!1),i({succeeded:f.succeeded,failed:f.failed,total:f.total}),f.failed>0?y.warn(`Applied ${f.succeeded}/${f.total} fixes. ${f.failed} failed.`):y.debug(`Successfully applied all ${f.total} fixes!`),f.succeeded>0){y.debug("[useApplyFixes] Emitting FORCE_REMOUNT to refresh story...");try{jv.getChannel().emit(Xz,{storyId:gt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(k){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",k)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Ul(),y.debug("[useApplyFixes] Storybook preview reloaded")}t&&(y.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),y.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),g=hm(f=>{let k=[],T=[],E=[];for(let I of f){let D=I.currentValue||I.actual||"",R=I.suggestedValue||I.expected||"";if(D&&R&&Qz(D,R)){k.push(I);continue}if(Jz(I)){T.push(I);continue}let $=I.generatedFix?.filePath||I.file||"";if(!$){y.warn(`[useApplyFixes] Skipping issue ${I.id} - no target file path`);continue}let P=$.toLowerCase().split(".").pop()||"",z=["tsx","jsx","ts","js"].includes(P)?"component":"css";E.push({...I,targetFilePath:$,targetFileType:z})}return{actionable:E,negligible:k,designTokens:T}},[]);return{applyFixes:hm(f=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(f.length===0){y.warn("[useApplyFixes] No issues to fix");return}let k=g(f);if(k.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${k.negligible.length} negligible issue(s)`),k.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${k.designTokens.length} design token suggestion(s)`),k.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let T=k.actionable.filter(D=>D.targetFileType==="css"),E=k.actionable.filter(D=>D.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),T.length>0){let D=[...new Set(T.map(R=>R.targetFilePath))];y.debug(` - ${T.length} CSS issue(s) in: ${D.join(", ")}`)}if(E.length>0){let D=[...new Set(E.map(R=>R.targetFilePath))];y.debug(` - ${E.length} component issue(s) in: ${D.join(", ")}`),y.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){y.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:k.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{gt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:k.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},Kz),d(Zz,{issues:k.actionable,storybookRoot:n||void 0})},[d,r,o,i,g,n,l]),isApplying:r}};Ce();je();import{useState as sJ}from"react";var cJ=V();Ce();import{useState as ni}from"react";je();Oe();ct();var oN=V();async function Kl(e,t,n,r,o){if(!e)return y.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await ne(`${oN}/api/issues/dismiss`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},credentials:"include",body:JSON.stringify({issueId:e,dismissed:t,dismissReason:n,dismissedBy:r})});if(!i.ok){let a=await i.text();return y.error("[DismissalSync] API error:",i.status,a),{success:!1,error:`API error: ${i.status}`}}let s=await i.json();return y.debug(`[DismissalSync] Synced issue ${e}, new score: ${s.newScore}`),{success:!0,newScore:s.newScore,activeIssuesCount:s.activeIssuesCount}}catch(i){return y.error("[DismissalSync] Failed to sync:",i),{success:!1,error:i.message}}}async function Hv(e,t){let n=e.filter(i=>i.dbId);if(n.length===0)return y.warn("[DismissalSync] No valid dismissals to sync (missing dbIds)"),{success:!1,error:"No valid dismissals"};let o=(await Promise.all(n.map(i=>Kl(i.dbId,i.dismissed,i.dismissReason,i.dismissedBy,t)))).filter(i=>i.success);if(o.length>0){let i=o[o.length-1];return y.debug(`[DismissalSync] Batch synced ${o.length}/${n.length} dismissals`),i}return{success:!1,error:"All dismissals failed"}}Rn();Xf();Di();Oe();je();var iN=["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"],sN=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],aN=V();function ym(){let[e,t]=ni(!1),[n,r]=ni(null),[o,i]=ni(null),[s,a]=ni(null),[u,c]=ni(null),[l,d]=ni(null),[g,p]=ni(null),{sessionToken:f}=we(),{selectedProjectId:k}=Je(),{currentStoryId:T,currentStoryName:E}=nt(),{workspacePath:I,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:$,dismissIssue:P,recalculateScore:z,addStreamingMessage:x}=ce();return{generateBatchFixes:async v=>{if(!f){r("Not authenticated");return}if(!k){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),d(null),a({total:v.length,completed:0});let C=v.map(m=>({issueId:m.id,generatedFix:{code:"",diffPreview:"",filePath:m.file||"",confidence:0,strategy:"",status:"generating"}}));R(C);try{y.debug("[useBatchGenerateFixes] Generating fixes for",v.length,"issues");let m=null;try{let h=Gs();h?.computed&&(m=h.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(h){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",h)}let F=null;try{F=await Xs(T),F&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",F)}catch(h){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",h)}let S=await fetch(`${aN}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({projectId:k,storyId:T,workspacePath:I,includeComponentIssues:$,computedStyles:m,storyFilePaths:F,reviewContext:{storyName:E||void 0,variantArgs:Bi()||void 0},issues:v.map(h=>({id:h.id,dbId:h.dbId,title:h.title,description:h.description,property:h.property,currentValue:h.currentValue,suggestedValue:h.suggestedValue,file:h.file,lineNumber:h.lineNumber,severity:h.severity,type:h.type,fixTarget:h.fixTarget,domElement:h.domElement,figmaContext:h.figmaContext,suggestedFix:h.suggestedFix}))})});if(!S.ok){let h=await S.json().catch(()=>({}));throw new Error(h.error||"Batch fix generation failed")}let b=await S.json();if(!b.success)throw new Error(b.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",b.result.fixes.length,"fixes"),b.result.storybookRoot&&(p(b.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",b.result.storybookRoot)),b.result.selfReview&&(d(b.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",b.result.selfReview)),b.result.partialFailure){let{failedBatches:h,errors:j}=b.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${h.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${h.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:v.length,completed:b.result.fixes.length});let A=new Set(b.result.fixes.map(h=>h.issueId)),L=v.filter(h=>!A.has(h.id));L.length>0&&(y.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.forEach(h=>{D(h.id,{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),b.timing&&(i({durationSec:b.timing.durationSec,issueCount:b.timing.issueCount,avgPerIssueSec:b.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${b.timing.durationSec}s for ${b.timing.issueCount} issues`)),b.result?.usage&&(c({inputTokens:b.result.usage.inputTokens||0,outputTokens:b.result.usage.outputTokens||0,costUsd:b.result.usage.costUsd||0,modelId:b.result.usage.modelId||"unknown",provider:b.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${b.result.usage.inputTokens} in, ${b.result.usage.outputTokens} out, $${b.result.usage.costUsd?.toFixed(4)}`));let B=[],N=[];if(b.result.fixes.forEach(h=>{let j=h.noChangesNeeded===!0;if(!j){let X=(h.fixStrategy||"").toLowerCase(),ee=(h.generatedCode||"").toLowerCase(),me=(h.diffPreview||"").toLowerCase(),xe=iN.some(Ye=>X.includes(Ye.toLowerCase())||X.replace(/[-_]/g,"").includes(Ye.replace(/[-_]/g,""))),oe=sN.some(Ye=>ee.includes(Ye)||me.includes(Ye));j=xe||oe}let H=v.find(X=>X.id===h.issueId);if(j&&H){let X=H.suggestedValue,ee=H.currentValue;X&&ee&&!Qo(X,ee)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${X}", actual="${ee}"), NOT auto-dismissing issue ${h.issueId}`),j=!1)}let M=H?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${h.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:M,detectedBy:H?.detectedBy,noChangesNeeded:h.noChangesNeeded,fixStrategy:h.fixStrategy,title:H?.title?.substring(0,50)}),M&&j&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${h.issueId} (detectedBy: ${H?.detectedBy})`),j=!1),j){let X=`Auto-dismissed: ${h.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${h.issueId} - noChangesNeeded: ${h.noChangesNeeded}, strategy: "${h.fixStrategy}"`),P(h.issueId,X),B.push({localId:h.issueId,dbId:H?.dbId,dismissReason:X}),N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode||"",diffPreview:h.diffPreview||"",filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:"ready",error:void 0,noChangesExplanation:h.noChangesExplanation}})}else{let X=h.error||h.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode,diffPreview:h.diffPreview,filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:X,error:h.error,noChangesExplanation:h.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),R(N)),B.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${B.length} false positive(s), recalculating score`),z(),f){let j=B.filter(H=>H.dbId).map(H=>({dbId:H.dbId,dismissed:!0,dismissReason:H.dismissReason,dismissedBy:"system"}));j.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),Hv(j,f).then(H=>{H.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${H.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",H.error)}).catch(H=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",H)}))}let h=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.`;x({role:"system",content:h})}y.debug("[useBatchGenerateFixes] Updated",b.result.fixes.length,"issues with fixes")}catch(m){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",m),r(m?.message||"Failed to generate batch fixes");let F=v.map(S=>({issueId:S.id,generatedFix:{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"",status:"failed",error:m?.message||"Failed to generate fix"}}));R(F)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}Ce();Oe();je();ct();import{useState as bm,useCallback as Sm}from"react";var lN=V();function wm(){let[e,t]=bm([]),[n,r]=bm(!1),[o,i]=bm(null),{sessionToken:s}=we(),{selectedProjectId:a}=Je(),{currentStoryId:u}=nt(),{setReviewResults:c}=ce(),l=Sm(async()=>{if(!(!s||!a)){r(!0),i(null);try{let p=new URLSearchParams({projectId:a,limit:"10"});u&&p.append("storyId",u);let f=await ne(`${lN}/api/reviews/list?${p.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!f.ok){let T=await f.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch reviews")}let k=await f.json();if(!k.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",k.reviews.length,"reviews for:",u),t(k.reviews)}catch(p){y.error("[useReviewHistory] Failed to fetch reviews:",p),i(p instanceof Error?p.message:"Failed to fetch reviews")}finally{r(!1)}}},[s,a,u]),d=Sm(p=>{y.debug("[useReviewHistory] Applying review:",p.id,"with",p.issues.length,"issues");let f=[];if(typeof p.models=="string")try{f=JSON.parse(p.models)}catch(I){y.error("[useReviewHistory] Failed to parse models:",I),f=["claude-sonnet-4-20250514"]}else f=p.models;let k=p.issues.map(I=>({id:I.id,reviewId:p.id,type:I.type,severity:I.severity,title:I.description,description:I.description,file:void 0,lineNumber:void 0,property:I.property,currentValue:I.actual,suggestedValue:I.expected,suggestedCode:I.suggestedFix||void 0,status:I.status,dismissed:I.dismissed||!1,dismissReason:I.dismissReason,dismissedBy:I.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(I.createdAt)})),T=p.completedAt&&p.createdAt?new Date(p.completedAt).getTime()-new Date(p.createdAt).getTime():void 0,E=p.storyId||"";if(c({id:p.id,componentId:"",storyId:E,modelId:f[0]||"claude-sonnet-4-5-20250929",complianceScore:p.complianceScore,issuesCount:p.issuesCount,issues:k,createdAt:new Date(p.createdAt),timestamp:new Date(p.createdAt).toISOString(),costUsd:p.costUsd,inputTokens:p.inputTokens,outputTokens:p.outputTokens,reviewDurationMs:T}),E){let I=p.issues.filter(P=>!P.dismissed),D=I.filter(P=>P.severity==="critical").length,R=I.filter(P=>P.severity==="major").length,$=I.filter(P=>P.severity==="minor").length;Fo(E,{score:p.complianceScore,issueCount:I.length,criticalCount:D,majorCount:R,minorCount:$})}},[c]),g=Sm(p=>{let f=e.find(k=>k.id===p);if(!f){y.error("[useReviewHistory] Review not found:",p);return}d(f)},[e,d]);return{reviews:e,isLoading:n,error:o,fetchReviews:l,loadReview:g}}Ce();Oe();import{useEffect as cN,useState as uN,useRef as Xl}from"react";import{useChannel as pN}from"storybook/manager-api";var dN="UICOPILOT/WORKSPACE_PATH",Wv="UICOPILOT/REQUEST_WORKSPACE_PATH",gN=3e3,fN=500,mN=5,vm=()=>{let[e,t]=uN({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ce(),r=Xl(!1),o=Xl(null),i=Xl(0),s=Xl(null),a=pN({[dN]:({path:u})=>{r.current||(r.current=!0,o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current),y.debug("[useAutoApplySupport] Server responded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",u),t({isSupported:!0,isDetecting:!1,workspacePath:u}),n(u))}});return cN(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(Wv,{}),s.current=setInterval(()=>{!r.current&&i.current<mN&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(Wv,{}))},fN),o.current=setTimeout(async()=>{if(s.current&&clearInterval(s.current),!r.current){y.debug("[useAutoApplySupport] Channel detection timed out, trying HTTP fallback...");try{let u=await fetch("/__uicopilot/health");if(u.ok){let c=await u.json();if(c.ok&&c.workspacePath&&!r.current){r.current=!0,y.debug("[useAutoApplySupport] HTTP fallback succeeded - auto-apply supported"),y.debug("[useAutoApplySupport] Workspace path:",c.workspacePath),t({isSupported:!0,isDetecting:!1,workspacePath:c.workspacePath}),n(c.workspacePath);return}}}catch{}r.current||(r.current=!0,y.debug("[useAutoApplySupport] Both channel and HTTP detection failed - auto-apply NOT supported"),t({isSupported:!1,isDetecting:!1,workspacePath:null}))}},gN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},km=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}}catch(t){return y.error("[copyToClipboard] Failed to copy:",t),!1}};Ce();je();import{useEffect as hN,useRef as xN}from"react";var $J=V(),yN=new Set;function Cm(){let{sessionToken:e}=we(),{selectedProjectId:t}=Je(),n=xN(!1);hN(()=>{t&&yN.add(t)},[e,t])}Ce();Rn();import{useCallback as HJ,useState as WJ}from"react";import{useState as ri,useMemo as tk,useCallback as _i}from"react";je();Oe();ct();Rn();import{useState as oo,useEffect as Ql,useRef as Oi,useCallback as Tm}from"react";var bN=300;function Vv({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=oo([]),[u,c]=oo({}),[l,d]=oo(0),[g,p]=oo([]),[f,k]=oo(new Set),[T,E]=oo(!1),[I,D]=oo(!1),[R,$]=oo(null),P=Oi(1),z=Oi(null),x=Oi(null),[w,v]=oo(0),C=Oi(!1),m=Oi({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});m.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let F=Tm(async(B,N,h=!1)=>{let{projectId:j,typeFilter:H,search:M,figmaPage:X,limit:ee}=m.current;if(!j||!H)return;z.current&&z.current.abort();let me=new AbortController;z.current=me,N?D(!0):E(!0),$(null);try{let xe=V(),oe=localStorage.getItem("uicopilot_session_token");if(!oe)throw new Error(`Not authenticated. Please connect to ${Ft.NAME} first.`);let Ye=new URLSearchParams({projectId:j,page:String(B),limit:String(ee)});H&&Ye.append("type",H),X&&Ye.append("figmaPage",X),M.trim()&&Ye.append("search",M.trim()),h&&Ye.append("refresh","true");let be=await fetch(`${xe}/api/figma/frames?${Ye.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe}`},signal:me.signal});if(!be.ok){let pe=await be.json();throw new Error(pe.error||"Failed to fetch frames")}let Te=await be.json(),te=Te.frames||[],Me=Te.thumbnails||{},Ae=be.headers.get("X-Cache-Status");if(te.length===0&&B===1&&!N&&!h&&!C.current&&Ae!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),C.current=!0,await F(1,!1,!0);return}N?(a(pe=>[...pe,...te]),c(pe=>({...pe,...Me}))):(a(te),c(Me)),d(Te.total||te.length),Te.pages&&p(Te.pages),Te.cacheDiff?.added&&k(new Set(Te.cacheDiff.added)),P.current=B}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let oe=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";$(oe),y.error("Error fetching frames:",xe)}finally{me.signal.aborted||(E(!1),D(!1))}},[]);Ql(()=>{if(!i||!e||!t)return;C.current=!1,x.current&&clearTimeout(x.current);let B=n.trim()?bN:0;return x.current=setTimeout(()=>{P.current=1,F(1,!1)},B),()=>{x.current&&clearTimeout(x.current)}},[e,t,n,r,i,w,F]);let S=Oi(new Set);Ql(()=>{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]),Ql(()=>{if(s.length===0)return;let B=s.filter(h=>!h.thumbnailCdnUrl&&!u[h.id]&&!S.current.has(h.id)).map(h=>h.id);if(B.length===0)return;B.forEach(h=>S.current.add(h)),(async()=>{try{let{projectId:h}=m.current,j=V(),H=localStorage.getItem("uicopilot_session_token");if(!H||!h)return;let M=await ne(`${j}/api/figma/frames?projectId=${h}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`}});if(M.ok){let X=await M.json();X.thumbnails&&Object.keys(X.thumbnails).length>0&&c(ee=>({...ee,...X.thumbnails}))}}catch(h){B.forEach(j=>S.current.delete(j)),y.error("Failed to fetch frame thumbnails:",h)}})()},[s,u]),Ql(()=>()=>{z.current&&z.current.abort(),x.current&&clearTimeout(x.current)},[]);let b=Tm(async()=>{let B=P.current+1;await F(B,!0)},[F]),A=Tm(()=>{C.current=!1,P.current=1,a([]),c({}),v(B=>B+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:f,isLoading:T,loadingMore:I,hasMore:L,loadMore:b,refresh:A,error:R}}je();Oe();ct();import{useState as Js,useCallback as Jl,useRef as SN}from"react";function Gv({projectId:e}){let[t,n]=Js({}),[r,o]=Js({}),[i,s]=Js(new Set),[a,u]=Js(new Set),[c,l]=Js({}),d=SN({}),g=Jl(async T=>{if(!(!e||i.has(T))){s(E=>new Set(E).add(T));try{let E=V(),I=localStorage.getItem("uicopilot_session_token"),D=await ne(`${E}/api/figma/variants?projectId=${e}&componentSetId=${T}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`}});if(D.ok){let R=await D.json();if(R.variants){n(P=>({...P,[T]:R.variants}));let $={};for(let P of R.variants)P.thumbnailCdnUrl&&($[P.id]=P.thumbnailCdnUrl);o(P=>({...P,[T]:{...P[T]||{},...$}})),d.current[T]||(d.current[T]=new Set),Object.keys($).forEach(P=>d.current[T].add(P))}else o($=>({...$,[T]:$[T]||{}}))}else o(R=>({...R,[T]:{}}))}catch(E){y.error("Failed to fetch variant metadata:",E),o(I=>({...I,[T]:{}}))}finally{s(E=>{let I=new Set(E);return I.delete(T),I})}}},[e,i]),p=Jl(async(T,E)=>{if(!e||E.length===0)return;d.current[T]||(d.current[T]=new Set);let I=r[T]||{},D=E.filter(R=>!d.current[T].has(R)&&!I[R]);if(D.length!==0){D.forEach(R=>d.current[T].add(R)),u(R=>new Set(R).add(T));try{let R=V(),$=localStorage.getItem("uicopilot_session_token"),P=await ne(`${R}/api/figma/variants?projectId=${e}&componentSetId=${T}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${$}`}});if(P.ok){let z=await P.json();z.thumbnails&&Object.keys(z.thumbnails).length>0&&o(x=>({...x,[T]:{...x[T]||{},...z.thumbnails}})),Array.isArray(z.failed)&&z.failed.length>0&&l(x=>{let w=new Set(x[T]||[]);for(let v of z.failed)w.add(v);return{...x,[T]:w}})}}catch(R){y.error("Failed to fetch variant thumbnails:",R),D.forEach($=>d.current[T]?.delete($))}finally{u(R=>{let $=new Set(R);return $.delete(T),$})}}},[e]),f=Jl(T=>{o(E=>{let I={...E};return delete I[T],I}),n(E=>{let I={...E};return delete I[T],I}),l(E=>{let I={...E};return delete I[T],I}),delete d.current[T]},[]),k=Jl(()=>{o({}),n({}),l({}),d.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,fetchVariants:g,fetchVariantThumbnails:p,clearVariantsForSet:f,clearAllVariants:k}}je();Di();Ce();Oe();ct();import{useState as qv,useEffect as Yv,useRef as Kv,useCallback as Im}from"react";function Xv({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=qv(null),[i,s]=qv(!1),a=Kv(null),u=Kv(new Set),c=Im(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=Bi();if(!g||Object.keys(g).length===0)return;let p=gt.getState().currentStoryId||"",f=p.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,k=>k.toUpperCase());a.current=e,s(!0),o(null);try{let k=V(),T=localStorage.getItem("uicopilot_session_token"),E=await ne(`${k}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({storyName:f,storyId:p,storyArgs:g,availableFilters:t.map(I=>({property:I.property,values:I.values}))})});if(E.ok){let I=await E.json();I.confidence>0&&Object.keys(I.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",I),o(I))}}catch(k){y.error("[useFilterSuggestion] Error:",k)}finally{s(!1)}},[e,t,n]);Yv(()=>{c()},[c]),Yv(()=>{e||(o(null),a.current=null)},[e]);let l=Im(()=>{},[]),d=Im(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:d}}function Qv(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Jv(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 Zv(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 ek(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 Zs({projectId:e,limit:t=20,enabled:n=!0}){let[r,o]=ri(!0),[i,s]=ri(!1),[a,u]=ri(!1),[c,l]=ri(""),[d,g]=ri(""),[p,f]=ri([]),[k,T]=ri(new Set),E=_i(te=>{l(te),p.length>0&&f([]),k.size>0&&T(new Set)},[p.length,k.size]),I=Qv(r,i,a),{frames:D,thumbnails:R,totalFrames:$,availablePages:P,recentlyAdded:z,isLoading:x,loadingMore:w,hasMore:v,loadMore:C,refresh:m,error:F}=Vv({projectId:e,typeFilter:I,search:c,figmaPage:d||void 0,limit:t,enabled:n&&!!I}),{variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariants:N,fetchVariantThumbnails:h,clearVariantsForSet:j,clearAllVariants:H}=Gv({projectId:e}),M=tk(()=>{let te=Jv(S),Me=Zv(D),Ae={};for(let pe of[...te,...Me])Ae[pe.property]||(Ae[pe.property]=new Set),pe.values.forEach(Pt=>Ae[pe.property].add(Pt));return Object.entries(Ae).map(([pe,Pt])=>({property:pe,values:Array.from(Pt).sort()}))},[S,D]),X=k.size===1?Array.from(k)[0]:null,ee=Xv({expandedSetId:X,availableFilters:M,filtersReady:M.length>0}),me=_i(()=>{if(!ee.suggestion)return;let{suggestedFilters:te}=ee.suggestion,Me=Object.entries(te).map(([Ae,pe])=>({property:Ae,value:pe}));f(Me),ee.dismissSuggestion()},[ee.suggestion]),xe=tk(()=>p.some(te=>te.value)?D.filter(te=>ek(te,p,S[te.id])):D,[D,p,S]),oe=_i((te,Me)=>{Me.stopPropagation();let Ae=!k.has(te);T(pe=>{let Pt=new Set(pe);return Pt.has(te)?Pt.delete(te):Pt.add(te),Pt}),Ae&&!S[te]&&!L.has(te)?N(te):Ae||j(te)},[k,S,L,N,j]),Ye=_i((te,Me)=>{let Ae=Me===""?null:Me;f(pe=>pe.find(nn=>nn.property===te)?pe.map(nn=>nn.property===te?{...nn,value:Ae}:nn):[...pe,{property:te,value:Ae}])},[]),be=_i(()=>{f([])},[]),Te=_i(te=>{let Me=D.find(Ae=>Ae.id===te);if(Me?.thumbnailCdnUrl)return Me.thumbnailCdnUrl;if(R[te])return R[te];for(let Ae of Object.values(b))if(Ae[te])return Ae[te]},[R,b]);return{frames:D,filteredFrames:xe,thumbnails:R,totalFrames:$,isLoading:x,loadingMore:w,hasMore:v,error:F,loadMore:C,refresh:m,search:c,setSearch:E,figmaPage:d,setFigmaPage:g,availablePages:P,recentlyAdded:z,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:p,availableFilters:M,handleFilterChange:Ye,clearFilters:be,expandedSets:k,toggleExpanded:oe,variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariantThumbnails:h,resolveThumbnail:Te,filterSuggestion:ee.suggestion,filterSuggestionLoading:ee.isLoading,applySuggestedFilters:me,dismissFilterSuggestion:ee.dismissSuggestion}}Ce();import{useEffect as Ir,useCallback as TN,useState as IN,useRef as FN}from"react";import{useChannel as EN}from"storybook/manager-api";function Ao(e){return e.status===401||e.status===403}var In=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};Rn();function nk(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 vu.error("Error parsing Figma URL:",t),null}}Oe();je();je();ct();var wN=V();async function Fm(e){let t=await ne(`${wN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(t))throw new In(t.status);return t.ok?(await t.json()).projects||[]:[]}je();ct();var vN=V();async function Em(e,t){let n=await ne(`${vN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(n))throw new In(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}je();ct();var kN=V();async function Am(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(`${kN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(s))throw new In(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}je();ct();var CN=V();async function Pm(e,t){let n=await ne(`${CN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Ao(n))throw new In(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}Di();function AN(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 PN=V(),LN="UICOPILOT/WORKSPACE_PATH",MN="UICOPILOT/REQUEST_WORKSPACE_PATH",Lm=!1;function Mm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Je(),{currentStoryId:l,mappingsRefreshKey:d,mappingsByStoryId:g,setFigmaFileUrl:p,setCurrentMapping:f,setMappingsByStoryId:k,setMappingSource:T,setLoadingMapping:E}=nt(),{setReviewResults:I,setReviewDetailTab:D,setStorybookImageUrl:R,setFigmaImageUrl:$,setFullPrompt:P,setFullResponse:z,bulkAddReviews:x}=ce(),[w,v]=IN([]),C=FN(null);Ir(()=>{let S=b=>{b.origin.startsWith(PN)&&b.data?.type==="UICOPILOT_AUTH_SUCCESS"&&b.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(b.data.token))};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[t]);let m=EN({[LN]:S=>{y.debug("[useDataInit] Received workspace path:",S.path),c(S.path)}});Ir(()=>{m(MN)},[m]),Ir(()=>{if(!e)return;let S=!1;return(async()=>{try{u(!0);let A=await Fm(e);S||(s(A),n(null))}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch projects:",A)}finally{S||u(!1)}})(),()=>{S=!0}},[e,s,u]),Ir(()=>{if(!i||r.length===0)return;let S=r.find(b=>b.storybookRoot===i);S&&o!==S.id&&(y.debug("[useDataInit] Auto-selecting project:",S.name),a(S.id))},[i,r,o,a]),Ir(()=>{if(!o||r.length===0)return;let S=r.find(A=>A.id===o),b=S?.figmaFileId;if(S&&typeof b=="string"&&b){let A=b,L=A.includes("figma.com")&&nk(A)?.fileKey||A;p(`https://www.figma.com/file/${L}`)}},[o,r,p]),Ir(()=>!e||!o||Lm?void 0:(Lm=!0,(async()=>{try{let b=await Pm(e,o);for(let[A,L]of Object.entries(b))Fo(A,{score:L.score,issueCount:L.issueCount,criticalCount:L.criticalCount,majorCount:L.majorCount,minorCount:L.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(b).length,"stories")}catch(b){b instanceof In&&n(b.message),y.error("[useDataInit] Failed to fetch review statuses:",b)}})(),()=>{Lm=!1}),[e,o]),Ir(()=>{if(!e||!o)return;let S=!1;return(async()=>{try{let A=await Em(e,o);if(S)return;let L={};for(let B of A)B.storyId&&(L[B.storyId]=B);k(L)}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch all mappings:",A)}})(),()=>{S=!0}},[e,o,d,k]),Ir(()=>{if(!l){f(null),T(null);return}let S=g[l]||null;S?(f(S),T("database")):(f(null),T(null)),E(!1)},[l,g,f,T,E]),Ir(()=>{v([]),C.current=null},[l]),Ir(()=>{if(!e||!o||!l)return;let S=!1;return(async()=>{try{let A=await Am(e,o,l,10,!0);if(!S){v(A);let L=A.map(B=>AN(B)).filter(Boolean);L.length>0&&x(L)}}catch(A){A instanceof In&&n(A.message),y.error("[useDataInit] Failed to fetch reviews:",A)}})(),()=>{S=!0}},[e,o,l]);let F=TN(S=>{y.debug("[useDataInit] Applying review:",S.id,"with",S.issues.length,"issues");let b=[];if(typeof S.models=="string")try{b=JSON.parse(S.models)}catch{b=["claude-sonnet-4-20250514"]}else b=S.models;let A=S.issues.map(h=>({id:h.id,reviewId:S.id,type:h.type,severity:h.severity,title:h.description,description:h.description,file:void 0,lineNumber:void 0,property:h.property,currentValue:h.actual,suggestedValue:h.expected,suggestedCode:h.suggestedFix||void 0,status:h.status,dismissed:h.dismissed||!1,dismissReason:h.dismissReason,dismissedBy:h.dismissedBy,figmaContext:h.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(h.createdAt)})),L=S.completedAt&&S.createdAt?new Date(S.completedAt).getTime()-new Date(S.createdAt).getTime():void 0,B=S.storyId||"";I({id:S.id,componentId:"",storyId:B,modelId:b[0]||"claude-sonnet-4-5-20250929",complianceScore:S.complianceScore,issuesCount:S.issuesCount,issues:A,createdAt:new Date(S.createdAt),timestamp:new Date(S.createdAt).toISOString(),costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens,reviewDurationMs:L});let N=gt.getState().currentStoryId;if(B&&B===N&&(S.storybookScreenshot&&(R(S.storybookScreenshot),Gw(B,S.storybookScreenshot,S.figmaScreenshot??void 0),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),S.figmaScreenshot&&($(S.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot"))),S.aiPrompt&&(P(S.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),S.aiResponse&&(z(S.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),B){let h=S.issues.filter(X=>!X.dismissed),j=h.filter(X=>X.severity==="critical").length,H=h.filter(X=>X.severity==="major").length,M=h.filter(X=>X.severity==="minor").length;Fo(B,{score:S.complianceScore,issueCount:h.length,criticalCount:j,majorCount:H,minorCount:M})}},[I,R,$,P,z]);Ir(()=>{if(w.length>0&&l&&C.current!==l){let S=w[0];S&&S.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",S.id,"for:",l),C.current=l,F(S),D("issues"))}},[w,l,F,D])}Rn();import{styled as ea}from"storybook/theming";var BN=ea.div({display:"flex",gap:"10px",marginTop:"8px"}),rk=ea.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),ok=ea.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"})),ik=ea.div({display:"flex",alignItems:"center",gap:"8px"}),sk=ea(kn)(({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"})),ak=({onConnect:e})=>{let{sessionToken:t,authMethod:n,setAuthMethod:r,startOAuth:o,logout:i,oauthPending:s,authError:a,saveApiKey:u}=Us(),[c,l]=rt.useState(""),d=()=>{let g=c.trim();g&&(u(g),e?.())};return rt.createElement(rt.Fragment,null,rt.createElement(ho,null,rt.createElement(xo,null,"Authentication Method"),rt.createElement(BN,null,rt.createElement(rk,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="oauth",onChange:()=>r("oauth")}),"OAuth (Recommended)"),rt.createElement(rk,null,rt.createElement("input",{type:"radio",name:"authMethod",checked:n==="apikey",onChange:()=>r("apikey")}),"API Key"))),n==="oauth"&&rt.createElement(ho,null,rt.createElement(xo,null,"Connect to ",Ft.NAME),t?rt.createElement(ok,null,rt.createElement(ik,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Ft.NAME)),rt.createElement(sk,{onClick:i},"Disconnect")):s?rt.createElement("div",{style:{padding:"20px 0",textAlign:"center",fontSize:"13px"}},rt.createElement("div",{style:{fontSize:"24px",marginBottom:"8px"}},"\u{1F510}"),rt.createElement(ps,{style:{marginBottom:"8px",fontWeight:600}},"Sign-in window opened"),rt.createElement(ps,{style:{color:"inherit",opacity:.7}},"Complete sign-in in the popup, then return here.")):rt.createElement("div",null,a&&rt.createElement("div",{style:{marginBottom:"12px",padding:"10px 12px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.4)",borderRadius:"6px",fontSize:"12px",color:"#b91c1c"}},"\u26A0\uFE0F ",a),rt.createElement(ps,{style:{marginBottom:"12px"}},"Connect to ",Ft.NAME," to manage projects and integrations."),rt.createElement(kn,{onClick:()=>{o(),e?.()}},"\u{1F517} Connect to ",Ft.NAME))),n==="apikey"&&rt.createElement(ho,null,rt.createElement(xo,null,"Session Token"),t?rt.createElement(ok,null,rt.createElement(ik,null,rt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),rt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to ",Ft.NAME)),rt.createElement(sk,{onClick:i},"Disconnect")):rt.createElement(rt.Fragment,null,rt.createElement(ps,{style:{marginBottom:"12px"}},"Paste the session token from your ",Ft.NAME," setup page."),rt.createElement(us,{type:"password",placeholder:"Paste session token",value:c,onChange:g=>l(g.target.value)}),rt.createElement(kn,{disabled:!c.trim(),style:{marginTop:"12px"},onClick:d},"Save Token"))))};import Ot,{useState as ta}from"react";Ce();import _n,{useState as DN,useEffect as RN,useCallback as zN}from"react";import{styled as io,keyframes as lk}from"storybook/theming";var NN=lk({from:{opacity:0},to:{opacity:1}}),ON=lk({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),_N=io.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${NN} 150ms ease-out`}),$N=io.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:`${ON} 150ms ease-out`})),UN=io.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),jN=io.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})),HN=io.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),WN=io.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.6}px ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.background.app,color:e.color.defaultText,marginBottom:`${e.layoutMargin}px`,boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary}})),VN=io.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.6}px`,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.mediumdark})),GN=io.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}})),qN=io.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),_r=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",confirmText:s,onConfirm:a,onCancel:u})=>{let[c,l]=DN(""),d=!!s&&c!==s,g=zN(p=>{p.key==="Escape"&&u()},[u]);return RN(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?_n.createElement(_n.Fragment,null,_n.createElement(_N,{onClick:u}),_n.createElement($N,{role:"dialog","aria-modal":"true","aria-label":t},_n.createElement(UN,null,t),_n.createElement(jN,null,n),s&&_n.createElement(_n.Fragment,null,_n.createElement(VN,null,"Type ",_n.createElement("strong",null,s)," to confirm:"),_n.createElement(WN,{type:"text",value:c,onChange:p=>l(p.target.value),placeholder:s,autoFocus:!0})),_n.createElement(HN,null,_n.createElement(GN,{onClick:u},o),_n.createElement(qN,{variant:i,onClick:a,disabled:d},r)))):null};import{styled as dr}from"storybook/theming";var YN=dr.div({marginBottom:"30px"}),KN=dr.div({display:"flex",gap:"8px",alignItems:"center"}),XN=dr(hn)({flex:1}),QN=dr(Yt)({padding:"8px 12px",whiteSpace:"nowrap"}),JN=dr.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),Bm=dr.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Dm=dr.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Rm=dr(us)({fontSize:"13px",padding:"6px 8px"}),ZN=dr.div({display:"flex",gap:"8px",marginTop:"12px"}),ck=dr(Yt)({fontSize:"12px",padding:"6px 12px"}),eO=dr(ck)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),tO=dr.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.size.s1,transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),uk=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=no(),{currentStorybookPath:s}=Je(),[a,u]=ta(!1),[c,l]=ta(!1),[d,g]=ta(!1),[p,f]=ta(!1),[k,T]=ta({name:"",storybookRoot:"",figmaFileUrl:""}),E=e.find(z=>z.id===t),I=z=>{n(z||null),u(!1)},D=async()=>{if(t)try{f(!0),await i(t),g(!1)}catch(z){console.error("Failed to delete project:",z)}finally{f(!1)}},R=()=>{if(u(!0),s){let z=s.replace(/\/+$/,"").split("/").pop()||"";T({storybookRoot:s,name:z,figmaFileUrl:""})}},$=async()=>{if(k.name.trim())try{l(!0);let z;if(k.figmaFileUrl.trim()){let w=k.figmaFileUrl.trim(),v=w.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);z=v?v[1]:w}let x=await o({name:k.name.trim(),storybookRoot:k.storybookRoot.trim()||void 0,figmaFileId:z});n(x.id),u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}catch(z){console.error("Failed to create project:",z)}finally{l(!1)}},P=z=>{T(x=>{let w={...x,storybookRoot:z};if(!x.name&&z){let v=z.replace(/\/+$/,"").split("/").pop()||"";w.name=v}return w})};return Ot.createElement(YN,null,Ot.createElement(ly,null,"Project"),Ot.createElement(KN,null,Ot.createElement(XN,{value:t||"",onChange:z=>I(z.target.value),disabled:r||a},Ot.createElement("option",{value:""},"-- Select a project --"),e.map(z=>Ot.createElement("option",{key:z.id,value:z.id},z.name))),Ot.createElement(QN,{onClick:R,disabled:r,type:"button"},"+ New"),Ot.createElement(tO,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),Ot.createElement(_r,{isOpen:d,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${E?.name||"this project"}". This cannot be undone.`,confirmLabel:p?"Deleting...":"Delete",confirmText:E?.name,variant:"danger",onConfirm:D,onCancel:()=>g(!1)}),a&&Ot.createElement(JN,null,Ot.createElement(Bm,null,Ot.createElement(Dm,null,"Storybook Path (for fix generation)"),Ot.createElement(Rm,{type:"text",placeholder:"/path/to/your/storybook",value:k.storybookRoot,onChange:z=>P(z.target.value)})),Ot.createElement(Bm,null,Ot.createElement(Dm,null,"Project Name *"),Ot.createElement(Rm,{type:"text",placeholder:"my-storybook",value:k.name,onChange:z=>{let x=z.target.value;T(w=>({...w,name:x}))}})),Ot.createElement(Bm,null,Ot.createElement(Dm,null,"Figma File URL (for design comparison)"),Ot.createElement(Rm,{type:"text",placeholder:"https://www.figma.com/file/...",value:k.figmaFileUrl,onChange:z=>{let x=z.target.value;T(w=>({...w,figmaFileUrl:x}))}})),Ot.createElement(ZN,null,Ot.createElement(ck,{onClick:$,disabled:c||!k.name.trim()},c?"Creating...":"Create"),Ot.createElement(eO,{onClick:()=>{u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import yt,{useState as xc,useCallback as jC,useEffect as a4}from"react";import{styled as Er}from"storybook/theming";import $r,{useState as na,useEffect as SO,useCallback as Nm}from"react";import{styled as Po}from"storybook/theming";Ce();je();ct();Ce();je();ct();import Ht,{useState as zm}from"react";import{styled as $n,keyframes as nO}from"storybook/theming";var rO={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},oO=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",iO=$n.div({position:"relative",display:"inline-flex"}),sO=nO`
|
|
31
31
|
0% { transform: rotate(0deg); }
|
|
32
32
|
100% { transform: rotate(360deg); }
|
|
33
33
|
`,aO=$n.button(({score:e,isLoading:t,theme:n})=>{let r=()=>t?n.color.secondary:e?e>=80?n.color.positive:e>=50?n.color.warning:n.color.negative:n.color.mediumdark;return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",fontSize:n.typography.size.s1,fontWeight:n.typography.weight.bold,fontFamily:n.typography.fonts.base,backgroundColor:r(),color:n.color.inverseText,cursor:t?"wait":"pointer",transition:"all 0.15s",border:"none",outline:"none","&:hover:not(:disabled)":{transform:"scale(1.05)",opacity:.9},"&:disabled":{cursor:"not-allowed",opacity:.7}}}),lO=$n.span`
|
|
@@ -215,7 +215,7 @@ ${"=".repeat(40)}
|
|
|
215
215
|
color: ${({theme:e})=>e.color.mediumdark};
|
|
216
216
|
text-align: center;
|
|
217
217
|
opacity: 0.7;
|
|
218
|
-
`,UW=xr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),jW=xr.div({fontSize:"32px"}),HW=xr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),WW=xr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),SF=xr.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})),wF=xr.span({flex:1}),vF=xr.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`}})),kF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Je(),{isConnected:r,sessionToken:o,authError:i}=we(),{currentStoryId:s}=nt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ce(),[g,p]=BW(!1),f=()=>{l(null),o&&fetch(`${V()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(P=>P.json()).then(P=>{d({enableFixGeneration:!!P.enableFixGeneration,enableFixApply:!!P.enableFixApply,enableAutoMap:!!P.enableAutoMap,enableReviewBadges:!!P.enableReviewBadges,showCosts:!!P.showCosts,enableParallelReview:!!P.enableParallelReview,enableModelSelection:!!P.enableModelSelection})}).catch(()=>{})};mm(),Mm(),bF(),Cm(),wm();let{notification:k,dismissNotification:T}=xF();DW(()=>{if(k){let P=setTimeout(T,5e3);return()=>clearTimeout(P)}},[k,T]);let E=t.find(P=>P.id===e),I=r&&!!e&&!!E,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=nt(),$=I&&!!s&&!a&&R;return Dt.createElement(gu,{header:Dt.createElement(fu,{toolbar:Dt.createElement(_f,{onOpenSettings:()=>p(!0)})}),footer:Dt.createElement($W,null,Ft.NAME," v","0.5.
|
|
218
|
+
`,UW=xr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),jW=xr.div({fontSize:"32px"}),HW=xr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),WW=xr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),SF=xr.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})),wF=xr.span({flex:1}),vF=xr.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`}})),kF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Je(),{isConnected:r,sessionToken:o,authError:i}=we(),{currentStoryId:s}=nt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:d}=ce(),[g,p]=BW(!1),f=()=>{l(null),o&&fetch(`${V()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(P=>P.json()).then(P=>{d({enableFixGeneration:!!P.enableFixGeneration,enableFixApply:!!P.enableFixApply,enableAutoMap:!!P.enableAutoMap,enableReviewBadges:!!P.enableReviewBadges,showCosts:!!P.showCosts,enableParallelReview:!!P.enableParallelReview,enableModelSelection:!!P.enableModelSelection})}).catch(()=>{})};mm(),Mm(),bF(),Cm(),wm();let{notification:k,dismissNotification:T}=xF();DW(()=>{if(k){let P=setTimeout(T,5e3);return()=>clearTimeout(P)}},[k,T]);let E=t.find(P=>P.id===e),I=r&&!!e&&!!E,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=nt(),$=I&&!!s&&!a&&R;return Dt.createElement(gu,{header:Dt.createElement(fu,{toolbar:Dt.createElement(_f,{onOpenSettings:()=>p(!0)})}),footer:Dt.createElement($W,null,Ft.NAME," v","0.5.12")},k&&Dt.createElement(zW,{variant:k.variant||"success"},Dt.createElement(NW,null,k.variant==="error"?"!":k.variant==="warning"?"\u26A0":"+"),Dt.createElement(OW,null,k.message),Dt.createElement(_W,{onClick:T},"x")),i&&Dt.createElement(SF,null,Dt.createElement("span",null,"\u26A0"),Dt.createElement(wF,null,i),Dt.createElement(vF,{onClick:()=>p(!0)},"Reconnect")),u==="admin"&&c&&Dt.createElement(SF,null,Dt.createElement("span",null,"\u{1F441}"),Dt.createElement(wF,null,"Previewing as ",c),Dt.createElement(vF,{onClick:f},"Exit preview")),D||$?Dt.createElement(Xc,{label:D?"Loading...":"Loading review..."}):I?Dt.createElement(Yx,null):Dt.createElement(UW,null,Dt.createElement(jW,null,"\u2699"),Dt.createElement(HW,null,i?"Connection issue":`Set up ${Ft.NAME}`),Dt.createElement(WW,null,i?"Session expired or dashboard unreachable. Please reconnect.":"Connect your account and select a project to start reviewing your components against Figma designs."),Dt.createElement(Yt,{onClick:()=>p(!0)},i?"Reconnect":"Open Settings")),g&&Dt.createElement(YC,{onClose:()=>p(!1)}))};import CF,{useCallback as VW}from"react";import{useStorybookApi as GW}from"storybook/manager-api";import{IconButton as qW}from"storybook/internal/components";var YW="uireview",KW=`${YW}/panel`,TF=()=>{let e=GW(),t=VW(()=>{e.togglePanel(!0),e.setSelectedPanel(KW)},[e]);return CF.createElement(qW,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},CF.createElement(lF,null))};Ce();import Gt,{useState as za,useCallback as AF,useEffect as ey}from"react";import{styled as fo,useTheme as sV}from"storybook/theming";import{addons as au}from"storybook/manager-api";je();Oe();import{addons as tV,experimental_getStatusStore as su}from"storybook/manager-api";async function IF(e,t,n,r){let o=new Array(e.length),i=0;async function s(){for(;i<e.length&&!r();){let a=i++;try{let u=await e[a]();o[a]=u,r()||n(a,u)}catch(u){o[a]=u,r()||n(a,u)}}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),o}je();Oe();var XW=V(),QW="uireview/badge";async function JW(e,t,n=3){for(let r=0;r<=n;r++){let o=await fetch(e,t);if(o.status!==429||r===n)return o;let i=Math.pow(2,r)*1e3;y.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(s=>setTimeout(s,i))}throw new Error("Max retries exceeded")}async function ZW(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:d,value:g}=await e.read();if(d)break;if(t()){e.cancel();break}r+=n.decode(g,{stream:!0});let p=r.split(`
|
|
219
219
|
`);r=p.pop()||"";for(let f of p)if(f.startsWith("data: "))try{let k=JSON.parse(f.slice(6));if(k.type==="complete"){o=k.complianceScore??k.validation?.complianceScore??null;let E=(k.issues||[]).filter(I=>!I.dismissed);i=E.filter(I=>I.severity==="critical").length,s=E.filter(I=>I.severity==="major").length,a=E.filter(I=>I.severity==="minor").length,u=k.costUsd||0,c=k.inputTokens||0,l=k.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function iu(e,t,n,r,o){e&&e.set([{value:n,typeId:QW,storyId:t,title:r,description:o}])}async function eV(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 FF(e,t,n,r,o,i){iu(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await eV(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await JW(`${XW}/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 ZW(u,i),{score:l,criticalCount:d,majorCount:g,minorCount:p,costUsd:f,inputTokens:k,outputTokens:T}=c;if(l!==null){let E=d>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",I=[`Score: ${l}`];d>0&&I.push(`${d} critical`),g>0&&I.push(`${g} major`),p>0&&I.push(`${p} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return iu(o,e.storyId,E,D,I.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:f,inputTokens:k,outputTokens:T}}return iu(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(s){y.error(`[reviewAll] Failed to review ${e.storyName}:`,s);let a=s instanceof Error?s.message:"Unknown error";return iu(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var nV=V(),Ba="uireview/badge";function EF(){let e=!1,t=!1;try{let n=tV.getChannel();n.on(Jx,async()=>{if(!t){t=!0,e=!1;try{await iV(n,()=>e)}finally{t=!1}}}),n.on(Zx,()=>{e=!0})}catch{}}async function Qx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${nV}/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 rV(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function rV(e){try{if(typeof su!="function")return;let t=su(Ba);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[Ba]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[Ba];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:Ba,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 oV(){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 iV(e,t){let n=await Qx();if(n.length===0){e.emit(Ra,{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 k=localStorage.getItem("uicopilot_selected_models");if(k){let T=JSON.parse(k);Array.isArray(T)&&T.length>0&&(i=T[0])}}catch{}let s=null;try{typeof su=="function"&&(s=su(Ba))}catch{}let a=oV(),u=0,c=0,l=0,d=0,g=0,p=0;e.emit(Da,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let f=n.map(k=>()=>FF(k,r,o,i,s,t));await IF(f,a,(k,T)=>{if(T&&typeof T=="object"&&"score"in T){let E=T;E.score!==null&&E.score>=90?u++:E.score!==null&&E.score>=70?c++:l++,d+=E.costUsd||0,g+=E.inputTokens||0,p+=E.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${k+1}/${n.length} done:`,n[k].storyName,T),e.emit(Da,{total:n.length,completed:u+c+l,currentStoryName:n[k].storyName})},t),e.emit(Ra,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:d,inputTokens:g,outputTokens:p})}var aV=fo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),lV=fo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),cV=fo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),PF=fo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),LF=fo.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}})),uV=fo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),pV=fo.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),MF=fo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),as=fo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Jx="uireview/review-all-start",Zx="uireview/review-all-cancel",Da="uireview/review-all-progress",Ra="uireview/review-all-complete";function BF(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var DF=()=>{let[e,t]=za(!1),[n,r]=za(null),[o,i]=za(null),[s,a]=za(null),[u,c]=za(BF);ey(()=>{let f=()=>c(BF()),k=setInterval(f,2e3);return window.addEventListener("storage",f),()=>{clearInterval(k),window.removeEventListener("storage",f)}},[]),ey(()=>{let f=()=>{Qx().then(I=>{a(I.length)}).catch(()=>{})},k=setTimeout(f,3e3),T=null;try{T=au.getChannel(),T.on("storyChanged",f),T.on("uireview/mappings-changed",f)}catch{}let E=setInterval(f,6e4);return()=>{clearTimeout(k),clearInterval(E),T&&(T.off("storyChanged",f),T.off("uireview/mappings-changed",f))}},[]),ey(()=>{let f;try{f=au.getChannel()}catch{return}let k=E=>{r(E),t(!0)},T=E=>{t(!1),r(null),i({total:E.total,passed:E.passed,failed:E.failed,warned:E.warnCount||0,costUsd:E.costUsd||0})};return f.on(Da,k),f.on(Ra,T),()=>{f.off(Da,k),f.off(Ra,T)}},[]);let l=AF(()=>{try{au.getChannel().emit(Jx),t(!0),i(null)}catch{}},[]),d=AF(()=>{try{au.getChannel().emit(Zx)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,p=sV();return u?Gt.createElement(aV,null,Gt.createElement(lV,null,Gt.createElement(cV,null,"UI Review"),e?Gt.createElement(LF,{running:!0,onClick:d},"Cancel"):Gt.createElement(LF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Gt.createElement(Gt.Fragment,null,Gt.createElement(MF,null,Gt.createElement(as,{dotColor:p.color.positive},"Pass (",o.passed,")"),Gt.createElement(as,{dotColor:p.color.warning},"Warn (",o.warned,")"),Gt.createElement(as,{dotColor:p.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Gt.createElement(PF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Gt.createElement(MF,null,Gt.createElement(as,{dotColor:p.color.positive},"Pass"),Gt.createElement(as,{dotColor:p.color.warning},"Warn"),Gt.createElement(as,{dotColor:p.color.negative},"Fail")),e&&n&&Gt.createElement(Gt.Fragment,null,Gt.createElement(uV,null,Gt.createElement(pV,{percent:g})),Gt.createElement(PF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as zF from"@sentry/react";var dV="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",RF=!1;function gV(){if(typeof window>"u")return"production";let e=window.location.hostname;return/^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(e)?"localhost":"production"}function NF(){if(!RF){RF=!0;try{zF.init({dsn:dV,environment:gV(),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{}}}NF();var cu="uireview",mV=`${cu}/panel`,hV=`${cu}/tool`,_F=`${cu}/test-provider`;lu.register(cu,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof OF=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=OF("uireview/badge");Dv(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");lu.add(hV,{type:ty.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Na.createElement(TF,null)}),EF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&lu.add(_F,{type:ty.experimental_TEST_PROVIDER,id:_F,render:()=>Na.createElement(DF,null)}),lu.add(mV,{type:ty.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Na.createElement(fV,{active:t||!1},Na.createElement(zf,null,Na.createElement(kF,null)))})});
|
|
220
220
|
/*! Bundled license information:
|
|
221
221
|
|