/* WAREHOUSE 2.0 · 公司 — Swiss 版式,真後端
   平台級駕駛艙:公司清單(租戶)+ 入駐申請審批 + 行業模板。
   頁面只讀;開通/審批/停用/邀請成員等一律交秘書執行。 */
(() => {
const W2 = window.W2;
const { t } = window.W2_LANG;
window.W2_LANG.addEN({
  "多公司開通 · 租戶資料庫 · 入駐審批 · 成員維護 · 頁面只讀,操作交秘書": "Multi-company provisioning · tenant databases · signup approval · member care · read-only page, actions via Secretary",
  "開通新公司": "New company",
  "我要開通一家新公司,請追問公司名稱、企業代碼、行業模板與初始管理員(帳號、顯示名稱、密碼)後執行開通": "I want to provision a new company — ask me for company name, slug, industry template and the initial admin (username, display name, password), then execute",
  "當前帳號沒有平台管理權限": "This account has no platform admin access",
  "只有系統管理員或平台運營員能管理所有公司。": "Only system admins or platform operators can manage all companies.",
  "問秘書怎麼開通權限": "Ask Secretary about access",
  "我在公司管理頁被擋住了,提示沒有平台管理權限。幫我看看誰能授權、怎麼開通": "I'm blocked on the Companies page — no platform admin access. Find out who can grant it and how",
  "在管公司": "Companies", "家": "", "啟用中": "Active", "已停用": "Suspended", "待審批申請": "Pending signups",
  "僅授權範圍": "scoped access", "運行中": "running", "無停用": "none suspended", "無待審": "none pending",
  "讓秘書評估恢復 →": "Assess reactivation →",
  "有 {n} 家公司處於停用狀態,幫我看看哪些適合恢復、哪些該保持停用": "{n} companies are suspended — assess which should be reactivated and which should stay off",
  "交秘書逐條審 →": "Review via Secretary →",
  "把待審批的公司入駐申請逐條給我摘要與開通建議,我逐一拍板": "Summarise each pending company signup with a provisioning recommendation; I'll decide one by one",
  "入駐申請": "Signup requests", "{n} 條待審批": "{n} pending",
  "全部交秘書審一遍": "Review all via Secretary",
  "暫無待審批的入駐申請": "No pending signup requests",
  "企業在註冊頁提交入駐申請後,會第一時間出現在這裡等你拍板。": "When a business applies on the signup page, the request lands here for your decision.",
  "申請人": "Applicant", "聯繫方式": "Contact", "申請於": "Applied", "備註": "Note",
  "待審批": "Pending", "已開通": "Approved", "已駁回": "Rejected",
  "通過並開通": "Approve & provision", "駁回": "Reject",
  "審批通過公司入駐申請 #{id}「{name}」(代碼 /{slug},模板 {tpl},管理員 {admin}):開通公司並初始化租戶資料庫,完成後把管理員帳號與臨時密碼結果告訴我": "Approve company signup #{id} \"{name}\" (slug /{slug}, template {tpl}, admin {admin}): provision the company and initialise the tenant database, then report the admin account and temp password",
  "駁回公司入駐申請 #{id}「{name}」(/{slug}):請先追問我駁回理由,確認後執行": "Reject company signup #{id} \"{name}\" (/{slug}): ask me for the rejection reason first, then execute after my confirmation",
  "公司列表": "Company list", "共 {n} 家 · 點行看詳情": "{n} companies · click a row for detail",
  "搜索公司名 / 企業代碼": "Search name / slug",
  "啟用": "Active", "停用": "Suspended",
  "企業代碼": "Slug", "行業模板": "Template", "成員": "Members", "建立": "Created",
  "問這家公司近況": "Company brief",
  "公司「{name}」(/{slug})最近的使用情況怎麼樣?成員、物資、流水給我個摘要": "How is company \"{name}\" (/{slug}) doing lately? Summarise members, items and transactions",
  "停用公司「{name}」(/{slug}),其成員將無法登入;請跟我確認後執行": "Suspend company \"{name}\" (/{slug}) — its members will lose access; confirm with me, then execute",
  "恢復公司「{name}」(/{slug})的使用,請跟我確認後執行": "Reactivate company \"{name}\" (/{slug}); confirm with me, then execute",
  "還沒有公司": "No companies yet",
  "當前篩選下沒有公司": "No companies under current filter",
  "換個關鍵詞或狀態試試。": "Try a different keyword or status.",
  "對秘書說「開通一家新公司」,即可建立租戶資料庫與初始管理員。": "Tell the Secretary \"provision a new company\" to create the tenant database and initial admin.",
  "開通第一家公司": "Provision the first company",
  "開通公司時選用 · 決定初始分類與提示詞範圍": "Chosen at provisioning · seeds categories & prompt scope",
  "用此模板開通": "Provision with this",
  "用行業模板「{name}」({key})開通一家新公司,請追問公司名稱、企業代碼與初始管理員後執行": "Provision a new company with industry template \"{name}\" ({key}) — ask me for company name, slug and initial admin, then execute",
  "模板清單暫時拉不到,不影響開通;直接吩咐秘書即可。": "Template list unavailable right now — provisioning still works, just tell the Secretary.",
  "載入中…": "Loading…",
  "用戶": "Users", "物資數": "Items", "倉庫數": "Warehouses", "流水筆數": "Transactions",
  "建立於": "Created", "資料庫": "Database",
  "成員({n})": "Members ({n})", "暫無成員": "No members yet",
  "重置密碼": "Reset password",
  "重置公司「{co}」成員「{name}(@{u})」的登入密碼,生成一次性臨時密碼給我": "Reset the password of member \"{name}\" (@{u}) in company \"{co}\" and give me the one-time temp password",
  "邀請成員": "Invite member",
  "邀請新成員加入公司「{name}」(/{slug}),請追問帳號、顯示名稱與角色後辦理": "Invite a new member to company \"{name}\" (/{slug}) — ask me for username, display name and role, then proceed",
  "修改公司資料": "Edit company",
  "修改公司「{name}」(/{slug})的名稱或行業模板,請追問要改成什麼後執行": "Edit company \"{name}\" (/{slug}) — name or industry template; ask me for the new values, then execute",
  "停用公司": "Suspend company", "恢復公司": "Reactivate company",
  "平台上現在有哪些公司最活躍?哪些長期閒置?給我一份經營摘要": "Which companies are most active on the platform and which sit idle? Give me an operations brief",
  "問平台概況": "Platform brief",
});
const { useState: _s, useEffect: _e, useMemo: _mm } = React;
const { Icon: I, Btn: B, Tag: T, Label: LB, Empty: EM, Kpi, Folio, Band, pad2, num } = W2;
const ask = (p) => W2.openSecretary(p);

const day = (s) => (s ? String(s).slice(0, 10) : "—");
const ST_TENANT = { active: ["ok", "啟用"], suspended: ["bad", "停用"] };
const ST_SIGNUP = { pending: ["warn", "待審批"], approved: ["ok", "已開通"], rejected: ["plain", "已駁回"] };
const StTag = (map) => ({ st }) => {
  const [tone, label] = map[st] || ["plain", st || "—"];
  return <T tone={tone} dot={tone !== "plain"}>{t(label)}</T>;
};
const TenantTag = StTag(ST_TENANT);
const SignupTag = StTag(ST_SIGNUP);

/* ── 公司詳情抽屜(/detail 按需拉取,防禦性)── */
const CoDrawer = ({ co, onClose }) => {
  const [d, setD] = _s(null);
  _e(() => {
    setD(null);
    W2.json("/api/platform/tenants/" + encodeURIComponent(co.slug || "") + "/detail").then(setD).catch(() => setD({}));
  }, [co.slug]);
  const ten = (d && d.tenant) || {};
  const stx = (d && d.stats) || {};
  const members = d && Array.isArray(d.members) ? d.members : [];
  const name = ten.name || co.name || "—";
  const slug = ten.slug || co.slug || "—";
  const status = ten.status || co.status || "active";
  const activeCo = status === "active";
  const v = (x) => (x == null ? "—" : x);
  const acts = [
    ["user", "邀請成員", t("邀請新成員加入公司「{name}」(/{slug}),請追問帳號、顯示名稱與角色後辦理", { name, slug })],
    ["gear", "修改公司資料", t("修改公司「{name}」(/{slug})的名稱或行業模板,請追問要改成什麼後執行", { name, slug })],
    activeCo
      ? ["x", "停用公司", t("停用公司「{name}」(/{slug}),其成員將無法登入;請跟我確認後執行", { name, slug })]
      : ["check", "恢復公司", t("恢復公司「{name}」(/{slug})的使用,請跟我確認後執行", { name, slug })],
    ["sparkle", "問這家公司近況", t("公司「{name}」(/{slug})最近的使用情況怎麼樣?成員、物資、流水給我個摘要", { name, slug })],
  ];
  return (
    <div className="drawer">
      <div style={{ padding: "16px 18px", borderBottom: "2px solid var(--rule)" }}>
        <div className="row spread" style={{ marginBottom: 10 }}>
          <TenantTag st={status}/>
          <button className="btn ghost sm" style={{ padding: "0 7px" }} onClick={onClose} title="Esc"><I name="x" size={13}/></button>
        </div>
        <div style={{ fontSize: 19, fontWeight: 750, letterSpacing: "-.025em", lineHeight: 1.25 }}>{name}</div>
        <div className="num muted" style={{ fontSize: 11.5, marginTop: 5 }}>/{slug}{(ten.template_name || co.template_name) ? " · " + (ten.template_name || co.template_name) : ""}</div>
      </div>
      <div style={{ padding: 18, maxHeight: "calc(100vh - 280px)", overflowY: "auto" }}>
        {d === null && <div className="muted" style={{ fontSize: 12.5, marginBottom: 14 }}>{t("載入中…")}</div>}
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14, marginBottom: 18 }}>
          {[[t("成員"), v(stx.members)], [t("用戶"), v(stx.users)], [t("物資數"), v(stx.items)], [t("倉庫數"), v(stx.warehouses)], [t("流水筆數"), v(stx.transactions)], [t("建立於"), day(ten.created_at || co.created_at)]].map(([k, val]) => (
            <div key={k} className="col g4" style={{ borderTop: "1px solid var(--hair)", paddingTop: 8 }}>
              <LB dim style={{ fontSize: 8.5 }}>{k}</LB>
              <span className="num" style={{ fontSize: 14, fontWeight: 650 }}>{val}</span>
            </div>
          ))}
        </div>
        <LB dim style={{ fontSize: 8.5, marginBottom: 8 }}>{t("成員({n})", { n: members.length })}</LB>
        <div style={{ borderTop: "1px solid var(--hair)", marginBottom: 18 }}>
          {!members.length && <div className="muted" style={{ fontSize: 12, padding: "10px 0" }}>{t("暫無成員")}</div>}
          {members.map((m, i) => (
            <div key={m.global_user_id || i} className="row g10" style={{ padding: "9px 0", borderBottom: "1px solid var(--hair-soft)" }}>
              <div className="col g2" style={{ flex: 1, minWidth: 0 }}>
                <span style={{ fontWeight: 650, fontSize: 12.5 }}>{m.display_name || m.username || "—"}</span>
                <span className="num muted" style={{ fontSize: 10.5 }}>@{m.username || "—"}{m.role ? " · " + m.role : ""}</span>
              </div>
              {m.status === "active" ? <T tone="ok" dot>{t("啟用")}</T> : <T tone="plain">{m.status || "—"}</T>}
              <button className="btn sm" title={t("重置密碼")} style={{ padding: "0 8px" }}
                onClick={() => ask(t("重置公司「{co}」成員「{name}(@{u})」的登入密碼,生成一次性臨時密碼給我", { co: name, name: m.display_name || m.username || "—", u: m.username || "—" }))}>
                <I name="shield" size={12}/>
              </button>
            </div>
          ))}
        </div>
        <LB dim style={{ fontSize: 8.5, marginBottom: 8 }}>{t("直接吩咐秘書")}</LB>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }}>
          {acts.map(([icon, label, prompt]) => (
            <button key={label} className="btn" style={{ height: 40, justifyContent: "flex-start", fontSize: 12.5 }} onClick={() => ask(prompt)}>
              <I name={icon} size={14}/>{t(label)}
            </button>
          ))}
        </div>
        <div className="muted" style={{ fontSize: 10.5, marginTop: 12, lineHeight: 1.6 }}>{t("2.0 約定:頁面只讀,改動經秘書確認執行,全程留痕。")}</div>
      </div>
    </div>
  );
};

