@hot-updater/console 1.0.0-rc.44 → 1.0.0-rc.46
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/.output/nitro.json +1 -1
- package/.output/public/assets/api-DCM0wr6O.js +1 -0
- package/.output/public/assets/{index-cjpqHeMo.js → index-DNqzBBQm.js} +1 -1
- package/.output/public/assets/{insights-f2XjD8eb.js → insights-CxZ2GCYV.js} +2 -2
- package/.output/public/assets/{insights-Dw9BSqod.js → insights-vNRCrfnS.js} +1 -1
- package/.output/public/assets/{remote-config-CJPXuXOM.js → remote-config-BWwHOkCK.js} +1 -1
- package/.output/public/assets/{remote-config-BvbrGWh8.js → remote-config-Br56BODb.js} +3 -3
- package/.output/public/assets/{routes-B0Z6ly9V.js → routes-CcHyRuhT.js} +2 -2
- package/.output/public/assets/{routes-DPQr7zoH.js → routes-Cnc-0wCf.js} +1 -1
- package/.output/server/{__23tanstack-start-server-fn-resolver-CAIUZxS3.mjs → __23tanstack-start-server-fn-resolver-DBoGuFHl.mjs} +40 -48
- package/.output/server/_ssr/{BundleIdDisplay-DmwFwFig.mjs → BundleIdDisplay-BLIcWfKh.mjs} +2 -2
- package/.output/server/_ssr/{ConsoleFeatureUnavailable-CXdtdnY7.mjs → ConsoleFeatureUnavailable-tkUa36qH.mjs} +5 -5
- package/.output/server/_ssr/{EventDetails-BRHWr0y4.mjs → EventDetails-BfatDL9h.mjs} +6 -6
- package/.output/server/_ssr/{HashValueDisplay-DPf-8SmO.mjs → HashValueDisplay-Db7UyXRv.mjs} +2 -2
- package/.output/server/_ssr/{InsightsInfo-i8nqiI4p.mjs → InsightsInfo-Bf5ScSi9.mjs} +4 -4
- package/.output/server/_ssr/{InsightsPageHeader-ASTSUdCJ.mjs → InsightsPageHeader-Bl-joCfN.mjs} +5 -5
- package/.output/server/_ssr/{NotFoundPage-3jFxLwYw.mjs → NotFoundPage-Bi2qUsx1.mjs} +2 -2
- package/.output/server/_ssr/{alert-dialog-DiNl2zyc.mjs → alert-dialog-sMWGv43S.mjs} +1 -1
- package/.output/server/_ssr/{api-yMNlDDQz.mjs → api-DtU13_AI.mjs} +3 -20
- package/.output/server/_ssr/{api-keys-DJ695sz4.mjs → api-keys-B40C8x9k.mjs} +7 -7
- package/.output/server/_ssr/{api-keys-DsWCDbyZ.mjs → api-keys-M8Dotim_.mjs} +2 -2
- package/.output/server/_ssr/{api-keys-rpc-CMreTvPQ.mjs → api-keys-rpc-Tag1hm3M.mjs} +3 -3
- package/.output/server/_ssr/{api-rpc-DFxQatm1.mjs → api-rpc-D4Bj1ivx.mjs} +9 -65
- package/.output/server/_ssr/{auth-rpc-ABmGfiYv.mjs → auth-rpc-sa9Klhqj.mjs} +4 -4
- package/.output/server/_ssr/{auth.server-CftUlVI0.mjs → auth.server-C7gBA8hC.mjs} +8 -8
- package/.output/server/_ssr/{config.server-DKKxOk0p.mjs → config.server-RKYRoVbq.mjs} +5 -6
- package/.output/server/_ssr/{console-access-BGqx9nA9.mjs → console-access-DQhcMCMv.mjs} +2 -2
- package/.output/server/_ssr/{console-features-api-D3dSwBFb.mjs → console-features-api-Bn7S9NPh.mjs} +3 -3
- package/.output/server/_ssr/{console-features-rpc-DlmjEgPo.mjs → console-features-rpc-M7C9V3UZ.mjs} +3 -3
- package/.output/server/_ssr/{databaseRows-BUuNU-qt.mjs → databaseRows-CPphvbag.mjs} +6 -7
- package/.output/server/_ssr/{dialog-EwBwQ3Al.mjs → dialog-CED2DFlP.mjs} +1 -1
- package/.output/server/_ssr/{dist-wmnTk7w6.mjs → dist-CbQbBIw-.mjs} +2 -3
- package/.output/server/_ssr/{empty-IxfzBAbK.mjs → empty-X3Mb-0Rh.mjs} +2 -2
- package/.output/server/_ssr/{field-CAk8Po6G.mjs → field-Bq9ez4V0.mjs} +2 -2
- package/.output/server/_ssr/{getBundleChildren-CmjDg6Re.mjs → getBundleChildren-Cv9iz1As.mjs} +2 -2
- package/.output/server/_ssr/{input-group-C8xGutM-.mjs → input-group-BDVVM0Zn.mjs} +1 -1
- package/.output/server/_ssr/{insights-CiMMDBOR.mjs → insights-BDBmvZ6K.mjs} +18 -18
- package/.output/server/_ssr/{insights-TfCZijVT.mjs → insights-CZfz7BbH.mjs} +5 -5
- package/.output/server/_ssr/{insights-BOlIwjER.mjs → insights-DGKnQkgB.mjs} +2 -2
- package/.output/server/_ssr/{insights-api-BujwgqiF.mjs → insights-api-BiflmVk6.mjs} +3 -3
- package/.output/server/_ssr/{insights-failures-rpc-qo3-10sJ.mjs → insights-failures-rpc-D77GE8Sa.mjs} +6 -6
- package/.output/server/_ssr/{insights-recovery-rpc-CJc-e3aX.mjs → insights-recovery-rpc-giYcsG87.mjs} +4 -4
- package/.output/server/_ssr/{insights-rpc-Bq9yK1cQ.mjs → insights-rpc-zGPxWSbl.mjs} +3 -3
- package/.output/server/_ssr/{insights-usage-rpc-Dd6LuAuP.mjs → insights-usage-rpc-B9F5Atkw.mjs} +3 -3
- package/.output/server/_ssr/{insights-usage-rpc-DSqa8rm7.mjs → insights-usage-rpc-DC6Bu-Um.mjs} +4 -4
- package/.output/server/_ssr/{insights_.distribution-B8JZmhAz.mjs → insights_.distribution-BUrD0M3t.mjs} +5 -5
- package/.output/server/_ssr/{insights_.distribution-B5Lw0-Dy.mjs → insights_.distribution-C2IgQYXY.mjs} +2 -2
- package/.output/server/_ssr/{insights_.distribution-CIV8qEbl.mjs → insights_.distribution-D9qvWJk0.mjs} +11 -11
- package/.output/server/_ssr/{installations-Bf7bPK9c.mjs → installations-BV0OM7Uy.mjs} +2 -2
- package/.output/server/_ssr/{installations-Dx_EV-mI.mjs → installations-C21DpVcb.mjs} +4 -4
- package/.output/server/_ssr/{installations-DKwMDKvg.mjs → installations-dAUE-ioO.mjs} +10 -10
- package/.output/server/_ssr/{plugins-3wxZQEn5.mjs → plugins-BaD1slHx.mjs} +4 -4
- package/.output/server/_ssr/{release-adoption-rpc-D6o106Na.mjs → release-adoption-rpc-DFZ-Op6d.mjs} +6 -6
- package/.output/server/_ssr/{releaseManagement-BTCWEY8-.mjs → releaseManagement-DFMUnDF5.mjs} +1 -1
- package/.output/server/_ssr/{remote-config-Cik_fTGD.mjs → remote-config-BFvOUuyk.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-Dho6TuQe.mjs → remote-config-DFYC51RV.mjs} +15 -15
- package/.output/server/_ssr/{remote-config-CxLhYG7c.mjs → remote-config-_tZx6Ge2.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-rpc-Nec8oaNz.mjs → remote-config-rpc-CjHJ1ure.mjs} +4 -4
- package/.output/server/_ssr/{router-Cp3mzjj7.mjs → router-DhFb-pDT.mjs} +13 -13
- package/.output/server/_ssr/{routes-CazO1POC.mjs → routes-BQmkLu_-.mjs} +15 -15
- package/.output/server/_ssr/{routes-CJMAShOS.mjs → routes-CFDo4Koe.mjs} +8 -8
- package/.output/server/_ssr/{runtime.server-DLrq5UBB.mjs → runtime.server-De0QVWc9.mjs} +2 -2
- package/.output/server/_ssr/{schema-DrOtkRVD.mjs → schema-BiAVyEj2.mjs} +1 -1
- package/.output/server/_ssr/{select-DPTLkWdD.mjs → select-OIka_qhv.mjs} +1 -1
- package/.output/server/_ssr/{server-DBgxQIeE.mjs → server-nJn93aLo.mjs} +3 -3
- package/.output/server/_ssr/{sidebar-CQn_ksV8.mjs → sidebar-DwaxcWKo.mjs} +2 -2
- package/.output/server/_ssr/ssr.mjs +1 -1
- package/.output/server/_ssr/{switch-Da_EY-bS.mjs → switch-C28pz0ID.mjs} +2 -2
- package/.output/server/_ssr/{table-CAbD28jq.mjs → table-x55cOnVQ.mjs} +1 -1
- package/.output/server/_ssr/{tabs-CcoEXc6t.mjs → tabs-CAsCh1zC.mjs} +2 -2
- package/.output/server/_ssr/{uuidv7-ctA_XVZA.mjs → uuidv7-C88s9jWF.mjs} +2 -2
- package/.output/server/{_tanstack-start-manifest_v-BeBad5Wm.mjs → _tanstack-start-manifest_v-Cxw82E0f.mjs} +11 -11
- package/.output/server/index.mjs +114 -114
- package/README.md +1 -3
- package/package.json +7 -7
- package/src/lib/api-rpc.ts +0 -86
- package/src/lib/api.ts +0 -36
- package/src/lib/server/config.server.ts +0 -2
- package/.output/public/assets/api-DUgI6yOI.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-config-CXOi0LRu.js","assets/ConsoleFeatureUnavailable-jB4Loglh.js","assets/sidebar-DNVyJPfX.js","assets/console-features-api-BH5m_PtQ.js","assets/arrow-up-right-BtffZA6e.js","assets/NotFoundPage-DIqCpWa3.js","assets/empty-CuT2UhFp.js","assets/remote-config-
|
|
2
|
-
import{Bn as e,Fn as t,Gn as n,Hn as r,Hr as i,Jn as a,Ln as o,Nn as s,Rn as c,Ur as l,Vn as u,Wr as d,Z as f,Zn as p,ar as m,cr as h,ct as g,ei as _,ir as v,jr as y,nr as b,p as x,qt as S,ri as C,rr as w,un as T}from"./sidebar-DNVyJPfX.js";import{r as ee}from"./console-features-api-BH5m_PtQ.js";import{a as te,c as E,i as D,m as O,s as k}from"./useCompositeListItem-9E4pj_CH.js";import{a as ne,d as re,i as ie,l as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./alert-dialog-Bbk_4-WJ.js";import{h as de,i as fe}from"./api-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-config-CXOi0LRu.js","assets/ConsoleFeatureUnavailable-jB4Loglh.js","assets/sidebar-DNVyJPfX.js","assets/console-features-api-BH5m_PtQ.js","assets/arrow-up-right-BtffZA6e.js","assets/NotFoundPage-DIqCpWa3.js","assets/empty-CuT2UhFp.js","assets/remote-config-BWwHOkCK.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{Bn as e,Fn as t,Gn as n,Hn as r,Hr as i,Jn as a,Ln as o,Nn as s,Rn as c,Ur as l,Vn as u,Wr as d,Z as f,Zn as p,ar as m,cr as h,ct as g,ei as _,ir as v,jr as y,nr as b,p as x,qt as S,ri as C,rr as w,un as T}from"./sidebar-DNVyJPfX.js";import{r as ee}from"./console-features-api-BH5m_PtQ.js";import{a as te,c as E,i as D,m as O,s as k}from"./useCompositeListItem-9E4pj_CH.js";import{a as ne,d as re,i as ie,l as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./alert-dialog-Bbk_4-WJ.js";import{h as de,i as fe}from"./api-DCM0wr6O.js";import{a as A,b as j,d as M,f as N,g as pe,h as me,i as he,l as P,m as ge,n as _e,o as ve,p as F,r as I,s as ye,t as L,u as R,v as z,y as be}from"./field-BBDpjIqu.js";import{N as xe,a as Se,i as B,n as Ce,o as we,r as V,s as Te,t as Ee}from"./select-BZZBXMkr.js";import{t as De}from"./clipboard-DS9ucUQL.js";import{a as Oe,c as H,i as ke,l as Ae,n as je,o as Me,r as Ne,t as Pe}from"./dialog-Bqbb7B0N.js";import{t as Fe}from"./refresh-cw-BYgoNCco.js";import{i as Ie,n as Le,o as Re,r as ze,s as Be,t as Ve}from"./input-group-ja_30qaF.js";import{t as He}from"./search-DaTDPW25.js";import{a as Ue,i as We,n as U,o as Ge,r as Ke,s as qe,t as Je}from"./switch-DZ1TPwx-.js";import{t as Ye}from"./smartphone-DpTFgtKf.js";import{t as Xe}from"./undo-2-CmrHjwFc.js";import{n as W}from"./dist-LxKJB-Vu.js";import{a as Ze,i as Qe,n as $e,o as et,r as tt,t as nt}from"./tabs-C7FOEjFC.js";import{a as rt,i as it,n as at,o as ot,r as st,t as ct}from"./empty-CuT2UhFp.js";var lt=m(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),ut=m(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),dt=m(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),ft=m(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),pt=m(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),mt=m(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),ht=m(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),gt=m(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),G=C(_()),K=l(),_t=C(Ue(),1),vt=C(We(),1),yt=w({method:`GET`}).middleware([b]).handler(d(`0ccfae64b399b03d820328fa98a38e2caa0b622d3da5a7ca633c5a0e8101e3f6`)),bt=w({method:`GET`}).middleware([b]).handler(d(`3377db68b9d1d971971595469029c0466da0777a177b294d655cd0c039737f1a`)),xt=w({method:`GET`}).middleware([b]).handler(d(`af71e3c55a659ce46093e33b9d70e729359610eec7d576502e8f0e26c785b317`)),St=w({method:`POST`}).middleware([b]).handler(d(`4182bf9ccbb675700638f30bc6122517ccd90b16a339a6823a0f5f6c808d70a6`)),Ct=w({method:`POST`}).middleware([b]).handler(d(`98c10bdc514eb4d3fe65af546be44452b492a81092cfe45625778a4c9f731727`)),wt=w({method:`POST`}).middleware([b]).handler(d(`1371bff16085636e2c44b60a573ae434b556c63045c40a0a93a93ab69ec47999`)),q={all:[`remote-config`],active:[`remote-config`,`active`],versions:[`remote-config`,`versions`],version:e=>[`remote-config`,`version`,e],preview:e=>[`remote-config`,`preview`,e]},Tt=()=>h({queryKey:q.active,queryFn:()=>yt(),staleTime:6e4}),Et=({enabled:e})=>O({queryKey:q.versions,queryFn:({pageParam:e})=>bt({data:e===void 0?{}:{cursor:e}}),initialPageParam:void 0,getNextPageParam:e=>e.next,staleTime:6e4,enabled:e}),Dt=e=>h({queryKey:q.version(e??0),queryFn:()=>xt({data:{version:e}}),enabled:e!==null,staleTime:1/0}),Ot=()=>{let e=i();return async()=>{await Promise.all([e.invalidateQueries({queryKey:q.active}),e.invalidateQueries({queryKey:q.versions})])}},kt=()=>{let e=Ot();return re({mutationFn:e=>St({data:e}),onSuccess:async t=>{(t.status===`published`||t.status===`conflict`)&&await e()}})},At=()=>re({mutationFn:e=>Ct({data:e}),onSuccess:Ot()}),jt=e=>h({queryKey:q.preview(e),queryFn:()=>wt({data:e}),placeholderData:y,staleTime:1/0}),J={STRING:`String`,NUMBER:`Number`,BOOLEAN:`Boolean`,JSON:`JSON`},Y={platform:`Platform`,channel:`Channel`,appVersion:`App version`,percent:`Percentage of installs`,cohort:`Cohort`,fingerprint:`Fingerprint`,dateTime:`Date and time`},X=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Mt=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Nt=(e,t,n,r)=>{let i=Object.entries(e.parameters),a=t===null?-1:i.findIndex(([e])=>e===t),o=a===-1?[...i.filter(([e])=>e!==n),[n,r]]:i.map((e,t)=>t===a?[n,r]:e);return{...e,parameters:Object.fromEntries(o)}},Pt=(e,t)=>({...e,parameters:Object.fromEntries(Object.entries(e.parameters).filter(([e])=>e!==t))}),Ft=(e,t)=>Object.fromEntries(Object.entries(e.parameters).map(([e,n])=>{let{conditionalValues:r,...i}=n,a=Object.entries(r??{}).flatMap(([e,n])=>{let r=t(e);return r===null?[]:[[r,n]]});return[e,a.length===0?i:{...i,conditionalValues:Object.fromEntries(a)}]})),It=(e,t,n)=>t===null?{...e,conditions:[...e.conditions,n]}:{conditions:e.conditions.map(e=>e.name===t?n:e),parameters:t===n.name?e.parameters:Ft(e,e=>e===t?n.name:e)},Lt=(e,t)=>({conditions:e.conditions.filter(e=>e.name!==t),parameters:Ft(e,e=>e===t?null:e)}),Rt=(e,t,n)=>{let r=t+n;if(r<0||r>=e.conditions.length)return e;let i=[...e.conditions];return[i[t],i[r]]=[i[r],i[t]],{...e,conditions:i}},zt=(e,t)=>Object.entries(e.parameters).filter(([,e])=>X(e.conditionalValues,t)!==void 0).map(([e])=>e),Bt=(e,t=3)=>e.length<=t?e.join(`, `):`${e.slice(0,t).join(`, `)} +${e.length-t}`,Vt=e=>Number.isInteger(e)?String(e):e.toFixed(1),Ht=e=>{let t=new Intl.DateTimeFormat(`en`,{timeZone:e,timeZoneName:e===`UTC`?`short`:`shortOffset`,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});return e=>t.format(new Date(e))},Ut=Ht(`UTC`),Wt=(e=new Date)=>{let t=new Date(e);t.setMinutes(60,0,0);let n=new Date(e);n.setDate(n.getDate()+1),n.setHours(9,0,0,0);let r=new Date(e);return r.setSeconds(0,0),[{label:`Now`,iso:r.toISOString()},{label:`Next hour`,iso:t.toISOString()},{label:`Tomorrow 09:00`,iso:n.toISOString()}]},Gt=(e,t=new Date)=>{let n=e===void 0?t:new Date(e),r=e=>{let t=new Date(n);return t.setDate(t.getDate()+e),t.setSeconds(0,0),t.toISOString()};return[{label:`+1 day`,iso:r(1)},{label:`+1 week`,iso:r(7)}]},Kt=e=>{if(e===void 0)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`},qt=e=>{if(e.length===0)return;let t=new Date(e).getTime();return Number.isFinite(t)?new Date(t).toISOString():void 0},Jt=(e,t=Ut)=>{switch(e.type){case`platform`:return`Platform is ${Bt(e.platforms.map(e=>e===`ios`?`iOS`:`Android`))}`;case`channel`:return`Channel is ${Bt(e.channels)}`;case`appVersion`:return`App version ${e.range}`;case`cohort`:return`Cohort is ${Bt(e.cohorts)}`;case`percent`:return e.from===0?`${Vt(e.to)}% of installs`:`${Vt(e.from)}–${Vt(e.to)}% of installs`;case`fingerprint`:return`Fingerprint is ${Bt(e.hashes.map(e=>e.slice(0,8)))}`;case`dateTime`:return e.from!==void 0&&e.to!==void 0?`From ${t(e.from)} until ${t(e.to)}`:e.from===void 0?`Until ${t(e.to??``)}`:`From ${t(e.from)}`}},Z=e=>`value`in e?e.value.length===0?`""`:e.value:`In-app default`,Yt=()=>{let e=crypto.getRandomValues(new Uint8Array(6));return Array.from(e,e=>e.toString(36).padStart(2,`0`)).join(``).slice(0,8)},Xt=(e,t)=>({added:Object.keys(t).filter(t=>!Object.hasOwn(e,t)),changed:Object.keys(t).filter(n=>Object.hasOwn(e,n)&&JSON.stringify(e[n])!==JSON.stringify(t[n])),removed:Object.keys(e).filter(e=>!Object.hasOwn(t,e))}),Zt=(e,t)=>{let n=e=>Object.fromEntries(e.conditions.map(e=>[e.name,e])),r=(e,t)=>e.conditions.map(({name:e})=>e).filter(e=>t.conditions.some(t=>t.name===e));return{parameters:Xt(e.parameters,t.parameters),conditions:Xt(n(e),n(t)),reordered:r(e,t).join(`
|
|
3
3
|
`)!==r(t,e).join(`
|
|
4
4
|
`)}},Q=`Not set`,Qt=(e,t)=>{let n=[],r=(e,t,r)=>{(t===null?r!==Q:t!==r)&&n.push({field:e,before:t,after:r})};r(`Type`,e===null?null:J[e.valueType],J[t.valueType]),r(`Default`,e===null?null:Z(e.defaultValue),Z(t.defaultValue));let i=new Set([...Object.keys(e?.conditionalValues??{}),...Object.keys(t.conditionalValues??{})]);for(let n of i){let i=X(e?.conditionalValues,n),a=X(t.conditionalValues,n);r(`When ${n}`,e===null?null:i===void 0?Q:Z(i),a===void 0?Q:Z(a))}return r(`Description`,e===null?null:e.description??Q,t.description??Q),n},$t=(e,t,n=Ut)=>{let r=e=>e.rules.map(e=>Jt(e,n)).join(` · `),i=r(t);if(e===null)return[{field:`Rules`,before:null,after:i}];let a=r(e);return a===i?[]:[{field:`Rules`,before:a,after:i}]},en=`hot-updater:remote-config-draft`,$=e=>typeof e==`object`&&!!e&&!Array.isArray(e),tn=e=>$(e)&&(typeof e.value==`string`||e.useInAppDefault===!0),nn=e=>$(e)&&$(e.parameters)&&Array.isArray(e.conditions)&&Object.values(e.parameters).every(e=>$(e)&&Object.hasOwn(J,String(e.valueType))&&tn(e.defaultValue)&&(e.conditionalValues===void 0||$(e.conditionalValues)&&Object.values(e.conditionalValues).every(tn)))&&e.conditions.every(e=>$(e)&&typeof e.name==`string`&&Array.isArray(e.rules)&&e.rules.every(e=>$(e)&&Object.hasOwn(Y,String(e.type)))),rn=e=>{try{let t=window.localStorage.getItem(en);if(t===null)return null;let n=JSON.parse(t);return!$(n)||n.baseVersion!==e.version||!nn(n.base)||!nn(n.template)||!Mt(n.base,e.template)||Mt(n.template,e.template)?null:{baseVersion:e.version,base:n.base,template:n.template}}catch{return null}},an=e=>{try{return e===null?window.localStorage.removeItem(en):window.localStorage.setItem(en,JSON.stringify(e)),!0}catch{return!1}},on=/^[A-Za-z_][A-Za-z0-9_]{0,255}$/u,sn=(e,t)=>e.length===0?`Enter a key.`:on.test(e)?t.includes(e)?`Another parameter uses this key.`:null:`Start with a letter or _, then use letters, digits, and _.`,cn=(e,t)=>{if(e===`NUMBER`)return t.trim().length>0&&Number.isFinite(Number(t))?null:`Enter a number.`;if(e===`JSON`)try{return JSON.parse(t),null}catch{return`Enter valid JSON.`}return e===`BOOLEAN`&&t!==`true`&&t!==`false`?`Choose true or false.`:null},ln=(e,t,n)=>{let r=e.map(e=>Jt(e,n)).join(` · `),i=r.length<=100?r:`${r.slice(0,99).trimEnd()}…`;if(i.length===0||!t.includes(i))return i;for(let e=2;;e+=1){let n=` (${e})`,r=`${i.slice(0,100-n.length)}${n}`;if(!t.includes(r))return r}},un=(e,t)=>{let n=e.trim();return n.length===0?`Enter a name.`:n.length>100?`Use 100 characters or fewer.`:t.includes(n)?`Another condition uses this name.`:null},dn=e=>[...new Set(e.split(/[\n,]/u).map(e=>e.trim()).filter(e=>e.length>0))],fn=e=>{switch(e.type){case`platform`:return e.platforms.length===0?`Choose a platform.`:null;case`channel`:return e.channels.length===0?`Enter a channel.`:null;case`appVersion`:return e.range.trim().length===0?`Enter a version range, such as >=1.4.0.`:null;case`cohort`:return e.cohorts.length===0?`Enter a cohort.`:null;case`percent`:return e.from>=e.to||e.from<0||e.to>100||Math.abs(e.to*10-Math.round(e.to*10))>1e-9||Math.abs(e.from*10-Math.round(e.from*10))>1e-9?`Use a range from 0 to 100 in steps of 0.1.`:null;case`fingerprint`:return e.hashes.length===0?`Enter a fingerprint.`:null;case`dateTime`:return e.from===void 0&&e.to===void 0?`Choose a start, an end, or both.`:e.from!==void 0&&e.to!==void 0&&e.from>=e.to?`End after the start.`:null}},pn=e=>{switch(e){case`platform`:return{type:e,platforms:[`ios`]};case`channel`:return{type:e,channels:[]};case`appVersion`:return{type:e,range:``};case`cohort`:return{type:e,cohorts:[]};case`percent`:return{type:e,seed:Yt(),from:0,to:10};case`fingerprint`:return{type:e,hashes:[]};case`dateTime`:return{type:e,from:Wt()[1].iso}}},mn=G.createContext(void 0);function hn(e=!0){let t=G.useContext(mn);if(t===void 0&&!e)throw Error(a(7));return t}function gn(t){let{render:n,className:i,style:a,state:o=r,props:s=u,refs:c=u,metadata:l,stateAttributesMapping:d,tag:f=`div`,...p}=t,{compositeProps:m,compositeRef:h}=et({metadata:l});return e(f,t,{state:o,ref:[...c,h],props:[m,...s,p],stateAttributesMapping:d})}var _n=G.forwardRef(function(t,r){let{className:i,defaultPressed:a=!1,disabled:o=!1,form:s,onPressedChange:c,pressed:l,render:u,type:d,value:f,nativeButton:p=!0,style:m,...h}=t,_=g(f||void 0),v=hn(),y=v?.value??[],b=v?void 0:a,x=(o||v?.disabled)??!1,[C,w]=D({controlled:v?_!==void 0&&y.indexOf(_)>-1:l,default:b,name:`Toggle`,state:`pressed`}),{getButtonProps:ee,buttonRef:te}=n({disabled:x,native:p}),E={disabled:x,pressed:C},O=[te,r],k=[{"aria-pressed":C,onClick(e){let t=!C,n=S(T,e.nativeEvent);_&&v?.setGroupValue?.(_,t,n),c?.(t,n),!n.isCanceled&&w(t)}},h,ee],ne=e(`button`,t,{enabled:!v,state:E,ref:O,props:k});return v?(0,K.jsx)(gn,{tag:`button`,render:u,className:i,style:m,state:E,refs:O,props:k}):ne}),vn=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),yn={multiple(e){return e?{[vn.multiple]:``}:null}},bn=G.forwardRef(function(t,n){let{defaultValue:r,disabled:i=!1,loopFocus:a=!0,onValueChange:o,orientation:s=`horizontal`,multiple:c=!1,value:l,className:d,render:f,style:m,...h}=t,g=Te(!0),_=G.useMemo(()=>l!==void 0||r!==void 0,[l,r]),v=(g?.disabled??!1)||i,[y,b]=D({controlled:l,default:l===void 0?r??u:void 0,name:`ToggleGroup`,state:`value`}),x=p((e,t,n)=>{let r;c?(r=y.slice(),t?r.push(e):r.splice(y.indexOf(e),1)):r=t?[e]:[],o?.(r,n),!n.isCanceled&&b(r)}),S={disabled:v,multiple:c,orientation:s},C=G.useMemo(()=>({disabled:v,orientation:s,setGroupValue:x,value:y,isValueInitialized:_}),[v,s,x,y,_]),w={role:`group`},T=e(`div`,t,{enabled:!!g,state:S,ref:n,props:[w,h],stateAttributesMapping:yn});return(0,K.jsx)(mn.Provider,{value:C,children:g?T:(0,K.jsx)(Ze,{render:f,className:d,style:m,state:S,refs:[n],props:[w,h],stateAttributesMapping:yn,loopFocus:a,enableHomeAndEndKeys:!0,orientation:s})})}),xn=c(`group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-7 min-w-7 px-2 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5`,sm:`h-6 min-w-6 rounded-[min(var(--radius-md),8px)] px-2 text-[0.625rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,lg:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),Sn=G.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function Cn({className:e,variant:t,size:n,spacing:r=2,orientation:i=`horizontal`,children:a,...s}){return(0,K.jsx)(bn,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:o(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-md data-[size=sm]:rounded-[min(var(--radius-md),8px)] data-vertical:flex-col data-vertical:items-stretch`,e),...s,children:(0,K.jsx)(Sn.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function wn({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=G.useContext(Sn);return(0,K.jsx)(_n,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:o(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,xn({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}function Tn(){let[e,t]=(0,G.useState)(`UTC`);return(0,G.useEffect)(()=>{t(Intl.DateTimeFormat().resolvedOptions().timeZone)},[]),{timeZone:e,dateTimeText:(0,G.useMemo)(()=>Ht(e),[e])}}var En=Object.keys(Y);function Dn({id:e,values:t,onChange:n,placeholder:r,multiline:i=!1}){let[a,o]=(0,G.useState)(t.join(`, `)),[s,c]=(0,G.useState)(t);s!==t&&(c(t),dn(a).join(`
|
|
5
5
|
`)!==t.join(`
|
|
6
|
-
`)&&o(t.join(`, `)));let l=e=>{o(e),n(dn(e))};return i?(0,K.jsx)(Re,{className:`min-h-20 font-mono text-xs`,id:e,onChange:e=>l(e.target.value),placeholder:r,spellCheck:!1,value:a}):(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:e,onChange:e=>l(e.target.value),placeholder:r,value:a})}function On({id:e,label:n,value:r,presets:i,onChange:a}){return(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:e,children:n}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 tabular-nums sm:h-9`,id:e,onChange:e=>a(qt(e.target.value)),type:`datetime-local`,value:Kt(r)}),r===void 0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{"aria-label":`Clear ${n.toLowerCase()}`,className:`size-11 sm:size-5`,onClick:()=>a(void 0),size:`icon-xs`,children:(0,K.jsx)(v,{})})})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,K.jsx)(t,{"aria-pressed":e.iso===r,className:`min-h-11 sm:min-h-6`,onClick:()=>a(e.iso),size:`xs`,type:`button`,variant:e.iso===r?`secondary`:`outline`,children:e.label},e.label))})]})}function kn({rule:e,onChange:n}){let r=(0,G.useId)(),i=fe();switch(e.type){case`platform`:return(0,K.jsx)(Cn,{"aria-label":`Platforms`,multiple:!0,onValueChange:t=>n({...e,platforms:t.filter(e=>e===`ios`||e===`android`)}),value:[...e.platforms],variant:`outline`,children:[`ios`,`android`].map(e=>(0,K.jsxs)(wn,{className:`min-h-11 px-3 sm:min-h-8`,value:e,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:e}),e===`ios`?`iOS`:`Android`]},e))});case`channel`:{let a=(i.data??[]).map(({name:e})=>e).filter(t=>!e.channels.includes(t));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Dn,{id:`${r}-channels`,onChange:t=>n({...e,channels:t}),placeholder:`production, beta`,values:e.channels}),a.length>0?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Add:`}),a.slice(0,8).map(r=>(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-6`,onClick:()=>n({...e,channels:[...e.channels,r]}),size:`xs`,type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),r]},r))]}):null]})}case`appVersion`:return(0,K.jsx)(f,{"aria-label":`App version range`,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,onChange:t=>n({...e,range:t.target.value}),placeholder:`>=1.4.0`,value:e.range});case`cohort`:return(0,K.jsx)(Dn,{id:`${r}-cohorts`,onChange:t=>n({...e,cohorts:t}),placeholder:`1, 2, beta-testers`,values:e.cohorts});case`percent`:return(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[repeat(2,minmax(0,8rem))_minmax(0,1fr)]`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-from`,children:`From %`}),(0,K.jsx)(f,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-from`,inputMode:`decimal`,max:100,min:0,onChange:t=>n({...e,from:Number(t.target.value)}),step:.1,type:`number`,value:e.from})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-to`,children:`To %`}),(0,K.jsx)(f,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-to`,inputMode:`decimal`,max:100,min:0,onChange:t=>n({...e,to:Number(t.target.value)}),step:.1,type:`number`,value:e.to})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-seed`,children:`Seed`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${r}-seed`,onChange:t=>n({...e,seed:t.target.value}),value:e.seed}),(0,K.jsx)(t,{"aria-label":`New seed`,className:`size-11 sm:size-9`,onClick:()=>n({...e,seed:Yt()}),size:`icon`,type:`button`,variant:`outline`,children:(0,K.jsx)(Fe,{})})]})]})]});case`fingerprint`:return(0,K.jsx)(Dn,{id:`${r}-hashes`,multiline:!0,onChange:t=>n({...e,hashes:t}),placeholder:`One fingerprint hash per line`,values:e.hashes});case`dateTime`:{let t=(t,r)=>{let{[t]:i,...a}=e;n(r===void 0?a:{...a,[t]:r})};return(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsx)(On,{id:`${r}-from`,label:`From`,onChange:e=>t(`from`,e),presets:Wt(),value:e.from}),(0,K.jsx)(On,{id:`${r}-until`,label:`Until`,onChange:e=>t(`to`,e),presets:Gt(e.from),value:e.to})]})}}}var An={platform:`Devices on any of these platforms.`,channel:`Devices on any of these channels, separated by commas.`,appVersion:`A semver range of native app versions, as release targets use: 2.x, >=1.4.0 <2.0.0.`,percent:`Installs whose numeric cohort lands in this share. Rules with one seed split the same order, so 0–10 and 10–20 never overlap.`,cohort:`Numeric cohorts from 1 to 1000, or custom cohort names.`,fingerprint:`Native builds with any of these fingerprints.`,dateTime:`Leave either end empty to keep it open. Devices get the change at their next fetch.`};function jn({open:e,onOpenChange:t,condition:n,takenNames:r,onSave:i}){let a=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-xl`,children:(0,K.jsx)(Mn,{condition:n,onCancel:()=>t(!1),onSave:e=>{i(e),t(!1)},takenNames:r},a)})})}function Mn({condition:e,takenNames:n,onSave:r,onCancel:i}){let a=(0,G.useId)(),{dateTimeText:o,timeZone:s}=Tn(),[c,l]=(0,G.useState)(()=>e===null||e.name===ln(e.rules,n,o)?``:e.name),[u,d]=(0,G.useState)(e===null?[pn(`platform`)]:[...e.rules]),[p,m]=(0,G.useState)(!1),h=ln(u,n,o),g=c.trim().length===0?h:c,_=un(g,n),v=u.map(fn),y=En.filter(e=>!u.some(t=>t.type===e)),b=_!==null||u.length===0||v.some(e=>e!==null);return(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),m(!0),!b&&r({name:g.trim(),rules:u.map(e=>e.type===`appVersion`?{...e,range:e.range.trim()}:e)})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add condition`:`Edit condition`}),(0,K.jsx)(Ne,{children:`A device matches when it matches every rule.`})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(L,{"data-invalid":p&&_!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${a}-name`,children:`Name`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${a}-name`,maxLength:101,onChange:e=>l(e.target.value),placeholder:h||`Beta testers on iOS`,value:c}),(0,K.jsx)(_e,{children:`Optional: without one, it is named after its rules.`}),(0,K.jsx)(I,{children:p?_:null})]}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Rules`}),u.length===0?(0,K.jsx)(I,{children:p?`Add at least one rule.`:null}):null,(0,K.jsx)(`ol`,{className:`flex flex-col gap-3`,children:u.map((e,n)=>(0,K.jsx)(`li`,{className:`rounded-lg border p-3`,children:(0,K.jsxs)(L,{"data-invalid":p&&v[n]!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:Y[e.type]}),(0,K.jsx)(t,{"aria-label":`Remove the ${Y[e.type].toLowerCase()} rule`,className:`size-11 sm:size-7`,onClick:()=>d(u.filter((e,t)=>t!==n)),size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]}),(0,K.jsx)(kn,{onChange:e=>d(u.map((t,r)=>r===n?e:t)),rule:e}),(0,K.jsx)(_e,{children:e.type===`dateTime`?`In your time zone, ${s}. ${An.dateTime}`:An[e.type]}),(0,K.jsx)(I,{children:p?v[n]:null})]})},e.type))}),y.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(y.map(e=>[e,Y[e]])),onValueChange:e=>{e!==null&&d([...u,pn(e)])},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a rule`,className:`min-h-11 w-full sm:min-h-9 sm:w-56`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a rule`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:y.map(e=>(0,K.jsx)(B,{value:e,children:Y[e]},e))})})]}):null]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{onClick:i,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(t,{type:`submit`,children:e===null?`Add condition`:`Save condition`})]})]})}function Nn({condition:e,dateTimeText:t}){let n=e.rules.map(e=>Jt(e,t)).join(` · `);return n===e.name?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}function Pn({template:e,onSaveCondition:n,onRemoveCondition:r,onMoveCondition:i}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),l=U(a),u=U(s),{dateTimeText:d}=Tn(),{conditions:f}=e,p=l?.condition?.name??null,m=t=>{let n=zt(e,t);n.length===0?r(t):c({name:t,users:n})};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Conditions`})}),(0,K.jsx)(pe,{className:`text-xs`,children:`Listed by priority: when several match a device, the first wins.`})]}),(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})]}),(0,K.jsx)(me,{className:`p-0`,children:f.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(ot,{children:`No conditions`}),(0,K.jsx)(st,{children:`Add a condition to give some devices other values: a platform, channel, app version range, cohort, or a share of installs.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})})]}):(0,K.jsx)(`ol`,{"aria-label":`Conditions`,className:`divide-y`,children:f.map((n,r)=>{let a=zt(e,n.name);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[auto_minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsx)(`span`,{"aria-label":`Priority ${r+1}`,className:`flex size-6 items-center justify-center rounded-md bg-muted text-xs font-medium tabular-nums`,children:r+1}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.name}),(0,K.jsx)(Nn,{condition:n,dateTimeText:d}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:a.length===0?`No parameter uses it yet`:`Sets ${a.length===1?`1 parameter`:`${a.length} parameters`}: ${a.slice(0,3).join(`, `)}${a.length>3?`…`:``}`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 md:justify-end`,children:[(0,K.jsx)(t,{"aria-label":`Move ${n.name} up`,className:`size-11 md:size-7`,disabled:r===0,onClick:()=>i(r,-1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(ut,{})}),(0,K.jsx)(t,{"aria-label":`Move ${n.name} down`,className:`size-11 md:size-7`,disabled:r===f.length-1,onClick:()=>i(r,1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(lt,{})}),(0,K.jsxs)(t,{"aria-label":`Edit ${n.name}`,className:`min-h-11 md:min-h-7`,onClick:()=>o({condition:n}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(t,{"aria-label":`Delete ${n.name}`,className:`size-11 md:size-7`,onClick:()=>m(n.name),size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]},n.name)})})}),(0,K.jsx)(jn,{condition:l?.condition??null,onOpenChange:e=>{e||o(null)},onSave:e=>n(p,e),open:a!==null,takenNames:f.map(({name:e})=>e).filter(e=>e!==p)}),(0,K.jsx)(ue,{onOpenChange:e=>{e||c(null)},open:s!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Delete `,u?.name,`?`]}),(0,K.jsxs)(ne,{children:[u?.users.length===1?`1 parameter has a value for it`:`${u?.users.length} parameters have a value for it`,` `,`(`,u?.users.join(`, `),`). Those values are removed too, so matching devices get the default value after you publish.`]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{children:`Cancel`}),(0,K.jsx)(oe,{onClick:e=>{e.preventDefault(),s!==null&&r(s.name),c(null)},variant:`destructive`,children:`Delete condition`})]})]})})]})}var Fn=e=>e===`BOOLEAN`?`false`:e===`NUMBER`?`0`:e===`JSON`?`{}`:``,In=(e,t)=>`value`in t?cn(e,t.value):null;function Ln({id:e,label:n,valueType:r,value:i,onChange:a,showErrors:o}){let s=!(`value`in i),c=`value`in i?i.value:``,l=o?In(r,i):null,u=e=>a({value:e});return(0,K.jsxs)(L,{"data-invalid":l!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(A,{htmlFor:e,id:`${e}-label`,children:n}),(0,K.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground sm:min-h-0`,children:[(0,K.jsx)(Je,{checked:s,id:`${e}-in-app-default`,onCheckedChange:e=>a(e?{useInAppDefault:!0}:{value:Fn(r)})}),(0,K.jsx)(`label`,{htmlFor:`${e}-in-app-default`,children:`Use in-app default`})]})]}),s?(0,K.jsxs)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,id:e,children:[`Devices keep the default set in the app's`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`remoteConfig(`,`{ defaults }`,`)`]}),`.`]}):r===`BOOLEAN`?(0,K.jsxs)(Cn,{"aria-labelledby":`${e}-label`,id:e,onValueChange:e=>{let[t]=e;(t===`true`||t===`false`)&&u(t)},value:[c],variant:`outline`,children:[(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`true`,children:`true`}),(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`false`,children:`false`})]}):r===`NUMBER`?(0,K.jsx)(f,{"aria-invalid":l!==null||void 0,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:e,inputMode:`decimal`,onChange:e=>u(e.target.value),value:c}):r===`JSON`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-24 font-mono text-xs`,id:e,onChange:e=>u(e.target.value),spellCheck:!1,value:c}),(0,K.jsxs)(t,{className:`self-start`,disabled:cn(`JSON`,c)!==null,onClick:()=>u(JSON.stringify(JSON.parse(c),null,2)),size:`sm`,type:`button`,variant:`outline`,children:[(0,K.jsx)(dt,{"data-icon":`inline-start`}),`Format JSON`]})]}):(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-11 text-sm sm:min-h-9`,id:e,onChange:e=>u(e.target.value),rows:2,value:c}),(0,K.jsx)(I,{children:l})]})}var Rn=Object.keys(J),zn={STRING:`getString`,NUMBER:`getNumber`,BOOLEAN:`getBoolean`,JSON:`getString`},Bn=(e,t)=>`value`in e&&In(t,e)!==null?{value:Fn(t)}:e;function Vn({open:e,onOpenChange:t,parameterKey:n,parameter:r,takenKeys:i,conditions:a,onSave:o,onAddCondition:s}){let c=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto data-nested-dialog-open:after:absolute data-nested-dialog-open:after:inset-0 data-nested-dialog-open:after:rounded-xl data-nested-dialog-open:after:bg-background/70 sm:max-w-2xl`,children:(0,K.jsx)(Hn,{conditions:a,onAddCondition:s,onCancel:()=>t(!1),onSave:(e,n)=>{o(e,n),t(!1)},parameter:r,parameterKey:n,takenKeys:i},c)})})}function Hn({parameterKey:e,parameter:n,takenKeys:r,conditions:i,onSave:a,onCancel:o,onAddCondition:s}){let c=(0,G.useId)(),{dateTimeText:l}=Tn(),[u,d]=(0,G.useState)(e??``),[p,m]=(0,G.useState)(n?.valueType??`STRING`),[h,g]=(0,G.useState)(n?.description??``),_=h.trim().length>256,[y,b]=(0,G.useState)(n?.defaultValue??{value:``}),[x,S]=(0,G.useState)(n?.conditionalValues??{}),[C,w]=(0,G.useState)({}),[T,ee]=(0,G.useState)(!1),[te,E]=(0,G.useState)(!1),D=sn(u.trim(),r),O=i.filter(({name:e})=>X(x,e)!==void 0),k=i.filter(({name:e})=>X(x,e)===void 0),ne=D!==null||_||[y,...Object.values(x)].some(e=>In(p,e)!==null),re=e=>{m(e),b(Bn(y,e)),S(Object.fromEntries(Object.entries(x).map(([t,n])=>[t,Bn(n,e)])))},ie=e=>{let t=X(C,e);S({...x,[e]:t===void 0?{value:Fn(p)}:Bn(t,p)})},ae=e=>{let{[e]:t,...n}=x;t!==void 0&&w({...C,[e]:t}),S(n)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),ee(!0),ne)return;let t=Object.fromEntries(O.map(({name:e})=>[e,X(x,e)]));a(u.trim(),{valueType:p,defaultValue:y,...Object.keys(t).length===0?{}:{conditionalValues:t},...h.trim().length===0?{}:{description:h.trim()}})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add parameter`:`Edit parameter`}),(0,K.jsxs)(Ne,{children:[`The app reads it with`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`hotUpdater.remoteConfig.`,zn[p],`("`,u.trim()||`key`,`")`]}),`, which is null when neither the server nor the app's defaults have a value.`]})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[minmax(0,1fr)_11rem]`,children:[(0,K.jsxs)(L,{"data-invalid":T&&D!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-key`,children:`Key`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${c}-key`,maxLength:257,onChange:e=>d(e.target.value),placeholder:`welcome_message`,spellCheck:!1,value:u}),(0,K.jsx)(I,{children:T?D:null})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${c}-type`,children:`Type`}),(0,K.jsxs)(Ee,{items:J,onValueChange:e=>{e!==null&&re(e)},value:p,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${c}-type`,children:(0,K.jsx)(we,{})}),(0,K.jsx)(Ce,{children:(0,K.jsx)(V,{children:Rn.map(e=>(0,K.jsx)(B,{value:e,children:J[e]},e))})})]})]})]}),(0,K.jsxs)(L,{"data-invalid":_||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-description`,children:`Description`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${c}-description`,onChange:e=>g(e.target.value),placeholder:`Optional: what the app does with it`,value:h}),(0,K.jsx)(I,{children:_?`Use 256 characters or fewer.`:null})]}),(0,K.jsx)(Ln,{id:`${c}-default`,label:`Default value`,onChange:b,showErrors:T,value:y,valueType:p}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Conditional values`}),(0,K.jsx)(_e,{children:`Devices that match a condition get its value. When several match, the first in the Conditions list wins. Removing a value keeps the condition, and its devices get the default value.`}),O.length>0?(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,children:O.map(e=>(0,K.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,K.jsx)(Nn,{condition:e,dateTimeText:l})]}),(0,K.jsxs)(t,{"aria-label":`Remove the value for ${e.name}`,className:`min-h-11 shrink-0 text-muted-foreground sm:min-h-7`,onClick:()=>ae(e.name),size:`sm`,type:`button`,variant:`ghost`,children:[(0,K.jsx)(v,{"data-icon":`inline-start`}),`Remove value`]})]}),(0,K.jsx)(Ln,{id:`${c}-${e.name}`,label:(0,K.jsxs)(K.Fragment,{children:[`Value`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]}),onChange:t=>S({...x,[e.name]:t}),showErrors:T,value:X(x,e.name),valueType:p})]},e.name))}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(k.map(({name:e})=>[e,e])),onValueChange:e=>{e!==null&&ie(e)},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a value for a condition`,className:`min-h-11 w-full sm:min-h-9 sm:w-64`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a value for a condition`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:k.map(({name:e})=>(0,K.jsx)(B,{value:e,children:e},e))})})]}):null,(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-9`,onClick:()=>E(!0),type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`New condition`]})]})]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{onClick:o,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(t,{type:`submit`,children:e===null?`Add parameter`:`Save parameter`})]})]}),(0,K.jsx)(jn,{condition:null,onOpenChange:E,onSave:e=>{s(e),ie(e.name)},open:te,takenNames:i.map(({name:e})=>e)})]})}function Un({text:e}){return(0,K.jsx)(`span`,{className:`line-clamp-2 block min-w-0 break-words font-mono text-xs text-foreground`,title:e,children:e})}function Wn({parameterKey:e,parameter:n,conditions:r,onEdit:i,onRemove:a}){let o=r.filter(({name:e})=>X(n.conditionalValues,e)!==void 0);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,15rem)_minmax(0,1fr)_auto] md:items-start`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,children:e}),(0,K.jsx)(P,{className:`shrink-0`,variant:`outline`,children:J[n.valueType]})]}),n.description===void 0?null:(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n.description})]}),(0,K.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[minmax(0,9rem)_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:[o.map(({name:e})=>(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`line-clamp-2 break-words text-muted-foreground`,title:e,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:(0,K.jsx)(Un,{text:Z(X(n.conditionalValues,e))})})]},e)),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Default`}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:`value`in n.defaultValue?(0,K.jsx)(Un,{text:Z(n.defaultValue)}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app default`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(t,{"aria-label":`Edit ${e}`,className:`min-h-11 md:min-h-7`,onClick:i,size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(t,{"aria-label":`Delete ${e}`,className:`size-11 md:size-7`,onClick:a,size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]})}function Gn({template:e,onSaveParameter:n,onRemoveParameter:r,onAddCondition:i}){let[a,o]=(0,G.useState)(null),s=U(a),[c,l]=(0,G.useState)(``),u=Object.keys(e.parameters),d=u.filter(e=>e.toLowerCase().includes(c.trim().toLowerCase())),f=s?.key??null;return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Parameters`})}),(0,K.jsxs)(`div`,{className:`flex w-full flex-wrap gap-2 sm:w-auto`,children:[u.length>5?(0,K.jsxs)(Ve,{className:`min-h-11 w-full sm:min-h-8 sm:w-56`,children:[(0,K.jsx)(Le,{children:(0,K.jsx)(He,{"aria-hidden":`true`})}),(0,K.jsx)(Ie,{"aria-label":`Filter parameters by key`,className:`text-base sm:text-xs`,onChange:e=>l(e.target.value),placeholder:`Filter by key`,value:c})]}):null,(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})]})]}),(0,K.jsx)(me,{className:`p-0`,children:u.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(qe,{})}),(0,K.jsx)(ot,{children:`No parameters`}),(0,K.jsx)(st,{children:`Add a parameter, give it a default, then publish to change the app without a new build.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})})]}):d.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-center text-xs text-muted-foreground`,children:[(0,K.jsx)(`p`,{className:`font-medium text-foreground`,children:`No matching keys`}),(0,K.jsx)(t,{onClick:()=>l(``),size:`sm`,variant:`outline`,children:`Clear filter`})]}):(0,K.jsx)(`ul`,{"aria-label":`Parameters`,className:`divide-y`,children:d.map(t=>(0,K.jsx)(Wn,{conditions:e.conditions,onEdit:()=>o({key:t,parameter:e.parameters[t]??null}),onRemove:()=>r(t),parameter:e.parameters[t],parameterKey:t},t))})}),(0,K.jsx)(Vn,{conditions:e.conditions,onAddCondition:i,onOpenChange:e=>{e||o(null)},onSave:(e,t)=>n(f,e,t),open:a!==null,parameter:s?.parameter??null,parameterKey:f,takenKeys:u.filter(e=>e!==f)})]})}var Kn={platform:`ios`,channel:`production`,appVersion:`1.0.0`,cohort:`1`,fingerprintHash:``,at:``},qn=(e,t=300)=>{let[n,r]=(0,G.useState)(e);return(0,G.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n};function Jn({template:e,isDraft:t}){let n=(0,G.useId)(),[r,i]=(0,G.useState)(Kn),{at:a,...o}=qn(r),c=qt(a),l=jt({template:e,context:{...o,...c===void 0?{}:{now:Date.parse(c)}}}),u=Object.keys(e.parameters),d=(e,t)=>i({...r,[e]:t});return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Preview a device`})}),(0,K.jsx)(pe,{className:`text-xs`,children:t?`The values this device would get once your changes are published, now or at the time you pick.`:`The values this device gets from the active version, now or at the time you pick.`})]}),(0,K.jsxs)(me,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-platform`,children:`Platform`}),(0,K.jsxs)(Ee,{items:{ios:`iOS`,android:`Android`},onValueChange:e=>{(e===`ios`||e===`android`)&&d(`platform`,e)},value:r.platform,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${n}-platform`,children:(0,K.jsxs)(we,{children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:r.platform}),r.platform===`ios`?`iOS`:`Android`]})}),(0,K.jsx)(Ce,{children:(0,K.jsxs)(V,{children:[(0,K.jsxs)(B,{value:`ios`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`ios`}),`iOS`]}),(0,K.jsxs)(B,{value:`android`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`android`}),`Android`]})]})})]})]}),[[`channel`,`Channel`,`production`],[`appVersion`,`App version`,`1.0.0`],[`cohort`,`Cohort`,`1-1000 or a name`],[`fingerprintHash`,`Fingerprint`,`Optional`]].map(([e,t,i])=>(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-${e}`,children:t}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 text-base sm:min-h-9 sm:text-xs`,id:`${n}-${e}`,onChange:t=>d(e,t.target.value),placeholder:i,spellCheck:!1,value:r[e]})]},e)),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-at`,children:`Time`}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 text-base tabular-nums sm:h-9 sm:text-xs`,id:`${n}-at`,onChange:e=>d(`at`,e.target.value),type:`datetime-local`,value:r.at}),r.at.length===0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{className:`min-h-11 sm:min-h-6`,onClick:()=>d(`at`,``),size:`xs`,children:`Now`})})]})]})]}),u.length===0?(0,K.jsx)(ct,{className:`border py-8`,children:(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(Ye,{})}),(0,K.jsx)(ot,{children:`Nothing to preview`}),(0,K.jsx)(st,{children:`Add a parameter, and its value for this device shows here.`})]})}):l.data?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The draft has problems to fix first`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:l.data.issues.slice(0,5).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):l.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The preview couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection, then change a field to try again.`})]}):l.data===void 0?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading the preview`}),u.slice(0,4).map(e=>(0,K.jsx)(s,{className:`h-8 w-full`},e))]}):(0,K.jsx)(`dl`,{"aria-busy":l.isFetching||void 0,className:`divide-y rounded-lg border`,children:u.map(e=>{let t=l.data.status===`ok`?l.data.parameters[e]:void 0;return(0,K.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,14rem)_minmax(0,1fr)_auto] sm:items-center sm:gap-3`,children:[(0,K.jsx)(`dt`,{className:`truncate font-mono text-xs font-medium`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-xs`,children:t===void 0?`…`:t.value===null?(0,K.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:`In-app default`}):(0,K.jsx)(`span`,{title:t.value,children:t.value.length===0?`""`:t.value})}),(0,K.jsx)(`dd`,{children:t?.condition===void 0?null:t.condition===null?(0,K.jsx)(P,{variant:`outline`,children:`Default value`}):(0,K.jsx)(P,{variant:`secondary`,children:t.condition})})]},e)})})]})]})}function Yn({name:e,fields:t}){return(0,K.jsxs)(`li`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`break-words font-mono`,children:e}),t.length===0?null:(0,K.jsx)(`ul`,{className:`mt-0.5 flex flex-col gap-0.5`,children:t.map(e=>(0,K.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:e.field}),e.before===null?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono line-through decoration-muted-foreground/60`,title:e.before,children:e.before}),(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`})]}),(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono text-foreground`,title:e.after,children:e.after})]},e.field))})]})}function Xn({label:e,changes:t,describe:n}){let r=[[`Added`,t.added],[`Changed`,t.changed],[`Removed`,t.removed]];return r.every(([,e])=>e.length===0)?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:e}),(0,K.jsx)(`dl`,{className:`mt-1 grid grid-cols-[5rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t.length===0?null:(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:e===`Removed`?(0,K.jsx)(`span`,{className:`break-words font-mono`,children:t.join(`, `)}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,K.jsx)(Yn,{fields:n(e),name:e},e))})})]},e))})]})}function Zn({open:e,onOpenChange:n,base:r,baseVersion:i,draft:a,onPublished:o,onLoadLatest:s,onPublishOver:c}){let l=(0,G.useId)(),u=kt(),[d,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(null),{dateTimeText:g}=Tn(),_=Zt(r,a),v=e=>{let t=Object.hasOwn(r.parameters,e)?r.parameters[e]:null,n=Object.hasOwn(a.parameters,e)?a.parameters[e]:null;return n===null?[]:Qt(t,n)},y=e=>{let t=r.conditions.find(t=>t.name===e)??null,n=a.conditions.find(t=>t.name===e)??null;return n===null?[]:$t(t,n,g)},b=d.trim().length>256,x=e=>{u.isPending||(n(e),e||(h(null),u.reset()))};return(0,K.jsx)(Pe,{onOpenChange:x,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-lg`,children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:async e=>{if(e.preventDefault(),!b)try{let e=await u.mutateAsync({template:a,baseVersion:i,...d.trim().length===0?{}:{description:d.trim()}});h(e),e.status===`published`&&(W.success(`Published version ${e.version.version}`),p(``),h(null),n(!1),o())}catch(e){W.error(e instanceof Error?e.message:`Unable to publish`)}},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:`Publish changes`}),(0,K.jsxs)(Ne,{children:[`This becomes version `,i+1,`. Devices get its values on their next fetch; earlier versions stay available to roll back to.`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,K.jsx)(Xn,{changes:_.parameters,describe:v,label:`Parameters`}),(0,K.jsx)(Xn,{changes:_.conditions,describe:y,label:`Conditions`}),_.reordered?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Condition priority changed.`}):null]}),m?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The server refused the template`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:m.issues.slice(0,6).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):null,m?.status===`conflict`?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,m.currentVersion,` was published while you edited`]}),(0,K.jsx)(N,{children:`Load it to review what changed, or publish yours after it, replacing its values.`}),(0,K.jsxs)(`div`,{className:`col-span-full mt-2 flex flex-wrap gap-2`,children:[(0,K.jsxs)(t,{onClick:()=>{x(!1),s()},size:`sm`,type:`button`,variant:`outline`,children:[`Load version `,m.currentVersion]}),(0,K.jsx)(t,{onClick:()=>{c(m.currentVersion),h(null)},size:`sm`,type:`button`,variant:`ghost`,children:`Publish mine after it`})]})]}):null,(0,K.jsxs)(L,{"data-invalid":b||void 0,children:[(0,K.jsx)(A,{htmlFor:`${l}-description`,children:`Description`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${l}-description`,onChange:e=>p(e.target.value),placeholder:`What changed and why`,value:d}),(0,K.jsx)(_e,{children:`Shown in the version history.`}),(0,K.jsx)(I,{children:b?`Use 256 characters or fewer.`:null})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{disabled:u.isPending,onClick:()=>x(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsxs)(t,{disabled:u.isPending||m?.status===`conflict`,type:`submit`,children:[u.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish version `,i+1]})]})]})})})}function Qn({ms:e}){let t=new Date(e);return(0,K.jsx)(`time`,{className:`tabular-nums`,dateTime:t.toISOString(),title:`${t.toISOString().replace(`T`,` `).slice(0,19)} UTC`,children:(0,_t.default)(e).format(`YYYY/MM/DD HH:mm`)})}function $n({open:e,version:n,onOpenChange:r}){let i=Dt(n),a=i.data===null||i.data===void 0?null:JSON.stringify(i.data.template,null,2);return(0,K.jsx)(Pe,{onOpenChange:r,open:e,children:(0,K.jsxs)(je,{className:`max-h-[calc(100svh-2rem)] grid-rows-[auto_minmax(0,1fr)] sm:max-w-2xl`,children:[(0,K.jsxs)(Oe,{children:[(0,K.jsxs)(Me,{children:[`Version `,n]}),(0,K.jsx)(Ne,{children:`The template as it was published, in the JSON the admin API takes.`})]}),i.isLoading?(0,K.jsx)(s,{className:`h-48 w-full`}):i.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`This version couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void i.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):a===null?(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,n,` no longer exists.`]}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-2`,children:[(0,K.jsx)(`pre`,{className:`min-h-0 overflow-auto rounded-md bg-muted p-3 font-mono text-xs`,children:a}),(0,K.jsxs)(t,{className:`self-end`,onClick:()=>{navigator.clipboard.writeText(a).then(()=>W.success(`Template JSON copied`),()=>W.error(`Unable to copy the template`))},size:`sm`,variant:`outline`,children:[(0,K.jsx)(De,{"data-icon":`inline-start`}),`Copy JSON`]})]})]})})}function er({activeVersion:e,hasDraft:n,onRolledBack:r,onStartEditing:i}){let a=Et({enabled:!0}),o=At(),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),f=U(c),p=U(u),m=a.data?.pages.flatMap(e=>e.versions)??[],h=async e=>{if(e.preventDefault(),u!==null)try{let e=await o.mutateAsync({version:u.source,baseVersion:u.next-1});e.status===`published`?(W.success(`Version ${e.version.version} restores version ${u.source}`),r()):e.status===`conflict`?W.error(`Version ${e.currentVersion} was published meanwhile. Review it, then roll back again.`):W.error(`That version no longer exists.`),d(null)}catch(e){W.error(e instanceof Error?e.message:`Unable to roll back`)}};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsx)(z,{className:`border-b px-4 py-3 sm:px-6`,children:(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Versions`})})}),(0,K.jsx)(me,{className:`p-0`,children:a.isError?(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Versions couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void a.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]})}):a.isLoading?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 sm:p-6`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading versions`}),Array.from({length:3},(e,t)=>(0,K.jsx)(s,{className:`h-10 w-full`},t))]}):m.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(mt,{})}),(0,K.jsx)(ot,{children:`No versions yet`}),(0,K.jsx)(st,{children:`Your first publish becomes version 1. Every publish after it is kept here, ready to roll back to.`})]}),(0,K.jsx)(at,{children:(0,K.jsx)(t,{className:`min-h-11 sm:min-h-7`,onClick:i,children:`Add a parameter`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ol`,{"aria-label":`Versions`,className:`divide-y`,children:m.map(n=>(0,K.jsxs)(`li`,{className:`grid gap-2 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium tabular-nums`,children:[`Version `,n.version]}),n.version===e?(0,K.jsx)(P,{children:`Active`}):null,n.updateType===`ROLLBACK`?(0,K.jsxs)(P,{variant:`outline`,children:[`Rollback to v`,n.rollbackSource]}):null]}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(Qn,{ms:n.createdAtMs}),n.description===null||n.updateType===`ROLLBACK`&&n.description===`Rollback to version ${n.rollbackSource}`?null:(0,K.jsxs)(K.Fragment,{children:[` · `,n.description]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(t,{"aria-label":`View version ${n.version}`,className:`min-h-11 md:min-h-7`,onClick:()=>l(n.version),size:`sm`,variant:`ghost`,children:[(0,K.jsx)(ft,{"data-icon":`inline-start`}),`View`]}),(0,K.jsxs)(t,{"aria-label":`Roll back to version ${n.version}`,className:`min-h-11 md:min-h-7`,disabled:n.version===e,onClick:()=>d({source:n.version,next:e+1}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]},n.version))}),a.hasNextPage?(0,K.jsx)(`div`,{className:`border-t px-4 py-3 sm:px-6`,children:(0,K.jsxs)(t,{className:`min-h-11 w-full sm:min-h-7 sm:w-auto`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),variant:`outline`,children:[a.isFetchingNextPage?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):null,`Load older versions`]})}):null]})}),(0,K.jsx)($n,{onOpenChange:e=>{e||l(null)},open:c!==null,version:f}),(0,K.jsx)(ue,{onOpenChange:e=>{!o.isPending&&!e&&d(null)},open:u!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Roll back to version `,p?.source,`?`]}),(0,K.jsxs)(ne,{children:[`Version `,p?.next,` will publish a copy of version`,` `,p?.source,`, and devices get its values on their next fetch.`,n?` Your unpublished changes are discarded.`:``]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{disabled:o.isPending,children:`Cancel`}),(0,K.jsxs)(oe,{disabled:o.isPending,onClick:e=>void h(e),children:[o.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]})})]})}_t.default.extend(vt.default);var tr=[`parameters`,`conditions`,`preview`,`versions`];function nr({tab:e,onTabChange:n}){let r=Tt(),[i,a]=(0,G.useState)(null),[o,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),p=r.data,m=i?.template??p?.template,h=i!==null&&p!==void 0&&!Mt(i.template,p.template),g=h&&p!==void 0&&i.baseVersion!==p.version;(0,G.useEffect)(()=>{if(o||p===void 0)return;c(!0);let e=rn(p);e!==null&&(a(e),u(!0))},[p,o]),(0,G.useEffect)(()=>{if(i===null||!h||an(i))return;let e=e=>e.preventDefault();return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[i,h]);let _=()=>{a(null),u(!1),an(null)},v=e=>{p===void 0||m===void 0||(u(!1),a({baseVersion:i?.baseVersion??p.version,base:i?.base??p.template,template:e(m)}))},y={parameters:m===void 0?null:Object.keys(m.parameters).length,conditions:m?.conditions.length??null};return(0,K.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 border-b bg-background px-3 py-3 sm:min-h-12 sm:bg-card/70 sm:px-4 sm:backdrop-blur-sm`,children:[(0,K.jsx)(x,{className:`-ml-1 size-11 lg:size-7`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(qe,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-sm font-medium`,children:`Remote Config`})]}),p===void 0?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p.version===0?`Nothing published yet`:(0,K.jsxs)(K.Fragment,{children:[`Version `,p.version,p.updatedAtMs===null?null:(0,K.jsxs)(K.Fragment,{children:[` · published `,(0,K.jsx)(`time`,{dateTime:new Date(p.updatedAtMs).toISOString(),title:(0,_t.default)(p.updatedAtMs).format(`YYYY/MM/DD HH:mm:ss`),children:(0,_t.default)(p.updatedAtMs).fromNow()})]})]})}),h?(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsx)(P,{className:`hidden sm:inline-flex`,variant:`secondary`,children:`Unpublished changes`}),(0,K.jsxs)(t,{className:`min-h-11 lg:min-h-7`,onClick:_,variant:`ghost`,children:[(0,K.jsx)(Xe,{"data-icon":`inline-start`}),`Discard`]}),(0,K.jsxs)(t,{className:`min-h-11 lg:min-h-7`,onClick:()=>f(!0),children:[(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish changes`]})]}):null]}),(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 p-3 sm:p-6`,children:(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4`,children:[r.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Remote Config couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void r.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):null,l&&h&&i!==null?(0,K.jsxs)(R,{children:[(0,K.jsx)(mt,{}),(0,K.jsx)(F,{children:`Your unpublished changes are back`}),(0,K.jsxs)(N,{children:[`This browser kept them from your last visit, on version`,` `,i.baseVersion,`.`]}),(0,K.jsx)(M,{children:(0,K.jsx)(t,{onClick:_,size:`xs`,variant:`outline`,children:`Discard them`})})]}):null,g&&i!==null&&p!==void 0?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,p.version,` was published while you edited`]}),(0,K.jsxs)(N,{children:[`Your draft started from version `,i.baseVersion,`. Discard it to review version `,p.version,`, or publish yours after it.`]}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:_,size:`xs`,variant:`outline`,children:[`Load version `,p.version]})})]}):null,(0,K.jsxs)(nt,{onValueChange:e=>n(e),value:e,children:[(0,K.jsx)(tt,{"aria-label":`Remote Config views`,className:`max-w-full group-data-horizontal/tabs:h-auto`,children:[[`parameters`,`Parameters`,y.parameters],[`conditions`,`Conditions`,y.conditions],[`preview`,`Preview`,null],[`versions`,`Versions`,null]].map(([e,t,n])=>(0,K.jsxs)(Qe,{className:`min-h-11 flex-none px-3 lg:min-h-7`,value:e,children:[t,n===null?null:(0,K.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n})]},e))}),m===void 0||p===void 0?r.isError?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading Remote Config`}),(0,K.jsx)(s,{className:`h-14 w-full`}),(0,K.jsx)(s,{className:`h-14 w-full`}),(0,K.jsx)(s,{className:`h-14 w-full`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($e,{value:`parameters`,children:(0,K.jsx)(Gn,{onAddCondition:e=>v(t=>It(t,null,e)),onRemoveParameter:e=>v(t=>Pt(t,e)),onSaveParameter:(e,t,n)=>v(r=>Nt(r,e,t,n)),template:m})}),(0,K.jsx)($e,{value:`conditions`,children:(0,K.jsx)(Pn,{onMoveCondition:(e,t)=>v(n=>Rt(n,e,t)),onRemoveCondition:e=>v(t=>Lt(t,e)),onSaveCondition:(e,t)=>v(n=>It(n,e,t)),template:m})}),(0,K.jsx)($e,{value:`preview`,children:(0,K.jsx)(Jn,{isDraft:h,template:m})}),(0,K.jsx)($e,{value:`versions`,children:(0,K.jsx)(er,{activeVersion:p.version,hasDraft:h,onRolledBack:_,onStartEditing:()=>n(`parameters`)})})]})]})]})}),p!==void 0&&i!==null?(0,K.jsx)(Zn,{base:p.template,baseVersion:i.baseVersion,draft:i.template,onLoadLatest:_,onOpenChange:f,onPublishOver:e=>a({...i,baseVersion:e,base:p.template}),onPublished:_,open:d}):null]})}var rr=E(`/remote-config`)({beforeLoad:({context:e})=>ee(e.queryClient,`remoteConfig`),notFoundComponent:k(()=>te(()=>import(`./remote-config-CXOi0LRu.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`notFoundComponent`),component:k(()=>te(()=>import(`./remote-config-CJPXuXOM.js`),__vite__mapDeps([7,2])),`component`),validateSearch:e=>tr.includes(e.tab)&&e.tab!==`parameters`?{tab:e.tab}:{}});export{nr as n,rr as t};
|
|
6
|
+
`)&&o(t.join(`, `)));let l=e=>{o(e),n(dn(e))};return i?(0,K.jsx)(Re,{className:`min-h-20 font-mono text-xs`,id:e,onChange:e=>l(e.target.value),placeholder:r,spellCheck:!1,value:a}):(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:e,onChange:e=>l(e.target.value),placeholder:r,value:a})}function On({id:e,label:n,value:r,presets:i,onChange:a}){return(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:e,children:n}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 tabular-nums sm:h-9`,id:e,onChange:e=>a(qt(e.target.value)),type:`datetime-local`,value:Kt(r)}),r===void 0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{"aria-label":`Clear ${n.toLowerCase()}`,className:`size-11 sm:size-5`,onClick:()=>a(void 0),size:`icon-xs`,children:(0,K.jsx)(v,{})})})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,K.jsx)(t,{"aria-pressed":e.iso===r,className:`min-h-11 sm:min-h-6`,onClick:()=>a(e.iso),size:`xs`,type:`button`,variant:e.iso===r?`secondary`:`outline`,children:e.label},e.label))})]})}function kn({rule:e,onChange:n}){let r=(0,G.useId)(),i=fe();switch(e.type){case`platform`:return(0,K.jsx)(Cn,{"aria-label":`Platforms`,multiple:!0,onValueChange:t=>n({...e,platforms:t.filter(e=>e===`ios`||e===`android`)}),value:[...e.platforms],variant:`outline`,children:[`ios`,`android`].map(e=>(0,K.jsxs)(wn,{className:`min-h-11 px-3 sm:min-h-8`,value:e,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:e}),e===`ios`?`iOS`:`Android`]},e))});case`channel`:{let a=(i.data??[]).map(({name:e})=>e).filter(t=>!e.channels.includes(t));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Dn,{id:`${r}-channels`,onChange:t=>n({...e,channels:t}),placeholder:`production, beta`,values:e.channels}),a.length>0?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Add:`}),a.slice(0,8).map(r=>(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-6`,onClick:()=>n({...e,channels:[...e.channels,r]}),size:`xs`,type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),r]},r))]}):null]})}case`appVersion`:return(0,K.jsx)(f,{"aria-label":`App version range`,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,onChange:t=>n({...e,range:t.target.value}),placeholder:`>=1.4.0`,value:e.range});case`cohort`:return(0,K.jsx)(Dn,{id:`${r}-cohorts`,onChange:t=>n({...e,cohorts:t}),placeholder:`1, 2, beta-testers`,values:e.cohorts});case`percent`:return(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[repeat(2,minmax(0,8rem))_minmax(0,1fr)]`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-from`,children:`From %`}),(0,K.jsx)(f,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-from`,inputMode:`decimal`,max:100,min:0,onChange:t=>n({...e,from:Number(t.target.value)}),step:.1,type:`number`,value:e.from})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-to`,children:`To %`}),(0,K.jsx)(f,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-to`,inputMode:`decimal`,max:100,min:0,onChange:t=>n({...e,to:Number(t.target.value)}),step:.1,type:`number`,value:e.to})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-seed`,children:`Seed`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${r}-seed`,onChange:t=>n({...e,seed:t.target.value}),value:e.seed}),(0,K.jsx)(t,{"aria-label":`New seed`,className:`size-11 sm:size-9`,onClick:()=>n({...e,seed:Yt()}),size:`icon`,type:`button`,variant:`outline`,children:(0,K.jsx)(Fe,{})})]})]})]});case`fingerprint`:return(0,K.jsx)(Dn,{id:`${r}-hashes`,multiline:!0,onChange:t=>n({...e,hashes:t}),placeholder:`One fingerprint hash per line`,values:e.hashes});case`dateTime`:{let t=(t,r)=>{let{[t]:i,...a}=e;n(r===void 0?a:{...a,[t]:r})};return(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsx)(On,{id:`${r}-from`,label:`From`,onChange:e=>t(`from`,e),presets:Wt(),value:e.from}),(0,K.jsx)(On,{id:`${r}-until`,label:`Until`,onChange:e=>t(`to`,e),presets:Gt(e.from),value:e.to})]})}}}var An={platform:`Devices on any of these platforms.`,channel:`Devices on any of these channels, separated by commas.`,appVersion:`A semver range of native app versions, as release targets use: 2.x, >=1.4.0 <2.0.0.`,percent:`Installs whose numeric cohort lands in this share. Rules with one seed split the same order, so 0–10 and 10–20 never overlap.`,cohort:`Numeric cohorts from 1 to 1000, or custom cohort names.`,fingerprint:`Native builds with any of these fingerprints.`,dateTime:`Leave either end empty to keep it open. Devices get the change at their next fetch.`};function jn({open:e,onOpenChange:t,condition:n,takenNames:r,onSave:i}){let a=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-xl`,children:(0,K.jsx)(Mn,{condition:n,onCancel:()=>t(!1),onSave:e=>{i(e),t(!1)},takenNames:r},a)})})}function Mn({condition:e,takenNames:n,onSave:r,onCancel:i}){let a=(0,G.useId)(),{dateTimeText:o,timeZone:s}=Tn(),[c,l]=(0,G.useState)(()=>e===null||e.name===ln(e.rules,n,o)?``:e.name),[u,d]=(0,G.useState)(e===null?[pn(`platform`)]:[...e.rules]),[p,m]=(0,G.useState)(!1),h=ln(u,n,o),g=c.trim().length===0?h:c,_=un(g,n),v=u.map(fn),y=En.filter(e=>!u.some(t=>t.type===e)),b=_!==null||u.length===0||v.some(e=>e!==null);return(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),m(!0),!b&&r({name:g.trim(),rules:u.map(e=>e.type===`appVersion`?{...e,range:e.range.trim()}:e)})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add condition`:`Edit condition`}),(0,K.jsx)(Ne,{children:`A device matches when it matches every rule.`})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(L,{"data-invalid":p&&_!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${a}-name`,children:`Name`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${a}-name`,maxLength:101,onChange:e=>l(e.target.value),placeholder:h||`Beta testers on iOS`,value:c}),(0,K.jsx)(_e,{children:`Optional: without one, it is named after its rules.`}),(0,K.jsx)(I,{children:p?_:null})]}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Rules`}),u.length===0?(0,K.jsx)(I,{children:p?`Add at least one rule.`:null}):null,(0,K.jsx)(`ol`,{className:`flex flex-col gap-3`,children:u.map((e,n)=>(0,K.jsx)(`li`,{className:`rounded-lg border p-3`,children:(0,K.jsxs)(L,{"data-invalid":p&&v[n]!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:Y[e.type]}),(0,K.jsx)(t,{"aria-label":`Remove the ${Y[e.type].toLowerCase()} rule`,className:`size-11 sm:size-7`,onClick:()=>d(u.filter((e,t)=>t!==n)),size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]}),(0,K.jsx)(kn,{onChange:e=>d(u.map((t,r)=>r===n?e:t)),rule:e}),(0,K.jsx)(_e,{children:e.type===`dateTime`?`In your time zone, ${s}. ${An.dateTime}`:An[e.type]}),(0,K.jsx)(I,{children:p?v[n]:null})]})},e.type))}),y.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(y.map(e=>[e,Y[e]])),onValueChange:e=>{e!==null&&d([...u,pn(e)])},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a rule`,className:`min-h-11 w-full sm:min-h-9 sm:w-56`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a rule`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:y.map(e=>(0,K.jsx)(B,{value:e,children:Y[e]},e))})})]}):null]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{onClick:i,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(t,{type:`submit`,children:e===null?`Add condition`:`Save condition`})]})]})}function Nn({condition:e,dateTimeText:t}){let n=e.rules.map(e=>Jt(e,t)).join(` · `);return n===e.name?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}function Pn({template:e,onSaveCondition:n,onRemoveCondition:r,onMoveCondition:i}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),l=U(a),u=U(s),{dateTimeText:d}=Tn(),{conditions:f}=e,p=l?.condition?.name??null,m=t=>{let n=zt(e,t);n.length===0?r(t):c({name:t,users:n})};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Conditions`})}),(0,K.jsx)(pe,{className:`text-xs`,children:`Listed by priority: when several match a device, the first wins.`})]}),(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})]}),(0,K.jsx)(me,{className:`p-0`,children:f.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(ot,{children:`No conditions`}),(0,K.jsx)(st,{children:`Add a condition to give some devices other values: a platform, channel, app version range, cohort, or a share of installs.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})})]}):(0,K.jsx)(`ol`,{"aria-label":`Conditions`,className:`divide-y`,children:f.map((n,r)=>{let a=zt(e,n.name);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[auto_minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsx)(`span`,{"aria-label":`Priority ${r+1}`,className:`flex size-6 items-center justify-center rounded-md bg-muted text-xs font-medium tabular-nums`,children:r+1}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.name}),(0,K.jsx)(Nn,{condition:n,dateTimeText:d}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:a.length===0?`No parameter uses it yet`:`Sets ${a.length===1?`1 parameter`:`${a.length} parameters`}: ${a.slice(0,3).join(`, `)}${a.length>3?`…`:``}`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 md:justify-end`,children:[(0,K.jsx)(t,{"aria-label":`Move ${n.name} up`,className:`size-11 md:size-7`,disabled:r===0,onClick:()=>i(r,-1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(ut,{})}),(0,K.jsx)(t,{"aria-label":`Move ${n.name} down`,className:`size-11 md:size-7`,disabled:r===f.length-1,onClick:()=>i(r,1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(lt,{})}),(0,K.jsxs)(t,{"aria-label":`Edit ${n.name}`,className:`min-h-11 md:min-h-7`,onClick:()=>o({condition:n}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(t,{"aria-label":`Delete ${n.name}`,className:`size-11 md:size-7`,onClick:()=>m(n.name),size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]},n.name)})})}),(0,K.jsx)(jn,{condition:l?.condition??null,onOpenChange:e=>{e||o(null)},onSave:e=>n(p,e),open:a!==null,takenNames:f.map(({name:e})=>e).filter(e=>e!==p)}),(0,K.jsx)(ue,{onOpenChange:e=>{e||c(null)},open:s!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Delete `,u?.name,`?`]}),(0,K.jsxs)(ne,{children:[u?.users.length===1?`1 parameter has a value for it`:`${u?.users.length} parameters have a value for it`,` `,`(`,u?.users.join(`, `),`). Those values are removed too, so matching devices get the default value after you publish.`]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{children:`Cancel`}),(0,K.jsx)(oe,{onClick:e=>{e.preventDefault(),s!==null&&r(s.name),c(null)},variant:`destructive`,children:`Delete condition`})]})]})})]})}var Fn=e=>e===`BOOLEAN`?`false`:e===`NUMBER`?`0`:e===`JSON`?`{}`:``,In=(e,t)=>`value`in t?cn(e,t.value):null;function Ln({id:e,label:n,valueType:r,value:i,onChange:a,showErrors:o}){let s=!(`value`in i),c=`value`in i?i.value:``,l=o?In(r,i):null,u=e=>a({value:e});return(0,K.jsxs)(L,{"data-invalid":l!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(A,{htmlFor:e,id:`${e}-label`,children:n}),(0,K.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground sm:min-h-0`,children:[(0,K.jsx)(Je,{checked:s,id:`${e}-in-app-default`,onCheckedChange:e=>a(e?{useInAppDefault:!0}:{value:Fn(r)})}),(0,K.jsx)(`label`,{htmlFor:`${e}-in-app-default`,children:`Use in-app default`})]})]}),s?(0,K.jsxs)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,id:e,children:[`Devices keep the default set in the app's`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`remoteConfig(`,`{ defaults }`,`)`]}),`.`]}):r===`BOOLEAN`?(0,K.jsxs)(Cn,{"aria-labelledby":`${e}-label`,id:e,onValueChange:e=>{let[t]=e;(t===`true`||t===`false`)&&u(t)},value:[c],variant:`outline`,children:[(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`true`,children:`true`}),(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`false`,children:`false`})]}):r===`NUMBER`?(0,K.jsx)(f,{"aria-invalid":l!==null||void 0,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:e,inputMode:`decimal`,onChange:e=>u(e.target.value),value:c}):r===`JSON`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-24 font-mono text-xs`,id:e,onChange:e=>u(e.target.value),spellCheck:!1,value:c}),(0,K.jsxs)(t,{className:`self-start`,disabled:cn(`JSON`,c)!==null,onClick:()=>u(JSON.stringify(JSON.parse(c),null,2)),size:`sm`,type:`button`,variant:`outline`,children:[(0,K.jsx)(dt,{"data-icon":`inline-start`}),`Format JSON`]})]}):(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-11 text-sm sm:min-h-9`,id:e,onChange:e=>u(e.target.value),rows:2,value:c}),(0,K.jsx)(I,{children:l})]})}var Rn=Object.keys(J),zn={STRING:`getString`,NUMBER:`getNumber`,BOOLEAN:`getBoolean`,JSON:`getString`},Bn=(e,t)=>`value`in e&&In(t,e)!==null?{value:Fn(t)}:e;function Vn({open:e,onOpenChange:t,parameterKey:n,parameter:r,takenKeys:i,conditions:a,onSave:o,onAddCondition:s}){let c=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto data-nested-dialog-open:after:absolute data-nested-dialog-open:after:inset-0 data-nested-dialog-open:after:rounded-xl data-nested-dialog-open:after:bg-background/70 sm:max-w-2xl`,children:(0,K.jsx)(Hn,{conditions:a,onAddCondition:s,onCancel:()=>t(!1),onSave:(e,n)=>{o(e,n),t(!1)},parameter:r,parameterKey:n,takenKeys:i},c)})})}function Hn({parameterKey:e,parameter:n,takenKeys:r,conditions:i,onSave:a,onCancel:o,onAddCondition:s}){let c=(0,G.useId)(),{dateTimeText:l}=Tn(),[u,d]=(0,G.useState)(e??``),[p,m]=(0,G.useState)(n?.valueType??`STRING`),[h,g]=(0,G.useState)(n?.description??``),_=h.trim().length>256,[y,b]=(0,G.useState)(n?.defaultValue??{value:``}),[x,S]=(0,G.useState)(n?.conditionalValues??{}),[C,w]=(0,G.useState)({}),[T,ee]=(0,G.useState)(!1),[te,E]=(0,G.useState)(!1),D=sn(u.trim(),r),O=i.filter(({name:e})=>X(x,e)!==void 0),k=i.filter(({name:e})=>X(x,e)===void 0),ne=D!==null||_||[y,...Object.values(x)].some(e=>In(p,e)!==null),re=e=>{m(e),b(Bn(y,e)),S(Object.fromEntries(Object.entries(x).map(([t,n])=>[t,Bn(n,e)])))},ie=e=>{let t=X(C,e);S({...x,[e]:t===void 0?{value:Fn(p)}:Bn(t,p)})},ae=e=>{let{[e]:t,...n}=x;t!==void 0&&w({...C,[e]:t}),S(n)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),ee(!0),ne)return;let t=Object.fromEntries(O.map(({name:e})=>[e,X(x,e)]));a(u.trim(),{valueType:p,defaultValue:y,...Object.keys(t).length===0?{}:{conditionalValues:t},...h.trim().length===0?{}:{description:h.trim()}})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add parameter`:`Edit parameter`}),(0,K.jsxs)(Ne,{children:[`The app reads it with`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`hotUpdater.remoteConfig.`,zn[p],`("`,u.trim()||`key`,`")`]}),`, which is null when neither the server nor the app's defaults have a value.`]})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[minmax(0,1fr)_11rem]`,children:[(0,K.jsxs)(L,{"data-invalid":T&&D!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-key`,children:`Key`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${c}-key`,maxLength:257,onChange:e=>d(e.target.value),placeholder:`welcome_message`,spellCheck:!1,value:u}),(0,K.jsx)(I,{children:T?D:null})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${c}-type`,children:`Type`}),(0,K.jsxs)(Ee,{items:J,onValueChange:e=>{e!==null&&re(e)},value:p,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${c}-type`,children:(0,K.jsx)(we,{})}),(0,K.jsx)(Ce,{children:(0,K.jsx)(V,{children:Rn.map(e=>(0,K.jsx)(B,{value:e,children:J[e]},e))})})]})]})]}),(0,K.jsxs)(L,{"data-invalid":_||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-description`,children:`Description`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${c}-description`,onChange:e=>g(e.target.value),placeholder:`Optional: what the app does with it`,value:h}),(0,K.jsx)(I,{children:_?`Use 256 characters or fewer.`:null})]}),(0,K.jsx)(Ln,{id:`${c}-default`,label:`Default value`,onChange:b,showErrors:T,value:y,valueType:p}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Conditional values`}),(0,K.jsx)(_e,{children:`Devices that match a condition get its value. When several match, the first in the Conditions list wins. Removing a value keeps the condition, and its devices get the default value.`}),O.length>0?(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,children:O.map(e=>(0,K.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,K.jsx)(Nn,{condition:e,dateTimeText:l})]}),(0,K.jsxs)(t,{"aria-label":`Remove the value for ${e.name}`,className:`min-h-11 shrink-0 text-muted-foreground sm:min-h-7`,onClick:()=>ae(e.name),size:`sm`,type:`button`,variant:`ghost`,children:[(0,K.jsx)(v,{"data-icon":`inline-start`}),`Remove value`]})]}),(0,K.jsx)(Ln,{id:`${c}-${e.name}`,label:(0,K.jsxs)(K.Fragment,{children:[`Value`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]}),onChange:t=>S({...x,[e.name]:t}),showErrors:T,value:X(x,e.name),valueType:p})]},e.name))}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(k.map(({name:e})=>[e,e])),onValueChange:e=>{e!==null&&ie(e)},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a value for a condition`,className:`min-h-11 w-full sm:min-h-9 sm:w-64`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a value for a condition`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:k.map(({name:e})=>(0,K.jsx)(B,{value:e,children:e},e))})})]}):null,(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-9`,onClick:()=>E(!0),type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`New condition`]})]})]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{onClick:o,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(t,{type:`submit`,children:e===null?`Add parameter`:`Save parameter`})]})]}),(0,K.jsx)(jn,{condition:null,onOpenChange:E,onSave:e=>{s(e),ie(e.name)},open:te,takenNames:i.map(({name:e})=>e)})]})}function Un({text:e}){return(0,K.jsx)(`span`,{className:`line-clamp-2 block min-w-0 break-words font-mono text-xs text-foreground`,title:e,children:e})}function Wn({parameterKey:e,parameter:n,conditions:r,onEdit:i,onRemove:a}){let o=r.filter(({name:e})=>X(n.conditionalValues,e)!==void 0);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,15rem)_minmax(0,1fr)_auto] md:items-start`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,children:e}),(0,K.jsx)(P,{className:`shrink-0`,variant:`outline`,children:J[n.valueType]})]}),n.description===void 0?null:(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n.description})]}),(0,K.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[minmax(0,9rem)_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:[o.map(({name:e})=>(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`line-clamp-2 break-words text-muted-foreground`,title:e,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:(0,K.jsx)(Un,{text:Z(X(n.conditionalValues,e))})})]},e)),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Default`}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:`value`in n.defaultValue?(0,K.jsx)(Un,{text:Z(n.defaultValue)}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app default`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(t,{"aria-label":`Edit ${e}`,className:`min-h-11 md:min-h-7`,onClick:i,size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(t,{"aria-label":`Delete ${e}`,className:`size-11 md:size-7`,onClick:a,size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]})}function Gn({template:e,onSaveParameter:n,onRemoveParameter:r,onAddCondition:i}){let[a,o]=(0,G.useState)(null),s=U(a),[c,l]=(0,G.useState)(``),u=Object.keys(e.parameters),d=u.filter(e=>e.toLowerCase().includes(c.trim().toLowerCase())),f=s?.key??null;return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Parameters`})}),(0,K.jsxs)(`div`,{className:`flex w-full flex-wrap gap-2 sm:w-auto`,children:[u.length>5?(0,K.jsxs)(Ve,{className:`min-h-11 w-full sm:min-h-8 sm:w-56`,children:[(0,K.jsx)(Le,{children:(0,K.jsx)(He,{"aria-hidden":`true`})}),(0,K.jsx)(Ie,{"aria-label":`Filter parameters by key`,className:`text-base sm:text-xs`,onChange:e=>l(e.target.value),placeholder:`Filter by key`,value:c})]}):null,(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})]})]}),(0,K.jsx)(me,{className:`p-0`,children:u.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(qe,{})}),(0,K.jsx)(ot,{children:`No parameters`}),(0,K.jsx)(st,{children:`Add a parameter, give it a default, then publish to change the app without a new build.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})})]}):d.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-center text-xs text-muted-foreground`,children:[(0,K.jsx)(`p`,{className:`font-medium text-foreground`,children:`No matching keys`}),(0,K.jsx)(t,{onClick:()=>l(``),size:`sm`,variant:`outline`,children:`Clear filter`})]}):(0,K.jsx)(`ul`,{"aria-label":`Parameters`,className:`divide-y`,children:d.map(t=>(0,K.jsx)(Wn,{conditions:e.conditions,onEdit:()=>o({key:t,parameter:e.parameters[t]??null}),onRemove:()=>r(t),parameter:e.parameters[t],parameterKey:t},t))})}),(0,K.jsx)(Vn,{conditions:e.conditions,onAddCondition:i,onOpenChange:e=>{e||o(null)},onSave:(e,t)=>n(f,e,t),open:a!==null,parameter:s?.parameter??null,parameterKey:f,takenKeys:u.filter(e=>e!==f)})]})}var Kn={platform:`ios`,channel:`production`,appVersion:`1.0.0`,cohort:`1`,fingerprintHash:``,at:``},qn=(e,t=300)=>{let[n,r]=(0,G.useState)(e);return(0,G.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n};function Jn({template:e,isDraft:t}){let n=(0,G.useId)(),[r,i]=(0,G.useState)(Kn),{at:a,...o}=qn(r),c=qt(a),l=jt({template:e,context:{...o,...c===void 0?{}:{now:Date.parse(c)}}}),u=Object.keys(e.parameters),d=(e,t)=>i({...r,[e]:t});return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Preview a device`})}),(0,K.jsx)(pe,{className:`text-xs`,children:t?`The values this device would get once your changes are published, now or at the time you pick.`:`The values this device gets from the active version, now or at the time you pick.`})]}),(0,K.jsxs)(me,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-platform`,children:`Platform`}),(0,K.jsxs)(Ee,{items:{ios:`iOS`,android:`Android`},onValueChange:e=>{(e===`ios`||e===`android`)&&d(`platform`,e)},value:r.platform,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${n}-platform`,children:(0,K.jsxs)(we,{children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:r.platform}),r.platform===`ios`?`iOS`:`Android`]})}),(0,K.jsx)(Ce,{children:(0,K.jsxs)(V,{children:[(0,K.jsxs)(B,{value:`ios`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`ios`}),`iOS`]}),(0,K.jsxs)(B,{value:`android`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`android`}),`Android`]})]})})]})]}),[[`channel`,`Channel`,`production`],[`appVersion`,`App version`,`1.0.0`],[`cohort`,`Cohort`,`1-1000 or a name`],[`fingerprintHash`,`Fingerprint`,`Optional`]].map(([e,t,i])=>(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-${e}`,children:t}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 text-base sm:min-h-9 sm:text-xs`,id:`${n}-${e}`,onChange:t=>d(e,t.target.value),placeholder:i,spellCheck:!1,value:r[e]})]},e)),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-at`,children:`Time`}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 text-base tabular-nums sm:h-9 sm:text-xs`,id:`${n}-at`,onChange:e=>d(`at`,e.target.value),type:`datetime-local`,value:r.at}),r.at.length===0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{className:`min-h-11 sm:min-h-6`,onClick:()=>d(`at`,``),size:`xs`,children:`Now`})})]})]})]}),u.length===0?(0,K.jsx)(ct,{className:`border py-8`,children:(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(Ye,{})}),(0,K.jsx)(ot,{children:`Nothing to preview`}),(0,K.jsx)(st,{children:`Add a parameter, and its value for this device shows here.`})]})}):l.data?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The draft has problems to fix first`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:l.data.issues.slice(0,5).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):l.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The preview couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection, then change a field to try again.`})]}):l.data===void 0?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading the preview`}),u.slice(0,4).map(e=>(0,K.jsx)(s,{className:`h-8 w-full`},e))]}):(0,K.jsx)(`dl`,{"aria-busy":l.isFetching||void 0,className:`divide-y rounded-lg border`,children:u.map(e=>{let t=l.data.status===`ok`?l.data.parameters[e]:void 0;return(0,K.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,14rem)_minmax(0,1fr)_auto] sm:items-center sm:gap-3`,children:[(0,K.jsx)(`dt`,{className:`truncate font-mono text-xs font-medium`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-xs`,children:t===void 0?`…`:t.value===null?(0,K.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:`In-app default`}):(0,K.jsx)(`span`,{title:t.value,children:t.value.length===0?`""`:t.value})}),(0,K.jsx)(`dd`,{children:t?.condition===void 0?null:t.condition===null?(0,K.jsx)(P,{variant:`outline`,children:`Default value`}):(0,K.jsx)(P,{variant:`secondary`,children:t.condition})})]},e)})})]})]})}function Yn({name:e,fields:t}){return(0,K.jsxs)(`li`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`break-words font-mono`,children:e}),t.length===0?null:(0,K.jsx)(`ul`,{className:`mt-0.5 flex flex-col gap-0.5`,children:t.map(e=>(0,K.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:e.field}),e.before===null?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono line-through decoration-muted-foreground/60`,title:e.before,children:e.before}),(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`})]}),(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono text-foreground`,title:e.after,children:e.after})]},e.field))})]})}function Xn({label:e,changes:t,describe:n}){let r=[[`Added`,t.added],[`Changed`,t.changed],[`Removed`,t.removed]];return r.every(([,e])=>e.length===0)?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:e}),(0,K.jsx)(`dl`,{className:`mt-1 grid grid-cols-[5rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t.length===0?null:(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:e===`Removed`?(0,K.jsx)(`span`,{className:`break-words font-mono`,children:t.join(`, `)}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,K.jsx)(Yn,{fields:n(e),name:e},e))})})]},e))})]})}function Zn({open:e,onOpenChange:n,base:r,baseVersion:i,draft:a,onPublished:o,onLoadLatest:s,onPublishOver:c}){let l=(0,G.useId)(),u=kt(),[d,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(null),{dateTimeText:g}=Tn(),_=Zt(r,a),v=e=>{let t=Object.hasOwn(r.parameters,e)?r.parameters[e]:null,n=Object.hasOwn(a.parameters,e)?a.parameters[e]:null;return n===null?[]:Qt(t,n)},y=e=>{let t=r.conditions.find(t=>t.name===e)??null,n=a.conditions.find(t=>t.name===e)??null;return n===null?[]:$t(t,n,g)},b=d.trim().length>256,x=e=>{u.isPending||(n(e),e||(h(null),u.reset()))};return(0,K.jsx)(Pe,{onOpenChange:x,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-lg`,children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:async e=>{if(e.preventDefault(),!b)try{let e=await u.mutateAsync({template:a,baseVersion:i,...d.trim().length===0?{}:{description:d.trim()}});h(e),e.status===`published`&&(W.success(`Published version ${e.version.version}`),p(``),h(null),n(!1),o())}catch(e){W.error(e instanceof Error?e.message:`Unable to publish`)}},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:`Publish changes`}),(0,K.jsxs)(Ne,{children:[`This becomes version `,i+1,`. Devices get its values on their next fetch; earlier versions stay available to roll back to.`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,K.jsx)(Xn,{changes:_.parameters,describe:v,label:`Parameters`}),(0,K.jsx)(Xn,{changes:_.conditions,describe:y,label:`Conditions`}),_.reordered?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Condition priority changed.`}):null]}),m?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The server refused the template`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:m.issues.slice(0,6).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):null,m?.status===`conflict`?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,m.currentVersion,` was published while you edited`]}),(0,K.jsx)(N,{children:`Load it to review what changed, or publish yours after it, replacing its values.`}),(0,K.jsxs)(`div`,{className:`col-span-full mt-2 flex flex-wrap gap-2`,children:[(0,K.jsxs)(t,{onClick:()=>{x(!1),s()},size:`sm`,type:`button`,variant:`outline`,children:[`Load version `,m.currentVersion]}),(0,K.jsx)(t,{onClick:()=>{c(m.currentVersion),h(null)},size:`sm`,type:`button`,variant:`ghost`,children:`Publish mine after it`})]})]}):null,(0,K.jsxs)(L,{"data-invalid":b||void 0,children:[(0,K.jsx)(A,{htmlFor:`${l}-description`,children:`Description`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${l}-description`,onChange:e=>p(e.target.value),placeholder:`What changed and why`,value:d}),(0,K.jsx)(_e,{children:`Shown in the version history.`}),(0,K.jsx)(I,{children:b?`Use 256 characters or fewer.`:null})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{disabled:u.isPending,onClick:()=>x(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsxs)(t,{disabled:u.isPending||m?.status===`conflict`,type:`submit`,children:[u.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish version `,i+1]})]})]})})})}function Qn({ms:e}){let t=new Date(e);return(0,K.jsx)(`time`,{className:`tabular-nums`,dateTime:t.toISOString(),title:`${t.toISOString().replace(`T`,` `).slice(0,19)} UTC`,children:(0,_t.default)(e).format(`YYYY/MM/DD HH:mm`)})}function $n({open:e,version:n,onOpenChange:r}){let i=Dt(n),a=i.data===null||i.data===void 0?null:JSON.stringify(i.data.template,null,2);return(0,K.jsx)(Pe,{onOpenChange:r,open:e,children:(0,K.jsxs)(je,{className:`max-h-[calc(100svh-2rem)] grid-rows-[auto_minmax(0,1fr)] sm:max-w-2xl`,children:[(0,K.jsxs)(Oe,{children:[(0,K.jsxs)(Me,{children:[`Version `,n]}),(0,K.jsx)(Ne,{children:`The template as it was published, in the JSON the admin API takes.`})]}),i.isLoading?(0,K.jsx)(s,{className:`h-48 w-full`}):i.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`This version couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void i.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):a===null?(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,n,` no longer exists.`]}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-2`,children:[(0,K.jsx)(`pre`,{className:`min-h-0 overflow-auto rounded-md bg-muted p-3 font-mono text-xs`,children:a}),(0,K.jsxs)(t,{className:`self-end`,onClick:()=>{navigator.clipboard.writeText(a).then(()=>W.success(`Template JSON copied`),()=>W.error(`Unable to copy the template`))},size:`sm`,variant:`outline`,children:[(0,K.jsx)(De,{"data-icon":`inline-start`}),`Copy JSON`]})]})]})})}function er({activeVersion:e,hasDraft:n,onRolledBack:r,onStartEditing:i}){let a=Et({enabled:!0}),o=At(),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),f=U(c),p=U(u),m=a.data?.pages.flatMap(e=>e.versions)??[],h=async e=>{if(e.preventDefault(),u!==null)try{let e=await o.mutateAsync({version:u.source,baseVersion:u.next-1});e.status===`published`?(W.success(`Version ${e.version.version} restores version ${u.source}`),r()):e.status===`conflict`?W.error(`Version ${e.currentVersion} was published meanwhile. Review it, then roll back again.`):W.error(`That version no longer exists.`),d(null)}catch(e){W.error(e instanceof Error?e.message:`Unable to roll back`)}};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsx)(z,{className:`border-b px-4 py-3 sm:px-6`,children:(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Versions`})})}),(0,K.jsx)(me,{className:`p-0`,children:a.isError?(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Versions couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void a.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]})}):a.isLoading?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 sm:p-6`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading versions`}),Array.from({length:3},(e,t)=>(0,K.jsx)(s,{className:`h-10 w-full`},t))]}):m.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(mt,{})}),(0,K.jsx)(ot,{children:`No versions yet`}),(0,K.jsx)(st,{children:`Your first publish becomes version 1. Every publish after it is kept here, ready to roll back to.`})]}),(0,K.jsx)(at,{children:(0,K.jsx)(t,{className:`min-h-11 sm:min-h-7`,onClick:i,children:`Add a parameter`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ol`,{"aria-label":`Versions`,className:`divide-y`,children:m.map(n=>(0,K.jsxs)(`li`,{className:`grid gap-2 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium tabular-nums`,children:[`Version `,n.version]}),n.version===e?(0,K.jsx)(P,{children:`Active`}):null,n.updateType===`ROLLBACK`?(0,K.jsxs)(P,{variant:`outline`,children:[`Rollback to v`,n.rollbackSource]}):null]}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(Qn,{ms:n.createdAtMs}),n.description===null||n.updateType===`ROLLBACK`&&n.description===`Rollback to version ${n.rollbackSource}`?null:(0,K.jsxs)(K.Fragment,{children:[` · `,n.description]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(t,{"aria-label":`View version ${n.version}`,className:`min-h-11 md:min-h-7`,onClick:()=>l(n.version),size:`sm`,variant:`ghost`,children:[(0,K.jsx)(ft,{"data-icon":`inline-start`}),`View`]}),(0,K.jsxs)(t,{"aria-label":`Roll back to version ${n.version}`,className:`min-h-11 md:min-h-7`,disabled:n.version===e,onClick:()=>d({source:n.version,next:e+1}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]},n.version))}),a.hasNextPage?(0,K.jsx)(`div`,{className:`border-t px-4 py-3 sm:px-6`,children:(0,K.jsxs)(t,{className:`min-h-11 w-full sm:min-h-7 sm:w-auto`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),variant:`outline`,children:[a.isFetchingNextPage?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):null,`Load older versions`]})}):null]})}),(0,K.jsx)($n,{onOpenChange:e=>{e||l(null)},open:c!==null,version:f}),(0,K.jsx)(ue,{onOpenChange:e=>{!o.isPending&&!e&&d(null)},open:u!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Roll back to version `,p?.source,`?`]}),(0,K.jsxs)(ne,{children:[`Version `,p?.next,` will publish a copy of version`,` `,p?.source,`, and devices get its values on their next fetch.`,n?` Your unpublished changes are discarded.`:``]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{disabled:o.isPending,children:`Cancel`}),(0,K.jsxs)(oe,{disabled:o.isPending,onClick:e=>void h(e),children:[o.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]})})]})}_t.default.extend(vt.default);var tr=[`parameters`,`conditions`,`preview`,`versions`];function nr({tab:e,onTabChange:n}){let r=Tt(),[i,a]=(0,G.useState)(null),[o,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),p=r.data,m=i?.template??p?.template,h=i!==null&&p!==void 0&&!Mt(i.template,p.template),g=h&&p!==void 0&&i.baseVersion!==p.version;(0,G.useEffect)(()=>{if(o||p===void 0)return;c(!0);let e=rn(p);e!==null&&(a(e),u(!0))},[p,o]),(0,G.useEffect)(()=>{if(i===null||!h||an(i))return;let e=e=>e.preventDefault();return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[i,h]);let _=()=>{a(null),u(!1),an(null)},v=e=>{p===void 0||m===void 0||(u(!1),a({baseVersion:i?.baseVersion??p.version,base:i?.base??p.template,template:e(m)}))},y={parameters:m===void 0?null:Object.keys(m.parameters).length,conditions:m?.conditions.length??null};return(0,K.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 border-b bg-background px-3 py-3 sm:min-h-12 sm:bg-card/70 sm:px-4 sm:backdrop-blur-sm`,children:[(0,K.jsx)(x,{className:`-ml-1 size-11 lg:size-7`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(qe,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-sm font-medium`,children:`Remote Config`})]}),p===void 0?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p.version===0?`Nothing published yet`:(0,K.jsxs)(K.Fragment,{children:[`Version `,p.version,p.updatedAtMs===null?null:(0,K.jsxs)(K.Fragment,{children:[` · published `,(0,K.jsx)(`time`,{dateTime:new Date(p.updatedAtMs).toISOString(),title:(0,_t.default)(p.updatedAtMs).format(`YYYY/MM/DD HH:mm:ss`),children:(0,_t.default)(p.updatedAtMs).fromNow()})]})]})}),h?(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsx)(P,{className:`hidden sm:inline-flex`,variant:`secondary`,children:`Unpublished changes`}),(0,K.jsxs)(t,{className:`min-h-11 lg:min-h-7`,onClick:_,variant:`ghost`,children:[(0,K.jsx)(Xe,{"data-icon":`inline-start`}),`Discard`]}),(0,K.jsxs)(t,{className:`min-h-11 lg:min-h-7`,onClick:()=>f(!0),children:[(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish changes`]})]}):null]}),(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 p-3 sm:p-6`,children:(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4`,children:[r.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Remote Config couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void r.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):null,l&&h&&i!==null?(0,K.jsxs)(R,{children:[(0,K.jsx)(mt,{}),(0,K.jsx)(F,{children:`Your unpublished changes are back`}),(0,K.jsxs)(N,{children:[`This browser kept them from your last visit, on version`,` `,i.baseVersion,`.`]}),(0,K.jsx)(M,{children:(0,K.jsx)(t,{onClick:_,size:`xs`,variant:`outline`,children:`Discard them`})})]}):null,g&&i!==null&&p!==void 0?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,p.version,` was published while you edited`]}),(0,K.jsxs)(N,{children:[`Your draft started from version `,i.baseVersion,`. Discard it to review version `,p.version,`, or publish yours after it.`]}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:_,size:`xs`,variant:`outline`,children:[`Load version `,p.version]})})]}):null,(0,K.jsxs)(nt,{onValueChange:e=>n(e),value:e,children:[(0,K.jsx)(tt,{"aria-label":`Remote Config views`,className:`max-w-full group-data-horizontal/tabs:h-auto`,children:[[`parameters`,`Parameters`,y.parameters],[`conditions`,`Conditions`,y.conditions],[`preview`,`Preview`,null],[`versions`,`Versions`,null]].map(([e,t,n])=>(0,K.jsxs)(Qe,{className:`min-h-11 flex-none px-3 lg:min-h-7`,value:e,children:[t,n===null?null:(0,K.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n})]},e))}),m===void 0||p===void 0?r.isError?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading Remote Config`}),(0,K.jsx)(s,{className:`h-14 w-full`}),(0,K.jsx)(s,{className:`h-14 w-full`}),(0,K.jsx)(s,{className:`h-14 w-full`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($e,{value:`parameters`,children:(0,K.jsx)(Gn,{onAddCondition:e=>v(t=>It(t,null,e)),onRemoveParameter:e=>v(t=>Pt(t,e)),onSaveParameter:(e,t,n)=>v(r=>Nt(r,e,t,n)),template:m})}),(0,K.jsx)($e,{value:`conditions`,children:(0,K.jsx)(Pn,{onMoveCondition:(e,t)=>v(n=>Rt(n,e,t)),onRemoveCondition:e=>v(t=>Lt(t,e)),onSaveCondition:(e,t)=>v(n=>It(n,e,t)),template:m})}),(0,K.jsx)($e,{value:`preview`,children:(0,K.jsx)(Jn,{isDraft:h,template:m})}),(0,K.jsx)($e,{value:`versions`,children:(0,K.jsx)(er,{activeVersion:p.version,hasDraft:h,onRolledBack:_,onStartEditing:()=>n(`parameters`)})})]})]})]})}),p!==void 0&&i!==null?(0,K.jsx)(Zn,{base:p.template,baseVersion:i.baseVersion,draft:i.template,onLoadLatest:_,onOpenChange:f,onPublishOver:e=>a({...i,baseVersion:e,base:p.template}),onPublished:_,open:d}):null]})}var rr=E(`/remote-config`)({beforeLoad:({context:e})=>ee(e.queryClient,`remoteConfig`),notFoundComponent:k(()=>te(()=>import(`./remote-config-CXOi0LRu.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`notFoundComponent`),component:k(()=>te(()=>import(`./remote-config-BWwHOkCK.js`),__vite__mapDeps([7,2])),`component`),validateSearch:e=>tr.includes(e.tab)&&e.tab!==`parameters`?{tab:e.tab}:{}});export{nr as n,rr as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/routes-
|
|
2
|
-
import{In as e,Ln as t,Nn as n,Pn as r,Ur as i,Wr as a,ar as o,cr as s,nr as c,rr as l}from"./sidebar-DNVyJPfX.js";import{a as u,i as d,l as f,o as p}from"./console-features-api-BH5m_PtQ.js";import{a as ee,c as m,s as h}from"./useCompositeListItem-9E4pj_CH.js";import{_ as g,m as _,s as v,x as y}from"./insights-api-BigAU9sZ.js";import{_ as b,h as x,m as S,v as C,y as w}from"./field-BBDpjIqu.js";import{t as T}from"./key-round-wS_SIZ6b.js";import{s as te}from"./switch-DZ1TPwx-.js";import{n as E,t as D}from"./InsightsInfo-BNO0WznZ.js";var O=o(`chart-line`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]]),k=o(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),A=i(),j={apiKeys:{navigation:{icon:(0,A.jsx)(T,{}),paths:[`/api-keys`],link:({onClick:e})=>(0,A.jsx)(f,{to:`/api-keys`,onClick:e})}}},M=l({method:`GET`}).middleware([c]).handler(a(`b4bf4c461903edcdc44eea52468c737b5b600a586f542138ff022dcbbe86c45c`));function N(e){let t=e.map(({releaseId:e,platform:t,channel:n})=>({releaseId:e,platform:t,channel:n})).sort((e,t)=>e.releaseId.localeCompare(t.releaseId));return s({queryKey:[`bundle-activity`,t],queryFn:()=>M({data:t}),enabled:t.length>0,staleTime:3e4})}var P=[{label:`Downloaded`,field:`downloads`,color:`text-primary/85`},{label:`Launched`,field:`launched`,color:`text-success/85`},{label:`Crashed`,field:`failedLaunches`,color:`text-warning/85`}],F=e=>{let t=e.launched+e.failedLaunches;return t===0?`—`:`${(e.failedLaunches/t*100).toFixed(2)}%`},I=e=>Math.max(0,e.downloads-e.launched-e.failedLaunches);function L(){return(0,A.jsx)(D,{label:`About release insight metrics`,children:`Downloaded: got this bundle. Launched: ran it. Crashed: crashed on it and rolled back. Once every installation restarts, Downloaded = Launched + Crashed.`})}function R({report:e,loading:r=!1,input:i,variant:a=`inline`}){if(!e)return r?(0,A.jsx)(n,{"aria-label":`Loading release insights`,className:a===`card`?`h-16 w-full`:`h-4 w-40`}):(0,A.jsx)(`span`,{"aria-label":`Release insights unavailable`,className:`text-sm text-muted-foreground`,children:`—`});let o=i?.builtIn===!0,s=o?0:I(e),c=(0,A.jsx)(`dl`,{className:t(a===`card`?`grid grid-cols-[1fr_1fr_auto] gap-4`:`flex min-w-[220px] flex-wrap items-baseline gap-x-3 gap-y-1`),children:P.map(({label:n,field:r,color:i})=>(0,A.jsxs)(`div`,{className:t(`flex`,a===`card`?`min-w-0 flex-col gap-1`:`items-baseline gap-1.5 whitespace-nowrap`),children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n}),(0,A.jsxs)(`dd`,{className:t(`flex flex-wrap items-baseline gap-x-1.5 tabular-nums`,a===`card`?`text-xl font-semibold`:`text-sm font-medium`,e[r]>0&&!(r===`downloads`&&o)?i:`text-muted-foreground`),children:[r===`downloads`&&o?(0,A.jsx)(`span`,{title:`The built-in bundle is never downloaded`,children:`—`}):e[r].toLocaleString(),r===`failedLaunches`?(0,A.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,F(e),`)`]}):null]})]},r))});return(0,A.jsxs)(`div`,{className:t(`flex`,a===`card`?`flex-col gap-2`:`items-center gap-1`),children:[i?(0,A.jsx)(f,{className:`min-w-0 rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,to:`/insights`,search:{healthPlatform:i.platform,healthChannel:i.channel,releaseId:i.releaseId,bundleWindow:E(i.releaseId)},children:c}):c,a===`card`&&s>0?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s.toLocaleString(),` downloaded but not launched yet: waiting for a restart, or passed over for a newer bundle.`]}):null,a===`inline`?(0,A.jsx)(L,{}):null]})}function z({input:e}){let r=v({platform:e.platform,channel:e.channel,releaseId:e.releaseId}),i=r.data;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i?(0,A.jsx)(`dl`,{children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Download failures`}),(0,A.jsxs)(`dd`,{className:t(`flex items-baseline gap-1.5 text-sm font-medium tabular-nums`,i.failedUpdates>0?`text-warning/85`:`text-muted-foreground`),children:[i.failedUpdates.toLocaleString(),(0,A.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,g(_(i)),`)`]})]})]})}):r.isPending?(0,A.jsx)(n,{"aria-label":`Loading download failures`,className:`h-4 w-40`}):(0,A.jsx)(`span`,{"aria-label":`Download failures unavailable`,className:`text-sm text-muted-foreground`,children:`—`}),(0,A.jsx)(D,{label:`About download failures`,children:`Failed downloads or installs of this bundle, at most one per installation a day. Rate = failures ÷ (failures + downloads).`})]})}function B({input:t}){let n=N([t]);return(0,A.jsxs)(S,{children:[(0,A.jsxs)(C,{className:`flex-row items-center justify-between px-4 pt-4 pb-3`,children:[(0,A.jsx)(w,{className:`text-sm font-medium`,children:`Insights`}),(0,A.jsx)(L,{})]}),(0,A.jsxs)(x,{className:`flex flex-col gap-3 px-4 pb-4`,children:[(0,A.jsx)(R,{variant:`card`,input:t,loading:n.isFetching,report:n.data?.[t.releaseId]}),(0,A.jsx)(r,{}),(0,A.jsx)(z,{input:t})]}),(0,A.jsx)(b,{className:`px-4 pb-4`,children:(0,A.jsxs)(f,{className:e({variant:`outline`,size:`sm`}),to:`/insights`,search:{healthPlatform:t.platform,healthChannel:t.channel,releaseId:t.releaseId,bundleWindow:E(t.releaseId),healthChart:`adoption`},children:[(0,A.jsx)(O,{"aria-hidden":`true`,"data-icon":`inline-start`}),`View adoption`]})})]})}function V({input:e}){return d(`insightsAnalytics`)?null:(0,A.jsxs)(S,{children:[(0,A.jsx)(C,{className:`px-4 pt-4 pb-3`,children:(0,A.jsx)(w,{className:`text-sm font-medium`,children:`Insights`})}),(0,A.jsx)(x,{className:`px-4 pb-4`,children:(0,A.jsx)(z,{input:e})})]})}function H({releaseId:e,releases:t}){let n=N(t);return(0,A.jsx)(R,{input:t.find(t=>t.releaseId===e),loading:n.isFetching,report:n.data?.[e]})}var U={Cell:H},W={insights:{navigation:{icon:(0,A.jsx)(y,{}),paths:[`/insights`,`/insights/distribution`,`/installations`],link:({features:e,onClick:t})=>e.insightsAnalytics?(0,A.jsx)(f,{to:`/insights`,onClick:t}):(0,A.jsx)(f,{to:`/installations`,onClick:t})},releaseSection:({release:e})=>(0,A.jsx)(V,{input:e})},insightsAnalytics:{releaseColumn:U,releaseSection:({release:e})=>(0,A.jsx)(B,{input:e})}},G={remoteConfig:{navigation:{icon:(0,A.jsx)(te,{}),paths:[`/remote-config`],link:({onClick:e})=>(0,A.jsx)(f,{to:`/remote-config`,onClick:e})}}},K={...W,...j,...G},q=Object.keys(p),J=()=>{let e=u().data?.features;return e===void 0?[]:q.flatMap(t=>{let n=K[t];return n!==void 0&&e[t]?[{...n,feature:t,label:p[t].label,features:e}]:[]})},Y=()=>J().flatMap(({feature:e,label:t,releaseColumn:n})=>n===void 0?[]:[{...n,feature:e,label:t}]);function X({release:e}){return J().map(({feature:t,releaseSection:n})=>n===void 0?null:(0,A.jsx)(n,{release:e},t))}var Z=e=>typeof e==`string`&&e.trim().length>0?e.trim():void 0;function Q(e){let t=Z(e.beforeReleaseId),n=t?void 0:Z(e.afterReleaseId),r=e.enabled===!0||e.enabled===`true`?!0:e.enabled===!1||e.enabled===`false`?!1:void 0,i=Z(e.bundleId),a=i?void 0:Z(e.scopeKey),o=i||a?void 0:Z(e.channelId),s=o===void 0?void 0:e.platform===`android`?`android`:`ios`;return{afterReleaseId:n,beforeReleaseId:t,bundleId:i,channelId:o,enabled:a||o?r:void 0,platform:s,releaseId:Z(e.releaseId),scopeKey:a}}function $(e){let t=e.enabled===void 0?{}:{enabled:e.enabled};return e.bundleId?{kind:`bundle`,bundleId:e.bundleId}:e.scopeKey?{kind:`scope`,scopeKey:e.scopeKey,...t}:e.channelId&&e.platform?{kind:`channelPlatform`,channelId:e.channelId,platform:e.platform,...t}:{kind:`all`}}function ne(e){return $(e).kind!==`all`}function re(e,t){let n={...e,...t};return t.bundleId?Q({bundleId:n.bundleId}):t.scopeKey?Q({scopeKey:n.scopeKey,enabled:n.enabled}):`channelId`in t||`platform`in t?Q({channelId:n.channelId,enabled:n.enabled,platform:n.platform}):Q({bundleId:n.bundleId,channelId:n.channelId,enabled:n.enabled,platform:n.platform,scopeKey:n.scopeKey})}var ie=m(`/`)({component:h(()=>ee(()=>import(`./routes-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/routes-Cnc-0wCf.js","assets/sidebar-DNVyJPfX.js","assets/useCompositeListItem-9E4pj_CH.js","assets/console-features-api-BH5m_PtQ.js","assets/alert-dialog-Bbk_4-WJ.js","assets/select-BZZBXMkr.js","assets/field-BBDpjIqu.js","assets/switch-DZ1TPwx-.js","assets/valueToPercent-CH8GCHaL.js","assets/api-DCM0wr6O.js","assets/chevron-right-BqD5wtFb.js","assets/HashValueDisplay-BFX_kY3-.js","assets/dist-LxKJB-Vu.js","assets/list-CgrYiadM.js","assets/dialog-Bqbb7B0N.js","assets/input-group-ja_30qaF.js","assets/InsightsInfo-BNO0WznZ.js","assets/insights-api-BigAU9sZ.js","assets/table-Gm4qRWwE.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{In as e,Ln as t,Nn as n,Pn as r,Ur as i,Wr as a,ar as o,cr as s,nr as c,rr as l}from"./sidebar-DNVyJPfX.js";import{a as u,i as d,l as f,o as p}from"./console-features-api-BH5m_PtQ.js";import{a as ee,c as m,s as h}from"./useCompositeListItem-9E4pj_CH.js";import{_ as g,m as _,s as v,x as y}from"./insights-api-BigAU9sZ.js";import{_ as b,h as x,m as S,v as C,y as w}from"./field-BBDpjIqu.js";import{t as T}from"./key-round-wS_SIZ6b.js";import{s as te}from"./switch-DZ1TPwx-.js";import{n as E,t as D}from"./InsightsInfo-BNO0WznZ.js";var O=o(`chart-line`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]]),k=o(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),A=i(),j={apiKeys:{navigation:{icon:(0,A.jsx)(T,{}),paths:[`/api-keys`],link:({onClick:e})=>(0,A.jsx)(f,{to:`/api-keys`,onClick:e})}}},M=l({method:`GET`}).middleware([c]).handler(a(`b4bf4c461903edcdc44eea52468c737b5b600a586f542138ff022dcbbe86c45c`));function N(e){let t=e.map(({releaseId:e,platform:t,channel:n})=>({releaseId:e,platform:t,channel:n})).sort((e,t)=>e.releaseId.localeCompare(t.releaseId));return s({queryKey:[`bundle-activity`,t],queryFn:()=>M({data:t}),enabled:t.length>0,staleTime:3e4})}var P=[{label:`Downloaded`,field:`downloads`,color:`text-primary/85`},{label:`Launched`,field:`launched`,color:`text-success/85`},{label:`Crashed`,field:`failedLaunches`,color:`text-warning/85`}],F=e=>{let t=e.launched+e.failedLaunches;return t===0?`—`:`${(e.failedLaunches/t*100).toFixed(2)}%`},I=e=>Math.max(0,e.downloads-e.launched-e.failedLaunches);function L(){return(0,A.jsx)(D,{label:`About release insight metrics`,children:`Downloaded: got this bundle. Launched: ran it. Crashed: crashed on it and rolled back. Once every installation restarts, Downloaded = Launched + Crashed.`})}function R({report:e,loading:r=!1,input:i,variant:a=`inline`}){if(!e)return r?(0,A.jsx)(n,{"aria-label":`Loading release insights`,className:a===`card`?`h-16 w-full`:`h-4 w-40`}):(0,A.jsx)(`span`,{"aria-label":`Release insights unavailable`,className:`text-sm text-muted-foreground`,children:`—`});let o=i?.builtIn===!0,s=o?0:I(e),c=(0,A.jsx)(`dl`,{className:t(a===`card`?`grid grid-cols-[1fr_1fr_auto] gap-4`:`flex min-w-[220px] flex-wrap items-baseline gap-x-3 gap-y-1`),children:P.map(({label:n,field:r,color:i})=>(0,A.jsxs)(`div`,{className:t(`flex`,a===`card`?`min-w-0 flex-col gap-1`:`items-baseline gap-1.5 whitespace-nowrap`),children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n}),(0,A.jsxs)(`dd`,{className:t(`flex flex-wrap items-baseline gap-x-1.5 tabular-nums`,a===`card`?`text-xl font-semibold`:`text-sm font-medium`,e[r]>0&&!(r===`downloads`&&o)?i:`text-muted-foreground`),children:[r===`downloads`&&o?(0,A.jsx)(`span`,{title:`The built-in bundle is never downloaded`,children:`—`}):e[r].toLocaleString(),r===`failedLaunches`?(0,A.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,F(e),`)`]}):null]})]},r))});return(0,A.jsxs)(`div`,{className:t(`flex`,a===`card`?`flex-col gap-2`:`items-center gap-1`),children:[i?(0,A.jsx)(f,{className:`min-w-0 rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,to:`/insights`,search:{healthPlatform:i.platform,healthChannel:i.channel,releaseId:i.releaseId,bundleWindow:E(i.releaseId)},children:c}):c,a===`card`&&s>0?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s.toLocaleString(),` downloaded but not launched yet: waiting for a restart, or passed over for a newer bundle.`]}):null,a===`inline`?(0,A.jsx)(L,{}):null]})}function z({input:e}){let r=v({platform:e.platform,channel:e.channel,releaseId:e.releaseId}),i=r.data;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i?(0,A.jsx)(`dl`,{children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Download failures`}),(0,A.jsxs)(`dd`,{className:t(`flex items-baseline gap-1.5 text-sm font-medium tabular-nums`,i.failedUpdates>0?`text-warning/85`:`text-muted-foreground`),children:[i.failedUpdates.toLocaleString(),(0,A.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,g(_(i)),`)`]})]})]})}):r.isPending?(0,A.jsx)(n,{"aria-label":`Loading download failures`,className:`h-4 w-40`}):(0,A.jsx)(`span`,{"aria-label":`Download failures unavailable`,className:`text-sm text-muted-foreground`,children:`—`}),(0,A.jsx)(D,{label:`About download failures`,children:`Failed downloads or installs of this bundle, at most one per installation a day. Rate = failures ÷ (failures + downloads).`})]})}function B({input:t}){let n=N([t]);return(0,A.jsxs)(S,{children:[(0,A.jsxs)(C,{className:`flex-row items-center justify-between px-4 pt-4 pb-3`,children:[(0,A.jsx)(w,{className:`text-sm font-medium`,children:`Insights`}),(0,A.jsx)(L,{})]}),(0,A.jsxs)(x,{className:`flex flex-col gap-3 px-4 pb-4`,children:[(0,A.jsx)(R,{variant:`card`,input:t,loading:n.isFetching,report:n.data?.[t.releaseId]}),(0,A.jsx)(r,{}),(0,A.jsx)(z,{input:t})]}),(0,A.jsx)(b,{className:`px-4 pb-4`,children:(0,A.jsxs)(f,{className:e({variant:`outline`,size:`sm`}),to:`/insights`,search:{healthPlatform:t.platform,healthChannel:t.channel,releaseId:t.releaseId,bundleWindow:E(t.releaseId),healthChart:`adoption`},children:[(0,A.jsx)(O,{"aria-hidden":`true`,"data-icon":`inline-start`}),`View adoption`]})})]})}function V({input:e}){return d(`insightsAnalytics`)?null:(0,A.jsxs)(S,{children:[(0,A.jsx)(C,{className:`px-4 pt-4 pb-3`,children:(0,A.jsx)(w,{className:`text-sm font-medium`,children:`Insights`})}),(0,A.jsx)(x,{className:`px-4 pb-4`,children:(0,A.jsx)(z,{input:e})})]})}function H({releaseId:e,releases:t}){let n=N(t);return(0,A.jsx)(R,{input:t.find(t=>t.releaseId===e),loading:n.isFetching,report:n.data?.[e]})}var U={Cell:H},W={insights:{navigation:{icon:(0,A.jsx)(y,{}),paths:[`/insights`,`/insights/distribution`,`/installations`],link:({features:e,onClick:t})=>e.insightsAnalytics?(0,A.jsx)(f,{to:`/insights`,onClick:t}):(0,A.jsx)(f,{to:`/installations`,onClick:t})},releaseSection:({release:e})=>(0,A.jsx)(V,{input:e})},insightsAnalytics:{releaseColumn:U,releaseSection:({release:e})=>(0,A.jsx)(B,{input:e})}},G={remoteConfig:{navigation:{icon:(0,A.jsx)(te,{}),paths:[`/remote-config`],link:({onClick:e})=>(0,A.jsx)(f,{to:`/remote-config`,onClick:e})}}},K={...W,...j,...G},q=Object.keys(p),J=()=>{let e=u().data?.features;return e===void 0?[]:q.flatMap(t=>{let n=K[t];return n!==void 0&&e[t]?[{...n,feature:t,label:p[t].label,features:e}]:[]})},Y=()=>J().flatMap(({feature:e,label:t,releaseColumn:n})=>n===void 0?[]:[{...n,feature:e,label:t}]);function X({release:e}){return J().map(({feature:t,releaseSection:n})=>n===void 0?null:(0,A.jsx)(n,{release:e},t))}var Z=e=>typeof e==`string`&&e.trim().length>0?e.trim():void 0;function Q(e){let t=Z(e.beforeReleaseId),n=t?void 0:Z(e.afterReleaseId),r=e.enabled===!0||e.enabled===`true`?!0:e.enabled===!1||e.enabled===`false`?!1:void 0,i=Z(e.bundleId),a=i?void 0:Z(e.scopeKey),o=i||a?void 0:Z(e.channelId),s=o===void 0?void 0:e.platform===`android`?`android`:`ios`;return{afterReleaseId:n,beforeReleaseId:t,bundleId:i,channelId:o,enabled:a||o?r:void 0,platform:s,releaseId:Z(e.releaseId),scopeKey:a}}function $(e){let t=e.enabled===void 0?{}:{enabled:e.enabled};return e.bundleId?{kind:`bundle`,bundleId:e.bundleId}:e.scopeKey?{kind:`scope`,scopeKey:e.scopeKey,...t}:e.channelId&&e.platform?{kind:`channelPlatform`,channelId:e.channelId,platform:e.platform,...t}:{kind:`all`}}function ne(e){return $(e).kind!==`all`}function re(e,t){let n={...e,...t};return t.bundleId?Q({bundleId:n.bundleId}):t.scopeKey?Q({scopeKey:n.scopeKey,enabled:n.enabled}):`channelId`in t||`platform`in t?Q({channelId:n.channelId,enabled:n.enabled,platform:n.platform}):Q({bundleId:n.bundleId,channelId:n.channelId,enabled:n.enabled,platform:n.platform,scopeKey:n.scopeKey})}var ie=m(`/`)({component:h(()=>ee(()=>import(`./routes-Cnc-0wCf.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),`component`),validateSearch:Q});export{X as a,k as c,re as i,ne as n,J as o,$ as r,Y as s,ie as t};
|