react-semaphor 0.1.449 → 0.1.454
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +119 -112
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/brand-studio/index.cjs +4 -4
- package/dist/brand-studio/index.js +15 -13
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +39 -2131
- package/dist/chunks/{analyze-result-contract-T-0Ntzys.js → analyze-result-contract-BbRJ-C06.js} +1 -1
- package/dist/chunks/{analyze-result-contract-BHb7sUUW.cjs → analyze-result-contract-LPDNldic.cjs} +1 -1
- package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +1 -0
- package/dist/chunks/canonical-result-keys-D6avdjpA.js +467 -0
- package/dist/chunks/color-CJvdlFM_.js +2162 -0
- package/dist/chunks/color-CyB5o13F.cjs +4 -0
- package/dist/chunks/{common-types-CQ6SHfLk.cjs → common-types-C57kJ59w.cjs} +1 -1
- package/dist/chunks/{common-types-B7Jk3Rtj.js → common-types-H51FLKB7.js} +1 -1
- package/dist/chunks/contracts-CoCOpd_i.js +11 -0
- package/dist/chunks/contracts-CtB2VONT.cjs +1 -0
- package/dist/chunks/dashboard-briefing-launcher-Dwj1i7lr.cjs +26 -0
- package/dist/chunks/{dashboard-briefing-launcher-DCHiEkLE.js → dashboard-briefing-launcher-SYroFdae.js} +86 -84
- package/dist/chunks/{dashboard-controls-DwRFCcHV.js → dashboard-controls-1LpeU2sz.js} +15 -13
- package/dist/chunks/{dashboard-controls-CaFioayc.cjs → dashboard-controls-CpFoh7-A.cjs} +1 -1
- package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +1 -0
- package/dist/chunks/{dashboard-date-comparison-definition-Ba-clViK.js → dashboard-date-comparison-definition-DC3ekV2S.js} +1 -1
- package/dist/chunks/{dashboard-json-WoILbfTe.js → dashboard-json-D-T-sQxU.js} +25 -23
- package/dist/chunks/dashboard-json-DwSQopc_.cjs +1 -0
- package/dist/chunks/edit-dashboard-visual-BEmoQAET.cjs +172 -0
- package/dist/chunks/{edit-dashboard-visual-ciFhxqaI.js → edit-dashboard-visual-DqxUq4Bs.js} +6925 -6947
- package/dist/chunks/editor-action-buttons-18r2xwei.cjs +16 -0
- package/dist/chunks/{editor-action-buttons-BPo_45pM.js → editor-action-buttons-B2l3WIRC.js} +41 -39
- package/dist/chunks/format-types-CFHQoIuk.js +1350 -0
- package/dist/chunks/format-types-PSZZ7hG8.cjs +1 -0
- package/dist/chunks/index-Bn5wlkHt.cjs +4 -0
- package/dist/chunks/index-ByFbacH7.cjs +1 -0
- package/dist/chunks/index-CACdoqu3.js +318 -0
- package/dist/chunks/index-CLB_NGZ8.cjs +1392 -0
- package/dist/chunks/index-Ca784dpx.js +3714 -0
- package/dist/chunks/{index-CPuawpXJ.js → index-DAoS4BNU.js} +48514 -48484
- package/dist/chunks/index-DSKR3nKn.js +421 -0
- package/dist/chunks/index-F25jnH0p.cjs +1 -0
- package/dist/chunks/matrix-result-contract-CofATICL.js +437 -0
- package/dist/chunks/matrix-result-contract-zamd9euI.cjs +1 -0
- package/dist/chunks/pivot-header-presentation-DhyQXxKq.cjs +4 -0
- package/dist/chunks/pivot-header-presentation-ckYOQ4aZ.js +557 -0
- package/dist/chunks/{pivot-result-identity-CDLRT-YG.cjs → pivot-result-identity-Bb4EixVN.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-CwJWpKI7.js → pivot-result-identity-DU1v-5Xk.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-DmcF1ris.cjs +1 -0
- package/dist/chunks/pivot-result-lifecycle-sjzIOpvp.js +1641 -0
- package/dist/chunks/raw-temporal-contract-BtjH_G-d.cjs +1 -0
- package/dist/chunks/raw-temporal-contract-CxncLze5.js +64 -0
- package/dist/chunks/report-preferences-dialog-BgSvlDXa.cjs +1 -0
- package/dist/chunks/report-preferences-dialog-DDc2WUa0.js +723 -0
- package/dist/chunks/{report-runtime-context-C8LZFsqV.cjs → report-runtime-context-DqxS4wbi.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-bCy3CVzK.js → report-runtime-context-SM6YO61_.js} +5 -5
- package/dist/chunks/saved-temporal-bucket-format-CFfWXRl9.cjs +1 -0
- package/dist/chunks/saved-temporal-bucket-format-SGAV0ivR.js +922 -0
- package/dist/chunks/{switch-BXet-Sno.js → switch-BeZW-HnS.js} +4350 -5249
- package/dist/chunks/switch-D-CCcfhc.cjs +138 -0
- package/dist/chunks/temporal-bucket-5UYEotyQ.js +810 -0
- package/dist/chunks/temporal-bucket-DHY1y9lq.cjs +1 -0
- package/dist/chunks/temporal-bucket-authoring-K1kE6R_z.js +222 -0
- package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +1 -0
- package/dist/chunks/{temporal-bucket-contract-ChDBWX8I.cjs → temporal-bucket-contract-D2-93DGr.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-_F6vNhhH.js → temporal-bucket-contract-D5d-xEl3.js} +1 -1
- package/dist/chunks/{token-types-BdQ8kHBm.cjs → token-types-D7CaaI80.cjs} +1 -1
- package/dist/chunks/{token-types-BHR58aTy.js → token-types-GbxRUozo.js} +1 -1
- package/dist/chunks/{update-policy-BxvYMYz0.cjs → update-policy-BmiOd0PB.cjs} +1 -1
- package/dist/chunks/{update-policy-g0rCQ9BM.js → update-policy-hednMF-0.js} +1 -1
- package/dist/chunks/validators-BDYprKI9.cjs +1 -0
- package/dist/chunks/{validators-Cs74WVie.js → validators-DEmd8Sin.js} +1561 -1197
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +35 -32
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +78 -77
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +29 -30
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +21 -21
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +156 -140
- package/dist/index.cjs +1 -1
- package/dist/index.js +157 -155
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +81 -11
- package/dist/types/briefings.d.ts +727 -19
- package/dist/types/dashboard-assistant.d.ts +37 -17
- package/dist/types/dashboard-authoring.d.ts +61 -14
- package/dist/types/dashboard.d.ts +137 -12
- package/dist/types/data-app-builder.d.ts +28 -2
- package/dist/types/data-app-codegen-node.d.ts +29 -3
- package/dist/types/data-app-codegen.d.ts +29 -3
- package/dist/types/data-app-sdk-adapters.d.ts +28 -2
- package/dist/types/data-app-sdk-validation.d.ts +51 -7
- package/dist/types/data-app-sdk.d.ts +55 -10
- package/dist/types/format-utils.d.ts +190 -3
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +128 -33
- package/dist/types/shared.d.ts +14 -12
- package/dist/types/surfboard.d.ts +138 -13
- package/dist/types/types.d.ts +117 -23
- package/dist/types/value-format-preferences.d.ts +3 -0
- package/package.json +2 -1
- package/dist/chunks/card-config-utils-15sRtebL.cjs +0 -1
- package/dist/chunks/card-config-utils-BYZ5MJOh.js +0 -16
- package/dist/chunks/catalog-field-grounding-Bnx-3tE0.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-S2jKwKGD.js +0 -100
- package/dist/chunks/dashboard-briefing-launcher-DDgDr2s3.cjs +0 -26
- package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +0 -1
- package/dist/chunks/dashboard-input-contract-DSt8dGzP.js +0 -18
- package/dist/chunks/dashboard-input-contract-DV3cshjz.cjs +0 -1
- package/dist/chunks/dashboard-json-CYtvwtvj.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-DwKcvlsF.cjs +0 -177
- package/dist/chunks/editor-action-buttons-BVmsk0Aj.cjs +0 -16
- package/dist/chunks/format-types-CSv0V7mm.cjs +0 -1
- package/dist/chunks/format-types-DZGgYj39.js +0 -1663
- package/dist/chunks/index-CJdxSyQq.js +0 -2578
- package/dist/chunks/index-DPv8_Ild.cjs +0 -1395
- package/dist/chunks/index-DRlMUglg.cjs +0 -4
- package/dist/chunks/metric-comparison-97zHGEx5.js +0 -387
- package/dist/chunks/metric-comparison-CUAJ8n4y.cjs +0 -1
- package/dist/chunks/pivot-result-lifecycle-BBabQ_da.js +0 -914
- package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +0 -4
- package/dist/chunks/presentation-execution-BLfPTGX_.js +0 -637
- package/dist/chunks/presentation-execution-BTV-Q43g.cjs +0 -1
- package/dist/chunks/report-preferences-dialog-D9ZCGh9l.js +0 -691
- package/dist/chunks/report-preferences-dialog-DaqTEcac.cjs +0 -1
- package/dist/chunks/switch-Cjk6G06r.cjs +0 -138
- package/dist/chunks/temporal-bucket-BnPxGrAi.js +0 -446
- package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +0 -1
- package/dist/chunks/temporal-bucket-authoring-CgOuakGW.js +0 -205
- package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +0 -1
- package/dist/chunks/temporal-result-owner-6peubmhU.js +0 -443
- package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +0 -1
- package/dist/chunks/validators-9D4KBqKD.cjs +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const fn='"Open Sans", Arial, ui-sans-serif, system-ui, sans-serif',T0=fn,N0='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',P0=[{id:"open-sans",label:"Semaphor default / Open Sans",value:fn},{id:"inter",label:"Inter",value:'Inter, "Open Sans", Arial, ui-sans-serif, system-ui, sans-serif'},{id:"ibm-plex-sans",label:"IBM Plex Sans",value:'"IBM Plex Sans", "Open Sans", Arial, ui-sans-serif, system-ui, sans-serif'},{id:"system",label:"System UI",value:'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'}],Jn=(e,n)=>{if(typeof e=="number"){if(n===3)return{mode:"rgb",r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(n===4)return{mode:"rgb",r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(n===6)return{mode:"rgb",r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(n===8)return{mode:"rgb",r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},R0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},H0=e=>Jn(R0[e.toLowerCase()],6),I0=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,C0=e=>{let n;return(n=e.match(I0))?Jn(parseInt(n[1],16),n[1].length):void 0},H="([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)",ee=`${H}%`,on=`(?:${H}%|${H})`,S0=`(?:${H}(deg|grad|rad|turn)|${H})`,Y="\\s*,\\s*",A0=new RegExp(`^rgba?\\(\\s*${H}${Y}${H}${Y}${H}\\s*(?:,\\s*${on}\\s*)?\\)$`),O0=new RegExp(`^rgba?\\(\\s*${ee}${Y}${ee}${Y}${ee}\\s*(?:,\\s*${on}\\s*)?\\)$`),X0=e=>{let n={mode:"rgb"},t;if(t=e.match(A0))t[1]!==void 0&&(n.r=t[1]/255),t[2]!==void 0&&(n.g=t[2]/255),t[3]!==void 0&&(n.b=t[3]/255);else if(t=e.match(O0))t[1]!==void 0&&(n.r=t[1]/100),t[2]!==void 0&&(n.g=t[2]/100),t[3]!==void 0&&(n.b=t[3]/100);else return;return t[4]!==void 0?n.alpha=Math.max(0,Math.min(1,t[4]/100)):t[5]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[5]))),n},L0=(e,n)=>e===void 0?void 0:typeof e!="object"?dn(e):e.mode!==void 0?e:n?{...e,mode:n}:void 0,Bn=(e="rgb")=>n=>(n=L0(n,e))!==void 0?n.mode===e?n:T[n.mode][e]?T[n.mode][e](n):e==="rgb"?T[n.mode].rgb(n):T.rgb[e](T[n.mode].rgb(n)):void 0,T={},Un={},oe=[],Gn={},q0=e=>e,p=e=>(T[e.mode]={...T[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(n=>{T[n]||(T[n]={}),T[n][e.mode]=e.fromMode[n]}),e.ranges||(e.ranges={}),e.difference||(e.difference={}),e.channels.forEach(n=>{if(e.ranges[n]===void 0&&(e.ranges[n]=[0,1]),!e.interpolate[n])throw new Error(`Missing interpolator for: ${n}`);typeof e.interpolate[n]=="function"&&(e.interpolate[n]={use:e.interpolate[n]}),e.interpolate[n].fixup||(e.interpolate[n].fixup=q0)}),Un[e.mode]=e,(e.parse||[]).forEach(n=>{F0(n,e.mode)}),Bn(e.mode)),E0=e=>Un[e],F0=(e,n)=>{if(typeof e=="string"){if(!n)throw new Error("'mode' required when 'parser' is a string");Gn[e]=n}else typeof e=="function"&&oe.indexOf(e)<0&&oe.push(e)},Qe=/[^\x00-\x7F]|[a-zA-Z_]/,Y0=/[^\x00-\x7F]|[-\w]/,d={Function:"function",Ident:"ident",Number:"number",Percentage:"percentage",ParenClose:")",None:"none",Hue:"hue",Alpha:"alpha"};let h=0;function re(e){let n=e[h],t=e[h+1];return n==="-"||n==="+"?/\d/.test(t)||t==="."&&/\d/.test(e[h+2]):n==="."?/\d/.test(t):/\d/.test(n)}function Ve(e){if(h>=e.length)return!1;let n=e[h];if(Qe.test(n))return!0;if(n==="-"){if(e.length-h<2)return!1;let t=e[h+1];return!!(t==="-"||Qe.test(t))}return!1}const j0={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function V(e){let n="";if((e[h]==="-"||e[h]==="+")&&(n+=e[h++]),n+=fe(e),e[h]==="."&&/\d/.test(e[h+1])&&(n+=e[h++]+fe(e)),(e[h]==="e"||e[h]==="E")&&((e[h+1]==="-"||e[h+1]==="+")&&/\d/.test(e[h+2])?n+=e[h++]+e[h++]+fe(e):/\d/.test(e[h+1])&&(n+=e[h++]+fe(e))),Ve(e)){let t=de(e);return t==="deg"||t==="rad"||t==="turn"||t==="grad"?{type:d.Hue,value:n*j0[t]}:void 0}return e[h]==="%"?(h++,{type:d.Percentage,value:+n}):{type:d.Number,value:+n}}function fe(e){let n="";for(;/\d/.test(e[h]);)n+=e[h++];return n}function de(e){let n="";for(;h<e.length&&Y0.test(e[h]);)n+=e[h++];return n}function D0(e){let n=de(e);return e[h]==="("?(h++,{type:d.Function,value:n}):n==="none"?{type:d.None,value:void 0}:{type:d.Ident,value:n}}function Z0(e=""){let n=e.trim(),t=[],i;for(h=0;h<n.length;){if(i=n[h++],i===`
|
|
2
|
+
`||i===" "||i===" "){for(;h<n.length&&(n[h]===`
|
|
3
|
+
`||n[h]===" "||n[h]===" ");)h++;continue}if(i===",")return;if(i===")"){t.push({type:d.ParenClose});continue}if(i==="+"){if(h--,re(n)){t.push(V(n));continue}return}if(i==="-"){if(h--,re(n)){t.push(V(n));continue}if(Ve(n)){t.push({type:d.Ident,value:de(n)});continue}return}if(i==="."){if(h--,re(n)){t.push(V(n));continue}return}if(i==="/"){for(;h<n.length&&(n[h]===`
|
|
4
|
+
`||n[h]===" "||n[h]===" ");)h++;let a;if(re(n)&&(a=V(n),a.type!==d.Hue)){t.push({type:d.Alpha,value:a});continue}if(Ve(n)&&de(n)==="none"){t.push({type:d.Alpha,value:{type:d.None,value:void 0}});continue}return}if(/\d/.test(i)){h--,t.push(V(n));continue}if(Qe.test(i)){h--,t.push(D0(n));continue}return}return t}function J0(e){e._i=0;let n=e[e._i++];if(!n||n.type!==d.Function||n.value!=="color"||(n=e[e._i++],n.type!==d.Ident))return;const t=Gn[n.value];if(!t)return;const i={mode:t},a=Wn(e,!1);if(!a)return;const r=E0(t).channels;for(let f=0,o,u;f<r.length;f++)o=a[f],u=r[f],o.type!==d.None&&(i[u]=o.type===d.Number?o.value:o.value/100,u==="alpha"&&(i[u]=Math.max(0,Math.min(1,i[u]))));return i}function Wn(e,n){const t=[];let i;for(;e._i<e.length;){if(i=e[e._i++],i.type===d.None||i.type===d.Number||i.type===d.Alpha||i.type===d.Percentage||n&&i.type===d.Hue){t.push(i);continue}if(i.type===d.ParenClose){if(e._i<e.length)return;continue}return}if(!(t.length<3||t.length>4)){if(t.length===4){if(t[3].type!==d.Alpha)return;t[3]=t[3].value}return t.length===3&&t.push({type:d.None,value:void 0}),t.every(a=>a.type!==d.Alpha)?t:void 0}}function B0(e,n){e._i=0;let t=e[e._i++];if(!t||t.type!==d.Function)return;let i=Wn(e,n);if(i)return i.unshift(t.value),i}const dn=e=>{if(typeof e!="string")return;const n=Z0(e),t=n?B0(n,!0):void 0;let i,a=0,r=oe.length;for(;a<r;)if((i=oe[a++](e,t))!==void 0)return i;return n?J0(n):void 0};function U0(e,n){if(!n||n[0]!=="rgb"&&n[0]!=="rgba")return;const t={mode:"rgb"},[,i,a,r,f]=n;if(!(i.type===d.Hue||a.type===d.Hue||r.type===d.Hue))return i.type!==d.None&&(t.r=i.type===d.Number?i.value/255:i.value/100),a.type!==d.None&&(t.g=a.type===d.Number?a.value/255:a.value/100),r.type!==d.None&&(t.b=r.type===d.Number?r.value/255:r.value/100),f.type!==d.None&&(t.alpha=Math.min(1,Math.max(0,f.type===d.Number?f.value:f.value/100))),t}const G0=e=>e==="transparent"?{mode:"rgb",r:0,g:0,b:0,alpha:0}:void 0,W0=(e,n,t)=>e+t*(n-e),K0=e=>{let n=[];for(let t=0;t<e.length-1;t++){let i=e[t],a=e[t+1];i===void 0&&a===void 0?n.push(void 0):i!==void 0&&a!==void 0?n.push([i,a]):n.push(i!==void 0?[i,i]:[a,a])}return n},Q0=e=>n=>{let t=K0(n);return i=>{let a=i*t.length,r=i>=1?t.length-1:Math.max(Math.floor(a),0),f=t[r];return f===void 0?void 0:e(f[0],f[1],a-r)}},l=Q0(W0),y=e=>{let n=!1,t=e.map(i=>i!==void 0?(n=!0,i):1);return n?t:e},j={mode:"rgb",channels:["r","g","b","alpha"],parse:[U0,C0,X0,H0,G0,"srgb"],serialize:"srgb",interpolate:{r:l,g:l,b:l,alpha:{use:l,fixup:y}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},Re=(e=0)=>Math.pow(Math.abs(e),563/256)*Math.sign(e),kn=e=>{let n=Re(e.r),t=Re(e.g),i=Re(e.b),a={mode:"xyz65",x:.5766690429101305*n+.1855582379065463*t+.1882286462349947*i,y:.297344975250536*n+.6273635662554661*t+.0752914584939979*i,z:.0270313613864123*n+.0706888525358272*t+.9913375368376386*i};return e.alpha!==void 0&&(a.alpha=e.alpha),a},He=e=>Math.pow(Math.abs(e),256/563)*Math.sign(e),_n=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a={mode:"a98",r:He(e*2.0415879038107465-n*.5650069742788597-.3447313507783297*t),g:He(e*-.9692436362808798+n*1.8759675015077206+.0415550574071756*t),b:He(e*.0134442806320312-n*.1183623922310184+1.0151749943912058*t)};return i!==void 0&&(a.alpha=i),a},Ie=(e=0)=>{const n=Math.abs(e);return n<=.04045?e/12.92:(Math.sign(e)||1)*Math.pow((n+.055)/1.055,2.4)},D=({r:e,g:n,b:t,alpha:i})=>{let a={mode:"lrgb",r:Ie(e),g:Ie(n),b:Ie(t)};return i!==void 0&&(a.alpha=i),a},L=e=>{let{r:n,g:t,b:i,alpha:a}=D(e),r={mode:"xyz65",x:.4123907992659593*n+.357584339383878*t+.1804807884018343*i,y:.2126390058715102*n+.715168678767756*t+.0721923153607337*i,z:.0193308187155918*n+.119194779794626*t+.9505321522496607*i};return a!==void 0&&(r.alpha=a),r},Ce=(e=0)=>{const n=Math.abs(e);return n>.0031308?(Math.sign(e)||1)*(1.055*Math.pow(n,1/2.4)-.055):e*12.92},Z=({r:e,g:n,b:t,alpha:i},a="rgb")=>{let r={mode:a,r:Ce(e),g:Ce(n),b:Ce(t)};return i!==void 0&&(r.alpha=i),r},q=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Z({r:e*3.2409699419045226-n*1.537383177570094-.4986107602930034*t,g:e*-.9692436362808796+n*1.8759675015077204+.0415550574071756*t,b:e*.0556300796969936-n*.2039769588889765+1.0569715142428784*t});return i!==void 0&&(a.alpha=i),a},V0={...j,mode:"a98",parse:["a98-rgb"],serialize:"a98-rgb",fromMode:{rgb:e=>_n(L(e)),xyz65:_n},toMode:{rgb:e=>q(kn(e)),xyz65:kn}},$=e=>(e=e%360)<0?e+360:e,et=(e,n)=>e.map((t,i,a)=>{if(t===void 0)return t;let r=$(t);return i===0||e[i-1]===void 0?r:n(r-$(a[i-1]))}).reduce((t,i)=>!t.length||i===void 0||t[t.length-1]===void 0?(t.push(i),t):(t.push(i+t[t.length-1]),t),[]),N=e=>et(e,n=>Math.abs(n)<=180?n:n-360*Math.sign(n)),k=[-.14861,1.78277,-.29227,-.90649,1.97294,0],nt=Math.PI/180,tt=180/Math.PI;let $n=k[3]*k[4],zn=k[1]*k[4],wn=k[1]*k[2]-k[0]*k[3];const at=({r:e,g:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=(wn*t+e*$n-n*zn)/(wn+$n-zn),r=t-a,f=(k[4]*(n-a)-k[2]*r)/k[3],o={mode:"cubehelix",l:a,s:a===0||a===1?void 0:Math.sqrt(r*r+f*f)/(k[4]*a*(1-a))};return o.s&&(o.h=Math.atan2(f,r)*tt-120),i!==void 0&&(o.alpha=i),o},it=({h:e,s:n,l:t,alpha:i})=>{let a={mode:"rgb"};e=(e===void 0?0:e+120)*nt,t===void 0&&(t=0);let r=n===void 0?0:n*t*(1-t),f=Math.cos(e),o=Math.sin(e);return a.r=t+r*(k[0]*f+k[1]*o),a.g=t+r*(k[2]*f+k[3]*o),a.b=t+r*(k[4]*f+k[5]*o),i!==void 0&&(a.alpha=i),a},ce=(e,n)=>{if(e.h===void 0||n.h===void 0||!e.s||!n.s)return 0;let t=$(e.h),i=$(n.h),a=Math.sin((i-t+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*n.s)*a},rt=(e,n)=>{if(e.h===void 0||n.h===void 0)return 0;let t=$(e.h),i=$(n.h);return Math.abs(i-t)>180?t-(i-360*Math.sign(i-t)):i-t},be=(e,n)=>{if(e.h===void 0||n.h===void 0||!e.c||!n.c)return 0;let t=$(e.h),i=$(n.h),a=Math.sin((i-t+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*n.c)*a},P=e=>{let n=e.reduce((i,a)=>{if(a!==void 0){let r=a*Math.PI/180;i.sin+=Math.sin(r),i.cos+=Math.cos(r)}return i},{sin:0,cos:0}),t=Math.atan2(n.sin,n.cos)*180/Math.PI;return t<0?360+t:t},ft={mode:"cubehelix",channels:["h","s","l","alpha"],parse:["--cubehelix"],serialize:"--cubehelix",ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:at},toMode:{rgb:it},interpolate:{h:{use:l,fixup:N},s:l,l,alpha:{use:l,fixup:y}},difference:{h:ce},average:{h:P}},I=({l:e,a:n,b:t,alpha:i},a="lch")=>{n===void 0&&(n=0),t===void 0&&(t=0);let r=Math.sqrt(n*n+t*t),f={mode:a,l:e,c:r};return r&&(f.h=$(Math.atan2(t,n)*180/Math.PI)),i!==void 0&&(f.alpha=i),f},C=({l:e,c:n,h:t,alpha:i},a="lab")=>{t===void 0&&(t=0);let r={mode:a,l:e,a:n?n*Math.cos(t/180*Math.PI):0,b:n?n*Math.sin(t/180*Math.PI):0};return i!==void 0&&(r.alpha=i),r},Kn=Math.pow(29,3)/Math.pow(3,3),Qn=Math.pow(6,3)/Math.pow(29,3),M={X:.3457/.3585,Y:1,Z:(1-.3457-.3585)/.3585},F={X:.3127/.329,Y:1,Z:(1-.3127-.329)/.329};let Se=e=>Math.pow(e,3)>Qn?Math.pow(e,3):(116*e-16)/Kn;const Vn=({l:e,a:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=(e+16)/116,r=n/500+a,f=a-t/200,o={mode:"xyz65",x:Se(r)*F.X,y:Se(a)*F.Y,z:Se(f)*F.Z};return i!==void 0&&(o.alpha=i),o},pe=e=>q(Vn(e)),Ae=e=>e>Qn?Math.cbrt(e):(Kn*e+16)/116,e0=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Ae(e/F.X),r=Ae(n/F.Y),f=Ae(t/F.Z),o={mode:"lab65",l:116*r-16,a:500*(a-r),b:200*(r-f)};return i!==void 0&&(o.alpha=i),o},me=e=>{let n=e0(L(e));return e.r===e.b&&e.b===e.g&&(n.a=n.b=0),n},le=1,n0=1,ne=26/180*Math.PI,ue=Math.cos(ne),se=Math.sin(ne),t0=100/Math.log(139/100),en=({l:e,c:n,h:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a={mode:"lab65",l:(Math.exp(e*le/t0)-1)/.0039},r=(Math.exp(.0435*n*n0*le)-1)/.075,f=r*Math.cos(t/180*Math.PI-ne),o=r*Math.sin(t/180*Math.PI-ne);return a.a=f*ue-o/.83*se,a.b=f*se+o/.83*ue,i!==void 0&&(a.alpha=i),a},nn=({l:e,a:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=n*ue+t*se,r=.83*(t*ue-n*se),f=Math.sqrt(a*a+r*r),o={mode:"dlch",l:t0/le*Math.log(1+.0039*e),c:Math.log(1+.075*f)/(.0435*n0*le)};return o.c&&(o.h=$((Math.atan2(r,a)+ne)/Math.PI*180)),i!==void 0&&(o.alpha=i),o},Tn=e=>en(I(e,"dlch")),Nn=e=>C(nn(e),"dlab"),ot={mode:"dlab",parse:["--din99o-lab"],serialize:"--din99o-lab",toMode:{lab65:Tn,rgb:e=>pe(Tn(e))},fromMode:{lab65:Nn,rgb:e=>Nn(me(e))},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l,a:l,b:l,alpha:{use:l,fixup:y}}},dt={mode:"dlch",parse:["--din99o-lch"],serialize:"--din99o-lch",toMode:{lab65:en,dlab:e=>C(e,"dlab"),rgb:e=>pe(en(e))},fromMode:{lab65:nn,dlab:e=>I(e,"dlch"),rgb:e=>nn(me(e))},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l,c:l,h:{use:l,fixup:N},alpha:{use:l,fixup:y}},difference:{h:be},average:{h:P}};function lt({h:e,s:n,i:t,alpha:i}){e=$(e!==void 0?e:0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.abs(e/60%2-1),r;switch(Math.floor(e/60)){case 0:r={r:t*(1+n*(3/(2-a)-1)),g:t*(1+n*(3*(1-a)/(2-a)-1)),b:t*(1-n)};break;case 1:r={r:t*(1+n*(3*(1-a)/(2-a)-1)),g:t*(1+n*(3/(2-a)-1)),b:t*(1-n)};break;case 2:r={r:t*(1-n),g:t*(1+n*(3/(2-a)-1)),b:t*(1+n*(3*(1-a)/(2-a)-1))};break;case 3:r={r:t*(1-n),g:t*(1+n*(3*(1-a)/(2-a)-1)),b:t*(1+n*(3/(2-a)-1))};break;case 4:r={r:t*(1+n*(3*(1-a)/(2-a)-1)),g:t*(1-n),b:t*(1+n*(3/(2-a)-1))};break;case 5:r={r:t*(1+n*(3/(2-a)-1)),g:t*(1-n),b:t*(1+n*(3*(1-a)/(2-a)-1))};break;default:r={r:t*(1-n),g:t*(1-n),b:t*(1-n)}}return r.mode="rgb",i!==void 0&&(r.alpha=i),r}function ut({r:e,g:n,b:t,alpha:i}){e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.max(e,n,t),r=Math.min(e,n,t),f={mode:"hsi",s:e+n+t===0?0:1-3*r/(e+n+t),i:(e+n+t)/3};return a-r!==0&&(f.h=(a===e?(n-t)/(a-r)+(n<t)*6:a===n?(t-e)/(a-r)+2:(e-n)/(a-r)+4)*60),i!==void 0&&(f.alpha=i),f}const st={mode:"hsi",toMode:{rgb:lt},parse:["--hsi"],serialize:"--hsi",fromMode:{rgb:ut},channels:["h","s","i","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:l,fixup:N},s:l,i:l,alpha:{use:l,fixup:y}},difference:{h:ce},average:{h:P}};function ht({h:e,s:n,l:t,alpha:i}){e=$(e!==void 0?e:0),n===void 0&&(n=0),t===void 0&&(t=0);let a=t+n*(t<.5?t:1-t),r=a-(a-t)*2*Math.abs(e/60%2-1),f;switch(Math.floor(e/60)){case 0:f={r:a,g:r,b:2*t-a};break;case 1:f={r,g:a,b:2*t-a};break;case 2:f={r:2*t-a,g:a,b:r};break;case 3:f={r:2*t-a,g:r,b:a};break;case 4:f={r,g:2*t-a,b:a};break;case 5:f={r:a,g:2*t-a,b:r};break;default:f={r:2*t-a,g:2*t-a,b:2*t-a}}return f.mode="rgb",i!==void 0&&(f.alpha=i),f}function ct({r:e,g:n,b:t,alpha:i}){e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.max(e,n,t),r=Math.min(e,n,t),f={mode:"hsl",s:a===r?0:(a-r)/(1-Math.abs(a+r-1)),l:.5*(a+r)};return a-r!==0&&(f.h=(a===e?(n-t)/(a-r)+(n<t)*6:a===n?(t-e)/(a-r)+2:(e-n)/(a-r)+4)*60),i!==void 0&&(f.alpha=i),f}const bt=(e,n)=>{switch(n){case"deg":return+e;case"rad":return e/Math.PI*180;case"grad":return e/10*9;case"turn":return e*360}},pt=new RegExp(`^hsla?\\(\\s*${S0}${Y}${ee}${Y}${ee}\\s*(?:,\\s*${on}\\s*)?\\)$`),mt=e=>{let n=e.match(pt);if(!n)return;let t={mode:"hsl"};return n[3]!==void 0?t.h=+n[3]:n[1]!==void 0&&n[2]!==void 0&&(t.h=bt(n[1],n[2])),n[4]!==void 0&&(t.s=Math.min(Math.max(0,n[4]/100),1)),n[5]!==void 0&&(t.l=Math.min(Math.max(0,n[5]/100),1)),n[6]!==void 0?t.alpha=Math.max(0,Math.min(1,n[6]/100)):n[7]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[7]))),t};function gt(e,n){if(!n||n[0]!=="hsl"&&n[0]!=="hsla")return;const t={mode:"hsl"},[,i,a,r,f]=n;if(i.type!==d.None){if(i.type===d.Percentage)return;t.h=i.value}if(a.type!==d.None){if(a.type===d.Hue)return;t.s=a.value/100}if(r.type!==d.None){if(r.type===d.Hue)return;t.l=r.value/100}return f.type!==d.None&&(t.alpha=Math.min(1,Math.max(0,f.type===d.Number?f.value:f.value/100))),t}const a0={mode:"hsl",toMode:{rgb:ht},fromMode:{rgb:ct},channels:["h","s","l","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[gt,mt],serialize:e=>`hsl(${e.h!==void 0?e.h:"none"} ${e.s!==void 0?e.s*100+"%":"none"} ${e.l!==void 0?e.l*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:l,fixup:N},s:l,l,alpha:{use:l,fixup:y}},difference:{h:ce},average:{h:P}};function i0({h:e,s:n,v:t,alpha:i}){e=$(e!==void 0?e:0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.abs(e/60%2-1),r;switch(Math.floor(e/60)){case 0:r={r:t,g:t*(1-n*a),b:t*(1-n)};break;case 1:r={r:t*(1-n*a),g:t,b:t*(1-n)};break;case 2:r={r:t*(1-n),g:t,b:t*(1-n*a)};break;case 3:r={r:t*(1-n),g:t*(1-n*a),b:t};break;case 4:r={r:t*(1-n*a),g:t*(1-n),b:t};break;case 5:r={r:t,g:t*(1-n),b:t*(1-n*a)};break;default:r={r:t*(1-n),g:t*(1-n),b:t*(1-n)}}return r.mode="rgb",i!==void 0&&(r.alpha=i),r}function r0({r:e,g:n,b:t,alpha:i}){e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.max(e,n,t),r=Math.min(e,n,t),f={mode:"hsv",s:a===0?0:1-r/a,v:a};return a-r!==0&&(f.h=(a===e?(n-t)/(a-r)+(n<t)*6:a===n?(t-e)/(a-r)+2:(e-n)/(a-r)+4)*60),i!==void 0&&(f.alpha=i),f}const f0={mode:"hsv",toMode:{rgb:i0},parse:["--hsv"],serialize:"--hsv",fromMode:{rgb:r0},channels:["h","s","v","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:l,fixup:N},s:l,v:l,alpha:{use:l,fixup:y}},difference:{h:ce},average:{h:P}};function Mt({h:e,w:n,b:t,alpha:i}){if(n===void 0&&(n=0),t===void 0&&(t=0),n+t>1){let a=n+t;n/=a,t/=a}return i0({h:e,s:t===1?1:1-n/(1-t),v:1-t,alpha:i})}function xt(e){let n=r0(e);if(n===void 0)return;let t=n.s!==void 0?n.s:0,i=n.v!==void 0?n.v:0,a={mode:"hwb",w:(1-t)*i,b:1-i};return n.h!==void 0&&(a.h=n.h),n.alpha!==void 0&&(a.alpha=n.alpha),a}function yt(e,n){if(!n||n[0]!=="hwb")return;const t={mode:"hwb"},[,i,a,r,f]=n;if(i.type!==d.None){if(i.type===d.Percentage)return;t.h=i.value}if(a.type!==d.None){if(a.type===d.Hue)return;t.w=a.value/100}if(r.type!==d.None){if(r.type===d.Hue)return;t.b=r.value/100}return f.type!==d.None&&(t.alpha=Math.min(1,Math.max(0,f.type===d.Number?f.value:f.value/100))),t}const vt={mode:"hwb",toMode:{rgb:Mt},fromMode:{rgb:xt},channels:["h","w","b","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[yt],serialize:e=>`hwb(${e.h!==void 0?e.h:"none"} ${e.w!==void 0?e.w*100+"%":"none"} ${e.b!==void 0?e.b*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:l,fixup:N},w:l,b:l,alpha:{use:l,fixup:y}},difference:{h:rt},average:{h:P}},o0=203,ge=.1593017578125,d0=78.84375,Me=.8359375,xe=18.8515625,ye=18.6875;function Oe(e){if(e<0)return 0;const n=Math.pow(e,1/d0);return 1e4*Math.pow(Math.max(0,n-Me)/(xe-ye*n),1/ge)}function Xe(e){if(e<0)return 0;const n=Math.pow(e/1e4,ge);return Math.pow((Me+xe*n)/(1+ye*n),d0)}const Le=e=>Math.max(e/o0,0),Pn=({i:e,t:n,p:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);const a=Oe(e+.008609037037932761*n+.11102962500302593*t),r=Oe(e-.00860903703793275*n-.11102962500302599*t),f=Oe(e+.5600313357106791*n-.32062717498731885*t),o={mode:"xyz65",x:Le(2.070152218389422*a-1.3263473389671556*r+.2066510476294051*f),y:Le(.3647385209748074*a+.680566024947227*r-.0453045459220346*f),z:Le(-.049747207535812*a-.0492609666966138*r+1.1880659249923042*f)};return i!==void 0&&(o.alpha=i),o},qe=(e=0)=>Math.max(e*o0,0),Rn=({x:e,y:n,z:t,alpha:i})=>{const a=qe(e),r=qe(n),f=qe(t),o=Xe(.3592832590121217*a+.6976051147779502*r-.0358915932320289*f),u=Xe(-.1920808463704995*a+1.1004767970374323*r+.0753748658519118*f),s=Xe(.0070797844607477*a+.0748396662186366*r+.8433265453898765*f),c=.5*o+.5*u,b=1.61376953125*o-3.323486328125*u+1.709716796875*s,m=4.378173828125*o-4.24560546875*u-.132568359375*s,g={mode:"itp",i:c,t:b,p:m};return i!==void 0&&(g.alpha=i),g},kt={mode:"itp",channels:["i","t","p","alpha"],parse:["--ictcp"],serialize:"--ictcp",toMode:{xyz65:Pn,rgb:e=>q(Pn(e))},fromMode:{xyz65:Rn,rgb:e=>Rn(L(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:l,t:l,p:l,alpha:{use:l,fixup:y}}},_t=134.03437499999998,$t=16295499532821565e-27,Ee=e=>{if(e<0)return 0;let n=Math.pow(e/1e4,ge);return Math.pow((Me+xe*n)/(1+ye*n),_t)},Fe=(e=0)=>Math.max(e*203,0),l0=({x:e,y:n,z:t,alpha:i})=>{e=Fe(e),n=Fe(n),t=Fe(t);let a=1.15*e-.15*t,r=.66*n+.34*e,f=Ee(.41478972*a+.579999*r+.014648*t),o=Ee(-.20151*a+1.120649*r+.0531008*t),u=Ee(-.0166008*a+.2648*r+.6684799*t),s=(f+o)/2,c={mode:"jab",j:.44*s/(1-.56*s)-$t,a:3.524*f-4.066708*o+.542708*u,b:.199076*f+1.096799*o-1.295875*u};return i!==void 0&&(c.alpha=i),c},zt=134.03437499999998,Hn=16295499532821565e-27,Ye=e=>{if(e<0)return 0;let n=Math.pow(e,1/zt);return 1e4*Math.pow((Me-n)/(ye*n-xe),1/ge)},je=e=>e/203,u0=({j:e,a:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=(e+Hn)/(.44+.56*(e+Hn)),r=Ye(a+.13860504*n+.058047316*t),f=Ye(a-.13860504*n-.058047316*t),o=Ye(a-.096019242*n-.8118919*t),u={mode:"xyz65",x:je(1.661373024652174*r-.914523081304348*f+.23136208173913045*o),y:je(-.3250758611844533*r+1.571847026732543*f-.21825383453227928*o),z:je(-.090982811*r-.31272829*f+1.5227666*o)};return i!==void 0&&(u.alpha=i),u},s0=e=>{let n=l0(L(e));return e.r===e.b&&e.b===e.g&&(n.a=n.b=0),n},h0=e=>q(u0(e)),wt={mode:"jab",channels:["j","a","b","alpha"],parse:["--jzazbz"],serialize:"--jzazbz",fromMode:{rgb:s0,xyz65:l0},toMode:{rgb:h0,xyz65:u0},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:l,a:l,b:l,alpha:{use:l,fixup:y}}},In=({j:e,a:n,b:t,alpha:i})=>{n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.sqrt(n*n+t*t),r={mode:"jch",j:e,c:a};return a&&(r.h=$(Math.atan2(t,n)*180/Math.PI)),i!==void 0&&(r.alpha=i),r},Cn=({j:e,c:n,h:t,alpha:i})=>{t===void 0&&(t=0);let a={mode:"jab",j:e,a:n?n*Math.cos(t/180*Math.PI):0,b:n?n*Math.sin(t/180*Math.PI):0};return i!==void 0&&(a.alpha=i),a},Tt={mode:"jch",parse:["--jzczhz"],serialize:"--jzczhz",toMode:{jab:Cn,rgb:e=>h0(Cn(e))},fromMode:{rgb:e=>In(s0(e)),jab:In},channels:["j","c","h","alpha"],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:l,fixup:N},c:l,j:l,alpha:{use:l,fixup:y}},difference:{h:be},average:{h:P}},ve=Math.pow(29,3)/Math.pow(3,3),ln=Math.pow(6,3)/Math.pow(29,3);let De=e=>Math.pow(e,3)>ln?Math.pow(e,3):(116*e-16)/ve;const un=({l:e,a:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=(e+16)/116,r=n/500+a,f=a-t/200,o={mode:"xyz50",x:De(r)*M.X,y:De(a)*M.Y,z:De(f)*M.Z};return i!==void 0&&(o.alpha=i),o},te=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Z({r:e*3.1341359569958707-n*1.6173863321612538-.4906619460083532*t,g:e*-.978795502912089+n*1.916254567259524+.03344273116131949*t,b:e*.07195537988411677-n*.2289768264158322+1.405386058324125*t});return i!==void 0&&(a.alpha=i),a},c0=e=>te(un(e)),ae=e=>{let{r:n,g:t,b:i,alpha:a}=D(e),r={mode:"xyz50",x:.436065742824811*n+.3851514688337912*t+.14307845442264197*i,y:.22249319175623702*n+.7168870538238823*t+.06061979053616537*i,z:.013923904500943465*n+.09708128566574634*t+.7140993584005155*i};return a!==void 0&&(r.alpha=a),r},Ze=e=>e>ln?Math.cbrt(e):(ve*e+16)/116,sn=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Ze(e/M.X),r=Ze(n/M.Y),f=Ze(t/M.Z),o={mode:"lab",l:116*r-16,a:500*(a-r),b:200*(r-f)};return i!==void 0&&(o.alpha=i),o},b0=e=>{let n=sn(ae(e));return e.r===e.b&&e.b===e.g&&(n.a=n.b=0),n};function Nt(e,n){if(!n||n[0]!=="lab")return;const t={mode:"lab"},[,i,a,r,f]=n;if(!(i.type===d.Hue||a.type===d.Hue||r.type===d.Hue))return i.type!==d.None&&(t.l=Math.min(Math.max(0,i.value),100)),a.type!==d.None&&(t.a=a.type===d.Number?a.value:a.value*125/100),r.type!==d.None&&(t.b=r.type===d.Number?r.value:r.value*125/100),f.type!==d.None&&(t.alpha=Math.min(1,Math.max(0,f.type===d.Number?f.value:f.value/100))),t}const hn={mode:"lab",toMode:{xyz50:un,rgb:c0},fromMode:{xyz50:sn,rgb:b0},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[Nt],serialize:e=>`lab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{l,a:l,b:l,alpha:{use:l,fixup:y}}},Pt={...hn,mode:"lab65",parse:["--lab-d65"],serialize:"--lab-d65",toMode:{xyz65:Vn,rgb:pe},fromMode:{xyz65:e0,rgb:me},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function Rt(e,n){if(!n||n[0]!=="lch")return;const t={mode:"lch"},[,i,a,r,f]=n;if(i.type!==d.None){if(i.type===d.Hue)return;t.l=Math.min(Math.max(0,i.value),100)}if(a.type!==d.None&&(t.c=Math.max(0,a.type===d.Number?a.value:a.value*150/100)),r.type!==d.None){if(r.type===d.Percentage)return;t.h=r.value}return f.type!==d.None&&(t.alpha=Math.min(1,Math.max(0,f.type===d.Number?f.value:f.value/100))),t}const cn={mode:"lch",toMode:{lab:C,rgb:e=>c0(C(e))},fromMode:{rgb:e=>I(b0(e)),lab:I},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[Rt],serialize:e=>`lch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:l,fixup:N},c:l,l,alpha:{use:l,fixup:y}},difference:{h:be},average:{h:P}},Ht={...cn,mode:"lch65",parse:["--lch-d65"],serialize:"--lch-d65",toMode:{lab65:e=>C(e,"lab65"),rgb:e=>pe(C(e,"lab65"))},fromMode:{rgb:e=>I(me(e),"lch65"),lab65:e=>I(e,"lch65")},ranges:{l:[0,100],c:[0,150],h:[0,360]}},p0=({l:e,u:n,v:t,alpha:i})=>{n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.sqrt(n*n+t*t),r={mode:"lchuv",l:e,c:a};return a&&(r.h=$(Math.atan2(t,n)*180/Math.PI)),i!==void 0&&(r.alpha=i),r},m0=({l:e,c:n,h:t,alpha:i})=>{t===void 0&&(t=0);let a={mode:"luv",l:e,u:n?n*Math.cos(t/180*Math.PI):0,v:n?n*Math.sin(t/180*Math.PI):0};return i!==void 0&&(a.alpha=i),a},g0=(e,n,t)=>4*e/(e+15*n+3*t),M0=(e,n,t)=>9*n/(e+15*n+3*t),It=g0(M.X,M.Y,M.Z),Ct=M0(M.X,M.Y,M.Z),St=e=>e<=ln?ve*e:116*Math.cbrt(e)-16,tn=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=St(n/M.Y),r=g0(e,n,t),f=M0(e,n,t);!isFinite(r)||!isFinite(f)?a=r=f=0:(r=13*a*(r-It),f=13*a*(f-Ct));let o={mode:"luv",l:a,u:r,v:f};return i!==void 0&&(o.alpha=i),o},At=(e,n,t)=>4*e/(e+15*n+3*t),Ot=(e,n,t)=>9*n/(e+15*n+3*t),Xt=At(M.X,M.Y,M.Z),Lt=Ot(M.X,M.Y,M.Z),an=({l:e,u:n,v:t,alpha:i})=>{if(e===void 0&&(e=0),e===0)return{mode:"xyz50",x:0,y:0,z:0};n===void 0&&(n=0),t===void 0&&(t=0);let a=n/(13*e)+Xt,r=t/(13*e)+Lt,f=M.Y*(e<=8?e/ve:Math.pow((e+16)/116,3)),o=f*(9*a)/(4*r),u=f*(12-3*a-20*r)/(4*r),s={mode:"xyz50",x:o,y:f,z:u};return i!==void 0&&(s.alpha=i),s},qt=e=>p0(tn(ae(e))),Et=e=>te(an(m0(e))),Ft={mode:"lchuv",toMode:{luv:m0,rgb:Et},fromMode:{rgb:qt,luv:p0},channels:["l","c","h","alpha"],parse:["--lchuv"],serialize:"--lchuv",ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:l,fixup:N},c:l,l,alpha:{use:l,fixup:y}},difference:{h:be},average:{h:P}},Yt={...j,mode:"lrgb",toMode:{rgb:Z},fromMode:{rgb:D},parse:["srgb-linear"],serialize:"srgb-linear"},jt={mode:"luv",toMode:{xyz50:an,rgb:e=>te(an(e))},fromMode:{xyz50:tn,rgb:e=>tn(ae(e))},channels:["l","u","v","alpha"],parse:["--luv"],serialize:"--luv",ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l,u:l,v:l,alpha:{use:l,fixup:y}}},x0=({r:e,g:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.cbrt(.412221469470763*e+.5363325372617348*n+.0514459932675022*t),r=Math.cbrt(.2119034958178252*e+.6806995506452344*n+.1073969535369406*t),f=Math.cbrt(.0883024591900564*e+.2817188391361215*n+.6299787016738222*t),o={mode:"oklab",l:.210454268309314*a+.7936177747023054*r-.0040720430116193*f,a:1.9779985324311684*a-2.42859224204858*r+.450593709617411*f,b:.0259040424655478*a+.7827717124575296*r-.8086757549230774*f};return i!==void 0&&(o.alpha=i),o},ke=e=>{let n=x0(D(e));return e.r===e.b&&e.b===e.g&&(n.a=n.b=0),n},ie=({l:e,a:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Math.pow(e+.3963377773761749*n+.2158037573099136*t,3),r=Math.pow(e-.1055613458156586*n-.0638541728258133*t,3),f=Math.pow(e-.0894841775298119*n-1.2914855480194092*t,3),o={mode:"lrgb",r:4.076741636075957*a-3.3077115392580616*r+.2309699031821044*f,g:-1.2684379732850317*a+2.6097573492876887*r-.3413193760026573*f,b:-.0041960761386756*a-.7034186179359362*r+1.7076146940746117*f};return i!==void 0&&(o.alpha=i),o},_e=e=>Z(ie(e));function rn(e){const i=1.170873786407767;return .5*(i*e-.206+Math.sqrt((i*e-.206)*(i*e-.206)+4*.03*i*e))}function he(e){return(e*e+.206*e)/(1.170873786407767*(e+.03))}function Dt(e,n){let t,i,a,r,f,o,u,s;-1.88170328*e-.80936493*n>1?(t=1.19086277,i=1.76576728,a=.59662641,r=.75515197,f=.56771245,o=4.0767416621,u=-3.3077115913,s=.2309699292):1.81444104*e-1.19445276*n>1?(t=.73956515,i=-.45954404,a=.08285427,r=.1254107,f=.14503204,o=-1.2684380046,u=2.6097574011,s=-.3413193965):(t=1.35733652,i=-.00915799,a=-1.1513021,r=-.50559606,f=.00692167,o=-.0041960863,u=-.7034186147,s=1.707614701);let c=t+i*e+a*n+r*e*e+f*e*n,b=.3963377774*e+.2158037573*n,m=-.1055613458*e-.0638541728*n,g=-.0894841775*e-1.291485548*n;{let x=1+c*b,_=1+c*m,v=1+c*g,w=x*x*x,z=_*_*_,R=v*v*v,J=3*b*x*x,B=3*m*_*_,U=3*g*v*v,G=6*b*b*x,W=6*m*m*_,K=6*g*g*v,E=o*w+u*z+s*R,S=o*J+u*B+s*U,Q=o*G+u*W+s*K;c=c-E*S/(S*S-.5*E*Q)}return c}function bn(e,n){let t=Dt(e,n),i=ie({l:1,a:t*e,b:t*n}),a=Math.cbrt(1/Math.max(i.r,i.g,i.b)),r=a*t;return[a,r]}function Zt(e,n,t,i,a,r=null){r||(r=bn(e,n));let f;if((t-a)*r[1]-(r[0]-a)*i<=0)f=r[1]*a/(i*r[0]+r[1]*(a-t));else{f=r[1]*(a-1)/(i*(r[0]-1)+r[1]*(a-t));{let o=t-a,u=i,s=.3963377774*e+.2158037573*n,c=-.1055613458*e-.0638541728*n,b=-.0894841775*e-1.291485548*n,m=o+u*s,g=o+u*c,x=o+u*b;{let _=a*(1-f)+f*t,v=f*i,w=_+v*s,z=_+v*c,R=_+v*b,J=w*w*w,B=z*z*z,U=R*R*R,G=3*m*w*w,W=3*g*z*z,K=3*x*R*R,E=6*m*m*w,S=6*g*g*z,Q=6*x*x*R,mn=4.0767416621*J-3.3077115913*B+.2309699292*U-1,$e=4.0767416621*G-3.3077115913*W+.2309699292*K,$0=4.0767416621*E-3.3077115913*S+.2309699292*Q,gn=$e/($e*$e-.5*mn*$0),ze=-mn*gn,Mn=-1.2684380046*J+2.6097574011*B-.3413193965*U-1,we=-1.2684380046*G+2.6097574011*W-.3413193965*K,z0=-1.2684380046*E+2.6097574011*S-.3413193965*Q,xn=we/(we*we-.5*Mn*z0),Te=-Mn*xn,yn=-.0041960863*J-.7034186147*B+1.707614701*U-1,Ne=-.0041960863*G-.7034186147*W+1.707614701*K,w0=-.0041960863*E-.7034186147*S+1.707614701*Q,vn=Ne/(Ne*Ne-.5*yn*w0),Pe=-yn*vn;ze=gn>=0?ze:1e6,Te=xn>=0?Te:1e6,Pe=vn>=0?Pe:1e6,f+=Math.min(ze,Math.min(Te,Pe))}}}return f}function pn(e,n,t=null){t||(t=bn(e,n));let i=t[0],a=t[1];return[a/i,a/(1-i)]}function y0(e,n,t){let i=bn(n,t),a=Zt(n,t,e,1,e,i),r=pn(n,t,i),f=.11516993+1/(7.4477897+4.1590124*t+n*(-2.19557347+1.75198401*t+n*(-2.13704948-10.02301043*t+n*(-4.24894561+5.38770819*t+4.69891013*n)))),o=.11239642+1/(1.6132032-.68124379*t+n*(.40370612+.90148123*t+n*(-.27087943+.6122399*t+n*(.00299215-.45399568*t-.14661872*n)))),u=a/Math.min(e*r[0],(1-e)*r[1]),s=e*f,c=(1-e)*o,b=.9*u*Math.sqrt(Math.sqrt(1/(1/(s*s*s*s)+1/(c*c*c*c))));return s=e*.4,c=(1-e)*.8,[Math.sqrt(1/(1/(s*s)+1/(c*c))),b,a]}function Sn(e){const n=e.l!==void 0?e.l:0,t=e.a!==void 0?e.a:0,i=e.b!==void 0?e.b:0,a={mode:"okhsl",l:rn(n)};e.alpha!==void 0&&(a.alpha=e.alpha);let r=Math.sqrt(t*t+i*i);if(!r)return a.s=0,a;let[f,o,u]=y0(n,t/r,i/r),s;if(r<o){let c=0,b=.8*f,m=1-b/o;s=(r-c)/(b+m*(r-c))*.8}else{let c=o,b=.2*o*o*1.25*1.25/f,m=1-b/(u-o);s=.8+.2*((r-c)/(b+m*(r-c)))}return s&&(a.s=s,a.h=$(Math.atan2(i,t)*180/Math.PI)),a}function An(e){let n=e.h!==void 0?e.h:0,t=e.s!==void 0?e.s:0,i=e.l!==void 0?e.l:0;const a={mode:"oklab",l:he(i)};if(e.alpha!==void 0&&(a.alpha=e.alpha),!t||i===1)return a.a=a.b=0,a;let r=Math.cos(n/180*Math.PI),f=Math.sin(n/180*Math.PI),[o,u,s]=y0(a.l,r,f),c,b,m,g;t<.8?(c=1.25*t,b=0,m=.8*o,g=1-m/u):(c=5*(t-.8),b=u,m=.2*u*u*1.25*1.25/o,g=1-m/(s-u));let x=b+c*m/(1-g*c);return a.a=x*r,a.b=x*f,a}const Jt={...a0,mode:"okhsl",channels:["h","s","l","alpha"],parse:["--okhsl"],serialize:"--okhsl",fromMode:{oklab:Sn,rgb:e=>Sn(ke(e))},toMode:{oklab:An,rgb:e=>_e(An(e))}};function On(e){let n=e.l!==void 0?e.l:0,t=e.a!==void 0?e.a:0,i=e.b!==void 0?e.b:0,a=Math.sqrt(t*t+i*i),r=a?t/a:1,f=a?i/a:1,[o,u]=pn(r,f),s=.5,c=1-s/o,b=u/(a+n*u),m=b*n,g=b*a,x=he(m),_=g*x/m,v=ie({l:x,a:r*_,b:f*_}),w=Math.cbrt(1/Math.max(v.r,v.g,v.b,0));n=n/w,a=a/w*rn(n)/n,n=rn(n);const z={mode:"okhsv",s:a?(s+u)*g/(u*s+u*c*g):0,v:n?n/m:0};return z.s&&(z.h=$(Math.atan2(i,t)*180/Math.PI)),e.alpha!==void 0&&(z.alpha=e.alpha),z}function Xn(e){const n={mode:"oklab"};e.alpha!==void 0&&(n.alpha=e.alpha);const t=e.h!==void 0?e.h:0,i=e.s!==void 0?e.s:0,a=e.v!==void 0?e.v:0,r=Math.cos(t/180*Math.PI),f=Math.sin(t/180*Math.PI),[o,u]=pn(r,f),s=.5,c=1-s/o,b=1-i*s/(s+u-u*c*i),m=i*u*s/(s+u-u*c*i),g=he(b),x=m*g/b,_=ie({l:g,a:r*x,b:f*x}),v=Math.cbrt(1/Math.max(_.r,_.g,_.b,0)),w=he(a*b),z=m*w/b;return n.l=w*v,n.a=z*r*v,n.b=z*f*v,n}const Bt={...f0,mode:"okhsv",channels:["h","s","v","alpha"],parse:["--okhsv"],serialize:"--okhsv",fromMode:{oklab:On,rgb:e=>On(ke(e))},toMode:{oklab:Xn,rgb:e=>_e(Xn(e))}};function Ut(e,n){if(!n||n[0]!=="oklab")return;const t={mode:"oklab"},[,i,a,r,f]=n;if(!(i.type===d.Hue||a.type===d.Hue||r.type===d.Hue))return i.type!==d.None&&(t.l=Math.min(Math.max(0,i.type===d.Number?i.value:i.value/100),1)),a.type!==d.None&&(t.a=a.type===d.Number?a.value:a.value*.4/100),r.type!==d.None&&(t.b=r.type===d.Number?r.value:r.value*.4/100),f.type!==d.None&&(t.alpha=Math.min(1,Math.max(0,f.type===d.Number?f.value:f.value/100))),t}const Gt={...hn,mode:"oklab",toMode:{lrgb:ie,rgb:_e},fromMode:{lrgb:x0,rgb:ke},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[Ut],serialize:e=>`oklab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`};function Wt(e,n){if(!n||n[0]!=="oklch")return;const t={mode:"oklch"},[,i,a,r,f]=n;if(i.type!==d.None){if(i.type===d.Hue)return;t.l=Math.min(Math.max(0,i.type===d.Number?i.value:i.value/100),1)}if(a.type!==d.None&&(t.c=Math.max(0,a.type===d.Number?a.value:a.value*.4/100)),r.type!==d.None){if(r.type===d.Percentage)return;t.h=r.value}return f.type!==d.None&&(t.alpha=Math.min(1,Math.max(0,f.type===d.Number?f.value:f.value/100))),t}const Kt={...cn,mode:"oklch",toMode:{oklab:e=>C(e,"oklab"),rgb:e=>_e(C(e,"oklab"))},fromMode:{rgb:e=>I(ke(e),"oklch"),oklab:e=>I(e,"oklch")},parse:[Wt],serialize:e=>`oklch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},Ln=e=>{let{r:n,g:t,b:i,alpha:a}=D(e),r={mode:"xyz65",x:.486570948648216*n+.265667693169093*t+.1982172852343625*i,y:.2289745640697487*n+.6917385218365062*t+.079286914093745*i,z:0*n+.0451133818589026*t+1.043944368900976*i};return a!==void 0&&(r.alpha=a),r},qn=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a=Z({r:e*2.4934969119414263-n*.9313836179191242-.402710784450717*t,g:e*-.8294889695615749+n*1.7626640603183465+.0236246858419436*t,b:e*.0358458302437845-n*.0761723892680418+.9568845240076871*t},"p3");return i!==void 0&&(a.alpha=i),a},Qt={...j,mode:"p3",parse:["display-p3"],serialize:"display-p3",fromMode:{rgb:e=>qn(L(e)),xyz65:qn},toMode:{rgb:e=>q(Ln(e)),xyz65:Ln}},Je=e=>{let n=Math.abs(e);return n>=1/512?Math.sign(e)*Math.pow(n,1/1.8):16*e},En=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a={mode:"prophoto",r:Je(e*1.3457868816471585-n*.2555720873797946-.0511018649755453*t),g:Je(e*-.5446307051249019+n*1.5082477428451466+.0205274474364214*t),b:Je(e*0+n*0+1.2119675456389452*t)};return i!==void 0&&(a.alpha=i),a},Be=(e=0)=>{let n=Math.abs(e);return n>=16/512?Math.sign(e)*Math.pow(n,1.8):e/16},Fn=e=>{let n=Be(e.r),t=Be(e.g),i=Be(e.b),a={mode:"xyz50",x:.7977666449006423*n+.1351812974005331*t+.0313477341283922*i,y:.2880748288194013*n+.7118352342418731*t+899369387256e-16*i,z:0*n+0*t+.8251046025104602*i};return e.alpha!==void 0&&(a.alpha=e.alpha),a},Vt={...j,mode:"prophoto",parse:["prophoto-rgb"],serialize:"prophoto-rgb",fromMode:{xyz50:En,rgb:e=>En(ae(e))},toMode:{xyz50:Fn,rgb:e=>te(Fn(e))}},Yn=1.09929682680944,ea=.018053968510807,Ue=e=>{const n=Math.abs(e);return n>ea?(Math.sign(e)||1)*(Yn*Math.pow(n,.45)-(Yn-1)):4.5*e},jn=({x:e,y:n,z:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);let a={mode:"rec2020",r:Ue(e*1.7166511879712683-n*.3556707837763925-.2533662813736599*t),g:Ue(e*-.6666843518324893+n*1.6164812366349395+.0157685458139111*t),b:Ue(e*.0176398574453108-n*.0427706132578085+.9421031212354739*t)};return i!==void 0&&(a.alpha=i),a},Dn=1.09929682680944,na=.018053968510807,Ge=(e=0)=>{let n=Math.abs(e);return n<na*4.5?e/4.5:(Math.sign(e)||1)*Math.pow((n+Dn-1)/Dn,1/.45)},Zn=e=>{let n=Ge(e.r),t=Ge(e.g),i=Ge(e.b),a={mode:"xyz65",x:.6369580483012911*n+.1446169035862083*t+.1688809751641721*i,y:.262700212011267*n+.6779980715188708*t+.059301716469862*i,z:0*n+.0280726930490874*t+1.0609850577107909*i};return e.alpha!==void 0&&(a.alpha=e.alpha),a},ta={...j,mode:"rec2020",fromMode:{xyz65:jn,rgb:e=>jn(L(e))},toMode:{xyz65:Zn,rgb:e=>q(Zn(e))},parse:["rec2020"],serialize:"rec2020"},X=.0037930732552754493,v0=Math.cbrt(X),We=e=>Math.cbrt(e)-v0,aa=e=>{const{r:n,g:t,b:i,alpha:a}=D(e),r=We(.3*n+.622*t+.078*i+X),f=We(.23*n+.692*t+.078*i+X),o=We(.2434226892454782*n+.2047674442449682*t+.5518098665095535*i+X),u={mode:"xyb",x:(r-f)/2,y:(r+f)/2,b:o-(r+f)/2};return a!==void 0&&(u.alpha=a),u},Ke=e=>Math.pow(e+v0,3),ia=({x:e,y:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);const a=Ke(e+n)-X,r=Ke(n-e)-X,f=Ke(t+n)-X,o=Z({r:11.031566904639861*a-9.866943908131562*r-.16462299650829934*f,g:-3.2541473810744237*a+4.418770377582723*r-.16462299650829934*f,b:-3.6588512867136815*a+2.7129230459360922*r+1.9459282407775895*f});return i!==void 0&&(o.alpha=i),o},ra={mode:"xyb",channels:["x","y","b","alpha"],parse:["--xyb"],serialize:"--xyb",toMode:{rgb:ia},fromMode:{rgb:aa},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:l,y:l,b:l,alpha:{use:l,fixup:y}}},fa={mode:"xyz50",parse:["xyz-d50"],serialize:"xyz-d50",toMode:{rgb:te,lab:sn},fromMode:{rgb:ae,lab:un},channels:["x","y","z","alpha"],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:l,y:l,z:l,alpha:{use:l,fixup:y}}},oa=e=>{let{x:n,y:t,z:i,alpha:a}=e;n===void 0&&(n=0),t===void 0&&(t=0),i===void 0&&(i=0);let r={mode:"xyz50",x:1.0479298208405488*n+.0229467933410191*t-.0501922295431356*i,y:.0296278156881593*n+.990434484573249*t-.0170738250293851*i,z:-.0092430581525912*n+.0150551448965779*t+.7518742899580008*i};return a!==void 0&&(r.alpha=a),r},da=e=>{let{x:n,y:t,z:i,alpha:a}=e;n===void 0&&(n=0),t===void 0&&(t=0),i===void 0&&(i=0);let r={mode:"xyz65",x:.9554734527042182*n-.0230985368742614*t+.0632593086610217*i,y:-.0283697069632081*n+1.0099954580058226*t+.021041398966943*i,z:.0123140016883199*n-.0205076964334779*t+1.3303659366080753*i};return a!==void 0&&(r.alpha=a),r},la={mode:"xyz65",toMode:{rgb:q,xyz50:oa},fromMode:{rgb:L,xyz50:da},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:["x","y","z","alpha"],parse:["xyz","xyz-d65"],serialize:"xyz-d65",interpolate:{x:l,y:l,z:l,alpha:{use:l,fixup:y}}},ua=({r:e,g:n,b:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);const a={mode:"yiq",y:.29889531*e+.58662247*n+.11448223*t,i:.59597799*e-.2741761*n-.32180189*t,q:.21147017*e-.52261711*n+.31114694*t};return i!==void 0&&(a.alpha=i),a},sa=({y:e,i:n,q:t,alpha:i})=>{e===void 0&&(e=0),n===void 0&&(n=0),t===void 0&&(t=0);const a={mode:"rgb",r:e+.95608445*n+.6208885*t,g:e-.27137664*n-.6486059*t,b:e-1.10561724*n+1.70250126*t};return i!==void 0&&(a.alpha=i),a},ha={mode:"yiq",toMode:{rgb:sa},fromMode:{rgb:ua},channels:["y","i","q","alpha"],parse:["--yiq"],serialize:"--yiq",ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:l,i:l,q:l,alpha:{use:l,fixup:y}}};p(V0);p(ft);p(ot);p(dt);p(st);p(a0);p(f0);p(vt);p(kt);p(wt);p(Tt);p(hn);p(Pt);p(cn);p(Ht);p(Ft);p(Yt);p(jt);p(Jt);p(Bt);p(Gt);p(Kt);p(Qt);p(Vt);p(ta);p(j);p(ra);p(fa);p(la);p(ha);const k0=Bn("rgb");function _0(e){const n=dn(e);if(!n)return null;const t=k0(n);return!t||t.alpha!==void 0&&t.alpha!==1||!A(t.r)||!A(t.g)||!A(t.b)?null:{r:O(t.r)*255,g:O(t.g)*255,b:O(t.b)*255}}function ca(e){const n=dn(e);if(!n)return null;const t=k0(n);if(!t||!A(t.r)||!A(t.g)||!A(t.b))return null;const i=t.alpha??1;return A(i)?{r:O(t.r)*255,g:O(t.g)*255,b:O(t.b)*255,alpha:O(i)}:null}function ba({r:e,g:n,b:t}){const i=e/255,a=n/255,r=t/255,f=Math.max(i,a,r),o=Math.min(i,a,r),u=f-o;let s=0;const c=(f+o)/2,b=u===0?0:u/(1-Math.abs(2*c-1));if(u!==0){switch(f){case i:s=(a-r)/u%6;break;case a:s=(r-i)/u+2;break;case r:s=(i-a)/u+4;break}s*=60,s<0&&(s+=360)}return{h:Math.round(s),s:Number((b*100).toFixed(1)),l:Number((c*100).toFixed(1))}}function pa(e){const{h:n,s:t,l:i}=ba(e);return`${n} ${t}% ${i}%`}function ma(e){const n=_0(e);return n?pa(n):null}function A(e){return typeof e=="number"&&Number.isFinite(e)}function O(e){return Math.min(1,Math.max(0,e))}exports.APPEARANCE_FONT_PRESETS=P0;exports.SEMAPHOR_DEFAULT_FONT_FAMILY=fn;exports.SEMAPHOR_HEADING_FONT_FAMILY=T0;exports.SEMAPHOR_MONO_FONT_FAMILY=N0;exports.compileColorToHslTriplet=ma;exports.parseAppearanceColor=_0;exports.parseRuntimeColor=ca;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("./validators-
|
|
1
|
+
"use strict";require("./validators-BDYprKI9.cjs");const e="SEMAPHOR_CALCULATED_FIELD";function u(Y){return(Y==null?void 0:Y.sourceField)||(Y==null?void 0:Y.name)||""}const s=["MM-DD-YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","MMMM DD, YYYY","MMM DD, YYYY","DD MMM YYYY","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm Z","YYYY-MM-DD HH:mm:ss Z","Week of MMM DD, YYYY","Week of MMMM DD, YYYY","YYYY-WW","MMM YYYY","MMMM YYYY","YYYY-MM","MM/YYYY","YYYY MMM","Q1 YYYY","YYYY Q1","1st Quarter YYYY","YYYY-Q1","Quarter 1, YYYY","YYYY","YY","custom"];function D(Y){return Y.role==="metric"&&"expression"in Y&&!!Y.expression}function r(Y){return!!Y.expression}function _(Y){return!!Y.expression}function l(Y){var t,n;const M=Y;return!!(M!=null&&M.expression&&((n=(t=M.calculatedFormula)==null?void 0:t.inputFields)!=null&&n.length))}function o(Y){return!!(Y&&(Y.entityName===e||Y.entityId===e))}var a=(Y=>(Y.SUBTOTAL="__SUBTOTAL__",Y.TOTAL="__TOTAL__",Y.ALL="__ALL__",Y))(a||{});const c={database:null,schema:null,table:null},A="__card_default__";exports.CALCULATED_FIELD_ENTITY_MARKER=e;exports.CONTROL_CARD_DEFAULT_VALUE=A;exports.DATE_FORMAT_VALUES=s;exports.EMPTY_SELECTION=c;exports.PivotMarkerEnum=a;exports.getFieldRuntimeColumnName=u;exports.hasCalculatedFieldMarker=o;exports.hasCalculatedFormulaInputs=l;exports.isCalculatedDimension=r;exports.isCalculatedField=_;exports.isCalculatedMetric=D;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const A=["lg","md","sm","xs","xxs"];exports.DASHBOARD_AUTHORING_BREAKPOINTS=A;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=15;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),x=require("react"),s=require("./index-CLB_NGZ8.cjs"),n=require("./switch-D-CCcfhc.cjs"),je=require("./layout-grid-xm8pqtx0.cjs"),K=require("./x-B6ghREd2.cjs"),V=require("./editor-action-buttons-18r2xwei.cjs"),ye=require("./saved-temporal-bucket-format-CFfWXRl9.cjs");require("./validators-BDYprKI9.cjs");require("./analyze-result-contract-LPDNldic.cjs");require("../value-format-preferences/index.cjs");const Ue=require("./search-BqqhaMx9.cjs"),Oe=require("./mouse-pointer-2-DX4A_XZw.cjs"),we=require("./pivot-header-presentation-DhyQXxKq.cjs");require("./index-ByFbacH7.cjs");require("./temporal-bucket-authoring-o3Emn05L.cjs");require("./canonical-result-keys-BA0HCP4e.cjs");require("./color-CyB5o13F.cjs");require("react-dom");const X=require("./index-Bn5wlkHt.cjs");/**
|
|
2
|
+
* @license lucide-react v0.453.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ze=K.createLucideIcon("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
|
|
7
|
+
* @license lucide-react v0.453.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const _e=K.createLucideIcon("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/**
|
|
12
|
+
* @license lucide-react v0.453.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const $e=K.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
17
|
+
* @license lucide-react v0.453.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Ne=K.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
|
|
22
|
+
* @license lucide-react v0.453.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const qe=K.createLucideIcon("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);function He(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((t,r)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},r))})}function We({open:t,onOpenChange:r,onSubmit:l,isCreating:o}){const[a,d]=x.useState(""),[h,p]=x.useState("");x.useEffect(()=>{t||(d(""),p(""))},[t]);const c=()=>{a.trim()&&l({title:a,description:h})},u=i=>{r(i)};return e.jsx(s.Dialog,{open:t,onOpenChange:u,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(je.LayoutGrid,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"New library visual"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Visual"})]})]}),e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>u(!1),"aria-label":"Close",disabled:o,children:e.jsx(K.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-3 px-4 py-3",children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Create a saved visual that can be reused across dashboards."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(n.Label,{htmlFor:"visual-title",className:"text-[12px]",children:"Name"}),e.jsx(n.Input,{id:"visual-title",size:"sm",placeholder:"Untitled visual",value:a,onChange:i=>d(i.target.value),disabled:o,onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),c())}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(n.Label,{htmlFor:"visual-description",className:"text-[12px]",children:"Description"}),e.jsx(n.Input,{id:"visual-description",size:"sm",placeholder:"Optional",value:h,onChange:i=>p(i.target.value),disabled:o})]})]}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5",children:[e.jsx(n.Button,{size:"xs",variant:"outline",onClick:()=>u(!1),disabled:o,children:"Cancel"}),e.jsx(n.Button,{size:"xs",onClick:c,disabled:!a.trim()||o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating..."]}):"Create library visual"})]})]})})}function Ee(t){return t?new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Unknown"}function Ae(t,r){var o;const l=(o=t.ownership.createdBy)==null?void 0:o.type;return l==="tenant"||l==="organization"&&r}function Ce(t,r){var l,o;return Ae(t,r)?((l=t.ownership.createdBy)==null?void 0:l.name)||((o=t.createdByTenantUserRel)==null?void 0:o.name)||t.lastModifiedBy||"Unknown":"Organization"}function Ge(t,r){return Ce(t,r).split(/\s+/).filter(Boolean).slice(0,2).map(o=>o.charAt(0).toUpperCase()).join("")||"?"}function Xe(t){const r=(t||"").toLowerCase();return r.includes("table")?n.Table2:r.includes("pie")||r.includes("donut")?s.ChartPie:r.includes("line")?s.ChartLine:r.includes("bar")?n.ChartColumn:je.LayoutGrid}function Ke({visual:t}){const r=t.ownership.status==="public"?"Public":t.ownership.status==="shared"||t.ownership.sharedCount>0?"Shared":"Private";return e.jsx("span",{className:"inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground",children:r})}function Qe({open:t,onOpenChange:r}){const[l,o]=x.useState(""),[a,d]=x.useState(new Set),[h,p]=x.useState(!1),[c,u]=x.useState(null),[i,g]=x.useState(null),[m,f]=x.useState(!1),[w,y]=x.useState(null),[E,B]=x.useState(null),D=()=>{d(new Set),u(null),g(null),f(!1),y(null)},b=()=>{r(!1),D()},{selectVisual:S}=s.useManagementActions(),{handleAddLibraryVisual:A,handleEditLibraryVisual:T}=V.useVisualUtils(),{isConsoleMode:v}=s.useDashboardPreferences(),{resources:j,isLoading:L,isError:I,createResource:$,updateResource:k,deleteResourceAsync:M,duplicateResource:_,isCreating:oe,isDeleting:q}=s.useVisualManagement(void 0,C=>{p(!1),C&&(S(C),T(C),b())}),{startUpdating:fe,stopUpdating:ie,isUpdating:ge}=s.useResourceUpdateState(),W=j,U=x.useMemo(()=>{const C=l.trim().toLowerCase();return C?W.filter(F=>{var R,Y,J;return((R=F.title)==null?void 0:R.toLowerCase().includes(C))||((Y=F.description)==null?void 0:Y.toLowerCase().includes(C))||((J=F.kind)==null?void 0:J.toLowerCase().includes(C))}):W},[l,W]),Q=x.useMemo(()=>W.filter(C=>a.has(C.id)),[a,W]),ee=Q.filter(C=>C.permissions.canDelete),te=Q.filter(C=>C.permissions.canShare),le=U.length>0&&U.every(C=>a.has(C.id)),ue=U.some(C=>a.has(C.id)),se=C=>{const F=new Set(a);C(F),d(F)},ne=C=>{se(F=>{F.has(C)?F.delete(C):F.add(C)})},G=()=>{d(C=>{const F=new Set(C);return le?U.forEach(R=>F.delete(R.id)):U.forEach(R=>F.add(R.id)),F})},ce=async C=>{(await A(C)).success&&b()},O=async()=>{const C=Q;if(C.length===0)return;let F=!1;for(const R of C)if(!(await A(R)).success){F=!0;break}F||b()},z=C=>{T(C),b()},Z=C=>{B(C),_(C,{onSettled:()=>B(null)})},ae=()=>{if(ee.length===0){s.ue.error("Select a visual you can delete");return}y(null),f(!0)},he=async()=>{const C=w?[w]:ee;try{for(const F of C)await M(F.id);d(F=>{const R=new Set(F);return C.forEach(Y=>R.delete(Y.id)),R}),f(!1),y(null)}catch{}},be=()=>{if(Q.length!==1){s.ue.error("Select one visual to share");return}const[C]=Q;if(!C.permissions.canShare){s.ue.error("You do not have permission to share this visual");return}u(C)},de=({title:C,description:F})=>{if(!i)return;const R={};if(C!==i.title&&(R.title=C),(i.description||"")!==F&&(R.description=F),Object.keys(R).length===0){g(null);return}const Y=Object.keys(R),J=Y.length===1?Y[0]:void 0;fe(i.id,J),k({resourceId:i.id,data:R},{onSuccess:()=>{ie(i.id,J),g(null)},onError:()=>{ie(i.id,J)}})},re=C=>{r(C),C||D()},H=w?1:ee.length;return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:re,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(n.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"Visuals library"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Add to dashboard"})]})]}),e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>re(!1),"aria-label":"Close visuals library",children:"×"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"relative min-w-[12rem] flex-1 md:max-w-md",children:[e.jsx(Ue.Search,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:l,onChange:C=>o(C.target.value),placeholder:"Search visuals...",className:"h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none","aria-label":"Search visuals"})]}),e.jsxs(n.Button,{size:"xs",variant:"outline",className:"ml-auto",onClick:()=>p(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"New library visual"]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:L?e.jsx("div",{className:"p-3",children:e.jsx(He,{})}):I?e.jsx("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:e.jsx("p",{className:"text-[13px] text-destructive",children:"Failed to load visuals"})}):U.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:[e.jsx(je.LayoutGrid,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("p",{className:"text-[13px] font-medium",children:l?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:l?"Try a different search.":"Create a saved visual to add it here."})]}):e.jsx(Ye,{visuals:U,selectedIds:a,allFilteredSelected:le,someFilteredSelected:ue,onSelectAll:G,onToggleSelection:ne,onAddVisual:ce,onOpenVisual:z,onEditDetails:g,onShareVisual:u,onDeleteVisual:C=>{y(C),f(!0)},onDuplicateVisual:Z,duplicatingId:E,isDeleting:q,isConsoleMode:v})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:a.size>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[e.jsx("span",{className:"font-medium tabular-nums text-foreground",children:a.size})," ","selected"]}),e.jsx(n.Button,{size:"xs",variant:"ghost",onClick:()=>d(new Set),children:"Clear"}),e.jsxs(n.Button,{size:"xs",variant:"outline",onClick:be,disabled:Q.length!==1||te.length!==1,children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsxs(n.Button,{size:"xs",variant:"outline",className:"text-destructive hover:text-destructive",onClick:ae,disabled:ee.length===0,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),"Delete ",ee.length||a.size]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n.Button,{size:"xs",variant:"outline",onClick:()=>re(!1),children:"Close"}),e.jsxs(n.Button,{size:"xs",onClick:O,disabled:a.size===0,children:[e.jsx(n.Check,{className:"h-3.5 w-3.5"}),a.size===0?"Add to dashboard":`Add ${a.size} visual${a.size===1?"":"s"}`]})]})]})]})}),e.jsx(We,{open:h,onOpenChange:p,onSubmit:$,isCreating:oe}),c&&e.jsx(s.ShareDialog,{resource:c,resourceType:s.ResourceType.VISUAL,onClose:()=>u(null)}),i&&e.jsx(s.ResourceEditDialog,{open:!!i,resourceLabel:"Visual",initialTitle:i.title||"",initialDescription:i.description||"",onClose:()=>g(null),onSave:de,isSaving:ge(i.id)}),e.jsx(s.AlertDialog,{open:m,onOpenChange:C=>{!C&&q||(f(C),C||y(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs(s.AlertDialogTitle,{children:["Delete ",H," visual",H===1?"":"s","?"]}),e.jsx(s.AlertDialogDescription,{children:"This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately."})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:q,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:C=>{C.preventDefault(),he()},disabled:q||H===0,children:[q?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),q?"Deleting...":"Delete"]})]})]})})]})}function Ye({visuals:t,selectedIds:r,allFilteredSelected:l,someFilteredSelected:o,onSelectAll:a,onToggleSelection:d,onAddVisual:h,onOpenVisual:p,onEditDetails:c,onShareVisual:u,onDeleteVisual:i,onDuplicateVisual:g,duplicatingId:m,isDeleting:f,isConsoleMode:w}){return e.jsxs("div",{className:"min-w-[48rem]",children:[e.jsxs("div",{className:"grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[e.jsx(s.Checkbox,{checked:l?!0:o?"indeterminate":!1,onCheckedChange:a,"aria-label":"Select all visuals"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Created by"}),e.jsx("span",{children:"Updated"}),e.jsx("span",{children:"Visibility"}),e.jsx("span",{className:"text-right",children:"Shared"}),e.jsx("span",{className:"text-right",children:"Actions"})]}),t.map(y=>e.jsx(Ze,{visual:y,selected:r.has(y.id),onToggleSelection:d,onAddVisual:h,onOpenVisual:p,onEditDetails:c,onShareVisual:u,onDeleteVisual:i,onDuplicateVisual:g,duplicatingId:m,isDeleting:f,isConsoleMode:w},y.id))]})}function Ze({visual:t,selected:r,onToggleSelection:l,onAddVisual:o,onOpenVisual:a,onEditDetails:d,onShareVisual:h,onDeleteVisual:p,onDuplicateVisual:c,duplicatingId:u,isDeleting:i,isConsoleMode:g}){var w;const m=Xe(t.kind),f=()=>{o(t)};return e.jsxs("div",{className:n.cn("group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",r&&"bg-muted/70"),children:[e.jsx("div",{children:e.jsx(s.Checkbox,{checked:r,onCheckedChange:()=>l(t.id),"aria-label":`Select ${t.title||"visual"}`})}),e.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:f,"aria-label":`Add ${t.title||"visual"} to dashboard`,children:[e.jsx(m,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-foreground",title:t.title||"Untitled Visual",children:t.title||"Untitled Visual"}),((w=t.description)==null?void 0:w.trim())&&e.jsx("div",{className:"truncate text-[11px] text-muted-foreground",title:t.description,children:t.description})]})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground",children:Ge(t,g)}),e.jsx("span",{className:"truncate text-muted-foreground",children:Ce(t,g)})]}),e.jsx("span",{className:"text-muted-foreground",children:Ee(t.updatedAt)}),e.jsx(Ke,{visual:t}),e.jsx("span",{className:"text-right tabular-nums text-muted-foreground",children:t.ownership.sharedCount>0?t.ownership.sharedCount:"—"}),e.jsx(Je,{visual:t,onOpenVisual:a,onEditDetails:d,onShareVisual:h,onDeleteVisual:p,onDuplicateVisual:c,duplicatingId:u,isDeleting:i,isConsoleMode:g})]})}function Je({visual:t,onOpenVisual:r,onEditDetails:l,onShareVisual:o,onDeleteVisual:a,onDuplicateVisual:d,duplicatingId:h,isDeleting:p,isConsoleMode:c}){return e.jsxs("div",{className:"flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",onClick:u=>u.stopPropagation(),children:[e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0",onClick:()=>r(t),"aria-label":"Edit visual",children:e.jsx(s.PenLine,{className:"h-3.5 w-3.5"})}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0","aria-label":"More actions",children:e.jsx(s.Ellipsis,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",children:[e.jsxs(s.DropdownMenuItem,{onClick:()=>r(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>d(t.id),disabled:h===t.id,children:[h===t.id?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),h===t.id?"Duplicating...":"Duplicate"]}),t.permissions.canEdit&&e.jsxs(s.DropdownMenuItem,{onClick:()=>l(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit details"]}),t.permissions.canShare&&e.jsxs(s.DropdownMenuItem,{onClick:()=>o(t),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),t.permissions.canDelete&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>a(t),disabled:p,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),p?"Deleting...":"Delete"]})]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[Ae(t,c)&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Ce(t,c)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:Ee(t.updatedAt)})]})]})]})]})]})}function et({open:t,onOpenChange:r,isLibraryVisual:l,currentVisualName:o,isSaving:a=!1,destinationMode:d="both",onConfirm:h}){const[p,c]=x.useState(l&&o?`Copy of ${o}`:o||""),[u,i]=x.useState("");x.useEffect(()=>{t&&(c(l&&o?`Copy of ${o}`:o||""),i(""))},[t,l,o]);const g=!!p.trim(),m=d==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:d==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},f=()=>{!g||a||h({name:p.trim(),description:u.trim()||void 0,saveToLibrary:m.saveToLibrary,saveToCurrentDashboard:m.saveToCurrentDashboard})};return e.jsx(s.Dialog,{open:t,onOpenChange:r,children:e.jsxs(s.DialogContent,{className:"sm:max-w-[500px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx("span",{children:"Save Visual As"}),m.badgeType!=="local"&&e.jsx(V.VisualBadge,{type:m.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),e.jsx(s.DialogDescription,{children:m.description})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"name",children:"Name"}),e.jsx(n.Input,{id:"name",value:p,onChange:w=>c(w.target.value),placeholder:"Enter visual name",disabled:a})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Textarea,{id:"description",value:u,onChange:w=>i(w.target.value),placeholder:"Enter visual description",rows:3,disabled:a})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(n.Button,{variant:"outline",onClick:()=>r(!1),disabled:a,children:"Cancel"}),e.jsxs(n.Button,{onClick:f,disabled:!g||a,children:[a&&e.jsx(n.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),m.actionLabel]})]})]})})}function tt(){const[t,r]=x.useState(!1),[l,o]=x.useState(!1),[a,d]=x.useState(null),[h,p]=x.useState(null),c=n.useEditorStore(v=>v.frame),u=n.useEditorStore(v=>v.card),i=s.useSelectedVisual(),g=n.useDashboardStore(v=>v.selectedSheetId),m=n.useDashboardStore(v=>v.dashboard),{getUpdatedFrame:f}=V.useVisualUtils(),{selectVisual:w}=s.useManagementActions(),{addFrame:y,setSelectedFrameId:E,setIsVisualEditing:B}=n.useDashboardActions(),D=s.useResolveExistingFrameSemanticExecutionPayload(),b=!!(c!=null&&c.visualId),S=(()=>{var v,j;return((v=c==null?void 0:c.cards)==null?void 0:v.length)===1&&((j=c.cards[0])!=null&&j.title)?c.cards[0].title:i!=null&&i.title?i.title:(u==null?void 0:u.title)||"Untitled Visual"})(),A=s.useCreateVisualWithFrame(v=>{v!=null&&v.id&&(w(v),l&&a&&h&&g&&(async()=>{try{const j={...a,id:ye.v4(),visualId:v.id};y(g,j,{position:"end",semanticExecutionPayload:h}),E(j.id),o(!1),d(null),p(null),B(!1)}catch(j){console.error("Failed to promote semantic metadata for saved visual:",j),s.ue.error(j instanceof Error?j.message:"Failed to prepare semantic metadata for the saved visual")}})(),r(!1))});return{saveAsDialogOpen:t,setSaveAsDialogOpen:r,handleSaveAs:async v=>{if(!g){s.ue.error("No sheet selected");return}const j=f(),L=n.getDynamicFrameSaveIssue(j);if(L){s.ue.error(L);return}const $=j.cards.length===1?{...j,cards:j.cards.map(k=>({...k,title:v.name}))}:j;if(v.saveToLibrary){let k=null;if(v.saveToCurrentDashboard)try{k=await D($,{previousFrame:n.findDashboardFrameById(m,$.id)})}catch(_){console.error("Failed to prepare semantic metadata before saving visual:",_),s.ue.error(_ instanceof Error?_.message:"Failed to prepare semantic metadata for the saved visual");return}o(v.saveToCurrentDashboard),d($),p(k);const M={title:v.name,description:v.description,frameObject:$,isPrivate:!1};A.mutate(M)}else if(v.saveToCurrentDashboard){const k={...$,id:ye.v4(),visualId:void 0};try{const M=await D($,{previousFrame:n.findDashboardFrameById(m,$.id)});y(g,k,{position:"end",semanticExecutionPayload:M}),E(k.id),s.ue.success("Visual saved to dashboard"),r(!1),B(!1)}catch(M){console.error("Failed to save visual to dashboard:",M),s.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:b,currentVisualName:S,isSaving:A.isPending}}function st(t={}){const{isInspectionMode:r}=s.useDashboardInteractionMode(),l=n.useEditorStore(k=>k.frame),o=n.useEditorStore(k=>k.editorContext),a=s.useManagementStore(k=>k.selectedVisual),d=n.useDashboardStore(k=>k.selectedFrameId),h=n.useDashboardStore(k=>k.selectedSheetId),p=n.useDashboardStore(k=>k.dashboard),{setIsVisualEditing:c,updateFrame:u}=n.useDashboardActions(),[i,g]=x.useState(!1),[m,f]=x.useState("both"),w=s.useResolveExistingFrameSemanticExecutionPayload(),y=(o==null?void 0:o.type)==="documentSection",E=!!(l!=null&&l.visualId||a!=null&&a.id),B=!!(l!=null&&l.visualId&&d),D=E&&!B,{saveAsDialogOpen:b,setSaveAsDialogOpen:S,handleSaveAs:A,isLibraryVisual:T,currentVisualName:v,isSaving:j}=tt(),{getUpdatedFrame:L}=V.useVisualUtils();if(r)return e.jsxs(e.Fragment,{children:[e.jsx(V.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(V.EditorCancelButton,{})]});if(y)return e.jsxs(e.Fragment,{children:[e.jsx(V.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(V.EditorCancelButton,{})]});const I=async()=>{if(!h){s.ue.error("No sheet selected");return}if(i)return;g(!0);const k=L(),M=n.getDynamicFrameSaveIssue(k);if(M){g(!1),s.ue.error(M);return}const _={...k,visualId:void 0},oe=n.findDashboardFrameById(p,_.id);try{const q=await w(_,{previousFrame:oe});u(h,_,{semanticExecutionPayload:q})}catch(q){console.error("Failed to apply local semantic metadata:",q),g(!1),s.ue.error(q instanceof Error?q.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{g(!1),s.ue.success("Changes applied. Visual is now local to this dashboard"),c(!1)},300)},$=k=>{f(k),S(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-control",children:[!E&&e.jsx(V.EditorAcceptButton,{className:"!rounded-none",variant:"default"}),E&&D&&e.jsx(V.VisualSaveButton,{className:"!rounded-none",variant:"default"}),E&&B&&e.jsx(V.VisualSaveAndApplyButton,{className:"!rounded-none"}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(n.Button,{variant:"default",size:"xs",className:"w-7 !rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:j||i,children:e.jsx(K.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",children:[B&&e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenuItem,{onClick:I,disabled:i,children:[e.jsx(n.Check,{className:"h-3.5 w-3.5"}),i?"Applying...":"Apply Locally"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("local"),disabled:j,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("library"),disabled:j,children:[e.jsx(V.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("both"),disabled:j,children:[e.jsx(V.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),e.jsx(V.EditorCancelButton,{}),e.jsx(et,{open:b,onOpenChange:k=>{j||S(k)},isLibraryVisual:T,currentVisualName:v,isSaving:j,destinationMode:m,onConfirm:A})]})}function rt({className:t}){const r=n.useEditorStore(u=>u.isDevMode),l=n.useDashboardStore(u=>u.isVisualEditing),{setIsDevMode:o}=n.useEditorActions(),{config:a}=x.useContext(s.SemaphorContext).tokenProps,d=(a==null?void 0:a.showAdvancedMode)!==!1;if(!l||!d)return null;const h=r?Oe.MousePointer2:s.CodeXml,p=r?"Visual editor":"SQL editor",c=r?"Switch to visual editor":"Switch to SQL editor";return e.jsxs("button",{type:"button","aria-label":c,title:c,onClick:()=>o(!r),className:n.cn("inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",t),children:[e.jsx(h,{className:"h-3 w-3 text-muted-foreground"}),p]})}function nt({open:t,onOpenChange:r,onSave:l,onDiscard:o,isSaving:a,title:d="Unsaved changes",description:h="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:p="Cancel",discardLabel:c="Discard",saveLabel:u="Save"}){const i=g=>{!g&&a||r(g)};return e.jsx(s.AlertDialog,{open:t,onOpenChange:i,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:d}),e.jsx(s.AlertDialogDescription,{children:h})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(n.Button,{type:"button",size:"xs",onClick:o,disabled:a,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:c}),e.jsx(s.AlertDialogCancel,{disabled:a,children:p}),e.jsx(n.Button,{type:"button",size:"xs",onClick:l,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(n.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):u})]})]})})}const at=1e4,ot=15e3,it=3e4,lt=3e4,ct=12e4,De=2*60*60*1e3;function dt(t){const r=Date.now()-t.getTime();return r<lt?at:r<ct?ot:it}function ut(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),l=s.useExportStore(m=>m.activeExports),[o,a]=x.useState(typeof document<"u"?!document.hidden:!0),d=x.useRef(null),h=x.useRef(!1),p=x.useRef(void 0),c=r==null?void 0:r.apiServiceUrl,u=t==null?void 0:t.accessToken,i=x.useCallback(()=>{const m=s.useExportStore.getState().activeExports;return Array.from(m.values()).filter(f=>s.isExportInProgress(f.status))},[]);x.useEffect(()=>{if(typeof document>"u")return;const m=()=>{a(!document.hidden)};return document.addEventListener("visibilitychange",m),()=>{document.removeEventListener("visibilitychange",m)}},[]);const g=x.useCallback(async()=>{if(!c||!u){h.current=!1;return}const m=i();if(m.length===0){h.current=!1;return}const f=Date.now(),w=m.filter(b=>f-b.startedAt.getTime()>De);if(w.length>0){const{updateExport:b}=s.useExportStore.getState().actions;for(const S of w)b(S.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const y=m.filter(b=>f-b.startedAt.getTime()<=De);if(y.length===0){h.current=!1;return}const E=await Promise.allSettled(y.map(async b=>{try{const S=await s.getExportStatus(c,u,b.id);let A;if(S.status==="completed")try{A=await s.getDownloadUrl(c,u,b.id)}catch(T){console.error(`[useExportPolling] Failed to get download URL for ${b.id}:`,T)}return{id:b.id,status:S.status,progress:S.progress,completedChunks:S.completedChunks,completedAt:S.completedAt?new Date(S.completedAt):void 0,lastUpdatedAt:new Date,fileSize:S.fileSize,error:S.error,downloadUrl:A}}catch(S){return console.error(`[useExportPolling] Failed to poll export ${b.id}:`,S),null}})),{updateExport:B}=s.useExportStore.getState().actions;for(const b of E)b.status==="fulfilled"&&b.value&&B(b.value.id,b.value);const D=i();if(D.length>0&&!document.hidden){const b=D.reduce((A,T)=>T.startedAt<A?T.startedAt:A,D[0].startedAt),S=dt(b);d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var A;(A=p.current)==null||A.call(p)},S)}else h.current=!1},[c,u,i]);return x.useEffect(()=>{p.current=g},[g]),x.useEffect(()=>{var f;i().length>0&&o&&!h.current&&(h.current=!0,(f=p.current)==null||f.call(p))},[l,o,i]),x.useEffect(()=>{var f;const m=i();o&&m.length>0&&!h.current&&(h.current=!0,(f=p.current)==null||f.call(p))},[o,i]),x.useEffect(()=>{!o&&d.current&&(clearTimeout(d.current),d.current=null,h.current=!1)},[o]),x.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),{isPolling:h.current,isTabVisible:o,inProgressCount:i().length}}function ht(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),l=s.useExportStore(p=>p.activeExports),{addExport:o}=s.useExportActions(),a=x.useRef(!1),d=r==null?void 0:r.apiServiceUrl,h=t==null?void 0:t.accessToken;x.useEffect(()=>{if(a.current||!d||!h)return;(async()=>{try{const{exports:c}=await s.getExports(d,h,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const u of c){if(l.has(u.id))continue;const i=u.totalChunks?Math.round(u.completedChunks/u.totalChunks*100):0;let g;if(u.status==="completed")try{g=await s.getDownloadUrl(d,h,u.id)}catch(f){console.error(`[useExportRecovery] Failed to get download URL for ${u.id}:`,f)}const m={id:u.id,status:u.status,progress:i,title:mt(u),totalRows:u.totalRows,totalChunks:u.totalChunks,completedChunks:u.completedChunks,startedAt:new Date(u.createdAt),lastUpdatedAt:new Date,completedAt:u.completedAt?new Date(u.completedAt):void 0,fileSize:u.fileSize,error:u.error,expiresAt:new Date(u.expiresAt),downloadUrl:g};o(m)}a.current=!0}catch(c){console.error("[useExportRecovery] Failed to recover exports:",c),a.current=!0}})()},[d,h,o,l])}function mt(t){return t.title?t.title:s.isExportInProgress(t.status)?"Export in progress...":t.status==="completed"?"Export completed":t.status==="failed"?"Export failed":"Export"}function ke({export:t,onRemove:r}){const l=()=>{t.downloadUrl&&window.open(t.downloadUrl,"_blank")},o=p=>{p.stopPropagation(),r==null||r(t.id)},a=()=>{switch(t.status){case"completed":return e.jsx(s.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx($e,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(n.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},d=s.isExportInProgress(t.status),h=(()=>{switch(t.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[a(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:t.title}),t.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[t.totalRows.toLocaleString()," rows"]}),t.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:s.formatFileSize(t.fileSize)})]})]}),d&&e.jsx("div",{className:"text-xs text-muted-foreground",children:h}),t.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:t.error||"Export failed"})]})]}),e.jsx(n.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:o,"aria-label":"Remove notification",children:e.jsx(K.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[t.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:we.formatDistanceToNow(t.startedAt,{addSuffix:!0})}),t.downloadUrl&&e.jsxs(n.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:l,children:[e.jsx(s.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),d&&e.jsxs("div",{children:[e.jsx(s.Progress,{value:t.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[t.progress,"% complete"]})]}),t.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:we.formatDistanceToNow(t.startedAt,{addSuffix:!0})})]})]})}function Be(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),l=s.useExportStore(y=>y.activeExports),{clearCompleted:o,removeExport:a,updateExport:d}=s.useExportActions(),[h,p]=x.useState(!1),[c,u]=x.useState(!1),i=Array.from(l.values()).sort((y,E)=>E.startedAt.getTime()-y.startedAt.getTime()),g=i.some(y=>y.status==="completed"||y.status==="failed"),m=x.useCallback(async()=>{const y=r==null?void 0:r.apiServiceUrl,E=t==null?void 0:t.accessToken;if(!(!y||!E)){p(!0);try{const B=Array.from(l.values());await Promise.all(B.map(async D=>{try{const b=await s.getExportStatus(y,E,D.id);let S;if(b.status==="completed")try{S=await s.getDownloadUrl(y,E,D.id)}catch(A){console.error(`Failed to get download URL for ${D.id}:`,A)}d(D.id,{status:b.status,progress:b.progress,completedChunks:b.completedChunks,completedAt:b.completedAt?new Date(b.completedAt):void 0,lastUpdatedAt:new Date,fileSize:b.fileSize,error:b.error,downloadUrl:S})}catch(b){console.error(`Failed to refresh export ${D.id}:`,b)}}))}finally{p(!1)}}},[l,t==null?void 0:t.accessToken,r==null?void 0:r.apiServiceUrl,d]),f=x.useCallback(async()=>{const y=r==null?void 0:r.apiServiceUrl,E=t==null?void 0:t.accessToken;if(!y||!E){o();return}u(!0);try{const B=i.filter(b=>b.status==="completed"||b.status==="failed"),D=await Promise.allSettled(B.map(async b=>(await s.cancelExport(y,E,b.id),b.id)));for(const b of D)b.status==="fulfilled"?a(b.value):console.error("Failed to delete export:",b.reason)}finally{u(!1)}},[i,r==null?void 0:r.apiServiceUrl,t==null?void 0:t.accessToken,o,a]),w=x.useCallback(async y=>{const E=r==null?void 0:r.apiServiceUrl,B=t==null?void 0:t.accessToken;if(E&&B)try{await s.cancelExport(E,B,y),a(y);return}catch(D){console.error(`Failed to cancel export ${y}:`,D)}a(y)},[r==null?void 0:r.apiServiceUrl,t==null?void 0:t.accessToken,a]);return i.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(Ne,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(n.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:m,disabled:h,title:"Refresh status",children:e.jsx(s.RefreshCw,{className:`h-4 w-4 ${h?"animate-spin":""}`})}),g&&e.jsx(n.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:f,disabled:c,children:c?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:i.map(y=>e.jsx(ke,{export:y,onRemove:w},y.id))})})]})}function xt({variant:t}){const r=s.useExportStore(c=>c.activeExports),l=s.useInProgressExportsCount(),o=r.size>0,a=Array.from(r.values()).some(c=>c.status==="completed"||c.status==="failed"),h=l>0?l>9?"9+":String(l):null,p=o;return e.jsxs(n.Popover,{children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:t??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[e.jsx(s.Bell,{className:"h-3.5 w-3.5"}),p&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${h?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:h})]})}),e.jsx(n.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(Be,{})})]})}function pt(t){if(t)return{renamed:t.type==="rename"?{oldId:t.oldId,newId:t.newId}:void 0,removedControlId:t.type==="remove"?t.controlId:void 0,cardBindingsById:t.type==="add"||t.type==="update"?t.cardBindingsById:void 0,affectedBindingControlIds:t.type==="add"||t.type==="update"?t.affectedBindingControlIds:void 0}}function Ie({open:t,onOpenChange:r,trigger:l,showTrigger:o=!0,initialMode:a="manage"}){const d=a==="create",{forceClose:h,handleOpenChange:p,isCreateFlowActive:c,preventPassiveDismissDuringCreate:u,resolvedOpen:i,setIsCreateFlowActive:g}=V.useCreateFlowOverlayState({open:t,onOpenChange:r,initialCreateFlowActive:a==="create",dismissMode:o?"passive":"explicit-only"}),m=n.useDashboardStore(j=>j.dashboard),{setDashboardControlsModel:f}=n.useDashboardActions(),{participants:w}=s.useDashboardStructuralParticipants(n.getDashboardCards(m)),y=Array.from(new Map(w.flatMap(j=>j.fieldChoices.map(L=>{var I;return[L.value,{option:L,target:(I=j.fieldTargetMap)==null?void 0:I[L.value]}]}))).values()),E=Array.from(new Map(w.flatMap(j=>j.metricChoices.map(L=>{var I;return[L.value,{option:L,target:(I=j.metricTargetMap)==null?void 0:I[L.value]}]}))).values()),B=n.collectDashboardControlIds({...m||{},controls:[]}),D=s.buildDashboardStructuralParticipantIdsByControlId(m),b=(j,L,I)=>{f(j,L,pt(I))},S=x.useCallback(()=>{if(d){h();return}g(!1)},[d,h,g]),A=e.jsx(V.ControlDefinitionListEditor,{scope:"dashboard",controls:m.controls||[],reservedControlIds:B,defaultValues:m.defaultControlValues||{},usageByControlId:s.buildDashboardControlUsageById(m),availableFieldChoices:y,availableMetricChoices:E,structuralParticipants:w,structuralParticipantIdsByControlId:D,initialCreateFlow:a==="create",onCreateFlowActiveChange:g,onCreateFlowComplete:S,onChange:b,emptyMessage:"No dashboard controls yet."}),T=c?"Add dashboard control":"Dashboard Controls",v=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),A]});return o?e.jsxs(n.Popover,{open:i,onOpenChange:p,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:l||e.jsxs(n.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[e.jsx(n.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),e.jsx(n.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:u,onPointerDownOutside:u,children:v})]}):e.jsx(s.Dialog,{open:i,onOpenChange:p,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:u,onPointerDownOutside:u,children:[e.jsxs(s.DialogHeader,{className:c?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:T}),e.jsx(s.DialogDescription,{className:c?"sr-only":"text-[13px]",children:c?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:A})]})})}const ft=["enum","multi_enum","text","number","boolean","date"];function Fe({open:t,onOpenChange:r,initialMode:l="manage"}){var v;const o=l==="create",{forceClose:a,handleOpenChange:d,isCreateFlowActive:h,preventPassiveDismissDuringCreate:p,resolvedOpen:c,setIsCreateFlowActive:u}=V.useCreateFlowOverlayState({open:t,onOpenChange:r,initialCreateFlowActive:l==="create",dismissMode:"explicit-only"}),i=n.useDashboardStore(j=>j.dashboard),g=n.useDashboardStore(j=>j.selectedSheetId),{setDashboardInputs:m}=n.useDashboardActions(),f=(v=i.sheets)==null?void 0:v.find(j=>j.id===g),w=(f==null?void 0:f.kind)==="document"&&!!f.document,y=x.useMemo(()=>w&&(f!=null&&f.document)?s.getDocumentSheetDashboardInputs(i,f.id):[],[i,w,f==null?void 0:f.document,f==null?void 0:f.id]),E=x.useMemo(()=>y.filter(j=>j.kind==="control"),[y]),B=x.useMemo(()=>E.map(j=>j.control),[E]),D=x.useMemo(()=>bt(B),[B]),b=x.useMemo(()=>gt(i),[i]),S=x.useCallback(()=>{if(o){a();return}u(!1)},[o,a,u]),A=x.useCallback((j,L,I)=>{!w||!(f!=null&&f.document)||m(jt({allInputs:i.inputs||[],documentSheetId:f.id,currentDocumentInputs:y,nextControls:j,nextDefaultValues:L,change:I}))},[i.inputs,y,w,f,m]);if(!w||!(f!=null&&f.document))return null;const T=h?"Add document control":"Document Controls";return e.jsx(s.Dialog,{open:c,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:p,onPointerDownOutside:p,children:[e.jsxs(s.DialogHeader,{className:h?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:T}),e.jsx(s.DialogDescription,{className:h?"sr-only":"text-[13px]",children:h?"Configure and add a document-local control input.":"Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:e.jsx(V.ControlDefinitionListEditor,{scope:"dashboard",controls:B,reservedControlIds:b,defaultValues:D,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:ft,initialCreateFlow:l==="create",onCreateFlowActiveChange:u,onCreateFlowComplete:S,onChange:A,emptyMessage:"No document controls yet."})})]})})}function gt(t){return(t.controls||[]).map(r=>r.id)}function bt(t){const r={};for(const l of t)l.defaultValue!==void 0&&(r[l.id]=l.defaultValue);return r}function vt(t,r){return r?Object.prototype.hasOwnProperty.call(r,t.id)?{...t,defaultValue:r[t.id]}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}}function jt({allInputs:t,documentSheetId:r,currentDocumentInputs:l,nextControls:o,nextDefaultValues:a,change:d}){const h=new Map(o.map(m=>[m.id,vt(m,a)])),p=(d==null?void 0:d.type)==="rename"?{oldId:d.oldId,newId:d.newId}:null,c=new Set,u=[];for(const m of l){if(m.kind!=="control"){u.push(m);continue}const f=h.get(m.control.id)||((p==null?void 0:p.oldId)===m.control.id?h.get(p.newId):void 0);if(!f)continue;c.add(f.id);const w=s.createUniqueDashboardInputVariableNameFromName(f.id,[...t,...u].filter(E=>E.id!==m.id)),y=f.id===w?f:{...f,id:w};u.push({...m,label:y.label,variableName:w,requiredAtExecution:y.requiredAtExecution,control:y})}for(const m of h.values())c.has(m.id)||u.push(s.createDashboardControlInputFromControl({control:m,existingInputs:[...t,...u],sheetId:r}));const i=new Set(l.map(m=>m.id));return[...t.filter(m=>!i.has(m.id)),...u]}function Le({showFilters:t,onShowFiltersChange:r,pickerContent:l,settingsContent:o,size:a="default",className:d,primaryButtonClassName:h,secondaryButtonClassName:p,pickerContentClassName:c,settingsContentClassName:u}){const i=a==="toolbar",[g,m]=x.useState(!1),f=s.useSurfaceAppearance("interactive");return e.jsxs("div",{className:n.cn("relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",i?"h-8":"h-7",d),children:[e.jsxs(n.Popover,{open:t,onOpenChange:r,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"ghost",size:"xs",className:n.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",h),children:[t?e.jsx(V.FilterX,{className:"h-3.5 w-3.5"}):e.jsx(s.Filter,{className:"h-3.5 w-3.5"}),"Filter"]})}),e.jsx(n.PopoverContent,{align:"end",sideOffset:6,className:n.cn("w-auto rounded-card border border-border/60 p-0 shadow-sm",c),style:f.contentStyle,children:l})]}),e.jsxs(n.Popover,{open:g,onOpenChange:m,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsx(n.Button,{variant:"ghost",size:"xs",className:n.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",p),"aria-label":"Filter and control actions",children:e.jsx(K.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(n.PopoverContent,{align:"end",sideOffset:6,className:n.cn("w-auto rounded-card border border-border/60 p-0 shadow-sm",u),style:f.contentStyle,children:o(()=>m(!1))})]})]})}function Ct(){V.useSyncLegacyEditorState();const t=n.useDashboardStore(c=>c.selectedSheetId),r=n.useDashboardStore(c=>c.selectedFrameId),l=n.useDashboardStore(c=>c.dashboard),o=n.useDashboardStore(c=>c.actions.getSelectedFrame),{setSelectedFrameId:a}=n.useDashboardActions(),{setCard:d}=n.useEditorActions(),h=n.useEditorStore(c=>c.card.dataSource);return x.useEffect(()=>{var u,i;let c=o();if(!c){const g=(u=l==null?void 0:l.sheets)==null?void 0:u.find(f=>f.id===t),m=(i=g==null?void 0:g.frames)==null?void 0:i[0];m&&(a(m.id),c=m)}if(c){const g=c.cards.find(m=>m.id===c.activeCardId);g&&d(g)}},[o,t,r,l,a,d]),{hasEntities:!!(h!=null&&h.selectedEntities&&h.selectedEntities.length>0)}}function yt(){const t=n.useDashboardStore(c=>c.dashboard),r=n.useDashboardStore(c=>c.semanticExecutionPayload),l=n.useDashboardStore(c=>c.actions.addFilter),{hasEntities:o}=Ct(),{isLoading:a}=s.useFilterableFields(),d=x.useMemo(()=>n.getGlobalDateFilterCoverage(t,r),[t,r]),p=!n.getGlobalDateFilter(t.filters)&&d.hasEligibleCards&&!a;return e.jsxs("div",{className:"flex h-[520px] w-[400px] flex-col",children:[p&&e.jsx("div",{className:"border-b border-border/60 p-2",children:e.jsxs("button",{type:"button",onClick:()=>l(n.createDefaultGlobalDateFilter()),title:`Applies to ${d.eligibleCardCount} of ${d.totalCardCount} date-aware cards`,className:"flex w-full items-start gap-2 rounded-[4px] px-2 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border",children:[e.jsx(_e,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"text-[12px] font-medium text-foreground",children:"Add global date filter"}),e.jsx("span",{className:"text-[11px] leading-[1.4] text-muted-foreground",children:"One date range across all date-aware cards."})]})]})}),!o&&e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-8 text-center",children:[e.jsx(s.Database,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("h3",{className:"mb-1 text-[13px] font-medium text-foreground",children:"No fields configured"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Configure a data source for this card to enable filtering."})]}),o&&e.jsx("div",{className:"flex flex-1 overflow-hidden",children:e.jsx(s.FilterableFieldsPanel,{context:"filter"})})]})}const Se=!1;function wt({onAddFilter:t,onAddControl:r,onManageControls:l,onDismiss:o}){const a=n.useDashboardStore(p=>p.dashboard.filterLayout),{setFilterLayout:d}=n.useDashboardActions();a!=null&&a.displayMode;const h=(a==null?void 0:a.toolbarWrap)??!1;return a==null||a.showDownloadButton,e.jsxs("div",{className:"w-[300px]",children:[e.jsxs("div",{className:"p-1",children:[e.jsx(ve,{icon:s.Filter,label:"Add filter",onClick:()=>{t(),o()}}),e.jsx(ve,{icon:n.SlidersHorizontal,label:"Add control",onClick:()=>{r(),o()}}),e.jsx(ve,{icon:s.Pencil,label:"Manage controls",onClick:()=>{l(),o()}})]}),e.jsx("div",{className:"border-t border-border/60"}),e.jsxs("div",{className:"space-y-1 p-2",children:[e.jsx("p",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display"}),Se,e.jsx(Nt,{id:"filter-display-wrap",label:"Wrap to multiple lines",checked:h,onCheckedChange:p=>d({toolbarWrap:p===!0})}),Se]})]})}function ve({icon:t,label:r,onClick:l}){return e.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted/40",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-muted-foreground"}),r]})}function Nt({id:t,label:r,checked:l,onCheckedChange:o}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-[4px] px-1 py-1 transition-colors hover:bg-muted/40",children:[e.jsx(s.Checkbox,{id:t,checked:l,onCheckedChange:o}),e.jsx(n.Label,{htmlFor:t,className:"cursor-pointer text-[12px] font-normal leading-[1.3]",children:r})]})}function Dt({size:t,className:r,primaryButtonClassName:l,secondaryButtonClassName:o,pickerContentClassName:a,settingsContentClassName:d}){var T;const[h,p]=x.useState(null),c=n.useDashboardStore(v=>v.dashboard),u=n.useDashboardStore(v=>v.selectedSheetId),i=n.useDashboardStore(v=>v.showFilters),g=s.useAssistantLayoutStore(v=>v.setPanelOpen),m=n.useDashboardStore(v=>v.actions),{setDocumentInspectorTab:f,setShowFilters:w}=m,y=(T=c.sheets)==null?void 0:T.find(v=>v.id===u),E=n.isDocumentSheet(y),B=x.useCallback(v=>{window.setTimeout(()=>{p(v)},0)},[]),D=x.useCallback(v=>{if(E&&u){v&&f(u,"inputs");return}v&&g("dashboard",!1),w(v)},[E,u,f,g,w]),b=x.useCallback(()=>{D(!0)},[D]),S=x.useCallback(()=>{B("create")},[B]),A=x.useCallback(()=>{B("manage")},[B]);return e.jsxs(e.Fragment,{children:[e.jsx(Le,{showFilters:E?!1:i,onShowFiltersChange:D,pickerContent:e.jsx(yt,{}),settingsContent:v=>e.jsx(wt,{onAddFilter:b,onAddControl:S,onManageControls:A,onDismiss:v}),size:t,className:r,primaryButtonClassName:l,secondaryButtonClassName:o,pickerContentClassName:a,settingsContentClassName:d}),h?E?e.jsx(Fe,{open:!0,onOpenChange:v=>{v||p(null)},initialMode:h}):e.jsx(Ie,{open:!0,onOpenChange:v=>{v||p(null)},showTrigger:!1,initialMode:h}):null]})}function Te({disabled:t,briefingCount:r,className:l,onClick:o}){const a=typeof r=="number"&&r>0;return e.jsxs(n.Button,{type:"button",size:"xs",variant:"outline",disabled:t,className:n.cn("gap-1.5",l),onClick:o,"aria-label":"Reports & briefings",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),"Reports & briefings",a?e.jsx("span",{className:"ml-0.5 rounded-control bg-muted px-1 text-[10px] tabular-nums text-foreground/70",children:r}):null]})}const St="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Me="inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50",pe="inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-3 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50";function Et(t){return t==="dashboard"?"This dashboard":"Project"}function At(t){if(!t)return"Never";const r=new Date(t);if(Number.isNaN(r.getTime()))return"Unknown";const l=Date.now()-r.getTime(),o=Math.round(l/6e4);if(o<1)return"now";if(o<60)return`${o}m ago`;const a=Math.round(o/60);if(a<24)return`${a}h ago`;const d=Math.round(a/24);if(d<7)return`${d}d ago`;const h=Math.round(d/7);return h<5?`${h}w ago`:`${Math.round(d/30)}mo ago`}function kt(t){return t.scheduleExpr?X.describeBriefingSchedule(t.scheduleExpr,t.timezone||"UTC")??"Invalid schedule":"On demand"}function Bt(t){if(t.lastRunStatus){const r=t.lastRunStatus.toString().toUpperCase();return r==="SUCCESS"?"Last run completed.":r==="FAILED"?"Last run failed.":`Last run ${t.lastRunStatus.toString().toLowerCase()}`}return null}function Pe(t){return t.hasActiveRun?"Running":t.lastRunStatus?`Last run ${t.lastRunStatus.toString().toLowerCase()}`:"Idle"}function It(t){return t.source.type==="dashboard"?"This dashboard":"Project"}function Ft({activeView:t,onChange:r}){return e.jsx("div",{className:"flex shrink-0 items-center gap-1 rounded-control bg-muted p-0.5",role:"tablist","aria-label":"Briefing source view",children:["dashboard","project"].map(l=>{const o=t===l;return e.jsx("button",{type:"button",role:"tab","aria-selected":o,onClick:()=>r(l),className:n.cn("h-6 rounded-[3px] px-2 text-[11px] transition-colors",o?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:Et(l)},l)})})}function Lt({briefings:t,dashboardLabel:r,sourceView:l,error:o,loading:a,onSourceViewChange:d,onClose:h,onEdit:p,onNew:c,canCreate:u,canCreateScheduledReport:i,analyticalBriefingsEnabled:g,onRunNow:m,onTogglePause:f,onDelete:w,selectingId:y,busyId:E,manageBriefingsHref:B,contentKind:D,hideHeader:b=!1}){const S=t.length,A=t.filter(I=>I.status==="ACTIVE").length,T=D==="reports"?S===1?"report":"reports":D==="briefings"?S===1?"briefing":"briefings":S===1?"item":"items",v=t.find(I=>I.hasActiveRun)??null,j=D??"reports & briefings",L=l==="dashboard"?r:`Project ${j}`;return e.jsxs("section",{"aria-label":`Dashboard ${j.replace("&","and")}`,className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[b?null:e.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-border px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:St,children:j}),e.jsx("h2",{className:"mt-0.5 truncate text-[14px] font-semibold leading-5",children:L})]}),e.jsx("button",{type:"button",onClick:h,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":`Close ${j.replace("&","and")} panel`,children:e.jsx(K.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Ft,{activeView:l,onChange:d}),e.jsx("div",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:a&&S===0?e.jsxs("span",{children:["Loading ",j,"…"]}):S===0?e.jsxs("span",{children:["No ",j," yet"]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"font-medium text-foreground/80",children:[S," ",T]}),e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{children:[A," active"]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[a?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}):null,S>0&&u?g&&i?e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("button",{className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," New"]})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:()=>c("scheduled_report"),children:"Schedule a report"}),e.jsx(s.DropdownMenuItem,{onClick:()=>c("analytical_briefing"),children:"Create analytical briefing"})]})]}):i?e.jsxs("button",{onClick:()=>c("scheduled_report"),className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," Schedule report"]}):g?e.jsxs("button",{onClick:()=>c("analytical_briefing"),className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," New briefing"]}):null:null]})]}),v?e.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2 text-[12px]",children:[e.jsx(n.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),e.jsx("span",{className:"font-medium text-foreground",children:v.name}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:Pe(v)})]}):null,e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o?e.jsx("div",{className:"m-4 rounded-card border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] text-destructive",children:o}):null,!a&&t.length===0&&!o?e.jsx(Tt,{onNew:c,canCreate:u,canCreateScheduledReport:i,analyticalBriefingsEnabled:g,contentKind:D}):null,t.map(I=>e.jsx(Pt,{briefing:I,isOpening:y===I.id,isBusy:E===I.id,onOpen:()=>p(I.id),onRunNow:()=>m(I),onTogglePause:()=>f(I),onDelete:()=>w(I)},I.id))]}),B?e.jsx("div",{className:"border-t border-border px-4 py-2.5",children:e.jsxs("a",{href:B,className:n.cn(Me,"h-6 px-1 text-[11px]"),children:["Manage all reports & briefings",e.jsx(ze,{className:"h-3 w-3"})]})}):null]})}function Tt({onNew:t,canCreate:r,canCreateScheduledReport:l,analyticalBriefingsEnabled:o,contentKind:a}){const d=a==="reports"?{title:"No reports yet",description:"Schedule an emailed dashboard or visual report to see it here."}:a==="briefings"?{title:"No briefings yet",description:"Create an analytical briefing to monitor this dashboard and brief your team."}:null;return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-8 py-12 text-center",children:[e.jsx(Mt,{className:"mb-5 h-[88px] w-[112px] text-border"}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:(d==null?void 0:d.title)??"Have an analyst brief your team"}),e.jsx("p",{className:"mt-1.5 max-w-[320px] text-[12px] leading-5 text-muted-foreground",children:(d==null?void 0:d.description)??"Describe what to watch. An analyst digs into this dashboard and the data behind it, then briefs your team on the cadence you choose."}),r?e.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[l?e.jsxs("button",{onClick:()=>t("scheduled_report"),className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," Schedule a report"]}):null,o?e.jsx("button",{onClick:()=>t("analytical_briefing"),className:Me,children:"Create analytical briefing"}):null]}):null]})}function Mt({className:t}){return e.jsxs("svg",{viewBox:"0 0 112 88",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"presentation","aria-hidden":"true",className:t,children:[e.jsx("rect",{x:"22",y:"6",width:"60",height:"72",rx:"3",stroke:"currentColor",strokeWidth:"1.25"}),e.jsx("line",{x1:"30",y1:"16",x2:"64",y2:"16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("line",{x1:"30",y1:"21",x2:"52",y2:"21",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",opacity:"0.5"}),e.jsx("circle",{cx:"31",cy:"32",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"32",x2:"72",y2:"32",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"31",cy:"38",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"38",x2:"68",y2:"38",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"31",cy:"44",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"44",x2:"74",y2:"44",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("rect",{x:"30",y:"64",width:"5",height:"8",rx:"0.5",fill:"currentColor",opacity:"0.55"}),e.jsx("rect",{x:"38",y:"60",width:"5",height:"12",rx:"0.5",fill:"currentColor",opacity:"0.7"}),e.jsx("rect",{x:"46",y:"56",width:"5",height:"16",rx:"0.5",fill:"currentColor",opacity:"0.85"}),e.jsx("rect",{x:"54",y:"62",width:"5",height:"10",rx:"0.5",fill:"currentColor",opacity:"0.6"}),e.jsx("rect",{x:"62",y:"58",width:"5",height:"14",rx:"0.5",fill:"currentColor",opacity:"0.75"}),e.jsx("circle",{cx:"86",cy:"62",r:"10",fill:"var(--background, white)",stroke:"currentColor",strokeWidth:"1.25"}),e.jsx("line",{x1:"93.5",y1:"69.5",x2:"100",y2:"76",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Pt({briefing:t,isOpening:r,isBusy:l,onOpen:o,onRunNow:a,onTogglePause:d,onDelete:h}){const p=t.status==="PAUSED",c=t.hasActiveRun,u=Bt(t),i=At(t.lastRunAt),g=t.lastRunStatus,m=X.getBriefingPresentation(t),f=g==="SUCCESS"?s.briefingTone.success.dot:g==="FAILED"?s.briefingTone.danger.dot:g?s.briefingTone.warning.dot:s.briefingTone.neutral.dot;return e.jsxs("div",{className:n.cn("group relative border-b border-border/60 px-4 py-3 transition-colors hover:bg-muted/60",p&&"opacity-70"),children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:o,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),o())},className:"cursor-pointer pr-8",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),p?e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:"· Paused"}):null]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:m.typeLabel}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{children:It(t)}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx(s.Clock,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:kt(t)}),t.lastRunAt?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{children:["Last run ",i]})]}):null]}),u||c?e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 text-[12px] leading-[1.5] text-foreground/80",children:[c?e.jsx(n.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground/70"}):e.jsx("span",{className:n.cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full",f)}),e.jsx("span",{className:"truncate",children:c?Pe(t):u})]}):null]}),e.jsx("div",{className:"absolute right-3 top-3",children:l?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):r?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx("button",{type:"button",onClick:w=>w.stopPropagation(),className:"inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground/70 opacity-60 hover:bg-muted hover:text-foreground/80 focus-visible:opacity-100 group-hover:opacity-100","aria-label":`${m.noun==="report"?"Report":"Briefing"} actions`,children:e.jsx(s.Ellipsis,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-44",children:[e.jsxs(s.DropdownMenuItem,{onClick:o,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit ",m.noun]}),e.jsxs(s.DropdownMenuItem,{onClick:w=>{w.preventDefault(),a()},children:[e.jsx(s.Zap,{className:"h-3.5 w-3.5"}),"Run now"]}),t.scheduleExpr?e.jsx(s.DropdownMenuItem,{onClick:w=>{w.preventDefault(),d()},children:p?e.jsxs(e.Fragment,{children:[e.jsx(s.Play,{className:"h-3.5 w-3.5"}),"Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Pause,{className:"h-3.5 w-3.5"}),"Pause"]})}):null,e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{onClick:w=>{w.preventDefault(),h()},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),"Delete ",m.noun]})]})]})})]})}const Vt=2e3,Rt=20*6e4;function Ut(t){return(t==null?void 0:t.trim())||"This dashboard"}function Ot(t){return t==="This dashboard"?"Watch this dashboard":`Watch ${t}`}function zt(t,r,l){return r!=="dashboard"?t:t.filter(o=>o.source.type==="dashboard"&&o.source.dashboardId===l)}async function _t(t){const l=[];let o=1,a=0,d=Number.POSITIVE_INFINITY;for(;a<d;){const h=await t.apiClient.listBriefings(t.apiServiceUrl,t.token,{scope:"organization",page:o,pageSize:100});if(l.push(...h.briefings),a+=h.briefings.length,d=h.total,h.briefings.length===0||a>=d)break;o+=1}return l}const $t={listBriefings:s.listBriefings,getBriefing:s.getBriefing,pauseBriefing:s.pauseBriefing,resumeBriefing:s.resumeBriefing,deleteBriefing:s.deleteBriefing,runBriefingNow:s.runBriefingNow};function qt({briefingId:t,initialRun:r,apiServiceUrl:l,token:o,onTerminal:a,onTimeout:d,onExpand:h}){const[p,c]=x.useState(r),{startRun:u}=s.useBriefingRunPolling({apiServiceUrl:l,token:o,intervalMs:Vt,timeoutMs:Rt,fetchRun:({apiServiceUrl:g,token:m,runId:f})=>s.getBriefingRun(g,m,t,f),onRun:g=>{c(g)},onTerminalRun:g=>{a(g)},onTimeout:()=>{d()}}),i=x.useRef(!1);return x.useEffect(()=>{i.current||(i.current=!0,s.isActiveBriefingRunStatus(r.status)?u(r):s.isTerminalBriefingRunStatus(r.status)&&a(r))},[r,a,u]),e.jsx(s.BackgroundRunPill,{run:p,onExpand:h})}function Ht(t){return e.jsx(s.BriefingUiCapabilitiesBoundary,{children:e.jsx(Wt,{...t})})}function Wt({dashboardId:t,dashboardTitle:r,apiServiceUrl:l,token:o,disabled:a,className:d,manageBriefingsHref:h,open:p,onOpenChange:c,hideTrigger:u=!1,workflowIntent:i,client:g}){const{authToken:m,tokenProps:f}=s.useSemaphorContext(),w=s.useBriefingUiCapabilities(),y=!i||w.canCreate&&(i==="scheduled_report"||w.analyticalBriefingsEnabled),[E,B]=x.useState(!1),D=p??E,b=N=>{p===void 0&&B(N),c==null||c(N)},[S,A]=x.useState(i?"author":"list"),[T,v]=x.useState(i??"analytical_briefing"),[j,L]=x.useState("dashboard"),[I,$]=x.useState([]),[k,M]=x.useState(null),_=i&&!y&&!k?"list":S,[oe,q]=x.useState(!1),[fe,ie]=x.useState(null),[ge,W]=x.useState(null),[U,Q]=x.useState(null),[ee,te]=x.useState(null),le=x.useRef(null),ue=x.useRef(D);x.useEffect(()=>{const N=D&&!ue.current;ue.current=D,!(!N||!i)&&(M(null),L("dashboard"),v(i),A("author"),te(null))},[D,i]);const[se,ne]=x.useState(null),[G,ce]=x.useState(null),O=l??(f==null?void 0:f.apiServiceUrl),z=o??(m==null?void 0:m.accessToken),Z=x.useMemo(()=>({...$t,...g}),[g]),ae=Ut(r),he=x.useMemo(()=>{const N=zt(I,j,t);if(!i)return N;const P=i==="scheduled_report"?"report":"briefing";return N.filter(me=>X.getBriefingPresentation(me).noun===P)},[t,I,j,i]),be=x.useMemo(()=>j==="dashboard"?{source:{type:"dashboard",dashboardId:t},label:ae,detail:Ot(ae)}:{source:{type:"project"},label:"This project",detail:"Use any data in this project."},[t,ae,j]),de=!!(O&&z),re=X.getBriefingCreationIntents({canCreate:w.canCreate,analyticalBriefingsEnabled:w.analyticalBriefingsEnabled,scheduledReportAvailable:j==="dashboard"}),H=x.useCallback(async()=>{if(!(!O||!z)){q(!0),te(null);try{$(await _t({apiClient:Z,apiServiceUrl:O,token:z}))}catch(N){te(N instanceof Error?N.message:"Could not load briefings.")}finally{q(!1)}}},[Z,O,z]);x.useEffect(()=>{!D||_!=="list"||!de||H()},[de,_,H,D]);const C=()=>{M(null),L("dashboard"),A("list"),b(!0)},F=N=>{M(null),v(N),A("author")},R=async N=>{if(!(!O||!z)){ie(N),te(null);try{const P=await Z.getBriefing(O,z,N);M(P.briefing),A("author")}catch(P){te(P instanceof Error?P.message:"Could not open briefing.")}finally{ie(null)}}},Y=async N=>{if(!(!O||!z)){W(N.id);try{await Z.runBriefingNow(O,z,N.id,{requestId:Gt()}),H()}catch(P){s.ue.error(P instanceof Error?P.message:"Could not start the run.")}finally{W(null)}}},J=async N=>{if(!O||!z)return;const{noun:P}=X.getBriefingPresentation(N),me=P==="report"?"Report":"Briefing";W(N.id);try{const xe=N.status==="PAUSED"?await Z.resumeBriefing(O,z,N.id):await Z.pauseBriefing(O,z,N.id);s.ue.success(xe.briefing.status==="PAUSED"?`${me} paused`:`${me} resumed`),H()}catch(xe){s.ue.error(xe instanceof Error?xe.message:`Could not update the ${P} status.`)}finally{W(null)}},Ve=async()=>{if(!U||!O||!z)return;const N=U;W(N.id);try{await Z.deleteBriefing(O,z,N.id);const{noun:P}=X.getBriefingPresentation(N);s.ue.success(`${P==="report"?"Report":"Briefing"} deleted`),Q(null),H()}catch(P){s.ue.error(P instanceof Error?P.message:"Could not delete the briefing.")}finally{W(null)}},Re=he.length;return w.surfaceVisible?e.jsxs(s.Sheet,{open:D,onOpenChange:b,children:[u?null:e.jsx(Te,{disabled:a||!de,briefingCount:Re,className:d,onClick:C}),e.jsxs(s.SheetContent,{ref:le,side:"right",hideClose:!0,className:"flex h-full w-full flex-col overflow-hidden p-0 outline-none sm:max-w-[560px]",onOpenAutoFocus:N=>{var P;N.preventDefault(),(P=le.current)==null||P.focus({preventScroll:!0})},children:[e.jsxs(s.SheetHeader,{className:"sr-only",children:[e.jsx(s.SheetTitle,{children:"Reports & briefings"}),e.jsx(s.SheetDescription,{children:"Manage reports and briefings for this dashboard."})]}),i?e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b border-border pl-4 pr-3 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-5",role:"tablist","aria-label":i==="scheduled_report"?"Email report workflow":"Analytical briefing workflow",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":_==="author",disabled:!y,className:n.cn("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",_==="author"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground",!y&&"cursor-not-allowed opacity-50"),onClick:()=>{y&&(M(null),v(i),L("dashboard"),A("author"))},children:k?`Edit ${X.getBriefingPresentation(k).noun}`:i==="scheduled_report"?"Schedule report":"Create briefing"}),e.jsx("button",{type:"button",role:"tab","aria-selected":_==="list",className:n.cn("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",_==="list"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),onClick:()=>A("list"),children:i==="scheduled_report"?"Manage reports":"Manage briefings"})]}),e.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":i==="scheduled_report"?"Close email report workflow":"Close analytical briefing workflow",children:e.jsx(K.X,{className:"h-3.5 w-3.5"})})]}):null,_==="list"?e.jsx(Lt,{briefings:he,dashboardLabel:ae,sourceView:j,error:ee,loading:oe,onSourceViewChange:L,onClose:()=>b(!1),onEdit:N=>{R(N)},onNew:F,canCreate:!i&&re.length>0,canCreateScheduledReport:re.includes("scheduled_report"),analyticalBriefingsEnabled:re.includes("analytical_briefing"),onRunNow:N=>{Y(N)},onTogglePause:N=>{J(N)},onDelete:N=>Q(N),selectingId:fe,busyId:ge,manageBriefingsHref:h,contentKind:i==="scheduled_report"?"reports":i==="analytical_briefing"?"briefings":void 0,hideHeader:!!i}):e.jsx(s.BriefingAuthor,{apiServiceUrl:O,token:z,briefing:k,intent:T,sourceContext:k?void 0:be,title:k?`Edit ${X.getBriefingPresentation(k).noun}`:T==="scheduled_report"?"Schedule report":"Create analytical briefing",hideHeader:!!i,className:"h-full min-h-0 max-w-none border-0 shadow-none",onBack:i?void 0:()=>A("list"),onCancel:()=>b(!1),onDeleted:()=>{const N=k?X.getBriefingPresentation(k).noun:"briefing";s.ue.success(`${N==="report"?"Report":"Briefing"} deleted`),M(null),A("list"),H()},onRunStarted:()=>{},onSaved:N=>{M(N),H()},onMinimizeRun:({briefing:N,run:P})=>{ne({briefing:N,run:P}),b(!1)}})]}),se&&O&&z?e.jsx(qt,{briefingId:se.briefing.id,initialRun:se.run,apiServiceUrl:O,token:z,onTerminal:N=>{ce({briefing:se.briefing,run:N}),ne(null),H()},onTimeout:()=>{ne(null),H()},onExpand:()=>{M(se.briefing),A("author"),ne(null),b(!0)}}):null,G?e.jsx("div",{className:"fixed bottom-4 right-4 z-50 w-[360px]",children:e.jsx(s.RunCompletionBanner,{title:G.run.status==="SUCCESS"?`${G.briefing.name} is ready`:`${G.briefing.name} run failed`,durationSeconds:G.run.startedAt&&G.run.completedAt?Math.max(0,Math.floor((new Date(G.run.completedAt).getTime()-new Date(G.run.startedAt).getTime())/1e3)):null,status:G.run.status==="SUCCESS"?"success":"failed",onView:()=>{M(G.briefing),A("author"),ce(null),b(!0)},onDismiss:()=>ce(null)})}):null,e.jsx(s.AlertDialog,{open:!!U,onOpenChange:N=>{N||Q(null)},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs(s.AlertDialogTitle,{children:["Delete"," ",U?X.getBriefingPresentation(U).noun:"briefing","?"]}),e.jsxs(s.AlertDialogDescription,{children:["This permanently deletes ",e.jsx("strong",{children:U==null?void 0:U.name}),". Recipients will stop receiving it."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsxs(s.AlertDialogAction,{className:"bg-destructive/90 hover:bg-destructive",onClick:Ve,children:["Delete"," ",U?X.getBriefingPresentation(U).noun:"briefing"]})]})]})})]}):null}function Gt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`briefing-run-now-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}exports.AdvancedModeToggle=rt;exports.DashboardBriefingLauncher=Ht;exports.DashboardControlsSettings=Ie;exports.DashboardFilterControlsButton=Le;exports.DashboardFilterControlsLauncher=Dt;exports.DocumentControlsSettings=Fe;exports.ExportNotificationItem=ke;exports.ExportNotificationList=Be;exports.NotificationBell=xt;exports.UnsavedChangesAlert=nt;exports.VisualEditingControls=st;exports.VisualsLibraryDialog=Qe;exports.WatchDashboardButton=Te;exports.useExportPolling=ut;exports.useExportRecovery=ht;
|