/* ── 主頁 ── */
const Page = () => {
  const [tenants, setTenants] = _s(null);       // null = 載入中
  const [scopeFull, setScopeFull] = _s(true);
  const [signups, setSignups] = _s([]);
  const [pending, setPending] = _s(0);
  const [templates, setTemplates] = _s([]);
  const [deny, setDeny] = _s(false);
  const [q, setQ] = _s("");
  const [st, setSt] = _s("all");
  const [sel, setSel] = _s(null);
  const [tick, setTick] = _s(0);

  _e(() => {
    W2.json("/api/platform/tenants")
      .then((d) => { setTenants(Array.isArray(d.tenants) ? d.tenants : []); setScopeFull(d.scope_full !== false); setDeny(false); })
      .catch(() => { setTenants([]); setDeny(true); });
    W2.json("/api/platform/signups?status=pending")
      .then((d) => { setSignups(Array.isArray(d.signups) ? d.signups : []); setPending(num(d.pending_count) || (Array.isArray(d.signups) ? d.signups.length : 0)); })
      .catch(() => {});
    W2.json("/api/platform/templates")
      .then((d) => setTemplates(Array.isArray(d.templates) ? d.templates : []))
      .catch(() => {});
  }, [tick]);
  _e(() => {
    const h = (e) => { if (e.key === "Escape") setSel(null); };
    window.addEventListener("keydown", h);
    return () => window.removeEventListener("keydown", h);
  }, []);

  const all = tenants || [];
  const actives = all.filter((c) => (c.status || "active") === "active");
  const suspended = all.filter((c) => c.status === "suspended");
  const list = _mm(() => {
    let arr = all;
    if (st === "active") arr = actives;
    if (st === "suspended") arr = suspended;
    if (q) {
      const k = q.toLowerCase();
      arr = arr.filter((c) => ((c.name || "") + (c.slug || "") + (c.template_name || "") + (c.industry_template || "")).toLowerCase().includes(k));
    }
    return arr;
  }, [tenants, st, q]);

  const folio = (
    <Folio no="17" en="COMPANIES" title={t("公司")}
      sub={t("多公司開通 · 租戶資料庫 · 入駐審批 · 成員維護 · 頁面只讀,操作交秘書")}
      right={<>
        <B icon="refresh" onClick={() => setTick((x) => x + 1)}>{t("刷新")}</B>
        <B icon="sparkle" onClick={() => ask(t("平台上現在有哪些公司最活躍?哪些長期閒置?給我一份經營摘要"))}>{t("問平台概況")}</B>
        <B kind="primary" icon="plus" onClick={() => ask(t("我要開通一家新公司,請追問公司名稱、企業代碼、行業模板與初始管理員(帳號、顯示名稱、密碼)後執行開通"))}>{t("開通新公司")}</B>
      </>}/>
  );

  if (deny) return (
    <>
      {folio}
      <div className="rise" style={{ animationDelay: ".05s" }}>
        <EM icon="shield" title={t("當前帳號沒有平台管理權限")}
          sub={t("只有系統管理員或平台運營員能管理所有公司。")}
          action={<B icon="sparkle" onClick={() => ask(t("我在公司管理頁被擋住了,提示沒有平台管理權限。幫我看看誰能授權、怎麼開通"))}>{t("問秘書怎麼開通權限")}</B>}/>
      </div>
    </>
  );

  return (
    <>
      {folio}

      <div className="kpi-band">
        <Kpi label={t("在管公司")} value={all.length} unit={t("家")} delay={0}
          foot={scopeFull ? <T tone="plain">PLATFORM</T> : <T tone="warn">{t("僅授權範圍")}</T>}/>
        <Kpi label={t("啟用中")} value={actives.length} unit={t("家")} delay={.05}
          foot={actives.length ? <T tone="ok" dot>{t("運行中")}</T> : <span className="muted" style={{ fontSize: 11.5 }}>—</span>}/>
        <Kpi label={t("已停用")} value={suspended.length} unit={t("家")} delay={.1}
          foot={suspended.length
            ? <button className="tag warn" style={{ cursor: "pointer" }} onClick={() => ask(t("有 {n} 家公司處於停用狀態,幫我看看哪些適合恢復、哪些該保持停用", { n: suspended.length }))}>{t("讓秘書評估恢復 →")}</button>
            : <T tone="ok" dot>{t("無停用")}</T>}/>
        <Kpi label={t("待審批申請")} value={pending} unit={t("條")} red={pending > 0} delay={.15}
          foot={pending
            ? <button className="tag redinv" style={{ cursor: "pointer" }} onClick={() => ask(t("把待審批的公司入駐申請逐條給我摘要與開通建議,我逐一拍板"))}>{t("交秘書逐條審 →")}</button>
            : <T tone="ok" dot>{t("無待審")}</T>}/>
      </div>

      <Band no="01" title={t("入駐申請")} sub={signups.length ? t("{n} 條待審批", { n: signups.length }) : null} delay={.1}
        right={!!signups.length && <B size="sm" icon="sparkle" onClick={() => ask(t("把待審批的公司入駐申請逐條給我摘要與開通建議,我逐一拍板"))}>{t("全部交秘書審一遍")}</B>}>
        {!signups.length
          ? <EM icon="clipboard" title={t("暫無待審批的入駐申請")} sub={t("企業在註冊頁提交入駐申請後,會第一時間出現在這裡等你拍板。")}/>
          : <div style={{ borderTop: "2px solid var(--rule)" }}>
              {signups.map((s, i) => (
                <div key={s.id || i} className="ledger-row">
                  <span className="lr-idx">{pad2(i + 1)}</span>
                  <div className="col g4" style={{ flex: 1.6, minWidth: 0 }}>
                    <div className="row g10 wrap">
                      <span style={{ fontWeight: 700, fontSize: 13.5 }}>{s.company_name || "—"}</span>
                      <span className="num muted" style={{ fontSize: 11 }}>/{s.slug || "—"}</span>
                      <SignupTag st={s.status || "pending"}/>
                    </div>
                    <div className="muted" style={{ fontSize: 11.5, lineHeight: 1.55 }}>
                      {t("申請人")} {s.admin_display_name || "—"} <span className="num">@{s.admin_username || "—"}</span> · {t("聯繫方式")} {s.contact || "—"} · {t("申請於")} <span className="num">{day(s.created_at)}</span>
                      {s.reason ? <> · {t("備註")} {s.reason}</> : null}
                    </div>
                  </div>
                  <T tone="plain">{s.template_name || s.industry_template || "—"}</T>
                  <div className="row g6">
                    <B size="sm" kind="primary" onClick={() => ask(t("審批通過公司入駐申請 #{id}「{name}」(代碼 /{slug},模板 {tpl},管理員 {admin}):開通公司並初始化租戶資料庫,完成後把管理員帳號與臨時密碼結果告訴我", { id: s.id != null ? s.id : "—", name: s.company_name || "—", slug: s.slug || "—", tpl: s.template_name || s.industry_template || "—", admin: (s.admin_display_name || "—") + " @" + (s.admin_username || "—") }))}>{t("通過並開通")}</B>
                    <B size="sm" kind="red" onClick={() => ask(t("駁回公司入駐申請 #{id}「{name}」(/{slug}):請先追問我駁回理由,確認後執行", { id: s.id != null ? s.id : "—", name: s.company_name || "—", slug: s.slug || "—" }))}>{t("駁回")}</B>
                  </div>
                </div>
              ))}
            </div>}
      </Band>

      <div style={{ display: "flex", gap: 24, alignItems: "flex-start" }}>
        <div style={{ flex: 1, minWidth: 0 }}>
          <Band no="02" title={t("公司列表")} sub={t("共 {n} 家 · 點行看詳情", { n: all.length })} delay={.15}
            right={<div className="row g10 wrap">
              <div style={{ position: "relative", minWidth: 200 }}>
                <I name="search" size={13} color="var(--ink-4)" style={{ position: "absolute", left: 0, top: "50%", transform: "translateY(-50%)" }}/>
                <input className="field" style={{ paddingLeft: 22, height: 32, fontSize: 12.5 }} value={q} onChange={(e) => setQ(e.target.value)} placeholder={t("搜索公司名 / 企業代碼")}/>
              </div>
              <div className="seg">
                {[["all", "全部"], ["active", "啟用"], ["suspended", "停用"]].map(([id, label]) => (
                  <button key={id} className={st === id ? "on" : ""} onClick={() => setSt(id)}>{t(label)}</button>
                ))}
              </div>
            </div>}>
            {tenants === null
              ? <div className="muted" style={{ fontSize: 12.5, padding: "18px 0" }}>{t("載入中…")}</div>
              : !list.length
                ? <EM icon="building"
                    title={all.length ? t("當前篩選下沒有公司") : t("還沒有公司")}
                    sub={all.length ? t("換個關鍵詞或狀態試試。") : t("對秘書說「開通一家新公司」,即可建立租戶資料庫與初始管理員。")}
                    action={!all.length && <B kind="primary" icon="sparkle" onClick={() => ask(t("我要開通一家新公司,請追問公司名稱、企業代碼、行業模板與初始管理員(帳號、顯示名稱、密碼)後執行開通"))}>{t("開通第一家公司")}</B>}/>
                : <div style={{ overflowX: "auto" }}>
                    <table className="tbl2">
                      <thead><tr>
                        <th>{t("公司")}</th><th>{t("企業代碼")}</th><th>{t("行業模板")}</th><th>{t("成員")}</th><th>{t("建立")}</th><th>{t("狀態")}</th><th style={{ width: 110 }}>{t("交給秘書")}</th>
                      </tr></thead>
                      <tbody>
                        {list.map((c, i) => (
                          <tr key={c.id || c.slug || i} className={sel && sel.slug === c.slug ? "on" : ""} onClick={() => setSel(c)} style={{ cursor: "pointer" }}>
                            <td><span style={{ fontWeight: 650 }}>{c.name || "—"}</span></td>
                            <td><span className="num muted">/{c.slug || "—"}</span></td>
                            <td className="muted">{c.template_name || c.industry_template || "—"}</td>
                            <td><span className="num" style={{ fontWeight: 700, fontSize: 15 }}>{c.member_count != null ? c.member_count : "—"}</span></td>
                            <td><span className="num muted" style={{ fontSize: 12 }}>{day(c.created_at)}</span></td>
                            <td><TenantTag st={c.status || "active"}/></td>
                            <td onClick={(e) => e.stopPropagation()}>
                              <div className="row g4">
                                <button className="btn sm" title={t("問這家公司近況")} style={{ padding: "0 8px" }}
                                  onClick={() => ask(t("公司「{name}」(/{slug})最近的使用情況怎麼樣?成員、物資、流水給我個摘要", { name: c.name || "—", slug: c.slug || "—" }))}><I name="sparkle" size={12}/></button>
                                {(c.status || "active") === "active"
                                  ? <button className="btn sm" title={t("停用公司")} style={{ padding: "0 8px" }}
                                      onClick={() => ask(t("停用公司「{name}」(/{slug}),其成員將無法登入;請跟我確認後執行", { name: c.name || "—", slug: c.slug || "—" }))}><I name="x" size={12}/></button>
                                  : <button className="btn sm" title={t("恢復公司")} style={{ padding: "0 8px" }}
                                      onClick={() => ask(t("恢復公司「{name}」(/{slug})的使用,請跟我確認後執行", { name: c.name || "—", slug: c.slug || "—" }))}><I name="check" size={12}/></button>}
                              </div>
                            </td>
                          </tr>
                        ))}
                      </tbody>
                    </table>
                  </div>}
          </Band>

          <Band no="03" title={t("行業模板")} sub={t("開通公司時選用 · 決定初始分類與提示詞範圍")} delay={.2}>
            {!templates.length
              ? <div className="muted" style={{ fontSize: 12.5, padding: "12px 0" }}>{t("模板清單暫時拉不到,不影響開通;直接吩咐秘書即可。")}</div>
              : <div style={{ borderTop: "2px solid var(--rule)" }}>
                  {templates.map((tp, i) => (
                    <div key={tp.key || i} className="ledger-row">
                      <span className="lr-idx">{pad2(i + 1)}</span>
                      <div className="col g4" style={{ flex: 1, minWidth: 0 }}>
                        <div className="row g10">
                          <span style={{ fontWeight: 650, fontSize: 13.5 }}>{tp.name || "—"}</span>
                          <span className="num muted" style={{ fontSize: 10.5 }}>{tp.key || "—"}</span>
                        </div>
                        {tp.description && <div className="muted" style={{ fontSize: 11.5, lineHeight: 1.55 }}>{tp.description}</div>}
                      </div>
                      <B size="sm" icon="plus" onClick={() => ask(t("用行業模板「{name}」({key})開通一家新公司,請追問公司名稱、企業代碼與初始管理員後執行", { name: tp.name || "—", key: tp.key || "—" }))}>{t("用此模板開通")}</B>
                    </div>
                  ))}
                </div>}
          </Band>
        </div>

        {sel && <CoDrawer co={sel} onClose={() => setSel(null)}/>}
      </div>
    </>
  );
};

window.W2.PAGES["companies"] = Page;
})();
