var $=Object.defineProperty;var b=(t,e)=>{for(var s in e)$(t,s,{get:e[s],enumerable:!0})};var x={};b(x,{IssueCounter:()=>u,getIssueCountsEnumeration:()=>B,getIssueKindIconName:()=>o});import"./../icon_button/icon_button.js";import*as w from"./../../../core/common/common.js";import*as r from"./../../../core/i18n/i18n.js";import"./../../../models/issues_manager/issues_manager.js";import{html as M,render as O}from"./../../lit/lit.js";var C=`:host{white-space:normal;display:inline-block}
/*# sourceURL=${import.meta.resolve("./issueCounter.css")} */`;var c={pageErrors:"{issueCount, plural, =1 {# page error} other {# page errors}}",breakingChanges:"{issueCount, plural, =1 {# breaking change} other {# breaking changes}}",possibleImprovements:"{issueCount, plural, =1 {# possible improvement} other {# possible improvements}}"},U=r.i18n.registerUIStrings("ui/components/issue_counter/IssueCounter.ts",c),g=r.i18n.getLocalizedString.bind(void 0,U);function o(t){switch(t){case"PageError":return"issue-cross-filled";case"BreakingChange":return"issue-exclamation-filled";case"Improvement":return"issue-text-filled"}}function f(t,e){return e?{iconName:t,iconWidth:e,iconHeight:e}:{iconName:t}}var R=(function(){let e;return{format(...s){if(!e){let i={type:"unit",style:"short"};e=new Intl.ListFormat(r.DevToolsLocale.DevToolsLocale.instance().locale,i)}return e.format(...s)}}})();function B(t,e=!0){let s=[t.numberOfIssues("PageError"),t.numberOfIssues("BreakingChange"),t.numberOfIssues("Improvement")],i=[g(c.pageErrors,{issueCount:s[0]}),g(c.breakingChanges,{issueCount:s[1]}),g(c.possibleImprovements,{issueCount:s[2]})];return R.format(i.filter((a,d)=>e?s[d]>0:!0))}var u=class extends HTMLElement{#u=this.attachShadow({mode:"open"});#e;#n;#s="";#i;#o=[0,0,0];#r="OmitEmpty";#t;#a;#c;#l=!1;scheduleUpdate(){this.#i?this.#i.schedule(async()=>this.#h()):this.#h()}set data(e){this.#e=e.clickHandler,this.#s=e.leadingText??"",this.#n=e.tooltipCallback,this.#r=e.displayMode??"OmitEmpty",this.#a=e.accessibleName,this.#c=e.throttlerTimeout,this.#l=!!e.compact,this.#t!==e.issuesManager&&(this.#t?.removeEventListener("IssuesCountUpdated",this.scheduleUpdate,this),this.#t=e.issuesManager,this.#t.addEventListener("IssuesCountUpdated",this.scheduleUpdate,this)),e.throttlerTimeout!==0?this.#i=new w.Throttler.Throttler(e.throttlerTimeout??100):this.#i=void 0,this.scheduleUpdate()}get data(){return{clickHandler:this.#e,leadingText:this.#s,tooltipCallback:this.#n,displayMode:this.#r,accessibleName:this.#a,throttlerTimeout:this.#c,compact:this.#l,issuesManager:this.#t}}#h(){if(!this.#t)return;this.#o=[this.#t.numberOfIssues("PageError"),this.#t.numberOfIssues("BreakingChange"),this.#t.numberOfIssues("Improvement")];let s=["PageError","BreakingChange","Improvement"][this.#o.findIndex(p=>p>0)??2],i=(p,l)=>{switch(this.#r){case"OmitEmpty":return l>0?`${l}`:void 0;case"ShowAlways":return`${l}`;case"OnlyMostImportant":return p===s?`${l}`:void 0}},a="2ex",d={groups:[{...f(o("PageError"),a),text:i("PageError",this.#o[0])},{...f(o("BreakingChange"),a),text:i("BreakingChange",this.#o[1])},{...f(o("Improvement"),a),text:i("Improvement",this.#o[2])}],clickHandler:this.#e,leadingText:this.#s,accessibleName:this.#a,compact:this.#l};O(M`
        <style>${C}</style>
        <icon-button .data=${d} .accessibleName=${this.#a}></icon-button>
        `,this.#u,{host:this}),this.#n?.()}};customElements.define("devtools-issue-counter",u);var S={};b(S,{IssueLinkIcon:()=>m,extractShortPath:()=>H});import"./../../kit/kit.js";import*as v from"./../../../core/common/common.js";import*as k from"./../../../core/i18n/i18n.js";import*as y from"./../../../models/issues_manager/issues_manager.js";import*as E from"./../render_coordinator/render_coordinator.js";import*as n from"./../../lit/lit.js";import*as L from"./../../visual_logging/visual_logging.js";var T=`:host{display:inline-block;white-space:nowrap;color:inherit;font-size:inherit;font-family:inherit}:host([hidden]){display:none}button{border:none;background:transparent;margin:0;padding:0;&.link{cursor:pointer;& > span{color:var(--sys-color-primary)}}}devtools-icon{width:16px;height:16px;vertical-align:middle;&[name="issue-cross-filled"]{color:var(--icon-error)}&[name="issue-exclamation-filled"]{color:var(--icon-warning)}&[name="issue-text-filled"]{color:var(--icon-info)}}@media (forced-colors: active){devtools-icon{color:ButtonText}}
/*# sourceURL=${import.meta.resolve("./issueLinkIcon.css")} */`;var{html:N}=n,h={clickToShowIssue:"Click to show issue in the issues tab",clickToShowIssueWithTitle:"Click to open the issue tab and show issue: {title}",issueUnavailable:"Issue unavailable at this time"},D=k.i18n.registerUIStrings("ui/components/issue_counter/IssueLinkIcon.ts",h),I=k.i18n.getLocalizedString.bind(void 0,D),H=t=>(/[^/]+$/.exec(t)||/[^/]+\/$/.exec(t)||[""])[0],m=class extends HTMLElement{#u=this.attachShadow({mode:"open"});#e;#n=null;#s;#i;#o;#r=v.Revealer.reveal;set data(e){if(this.#e=e.issue,this.#s=e.issueId,this.#i=e.issueResolver,!this.#e)if(this.#s){if(!this.#i)throw new Error("An `IssueResolver` must be provided if an `issueId` is provided.")}else throw new Error("Either `issue` or `issueId` must be provided");this.#o=e.additionalOnClickAction,e.revealOverride&&(this.#r=e.revealOverride),this.#t(),this.#l()}async#t(){if(!this.#e&&this.#s)try{this.#e=await this.#i?.waitFor(this.#s)}catch{this.#e=null}let e=this.#e?.getDescription();if(e){let s=await y.MarkdownIssueDescription.getIssueTitleFromMarkdownDescription(e);s&&(this.#n=s)}await this.#l()}get data(){return{issue:this.#e,issueId:this.#s,issueResolver:this.#i,additionalOnClickAction:this.#o,revealOverride:this.#r!==v.Revealer.reveal?this.#r:void 0}}handleClick(e){e.button===0&&(this.#e&&this.#r(this.#e),this.#o?.(),e.consume())}#a(){return this.#n?I(h.clickToShowIssueWithTitle,{title:this.#n}):this.#e?I(h.clickToShowIssue):I(h.issueUnavailable)}#c(){return this.#e?o(this.#e.getKind()):"issue-questionmark-filled"}#l(){return E.write(()=>{n.render(N`
      <style>${T}</style>
      <button class=${n.Directives.classMap({link:!!this.#e})}
              title=${this.#a()}
              jslog=${L.link("issue").track({click:!0})}
              @click=${this.handleClick}>
        <devtools-icon name=${this.#c()}></devtools-icon>
      </button>`,this.#u,{host:this})})}};customElements.define("devtools-issue-link-icon",m);export{x as IssueCounter,S as IssueLinkIcon};
//# sourceMappingURL=issue_counter.js.map
